@llamaindex/workflow-debugger 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -620,7 +620,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
620
620
  +`).split(`
621
621
  `)),p=u.reduce((f,m)=>f.concat(...m),[]);return[u,p]}return[[],[]]},[t]);return D.useEffect(()=>{const l=(e==null?void 0:e.target)??yne,u=(e==null?void 0:e.actInsideInputWithModifier)??!0;if(t!==null){const p=g=>{var y,v;if(a.current=g.ctrlKey||g.metaKey||g.shiftKey||g.altKey,(!a.current||a.current&&!u)&&Lte(g))return!1;const E=Tne(g.code,o);if(i.current.add(g[E]),vne(s,i.current,!1)){const A=((v=(y=g.composedPath)==null?void 0:y.call(g))==null?void 0:v[0])||g.target,T=(A==null?void 0:A.nodeName)==="BUTTON"||(A==null?void 0:A.nodeName)==="A";e.preventDefault!==!1&&(a.current||!T)&&g.preventDefault(),r(!0)}},f=g=>{const S=Tne(g.code,o);vne(s,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(g[S]),g.key==="Meta"&&i.current.clear(),a.current=!1},m=()=>{i.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",p),l==null||l.addEventListener("keyup",f),window.addEventListener("blur",m),window.addEventListener("contextmenu",m),()=>{l==null||l.removeEventListener("keydown",p),l==null||l.removeEventListener("keyup",f),window.removeEventListener("blur",m),window.removeEventListener("contextmenu",m)}}},[t,r]),n}function vne(t,e,n){return t.filter(r=>n||r.length===e.size).some(r=>r.every(a=>e.has(a)))}function Tne(t,e){return e.includes(t)?"code":"key"}const eBe=()=>{const t=gr();return D.useMemo(()=>({zoomIn:e=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1.2,{duration:e==null?void 0:e.duration}):Promise.resolve(!1)},zoomOut:e=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1/1.2,{duration:e==null?void 0:e.duration}):Promise.resolve(!1)},zoomTo:(e,n)=>{const{panZoom:r}=t.getState();return r?r.scaleTo(e,{duration:n==null?void 0:n.duration}):Promise.resolve(!1)},getZoom:()=>t.getState().transform[2],setViewport:async(e,n)=>{const{transform:[r,a,i],panZoom:s}=t.getState();return s?(await s.setViewport({x:e.x??r,y:e.y??a,zoom:e.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[e,n,r]=t.getState().transform;return{x:e,y:n,zoom:r}},setCenter:async(e,n,r)=>t.getState().setCenter(e,n,r),fitBounds:async(e,n)=>{const{width:r,height:a,minZoom:i,maxZoom:s,panZoom:o}=t.getState(),l=v3(e,r,a,i,s,(n==null?void 0:n.padding)??.1);return o?(await o.setViewport(l,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(e,n={})=>{const{transform:r,snapGrid:a,snapToGrid:i,domNode:s}=t.getState();if(!s)return e;const{x:o,y:l}=s.getBoundingClientRect(),u={x:e.x-o,y:e.y-l},p=n.snapGrid??a,f=n.snapToGrid??i;return C0(u,r,f,p)},flowToScreenPosition:e=>{const{transform:n,domNode:r}=t.getState();if(!r)return e;const{x:a,y:i}=r.getBoundingClientRect(),s=oA(e,n);return{x:s.x+a,y:s.y+i}}}),[])};function Ane(t,e){const n=[],r=new Map,a=[];for(const i of t)if(i.type==="add"){a.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const s=r.get(i.id);s?s.push(i):r.set(i.id,[i])}for(const i of e){const s=r.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const o={...i};for(const l of s)tBe(l,o);n.push(o)}return a.length&&a.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function tBe(t,e){switch(t.type){case"select":{e.selected=t.selected;break}case"position":{typeof t.position<"u"&&(e.position=t.position),typeof t.dragging<"u"&&(e.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(e.measured??(e.measured={}),e.measured.width=t.dimensions.width,e.measured.height=t.dimensions.height,t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(e.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(e.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(e.resizing=t.resizing);break}}}function Cne(t,e){return Ane(t,e)}function Rne(t,e){return Ane(t,e)}function sf(t,e){return{id:t,type:"select",selected:e}}function $h(t,e=new Set,n=!1){const r=[];for(const[a,i]of t){const s=e.has(a);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),r.push(sf(i.id,s)))}return r}function Nne({items:t=[],lookup:e}){var a;const n=[],r=new Map(t.map(i=>[i.id,i]));for(const[i,s]of t.entries()){const o=e.get(s.id),l=((a=o==null?void 0:o.internals)==null?void 0:a.userNode)??o;l!==void 0&&l!==s&&n.push({id:s.id,item:s,type:"replace"}),l===void 0&&n.push({item:s,type:"add",index:i})}for(const[i]of e)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function wne(t){return{id:t.id,type:"remove"}}const xne=t=>wFe(t),nBe=t=>Ate(t);function One(t){return D.forwardRef(t)}const rBe=typeof window<"u"?D.useLayoutEffect:D.useEffect;function Ine(t){const[e,n]=D.useState(BigInt(0)),[r]=D.useState(()=>aBe(()=>n(a=>a+BigInt(1))));return rBe(()=>{const a=r.get();a.length&&(t(a),r.reset())},[e]),r}function aBe(t){let e=[];return{get:()=>e,reset:()=>{e=[]},push:n=>{e.push(n),t()}}}const Dne=D.createContext(null);function iBe({children:t}){const e=gr(),n=D.useCallback(o=>{const{nodes:l=[],setNodes:u,hasDefaultNodes:p,onNodesChange:f,nodeLookup:m,fitViewQueued:g}=e.getState();let S=l;for(const y of o)S=typeof y=="function"?y(S):y;const E=Nne({items:S,lookup:m});p&&u(S),E.length>0?f==null||f(E):g&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:v,setNodes:A}=e.getState();y&&A(v)})},[]),r=Ine(n),a=D.useCallback(o=>{const{edges:l=[],setEdges:u,hasDefaultEdges:p,onEdgesChange:f,edgeLookup:m}=e.getState();let g=l;for(const S of o)g=typeof S=="function"?S(g):S;p?u(g):f&&f(Nne({items:g,lookup:m}))},[]),i=Ine(a),s=D.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return N.jsx(Dne.Provider,{value:s,children:t})}function sBe(){const t=D.useContext(Dne);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const oBe=t=>!!t.panZoom;function F3(){const t=eBe(),e=gr(),n=sBe(),r=un(oBe),a=D.useMemo(()=>{const i=f=>e.getState().nodeLookup.get(f),s=f=>{n.nodeQueue.push(f)},o=f=>{n.edgeQueue.push(f)},l=f=>{var v,A;const{nodeLookup:m,nodeOrigin:g}=e.getState(),S=xne(f)?f:m.get(f.id),E=S.parentId?Dte(S.position,S.measured,S.parentId,m,g):S.position,y={...S,position:E,width:((v=S.measured)==null?void 0:v.width)??S.width,height:((A=S.measured)==null?void 0:A.height)??S.height};return Uh(y)},u=(f,m,g={replace:!1})=>{s(S=>S.map(E=>{if(E.id===f){const y=typeof m=="function"?m(E):m;return g.replace&&xne(y)?y:{...E,...y}}return E}))},p=(f,m,g={replace:!1})=>{o(S=>S.map(E=>{if(E.id===f){const y=typeof m=="function"?m(E):m;return g.replace&&nBe(y)?y:{...E,...y}}return E}))};return{getNodes:()=>e.getState().nodes.map(f=>({...f})),getNode:f=>{var m;return(m=i(f))==null?void 0:m.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:f=[]}=e.getState();return f.map(m=>({...m}))},getEdge:f=>e.getState().edgeLookup.get(f),setNodes:s,setEdges:o,addNodes:f=>{const m=Array.isArray(f)?f:[f];n.nodeQueue.push(g=>[...g,...m])},addEdges:f=>{const m=Array.isArray(f)?f:[f];n.edgeQueue.push(g=>[...g,...m])},toObject:()=>{const{nodes:f=[],edges:m=[],transform:g}=e.getState(),[S,E,y]=g;return{nodes:f.map(v=>({...v})),edges:m.map(v=>({...v})),viewport:{x:S,y:E,zoom:y}}},deleteElements:async({nodes:f=[],edges:m=[]})=>{const{nodes:g,edges:S,onNodesDelete:E,onEdgesDelete:y,triggerNodeChanges:v,triggerEdgeChanges:A,onDelete:T,onBeforeDelete:w}=e.getState(),{nodes:O,edges:R}=await kFe({nodesToRemove:f,edgesToRemove:m,nodes:g,edges:S,onBeforeDelete:w}),I=R.length>0,L=O.length>0;if(I){const P=R.map(wne);y==null||y(R),A(P)}if(L){const P=O.map(wne);E==null||E(O),v(P)}return(L||I)&&(T==null||T({nodes:O,edges:R})),{deletedNodes:O,deletedEdges:R}},getIntersectingNodes:(f,m=!0,g)=>{const S=Ote(f),E=S?f:l(f),y=g!==void 0;return E?(g||e.getState().nodes).filter(v=>{const A=e.getState().nodeLookup.get(v.id);if(A&&!S&&(v.id===f.id||!A.internals.positionAbsolute))return!1;const T=Uh(y?v:A),w=T0(T,E);return m&&w>0||w>=T.width*T.height||w>=E.width*E.height}):[]},isNodeIntersecting:(f,m,g=!0)=>{const E=Ote(f)?f:l(f);if(!E)return!1;const y=T0(E,m);return g&&y>0||y>=m.width*m.height||y>=E.width*E.height},updateNode:u,updateNodeData:(f,m,g={replace:!1})=>{u(f,S=>{const E=typeof m=="function"?m(S):m;return g.replace?{...S,data:E}:{...S,data:{...S.data,...E}}},g)},updateEdge:p,updateEdgeData:(f,m,g={replace:!1})=>{p(f,S=>{const E=typeof m=="function"?m(S):m;return g.replace?{...S,data:E}:{...S,data:{...S.data,...E}}},g)},getNodesBounds:f=>{const{nodeLookup:m,nodeOrigin:g}=e.getState();return xFe(f,{nodeLookup:m,nodeOrigin:g})},getHandleConnections:({type:f,id:m,nodeId:g})=>{var S;return Array.from(((S=e.getState().connectionLookup.get(`${g}-${f}${m?`-${m}`:""}`))==null?void 0:S.values())??[])},getNodeConnections:({type:f,handleId:m,nodeId:g})=>{var S;return Array.from(((S=e.getState().connectionLookup.get(`${g}${f?m?`-${f}-${m}`:`-${f}`:""}`))==null?void 0:S.values())??[])},fitView:async f=>{const m=e.getState().fitViewResolver??FFe();return e.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:m}),n.nodeQueue.push(g=>[...g]),m.promise}}},[]);return D.useMemo(()=>({...a,...t,viewportInitialized:r}),[r])}const kne=t=>t.selected,lBe=typeof window<"u"?window:void 0;function cBe({deleteKeyCode:t,multiSelectionKeyCode:e}){const n=gr(),{deleteElements:r}=F3(),a=x0(t,{actInsideInputWithModifier:!1}),i=x0(e,{target:lBe});D.useEffect(()=>{if(a){const{edges:s,nodes:o}=n.getState();r({nodes:o.filter(kne),edges:s.filter(kne)}),n.setState({nodesSelectionActive:!1})}},[a]),D.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function uBe(t){const e=gr();D.useEffect(()=>{const n=()=>{var a,i,s,o;if(!t.current||!(((i=(a=t.current).checkVisibility)==null?void 0:i.call(a))??!0))return!1;const r=T3(t.current);(r.height===0||r.width===0)&&((o=(s=e.getState()).onError)==null||o.call(s,"004",hl.error004())),e.setState({width:r.width||500,height:r.height||500})};if(t.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(t.current),()=>{window.removeEventListener("resize",n),r&&t.current&&r.unobserve(t.current)}}},[])}const mA={position:"absolute",width:"100%",height:"100%",top:0,left:0},dBe=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function pBe({onPaneContextMenu:t,zoomOnScroll:e=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:a=.5,panOnScrollMode:i=rf.Free,zoomOnDoubleClick:s=!0,panOnDrag:o=!0,defaultViewport:l,translateExtent:u,minZoom:p,maxZoom:f,zoomActivationKeyCode:m,preventScrolling:g=!0,children:S,noWheelClassName:E,noPanClassName:y,onViewportChange:v,isControlledViewport:A,paneClickDistance:T}){const w=gr(),O=D.useRef(null),{userSelectionActive:R,lib:I,connectionInProgress:L}=un(dBe,Cr),P=x0(m),U=D.useRef();uBe(O);const H=D.useCallback(W=>{v==null||v({x:W[0],y:W[1],zoom:W[2]}),A||w.setState({transform:W})},[v,A]);return D.useEffect(()=>{if(O.current){U.current=E5e({domNode:O.current,minZoom:p,maxZoom:f,translateExtent:u,viewport:l,paneClickDistance:T,onDraggingChange:j=>w.setState({paneDragging:j}),onPanZoomStart:(j,z)=>{const{onViewportChangeStart:V,onMoveStart:X}=w.getState();X==null||X(j,z),V==null||V(z)},onPanZoom:(j,z)=>{const{onViewportChange:V,onMove:X}=w.getState();X==null||X(j,z),V==null||V(z)},onPanZoomEnd:(j,z)=>{const{onViewportChangeEnd:V,onMoveEnd:X}=w.getState();X==null||X(j,z),V==null||V(z)}});const{x:W,y:Z,zoom:F}=U.current.getViewport();return w.setState({panZoom:U.current,transform:[W,Z,F],domNode:O.current.closest(".react-flow")}),()=>{var j;(j=U.current)==null||j.destroy()}}},[]),D.useEffect(()=>{var W;(W=U.current)==null||W.update({onPaneContextMenu:t,zoomOnScroll:e,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:a,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:o,zoomActivationKeyPressed:P,preventScrolling:g,noPanClassName:y,userSelectionActive:R,noWheelClassName:E,lib:I,onTransformChange:H,connectionInProgress:L})},[t,e,n,r,a,i,s,o,P,g,y,R,E,I,H,L]),N.jsx("div",{className:"react-flow__renderer",ref:O,style:mA,children:S})}const fBe=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function mBe(){const{userSelectionActive:t,userSelectionRect:e}=un(fBe,Cr);return t&&e?N.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}const B3=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},hBe=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,connectionInProgress:t.connection.inProgress,dragging:t.paneDragging});function gBe({isSelecting:t,selectionKeyPressed:e,selectionMode:n=S0.Full,panOnDrag:r,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:p,onPaneMouseMove:f,onPaneMouseLeave:m,children:g}){const S=gr(),{userSelectionActive:E,elementsSelectable:y,dragging:v,connectionInProgress:A}=un(hBe,Cr),T=y&&(t||E),w=D.useRef(null),O=D.useRef(),R=D.useRef(new Set),I=D.useRef(new Set),L=D.useRef(!1),P=D.useRef(!1),U=V=>{if(L.current||A){L.current=!1;return}o==null||o(V),S.getState().resetSelectedElements(),S.setState({nodesSelectionActive:!1})},H=V=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){V.preventDefault();return}l==null||l(V)},W=u?V=>u(V):void 0,Z=V=>{var ee,B;const{resetSelectedElements:X,domNode:te}=S.getState();if(O.current=te==null?void 0:te.getBoundingClientRect(),!y||!t||V.button!==0||V.target!==w.current||!O.current)return;(B=(ee=V.target)==null?void 0:ee.setPointerCapture)==null||B.call(ee,V.pointerId),P.current=!0,L.current=!1;const{x:$,y:Q}=xo(V.nativeEvent,O.current);X(),S.setState({userSelectionRect:{width:0,height:0,startX:$,startY:Q,x:$,y:Q}}),i==null||i(V)},F=V=>{const{userSelectionRect:X,transform:te,nodeLookup:$,edgeLookup:Q,connectionLookup:ee,triggerNodeChanges:B,triggerEdgeChanges:ie,defaultEdgeOptions:ce}=S.getState();if(!O.current||!X)return;L.current=!0;const{x:se,y:ne}=xo(V.nativeEvent,O.current),{startX:oe,startY:he}=X,_e={startX:oe,startY:he,x:se<oe?se:oe,y:ne<he?ne:he,width:Math.abs(se-oe),height:Math.abs(ne-he)},Ce=R.current,Ne=I.current;R.current=new Set(S3($,_e,te,n===S0.Partial,!0).map(De=>De.id)),I.current=new Set;const Te=(ce==null?void 0:ce.selectable)??!0;for(const De of R.current){const Ye=ee.get(De);if(Ye)for(const{edgeId:qe}of Ye.values()){const ht=Q.get(qe);ht&&(ht.selectable??Te)&&I.current.add(qe)}}if(!kte(Ce,R.current)){const De=$h($,R.current,!0);B(De)}if(!kte(Ne,I.current)){const De=$h(Q,I.current);ie(De)}S.setState({userSelectionRect:_e,userSelectionActive:!0,nodesSelectionActive:!1})},j=V=>{var te,$;if(V.button!==0||!P.current)return;($=(te=V.target)==null?void 0:te.releasePointerCapture)==null||$.call(te,V.pointerId);const{userSelectionRect:X}=S.getState();!E&&X&&V.target===w.current&&(U==null||U(V)),S.setState({userSelectionActive:!1,userSelectionRect:null,nodesSelectionActive:R.current.size>0}),s==null||s(V),(e||a)&&(L.current=!1),P.current=!1},z=r===!0||Array.isArray(r)&&r.includes(0);return N.jsxs("div",{className:Zr(["react-flow__pane",{draggable:z,dragging:v,selection:t}]),onClick:T?void 0:B3(U,w),onContextMenu:B3(H,w),onWheel:B3(W,w),onPointerEnter:T?void 0:p,onPointerDown:T?Z:f,onPointerMove:T?F:f,onPointerUp:T?j:void 0,onPointerLeave:m,ref:w,style:mA,children:[g,N.jsx(mBe,{})]})}function U3({id:t,store:e,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:a,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:o,onError:l}=e.getState(),u=o.get(t);if(!u){l==null||l("012",hl.error012(t));return}e.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(i({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var p;return(p=r==null?void 0:r.current)==null?void 0:p.blur()})):a([t])}function Mne({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:r,nodeId:a,isSelectable:i,nodeClickDistance:s}){const o=gr(),[l,u]=D.useState(!1),p=D.useRef();return D.useEffect(()=>{p.current=a5e({getStoreItems:()=>o.getState(),onNodeMouseDown:f=>{U3({id:f,store:o,nodeRef:t})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),D.useEffect(()=>{var f,m;if(e)(f=p.current)==null||f.destroy();else if(t.current)return(m=p.current)==null||m.update({noDragClassName:n,handleSelector:r,domNode:t.current,isSelectable:i,nodeId:a,nodeClickDistance:s}),()=>{var g;(g=p.current)==null||g.destroy()}},[n,r,e,i,t,a]),l}const _Be=t=>e=>e.selected&&(e.draggable||t&&typeof e.draggable>"u");function Lne(){const t=gr();return D.useCallback(n=>{const{nodeExtent:r,snapToGrid:a,snapGrid:i,nodesDraggable:s,onError:o,updateNodePositions:l,nodeLookup:u,nodeOrigin:p}=t.getState(),f=new Map,m=_Be(s),g=a?i[0]:5,S=a?i[1]:5,E=n.direction.x*g*n.factor,y=n.direction.y*S*n.factor;for(const[,v]of u){if(!m(v))continue;let A={x:v.internals.positionAbsolute.x+E,y:v.internals.positionAbsolute.y+y};a&&(A=A0(A,i));const{position:T,positionAbsolute:w}=Cte({nodeId:v.id,nextPosition:A,nodeLookup:u,nodeExtent:r,nodeOrigin:p,onError:o});v.position=T,v.internals.positionAbsolute=w,f.set(v.id,v)}l(f)},[])}const G3=D.createContext(null),bBe=G3.Provider;G3.Consumer;const Pne=()=>D.useContext(G3),EBe=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),SBe=(t,e,n)=>r=>{const{connectionClickStartHandle:a,connectionMode:i,connection:s}=r,{fromHandle:o,toHandle:l,isValid:u}=s,p=(l==null?void 0:l.nodeId)===t&&(l==null?void 0:l.id)===e&&(l==null?void 0:l.type)===n;return{connectingFrom:(o==null?void 0:o.nodeId)===t&&(o==null?void 0:o.id)===e&&(o==null?void 0:o.type)===n,connectingTo:p,clickConnecting:(a==null?void 0:a.nodeId)===t&&(a==null?void 0:a.id)===e&&(a==null?void 0:a.type)===n,isPossibleEndHandle:i===Ph.Strict?(o==null?void 0:o.type)!==n:t!==(o==null?void 0:o.nodeId)||e!==(o==null?void 0:o.id),connectionInProcess:!!o,clickConnectionInProcess:!!a,valid:p&&u}};function yBe({type:t="source",position:e=mt.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:a=!0,isConnectableEnd:i=!0,id:s,onConnect:o,children:l,className:u,onMouseDown:p,onTouchStart:f,...m},g){var j,z;const S=s||null,E=t==="target",y=gr(),v=Pne(),{connectOnClick:A,noPanClassName:T,rfId:w}=un(EBe,Cr),{connectingFrom:O,connectingTo:R,clickConnecting:I,isPossibleEndHandle:L,connectionInProcess:P,clickConnectionInProcess:U,valid:H}=un(SBe(v,S,t),Cr);v||(z=(j=y.getState()).onError)==null||z.call(j,"010",hl.error010());const W=V=>{const{defaultEdgeOptions:X,onConnect:te,hasDefaultEdges:$}=y.getState(),Q={...X,...V};if($){const{edges:ee,setEdges:B}=y.getState();B(qte(Q,ee))}te==null||te(Q),o==null||o(Q)},Z=V=>{if(!v)return;const X=Pte(V.nativeEvent);if(a&&(X&&V.button===0||!X)){const te=y.getState();D3.onPointerDown(V.nativeEvent,{handleDomNode:V.currentTarget,autoPanOnConnect:te.autoPanOnConnect,connectionMode:te.connectionMode,connectionRadius:te.connectionRadius,domNode:te.domNode,nodeLookup:te.nodeLookup,lib:te.lib,isTarget:E,handleId:S,nodeId:v,flowId:te.rfId,panBy:te.panBy,cancelConnection:te.cancelConnection,onConnectStart:te.onConnectStart,onConnectEnd:te.onConnectEnd,updateConnection:te.updateConnection,onConnect:W,isValidConnection:n||te.isValidConnection,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:te.autoPanSpeed,dragThreshold:te.connectionDragThreshold})}X?p==null||p(V):f==null||f(V)},F=V=>{const{onClickConnectStart:X,onClickConnectEnd:te,connectionClickStartHandle:$,connectionMode:Q,isValidConnection:ee,lib:B,rfId:ie,nodeLookup:ce,connection:se}=y.getState();if(!v||!$&&!a)return;if(!$){X==null||X(V.nativeEvent,{nodeId:v,handleId:S,handleType:t}),y.setState({connectionClickStartHandle:{nodeId:v,type:t,id:S}});return}const ne=Mte(V.target),oe=n||ee,{connection:he,isValid:_e}=D3.isValid(V.nativeEvent,{handle:{nodeId:v,id:S,type:t},connectionMode:Q,fromNodeId:$.nodeId,fromHandleId:$.id||null,fromType:$.type,isValidConnection:oe,flowId:ie,doc:ne,lib:B,nodeLookup:ce});_e&&he&&W(he);const Ce=structuredClone(se);delete Ce.inProgress,Ce.toPosition=Ce.toHandle?Ce.toHandle.position:null,te==null||te(V,Ce),y.setState({connectionClickStartHandle:null})};return N.jsx("div",{"data-handleid":S,"data-nodeid":v,"data-handlepos":e,"data-id":`${w}-${v}-${S}-${t}`,className:Zr(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",T,u,{source:!E,target:E,connectable:r,connectablestart:a,connectableend:i,clickconnecting:I,connectingfrom:O,connectingto:R,valid:H,connectionindicator:r&&(!P||L)&&(P||U?i:a)}]),onMouseDown:Z,onTouchStart:Z,onClick:A?F:void 0,ref:g,...m,children:l})}const gl=D.memo(One(yBe));function vBe({data:t,isConnectable:e,sourcePosition:n=mt.Bottom}){return N.jsxs(N.Fragment,{children:[t==null?void 0:t.label,N.jsx(gl,{type:"source",position:n,isConnectable:e})]})}function TBe({data:t,isConnectable:e,targetPosition:n=mt.Top,sourcePosition:r=mt.Bottom}){return N.jsxs(N.Fragment,{children:[N.jsx(gl,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,N.jsx(gl,{type:"source",position:r,isConnectable:e})]})}function ABe(){return null}function CBe({data:t,isConnectable:e,targetPosition:n=mt.Top}){return N.jsxs(N.Fragment,{children:[N.jsx(gl,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label]})}const hA={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Fne={input:vBe,default:TBe,output:CBe,group:ABe};function RBe(t){var e,n,r,a;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((e=t.style)==null?void 0:e.width),height:t.height??t.initialHeight??((n=t.style)==null?void 0:n.height)}:{width:t.width??((r=t.style)==null?void 0:r.width),height:t.height??((a=t.style)==null?void 0:a.height)}}const NBe=t=>{const{width:e,height:n,x:r,y:a}=v0(t.nodeLookup,{filter:i=>!!i.selected});return{width:wo(e)?e:null,height:wo(n)?n:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${r}px,${a}px)`}};function wBe({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const r=gr(),{width:a,height:i,transformString:s,userSelectionActive:o}=un(NBe,Cr),l=Lne(),u=D.useRef(null);if(D.useEffect(()=>{var m;n||(m=u.current)==null||m.focus({preventScroll:!0})},[n]),Mne({nodeRef:u}),o||!a||!i)return null;const p=t?m=>{const g=r.getState().nodes.filter(S=>S.selected);t(m,g)}:void 0,f=m=>{Object.prototype.hasOwnProperty.call(hA,m.key)&&(m.preventDefault(),l({direction:hA[m.key],factor:m.shiftKey?4:1}))};return N.jsx("div",{className:Zr(["react-flow__nodesselection","react-flow__container",e]),style:{transform:s},children:N.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:a,height:i}})})}const Bne=typeof window<"u"?window:void 0,xBe=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Une({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:a,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:o,deleteKeyCode:l,selectionKeyCode:u,selectionOnDrag:p,selectionMode:f,onSelectionStart:m,onSelectionEnd:g,multiSelectionKeyCode:S,panActivationKeyCode:E,zoomActivationKeyCode:y,elementsSelectable:v,zoomOnScroll:A,zoomOnPinch:T,panOnScroll:w,panOnScrollSpeed:O,panOnScrollMode:R,zoomOnDoubleClick:I,panOnDrag:L,defaultViewport:P,translateExtent:U,minZoom:H,maxZoom:W,preventScrolling:Z,onSelectionContextMenu:F,noWheelClassName:j,noPanClassName:z,disableKeyboardA11y:V,onViewportChange:X,isControlledViewport:te}){const{nodesSelectionActive:$,userSelectionActive:Q}=un(xBe),ee=x0(u,{target:Bne}),B=x0(E,{target:Bne}),ie=B||L,ce=B||w,se=p&&ie!==!0,ne=ee||Q||se;return cBe({deleteKeyCode:l,multiSelectionKeyCode:S}),N.jsx(pBe,{onPaneContextMenu:i,elementsSelectable:v,zoomOnScroll:A,zoomOnPinch:T,panOnScroll:ce,panOnScrollSpeed:O,panOnScrollMode:R,zoomOnDoubleClick:I,panOnDrag:!ee&&ie,defaultViewport:P,translateExtent:U,minZoom:H,maxZoom:W,zoomActivationKeyCode:y,preventScrolling:Z,noWheelClassName:j,noPanClassName:z,onViewportChange:X,isControlledViewport:te,paneClickDistance:o,children:N.jsxs(gBe,{onSelectionStart:m,onSelectionEnd:g,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:a,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:ie,isSelecting:!!ne,selectionMode:f,selectionKeyPressed:ee,selectionOnDrag:se,children:[t,$&&N.jsx(wBe,{onSelectionContextMenu:F,noPanClassName:z,disableKeyboardA11y:V})]})})}Une.displayName="FlowRenderer";const OBe=D.memo(Une),IBe=t=>e=>t?S3(e.nodeLookup,{x:0,y:0,width:e.width,height:e.height},e.transform,!0).map(n=>n.id):Array.from(e.nodeLookup.keys());function DBe(t){return un(D.useCallback(IBe(t),[t]),Cr)}const kBe=t=>t.updateNodeInternals;function MBe(){const t=un(kBe),[e]=D.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(a=>{const i=a.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:a.target,force:!0})}),t(r)}));return D.useEffect(()=>()=>{e==null||e.disconnect()},[e]),e}function LBe({node:t,nodeType:e,hasDimensions:n,resizeObserver:r}){const a=gr(),i=D.useRef(null),s=D.useRef(null),o=D.useRef(t.sourcePosition),l=D.useRef(t.targetPosition),u=D.useRef(e),p=n&&!!t.internals.handleBounds;return D.useEffect(()=>{i.current&&!t.hidden&&(!p||s.current!==i.current)&&(s.current&&(r==null||r.unobserve(s.current)),r==null||r.observe(i.current),s.current=i.current)},[p,t.hidden]),D.useEffect(()=>()=>{s.current&&(r==null||r.unobserve(s.current),s.current=null)},[]),D.useEffect(()=>{if(i.current){const f=u.current!==e,m=o.current!==t.sourcePosition,g=l.current!==t.targetPosition;(f||m||g)&&(u.current=e,o.current=t.sourcePosition,l.current=t.targetPosition,a.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:i.current,force:!0}]])))}},[t.id,e,t.sourcePosition,t.targetPosition]),i}function PBe({id:t,onClick:e,onMouseEnter:n,onMouseMove:r,onMouseLeave:a,onContextMenu:i,onDoubleClick:s,nodesDraggable:o,elementsSelectable:l,nodesConnectable:u,nodesFocusable:p,resizeObserver:f,noDragClassName:m,noPanClassName:g,disableKeyboardA11y:S,rfId:E,nodeTypes:y,nodeClickDistance:v,onError:A}){const{node:T,internals:w,isParent:O}=un(oe=>{const he=oe.nodeLookup.get(t),_e=oe.parentLookup.has(t);return{node:he,internals:he.internals,isParent:_e}},Cr);let R=T.type||"default",I=(y==null?void 0:y[R])||Fne[R];I===void 0&&(A==null||A("003",hl.error003(R)),R="default",I=(y==null?void 0:y.default)||Fne.default);const L=!!(T.draggable||o&&typeof T.draggable>"u"),P=!!(T.selectable||l&&typeof T.selectable>"u"),U=!!(T.connectable||u&&typeof T.connectable>"u"),H=!!(T.focusable||p&&typeof T.focusable>"u"),W=gr(),Z=Ite(T),F=LBe({node:T,nodeType:R,hasDimensions:Z,resizeObserver:f}),j=Mne({nodeRef:F,disabled:T.hidden||!L,noDragClassName:m,handleSelector:T.dragHandle,nodeId:t,isSelectable:P,nodeClickDistance:v}),z=Lne();if(T.hidden)return null;const V=Ec(T),X=RBe(T),te=P||L||e||n||r||a,$=n?oe=>n(oe,{...w.userNode}):void 0,Q=r?oe=>r(oe,{...w.userNode}):void 0,ee=a?oe=>a(oe,{...w.userNode}):void 0,B=i?oe=>i(oe,{...w.userNode}):void 0,ie=s?oe=>s(oe,{...w.userNode}):void 0,ce=oe=>{const{selectNodesOnDrag:he,nodeDragThreshold:_e}=W.getState();P&&(!he||!L||_e>0)&&U3({id:t,store:W,nodeRef:F}),e&&e(oe,{...w.userNode})},se=oe=>{if(!(Lte(oe.nativeEvent)||S)){if(Ete.includes(oe.key)&&P){const he=oe.key==="Escape";U3({id:t,store:W,unselect:he,nodeRef:F})}else if(L&&T.selected&&Object.prototype.hasOwnProperty.call(hA,oe.key)){oe.preventDefault();const{ariaLabelConfig:he}=W.getState();W.setState({ariaLiveMessage:he["node.a11yDescription.ariaLiveMessage"]({direction:oe.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),z({direction:hA[oe.key],factor:oe.shiftKey?4:1})}}},ne=()=>{var De;if(S||!((De=F.current)!=null&&De.matches(":focus-visible")))return;const{transform:oe,width:he,height:_e,autoPanOnNodeFocus:Ce,setCenter:Ne}=W.getState();if(!Ce)return;S3(new Map([[t,T]]),{x:0,y:0,width:he,height:_e},oe,!0).length>0||Ne(T.position.x+V.width/2,T.position.y+V.height/2,{zoom:oe[2]})};return N.jsx("div",{className:Zr(["react-flow__node",`react-flow__node-${R}`,{[g]:L},T.className,{selected:T.selected,selectable:P,parent:O,draggable:L,dragging:j}]),ref:F,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:te?"all":"none",visibility:Z?"visible":"hidden",...T.style,...X},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:$,onMouseMove:Q,onMouseLeave:ee,onContextMenu:B,onClick:ce,onDoubleClick:ie,onKeyDown:H?se:void 0,tabIndex:H?0:void 0,onFocus:H?ne:void 0,role:T.ariaRole??(H?"group":void 0),"aria-roledescription":"node","aria-describedby":S?void 0:`${hne}-${E}`,"aria-label":T.ariaLabel,...T.domAttributes,children:N.jsx(bBe,{value:t,children:N.jsx(I,{id:t,data:T.data,type:R,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:T.selected??!1,selectable:P,draggable:L,deletable:T.deletable??!0,isConnectable:U,sourcePosition:T.sourcePosition,targetPosition:T.targetPosition,dragging:j,dragHandle:T.dragHandle,zIndex:w.z,parentId:T.parentId,...V})})})}const FBe=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Gne(t){const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:a,onError:i}=un(FBe,Cr),s=DBe(t.onlyRenderVisibleElements),o=MBe();return N.jsx("div",{className:"react-flow__nodes",style:mA,children:s.map(l=>N.jsx(PBe,{id:l,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e,nodesConnectable:n,nodesFocusable:r,elementsSelectable:a,nodeClickDistance:t.nodeClickDistance,onError:i},l))})}Gne.displayName="NodeRenderer";const BBe=D.memo(Gne);function UBe(t){return un(D.useCallback(n=>{if(!t)return n.edges.map(a=>a.id);const r=[];if(n.width&&n.height)for(const a of n.edges){const i=n.nodeLookup.get(a.source),s=n.nodeLookup.get(a.target);i&&s&&zFe({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&r.push(a.id)}return r},[t]),Cr)}const GBe=({color:t="none",strokeWidth:e=1})=>{const n={strokeWidth:e,...t&&{stroke:t}};return N.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},zBe=({color:t="none",strokeWidth:e=1})=>{const n={strokeWidth:e,...t&&{stroke:t,fill:t}};return N.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},zne={[Fh.Arrow]:GBe,[Fh.ArrowClosed]:zBe};function qBe(t){const e=gr();return D.useMemo(()=>{var a,i;return Object.prototype.hasOwnProperty.call(zne,t)?zne[t]:((i=(a=e.getState()).onError)==null||i.call(a,"009",hl.error009(t)),null)},[t])}const HBe=({id:t,type:e,color:n,width:r=12.5,height:a=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:o="auto-start-reverse"})=>{const l=qBe(e);return l?N.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${r}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:o,refX:"0",refY:"0",children:N.jsx(l,{color:n,strokeWidth:s})}):null},qne=({defaultColor:t,rfId:e})=>{const n=un(i=>i.edges),r=un(i=>i.defaultEdgeOptions),a=D.useMemo(()=>jFe(n,{id:e,defaultColor:t,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,e,t]);return a.length?N.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:N.jsx("defs",{children:a.map(i=>N.jsx(HBe,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};qne.displayName="MarkerDefinitions";var $Be=D.memo(qne);function Hne({x:t,y:e,label:n,labelStyle:r,labelShowBg:a=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:o=2,children:l,className:u,...p}){const[f,m]=D.useState({x:1,y:0,width:0,height:0}),g=Zr(["react-flow__edge-textwrapper",u]),S=D.useRef(null);return D.useEffect(()=>{if(S.current){const E=S.current.getBBox();m({x:E.x,y:E.y,width:E.width,height:E.height})}},[n]),n?N.jsxs("g",{transform:`translate(${t-f.width/2} ${e-f.height/2})`,className:g,visibility:f.width?"visible":"hidden",...p,children:[a&&N.jsx("rect",{width:f.width+2*s[0],x:-s[0],y:-s[1],height:f.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:o,ry:o}),N.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:S,style:r,children:n}),l]}):null}Hne.displayName="EdgeText";const YBe=D.memo(Hne);function gA({path:t,labelX:e,labelY:n,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:o,labelBgBorderRadius:l,interactionWidth:u=20,...p}){return N.jsxs(N.Fragment,{children:[N.jsx("path",{...p,d:t,fill:"none",className:Zr(["react-flow__edge-path",p.className])}),u?N.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&wo(e)&&wo(n)?N.jsx(YBe,{x:e,y:n,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:o,labelBgBorderRadius:l}):null]})}function $ne({pos:t,x1:e,y1:n,x2:r,y2:a}){return t===mt.Left||t===mt.Right?[.5*(e+r),n]:[e,.5*(n+a)]}function Yne({sourceX:t,sourceY:e,sourcePosition:n=mt.Bottom,targetX:r,targetY:a,targetPosition:i=mt.Top}){const[s,o]=$ne({pos:n,x1:t,y1:e,x2:r,y2:a}),[l,u]=$ne({pos:i,x1:r,y1:a,x2:t,y2:e}),[p,f,m,g]=Bte({sourceX:t,sourceY:e,targetX:r,targetY:a,sourceControlX:s,sourceControlY:o,targetControlX:l,targetControlY:u});return[`M${t},${e} C${s},${o} ${l},${u} ${r},${a}`,p,f,m,g]}function Vne(t){return D.memo(({id:e,sourceX:n,sourceY:r,targetX:a,targetY:i,sourcePosition:s,targetPosition:o,label:l,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:g,style:S,markerEnd:E,markerStart:y,interactionWidth:v})=>{const[A,T,w]=Yne({sourceX:n,sourceY:r,sourcePosition:s,targetX:a,targetY:i,targetPosition:o}),O=t.isInternal?void 0:e;return N.jsx(gA,{id:O,path:A,labelX:T,labelY:w,label:l,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:g,style:S,markerEnd:E,markerStart:y,interactionWidth:v})})}const VBe=Vne({isInternal:!1}),Wne=Vne({isInternal:!0});VBe.displayName="SimpleBezierEdge",Wne.displayName="SimpleBezierEdgeInternal";function jne(t){return D.memo(({id:e,sourceX:n,sourceY:r,targetX:a,targetY:i,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:m,sourcePosition:g=mt.Bottom,targetPosition:S=mt.Top,markerEnd:E,markerStart:y,pathOptions:v,interactionWidth:A})=>{const[T,w,O]=A3({sourceX:n,sourceY:r,sourcePosition:g,targetX:a,targetY:i,targetPosition:S,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset,stepPosition:v==null?void 0:v.stepPosition}),R=t.isInternal?void 0:e;return N.jsx(gA,{id:R,path:T,labelX:w,labelY:O,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:m,markerEnd:E,markerStart:y,interactionWidth:A})})}const Kne=jne({isInternal:!1}),Xne=jne({isInternal:!0});Kne.displayName="SmoothStepEdge",Xne.displayName="SmoothStepEdgeInternal";function Qne(t){return D.memo(({id:e,...n})=>{var a;const r=t.isInternal?void 0:e;return N.jsx(Kne,{...n,id:r,pathOptions:D.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(a=n.pathOptions)==null?void 0:a.offset])})})}const WBe=Qne({isInternal:!1}),Zne=Qne({isInternal:!0});WBe.displayName="StepEdge",Zne.displayName="StepEdgeInternal";function Jne(t){return D.memo(({id:e,sourceX:n,sourceY:r,targetX:a,targetY:i,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:m,markerEnd:g,markerStart:S,interactionWidth:E})=>{const[y,v,A]=Hte({sourceX:n,sourceY:r,targetX:a,targetY:i}),T=t.isInternal?void 0:e;return N.jsx(gA,{id:T,path:y,labelX:v,labelY:A,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:u,labelBgPadding:p,labelBgBorderRadius:f,style:m,markerEnd:g,markerStart:S,interactionWidth:E})})}const jBe=Jne({isInternal:!1}),ere=Jne({isInternal:!0});jBe.displayName="StraightEdge",ere.displayName="StraightEdgeInternal";function tre(t){return D.memo(({id:e,sourceX:n,sourceY:r,targetX:a,targetY:i,sourcePosition:s=mt.Bottom,targetPosition:o=mt.Top,label:l,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:g,style:S,markerEnd:E,markerStart:y,pathOptions:v,interactionWidth:A})=>{const[T,w,O]=Gte({sourceX:n,sourceY:r,sourcePosition:s,targetX:a,targetY:i,targetPosition:o,curvature:v==null?void 0:v.curvature}),R=t.isInternal?void 0:e;return N.jsx(gA,{id:R,path:T,labelX:w,labelY:O,label:l,labelStyle:u,labelShowBg:p,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:g,style:S,markerEnd:E,markerStart:y,interactionWidth:A})})}const KBe=tre({isInternal:!1}),nre=tre({isInternal:!0});KBe.displayName="BezierEdge",nre.displayName="BezierEdgeInternal";const rre={default:nre,straight:ere,step:Zne,smoothstep:Xne,simplebezier:Wne},are={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},XBe=(t,e,n)=>n===mt.Left?t-e:n===mt.Right?t+e:t,QBe=(t,e,n)=>n===mt.Top?t-e:n===mt.Bottom?t+e:t,ire="react-flow__edgeupdater";function sre({position:t,centerX:e,centerY:n,radius:r=10,onMouseDown:a,onMouseEnter:i,onMouseOut:s,type:o}){return N.jsx("circle",{onMouseDown:a,onMouseEnter:i,onMouseOut:s,className:Zr([ire,`${ire}-${o}`]),cx:XBe(e,r,t),cy:QBe(n,r,t),r,stroke:"transparent",fill:"transparent"})}function ZBe({isReconnectable:t,reconnectRadius:e,edge:n,sourceX:r,sourceY:a,targetX:i,targetY:s,sourcePosition:o,targetPosition:l,onReconnect:u,onReconnectStart:p,onReconnectEnd:f,setReconnecting:m,setUpdateHover:g}){const S=gr(),E=(w,O)=>{if(w.button!==0)return;const{autoPanOnConnect:R,domNode:I,isValidConnection:L,connectionMode:P,connectionRadius:U,lib:H,onConnectStart:W,onConnectEnd:Z,cancelConnection:F,nodeLookup:j,rfId:z,panBy:V,updateConnection:X}=S.getState(),te=O.type==="target",$=(B,ie)=>{m(!1),f==null||f(B,n,O.type,ie)},Q=B=>u==null?void 0:u(n,B),ee=(B,ie)=>{m(!0),p==null||p(w,n,O.type),W==null||W(B,ie)};D3.onPointerDown(w.nativeEvent,{autoPanOnConnect:R,connectionMode:P,connectionRadius:U,domNode:I,handleId:O.id,nodeId:O.nodeId,nodeLookup:j,isTarget:te,edgeUpdaterType:O.type,lib:H,flowId:z,cancelConnection:F,panBy:V,isValidConnection:L,onConnect:Q,onConnectStart:ee,onConnectEnd:Z,onReconnectEnd:$,updateConnection:X,getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,dragThreshold:S.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},y=w=>E(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=w=>E(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),A=()=>g(!0),T=()=>g(!1);return N.jsxs(N.Fragment,{children:[(t===!0||t==="source")&&N.jsx(sre,{position:o,centerX:r,centerY:a,radius:e,onMouseDown:y,onMouseEnter:A,onMouseOut:T,type:"source"}),(t===!0||t==="target")&&N.jsx(sre,{position:l,centerX:i,centerY:s,radius:e,onMouseDown:v,onMouseEnter:A,onMouseOut:T,type:"target"})]})}function JBe({id:t,edgesFocusable:e,edgesReconnectable:n,elementsSelectable:r,onClick:a,onDoubleClick:i,onContextMenu:s,onMouseEnter:o,onMouseMove:l,onMouseLeave:u,reconnectRadius:p,onReconnect:f,onReconnectStart:m,onReconnectEnd:g,rfId:S,edgeTypes:E,noPanClassName:y,onError:v,disableKeyboardA11y:A}){let T=un(Ne=>Ne.edgeLookup.get(t));const w=un(Ne=>Ne.defaultEdgeOptions);T=w?{...w,...T}:T;let O=T.type||"default",R=(E==null?void 0:E[O])||rre[O];R===void 0&&(v==null||v("011",hl.error011(O)),O="default",R=(E==null?void 0:E.default)||rre.default);const I=!!(T.focusable||e&&typeof T.focusable>"u"),L=typeof f<"u"&&(T.reconnectable||n&&typeof T.reconnectable>"u"),P=!!(T.selectable||r&&typeof T.selectable>"u"),U=D.useRef(null),[H,W]=D.useState(!1),[Z,F]=D.useState(!1),j=gr(),{zIndex:z,sourceX:V,sourceY:X,targetX:te,targetY:$,sourcePosition:Q,targetPosition:ee}=un(D.useCallback(Ne=>{const Te=Ne.nodeLookup.get(T.source),De=Ne.nodeLookup.get(T.target);if(!Te||!De)return{zIndex:T.zIndex,...are};const Ye=WFe({id:t,sourceNode:Te,targetNode:De,sourceHandle:T.sourceHandle||null,targetHandle:T.targetHandle||null,connectionMode:Ne.connectionMode,onError:v});return{zIndex:GFe({selected:T.selected,zIndex:T.zIndex,sourceNode:Te,targetNode:De,elevateOnSelect:Ne.elevateEdgesOnSelect}),...Ye||are}},[T.source,T.target,T.sourceHandle,T.targetHandle,T.selected,T.zIndex]),Cr),B=D.useMemo(()=>T.markerStart?`url('#${C3(T.markerStart,S)}')`:void 0,[T.markerStart,S]),ie=D.useMemo(()=>T.markerEnd?`url('#${C3(T.markerEnd,S)}')`:void 0,[T.markerEnd,S]);if(T.hidden||V===null||X===null||te===null||$===null)return null;const ce=Ne=>{var qe;const{addSelectedEdges:Te,unselectNodesAndEdges:De,multiSelectionActive:Ye}=j.getState();P&&(j.setState({nodesSelectionActive:!1}),T.selected&&Ye?(De({nodes:[],edges:[T]}),(qe=U.current)==null||qe.blur()):Te([t])),a&&a(Ne,T)},se=i?Ne=>{i(Ne,{...T})}:void 0,ne=s?Ne=>{s(Ne,{...T})}:void 0,oe=o?Ne=>{o(Ne,{...T})}:void 0,he=l?Ne=>{l(Ne,{...T})}:void 0,_e=u?Ne=>{u(Ne,{...T})}:void 0,Ce=Ne=>{var Te;if(!A&&Ete.includes(Ne.key)&&P){const{unselectNodesAndEdges:De,addSelectedEdges:Ye}=j.getState();Ne.key==="Escape"?((Te=U.current)==null||Te.blur(),De({edges:[T]})):Ye([t])}};return N.jsx("svg",{style:{zIndex:z},children:N.jsxs("g",{className:Zr(["react-flow__edge",`react-flow__edge-${O}`,T.className,y,{selected:T.selected,animated:T.animated,inactive:!P&&!a,updating:H,selectable:P}]),onClick:ce,onDoubleClick:se,onContextMenu:ne,onMouseEnter:oe,onMouseMove:he,onMouseLeave:_e,onKeyDown:I?Ce:void 0,tabIndex:I?0:void 0,role:T.ariaRole??(I?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":T.ariaLabel===null?void 0:T.ariaLabel||`Edge from ${T.source} to ${T.target}`,"aria-describedby":I?`${gne}-${S}`:void 0,ref:U,...T.domAttributes,children:[!Z&&N.jsx(R,{id:t,source:T.source,target:T.target,type:T.type,selected:T.selected,animated:T.animated,selectable:P,deletable:T.deletable??!0,label:T.label,labelStyle:T.labelStyle,labelShowBg:T.labelShowBg,labelBgStyle:T.labelBgStyle,labelBgPadding:T.labelBgPadding,labelBgBorderRadius:T.labelBgBorderRadius,sourceX:V,sourceY:X,targetX:te,targetY:$,sourcePosition:Q,targetPosition:ee,data:T.data,style:T.style,sourceHandleId:T.sourceHandle,targetHandleId:T.targetHandle,markerStart:B,markerEnd:ie,pathOptions:"pathOptions"in T?T.pathOptions:void 0,interactionWidth:T.interactionWidth}),L&&N.jsx(ZBe,{edge:T,isReconnectable:L,reconnectRadius:p,onReconnect:f,onReconnectStart:m,onReconnectEnd:g,sourceX:V,sourceY:X,targetX:te,targetY:$,sourcePosition:Q,targetPosition:ee,setUpdateHover:W,setReconnecting:F})]})})}const e6e=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function ore({defaultMarkerColor:t,onlyRenderVisibleElements:e,rfId:n,edgeTypes:r,noPanClassName:a,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:o,onEdgeMouseMove:l,onEdgeMouseLeave:u,onEdgeClick:p,reconnectRadius:f,onEdgeDoubleClick:m,onReconnectStart:g,onReconnectEnd:S,disableKeyboardA11y:E}){const{edgesFocusable:y,edgesReconnectable:v,elementsSelectable:A,onError:T}=un(e6e,Cr),w=UBe(e);return N.jsxs("div",{className:"react-flow__edges",children:[N.jsx($Be,{defaultColor:t,rfId:n}),w.map(O=>N.jsx(JBe,{id:O,edgesFocusable:y,edgesReconnectable:v,elementsSelectable:A,noPanClassName:a,onReconnect:i,onContextMenu:s,onMouseEnter:o,onMouseMove:l,onMouseLeave:u,onClick:p,reconnectRadius:f,onDoubleClick:m,onReconnectStart:g,onReconnectEnd:S,rfId:n,onError:T,edgeTypes:r,disableKeyboardA11y:E},O))]})}ore.displayName="EdgeRenderer";const t6e=D.memo(ore),n6e=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function r6e({children:t}){const e=un(n6e);return N.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:e},children:t})}function a6e(t){const e=F3(),n=D.useRef(!1);D.useEffect(()=>{!n.current&&e.viewportInitialized&&t&&(setTimeout(()=>t(e),1),n.current=!0)},[t,e.viewportInitialized])}const i6e=t=>{var e;return(e=t.panZoom)==null?void 0:e.syncViewport};function s6e(t){const e=un(i6e),n=gr();return D.useEffect(()=>{t&&(e==null||e(t),n.setState({transform:[t.x,t.y,t.zoom]}))},[t,e]),null}function o6e(t){return t.connection.inProgress?{...t.connection,to:C0(t.connection.to,t.transform)}:{...t.connection}}function l6e(t){return o6e}function c6e(t){const e=l6e();return un(e,Cr)}const u6e=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function d6e({containerStyle:t,style:e,type:n,component:r}){const{nodesConnectable:a,width:i,height:s,isValid:o,inProgress:l}=un(u6e,Cr);return!(i&&a&&l)?null:N.jsx("svg",{style:t,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:N.jsx("g",{className:Zr(["react-flow__connection",Tte(o)]),children:N.jsx(lre,{style:e,type:n,CustomComponent:r,isValid:o})})})}const lre=({style:t,type:e=ad.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:a,from:i,fromNode:s,fromHandle:o,fromPosition:l,to:u,toNode:p,toHandle:f,toPosition:m}=c6e();if(!a)return;if(n)return N.jsx(n,{connectionLineType:e,connectionLineStyle:t,fromNode:s,fromHandle:o,fromX:i.x,fromY:i.y,toX:u.x,toY:u.y,fromPosition:l,toPosition:m,connectionStatus:Tte(r),toNode:p,toHandle:f});let g="";const S={sourceX:i.x,sourceY:i.y,sourcePosition:l,targetX:u.x,targetY:u.y,targetPosition:m};switch(e){case ad.Bezier:[g]=Gte(S);break;case ad.SimpleBezier:[g]=Yne(S);break;case ad.Step:[g]=A3({...S,borderRadius:0});break;case ad.SmoothStep:[g]=A3(S);break;default:[g]=Hte(S)}return N.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:t})};lre.displayName="ConnectionLine";const p6e={};function cre(t=p6e){D.useRef(t),gr(),D.useEffect(()=>{},[t])}function f6e(){gr(),D.useRef(!1),D.useEffect(()=>{},[])}function ure({nodeTypes:t,edgeTypes:e,onInit:n,onNodeClick:r,onEdgeClick:a,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:o,onNodeMouseMove:l,onNodeMouseLeave:u,onNodeContextMenu:p,onSelectionContextMenu:f,onSelectionStart:m,onSelectionEnd:g,connectionLineType:S,connectionLineStyle:E,connectionLineComponent:y,connectionLineContainerStyle:v,selectionKeyCode:A,selectionOnDrag:T,selectionMode:w,multiSelectionKeyCode:O,panActivationKeyCode:R,zoomActivationKeyCode:I,deleteKeyCode:L,onlyRenderVisibleElements:P,elementsSelectable:U,defaultViewport:H,translateExtent:W,minZoom:Z,maxZoom:F,preventScrolling:j,defaultMarkerColor:z,zoomOnScroll:V,zoomOnPinch:X,panOnScroll:te,panOnScrollSpeed:$,panOnScrollMode:Q,zoomOnDoubleClick:ee,panOnDrag:B,onPaneClick:ie,onPaneMouseEnter:ce,onPaneMouseMove:se,onPaneMouseLeave:ne,onPaneScroll:oe,onPaneContextMenu:he,paneClickDistance:_e,nodeClickDistance:Ce,onEdgeContextMenu:Ne,onEdgeMouseEnter:Te,onEdgeMouseMove:De,onEdgeMouseLeave:Ye,reconnectRadius:qe,onReconnect:ht,onReconnectStart:ut,onReconnectEnd:Qt,noDragClassName:bn,noWheelClassName:Zt,noPanClassName:Mn,disableKeyboardA11y:Cn,nodeExtent:Lt,rfId:ln,viewport:Ee,onViewportChange:we}){return cre(t),cre(e),f6e(),a6e(n),s6e(Ee),N.jsx(OBe,{onPaneClick:ie,onPaneMouseEnter:ce,onPaneMouseMove:se,onPaneMouseLeave:ne,onPaneContextMenu:he,onPaneScroll:oe,paneClickDistance:_e,deleteKeyCode:L,selectionKeyCode:A,selectionOnDrag:T,selectionMode:w,onSelectionStart:m,onSelectionEnd:g,multiSelectionKeyCode:O,panActivationKeyCode:R,zoomActivationKeyCode:I,elementsSelectable:U,zoomOnScroll:V,zoomOnPinch:X,zoomOnDoubleClick:ee,panOnScroll:te,panOnScrollSpeed:$,panOnScrollMode:Q,panOnDrag:B,defaultViewport:H,translateExtent:W,minZoom:Z,maxZoom:F,onSelectionContextMenu:f,preventScrolling:j,noDragClassName:bn,noWheelClassName:Zt,noPanClassName:Mn,disableKeyboardA11y:Cn,onViewportChange:we,isControlledViewport:!!Ee,children:N.jsxs(r6e,{children:[N.jsx(t6e,{edgeTypes:e,onEdgeClick:a,onEdgeDoubleClick:s,onReconnect:ht,onReconnectStart:ut,onReconnectEnd:Qt,onlyRenderVisibleElements:P,onEdgeContextMenu:Ne,onEdgeMouseEnter:Te,onEdgeMouseMove:De,onEdgeMouseLeave:Ye,reconnectRadius:qe,defaultMarkerColor:z,noPanClassName:Mn,disableKeyboardA11y:Cn,rfId:ln}),N.jsx(d6e,{style:E,type:S,component:y,containerStyle:v}),N.jsx("div",{className:"react-flow__edgelabel-renderer"}),N.jsx(BBe,{nodeTypes:t,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:o,onNodeMouseMove:l,onNodeMouseLeave:u,onNodeContextMenu:p,nodeClickDistance:Ce,onlyRenderVisibleElements:P,noPanClassName:Mn,noDragClassName:bn,disableKeyboardA11y:Cn,nodeExtent:Lt,rfId:ln}),N.jsx("div",{className:"react-flow__viewport-portal"})]})})}ure.displayName="GraphView";const m6e=D.memo(ure),dre=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:a,height:i,fitView:s,fitViewOptions:o,minZoom:l=.5,maxZoom:u=2,nodeOrigin:p,nodeExtent:f}={})=>{const m=new Map,g=new Map,S=new Map,E=new Map,y=r??e??[],v=n??t??[],A=p??[0,0],T=f??E0;Qte(S,E,y);const w=w3(v,m,g,{nodeOrigin:A,nodeExtent:T,elevateNodesOnSelect:!1});let O=[0,0,1];if(s&&a&&i){const R=v0(m,{filter:U=>!!((U.width||U.initialWidth)&&(U.height||U.initialHeight))}),{x:I,y:L,zoom:P}=v3(R,a,i,l,u,(o==null?void 0:o.padding)??.1);O=[I,L,P]}return{rfId:"1",width:a??0,height:i??0,transform:O,nodes:v,nodesInitialized:w,nodeLookup:m,parentLookup:g,edges:y,edgeLookup:E,connectionLookup:S,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:l,maxZoom:u,translateExtent:E0,nodeExtent:T,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ph.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:A,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:o,fitViewResolver:null,connection:{...yte},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:MFe,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Ste}},h6e=({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:a,height:i,fitView:s,fitViewOptions:o,minZoom:l,maxZoom:u,nodeOrigin:p,nodeExtent:f})=>P5e((m,g)=>{async function S(){const{nodeLookup:E,panZoom:y,fitViewOptions:v,fitViewResolver:A,width:T,height:w,minZoom:O,maxZoom:R}=g();y&&(await DFe({nodes:E,width:T,height:w,panZoom:y,minZoom:O,maxZoom:R},v),A==null||A.resolve(!0),m({fitViewResolver:null}))}return{...dre({nodes:t,edges:e,width:a,height:i,fitView:s,fitViewOptions:o,minZoom:l,maxZoom:u,nodeOrigin:p,nodeExtent:f,defaultNodes:n,defaultEdges:r}),setNodes:E=>{const{nodeLookup:y,parentLookup:v,nodeOrigin:A,elevateNodesOnSelect:T,fitViewQueued:w}=g(),O=w3(E,y,v,{nodeOrigin:A,nodeExtent:f,elevateNodesOnSelect:T,checkEquality:!0});w&&O?(S(),m({nodes:E,nodesInitialized:O,fitViewQueued:!1,fitViewOptions:void 0})):m({nodes:E,nodesInitialized:O})},setEdges:E=>{const{connectionLookup:y,edgeLookup:v}=g();Qte(y,v,E),m({edges:E})},setDefaultNodesAndEdges:(E,y)=>{if(E){const{setNodes:v}=g();v(E),m({hasDefaultNodes:!0})}if(y){const{setEdges:v}=g();v(y),m({hasDefaultEdges:!0})}},updateNodeInternals:E=>{const{triggerNodeChanges:y,nodeLookup:v,parentLookup:A,domNode:T,nodeOrigin:w,nodeExtent:O,debug:R,fitViewQueued:I}=g(),{changes:L,updatedInternals:P}=e5e(E,v,A,T,w,O);P&&(XFe(v,A,{nodeOrigin:w,nodeExtent:O}),I?(S(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(L==null?void 0:L.length)>0&&(R&&console.log("React Flow: trigger node changes",L),y==null||y(L)))},updateNodePositions:(E,y=!1)=>{const v=[],A=[],{nodeLookup:T,triggerNodeChanges:w}=g();for(const[O,R]of E){const I=T.get(O),L=!!(I!=null&&I.expandParent&&(I!=null&&I.parentId)&&(R!=null&&R.position)),P={id:O,type:"position",position:L?{x:Math.max(0,R.position.x),y:Math.max(0,R.position.y)}:R.position,dragging:y};L&&I.parentId&&v.push({id:O,parentId:I.parentId,rect:{...R.internals.positionAbsolute,width:R.measured.width??0,height:R.measured.height??0}}),A.push(P)}if(v.length>0){const{parentLookup:O,nodeOrigin:R}=g(),I=O3(v,T,O,R);A.push(...I)}w(A)},triggerNodeChanges:E=>{const{onNodesChange:y,setNodes:v,nodes:A,hasDefaultNodes:T,debug:w}=g();if(E!=null&&E.length){if(T){const O=Cne(E,A);v(O)}w&&console.log("React Flow: trigger node changes",E),y==null||y(E)}},triggerEdgeChanges:E=>{const{onEdgesChange:y,setEdges:v,edges:A,hasDefaultEdges:T,debug:w}=g();if(E!=null&&E.length){if(T){const O=Rne(E,A);v(O)}w&&console.log("React Flow: trigger edge changes",E),y==null||y(E)}},addSelectedNodes:E=>{const{multiSelectionActive:y,edgeLookup:v,nodeLookup:A,triggerNodeChanges:T,triggerEdgeChanges:w}=g();if(y){const O=E.map(R=>sf(R,!0));T(O);return}T($h(A,new Set([...E]),!0)),w($h(v))},addSelectedEdges:E=>{const{multiSelectionActive:y,edgeLookup:v,nodeLookup:A,triggerNodeChanges:T,triggerEdgeChanges:w}=g();if(y){const O=E.map(R=>sf(R,!0));w(O);return}w($h(v,new Set([...E]))),T($h(A,new Set,!0))},unselectNodesAndEdges:({nodes:E,edges:y}={})=>{const{edges:v,nodes:A,nodeLookup:T,triggerNodeChanges:w,triggerEdgeChanges:O}=g(),R=E||A,I=y||v,L=R.map(U=>{const H=T.get(U.id);return H&&(H.selected=!1),sf(U.id,!1)}),P=I.map(U=>sf(U.id,!1));w(L),O(P)},setMinZoom:E=>{const{panZoom:y,maxZoom:v}=g();y==null||y.setScaleExtent([E,v]),m({minZoom:E})},setMaxZoom:E=>{const{panZoom:y,minZoom:v}=g();y==null||y.setScaleExtent([v,E]),m({maxZoom:E})},setTranslateExtent:E=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(E),m({translateExtent:E})},setPaneClickDistance:E=>{var y;(y=g().panZoom)==null||y.setClickDistance(E)},resetSelectedElements:()=>{const{edges:E,nodes:y,triggerNodeChanges:v,triggerEdgeChanges:A,elementsSelectable:T}=g();if(!T)return;const w=y.reduce((R,I)=>I.selected?[...R,sf(I.id,!1)]:R,[]),O=E.reduce((R,I)=>I.selected?[...R,sf(I.id,!1)]:R,[]);v(w),A(O)},setNodeExtent:E=>{const{nodes:y,nodeLookup:v,parentLookup:A,nodeOrigin:T,elevateNodesOnSelect:w,nodeExtent:O}=g();E[0][0]===O[0][0]&&E[0][1]===O[0][1]&&E[1][0]===O[1][0]&&E[1][1]===O[1][1]||(w3(y,v,A,{nodeOrigin:T,nodeExtent:E,elevateNodesOnSelect:w,checkEquality:!1}),m({nodeExtent:E}))},panBy:E=>{const{transform:y,width:v,height:A,panZoom:T,translateExtent:w}=g();return t5e({delta:E,panZoom:T,transform:y,translateExtent:w,width:v,height:A})},setCenter:async(E,y,v)=>{const{width:A,height:T,maxZoom:w,panZoom:O}=g();if(!O)return Promise.resolve(!1);const R=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:w;return await O.setViewport({x:A/2-E*R,y:T/2-y*R,zoom:R},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...yte}})},updateConnection:E=>{m({connection:E})},reset:()=>m({...dre()})}},Object.is);function g6e({initialNodes:t,initialEdges:e,defaultNodes:n,defaultEdges:r,initialWidth:a,initialHeight:i,initialMinZoom:s,initialMaxZoom:o,initialFitViewOptions:l,fitView:u,nodeOrigin:p,nodeExtent:f,children:m}){const[g]=D.useState(()=>h6e({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,width:a,height:i,fitView:u,minZoom:s,maxZoom:o,fitViewOptions:l,nodeOrigin:p,nodeExtent:f}));return N.jsx(F5e,{value:g,children:N.jsx(iBe,{children:m})})}function _6e({children:t,nodes:e,edges:n,defaultNodes:r,defaultEdges:a,width:i,height:s,fitView:o,fitViewOptions:l,minZoom:u,maxZoom:p,nodeOrigin:f,nodeExtent:m}){return D.useContext(dA)?N.jsx(N.Fragment,{children:t}):N.jsx(g6e,{initialNodes:e,initialEdges:n,defaultNodes:r,defaultEdges:a,initialWidth:i,initialHeight:s,fitView:o,initialFitViewOptions:l,initialMinZoom:u,initialMaxZoom:p,nodeOrigin:f,nodeExtent:m,children:t})}const b6e={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function E6e({nodes:t,edges:e,defaultNodes:n,defaultEdges:r,className:a,nodeTypes:i,edgeTypes:s,onNodeClick:o,onEdgeClick:l,onInit:u,onMove:p,onMoveStart:f,onMoveEnd:m,onConnect:g,onConnectStart:S,onConnectEnd:E,onClickConnectStart:y,onClickConnectEnd:v,onNodeMouseEnter:A,onNodeMouseMove:T,onNodeMouseLeave:w,onNodeContextMenu:O,onNodeDoubleClick:R,onNodeDragStart:I,onNodeDrag:L,onNodeDragStop:P,onNodesDelete:U,onEdgesDelete:H,onDelete:W,onSelectionChange:Z,onSelectionDragStart:F,onSelectionDrag:j,onSelectionDragStop:z,onSelectionContextMenu:V,onSelectionStart:X,onSelectionEnd:te,onBeforeDelete:$,connectionMode:Q,connectionLineType:ee=ad.Bezier,connectionLineStyle:B,connectionLineComponent:ie,connectionLineContainerStyle:ce,deleteKeyCode:se="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:oe=!1,selectionMode:he=S0.Full,panActivationKeyCode:_e="Space",multiSelectionKeyCode:Ce=R0()?"Meta":"Control",zoomActivationKeyCode:Ne=R0()?"Meta":"Control",snapToGrid:Te,snapGrid:De,onlyRenderVisibleElements:Ye=!1,selectNodesOnDrag:qe,nodesDraggable:ht,autoPanOnNodeFocus:ut,nodesConnectable:Qt,nodesFocusable:bn,nodeOrigin:Zt=_ne,edgesFocusable:Mn,edgesReconnectable:Cn,elementsSelectable:Lt=!0,defaultViewport:ln=X5e,minZoom:Ee=.5,maxZoom:we=2,translateExtent:ze=E0,preventScrolling:tt=!0,nodeExtent:gt,defaultMarkerColor:cr="#b1b1b7",zoomOnScroll:$n=!0,zoomOnPinch:En=!0,panOnScroll:Pt=!1,panOnScrollSpeed:dn=.5,panOnScrollMode:Dt=rf.Free,zoomOnDoubleClick:Or=!0,panOnDrag:nr=!0,onPaneClick:Ir,onPaneMouseEnter:pt,onPaneMouseMove:Ur,onPaneMouseLeave:Gr,onPaneScroll:Rn,onPaneContextMenu:de,paneClickDistance:be=0,nodeClickDistance:Me=0,children:je,onReconnect:Vt,onReconnectStart:Ft,onReconnectEnd:Ke,onEdgeContextMenu:Ve,onEdgeDoubleClick:ot,onEdgeMouseEnter:gn,onEdgeMouseMove:rr,onEdgeMouseLeave:eo,reconnectRadius:uu=10,onNodesChange:du,onEdgesChange:Rs,noDragClassName:Sr="nodrag",noWheelClassName:pa="nowheel",noPanClassName:to="nopan",fitView:pu,fitViewOptions:ip,connectOnClick:fu,attributionPosition:Nm,proOptions:Yl,defaultEdgeOptions:sp,elevateNodesOnSelect:Na,elevateEdgesOnSelect:no,disableKeyboardA11y:ro=!1,autoPanOnConnect:Vo,autoPanOnNodeDrag:Dr,autoPanSpeed:wm,connectionRadius:Vl,isValidConnection:ao,onError:Fe,style:ft,id:Bt,nodeDragThreshold:Sn,connectionDragThreshold:yr,viewport:fa,onViewportChange:ri,width:Ga,height:Ln,colorMode:ai="light",debug:xm,onScroll:io,ariaLabelConfig:op,...mu},k_){const ma=Bt||"1",lp=J5e(ai),Wl=D.useCallback(Wo=>{Wo.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),io==null||io(Wo)},[io]);return N.jsx("div",{"data-testid":"rf__wrapper",...mu,onScroll:Wl,style:{...ft,...b6e},ref:k_,className:Zr(["react-flow",a,lp]),id:Bt,role:"application",children:N.jsxs(_6e,{nodes:t,edges:e,width:Ga,height:Ln,fitView:pu,fitViewOptions:ip,minZoom:Ee,maxZoom:we,nodeOrigin:Zt,nodeExtent:gt,children:[N.jsx(m6e,{onInit:u,onNodeClick:o,onEdgeClick:l,onNodeMouseEnter:A,onNodeMouseMove:T,onNodeMouseLeave:w,onNodeContextMenu:O,onNodeDoubleClick:R,nodeTypes:i,edgeTypes:s,connectionLineType:ee,connectionLineStyle:B,connectionLineComponent:ie,connectionLineContainerStyle:ce,selectionKeyCode:ne,selectionOnDrag:oe,selectionMode:he,deleteKeyCode:se,multiSelectionKeyCode:Ce,panActivationKeyCode:_e,zoomActivationKeyCode:Ne,onlyRenderVisibleElements:Ye,defaultViewport:ln,translateExtent:ze,minZoom:Ee,maxZoom:we,preventScrolling:tt,zoomOnScroll:$n,zoomOnPinch:En,zoomOnDoubleClick:Or,panOnScroll:Pt,panOnScrollSpeed:dn,panOnScrollMode:Dt,panOnDrag:nr,onPaneClick:Ir,onPaneMouseEnter:pt,onPaneMouseMove:Ur,onPaneMouseLeave:Gr,onPaneScroll:Rn,onPaneContextMenu:de,paneClickDistance:be,nodeClickDistance:Me,onSelectionContextMenu:V,onSelectionStart:X,onSelectionEnd:te,onReconnect:Vt,onReconnectStart:Ft,onReconnectEnd:Ke,onEdgeContextMenu:Ve,onEdgeDoubleClick:ot,onEdgeMouseEnter:gn,onEdgeMouseMove:rr,onEdgeMouseLeave:eo,reconnectRadius:uu,defaultMarkerColor:cr,noDragClassName:Sr,noWheelClassName:pa,noPanClassName:to,rfId:ma,disableKeyboardA11y:ro,nodeExtent:gt,viewport:fa,onViewportChange:ri}),N.jsx(Z5e,{nodes:t,edges:e,defaultNodes:n,defaultEdges:r,onConnect:g,onConnectStart:S,onConnectEnd:E,onClickConnectStart:y,onClickConnectEnd:v,nodesDraggable:ht,autoPanOnNodeFocus:ut,nodesConnectable:Qt,nodesFocusable:bn,edgesFocusable:Mn,edgesReconnectable:Cn,elementsSelectable:Lt,elevateNodesOnSelect:Na,elevateEdgesOnSelect:no,minZoom:Ee,maxZoom:we,nodeExtent:gt,onNodesChange:du,onEdgesChange:Rs,snapToGrid:Te,snapGrid:De,connectionMode:Q,translateExtent:ze,connectOnClick:fu,defaultEdgeOptions:sp,fitView:pu,fitViewOptions:ip,onNodesDelete:U,onEdgesDelete:H,onDelete:W,onNodeDragStart:I,onNodeDrag:L,onNodeDragStop:P,onSelectionDrag:j,onSelectionDragStart:F,onSelectionDragStop:z,onMove:p,onMoveStart:f,onMoveEnd:m,noPanClassName:to,nodeOrigin:Zt,rfId:ma,autoPanOnConnect:Vo,autoPanOnNodeDrag:Dr,autoPanSpeed:wm,onError:Fe,connectionRadius:Vl,isValidConnection:ao,selectNodesOnDrag:qe,nodeDragThreshold:Sn,connectionDragThreshold:yr,onBeforeDelete:$,paneClickDistance:be,debug:xm,ariaLabelConfig:op}),N.jsx(K5e,{onSelectionChange:Z}),je,N.jsx($5e,{proOptions:Yl,position:Nm}),N.jsx(H5e,{rfId:ma,disableKeyboardA11y:ro})]})})}var S6e=One(E6e);function y6e(t){const[e,n]=D.useState(t),r=D.useCallback(a=>n(i=>Cne(a,i)),[]);return[e,n,r]}function v6e(t){const[e,n]=D.useState(t),r=D.useCallback(a=>n(i=>Rne(a,i)),[]);return[e,n,r]}function T6e({dimensions:t,lineWidth:e,variant:n,className:r}){return N.jsx("path",{strokeWidth:e,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:Zr(["react-flow__background-pattern",n,r])})}function A6e({radius:t,className:e}){return N.jsx("circle",{cx:t,cy:t,r:t,className:Zr(["react-flow__background-pattern","dots",e])})}var Sc;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Sc||(Sc={}));const C6e={[Sc.Dots]:1,[Sc.Lines]:1,[Sc.Cross]:6},R6e=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function pre({id:t,variant:e=Sc.Dots,gap:n=20,size:r,lineWidth:a=1,offset:i=0,color:s,bgColor:o,style:l,className:u,patternClassName:p}){const f=D.useRef(null),{transform:m,patternId:g}=un(R6e,Cr),S=r||C6e[e],E=e===Sc.Dots,y=e===Sc.Cross,v=Array.isArray(n)?n:[n,n],A=[v[0]*m[2]||1,v[1]*m[2]||1],T=S*m[2],w=Array.isArray(i)?i:[i,i],O=y?[T,T]:A,R=[w[0]*m[2]||1+O[0]/2,w[1]*m[2]||1+O[1]/2],I=`${g}${t||""}`;return N.jsxs("svg",{className:Zr(["react-flow__background",u]),style:{...l,...mA,"--xy-background-color-props":o,"--xy-background-pattern-color-props":s},ref:f,"data-testid":"rf__background",children:[N.jsx("pattern",{id:I,x:m[0]%A[0],y:m[1]%A[1],width:A[0],height:A[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${R[0]},-${R[1]})`,children:E?N.jsx(A6e,{radius:T/2,className:p}):N.jsx(T6e,{dimensions:O,lineWidth:a,variant:e,className:p})}),N.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${I})`})]})}pre.displayName="Background";const N6e=D.memo(pre);function w6e(){return N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:N.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function x6e(){return N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:N.jsx("path",{d:"M0 0h32v4.2H0z"})})}function O6e(){return N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:N.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function I6e(){return N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:N.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function D6e(){return N.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:N.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function _A({children:t,className:e,...n}){return N.jsx("button",{type:"button",className:Zr(["react-flow__controls-button",e]),...n,children:t})}const k6e=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function fre({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:a,onZoomIn:i,onZoomOut:s,onFitView:o,onInteractiveChange:l,className:u,children:p,position:f="bottom-left",orientation:m="vertical","aria-label":g}){const S=gr(),{isInteractive:E,minZoomReached:y,maxZoomReached:v,ariaLabelConfig:A}=un(k6e,Cr),{zoomIn:T,zoomOut:w,fitView:O}=F3(),R=()=>{T(),i==null||i()},I=()=>{w(),s==null||s()},L=()=>{O(a),o==null||o()},P=()=>{S.setState({nodesDraggable:!E,nodesConnectable:!E,elementsSelectable:!E}),l==null||l(!E)},U=m==="horizontal"?"horizontal":"vertical";return N.jsxs(pA,{className:Zr(["react-flow__controls",U,u]),position:f,style:t,"data-testid":"rf__controls","aria-label":g??A["controls.ariaLabel"],children:[e&&N.jsxs(N.Fragment,{children:[N.jsx(_A,{onClick:R,className:"react-flow__controls-zoomin",title:A["controls.zoomIn.ariaLabel"],"aria-label":A["controls.zoomIn.ariaLabel"],disabled:v,children:N.jsx(w6e,{})}),N.jsx(_A,{onClick:I,className:"react-flow__controls-zoomout",title:A["controls.zoomOut.ariaLabel"],"aria-label":A["controls.zoomOut.ariaLabel"],disabled:y,children:N.jsx(x6e,{})})]}),n&&N.jsx(_A,{className:"react-flow__controls-fitview",onClick:L,title:A["controls.fitView.ariaLabel"],"aria-label":A["controls.fitView.ariaLabel"],children:N.jsx(O6e,{})}),r&&N.jsx(_A,{className:"react-flow__controls-interactive",onClick:P,title:A["controls.interactive.ariaLabel"],"aria-label":A["controls.interactive.ariaLabel"],children:E?N.jsx(D6e,{}):N.jsx(I6e,{})}),p]})}fre.displayName="Controls",D.memo(fre);function M6e({id:t,x:e,y:n,width:r,height:a,style:i,color:s,strokeColor:o,strokeWidth:l,className:u,borderRadius:p,shapeRendering:f,selected:m,onClick:g}){const{background:S,backgroundColor:E}=i||{},y=s||S||E;return N.jsx("rect",{className:Zr(["react-flow__minimap-node",{selected:m},u]),x:e,y:n,rx:p,ry:p,width:r,height:a,style:{fill:y,stroke:o,strokeWidth:l},shapeRendering:f,onClick:g?v=>g(v,t):void 0})}const L6e=D.memo(M6e),P6e=t=>t.nodes.map(e=>e.id),z3=t=>t instanceof Function?t:()=>t;function F6e({nodeStrokeColor:t,nodeColor:e,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:a,nodeComponent:i=L6e,onClick:s}){const o=un(P6e,Cr),l=z3(e),u=z3(t),p=z3(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return N.jsx(N.Fragment,{children:o.map(m=>N.jsx(U6e,{id:m,nodeColorFunc:l,nodeStrokeColorFunc:u,nodeClassNameFunc:p,nodeBorderRadius:r,nodeStrokeWidth:a,NodeComponent:i,onClick:s,shapeRendering:f},m))})}function B6e({id:t,nodeColorFunc:e,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:a,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:o,onClick:l}){const{node:u,x:p,y:f,width:m,height:g}=un(S=>{const{internals:E}=S.nodeLookup.get(t),y=E.userNode,{x:v,y:A}=E.positionAbsolute,{width:T,height:w}=Ec(y);return{node:y,x:v,y:A,width:T,height:w}},Cr);return!u||u.hidden||!Ite(u)?null:N.jsx(o,{x:p,y:f,width:m,height:g,style:u.style,selected:!!u.selected,className:r(u),color:e(u),borderRadius:a,strokeColor:n(u),strokeWidth:i,shapeRendering:s,onClick:l,id:u.id})}const U6e=D.memo(B6e);var G6e=D.memo(F6e);const z6e=200,q6e=150,H6e=t=>!t.hidden,$6e=t=>{const e={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:e,boundingRect:t.nodeLookup.size>0?xte(v0(t.nodeLookup,{filter:H6e}),e):e,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},Y6e="react-flow__minimap-desc";function mre({style:t,className:e,nodeStrokeColor:n,nodeColor:r,nodeClassName:a="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:o,bgColor:l,maskColor:u,maskStrokeColor:p,maskStrokeWidth:f,position:m="bottom-right",onClick:g,onNodeClick:S,pannable:E=!1,zoomable:y=!1,ariaLabel:v,inversePan:A,zoomStep:T=1,offsetScale:w=5}){const O=gr(),R=D.useRef(null),{boundingRect:I,viewBB:L,rfId:P,panZoom:U,translateExtent:H,flowWidth:W,flowHeight:Z,ariaLabelConfig:F}=un($6e,Cr),j=(t==null?void 0:t.width)??z6e,z=(t==null?void 0:t.height)??q6e,V=I.width/j,X=I.height/z,te=Math.max(V,X),$=te*j,Q=te*z,ee=w*te,B=I.x-($-I.width)/2-ee,ie=I.y-(Q-I.height)/2-ee,ce=$+ee*2,se=Q+ee*2,ne=`${Y6e}-${P}`,oe=D.useRef(0),he=D.useRef();oe.current=te,D.useEffect(()=>{if(R.current&&U)return he.current=u5e({domNode:R.current,panZoom:U,getTransform:()=>O.getState().transform,getViewScale:()=>oe.current}),()=>{var Te;(Te=he.current)==null||Te.destroy()}},[U]),D.useEffect(()=>{var Te;(Te=he.current)==null||Te.update({translateExtent:H,width:W,height:Z,inversePan:A,pannable:E,zoomStep:T,zoomable:y})},[E,y,A,T,H,W,Z]);const _e=g?Te=>{var qe;const[De,Ye]=((qe=he.current)==null?void 0:qe.pointer(Te))||[0,0];g(Te,{x:De,y:Ye})}:void 0,Ce=S?D.useCallback((Te,De)=>{const Ye=O.getState().nodeLookup.get(De).internals.userNode;S(Te,Ye)},[]):void 0,Ne=v??F["minimap.ariaLabel"];return N.jsx(pA,{position:m,style:{...t,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof p=="string"?p:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*te:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:Zr(["react-flow__minimap",e]),"data-testid":"rf__minimap",children:N.jsxs("svg",{width:j,height:z,viewBox:`${B} ${ie} ${ce} ${se}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:R,onClick:_e,children:[Ne&&N.jsx("title",{id:ne,children:Ne}),N.jsx(G6e,{onClick:Ce,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:a,nodeStrokeWidth:s,nodeComponent:o}),N.jsx("path",{className:"react-flow__minimap-mask",d:`M${B-ee},${ie-ee}h${ce+ee*2}v${se+ee*2}h${-ce-ee*2}z
622
622
  M${L.x},${L.y}h${L.width}v${L.height}h${-L.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}mre.displayName="MiniMap",D.memo(mre);const V6e=t=>e=>t?`${Math.max(1/e.transform[2],1)}`:void 0,W6e={[Hh.Line]:"right",[Hh.Handle]:"bottom-right"};function j6e({nodeId:t,position:e,variant:n=Hh.Handle,className:r,style:a=void 0,children:i,color:s,minWidth:o=10,minHeight:l=10,maxWidth:u=Number.MAX_VALUE,maxHeight:p=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:m,autoScale:g=!0,shouldResize:S,onResizeStart:E,onResize:y,onResizeEnd:v}){const A=Pne(),T=typeof t=="string"?t:A,w=gr(),O=D.useRef(null),R=n===Hh.Handle,I=un(D.useCallback(V6e(R&&g),[R,g]),Cr),L=D.useRef(null),P=e??W6e[n];D.useEffect(()=>{if(!(!O.current||!T))return L.current||(L.current=R5e({domNode:O.current,nodeId:T,getStoreItems:()=>{const{nodeLookup:H,transform:W,snapGrid:Z,snapToGrid:F,nodeOrigin:j,domNode:z}=w.getState();return{nodeLookup:H,transform:W,snapGrid:Z,snapToGrid:F,nodeOrigin:j,paneDomNode:z}},onChange:(H,W)=>{const{triggerNodeChanges:Z,nodeLookup:F,parentLookup:j,nodeOrigin:z}=w.getState(),V=[],X={x:H.x,y:H.y},te=F.get(T);if(te&&te.expandParent&&te.parentId){const $=te.origin??z,Q=H.width??te.measured.width??0,ee=H.height??te.measured.height??0,B={id:te.id,parentId:te.parentId,rect:{width:Q,height:ee,...Dte({x:H.x??te.position.x,y:H.y??te.position.y},{width:Q,height:ee},te.parentId,F,$)}},ie=O3([B],F,j,z);V.push(...ie),X.x=H.x?Math.max($[0]*Q,H.x):void 0,X.y=H.y?Math.max($[1]*ee,H.y):void 0}if(X.x!==void 0&&X.y!==void 0){const $={id:T,type:"position",position:{...X}};V.push($)}if(H.width!==void 0&&H.height!==void 0){const Q={id:T,type:"dimensions",resizing:!0,setAttributes:m?m==="horizontal"?"width":"height":!0,dimensions:{width:H.width,height:H.height}};V.push(Q)}for(const $ of W){const Q={...$,type:"position"};V.push(Q)}Z(V)},onEnd:({width:H,height:W})=>{const Z={id:T,type:"dimensions",resizing:!1,dimensions:{width:H,height:W}};w.getState().triggerNodeChanges([Z])}})),L.current.update({controlPosition:P,boundaries:{minWidth:o,minHeight:l,maxWidth:u,maxHeight:p},keepAspectRatio:f,resizeDirection:m,onResizeStart:E,onResize:y,onResizeEnd:v,shouldResize:S}),()=>{var H;(H=L.current)==null||H.destroy()}},[P,o,l,u,p,f,E,y,v,S]);const U=P.split("-");return N.jsx("div",{className:Zr(["react-flow__resize-control","nodrag",...U,n,r]),ref:O,style:{...a,scale:I,...s&&{[R?"backgroundColor":"borderColor"]:s}},children:i})}D.memo(j6e);function K6e({workflowName:t,className:e="w-full h-[600px]",events:n,onNodeClick:r,highlightedNodeId:a,selectedNodeId:i,isComplete:s=!1}){const[o,l,u]=y6e([]),[p,f,m]=v6e([]),[g,S]=D.useState(!1),[E,y]=D.useState(null),[v,A]=D.useState(-1),[T,w]=D.useState(()=>{if(typeof window>"u")return!1;try{return document.documentElement.classList.contains("dark")?!0:window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches}catch{return!1}}),O=D.useMemo(()=>({step:({data:U,id:H})=>{const W=a===H,Z=i===H;let F={transition:"all 1s ease-out"};return U.highlightColor&&U.highlightColor!==null?(F.backgroundColor=T?void 0:"#CCFBEF",F.borderColor=U.highlightColor,F.boxShadow=`0 0 0 3px ${U.highlightColor}66`):U.highlightColor===null&&(F.backgroundColor=T?"#0b1220":"#E6EEFF",F.borderColor=T?"#274690":"#7EA6FF",F.boxShadow="0 0 0 0px transparent"),Z?F={backgroundColor:T?"#1e3a8a":"#DBEAFE",borderColor:"#3B82F6",boxShadow:"0 0 0 4px #3B82F6",transition:"all 1s ease-out"}:W&&(F={...F,borderColor:"#10B981",boxShadow:"0 0 0 3px #10B98166"}),N.jsxs("div",{className:"px-4 py-2 shadow-md rounded-md min-w-[160px] cursor-pointer transition-all bg-[#E6EEFF] border-2 border-[#7EA6FF] dark:bg-[#0b1220] dark:border-[#274690] hover:shadow-lg hover:scale-105",style:F,onClick:()=>r==null?void 0:r(H),children:[N.jsx(gl,{type:"target",position:mt.Left}),N.jsxs("div",{className:"flex items-center justify-between gap-2",children:[N.jsx("div",{className:"font-bold text-[#1E3A8A] text-sm dark:text-[#e5edff]",children:U.label}),U.workerCount>0&&N.jsx("div",{className:"flex items-center justify-center min-w-[20px] h-[20px] px-1.5 rounded-full bg-[#10B981] text-white text-[10px] font-bold",children:U.workerCount})]}),U.title&&N.jsx("div",{className:"text-xs text-[#1D4ED8] mt-1 dark:text-[#9db4ff]",children:U.title}),(U.lastInputEvent||U.lastOutputEvent)&&N.jsxs("div",{className:"text-[10px] text-gray-700 dark:text-gray-300 mt-1",children:[U.lastInputEvent&&N.jsxs("div",{children:[N.jsx("span",{className:"font-semibold",children:"in:"})," ",U.lastInputEvent]}),U.lastOutputEvent&&N.jsxs("div",{children:[N.jsx("span",{className:"font-semibold",children:"out:"})," ",U.lastOutputEvent]})]}),N.jsx(gl,{type:"source",position:mt.Right})]})},event:({data:U,id:H})=>{const W=a===H,Z=i===H;let F={transition:"all 1s ease-out"};return U.highlightColor&&U.highlightColor!==null?(F.backgroundColor=T?void 0:"#FFE8B5",F.borderColor=U.highlightColor,F.boxShadow=`0 0 0 3px ${U.highlightColor}66`):U.highlightColor===null&&(F.backgroundColor=T?"#241a06":"#FFF3BF",F.borderColor=T?"#F59E0B":"#FFD166",F.boxShadow="0 0 0 0px transparent"),Z?F={backgroundColor:T?"#1e3a8a":"#DBEAFE",borderColor:"#3B82F6",boxShadow:"0 0 0 4px #3B82F6",transition:"all 1s ease-out"}:W&&(F={...F,borderColor:"#10B981",boxShadow:"0 0 0 3px #10B98166"}),N.jsxs("div",{className:"px-3 py-2 shadow-md rounded-full min-w-[140px] text-center cursor-pointer transition-all bg-[#FFF3BF] border-2 border-[#FFD166] dark:bg-[#241a06] dark:border-[#F59E0B] hover:shadow-lg hover:scale-105",style:F,onClick:()=>r==null?void 0:r(H),children:[N.jsx(gl,{type:"target",position:mt.Left}),N.jsx("div",{className:"font-bold text-[#92400E] text-sm dark:text-[#fde68a]",children:U.label}),U.event_type&&N.jsx("div",{className:"text-xs text-[#B45309] mt-1 dark:text-[#fbbf24]",children:U.event_type}),N.jsx(gl,{type:"source",position:mt.Right})]})},external:({data:U,id:H})=>{const W=a===H,Z=i===H;let F=U.highlightColor?{backgroundColor:T?void 0:"#FFE5D4",borderColor:U.highlightColor,boxShadow:`0 0 0 3px ${U.highlightColor}66`}:void 0;return Z?F={backgroundColor:T?"#1e3a8a":"#DBEAFE",borderColor:"#3B82F6",boxShadow:"0 0 0 4px #3B82F6"}:W&&(F={backgroundColor:F==null?void 0:F.backgroundColor,borderColor:"#10B981",boxShadow:"0 0 0 3px #10B98166"}),N.jsxs("div",{className:"px-3 py-2 shadow-md rounded-lg min-w-[140px] text-center cursor-pointer transition-all bg-[#FFEDD5] border-2 border-[#FB923C] dark:bg-[#1f0f08] dark:border-[#ea7a3a] hover:shadow-lg hover:scale-105",style:F,onClick:()=>r==null?void 0:r(H),children:[N.jsx(gl,{type:"target",position:mt.Left}),N.jsx("div",{className:"font-bold text-[#7C2D12] text-sm dark:text-[#fed7aa]",children:U.label}),U.title&&N.jsx("div",{className:"text-xs text-[#C2410C] mt-1 dark:text-[#fdba74]",children:U.title}),N.jsx(gl,{type:"source",position:mt.Right})]})}}),[T,a,i,r]);D.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const U=window.matchMedia("(prefers-color-scheme: dark)"),H=W=>w(W.matches);return U.addEventListener?U.addEventListener("change",H):U.addListener(H),()=>{U.removeEventListener?U.removeEventListener("change",H):U.removeListener(H)}},[]);const R=Yu(),I=D.useCallback(U=>f(H=>qte(U,H)),[f]),L=D.useCallback(U=>{const H=new Map,W=new Map;U.nodes.forEach($=>{H.set($.id,[]),W.set($.id,0)}),U.edges.forEach(({source:$,target:Q})=>{var ee;(ee=H.get($))==null||ee.push(Q),W.set(Q,(W.get(Q)||0)+1)});const Z=[];W.forEach(($,Q)=>{$===0&&Z.push(Q)});const F=new Map;for(Z.forEach($=>F.set($,0));Z.length;){const $=Z.shift(),Q=F.get($)??0;for(const ee of H.get($)||[]){const B=Math.max(Q+1,F.get(ee)??0);F.set(ee,B),W.set(ee,(W.get(ee)||0)-1),(W.get(ee)||0)===0&&Z.push(ee)}}const j={};U.nodes.forEach($=>{const Q=F.get($.id)??0;j[Q]||(j[Q]=[]),j[Q].push($.id)});const z=260,V=110,X=U.nodes.map($=>{const Q=F.get($.id)??0,B=j[Q].indexOf($.id),ie=Q*z,ce=B*V;return{id:$.id,type:$.node_type,position:{x:ie,y:ce},data:{label:$.label,title:$.title,event_type:$.event_type,type:$.node_type}}}),te=U.edges.map(($,Q)=>({id:`edge-${Q}`,source:$.source,target:$.target,type:"smoothstep",animated:!1,style:{stroke:"var(--wf-edge-stroke)",strokeWidth:2},markerEnd:{type:Fh.ArrowClosed,color:"var(--wf-edge-stroke)"}}));return{nodes:X,edges:te}},[]),P=D.useCallback(async()=>{if(!t){l([]),f([]),y(null);return}S(!0),y(null);try{const{data:U,error:H}=await $9({client:R,path:{name:t}});if(H)throw new Error(String(H));const W=U==null?void 0:U.graph;if(!W)throw new Error("No graph data received");const Z=L(W);l(Z.nodes),f(Z.edges)}catch(U){console.error("Error fetching workflow visualization:",U),y(U instanceof Error?U.message:"Failed to load workflow visualization"),l([]),f([])}finally{S(!1)}},[t,R,L,l,f]);return D.useEffect(()=>{P()},[P]),D.useEffect(()=>{if(!n||n.length===0){A(-1),l(Z=>Z.map(F=>{const j={...F.data};return delete j.highlightColor,delete j.activeWorkers,delete j.workerCount,delete j.fadeTimestamp,{...F,data:j}}));return}const U=n.slice(v+1);if(U.length===0)return;A(n.length-1);const H=Z=>{if(!Z)return"";try{return((typeof Z=="string"?Z:String(Z)).replace("<class","").replace(">","").replaceAll("'","").split(".").at(-1)||"").trim()}catch{return""}},W=Z=>{switch(Z){case"preparing":return"#3B82F6";case"in_progress":return"#F59E0B";case"running":return"#10B981";case"not_running":case"not_in_progress":case"exited":return null;default:return"#10B981"}};for(const Z of U){const F=(Z==null?void 0:Z.type)??"",j=(Z==null?void 0:Z.data)??{};if(F==="StepStateChanged"||F==="workflows.events.StepStateChanged"){const z=String((j==null?void 0:j.name)||""),V=String((j==null?void 0:j.step_state)||""),X=String((j==null?void 0:j.worker_id)||""),te=W(V);l($=>$.map(Q=>{const ee={...Q.data};if(Q.id===z){const B=new Set(ee.activeWorkers||[]);if(V==="preparing"||V==="in_progress"||V==="running"?B.add(X):(V==="not_running"||V==="not_in_progress"||V==="exited")&&B.delete(X),ee.activeWorkers=Array.from(B),ee.workerCount=B.size,B.size>0)ee.highlightColor=te||"#10B981",ee.fadeTimestamp=Date.now();else if((V==="exited"||V==="not_running")&&ee.highlightColor){const ie=Date.now();ee.fadeTimestamp=ie,setTimeout(()=>{l(ce=>ce.map(se=>{if(se.id===z&&se.data.fadeTimestamp===ie){const ne={...se.data};return ne.highlightColor=null,{...se,data:ne}}return se}))},1e3)}return ee.lastInputEvent=H(j==null?void 0:j.input_event_name),ee.lastOutputEvent=H(j==null?void 0:j.output_event_name),ee.status=V,{...Q,data:ee}}return Q}))}else if(F&&!F.includes("workflows.events.EventsQueueChanged")){const z=H(F.replace("__main__.","").replace("workflows.events.",""));l(V=>V.map(X=>{if(X.id===z&&X.type==="event"){const te={...X.data};return te.highlightColor="#10B981",te.fadeTimestamp=Date.now(),{...X,data:te}}return X})),setTimeout(()=>{l(V=>V.map(X=>{if(X.id===z&&X.type==="event"){const te={...X.data};return te.highlightColor=null,te.fadeTimestamp=null,{...X,data:te}}return X}))},1e3)}}},[n,v,l,s]),g?N.jsx("div",{className:`${e} flex items-center justify-center bg-card border border-border rounded-lg`,children:N.jsxs("div",{className:"text-center",children:[N.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto mb-2"}),N.jsx("p",{className:"text-muted-foreground",children:"Loading workflow visualization..."})]})}):E?N.jsx("div",{className:`${e} flex items-center justify-center bg-destructive/10 border border-destructive/30 rounded-lg`,children:N.jsxs("div",{className:"text-center p-4",children:[N.jsx("p",{className:"text-destructive font-medium",children:"Error loading visualization"}),N.jsx("p",{className:"text-sm mt-1 text-destructive",children:E}),N.jsx("button",{onClick:P,className:"mt-3 px-4 py-2 bg-primary text-primary-foreground rounded-md text-sm hover:opacity-90 transition-colors",children:"Retry"})]})}):t?o.length===0?N.jsx("div",{className:`${e} flex items-center justify-center bg-card border border-border rounded-lg`,children:N.jsx("p",{className:"text-muted-foreground",children:"No workflow data available"})}):N.jsx("div",{className:`${e} border border-border rounded-lg overflow-hidden`,children:N.jsx(S6e,{nodes:o,edges:p,onNodesChange:u,onEdgesChange:m,onConnect:I,nodeTypes:O,defaultEdgeOptions:{markerEnd:{type:Fh.ArrowClosed,color:"var(--wf-edge-stroke)"}},fitView:!0,attributionPosition:"bottom-left",children:N.jsx(N6e,{variant:Sc.Dots,gap:12,size:1,color:T?"#374151":"#e5e7eb"})})}):N.jsx("div",{className:`${e} flex items-center justify-center bg-card border border-border rounded-lg`,children:N.jsx("p",{className:"text-muted-foreground",children:"Select a workflow to view its visualization"})})}function X6e({handlerId:t,workflowName:e,disabled:n}){const[r,a]=D.useState(!1),[i,s]=D.useState([]),[o,l]=D.useState(null),[u,p]=D.useState({}),[f,m]=D.useState(!1),[g,S]=D.useState(null),[E,y]=D.useState(!1),[v,A]=D.useState(null),[T,w]=D.useState(!1),O=Yu();D.useEffect(()=>{if(!r||!e)return;(async()=>{m(!0),A(null);try{const W=(await G_e({client:O,path:{name:e}})).data;if(!W){s([]);return}if(!W.events){s([]);return}if(s(W.events),W.events&&W.events.length>0){const F=W.events[0].title;l(F||null)}}catch(H){console.error("Failed to fetch event schemas:",H),A(H instanceof Error?H.message:"Failed to fetch events"),s([])}finally{m(!1)}})()},[r,e,O]),D.useEffect(()=>{r||(l(null),p({}),S(null),A(null),w(!1))},[r]),D.useEffect(()=>{p({}),A(null),w(!1)},[o]);const R=D.useMemo(()=>o&&i.find(U=>U.title===o)||null,[o,i]),I=D.useMemo(()=>g?Object.values(g).some(U=>U!==null):!1,[g]),L=async()=>{if(!(!t||!o)){y(!0),A(null),w(!1);try{const U={type:o,data:u},{error:H}=await H9({client:O,path:{handler_id:t},body:{event:JSON.stringify(U)}});if(H)throw new Error(typeof H=="string"?H:JSON.stringify(H));w(!0),setTimeout(()=>{a(!1)},1e3)}catch(U){console.error("Failed to send event:",U),A(U instanceof Error?U.message:"Failed to send event")}finally{y(!1)}}},P=!E&&!I&&o&&t&&!T;return N.jsxs(afe,{open:r,onOpenChange:a,children:[N.jsx(ife,{asChild:!0,children:N.jsxs(Bn,{variant:"outline",size:"sm",disabled:n||!t||!e,title:t?e?"Send event to workflow":"No workflow selected":"No active handler",children:[N.jsx(Ude,{className:"h-4 w-4 mr-2"}),"Send Event"]})}),N.jsxs(lfe,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[N.jsxs(cfe,{children:[N.jsx(dfe,{children:"Send Event to Workflow"}),N.jsx(pfe,{children:"Send a custom event to the running workflow handler."})]}),N.jsx("div",{className:"space-y-4 py-4",children:f?N.jsx("div",{className:"text-center text-muted-foreground",children:"Loading event types..."}):i.length===0?N.jsx("div",{className:"text-center text-muted-foreground",children:v||"No events available for this workflow"}):N.jsxs(N.Fragment,{children:[N.jsxs("div",{className:"space-y-2",children:[N.jsx("label",{className:"text-sm font-medium",children:"Event Type"}),N.jsxs(oN,{value:o||"",onValueChange:l,children:[N.jsx(cN,{children:N.jsx(lN,{placeholder:"Select event type..."})}),N.jsx(uN,{children:i.map(U=>N.jsx(Rv,{value:U.title||"",children:U.title||"Unnamed Event"},U.title||"unknown"))})]})]}),R&&N.jsxs("div",{className:"space-y-2",children:[N.jsx("label",{className:"text-sm font-medium",children:"Event Data"}),N.jsx(_j,{schema:{properties:R.properties,required:R.required},values:u,onChange:p,onErrorsChange:S,className:"space-y-3 border border-border rounded-lg p-4 bg-muted/30"})]}),v&&N.jsx("div",{className:"text-destructive text-sm p-3 bg-destructive/10 border border-destructive/20 rounded",children:v}),T&&N.jsx("div",{className:"text-green-600 text-sm p-3 bg-green-50 border border-green-200 rounded",children:"Event sent successfully!"})]})}),N.jsxs(ufe,{children:[N.jsx(Bn,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),N.jsx(Bn,{onClick:L,disabled:!P,children:E?"Sending...":"Send Event"})]})]})]})}function Q6e({handlerId:t,selectedWorkflow:e}){var A;const{state:n,subscribeToEvents:r}=nIe(t),[a,i]=D.useState(!1),[s,o]=D.useState(!0),[l,u]=D.useState(null),[p,f]=D.useState(null),{items:m,push:g,clear:S}=rIe(100,(T,w)=>T.timestamp.getTime()-w.timestamp.getTime()),E=T=>typeof T=="string"?T:!T||typeof T!="object"?String(T??""):JSON.stringify(T,null,a?0:2),y=T=>{if(!T)return"";const w=new Date(T),O=w.toLocaleTimeString([],{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"}),R=String(w.getMilliseconds()).padStart(3,"0");return`${O}.${R}`};D.useEffect(()=>{if(n.status==="running"){const{disconnect:T}=r({onData:w=>{g(w)},onSuccess(w){var O,R;u(((R=(O=w[w.length-1])==null?void 0:O.data)==null?void 0:R.result)??null)},onError(w){f(w.message)}},!0);return()=>{T()}}},[r,n.status,g]),D.useEffect(()=>{S(),u(null),f(null)},[t,S]);const v=D.useMemo(()=>s?m.filter(T=>!r0e(T)):m,[m,s]);return N.jsxs("div",{className:"h-full flex flex-col",children:[N.jsxs("div",{className:"p-4 border-b border-border",children:[N.jsxs("div",{className:"flex items-center justify-between",children:[N.jsx("h2",{className:"font-semibold text-sm",children:"Run Details"}),N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsx(i0e,{variant:n.status==="completed"?"default":"secondary",children:n.status}),N.jsx(X6e,{handlerId:t,workflowName:e??null,disabled:!n||n.status==="completed"||n.status==="failed"})]})]}),N.jsxs("div",{className:"flex items-center justify-between gap-2 mt-2",children:[N.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:n.handler_id}),N.jsxs("span",{className:"text-xs text-muted-foreground font-mono",children:["Last updated: ",(A=n.updated_at)==null?void 0:A.getTime()]})]})]}),N.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[N.jsx("div",{className:"flex-1 p-4 overflow-auto border-r border-border",children:N.jsx(K6e,{workflowName:e||null,events:m.map(T=>({type:T.type,data:T.data})),className:"w-full h-full min-h-[400px]",isComplete:n.status==="completed"||n.status==="failed"})}),N.jsxs("div",{className:"w-[480px] flex flex-col overflow-hidden",children:[N.jsx("div",{className:"p-4 pb-2 border-b border-border",children:N.jsxs("div",{className:"flex items-center justify-between mb-3",children:[N.jsxs("h4",{className:"font-medium text-sm",children:["Event Stream (",v.length,")"]}),N.jsxs("div",{className:"flex items-center gap-3",children:[N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsx(gfe,{htmlFor:"hide-internal",className:"text-xs",children:"Hide internal"}),N.jsx(Ohe,{id:"hide-internal",checked:s,onCheckedChange:T=>o(!!T)})]}),N.jsx(Bn,{variant:"ghost",size:"sm",onClick:()=>i(!a),children:a?"Formatted":"Compact"})]})]})}),N.jsx("div",{className:"flex-1 overflow-auto",children:n.handler_id?m.length===0?N.jsx("div",{className:"flex items-center justify-center h-full",children:N.jsx("p",{className:"text-muted-foreground text-sm",children:"No events yet..."})}):N.jsxs(C9,{children:[N.jsx(R9,{className:"sticky top-0 bg-background z-10",children:N.jsxs(hN,{children:[N.jsx(gN,{className:"w-8",children:"#"}),N.jsx(gN,{children:"Event"})]})}),N.jsx(N9,{children:v.map((T,w)=>{const O=T;return N.jsxs(hN,{"data-event-index":w,className:"cursor-pointer transition-colors",children:[N.jsx(_N,{className:"text-xs text-muted-foreground align-top",children:w+1}),N.jsx(_N,{className:"py-3",children:N.jsxs("div",{className:"space-y-2",children:[N.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[N.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:N.jsx("code",{className:"text-sm font-mono truncate",children:O.type})}),O.timestamp!==void 0?N.jsx("span",{className:"text-[10px] text-muted-foreground font-mono whitespace-nowrap",children:y(O.timestamp.getTime())}):null]}),N.jsx(Cee,{language:typeof O.data=="string"?"text":"json",value:E(O.data),wrapLongLines:a,className:"rounded border max-h-64 overflow-auto"})]})})]},`${O.type}-${w}`)})})]}):N.jsx("div",{className:"flex items-center justify-center h-full",children:N.jsx("p",{className:"text-muted-foreground text-sm",children:"Start a run to see events"})})}),(l||p)&&N.jsxs("div",{className:"p-4 border-t border-border",children:[N.jsx("h4",{className:"font-medium text-sm mb-2",children:"Final Result"}),p?N.jsxs("div",{className:"text-destructive text-sm p-3 bg-destructive/10 border border-destructive/20 rounded",children:["Failed to load final result: ",p]}):N.jsx(Cee,{language:typeof l=="string"?"text":"json",value:typeof l=="string"?l:JSON.stringify(l,null,2),className:"rounded border overflow-hidden"})]})]})]})]})}function Z6e(t,e,n=!0){D.useEffect(()=>{const r=a=>{(n&&a.ctrlKey&&a.key.toLowerCase()===t.toLowerCase()||!n&&a.key.toLowerCase()===t.toLowerCase())&&(a.preventDefault(),e())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[t,e,n])}function J6e(){const e=new URLSearchParams(window.location.search).get("api");return e?e.endsWith("/")?e.slice(0,-1):e:"http://localhost:8000"}function eUe(){const[t,e]=D.useState(J6e),[n,r]=D.useState(t),[a,i]=D.useState(null),[s,o]=D.useState(null),{state:l,sync:u}=eIe(),[p,f]=D.useState(37.5),[m,g]=D.useState(!1),[S,E]=D.useState(!1),[y,v]=D.useState(!1),[A,T]=D.useState(null),[w,O]=D.useState(null),R=l.workflows,I=Yu(),L=D.useCallback(async()=>{try{O(null);const{data:j,error:z}=await P_e({client:I});if(z)throw new Error(String(z));j&&j.status?T(!0):(T(!1),O("Workflow server is unreachable"))}catch{T(!1),O("Workflow server is unreachable")}},[I]);D.useEffect(()=>{I.setConfig({baseUrl:t}),L(),u()},[t,I,L,u]);const P=()=>{const j=n.endsWith("/")?n.slice(0,-1):n;e(j)},U=()=>{const j="http://localhost:8000";e(j),r(j)},H=j=>{o(j)},W=j=>{j.preventDefault(),g(!0)},Z=D.useCallback(j=>{const z=document.querySelector(".main-content-area");if(!z)return;const V=z.getBoundingClientRect(),X=(j.clientX-V.left)/V.width*100,te=Math.max(20,Math.min(80,X));f(te)},[]),F=D.useCallback(()=>{g(!1)},[]);return D.useEffect(()=>{if(m)return document.addEventListener("mousemove",Z),document.addEventListener("mouseup",F),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",F),document.body.style.cursor="",document.body.style.userSelect=""}},[m,Z,F]),Z6e("b",D.useCallback(()=>{v(j=>!j)},[]),!0),N.jsxs("div",{className:`h-screen flex flex-col bg-background ${m?"resize-active":""}`,children:[N.jsxs("div",{className:"flex items-center justify-between h-12 px-4 bg-card border-b border-border",children:[N.jsxs("div",{className:"flex items-center gap-4",children:[N.jsx(Bn,{variant:"ghost",size:"sm",onClick:()=>E(!S),title:S?"Show sidebar":"Hide sidebar",children:S?N.jsx(Mde,{className:"h-4 w-4"}):N.jsx(kde,{className:"h-4 w-4"})}),N.jsx("h1",{className:"text-md font-semibold",children:"Workflow Debugger"})]}),N.jsxs("div",{className:"flex items-center gap-2",children:[N.jsx("label",{className:"text-xs text-muted-foreground font-medium",children:"Workflow:"}),N.jsxs(oN,{value:a||"",onValueChange:i,children:[N.jsx(cN,{className:"w-48",children:N.jsx(lN,{placeholder:"Select workflow..."})}),N.jsx(uN,{children:Object.keys(R).map(j=>N.jsx(Rv,{value:j,children:j},j))})]})]}),N.jsxs("div",{className:"flex items-center gap-2",children:[A!==null&&N.jsx("span",{className:`${A?"bg-green-500":"bg-red-500"} h-2 w-2 rounded-full`}),A===!1&&N.jsx("span",{className:"text-destructive text-xs",children:w||"Workflow server is unreachable"}),N.jsxs(Yhe,{children:[N.jsx(Vhe,{asChild:!0,children:N.jsx(Bn,{variant:"ghost",size:"sm",children:N.jsx(Gde,{className:"h-4 w-4"})})}),N.jsx(Whe,{className:"w-80",children:N.jsx("div",{className:"space-y-4",children:N.jsxs("div",{className:"space-y-2",children:[N.jsx("h4",{className:"font-medium text-sm",children:"API Configuration"}),N.jsx(kv,{value:n,onChange:j=>r(j.target.value),placeholder:"http://localhost:8000"}),N.jsxs("div",{className:"flex gap-2",children:[N.jsx(Bn,{onClick:P,variant:"outline",size:"sm",disabled:n===t,children:"Save"}),N.jsx(Bn,{onClick:U,variant:"outline",size:"sm",children:"Reset"})]}),N.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: ",t]})]})})})]})]})]}),N.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!S&&N.jsx("div",{className:"w-48 border-r border-border bg-card overflow-hidden transition-all duration-200",children:N.jsx(oIe,{activeHandlerId:s,onHandlerSelect:o})}),N.jsxs("div",{className:"flex-1 flex overflow-hidden main-content-area",children:[y?N.jsx("div",{className:"w-10 border-r border-border bg-muted/30 flex flex-col items-center justify-center hover:bg-muted/50 transition-colors",children:N.jsx(Bn,{variant:"ghost",size:"sm",onClick:()=>v(!1),title:"Show configuration panel (Ctrl+B)",className:"h-10 w-10 p-0",children:N.jsx(Lde,{className:"h-5 w-5"})})}):N.jsxs(N.Fragment,{children:[N.jsx("div",{className:"border-r border-border overflow-auto",style:{width:`${p}%`},children:a&&N.jsx(sIe,{selectedWorkflow:a,onRunStart:H,activeHandlerId:s,onCollapse:()=>v(!0)})}),N.jsx("div",{className:`w-2 hover:bg-gray-500/20 hover:shadow-lg cursor-col-resize flex-shrink-0 transition-all duration-200 relative group border-l border-r border-border ${m?"shadow-xl":""}`,onMouseDown:W,title:"Drag to resize panels"})]}),N.jsx("div",{className:"overflow-auto",style:{width:y?"calc(100% - 40px)":`${100-p}%`},children:s&&N.jsx(Q6e,{handlerId:s,selectedWorkflow:a})})]})]})]})}class tUe extends Oe.Component{constructor(n){super(n);Pe(this,"resetError",()=>{this.setState({hasError:!1,error:void 0})});this.state={hasError:!1}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,r){console.error("ErrorBoundary caught an error:",n,r)}render(){if(this.state.hasError&&this.state.error){if(this.props.fallback){const n=this.props.fallback;return N.jsx(n,{error:this.state.error,resetError:this.resetError})}return N.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:N.jsxs("div",{className:"max-w-md p-6 bg-card border border-border rounded-lg shadow-sm",children:[N.jsx("h2",{className:"text-lg font-semibold text-destructive mb-2",children:"Something went wrong"}),N.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"The workflow debugger encountered an error. This might happen if the workflow server is unreachable."}),N.jsxs("details",{className:"mb-4",children:[N.jsx("summary",{className:"text-sm font-medium cursor-pointer hover:text-foreground",children:"Error Details"}),N.jsx("pre",{className:"mt-2 text-xs bg-muted p-3 rounded border overflow-auto",children:this.state.error.message})]}),N.jsxs("div",{className:"flex gap-2",children:[N.jsx("button",{onClick:this.resetError,className:"px-3 py-2 text-sm bg-primary text-primary-foreground rounded hover:bg-primary/90 transition-colors",children:"Try Again"}),N.jsx("button",{onClick:()=>window.location.reload(),className:"px-3 py-2 text-sm bg-secondary text-secondary-foreground rounded hover:bg-secondary/90 transition-colors",children:"Reload Page"})]})]})})}return this.props.children}}function nUe(){const e=q9({baseUrl:"http://localhost:8000"});return N.jsx(tUe,{children:N.jsx(tbe,{clients:{workflowsClient:e},children:N.jsx(eUe,{})})})}function hre(){const t=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.classList.toggle("dark",t)}hre(),window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",hre),cue.createRoot(document.getElementById("root")).render(N.jsx(D.StrictMode,{children:N.jsx(nUe,{})}));const ui=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),q3=[.001,0,0,.001,0,0],H3=1.35,rs={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},_l={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},O0="pdfjs_internal_editor_",Ot={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},rn={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},gre={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ia={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},I0={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Yr={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},Yh={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},D0={ERRORS:0,WARNINGS:1,INFOS:5},Vh={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},bA={moveTo:0,lineTo:1,curveTo:2,closePath:3},_re={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let EA=D0.WARNINGS;function rUe(t){Number.isInteger(t)&&(EA=t)}function aUe(){return EA}function SA(t){EA>=D0.INFOS&&console.info(`Info: ${t}`)}function It(t){EA>=D0.WARNINGS&&console.warn(`Warning: ${t}`)}function Qn(t){throw new Error(t)}function on(t,e){t||Qn(e)}function iUe(t){switch(t==null?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function $3(t,e=null,n=null){if(!t)return null;if(n&&typeof t=="string"){if(n.addDefaultProtocol&&t.startsWith("www.")){const a=t.match(/\./g);(a==null?void 0:a.length)>=2&&(t=`http://${t}`)}if(n.tryConvertEncoding)try{t=uUe(t)}catch{}}const r=e?URL.parse(t,e):URL.parse(t);return iUe(r)?r:null}function Y3(t,e,n=!1){const r=URL.parse(t);return r?(r.hash=e,r.href):n&&$3(t,"http://example.com")?t.split("#",1)[0]+`${e?`#${e}`:""}`:""}function qt(t,e,n,r=!1){return Object.defineProperty(t,e,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}const of=(function(){function e(n,r){this.message=n,this.name=r}return e.prototype=new Error,e.constructor=e,e})();class bre extends of{constructor(e,n){super(e,"PasswordException"),this.code=n}}class V3 extends of{constructor(e,n){super(e,"UnknownErrorException"),this.details=n}}class yA extends of{constructor(e){super(e,"InvalidPDFException")}}class k0 extends of{constructor(e,n,r){super(e,"ResponseException"),this.status=n,this.missing=r}}class sUe extends of{constructor(e){super(e,"FormatError")}}class yc extends of{constructor(e){super(e,"AbortException")}}function Ere(t){(typeof t!="object"||(t==null?void 0:t.length)===void 0)&&Qn("Invalid argument for bytesToString");const e=t.length,n=8192;if(e<n)return String.fromCharCode.apply(null,t);const r=[];for(let a=0;a<e;a+=n){const i=Math.min(a+n,e),s=t.subarray(a,i);r.push(String.fromCharCode.apply(null,s))}return r.join("")}function M0(t){typeof t!="string"&&Qn("Invalid argument for stringToBytes");const e=t.length,n=new Uint8Array(e);for(let r=0;r<e;++r)n[r]=t.charCodeAt(r)&255;return n}function oUe(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,t&255)}function lUe(){const t=new Uint8Array(4);return t[0]=1,new Uint32Array(t.buffer,0,1)[0]===1}function cUe(){try{return new Function(""),!0}catch{return!1}}class Ea{static get isLittleEndian(){return qt(this,"isLittleEndian",lUe())}static get isEvalSupported(){return qt(this,"isEvalSupported",cUe())}static get isOffscreenCanvasSupported(){return qt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return qt(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:e,userAgent:n}=navigator;return qt(this,"platform",{isAndroid:n.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:n.includes("Firefox")})}static get isCSSRoundSupported(){var e,n;return qt(this,"isCSSRoundSupported",(n=(e=globalThis.CSS)==null?void 0:e.supports)==null?void 0:n.call(e,"width: round(1.5px, 1px)"))}}const W3=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class Je{static makeHexColor(e,n,r){return`#${W3[e]}${W3[n]}${W3[r]}`}static domMatrixToTransform(e){return[e.a,e.b,e.c,e.d,e.e,e.f]}static scaleMinMax(e,n){let r;e[0]?(e[0]<0&&(r=n[0],n[0]=n[2],n[2]=r),n[0]*=e[0],n[2]*=e[0],e[3]<0&&(r=n[1],n[1]=n[3],n[3]=r),n[1]*=e[3],n[3]*=e[3]):(r=n[0],n[0]=n[1],n[1]=r,r=n[2],n[2]=n[3],n[3]=r,e[1]<0&&(r=n[1],n[1]=n[3],n[3]=r),n[1]*=e[1],n[3]*=e[1],e[2]<0&&(r=n[0],n[0]=n[2],n[2]=r),n[0]*=e[2],n[2]*=e[2]),n[0]+=e[4],n[1]+=e[5],n[2]+=e[4],n[3]+=e[5]}static transform(e,n){return[e[0]*n[0]+e[2]*n[1],e[1]*n[0]+e[3]*n[1],e[0]*n[2]+e[2]*n[3],e[1]*n[2]+e[3]*n[3],e[0]*n[4]+e[2]*n[5]+e[4],e[1]*n[4]+e[3]*n[5]+e[5]]}static multiplyByDOMMatrix(e,n){return[e[0]*n.a+e[2]*n.b,e[1]*n.a+e[3]*n.b,e[0]*n.c+e[2]*n.d,e[1]*n.c+e[3]*n.d,e[0]*n.e+e[2]*n.f+e[4],e[1]*n.e+e[3]*n.f+e[5]]}static applyTransform(e,n,r=0){const a=e[r],i=e[r+1];e[r]=a*n[0]+i*n[2]+n[4],e[r+1]=a*n[1]+i*n[3]+n[5]}static applyTransformToBezier(e,n,r=0){const a=n[0],i=n[1],s=n[2],o=n[3],l=n[4],u=n[5];for(let p=0;p<6;p+=2){const f=e[r+p],m=e[r+p+1];e[r+p]=f*a+m*s+l,e[r+p+1]=f*i+m*o+u}}static applyInverseTransform(e,n){const r=e[0],a=e[1],i=n[0]*n[3]-n[1]*n[2];e[0]=(r*n[3]-a*n[2]+n[2]*n[5]-n[4]*n[3])/i,e[1]=(-r*n[1]+a*n[0]+n[4]*n[1]-n[5]*n[0])/i}static axialAlignedBoundingBox(e,n,r){const a=n[0],i=n[1],s=n[2],o=n[3],l=n[4],u=n[5],p=e[0],f=e[1],m=e[2],g=e[3];let S=a*p+l,E=S,y=a*m+l,v=y,A=o*f+u,T=A,w=o*g+u,O=w;if(i!==0||s!==0){const R=i*p,I=i*m,L=s*f,P=s*g;S+=L,v+=L,y+=P,E+=P,A+=R,O+=R,w+=I,T+=I}r[0]=Math.min(r[0],S,y,E,v),r[1]=Math.min(r[1],A,w,T,O),r[2]=Math.max(r[2],S,y,E,v),r[3]=Math.max(r[3],A,w,T,O)}static inverseTransform(e){const n=e[0]*e[3]-e[1]*e[2];return[e[3]/n,-e[1]/n,-e[2]/n,e[0]/n,(e[2]*e[5]-e[4]*e[3])/n,(e[4]*e[1]-e[5]*e[0])/n]}static singularValueDecompose2dScale(e,n){const r=e[0],a=e[1],i=e[2],s=e[3],o=r**2+a**2,l=r*i+a*s,u=i**2+s**2,p=(o+u)/2,f=Math.sqrt(p**2-(o*u-l**2));n[0]=Math.sqrt(p+f||1),n[1]=Math.sqrt(p-f||1)}static normalizeRect(e){const n=e.slice(0);return e[0]>e[2]&&(n[0]=e[2],n[2]=e[0]),e[1]>e[3]&&(n[1]=e[3],n[3]=e[1]),n}static intersect(e,n){const r=Math.max(Math.min(e[0],e[2]),Math.min(n[0],n[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(n[0],n[2]));if(r>a)return null;const i=Math.max(Math.min(e[1],e[3]),Math.min(n[1],n[3])),s=Math.min(Math.max(e[1],e[3]),Math.max(n[1],n[3]));return i>s?null:[r,i,a,s]}static pointBoundingBox(e,n,r){r[0]=Math.min(r[0],e),r[1]=Math.min(r[1],n),r[2]=Math.max(r[2],e),r[3]=Math.max(r[3],n)}static rectBoundingBox(e,n,r,a,i){i[0]=Math.min(i[0],e,r),i[1]=Math.min(i[1],n,a),i[2]=Math.max(i[2],e,r),i[3]=Math.max(i[3],n,a)}static bezierBoundingBox(e,n,r,a,i,s,o,l,u){u[0]=Math.min(u[0],e,o),u[1]=Math.min(u[1],n,l),u[2]=Math.max(u[2],e,o),u[3]=Math.max(u[3],n,l),K(this,Ac,qB).call(this,e,r,i,o,n,a,s,l,3*(-e+3*(r-i)+o),6*(e-2*r+i),3*(r-e),u),K(this,Ac,qB).call(this,e,r,i,o,n,a,s,l,3*(-n+3*(a-s)+l),6*(n-2*a+s),3*(a-n),u)}}Ac=new WeakSet,vR=function(e,n,r,a,i,s,o,l,u,p){if(u<=0||u>=1)return;const f=1-u,m=u*u,g=m*u,S=f*(f*(f*e+3*u*n)+3*m*r)+g*a,E=f*(f*(f*i+3*u*s)+3*m*o)+g*l;p[0]=Math.min(p[0],S),p[1]=Math.min(p[1],E),p[2]=Math.max(p[2],S),p[3]=Math.max(p[3],E)},qB=function(e,n,r,a,i,s,o,l,u,p,f,m){if(Math.abs(u)<1e-12){Math.abs(p)>=1e-12&&K(this,Ac,vR).call(this,e,n,r,a,i,s,o,l,-f/p,m);return}const g=p**2-4*f*u;if(g<0)return;const S=Math.sqrt(g),E=2*u;K(this,Ac,vR).call(this,e,n,r,a,i,s,o,l,(-p+S)/E,m),K(this,Ac,vR).call(this,e,n,r,a,i,s,o,l,(-p-S)/E,m)},Y(Je,Ac);function uUe(t){return decodeURIComponent(escape(t))}let j3=null,Sre=null;function yre(t){return j3||(j3=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Sre=new Map([["ſt","ſt"]])),t.replaceAll(j3,(e,n,r)=>n?n.normalize("NFKC"):Sre.get(r))}function K3(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),Ere(t)}const X3="pdfjs_internal_id_";function dUe(t,e,n){if(!Array.isArray(n)||n.length<2)return!1;const[r,a,...i]=n;if(!t(r)&&!Number.isInteger(r)||!e(a))return!1;const s=i.length;let o=!0;switch(a.name){case"XYZ":if(s<2||s>3)return!1;break;case"Fit":case"FitB":return s===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(s>1)return!1;break;case"FitR":if(s!==4)return!1;o=!1;break;default:return!1}for(const l of i)if(!(typeof l=="number"||o&&l===null))return!1;return!0}function Ka(t,e,n){return Math.min(Math.max(t,e),n)}function vre(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(Ere(t))}function pUe(t){return Uint8Array.fromBase64?Uint8Array.fromBase64(t):M0(atob(t))}typeof Promise.try!="function"&&(Promise.try=function(t,...e){return new Promise(n=>{n(t(...e))})}),typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(t){return t.reduce((e,n)=>e+n,0)});class L0{static textContent(e){const n=[],r={items:n,styles:Object.create(null)};function a(i){var l;if(!i)return;let s=null;const o=i.name;if(o==="#text")s=i.value;else if(L0.shouldBuildText(o))(l=i==null?void 0:i.attributes)!=null&&l.textContent?s=i.attributes.textContent:i.value&&(s=i.value);else return;if(s!==null&&n.push({str:s}),!!i.children)for(const u of i.children)a(u)}return a(e),r}static shouldBuildText(e){return!(e==="textarea"||e==="input"||e==="option"||e==="select")}}class Q3{static setupStorage(e,n,r,a,i){const s=a.getValue(n,{value:null});switch(r.name){case"textarea":if(s.value!==null&&(e.textContent=s.value),i==="print")break;e.addEventListener("input",o=>{a.setValue(n,{value:o.target.value})});break;case"input":if(r.attributes.type==="radio"||r.attributes.type==="checkbox"){if(s.value===r.attributes.xfaOn?e.setAttribute("checked",!0):s.value===r.attributes.xfaOff&&e.removeAttribute("checked"),i==="print")break;e.addEventListener("change",o=>{a.setValue(n,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(s.value!==null&&e.setAttribute("value",s.value),i==="print")break;e.addEventListener("input",o=>{a.setValue(n,{value:o.target.value})})}break;case"select":if(s.value!==null){e.setAttribute("value",s.value);for(const o of r.children)o.attributes.value===s.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}e.addEventListener("input",o=>{const l=o.target.options,u=l.selectedIndex===-1?"":l[l.selectedIndex].value;a.setValue(n,{value:u})});break}}static setAttributes({html:e,element:n,storage:r=null,intent:a,linkService:i}){const{attributes:s}=n,o=e instanceof HTMLAnchorElement;s.type==="radio"&&(s.name=`${s.name}-${a}`);for(const[l,u]of Object.entries(s))if(u!=null)switch(l){case"class":u.length&&e.setAttribute(l,u.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",u);break;case"style":Object.assign(e.style,u);break;case"textContent":e.textContent=u;break;default:(!o||l!=="href"&&l!=="newWindow")&&e.setAttribute(l,u)}o&&i.addLinkAttributes(e,s.href,s.newWindow),r&&s.dataId&&this.setupStorage(e,s.dataId,n,r)}static render(e){var f,m;const n=e.annotationStorage,r=e.linkService,a=e.xfaHtml,i=e.intent||"display",s=document.createElement(a.name);a.attributes&&this.setAttributes({html:s,element:a,intent:i,linkService:r});const o=i!=="richText",l=e.div;if(l.append(s),e.viewport){const g=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=g}o&&l.setAttribute("class","xfaLayer xfaFont");const u=[];if(a.children.length===0){if(a.value){const g=document.createTextNode(a.value);s.append(g),o&&L0.shouldBuildText(a.name)&&u.push(g)}return{textDivs:u}}const p=[[a,-1,s]];for(;p.length>0;){const[g,S,E]=p.at(-1);if(S+1===g.children.length){p.pop();continue}const y=g.children[++p.at(-1)[1]];if(y===null)continue;const{name:v}=y;if(v==="#text"){const T=document.createTextNode(y.value);u.push(T),E.append(T);continue}const A=(f=y==null?void 0:y.attributes)!=null&&f.xmlns?document.createElementNS(y.attributes.xmlns,v):document.createElement(v);if(E.append(A),y.attributes&&this.setAttributes({html:A,element:y,storage:n,intent:i,linkService:r}),((m=y.children)==null?void 0:m.length)>0)p.push([y,-1,A]);else if(y.value){const T=document.createTextNode(y.value);o&&L0.shouldBuildText(v)&&u.push(T),A.append(T)}}for(const g of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:u}}static update(e){const n=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=n,e.div.hidden=!1}}const vc="http://www.w3.org/2000/svg",pf=class pf{};Pe(pf,"CSS",96),Pe(pf,"PDF",72),Pe(pf,"PDF_TO_CSS_UNITS",pf.CSS/pf.PDF);let Tc=pf;async function Wh(t,e="text"){if(B0(t,document.baseURI)){const n=await fetch(t);if(!n.ok)throw new Error(n.statusText);switch(e){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise((n,r)=>{const a=new XMLHttpRequest;a.open("GET",t,!0),a.responseType=e,a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){if(a.status===200||a.status===0){switch(e){case"arraybuffer":case"blob":case"json":n(a.response);return}n(a.responseText);return}r(new Error(a.statusText))}},a.send(null)})}class P0{constructor({viewBox:e,userUnit:n,scale:r,rotation:a,offsetX:i=0,offsetY:s=0,dontFlip:o=!1}){this.viewBox=e,this.userUnit=n,this.scale=r,this.rotation=a,this.offsetX=i,this.offsetY=s,r*=n;const l=(e[2]+e[0])/2,u=(e[3]+e[1])/2;let p,f,m,g;switch(a%=360,a<0&&(a+=360),a){case 180:p=-1,f=0,m=0,g=1;break;case 90:p=0,f=1,m=1,g=0;break;case 270:p=0,f=-1,m=-1,g=0;break;case 0:p=1,f=0,m=0,g=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(m=-m,g=-g);let S,E,y,v;p===0?(S=Math.abs(u-e[1])*r+i,E=Math.abs(l-e[0])*r+s,y=(e[3]-e[1])*r,v=(e[2]-e[0])*r):(S=Math.abs(l-e[0])*r+i,E=Math.abs(u-e[1])*r+s,y=(e[2]-e[0])*r,v=(e[3]-e[1])*r),this.transform=[p*r,f*r,m*r,g*r,S-p*r*l-m*r*u,E-f*r*l-g*r*u],this.width=y,this.height=v}get rawDims(){const e=this.viewBox;return qt(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:n=this.rotation,offsetX:r=this.offsetX,offsetY:a=this.offsetY,dontFlip:i=!1}={}){return new P0({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:n,offsetX:r,offsetY:a,dontFlip:i})}convertToViewportPoint(e,n){const r=[e,n];return Je.applyTransform(r,this.transform),r}convertToViewportRectangle(e){const n=[e[0],e[1]];Je.applyTransform(n,this.transform);const r=[e[2],e[3]];return Je.applyTransform(r,this.transform),[n[0],n[1],r[0],r[1]]}convertToPdfPoint(e,n){const r=[e,n];return Je.applyInverseTransform(r,this.transform),r}}class vA extends of{constructor(e,n=0){super(e,"RenderingCancelledException"),this.extraDelay=n}}function F0(t){const e=t.length;let n=0;for(;n<e&&t[n].trim()==="";)n++;return t.substring(n,n+5).toLowerCase()==="data:"}function TA(t){return typeof t=="string"&&/\.pdf$/i.test(t)}function Tre(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Are(t,e="document.pdf"){if(typeof t!="string")return e;if(F0(t))return It('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const r=(o=>{try{return new URL(o)}catch{try{return new URL(decodeURIComponent(o))}catch{try{return new URL(o,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{return null}}}}})(t);if(!r)return e;const a=o=>{try{let l=decodeURIComponent(o);return l.includes("/")?(l=l.split("/").at(-1),l.test(/^\.pdf$/i)?l:o):l}catch{return o}},i=/\.pdf$/i,s=r.pathname.split("/").at(-1);if(i.test(s))return a(s);if(r.searchParams.size>0){const o=Array.from(r.searchParams.values()).reverse();for(const u of o)if(i.test(u))return a(u);const l=Array.from(r.searchParams.keys()).reverse();for(const u of l)if(i.test(u))return a(u)}if(r.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(r.hash);if(l)return a(l[0])}return e}class Cre{constructor(){Pe(this,"started",Object.create(null));Pe(this,"times",[])}time(e){e in this.started&&It(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||It(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){const e=[];let n=0;for(const{name:r}of this.times)n=Math.max(r.length,n);for(const{name:r,start:a,end:i}of this.times)e.push(`${r.padEnd(n)} ${i-a}ms
623
- `);return e.join("")}}function B0(t,e){const n=e?URL.parse(t,e):URL.parse(t);return(n==null?void 0:n.protocol)==="http:"||(n==null?void 0:n.protocol)==="https:"}function as(t){t.preventDefault()}function Rr(t){t.preventDefault(),t.stopPropagation()}function fUe(t){console.log("Deprecated API usage: "+t)}class U0{static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!="string")return null;_(this,eE)||M(this,eE,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const n=_(this,eE).exec(e);if(!n)return null;const r=parseInt(n[1],10);let a=parseInt(n[2],10);a=a>=1&&a<=12?a-1:0;let i=parseInt(n[3],10);i=i>=1&&i<=31?i:1;let s=parseInt(n[4],10);s=s>=0&&s<=23?s:0;let o=parseInt(n[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(n[6],10);l=l>=0&&l<=59?l:0;const u=n[7]||"Z";let p=parseInt(n[8],10);p=p>=0&&p<=23?p:0;let f=parseInt(n[9],10)||0;return f=f>=0&&f<=59?f:0,u==="-"?(s+=p,o+=f):u==="+"&&(s-=p,o-=f),new Date(Date.UTC(r,a,i,s,o,l))}}eE=new WeakMap,Y(U0,eE);function Rre(t,{scale:e=1,rotation:n=0}){const{width:r,height:a}=t.attributes.style,i=[0,0,parseInt(r),parseInt(a)];return new P0({viewBox:i,userUnit:1,scale:e,rotation:n})}function jh(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(e=>parseInt(e)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):(It(`Not a valid color format: "${t}"`),[0,0,0])}function mUe(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const n of t.keys()){e.style.color=n;const r=window.getComputedStyle(e).color;t.set(n,jh(r))}e.remove()}function Nr(t){const{a:e,b:n,c:r,d:a,e:i,f:s}=t.getTransform();return[e,n,r,a,i,s]}function bl(t){const{a:e,b:n,c:r,d:a,e:i,f:s}=t.getTransform().invertSelf();return[e,n,r,a,i,s]}function od(t,e,n=!1,r=!0){if(e instanceof P0){const{pageWidth:a,pageHeight:i}=e.rawDims,{style:s}=t,o=Ea.isCSSRoundSupported,l=`var(--total-scale-factor) * ${a}px`,u=`var(--total-scale-factor) * ${i}px`,p=o?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,f=o?`round(down, ${u}, var(--scale-round-y))`:`calc(${u})`;!n||e.rotation%180===0?(s.width=p,s.height=f):(s.width=f,s.height=p)}r&&t.setAttribute("data-main-rotation",e.rotation)}class Oo{constructor(){const{pixelRatio:e}=Oo;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(e,n,r,a,i=-1){let s=1/0,o=1/0,l=1/0;r=Oo.capPixels(r,i),r>0&&(s=Math.sqrt(r/(e*n))),a!==-1&&(o=a/e,l=a/n);const u=Math.min(s,o,l);return this.sx>u||this.sy>u?(this.sx=u,this.sy=u,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,n){if(n>=0){const r=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+n/100));return e>0?Math.min(e,r):r}return e}}const AA=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class hUe{static get isDarkMode(){var e;return qt(this,"isDarkMode",!!((e=window==null?void 0:window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches))}}class Nre{static get commentForegroundColor(){const e=document.createElement("span");e.classList.add("comment","sidebar");const{style:n}=e;n.width=n.height="0",n.display="none",n.color="var(--comment-fg-color)",document.body.append(e);const{color:r}=window.getComputedStyle(e);return e.remove(),qt(this,"commentForegroundColor",jh(r))}}function wre(t,e,n,r){r=Math.min(Math.max(r??1,0),1);const a=255*(1-r);return t=Math.round(t*r+a),e=Math.round(e*r+a),n=Math.round(n*r+a),[t,e,n]}function xre(t,e){const n=t[0]/255,r=t[1]/255,a=t[2]/255,i=Math.max(n,r,a),s=Math.min(n,r,a),o=(i+s)/2;if(i===s)e[0]=e[1]=0;else{const l=i-s;switch(e[1]=o<.5?l/(i+s):l/(2-i-s),i){case n:e[0]=((r-a)/l+(r<a?6:0))*60;break;case r:e[0]=((a-n)/l+2)*60;break;case a:e[0]=((n-r)/l+4)*60;break}}e[2]=o}function Z3(t,e){const n=t[0],r=t[1],a=t[2],i=(1-Math.abs(2*a-1))*r,s=i*(1-Math.abs(n/60%2-1)),o=a-i/2;switch(Math.floor(n/60)){case 0:e[0]=i+o,e[1]=s+o,e[2]=o;break;case 1:e[0]=s+o,e[1]=i+o,e[2]=o;break;case 2:e[0]=o,e[1]=i+o,e[2]=s+o;break;case 3:e[0]=o,e[1]=s+o,e[2]=i+o;break;case 4:e[0]=s+o,e[1]=o,e[2]=i+o;break;case 5:case 6:e[0]=i+o,e[1]=o,e[2]=s+o;break}}function Ore(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Ire(t,e,n){Z3(t,n),n.map(Ore);const r=.2126*n[0]+.7152*n[1]+.0722*n[2];Z3(e,n),n.map(Ore);const a=.2126*n[0]+.7152*n[1]+.0722*n[2];return r>a?(r+.05)/(a+.05):(a+.05)/(r+.05)}const Dre=new Map;function kre(t,e){const n=t[0]+t[1]*256+t[2]*65536+e[0]*16777216+e[1]*4294967296+e[2]*1099511627776;let r=Dre.get(n);if(r)return r;const a=new Float32Array(9),i=a.subarray(0,3),s=a.subarray(3,6);xre(t,s);const o=a.subarray(6,9);xre(e,o);const l=o[2]<.5,u=l?12:4.5;if(s[2]=l?Math.sqrt(s[2]):1-Math.sqrt(1-s[2]),Ire(s,o,i)<u){let p,f;l?(p=s[2],f=1):(p=0,f=s[2]);const m=.005;for(;f-p>m;){const g=s[2]=(p+f)/2;l===Ire(s,o,i)<u?p=g:f=g}s[2]=l?f:p}return Z3(s,i),r=Je.makeHexColor(Math.round(i[0]*255),Math.round(i[1]*255),Math.round(i[2]*255)),Dre.set(n,r),r}function J3({html:t,dir:e,className:n},r){const a=document.createDocumentFragment();if(typeof t=="string"){const i=document.createElement("p");i.dir=e||"auto";const s=t.split(/(?:\r\n?|\n)/);for(let o=0,l=s.length;o<l;++o){const u=s[o];i.append(document.createTextNode(u)),o<l-1&&i.append(document.createElement("br"))}a.append(i)}else Q3.render({xfaHtml:t,div:a,intent:"richText"});a.firstChild.classList.add("richText",n),r.append(a)}const Cc=class Cc{constructor(e){Y(this,ka);Y(this,cd,null);Y(this,ud,null);Y(this,zs);Y(this,qs,null);Y(this,tE,null);Y(this,dd,null);Y(this,rg,null);Y(this,ag,null);M(this,zs,e),_(Cc,nE)||M(Cc,nE,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=M(this,cd,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const n=_(this,zs)._uiManager._signal;n instanceof AbortSignal&&!n.aborted&&(e.addEventListener("contextmenu",as,{signal:n}),e.addEventListener("pointerdown",K(Cc,KA,Ale),{signal:n}));const r=M(this,qs,document.createElement("div"));r.className="buttons",e.append(r);const a=_(this,zs).toolbarPosition;if(a){const{style:i}=e,s=_(this,zs)._uiManager.direction==="ltr"?1-a[0]:a[0];i.insetInlineEnd=`${100*s}%`,i.top=`calc(${100*a[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return _(this,cd)}hide(){var e;_(this,cd).classList.add("hidden"),(e=_(this,ud))==null||e.hideDropdown()}show(){var e,n;_(this,cd).classList.remove("hidden"),(e=_(this,tE))==null||e.shown(),(n=_(this,dd))==null||n.shown()}addDeleteButton(){const{editorType:e,_uiManager:n}=_(this,zs),r=document.createElement("button");r.classList.add("basic","deleteButton"),r.tabIndex=0,r.setAttribute("data-l10n-id",_(Cc,nE)[e]),K(this,ka,pb).call(this,r)&&r.addEventListener("click",a=>{n.delete()},{signal:n._signal}),_(this,qs).append(r)}async addAltText(e){const n=await e.render();K(this,ka,pb).call(this,n),_(this,qs).append(n,_(this,ka,vy)),M(this,tE,e)}addComment(e,n=null){if(_(this,dd))return;const r=e.renderForToolbar();if(!r)return;K(this,ka,pb).call(this,r);const a=M(this,rg,_(this,ka,vy));n?(_(this,qs).insertBefore(r,n),_(this,qs).insertBefore(a,n)):_(this,qs).append(r,a),M(this,dd,e),e.toolbar=this}addColorPicker(e){if(_(this,ud))return;M(this,ud,e);const n=e.renderButton();K(this,ka,pb).call(this,n),_(this,qs).append(n,_(this,ka,vy))}async addEditSignatureButton(e){const n=M(this,ag,await e.renderEditButton(_(this,zs)));K(this,ka,pb).call(this,n),_(this,qs).append(n,_(this,ka,vy))}removeButton(e){var n,r;switch(e){case"comment":(n=_(this,dd))==null||n.removeToolbarCommentButton(),M(this,dd,null),(r=_(this,rg))==null||r.remove(),M(this,rg,null);break}}async addButton(e,n){switch(e){case"colorPicker":this.addColorPicker(n);break;case"altText":await this.addAltText(n);break;case"editSignature":await this.addEditSignatureButton(n);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(n);break}}async addButtonBefore(e,n,r){const a=_(this,qs).querySelector(r);a&&e==="comment"&&this.addComment(n,a)}updateEditSignatureButton(e){_(this,ag)&&(_(this,ag).title=e)}remove(){var e;_(this,cd).remove(),(e=_(this,ud))==null||e.destroy(),M(this,ud,null)}};cd=new WeakMap,ud=new WeakMap,zs=new WeakMap,qs=new WeakMap,tE=new WeakMap,dd=new WeakMap,rg=new WeakMap,ag=new WeakMap,nE=new WeakMap,KA=new WeakSet,Ale=function(e){e.stopPropagation()},ka=new WeakSet,Cle=function(e){_(this,zs)._focusEventsAllowed=!1,Rr(e)},Rle=function(e){_(this,zs)._focusEventsAllowed=!0,Rr(e)},pb=function(e){const n=_(this,zs)._uiManager._signal;return!(n instanceof AbortSignal)||n.aborted?!1:(e.addEventListener("focusin",K(this,ka,Cle).bind(this),{capture:!0,signal:n}),e.addEventListener("focusout",K(this,ka,Rle).bind(this),{capture:!0,signal:n}),e.addEventListener("contextmenu",as,{signal:n}),!0)},vy=function(){const e=document.createElement("div");return e.className="divider",e},Y(Cc,KA),Y(Cc,nE,null);let eF=Cc;class gUe{constructor(e){Y(this,Nc);Y(this,rE,null);Y(this,ff,null);Y(this,Rc);M(this,Rc,e)}show(e,n,r){const[a,i]=K(this,Nc,wle).call(this,n,r),{style:s}=_(this,ff)||M(this,ff,K(this,Nc,Nle).call(this));e.append(_(this,ff)),s.insetInlineEnd=`${100*a}%`,s.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){_(this,ff).remove()}}rE=new WeakMap,ff=new WeakMap,Rc=new WeakMap,Nc=new WeakSet,Nle=function(){const e=M(this,ff,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar");const n=_(this,Rc)._signal;n instanceof AbortSignal&&!n.aborted&&e.addEventListener("contextmenu",as,{signal:n});const r=M(this,rE,document.createElement("div"));return r.className="buttons",e.append(r),_(this,Rc).hasCommentManager()&&K(this,Nc,HB).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{_(this,Rc).commentSelection("floating_button")}),K(this,Nc,HB).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{_(this,Rc).highlightSelection("floating_button")}),e},wle=function(e,n){let r=0,a=0;for(const i of e){const s=i.y+i.height;if(s<r)continue;const o=i.x+(n?i.width:0);if(s>r){a=o,r=s;continue}n?o>a&&(a=o):o<a&&(a=o)}return[n?1-a:a,r]},HB=function(e,n,r,a){const i=document.createElement("button");i.classList.add("basic",e),i.tabIndex=0,i.setAttribute("data-l10n-id",n);const s=document.createElement("span");i.append(s),s.className="visuallyHidden",s.setAttribute("data-l10n-id",r);const o=_(this,Rc)._signal;o instanceof AbortSignal&&!o.aborted&&(i.addEventListener("contextmenu",as,{signal:o}),i.addEventListener("click",a,{signal:o})),_(this,rE).append(i)};function Mre(t,e,n){for(const r of n)e.addEventListener(r,t[r].bind(t))}class _Ue{constructor(){Y(this,XA,0)}get id(){return`${O0}${_a(this,XA)._++}`}}XA=new WeakMap;const PF=class PF{constructor(){Y(this,sg);Y(this,ig,K3());Y(this,aE,0);Y(this,Qa,null)}static get _isSVGFittingCanvas(){const e='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',r=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),a=new Image;a.src=e;const i=a.decode().then(()=>(r.drawImage(a,0,0,1,1,0,0,1,3),new Uint32Array(r.getImageData(0,0,1,1).data.buffer)[0]===0));return qt(this,"_isSVGFittingCanvas",i)}async getFromFile(e){const{lastModified:n,name:r,size:a,type:i}=e;return K(this,sg,TR).call(this,`${n}_${r}_${a}_${i}`,e)}async getFromUrl(e){return K(this,sg,TR).call(this,e,e)}async getFromBlob(e,n){const r=await n;return K(this,sg,TR).call(this,e,r)}async getFromId(e){_(this,Qa)||M(this,Qa,new Map);const n=_(this,Qa).get(e);if(!n)return null;if(n.bitmap)return n.refCounter+=1,n;if(n.file)return this.getFromFile(n.file);if(n.blobPromise){const{blobPromise:r}=n;return delete n.blobPromise,this.getFromBlob(n.id,r)}return this.getFromUrl(n.url)}getFromCanvas(e,n){_(this,Qa)||M(this,Qa,new Map);let r=_(this,Qa).get(e);if(r!=null&&r.bitmap)return r.refCounter+=1,r;const a=new OffscreenCanvas(n.width,n.height);return a.getContext("2d").drawImage(n,0,0),r={bitmap:a.transferToImageBitmap(),id:`image_${_(this,ig)}_${_a(this,aE)._++}`,refCounter:1,isSvg:!1},_(this,Qa).set(e,r),_(this,Qa).set(r.id,r),r}getSvgUrl(e){const n=_(this,Qa).get(e);return n!=null&&n.isSvg?n.svgUrl:null}deleteId(e){var a;_(this,Qa)||M(this,Qa,new Map);const n=_(this,Qa).get(e);if(!n||(n.refCounter-=1,n.refCounter!==0))return;const{bitmap:r}=n;if(!n.url&&!n.file){const i=new OffscreenCanvas(r.width,r.height);i.getContext("bitmaprenderer").transferFromImageBitmap(r),n.blobPromise=i.convertToBlob()}(a=r.close)==null||a.call(r),n.bitmap=null}isValidId(e){return e.startsWith(`image_${_(this,ig)}_`)}};ig=new WeakMap,aE=new WeakMap,Qa=new WeakMap,sg=new WeakSet,TR=async function(e,n){_(this,Qa)||M(this,Qa,new Map);let r=_(this,Qa).get(e);if(r===null)return null;if(r!=null&&r.bitmap)return r.refCounter+=1,r;try{r||(r={bitmap:null,id:`image_${_(this,ig)}_${_a(this,aE)._++}`,refCounter:0,isSvg:!1});let a;if(typeof n=="string"?(r.url=n,a=await Wh(n,"blob")):n instanceof File?a=r.file=n:n instanceof Blob&&(a=n),a.type==="image/svg+xml"){const i=PF._isSVGFittingCanvas,s=new FileReader,o=new Image,l=new Promise((u,p)=>{o.onload=()=>{r.bitmap=o,r.isSvg=!0,u()},s.onload=async()=>{const f=r.svgUrl=s.result;o.src=await i?`${f}#svgView(preserveAspectRatio(none))`:f},o.onerror=s.onerror=p});s.readAsDataURL(a),await l}else r.bitmap=await createImageBitmap(a);r.refCounter=1}catch(a){It(a),r=null}return _(this,Qa).set(e,r),r&&_(this,Qa).set(r.id,r),r};let tF=PF;class bUe{constructor(e=128){Y(this,Vr,[]);Y(this,pd,!1);Y(this,iE);Y(this,xr,-1);M(this,iE,e)}add({cmd:e,undo:n,post:r,mustExec:a,type:i=NaN,overwriteIfSameType:s=!1,keepUndo:o=!1}){if(a&&e(),_(this,pd))return;const l={cmd:e,undo:n,post:r,type:i};if(_(this,xr)===-1){_(this,Vr).length>0&&(_(this,Vr).length=0),M(this,xr,0),_(this,Vr).push(l);return}if(s&&_(this,Vr)[_(this,xr)].type===i){o&&(l.undo=_(this,Vr)[_(this,xr)].undo),_(this,Vr)[_(this,xr)]=l;return}const u=_(this,xr)+1;u===_(this,iE)?_(this,Vr).splice(0,1):(M(this,xr,u),u<_(this,Vr).length&&_(this,Vr).splice(u)),_(this,Vr).push(l)}undo(){if(_(this,xr)===-1)return;M(this,pd,!0);const{undo:e,post:n}=_(this,Vr)[_(this,xr)];e(),n==null||n(),M(this,pd,!1),M(this,xr,_(this,xr)-1)}redo(){if(_(this,xr)<_(this,Vr).length-1){M(this,xr,_(this,xr)+1),M(this,pd,!0);const{cmd:e,post:n}=_(this,Vr)[_(this,xr)];e(),n==null||n(),M(this,pd,!1)}}hasSomethingToUndo(){return _(this,xr)!==-1}hasSomethingToRedo(){return _(this,xr)<_(this,Vr).length-1}cleanType(e){if(_(this,xr)!==-1){for(let n=_(this,xr);n>=0;n--)if(_(this,Vr)[n].type!==e){_(this,Vr).splice(n+1,_(this,xr)-n),M(this,xr,n);return}_(this,Vr).length=0,M(this,xr,-1)}}destroy(){M(this,Vr,null)}}Vr=new WeakMap,pd=new WeakMap,iE=new WeakMap,xr=new WeakMap;class G0{constructor(e){Y(this,QA);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:n}=Ea.platform;for(const[r,a,i={}]of e)for(const s of r){const o=s.startsWith("mac+");n&&o?(this.callbacks.set(s.slice(4),{callback:a,options:i}),this.allKeys.add(s.split("+").at(-1))):!n&&!o&&(this.callbacks.set(s,{callback:a,options:i}),this.allKeys.add(s.split("+").at(-1)))}}exec(e,n){if(!this.allKeys.has(n.key))return;const r=this.callbacks.get(K(this,QA,xle).call(this,n));if(!r)return;const{callback:a,options:{bubbles:i=!1,args:s=[],checker:o=null}}=r;o&&!o(e,n)||(a.bind(e,...s,n)(),i||Rr(n))}}QA=new WeakSet,xle=function(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const n=this.buffer.join("+");return this.buffer.length=0,n};const ZA=class ZA{get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return mUe(e),qt(this,"_colors",e)}convert(e){const n=jh(e);if(!window.matchMedia("(forced-colors: active)").matches)return n;for(const[r,a]of this._colors)if(a.every((i,s)=>i===n[s]))return ZA._colorsMapping.get(r);return n}getHexCode(e){const n=this._colors.get(e);return n?Je.makeHexColor(...n):e}};Pe(ZA,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let nF=ZA;const _g=class _g{constructor(e,n,r,a,i,s,o,l,u,p,f,m,g,S,E,y){Y(this,We);Y(this,og,new AbortController);Y(this,ss,null);Y(this,lg,null);Y(this,Mr,new Map);Y(this,la,new Map);Y(this,cg,null);Y(this,Hs,null);Y(this,ug,null);Y(this,$s,new bUe);Y(this,Za,null);Y(this,fd,null);Y(this,md,null);Y(this,dg,0);Y(this,hd,new Set);Y(this,yl,null);Y(this,Ys,null);Y(this,mf,new Set);Pe(this,"_editorUndoBar",null);Y(this,sE,!1);Y(this,oE,!1);Y(this,pg,!1);Y(this,lE,null);Y(this,vl,null);Y(this,gd,null);Y(this,fg,null);Y(this,_d,!1);Y(this,Tl,null);Y(this,JA,new _Ue);Y(this,bd,!1);Y(this,mg,!1);Y(this,cE,!1);Y(this,Ed,null);Y(this,hf,null);Y(this,hg,null);Y(this,Sd,null);Y(this,uE,null);Y(this,ea,Ot.NONE);Y(this,Dn,new Set);Y(this,wc,null);Y(this,yd,null);Y(this,vd,null);Y(this,dE,null);Y(this,gg,null);Y(this,pE,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});Y(this,Td,[0,0]);Y(this,Al,null);Y(this,xc,null);Y(this,fE,null);Y(this,mE,null);Y(this,Vs,null);const v=this._signal=_(this,og).signal;M(this,xc,e),M(this,fE,n),M(this,mE,r),M(this,cg,a),M(this,Za,i),M(this,yd,s),M(this,gg,l),this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:v}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:v}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:v}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:v}),o._on("setpreference",this.onSetPreference.bind(this),{signal:v}),o._on("switchannotationeditorparams",A=>this.updateParams(A.type,A.value),{signal:v}),window.addEventListener("pointerdown",()=>{M(this,mg,!0)},{capture:!0,signal:v}),window.addEventListener("pointerup",()=>{M(this,mg,!1)},{capture:!0,signal:v}),K(this,We,Dle).call(this),K(this,We,Ple).call(this),K(this,We,YB).call(this),M(this,Hs,l.annotationStorage),M(this,lE,l.filterFactory),M(this,vd,u),M(this,fg,p||null),M(this,sE,f),M(this,oE,m),M(this,pg,g),M(this,uE,S||null),this.viewParameters={realScale:Tc.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=E||null,this._supportsPinchToZoom=y!==!1,i==null||i.setSidebarUiManager(this)}static get _keyboardManager(){const e=_g.prototype,n=s=>_(s,xc).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&s.hasSomethingToControl(),r=(s,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},a=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return qt(this,"_keyboardManager",new G0([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:r}],[["ctrl+z","mac+meta+z"],e.undo,{checker:r}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:r}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:r}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(s,{target:o})=>!(o instanceof HTMLButtonElement)&&_(s,xc).contains(o)&&!s.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(s,{target:o})=>!(o instanceof HTMLButtonElement)&&_(s,xc).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:n}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:n}]]))}destroy(){var e,n,r,a,i,s,o,l,u;(e=_(this,Vs))==null||e.resolve(),M(this,Vs,null),(n=_(this,og))==null||n.abort(),M(this,og,null),this._signal=null;for(const p of _(this,la).values())p.destroy();_(this,la).clear(),_(this,Mr).clear(),_(this,mf).clear(),(r=_(this,Sd))==null||r.clear(),M(this,ss,null),_(this,Dn).clear(),_(this,$s).destroy(),(a=_(this,cg))==null||a.destroy(),(i=_(this,Za))==null||i.destroy(),(s=_(this,yd))==null||s.destroy(),(o=_(this,Tl))==null||o.hide(),M(this,Tl,null),(l=_(this,hg))==null||l.destroy(),M(this,hg,null),M(this,lg,null),_(this,vl)&&(clearTimeout(_(this,vl)),M(this,vl,null)),_(this,Al)&&(clearTimeout(_(this,Al)),M(this,Al,null)),(u=this._editorUndoBar)==null||u.destroy(),M(this,gg,null)}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return _(this,uE)}get useNewAltTextFlow(){return _(this,oE)}get useNewAltTextWhenAddingImage(){return _(this,pg)}get hcmFilter(){return qt(this,"hcmFilter",_(this,vd)?_(this,lE).addHCMFilter(_(this,vd).foreground,_(this,vd).background):"none")}get direction(){return qt(this,"direction",getComputedStyle(_(this,xc)).direction)}get _highlightColors(){return qt(this,"_highlightColors",_(this,fg)?new Map(_(this,fg).split(",").map(e=>(e=e.split("=").map(n=>n.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){const{_highlightColors:e}=this;if(!e)return qt(this,"highlightColors",null);const n=new Map,r=!!_(this,vd);for(const[a,i]of e){const s=a.endsWith("_HCM");if(r&&s){n.set(a.replace("_HCM",""),i);continue}!r&&!s&&n.set(a,i)}return qt(this,"highlightColors",n)}get highlightColorNames(){return qt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;const n=this.highlightColorNames.get(e);return this._highlightColors.get(n)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),M(this,md,e)}setMainHighlightColorPicker(e){M(this,hg,e)}editAltText(e,n=!1){var r;(r=_(this,cg))==null||r.editAltText(this,e,n)}hasCommentManager(){return!!_(this,Za)}editComment(e,n,r,a){var i;(i=_(this,Za))==null||i.showDialog(this,e,n,r,a)}selectComment(e,n){const r=_(this,la).get(e),a=r==null?void 0:r.getEditorByUID(n);a==null||a.toggleComment(!0,!0)}updateComment(e){var n;(n=_(this,Za))==null||n.updateComment(e.getData())}updatePopupColor(e){var n;(n=_(this,Za))==null||n.updatePopupColor(e)}removeComment(e){var n;(n=_(this,Za))==null||n.removeComments([e.uid])}toggleComment(e,n,r=void 0){var a;(a=_(this,Za))==null||a.toggleCommentPopup(e,n,r)}makeCommentColor(e,n){var r;return e&&((r=_(this,Za))==null?void 0:r.makeCommentColor(e,n))||null}getCommentDialogElement(){var e;return((e=_(this,Za))==null?void 0:e.dialogElement)||null}async waitForEditorsRendered(e){if(_(this,la).has(e-1))return;const{resolve:n,promise:r}=Promise.withResolvers(),a=i=>{i.pageNumber===e&&(this._eventBus._off("editorsrendered",a),n())};this._eventBus.on("editorsrendered",a),await r}getSignature(e){var n;(n=_(this,yd))==null||n.getSignature({uiManager:this,editor:e})}get signatureManager(){return _(this,yd)}switchToMode(e,n){this._eventBus.on("annotationeditormodechanged",n,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,n){this._eventBus.dispatch("setpreference",{source:this,name:e,value:n})}onSetPreference({name:e,value:n}){switch(e){case"enableNewAltTextWhenAddingImage":M(this,pg,n);break}}onPageChanging({pageNumber:e}){M(this,dg,e-1)}focusMainContainer(){_(this,xc).focus()}findParent(e,n){for(const r of _(this,la).values()){const{x:a,y:i,width:s,height:o}=r.div.getBoundingClientRect();if(e>=a&&e<=a+s&&n>=i&&n<=i+o)return r}return null}disableUserSelect(e=!1){_(this,fE).classList.toggle("noUserSelect",e)}addShouldRescale(e){_(this,mf).add(e)}removeShouldRescale(e){_(this,mf).delete(e)}onScaleChanging({scale:e}){var n;this.commitOrRemove(),this.viewParameters.realScale=e*Tc.PDF_TO_CSS_UNITS;for(const r of _(this,mf))r.onScaleChanging();(n=_(this,md))==null||n.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e="",n=!1){const r=document.getSelection();if(!r||r.isCollapsed)return;const{anchorNode:a,anchorOffset:i,focusNode:s,focusOffset:o}=r,l=r.toString(),p=K(this,We,AR).call(this,r).closest(".textLayer"),f=this.getSelectionBoxes(p);if(!f)return;r.empty();const m=K(this,We,$B).call(this,p),g=_(this,ea)===Ot.NONE,S=()=>{const E=m==null?void 0:m.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:f,anchorNode:a,anchorOffset:i,focusNode:s,focusOffset:o,text:l});g&&this.showAllEditors("highlight",!0,!0),n&&(E==null||E.editComment())};if(g){this.switchToMode(Ot.HIGHLIGHT,S);return}S()}commentSelection(e=""){this.highlightSelection(e,!0)}getAndRemoveDataFromAnnotationStorage(e){if(!_(this,Hs))return null;const n=`${O0}${e}`,r=_(this,Hs).getRawValue(n);return r&&_(this,Hs).remove(n),r}addToAnnotationStorage(e){!e.isEmpty()&&_(this,Hs)&&!_(this,Hs).has(e.id)&&_(this,Hs).setValue(e.id,e)}a11yAlert(e,n=null){const r=_(this,mE);r&&(r.setAttribute("data-l10n-id",e),n?r.setAttribute("data-l10n-args",JSON.stringify(n)):r.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,_(this,_d)&&(M(this,_d,!1),K(this,We,Ty).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const n of _(this,Dn))if(n.div.contains(e)){M(this,hf,[n,e]),n._focusEventsAllowed=!1;break}}focus(){if(!_(this,hf))return;const[e,n]=_(this,hf);M(this,hf,null),n.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),n.focus()}addEditListeners(){K(this,We,YB).call(this),K(this,We,VB).call(this)}removeEditListeners(){K(this,We,Lle).call(this),K(this,We,WB).call(this)}dragOver(e){for(const{type:n}of e.dataTransfer.items)for(const r of _(this,Ys))if(r.isHandlingMimeForPasting(n)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const n of e.dataTransfer.items)for(const r of _(this,Ys))if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer),e.preventDefault();return}}copy(e){var r;if(e.preventDefault(),(r=_(this,ss))==null||r.commitOrRemove(),!this.hasSelection)return;const n=[];for(const a of _(this,Dn)){const i=a.serialize(!0);i&&n.push(i)}n.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(n))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:n}=e;for(const i of n.items)for(const s of _(this,Ys))if(s.isHandlingMimeForPasting(i.type)){s.paste(i,this.currentLayer);return}let r=n.getData("application/pdfjs");if(!r)return;try{r=JSON.parse(r)}catch(i){It(`paste: "${i.message}".`);return}if(!Array.isArray(r))return;this.unselectAll();const a=this.currentLayer;try{const i=[];for(const l of r){const u=await a.deserialize(l);if(!u)return;i.push(u)}const s=()=>{for(const l of i)K(this,We,jB).call(this,l);K(this,We,KB).call(this,i)},o=()=>{for(const l of i)l.remove()};this.addCommands({cmd:s,undo:o,mustExec:!0})}catch(i){It(`paste: "${i.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),_(this,ea)!==Ot.NONE&&!this.isEditorHandlingKeyboard&&_g._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,_(this,_d)&&(M(this,_d,!1),K(this,We,Ty).call(this,"main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}setEditingState(e){e?(K(this,We,kle).call(this),K(this,We,VB).call(this),K(this,We,Ei).call(this,{isEditing:_(this,ea)!==Ot.NONE,isEmpty:K(this,We,Ay).call(this),hasSomethingToUndo:_(this,$s).hasSomethingToUndo(),hasSomethingToRedo:_(this,$s).hasSomethingToRedo(),hasSelectedEditor:!1})):(K(this,We,Mle).call(this),K(this,We,WB).call(this),K(this,We,Ei).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!_(this,Ys)){M(this,Ys,e);for(const n of _(this,Ys))K(this,We,Iu).call(this,n.defaultPropertiesToUpdate)}}getId(){return _(this,JA).id}get currentLayer(){return _(this,la).get(_(this,dg))}getLayer(e){return _(this,la).get(e)}get currentPageIndex(){return _(this,dg)}addLayer(e){_(this,la).set(e.pageIndex,e),_(this,bd)?e.enable():e.disable()}removeLayer(e){_(this,la).delete(e.pageIndex)}async updateMode(e,n=null,r=!1,a=!1,i=!1){var s,o,l,u,p,f;if(_(this,ea)!==e&&!(_(this,Vs)&&(await _(this,Vs).promise,!_(this,Vs)))){if(M(this,Vs,Promise.withResolvers()),(s=_(this,md))==null||s.commitOrRemove(),_(this,ea)===Ot.POPUP&&((o=_(this,Za))==null||o.hideSidebar()),(l=_(this,Za))==null||l.destroyPopup(),M(this,ea,e),e===Ot.NONE){this.setEditingState(!1),K(this,We,Ble).call(this);for(const m of _(this,Mr).values())m.hideStandaloneCommentButton();(u=this._editorUndoBar)==null||u.hide(),this.toggleComment(null),_(this,Vs).resolve();return}for(const m of _(this,Mr).values())m.addStandaloneCommentButton();e===Ot.SIGNATURE&&await((p=_(this,yd))==null?void 0:p.loadSignatures()),this.setEditingState(!0),await K(this,We,Fle).call(this),this.unselectAll();for(const m of _(this,la).values())m.updateMode(e);if(e===Ot.POPUP){_(this,lg)||M(this,lg,await _(this,gg).getAnnotationsByType(new Set(_(this,Ys).map(S=>S._editorType))));const m=new Set,g=[];for(const S of _(this,Mr).values()){const{annotationElementId:E,hasComment:y,deleted:v}=S;E&&m.add(E),y&&!v&&g.push(S.getData())}for(const S of _(this,lg)){const{id:E,popupRef:y,contentsObj:v}=S;y&&(v!=null&&v.str)&&!m.has(E)&&!_(this,hd).has(E)&&g.push(S)}(f=_(this,Za))==null||f.showSidebar(g)}if(!n){r&&this.addNewEditorFromKeyboard(),_(this,Vs).resolve();return}for(const m of _(this,Mr).values())m.uid===n?(this.setSelected(m),i?m.editComment():a?m.enterInEditMode():m.focus()):m.unselect();_(this,Vs).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==_(this,ea)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,n){if(_(this,Ys)){switch(e){case rn.CREATE:this.currentLayer.addNewEditor(n);return;case rn.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(_(this,dE)||M(this,dE,new Map)).set(e,n),this.showAllEditors("highlight",n);break}if(this.hasSelection)for(const r of _(this,Dn))r.updateParams(e,n);else for(const r of _(this,Ys))r.updateDefaultParams(e,n)}}showAllEditors(e,n,r=!1){var i;for(const s of _(this,Mr).values())s.editorType===e&&s.show(n);(((i=_(this,dE))==null?void 0:i.get(rn.HIGHLIGHT_SHOW_ALL))??!0)!==n&&K(this,We,Iu).call(this,[[rn.HIGHLIGHT_SHOW_ALL,n]])}enableWaiting(e=!1){if(_(this,cE)!==e){M(this,cE,e);for(const n of _(this,la).values())e?n.disableClick():n.enableClick(),n.div.classList.toggle("waiting",e)}}*getEditors(e){for(const n of _(this,Mr).values())n.pageIndex===e&&(yield n)}getEditor(e){return _(this,Mr).get(e)}addEditor(e){_(this,Mr).set(e.id,e)}removeEditor(e){var n,r;e.div.contains(document.activeElement)&&(_(this,vl)&&clearTimeout(_(this,vl)),M(this,vl,setTimeout(()=>{this.focusMainContainer(),M(this,vl,null)},0))),_(this,Mr).delete(e.id),e.annotationElementId&&((n=_(this,Sd))==null||n.delete(e.annotationElementId)),this.unselect(e),(!e.annotationElementId||!_(this,hd).has(e.annotationElementId))&&((r=_(this,Hs))==null||r.remove(e.id))}addDeletedAnnotationElement(e){_(this,hd).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return _(this,hd).has(e)}removeDeletedAnnotationElement(e){_(this,hd).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){_(this,ss)!==e&&(M(this,ss,e),e&&K(this,We,Iu).call(this,e.propertiesToUpdate))}updateUI(e){_(this,We,Ule)===e&&K(this,We,Iu).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){K(this,We,Iu).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(_(this,Dn).has(e)){_(this,Dn).delete(e),e.unselect(),K(this,We,Ei).call(this,{hasSelectedEditor:this.hasSelection});return}_(this,Dn).add(e),e.select(),K(this,We,Iu).call(this,e.propertiesToUpdate),K(this,We,Ei).call(this,{hasSelectedEditor:!0})}setSelected(e){var n;this.updateToolbar({mode:e.mode,editId:e.id}),(n=_(this,md))==null||n.commitOrRemove();for(const r of _(this,Dn))r!==e&&r.unselect();_(this,Dn).clear(),_(this,Dn).add(e),e.select(),K(this,We,Iu).call(this,e.propertiesToUpdate),K(this,We,Ei).call(this,{hasSelectedEditor:!0})}isSelected(e){return _(this,Dn).has(e)}get firstSelectedEditor(){return _(this,Dn).values().next().value}unselect(e){e.unselect(),_(this,Dn).delete(e),K(this,We,Ei).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return _(this,Dn).size!==0}get isEnterHandled(){return _(this,Dn).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var e;_(this,$s).undo(),K(this,We,Ei).call(this,{hasSomethingToUndo:_(this,$s).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:K(this,We,Ay).call(this)}),(e=this._editorUndoBar)==null||e.hide()}redo(){_(this,$s).redo(),K(this,We,Ei).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:_(this,$s).hasSomethingToRedo(),isEmpty:K(this,We,Ay).call(this)})}addCommands(e){_(this,$s).add(e),K(this,We,Ei).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:K(this,We,Ay).call(this)})}cleanUndoStack(e){_(this,$s).cleanType(e)}delete(){var i;this.commitOrRemove();const e=(i=this.currentLayer)==null?void 0:i.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const n=e?[e]:[..._(this,Dn)],r=()=>{var s;(s=this._editorUndoBar)==null||s.show(a,n.length===1?n[0].editorType:n.length);for(const o of n)o.remove()},a=()=>{for(const s of n)K(this,We,jB).call(this,s)};this.addCommands({cmd:r,undo:a,mustExec:!0})}commitOrRemove(){var e;(e=_(this,ss))==null||e.commitOrRemove()}hasSomethingToControl(){return _(this,ss)||this.hasSelection}selectAll(){for(const e of _(this,Dn))e.commit();K(this,We,KB).call(this,_(this,Mr).values())}unselectAll(){var e;if(!(_(this,ss)&&(_(this,ss).commitOrRemove(),_(this,ea)!==Ot.NONE))&&!((e=_(this,md))!=null&&e.commitOrRemove())&&this.hasSelection){for(const n of _(this,Dn))n.unselect();_(this,Dn).clear(),K(this,We,Ei).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,n,r=!1){if(r||this.commitOrRemove(),!this.hasSelection)return;_(this,Td)[0]+=e,_(this,Td)[1]+=n;const[a,i]=_(this,Td),s=[..._(this,Dn)],o=1e3;_(this,Al)&&clearTimeout(_(this,Al)),M(this,Al,setTimeout(()=>{M(this,Al,null),_(this,Td)[0]=_(this,Td)[1]=0,this.addCommands({cmd:()=>{for(const l of s)_(this,Mr).has(l.id)&&(l.translateInPage(a,i),l.translationDone())},undo:()=>{for(const l of s)_(this,Mr).has(l.id)&&(l.translateInPage(-a,-i),l.translationDone())},mustExec:!1})},o));for(const l of s)l.translateInPage(e,n),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),M(this,yl,new Map);for(const e of _(this,Dn))_(this,yl).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!_(this,yl))return!1;this.disableUserSelect(!1);const e=_(this,yl);M(this,yl,null);let n=!1;for(const[{x:a,y:i,pageIndex:s},o]of e)o.newX=a,o.newY=i,o.newPageIndex=s,n||(n=a!==o.savedX||i!==o.savedY||s!==o.savedPageIndex);if(!n)return!1;const r=(a,i,s,o)=>{if(_(this,Mr).has(a.id)){const l=_(this,la).get(o);l?a._setParentAndPosition(l,i,s):(a.pageIndex=o,a.x=i,a.y=s)}};return this.addCommands({cmd:()=>{for(const[a,{newX:i,newY:s,newPageIndex:o}]of e)r(a,i,s,o)},undo:()=>{for(const[a,{savedX:i,savedY:s,savedPageIndex:o}]of e)r(a,i,s,o)},mustExec:!0}),!0}dragSelectedEditors(e,n){if(_(this,yl))for(const r of _(this,yl).keys())r.drag(e,n)}rebuild(e){if(e.parent===null){const n=this.getLayer(e.pageIndex);n?(n.changeParent(e),n.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){var e;return((e=this.getActive())==null?void 0:e.shouldGetKeyboardEvents())||_(this,Dn).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return _(this,ss)===e}getActive(){return _(this,ss)}getMode(){return _(this,ea)}isEditingMode(){return _(this,ea)!==Ot.NONE}get imageManager(){return qt(this,"imageManager",new tF)}getSelectionBoxes(e){if(!e)return null;const n=document.getSelection();for(let u=0,p=n.rangeCount;u<p;u++)if(!e.contains(n.getRangeAt(u).commonAncestorContainer))return null;const{x:r,y:a,width:i,height:s}=e.getBoundingClientRect();let o;switch(e.getAttribute("data-main-rotation")){case"90":o=(u,p,f,m)=>({x:(p-a)/s,y:1-(u+f-r)/i,width:m/s,height:f/i});break;case"180":o=(u,p,f,m)=>({x:1-(u+f-r)/i,y:1-(p+m-a)/s,width:f/i,height:m/s});break;case"270":o=(u,p,f,m)=>({x:1-(p+m-a)/s,y:(u-r)/i,width:m/s,height:f/i});break;default:o=(u,p,f,m)=>({x:(u-r)/i,y:(p-a)/s,width:f/i,height:m/s});break}const l=[];for(let u=0,p=n.rangeCount;u<p;u++){const f=n.getRangeAt(u);if(!f.collapsed)for(const{x:m,y:g,width:S,height:E}of f.getClientRects())S===0||E===0||l.push(o(m,g,S,E))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:e,id:n}){(_(this,ug)||M(this,ug,new Map)).set(e,n)}removeChangedExistingAnnotation({annotationElementId:e}){var n;(n=_(this,ug))==null||n.delete(e)}renderAnnotationElement(e){var a;const n=(a=_(this,ug))==null?void 0:a.get(e.data.id);if(!n)return;const r=_(this,Hs).getRawValue(n);r&&(_(this,ea)===Ot.NONE&&!r.hasBeenModified||r.renderAnnotationElement(e))}setMissingCanvas(e,n,r){var i;const a=(i=_(this,Sd))==null?void 0:i.get(e);a&&(a.setCanvas(n,r),_(this,Sd).delete(e))}addMissingCanvas(e,n){(_(this,Sd)||M(this,Sd,new Map)).set(e,n)}};og=new WeakMap,ss=new WeakMap,lg=new WeakMap,Mr=new WeakMap,la=new WeakMap,cg=new WeakMap,Hs=new WeakMap,ug=new WeakMap,$s=new WeakMap,Za=new WeakMap,fd=new WeakMap,md=new WeakMap,dg=new WeakMap,hd=new WeakMap,yl=new WeakMap,Ys=new WeakMap,mf=new WeakMap,sE=new WeakMap,oE=new WeakMap,pg=new WeakMap,lE=new WeakMap,vl=new WeakMap,gd=new WeakMap,fg=new WeakMap,_d=new WeakMap,Tl=new WeakMap,JA=new WeakMap,bd=new WeakMap,mg=new WeakMap,cE=new WeakMap,Ed=new WeakMap,hf=new WeakMap,hg=new WeakMap,Sd=new WeakMap,uE=new WeakMap,ea=new WeakMap,Dn=new WeakMap,wc=new WeakMap,yd=new WeakMap,vd=new WeakMap,dE=new WeakMap,gg=new WeakMap,pE=new WeakMap,Td=new WeakMap,Al=new WeakMap,xc=new WeakMap,fE=new WeakMap,mE=new WeakMap,Vs=new WeakMap,We=new WeakSet,AR=function({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e},$B=function(e){const{currentLayer:n}=this;if(n.hasTextLayer(e))return n;for(const r of _(this,la).values())if(r.hasTextLayer(e))return r;return null},Ole=function(){const e=document.getSelection();if(!e||e.isCollapsed)return;const r=K(this,We,AR).call(this,e).closest(".textLayer"),a=this.getSelectionBoxes(r);a&&(_(this,Tl)||M(this,Tl,new gUe(this)),_(this,Tl).show(r,a,this.direction==="ltr"))},Ile=function(){var i,s,o;const e=document.getSelection();if(!e||e.isCollapsed){_(this,wc)&&((i=_(this,Tl))==null||i.hide(),M(this,wc,null),K(this,We,Ei).call(this,{hasSelectedText:!1}));return}const{anchorNode:n}=e;if(n===_(this,wc))return;const a=K(this,We,AR).call(this,e).closest(".textLayer");if(!a){_(this,wc)&&((s=_(this,Tl))==null||s.hide(),M(this,wc,null),K(this,We,Ei).call(this,{hasSelectedText:!1}));return}if((o=_(this,Tl))==null||o.hide(),M(this,wc,n),K(this,We,Ei).call(this,{hasSelectedText:!0}),!(_(this,ea)!==Ot.HIGHLIGHT&&_(this,ea)!==Ot.NONE)&&(_(this,ea)===Ot.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),M(this,_d,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=_(this,ea)===Ot.HIGHLIGHT?K(this,We,$B).call(this,a):null;if(l==null||l.toggleDrawing(),_(this,mg)){const u=new AbortController,p=this.combinedSignal(u),f=m=>{m.type==="pointerup"&&m.button!==0||(u.abort(),l==null||l.toggleDrawing(!0),m.type==="pointerup"&&K(this,We,Ty).call(this,"main_toolbar"))};window.addEventListener("pointerup",f,{signal:p}),window.addEventListener("blur",f,{signal:p})}else l==null||l.toggleDrawing(!0),K(this,We,Ty).call(this,"main_toolbar")}},Ty=function(e=""){_(this,ea)===Ot.HIGHLIGHT?this.highlightSelection(e):_(this,sE)&&K(this,We,Ole).call(this)},Dle=function(){document.addEventListener("selectionchange",K(this,We,Ile).bind(this),{signal:this._signal})},kle=function(){if(_(this,gd))return;M(this,gd,new AbortController);const e=this.combinedSignal(_(this,gd));window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})},Mle=function(){var e;(e=_(this,gd))==null||e.abort(),M(this,gd,null)},YB=function(){if(_(this,Ed))return;M(this,Ed,new AbortController);const e=this.combinedSignal(_(this,Ed));window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})},Lle=function(){var e;(e=_(this,Ed))==null||e.abort(),M(this,Ed,null)},VB=function(){if(_(this,fd))return;M(this,fd,new AbortController);const e=this.combinedSignal(_(this,fd));document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})},WB=function(){var e;(e=_(this,fd))==null||e.abort(),M(this,fd,null)},Ple=function(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})},Ei=function(e){Object.entries(e).some(([r,a])=>_(this,pE)[r]!==a)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(_(this,pE),e)}),_(this,ea)===Ot.HIGHLIGHT&&e.hasSelectedEditor===!1&&K(this,We,Iu).call(this,[[rn.HIGHLIGHT_FREE,!0]]))},Iu=function(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})},Fle=async function(){if(!_(this,bd)){M(this,bd,!0);const e=[];for(const n of _(this,la).values())e.push(n.enable());await Promise.all(e);for(const n of _(this,Mr).values())n.enable()}},Ble=function(){if(this.unselectAll(),_(this,bd)){M(this,bd,!1);for(const e of _(this,la).values())e.disable();for(const e of _(this,Mr).values())e.disable()}},jB=function(e){const n=_(this,la).get(e.pageIndex);n?n.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},Ule=function(){let e=null;for(e of _(this,Dn));return e},Ay=function(){if(_(this,Mr).size===0)return!0;if(_(this,Mr).size===1)for(const e of _(this,Mr).values())return e.isEmpty();return!1},KB=function(e){for(const n of _(this,Dn))n.unselect();_(this,Dn).clear();for(const n of e)n.isEmpty()||(_(this,Dn).add(n),n.select());K(this,We,Ei).call(this,{hasSelectedEditor:this.hasSelection})},Pe(_g,"TRANSLATE_SMALL",1),Pe(_g,"TRANSLATE_BIG",10);let ld=_g;const di=class di{constructor(e){Y(this,Do);Y(this,Sa,null);Y(this,Cl,!1);Y(this,Io,null);Y(this,bg,null);Y(this,Rl,null);Y(this,os,null);Y(this,Eg,!1);Y(this,Nl,null);Y(this,Ii,null);Y(this,Oc,null);Y(this,gf,null);Y(this,wl,!1);M(this,Ii,e),M(this,wl,e._uiManager.useNewAltTextFlow),_(di,Ad)||M(di,Ad,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){di._l10n??(di._l10n=e)}async render(){const e=M(this,Io,document.createElement("button"));e.className="altText",e.tabIndex="0";const n=M(this,bg,document.createElement("span"));e.append(n),_(this,wl)?(e.classList.add("new"),e.setAttribute("data-l10n-id",_(di,Ad).missing),n.setAttribute("data-l10n-id",_(di,Ad)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const r=_(this,Ii)._uiManager._signal;e.addEventListener("contextmenu",as,{signal:r}),e.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:r});const a=i=>{i.preventDefault(),_(this,Ii)._uiManager.editAltText(_(this,Ii)),_(this,wl)&&_(this,Ii)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:_(this,Do,Cy)}})};return e.addEventListener("click",a,{capture:!0,signal:r}),e.addEventListener("keydown",i=>{i.target===e&&i.key==="Enter"&&(M(this,Eg,!0),a(i))},{signal:r}),await K(this,Do,CR).call(this),e}finish(){_(this,Io)&&(_(this,Io).focus({focusVisible:_(this,Eg)}),M(this,Eg,!1))}isEmpty(){return _(this,wl)?_(this,Sa)===null:!_(this,Sa)&&!_(this,Cl)}hasData(){return _(this,wl)?_(this,Sa)!==null||!!_(this,Oc):this.isEmpty()}get guessedText(){return _(this,Oc)}async setGuessedText(e){_(this,Sa)===null&&(M(this,Oc,e),M(this,gf,await di._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),K(this,Do,CR).call(this))}toggleAltTextBadge(e=!1){var n;if(!_(this,wl)||_(this,Sa)){(n=_(this,Nl))==null||n.remove(),M(this,Nl,null);return}if(!_(this,Nl)){const r=M(this,Nl,document.createElement("div"));r.className="noAltTextBadge",_(this,Ii).div.append(r)}_(this,Nl).classList.toggle("hidden",!e)}serialize(e){let n=_(this,Sa);return!e&&_(this,Oc)===n&&(n=_(this,gf)),{altText:n,decorative:_(this,Cl),guessedText:_(this,Oc),textWithDisclaimer:_(this,gf)}}get data(){return{altText:_(this,Sa),decorative:_(this,Cl)}}set data({altText:e,decorative:n,guessedText:r,textWithDisclaimer:a,cancel:i=!1}){r&&(M(this,Oc,r),M(this,gf,a)),!(_(this,Sa)===e&&_(this,Cl)===n)&&(i||(M(this,Sa,e),M(this,Cl,n)),K(this,Do,CR).call(this))}toggle(e=!1){_(this,Io)&&(!e&&_(this,os)&&(clearTimeout(_(this,os)),M(this,os,null)),_(this,Io).disabled=!e)}shown(){_(this,Ii)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:_(this,Do,Cy)}})}destroy(){var e,n;(e=_(this,Io))==null||e.remove(),M(this,Io,null),M(this,bg,null),M(this,Rl,null),(n=_(this,Nl))==null||n.remove(),M(this,Nl,null)}};Sa=new WeakMap,Cl=new WeakMap,Io=new WeakMap,bg=new WeakMap,Rl=new WeakMap,os=new WeakMap,Eg=new WeakMap,Nl=new WeakMap,Ii=new WeakMap,Oc=new WeakMap,gf=new WeakMap,wl=new WeakMap,Ad=new WeakMap,Do=new WeakSet,Cy=function(){return _(this,Sa)&&"added"||_(this,Sa)===null&&this.guessedText&&"review"||"missing"},CR=async function(){var a,i,s;const e=_(this,Io);if(!e)return;if(_(this,wl)){if(e.classList.toggle("done",!!_(this,Sa)),e.setAttribute("data-l10n-id",_(di,Ad)[_(this,Do,Cy)]),(a=_(this,bg))==null||a.setAttribute("data-l10n-id",_(di,Ad)[`${_(this,Do,Cy)}-label`]),!_(this,Sa)){(i=_(this,Rl))==null||i.remove();return}}else{if(!_(this,Sa)&&!_(this,Cl)){e.classList.remove("done"),(s=_(this,Rl))==null||s.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=_(this,Rl);if(!n){M(this,Rl,n=document.createElement("span")),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${_(this,Ii).id}`;const o=100,l=_(this,Ii)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(_(this,os)),M(this,os,null)},{once:!0}),e.addEventListener("mouseenter",()=>{M(this,os,setTimeout(()=>{M(this,os,null),_(this,Rl).classList.add("show"),_(this,Ii)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),e.addEventListener("mouseleave",()=>{var u;_(this,os)&&(clearTimeout(_(this,os)),M(this,os,null)),(u=_(this,Rl))==null||u.classList.remove("show")},{signal:l})}_(this,Cl)?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=_(this,Sa)),n.parentNode||e.append(n);const r=_(this,Ii).getElementForAltText();r==null||r.setAttribute("aria-describedby",n.id)},Y(di,Ad,null),Pe(di,"_l10n",null);let CA=di;class RA{constructor(e){Y(this,gE);Y(this,Ma,null);Y(this,Ws,null);Y(this,_f,!1);Y(this,lr,null);Y(this,hE,null);Y(this,bf,null);Y(this,ko,null);Y(this,Ef,null);Y(this,Sf,!1);Y(this,yf,null);M(this,lr,e)}renderForToolbar(){const e=M(this,Ws,document.createElement("button"));return e.className="comment",K(this,gE,XB).call(this,e,!1)}renderForStandalone(){const e=M(this,Ma,document.createElement("button"));e.className="annotationCommentButton";const n=_(this,lr).commentButtonPosition;if(n){const{style:r}=e;r.insetInlineEnd=`calc(${100*(_(this,lr)._uiManager.direction==="ltr"?1-n[0]:n[0])}% - var(--comment-button-dim))`,r.top=`calc(${100*n[1]}% - var(--comment-button-dim))`;const a=_(this,lr).commentButtonColor;a&&(r.backgroundColor=a)}return K(this,gE,XB).call(this,e,!0)}focusButton(){setTimeout(()=>{var e;(e=_(this,Ma)??_(this,Ws))==null||e.focus()},0)}onUpdatedColor(){if(!_(this,Ma))return;const e=_(this,lr).commentButtonColor;e&&(_(this,Ma).style.backgroundColor=e),_(this,lr)._uiManager.updatePopupColor(_(this,lr))}get commentButtonWidth(){var e;return(((e=_(this,Ma))==null?void 0:e.getBoundingClientRect().width)??0)/_(this,lr).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(_(this,yf))return _(this,yf);if(!_(this,Ma))return null;const{x:e,y:n,height:r}=_(this,Ma).getBoundingClientRect(),{x:a,y:i,width:s,height:o}=_(this,lr).parent.boundingClientRect;return[(e-a)/s,(n+r-i)/o]}set commentPopupPositionInLayer(e){M(this,yf,e)}hasDefaultPopupPosition(){return _(this,yf)===null}removeStandaloneCommentButton(){var e;(e=_(this,Ma))==null||e.remove(),M(this,Ma,null)}removeToolbarCommentButton(){var e;(e=_(this,Ws))==null||e.remove(),M(this,Ws,null)}setCommentButtonStates({selected:e,hasPopup:n}){_(this,Ma)&&(_(this,Ma).classList.toggle("selected",e),_(this,Ma).ariaExpanded=n)}edit(e){const n=this.commentPopupPositionInLayer;let r,a;if(n)[r,a]=n;else{[r,a]=_(this,lr).commentButtonPosition;const{width:p,height:f,x:m,y:g}=_(this,lr);r=m+r*p,a=g+a*f}const i=_(this,lr).parent.boundingClientRect,{x:s,y:o,width:l,height:u}=i;_(this,lr)._uiManager.editComment(_(this,lr),s+r*l,o+a*u,{...e,parentDimensions:i})}finish(){_(this,Ws)&&(_(this,Ws).focus({focusVisible:_(this,_f)}),M(this,_f,!1))}isDeleted(){return _(this,Sf)||_(this,ko)===""}isEmpty(){return _(this,ko)===null}hasBeenEdited(){return this.isDeleted()||_(this,ko)!==_(this,hE)}serialize(){return this.data}get data(){return{text:_(this,ko),richText:_(this,bf),date:_(this,Ef),deleted:this.isDeleted()}}set data(e){if(e!==_(this,ko)&&M(this,bf,null),e===null){M(this,ko,""),M(this,Sf,!0);return}M(this,ko,e),M(this,Ef,new Date),M(this,Sf,!1)}setInitialText(e,n=null){M(this,hE,e),this.data=e,M(this,Ef,null),M(this,bf,n)}shown(){}destroy(){var e,n;(e=_(this,Ws))==null||e.remove(),M(this,Ws,null),(n=_(this,Ma))==null||n.remove(),M(this,Ma,null),M(this,ko,""),M(this,bf,null),M(this,Ef,null),M(this,lr,null),M(this,_f,!1),M(this,Sf,!1)}}Ma=new WeakMap,Ws=new WeakMap,_f=new WeakMap,lr=new WeakMap,hE=new WeakMap,bf=new WeakMap,ko=new WeakMap,Ef=new WeakMap,Sf=new WeakMap,yf=new WeakMap,gE=new WeakSet,XB=function(e,n){if(!_(this,lr)._uiManager.hasCommentManager())return null;e.tabIndex="0",e.ariaHasPopup="dialog",n?(e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(e.ariaControlsElements=[_(this,lr)._uiManager.getCommentDialogElement()],e.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));const r=_(this,lr)._uiManager._signal;if(!(r instanceof AbortSignal)||r.aborted)return e;e.addEventListener("contextmenu",as,{signal:r}),n&&(e.addEventListener("focusin",i=>{_(this,lr)._focusEventsAllowed=!1,Rr(i)},{capture:!0,signal:r}),e.addEventListener("focusout",i=>{_(this,lr)._focusEventsAllowed=!0,Rr(i)},{capture:!0,signal:r})),e.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:r});const a=i=>{i.preventDefault(),e===_(this,Ws)?this.edit():_(this,lr).toggleComment(!0)};return e.addEventListener("click",a,{capture:!0,signal:r}),e.addEventListener("keydown",i=>{i.target===e&&i.key==="Enter"&&(M(this,_f,!0),a(i))},{signal:r}),e.addEventListener("pointerenter",()=>{_(this,lr).toggleComment(!1,!0)},{signal:r}),e.addEventListener("pointerleave",()=>{_(this,lr).toggleComment(!1,!1)},{signal:r}),e};const FF=class FF{constructor({container:e,isPinchingDisabled:n=null,isPinchingStopped:r=null,onPinchStart:a=null,onPinching:i=null,onPinchEnd:s=null,signal:o}){Y(this,Cd);Y(this,Sg);Y(this,vf,!1);Y(this,_E,null);Y(this,bE);Y(this,EE);Y(this,SE);Y(this,yE);Y(this,Ic,null);Y(this,Tf);Y(this,Dc,null);Y(this,Af);Y(this,kc,null);M(this,Sg,e),M(this,_E,r),M(this,bE,n),M(this,EE,a),M(this,SE,i),M(this,yE,s),M(this,Af,new AbortController),M(this,Tf,AbortSignal.any([o,_(this,Af).signal])),e.addEventListener("touchstart",K(this,Cd,Gle).bind(this),{passive:!1,signal:_(this,Tf)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Oo.pixelRatio}destroy(){var e,n;(e=_(this,Af))==null||e.abort(),M(this,Af,null),(n=_(this,Ic))==null||n.abort(),M(this,Ic,null)}};Sg=new WeakMap,vf=new WeakMap,_E=new WeakMap,bE=new WeakMap,EE=new WeakMap,SE=new WeakMap,yE=new WeakMap,Ic=new WeakMap,Tf=new WeakMap,Dc=new WeakMap,Af=new WeakMap,kc=new WeakMap,Cd=new WeakSet,Gle=function(e){var a,i,s;if((a=_(this,bE))!=null&&a.call(this))return;if(e.touches.length===1){if(_(this,Ic))return;const o=M(this,Ic,new AbortController),l=AbortSignal.any([_(this,Tf),o.signal]),u=_(this,Sg),p={capture:!0,signal:l,passive:!1},f=m=>{var g;m.pointerType==="touch"&&((g=_(this,Ic))==null||g.abort(),M(this,Ic,null))};u.addEventListener("pointerdown",m=>{m.pointerType==="touch"&&(Rr(m),f(m))},p),u.addEventListener("pointerup",f,p),u.addEventListener("pointercancel",f,p);return}if(!_(this,kc)){M(this,kc,new AbortController);const o=AbortSignal.any([_(this,Tf),_(this,kc).signal]),l=_(this,Sg),u={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",K(this,Cd,zle).bind(this),u);const p=K(this,Cd,qle).bind(this);l.addEventListener("touchend",p,u),l.addEventListener("touchcancel",p,u),u.capture=!0,l.addEventListener("pointerdown",Rr,u),l.addEventListener("pointermove",Rr,u),l.addEventListener("pointercancel",Rr,u),l.addEventListener("pointerup",Rr,u),(i=_(this,EE))==null||i.call(this)}if(Rr(e),e.touches.length!==2||(s=_(this,_E))!=null&&s.call(this)){M(this,Dc,null);return}let[n,r]=e.touches;n.identifier>r.identifier&&([n,r]=[r,n]),M(this,Dc,{touch0X:n.screenX,touch0Y:n.screenY,touch1X:r.screenX,touch1Y:r.screenY})},zle=function(e){var w;if(!_(this,Dc)||e.touches.length!==2)return;Rr(e);let[n,r]=e.touches;n.identifier>r.identifier&&([n,r]=[r,n]);const{screenX:a,screenY:i}=n,{screenX:s,screenY:o}=r,l=_(this,Dc),{touch0X:u,touch0Y:p,touch1X:f,touch1Y:m}=l,g=f-u,S=m-p,E=s-a,y=o-i,v=Math.hypot(E,y)||1,A=Math.hypot(g,S)||1;if(!_(this,vf)&&Math.abs(A-v)<=FF.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=a,l.touch0Y=i,l.touch1X=s,l.touch1Y=o,!_(this,vf)){M(this,vf,!0);return}const T=[(a+s)/2,(i+o)/2];(w=_(this,SE))==null||w.call(this,T,A,v)},qle=function(e){var n;e.touches.length>=2||(_(this,kc)&&(_(this,kc).abort(),M(this,kc,null),(n=_(this,yE))==null||n.call(this)),_(this,Dc)&&(Rr(e),M(this,Dc,null),M(this,vf,!1)))};let z0=FF;const kt=class kt{constructor(e){Y(this,Tt);Y(this,Cf,null);Y(this,Mo,null);Y(this,_r,null);Y(this,Jn,null);Y(this,Mc,null);Y(this,yg,!1);Y(this,Rd,null);Y(this,vE,"");Y(this,La,null);Y(this,Rf,null);Y(this,Lc,null);Y(this,xl,null);Y(this,Nd,null);Y(this,TE,"");Y(this,Nf,!1);Y(this,ls,null);Y(this,AE,!1);Y(this,wf,!1);Y(this,Pc,!1);Y(this,Ol,null);Y(this,vg,0);Y(this,Tg,0);Y(this,js,null);Y(this,xf,null);Pe(this,"isSelected",!1);Pe(this,"_isCopy",!1);Pe(this,"_editToolbar",null);Pe(this,"_initialOptions",Object.create(null));Pe(this,"_initialData",null);Pe(this,"_isVisible",!0);Pe(this,"_uiManager",null);Pe(this,"_focusEventsAllowed",!0);Y(this,CE,!1);Y(this,eC,kt._zIndex++);this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null;const{rotation:n,rawDims:{pageWidth:r,pageHeight:a,pageX:i,pageY:s}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,a],this.pageTranslation=[i,s];const[o,l]=this.parentDimensions;this.x=e.x/o,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=kt.prototype._resizeWithKeyboard,n=ld.TRANSLATE_SMALL,r=ld.TRANSLATE_BIG;return qt(this,"_resizerKeyboardManager",new G0([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-n,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-r,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[n,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[r,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-n]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-r]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,n]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,r]}],[["Escape","mac+Escape"],kt.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return qt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const n=new EUe({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});n.annotationElementId=e.annotationElementId,n.deleted=!0,n._uiManager.addToAnnotationStorage(n)}static initialize(e,n){if(kt._l10n??(kt._l10n=e),kt._l10nResizer||(kt._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),kt._borderLineWidth!==-1)return;const r=getComputedStyle(document.documentElement);kt._borderLineWidth=parseFloat(r.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,n){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,n){Qn("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return _(this,CE)}set _isDraggable(e){var n;M(this,CE,e),(n=this.div)==null||n.classList.toggle("draggable",e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[e,n]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*n/(e*2),this.y+=this.width*e/(n*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*n/(e*2),this.y-=this.width*e/(n*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=_(this,eC)}setParent(e){var n;e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):(K(this,Tt,Ry).call(this),(n=_(this,xl))==null||n.remove(),M(this,xl,null)),this.parent=e}focusin(e){this._focusEventsAllowed&&(_(this,Nf)?M(this,Nf,!1):this.parent.setSelected(this))}focusout(e){var r;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const n=e.relatedTarget;n!=null&&n.closest(`#${this.id}`)||(e.preventDefault(),(r=this.parent)!=null&&r.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,n,r,a){const[i,s]=this.parentDimensions;[r,a]=this.screenToPageTranslation(r,a),this.x=(e+r)/i,this.y=(n+a)/s,this.fixAndSetPosition()}_moveAfterPaste(e,n){const[r,a]=this.parentDimensions;this.setAt(e*r,n*a,this.width*r,this.height*a),this._onTranslated()}translate(e,n){K(this,Tt,QB).call(this,this.parentDimensions,e,n)}translateInPage(e,n){_(this,ls)||M(this,ls,[this.x,this.y,this.width,this.height]),K(this,Tt,QB).call(this,this.pageDimensions,e,n),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,n){_(this,ls)||M(this,ls,[this.x,this.y,this.width,this.height]);const{div:r,parentDimensions:[a,i]}=this;if(this.x+=e/a,this.y+=n/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:f,y:m}=this.div.getBoundingClientRect();this.parent.findNewParent(this,f,m)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:s,y:o}=this;const[l,u]=this.getBaseTranslation();s+=l,o+=u;const{style:p}=r;p.left=`${(100*s).toFixed(2)}%`,p.top=`${(100*o).toFixed(2)}%`,this._onTranslating(s,o),r.scrollIntoView({block:"nearest"})}_onTranslating(e,n){}_onTranslated(e,n){}get _hasBeenMoved(){return!!_(this,ls)&&(_(this,ls)[0]!==this.x||_(this,ls)[1]!==this.y)}get _hasBeenResized(){return!!_(this,ls)&&(_(this,ls)[2]!==this.width||_(this,ls)[3]!==this.height)}getBaseTranslation(){const[e,n]=this.parentDimensions,{_borderLineWidth:r}=kt,a=r/e,i=r/n;switch(this.rotation){case 90:return[-a,i];case 180:return[a,i];case 270:return[a,-i];default:return[-a,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:n},pageDimensions:[r,a]}=this;let{x:i,y:s,width:o,height:l}=this;if(o*=r,l*=a,i*=r,s*=a,this._mustFixPosition)switch(e){case 0:i=Ka(i,0,r-o),s=Ka(s,0,a-l);break;case 90:i=Ka(i,0,r-l),s=Ka(s,o,a);break;case 180:i=Ka(i,o,r),s=Ka(s,l,a);break;case 270:i=Ka(i,l,r),s=Ka(s,0,a-o);break}this.x=i/=r,this.y=s/=a;const[u,p]=this.getBaseTranslation();i+=u,s+=p,n.left=`${(100*i).toFixed(2)}%`,n.top=`${(100*s).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,n){var r;return K(r=kt,RE,ZB).call(r,e,n,this.parentRotation)}pageTranslationToScreen(e,n){var r;return K(r=kt,RE,ZB).call(r,e,n,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[n,r]}=this;return[n*e,r*e]}setDims(){const{div:{style:e},width:n,height:r}=this;e.width=`${(100*n).toFixed(2)}%`,e.height=`${(100*r).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(e*1e4)/1e4}_onResizing(){}altTextFinish(){var e;(e=_(this,_r))==null||e.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||_(this,wf))return this._editToolbar;this._editToolbar=new eF(this),this.div.append(this._editToolbar.render());const{toolbarButtons:e}=this;if(e)for(const[n,r]of e)await this._editToolbar.addButton(n,r);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var e;(e=this._editToolbar)==null||e.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var e;(e=this._editToolbar)==null||e.removeButton("comment")}removeEditToolbar(){var e,n;(e=this._editToolbar)==null||e.remove(),this._editToolbar=null,(n=_(this,_r))==null||n.destroy()}addContainer(e){var r;const n=(r=this._editToolbar)==null?void 0:r.div;n?n.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return _(this,_r)||(CA.initialize(kt._l10n),M(this,_r,new CA(this)),_(this,Cf)&&(_(this,_r).data=_(this,Cf),M(this,Cf,null))),_(this,_r)}get altTextData(){var e;return(e=_(this,_r))==null?void 0:e.data}set altTextData(e){_(this,_r)&&(_(this,_r).data=e)}get guessedAltText(){var e;return(e=_(this,_r))==null?void 0:e.guessedText}async setGuessedAltText(e){var n;await((n=_(this,_r))==null?void 0:n.setGuessedText(e))}serializeAltText(e){var n;return(n=_(this,_r))==null?void 0:n.serialize(e)}hasAltText(){return!!_(this,_r)&&!_(this,_r).isEmpty()}hasAltTextData(){var e;return((e=_(this,_r))==null?void 0:e.hasData())??!1}focusCommentButton(){var e;(e=_(this,Jn))==null||e.focusButton()}addCommentButton(){return _(this,Jn)||M(this,Jn,new RA(this))}addStandaloneCommentButton(){if(_(this,Mc)){this._uiManager.isEditingMode()&&_(this,Mc).classList.remove("hidden");return}this.hasComment&&(M(this,Mc,_(this,Jn).renderForStandalone()),this.div.append(_(this,Mc)))}removeStandaloneCommentButton(){_(this,Jn).removeStandaloneCommentButton(),M(this,Mc,null)}hideStandaloneCommentButton(){var e;(e=_(this,Mc))==null||e.classList.add("hidden")}get comment(){const{data:{richText:e,text:n,date:r,deleted:a}}=_(this,Jn);return{text:n,richText:e,date:r,deleted:a,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){_(this,Jn)||M(this,Jn,new RA(this)),_(this,Jn).data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:n,richText:r}){if(!n||(_(this,Jn)||M(this,Jn,new RA(this)),_(this,Jn).setInitialText(e,r),!this.annotationElementId))return;const a=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);a&&this.updateFromAnnotationLayer(a)}get hasEditedComment(){var e;return(e=_(this,Jn))==null?void 0:e.hasBeenEdited()}get hasDeletedComment(){var e;return(e=_(this,Jn))==null?void 0:e.isDeleted()}get hasComment(){return!!_(this,Jn)&&!_(this,Jn).isEmpty()&&!_(this,Jn).isDeleted()}async editComment(e){_(this,Jn)||M(this,Jn,new RA(this)),_(this,Jn).edit(e)}toggleComment(e,n=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,n)}setSelectedCommentButton(e){_(this,Jn).setSelectedButton(e)}addComment(e){if(this.hasEditedComment){const[,,,a]=e.rect,[i]=this.pageDimensions,[s]=this.pageTranslation,o=s+i+1,l=a-100,u=o+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,u,a]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:n}}){_(this,Jn).data=n?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var s;const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=_(this,yg)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),K(this,Tt,n6).call(this);const[n,r]=this.parentDimensions;this.parentRotation%180!==0&&(e.style.maxWidth=`${(100*r/n).toFixed(2)}%`,e.style.maxHeight=`${(100*n/r).toFixed(2)}%`);const[a,i]=this.getInitialTranslation();return this.translate(a,i),Mre(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(_(this,xf)||M(this,xf,new z0({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:K(this,Tt,Yle).bind(this),onPinching:K(this,Tt,Vle).bind(this),onPinchEnd:K(this,Tt,Wle).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(s=this._uiManager._editorUndoBar)==null||s.hide(),e}pointerdown(e){const{isMac:n}=Ea.platform;if(e.button!==0||e.ctrlKey&&n){e.preventDefault();return}if(M(this,Nf,!0),this._isDraggable){K(this,Tt,jle).call(this,e);return}K(this,Tt,t6).call(this,e)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){_(this,Ol)&&clearTimeout(_(this,Ol)),M(this,Ol,setTimeout(()=>{var e;M(this,Ol,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,n,r){e.changeParent(this),this.x=n,this.y=r,this.fixAndSetPosition(),this._onTranslated()}getRect(e,n,r=this.rotation){const a=this.parentScale,[i,s]=this.pageDimensions,[o,l]=this.pageTranslation,u=e/a,p=n/a,f=this.x*i,m=this.y*s,g=this.width*i,S=this.height*s;switch(r){case 0:return[f+u+o,s-m-p-S+l,f+u+g+o,s-m-p+l];case 90:return[f+p+o,s-m+u+l,f+p+S+o,s-m+u+g+l];case 180:return[f-u-g+o,s-m+p+l,f-u+o,s-m+p+S+l];case 270:return[f-p-S+o,s-m-u-g+l,f-p+o,s-m-u+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,n){const[r,a,i,s]=e,o=i-r,l=s-a;switch(this.rotation){case 0:return[r,n-s,o,l];case 90:return[r,n-a,l,o];case 180:return[i,n-a,o,l];case 270:return[i,n-s,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&kt._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var e;(e=_(this,Jn))==null||e.onUpdatedColor()}getData(){const{comment:{text:e,color:n,date:r,opacity:a,deleted:i,richText:s},uid:o,pageIndex:l,creationDate:u,modificationDate:p}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:s,contentsObj:{str:e},creationDate:u,modificationDate:r||p,popupRef:!i,color:n,opacity:a}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),M(this,wf,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),M(this,wf,!1),!0):!1}isInEditMode(){return _(this,wf)}shouldGetKeyboardEvents(){return _(this,Pc)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:n,bottom:r,right:a}=this.getClientDimensions(),{innerHeight:i,innerWidth:s}=window;return n<s&&a>0&&e<i&&r>0}rebuild(){K(this,Tt,n6).call(this)}rotate(e){}resize(){}serializeDeleted(){var e;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((e=this._initialData)==null?void 0:e.popupRef)||""}}serialize(e=!1,n=null){var r;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((r=this._initialData)==null?void 0:r.popupRef)||""}}static async deserialize(e,n,r){const a=new this.prototype.constructor({parent:n,id:n.getNextId(),uiManager:r,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});a.rotation=e.rotation,M(a,Cf,e.accessibilityData),a._isCopy=e.isCopy||!1;const[i,s]=a.pageDimensions,[o,l,u,p]=a.getRectInCurrentCoords(e.rect,s);return a.x=o/i,a.y=l/s,a.width=u/i,a.height=p/s,a}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var e,n;if((e=_(this,Nd))==null||e.abort(),M(this,Nd,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),_(this,Ol)&&(clearTimeout(_(this,Ol)),M(this,Ol,null)),K(this,Tt,Ry).call(this),this.removeEditToolbar(),_(this,js)){for(const r of _(this,js).values())clearTimeout(r);M(this,js,null)}this.parent=null,(n=_(this,xf))==null||n.destroy(),M(this,xf,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(K(this,Tt,Hle).call(this),_(this,La).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[e,n]}=this,[r,a,i,s]=this.getPDFRect();return[kt._round(r+(i-r)*e),kt._round(a+(s-a)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return _(this,Jn).commentPopupPositionInLayer}set commentPopupPosition(e){_(this,Jn).commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return _(this,Jn).hasDefaultPopupPosition()}get commentButtonWidth(){return _(this,Jn).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){_(this,Jn).setCommentButtonStates(e)}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),M(this,Lc,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const n=_(this,La).children;if(!_(this,Mo)){M(this,Mo,Array.from(n));const s=K(this,Tt,Kle).bind(this),o=K(this,Tt,Xle).bind(this),l=this._uiManager._signal;for(const u of _(this,Mo)){const p=u.getAttribute("data-resizer-name");u.setAttribute("role","spinbutton"),u.addEventListener("keydown",s,{signal:l}),u.addEventListener("blur",o,{signal:l}),u.addEventListener("focus",K(this,Tt,Qle).bind(this,p),{signal:l}),u.setAttribute("data-l10n-id",kt._l10nResizer[p])}}const r=_(this,Mo)[0];let a=0;for(const s of n){if(s===r)break;a++}const i=(360-this.rotation+this.parentRotation)%360/90*(_(this,Mo).length/4);if(i!==a){if(i<a)for(let o=0;o<a-i;o++)_(this,La).append(_(this,La).firstChild);else if(i>a)for(let o=0;o<i-a;o++)_(this,La).firstChild.before(_(this,La).lastChild);let s=0;for(const o of n){const u=_(this,Mo)[s++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",kt._l10nResizer[u])}}K(this,Tt,r6).call(this,0),M(this,Pc,!0),_(this,La).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(e,n){_(this,Pc)&&K(this,Tt,e6).call(this,_(this,TE),{deltaX:e,deltaY:n,fromKeyboard:!0})}_stopResizingWithKeyboard(){K(this,Tt,Ry).call(this),this.div.focus()}select(){var e,n,r;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(e=this.div)==null||e.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var a,i;(a=this.div)!=null&&a.classList.contains("selectedEditor")&&((i=this._editToolbar)==null||i.show())});return}(n=this._editToolbar)==null||n.show(),(r=_(this,_r))==null||r.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var e;return(e=this.div)==null?void 0:e.focus({preventScroll:!0})},0)}unselect(){var e,n,r,a,i;this.isSelected&&(this.isSelected=!1,(e=_(this,La))==null||e.classList.add("hidden"),(n=this.div)==null||n.classList.remove("selectedEditor"),(r=this.div)!=null&&r.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(a=this._editToolbar)==null||a.hide(),(i=_(this,_r))==null||i.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(e,n){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return _(this,AE)}set isEditing(e){M(this,AE,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,n=!1){if(n){_(this,js)||M(this,js,new Map);const{action:r}=e;let a=_(this,js).get(r);a&&clearTimeout(a),a=setTimeout(()=>{this._reportTelemetry(e),_(this,js).delete(r),_(this,js).size===0&&M(this,js,null)},kt._telemetryTimeout),_(this,js).set(r,a);return}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),M(this,yg,!1)}disable(){this.div&&(this.div.tabIndex=-1),M(this,yg,!0)}updateFakeAnnotationElement(e){if(!_(this,xl)&&!this.deleted){M(this,xl,e.addFakeAnnotation(this));return}if(this.deleted){_(this,xl).remove(),M(this,xl,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&_(this,xl).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let n=e.container.querySelector(".annotationContent");if(!n)n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),e.container.prepend(n);else if(n.nodeName==="CANVAS"){const r=n;n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),r.before(n)}return n}resetAnnotationElement(e){const{firstChild:n}=e.container;(n==null?void 0:n.nodeName)==="DIV"&&n.classList.contains("annotationContent")&&n.remove()}};Cf=new WeakMap,Mo=new WeakMap,_r=new WeakMap,Jn=new WeakMap,Mc=new WeakMap,yg=new WeakMap,Rd=new WeakMap,vE=new WeakMap,La=new WeakMap,Rf=new WeakMap,Lc=new WeakMap,xl=new WeakMap,Nd=new WeakMap,TE=new WeakMap,Nf=new WeakMap,ls=new WeakMap,AE=new WeakMap,wf=new WeakMap,Pc=new WeakMap,Ol=new WeakMap,vg=new WeakMap,Tg=new WeakMap,js=new WeakMap,xf=new WeakMap,CE=new WeakMap,eC=new WeakMap,Tt=new WeakSet,QB=function([e,n],r,a){[r,a]=this.screenToPageTranslation(r,a),this.x+=r/e,this.y+=a/n,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},RE=new WeakSet,ZB=function(e,n,r){switch(r){case 90:return[n,-e];case 180:return[-e,-n];case 270:return[-n,e];default:return[e,n]}},RR=function(e){switch(e){case 90:{const[n,r]=this.pageDimensions;return[0,-n/r,r/n,0]}case 180:return[-1,0,0,-1];case 270:{const[n,r]=this.pageDimensions;return[0,n/r,-r/n,0]}default:return[1,0,0,1]}},Hle=function(){if(_(this,La))return;M(this,La,document.createElement("div")),_(this,La).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],n=this._uiManager._signal;for(const r of e){const a=document.createElement("div");_(this,La).append(a),a.classList.add("resizer",r),a.setAttribute("data-resizer-name",r),a.addEventListener("pointerdown",K(this,Tt,$le).bind(this,r),{signal:n}),a.addEventListener("contextmenu",as,{signal:n}),a.tabIndex=-1}this.div.prepend(_(this,La))},$le=function(e,n){var p;n.preventDefault();const{isMac:r}=Ea.platform;if(n.button!==0||n.ctrlKey&&r)return;(p=_(this,_r))==null||p.toggle(!1);const a=this._isDraggable;this._isDraggable=!1,M(this,Rf,[n.screenX,n.screenY]);const i=new AbortController,s=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",K(this,Tt,e6).bind(this,e),{passive:!0,capture:!0,signal:s}),window.addEventListener("touchmove",Rr,{passive:!1,signal:s}),window.addEventListener("contextmenu",as,{signal:s}),M(this,Lc,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(n.target).cursor;const u=()=>{var f;i.abort(),this.parent.togglePointerEvents(!0),(f=_(this,_r))==null||f.toggle(!0),this._isDraggable=a,this.parent.div.style.cursor=o,this.div.style.cursor=l,K(this,Tt,NR).call(this)};window.addEventListener("pointerup",u,{signal:s}),window.addEventListener("blur",u,{signal:s})},JB=function(e,n,r,a){this.width=r,this.height=a,this.x=e,this.y=n,this.setDims(),this.fixAndSetPosition(),this._onResized()},NR=function(){if(!_(this,Lc))return;const{savedX:e,savedY:n,savedWidth:r,savedHeight:a}=_(this,Lc);M(this,Lc,null);const i=this.x,s=this.y,o=this.width,l=this.height;i===e&&s===n&&o===r&&l===a||this.addCommands({cmd:K(this,Tt,JB).bind(this,i,s,o,l),undo:K(this,Tt,JB).bind(this,e,n,r,a),mustExec:!0})},e6=function(e,n){const[r,a]=this.parentDimensions,i=this.x,s=this.y,o=this.width,l=this.height,u=kt.MIN_SIZE/r,p=kt.MIN_SIZE/a,f=K(this,Tt,RR).call(this,this.rotation),m=(z,V)=>[f[0]*z+f[2]*V,f[1]*z+f[3]*V],g=K(this,Tt,RR).call(this,360-this.rotation),S=(z,V)=>[g[0]*z+g[2]*V,g[1]*z+g[3]*V];let E,y,v=!1,A=!1;switch(e){case"topLeft":v=!0,E=(z,V)=>[0,0],y=(z,V)=>[z,V];break;case"topMiddle":E=(z,V)=>[z/2,0],y=(z,V)=>[z/2,V];break;case"topRight":v=!0,E=(z,V)=>[z,0],y=(z,V)=>[0,V];break;case"middleRight":A=!0,E=(z,V)=>[z,V/2],y=(z,V)=>[0,V/2];break;case"bottomRight":v=!0,E=(z,V)=>[z,V],y=(z,V)=>[0,0];break;case"bottomMiddle":E=(z,V)=>[z/2,V],y=(z,V)=>[z/2,0];break;case"bottomLeft":v=!0,E=(z,V)=>[0,V],y=(z,V)=>[z,0];break;case"middleLeft":A=!0,E=(z,V)=>[0,V/2],y=(z,V)=>[z,V/2];break}const T=E(o,l),w=y(o,l);let O=m(...w);const R=kt._round(i+O[0]),I=kt._round(s+O[1]);let L=1,P=1,U,H;if(n.fromKeyboard)({deltaX:U,deltaY:H}=n);else{const{screenX:z,screenY:V}=n,[X,te]=_(this,Rf);[U,H]=this.screenToPageTranslation(z-X,V-te),_(this,Rf)[0]=z,_(this,Rf)[1]=V}if([U,H]=S(U/r,H/a),v){const z=Math.hypot(o,l);L=P=Math.max(Math.min(Math.hypot(w[0]-T[0]-U,w[1]-T[1]-H)/z,1/o,1/l),u/o,p/l)}else A?L=Ka(Math.abs(w[0]-T[0]-U),u,1)/o:P=Ka(Math.abs(w[1]-T[1]-H),p,1)/l;const W=kt._round(o*L),Z=kt._round(l*P);O=m(...y(W,Z));const F=R-O[0],j=I-O[1];_(this,ls)||M(this,ls,[this.x,this.y,this.width,this.height]),this.width=W,this.height=Z,this.x=F,this.y=j,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Yle=function(){var e;M(this,Lc,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(e=_(this,_r))==null||e.toggle(!1),this.parent.togglePointerEvents(!1)},Vle=function(e,n,r){let i=.7*(r/n)+1-.7;if(i===1)return;const s=K(this,Tt,RR).call(this,this.rotation),o=(R,I)=>[s[0]*R+s[2]*I,s[1]*R+s[3]*I],[l,u]=this.parentDimensions,p=this.x,f=this.y,m=this.width,g=this.height,S=kt.MIN_SIZE/l,E=kt.MIN_SIZE/u;i=Math.max(Math.min(i,1/m,1/g),S/m,E/g);const y=kt._round(m*i),v=kt._round(g*i);if(y===m&&v===g)return;_(this,ls)||M(this,ls,[p,f,m,g]);const A=o(m/2,g/2),T=kt._round(p+A[0]),w=kt._round(f+A[1]),O=o(y/2,v/2);this.x=T-O[0],this.y=w-O[1],this.width=y,this.height=v,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Wle=function(){var e;(e=_(this,_r))==null||e.toggle(!0),this.parent.togglePointerEvents(!0),K(this,Tt,NR).call(this)},t6=function(e){const{isMac:n}=Ea.platform;e.ctrlKey&&!n||e.shiftKey||e.metaKey&&n?this.parent.toggleSelected(this):this.parent.setSelected(this)},jle=function(e){const{isSelected:n}=this;this._uiManager.setUpDragSession();let r=!1;const a=new AbortController,i=this._uiManager.combinedSignal(a),s={capture:!0,passive:!1,signal:i},o=u=>{a.abort(),M(this,Rd,null),M(this,Nf,!1),this._uiManager.endDragSession()||K(this,Tt,t6).call(this,u),r&&this._onStopDragging()};n&&(M(this,vg,e.clientX),M(this,Tg,e.clientY),M(this,Rd,e.pointerId),M(this,vE,e.pointerType),window.addEventListener("pointermove",u=>{r||(r=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:p,clientY:f,pointerId:m}=u;if(m!==_(this,Rd)){Rr(u);return}const[g,S]=this.screenToPageTranslation(p-_(this,vg),f-_(this,Tg));M(this,vg,p),M(this,Tg,f),this._uiManager.dragSelectedEditors(g,S)},s),window.addEventListener("touchmove",Rr,s),window.addEventListener("pointerdown",u=>{u.pointerType===_(this,vE)&&(_(this,xf)||u.isPrimary)&&o(u),Rr(u)},s));const l=u=>{if(!_(this,Rd)||_(this,Rd)===u.pointerId){o(u);return}Rr(u)};window.addEventListener("pointerup",l,{signal:i}),window.addEventListener("blur",l,{signal:i})},n6=function(){if(_(this,Nd)||!this.div)return;M(this,Nd,new AbortController);const e=this._uiManager.combinedSignal(_(this,Nd));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})},Kle=function(e){kt._resizerKeyboardManager.exec(this,e)},Xle=function(e){var n;_(this,Pc)&&((n=e.relatedTarget)==null?void 0:n.parentNode)!==_(this,La)&&K(this,Tt,Ry).call(this)},Qle=function(e){M(this,TE,_(this,Pc)?e:"")},r6=function(e){if(_(this,Mo))for(const n of _(this,Mo))n.tabIndex=e},Ry=function(){M(this,Pc,!1),K(this,Tt,r6).call(this,-1),K(this,Tt,NR).call(this)},Y(kt,RE),Pe(kt,"_l10n",null),Pe(kt,"_l10nResizer",null),Pe(kt,"_borderLineWidth",-1),Pe(kt,"_colorManager",new nF),Pe(kt,"_zIndex",1),Pe(kt,"_telemetryTimeout",1e3);let or=kt;class EUe extends or{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Lre=3285377520,Bs=4294901760,El=65535;class Pre{constructor(e){this.h1=e?e&4294967295:Lre,this.h2=e?e&4294967295:Lre}update(e){let n,r;if(typeof e=="string"){n=new Uint8Array(e.length*2),r=0;for(let E=0,y=e.length;E<y;E++){const v=e.charCodeAt(E);v<=255?n[r++]=v:(n[r++]=v>>>8,n[r++]=v&255)}}else if(ArrayBuffer.isView(e))n=e.slice(),r=n.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const a=r>>2,i=r-a*4,s=new Uint32Array(n.buffer,0,a);let o=0,l=0,u=this.h1,p=this.h2;const f=3432918353,m=461845907,g=f&El,S=m&El;for(let E=0;E<a;E++)E&1?(o=s[E],o=o*f&Bs|o*g&El,o=o<<15|o>>>17,o=o*m&Bs|o*S&El,u^=o,u=u<<13|u>>>19,u=u*5+3864292196):(l=s[E],l=l*f&Bs|l*g&El,l=l<<15|l>>>17,l=l*m&Bs|l*S&El,p^=l,p=p<<13|p>>>19,p=p*5+3864292196);switch(o=0,i){case 3:o^=n[a*4+2]<<16;case 2:o^=n[a*4+1]<<8;case 1:o^=n[a*4],o=o*f&Bs|o*g&El,o=o<<15|o>>>17,o=o*m&Bs|o*S&El,a&1?u^=o:p^=o}this.h1=u,this.h2=p}hexdigest(){let e=this.h1,n=this.h2;return e^=n>>>1,e=e*3981806797&Bs|e*36045&El,n=n*4283543511&Bs|((n<<16|e>>>16)*2950163797&Bs)>>>16,e^=n>>>1,e=e*444984403&Bs|e*60499&El,n=n*3301882366&Bs|((n<<16|e>>>16)*3120437893&Bs)>>>16,e^=n>>>1,(e>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")}}const rF=Object.freeze({map:null,hash:"",transfer:void 0});class aF{constructor(){Y(this,tC);Y(this,Of,!1);Y(this,If,null);Y(this,Fc,null);Y(this,Pa,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,n){const r=_(this,Pa).get(e);return r===void 0?n:Object.assign(n,r)}getRawValue(e){return _(this,Pa).get(e)}remove(e){const n=_(this,Pa).get(e);if(n!==void 0&&(n instanceof or&&_(this,Fc).delete(n.annotationElementId),_(this,Pa).delete(e),_(this,Pa).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(const r of _(this,Pa).values())if(r instanceof or)return;this.onAnnotationEditor(null)}}setValue(e,n){const r=_(this,Pa).get(e);let a=!1;if(r!==void 0)for(const[i,s]of Object.entries(n))r[i]!==s&&(a=!0,r[i]=s);else a=!0,_(this,Pa).set(e,n);a&&K(this,tC,Zle).call(this),n instanceof or&&((_(this,Fc)||M(this,Fc,new Map)).set(n.annotationElementId,n),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(n.constructor._type))}has(e){return _(this,Pa).has(e)}get size(){return _(this,Pa).size}resetModified(){_(this,Of)&&(M(this,Of,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Fre(this)}get serializable(){if(_(this,Pa).size===0)return rF;const e=new Map,n=new Pre,r=[],a=Object.create(null);let i=!1;for(const[s,o]of _(this,Pa)){const l=o instanceof or?o.serialize(!1,a):o;l&&(e.set(s,l),n.update(`${s}:${JSON.stringify(l)}`),i||(i=!!l.bitmap))}if(i)for(const s of e.values())s.bitmap&&r.push(s.bitmap);return e.size>0?{map:e,hash:n.hexdigest(),transfer:r}:rF}get editorStats(){let e=null;const n=new Map;let r=0,a=0;for(const i of _(this,Pa).values()){if(!(i instanceof or)){i.popup&&(i.popup.deleted?a+=1:r+=1);continue}i.isCommentDeleted?a+=1:i.hasEditedComment&&(r+=1);const s=i.telemetryFinalData;if(!s)continue;const{type:o}=s;n.has(o)||n.set(o,Object.getPrototypeOf(i).constructor),e||(e=Object.create(null));const l=e[o]||(e[o]=new Map);for(const[u,p]of Object.entries(s)){if(u==="type")continue;let f=l.get(u);f||(f=new Map,l.set(u,f));const m=f.get(p)??0;f.set(p,m+1)}}if((a>0||r>0)&&(e||(e=Object.create(null)),e.comments={deleted:a,edited:r}),!e)return null;for(const[i,s]of n)e[i]=s.computeTelemetryFinalData(e[i]);return e}resetModifiedIds(){M(this,If,null)}updateEditor(e,n){var a;const r=(a=_(this,Fc))==null?void 0:a.get(e);return r?(r.updateFromAnnotationLayer(n),!0):!1}getEditor(e){var n;return((n=_(this,Fc))==null?void 0:n.get(e))||null}get modifiedIds(){if(_(this,If))return _(this,If);const e=[];if(_(this,Fc))for(const n of _(this,Fc).values())n.serialize()&&e.push(n.annotationElementId);return M(this,If,{ids:new Set(e),hash:e.join(",")})}[Symbol.iterator](){return _(this,Pa).entries()}}Of=new WeakMap,If=new WeakMap,Fc=new WeakMap,Pa=new WeakMap,tC=new WeakSet,Zle=function(){_(this,Of)||(M(this,Of,!0),typeof this.onSetModified=="function"&&this.onSetModified())};class Fre extends aF{constructor(n){super();Y(this,NE);const{map:r,hash:a,transfer:i}=n.serializable,s=structuredClone(r,i?{transfer:i}:null);M(this,NE,{map:s,hash:a,transfer:i})}get print(){Qn("Should not call PrintAnnotationStorage.print")}get serializable(){return _(this,NE)}get modifiedIds(){return qt(this,"modifiedIds",{ids:new Set,hash:""})}}NE=new WeakMap;class SUe{constructor({ownerDocument:e=globalThis.document,styleElement:n=null}){Y(this,Ag,new Set);this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const n=this.styleElement.sheet;n.insertRule(e,n.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),_(this,Ag).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,disableFontFace:n,_inspectFont:r}){if(!(!e||_(this,Ag).has(e.loadedName))){if(on(!n,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:a,src:i,style:s}=e,o=new FontFace(a,i,s);this.addNativeFontFace(o);try{await o.load(),_(this,Ag).add(a),r==null||r(e)}catch{It(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}Qn("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const r=e.createNativeFontFace();if(r){this.addNativeFontFace(r);try{await r.loaded}catch(a){throw It(`Failed to load font '${r.family}': '${a}'.`),e.disableFontFace=!0,a}}return}const n=e.createFontFaceRule();if(n){if(this.insertRule(n),this.isSyncFontLoadingSupported)return;await new Promise(r=>{const a=this._queueLoadingCallback(r);this._prepareFontLoadEvent(e,a)})}}get isFontLoadingAPISupported(){var n;const e=!!((n=this._document)!=null&&n.fonts);return qt(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){return qt(this,"isSyncFontLoadingSupported",ui||Ea.platform.isFirefox)}_queueLoadingCallback(e){function n(){for(on(!a.done,"completeRequest() cannot be called twice."),a.done=!0;r.length>0&&r[0].done;){const i=r.shift();setTimeout(i.callback,0)}}const{loadingRequests:r}=this,a={done:!1,complete:n,callback:e};return r.push(a),a}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return qt(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,n){function r(w,O){return w.charCodeAt(O)<<24|w.charCodeAt(O+1)<<16|w.charCodeAt(O+2)<<8|w.charCodeAt(O+3)&255}function a(w,O,R,I){const L=w.substring(0,O),P=w.substring(O+R);return L+I+P}let i,s;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let u=0;function p(w,O){if(++u>30){It("Load test font never loaded."),O();return}if(l.font="30px "+w,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){O();return}setTimeout(p.bind(null,w,O))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let m=this._loadTestFont;m=a(m,976,f.length,f);const S=16,E=1482184792;let y=r(m,S);for(i=0,s=f.length-3;i<s;i+=4)y=y-E+r(f,i)|0;i<f.length&&(y=y-E+r(f+"XXX",i)|0),m=a(m,S,4,oUe(y));const v=`url(data:font/opentype;base64,${btoa(m)});`,A=`@font-face {font-family:"${f}";src:${v}}`;this.insertRule(A);const T=this._document.createElement("div");T.style.visibility="hidden",T.style.width=T.style.height="10px",T.style.position="absolute",T.style.top=T.style.left="0px";for(const w of[e.loadedName,f]){const O=this._document.createElement("span");O.textContent="Hi",O.style.fontFamily=w,T.append(O)}this._document.body.append(T),p(f,()=>{T.remove(),n.complete()})}}Ag=new WeakMap;class yUe{constructor(e,n=null,r,a){Y(this,Un);this.compiledGlyphs=Object.create(null),M(this,Un,e),this._inspectFont=n,r&&Object.assign(this,r),a&&(this.charProcOperatorList=a)}createNativeFontFace(){var n;if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{const r={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(r.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,r)}return(n=this._inspectFont)==null||n.call(this,this),e}createFontFaceRule(){var r;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${vre(this.data)});`;let n;if(!this.cssFontInfo)n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let a=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(a+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${a}src:${e}}`}return(r=this._inspectFont)==null||r.call(this,this,e),n}getPathGenerator(e,n){if(this.compiledGlyphs[n]!==void 0)return this.compiledGlyphs[n];const r=this.loadedName+"_path_"+n;let a;try{a=e.get(r)}catch(s){It(`getPathGenerator - ignoring character: "${s}".`)}const i=new Path2D(a||"");return this.fontExtraProperties||e.delete(r),this.compiledGlyphs[n]=i}get black(){return _(this,Un).black}get bold(){return _(this,Un).bold}get disableFontFace(){return _(this,Un).disableFontFace??!1}get fontExtraProperties(){return _(this,Un).fontExtraProperties??!1}get isInvalidPDFjsFont(){return _(this,Un).isInvalidPDFjsFont}get isType3Font(){return _(this,Un).isType3Font}get italic(){return _(this,Un).italic}get missingFile(){return _(this,Un).missingFile}get remeasure(){return _(this,Un).remeasure}get vertical(){return _(this,Un).vertical}get ascent(){return _(this,Un).ascent}get defaultWidth(){return _(this,Un).defaultWidth}get descent(){return _(this,Un).descent}get bbox(){return _(this,Un).bbox}get fontMatrix(){return _(this,Un).fontMatrix}get fallbackName(){return _(this,Un).fallbackName}get loadedName(){return _(this,Un).loadedName}get mimetype(){return _(this,Un).mimetype}get name(){return _(this,Un).name}get data(){return _(this,Un).data}clearData(){_(this,Un).clearData()}get cssFontInfo(){return _(this,Un).cssFontInfo}get systemFontInfo(){return _(this,Un).systemFontInfo}get defaultVMetrics(){return _(this,Un).defaultVMetrics}}Un=new WeakMap;function vUe(t){if(t instanceof URL)return t.href;if(typeof t=="string"){if(ui)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function TUe(t){if(ui&&typeof Buffer<"u"&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if(typeof t=="string")return M0(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t=="object"&&!isNaN(t==null?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function NA(t){if(typeof t!="string")return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const iF=t=>typeof t=="object"&&Number.isInteger(t==null?void 0:t.num)&&t.num>=0&&Number.isInteger(t==null?void 0:t.gen)&&t.gen>=0,AUe=t=>typeof t=="object"&&typeof(t==null?void 0:t.name)=="string",Bre=dUe.bind(null,iF,AUe);class CUe{constructor(){Y(this,Bc,new Map);Y(this,nC,Promise.resolve())}postMessage(e,n){const r={data:structuredClone(e,n?{transfer:n}:null)};_(this,nC).then(()=>{for(const[a]of _(this,Bc))a.call(this,r)})}addEventListener(e,n,r=null){let a=null;if((r==null?void 0:r.signal)instanceof AbortSignal){const{signal:i}=r;if(i.aborted){It("LoopbackPort - cannot use an `aborted` signal.");return}const s=()=>this.removeEventListener(e,n);a=()=>i.removeEventListener("abort",s),i.addEventListener("abort",s)}_(this,Bc).set(n,a)}removeEventListener(e,n){const r=_(this,Bc).get(n);r==null||r(),_(this,Bc).delete(n)}terminate(){for(const[,e]of _(this,Bc))e==null||e();_(this,Bc).clear()}}Bc=new WeakMap,nC=new WeakMap;const wA={DATA:1,ERROR:2},Jr={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Ure(){}function xi(t){if(t instanceof yc||t instanceof yA||t instanceof bre||t instanceof k0||t instanceof V3)return t;switch(t instanceof Error||typeof t=="object"&&t!==null||Qn('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new yc(t.message);case"InvalidPDFException":return new yA(t.message);case"PasswordException":return new bre(t.message,t.code);case"ResponseException":return new k0(t.message,t.status,t.missing);case"UnknownErrorException":return new V3(t.message,t.details)}return new V3(t.message,t.toString())}class q0{constructor(e,n,r){Y(this,Ks);Y(this,Cg,new AbortController);this.sourceName=e,this.targetName=n,this.comObj=r,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),r.addEventListener("message",K(this,Ks,Jle).bind(this),{signal:_(this,Cg).signal})}on(e,n){const r=this.actionHandler;if(r[e])throw new Error(`There is already an actionName called "${e}"`);r[e]=n}send(e,n,r){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:n},r)}sendWithPromise(e,n,r){const a=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[a]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:a,data:n},r)}catch(s){i.reject(s)}return i.promise}sendWithStream(e,n,r,a){const i=this.streamId++,s=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:u=>{const p=Promise.withResolvers();return this.streamControllers[i]={controller:u,startCall:p,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:s,targetName:o,action:e,streamId:i,data:n,desiredSize:u.desiredSize},a),p.promise},pull:u=>{const p=Promise.withResolvers();return this.streamControllers[i].pullCall=p,l.postMessage({sourceName:s,targetName:o,stream:Jr.PULL,streamId:i,desiredSize:u.desiredSize}),p.promise},cancel:u=>{on(u instanceof Error,"cancel must have a valid reason");const p=Promise.withResolvers();return this.streamControllers[i].cancelCall=p,this.streamControllers[i].isClosed=!0,l.postMessage({sourceName:s,targetName:o,stream:Jr.CANCEL,streamId:i,reason:xi(u)}),p.promise}},r)}destroy(){var e;(e=_(this,Cg))==null||e.abort(),M(this,Cg,null)}}Cg=new WeakMap,Ks=new WeakSet,Jle=function({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){K(this,Ks,tce).call(this,e);return}if(e.callback){const r=e.callbackId,a=this.callbackCapabilities[r];if(!a)throw new Error(`Cannot resolve callback ${r}`);if(delete this.callbackCapabilities[r],e.callback===wA.DATA)a.resolve(e.data);else if(e.callback===wA.ERROR)a.reject(xi(e.reason));else throw new Error("Unexpected callback case");return}const n=this.actionHandler[e.action];if(!n)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const r=this.sourceName,a=e.sourceName,i=this.comObj;Promise.try(n,e.data).then(function(s){i.postMessage({sourceName:r,targetName:a,callback:wA.DATA,callbackId:e.callbackId,data:s})},function(s){i.postMessage({sourceName:r,targetName:a,callback:wA.ERROR,callbackId:e.callbackId,reason:xi(s)})});return}if(e.streamId){K(this,Ks,ece).call(this,e);return}n(e.data)},ece=function(e){const n=e.streamId,r=this.sourceName,a=e.sourceName,i=this.comObj,s=this,o=this.actionHandler[e.action],l={enqueue(u,p=1,f){if(this.isCancelled)return;const m=this.desiredSize;this.desiredSize-=p,m>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:r,targetName:a,stream:Jr.ENQUEUE,streamId:n,chunk:u},f)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:a,stream:Jr.CLOSE,streamId:n}),delete s.streamSinks[n])},error(u){on(u instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:a,stream:Jr.ERROR,streamId:n,reason:xi(u)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[n]=l,Promise.try(o,e.data,l).then(function(){i.postMessage({sourceName:r,targetName:a,stream:Jr.START_COMPLETE,streamId:n,success:!0})},function(u){i.postMessage({sourceName:r,targetName:a,stream:Jr.START_COMPLETE,streamId:n,reason:xi(u)})})},tce=function(e){const n=e.streamId,r=this.sourceName,a=e.sourceName,i=this.comObj,s=this.streamControllers[n],o=this.streamSinks[n];switch(e.stream){case Jr.START_COMPLETE:e.success?s.startCall.resolve():s.startCall.reject(xi(e.reason));break;case Jr.PULL_COMPLETE:e.success?s.pullCall.resolve():s.pullCall.reject(xi(e.reason));break;case Jr.PULL:if(!o){i.postMessage({sourceName:r,targetName:a,stream:Jr.PULL_COMPLETE,streamId:n,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Ure).then(function(){i.postMessage({sourceName:r,targetName:a,stream:Jr.PULL_COMPLETE,streamId:n,success:!0})},function(u){i.postMessage({sourceName:r,targetName:a,stream:Jr.PULL_COMPLETE,streamId:n,reason:xi(u)})});break;case Jr.ENQUEUE:if(on(s,"enqueue should have stream controller"),s.isClosed)break;s.controller.enqueue(e.chunk);break;case Jr.CLOSE:if(on(s,"close should have stream controller"),s.isClosed)break;s.isClosed=!0,s.controller.close(),K(this,Ks,wR).call(this,s,n);break;case Jr.ERROR:on(s,"error should have stream controller"),s.controller.error(xi(e.reason)),K(this,Ks,wR).call(this,s,n);break;case Jr.CANCEL_COMPLETE:e.success?s.cancelCall.resolve():s.cancelCall.reject(xi(e.reason)),K(this,Ks,wR).call(this,s,n);break;case Jr.CANCEL:if(!o)break;const l=xi(e.reason);Promise.try(o.onCancel||Ure,l).then(function(){i.postMessage({sourceName:r,targetName:a,stream:Jr.CANCEL_COMPLETE,streamId:n,success:!0})},function(u){i.postMessage({sourceName:r,targetName:a,stream:Jr.CANCEL_COMPLETE,streamId:n,reason:xi(u)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[n];break;default:throw new Error("Unexpected stream case")}},wR=async function(e,n){var r,a,i;await Promise.allSettled([(r=e.startCall)==null?void 0:r.promise,(a=e.pullCall)==null?void 0:a.promise,(i=e.cancelCall)==null?void 0:i.promise]),delete this.streamControllers[n]};class Gre{constructor({enableHWA:e=!1}){Y(this,wE,!1);M(this,wE,e)}create(e,n){if(e<=0||n<=0)throw new Error("Invalid canvas size");const r=this._createCanvas(e,n);return{canvas:r,context:r.getContext("2d",{willReadFrequently:!_(this,wE)})}}reset(e,n,r){if(!e.canvas)throw new Error("Canvas is not specified");if(n<=0||r<=0)throw new Error("Invalid canvas size");e.canvas.width=n,e.canvas.height=r}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,n){Qn("Abstract method `_createCanvas` called.")}}wE=new WeakMap;class RUe extends Gre{constructor({ownerDocument:e=globalThis.document,enableHWA:n=!1}){super({enableHWA:n}),this._document=e}_createCanvas(e,n){const r=this._document.createElement("canvas");return r.width=e,r.height=n,r}}class zre{constructor({baseUrl:e=null,isCompressed:n=!0}){this.baseUrl=e,this.isCompressed=n}async fetch({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");const n=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(n).then(r=>({cMapData:r,isCompressed:this.isCompressed})).catch(r=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${n}`)})}async _fetch(e){Qn("Abstract method `_fetch` called.")}}class qre extends zre{async _fetch(e){const n=await Wh(e,this.isCompressed?"arraybuffer":"text");return n instanceof ArrayBuffer?new Uint8Array(n):M0(n)}}class Hre{addFilter(e){return"none"}addHCMFilter(e,n){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,n,r,a,i){return"none"}destroy(e=!1){}}class NUe extends Hre{constructor({docId:n,ownerDocument:r=globalThis.document}){super();Y(this,Ze);Y(this,Df);Y(this,Rg);Y(this,Uc);Y(this,Gc);Y(this,Ja);Y(this,kf);Y(this,Mf,0);M(this,Gc,n),M(this,Ja,r)}addFilter(n){if(!n)return"none";let r=_(this,Ze,ii).get(n);if(r)return r;const[a,i,s]=K(this,Ze,xR).call(this,n),o=n.length===1?a:`${a}${i}${s}`;if(r=_(this,Ze,ii).get(o),r)return _(this,Ze,ii).set(n,r),r;const l=`g_${_(this,Gc)}_transfer_map_${_a(this,Mf)._++}`,u=K(this,Ze,mb).call(this,l);_(this,Ze,ii).set(n,u),_(this,Ze,ii).set(o,u);const p=K(this,Ze,hb).call(this,l);return K(this,Ze,xy).call(this,a,i,s,p),u}addHCMFilter(n,r){var S;const a=`${n}-${r}`,i="base";let s=_(this,Ze,Ny).get(i);if((s==null?void 0:s.key)===a||(s?((S=s.filter)==null||S.remove(),s.key=a,s.url="none",s.filter=null):(s={key:a,url:"none",filter:null},_(this,Ze,Ny).set(i,s)),!n||!r))return s.url;const o=K(this,Ze,Oy).call(this,n);n=Je.makeHexColor(...o);const l=K(this,Ze,Oy).call(this,r);if(r=Je.makeHexColor(...l),_(this,Ze,fb).style.color="",n==="#000000"&&r==="#ffffff"||n===r)return s.url;const u=new Array(256);for(let E=0;E<=255;E++){const y=E/255;u[E]=y<=.03928?y/12.92:((y+.055)/1.055)**2.4}const p=u.join(","),f=`g_${_(this,Gc)}_hcm_filter`,m=s.filter=K(this,Ze,hb).call(this,f);K(this,Ze,xy).call(this,p,p,p,m),K(this,Ze,a6).call(this,m);const g=(E,y)=>{const v=o[E]/255,A=l[E]/255,T=new Array(y+1);for(let w=0;w<=y;w++)T[w]=v+w/y*(A-v);return T.join(",")};return K(this,Ze,xy).call(this,g(0,5),g(1,5),g(2,5),m),s.url=K(this,Ze,mb).call(this,f),s.url}addAlphaFilter(n){let r=_(this,Ze,ii).get(n);if(r)return r;const[a]=K(this,Ze,xR).call(this,[n]),i=`alpha_${a}`;if(r=_(this,Ze,ii).get(i),r)return _(this,Ze,ii).set(n,r),r;const s=`g_${_(this,Gc)}_alpha_map_${_a(this,Mf)._++}`,o=K(this,Ze,mb).call(this,s);_(this,Ze,ii).set(n,o),_(this,Ze,ii).set(i,o);const l=K(this,Ze,hb).call(this,s);return K(this,Ze,i6).call(this,a,l),o}addLuminosityFilter(n){let r=_(this,Ze,ii).get(n||"luminosity");if(r)return r;let a,i;if(n?([a]=K(this,Ze,xR).call(this,[n]),i=`luminosity_${a}`):i="luminosity",r=_(this,Ze,ii).get(i),r)return _(this,Ze,ii).set(n,r),r;const s=`g_${_(this,Gc)}_luminosity_map_${_a(this,Mf)._++}`,o=K(this,Ze,mb).call(this,s);_(this,Ze,ii).set(n,o),_(this,Ze,ii).set(i,o);const l=K(this,Ze,hb).call(this,s);return K(this,Ze,nce).call(this,l),n&&K(this,Ze,i6).call(this,a,l),o}addHighlightHCMFilter(n,r,a,i,s){var A;const o=`${r}-${a}-${i}-${s}`;let l=_(this,Ze,Ny).get(n);if((l==null?void 0:l.key)===o||(l?((A=l.filter)==null||A.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},_(this,Ze,Ny).set(n,l)),!r||!a))return l.url;const[u,p]=[r,a].map(K(this,Ze,Oy).bind(this));let f=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),m=Math.round(.2126*p[0]+.7152*p[1]+.0722*p[2]),[g,S]=[i,s].map(K(this,Ze,Oy).bind(this));m<f&&([f,m,g,S]=[m,f,S,g]),_(this,Ze,fb).style.color="";const E=(T,w,O)=>{const R=new Array(256),I=(m-f)/O,L=T/255,P=(w-T)/(255*O);let U=0;for(let H=0;H<=O;H++){const W=Math.round(f+H*I),Z=L+H*P;for(let F=U;F<=W;F++)R[F]=Z;U=W+1}for(let H=U;H<256;H++)R[H]=R[U-1];return R.join(",")},y=`g_${_(this,Gc)}_hcm_${n}_filter`,v=l.filter=K(this,Ze,hb).call(this,y);return K(this,Ze,a6).call(this,v),K(this,Ze,xy).call(this,E(g[0],S[0],5),E(g[1],S[1],5),E(g[2],S[2],5),v),l.url=K(this,Ze,mb).call(this,y),l.url}destroy(n=!1){var r,a,i,s;n&&((r=_(this,kf))!=null&&r.size)||((a=_(this,Uc))==null||a.parentNode.parentNode.remove(),M(this,Uc,null),(i=_(this,Rg))==null||i.clear(),M(this,Rg,null),(s=_(this,kf))==null||s.clear(),M(this,kf,null),M(this,Mf,0))}}Df=new WeakMap,Rg=new WeakMap,Uc=new WeakMap,Gc=new WeakMap,Ja=new WeakMap,kf=new WeakMap,Mf=new WeakMap,Ze=new WeakSet,ii=function(){return _(this,Rg)||M(this,Rg,new Map)},Ny=function(){return _(this,kf)||M(this,kf,new Map)},fb=function(){if(!_(this,Uc)){const n=_(this,Ja).createElement("div"),{style:r}=n;r.visibility="hidden",r.contain="strict",r.width=r.height=0,r.position="absolute",r.top=r.left=0,r.zIndex=-1;const a=_(this,Ja).createElementNS(vc,"svg");a.setAttribute("width",0),a.setAttribute("height",0),M(this,Uc,_(this,Ja).createElementNS(vc,"defs")),n.append(a),a.append(_(this,Uc)),_(this,Ja).body.append(n)}return _(this,Uc)},xR=function(n){if(n.length===1){const u=n[0],p=new Array(256);for(let m=0;m<256;m++)p[m]=u[m]/255;const f=p.join(",");return[f,f,f]}const[r,a,i]=n,s=new Array(256),o=new Array(256),l=new Array(256);for(let u=0;u<256;u++)s[u]=r[u]/255,o[u]=a[u]/255,l[u]=i[u]/255;return[s.join(","),o.join(","),l.join(",")]},mb=function(n){if(_(this,Df)===void 0){M(this,Df,"");const r=_(this,Ja).URL;r!==_(this,Ja).baseURI&&(F0(r)?It('#createUrl: ignore "data:"-URL for performance reasons.'):M(this,Df,Y3(r,"")))}return`url(${_(this,Df)}#${n})`},nce=function(n){const r=_(this,Ja).createElementNS(vc,"feColorMatrix");r.setAttribute("type","matrix"),r.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),n.append(r)},a6=function(n){const r=_(this,Ja).createElementNS(vc,"feColorMatrix");r.setAttribute("type","matrix"),r.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),n.append(r)},hb=function(n){const r=_(this,Ja).createElementNS(vc,"filter");return r.setAttribute("color-interpolation-filters","sRGB"),r.setAttribute("id",n),_(this,Ze,fb).append(r),r},wy=function(n,r,a){const i=_(this,Ja).createElementNS(vc,r);i.setAttribute("type","discrete"),i.setAttribute("tableValues",a),n.append(i)},xy=function(n,r,a,i){const s=_(this,Ja).createElementNS(vc,"feComponentTransfer");i.append(s),K(this,Ze,wy).call(this,s,"feFuncR",n),K(this,Ze,wy).call(this,s,"feFuncG",r),K(this,Ze,wy).call(this,s,"feFuncB",a)},i6=function(n,r){const a=_(this,Ja).createElementNS(vc,"feComponentTransfer");r.append(a),K(this,Ze,wy).call(this,a,"feFuncA",n)},Oy=function(n){return _(this,Ze,fb).style.color=n,jh(getComputedStyle(_(this,Ze,fb)).getPropertyValue("color"))};class $re{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const n=`${this.baseUrl}${e}`;return this._fetch(n).catch(r=>{throw new Error(`Unable to load font data at: ${n}`)})}async _fetch(e){Qn("Abstract method `_fetch` called.")}}class Yre extends $re{async _fetch(e){const n=await Wh(e,"arraybuffer");return new Uint8Array(n)}}class Vre{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!e)throw new Error("Wasm filename must be specified.");const n=`${this.baseUrl}${e}`;return this._fetch(n).catch(r=>{throw new Error(`Unable to load wasm data at: ${n}`)})}async _fetch(e){Qn("Abstract method `_fetch` called.")}}class Wre extends Vre{async _fetch(e){const n=await Wh(e,"arraybuffer");return new Uint8Array(n)}}ui&&It("Please use the `legacy` build in Node.js environments.");async function sF(t){const n=await process.getBuiltinModule("fs").promises.readFile(t);return new Uint8Array(n)}class wUe extends Hre{}class xUe extends Gre{_createCanvas(e,n){return process.getBuiltinModule("module").createRequire(wn&&wn.tagName.toUpperCase()==="SCRIPT"&&wn.src||new URL("debugger.v0.2.1.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(e,n)}}class OUe extends zre{async _fetch(e){return sF(e)}}class IUe extends $re{async _fetch(e){return sF(e)}}class DUe extends Vre{async _fetch(e){return sF(e)}}const Kh="__forcedDependency",{floor:jre,ceil:Kre}=Math;function xA(t,e,n,r,a,i){t[e*4+0]=Math.min(t[e*4+0],n),t[e*4+1]=Math.min(t[e*4+1],r),t[e*4+2]=Math.max(t[e*4+2],a),t[e*4+3]=Math.max(t[e*4+3],i)}const oF=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class kUe{constructor(e,n){Y(this,Ng);Y(this,wd);M(this,Ng,e),M(this,wd,n)}get length(){return _(this,Ng).length}isEmpty(e){return _(this,Ng)[e]===oF}minX(e){return _(this,wd)[e*4+0]/256}minY(e){return _(this,wd)[e*4+1]/256}maxX(e){return(_(this,wd)[e*4+2]+1)/256}maxY(e){return(_(this,wd)[e*4+3]+1)/256}}Ng=new WeakMap,wd=new WeakMap;const OA=(t,e)=>{if(!t)return;let n=t.get(e);return n||(n={dependencies:new Set,isRenderingOperation:!1},t.set(e,n)),n};class MUe{constructor(e,n,r=!1){Y(this,OE);Y(this,Di,{__proto__:null});Y(this,ki,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Kh]:[]});Y(this,Lf,new Map);Y(this,Lo,[]);Y(this,Pf,[]);Y(this,zc,[[1,0,0,1,0,0]]);Y(this,kn,[-1/0,-1/0,1/0,1/0]);Y(this,Gn,new Float64Array([1/0,1/0,-1/0,-1/0]));Y(this,qc,-1);Y(this,Mi,new Set);Y(this,xE,new Map);Y(this,wg,new Map);Y(this,Ff);Y(this,Bf);Y(this,Hc);Y(this,ei);Y(this,Il);M(this,Ff,e.width),M(this,Bf,e.height),K(this,OE,s6).call(this,n),r&&M(this,Il,new Map)}growOperationsCount(e){e>=_(this,ei).length&&K(this,OE,s6).call(this,e,_(this,ei))}save(e){return M(this,Di,{__proto__:_(this,Di)}),M(this,ki,{__proto__:_(this,ki),transform:{__proto__:_(this,ki).transform},moveText:{__proto__:_(this,ki).moveText},sameLineText:{__proto__:_(this,ki).sameLineText},[Kh]:{__proto__:_(this,ki)[Kh]}}),M(this,kn,{__proto__:_(this,kn)}),_(this,Lo).push(e),this}restore(e){var a;const n=Object.getPrototypeOf(_(this,Di));if(n===null)return this;M(this,Di,n),M(this,ki,Object.getPrototypeOf(_(this,ki))),M(this,kn,Object.getPrototypeOf(_(this,kn)));const r=_(this,Lo).pop();return r!==void 0&&((a=OA(_(this,Il),e))==null||a.dependencies.add(r),_(this,ei)[e]=_(this,ei)[r]),this}recordOpenMarker(e){return _(this,Lo).push(e),this}getOpenMarker(){return _(this,Lo).length===0?null:_(this,Lo).at(-1)}recordCloseMarker(e){var r;const n=_(this,Lo).pop();return n!==void 0&&((r=OA(_(this,Il),e))==null||r.dependencies.add(n),_(this,ei)[e]=_(this,ei)[n]),this}beginMarkedContent(e){return _(this,Pf).push(e),this}endMarkedContent(e){var r;const n=_(this,Pf).pop();return n!==void 0&&((r=OA(_(this,Il),e))==null||r.dependencies.add(n),_(this,ei)[e]=_(this,ei)[n]),this}pushBaseTransform(e){return _(this,zc).push(Je.multiplyByDOMMatrix(_(this,zc).at(-1),e.getTransform())),this}popBaseTransform(){return _(this,zc).length>1&&_(this,zc).pop(),this}recordSimpleData(e,n){return _(this,Di)[e]=n,this}recordIncrementalData(e,n){return _(this,ki)[e].push(n),this}resetIncrementalData(e,n){return _(this,ki)[e].length=0,this}recordNamedData(e,n){return _(this,Lf).set(e,n),this}recordSimpleDataFromNamed(e,n,r){_(this,Di)[e]=_(this,Lf).get(n)??r}recordFutureForcedDependency(e,n){return this.recordIncrementalData(Kh,n),this}inheritSimpleDataAsFutureForcedDependencies(e){for(const n of e)n in _(this,Di)&&this.recordFutureForcedDependency(n,_(this,Di)[n]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const e of _(this,Mi))this.recordFutureForcedDependency(Kh,e);return this}resetBBox(e){return _(this,qc)!==e&&(M(this,qc,e),_(this,Gn)[0]=1/0,_(this,Gn)[1]=1/0,_(this,Gn)[2]=-1/0,_(this,Gn)[3]=-1/0),this}recordClipBox(e,n,r,a,i,s){const o=Je.multiplyByDOMMatrix(_(this,zc).at(-1),n.getTransform()),l=[1/0,1/0,-1/0,-1/0];Je.axialAlignedBoundingBox([r,i,a,s],o,l);const u=Je.intersect(_(this,kn),l);return u?(_(this,kn)[0]=u[0],_(this,kn)[1]=u[1],_(this,kn)[2]=u[2],_(this,kn)[3]=u[3]):(_(this,kn)[0]=_(this,kn)[1]=1/0,_(this,kn)[2]=_(this,kn)[3]=-1/0),this}recordBBox(e,n,r,a,i,s){const o=_(this,kn);if(o[0]===1/0)return this;const l=Je.multiplyByDOMMatrix(_(this,zc).at(-1),n.getTransform());if(o[0]===-1/0)return Je.axialAlignedBoundingBox([r,i,a,s],l,_(this,Gn)),this;const u=[1/0,1/0,-1/0,-1/0];return Je.axialAlignedBoundingBox([r,i,a,s],l,u),_(this,Gn)[0]=Math.min(_(this,Gn)[0],Math.max(u[0],o[0])),_(this,Gn)[1]=Math.min(_(this,Gn)[1],Math.max(u[1],o[1])),_(this,Gn)[2]=Math.max(_(this,Gn)[2],Math.min(u[2],o[2])),_(this,Gn)[3]=Math.max(_(this,Gn)[3],Math.min(u[3],o[3])),this}recordCharacterBBox(e,n,r,a=1,i=0,s=0,o){const l=r.bbox;let u,p;if(l&&(u=l[2]!==l[0]&&l[3]!==l[1]&&_(this,wg).get(r),u!==!1&&(p=[0,0,0,0],Je.axialAlignedBoundingBox(l,r.fontMatrix,p),(a!==1||i!==0||s!==0)&&Je.scaleMinMax([a,0,0,-a,i,s],p),u)))return this.recordBBox(e,n,p[0],p[2],p[1],p[3]);if(!o)return this.recordFullPageBBox(e);const f=o();return l&&p&&u===void 0&&(u=p[0]<=i-f.actualBoundingBoxLeft&&p[2]>=i+f.actualBoundingBoxRight&&p[1]<=s-f.actualBoundingBoxAscent&&p[3]>=s+f.actualBoundingBoxDescent,_(this,wg).set(r,u),u)?this.recordBBox(e,n,p[0],p[2],p[1],p[3]):this.recordBBox(e,n,i-f.actualBoundingBoxLeft,i+f.actualBoundingBoxRight,s-f.actualBoundingBoxAscent,s+f.actualBoundingBoxDescent)}recordFullPageBBox(e){return _(this,Gn)[0]=Math.max(0,_(this,kn)[0]),_(this,Gn)[1]=Math.max(0,_(this,kn)[1]),_(this,Gn)[2]=Math.min(_(this,Ff),_(this,kn)[2]),_(this,Gn)[3]=Math.min(_(this,Bf),_(this,kn)[3]),this}getSimpleIndex(e){return _(this,Di)[e]}recordDependencies(e,n){const r=_(this,Mi),a=_(this,Di),i=_(this,ki);for(const s of n)s in _(this,Di)?r.add(a[s]):s in i&&i[s].forEach(r.add,r);return this}recordNamedDependency(e,n){return _(this,Lf).has(n)&&_(this,Mi).add(_(this,Lf).get(n)),this}recordOperation(e,n=!1){if(this.recordDependencies(e,[Kh]),_(this,Il)){const r=OA(_(this,Il),e),{dependencies:a}=r;_(this,Mi).forEach(a.add,a),_(this,Lo).forEach(a.add,a),_(this,Pf).forEach(a.add,a),a.delete(e),r.isRenderingOperation=!0}if(_(this,qc)===e){const r=jre(_(this,Gn)[0]*256/_(this,Ff)),a=jre(_(this,Gn)[1]*256/_(this,Bf)),i=Kre(_(this,Gn)[2]*256/_(this,Ff)),s=Kre(_(this,Gn)[3]*256/_(this,Bf));xA(_(this,Hc),e,r,a,i,s);for(const o of _(this,Mi))o!==e&&xA(_(this,Hc),o,r,a,i,s);for(const o of _(this,Lo))o!==e&&xA(_(this,Hc),o,r,a,i,s);for(const o of _(this,Pf))o!==e&&xA(_(this,Hc),o,r,a,i,s);n||(_(this,Mi).clear(),M(this,qc,-1))}return this}recordShowTextOperation(e,n=!1){const r=Array.from(_(this,Mi));this.recordOperation(e,n),this.recordIncrementalData("sameLineText",e);for(const a of r)this.recordIncrementalData("sameLineText",a);return this}bboxToClipBoxDropOperation(e,n=!1){return _(this,qc)===e&&(M(this,qc,-1),_(this,kn)[0]=Math.max(_(this,kn)[0],_(this,Gn)[0]),_(this,kn)[1]=Math.max(_(this,kn)[1],_(this,Gn)[1]),_(this,kn)[2]=Math.min(_(this,kn)[2],_(this,Gn)[2]),_(this,kn)[3]=Math.min(_(this,kn)[3],_(this,Gn)[3]),n||_(this,Mi).clear()),this}_takePendingDependencies(){const e=_(this,Mi);return M(this,Mi,new Set),e}_extractOperation(e){const n=_(this,xE).get(e);return _(this,xE).delete(e),n}_pushPendingDependencies(e){for(const n of e)_(this,Mi).add(n)}take(){return _(this,wg).clear(),new kUe(_(this,ei),_(this,Hc))}takeDebugMetadata(){return _(this,Il)}}Di=new WeakMap,ki=new WeakMap,Lf=new WeakMap,Lo=new WeakMap,Pf=new WeakMap,zc=new WeakMap,kn=new WeakMap,Gn=new WeakMap,qc=new WeakMap,Mi=new WeakMap,xE=new WeakMap,wg=new WeakMap,Ff=new WeakMap,Bf=new WeakMap,Hc=new WeakMap,ei=new WeakMap,Il=new WeakMap,OE=new WeakSet,s6=function(e,n){const r=new ArrayBuffer(e*4);M(this,Hc,new Uint8ClampedArray(r)),M(this,ei,new Uint32Array(r)),n&&n.length>0?(_(this,ei).set(n),_(this,ei).fill(oF,n.length)):_(this,ei).fill(oF)};const BF=class BF{constructor(e,n,r){Y(this,er);Y(this,Lr);Y(this,Po);Y(this,xg,0);Y(this,Og,0);if(e instanceof BF&&_(e,Po)===!!r)return e;M(this,er,e),M(this,Lr,n),M(this,Po,!!r)}growOperationsCount(){throw new Error("Unreachable")}save(e){return _a(this,Og)._++,_(this,er).save(_(this,Lr)),this}restore(e){return _(this,Og)>0&&(_(this,er).restore(_(this,Lr)),_a(this,Og)._--),this}recordOpenMarker(e){return _a(this,xg)._++,this}getOpenMarker(){return _(this,xg)>0?_(this,Lr):_(this,er).getOpenMarker()}recordCloseMarker(e){return _a(this,xg)._--,this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return _(this,er).pushBaseTransform(e),this}popBaseTransform(){return _(this,er).popBaseTransform(),this}recordSimpleData(e,n){return _(this,er).recordSimpleData(e,_(this,Lr)),this}recordIncrementalData(e,n){return _(this,er).recordIncrementalData(e,_(this,Lr)),this}resetIncrementalData(e,n){return _(this,er).resetIncrementalData(e,_(this,Lr)),this}recordNamedData(e,n){return this}recordSimpleDataFromNamed(e,n,r){return _(this,er).recordSimpleDataFromNamed(e,n,_(this,Lr)),this}recordFutureForcedDependency(e,n){return _(this,er).recordFutureForcedDependency(e,_(this,Lr)),this}inheritSimpleDataAsFutureForcedDependencies(e){return _(this,er).inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return _(this,er).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return _(this,Po)||_(this,er).resetBBox(_(this,Lr)),this}recordClipBox(e,n,r,a,i,s){return _(this,Po)||_(this,er).recordClipBox(_(this,Lr),n,r,a,i,s),this}recordBBox(e,n,r,a,i,s){return _(this,Po)||_(this,er).recordBBox(_(this,Lr),n,r,a,i,s),this}recordCharacterBBox(e,n,r,a,i,s,o){return _(this,Po)||_(this,er).recordCharacterBBox(_(this,Lr),n,r,a,i,s,o),this}recordFullPageBBox(e){return _(this,Po)||_(this,er).recordFullPageBBox(_(this,Lr)),this}getSimpleIndex(e){return _(this,er).getSimpleIndex(e)}recordDependencies(e,n){return _(this,er).recordDependencies(_(this,Lr),n),this}recordNamedDependency(e,n){return _(this,er).recordNamedDependency(_(this,Lr),n),this}recordOperation(e){return _(this,er).recordOperation(_(this,Lr),!0),this}recordShowTextOperation(e){return _(this,er).recordShowTextOperation(_(this,Lr),!0),this}bboxToClipBoxDropOperation(e){return _(this,Po)||_(this,er).bboxToClipBoxDropOperation(_(this,Lr),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};er=new WeakMap,Lr=new WeakMap,Po=new WeakMap,xg=new WeakMap,Og=new WeakMap;let IA=BF;const Us={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]},Da={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function lF(t,e){if(!e)return;const n=e[2]-e[0],r=e[3]-e[1],a=new Path2D;a.rect(e[0],e[1],n,r),t.clip(a)}class cF{isModifyingCurrentTransform(){return!1}getPattern(){Qn("Abstract method `getPattern` called.")}}class LUe extends cF{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let n;this._type==="axial"?n=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(n=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const r of this._colorStops)n.addColorStop(r[0],r[1]);return n}getPattern(e,n,r,a){let i;if(a===Da.STROKE||a===Da.FILL){const s=n.current.getClippedPathBoundingBox(a,Nr(e))||[0,0,0,0],o=Math.ceil(s[2]-s[0])||1,l=Math.ceil(s[3]-s[1])||1,u=n.cachedCanvases.getCanvas("pattern",o,l),p=u.context;p.clearRect(0,0,p.canvas.width,p.canvas.height),p.beginPath(),p.rect(0,0,p.canvas.width,p.canvas.height),p.translate(-s[0],-s[1]),r=Je.transform(r,[1,0,0,1,s[0],s[1]]),p.transform(...n.baseTransform),this.matrix&&p.transform(...this.matrix),lF(p,this._bbox),p.fillStyle=this._createGradient(p),p.fill(),i=e.createPattern(u.canvas,"no-repeat");const f=new DOMMatrix(r);i.setTransform(f)}else lF(e,this._bbox),i=this._createGradient(e);return i}}function uF(t,e,n,r,a,i,s,o){const l=e.coords,u=e.colors,p=t.data,f=t.width*4;let m;l[n+1]>l[r+1]&&(m=n,n=r,r=m,m=i,i=s,s=m),l[r+1]>l[a+1]&&(m=r,r=a,a=m,m=s,s=o,o=m),l[n+1]>l[r+1]&&(m=n,n=r,r=m,m=i,i=s,s=m);const g=(l[n]+e.offsetX)*e.scaleX,S=(l[n+1]+e.offsetY)*e.scaleY,E=(l[r]+e.offsetX)*e.scaleX,y=(l[r+1]+e.offsetY)*e.scaleY,v=(l[a]+e.offsetX)*e.scaleX,A=(l[a+1]+e.offsetY)*e.scaleY;if(S>=A)return;const T=u[i],w=u[i+1],O=u[i+2],R=u[s],I=u[s+1],L=u[s+2],P=u[o],U=u[o+1],H=u[o+2],W=Math.round(S),Z=Math.round(A);let F,j,z,V,X,te,$,Q;for(let ee=W;ee<=Z;ee++){if(ee<y){const ne=ee<S?0:(S-ee)/(S-y);F=g-(g-E)*ne,j=T-(T-R)*ne,z=w-(w-I)*ne,V=O-(O-L)*ne}else{let ne;ee>A?ne=1:y===A?ne=0:ne=(y-ee)/(y-A),F=E-(E-v)*ne,j=R-(R-P)*ne,z=I-(I-U)*ne,V=L-(L-H)*ne}let B;ee<S?B=0:ee>A?B=1:B=(S-ee)/(S-A),X=g-(g-v)*B,te=T-(T-P)*B,$=w-(w-U)*B,Q=O-(O-H)*B;const ie=Math.round(Math.min(F,X)),ce=Math.round(Math.max(F,X));let se=f*ee+ie*4;for(let ne=ie;ne<=ce;ne++)B=(F-ne)/(F-X),B<0?B=0:B>1&&(B=1),p[se++]=j-(j-te)*B|0,p[se++]=z-(z-$)*B|0,p[se++]=V-(V-Q)*B|0,p[se++]=255}}function PUe(t,e,n){const r=e.coords,a=e.colors;let i,s;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(r.length/o)-1,u=o-1;for(i=0;i<l;i++){let p=i*o;for(let f=0;f<u;f++,p++)uF(t,n,r[p],r[p+1],r[p+o],a[p],a[p+1],a[p+o]),uF(t,n,r[p+o+1],r[p+1],r[p+o],a[p+o+1],a[p+1],a[p+o])}break;case"triangles":for(i=0,s=r.length;i<s;i+=3)uF(t,n,r[i],r[i+1],r[i+2],a[i],a[i+1],a[i+2]);break;default:throw new Error("illegal figure")}}class FUe extends cF{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[6],this._background=e[7],this.matrix=null}_createMeshCanvas(e,n,r){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),u=Math.ceil(this._bounds[2])-o,p=Math.ceil(this._bounds[3])-l,f=Math.min(Math.ceil(Math.abs(u*e[0]*1.1)),3e3),m=Math.min(Math.ceil(Math.abs(p*e[1]*1.1)),3e3),g=u/f,S=p/m,E={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/g,scaleY:1/S},y=f+4,v=m+4,A=r.getCanvas("mesh",y,v),T=A.context,w=T.createImageData(f,m);if(n){const R=w.data;for(let I=0,L=R.length;I<L;I+=4)R[I]=n[0],R[I+1]=n[1],R[I+2]=n[2],R[I+3]=255}for(const R of this._figures)PUe(w,R,E);return T.putImageData(w,2,2),{canvas:A.canvas,offsetX:o-2*g,offsetY:l-2*S,scaleX:g,scaleY:S}}isModifyingCurrentTransform(){return!0}getPattern(e,n,r,a){lF(e,this._bbox);const i=new Float32Array(2);if(a===Da.SHADING)Je.singularValueDecompose2dScale(Nr(e),i);else if(this.matrix){Je.singularValueDecompose2dScale(this.matrix,i);const[o,l]=i;Je.singularValueDecompose2dScale(n.baseTransform,i),i[0]*=o,i[1]*=l}else Je.singularValueDecompose2dScale(n.baseTransform,i);const s=this._createMeshCanvas(i,a===Da.SHADING?null:this._background,n.cachedCanvases);return a!==Da.SHADING&&(e.setTransform(...n.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(s.offsetX,s.offsetY),e.scale(s.scaleX,s.scaleY),e.createPattern(s.canvas,"no-repeat")}}class BUe extends cF{getPattern(){return"hotpink"}}function UUe(t){switch(t[0]){case"RadialAxial":return new LUe(t);case"Mesh":return new FUe(t);case"Dummy":return new BUe}throw new Error(`Unknown IR type: ${t[0]}`)}const Xre={COLORED:1,UNCOLORED:2},rC=class rC{constructor(e,n,r,a){this.color=e[1],this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.ctx=n,this.canvasGraphicsFactory=r,this.baseTransform=a}createPatternCanvas(e,n){var te,$;const{bbox:r,operatorList:a,paintType:i,tilingType:s,color:o,canvasGraphicsFactory:l}=this;let{xstep:u,ystep:p}=this;u=Math.abs(u),p=Math.abs(p),SA("TilingType: "+s);const f=r[0],m=r[1],g=r[2],S=r[3],E=g-f,y=S-m,v=new Float32Array(2);Je.singularValueDecompose2dScale(this.matrix,v);const[A,T]=v;Je.singularValueDecompose2dScale(this.baseTransform,v);const w=A*v[0],O=T*v[1];let R=E,I=y,L=!1,P=!1;const U=Math.ceil(u*w),H=Math.ceil(p*O),W=Math.ceil(E*w),Z=Math.ceil(y*O);U>=W?R=u:L=!0,H>=Z?I=p:P=!0;const F=this.getSizeAndScale(R,this.ctx.canvas.width,w),j=this.getSizeAndScale(I,this.ctx.canvas.height,O),z=e.cachedCanvases.getCanvas("pattern",F.size,j.size),V=z.context,X=l.createCanvasGraphics(V,n);if(X.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(X,i,o),V.translate(-F.scale*f,-j.scale*m),X.transform(0,F.scale,0,0,j.scale,0,0),V.save(),(te=X.dependencyTracker)==null||te.save(),this.clipBbox(X,f,m,g,S),X.baseTransform=Nr(X.ctx),X.executeOperatorList(a),X.endDrawing(),($=X.dependencyTracker)==null||$.restore(),V.restore(),L||P){const Q=z.canvas;L&&(R=u),P&&(I=p);const ee=this.getSizeAndScale(R,this.ctx.canvas.width,w),B=this.getSizeAndScale(I,this.ctx.canvas.height,O),ie=ee.size,ce=B.size,se=e.cachedCanvases.getCanvas("pattern-workaround",ie,ce),ne=se.context,oe=L?Math.floor(E/u):0,he=P?Math.floor(y/p):0;for(let _e=0;_e<=oe;_e++)for(let Ce=0;Ce<=he;Ce++)ne.drawImage(Q,ie*_e,ce*Ce,ie,ce,0,0,ie,ce);return{canvas:se.canvas,scaleX:ee.scale,scaleY:B.scale,offsetX:f,offsetY:m}}return{canvas:z.canvas,scaleX:F.scale,scaleY:j.scale,offsetX:f,offsetY:m}}getSizeAndScale(e,n,r){const a=Math.max(rC.MAX_PATTERN_SIZE,n);let i=Math.ceil(e*r);return i>=a?i=a:r=i/e,{scale:r,size:i}}clipBbox(e,n,r,a,i){const s=a-n,o=i-r;e.ctx.rect(n,r,s,o),Je.axialAlignedBoundingBox([n,r,a,i],Nr(e.ctx),e.current.minMax),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,n,r){const a=e.ctx,i=e.current;switch(n){case Xre.COLORED:const{fillStyle:s,strokeStyle:o}=this.ctx;a.fillStyle=i.fillColor=s,a.strokeStyle=i.strokeColor=o;break;case Xre.UNCOLORED:a.fillStyle=a.strokeStyle=r,i.fillColor=i.strokeColor=r;break;default:throw new sUe(`Unsupported paint type: ${n}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,n,r,a,i){let s=r;a!==Da.SHADING&&(s=Je.transform(s,n.baseTransform),this.matrix&&(s=Je.transform(s,this.matrix)));const o=this.createPatternCanvas(n,i);let l=new DOMMatrix(s);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const u=e.createPattern(o.canvas,"repeat");return u.setTransform(l),u}};Pe(rC,"MAX_PATTERN_SIZE",3e3);let dF=rC;function GUe({src:t,srcPos:e=0,dest:n,width:r,height:a,nonBlackColor:i=4294967295,inverseDecode:s=!1}){const o=Ea.isLittleEndian?4278190080:255,[l,u]=s?[i,o]:[o,i],p=r>>3,f=r&7,m=t.length;n=new Uint32Array(n.buffer);let g=0;for(let S=0;S<a;S++){for(const y=e+p;e<y;e++){const v=e<m?t[e]:255;n[g++]=v&128?u:l,n[g++]=v&64?u:l,n[g++]=v&32?u:l,n[g++]=v&16?u:l,n[g++]=v&8?u:l,n[g++]=v&4?u:l,n[g++]=v&2?u:l,n[g++]=v&1?u:l}if(f===0)continue;const E=e<m?t[e++]:255;for(let y=0;y<f;y++)n[g++]=E&1<<7-y?u:l}return{srcPos:e,destPos:g}}const Qre=16,Zre=100,zUe=15,Jre=10,Oi=16,pF=new DOMMatrix,is=new Float32Array(2),Xh=new Float32Array([1/0,1/0,-1/0,-1/0]);function qUe(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(n,r){e.translate(n,r),this.__originalTranslate(n,r)},t.scale=function(n,r){e.scale(n,r),this.__originalScale(n,r)},t.transform=function(n,r,a,i,s,o){e.transform(n,r,a,i,s,o),this.__originalTransform(n,r,a,i,s,o)},t.setTransform=function(n,r,a,i,s,o){e.setTransform(n,r,a,i,s,o),this.__originalSetTransform(n,r,a,i,s,o)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(n){e.rotate(n),this.__originalRotate(n)},t.clip=function(n){e.clip(n),this.__originalClip(n)},t.moveTo=function(n,r){e.moveTo(n,r),this.__originalMoveTo(n,r)},t.lineTo=function(n,r){e.lineTo(n,r),this.__originalLineTo(n,r)},t.bezierCurveTo=function(n,r,a,i,s,o){e.bezierCurveTo(n,r,a,i,s,o),this.__originalBezierCurveTo(n,r,a,i,s,o)},t.rect=function(n,r,a,i){e.rect(n,r,a,i),this.__originalRect(n,r,a,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}class HUe{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,n,r){let a;return this.cache[e]!==void 0?(a=this.cache[e],this.canvasFactory.reset(a,n,r)):(a=this.canvasFactory.create(n,r),this.cache[e]=a),a}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const n=this.cache[e];this.canvasFactory.destroy(n),delete this.cache[e]}}}function DA(t,e,n,r,a,i,s,o,l,u){const[p,f,m,g,S,E]=Nr(t);if(f===0&&m===0){const A=s*p+S,T=Math.round(A),w=o*g+E,O=Math.round(w),R=(s+l)*p+S,I=Math.abs(Math.round(R)-T)||1,L=(o+u)*g+E,P=Math.abs(Math.round(L)-O)||1;return t.setTransform(Math.sign(p),0,0,Math.sign(g),T,O),t.drawImage(e,n,r,a,i,0,0,I,P),t.setTransform(p,f,m,g,S,E),[I,P]}if(p===0&&g===0){const A=o*m+S,T=Math.round(A),w=s*f+E,O=Math.round(w),R=(o+u)*m+S,I=Math.abs(Math.round(R)-T)||1,L=(s+l)*f+E,P=Math.abs(Math.round(L)-O)||1;return t.setTransform(0,Math.sign(f),Math.sign(m),0,T,O),t.drawImage(e,n,r,a,i,0,0,P,I),t.setTransform(p,f,m,g,S,E),[P,I]}t.drawImage(e,n,r,a,i,s,o,l,u);const y=Math.hypot(p,f),v=Math.hypot(m,g);return[y*l,v*u]}class eae{constructor(e,n,r){Pe(this,"alphaIsShape",!1);Pe(this,"fontSize",0);Pe(this,"fontSizeScale",1);Pe(this,"textMatrix",null);Pe(this,"textMatrixScale",1);Pe(this,"fontMatrix",q3);Pe(this,"leading",0);Pe(this,"x",0);Pe(this,"y",0);Pe(this,"lineX",0);Pe(this,"lineY",0);Pe(this,"charSpacing",0);Pe(this,"wordSpacing",0);Pe(this,"textHScale",1);Pe(this,"textRenderingMode",Ia.FILL);Pe(this,"textRise",0);Pe(this,"fillColor","#000000");Pe(this,"strokeColor","#000000");Pe(this,"patternFill",!1);Pe(this,"patternStroke",!1);Pe(this,"fillAlpha",1);Pe(this,"strokeAlpha",1);Pe(this,"lineWidth",1);Pe(this,"activeSMask",null);Pe(this,"transferMaps","none");r==null||r(this),this.clipBox=new Float32Array([0,0,e,n]),this.minMax=Xh.slice()}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e.minMax=this.minMax.slice(),e}getPathBoundingBox(e=Da.FILL,n=null){const r=this.minMax.slice();if(e===Da.STROKE){n||Qn("Stroke bounding box must include transform."),Je.singularValueDecompose2dScale(n,is);const a=is[0]*this.lineWidth/2,i=is[1]*this.lineWidth/2;r[0]-=a,r[1]-=i,r[2]+=a,r[3]+=i}return r}updateClipFromPath(){const e=Je.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0),this.minMax.set(Xh,0)}getClippedPathBoundingBox(e=Da.FILL,n=null){return Je.intersect(this.clipBox,this.getPathBoundingBox(e,n))}}function tae(t,e){if(e instanceof ImageData){t.putImageData(e,0,0);return}const n=e.height,r=e.width,a=n%Oi,i=(n-a)/Oi,s=a===0?i:i+1,o=t.createImageData(r,Oi);let l=0,u;const p=e.data,f=o.data;let m,g,S,E;if(e.kind===I0.GRAYSCALE_1BPP){const y=p.byteLength,v=new Uint32Array(f.buffer,0,f.byteLength>>2),A=v.length,T=r+7>>3,w=4294967295,O=Ea.isLittleEndian?4278190080:255;for(m=0;m<s;m++){for(S=m<i?Oi:a,u=0,g=0;g<S;g++){const R=y-l;let I=0;const L=R>T?r:R*8-7,P=L&-8;let U=0,H=0;for(;I<P;I+=8)H=p[l++],v[u++]=H&128?w:O,v[u++]=H&64?w:O,v[u++]=H&32?w:O,v[u++]=H&16?w:O,v[u++]=H&8?w:O,v[u++]=H&4?w:O,v[u++]=H&2?w:O,v[u++]=H&1?w:O;for(;I<L;I++)U===0&&(H=p[l++],U=128),v[u++]=H&U?w:O,U>>=1}for(;u<A;)v[u++]=0;t.putImageData(o,0,m*Oi)}}else if(e.kind===I0.RGBA_32BPP){for(g=0,E=r*Oi*4,m=0;m<i;m++)f.set(p.subarray(l,l+E)),l+=E,t.putImageData(o,0,g),g+=Oi;m<s&&(E=r*a*4,f.set(p.subarray(l,l+E)),t.putImageData(o,0,g))}else if(e.kind===I0.RGB_24BPP)for(S=Oi,E=r*S,m=0;m<s;m++){for(m>=i&&(S=a,E=r*S),u=0,g=E;g--;)f[u++]=p[l++],f[u++]=p[l++],f[u++]=p[l++],f[u++]=255;t.putImageData(o,0,m*Oi)}else throw new Error(`bad image kind: ${e.kind}`)}function nae(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}const n=e.height,r=e.width,a=n%Oi,i=(n-a)/Oi,s=a===0?i:i+1,o=t.createImageData(r,Oi);let l=0;const u=e.data,p=o.data;for(let f=0;f<s;f++){const m=f<i?Oi:a;({srcPos:l}=GUe({src:u,srcPos:l,dest:p,width:r,height:m,nonBlackColor:0})),t.putImageData(o,0,f*Oi)}}function H0(t,e){const n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const r of n)t[r]!==void 0&&(e[r]=t[r]);t.setLineDash!==void 0&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function kA(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",t.setLineDash!==void 0&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;e!=="none"&&e!==""&&(t.filter="none")}function rae(t,e){if(e)return!0;Je.singularValueDecompose2dScale(t,is);const n=Math.fround(Oo.pixelRatio*Tc.PDF_TO_CSS_UNITS);return is[0]<=n&&is[1]<=n}const $Ue=["butt","round","square"],YUe=["miter","round","bevel"],VUe={},aae={},UF=class UF{constructor(e,n,r,a,i,{optionalContentConfig:s,markedContentStack:o=null},l,u,p){Y(this,Fo);this.ctx=e,this.current=new eae(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=n,this.objs=r,this.canvasFactory=a,this.filterFactory=i,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=s,this.cachedCanvases=new HUe(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=u,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=p??null}getObject(e,n,r=null){var a;return typeof n=="string"?((a=this.dependencyTracker)==null||a.recordNamedDependency(e,n),n.startsWith("g_")?this.commonObjs.get(n):this.objs.get(n)):r}beginDrawing({transform:e,viewport:n,transparency:r=!1,background:a=null}){const i=this.ctx.canvas.width,s=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=a||"#ffffff",this.ctx.fillRect(0,0,i,s),this.ctx.fillStyle=o,r){const l=this.cachedCanvases.getCanvas("transparent",i,s);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...Nr(this.compositeCtx))}this.ctx.save(),kA(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...n.transform),this.viewportScale=n.scale,this.baseTransform=Nr(this.ctx)}executeOperatorList(e,n,r,a,i){var v;const s=e.argsArray,o=e.fnArray;let l=n||0;const u=s.length;if(u===l)return l;const p=u-l>Jre&&typeof r=="function",f=p?Date.now()+zUe:0;let m=0;const g=this.commonObjs,S=this.objs;let E,y;for(;;){if(a!==void 0&&l===a.nextBreakPoint)return a.breakIt(l,r),l;if(!i||i(l))if(E=o[l],y=s[l]??null,E!==Vh.dependency)y===null?this[E](l):this[E](l,...y);else for(const A of y){(v=this.dependencyTracker)==null||v.recordNamedData(A,l);const T=A.startsWith("g_")?g:S;if(!T.has(A))return T.get(A,r),l}if(l++,l===u)return l;if(p&&++m>Jre){if(Date.now()>f)return r(),l;m=0}}}endDrawing(){K(this,Fo,o6).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const n of e.values())typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&(n.width=n.height=0);e.clear()}this._cachedBitmapsMap.clear(),K(this,Fo,l6).call(this)}_scaleImage(e,n){const r=e.width??e.displayWidth,a=e.height??e.displayHeight;let i=Math.max(Math.hypot(n[0],n[1]),1),s=Math.max(Math.hypot(n[2],n[3]),1),o=r,l=a,u="prescale1",p,f;for(;i>2&&o>1||s>2&&l>1;){let m=o,g=l;i>2&&o>1&&(m=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),i/=o/m),s>2&&l>1&&(g=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,s/=l/g),p=this.cachedCanvases.getCanvas(u,m,g),f=p.context,f.clearRect(0,0,m,g),f.drawImage(e,0,0,o,l,0,0,m,g),e=p.canvas,o=m,l=g,u=u==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:o,paintHeight:l}}_createMaskCanvas(e,n){var U,H;const r=this.ctx,{width:a,height:i}=n,s=this.current.fillColor,o=this.current.patternFill,l=Nr(r);let u,p,f,m;if((n.bitmap||n.data)&&n.count>1){const W=n.bitmap||n.data.buffer;p=JSON.stringify(o?l:[l.slice(0,4),s]),u=this._cachedBitmapsMap.get(W),u||(u=new Map,this._cachedBitmapsMap.set(W,u));const Z=u.get(p);if(Z&&!o){const F=Math.round(Math.min(l[0],l[2])+l[4]),j=Math.round(Math.min(l[1],l[3])+l[5]);return(U=this.dependencyTracker)==null||U.recordDependencies(e,Us.transformAndFill),{canvas:Z,offsetX:F,offsetY:j}}f=Z}f||(m=this.cachedCanvases.getCanvas("maskCanvas",a,i),nae(m.context,n));let g=Je.transform(l,[1/a,0,0,-1/i,0,0]);g=Je.transform(g,[1,0,0,1,0,-i]);const S=Xh.slice();Je.axialAlignedBoundingBox([0,0,a,i],g,S);const[E,y,v,A]=S,T=Math.round(v-E)||1,w=Math.round(A-y)||1,O=this.cachedCanvases.getCanvas("fillCanvas",T,w),R=O.context,I=E,L=y;R.translate(-I,-L),R.transform(...g),f||(f=this._scaleImage(m.canvas,bl(R)),f=f.img,u&&o&&u.set(p,f)),R.imageSmoothingEnabled=rae(Nr(R),n.interpolate),DA(R,f,0,0,f.width,f.height,0,0,a,i),R.globalCompositeOperation="source-in";const P=Je.transform(bl(R),[1,0,0,1,-I,-L]);return R.fillStyle=o?s.getPattern(r,this,P,Da.FILL,e):s,R.fillRect(0,0,a,i),u&&!o&&(this.cachedCanvases.delete("fillCanvas"),u.set(p,O.canvas)),(H=this.dependencyTracker)==null||H.recordDependencies(e,Us.transformAndFill),{canvas:O.canvas,offsetX:Math.round(I),offsetY:Math.round(L)}}setLineWidth(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("lineWidth",e),n!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=n,this.ctx.lineWidth=n}setLineCap(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("lineCap",e),this.ctx.lineCap=$Ue[n]}setLineJoin(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("lineJoin",e),this.ctx.lineJoin=YUe[n]}setMiterLimit(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("miterLimit",e),this.ctx.miterLimit=n}setDash(e,n,r){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("dash",e);const a=this.ctx;a.setLineDash!==void 0&&(a.setLineDash(n),a.lineDashOffset=r)}setRenderingIntent(e,n){}setFlatness(e,n){}setGState(e,n){var r,a,i,s,o;for(const[l,u]of n)switch(l){case"LW":this.setLineWidth(e,u);break;case"LC":this.setLineCap(e,u);break;case"LJ":this.setLineJoin(e,u);break;case"ML":this.setMiterLimit(e,u);break;case"D":this.setDash(e,u[0],u[1]);break;case"RI":this.setRenderingIntent(e,u);break;case"FL":this.setFlatness(e,u);break;case"Font":this.setFont(e,u[0],u[1]);break;case"CA":(r=this.dependencyTracker)==null||r.recordSimpleData("strokeAlpha",e),this.current.strokeAlpha=u;break;case"ca":(a=this.dependencyTracker)==null||a.recordSimpleData("fillAlpha",e),this.ctx.globalAlpha=this.current.fillAlpha=u;break;case"BM":(i=this.dependencyTracker)==null||i.recordSimpleData("globalCompositeOperation",e),this.ctx.globalCompositeOperation=u;break;case"SMask":(s=this.dependencyTracker)==null||s.recordSimpleData("SMask",e),this.current.activeSMask=u?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",e),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(u);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(e){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(a,n,r);this.suspendedCtx=this.ctx;const s=this.ctx=i.context;s.setTransform(this.suspendedCtx.getTransform()),H0(this.suspendedCtx,s),qUe(s,this.suspendedCtx),this.setGState(e,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),H0(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const n=this.current.activeSMask,r=this.suspendedCtx;this.composeSMask(r,n,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,n,r,a){const i=a[0],s=a[1],o=a[2]-i,l=a[3]-s;o===0||l===0||(this.genericComposeSMask(n.context,r,o,l,n.subtype,n.backdrop,n.transferMap,i,s,n.offsetX,n.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(r.canvas,0,0),e.restore())}genericComposeSMask(e,n,r,a,i,s,o,l,u,p,f){let m=e.canvas,g=l-p,S=u-f;if(s)if(g<0||S<0||g+r>m.width||S+a>m.height){const y=this.cachedCanvases.getCanvas("maskExtension",r,a),v=y.context;v.drawImage(m,-g,-S),v.globalCompositeOperation="destination-atop",v.fillStyle=s,v.fillRect(0,0,r,a),v.globalCompositeOperation="source-over",m=y.canvas,g=S=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const y=new Path2D;y.rect(g,S,r,a),e.clip(y),e.globalCompositeOperation="destination-atop",e.fillStyle=s,e.fillRect(g,S,r,a),e.restore()}n.save(),n.globalAlpha=1,n.setTransform(1,0,0,1,0,0),i==="Alpha"&&o?n.filter=this.filterFactory.addAlphaFilter(o):i==="Luminosity"&&(n.filter=this.filterFactory.addLuminosityFilter(o));const E=new Path2D;E.rect(l,u,r,a),n.clip(E),n.globalCompositeOperation="destination-in",n.drawImage(m,g,S,r,a,l,u,r,a),n.restore()}save(e){var r;this.inSMaskMode&&H0(this.ctx,this.suspendedCtx),this.ctx.save();const n=this.current;this.stateStack.push(n),this.current=n.clone(),(r=this.dependencyTracker)==null||r.save(e)}restore(e){var n;if((n=this.dependencyTracker)==null||n.restore(e),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&H0(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(e,n,r,a,i,s,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",e),this.ctx.transform(n,r,a,i,s,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,n,r,a){let[i]=r;if(!a){i||(i=r[0]=new Path2D),this[n](e,i);return}if(this.dependencyTracker!==null){const s=n===Vh.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,a[0]-s,a[2]+s,a[1]-s,a[3]+s).recordDependencies(e,["transform"])}if(!(i instanceof Path2D)){const s=r[0]=new Path2D;for(let o=0,l=i.length;o<l;)switch(i[o++]){case bA.moveTo:s.moveTo(i[o++],i[o++]);break;case bA.lineTo:s.lineTo(i[o++],i[o++]);break;case bA.curveTo:s.bezierCurveTo(i[o++],i[o++],i[o++],i[o++],i[o++],i[o++]);break;case bA.closePath:s.closePath();break;default:It(`Unrecognized drawing path operator: ${i[o-1]}`);break}i=s}Je.axialAlignedBoundingBox(a,Nr(this.ctx),this.current.minMax),this[n](e,i),this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,n,r=!0){var s;const a=this.ctx,i=this.current.strokeColor;if(a.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof i=="object"&&(i!=null&&i.getPattern)){const o=i.isModifyingCurrentTransform()?a.getTransform():null;if(a.save(),a.strokeStyle=i.getPattern(a,this,bl(a),Da.STROKE,e),o){const l=new Path2D;l.addPath(n,a.getTransform().invertSelf().multiplySelf(o)),n=l}this.rescaleAndStroke(n,!1),a.restore()}else this.rescaleAndStroke(n,!0);(s=this.dependencyTracker)==null||s.recordDependencies(e,Us.stroke),r&&this.consumePath(e,n,this.current.getClippedPathBoundingBox(Da.STROKE,Nr(this.ctx))),a.globalAlpha=this.current.fillAlpha}closeStroke(e,n){this.stroke(e,n)}fill(e,n,r=!0){var u,p,f;const a=this.ctx,i=this.current.fillColor,s=this.current.patternFill;let o=!1;if(s){const m=i.isModifyingCurrentTransform()?a.getTransform():null;if((u=this.dependencyTracker)==null||u.save(e),a.save(),a.fillStyle=i.getPattern(a,this,bl(a),Da.FILL,e),m){const g=new Path2D;g.addPath(n,a.getTransform().invertSelf().multiplySelf(m)),n=g}o=!0}const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(a.fill(n,"evenodd"),this.pendingEOFill=!1):a.fill(n)),(p=this.dependencyTracker)==null||p.recordDependencies(e,Us.fill),o&&(a.restore(),(f=this.dependencyTracker)==null||f.restore(e)),r&&this.consumePath(e,n,l)}eoFill(e,n){this.pendingEOFill=!0,this.fill(e,n)}fillStroke(e,n){this.fill(e,n,!1),this.stroke(e,n,!1),this.consumePath(e,n)}eoFillStroke(e,n){this.pendingEOFill=!0,this.fillStroke(e,n)}closeFillStroke(e,n){this.fillStroke(e,n)}closeEOFillStroke(e,n){this.pendingEOFill=!0,this.fillStroke(e,n)}endPath(e,n){this.consumePath(e,n)}rawFillPath(e,n){var r;this.ctx.fill(n),(r=this.dependencyTracker)==null||r.recordDependencies(e,Us.rawFillPath).recordOperation(e)}clip(e){var n;(n=this.dependencyTracker)==null||n.recordFutureForcedDependency("clipMode",e),this.pendingClip=VUe}eoClip(e){var n;(n=this.dependencyTracker)==null||n.recordFutureForcedDependency("clipMode",e),this.pendingClip=aae}beginText(e){var n;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(n=this.dependencyTracker)==null||n.recordOpenMarker(e).resetIncrementalData("sameLineText").resetIncrementalData("moveText",e)}endText(e){const n=this.pendingTextPaths,r=this.ctx;if(this.dependencyTracker){const{dependencyTracker:a}=this;n!==void 0&&a.recordFutureForcedDependency("textClip",a.getOpenMarker()).recordFutureForcedDependency("textClip",e),a.recordCloseMarker(e)}if(n!==void 0){const a=new Path2D,i=r.getTransform().invertSelf();for(const{transform:s,x:o,y:l,fontSize:u,path:p}of n)p&&a.addPath(p,new DOMMatrix(s).preMultiplySelf(i).translate(o,l).scale(u,-u));r.clip(a)}delete this.pendingTextPaths}setCharSpacing(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("charSpacing",e),this.current.charSpacing=n}setWordSpacing(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("wordSpacing",e),this.current.wordSpacing=n}setHScale(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("hScale",e),this.current.textHScale=n/100}setLeading(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("leading",e),this.current.leading=-n}setFont(e,n,r){var f,m;(f=this.dependencyTracker)==null||f.recordSimpleData("font",e).recordSimpleDataFromNamed("fontObj",n,e);const a=this.commonObjs.get(n),i=this.current;if(!a)throw new Error(`Can't find font for ${n}`);if(i.fontMatrix=a.fontMatrix||q3,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&It("Invalid font matrix for font "+n),r<0?(r=-r,i.fontDirection=-1):i.fontDirection=1,this.current.font=a,this.current.fontSize=r,a.isType3Font)return;const s=a.loadedName||"sans-serif",o=((m=a.systemFontInfo)==null?void 0:m.css)||`"${s}", ${a.fallbackName}`;let l="normal";a.black?l="900":a.bold&&(l="bold");const u=a.italic?"italic":"normal";let p=r;r<Qre?p=Qre:r>Zre&&(p=Zre),this.current.fontSizeScale=r/p,this.ctx.font=`${u} ${l} ${p}px ${o}`}setTextRenderingMode(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("textRenderingMode",e),this.current.textRenderingMode=n}setTextRise(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("textRise",e),this.current.textRise=n}moveText(e,n,r){var a;(a=this.dependencyTracker)==null||a.resetIncrementalData("sameLineText").recordIncrementalData("moveText",e),this.current.x=this.current.lineX+=n,this.current.y=this.current.lineY+=r}setLeadingMoveText(e,n,r){this.setLeading(e,-r),this.moveText(e,n,r)}setTextMatrix(e,n){var a;(a=this.dependencyTracker)==null||a.recordSimpleData("textMatrix",e);const{current:r}=this;r.textMatrix=n,r.textMatrixScale=Math.hypot(n[0],n[1]),r.x=r.lineX=0,r.y=r.lineY=0}nextLine(e){var n;this.moveText(e,0,this.current.leading),(n=this.dependencyTracker)==null||n.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??e)}paintChar(e,n,r,a,i,s){var v,A,T,w;const o=this.ctx,l=this.current,u=l.font,p=l.textRenderingMode,f=l.fontSize/l.fontSizeScale,m=p&Ia.FILL_STROKE_MASK,g=!!(p&Ia.ADD_TO_PATH_FLAG),S=l.patternFill&&!u.missingFile,E=l.patternStroke&&!u.missingFile;let y;if((u.disableFontFace||g||S||E)&&!u.missingFile&&(y=u.getPathGenerator(this.commonObjs,n)),y&&(u.disableFontFace||S||E)){o.save(),o.translate(r,a),o.scale(f,-f),(v=this.dependencyTracker)==null||v.recordCharacterBBox(e,o,u);let O;if(m===Ia.FILL||m===Ia.FILL_STROKE)if(i){O=o.getTransform(),o.setTransform(...i);const R=K(this,Fo,c6).call(this,y,O,i);o.fill(R)}else o.fill(y);if(m===Ia.STROKE||m===Ia.FILL_STROKE)if(s){O||(O=o.getTransform()),o.setTransform(...s);const{a:R,b:I,c:L,d:P}=O,U=Je.inverseTransform(s),H=Je.transform([R,I,L,P,0,0],U);Je.singularValueDecompose2dScale(H,is),o.lineWidth*=Math.max(is[0],is[1])/f,o.stroke(K(this,Fo,c6).call(this,y,O,s))}else o.lineWidth/=f,o.stroke(y);o.restore()}else(m===Ia.FILL||m===Ia.FILL_STROKE)&&(o.fillText(n,r,a),(A=this.dependencyTracker)==null||A.recordCharacterBBox(e,o,u,f,r,a,()=>o.measureText(n))),(m===Ia.STROKE||m===Ia.FILL_STROKE)&&(this.dependencyTracker&&((T=this.dependencyTracker)==null||T.recordCharacterBBox(e,o,u,f,r,a,()=>o.measureText(n)).recordDependencies(e,Us.stroke)),o.strokeText(n,r,a));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Nr(o),x:r,y:a,fontSize:f,path:y}),(w=this.dependencyTracker)==null||w.recordCharacterBBox(e,o,u,f,r,a))}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const n=e.getImageData(0,0,10,10).data;let r=!1;for(let a=3;a<n.length;a+=4)if(n[a]>0&&n[a]<255){r=!0;break}return qt(this,"isFontSubpixelAAEnabled",r)}showText(e,n){var L,P,U,H;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(e,Us.showText).resetBBox(e),this.current.textRenderingMode&Ia.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",e).inheritPendingDependenciesAsFutureForcedDependencies());const r=this.current,a=r.font;if(a.isType3Font){this.showType3Text(e,n),(L=this.dependencyTracker)==null||L.recordShowTextOperation(e);return}const i=r.fontSize;if(i===0){(P=this.dependencyTracker)==null||P.recordOperation(e);return}const s=this.ctx,o=r.fontSizeScale,l=r.charSpacing,u=r.wordSpacing,p=r.fontDirection,f=r.textHScale*p,m=n.length,g=a.vertical,S=g?1:-1,E=a.defaultVMetrics,y=i*r.fontMatrix[0],v=r.textRenderingMode===Ia.FILL&&!a.disableFontFace&&!r.patternFill;s.save(),r.textMatrix&&s.transform(...r.textMatrix),s.translate(r.x,r.y+r.textRise),p>0?s.scale(f,-1):s.scale(f,1);let A,T;if(r.patternFill){s.save();const W=r.fillColor.getPattern(s,this,bl(s),Da.FILL,e);A=Nr(s),s.restore(),s.fillStyle=W}if(r.patternStroke){s.save();const W=r.strokeColor.getPattern(s,this,bl(s),Da.STROKE,e);T=Nr(s),s.restore(),s.strokeStyle=W}let w=r.lineWidth;const O=r.textMatrixScale;if(O===0||w===0){const W=r.textRenderingMode&Ia.FILL_STROKE_MASK;(W===Ia.STROKE||W===Ia.FILL_STROKE)&&(w=this.getSinglePixelWidth())}else w/=O;if(o!==1&&(s.scale(o,o),w/=o),s.lineWidth=w,a.isInvalidPDFjsFont){const W=[];let Z=0;for(const j of n)W.push(j.unicode),Z+=j.width;const F=W.join("");if(s.fillText(F,0,0),this.dependencyTracker!==null){const j=s.measureText(F);this.dependencyTracker.recordBBox(e,this.ctx,-j.actualBoundingBoxLeft,j.actualBoundingBoxRight,-j.actualBoundingBoxAscent,j.actualBoundingBoxDescent).recordShowTextOperation(e)}r.x+=Z*y*f,s.restore(),this.compose();return}let R=0,I;for(I=0;I<m;++I){const W=n[I];if(typeof W=="number"){R+=S*W*i/1e3;continue}let Z=!1;const F=(W.isSpace?u:0)+l,j=W.fontChar,z=W.accent;let V,X,te=W.width;if(g){const ee=W.vmetric||E,B=-(W.vmetric?ee[1]:te*.5)*y,ie=ee[2]*y;te=ee?-ee[0]:te,V=B/o,X=(R+ie)/o}else V=R/o,X=0;let $;if(a.remeasure&&te>0){$=s.measureText(j);const ee=$.width*1e3/i*o;if(te<ee&&this.isFontSubpixelAAEnabled){const B=te/ee;Z=!0,s.save(),s.scale(B,1),V/=B}else te!==ee&&(V+=(te-ee)/2e3*i/o)}if(this.contentVisible&&(W.isInFont||a.missingFile)){if(v&&!z)s.fillText(j,V,X),(U=this.dependencyTracker)==null||U.recordCharacterBBox(e,s,$?{bbox:null}:a,i/o,V,X,()=>$??s.measureText(j));else if(this.paintChar(e,j,V,X,A,T),z){const ee=V+i*z.offset.x/o,B=X-i*z.offset.y/o;this.paintChar(e,z.fontChar,ee,B,A,T)}}const Q=g?te*y-F*p:te*y+F*p;R+=Q,Z&&s.restore()}g?r.y-=R:r.x+=R*f,s.restore(),this.compose(),(H=this.dependencyTracker)==null||H.recordShowTextOperation(e)}showType3Text(e,n){const r=this.ctx,a=this.current,i=a.font,s=a.fontSize,o=a.fontDirection,l=i.vertical?1:-1,u=a.charSpacing,p=a.wordSpacing,f=a.textHScale*o,m=a.fontMatrix||q3,g=n.length,S=a.textRenderingMode===Ia.INVISIBLE;let E,y,v,A;if(S||s===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,r.save(),a.textMatrix&&r.transform(...a.textMatrix),r.translate(a.x,a.y+a.textRise),r.scale(f,o);const T=this.dependencyTracker;for(this.dependencyTracker=T?new IA(T,e):null,E=0;E<g;++E){if(y=n[E],typeof y=="number"){A=l*y*s/1e3,this.ctx.translate(A,0),a.x+=A*f;continue}const w=(y.isSpace?p:0)+u,O=i.charProcOperatorList[y.operatorListId];O?this.contentVisible&&(this.save(),r.scale(s,s),r.transform(...m),this.executeOperatorList(O),this.restore()):It(`Type3 character "${y.operatorListId}" is not available.`);const R=[y.width,0];Je.applyTransform(R,m),v=R[0]*s+w,r.translate(v,0),a.x+=v*f}r.restore(),T&&(this.dependencyTracker=T)}setCharWidth(e,n,r){}setCharWidthAndBounds(e,n,r,a,i,s,o){var u;const l=new Path2D;l.rect(a,i,s-a,o-i),this.ctx.clip(l),(u=this.dependencyTracker)==null||u.recordBBox(e,this.ctx,a,s,i,o).recordClipBox(e,this.ctx,a,s,i,o),this.endPath(e)}getColorN_Pattern(e,n){let r;if(n[0]==="TilingPattern"){const a=this.baseTransform||Nr(this.ctx),i={createCanvasGraphics:(s,o)=>new UF(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new IA(this.dependencyTracker,o,!0):null)};r=new dF(n,this.ctx,i,a)}else r=this._getPattern(e,n[1],n[2]);return r}setStrokeColorN(e,...n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("strokeColor",e),this.current.strokeColor=this.getColorN_Pattern(e,n),this.current.patternStroke=!0}setFillColorN(e,...n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("fillColor",e),this.current.fillColor=this.getColorN_Pattern(e,n),this.current.patternFill=!0}setStrokeRGBColor(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("strokeColor",e),this.ctx.strokeStyle=this.current.strokeColor=n,this.current.patternStroke=!1}setStrokeTransparent(e){var n;(n=this.dependencyTracker)==null||n.recordSimpleData("strokeColor",e),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("fillColor",e),this.ctx.fillStyle=this.current.fillColor=n,this.current.patternFill=!1}setFillTransparent(e){var n;(n=this.dependencyTracker)==null||n.recordSimpleData("fillColor",e),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,n,r=null){let a;return this.cachedPatterns.has(n)?a=this.cachedPatterns.get(n):(a=UUe(this.getObject(e,n)),this.cachedPatterns.set(n,a)),r&&(a.matrix=r),a}shadingFill(e,n){var s;if(!this.contentVisible)return;const r=this.ctx;this.save(e);const a=this._getPattern(e,n);r.fillStyle=a.getPattern(r,this,bl(r),Da.SHADING,e);const i=bl(r);if(i){const{width:o,height:l}=r.canvas,u=Xh.slice();Je.axialAlignedBoundingBox([0,0,o,l],i,u);const[p,f,m,g]=u;this.ctx.fillRect(p,f,m-p,g-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(s=this.dependencyTracker)==null||s.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,Us.transform).recordDependencies(e,Us.fill).recordOperation(e),this.compose(this.current.getClippedPathBoundingBox()),this.restore(e)}beginInlineImage(){Qn("Should not call beginInlineImage")}beginImageData(){Qn("Should not call beginImageData")}paintFormXObjectBegin(e,n,r){var a;if(this.contentVisible&&(this.save(e),this.baseTransformStack.push(this.baseTransform),n&&this.transform(e,...n),this.baseTransform=Nr(this.ctx),r)){Je.axialAlignedBoundingBox(r,this.baseTransform,this.current.minMax);const[i,s,o,l]=r,u=new Path2D;u.rect(i,s,o-i,l-s),this.ctx.clip(u),(a=this.dependencyTracker)==null||a.recordClipBox(e,this.ctx,i,o,s,l),this.endPath(e)}}paintFormXObjectEnd(e){this.contentVisible&&(this.restore(e),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e,n){var T;if(!this.contentVisible)return;this.save(e),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const r=this.ctx;n.isolated||SA("TODO: Support non-isolated groups."),n.knockout&&It("Knockout groups not supported.");const a=Nr(r);if(n.matrix&&r.transform(...n.matrix),!n.bbox)throw new Error("Bounding box is required.");let i=Xh.slice();Je.axialAlignedBoundingBox(n.bbox,Nr(r),i);const s=[0,0,r.canvas.width,r.canvas.height];i=Je.intersect(i,s)||[0,0,0,0];const o=Math.floor(i[0]),l=Math.floor(i[1]),u=Math.max(Math.ceil(i[2])-o,1),p=Math.max(Math.ceil(i[3])-l,1);this.current.startNewPathAndClipBox([0,0,u,p]);let f="groupAt"+this.groupLevel;n.smask&&(f+="_smask_"+this.smaskCounter++%2);const m=this.cachedCanvases.getCanvas(f,u,p),g=m.context;g.translate(-o,-l),g.transform(...a);let S=new Path2D;const[E,y,v,A]=n.bbox;if(S.rect(E,y,v-E,A-y),n.matrix){const w=new Path2D;w.addPath(S,new DOMMatrix(n.matrix)),S=w}g.clip(S),n.smask&&this.smaskStack.push({canvas:m.canvas,context:g,offsetX:o,offsetY:l,subtype:n.smask.subtype,backdrop:n.smask.backdrop,transferMap:n.smask.transferMap||null,startTransformInverse:null}),(!n.smask||this.dependencyTracker)&&(r.setTransform(1,0,0,1,0,0),r.translate(o,l),r.save()),H0(r,g),this.ctx=g,(T=this.dependencyTracker)==null||T.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(r),this.setGState(e,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(r),this.groupLevel++}endGroup(e,n){var i;if(!this.contentVisible)return;this.groupLevel--;const r=this.ctx,a=this.groupStack.pop();if(this.ctx=a,this.ctx.imageSmoothingEnabled=!1,(i=this.dependencyTracker)==null||i.popBaseTransform(),n.smask)this.tempSMask=this.smaskStack.pop(),this.restore(e),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const s=Nr(this.ctx);this.restore(e),this.ctx.save(),this.ctx.setTransform(...s);const o=Xh.slice();Je.axialAlignedBoundingBox([0,0,r.canvas.width,r.canvas.height],s,o),this.ctx.drawImage(r.canvas,0,0),this.ctx.restore(),this.compose(o)}}beginAnnotation(e,n,r,a,i,s){if(K(this,Fo,o6).call(this),kA(this.ctx),this.ctx.save(),this.save(e),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),r){const o=r[2]-r[0],l=r[3]-r[1];if(s&&this.annotationCanvasMap){a=a.slice(),a[4]-=r[0],a[5]-=r[1],r=r.slice(),r[0]=r[1]=0,r[2]=o,r[3]=l,Je.singularValueDecompose2dScale(Nr(this.ctx),is);const{viewportScale:u}=this,p=Math.ceil(o*this.outputScaleX*u),f=Math.ceil(l*this.outputScaleY*u);this.annotationCanvas=this.canvasFactory.create(p,f);const{canvas:m,context:g}=this.annotationCanvas;this.annotationCanvasMap.set(n,m),this.annotationCanvas.savedCtx=this.ctx,this.ctx=g,this.ctx.save(),this.ctx.setTransform(is[0],0,0,-is[1],0,l*is[1]),kA(this.ctx)}else{kA(this.ctx),this.endPath(e);const u=new Path2D;u.rect(r[0],r[1],o,l),this.ctx.clip(u)}}this.current=new eae(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(e,...a),this.transform(e,...i)}endAnnotation(e){this.annotationCanvas&&(this.ctx.restore(),K(this,Fo,l6).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e,n){var o;if(!this.contentVisible)return;const r=n.count;n=this.getObject(e,n.data,n),n.count=r;const a=this.ctx,i=this._createMaskCanvas(e,n),s=i.canvas;a.save(),a.setTransform(1,0,0,1,0,0),a.drawImage(s,i.offsetX,i.offsetY),(o=this.dependencyTracker)==null||o.resetBBox(e).recordBBox(e,this.ctx,i.offsetX,i.offsetX+s.width,i.offsetY,i.offsetY+s.height).recordOperation(e),a.restore(),this.compose()}paintImageMaskXObjectRepeat(e,n,r,a=0,i=0,s,o){var f,m,g;if(!this.contentVisible)return;n=this.getObject(e,n.data,n);const l=this.ctx;l.save();const u=Nr(l);l.transform(r,a,i,s,0,0);const p=this._createMaskCanvas(e,n);l.setTransform(1,0,0,1,p.offsetX-u[4],p.offsetY-u[5]),(f=this.dependencyTracker)==null||f.resetBBox(e);for(let S=0,E=o.length;S<E;S+=2){const y=Je.transform(u,[r,a,i,s,o[S],o[S+1]]);l.drawImage(p.canvas,y[4],y[5]),(m=this.dependencyTracker)==null||m.recordBBox(e,this.ctx,y[4],y[4]+p.canvas.width,y[5],y[5]+p.canvas.height)}l.restore(),this.compose(),(g=this.dependencyTracker)==null||g.recordOperation(e)}paintImageMaskXObjectGroup(e,n){var s,o,l;if(!this.contentVisible)return;const r=this.ctx,a=this.current.fillColor,i=this.current.patternFill;(s=this.dependencyTracker)==null||s.resetBBox(e).recordDependencies(e,Us.transformAndFill);for(const u of n){const{data:p,width:f,height:m,transform:g}=u,S=this.cachedCanvases.getCanvas("maskCanvas",f,m),E=S.context;E.save();const y=this.getObject(e,p,u);nae(E,y),E.globalCompositeOperation="source-in",E.fillStyle=i?a.getPattern(E,this,bl(r),Da.FILL,e):a,E.fillRect(0,0,f,m),E.restore(),r.save(),r.transform(...g),r.scale(1,-1),DA(r,S.canvas,0,0,f,m,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(e,r,0,f,0,m),r.restore()}this.compose(),(l=this.dependencyTracker)==null||l.recordOperation(e)}paintImageXObject(e,n){if(!this.contentVisible)return;const r=this.getObject(e,n);if(!r){It("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e,r)}paintImageXObjectRepeat(e,n,r,a,i){if(!this.contentVisible)return;const s=this.getObject(e,n);if(!s){It("Dependent image isn't ready yet");return}const o=s.width,l=s.height,u=[];for(let p=0,f=i.length;p<f;p+=2)u.push({transform:[r,0,0,a,i[p],i[p+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(e,s,u)}applyTransferMapsToCanvas(e){return this.current.transferMaps!=="none"&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps==="none")return e.bitmap;const{bitmap:n,width:r,height:a}=e,i=this.cachedCanvases.getCanvas("inlineImage",r,a),s=i.context;return s.filter=this.current.transferMaps,s.drawImage(n,0,0),s.filter="none",i.canvas}paintInlineImageXObject(e,n){var u;if(!this.contentVisible)return;const r=n.width,a=n.height,i=this.ctx;this.save(e);const{filter:s}=i;s!=="none"&&s!==""&&(i.filter="none"),i.scale(1/r,-1/a);let o;if(n.bitmap)o=this.applyTransferMapsToBitmap(n);else if(typeof HTMLElement=="function"&&n instanceof HTMLElement||!n.data)o=n;else{const f=this.cachedCanvases.getCanvas("inlineImage",r,a).context;tae(f,n),o=this.applyTransferMapsToCanvas(f)}const l=this._scaleImage(o,bl(i));i.imageSmoothingEnabled=rae(Nr(i),n.interpolate),(u=this.dependencyTracker)==null||u.resetBBox(e).recordBBox(e,i,0,r,-a,0).recordDependencies(e,Us.imageXObject).recordOperation(e),DA(i,l.img,0,0,l.paintWidth,l.paintHeight,0,-a,r,a),this.compose(),this.restore(e)}paintInlineImageXObjectGroup(e,n,r){var s,o,l;if(!this.contentVisible)return;const a=this.ctx;let i;if(n.bitmap)i=n.bitmap;else{const u=n.width,p=n.height,m=this.cachedCanvases.getCanvas("inlineImage",u,p).context;tae(m,n),i=this.applyTransferMapsToCanvas(m)}(s=this.dependencyTracker)==null||s.resetBBox(e);for(const u of r)a.save(),a.transform(...u.transform),a.scale(1,-1),DA(a,i,u.x,u.y,u.w,u.h,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(e,a,0,1,-1,0),a.restore();(l=this.dependencyTracker)==null||l.recordOperation(e),this.compose()}paintSolidColorImageMask(e){var n;this.contentVisible&&((n=this.dependencyTracker)==null||n.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,Us.fill).recordOperation(e),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e,n){}markPointProps(e,n,r){}beginMarkedContent(e,n){var r;(r=this.dependencyTracker)==null||r.beginMarkedContent(e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,n,r){var a;(a=this.dependencyTracker)==null||a.beginMarkedContent(e),n==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(r)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(e){var n;(n=this.dependencyTracker)==null||n.endMarkedContent(e),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(e){}endCompat(e){}consumePath(e,n,r){var s,o;const a=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(r);const i=this.ctx;this.pendingClip?(a||(this.pendingClip===aae?i.clip(n,"evenodd"):i.clip(n)),this.pendingClip=null,(s=this.dependencyTracker)==null||s.bboxToClipBoxDropOperation(e).recordFutureForcedDependency("clipPath",e)):(o=this.dependencyTracker)==null||o.recordOperation(e),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=Nr(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const n=Math.abs(e[0]*e[3]-e[2]*e[1]),r=Math.hypot(e[0],e[2]),a=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(r,a)/n}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:e}=this.current,{a:n,b:r,c:a,d:i}=this.ctx.getTransform();let s,o;if(r===0&&a===0){const l=Math.abs(n),u=Math.abs(i);if(l===u)if(e===0)s=o=1/l;else{const p=l*e;s=o=p<1?1/p:1}else if(e===0)s=1/l,o=1/u;else{const p=l*e,f=u*e;s=p<1?1/p:1,o=f<1?1/f:1}}else{const l=Math.abs(n*i-r*a),u=Math.hypot(n,r),p=Math.hypot(a,i);if(e===0)s=p/l,o=u/l;else{const f=e*l;s=p>f?p/f:1,o=u>f?u/f:1}}this._cachedScaleForStroking[0]=s,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e,n){const{ctx:r,current:{lineWidth:a}}=this,[i,s]=this.getScaleForStroking();if(i===s){r.lineWidth=(a||1)*i,r.stroke(e);return}const o=r.getLineDash();n&&r.save(),r.scale(i,s),pF.a=1/i,pF.d=1/s;const l=new Path2D;if(l.addPath(e,pF),o.length>0){const u=Math.max(i,s);r.setLineDash(o.map(p=>p/u)),r.lineDashOffset/=u}r.lineWidth=a||1,r.stroke(l),n&&r.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};Fo=new WeakSet,o6=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},l6=function(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){const n=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=n}}},c6=function(e,n,r){const a=new Path2D;return a.addPath(e,new DOMMatrix(r).invertSelf().multiplySelf(n)),a};let Qh=UF;for(const t in Vh)Qh.prototype[t]!==void 0&&(Qh.prototype[Vh[t]]=Qh.prototype[t]);const Mg=class Mg{constructor(e){Y(this,kg);Y(this,Ig);Y(this,Dg);Y(this,IE);M(this,Ig,e),M(this,Dg,new DataView(_(this,Ig))),M(this,IE,new TextDecoder)}static write(e){const n=new TextEncoder,r={};let a=0;for(const u of Mg.strings){const p=n.encode(e[u]);r[u]=p,a+=4+p.length}const i=new ArrayBuffer(a),s=new Uint8Array(i),o=new DataView(i);let l=0;for(const u of Mg.strings){const p=r[u],f=p.length;o.setUint32(l,f),s.set(p,l+4),l+=4+f}return on(l===i.byteLength,"CssFontInfo.write: Buffer overflow"),i}get fontFamily(){return K(this,kg,OR).call(this,0)}get fontWeight(){return K(this,kg,OR).call(this,1)}get italicAngle(){return K(this,kg,OR).call(this,2)}};Ig=new WeakMap,Dg=new WeakMap,IE=new WeakMap,kg=new WeakSet,OR=function(e){on(e<Mg.strings.length,"Invalid string index");let n=0;for(let a=0;a<e;a++)n+=_(this,Dg).getUint32(n)+4;const r=_(this,Dg).getUint32(n);return _(this,IE).decode(new Uint8Array(_(this,Ig),n+4,r))},Pe(Mg,"strings",["fontFamily","fontWeight","italicAngle"]);let MA=Mg;const Lg=class Lg{constructor(e){Y(this,Gf);Y(this,xd);Y(this,Dl);Y(this,Uf);M(this,xd,e),M(this,Dl,new DataView(_(this,xd))),M(this,Uf,new TextDecoder)}static write(e){const n=new TextEncoder,r={};let a=0;for(const m of Lg.strings){const g=n.encode(e[m]);r[m]=g,a+=4+g.length}a+=4;let i,s,o=1+a;e.style&&(i=n.encode(e.style.style),s=n.encode(e.style.weight),o+=4+i.length+4+s.length);const l=new ArrayBuffer(o),u=new Uint8Array(l),p=new DataView(l);let f=0;p.setUint8(f++,e.guessFallback?1:0),p.setUint32(f,0),f+=4,a=0;for(const m of Lg.strings){const g=r[m],S=g.length;a+=4+S,p.setUint32(f,S),u.set(g,f+4),f+=4+S}return p.setUint32(f-a-4,a),e.style&&(p.setUint32(f,i.length),u.set(i,f+4),f+=4+i.length,p.setUint32(f,s.length),u.set(s,f+4),f+=4+s.length),on(f<=l.byteLength,"SubstitionInfo.write: Buffer overflow"),l.transferToFixedLength(f)}get guessFallback(){return _(this,Dl).getUint8(0)!==0}get css(){return K(this,Gf,Iy).call(this,0)}get loadedName(){return K(this,Gf,Iy).call(this,1)}get baseFontName(){return K(this,Gf,Iy).call(this,2)}get src(){return K(this,Gf,Iy).call(this,3)}get style(){let e=1;e+=4+_(this,Dl).getUint32(e);const n=_(this,Dl).getUint32(e),r=_(this,Uf).decode(new Uint8Array(_(this,xd),e+4,n));e+=4+n;const a=_(this,Dl).getUint32(e),i=_(this,Uf).decode(new Uint8Array(_(this,xd),e+4,a));return{style:r,weight:i}}};xd=new WeakMap,Dl=new WeakMap,Uf=new WeakMap,Gf=new WeakSet,Iy=function(e){on(e<Lg.strings.length,"Invalid string index");let n=5;for(let a=0;a<e;a++)n+=_(this,Dl).getUint32(n)+4;const r=_(this,Dl).getUint32(n);return _(this,Uf).decode(new Uint8Array(_(this,xd),n+4,r))},Pe(Lg,"strings",["css","loadedName","baseFontName","src"]);let LA=Lg;const Mt=class Mt{constructor({data:e,extra:n}){Y(this,Pr);Y(this,kl);Y(this,DE);Y(this,zn);M(this,kl,e),M(this,DE,new TextDecoder),M(this,zn,new DataView(_(this,kl))),n&&Object.assign(this,n)}get black(){return K(this,Pr,Zo).call(this,0)}get bold(){return K(this,Pr,Zo).call(this,1)}get disableFontFace(){return K(this,Pr,Zo).call(this,2)}get fontExtraProperties(){return K(this,Pr,Zo).call(this,3)}get isInvalidPDFjsFont(){return K(this,Pr,Zo).call(this,4)}get isType3Font(){return K(this,Pr,Zo).call(this,5)}get italic(){return K(this,Pr,Zo).call(this,6)}get missingFile(){return K(this,Pr,Zo).call(this,7)}get remeasure(){return K(this,Pr,Zo).call(this,8)}get vertical(){return K(this,Pr,Zo).call(this,9)}get ascent(){return K(this,Pr,IR).call(this,0)}get defaultWidth(){return K(this,Pr,IR).call(this,1)}get descent(){return K(this,Pr,IR).call(this,2)}get bbox(){let e=_(Mt,Fg);if(_(this,zn).getUint8(e)===0)return;e+=1;const r=[];for(let a=0;a<4;a++)r.push(_(this,zn).getInt16(e,!0)),e+=2;return r}get fontMatrix(){let e=_(Mt,Bg);if(_(this,zn).getUint8(e)===0)return;e+=1;const r=[];for(let a=0;a<6;a++)r.push(_(this,zn).getFloat64(e,!0)),e+=8;return r}get defaultVMetrics(){let e=_(Mt,Ug);if(_(this,zn).getUint8(e)===0)return;e+=1;const r=[];for(let a=0;a<3;a++)r.push(_(this,zn).getInt16(e,!0)),e+=2;return r}get fallbackName(){return K(this,Pr,Dy).call(this,0)}get loadedName(){return K(this,Pr,Dy).call(this,1)}get mimetype(){return K(this,Pr,Dy).call(this,2)}get name(){return K(this,Pr,Dy).call(this,3)}get data(){let e=_(Mt,cs);const n=_(this,zn).getUint32(e);e+=4+n;const r=_(this,zn).getUint32(e);e+=4+r;const a=_(this,zn).getUint32(e);e+=4+a;const i=_(this,zn).getUint32(e);if(i!==0)return new Uint8Array(_(this,kl),e+4,i)}clearData(){let e=_(Mt,cs);const n=_(this,zn).getUint32(e);e+=4+n;const r=_(this,zn).getUint32(e);e+=4+r;const a=_(this,zn).getUint32(e);e+=4+a;const i=_(this,zn).getUint32(e);new Uint8Array(_(this,kl),e+4,i).fill(0),_(this,zn).setUint32(e,0)}get cssFontInfo(){let e=_(Mt,cs);const n=_(this,zn).getUint32(e);e+=4+n;const r=_(this,zn).getUint32(e);e+=4+r;const a=_(this,zn).getUint32(e);if(a===0)return null;const i=new Uint8Array(a);return i.set(new Uint8Array(_(this,kl),e+4,a)),new MA(i.buffer)}get systemFontInfo(){let e=_(Mt,cs);const n=_(this,zn).getUint32(e);e+=4+n;const r=_(this,zn).getUint32(e);if(r===0)return null;const a=new Uint8Array(r);return a.set(new Uint8Array(_(this,kl),e+4,r)),new LA(a.buffer)}static write(e){const n=e.systemFontInfo?LA.write(e.systemFontInfo):null,r=e.cssFontInfo?MA.write(e.cssFontInfo):null,a=new TextEncoder,i={};let s=0;for(const E of Mt.strings)i[E]=a.encode(e[E]),s+=4+i[E].length;const o=_(Mt,cs)+4+s+4+(n?n.byteLength:0)+4+(r?r.byteLength:0)+4+(e.data?e.data.length:0),l=new ArrayBuffer(o),u=new Uint8Array(l),p=new DataView(l);let f=0;const m=Mt.bools.length;let g=0,S=0;for(let E=0;E<m;E++){const y=e[Mt.bools[E]];g|=(y===void 0?0:y?2:1)<<S,S+=2,(S===8||E===m-1)&&(p.setUint8(f++,g),g=0,S=0)}on(f===_(Mt,Pg),"FontInfo.write: Boolean properties offset mismatch");for(const E of Mt.numbers)p.setFloat64(f,e[E]),f+=8;if(on(f===_(Mt,Fg),"FontInfo.write: Number properties offset mismatch"),e.bbox){p.setUint8(f++,4);for(const E of e.bbox)p.setInt16(f,E,!0),f+=2}else p.setUint8(f++,0),f+=8;if(on(f===_(Mt,Bg),"FontInfo.write: BBox properties offset mismatch"),e.fontMatrix){p.setUint8(f++,6);for(const E of e.fontMatrix)p.setFloat64(f,E,!0),f+=8}else p.setUint8(f++,0),f+=48;if(on(f===_(Mt,Ug),"FontInfo.write: FontMatrix properties offset mismatch"),e.defaultVMetrics){p.setUint8(f++,1);for(const E of e.defaultVMetrics)p.setInt16(f,E,!0),f+=2}else p.setUint8(f++,0),f+=6;on(f===_(Mt,cs),"FontInfo.write: DefaultVMetrics properties offset mismatch"),p.setUint32(_(Mt,cs),0),f+=4;for(const E of Mt.strings){const y=i[E],v=y.length;p.setUint32(f,v),u.set(y,f+4),f+=4+v}if(p.setUint32(_(Mt,cs),f-_(Mt,cs)-4),!n)p.setUint32(f,0),f+=4;else{const E=n.byteLength;p.setUint32(f,E),on(f+4+E<=l.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),u.set(new Uint8Array(n),f+4),f+=4+E}if(!r)p.setUint32(f,0),f+=4;else{const E=r.byteLength;p.setUint32(f,E),on(f+4+E<=l.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),u.set(new Uint8Array(r),f+4),f+=4+E}return e.data===void 0?(p.setUint32(f,0),f+=4):(p.setUint32(f,e.data.length),u.set(e.data,f+4),f+=4+e.data.length),on(f<=l.byteLength,"FontInfo.write: Buffer overflow"),l.transferToFixedLength(f)}};Pg=new WeakMap,Fg=new WeakMap,Bg=new WeakMap,Ug=new WeakMap,cs=new WeakMap,kl=new WeakMap,DE=new WeakMap,zn=new WeakMap,Pr=new WeakSet,Zo=function(e){on(e<Mt.bools.length,"Invalid boolean index");const n=Math.floor(e/4),r=e*2%8,a=_(this,zn).getUint8(n)>>r&3;return a===0?void 0:a===2},IR=function(e){return on(e<Mt.numbers.length,"Invalid number index"),_(this,zn).getFloat64(_(Mt,Pg)+e*8)},Dy=function(e){on(e<Mt.strings.length,"Invalid string index");let n=_(Mt,cs)+4;for(let i=0;i<e;i++)n+=_(this,zn).getUint32(n)+4;const r=_(this,zn).getUint32(n),a=new Uint8Array(r);return a.set(new Uint8Array(_(this,kl),n+4,r)),_(this,DE).decode(a)},Pe(Mt,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),Pe(Mt,"numbers",["ascent","defaultWidth","descent"]),Pe(Mt,"strings",["fallbackName","loadedName","mimetype","name"]),Y(Mt,Pg,Math.ceil(Mt.bools.length*2/8)),Y(Mt,Fg,_(Mt,Pg)+Mt.numbers.length*8),Y(Mt,Bg,_(Mt,Fg)+1+8),Y(Mt,Ug,_(Mt,Bg)+1+48),Y(Mt,cs,_(Mt,Ug)+1+6);let fF=Mt;class Gs{static get workerPort(){return _(this,kE)}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");M(this,kE,e)}static get workerSrc(){return _(this,ME)}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");M(this,ME,e)}}kE=new WeakMap,ME=new WeakMap,Y(Gs,kE,null),Y(Gs,ME,"");class WUe{constructor({parsedData:e,rawData:n}){Y(this,Gg);Y(this,LE);M(this,Gg,e),M(this,LE,n)}getRaw(){return _(this,LE)}get(e){return _(this,Gg).get(e)??null}[Symbol.iterator](){return _(this,Gg).entries()}}Gg=new WeakMap,LE=new WeakMap;const Zh=Symbol("INTERNAL");class jUe{constructor(e,{name:n,intent:r,usage:a,rbGroups:i}){Y(this,PE,!1);Y(this,FE,!1);Y(this,BE,!1);Y(this,zg,!0);M(this,PE,!!(e&rs.DISPLAY)),M(this,FE,!!(e&rs.PRINT)),this.name=n,this.intent=r,this.usage=a,this.rbGroups=i}get visible(){if(_(this,BE))return _(this,zg);if(!_(this,zg))return!1;const{print:e,view:n}=this.usage;return _(this,PE)?(n==null?void 0:n.viewState)!=="OFF":_(this,FE)?(e==null?void 0:e.printState)!=="OFF":!0}_setVisible(e,n,r=!1){e!==Zh&&Qn("Internal method `_setVisible` called."),M(this,BE,r),M(this,zg,n)}}PE=new WeakMap,FE=new WeakMap,BE=new WeakMap,zg=new WeakMap;class KUe{constructor(e,n=rs.DISPLAY){Y(this,UE);Y(this,Od,null);Y(this,qn,new Map);Y(this,qg,null);Y(this,Hg,null);if(this.renderingIntent=n,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,M(this,Hg,e.order);for(const r of e.groups)_(this,qn).set(r.id,new jUe(n,r));if(e.baseState==="OFF")for(const r of _(this,qn).values())r._setVisible(Zh,!1);for(const r of e.on)_(this,qn).get(r)._setVisible(Zh,!0);for(const r of e.off)_(this,qn).get(r)._setVisible(Zh,!1);M(this,qg,this.getHash())}}isVisible(e){if(_(this,qn).size===0)return!0;if(!e)return SA("Optional content group not defined."),!0;if(e.type==="OCG")return _(this,qn).has(e.id)?_(this,qn).get(e.id).visible:(It(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return K(this,UE,u6).call(this,e.expression);if(!e.policy||e.policy==="AnyOn"){for(const n of e.ids){if(!_(this,qn).has(n))return It(`Optional content group not found: ${n}`),!0;if(_(this,qn).get(n).visible)return!0}return!1}else if(e.policy==="AllOn"){for(const n of e.ids){if(!_(this,qn).has(n))return It(`Optional content group not found: ${n}`),!0;if(!_(this,qn).get(n).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(const n of e.ids){if(!_(this,qn).has(n))return It(`Optional content group not found: ${n}`),!0;if(!_(this,qn).get(n).visible)return!0}return!1}else if(e.policy==="AllOff"){for(const n of e.ids){if(!_(this,qn).has(n))return It(`Optional content group not found: ${n}`),!0;if(_(this,qn).get(n).visible)return!1}return!0}return It(`Unknown optional content policy ${e.policy}.`),!0}return It(`Unknown group type ${e.type}.`),!0}setVisibility(e,n=!0,r=!0){var i;const a=_(this,qn).get(e);if(!a){It(`Optional content group not found: ${e}`);return}if(r&&n&&a.rbGroups.length)for(const s of a.rbGroups)for(const o of s)o!==e&&((i=_(this,qn).get(o))==null||i._setVisible(Zh,!1,!0));a._setVisible(Zh,!!n,!0),M(this,Od,null)}setOCGState({state:e,preserveRB:n}){let r;for(const a of e){switch(a){case"ON":case"OFF":case"Toggle":r=a;continue}const i=_(this,qn).get(a);if(i)switch(r){case"ON":this.setVisibility(a,!0,n);break;case"OFF":this.setVisibility(a,!1,n);break;case"Toggle":this.setVisibility(a,!i.visible,n);break}}M(this,Od,null)}get hasInitialVisibility(){return _(this,qg)===null||this.getHash()===_(this,qg)}getOrder(){return _(this,qn).size?_(this,Hg)?_(this,Hg).slice():[..._(this,qn).keys()]:null}getGroup(e){return _(this,qn).get(e)||null}getHash(){if(_(this,Od)!==null)return _(this,Od);const e=new Pre;for(const[n,r]of _(this,qn))e.update(`${n}:${r.visible}`);return M(this,Od,e.hexdigest())}[Symbol.iterator](){return _(this,qn).entries()}}Od=new WeakMap,qn=new WeakMap,qg=new WeakMap,Hg=new WeakMap,UE=new WeakSet,u6=function(e){const n=e.length;if(n<2)return!0;const r=e[0];for(let a=1;a<n;a++){const i=e[a];let s;if(Array.isArray(i))s=K(this,UE,u6).call(this,i);else if(_(this,qn).has(i))s=_(this,qn).get(i).visible;else return It(`Optional content group not found: ${i}`),!0;switch(r){case"And":if(!s)return!1;break;case"Or":if(s)return!0;break;case"Not":return!s;default:return!0}}return r==="And"};class XUe{constructor(e,{disableRange:n=!1,disableStream:r=!1}){on(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:a,initialData:i,progressiveDone:s,contentDispositionFilename:o}=e;if(this._queuedChunks=[],this._progressiveDone=s,this._contentDispositionFilename=o,(i==null?void 0:i.length)>0){const l=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!r,this._isRangeSupported=!n,this._contentLength=a,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((l,u)=>{this._onReceiveData({begin:l,chunk:u})}),e.addProgressListener((l,u)=>{this._onProgress({loaded:l,total:u})}),e.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:n}){const r=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;if(e===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(r):this._queuedChunks.push(r);else{const a=this._rangeReaders.some(function(i){return i._begin!==e?!1:(i._enqueue(r),!0)});on(a,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}_onProgress(e){var n,r,a,i;e.total===void 0?(r=(n=this._rangeReaders[0])==null?void 0:n.onProgress)==null||r.call(n,{loaded:e.loaded}):(i=(a=this._fullRequestReader)==null?void 0:a.onProgress)==null||i.call(a,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;(e=this._fullRequestReader)==null||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const n=this._rangeReaders.indexOf(e);n>=0&&this._rangeReaders.splice(n,1)}getFullReader(){on(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new QUe(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const r=new ZUe(this,e,n);return this._pdfDataRangeTransport.requestDataRange(e,n),this._rangeReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeReaders.slice(0))r.cancel(e);this._pdfDataRangeTransport.abort()}}class QUe{constructor(e,n,r=!1,a=null){this._stream=e,this._done=r||!1,this._filename=TA(a)?a:null,this._queuedChunks=n||[],this._loaded=0;for(const i of this._queuedChunks)this._loaded+=i.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class ZUe{constructor(e,n,r){this._stream=e,this._begin=n,this._end=r,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const n=this._queuedChunk;return this._queuedChunk=null,{value:n,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function JUe(t){let e=!0,n=r("filename\\*","i").exec(t);if(n){n=n[1];let p=o(n);return p=unescape(p),p=l(p),p=u(p),i(p)}if(n=s(t),n){const p=u(n);return i(p)}if(n=r("filename","i").exec(t),n){n=n[1];let p=o(n);return p=u(p),i(p)}function r(p,f){return new RegExp("(?:^|;)\\s*"+p+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',f)}function a(p,f){if(p){if(!/^[\x00-\xFF]+$/.test(f))return f;try{const m=new TextDecoder(p,{fatal:!0}),g=M0(f);f=m.decode(g),e=!1}catch{}}return f}function i(p){return e&&/[\x80-\xff]/.test(p)&&(p=a("utf-8",p),e&&(p=a("iso-8859-1",p))),p}function s(p){const f=[];let m;const g=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(m=g.exec(p))!==null;){let[,E,y,v]=m;if(E=parseInt(E,10),E in f){if(E===0)break;continue}f[E]=[y,v]}const S=[];for(let E=0;E<f.length&&E in f;++E){let[y,v]=f[E];v=o(v),y&&(v=unescape(v),E===0&&(v=l(v))),S.push(v)}return S.join("")}function o(p){if(p.startsWith('"')){const f=p.slice(1).split('\\"');for(let m=0;m<f.length;++m){const g=f[m].indexOf('"');g!==-1&&(f[m]=f[m].slice(0,g),f.length=m+1),f[m]=f[m].replaceAll(/\\(.)/g,"$1")}p=f.join('"')}return p}function l(p){const f=p.indexOf("'");if(f===-1)return p;const m=p.slice(0,f),S=p.slice(f+1).replace(/^[^']*'/,"");return a(m,S)}function u(p){return!p.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(p)?p:p.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(f,m,g,S){if(g==="q"||g==="Q")return S=S.replaceAll("_"," "),S=S.replaceAll(/=([0-9a-fA-F]{2})/g,function(E,y){return String.fromCharCode(parseInt(y,16))}),a(m,S);try{S=atob(S)}catch{}return a(m,S)})}return""}function iae(t,e){const n=new Headers;if(!t||!e||typeof e!="object")return n;for(const r in e){const a=e[r];a!==void 0&&n.append(r,a)}return n}function PA(t){var e;return((e=URL.parse(t))==null?void 0:e.origin)??null}function sae({responseHeaders:t,isHttp:e,rangeChunkSize:n,disableRange:r}){const a={allowRangeRequests:!1,suggestedLength:void 0},i=parseInt(t.get("Content-Length"),10);return!Number.isInteger(i)||(a.suggestedLength=i,i<=2*n)||r||!e||t.get("Accept-Ranges")!=="bytes"||(t.get("Content-Encoding")||"identity")!=="identity"||(a.allowRangeRequests=!0),a}function oae(t){const e=t.get("Content-Disposition");if(e){let n=JUe(e);if(n.includes("%"))try{n=decodeURIComponent(n)}catch{}if(TA(n))return n}return null}function $0(t,e){return new k0(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,t===404||t===0&&e.startsWith("file:"))}function lae(t){return t===200||t===206}function cae(t,e,n){return{method:"GET",headers:t,signal:n.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function uae(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(It(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class e7e{constructor(e){Pe(this,"_responseOrigin",null);this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=iae(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return on(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new t7e(this),this._fullRequestReader}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const r=new n7e(this,e,n);return this._rangeRequestReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeRequestReaders.slice(0))r.cancel(e)}}class t7e{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;const n=e.source;this._withCredentials=n.withCredentials||!1,this._contentLength=n.length,this._headersCapability=Promise.withResolvers(),this._disableRange=n.disableRange||!1,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!n.disableStream,this._isRangeSupported=!n.disableRange;const r=new Headers(e.headers),a=n.url;fetch(a,cae(r,this._withCredentials,this._abortController)).then(i=>{if(e._responseOrigin=PA(i.url),!lae(i.status))throw $0(i.status,a);this._reader=i.body.getReader(),this._headersCapability.resolve();const s=i.headers,{allowRangeRequests:o,suggestedLength:l}=sae({responseHeaders:s,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=oae(s),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new yc("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;await this._headersCapability.promise;const{value:e,done:n}=await this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded,total:this._contentLength}),{value:uae(e),done:!1})}cancel(e){var n;(n=this._reader)==null||n.cancel(e),this._abortController.abort()}}class n7e{constructor(e,n,r){this._stream=e,this._reader=null,this._loaded=0;const a=e.source;this._withCredentials=a.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!a.disableStream,this._abortController=new AbortController;const i=new Headers(e.headers);i.append("Range",`bytes=${n}-${r-1}`);const s=a.url;fetch(s,cae(i,this._withCredentials,this._abortController)).then(o=>{const l=PA(o.url);if(l!==e._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${e._responseOrigin}".`);if(!lae(o.status))throw $0(o.status,s);this._readCapability.resolve(),this._reader=o.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;await this._readCapability.promise;const{value:e,done:n}=await this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded}),{value:uae(e),done:!1})}cancel(e){var n;(n=this._reader)==null||n.cancel(e),this._abortController.abort()}}const mF=200,hF=206;function r7e(t){const e=t.response;return typeof e!="string"?e:M0(e).buffer}class a7e{constructor({url:e,httpHeaders:n,withCredentials:r}){Pe(this,"_responseOrigin",null);this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=iae(this.isHttp,n),this.withCredentials=r||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){const n=new XMLHttpRequest,r=this.currXhrId++,a=this.pendingRequests[r]={xhr:n};n.open("GET",this.url),n.withCredentials=this.withCredentials;for(const[i,s]of this.headers)n.setRequestHeader(i,s);return this.isHttp&&"begin"in e&&"end"in e?(n.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),a.expectedStatus=hF):a.expectedStatus=mF,n.responseType="arraybuffer",on(e.onError,"Expected `onError` callback to be provided."),n.onerror=()=>{e.onError(n.status)},n.onreadystatechange=this.onStateChange.bind(this,r),n.onprogress=this.onProgress.bind(this,r),a.onHeadersReceived=e.onHeadersReceived,a.onDone=e.onDone,a.onError=e.onError,a.onProgress=e.onProgress,n.send(null),r}onProgress(e,n){var a;const r=this.pendingRequests[e];r&&((a=r.onProgress)==null||a.call(r,n))}onStateChange(e,n){const r=this.pendingRequests[e];if(!r)return;const a=r.xhr;if(a.readyState>=2&&r.onHeadersReceived&&(r.onHeadersReceived(),delete r.onHeadersReceived),a.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],a.status===0&&this.isHttp){r.onError(a.status);return}const i=a.status||mF;if(!(i===mF&&r.expectedStatus===hF)&&i!==r.expectedStatus){r.onError(a.status);return}const o=r7e(a);if(i===hF){const l=a.getResponseHeader("Content-Range"),u=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);u?r.onDone({begin:parseInt(u[1],10),chunk:o}):(It('Missing or invalid "Content-Range" header.'),r.onError(0))}else o?r.onDone({begin:0,chunk:o}):r.onError(a.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const n=this.pendingRequests[e].xhr;delete this.pendingRequests[e],n.abort()}}class i7e{constructor(e){this._source=e,this._manager=new a7e(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const n=this._rangeRequestReaders.indexOf(e);n>=0&&this._rangeRequestReaders.splice(n,1)}getFullReader(){return on(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new s7e(this._manager,this._source),this._fullRequestReader}getRangeReader(e,n){const r=new o7e(this._manager,e,n);return r.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeRequestReaders.slice(0))r.cancel(e)}}class s7e{constructor(e,n){this._manager=e,this._url=n.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=n.disableRange||!1,this._contentLength=n.length,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,n=this._manager.getRequestXhr(e);this._manager._responseOrigin=PA(n.responseURL);const r=n.getAllResponseHeaders(),a=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(o=>{const[l,...u]=o.split(": ");return[l,u.join(": ")]}):[]),{allowRangeRequests:i,suggestedLength:s}=sae({responseHeaders:a,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=s||this._contentLength,this._filename=oae(a),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=$0(e,this._url),this._headersCapability.reject(this._storedError);for(const n of this._requests)n.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var n;(n=this.onProgress)==null||n.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class o7e{constructor(e,n,r){this._manager=e,this._url=e.url,this._requestId=e.request({begin:n,end:r,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var n;const e=PA((n=this._manager.getRequestXhr(this._requestId))==null?void 0:n.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var e;(e=this.onClosed)==null||e.call(this,this)}_onDone(e){const n=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:n,done:!1}):this._queuedChunk=n,this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??(this._storedError=$0(e,this._url));for(const n of this._requests)n.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var n;this.isStreamingSupported||(n=this.onProgress)==null||n.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const n=this._queuedChunk;return this._queuedChunk=null,{value:n,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const l7e=/^[a-z][a-z0-9\-+.]+:/i;function c7e(t){if(l7e.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}class u7e{constructor(e){this.source=e,this.url=c7e(e.url),on(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return on(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new d7e(this),this._fullRequestReader}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const r=new p7e(this,e,n);return this._rangeRequestReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeRequestReaders.slice(0))r.cancel(e)}}class d7e{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const n=e.source;this._contentLength=n.length,this._loaded=0,this._filename=null,this._disableRange=n.disableRange||!1,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!n.disableStream,this._isRangeSupported=!n.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const r=process.getBuiltinModule("fs");r.promises.lstat(this._url).then(a=>{this._contentLength=a.size,this._setReadableStream(r.createReadStream(this._url)),this._headersCapability.resolve()},a=>{a.code==="ENOENT"&&(a=$0(0,this._url.href)),this._storedError=a,this._headersCapability.reject(a)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",n=>{this._error(n)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new yc("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class p7e{constructor(e,n,r){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const a=e.source;this._isStreamingSupported=!a.disableStream;const i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:n,end:r-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",n=>{this._error(n)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Y0=Symbol("INITIAL_DATA");class dae{constructor(){Y(this,GE);Y(this,us,Object.create(null))}get(e,n=null){if(n){const a=K(this,GE,d6).call(this,e);return a.promise.then(()=>n(a.data)),null}const r=_(this,us)[e];if(!r||r.data===Y0)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return r.data}has(e){const n=_(this,us)[e];return!!n&&n.data!==Y0}delete(e){const n=_(this,us)[e];return!n||n.data===Y0?!1:(delete _(this,us)[e],!0)}resolve(e,n=null){const r=K(this,GE,d6).call(this,e);r.data=n,r.resolve()}clear(){var e;for(const n in _(this,us)){const{data:r}=_(this,us)[n];(e=r==null?void 0:r.bitmap)==null||e.close()}M(this,us,Object.create(null))}*[Symbol.iterator](){for(const e in _(this,us)){const{data:n}=_(this,us)[e];n!==Y0&&(yield[e,n])}}}us=new WeakMap,GE=new WeakSet,d6=function(e){var n;return(n=_(this,us))[e]||(n[e]={...Promise.withResolvers(),data:Y0})};const f7e=1e5,pae=30;let V0=(Fr=class{constructor({textContentSource:e,container:n,viewport:r}){Y(this,Yc);Y(this,Id,Promise.withResolvers());Y(this,Li,null);Y(this,zE,!1);Y(this,qE,!!(($ae=globalThis.FontInspector)!=null&&$ae.enabled));Y(this,zf,null);Y(this,$c,null);Y(this,HE,0);Y(this,$E,0);Y(this,qf,null);Y(this,$g,null);Y(this,Yg,0);Y(this,Dd,0);Y(this,Vg,Object.create(null));Y(this,YE,[]);Y(this,Wg,null);Y(this,Hf,[]);Y(this,VE,new WeakMap);Y(this,WE,null);var l;if(e instanceof ReadableStream)M(this,Wg,e);else if(typeof e=="object")M(this,Wg,new ReadableStream({start(u){u.enqueue(e),u.close()}}));else throw new Error('No "textContentSource" parameter specified.');M(this,Li,M(this,$g,n)),M(this,Dd,r.scale*Oo.pixelRatio),M(this,Yg,r.rotation),M(this,$c,{div:null,properties:null,ctx:null});const{pageWidth:a,pageHeight:i,pageX:s,pageY:o}=r.rawDims;M(this,WE,[1,0,0,-1,-s,o+i]),M(this,$E,a),M(this,HE,i),K(l=Fr,ds,ice).call(l),od(n,r),_(this,Id).promise.finally(()=>{_(Fr,Kg).delete(this),M(this,$c,null),M(this,Vg,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:n}=Ea.platform;return qt(this,"fontFamilyMap",new Map([["sans-serif",`${e&&n?"Calibri, ":""}sans-serif`],["monospace",`${e&&n?"Lucida Console, ":""}monospace`]]))}render(){const e=()=>{_(this,qf).read().then(({value:n,done:r})=>{if(r){_(this,Id).resolve();return}_(this,zf)??M(this,zf,n.lang),Object.assign(_(this,Vg),n.styles),K(this,Yc,rce).call(this,n.items),e()},_(this,Id).reject)};return M(this,qf,_(this,Wg).getReader()),_(Fr,Kg).add(this),e(),_(this,Id).promise}update({viewport:e,onBefore:n=null}){var i;const r=e.scale*Oo.pixelRatio,a=e.rotation;if(a!==_(this,Yg)&&(n==null||n(),M(this,Yg,a),od(_(this,$g),{rotation:a})),r!==_(this,Dd)){n==null||n(),M(this,Dd,r);const s={div:null,properties:null,ctx:K(i=Fr,ds,DR).call(i,_(this,zf))};for(const o of _(this,Hf))s.properties=_(this,VE).get(o),s.div=o,K(this,Yc,p6).call(this,s)}}cancel(){var n;const e=new yc("TextLayer task cancelled.");(n=_(this,qf))==null||n.cancel(e).catch(()=>{}),M(this,qf,null),_(this,Id).reject(e)}get textDivs(){return _(this,Hf)}get textContentItemsStr(){return _(this,YE)}static cleanup(){if(!(_(this,Kg).size>0)){_(this,jg).clear();for(const{canvas:e}of _(this,$f).values())e.remove();_(this,$f).clear()}}},Id=new WeakMap,Li=new WeakMap,zE=new WeakMap,qE=new WeakMap,zf=new WeakMap,$c=new WeakMap,HE=new WeakMap,$E=new WeakMap,qf=new WeakMap,$g=new WeakMap,Yg=new WeakMap,Dd=new WeakMap,Vg=new WeakMap,YE=new WeakMap,Wg=new WeakMap,Hf=new WeakMap,VE=new WeakMap,WE=new WeakMap,jg=new WeakMap,$f=new WeakMap,jE=new WeakMap,kd=new WeakMap,Kg=new WeakMap,Yc=new WeakSet,rce=function(e){var a,i;if(_(this,zE))return;(i=_(this,$c)).ctx??(i.ctx=K(a=Fr,ds,DR).call(a,_(this,zf)));const n=_(this,Hf),r=_(this,YE);for(const s of e){if(n.length>f7e){It("Ignoring additional textDivs for performance reasons."),M(this,zE,!0);return}if(s.str===void 0){if(s.type==="beginMarkedContentProps"||s.type==="beginMarkedContent"){const o=_(this,Li);M(this,Li,document.createElement("span")),_(this,Li).classList.add("markedContent"),s.id&&_(this,Li).setAttribute("id",`${s.id}`),o.append(_(this,Li))}else s.type==="endMarkedContent"&&M(this,Li,_(this,Li).parentNode);continue}r.push(s.str),K(this,Yc,ace).call(this,s)}},ace=function(e){var E;const n=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};_(this,Hf).push(n);const a=Je.transform(_(this,WE),e.transform);let i=Math.atan2(a[1],a[0]);const s=_(this,Vg)[e.fontName];s.vertical&&(i+=Math.PI/2);let o=_(this,qE)&&s.fontSubstitution||s.fontFamily;o=Fr.fontFamilyMap.get(o)||o;const l=Math.hypot(a[2],a[3]),u=l*K(E=Fr,ds,sce).call(E,o,s,_(this,zf));let p,f;i===0?(p=a[4],f=a[5]-u):(p=a[4]+u*Math.sin(i),f=a[5]-u*Math.cos(i));const m="calc(var(--total-scale-factor) *",g=n.style;_(this,Li)===_(this,$g)?(g.left=`${(100*p/_(this,$E)).toFixed(2)}%`,g.top=`${(100*f/_(this,HE)).toFixed(2)}%`):(g.left=`${m}${p.toFixed(2)}px)`,g.top=`${m}${f.toFixed(2)}px)`),g.fontSize=`${m}${(_(Fr,kd)*l).toFixed(2)}px)`,g.fontFamily=o,r.fontSize=l,n.setAttribute("role","presentation"),n.textContent=e.str,n.dir=e.dir,_(this,qE)&&(n.dataset.fontName=s.fontSubstitutionLoadedName||e.fontName),i!==0&&(r.angle=i*(180/Math.PI));let S=!1;if(e.str.length>1)S=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){const y=Math.abs(e.transform[0]),v=Math.abs(e.transform[3]);y!==v&&Math.max(y,v)/Math.min(y,v)>1.5&&(S=!0)}if(S&&(r.canvasWidth=s.vertical?e.height:e.width),_(this,VE).set(n,r),_(this,$c).div=n,_(this,$c).properties=r,K(this,Yc,p6).call(this,_(this,$c)),r.hasText&&_(this,Li).append(n),r.hasEOL){const y=document.createElement("br");y.setAttribute("role","presentation"),_(this,Li).append(y)}},p6=function(e){var o;const{div:n,properties:r,ctx:a}=e,{style:i}=n;let s="";if(_(Fr,kd)>1&&(s=`scale(${1/_(Fr,kd)})`),r.canvasWidth!==0&&r.hasText){const{fontFamily:l}=i,{canvasWidth:u,fontSize:p}=r;K(o=Fr,ds,f6).call(o,a,p*_(this,Dd),l);const{width:f}=a.measureText(n.textContent);f>0&&(s=`scaleX(${u*_(this,Dd)/f}) ${s}`)}r.angle!==0&&(s=`rotate(${r.angle}deg) ${s}`),s.length>0&&(i.transform=s)},ds=new WeakSet,DR=function(e=null){let n=_(this,$f).get(e||(e=""));if(!n){const r=document.createElement("canvas");r.className="hiddenCanvasElement",r.lang=e,document.body.append(r),n=r.getContext("2d",{alpha:!1,willReadFrequently:!0}),_(this,$f).set(e,n),_(this,jE).set(n,{size:0,family:""})}return n},f6=function(e,n,r){const a=_(this,jE).get(e);n===a.size&&r===a.family||(e.font=`${n}px ${r}`,a.size=n,a.family=r)},ice=function(){if(_(this,kd)!==null)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),M(this,kd,e.getBoundingClientRect().height),e.remove()},sce=function(e,n,r){const a=_(this,jg).get(e);if(a)return a;const i=K(this,ds,DR).call(this,r);i.canvas.width=i.canvas.height=pae,K(this,ds,f6).call(this,i,pae,e);const s=i.measureText(""),o=s.fontBoundingBoxAscent,l=Math.abs(s.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let u=.8;return o?u=o/(o+l):(Ea.platform.isFirefox&&It("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),n.ascent?u=n.ascent:n.descent&&(u=1+n.descent)),_(this,jg).set(e,u),u},Y(Fr,ds),Y(Fr,jg,new Map),Y(Fr,$f,new Map),Y(Fr,jE,new WeakMap),Y(Fr,kd,null),Y(Fr,Kg,new Set),Fr);const m7e=100;function gF(t={}){typeof t=="string"||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new _F,{docId:n}=e,r=t.url?vUe(t.url):null,a=t.data?TUe(t.data):null,i=t.httpHeaders||null,s=t.withCredentials===!0,o=t.password??null,l=t.range instanceof bF?t.range:null,u=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:2**16;let p=t.worker instanceof Jh?t.worker:null;const f=t.verbosity,m=typeof t.docBaseUrl=="string"&&!F0(t.docBaseUrl)?t.docBaseUrl:null,g=NA(t.cMapUrl),S=t.cMapPacked!==!1,E=t.CMapReaderFactory||(ui?OUe:qre),y=NA(t.iccUrl),v=NA(t.standardFontDataUrl),A=t.StandardFontDataFactory||(ui?IUe:Yre),T=NA(t.wasmUrl),w=t.WasmFactory||(ui?DUe:Wre),O=t.stopAtErrors!==!0,R=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,I=t.isEvalSupported!==!1,L=typeof t.isOffscreenCanvasSupported=="boolean"?t.isOffscreenCanvasSupported:!ui,P=typeof t.isImageDecoderSupported=="boolean"?t.isImageDecoderSupported:!ui&&(Ea.platform.isFirefox||!globalThis.chrome),U=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,H=typeof t.disableFontFace=="boolean"?t.disableFontFace:ui,W=t.fontExtraProperties===!0,Z=t.enableXfa===!0,F=t.ownerDocument||globalThis.document,j=t.disableRange===!0,z=t.disableStream===!0,V=t.disableAutoFetch===!0,X=t.pdfBug===!0,te=t.CanvasFactory||(ui?xUe:RUe),$=t.FilterFactory||(ui?wUe:NUe),Q=t.enableHWA===!0,ee=t.useWasm!==!1,B=l?l.length:t.length??NaN,ie=typeof t.useSystemFonts=="boolean"?t.useSystemFonts:!ui&&!H,ce=typeof t.useWorkerFetch=="boolean"?t.useWorkerFetch:!!(E===qre&&A===Yre&&w===Wre&&g&&v&&T&&B0(g,document.baseURI)&&B0(v,document.baseURI)&&B0(T,document.baseURI)),se=null;rUe(f);const ne={canvasFactory:new te({ownerDocument:F,enableHWA:Q}),filterFactory:new $({docId:n,ownerDocument:F}),cMapReaderFactory:ce?null:new E({baseUrl:g,isCompressed:S}),standardFontDataFactory:ce?null:new A({baseUrl:v}),wasmFactory:ce?null:new w({baseUrl:T})};p||(p=Jh.create({verbosity:f,port:Gs.workerPort}),e._worker=p);const oe={docId:n,apiVersion:"5.4.296",data:a,password:o,disableAutoFetch:V,rangeChunkSize:u,length:B,docBaseUrl:m,enableXfa:Z,evaluatorOptions:{maxImageSize:R,disableFontFace:H,ignoreErrors:O,isEvalSupported:I,isOffscreenCanvasSupported:L,isImageDecoderSupported:P,canvasMaxAreaInBytes:U,fontExtraProperties:W,useSystemFonts:ie,useWasm:ee,useWorkerFetch:ce,cMapUrl:g,iccUrl:y,standardFontDataUrl:v,wasmUrl:T}},he={ownerDocument:F,pdfBug:X,styleElement:se,loadingParams:{disableAutoFetch:V,enableXfa:Z}};return p.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(p.destroyed)throw new Error("Worker was destroyed");const _e=p.messageHandler.sendWithPromise("GetDocRequest",oe,a?[a.buffer]:null);let Ce;if(l)Ce=new XUe(l,{disableRange:j,disableStream:z});else if(!a){if(!r)throw new Error("getDocument - no `url` parameter provided.");const Ne=B0(r)?e7e:ui?u7e:i7e;Ce=new Ne({url:r,length:B,httpHeaders:i,withCredentials:s,rangeChunkSize:u,disableRange:j,disableStream:z})}return _e.then(Ne=>{if(e.destroyed)throw new Error("Loading aborted");if(p.destroyed)throw new Error("Worker was destroyed");const Te=new q0(n,Ne,p.port),De=new _7e(Te,e,Ce,he,ne,Q);e._transport=De,Te.send("Ready",null)})}).catch(e._capability.reject),e}const iC=class iC{constructor(){Pe(this,"_capability",Promise.withResolvers());Pe(this,"_transport",null);Pe(this,"_worker",null);Pe(this,"docId",`d${_a(iC,aC)._++}`);Pe(this,"destroyed",!1);Pe(this,"onPassword",null);Pe(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var e,n,r,a;this.destroyed=!0;try{(e=this._worker)!=null&&e.port&&(this._worker._pendingDestroy=!0),await((n=this._transport)==null?void 0:n.destroy())}catch(i){throw(r=this._worker)!=null&&r.port&&delete this._worker._pendingDestroy,i}this._transport=null,(a=this._worker)==null||a.destroy(),this._worker=null}async getData(){return this._transport.getData()}};aC=new WeakMap,Y(iC,aC,0);let _F=iC,bF=(Yae=class{constructor(e,n,r=!1,a=null){Y(this,Yf,Promise.withResolvers());Y(this,KE,[]);Y(this,XE,[]);Y(this,QE,[]);Y(this,ZE,[]);this.length=e,this.initialData=n,this.progressiveDone=r,this.contentDispositionFilename=a}addRangeListener(e){_(this,ZE).push(e)}addProgressListener(e){_(this,QE).push(e)}addProgressiveReadListener(e){_(this,XE).push(e)}addProgressiveDoneListener(e){_(this,KE).push(e)}onDataRange(e,n){for(const r of _(this,ZE))r(e,n)}onDataProgress(e,n){_(this,Yf).promise.then(()=>{for(const r of _(this,QE))r(e,n)})}onDataProgressiveRead(e){_(this,Yf).promise.then(()=>{for(const n of _(this,XE))n(e)})}onDataProgressiveDone(){_(this,Yf).promise.then(()=>{for(const e of _(this,KE))e()})}transportReady(){_(this,Yf).resolve()}requestDataRange(e,n){Qn("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},Yf=new WeakMap,KE=new WeakMap,XE=new WeakMap,QE=new WeakMap,ZE=new WeakMap,Yae);class h7e{constructor(e,n){this._pdfInfo=e,this._transport=n}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return qt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(e,n){return this._transport.getAnnotationsByType(e,n)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:n}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(n)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class g7e{constructor(e,n,r,a=!1){Y(this,Vf);Y(this,Vc,!1);this._pageIndex=e,this._pageInfo=n,this._transport=r,this._stats=a?new Cre:null,this._pdfBug=a,this.commonObjs=r.commonObjs,this.objs=new dae,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:n=this.rotate,offsetX:r=0,offsetY:a=0,dontFlip:i=!1}={}){return new P0({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:n,offsetX:r,offsetY:a,dontFlip:i})}getAnnotations({intent:e="display"}={}){const{renderingIntent:n}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,n)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return qt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var e;return((e=this._transport._htmlForXfa)==null?void 0:e.children[this._pageIndex])||null}render({canvasContext:e,canvas:n=e.canvas,viewport:r,intent:a="display",annotationMode:i=_l.ENABLE,transform:s=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:u=null,pageColors:p=null,printAnnotationStorage:f=null,isEditing:m=!1,recordOperations:g=!1,operationsFilter:S=null}){var P,U,H;(P=this._stats)==null||P.time("Overall");const E=this._transport.getRenderingIntent(a,i,f,m),{renderingIntent:y,cacheKey:v}=E;M(this,Vc,!1),l||(l=this._transport.getOptionalContentConfig(y));let A=this._intentStates.get(v);A||(A=Object.create(null),this._intentStates.set(v,A)),A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);const T=!!(y&rs.PRINT);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(U=this._stats)==null||U.time("Page Request"),this._pumpOperatorList(E));const w=!!(this._pdfBug&&((H=globalThis.StepperManager)!=null&&H.enabled)),O=!this.recordedBBoxes&&(g||w),R=W=>{var Z,F;if(A.renderTasks.delete(I),O){const j=(Z=I.gfx)==null?void 0:Z.dependencyTracker.take();j&&(I.stepper&&I.stepper.setOperatorBBoxes(j,I.gfx.dependencyTracker.takeDebugMetadata()),g&&(this.recordedBBoxes=j))}T&&M(this,Vc,!0),K(this,Vf,ky).call(this),W?(I.capability.reject(W),this._abortOperatorList({intentState:A,reason:W instanceof Error?W:new Error(W)})):I.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(F=globalThis.Stats)!=null&&F.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},I=new EF({callback:R,params:{canvas:n,canvasContext:e,dependencyTracker:O?new MUe(n,A.operatorList.length,w):null,viewport:r,transform:s,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:u,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!T,pdfBug:this._pdfBug,pageColors:p,enableHWA:this._transport.enableHWA,operationsFilter:S});(A.renderTasks||(A.renderTasks=new Set)).add(I);const L=I.task;return Promise.all([A.displayReadyCapability.promise,l]).then(([W,Z])=>{var F;if(this.destroyed){R();return}if((F=this._stats)==null||F.time("Rendering"),!(Z.renderingIntent&y))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");I.initializeGraphics({transparency:W,optionalContentConfig:Z}),I.operatorListChanged()}).catch(R),L}getOperatorList({intent:e="display",annotationMode:n=_l.ENABLE,printAnnotationStorage:r=null,isEditing:a=!1}={}){var u;function i(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const s=this._transport.getRenderingIntent(e,n,r,a,!0);let o=this._intentStates.get(s.cacheKey);o||(o=Object.create(null),this._intentStates.set(s.cacheKey,o));let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=i,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(u=this._stats)==null||u.time("Page Request"),this._pumpOperatorList(s)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:n=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:n===!0},{highWaterMark:100,size(a){return a.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(r=>L0.textContent(r));const n=this.streamTextContent(e);return new Promise(function(r,a){function i(){s.read().then(function({value:l,done:u}){if(u){r(o);return}o.lang??(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),i()},a)}const s=n.getReader(),o={items:[],styles:Object.create(null),lang:null};i()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const n of this._intentStates.values())if(this._abortOperatorList({intentState:n,reason:new Error("Page was destroyed."),force:!0}),!n.opListReadCapability)for(const r of n.renderTasks)e.push(r.completed),r.cancel();return this.objs.clear(),M(this,Vc,!1),Promise.all(e)}cleanup(e=!1){M(this,Vc,!0);const n=K(this,Vf,ky).call(this);return e&&n&&this._stats&&(this._stats=new Cre),n}_startRenderPage(e,n){var a,i;const r=this._intentStates.get(n);r&&((a=this._stats)==null||a.timeEnd("Page Request"),(i=r.displayReadyCapability)==null||i.resolve(e))}_renderPageChunk(e,n){for(let r=0,a=e.length;r<a;r++)n.operatorList.fnArray.push(e.fnArray[r]),n.operatorList.argsArray.push(e.argsArray[r]);n.operatorList.lastChunk=e.lastChunk,n.operatorList.separateAnnots=e.separateAnnots;for(const r of n.renderTasks)r.operatorListChanged();e.lastChunk&&K(this,Vf,ky).call(this)}_pumpOperatorList({renderingIntent:e,cacheKey:n,annotationStorageSerializable:r,modifiedIds:a}){const{map:i,transfer:s}=r,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:n,annotationStorage:i,modifiedIds:a},s).getReader(),u=this._intentStates.get(n);u.streamReader=l;const p=()=>{l.read().then(({value:f,done:m})=>{if(m){u.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(f,u),p())},f=>{if(u.streamReader=null,!this._transport.destroyed){if(u.operatorList){u.operatorList.lastChunk=!0;for(const m of u.renderTasks)m.operatorListChanged();K(this,Vf,ky).call(this)}if(u.displayReadyCapability)u.displayReadyCapability.reject(f);else if(u.opListReadCapability)u.opListReadCapability.reject(f);else throw f}})};p()}_abortOperatorList({intentState:e,reason:n,force:r=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!r){if(e.renderTasks.size>0)return;if(n instanceof vA){let a=m7e;n.extraDelay>0&&n.extraDelay<1e3&&(a+=n.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:n,force:!0})},a);return}}if(e.streamReader.cancel(new yc(n.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(const[a,i]of this._intentStates)if(i===e){this._intentStates.delete(a);break}this.cleanup()}}}get stats(){return this._stats}}Vc=new WeakMap,Vf=new WeakSet,ky=function(){if(!_(this,Vc)||this.destroyed)return!1;for(const{renderTasks:e,operatorList:n}of this._intentStates.values())if(e.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),M(this,Vc,!1),!0};const br=class br{constructor({name:e=null,port:n=null,verbosity:r=aUe()}={}){Y(this,pi);Y(this,Md,Promise.withResolvers());Y(this,Bo,null);Y(this,Wc,null);Y(this,Wf,null);if(this.name=e,this.destroyed=!1,this.verbosity=r,n){if(_(br,Kf).has(n))throw new Error("Cannot use more than one PDFWorker per port.");_(br,Kf).set(n,this),K(this,pi,oce).call(this,n)}else K(this,pi,lce).call(this)}get promise(){return _(this,Md).promise}get port(){return _(this,Wc)}get messageHandler(){return _(this,Bo)}destroy(){var e,n;this.destroyed=!0,(e=_(this,Wf))==null||e.terminate(),M(this,Wf,null),_(br,Kf).delete(_(this,Wc)),M(this,Wc,null),(n=_(this,Bo))==null||n.destroy(),M(this,Bo,null)}static create(e){const n=_(this,Kf).get(e==null?void 0:e.port);if(n){if(n._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new br(e)}static get workerSrc(){if(Gs.workerSrc)return Gs.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return qt(this,"_setupFakeWorkerGlobal",(async()=>_(this,Xg,MR)?_(this,Xg,MR):(await import(this.workerSrc)).WorkerMessageHandler)())}};Md=new WeakMap,Bo=new WeakMap,Wc=new WeakMap,Wf=new WeakMap,sC=new WeakMap,jf=new WeakMap,Kf=new WeakMap,pi=new WeakSet,kR=function(){_(this,Md).resolve(),_(this,Bo).send("configure",{verbosity:this.verbosity})},oce=function(e){M(this,Wc,e),M(this,Bo,new q0("main","worker",e)),_(this,Bo).on("ready",()=>{}),K(this,pi,kR).call(this)},lce=function(){if(_(br,jf)||_(br,Xg,MR)){K(this,pi,My).call(this);return}let{workerSrc:e}=br;try{br._isSameOrigin(window.location,e)||(e=br._createCDNWrapper(new URL(e,window.location).href));const n=new Worker(e,{type:"module"}),r=new q0("main","worker",n),a=()=>{i.abort(),r.destroy(),n.terminate(),this.destroyed?_(this,Md).reject(new Error("Worker was destroyed")):K(this,pi,My).call(this)},i=new AbortController;n.addEventListener("error",()=>{_(this,Wf)||a()},{signal:i.signal}),r.on("test",o=>{if(i.abort(),this.destroyed||!o){a();return}M(this,Bo,r),M(this,Wc,n),M(this,Wf,n),K(this,pi,kR).call(this)}),r.on("ready",o=>{if(i.abort(),this.destroyed){a();return}try{s()}catch{K(this,pi,My).call(this)}});const s=()=>{const o=new Uint8Array;r.send("test",o,[o.buffer])};s();return}catch{SA("The worker has been disabled.")}K(this,pi,My).call(this)},My=function(){_(br,jf)||(It("Setting up fake worker."),M(br,jf,!0)),br._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){_(this,Md).reject(new Error("Worker was destroyed"));return}const n=new CUe;M(this,Wc,n);const r=`fake${_a(br,sC)._++}`,a=new q0(r+"_worker",r,n);e.setup(a,n),M(this,Bo,new q0(r,r+"_worker",n)),K(this,pi,kR).call(this)}).catch(e=>{_(this,Md).reject(new Error(`Setting up fake worker failed: "${e.message}".`))})},Xg=new WeakSet,MR=function(){var e;try{return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch{return null}},Y(br,Xg),Y(br,sC,0),Y(br,jf,!1),Y(br,Kf,new WeakMap),ui&&(M(br,jf,!0),Gs.workerSrc||(Gs.workerSrc="./pdf.worker.mjs")),br._isSameOrigin=(e,n)=>{const r=URL.parse(e);if(!(r!=null&&r.origin)||r.origin==="null")return!1;const a=new URL(n,r);return r.origin===a.origin},br._createCDNWrapper=e=>{const n=`await import("${e}");`;return URL.createObjectURL(new Blob([n],{type:"text/javascript"}))},br.fromPort=e=>{if(fUe("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(e!=null&&e.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return br.create(e)};let Jh=br;class _7e{constructor(e,n,r,a,i,s){Y(this,Xf);Y(this,jc,new Map);Y(this,Ml,new Map);Y(this,Qg,new Map);Y(this,Zg,new Map);Y(this,Kc,null);this.messageHandler=e,this.loadingTask=n,this.commonObjs=new dae,this.fontLoader=new SUe({ownerDocument:a.ownerDocument,styleElement:a.styleElement}),this.loadingParams=a.loadingParams,this._params=a,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.wasmFactory=i.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=r,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=s,this.setupMessageHandler()}get annotationStorage(){return qt(this,"annotationStorage",new aF)}getRenderingIntent(e,n=_l.ENABLE,r=null,a=!1,i=!1){let s=rs.DISPLAY,o=rF;switch(e){case"any":s=rs.ANY;break;case"display":break;case"print":s=rs.PRINT;break;default:It(`getRenderingIntent - invalid intent: ${e}`)}const l=s&rs.PRINT&&r instanceof Fre?r:this.annotationStorage;switch(n){case _l.DISABLE:s+=rs.ANNOTATIONS_DISABLE;break;case _l.ENABLE:break;case _l.ENABLE_FORMS:s+=rs.ANNOTATIONS_FORMS;break;case _l.ENABLE_STORAGE:s+=rs.ANNOTATIONS_STORAGE,o=l.serializable;break;default:It(`getRenderingIntent - invalid annotationMode: ${n}`)}a&&(s+=rs.IS_EDITING),i&&(s+=rs.OPLIST);const{ids:u,hash:p}=l.modifiedIds,f=[s,o.hash,p];return{renderingIntent:s,cacheKey:f.join("_"),annotationStorageSerializable:o,modifiedIds:u}}destroy(){var r;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(r=_(this,Kc))==null||r.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const a of _(this,Ml).values())e.push(a._destroy());_(this,Ml).clear(),_(this,Qg).clear(),_(this,Zg).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const n=this.messageHandler.sendWithPromise("Terminate",null);return e.push(n),Promise.all(e).then(()=>{var a,i;this.commonObjs.clear(),this.fontLoader.clear(),_(this,jc).clear(),this.filterFactory.destroy(),V0.cleanup(),(a=this._networkStream)==null||a.cancelAllRequests(new yc("Worker was terminated.")),(i=this.messageHandler)==null||i.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:n}=this;e.on("GetReader",(r,a)=>{on(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=i=>{this._lastProgress={loaded:i.loaded,total:i.total}},a.onPull=()=>{this._fullReader.read().then(function({value:i,done:s}){if(s){a.close();return}on(i instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),a.enqueue(new Uint8Array(i),1,[i])}).catch(i=>{a.error(i)})},a.onCancel=i=>{this._fullReader.cancel(i),a.ready.catch(s=>{if(!this.destroyed)throw s})}}),e.on("ReaderHeadersReady",async r=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:a,isRangeSupported:i,contentLength:s}=this._fullReader;return(!a||!i)&&(this._lastProgress&&((o=n.onProgress)==null||o.call(n,this._lastProgress)),this._fullReader.onProgress=l=>{var u;(u=n.onProgress)==null||u.call(n,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:a,isRangeSupported:i,contentLength:s}}),e.on("GetRangeReader",(r,a)=>{on(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(r.begin,r.end);if(!i){a.close();return}a.onPull=()=>{i.read().then(function({value:s,done:o}){if(o){a.close();return}on(s instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),a.enqueue(new Uint8Array(s),1,[s])}).catch(s=>{a.error(s)})},a.onCancel=s=>{i.cancel(s),a.ready.catch(o=>{if(!this.destroyed)throw o})}}),e.on("GetDoc",({pdfInfo:r})=>{this._numPages=r.numPages,this._htmlForXfa=r.htmlForXfa,delete r.htmlForXfa,n._capability.resolve(new h7e(r,this))}),e.on("DocException",r=>{n._capability.reject(xi(r))}),e.on("PasswordRequest",r=>{M(this,Kc,Promise.withResolvers());try{if(!n.onPassword)throw xi(r);const a=i=>{i instanceof Error?_(this,Kc).reject(i):_(this,Kc).resolve({password:i})};n.onPassword(a,r.code)}catch(a){_(this,Kc).reject(a)}return _(this,Kc).promise}),e.on("DataLoaded",r=>{var a;(a=n.onProgress)==null||a.call(n,{loaded:r.length,total:r.length}),this.downloadInfoCapability.resolve(r)}),e.on("StartRenderPage",r=>{if(this.destroyed)return;_(this,Ml).get(r.pageIndex)._startRenderPage(r.transparency,r.cacheKey)}),e.on("commonobj",([r,a,i])=>{var s;if(this.destroyed||this.commonObjs.has(r))return null;switch(a){case"Font":if("error"in i){const f=i.error;It(`Error during font loading: ${f}`),this.commonObjs.resolve(r,f);break}const o=new fF(i),l=this._params.pdfBug&&((s=globalThis.FontInspector)!=null&&s.enabled)?(f,m)=>globalThis.FontInspector.fontAdded(f,m):null,u=new yUe(o,l,i.extra,i.charProcOperatorList);this.fontLoader.bind(u).catch(()=>e.sendWithPromise("FontFallback",{id:r})).finally(()=>{!u.fontExtraProperties&&u.data&&u.clearData(),this.commonObjs.resolve(r,u)});break;case"CopyLocalImage":const{imageRef:p}=i;on(p,"The imageRef must be defined.");for(const f of _(this,Ml).values())for(const[,m]of f.objs)if((m==null?void 0:m.ref)===p)return m.dataLen?(this.commonObjs.resolve(r,structuredClone(m)),m.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(r,i);break;default:throw new Error(`Got unknown common object type ${a}`)}return null}),e.on("obj",([r,a,i,s])=>{var l;if(this.destroyed)return;const o=_(this,Ml).get(a);if(!o.objs.has(r)){if(o._intentStates.size===0){(l=s==null?void 0:s.bitmap)==null||l.close();return}switch(i){case"Image":case"Pattern":o.objs.resolve(r,s);break;default:throw new Error(`Got unknown object type ${i}`)}}}),e.on("DocProgress",r=>{var a;this.destroyed||(a=n.onProgress)==null||a.call(n,{loaded:r.loaded,total:r.total})}),e.on("FetchBinaryData",async r=>{if(this.destroyed)throw new Error("Worker was destroyed.");const a=this[r.type];if(!a)throw new Error(`${r.type} not initialized, see the \`useWorkerFetch\` parameter.`);return a.fetch(r)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var r;this.annotationStorage.size<=0&&It("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:n}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:((r=this._fullReader)==null?void 0:r.filename)??null},n).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const n=e-1,r=_(this,Qg).get(n);if(r)return r;const a=this.messageHandler.sendWithPromise("GetPage",{pageIndex:n}).then(i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&_(this,Zg).set(i.refStr,e);const s=new g7e(n,i,this,this._params.pdfBug);return _(this,Ml).set(n,s),s});return _(this,Qg).set(n,a),a}getPageIndex(e){return iF(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,n){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:n})}getFieldObjects(){return K(this,Xf,Ly).call(this,"GetFieldObjects")}hasJSActions(){return K(this,Xf,Ly).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return typeof e!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(e,n){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:e,pageIndexesToSkip:n})}getDocJSActions(){return K(this,Xf,Ly).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return K(this,Xf,Ly).call(this,"GetOptionalContentConfig").then(n=>new KUe(n,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",n=_(this,jc).get(e);if(n)return n;const r=this.messageHandler.sendWithPromise(e,null).then(a=>{var i,s;return{info:a[0],metadata:a[1]?new WUe(a[1]):null,contentDispositionFilename:((i=this._fullReader)==null?void 0:i.filename)??null,contentLength:((s=this._fullReader)==null?void 0:s.contentLength)??null}});return _(this,jc).set(e,r),r}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const n of _(this,Ml).values())if(!n.cleanup())throw new Error(`startCleanup: Page ${n.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),_(this,jc).clear(),this.filterFactory.destroy(!0),V0.cleanup()}}cachedPageNumber(e){if(!iF(e))return null;const n=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return _(this,Zg).get(n)??null}}jc=new WeakMap,Ml=new WeakMap,Qg=new WeakMap,Zg=new WeakMap,Kc=new WeakMap,Xf=new WeakSet,Ly=function(e,n=null){const r=_(this,jc).get(e);if(r)return r;const a=this.messageHandler.sendWithPromise(e,n);return _(this,jc).set(e,a),a};class b7e{constructor(e){Y(this,Ld,null);Pe(this,"onContinue",null);Pe(this,"onError",null);M(this,Ld,e)}get promise(){return _(this,Ld).capability.promise}cancel(e=0){_(this,Ld).cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=_(this,Ld).operatorList;if(!e)return!1;const{annotationCanvasMap:n}=_(this,Ld);return e.form||e.canvas&&(n==null?void 0:n.size)>0}}Ld=new WeakMap;const Zf=class Zf{constructor({callback:e,params:n,objs:r,commonObjs:a,annotationCanvasMap:i,operatorList:s,pageIndex:o,canvasFactory:l,filterFactory:u,useRequestAnimationFrame:p=!1,pdfBug:f=!1,pageColors:m=null,enableHWA:g=!1,operationsFilter:S=null}){Y(this,Pd,null);this.callback=e,this.params=n,this.objs=r,this.commonObjs=a,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=s,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=u,this._pdfBug=f,this.pageColors=m,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=p===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new b7e(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=n.canvas,this._canvasContext=n.canvas?null:n.canvasContext,this._enableHWA=g,this._dependencyTracker=n.dependencyTracker,this._operationsFilter=S}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:n}){var l,u;if(this.cancelled)return;if(this._canvas){if(_(Zf,Qf).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");_(Zf,Qf).add(this._canvas)}this._pdfBug&&((l=globalThis.StepperManager)!=null&&l.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:r,transform:a,background:i,dependencyTracker:s}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Qh(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors,s),this.gfx.beginDrawing({transform:a,viewport:r,transparency:e,background:i}),this.operatorListIdx=0,this.graphicsReady=!0,(u=this.graphicsReadyCallback)==null||u.call(this)}cancel(e=null,n=0){var r,a,i;this.running=!1,this.cancelled=!0,(r=this.gfx)==null||r.endDrawing(),_(this,Pd)&&(window.cancelAnimationFrame(_(this,Pd)),M(this,Pd,null)),_(Zf,Qf).delete(this._canvas),e||(e=new vA(`Rendering cancelled, page ${this._pageIndex+1}`,n)),this.callback(e),(i=(a=this.task).onError)==null||i.call(a,e)}operatorListChanged(){var e,n;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(e=this.gfx.dependencyTracker)==null||e.growOperationsCount(this.operatorList.fnArray.length),(n=this.stepper)==null||n.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?M(this,Pd,window.requestAnimationFrame(()=>{M(this,Pd,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),_(Zf,Qf).delete(this._canvas),this.callback())))}};Pd=new WeakMap,Qf=new WeakMap,Y(Zf,Qf,new WeakSet);let EF=Zf;const W0="5.4.296",fae="f56dc8601",Pi=class Pi{constructor({editor:e=null,uiManager:n=null}){Y(this,Hn);Y(this,ps,null);Y(this,Jf,null);Y(this,Jg);Y(this,ca,null);Y(this,JE,!1);Y(this,e_,!1);Y(this,Xc,null);Y(this,eS);Y(this,Fd,null);Y(this,Uo,null);var r,a;e?(M(this,e_,!1),M(this,Xc,e)):M(this,e_,!0),M(this,Uo,(e==null?void 0:e._uiManager)||n),M(this,eS,_(this,Uo)._eventBus),M(this,Jg,((r=e==null?void 0:e.color)==null?void 0:r.toUpperCase())||((a=_(this,Uo))==null?void 0:a.highlightColors.values().next().value)||"#FFFF98"),_(Pi,tS)||M(Pi,tS,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return qt(this,"_keyboardManager",new G0([[["Escape","mac+Escape"],Pi.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Pi.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Pi.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Pi.prototype._moveToPrevious],[["Home","mac+Home"],Pi.prototype._moveToBeginning],[["End","mac+End"],Pi.prototype._moveToEnd]]))}renderButton(){const e=M(this,ps,document.createElement("button"));e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.ariaHasPopup="true",_(this,Xc)&&(e.ariaControls=`${_(this,Xc).id}_colorpicker_dropdown`);const n=_(this,Uo)._signal;e.addEventListener("click",K(this,Hn,Wm).bind(this),{signal:n}),e.addEventListener("keydown",K(this,Hn,g6).bind(this),{signal:n});const r=M(this,Jf,document.createElement("span"));return r.className="swatch",r.ariaHidden="true",r.style.backgroundColor=_(this,Jg),e.append(r),e}renderMainDropdown(){const e=M(this,ca,K(this,Hn,m6).call(this));return e.ariaOrientation="horizontal",e.ariaLabelledBy="highlightColorPickerLabel",e}_colorSelectFromKeyboard(e){if(e.target===_(this,ps)){K(this,Hn,Wm).call(this,e);return}const n=e.target.getAttribute("data-color");n&&K(this,Hn,h6).call(this,n,e)}_moveToNext(e){var n,r;if(!_(this,Hn,kp)){K(this,Hn,Wm).call(this,e);return}if(e.target===_(this,ps)){(n=_(this,ca).firstChild)==null||n.focus();return}(r=e.target.nextSibling)==null||r.focus()}_moveToPrevious(e){var n,r;if(e.target===((n=_(this,ca))==null?void 0:n.firstChild)||e.target===_(this,ps)){_(this,Hn,kp)&&this._hideDropdownFromKeyboard();return}_(this,Hn,kp)||K(this,Hn,Wm).call(this,e),(r=e.target.previousSibling)==null||r.focus()}_moveToBeginning(e){var n;if(!_(this,Hn,kp)){K(this,Hn,Wm).call(this,e);return}(n=_(this,ca).firstChild)==null||n.focus()}_moveToEnd(e){var n;if(!_(this,Hn,kp)){K(this,Hn,Wm).call(this,e);return}(n=_(this,ca).lastChild)==null||n.focus()}hideDropdown(){var e,n;(e=_(this,ca))==null||e.classList.add("hidden"),_(this,ps).ariaExpanded="false",(n=_(this,Fd))==null||n.abort(),M(this,Fd,null)}_hideDropdownFromKeyboard(){var e;if(!_(this,e_)){if(!_(this,Hn,kp)){(e=_(this,Xc))==null||e.unselect();return}this.hideDropdown(),_(this,ps).focus({preventScroll:!0,focusVisible:_(this,JE)})}}updateColor(e){if(_(this,Jf)&&(_(this,Jf).style.backgroundColor=e),!_(this,ca))return;const n=_(this,Uo).highlightColors.values();for(const r of _(this,ca).children)r.ariaSelected=n.next().value===e.toUpperCase()}destroy(){var e,n;(e=_(this,ps))==null||e.remove(),M(this,ps,null),M(this,Jf,null),(n=_(this,ca))==null||n.remove(),M(this,ca,null)}};ps=new WeakMap,Jf=new WeakMap,Jg=new WeakMap,ca=new WeakMap,JE=new WeakMap,e_=new WeakMap,Xc=new WeakMap,eS=new WeakMap,Fd=new WeakMap,Uo=new WeakMap,tS=new WeakMap,Hn=new WeakSet,m6=function(){const e=document.createElement("div"),n=_(this,Uo)._signal;e.addEventListener("contextmenu",as,{signal:n}),e.className="dropdown",e.role="listbox",e.ariaMultiSelectable="false",e.ariaOrientation="vertical",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),_(this,Xc)&&(e.id=`${_(this,Xc).id}_colorpicker_dropdown`);for(const[r,a]of _(this,Uo).highlightColors){const i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",a),i.title=r,i.setAttribute("data-l10n-id",_(Pi,tS)[r]);const s=document.createElement("span");i.append(s),s.className="swatch",s.style.backgroundColor=a,i.ariaSelected=a===_(this,Jg),i.addEventListener("click",K(this,Hn,h6).bind(this,a),{signal:n}),e.append(i)}return e.addEventListener("keydown",K(this,Hn,g6).bind(this),{signal:n}),e},h6=function(e,n){n.stopPropagation(),_(this,eS).dispatch("switchannotationeditorparams",{source:this,type:rn.HIGHLIGHT_COLOR,value:e}),this.updateColor(e)},g6=function(e){Pi._keyboardManager.exec(this,e)},Wm=function(e){if(_(this,Hn,kp)){this.hideDropdown();return}if(M(this,JE,e.detail===0),_(this,Fd)||(M(this,Fd,new AbortController),window.addEventListener("pointerdown",K(this,Hn,cce).bind(this),{signal:_(this,Uo).combinedSignal(_(this,Fd))})),_(this,ps).ariaExpanded="true",_(this,ca)){_(this,ca).classList.remove("hidden");return}const n=M(this,ca,K(this,Hn,m6).call(this));_(this,ps).append(n)},cce=function(e){var n;(n=_(this,ca))!=null&&n.contains(e.target)||this.hideDropdown()},kp=function(){return _(this,ca)&&!_(this,ca).classList.contains("hidden")},Y(Pi,tS,null);let j0=Pi;const em=class em{constructor(e){Y(this,Ll,null);Y(this,nS,null);Y(this,t_,null);M(this,nS,e),M(this,t_,e._uiManager),_(em,rS)||M(em,rS,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(_(this,Ll))return _(this,Ll);const{editorType:e,colorType:n,colorValue:r}=_(this,nS),a=M(this,Ll,document.createElement("input"));return a.type="color",a.value=r||"#000000",a.className="basicColorPicker",a.tabIndex=0,a.setAttribute("data-l10n-id",_(em,rS)[e]),a.addEventListener("input",()=>{_(this,t_).updateParams(n,a.value)},{signal:_(this,t_)._signal}),a}update(e){_(this,Ll)&&(_(this,Ll).value=e)}destroy(){var e;(e=_(this,Ll))==null||e.remove(),M(this,Ll,null)}hideDropdown(){}};Ll=new WeakMap,nS=new WeakMap,t_=new WeakMap,rS=new WeakMap,Y(em,rS,null);let FA=em;function mae(t){return Math.floor(Math.max(0,Math.min(1,t))*255).toString(16).padStart(2,"0")}function K0(t){return Math.max(0,Math.min(255,255*t))}class hae{static CMYK_G([e,n,r,a]){return["G",1-Math.min(1,.3*e+.59*r+.11*n+a)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=K0(e),[e,e,e]}static G_HTML([e]){const n=mae(e);return`#${n}${n}${n}`}static RGB_G([e,n,r]){return["G",.3*e+.59*n+.11*r]}static RGB_rgb(e){return e.map(K0)}static RGB_HTML(e){return`#${e.map(mae).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,n,r,a]){return["RGB",1-Math.min(1,e+a),1-Math.min(1,r+a),1-Math.min(1,n+a)]}static CMYK_rgb([e,n,r,a]){return[K0(1-Math.min(1,e+a)),K0(1-Math.min(1,r+a)),K0(1-Math.min(1,n+a))]}static CMYK_HTML(e){const n=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(n)}static RGB_CMYK([e,n,r]){const a=1-e,i=1-n,s=1-r,o=Math.min(a,i,s);return["CMYK",a,i,s,o]}}class E7e{create(e,n,r=!1){if(e<=0||n<=0)throw new Error("Invalid SVG dimensions");const a=this._createSVG("svg:svg");return a.setAttribute("version","1.1"),r||(a.setAttribute("width",`${e}px`),a.setAttribute("height",`${n}px`)),a.setAttribute("preserveAspectRatio","none"),a.setAttribute("viewBox",`0 0 ${e} ${n}`),a}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Qn("Abstract method `_createSVG` called.")}}class X0 extends E7e{_createSVG(e){return document.createElementNS(vc,e)}}const S7e=9,lf=new WeakSet,y7e=new Date().getTimezoneOffset()*60*1e3;class gae{static create(e){switch(e.data.annotationType){case Yr.LINK:return new SF(e);case Yr.TEXT:return new T7e(e);case Yr.WIDGET:switch(e.data.fieldType){case"Tx":return new A7e(e);case"Btn":return e.data.radioButton?new _ae(e):e.data.checkBox?new R7e(e):new N7e(e);case"Ch":return new w7e(e);case"Sig":return new C7e(e)}return new cf(e);case Yr.POPUP:return new yF(e);case Yr.FREETEXT:return new bae(e);case Yr.LINE:return new O7e(e);case Yr.SQUARE:return new I7e(e);case Yr.CIRCLE:return new D7e(e);case Yr.POLYLINE:return new Eae(e);case Yr.CARET:return new M7e(e);case Yr.INK:return new vF(e);case Yr.POLYGON:return new k7e(e);case Yr.HIGHLIGHT:return new Sae(e);case Yr.UNDERLINE:return new L7e(e);case Yr.SQUIGGLY:return new P7e(e);case Yr.STRIKEOUT:return new F7e(e);case Yr.STAMP:return new yae(e);case Yr.FILEATTACHMENT:return new B7e(e);default:return new wr(e)}}}const GF=class GF{constructor(e,{isRenderable:n=!1,ignoreBorder:r=!1,createQuadrilaterals:a=!1}={}){Y(this,aS);Y(this,tm,null);Y(this,n_,!1);Y(this,Xs,null);this.isRenderable=n,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableComment=e.enableComment,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,n&&(this.container=this._createContainer(r)),a&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:n}){return!!(e!=null&&e.str||n!=null&&n.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return GF._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var r;const{data:e}=this,n=(r=this.annotationStorage)==null?void 0:r.getEditor(e.id);return n?n.getData():e}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var o;const e=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(e)return e.commentButtonPositionInPage;const{quadPoints:n,inkLists:r,rect:a}=this.data;let i=-1/0,s=-1/0;if((n==null?void 0:n.length)>=8){for(let l=0;l<n.length;l+=8)n[l+1]>s?(s=n[l+1],i=n[l+2]):n[l+1]===s&&(i=Math.max(i,n[l+2]));return[i,s]}if((r==null?void 0:r.length)>=1){for(const l of r)for(let u=0,p=l.length;u<p;u+=2)l[u+1]>s?(s=l[u+1],i=l[u]):l[u+1]===s&&(i=Math.max(i,l[u]));if(i!==1/0)return[i,s]}return a?[a[2],a[3]]:null}_normalizePoint(e){const{page:{view:n},viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:i,pageY:s}}}=this.parent;return e[1]=n[3]-e[1]+n[1],e[0]=100*(e[0]-i)/r,e[1]=100*(e[1]-s)/a,e}get commentText(){var n,r,a;const{data:e}=this;return((r=(n=this.annotationStorage.getRawValue(`${O0}${e.id}`))==null?void 0:n.popup)==null?void 0:r.contents)||((a=e.contentsObj)==null?void 0:a.str)||""}set commentText(e){const{data:n}=this,r={deleted:!e,contents:e||""};this.annotationStorage.updateEditor(n.id,{popup:r})||this.annotationStorage.setValue(`${O0}${n.id}`,{id:n.id,annotationType:n.annotationType,pageIndex:this.parent.page._pageIndex,popup:r,popupRef:n.popupRef,modificationDate:new Date}),e||this.removePopup()}removePopup(){var e,n;(n=((e=_(this,Xs))==null?void 0:e.popup)||this.popup)==null||n.remove(),M(this,Xs,this.popup=null)}updateEdited(e){var i;if(!this.container)return;e.rect&&(_(this,tm)||M(this,tm,{rect:this.data.rect.slice(0)}));const{rect:n,popup:r}=e;n&&K(this,aS,_6).call(this,n);let a=((i=_(this,Xs))==null?void 0:i.popup)||this.popup;!a&&(r!=null&&r.text)&&(this._createPopup(r),a=_(this,Xs).popup),a&&(a.updateEdited(e),r!=null&&r.deleted&&(a.remove(),M(this,Xs,null),this.popup=null))}resetEdited(){var e;_(this,tm)&&(K(this,aS,_6).call(this,_(this,tm).rect),(e=_(this,Xs))==null||e.popup.resetEdited(),M(this,tm,null))}_createContainer(e){const{data:n,parent:{page:r,viewport:a}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",n.id),!(this instanceof cf)&&!(this instanceof SF)&&(i.tabIndex=0);const{style:s}=i;if(s.zIndex=this.parent.zIndex,this.parent.zIndex+=2,n.alternativeText&&(i.title=n.alternativeText),n.noRotate&&i.classList.add("norotate"),!n.rect||this instanceof yF){const{rotation:E}=n;return!n.hasOwnCanvas&&E!==0&&this.setRotation(E,i),i}const{width:o,height:l}=this;if(!e&&n.borderStyle.width>0){s.borderWidth=`${n.borderStyle.width}px`;const E=n.borderStyle.horizontalCornerRadius,y=n.borderStyle.verticalCornerRadius;if(E>0||y>0){const A=`calc(${E}px * var(--total-scale-factor)) / calc(${y}px * var(--total-scale-factor))`;s.borderRadius=A}else if(this instanceof _ae){const A=`calc(${o}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;s.borderRadius=A}switch(n.borderStyle.style){case Yh.SOLID:s.borderStyle="solid";break;case Yh.DASHED:s.borderStyle="dashed";break;case Yh.BEVELED:It("Unimplemented border style: beveled");break;case Yh.INSET:It("Unimplemented border style: inset");break;case Yh.UNDERLINE:s.borderBottomStyle="solid";break}const v=n.borderColor||null;v?(M(this,n_,!0),s.borderColor=Je.makeHexColor(v[0]|0,v[1]|0,v[2]|0)):s.borderWidth=0}const u=Je.normalizeRect([n.rect[0],r.view[3]-n.rect[1]+r.view[1],n.rect[2],r.view[3]-n.rect[3]+r.view[1]]),{pageWidth:p,pageHeight:f,pageX:m,pageY:g}=a.rawDims;s.left=`${100*(u[0]-m)/p}%`,s.top=`${100*(u[1]-g)/f}%`;const{rotation:S}=n;return n.hasOwnCanvas||S===0?(s.width=`${100*o/p}%`,s.height=`${100*l/f}%`):this.setRotation(S,i),i}setRotation(e,n=this.container){if(!this.data.rect)return;const{pageWidth:r,pageHeight:a}=this.parent.viewport.rawDims;let{width:i,height:s}=this;e%180!==0&&([i,s]=[s,i]),n.style.width=`${100*i/r}%`,n.style.height=`${100*s/a}%`,n.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(n,r,a)=>{const i=a.detail[n],s=i[0],o=i.slice(1);a.target.style[r]=hae[`${s}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[r]:hae[`${s}_rgb`](o)})};return qt(this,"_commonActions",{display:n=>{const{display:r}=n.detail,a=r%2===1;this.container.style.visibility=a?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:a,noPrint:r===1||r===2})},print:n=>{this.annotationStorage.setValue(this.data.id,{noPrint:!n.detail.print})},hidden:n=>{const{hidden:r}=n.detail;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:r,noView:r})},focus:n=>{setTimeout(()=>n.target.focus({preventScroll:!1}),0)},userName:n=>{n.target.title=n.detail.userName},readonly:n=>{n.target.disabled=n.detail.readonly},required:n=>{this._setRequired(n.target,n.detail.required)},bgColor:n=>{e("bgColor","backgroundColor",n)},fillColor:n=>{e("fillColor","backgroundColor",n)},fgColor:n=>{e("fgColor","color",n)},textColor:n=>{e("textColor","color",n)},borderColor:n=>{e("borderColor","borderColor",n)},strokeColor:n=>{e("strokeColor","borderColor",n)},rotation:n=>{const r=n.detail.rotation;this.setRotation(r),this.annotationStorage.setValue(this.data.id,{rotation:r})}})}_dispatchEventFromSandbox(e,n){const r=this._commonActions;for(const a of Object.keys(n.detail)){const i=e[a]||r[a];i==null||i(n)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const n=this.annotationStorage.getRawValue(this.data.id);if(!n)return;const r=this._commonActions;for(const[a,i]of Object.entries(n)){const s=r[a];if(s){const o={detail:{[a]:i},target:e};s(o),delete n[a]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[n,r,a,i]=this.data.rect.map(E=>Math.fround(E));if(e.length===8){const[E,y,v,A]=e.subarray(2,6);if(a===E&&i===y&&n===v&&r===A)return}const{style:s}=this.container;let o;if(_(this,n_)){const{borderColor:E,borderWidth:y}=s;s.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${E}" stroke-width="${y}">`],this.container.classList.add("hasBorder")}const l=a-n,u=i-r,{svgFactory:p}=this,f=p.createElement("svg");f.classList.add("quadrilateralsContainer"),f.setAttribute("width",0),f.setAttribute("height",0),f.role="none";const m=p.createElement("defs");f.append(m);const g=p.createElement("clipPath"),S=`clippath_${this.data.id}`;g.setAttribute("id",S),g.setAttribute("clipPathUnits","objectBoundingBox"),m.append(g);for(let E=2,y=e.length;E<y;E+=8){const v=e[E],A=e[E+1],T=e[E+2],w=e[E+3],O=p.createElement("rect"),R=(T-n)/l,I=(i-A)/u,L=(v-T)/l,P=(A-w)/u;O.setAttribute("x",R),O.setAttribute("y",I),O.setAttribute("width",L),O.setAttribute("height",P),g.append(O),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${R}" y="${I}" width="${L}" height="${P}"/>`)}_(this,n_)&&(o.push("</g></svg>')"),s.backgroundImage=o.join("")),this.container.append(f),this.container.style.clipPath=`url(#${S})`}_createPopup(e=null){const{data:n}=this;let r,a;e?(r={str:e.text},a=e.date):(r=n.contentsObj,a=n.modificationDate);const i=M(this,Xs,new yF({data:{color:n.color,titleObj:n.titleObj,modificationDate:a,contentsObj:r,richText:n.richText,parentRect:n.rect,borderStyle:0,id:`popup_${n.id}`,rotation:n.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent._commentManager||this.parent.div.append(i.render())}get hasPopupElement(){return!!(_(this,Xs)||this.popup||this.data.popupRef)}get extraPopupElement(){return _(this,Xs)}render(){Qn("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,n=null){const r=[];if(this._fieldObjects){const a=this._fieldObjects[e];if(a)for(const{page:i,id:s,exportValues:o}of a){if(i===-1||s===n)continue;const l=typeof o=="string"?o:null,u=document.querySelector(`[data-element-id="${s}"]`);if(u&&!lf.has(u)){It(`_getElementsByName - element not allowed: ${s}`);continue}r.push({id:s,exportValue:l,domElement:u})}return r}for(const a of document.getElementsByName(e)){const{exportValue:i}=a,s=a.getAttribute("data-element-id");s!==n&&lf.has(a)&&r.push({id:s,exportValue:i,domElement:a})}return r}show(){var e;this.container&&(this.container.hidden=!1),(e=this.popup)==null||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),(e=this.popup)==null||e.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const n of e)n.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:n}}=this;this.container.addEventListener("dblclick",()=>{var r;(r=this.linkService.eventBus)==null||r.dispatch("switchannotationeditormode",{source:this,mode:e,editId:n,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};tm=new WeakMap,n_=new WeakMap,Xs=new WeakMap,aS=new WeakSet,_6=function(e){const{container:{style:n},data:{rect:r,rotation:a},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:o,pageY:l}}}}=this;r==null||r.splice(0,4,...e),n.left=`${100*(e[0]-o)/i}%`,n.top=`${100*(s-e[3]+l)/s}%`,a===0?(n.width=`${100*(e[2]-e[0])/i}%`,n.height=`${100*(e[3]-e[1])/s}%`):this.setRotation(a)};let wr=GF;class v7e extends wr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.editor=e.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:e}=this;e.hasComment&&(this._createPopup(e.comment),this.extraPopupElement.popup.renderCommentButton())}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(e){this.editor.comment=e,e||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}class SF extends wr{constructor(n,r=null){super(n,{isRenderable:!0,ignoreBorder:!!(r!=null&&r.ignoreBorder),createQuadrilaterals:!0});Y(this,fs);this.isTooltipOnly=n.data.isTooltipOnly}render(){const{data:n,linkService:r}=this,a=document.createElement("a");a.setAttribute("data-element-id",n.id);let i=!1;return n.url?(r.addLinkAttributes(a,n.url,n.newWindow),i=!0):n.action?(this._bindNamedAction(a,n.action,n.overlaidText),i=!0):n.attachment?(K(this,fs,uce).call(this,a,n.attachment,n.overlaidText,n.attachmentDest),i=!0):n.setOCGState?(K(this,fs,dce).call(this,a,n.setOCGState,n.overlaidText),i=!0):n.dest?(this._bindLink(a,n.dest,n.overlaidText),i=!0):(n.actions&&(n.actions.Action||n.actions["Mouse Up"]||n.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(a,n),i=!0),n.resetForm?(this._bindResetFormAction(a,n.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(a,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(a),this.container}_bindLink(n,r,a=""){n.href=this.linkService.getDestinationHash(r),n.onclick=()=>(r&&this.linkService.goToDestination(r),!1),(r||r==="")&&K(this,fs,jm).call(this),a&&(n.title=a)}_bindNamedAction(n,r,a=""){n.href=this.linkService.getAnchorUrl(""),n.onclick=()=>(this.linkService.executeNamedAction(r),!1),a&&(n.title=a),K(this,fs,jm).call(this)}_bindJSAction(n,r){n.href=this.linkService.getAnchorUrl("");const a=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(r.actions)){const s=a.get(i);s&&(n[s]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r.id,name:i}}),!1})}r.overlaidText&&(n.title=r.overlaidText),n.onclick||(n.onclick=()=>!1),K(this,fs,jm).call(this)}_bindResetFormAction(n,r){const a=n.onclick;if(a||(n.href=this.linkService.getAnchorUrl("")),K(this,fs,jm).call(this),!this._fieldObjects){It('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),a||(n.onclick=()=>!1);return}n.onclick=()=>{var f;a==null||a();const{fields:i,refs:s,include:o}=r,l=[];if(i.length!==0||s.length!==0){const m=new Set(s);for(const g of i){const S=this._fieldObjects[g]||[];for(const{id:E}of S)m.add(E)}for(const g of Object.values(this._fieldObjects))for(const S of g)m.has(S.id)===o&&l.push(S)}else for(const m of Object.values(this._fieldObjects))l.push(...m);const u=this.annotationStorage,p=[];for(const m of l){const{id:g}=m;switch(p.push(g),m.type){case"text":{const E=m.defaultValue||"";u.setValue(g,{value:E});break}case"checkbox":case"radiobutton":{const E=m.defaultValue===m.exportValues;u.setValue(g,{value:E});break}case"combobox":case"listbox":{const E=m.defaultValue||"";u.setValue(g,{value:E});break}default:continue}const S=document.querySelector(`[data-element-id="${g}"]`);if(S){if(!lf.has(S)){It(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;S.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((f=this.linkService.eventBus)==null||f.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:p,name:"ResetForm"}})),!1}}}fs=new WeakSet,jm=function(){this.container.setAttribute("data-internal-link","")},uce=function(n,r,a="",i=null){n.href=this.linkService.getAnchorUrl(""),r.description?n.title=r.description:a&&(n.title=a),n.onclick=()=>{var s;return(s=this.downloadManager)==null||s.openOrDownloadData(r.content,r.filename,i),!1},K(this,fs,jm).call(this)},dce=function(n,r,a=""){n.href=this.linkService.getAnchorUrl(""),n.onclick=()=>(this.linkService.executeSetOCGState(r),!1),a&&(n.title=a),K(this,fs,jm).call(this)};class T7e extends wr{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class cf extends wr{render(){return this.container}showElementAndHideCanvas(e){var n;this.data.hasOwnCanvas&&(((n=e.previousSibling)==null?void 0:n.nodeName)==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return Ea.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,n,r,a,i){r.includes("mouse")?e.addEventListener(r,s=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:i(s),shift:s.shiftKey,modifier:this._getKeyModifier(s)}})}):e.addEventListener(r,s=>{var o;if(r==="blur"){if(!n.focused||!s.relatedTarget)return;n.focused=!1}else if(r==="focus"){if(n.focused)return;n.focused=!0}i&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:i(s)}}))})}_setEventListeners(e,n,r,a){var i,s,o;for(const[l,u]of r)(u==="Action"||(i=this.data.actions)!=null&&i[u])&&((u==="Focus"||u==="Blur")&&(n||(n={focused:!1})),this._setEventListener(e,n,l,u,a),u==="Focus"&&!((s=this.data.actions)!=null&&s.Blur)?this._setEventListener(e,n,"blur","Blur",null):u==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(e,n,"focus","Focus",null))}_setBackgroundColor(e){const n=this.data.backgroundColor||null;e.style.backgroundColor=n===null?"transparent":Je.makeHexColor(n[0],n[1],n[2])}_setTextStyle(e){const n=["left","center","right"],{fontColor:r}=this.data.defaultAppearanceData,a=this.data.defaultAppearanceData.fontSize||S7e,i=e.style;let s;const o=2,l=u=>Math.round(10*u)/10;if(this.data.multiLine){const u=Math.abs(this.data.rect[3]-this.data.rect[1]-o),p=Math.round(u/(H3*a))||1,f=u/p;s=Math.min(a,l(f/H3))}else{const u=Math.abs(this.data.rect[3]-this.data.rect[1]-o);s=Math.min(a,l(u/H3))}i.fontSize=`calc(${s}px * var(--total-scale-factor))`,i.color=Je.makeHexColor(r[0],r[1],r[2]),this.data.textAlignment!==null&&(i.textAlign=n[this.data.textAlignment])}_setRequired(e,n){n?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",n)}}class A7e extends cf{constructor(e){const n=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:n})}setPropertyOnSiblings(e,n,r,a){const i=this.annotationStorage;for(const s of this._getElementsByName(e.name,e.id))s.domElement&&(s.domElement[n]=r),i.setValue(s.id,{[a]:r})}render(){var a,i;const e=this.annotationStorage,n=this.data.id;this.container.classList.add("textWidgetAnnotation");let r=null;if(this.renderForms){const s=e.getValue(n,{value:this.data.fieldValue});let o=s.value||"";const l=e.getValue(n,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let u=s.formattedValue||((a=this.data.textContent)==null?void 0:a.join(`
623
+ `);return e.join("")}}function B0(t,e){const n=e?URL.parse(t,e):URL.parse(t);return(n==null?void 0:n.protocol)==="http:"||(n==null?void 0:n.protocol)==="https:"}function as(t){t.preventDefault()}function Rr(t){t.preventDefault(),t.stopPropagation()}function fUe(t){console.log("Deprecated API usage: "+t)}class U0{static toDateObject(e){if(e instanceof Date)return e;if(!e||typeof e!="string")return null;_(this,eE)||M(this,eE,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const n=_(this,eE).exec(e);if(!n)return null;const r=parseInt(n[1],10);let a=parseInt(n[2],10);a=a>=1&&a<=12?a-1:0;let i=parseInt(n[3],10);i=i>=1&&i<=31?i:1;let s=parseInt(n[4],10);s=s>=0&&s<=23?s:0;let o=parseInt(n[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(n[6],10);l=l>=0&&l<=59?l:0;const u=n[7]||"Z";let p=parseInt(n[8],10);p=p>=0&&p<=23?p:0;let f=parseInt(n[9],10)||0;return f=f>=0&&f<=59?f:0,u==="-"?(s+=p,o+=f):u==="+"&&(s-=p,o-=f),new Date(Date.UTC(r,a,i,s,o,l))}}eE=new WeakMap,Y(U0,eE);function Rre(t,{scale:e=1,rotation:n=0}){const{width:r,height:a}=t.attributes.style,i=[0,0,parseInt(r),parseInt(a)];return new P0({viewBox:i,userUnit:1,scale:e,rotation:n})}function jh(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(e&16711680)>>16,(e&65280)>>8,e&255]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(e=>parseInt(e)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(e=>parseInt(e)).slice(0,3):(It(`Not a valid color format: "${t}"`),[0,0,0])}function mUe(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const n of t.keys()){e.style.color=n;const r=window.getComputedStyle(e).color;t.set(n,jh(r))}e.remove()}function Nr(t){const{a:e,b:n,c:r,d:a,e:i,f:s}=t.getTransform();return[e,n,r,a,i,s]}function bl(t){const{a:e,b:n,c:r,d:a,e:i,f:s}=t.getTransform().invertSelf();return[e,n,r,a,i,s]}function od(t,e,n=!1,r=!0){if(e instanceof P0){const{pageWidth:a,pageHeight:i}=e.rawDims,{style:s}=t,o=Ea.isCSSRoundSupported,l=`var(--total-scale-factor) * ${a}px`,u=`var(--total-scale-factor) * ${i}px`,p=o?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,f=o?`round(down, ${u}, var(--scale-round-y))`:`calc(${u})`;!n||e.rotation%180===0?(s.width=p,s.height=f):(s.width=f,s.height=p)}r&&t.setAttribute("data-main-rotation",e.rotation)}class Oo{constructor(){const{pixelRatio:e}=Oo;this.sx=e,this.sy=e}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(e,n,r,a,i=-1){let s=1/0,o=1/0,l=1/0;r=Oo.capPixels(r,i),r>0&&(s=Math.sqrt(r/(e*n))),a!==-1&&(o=a/e,l=a/n);const u=Math.min(s,o,l);return this.sx>u||this.sy>u?(this.sx=u,this.sy=u,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,n){if(n>=0){const r=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+n/100));return e>0?Math.min(e,r):r}return e}}const AA=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class hUe{static get isDarkMode(){var e;return qt(this,"isDarkMode",!!((e=window==null?void 0:window.matchMedia)!=null&&e.call(window,"(prefers-color-scheme: dark)").matches))}}class Nre{static get commentForegroundColor(){const e=document.createElement("span");e.classList.add("comment","sidebar");const{style:n}=e;n.width=n.height="0",n.display="none",n.color="var(--comment-fg-color)",document.body.append(e);const{color:r}=window.getComputedStyle(e);return e.remove(),qt(this,"commentForegroundColor",jh(r))}}function wre(t,e,n,r){r=Math.min(Math.max(r??1,0),1);const a=255*(1-r);return t=Math.round(t*r+a),e=Math.round(e*r+a),n=Math.round(n*r+a),[t,e,n]}function xre(t,e){const n=t[0]/255,r=t[1]/255,a=t[2]/255,i=Math.max(n,r,a),s=Math.min(n,r,a),o=(i+s)/2;if(i===s)e[0]=e[1]=0;else{const l=i-s;switch(e[1]=o<.5?l/(i+s):l/(2-i-s),i){case n:e[0]=((r-a)/l+(r<a?6:0))*60;break;case r:e[0]=((a-n)/l+2)*60;break;case a:e[0]=((n-r)/l+4)*60;break}}e[2]=o}function Z3(t,e){const n=t[0],r=t[1],a=t[2],i=(1-Math.abs(2*a-1))*r,s=i*(1-Math.abs(n/60%2-1)),o=a-i/2;switch(Math.floor(n/60)){case 0:e[0]=i+o,e[1]=s+o,e[2]=o;break;case 1:e[0]=s+o,e[1]=i+o,e[2]=o;break;case 2:e[0]=o,e[1]=i+o,e[2]=s+o;break;case 3:e[0]=o,e[1]=s+o,e[2]=i+o;break;case 4:e[0]=s+o,e[1]=o,e[2]=i+o;break;case 5:case 6:e[0]=i+o,e[1]=o,e[2]=s+o;break}}function Ore(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Ire(t,e,n){Z3(t,n),n.map(Ore);const r=.2126*n[0]+.7152*n[1]+.0722*n[2];Z3(e,n),n.map(Ore);const a=.2126*n[0]+.7152*n[1]+.0722*n[2];return r>a?(r+.05)/(a+.05):(a+.05)/(r+.05)}const Dre=new Map;function kre(t,e){const n=t[0]+t[1]*256+t[2]*65536+e[0]*16777216+e[1]*4294967296+e[2]*1099511627776;let r=Dre.get(n);if(r)return r;const a=new Float32Array(9),i=a.subarray(0,3),s=a.subarray(3,6);xre(t,s);const o=a.subarray(6,9);xre(e,o);const l=o[2]<.5,u=l?12:4.5;if(s[2]=l?Math.sqrt(s[2]):1-Math.sqrt(1-s[2]),Ire(s,o,i)<u){let p,f;l?(p=s[2],f=1):(p=0,f=s[2]);const m=.005;for(;f-p>m;){const g=s[2]=(p+f)/2;l===Ire(s,o,i)<u?p=g:f=g}s[2]=l?f:p}return Z3(s,i),r=Je.makeHexColor(Math.round(i[0]*255),Math.round(i[1]*255),Math.round(i[2]*255)),Dre.set(n,r),r}function J3({html:t,dir:e,className:n},r){const a=document.createDocumentFragment();if(typeof t=="string"){const i=document.createElement("p");i.dir=e||"auto";const s=t.split(/(?:\r\n?|\n)/);for(let o=0,l=s.length;o<l;++o){const u=s[o];i.append(document.createTextNode(u)),o<l-1&&i.append(document.createElement("br"))}a.append(i)}else Q3.render({xfaHtml:t,div:a,intent:"richText"});a.firstChild.classList.add("richText",n),r.append(a)}const Cc=class Cc{constructor(e){Y(this,ka);Y(this,cd,null);Y(this,ud,null);Y(this,zs);Y(this,qs,null);Y(this,tE,null);Y(this,dd,null);Y(this,rg,null);Y(this,ag,null);M(this,zs,e),_(Cc,nE)||M(Cc,nE,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=M(this,cd,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const n=_(this,zs)._uiManager._signal;n instanceof AbortSignal&&!n.aborted&&(e.addEventListener("contextmenu",as,{signal:n}),e.addEventListener("pointerdown",K(Cc,KA,Ale),{signal:n}));const r=M(this,qs,document.createElement("div"));r.className="buttons",e.append(r);const a=_(this,zs).toolbarPosition;if(a){const{style:i}=e,s=_(this,zs)._uiManager.direction==="ltr"?1-a[0]:a[0];i.insetInlineEnd=`${100*s}%`,i.top=`calc(${100*a[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return _(this,cd)}hide(){var e;_(this,cd).classList.add("hidden"),(e=_(this,ud))==null||e.hideDropdown()}show(){var e,n;_(this,cd).classList.remove("hidden"),(e=_(this,tE))==null||e.shown(),(n=_(this,dd))==null||n.shown()}addDeleteButton(){const{editorType:e,_uiManager:n}=_(this,zs),r=document.createElement("button");r.classList.add("basic","deleteButton"),r.tabIndex=0,r.setAttribute("data-l10n-id",_(Cc,nE)[e]),K(this,ka,pb).call(this,r)&&r.addEventListener("click",a=>{n.delete()},{signal:n._signal}),_(this,qs).append(r)}async addAltText(e){const n=await e.render();K(this,ka,pb).call(this,n),_(this,qs).append(n,_(this,ka,vy)),M(this,tE,e)}addComment(e,n=null){if(_(this,dd))return;const r=e.renderForToolbar();if(!r)return;K(this,ka,pb).call(this,r);const a=M(this,rg,_(this,ka,vy));n?(_(this,qs).insertBefore(r,n),_(this,qs).insertBefore(a,n)):_(this,qs).append(r,a),M(this,dd,e),e.toolbar=this}addColorPicker(e){if(_(this,ud))return;M(this,ud,e);const n=e.renderButton();K(this,ka,pb).call(this,n),_(this,qs).append(n,_(this,ka,vy))}async addEditSignatureButton(e){const n=M(this,ag,await e.renderEditButton(_(this,zs)));K(this,ka,pb).call(this,n),_(this,qs).append(n,_(this,ka,vy))}removeButton(e){var n,r;switch(e){case"comment":(n=_(this,dd))==null||n.removeToolbarCommentButton(),M(this,dd,null),(r=_(this,rg))==null||r.remove(),M(this,rg,null);break}}async addButton(e,n){switch(e){case"colorPicker":this.addColorPicker(n);break;case"altText":await this.addAltText(n);break;case"editSignature":await this.addEditSignatureButton(n);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(n);break}}async addButtonBefore(e,n,r){const a=_(this,qs).querySelector(r);a&&e==="comment"&&this.addComment(n,a)}updateEditSignatureButton(e){_(this,ag)&&(_(this,ag).title=e)}remove(){var e;_(this,cd).remove(),(e=_(this,ud))==null||e.destroy(),M(this,ud,null)}};cd=new WeakMap,ud=new WeakMap,zs=new WeakMap,qs=new WeakMap,tE=new WeakMap,dd=new WeakMap,rg=new WeakMap,ag=new WeakMap,nE=new WeakMap,KA=new WeakSet,Ale=function(e){e.stopPropagation()},ka=new WeakSet,Cle=function(e){_(this,zs)._focusEventsAllowed=!1,Rr(e)},Rle=function(e){_(this,zs)._focusEventsAllowed=!0,Rr(e)},pb=function(e){const n=_(this,zs)._uiManager._signal;return!(n instanceof AbortSignal)||n.aborted?!1:(e.addEventListener("focusin",K(this,ka,Cle).bind(this),{capture:!0,signal:n}),e.addEventListener("focusout",K(this,ka,Rle).bind(this),{capture:!0,signal:n}),e.addEventListener("contextmenu",as,{signal:n}),!0)},vy=function(){const e=document.createElement("div");return e.className="divider",e},Y(Cc,KA),Y(Cc,nE,null);let eF=Cc;class gUe{constructor(e){Y(this,Nc);Y(this,rE,null);Y(this,ff,null);Y(this,Rc);M(this,Rc,e)}show(e,n,r){const[a,i]=K(this,Nc,wle).call(this,n,r),{style:s}=_(this,ff)||M(this,ff,K(this,Nc,Nle).call(this));e.append(_(this,ff)),s.insetInlineEnd=`${100*a}%`,s.top=`calc(${100*i}% + var(--editor-toolbar-vert-offset))`}hide(){_(this,ff).remove()}}rE=new WeakMap,ff=new WeakMap,Rc=new WeakMap,Nc=new WeakSet,Nle=function(){const e=M(this,ff,document.createElement("div"));e.className="editToolbar",e.setAttribute("role","toolbar");const n=_(this,Rc)._signal;n instanceof AbortSignal&&!n.aborted&&e.addEventListener("contextmenu",as,{signal:n});const r=M(this,rE,document.createElement("div"));return r.className="buttons",e.append(r),_(this,Rc).hasCommentManager()&&K(this,Nc,HB).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{_(this,Rc).commentSelection("floating_button")}),K(this,Nc,HB).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{_(this,Rc).highlightSelection("floating_button")}),e},wle=function(e,n){let r=0,a=0;for(const i of e){const s=i.y+i.height;if(s<r)continue;const o=i.x+(n?i.width:0);if(s>r){a=o,r=s;continue}n?o>a&&(a=o):o<a&&(a=o)}return[n?1-a:a,r]},HB=function(e,n,r,a){const i=document.createElement("button");i.classList.add("basic",e),i.tabIndex=0,i.setAttribute("data-l10n-id",n);const s=document.createElement("span");i.append(s),s.className="visuallyHidden",s.setAttribute("data-l10n-id",r);const o=_(this,Rc)._signal;o instanceof AbortSignal&&!o.aborted&&(i.addEventListener("contextmenu",as,{signal:o}),i.addEventListener("click",a,{signal:o})),_(this,rE).append(i)};function Mre(t,e,n){for(const r of n)e.addEventListener(r,t[r].bind(t))}class _Ue{constructor(){Y(this,XA,0)}get id(){return`${O0}${_a(this,XA)._++}`}}XA=new WeakMap;const PF=class PF{constructor(){Y(this,sg);Y(this,ig,K3());Y(this,aE,0);Y(this,Qa,null)}static get _isSVGFittingCanvas(){const e='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',r=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),a=new Image;a.src=e;const i=a.decode().then(()=>(r.drawImage(a,0,0,1,1,0,0,1,3),new Uint32Array(r.getImageData(0,0,1,1).data.buffer)[0]===0));return qt(this,"_isSVGFittingCanvas",i)}async getFromFile(e){const{lastModified:n,name:r,size:a,type:i}=e;return K(this,sg,TR).call(this,`${n}_${r}_${a}_${i}`,e)}async getFromUrl(e){return K(this,sg,TR).call(this,e,e)}async getFromBlob(e,n){const r=await n;return K(this,sg,TR).call(this,e,r)}async getFromId(e){_(this,Qa)||M(this,Qa,new Map);const n=_(this,Qa).get(e);if(!n)return null;if(n.bitmap)return n.refCounter+=1,n;if(n.file)return this.getFromFile(n.file);if(n.blobPromise){const{blobPromise:r}=n;return delete n.blobPromise,this.getFromBlob(n.id,r)}return this.getFromUrl(n.url)}getFromCanvas(e,n){_(this,Qa)||M(this,Qa,new Map);let r=_(this,Qa).get(e);if(r!=null&&r.bitmap)return r.refCounter+=1,r;const a=new OffscreenCanvas(n.width,n.height);return a.getContext("2d").drawImage(n,0,0),r={bitmap:a.transferToImageBitmap(),id:`image_${_(this,ig)}_${_a(this,aE)._++}`,refCounter:1,isSvg:!1},_(this,Qa).set(e,r),_(this,Qa).set(r.id,r),r}getSvgUrl(e){const n=_(this,Qa).get(e);return n!=null&&n.isSvg?n.svgUrl:null}deleteId(e){var a;_(this,Qa)||M(this,Qa,new Map);const n=_(this,Qa).get(e);if(!n||(n.refCounter-=1,n.refCounter!==0))return;const{bitmap:r}=n;if(!n.url&&!n.file){const i=new OffscreenCanvas(r.width,r.height);i.getContext("bitmaprenderer").transferFromImageBitmap(r),n.blobPromise=i.convertToBlob()}(a=r.close)==null||a.call(r),n.bitmap=null}isValidId(e){return e.startsWith(`image_${_(this,ig)}_`)}};ig=new WeakMap,aE=new WeakMap,Qa=new WeakMap,sg=new WeakSet,TR=async function(e,n){_(this,Qa)||M(this,Qa,new Map);let r=_(this,Qa).get(e);if(r===null)return null;if(r!=null&&r.bitmap)return r.refCounter+=1,r;try{r||(r={bitmap:null,id:`image_${_(this,ig)}_${_a(this,aE)._++}`,refCounter:0,isSvg:!1});let a;if(typeof n=="string"?(r.url=n,a=await Wh(n,"blob")):n instanceof File?a=r.file=n:n instanceof Blob&&(a=n),a.type==="image/svg+xml"){const i=PF._isSVGFittingCanvas,s=new FileReader,o=new Image,l=new Promise((u,p)=>{o.onload=()=>{r.bitmap=o,r.isSvg=!0,u()},s.onload=async()=>{const f=r.svgUrl=s.result;o.src=await i?`${f}#svgView(preserveAspectRatio(none))`:f},o.onerror=s.onerror=p});s.readAsDataURL(a),await l}else r.bitmap=await createImageBitmap(a);r.refCounter=1}catch(a){It(a),r=null}return _(this,Qa).set(e,r),r&&_(this,Qa).set(r.id,r),r};let tF=PF;class bUe{constructor(e=128){Y(this,Vr,[]);Y(this,pd,!1);Y(this,iE);Y(this,xr,-1);M(this,iE,e)}add({cmd:e,undo:n,post:r,mustExec:a,type:i=NaN,overwriteIfSameType:s=!1,keepUndo:o=!1}){if(a&&e(),_(this,pd))return;const l={cmd:e,undo:n,post:r,type:i};if(_(this,xr)===-1){_(this,Vr).length>0&&(_(this,Vr).length=0),M(this,xr,0),_(this,Vr).push(l);return}if(s&&_(this,Vr)[_(this,xr)].type===i){o&&(l.undo=_(this,Vr)[_(this,xr)].undo),_(this,Vr)[_(this,xr)]=l;return}const u=_(this,xr)+1;u===_(this,iE)?_(this,Vr).splice(0,1):(M(this,xr,u),u<_(this,Vr).length&&_(this,Vr).splice(u)),_(this,Vr).push(l)}undo(){if(_(this,xr)===-1)return;M(this,pd,!0);const{undo:e,post:n}=_(this,Vr)[_(this,xr)];e(),n==null||n(),M(this,pd,!1),M(this,xr,_(this,xr)-1)}redo(){if(_(this,xr)<_(this,Vr).length-1){M(this,xr,_(this,xr)+1),M(this,pd,!0);const{cmd:e,post:n}=_(this,Vr)[_(this,xr)];e(),n==null||n(),M(this,pd,!1)}}hasSomethingToUndo(){return _(this,xr)!==-1}hasSomethingToRedo(){return _(this,xr)<_(this,Vr).length-1}cleanType(e){if(_(this,xr)!==-1){for(let n=_(this,xr);n>=0;n--)if(_(this,Vr)[n].type!==e){_(this,Vr).splice(n+1,_(this,xr)-n),M(this,xr,n);return}_(this,Vr).length=0,M(this,xr,-1)}}destroy(){M(this,Vr,null)}}Vr=new WeakMap,pd=new WeakMap,iE=new WeakMap,xr=new WeakMap;class G0{constructor(e){Y(this,QA);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:n}=Ea.platform;for(const[r,a,i={}]of e)for(const s of r){const o=s.startsWith("mac+");n&&o?(this.callbacks.set(s.slice(4),{callback:a,options:i}),this.allKeys.add(s.split("+").at(-1))):!n&&!o&&(this.callbacks.set(s,{callback:a,options:i}),this.allKeys.add(s.split("+").at(-1)))}}exec(e,n){if(!this.allKeys.has(n.key))return;const r=this.callbacks.get(K(this,QA,xle).call(this,n));if(!r)return;const{callback:a,options:{bubbles:i=!1,args:s=[],checker:o=null}}=r;o&&!o(e,n)||(a.bind(e,...s,n)(),i||Rr(n))}}QA=new WeakSet,xle=function(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const n=this.buffer.join("+");return this.buffer.length=0,n};const ZA=class ZA{get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return mUe(e),qt(this,"_colors",e)}convert(e){const n=jh(e);if(!window.matchMedia("(forced-colors: active)").matches)return n;for(const[r,a]of this._colors)if(a.every((i,s)=>i===n[s]))return ZA._colorsMapping.get(r);return n}getHexCode(e){const n=this._colors.get(e);return n?Je.makeHexColor(...n):e}};Pe(ZA,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let nF=ZA;const _g=class _g{constructor(e,n,r,a,i,s,o,l,u,p,f,m,g,S,E,y){Y(this,We);Y(this,og,new AbortController);Y(this,ss,null);Y(this,lg,null);Y(this,Mr,new Map);Y(this,la,new Map);Y(this,cg,null);Y(this,Hs,null);Y(this,ug,null);Y(this,$s,new bUe);Y(this,Za,null);Y(this,fd,null);Y(this,md,null);Y(this,dg,0);Y(this,hd,new Set);Y(this,yl,null);Y(this,Ys,null);Y(this,mf,new Set);Pe(this,"_editorUndoBar",null);Y(this,sE,!1);Y(this,oE,!1);Y(this,pg,!1);Y(this,lE,null);Y(this,vl,null);Y(this,gd,null);Y(this,fg,null);Y(this,_d,!1);Y(this,Tl,null);Y(this,JA,new _Ue);Y(this,bd,!1);Y(this,mg,!1);Y(this,cE,!1);Y(this,Ed,null);Y(this,hf,null);Y(this,hg,null);Y(this,Sd,null);Y(this,uE,null);Y(this,ea,Ot.NONE);Y(this,Dn,new Set);Y(this,wc,null);Y(this,yd,null);Y(this,vd,null);Y(this,dE,null);Y(this,gg,null);Y(this,pE,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});Y(this,Td,[0,0]);Y(this,Al,null);Y(this,xc,null);Y(this,fE,null);Y(this,mE,null);Y(this,Vs,null);const v=this._signal=_(this,og).signal;M(this,xc,e),M(this,fE,n),M(this,mE,r),M(this,cg,a),M(this,Za,i),M(this,yd,s),M(this,gg,l),this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:v}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:v}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:v}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:v}),o._on("setpreference",this.onSetPreference.bind(this),{signal:v}),o._on("switchannotationeditorparams",A=>this.updateParams(A.type,A.value),{signal:v}),window.addEventListener("pointerdown",()=>{M(this,mg,!0)},{capture:!0,signal:v}),window.addEventListener("pointerup",()=>{M(this,mg,!1)},{capture:!0,signal:v}),K(this,We,Dle).call(this),K(this,We,Ple).call(this),K(this,We,YB).call(this),M(this,Hs,l.annotationStorage),M(this,lE,l.filterFactory),M(this,vd,u),M(this,fg,p||null),M(this,sE,f),M(this,oE,m),M(this,pg,g),M(this,uE,S||null),this.viewParameters={realScale:Tc.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=E||null,this._supportsPinchToZoom=y!==!1,i==null||i.setSidebarUiManager(this)}static get _keyboardManager(){const e=_g.prototype,n=s=>_(s,xc).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&s.hasSomethingToControl(),r=(s,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},a=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return qt(this,"_keyboardManager",new G0([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:r}],[["ctrl+z","mac+meta+z"],e.undo,{checker:r}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:r}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:r}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(s,{target:o})=>!(o instanceof HTMLButtonElement)&&_(s,xc).contains(o)&&!s.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(s,{target:o})=>!(o instanceof HTMLButtonElement)&&_(s,xc).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:n}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:n}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:n}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:n}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:n}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:n}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:n}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:n}]]))}destroy(){var e,n,r,a,i,s,o,l,u;(e=_(this,Vs))==null||e.resolve(),M(this,Vs,null),(n=_(this,og))==null||n.abort(),M(this,og,null),this._signal=null;for(const p of _(this,la).values())p.destroy();_(this,la).clear(),_(this,Mr).clear(),_(this,mf).clear(),(r=_(this,Sd))==null||r.clear(),M(this,ss,null),_(this,Dn).clear(),_(this,$s).destroy(),(a=_(this,cg))==null||a.destroy(),(i=_(this,Za))==null||i.destroy(),(s=_(this,yd))==null||s.destroy(),(o=_(this,Tl))==null||o.hide(),M(this,Tl,null),(l=_(this,hg))==null||l.destroy(),M(this,hg,null),M(this,lg,null),_(this,vl)&&(clearTimeout(_(this,vl)),M(this,vl,null)),_(this,Al)&&(clearTimeout(_(this,Al)),M(this,Al,null)),(u=this._editorUndoBar)==null||u.destroy(),M(this,gg,null)}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return _(this,uE)}get useNewAltTextFlow(){return _(this,oE)}get useNewAltTextWhenAddingImage(){return _(this,pg)}get hcmFilter(){return qt(this,"hcmFilter",_(this,vd)?_(this,lE).addHCMFilter(_(this,vd).foreground,_(this,vd).background):"none")}get direction(){return qt(this,"direction",getComputedStyle(_(this,xc)).direction)}get _highlightColors(){return qt(this,"_highlightColors",_(this,fg)?new Map(_(this,fg).split(",").map(e=>(e=e.split("=").map(n=>n.trim()),e[1]=e[1].toUpperCase(),e))):null)}get highlightColors(){const{_highlightColors:e}=this;if(!e)return qt(this,"highlightColors",null);const n=new Map,r=!!_(this,vd);for(const[a,i]of e){const s=a.endsWith("_HCM");if(r&&s){n.set(a.replace("_HCM",""),i);continue}!r&&!s&&n.set(a,i)}return qt(this,"highlightColors",n)}get highlightColorNames(){return qt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;const n=this.highlightColorNames.get(e);return this._highlightColors.get(n)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),M(this,md,e)}setMainHighlightColorPicker(e){M(this,hg,e)}editAltText(e,n=!1){var r;(r=_(this,cg))==null||r.editAltText(this,e,n)}hasCommentManager(){return!!_(this,Za)}editComment(e,n,r,a){var i;(i=_(this,Za))==null||i.showDialog(this,e,n,r,a)}selectComment(e,n){const r=_(this,la).get(e),a=r==null?void 0:r.getEditorByUID(n);a==null||a.toggleComment(!0,!0)}updateComment(e){var n;(n=_(this,Za))==null||n.updateComment(e.getData())}updatePopupColor(e){var n;(n=_(this,Za))==null||n.updatePopupColor(e)}removeComment(e){var n;(n=_(this,Za))==null||n.removeComments([e.uid])}toggleComment(e,n,r=void 0){var a;(a=_(this,Za))==null||a.toggleCommentPopup(e,n,r)}makeCommentColor(e,n){var r;return e&&((r=_(this,Za))==null?void 0:r.makeCommentColor(e,n))||null}getCommentDialogElement(){var e;return((e=_(this,Za))==null?void 0:e.dialogElement)||null}async waitForEditorsRendered(e){if(_(this,la).has(e-1))return;const{resolve:n,promise:r}=Promise.withResolvers(),a=i=>{i.pageNumber===e&&(this._eventBus._off("editorsrendered",a),n())};this._eventBus.on("editorsrendered",a),await r}getSignature(e){var n;(n=_(this,yd))==null||n.getSignature({uiManager:this,editor:e})}get signatureManager(){return _(this,yd)}switchToMode(e,n){this._eventBus.on("annotationeditormodechanged",n,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,n){this._eventBus.dispatch("setpreference",{source:this,name:e,value:n})}onSetPreference({name:e,value:n}){switch(e){case"enableNewAltTextWhenAddingImage":M(this,pg,n);break}}onPageChanging({pageNumber:e}){M(this,dg,e-1)}focusMainContainer(){_(this,xc).focus()}findParent(e,n){for(const r of _(this,la).values()){const{x:a,y:i,width:s,height:o}=r.div.getBoundingClientRect();if(e>=a&&e<=a+s&&n>=i&&n<=i+o)return r}return null}disableUserSelect(e=!1){_(this,fE).classList.toggle("noUserSelect",e)}addShouldRescale(e){_(this,mf).add(e)}removeShouldRescale(e){_(this,mf).delete(e)}onScaleChanging({scale:e}){var n;this.commitOrRemove(),this.viewParameters.realScale=e*Tc.PDF_TO_CSS_UNITS;for(const r of _(this,mf))r.onScaleChanging();(n=_(this,md))==null||n.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}highlightSelection(e="",n=!1){const r=document.getSelection();if(!r||r.isCollapsed)return;const{anchorNode:a,anchorOffset:i,focusNode:s,focusOffset:o}=r,l=r.toString(),p=K(this,We,AR).call(this,r).closest(".textLayer"),f=this.getSelectionBoxes(p);if(!f)return;r.empty();const m=K(this,We,$B).call(this,p),g=_(this,ea)===Ot.NONE,S=()=>{const E=m==null?void 0:m.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:f,anchorNode:a,anchorOffset:i,focusNode:s,focusOffset:o,text:l});g&&this.showAllEditors("highlight",!0,!0),n&&(E==null||E.editComment())};if(g){this.switchToMode(Ot.HIGHLIGHT,S);return}S()}commentSelection(e=""){this.highlightSelection(e,!0)}getAndRemoveDataFromAnnotationStorage(e){if(!_(this,Hs))return null;const n=`${O0}${e}`,r=_(this,Hs).getRawValue(n);return r&&_(this,Hs).remove(n),r}addToAnnotationStorage(e){!e.isEmpty()&&_(this,Hs)&&!_(this,Hs).has(e.id)&&_(this,Hs).setValue(e.id,e)}a11yAlert(e,n=null){const r=_(this,mE);r&&(r.setAttribute("data-l10n-id",e),n?r.setAttribute("data-l10n-args",JSON.stringify(n)):r.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,_(this,_d)&&(M(this,_d,!1),K(this,We,Ty).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const n of _(this,Dn))if(n.div.contains(e)){M(this,hf,[n,e]),n._focusEventsAllowed=!1;break}}focus(){if(!_(this,hf))return;const[e,n]=_(this,hf);M(this,hf,null),n.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),n.focus()}addEditListeners(){K(this,We,YB).call(this),K(this,We,VB).call(this)}removeEditListeners(){K(this,We,Lle).call(this),K(this,We,WB).call(this)}dragOver(e){for(const{type:n}of e.dataTransfer.items)for(const r of _(this,Ys))if(r.isHandlingMimeForPasting(n)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(const n of e.dataTransfer.items)for(const r of _(this,Ys))if(r.isHandlingMimeForPasting(n.type)){r.paste(n,this.currentLayer),e.preventDefault();return}}copy(e){var r;if(e.preventDefault(),(r=_(this,ss))==null||r.commitOrRemove(),!this.hasSelection)return;const n=[];for(const a of _(this,Dn)){const i=a.serialize(!0);i&&n.push(i)}n.length!==0&&e.clipboardData.setData("application/pdfjs",JSON.stringify(n))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:n}=e;for(const i of n.items)for(const s of _(this,Ys))if(s.isHandlingMimeForPasting(i.type)){s.paste(i,this.currentLayer);return}let r=n.getData("application/pdfjs");if(!r)return;try{r=JSON.parse(r)}catch(i){It(`paste: "${i.message}".`);return}if(!Array.isArray(r))return;this.unselectAll();const a=this.currentLayer;try{const i=[];for(const l of r){const u=await a.deserialize(l);if(!u)return;i.push(u)}const s=()=>{for(const l of i)K(this,We,jB).call(this,l);K(this,We,KB).call(this,i)},o=()=>{for(const l of i)l.remove()};this.addCommands({cmd:s,undo:o,mustExec:!0})}catch(i){It(`paste: "${i.message}".`)}}keydown(e){!this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!0),_(this,ea)!==Ot.NONE&&!this.isEditorHandlingKeyboard&&_g._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&e.key==="Shift"&&(this.isShiftKeyDown=!1,_(this,_d)&&(M(this,_d,!1),K(this,We,Ty).call(this,"main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}setEditingState(e){e?(K(this,We,kle).call(this),K(this,We,VB).call(this),K(this,We,Ei).call(this,{isEditing:_(this,ea)!==Ot.NONE,isEmpty:K(this,We,Ay).call(this),hasSomethingToUndo:_(this,$s).hasSomethingToUndo(),hasSomethingToRedo:_(this,$s).hasSomethingToRedo(),hasSelectedEditor:!1})):(K(this,We,Mle).call(this),K(this,We,WB).call(this),K(this,We,Ei).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!_(this,Ys)){M(this,Ys,e);for(const n of _(this,Ys))K(this,We,Iu).call(this,n.defaultPropertiesToUpdate)}}getId(){return _(this,JA).id}get currentLayer(){return _(this,la).get(_(this,dg))}getLayer(e){return _(this,la).get(e)}get currentPageIndex(){return _(this,dg)}addLayer(e){_(this,la).set(e.pageIndex,e),_(this,bd)?e.enable():e.disable()}removeLayer(e){_(this,la).delete(e.pageIndex)}async updateMode(e,n=null,r=!1,a=!1,i=!1){var s,o,l,u,p,f;if(_(this,ea)!==e&&!(_(this,Vs)&&(await _(this,Vs).promise,!_(this,Vs)))){if(M(this,Vs,Promise.withResolvers()),(s=_(this,md))==null||s.commitOrRemove(),_(this,ea)===Ot.POPUP&&((o=_(this,Za))==null||o.hideSidebar()),(l=_(this,Za))==null||l.destroyPopup(),M(this,ea,e),e===Ot.NONE){this.setEditingState(!1),K(this,We,Ble).call(this);for(const m of _(this,Mr).values())m.hideStandaloneCommentButton();(u=this._editorUndoBar)==null||u.hide(),this.toggleComment(null),_(this,Vs).resolve();return}for(const m of _(this,Mr).values())m.addStandaloneCommentButton();e===Ot.SIGNATURE&&await((p=_(this,yd))==null?void 0:p.loadSignatures()),this.setEditingState(!0),await K(this,We,Fle).call(this),this.unselectAll();for(const m of _(this,la).values())m.updateMode(e);if(e===Ot.POPUP){_(this,lg)||M(this,lg,await _(this,gg).getAnnotationsByType(new Set(_(this,Ys).map(S=>S._editorType))));const m=new Set,g=[];for(const S of _(this,Mr).values()){const{annotationElementId:E,hasComment:y,deleted:v}=S;E&&m.add(E),y&&!v&&g.push(S.getData())}for(const S of _(this,lg)){const{id:E,popupRef:y,contentsObj:v}=S;y&&(v!=null&&v.str)&&!m.has(E)&&!_(this,hd).has(E)&&g.push(S)}(f=_(this,Za))==null||f.showSidebar(g)}if(!n){r&&this.addNewEditorFromKeyboard(),_(this,Vs).resolve();return}for(const m of _(this,Mr).values())m.uid===n?(this.setSelected(m),i?m.editComment():a?m.enterInEditMode():m.focus()):m.unselect();_(this,Vs).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==_(this,ea)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,n){if(_(this,Ys)){switch(e){case rn.CREATE:this.currentLayer.addNewEditor(n);return;case rn.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(_(this,dE)||M(this,dE,new Map)).set(e,n),this.showAllEditors("highlight",n);break}if(this.hasSelection)for(const r of _(this,Dn))r.updateParams(e,n);else for(const r of _(this,Ys))r.updateDefaultParams(e,n)}}showAllEditors(e,n,r=!1){var i;for(const s of _(this,Mr).values())s.editorType===e&&s.show(n);(((i=_(this,dE))==null?void 0:i.get(rn.HIGHLIGHT_SHOW_ALL))??!0)!==n&&K(this,We,Iu).call(this,[[rn.HIGHLIGHT_SHOW_ALL,n]])}enableWaiting(e=!1){if(_(this,cE)!==e){M(this,cE,e);for(const n of _(this,la).values())e?n.disableClick():n.enableClick(),n.div.classList.toggle("waiting",e)}}*getEditors(e){for(const n of _(this,Mr).values())n.pageIndex===e&&(yield n)}getEditor(e){return _(this,Mr).get(e)}addEditor(e){_(this,Mr).set(e.id,e)}removeEditor(e){var n,r;e.div.contains(document.activeElement)&&(_(this,vl)&&clearTimeout(_(this,vl)),M(this,vl,setTimeout(()=>{this.focusMainContainer(),M(this,vl,null)},0))),_(this,Mr).delete(e.id),e.annotationElementId&&((n=_(this,Sd))==null||n.delete(e.annotationElementId)),this.unselect(e),(!e.annotationElementId||!_(this,hd).has(e.annotationElementId))&&((r=_(this,Hs))==null||r.remove(e.id))}addDeletedAnnotationElement(e){_(this,hd).add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return _(this,hd).has(e)}removeDeletedAnnotationElement(e){_(this,hd).delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}setActiveEditor(e){_(this,ss)!==e&&(M(this,ss,e),e&&K(this,We,Iu).call(this,e.propertiesToUpdate))}updateUI(e){_(this,We,Ule)===e&&K(this,We,Iu).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){K(this,We,Iu).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(_(this,Dn).has(e)){_(this,Dn).delete(e),e.unselect(),K(this,We,Ei).call(this,{hasSelectedEditor:this.hasSelection});return}_(this,Dn).add(e),e.select(),K(this,We,Iu).call(this,e.propertiesToUpdate),K(this,We,Ei).call(this,{hasSelectedEditor:!0})}setSelected(e){var n;this.updateToolbar({mode:e.mode,editId:e.id}),(n=_(this,md))==null||n.commitOrRemove();for(const r of _(this,Dn))r!==e&&r.unselect();_(this,Dn).clear(),_(this,Dn).add(e),e.select(),K(this,We,Iu).call(this,e.propertiesToUpdate),K(this,We,Ei).call(this,{hasSelectedEditor:!0})}isSelected(e){return _(this,Dn).has(e)}get firstSelectedEditor(){return _(this,Dn).values().next().value}unselect(e){e.unselect(),_(this,Dn).delete(e),K(this,We,Ei).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return _(this,Dn).size!==0}get isEnterHandled(){return _(this,Dn).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var e;_(this,$s).undo(),K(this,We,Ei).call(this,{hasSomethingToUndo:_(this,$s).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:K(this,We,Ay).call(this)}),(e=this._editorUndoBar)==null||e.hide()}redo(){_(this,$s).redo(),K(this,We,Ei).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:_(this,$s).hasSomethingToRedo(),isEmpty:K(this,We,Ay).call(this)})}addCommands(e){_(this,$s).add(e),K(this,We,Ei).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:K(this,We,Ay).call(this)})}cleanUndoStack(e){_(this,$s).cleanType(e)}delete(){var i;this.commitOrRemove();const e=(i=this.currentLayer)==null?void 0:i.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const n=e?[e]:[..._(this,Dn)],r=()=>{var s;(s=this._editorUndoBar)==null||s.show(a,n.length===1?n[0].editorType:n.length);for(const o of n)o.remove()},a=()=>{for(const s of n)K(this,We,jB).call(this,s)};this.addCommands({cmd:r,undo:a,mustExec:!0})}commitOrRemove(){var e;(e=_(this,ss))==null||e.commitOrRemove()}hasSomethingToControl(){return _(this,ss)||this.hasSelection}selectAll(){for(const e of _(this,Dn))e.commit();K(this,We,KB).call(this,_(this,Mr).values())}unselectAll(){var e;if(!(_(this,ss)&&(_(this,ss).commitOrRemove(),_(this,ea)!==Ot.NONE))&&!((e=_(this,md))!=null&&e.commitOrRemove())&&this.hasSelection){for(const n of _(this,Dn))n.unselect();_(this,Dn).clear(),K(this,We,Ei).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(e,n,r=!1){if(r||this.commitOrRemove(),!this.hasSelection)return;_(this,Td)[0]+=e,_(this,Td)[1]+=n;const[a,i]=_(this,Td),s=[..._(this,Dn)],o=1e3;_(this,Al)&&clearTimeout(_(this,Al)),M(this,Al,setTimeout(()=>{M(this,Al,null),_(this,Td)[0]=_(this,Td)[1]=0,this.addCommands({cmd:()=>{for(const l of s)_(this,Mr).has(l.id)&&(l.translateInPage(a,i),l.translationDone())},undo:()=>{for(const l of s)_(this,Mr).has(l.id)&&(l.translateInPage(-a,-i),l.translationDone())},mustExec:!1})},o));for(const l of s)l.translateInPage(e,n),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),M(this,yl,new Map);for(const e of _(this,Dn))_(this,yl).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!_(this,yl))return!1;this.disableUserSelect(!1);const e=_(this,yl);M(this,yl,null);let n=!1;for(const[{x:a,y:i,pageIndex:s},o]of e)o.newX=a,o.newY=i,o.newPageIndex=s,n||(n=a!==o.savedX||i!==o.savedY||s!==o.savedPageIndex);if(!n)return!1;const r=(a,i,s,o)=>{if(_(this,Mr).has(a.id)){const l=_(this,la).get(o);l?a._setParentAndPosition(l,i,s):(a.pageIndex=o,a.x=i,a.y=s)}};return this.addCommands({cmd:()=>{for(const[a,{newX:i,newY:s,newPageIndex:o}]of e)r(a,i,s,o)},undo:()=>{for(const[a,{savedX:i,savedY:s,savedPageIndex:o}]of e)r(a,i,s,o)},mustExec:!0}),!0}dragSelectedEditors(e,n){if(_(this,yl))for(const r of _(this,yl).keys())r.drag(e,n)}rebuild(e){if(e.parent===null){const n=this.getLayer(e.pageIndex);n?(n.changeParent(e),n.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){var e;return((e=this.getActive())==null?void 0:e.shouldGetKeyboardEvents())||_(this,Dn).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return _(this,ss)===e}getActive(){return _(this,ss)}getMode(){return _(this,ea)}isEditingMode(){return _(this,ea)!==Ot.NONE}get imageManager(){return qt(this,"imageManager",new tF)}getSelectionBoxes(e){if(!e)return null;const n=document.getSelection();for(let u=0,p=n.rangeCount;u<p;u++)if(!e.contains(n.getRangeAt(u).commonAncestorContainer))return null;const{x:r,y:a,width:i,height:s}=e.getBoundingClientRect();let o;switch(e.getAttribute("data-main-rotation")){case"90":o=(u,p,f,m)=>({x:(p-a)/s,y:1-(u+f-r)/i,width:m/s,height:f/i});break;case"180":o=(u,p,f,m)=>({x:1-(u+f-r)/i,y:1-(p+m-a)/s,width:f/i,height:m/s});break;case"270":o=(u,p,f,m)=>({x:1-(p+m-a)/s,y:(u-r)/i,width:m/s,height:f/i});break;default:o=(u,p,f,m)=>({x:(u-r)/i,y:(p-a)/s,width:f/i,height:m/s});break}const l=[];for(let u=0,p=n.rangeCount;u<p;u++){const f=n.getRangeAt(u);if(!f.collapsed)for(const{x:m,y:g,width:S,height:E}of f.getClientRects())S===0||E===0||l.push(o(m,g,S,E))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:e,id:n}){(_(this,ug)||M(this,ug,new Map)).set(e,n)}removeChangedExistingAnnotation({annotationElementId:e}){var n;(n=_(this,ug))==null||n.delete(e)}renderAnnotationElement(e){var a;const n=(a=_(this,ug))==null?void 0:a.get(e.data.id);if(!n)return;const r=_(this,Hs).getRawValue(n);r&&(_(this,ea)===Ot.NONE&&!r.hasBeenModified||r.renderAnnotationElement(e))}setMissingCanvas(e,n,r){var i;const a=(i=_(this,Sd))==null?void 0:i.get(e);a&&(a.setCanvas(n,r),_(this,Sd).delete(e))}addMissingCanvas(e,n){(_(this,Sd)||M(this,Sd,new Map)).set(e,n)}};og=new WeakMap,ss=new WeakMap,lg=new WeakMap,Mr=new WeakMap,la=new WeakMap,cg=new WeakMap,Hs=new WeakMap,ug=new WeakMap,$s=new WeakMap,Za=new WeakMap,fd=new WeakMap,md=new WeakMap,dg=new WeakMap,hd=new WeakMap,yl=new WeakMap,Ys=new WeakMap,mf=new WeakMap,sE=new WeakMap,oE=new WeakMap,pg=new WeakMap,lE=new WeakMap,vl=new WeakMap,gd=new WeakMap,fg=new WeakMap,_d=new WeakMap,Tl=new WeakMap,JA=new WeakMap,bd=new WeakMap,mg=new WeakMap,cE=new WeakMap,Ed=new WeakMap,hf=new WeakMap,hg=new WeakMap,Sd=new WeakMap,uE=new WeakMap,ea=new WeakMap,Dn=new WeakMap,wc=new WeakMap,yd=new WeakMap,vd=new WeakMap,dE=new WeakMap,gg=new WeakMap,pE=new WeakMap,Td=new WeakMap,Al=new WeakMap,xc=new WeakMap,fE=new WeakMap,mE=new WeakMap,Vs=new WeakMap,We=new WeakSet,AR=function({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e},$B=function(e){const{currentLayer:n}=this;if(n.hasTextLayer(e))return n;for(const r of _(this,la).values())if(r.hasTextLayer(e))return r;return null},Ole=function(){const e=document.getSelection();if(!e||e.isCollapsed)return;const r=K(this,We,AR).call(this,e).closest(".textLayer"),a=this.getSelectionBoxes(r);a&&(_(this,Tl)||M(this,Tl,new gUe(this)),_(this,Tl).show(r,a,this.direction==="ltr"))},Ile=function(){var i,s,o;const e=document.getSelection();if(!e||e.isCollapsed){_(this,wc)&&((i=_(this,Tl))==null||i.hide(),M(this,wc,null),K(this,We,Ei).call(this,{hasSelectedText:!1}));return}const{anchorNode:n}=e;if(n===_(this,wc))return;const a=K(this,We,AR).call(this,e).closest(".textLayer");if(!a){_(this,wc)&&((s=_(this,Tl))==null||s.hide(),M(this,wc,null),K(this,We,Ei).call(this,{hasSelectedText:!1}));return}if((o=_(this,Tl))==null||o.hide(),M(this,wc,n),K(this,We,Ei).call(this,{hasSelectedText:!0}),!(_(this,ea)!==Ot.HIGHLIGHT&&_(this,ea)!==Ot.NONE)&&(_(this,ea)===Ot.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),M(this,_d,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=_(this,ea)===Ot.HIGHLIGHT?K(this,We,$B).call(this,a):null;if(l==null||l.toggleDrawing(),_(this,mg)){const u=new AbortController,p=this.combinedSignal(u),f=m=>{m.type==="pointerup"&&m.button!==0||(u.abort(),l==null||l.toggleDrawing(!0),m.type==="pointerup"&&K(this,We,Ty).call(this,"main_toolbar"))};window.addEventListener("pointerup",f,{signal:p}),window.addEventListener("blur",f,{signal:p})}else l==null||l.toggleDrawing(!0),K(this,We,Ty).call(this,"main_toolbar")}},Ty=function(e=""){_(this,ea)===Ot.HIGHLIGHT?this.highlightSelection(e):_(this,sE)&&K(this,We,Ole).call(this)},Dle=function(){document.addEventListener("selectionchange",K(this,We,Ile).bind(this),{signal:this._signal})},kle=function(){if(_(this,gd))return;M(this,gd,new AbortController);const e=this.combinedSignal(_(this,gd));window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})},Mle=function(){var e;(e=_(this,gd))==null||e.abort(),M(this,gd,null)},YB=function(){if(_(this,Ed))return;M(this,Ed,new AbortController);const e=this.combinedSignal(_(this,Ed));window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})},Lle=function(){var e;(e=_(this,Ed))==null||e.abort(),M(this,Ed,null)},VB=function(){if(_(this,fd))return;M(this,fd,new AbortController);const e=this.combinedSignal(_(this,fd));document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})},WB=function(){var e;(e=_(this,fd))==null||e.abort(),M(this,fd,null)},Ple=function(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})},Ei=function(e){Object.entries(e).some(([r,a])=>_(this,pE)[r]!==a)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(_(this,pE),e)}),_(this,ea)===Ot.HIGHLIGHT&&e.hasSelectedEditor===!1&&K(this,We,Iu).call(this,[[rn.HIGHLIGHT_FREE,!0]]))},Iu=function(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})},Fle=async function(){if(!_(this,bd)){M(this,bd,!0);const e=[];for(const n of _(this,la).values())e.push(n.enable());await Promise.all(e);for(const n of _(this,Mr).values())n.enable()}},Ble=function(){if(this.unselectAll(),_(this,bd)){M(this,bd,!1);for(const e of _(this,la).values())e.disable();for(const e of _(this,Mr).values())e.disable()}},jB=function(e){const n=_(this,la).get(e.pageIndex);n?n.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))},Ule=function(){let e=null;for(e of _(this,Dn));return e},Ay=function(){if(_(this,Mr).size===0)return!0;if(_(this,Mr).size===1)for(const e of _(this,Mr).values())return e.isEmpty();return!1},KB=function(e){for(const n of _(this,Dn))n.unselect();_(this,Dn).clear();for(const n of e)n.isEmpty()||(_(this,Dn).add(n),n.select());K(this,We,Ei).call(this,{hasSelectedEditor:this.hasSelection})},Pe(_g,"TRANSLATE_SMALL",1),Pe(_g,"TRANSLATE_BIG",10);let ld=_g;const di=class di{constructor(e){Y(this,Do);Y(this,Sa,null);Y(this,Cl,!1);Y(this,Io,null);Y(this,bg,null);Y(this,Rl,null);Y(this,os,null);Y(this,Eg,!1);Y(this,Nl,null);Y(this,Ii,null);Y(this,Oc,null);Y(this,gf,null);Y(this,wl,!1);M(this,Ii,e),M(this,wl,e._uiManager.useNewAltTextFlow),_(di,Ad)||M(di,Ad,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){di._l10n??(di._l10n=e)}async render(){const e=M(this,Io,document.createElement("button"));e.className="altText",e.tabIndex="0";const n=M(this,bg,document.createElement("span"));e.append(n),_(this,wl)?(e.classList.add("new"),e.setAttribute("data-l10n-id",_(di,Ad).missing),n.setAttribute("data-l10n-id",_(di,Ad)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const r=_(this,Ii)._uiManager._signal;e.addEventListener("contextmenu",as,{signal:r}),e.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:r});const a=i=>{i.preventDefault(),_(this,Ii)._uiManager.editAltText(_(this,Ii)),_(this,wl)&&_(this,Ii)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:_(this,Do,Cy)}})};return e.addEventListener("click",a,{capture:!0,signal:r}),e.addEventListener("keydown",i=>{i.target===e&&i.key==="Enter"&&(M(this,Eg,!0),a(i))},{signal:r}),await K(this,Do,CR).call(this),e}finish(){_(this,Io)&&(_(this,Io).focus({focusVisible:_(this,Eg)}),M(this,Eg,!1))}isEmpty(){return _(this,wl)?_(this,Sa)===null:!_(this,Sa)&&!_(this,Cl)}hasData(){return _(this,wl)?_(this,Sa)!==null||!!_(this,Oc):this.isEmpty()}get guessedText(){return _(this,Oc)}async setGuessedText(e){_(this,Sa)===null&&(M(this,Oc,e),M(this,gf,await di._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),K(this,Do,CR).call(this))}toggleAltTextBadge(e=!1){var n;if(!_(this,wl)||_(this,Sa)){(n=_(this,Nl))==null||n.remove(),M(this,Nl,null);return}if(!_(this,Nl)){const r=M(this,Nl,document.createElement("div"));r.className="noAltTextBadge",_(this,Ii).div.append(r)}_(this,Nl).classList.toggle("hidden",!e)}serialize(e){let n=_(this,Sa);return!e&&_(this,Oc)===n&&(n=_(this,gf)),{altText:n,decorative:_(this,Cl),guessedText:_(this,Oc),textWithDisclaimer:_(this,gf)}}get data(){return{altText:_(this,Sa),decorative:_(this,Cl)}}set data({altText:e,decorative:n,guessedText:r,textWithDisclaimer:a,cancel:i=!1}){r&&(M(this,Oc,r),M(this,gf,a)),!(_(this,Sa)===e&&_(this,Cl)===n)&&(i||(M(this,Sa,e),M(this,Cl,n)),K(this,Do,CR).call(this))}toggle(e=!1){_(this,Io)&&(!e&&_(this,os)&&(clearTimeout(_(this,os)),M(this,os,null)),_(this,Io).disabled=!e)}shown(){_(this,Ii)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:_(this,Do,Cy)}})}destroy(){var e,n;(e=_(this,Io))==null||e.remove(),M(this,Io,null),M(this,bg,null),M(this,Rl,null),(n=_(this,Nl))==null||n.remove(),M(this,Nl,null)}};Sa=new WeakMap,Cl=new WeakMap,Io=new WeakMap,bg=new WeakMap,Rl=new WeakMap,os=new WeakMap,Eg=new WeakMap,Nl=new WeakMap,Ii=new WeakMap,Oc=new WeakMap,gf=new WeakMap,wl=new WeakMap,Ad=new WeakMap,Do=new WeakSet,Cy=function(){return _(this,Sa)&&"added"||_(this,Sa)===null&&this.guessedText&&"review"||"missing"},CR=async function(){var a,i,s;const e=_(this,Io);if(!e)return;if(_(this,wl)){if(e.classList.toggle("done",!!_(this,Sa)),e.setAttribute("data-l10n-id",_(di,Ad)[_(this,Do,Cy)]),(a=_(this,bg))==null||a.setAttribute("data-l10n-id",_(di,Ad)[`${_(this,Do,Cy)}-label`]),!_(this,Sa)){(i=_(this,Rl))==null||i.remove();return}}else{if(!_(this,Sa)&&!_(this,Cl)){e.classList.remove("done"),(s=_(this,Rl))==null||s.remove();return}e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=_(this,Rl);if(!n){M(this,Rl,n=document.createElement("span")),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${_(this,Ii).id}`;const o=100,l=_(this,Ii)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(_(this,os)),M(this,os,null)},{once:!0}),e.addEventListener("mouseenter",()=>{M(this,os,setTimeout(()=>{M(this,os,null),_(this,Rl).classList.add("show"),_(this,Ii)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),e.addEventListener("mouseleave",()=>{var u;_(this,os)&&(clearTimeout(_(this,os)),M(this,os,null)),(u=_(this,Rl))==null||u.classList.remove("show")},{signal:l})}_(this,Cl)?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=_(this,Sa)),n.parentNode||e.append(n);const r=_(this,Ii).getElementForAltText();r==null||r.setAttribute("aria-describedby",n.id)},Y(di,Ad,null),Pe(di,"_l10n",null);let CA=di;class RA{constructor(e){Y(this,gE);Y(this,Ma,null);Y(this,Ws,null);Y(this,_f,!1);Y(this,lr,null);Y(this,hE,null);Y(this,bf,null);Y(this,ko,null);Y(this,Ef,null);Y(this,Sf,!1);Y(this,yf,null);M(this,lr,e)}renderForToolbar(){const e=M(this,Ws,document.createElement("button"));return e.className="comment",K(this,gE,XB).call(this,e,!1)}renderForStandalone(){const e=M(this,Ma,document.createElement("button"));e.className="annotationCommentButton";const n=_(this,lr).commentButtonPosition;if(n){const{style:r}=e;r.insetInlineEnd=`calc(${100*(_(this,lr)._uiManager.direction==="ltr"?1-n[0]:n[0])}% - var(--comment-button-dim))`,r.top=`calc(${100*n[1]}% - var(--comment-button-dim))`;const a=_(this,lr).commentButtonColor;a&&(r.backgroundColor=a)}return K(this,gE,XB).call(this,e,!0)}focusButton(){setTimeout(()=>{var e;(e=_(this,Ma)??_(this,Ws))==null||e.focus()},0)}onUpdatedColor(){if(!_(this,Ma))return;const e=_(this,lr).commentButtonColor;e&&(_(this,Ma).style.backgroundColor=e),_(this,lr)._uiManager.updatePopupColor(_(this,lr))}get commentButtonWidth(){var e;return(((e=_(this,Ma))==null?void 0:e.getBoundingClientRect().width)??0)/_(this,lr).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(_(this,yf))return _(this,yf);if(!_(this,Ma))return null;const{x:e,y:n,height:r}=_(this,Ma).getBoundingClientRect(),{x:a,y:i,width:s,height:o}=_(this,lr).parent.boundingClientRect;return[(e-a)/s,(n+r-i)/o]}set commentPopupPositionInLayer(e){M(this,yf,e)}hasDefaultPopupPosition(){return _(this,yf)===null}removeStandaloneCommentButton(){var e;(e=_(this,Ma))==null||e.remove(),M(this,Ma,null)}removeToolbarCommentButton(){var e;(e=_(this,Ws))==null||e.remove(),M(this,Ws,null)}setCommentButtonStates({selected:e,hasPopup:n}){_(this,Ma)&&(_(this,Ma).classList.toggle("selected",e),_(this,Ma).ariaExpanded=n)}edit(e){const n=this.commentPopupPositionInLayer;let r,a;if(n)[r,a]=n;else{[r,a]=_(this,lr).commentButtonPosition;const{width:p,height:f,x:m,y:g}=_(this,lr);r=m+r*p,a=g+a*f}const i=_(this,lr).parent.boundingClientRect,{x:s,y:o,width:l,height:u}=i;_(this,lr)._uiManager.editComment(_(this,lr),s+r*l,o+a*u,{...e,parentDimensions:i})}finish(){_(this,Ws)&&(_(this,Ws).focus({focusVisible:_(this,_f)}),M(this,_f,!1))}isDeleted(){return _(this,Sf)||_(this,ko)===""}isEmpty(){return _(this,ko)===null}hasBeenEdited(){return this.isDeleted()||_(this,ko)!==_(this,hE)}serialize(){return this.data}get data(){return{text:_(this,ko),richText:_(this,bf),date:_(this,Ef),deleted:this.isDeleted()}}set data(e){if(e!==_(this,ko)&&M(this,bf,null),e===null){M(this,ko,""),M(this,Sf,!0);return}M(this,ko,e),M(this,Ef,new Date),M(this,Sf,!1)}setInitialText(e,n=null){M(this,hE,e),this.data=e,M(this,Ef,null),M(this,bf,n)}shown(){}destroy(){var e,n;(e=_(this,Ws))==null||e.remove(),M(this,Ws,null),(n=_(this,Ma))==null||n.remove(),M(this,Ma,null),M(this,ko,""),M(this,bf,null),M(this,Ef,null),M(this,lr,null),M(this,_f,!1),M(this,Sf,!1)}}Ma=new WeakMap,Ws=new WeakMap,_f=new WeakMap,lr=new WeakMap,hE=new WeakMap,bf=new WeakMap,ko=new WeakMap,Ef=new WeakMap,Sf=new WeakMap,yf=new WeakMap,gE=new WeakSet,XB=function(e,n){if(!_(this,lr)._uiManager.hasCommentManager())return null;e.tabIndex="0",e.ariaHasPopup="dialog",n?(e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(e.ariaControlsElements=[_(this,lr)._uiManager.getCommentDialogElement()],e.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button"));const r=_(this,lr)._uiManager._signal;if(!(r instanceof AbortSignal)||r.aborted)return e;e.addEventListener("contextmenu",as,{signal:r}),n&&(e.addEventListener("focusin",i=>{_(this,lr)._focusEventsAllowed=!1,Rr(i)},{capture:!0,signal:r}),e.addEventListener("focusout",i=>{_(this,lr)._focusEventsAllowed=!0,Rr(i)},{capture:!0,signal:r})),e.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:r});const a=i=>{i.preventDefault(),e===_(this,Ws)?this.edit():_(this,lr).toggleComment(!0)};return e.addEventListener("click",a,{capture:!0,signal:r}),e.addEventListener("keydown",i=>{i.target===e&&i.key==="Enter"&&(M(this,_f,!0),a(i))},{signal:r}),e.addEventListener("pointerenter",()=>{_(this,lr).toggleComment(!1,!0)},{signal:r}),e.addEventListener("pointerleave",()=>{_(this,lr).toggleComment(!1,!1)},{signal:r}),e};const FF=class FF{constructor({container:e,isPinchingDisabled:n=null,isPinchingStopped:r=null,onPinchStart:a=null,onPinching:i=null,onPinchEnd:s=null,signal:o}){Y(this,Cd);Y(this,Sg);Y(this,vf,!1);Y(this,_E,null);Y(this,bE);Y(this,EE);Y(this,SE);Y(this,yE);Y(this,Ic,null);Y(this,Tf);Y(this,Dc,null);Y(this,Af);Y(this,kc,null);M(this,Sg,e),M(this,_E,r),M(this,bE,n),M(this,EE,a),M(this,SE,i),M(this,yE,s),M(this,Af,new AbortController),M(this,Tf,AbortSignal.any([o,_(this,Af).signal])),e.addEventListener("touchstart",K(this,Cd,Gle).bind(this),{passive:!1,signal:_(this,Tf)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Oo.pixelRatio}destroy(){var e,n;(e=_(this,Af))==null||e.abort(),M(this,Af,null),(n=_(this,Ic))==null||n.abort(),M(this,Ic,null)}};Sg=new WeakMap,vf=new WeakMap,_E=new WeakMap,bE=new WeakMap,EE=new WeakMap,SE=new WeakMap,yE=new WeakMap,Ic=new WeakMap,Tf=new WeakMap,Dc=new WeakMap,Af=new WeakMap,kc=new WeakMap,Cd=new WeakSet,Gle=function(e){var a,i,s;if((a=_(this,bE))!=null&&a.call(this))return;if(e.touches.length===1){if(_(this,Ic))return;const o=M(this,Ic,new AbortController),l=AbortSignal.any([_(this,Tf),o.signal]),u=_(this,Sg),p={capture:!0,signal:l,passive:!1},f=m=>{var g;m.pointerType==="touch"&&((g=_(this,Ic))==null||g.abort(),M(this,Ic,null))};u.addEventListener("pointerdown",m=>{m.pointerType==="touch"&&(Rr(m),f(m))},p),u.addEventListener("pointerup",f,p),u.addEventListener("pointercancel",f,p);return}if(!_(this,kc)){M(this,kc,new AbortController);const o=AbortSignal.any([_(this,Tf),_(this,kc).signal]),l=_(this,Sg),u={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",K(this,Cd,zle).bind(this),u);const p=K(this,Cd,qle).bind(this);l.addEventListener("touchend",p,u),l.addEventListener("touchcancel",p,u),u.capture=!0,l.addEventListener("pointerdown",Rr,u),l.addEventListener("pointermove",Rr,u),l.addEventListener("pointercancel",Rr,u),l.addEventListener("pointerup",Rr,u),(i=_(this,EE))==null||i.call(this)}if(Rr(e),e.touches.length!==2||(s=_(this,_E))!=null&&s.call(this)){M(this,Dc,null);return}let[n,r]=e.touches;n.identifier>r.identifier&&([n,r]=[r,n]),M(this,Dc,{touch0X:n.screenX,touch0Y:n.screenY,touch1X:r.screenX,touch1Y:r.screenY})},zle=function(e){var w;if(!_(this,Dc)||e.touches.length!==2)return;Rr(e);let[n,r]=e.touches;n.identifier>r.identifier&&([n,r]=[r,n]);const{screenX:a,screenY:i}=n,{screenX:s,screenY:o}=r,l=_(this,Dc),{touch0X:u,touch0Y:p,touch1X:f,touch1Y:m}=l,g=f-u,S=m-p,E=s-a,y=o-i,v=Math.hypot(E,y)||1,A=Math.hypot(g,S)||1;if(!_(this,vf)&&Math.abs(A-v)<=FF.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=a,l.touch0Y=i,l.touch1X=s,l.touch1Y=o,!_(this,vf)){M(this,vf,!0);return}const T=[(a+s)/2,(i+o)/2];(w=_(this,SE))==null||w.call(this,T,A,v)},qle=function(e){var n;e.touches.length>=2||(_(this,kc)&&(_(this,kc).abort(),M(this,kc,null),(n=_(this,yE))==null||n.call(this)),_(this,Dc)&&(Rr(e),M(this,Dc,null),M(this,vf,!1)))};let z0=FF;const kt=class kt{constructor(e){Y(this,Tt);Y(this,Cf,null);Y(this,Mo,null);Y(this,_r,null);Y(this,Jn,null);Y(this,Mc,null);Y(this,yg,!1);Y(this,Rd,null);Y(this,vE,"");Y(this,La,null);Y(this,Rf,null);Y(this,Lc,null);Y(this,xl,null);Y(this,Nd,null);Y(this,TE,"");Y(this,Nf,!1);Y(this,ls,null);Y(this,AE,!1);Y(this,wf,!1);Y(this,Pc,!1);Y(this,Ol,null);Y(this,vg,0);Y(this,Tg,0);Y(this,js,null);Y(this,xf,null);Pe(this,"isSelected",!1);Pe(this,"_isCopy",!1);Pe(this,"_editToolbar",null);Pe(this,"_initialOptions",Object.create(null));Pe(this,"_initialData",null);Pe(this,"_isVisible",!0);Pe(this,"_uiManager",null);Pe(this,"_focusEventsAllowed",!0);Y(this,CE,!1);Y(this,eC,kt._zIndex++);this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null,this.creationDate=e.creationDate||new Date,this.modificationDate=e.modificationDate||null;const{rotation:n,rawDims:{pageWidth:r,pageHeight:a,pageX:i,pageY:s}}=this.parent.viewport;this.rotation=n,this.pageRotation=(360+n-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[r,a],this.pageTranslation=[i,s];const[o,l]=this.parentDimensions;this.x=e.x/o,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=kt.prototype._resizeWithKeyboard,n=ld.TRANSLATE_SMALL,r=ld.TRANSLATE_BIG;return qt(this,"_resizerKeyboardManager",new G0([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-n,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-r,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[n,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[r,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-n]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-r]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,n]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,r]}],[["Escape","mac+Escape"],kt.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return qt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const n=new EUe({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});n.annotationElementId=e.annotationElementId,n.deleted=!0,n._uiManager.addToAnnotationStorage(n)}static initialize(e,n){if(kt._l10n??(kt._l10n=e),kt._l10nResizer||(kt._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),kt._borderLineWidth!==-1)return;const r=getComputedStyle(document.documentElement);kt._borderLineWidth=parseFloat(r.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,n){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,n){Qn("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return _(this,CE)}set _isDraggable(e){var n;M(this,CE,e),(n=this.div)==null||n.classList.toggle("draggable",e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[e,n]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*n/(e*2),this.y+=this.width*e/(n*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*n/(e*2),this.y-=this.width*e/(n*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=_(this,eC)}setParent(e){var n;e!==null?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):(K(this,Tt,Ry).call(this),(n=_(this,xl))==null||n.remove(),M(this,xl,null)),this.parent=e}focusin(e){this._focusEventsAllowed&&(_(this,Nf)?M(this,Nf,!1):this.parent.setSelected(this))}focusout(e){var r;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const n=e.relatedTarget;n!=null&&n.closest(`#${this.id}`)||(e.preventDefault(),(r=this.parent)!=null&&r.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,n,r,a){const[i,s]=this.parentDimensions;[r,a]=this.screenToPageTranslation(r,a),this.x=(e+r)/i,this.y=(n+a)/s,this.fixAndSetPosition()}_moveAfterPaste(e,n){const[r,a]=this.parentDimensions;this.setAt(e*r,n*a,this.width*r,this.height*a),this._onTranslated()}translate(e,n){K(this,Tt,QB).call(this,this.parentDimensions,e,n)}translateInPage(e,n){_(this,ls)||M(this,ls,[this.x,this.y,this.width,this.height]),K(this,Tt,QB).call(this,this.pageDimensions,e,n),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,n){_(this,ls)||M(this,ls,[this.x,this.y,this.width,this.height]);const{div:r,parentDimensions:[a,i]}=this;if(this.x+=e/a,this.y+=n/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:f,y:m}=this.div.getBoundingClientRect();this.parent.findNewParent(this,f,m)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:s,y:o}=this;const[l,u]=this.getBaseTranslation();s+=l,o+=u;const{style:p}=r;p.left=`${(100*s).toFixed(2)}%`,p.top=`${(100*o).toFixed(2)}%`,this._onTranslating(s,o),r.scrollIntoView({block:"nearest"})}_onTranslating(e,n){}_onTranslated(e,n){}get _hasBeenMoved(){return!!_(this,ls)&&(_(this,ls)[0]!==this.x||_(this,ls)[1]!==this.y)}get _hasBeenResized(){return!!_(this,ls)&&(_(this,ls)[2]!==this.width||_(this,ls)[3]!==this.height)}getBaseTranslation(){const[e,n]=this.parentDimensions,{_borderLineWidth:r}=kt,a=r/e,i=r/n;switch(this.rotation){case 90:return[-a,i];case 180:return[a,i];case 270:return[a,-i];default:return[-a,-i]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:n},pageDimensions:[r,a]}=this;let{x:i,y:s,width:o,height:l}=this;if(o*=r,l*=a,i*=r,s*=a,this._mustFixPosition)switch(e){case 0:i=Ka(i,0,r-o),s=Ka(s,0,a-l);break;case 90:i=Ka(i,0,r-l),s=Ka(s,o,a);break;case 180:i=Ka(i,o,r),s=Ka(s,l,a);break;case 270:i=Ka(i,l,r),s=Ka(s,0,a-o);break}this.x=i/=r,this.y=s/=a;const[u,p]=this.getBaseTranslation();i+=u,s+=p,n.left=`${(100*i).toFixed(2)}%`,n.top=`${(100*s).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,n){var r;return K(r=kt,RE,ZB).call(r,e,n,this.parentRotation)}pageTranslationToScreen(e,n){var r;return K(r=kt,RE,ZB).call(r,e,n,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[n,r]}=this;return[n*e,r*e]}setDims(){const{div:{style:e},width:n,height:r}=this;e.width=`${(100*n).toFixed(2)}%`,e.height=`${(100*r).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(e*1e4)/1e4}_onResizing(){}altTextFinish(){var e;(e=_(this,_r))==null||e.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||_(this,wf))return this._editToolbar;this._editToolbar=new eF(this),this.div.append(this._editToolbar.render());const{toolbarButtons:e}=this;if(e)for(const[n,r]of e)await this._editToolbar.addButton(n,r);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var e;(e=this._editToolbar)==null||e.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var e;(e=this._editToolbar)==null||e.removeButton("comment")}removeEditToolbar(){var e,n;(e=this._editToolbar)==null||e.remove(),this._editToolbar=null,(n=_(this,_r))==null||n.destroy()}addContainer(e){var r;const n=(r=this._editToolbar)==null?void 0:r.div;n?n.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return _(this,_r)||(CA.initialize(kt._l10n),M(this,_r,new CA(this)),_(this,Cf)&&(_(this,_r).data=_(this,Cf),M(this,Cf,null))),_(this,_r)}get altTextData(){var e;return(e=_(this,_r))==null?void 0:e.data}set altTextData(e){_(this,_r)&&(_(this,_r).data=e)}get guessedAltText(){var e;return(e=_(this,_r))==null?void 0:e.guessedText}async setGuessedAltText(e){var n;await((n=_(this,_r))==null?void 0:n.setGuessedText(e))}serializeAltText(e){var n;return(n=_(this,_r))==null?void 0:n.serialize(e)}hasAltText(){return!!_(this,_r)&&!_(this,_r).isEmpty()}hasAltTextData(){var e;return((e=_(this,_r))==null?void 0:e.hasData())??!1}focusCommentButton(){var e;(e=_(this,Jn))==null||e.focusButton()}addCommentButton(){return _(this,Jn)||M(this,Jn,new RA(this))}addStandaloneCommentButton(){if(_(this,Mc)){this._uiManager.isEditingMode()&&_(this,Mc).classList.remove("hidden");return}this.hasComment&&(M(this,Mc,_(this,Jn).renderForStandalone()),this.div.append(_(this,Mc)))}removeStandaloneCommentButton(){_(this,Jn).removeStandaloneCommentButton(),M(this,Mc,null)}hideStandaloneCommentButton(){var e;(e=_(this,Mc))==null||e.classList.add("hidden")}get comment(){const{data:{richText:e,text:n,date:r,deleted:a}}=_(this,Jn);return{text:n,richText:e,date:r,deleted:a,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){_(this,Jn)||M(this,Jn,new RA(this)),_(this,Jn).data=e,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:e,popupRef:n,richText:r}){if(!n||(_(this,Jn)||M(this,Jn,new RA(this)),_(this,Jn).setInitialText(e,r),!this.annotationElementId))return;const a=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);a&&this.updateFromAnnotationLayer(a)}get hasEditedComment(){var e;return(e=_(this,Jn))==null?void 0:e.hasBeenEdited()}get hasDeletedComment(){var e;return(e=_(this,Jn))==null?void 0:e.isDeleted()}get hasComment(){return!!_(this,Jn)&&!_(this,Jn).isEmpty()&&!_(this,Jn).isDeleted()}async editComment(e){_(this,Jn)||M(this,Jn,new RA(this)),_(this,Jn).edit(e)}toggleComment(e,n=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,n)}setSelectedCommentButton(e){_(this,Jn).setSelectedButton(e)}addComment(e){if(this.hasEditedComment){const[,,,a]=e.rect,[i]=this.pageDimensions,[s]=this.pageTranslation,o=s+i+1,l=a-100,u=o+180;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,u,a]}}}updateFromAnnotationLayer({popup:{contents:e,deleted:n}}){_(this,Jn).data=n?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var s;const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=_(this,yg)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),K(this,Tt,n6).call(this);const[n,r]=this.parentDimensions;this.parentRotation%180!==0&&(e.style.maxWidth=`${(100*r/n).toFixed(2)}%`,e.style.maxHeight=`${(100*n/r).toFixed(2)}%`);const[a,i]=this.getInitialTranslation();return this.translate(a,i),Mre(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(_(this,xf)||M(this,xf,new z0({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:K(this,Tt,Yle).bind(this),onPinching:K(this,Tt,Vle).bind(this),onPinchEnd:K(this,Tt,Wle).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(s=this._uiManager._editorUndoBar)==null||s.hide(),e}pointerdown(e){const{isMac:n}=Ea.platform;if(e.button!==0||e.ctrlKey&&n){e.preventDefault();return}if(M(this,Nf,!0),this._isDraggable){K(this,Tt,jle).call(this,e);return}K(this,Tt,t6).call(this,e)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){_(this,Ol)&&clearTimeout(_(this,Ol)),M(this,Ol,setTimeout(()=>{var e;M(this,Ol,null),(e=this.parent)==null||e.moveEditorInDOM(this)},0))}_setParentAndPosition(e,n,r){e.changeParent(this),this.x=n,this.y=r,this.fixAndSetPosition(),this._onTranslated()}getRect(e,n,r=this.rotation){const a=this.parentScale,[i,s]=this.pageDimensions,[o,l]=this.pageTranslation,u=e/a,p=n/a,f=this.x*i,m=this.y*s,g=this.width*i,S=this.height*s;switch(r){case 0:return[f+u+o,s-m-p-S+l,f+u+g+o,s-m-p+l];case 90:return[f+p+o,s-m+u+l,f+p+S+o,s-m+u+g+l];case 180:return[f-u-g+o,s-m+p+l,f-u+o,s-m+p+S+l];case 270:return[f-p-S+o,s-m-u-g+l,f-p+o,s-m-u+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,n){const[r,a,i,s]=e,o=i-r,l=s-a;switch(this.rotation){case 0:return[r,n-s,o,l];case 90:return[r,n-a,l,o];case 180:return[i,n-a,o,l];case 270:return[i,n-s,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&kt._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var e;(e=_(this,Jn))==null||e.onUpdatedColor()}getData(){const{comment:{text:e,color:n,date:r,opacity:a,deleted:i,richText:s},uid:o,pageIndex:l,creationDate:u,modificationDate:p}=this;return{id:o,pageIndex:l,rect:this.getPDFRect(),richText:s,contentsObj:{str:e},creationDate:u,modificationDate:r||p,popupRef:!i,color:n,opacity:a}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),M(this,wf,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),M(this,wf,!1),!0):!1}isInEditMode(){return _(this,wf)}shouldGetKeyboardEvents(){return _(this,Pc)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:n,bottom:r,right:a}=this.getClientDimensions(),{innerHeight:i,innerWidth:s}=window;return n<s&&a>0&&e<i&&r>0}rebuild(){K(this,Tt,n6).call(this)}rotate(e){}resize(){}serializeDeleted(){var e;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((e=this._initialData)==null?void 0:e.popupRef)||""}}serialize(e=!1,n=null){var r;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((r=this._initialData)==null?void 0:r.popupRef)||""}}static async deserialize(e,n,r){const a=new this.prototype.constructor({parent:n,id:n.getNextId(),uiManager:r,annotationElementId:e.annotationElementId,creationDate:e.creationDate,modificationDate:e.modificationDate});a.rotation=e.rotation,M(a,Cf,e.accessibilityData),a._isCopy=e.isCopy||!1;const[i,s]=a.pageDimensions,[o,l,u,p]=a.getRectInCurrentCoords(e.rect,s);return a.x=o/i,a.y=l/s,a.width=u/i,a.height=p/s,a}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var e,n;if((e=_(this,Nd))==null||e.abort(),M(this,Nd,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),_(this,Ol)&&(clearTimeout(_(this,Ol)),M(this,Ol,null)),K(this,Tt,Ry).call(this),this.removeEditToolbar(),_(this,js)){for(const r of _(this,js).values())clearTimeout(r);M(this,js,null)}this.parent=null,(n=_(this,xf))==null||n.destroy(),M(this,xf,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(K(this,Tt,Hle).call(this),_(this,La).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[e,n]}=this,[r,a,i,s]=this.getPDFRect();return[kt._round(r+(i-r)*e),kt._round(a+(s-a)*(1-n))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return _(this,Jn).commentPopupPositionInLayer}set commentPopupPosition(e){_(this,Jn).commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return _(this,Jn).hasDefaultPopupPosition()}get commentButtonWidth(){return _(this,Jn).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){_(this,Jn).setCommentButtonStates(e)}keydown(e){if(!this.isResizable||e.target!==this.div||e.key!=="Enter")return;this._uiManager.setSelected(this),M(this,Lc,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const n=_(this,La).children;if(!_(this,Mo)){M(this,Mo,Array.from(n));const s=K(this,Tt,Kle).bind(this),o=K(this,Tt,Xle).bind(this),l=this._uiManager._signal;for(const u of _(this,Mo)){const p=u.getAttribute("data-resizer-name");u.setAttribute("role","spinbutton"),u.addEventListener("keydown",s,{signal:l}),u.addEventListener("blur",o,{signal:l}),u.addEventListener("focus",K(this,Tt,Qle).bind(this,p),{signal:l}),u.setAttribute("data-l10n-id",kt._l10nResizer[p])}}const r=_(this,Mo)[0];let a=0;for(const s of n){if(s===r)break;a++}const i=(360-this.rotation+this.parentRotation)%360/90*(_(this,Mo).length/4);if(i!==a){if(i<a)for(let o=0;o<a-i;o++)_(this,La).append(_(this,La).firstChild);else if(i>a)for(let o=0;o<i-a;o++)_(this,La).firstChild.before(_(this,La).lastChild);let s=0;for(const o of n){const u=_(this,Mo)[s++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",kt._l10nResizer[u])}}K(this,Tt,r6).call(this,0),M(this,Pc,!0),_(this,La).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(e,n){_(this,Pc)&&K(this,Tt,e6).call(this,_(this,TE),{deltaX:e,deltaY:n,fromKeyboard:!0})}_stopResizingWithKeyboard(){K(this,Tt,Ry).call(this),this.div.focus()}select(){var e,n,r;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(e=this.div)==null||e.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var a,i;(a=this.div)!=null&&a.classList.contains("selectedEditor")&&((i=this._editToolbar)==null||i.show())});return}(n=this._editToolbar)==null||n.show(),(r=_(this,_r))==null||r.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var e;return(e=this.div)==null?void 0:e.focus({preventScroll:!0})},0)}unselect(){var e,n,r,a,i;this.isSelected&&(this.isSelected=!1,(e=_(this,La))==null||e.classList.add("hidden"),(n=this.div)==null||n.classList.remove("selectedEditor"),(r=this.div)!=null&&r.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(a=this._editToolbar)==null||a.hide(),(i=_(this,_r))==null||i.toggleAltTextBadge(!0),this.hasComment&&this._uiManager.toggleComment(this,!1,!1))}updateParams(e,n){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(e){e.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return _(this,AE)}set isEditing(e){M(this,AE,e),this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,n=!1){if(n){_(this,js)||M(this,js,new Map);const{action:r}=e;let a=_(this,js).get(r);a&&clearTimeout(a),a=setTimeout(()=>{this._reportTelemetry(e),_(this,js).delete(r),_(this,js).size===0&&M(this,js,null)},kt._telemetryTimeout),_(this,js).set(r,a);return}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),M(this,yg,!1)}disable(){this.div&&(this.div.tabIndex=-1),M(this,yg,!0)}updateFakeAnnotationElement(e){if(!_(this,xl)&&!this.deleted){M(this,xl,e.addFakeAnnotation(this));return}if(this.deleted){_(this,xl).remove(),M(this,xl,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&_(this,xl).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;let n=e.container.querySelector(".annotationContent");if(!n)n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),e.container.prepend(n);else if(n.nodeName==="CANVAS"){const r=n;n=document.createElement("div"),n.classList.add("annotationContent",this.editorType),r.before(n)}return n}resetAnnotationElement(e){const{firstChild:n}=e.container;(n==null?void 0:n.nodeName)==="DIV"&&n.classList.contains("annotationContent")&&n.remove()}};Cf=new WeakMap,Mo=new WeakMap,_r=new WeakMap,Jn=new WeakMap,Mc=new WeakMap,yg=new WeakMap,Rd=new WeakMap,vE=new WeakMap,La=new WeakMap,Rf=new WeakMap,Lc=new WeakMap,xl=new WeakMap,Nd=new WeakMap,TE=new WeakMap,Nf=new WeakMap,ls=new WeakMap,AE=new WeakMap,wf=new WeakMap,Pc=new WeakMap,Ol=new WeakMap,vg=new WeakMap,Tg=new WeakMap,js=new WeakMap,xf=new WeakMap,CE=new WeakMap,eC=new WeakMap,Tt=new WeakSet,QB=function([e,n],r,a){[r,a]=this.screenToPageTranslation(r,a),this.x+=r/e,this.y+=a/n,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},RE=new WeakSet,ZB=function(e,n,r){switch(r){case 90:return[n,-e];case 180:return[-e,-n];case 270:return[-n,e];default:return[e,n]}},RR=function(e){switch(e){case 90:{const[n,r]=this.pageDimensions;return[0,-n/r,r/n,0]}case 180:return[-1,0,0,-1];case 270:{const[n,r]=this.pageDimensions;return[0,n/r,-r/n,0]}default:return[1,0,0,1]}},Hle=function(){if(_(this,La))return;M(this,La,document.createElement("div")),_(this,La).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],n=this._uiManager._signal;for(const r of e){const a=document.createElement("div");_(this,La).append(a),a.classList.add("resizer",r),a.setAttribute("data-resizer-name",r),a.addEventListener("pointerdown",K(this,Tt,$le).bind(this,r),{signal:n}),a.addEventListener("contextmenu",as,{signal:n}),a.tabIndex=-1}this.div.prepend(_(this,La))},$le=function(e,n){var p;n.preventDefault();const{isMac:r}=Ea.platform;if(n.button!==0||n.ctrlKey&&r)return;(p=_(this,_r))==null||p.toggle(!1);const a=this._isDraggable;this._isDraggable=!1,M(this,Rf,[n.screenX,n.screenY]);const i=new AbortController,s=this._uiManager.combinedSignal(i);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",K(this,Tt,e6).bind(this,e),{passive:!0,capture:!0,signal:s}),window.addEventListener("touchmove",Rr,{passive:!1,signal:s}),window.addEventListener("contextmenu",as,{signal:s}),M(this,Lc,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(n.target).cursor;const u=()=>{var f;i.abort(),this.parent.togglePointerEvents(!0),(f=_(this,_r))==null||f.toggle(!0),this._isDraggable=a,this.parent.div.style.cursor=o,this.div.style.cursor=l,K(this,Tt,NR).call(this)};window.addEventListener("pointerup",u,{signal:s}),window.addEventListener("blur",u,{signal:s})},JB=function(e,n,r,a){this.width=r,this.height=a,this.x=e,this.y=n,this.setDims(),this.fixAndSetPosition(),this._onResized()},NR=function(){if(!_(this,Lc))return;const{savedX:e,savedY:n,savedWidth:r,savedHeight:a}=_(this,Lc);M(this,Lc,null);const i=this.x,s=this.y,o=this.width,l=this.height;i===e&&s===n&&o===r&&l===a||this.addCommands({cmd:K(this,Tt,JB).bind(this,i,s,o,l),undo:K(this,Tt,JB).bind(this,e,n,r,a),mustExec:!0})},e6=function(e,n){const[r,a]=this.parentDimensions,i=this.x,s=this.y,o=this.width,l=this.height,u=kt.MIN_SIZE/r,p=kt.MIN_SIZE/a,f=K(this,Tt,RR).call(this,this.rotation),m=(z,V)=>[f[0]*z+f[2]*V,f[1]*z+f[3]*V],g=K(this,Tt,RR).call(this,360-this.rotation),S=(z,V)=>[g[0]*z+g[2]*V,g[1]*z+g[3]*V];let E,y,v=!1,A=!1;switch(e){case"topLeft":v=!0,E=(z,V)=>[0,0],y=(z,V)=>[z,V];break;case"topMiddle":E=(z,V)=>[z/2,0],y=(z,V)=>[z/2,V];break;case"topRight":v=!0,E=(z,V)=>[z,0],y=(z,V)=>[0,V];break;case"middleRight":A=!0,E=(z,V)=>[z,V/2],y=(z,V)=>[0,V/2];break;case"bottomRight":v=!0,E=(z,V)=>[z,V],y=(z,V)=>[0,0];break;case"bottomMiddle":E=(z,V)=>[z/2,V],y=(z,V)=>[z/2,0];break;case"bottomLeft":v=!0,E=(z,V)=>[0,V],y=(z,V)=>[z,0];break;case"middleLeft":A=!0,E=(z,V)=>[0,V/2],y=(z,V)=>[z,V/2];break}const T=E(o,l),w=y(o,l);let O=m(...w);const R=kt._round(i+O[0]),I=kt._round(s+O[1]);let L=1,P=1,U,H;if(n.fromKeyboard)({deltaX:U,deltaY:H}=n);else{const{screenX:z,screenY:V}=n,[X,te]=_(this,Rf);[U,H]=this.screenToPageTranslation(z-X,V-te),_(this,Rf)[0]=z,_(this,Rf)[1]=V}if([U,H]=S(U/r,H/a),v){const z=Math.hypot(o,l);L=P=Math.max(Math.min(Math.hypot(w[0]-T[0]-U,w[1]-T[1]-H)/z,1/o,1/l),u/o,p/l)}else A?L=Ka(Math.abs(w[0]-T[0]-U),u,1)/o:P=Ka(Math.abs(w[1]-T[1]-H),p,1)/l;const W=kt._round(o*L),Z=kt._round(l*P);O=m(...y(W,Z));const F=R-O[0],j=I-O[1];_(this,ls)||M(this,ls,[this.x,this.y,this.width,this.height]),this.width=W,this.height=Z,this.x=F,this.y=j,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Yle=function(){var e;M(this,Lc,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(e=_(this,_r))==null||e.toggle(!1),this.parent.togglePointerEvents(!1)},Vle=function(e,n,r){let i=.7*(r/n)+1-.7;if(i===1)return;const s=K(this,Tt,RR).call(this,this.rotation),o=(R,I)=>[s[0]*R+s[2]*I,s[1]*R+s[3]*I],[l,u]=this.parentDimensions,p=this.x,f=this.y,m=this.width,g=this.height,S=kt.MIN_SIZE/l,E=kt.MIN_SIZE/u;i=Math.max(Math.min(i,1/m,1/g),S/m,E/g);const y=kt._round(m*i),v=kt._round(g*i);if(y===m&&v===g)return;_(this,ls)||M(this,ls,[p,f,m,g]);const A=o(m/2,g/2),T=kt._round(p+A[0]),w=kt._round(f+A[1]),O=o(y/2,v/2);this.x=T-O[0],this.y=w-O[1],this.width=y,this.height=v,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Wle=function(){var e;(e=_(this,_r))==null||e.toggle(!0),this.parent.togglePointerEvents(!0),K(this,Tt,NR).call(this)},t6=function(e){const{isMac:n}=Ea.platform;e.ctrlKey&&!n||e.shiftKey||e.metaKey&&n?this.parent.toggleSelected(this):this.parent.setSelected(this)},jle=function(e){const{isSelected:n}=this;this._uiManager.setUpDragSession();let r=!1;const a=new AbortController,i=this._uiManager.combinedSignal(a),s={capture:!0,passive:!1,signal:i},o=u=>{a.abort(),M(this,Rd,null),M(this,Nf,!1),this._uiManager.endDragSession()||K(this,Tt,t6).call(this,u),r&&this._onStopDragging()};n&&(M(this,vg,e.clientX),M(this,Tg,e.clientY),M(this,Rd,e.pointerId),M(this,vE,e.pointerType),window.addEventListener("pointermove",u=>{r||(r=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:p,clientY:f,pointerId:m}=u;if(m!==_(this,Rd)){Rr(u);return}const[g,S]=this.screenToPageTranslation(p-_(this,vg),f-_(this,Tg));M(this,vg,p),M(this,Tg,f),this._uiManager.dragSelectedEditors(g,S)},s),window.addEventListener("touchmove",Rr,s),window.addEventListener("pointerdown",u=>{u.pointerType===_(this,vE)&&(_(this,xf)||u.isPrimary)&&o(u),Rr(u)},s));const l=u=>{if(!_(this,Rd)||_(this,Rd)===u.pointerId){o(u);return}Rr(u)};window.addEventListener("pointerup",l,{signal:i}),window.addEventListener("blur",l,{signal:i})},n6=function(){if(_(this,Nd)||!this.div)return;M(this,Nd,new AbortController);const e=this._uiManager.combinedSignal(_(this,Nd));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})},Kle=function(e){kt._resizerKeyboardManager.exec(this,e)},Xle=function(e){var n;_(this,Pc)&&((n=e.relatedTarget)==null?void 0:n.parentNode)!==_(this,La)&&K(this,Tt,Ry).call(this)},Qle=function(e){M(this,TE,_(this,Pc)?e:"")},r6=function(e){if(_(this,Mo))for(const n of _(this,Mo))n.tabIndex=e},Ry=function(){M(this,Pc,!1),K(this,Tt,r6).call(this,-1),K(this,Tt,NR).call(this)},Y(kt,RE),Pe(kt,"_l10n",null),Pe(kt,"_l10nResizer",null),Pe(kt,"_borderLineWidth",-1),Pe(kt,"_colorManager",new nF),Pe(kt,"_zIndex",1),Pe(kt,"_telemetryTimeout",1e3);let or=kt;class EUe extends or{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Lre=3285377520,Bs=4294901760,El=65535;class Pre{constructor(e){this.h1=e?e&4294967295:Lre,this.h2=e?e&4294967295:Lre}update(e){let n,r;if(typeof e=="string"){n=new Uint8Array(e.length*2),r=0;for(let E=0,y=e.length;E<y;E++){const v=e.charCodeAt(E);v<=255?n[r++]=v:(n[r++]=v>>>8,n[r++]=v&255)}}else if(ArrayBuffer.isView(e))n=e.slice(),r=n.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const a=r>>2,i=r-a*4,s=new Uint32Array(n.buffer,0,a);let o=0,l=0,u=this.h1,p=this.h2;const f=3432918353,m=461845907,g=f&El,S=m&El;for(let E=0;E<a;E++)E&1?(o=s[E],o=o*f&Bs|o*g&El,o=o<<15|o>>>17,o=o*m&Bs|o*S&El,u^=o,u=u<<13|u>>>19,u=u*5+3864292196):(l=s[E],l=l*f&Bs|l*g&El,l=l<<15|l>>>17,l=l*m&Bs|l*S&El,p^=l,p=p<<13|p>>>19,p=p*5+3864292196);switch(o=0,i){case 3:o^=n[a*4+2]<<16;case 2:o^=n[a*4+1]<<8;case 1:o^=n[a*4],o=o*f&Bs|o*g&El,o=o<<15|o>>>17,o=o*m&Bs|o*S&El,a&1?u^=o:p^=o}this.h1=u,this.h2=p}hexdigest(){let e=this.h1,n=this.h2;return e^=n>>>1,e=e*3981806797&Bs|e*36045&El,n=n*4283543511&Bs|((n<<16|e>>>16)*2950163797&Bs)>>>16,e^=n>>>1,e=e*444984403&Bs|e*60499&El,n=n*3301882366&Bs|((n<<16|e>>>16)*3120437893&Bs)>>>16,e^=n>>>1,(e>>>0).toString(16).padStart(8,"0")+(n>>>0).toString(16).padStart(8,"0")}}const rF=Object.freeze({map:null,hash:"",transfer:void 0});class aF{constructor(){Y(this,tC);Y(this,Of,!1);Y(this,If,null);Y(this,Fc,null);Y(this,Pa,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,n){const r=_(this,Pa).get(e);return r===void 0?n:Object.assign(n,r)}getRawValue(e){return _(this,Pa).get(e)}remove(e){const n=_(this,Pa).get(e);if(n!==void 0&&(n instanceof or&&_(this,Fc).delete(n.annotationElementId),_(this,Pa).delete(e),_(this,Pa).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(const r of _(this,Pa).values())if(r instanceof or)return;this.onAnnotationEditor(null)}}setValue(e,n){const r=_(this,Pa).get(e);let a=!1;if(r!==void 0)for(const[i,s]of Object.entries(n))r[i]!==s&&(a=!0,r[i]=s);else a=!0,_(this,Pa).set(e,n);a&&K(this,tC,Zle).call(this),n instanceof or&&((_(this,Fc)||M(this,Fc,new Map)).set(n.annotationElementId,n),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(n.constructor._type))}has(e){return _(this,Pa).has(e)}get size(){return _(this,Pa).size}resetModified(){_(this,Of)&&(M(this,Of,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Fre(this)}get serializable(){if(_(this,Pa).size===0)return rF;const e=new Map,n=new Pre,r=[],a=Object.create(null);let i=!1;for(const[s,o]of _(this,Pa)){const l=o instanceof or?o.serialize(!1,a):o;l&&(e.set(s,l),n.update(`${s}:${JSON.stringify(l)}`),i||(i=!!l.bitmap))}if(i)for(const s of e.values())s.bitmap&&r.push(s.bitmap);return e.size>0?{map:e,hash:n.hexdigest(),transfer:r}:rF}get editorStats(){let e=null;const n=new Map;let r=0,a=0;for(const i of _(this,Pa).values()){if(!(i instanceof or)){i.popup&&(i.popup.deleted?a+=1:r+=1);continue}i.isCommentDeleted?a+=1:i.hasEditedComment&&(r+=1);const s=i.telemetryFinalData;if(!s)continue;const{type:o}=s;n.has(o)||n.set(o,Object.getPrototypeOf(i).constructor),e||(e=Object.create(null));const l=e[o]||(e[o]=new Map);for(const[u,p]of Object.entries(s)){if(u==="type")continue;let f=l.get(u);f||(f=new Map,l.set(u,f));const m=f.get(p)??0;f.set(p,m+1)}}if((a>0||r>0)&&(e||(e=Object.create(null)),e.comments={deleted:a,edited:r}),!e)return null;for(const[i,s]of n)e[i]=s.computeTelemetryFinalData(e[i]);return e}resetModifiedIds(){M(this,If,null)}updateEditor(e,n){var a;const r=(a=_(this,Fc))==null?void 0:a.get(e);return r?(r.updateFromAnnotationLayer(n),!0):!1}getEditor(e){var n;return((n=_(this,Fc))==null?void 0:n.get(e))||null}get modifiedIds(){if(_(this,If))return _(this,If);const e=[];if(_(this,Fc))for(const n of _(this,Fc).values())n.serialize()&&e.push(n.annotationElementId);return M(this,If,{ids:new Set(e),hash:e.join(",")})}[Symbol.iterator](){return _(this,Pa).entries()}}Of=new WeakMap,If=new WeakMap,Fc=new WeakMap,Pa=new WeakMap,tC=new WeakSet,Zle=function(){_(this,Of)||(M(this,Of,!0),typeof this.onSetModified=="function"&&this.onSetModified())};class Fre extends aF{constructor(n){super();Y(this,NE);const{map:r,hash:a,transfer:i}=n.serializable,s=structuredClone(r,i?{transfer:i}:null);M(this,NE,{map:s,hash:a,transfer:i})}get print(){Qn("Should not call PrintAnnotationStorage.print")}get serializable(){return _(this,NE)}get modifiedIds(){return qt(this,"modifiedIds",{ids:new Set,hash:""})}}NE=new WeakMap;class SUe{constructor({ownerDocument:e=globalThis.document,styleElement:n=null}){Y(this,Ag,new Set);this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const n=this.styleElement.sheet;n.insertRule(e,n.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),_(this,Ag).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,disableFontFace:n,_inspectFont:r}){if(!(!e||_(this,Ag).has(e.loadedName))){if(on(!n,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:a,src:i,style:s}=e,o=new FontFace(a,i,s);this.addNativeFontFace(o);try{await o.load(),_(this,Ag).add(a),r==null||r(e)}catch{It(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}Qn("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const r=e.createNativeFontFace();if(r){this.addNativeFontFace(r);try{await r.loaded}catch(a){throw It(`Failed to load font '${r.family}': '${a}'.`),e.disableFontFace=!0,a}}return}const n=e.createFontFaceRule();if(n){if(this.insertRule(n),this.isSyncFontLoadingSupported)return;await new Promise(r=>{const a=this._queueLoadingCallback(r);this._prepareFontLoadEvent(e,a)})}}get isFontLoadingAPISupported(){var n;const e=!!((n=this._document)!=null&&n.fonts);return qt(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){return qt(this,"isSyncFontLoadingSupported",ui||Ea.platform.isFirefox)}_queueLoadingCallback(e){function n(){for(on(!a.done,"completeRequest() cannot be called twice."),a.done=!0;r.length>0&&r[0].done;){const i=r.shift();setTimeout(i.callback,0)}}const{loadingRequests:r}=this,a={done:!1,complete:n,callback:e};return r.push(a),a}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return qt(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,n){function r(w,O){return w.charCodeAt(O)<<24|w.charCodeAt(O+1)<<16|w.charCodeAt(O+2)<<8|w.charCodeAt(O+3)&255}function a(w,O,R,I){const L=w.substring(0,O),P=w.substring(O+R);return L+I+P}let i,s;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let u=0;function p(w,O){if(++u>30){It("Load test font never loaded."),O();return}if(l.font="30px "+w,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){O();return}setTimeout(p.bind(null,w,O))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let m=this._loadTestFont;m=a(m,976,f.length,f);const S=16,E=1482184792;let y=r(m,S);for(i=0,s=f.length-3;i<s;i+=4)y=y-E+r(f,i)|0;i<f.length&&(y=y-E+r(f+"XXX",i)|0),m=a(m,S,4,oUe(y));const v=`url(data:font/opentype;base64,${btoa(m)});`,A=`@font-face {font-family:"${f}";src:${v}}`;this.insertRule(A);const T=this._document.createElement("div");T.style.visibility="hidden",T.style.width=T.style.height="10px",T.style.position="absolute",T.style.top=T.style.left="0px";for(const w of[e.loadedName,f]){const O=this._document.createElement("span");O.textContent="Hi",O.style.fontFamily=w,T.append(O)}this._document.body.append(T),p(f,()=>{T.remove(),n.complete()})}}Ag=new WeakMap;class yUe{constructor(e,n=null,r,a){Y(this,Un);this.compiledGlyphs=Object.create(null),M(this,Un,e),this._inspectFont=n,r&&Object.assign(this,r),a&&(this.charProcOperatorList=a)}createNativeFontFace(){var n;if(!this.data||this.disableFontFace)return null;let e;if(!this.cssFontInfo)e=new FontFace(this.loadedName,this.data,{});else{const r={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(r.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,r)}return(n=this._inspectFont)==null||n.call(this,this),e}createFontFaceRule(){var r;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${vre(this.data)});`;let n;if(!this.cssFontInfo)n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;else{let a=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(a+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${a}src:${e}}`}return(r=this._inspectFont)==null||r.call(this,this,e),n}getPathGenerator(e,n){if(this.compiledGlyphs[n]!==void 0)return this.compiledGlyphs[n];const r=this.loadedName+"_path_"+n;let a;try{a=e.get(r)}catch(s){It(`getPathGenerator - ignoring character: "${s}".`)}const i=new Path2D(a||"");return this.fontExtraProperties||e.delete(r),this.compiledGlyphs[n]=i}get black(){return _(this,Un).black}get bold(){return _(this,Un).bold}get disableFontFace(){return _(this,Un).disableFontFace??!1}get fontExtraProperties(){return _(this,Un).fontExtraProperties??!1}get isInvalidPDFjsFont(){return _(this,Un).isInvalidPDFjsFont}get isType3Font(){return _(this,Un).isType3Font}get italic(){return _(this,Un).italic}get missingFile(){return _(this,Un).missingFile}get remeasure(){return _(this,Un).remeasure}get vertical(){return _(this,Un).vertical}get ascent(){return _(this,Un).ascent}get defaultWidth(){return _(this,Un).defaultWidth}get descent(){return _(this,Un).descent}get bbox(){return _(this,Un).bbox}get fontMatrix(){return _(this,Un).fontMatrix}get fallbackName(){return _(this,Un).fallbackName}get loadedName(){return _(this,Un).loadedName}get mimetype(){return _(this,Un).mimetype}get name(){return _(this,Un).name}get data(){return _(this,Un).data}clearData(){_(this,Un).clearData()}get cssFontInfo(){return _(this,Un).cssFontInfo}get systemFontInfo(){return _(this,Un).systemFontInfo}get defaultVMetrics(){return _(this,Un).defaultVMetrics}}Un=new WeakMap;function vUe(t){if(t instanceof URL)return t.href;if(typeof t=="string"){if(ui)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function TUe(t){if(ui&&typeof Buffer<"u"&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if(typeof t=="string")return M0(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||typeof t=="object"&&!isNaN(t==null?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function NA(t){if(typeof t!="string")return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const iF=t=>typeof t=="object"&&Number.isInteger(t==null?void 0:t.num)&&t.num>=0&&Number.isInteger(t==null?void 0:t.gen)&&t.gen>=0,AUe=t=>typeof t=="object"&&typeof(t==null?void 0:t.name)=="string",Bre=dUe.bind(null,iF,AUe);class CUe{constructor(){Y(this,Bc,new Map);Y(this,nC,Promise.resolve())}postMessage(e,n){const r={data:structuredClone(e,n?{transfer:n}:null)};_(this,nC).then(()=>{for(const[a]of _(this,Bc))a.call(this,r)})}addEventListener(e,n,r=null){let a=null;if((r==null?void 0:r.signal)instanceof AbortSignal){const{signal:i}=r;if(i.aborted){It("LoopbackPort - cannot use an `aborted` signal.");return}const s=()=>this.removeEventListener(e,n);a=()=>i.removeEventListener("abort",s),i.addEventListener("abort",s)}_(this,Bc).set(n,a)}removeEventListener(e,n){const r=_(this,Bc).get(n);r==null||r(),_(this,Bc).delete(n)}terminate(){for(const[,e]of _(this,Bc))e==null||e();_(this,Bc).clear()}}Bc=new WeakMap,nC=new WeakMap;const wA={DATA:1,ERROR:2},Jr={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Ure(){}function xi(t){if(t instanceof yc||t instanceof yA||t instanceof bre||t instanceof k0||t instanceof V3)return t;switch(t instanceof Error||typeof t=="object"&&t!==null||Qn('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new yc(t.message);case"InvalidPDFException":return new yA(t.message);case"PasswordException":return new bre(t.message,t.code);case"ResponseException":return new k0(t.message,t.status,t.missing);case"UnknownErrorException":return new V3(t.message,t.details)}return new V3(t.message,t.toString())}class q0{constructor(e,n,r){Y(this,Ks);Y(this,Cg,new AbortController);this.sourceName=e,this.targetName=n,this.comObj=r,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),r.addEventListener("message",K(this,Ks,Jle).bind(this),{signal:_(this,Cg).signal})}on(e,n){const r=this.actionHandler;if(r[e])throw new Error(`There is already an actionName called "${e}"`);r[e]=n}send(e,n,r){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:n},r)}sendWithPromise(e,n,r){const a=this.callbackId++,i=Promise.withResolvers();this.callbackCapabilities[a]=i;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:a,data:n},r)}catch(s){i.reject(s)}return i.promise}sendWithStream(e,n,r,a){const i=this.streamId++,s=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:u=>{const p=Promise.withResolvers();return this.streamControllers[i]={controller:u,startCall:p,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:s,targetName:o,action:e,streamId:i,data:n,desiredSize:u.desiredSize},a),p.promise},pull:u=>{const p=Promise.withResolvers();return this.streamControllers[i].pullCall=p,l.postMessage({sourceName:s,targetName:o,stream:Jr.PULL,streamId:i,desiredSize:u.desiredSize}),p.promise},cancel:u=>{on(u instanceof Error,"cancel must have a valid reason");const p=Promise.withResolvers();return this.streamControllers[i].cancelCall=p,this.streamControllers[i].isClosed=!0,l.postMessage({sourceName:s,targetName:o,stream:Jr.CANCEL,streamId:i,reason:xi(u)}),p.promise}},r)}destroy(){var e;(e=_(this,Cg))==null||e.abort(),M(this,Cg,null)}}Cg=new WeakMap,Ks=new WeakSet,Jle=function({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){K(this,Ks,tce).call(this,e);return}if(e.callback){const r=e.callbackId,a=this.callbackCapabilities[r];if(!a)throw new Error(`Cannot resolve callback ${r}`);if(delete this.callbackCapabilities[r],e.callback===wA.DATA)a.resolve(e.data);else if(e.callback===wA.ERROR)a.reject(xi(e.reason));else throw new Error("Unexpected callback case");return}const n=this.actionHandler[e.action];if(!n)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const r=this.sourceName,a=e.sourceName,i=this.comObj;Promise.try(n,e.data).then(function(s){i.postMessage({sourceName:r,targetName:a,callback:wA.DATA,callbackId:e.callbackId,data:s})},function(s){i.postMessage({sourceName:r,targetName:a,callback:wA.ERROR,callbackId:e.callbackId,reason:xi(s)})});return}if(e.streamId){K(this,Ks,ece).call(this,e);return}n(e.data)},ece=function(e){const n=e.streamId,r=this.sourceName,a=e.sourceName,i=this.comObj,s=this,o=this.actionHandler[e.action],l={enqueue(u,p=1,f){if(this.isCancelled)return;const m=this.desiredSize;this.desiredSize-=p,m>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),i.postMessage({sourceName:r,targetName:a,stream:Jr.ENQUEUE,streamId:n,chunk:u},f)},close(){this.isCancelled||(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:a,stream:Jr.CLOSE,streamId:n}),delete s.streamSinks[n])},error(u){on(u instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,i.postMessage({sourceName:r,targetName:a,stream:Jr.ERROR,streamId:n,reason:xi(u)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[n]=l,Promise.try(o,e.data,l).then(function(){i.postMessage({sourceName:r,targetName:a,stream:Jr.START_COMPLETE,streamId:n,success:!0})},function(u){i.postMessage({sourceName:r,targetName:a,stream:Jr.START_COMPLETE,streamId:n,reason:xi(u)})})},tce=function(e){const n=e.streamId,r=this.sourceName,a=e.sourceName,i=this.comObj,s=this.streamControllers[n],o=this.streamSinks[n];switch(e.stream){case Jr.START_COMPLETE:e.success?s.startCall.resolve():s.startCall.reject(xi(e.reason));break;case Jr.PULL_COMPLETE:e.success?s.pullCall.resolve():s.pullCall.reject(xi(e.reason));break;case Jr.PULL:if(!o){i.postMessage({sourceName:r,targetName:a,stream:Jr.PULL_COMPLETE,streamId:n,success:!0});break}o.desiredSize<=0&&e.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=e.desiredSize,Promise.try(o.onPull||Ure).then(function(){i.postMessage({sourceName:r,targetName:a,stream:Jr.PULL_COMPLETE,streamId:n,success:!0})},function(u){i.postMessage({sourceName:r,targetName:a,stream:Jr.PULL_COMPLETE,streamId:n,reason:xi(u)})});break;case Jr.ENQUEUE:if(on(s,"enqueue should have stream controller"),s.isClosed)break;s.controller.enqueue(e.chunk);break;case Jr.CLOSE:if(on(s,"close should have stream controller"),s.isClosed)break;s.isClosed=!0,s.controller.close(),K(this,Ks,wR).call(this,s,n);break;case Jr.ERROR:on(s,"error should have stream controller"),s.controller.error(xi(e.reason)),K(this,Ks,wR).call(this,s,n);break;case Jr.CANCEL_COMPLETE:e.success?s.cancelCall.resolve():s.cancelCall.reject(xi(e.reason)),K(this,Ks,wR).call(this,s,n);break;case Jr.CANCEL:if(!o)break;const l=xi(e.reason);Promise.try(o.onCancel||Ure,l).then(function(){i.postMessage({sourceName:r,targetName:a,stream:Jr.CANCEL_COMPLETE,streamId:n,success:!0})},function(u){i.postMessage({sourceName:r,targetName:a,stream:Jr.CANCEL_COMPLETE,streamId:n,reason:xi(u)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[n];break;default:throw new Error("Unexpected stream case")}},wR=async function(e,n){var r,a,i;await Promise.allSettled([(r=e.startCall)==null?void 0:r.promise,(a=e.pullCall)==null?void 0:a.promise,(i=e.cancelCall)==null?void 0:i.promise]),delete this.streamControllers[n]};class Gre{constructor({enableHWA:e=!1}){Y(this,wE,!1);M(this,wE,e)}create(e,n){if(e<=0||n<=0)throw new Error("Invalid canvas size");const r=this._createCanvas(e,n);return{canvas:r,context:r.getContext("2d",{willReadFrequently:!_(this,wE)})}}reset(e,n,r){if(!e.canvas)throw new Error("Canvas is not specified");if(n<=0||r<=0)throw new Error("Invalid canvas size");e.canvas.width=n,e.canvas.height=r}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,n){Qn("Abstract method `_createCanvas` called.")}}wE=new WeakMap;class RUe extends Gre{constructor({ownerDocument:e=globalThis.document,enableHWA:n=!1}){super({enableHWA:n}),this._document=e}_createCanvas(e,n){const r=this._document.createElement("canvas");return r.width=e,r.height=n,r}}class zre{constructor({baseUrl:e=null,isCompressed:n=!0}){this.baseUrl=e,this.isCompressed=n}async fetch({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");const n=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(n).then(r=>({cMapData:r,isCompressed:this.isCompressed})).catch(r=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${n}`)})}async _fetch(e){Qn("Abstract method `_fetch` called.")}}class qre extends zre{async _fetch(e){const n=await Wh(e,this.isCompressed?"arraybuffer":"text");return n instanceof ArrayBuffer?new Uint8Array(n):M0(n)}}class Hre{addFilter(e){return"none"}addHCMFilter(e,n){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,n,r,a,i){return"none"}destroy(e=!1){}}class NUe extends Hre{constructor({docId:n,ownerDocument:r=globalThis.document}){super();Y(this,Ze);Y(this,Df);Y(this,Rg);Y(this,Uc);Y(this,Gc);Y(this,Ja);Y(this,kf);Y(this,Mf,0);M(this,Gc,n),M(this,Ja,r)}addFilter(n){if(!n)return"none";let r=_(this,Ze,ii).get(n);if(r)return r;const[a,i,s]=K(this,Ze,xR).call(this,n),o=n.length===1?a:`${a}${i}${s}`;if(r=_(this,Ze,ii).get(o),r)return _(this,Ze,ii).set(n,r),r;const l=`g_${_(this,Gc)}_transfer_map_${_a(this,Mf)._++}`,u=K(this,Ze,mb).call(this,l);_(this,Ze,ii).set(n,u),_(this,Ze,ii).set(o,u);const p=K(this,Ze,hb).call(this,l);return K(this,Ze,xy).call(this,a,i,s,p),u}addHCMFilter(n,r){var S;const a=`${n}-${r}`,i="base";let s=_(this,Ze,Ny).get(i);if((s==null?void 0:s.key)===a||(s?((S=s.filter)==null||S.remove(),s.key=a,s.url="none",s.filter=null):(s={key:a,url:"none",filter:null},_(this,Ze,Ny).set(i,s)),!n||!r))return s.url;const o=K(this,Ze,Oy).call(this,n);n=Je.makeHexColor(...o);const l=K(this,Ze,Oy).call(this,r);if(r=Je.makeHexColor(...l),_(this,Ze,fb).style.color="",n==="#000000"&&r==="#ffffff"||n===r)return s.url;const u=new Array(256);for(let E=0;E<=255;E++){const y=E/255;u[E]=y<=.03928?y/12.92:((y+.055)/1.055)**2.4}const p=u.join(","),f=`g_${_(this,Gc)}_hcm_filter`,m=s.filter=K(this,Ze,hb).call(this,f);K(this,Ze,xy).call(this,p,p,p,m),K(this,Ze,a6).call(this,m);const g=(E,y)=>{const v=o[E]/255,A=l[E]/255,T=new Array(y+1);for(let w=0;w<=y;w++)T[w]=v+w/y*(A-v);return T.join(",")};return K(this,Ze,xy).call(this,g(0,5),g(1,5),g(2,5),m),s.url=K(this,Ze,mb).call(this,f),s.url}addAlphaFilter(n){let r=_(this,Ze,ii).get(n);if(r)return r;const[a]=K(this,Ze,xR).call(this,[n]),i=`alpha_${a}`;if(r=_(this,Ze,ii).get(i),r)return _(this,Ze,ii).set(n,r),r;const s=`g_${_(this,Gc)}_alpha_map_${_a(this,Mf)._++}`,o=K(this,Ze,mb).call(this,s);_(this,Ze,ii).set(n,o),_(this,Ze,ii).set(i,o);const l=K(this,Ze,hb).call(this,s);return K(this,Ze,i6).call(this,a,l),o}addLuminosityFilter(n){let r=_(this,Ze,ii).get(n||"luminosity");if(r)return r;let a,i;if(n?([a]=K(this,Ze,xR).call(this,[n]),i=`luminosity_${a}`):i="luminosity",r=_(this,Ze,ii).get(i),r)return _(this,Ze,ii).set(n,r),r;const s=`g_${_(this,Gc)}_luminosity_map_${_a(this,Mf)._++}`,o=K(this,Ze,mb).call(this,s);_(this,Ze,ii).set(n,o),_(this,Ze,ii).set(i,o);const l=K(this,Ze,hb).call(this,s);return K(this,Ze,nce).call(this,l),n&&K(this,Ze,i6).call(this,a,l),o}addHighlightHCMFilter(n,r,a,i,s){var A;const o=`${r}-${a}-${i}-${s}`;let l=_(this,Ze,Ny).get(n);if((l==null?void 0:l.key)===o||(l?((A=l.filter)==null||A.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},_(this,Ze,Ny).set(n,l)),!r||!a))return l.url;const[u,p]=[r,a].map(K(this,Ze,Oy).bind(this));let f=Math.round(.2126*u[0]+.7152*u[1]+.0722*u[2]),m=Math.round(.2126*p[0]+.7152*p[1]+.0722*p[2]),[g,S]=[i,s].map(K(this,Ze,Oy).bind(this));m<f&&([f,m,g,S]=[m,f,S,g]),_(this,Ze,fb).style.color="";const E=(T,w,O)=>{const R=new Array(256),I=(m-f)/O,L=T/255,P=(w-T)/(255*O);let U=0;for(let H=0;H<=O;H++){const W=Math.round(f+H*I),Z=L+H*P;for(let F=U;F<=W;F++)R[F]=Z;U=W+1}for(let H=U;H<256;H++)R[H]=R[U-1];return R.join(",")},y=`g_${_(this,Gc)}_hcm_${n}_filter`,v=l.filter=K(this,Ze,hb).call(this,y);return K(this,Ze,a6).call(this,v),K(this,Ze,xy).call(this,E(g[0],S[0],5),E(g[1],S[1],5),E(g[2],S[2],5),v),l.url=K(this,Ze,mb).call(this,y),l.url}destroy(n=!1){var r,a,i,s;n&&((r=_(this,kf))!=null&&r.size)||((a=_(this,Uc))==null||a.parentNode.parentNode.remove(),M(this,Uc,null),(i=_(this,Rg))==null||i.clear(),M(this,Rg,null),(s=_(this,kf))==null||s.clear(),M(this,kf,null),M(this,Mf,0))}}Df=new WeakMap,Rg=new WeakMap,Uc=new WeakMap,Gc=new WeakMap,Ja=new WeakMap,kf=new WeakMap,Mf=new WeakMap,Ze=new WeakSet,ii=function(){return _(this,Rg)||M(this,Rg,new Map)},Ny=function(){return _(this,kf)||M(this,kf,new Map)},fb=function(){if(!_(this,Uc)){const n=_(this,Ja).createElement("div"),{style:r}=n;r.visibility="hidden",r.contain="strict",r.width=r.height=0,r.position="absolute",r.top=r.left=0,r.zIndex=-1;const a=_(this,Ja).createElementNS(vc,"svg");a.setAttribute("width",0),a.setAttribute("height",0),M(this,Uc,_(this,Ja).createElementNS(vc,"defs")),n.append(a),a.append(_(this,Uc)),_(this,Ja).body.append(n)}return _(this,Uc)},xR=function(n){if(n.length===1){const u=n[0],p=new Array(256);for(let m=0;m<256;m++)p[m]=u[m]/255;const f=p.join(",");return[f,f,f]}const[r,a,i]=n,s=new Array(256),o=new Array(256),l=new Array(256);for(let u=0;u<256;u++)s[u]=r[u]/255,o[u]=a[u]/255,l[u]=i[u]/255;return[s.join(","),o.join(","),l.join(",")]},mb=function(n){if(_(this,Df)===void 0){M(this,Df,"");const r=_(this,Ja).URL;r!==_(this,Ja).baseURI&&(F0(r)?It('#createUrl: ignore "data:"-URL for performance reasons.'):M(this,Df,Y3(r,"")))}return`url(${_(this,Df)}#${n})`},nce=function(n){const r=_(this,Ja).createElementNS(vc,"feColorMatrix");r.setAttribute("type","matrix"),r.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),n.append(r)},a6=function(n){const r=_(this,Ja).createElementNS(vc,"feColorMatrix");r.setAttribute("type","matrix"),r.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),n.append(r)},hb=function(n){const r=_(this,Ja).createElementNS(vc,"filter");return r.setAttribute("color-interpolation-filters","sRGB"),r.setAttribute("id",n),_(this,Ze,fb).append(r),r},wy=function(n,r,a){const i=_(this,Ja).createElementNS(vc,r);i.setAttribute("type","discrete"),i.setAttribute("tableValues",a),n.append(i)},xy=function(n,r,a,i){const s=_(this,Ja).createElementNS(vc,"feComponentTransfer");i.append(s),K(this,Ze,wy).call(this,s,"feFuncR",n),K(this,Ze,wy).call(this,s,"feFuncG",r),K(this,Ze,wy).call(this,s,"feFuncB",a)},i6=function(n,r){const a=_(this,Ja).createElementNS(vc,"feComponentTransfer");r.append(a),K(this,Ze,wy).call(this,a,"feFuncA",n)},Oy=function(n){return _(this,Ze,fb).style.color=n,jh(getComputedStyle(_(this,Ze,fb)).getPropertyValue("color"))};class $re{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const n=`${this.baseUrl}${e}`;return this._fetch(n).catch(r=>{throw new Error(`Unable to load font data at: ${n}`)})}async _fetch(e){Qn("Abstract method `_fetch` called.")}}class Yre extends $re{async _fetch(e){const n=await Wh(e,"arraybuffer");return new Uint8Array(n)}}class Vre{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!e)throw new Error("Wasm filename must be specified.");const n=`${this.baseUrl}${e}`;return this._fetch(n).catch(r=>{throw new Error(`Unable to load wasm data at: ${n}`)})}async _fetch(e){Qn("Abstract method `_fetch` called.")}}class Wre extends Vre{async _fetch(e){const n=await Wh(e,"arraybuffer");return new Uint8Array(n)}}ui&&It("Please use the `legacy` build in Node.js environments.");async function sF(t){const n=await process.getBuiltinModule("fs").promises.readFile(t);return new Uint8Array(n)}class wUe extends Hre{}class xUe extends Gre{_createCanvas(e,n){return process.getBuiltinModule("module").createRequire(wn&&wn.tagName.toUpperCase()==="SCRIPT"&&wn.src||new URL("app.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(e,n)}}class OUe extends zre{async _fetch(e){return sF(e)}}class IUe extends $re{async _fetch(e){return sF(e)}}class DUe extends Vre{async _fetch(e){return sF(e)}}const Kh="__forcedDependency",{floor:jre,ceil:Kre}=Math;function xA(t,e,n,r,a,i){t[e*4+0]=Math.min(t[e*4+0],n),t[e*4+1]=Math.min(t[e*4+1],r),t[e*4+2]=Math.max(t[e*4+2],a),t[e*4+3]=Math.max(t[e*4+3],i)}const oF=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class kUe{constructor(e,n){Y(this,Ng);Y(this,wd);M(this,Ng,e),M(this,wd,n)}get length(){return _(this,Ng).length}isEmpty(e){return _(this,Ng)[e]===oF}minX(e){return _(this,wd)[e*4+0]/256}minY(e){return _(this,wd)[e*4+1]/256}maxX(e){return(_(this,wd)[e*4+2]+1)/256}maxY(e){return(_(this,wd)[e*4+3]+1)/256}}Ng=new WeakMap,wd=new WeakMap;const OA=(t,e)=>{if(!t)return;let n=t.get(e);return n||(n={dependencies:new Set,isRenderingOperation:!1},t.set(e,n)),n};class MUe{constructor(e,n,r=!1){Y(this,OE);Y(this,Di,{__proto__:null});Y(this,ki,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Kh]:[]});Y(this,Lf,new Map);Y(this,Lo,[]);Y(this,Pf,[]);Y(this,zc,[[1,0,0,1,0,0]]);Y(this,kn,[-1/0,-1/0,1/0,1/0]);Y(this,Gn,new Float64Array([1/0,1/0,-1/0,-1/0]));Y(this,qc,-1);Y(this,Mi,new Set);Y(this,xE,new Map);Y(this,wg,new Map);Y(this,Ff);Y(this,Bf);Y(this,Hc);Y(this,ei);Y(this,Il);M(this,Ff,e.width),M(this,Bf,e.height),K(this,OE,s6).call(this,n),r&&M(this,Il,new Map)}growOperationsCount(e){e>=_(this,ei).length&&K(this,OE,s6).call(this,e,_(this,ei))}save(e){return M(this,Di,{__proto__:_(this,Di)}),M(this,ki,{__proto__:_(this,ki),transform:{__proto__:_(this,ki).transform},moveText:{__proto__:_(this,ki).moveText},sameLineText:{__proto__:_(this,ki).sameLineText},[Kh]:{__proto__:_(this,ki)[Kh]}}),M(this,kn,{__proto__:_(this,kn)}),_(this,Lo).push(e),this}restore(e){var a;const n=Object.getPrototypeOf(_(this,Di));if(n===null)return this;M(this,Di,n),M(this,ki,Object.getPrototypeOf(_(this,ki))),M(this,kn,Object.getPrototypeOf(_(this,kn)));const r=_(this,Lo).pop();return r!==void 0&&((a=OA(_(this,Il),e))==null||a.dependencies.add(r),_(this,ei)[e]=_(this,ei)[r]),this}recordOpenMarker(e){return _(this,Lo).push(e),this}getOpenMarker(){return _(this,Lo).length===0?null:_(this,Lo).at(-1)}recordCloseMarker(e){var r;const n=_(this,Lo).pop();return n!==void 0&&((r=OA(_(this,Il),e))==null||r.dependencies.add(n),_(this,ei)[e]=_(this,ei)[n]),this}beginMarkedContent(e){return _(this,Pf).push(e),this}endMarkedContent(e){var r;const n=_(this,Pf).pop();return n!==void 0&&((r=OA(_(this,Il),e))==null||r.dependencies.add(n),_(this,ei)[e]=_(this,ei)[n]),this}pushBaseTransform(e){return _(this,zc).push(Je.multiplyByDOMMatrix(_(this,zc).at(-1),e.getTransform())),this}popBaseTransform(){return _(this,zc).length>1&&_(this,zc).pop(),this}recordSimpleData(e,n){return _(this,Di)[e]=n,this}recordIncrementalData(e,n){return _(this,ki)[e].push(n),this}resetIncrementalData(e,n){return _(this,ki)[e].length=0,this}recordNamedData(e,n){return _(this,Lf).set(e,n),this}recordSimpleDataFromNamed(e,n,r){_(this,Di)[e]=_(this,Lf).get(n)??r}recordFutureForcedDependency(e,n){return this.recordIncrementalData(Kh,n),this}inheritSimpleDataAsFutureForcedDependencies(e){for(const n of e)n in _(this,Di)&&this.recordFutureForcedDependency(n,_(this,Di)[n]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const e of _(this,Mi))this.recordFutureForcedDependency(Kh,e);return this}resetBBox(e){return _(this,qc)!==e&&(M(this,qc,e),_(this,Gn)[0]=1/0,_(this,Gn)[1]=1/0,_(this,Gn)[2]=-1/0,_(this,Gn)[3]=-1/0),this}recordClipBox(e,n,r,a,i,s){const o=Je.multiplyByDOMMatrix(_(this,zc).at(-1),n.getTransform()),l=[1/0,1/0,-1/0,-1/0];Je.axialAlignedBoundingBox([r,i,a,s],o,l);const u=Je.intersect(_(this,kn),l);return u?(_(this,kn)[0]=u[0],_(this,kn)[1]=u[1],_(this,kn)[2]=u[2],_(this,kn)[3]=u[3]):(_(this,kn)[0]=_(this,kn)[1]=1/0,_(this,kn)[2]=_(this,kn)[3]=-1/0),this}recordBBox(e,n,r,a,i,s){const o=_(this,kn);if(o[0]===1/0)return this;const l=Je.multiplyByDOMMatrix(_(this,zc).at(-1),n.getTransform());if(o[0]===-1/0)return Je.axialAlignedBoundingBox([r,i,a,s],l,_(this,Gn)),this;const u=[1/0,1/0,-1/0,-1/0];return Je.axialAlignedBoundingBox([r,i,a,s],l,u),_(this,Gn)[0]=Math.min(_(this,Gn)[0],Math.max(u[0],o[0])),_(this,Gn)[1]=Math.min(_(this,Gn)[1],Math.max(u[1],o[1])),_(this,Gn)[2]=Math.max(_(this,Gn)[2],Math.min(u[2],o[2])),_(this,Gn)[3]=Math.max(_(this,Gn)[3],Math.min(u[3],o[3])),this}recordCharacterBBox(e,n,r,a=1,i=0,s=0,o){const l=r.bbox;let u,p;if(l&&(u=l[2]!==l[0]&&l[3]!==l[1]&&_(this,wg).get(r),u!==!1&&(p=[0,0,0,0],Je.axialAlignedBoundingBox(l,r.fontMatrix,p),(a!==1||i!==0||s!==0)&&Je.scaleMinMax([a,0,0,-a,i,s],p),u)))return this.recordBBox(e,n,p[0],p[2],p[1],p[3]);if(!o)return this.recordFullPageBBox(e);const f=o();return l&&p&&u===void 0&&(u=p[0]<=i-f.actualBoundingBoxLeft&&p[2]>=i+f.actualBoundingBoxRight&&p[1]<=s-f.actualBoundingBoxAscent&&p[3]>=s+f.actualBoundingBoxDescent,_(this,wg).set(r,u),u)?this.recordBBox(e,n,p[0],p[2],p[1],p[3]):this.recordBBox(e,n,i-f.actualBoundingBoxLeft,i+f.actualBoundingBoxRight,s-f.actualBoundingBoxAscent,s+f.actualBoundingBoxDescent)}recordFullPageBBox(e){return _(this,Gn)[0]=Math.max(0,_(this,kn)[0]),_(this,Gn)[1]=Math.max(0,_(this,kn)[1]),_(this,Gn)[2]=Math.min(_(this,Ff),_(this,kn)[2]),_(this,Gn)[3]=Math.min(_(this,Bf),_(this,kn)[3]),this}getSimpleIndex(e){return _(this,Di)[e]}recordDependencies(e,n){const r=_(this,Mi),a=_(this,Di),i=_(this,ki);for(const s of n)s in _(this,Di)?r.add(a[s]):s in i&&i[s].forEach(r.add,r);return this}recordNamedDependency(e,n){return _(this,Lf).has(n)&&_(this,Mi).add(_(this,Lf).get(n)),this}recordOperation(e,n=!1){if(this.recordDependencies(e,[Kh]),_(this,Il)){const r=OA(_(this,Il),e),{dependencies:a}=r;_(this,Mi).forEach(a.add,a),_(this,Lo).forEach(a.add,a),_(this,Pf).forEach(a.add,a),a.delete(e),r.isRenderingOperation=!0}if(_(this,qc)===e){const r=jre(_(this,Gn)[0]*256/_(this,Ff)),a=jre(_(this,Gn)[1]*256/_(this,Bf)),i=Kre(_(this,Gn)[2]*256/_(this,Ff)),s=Kre(_(this,Gn)[3]*256/_(this,Bf));xA(_(this,Hc),e,r,a,i,s);for(const o of _(this,Mi))o!==e&&xA(_(this,Hc),o,r,a,i,s);for(const o of _(this,Lo))o!==e&&xA(_(this,Hc),o,r,a,i,s);for(const o of _(this,Pf))o!==e&&xA(_(this,Hc),o,r,a,i,s);n||(_(this,Mi).clear(),M(this,qc,-1))}return this}recordShowTextOperation(e,n=!1){const r=Array.from(_(this,Mi));this.recordOperation(e,n),this.recordIncrementalData("sameLineText",e);for(const a of r)this.recordIncrementalData("sameLineText",a);return this}bboxToClipBoxDropOperation(e,n=!1){return _(this,qc)===e&&(M(this,qc,-1),_(this,kn)[0]=Math.max(_(this,kn)[0],_(this,Gn)[0]),_(this,kn)[1]=Math.max(_(this,kn)[1],_(this,Gn)[1]),_(this,kn)[2]=Math.min(_(this,kn)[2],_(this,Gn)[2]),_(this,kn)[3]=Math.min(_(this,kn)[3],_(this,Gn)[3]),n||_(this,Mi).clear()),this}_takePendingDependencies(){const e=_(this,Mi);return M(this,Mi,new Set),e}_extractOperation(e){const n=_(this,xE).get(e);return _(this,xE).delete(e),n}_pushPendingDependencies(e){for(const n of e)_(this,Mi).add(n)}take(){return _(this,wg).clear(),new kUe(_(this,ei),_(this,Hc))}takeDebugMetadata(){return _(this,Il)}}Di=new WeakMap,ki=new WeakMap,Lf=new WeakMap,Lo=new WeakMap,Pf=new WeakMap,zc=new WeakMap,kn=new WeakMap,Gn=new WeakMap,qc=new WeakMap,Mi=new WeakMap,xE=new WeakMap,wg=new WeakMap,Ff=new WeakMap,Bf=new WeakMap,Hc=new WeakMap,ei=new WeakMap,Il=new WeakMap,OE=new WeakSet,s6=function(e,n){const r=new ArrayBuffer(e*4);M(this,Hc,new Uint8ClampedArray(r)),M(this,ei,new Uint32Array(r)),n&&n.length>0?(_(this,ei).set(n),_(this,ei).fill(oF,n.length)):_(this,ei).fill(oF)};const BF=class BF{constructor(e,n,r){Y(this,er);Y(this,Lr);Y(this,Po);Y(this,xg,0);Y(this,Og,0);if(e instanceof BF&&_(e,Po)===!!r)return e;M(this,er,e),M(this,Lr,n),M(this,Po,!!r)}growOperationsCount(){throw new Error("Unreachable")}save(e){return _a(this,Og)._++,_(this,er).save(_(this,Lr)),this}restore(e){return _(this,Og)>0&&(_(this,er).restore(_(this,Lr)),_a(this,Og)._--),this}recordOpenMarker(e){return _a(this,xg)._++,this}getOpenMarker(){return _(this,xg)>0?_(this,Lr):_(this,er).getOpenMarker()}recordCloseMarker(e){return _a(this,xg)._--,this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){return _(this,er).pushBaseTransform(e),this}popBaseTransform(){return _(this,er).popBaseTransform(),this}recordSimpleData(e,n){return _(this,er).recordSimpleData(e,_(this,Lr)),this}recordIncrementalData(e,n){return _(this,er).recordIncrementalData(e,_(this,Lr)),this}resetIncrementalData(e,n){return _(this,er).resetIncrementalData(e,_(this,Lr)),this}recordNamedData(e,n){return this}recordSimpleDataFromNamed(e,n,r){return _(this,er).recordSimpleDataFromNamed(e,n,_(this,Lr)),this}recordFutureForcedDependency(e,n){return _(this,er).recordFutureForcedDependency(e,_(this,Lr)),this}inheritSimpleDataAsFutureForcedDependencies(e){return _(this,er).inheritSimpleDataAsFutureForcedDependencies(e),this}inheritPendingDependenciesAsFutureForcedDependencies(){return _(this,er).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(e){return _(this,Po)||_(this,er).resetBBox(_(this,Lr)),this}recordClipBox(e,n,r,a,i,s){return _(this,Po)||_(this,er).recordClipBox(_(this,Lr),n,r,a,i,s),this}recordBBox(e,n,r,a,i,s){return _(this,Po)||_(this,er).recordBBox(_(this,Lr),n,r,a,i,s),this}recordCharacterBBox(e,n,r,a,i,s,o){return _(this,Po)||_(this,er).recordCharacterBBox(_(this,Lr),n,r,a,i,s,o),this}recordFullPageBBox(e){return _(this,Po)||_(this,er).recordFullPageBBox(_(this,Lr)),this}getSimpleIndex(e){return _(this,er).getSimpleIndex(e)}recordDependencies(e,n){return _(this,er).recordDependencies(_(this,Lr),n),this}recordNamedDependency(e,n){return _(this,er).recordNamedDependency(_(this,Lr),n),this}recordOperation(e){return _(this,er).recordOperation(_(this,Lr),!0),this}recordShowTextOperation(e){return _(this,er).recordShowTextOperation(_(this,Lr),!0),this}bboxToClipBoxDropOperation(e){return _(this,Po)||_(this,er).bboxToClipBoxDropOperation(_(this,Lr),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};er=new WeakMap,Lr=new WeakMap,Po=new WeakMap,xg=new WeakMap,Og=new WeakMap;let IA=BF;const Us={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]},Da={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function lF(t,e){if(!e)return;const n=e[2]-e[0],r=e[3]-e[1],a=new Path2D;a.rect(e[0],e[1],n,r),t.clip(a)}class cF{isModifyingCurrentTransform(){return!1}getPattern(){Qn("Abstract method `getPattern` called.")}}class LUe extends cF{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let n;this._type==="axial"?n=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(n=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const r of this._colorStops)n.addColorStop(r[0],r[1]);return n}getPattern(e,n,r,a){let i;if(a===Da.STROKE||a===Da.FILL){const s=n.current.getClippedPathBoundingBox(a,Nr(e))||[0,0,0,0],o=Math.ceil(s[2]-s[0])||1,l=Math.ceil(s[3]-s[1])||1,u=n.cachedCanvases.getCanvas("pattern",o,l),p=u.context;p.clearRect(0,0,p.canvas.width,p.canvas.height),p.beginPath(),p.rect(0,0,p.canvas.width,p.canvas.height),p.translate(-s[0],-s[1]),r=Je.transform(r,[1,0,0,1,s[0],s[1]]),p.transform(...n.baseTransform),this.matrix&&p.transform(...this.matrix),lF(p,this._bbox),p.fillStyle=this._createGradient(p),p.fill(),i=e.createPattern(u.canvas,"no-repeat");const f=new DOMMatrix(r);i.setTransform(f)}else lF(e,this._bbox),i=this._createGradient(e);return i}}function uF(t,e,n,r,a,i,s,o){const l=e.coords,u=e.colors,p=t.data,f=t.width*4;let m;l[n+1]>l[r+1]&&(m=n,n=r,r=m,m=i,i=s,s=m),l[r+1]>l[a+1]&&(m=r,r=a,a=m,m=s,s=o,o=m),l[n+1]>l[r+1]&&(m=n,n=r,r=m,m=i,i=s,s=m);const g=(l[n]+e.offsetX)*e.scaleX,S=(l[n+1]+e.offsetY)*e.scaleY,E=(l[r]+e.offsetX)*e.scaleX,y=(l[r+1]+e.offsetY)*e.scaleY,v=(l[a]+e.offsetX)*e.scaleX,A=(l[a+1]+e.offsetY)*e.scaleY;if(S>=A)return;const T=u[i],w=u[i+1],O=u[i+2],R=u[s],I=u[s+1],L=u[s+2],P=u[o],U=u[o+1],H=u[o+2],W=Math.round(S),Z=Math.round(A);let F,j,z,V,X,te,$,Q;for(let ee=W;ee<=Z;ee++){if(ee<y){const ne=ee<S?0:(S-ee)/(S-y);F=g-(g-E)*ne,j=T-(T-R)*ne,z=w-(w-I)*ne,V=O-(O-L)*ne}else{let ne;ee>A?ne=1:y===A?ne=0:ne=(y-ee)/(y-A),F=E-(E-v)*ne,j=R-(R-P)*ne,z=I-(I-U)*ne,V=L-(L-H)*ne}let B;ee<S?B=0:ee>A?B=1:B=(S-ee)/(S-A),X=g-(g-v)*B,te=T-(T-P)*B,$=w-(w-U)*B,Q=O-(O-H)*B;const ie=Math.round(Math.min(F,X)),ce=Math.round(Math.max(F,X));let se=f*ee+ie*4;for(let ne=ie;ne<=ce;ne++)B=(F-ne)/(F-X),B<0?B=0:B>1&&(B=1),p[se++]=j-(j-te)*B|0,p[se++]=z-(z-$)*B|0,p[se++]=V-(V-Q)*B|0,p[se++]=255}}function PUe(t,e,n){const r=e.coords,a=e.colors;let i,s;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(r.length/o)-1,u=o-1;for(i=0;i<l;i++){let p=i*o;for(let f=0;f<u;f++,p++)uF(t,n,r[p],r[p+1],r[p+o],a[p],a[p+1],a[p+o]),uF(t,n,r[p+o+1],r[p+1],r[p+o],a[p+o+1],a[p+1],a[p+o])}break;case"triangles":for(i=0,s=r.length;i<s;i+=3)uF(t,n,r[i],r[i+1],r[i+2],a[i],a[i+1],a[i+2]);break;default:throw new Error("illegal figure")}}class FUe extends cF{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[6],this._background=e[7],this.matrix=null}_createMeshCanvas(e,n,r){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),u=Math.ceil(this._bounds[2])-o,p=Math.ceil(this._bounds[3])-l,f=Math.min(Math.ceil(Math.abs(u*e[0]*1.1)),3e3),m=Math.min(Math.ceil(Math.abs(p*e[1]*1.1)),3e3),g=u/f,S=p/m,E={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/g,scaleY:1/S},y=f+4,v=m+4,A=r.getCanvas("mesh",y,v),T=A.context,w=T.createImageData(f,m);if(n){const R=w.data;for(let I=0,L=R.length;I<L;I+=4)R[I]=n[0],R[I+1]=n[1],R[I+2]=n[2],R[I+3]=255}for(const R of this._figures)PUe(w,R,E);return T.putImageData(w,2,2),{canvas:A.canvas,offsetX:o-2*g,offsetY:l-2*S,scaleX:g,scaleY:S}}isModifyingCurrentTransform(){return!0}getPattern(e,n,r,a){lF(e,this._bbox);const i=new Float32Array(2);if(a===Da.SHADING)Je.singularValueDecompose2dScale(Nr(e),i);else if(this.matrix){Je.singularValueDecompose2dScale(this.matrix,i);const[o,l]=i;Je.singularValueDecompose2dScale(n.baseTransform,i),i[0]*=o,i[1]*=l}else Je.singularValueDecompose2dScale(n.baseTransform,i);const s=this._createMeshCanvas(i,a===Da.SHADING?null:this._background,n.cachedCanvases);return a!==Da.SHADING&&(e.setTransform(...n.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(s.offsetX,s.offsetY),e.scale(s.scaleX,s.scaleY),e.createPattern(s.canvas,"no-repeat")}}class BUe extends cF{getPattern(){return"hotpink"}}function UUe(t){switch(t[0]){case"RadialAxial":return new LUe(t);case"Mesh":return new FUe(t);case"Dummy":return new BUe}throw new Error(`Unknown IR type: ${t[0]}`)}const Xre={COLORED:1,UNCOLORED:2},rC=class rC{constructor(e,n,r,a){this.color=e[1],this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.ctx=n,this.canvasGraphicsFactory=r,this.baseTransform=a}createPatternCanvas(e,n){var te,$;const{bbox:r,operatorList:a,paintType:i,tilingType:s,color:o,canvasGraphicsFactory:l}=this;let{xstep:u,ystep:p}=this;u=Math.abs(u),p=Math.abs(p),SA("TilingType: "+s);const f=r[0],m=r[1],g=r[2],S=r[3],E=g-f,y=S-m,v=new Float32Array(2);Je.singularValueDecompose2dScale(this.matrix,v);const[A,T]=v;Je.singularValueDecompose2dScale(this.baseTransform,v);const w=A*v[0],O=T*v[1];let R=E,I=y,L=!1,P=!1;const U=Math.ceil(u*w),H=Math.ceil(p*O),W=Math.ceil(E*w),Z=Math.ceil(y*O);U>=W?R=u:L=!0,H>=Z?I=p:P=!0;const F=this.getSizeAndScale(R,this.ctx.canvas.width,w),j=this.getSizeAndScale(I,this.ctx.canvas.height,O),z=e.cachedCanvases.getCanvas("pattern",F.size,j.size),V=z.context,X=l.createCanvasGraphics(V,n);if(X.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(X,i,o),V.translate(-F.scale*f,-j.scale*m),X.transform(0,F.scale,0,0,j.scale,0,0),V.save(),(te=X.dependencyTracker)==null||te.save(),this.clipBbox(X,f,m,g,S),X.baseTransform=Nr(X.ctx),X.executeOperatorList(a),X.endDrawing(),($=X.dependencyTracker)==null||$.restore(),V.restore(),L||P){const Q=z.canvas;L&&(R=u),P&&(I=p);const ee=this.getSizeAndScale(R,this.ctx.canvas.width,w),B=this.getSizeAndScale(I,this.ctx.canvas.height,O),ie=ee.size,ce=B.size,se=e.cachedCanvases.getCanvas("pattern-workaround",ie,ce),ne=se.context,oe=L?Math.floor(E/u):0,he=P?Math.floor(y/p):0;for(let _e=0;_e<=oe;_e++)for(let Ce=0;Ce<=he;Ce++)ne.drawImage(Q,ie*_e,ce*Ce,ie,ce,0,0,ie,ce);return{canvas:se.canvas,scaleX:ee.scale,scaleY:B.scale,offsetX:f,offsetY:m}}return{canvas:z.canvas,scaleX:F.scale,scaleY:j.scale,offsetX:f,offsetY:m}}getSizeAndScale(e,n,r){const a=Math.max(rC.MAX_PATTERN_SIZE,n);let i=Math.ceil(e*r);return i>=a?i=a:r=i/e,{scale:r,size:i}}clipBbox(e,n,r,a,i){const s=a-n,o=i-r;e.ctx.rect(n,r,s,o),Je.axialAlignedBoundingBox([n,r,a,i],Nr(e.ctx),e.current.minMax),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,n,r){const a=e.ctx,i=e.current;switch(n){case Xre.COLORED:const{fillStyle:s,strokeStyle:o}=this.ctx;a.fillStyle=i.fillColor=s,a.strokeStyle=i.strokeColor=o;break;case Xre.UNCOLORED:a.fillStyle=a.strokeStyle=r,i.fillColor=i.strokeColor=r;break;default:throw new sUe(`Unsupported paint type: ${n}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,n,r,a,i){let s=r;a!==Da.SHADING&&(s=Je.transform(s,n.baseTransform),this.matrix&&(s=Je.transform(s,this.matrix)));const o=this.createPatternCanvas(n,i);let l=new DOMMatrix(s);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const u=e.createPattern(o.canvas,"repeat");return u.setTransform(l),u}};Pe(rC,"MAX_PATTERN_SIZE",3e3);let dF=rC;function GUe({src:t,srcPos:e=0,dest:n,width:r,height:a,nonBlackColor:i=4294967295,inverseDecode:s=!1}){const o=Ea.isLittleEndian?4278190080:255,[l,u]=s?[i,o]:[o,i],p=r>>3,f=r&7,m=t.length;n=new Uint32Array(n.buffer);let g=0;for(let S=0;S<a;S++){for(const y=e+p;e<y;e++){const v=e<m?t[e]:255;n[g++]=v&128?u:l,n[g++]=v&64?u:l,n[g++]=v&32?u:l,n[g++]=v&16?u:l,n[g++]=v&8?u:l,n[g++]=v&4?u:l,n[g++]=v&2?u:l,n[g++]=v&1?u:l}if(f===0)continue;const E=e<m?t[e++]:255;for(let y=0;y<f;y++)n[g++]=E&1<<7-y?u:l}return{srcPos:e,destPos:g}}const Qre=16,Zre=100,zUe=15,Jre=10,Oi=16,pF=new DOMMatrix,is=new Float32Array(2),Xh=new Float32Array([1/0,1/0,-1/0,-1/0]);function qUe(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(n,r){e.translate(n,r),this.__originalTranslate(n,r)},t.scale=function(n,r){e.scale(n,r),this.__originalScale(n,r)},t.transform=function(n,r,a,i,s,o){e.transform(n,r,a,i,s,o),this.__originalTransform(n,r,a,i,s,o)},t.setTransform=function(n,r,a,i,s,o){e.setTransform(n,r,a,i,s,o),this.__originalSetTransform(n,r,a,i,s,o)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(n){e.rotate(n),this.__originalRotate(n)},t.clip=function(n){e.clip(n),this.__originalClip(n)},t.moveTo=function(n,r){e.moveTo(n,r),this.__originalMoveTo(n,r)},t.lineTo=function(n,r){e.lineTo(n,r),this.__originalLineTo(n,r)},t.bezierCurveTo=function(n,r,a,i,s,o){e.bezierCurveTo(n,r,a,i,s,o),this.__originalBezierCurveTo(n,r,a,i,s,o)},t.rect=function(n,r,a,i){e.rect(n,r,a,i),this.__originalRect(n,r,a,i)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}class HUe{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,n,r){let a;return this.cache[e]!==void 0?(a=this.cache[e],this.canvasFactory.reset(a,n,r)):(a=this.canvasFactory.create(n,r),this.cache[e]=a),a}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const n=this.cache[e];this.canvasFactory.destroy(n),delete this.cache[e]}}}function DA(t,e,n,r,a,i,s,o,l,u){const[p,f,m,g,S,E]=Nr(t);if(f===0&&m===0){const A=s*p+S,T=Math.round(A),w=o*g+E,O=Math.round(w),R=(s+l)*p+S,I=Math.abs(Math.round(R)-T)||1,L=(o+u)*g+E,P=Math.abs(Math.round(L)-O)||1;return t.setTransform(Math.sign(p),0,0,Math.sign(g),T,O),t.drawImage(e,n,r,a,i,0,0,I,P),t.setTransform(p,f,m,g,S,E),[I,P]}if(p===0&&g===0){const A=o*m+S,T=Math.round(A),w=s*f+E,O=Math.round(w),R=(o+u)*m+S,I=Math.abs(Math.round(R)-T)||1,L=(s+l)*f+E,P=Math.abs(Math.round(L)-O)||1;return t.setTransform(0,Math.sign(f),Math.sign(m),0,T,O),t.drawImage(e,n,r,a,i,0,0,P,I),t.setTransform(p,f,m,g,S,E),[P,I]}t.drawImage(e,n,r,a,i,s,o,l,u);const y=Math.hypot(p,f),v=Math.hypot(m,g);return[y*l,v*u]}class eae{constructor(e,n,r){Pe(this,"alphaIsShape",!1);Pe(this,"fontSize",0);Pe(this,"fontSizeScale",1);Pe(this,"textMatrix",null);Pe(this,"textMatrixScale",1);Pe(this,"fontMatrix",q3);Pe(this,"leading",0);Pe(this,"x",0);Pe(this,"y",0);Pe(this,"lineX",0);Pe(this,"lineY",0);Pe(this,"charSpacing",0);Pe(this,"wordSpacing",0);Pe(this,"textHScale",1);Pe(this,"textRenderingMode",Ia.FILL);Pe(this,"textRise",0);Pe(this,"fillColor","#000000");Pe(this,"strokeColor","#000000");Pe(this,"patternFill",!1);Pe(this,"patternStroke",!1);Pe(this,"fillAlpha",1);Pe(this,"strokeAlpha",1);Pe(this,"lineWidth",1);Pe(this,"activeSMask",null);Pe(this,"transferMaps","none");r==null||r(this),this.clipBox=new Float32Array([0,0,e,n]),this.minMax=Xh.slice()}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e.minMax=this.minMax.slice(),e}getPathBoundingBox(e=Da.FILL,n=null){const r=this.minMax.slice();if(e===Da.STROKE){n||Qn("Stroke bounding box must include transform."),Je.singularValueDecompose2dScale(n,is);const a=is[0]*this.lineWidth/2,i=is[1]*this.lineWidth/2;r[0]-=a,r[1]-=i,r[2]+=a,r[3]+=i}return r}updateClipFromPath(){const e=Je.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0),this.minMax.set(Xh,0)}getClippedPathBoundingBox(e=Da.FILL,n=null){return Je.intersect(this.clipBox,this.getPathBoundingBox(e,n))}}function tae(t,e){if(e instanceof ImageData){t.putImageData(e,0,0);return}const n=e.height,r=e.width,a=n%Oi,i=(n-a)/Oi,s=a===0?i:i+1,o=t.createImageData(r,Oi);let l=0,u;const p=e.data,f=o.data;let m,g,S,E;if(e.kind===I0.GRAYSCALE_1BPP){const y=p.byteLength,v=new Uint32Array(f.buffer,0,f.byteLength>>2),A=v.length,T=r+7>>3,w=4294967295,O=Ea.isLittleEndian?4278190080:255;for(m=0;m<s;m++){for(S=m<i?Oi:a,u=0,g=0;g<S;g++){const R=y-l;let I=0;const L=R>T?r:R*8-7,P=L&-8;let U=0,H=0;for(;I<P;I+=8)H=p[l++],v[u++]=H&128?w:O,v[u++]=H&64?w:O,v[u++]=H&32?w:O,v[u++]=H&16?w:O,v[u++]=H&8?w:O,v[u++]=H&4?w:O,v[u++]=H&2?w:O,v[u++]=H&1?w:O;for(;I<L;I++)U===0&&(H=p[l++],U=128),v[u++]=H&U?w:O,U>>=1}for(;u<A;)v[u++]=0;t.putImageData(o,0,m*Oi)}}else if(e.kind===I0.RGBA_32BPP){for(g=0,E=r*Oi*4,m=0;m<i;m++)f.set(p.subarray(l,l+E)),l+=E,t.putImageData(o,0,g),g+=Oi;m<s&&(E=r*a*4,f.set(p.subarray(l,l+E)),t.putImageData(o,0,g))}else if(e.kind===I0.RGB_24BPP)for(S=Oi,E=r*S,m=0;m<s;m++){for(m>=i&&(S=a,E=r*S),u=0,g=E;g--;)f[u++]=p[l++],f[u++]=p[l++],f[u++]=p[l++],f[u++]=255;t.putImageData(o,0,m*Oi)}else throw new Error(`bad image kind: ${e.kind}`)}function nae(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}const n=e.height,r=e.width,a=n%Oi,i=(n-a)/Oi,s=a===0?i:i+1,o=t.createImageData(r,Oi);let l=0;const u=e.data,p=o.data;for(let f=0;f<s;f++){const m=f<i?Oi:a;({srcPos:l}=GUe({src:u,srcPos:l,dest:p,width:r,height:m,nonBlackColor:0})),t.putImageData(o,0,f*Oi)}}function H0(t,e){const n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const r of n)t[r]!==void 0&&(e[r]=t[r]);t.setLineDash!==void 0&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function kA(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",t.setLineDash!==void 0&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;e!=="none"&&e!==""&&(t.filter="none")}function rae(t,e){if(e)return!0;Je.singularValueDecompose2dScale(t,is);const n=Math.fround(Oo.pixelRatio*Tc.PDF_TO_CSS_UNITS);return is[0]<=n&&is[1]<=n}const $Ue=["butt","round","square"],YUe=["miter","round","bevel"],VUe={},aae={},UF=class UF{constructor(e,n,r,a,i,{optionalContentConfig:s,markedContentStack:o=null},l,u,p){Y(this,Fo);this.ctx=e,this.current=new eae(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=n,this.objs=r,this.canvasFactory=a,this.filterFactory=i,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=o||[],this.optionalContentConfig=s,this.cachedCanvases=new HUe(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=u,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=p??null}getObject(e,n,r=null){var a;return typeof n=="string"?((a=this.dependencyTracker)==null||a.recordNamedDependency(e,n),n.startsWith("g_")?this.commonObjs.get(n):this.objs.get(n)):r}beginDrawing({transform:e,viewport:n,transparency:r=!1,background:a=null}){const i=this.ctx.canvas.width,s=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=a||"#ffffff",this.ctx.fillRect(0,0,i,s),this.ctx.fillStyle=o,r){const l=this.cachedCanvases.getCanvas("transparent",i,s);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...Nr(this.compositeCtx))}this.ctx.save(),kA(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...n.transform),this.viewportScale=n.scale,this.baseTransform=Nr(this.ctx)}executeOperatorList(e,n,r,a,i){var v;const s=e.argsArray,o=e.fnArray;let l=n||0;const u=s.length;if(u===l)return l;const p=u-l>Jre&&typeof r=="function",f=p?Date.now()+zUe:0;let m=0;const g=this.commonObjs,S=this.objs;let E,y;for(;;){if(a!==void 0&&l===a.nextBreakPoint)return a.breakIt(l,r),l;if(!i||i(l))if(E=o[l],y=s[l]??null,E!==Vh.dependency)y===null?this[E](l):this[E](l,...y);else for(const A of y){(v=this.dependencyTracker)==null||v.recordNamedData(A,l);const T=A.startsWith("g_")?g:S;if(!T.has(A))return T.get(A,r),l}if(l++,l===u)return l;if(p&&++m>Jre){if(Date.now()>f)return r(),l;m=0}}}endDrawing(){K(this,Fo,o6).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const n of e.values())typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement&&(n.width=n.height=0);e.clear()}this._cachedBitmapsMap.clear(),K(this,Fo,l6).call(this)}_scaleImage(e,n){const r=e.width??e.displayWidth,a=e.height??e.displayHeight;let i=Math.max(Math.hypot(n[0],n[1]),1),s=Math.max(Math.hypot(n[2],n[3]),1),o=r,l=a,u="prescale1",p,f;for(;i>2&&o>1||s>2&&l>1;){let m=o,g=l;i>2&&o>1&&(m=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),i/=o/m),s>2&&l>1&&(g=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,s/=l/g),p=this.cachedCanvases.getCanvas(u,m,g),f=p.context,f.clearRect(0,0,m,g),f.drawImage(e,0,0,o,l,0,0,m,g),e=p.canvas,o=m,l=g,u=u==="prescale1"?"prescale2":"prescale1"}return{img:e,paintWidth:o,paintHeight:l}}_createMaskCanvas(e,n){var U,H;const r=this.ctx,{width:a,height:i}=n,s=this.current.fillColor,o=this.current.patternFill,l=Nr(r);let u,p,f,m;if((n.bitmap||n.data)&&n.count>1){const W=n.bitmap||n.data.buffer;p=JSON.stringify(o?l:[l.slice(0,4),s]),u=this._cachedBitmapsMap.get(W),u||(u=new Map,this._cachedBitmapsMap.set(W,u));const Z=u.get(p);if(Z&&!o){const F=Math.round(Math.min(l[0],l[2])+l[4]),j=Math.round(Math.min(l[1],l[3])+l[5]);return(U=this.dependencyTracker)==null||U.recordDependencies(e,Us.transformAndFill),{canvas:Z,offsetX:F,offsetY:j}}f=Z}f||(m=this.cachedCanvases.getCanvas("maskCanvas",a,i),nae(m.context,n));let g=Je.transform(l,[1/a,0,0,-1/i,0,0]);g=Je.transform(g,[1,0,0,1,0,-i]);const S=Xh.slice();Je.axialAlignedBoundingBox([0,0,a,i],g,S);const[E,y,v,A]=S,T=Math.round(v-E)||1,w=Math.round(A-y)||1,O=this.cachedCanvases.getCanvas("fillCanvas",T,w),R=O.context,I=E,L=y;R.translate(-I,-L),R.transform(...g),f||(f=this._scaleImage(m.canvas,bl(R)),f=f.img,u&&o&&u.set(p,f)),R.imageSmoothingEnabled=rae(Nr(R),n.interpolate),DA(R,f,0,0,f.width,f.height,0,0,a,i),R.globalCompositeOperation="source-in";const P=Je.transform(bl(R),[1,0,0,1,-I,-L]);return R.fillStyle=o?s.getPattern(r,this,P,Da.FILL,e):s,R.fillRect(0,0,a,i),u&&!o&&(this.cachedCanvases.delete("fillCanvas"),u.set(p,O.canvas)),(H=this.dependencyTracker)==null||H.recordDependencies(e,Us.transformAndFill),{canvas:O.canvas,offsetX:Math.round(I),offsetY:Math.round(L)}}setLineWidth(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("lineWidth",e),n!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=n,this.ctx.lineWidth=n}setLineCap(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("lineCap",e),this.ctx.lineCap=$Ue[n]}setLineJoin(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("lineJoin",e),this.ctx.lineJoin=YUe[n]}setMiterLimit(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("miterLimit",e),this.ctx.miterLimit=n}setDash(e,n,r){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("dash",e);const a=this.ctx;a.setLineDash!==void 0&&(a.setLineDash(n),a.lineDashOffset=r)}setRenderingIntent(e,n){}setFlatness(e,n){}setGState(e,n){var r,a,i,s,o;for(const[l,u]of n)switch(l){case"LW":this.setLineWidth(e,u);break;case"LC":this.setLineCap(e,u);break;case"LJ":this.setLineJoin(e,u);break;case"ML":this.setMiterLimit(e,u);break;case"D":this.setDash(e,u[0],u[1]);break;case"RI":this.setRenderingIntent(e,u);break;case"FL":this.setFlatness(e,u);break;case"Font":this.setFont(e,u[0],u[1]);break;case"CA":(r=this.dependencyTracker)==null||r.recordSimpleData("strokeAlpha",e),this.current.strokeAlpha=u;break;case"ca":(a=this.dependencyTracker)==null||a.recordSimpleData("fillAlpha",e),this.ctx.globalAlpha=this.current.fillAlpha=u;break;case"BM":(i=this.dependencyTracker)==null||i.recordSimpleData("globalCompositeOperation",e),this.ctx.globalCompositeOperation=u;break;case"SMask":(s=this.dependencyTracker)==null||s.recordSimpleData("SMask",e),this.current.activeSMask=u?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",e),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(u);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(e){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(a,n,r);this.suspendedCtx=this.ctx;const s=this.ctx=i.context;s.setTransform(this.suspendedCtx.getTransform()),H0(this.suspendedCtx,s),qUe(s,this.suspendedCtx),this.setGState(e,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),H0(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const n=this.current.activeSMask,r=this.suspendedCtx;this.composeSMask(r,n,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,n,r,a){const i=a[0],s=a[1],o=a[2]-i,l=a[3]-s;o===0||l===0||(this.genericComposeSMask(n.context,r,o,l,n.subtype,n.backdrop,n.transferMap,i,s,n.offsetX,n.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(r.canvas,0,0),e.restore())}genericComposeSMask(e,n,r,a,i,s,o,l,u,p,f){let m=e.canvas,g=l-p,S=u-f;if(s)if(g<0||S<0||g+r>m.width||S+a>m.height){const y=this.cachedCanvases.getCanvas("maskExtension",r,a),v=y.context;v.drawImage(m,-g,-S),v.globalCompositeOperation="destination-atop",v.fillStyle=s,v.fillRect(0,0,r,a),v.globalCompositeOperation="source-over",m=y.canvas,g=S=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const y=new Path2D;y.rect(g,S,r,a),e.clip(y),e.globalCompositeOperation="destination-atop",e.fillStyle=s,e.fillRect(g,S,r,a),e.restore()}n.save(),n.globalAlpha=1,n.setTransform(1,0,0,1,0,0),i==="Alpha"&&o?n.filter=this.filterFactory.addAlphaFilter(o):i==="Luminosity"&&(n.filter=this.filterFactory.addLuminosityFilter(o));const E=new Path2D;E.rect(l,u,r,a),n.clip(E),n.globalCompositeOperation="destination-in",n.drawImage(m,g,S,r,a,l,u,r,a),n.restore()}save(e){var r;this.inSMaskMode&&H0(this.ctx,this.suspendedCtx),this.ctx.save();const n=this.current;this.stateStack.push(n),this.current=n.clone(),(r=this.dependencyTracker)==null||r.save(e)}restore(e){var n;if((n=this.dependencyTracker)==null||n.restore(e),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&H0(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(e,n,r,a,i,s,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",e),this.ctx.transform(n,r,a,i,s,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,n,r,a){let[i]=r;if(!a){i||(i=r[0]=new Path2D),this[n](e,i);return}if(this.dependencyTracker!==null){const s=n===Vh.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,a[0]-s,a[2]+s,a[1]-s,a[3]+s).recordDependencies(e,["transform"])}if(!(i instanceof Path2D)){const s=r[0]=new Path2D;for(let o=0,l=i.length;o<l;)switch(i[o++]){case bA.moveTo:s.moveTo(i[o++],i[o++]);break;case bA.lineTo:s.lineTo(i[o++],i[o++]);break;case bA.curveTo:s.bezierCurveTo(i[o++],i[o++],i[o++],i[o++],i[o++],i[o++]);break;case bA.closePath:s.closePath();break;default:It(`Unrecognized drawing path operator: ${i[o-1]}`);break}i=s}Je.axialAlignedBoundingBox(a,Nr(this.ctx),this.current.minMax),this[n](e,i),this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,n,r=!0){var s;const a=this.ctx,i=this.current.strokeColor;if(a.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof i=="object"&&(i!=null&&i.getPattern)){const o=i.isModifyingCurrentTransform()?a.getTransform():null;if(a.save(),a.strokeStyle=i.getPattern(a,this,bl(a),Da.STROKE,e),o){const l=new Path2D;l.addPath(n,a.getTransform().invertSelf().multiplySelf(o)),n=l}this.rescaleAndStroke(n,!1),a.restore()}else this.rescaleAndStroke(n,!0);(s=this.dependencyTracker)==null||s.recordDependencies(e,Us.stroke),r&&this.consumePath(e,n,this.current.getClippedPathBoundingBox(Da.STROKE,Nr(this.ctx))),a.globalAlpha=this.current.fillAlpha}closeStroke(e,n){this.stroke(e,n)}fill(e,n,r=!0){var u,p,f;const a=this.ctx,i=this.current.fillColor,s=this.current.patternFill;let o=!1;if(s){const m=i.isModifyingCurrentTransform()?a.getTransform():null;if((u=this.dependencyTracker)==null||u.save(e),a.save(),a.fillStyle=i.getPattern(a,this,bl(a),Da.FILL,e),m){const g=new Path2D;g.addPath(n,a.getTransform().invertSelf().multiplySelf(m)),n=g}o=!0}const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(a.fill(n,"evenodd"),this.pendingEOFill=!1):a.fill(n)),(p=this.dependencyTracker)==null||p.recordDependencies(e,Us.fill),o&&(a.restore(),(f=this.dependencyTracker)==null||f.restore(e)),r&&this.consumePath(e,n,l)}eoFill(e,n){this.pendingEOFill=!0,this.fill(e,n)}fillStroke(e,n){this.fill(e,n,!1),this.stroke(e,n,!1),this.consumePath(e,n)}eoFillStroke(e,n){this.pendingEOFill=!0,this.fillStroke(e,n)}closeFillStroke(e,n){this.fillStroke(e,n)}closeEOFillStroke(e,n){this.pendingEOFill=!0,this.fillStroke(e,n)}endPath(e,n){this.consumePath(e,n)}rawFillPath(e,n){var r;this.ctx.fill(n),(r=this.dependencyTracker)==null||r.recordDependencies(e,Us.rawFillPath).recordOperation(e)}clip(e){var n;(n=this.dependencyTracker)==null||n.recordFutureForcedDependency("clipMode",e),this.pendingClip=VUe}eoClip(e){var n;(n=this.dependencyTracker)==null||n.recordFutureForcedDependency("clipMode",e),this.pendingClip=aae}beginText(e){var n;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(n=this.dependencyTracker)==null||n.recordOpenMarker(e).resetIncrementalData("sameLineText").resetIncrementalData("moveText",e)}endText(e){const n=this.pendingTextPaths,r=this.ctx;if(this.dependencyTracker){const{dependencyTracker:a}=this;n!==void 0&&a.recordFutureForcedDependency("textClip",a.getOpenMarker()).recordFutureForcedDependency("textClip",e),a.recordCloseMarker(e)}if(n!==void 0){const a=new Path2D,i=r.getTransform().invertSelf();for(const{transform:s,x:o,y:l,fontSize:u,path:p}of n)p&&a.addPath(p,new DOMMatrix(s).preMultiplySelf(i).translate(o,l).scale(u,-u));r.clip(a)}delete this.pendingTextPaths}setCharSpacing(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("charSpacing",e),this.current.charSpacing=n}setWordSpacing(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("wordSpacing",e),this.current.wordSpacing=n}setHScale(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("hScale",e),this.current.textHScale=n/100}setLeading(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("leading",e),this.current.leading=-n}setFont(e,n,r){var f,m;(f=this.dependencyTracker)==null||f.recordSimpleData("font",e).recordSimpleDataFromNamed("fontObj",n,e);const a=this.commonObjs.get(n),i=this.current;if(!a)throw new Error(`Can't find font for ${n}`);if(i.fontMatrix=a.fontMatrix||q3,(i.fontMatrix[0]===0||i.fontMatrix[3]===0)&&It("Invalid font matrix for font "+n),r<0?(r=-r,i.fontDirection=-1):i.fontDirection=1,this.current.font=a,this.current.fontSize=r,a.isType3Font)return;const s=a.loadedName||"sans-serif",o=((m=a.systemFontInfo)==null?void 0:m.css)||`"${s}", ${a.fallbackName}`;let l="normal";a.black?l="900":a.bold&&(l="bold");const u=a.italic?"italic":"normal";let p=r;r<Qre?p=Qre:r>Zre&&(p=Zre),this.current.fontSizeScale=r/p,this.ctx.font=`${u} ${l} ${p}px ${o}`}setTextRenderingMode(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("textRenderingMode",e),this.current.textRenderingMode=n}setTextRise(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("textRise",e),this.current.textRise=n}moveText(e,n,r){var a;(a=this.dependencyTracker)==null||a.resetIncrementalData("sameLineText").recordIncrementalData("moveText",e),this.current.x=this.current.lineX+=n,this.current.y=this.current.lineY+=r}setLeadingMoveText(e,n,r){this.setLeading(e,-r),this.moveText(e,n,r)}setTextMatrix(e,n){var a;(a=this.dependencyTracker)==null||a.recordSimpleData("textMatrix",e);const{current:r}=this;r.textMatrix=n,r.textMatrixScale=Math.hypot(n[0],n[1]),r.x=r.lineX=0,r.y=r.lineY=0}nextLine(e){var n;this.moveText(e,0,this.current.leading),(n=this.dependencyTracker)==null||n.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??e)}paintChar(e,n,r,a,i,s){var v,A,T,w;const o=this.ctx,l=this.current,u=l.font,p=l.textRenderingMode,f=l.fontSize/l.fontSizeScale,m=p&Ia.FILL_STROKE_MASK,g=!!(p&Ia.ADD_TO_PATH_FLAG),S=l.patternFill&&!u.missingFile,E=l.patternStroke&&!u.missingFile;let y;if((u.disableFontFace||g||S||E)&&!u.missingFile&&(y=u.getPathGenerator(this.commonObjs,n)),y&&(u.disableFontFace||S||E)){o.save(),o.translate(r,a),o.scale(f,-f),(v=this.dependencyTracker)==null||v.recordCharacterBBox(e,o,u);let O;if(m===Ia.FILL||m===Ia.FILL_STROKE)if(i){O=o.getTransform(),o.setTransform(...i);const R=K(this,Fo,c6).call(this,y,O,i);o.fill(R)}else o.fill(y);if(m===Ia.STROKE||m===Ia.FILL_STROKE)if(s){O||(O=o.getTransform()),o.setTransform(...s);const{a:R,b:I,c:L,d:P}=O,U=Je.inverseTransform(s),H=Je.transform([R,I,L,P,0,0],U);Je.singularValueDecompose2dScale(H,is),o.lineWidth*=Math.max(is[0],is[1])/f,o.stroke(K(this,Fo,c6).call(this,y,O,s))}else o.lineWidth/=f,o.stroke(y);o.restore()}else(m===Ia.FILL||m===Ia.FILL_STROKE)&&(o.fillText(n,r,a),(A=this.dependencyTracker)==null||A.recordCharacterBBox(e,o,u,f,r,a,()=>o.measureText(n))),(m===Ia.STROKE||m===Ia.FILL_STROKE)&&(this.dependencyTracker&&((T=this.dependencyTracker)==null||T.recordCharacterBBox(e,o,u,f,r,a,()=>o.measureText(n)).recordDependencies(e,Us.stroke)),o.strokeText(n,r,a));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Nr(o),x:r,y:a,fontSize:f,path:y}),(w=this.dependencyTracker)==null||w.recordCharacterBBox(e,o,u,f,r,a))}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const n=e.getImageData(0,0,10,10).data;let r=!1;for(let a=3;a<n.length;a+=4)if(n[a]>0&&n[a]<255){r=!0;break}return qt(this,"isFontSubpixelAAEnabled",r)}showText(e,n){var L,P,U,H;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(e,Us.showText).resetBBox(e),this.current.textRenderingMode&Ia.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",e).inheritPendingDependenciesAsFutureForcedDependencies());const r=this.current,a=r.font;if(a.isType3Font){this.showType3Text(e,n),(L=this.dependencyTracker)==null||L.recordShowTextOperation(e);return}const i=r.fontSize;if(i===0){(P=this.dependencyTracker)==null||P.recordOperation(e);return}const s=this.ctx,o=r.fontSizeScale,l=r.charSpacing,u=r.wordSpacing,p=r.fontDirection,f=r.textHScale*p,m=n.length,g=a.vertical,S=g?1:-1,E=a.defaultVMetrics,y=i*r.fontMatrix[0],v=r.textRenderingMode===Ia.FILL&&!a.disableFontFace&&!r.patternFill;s.save(),r.textMatrix&&s.transform(...r.textMatrix),s.translate(r.x,r.y+r.textRise),p>0?s.scale(f,-1):s.scale(f,1);let A,T;if(r.patternFill){s.save();const W=r.fillColor.getPattern(s,this,bl(s),Da.FILL,e);A=Nr(s),s.restore(),s.fillStyle=W}if(r.patternStroke){s.save();const W=r.strokeColor.getPattern(s,this,bl(s),Da.STROKE,e);T=Nr(s),s.restore(),s.strokeStyle=W}let w=r.lineWidth;const O=r.textMatrixScale;if(O===0||w===0){const W=r.textRenderingMode&Ia.FILL_STROKE_MASK;(W===Ia.STROKE||W===Ia.FILL_STROKE)&&(w=this.getSinglePixelWidth())}else w/=O;if(o!==1&&(s.scale(o,o),w/=o),s.lineWidth=w,a.isInvalidPDFjsFont){const W=[];let Z=0;for(const j of n)W.push(j.unicode),Z+=j.width;const F=W.join("");if(s.fillText(F,0,0),this.dependencyTracker!==null){const j=s.measureText(F);this.dependencyTracker.recordBBox(e,this.ctx,-j.actualBoundingBoxLeft,j.actualBoundingBoxRight,-j.actualBoundingBoxAscent,j.actualBoundingBoxDescent).recordShowTextOperation(e)}r.x+=Z*y*f,s.restore(),this.compose();return}let R=0,I;for(I=0;I<m;++I){const W=n[I];if(typeof W=="number"){R+=S*W*i/1e3;continue}let Z=!1;const F=(W.isSpace?u:0)+l,j=W.fontChar,z=W.accent;let V,X,te=W.width;if(g){const ee=W.vmetric||E,B=-(W.vmetric?ee[1]:te*.5)*y,ie=ee[2]*y;te=ee?-ee[0]:te,V=B/o,X=(R+ie)/o}else V=R/o,X=0;let $;if(a.remeasure&&te>0){$=s.measureText(j);const ee=$.width*1e3/i*o;if(te<ee&&this.isFontSubpixelAAEnabled){const B=te/ee;Z=!0,s.save(),s.scale(B,1),V/=B}else te!==ee&&(V+=(te-ee)/2e3*i/o)}if(this.contentVisible&&(W.isInFont||a.missingFile)){if(v&&!z)s.fillText(j,V,X),(U=this.dependencyTracker)==null||U.recordCharacterBBox(e,s,$?{bbox:null}:a,i/o,V,X,()=>$??s.measureText(j));else if(this.paintChar(e,j,V,X,A,T),z){const ee=V+i*z.offset.x/o,B=X-i*z.offset.y/o;this.paintChar(e,z.fontChar,ee,B,A,T)}}const Q=g?te*y-F*p:te*y+F*p;R+=Q,Z&&s.restore()}g?r.y-=R:r.x+=R*f,s.restore(),this.compose(),(H=this.dependencyTracker)==null||H.recordShowTextOperation(e)}showType3Text(e,n){const r=this.ctx,a=this.current,i=a.font,s=a.fontSize,o=a.fontDirection,l=i.vertical?1:-1,u=a.charSpacing,p=a.wordSpacing,f=a.textHScale*o,m=a.fontMatrix||q3,g=n.length,S=a.textRenderingMode===Ia.INVISIBLE;let E,y,v,A;if(S||s===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,r.save(),a.textMatrix&&r.transform(...a.textMatrix),r.translate(a.x,a.y+a.textRise),r.scale(f,o);const T=this.dependencyTracker;for(this.dependencyTracker=T?new IA(T,e):null,E=0;E<g;++E){if(y=n[E],typeof y=="number"){A=l*y*s/1e3,this.ctx.translate(A,0),a.x+=A*f;continue}const w=(y.isSpace?p:0)+u,O=i.charProcOperatorList[y.operatorListId];O?this.contentVisible&&(this.save(),r.scale(s,s),r.transform(...m),this.executeOperatorList(O),this.restore()):It(`Type3 character "${y.operatorListId}" is not available.`);const R=[y.width,0];Je.applyTransform(R,m),v=R[0]*s+w,r.translate(v,0),a.x+=v*f}r.restore(),T&&(this.dependencyTracker=T)}setCharWidth(e,n,r){}setCharWidthAndBounds(e,n,r,a,i,s,o){var u;const l=new Path2D;l.rect(a,i,s-a,o-i),this.ctx.clip(l),(u=this.dependencyTracker)==null||u.recordBBox(e,this.ctx,a,s,i,o).recordClipBox(e,this.ctx,a,s,i,o),this.endPath(e)}getColorN_Pattern(e,n){let r;if(n[0]==="TilingPattern"){const a=this.baseTransform||Nr(this.ctx),i={createCanvasGraphics:(s,o)=>new UF(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new IA(this.dependencyTracker,o,!0):null)};r=new dF(n,this.ctx,i,a)}else r=this._getPattern(e,n[1],n[2]);return r}setStrokeColorN(e,...n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("strokeColor",e),this.current.strokeColor=this.getColorN_Pattern(e,n),this.current.patternStroke=!0}setFillColorN(e,...n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("fillColor",e),this.current.fillColor=this.getColorN_Pattern(e,n),this.current.patternFill=!0}setStrokeRGBColor(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("strokeColor",e),this.ctx.strokeStyle=this.current.strokeColor=n,this.current.patternStroke=!1}setStrokeTransparent(e){var n;(n=this.dependencyTracker)==null||n.recordSimpleData("strokeColor",e),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,n){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("fillColor",e),this.ctx.fillStyle=this.current.fillColor=n,this.current.patternFill=!1}setFillTransparent(e){var n;(n=this.dependencyTracker)==null||n.recordSimpleData("fillColor",e),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,n,r=null){let a;return this.cachedPatterns.has(n)?a=this.cachedPatterns.get(n):(a=UUe(this.getObject(e,n)),this.cachedPatterns.set(n,a)),r&&(a.matrix=r),a}shadingFill(e,n){var s;if(!this.contentVisible)return;const r=this.ctx;this.save(e);const a=this._getPattern(e,n);r.fillStyle=a.getPattern(r,this,bl(r),Da.SHADING,e);const i=bl(r);if(i){const{width:o,height:l}=r.canvas,u=Xh.slice();Je.axialAlignedBoundingBox([0,0,o,l],i,u);const[p,f,m,g]=u;this.ctx.fillRect(p,f,m-p,g-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(s=this.dependencyTracker)==null||s.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,Us.transform).recordDependencies(e,Us.fill).recordOperation(e),this.compose(this.current.getClippedPathBoundingBox()),this.restore(e)}beginInlineImage(){Qn("Should not call beginInlineImage")}beginImageData(){Qn("Should not call beginImageData")}paintFormXObjectBegin(e,n,r){var a;if(this.contentVisible&&(this.save(e),this.baseTransformStack.push(this.baseTransform),n&&this.transform(e,...n),this.baseTransform=Nr(this.ctx),r)){Je.axialAlignedBoundingBox(r,this.baseTransform,this.current.minMax);const[i,s,o,l]=r,u=new Path2D;u.rect(i,s,o-i,l-s),this.ctx.clip(u),(a=this.dependencyTracker)==null||a.recordClipBox(e,this.ctx,i,o,s,l),this.endPath(e)}}paintFormXObjectEnd(e){this.contentVisible&&(this.restore(e),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e,n){var T;if(!this.contentVisible)return;this.save(e),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const r=this.ctx;n.isolated||SA("TODO: Support non-isolated groups."),n.knockout&&It("Knockout groups not supported.");const a=Nr(r);if(n.matrix&&r.transform(...n.matrix),!n.bbox)throw new Error("Bounding box is required.");let i=Xh.slice();Je.axialAlignedBoundingBox(n.bbox,Nr(r),i);const s=[0,0,r.canvas.width,r.canvas.height];i=Je.intersect(i,s)||[0,0,0,0];const o=Math.floor(i[0]),l=Math.floor(i[1]),u=Math.max(Math.ceil(i[2])-o,1),p=Math.max(Math.ceil(i[3])-l,1);this.current.startNewPathAndClipBox([0,0,u,p]);let f="groupAt"+this.groupLevel;n.smask&&(f+="_smask_"+this.smaskCounter++%2);const m=this.cachedCanvases.getCanvas(f,u,p),g=m.context;g.translate(-o,-l),g.transform(...a);let S=new Path2D;const[E,y,v,A]=n.bbox;if(S.rect(E,y,v-E,A-y),n.matrix){const w=new Path2D;w.addPath(S,new DOMMatrix(n.matrix)),S=w}g.clip(S),n.smask&&this.smaskStack.push({canvas:m.canvas,context:g,offsetX:o,offsetY:l,subtype:n.smask.subtype,backdrop:n.smask.backdrop,transferMap:n.smask.transferMap||null,startTransformInverse:null}),(!n.smask||this.dependencyTracker)&&(r.setTransform(1,0,0,1,0,0),r.translate(o,l),r.save()),H0(r,g),this.ctx=g,(T=this.dependencyTracker)==null||T.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(r),this.setGState(e,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(r),this.groupLevel++}endGroup(e,n){var i;if(!this.contentVisible)return;this.groupLevel--;const r=this.ctx,a=this.groupStack.pop();if(this.ctx=a,this.ctx.imageSmoothingEnabled=!1,(i=this.dependencyTracker)==null||i.popBaseTransform(),n.smask)this.tempSMask=this.smaskStack.pop(),this.restore(e),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const s=Nr(this.ctx);this.restore(e),this.ctx.save(),this.ctx.setTransform(...s);const o=Xh.slice();Je.axialAlignedBoundingBox([0,0,r.canvas.width,r.canvas.height],s,o),this.ctx.drawImage(r.canvas,0,0),this.ctx.restore(),this.compose(o)}}beginAnnotation(e,n,r,a,i,s){if(K(this,Fo,o6).call(this),kA(this.ctx),this.ctx.save(),this.save(e),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),r){const o=r[2]-r[0],l=r[3]-r[1];if(s&&this.annotationCanvasMap){a=a.slice(),a[4]-=r[0],a[5]-=r[1],r=r.slice(),r[0]=r[1]=0,r[2]=o,r[3]=l,Je.singularValueDecompose2dScale(Nr(this.ctx),is);const{viewportScale:u}=this,p=Math.ceil(o*this.outputScaleX*u),f=Math.ceil(l*this.outputScaleY*u);this.annotationCanvas=this.canvasFactory.create(p,f);const{canvas:m,context:g}=this.annotationCanvas;this.annotationCanvasMap.set(n,m),this.annotationCanvas.savedCtx=this.ctx,this.ctx=g,this.ctx.save(),this.ctx.setTransform(is[0],0,0,-is[1],0,l*is[1]),kA(this.ctx)}else{kA(this.ctx),this.endPath(e);const u=new Path2D;u.rect(r[0],r[1],o,l),this.ctx.clip(u)}}this.current=new eae(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(e,...a),this.transform(e,...i)}endAnnotation(e){this.annotationCanvas&&(this.ctx.restore(),K(this,Fo,l6).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e,n){var o;if(!this.contentVisible)return;const r=n.count;n=this.getObject(e,n.data,n),n.count=r;const a=this.ctx,i=this._createMaskCanvas(e,n),s=i.canvas;a.save(),a.setTransform(1,0,0,1,0,0),a.drawImage(s,i.offsetX,i.offsetY),(o=this.dependencyTracker)==null||o.resetBBox(e).recordBBox(e,this.ctx,i.offsetX,i.offsetX+s.width,i.offsetY,i.offsetY+s.height).recordOperation(e),a.restore(),this.compose()}paintImageMaskXObjectRepeat(e,n,r,a=0,i=0,s,o){var f,m,g;if(!this.contentVisible)return;n=this.getObject(e,n.data,n);const l=this.ctx;l.save();const u=Nr(l);l.transform(r,a,i,s,0,0);const p=this._createMaskCanvas(e,n);l.setTransform(1,0,0,1,p.offsetX-u[4],p.offsetY-u[5]),(f=this.dependencyTracker)==null||f.resetBBox(e);for(let S=0,E=o.length;S<E;S+=2){const y=Je.transform(u,[r,a,i,s,o[S],o[S+1]]);l.drawImage(p.canvas,y[4],y[5]),(m=this.dependencyTracker)==null||m.recordBBox(e,this.ctx,y[4],y[4]+p.canvas.width,y[5],y[5]+p.canvas.height)}l.restore(),this.compose(),(g=this.dependencyTracker)==null||g.recordOperation(e)}paintImageMaskXObjectGroup(e,n){var s,o,l;if(!this.contentVisible)return;const r=this.ctx,a=this.current.fillColor,i=this.current.patternFill;(s=this.dependencyTracker)==null||s.resetBBox(e).recordDependencies(e,Us.transformAndFill);for(const u of n){const{data:p,width:f,height:m,transform:g}=u,S=this.cachedCanvases.getCanvas("maskCanvas",f,m),E=S.context;E.save();const y=this.getObject(e,p,u);nae(E,y),E.globalCompositeOperation="source-in",E.fillStyle=i?a.getPattern(E,this,bl(r),Da.FILL,e):a,E.fillRect(0,0,f,m),E.restore(),r.save(),r.transform(...g),r.scale(1,-1),DA(r,S.canvas,0,0,f,m,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(e,r,0,f,0,m),r.restore()}this.compose(),(l=this.dependencyTracker)==null||l.recordOperation(e)}paintImageXObject(e,n){if(!this.contentVisible)return;const r=this.getObject(e,n);if(!r){It("Dependent image isn't ready yet");return}this.paintInlineImageXObject(e,r)}paintImageXObjectRepeat(e,n,r,a,i){if(!this.contentVisible)return;const s=this.getObject(e,n);if(!s){It("Dependent image isn't ready yet");return}const o=s.width,l=s.height,u=[];for(let p=0,f=i.length;p<f;p+=2)u.push({transform:[r,0,0,a,i[p],i[p+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(e,s,u)}applyTransferMapsToCanvas(e){return this.current.transferMaps!=="none"&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if(this.current.transferMaps==="none")return e.bitmap;const{bitmap:n,width:r,height:a}=e,i=this.cachedCanvases.getCanvas("inlineImage",r,a),s=i.context;return s.filter=this.current.transferMaps,s.drawImage(n,0,0),s.filter="none",i.canvas}paintInlineImageXObject(e,n){var u;if(!this.contentVisible)return;const r=n.width,a=n.height,i=this.ctx;this.save(e);const{filter:s}=i;s!=="none"&&s!==""&&(i.filter="none"),i.scale(1/r,-1/a);let o;if(n.bitmap)o=this.applyTransferMapsToBitmap(n);else if(typeof HTMLElement=="function"&&n instanceof HTMLElement||!n.data)o=n;else{const f=this.cachedCanvases.getCanvas("inlineImage",r,a).context;tae(f,n),o=this.applyTransferMapsToCanvas(f)}const l=this._scaleImage(o,bl(i));i.imageSmoothingEnabled=rae(Nr(i),n.interpolate),(u=this.dependencyTracker)==null||u.resetBBox(e).recordBBox(e,i,0,r,-a,0).recordDependencies(e,Us.imageXObject).recordOperation(e),DA(i,l.img,0,0,l.paintWidth,l.paintHeight,0,-a,r,a),this.compose(),this.restore(e)}paintInlineImageXObjectGroup(e,n,r){var s,o,l;if(!this.contentVisible)return;const a=this.ctx;let i;if(n.bitmap)i=n.bitmap;else{const u=n.width,p=n.height,m=this.cachedCanvases.getCanvas("inlineImage",u,p).context;tae(m,n),i=this.applyTransferMapsToCanvas(m)}(s=this.dependencyTracker)==null||s.resetBBox(e);for(const u of r)a.save(),a.transform(...u.transform),a.scale(1,-1),DA(a,i,u.x,u.y,u.w,u.h,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(e,a,0,1,-1,0),a.restore();(l=this.dependencyTracker)==null||l.recordOperation(e),this.compose()}paintSolidColorImageMask(e){var n;this.contentVisible&&((n=this.dependencyTracker)==null||n.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,Us.fill).recordOperation(e),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e,n){}markPointProps(e,n,r){}beginMarkedContent(e,n){var r;(r=this.dependencyTracker)==null||r.beginMarkedContent(e),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,n,r){var a;(a=this.dependencyTracker)==null||a.beginMarkedContent(e),n==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(r)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(e){var n;(n=this.dependencyTracker)==null||n.endMarkedContent(e),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(e){}endCompat(e){}consumePath(e,n,r){var s,o;const a=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(r);const i=this.ctx;this.pendingClip?(a||(this.pendingClip===aae?i.clip(n,"evenodd"):i.clip(n)),this.pendingClip=null,(s=this.dependencyTracker)==null||s.bboxToClipBoxDropOperation(e).recordFutureForcedDependency("clipPath",e)):(o=this.dependencyTracker)==null||o.recordOperation(e),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=Nr(this.ctx);if(e[1]===0&&e[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const n=Math.abs(e[0]*e[3]-e[2]*e[1]),r=Math.hypot(e[0],e[2]),a=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(r,a)/n}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:e}=this.current,{a:n,b:r,c:a,d:i}=this.ctx.getTransform();let s,o;if(r===0&&a===0){const l=Math.abs(n),u=Math.abs(i);if(l===u)if(e===0)s=o=1/l;else{const p=l*e;s=o=p<1?1/p:1}else if(e===0)s=1/l,o=1/u;else{const p=l*e,f=u*e;s=p<1?1/p:1,o=f<1?1/f:1}}else{const l=Math.abs(n*i-r*a),u=Math.hypot(n,r),p=Math.hypot(a,i);if(e===0)s=p/l,o=u/l;else{const f=e*l;s=p>f?p/f:1,o=u>f?u/f:1}}this._cachedScaleForStroking[0]=s,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(e,n){const{ctx:r,current:{lineWidth:a}}=this,[i,s]=this.getScaleForStroking();if(i===s){r.lineWidth=(a||1)*i,r.stroke(e);return}const o=r.getLineDash();n&&r.save(),r.scale(i,s),pF.a=1/i,pF.d=1/s;const l=new Path2D;if(l.addPath(e,pF),o.length>0){const u=Math.max(i,s);r.setLineDash(o.map(p=>p/u)),r.lineDashOffset/=u}r.lineWidth=a||1,r.stroke(l),n&&r.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};Fo=new WeakSet,o6=function(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)},l6=function(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(e!=="none"){const n=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=n}}},c6=function(e,n,r){const a=new Path2D;return a.addPath(e,new DOMMatrix(r).invertSelf().multiplySelf(n)),a};let Qh=UF;for(const t in Vh)Qh.prototype[t]!==void 0&&(Qh.prototype[Vh[t]]=Qh.prototype[t]);const Mg=class Mg{constructor(e){Y(this,kg);Y(this,Ig);Y(this,Dg);Y(this,IE);M(this,Ig,e),M(this,Dg,new DataView(_(this,Ig))),M(this,IE,new TextDecoder)}static write(e){const n=new TextEncoder,r={};let a=0;for(const u of Mg.strings){const p=n.encode(e[u]);r[u]=p,a+=4+p.length}const i=new ArrayBuffer(a),s=new Uint8Array(i),o=new DataView(i);let l=0;for(const u of Mg.strings){const p=r[u],f=p.length;o.setUint32(l,f),s.set(p,l+4),l+=4+f}return on(l===i.byteLength,"CssFontInfo.write: Buffer overflow"),i}get fontFamily(){return K(this,kg,OR).call(this,0)}get fontWeight(){return K(this,kg,OR).call(this,1)}get italicAngle(){return K(this,kg,OR).call(this,2)}};Ig=new WeakMap,Dg=new WeakMap,IE=new WeakMap,kg=new WeakSet,OR=function(e){on(e<Mg.strings.length,"Invalid string index");let n=0;for(let a=0;a<e;a++)n+=_(this,Dg).getUint32(n)+4;const r=_(this,Dg).getUint32(n);return _(this,IE).decode(new Uint8Array(_(this,Ig),n+4,r))},Pe(Mg,"strings",["fontFamily","fontWeight","italicAngle"]);let MA=Mg;const Lg=class Lg{constructor(e){Y(this,Gf);Y(this,xd);Y(this,Dl);Y(this,Uf);M(this,xd,e),M(this,Dl,new DataView(_(this,xd))),M(this,Uf,new TextDecoder)}static write(e){const n=new TextEncoder,r={};let a=0;for(const m of Lg.strings){const g=n.encode(e[m]);r[m]=g,a+=4+g.length}a+=4;let i,s,o=1+a;e.style&&(i=n.encode(e.style.style),s=n.encode(e.style.weight),o+=4+i.length+4+s.length);const l=new ArrayBuffer(o),u=new Uint8Array(l),p=new DataView(l);let f=0;p.setUint8(f++,e.guessFallback?1:0),p.setUint32(f,0),f+=4,a=0;for(const m of Lg.strings){const g=r[m],S=g.length;a+=4+S,p.setUint32(f,S),u.set(g,f+4),f+=4+S}return p.setUint32(f-a-4,a),e.style&&(p.setUint32(f,i.length),u.set(i,f+4),f+=4+i.length,p.setUint32(f,s.length),u.set(s,f+4),f+=4+s.length),on(f<=l.byteLength,"SubstitionInfo.write: Buffer overflow"),l.transferToFixedLength(f)}get guessFallback(){return _(this,Dl).getUint8(0)!==0}get css(){return K(this,Gf,Iy).call(this,0)}get loadedName(){return K(this,Gf,Iy).call(this,1)}get baseFontName(){return K(this,Gf,Iy).call(this,2)}get src(){return K(this,Gf,Iy).call(this,3)}get style(){let e=1;e+=4+_(this,Dl).getUint32(e);const n=_(this,Dl).getUint32(e),r=_(this,Uf).decode(new Uint8Array(_(this,xd),e+4,n));e+=4+n;const a=_(this,Dl).getUint32(e),i=_(this,Uf).decode(new Uint8Array(_(this,xd),e+4,a));return{style:r,weight:i}}};xd=new WeakMap,Dl=new WeakMap,Uf=new WeakMap,Gf=new WeakSet,Iy=function(e){on(e<Lg.strings.length,"Invalid string index");let n=5;for(let a=0;a<e;a++)n+=_(this,Dl).getUint32(n)+4;const r=_(this,Dl).getUint32(n);return _(this,Uf).decode(new Uint8Array(_(this,xd),n+4,r))},Pe(Lg,"strings",["css","loadedName","baseFontName","src"]);let LA=Lg;const Mt=class Mt{constructor({data:e,extra:n}){Y(this,Pr);Y(this,kl);Y(this,DE);Y(this,zn);M(this,kl,e),M(this,DE,new TextDecoder),M(this,zn,new DataView(_(this,kl))),n&&Object.assign(this,n)}get black(){return K(this,Pr,Zo).call(this,0)}get bold(){return K(this,Pr,Zo).call(this,1)}get disableFontFace(){return K(this,Pr,Zo).call(this,2)}get fontExtraProperties(){return K(this,Pr,Zo).call(this,3)}get isInvalidPDFjsFont(){return K(this,Pr,Zo).call(this,4)}get isType3Font(){return K(this,Pr,Zo).call(this,5)}get italic(){return K(this,Pr,Zo).call(this,6)}get missingFile(){return K(this,Pr,Zo).call(this,7)}get remeasure(){return K(this,Pr,Zo).call(this,8)}get vertical(){return K(this,Pr,Zo).call(this,9)}get ascent(){return K(this,Pr,IR).call(this,0)}get defaultWidth(){return K(this,Pr,IR).call(this,1)}get descent(){return K(this,Pr,IR).call(this,2)}get bbox(){let e=_(Mt,Fg);if(_(this,zn).getUint8(e)===0)return;e+=1;const r=[];for(let a=0;a<4;a++)r.push(_(this,zn).getInt16(e,!0)),e+=2;return r}get fontMatrix(){let e=_(Mt,Bg);if(_(this,zn).getUint8(e)===0)return;e+=1;const r=[];for(let a=0;a<6;a++)r.push(_(this,zn).getFloat64(e,!0)),e+=8;return r}get defaultVMetrics(){let e=_(Mt,Ug);if(_(this,zn).getUint8(e)===0)return;e+=1;const r=[];for(let a=0;a<3;a++)r.push(_(this,zn).getInt16(e,!0)),e+=2;return r}get fallbackName(){return K(this,Pr,Dy).call(this,0)}get loadedName(){return K(this,Pr,Dy).call(this,1)}get mimetype(){return K(this,Pr,Dy).call(this,2)}get name(){return K(this,Pr,Dy).call(this,3)}get data(){let e=_(Mt,cs);const n=_(this,zn).getUint32(e);e+=4+n;const r=_(this,zn).getUint32(e);e+=4+r;const a=_(this,zn).getUint32(e);e+=4+a;const i=_(this,zn).getUint32(e);if(i!==0)return new Uint8Array(_(this,kl),e+4,i)}clearData(){let e=_(Mt,cs);const n=_(this,zn).getUint32(e);e+=4+n;const r=_(this,zn).getUint32(e);e+=4+r;const a=_(this,zn).getUint32(e);e+=4+a;const i=_(this,zn).getUint32(e);new Uint8Array(_(this,kl),e+4,i).fill(0),_(this,zn).setUint32(e,0)}get cssFontInfo(){let e=_(Mt,cs);const n=_(this,zn).getUint32(e);e+=4+n;const r=_(this,zn).getUint32(e);e+=4+r;const a=_(this,zn).getUint32(e);if(a===0)return null;const i=new Uint8Array(a);return i.set(new Uint8Array(_(this,kl),e+4,a)),new MA(i.buffer)}get systemFontInfo(){let e=_(Mt,cs);const n=_(this,zn).getUint32(e);e+=4+n;const r=_(this,zn).getUint32(e);if(r===0)return null;const a=new Uint8Array(r);return a.set(new Uint8Array(_(this,kl),e+4,r)),new LA(a.buffer)}static write(e){const n=e.systemFontInfo?LA.write(e.systemFontInfo):null,r=e.cssFontInfo?MA.write(e.cssFontInfo):null,a=new TextEncoder,i={};let s=0;for(const E of Mt.strings)i[E]=a.encode(e[E]),s+=4+i[E].length;const o=_(Mt,cs)+4+s+4+(n?n.byteLength:0)+4+(r?r.byteLength:0)+4+(e.data?e.data.length:0),l=new ArrayBuffer(o),u=new Uint8Array(l),p=new DataView(l);let f=0;const m=Mt.bools.length;let g=0,S=0;for(let E=0;E<m;E++){const y=e[Mt.bools[E]];g|=(y===void 0?0:y?2:1)<<S,S+=2,(S===8||E===m-1)&&(p.setUint8(f++,g),g=0,S=0)}on(f===_(Mt,Pg),"FontInfo.write: Boolean properties offset mismatch");for(const E of Mt.numbers)p.setFloat64(f,e[E]),f+=8;if(on(f===_(Mt,Fg),"FontInfo.write: Number properties offset mismatch"),e.bbox){p.setUint8(f++,4);for(const E of e.bbox)p.setInt16(f,E,!0),f+=2}else p.setUint8(f++,0),f+=8;if(on(f===_(Mt,Bg),"FontInfo.write: BBox properties offset mismatch"),e.fontMatrix){p.setUint8(f++,6);for(const E of e.fontMatrix)p.setFloat64(f,E,!0),f+=8}else p.setUint8(f++,0),f+=48;if(on(f===_(Mt,Ug),"FontInfo.write: FontMatrix properties offset mismatch"),e.defaultVMetrics){p.setUint8(f++,1);for(const E of e.defaultVMetrics)p.setInt16(f,E,!0),f+=2}else p.setUint8(f++,0),f+=6;on(f===_(Mt,cs),"FontInfo.write: DefaultVMetrics properties offset mismatch"),p.setUint32(_(Mt,cs),0),f+=4;for(const E of Mt.strings){const y=i[E],v=y.length;p.setUint32(f,v),u.set(y,f+4),f+=4+v}if(p.setUint32(_(Mt,cs),f-_(Mt,cs)-4),!n)p.setUint32(f,0),f+=4;else{const E=n.byteLength;p.setUint32(f,E),on(f+4+E<=l.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),u.set(new Uint8Array(n),f+4),f+=4+E}if(!r)p.setUint32(f,0),f+=4;else{const E=r.byteLength;p.setUint32(f,E),on(f+4+E<=l.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),u.set(new Uint8Array(r),f+4),f+=4+E}return e.data===void 0?(p.setUint32(f,0),f+=4):(p.setUint32(f,e.data.length),u.set(e.data,f+4),f+=4+e.data.length),on(f<=l.byteLength,"FontInfo.write: Buffer overflow"),l.transferToFixedLength(f)}};Pg=new WeakMap,Fg=new WeakMap,Bg=new WeakMap,Ug=new WeakMap,cs=new WeakMap,kl=new WeakMap,DE=new WeakMap,zn=new WeakMap,Pr=new WeakSet,Zo=function(e){on(e<Mt.bools.length,"Invalid boolean index");const n=Math.floor(e/4),r=e*2%8,a=_(this,zn).getUint8(n)>>r&3;return a===0?void 0:a===2},IR=function(e){return on(e<Mt.numbers.length,"Invalid number index"),_(this,zn).getFloat64(_(Mt,Pg)+e*8)},Dy=function(e){on(e<Mt.strings.length,"Invalid string index");let n=_(Mt,cs)+4;for(let i=0;i<e;i++)n+=_(this,zn).getUint32(n)+4;const r=_(this,zn).getUint32(n),a=new Uint8Array(r);return a.set(new Uint8Array(_(this,kl),n+4,r)),_(this,DE).decode(a)},Pe(Mt,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),Pe(Mt,"numbers",["ascent","defaultWidth","descent"]),Pe(Mt,"strings",["fallbackName","loadedName","mimetype","name"]),Y(Mt,Pg,Math.ceil(Mt.bools.length*2/8)),Y(Mt,Fg,_(Mt,Pg)+Mt.numbers.length*8),Y(Mt,Bg,_(Mt,Fg)+1+8),Y(Mt,Ug,_(Mt,Bg)+1+48),Y(Mt,cs,_(Mt,Ug)+1+6);let fF=Mt;class Gs{static get workerPort(){return _(this,kE)}static set workerPort(e){if(!(typeof Worker<"u"&&e instanceof Worker)&&e!==null)throw new Error("Invalid `workerPort` type.");M(this,kE,e)}static get workerSrc(){return _(this,ME)}static set workerSrc(e){if(typeof e!="string")throw new Error("Invalid `workerSrc` type.");M(this,ME,e)}}kE=new WeakMap,ME=new WeakMap,Y(Gs,kE,null),Y(Gs,ME,"");class WUe{constructor({parsedData:e,rawData:n}){Y(this,Gg);Y(this,LE);M(this,Gg,e),M(this,LE,n)}getRaw(){return _(this,LE)}get(e){return _(this,Gg).get(e)??null}[Symbol.iterator](){return _(this,Gg).entries()}}Gg=new WeakMap,LE=new WeakMap;const Zh=Symbol("INTERNAL");class jUe{constructor(e,{name:n,intent:r,usage:a,rbGroups:i}){Y(this,PE,!1);Y(this,FE,!1);Y(this,BE,!1);Y(this,zg,!0);M(this,PE,!!(e&rs.DISPLAY)),M(this,FE,!!(e&rs.PRINT)),this.name=n,this.intent=r,this.usage=a,this.rbGroups=i}get visible(){if(_(this,BE))return _(this,zg);if(!_(this,zg))return!1;const{print:e,view:n}=this.usage;return _(this,PE)?(n==null?void 0:n.viewState)!=="OFF":_(this,FE)?(e==null?void 0:e.printState)!=="OFF":!0}_setVisible(e,n,r=!1){e!==Zh&&Qn("Internal method `_setVisible` called."),M(this,BE,r),M(this,zg,n)}}PE=new WeakMap,FE=new WeakMap,BE=new WeakMap,zg=new WeakMap;class KUe{constructor(e,n=rs.DISPLAY){Y(this,UE);Y(this,Od,null);Y(this,qn,new Map);Y(this,qg,null);Y(this,Hg,null);if(this.renderingIntent=n,this.name=null,this.creator=null,e!==null){this.name=e.name,this.creator=e.creator,M(this,Hg,e.order);for(const r of e.groups)_(this,qn).set(r.id,new jUe(n,r));if(e.baseState==="OFF")for(const r of _(this,qn).values())r._setVisible(Zh,!1);for(const r of e.on)_(this,qn).get(r)._setVisible(Zh,!0);for(const r of e.off)_(this,qn).get(r)._setVisible(Zh,!1);M(this,qg,this.getHash())}}isVisible(e){if(_(this,qn).size===0)return!0;if(!e)return SA("Optional content group not defined."),!0;if(e.type==="OCG")return _(this,qn).has(e.id)?_(this,qn).get(e.id).visible:(It(`Optional content group not found: ${e.id}`),!0);if(e.type==="OCMD"){if(e.expression)return K(this,UE,u6).call(this,e.expression);if(!e.policy||e.policy==="AnyOn"){for(const n of e.ids){if(!_(this,qn).has(n))return It(`Optional content group not found: ${n}`),!0;if(_(this,qn).get(n).visible)return!0}return!1}else if(e.policy==="AllOn"){for(const n of e.ids){if(!_(this,qn).has(n))return It(`Optional content group not found: ${n}`),!0;if(!_(this,qn).get(n).visible)return!1}return!0}else if(e.policy==="AnyOff"){for(const n of e.ids){if(!_(this,qn).has(n))return It(`Optional content group not found: ${n}`),!0;if(!_(this,qn).get(n).visible)return!0}return!1}else if(e.policy==="AllOff"){for(const n of e.ids){if(!_(this,qn).has(n))return It(`Optional content group not found: ${n}`),!0;if(_(this,qn).get(n).visible)return!1}return!0}return It(`Unknown optional content policy ${e.policy}.`),!0}return It(`Unknown group type ${e.type}.`),!0}setVisibility(e,n=!0,r=!0){var i;const a=_(this,qn).get(e);if(!a){It(`Optional content group not found: ${e}`);return}if(r&&n&&a.rbGroups.length)for(const s of a.rbGroups)for(const o of s)o!==e&&((i=_(this,qn).get(o))==null||i._setVisible(Zh,!1,!0));a._setVisible(Zh,!!n,!0),M(this,Od,null)}setOCGState({state:e,preserveRB:n}){let r;for(const a of e){switch(a){case"ON":case"OFF":case"Toggle":r=a;continue}const i=_(this,qn).get(a);if(i)switch(r){case"ON":this.setVisibility(a,!0,n);break;case"OFF":this.setVisibility(a,!1,n);break;case"Toggle":this.setVisibility(a,!i.visible,n);break}}M(this,Od,null)}get hasInitialVisibility(){return _(this,qg)===null||this.getHash()===_(this,qg)}getOrder(){return _(this,qn).size?_(this,Hg)?_(this,Hg).slice():[..._(this,qn).keys()]:null}getGroup(e){return _(this,qn).get(e)||null}getHash(){if(_(this,Od)!==null)return _(this,Od);const e=new Pre;for(const[n,r]of _(this,qn))e.update(`${n}:${r.visible}`);return M(this,Od,e.hexdigest())}[Symbol.iterator](){return _(this,qn).entries()}}Od=new WeakMap,qn=new WeakMap,qg=new WeakMap,Hg=new WeakMap,UE=new WeakSet,u6=function(e){const n=e.length;if(n<2)return!0;const r=e[0];for(let a=1;a<n;a++){const i=e[a];let s;if(Array.isArray(i))s=K(this,UE,u6).call(this,i);else if(_(this,qn).has(i))s=_(this,qn).get(i).visible;else return It(`Optional content group not found: ${i}`),!0;switch(r){case"And":if(!s)return!1;break;case"Or":if(s)return!0;break;case"Not":return!s;default:return!0}}return r==="And"};class XUe{constructor(e,{disableRange:n=!1,disableStream:r=!1}){on(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:a,initialData:i,progressiveDone:s,contentDispositionFilename:o}=e;if(this._queuedChunks=[],this._progressiveDone=s,this._contentDispositionFilename=o,(i==null?void 0:i.length)>0){const l=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!r,this._isRangeSupported=!n,this._contentLength=a,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener((l,u)=>{this._onReceiveData({begin:l,chunk:u})}),e.addProgressListener((l,u)=>{this._onProgress({loaded:l,total:u})}),e.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),e.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),e.transportReady()}_onReceiveData({begin:e,chunk:n}){const r=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;if(e===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(r):this._queuedChunks.push(r);else{const a=this._rangeReaders.some(function(i){return i._begin!==e?!1:(i._enqueue(r),!0)});on(a,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}_onProgress(e){var n,r,a,i;e.total===void 0?(r=(n=this._rangeReaders[0])==null?void 0:n.onProgress)==null||r.call(n,{loaded:e.loaded}):(i=(a=this._fullRequestReader)==null?void 0:a.onProgress)==null||i.call(a,{loaded:e.loaded,total:e.total})}_onProgressiveDone(){var e;(e=this._fullRequestReader)==null||e.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const n=this._rangeReaders.indexOf(e);n>=0&&this._rangeReaders.splice(n,1)}getFullReader(){on(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new QUe(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const r=new ZUe(this,e,n);return this._pdfDataRangeTransport.requestDataRange(e,n),this._rangeReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeReaders.slice(0))r.cancel(e);this._pdfDataRangeTransport.abort()}}class QUe{constructor(e,n,r=!1,a=null){this._stream=e,this._done=r||!1,this._filename=TA(a)?a:null,this._queuedChunks=n||[],this._loaded=0;for(const i of this._queuedChunks)this._loaded+=i.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class ZUe{constructor(e,n,r){this._stream=e,this._begin=n,this._end=r,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length===0)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const n=this._queuedChunk;return this._queuedChunk=null,{value:n,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function JUe(t){let e=!0,n=r("filename\\*","i").exec(t);if(n){n=n[1];let p=o(n);return p=unescape(p),p=l(p),p=u(p),i(p)}if(n=s(t),n){const p=u(n);return i(p)}if(n=r("filename","i").exec(t),n){n=n[1];let p=o(n);return p=u(p),i(p)}function r(p,f){return new RegExp("(?:^|;)\\s*"+p+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',f)}function a(p,f){if(p){if(!/^[\x00-\xFF]+$/.test(f))return f;try{const m=new TextDecoder(p,{fatal:!0}),g=M0(f);f=m.decode(g),e=!1}catch{}}return f}function i(p){return e&&/[\x80-\xff]/.test(p)&&(p=a("utf-8",p),e&&(p=a("iso-8859-1",p))),p}function s(p){const f=[];let m;const g=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(m=g.exec(p))!==null;){let[,E,y,v]=m;if(E=parseInt(E,10),E in f){if(E===0)break;continue}f[E]=[y,v]}const S=[];for(let E=0;E<f.length&&E in f;++E){let[y,v]=f[E];v=o(v),y&&(v=unescape(v),E===0&&(v=l(v))),S.push(v)}return S.join("")}function o(p){if(p.startsWith('"')){const f=p.slice(1).split('\\"');for(let m=0;m<f.length;++m){const g=f[m].indexOf('"');g!==-1&&(f[m]=f[m].slice(0,g),f.length=m+1),f[m]=f[m].replaceAll(/\\(.)/g,"$1")}p=f.join('"')}return p}function l(p){const f=p.indexOf("'");if(f===-1)return p;const m=p.slice(0,f),S=p.slice(f+1).replace(/^[^']*'/,"");return a(m,S)}function u(p){return!p.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(p)?p:p.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(f,m,g,S){if(g==="q"||g==="Q")return S=S.replaceAll("_"," "),S=S.replaceAll(/=([0-9a-fA-F]{2})/g,function(E,y){return String.fromCharCode(parseInt(y,16))}),a(m,S);try{S=atob(S)}catch{}return a(m,S)})}return""}function iae(t,e){const n=new Headers;if(!t||!e||typeof e!="object")return n;for(const r in e){const a=e[r];a!==void 0&&n.append(r,a)}return n}function PA(t){var e;return((e=URL.parse(t))==null?void 0:e.origin)??null}function sae({responseHeaders:t,isHttp:e,rangeChunkSize:n,disableRange:r}){const a={allowRangeRequests:!1,suggestedLength:void 0},i=parseInt(t.get("Content-Length"),10);return!Number.isInteger(i)||(a.suggestedLength=i,i<=2*n)||r||!e||t.get("Accept-Ranges")!=="bytes"||(t.get("Content-Encoding")||"identity")!=="identity"||(a.allowRangeRequests=!0),a}function oae(t){const e=t.get("Content-Disposition");if(e){let n=JUe(e);if(n.includes("%"))try{n=decodeURIComponent(n)}catch{}if(TA(n))return n}return null}function $0(t,e){return new k0(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,t===404||t===0&&e.startsWith("file:"))}function lae(t){return t===200||t===206}function cae(t,e,n){return{method:"GET",headers:t,signal:n.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function uae(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(It(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class e7e{constructor(e){Pe(this,"_responseOrigin",null);this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=iae(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return on(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new t7e(this),this._fullRequestReader}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const r=new n7e(this,e,n);return this._rangeRequestReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeRequestReaders.slice(0))r.cancel(e)}}class t7e{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;const n=e.source;this._withCredentials=n.withCredentials||!1,this._contentLength=n.length,this._headersCapability=Promise.withResolvers(),this._disableRange=n.disableRange||!1,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!n.disableStream,this._isRangeSupported=!n.disableRange;const r=new Headers(e.headers),a=n.url;fetch(a,cae(r,this._withCredentials,this._abortController)).then(i=>{if(e._responseOrigin=PA(i.url),!lae(i.status))throw $0(i.status,a);this._reader=i.body.getReader(),this._headersCapability.resolve();const s=i.headers,{allowRangeRequests:o,suggestedLength:l}=sae({responseHeaders:s,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=oae(s),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new yc("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;await this._headersCapability.promise;const{value:e,done:n}=await this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded,total:this._contentLength}),{value:uae(e),done:!1})}cancel(e){var n;(n=this._reader)==null||n.cancel(e),this._abortController.abort()}}class n7e{constructor(e,n,r){this._stream=e,this._reader=null,this._loaded=0;const a=e.source;this._withCredentials=a.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!a.disableStream,this._abortController=new AbortController;const i=new Headers(e.headers);i.append("Range",`bytes=${n}-${r-1}`);const s=a.url;fetch(s,cae(i,this._withCredentials,this._abortController)).then(o=>{const l=PA(o.url);if(l!==e._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${e._responseOrigin}".`);if(!lae(o.status))throw $0(o.status,s);this._readCapability.resolve(),this._reader=o.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;await this._readCapability.promise;const{value:e,done:n}=await this._reader.read();return n?{value:e,done:n}:(this._loaded+=e.byteLength,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded}),{value:uae(e),done:!1})}cancel(e){var n;(n=this._reader)==null||n.cancel(e),this._abortController.abort()}}const mF=200,hF=206;function r7e(t){const e=t.response;return typeof e!="string"?e:M0(e).buffer}class a7e{constructor({url:e,httpHeaders:n,withCredentials:r}){Pe(this,"_responseOrigin",null);this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=iae(this.isHttp,n),this.withCredentials=r||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){const n=new XMLHttpRequest,r=this.currXhrId++,a=this.pendingRequests[r]={xhr:n};n.open("GET",this.url),n.withCredentials=this.withCredentials;for(const[i,s]of this.headers)n.setRequestHeader(i,s);return this.isHttp&&"begin"in e&&"end"in e?(n.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),a.expectedStatus=hF):a.expectedStatus=mF,n.responseType="arraybuffer",on(e.onError,"Expected `onError` callback to be provided."),n.onerror=()=>{e.onError(n.status)},n.onreadystatechange=this.onStateChange.bind(this,r),n.onprogress=this.onProgress.bind(this,r),a.onHeadersReceived=e.onHeadersReceived,a.onDone=e.onDone,a.onError=e.onError,a.onProgress=e.onProgress,n.send(null),r}onProgress(e,n){var a;const r=this.pendingRequests[e];r&&((a=r.onProgress)==null||a.call(r,n))}onStateChange(e,n){const r=this.pendingRequests[e];if(!r)return;const a=r.xhr;if(a.readyState>=2&&r.onHeadersReceived&&(r.onHeadersReceived(),delete r.onHeadersReceived),a.readyState!==4||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],a.status===0&&this.isHttp){r.onError(a.status);return}const i=a.status||mF;if(!(i===mF&&r.expectedStatus===hF)&&i!==r.expectedStatus){r.onError(a.status);return}const o=r7e(a);if(i===hF){const l=a.getResponseHeader("Content-Range"),u=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);u?r.onDone({begin:parseInt(u[1],10),chunk:o}):(It('Missing or invalid "Content-Range" header.'),r.onError(0))}else o?r.onDone({begin:0,chunk:o}):r.onError(a.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const n=this.pendingRequests[e].xhr;delete this.pendingRequests[e],n.abort()}}class i7e{constructor(e){this._source=e,this._manager=new a7e(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const n=this._rangeRequestReaders.indexOf(e);n>=0&&this._rangeRequestReaders.splice(n,1)}getFullReader(){return on(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new s7e(this._manager,this._source),this._fullRequestReader}getRangeReader(e,n){const r=new o7e(this._manager,e,n);return r.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeRequestReaders.slice(0))r.cancel(e)}}class s7e{constructor(e,n){this._manager=e,this._url=n.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=n.disableRange||!1,this._contentLength=n.length,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,n=this._manager.getRequestXhr(e);this._manager._responseOrigin=PA(n.responseURL);const r=n.getAllResponseHeaders(),a=new Headers(r?r.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(o=>{const[l,...u]=o.split(": ");return[l,u.join(": ")]}):[]),{allowRangeRequests:i,suggestedLength:s}=sae({responseHeaders:a,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=s||this._contentLength,this._filename=oae(a),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=$0(e,this._url),this._headersCapability.reject(this._storedError);for(const n of this._requests)n.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){var n;(n=this.onProgress)==null||n.call(this,{loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class o7e{constructor(e,n,r){this._manager=e,this._url=e.url,this._requestId=e.request({begin:n,end:r,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var n;const e=PA((n=this._manager.getRequestXhr(this._requestId))==null?void 0:n.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var e;(e=this.onClosed)==null||e.call(this,this)}_onDone(e){const n=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:n,done:!1}):this._queuedChunk=n,this._done=!0;for(const r of this._requests)r.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??(this._storedError=$0(e,this._url));for(const n of this._requests)n.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){var n;this.isStreamingSupported||(n=this.onProgress)==null||n.call(this,{loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const n=this._queuedChunk;return this._queuedChunk=null,{value:n,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const n of this._requests)n.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const l7e=/^[a-z][a-z0-9\-+.]+:/i;function c7e(t){if(l7e.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}class u7e{constructor(e){this.source=e,this.url=c7e(e.url),on(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var e;return((e=this._fullRequestReader)==null?void 0:e._loaded)??0}getFullReader(){return on(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new d7e(this),this._fullRequestReader}getRangeReader(e,n){if(n<=this._progressiveDataLength)return null;const r=new p7e(this,e,n);return this._rangeRequestReaders.push(r),r}cancelAllRequests(e){var n;(n=this._fullRequestReader)==null||n.cancel(e);for(const r of this._rangeRequestReaders.slice(0))r.cancel(e)}}class d7e{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const n=e.source;this._contentLength=n.length,this._loaded=0,this._filename=null,this._disableRange=n.disableRange||!1,this._rangeChunkSize=n.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!n.disableStream,this._isRangeSupported=!n.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const r=process.getBuiltinModule("fs");r.promises.lstat(this._url).then(a=>{this._contentLength=a.size,this._setReadableStream(r.createReadStream(this._url)),this._headersCapability.resolve()},a=>{a.code==="ENOENT"&&(a=$0(0,this._url.href)),this._storedError=a,this._headersCapability.reject(a)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",n=>{this._error(n)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new yc("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class p7e{constructor(e,n,r){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const a=e.source;this._isStreamingSupported=!a.disableStream;const i=process.getBuiltinModule("fs");this._setReadableStream(i.createReadStream(this._url,{start:n,end:r-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var r;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return e===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,(r=this.onProgress)==null||r.call(this,{loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",n=>{this._error(n)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Y0=Symbol("INITIAL_DATA");class dae{constructor(){Y(this,GE);Y(this,us,Object.create(null))}get(e,n=null){if(n){const a=K(this,GE,d6).call(this,e);return a.promise.then(()=>n(a.data)),null}const r=_(this,us)[e];if(!r||r.data===Y0)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return r.data}has(e){const n=_(this,us)[e];return!!n&&n.data!==Y0}delete(e){const n=_(this,us)[e];return!n||n.data===Y0?!1:(delete _(this,us)[e],!0)}resolve(e,n=null){const r=K(this,GE,d6).call(this,e);r.data=n,r.resolve()}clear(){var e;for(const n in _(this,us)){const{data:r}=_(this,us)[n];(e=r==null?void 0:r.bitmap)==null||e.close()}M(this,us,Object.create(null))}*[Symbol.iterator](){for(const e in _(this,us)){const{data:n}=_(this,us)[e];n!==Y0&&(yield[e,n])}}}us=new WeakMap,GE=new WeakSet,d6=function(e){var n;return(n=_(this,us))[e]||(n[e]={...Promise.withResolvers(),data:Y0})};const f7e=1e5,pae=30;let V0=(Fr=class{constructor({textContentSource:e,container:n,viewport:r}){Y(this,Yc);Y(this,Id,Promise.withResolvers());Y(this,Li,null);Y(this,zE,!1);Y(this,qE,!!(($ae=globalThis.FontInspector)!=null&&$ae.enabled));Y(this,zf,null);Y(this,$c,null);Y(this,HE,0);Y(this,$E,0);Y(this,qf,null);Y(this,$g,null);Y(this,Yg,0);Y(this,Dd,0);Y(this,Vg,Object.create(null));Y(this,YE,[]);Y(this,Wg,null);Y(this,Hf,[]);Y(this,VE,new WeakMap);Y(this,WE,null);var l;if(e instanceof ReadableStream)M(this,Wg,e);else if(typeof e=="object")M(this,Wg,new ReadableStream({start(u){u.enqueue(e),u.close()}}));else throw new Error('No "textContentSource" parameter specified.');M(this,Li,M(this,$g,n)),M(this,Dd,r.scale*Oo.pixelRatio),M(this,Yg,r.rotation),M(this,$c,{div:null,properties:null,ctx:null});const{pageWidth:a,pageHeight:i,pageX:s,pageY:o}=r.rawDims;M(this,WE,[1,0,0,-1,-s,o+i]),M(this,$E,a),M(this,HE,i),K(l=Fr,ds,ice).call(l),od(n,r),_(this,Id).promise.finally(()=>{_(Fr,Kg).delete(this),M(this,$c,null),M(this,Vg,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:n}=Ea.platform;return qt(this,"fontFamilyMap",new Map([["sans-serif",`${e&&n?"Calibri, ":""}sans-serif`],["monospace",`${e&&n?"Lucida Console, ":""}monospace`]]))}render(){const e=()=>{_(this,qf).read().then(({value:n,done:r})=>{if(r){_(this,Id).resolve();return}_(this,zf)??M(this,zf,n.lang),Object.assign(_(this,Vg),n.styles),K(this,Yc,rce).call(this,n.items),e()},_(this,Id).reject)};return M(this,qf,_(this,Wg).getReader()),_(Fr,Kg).add(this),e(),_(this,Id).promise}update({viewport:e,onBefore:n=null}){var i;const r=e.scale*Oo.pixelRatio,a=e.rotation;if(a!==_(this,Yg)&&(n==null||n(),M(this,Yg,a),od(_(this,$g),{rotation:a})),r!==_(this,Dd)){n==null||n(),M(this,Dd,r);const s={div:null,properties:null,ctx:K(i=Fr,ds,DR).call(i,_(this,zf))};for(const o of _(this,Hf))s.properties=_(this,VE).get(o),s.div=o,K(this,Yc,p6).call(this,s)}}cancel(){var n;const e=new yc("TextLayer task cancelled.");(n=_(this,qf))==null||n.cancel(e).catch(()=>{}),M(this,qf,null),_(this,Id).reject(e)}get textDivs(){return _(this,Hf)}get textContentItemsStr(){return _(this,YE)}static cleanup(){if(!(_(this,Kg).size>0)){_(this,jg).clear();for(const{canvas:e}of _(this,$f).values())e.remove();_(this,$f).clear()}}},Id=new WeakMap,Li=new WeakMap,zE=new WeakMap,qE=new WeakMap,zf=new WeakMap,$c=new WeakMap,HE=new WeakMap,$E=new WeakMap,qf=new WeakMap,$g=new WeakMap,Yg=new WeakMap,Dd=new WeakMap,Vg=new WeakMap,YE=new WeakMap,Wg=new WeakMap,Hf=new WeakMap,VE=new WeakMap,WE=new WeakMap,jg=new WeakMap,$f=new WeakMap,jE=new WeakMap,kd=new WeakMap,Kg=new WeakMap,Yc=new WeakSet,rce=function(e){var a,i;if(_(this,zE))return;(i=_(this,$c)).ctx??(i.ctx=K(a=Fr,ds,DR).call(a,_(this,zf)));const n=_(this,Hf),r=_(this,YE);for(const s of e){if(n.length>f7e){It("Ignoring additional textDivs for performance reasons."),M(this,zE,!0);return}if(s.str===void 0){if(s.type==="beginMarkedContentProps"||s.type==="beginMarkedContent"){const o=_(this,Li);M(this,Li,document.createElement("span")),_(this,Li).classList.add("markedContent"),s.id&&_(this,Li).setAttribute("id",`${s.id}`),o.append(_(this,Li))}else s.type==="endMarkedContent"&&M(this,Li,_(this,Li).parentNode);continue}r.push(s.str),K(this,Yc,ace).call(this,s)}},ace=function(e){var E;const n=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:e.str!=="",hasEOL:e.hasEOL,fontSize:0};_(this,Hf).push(n);const a=Je.transform(_(this,WE),e.transform);let i=Math.atan2(a[1],a[0]);const s=_(this,Vg)[e.fontName];s.vertical&&(i+=Math.PI/2);let o=_(this,qE)&&s.fontSubstitution||s.fontFamily;o=Fr.fontFamilyMap.get(o)||o;const l=Math.hypot(a[2],a[3]),u=l*K(E=Fr,ds,sce).call(E,o,s,_(this,zf));let p,f;i===0?(p=a[4],f=a[5]-u):(p=a[4]+u*Math.sin(i),f=a[5]-u*Math.cos(i));const m="calc(var(--total-scale-factor) *",g=n.style;_(this,Li)===_(this,$g)?(g.left=`${(100*p/_(this,$E)).toFixed(2)}%`,g.top=`${(100*f/_(this,HE)).toFixed(2)}%`):(g.left=`${m}${p.toFixed(2)}px)`,g.top=`${m}${f.toFixed(2)}px)`),g.fontSize=`${m}${(_(Fr,kd)*l).toFixed(2)}px)`,g.fontFamily=o,r.fontSize=l,n.setAttribute("role","presentation"),n.textContent=e.str,n.dir=e.dir,_(this,qE)&&(n.dataset.fontName=s.fontSubstitutionLoadedName||e.fontName),i!==0&&(r.angle=i*(180/Math.PI));let S=!1;if(e.str.length>1)S=!0;else if(e.str!==" "&&e.transform[0]!==e.transform[3]){const y=Math.abs(e.transform[0]),v=Math.abs(e.transform[3]);y!==v&&Math.max(y,v)/Math.min(y,v)>1.5&&(S=!0)}if(S&&(r.canvasWidth=s.vertical?e.height:e.width),_(this,VE).set(n,r),_(this,$c).div=n,_(this,$c).properties=r,K(this,Yc,p6).call(this,_(this,$c)),r.hasText&&_(this,Li).append(n),r.hasEOL){const y=document.createElement("br");y.setAttribute("role","presentation"),_(this,Li).append(y)}},p6=function(e){var o;const{div:n,properties:r,ctx:a}=e,{style:i}=n;let s="";if(_(Fr,kd)>1&&(s=`scale(${1/_(Fr,kd)})`),r.canvasWidth!==0&&r.hasText){const{fontFamily:l}=i,{canvasWidth:u,fontSize:p}=r;K(o=Fr,ds,f6).call(o,a,p*_(this,Dd),l);const{width:f}=a.measureText(n.textContent);f>0&&(s=`scaleX(${u*_(this,Dd)/f}) ${s}`)}r.angle!==0&&(s=`rotate(${r.angle}deg) ${s}`),s.length>0&&(i.transform=s)},ds=new WeakSet,DR=function(e=null){let n=_(this,$f).get(e||(e=""));if(!n){const r=document.createElement("canvas");r.className="hiddenCanvasElement",r.lang=e,document.body.append(r),n=r.getContext("2d",{alpha:!1,willReadFrequently:!0}),_(this,$f).set(e,n),_(this,jE).set(n,{size:0,family:""})}return n},f6=function(e,n,r){const a=_(this,jE).get(e);n===a.size&&r===a.family||(e.font=`${n}px ${r}`,a.size=n,a.family=r)},ice=function(){if(_(this,kd)!==null)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),M(this,kd,e.getBoundingClientRect().height),e.remove()},sce=function(e,n,r){const a=_(this,jg).get(e);if(a)return a;const i=K(this,ds,DR).call(this,r);i.canvas.width=i.canvas.height=pae,K(this,ds,f6).call(this,i,pae,e);const s=i.measureText(""),o=s.fontBoundingBoxAscent,l=Math.abs(s.fontBoundingBoxDescent);i.canvas.width=i.canvas.height=0;let u=.8;return o?u=o/(o+l):(Ea.platform.isFirefox&&It("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),n.ascent?u=n.ascent:n.descent&&(u=1+n.descent)),_(this,jg).set(e,u),u},Y(Fr,ds),Y(Fr,jg,new Map),Y(Fr,$f,new Map),Y(Fr,jE,new WeakMap),Y(Fr,kd,null),Y(Fr,Kg,new Set),Fr);const m7e=100;function gF(t={}){typeof t=="string"||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new _F,{docId:n}=e,r=t.url?vUe(t.url):null,a=t.data?TUe(t.data):null,i=t.httpHeaders||null,s=t.withCredentials===!0,o=t.password??null,l=t.range instanceof bF?t.range:null,u=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:2**16;let p=t.worker instanceof Jh?t.worker:null;const f=t.verbosity,m=typeof t.docBaseUrl=="string"&&!F0(t.docBaseUrl)?t.docBaseUrl:null,g=NA(t.cMapUrl),S=t.cMapPacked!==!1,E=t.CMapReaderFactory||(ui?OUe:qre),y=NA(t.iccUrl),v=NA(t.standardFontDataUrl),A=t.StandardFontDataFactory||(ui?IUe:Yre),T=NA(t.wasmUrl),w=t.WasmFactory||(ui?DUe:Wre),O=t.stopAtErrors!==!0,R=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,I=t.isEvalSupported!==!1,L=typeof t.isOffscreenCanvasSupported=="boolean"?t.isOffscreenCanvasSupported:!ui,P=typeof t.isImageDecoderSupported=="boolean"?t.isImageDecoderSupported:!ui&&(Ea.platform.isFirefox||!globalThis.chrome),U=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,H=typeof t.disableFontFace=="boolean"?t.disableFontFace:ui,W=t.fontExtraProperties===!0,Z=t.enableXfa===!0,F=t.ownerDocument||globalThis.document,j=t.disableRange===!0,z=t.disableStream===!0,V=t.disableAutoFetch===!0,X=t.pdfBug===!0,te=t.CanvasFactory||(ui?xUe:RUe),$=t.FilterFactory||(ui?wUe:NUe),Q=t.enableHWA===!0,ee=t.useWasm!==!1,B=l?l.length:t.length??NaN,ie=typeof t.useSystemFonts=="boolean"?t.useSystemFonts:!ui&&!H,ce=typeof t.useWorkerFetch=="boolean"?t.useWorkerFetch:!!(E===qre&&A===Yre&&w===Wre&&g&&v&&T&&B0(g,document.baseURI)&&B0(v,document.baseURI)&&B0(T,document.baseURI)),se=null;rUe(f);const ne={canvasFactory:new te({ownerDocument:F,enableHWA:Q}),filterFactory:new $({docId:n,ownerDocument:F}),cMapReaderFactory:ce?null:new E({baseUrl:g,isCompressed:S}),standardFontDataFactory:ce?null:new A({baseUrl:v}),wasmFactory:ce?null:new w({baseUrl:T})};p||(p=Jh.create({verbosity:f,port:Gs.workerPort}),e._worker=p);const oe={docId:n,apiVersion:"5.4.296",data:a,password:o,disableAutoFetch:V,rangeChunkSize:u,length:B,docBaseUrl:m,enableXfa:Z,evaluatorOptions:{maxImageSize:R,disableFontFace:H,ignoreErrors:O,isEvalSupported:I,isOffscreenCanvasSupported:L,isImageDecoderSupported:P,canvasMaxAreaInBytes:U,fontExtraProperties:W,useSystemFonts:ie,useWasm:ee,useWorkerFetch:ce,cMapUrl:g,iccUrl:y,standardFontDataUrl:v,wasmUrl:T}},he={ownerDocument:F,pdfBug:X,styleElement:se,loadingParams:{disableAutoFetch:V,enableXfa:Z}};return p.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(p.destroyed)throw new Error("Worker was destroyed");const _e=p.messageHandler.sendWithPromise("GetDocRequest",oe,a?[a.buffer]:null);let Ce;if(l)Ce=new XUe(l,{disableRange:j,disableStream:z});else if(!a){if(!r)throw new Error("getDocument - no `url` parameter provided.");const Ne=B0(r)?e7e:ui?u7e:i7e;Ce=new Ne({url:r,length:B,httpHeaders:i,withCredentials:s,rangeChunkSize:u,disableRange:j,disableStream:z})}return _e.then(Ne=>{if(e.destroyed)throw new Error("Loading aborted");if(p.destroyed)throw new Error("Worker was destroyed");const Te=new q0(n,Ne,p.port),De=new _7e(Te,e,Ce,he,ne,Q);e._transport=De,Te.send("Ready",null)})}).catch(e._capability.reject),e}const iC=class iC{constructor(){Pe(this,"_capability",Promise.withResolvers());Pe(this,"_transport",null);Pe(this,"_worker",null);Pe(this,"docId",`d${_a(iC,aC)._++}`);Pe(this,"destroyed",!1);Pe(this,"onPassword",null);Pe(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var e,n,r,a;this.destroyed=!0;try{(e=this._worker)!=null&&e.port&&(this._worker._pendingDestroy=!0),await((n=this._transport)==null?void 0:n.destroy())}catch(i){throw(r=this._worker)!=null&&r.port&&delete this._worker._pendingDestroy,i}this._transport=null,(a=this._worker)==null||a.destroy(),this._worker=null}async getData(){return this._transport.getData()}};aC=new WeakMap,Y(iC,aC,0);let _F=iC,bF=(Yae=class{constructor(e,n,r=!1,a=null){Y(this,Yf,Promise.withResolvers());Y(this,KE,[]);Y(this,XE,[]);Y(this,QE,[]);Y(this,ZE,[]);this.length=e,this.initialData=n,this.progressiveDone=r,this.contentDispositionFilename=a}addRangeListener(e){_(this,ZE).push(e)}addProgressListener(e){_(this,QE).push(e)}addProgressiveReadListener(e){_(this,XE).push(e)}addProgressiveDoneListener(e){_(this,KE).push(e)}onDataRange(e,n){for(const r of _(this,ZE))r(e,n)}onDataProgress(e,n){_(this,Yf).promise.then(()=>{for(const r of _(this,QE))r(e,n)})}onDataProgressiveRead(e){_(this,Yf).promise.then(()=>{for(const n of _(this,XE))n(e)})}onDataProgressiveDone(){_(this,Yf).promise.then(()=>{for(const e of _(this,KE))e()})}transportReady(){_(this,Yf).resolve()}requestDataRange(e,n){Qn("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}},Yf=new WeakMap,KE=new WeakMap,XE=new WeakMap,QE=new WeakMap,ZE=new WeakMap,Yae);class h7e{constructor(e,n){this._pdfInfo=e,this._transport=n}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return qt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(e,n){return this._transport.getAnnotationsByType(e,n)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:n}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(n)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class g7e{constructor(e,n,r,a=!1){Y(this,Vf);Y(this,Vc,!1);this._pageIndex=e,this._pageInfo=n,this._transport=r,this._stats=a?new Cre:null,this._pdfBug=a,this.commonObjs=r.commonObjs,this.objs=new dae,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:n=this.rotate,offsetX:r=0,offsetY:a=0,dontFlip:i=!1}={}){return new P0({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:n,offsetX:r,offsetY:a,dontFlip:i})}getAnnotations({intent:e="display"}={}){const{renderingIntent:n}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,n)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return qt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var e;return((e=this._transport._htmlForXfa)==null?void 0:e.children[this._pageIndex])||null}render({canvasContext:e,canvas:n=e.canvas,viewport:r,intent:a="display",annotationMode:i=_l.ENABLE,transform:s=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:u=null,pageColors:p=null,printAnnotationStorage:f=null,isEditing:m=!1,recordOperations:g=!1,operationsFilter:S=null}){var P,U,H;(P=this._stats)==null||P.time("Overall");const E=this._transport.getRenderingIntent(a,i,f,m),{renderingIntent:y,cacheKey:v}=E;M(this,Vc,!1),l||(l=this._transport.getOptionalContentConfig(y));let A=this._intentStates.get(v);A||(A=Object.create(null),this._intentStates.set(v,A)),A.streamReaderCancelTimeout&&(clearTimeout(A.streamReaderCancelTimeout),A.streamReaderCancelTimeout=null);const T=!!(y&rs.PRINT);A.displayReadyCapability||(A.displayReadyCapability=Promise.withResolvers(),A.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(U=this._stats)==null||U.time("Page Request"),this._pumpOperatorList(E));const w=!!(this._pdfBug&&((H=globalThis.StepperManager)!=null&&H.enabled)),O=!this.recordedBBoxes&&(g||w),R=W=>{var Z,F;if(A.renderTasks.delete(I),O){const j=(Z=I.gfx)==null?void 0:Z.dependencyTracker.take();j&&(I.stepper&&I.stepper.setOperatorBBoxes(j,I.gfx.dependencyTracker.takeDebugMetadata()),g&&(this.recordedBBoxes=j))}T&&M(this,Vc,!0),K(this,Vf,ky).call(this),W?(I.capability.reject(W),this._abortOperatorList({intentState:A,reason:W instanceof Error?W:new Error(W)})):I.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(F=globalThis.Stats)!=null&&F.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},I=new EF({callback:R,params:{canvas:n,canvasContext:e,dependencyTracker:O?new MUe(n,A.operatorList.length,w):null,viewport:r,transform:s,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:u,operatorList:A.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!T,pdfBug:this._pdfBug,pageColors:p,enableHWA:this._transport.enableHWA,operationsFilter:S});(A.renderTasks||(A.renderTasks=new Set)).add(I);const L=I.task;return Promise.all([A.displayReadyCapability.promise,l]).then(([W,Z])=>{var F;if(this.destroyed){R();return}if((F=this._stats)==null||F.time("Rendering"),!(Z.renderingIntent&y))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");I.initializeGraphics({transparency:W,optionalContentConfig:Z}),I.operatorListChanged()}).catch(R),L}getOperatorList({intent:e="display",annotationMode:n=_l.ENABLE,printAnnotationStorage:r=null,isEditing:a=!1}={}){var u;function i(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const s=this._transport.getRenderingIntent(e,n,r,a,!0);let o=this._intentStates.get(s.cacheKey);o||(o=Object.create(null),this._intentStates.set(s.cacheKey,o));let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=i,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(u=this._stats)==null||u.time("Page Request"),this._pumpOperatorList(s)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:n=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:e===!0,disableNormalization:n===!0},{highWaterMark:100,size(a){return a.items.length}})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(r=>L0.textContent(r));const n=this.streamTextContent(e);return new Promise(function(r,a){function i(){s.read().then(function({value:l,done:u}){if(u){r(o);return}o.lang??(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),i()},a)}const s=n.getReader(),o={items:[],styles:Object.create(null),lang:null};i()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const n of this._intentStates.values())if(this._abortOperatorList({intentState:n,reason:new Error("Page was destroyed."),force:!0}),!n.opListReadCapability)for(const r of n.renderTasks)e.push(r.completed),r.cancel();return this.objs.clear(),M(this,Vc,!1),Promise.all(e)}cleanup(e=!1){M(this,Vc,!0);const n=K(this,Vf,ky).call(this);return e&&n&&this._stats&&(this._stats=new Cre),n}_startRenderPage(e,n){var a,i;const r=this._intentStates.get(n);r&&((a=this._stats)==null||a.timeEnd("Page Request"),(i=r.displayReadyCapability)==null||i.resolve(e))}_renderPageChunk(e,n){for(let r=0,a=e.length;r<a;r++)n.operatorList.fnArray.push(e.fnArray[r]),n.operatorList.argsArray.push(e.argsArray[r]);n.operatorList.lastChunk=e.lastChunk,n.operatorList.separateAnnots=e.separateAnnots;for(const r of n.renderTasks)r.operatorListChanged();e.lastChunk&&K(this,Vf,ky).call(this)}_pumpOperatorList({renderingIntent:e,cacheKey:n,annotationStorageSerializable:r,modifiedIds:a}){const{map:i,transfer:s}=r,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:n,annotationStorage:i,modifiedIds:a},s).getReader(),u=this._intentStates.get(n);u.streamReader=l;const p=()=>{l.read().then(({value:f,done:m})=>{if(m){u.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(f,u),p())},f=>{if(u.streamReader=null,!this._transport.destroyed){if(u.operatorList){u.operatorList.lastChunk=!0;for(const m of u.renderTasks)m.operatorListChanged();K(this,Vf,ky).call(this)}if(u.displayReadyCapability)u.displayReadyCapability.reject(f);else if(u.opListReadCapability)u.opListReadCapability.reject(f);else throw f}})};p()}_abortOperatorList({intentState:e,reason:n,force:r=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!r){if(e.renderTasks.size>0)return;if(n instanceof vA){let a=m7e;n.extraDelay>0&&n.extraDelay<1e3&&(a+=n.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:n,force:!0})},a);return}}if(e.streamReader.cancel(new yc(n.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(const[a,i]of this._intentStates)if(i===e){this._intentStates.delete(a);break}this.cleanup()}}}get stats(){return this._stats}}Vc=new WeakMap,Vf=new WeakSet,ky=function(){if(!_(this,Vc)||this.destroyed)return!1;for(const{renderTasks:e,operatorList:n}of this._intentStates.values())if(e.size>0||!n.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),M(this,Vc,!1),!0};const br=class br{constructor({name:e=null,port:n=null,verbosity:r=aUe()}={}){Y(this,pi);Y(this,Md,Promise.withResolvers());Y(this,Bo,null);Y(this,Wc,null);Y(this,Wf,null);if(this.name=e,this.destroyed=!1,this.verbosity=r,n){if(_(br,Kf).has(n))throw new Error("Cannot use more than one PDFWorker per port.");_(br,Kf).set(n,this),K(this,pi,oce).call(this,n)}else K(this,pi,lce).call(this)}get promise(){return _(this,Md).promise}get port(){return _(this,Wc)}get messageHandler(){return _(this,Bo)}destroy(){var e,n;this.destroyed=!0,(e=_(this,Wf))==null||e.terminate(),M(this,Wf,null),_(br,Kf).delete(_(this,Wc)),M(this,Wc,null),(n=_(this,Bo))==null||n.destroy(),M(this,Bo,null)}static create(e){const n=_(this,Kf).get(e==null?void 0:e.port);if(n){if(n._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return n}return new br(e)}static get workerSrc(){if(Gs.workerSrc)return Gs.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return qt(this,"_setupFakeWorkerGlobal",(async()=>_(this,Xg,MR)?_(this,Xg,MR):(await import(this.workerSrc)).WorkerMessageHandler)())}};Md=new WeakMap,Bo=new WeakMap,Wc=new WeakMap,Wf=new WeakMap,sC=new WeakMap,jf=new WeakMap,Kf=new WeakMap,pi=new WeakSet,kR=function(){_(this,Md).resolve(),_(this,Bo).send("configure",{verbosity:this.verbosity})},oce=function(e){M(this,Wc,e),M(this,Bo,new q0("main","worker",e)),_(this,Bo).on("ready",()=>{}),K(this,pi,kR).call(this)},lce=function(){if(_(br,jf)||_(br,Xg,MR)){K(this,pi,My).call(this);return}let{workerSrc:e}=br;try{br._isSameOrigin(window.location,e)||(e=br._createCDNWrapper(new URL(e,window.location).href));const n=new Worker(e,{type:"module"}),r=new q0("main","worker",n),a=()=>{i.abort(),r.destroy(),n.terminate(),this.destroyed?_(this,Md).reject(new Error("Worker was destroyed")):K(this,pi,My).call(this)},i=new AbortController;n.addEventListener("error",()=>{_(this,Wf)||a()},{signal:i.signal}),r.on("test",o=>{if(i.abort(),this.destroyed||!o){a();return}M(this,Bo,r),M(this,Wc,n),M(this,Wf,n),K(this,pi,kR).call(this)}),r.on("ready",o=>{if(i.abort(),this.destroyed){a();return}try{s()}catch{K(this,pi,My).call(this)}});const s=()=>{const o=new Uint8Array;r.send("test",o,[o.buffer])};s();return}catch{SA("The worker has been disabled.")}K(this,pi,My).call(this)},My=function(){_(br,jf)||(It("Setting up fake worker."),M(br,jf,!0)),br._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){_(this,Md).reject(new Error("Worker was destroyed"));return}const n=new CUe;M(this,Wc,n);const r=`fake${_a(br,sC)._++}`,a=new q0(r+"_worker",r,n);e.setup(a,n),M(this,Bo,new q0(r,r+"_worker",n)),K(this,pi,kR).call(this)}).catch(e=>{_(this,Md).reject(new Error(`Setting up fake worker failed: "${e.message}".`))})},Xg=new WeakSet,MR=function(){var e;try{return((e=globalThis.pdfjsWorker)==null?void 0:e.WorkerMessageHandler)||null}catch{return null}},Y(br,Xg),Y(br,sC,0),Y(br,jf,!1),Y(br,Kf,new WeakMap),ui&&(M(br,jf,!0),Gs.workerSrc||(Gs.workerSrc="./pdf.worker.mjs")),br._isSameOrigin=(e,n)=>{const r=URL.parse(e);if(!(r!=null&&r.origin)||r.origin==="null")return!1;const a=new URL(n,r);return r.origin===a.origin},br._createCDNWrapper=e=>{const n=`await import("${e}");`;return URL.createObjectURL(new Blob([n],{type:"text/javascript"}))},br.fromPort=e=>{if(fUe("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(e!=null&&e.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return br.create(e)};let Jh=br;class _7e{constructor(e,n,r,a,i,s){Y(this,Xf);Y(this,jc,new Map);Y(this,Ml,new Map);Y(this,Qg,new Map);Y(this,Zg,new Map);Y(this,Kc,null);this.messageHandler=e,this.loadingTask=n,this.commonObjs=new dae,this.fontLoader=new SUe({ownerDocument:a.ownerDocument,styleElement:a.styleElement}),this.loadingParams=a.loadingParams,this._params=a,this.canvasFactory=i.canvasFactory,this.filterFactory=i.filterFactory,this.cMapReaderFactory=i.cMapReaderFactory,this.standardFontDataFactory=i.standardFontDataFactory,this.wasmFactory=i.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=r,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=s,this.setupMessageHandler()}get annotationStorage(){return qt(this,"annotationStorage",new aF)}getRenderingIntent(e,n=_l.ENABLE,r=null,a=!1,i=!1){let s=rs.DISPLAY,o=rF;switch(e){case"any":s=rs.ANY;break;case"display":break;case"print":s=rs.PRINT;break;default:It(`getRenderingIntent - invalid intent: ${e}`)}const l=s&rs.PRINT&&r instanceof Fre?r:this.annotationStorage;switch(n){case _l.DISABLE:s+=rs.ANNOTATIONS_DISABLE;break;case _l.ENABLE:break;case _l.ENABLE_FORMS:s+=rs.ANNOTATIONS_FORMS;break;case _l.ENABLE_STORAGE:s+=rs.ANNOTATIONS_STORAGE,o=l.serializable;break;default:It(`getRenderingIntent - invalid annotationMode: ${n}`)}a&&(s+=rs.IS_EDITING),i&&(s+=rs.OPLIST);const{ids:u,hash:p}=l.modifiedIds,f=[s,o.hash,p];return{renderingIntent:s,cacheKey:f.join("_"),annotationStorageSerializable:o,modifiedIds:u}}destroy(){var r;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(r=_(this,Kc))==null||r.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const a of _(this,Ml).values())e.push(a._destroy());_(this,Ml).clear(),_(this,Qg).clear(),_(this,Zg).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const n=this.messageHandler.sendWithPromise("Terminate",null);return e.push(n),Promise.all(e).then(()=>{var a,i;this.commonObjs.clear(),this.fontLoader.clear(),_(this,jc).clear(),this.filterFactory.destroy(),V0.cleanup(),(a=this._networkStream)==null||a.cancelAllRequests(new yc("Worker was terminated.")),(i=this.messageHandler)==null||i.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:n}=this;e.on("GetReader",(r,a)=>{on(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=i=>{this._lastProgress={loaded:i.loaded,total:i.total}},a.onPull=()=>{this._fullReader.read().then(function({value:i,done:s}){if(s){a.close();return}on(i instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),a.enqueue(new Uint8Array(i),1,[i])}).catch(i=>{a.error(i)})},a.onCancel=i=>{this._fullReader.cancel(i),a.ready.catch(s=>{if(!this.destroyed)throw s})}}),e.on("ReaderHeadersReady",async r=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:a,isRangeSupported:i,contentLength:s}=this._fullReader;return(!a||!i)&&(this._lastProgress&&((o=n.onProgress)==null||o.call(n,this._lastProgress)),this._fullReader.onProgress=l=>{var u;(u=n.onProgress)==null||u.call(n,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:a,isRangeSupported:i,contentLength:s}}),e.on("GetRangeReader",(r,a)=>{on(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(r.begin,r.end);if(!i){a.close();return}a.onPull=()=>{i.read().then(function({value:s,done:o}){if(o){a.close();return}on(s instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),a.enqueue(new Uint8Array(s),1,[s])}).catch(s=>{a.error(s)})},a.onCancel=s=>{i.cancel(s),a.ready.catch(o=>{if(!this.destroyed)throw o})}}),e.on("GetDoc",({pdfInfo:r})=>{this._numPages=r.numPages,this._htmlForXfa=r.htmlForXfa,delete r.htmlForXfa,n._capability.resolve(new h7e(r,this))}),e.on("DocException",r=>{n._capability.reject(xi(r))}),e.on("PasswordRequest",r=>{M(this,Kc,Promise.withResolvers());try{if(!n.onPassword)throw xi(r);const a=i=>{i instanceof Error?_(this,Kc).reject(i):_(this,Kc).resolve({password:i})};n.onPassword(a,r.code)}catch(a){_(this,Kc).reject(a)}return _(this,Kc).promise}),e.on("DataLoaded",r=>{var a;(a=n.onProgress)==null||a.call(n,{loaded:r.length,total:r.length}),this.downloadInfoCapability.resolve(r)}),e.on("StartRenderPage",r=>{if(this.destroyed)return;_(this,Ml).get(r.pageIndex)._startRenderPage(r.transparency,r.cacheKey)}),e.on("commonobj",([r,a,i])=>{var s;if(this.destroyed||this.commonObjs.has(r))return null;switch(a){case"Font":if("error"in i){const f=i.error;It(`Error during font loading: ${f}`),this.commonObjs.resolve(r,f);break}const o=new fF(i),l=this._params.pdfBug&&((s=globalThis.FontInspector)!=null&&s.enabled)?(f,m)=>globalThis.FontInspector.fontAdded(f,m):null,u=new yUe(o,l,i.extra,i.charProcOperatorList);this.fontLoader.bind(u).catch(()=>e.sendWithPromise("FontFallback",{id:r})).finally(()=>{!u.fontExtraProperties&&u.data&&u.clearData(),this.commonObjs.resolve(r,u)});break;case"CopyLocalImage":const{imageRef:p}=i;on(p,"The imageRef must be defined.");for(const f of _(this,Ml).values())for(const[,m]of f.objs)if((m==null?void 0:m.ref)===p)return m.dataLen?(this.commonObjs.resolve(r,structuredClone(m)),m.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(r,i);break;default:throw new Error(`Got unknown common object type ${a}`)}return null}),e.on("obj",([r,a,i,s])=>{var l;if(this.destroyed)return;const o=_(this,Ml).get(a);if(!o.objs.has(r)){if(o._intentStates.size===0){(l=s==null?void 0:s.bitmap)==null||l.close();return}switch(i){case"Image":case"Pattern":o.objs.resolve(r,s);break;default:throw new Error(`Got unknown object type ${i}`)}}}),e.on("DocProgress",r=>{var a;this.destroyed||(a=n.onProgress)==null||a.call(n,{loaded:r.loaded,total:r.total})}),e.on("FetchBinaryData",async r=>{if(this.destroyed)throw new Error("Worker was destroyed.");const a=this[r.type];if(!a)throw new Error(`${r.type} not initialized, see the \`useWorkerFetch\` parameter.`);return a.fetch(r)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var r;this.annotationStorage.size<=0&&It("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:n}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:((r=this._fullReader)==null?void 0:r.filename)??null},n).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const n=e-1,r=_(this,Qg).get(n);if(r)return r;const a=this.messageHandler.sendWithPromise("GetPage",{pageIndex:n}).then(i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&_(this,Zg).set(i.refStr,e);const s=new g7e(n,i,this,this._params.pdfBug);return _(this,Ml).set(n,s),s});return _(this,Qg).set(n,a),a}getPageIndex(e){return iF(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,n){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:n})}getFieldObjects(){return K(this,Xf,Ly).call(this,"GetFieldObjects")}hasJSActions(){return K(this,Xf,Ly).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return typeof e!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(e,n){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:e,pageIndexesToSkip:n})}getDocJSActions(){return K(this,Xf,Ly).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return K(this,Xf,Ly).call(this,"GetOptionalContentConfig").then(n=>new KUe(n,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",n=_(this,jc).get(e);if(n)return n;const r=this.messageHandler.sendWithPromise(e,null).then(a=>{var i,s;return{info:a[0],metadata:a[1]?new WUe(a[1]):null,contentDispositionFilename:((i=this._fullReader)==null?void 0:i.filename)??null,contentLength:((s=this._fullReader)==null?void 0:s.contentLength)??null}});return _(this,jc).set(e,r),r}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const n of _(this,Ml).values())if(!n.cleanup())throw new Error(`startCleanup: Page ${n.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),_(this,jc).clear(),this.filterFactory.destroy(!0),V0.cleanup()}}cachedPageNumber(e){if(!iF(e))return null;const n=e.gen===0?`${e.num}R`:`${e.num}R${e.gen}`;return _(this,Zg).get(n)??null}}jc=new WeakMap,Ml=new WeakMap,Qg=new WeakMap,Zg=new WeakMap,Kc=new WeakMap,Xf=new WeakSet,Ly=function(e,n=null){const r=_(this,jc).get(e);if(r)return r;const a=this.messageHandler.sendWithPromise(e,n);return _(this,jc).set(e,a),a};class b7e{constructor(e){Y(this,Ld,null);Pe(this,"onContinue",null);Pe(this,"onError",null);M(this,Ld,e)}get promise(){return _(this,Ld).capability.promise}cancel(e=0){_(this,Ld).cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=_(this,Ld).operatorList;if(!e)return!1;const{annotationCanvasMap:n}=_(this,Ld);return e.form||e.canvas&&(n==null?void 0:n.size)>0}}Ld=new WeakMap;const Zf=class Zf{constructor({callback:e,params:n,objs:r,commonObjs:a,annotationCanvasMap:i,operatorList:s,pageIndex:o,canvasFactory:l,filterFactory:u,useRequestAnimationFrame:p=!1,pdfBug:f=!1,pageColors:m=null,enableHWA:g=!1,operationsFilter:S=null}){Y(this,Pd,null);this.callback=e,this.params=n,this.objs=r,this.commonObjs=a,this.annotationCanvasMap=i,this.operatorListIdx=null,this.operatorList=s,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=u,this._pdfBug=f,this.pageColors=m,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=p===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new b7e(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=n.canvas,this._canvasContext=n.canvas?null:n.canvasContext,this._enableHWA=g,this._dependencyTracker=n.dependencyTracker,this._operationsFilter=S}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:n}){var l,u;if(this.cancelled)return;if(this._canvas){if(_(Zf,Qf).has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");_(Zf,Qf).add(this._canvas)}this._pdfBug&&((l=globalThis.StepperManager)!=null&&l.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:r,transform:a,background:i,dependencyTracker:s}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Qh(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:n},this.annotationCanvasMap,this.pageColors,s),this.gfx.beginDrawing({transform:a,viewport:r,transparency:e,background:i}),this.operatorListIdx=0,this.graphicsReady=!0,(u=this.graphicsReadyCallback)==null||u.call(this)}cancel(e=null,n=0){var r,a,i;this.running=!1,this.cancelled=!0,(r=this.gfx)==null||r.endDrawing(),_(this,Pd)&&(window.cancelAnimationFrame(_(this,Pd)),M(this,Pd,null)),_(Zf,Qf).delete(this._canvas),e||(e=new vA(`Rendering cancelled, page ${this._pageIndex+1}`,n)),this.callback(e),(i=(a=this.task).onError)==null||i.call(a,e)}operatorListChanged(){var e,n;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(e=this.gfx.dependencyTracker)==null||e.growOperationsCount(this.operatorList.fnArray.length),(n=this.stepper)==null||n.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?M(this,Pd,window.requestAnimationFrame(()=>{M(this,Pd,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),_(Zf,Qf).delete(this._canvas),this.callback())))}};Pd=new WeakMap,Qf=new WeakMap,Y(Zf,Qf,new WeakSet);let EF=Zf;const W0="5.4.296",fae="f56dc8601",Pi=class Pi{constructor({editor:e=null,uiManager:n=null}){Y(this,Hn);Y(this,ps,null);Y(this,Jf,null);Y(this,Jg);Y(this,ca,null);Y(this,JE,!1);Y(this,e_,!1);Y(this,Xc,null);Y(this,eS);Y(this,Fd,null);Y(this,Uo,null);var r,a;e?(M(this,e_,!1),M(this,Xc,e)):M(this,e_,!0),M(this,Uo,(e==null?void 0:e._uiManager)||n),M(this,eS,_(this,Uo)._eventBus),M(this,Jg,((r=e==null?void 0:e.color)==null?void 0:r.toUpperCase())||((a=_(this,Uo))==null?void 0:a.highlightColors.values().next().value)||"#FFFF98"),_(Pi,tS)||M(Pi,tS,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return qt(this,"_keyboardManager",new G0([[["Escape","mac+Escape"],Pi.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Pi.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Pi.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Pi.prototype._moveToPrevious],[["Home","mac+Home"],Pi.prototype._moveToBeginning],[["End","mac+End"],Pi.prototype._moveToEnd]]))}renderButton(){const e=M(this,ps,document.createElement("button"));e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.ariaHasPopup="true",_(this,Xc)&&(e.ariaControls=`${_(this,Xc).id}_colorpicker_dropdown`);const n=_(this,Uo)._signal;e.addEventListener("click",K(this,Hn,Wm).bind(this),{signal:n}),e.addEventListener("keydown",K(this,Hn,g6).bind(this),{signal:n});const r=M(this,Jf,document.createElement("span"));return r.className="swatch",r.ariaHidden="true",r.style.backgroundColor=_(this,Jg),e.append(r),e}renderMainDropdown(){const e=M(this,ca,K(this,Hn,m6).call(this));return e.ariaOrientation="horizontal",e.ariaLabelledBy="highlightColorPickerLabel",e}_colorSelectFromKeyboard(e){if(e.target===_(this,ps)){K(this,Hn,Wm).call(this,e);return}const n=e.target.getAttribute("data-color");n&&K(this,Hn,h6).call(this,n,e)}_moveToNext(e){var n,r;if(!_(this,Hn,kp)){K(this,Hn,Wm).call(this,e);return}if(e.target===_(this,ps)){(n=_(this,ca).firstChild)==null||n.focus();return}(r=e.target.nextSibling)==null||r.focus()}_moveToPrevious(e){var n,r;if(e.target===((n=_(this,ca))==null?void 0:n.firstChild)||e.target===_(this,ps)){_(this,Hn,kp)&&this._hideDropdownFromKeyboard();return}_(this,Hn,kp)||K(this,Hn,Wm).call(this,e),(r=e.target.previousSibling)==null||r.focus()}_moveToBeginning(e){var n;if(!_(this,Hn,kp)){K(this,Hn,Wm).call(this,e);return}(n=_(this,ca).firstChild)==null||n.focus()}_moveToEnd(e){var n;if(!_(this,Hn,kp)){K(this,Hn,Wm).call(this,e);return}(n=_(this,ca).lastChild)==null||n.focus()}hideDropdown(){var e,n;(e=_(this,ca))==null||e.classList.add("hidden"),_(this,ps).ariaExpanded="false",(n=_(this,Fd))==null||n.abort(),M(this,Fd,null)}_hideDropdownFromKeyboard(){var e;if(!_(this,e_)){if(!_(this,Hn,kp)){(e=_(this,Xc))==null||e.unselect();return}this.hideDropdown(),_(this,ps).focus({preventScroll:!0,focusVisible:_(this,JE)})}}updateColor(e){if(_(this,Jf)&&(_(this,Jf).style.backgroundColor=e),!_(this,ca))return;const n=_(this,Uo).highlightColors.values();for(const r of _(this,ca).children)r.ariaSelected=n.next().value===e.toUpperCase()}destroy(){var e,n;(e=_(this,ps))==null||e.remove(),M(this,ps,null),M(this,Jf,null),(n=_(this,ca))==null||n.remove(),M(this,ca,null)}};ps=new WeakMap,Jf=new WeakMap,Jg=new WeakMap,ca=new WeakMap,JE=new WeakMap,e_=new WeakMap,Xc=new WeakMap,eS=new WeakMap,Fd=new WeakMap,Uo=new WeakMap,tS=new WeakMap,Hn=new WeakSet,m6=function(){const e=document.createElement("div"),n=_(this,Uo)._signal;e.addEventListener("contextmenu",as,{signal:n}),e.className="dropdown",e.role="listbox",e.ariaMultiSelectable="false",e.ariaOrientation="vertical",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),_(this,Xc)&&(e.id=`${_(this,Xc).id}_colorpicker_dropdown`);for(const[r,a]of _(this,Uo).highlightColors){const i=document.createElement("button");i.tabIndex="0",i.role="option",i.setAttribute("data-color",a),i.title=r,i.setAttribute("data-l10n-id",_(Pi,tS)[r]);const s=document.createElement("span");i.append(s),s.className="swatch",s.style.backgroundColor=a,i.ariaSelected=a===_(this,Jg),i.addEventListener("click",K(this,Hn,h6).bind(this,a),{signal:n}),e.append(i)}return e.addEventListener("keydown",K(this,Hn,g6).bind(this),{signal:n}),e},h6=function(e,n){n.stopPropagation(),_(this,eS).dispatch("switchannotationeditorparams",{source:this,type:rn.HIGHLIGHT_COLOR,value:e}),this.updateColor(e)},g6=function(e){Pi._keyboardManager.exec(this,e)},Wm=function(e){if(_(this,Hn,kp)){this.hideDropdown();return}if(M(this,JE,e.detail===0),_(this,Fd)||(M(this,Fd,new AbortController),window.addEventListener("pointerdown",K(this,Hn,cce).bind(this),{signal:_(this,Uo).combinedSignal(_(this,Fd))})),_(this,ps).ariaExpanded="true",_(this,ca)){_(this,ca).classList.remove("hidden");return}const n=M(this,ca,K(this,Hn,m6).call(this));_(this,ps).append(n)},cce=function(e){var n;(n=_(this,ca))!=null&&n.contains(e.target)||this.hideDropdown()},kp=function(){return _(this,ca)&&!_(this,ca).classList.contains("hidden")},Y(Pi,tS,null);let j0=Pi;const em=class em{constructor(e){Y(this,Ll,null);Y(this,nS,null);Y(this,t_,null);M(this,nS,e),M(this,t_,e._uiManager),_(em,rS)||M(em,rS,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(_(this,Ll))return _(this,Ll);const{editorType:e,colorType:n,colorValue:r}=_(this,nS),a=M(this,Ll,document.createElement("input"));return a.type="color",a.value=r||"#000000",a.className="basicColorPicker",a.tabIndex=0,a.setAttribute("data-l10n-id",_(em,rS)[e]),a.addEventListener("input",()=>{_(this,t_).updateParams(n,a.value)},{signal:_(this,t_)._signal}),a}update(e){_(this,Ll)&&(_(this,Ll).value=e)}destroy(){var e;(e=_(this,Ll))==null||e.remove(),M(this,Ll,null)}hideDropdown(){}};Ll=new WeakMap,nS=new WeakMap,t_=new WeakMap,rS=new WeakMap,Y(em,rS,null);let FA=em;function mae(t){return Math.floor(Math.max(0,Math.min(1,t))*255).toString(16).padStart(2,"0")}function K0(t){return Math.max(0,Math.min(255,255*t))}class hae{static CMYK_G([e,n,r,a]){return["G",1-Math.min(1,.3*e+.59*r+.11*n+a)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return e=K0(e),[e,e,e]}static G_HTML([e]){const n=mae(e);return`#${n}${n}${n}`}static RGB_G([e,n,r]){return["G",.3*e+.59*n+.11*r]}static RGB_rgb(e){return e.map(K0)}static RGB_HTML(e){return`#${e.map(mae).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,n,r,a]){return["RGB",1-Math.min(1,e+a),1-Math.min(1,r+a),1-Math.min(1,n+a)]}static CMYK_rgb([e,n,r,a]){return[K0(1-Math.min(1,e+a)),K0(1-Math.min(1,r+a)),K0(1-Math.min(1,n+a))]}static CMYK_HTML(e){const n=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(n)}static RGB_CMYK([e,n,r]){const a=1-e,i=1-n,s=1-r,o=Math.min(a,i,s);return["CMYK",a,i,s,o]}}class E7e{create(e,n,r=!1){if(e<=0||n<=0)throw new Error("Invalid SVG dimensions");const a=this._createSVG("svg:svg");return a.setAttribute("version","1.1"),r||(a.setAttribute("width",`${e}px`),a.setAttribute("height",`${n}px`)),a.setAttribute("preserveAspectRatio","none"),a.setAttribute("viewBox",`0 0 ${e} ${n}`),a}createElement(e){if(typeof e!="string")throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Qn("Abstract method `_createSVG` called.")}}class X0 extends E7e{_createSVG(e){return document.createElementNS(vc,e)}}const S7e=9,lf=new WeakSet,y7e=new Date().getTimezoneOffset()*60*1e3;class gae{static create(e){switch(e.data.annotationType){case Yr.LINK:return new SF(e);case Yr.TEXT:return new T7e(e);case Yr.WIDGET:switch(e.data.fieldType){case"Tx":return new A7e(e);case"Btn":return e.data.radioButton?new _ae(e):e.data.checkBox?new R7e(e):new N7e(e);case"Ch":return new w7e(e);case"Sig":return new C7e(e)}return new cf(e);case Yr.POPUP:return new yF(e);case Yr.FREETEXT:return new bae(e);case Yr.LINE:return new O7e(e);case Yr.SQUARE:return new I7e(e);case Yr.CIRCLE:return new D7e(e);case Yr.POLYLINE:return new Eae(e);case Yr.CARET:return new M7e(e);case Yr.INK:return new vF(e);case Yr.POLYGON:return new k7e(e);case Yr.HIGHLIGHT:return new Sae(e);case Yr.UNDERLINE:return new L7e(e);case Yr.SQUIGGLY:return new P7e(e);case Yr.STRIKEOUT:return new F7e(e);case Yr.STAMP:return new yae(e);case Yr.FILEATTACHMENT:return new B7e(e);default:return new wr(e)}}}const GF=class GF{constructor(e,{isRenderable:n=!1,ignoreBorder:r=!1,createQuadrilaterals:a=!1}={}){Y(this,aS);Y(this,tm,null);Y(this,n_,!1);Y(this,Xs,null);this.isRenderable=n,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableComment=e.enableComment,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,n&&(this.container=this._createContainer(r)),a&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:n}){return!!(e!=null&&e.str||n!=null&&n.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return GF._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var r;const{data:e}=this,n=(r=this.annotationStorage)==null?void 0:r.getEditor(e.id);return n?n.getData():e}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var o;const e=(o=this.annotationStorage)==null?void 0:o.getEditor(this.data.id);if(e)return e.commentButtonPositionInPage;const{quadPoints:n,inkLists:r,rect:a}=this.data;let i=-1/0,s=-1/0;if((n==null?void 0:n.length)>=8){for(let l=0;l<n.length;l+=8)n[l+1]>s?(s=n[l+1],i=n[l+2]):n[l+1]===s&&(i=Math.max(i,n[l+2]));return[i,s]}if((r==null?void 0:r.length)>=1){for(const l of r)for(let u=0,p=l.length;u<p;u+=2)l[u+1]>s?(s=l[u+1],i=l[u]):l[u+1]===s&&(i=Math.max(i,l[u]));if(i!==1/0)return[i,s]}return a?[a[2],a[3]]:null}_normalizePoint(e){const{page:{view:n},viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:i,pageY:s}}}=this.parent;return e[1]=n[3]-e[1]+n[1],e[0]=100*(e[0]-i)/r,e[1]=100*(e[1]-s)/a,e}get commentText(){var n,r,a;const{data:e}=this;return((r=(n=this.annotationStorage.getRawValue(`${O0}${e.id}`))==null?void 0:n.popup)==null?void 0:r.contents)||((a=e.contentsObj)==null?void 0:a.str)||""}set commentText(e){const{data:n}=this,r={deleted:!e,contents:e||""};this.annotationStorage.updateEditor(n.id,{popup:r})||this.annotationStorage.setValue(`${O0}${n.id}`,{id:n.id,annotationType:n.annotationType,pageIndex:this.parent.page._pageIndex,popup:r,popupRef:n.popupRef,modificationDate:new Date}),e||this.removePopup()}removePopup(){var e,n;(n=((e=_(this,Xs))==null?void 0:e.popup)||this.popup)==null||n.remove(),M(this,Xs,this.popup=null)}updateEdited(e){var i;if(!this.container)return;e.rect&&(_(this,tm)||M(this,tm,{rect:this.data.rect.slice(0)}));const{rect:n,popup:r}=e;n&&K(this,aS,_6).call(this,n);let a=((i=_(this,Xs))==null?void 0:i.popup)||this.popup;!a&&(r!=null&&r.text)&&(this._createPopup(r),a=_(this,Xs).popup),a&&(a.updateEdited(e),r!=null&&r.deleted&&(a.remove(),M(this,Xs,null),this.popup=null))}resetEdited(){var e;_(this,tm)&&(K(this,aS,_6).call(this,_(this,tm).rect),(e=_(this,Xs))==null||e.popup.resetEdited(),M(this,tm,null))}_createContainer(e){const{data:n,parent:{page:r,viewport:a}}=this,i=document.createElement("section");i.setAttribute("data-annotation-id",n.id),!(this instanceof cf)&&!(this instanceof SF)&&(i.tabIndex=0);const{style:s}=i;if(s.zIndex=this.parent.zIndex,this.parent.zIndex+=2,n.alternativeText&&(i.title=n.alternativeText),n.noRotate&&i.classList.add("norotate"),!n.rect||this instanceof yF){const{rotation:E}=n;return!n.hasOwnCanvas&&E!==0&&this.setRotation(E,i),i}const{width:o,height:l}=this;if(!e&&n.borderStyle.width>0){s.borderWidth=`${n.borderStyle.width}px`;const E=n.borderStyle.horizontalCornerRadius,y=n.borderStyle.verticalCornerRadius;if(E>0||y>0){const A=`calc(${E}px * var(--total-scale-factor)) / calc(${y}px * var(--total-scale-factor))`;s.borderRadius=A}else if(this instanceof _ae){const A=`calc(${o}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;s.borderRadius=A}switch(n.borderStyle.style){case Yh.SOLID:s.borderStyle="solid";break;case Yh.DASHED:s.borderStyle="dashed";break;case Yh.BEVELED:It("Unimplemented border style: beveled");break;case Yh.INSET:It("Unimplemented border style: inset");break;case Yh.UNDERLINE:s.borderBottomStyle="solid";break}const v=n.borderColor||null;v?(M(this,n_,!0),s.borderColor=Je.makeHexColor(v[0]|0,v[1]|0,v[2]|0)):s.borderWidth=0}const u=Je.normalizeRect([n.rect[0],r.view[3]-n.rect[1]+r.view[1],n.rect[2],r.view[3]-n.rect[3]+r.view[1]]),{pageWidth:p,pageHeight:f,pageX:m,pageY:g}=a.rawDims;s.left=`${100*(u[0]-m)/p}%`,s.top=`${100*(u[1]-g)/f}%`;const{rotation:S}=n;return n.hasOwnCanvas||S===0?(s.width=`${100*o/p}%`,s.height=`${100*l/f}%`):this.setRotation(S,i),i}setRotation(e,n=this.container){if(!this.data.rect)return;const{pageWidth:r,pageHeight:a}=this.parent.viewport.rawDims;let{width:i,height:s}=this;e%180!==0&&([i,s]=[s,i]),n.style.width=`${100*i/r}%`,n.style.height=`${100*s/a}%`,n.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(n,r,a)=>{const i=a.detail[n],s=i[0],o=i.slice(1);a.target.style[r]=hae[`${s}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[r]:hae[`${s}_rgb`](o)})};return qt(this,"_commonActions",{display:n=>{const{display:r}=n.detail,a=r%2===1;this.container.style.visibility=a?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:a,noPrint:r===1||r===2})},print:n=>{this.annotationStorage.setValue(this.data.id,{noPrint:!n.detail.print})},hidden:n=>{const{hidden:r}=n.detail;this.container.style.visibility=r?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:r,noView:r})},focus:n=>{setTimeout(()=>n.target.focus({preventScroll:!1}),0)},userName:n=>{n.target.title=n.detail.userName},readonly:n=>{n.target.disabled=n.detail.readonly},required:n=>{this._setRequired(n.target,n.detail.required)},bgColor:n=>{e("bgColor","backgroundColor",n)},fillColor:n=>{e("fillColor","backgroundColor",n)},fgColor:n=>{e("fgColor","color",n)},textColor:n=>{e("textColor","color",n)},borderColor:n=>{e("borderColor","borderColor",n)},strokeColor:n=>{e("strokeColor","borderColor",n)},rotation:n=>{const r=n.detail.rotation;this.setRotation(r),this.annotationStorage.setValue(this.data.id,{rotation:r})}})}_dispatchEventFromSandbox(e,n){const r=this._commonActions;for(const a of Object.keys(n.detail)){const i=e[a]||r[a];i==null||i(n)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const n=this.annotationStorage.getRawValue(this.data.id);if(!n)return;const r=this._commonActions;for(const[a,i]of Object.entries(n)){const s=r[a];if(s){const o={detail:{[a]:i},target:e};s(o),delete n[a]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[n,r,a,i]=this.data.rect.map(E=>Math.fround(E));if(e.length===8){const[E,y,v,A]=e.subarray(2,6);if(a===E&&i===y&&n===v&&r===A)return}const{style:s}=this.container;let o;if(_(this,n_)){const{borderColor:E,borderWidth:y}=s;s.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${E}" stroke-width="${y}">`],this.container.classList.add("hasBorder")}const l=a-n,u=i-r,{svgFactory:p}=this,f=p.createElement("svg");f.classList.add("quadrilateralsContainer"),f.setAttribute("width",0),f.setAttribute("height",0),f.role="none";const m=p.createElement("defs");f.append(m);const g=p.createElement("clipPath"),S=`clippath_${this.data.id}`;g.setAttribute("id",S),g.setAttribute("clipPathUnits","objectBoundingBox"),m.append(g);for(let E=2,y=e.length;E<y;E+=8){const v=e[E],A=e[E+1],T=e[E+2],w=e[E+3],O=p.createElement("rect"),R=(T-n)/l,I=(i-A)/u,L=(v-T)/l,P=(A-w)/u;O.setAttribute("x",R),O.setAttribute("y",I),O.setAttribute("width",L),O.setAttribute("height",P),g.append(O),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${R}" y="${I}" width="${L}" height="${P}"/>`)}_(this,n_)&&(o.push("</g></svg>')"),s.backgroundImage=o.join("")),this.container.append(f),this.container.style.clipPath=`url(#${S})`}_createPopup(e=null){const{data:n}=this;let r,a;e?(r={str:e.text},a=e.date):(r=n.contentsObj,a=n.modificationDate);const i=M(this,Xs,new yF({data:{color:n.color,titleObj:n.titleObj,modificationDate:a,contentsObj:r,richText:n.richText,parentRect:n.rect,borderStyle:0,id:`popup_${n.id}`,rotation:n.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent._commentManager||this.parent.div.append(i.render())}get hasPopupElement(){return!!(_(this,Xs)||this.popup||this.data.popupRef)}get extraPopupElement(){return _(this,Xs)}render(){Qn("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,n=null){const r=[];if(this._fieldObjects){const a=this._fieldObjects[e];if(a)for(const{page:i,id:s,exportValues:o}of a){if(i===-1||s===n)continue;const l=typeof o=="string"?o:null,u=document.querySelector(`[data-element-id="${s}"]`);if(u&&!lf.has(u)){It(`_getElementsByName - element not allowed: ${s}`);continue}r.push({id:s,exportValue:l,domElement:u})}return r}for(const a of document.getElementsByName(e)){const{exportValue:i}=a,s=a.getAttribute("data-element-id");s!==n&&lf.has(a)&&r.push({id:s,exportValue:i,domElement:a})}return r}show(){var e;this.container&&(this.container.hidden=!1),(e=this.popup)==null||e.maybeShow()}hide(){var e;this.container&&(this.container.hidden=!0),(e=this.popup)==null||e.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const n of e)n.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:n}}=this;this.container.addEventListener("dblclick",()=>{var r;(r=this.linkService.eventBus)==null||r.dispatch("switchannotationeditormode",{source:this,mode:e,editId:n,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};tm=new WeakMap,n_=new WeakMap,Xs=new WeakMap,aS=new WeakSet,_6=function(e){const{container:{style:n},data:{rect:r,rotation:a},parent:{viewport:{rawDims:{pageWidth:i,pageHeight:s,pageX:o,pageY:l}}}}=this;r==null||r.splice(0,4,...e),n.left=`${100*(e[0]-o)/i}%`,n.top=`${100*(s-e[3]+l)/s}%`,a===0?(n.width=`${100*(e[2]-e[0])/i}%`,n.height=`${100*(e[3]-e[1])/s}%`):this.setRotation(a)};let wr=GF;class v7e extends wr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.editor=e.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:e}=this;e.hasComment&&(this._createPopup(e.comment),this.extraPopupElement.popup.renderCommentButton())}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(e){this.editor.comment=e,e||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.container.remove(),this.container=null,this.removePopup()}}class SF extends wr{constructor(n,r=null){super(n,{isRenderable:!0,ignoreBorder:!!(r!=null&&r.ignoreBorder),createQuadrilaterals:!0});Y(this,fs);this.isTooltipOnly=n.data.isTooltipOnly}render(){const{data:n,linkService:r}=this,a=document.createElement("a");a.setAttribute("data-element-id",n.id);let i=!1;return n.url?(r.addLinkAttributes(a,n.url,n.newWindow),i=!0):n.action?(this._bindNamedAction(a,n.action,n.overlaidText),i=!0):n.attachment?(K(this,fs,uce).call(this,a,n.attachment,n.overlaidText,n.attachmentDest),i=!0):n.setOCGState?(K(this,fs,dce).call(this,a,n.setOCGState,n.overlaidText),i=!0):n.dest?(this._bindLink(a,n.dest,n.overlaidText),i=!0):(n.actions&&(n.actions.Action||n.actions["Mouse Up"]||n.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(a,n),i=!0),n.resetForm?(this._bindResetFormAction(a,n.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(a,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(a),this.container}_bindLink(n,r,a=""){n.href=this.linkService.getDestinationHash(r),n.onclick=()=>(r&&this.linkService.goToDestination(r),!1),(r||r==="")&&K(this,fs,jm).call(this),a&&(n.title=a)}_bindNamedAction(n,r,a=""){n.href=this.linkService.getAnchorUrl(""),n.onclick=()=>(this.linkService.executeNamedAction(r),!1),a&&(n.title=a),K(this,fs,jm).call(this)}_bindJSAction(n,r){n.href=this.linkService.getAnchorUrl("");const a=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(r.actions)){const s=a.get(i);s&&(n[s]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:r.id,name:i}}),!1})}r.overlaidText&&(n.title=r.overlaidText),n.onclick||(n.onclick=()=>!1),K(this,fs,jm).call(this)}_bindResetFormAction(n,r){const a=n.onclick;if(a||(n.href=this.linkService.getAnchorUrl("")),K(this,fs,jm).call(this),!this._fieldObjects){It('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),a||(n.onclick=()=>!1);return}n.onclick=()=>{var f;a==null||a();const{fields:i,refs:s,include:o}=r,l=[];if(i.length!==0||s.length!==0){const m=new Set(s);for(const g of i){const S=this._fieldObjects[g]||[];for(const{id:E}of S)m.add(E)}for(const g of Object.values(this._fieldObjects))for(const S of g)m.has(S.id)===o&&l.push(S)}else for(const m of Object.values(this._fieldObjects))l.push(...m);const u=this.annotationStorage,p=[];for(const m of l){const{id:g}=m;switch(p.push(g),m.type){case"text":{const E=m.defaultValue||"";u.setValue(g,{value:E});break}case"checkbox":case"radiobutton":{const E=m.defaultValue===m.exportValues;u.setValue(g,{value:E});break}case"combobox":case"listbox":{const E=m.defaultValue||"";u.setValue(g,{value:E});break}default:continue}const S=document.querySelector(`[data-element-id="${g}"]`);if(S){if(!lf.has(S)){It(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;S.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((f=this.linkService.eventBus)==null||f.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:p,name:"ResetForm"}})),!1}}}fs=new WeakSet,jm=function(){this.container.setAttribute("data-internal-link","")},uce=function(n,r,a="",i=null){n.href=this.linkService.getAnchorUrl(""),r.description?n.title=r.description:a&&(n.title=a),n.onclick=()=>{var s;return(s=this.downloadManager)==null||s.openOrDownloadData(r.content,r.filename,i),!1},K(this,fs,jm).call(this)},dce=function(n,r,a=""){n.href=this.linkService.getAnchorUrl(""),n.onclick=()=>(this.linkService.executeSetOCGState(r),!1),a&&(n.title=a),K(this,fs,jm).call(this)};class T7e extends wr{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class cf extends wr{render(){return this.container}showElementAndHideCanvas(e){var n;this.data.hasOwnCanvas&&(((n=e.previousSibling)==null?void 0:n.nodeName)==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return Ea.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,n,r,a,i){r.includes("mouse")?e.addEventListener(r,s=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:i(s),shift:s.shiftKey,modifier:this._getKeyModifier(s)}})}):e.addEventListener(r,s=>{var o;if(r==="blur"){if(!n.focused||!s.relatedTarget)return;n.focused=!1}else if(r==="focus"){if(n.focused)return;n.focused=!0}i&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:i(s)}}))})}_setEventListeners(e,n,r,a){var i,s,o;for(const[l,u]of r)(u==="Action"||(i=this.data.actions)!=null&&i[u])&&((u==="Focus"||u==="Blur")&&(n||(n={focused:!1})),this._setEventListener(e,n,l,u,a),u==="Focus"&&!((s=this.data.actions)!=null&&s.Blur)?this._setEventListener(e,n,"blur","Blur",null):u==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(e,n,"focus","Focus",null))}_setBackgroundColor(e){const n=this.data.backgroundColor||null;e.style.backgroundColor=n===null?"transparent":Je.makeHexColor(n[0],n[1],n[2])}_setTextStyle(e){const n=["left","center","right"],{fontColor:r}=this.data.defaultAppearanceData,a=this.data.defaultAppearanceData.fontSize||S7e,i=e.style;let s;const o=2,l=u=>Math.round(10*u)/10;if(this.data.multiLine){const u=Math.abs(this.data.rect[3]-this.data.rect[1]-o),p=Math.round(u/(H3*a))||1,f=u/p;s=Math.min(a,l(f/H3))}else{const u=Math.abs(this.data.rect[3]-this.data.rect[1]-o);s=Math.min(a,l(u/H3))}i.fontSize=`calc(${s}px * var(--total-scale-factor))`,i.color=Je.makeHexColor(r[0],r[1],r[2]),this.data.textAlignment!==null&&(i.textAlign=n[this.data.textAlignment])}_setRequired(e,n){n?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",n)}}class A7e extends cf{constructor(e){const n=e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue;super(e,{isRenderable:n})}setPropertyOnSiblings(e,n,r,a){const i=this.annotationStorage;for(const s of this._getElementsByName(e.name,e.id))s.domElement&&(s.domElement[n]=r),i.setValue(s.id,{[a]:r})}render(){var a,i;const e=this.annotationStorage,n=this.data.id;this.container.classList.add("textWidgetAnnotation");let r=null;if(this.renderForms){const s=e.getValue(n,{value:this.data.fieldValue});let o=s.value||"";const l=e.getValue(n,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let u=s.formattedValue||((a=this.data.textContent)==null?void 0:a.join(`
624
624
  `))||null;u&&this.data.comb&&(u=u.replaceAll(/\s+/g,""));const p={userValue:o,formattedValue:u,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(r=document.createElement("textarea"),r.textContent=u??o,this.data.doNotScroll&&(r.style.overflowY="hidden")):(r=document.createElement("input"),r.type=this.data.password?"password":"text",r.setAttribute("value",u??o),this.data.doNotScroll&&(r.style.overflowX="hidden")),this.data.hasOwnCanvas&&(r.hidden=!0),lf.add(r),r.setAttribute("data-element-id",n),r.disabled=this.data.readOnly,r.name=this.data.fieldName,r.tabIndex=0;const{datetimeFormat:f,datetimeType:m,timeStep:g}=this.data,S=!!m&&this.enableScripting;f&&(r.title=f),this._setRequired(r,this.data.required),l&&(r.maxLength=l),r.addEventListener("input",y=>{e.setValue(n,{value:y.target.value}),this.setPropertyOnSiblings(r,"value",y.target.value,"value"),p.formattedValue=null}),r.addEventListener("resetform",y=>{const v=this.data.defaultFieldValue??"";r.value=p.userValue=v,p.formattedValue=null});let E=y=>{const{formattedValue:v}=p;v!=null&&(y.target.value=v),y.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){r.addEventListener("focus",v=>{var T;if(p.focused)return;const{target:A}=v;if(S&&(A.type=m,g&&(A.step=g)),p.userValue){const w=p.userValue;if(S)if(m==="time"){const O=new Date(w),R=[O.getHours(),O.getMinutes(),O.getSeconds()];A.value=R.map(I=>I.toString().padStart(2,"0")).join(":")}else A.value=new Date(w-y7e).toISOString().split(m==="date"?"T":".",1)[0];else A.value=w}p.lastCommittedValue=A.value,p.commitKey=1,(T=this.data.actions)!=null&&T.Focus||(p.focused=!0)}),r.addEventListener("updatefromsandbox",v=>{this.showElementAndHideCanvas(v.target);const A={value(T){p.userValue=T.detail.value??"",S||e.setValue(n,{value:p.userValue.toString()}),T.target.value=p.userValue},formattedValue(T){const{formattedValue:w}=T.detail;p.formattedValue=w,w!=null&&T.target!==document.activeElement&&(T.target.value=w);const O={formattedValue:w};S&&(O.value=w),e.setValue(n,O)},selRange(T){T.target.setSelectionRange(...T.detail.selRange)},charLimit:T=>{var I;const{charLimit:w}=T.detail,{target:O}=T;if(w===0){O.removeAttribute("maxLength");return}O.setAttribute("maxLength",w);let R=p.userValue;!R||R.length<=w||(R=R.slice(0,w),O.value=p.userValue=R,e.setValue(n,{value:R}),(I=this.linkService.eventBus)==null||I.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:R,willCommit:!0,commitKey:1,selStart:O.selectionStart,selEnd:O.selectionEnd}}))}};this._dispatchEventFromSandbox(A,v)}),r.addEventListener("keydown",v=>{var w;p.commitKey=1;let A=-1;if(v.key==="Escape"?A=0:v.key==="Enter"&&!this.data.multiLine?A=2:v.key==="Tab"&&(p.commitKey=3),A===-1)return;const{value:T}=v.target;p.lastCommittedValue!==T&&(p.lastCommittedValue=T,p.userValue=T,(w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:T,willCommit:!0,commitKey:A,selStart:v.target.selectionStart,selEnd:v.target.selectionEnd}}))});const y=E;E=null,r.addEventListener("blur",v=>{var w,O;if(!p.focused||!v.relatedTarget)return;(w=this.data.actions)!=null&&w.Blur||(p.focused=!1);const{target:A}=v;let{value:T}=A;if(S){if(T&&m==="time"){const R=T.split(":").map(I=>parseInt(I,10));T=new Date(2e3,0,1,R[0],R[1],R[2]||0).valueOf(),A.step=""}else T.includes("T")||(T=`${T}T00:00`),T=new Date(T).valueOf();A.type="text"}p.userValue=T,p.lastCommittedValue!==T&&((O=this.linkService.eventBus)==null||O.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:T,willCommit:!0,commitKey:p.commitKey,selStart:v.target.selectionStart,selEnd:v.target.selectionEnd}})),y(v)}),(i=this.data.actions)!=null&&i.Keystroke&&r.addEventListener("beforeinput",v=>{var P;p.lastCommittedValue=null;const{data:A,target:T}=v,{value:w,selectionStart:O,selectionEnd:R}=T;let I=O,L=R;switch(v.inputType){case"deleteWordBackward":{const U=w.substring(0,O).match(/\w*[^\w]*$/);U&&(I-=U[0].length);break}case"deleteWordForward":{const U=w.substring(O).match(/^[^\w]*\w*/);U&&(L+=U[0].length);break}case"deleteContentBackward":O===R&&(I-=1);break;case"deleteContentForward":O===R&&(L+=1);break}v.preventDefault(),(P=this.linkService.eventBus)==null||P.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:w,change:A||"",willCommit:!1,selStart:I,selEnd:L}})}),this._setEventListeners(r,p,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],v=>v.target.value)}if(E&&r.addEventListener("blur",E),this.data.comb){const v=(this.data.rect[2]-this.data.rect[0])/l;r.classList.add("comb"),r.style.letterSpacing=`calc(${v}px * var(--total-scale-factor) - 1ch)`}}else r=document.createElement("div"),r.textContent=this.data.fieldValue,r.style.verticalAlign="middle",r.style.display="table-cell",this.data.hasOwnCanvas&&(r.hidden=!0);return this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class C7e extends cf{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class R7e extends cf{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,n=this.data,r=n.id;let a=e.getValue(r,{value:n.exportValue===n.fieldValue}).value;typeof a=="string"&&(a=a!=="Off",e.setValue(r,{value:a})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const i=document.createElement("input");return lf.add(i),i.setAttribute("data-element-id",r),i.disabled=n.readOnly,this._setRequired(i,this.data.required),i.type="checkbox",i.name=n.fieldName,a&&i.setAttribute("checked",!0),i.setAttribute("exportValue",n.exportValue),i.tabIndex=0,i.addEventListener("change",s=>{const{name:o,checked:l}=s.target;for(const u of this._getElementsByName(o,r)){const p=l&&u.exportValue===n.exportValue;u.domElement&&(u.domElement.checked=p),e.setValue(u.id,{value:p})}e.setValue(r,{value:l})}),i.addEventListener("resetform",s=>{const o=n.defaultFieldValue||"Off";s.target.checked=o===n.exportValue}),this.enableScripting&&this.hasJSActions&&(i.addEventListener("updatefromsandbox",s=>{const o={value(l){l.target.checked=l.detail.value!=="Off",e.setValue(r,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,s)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],s=>s.target.checked)),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class _ae extends cf{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,n=this.data,r=n.id;let a=e.getValue(r,{value:n.fieldValue===n.buttonValue}).value;if(typeof a=="string"&&(a=a!==n.buttonValue,e.setValue(r,{value:a})),a)for(const s of this._getElementsByName(n.fieldName,r))e.setValue(s.id,{value:!1});const i=document.createElement("input");if(lf.add(i),i.setAttribute("data-element-id",r),i.disabled=n.readOnly,this._setRequired(i,this.data.required),i.type="radio",i.name=n.fieldName,a&&i.setAttribute("checked",!0),i.tabIndex=0,i.addEventListener("change",s=>{const{name:o,checked:l}=s.target;for(const u of this._getElementsByName(o,r))e.setValue(u.id,{value:!1});e.setValue(r,{value:l})}),i.addEventListener("resetform",s=>{const o=n.defaultFieldValue;s.target.checked=o!=null&&o===n.buttonValue}),this.enableScripting&&this.hasJSActions){const s=n.buttonValue;i.addEventListener("updatefromsandbox",o=>{const l={value:u=>{const p=s===u.detail.value;for(const f of this._getElementsByName(u.target.name)){const m=p&&f.id===r;f.domElement&&(f.domElement.checked=m),e.setValue(f.id,{value:m})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(i,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class N7e extends SF{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const n=e.lastChild;return this.enableScripting&&this.hasJSActions&&n&&(this._setDefaultPropertiesFromJS(n),n.addEventListener("updatefromsandbox",r=>{this._dispatchEventFromSandbox({},r)})),e}}class w7e extends cf{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,n=this.data.id,r=e.getValue(n,{value:this.data.fieldValue}),a=document.createElement("select");lf.add(a),a.setAttribute("data-element-id",n),a.disabled=this.data.readOnly,this._setRequired(a,this.data.required),a.name=this.data.fieldName,a.tabIndex=0;let i=this.data.combo&&this.data.options.length>0;this.data.combo||(a.size=this.data.options.length,this.data.multiSelect&&(a.multiple=!0)),a.addEventListener("resetform",p=>{const f=this.data.defaultFieldValue;for(const m of a.options)m.selected=m.value===f});for(const p of this.data.options){const f=document.createElement("option");f.textContent=p.displayValue,f.value=p.exportValue,r.value.includes(p.exportValue)&&(f.setAttribute("selected",!0),i=!1),a.append(f)}let s=null;if(i){const p=document.createElement("option");p.value=" ",p.setAttribute("hidden",!0),p.setAttribute("selected",!0),a.prepend(p),s=()=>{p.remove(),a.removeEventListener("input",s),s=null},a.addEventListener("input",s)}const o=p=>{const f=p?"value":"textContent",{options:m,multiple:g}=a;return g?Array.prototype.filter.call(m,S=>S.selected).map(S=>S[f]):m.selectedIndex===-1?null:m[m.selectedIndex][f]};let l=o(!1);const u=p=>{const f=p.target.options;return Array.prototype.map.call(f,m=>({displayValue:m.textContent,exportValue:m.value}))};return this.enableScripting&&this.hasJSActions?(a.addEventListener("updatefromsandbox",p=>{const f={value(m){s==null||s();const g=m.detail.value,S=new Set(Array.isArray(g)?g:[g]);for(const E of a.options)E.selected=S.has(E.value);e.setValue(n,{value:o(!0)}),l=o(!1)},multipleSelection(m){a.multiple=!0},remove(m){const g=a.options,S=m.detail.remove;g[S].selected=!1,a.remove(S),g.length>0&&Array.prototype.findIndex.call(g,y=>y.selected)===-1&&(g[0].selected=!0),e.setValue(n,{value:o(!0),items:u(m)}),l=o(!1)},clear(m){for(;a.length!==0;)a.remove(0);e.setValue(n,{value:null,items:[]}),l=o(!1)},insert(m){const{index:g,displayValue:S,exportValue:E}=m.detail.insert,y=a.children[g],v=document.createElement("option");v.textContent=S,v.value=E,y?y.before(v):a.append(v),e.setValue(n,{value:o(!0),items:u(m)}),l=o(!1)},items(m){const{items:g}=m.detail;for(;a.length!==0;)a.remove(0);for(const S of g){const{displayValue:E,exportValue:y}=S,v=document.createElement("option");v.textContent=E,v.value=y,a.append(v)}a.options.length>0&&(a.options[0].selected=!0),e.setValue(n,{value:o(!0),items:u(m)}),l=o(!1)},indices(m){const g=new Set(m.detail.indices);for(const S of m.target.options)S.selected=g.has(S.index);e.setValue(n,{value:o(!0)}),l=o(!1)},editable(m){m.target.disabled=!m.detail.editable}};this._dispatchEventFromSandbox(f,p)}),a.addEventListener("input",p=>{var g;const f=o(!0),m=o(!1);e.setValue(n,{value:f}),p.preventDefault(),(g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:n,name:"Keystroke",value:l,change:m,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(a,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],p=>p.target.value)):a.addEventListener("input",function(p){e.setValue(n,{value:o(!0)})}),this.data.combo&&this._setTextStyle(a),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class yF extends wr{constructor(n){const{data:r,elements:a,parent:i}=n,s=!!i._commentManager;super(n,{isRenderable:!s&&wr._hasPopupData(r)});Y(this,iS);if(this.elements=a,s&&wr._hasPopupData(r)){const o=this.popup=K(this,iS,b6).call(this);for(const l of a)l.popup=o}else this.popup=null}render(){const{container:n}=this;n.classList.add("popupAnnotation"),n.role="comment";const r=this.popup=K(this,iS,b6).call(this),a=[];for(const i of this.elements)i.popup=r,i.container.ariaHasPopup="dialog",a.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",a.map(i=>`${X3}${i}`).join(",")),this.container}}iS=new WeakSet,b6=function(){return new x7e({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})};class x7e{constructor({container:e,color:n,elements:r,titleObj:a,modificationDate:i,contentsObj:s,richText:o,parent:l,rect:u,parentRect:p,open:f,commentManager:m=null}){Y(this,Ht);Y(this,ms,null);Y(this,Bd,K(this,Ht,mce).bind(this));Y(this,oC,K(this,Ht,T6).bind(this));Y(this,lC,K(this,Ht,BR).bind(this));Y(this,r_,K(this,Ht,FR).bind(this));Y(this,a_,null);Y(this,Br,null);Y(this,Pl,null);Y(this,Ud,null);Y(this,nm,null);Y(this,i_,null);Y(this,s_,null);Y(this,Fl,!1);Y(this,hs,null);Y(this,Qc,null);Y(this,Zc,null);Y(this,ya,null);Y(this,Jc,null);Y(this,Gd,null);Y(this,sS,null);Y(this,eu,null);Y(this,o_,null);Y(this,rm,null);Y(this,zd,!1);Y(this,ti,null);Y(this,qd,null);M(this,Br,e),M(this,o_,a),M(this,Pl,s),M(this,eu,o),M(this,i_,l),M(this,a_,n),M(this,sS,u),M(this,s_,p),M(this,nm,r),M(this,ms,m),M(this,ti,r[0]),M(this,Ud,U0.toDateObject(i)),this.trigger=r.flatMap(g=>g.getElementsToTriggerPopup()),m?this.renderCommentButton():(K(this,Ht,LR).call(this),_(this,Br).hidden=!0,f&&K(this,Ht,FR).call(this))}renderCommentButton(){if(_(this,ya)||(_(this,Jc)||K(this,Ht,E6).call(this),!_(this,Jc)))return;const{signal:e}=M(this,Qc,new AbortController),n=!!_(this,ti).extraPopupElement,r=()=>{_(this,ms).toggleCommentPopup(this,!0,void 0,!n)},a=()=>{_(this,ms).toggleCommentPopup(this,!1,!0,!n)},i=()=>{_(this,ms).toggleCommentPopup(this,!1,!1)};if(n){M(this,ya,_(this,ti).container);for(const s of this.trigger)s.ariaHasPopup="dialog",s.ariaControls="commentPopup",s.addEventListener("keydown",_(this,Bd),{signal:e}),s.addEventListener("click",r,{signal:e}),s.addEventListener("pointerenter",a,{signal:e}),s.addEventListener("pointerleave",i,{signal:e}),s.classList.add("popupTriggerArea")}else{const s=M(this,ya,document.createElement("button"));s.className="annotationCommentButton";const o=_(this,ti).container;s.style.zIndex=o.style.zIndex+1,s.tabIndex=0,s.ariaHasPopup="dialog",s.ariaControls="commentPopup",s.setAttribute("data-l10n-id","pdfjs-show-comment-button"),K(this,Ht,y6).call(this),K(this,Ht,S6).call(this),s.addEventListener("keydown",_(this,Bd),{signal:e}),s.addEventListener("click",r,{signal:e}),s.addEventListener("pointerenter",a,{signal:e}),s.addEventListener("pointerleave",i,{signal:e}),o.after(s)}}get commentButtonColor(){const{color:e,opacity:n}=_(this,ti).commentData;return e?_(this,i_)._commentManager.makeCommentColor(e,n):null}focusCommentButton(){setTimeout(()=>{var e;(e=_(this,ya))==null||e.focus()},0)}getData(){const{richText:e,color:n,opacity:r,creationDate:a,modificationDate:i}=_(this,ti).commentData;return{contentsObj:{str:this.comment},richText:e,color:n,opacity:r,creationDate:a,modificationDate:i}}get elementBeforePopup(){return _(this,ya)}get comment(){return _(this,qd)||M(this,qd,_(this,ti).commentText),_(this,qd)}set comment(e){e!==this.comment&&(_(this,ti).commentText=M(this,qd,e))}get parentBoundingClientRect(){return _(this,ti).layer.getBoundingClientRect()}setCommentButtonStates({selected:e,hasPopup:n}){_(this,ya)&&(_(this,ya).classList.toggle("selected",e),_(this,ya).ariaExpanded=n)}setSelectedCommentButton(e){_(this,ya).classList.toggle("selected",e)}get commentPopupPosition(){if(_(this,Gd))return _(this,Gd);const{x:e,y:n,height:r}=_(this,ya).getBoundingClientRect(),{x:a,y:i,width:s,height:o}=_(this,ti).layer.getBoundingClientRect();return[(e-a)/s,(n+r-i)/o]}set commentPopupPosition(e){M(this,Gd,e)}hasDefaultPopupPosition(){return _(this,Gd)===null}get commentButtonPosition(){return _(this,Jc)}get commentButtonWidth(){return _(this,ya).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(e){const[n,r]=_(this,Gd)||this.commentButtonPosition.map(u=>u/100),a=this.parentBoundingClientRect,{x:i,y:s,width:o,height:l}=a;_(this,ms).showDialog(null,this,i+n*o,s+r*l,{...e,parentDimensions:a})}render(){var r,a;if(_(this,hs))return;const e=M(this,hs,document.createElement("div"));if(e.className="popup",_(this,a_)){const i=e.style.outlineColor=Je.makeHexColor(..._(this,a_));e.style.backgroundColor=`color-mix(in srgb, ${i} 30%, white)`}const n=document.createElement("span");if(n.className="header",(r=_(this,o_))!=null&&r.str){const i=document.createElement("span");i.className="title",n.append(i),{dir:i.dir,str:i.textContent}=_(this,o_)}if(e.append(n),_(this,Ud)){const i=document.createElement("time");i.className="popupDate",i.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),i.setAttribute("data-l10n-args",JSON.stringify({dateObj:_(this,Ud).valueOf()})),i.dateTime=_(this,Ud).toISOString(),n.append(i)}J3({html:_(this,Ht,PR)||_(this,Pl).str,dir:(a=_(this,Pl))==null?void 0:a.dir,className:"popupContent"},e),_(this,Br).append(e)}updateEdited({rect:e,popup:n,deleted:r}){var a;if(_(this,ms)){r?(this.remove(),M(this,qd,null)):n&&(n.deleted?this.remove():(K(this,Ht,y6).call(this),M(this,qd,n.text))),e&&(M(this,Jc,null),K(this,Ht,E6).call(this),K(this,Ht,S6).call(this));return}if(r||n!=null&&n.deleted){this.remove();return}K(this,Ht,LR).call(this),_(this,rm)||M(this,rm,{contentsObj:_(this,Pl),richText:_(this,eu)}),e&&M(this,Zc,null),n&&n.text&&(M(this,eu,K(this,Ht,fce).call(this,n.text)),M(this,Ud,U0.toDateObject(n.date)),M(this,Pl,null)),(a=_(this,hs))==null||a.remove(),M(this,hs,null)}resetEdited(){var e;_(this,rm)&&({contentsObj:_a(this,Pl)._,richText:_a(this,eu)._}=_(this,rm),M(this,rm,null),(e=_(this,hs))==null||e.remove(),M(this,hs,null),M(this,Zc,null))}remove(){var e,n,r;if((e=_(this,Qc))==null||e.abort(),M(this,Qc,null),(n=_(this,hs))==null||n.remove(),M(this,hs,null),M(this,zd,!1),M(this,Fl,!1),(r=_(this,ya))==null||r.remove(),M(this,ya,null),this.trigger)for(const a of this.trigger)a.classList.remove("popupTriggerArea")}forceHide(){M(this,zd,this.isVisible),_(this,zd)&&(_(this,Br).hidden=!0)}maybeShow(){_(this,ms)||(K(this,Ht,LR).call(this),_(this,zd)&&(_(this,hs)||K(this,Ht,BR).call(this),M(this,zd,!1),_(this,Br).hidden=!1))}get isVisible(){return _(this,ms)?!1:_(this,Br).hidden===!1}}ms=new WeakMap,Bd=new WeakMap,oC=new WeakMap,lC=new WeakMap,r_=new WeakMap,a_=new WeakMap,Br=new WeakMap,Pl=new WeakMap,Ud=new WeakMap,nm=new WeakMap,i_=new WeakMap,s_=new WeakMap,Fl=new WeakMap,hs=new WeakMap,Qc=new WeakMap,Zc=new WeakMap,ya=new WeakMap,Jc=new WeakMap,Gd=new WeakMap,sS=new WeakMap,eu=new WeakMap,o_=new WeakMap,rm=new WeakMap,zd=new WeakMap,ti=new WeakMap,qd=new WeakMap,Ht=new WeakSet,LR=function(){var n;if(_(this,Qc))return;M(this,Qc,new AbortController);const{signal:e}=_(this,Qc);for(const r of this.trigger)r.addEventListener("click",_(this,r_),{signal:e}),r.addEventListener("pointerenter",_(this,lC),{signal:e}),r.addEventListener("pointerleave",_(this,oC),{signal:e}),r.classList.add("popupTriggerArea");for(const r of _(this,nm))(n=r.container)==null||n.addEventListener("keydown",_(this,Bd),{signal:e})},E6=function(){const e=_(this,nm).find(n=>n.hasCommentButton);e&&M(this,Jc,e._normalizePoint(e.commentButtonPosition))},S6=function(){if(_(this,ti).extraPopupElement&&!_(this,ti).editor)return;this.renderCommentButton();const[e,n]=_(this,Jc),{style:r}=_(this,ya);r.left=`calc(${e}%)`,r.top=`calc(${n}% - var(--comment-button-dim))`},y6=function(){_(this,ti).extraPopupElement||(this.renderCommentButton(),_(this,ya).style.backgroundColor=this.commentButtonColor||"")},PR=function(){const e=_(this,eu),n=_(this,Pl);return e!=null&&e.str&&(!(n!=null&&n.str)||n.str===e.str)&&_(this,eu).html||null},v6=function(){var e,n,r;return((r=(n=(e=_(this,Ht,PR))==null?void 0:e.attributes)==null?void 0:n.style)==null?void 0:r.fontSize)||0},pce=function(){var e,n,r;return((r=(n=(e=_(this,Ht,PR))==null?void 0:e.attributes)==null?void 0:n.style)==null?void 0:r.color)||null},fce=function(e){const n=[],r={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:n}]}},a={style:{color:_(this,Ht,pce),fontSize:_(this,Ht,v6)?`calc(${_(this,Ht,v6)}px * var(--total-scale-factor))`:""}};for(const i of e.split(`
625
625
  `))n.push({name:"span",value:i,attributes:a});return r},mce=function(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||(e.key==="Enter"||e.key==="Escape"&&_(this,Fl))&&K(this,Ht,FR).call(this)},hce=function(){if(_(this,Zc)!==null)return;const{page:{view:e},viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:i}}}=_(this,i_);let s=!!_(this,s_),o=s?_(this,s_):_(this,sS);for(const S of _(this,nm))if(!o||Je.intersect(S.data.rect,o)!==null){o=S.data.rect,s=!0;break}const l=Je.normalizeRect([o[0],e[3]-o[1]+e[1],o[2],e[3]-o[3]+e[1]]),p=s?o[2]-o[0]+5:0,f=l[0]+p,m=l[1];M(this,Zc,[100*(f-a)/n,100*(m-i)/r]);const{style:g}=_(this,Br);g.left=`${_(this,Zc)[0]}%`,g.top=`${_(this,Zc)[1]}%`},FR=function(){if(_(this,ms)){_(this,ms).toggleCommentPopup(this,!1);return}M(this,Fl,!_(this,Fl)),_(this,Fl)?(K(this,Ht,BR).call(this),_(this,Br).addEventListener("click",_(this,r_)),_(this,Br).addEventListener("keydown",_(this,Bd))):(K(this,Ht,T6).call(this),_(this,Br).removeEventListener("click",_(this,r_)),_(this,Br).removeEventListener("keydown",_(this,Bd)))},BR=function(){_(this,hs)||this.render(),this.isVisible?_(this,Fl)&&_(this,Br).classList.add("focused"):(K(this,Ht,hce).call(this),_(this,Br).hidden=!1,_(this,Br).style.zIndex=parseInt(_(this,Br).style.zIndex)+1e3)},T6=function(){_(this,Br).classList.remove("focused"),!(_(this,Fl)||!this.isVisible)&&(_(this,Br).hidden=!0,_(this,Br).style.zIndex=parseInt(_(this,Br).style.zIndex)-1e3)};class bae extends wr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=Ot.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(const n of this.textContent){const r=document.createElement("span");r.textContent=n,e.append(r)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class O7e extends wr{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});Y(this,oS,null)}render(){this.container.classList.add("lineAnnotation");const{data:n,width:r,height:a}=this,i=this.svgFactory.create(r,a,!0),s=M(this,oS,this.svgFactory.createElement("svg:line"));return s.setAttribute("x1",n.rect[2]-n.lineCoordinates[0]),s.setAttribute("y1",n.rect[3]-n.lineCoordinates[1]),s.setAttribute("x2",n.rect[2]-n.lineCoordinates[2]),s.setAttribute("y2",n.rect[3]-n.lineCoordinates[3]),s.setAttribute("stroke-width",n.borderStyle.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),i.append(s),this.container.append(i),!n.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,oS)}addHighlightArea(){this.container.classList.add("highlightArea")}}oS=new WeakMap;class I7e extends wr{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});Y(this,lS,null)}render(){this.container.classList.add("squareAnnotation");const{data:n,width:r,height:a}=this,i=this.svgFactory.create(r,a,!0),s=n.borderStyle.width,o=M(this,lS,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",s/2),o.setAttribute("y",s/2),o.setAttribute("width",r-s),o.setAttribute("height",a-s),o.setAttribute("stroke-width",s||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!n.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,lS)}addHighlightArea(){this.container.classList.add("highlightArea")}}lS=new WeakMap;class D7e extends wr{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});Y(this,cS,null)}render(){this.container.classList.add("circleAnnotation");const{data:n,width:r,height:a}=this,i=this.svgFactory.create(r,a,!0),s=n.borderStyle.width,o=M(this,cS,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",r/2),o.setAttribute("cy",a/2),o.setAttribute("rx",r/2-s/2),o.setAttribute("ry",a/2-s/2),o.setAttribute("stroke-width",s||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),i.append(o),this.container.append(i),!n.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,cS)}addHighlightArea(){this.container.classList.add("highlightArea")}}cS=new WeakMap;class Eae extends wr{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});Y(this,uS,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:n,vertices:r,borderStyle:a,popupRef:i},width:s,height:o}=this;if(!r)return this.container;const l=this.svgFactory.create(s,o,!0);let u=[];for(let f=0,m=r.length;f<m;f+=2){const g=r[f]-n[0],S=n[3]-r[f+1];u.push(`${g},${S}`)}u=u.join(" ");const p=M(this,uS,this.svgFactory.createElement(this.svgElementName));return p.setAttribute("points",u),p.setAttribute("stroke-width",a.width||1),p.setAttribute("stroke","transparent"),p.setAttribute("fill","transparent"),l.append(p),this.container.append(l),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return _(this,uS)}addHighlightArea(){this.container.classList.add("highlightArea")}}uS=new WeakMap;class k7e extends Eae{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class M7e extends wr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class vF extends wr{constructor(n){super(n,{isRenderable:!0,ignoreBorder:!0});Y(this,pS);Y(this,dS,null);Y(this,am,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?Ot.HIGHLIGHT:Ot.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:n,rotation:r,inkLists:a,borderStyle:i,popupRef:s}}=this,{transform:o,width:l,height:u}=K(this,pS,A6).call(this,r,n),p=this.svgFactory.create(l,u,!0),f=M(this,dS,this.svgFactory.createElement("svg:g"));p.append(f),f.setAttribute("stroke-width",i.width||1),f.setAttribute("stroke-linecap","round"),f.setAttribute("stroke-linejoin","round"),f.setAttribute("stroke-miterlimit",10),f.setAttribute("stroke","transparent"),f.setAttribute("fill","transparent"),f.setAttribute("transform",o);for(let m=0,g=a.length;m<g;m++){const S=this.svgFactory.createElement(this.svgElementName);_(this,am).push(S),S.setAttribute("points",a[m].join(",")),f.append(S)}return!s&&this.hasPopupData&&this._createPopup(),this.container.append(p),this._editOnDoubleClick(),this.container}updateEdited(n){super.updateEdited(n);const{thickness:r,points:a,rect:i}=n,s=_(this,dS);if(r>=0&&s.setAttribute("stroke-width",r||1),a)for(let o=0,l=_(this,am).length;o<l;o++)_(this,am)[o].setAttribute("points",a[o].join(","));if(i){const{transform:o,width:l,height:u}=K(this,pS,A6).call(this,this.data.rotation,i);s.parentElement.setAttribute("viewBox",`0 0 ${l} ${u}`),s.setAttribute("transform",o)}}getElementsToTriggerPopup(){return _(this,am)}addHighlightArea(){this.container.classList.add("highlightArea")}}dS=new WeakMap,am=new WeakMap,pS=new WeakSet,A6=function(n,r){switch(n){case 90:return{transform:`rotate(90) translate(${-r[0]},${r[1]}) scale(1,-1)`,width:r[3]-r[1],height:r[2]-r[0]};case 180:return{transform:`rotate(180) translate(${-r[2]},${r[1]}) scale(1,-1)`,width:r[2]-r[0],height:r[3]-r[1]};case 270:return{transform:`rotate(270) translate(${-r[2]},${r[3]}) scale(1,-1)`,width:r[3]-r[1],height:r[2]-r[0]};default:return{transform:`translate(${-r[0]},${r[3]}) scale(1,-1)`,width:r[2]-r[0],height:r[3]-r[1]}}};class Sae extends wr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Ot.HIGHLIGHT}render(){const{data:{overlaidText:e,popupRef:n}}=this;if(!n&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),e){const r=document.createElement("mark");r.classList.add("overlaidText"),r.textContent=e,this.container.append(r)}return this.container}}class L7e extends wr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:n}}=this;if(!n&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),e){const r=document.createElement("u");r.classList.add("overlaidText"),r.textContent=e,this.container.append(r)}return this.container}}class P7e extends wr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:n}}=this;if(!n&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),e){const r=document.createElement("u");r.classList.add("overlaidText"),r.textContent=e,this.container.append(r)}return this.container}}class F7e extends wr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:n}}=this;if(!n&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),e){const r=document.createElement("s");r.classList.add("overlaidText"),r.textContent=e,this.container.append(r)}return this.container}}class yae extends wr{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Ot.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class B7e extends wr{constructor(n){var a;super(n,{isRenderable:!0});Y(this,mS);Y(this,fS,null);const{file:r}=this.data;this.filename=r.filename,this.content=r.content,(a=this.linkService.eventBus)==null||a.dispatch("fileattachmentannotation",{source:this,...r})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:n,data:r}=this;let a;r.hasAppearance||r.fillAlpha===0?a=document.createElement("div"):(a=document.createElement("img"),a.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(r.name)?"paperclip":"pushpin"}.svg`,r.fillAlpha&&r.fillAlpha<1&&(a.style=`filter: opacity(${Math.round(r.fillAlpha*100)}%);`)),a.addEventListener("dblclick",K(this,mS,C6).bind(this)),M(this,fS,a);const{isMac:i}=Ea.platform;return n.addEventListener("keydown",s=>{s.key==="Enter"&&(i?s.metaKey:s.ctrlKey)&&K(this,mS,C6).call(this)}),!r.popupRef&&this.hasPopupData?this._createPopup():a.classList.add("popupTriggerArea"),n.append(a),n}getElementsToTriggerPopup(){return _(this,fS)}addHighlightArea(){this.container.classList.add("highlightArea")}}fS=new WeakMap,mS=new WeakSet,C6=function(){var n;(n=this.downloadManager)==null||n.openOrDownloadData(this.content,this.filename)};let TF=(u_=class{constructor({div:e,accessibilityManager:n,annotationCanvasMap:r,annotationEditorUIManager:a,page:i,viewport:s,structTreeLayer:o,commentManager:l,linkService:u,annotationStorage:p}){Y(this,$d);Y(this,l_,null);Y(this,im,null);Y(this,c_,null);Y(this,Hd,new Map);Y(this,hS,null);Y(this,sm,null);this.div=e,M(this,l_,n),M(this,im,r),M(this,hS,o||null),M(this,sm,u||null),M(this,c_,p||new aF),this.page=i,this.viewport=s,this.zIndex=0,this._annotationEditorUIManager=a,this._commentManager=l||null}hasEditableAnnotations(){return _(this,Hd).size>0}async render(e){var s,o,l;const{annotations:n}=e,r=this.div;od(r,this.viewport);const a=new Map,i={data:null,layer:r,linkService:_(this,sm),downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:e.renderForms!==!1,svgFactory:new X0,annotationStorage:_(this,c_),enableComment:e.enableComment===!0,enableScripting:e.enableScripting===!0,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const u of n){if(u.noHTML)continue;const p=u.annotationType===Yr.POPUP;if(p){const g=a.get(u.id);if(!g)continue;i.elements=g}else if(u.rect[2]===u.rect[0]||u.rect[3]===u.rect[1])continue;i.data=u;const f=gae.create(i);if(!f.isRenderable)continue;if(!p&&u.popupRef){const g=a.get(u.popupRef);g?g.push(f):a.set(u.popupRef,[f])}const m=f.render();u.hidden&&(m.style.visibility="hidden"),await K(this,$d,R6).call(this,m,u.id,i.elements),(o=(s=f.extraPopupElement)==null?void 0:s.popup)==null||o.renderCommentButton(),f._isEditable&&(_(this,Hd).set(f.data.id,f),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(f))}K(this,$d,N6).call(this)}async addLinkAnnotations(e){const n={data:null,layer:this.div,linkService:_(this,sm),svgFactory:new X0,parent:this};for(const r of e){r.borderStyle||(r.borderStyle=u_._defaultBorderStyle),n.data=r;const a=gae.create(n);if(!a.isRenderable)continue;const i=a.render();await K(this,$d,R6).call(this,i,r.id,null)}}update({viewport:e}){const n=this.div;this.viewport=e,od(n,{rotation:e.rotation}),K(this,$d,N6).call(this),n.hidden=!1}getEditableAnnotations(){return Array.from(_(this,Hd).values())}getEditableAnnotation(e){return _(this,Hd).get(e)}addFakeAnnotation(e){var o;const{div:n}=this,{id:r,rotation:a}=e,i=new v7e({data:{id:r,rect:e.getPDFRect(),rotation:a},editor:e,layer:n,parent:this,enableComment:!!this._commentManager,linkService:_(this,sm),annotationStorage:_(this,c_)}),s=i.render();return n.append(s),(o=_(this,l_))==null||o.moveElementInDOM(n,s,s,!1),i.createOrUpdatePopup(),i}static get _defaultBorderStyle(){return qt(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Yh.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},l_=new WeakMap,im=new WeakMap,c_=new WeakMap,Hd=new WeakMap,hS=new WeakMap,sm=new WeakMap,$d=new WeakSet,R6=async function(e,n,r){var o,l;const a=e.firstChild||e,i=a.id=`${X3}${n}`,s=await((o=_(this,hS))==null?void 0:o.getAriaAttributes(i));if(s)for(const[u,p]of s)a.setAttribute(u,p);r?r.at(-1).container.after(e):(this.div.append(e),(l=_(this,l_))==null||l.moveElementInDOM(this.div,e,a,!1))},N6=function(){var n;if(!_(this,im))return;const e=this.div;for(const[r,a]of _(this,im)){const i=e.querySelector(`[data-annotation-id="${r}"]`);if(!i)continue;a.className="annotationContent";const{firstChild:s}=i;s?s.nodeName==="CANVAS"?s.replaceWith(a):s.classList.contains("annotationContent")?s.after(a):s.before(a):i.append(a);const o=_(this,Hd).get(r);o&&(o._hasNoCanvas?((n=this._annotationEditorUIManager)==null||n.setMissingCanvas(r,i.id,a),o._hasNoCanvas=!1):o.canvas=a)}_(this,im).clear()},u_);const BA=/\r\n?|\n/g,dr=class dr extends or{constructor(n){super({...n,name:"freeTextEditor"});Y(this,ta);Y(this,gs,"");Y(this,gS,`${this.id}-editor`);Y(this,om,null);Y(this,_s);Pe(this,"_colorPicker",null);this.color=n.color||dr._defaultColor||or._defaultLineColor,M(this,_s,n.fontSize||dr._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const n=dr.prototype,r=s=>s.isEmpty(),a=ld.TRANSLATE_SMALL,i=ld.TRANSLATE_BIG;return qt(this,"_keyboardManager",new G0([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],n.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],n.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],n._translateEmpty,{args:[-a,0],checker:r}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],n._translateEmpty,{args:[-i,0],checker:r}],[["ArrowRight","mac+ArrowRight"],n._translateEmpty,{args:[a,0],checker:r}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],n._translateEmpty,{args:[i,0],checker:r}],[["ArrowUp","mac+ArrowUp"],n._translateEmpty,{args:[0,-a],checker:r}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],n._translateEmpty,{args:[0,-i],checker:r}],[["ArrowDown","mac+ArrowDown"],n._translateEmpty,{args:[0,a],checker:r}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],n._translateEmpty,{args:[0,i],checker:r}]]))}static initialize(n,r){or.initialize(n,r);const a=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(a.getPropertyValue("--freetext-padding"))}static updateDefaultParams(n,r){switch(n){case rn.FREETEXT_SIZE:dr._defaultFontSize=r;break;case rn.FREETEXT_COLOR:dr._defaultColor=r;break}}updateParams(n,r){switch(n){case rn.FREETEXT_SIZE:K(this,ta,gce).call(this,r);break;case rn.FREETEXT_COLOR:K(this,ta,_ce).call(this,r);break}}static get defaultPropertiesToUpdate(){return[[rn.FREETEXT_SIZE,dr._defaultFontSize],[rn.FREETEXT_COLOR,dr._defaultColor||or._defaultLineColor]]}get propertiesToUpdate(){return[[rn.FREETEXT_SIZE,_(this,_s)],[rn.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new FA(this)),[["colorPicker",this._colorPicker]]}get colorType(){return rn.FREETEXT_COLOR}onUpdatedColor(){var n;this.editorDiv.style.color=this.color,(n=this._colorPicker)==null||n.update(this.color),super.onUpdatedColor()}_translateEmpty(n,r){this._uiManager.translateSelectedEditors(n,r,!0)}getInitialTranslation(){const n=this.parentScale;return[-dr._internalPadding*n,-(dr._internalPadding+_(this,_s))*n]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),M(this,om,new AbortController);const n=this._uiManager.combinedSignal(_(this,om));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:n}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:n}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:n}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:n}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:n}),!0}disableEditMode(){var n;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",_(this,gS)),this._isDraggable=!0,(n=_(this,om))==null||n.abort(),M(this,om,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(n){this._focusEventsAllowed&&(super.focusin(n),n.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(n){var r;this.width||(this.enableEditMode(),n&&this.editorDiv.focus(),(r=this._initialOptions)!=null&&r.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const n=_(this,gs),r=M(this,gs,K(this,ta,bce).call(this).trimEnd());if(n===r)return;const a=i=>{if(M(this,gs,i),!i){this.remove();return}K(this,ta,zR).call(this),this._uiManager.rebuild(this),K(this,ta,UR).call(this)};this.addCommands({cmd:()=>{a(r)},undo:()=>{a(n)},mustExec:!1}),K(this,ta,UR).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(n){n.target===this.div&&n.key==="Enter"&&(this.enterInEditMode(),n.preventDefault())}editorDivKeydown(n){dr._keyboardManager.exec(this,n)}editorDivFocus(n){this.isEditing=!0}editorDivBlur(n){this.isEditing=!1}editorDivInput(n){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let n,r;(this._isCopy||this.annotationElementId)&&(n=this.x,r=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",_(this,gS)),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:a}=this.editorDiv;if(a.fontSize=`calc(${_(this,_s)}px * var(--total-scale-factor))`,a.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,u]=this.getInitialTranslation();[l,u]=this.pageTranslationToScreen(l,u);const[p,f]=this.pageDimensions,[m,g]=this.pageTranslation;let S,E;switch(this.rotation){case 0:S=n+(o[0]-m)/p,E=r+this.height-(o[1]-g)/f;break;case 90:S=n+(o[0]-m)/p,E=r-(o[1]-g)/f,[l,u]=[u,-l];break;case 180:S=n-this.width+(o[0]-m)/p,E=r-(o[1]-g)/f,[l,u]=[-l,-u];break;case 270:S=n+(o[0]-m-this.height*f)/p,E=r+(o[1]-g-this.width*p)/f,[l,u]=[-u,l];break}this.setAt(S*i,E*s,l,u)}else this._moveAfterPaste(n,r);K(this,ta,zR).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(n){var S,E,y;const r=n.clipboardData||window.clipboardData,{types:a}=r;if(a.length===1&&a[0]==="text/plain")return;n.preventDefault();const i=K(S=dr,tu,w6).call(S,r.getData("text")||"").replaceAll(BA,`
626
626
  `);if(!i)return;const s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize(),s.deleteFromDocument();const o=s.getRangeAt(0);if(!i.includes(`