1/*! For license information please see 737.88b155a0.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkseekjob=self.webpackChunkseekjob||[]).push([[737],{645:(t,e,i)=>{function s(t){var e=!1;return{promise:new Promise((function(i,s){t.then((function(t){return!e&&i(t)})).catch((function(t){return!e&&s(t)}))})),cancel:function(){e=!0}}}i.d(e,{A:()=>s})},665:(t,e,i)=>{i.d(e,{Bd:()=>a,UT:()=>b,ci:()=>o,h1:()=>v,jA:()=>d,mZ:()=>u,mw:()=>l,qC:()=>g,qf:()=>h,vS:()=>f,xL:()=>m,zL:()=>c});var s=i(3404),n=i(6440);const a="undefined"!==typeof window,r=a&&"file:"===window.location.protocol;function o(t){return function(t){return"undefined"!==typeof t}(t)&&null!==t}function l(t){return t instanceof ArrayBuffer}function h(t){return(0,s.A)(a,"isBlob can only be used in a browser environment"),t instanceof Blob}function c(t){return function(t){return"string"===typeof t}(t)&&/^data:/.test(t)}function d(t){(0,s.A)(c(t),"Invalid data URI.");const[e="",i=""]=t.split(",");return-1!==e.split(";").indexOf("base64")?atob(i):unescape(i)}function u(){return a&&window.devicePixelRatio||1}const p="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function g(){n(!r,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${p}`)}function m(t){(null===t||void 0===t?void 0:t.cancel)&&t.cancel()}function f(t,e){return Object.defineProperty(t,"width",{get(){return this.view[2]*e},configurable:!0}),Object.defineProperty(t,"height",{get(){return this.view[3]*e},configurable:!0}),Object.defineProperty(t,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(t,"originalHeight",{get(){return this.view[3]},configurable:!0}),t}
2function b(t){return"RenderingCancelledException"===t.name}function v(t){return new Promise(((e,i)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return i(new Error("Error while reading a file."));e(s.result)},s.onerror=t=>{if(!t.target)return i(new Error("Error while reading a file."));const{error:e}=t.target;if(!e)return i(new Error("Error while reading a file."));switch(e.code){case e.NOT_FOUND_ERR:return i(new Error("Error while reading a file: File not found."));case e.SECURITY_ERR:return i(new Error("Error while reading a file: Security error."));case e.ABORT_ERR:return i(new Error("Error while reading a file: Aborted."));default:return i(new Error("Error while reading a file."))}},s.readAsArrayBuffer(t)}))}},1975:()=>{},3404:(t,e,i)=>{i.d(e,{A:()=>a});var s=!0,n="Invariant failed";function a(t,e){if(!t){if(s)throw new Error(n);var i="function"===typeof e?e():e,a=i?"".concat(n,": ").concat(i):n;throw new Error(a)}}},5425:(t,e,i)=>{i.d(e,{A:()=>E});var s=i(579),n=i(5043),a=i(7906),r=i(645),o=i(8387),l=i(3404),h=i(6440),c=Object.prototype.hasOwnProperty;function d(t,e,i){for(i of t.keys())if(u(i,e))return i}function u(t,e){var i,s,n;if(t===e)return!0;if(t&&e&&(i=t.constructor)===e.constructor){if(i===Date)return t.getTime()===e.getTime();if(i===RegExp)return t.toString()===e.toString();if(i===Array){if((s=t.length)===e.length)for(;s--&&u(t[s],e[s]););return-1===s}if(i===Set){if(t.size!==e.size)return!1;for(s of t){if((n=s)&&"object"===typeof n&&!(n=d(e,n)))return!1;if(!e.has(n))return!1}return!0}if(i===Map){if(t.size!==e.size)return!1;for(s of t){if((n=s[0])&&"object"===typeof n&&!(n=d(e,n)))return!1;if(!u(s[1],e.get(n)))return!1}return!0}if(i===ArrayBuffer)t=new Uint8Array(t),e=new Uint8Array(e);else if(i===DataView){if((s=t.byteLength)===e.byteLength)for(;s--&&t.getInt8(s)===e.getInt8(s););return-1===s}if(ArrayBuffer.isView(t)){if((s=t.byteLength)===e.byteLength)for(;s--&&t[s]===e[s];);return-1===s}if(!i||"object"===typeof t){for(i in s=0,t){if(c.call(t,i)&&++s&&!c.call(e,i))return!1;if(!(i in e)||!u(t[i],e[i]))return!1}return Object.keys(e).length===s}}return t!==t&&e!==e}var p=i(9355),g=i(6512),m=i(8599);class f{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(t){this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setExternalLinkRel(t){this.externalLinkRel=t}setExternalLinkTarget(t){this.externalLinkTarget=t}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return(0,l.A)(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber||0}set page(t){(0,l.A)(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber=t}get rotation(){return 0}set rotation(t){}goToDestination(t){return new Promise((e=>{(0,l.A)(this.pdfDocument,"PDF document not loaded."),(0,l.A)(t,"Destination is not specified."),"string"===typeof t?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)})).then((t=>{(0,l.A)(Array.isArray(t),`"${t}" is not a valid destination array.`);const e=t[0];new Promise((t=>{(0,l.A)(this.pdfDocument,"PDF document not loaded."),e instanceof Object?this.pdfDocument.getPageIndex(e).then((e=>{t(e)})).catch((()=>{(0,l.A)(!1,`"${e}" is not a valid page reference.`)})):"number"===typeof e?t(e):(0,l.A)(!1,`"${e}" is not a valid destination reference.`)})).then((e=>{const i=e+1;(0,l.A)(this.pdfViewer,"PDF viewer is not initialized."),(0,l.A)(i>=1&&i<=this.pagesCount,`"${i}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({dest:t,pageIndex:e,pageNumber:i})}))}))}navigateTo(t){this.goToDestination(t)}goToPage(t){const e=t-1;(0,l.A)(this.pdfViewer,"PDF viewer is not initialized."),(0,l.A)(t>=1&&t<=this.pagesCount,`"${t}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}addLinkAttributes(t,e,i){t.href=e,t.rel=this.externalLinkRel||"noopener noreferrer nofollow",t.target=i?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const b={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};
2var v=i(665),A=i(8234),y=function(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{l(s.next(t))}catch(e){a(e)}}function o(t){try{l(s.throw(t))}catch(e){a(e)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}l((s=s.apply(t,e||[])).next())}))},w=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"===typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]])}return i};const{Tm:x}=p,_=(t,e)=>{switch(e){case b.NEED_PASSWORD:t(prompt("Enter the password to open this PDF file."));break;case b.INCORRECT_PASSWORD:t(prompt("Invalid password. Please try again."));break}};function C(t){return"object"===typeof t&&null!==t&&("data"in t||"range"in t||"url"in t)}const E=(0,n.forwardRef)((function(t,e){var{children:i,className:c,error:d="Failed to load PDF file.",externalLinkRel:b,externalLinkTarget:E,file:S,inputRef:T,imageResourcesPath:M,loading:k="Loading PDF\u2026",noData:R="No PDF file specified.",onItemClick:P,onLoadError:I,onLoadProgress:L,onLoadSuccess:D,onPassword:F=_,onSourceError:N,onSourceSuccess:O,options:B,renderMode:z,rotate:H}=t,j=w(t,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[U,$]=(0,A.A)(),{value:G,error:V}=U,[W,q]=(0,A.A)(),{value:X,error:K}=W,Y=(0,n.useRef)(new f),Q=(0,n.useRef)([]),J=(0,n.useRef)(void 0),Z=(0,n.useRef)(void 0);S&&S!==J.current&&C(S)&&(h(!u(S,J.current),'File prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.'),J.current=S),B&&B!==Z.current&&(h(!u(B,Z.current),'Options prop passed to <Document /> changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.'),Z.current=B);const tt=(0,n.useRef)({scrollPageIntoView:t=>{const{dest:e,pageNumber:i,pageIndex:s=i-1}=t;if(P)return void P({dest:e,pageIndex:s,pageNumber:i});const n=Q.current[s];n?n.scrollIntoView():h(!1,`An internal link leading to page ${i} was clicked, but neither <Document> was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to <Document> and handle navigating by yourself or ensure that all pages are rendered within <Document>.`)}});(0,n.useImperativeHandle)(e,(()=>({linkService:Y,pages:Q,viewer:tt})),[]),(0,n.useEffect)((function(){$({type:"RESET"})}),[S,$]);const et=(0,n.useCallback)((()=>y(this,void 0,void 0,(function*(){if(!S)return null;if("string"===typeof S){if((0,v.zL)(S)){return{data:(0,v.jA)(S)}}return(0,v.qC)(),{url:S}}if(S instanceof x)return{range:S};if((0,v.mw)(S))return{data:S};if(v.Bd&&(0,v.qf)(S)){return{data:yield(0,v.h1)(S)}}if((0,l.A)("object"===typeof S,"Invalid parameter in file, need either Uint8Array, string or a parameter object"),(0,l.A)(C(S),"Invalid parameter object: need either .data, .range or .url"),"url"in S&&"string"===typeof S.url){if((0,v.zL)(S.url)){const{url:t}=S,e=w(S,["url"]),i=(0,v.jA)(t);return Object.assign({data:i},e)}(0,v.qC)()}return S}))),[S]);(0,n.useEffect)((()=>{const t=(0,r.A)(et());return t.promise.then((t=>{$({type:"RESOLVE",value:t})})).catch((t=>{$({type:"REJECT",error:t})})),()=>{(0,v.xL)(t)}}),[et,$]),(0,n.useEffect)((()=>{"undefined"!==typeof G&&(!1!==G?O&&O():V&&(h(!1,V.toString()),N&&N(V)))}),[G]),(0,n.useEffect)((function(){q({type:"RESET"})}),[q,G]),(0,n.useEffect)((function(){if(!G)return;const t=B?Object.assign(Object.assign({},G),B):G,e=p.YE(t);L&&(e.onProgress=L),F&&(e.onPassword=F);const i=e,s=i.promise.then((t=>{q({type:"RESOLVE",value:t})})).catch((t=>{i.destroyed||q({type:"REJECT",error:t})}));return()=>{s.finally((()=>i.destroy()))}}),[B,q,G]),(0,n.useEffect)((()=>
2{"undefined"!==typeof X&&(!1!==X?X&&(D&&D(X),Q.current=new Array(X.numPages),Y.current.setDocument(X)):K&&(h(!1,K.toString()),I&&I(K)))}),[X]),(0,n.useEffect)((function(){Y.current.setViewer(tt.current),Y.current.setExternalLinkRel(b),Y.current.setExternalLinkTarget(E)}),[b,E]);const it=(0,n.useCallback)(((t,e)=>{Q.current[t]=e}),[]),st=(0,n.useCallback)((t=>{delete Q.current[t]}),[]),nt=(0,n.useMemo)((()=>({imageResourcesPath:M,linkService:Y.current,onItemClick:P,pdf:X,registerPage:it,renderMode:z,rotate:H,unregisterPage:st})),[M,P,X,it,z,H,st]),at=(0,n.useMemo)((()=>(0,a.Ay)(j,(()=>X))),[j,X]);return(0,s.jsx)("div",Object.assign({className:(0,o.A)("react-pdf__Document",c),ref:T,style:{"--scale-factor":"1"}},at,{children:S?void 0===X||null===X?(0,s.jsx)(m.A,{type:"loading",children:"function"===typeof k?k():k}):!1===X?(0,s.jsx)(m.A,{type:"error",children:"function"===typeof d?d():d}):(0,s.jsx)(g.A.Provider,{value:nt,children:i}):(0,s.jsx)(m.A,{type:"no-data",children:"function"===typeof R?R():R})}))}))},6440:t=>{var e=function(){};t.exports=e},6512:(t,e,i)=>{i.d(e,{A:()=>s});const s=(0,i(5043).createContext)(null)},6584:(t,e,i)=>{i.d(e,{A:()=>D});var s=i(579),n=i(5043),a=i(645),r=i(7906),o=i(8387);function l(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=t.filter(Boolean);return i.length<=1?i[0]||null:function(t){i.forEach((function(e){"function"===typeof e?e(t):e&&(e.current=t)}))}}var h=i(3404),c=i(6440);const d=(0,n.createContext)(null);var u=i(8599),p=i(9355);const g={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},m=/^H(\d+)$/;function f(t){return"children"in t}function b(t){return!!f(t)&&(1===t.children.length&&0 in t.children&&"id"in t.children[0])}function v(t){const e={};if(f(t)){const{role:i}=t,s=i.match(m);if(s)e.role="heading",e["aria-level"]=Number(s[1]);else if(function(t){return t in g}(i)){const t=g[i];t&&(e.role=t)}}return e}function A(t){const e={};if(f(t)){if(void 0!==t.alt&&(e["aria-label"]=t.alt),void 0!==t.lang&&(e.lang=t.lang),b(t)){const[i]=t.children;if(i){const t=A(i);return Object.assign(Object.assign({},e),t)}}}else"id"in t&&(e["aria-owns"]=t.id);return e}function y(t){return t?Object.assign(Object.assign({},v(t)),A(t)):null}function w(t){let{className:e,node:i}=t;const a=(0,n.useMemo)((()=>y(i)),[i]),r=(0,n.useMemo)((()=>f(i)?b(i)?null:i.children.map(((t,e)=>(0,s.jsx)(w,{node:t},e))):null),[i]);return(0,s.jsx)("span",Object.assign({className:e},a,{children:r}))}function x(){return(0,n.useContext)(d)}var _=i(8234),C=i(665);function E(){const t=x();(0,h.A)(t,"Unable to find Page context.");const{onGetStructTreeError:e,onGetStructTreeSuccess:i}=t,[r,o]=(0,_.A)(),{value:l,error:d}=r,{customTextRenderer:u,page:p}=t;return(0,n.useEffect)((function(){o({type:"RESET"})}),[o,p]),(0,n.useEffect)((function(){if(u)return;if(!p)return;const t=(0,a.A)(p.getStructTree()),e=t;return t.promise.then((t=>{o({type:"RESOLVE",value:t})})).catch((t=>{o({type:"REJECT",error:t})})),()=>(0,C.xL)(e)}),[u,p,o]),(0,n.useEffect)((()=>{void 0!==l&&(!1!==l?l&&i&&i(l):d&&(c(!1,d.toString()),e&&e(d)))}),[l]),l?(0,s.jsx)(w,{className:"react-pdf__Page__structTree structTree",node:l}):null}const S=p.ng;function T(t){const e=x();(0,h.A)(e,"Unable to find Page context.");const i=Object.assign(Object.assign({},e),t),{_className:a,canvasBackground:r,devicePixelRatio:o=(0,C.mZ)(),onRenderError:d,onRenderSuccess:u,page:p,renderForms:g,renderTextLayer:m,rotate:f,scale:b}=i,{canvasRef:v}=t;(0,h.A)(p,"Attempted to render page canvas, but no page was specified.");const A=(0,n.useRef)(null);function y(t){(0,C.UT)(t)||(c(!1,t.toString()),d&&d(t))}const w=(0,n.useMemo)((()=>p.getViewport({scale:b*o,rotation:f})),[o,p,f,b]),_=(0,n.useMemo)((()=>p.getViewport({scale:b,rotation:f})),[p,f,b]);(0,n.useEffect)((function(){if(!p)return;p.cleanup();const{current:t}=A;if(!t)return;t.width=w.width,t.height=w.height,t.style.width=`${Math.floor(_.width)}px`,t.style.height=`${Math.floor(_.height)}px`,t.style.visibility="hidden";const e={annotationMode:g?S.ENABLE_FORMS:S.ENABLE,canvasContext:t.getContext("2d",{alpha:!1}),viewport:w};r&&(e.background=r);const i=p.render(e),s=i;return i.promise.then((()=>{t.style.visibility="",p&&u&&u((0,C.vS)(p,b))})).catch(y),()=>(0,C.xL)(s)}),[r,p,g,w,_]);const T=(0,n.useCallback)((()=>{const{current:t}=A;t&&(t.width=0,t.height=0)}),[]);return(0,n.useEffect)((()=>T),[T]),(0,s.jsx)("canvas",{className:`${a}__canvas`,dir:"ltr",ref:l(v,A),style:{display:"block",userSelect:"none"},children:m?(0,s.jsx)(E,{}):null})}function M(){const t=x();(0,h.A)(t,"Unable to find Page context.");const{customTextRenderer:e,onGetTextError:i,onGetTextSuccess:r,onRenderTextLayerError:l,onRenderTextLayerSuccess:d,page:u,pageIndex:g,pageNumber:m,rotate:f,scale:b}=t;(0,h.A)(u,"Attempted to load page text content, but no page was specified.");const[v,A]=(0,_.A)(),{value:y,error:w}=v,E=(0,n.useRef)(null);c(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10),"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer"),(0,n.useEffect)((function(){A({type:"RESET"})}),[u,A]),(0,n.useEffect)((function(){if(!u)return;const t=(0,a.A)(u.getTextContent()),e=t;return t.promise.then((t=>{A({type:"RESOLVE",value:t})})).catch((t=>{A({type:"REJECT",error:t})}
2)),()=>(0,C.xL)(e)}),[u,A]),(0,n.useEffect)((()=>{void 0!==y&&(!1!==y?y&&r&&r(y):w&&(c(!1,w.toString()),i&&i(w)))}),[y]);const S=(0,n.useCallback)((()=>{d&&d()}),[d]),T=(0,n.useCallback)((t=>{c(!1,t.toString()),l&&l(t)}),[l]);const M=(0,n.useMemo)((()=>u.getViewport({scale:b,rotation:f})),[u,f,b]);return(0,n.useLayoutEffect)((function(){if(!u||!y)return;const{current:t}=E;if(!t)return;t.innerHTML="";const i=u.streamTextContent({includeMarkedContent:!0}),s={container:t,textContentSource:i,viewport:M},n=new p.D6(s),a=n;return n.render().then((()=>{const i=document.createElement("div");i.className="endOfContent",t.append(i);const s=t.querySelectorAll('[role="presentation"]');if(e){let t=0;y.items.forEach(((i,n)=>{if(!function(t){return"str"in t}(i))return;const a=s[t];if(!a)return;const r=e(Object.assign({pageIndex:g,pageNumber:m,itemIndex:n},i));a.innerHTML=r,t+=i.str&&i.hasEOL?2:1}))}S()})).catch(T),()=>(0,C.xL)(a)}),[e,T,S,u,g,m,y,M]),(0,s.jsx)("div",{className:(0,o.A)("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){const t=E.current;t&&t.classList.remove("selecting")},onMouseDown:function(){const t=E.current;t&&t.classList.add("selecting")},ref:E})}var k=i(6512);function R(){return(0,n.useContext)(k.A)}function P(){const t=R(),e=x();(0,h.A)(e,"Unable to find Page context.");const i=Object.assign(Object.assign({},t),e),{imageResourcesPath:r,linkService:l,onGetAnnotationsError:d,onGetAnnotationsSuccess:u,onRenderAnnotationLayerError:g,onRenderAnnotationLayerSuccess:m,page:f,pdf:b,renderForms:v,rotate:A,scale:y=1}=i;(0,h.A)(b,"Attempted to load page annotations, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop."),(0,h.A)(f,"Attempted to load page annotations, but no page was specified."),(0,h.A)(l,"Attempted to load page annotations, but no linkService was specified.");const[w,E]=(0,_.A)(),{value:S,error:T}=w,M=(0,n.useRef)(null);c(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10),"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations"),(0,n.useEffect)((function(){E({type:"RESET"})}),[E,f]),(0,n.useEffect)((function(){if(!f)return;const t=(0,a.A)(f.getAnnotations()),e=t;return t.promise.then((t=>{E({type:"RESOLVE",value:t})})).catch((t=>{E({type:"REJECT",error:t})})),()=>{(0,C.xL)(e)}}),[E,f]),(0,n.useEffect)((()=>{void 0!==S&&(!1!==S?S&&u&&u(S):T&&(c(!1,T.toString()),d&&d(T)))}),[S]);const k=(0,n.useMemo)((()=>f.getViewport({scale:y,rotation:A})),[f,A,y]);return(0,n.useEffect)((function(){if(!b||!f||!l||!S)return;const{current:t}=M;if(!t)return;const e=k.clone({dontFlip:!0}),i={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:t,l10n:null,page:f,structTreeLayer:null,viewport:e},s={annotations:S,annotationStorage:b.annotationStorage,div:t,imageResourcesPath:r,linkService:l,page:f,renderForms:v,viewport:e};t.innerHTML="";try{new p.dU(i).render(s),m&&m()}catch(n){!function(t){c(!1,`${t}`),g&&g(t)}(n)}return()=>{}}),[S,r,l,f,b,v,k]),(0,s.jsx)("div",{className:(0,o.A)("react-pdf__Page__annotations","annotationLayer"),ref:M})}var I=function(t,e){var i={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(i[s]=t[s]);if(null!=t&&"function"===typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(i[s[n]]=t[s[n]])}return i};const L=1;function D(t){const e=R(),i=Object.assign(Object.assign({},e),t),{_className:p="react-pdf__Page",_enableRegisterUnregisterPage:g=!0,canvasBackground:m,canvasRef:f,children:b,className:v,customRenderer:A,customTextRenderer:y,devicePixelRatio:w,error:x="Failed to load the page.",height:E,inputRef:S,loading:k="Loading page\u2026",noData:D="No page specified.",onGetAnnotationsError:F,onGetAnnotationsSuccess:N,onGetStructTreeError:O,onGetStructTreeSuccess:B,onGetTextError:z,onGetTextSuccess:H,onLoadError:j,onLoadSuccess:U,onRenderAnnotationLayerError:$,onRenderAnnotationLayerSuccess:G,onRenderError:V,onRenderSuccess:W,onRenderTextLayerError:q,onRenderTextLayerSuccess:X,pageIndex:K,pageNumber:Y,pdf:Q,registerPage:J,renderAnnotationLayer:Z=!0,renderForms:tt=!1,renderMode:et="canvas",renderTextLayer:it=!0,rotate:st,scale:nt=L,unregisterPage:at,width:rt}=i,ot=I(i,["_className","_enableRegisterUnregisterPage","canvasBackgroun
2d","canvasRef","children","className","customRenderer","customTextRenderer","devicePixelRatio","error","height","inputRef","loading","noData","onGetAnnotationsError","onGetAnnotationsSuccess","onGetStructTreeError","onGetStructTreeSuccess","onGetTextError","onGetTextSuccess","onLoadError","onLoadSuccess","onRenderAnnotationLayerError","onRenderAnnotationLayerSuccess","onRenderError","onRenderSuccess","onRenderTextLayerError","onRenderTextLayerSuccess","pageIndex","pageNumber","pdf","registerPage","renderAnnotationLayer","renderForms","renderMode","renderTextLayer","rotate","scale","unregisterPage","width"]),[lt,ht]=(0,_.A)(),{value:ct,error:dt}=lt,ut=(0,n.useRef)(null);(0,h.A)(Q,"Attempted to load a page, but no document was specified. Wrap <Page /> in a <Document /> or pass explicit `pdf` prop.");const pt=(0,C.ci)(Y)?Y-1:null!==K&&void 0!==K?K:null,gt=null!==Y&&void 0!==Y?Y:(0,C.ci)(K)?K+1:null,mt=null!==st&&void 0!==st?st:ct?ct.rotate:null,ft=(0,n.useMemo)((()=>{if(!ct)return null;let t=1;const e=null!==nt&&void 0!==nt?nt:L;if(rt||E){const e=ct.getViewport({scale:1,rotation:mt});rt?t=rt/e.width:E&&(t=E/e.height)}return e*t}),[E,ct,mt,nt,rt]);(0,n.useEffect)((function(){return()=>{(0,C.ci)(pt)&&g&&at&&at(pt)}}),[g,Q,pt,at]),(0,n.useEffect)((function(){ht({type:"RESET"})}),[ht,Q,pt]),(0,n.useEffect)((function(){if(!Q||!gt)return;const t=(0,a.A)(Q.getPage(gt)),e=t;return t.promise.then((t=>{ht({type:"RESOLVE",value:t})})).catch((t=>{ht({type:"REJECT",error:t})})),()=>(0,C.xL)(e)}),[ht,Q,gt]),(0,n.useEffect)((()=>{void 0!==ct&&(!1!==ct?function(){if(U){if(!ct||!ft)return;U((0,C.vS)(ct,ft))}if(g&&J){if(!(0,C.ci)(pt)||!ut.current)return;J(pt,ut.current)}}():dt&&(c(!1,dt.toString()),j&&j(dt)))}),[ct,ft]);const bt=(0,n.useMemo)((()=>ct&&(0,C.ci)(pt)&>&&(0,C.ci)(mt)&&(0,C.ci)(ft)?{_className:p,canvasBackground:m,customTextRenderer:y,devicePixelRatio:w,onGetAnnotationsError:F,onGetAnnotationsSuccess:N,onGetStructTreeError:O,onGetStructTreeSuccess:B,onGetTextError:z,onGetTextSuccess:H,onRenderAnnotationLayerError:$,onRenderAnnotationLayerSuccess:G,onRenderError:V,onRenderSuccess:W,onRenderTextLayerError:q,onRenderTextLayerSuccess:X,page:ct,pageIndex:pt,pageNumber:gt,renderForms:tt,renderTextLayer:it,rotate:mt,scale:ft}:null),[p,m,y,w,F,N,O,B,z,H,$,G,V,W,q,X,ct,pt,gt,tt,it,mt,ft]),vt=(0,n.useMemo)((()=>(0,r.Ay)(ot,(()=>ct?ft?(0,C.vS)(ct,ft):void 0:ct))),[ot,ct,ft]),At=`${pt}@${ft}/${mt}`;function yt(){switch(et){case"custom":return(0,h.A)(A,'renderMode was set to "custom", but no customRenderer was passed.'),(0,s.jsx)(A,{},`${At}_custom`);case"none":return null;default:return(0,s.jsx)(T,{canvasRef:f},`${At}_canvas`)}}return(0,s.jsx)("div",Object.assign({className:(0,o.A)(p,v),"data-page-number":gt,ref:l(S,ut),style:{"--scale-factor":`${ft}`,backgroundColor:m||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},vt,{children:gt?null===Q||void 0===ct||null===ct?(0,s.jsx)(u.A,{type:"loading",children:"function"===typeof k?k():k}):!1===Q||!1===ct?(0,s.jsx)(u.A,{type:"error",children:"function"===typeof x?x():x}):(0,s.jsxs)(d.Provider,{value:bt,children:[yt(),it?(0,s.jsx)(M,{},`${At}_text`):null,Z?(0,s.jsx)(P,{},`${At}_annotations`):null,b]}):(0,s.jsx)(u.A,{type:"no-data",children:"function"===typeof D?D():D})}))}},6601:()=>{},7906:(t,e,i)=>{i.d(e,{Ay:()=>a});var s=function(t,e,i){if(i||2===arguments.length)for(var s,n=0,a=e.length;n<a;n++)!s&&n in e||(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},n=s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s(s([],["onCopy","onCut","onPaste"],!0),["onCompositionEnd","onCompositionStart","onCompositionUpdate"],!0),["onFocus","onBlur"],!0),["onInput","onInvalid","onReset","onSubmit"],!0),["onLoad","onError"],!0),["onKeyDown","onKeyPress","onKeyUp"],!0),["onAbort","onCanPlay","onCanPlayThrough","onDurationChange","onEmptied","onEncrypted","onEnded","onError","onLoadedData","onLoadedMetadata","onLoadStart","onPause","onPlay","onPlaying","onProgress","onRateChange","onSeeked","onSeeking","onStalled","onSuspend","onTimeUpdate","onVolumeChange","onWaiting"],!0),["onClick","onContextMenu","onDoubleClick","onMouseDown","onMouseEnter","onMouseLeave","onMouseMove","onMouseOut","onMouseOver","onMouseUp"],!0),["onDrag","onDragEnd","onDragEnter","onDragExit","onDragLeave","onDragOver","onDragStart","onDrop"],!0),["onSelect"],!0),["onTouchCancel","onTouchEnd","onTouchMove","onTouchStart"],!0),["onPointerDown","onPointerMove","onPointerUp","onPointerCancel","onGotPointerCapture","onLostPointerCapture","onPointerEnter","onPointerLeave","onPointerOver","onPointerOut"],!0),["onScroll"],!0),["onWheel"],!0),["onAnimationStart","onAnimationEnd","onAnimationIteration"],!0),["onTransitionEnd"],!0),["onChange"],!0),["onToggle"],!0);function a(t,e){var i={};
2return n.forEach((function(s){var n=t[s];n&&(i[s]=e?function(t){return n(t,e(s))}:n)})),i}},8234:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(5043);function n(t,e){switch(e.type){case"RESOLVE":return{value:e.value,error:void 0};case"REJECT":return{value:!1,error:e.error};case"RESET":return{value:void 0,error:void 0};default:return t}}function a(){return(0,s.useReducer)(n,{value:void 0,error:void 0})}},8599:(t,e,i)=>{i.d(e,{A:()=>n});var s=i(579);function n(t){let{children:e,type:i}=t;return(0,s.jsx)("div",{className:`react-pdf__message react-pdf__message--${i}`,children:e})}},9355:(t,e,i)=>{i.d(e,{D6:()=>xn,EA:()=>yn,Tm:()=>wn,YE:()=>_n,dU:()=>vn,ng:()=>An});var s={d:(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},n=globalThis.pdfjsLib={};s.d(n,{AbortException:()=>ft,AnnotationEditorLayer:()=>fn,AnnotationEditorParamsType:()=>A,AnnotationEditorType:()=>v,AnnotationEditorUIManager:()=>ce,AnnotationLayer:()=>en,AnnotationMode:()=>b,ColorPicker:()=>un,DOMSVGFactory:()=>_s,DrawLayer:()=>bn,FeatureTest:()=>yt,GlobalWorkerOptions:()=>oi,ImageKind:()=>T,InvalidPDFException:()=>ut,MissingPDFException:()=>pt,OPS:()=>J,OutputScale:()=>ee,PDFDataRangeTransport:()=>os,PDFDateString:()=>Kt,PDFWorker:()=>ds,PasswordResponses:()=>Z,PermissionFlag:()=>y,PixelsPerInch:()=>Ot,RenderingCancelledException:()=>Ht,TextLayer:()=>Qi,UnexpectedResponseException:()=>gt,Util:()=>xt,VerbosityLevel:()=>Q,XfaLayer:()=>Cs,build:()=>vs,createValidAbsoluteUrl:()=>ot,fetchData:()=>Bt,getDocument:()=>ns,getFilenameFromUrl:()=>$t,getPdfFilenameFromUrl:()=>Gt,getXfaPageViewport:()=>Yt,isDataScheme:()=>jt,isPdfFile:()=>Ut,noContextMenu:()=>qt,normalizeUnicode:()=>Et,setLayerDimensions:()=>te,shadow:()=>lt,version:()=>bs});const a="object"===typeof process&&process+""==="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&"browser"!==process.type),r=[1,0,0,1,0,0],o=[.001,0,0,.001,0,0],l=1.35,h=1,c=2,d=4,u=16,p=32,g=64,m=128,f=256,b={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},v={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},A={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_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},y={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},w=0,x=1,_=2,C=3,E=3,S=4,T={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},M=1,k=2,R=3,P=4,I=5,L=6,D=7,F=8,N=9,O=10,B=11,z=12,H=13,j=14,U=15,$=16,G=17,V=20,W=1,q=2,X=3,K=4,Y=5,Q={ERRORS:0,WARNINGS:1,INFOS:5},J={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},Z={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let tt=Q.WARNINGS;function et(t){Number.isInteger(t)&&(tt=t)}function it(){return tt}function st(t){tt>=Q.INFOS&&console.log(`Info: ${t}`)}function nt(t){tt>=Q.WARNINGS&&console.log(`Warning: ${t}`)}function at(t){throw new Error(t)}function rt(t,e){t||at(e)}function ot(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!t)return null;try{if(i&&"string"===typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}
2if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null}function lt(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const ht=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class ct extends ht{constructor(t,e){super(t,"PasswordException"),this.code=e}}class dt extends ht{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class ut extends ht{constructor(t){super(t,"InvalidPDFException")}}class pt extends ht{constructor(t){super(t,"MissingPDFException")}}class gt extends ht{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class mt extends ht{constructor(t){super(t,"FormatError")}}class ft extends ht{constructor(t){super(t,"AbortException")}}function bt(t){"object"===typeof t&&void 0!==t?.length||at("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const a=Math.min(n+i,e),r=t.subarray(n,a);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function vt(t){"string"!==typeof t&&at("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}function At(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e}class yt{static get isLittleEndian(){return lt(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return lt(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return lt(this,"isOffscreenCanvasSupported","undefined"!==typeof OffscreenCanvas)}static get platform(){return"undefined"!==typeof navigator&&"string"===typeof navigator?.platform?lt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"===typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):lt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return lt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const wt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class xt{static makeHexColor(t,e,i){return`#${wt[t]}${wt[e]}${wt[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){const i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],n[0],a[0]),Math.min(i[1],s[1],n[1],a[1]),Math.max(i[0],s[0],n[0],a[0]),Math.max(i[1],s[1],n[1],a[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],r=(i+a)/2,o=Math.sqrt((i+a)**2-4*(i*a-n*s))/2,l=r+o||1,h=r-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[i,n,s,a]}static#t(t,e,i,s,n,a,r,o,l,h){if(l<=0||l>=1)return;const c=1-l,d=l*l,u=d*l,p=c*(c*(c*t+3*l*e)+3*d*i)+u*s,g=c*(c*(c*n+3*l*a)+3*d*r)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,i,s,n,a,r,o,l,h,c,d){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,s,n,a,r,o,-c/h,d));const u=h**2-4*c*l;if(u<0)return;const p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,n,a,r,o,(-h+p)/g,d),this.#t(t,e,i,s,n,a,r,o,(-h-p)/g,d)}static bezierBoundingBox(t,e,i,s,n,a,r,o,l){return l?(l[0]=Math.min(l[0],t,r),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,r),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,r),Math.min(e,o),Math.max(t,r),Math.max(e,o)],this.#e(t,i,n,r,e,s,a,o,3*(3*(i-n)-t+r),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,r,e,s,a,o,3*(3*(s-a)-e+o),6*(e-2*s+a),3*(s-e),l),l}}let _t=null,Ct=null;function Et(t){return _t||(_t=/([\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,Ct=ne
2w Map([["\ufb05","\u017ft"]])),t.replaceAll(_t,((t,e,i)=>e?e.normalize("NFKC"):Ct.get(i)))}const St="pdfjs_internal_id_",Tt=0,Mt=1,kt=2,Rt=3,Pt=4,It=5,Lt=6,Dt=7,Ft=8;const Nt="http://www.w3.org/2000/svg";class Ot{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=(()=>this.CSS/this.PDF)()}async function Bt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";if(Wt(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class zt{constructor(t){let{viewBox:e,scale:i,rotation:s,offsetX:n=0,offsetY:a=0,dontFlip:r=!1}=t;this.viewBox=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=a;const o=(e[2]+e[0])/2,l=(e[3]+e[1])/2;let h,c,d,u,p,g,m,f;switch(s%=360,s<0&&(s+=360),s){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,u=-u),0===h?(p=Math.abs(l-e[1])*i+n,g=Math.abs(o-e[0])*i+a,m=(e[3]-e[1])*i,f=(e[2]-e[0])*i):(p=Math.abs(o-e[0])*i+n,g=Math.abs(l-e[1])*i+a,m=(e[2]-e[0])*i,f=(e[3]-e[1])*i),this.transform=[h*i,c*i,d*i,u*i,p-h*i*o-d*i*l,g-c*i*o-u*i*l],this.width=m,this.height=f}get rawDims(){const{viewBox:t}=this;return lt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone(){let{scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new zt({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){return xt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=xt.applyTransform([t[0],t[1]],this.transform),i=xt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return xt.applyInverseTransform([t,e],this.transform)}}class Ht extends ht{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;super(t,"RenderingCancelledException"),this.extraDelay=e}}function jt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Ut(t){return"string"===typeof t&&/\.pdf$/i.test(t)}function $t(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Gt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"document.pdf";if("string"!==typeof t)return e;if(jt(t))return nt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e}class Vt{started=(()=>Object.create(null))();times=[];time(t){t in this.started&&nt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||nt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:i}of this.times)e=Math.max(i.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function Wt(t,e){try{const{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function qt(t){t.preventDefault()}function Xt(t){console.log("Deprecated API usage: "+t)}class Kt{static#i;static toDateObject(t){if(!t||"string"!==typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let r=parseInt(e[5],10);r=r>=0&&r<=59?r:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(e[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(a+=h,r+=c):"+"===l&&(a-=h,r-=c),new Date(Date.UTC(i,s,n,a,r,o))}}function Yt(t,e){let{scale:i=1,rotation:s=0}=e;const{width:n,height:a}=t.attributes.style,r=[0,0,parseInt(n),parseInt(a)];return new zt({viewBox:r,scale:i,rotation:s})}function Qt(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(nt(`Not a valid color format: "${t}"`),[0,0,0])}function Jt(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform();return[e,i,s,n,a,r]}function Zt(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform().invertSelf();return[e,i,s,n,a,r]}function te(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(e instanceof zt){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:a}=t,r=yt.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${n}px`,h=r?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,c=r?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;i&&e.rotation%180!==0?(a.width=c,a.height=h):(a.width=h,a.height=c)}s&&t.setAttribute("data-main-rotation",e.rotation)}class ee{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}class ie{#s=null;#n=null;#a;#r=null;#o=null;static#l=null;constructor(t){this.#a=t,ie.#l||=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"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#a._uiManager._signal;t.addEventListener("contextmenu",qt,{signal:e}),t.addEventListener("pointerdown",ie.#h,{signal:e});const i=this.#r=document.createElement("div");i.className="buttons",t.append(i);const s=this.#a.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#a._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#c(),t}get div(){return this.#s}static#h(t){t.stopPropagation()}#d(t){this.#a._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()}#u(t){this.#a._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()}#p(t){const e=this.#a._uiManager._signal;t.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",qt,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#c(){const{editorType:t,_uiManager:e}=this.#a,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",ie.#l[t]),this.#p(i),i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#r.append(i)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#r.prepend(e,this.#g),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#p(e),this.#r.prepend(e,this.#g)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class se{#r=null;#s=null;#m;constructor(t){this.#m=t}#f(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",qt,{signal:this.#m._signal});const e=this.#r=document.createElement("div");return e.className="buttons",t.append(e),this.#b(),t}#v(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const a=n.x+(e?n.width:0);t>i?(s=a,i=t):e?a>s&&(s=a):a<s&&(s=a)}return[e?1-s:s,i]}
2show(t,e,i){const[s,n]=this.#v(e,i),{style:a}=this.#s||=this.#f();t.append(this.#s),a.insetInlineEnd=100*s+"%",a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#b(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#m._signal;t.addEventListener("contextmenu",qt,{signal:i}),t.addEventListener("click",(()=>{this.#m.highlightSelection("floating_button")}),{signal:i}),this.#r.append(t)}}function ne(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class ae{#A=0;get id(){return"pdfjs_internal_editor_"+this.#A++}}class re{#y=(()=>function(){if("undefined"!==typeof crypto&&"function"===typeof crypto?.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);if("undefined"!==typeof crypto&&"function"===typeof crypto?.getRandomValues)crypto.getRandomValues(t);else for(let e=0;e<32;e++)t[e]=Math.floor(255*Math.random());return bt(t)}())();#A=0;#w=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='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>';return lt(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#x(t,e){this.#w||=new Map;let i=this.#w.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#y}_${this.#A++}`,refCounter:0,isSvg:!1},"string"===typeof e?(i.url=e,t=await Bt(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=re._isSVGFittingCanvas,s=new FileReader,n=new Image,a=new Promise(((t,a)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=a}));s.readAsDataURL(t),await a}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(s){console.error(s),i=null}return this.#w.set(t,i),i&&this.#w.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#x(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#x(t,t)}async getFromBlob(t,e){const i=await e;return this.#x(t,i)}async getFromId(t){this.#w||=new Map;const e=this.#w.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#w||=new Map;let i=this.#w.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#y}_${this.#A++}`,refCounter:1,isSvg:!1},this.#w.set(t,i),this.#w.set(i.id,i),i}getSvgUrl(t){const e=this.#w.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#w||=new Map;const e=this.#w.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#y}_`)}}class oe{#_=[];#C=!1;#E;#S=-1;constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:128;this.#E=t}add(t){let{cmd:e,undo:i,post:s,mustExec:n,type:a=NaN,overwriteIfSameType:r=!1,keepUndo:o=!1}=t;if(n&&e(),this.#C)return;const l={cmd:e,undo:i,post:s,type:a};if(-1===this.#S)return this.#_.length>0&&(this.#_.length=0),this.#S=0,void this.#_.push(l);if(r&&this.#_[this.#S].type===a)return o&&(l.undo=this.#_[this.#S].undo),void(this.#_[this.#S]=l);const h=this.#S+1;h===this.#E?this.#_.splice(0,1):(this.#S=h,h<this.#_.length&&this.#_.splice(h)),this.#_.push(l)}undo(){if(-1===this.#S)return;this.#C=!0;const{undo:t,post:e}=this.#_[this.#S];t(),e?.(),this.#C=!1,this.#S-=1}redo(){if(this.#S<this.#_.length-1){this.#S+=1,this.#C=!0;const{cmd:t,post:e}=this.#_[this.#S];t(),e?.(),this.#C=!1}}hasSomethingToUndo(){return-1!==this.#S}hasSomethingToRedo(){return this.#S<this.#_.length-1}destroy(){this.#_=null}}class le{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=yt.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#T(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#T(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:a=[],checker:r=null}}=i;r&&!r(t,e)||(s.bind(t,...a,e)(),n||(e.stopPropagation(),e.preventDefault()))}}class he{static _colorsMapping=(()=>new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]))();get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,Qt(s))}e.remove()}(t),lt(this,"_colors",t)}convert(t){const e=Qt(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[i,s]of this._colors)if(s.every(((t,i)=>t===e[i])))return he._colorsMapping.get(i);return e}getHexCode(t){const e=this._colors.get(t);return e?xt.makeHexColor(...e):t}}class ce{#M=(()=>new AbortController)();#k=null;#R=(()=>new Map)();#P=(()=>new Map)();#I=null;#L=null;#D=null;#F=(()=>new oe)();#N=null;#O=0;#B=(()=>new Set)();#z=null;#H=null;#j=(()=>new Set)();#U=!1;#$=!1;#G=!1;#V=null;#W=null;#q=null;#X=null;#K=!1;#Y=null;#Q=(()=>new ae)();#J=!1;#Z=!1;#tt=null;#et=null;#it=null;#st=null;#nt=(()=>v.NONE)();#at=(()=>new Set)();#rt=null;#ot=null;#lt=null;#ht={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ct=[0,0];#dt=null;#ut=null;#pt=null;#gt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=ce.prototype,e=t=>t.#ut.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,e)=>{let{target:i}=e;if(i instanceof HTMLInputElement){const{type:t}=i;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,n=this.TRANSLATE_BIG;return lt(this,"_keyboardManager",new le([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,e)=>{let{target:i}=e;return!(i instanceof HTMLButtonElement)&&t.#ut.contains(i)&&!t.isEnterHandled}}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,e)=>{let{target:i}=e;return!(i instanceof HTMLButtonElement)&&t.#ut.contains(document.activeElement)}}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}constructor(t,e,i,s,n,a,r,o,l,h,c){const d=this._signal=this.#M.signal;this.#ut=t,this.#pt=e,this.#I=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:d}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:d}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:d}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:d}),s._on("setpreference",this.onSetPreference.bind(this),{signal:d}),s._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:d}),this.#mt(),this.#ft(),this.#bt(),this.#L=n.annotationStorage,this.#V=n.filterFactory,this.#ot=a,this.#X=r||null,this.#U=o,this.#$=l,this.#G=h,this.#st=c||null,this.viewParameters={realScale:Ot.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){this.#gt?.resolve(),this.#gt=null,this.#M?.abort(),this.#M=null,this._signal=null;
2for(const t of this.#P.values())t.destroy();this.#P.clear(),this.#R.clear(),this.#j.clear(),this.#k=null,this.#at.clear(),this.#F.destroy(),this.#I?.destroy(),this.#Y?.hide(),this.#Y=null,this.#W&&(clearTimeout(this.#W),this.#W=null),this.#dt&&(clearTimeout(this.#dt),this.#dt=null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#st}get useNewAltTextFlow(){return this.#$}get useNewAltTextWhenAddingImage(){return this.#G}get hcmFilter(){return lt(this,"hcmFilter",this.#ot?this.#V.addHCMFilter(this.#ot.foreground,this.#ot.background):"none")}get direction(){return lt(this,"direction",getComputedStyle(this.#ut).direction)}get highlightColors(){return lt(this,"highlightColors",this.#X?new Map(this.#X.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return lt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setMainHighlightColorPicker(t){this.#it=t}editAltText(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.#I?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference(t){let{name:e,value:i}=t;if("enableNewAltTextWhenAddingImage"===e)this.#G=i}onPageChanging(t){let{pageNumber:e}=t;this.#O=e-1}focusMainContainer(){this.#ut.focus()}findParent(t,e){for(const i of this.#P.values()){const{x:s,y:n,width:a,height:r}=i.div.getBoundingClientRect();if(t>=s&&t<=s+a&&e>=n&&e<=n+r)return i}return null}disableUserSelect(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.#pt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#j.add(t)}removeShouldRescale(t){this.#j.delete(t)}onScaleChanging(t){let{scale:e}=t;this.commitOrRemove(),this.viewParameters.realScale=e*Ot.PDF_TO_CSS_UNITS;for(const i of this.#j)i.onScaleChanging()}onRotationChanging(t){let{pagesRotation:e}=t;this.commitOrRemove(),this.viewParameters.rotation=e}#vt(t){let{anchorNode:e}=t;return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#At(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const i of this.#P.values())if(i.hasTextLayer(t))return i;return null}highlightSelection(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:a}=e,r=e.toString(),o=this.#vt(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#At(o),c=this.#nt===v.NONE,d=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:a,text:r}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(v.HIGHLIGHT,d):d()}#yt(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#vt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#Y||=new se(this),this.#Y.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#L||this.#L.has(t.id)||this.#L.setValue(t.id,t)}#wt(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#rt&&(this.#Y?.hide(),this.#rt=null,this.#xt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#rt)return;const i=this.#vt(t).closest(".textLayer");if(i){if(this.#Y?.hide(),this.#rt=e,this.#xt({hasSelectedText:!0}),(this.#nt===v.HIGHLIGHT||this.#nt===v.NONE)&&(this.#nt===v.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#K=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#nt===v.HIGHLIGHT?this.#At(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#_t("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#rt&&(this.#Y?.hide(),this.#rt=null,this.#xt({hasSelectedText:!1}))}#_t(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";this.#nt===v.HIGHLIGHT?this.highlightSelection(t):this.#U&&this.#yt()}#mt(){document.addEventListener("selectionchange",this.#wt.bind(this),{signal:this._signal})}#Ct(){if(this.#q)return;this.#q=new AbortController;const t=this.combinedSignal(this.#q);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Et(){this.#q?.abort(),this.#q=null}blur(){if(this.isShiftKeyDown=!1,this.#K&&(this.#K=!1,this.#_t("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#at)if(e.div.contains(t)){this.#et=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#et)return;const[t,e]=this.#et;this.#et=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#bt(){if(this.#tt)return;this.#tt=new AbortController;const t=this.combinedSignal(this.#tt);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#St(){this.#tt?.abort(),this.#tt=null}#Tt(){if(this.#N)return;this.#N=new AbortController;const t=this.combinedSignal(this.#N);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#Mt(){this.#N?.abort(),this.#N=null}#ft(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#bt(),this.#Tt()}removeEditListeners(){this.#St(),this.#Mt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#k?.commitOrRemove(),!this.hasSelection)return;const e=[];
2for(const i of this.#at){const t=i.serialize(!0);t&&e.push(t)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const a of e.items)for(const t of this.#H)if(t.isHandlingMimeForPasting(a.type))return void t.paste(a,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(n){return void nt(`paste: "${n.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const a of i){const e=await s.deserialize(a);if(!e)return;t.push(e)}const e=()=>{for(const e of t)this.#kt(e);this.#Rt(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(n){nt(`paste: "${n.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0),this.#nt===v.NONE||this.isEditorHandlingKeyboard||ce._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#K&&(this.#K=!1,this.#_t("main_toolbar")))}onEditingAction(t){let{name:e}=t;switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#xt(t){Object.entries(t).some((t=>{let[e,i]=t;return this.#ht[e]!==i}))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#ht,t)}),this.#nt===v.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Pt([[A.HIGHLIGHT_FREE,!0]]))}#Pt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#Tt(),this.#xt({isEditing:this.#nt!==v.NONE,isEmpty:this.#It(),hasSomethingToUndo:this.#F.hasSomethingToUndo(),hasSomethingToRedo:this.#F.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Et(),this.#Mt(),this.#xt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#H){this.#H=t;for(const t of this.#H)this.#Pt(t.defaultPropertiesToUpdate)}}getId(){return this.#Q.id}get currentLayer(){return this.#P.get(this.#O)}getLayer(t){return this.#P.get(t)}get currentPageIndex(){return this.#O}addLayer(t){this.#P.set(t.pageIndex,t),this.#J?t.enable():t.disable()}removeLayer(t){this.#P.delete(t.pageIndex)}async updateMode(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.#nt!==t&&(!this.#gt||(await this.#gt.promise,this.#gt))){if(this.#gt=Promise.withResolvers(),this.#nt=t,t===v.NONE)return this.setEditingState(!1),this.#Lt(),void this.#gt.resolve();this.setEditingState(!0),await this.#Dt(),this.unselectAll();for(const e of this.#P.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#gt.resolve();for(const t of this.#R.values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#gt.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#nt&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#H){switch(t){case A.CREATE:return void this.currentLayer.addNewEditor();case A.HIGHLIGHT_DEFAULT_COLOR:this.#it?.updateColor(e);break;case A.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#lt||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#at)i.updateParams(t,e);for(const i of this.#H)i.updateDefaultParams(t,e)}}showAllEditors(t,e){for(const i of this.#R.values())i.editorType===t&&i.show(e);(this.#lt?.get(A.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Pt([[A.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.#Z!==t){this.#Z=t;for(const e of this.#P.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Dt(){if(!this.#J){this.#J=!0;const t=[];for(const e of this.#P.values())t.push(e.enable());await Promise.all(t);for(const e of this.#R.values())e.enable()}}#Lt(){if(this.unselectAll(),this.#J){this.#J=!1;for(const t of this.#P.values())t.disable();for(const t of this.#R.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#R.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#R.get(t)}addEditor(t){this.#R.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#W&&clearTimeout(this.#W),this.#W=setTimeout((()=>{this.focusMainContainer(),this.#W=null}),0)),this.#R.delete(t.id),this.unselect(t),t.annotationElementId&&this.#B.has(t.annotationElementId)||this.#L?.remove(t.id)}addDeletedAnnotationElement(t){this.#B.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}
2isDeletedAnnotationElement(t){return this.#B.has(t)}removeDeletedAnnotationElement(t){this.#B.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#kt(t){const e=this.#P.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#k!==t&&(this.#k=t,t&&this.#Pt(t.propertiesToUpdate))}get#Ft(){let t=null;for(t of this.#at);return t}updateUI(t){this.#Ft===t&&this.#Pt(t.propertiesToUpdate)}toggleSelected(t){if(this.#at.has(t))return this.#at.delete(t),t.unselect(),void this.#xt({hasSelectedEditor:this.hasSelection});this.#at.add(t),t.select(),this.#Pt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}setSelected(t){for(const e of this.#at)e!==t&&e.unselect();this.#at.clear(),this.#at.add(t),t.select(),this.#Pt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}isSelected(t){return this.#at.has(t)}get firstSelectedEditor(){return this.#at.values().next().value}unselect(t){t.unselect(),this.#at.delete(t),this.#xt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#at.size}get isEnterHandled(){return 1===this.#at.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#F.undo(),this.#xt({hasSomethingToUndo:this.#F.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#It()})}redo(){this.#F.redo(),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#F.hasSomethingToRedo(),isEmpty:this.#It()})}addCommands(t){this.#F.add(t),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#It()})}#It(){if(0===this.#R.size)return!0;if(1===this.#R.size)for(const t of this.#R.values())return t.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...this.#at];this.addCommands({cmd:()=>{for(const e of t)e.remove()},undo:()=>{for(const e of t)this.#kt(e)},mustExec:!0})}commitOrRemove(){this.#k?.commitOrRemove()}hasSomethingToControl(){return this.#k||this.hasSelection}#Rt(t){for(const e of this.#at)e.unselect();this.#at.clear();for(const e of t)e.isEmpty()||(this.#at.add(e),e.select());this.#xt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#at)t.commit();this.#Rt(this.#R.values())}unselectAll(){if((!this.#k||(this.#k.commitOrRemove(),this.#nt===v.NONE))&&this.hasSelection){for(const t of this.#at)t.unselect();this.#at.clear(),this.#xt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e){if(arguments.length>2&&void 0!==arguments[2]&&arguments[2]||this.commitOrRemove(),!this.hasSelection)return;this.#ct[0]+=t,this.#ct[1]+=e;const[i,s]=this.#ct,n=[...this.#at];this.#dt&&clearTimeout(this.#dt),this.#dt=setTimeout((()=>{this.#dt=null,this.#ct[0]=this.#ct[1]=0,this.addCommands({cmd:()=>{for(const t of n)this.#R.has(t.id)&&t.translateInPage(i,s)},undo:()=>{for(const t of n)this.#R.has(t.id)&&t.translateInPage(-i,-s)},mustExec:!1})}),1e3);for(const a of n)a.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#z=new Map;for(const t of this.#at)this.#z.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#z)return!1;this.disableUserSelect(!1);const t=this.#z;this.#z=null;let e=!1;for(const[{x:s,y:n,pageIndex:a},r]of t)r.newX=s,r.newY=n,r.newPageIndex=a,e||=s!==r.savedX||n!==r.savedY||a!==r.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#R.has(t.id)){const n=this.#P.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:a}]of t)i(e,s,n,a)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:a}]of t)i(e,s,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#z)for(const i of this.#z.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#at.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#k===t}getActive(){return this.#k}getMode(){return this.#nt}get imageManager(){return lt(this,"imageManager",new re)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,h=e.rangeCount;l<h;
vendor: 8,950 bytes, line 2
2l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:a}=t.getBoundingClientRect();let r;switch(t.getAttribute("data-main-rotation")){case"90":r=(t,e,r,o)=>({x:(e-s)/a,y:1-(t+r-i)/n,width:o/a,height:r/n});break;case"180":r=(t,e,r,o)=>({x:1-(t+r-i)/n,y:1-(e+o-s)/a,width:r/n,height:o/a});break;case"270":r=(t,e,r,o)=>({x:1-(e+o-s)/a,y:(t-i)/n,width:o/a,height:r/n});break;default:r=(t,e,r,o)=>({x:(t-i)/n,y:(e-s)/a,width:r/n,height:o/a})}const o=[];for(let l=0,h=e.rangeCount;l<h;l++){const t=e.getRangeAt(l);if(!t.collapsed)for(const{x:e,y:i,width:s,height:n}of t.getClientRects())0!==s&&0!==n&&o.push(r(e,i,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation(t){let{annotationElementId:e,id:i}=t;(this.#D||=new Map).set(e,i)}removeChangedExistingAnnotation(t){let{annotationElementId:e}=t;this.#D?.delete(e)}renderAnnotationElement(t){const e=this.#D?.get(t.data.id);if(!e)return;const i=this.#L.getRawValue(e);i&&(this.#nt!==v.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}}class de{#o=null;#Nt=!1;#Ot=null;#Bt=null;#zt=null;#Ht=null;#jt=!1;#Ut=null;#a=null;#$t=null;#Gt=null;#Vt=!1;static#Wt=null;static _l10n=null;constructor(t){this.#a=t,this.#Vt=t._uiManager.useNewAltTextFlow,de.#Wt||=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(t){de._l10n??=t}async render(){const t=this.#Ot=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#Bt=document.createElement("span");t.append(e),this.#Vt?(t.classList.add("new"),t.setAttribute("data-l10n-id",de.#Wt.missing),e.setAttribute("data-l10n-id",de.#Wt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#a._uiManager._signal;t.addEventListener("contextmenu",qt,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#a._uiManager.editAltText(this.#a),this.#Vt&&this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#qt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#jt=!0,s(e))}),{signal:i}),await this.#Xt(),t}get#qt(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Ot&&(this.#Ot.focus({focusVisible:this.#jt}),this.#jt=!1)}isEmpty(){return this.#Vt?null===this.#o:!this.#o&&!this.#Nt}hasData(){return this.#Vt?null!==this.#o||!!this.#$t:this.isEmpty()}get guessedText(){return this.#$t}async setGuessedText(t){null===this.#o&&(this.#$t=t,this.#Gt=await de._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Xt())}toggleAltTextBadge(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this.#Vt||this.#o)return this.#Ut?.remove(),void(this.#Ut=null);if(!this.#Ut){const t=this.#Ut=document.createElement("div");t.className="noAltTextBadge",this.#a.div.append(t)}this.#Ut.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#$t!==e||(e=this.#Gt),{altText:e,decorative:this.#Nt,guessedText:this.#$t,textWithDisclaimer:this.#Gt}}get data(){return{altText:this.#o,decorative:this.#Nt}}set data(t){let{altText:e,decorative:i,guessedText:s,textWithDisclaimer:n,cancel:a=!1}=t;s&&(this.#$t=s,this.#Gt=n),this.#o===e&&this.#Nt===i||(a||(this.#o=e,this.#Nt=i),this.#Xt())}toggle(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.#Ot&&(!t&&this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#Ot.disabled=!t)}shown(){this.#a._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#qt}})}destroy(){this.#Ot?.remove(),this.#Ot=null,this.#Bt=null,this.#zt=null,this.#Ut?.remove(),this.#Ut=null}async#Xt(){const t=this.#Ot;if(!t)return;if(this.#Vt){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",de.#Wt[this.#qt]),this.#Bt?.setAttribute("data-l10n-id",de.#Wt[`${this.#qt}-label`]),!this.#o)return void this.#zt?.remove()}else{if(!this.#o&&!this.#Nt)return t.classList.remove("done"),void this.#zt?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#zt;if(!e){this.#zt=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#a.id}`;const i=100,s=this.#a._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#Ht),this.#Ht=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Ht=setTimeout((()=>{this.#Ht=null,this.#zt.classList.add("show"),this.#a._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#zt?.classList.remove("show")}),{signal:s})}this.#Nt?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);const i=this.#a.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}class ue{#Kt=null;#Yt=null;#o=null;#Qt=!1;#Jt=!1;#Zt=null;#te=null;#ee=null;#ie="";#se=!1;#ne=null;#ae=!1;#re=!1;#oe=!1;#le=null;#he=0;#ce=0;#de=null;_editToolbar=null;_initialOptions=(()=>Object.create(null))();_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#ue=!1;#pe=(()=>ue._zIndex++)();static _borderLineWidth=-1;static _colorManager=(()=>new he)();static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=ue.prototype._resizeWithKeyboard,e=ce.TRANSLATE_SMALL,i=ce.TRANSLATE_BIG;return lt(this,"_resizerKeyboardManager",new le([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],ue.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,a];const[r,o]=this.parentDimensions;this.x=t.x/r,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return lt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new pe({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(ue._l10n??=t,ue._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"}),-1!==ue._borderLineWidth)return;const i=getComputedStyle(document.documentElement);ue._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){at("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#ue}set _isDraggable(t){this.#ue=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}
2setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#pe}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#ge(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#se?this.#se=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,a]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/a,this.fixAndSetPosition()}#me(t,e,i){let[s,n]=t;[e,i]=this.screenToPageTranslation(e,i),this.x+=e/s,this.y+=i/n,this.fixAndSetPosition()}translate(t,e){this.#me(this.parentDimensions,t,e)}translateInPage(t,e){this.#ne||=[this.x,this.y],this.#me(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#ne||=[this.x,this.y];const[i,s]=this.parentDimensions;if(this.x+=t/i,this.y+=e/s,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this;const[r,o]=this.getBaseTranslation();n+=r,a+=o,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*a).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#ne&&(this.#ne[0]!==this.x||this.#ne[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=ue,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.rotation;const[e,i]=this.pageDimensions;let{x:s,y:n,width:a,height:r}=this;if(a*=e,r*=i,s*=e,n*=i,this._mustFixPosition)switch(t){case 0:s=Math.max(0,Math.min(e-a,s)),n=Math.max(0,Math.min(i-r,n));break;case 90:s=Math.max(0,Math.min(e-r,s)),n=Math.min(i,Math.max(a,n));break;case 180:s=Math.min(e,Math.max(a,s)),n=Math.min(i,Math.max(r,n));break;case 270:s=Math.min(e,Math.max(r,s)),n=Math.max(0,Math.min(i-a,n))}this.x=s/=e,this.y=n/=i;const[o,l]=this.getBaseTranslation();s+=o,n+=l;const{style:h}=this.div;h.left=`${(100*s).toFixed(2)}%`,h.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}static#fe(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return ue.#fe(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return ue.#fe(t,e,360-this.parentRotation)}#be(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions;this.div.style.width=`${(100*t/i).toFixed(2)}%`,this.#Jt||(this.div.style.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#Jt&&e.endsWith("%");if(s&&n)return;const[a,r]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/a).toFixed(2)}%`),this.#Jt||n||(t.height=`${(100*parseFloat(e)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#ve(){if(this.#Zt)return;this.#Zt=document.createElement("div"),this.#Zt.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#Zt.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#Ae.bind(this,i),{signal:e}),t.addEventListener("contextmenu",qt,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#Zt)}#Ae(t,e){e.preventDefault();const{isMac:i}=yt.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1;const n=new AbortController,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#ye.bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("contextmenu",qt,{signal:a});const r=this.x,o=this.y,l=this.width,h=this.height,c=this.parent.div.style.cursor,d=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const u=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=c,this.div.style.cursor=d,this.#we(r,o,l,h)};window.addEventListener("pointerup",u,{signal:a}),window.addEventListener("blur",u,{signal:a})}#we(t,e,i,s){const n=this.x,a=this.y,r=this.width,o=this.height;n===t&&a===e&&r===i&&o===s||this.addCommands({cmd:()=>{this.width=r,this.height=o,this.x=n,this.y=a;const[t,e]=this.parentDimensions;this.setDims(t*r,e*o),this.fixAndSetPosition()},undo:()=>{this.width=i,this.height=s,this.x=t,this.y=e;const[n,a]=this.parentDimensions;this.setDims(n*i,a*s),this.fixAndSetPosition()},mustExec:!0})}#ye(t,e){const[i,s]=this.parentDimensions,n=this.x,a=this.y,r=this.width,o=this.height,l=ue.MIN_SIZE/i,h=ue.MIN_SIZE/s,c=t=>Math.round(1e4*t)/1e4,d=this.#be(this.rotation),u=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],p=this.#be(360-this.rotation);let g,m,f=!1,b=!1;switch(t){case"topLeft":f=!0,g=(t,e)=>
2[0,0],m=(t,e)=>[t,e];break;case"topMiddle":g=(t,e)=>[t/2,0],m=(t,e)=>[t/2,e];break;case"topRight":f=!0,g=(t,e)=>[t,0],m=(t,e)=>[0,e];break;case"middleRight":b=!0,g=(t,e)=>[t,e/2],m=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,g=(t,e)=>[t,e],m=(t,e)=>[0,0];break;case"bottomMiddle":g=(t,e)=>[t/2,e],m=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,g=(t,e)=>[0,e],m=(t,e)=>[t,0];break;case"middleLeft":b=!0,g=(t,e)=>[0,e/2],m=(t,e)=>[t,e/2]}const v=g(r,o),A=m(r,o);let y=u(...A);const w=c(n+y[0]),x=c(a+y[1]);let _=1,C=1,[E,S]=this.screenToPageTranslation(e.movementX,e.movementY);var T,M;if([E,S]=(T=E/i,M=S/s,[p[0]*T+p[2]*M,p[1]*T+p[3]*M]),f){const t=Math.hypot(r,o);_=C=Math.max(Math.min(Math.hypot(A[0]-v[0]-E,A[1]-v[1]-S)/t,1/r,1/o),l/r,h/o)}else b?_=Math.max(l,Math.min(1,Math.abs(A[0]-v[0]-E)))/r:C=Math.max(h,Math.min(1,Math.abs(A[1]-v[1]-S)))/o;const k=c(r*_),R=c(o*C);y=u(...m(k,R));const P=w-y[0],I=x-y[1];this.width=k,this.height=R,this.x=P,this.y=I,this.setDims(i*k,s*R),this.fixAndSetPosition()}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#re||(this._editToolbar=new ie(this),this.div.append(this._editToolbar.render()),this.#o&&await this._editToolbar.addAltText(this.#o)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#o?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#o||(de.initialize(ue._l10n),this.#o=new de(this),this.#Kt&&(this.#o.data=this.#Kt,this.#Kt=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await(this.#o?.setGuessedText(t))}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#Qt?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#xe();const[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[i,s]=this.getInitialTranslation();return this.translate(i,s),ne(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=yt.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#se=!0,this._isDraggable?this.#_e(t):this.#Ce(t))}get isSelected(){return this._uiManager.isSelected(this)}#Ce(t){const{isMac:e}=yt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#_e(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();const i=new AbortController,s=this._uiManager.combinedSignal(i);if(e){this.div.classList.add("moving"),this.#he=t.clientX,this.#ce=t.clientY;const e=t=>{const{clientX:e,clientY:i}=t,[s,n]=this.screenToPageTranslation(e-this.#he,i-this.#ce);this.#he=e,this.#ce=i,this._uiManager.dragSelectedEditors(s,n)};window.addEventListener("pointermove",e,{passive:!0,capture:!0,signal:s})}const n=()=>{i.abort(),e&&this.div.classList.remove("moving"),this.#se=!1,this._uiManager.endDragSession()||this.#Ce(t)};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}moveInDOM(){this.#le&&clearTimeout(this.#le),this.#le=setTimeout((()=>{this.#le=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition()}getRect(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.rotation;const s=this.parentScale,[n,a]=this.pageDimensions,[r,o]=this.pageTranslation,l=t/s,h=e/s,c=this.x*n,d=this.y*a,u=this.width*n,p=this.height*a;switch(i){case 0:return[c+l+r,a-d-h-p+o,c+l+u+r,a-d-h+o];case 90:return[c+h+r,a-d+l+o,c+h+p+r,a-d+l+u+o];case 180:return[c-l-u+r,a-d+h+o,c-l+r,a-d+h+p+o];case 270:return[c-h-p+r,a-d-l-u+o,c-h+r,a-d-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,a]=t,r=n-i,o=a-s;switch(this.rotation){case 0:return[i,e-a,r,o];case 90:return[i,e-s,o,r];case 180:return[n,e-s,r,o];case 270:return[n,e-a,o,r];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#re=!0}disableEditMode(){this.#re=!1}isInEditMode(){return this.#re}shouldGetKeyboardEvents(){return this.#oe}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}#xe(){if(this.#ee||!this.div)return;this.#ee=new AbortController;const t=this._uiManager.combinedSignal(this.#ee);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#xe()}rotate(t){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(){at("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#Kt=t.accessibilityData;const[n,a]=s.pageDimensions,[r,o,l,h]=s.getRectInCurrentCoords(t.rect,a);return s.x=r/n,s.y=o/a,s.width=l/n,s.height=h/a,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#ee?.abort(),this.#ee=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#le&&(clearTimeout(this.#le),this.#le=null),this.#ge(),this.removeEditToolbar(),this.#de){for(const t of this.#de.values())clearTimeout(t);this.#de=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#ve(),this.#Zt.classList.remove("hidden"),ne(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#te={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#Zt.children;if(!this.#Yt){this.#Yt=Array.from(e);const t=this.#Ee.bind(this),i=this.#Se.bind(this),s=this._uiManager._signal;for(const e of this.#Yt){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Te.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",ue._l10nResizer[n])}}const i=this.#Yt[0];let s=0;for(const a of e){if(a===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#Yt.length/4);if(n!==s){if(n<s)for(let e=0;e<s-n;e++)this.#Zt.append(this.#Zt.firstChild);else if(n>s)for(let e=0;e<n-s;e++)this.#Zt.firstChild.before(this.#Zt.lastChild);let t=0;for(const i of e){const e=this.#Yt[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",ue._l10nResizer[e])}}this.#Me(0),this.#oe=!0,this.#Zt.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#Ee(t){ue._resizerKeyboardManager.exec(this,t)}#Se(t){this.#oe&&t.relatedTarget?.parentNode!==this.#Zt&&this.#ge()}#Te(t){this.#ie=this.#oe?t:""}#Me(t){if(this.#Yt)for(const e of this.#Yt)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#oe&&this.#ye(this.#ie,{movementX:t,movementY:e})}#ge(){if(this.#oe=!1,this.#Me(-1),this.#te){const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#te;this.#we(t,e,i,s),this.#te=null}}_stopResizingWithKeyboard(){this.#ge(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){this.#Zt?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#ae}set isEditing(t){this.#ae=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#Jt=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t){if(arguments.length>1&&void 0!==arguments[1]&&arguments[1]){this.#de||=new Map;const{action:e}=t;let i=this.#de.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#de.delete(e),0===this.#de.size&&(this.#de=null)}),ue._telemetryTimeout),void this.#de.set(e,i)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}
2show(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#Qt=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#Qt=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class pe extends ue{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const ge=3285377520,me=4294901760,fe=65535;class be{constructor(t){this.h1=t?4294967295&t:ge,this.h2=t?4294967295&t:ge}update(t){let e,i;if("string"===typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,a=new Uint32Array(e.buffer,0,s);let r=0,o=0,l=this.h1,h=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let g=0;g<s;g++)1&g?(r=a[g],r=r*c&me|r*u&fe,r=r<<15|r>>>17,r=r*d&me|r*p&fe,l^=r,l=l<<13|l>>>19,l=5*l+3864292196):(o=a[g],o=o*c&me|o*u&fe,o=o<<15|o>>>17,o=o*d&me|o*p&fe,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(r=0,n){case 3:r^=e[4*s+2]<<16;case 2:r^=e[4*s+1]<<8;case 1:r^=e[4*s],r=r*c&me|r*u&fe,r=r<<15|r>>>17,r=r*d&me|r*p&fe,1&s?l^=r:h^=r}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&me|36045*t&fe,e=4283543511*e&me|(2950163797*(e<<16|t>>>16)&me)>>>16,t^=e>>>1,t=444984403*t&me|60499*t&fe,e=3301882366*e&me|(3120437893*(e<<16|t>>>16)&me)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const ve=Object.freeze({map:null,hash:"",transfer:void 0});class Ae{#ke=!1;#Re=null;#Pe=(()=>new Map)();constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#Pe.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Pe.get(t)}remove(t){if(this.#Pe.delete(t),0===this.#Pe.size&&this.resetModified(),"function"===typeof this.onAnnotationEditor){for(const t of this.#Pe.values())if(t instanceof ue)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#Pe.get(t);let s=!1;if(void 0!==i)for(const[n,a]of Object.entries(e))i[n]!==a&&(s=!0,i[n]=a);else s=!0,this.#Pe.set(t,e);s&&this.#Ie(),e instanceof ue&&"function"===typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#Pe.has(t)}getAll(){return this.#Pe.size>0?At(this.#Pe):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#Pe.size}#Ie(){this.#ke||(this.#ke=!0,"function"===typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#ke&&(this.#ke=!1,"function"===typeof this.onResetModified&&this.onResetModified())}get print(){return new ye(this)}get serializable(){if(0===this.#Pe.size)return ve;const t=new Map,e=new be,i=[],s=Object.create(null);let n=!1;for(const[a,r]of this.#Pe){const i=r instanceof ue?r.serialize(!1,s):r;i&&(t.set(a,i),e.update(`${a}:${JSON.stringify(i)}`),n||=!!i.bitmap)}if(n)for(const a of t.values())a.bitmap&&i.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:ve}get editorStats(){let t=null;const e=new Map;for(const i of this.#Pe.values()){if(!(i instanceof ue))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const a=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=a.get(t);i||(i=new Map,a.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#Re=null}get modifiedIds(){if(this.#Re)return this.#Re;const t=[];for(const e of this.#Pe.values())e instanceof ue&&e.annotationElementId&&e.serialize()&&t.pu
2sh(e.annotationElementId);return this.#Re={ids:new Set(t),hash:t.join(",")}}}class ye extends Ae{#Le;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#Le={map:n,hash:i,transfer:s}}get print(){at("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#Le}get modifiedIds(){return lt(this,"modifiedIds",{ids:new Set,hash:""})}}class we{#De=(()=>new Set)();constructor(t){let{ownerDocument:e=globalThis.document,styleElement:i=null}=t;this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#De.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont(t){let{systemFontInfo:e,_inspectFont:i}=t;if(e&&!this.#De.has(e.loadedName))if(rt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:t,src:s,style:n}=e,a=new FontFace(t,s,n);this.addNativeFontFace(a);try{await a.load(),this.#De.add(t),i?.(e)}catch{nt(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}}else at("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw nt(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){return lt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(a||"undefined"!==typeof navigator&&"string"===typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),lt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(rt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return lt(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,a;const r=this._document.createElement("canvas");r.width=1,r.height=1;const o=r.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=s(c,976,h.length,h);const d=1482184792;let u=i(c,16);for(n=0,a=h.length-3;n<a;n+=4)u=u-d+i(h,n)|0;var p;n<h.length&&(u=u-d+i(h+"XXX",n)|0),c=s(c,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(g);const m=this._document.createElement("div");m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px";for(const f of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=f,m.append(t)}this._document.body.append(m),function t(e,i){if(++l>30)return nt("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,(()=>{m.remove(),e.complete()}
2))}}class xe{constructor(t,e){let{disableFontFace:i=!1,inspectFont:s=null}=e;this.compiledGlyphs=Object.create(null);for(const n in t)this[n]=t[n];this.disableFontFace=!0===i,this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(bt(e))});`;var e;let i;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${t}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),i}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let i;try{i=t.get(this.loadedName+"_path_"+e)}catch(n){nt(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(i)||0===i.length)return this.compiledGlyphs[e]=function(t,e){};const s=[];for(let a=0,r=i.length;a<r;)switch(i[a++]){case Tt:{const[t,e,n,r,o,l]=i.slice(a,a+6);s.push((i=>i.bezierCurveTo(t,e,n,r,o,l))),a+=6}break;case Mt:{const[t,e]=i.slice(a,a+2);s.push((i=>i.moveTo(t,e))),a+=2}break;case kt:{const[t,e]=i.slice(a,a+2);s.push((i=>i.lineTo(t,e))),a+=2}break;case Rt:{const[t,e,n,r]=i.slice(a,a+4);s.push((i=>i.quadraticCurveTo(t,e,n,r))),a+=4}break;case Pt:s.push((t=>t.restore()));break;case It:s.push((t=>t.save()));break;case Lt:rt(2===s.length,"Scale command is only valid at the third position.");break;case Dt:{const[t,e,n,r,o,l]=i.slice(a,a+6);s.push((i=>i.transform(t,e,n,r,o,l))),a+=6}break;case Ft:{const[t,e]=i.slice(a,a+2);s.push((i=>i.translate(t,e))),a+=2}}return this.compiledGlyphs[e]=function(t,e){s[0](t),s[1](t),t.scale(e,-e);for(let i=2,n=s.length;i<n;i++)s[i](t)}}}class _e{#Fe=!1;constructor(t){let{enableHWA:e=!1}=t;this.#Fe=e}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#Fe})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){at("Abstract method `_createCanvas` called.")}}class Ce{constructor(t){let{baseUrl:e=null,isCompressed:i=!0}=t;this.baseUrl=e,this.isCompressed=i}async fetch(t){let{name:e}=t;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 i=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(i).then((t=>({cMapData:t,isCompressed:this.isCompressed}))).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${i}`)}))}async _fetch(t){at("Abstract method `_fetch` called.")}}class Ee extends Ce{async _fetch(t){const e=await Bt(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):vt(e)}}class Se{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(){}}class Te{constructor(t){let{baseUrl:e=null}=t;this.baseUrl=e}async fetch(t){let{filename:e}=t;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 i=`${this.baseUrl}${e}`;return this._fetch(i).catch((t=>{throw new Error(`Unable to load font data at: ${i}`)}))}async _fetch(t){at("Abstract method `_fetch` called.")}}class Me extends Te{async _fetch(t){const e=await Bt(t,"arraybuffer");return new Uint8Array(e)}}if(a){var ke=Promise.withResolvers(),Re=null;(async()=>{const t=await import("fs"),e=await import("http"),i=await import("https"),s=await import("url");return new Map(Object.entries({fs:t,http:e,https:i,url:s,canvas:undefined,path2d:undefined}))})().then((t=>{Re=t,ke.resolve()}),(t=>{nt(`loadPackages: ${t}`),Re=new Map,ke.resolve()}))}class Pe{static get promise(){return ke.promise}static get(t){return Re?.get(t)}}async function Ie(t){const e=Pe.get("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}const Le="Fill",De="Stroke",Fe="Shading";function Ne(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class Oe{getPattern(){at("Abstract method `getPattern` called.")}}class Be extends Oe{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const i of this._colorStops)e.addColorStop(i[0],i[1]);return e}getPattern(t,e,i,s){let n;if(s===De||s===Le){const a=e.current.getClippedPathBoundingBox(s,Jt(t))||[0,0,0,0],r=M
vendor: 4,595 bytes, line 2
2ath.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.cachedCanvases.getCanvas("pattern",r,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-a[0],-a[1]),i=xt.transform(i,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),Ne(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const c=new DOMMatrix(i);n.setTransform(c)}else Ne(t,this._bbox),n=this._createGradient(t);return n}}function ze(t,e,i,s,n,a,r,o){const l=e.coords,h=e.colors,c=t.data,d=4*t.width;let u;l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=a,a=r,r=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=r,r=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=a,a=r,r=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,m=(l[s]+e.offsetX)*e.scaleX,f=(l[s+1]+e.offsetY)*e.scaleY,b=(l[n]+e.offsetX)*e.scaleX,v=(l[n+1]+e.offsetY)*e.scaleY;if(g>=v)return;const A=h[a],y=h[a+1],w=h[a+2],x=h[r],_=h[r+1],C=h[r+2],E=h[o],S=h[o+1],T=h[o+2],M=Math.round(g),k=Math.round(v);let R,P,I,L,D,F,N,O;for(let B=M;B<=k;B++){if(B<f){const t=B<g?0:(g-B)/(g-f);R=p-(p-m)*t,P=A-(A-x)*t,I=y-(y-_)*t,L=w-(w-C)*t}else{let t;t=B>v?1:f===v?0:(f-B)/(f-v),R=m-(m-b)*t,P=x-(x-E)*t,I=_-(_-S)*t,L=C-(C-T)*t}let t;t=B<g?0:B>v?1:(g-B)/(g-v),D=p-(p-b)*t,F=A-(A-E)*t,N=y-(y-S)*t,O=w-(w-T)*t;const e=Math.round(Math.min(R,D)),i=Math.round(Math.max(R,D));let s=d*B+4*e;for(let n=e;n<=i;n++)t=(R-n)/(R-D),t<0?t=0:t>1&&(t=1),c[s++]=P-(P-F)*t|0,c[s++]=I-(I-N)*t|0,c[s++]=L-(L-O)*t|0,c[s++]=255}}function He(t,e,i){const s=e.coords,n=e.colors;let a,r;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(a=0;a<l;a++){let e=a*o;for(let a=0;a<h;a++,e++)ze(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),ze(t,i,s[e+o+1],s[e+1],s[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(a=0,r=s.length;a<r;a+=3)ze(t,i,s[a],s[a+1],s[a+2],n[a],n[a+1],n[a+2]);break;default:throw new Error("illegal figure")}}class je extends Oe{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-s,r=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(r*t[1]*1.1)),3e3),h=a/o,c=r/l,d={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/c},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),m=g.context,f=m.createImageData(o,l);if(e){const t=f.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const b of this._figures)He(f,b,d);m.putImageData(f,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*c,scaleX:h,scaleY:c}}getPattern(t,e,i,s){let n;if(Ne(t,this._bbox),s===Fe)n=xt.singularValueDecompose2dScale(Jt(t));else if(n=xt.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=xt.singularValueDecompose2dScale(this.matrix);n=[n[0]*t[0],n[1]*t[1]]}const a=this._createMeshCanvas(n,s===Fe?null:this._background,e.cachedCanvases);return s!==Fe&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class Ue extends Oe{getPattern(){return"hotpink"}}const $e=1,Ge=2;class Ve{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=n}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:a,canvasGraphicsFactory:r}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),st("TilingType: "+n);const h=e[0],c=e[1],d=e[2],u=e[3],p=d-h,g=u-c,m=xt.singularValueDecompose2dScale(this.matrix),f=xt.singularValueDecompose2dScale(this.baseTransform),b=m[0]*f[0],v=m[1]*f[1];let A=p,y=g,w=!1,x=!1;const _=Math.ceil(o*b),C=Math.ceil(l*v);_>=Math.ceil(p*b)?A=o:w=!0,C>=Math.ceil(g*v)?y=l:x=!0;const E=this.getSizeAndScale(A,this.ctx.canvas.width,b),S=this.getSizeAndScale(y,this.ctx.canvas.height,v),T=t.cachedCanvases.getCanvas("pattern",E.size,S.size),M=T.context,k=r.createCanvasGraphics(M);if(k.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(k,s,a),M.translate(-E.scale*h,-S.scale*c),k.transform(E.scale,0,0,S.scale,0,0),M.save(),this.clipBbox(k,h,c,d,u),k.baseTransform=Jt(k.ctx),k.executeOperatorList(i),k.endDrawing(),M.restore(
2),w||x){const e=T.canvas;w&&(A=o),x&&(y=l);const i=this.getSizeAndScale(A,this.ctx.canvas.width,b),s=this.getSizeAndScale(y,this.ctx.canvas.height,v),n=i.size,a=s.size,r=t.cachedCanvases.getCanvas("pattern-workaround",n,a),d=r.context,u=w?Math.floor(p/o):0,m=x?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=m;i++)d.drawImage(e,n*t,a*i,n,a,0,0,n,a);return{canvas:r.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:c}}return{canvas:T.canvas,scaleX:E.scale,scaleY:S.scale,offsetX:h,offsetY:c}}getSizeAndScale(t,e,i){const s=Math.max(Ve.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){const a=s-e,r=n-i;t.ctx.rect(e,i,a,r),t.current.updateRectMinMax(Jt(t.ctx),[e,i,s,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case $e:const t=this.ctx;s.fillStyle=t.fillStyle,s.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case Ge:const a=xt.makeHexColor(i[0],i[1],i[2]);s.fillStyle=a,s.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new mt(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let n=i;s!==Fe&&(n=xt.transform(n,e.baseTransform),this.matrix&&(n=xt.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let r=new DOMMatrix(n);r=r.translate(a.offsetX,a.offsetY),r=r.scale(1/a.scaleX,1/a.scaleY);const o=t.createPattern(a.canvas,"repeat");return o.setTransform(r),o}}function We(t){let{src:e,srcPos:i=0,dest:s,width:n,height:a,nonBlackColor:r=4294967295,inverseDecode:o=!1}=t;const l=yt.isLittleEndian?4278190080:255,[h,c]=o?[r,l]:[l,r],d=n>>3,u=7&n,p=e.length;s=new Uint32Array(s.buffer);let g=0;for(let m=0;m<a;m++){for(const n=i+d;i<n;i++){const t=i<p?e[i]:255;s[g++]=128&t?c:h,s[g++]=64&t?c:h,s[g++]=32&t?c:h,s[g++]=16&t?c:h,s[g++]=8&t?c:h,s[g++]=4&t?c:h,s[g++]=2&t?c:h,s[g++]=1&t?c:h}if(0===u)continue;const t=i<p?e[i++]:255;for(let e=0;e<u;e++)s[g++]=t&1<<7-e?c:h}return{srcPos:i,destPos:g}}const qe=16;class Xe{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Ke(t,e,i,s,n,a,r,o,l,h){const[c,d,u,p,g,m]=Jt(t);if(0===d&&0===u){const f=r*c+g,b=Math.round(f),v=o*p+m,A=Math.round(v),y=(r+l)*c+g,w=Math.abs(Math.round(y)-b)||1,x=(o+h)*p+m,_=Math.abs(Math.round(x)-A)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),b,A),t.drawImage(e,i,s,n,a,0,0,w,_),t.setTransform(c,d,u,p,g,m),[w,_]}if(0===c&&0===p){const f=o*u+g,b=Math.round(f),v=r*d+m,A=Math.round(v),y=(o+h)*u+g,w=Math.abs(Math.round(y)-b)||1,x=(r+l)*d+m,_=Math.abs(Math.round(x)-A)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,b,A),t.drawImage(e,i,s,n,a,0,0,_,w),t.setTransform(c,d,u,p,g,m),[_,w]}t.drawImage(e,i,s,n,a,r,o,l,h);return[Math.hypot(c,d)*l,Math.hypot(u,p)*h]}class Ye{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=r,this.textMatrixScale=1,this.fontMatrix=o,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=w,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=xt.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){const i=xt.applyTransform(e,t),s=xt.applyTransform(e.slice(2),t),n=xt.applyTransform([e[0],e[3]],t),a=xt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],n[0],a[0]),this.minY=Math.min(this.minY,i[1],s[1],n[1],a[1]),this.maxX=Math.max(this.maxX,i[0],s[0],n[0],a[0]),this.maxY=Math.max(this.maxY,i[1],s[1],n[1],a[1])}updateScalingPathMinMax(t,e){xt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,n,a,r,o,l,h){const c=xt.bezierBoundingBox(e,i,s,n,a,r,o,l,h);h||this.updateRectMinMax(t,c)}getPathBoundingBox(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Le,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=[this.minX,this.minY,this.maxX,this.maxY];if(t===De){e||at("Stroke bounding box must include transform.");const t=xt.singularValueDecompose2dScale(e),s=t[0]*this.lineWidth/2,n=t[1]*this.lineWidth/2;i[0]-=s,i[1]-=n,i[2]+=s,i[3]+=n}return i}updateClipFromPath(){const t=xt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Le,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return xt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Qe(t,e){if("undefined"!==typeof ImageData&&e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%qe,a=(i-n)/qe,r=0===n?a:a+1,o=t.createImageData(s,qe);let l,h=0;const c=e.data,d=o.data;let u,p,g,m;if(e.kind===T.GRAYSCALE_1BPP){const e=c.byteLength,i=new Uint32Array(d.buffer,0,d.byteLength>>2),m=i.length,f=s+7>>3,b=4294967295,v=yt.isLittleEndian?4278190080:255;for(u=0;
2u<r;u++){for(g=u<a?qe:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const a=t>f?s:8*t-7,r=-8&a;let o=0,d=0;for(;n<r;n+=8)d=c[h++],i[l++]=128&d?b:v,i[l++]=64&d?b:v,i[l++]=32&d?b:v,i[l++]=16&d?b:v,i[l++]=8&d?b:v,i[l++]=4&d?b:v,i[l++]=2&d?b:v,i[l++]=1&d?b:v;for(;n<a;n++)0===o&&(d=c[h++],o=128),i[l++]=d&o?b:v,o>>=1}for(;l<m;)i[l++]=0;t.putImageData(o,0,u*qe)}}else if(e.kind===T.RGBA_32BPP){for(p=0,m=s*qe*4,u=0;u<a;u++)d.set(c.subarray(h,h+m)),h+=m,t.putImageData(o,0,p),p+=qe;u<r&&(m=s*n*4,d.set(c.subarray(h,h+m)),t.putImageData(o,0,p))}else{if(e.kind!==T.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=qe,m=s*g,u=0;u<r;u++){for(u>=a&&(g=n,m=s*g),l=0,p=m;p--;)d[l++]=c[h++],d[l++]=c[h++],d[l++]=c[h++],d[l++]=255;t.putImageData(o,0,u*qe)}}}function Je(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%qe,a=(i-n)/qe,r=0===n?a:a+1,o=t.createImageData(s,qe);let l=0;const h=e.data,c=o.data;for(let d=0;d<r;d++){const e=d<a?qe:n;({srcPos:l}=We({src:h,srcPos:l,dest:c,width:s,height:e,nonBlackColor:0})),t.putImageData(o,0,d*qe)}}function Ze(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function ti(t){if(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",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!a){const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function ei(t,e){if(e)return!0;const i=xt.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*Ot.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}const ii=["butt","round","square"],si=["miter","round","bevel"],ni={},ai={};class ri{constructor(t,e,i,s,n,a,r,o){let{optionalContentConfig:l,markedContentStack:h=null}=a;this.ctx=t,this.current=new Ye(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=h||[],this.optionalContentConfig=l,this.cachedCanvases=new Xe(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=r,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=o,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return"string"===typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing(t){let{transform:e,viewport:i,transparency:s=!1,background:n=null}=t;const a=this.ctx.canvas.width,r=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,a,r),this.ctx.fillStyle=o,s){const t=this.cachedCanvases.getCanvas("transparent",a,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Jt(this.compositeCtx))}this.ctx.save(),ti(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...i.transform),this.viewportScale=i.scale,this.baseTransform=Jt(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,a=t.fnArray;let r=e||0;const o=n.length;if(o===r)return r;const l=o-r>10&&"function"===typeof i,h=l?Date.now()+15:0;let c=0;const d=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==s&&r===s.nextBreakPoint)return s.breakIt(r,i),r;if(p=a[r],p!==J.dependency)this[p].apply(this,n[r]);else for(const t of n[r]){const e=t.startsWith("g_")?d:u;if(!e.has(t))return e.get(t,i),r}if(r++,r===o)return r;if(l&&++c>10){if(Date.now()>h)return i(),r;c=0}}}#Ne(){for(;this.stateStack.length||this.inSMaskMode;
2)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)}endDrawing(){this.#Ne(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#Oe()}#Oe(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,a,r=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=s,c="prescale1";for(;r>2&&l>1||o>2&&h>1;){let e=l,i=h;r>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),r/=l/e),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),n=this.cachedCanvases.getCanvas(c,e,i),a=n.context,a.clearRect(0,0,e,i),a.drawImage(t,0,0,l,h,0,0,e,i),t=n.canvas,l=e,h=i,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,a=this.current.patternFill,r=Jt(e);let o,l,h,c;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(a?r:[r.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const i=o.get(l);if(i&&!a){return{canvas:i,offsetX:Math.round(Math.min(r[0],r[2])+r[4]),offsetY:Math.round(Math.min(r[1],r[3])+r[5])}}h=i}h||(c=this.cachedCanvases.getCanvas("maskCanvas",i,s),Je(c.context,t));let d=xt.transform(r,[1/i,0,0,-1/s,0,0]);d=xt.transform(d,[1,0,0,1,0,-s]);const[u,p,g,m]=xt.getAxialAlignedBoundingBox([0,0,i,s],d),f=Math.round(g-u)||1,b=Math.round(m-p)||1,v=this.cachedCanvases.getCanvas("fillCanvas",f,b),A=v.context,y=u,w=p;A.translate(-y,-w),A.transform(...d),h||(h=this._scaleImage(c.canvas,Zt(A)),h=h.img,o&&a&&o.set(l,h)),A.imageSmoothingEnabled=ei(Jt(A),t.interpolate),Ke(A,h,0,0,h.width,h.height,0,0,i,s),A.globalCompositeOperation="source-in";const x=xt.transform(Zt(A),[1,0,0,1,-y,-w]);return A.fillStyle=a?n.getPattern(e,this,x,Le):n,A.fillRect(0,0,i,s),o&&!a&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,v.canvas)),{canvas:v.canvas,offsetX:Math.round(y),offsetY:Math.round(w)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=ii[t]}setLineJoin(t){this.ctx.lineJoin=si[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i,this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;const n=this.ctx;n.setTransform(...Jt(this.suspendedCtx)),Ze(this.suspendedCtx,n),function(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()}
2,t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,a,r){e.transform(t,i,s,n,a,r),this.__originalTransform(t,i,s,n,a,r)},t.setTransform=function(t,i,s,n,a,r){e.setTransform(t,i,s,n,a,r),this.__originalSetTransform(t,i,s,n,a,r)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,a,r){e.bezierCurveTo(t,i,s,n,a,r),this.__originalBezierCurveTo(t,i,s,n,a,r)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Ze(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),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(t,e,i,s){const n=s[0],a=s[1],r=s[2]-n,o=s[3]-a;0!==r&&0!==o&&(this.genericComposeSMask(e.context,i,r,o,e.subtype,e.backdrop,e.transferMap,n,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,a,r,o,l,h,c){let d=t.canvas,u=o-h,p=l-c;if(a){const e=xt.makeHexColor(...a);if(u<0||p<0||u+i>d.width||p+s>d.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),n=t.context;n.drawImage(d,-u,-p),n.globalCompositeOperation="destination-atop",n.fillStyle=e,n.fillRect(0,0,i,s),n.globalCompositeOperation="source-over",d=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const n=new Path2D;n.rect(u,p,i,s),t.clip(n),t.globalCompositeOperation="destination-atop",t.fillStyle=e,t.fillRect(u,p,i,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&r?e.filter=this.filterFactory.addAlphaFilter(r):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(r));const g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(d,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode?(Ze(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Ze(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,n,a){this.ctx.transform(t,e,i,s,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){const s=this.ctx,n=this.current;let a,r,o=n.x,l=n.y;const h=Jt(s),c=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],d=c?i.slice(0):null;for(let u=0,p=0,g=t.length;u<g;u++)switch(0|t[u]){case J.rectangle:o=e[p++],l=e[p++];const t=e[p++],i=e[p++],u=o+t,g=l+i;s.moveTo(o,l),0===t||0===i?s.lineTo(u,g):(s.lineTo(u,l),s.lineTo(u,g),s.lineTo(o,g)),c||n.updateRectMinMax(h,[o,l,u,g]),s.closePath();break;case J.moveTo:o=e[p++],l=e[p++],s.moveTo(o,l),c||n.updatePathMinMax(h,o,l);break;case J.lineTo:o=e[p++],l=e[p++],s.lineTo(o,l),c||n.updatePathMinMax(h,o,l);break;case J.curveTo:a=o,r=l,o=e[p+4],l=e[p+5],s.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],o,l),n.updateCurvePathMinMax(h,a,r,e[p],e[p+1],e[p+2],e[p+3],o,l,d),p+=6;break;case J.curveTo2:a=o,r=l,s.bezierCurveTo(o,l,e[p],e[p+1],e[p+2],e[p+3]),n.updateCurvePathMinMax(h,a,r,o,l,e[p],e[p+1],e[p+2],e[p+3],d),o=e[p+2],l=e[p+3],p+=4;break;case J.curveTo3:a=o,r=l,o=e[p+2],l=e[p+3],s.bezierCurveTo(e[p],e[p+1],o,l,o,l),n.updateCurvePathMinMax(h,a,r,e[p],e[p+1],o,l,o,l,d),p+=4;break;case J.closePath:s.closePath()}c&&n.updateScalingPathMinMax(h,d),n.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"===typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,Zt(e),De),this.rescaleAndStroke(!1),e.restore(
2)):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(){let t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];const e=this.ctx,i=this.current.fillColor;let s=!1;this.current.patternFill&&(e.save(),e.fillStyle=i.getPattern(e,this,Zt(e),Le),s=!0);const n=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==n&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),s&&e.restore(),t&&this.consumePath(n)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=ni}eoClip(){this.pendingClip=ai}beginText(){this.current.textMatrix=r,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0!==t){e.save(),e.beginPath();for(const i of t)e.setTransform(...i.transform),e.translate(i.x,i.y),i.addToPath(e,i.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||o,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||nt("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",a=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let r="normal";i.black?r="900":i.bold&&(r="bold");const l=i.italic?"italic":"normal";let h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font=`${l} ${r} ${h}px ${a}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,s,n,a){this.current.textMatrix=[t,e,i,s,n,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,i,s){const n=this.ctx,a=this.current,r=a.font,o=a.textRenderingMode,l=a.fontSize/a.fontSizeScale,h=o&E,c=!!(o&S),d=a.patternFill&&!r.missingFile;let u;if((r.disableFontFace||c||d)&&(u=r.getPathGenerator(this.commonObjs,t)),r.disableFontFace||d?(n.save(),n.translate(e,i),n.beginPath(),u(n,l),s&&n.setTransform(...s),h!==w&&h!==_||n.fill(),h!==x&&h!==_||n.stroke(),n.restore()):(h!==w&&h!==_||n.fillText(t,e,i),h!==x&&h!==_||n.strokeText(t,e,i)),c){(this.pendingTextPaths||=[]).push({transform:Jt(n),x:e,y:i,fontSize:l,addToPath:u})}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let s=3;s<e.length;s+=4)if(e[s]>0&&e[s]<255){i=!0;break}return lt(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(0===s)return;const n=this.ctx,a=e.fontSizeScale,r=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,h=e.textHScale*l,c=t.length,d=i.vertical,u=d?1:-1,p=i.defaultVMetrics,g=s*e.fontMatrix[0],m=e.textRenderingMode===w&&!i.disableFontFace&&!e.patternFill;let f;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,Zt(n),Le);f=Jt(n),n.restore(),n.fillStyle=t}let b=e.lineWidth;const v=e.textMatrixScale;if(0===v||0===b){const t=e.textRenderingMode&E;t!==x&&t!==_||(b=this.getSinglePixelWidth())}else b/=v;if(1!==a&&(n.scale(a,a),b/=a),n.lineWidth=b,i.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t)i.push(e.unicode),s+=e.width;
2return n.fillText(i.join(""),0,0),e.x+=s*g*h,n.restore(),void this.compose()}let A,y=0;for(A=0;A<c;++A){const e=t[A];if("number"===typeof e){y+=u*e*s/1e3;continue}let h=!1;const c=(e.isSpace?o:0)+r,b=e.fontChar,v=e.accent;let w,x,_=e.width;if(d){const t=e.vmetric||p,i=-(e.vmetric?t[1]:.5*_)*g,s=t[2]*g;_=t?-t[0]:_,w=i/a,x=(y+s)/a}else w=y/a,x=0;if(i.remeasure&&_>0){const t=1e3*n.measureText(b).width/s*a;if(_<t&&this.isFontSubpixelAAEnabled){const e=_/t;h=!0,n.save(),n.scale(e,1),w/=e}else _!==t&&(w+=(_-t)/2e3*s/a)}if(this.contentVisible&&(e.isInFont||i.missingFile))if(m&&!v)n.fillText(b,w,x);else if(this.paintChar(b,w,x,f),v){const t=w+s*v.offset.x/a,e=x-s*v.offset.y/a;this.paintChar(v.fontChar,t,e,f)}y+=d?_*g-c*l:_*g+c*l,h&&n.restore()}d?e.y-=y:e.x+=y*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,a=i.fontDirection,r=s.vertical?1:-1,l=i.charSpacing,h=i.wordSpacing,c=i.textHScale*a,d=i.fontMatrix||o,u=t.length;let p,g,m,f;if(!(i.textRenderingMode===C)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...i.textMatrix),e.translate(i.x,i.y),e.scale(c,a),p=0;p<u;++p){if(g=t[p],"number"===typeof g){f=r*g*n/1e3,this.ctx.translate(f,0),i.x+=f*c;continue}const a=(g.isSpace?h:0)+l,o=s.charProcOperatorList[g.operatorListId];if(!o){nt(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(o),this.restore());m=xt.applyTransform([g.width,0],d)[0]*n+a,e.translate(m,0),i.x+=m*c}e.restore(),this.processingType3=null}}setCharWidth(t,e){}
2setCharWidthAndBounds(t,e,i,s,n,a){this.ctx.rect(i,s,n-i,a-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=t[1],s=this.baseTransform||Jt(this.ctx),n={createCanvasGraphics:t=>new ri(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ve(t,i,this.ctx,n,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=xt.makeHexColor(t,e,i)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(t,e,i){this.ctx.fillStyle=this.current.fillColor=xt.makeHexColor(t,e,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t){let e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return this.cachedPatterns.has(t)?e=this.cachedPatterns.get(t):(e=function(t){switch(t[0]){case"RadialAxial":return new Be(t);case"Mesh":return new je(t);case"Dummy":return new Ue}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,e)),i&&(e.matrix=i),e}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,Zt(e),Fe);const s=Zt(e);if(s){const{width:t,height:i}=e.canvas,[n,a,r,o]=xt.getAxialAlignedBoundingBox([0,0,t,i],s);this.ctx.fillRect(n,a,r-n,o-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){at("Should not call beginInlineImage")}beginImageData(){at("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Jt(this.ctx),e)){const t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i),this.current.updateRectMinMax(Jt(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;
2t.isolated||st("TODO: Support non-isolated groups."),t.knockout&&nt("Knockout groups not supported.");const i=Jt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=xt.getAxialAlignedBoundingBox(t.bbox,Jt(e));const n=[0,0,e.canvas.width,e.canvas.height];s=xt.intersect(s,n)||[0,0,0,0];const a=Math.floor(s[0]),r=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-a,1),l=Math.max(Math.ceil(s[3])-r,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(h,o,l),d=c.context;d.translate(-a,-r),d.transform(...i),t.smask?this.smaskStack.push({canvas:c.canvas,context:d,offsetX:a,offsetY:r,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,r),e.save()),Ze(e,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=Jt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=xt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#Ne(),ti(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=a;
2const[n,r]=xt.singularValueDecompose2dScale(Jt(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(a*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,h);const{canvas:c,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(t,c),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(n,0,0,-r,0,a*r),ti(this.ctx)}else ti(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new Ye(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#Oe(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this.processingType3;if(s&&(void 0===s.compiled&&(s.compiled=function(t){const{width:e,height:i}=t;if(e>1e3||i>1e3)return null;const s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1;let a,r,o,l=new Uint8Array(n*(i+1));const h=e+7&-8;let c=new Uint8Array(h*i),d=0;for(const m of t.data){let t=128;for(;t>0;)c[d++]=m&t?0:255,t>>=1}let u=0;for(d=0,0!==c[d]&&(l[0]=1,++u),r=1;r<e;r++)c[d]!==c[d+1]&&(l[r]=c[d]?2:1,++u),d++;for(0!==c[d]&&(l[r]=2,++u),a=1;a<i;a++){d=a*h,o=a*n,c[d-h]!==c[d]&&(l[o]=c[d]?1:8,++u);let t=(c[d]?4:0)+(c[d-h]?8:0);for(r=1;r<e;r++)t=(t>>2)+(c[d+1]?4:0)+(c[d-h+1]?8:0),s[t]&&(l[o+r]=s[t],++u),d++;if(c[d-h]!==c[d]&&(l[o+r]=c[d]?2:4,++u),u>1e3)return null}for(d=h*(i-1),o=a*n,0!==c[d]&&(l[o]=8,++u),r=1;r<e;r++)c[d]!==c[d+1]&&(l[o+r]=c[d]?4:8,++u),d++;if(0!==c[d]&&(l[o+r]=4,++u),u>1e3)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;u&&a<=i;a++){let t=a*n;const i=t+e;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%n,a);const s=t;let r=l[t];do{const e=p[r];do{t+=e}while(!l[t]);const i=l[t];5!==i&&10!==i?(r=i,l[t]=0):(r=i&51*r>>4,l[t]&=r>>2|r<<2),g.lineTo(t%n,t/n|0),l[t]||--u}while(s!==t);--a}return c=null,l=null,function(t){t.save(),t.scale(1/e,-1/i),t.translate(0,-i),t.fill(g),t.beginPath(),t.restore()}}(t)),s.compiled))return void s.compiled(i);const n=this._createMaskCanvas(t),a=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(a,n.offsetX,n.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4?arguments[4]:void 0,a=arguments.length>5?arguments[5]:void 0;if(!this.contentVisible)return;t=this.getObject(t.data,t);const r=this.ctx;r.save();const o=Jt(r);r.transform(e,i,s,n,0,0);const l=this._createMaskCanvas(t);r.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let h=0,c=a.length;h<c;h+=2){const t=xt.transform(o,[e,i,s,n,a[h],a[h+1]]),[c,d]=xt.applyTransform([0,0],t);r.drawImage(l.canvas,c,d)}r.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:t,width:a,height:r,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",a,r),h=l.context;h.save();Je(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,Zt(e),Le):i,h.fillRect(0,0,a,r),h.restore(
2),e.save(),e.transform(...o),e.scale(1,-1),Ke(e,l.canvas,0,0,a,r,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):nt("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void nt("Dependent image isn't ready yet");const a=n.width,r=n.height,o=[];for(let l=0,h=s.length;l<h;l+=2)o.push({transform:[e,0,0,i,s[l],s[l+1]],x:0,y:0,w:a,h:r});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),a=n.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;if(this.save(),!a){const{filter:t}=s;"none"!==t&&""!==t&&(s.filter="none")}let n;if(s.scale(1/e,-1/i),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if("function"===typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;Qe(s,t),n=this.applyTransferMapsToCanvas(s)}const r=this._scaleImage(n,Zt(s));s.imageSmoothingEnabled=ei(Jt(s),t.interpolate),Ke(s,r.img,0,0,r.paintWidth,r.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const e=t.width,i=t.height,n=this.cachedCanvases.getCanvas("inlineImage",e,i).context;Qe(n,t),s=this.applyTransferMapsToCanvas(n)}for(const n of e)i.save(),i.transform(...n.transform),i.scale(1,-1),Ke(i,s,n.x,n.y,n.w,n.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const i=this.ctx;this.pendingClip&&(e||(this.pendingClip===ai?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Jt(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let a,r;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)a=r=1/i;else{const e=i*t;a=r=e<1?1/e:1}else if(0===t)a=1/i,r=1/s;else{const e=i*t,n=s*t;a=e<1?1/e:1,r=n<1?1/n:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),h=Math.hypot(s,n);if(0===t)a=h/o,r=l/o;else{const e=t*o;a=h>e?h/e:1,r=l>e?l/e:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=r}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:i}=this.current,[s,n]=this.getScaleForStroking();if(e.lineWidth=i||1,1===s&&1===n)return void e.stroke();const a=e.getLineDash();if(t&&e.save(),e.scale(s,n),a.length>0){const t=Math.max(s,n);e.setLineDash(a.map((e=>e/t))),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const Cn in J)void 0!==ri.prototype[Cn]&&(ri.prototype[J[Cn]]=ri.prototype[Cn]
2);class oi{static#Be=null;static#ze="";static get workerPort(){return this.#Be}static set workerPort(t){if(!("undefined"!==typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#Be=t}static get workerSrc(){return this.#ze}static set workerSrc(t){if("string"!==typeof t)throw new Error("Invalid `workerSrc` type.");this.#ze=t}}const li=1,hi=2,ci=1,di=2,ui=3,pi=4,gi=5,mi=6,fi=7,bi=8;function vi(t){switch(t instanceof Error||"object"===typeof t&&null!==t||at('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new ft(t.message);case"MissingPDFException":return new pt(t.message);case"PasswordException":return new ct(t.message,t.code);case"UnexpectedResponseException":return new gt(t.message,t.status);case"UnknownErrorException":return new dt(t.message,t.details);default:return new dt(t.message,t.toString())}}class Ai{#He=(()=>new AbortController)();constructor(t,e,i){this.sourceName=t,this.targetName=e,this.comObj=i,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),i.addEventListener("message",this.#je.bind(this),{signal:this.#He.signal})}#je(t){let{data:e}=t;if(e.targetName!==this.sourceName)return;if(e.stream)return void this.#Ue(e);if(e.callback){const t=e.callbackId,i=this.callbackCapabilities[t];if(!i)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],e.callback===li)i.resolve(e.data);else{if(e.callback!==hi)throw new Error("Unexpected callback case");i.reject(vi(e.reason))}return}const i=this.actionHandler[e.action];if(!i)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const t=this.sourceName,s=e.sourceName,n=this.comObj;new Promise((function(t){t(i(e.data))})).then((function(i){n.postMessage({sourceName:t,targetName:s,callback:li,callbackId:e.callbackId,data:i})}),(function(i){n.postMessage({sourceName:t,targetName:s,callback:hi,callbackId:e.callbackId,reason:vi(i)})}))}else e.streamId?this.#$e(e):i(e.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(a){n.reject(a)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,a=this.sourceName,r=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:r,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:a,targetName:r,stream:mi,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{rt(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:a,targetName:r,stream:ci,streamId:n,reason:vi(t)}),e.promise}},i)}#$e(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,a=this,r=this.actionHandler[t.action],o={enqueue(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2?arguments[2]:void 0;if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:pi,streamId:e,chunk:t},r)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:ui,streamId:e}),delete a.streamSinks[e])},error(t){rt(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:gi,streamId:e,reason:vi(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,new Promise((function(e){e(r(t.data,o))})).then((function(){n.postMessage({sourceName:i,targetName:s,stream:bi,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:bi,streamId:e,reason:vi(t)})}
2))}#Ue(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,a=this.streamControllers[e],r=this.streamSinks[e];switch(t.stream){case bi:t.success?a.startCall.resolve():a.startCall.reject(vi(t.reason));break;case fi:t.success?a.pullCall.resolve():a.pullCall.reject(vi(t.reason));break;case mi:if(!r){n.postMessage({sourceName:i,targetName:s,stream:fi,streamId:e,success:!0});break}r.desiredSize<=0&&t.desiredSize>0&&r.sinkCapability.resolve(),r.desiredSize=t.desiredSize,new Promise((function(t){t(r.onPull?.())})).then((function(){n.postMessage({sourceName:i,targetName:s,stream:fi,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:fi,streamId:e,reason:vi(t)})}));break;case pi:if(rt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case ui:if(rt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#Ge(a,e);break;case gi:rt(a,"error should have stream controller"),a.controller.error(vi(t.reason)),this.#Ge(a,e);break;case di:t.success?a.cancelCall.resolve():a.cancelCall.reject(vi(t.reason)),this.#Ge(a,e);break;case ci:if(!r)break;new Promise((function(e){e(r.onCancel?.(vi(t.reason)))})).then((function(){n.postMessage({sourceName:i,targetName:s,stream:di,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:di,streamId:e,reason:vi(t)})})),r.sinkCapability.reject(vi(t.reason)),r.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#Ge(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#He?.abort(),this.#He=null}}class yi{#Ve;#We;constructor(t){let{parsedData:e,rawData:i}=t;this.#Ve=e,this.#We=i}getRaw(){return this.#We}get(t){return this.#Ve.get(t)??null}getAll(){return At(this.#Ve)}has(t){return this.#Ve.has(t)}}const wi=Symbol("INTERNAL");class xi{#qe=!1;#Xe=!1;#Ke=!1;#Ye=!0;constructor(t,e){let{name:i,intent:s,usage:n,rbGroups:a}=e;this.#qe=!!(t&c),this.#Xe=!!(t&d),this.name=i,this.intent=s,this.usage=n,this.rbGroups=a}get visible(){if(this.#Ke)return this.#Ye;if(!this.#Ye)return!1;const{print:t,view:e}=this.usage;return this.#qe?"OFF"!==e?.viewState:!this.#Xe||"OFF"!==t?.printState}_setVisible(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t!==wi&&at("Internal method `_setVisible` called."),this.#Ke=i,this.#Ye=e}}class _i{#Qe=null;#Je=(()=>new Map)();#Ze=null;#ti=null;constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c;if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#ti=t.order;for(const i of t.groups)this.#Je.set(i.id,new xi(e,i));if("OFF"===t.baseState)for(const t of this.#Je.values())t._setVisible(wi,!1);for(const e of t.on)this.#Je.get(e)._setVisible(wi,!0);for(const e of t.off)this.#Je.get(e)._setVisible(wi,!1);this.#Ze=this.getHash()}}#ei(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#ei(e);else{if(!this.#Je.has(e))return nt(`Optional content group not found: ${e}`),!0;n=this.#Je.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#Je.size)return!0;if(!t)return st("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Je.has(t.id)?this.#Je.get(t.id).visible:(nt(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#ei(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Je.has(e))return nt(`Optional content group not found: ${e}`),!0;if(this.#Je.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Je.has(e))return nt(`Optional content group not found: ${e}`),!0;if(!this.#Je.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Je.has(e))return nt(`Optional content group not found: ${e}`),!0;if(!this.#Je.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Je.has(e))return nt(`Optional content group not found: ${e}`),!0;if(this.#Je.get(e).visible)return!1}return!0}return nt(`Unknown optional content policy ${t.policy}.`),!0}return nt(`Unknown group type ${t.type}.`),!0}setVisibility(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const s=this.#Je.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#Je.get(i)?._setVisible(wi,!1,!0);s._setVisible(wi,!!e,!0),this.#Qe=null}else nt(`Optional content group not found: ${t}`)}setOCGState(t){let e,{state:i,preserveRB:s}=t;
2for(const n of i){switch(n){case"ON":case"OFF":case"Toggle":e=n;continue}const t=this.#Je.get(n);if(t)switch(e){case"ON":this.setVisibility(n,!0,s);break;case"OFF":this.setVisibility(n,!1,s);break;case"Toggle":this.setVisibility(n,!t.visible,s)}}this.#Qe=null}get hasInitialVisibility(){return null===this.#Ze||this.getHash()===this.#Ze}getOrder(){return this.#Je.size?this.#ti?this.#ti.slice():[...this.#Je.keys()]:null}getGroups(){return this.#Je.size>0?At(this.#Je):null}getGroup(t){return this.#Je.get(t)||null}getHash(){if(null!==this.#Qe)return this.#Qe;const t=new be;for(const[e,i]of this.#Je)t.update(`${e}:${i.visible}`);return this.#Qe=t.hexdigest()}}class Ci{constructor(t,e){let{disableRange:i=!1,disableStream:s=!1}=e;rt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:n,initialData:a,progressiveDone:r,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=o,a?.length>0){const t=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!i,this._contentLength=n,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData(t){let{begin:e,chunk:i}=t;const s=i instanceof Uint8Array&&i.byteLength===i.buffer.byteLength?i.buffer:new Uint8Array(i).buffer;if(void 0===e)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{rt(this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(s),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){rt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Ei(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Si(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Ei{constructor(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;this._stream=t,this._done=i||!1,this._filename=Ut(s)?s:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.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 t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Si{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.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 t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Ti(t,e){const i=new Headers;if(!t||!e||"object"!==typeof e)return i;for(const s in e){const t=e[s];void 0!==t&&i.append(s,t)}return i}function Mi(t){let{responseHeaders:e,isHttp:i,rangeChunkSize:s,disableRange:n}=t;const a={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(e.get("Content-Length"),10);if(!Number.isInteger(r))return a;
vendor: 6,848 bytes, line 2
2if(a.suggestedLength=r,r<=2*s)return a;if(n||!i)return a;if("bytes"!==e.get("Accept-Ranges"))return a;return"identity"!==(e.get("Content-Encoding")||"identity")||(a.allowRangeRequests=!0),a}function ki(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=r(i);return t=unescape(t),t=o(t),t=l(t),a(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const a=[];for(let s=0;s<e.length&&s in e;++s){let[t,i]=e[s];i=r(i),t&&(i=unescape(i),0===s&&(i=o(i))),a.push(i)}return a.join("")}(t),i)return a(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=r(i);return t=l(t),a(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=vt(i);i=s.decode(n),e=!1}catch{}}return i}function a(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function r(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{s=atob(s)}catch{}return n(e,s)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(Ut(t))return t}return null}function Ri(t,e){return 404===t||0===t&&e.startsWith("file:")?new pt('Missing PDF "'+e+'".'):new gt(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function Pi(t){return 200===t||206===t}function Ii(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Li(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(nt(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Di{constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Ti(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return rt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Fi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Ni(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Fi{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,Ii(i,this._withCredentials,this._abortController)).then((e=>{if(!Pi(e.status))throw Ri(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:a}=Mi({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=a||this._contentLength,this._filename=ki(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new ft("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(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Li(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Ni{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const a=s.url;fetch(a,Ii(n,this._withCredentials,this._abortController)).then((t=>{if(!Pi(t.status))throw Ri(t.status,a);this._readCapability.resolve(),this._reader=t.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Li(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Oi{constructor(t){let{url:e,httpHeaders:i,withCredentials:s}=t;this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=Ti(this.isHttp,i),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,i){const s={begin:t,end:e};for(const n in i)s[n]=i[n];return this.request(s)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[n,a]of this.headers)e.setRequestHeader(n,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(i){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>
2=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError?.(s.status);const n=s.status||200;if(!(200===n&&206===i.expectedStatus)&&n!==i.expectedStatus)return void i.onError?.(s.status);const a=function(t){const e=t.response;return"string"!==typeof e?e:vt(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);i.onDone({begin:parseInt(e[1],10),chunk:a})}else a?i.onDone({begin:0,chunk:a}):i.onError?.(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class Bi{constructor(t){this._source=t,this._manager=new Oi(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return rt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new zi(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new Hi(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class zi{constructor(t,e){this._manager=t;const i={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(i),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.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 t=this._fullRequestId,e=this._manager.getRequestXhr(t),i=new Headers(e.getAllResponseHeaders().trim().split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]}))),{allowRangeRequests:s,suggestedLength:n}=Mi({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});s&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=ki(i),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Ri(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.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(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 t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest
2(this._fullRequestId),this._fullRequestReader=null}}class Hi{constructor(t,e,i){this._manager=t;const s={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,i,s),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError=Ri(t,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const ji=/^[a-z][a-z0-9\-+.]+:/i;
2function Ui(t,e,i){if("http:"===t.protocol){return Pe.get("http").request(t,{headers:e},i)}return Pe.get("https").request(t,{headers:e},i)}class $i{constructor(t){this.source=t,this.url=function(t){if(ji.test(t))return new URL(t);const e=Pe.get("url");return new URL(e.pathToFileURL(t))}(t.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.headers=Ti(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return rt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new Xi(this):new Wi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=this.isFsUrl?new Ki(this,t,e):new qi(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Gi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers()}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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new ft("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Vi{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}class Wi extends Gi{constructor(t){super(t);const e=Object.fromEntries(t.headers);this._request=Ui(this._url,e,(e=>{if(404===e.statusCode){const t=new pt(`Missing PDF "${this._url}".`);return this._storedError=t,void this._headersCapability.reject(t)}this._headersCapability.resolve(),this._setReadableStream(e);const i=new Headers(this._readableStream.headers),{allowRangeRequests:s,suggestedLength:n}=Mi({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=s,this._contentLength=n||this._contentLength,this._filename=ki(i)})),this._request.on("error",(t=>{this._storedError=t,this._headersCapability.reject(t)})),this._request.end()}}class qi extends Vi{constructor(t,e,i){super(t);const s=Object.fromEntries(t.headers);s.Range=`bytes=${e}-${i-1}`;this._request=Ui(this._url,s,(t=>
2{if(404!==t.statusCode)this._setReadableStream(t);else{const t=new pt(`Missing PDF "${this._url}".`);this._storedError=t}})),this._request.on("error",(t=>{this._storedError=t})),this._request.end()}}class Xi extends Gi{constructor(t){super(t);const e=Pe.get("fs");e.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(e.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new pt(`Missing PDF "${this._url}".`)),this._storedError=t,this._headersCapability.reject(t)}))}}class Ki extends Vi{constructor(t,e,i){super(t);const s=Pe.get("fs");this._setReadableStream(s.createReadStream(this._url,{start:e,end:i-1}))}}const Yi=30;class Qi{#ii=(()=>Promise.withResolvers())();#ut=null;#si=!1;#ni=(()=>!!globalThis.FontInspector?.enabled)();#ai=null;#ri=null;#oi=0;#li=0;#hi=null;#ci=null;#di=0;#ui=0;#pi=(()=>Object.create(null))();#gi=[];#mi=null;#fi=[];#bi=(()=>new WeakMap)();#vi=null;static#Ai=(()=>new Map)();static#yi=(()=>new Map)();static#wi=(()=>new WeakMap)();static#xi=null;static#_i=(()=>new Set)();constructor(t){let{textContentSource:e,container:i,viewport:s}=t;if(e instanceof ReadableStream)this.#mi=e;else{if("object"!==typeof e)throw new Error('No "textContentSource" parameter specified.');this.#mi=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#ut=this.#ci=i,this.#ui=s.scale*(globalThis.devicePixelRatio||1),this.#di=s.rotation,this.#ri={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:a,pageX:r,pageY:o}=s.rawDims;this.#vi=[1,0,0,-1,-r,o+a],this.#li=n,this.#oi=a,Qi.#Ci(),te(i,s),this.#ii.promise.finally((()=>{Qi.#_i.delete(this),this.#ri=null,this.#pi=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=yt.platform;return lt(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const t=()=>{this.#hi.read().then((e=>{let{value:i,done:s}=e;s?this.#ii.resolve():(this.#ai??=i.lang,Object.assign(this.#pi,i.styles),this.#Ei(i.items),t())}),this.#ii.reject)};return this.#hi=this.#mi.getReader(),Qi.#_i.add(this),t(),this.#ii.promise}update(t){let{viewport:e,onBefore:i=null}=t;const s=e.scale*(globalThis.devicePixelRatio||1),n=e.rotation;if(n!==this.#di&&(i?.(),this.#di=n,te(this.#ci,{rotation:n})),s!==this.#ui){i?.(),this.#ui=s;const t={div:null,properties:null,ctx:Qi.#Si(this.#ai)};for(const e of this.#fi)t.properties=this.#bi.get(e),t.div=e,this.#Ti(t)}}cancel(){const t=new ft("TextLayer task cancelled.");this.#hi?.cancel(t).catch((()=>{})),this.#hi=null,this.#ii.reject(t)}get textDivs(){return this.#fi}get textContentItemsStr(){return this.#gi}#Ei(t){if(this.#si)return;this.#ri.ctx??=Qi.#Si(this.#ai);const e=this.#fi,i=this.#gi;for(const s of t){if(e.length>1e5)return nt("Ignoring additional textDivs for performance reasons."),void(this.#si=!0);if(void 0!==s.str)i.push(s.str),this.#Mi(s);else if("beginMarkedContentProps"===s.type||"beginMarkedContent"===s.type){const t=this.#ut;this.#ut=document.createElement("span"),this.#ut.classList.add("markedContent"),null!==s.id&&this.#ut.setAttribute("id",`${s.id}`),t.append(this.#ut)}else"endMarkedContent"===s.type&&(this.#ut=this.#ut.parentNode)}}#Mi(t){const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};this.#fi.push(e);const s=xt.transform(this.#vi,t.transform);let n=Math.atan2(s[1],s[0]);const a=this.#pi[t.fontName];a.vertical&&(n+=Math.PI/2);let r=this.#ni&&a.fontSubstitution||a.fontFamily;r=Qi.fontFamilyMap.get(r)||r;const o=Math.hypot(s[2],s[3]),l=o*Qi.#ki(r,this.#ai);let h,c;0===n?(h=s[4],c=s[5]-l):(h=s[4]+l*Math.sin(n),c=s[5]-l*Math.cos(n));const d="calc(var(--scale-factor)*",u=e.style;this.#ut===this.#ci?(u.left=`${(100*h/this.#li).toFixed(2)}%`,u.top=`${(100*c/this.#oi).toFixed(2)}%`):(u.left=`${d}${h.toFixed(2)}px)`,u.top=`${d}${c.toFixed(2)}px)`),u.fontSize=`${d}${(Qi.#xi*o).toFixed(2)}px)`,u.fontFamily=r,i.fontSize=o,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,this.#ni&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),0!==n&&(i.angle=n*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(p=!0)}if(p&&(i.canvasWidth=a.vertical?t.height:t.width),this.#bi.set(e,i),this.#ri.div=e,this.#ri.properties=i,this.#Ti(this.#ri),i.hasText&&this.#ut.append(e),i.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#ut.append(t)}}#Ti(t){const{div:e,properties:i,ctx:s}=t,{style:n}=e;let a="";if(Qi.#xi>1&&(a=`scale(${1/Qi.#xi})`),0!==i.canvasWidth&&i.hasText){const{fontFamily:t}=n,{canvasWidth:r,fontSize:o}=i;Qi.#Ri(s,o*this.#ui,t);const{width:l}=s.measureText(e.textContent);l>0&&(a=`scaleX(${r*this.#ui/l}) ${a}`)}0!==i.angle&&(a=`rotate(${i.angle}deg) ${a}`),a.length>0&&(n.transform=a)}static cleanup(){if(!(this.#_i.size>0)){this.#Ai.clear();for(const{canvas:t}of this.#yi.values())t.remove();this.#yi.clear()}}static#Si(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=this.#yi.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#yi.set(t,e),this.#wi.set(e,{size:0,family:""})}return e}static#Ri(t,e,i){const s=this.#wi.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#Ci(){if(null!==this.#xi)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#xi=t.getBoundingClientRect().height,t.remove()}static#ki(t,e){const i=this.#Ai.get(t);if(i)return i;const s=this.#Si(e);s.canvas.width=s.canvas.height=Yi,this.#Ri(s,Yi,t);const n=s.measureText("");let a=n.fontBoundingBoxAscent,r=Math.abs(n.fontBoundingBoxDescent);if(a){const e=a/(a+r);return this.#Ai.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,Yi,Yi),s.strokeText("g",0,0);let o=s.getImageData(0,0,Yi,Yi).data;r=0;for(let h=o.length-1-3;h>=0;h-=4)if(o[h]>0){r=Math.ceil(h/4/Yi);break}s.clearRect(0,0,Yi,Yi),s.strokeText("A",0,Yi),o=s.getImageData(0,0,Yi,Yi).data,a=0;for(let h=0,c=o.length;h<c;h+=4)if(o[h]>
20){a=Yi-Math.floor(h/4/Yi);break}s.canvas.width=s.canvas.height=0;const l=a?a/(a+r):.8;return this.#Ai.set(t,l),l}}class Ji{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let s=null;const n=i.name;if("#text"===n)s=i.value;else{if(!Ji.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const Zi=65536,ts=a?class extends _e{_createCanvas(t,e){return Pe.get("canvas").createCanvas(t,e)}}:class extends _e{constructor(t){let{ownerDocument:e=globalThis.document,enableHWA:i=!1}=t;super({enableHWA:i}),this._document=e}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}},es=a?class extends Ce{async _fetch(t){return Ie(t)}}:Ee,is=a?class extends Se{}:class extends Se{#Pi;#Ii;#Li;#Di;#Fi;#Ni;#A=0;constructor(t){let{docId:e,ownerDocument:i=globalThis.document}=t;super(),this.#Di=e,this.#Fi=i}get#w(){return this.#Ii||=new Map}get#Oi(){return this.#Ni||=new Map}get#Bi(){if(!this.#Li){const t=this.#Fi.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#Fi.createElementNS(Nt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#Li=this.#Fi.createElementNS(Nt,"defs"),t.append(i),i.append(this.#Li),this.#Fi.body.append(t)}return this.#Li}#zi(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),a=new Array(256),r=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,a[o]=i[o]/255,r[o]=s[o]/255;return[n.join(","),a.join(","),r.join(",")]}#Hi(t){if(void 0===this.#Pi){this.#Pi="";const t=this.#Fi.URL;t!==this.#Fi.baseURI&&(jt(t)?nt('#createUrl: ignore "data:"-URL for performance reasons.'):this.#Pi=t.split("#",1)[0])}return`url(${this.#Pi}#${t})`}addFilter(t){if(!t)return"none";let e=this.#w.get(t);if(e)return e;const[i,s,n]=this.#zi(t),a=1===t.length?i:`${i}${s}${n}`;if(e=this.#w.get(a),e)return this.#w.set(t,e),e;const r=`g_${this.#Di}_transfer_map_${this.#A++}`,o=this.#Hi(r);this.#w.set(t,o),this.#w.set(a,o);const l=this.#ji(r);return this.#Ui(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#Oi.get(s);if(n?.key===i)return n.url;if(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#Oi.set(s,n)),!t||!e)return n.url;const a=this.#$i(t);t=xt.makeHexColor(...a);const r=this.#$i(e);if(e=xt.makeHexColor(...r),this.#Bi.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let u=0;u<=255;u++){const t=u/255;o[u]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#Di}_hcm_filter`,c=n.filter=this.#ji(h);this.#Ui(l,l,l,c),this.#Gi(c);const d=(t,e)=>{const i=a[t]/255,s=r[t]/255,n=new Array(e+1);for(let a=0;a<=e;a++)n[a]=i+a/e*(s-i);return n.join(",")};return this.#Ui(d(0,5),d(1,5),d(2,5),c),n.url=this.#Hi(h),n.url}addAlphaFilter(t){let e=this.#w.get(t);if(e)return e;const[i]=this.#zi([t]),s=`alpha_${i}`;if(e=this.#w.get(s),e)return this.#w.set(t,e),e;const n=`g_${this.#Di}_alpha_map_${this.#A++}`,a=this.#Hi(n);this.#w.set(t,a),this.#w.set(s,a);const r=this.#ji(n);return this.#Vi(i,r),a}addLuminosityFilter(t){let e,i,s=this.#w.get(t||"luminosity");if(s)return s;if(t?([e]=this.#zi([t]),i=`luminosity_${e}`):i="luminosity",s=this.#w.get(i),s)return this.#w.set(t,s),s;const n=`g_${this.#Di}_luminosity_map_${this.#A++}`,a=this.#Hi(n);this.#w.set(t,a),this.#w.set(i,a);const r=this.#ji(n);return this.#Wi(r),t&&this.#Vi(e,r),a}addHighlightHCMFilter(t,e,i,s,n){const a=`${e}-${i}-${s}-${n}`;let r=this.#Oi.get(t);if(r?.key===a)return r.url;if(r?(r.filter?.remove(),r.key=a,r.url="none",r.filter=null):(r={key:a,url:"none",filter:null},this.#Oi.set(t,r)),!e||!i)return r.url;const[o,l]=[e,i].map(this.#$i.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[d,u]=[s,n].map(this.#$i.bind(this));c<h&&([h,c,d,u]=[c,h,u,d]),this.#Bi.style.color="";const p=(t,e,i)=>
2{const s=new Array(256),n=(c-h)/i,a=t/255,r=(e-t)/(255*i);let o=0;for(let l=0;l<=i;l++){const t=Math.round(h+l*n),e=a+l*r;for(let i=o;i<=t;i++)s[i]=e;o=t+1}for(let l=o;l<256;l++)s[l]=s[o-1];return s.join(",")},g=`g_${this.#Di}_hcm_${t}_filter`,m=r.filter=this.#ji(g);return this.#Gi(m),this.#Ui(p(d[0],u[0],5),p(d[1],u[1],5),p(d[2],u[2],5),m),r.url=this.#Hi(g),r.url}destroy(){arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&0!==this.#Oi.size||(this.#Li&&(this.#Li.parentNode.parentNode.remove(),this.#Li=null),this.#Ii&&(this.#Ii.clear(),this.#Ii=null),this.#A=0)}#Wi(t){const e=this.#Fi.createElementNS(Nt,"feColorMatrix");e.setAttribute("type","matrix"),e.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"),t.append(e)}#Gi(t){const e=this.#Fi.createElementNS(Nt,"feColorMatrix");e.setAttribute("type","matrix"),e.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"),t.append(e)}#ji(t){const e=this.#Fi.createElementNS(Nt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#Bi.append(e),e}#qi(t,e,i){const s=this.#Fi.createElementNS(Nt,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#Ui(t,e,i,s){const n=this.#Fi.createElementNS(Nt,"feComponentTransfer");
2s.append(n),this.#qi(n,"feFuncR",t),this.#qi(n,"feFuncG",e),this.#qi(n,"feFuncB",i)}#Vi(t,e){const i=this.#Fi.createElementNS(Nt,"feComponentTransfer");e.append(i),this.#qi(i,"feFuncA",t)}#$i(t){return this.#Bi.style.color=t,Qt(getComputedStyle(this.#Bi).getPropertyValue("color"))}},ss=a?class extends Te{async _fetch(t){return Ie(t)}}:Me;function ns(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"string"===typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new rs,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(a&&"string"===typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(a&&"undefined"!==typeof Buffer&&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("string"===typeof t)return vt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"===typeof t&&!isNaN(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.")}(t.data):null,r=t.httpHeaders||null,o=!0===t.withCredentials,l=t.password??null,h=t.range instanceof os?t.range:null,c=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:Zi;let d=t.worker instanceof ds?t.worker:null;const u=t.verbosity,p="string"!==typeof t.docBaseUrl||jt(t.docBaseUrl)?null:t.docBaseUrl,g="string"===typeof t.cMapUrl?t.cMapUrl:null,m=!1!==t.cMapPacked,f=t.CMapReaderFactory||es,b="string"===typeof t.standardFontDataUrl?t.standardFontDataUrl:null,v=t.StandardFontDataFactory||ss,A=!0!==t.stopAtErrors,y=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,w=!1!==t.isEvalSupported,x="boolean"===typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!a,_="boolean"===typeof t.isChrome?t.isChrome:!yt.platform.isFirefox&&"undefined"!==typeof window&&!!window?.chrome,C=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,E="boolean"===typeof t.disableFontFace?t.disableFontFace:a,S=!0===t.fontExtraProperties,T=!0===t.enableXfa,M=t.ownerDocument||globalThis.document,k=!0===t.disableRange,R=!0===t.disableStream,P=!0===t.disableAutoFetch,I=!0===t.pdfBug,L=t.CanvasFactory||ts,D=t.FilterFactory||is,F=!0===t.enableHWA,N=h?h.length:t.length??NaN,O="boolean"===typeof t.useSystemFonts?t.useSystemFonts:!a&&!E,B="boolean"===typeof t.useWorkerFetch?t.useWorkerFetch:f===Ee&&v===Me&&g&&b&&Wt(g,document.baseURI)&&Wt(b,document.baseURI);t.canvasFactory&&Xt("`canvasFactory`-instance option, please use `CanvasFactory` instead."),t.filterFactory&&Xt("`filterFactory`-instance option, please use `FilterFactory` instead.");et(u);const z={canvasFactory:new L({ownerDocument:M,enableHWA:F}),filterFactory:new D({docId:i,ownerDocument:M}),cMapReaderFactory:B?null:new f({baseUrl:g,isCompressed:m}),standardFontDataFactory:B?null:new v({baseUrl:b})};if(!d){const t={verbosity:u,port:oi.workerPort};d=t.port?ds.fromPort(t):new ds(t),e._worker=d}const H={docId:i,apiVersion:"4.8.69",data:n,password:l,disableAutoFetch:P,rangeChunkSize:c,length:N,docBaseUrl:p,enableXfa:T,evaluatorOptions:{maxImageSize:y,disableFontFace:E,ignoreErrors:A,isEvalSupported:w,isOffscreenCanvasSupported:x,isChrome:_,canvasMaxAreaInBytes:C,fontExtraProperties:S,useSystemFonts:O,cMapUrl:B?g:null,standardFontDataUrl:B?b:null}},j={disableFontFace:E,fontExtraProperties:S,ownerDocument:M,pdfBug:I,styleElement:null,loadingParams:{disableAutoFetch:P,enableXfa:T}};return d.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const t=d.messageHandler.sendWithPromise("GetDocRequest",H,n?[n.buffer]:null);let l;if(h)l=new Ci(h,{disableRange:k,disableStream:R});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");let t;if(a){t="undefined"!==typeof fetch&&"undefined"!==typeof Response&&"body"in Response.prototype&&Wt(s)?Di:$i}else t=Wt(s)?Di:Bi;l=new t({url:s,length:N,httpHeaders:r,withCredentials:o,rangeChunkSize:c,disableRange:k,disableStream:R})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const s=new Ai(i,t,d.port),n=new us(s,e,l,j,z);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}function as(t){return"object"===typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class rs{static#Di=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+rs.#Di++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}}class os{constructor(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const i of this._rangeListeners)i(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(const i of this._progressListeners)i(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(const e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){at("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class ls{constructor(t,e){this._pdfInfo=t,this._transport=e}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 lt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}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()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){let{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{renderingIntent:e}
2=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}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(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}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 hs{#Xi=null;#Ki=!1;constructor(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Vt:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new gs,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}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(){let{scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new zt({viewBox:this.view,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations(){let{intent:t="display"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return lt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render(t){let{canvasContext:e,viewport:i,intent:s="display",annotationMode:n=b.ENABLE,transform:a=null,background:r=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:u=!1}=t;this._stats?.time("Overall");const p=this._transport.getRenderingIntent(s,n,c,u),{renderingIntent:g,cacheKey:m}=p;this.#Ki=!1,this.#Yi(),o||=this._transport.getOptionalContentConfig(g);let f=this._intentStates.get(m);f||(f=Object.create(null),this._intentStates.set(m,f)),f.streamReaderCancelTimeout&&(clearTimeout(f.streamReaderCancelTimeout),f.streamReaderCancelTimeout=null);const v=!!(g&d);f.displayReadyCapability||(f.displayReadyCapability=Promise.withResolvers(),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(p));const A=t=>{f.renderTasks.delete(y),(this._maybeCleanupAfterRender||v)&&(this.#Ki=!0),this.#Qi(!v),t?(y.capability.reject(t),this._abortOperatorList({intentState:f,reason:t instanceof Error?t:new Error(t)})):y.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},y=new fs({callback:A,params:{canvasContext:e,viewport:i,transform:a,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:f.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:h});(f.renderTasks||=new Set).add(y);const w=y.task;return Promise.all([f.displayReadyCapability.promise,o]).then((t=>{let[e,i]=t;if(this.destroyed)A();else{if(this._stats?.time("Rendering"),!(i.renderingIntent&g))throw new Error("Mu
2st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");y.initializeGraphics({transparency:e,optionalContentConfig:i}),y.operatorListChanged()}})).catch(A),w}getOperatorList(){let{intent:t="display",annotationMode:e=b.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=this._transport.getRenderingIntent(t,e,i,s,!0);let a,r=this._intentStates.get(n.cacheKey);return r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r)),r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(a),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.opListReadCapability.promise}streamTextContent(){let{includeMarkedContent:t=!1,disableNormalization:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this._transport._htmlForXfa)return this.getXfa().then((t=>Ji.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then((function(i){let{value:s,done:a}=i;a?t(n):(n.lang??=s.lang,Object.assign(n.styles,s.styles),n.items.push(...s.items),e())}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#Ki=!1,this.#Yi(),Promise.all(t)}cleanup(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.#Ki=!0;const e=this.#Qi(!1);return t&&e&&(this._stats&&=new Vt),e}#Qi(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.#Yi(),!this.#Ki||this.destroyed)return!1;if(t)return this.#Xi=setTimeout((()=>{this.#Xi=null,this.#Qi(!1)}),5e3),!1;for(const{renderTasks:e,operatorList:i}of this._intentStates.values())if(e.size>0||!i.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#Ki=!1,!0}#Yi(){this.#Xi&&(clearTimeout(this.#Xi),this.#Xi=null)}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const i of e.renderTasks)i.operatorListChanged();t.lastChunk&&this.#Qi(!0)}_pumpOperatorList(t){let{renderingIntent:e,cacheKey:i,annotationStorageSerializable:s,modifiedIds:n}=t;const{map:a,transfer:r}=s,o=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:i,annotationStorage:a,modifiedIds:n},r).getReader(),l=this._intentStates.get(i);l.streamReader=o;const h=()=>{o.read().then((t=>{let{value:e,done:i}=t;i?l.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,l),h())}),(t=>{if(l.streamReader=null,!this._transport.destroyed){if(l.operatorList){l.operatorList.lastChunk=!0;for(const t of l.renderTasks)t.operatorListChanged();this.#Qi(!0)}if(l.displayReadyCapability)l.displayReadyCapability.reject(t);else{if(!l.opListReadCapability)throw t;l.opListReadCapability.reject(t)}}}))};h()}_abortOperatorList(t){let{intentState:e,reason:i,force:s=!1}=t;if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!s){if(e.renderTasks.size>0)return;if(i instanceof Ht){let t=100;return i.extraDelay>0&&i.extraDelay<1e3&&(t+=i.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:i,force:!0})}),t))}}if(e.streamReader.cancel(new ft(i.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(const[t,i]of this._intentStates)if(i===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}class cs{#Ji=(()=>new Map)();#Zi=(()=>Promise.resolve())();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#Zi.then((()=>{for(const[t]of this.#Ji)t.call(this,i)}))}addEventListener(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void nt("LoopbackPort - cannot use an `aborted` signal.");const a=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}this.#Ji.set(e,s)}removeEventListener(t,e){const i=this.#Ji.get(e);i?.(),this.#Ji.delete(e)}terminate(){for(const[,t]of this.#Ji)t?.();this.#Ji.clear()}}class ds{static#ts=0;static#es=!1;static#is;static#ss=(()=>{a&&(this.#es=!0,oi.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(i=new URL(t),!i.origin||"null"===i.origin)return!1}catch{return!1}const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}})();constructor(){let{name:t=null,port:e=null,verbosity:i=it()}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.name=t,this.destroyed=!1,this.verbosity=i,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if(ds.#is?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");return(ds.#is||=new WeakMap).set(e,this),void this._initializeFromPort(e)}this._initialize()}get promise(){return a?Promise.all([Pe.promise,this._readyCapability.promise]):this._readyCapability.promise}#ns(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Ai("main","worker",t),this._messageHandler.on("ready",(function(){})),this.#ns()}_initialize(){if(ds.#es||ds.#as)return void this._setupFakeWorker();let{workerSrc:t}=ds;try{ds._isSameOrigin(window.location.href,t)||(t=ds._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new Ai("main","worker",e),s=()=>{n.abort(),i.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",(()=>{this._webWorker||s()}),{signal:n.signal}),i.on("test",(t=>{n.abort(),!this.destroyed&&t?(this._messageHandler=i,this._port=e,this._webWorker=e,this.#ns()):s()})),i.on("ready",(t=>{if(n.abort(),this.destroyed)s();else try{a()}catch{this._setupFakeWorker()}}));const a=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};return void a()}catch{st("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){ds.#es||(nt("Setting up fake worker."),ds.#es=!0),ds._setupFakeWorkerGlobal.then((t=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const e=new cs;this._port=e;const i="fake"+ds.#ts++,s=new Ai(i+"_worker",i,e);t.setup(s,e),this._messageHandler=new Ai(i,i+"_worker",e),this.#ns()})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),ds.#is?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const e=this.#is?.get(t.port);
2if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new ds(t)}static get workerSrc(){if(oi.workerSrc)return oi.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#as(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return lt(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#as)return this.#as;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class us{#rs=(()=>new Map)();#os=(()=>new Map)();#ls=(()=>new Map)();#hs=(()=>new Map)();#cs=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new gs,this.fontLoader=new we({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#ds(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=this.#rs.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#rs.set(t,s),s}get annotationStorage(){return lt(this,"annotationStorage",new Ae)}getRenderingIntent(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b.ENABLE,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],n=arguments.length>4&&void 0!==arguments[4]&&arguments[4],a=c,r=ve;switch(t){case"any":a=h;break;case"display":break;case"print":a=d;break;default:nt(`getRenderingIntent - invalid intent: ${t}`)}const o=a&d&&i instanceof ye?i:this.annotationStorage;switch(e){case b.DISABLE:a+=g;break;case b.ENABLE:break;case b.ENABLE_FORMS:a+=u;break;case b.ENABLE_STORAGE:a+=p,r=o.serializable;break;default:nt(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(a+=m),n&&(a+=f);const{ids:l,hash:v}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,r.hash,v].join("_"),annotationStorageSerializable:r,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#cs?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of this.#os.values())t.push(i._destroy());this.#os.clear(),this.#ls.clear(),this.#hs.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#rs.clear(),this.filterFactory.destroy(),Qi.cleanup(),this._networkStream?.cancelAllRequests(new ft("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{rt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function(t){let{value:i,done:s}=t;s?e.close():(rt(i instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(i),1,[i]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async t=>{await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:s,contentLength:n}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:n}})),t.on("GetRangeReader",((t,e)=>{rt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then((function(t){let{value:i,done:s}=t;s?e.close():(rt(i instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(i),1,[i]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{i.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),t.on("GetDoc",(t=>{let{pdfInfo:i}=t;this._numPages=i.numPages,this._htmlForXfa=i.htmlForXfa,delete i.htmlForXfa,e._capability.resolve(new ls(i,this))})),t.on("DocException",(function(t){let i;switch(t.name){case"PasswordException":i=new ct(t.message,t.code);break;case"InvalidPDFException":i=new ut(t.message);break;case"MissingPDFException":i=new pt(t.message);break;case"UnexpectedResponseException":i=new gt(t.message,t.status);break;case"UnknownErrorException":i=new dt(t.message,t.details);break;default:at("DocException - expected a valid Error.")}e._capability.reject(i)})),t.on("PasswordRequest",(t=>{if(this.#cs=Promise.withResolvers(),e.onPassword){const s=t=>{t instanceof Error?this.#cs.reject(t):this.#cs.resolve({password:t})};try{e.onPassword(s,t.code)}catch(i){this.#cs.reject(i)}}else this.#cs.reject(new ct(t.message,t.code));return this.#cs.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{if(this.destroyed)return;this.#os.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(e=>{let[i,s,n]=e;if(this.destroyed)return null;if(this.commonObjs.has(i))return null;switch(s){case"Font":const{disableFontFace:e,fontExtraProperties:a,pdfBug:r}=this._params;if("error"in n){const t=n.error;nt(`Error during font loading: ${t}`),this.commonObjs.resolve(i,t);break}const o=r&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,l=new xe(n,{disableFontFace:e,inspectFont:o});this.fontLoader.bind(l).catch((()=>
2t.sendWithPromise("FontFallback",{id:i}))).finally((()=>{!a&&l.data&&(l.data=null),this.commonObjs.resolve(i,l)}));break;case"CopyLocalImage":const{imageRef:h}=n;rt(h,"The imageRef must be defined.");for(const t of this.#os.values())for(const[,e]of t.objs)if(e?.ref===h)return e.dataLen?(this.commonObjs.resolve(i,structuredClone(e)),e.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(i,n);break;default:throw new Error(`Got unknown common object type ${s}`)}return null})),t.on("obj",(t=>{let[e,i,s,n]=t;if(this.destroyed)return;const a=this.#os.get(i);if(!a.objs.has(e))if(0!==a._intentStates.size)switch(s){case"Image":a.objs.resolve(e,n),n?.dataLen>1e7&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(e,n);break;default:throw new Error(`Got unknown object type ${s}`)}else n?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBuiltInCMap",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(t)})),t.on("FetchStandardFontData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&nt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#ls.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#hs.set(i.refStr,t);const s=new hs(e,i,this,this._params.pdfBug);return this.#os.set(e,s),s}));return this.#ls.set(e,s),s}getPageIndex(t){return as(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#ds("GetFieldObjects")}hasJSActions(){return this.#ds("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!==typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}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)}getDocJSActions(){return this.#ds("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#ds("GetOptionalContentConfig").then((e=>new _i(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#rs.get(t);if(e)return e;
2const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new yi(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#rs.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#os.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#rs.clear(),this.filterFactory.destroy(!0),Qi.cleanup()}}cachedPageNumber(t){if(!as(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#hs.get(e)??null}}const ps=Symbol("INITIAL_DATA");class gs{#us=(()=>Object.create(null))();#ps(t){return this.#us[t]||={...Promise.withResolvers(),data:ps}}get(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(e){const i=this.#ps(t);return i.promise.then((()=>e(i.data))),null}const i=this.#us[t];if(!i||i.data===ps)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#us[t];return!!e&&e.data!==ps}resolve(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=this.#ps(t);i.data=e,i.resolve()}clear(){for(const t in this.#us){const{data:e}=this.#us[t];e?.bitmap?.close()}this.#us=Object.create(null)}*[Symbol.iterator](){for(const t in this.#us){const{data:e}=this.#us[t];e!==ps&&(yield[t,e])}}}class ms{#gs=null;constructor(t){this.#gs=t,this.onContinue=null}get promise(){return this.#gs.capability.promise}cancel(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.#gs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#gs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#gs;return t.form||t.canvas&&e?.size>0}}class fs{#ms=null;static#fs=(()=>new WeakSet)();constructor(t){let{callback:e,params:i,objs:s,commonObjs:n,annotationCanvasMap:a,operatorList:r,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:d=!1,pageColors:u=null}=t;this.callback=e,this.params=i,this.objs=s,this.commonObjs=n,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=d,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===c&&"undefined"!==typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new ms(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=i.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics(t){let{transparency:e=!1,optionalContentConfig:i}=t;if(this.cancelled)return;if(this._canvas){if(fs.#fs.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.");fs.#fs.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:n,transform:a,background:r}=this.params;this.gfx=new ri(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:i},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:n,transparency:e,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#ms&&(window.cancelAnimationFrame(this.#ms),this.#ms=null),fs.#fs.delete(this._canvas),this.callback(t||new Ht(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#ms=window.requestAnimationFrame((()=>{this.#ms=null,this._nextBound().catch(this._cancelBound)}
2)):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.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),fs.#fs.delete(this._canvas),this.callback())))}}const bs="4.8.69",vs="3634dab10";function As(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function ys(t){return Math.max(0,Math.min(255,255*t))}class ws{static CMYK_G(t){let[e,i,s,n]=t;return["G",1-Math.min(1,.3*e+.59*s+.11*i+n)]}static G_CMYK(t){let[e]=t;return["CMYK",0,0,0,1-e]}static G_RGB(t){let[e]=t;return["RGB",e,e,e]}static G_rgb(t){let[e]=t;return e=ys(e),[e,e,e]}static G_HTML(t){let[e]=t;const i=As(e);return`#${i}${i}${i}`}static RGB_G(t){let[e,i,s]=t;return["G",.3*e+.59*i+.11*s]}static RGB_rgb(t){return t.map(ys)}static RGB_HTML(t){return`#${t.map(As).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB(t){let[e,i,s,n]=t;return["RGB",1-Math.min(1,e+n),1-Math.min(1,s+n),1-Math.min(1,i+n)]}static CMYK_rgb(t){let[e,i,s,n]=t;return[ys(1-Math.min(1,e+n)),ys(1-Math.min(1,s+n)),ys(1-Math.min(1,i+n))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK(t){let[e,i,s]=t;const n=1-e,a=1-i,r=1-s;return["CMYK",n,a,r,Math.min(n,a,r)]}}class xs{create(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!==typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){at("Abstract method `_createSVG` called.")}}class _s extends xs{_createSVG(t){return document.createElementNS(Nt,t)}}class Cs{static setupStorage(t,e,i,s,n){const a=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(a.value===i.attributes.xfaOn?t.setAttribute("checked",!0):a.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value){t.setAttribute("value",a.value);for(const t of i.children)t.attributes.value===a.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})}))}}static setAttributes(t){let{html:e,element:i,storage:s=null,intent:n,linkService:a}=t;const{attributes:r}=i,o=e instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${n}`);for(const[l,h]of Object.entries(r))if(null!==h&&void 0!==h)switch(l){case"class":h.length&&e.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",h);break;case"style":Object.assign(e.style,h);break;case"textContent":e.textContent=h;break;default:(!o||"href"!==l&&"newWindow"!==l)&&e.setAttribute(l,h)}o&&a.addLinkAttributes(e,r.href,r.newWindow),s&&r.dataId&&this.setupStorage(e,r.dataId,i,s)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",a=document.createElement(s.name);s.attributes&&this.setAttributes({html:a,element:s,intent:n,linkService:i});const r="richText"!==n,o=t.div;if(o.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}r&&o.setAttribute("class","xfaLayer xfaFont");const l=[];
2if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);a.append(t),r&&Ji.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}const h=[[s,-1,a]];for(;h.length>0;){const[t,s,a]=h.at(-1);if(s+1===t.children.length){h.pop();continue}const o=t.children[++h.at(-1)[1]];if(null===o)continue;const{name:c}=o;if("#text"===c){const t=document.createTextNode(o.value);l.push(t),a.append(t);continue}const d=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,c):document.createElement(c);if(a.append(d),o.attributes&&this.setAttributes({html:d,element:o,storage:e,intent:n,linkService:i}),o.children?.length>0)h.push([o,-1,d]);else if(o.value){const t=document.createTextNode(o.value);r&&Ji.shouldBuildText(c)&&l.push(t),d.append(t)}}for(const c of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))c.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Es=1e3,Ss=new WeakSet;function Ts(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class Ms{static create(t){switch(t.data.annotationType){case k:return new Rs(t);case M:return new Ps(t);case V:switch(t.data.fieldType){case"Tx":return new Ls(t);case"Btn":return t.data.radioButton?new Ns(t):t.data.checkBox?new Fs(t):new Os(t);case"Ch":return new Bs(t);case"Sig":return new Ds(t)}return new Is(t);case $:return new zs(t);case R:return new js(t);case P:return new Us(t);case I:return new $s(t);case L:return new Gs(t);case F:return new Vs(t);case j:return new qs(t);case U:return new Xs(t);case D:return new Ws(t);case N:return new Ks(t);case O:return new Ys(t);case B:return new Qs(t);case z:return new Js(t);case H:return new Zs(t);case G:return new tn(t);default:return new ks(t)}}}class ks{#bs=null;#vs=!1;#As=null;constructor(t){let{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData(t){let{titleObj:e,contentsObj:i,richText:s}=t;return!!(e?.str||i?.str||s?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return ks._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#bs||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#ys(e),this.#As?.popup.updateEdited(t)}resetEdited(){this.#bs&&(this.#ys(this.#bs.rect),this.#As?.popup.resetEdited(),this.#bs=null)}#ys(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:r,pageY:o}}}}=this;i?.splice(0,4,...t);const{width:l,height:h}=Ts(t);e.left=100*(t[0]-r)/n+"%",e.top=100*(a-t[3]+o)/a+"%",0===s?(e.width=100*l/n+"%",e.height=100*h/a+"%"):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Is||(n.tabIndex=Es);const{style:a}=n;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof zs){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:r,height:o}=Ts(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;a.borderRadius=e}else if(this instanceof Ns){const t=`calc(${r}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case W:a.borderStyle="solid";break;case q:a.borderStyle="dashed";break;case X:nt("Unimplemented border style: beveled");break;case K:nt("Unimplemented border style: inset");break;case Y:a.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#vs=!0,a.borderColor=xt.makeHexColor(0|s[0],0|s[1],0|s[2])):a.borderWidth=0}
2const l=xt.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:c,pageX:d,pageY:u}=s.rawDims;a.left=100*(l[0]-d)/h+"%",a.top=100*(l[1]-u)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(a.width=100*r/h+"%",a.height=100*o/c+"%"):this.setRotation(p,n),n}setRotation(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.container;if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:a}=Ts(this.data.rect);let r,o;t%180===0?(r=100*n/i,o=100*a/s):(r=100*a/i,o=100*n/s),e.style.width=`${r}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],a=s.slice(1);i.target.style[e]=ws[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:ws[`${n}_rgb`](a)})};return lt(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const a=i[s];if(a){a({detail:{[s]:n},target:t}),delete e[s]}}}
2_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[a,r,o,l]=t.subarray(2,6);if(s===a&&n===r&&e===o&&i===l)return}const{style:a}=this.container;let r;if(this.#vs){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0,r=["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="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0);const d=h.createElement("defs");c.append(d);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let g=2,m=t.length;g<m;g+=8){const i=t[g],s=t[g+1],a=t[g+2],c=t[g+3],d=h.createElement("rect"),p=(a-e)/o,m=(n-s)/l,f=(i-a)/o,b=(s-c)/l;d.setAttribute("x",p),d.setAttribute("y",m),d.setAttribute("width",f),d.setAttribute("height",b),u.append(d),r?.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${m}" width="${f}" height="${b}"/>`)}this.#vs&&(r.push("</g></svg>')"),a.backgroundImage=r.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#As=new zs({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(e.render())}render(){at("Abstract method `AnnotationElement.render` called")}_getElementsByName(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:a}of s){if(-1===t)continue;if(n===e)continue;const s="string"===typeof a?a:null,r=document.querySelector(`[data-element-id="${n}"]`);!r||Ss.has(r)?i.push({id:n,exportValue:s,domElement:r}):nt(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(Ss.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}return i}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}class Rs extends ks{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#ws(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#xs(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#_s(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#_s()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#_s()}#ws(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#_s()}#xs(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#_s()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#_s()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#_s(),!this._fieldObjects)return nt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:s,include:n}=e,a=[];if(0!==t.length||0!==s.length){const e=new Set(s);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===n&&a.push(i)}else for(const e of Object.values(this._fieldObjects))a.push(...e);const r=this.annotationStorage,o=[];for(const e of a){const{id:t}=e;switch(o.push(t),e.type){case"text":{const i=e.defaultValue||"";r.setValue(t,{value:i});break}case"checkbox":case"radiobutton":{const i=e.defaultValue===e.exportValues;r.setValue(t,{value:i});break}case"combobox":case"listbox":{const i=e.defaultValue||"";r.setValue(t,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${t}"]`);i&&(Ss.has(i)?i.dispatchEvent(new Event("resetform")):nt(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class Ps extends ks{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}
2class Is extends ks{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return yt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(i,(t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,e,i,s){for(const[n,a]of i)("Action"===a||this.data.actions?.[a])&&("Focus"!==a&&"Blur"!==a||(e||={focused:!1}),this._setEventListener(t,e,n,a,s),"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":xt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style;let a;const r=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(l*s))||1);a=Math.min(s,r(e/l))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(s,r(t/l))}n.fontSize=`calc(${a}px * var(--scale-factor))`,n.color=xt.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Ls extends Is{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;
2for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=i),n.setValue(a.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&n.length>a&&(n=n.slice(0,a));let r=s.formattedValue||this.data.textContent?.join("\n")||null;r&&this.data.comb&&(r=r.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:r,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=r??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",r??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),Ss.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Es,this._setRequired(i,this.data.required),a&&(i.maxLength=a),i.addEventListener("input",(s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null})),i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null}));let l=t=>{const{formattedValue:e}=o;null!==e&&void 0!==e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)})),i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target);const s={value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){const{formattedValue:s}=i.detail;o.formattedValue=s,null!==s&&void 0!==s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let a=o.userValue;!a||a.length<=s||(a=a.slice(0,s),n.value=o.userValue=a,t.setValue(e,{value:a}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}};this._dispatchEventFromSandbox(s,i)})),i.addEventListener("keydown",(t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;const{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const s=l;l=null,i.addEventListener("blur",(t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)})),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{o.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:a,selectionEnd:r}=s;let l=a,h=r;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,a).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}
2case"deleteWordForward":{const t=n.substring(a).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":a===r&&(l-=1);break;case"deleteContentForward":a===r&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:l,selEnd:h}})})),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(l&&i.addEventListener("blur",l),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/a;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}px * var(--scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Ds extends Is{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Fs extends Is{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"===typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Ss.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=Es,n.addEventListener("change",(s=>{const{name:n,checked:a}=s.target;for(const r of this._getElementsByName(n,i)){const i=a&&r.exportValue===e.exportValue;r.domElement&&(r.domElement.checked=i),t.setValue(r.id,{value:i})}t.setValue(i,{value:a})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Ns extends Is{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"===typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const a of this._getElementsByName(e.fieldName,i))t.setValue(a.id,{value:!1});const n=document.createElement("input");if(Ss.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=Es,n.addEventListener("change",(e=>{const{name:s,checked:n}=e.target;for(const a of this._getElementsByName(s,i))t.setValue(a.id,{value:!1});t.setValue(i,{value:n})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!==i&&void 0!==i&&i===e.buttonValue})),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{const n={value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}
2return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Os extends Rs{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Bs extends Is{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Ss.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=Es;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const i of s.options)i.selected=i.value===e}));for(const h of this.data.options){const t=document.createElement("option");t.textContent=h.displayValue,t.value=h.exportValue,i.value.includes(h.exportValue)&&(t.setAttribute("selected",!0),n=!1),s.append(t)}let a=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),a=()=>{t.remove(),s.removeEventListener("input",a),a=null},s.addEventListener("input",a)}const r=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=r(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{const n={value(i){a?.();const n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:r(!0)}),o=r(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,a=i.detail.remove;if(n[a].selected=!1,s.remove(a),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=r(!1)},insert(i){const{index:n,displayValue:a,exportValue:h}=i.detail.insert,c=s.children[n],d=document.createElement("option");d.textContent=a,d.value=h,c?c.before(d):s.append(d),t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:r(!0)}),o=r(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)})),s.addEventListener("input",(i=>{const s=r(!0),n=r(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):s.addEventListener("input",(function(i){t.setValue(e,{value:r(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class zs extends ks{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:ks._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Hs({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,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}),e=[];for(const i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${St}${t}`)).join(",")),this.container}}
2class Hs{#Cs=this.#Es.bind(this);#Ss=this.#Ts.bind(this);#Ms=this.#ks.bind(this);#Rs=this.#Ps.bind(this);#Is=null;#ut=null;#Ls=null;#Ds=null;#Fs=null;#Ns=null;#Os=null;#Bs=!1;#zs=null;#S=null;#Hs=null;#js=null;#Us=null;#bs=null;#$s=!1;constructor(t){let{container:e,color:i,elements:s,titleObj:n,modificationDate:a,contentsObj:r,richText:o,parent:l,rect:h,parentRect:c,open:d}=t;this.#ut=e,this.#Us=n,this.#Ls=r,this.#js=o,this.#Ns=l,this.#Is=i,this.#Hs=h,this.#Os=c,this.#Fs=s,this.#Ds=Kt.toDateObject(a),this.trigger=s.flatMap((t=>t.getElementsToTriggerPopup()));for(const u of this.trigger)u.addEventListener("click",this.#Rs),u.addEventListener("mouseenter",this.#Ms),u.addEventListener("mouseleave",this.#Ss),u.classList.add("popupTriggerArea");for(const u of s)u.container?.addEventListener("keydown",this.#Cs);this.#ut.hidden=!0,d&&this.#Ps()}render(){if(this.#zs)return;const t=this.#zs=document.createElement("div");if(t.className="popup",this.#Is){const e=t.style.outlineColor=xt.makeHexColor(...this.#Is);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;t.style.backgroundColor=xt.makeHexColor(...this.#Is.map((t=>Math.floor(e*(255-t)+t))))}}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#Us),t.append(e),this.#Ds){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#Ds.valueOf()})),e.append(t)}const s=this.#Gs;if(s)Cs.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#Ls);t.append(e)}this.#ut.append(t)}get#Gs(){const t=this.#js,e=this.#Ls;return!t?.str||e?.str&&e.str!==t.str?null:this.#js.html||null}get#Vs(){return this.#Gs?.attributes?.style?.fontSize||0}get#Ws(){return this.#Gs?.attributes?.style?.color||null}#qs(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#Ws,fontSize:this.#Vs?`calc(${this.#Vs}px * var(--scale-factor))`:""}};for(const n of t.split("\n"))e.push({name:"span",value:n,attributes:s});return i}_formatContents(t){let{str:e,dir:i}=t;const s=document.createElement("p");s.classList.add("popupContent"),s.dir=i;const n=e.split(/(?:\r\n?|\n)/);for(let a=0,r=n.length;a<r;++a){const t=n[a];s.append(document.createTextNode(t)),a<r-1&&s.append(document.createElement("br"))}return s}#Es(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#Bs)&&this.#Ps()}updateEdited(t){let{rect:e,popupContent:i}=t;this.#bs||={contentsObj:this.#Ls,richText:this.#js},e&&(this.#S=null),i&&(this.#js=this.#qs(i),this.#Ls=null),this.#zs?.remove(),this.#zs=null}resetEdited(){this.#bs&&(({contentsObj:this.#Ls,richText:this.#js}=this.#bs),this.#bs=null,this.#zs?.remove(),this.#zs=null,this.#S=null)}#Xs(){if(null!==this.#S)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#Ns;let a=!!this.#Os,r=a?this.#Os:this.#Hs;for(const u of this.#Fs)if(!r||null!==xt.intersect(u.data.rect,r)){r=u.data.rect,a=!0;break}const o=xt.normalizeRect([r[0],t[3]-r[1]+t[1],r[2],t[3]-r[3]+t[1]]),l=a?r[2]-r[0]+5:0,h=o[0]+l,c=o[1];this.#S=[100*(h-s)/e,100*(c-n)/i];const{style:d}=this.#ut;d.left=`${this.#S[0]}%`,d.top=`${this.#S[1]}%`}#Ps(){this.#Bs=!this.#Bs,this.#Bs?(this.#ks(),this.#ut.addEventListener("click",this.#Rs),this.#ut.addEventListener("keydown",this.#Cs)):(this.#Ts(),this.#ut.removeEventListener("click",this.#Rs),this.#ut.removeEventListener("keydown",this.#Cs))}#ks(){this.#zs||this.render(),this.isVisible?this.#Bs&&this.#ut.classList.add("focused"):(this.#Xs(),this.#ut.hidden=!1,this.#ut.style.zIndex=parseInt(this.#ut.style.zIndex)+1e3)}#Ts(){this.#ut.classList.remove("focused"),!this.#Bs&&this.isVisible&&(this.#ut.hidden=!0,this.#ut.style.zIndex=parseInt(this.#ut.style.zIndex)-1e3)}
vendor: 4,379 bytes, line 2
2forceHide(){this.#$s=this.isVisible,this.#$s&&(this.#ut.hidden=!0)}maybeShow(){this.#$s&&(this.#zs||this.#ks(),this.#$s=!1,this.#ut.hidden=!1)}get isVisible(){return!1===this.#ut.hidden}}class js extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=v.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class Us extends ks{#Ks=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=Ts(t.rect),s=this.svgFactory.create(e,i,!0),n=this.#Ks=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Ks}addHighlightArea(){this.container.classList.add("highlightArea")}}class $s extends ks{#Ys=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=Ts(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#Ys=this.svgFactory.createElement("svg:rect");return a.setAttribute("x",n/2),a.setAttribute("y",n/2),a.setAttribute("width",e-n),a.setAttribute("height",i-n),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Ys}addHighlightArea(){this.container.classList.add("highlightArea")}}class Gs extends ks{#Qs=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=Ts(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#Qs=this.svgFactory.createElement("svg:ellipse");return a.setAttribute("cx",e/2),a.setAttribute("cy",i/2),a.setAttribute("rx",e/2-n/2),a.setAttribute("ry",i/2-n/2),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Qs}addHighlightArea(){this.container.classList.add("highlightArea")}}class Vs extends ks{#Js=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;const{width:n,height:a}=Ts(t),r=this.svgFactory.create(n,a,!0);let o=[];for(let h=0,c=e.length;h<c;h+=2){const i=e[h]-t[0],s=t[3]-e[h+1];o.push(`${i},${s}`)}o=o.join(" ");const l=this.#Js=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Js}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ws extends Vs{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class qs extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}
2class Xs extends ks{#Zs=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?v.HIGHLIGHT:v.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,inkLists:e,borderStyle:i,popupRef:s}}=this,{width:n,height:a}=Ts(t),r=this.svgFactory.create(n,a,!0);for(const o of e){let e=[];for(let i=0,n=o.length;i<n;i+=2){const s=o[i]-t[0],n=t[3]-o[i+1];e.push(`${s},${n}`)}e=e.join(" ");const s=this.svgFactory.createElement(this.svgElementName);this.#Zs.push(s),s.setAttribute("points",e),s.setAttribute("stroke-width",i.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),r.append(s)}return!s&&this.hasPopupData&&this._createPopup(),this.container.append(r),this._editOnDoubleClick(),this.container}getElementsToTriggerPopup(){return this.#Zs}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ks extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=v.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Ys extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class Qs extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class Js extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class Zs extends ks{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=v.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 tn extends ks{#tn=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#en.bind(this)),this.#tn=i;const{isMac:s}=yt.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#en()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#tn}addHighlightArea(){this.container.classList.add("highlightArea")}#en(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class en{#in=null;#sn=null;#nn=(()=>new Map)();#an=null;constructor(t){let{div:e,accessibilityManager:i,annotationCanvasMap:s,annotationEditorUIManager:n,page:a,viewport:r,structTreeLayer:o}=t;this.div=e,this.#in=i,this.#sn=s,this.#an=o||null,this.page=a,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=n}hasEditableAnnotations(){return this.#nn.size>0}async#rn(t,e){const i=t.firstChild||t,s=i.id=`${St}${e}`,n=await(this.#an?.getAriaAttributes(s));if(n)for(const[a,r]of n)i.setAttribute(a,r);this.div.append(t),this.#in?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;te(i,this.viewport);const s=new Map,n={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new _s,annotationStorage:t.annotationStorage||new Ae,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const a of e){if(a.noHTML)continue;const t=a.annotationType===$;if(t){const t=s.get(a.id);if(!t)continue;n.elements=t}else{const{width:t,height:e}=Ts(a.rect);if(t<=0||e<=0)continue}n.data=a;const e=Ms.create(n);if(!e.isRenderable)continue;if(!t&&a.popupRef){const t=s.get(a.popupRef);t?t.push(e):s.set(a.popupRef,[e])}const i=e.render();a.hidden&&(i.style.visibility="hidden"),await this.#rn(i,a.id),e._isEditable&&(this.#nn.set(e.data.id,e),this._annotationEditorUIManager?.renderAnnotationElement(e))}this.#on()}update(t){let{viewport:e}=t;const i=this.div;this.viewport=e,te(i,{rotation:e.rotation}),this.#on(),i.hidden=!1}#on(){if(!this.#sn)return;const t=this.div;for(const[e,i]of this.#sn){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i)}this.#sn.clear()}getEditableAnnotations(){return Array.from(this.#nn.values())}getEditableAnnotation(t){return this.#nn.get(t)}}const sn=/\r\n?|\n/g;class nn extends ue{#Is;#ln="";#hn=`${this.id}-editor`;#cn=null;#Vs;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=nn.prototype,e=t=>t.isEmpty(),i=ce.TRANSLATE_SMALL,s=ce.TRANSLATE_BIG;return lt(this,"_keyboardManager",new le([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=(()=>v.FREETEXT)();constructor(t){super({...t,name:"freeTextEditor"}),this.#Is=t.color||nn._defaultColor||ue._defaultLineColor,this.#Vs=t.fontSize||nn._defaultFontSize}static initialize(t,e){ue.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}
2static updateDefaultParams(t,e){switch(t){case A.FREETEXT_SIZE:nn._defaultFontSize=e;break;case A.FREETEXT_COLOR:nn._defaultColor=e}}updateParams(t,e){switch(t){case A.FREETEXT_SIZE:this.#dn(e);break;case A.FREETEXT_COLOR:this.#un(e)}}static get defaultPropertiesToUpdate(){return[[A.FREETEXT_SIZE,nn._defaultFontSize],[A.FREETEXT_COLOR,nn._defaultColor||ue._defaultLineColor]]}get propertiesToUpdate(){return[[A.FREETEXT_SIZE,this.#Vs],[A.FREETEXT_COLOR,this.#Is]]}#dn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#Vs)*this.parentScale),this.#Vs=t,this.#pn()},i=this.#Vs;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#un(t){const e=t=>{this.#Is=this.editorDiv.style.color=t},i=this.#Is;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-nn._internalPadding*t,-(nn._internalPadding+this.#Vs)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(v.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#cn=new AbortController;const t=this._uiManager.combinedSignal(this.#cn);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#hn),this._isDraggable=!0,this.#cn?.abort(),this.#cn=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width||(this.enableEditMode(),this.editorDiv.focus(),this._initialOptions?.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()}#gn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(nn.#mn(i)),e=i);return t.join("\n")}#pn(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180===this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#ln,e=this.#ln=this.#gn().trimEnd();if(t===e)return;const i=t=>{this.#ln=t,t?(this.#fn(),this._uiManager.rebuild(this),this.#pn()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#pn()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){nn._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){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)}
2render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#hn),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:i}=this.editorDiv;if(i.fontSize=`calc(${this.#Vs}px * var(--scale-factor))`,i.color=this.#Is,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),ne(this,this.div,["dblclick","keydown"]),this.width){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);const[o,l]=this.pageDimensions,[h,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=t+(n[0]-h)/o,u=e+this.height-(n[1]-c)/l;break;case 90:d=t+(n[0]-h)/o,u=e-(n[1]-c)/l,[a,r]=[r,-a];break;case 180:d=t-this.width+(n[0]-h)/o,u=e-(n[1]-c)/l,[a,r]=[-a,-r];break;case 270:d=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-c-this.width*o)/l,[a,r]=[-r,a]}this.setAt(d*i,u*s,a,r)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#fn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#mn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(sn,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=nn.#bn(e.getData("text")||"").replaceAll(sn,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const a=n.getRangeAt(0);if(!s.includes("\n"))return a.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:r,startOffset:o}=a,l=[],h=[];if(r.nodeType===Node.TEXT_NODE){const t=r.parentElement;if(h.push(r.nodeValue.slice(o).replaceAll(sn,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(nn.#mn(i)):e=h}l.push(r.nodeValue.slice(0,o).replaceAll(sn,""))}else if(r===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(nn.#mn(i))}this.#ln=`${l.join("\n")}${s}${h.join("\n")}`,this.#fn();const c=new Range;let d=l.reduce(((t,e)=>t+e.length),0);for(const{firstChild:u}of this.editorDiv.childNodes)if(u.nodeType===Node.TEXT_NODE){const t=u.nodeValue.length;if(d<=t){c.setStart(u,d),c.setEnd(u,d);break}d-=t}n.removeAllRanges(),n.addRange(c)}#fn(){if(this.editorDiv.replaceChildren(),this.#ln)for(const t of this.#ln.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#vn(){return this.#ln.replaceAll("\xa0"," ")}static#bn(t){return t.replaceAll(" ","\xa0")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof js){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:a,id:r,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:c}}}=t;if(!l||0===l.length)return null;s=t={annotationType:v.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:c-1,rect:n.slice(0),rotation:a,id:r,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,i);return n.#Vs=t.fontSize,n.#Is=xt.makeHexColor(...t.color),n.#ln=nn.#bn(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=nn._internalPadding*this.parentScale,i=this.getRect(e,e),s=ue._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#Is),n={annotationType:v.FREETEXT,color:s,fontSize:this.#Vs,value:this.#vn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#An(n)?null:(n.id=this.annotationElementId,n)}#An(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#Vs}px * var(--scale-factor))`,i.color=this.#Is,e.replaceChildren();for(const n of this.#ln.split("\n")){const t=document.createElement("div");t.append(n?document.createTextNode(n):document.createElement("br")),e.append(t)}const s=nn._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#ln}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class an{toSVGPath(){at("Abstract method `toSVGPath` must be implemented.")}get box(){at("Abstract getter `box` must be implemented.")}serialize(t,e){at("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){at("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){at("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}class rn{#yn;#wn=[];#xn;#_n;#Cn=[];#En=(()=>new Float64Array(18))();#Sn;#Tn;#Mn;#kn;#Rn;#Pn;#In=[];static#Ln=8;static#Dn=2;static#Fn=(()=>
2rn.#Ln+rn.#Dn)();constructor(t,e,i,s,n){let{x:a,y:r}=t,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;this.#yn=e,this.#Pn=s*i,this.#_n=n,this.#En.set([NaN,NaN,NaN,NaN,a,r],6),this.#xn=o,this.#kn=rn.#Ln*i,this.#Mn=rn.#Fn*i,this.#Rn=i,this.#In.push(a,r)}isEmpty(){return isNaN(this.#En[8])}#Nn(){const t=this.#En.subarray(4,6),e=this.#En.subarray(16,18),[i,s,n,a]=this.#yn;return[(this.#Sn+(t[0]-e[0])/2-i)/n,(this.#Tn+(t[1]-e[1])/2-s)/a,(this.#Sn+(e[0]-t[0])/2-i)/n,(this.#Tn+(e[1]-t[1])/2-s)/a]}add(t){let{x:e,y:i}=t;this.#Sn=e,this.#Tn=i;const[s,n,a,r]=this.#yn;let[o,l,h,c]=this.#En.subarray(8,12);const d=e-h,u=i-c,p=Math.hypot(d,u);if(p<this.#Mn)return!1;const g=p-this.#kn,m=g/p,f=m*d,b=m*u;let v=o,A=l;o=h,l=c,h+=f,c+=b,this.#In?.push(e,i);const y=f/g,w=-b/g*this.#Pn,x=y*this.#Pn;if(this.#En.set(this.#En.subarray(2,8),0),this.#En.set([h+w,c+x],4),this.#En.set(this.#En.subarray(14,18),12),this.#En.set([h-w,c-x],16),isNaN(this.#En[6]))return 0===this.#Cn.length&&(this.#En.set([o+w,l+x],2),this.#Cn.push(NaN,NaN,NaN,NaN,(o+w-s)/a,(l+x-n)/r),this.#En.set([o-w,l-x],14),this.#wn.push(NaN,NaN,NaN,NaN,(o-w-s)/a,(l-x-n)/r)),this.#En.set([v,A,o,l,h,c],6),!this.isEmpty();this.#En.set([v,A,o,l,h,c],6);return Math.abs(Math.atan2(A-l,v-o)-Math.atan2(b,f))<Math.PI/2?([o,l,h,c]=this.#En.subarray(2,6),this.#Cn.push(NaN,NaN,NaN,NaN,((o+h)/2-s)/a,((l+c)/2-n)/r),[o,l,v,A]=this.#En.subarray(14,18),this.#wn.push(NaN,NaN,NaN,NaN,((v+o)/2-s)/a,((A+l)/2-n)/r),!0):([v,A,o,l,h,c]=this.#En.subarray(0,6),this.#Cn.push(((v+5*o)/6-s)/a,((A+5*l)/6-n)/r,((5*o+h)/6-s)/a,((5*l+c)/6-n)/r,((o+h)/2-s)/a,((l+c)/2-n)/r),[h,c,o,l,v,A]=this.#En.subarray(12,18),this.#wn.push(((v+5*o)/6-s)/a,((A+5*l)/6-n)/r,((5*o+h)/6-s)/a,((5*l+c)/6-n)/r,((o+h)/2-s)/a,((l+c)/2-n)/r),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#Cn,e=this.#wn;if(isNaN(this.#En[6])&&!this.isEmpty())return this.#On();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let s=6;s<t.length;s+=6)isNaN(t[s])?i.push(`L${t[s+4]} ${t[s+5]}`):i.push(`C${t[s]} ${t[s+1]} ${t[s+2]} ${t[s+3]} ${t[s+4]} ${t[s+5]}`);this.#Bn(i);for(let s=e.length-6;s>=6;s-=6)isNaN(e[s])?i.push(`L${e[s+4]} ${e[s+5]}`):i.push(`C${e[s]} ${e[s+1]} ${e[s+2]} ${e[s+3]} ${e[s+4]} ${e[s+5]}`);return this.#zn(i),i.join(" ")}#On(){const[t,e,i,s]=this.#yn,[n,a,r,o]=this.#Nn();return`M${(this.#En[2]-t)/i} ${(this.#En[3]-e)/s} L${(this.#En[4]-t)/i} ${(this.#En[5]-e)/s} L${n} ${a} L${r} ${o} L${(this.#En[16]-t)/i} ${(this.#En[17]-e)/s} L${(this.#En[14]-t)/i} ${(this.#En[15]-e)/s} Z`}#zn(t){const e=this.#wn;t.push(`L${e[4]} ${e[5]} Z`)}#Bn(t){const[e,i,s,n]=this.#yn,a=this.#En.subarray(4,6),r=this.#En.subarray(16,18),[o,l,h,c]=this.#Nn();t.push(`L${(a[0]-e)/s} ${(a[1]-i)/n} L${o} ${l} L${h} ${c} L${(r[0]-e)/s} ${(r[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,a){return new on(t,e,i,s,n,a)}getOutlines(){const t=this.#Cn,e=this.#wn,i=this.#En,[s,n,a,r]=this.#yn,o=new Float64Array((this.#In?.length??0)+2);for(let c=0,d=o.length-2;c<d;c+=2)o[c]=(this.#In[c]-s)/a,o[c+1]=(this.#In[c+1]-n)/r;if(o[o.length-2]=(this.#Sn-s)/a,o[o.length-1]=(this.#Tn-n)/r,isNaN(i[6])&&!this.isEmpty())return this.#Hn(o);const l=new Float64Array(this.#Cn.length+24+this.#wn.length);let h=t.length;for(let c=0;c<h;c+=2)isNaN(t[c])?l[c]=l[c+1]=NaN:(l[c]=t[c],l[c+1]=t[c+1]);h=this.#jn(l,h);for(let c=e.length-6;c>=6;c-=6)for(let t=0;t<6;t+=2)isNaN(e[c+t])?(l[h]=l[h+1]=NaN,h+=2):(l[h]=e[c+t],l[h+1]=e[c+t+1],h+=2);return this.#Un(l,h),this.newFreeDrawOutline(l,o,this.#yn,this.#Rn,this.#xn,this.#_n)}#Hn(t){const e=this.#En,[i,s,n,a]=this.#yn,[r,o,l,h]=this.#Nn(),c=new Float64Array(36);return c.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/a,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/a,NaN,NaN,NaN,NaN,r,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/a,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/a],0),this.newFreeDrawOutline(c,t,this.#yn,this.#Rn,this.#xn,this.#_n)}#Un(t,e){const i=this.#wn;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#jn(t,e){const i=this.#En.subarray(4,6),s=this.#En.subarray(16,18),[n,a,r,o]=this.#yn,[l,h,c,d]=this.#Nn();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/r,(i[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(s[0]-n)/r,(s[1]-a)/o],e),e+24}}class on extends an{#yn;#$n=null;#xn;#_n;#In;#Rn;#Gn;constructor(t,e,i,s,n,a){super(),this.#Gn=t,this.#In=e,this.#yn=i,this.#Rn=s,this.#xn=n,this.#_n=a,this.#Vn(a);const{x:r,y:o,width:l,height:h}=this.#$n;for(let c=0,d=t.length;c<d;c+=2)t[c]=(t[c]-r)/l,t[c+1]=(t[c+1]-o)/h;for(let c=0,d=e.length;c<d;c+=2)e[c]=(e[c]-r)/l,e[c+1]=(e[c+1]-o)/h}toSVGPath(){const t=[`M${this.#Gn[4]} ${this.#Gn[5]}`];for(let e=6,i=this.#Gn.length;e<i;e+=6)isNaN(this.#Gn[e])?t.push(`L${this.#Gn[e+4]} ${this.#Gn[e+5]}`):t.push(`C${this.#Gn[e]} ${this.#Gn[e+1]} ${this.#Gn[e+2]} ${this.#Gn[e+3]} ${this.#Gn[e+4]} ${this.#Gn[e+5]}`);return t.push("Z"),t.join(" ")}serialize(t,e){let[i,s,n,a]=t;const r=n-i,o=a-s;let l,h;switch(e){case 0:l=this.#Wn(this.#Gn,i,a,r,-o),h=this.#Wn(this.#In,i,a,r,-o);break;case 90:l=this.#qn(this.#Gn,i,s,r,o),h=this.#qn(this.#In,i,s,r,o);break;case 180:l=this.#Wn(this.#Gn,n,s,-r,o),h=this.#Wn(this.#In,n,s,-r,o);break;case 270:l=this.#qn(this.#Gn,n,a,-r,-o),h=this.#qn(this.#In,n,a,-r,-o)}return{outline:Array.from(l),points:[Array.from(h)]}}#Wn(t,e,i,s,n){const a=new Float64Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r]*s,a[r+1]=i+t[r+1]*n;return a}#qn(t,e,i,s,n){const a=new Float64Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r+1]*s,a[r+1]=i+t[r]*n;return a}#Vn(t){const e=this.#Gn;let i=e[4],s=e[5],n=i,a=s,r=i,o=s,l=i,h=s;const c=t?Math.max:Math.min;for(let m=6,f=e.length;m<f;m+=6){if(isNaN(e[m]))n=Math.min(n,e[m+4]),a=Math.min(a,e[m+5]),r=Math.max(r,e[m+4]),o=Math.max(o,e[m+5]),h<e[m+5]?(l=e[m+4],h=e[m+5]):h===e[m+5]&&(l=c(l,e[m+4]));else{const t=xt.bezierBoundingBox(i,s,...e.slice(m,m+6));n=Math.min(n,t[0]),a=Math.min(a,t[1]),r=Math.max(r,t[2]),o=Math.max(o,t[3]),h<t[3]?(l=t[2],h=t[3]):h===t[3]&&(l=c(l,t[2]))}i=e[m+4],s=e[m+5]}const d=n-this.#xn,u=a-this.#xn,p=r-n+2*this.#xn,g=o-a+2*this.#xn;this.#$n={x:d,y:u,width:p,height:g,lastPoint:[l,h]}}get box(){return this.#$n}newOutliner(t,e,i,s,n){return new rn(t,e,i,s,n,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}getNewOutline(t,e){const{x:i,y:s,width:n,height:a}=this.#$n,[r,o,l,h]=this.#yn,c=n*l,d=a*h,u=i*l+r,p=s*h+o,g=this.newOutliner({x:this.#In[0]*c+u,y:this.#In[1]*d+p},this.#yn,this.#Rn,t,this.#_n,e??this.#xn);for(let m=2;m<this.#In.length;m+=2)g.add({x:this.#In[m]*c+u,y:this.#In[m+1]*d+p});return g.getOutlines()}get mustRemoveSelfIntersections(){return!0}}class ln{#yn;#Xn=[];#Kn=[];constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,s=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],n=1/0,a=-1/0,r=1/0,o=-1/0;const l=10**-4;for(const{x:m,y:f,width:b,height:v}of t){const t=Math.floor((m-e)/l)*l,i=Math.ceil((m+b+e)/l)*l,s=Math.floor((f-e)/l)*l,h=Math.ceil((f+v+e)/l)*l,c=[t,s,h,!0],d=[i,s,h,!1];this.#Xn.push(c,d),n=Math.min(n,t),a=Math.max(a,i),r=Math.min(r,s),o=Math.max(o,h)}const h=a-n+2*i,c=o-r+2*i,d=n-i,u=r-i,p=this.#Xn.at(s?-1:-2),g=[p[0],p[2]];for(const m of this.#Xn){const[t,e,i]=m;m[0]=(t-d)/h,m[1]=(e-u)/c,m[2]=(i-u)/c}this.#yn={x:d,y:u,width:h,height:c,lastPoint:g}}getOutlines(){this.#Xn.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#Xn)e[3]?(t.push(...this.#Yn(e)),this.#Qn(e)):(this.#Jn(e),t.push(...this.#Yn(e)));return this.#Zn(t)}#Zn(t){const e=[],i=new Set;for(const a of t){const[t,i,s]=a;e.push([t,i,a],[t,s,a])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let a=0,r=e.length;a<r;a+=2){const t=e[a][2],s=e[a+1][2];t.push(s),s.push(t),i.add(t),i.add(s)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,a,r,o,l]=t;i.delete(t);let h=e,c=a;for(n=[e,r],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,a,r,o,l]=t,h!==e&&(n.push(h,c,e,c===a?a:r),h=e),c=c===a?r:a}n.push(h,c)}return new hn(s,this.#yn)}#ta(t){const e=this.#Kn;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,a=e[n][0];if(a===t)return n;a<t?i=n+1:s=n-1}return s+1}#Qn(t){let[,e,i]=t;const s=this.#ta(e);this.#Kn.splice(s,0,[e,i])}#Jn(t){let[,e,i]=t;const s=this.#ta(e);for(let n=s;n<this.#Kn.length;n++){const[t,s]=this.#Kn[n];if(t!==e)break;if(t===e&&s===i)return void this.#Kn.splice(n,1)}for(let n=s-1;n>=0;n--){const[t,s]=this.#Kn[n];if(t!==e)break;if(t===e&&s===i)return void this.#Kn.splice(n,1)}}#Yn(t){const[e,i,s]=t,n=[[e,i,s]],a=this.#ta(s);for(let r=0;r<a;r++){const[t,i]=this.#Kn[r];for(let s=0,a=n.length;s<a;s++){const[,r,o]=n[s];if(!(i<=r||o<=t))if(r>=t)if(o>i)n[s][1]=i;else{if(1===a)return[];n.splice(s,1),s--,a--}else n[s][2]=t,o>i&&n.push([e,i,o])}}return n}}class hn extends an{#yn;#ea;constructor(t,e){super(),this.#ea=t,this.#yn=e}toSVGPath(){const t=[];for(const e of this.#ea){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const a=e[n],r=e[n+1];a===i?(t.push(`V${r}`),s=r):r===s&&(t.push(`H${a}`),i=a)}t.push("Z")}return t.join(" ")}serialize(t,e){let[i,s,n,a]=t;const r=[],o=n-i,l=a-s;for(const h of this.#ea){const t=new Array(h.length);for(let e=0;e<h.length;e+=2)t[e]=i+h[e]*o,t[e+1]=a-h[e+1]*l;r.push(t)}return r}get box(){return this.#yn}get classNamesForDrawing(){return["highlight"]}get classNamesForOutlining(){return["highlightOutline"]}}class cn extends rn{newFreeDrawOutline(t,e,i,s,n,a){return new dn(t,e,i,s,n,a)}get classNamesForDrawing(){return["highlight","free"]}}class dn extends on{get classNamesForDrawing(){return["highlight","free"]}get classNamesForOutlining(){return["highlightOutline","free"]}newOutliner(t,e,i,s,n){return new cn(t,e,i,s,n,arguments.length>5&&void 0!==arguments[5]?arguments[5]:0)}}class un{#ia=null;#sa=null;#na;#aa=null;#ra=!1;#oa=!1;#a=null;#la;#ha=null;#m=null;#ca;static#da=null;static get _keyboardManager(){return lt(this,"_keyboardManager",new le([[["Escape","mac+Escape"],un.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],un.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],un.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],un.prototype._moveToPrevious],[["Home","mac+Home"],un.prototype._moveToBeginning],[["End","mac+End"],un.prototype._moveToEnd]]))}constructor(t){let{editor:e=null,uiManager:i=null}=t;e?(this.#oa=!1,this.#ca=A.HIGHLIGHT_COLOR,this.#a=e):(this.#oa=!0,this.#ca=A.HIGHLIGHT_DEFAULT_COLOR),this.#m=e?._uiManager||i,this.#la=this.#m._eventBus,this.#na=e?.color||this.#m?.highlightColors.values().next().value||"#FFFF98",un.#da||=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"})}renderButton(){const t=this.#ia=document.createElement("button");
2t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#m._signal;t.addEventListener("click",this.#ua.bind(this),{signal:e}),t.addEventListener("keydown",this.#Es.bind(this),{signal:e});const i=this.#sa=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#na,t.append(i),t}renderMainDropdown(){const t=this.#aa=this.#pa();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#pa(){const t=document.createElement("div"),e=this.#m._signal;t.addEventListener("contextmenu",qt,{signal:e}),t.className="dropdown",t.role="listbox",t.setAttribute("aria-multiselectable",!1),t.setAttribute("aria-orientation","vertical"),t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[i,s]of this.#m.highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",s),n.title=i,n.setAttribute("data-l10n-id",un.#da[i]);const a=document.createElement("span");n.append(a),a.className="swatch",a.style.backgroundColor=s,n.setAttribute("aria-selected",s===this.#na),n.addEventListener("click",this.#ga.bind(this,s),{signal:e}),t.append(n)}return t.addEventListener("keydown",this.#Es.bind(this),{signal:e}),t}#ga(t,e){e.stopPropagation(),this.#la.dispatch("switchannotationeditorparams",{source:this,type:this.#ca,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#ia)return void this.#ua(t);const e=t.target.getAttribute("data-color");e&&this.#ga(e,t)}_moveToNext(t){this.#ma?t.target!==this.#ia?t.target.nextSibling?.focus():this.#aa.firstChild?.focus():this.#ua(t)}_moveToPrevious(t){t.target!==this.#aa?.firstChild&&t.target!==this.#ia?(this.#ma||this.#ua(t),t.target.previousSibling?.focus()):this.#ma&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#ma?this.#aa.firstChild?.focus():this.#ua(t)}_moveToEnd(t){this.#ma?this.#aa.lastChild?.focus():this.#ua(t)}#Es(t){un._keyboardManager.exec(this,t)}#ua(t){if(this.#ma)return void this.hideDropdown();if(this.#ra=0===t.detail,this.#ha||(this.#ha=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#m.combinedSignal(this.#ha)})),this.#aa)return void this.#aa.classList.remove("hidden");const e=this.#aa=this.#pa();this.#ia.append(e)}#h(t){this.#aa?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#aa?.classList.add("hidden"),this.#ha?.abort(),this.#ha=null}get#ma(){return this.#aa&&!this.#aa.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#oa||(this.#ma?(this.hideDropdown(),this.#ia.focus({preventScroll:!0,focusVisible:this.#ra})):this.#a?.unselect())}updateColor(t){if(this.#sa&&(this.#sa.style.backgroundColor=t),!this.#aa)return;const e=this.#m.highlightColors.values();for(const i of this.#aa.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#ia?.remove(),this.#ia=null,this.#sa=null,this.#aa?.remove(),this.#aa=null}}class pn extends ue{#fa=null;#ba=0;#va;#Aa=null;#n=null;#ya=null;#wa=null;#xa=0;#_a=null;#Ca=null;#A=null;#Ea=!1;#Sa=null;#Ta;#Ma=null;#ka="";#Pn;#Ra="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=(()=>v.HIGHLIGHT)();static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=pn.prototype;return lt(this,"_keyboardManager",new le([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||pn._defaultColor,this.#Pn=t.thickness||pn._defaultThickness,this.#Ta=t.opacity||pn._defaultOpacity,this.#va=t.boxes||null,this.#Ra=t.methodOfCreation||"",this.#ka=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#Ea=!0,this.#Pa(t),this.#Ia()):this.#va&&(this.#fa=t.anchorNode,this.#ba=t.anchorOffset,this.#wa=t.focusNode,this.#xa=t.focusOffset,this.#La(),this.#Ia(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Ea?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#Pn,methodOfCreation:this.#Ra}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#La(){const t=new ln(this.#va,.001);this.#Ca=t.getOutlines(),({x:this.x,y:this.y,width:this.width,height:this.height}=this.#Ca.box);const e=new ln(this.#va,.0025,.001,"ltr"===this._uiManager.direction);this.#ya=e.getOutlines();const{lastPoint:i}=this.#ya.box;this.#Sa=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Pa(t){let{highlightOutlines:e,highlightId:i,clipPathId:s}=t;this.#Ca=e;if(this.#ya=e.getNewOutline(this.#Pn/2+1.5,.0025),i>=0)this.#A=i,this.#Aa=s,this.parent.drawLayer.finalizeLine(i,e),this.#Ma=this.parent.drawLayer.drawOutline(this.#ya);else if(this.parent){const t=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#A,e),this.parent.drawLayer.updateBox(this.#A,pn.#Da(this.#Ca.box,(t-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#Ma,this.#ya),this.parent.drawLayer.updateBox(this.#Ma,pn.#Da(this.#ya.box,t))}const{x:n,y:a,width:r,height:o}=e.box;switch(this.rotation){case 0:this.x=n,this.y=a,this.width=r,this.height=o;break;case 90:{const[t,e]=this.parentDimensions;this.x=a,this.y=1-n,this.width=r*e/t,this.height=o*t/e;break}case 180:this.x=1-n,this.y=1-a,this.width=r,this.height=o;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-a,this.y=n,this.width=r*e/t,this.height=o*t/e;break}}const{lastPoint:l}=this.#ya.box;this.#Sa=[(l[0]-n)/r,(l[1]-a)/o]}static initialize(t,e){ue.initialize(t,e),pn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case A.HIGHLIGHT_DEFAULT_COLOR:pn._defaultColor=e;break;case A.HIGHLIGHT_THICKNESS:pn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#Sa}updateParams(t,e){switch(t){case A.HIGHLIGHT_COLOR:this.#un(e);break;case A.HIGHLIGHT_THICKNESS:this.#Fa(e)}}static get defaultPropertiesToUpdate(){return[[A.HIGHLIGHT_DEFAULT_COLOR,pn._defaultColor],[A.HIGHLIGHT_THICKNESS,pn._defaultThickness]]}get propertiesToUpdate(){return[[A.HIGHLIGHT_COLOR,this.color||pn._defaultColor],[A.HIGHLIGHT_THICKNESS,this.#Pn||pn._defaultThickness],[A.HIGHLIGHT_FREE,this.#Ea]]}#un(t){const e=(t,e)=>{this.color=t,this.parent?.drawLayer.changeColor(this.#A,t),this.#n?.updateColor(t),this.#Ta=e,this.parent?.drawLayer.changeOpacity(this.#A,e)},i=this.color,s=this.#Ta;this.addCommands({cmd:e.bind(this,t,pn._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#Fa(t){const e=this.#Pn,i=t=>{this.#Pn=t,this.#Na(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#n=new un({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#Oa())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#Oa())}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#Ba(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Ia(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#Ba():t&&(this.#Ia(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#Na(t){if(!this.#Ea)return;this.#Pa({highlightOutlines:this.#Ca.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#Ba(){null!==this.#A&&this.parent&&(this.parent.drawLayer.remove(this.#A),this.#A=null,this.parent.drawLayer.remove(this.#Ma),this.#Ma=null)}#Ia(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.parent;null===this.#A&&(({id:this.#A,clipPathId:this.#Aa}=t.drawLayer.draw(this.#Ca,this.color,this.#Ta)),this.#Ma=t.drawLayer.drawOutline(this.#ya),this.#_a&&(this.#_a.style.clipPath=this.#Aa))}static#Da(t,e){let{x:i,y:s,width:n,height:a}=t;switch(e){case 90:return{x:1-s-a,y:i,width:a,height:n};case 180:return{x:1-i-n,y:1-s-a,width:n,height:a};case 270:return{x:s,y:1-i-n,width:a,height:n}}return{x:i,y:s,width:n,height:a}}rotate(t){const{drawLayer:e}=this.parent;let i;this.#Ea?(t=(t-this.rotation+360)%360,i=pn.#Da(this.#Ca.box,t)):i=pn.#Da(this,t),e.rotate(this.#A,t),e.rotate(this.#Ma,t),e.updateBox(this.#A,i),e.updateBox(this.#Ma,pn.#Da(this.#ya.box,t))}
2render(){if(this.div)return this.div;const t=super.render();this.#ka&&(t.setAttribute("aria-label",this.#ka),t.setAttribute("role","mark")),this.#Ea?t.classList.add("free"):this.div.addEventListener("keydown",this.#za.bind(this),{signal:this._uiManager._signal});const e=this.#_a=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#Aa;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),ne(this,this.#_a,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent.drawLayer.addClass(this.#Ma,"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(this.#Ma,"hovered")}#za(t){pn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#Ha(!0);break;case 1:case 3:this.#Ha(!1)}}#Ha(t){if(!this.#fa)return;const e=window.getSelection();t?e.setPosition(this.#fa,this.#ba):e.setPosition(this.#wa,this.#xa)}select(){super.select(),this.#Ma&&(this.parent?.drawLayer.removeClass(this.#Ma,"hovered"),this.parent?.drawLayer.addClass(this.#Ma,"selected"))}unselect(){super.unselect(),this.#Ma&&(this.parent?.drawLayer.removeClass(this.#Ma,"selected"),this.#Ea||this.#Ha(!1))}get _mustFixPosition(){return!this.#Ea}show(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._isVisible;super.show(t),this.parent&&(this.parent.drawLayer.show(this.#A,t),this.parent.drawLayer.show(this.#Ma,t))}#Oa(){return this.#Ea?this.rotation:0}#ja(){if(this.#Ea)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#va,a=new Float32Array(8*n.length);let r=0;for(const{x:o,y:l,width:h,height:c}of n){const n=o*t+i,d=(1-l-c)*e+s;a[r]=a[r+4]=n,a[r+1]=a[r+3]=d,a[r+2]=a[r+6]=n+h*t,a[r+5]=a[r+7]=d+c*e,r+=8}return a}#Ua(t){return this.#Ca.serialize(t,this.#Oa())}static startHighlighting(t,e,i){let{target:s,x:n,y:a}=i;const{x:r,y:o,width:l,height:h}=s.getBoundingClientRect(),c=new AbortController,d=t.combinedSignal(c),u=e=>{c.abort(),this.#$a(t,e)};window.addEventListener("blur",u,{signal:d}),window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("pointerdown",(t=>{t.preventDefault(),t.stopPropagation()}),{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",qt,{signal:d}),s.addEventListener("pointermove",this.#Ga.bind(this,t),{signal:d}),this._freeHighlight=new cn({x:n,y:a},[r,o,l,h],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0))}static#Ga(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static#$a(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof Ks){const{data:{quadPoints:e,rect:i,rotation:n,id:a,color:r,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:v.HIGHLIGHT,color:Array.from(r),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}else if(t instanceof Xs){const{data:{inkLists:e,rect:i,rotation:n,id:a,color:r,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:v.HIGHLIGHT,color:Array.from(r),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}const{color:n,quadPoints:a,inkLists:r,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=xt.makeHexColor(...n),l.#Ta=o||1,r&&(l.#Pn=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,c]=l.pageDimensions,[d,u]=l.pageTranslation;if(a){const t=l.#va=[];for(let e=0;e<a.length;e+=8)t.push({x:(a[e]-d)/h,y:1-(a[e+1]-u)/c,width:(a[e+2]-a[e])/h,height:(a[e+1]-a[e+5])/c});l.#La(),l.#Ia(),l.rotate(l.rotation)}else if(r){l.#Ea=!0;const t=r[0],i={x:t[0]-d,y:c-(t[1]-u)},s=new cn(i,[0,0,h,c],1,l.#Pn/2,!0,.001);for(let e=0,r=t.length;e<r;e+=2)i.x=t[e]-d,i.y=c-(t[e+1]-u),s.add(i);const{id:n,clipPathId:a}=e.drawLayer.draw(s,l.color,l._defaultOpacity,!0);l.#Pa({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:a}),l.#Ia()}return l}serialize(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=ue._colorManager.convert(this.color),s={annotationType:v.HIGHLIGHT,color:i,opacity:this.#Ta,thickness:this.#Pn,quadPoints:this.#ja(),outlines:this.#Ua(e),pageIndex:this.pageIndex,rect:e,rotation:this.#Oa(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#An(s)?null:(s.id=this.annotationElementId,s)}#An(t){const{color:e}=this._initialData;return t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class gn extends ue{#Va=0;#Wa=0;#qa=null;#Xa=(()=>new Path2D)();#Ka=!1;#Ya=null;#Qa=!1;#Ja=!1;#Za=null;#tr=null;#er=0;#ir=0;#sr=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";static _editorType=(()=>v.INK)();constructor(t){super({...t,name:"inkEditor"}),this.color=t.color||null,this.thickness=t.thickness||null,this.opacity=t.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(t,e){ue.initialize(t,e)}static updateDefaultParams(t,e){switch(t){case A.INK_THICKNESS:gn._defaultThickness=e;break;case A.INK_COLOR:gn._defaultColor=e;break;case A.INK_OPACITY:gn._defaultOpacity=e/100}}updateParams(t,e){switch(t){case A.INK_THICKNESS:this.#Fa(e);break;case A.INK_COLOR:this.#un(e);break;case A.INK_OPACITY:this.#nr(e)}}static get defaultPropertiesToUpdate(){return[[A.INK_THICKNESS,gn._defaultThickness],[A.INK_COLOR,gn._defaultColor||ue._defaultLineColor],[A.INK_OPACITY,Math.round(100*gn._defaultOpacity)]]}get propertiesToUpdate(){return[[A.INK_THICKNESS,this.thickness||gn._defaultThickness],[A.INK_COLOR,this.color||gn._defaultColor||ue._defaultLineColor],[A.INK_OPACITY,Math.round(100*(this.opacity??gn._defaultOpacity))]]}#Fa(t){const e=t=>{this.thickness=t,this.#ar()},i=this.thickness;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#un(t){const e=t=>{this.color=t,this.#rr()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#nr(t){const e=t=>{this.opacity=t,this.#rr()};t/=100;const i=this.opacity;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.canvas||(this.#or(),this.#lr()),this.isAttachedToDOM||(this.parent.add(this),this.#hr()),this.#ar()))}remove(){null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#qa&&(clearTimeout(this.#qa),this.#qa=null),this.#Za?.disconnect(),this.#Za=null,super.remove())}setParent(t){!this.parent&&t?this._uiManager.removeShouldRescale(this):this.parent&&null===t&&this._uiManager.addShouldRescale(this),super.setParent(t)}onScaleChanging(){const[t,e]=this.parentDimensions,i=this.width*t,s=this.height*e;this.setDimensions(i,s)}
2enableEditMode(){this.#Ka||null===this.canvas||(super.enableEditMode(),this._isDraggable=!1,this.#cr())}disableEditMode(){this.isInEditMode()&&null!==this.canvas&&(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.#dr())}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}#ur(){const{parentRotation:t,parentDimensions:[e,i]}=this;switch(t){case 90:return[0,i,i,e];case 180:return[e,i,e,i];case 270:return[e,0,i,e];default:return[0,0,e,i]}}#pr(){const{ctx:t,color:e,opacity:i,thickness:s,parentScale:n,scaleFactor:a}=this;t.lineWidth=s*n/a,t.lineCap="round",t.lineJoin="round",t.miterLimit=10,t.strokeStyle=`${e}${function(t){return Math.round(Math.min(255,Math.max(1,255*t))).toString(16).padStart(2,"0")}(i)}`}#gr(t,e){this.canvas.addEventListener("contextmenu",qt,{signal:this._uiManager._signal}),this.#dr(),this.#Ya=new AbortController;const i=this._uiManager.combinedSignal(this.#Ya);this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:i}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:i}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:i}),this.isEditing=!0,this.#Ja||(this.#Ja=!0,this.#hr(),this.thickness||=gn._defaultThickness,this.color||=gn._defaultColor||ue._defaultLineColor,this.opacity??=gn._defaultOpacity),this.currentPath.push([t,e]),this.#Qa=!1,this.#pr(),this.#sr=()=>{this.#mr(),this.#sr&&window.requestAnimationFrame(this.#sr)},window.requestAnimationFrame(this.#sr)}#fr(t,e){const[i,s]=this.currentPath.at(-1);if(this.currentPath.length>1&&t===i&&e===s)return;const n=this.currentPath;let a=this.#Xa;if(n.push([t,e]),this.#Qa=!0,n.length<=2)return a.moveTo(...n[0]),void a.lineTo(t,e);3===n.length&&(this.#Xa=a=new Path2D,a.moveTo(...n[0])),this.#br(a,...n.at(-3),...n.at(-2),t,e)}#vr(){if(0===this.currentPath.length)return;const t=this.currentPath.at(-1);this.#Xa.lineTo(...t)}#Ar(t,e){let i;if(this.#sr=null,t=Math.min(Math.max(t,0),this.canvas.width),e=Math.min(Math.max(e,0),this.canvas.height),this.#fr(t,e),this.#vr(),1!==this.currentPath.length)i=this.#yr();else{const s=[t,e];i=[[s,s.slice(),s.slice(),s]]}const s=this.#Xa,n=this.currentPath;this.currentPath=[],this.#Xa=new Path2D;this.addCommands({cmd:()=>{this.allRawPaths.push(n),this.paths.push(i),this.bezierPath2D.push(s),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(this.canvas||(this.#or(),this.#lr()),this.#ar())},mustExec:!0})}#mr(){if(!this.#Qa)return;this.#Qa=!1;const t=Math.ceil(this.thickness*this.parentScale),e=this.currentPath.slice(-3),i=e.map((t=>t[0])),s=e.map((t=>t[1])),{ctx:n}=(Math.min(...i),Math.max(...i),Math.min(...s),Math.max(...s),this);n.save(),n.clearRect(0,0,this.canvas.width,this.canvas.height);for(const a of this.bezierPath2D)n.stroke(a);n.stroke(this.#Xa),n.restore()}#br(t,e,i,s,n,a,r){const o=(e+s)/2,l=(i+n)/2,h=(s+a)/2,c=(n+r)/2;t.bezierCurveTo(o+2*(s-o)/3,l+2*(n-l)/3,h+2*(s-h)/3,c+2*(n-c)/3,h,c)}#yr(){const t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];const e=[];let i,[s,n]=t[0];for(i=1;i<t.length-2;i++){const[a,r]=t[i],[o,l]=t[i+1],h=(a+o)/2,c=(r+l)/2,d=[s+2*(a-s)/3,n+2*(r-n)/3],u=[h+2*(a-h)/3,c+2*(r-c)/3];e.push([[s,n],d,u,[h,c]]),[s,n]=[h,c]}const[a,r]=t[i],[o,l]=t[i+1],h=[s+2*(a-s)/3,n+2*(r-n)/3],c=[o+2*(a-o)/3,l+2*(r-l)/3];return e.push([[s,n],h,c,[o,l]]),e}#rr(){if(this.isEmpty())return void this.#wr();this.#pr();const{canvas:t,ctx:e}=this;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height),this.#wr();for(const i of this.bezierPath2D)e.stroke(i)}commit(){this.#Ka||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),this.#Ka=!0,this.div.classList.add("disabled"),this.#ar(!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),this.enableEditMode())}#cr(){if(this.#tr)return;this.#tr=new AbortController;const t=this._uiManager.combinedSignal(this.#tr);this.canvas.addEventListener("pointerdown",this.canvasPointerdown.bind(this),{signal:t})}#dr(){this.pointerdownAC?.abort(),this.pointerdownAC=null}canvasPointerdown(t){0===t.button&&this.isInEditMode()&&!this.#Ka&&(this.setInForeground(),t.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),this.#gr(t.offsetX,t.offsetY))}canvasPointermove(t){t.preventDefault(),this.#fr(t.offsetX,t.offsetY)}canvasPointerup(t){t.preventDefault(),this.#xr(t)}canvasPointerleave(t){this.#xr(t)}#xr(t){this.#Ya?.abort(),this.#Ya=null,this.#cr(),this.#qa&&clearTimeout(this.#qa),this.#qa=setTimeout((()=>{this.#qa=null,this.canvas.removeEventListener("contextmenu",qt)}),10),this.#Ar(t.offsetX,t.offsetY),this.addToAnnotationStorage(),this.setInBackgroun
2d()}#or(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#lr(){this.#Za=new ResizeObserver((t=>{const e=t[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)})),this.#Za.observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{this.#Za?.disconnect(),this.#Za=null}),{once:!0})}get isResizable(){return!this.isEmpty()&&this.#Ka}render(){if(this.div)return this.div;let t,e;this.width&&(t=this.x,e=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,s,n,a]=this.#ur();if(this.setAt(i,s,0,0),this.setDims(n,a),this.#or(),this.width){const[i,s]=this.parentDimensions;this.setAspectRatio(this.width*i,this.height*s),this.setAt(t*i,e*s,this.width*i,this.height*s),this.#Ja=!0,this.#hr(),this.setDims(this.width*i,this.height*s),this.#rr(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#lr(),this.div}#hr(){if(!this.#Ja)return;const[t,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t),this.canvas.height=Math.ceil(this.height*e),this.#wr()}setDimensions(t,e){const i=Math.round(t),s=Math.round(e);if(this.#er===i&&this.#ir===s)return;this.#er=i,this.#ir=s,this.canvas.style.visibility="hidden";const[n,a]=this.parentDimensions;this.width=t/n,this.height=e/a,this.fixAndSetPosition(),this.#Ka&&this.#_r(t,e),this.#hr(),this.#rr(),this.canvas.style.visibility="visible",this.fixDims()}#_r(t,e){const i=this.#Cr(),s=(t-i)/this.#Wa,n=(e-i)/this.#Va;this.scaleFactor=Math.min(s,n)}#wr(){const t=this.#Cr()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)}static#Er(t){const e=new Path2D;for(let i=0,s=t.length;i<s;i++){const[s,n,a,r]=t[i];0===i&&e.moveTo(...s),e.bezierCurveTo(n[0],n[1],a[0],a[1],r[0],r[1])}return e}static#Sr(t,e,i){const[s,n,a,r]=e;switch(i){case 0:for(let e=0,i=t.length;e<i;e+=2)t[e]+=s,t[e+1]=r-t[e+1];break;case 90:for(let e=0,i=t.length;e<i;e+=2){const i=t[e];t[e]=t[e+1]+s,t[e+1]=i+n}break;case 180:for(let e=0,i=t.length;e<i;e+=2)t[e]=a-t[e],t[e+1]+=n;break;case 270:for(let e=0,i=t.length;e<i;e+=2){const i=t[e];t[e]=a-t[e+1],t[e+1]=r-i}break;default:throw new Error("Invalid rotation")}return t}static#Tr(t,e,i){const[s,n,a,r]=e;switch(i){case 0:for(let e=0,i=t.length;e<i;e+=2)t[e]-=s,t[e+1]=r-t[e+1];break;case 90:for(let e=0,i=t.length;e<i;e+=2){const i=t[e];t[e]=t[e+1]-n,t[e+1]=i-s}break;case 180:for(let e=0,i=t.length;e<i;e+=2)t[e]=a-t[e],t[e+1]-=n;break;case 270:for(let e=0,i=t.length;e<i;e+=2){const i=t[e];t[e]=r-t[e+1],t[e+1]=a-i}break;default:throw new Error("Invalid rotation")}return t}#Mr(t,e,i,s){const n=[],a=this.thickness/2,r=t*e+a,o=t*i+a;for(const l of this.paths){const e=[],i=[];for(let s=0,n=l.length;s<n;s++){const[a,h,c,d]=l[s];if(a[0]===d[0]&&a[1]===d[1]&&1===n){const s=t*a[0]+r,n=t*a[1]+o;e.push(s,n),i.push(s,n);break}const u=t*a[0]+r,p=t*a[1]+o,g=t*h[0]+r,m=t*h[1]+o,f=t*c[0]+r,b=t*c[1]+o,v=t*d[0]+r,A=t*d[1]+o;0===s&&(e.push(u,p),i.push(u,p)),e.push(g,m,f,b,v,A),i.push(g,m),s===n-1&&i.push(v,A)}n.push({bezier:gn.#Sr(e,s,this.rotation),points:gn.#Sr(i,s,this.rotation)})}return n}#kr(){let t=1/0,e=-1/0,i=1/0,s=-1/0;for(const n of this.paths)for(const[a,r,o,l]of n){const n=xt.bezierBoundingBox(...a,...r,...o,...l);t=Math.min(t,n[0]),i=Math.min(i,n[1]),e=Math.max(e,n[2]),s=Math.max(s,n[3])}return[t,i,e,s]}#Cr(){return this.#Ka?Math.ceil(this.thickness*this.parentScale):0}#ar(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.isEmpty())return;if(!this.#Ka)return void this.#rr();const e=this.#kr(),i=this.#Cr();this.#Wa=Math.max(ue.MIN_SIZE,e[2]-e[0]),this.#Va=Math.max(ue.MIN_SIZE,e[3]-e[1]);const s=Math.ceil(i+this.#Wa*this.scaleFactor),n=Math.ceil(i+this.#Va*this.scaleFactor),[a,r]=this.parentDimensions;this.width=s/a,this.height=n/r,this.setAspectRatio(s,n);const o=this.translationX,l=this.translationY;this.translationX=-e[0],this.translationY=-e[1],this.#hr(),this.#rr(),this.#er=s,this.#ir=n,this.setDims(s,n);const h=t?i/this.scaleFactor/2:0;this.translate(o-this.translationX-h,l-this.translationY-h)}static async deserialize(t,e,i){if(t instanceof Xs)return null;const s=await super.deserialize(t,e,i);s.thickness=t.thickness,s.color=xt.makeHexColor(...t.color),s.opacity=t.opacity;const[n,a]=s.pageDimensions,r=s.width*n,o=s.height*a,l=s.parentScale,h=t.thickness/2;s.#Ka=!0,s.#er=Math.round(r),s.#ir=Math.round(o);const{paths:c,rect:d,rotation:u}=t;for(let{bezier:g}
2of c){g=gn.#Tr(g,d,u);const t=[];s.paths.push(t);let e=l*(g[0]-h),i=l*(g[1]-h);for(let s=2,a=g.length;s<a;s+=6){const n=l*(g[s]-h),a=l*(g[s+1]-h),r=l*(g[s+2]-h),o=l*(g[s+3]-h),c=l*(g[s+4]-h),d=l*(g[s+5]-h);t.push([[e,i],[n,a],[r,o],[c,d]]),e=c,i=d}const n=this.#Er(t);s.bezierPath2D.push(n)}const p=s.#kr();return s.#Wa=Math.max(ue.MIN_SIZE,p[2]-p[0]),s.#Va=Math.max(ue.MIN_SIZE,p[3]-p[1]),s.#_r(r,o),s}serialize(){if(this.isEmpty())return null;const t=this.getRect(0,0),e=ue._colorManager.convert(this.ctx.strokeStyle);return{annotationType:v.INK,color:e,thickness:this.thickness,opacity:this.opacity,paths:this.#Mr(this.scaleFactor/this.parentScale,this.translationX,this.translationY,t),pageIndex:this.pageIndex,rect:t,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}}class mn extends ue{#Rr=null;#Pr=null;#Ir=null;#Lr=null;#Dr=null;#Fr="";#Nr=null;#Za=null;#Or=null;#Br=!1;#zr=!1;static _type="stamp";static _editorType=(()=>v.STAMP)();constructor(t){super({...t,name:"stampEditor"}),this.#Lr=t.bitmapUrl,this.#Dr=t.bitmapFile}static initialize(t,e){ue.initialize(t,e)}static get supportedTypes(){return lt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>`image/${t}`)))}static get supportedTypesStr(){return lt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(v.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#Hr(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t?(this.#Rr=t.bitmap,e||(this.#Pr=t.id,this.#Br=t.isSvg),t.file&&(this.#Fr=t.file.name),this.#or()):this.remove()}#jr(){if(this.#Ir=null,this._uiManager.enableWaiting(!1),this.#Nr){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Rr)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Rr){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:a}=t||this.copyCanvas(null,null,!0).imageData,r=await i.guess({name:"altText",request:{data:s,width:n,height:a,channels:s.length/(n*a)}});if(!r)throw new Error("No response from the AI service.");if(r.error)throw new Error("Error from the AI service.");if(r.cancel)return null;if(!r.output)throw new Error("No valid response from the AI service.");const o=r.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#Ur(){if(this.#Pr)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#Pr).then((t=>this.#Hr(t,!0))).finally((()=>this.#jr()));if(this.#Lr){const t=this.#Lr;return this.#Lr=null,this._uiManager.enableWaiting(!0),void(this.#Ir=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Hr(t))).finally((()=>this.#jr())))}if(this.#Dr){const t=this.#Dr;return this.#Dr=null,this._uiManager.enableWaiting(!0),void(this.#Ir=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Hr(t))).finally((()=>this.#jr())))}const t=document.createElement("input");t.type="file",t.accept=mn.supportedTypesStr;const e=this._uiManager._signal;this.#Ir=new Promise((i=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Hr(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#jr())),t.click()}remove(){this.#Pr&&(this.#Rr=null,this._uiManager.imageManager.deleteId(this.#Pr),this.#Nr?.remove(),this.#Nr=null,this.#Za?.disconnect(),this.#Za=null,this.#Or&&(clearTimeout(this.#Or),this.#Or=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#Pr&&null===this.#Nr&&this.#Ur(),this.isAttachedToDOM||this.parent.add(this))):this.#Pr&&this.#Ur()}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#Ir||this.#Rr||this.#Lr||this.#Dr||this.#Pr)}get isResizable(){return!0}
2render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#Rr?this.#or():this.#Ur(),this.width&&!this.annotationElementId){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this.div}#or(){const{div:t}=this;let{width:e,height:i}=this.#Rr;const[s,n]=this.pageDimensions,a=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>a*s||i>a*n){const t=Math.min(a*s/e,a*n/i);e*=t,i*=t}const[r,o]=this.parentDimensions;this.setDims(e*r/s,i*o/n),this._uiManager.enableWaiting(!1);const l=this.#Nr=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#$r(e,i),this.#lr(),this.#zr||(this.parent.addUndoableEditor(this),this.#zr=!0),this._reportTelemetry({action:"inserted_image"}),this.#Fr&&l.setAttribute("aria-label",this.#Fr)}copyCanvas(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];t||(t=224);const{width:s,height:n}=this.#Rr,a=new ee;let r=this.#Rr,o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*a.sx),i=h.height=Math.ceil(l*a.sy);this.#Br||(r=this.#Gr(t,i));const c=h.getContext("2d");c.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(d="#8f8f9d",u="#42414d");const p=15,g=p*a.sx,m=p*a.sy,f=new OffscreenCanvas(2*g,2*m),b=f.getContext("2d");b.fillStyle=d,b.fillRect(0,0,2*g,2*m),b.fillStyle=u,b.fillRect(0,0,g,m),b.fillRect(g,m,g,m),c.fillStyle=c.createPattern(f,"repeat"),c.fillRect(0,0,t,i),c.drawImage(r,0,0,r.width,r.height,0,0,t,i)}let c=null;if(i){let e,i;if(a.symmetric&&r.width<t&&r.height<t)e=r.width,i=r.height;else if(r=this.#Rr,s>t||n>t){const a=Math.min(t/s,t/n);e=Math.floor(s*a),i=Math.floor(n*a),this.#Br||(r=this.#Gr(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(r,0,0,r.width,r.height,0,0,e,i),c={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:c}}#Vr(t,e){const[i,s]=this.parentDimensions;this.width=t/i,this.height=e/s,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,null!==this.#Or&&clearTimeout(this.#Or);this.#Or=setTimeout((()=>{this.#Or=null,this.#$r(t,e)}),200)}#Gr(t,e){const{width:i,height:s}=this.#Rr;let n=i,a=s,r=this.#Rr;for(;n>2*t||a>2*e;){const i=n,s=a;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const o=new OffscreenCanvas(n,a);o.getContext("2d").drawImage(r,0,0,i,s,0,0,n,a),r=o.transferToImageBitmap()}return r}#$r(t,e){const i=new ee,s=Math.ceil(t*i.sx),n=Math.ceil(e*i.sy),a=this.#Nr;if(!a||a.width===s&&a.height===n)return;a.width=s,a.height=n;const r=this.#Br?this.#Rr:this.#Gr(s,n),o=a.getContext("2d");o.filter=this._uiManager.hcmFilter,o.drawImage(r,0,0,r.width,r.height,0,0,s,n)}getImageForAltText(){return this.#Nr}#Wr(t){if(t){if(this.#Br){const t=this._uiManager.imageManager.getSvgUrl(this.#Pr);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#Rr);return t.getContext("2d").drawImage(this.#Rr,0,0),t.toDataURL()}if(this.#Br){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*Ot.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Ot.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#Rr,0,0,this.#Rr.width,this.#Rr.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#Rr)}#lr(){this._uiManager._signal&&(this.#Za=new ResizeObserver((t=>{const e=t[0].contentRect;e.width&&e.height&&this.#Vr(e.width,e.height)})),this.#Za.observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{this.#Za?.disconnect(),this.#Za=null}),{once:!0}))}static async deserialize(t,e,i){let s=null;if(t instanceof Zs){const{data:{rect:n,rotation:a,id:r,structParent:o,popupRef:l},container:h,parent:{page:{pageNumber:c}}}=t,d=h.querySelector("canvas"),u=i.imageManager.getFromCanvas(h.id,d);d.remove();const p=(await e._structTree.getAriaAttributes(`${St}${r}`))?.get("aria-label")||"";s=t={annotationType:v.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:c-1,rect:n.slice(0),rotation:a,id:r,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:o,popupRef:l}}const n=await super.deserialize(t,e,i),{rect:a,bitmap:r,bitmapUrl:o,bitmapId:l,isSvg:h,accessibilityData:c}=t;l&&i.imageManager.isValidId(l)?(n.#Pr=l,r&&(n.#Rr=r)):n.#Lr=o,n.#Br=h;const[d,u]=n.pageDimensions;return n.width=(a[2]-a[0])/d,n.height=(a[3]-a[1])/u,n.annotationElementId=t.id||null,c&&(n.altTextData=c),n._initialData=s,n.#zr=!!s,n}serialize(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:v.STAMP,bitmapId:this.#Pr,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Br,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#Wr(!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#An(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const a=this.#Br?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#Pr)){if(this.#Br){const t=e.stamps.get(this.#Pr);a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=this.#Wr(!1))}}else e.stamps.set(this.#Pr,{area:a,serialized:i}),i.bitmap=this.#Wr(!1);return i}#An(t){const{rect:e,pageIndex:i,accessibilityData:{altText:s}}=this._initialData,n=t.rect.every(((t,i)=>Math.abs(t-e[i])<1)),a=t.pageIndex===i,r=(t.accessibilityData?.alt||"")===s;return{isSame:n&&a&&r,isSameAltText:r}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}class fn{#in;#qr=!1;#Xr=null;#Kr=null;#Yr=null;#Qr=(()=>new Map)();#Jr=!1;#Zr=!1;#to=!1;#eo=null;#io=null;#m;static _initialized=!1;static#H=(()=>new Map([nn,gn,mn,pn].map((t=>[t._editorType,t]))))();constructor(t){let{uiManager:e,pageIndex:i,div:s,structTreeLayer:n,accessibilityManager:a,annotationLayer:r,drawLayer:o,textLayer:l,viewport:h,l10n:c}=t;const d=[...fn.#H.values()];if(!fn._initialized){fn._initialized=!0;for(const t of d)t.initialize(c,e)}
2e.registerEditorTypes(d),this.#m=e,this.pageIndex=i,this.div=s,this.#in=a,this.#Xr=r,this.viewport=h,this.#eo=l,this.drawLayer=o,this._structTree=n,this.#m.addLayer(this)}get isEmpty(){return 0===this.#Qr.size}get isInvisible(){return this.isEmpty&&this.#m.getMode()===v.NONE}updateToolbar(t){this.#m.updateToolbar(t)}updateMode(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.#m.getMode();switch(this.#so(),t){case v.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case v.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case v.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const i of fn.#H.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#eo?.div}addInkEditorIfNeeded(t){if(this.#m.getMode()!==v.INK)return;if(!t)for(const e of this.#Qr.values())if(e.isEmpty())return void e.setInBackground();this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){this.#m.setEditingState(t)}addCommands(t){this.#m.addCommands(t)}toggleDrawing(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("drawing",!t)}togglePointerEvents(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.#Xr?.div.classList.toggle("disabled",!t)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const i of this.#Qr.values())i.enableEditing(),i.show(!0),i.annotationElementId&&(this.#m.removeChangedExistingAnnotation(i),t.add(i.annotationElementId));if(!this.#Xr)return;const e=this.#Xr.getEditableAnnotations();for(const i of e){if(i.hide(),this.#m.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}}disable(){this.#to=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const s of this.#Qr.values())s.disableEditing(),s.annotationElementId&&(null===s.serialize()?(e.set(s.annotationElementId,s),this.getEditableAnnotation(s.annotationElementId)?.show(),s.remove()):t.set(s.annotationElementId,s));if(this.#Xr){const i=this.#Xr.getEditableAnnotations();for(const s of i){const{id:i}=s.data;if(this.#m.isDeletedAnnotationElement(i))continue;let n=e.get(i);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=t.get(i),n&&(this.#m.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#so(),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const s of fn.#H.values())i.remove(`${s._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#to=!1}getEditableAnnotation(t){return this.#Xr?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#m.getActive()!==t&&this.#m.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#eo?.div&&!this.#io){this.#io=new AbortController;const t=this.#m.combinedSignal(this.#io);this.#eo.div.addEventListener("pointerdown",this.#no.bind(this),{signal:t}),this.#eo.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#eo?.div&&this.#io&&(this.#io.abort(),this.#io=null,this.#eo.div.classList.remove("highlighting"))}#no(t){this.#m.unselectAll();const{target:e}=t;if(e===this.#eo.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#eo.div.contains(e)){const{isMac:e}=yt.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#m.showAllEditors("highlight",!0,!0),this.#eo.div.classList.add("free"),this.toggleDrawing(),pn.startHighlighting(this,"ltr"===this.#m.direction,{target:this.#eo.div,x:t.x,y:t.y}),this.#eo.div.addEventListener("pointerup",(()=>{this.#eo.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#m._signal}),t.preventDefault()}}enableClick(){if(this.#Kr)return;this.#Kr=new AbortController;const t=this.#m.combinedSignal(this.#Kr);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:t})}disableClick(){this.#Kr?.abort(),this.#Kr=null}
2attach(t){this.#Qr.set(t.id,t);const{annotationElementId:e}=t;e&&this.#m.isDeletedAnnotationElement(e)&&this.#m.removeDeletedAnnotationElement(t)}detach(t){this.#Qr.delete(t.id),this.#in?.removePointerInTextLayer(t.contentDiv),!this.#to&&t.annotationElementId&&this.#m.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#m.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,this.#Zr||this.addInkEditorIfNeeded(!1)}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#m.addDeletedAnnotationElement(t.annotationElementId),ue.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#m.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),this.#m.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#Yr&&(t._focusEventsAllowed=!1,this.#Yr=setTimeout((()=>{this.#Yr=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#m._signal}),e.focus())}),0)),t._structTreeParentId=this.#in?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#m.getId()}get#ao(){return fn.#H.get(this.#m.getMode())}combinedSignal(t){return this.#m.combinedSignal(t)}#ro(t){const e=this.#ao;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#ao?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#m.updateToolbar(t),this.#m.updateMode(t);const{offsetX:i,offsetY:s}=this.#oo(),n=this.getNextId(),a=this.#ro({parent:this,id:n,x:i,y:s,uiManager:this.#m,isCentered:!0,...e});a&&this.add(a)}async deserialize(t){return await(fn.#H.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#m))||null}createAndAddNewEditor(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=this.getNextId(),n=this.#ro({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#m,isCentered:e,...i});return n&&this.add(n),n}#oo(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),r=(n+Math.min(window.innerWidth,t+i))/2-t,o=(a+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180===0?[r,o]:[o,r];return{offsetX:l,offsetY:h}}addNewEditor(){this.createAndAddNewEditor(this.#oo(),!0)}setSelected(t){this.#m.setSelected(t)}toggleSelected(t){this.#m.toggleSelected(t)}unselect(t){this.#m.unselect(t)}pointerup(t){const{isMac:e}=yt.platform;0!==t.button||t.ctrlKey&&e||t.target===this.div&&this.#Jr&&(this.#Jr=!1,this.#qr?this.#m.getMode()!==v.STAMP?this.createAndAddNewEditor(t,!1):this.#m.unselectAll():this.#qr=!0)}pointerdown(t){if(this.#m.getMode()===v.HIGHLIGHT&&this.enableTextSelection(),this.#Jr)return void(this.#Jr=!1);const{isMac:e}=yt.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;this.#Jr=!0;const i=this.#m.getActive();this.#qr=!i||i.isEmpty()}findNewParent(t,e,i){const s=this.#m.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}destroy(){this.#m.getActive()?.parent===this&&(this.#m.commitOrRemove(),this.#m.setActiveEditor(null)),this.#Yr&&(clearTimeout(this.#Yr),this.#Yr=null);for(const t of this.#Qr.values())this.#in?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#Qr.clear(),this.#m.removeLayer(this)}#so(){this.#Zr=!0;for(const t of this.#Qr.values())t.isEmpty()&&t.remove();this.#Zr=!1}render(t){let{viewport:e}=t;this.viewport=e,te(this.div,e);for(const i of this.#m.getEditors(this.pageIndex))this.add(i),i.rebuild();this.updateMode()}update(t){let{viewport:e}=t;this.#m.commitOrRemove(),this.#so();const i=this.viewport.rotation,s=e.rotation;if(this.viewport=e,te(this.div,{rotation:s}),i!==s)for(const n of this.#Qr.values())n.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#m.viewParameters.realScale}}class bn{#Ns=null;#A=0;#lo=(()=>new Map)();#ho=(()=>new Map)();constructor(t){let{pageIndex:e}=t;this.pageIndex=e}setParent(t){if(this.#Ns){if(this.#Ns!==t){if(this.#lo.size>0)for(const e of this.#lo.values())e.remove(),t.append(e);this.#Ns=t}}else this.#Ns=t}static get _svgFactory(){return lt(this,"_svgFactory",new _s)}static#co(t){let{x:e=0,y:i=0,width:s=1,height:n=1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{style:a}=t;a.top=100*i+"%",a.left=100*e+"%",a.width=100*s+"%",a.height=100*n+"%"}#do(t){const e=bn._svgFactory.create(1,1,!0);return this.#Ns.append(e),e.setAttribute("aria-hidden",!0),bn.#co(e,t),e}#uo(t,e){const i=bn._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s),i.setAttribute("clipPathUnits","objectBoundingBox");const n=bn._svgFactory.createElement("use");return i.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),s}draw(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const n=this.#A++,a=this.#do(t.box);a.classList.add(...t.classNamesForDrawing);const r=bn._svgFactory.createElement("defs");a.append(r);const o=bn._svgFactory.createElement("path");r.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("d",t.toSVGPath()),s&&this.#ho.set(n,o);const h=this.#uo(r,l),c=bn._svgFactory.createElement("use");return a.append(c),a.setAttribute("fill",e),a.setAttribute("fill-opacity",i),c.setAttribute("href",`#${l}`),this.#lo.set(n,a),{id:n,clipPathId:`url(#${h})`}}drawOutline(t){const e=this.#A++,i=this.#do(t.box);i.classList.add(...t.classNamesForOutlining);const s=bn._svgFactory.createElement("defs");i.append(s);const n=bn._svgFactory.createElement("path");s.append(n);const a=`path_p${this.pageIndex}_${e}`;let r;if(n.setAttribute("id",a),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke"),t.mustRemoveSelfIntersections){const t=bn._svgFactory.createElement("mask");s.append(t),r=`mask_p${this.pageIndex}_${e}`,t.setAttribute("id",r),t.setAttribute("maskUnits","objectBoundingBox");const i=bn._svgFactory.createElement("rect");t.append(i),i.setAttribute("width","1"),i.setAttribute("height","1"),i.setAttribute("fill","white");const n=bn._svgFactory.createElement("use");t.append(n),n.setAttribute("href",`#${a}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}const o=bn._svgFactory.createElement("use");i.append(o),o.setAttribute("href",`#${a}`),r&&o.setAttribute("mask",`url(#${r})`);const l=o.cloneNode();return i.append(l),o.classList.add("mainOutline"),l.classList.add("secondaryOutline"),this.#lo.set(e,i),e}finalizeLine(t,e){const i=this.#ho.get(t);this.#ho.delete(t),this.updateBox(t,e.box),i.setAttribute("d",e.toSVGPath())}updateLine(t,e){this.#lo.get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}updatePath(t,e){this.#ho.get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){bn.#co(this.#lo.get(t),e)}show(t,e){this.#lo.get(t).classList.toggle("hidden",!e)}rotate(t,e){this.#lo.get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){this.#lo.get(t).setAttribute("fill",e)}
2changeOpacity(t,e){this.#lo.get(t).setAttribute("fill-opacity",e)}addClass(t,e){this.#lo.get(t).classList.add(e)}removeClass(t,e){this.#lo.get(t).classList.remove(e)}getSVGRoot(t){return this.#lo.get(t)}remove(t){this.#ho.delete(t),null!==this.#Ns&&(this.#lo.get(t).remove(),this.#lo.delete(t))}destroy(){this.#Ns=null;for(const t of this.#lo.values())t.remove();this.#lo.clear(),this.#ho.clear()}}var vn=n.AnnotationLayer,An=n.AnnotationMode,yn=n.GlobalWorkerOptions,wn=n.PDFDataRangeTransport,xn=n.TextLayer,_n=n.getDocument}}]); 3//# sourceMappingURL=737.88b155a0.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.