diff --git "a/pdf.min.js" "b/pdf.min.js" new file mode 100644--- /dev/null +++ "b/pdf.min.js" @@ -0,0 +1,21 @@ +/** + * @licstart The following is the entire license notice for the + * JavaScript code in this page + * + * Copyright 2023 Mozilla Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @licend The above is the entire license notice for the + * JavaScript code in this page + */var t,e,i,s,n={976:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{AnnotationLayer:()=>AnnotationLayer,FreeTextAnnotationElement:()=>FreeTextAnnotationElement,InkAnnotationElement:()=>InkAnnotationElement,StampAnnotationElement:()=>StampAnnotationElement});var i=e(292),s=e(419),n=e(792);function makeColorComp(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function scaleAndClamp(t){return Math.max(0,Math.min(255,255*t))}class ColorConverters{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=scaleAndClamp(t),t,t]}static G_HTML([t]){const e=makeColorComp(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(scaleAndClamp)}static RGB_HTML(t){return`#${t.map(makeColorComp).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[scaleAndClamp(1-Math.min(1,t+s)),scaleAndClamp(1-Math.min(1,i+s)),scaleAndClamp(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,a=1-i;return["CMYK",s,n,a,Math.min(s,n,a)]}}var a=e(284);const r=1e3,o=new WeakSet;function getRectDims(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class AnnotationElementFactory{static create(t){switch(t.data.annotationType){case i.AnnotationType.LINK:return new LinkAnnotationElement(t);case i.AnnotationType.TEXT:return new TextAnnotationElement(t);case i.AnnotationType.WIDGET:switch(t.data.fieldType){case"Tx":return new TextWidgetAnnotationElement(t);case"Btn":return t.data.radioButton?new RadioButtonWidgetAnnotationElement(t):t.data.checkBox?new CheckboxWidgetAnnotationElement(t):new PushButtonWidgetAnnotationElement(t);case"Ch":return new ChoiceWidgetAnnotationElement(t);case"Sig":return new SignatureWidgetAnnotationElement(t)}return new WidgetAnnotationElement(t);case i.AnnotationType.POPUP:return new PopupAnnotationElement(t);case i.AnnotationType.FREETEXT:return new FreeTextAnnotationElement(t);case i.AnnotationType.LINE:return new LineAnnotationElement(t);case i.AnnotationType.SQUARE:return new SquareAnnotationElement(t);case i.AnnotationType.CIRCLE:return new CircleAnnotationElement(t);case i.AnnotationType.POLYLINE:return new PolylineAnnotationElement(t);case i.AnnotationType.CARET:return new CaretAnnotationElement(t);case i.AnnotationType.INK:return new InkAnnotationElement(t);case i.AnnotationType.POLYGON:return new PolygonAnnotationElement(t);case i.AnnotationType.HIGHLIGHT:return new HighlightAnnotationElement(t);case i.AnnotationType.UNDERLINE:return new UnderlineAnnotationElement(t);case i.AnnotationType.SQUIGGLY:return new SquigglyAnnotationElement(t);case i.AnnotationType.STRIKEOUT:return new StrikeOutAnnotationElement(t);case i.AnnotationType.STAMP:return new StampAnnotationElement(t);case i.AnnotationType.FILEATTACHMENT:return new FileAttachmentAnnotationElement(t);default:return new AnnotationElement(t)}}}class AnnotationElement{#t=null;#e=!1;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!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({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get hasPopupData(){return AnnotationElement._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#t||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#i(e)}resetEdited(){if(this.#t){this.#i(this.#t.rect);this.#t=null}}#i(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}=getRectDims(t);e.left=100*(t[0]-r)/n+"%";e.top=100*(a-t[3]+o)/a+"%";if(0===s){e.width=100*l/n+"%";e.height=100*h/a+"%"}else this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:s,viewport:n}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",e.id);this instanceof WidgetAnnotationElement||(a.tabIndex=r);const{style:o}=a;o.zIndex=this.parent.zIndex++;e.popupRef&&a.setAttribute("aria-haspopup","dialog");e.alternativeText&&(a.title=e.alternativeText);e.noRotate&&a.classList.add("norotate");if(!e.rect||this instanceof PopupAnnotationElement){const{rotation:t}=e;e.hasOwnCanvas||0===t||this.setRotation(t,a);return a}const{width:l,height:h}=getRectDims(e.rect);if(!t&&e.borderStyle.width>0){o.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,s=e.borderStyle.verticalCornerRadius;if(t>0||s>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${s}px * var(--scale-factor))`;o.borderRadius=e}else if(this instanceof RadioButtonWidgetAnnotationElement){const t=`calc(${l}px * var(--scale-factor)) / calc(${h}px * var(--scale-factor))`;o.borderRadius=t}switch(e.borderStyle.style){case i.AnnotationBorderStyleType.SOLID:o.borderStyle="solid";break;case i.AnnotationBorderStyleType.DASHED:o.borderStyle="dashed";break;case i.AnnotationBorderStyleType.BEVELED:(0,i.warn)("Unimplemented border style: beveled");break;case i.AnnotationBorderStyleType.INSET:(0,i.warn)("Unimplemented border style: inset");break;case i.AnnotationBorderStyleType.UNDERLINE:o.borderBottomStyle="solid"}const n=e.borderColor||null;if(n){this.#e=!0;o.borderColor=i.Util.makeHexColor(0|n[0],0|n[1],0|n[2])}else o.borderWidth=0}const d=i.Util.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:u,pageX:p,pageY:g}=n.rawDims;o.left=100*(d[0]-p)/c+"%";o.top=100*(d[1]-g)/u+"%";const{rotation:m}=e;if(e.hasOwnCanvas||0===m){o.width=100*l/c+"%";o.height=100*h/u+"%"}else this.setRotation(m,a);return a}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:a}=getRectDims(this.data.rect);let r,o;if(t%180==0){r=100*n/i;o=100*a/s}else{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 setColor=(t,e,i)=>{const s=i.detail[t],n=s[0],a=s.slice(1);i.target.style[e]=ColorConverters[`${n}_HTML`](a);this.annotationStorage.setValue(this.data.id,{[e]:ColorConverters[`${n}_rgb`](a)})};return(0,i.shadow)(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:t=>{setColor("bgColor","backgroundColor",t)},fillColor:t=>{setColor("fillColor","backgroundColor",t)},fgColor:t=>{setColor("fgColor","color",t)},textColor:t=>{setColor("textColor","color",t)},borderColor:t=>{setColor("borderColor","borderColor",t)},strokeColor:t=>{setColor("strokeColor","borderColor",t)},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]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect;if(1===t.length){const[,{x:a,y:r},{x:o,y:l}]=t[0];if(s===a&&n===r&&e===o&&i===l)return}const{style:a}=this.container;let r;if(this.#e){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0;r=["url('data:image/svg+xml;utf8,",'',``];this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer");d.setAttribute("width",0);d.setAttribute("height",0);const c=h.createElement("defs");d.append(c);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p);u.setAttribute("clipPathUnits","objectBoundingBox");c.append(u);for(const[,{x:i,y:s},{x:a,y:d}]of t){const t=h.createElement("rect"),c=(a-e)/o,p=(n-s)/l,g=(i-a)/o,m=(s-d)/l;t.setAttribute("x",c);t.setAttribute("y",p);t.setAttribute("width",g);t.setAttribute("height",m);u.append(t);r?.push(``)}if(this.#e){r.push("')");a.backgroundImage=r.join("")}this.container.append(d);this.container.style.clipPath=`url(#${p})`}_createPopup(){const{container:t,data:e}=this;t.setAttribute("aria-haspopup","dialog");const i=new PopupAnnotationElement({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(i.render())}render(){(0,i.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const n=this._fieldObjects[t];if(n)for(const{page:t,id:a,exportValues:r}of n){if(-1===t)continue;if(a===e)continue;const n="string"==typeof r?r:null,l=document.querySelector(`[data-element-id="${a}"]`);!l||o.has(l)?s.push({id:a,exportValue:n,domElement:l}):(0,i.warn)(`_getElementsByName - element not allowed: ${a}`)}return s}for(const i of document.getElementsByName(t)){const{exportValue:t}=i,n=i.getAttribute("data-element-id");n!==e&&(o.has(i)&&s.push({id:n,exportValue:t,domElement:i}))}return s}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")}get _isEditable(){return!1}_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 LinkAnnotationElement extends AnnotationElement{constructor(t,e=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;if(t.url){e.addLinkAttributes(i,t.url,t.newWindow);s=!0}else if(t.action){this._bindNamedAction(i,t.action);s=!0}else if(t.attachment){this.#s(i,t.attachment,t.attachmentDest);s=!0}else if(t.setOCGState){this.#n(i,t.setOCGState);s=!0}else if(t.dest){this._bindLink(i,t.dest);s=!0}else{if(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions){this._bindJSAction(i,t);s=!0}if(t.resetForm){this._bindResetFormAction(i,t.resetForm);s=!0}else if(this.isTooltipOnly&&!s){this._bindLink(i,"");s=!0}}this.container.classList.add("linkAnnotation");s&&this.container.append(i);return this.container}#a(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e);t.onclick=()=>{e&&this.linkService.goToDestination(e);return!1};(e||""===e)&&this.#a()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl("");t.onclick=()=>{this.linkService.executeNamedAction(e);return!1};this.#a()}#s(t,e,i=null){t.href=this.linkService.getAnchorUrl("");t.onclick=()=>{this.downloadManager?.openOrDownloadData(e.content,e.filename,i);return!1};this.#a()}#n(t,e){t.href=this.linkService.getAnchorUrl("");t.onclick=()=>{this.linkService.executeSetOCGState(e);return!1};this.#a()}_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}});return!1})}t.onclick||(t.onclick=()=>!1);this.#a()}_bindResetFormAction(t,e){const s=t.onclick;s||(t.href=this.linkService.getAnchorUrl(""));this.#a();if(this._fieldObjects)t.onclick=()=>{s?.();const{fields:t,refs:n,include:a}=e,r=[];if(0!==t.length||0!==n.length){const e=new Set(n);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)===a&&r.push(i)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const l=this.annotationStorage,h=[];for(const t of r){const{id:e}=t;h.push(e);switch(t.type){case"text":{const i=t.defaultValue||"";l.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;l.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";l.setValue(e,{value:i});break}default:continue}const s=document.querySelector(`[data-element-id="${e}"]`);s&&(o.has(s)?s.dispatchEvent(new Event("resetform")):(0,i.warn)(`_bindResetFormAction - element not allowed: ${e}`))}this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:h,name:"ResetForm"}});return!1};else{(0,i.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.');s||(t.onclick=()=>!1)}}}class TextAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");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);return this.container}}class WidgetAnnotationElement extends AnnotationElement{render(){return this.container}showElementAndHideCanvas(t){if(this.data.hasOwnCanvas){"CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0);t.hidden=!1}}_getKeyModifier(t){return i.FeatureTest.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)if("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":i.Util.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,a=t.style;let r;const roundToOneDecimal=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/(i.LINE_FACTOR*n))||1);r=Math.min(n,roundToOneDecimal(e/i.LINE_FACTOR))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(n,roundToOneDecimal(t/i.LINE_FACTOR))}a.fontSize=`calc(${r}px * var(--scale-factor))`;a.color=i.Util.makeHexColor(s[0],s[1],s[2]);null!==this.data.textAlignment&&(a.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required");t.setAttribute("aria-required",e)}}class TextWidgetAnnotationElement extends WidgetAnnotationElement{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;for(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 l=s.formattedValue||this.data.textContent?.join("\n")||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));const h={userValue:n,formattedValue:l,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){i=document.createElement("textarea");i.textContent=l??n;this.data.doNotScroll&&(i.style.overflowY="hidden")}else{i=document.createElement("input");i.type="text";i.setAttribute("value",l??n);this.data.doNotScroll&&(i.style.overflowX="hidden")}this.data.hasOwnCanvas&&(i.hidden=!0);o.add(i);i.setAttribute("data-element-id",e);i.disabled=this.data.readOnly;i.name=this.data.fieldName;i.tabIndex=r;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");h.formattedValue=null}));i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";i.value=h.userValue=e;h.formattedValue=null}));let blurListener=t=>{const{formattedValue:e}=h;null!=e&&(t.target.value=e);t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(t=>{if(h.focused)return;const{target:e}=t;h.userValue&&(e.value=h.userValue);h.lastCommittedValue=e.value;h.commitKey=1;this.data.actions?.Focus||(h.focused=!0)}));i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target);const s={value(i){h.userValue=i.detail.value??"";t.setValue(e,{value:h.userValue.toString()});i.target.value=h.userValue},formattedValue(i){const{formattedValue:s}=i.detail;h.formattedValue=s;null!=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){n.removeAttribute("maxLength");return}n.setAttribute("maxLength",s);let a=h.userValue;if(a&&!(a.length<=s)){a=a.slice(0,s);n.value=h.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=>{h.commitKey=1;let i=-1;"Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(h.commitKey=3):i=2;if(-1===i)return;const{value:s}=t.target;if(h.lastCommittedValue!==s){h.lastCommittedValue=s;h.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=blurListener;blurListener=null;i.addEventListener("blur",(t=>{if(!h.focused||!t.relatedTarget)return;this.data.actions?.Blur||(h.focused=!1);const{value:i}=t.target;h.userValue=i;h.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:h.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}});s(t)}));this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{h.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:a,selectionEnd:r}=s;let o=a,l=r;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,a).match(/\w*[^\w]*$/);t&&(o-=t[0].length);break}case"deleteWordForward":{const t=n.substring(a).match(/^[^\w]*\w*/);t&&(l+=t[0].length);break}case"deleteContentBackward":a===r&&(o-=1);break;case"deleteContentForward":a===r&&(l+=1)}t.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:o,selEnd:l}})}));this._setEventListeners(i,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}blurListener&&i.addEventListener("blur",blurListener);if(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)}this._setTextStyle(i);this._setBackgroundColor(i);this._setDefaultPropertiesFromJS(i);this.container.append(i);return this.container}}class SignatureWidgetAnnotationElement extends WidgetAnnotationElement{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement{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;if("string"==typeof s){s="Off"!==s;t.setValue(i,{value:s})}this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");o.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=r;n.addEventListener("change",(s=>{const{name:n,checked:a}=s.target;for(const s of this._getElementsByName(n,i)){const i=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i);t.setValue(s.id,{value:i})}t.setValue(i,{value:a})}));n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}));if(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);return this.container}}class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement{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})}if(s)for(const s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});const n=document.createElement("input");o.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=r;n.addEventListener("change",(e=>{const{name:s,checked:n}=e.target;for(const e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})}));n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}));if(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))}this._setBackgroundColor(n);this._setDefaultPropertiesFromJS(n);this.container.append(n);return this.container}}class PushButtonWidgetAnnotationElement extends LinkAnnotationElement{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;if(this.enableScripting&&this.hasJSActions&&e){this._setDefaultPropertiesFromJS(e);e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))}return t}}class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement{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");o.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=r;let n=this.data.combo&&this.data.options.length>0;if(!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 t of s.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue;e.value=t.exportValue;if(i.value.includes(t.exportValue)){e.setAttribute("selected",!0);n=!1}s.append(e)}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 getValue=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 l=getValue(!1);const getItems=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};if(this.enableScripting&&this.hasJSActions){s.addEventListener("updatefromsandbox",(i=>{const n={value(i){a?.();const n=i.detail.value,r=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=r.has(t.value);t.setValue(e,{value:getValue(!0)});l=getValue(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,a=i.detail.remove;n[a].selected=!1;s.remove(a);if(n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:getValue(!0),items:getItems(i)});l=getValue(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]});l=getValue(!1)},insert(i){const{index:n,displayValue:a,exportValue:r}=i.detail.insert,o=s.children[n],h=document.createElement("option");h.textContent=a;h.value=r;o?o.before(h):s.append(h);t.setValue(e,{value:getValue(!0),items:getItems(i)});l=getValue(!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:getValue(!0),items:getItems(i)});l=getValue(!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:getValue(!0)});l=getValue(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)}));s.addEventListener("input",(i=>{const s=getValue(!0),n=getValue(!1);t.setValue(e,{value:s});i.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,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))}else s.addEventListener("input",(function(i){t.setValue(e,{value:getValue(!0)})}));this.data.combo&&this._setTextStyle(s);this._setBackgroundColor(s);this._setDefaultPropertiesFromJS(s);this.container.append(s);return this.container}}class PopupAnnotationElement extends AnnotationElement{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:AnnotationElement._hasPopupData(e)});this.elements=i}render(){this.container.classList.add("popupAnnotation");const t=new PopupElement({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;e.push(i.data.id);i.addHighlightArea()}this.container.setAttribute("aria-controls",e.map((t=>`${i.AnnotationPrefix}${t}`)).join(","));return this.container}}class PopupElement{#r=this.#o.bind(this);#l=this.#h.bind(this);#d=this.#c.bind(this);#u=this.#p.bind(this);#g=null;#m=null;#f=null;#b=null;#A=null;#v=null;#y=null;#E=!1;#w=null;#_=null;#x=null;#T=null;#S=!1;constructor({container:t,color:e,elements:i,titleObj:n,modificationDate:a,contentsObj:r,richText:o,parent:l,rect:h,parentRect:d,open:c}){this.#m=t;this.#T=n;this.#f=r;this.#x=o;this.#v=l;this.#g=e;this.#_=h;this.#y=d;this.#A=i;this.#b=s.PDFDateString.toDateObject(a);this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger){t.addEventListener("click",this.#u);t.addEventListener("mouseenter",this.#d);t.addEventListener("mouseleave",this.#l);t.classList.add("popupTriggerArea")}for(const t of i)t.container?.addEventListener("keydown",this.#r);this.#m.hidden=!0;c&&this.#p()}render(){if(this.#w)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:n,pageY:r}}}=this.#v,o=this.#w=document.createElement("div");o.className="popup";if(this.#g){const t=o.style.outlineColor=i.Util.makeHexColor(...this.#g);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))o.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`;else{const t=.7;o.style.backgroundColor=i.Util.makeHexColor(...this.#g.map((e=>Math.floor(t*(255-e)+e))))}}const l=document.createElement("span");l.className="header";const h=document.createElement("h1");l.append(h);({dir:h.dir,str:h.textContent}=this.#T);o.append(l);if(this.#b){const t=document.createElement("span");t.classList.add("popupDate");t.setAttribute("data-l10n-id","pdfjs-annotation-date-string");t.setAttribute("data-l10n-args",JSON.stringify({date:this.#b.toLocaleDateString(),time:this.#b.toLocaleTimeString()}));l.append(t)}const d=this.#f,c=this.#x;if(!c?.str||d?.str&&d.str!==c.str){const t=this._formatContents(d);o.append(t)}else{a.XfaLayer.render({xfaHtml:c.html,intent:"richText",div:o});o.lastChild.classList.add("richText","popupContent")}let u=!!this.#y,p=u?this.#y:this.#_;for(const t of this.#A)if(!p||null!==i.Util.intersect(t.data.rect,p)){p=t.data.rect;u=!0;break}const g=i.Util.normalizeRect([p[0],t[3]-p[1]+t[1],p[2],t[3]-p[3]+t[1]]),m=u?p[2]-p[0]+5:0,f=g[0]+m,b=g[1],{style:A}=this.#m;A.left=100*(f-n)/e+"%";A.top=100*(b-r)/s+"%";this.#m.append(o)}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent");i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t{"Enter"===t.key&&(n?t.metaKey:t.ctrlKey)&&this.#D()}));!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea");t.append(s);return t}getElementsToTriggerPopup(){return this.#k}addHighlightArea(){this.container.classList.add("highlightArea")}#D(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class AnnotationLayer{#I=null;#L=null;#O=new Map;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:a}){this.div=t;this.#I=e;this.#L=i;this.page=n;this.viewport=a;this.zIndex=0;this._annotationEditorUIManager=s}#N(t,e){const s=t.firstChild||t;s.id=`${i.AnnotationPrefix}${e}`;this.div.append(t);this.#I?.moveElementInDOM(this.div,t,s,!1)}async render(t){const{annotations:e}=t,a=this.div;(0,s.setLayerDimensions)(a,this.viewport);const r=new Map,o={data:null,layer:a,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new s.DOMSVGFactory,annotationStorage:t.annotationStorage||new n.AnnotationStorage,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===i.AnnotationType.POPUP;if(e){const e=r.get(t.id);if(!e)continue;o.elements=e}else{const{width:e,height:i}=getRectDims(t.rect);if(e<=0||i<=0)continue}o.data=t;const s=AnnotationElementFactory.create(o);if(!s.isRenderable)continue;if(!e&&t.popupRef){const e=r.get(t.popupRef);e?e.push(s):r.set(t.popupRef,[s])}const n=s.render();t.hidden&&(n.style.visibility="hidden");this.#N(n,t.id);if(s.annotationEditorType>0){this.#O.set(s.data.id,s);this._annotationEditorUIManager?.renderAnnotationElement(s)}}this.#B()}update({viewport:t}){const e=this.div;this.viewport=t;(0,s.setLayerDimensions)(e,{rotation:t.rotation});this.#B();e.hidden=!1}#B(){if(!this.#L)return;const t=this.div;for(const[e,i]of this.#L){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.#L.clear()}getEditableAnnotations(){return Array.from(this.#O.values())}getEditableAnnotation(t){return this.#O.get(t)}}},792:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{AnnotationStorage:()=>AnnotationStorage,PrintAnnotationStorage:()=>PrintAnnotationStorage,SerializableEmpty:()=>a});var i=e(292),s=e(310),n=e(651);const a=Object.freeze({map:null,hash:"",transfer:void 0});class AnnotationStorage{#H=!1;#U=new Map;constructor(){this.onSetModified=null;this.onResetModified=null;this.onAnnotationEditor=null}getValue(t,e){const i=this.#U.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#U.get(t)}remove(t){this.#U.delete(t);0===this.#U.size&&this.resetModified();if("function"==typeof this.onAnnotationEditor){for(const t of this.#U.values())if(t instanceof s.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#U.get(t);let n=!1;if(void 0!==i){for(const[t,s]of Object.entries(e))if(i[t]!==s){n=!0;i[t]=s}}else{n=!0;this.#U.set(t,e)}n&&this.#z();e instanceof s.AnnotationEditor&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#U.has(t)}getAll(){return this.#U.size>0?(0,i.objectFromMap)(this.#U):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#U.size}#z(){if(!this.#H){this.#H=!0;"function"==typeof this.onSetModified&&this.onSetModified()}}resetModified(){if(this.#H){this.#H=!1;"function"==typeof this.onResetModified&&this.onResetModified()}}get print(){return new PrintAnnotationStorage(this)}get serializable(){if(0===this.#U.size)return a;const t=new Map,e=new n.MurmurHash3_64,i=[],r=Object.create(null);let o=!1;for(const[i,n]of this.#U){const a=n instanceof s.AnnotationEditor?n.serialize(!1,r):n;if(a){t.set(i,a);e.update(`${i}:${JSON.stringify(a)}`);o||=!!a.bitmap}}if(o)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:a}get editorStats(){let t=null;const e=new Map;for(const i of this.#U.values()){if(!(i instanceof s.AnnotationEditor))continue;const n=i.telemetryFinalData;if(!n)continue;const{type:a}=n;e.has(a)||e.set(a,Object.getPrototypeOf(i).constructor);t||=Object.create(null);const r=t[a]||=new Map;for(const[t,e]of Object.entries(n)){if("type"===t)continue;let i=r.get(t);if(!i){i=new Map;r.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}}class PrintAnnotationStorage extends AnnotationStorage{#V;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#V={map:n,hash:i,transfer:s}}get print(){(0,i.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#V}}},831:(t,__webpack_exports__,e)=>{e.a(t,(async(t,i)=>{try{e.d(__webpack_exports__,{PDFDataRangeTransport:()=>PDFDataRangeTransport,PDFWorker:()=>PDFWorker,build:()=>R,getDocument:()=>getDocument,version:()=>P});var s=e(292),n=e(792),a=e(419),r=e(10),o=e(573),l=e(923),h=e(814),d=e(164),c=e(178),u=e(62),p=e(626),g=e(585),m=e(94),f=e(457),b=e(786),A=e(50),v=t([o,b]);[o,b]=v.then?(await v)():v;const y=65536,E=100,w=5e3,_=s.isNodeJS?o.NodeCanvasFactory:a.DOMCanvasFactory,x=s.isNodeJS?o.NodeCMapReaderFactory:a.DOMCMapReaderFactory,T=s.isNodeJS?o.NodeFilterFactory:a.DOMFilterFactory,S=s.isNodeJS?o.NodeStandardFontDataFactory:a.DOMStandardFontDataFactory;function getDocument(t){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});if("object"!=typeof t)throw new Error("Invalid parameter in getDocument, need parameter object.");if(!t.url&&!t.data&&!t.range)throw new Error("Invalid parameter object: need either .data, .range or .url");const e=new PDFDocumentLoadingTask,{docId:i}=e,n=t.url?getUrlProp(t.url):null,r=t.data?getDataProp(t.data):null,o=t.httpHeaders||null,l=!0===t.withCredentials,h=t.password??null,u=t.range instanceof PDFDataRangeTransport?t.range:null,p=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:y;let A=t.worker instanceof PDFWorker?t.worker:null;const v=t.verbosity,E="string"!=typeof t.docBaseUrl||(0,a.isDataScheme)(t.docBaseUrl)?null:t.docBaseUrl,w="string"==typeof t.cMapUrl?t.cMapUrl:null,C=!1!==t.cMapPacked,M=t.CMapReaderFactory||x,P="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,R=t.StandardFontDataFactory||S,F=!0!==t.stopAtErrors,k=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,D=!1!==t.isEvalSupported,I="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!s.isNodeJS,L=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,O="boolean"==typeof t.disableFontFace?t.disableFontFace:s.isNodeJS,N=!0===t.fontExtraProperties,B=!0===t.enableXfa,H=t.ownerDocument||globalThis.document,U=!0===t.disableRange,z=!0===t.disableStream,V=!0===t.disableAutoFetch,j=!0===t.pdfBug,G=u?u.length:t.length??NaN,$="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!s.isNodeJS&&!O,W="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:M===a.DOMCMapReaderFactory&&R===a.DOMStandardFontDataFactory&&w&&P&&(0,a.isValidFetchUrl)(w,document.baseURI)&&(0,a.isValidFetchUrl)(P,document.baseURI),q=t.canvasFactory||new _({ownerDocument:H}),K=t.filterFactory||new T({docId:i,ownerDocument:H});(0,s.setVerbosityLevel)(v);const X={canvasFactory:q,filterFactory:K};if(!W){X.cMapReaderFactory=new M({baseUrl:w,isCompressed:C});X.standardFontDataFactory=new R({baseUrl:P})}if(!A){const t={verbosity:v,port:d.GlobalWorkerOptions.workerPort};A=t.port?PDFWorker.fromPort(t):new PDFWorker(t);e._worker=A}const Y={docId:i,apiVersion:"4.2.67",data:r,password:h,disableAutoFetch:V,rangeChunkSize:p,length:G,docBaseUrl:E,enableXfa:B,evaluatorOptions:{maxImageSize:k,disableFontFace:O,ignoreErrors:F,isEvalSupported:D,isOffscreenCanvasSupported:I,canvasMaxAreaInBytes:L,fontExtraProperties:N,useSystemFonts:$,cMapUrl:W?w:null,standardFontDataUrl:W?P:null}},J={ignoreErrors:F,disableFontFace:O,fontExtraProperties:N,enableXfa:B,ownerDocument:H,disableAutoFetch:V,pdfBug:j,styleElement:null};A.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");const t=_fetchDocument(A,Y),h=new Promise((function(t){let e;if(u)e=new g.PDFDataTransportStream(u,{disableRange:U,disableStream:z});else if(!r){e=(t=>{if(s.isNodeJS){return function(){return"undefined"!=typeof fetch&&"undefined"!=typeof Response&&"body"in Response.prototype}()&&(0,a.isValidFetchUrl)(t.url)?new m.PDFFetchStream(t):new b.PDFNodeStream(t)}return(0,a.isValidFetchUrl)(t.url)?new m.PDFFetchStream(t):new f.PDFNetworkStream(t)})({url:n,length:G,httpHeaders:o,withCredentials:l,rangeChunkSize:p,disableRange:U,disableStream:z})}t(e)}));return Promise.all([t,h]).then((function([t,s]){if(e.destroyed)throw new Error("Loading aborted");const n=new c.MessageHandler(i,t,A.port),a=new WorkerTransport(n,e,s,J,X);e._transport=a;n.send("Ready",null)}))})).catch(e._capability.reject);return e}async function _fetchDocument(t,e){if(t.destroyed)throw new Error("Worker was destroyed");const i=await t.messageHandler.sendWithPromise("GetDocRequest",e,e.data?[e.data.buffer]:null);if(t.destroyed)throw new Error("Worker was destroyed");return i}function getUrlProp(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(s.isNodeJS&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function getDataProp(t){if(s.isNodeJS&&"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(0,s.stringToBytes)(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.")}function isRefProxy(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class PDFDocumentLoadingTask{static#j=0;constructor(){this._capability=Promise.withResolvers();this._transport=null;this._worker=null;this.docId="d"+PDFDocumentLoadingTask.#j++;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){this._worker?.port&&delete this._worker._pendingDestroy;throw t}this._transport=null;if(this._worker){this._worker.destroy();this._worker=null}}}class PDFDataRangeTransport{constructor(t,e,i=!1,s=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){(0,s.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class PDFDocumentProxy{constructor(t,e){this._pdfInfo=t;this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,s.shadow)(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({intent:t="display"}={}){const{renderingIntent:e}=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(t=!1){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 PDFPageProxy{#G=null;#$=!1;constructor(t,e,i,s=!1){this._pageIndex=t;this._pageInfo=e;this._transport=i;this._stats=s?new a.StatTimer:null;this._pdfBug=s;this.commonObjs=i.commonObjs;this.objs=new PDFObjects;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({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new a.PageViewport({viewBox:this.view,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){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(0,s.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:n=s.AnnotationMode.ENABLE,transform:a=null,background:r=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:d=null}){this._stats?.time("Overall");const c=this._transport.getRenderingIntent(i,n,d),{renderingIntent:u,cacheKey:p}=c;this.#$=!1;this.#W();o||=this._transport.getOptionalContentConfig(u);let g=this._intentStates.get(p);if(!g){g=Object.create(null);this._intentStates.set(p,g)}if(g.streamReaderCancelTimeout){clearTimeout(g.streamReaderCancelTimeout);g.streamReaderCancelTimeout=null}const m=!!(u&s.RenderingIntentFlag.PRINT);if(!g.displayReadyCapability){g.displayReadyCapability=Promise.withResolvers();g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(c)}const complete=t=>{g.renderTasks.delete(f);(this._maybeCleanupAfterRender||m)&&(this.#$=!0);this.#q(!m);if(t){f.capability.reject(t);this._abortOperatorList({intentState:g,reason:t instanceof Error?t:new Error(t)})}else f.capability.resolve();this._stats?.timeEnd("Rendering");this._stats?.timeEnd("Overall")},f=new InternalRenderTask({callback:complete,params:{canvasContext:t,viewport:e,transform:a,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!m,pdfBug:this._pdfBug,pageColors:h});(g.renderTasks||=new Set).add(f);const b=f.task;Promise.all([g.displayReadyCapability.promise,o]).then((([t,e])=>{if(this.destroyed)complete();else{this._stats?.time("Rendering");if(!(e.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");f.initializeGraphics({transparency:t,optionalContentConfig:e});f.operatorListChanged()}})).catch(complete);return b}getOperatorList({intent:t="display",annotationMode:e=s.AnnotationMode.ENABLE,printAnnotationStorage:i=null}={}){const n=this._transport.getRenderingIntent(t,e,i,!0);let a,r=this._intentStates.get(n.cacheKey);if(!r){r=Object.create(null);this._intentStates.set(n.cacheKey,r)}if(!r.opListReadCapability){a=Object.create(null);a.operatorListChanged=function operatorListChanged(){if(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)}return r.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>A.XfaText.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null)};!function pump(){s.read().then((function({value:e,done:i}){if(i)t(n);else{Object.assign(n.styles,e.styles);n.items.push(...e.items);pump()}}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values()){this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0});if(!e.opListReadCapability)for(const i of e.renderTasks){t.push(i.completed);i.cancel()}}this.objs.clear();this.#$=!1;this.#W();return Promise.all(t)}cleanup(t=!1){this.#$=!0;const e=this.#q(!1);t&&e&&(this._stats&&=new a.StatTimer);return e}#q(t=!1){this.#W();if(!this.#$||this.destroyed)return!1;if(t){this.#G=setTimeout((()=>{this.#G=null;this.#q(!1)}),w);return!1}for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;this._intentStates.clear();this.objs.clear();this.#$=!1;return!0}#W(){if(this.#G){clearTimeout(this.#G);this.#G=null}}_startRenderPage(t,e){const i=this._intentStates.get(e);if(i){this._stats?.timeEnd("Page Request");i.displayReadyCapability?.resolve(t)}}_renderPageChunk(t,e){for(let i=0,s=t.length;i{a.read().then((({value:t,done:e})=>{if(e)r.streamReader=null;else if(!this._transport.destroyed){this._renderPageChunk(t,r);pump()}}),(t=>{r.streamReader=null;if(!this._transport.destroyed){if(r.operatorList){r.operatorList.lastChunk=!0;for(const t of r.renderTasks)t.operatorListChanged();this.#q(!0)}if(r.displayReadyCapability)r.displayReadyCapability.reject(t);else{if(!r.opListReadCapability)throw t;r.opListReadCapability.reject(t)}}}))};pump()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout){clearTimeout(t.streamReaderCancelTimeout);t.streamReaderCancelTimeout=null}if(!i){if(t.renderTasks.size>0)return;if(e instanceof a.RenderingCancelledException){let i=E;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay);t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null;this._abortOperatorList({intentState:t,reason:e,force:!0})}),i);return}}t.streamReader.cancel(new s.AbortException(e.message)).catch((()=>{}));t.streamReader=null;if(!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class LoopbackPort{#K=new Set;#X=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#X.then((()=>{for(const t of this.#K)t.call(this,i)}))}addEventListener(t,e){this.#K.add(e)}removeEventListener(t,e){this.#K.delete(e)}terminate(){this.#K.clear()}}const C={isWorkerDisabled:!1,fakeWorkerId:0};if(s.isNodeJS){C.isWorkerDisabled=!0;d.GlobalWorkerOptions.workerSrc||="./pdf.worker.mjs"}C.isSameOrigin=function(t,e){let i;try{i=new URL(t);if(!i.origin||"null"===i.origin)return!1}catch{return!1}const s=new URL(e,i);return i.origin===s.origin};C.createCDNWrapper=function(t){const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};class PDFWorker{static#Y;constructor({name:t=null,port:e=null,verbosity:i=(0,s.getVerbosityLevel)()}={}){this.name=t;this.destroyed=!1;this.verbosity=i;this._readyCapability=Promise.withResolvers();this._port=null;this._webWorker=null;this._messageHandler=null;if(e){if(PDFWorker.#Y?.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(PDFWorker.#Y||=new WeakMap).set(e,this);this._initializeFromPort(e)}else this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t;this._messageHandler=new c.MessageHandler("main","worker",t);this._messageHandler.on("ready",(function(){}));this._readyCapability.resolve();this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!C.isWorkerDisabled&&!PDFWorker.#J){let{workerSrc:t}=PDFWorker;try{C.isSameOrigin(window.location.href,t)||(t=C.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new c.MessageHandler("main","worker",e),terminateEarly=()=>{e.removeEventListener("error",onWorkerError);i.destroy();e.terminate();this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},onWorkerError=()=>{this._webWorker||terminateEarly()};e.addEventListener("error",onWorkerError);i.on("test",(t=>{e.removeEventListener("error",onWorkerError);if(this.destroyed)terminateEarly();else if(t){this._messageHandler=i;this._port=e;this._webWorker=e;this._readyCapability.resolve();i.send("configure",{verbosity:this.verbosity})}else{this._setupFakeWorker();i.destroy();e.terminate()}}));i.on("ready",(t=>{e.removeEventListener("error",onWorkerError);if(this.destroyed)terminateEarly();else try{sendTest()}catch{this._setupFakeWorker()}}));const sendTest=()=>{const t=new Uint8Array;i.send("test",t,[t.buffer])};sendTest();return}catch{(0,s.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){if(!C.isWorkerDisabled){(0,s.warn)("Setting up fake worker.");C.isWorkerDisabled=!0}PDFWorker._setupFakeWorkerGlobal.then((t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new LoopbackPort;this._port=e;const i="fake"+C.fakeWorkerId++,s=new c.MessageHandler(i+"_worker",i,e);t.setup(s,e);const n=new c.MessageHandler(i,i+"_worker",e);this._messageHandler=n;this._readyCapability.resolve();n.send("configure",{verbosity:this.verbosity})})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0;if(this._webWorker){this._webWorker.terminate();this._webWorker=null}PDFWorker.#Y?.delete(this._port);this._port=null;if(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.#Y?.get(t.port);if(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 PDFWorker(t)}static get workerSrc(){if(d.GlobalWorkerOptions.workerSrc)return d.GlobalWorkerOptions.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#J(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return(0,s.shadow)(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#J)return this.#J;return(await import(this.workerSrc)).WorkerMessageHandler})())}}class WorkerTransport{#Q=new Map;#Z=new Map;#tt=new Map;#et=new Map;#it=null;constructor(t,e,i,s,n){this.messageHandler=t;this.loadingTask=e;this.commonObjs=new PDFObjects;this.fontLoader=new r.FontLoader({ownerDocument:s.ownerDocument,styleElement:s.styleElement});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()}#st(t,e=null){const i=this.#Q.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);this.#Q.set(t,s);return s}get annotationStorage(){return(0,s.shadow)(this,"annotationStorage",new n.AnnotationStorage)}getRenderingIntent(t,e=s.AnnotationMode.ENABLE,i=null,a=!1){let r=s.RenderingIntentFlag.DISPLAY,o=n.SerializableEmpty;switch(t){case"any":r=s.RenderingIntentFlag.ANY;break;case"display":break;case"print":r=s.RenderingIntentFlag.PRINT;break;default:(0,s.warn)(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case s.AnnotationMode.DISABLE:r+=s.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case s.AnnotationMode.ENABLE:break;case s.AnnotationMode.ENABLE_FORMS:r+=s.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case s.AnnotationMode.ENABLE_STORAGE:r+=s.RenderingIntentFlag.ANNOTATIONS_STORAGE;o=(r&s.RenderingIntentFlag.PRINT&&i instanceof n.PrintAnnotationStorage?i:this.annotationStorage).serializable;break;default:(0,s.warn)(`getRenderingIntent - invalid annotationMode: ${e}`)}a&&(r+=s.RenderingIntentFlag.OPLIST);return{renderingIntent:r,cacheKey:`${r}_${o.hash}`,annotationStorageSerializable:o}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0;this.destroyCapability=Promise.withResolvers();this.#it?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Z.values())t.push(e._destroy());this.#Z.clear();this.#tt.clear();this.#et.clear();this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);t.push(e);Promise.all(t).then((()=>{this.commonObjs.clear();this.fontLoader.clear();this.#Q.clear();this.filterFactory.destroy();(0,h.cleanupTextLayer)();this._networkStream?.cancelAllRequests(new s.AbortException("Worker was terminated."));if(this.messageHandler){this.messageHandler.destroy();this.messageHandler=null}this.destroyCapability.resolve()}),this.destroyCapability.reject);return this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{(0,s.assert)(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({value:t,done:i}){if(i)e.close();else{(0,s.assert)(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer.");e.enqueue(new Uint8Array(t),1,[t])}})).catch((t=>{e.error(t)}))};e.onCancel=t=>{this._fullReader.cancel(t);e.ready.catch((t=>{if(!this.destroyed)throw t}))}}));t.on("ReaderHeadersReady",(t=>{const i=Promise.withResolvers(),s=this._fullReader;s.headersReady.then((()=>{if(!s.isStreamingSupported||!s.isRangeSupported){this._lastProgress&&e.onProgress?.(this._lastProgress);s.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}}i.resolve({isStreamingSupported:s.isStreamingSupported,isRangeSupported:s.isRangeSupported,contentLength:s.contentLength})}),i.reject);return i.promise}));t.on("GetRangeReader",((t,e)=>{(0,s.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);if(i){e.onPull=()=>{i.read().then((function({value:t,done:i}){if(i)e.close();else{(0,s.assert)(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer.");e.enqueue(new Uint8Array(t),1,[t])}})).catch((t=>{e.error(t)}))};e.onCancel=t=>{i.cancel(t);e.ready.catch((t=>{if(!this.destroyed)throw t}))}}else e.close()}));t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages;this._htmlForXfa=t.htmlForXfa;delete t.htmlForXfa;e._capability.resolve(new PDFDocumentProxy(t,this))}));t.on("DocException",(function(t){let i;switch(t.name){case"PasswordException":i=new s.PasswordException(t.message,t.code);break;case"InvalidPDFException":i=new s.InvalidPDFException(t.message);break;case"MissingPDFException":i=new s.MissingPDFException(t.message);break;case"UnexpectedResponseException":i=new s.UnexpectedResponseException(t.message,t.status);break;case"UnknownErrorException":i=new s.UnknownErrorException(t.message,t.details);break;default:(0,s.unreachable)("DocException - expected a valid Error.")}e._capability.reject(i)}));t.on("PasswordRequest",(t=>{this.#it=Promise.withResolvers();if(e.onPassword){const updatePassword=t=>{t instanceof Error?this.#it.reject(t):this.#it.resolve({password:t})};try{e.onPassword(updatePassword,t.code)}catch(t){this.#it.reject(t)}}else this.#it.reject(new s.PasswordException(t.message,t.code));return this.#it.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.#Z.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}));t.on("commonobj",(([e,i,n])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":const a=this._params;if("error"in n){const t=n.error;(0,s.warn)(`Error during font loading: ${t}`);this.commonObjs.resolve(e,t);break}const o=a.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,l=new r.FontFaceObject(n,{disableFontFace:a.disableFontFace,ignoreErrors:a.ignoreErrors,inspectFont:o});this.fontLoader.bind(l).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!a.fontExtraProperties&&l.data&&(l.data=null);this.commonObjs.resolve(e,l)}));break;case"CopyLocalImage":const{imageRef:h}=n;(0,s.assert)(h,"The imageRef must be defined.");for(const t of this.#Z.values())for(const[,i]of t.objs)if(i.ref===h){if(!i.dataLen)return null;this.commonObjs.resolve(e,structuredClone(i));return i.dataLen}break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}));t.on("obj",(([t,e,i,n])=>{if(this.destroyed)return;const a=this.#Z.get(e);if(!a.objs.has(t))if(0!==a._intentStates.size)switch(i){case"Image":a.objs.resolve(t,n);n?.dataLen>s.MAX_IMAGE_SIZE_TO_CACHE&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(t,n);break;default:throw new Error(`Got unknown object type ${i}`)}else n?.bitmap?.close()}));t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}));t.on("FetchBuiltInCMap",(t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(t):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))));t.on("FetchStandardFontData",(t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(t):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&(0,s.warn)("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.#tt.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.#et.set(i.refStr,t);const s=new PDFPageProxy(e,i,this,this._params.pdfBug);this.#Z.set(e,s);return s}));this.#tt.set(e,s);return s}getPageIndex(t){return isRefProxy(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.#st("GetFieldObjects")}hasJSActions(){return this.#st("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.#st("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.#st("GetOptionalContentConfig").then((e=>new p.OptionalContentConfig(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Q.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new u.Metadata(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));this.#Q.set(t,i);return i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#Z.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear();t||this.fontLoader.clear();this.#Q.clear();this.filterFactory.destroy(!0);(0,h.cleanupTextLayer)()}}cachedPageNumber(t){if(!isRefProxy(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#et.get(e)??null}get loadingParams(){const{disableAutoFetch:t,enableXfa:e}=this._params;return(0,s.shadow)(this,"loadingParams",{disableAutoFetch:t,enableXfa:e})}}const M=Symbol("INITIAL_DATA");class PDFObjects{#nt=Object.create(null);#at(t){return this.#nt[t]||={...Promise.withResolvers(),data:M}}get(t,e=null){if(e){const i=this.#at(t);i.promise.then((()=>e(i.data)));return null}const i=this.#nt[t];if(!i||i.data===M)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#nt[t];return!!e&&e.data!==M}resolve(t,e=null){const i=this.#at(t);i.data=e;i.resolve()}clear(){for(const t in this.#nt){const{data:e}=this.#nt[t];e?.bitmap?.close()}this.#nt=Object.create(null)}*[Symbol.iterator](){for(const t in this.#nt){const{data:e}=this.#nt[t];e!==M&&(yield[t,e])}}}class RenderTask{#rt=null;constructor(t){this.#rt=t;this.onContinue=null}get promise(){return this.#rt.capability.promise}cancel(t=0){this.#rt.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#rt.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#rt;return t.form||t.canvas&&e?.size>0}}class InternalRenderTask{static#ot=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:a,pageIndex:r,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null}){this.callback=t;this.params=e;this.objs=i;this.commonObjs=s;this.annotationCanvasMap=n;this.operatorListIdx=null;this.operatorList=a;this._pageIndex=r;this.canvasFactory=o;this.filterFactory=l;this._pdfBug=d;this.pageColors=c;this.running=!1;this.graphicsReadyCallback=null;this.graphicsReady=!1;this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window;this.cancelled=!1;this.capability=Promise.withResolvers();this.task=new RenderTask(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=e.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(InternalRenderTask.#ot.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.");InternalRenderTask.#ot.add(this._canvas)}if(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:i,viewport:s,transform:n,background:a}=this.params;this.gfx=new l.CanvasGraphics(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors);this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:a});this.operatorListIdx=0;this.graphicsReady=!0;this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1;this.cancelled=!0;this.gfx?.endDrawing();InternalRenderTask.#ot.delete(this._canvas);this.callback(t||new a.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){if(this.graphicsReady){this.stepper?.updateOperatorList(this.operatorList);this.running||this._continue()}else this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0;this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame((()=>{this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(!this.cancelled){this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper);if(this.operatorListIdx===this.operatorList.argsArray.length){this.running=!1;if(this.operatorList.lastChunk){this.gfx.endDrawing();InternalRenderTask.#ot.delete(this._canvas);this.callback()}}}}}const P="4.2.67",R="49b388101";i()}catch(F){i(F)}}))},583:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{BaseCMapReaderFactory:()=>BaseCMapReaderFactory,BaseCanvasFactory:()=>BaseCanvasFactory,BaseFilterFactory:()=>BaseFilterFactory,BaseSVGFactory:()=>BaseSVGFactory,BaseStandardFontDataFactory:()=>BaseStandardFontDataFactory});var i=e(292);class BaseFilterFactory{constructor(){this.constructor===BaseFilterFactory&&(0,i.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class BaseCanvasFactory{constructor(){this.constructor===BaseCanvasFactory&&(0,i.unreachable)("Cannot initialize BaseCanvasFactory.")}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")}}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){(0,i.unreachable)("Abstract method `_createCanvas` called.")}}class BaseCMapReaderFactory{constructor({baseUrl:t=null,isCompressed:e=!0}){this.constructor===BaseCMapReaderFactory&&(0,i.unreachable)("Cannot initialize BaseCMapReaderFactory.");this.baseUrl=t;this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":""),s=this.isCompressed?i.CMapCompressionType.BINARY:i.CMapCompressionType.NONE;return this._fetchData(e,s).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}_fetchData(t,e){(0,i.unreachable)("Abstract method `_fetchData` called.")}}class BaseStandardFontDataFactory{constructor({baseUrl:t=null}){this.constructor===BaseStandardFontDataFactory&&(0,i.unreachable)("Cannot initialize BaseStandardFontDataFactory.");this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetchData(e).catch((t=>{throw new Error(`Unable to load font data at: ${e}`)}))}_fetchData(t){(0,i.unreachable)("Abstract method `_fetchData` called.")}}class BaseSVGFactory{constructor(){this.constructor===BaseSVGFactory&&(0,i.unreachable)("Cannot initialize BaseSVGFactory.")}create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");s.setAttribute("version","1.1");if(!i){s.setAttribute("width",`${t}px`);s.setAttribute("height",`${e}px`)}s.setAttribute("preserveAspectRatio","none");s.setAttribute("viewBox",`0 0 ${t} ${e}`);return s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){(0,i.unreachable)("Abstract method `_createSVG` called.")}}},923:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{CanvasGraphics:()=>CanvasGraphics});var i=e(292),s=e(419);const n="Fill",a="Stroke",r="Shading";function applyBoundingBox(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 BaseShadingPattern{constructor(){this.constructor===BaseShadingPattern&&(0,i.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,i.unreachable)("Abstract method `getPattern` called.")}}class RadialAxialShadingPattern extends BaseShadingPattern{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 t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,r,o){let l;if(o===a||o===n){const n=e.current.getClippedPathBoundingBox(o,(0,s.getCurrentTransform)(t))||[0,0,0,0],a=Math.ceil(n[2]-n[0])||1,h=Math.ceil(n[3]-n[1])||1,d=e.cachedCanvases.getCanvas("pattern",a,h,!0),c=d.context;c.clearRect(0,0,c.canvas.width,c.canvas.height);c.beginPath();c.rect(0,0,c.canvas.width,c.canvas.height);c.translate(-n[0],-n[1]);r=i.Util.transform(r,[1,0,0,1,n[0],n[1]]);c.transform(...e.baseTransform);this.matrix&&c.transform(...this.matrix);applyBoundingBox(c,this._bbox);c.fillStyle=this._createGradient(c);c.fill();l=t.createPattern(d.canvas,"no-repeat");const u=new DOMMatrix(r);l.setTransform(u)}else{applyBoundingBox(t,this._bbox);l=this._createGradient(t)}return l}}function drawTriangle(t,e,i,s,n,a,r,o){const l=e.coords,h=e.colors,d=t.data,c=4*t.width;let u;if(l[i+1]>l[s+1]){u=i;i=s;s=u;u=a;a=r;r=u}if(l[s+1]>l[n+1]){u=s;s=n;n=u;u=r;r=o;o=u}if(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,A=(l[n+1]+e.offsetY)*e.scaleY;if(g>=A)return;const v=h[a],y=h[a+1],E=h[a+2],w=h[r],_=h[r+1],x=h[r+2],T=h[o],S=h[o+1],C=h[o+2],M=Math.round(g),P=Math.round(A);let R,F,k,D,I,L,O,N;for(let t=M;t<=P;t++){if(tA?1:f===A?0:(f-t)/(f-A);R=m-(m-b)*e;F=w-(w-T)*e;k=_-(_-S)*e;D=x-(x-C)*e}let e;e=tA?1:(g-t)/(g-A);I=p-(p-b)*e;L=v-(v-T)*e;O=y-(y-S)*e;N=E-(E-C)*e;const i=Math.round(Math.min(R,I)),s=Math.round(Math.max(R,I));let n=c*t+4*i;for(let t=i;t<=s;t++){e=(R-t)/(R-I);e<0?e=0:e>1&&(e=1);d[n++]=F-(F-L)*e|0;d[n++]=k-(k-O)*e|0;d[n++]=D-(D-N)*e|0;d[n++]=255}}}function drawFigure(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=s?n=s:i=n/t;return{scale:i,size:n}}clipBbox(t,e,i,n,a){const r=n-e,o=a-i;t.ctx.rect(e,i,r,o);t.current.updateRectMinMax((0,s.getCurrentTransform)(t.ctx),[e,i,n,a]);t.clip();t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const n=t.ctx,a=t.current;switch(e){case o:const t=this.ctx;n.fillStyle=t.fillStyle;n.strokeStyle=t.strokeStyle;a.fillColor=t.fillStyle;a.strokeColor=t.strokeStyle;break;case l:const r=i.Util.makeHexColor(s[0],s[1],s[2]);n.fillStyle=r;n.strokeStyle=r;a.fillColor=r;a.strokeColor=r;break;default:throw new i.FormatError(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,n){let a=s;if(n!==r){a=i.Util.transform(a,e.baseTransform);this.matrix&&(a=i.Util.transform(a,this.matrix))}const o=this.createPatternCanvas(e);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY);l=l.scale(1/o.scaleX,1/o.scaleY);const h=t.createPattern(o.canvas,"repeat");h.setTransform(l);return h}}function convertBlackAndWhiteToRGBA({src:t,srcPos:e=0,dest:s,width:n,height:a,nonBlackColor:r=4294967295,inverseDecode:o=!1}){const l=i.FeatureTest.isLittleEndian?4278190080:255,[h,d]=o?[r,l]:[l,r],c=n>>3,u=7&n,p=t.length;s=new Uint32Array(s.buffer);let g=0;for(let i=0;i>2),b=s.length,A=n+7>>3,v=4294967295,y=i.FeatureTest.isLittleEndian?4278190080:255;for(g=0;gA?n:8*t-7,r=-8&a;let o=0,l=0;for(;i>=1}}for(;h=r){f=a;b=n*f}h=0;for(m=b;m--;){p[h++]=u[c++];p[h++]=u[c++];p[h++]=u[c++];p[h++]=255}t.putImageData(l,0,g*d)}}}function putBinaryImageMask(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}const i=e.height,s=e.width,n=i%d,a=(i-n)/d,r=0===n?a:a+1,o=t.createImageData(s,d);let l=0;const h=e.data,c=o.data;for(let e=0;e>8;t[a-2]=t[a-2]*n+i*r>>8;t[a-1]=t[a-1]*n+s*r>>8}}}function composeSMaskAlpha(t,e,i){const s=t.length;for(let n=3;n>8]>>8:e[n]*s>>16}}function composeSMask(t,e,i,s){const n=s[0],a=s[1],r=s[2]-n,o=s[3]-a;if(0!==r&&0!==o){!function genericComposeSMask(t,e,i,s,n,a,r,o,l,h,d){const c=!!a,u=c?a[0]:0,p=c?a[1]:0,g=c?a[2]:0,m="Luminosity"===n?composeSMaskLuminosity:composeSMaskAlpha,f=Math.min(s,Math.ceil(1048576/i));for(let n=0;n10&&"function"==typeof s,d=h?Date.now()+15:0;let c=0;const u=this.commonObjs,p=this.objs;let g;for(;;){if(void 0!==n&&o===n.nextBreakPoint){n.breakIt(o,s);return o}g=r[o];if(g!==i.OPS.dependency)this[g].apply(this,a[o]);else for(const t of a[o]){const e=t.startsWith("g_")?u:p;if(!e.has(t)){e.get(t,s);return o}}o++;if(o===l)return o;if(h&&++c>10){if(Date.now()>d){s();return o}c=0}}}#lt(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore();if(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.#lt();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.#ht()}#ht(){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,s=t.height;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,d="prescale1";for(;r>2&&l>1||o>2&&h>1;){let e=l,i=h;if(r>2&&l>1){e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2);r/=l/e}if(o>2&&h>1){i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2;o/=h/i}n=this.cachedCanvases.getCanvas(d,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;d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:a,height:r}=t,o=this.current.fillColor,l=this.current.patternFill,h=(0,s.getCurrentTransform)(e);let d,c,u,p;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;c=JSON.stringify(l?h:[h.slice(0,4),o]);d=this._cachedBitmapsMap.get(e);if(!d){d=new Map;this._cachedBitmapsMap.set(e,d)}const i=d.get(c);if(i&&!l){return{canvas:i,offsetX:Math.round(Math.min(h[0],h[2])+h[4]),offsetY:Math.round(Math.min(h[1],h[3])+h[5])}}u=i}if(!u){p=this.cachedCanvases.getCanvas("maskCanvas",a,r);putBinaryImageMask(p.context,t)}let g=i.Util.transform(h,[1/a,0,0,-1/r,0,0]);g=i.Util.transform(g,[1,0,0,1,0,-r]);const[m,f,b,A]=i.Util.getAxialAlignedBoundingBox([0,0,a,r],g),v=Math.round(b-m)||1,y=Math.round(A-f)||1,E=this.cachedCanvases.getCanvas("fillCanvas",v,y),w=E.context,_=m,x=f;w.translate(-_,-x);w.transform(...g);if(!u){u=this._scaleImage(p.canvas,(0,s.getCurrentTransformInverse)(w));u=u.img;d&&l&&d.set(c,u)}w.imageSmoothingEnabled=getImageSmoothingEnabled((0,s.getCurrentTransform)(w),t.interpolate);drawImageAtIntegerCoords(w,u,0,0,u.width,u.height,0,0,a,r);w.globalCompositeOperation="source-in";const T=i.Util.transform((0,s.getCurrentTransformInverse)(w),[1,0,0,1,-_,-x]);w.fillStyle=l?o.getPattern(e,this,T,n):o;w.fillRect(0,0,a,r);if(d&&!l){this.cachedCanvases.delete("fillCanvas");d.set(c,E.canvas)}return{canvas:E.canvas,offsetX:Math.round(_),offsetY:Math.round(x)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1);this.current.lineWidth=t;this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=c[t]}setLineJoin(t){this.ctx.lineJoin=u[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;if(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,n=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx;this.ctx=n.context;const a=this.ctx;a.setTransform(...(0,s.getCurrentTransform)(this.suspendedCtx));copyCtxState(this.suspendedCtx,a);!function mirrorContextOperations(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 ctxSave(){e.save();this.__originalSave()};t.restore=function ctxRestore(){e.restore();this.__originalRestore()};t.translate=function ctxTranslate(t,i){e.translate(t,i);this.__originalTranslate(t,i)};t.scale=function ctxScale(t,i){e.scale(t,i);this.__originalScale(t,i)};t.transform=function ctxTransform(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 ctxSetTransform(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 ctxResetTransform(){e.resetTransform();this.__originalResetTransform()};t.rotate=function ctxRotate(t){e.rotate(t);this.__originalRotate(t)};t.clip=function ctxRotate(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()}}(a,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();copyCtxState(this.ctx,this.suspendedCtx);this.ctx=this.suspendedCtx;this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;if(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])}else t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask;composeSMask(this.suspendedCtx,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()}save(){if(this.inSMaskMode){copyCtxState(this.ctx,this.suspendedCtx);this.suspendedCtx.save()}else this.ctx.save();const t=this.current;this.stateStack.push(t);this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode();if(0!==this.stateStack.length){this.current=this.stateStack.pop();if(this.inSMaskMode){this.suspendedCtx.restore();copyCtxState(this.suspendedCtx,this.ctx)}else 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,n){const a=this.ctx,r=this.current;let o,l,h=r.x,d=r.y;const c=(0,s.getCurrentTransform)(a),u=0===c[0]&&0===c[3]||0===c[1]&&0===c[2],p=u?n.slice(0):null;for(let s=0,n=0,g=t.length;s100&&(h=100);this.current.fontSizeScale=e/h;this.ctx.font=`${l} ${o} ${h}px ${r}`}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,n,a){const r=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,c=h&i.TextRenderingMode.FILL_STROKE_MASK,u=!!(h&i.TextRenderingMode.ADD_TO_PATH_FLAG),p=o.patternFill&&!l.missingFile;let g;(l.disableFontFace||u||p)&&(g=l.getPathGenerator(this.commonObjs,t));if(l.disableFontFace||p){r.save();r.translate(e,n);r.beginPath();g(r,d);a&&r.setTransform(...a);c!==i.TextRenderingMode.FILL&&c!==i.TextRenderingMode.FILL_STROKE||r.fill();c!==i.TextRenderingMode.STROKE&&c!==i.TextRenderingMode.FILL_STROKE||r.stroke();r.restore()}else{c!==i.TextRenderingMode.FILL&&c!==i.TextRenderingMode.FILL_STROKE||r.fillText(t,e,n);c!==i.TextRenderingMode.STROKE&&c!==i.TextRenderingMode.FILL_STROKE||r.strokeText(t,e,n)}if(u){(this.pendingTextPaths||=[]).push({transform:(0,s.getCurrentTransform)(r),x:e,y:n,fontSize:d,addToPath:g})}}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 s=!1;for(let t=3;t0&&e[t]<255){s=!0;break}return(0,i.shadow)(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,a=e.font;if(a.isType3Font)return this.showType3Text(t);const r=e.fontSize;if(0===r)return;const o=this.ctx,l=e.fontSizeScale,h=e.charSpacing,d=e.wordSpacing,c=e.fontDirection,u=e.textHScale*c,p=t.length,g=a.vertical,m=g?1:-1,f=a.defaultVMetrics,b=r*e.fontMatrix[0],A=e.textRenderingMode===i.TextRenderingMode.FILL&&!a.disableFontFace&&!e.patternFill;o.save();o.transform(...e.textMatrix);o.translate(e.x,e.y+e.textRise);c>0?o.scale(u,-1):o.scale(u,1);let v;if(e.patternFill){o.save();const t=e.fillColor.getPattern(o,this,(0,s.getCurrentTransformInverse)(o),n);v=(0,s.getCurrentTransform)(o);o.restore();o.fillStyle=t}let y=e.lineWidth;const E=e.textMatrixScale;if(0===E||0===y){const t=e.textRenderingMode&i.TextRenderingMode.FILL_STROKE_MASK;t!==i.TextRenderingMode.STROKE&&t!==i.TextRenderingMode.FILL_STROKE||(y=this.getSinglePixelWidth())}else y/=E;if(1!==l){o.scale(l,l);y/=l}o.lineWidth=y;if(a.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t){i.push(e.unicode);s+=e.width}o.fillText(i.join(""),0,0);e.x+=s*b*u;o.restore();this.compose();return}let w,_=0;for(w=0;w0){const t=1e3*o.measureText(n).width/r*l;if(Enew CanvasGraphics(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new TilingPattern(t,i,this.ctx,a,n)}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,s){const n=i.Util.makeHexColor(t,e,s);this.ctx.strokeStyle=n;this.current.strokeColor=n}setFillRGBColor(t,e,s){const n=i.Util.makeHexColor(t,e,s);this.ctx.fillStyle=n;this.current.fillColor=n;this.current.patternFill=!1}_getPattern(t,e=null){let i;if(this.cachedPatterns.has(t))i=this.cachedPatterns.get(t);else{i=function getShadingPattern(t){switch(t[0]){case"RadialAxial":return new RadialAxialShadingPattern(t);case"Mesh":return new MeshShadingPattern(t);case"Dummy":return new DummyShadingPattern}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t));this.cachedPatterns.set(t,i)}e&&(i.matrix=e);return i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const n=this._getPattern(t);e.fillStyle=n.getPattern(e,this,(0,s.getCurrentTransformInverse)(e),r);const a=(0,s.getCurrentTransformInverse)(e);if(a){const{width:t,height:s}=e.canvas,[n,r,o,l]=i.Util.getAxialAlignedBoundingBox([0,0,t,s],a);this.ctx.fillRect(n,r,o-n,l-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox());this.restore()}beginInlineImage(){(0,i.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,i.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible){this.save();this.baseTransformStack.push(this.baseTransform);Array.isArray(t)&&6===t.length&&this.transform(...t);this.baseTransform=(0,s.getCurrentTransform)(this.ctx);if(e){const t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i);this.current.updateRectMinMax((0,s.getCurrentTransform)(this.ctx),e);this.clip();this.endPath()}}}paintFormXObjectEnd(){if(this.contentVisible){this.restore();this.baseTransform=this.baseTransformStack.pop()}}beginGroup(t){if(!this.contentVisible)return;this.save();if(this.inSMaskMode){this.endSMaskMode();this.current.activeSMask=null}const e=this.ctx;t.isolated||(0,i.info)("TODO: Support non-isolated groups.");t.knockout&&(0,i.warn)("Knockout groups not supported.");const n=(0,s.getCurrentTransform)(e);t.matrix&&e.transform(...t.matrix);if(!t.bbox)throw new Error("Bounding box is required.");let a=i.Util.getAxialAlignedBoundingBox(t.bbox,(0,s.getCurrentTransform)(e));const r=[0,0,e.canvas.width,e.canvas.height];a=i.Util.intersect(a,r)||[0,0,0,0];const o=Math.floor(a[0]),l=Math.floor(a[1]);let d=Math.max(Math.ceil(a[2])-o,1),c=Math.max(Math.ceil(a[3])-l,1),u=1,p=1;if(d>h){u=d/h;d=h}if(c>h){p=c/h;c=h}this.current.startNewPathAndClipBox([0,0,d,c]);let g="groupAt"+this.groupLevel;t.smask&&(g+="_smask_"+this.smaskCounter++%2);const m=this.cachedCanvases.getCanvas(g,d,c),f=m.context;f.scale(1/u,1/p);f.translate(-o,-l);f.transform(...n);if(t.smask)this.smaskStack.push({canvas:m.canvas,context:f,offsetX:o,offsetY:l,scaleX:u,scaleY:p,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null});else{e.setTransform(1,0,0,1,0,0);e.translate(o,l);e.scale(u,p);e.save()}copyCtxState(e,f);this.ctx=f;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,n=this.groupStack.pop();this.ctx=n;this.ctx.imageSmoothingEnabled=!1;if(t.smask){this.tempSMask=this.smaskStack.pop();this.restore()}else{this.ctx.restore();const t=(0,s.getCurrentTransform)(this.ctx);this.restore();this.ctx.save();this.ctx.setTransform(...t);const n=i.Util.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0);this.ctx.restore();this.compose(n)}}beginAnnotation(t,e,n,a,r){this.#lt();resetCtxToDefault(this.ctx);this.ctx.save();this.save();this.baseTransform&&this.ctx.setTransform(...this.baseTransform);if(Array.isArray(e)&&4===e.length){const a=e[2]-e[0],o=e[3]-e[1];if(r&&this.annotationCanvasMap){(n=n.slice())[4]-=e[0];n[5]-=e[1];(e=e.slice())[0]=e[1]=0;e[2]=a;e[3]=o;const[r,l]=i.Util.singularValueDecompose2dScale((0,s.getCurrentTransform)(this.ctx)),{viewportScale:h}=this,d=Math.ceil(a*this.outputScaleX*h),c=Math.ceil(o*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(d,c);const{canvas:u,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(t,u);this.annotationCanvas.savedCtx=this.ctx;this.ctx=p;this.ctx.save();this.ctx.setTransform(r,0,0,-l,0,o*l);resetCtxToDefault(this.ctx)}else{resetCtxToDefault(this.ctx);this.ctx.rect(e[0],e[1],a,o);this.ctx.clip();this.endPath()}}this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.transform(...n);this.transform(...a)}endAnnotation(){if(this.annotationCanvas){this.ctx.restore();this.#ht();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 compileType3Glyph(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 d=new Uint8Array(h*i),c=0;for(const e of t.data){let t=128;for(;t>0;){d[c++]=e&t?0:255;t>>=1}}let u=0;c=0;if(0!==d[c]){l[0]=1;++u}for(r=1;r>2)+(d[c+1]?4:0)+(d[c-h+1]?8:0);if(s[t]){l[o+r]=s[t];++u}c++}if(d[c-h]!==d[c]){l[o+r]=d[c]?2:4;++u}if(u>1e3)return null}c=h*(i-1);o=a*n;if(0!==d[c]){l[o]=8;++u}for(r=1;r1e3)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>4;l[t]&=r>>2|r<<2}g.lineTo(t%n,t/n|0);l[t]||--u}while(s!==t);--a}d=null;l=null;return function(t){t.save();t.scale(1/e,-1/i);t.translate(0,-i);t.fill(g);t.beginPath();t.restore()}}(t));if(s.compiled){s.compiled(i);return}}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,n=0,a=0,r,o){if(!this.contentVisible)return;t=this.getObject(t.data,t);const l=this.ctx;l.save();const h=(0,s.getCurrentTransform)(l);l.transform(e,n,a,r,0,0);const d=this._createMaskCanvas(t);l.setTransform(1,0,0,1,d.offsetX-h[4],d.offsetY-h[5]);for(let t=0,s=o.length;te?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();e.lineWidth=i||1;if(1===s&&1===n){e.stroke();return}const a=e.getLineDash();t&&e.save();e.scale(s,n);if(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 t in i.OPS)void 0!==CanvasGraphics.prototype[t]&&(CanvasGraphics.prototype[i.OPS[t]]=CanvasGraphics.prototype[t])},419:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{DOMCMapReaderFactory:()=>DOMCMapReaderFactory,DOMCanvasFactory:()=>DOMCanvasFactory,DOMFilterFactory:()=>DOMFilterFactory,DOMSVGFactory:()=>DOMSVGFactory,DOMStandardFontDataFactory:()=>DOMStandardFontDataFactory,PDFDateString:()=>PDFDateString,PageViewport:()=>PageViewport,PixelsPerInch:()=>PixelsPerInch,RenderingCancelledException:()=>RenderingCancelledException,StatTimer:()=>StatTimer,fetchData:()=>fetchData,getColorValues:()=>getColorValues,getCurrentTransform:()=>getCurrentTransform,getCurrentTransformInverse:()=>getCurrentTransformInverse,getFilenameFromUrl:()=>getFilenameFromUrl,getPdfFilenameFromUrl:()=>getPdfFilenameFromUrl,getRGB:()=>getRGB,getXfaPageViewport:()=>getXfaPageViewport,isDataScheme:()=>isDataScheme,isPdfFile:()=>isPdfFile,isValidFetchUrl:()=>isValidFetchUrl,noContextMenu:()=>noContextMenu,setLayerDimensions:()=>setLayerDimensions});var i=e(583),s=e(292);const n="http://www.w3.org/2000/svg";class PixelsPerInch{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}class DOMFilterFactory extends i.BaseFilterFactory{#dt;#ct;#j;#ut;#pt;#gt=0;constructor({docId:t,ownerDocument:e=globalThis.document}={}){super();this.#j=t;this.#ut=e}get#mt(){return this.#dt||=new Map}get#ft(){return this.#pt||=new Map}get#bt(){if(!this.#ct){const t=this.#ut.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.#ut.createElementNS(n,"svg");i.setAttribute("width",0);i.setAttribute("height",0);this.#ct=this.#ut.createElementNS(n,"defs");t.append(i);i.append(this.#ct);this.#ut.body.append(t)}return this.#ct}addFilter(t){if(!t)return"none";let e,i,s,n,a=this.#mt.get(t);if(a)return a;if(1===t.length){const a=t[0],r=new Array(256);for(let t=0;t<256;t++)r[t]=a[t]/255;n=e=i=s=r.join(",")}else{const[a,r,o]=t,l=new Array(256),h=new Array(256),d=new Array(256);for(let t=0;t<256;t++){l[t]=a[t]/255;h[t]=r[t]/255;d[t]=o[t]/255}e=l.join(",");i=h.join(",");s=d.join(",");n=`${e}${i}${s}`}a=this.#mt.get(n);if(a){this.#mt.set(t,a);return a}const r=`g_${this.#j}_transfer_map_${this.#gt++}`,o=`url(#${r})`;this.#mt.set(t,o);this.#mt.set(n,o);const l=this.#At(r);this.#vt(e,i,s,l);return o}addHCMFilter(t,e){const i=`${t}-${e}`,n="base";let a=this.#ft.get(n);if(a?.key===i)return a.url;if(a){a.filter?.remove();a.key=i;a.url="none";a.filter=null}else{a={key:i,url:"none",filter:null};this.#ft.set(n,a)}if(!t||!e)return a.url;const r=this.#yt(t);t=s.Util.makeHexColor(...r);const o=this.#yt(e);e=s.Util.makeHexColor(...o);this.#bt.style.color="";if("#000000"===t&&"#ffffff"===e||t===e)return a.url;const l=new Array(256);for(let t=0;t<=255;t++){const e=t/255;l[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const h=l.join(","),d=`g_${this.#j}_hcm_filter`,c=a.filter=this.#At(d);this.#vt(h,h,h,c);this.#Et(c);const getSteps=(t,e)=>{const i=r[t]/255,s=o[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};this.#vt(getSteps(0,5),getSteps(1,5),getSteps(2,5),c);a.url=`url(#${d})`;return a.url}addHighlightHCMFilter(t,e,i,s,n){const a=`${e}-${i}-${s}-${n}`;let r=this.#ft.get(t);if(r?.key===a)return r.url;if(r){r.filter?.remove();r.key=a;r.url="none";r.filter=null}else{r={key:a,url:"none",filter:null};this.#ft.set(t,r)}if(!e||!i)return r.url;const[o,l]=[e,i].map(this.#yt.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,n].map(this.#yt.bind(this));d{const s=new Array(256),n=(d-h)/i,a=t/255,r=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*n),i=a+t*r;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},p=`g_${this.#j}_hcm_${t}_filter`,g=r.filter=this.#At(p);this.#Et(g);this.#vt(getSteps(c[0],u[0],5),getSteps(c[1],u[1],5),getSteps(c[2],u[2],5),g);r.url=`url(#${p})`;return r.url}destroy(t=!1){if(!t||0===this.#ft.size){if(this.#ct){this.#ct.parentNode.parentNode.remove();this.#ct=null}if(this.#dt){this.#dt.clear();this.#dt=null}this.#gt=0}}#Et(t){const e=this.#ut.createElementNS(n,"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)}#At(t){const e=this.#ut.createElementNS(n,"filter");e.setAttribute("color-interpolation-filters","sRGB");e.setAttribute("id",t);this.#bt.append(e);return e}#wt(t,e,i){const s=this.#ut.createElementNS(n,e);s.setAttribute("type","discrete");s.setAttribute("tableValues",i);t.append(s)}#vt(t,e,i,s){const a=this.#ut.createElementNS(n,"feComponentTransfer");s.append(a);this.#wt(a,"feFuncR",t);this.#wt(a,"feFuncG",e);this.#wt(a,"feFuncB",i)}#yt(t){this.#bt.style.color=t;return getRGB(getComputedStyle(this.#bt).getPropertyValue("color"))}}class DOMCanvasFactory extends i.BaseCanvasFactory{constructor({ownerDocument:t=globalThis.document}={}){super();this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");i.width=t;i.height=e;return i}}async function fetchData(t,e="text"){if(isValidFetchUrl(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":i(n.response);return}i(n.responseText)}};n.send(null)}))}class DOMCMapReaderFactory extends i.BaseCMapReaderFactory{_fetchData(t,e){return fetchData(t,this.isCompressed?"arraybuffer":"text").then((t=>({cMapData:t instanceof ArrayBuffer?new Uint8Array(t):(0,s.stringToBytes)(t),compressionType:e})))}}class DOMStandardFontDataFactory extends i.BaseStandardFontDataFactory{_fetchData(t){return fetchData(t,"arraybuffer").then((t=>new Uint8Array(t)))}}class DOMSVGFactory extends i.BaseSVGFactory{_createSVG(t){return document.createElementNS(n,t)}}class PageViewport{constructor({viewBox:t,scale:e,rotation:i,offsetX:s=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t;this.scale=e;this.rotation=i;this.offsetX=s;this.offsetY=n;const r=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let l,h,d,c,u,p,g,m;(i%=360)<0&&(i+=360);switch(i){case 180:l=-1;h=0;d=0;c=1;break;case 90:l=0;h=1;d=1;c=0;break;case 270:l=0;h=-1;d=-1;c=0;break;case 0:l=1;h=0;d=0;c=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(a){d=-d;c=-c}if(0===l){u=Math.abs(o-t[1])*e+s;p=Math.abs(r-t[0])*e+n;g=(t[3]-t[1])*e;m=(t[2]-t[0])*e}else{u=Math.abs(r-t[0])*e+s;p=Math.abs(o-t[1])*e+n;g=(t[2]-t[0])*e;m=(t[3]-t[1])*e}this.transform=[l*e,h*e,d*e,c*e,u-l*e*r-d*e*o,p-h*e*r-c*e*o];this.width=g;this.height=m}get rawDims(){const{viewBox:t}=this;return(0,s.shadow)(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new PageViewport({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){return s.Util.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=s.Util.applyTransform([t[0],t[1]],this.transform),i=s.Util.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return s.Util.applyInverseTransform([t,e],this.transform)}}class RenderingCancelledException extends s.BaseException{constructor(t,e=0){super(t,"RenderingCancelledException");this.extraDelay=e}}function isDataScheme(t){const e=t.length;let i=0;for(;i=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const h=e[7]||"Z";let d=parseInt(e[8],10);d=d>=0&&d<=23?d:0;let c=parseInt(e[9],10)||0;c=c>=0&&c<=59?c:0;if("-"===h){r+=d;o+=c}else if("+"===h){r-=d;o-=c}return new Date(Date.UTC(i,s,n,r,o,l))}}function getXfaPageViewport(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,a=[0,0,parseInt(s),parseInt(n)];return new PageViewport({viewBox:a,scale:e,rotation:i})}function getRGB(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}if(t.startsWith("rgb("))return t.slice(4,-1).split(",").map((t=>parseInt(t)));if(t.startsWith("rgba("))return t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3);(0,s.warn)(`Not a valid color format: "${t}"`);return[0,0,0]}function getColorValues(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,getRGB(s))}e.remove()}function getCurrentTransform(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform();return[e,i,s,n,a,r]}function getCurrentTransformInverse(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 setLayerDimensions(t,e,i=!1,n=!0){if(e instanceof PageViewport){const{pageWidth:n,pageHeight:a}=e.rawDims,{style:r}=t,o=s.FeatureTest.isCSSRoundSupported,l=`var(--scale-factor) * ${n}px`,h=`var(--scale-factor) * ${a}px`,d=o?`round(${l}, 1px)`:`calc(${l})`,c=o?`round(${h}, 1px)`:`calc(${h})`;if(i&&e.rotation%180!=0){r.width=c;r.height=d}else{r.width=d;r.height=c}}n&&t.setAttribute("data-main-rotation",e.rotation)}},47:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{DrawLayer:()=>DrawLayer});var i=e(419),s=e(292);class DrawLayer{#v=null;#gt=0;#_t=new Map;#xt=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#v){if(this.#v!==t){if(this.#_t.size>0)for(const e of this.#_t.values()){e.remove();t.append(e)}this.#v=t}}else this.#v=t}static get _svgFactory(){return(0,s.shadow)(this,"_svgFactory",new i.DOMSVGFactory)}static#Tt(t,{x:e=0,y:i=0,width:s=1,height:n=1}={}){const{style:a}=t;a.top=100*i+"%";a.left=100*e+"%";a.width=100*s+"%";a.height=100*n+"%"}#St(t){const e=DrawLayer._svgFactory.create(1,1,!0);this.#v.append(e);e.setAttribute("aria-hidden",!0);DrawLayer.#Tt(e,t);return e}#Ct(t,e){const i=DrawLayer._svgFactory.createElement("clipPath");t.append(i);const s=`clip_${e}`;i.setAttribute("id",s);i.setAttribute("clipPathUnits","objectBoundingBox");const n=DrawLayer._svgFactory.createElement("use");i.append(n);n.setAttribute("href",`#${e}`);n.classList.add("clip");return s}highlight(t,e,i,s=!1){const n=this.#gt++,a=this.#St(t.box);a.classList.add("highlight");t.free&&a.classList.add("free");const r=DrawLayer._svgFactory.createElement("defs");a.append(r);const o=DrawLayer._svgFactory.createElement("path");r.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l);o.setAttribute("d",t.toSVGPath());s&&this.#xt.set(n,o);const h=this.#Ct(r,l),d=DrawLayer._svgFactory.createElement("use");a.append(d);a.setAttribute("fill",e);a.setAttribute("fill-opacity",i);d.setAttribute("href",`#${l}`);this.#_t.set(n,a);return{id:n,clipPathId:`url(#${h})`}}highlightOutline(t){const e=this.#gt++,i=this.#St(t.box);i.classList.add("highlightOutline");const s=DrawLayer._svgFactory.createElement("defs");i.append(s);const n=DrawLayer._svgFactory.createElement("path");s.append(n);const a=`path_p${this.pageIndex}_${e}`;n.setAttribute("id",a);n.setAttribute("d",t.toSVGPath());n.setAttribute("vector-effect","non-scaling-stroke");let r;if(t.free){i.classList.add("free");const t=DrawLayer._svgFactory.createElement("mask");s.append(t);r=`mask_p${this.pageIndex}_${e}`;t.setAttribute("id",r);t.setAttribute("maskUnits","objectBoundingBox");const n=DrawLayer._svgFactory.createElement("rect");t.append(n);n.setAttribute("width","1");n.setAttribute("height","1");n.setAttribute("fill","white");const o=DrawLayer._svgFactory.createElement("use");t.append(o);o.setAttribute("href",`#${a}`);o.setAttribute("stroke","none");o.setAttribute("fill","black");o.setAttribute("fill-rule","nonzero");o.classList.add("mask")}const o=DrawLayer._svgFactory.createElement("use");i.append(o);o.setAttribute("href",`#${a}`);r&&o.setAttribute("mask",`url(#${r})`);const l=o.cloneNode();i.append(l);o.classList.add("mainOutline");l.classList.add("secondaryOutline");this.#_t.set(e,i);return e}finalizeLine(t,e){const i=this.#xt.get(t);this.#xt.delete(t);this.updateBox(t,e.box);i.setAttribute("d",e.toSVGPath())}updateLine(t,e){this.#_t.get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}removeFreeHighlight(t){this.remove(t);this.#xt.delete(t)}updatePath(t,e){this.#xt.get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){DrawLayer.#Tt(this.#_t.get(t),e)}show(t,e){this.#_t.get(t).classList.toggle("hidden",!e)}rotate(t,e){this.#_t.get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){this.#_t.get(t).setAttribute("fill",e)}changeOpacity(t,e){this.#_t.get(t).setAttribute("fill-opacity",e)}addClass(t,e){this.#_t.get(t).classList.add(e)}removeClass(t,e){this.#_t.get(t).classList.remove(e)}remove(t){if(null!==this.#v){this.#_t.get(t).remove();this.#_t.delete(t)}}destroy(){this.#v=null;for(const t of this.#_t.values())t.remove();this.#_t.clear()}}},731:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{AnnotationEditorLayer:()=>AnnotationEditorLayer});var i=e(292),s=e(310),n=e(830),a=e(976);const r=/\r\n?|\n/g;class FreeTextEditor extends s.AnnotationEditor{#Mt=this.editorDivBlur.bind(this);#Pt=this.editorDivFocus.bind(this);#Rt=this.editorDivInput.bind(this);#Ft=this.editorDivKeydown.bind(this);#kt=this.editorDivPaste.bind(this);#g;#Dt="";#It=`${this.id}-editor`;#Lt;#Ot=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=FreeTextEditor.prototype,arrowChecker=t=>t.isEmpty(),e=n.AnnotationEditorUIManager.TRANSLATE_SMALL,s=n.AnnotationEditorUIManager.TRANSLATE_BIG;return(0,i.shadow)(this,"_keyboardManager",new n.KeyboardManager([[["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:[-e,0],checker:arrowChecker}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:arrowChecker}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[e,0],checker:arrowChecker}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:arrowChecker}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-e],checker:arrowChecker}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:arrowChecker}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,e],checker:arrowChecker}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:arrowChecker}]]))}static _type="freetext";static _editorType=i.AnnotationEditorType.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"});this.#g=t.color||FreeTextEditor._defaultColor||s.AnnotationEditor._defaultLineColor;this.#Lt=t.fontSize||FreeTextEditor._defaultFontSize}static initialize(t,e){s.AnnotationEditor.initialize(t,e,{strings:["pdfjs-free-text-default-content"]});const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case i.AnnotationEditorParamsType.FREETEXT_SIZE:FreeTextEditor._defaultFontSize=e;break;case i.AnnotationEditorParamsType.FREETEXT_COLOR:FreeTextEditor._defaultColor=e}}updateParams(t,e){switch(t){case i.AnnotationEditorParamsType.FREETEXT_SIZE:this.#Nt(e);break;case i.AnnotationEditorParamsType.FREETEXT_COLOR:this.#Bt(e)}}static get defaultPropertiesToUpdate(){return[[i.AnnotationEditorParamsType.FREETEXT_SIZE,FreeTextEditor._defaultFontSize],[i.AnnotationEditorParamsType.FREETEXT_COLOR,FreeTextEditor._defaultColor||s.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[i.AnnotationEditorParamsType.FREETEXT_SIZE,this.#Lt],[i.AnnotationEditorParamsType.FREETEXT_COLOR,this.#g]]}#Nt(t){const setFontsize=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`;this.translate(0,-(t-this.#Lt)*this.parentScale);this.#Lt=t;this.#Ht()},e=this.#Lt;this.addCommands({cmd:setFontsize.bind(this,t),undo:setFontsize.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#Bt(t){const setColor=t=>{this.#g=this.editorDiv.style.color=t},e=this.#g;this.addCommands({cmd:setColor.bind(this,t),undo:setColor.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-FreeTextEditor._internalPadding*t,-(FreeTextEditor._internalPadding+this.#Lt)*t]}rebuild(){if(this.parent){super.rebuild();null!==this.div&&(this.isAttachedToDOM||this.parent.add(this))}}enableEditMode(){if(!this.isInEditMode()){this.parent.setEditingState(!1);this.parent.updateToolbar(i.AnnotationEditorType.FREETEXT);super.enableEditMode();this.overlayDiv.classList.remove("enabled");this.editorDiv.contentEditable=!0;this._isDraggable=!1;this.div.removeAttribute("aria-activedescendant");this.editorDiv.addEventListener("keydown",this.#Ft);this.editorDiv.addEventListener("focus",this.#Pt);this.editorDiv.addEventListener("blur",this.#Mt);this.editorDiv.addEventListener("input",this.#Rt);this.editorDiv.addEventListener("paste",this.#kt)}}disableEditMode(){if(this.isInEditMode()){this.parent.setEditingState(!0);super.disableEditMode();this.overlayDiv.classList.add("enabled");this.editorDiv.contentEditable=!1;this.div.setAttribute("aria-activedescendant",this.#It);this._isDraggable=!0;this.editorDiv.removeEventListener("keydown",this.#Ft);this.editorDiv.removeEventListener("focus",this.#Pt);this.editorDiv.removeEventListener("blur",this.#Mt);this.editorDiv.removeEventListener("input",this.#Rt);this.editorDiv.removeEventListener("paste",this.#kt);this.div.focus({preventScroll:!0});this.isEditing=!1;this.parent.div.classList.add("freetextEditing")}}focusin(t){if(this._focusEventsAllowed){super.focusin(t);t.target!==this.editorDiv&&this.editorDiv.focus()}}onceAdded(){if(!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;if(this.parent){this.parent.setEditingState(!0);this.parent.div.classList.add("freetextEditing")}super.remove()}#Ut(){const t=[];this.editorDiv.normalize();for(const e of this.editorDiv.childNodes)t.push(FreeTextEditor.#zt(e));return t.join("\n")}#Ht(){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)}if(this.rotation%180==this.parentRotation%180){this.width=i.width/t;this.height=i.height/e}else{this.width=i.height/t;this.height=i.width/e}this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit();this.disableEditMode();const t=this.#Dt,e=this.#Dt=this.#Ut().trimEnd();if(t===e)return;const setText=t=>{this.#Dt=t;if(t){this.#Vt();this._uiManager.rebuild(this);this.#Ht()}else this.remove()};this.addCommands({cmd:()=>{setText(e)},undo:()=>{setText(t)},mustExec:!1});this.#Ht()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode();this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){if(t.target===this.div&&"Enter"===t.key){this.enterInEditMode();t.preventDefault()}}editorDivKeydown(t){FreeTextEditor._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)}render(){if(this.div)return this.div;let t,e;if(this.width){t=this.x;e=this.y}super.render();this.editorDiv=document.createElement("div");this.editorDiv.className="internal";this.editorDiv.setAttribute("id",this.#It);this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text");this.enableEditing();s.AnnotationEditor._l10nPromise.get("pdfjs-free-text-default-content").then((t=>this.editorDiv?.setAttribute("default-content",t)));this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;i.fontSize=`calc(${this.#Lt}px * var(--scale-factor))`;i.color=this.#g;this.div.append(this.editorDiv);this.overlayDiv=document.createElement("div");this.overlayDiv.classList.add("overlay","enabled");this.div.append(this.overlayDiv);(0,n.bindEvents)(this,this.div,["dblclick","keydown"]);if(this.width){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this.#Ot;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);const[o,l]=this.pageDimensions,[h,d]=this.pageTranslation;let c,u;switch(this.rotation){case 0:c=t+(n[0]-h)/o;u=e+this.height-(n[1]-d)/l;break;case 90:c=t+(n[0]-h)/o;u=e-(n[1]-d)/l;[a,r]=[r,-a];break;case 180:c=t-this.width+(n[0]-h)/o;u=e-(n[1]-d)/l;[a,r]=[-a,-r];break;case 270:c=t+(n[0]-h-this.height*l)/o;u=e+(n[1]-d-this.width*o)/l;[a,r]=[-r,a]}this.setAt(c*i,u*s,a,r)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#Vt();this._isDraggable=!0;this.editorDiv.contentEditable=!1}else{this._isDraggable=!1;this.editorDiv.contentEditable=!0}return this.div}static#zt(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(r,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=FreeTextEditor.#jt(e.getData("text")||"").replaceAll(r,"\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")){a.insertNode(document.createTextNode(s));this.editorDiv.normalize();n.collapseToStart();return}const{startContainer:o,startOffset:l}=a,h=[],d=[];if(o.nodeType===Node.TEXT_NODE){const t=o.parentElement;d.push(o.nodeValue.slice(l).replaceAll(r,""));if(t!==this.editorDiv){let e=h;for(const i of this.editorDiv.childNodes)i!==t?e.push(FreeTextEditor.#zt(i)):e=d}h.push(o.nodeValue.slice(0,l).replaceAll(r,""))}else if(o===this.editorDiv){let t=h,e=0;for(const i of this.editorDiv.childNodes){e++===l&&(t=d);t.push(FreeTextEditor.#zt(i))}}this.#Dt=`${h.join("\n")}${s}${d.join("\n")}`;this.#Vt();const c=new Range;let u=h.reduce(((t,e)=>t+e.length),0);for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(u<=e){c.setStart(t,u);c.setEnd(t,u);break}u-=e}n.removeAllRanges();n.addRange(c)}#Vt(){this.editorDiv.replaceChildren();if(this.#Dt)for(const t of this.#Dt.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br"));this.editorDiv.append(e)}}#Gt(){return this.#Dt.replaceAll(" "," ")}static#jt(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static deserialize(t,e,s){let n=null;if(t instanceof a.FreeTextAnnotationElement){const{data:{defaultAppearanceData:{fontSize:e,fontColor:s},rect:a,rotation:r,id:o},textContent:l,textPosition:h,parent:{page:{pageNumber:d}}}=t;if(!l||0===l.length)return null;n=t={annotationType:i.AnnotationEditorType.FREETEXT,color:Array.from(s),fontSize:e,value:l.join("\n"),position:h,pageIndex:d-1,rect:a.slice(0),rotation:r,id:o,deleted:!1}}const r=super.deserialize(t,e,s);r.#Lt=t.fontSize;r.#g=i.Util.makeHexColor(...t.color);r.#Dt=FreeTextEditor.#jt(t.value);r.annotationElementId=t.id||null;r.#Ot=n;return r}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const e=FreeTextEditor._internalPadding*this.parentScale,n=this.getRect(e,e),a=s.AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#g),r={annotationType:i.AnnotationEditorType.FREETEXT,color:a,fontSize:this.#Lt,value:this.#Gt(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};if(t)return r;if(this.annotationElementId&&!this.#$t(r))return null;r.id=this.annotationElementId;return r}#$t(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this.#Ot;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.#Lt}px * var(--scale-factor))`;i.color=this.#g;e.replaceChildren();for(const t of this.#Dt.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br"));e.append(i)}const s=FreeTextEditor._internalPadding*this.parentScale;t.updateEdited({rect:this.getRect(s,s)});return e}resetAnnotationElement(t){super.resetAnnotationElement(t);t.resetEdited()}}var o=e(61),l=e(259),h=e(419);class HighlightEditor extends s.AnnotationEditor{#Wt=null;#qt=0;#Kt;#Xt=null;#Yt=null;#Jt=null;#Qt=null;#Zt=0;#te=null;#ee=null;#gt=null;#ie=!1;#se=this.#ne.bind(this);#ae=null;#re;#oe=null;#le="";#he;#de="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _l10nPromise;static _type="highlight";static _editorType=i.AnnotationEditorType.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=HighlightEditor.prototype;return(0,i.shadow)(this,"_keyboardManager",new n.KeyboardManager([[["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||HighlightEditor._defaultColor;this.#he=t.thickness||HighlightEditor._defaultThickness;this.#re=t.opacity||HighlightEditor._defaultOpacity;this.#Kt=t.boxes||null;this.#de=t.methodOfCreation||"";this.#le=t.text||"";this._isDraggable=!1;if(t.highlightId>-1){this.#ie=!0;this.#ce(t);this.#ue()}else{this.#Wt=t.anchorNode;this.#qt=t.anchorOffset;this.#Qt=t.focusNode;this.#Zt=t.focusOffset;this.#pe();this.#ue();this.rotate(this.rotation)}}get telemetryInitialData(){return{action:"added",type:this.#ie?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#he,methodOfCreation:this.#de}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#pe(){const t=new o.Outliner(this.#Kt,.001);this.#ee=t.getOutlines();({x:this.x,y:this.y,width:this.width,height:this.height}=this.#ee.box);const e=new o.Outliner(this.#Kt,.0025,.001,"ltr"===this._uiManager.direction);this.#Jt=e.getOutlines();const{lastPoint:i}=this.#Jt.box;this.#ae=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#ce({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#ee=t;this.#Jt=t.getNewOutline(this.#he/2+1.5,.0025);if(e>=0){this.#gt=e;this.#Xt=i;this.parent.drawLayer.finalizeLine(e,t);this.#oe=this.parent.drawLayer.highlightOutline(this.#Jt)}else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#gt,t);this.parent.drawLayer.updateBox(this.#gt,HighlightEditor.#ge(this.#ee.box,(e-this.rotation+360)%360));this.parent.drawLayer.updateLine(this.#oe,this.#Jt);this.parent.drawLayer.updateBox(this.#oe,HighlightEditor.#ge(this.#Jt.box,e))}const{x:s,y:n,width:a,height:r}=t.box;switch(this.rotation){case 0:this.x=s;this.y=n;this.width=a;this.height=r;break;case 90:{const[t,e]=this.parentDimensions;this.x=n;this.y=1-s;this.width=a*e/t;this.height=r*t/e;break}case 180:this.x=1-s;this.y=1-n;this.width=a;this.height=r;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n;this.y=s;this.width=a*e/t;this.height=r*t/e;break}}const{lastPoint:o}=this.#Jt.box;this.#ae=[(o[0]-s)/a,(o[1]-n)/r]}static initialize(t,e){s.AnnotationEditor.initialize(t,e);HighlightEditor._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case i.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:HighlightEditor._defaultColor=e;break;case i.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:HighlightEditor._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#ae}updateParams(t,e){switch(t){case i.AnnotationEditorParamsType.HIGHLIGHT_COLOR:this.#Bt(e);break;case i.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS:this.#me(e)}}static get defaultPropertiesToUpdate(){return[[i.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR,HighlightEditor._defaultColor],[i.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS,HighlightEditor._defaultThickness]]}get propertiesToUpdate(){return[[i.AnnotationEditorParamsType.HIGHLIGHT_COLOR,this.color||HighlightEditor._defaultColor],[i.AnnotationEditorParamsType.HIGHLIGHT_THICKNESS,this.#he||HighlightEditor._defaultThickness],[i.AnnotationEditorParamsType.HIGHLIGHT_FREE,this.#ie]]}#Bt(t){const setColor=t=>{this.color=t;this.parent?.drawLayer.changeColor(this.#gt,t);this.#Yt?.updateColor(t)},e=this.color;this.addCommands({cmd:setColor.bind(this,t),undo:setColor.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#me(t){const e=this.#he,setThickness=t=>{this.#he=t;this.#fe(t)};this.addCommands({cmd:setThickness.bind(this,t),undo:setThickness.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();if(!t)return null;if(this._uiManager.highlightColors){this.#Yt=new l.ColorPicker({editor:this});t.addColorPicker(this.#Yt)}return t}disableEditing(){super.disableEditing();this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing();this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#be())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#be())}onceAdded(){this.parent.addUndoableEditor(this);this.div.focus()}remove(){this.#Ae();this._reportTelemetry({action:"deleted"});super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){this.#ue();this.isAttachedToDOM||this.parent.add(this)}}}setParent(t){let e=!1;if(this.parent&&!t)this.#Ae();else if(t){this.#ue(t);e=!this.parent&&this.div?.classList.contains("selectedEditor")}super.setParent(t);this.show(this._isVisible);e&&this.select()}#fe(t){if(!this.#ie)return;this.#ce({highlightOutlines:this.#ee.getNewOutline(t/2)});this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#Ae(){if(null!==this.#gt&&this.parent){this.parent.drawLayer.remove(this.#gt);this.#gt=null;this.parent.drawLayer.remove(this.#oe);this.#oe=null}}#ue(t=this.parent){if(null===this.#gt){({id:this.#gt,clipPathId:this.#Xt}=t.drawLayer.highlight(this.#ee,this.color,this.#re));this.#oe=t.drawLayer.highlightOutline(this.#Jt);this.#te&&(this.#te.style.clipPath=this.#Xt)}}static#ge({x:t,y:e,width:i,height:s},n){switch(n){case 90:return{x:1-e-s,y:t,width:s,height:i};case 180:return{x:1-t-i,y:1-e-s,width:i,height:s};case 270:return{x:e,y:1-t-i,width:s,height:i}}return{x:t,y:e,width:i,height:s}}rotate(t){const{drawLayer:e}=this.parent;let i;if(this.#ie){t=(t-this.rotation+360)%360;i=HighlightEditor.#ge(this.#ee.box,t)}else i=HighlightEditor.#ge(this,t);e.rotate(this.#gt,t);e.rotate(this.#oe,t);e.updateBox(this.#gt,i);e.updateBox(this.#oe,HighlightEditor.#ge(this.#Jt.box,t))}render(){if(this.div)return this.div;const t=super.render();if(this.#le){t.setAttribute("aria-label",this.#le);t.setAttribute("role","mark")}this.#ie?t.classList.add("free"):this.div.addEventListener("keydown",this.#se);const e=this.#te=document.createElement("div");t.append(e);e.setAttribute("aria-hidden","true");e.className="internal";e.style.clipPath=this.#Xt;const[i,s]=this.parentDimensions;this.setDims(this.width*i,this.height*s);(0,n.bindEvents)(this,this.#te,["pointerover","pointerleave"]);this.enableEditing();return t}pointerover(){this.parent.drawLayer.addClass(this.#oe,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#oe,"hovered")}#ne(t){HighlightEditor._keyboardManager.exec(this,t)}_moveCaret(t){this.parent.unselect(this);switch(t){case 0:case 2:this.#ve(!0);break;case 1:case 3:this.#ve(!1)}}#ve(t){if(!this.#Wt)return;const e=window.getSelection();t?e.setPosition(this.#Wt,this.#qt):e.setPosition(this.#Qt,this.#Zt)}select(){super.select();if(this.#oe){this.parent?.drawLayer.removeClass(this.#oe,"hovered");this.parent?.drawLayer.addClass(this.#oe,"selected")}}unselect(){super.unselect();if(this.#oe){this.parent?.drawLayer.removeClass(this.#oe,"selected");this.#ie||this.#ve(!1)}}get _mustFixPosition(){return!this.#ie}show(t=this._isVisible){super.show(t);if(this.parent){this.parent.drawLayer.show(this.#gt,t);this.parent.drawLayer.show(this.#oe,t)}}#be(){return this.#ie?this.rotation:0}#ye(){if(this.#ie)return null;const[t,e]=this.pageDimensions,i=this.#Kt,s=new Array(8*i.length);let n=0;for(const{x:a,y:r,width:o,height:l}of i){const i=a*t,h=(1-r-l)*e;s[n]=s[n+4]=i;s[n+1]=s[n+3]=h;s[n+2]=s[n+6]=i+o*t;s[n+5]=s[n+7]=h+l*e;n+=8}return s}#Ee(t){return this.#ee.serialize(t,this.#be())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:a,y:r,width:l,height:d}=i.getBoundingClientRect(),pointerMove=e=>{this.#we(t,e)},c={capture:!0,passive:!1},pointerDown=t=>{t.preventDefault();t.stopPropagation()},pointerUpCallback=e=>{i.removeEventListener("pointermove",pointerMove);window.removeEventListener("blur",pointerUpCallback);window.removeEventListener("pointerup",pointerUpCallback);window.removeEventListener("pointerdown",pointerDown,c);window.removeEventListener("contextmenu",h.noContextMenu);this.#_e(t,e)};window.addEventListener("blur",pointerUpCallback);window.addEventListener("pointerup",pointerUpCallback);window.addEventListener("pointerdown",pointerDown,c);window.addEventListener("contextmenu",h.noContextMenu);i.addEventListener("pointermove",pointerMove);this._freeHighlight=new o.FreeOutliner({x:s,y:n},[a,r,l,d],t.scale,this._defaultThickness/2,e,.001);({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0))}static#we(t,e){this._freeHighlight.add(e)&&t.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static#_e(t,e){this._freeHighlight.isEmpty()?t.drawLayer.removeFreeHighlight(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 deserialize(t,e,s){const n=super.deserialize(t,e,s),{rect:[a,r,o,l],color:h,quadPoints:d}=t;n.color=i.Util.makeHexColor(...h);n.#re=t.opacity;const[c,u]=n.pageDimensions;n.width=(o-a)/c;n.height=(l-r)/u;const p=n.#Kt=[];for(let t=0;t{this.thickness=t;this.#Ue()},e=this.thickness;this.addCommands({cmd:setThickness.bind(this,t),undo:setThickness.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#Bt(t){const setColor=t=>{this.color=t;this.#ze()},e=this.color;this.addCommands({cmd:setColor.bind(this,t),undo:setColor.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#He(t){const setOpacity=t=>{this.opacity=t;this.#ze()};t/=100;const e=this.opacity;this.addCommands({cmd:setOpacity.bind(this,t),undo:setOpacity.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:i.AnnotationEditorParamsType.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){if(!this.canvas){this.#Ve();this.#je()}if(!this.isAttachedToDOM){this.parent.add(this);this.#Ge()}this.#Ue()}}}remove(){if(null!==this.canvas){this.isEmpty()||this.commit();this.canvas.width=this.canvas.height=0;this.canvas.remove();this.canvas=null;if(this.#Re){clearTimeout(this.#Re);this.#Re=null}this.#Le.disconnect();this.#Le=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)}enableEditMode(){if(!this.#ke&&null!==this.canvas){super.enableEditMode();this._isDraggable=!1;this.canvas.addEventListener("pointerdown",this.#Pe)}}disableEditMode(){if(this.isInEditMode()&&null!==this.canvas){super.disableEditMode();this._isDraggable=!this.isEmpty();this.div.classList.remove("editing");this.canvas.removeEventListener("pointerdown",this.#Pe)}}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}#$e(){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]}}#We(){const{ctx:t,color:e,opacity:i,thickness:s,parentScale:a,scaleFactor:r}=this;t.lineWidth=s*a/r;t.lineCap="round";t.lineJoin="round";t.miterLimit=10;t.strokeStyle=`${e}${(0,n.opacityToHex)(i)}`}#qe(t,e){this.canvas.addEventListener("contextmenu",h.noContextMenu);this.canvas.addEventListener("pointerleave",this.#Ce);this.canvas.addEventListener("pointermove",this.#Se);this.canvas.addEventListener("pointerup",this.#Me);this.canvas.removeEventListener("pointerdown",this.#Pe);this.isEditing=!0;if(!this.#Ie){this.#Ie=!0;this.#Ge();this.thickness||=InkEditor._defaultThickness;this.color||=InkEditor._defaultColor||s.AnnotationEditor._defaultLineColor;this.opacity??=InkEditor._defaultOpacity}this.currentPath.push([t,e]);this.#De=!1;this.#We();this.#Be=()=>{this.#Ke();this.#Be&&window.requestAnimationFrame(this.#Be)};window.requestAnimationFrame(this.#Be)}#Xe(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.#Fe;n.push([t,e]);this.#De=!0;if(n.length<=2){a.moveTo(...n[0]);a.lineTo(t,e)}else{if(3===n.length){this.#Fe=a=new Path2D;a.moveTo(...n[0])}this.#Ye(a,...n.at(-3),...n.at(-2),t,e)}}#Je(){if(0===this.currentPath.length)return;const t=this.currentPath.at(-1);this.#Fe.lineTo(...t)}#Qe(t,e){this.#Be=null;t=Math.min(Math.max(t,0),this.canvas.width);e=Math.min(Math.max(e,0),this.canvas.height);this.#Xe(t,e);this.#Je();let i;if(1!==this.currentPath.length)i=this.#Ze();else{const s=[t,e];i=[[s,s.slice(),s.slice(),s]]}const s=this.#Fe,n=this.currentPath;this.currentPath=[];this.#Fe=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();if(0===this.paths.length)this.remove();else{if(!this.canvas){this.#Ve();this.#je()}this.#Ue()}},mustExec:!0})}#Ke(){if(!this.#De)return;this.#De=!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 t of this.bezierPath2D)n.stroke(t);n.stroke(this.#Fe);n.restore()}#Ye(t,e,i,s,n,a,r){const o=(e+s)/2,l=(i+n)/2,h=(s+a)/2,d=(n+r)/2;t.bezierCurveTo(o+2*(s-o)/3,l+2*(n-l)/3,h+2*(s-h)/3,d+2*(n-d)/3,h,d)}#Ze(){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{this.#Re=null;this.canvas.removeEventListener("contextmenu",h.noContextMenu)}),10);this.#Qe(t.offsetX,t.offsetY);this.addToAnnotationStorage();this.setInBackground()}#Ve(){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")}#je(){this.#Le=new ResizeObserver((t=>{const e=t[0].contentRect;e.width&&e.height&&this.setDimensions(e.width,e.height)}));this.#Le.observe(this.div)}get isResizable(){return!this.isEmpty()&&this.#ke}render(){if(this.div)return this.div;let t,e;if(this.width){t=this.x;e=this.y}super.render();this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,s,n,a]=this.#$e();this.setAt(i,s,0,0);this.setDims(n,a);this.#Ve();if(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.#Ie=!0;this.#Ge();this.setDims(this.width*i,this.height*s);this.#ze();this.div.classList.add("disabled")}else{this.div.classList.add("editing");this.enableEditMode()}this.#je();return this.div}#Ge(){if(!this.#Ie)return;const[t,e]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*t);this.canvas.height=Math.ceil(this.height*e);this.#ti()}setDimensions(t,e){const i=Math.round(t),s=Math.round(e);if(this.#Oe===i&&this.#Ne===s)return;this.#Oe=i;this.#Ne=s;this.canvas.style.visibility="hidden";const[n,a]=this.parentDimensions;this.width=t/n;this.height=e/a;this.fixAndSetPosition();this.#ke&&this.#ii(t,e);this.#Ge();this.#ze();this.canvas.style.visibility="visible";this.fixDims()}#ii(t,e){const i=this.#si(),s=(t-i)/this.#Te,n=(e-i)/this.#xe;this.scaleFactor=Math.min(s,n)}#ti(){const t=this.#si()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+t,this.translationY*this.scaleFactor+t)}static#ni(t){const e=new Path2D;for(let i=0,s=t.length;i`image/${t}`)))}static get supportedTypesStr(){return(0,i.shadow)(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(i.AnnotationEditorType.STAMP,{bitmapFile:t.getAsFile()})}#vi(t,e=!1){if(t){this.#hi=t.bitmap;if(!e){this.#di=t.id;this.#bi=t.isSvg}t.file&&(this.#gi=t.file.name);this.#Ve()}else this.remove()}#yi(){this.#ci=null;this._uiManager.enableWaiting(!1);this.#mi&&this.div.focus()}#Ei(){if(this.#di){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(this.#di).then((t=>this.#vi(t,!0))).finally((()=>this.#yi()));return}if(this.#ui){const t=this.#ui;this.#ui=null;this._uiManager.enableWaiting(!0);this.#ci=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#vi(t))).finally((()=>this.#yi()));return}if(this.#pi){const t=this.#pi;this.#pi=null;this._uiManager.enableWaiting(!0);this.#ci=this._uiManager.imageManager.getFromFile(t).then((t=>this.#vi(t))).finally((()=>this.#yi()));return}const t=document.createElement("input");t.type="file";t.accept=StampEditor.supportedTypesStr;this.#ci=new Promise((e=>{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.#vi(e)}else this.remove();e()}));t.addEventListener("cancel",(()=>{this.remove();e()}))})).finally((()=>this.#yi()));t.click()}remove(){if(this.#di){this.#hi=null;this._uiManager.imageManager.deleteId(this.#di);this.#mi?.remove();this.#mi=null;this.#Le?.disconnect();this.#Le=null;if(this.#fi){clearTimeout(this.#fi);this.#fi=null}}super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){this.#di&&null===this.#mi&&this.#Ei();this.isAttachedToDOM||this.parent.add(this)}}else this.#di&&this.#Ei()}onceAdded(){this._isDraggable=!0;this.div.focus()}isEmpty(){return!(this.#ci||this.#hi||this.#ui||this.#pi||this.#di)}get isResizable(){return!0}render(){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.addAltTextButton();this.#hi?this.#Ve():this.#Ei();if(this.width){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this.div}#Ve(){const{div:t}=this;let{width:e,height:i}=this.#hi;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.#mi=document.createElement("canvas");t.append(l);t.hidden=!1;this.#wi(e,i);this.#je();if(!this.#Ai){this.parent.addUndoableEditor(this);this.#Ai=!0}this._reportTelemetry({action:"inserted_image"});this.#gi&&l.setAttribute("aria-label",this.#gi)}#_i(t,e){const[i,s]=this.parentDimensions;this.width=t/i;this.height=e/s;this.setDims(t,e);this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;null!==this.#fi&&clearTimeout(this.#fi);this.#fi=setTimeout((()=>{this.#fi=null;this.#wi(t,e)}),200)}#xi(t,e){const{width:i,height:s}=this.#hi;let n=i,a=s,r=this.#hi;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}#wi(t,e){t=Math.ceil(t);e=Math.ceil(e);const i=this.#mi;if(!i||i.width===t&&i.height===e)return;i.width=t;i.height=e;const s=this.#bi?this.#hi:this.#xi(t,e);if(this._uiManager.hasMLManager&&!this.hasAltText()){const i=new OffscreenCanvas(t,e);i.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,e);i.convertToBlob().then((t=>{const e=new FileReader;e.onload=()=>{const t=e.result;this._uiManager.mlGuess({service:"image-to-text",request:{imageData:t}}).then((t=>{const e=t?.output||"";this.parent&&e&&!this.hasAltText()&&(this.altTextData={altText:e,decorative:!1})}))};e.readAsDataURL(t)}))}const n=i.getContext("2d");n.filter=this._uiManager.hcmFilter;n.drawImage(s,0,0,s.width,s.height,0,0,t,e)}getImageForAltText(){return this.#mi}#Ti(t){if(t){if(this.#bi){const t=this._uiManager.imageManager.getSvgUrl(this.#di);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#hi);t.getContext("2d").drawImage(this.#hi,0,0);return t.toDataURL()}if(this.#bi){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*h.PixelsPerInch.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*h.PixelsPerInch.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);n.getContext("2d").drawImage(this.#hi,0,0,this.#hi.width,this.#hi.height,0,0,i,s);return n.transferToImageBitmap()}return structuredClone(this.#hi)}#je(){this.#Le=new ResizeObserver((t=>{const e=t[0].contentRect;e.width&&e.height&&this.#_i(e.width,e.height)}));this.#Le.observe(this.div)}static deserialize(t,e,i){if(t instanceof a.StampAnnotationElement)return null;const s=super.deserialize(t,e,i),{rect:n,bitmapUrl:r,bitmapId:o,isSvg:l,accessibilityData:h}=t;o&&i.imageManager.isValidId(o)?s.#di=o:s.#ui=r;s.#bi=l;const[d,c]=s.pageDimensions;s.width=(n[2]-n[0])/d;s.height=(n[3]-n[1])/c;h&&(s.altTextData=h);return s}serialize(t=!1,e=null){if(this.isEmpty())return null;const s={annotationType:i.AnnotationEditorType.STAMP,bitmapId:this.#di,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#bi,structTreeParentId:this._structTreeParentId};if(t){s.bitmapUrl=this.#Ti(!0);s.accessibilityData=this.altTextData;return s}const{decorative:n,altText:a}=this.altTextData;!n&&a&&(s.accessibilityData={type:"Figure",alt:a});if(null===e)return s;e.stamps||=new Map;const r=this.#bi?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(e.stamps.has(this.#di)){if(this.#bi){const t=e.stamps.get(this.#di);if(r>t.area){t.area=r;t.serialized.bitmap.close();t.serialized.bitmap=this.#Ti(!1)}}}else{e.stamps.set(this.#di,{area:r,serialized:s});s.bitmap=this.#Ti(!1)}return s}}class AnnotationEditorLayer{#I;#Si=!1;#Ci=null;#Mi=null;#Pi=null;#Ri=null;#Fi=null;#ki=new Map;#Di=!1;#Ii=!1;#Li=!1;#Oi=null;#Ni;static _initialized=!1;static#Bi=new Map([FreeTextEditor,InkEditor,StampEditor,HighlightEditor].map((t=>[t._editorType,t])));constructor({uiManager:t,pageIndex:e,div:i,accessibilityManager:s,annotationLayer:n,drawLayer:a,textLayer:r,viewport:o,l10n:l}){const h=[...AnnotationEditorLayer.#Bi.values()];if(!AnnotationEditorLayer._initialized){AnnotationEditorLayer._initialized=!0;for(const e of h)e.initialize(l,t)}t.registerEditorTypes(h);this.#Ni=t;this.pageIndex=e;this.div=i;this.#I=s;this.#Ci=n;this.viewport=o;this.#Oi=r;this.drawLayer=a;this.#Ni.addLayer(this)}get isEmpty(){return 0===this.#ki.size}get isInvisible(){return this.isEmpty&&this.#Ni.getMode()===i.AnnotationEditorType.NONE}updateToolbar(t){this.#Ni.updateToolbar(t)}updateMode(t=this.#Ni.getMode()){this.#Hi();switch(t){case i.AnnotationEditorType.NONE:this.disableTextSelection();this.togglePointerEvents(!1);this.toggleAnnotationLayerPointerEvents(!0);this.disableClick();return;case i.AnnotationEditorType.INK:this.addInkEditorIfNeeded(!1);this.disableTextSelection();this.togglePointerEvents(!0);this.disableClick();break;case i.AnnotationEditorType.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 AnnotationEditorLayer.#Bi.values())e.toggle(`${i._type}Editing`,t===i._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#Oi?.div}addInkEditorIfNeeded(t){if(this.#Ni.getMode()!==i.AnnotationEditorType.INK)return;if(!t)for(const t of this.#ki.values())if(t.isEmpty()){t.setInBackground();return}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){this.#Ni.setEditingState(t)}addCommands(t){this.#Ni.addCommands(t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#Ci?.div.classList.toggle("disabled",!t)}enable(){this.div.tabIndex=0;this.togglePointerEvents(!0);const t=new Set;for(const e of this.#ki.values()){e.enableEditing();e.show(!0);if(e.annotationElementId){this.#Ni.removeChangedExistingAnnotation(e);t.add(e.annotationElementId)}}if(!this.#Ci)return;const e=this.#Ci.getEditableAnnotations();for(const i of e){i.hide();if(this.#Ni.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=this.deserialize(i);if(e){this.addOrRebuild(e);e.enableEditing()}}}disable(){this.#Li=!0;this.div.tabIndex=-1;this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const i of this.#ki.values()){i.disableEditing();if(i.annotationElementId)if(null===i.serialize()){e.set(i.annotationElementId,i);this.getEditableAnnotation(i.annotationElementId)?.show();i.remove()}else t.set(i.annotationElementId,i)}if(this.#Ci){const i=this.#Ci.getEditableAnnotations();for(const s of i){const{id:i}=s.data;if(this.#Ni.isDeletedAnnotationElement(i))continue;let n=e.get(i);if(n){n.resetAnnotationElement(s);n.show(!1);s.show()}else{n=t.get(i);if(n){this.#Ni.addChangedExistingAnnotation(n);n.renderAnnotationElement(s);n.show(!1)}s.show()}}}this.#Hi();this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const t of AnnotationEditorLayer.#Bi.values())i.remove(`${t._type}Editing`);this.disableTextSelection();this.toggleAnnotationLayerPointerEvents(!0);this.#Li=!1}getEditableAnnotation(t){return this.#Ci?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#Ni.getActive()!==t&&this.#Ni.setActiveEditor(t)}enableTextSelection(){this.div.tabIndex=-1;if(this.#Oi?.div&&!this.#Ri){this.#Ri=this.#Ui.bind(this);this.#Oi.div.addEventListener("pointerdown",this.#Ri);this.#Oi.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0;if(this.#Oi?.div&&this.#Ri){this.#Oi.div.removeEventListener("pointerdown",this.#Ri);this.#Ri=null;this.#Oi.div.classList.remove("highlighting")}}#Ui(t){this.#Ni.unselectAll();if(t.target===this.#Oi.div){const{isMac:e}=i.FeatureTest.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#Ni.showAllEditors("highlight",!0,!0);this.#Oi.div.classList.add("free");HighlightEditor.startHighlighting(this,"ltr"===this.#Ni.direction,t);this.#Oi.div.addEventListener("pointerup",(()=>{this.#Oi.div.classList.remove("free")}),{once:!0});t.preventDefault()}}enableClick(){if(!this.#Pi){this.#Pi=this.pointerdown.bind(this);this.#Mi=this.pointerup.bind(this);this.div.addEventListener("pointerdown",this.#Pi);this.div.addEventListener("pointerup",this.#Mi)}}disableClick(){if(this.#Pi){this.div.removeEventListener("pointerdown",this.#Pi);this.div.removeEventListener("pointerup",this.#Mi);this.#Pi=null;this.#Mi=null}}attach(t){this.#ki.set(t.id,t);const{annotationElementId:e}=t;e&&this.#Ni.isDeletedAnnotationElement(e)&&this.#Ni.removeDeletedAnnotationElement(t)}detach(t){this.#ki.delete(t.id);this.#I?.removePointerInTextLayer(t.contentDiv);!this.#Li&&t.annotationElementId&&this.#Ni.addDeletedAnnotationElement(t)}remove(t){this.detach(t);this.#Ni.removeEditor(t);t.div.remove();t.isAttachedToDOM=!1;this.#Ii||this.addInkEditorIfNeeded(!1)}changeParent(t){if(t.parent!==this){if(t.parent&&t.annotationElementId){this.#Ni.addDeletedAnnotationElement(t.annotationElementId);s.AnnotationEditor.deleteAnnotationElement(t);t.annotationElementId=null}this.attach(t);t.parent?.detach(t);t.setParent(this);if(t.div&&t.isAttachedToDOM){t.div.remove();this.div.append(t.div)}}}add(t){if(t.parent!==this||!t.isAttachedToDOM){this.changeParent(t);this.#Ni.addEditor(t);this.attach(t);if(!t.isAttachedToDOM){const e=t.render();this.div.append(e);t.isAttachedToDOM=!0}t.fixAndSetPosition();t.onceAdded();this.#Ni.addToAnnotationStorage(t);t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;if(t.div.contains(e)&&!this.#Fi){t._focusEventsAllowed=!1;this.#Fi=setTimeout((()=>{this.#Fi=null;if(t.div.contains(document.activeElement))t._focusEventsAllowed=!0;else{t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0});e.focus()}}),0)}t._structTreeParentId=this.#I?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){if(t.needsToBeRebuilt()){t.parent||=this;t.rebuild();t.show()}else this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#Ni.getId()}get#zi(){return AnnotationEditorLayer.#Bi.get(this.#Ni.getMode())}#Vi(t){const e=this.#zi;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#zi?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#Ni.updateToolbar(t);this.#Ni.updateMode(t);const{offsetX:i,offsetY:s}=this.#ji(),n=this.getNextId(),a=this.#Vi({parent:this,id:n,x:i,y:s,uiManager:this.#Ni,isCentered:!0,...e});a&&this.add(a)}deserialize(t){return AnnotationEditorLayer.#Bi.get(t.annotationType??t.annotationEditorType)?.deserialize(t,this,this.#Ni)||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#Vi({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#Ni,isCentered:e,...i});n&&this.add(n);return n}#ji(){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.#ji(),!0)}setSelected(t){this.#Ni.setSelected(t)}toggleSelected(t){this.#Ni.toggleSelected(t)}isSelected(t){return this.#Ni.isSelected(t)}unselect(t){this.#Ni.unselect(t)}pointerup(t){const{isMac:e}=i.FeatureTest.platform;if(!(0!==t.button||t.ctrlKey&&e)&&t.target===this.div&&this.#Di){this.#Di=!1;this.#Si?this.#Ni.getMode()!==i.AnnotationEditorType.STAMP?this.createAndAddNewEditor(t,!1):this.#Ni.unselectAll():this.#Si=!0}}pointerdown(t){this.#Ni.getMode()===i.AnnotationEditorType.HIGHLIGHT&&this.enableTextSelection();if(this.#Di){this.#Di=!1;return}const{isMac:e}=i.FeatureTest.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;this.#Di=!0;const s=this.#Ni.getActive();this.#Si=!s||s.isEmpty()}findNewParent(t,e,i){const s=this.#Ni.findParent(e,i);if(null===s||s===this)return!1;s.changeParent(t);return!0}destroy(){if(this.#Ni.getActive()?.parent===this){this.#Ni.commitOrRemove();this.#Ni.setActiveEditor(null)}if(this.#Fi){clearTimeout(this.#Fi);this.#Fi=null}for(const t of this.#ki.values()){this.#I?.removePointerInTextLayer(t.contentDiv);t.setParent(null);t.isAttachedToDOM=!1;t.div.remove()}this.div=null;this.#ki.clear();this.#Ni.removeLayer(this)}#Hi(){this.#Ii=!0;for(const t of this.#ki.values())t.isEmpty()&&t.remove();this.#Ii=!1}render({viewport:t}){this.viewport=t;(0,h.setLayerDimensions)(this.div,t);for(const t of this.#Ni.getEditors(this.pageIndex)){this.add(t);t.rebuild()}this.updateMode()}update({viewport:t}){this.#Ni.commitOrRemove();this.#Hi();const e=this.viewport.rotation,i=t.rotation;this.viewport=t;(0,h.setLayerDimensions)(this.div,{rotation:i});if(e!==i)for(const t of this.#ki.values())t.rotate(i);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#Ni.viewParameters.realScale}}},259:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{ColorPicker:()=>ColorPicker});var i=e(292),s=e(830),n=e(419);class ColorPicker{#r=this.#o.bind(this);#Gi=this.#$i.bind(this);#Wi=null;#qi=null;#Ki;#Xi=null;#Yi=!1;#Ji=!1;#Qi=null;#Zi;#Ni=null;#ts;static get _keyboardManager(){return(0,i.shadow)(this,"_keyboardManager",new s.KeyboardManager([[["Escape","mac+Escape"],ColorPicker.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ColorPicker.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ColorPicker.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ColorPicker.prototype._moveToPrevious],[["Home","mac+Home"],ColorPicker.prototype._moveToBeginning],[["End","mac+End"],ColorPicker.prototype._moveToEnd]]))}constructor({editor:t=null,uiManager:e=null}){if(t){this.#Ji=!1;this.#ts=i.AnnotationEditorParamsType.HIGHLIGHT_COLOR;this.#Qi=t}else{this.#Ji=!0;this.#ts=i.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR}this.#Ni=t?._uiManager||e;this.#Zi=this.#Ni._eventBus;this.#Ki=t?.color||this.#Ni?.highlightColors.values().next().value||"#FFFF98"}renderButton(){const t=this.#Wi=document.createElement("button");t.className="colorPicker";t.tabIndex="0";t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button");t.setAttribute("aria-haspopup",!0);t.addEventListener("click",this.#es.bind(this));t.addEventListener("keydown",this.#r);const e=this.#qi=document.createElement("span");e.className="swatch";e.setAttribute("aria-hidden",!0);e.style.backgroundColor=this.#Ki;t.append(e);return t}renderMainDropdown(){const t=this.#Xi=this.#is();t.setAttribute("aria-orientation","horizontal");t.setAttribute("aria-labelledby","highlightColorPickerLabel");return t}#is(){const t=document.createElement("div");t.addEventListener("contextmenu",n.noContextMenu);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[e,i]of this.#Ni.highlightColors){const s=document.createElement("button");s.tabIndex="0";s.role="option";s.setAttribute("data-color",i);s.title=e;s.setAttribute("data-l10n-id",`pdfjs-editor-colorpicker-${e}`);const n=document.createElement("span");s.append(n);n.className="swatch";n.style.backgroundColor=i;s.setAttribute("aria-selected",i===this.#Ki);s.addEventListener("click",this.#ss.bind(this,i));t.append(s)}t.addEventListener("keydown",this.#r);return t}#ss(t,e){e.stopPropagation();this.#Zi.dispatch("switchannotationeditorparams",{source:this,type:this.#ts,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Wi){this.#es(t);return}const e=t.target.getAttribute("data-color");e&&this.#ss(e,t)}_moveToNext(t){this.#ns?t.target!==this.#Wi?t.target.nextSibling?.focus():this.#Xi.firstChild?.focus():this.#es(t)}_moveToPrevious(t){if(t.target!==this.#Xi?.firstChild&&t.target!==this.#Wi){this.#ns||this.#es(t);t.target.previousSibling?.focus()}else this.#ns&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#ns?this.#Xi.firstChild?.focus():this.#es(t)}_moveToEnd(t){this.#ns?this.#Xi.lastChild?.focus():this.#es(t)}#o(t){ColorPicker._keyboardManager.exec(this,t)}#es(t){if(this.#ns){this.hideDropdown();return}this.#Yi=0===t.detail;window.addEventListener("pointerdown",this.#Gi);if(this.#Xi){this.#Xi.classList.remove("hidden");return}const e=this.#Xi=this.#is();this.#Wi.append(e)}#$i(t){this.#Xi?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Xi?.classList.add("hidden");window.removeEventListener("pointerdown",this.#Gi)}get#ns(){return this.#Xi&&!this.#Xi.classList.contains("hidden")}_hideDropdownFromKeyboard(){if(!this.#Ji)if(this.#ns){this.hideDropdown();this.#Wi.focus({preventScroll:!0,focusVisible:this.#Yi})}else this.#Qi?.unselect()}updateColor(t){this.#qi&&(this.#qi.style.backgroundColor=t);if(!this.#Xi)return;const e=this.#Ni.highlightColors.values();for(const i of this.#Xi.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Wi?.remove();this.#Wi=null;this.#qi=null;this.#Xi?.remove();this.#Xi=null}}},310:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{AnnotationEditor:()=>AnnotationEditor});var i=e(830),s=e(292),n=e(419);class AltText{#as="";#rs=!1;#os=null;#ls=null;#hs=null;#ds=!1;#Qi=null;static _l10nPromise=null;constructor(t){this.#Qi=t}static initialize(t){AltText._l10nPromise||=t}async render(){const t=this.#os=document.createElement("button");t.className="altText";const e=await AltText._l10nPromise.get("pdfjs-editor-alt-text-button-label");t.textContent=e;t.setAttribute("aria-label",e);t.tabIndex="0";t.addEventListener("contextmenu",n.noContextMenu);t.addEventListener("pointerdown",(t=>t.stopPropagation()));const onClick=t=>{t.preventDefault();this.#Qi._uiManager.editAltText(this.#Qi)};t.addEventListener("click",onClick,{capture:!0});t.addEventListener("keydown",(e=>{if(e.target===t&&"Enter"===e.key){this.#ds=!0;onClick(e)}}));await this.#cs();return t}finish(){if(this.#os){this.#os.focus({focusVisible:this.#ds});this.#ds=!1}}isEmpty(){return!this.#as&&!this.#rs}get data(){return{altText:this.#as,decorative:this.#rs}}set data({altText:t,decorative:e}){if(this.#as!==t||this.#rs!==e){this.#as=t;this.#rs=e;this.#cs()}}toggle(t=!1){if(this.#os){if(!t&&this.#hs){clearTimeout(this.#hs);this.#hs=null}this.#os.disabled=!t}}destroy(){this.#os?.remove();this.#os=null;this.#ls=null}async#cs(){const t=this.#os;if(!t)return;if(!this.#as&&!this.#rs){t.classList.remove("done");this.#ls?.remove();return}t.classList.add("done");AltText._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then((e=>{t.setAttribute("aria-label",e)}));let e=this.#ls;if(!e){this.#ls=e=document.createElement("span");e.className="tooltip";e.setAttribute("role","tooltip");const i=e.id=`alt-text-tooltip-${this.#Qi.id}`;t.setAttribute("aria-describedby",i);const s=100;t.addEventListener("mouseenter",(()=>{this.#hs=setTimeout((()=>{this.#hs=null;this.#ls.classList.add("show");this.#Qi._reportTelemetry({action:"alt_text_tooltip"})}),s)}));t.addEventListener("mouseleave",(()=>{if(this.#hs){clearTimeout(this.#hs);this.#hs=null}this.#ls?.classList.remove("show")}))}e.innerText=this.#rs?await AltText._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#as;e.parentNode||t.append(e);const i=this.#Qi.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}var a=e(362);class AnnotationEditor{#us=null;#as=null;#ps=!1;#gs=!1;#ms=null;#fs=null;#bs=this.focusin.bind(this);#As=this.focusout.bind(this);#vs=null;#ys="";#Es=!1;#ws=null;#_s=!1;#xs=!1;#Ts=!1;#Ss=null;#Cs=0;#Ms=0;#Ps=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#Rs=!1;#Fs=AnnotationEditor._zIndex++;static _borderLineWidth=-1;static _colorManager=new i.ColorManager;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=AnnotationEditor.prototype._resizeWithKeyboard,e=i.AnnotationEditorUIManager.TRANSLATE_SMALL,n=i.AnnotationEditorUIManager.TRANSLATE_BIG;return(0,s.shadow)(this,"_resizerKeyboardManager",new i.KeyboardManager([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,n]}],[["Escape","mac+Escape"],AnnotationEditor.prototype._stopResizingWithKeyboard]]))}constructor(t){this.constructor===AnnotationEditor&&(0,s.unreachable)("Cannot initialize AnnotationEditor.");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:n,pageX:a,pageY:r}}=this.parent.viewport;this.rotation=e;this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360;this.pageDimensions=[i,n];this.pageTranslation=[a,r];const[o,l]=this.parentDimensions;this.x=t.x/o;this.y=t.y/l;this.isAttachedToDOM=!1;this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return(0,s.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new FakeEditor({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,i){AnnotationEditor._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map((e=>[e,t.get(e.replaceAll(/([A-Z])/g,(t=>`-${t.toLowerCase()}`)))])));if(i?.strings)for(const e of i.strings)AnnotationEditor._l10nPromise.set(e,t.get(e));if(-1!==AnnotationEditor._borderLineWidth)return;const s=getComputedStyle(document.documentElement);AnnotationEditor._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){(0,s.unreachable)("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#Rs}set _isDraggable(t){this.#Rs=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}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Fs}setParent(t){if(null!==t){this.pageIndex=t.pageIndex;this.pageDimensions=t.pageDimensions}else this.#ks();this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#Es?this.#Es=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;if(!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()}#Ds([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s);this.x+=i/t;this.y+=s/e;this.fixAndSetPosition()}translate(t,e){this.#Ds(this.parentDimensions,t,e)}translateInPage(t,e){this.#ws||=[this.x,this.y];this.#Ds(this.pageDimensions,t,e);this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#ws||=[this.x,this.y];const[i,s]=this.parentDimensions;this.x+=t/i;this.y+=e/s;if(this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();if(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.#ws&&(this.#ws[0]!==this.x||this.#ws[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=AnnotationEditor,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(t=this.rotation){const[e,i]=this.pageDimensions;let{x:s,y:n,width:a,height:r}=this;a*=e;r*=i;s*=e;n*=i;if(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#Is(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 AnnotationEditor.#Is(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return AnnotationEditor.#Is(t,e,360-this.parentRotation)}#Ls(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,n=e*t,a=i*t;return s.FeatureTest.isCSSRoundSupported?[Math.round(n),Math.round(a)]:[n,a]}setDims(t,e){const[i,s]=this.parentDimensions;this.div.style.width=`${(100*t/i).toFixed(2)}%`;this.#gs||(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.#gs&&e.endsWith("%");if(s&&n)return;const[a,r]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/a).toFixed(2)}%`);this.#gs||n||(t.height=`${(100*parseFloat(e)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Os(){if(this.#ms)return;this.#ms=document.createElement("div");this.#ms.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"];for(const e of t){const t=document.createElement("div");this.#ms.append(t);t.classList.add("resizer",e);t.setAttribute("data-resizer-name",e);t.addEventListener("pointerdown",this.#Ns.bind(this,e));t.addEventListener("contextmenu",n.noContextMenu);t.tabIndex=-1}this.div.prepend(this.#ms)}#Ns(t,e){e.preventDefault();const{isMac:i}=s.FeatureTest.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#as?.toggle(!1);const a=this.#Bs.bind(this,t),r=this._isDraggable;this._isDraggable=!1;const o={passive:!0,capture:!0};this.parent.togglePointerEvents(!1);window.addEventListener("pointermove",a,o);window.addEventListener("contextmenu",n.noContextMenu);const l=this.x,h=this.y,d=this.width,c=this.height,u=this.parent.div.style.cursor,p=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const pointerUpCallback=()=>{this.parent.togglePointerEvents(!0);this.#as?.toggle(!0);this._isDraggable=r;window.removeEventListener("pointerup",pointerUpCallback);window.removeEventListener("blur",pointerUpCallback);window.removeEventListener("pointermove",a,o);window.removeEventListener("contextmenu",n.noContextMenu);this.parent.div.style.cursor=u;this.div.style.cursor=p;this.#Hs(l,h,d,c)};window.addEventListener("pointerup",pointerUpCallback);window.addEventListener("blur",pointerUpCallback)}#Hs(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})}#Bs(t,e){const[i,s]=this.parentDimensions,n=this.x,a=this.y,r=this.width,o=this.height,l=AnnotationEditor.MIN_SIZE/i,h=AnnotationEditor.MIN_SIZE/s,round=t=>Math.round(1e4*t)/1e4,d=this.#Ls(this.rotation),transf=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],c=this.#Ls(360-this.rotation);let u,p,g=!1,m=!1;switch(t){case"topLeft":g=!0;u=(t,e)=>[0,0];p=(t,e)=>[t,e];break;case"topMiddle":u=(t,e)=>[t/2,0];p=(t,e)=>[t/2,e];break;case"topRight":g=!0;u=(t,e)=>[t,0];p=(t,e)=>[0,e];break;case"middleRight":m=!0;u=(t,e)=>[t,e/2];p=(t,e)=>[0,e/2];break;case"bottomRight":g=!0;u=(t,e)=>[t,e];p=(t,e)=>[0,0];break;case"bottomMiddle":u=(t,e)=>[t/2,e];p=(t,e)=>[t/2,0];break;case"bottomLeft":g=!0;u=(t,e)=>[0,e];p=(t,e)=>[t,0];break;case"middleLeft":m=!0;u=(t,e)=>[0,e/2];p=(t,e)=>[t,e/2]}const f=u(r,o),b=p(r,o);let A=transf(...b);const v=round(n+A[0]),y=round(a+A[1]);let E=1,w=1,[_,x]=this.screenToPageTranslation(e.movementX,e.movementY);[_,x]=(T=_/i,S=x/s,[c[0]*T+c[2]*S,c[1]*T+c[3]*S]);var T,S;if(g){const t=Math.hypot(r,o);E=w=Math.max(Math.min(Math.hypot(b[0]-f[0]-_,b[1]-f[1]-x)/t,1/r,1/o),l/r,h/o)}else m?E=Math.max(l,Math.min(1,Math.abs(b[0]-f[0]-_)))/r:w=Math.max(h,Math.min(1,Math.abs(b[1]-f[1]-x)))/o;const C=round(r*E),M=round(o*w);A=transf(...p(C,M));const P=v-A[0],R=y-A[1];this.width=C;this.height=M;this.x=P;this.y=R;this.setDims(i*C,s*M);this.fixAndSetPosition()}altTextFinish(){this.#as?.finish()}async addEditToolbar(){if(this.#vs||this.#xs)return this.#vs;this.#vs=new a.EditorToolbar(this);this.div.append(this.#vs.render());this.#as&&this.#vs.addAltTextButton(await this.#as.render());return this.#vs}removeEditToolbar(){if(this.#vs){this.#vs.remove();this.#vs=null;this.#as?.destroy()}}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){if(!this.#as){AltText.initialize(AnnotationEditor._l10nPromise);this.#as=new AltText(this);await this.addEditToolbar()}}get altTextData(){return this.#as?.data}set altTextData(t){this.#as&&(this.#as.data=t)}hasAltText(){return!this.#as?.isEmpty()}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.#ps?-1:0;this._isVisible||this.div.classList.add("hidden");this.setInForeground();this.div.addEventListener("focusin",this.#bs);this.div.addEventListener("focusout",this.#As);const[t,e]=this.parentDimensions;if(this.parentRotation%180!=0){this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`;this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`}const[s,n]=this.getInitialTranslation();this.translate(s,n);(0,i.bindEvents)(this,this.div,["pointerdown"]);return this.div}pointerdown(t){const{isMac:e}=s.FeatureTest.platform;if(0!==t.button||t.ctrlKey&&e)t.preventDefault();else{this.#Es=!0;this._isDraggable?this.#Us(t):this.#zs(t)}}#zs(t){const{isMac:e}=s.FeatureTest.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#Us(t){const e=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let i,s;if(e){this.div.classList.add("moving");i={passive:!0,capture:!0};this.#Cs=t.clientX;this.#Ms=t.clientY;s=t=>{const{clientX:e,clientY:i}=t,[s,n]=this.screenToPageTranslation(e-this.#Cs,i-this.#Ms);this.#Cs=e;this.#Ms=i;this._uiManager.dragSelectedEditors(s,n)};window.addEventListener("pointermove",s,i)}const pointerUpCallback=()=>{window.removeEventListener("pointerup",pointerUpCallback);window.removeEventListener("blur",pointerUpCallback);if(e){this.div.classList.remove("moving");window.removeEventListener("pointermove",s,i)}this.#Es=!1;this._uiManager.endDragSession()||this.#zs(t)};window.addEventListener("pointerup",pointerUpCallback);window.addEventListener("blur",pointerUpCallback)}moveInDOM(){this.#Ss&&clearTimeout(this.#Ss);this.#Ss=setTimeout((()=>{this.#Ss=null;this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this);this.x=e;this.y=i;this.fixAndSetPosition()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,a]=this.pageDimensions,[r,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*n,c=this.y*a,u=this.width*n,p=this.height*a;switch(i){case 0:return[d+l+r,a-c-h-p+o,d+l+u+r,a-c-h+o];case 90:return[d+h+r,a-c+l+o,d+h+p+r,a-c+l+u+o];case 180:return[d-l-u+r,a-c+h+o,d-l+r,a-c+h+p+o];case 270:return[d-h-p+r,a-c-l-u+o,d-h+r,a-c-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.#xs=!0}disableEditMode(){this.#xs=!1}isInEditMode(){return this.#xs}shouldGetKeyboardEvents(){return this.#Ts}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){this.div?.addEventListener("focusin",this.#bs);this.div?.addEventListener("focusout",this.#As)}rotate(t){}serialize(t=!1,e=null){(0,s.unreachable)("An editor must be serializable")}static deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation;const[n,a]=s.pageDimensions,[r,o,l,h]=s.getRectInCurrentCoords(t.rect,a);s.x=r/n;s.y=o/a;s.width=l/n;s.height=h/a;return s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){this.div.removeEventListener("focusin",this.#bs);this.div.removeEventListener("focusout",this.#As);this.isEmpty()||this.commit();this.parent?this.parent.remove(this):this._uiManager.removeEditor(this);if(this.#Ss){clearTimeout(this.#Ss);this.#Ss=null}this.#ks();this.removeEditToolbar();if(this.#Ps){for(const t of this.#Ps.values())clearTimeout(t);this.#Ps=null}this.parent=null}get isResizable(){return!1}makeResizable(){if(this.isResizable){this.#Os();this.#ms.classList.remove("hidden");(0,i.bindEvents)(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.#fs={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#ms.children;if(!this.#us){this.#us=Array.from(e);const t=this.#Vs.bind(this),i=this.#js.bind(this);for(const e of this.#us){const s=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton");e.addEventListener("keydown",t);e.addEventListener("blur",i);e.addEventListener("focus",this.#Gs.bind(this,s));AnnotationEditor._l10nPromise.get(`pdfjs-editor-resizer-label-${s}`).then((t=>e.setAttribute("aria-label",t)))}}const i=this.#us[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#us.length/4);if(n!==s){if(ns)for(let t=0;ti.setAttribute("aria-label",t)))}}this.#$s(0);this.#Ts=!0;this.#ms.firstChild.focus({focusVisible:!0});t.preventDefault();t.stopImmediatePropagation()}#Vs(t){AnnotationEditor._resizerKeyboardManager.exec(this,t)}#js(t){this.#Ts&&t.relatedTarget?.parentNode!==this.#ms&&this.#ks()}#Gs(t){this.#ys=this.#Ts?t:""}#$s(t){if(this.#us)for(const e of this.#us)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Ts&&this.#Bs(this.#ys,{movementX:t,movementY:e})}#ks(){this.#Ts=!1;this.#$s(-1);if(this.#fs){const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#fs;this.#Hs(t,e,i,s);this.#fs=null}}_stopResizingWithKeyboard(){this.#ks();this.div.focus()}select(){this.makeResizable();this.div?.classList.add("selectedEditor");this.#vs?this.#vs?.show():this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this.#vs?.show()}))}unselect(){this.#ms?.classList.add("hidden");this.div?.classList.remove("selectedEditor");this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0});this.#vs?.hide()}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#_s}set isEditing(t){this.#_s=t;if(this.parent)if(t){this.parent.setSelected(this);this.parent.setActiveEditor(this)}else this.parent.setActiveEditor(null)}setAspectRatio(t,e){this.#gs=!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,e=!1){if(e){this.#Ps||=new Map;const{action:e}=t;let i=this.#Ps.get(e);i&&clearTimeout(i);i=setTimeout((()=>{this._reportTelemetry(t);this.#Ps.delete(e);0===this.#Ps.size&&(this.#Ps=null)}),AnnotationEditor._telemetryTimeout);this.#Ps.set(e,i)}else{t.type||=this.editorType;this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}}show(t=this._isVisible){this.div.classList.toggle("hidden",!t);this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0);this.#ps=!1}disable(){this.div&&(this.div.tabIndex=-1);this.#ps=!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 FakeEditor extends AnnotationEditor{constructor(t){super(t);this.annotationElementId=t.annotationElementId;this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}},61:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{FreeOutliner:()=>FreeOutliner,Outliner:()=>Outliner});var i=e(292);class Outliner{#Ws;#qs=[];#Ks=[];constructor(t,e=0,i=0,s=!0){let n=1/0,a=-1/0,r=1/0,o=-1/0;const l=10**-4;for(const{x:i,y:s,width:h,height:d}of t){const t=Math.floor((i-e)/l)*l,c=Math.ceil((i+h+e)/l)*l,u=Math.floor((s-e)/l)*l,p=Math.ceil((s+d+e)/l)*l,g=[t,u,p,!0],m=[c,u,p,!1];this.#qs.push(g,m);n=Math.min(n,t);a=Math.max(a,c);r=Math.min(r,u);o=Math.max(o,p)}const h=a-n+2*i,d=o-r+2*i,c=n-i,u=r-i,p=this.#qs.at(s?-1:-2),g=[p[0],p[2]];for(const t of this.#qs){const[e,i,s]=t;t[0]=(e-c)/h;t[1]=(i-u)/d;t[2]=(s-u)/d}this.#Ws={x:c,y:u,width:h,height:d,lastPoint:g}}getOutlines(){this.#qs.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#qs)if(e[3]){t.push(...this.#Xs(e));this.#Ys(e)}else{this.#Js(e);t.push(...this.#Xs(e))}return this.#Qs(t)}#Qs(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,s=e.length;t0;){const t=i.values().next().value;let[e,a,r,o,l]=t;i.delete(t);let h=e,d=a;n=[e,r];s.push(n);for(;;){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;if(h!==e){n.push(h,d,e,d===a?a:r);h=e}d=d===a?r:a}n.push(h,d)}return new HighlightOutline(s,this.#Ws)}#Zs(t){const e=this.#Ks;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=0;s--){const[i,n]=this.#Ks[s];if(i!==t)break;if(i===t&&n===e){this.#Ks.splice(s,1);return}}}#Xs(t){const[e,i,s]=t,n=[[e,i,s]],a=this.#Zs(s);for(let t=0;t=i)if(o>s)n[t][1]=s;else{if(1===a)return[];n.splice(t,1);t--;a--}else{n[t][2]=i;o>s&&n.push([e,s,o])}}}return n}}class Outline{toSVGPath(){throw new Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw new Error("Abstract getter `box` must be implemented.")}serialize(t,e){throw new Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof FreeHighlightOutline}}class HighlightOutline extends Outline{#Ws;#tn;constructor(t,e){super();this.#tn=t;this.#Ws=e}toSVGPath(){const t=[];for(const e of this.#tn){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n=6;t-=6)isNaN(e[t])?u.push(`L${e[t+4]} ${e[t+5]}`):u.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);u.push(`L${e[4]} ${e[5]} Z`);return u.join(" ")}getOutlines(){const t=this.#nn,e=this.#en,i=this.#an,s=i.subarray(4,6),n=i.subarray(16,18),[a,r,o,l]=this.#Ws,h=new Float64Array((this.#cn?.length??0)+2);for(let t=0,e=h.length-2;t=6;t-=6)for(let i=0;i<6;i+=2)if(isNaN(e[t+i])){g[m]=g[m+1]=NaN;m+=2}else{g[m]=e[t+i];g[m+1]=e[t+i+1];m+=2}g.set([NaN,NaN,NaN,NaN,e[4],e[5]],m);return new FreeHighlightOutline(g,h,this.#Ws,this.#dn,this.#in,this.#sn)}}class FreeHighlightOutline extends Outline{#Ws;#fn=null;#in;#sn;#cn;#dn;#bn;constructor(t,e,i,s,n,a){super();this.#bn=t;this.#cn=e;this.#Ws=i;this.#dn=s;this.#in=n;this.#sn=a;this.#An(a);const{x:r,y:o,width:l,height:h}=this.#fn;for(let e=0,i=t.length;e{e.d(__webpack_exports__,{EditorToolbar:()=>EditorToolbar,HighlightToolbar:()=>HighlightToolbar});var i=e(419);class EditorToolbar{#En=null;#Yt=null;#Qi;#wn=null;constructor(t){this.#Qi=t}render(){const t=this.#En=document.createElement("div");t.className="editToolbar";t.setAttribute("role","toolbar");t.addEventListener("contextmenu",i.noContextMenu);t.addEventListener("pointerdown",EditorToolbar.#$i);const e=this.#wn=document.createElement("div");e.className="buttons";t.append(e);const s=this.#Qi.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#Qi._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%";e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}this.#_n();return t}static#$i(t){t.stopPropagation()}#xn(t){this.#Qi._focusEventsAllowed=!1;t.preventDefault();t.stopPropagation()}#Tn(t){this.#Qi._focusEventsAllowed=!0;t.preventDefault();t.stopPropagation()}#Sn(t){t.addEventListener("focusin",this.#xn.bind(this),{capture:!0});t.addEventListener("focusout",this.#Tn.bind(this),{capture:!0});t.addEventListener("contextmenu",i.noContextMenu)}hide(){this.#En.classList.add("hidden");this.#Yt?.hideDropdown()}show(){this.#En.classList.remove("hidden")}#_n(){const t=document.createElement("button");t.className="delete";t.tabIndex=0;t.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#Qi.editorType}-button`);this.#Sn(t);t.addEventListener("click",(t=>{this.#Qi._uiManager.delete()}));this.#wn.append(t)}get#Cn(){const t=document.createElement("div");t.className="divider";return t}addAltTextButton(t){this.#Sn(t);this.#wn.prepend(t,this.#Cn)}addColorPicker(t){this.#Yt=t;const e=t.renderButton();this.#Sn(e);this.#wn.prepend(e,this.#Cn)}remove(){this.#En.remove();this.#Yt?.destroy();this.#Yt=null}}class HighlightToolbar{#wn=null;#En=null;#Ni;constructor(t){this.#Ni=t}#Mn(){const t=this.#En=document.createElement("div");t.className="editToolbar";t.setAttribute("role","toolbar");t.addEventListener("contextmenu",i.noContextMenu);const e=this.#wn=document.createElement("div");e.className="buttons";t.append(e);this.#Pn();return t}#Rn(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(ti){s=a;i=t}else e?a>s&&(s=a):a{this.#Ni.highlightSelection("floating_button")}));this.#wn.append(t)}}},830:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{AnnotationEditorUIManager:()=>AnnotationEditorUIManager,ColorManager:()=>ColorManager,KeyboardManager:()=>KeyboardManager,bindEvents:()=>bindEvents,opacityToHex:()=>opacityToHex});var i=e(292),s=e(419),n=e(362);function bindEvents(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}function opacityToHex(t){return Math.round(Math.min(255,Math.max(1,255*t))).toString(16).padStart(2,"0")}class IdManager{#gt=0;constructor(){}get id(){return`${i.AnnotationEditorPrefix}${this.#gt++}`}}class ImageManager{#Fn=(0,i.getUuid)();#gt=0;#mt=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d"),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,';const s=e.decode().then((()=>{t.drawImage(e,0,0,1,1,0,0,1,3);return 0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]}));return(0,i.shadow)(this,"_isSVGFittingCanvas",s)}async#kn(t,e){this.#mt||=new Map;let i=this.#mt.get(t);if(null===i)return null;if(i?.bitmap){i.refCounter+=1;return i}try{i||={bitmap:null,id:`image_${this.#Fn}_${this.#gt++}`,refCounter:0,isSvg:!1};let t;if("string"==typeof e){i.url=e;t=await(0,s.fetchData)(e,"blob")}else t=i.file=e;if("image/svg+xml"===t.type){const e=ImageManager._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(t){console.error(t);i=null}this.#mt.set(t,i);i&&this.#mt.set(i.id,i);return i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#kn(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#kn(t,t)}async getFromId(t){this.#mt||=new Map;const e=this.#mt.get(t);if(!e)return null;if(e.bitmap){e.refCounter+=1;return e}return e.file?this.getFromFile(e.file):this.getFromUrl(e.url)}getSvgUrl(t){const e=this.#mt.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#mt||=new Map;const e=this.#mt.get(t);if(e){e.refCounter-=1;0===e.refCounter&&(e.bitmap=null)}}isValidId(t){return t.startsWith(`image_${this.#Fn}_`)}}class CommandManager{#Dn=[];#In=!1;#Ln;#On=-1;constructor(t=128){this.#Ln=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:r=!1}){s&&t();if(this.#In)return;const o={cmd:t,undo:e,post:i,type:n};if(-1===this.#On){this.#Dn.length>0&&(this.#Dn.length=0);this.#On=0;this.#Dn.push(o);return}if(a&&this.#Dn[this.#On].type===n){r&&(o.undo=this.#Dn[this.#On].undo);this.#Dn[this.#On]=o;return}const l=this.#On+1;if(l===this.#Ln)this.#Dn.splice(0,1);else{this.#On=l;lt===e[i])))return ColorManager._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?i.Util.makeHexColor(...e):t}}class AnnotationEditorUIManager{#Bn=null;#Hn=new Map;#Un=new Map;#zn=null;#Vn=null;#jn=null;#Gn=new CommandManager;#$n=0;#Wn=new Set;#qn=null;#Bi=null;#Kn=new Set;#Xn=!1;#Yn=null;#Jn=null;#Qn=null;#Zn=!1;#ta=null;#ea=new IdManager;#ia=!1;#sa=!1;#na=null;#aa=null;#ra=null;#oa=i.AnnotationEditorType.NONE;#la=new Set;#ha=null;#da=null;#ca=null;#ua=this.blur.bind(this);#pa=this.focus.bind(this);#ga=this.copy.bind(this);#ma=this.cut.bind(this);#fa=this.paste.bind(this);#se=this.keydown.bind(this);#ba=this.keyup.bind(this);#Aa=this.onEditingAction.bind(this);#va=this.onPageChanging.bind(this);#ya=this.onScaleChanging.bind(this);#Ea=this.#wa.bind(this);#_a=this.onRotationChanging.bind(this);#xa={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#Ta=[0,0];#Sa=null;#m=null;#Ca=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const t=AnnotationEditorUIManager.prototype,arrowChecker=t=>t.#m.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),textInputChecker=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},e=this.TRANSLATE_SMALL,s=this.TRANSLATE_BIG;return(0,i.shadow)(this,"_keyboardManager",new KeyboardManager([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:textInputChecker}],[["ctrl+z","mac+meta+z"],t.undo,{checker:textInputChecker}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.redo,{checker:textInputChecker}],[["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:textInputChecker}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#m.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#m.contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-e,0],checker:arrowChecker}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-s,0],checker:arrowChecker}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[e,0],checker:arrowChecker}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[s,0],checker:arrowChecker}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-e],checker:arrowChecker}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-s],checker:arrowChecker}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,e],checker:arrowChecker}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,s],checker:arrowChecker}]]))}constructor(t,e,i,n,a,r,o,l,h){this.#m=t;this.#Ca=e;this.#zn=i;this._eventBus=n;this._eventBus._on("editingaction",this.#Aa);this._eventBus._on("pagechanging",this.#va);this._eventBus._on("scalechanging",this.#ya);this._eventBus._on("rotationchanging",this.#_a);this.#Ma();this.#Pa();this.#Vn=a.annotationStorage;this.#Yn=a.filterFactory;this.#da=r;this.#Qn=o||null;this.#Xn=l;this.#ra=h||null;this.viewParameters={realScale:s.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0};this.isShiftKeyDown=!1}destroy(){this.#Ra();this.#Fa();this._eventBus._off("editingaction",this.#Aa);this._eventBus._off("pagechanging",this.#va);this._eventBus._off("scalechanging",this.#ya);this._eventBus._off("rotationchanging",this.#_a);for(const t of this.#Un.values())t.destroy();this.#Un.clear();this.#Hn.clear();this.#Kn.clear();this.#Bn=null;this.#la.clear();this.#Gn.destroy();this.#zn?.destroy();this.#ta?.hide();this.#ta=null;if(this.#Jn){clearTimeout(this.#Jn);this.#Jn=null}if(this.#Sa){clearTimeout(this.#Sa);this.#Sa=null}this.#ka()}async mlGuess(t){return this.#ra?.guess(t)||null}get hasMLManager(){return!!this.#ra}get hcmFilter(){return(0,i.shadow)(this,"hcmFilter",this.#da?this.#Yn.addHCMFilter(this.#da.foreground,this.#da.background):"none")}get direction(){return(0,i.shadow)(this,"direction",getComputedStyle(this.#m).direction)}get highlightColors(){return(0,i.shadow)(this,"highlightColors",this.#Qn?new Map(this.#Qn.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return(0,i.shadow)(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setMainHighlightColorPicker(t){this.#aa=t}editAltText(t){this.#zn?.editAltText(this,t)}onPageChanging({pageNumber:t}){this.#$n=t-1}focusMainContainer(){this.#m.focus()}findParent(t,e){for(const i of this.#Un.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(t=!1){this.#Ca.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#Kn.add(t)}removeShouldRescale(t){this.#Kn.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove();this.viewParameters.realScale=t*s.PixelsPerInch.PDF_TO_CSS_UNITS;for(const t of this.#Kn)t.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove();this.viewParameters.rotation=t}#Da({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:n,focusNode:a,focusOffset:r}=e,o=e.toString(),l=this.#Da(e).closest(".textLayer"),h=this.getSelectionBoxes(l);if(h){e.empty();if(this.#oa===i.AnnotationEditorType.NONE){this._eventBus.dispatch("showannotationeditorui",{source:this,mode:i.AnnotationEditorType.HIGHLIGHT});this.showAllEditors("highlight",!0,!0)}for(const e of this.#Un.values())if(e.hasTextLayer(l)){e.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:s,anchorOffset:n,focusNode:a,focusOffset:r,text:o});break}}}#Ia(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#Da(t).closest(".textLayer"),i=this.getSelectionBoxes(e);if(i){this.#ta||=new n.HighlightToolbar(this);this.#ta.show(e,i,"ltr"===this.direction)}}addToAnnotationStorage(t){t.isEmpty()||!this.#Vn||this.#Vn.has(t.id)||this.#Vn.setValue(t.id,t)}#wa(){const t=document.getSelection();if(!t||t.isCollapsed){if(this.#ha){this.#ta?.hide();this.#ha=null;this.#La({hasSelectedText:!1})}return}const{anchorNode:e}=t;if(e===this.#ha)return;if(this.#Da(t).closest(".textLayer")){this.#ta?.hide();this.#ha=e;this.#La({hasSelectedText:!0});if(this.#oa===i.AnnotationEditorType.HIGHLIGHT||this.#oa===i.AnnotationEditorType.NONE){this.#oa===i.AnnotationEditorType.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0);this.#Zn=this.isShiftKeyDown;if(!this.isShiftKeyDown){const pointerup=t=>{if("pointerup"!==t.type||0===t.button){window.removeEventListener("pointerup",pointerup);window.removeEventListener("blur",pointerup);"pointerup"===t.type&&this.#Oa("main_toolbar")}};window.addEventListener("pointerup",pointerup);window.addEventListener("blur",pointerup)}}}else if(this.#ha){this.#ta?.hide();this.#ha=null;this.#La({hasSelectedText:!1})}}#Oa(t=""){this.#oa===i.AnnotationEditorType.HIGHLIGHT?this.highlightSelection(t):this.#Xn&&this.#Ia()}#Ma(){document.addEventListener("selectionchange",this.#Ea)}#ka(){document.removeEventListener("selectionchange",this.#Ea)}#Na(){window.addEventListener("focus",this.#pa);window.addEventListener("blur",this.#ua)}#Fa(){window.removeEventListener("focus",this.#pa);window.removeEventListener("blur",this.#ua)}blur(){this.isShiftKeyDown=!1;if(this.#Zn){this.#Zn=!1;this.#Oa("main_toolbar")}if(!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#la)if(e.div.contains(t)){this.#na=[e,t];e._focusEventsAllowed=!1;break}}focus(){if(!this.#na)return;const[t,e]=this.#na;this.#na=null;e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0});e.focus()}#Pa(){window.addEventListener("keydown",this.#se);window.addEventListener("keyup",this.#ba)}#Ra(){window.removeEventListener("keydown",this.#se);window.removeEventListener("keyup",this.#ba)}#Ba(){document.addEventListener("copy",this.#ga);document.addEventListener("cut",this.#ma);document.addEventListener("paste",this.#fa)}#Ha(){document.removeEventListener("copy",this.#ga);document.removeEventListener("cut",this.#ma);document.removeEventListener("paste",this.#fa)}addEditListeners(){this.#Pa();this.#Ba()}removeEditListeners(){this.#Ra();this.#Ha()}copy(t){t.preventDefault();this.#Bn?.commitOrRemove();if(!this.hasSelection)return;const e=[];for(const t of this.#la){const i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t);this.delete()}paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#Bi)if(e.isHandlingMimeForPasting(t.type)){e.paste(t,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(t){(0,i.warn)(`paste: "${t.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const n=this.currentLayer;try{const t=[];for(const e of s){const i=n.deserialize(e);if(!i)return;t.push(i)}const cmd=()=>{for(const e of t)this.#Ua(e);this.#za(t)},undo=()=>{for(const e of t)e.remove()};this.addCommands({cmd,undo,mustExec:!0})}catch(t){(0,i.warn)(`paste: "${t.message}".`)}}keydown(t){this.isShiftKeyDown||"Shift"!==t.key||(this.isShiftKeyDown=!0);this.#oa===i.AnnotationEditorType.NONE||this.isEditorHandlingKeyboard||AnnotationEditorUIManager._keyboardManager.exec(this,t)}keyup(t){if(this.isShiftKeyDown&&"Shift"===t.key){this.isShiftKeyDown=!1;if(this.#Zn){this.#Zn=!1;this.#Oa("main_toolbar")}}}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#La(t){if(Object.entries(t).some((([t,e])=>this.#xa[t]!==e))){this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#xa,t)});this.#oa===i.AnnotationEditorType.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Va([[i.AnnotationEditorParamsType.HIGHLIGHT_FREE,!0]])}}#Va(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){if(t){this.#Na();this.#Ba();this.#La({isEditing:this.#oa!==i.AnnotationEditorType.NONE,isEmpty:this.#ja(),hasSomethingToUndo:this.#Gn.hasSomethingToUndo(),hasSomethingToRedo:this.#Gn.hasSomethingToRedo(),hasSelectedEditor:!1})}else{this.#Fa();this.#Ha();this.#La({isEditing:!1});this.disableUserSelect(!1)}}registerEditorTypes(t){if(!this.#Bi){this.#Bi=t;for(const t of this.#Bi)this.#Va(t.defaultPropertiesToUpdate)}}getId(){return this.#ea.id}get currentLayer(){return this.#Un.get(this.#$n)}getLayer(t){return this.#Un.get(t)}get currentPageIndex(){return this.#$n}addLayer(t){this.#Un.set(t.pageIndex,t);this.#ia?t.enable():t.disable()}removeLayer(t){this.#Un.delete(t.pageIndex)}updateMode(t,e=null,s=!1){if(this.#oa!==t){this.#oa=t;if(t!==i.AnnotationEditorType.NONE){this.setEditingState(!0);this.#Ga();this.unselectAll();for(const e of this.#Un.values())e.updateMode(t);if(e||!s){if(e)for(const t of this.#Hn.values())if(t.annotationElementId===e){this.setSelected(t);t.enterInEditMode();break}}else this.addNewEditorFromKeyboard()}else{this.setEditingState(!1);this.#$a()}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#oa&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#Bi){switch(t){case i.AnnotationEditorParamsType.CREATE:this.currentLayer.addNewEditor();return;case i.AnnotationEditorParamsType.HIGHLIGHT_DEFAULT_COLOR:this.#aa?.updateColor(e);break;case i.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}});(this.#ca||=new Map).set(t,e);this.showAllEditors("highlight",e)}for(const i of this.#la)i.updateParams(t,e);for(const i of this.#Bi)i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){for(const i of this.#Hn.values())i.editorType===t&&i.show(e);(this.#ca?.get(i.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Va([[i.AnnotationEditorParamsType.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#sa!==t){this.#sa=t;for(const e of this.#Un.values()){t?e.disableClick():e.enableClick();e.div.classList.toggle("waiting",t)}}}#Ga(){if(!this.#ia){this.#ia=!0;for(const t of this.#Un.values())t.enable();for(const t of this.#Hn.values())t.enable()}}#$a(){this.unselectAll();if(this.#ia){this.#ia=!1;for(const t of this.#Un.values())t.disable();for(const t of this.#Hn.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#Hn.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#Hn.get(t)}addEditor(t){this.#Hn.set(t.id,t)}removeEditor(t){if(t.div.contains(document.activeElement)){this.#Jn&&clearTimeout(this.#Jn);this.#Jn=setTimeout((()=>{this.focusMainContainer();this.#Jn=null}),0)}this.#Hn.delete(t.id);this.unselect(t);t.annotationElementId&&this.#Wn.has(t.annotationElementId)||this.#Vn?.remove(t.id)}addDeletedAnnotationElement(t){this.#Wn.add(t.annotationElementId);this.addChangedExistingAnnotation(t);t.deleted=!0}isDeletedAnnotationElement(t){return this.#Wn.has(t)}removeDeletedAnnotationElement(t){this.#Wn.delete(t.annotationElementId);this.removeChangedExistingAnnotation(t);t.deleted=!1}#Ua(t){const e=this.#Un.get(t.pageIndex);if(e)e.addOrRebuild(t);else{this.addEditor(t);this.addToAnnotationStorage(t)}}setActiveEditor(t){if(this.#Bn!==t){this.#Bn=t;t&&this.#Va(t.propertiesToUpdate)}}get#Wa(){let t=null;for(t of this.#la);return t}updateUI(t){this.#Wa===t&&this.#Va(t.propertiesToUpdate)}toggleSelected(t){if(this.#la.has(t)){this.#la.delete(t);t.unselect();this.#La({hasSelectedEditor:this.hasSelection})}else{this.#la.add(t);t.select();this.#Va(t.propertiesToUpdate);this.#La({hasSelectedEditor:!0})}}setSelected(t){for(const e of this.#la)e!==t&&e.unselect();this.#la.clear();this.#la.add(t);t.select();this.#Va(t.propertiesToUpdate);this.#La({hasSelectedEditor:!0})}isSelected(t){return this.#la.has(t)}get firstSelectedEditor(){return this.#la.values().next().value}unselect(t){t.unselect();this.#la.delete(t);this.#La({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#la.size}get isEnterHandled(){return 1===this.#la.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#Gn.undo();this.#La({hasSomethingToUndo:this.#Gn.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#ja()})}redo(){this.#Gn.redo();this.#La({hasSomethingToUndo:!0,hasSomethingToRedo:this.#Gn.hasSomethingToRedo(),isEmpty:this.#ja()})}addCommands(t){this.#Gn.add(t);this.#La({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#ja()})}#ja(){if(0===this.#Hn.size)return!0;if(1===this.#Hn.size)for(const t of this.#Hn.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();if(!this.hasSelection)return;const t=[...this.#la];this.addCommands({cmd:()=>{for(const e of t)e.remove()},undo:()=>{for(const e of t)this.#Ua(e)},mustExec:!0})}commitOrRemove(){this.#Bn?.commitOrRemove()}hasSomethingToControl(){return this.#Bn||this.hasSelection}#za(t){for(const t of this.#la)t.unselect();this.#la.clear();for(const e of t)if(!e.isEmpty()){this.#la.add(e);e.select()}this.#La({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#la)t.commit();this.#za(this.#Hn.values())}unselectAll(){if(this.#Bn){this.#Bn.commitOrRemove();if(this.#oa!==i.AnnotationEditorType.NONE)return}if(this.hasSelection){for(const t of this.#la)t.unselect();this.#la.clear();this.#La({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){i||this.commitOrRemove();if(!this.hasSelection)return;this.#Ta[0]+=t;this.#Ta[1]+=e;const[s,n]=this.#Ta,a=[...this.#la];this.#Sa&&clearTimeout(this.#Sa);this.#Sa=setTimeout((()=>{this.#Sa=null;this.#Ta[0]=this.#Ta[1]=0;this.addCommands({cmd:()=>{for(const t of a)this.#Hn.has(t.id)&&t.translateInPage(s,n)},undo:()=>{for(const t of a)this.#Hn.has(t.id)&&t.translateInPage(-s,-n)},mustExec:!1})}),1e3);for(const i of a)i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0);this.#qn=new Map;for(const t of this.#la)this.#qn.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#qn)return!1;this.disableUserSelect(!1);const t=this.#qn;this.#qn=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},a]of t){a.newX=i;a.newY=s;a.newPageIndex=n;e||=i!==a.savedX||s!==a.savedY||n!==a.savedPageIndex}if(!e)return!1;const move=(t,e,i,s)=>{if(this.#Hn.has(t.id)){const n=this.#Un.get(s);if(n)t._setParentAndPosition(n,e,i);else{t.pageIndex=s;t.x=e;t.y=i}}};this.addCommands({cmd:()=>{for(const[e,{newX:i,newY:s,newPageIndex:n}]of t)move(e,i,s,n)},undo:()=>{for(const[e,{savedX:i,savedY:s,savedPageIndex:n}]of t)move(e,i,s,n)},mustExec:!0});return!0}dragSelectedEditors(t,e){if(this.#qn)for(const i of this.#qn.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);if(e){e.changeParent(t);e.addOrRebuild(t)}else{this.addEditor(t);this.addToAnnotationStorage(t);t.rebuild()}}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#la.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#Bn===t}getActive(){return this.#Bn}getMode(){return this.#oa}get imageManager(){return(0,i.shadow)(this,"imageManager",new ImageManager)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i({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 t=0,i=e.rangeCount;t{e.d(__webpack_exports__,{PDFFetchStream:()=>PDFFetchStream});var i=e(292),s=e(490);function createFetchOptions(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function createHeaders(t){const e=new Headers;for(const i in t){const s=t[i];void 0!==s&&e.append(i,s)}return e}function getArrayBuffer(t){if(t instanceof Uint8Array)return t.buffer;if(t instanceof ArrayBuffer)return t;(0,i.warn)(`getArrayBuffer - unexpected data format: ${t}`);return new Uint8Array(t).buffer}class PDFFetchStream{constructor(t){this.source=t;this.isHttp=/^https?:/i.test(t.url);this.httpHeaders=this.isHttp&&t.httpHeaders||{};this._fullRequestReader=null;this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){(0,i.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once.");this._fullRequestReader=new PDFFetchStreamReader(this);return this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new PDFFetchStreamRangeReader(this,t,e);this._rangeRequestReaders.push(i);return i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class PDFFetchStreamReader{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;this._headers=createHeaders(this._stream.httpHeaders);const n=e.url;fetch(n,createFetchOptions(this._headers,this._withCredentials,this._abortController)).then((t=>{if(!(0,s.validateResponseStatus)(t.status))throw(0,s.createResponseStatusError)(t.status,n);this._reader=t.body.getReader();this._headersCapability.resolve();const getResponseHeader=e=>t.headers.get(e),{allowRangeRequests:e,suggestedLength:a}=(0,s.validateRangeRequestCapabilities)({getResponseHeader,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=e;this._contentLength=a||this._contentLength;this._filename=(0,s.extractFilenameFromHeader)(getResponseHeader);!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new i.AbortException("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();if(e)return{value:t,done:e};this._loaded+=t.byteLength;this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:getArrayBuffer(t),done:!1}}cancel(t){this._reader?.cancel(t);this._abortController.abort()}}class PDFFetchStreamRangeReader{constructor(t,e,i){this._stream=t;this._reader=null;this._loaded=0;const n=t.source;this._withCredentials=n.withCredentials||!1;this._readCapability=Promise.withResolvers();this._isStreamingSupported=!n.disableStream;this._abortController=new AbortController;this._headers=createHeaders(this._stream.httpHeaders);this._headers.append("Range",`bytes=${e}-${i-1}`);const a=n.url;fetch(a,createFetchOptions(this._headers,this._withCredentials,this._abortController)).then((t=>{if(!(0,s.validateResponseStatus)(t.status))throw(0,s.createResponseStatusError)(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();if(e)return{value:t,done:e};this._loaded+=t.byteLength;this.onProgress?.({loaded:this._loaded});return{value:getArrayBuffer(t),done:!1}}cancel(t){this._reader?.cancel(t);this._abortController.abort()}}},10:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{FontFaceObject:()=>FontFaceObject,FontLoader:()=>FontLoader});var i=e(292);class FontLoader{#qa=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t;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){if(!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.#qa.clear();if(this.styleElement){this.styleElement.remove();this.styleElement=null}}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#qa.has(t.loadedName)){(0,i.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set.");if(this.isFontLoadingAPISupported){const{loadedName:s,src:n,style:a}=t,r=new FontFace(s,n,a);this.addNativeFontFace(r);try{await r.load();this.#qa.add(s);e?.(t)}catch{(0,i.warn)(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`);this.removeNativeFontFace(r)}}else(0,i.unreachable)("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;t.attached=!0;if(t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(s){(0,i.warn)(`Failed to load font '${e.family}': '${s}'.`);t.disableFontFace=!0;throw s}}return}const e=t.createFontFaceRule();if(e){this.insertRule(e);if(this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return(0,i.shadow)(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;(i.isNodeJS||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0);return(0,i.shadow)(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,s={done:!1,complete:function completeRequest(){(0,i.assert)(!s.done,"completeRequest() cannot be called twice.");s.done=!0;for(;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};e.push(s);return s}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return(0,i.shadow)(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function int32(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function spliceString(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let s,n;const a=this._document.createElement("canvas");a.width=1;a.height=1;const r=a.getContext("2d");let o=0;const l=`lt${Date.now()}${this.loadTestFontId++}`;let h=this._loadTestFont;h=spliceString(h,976,l.length,l);const d=1482184792;let c=int32(h,16);for(s=0,n=l.length-3;s30){(0,i.warn)("Load test font never loaded.");e();return}r.font="30px "+t;r.fillText(".",0,20);r.getImageData(0,0,1,1).data[3]>0?e():setTimeout(isFontReady.bind(null,t,e))}(l,(()=>{p.remove();e.complete()}))}}class FontFaceObject{constructor(t,{disableFontFace:e=!1,ignoreErrors:i=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.disableFontFace=!0===e;this.ignoreErrors=!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,{});this._inspectFont?.(this);return t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=(0,i.bytesToString)(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`);s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;this._inspectFont?.(this,e);return s}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(t){if(!this.ignoreErrors)throw t;(0,i.warn)(`getPathGenerator - ignoring character: "${t}".`)}if(!Array.isArray(s)||0===s.length)return this.compiledGlyphs[e]=function(t,e){};const n=[];for(let t=0,e=s.length;tt.bezierCurveTo(e,i,a,r,o,l)));t+=6}break;case i.FontRenderOps.MOVE_TO:{const[e,i]=s.slice(t,t+2);n.push((t=>t.moveTo(e,i)));t+=2}break;case i.FontRenderOps.LINE_TO:{const[e,i]=s.slice(t,t+2);n.push((t=>t.lineTo(e,i)));t+=2}break;case i.FontRenderOps.QUADRATIC_CURVE_TO:{const[e,i,a,r]=s.slice(t,t+4);n.push((t=>t.quadraticCurveTo(e,i,a,r)));t+=4}break;case i.FontRenderOps.RESTORE:n.push((t=>t.restore()));break;case i.FontRenderOps.SAVE:n.push((t=>t.save()));break;case i.FontRenderOps.SCALE:(0,i.assert)(2===n.length,"Scale command is only valid at the third position.");break;case i.FontRenderOps.TRANSFORM:{const[e,i,a,r,o,l]=s.slice(t,t+6);n.push((t=>t.transform(e,i,a,r,o,l)));t+=6}break;case i.FontRenderOps.TRANSLATE:{const[e,i]=s.slice(t,t+2);n.push((t=>t.translate(e,i)));t+=2}}return this.compiledGlyphs[e]=function glyphDrawer(t,e){n[0](t);n[1](t);t.scale(e,-e);for(let e=2,i=n.length;e{e.d(__webpack_exports__,{Metadata:()=>Metadata});var i=e(292);class Metadata{#Ka;#Xa;constructor({parsedData:t,rawData:e}){this.#Ka=t;this.#Xa=e}getRaw(){return this.#Xa}get(t){return this.#Ka.get(t)??null}getAll(){return(0,i.objectFromMap)(this.#Ka)}has(t){return this.#Ka.has(t)}}},457:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{PDFNetworkStream:()=>PDFNetworkStream});var i=e(292),s=e(490);class NetworkManager{constructor(t,e={}){this.url=t;this.isHttp=/^https?:/i.test(t);this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null);this.withCredentials=e.withCredentials||!1;this.currXhrId=0;this.pendingRequests=Object.create(null)}requestRange(t,e,i){const s={begin:t,end:e};for(const t in i)s[t]=i[t];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 t in this.httpHeaders){const i=this.httpHeaders[t];void 0!==i&&e.setRequestHeader(t,i)}if(this.isHttp&&"begin"in t&&"end"in t){e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`);s.expectedStatus=206}else 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);return i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const n=s.xhr;if(n.readyState>=2&&s.onHeadersReceived){s.onHeadersReceived();delete s.onHeadersReceived}if(4!==n.readyState)return;if(!(t in this.pendingRequests))return;delete this.pendingRequests[t];if(0===n.status&&this.isHttp){s.onError?.(n.status);return}const a=n.status||200;if(!(200===a&&206===s.expectedStatus)&&a!==s.expectedStatus){s.onError?.(n.status);return}const r=function getArrayBuffer(t){const e=t.response;return"string"!=typeof e?e:(0,i.stringToBytes)(e).buffer}(n);if(206===a){const t=n.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);s.onDone({begin:parseInt(e[1],10),chunk:r})}else r?s.onDone({begin:0,chunk:r}):s.onError?.(n.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 PDFNetworkStream{constructor(t){this._source=t;this._manager=new NetworkManager(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials});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(){(0,i.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once.");this._fullRequestReader=new PDFNetworkStreamFullRequestReader(this._manager,this._source);return this._fullRequestReader}getRangeReader(t,e){const i=new PDFNetworkStreamRangeRequestReader(this._manager,t,e);i.onClosed=this._onRangeRequestReaderClosed.bind(this);this._rangeRequestReaders.push(i);return i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class PDFNetworkStreamFullRequestReader{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._headersReceivedCapability=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),getResponseHeader=t=>e.getResponseHeader(t),{allowRangeRequests:i,suggestedLength:n}=(0,s.validateRangeRequestCapabilities)({getResponseHeader,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0);this._contentLength=n||this._contentLength;this._filename=(0,s.extractFilenameFromHeader)(getResponseHeader);this._isRangeSupported&&this._manager.abortRequest(t);this._headersReceivedCapability.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);this._done=!0;if(!(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=(0,s.createResponseStatusError)(t,this._url);this._headersReceivedCapability.reject(this._storedError);for(const t of this._requests)t.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._headersReceivedCapability.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();this._requests.push(t);return t.promise}cancel(t){this._done=!0;this._headersReceivedCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0;this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId);this._fullRequestReader=null}}class PDFNetworkStreamRangeRequestReader{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 t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0;this._close()}_onError(t){this._storedError=(0,s.createResponseStatusError)(t,this._url);for(const t of this._requests)t.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;this._queuedChunk=null;return{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();this._requests.push(t);return t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0;this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId);this._close()}}},490:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{createResponseStatusError:()=>createResponseStatusError,extractFilenameFromHeader:()=>extractFilenameFromHeader,validateRangeRequestCapabilities:()=>validateRangeRequestCapabilities,validateResponseStatus:()=>validateResponseStatus});var i=e(292);var s=e(419);function validateRangeRequestCapabilities({getResponseHeader:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(t("Content-Length"),10);if(!Number.isInteger(a))return n;n.suggestedLength=a;if(a<=2*i)return n;if(s||!e)return n;if("bytes"!==t("Accept-Ranges"))return n;if("identity"!==(t("Content-Encoding")||"identity"))return n;n.allowRangeRequests=!0;return n}function extractFilenameFromHeader(t){const e=t("Content-Disposition");if(e){let t=function getFilenameFromContentDispositionHeader(t){let e=!0,s=toParamRegExp("filename\\*","i").exec(t);if(s){s=s[1];let t=rfc2616unquote(s);t=unescape(t);t=rfc5987decode(t);t=rfc2047decode(t);return fixupEncoding(t)}s=function rfc2231getparam(t){const e=[];let i;const s=toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=s.exec(t));){let[,t,s,n]=i;t=parseInt(t,10);if(t in e){if(0===t)break}else e[t]=[s,n]}const n=[];for(let t=0;t{e.a(t,(async(t,i)=>{try{e.d(__webpack_exports__,{PDFNodeStream:()=>PDFNodeStream});var s=e(292),n=e(490);let a,r,o,l;if(s.isNodeJS){a=await import("fs");r=await import("http");o=await import("https");l=await import("url")}const h=/^file:\/\/\/[a-zA-Z]:\//;function parseUrl(t){const e=l.parse(t);if("file:"===e.protocol||e.host)return e;if(/^[a-z]:[/\\]/i.test(t))return l.parse(`file:///${t}`);e.host||(e.protocol="file:");return e}class PDFNodeStream{constructor(t){this.source=t;this.url=parseUrl(t.url);this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol;this.isFsUrl="file:"===this.url.protocol;this.httpHeaders=this.isHttp&&t.httpHeaders||{};this._fullRequestReader=null;this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){(0,s.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once.");this._fullRequestReader=this.isFsUrl?new PDFNodeStreamFsFullReader(this):new PDFNodeStreamFullReader(this);return this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=this.isFsUrl?new PDFNodeStreamFsRangeReader(this,t,e):new PDFNodeStreamRangeReader(this,t,e);this._rangeRequestReaders.push(i);return i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class BaseFullReader{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(){await this._readCapability.promise;if(this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t){this._readCapability=Promise.withResolvers();return 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 s.AbortException("streaming is disabled"));this._storedError&&this._readableStream.destroy(this._storedError)}}class BaseRangeReader{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(){await this._readCapability.promise;if(this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t){this._readCapability=Promise.withResolvers();return 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)}}function createRequestOptions(t,e){return{protocol:t.protocol,auth:t.auth,host:t.hostname,port:t.port,path:t.path,method:"GET",headers:e}}class PDFNodeStreamFullReader extends BaseFullReader{constructor(t){super(t);const handleResponse=e=>{if(404===e.statusCode){const t=new s.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=t;this._headersCapability.reject(t);return}this._headersCapability.resolve();this._setReadableStream(e);const getResponseHeader=t=>this._readableStream.headers[t.toLowerCase()],{allowRangeRequests:i,suggestedLength:a}=(0,n.validateRangeRequestCapabilities)({getResponseHeader,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i;this._contentLength=a||this._contentLength;this._filename=(0,n.extractFilenameFromHeader)(getResponseHeader)};this._request=null;"http:"===this._url.protocol?this._request=r.request(createRequestOptions(this._url,t.httpHeaders),handleResponse):this._request=o.request(createRequestOptions(this._url,t.httpHeaders),handleResponse);this._request.on("error",(t=>{this._storedError=t;this._headersCapability.reject(t)}));this._request.end()}}class PDFNodeStreamRangeReader extends BaseRangeReader{constructor(t,e,i){super(t);this._httpHeaders={};for(const e in t.httpHeaders){const i=t.httpHeaders[e];void 0!==i&&(this._httpHeaders[e]=i)}this._httpHeaders.Range=`bytes=${e}-${i-1}`;const handleResponse=t=>{if(404!==t.statusCode)this._setReadableStream(t);else{const t=new s.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=t}};this._request=null;"http:"===this._url.protocol?this._request=r.request(createRequestOptions(this._url,this._httpHeaders),handleResponse):this._request=o.request(createRequestOptions(this._url,this._httpHeaders),handleResponse);this._request.on("error",(t=>{this._storedError=t}));this._request.end()}}class PDFNodeStreamFsFullReader extends BaseFullReader{constructor(t){super(t);let e=decodeURIComponent(this._url.path);h.test(this._url.href)&&(e=e.replace(/^\//,""));a.promises.lstat(e).then((t=>{this._contentLength=t.size;this._setReadableStream(a.createReadStream(e));this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new s.MissingPDFException(`Missing PDF "${e}".`));this._storedError=t;this._headersCapability.reject(t)}))}}class PDFNodeStreamFsRangeReader extends BaseRangeReader{constructor(t,e,i){super(t);let s=decodeURIComponent(this._url.path);h.test(this._url.href)&&(s=s.replace(/^\//,""));this._setReadableStream(a.createReadStream(s,{start:e,end:i-1}))}}i()}catch(d){i(d)}}),1)},573:(t,__webpack_exports__,e)=>{e.a(t,(async(t,i)=>{try{e.d(__webpack_exports__,{NodeCMapReaderFactory:()=>NodeCMapReaderFactory,NodeCanvasFactory:()=>NodeCanvasFactory,NodeFilterFactory:()=>NodeFilterFactory,NodeStandardFontDataFactory:()=>NodeStandardFontDataFactory});var s=e(583);let t,n,a;if(e(292).isNodeJS){t=await import("fs");try{n=await import("canvas")}catch{}try{a=await import("path2d")}catch{}}const fetchData=function(e){return t.promises.readFile(e).then((t=>new Uint8Array(t)))};class NodeFilterFactory extends s.BaseFilterFactory{}class NodeCanvasFactory extends s.BaseCanvasFactory{_createCanvas(t,e){return n.createCanvas(t,e)}}class NodeCMapReaderFactory extends s.BaseCMapReaderFactory{_fetchData(t,e){return fetchData(t).then((t=>({cMapData:t,compressionType:e})))}}class NodeStandardFontDataFactory extends s.BaseStandardFontDataFactory{_fetchData(t){return fetchData(t)}}i()}catch(t){i(t)}}),1)},626:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{OptionalContentConfig:()=>OptionalContentConfig});var i=e(292),s=e(651);const n=Symbol("INTERNAL");class OptionalContentGroup{#Ya=!1;#Ja=!1;#Qa=!1;#Za=!0;constructor(t,{name:e,intent:s,usage:n}){this.#Ya=!!(t&i.RenderingIntentFlag.DISPLAY);this.#Ja=!!(t&i.RenderingIntentFlag.PRINT);this.name=e;this.intent=s;this.usage=n}get visible(){if(this.#Qa)return this.#Za;if(!this.#Za)return!1;const{print:t,view:e}=this.usage;return this.#Ya?"OFF"!==e?.viewState:!this.#Ja||"OFF"!==t?.printState}_setVisible(t,e,s=!1){t!==n&&(0,i.unreachable)("Internal method `_setVisible` called.");this.#Qa=s;this.#Za=e}}class OptionalContentConfig{#tr=null;#er=new Map;#ir=null;#sr=null;constructor(t,e=i.RenderingIntentFlag.DISPLAY){this.renderingIntent=e;this.name=null;this.creator=null;if(null!==t){this.name=t.name;this.creator=t.creator;this.#sr=t.order;for(const i of t.groups)this.#er.set(i.id,new OptionalContentGroup(e,i));if("OFF"===t.baseState)for(const t of this.#er.values())t._setVisible(n,!1);for(const e of t.on)this.#er.get(e)._setVisible(n,!0);for(const e of t.off)this.#er.get(e)._setVisible(n,!1);this.#ir=this.getHash()}}#nr(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let n=1;n0?(0,i.objectFromMap)(this.#er):null}getGroup(t){return this.#er.get(t)||null}getHash(){if(null!==this.#tr)return this.#tr;const t=new s.MurmurHash3_64;for(const[e,i]of this.#er)t.update(`${e}:${i.visible}`);return this.#tr=t.hexdigest()}}},814:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{cleanupTextLayer:()=>cleanupTextLayer,renderTextLayer:()=>renderTextLayer,updateTextLayer:()=>updateTextLayer});var i=e(292),s=e(419);const n=30,a=.8,r=new Map;let o=null;function getCtx(){if(!o){const t=document.createElement("canvas");t.className="hiddenCanvasElement";document.body.append(t);o=t.getContext("2d",{alpha:!1})}return o}function cleanupTextLayer(){o?.canvas.remove();o=null}function appendText(t,e,s){const o=document.createElement("span"),l={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};t._textDivs.push(o);const h=i.Util.transform(t._transform,e.transform);let d=Math.atan2(h[1],h[0]);const c=s[e.fontName];c.vertical&&(d+=Math.PI/2);const u=t._fontInspectorEnabled&&c.fontSubstitution||c.fontFamily,p=Math.hypot(h[2],h[3]),g=p*function getAscent(t){const e=r.get(t);if(e)return e;const i=getCtx(),s=i.font;i.canvas.width=i.canvas.height=n;i.font=`${n}px ${t}`;const o=i.measureText("");let l=o.fontBoundingBoxAscent,h=Math.abs(o.fontBoundingBoxDescent);if(l){const e=l/(l+h);r.set(t,e);i.canvas.width=i.canvas.height=0;i.font=s;return e}i.strokeStyle="red";i.clearRect(0,0,n,n);i.strokeText("g",0,0);let d=i.getImageData(0,0,n,n).data;h=0;for(let t=d.length-1-3;t>=0;t-=4)if(d[t]>0){h=Math.ceil(t/4/n);break}i.clearRect(0,0,n,n);i.strokeText("A",0,n);d=i.getImageData(0,0,n,n).data;l=0;for(let t=0,e=d.length;t0){l=n-Math.floor(t/4/n);break}i.canvas.width=i.canvas.height=0;i.font=s;if(l){const e=l/(l+h);r.set(t,e);return e}r.set(t,a);return a}(u);let m,f;if(0===d){m=h[4];f=h[5]-g}else{m=h[4]+g*Math.sin(d);f=h[5]-g*Math.cos(d)}const b="calc(var(--scale-factor)*",A=o.style;if(t._container===t._rootContainer){A.left=`${(100*m/t._pageWidth).toFixed(2)}%`;A.top=`${(100*f/t._pageHeight).toFixed(2)}%`}else{A.left=`${b}${m.toFixed(2)}px)`;A.top=`${b}${f.toFixed(2)}px)`}A.fontSize=`${b}${p.toFixed(2)}px)`;A.fontFamily=u;l.fontSize=p;o.setAttribute("role","presentation");o.textContent=e.str;o.dir=e.dir;t._fontInspectorEnabled&&(o.dataset.fontName=c.fontSubstitutionLoadedName||e.fontName);0!==d&&(l.angle=d*(180/Math.PI));let v=!1;if(e.str.length>1)v=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),i=Math.abs(e.transform[3]);t!==i&&Math.max(t,i)/Math.min(t,i)>1.5&&(v=!0)}v&&(l.canvasWidth=c.vertical?e.height:e.width);t._textDivProperties.set(o,l);t._isReadableStream&&t._layoutText(o)}function layout(t){const{div:e,scale:i,properties:s,ctx:n,prevFontSize:a,prevFontFamily:r}=t,{style:o}=e;let l="";if(0!==s.canvasWidth&&s.hasText){const{fontFamily:h}=o,{canvasWidth:d,fontSize:c}=s;if(a!==c||r!==h){n.font=`${c*i}px ${h}`;t.prevFontSize=c;t.prevFontFamily=h}const{width:u}=n.measureText(e.textContent);u>0&&(l=`scaleX(${d*i/u})`)}0!==s.angle&&(l=`rotate(${s.angle}deg) ${l}`);l.length>0&&(o.transform=l)}class TextLayerRenderTask{constructor({textContentSource:t,container:e,viewport:i,textDivs:n,textDivProperties:a,textContentItemsStr:r}){this._textContentSource=t;this._isReadableStream=t instanceof ReadableStream;this._container=this._rootContainer=e;this._textDivs=n||[];this._textContentItemsStr=r||[];this._fontInspectorEnabled=!!globalThis.FontInspector?.enabled;this._reader=null;this._textDivProperties=a||new WeakMap;this._canceled=!1;this._capability=Promise.withResolvers();this._layoutTextParams={prevFontSize:null,prevFontFamily:null,div:null,scale:i.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:getCtx()};const{pageWidth:o,pageHeight:l,pageX:h,pageY:d}=i.rawDims;this._transform=[1,0,0,-1,-h,d+l];this._pageWidth=o;this._pageHeight=l;(0,s.setLayerDimensions)(e,i);this._capability.promise.finally((()=>{this._layoutTextParams=null})).catch((()=>{}))}get promise(){return this._capability.promise}cancel(){this._canceled=!0;if(this._reader){this._reader.cancel(new i.AbortException("TextLayer task cancelled.")).catch((()=>{}));this._reader=null}this._capability.reject(new i.AbortException("TextLayer task cancelled."))}_processItems(t,e){for(const i of t)if(void 0!==i.str){this._textContentItemsStr.push(i.str);appendText(this,i,e)}else if("beginMarkedContentProps"===i.type||"beginMarkedContent"===i.type){const t=this._container;this._container=document.createElement("span");this._container.classList.add("markedContent");null!==i.id&&this._container.setAttribute("id",`${i.id}`);t.append(this._container)}else"endMarkedContent"===i.type&&(this._container=this._container.parentNode)}_layoutText(t){const e=this._layoutTextParams.properties=this._textDivProperties.get(t);this._layoutTextParams.div=t;layout(this._layoutTextParams);e.hasText&&this._container.append(t);if(e.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation");this._container.append(t)}}_render(){const{promise:t,resolve:e,reject:i}=Promise.withResolvers();let s=Object.create(null);if(this._isReadableStream){const pump=()=>{this._reader.read().then((({value:t,done:i})=>{if(i)e();else{Object.assign(s,t.styles);this._processItems(t.items,s);pump()}}),i)};this._reader=this._textContentSource.getReader();pump()}else{if(!this._textContentSource)throw new Error('No "textContentSource" parameter specified.');{const{items:t,styles:i}=this._textContentSource;this._processItems(t,i);e()}}t.then((()=>{s=null;!function render(t){if(t._canceled)return;const e=t._textDivs,i=t._capability;if(e.length>1e5)i.resolve();else{if(!t._isReadableStream)for(const i of e)t._layoutText(i);i.resolve()}}(this)}),this._capability.reject)}}function renderTextLayer(t){const e=new TextLayerRenderTask(t);e._render();return e}function updateTextLayer({container:t,viewport:e,textDivs:i,textDivProperties:n,mustRotate:a=!0,mustRescale:r=!0}){a&&(0,s.setLayerDimensions)(t,{rotation:e.rotation});if(r){const t=getCtx(),s={prevFontSize:null,prevFontFamily:null,div:null,scale:e.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:t};for(const t of i){s.properties=n.get(t);s.div=t;layout(s)}}}},585:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{PDFDataTransportStream:()=>PDFDataTransportStream});var i=e(292),s=e(419);class PDFDataTransportStream{constructor(t,{disableRange:e=!1,disableStream:s=!1}){(0,i.assert)(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:n,initialData:a,progressiveDone:r,contentDispositionFilename:o}=t;this._queuedChunks=[];this._progressiveDone=r;this._contentDispositionFilename=o;if(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=!e;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({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const e=this._rangeReaders.some((function(e){if(e._begin!==t)return!1;e._enqueue(s);return!0}));(0,i.assert)(e,"_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(){(0,i.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;this._queuedChunks=null;return new PDFDataTransportStreamReader(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new PDFDataTransportStreamRangeReader(this,t,e);this._pdfDataRangeTransport.requestDataRange(t,e);this._rangeReaders.push(i);return i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class PDFDataTransportStreamReader{constructor(t,e,i=!1,n=null){this._stream=t;this._done=i||!1;this._filename=(0,s.isPdfFile)(n)?n:null;this._queuedChunks=e||[];this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.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();this._requests.push(t);return t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class PDFDataTransportStreamRangeReader{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;this._queuedChunk=null;return{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();this._requests.push(t);return t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0;this._stream._removeRangeReader(this)}}},164:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{GlobalWorkerOptions:()=>GlobalWorkerOptions});class GlobalWorkerOptions{static#ar=null;static#rr="";static get workerPort(){return this.#ar}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#ar=t}static get workerSrc(){return this.#rr}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#rr=t}}},284:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{XfaLayer:()=>XfaLayer});var i=e(50);class XfaLayer{static setupStorage(t,e,i,s,n){const a=s.getValue(e,{value:null});switch(i.name){case"textarea":null!==a.value&&(t.textContent=a.value);if("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){a.value===i.attributes.xfaOn?t.setAttribute("checked",!0):a.value===i.attributes.xfaOff&&t.removeAttribute("checked");if("print"===n)break;t.addEventListener("change",(t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{null!==a.value&&t.setAttribute("value",a.value);if("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({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:a}=e,r=t instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${s}`);for(const[e,i]of Object.entries(a))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!r||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}r&&n.addLinkAttributes(t,a.href,a.newWindow);i&&a.dataId&&this.setupStorage(t,a.dataId,e,i)}static render(t){const e=t.annotationStorage,s=t.linkService,n=t.xfaHtml,a=t.intent||"display",r=document.createElement(n.name);n.attributes&&this.setAttributes({html:r,element:n,intent:a,linkService:s});const o="richText"!==a,l=t.div;l.append(r);if(t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=e}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(0===n.children.length){if(n.value){const t=document.createTextNode(n.value);r.append(t);o&&i.XfaText.shouldBuildText(n.name)&&h.push(t)}return{textDivs:h}}const d=[[n,-1,r]];for(;d.length>0;){const[t,n,r]=d.at(-1);if(n+1===t.children.length){d.pop();continue}const l=t.children[++d.at(-1)[1]];if(null===l)continue;const{name:c}=l;if("#text"===c){const t=document.createTextNode(l.value);h.push(t);r.append(t);continue}const u=l?.attributes?.xmlns?document.createElementNS(l.attributes.xmlns,c):document.createElement(c);r.append(u);l.attributes&&this.setAttributes({html:u,element:l,storage:e,intent:a,linkService:s});if(l.children?.length>0)d.push([l,-1,u]);else if(l.value){const t=document.createTextNode(l.value);o&&i.XfaText.shouldBuildText(c)&&h.push(t);u.append(t)}}for(const t of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e;t.div.hidden=!1}}},50:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{XfaText:()=>XfaText});class XfaText{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};!function walk(t){if(!t)return;let i=null;const s=t.name;if("#text"===s)i=t.value;else{if(!XfaText.shouldBuildText(s))return;t?.attributes?.textContent?i=t.attributes.textContent:t.value&&(i=t.value)}null!==i&&e.push({str:i});if(t.children)for(const e of t.children)walk(e)}(t);return i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}},228:(t,__webpack_exports__,e)=>{e.a(t,(async(t,i)=>{try{e.d(__webpack_exports__,{AbortException:()=>s.AbortException,AnnotationEditorLayer:()=>o.AnnotationEditorLayer,AnnotationEditorParamsType:()=>s.AnnotationEditorParamsType,AnnotationEditorType:()=>s.AnnotationEditorType,AnnotationEditorUIManager:()=>l.AnnotationEditorUIManager,AnnotationLayer:()=>h.AnnotationLayer,AnnotationMode:()=>s.AnnotationMode,CMapCompressionType:()=>s.CMapCompressionType,ColorPicker:()=>d.ColorPicker,DOMSVGFactory:()=>a.DOMSVGFactory,DrawLayer:()=>c.DrawLayer,FeatureTest:()=>s.FeatureTest,GlobalWorkerOptions:()=>u.GlobalWorkerOptions,ImageKind:()=>s.ImageKind,InvalidPDFException:()=>s.InvalidPDFException,MissingPDFException:()=>s.MissingPDFException,OPS:()=>s.OPS,Outliner:()=>p.Outliner,PDFDataRangeTransport:()=>n.PDFDataRangeTransport,PDFDateString:()=>a.PDFDateString,PDFWorker:()=>n.PDFWorker,PasswordResponses:()=>s.PasswordResponses,PermissionFlag:()=>s.PermissionFlag,PixelsPerInch:()=>a.PixelsPerInch,RenderingCancelledException:()=>a.RenderingCancelledException,UnexpectedResponseException:()=>s.UnexpectedResponseException,Util:()=>s.Util,VerbosityLevel:()=>s.VerbosityLevel,XfaLayer:()=>g.XfaLayer,build:()=>n.build,createValidAbsoluteUrl:()=>s.createValidAbsoluteUrl,fetchData:()=>a.fetchData,getDocument:()=>n.getDocument,getFilenameFromUrl:()=>a.getFilenameFromUrl,getPdfFilenameFromUrl:()=>a.getPdfFilenameFromUrl,getXfaPageViewport:()=>a.getXfaPageViewport,isDataScheme:()=>a.isDataScheme,isPdfFile:()=>a.isPdfFile,noContextMenu:()=>a.noContextMenu,normalizeUnicode:()=>s.normalizeUnicode,renderTextLayer:()=>r.renderTextLayer,setLayerDimensions:()=>a.setLayerDimensions,shadow:()=>s.shadow,updateTextLayer:()=>r.updateTextLayer,version:()=>n.version});var s=e(292),n=e(831),a=e(419),r=e(814),o=e(731),l=e(830),h=e(976),d=e(259),c=e(47),u=e(164),p=e(61),g=e(284),m=t([n]);n=(m.then?(await m)():m)[0];i()}catch(t){i(t)}}))},178:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{MessageHandler:()=>MessageHandler});var i=e(292);const s=1,n=2,a=1,r=2,o=3,l=4,h=5,d=6,c=7,u=8;function wrapReason(t){t instanceof Error||"object"==typeof t&&null!==t||(0,i.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.');switch(t.name){case"AbortException":return new i.AbortException(t.message);case"MissingPDFException":return new i.MissingPDFException(t.message);case"PasswordException":return new i.PasswordException(t.message,t.code);case"UnexpectedResponseException":return new i.UnexpectedResponseException(t.message,t.status);case"UnknownErrorException":return new i.UnknownErrorException(t.message,t.details);default:return new i.UnknownErrorException(t.message,t.toString())}}class MessageHandler{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);this._onComObjOnMessage=t=>{const e=t.data;if(e.targetName!==this.sourceName)return;if(e.stream){this.#or(e);return}if(e.callback){const t=e.callbackId,i=this.callbackCapabilities[t];if(!i)throw new Error(`Cannot resolve callback ${t}`);delete this.callbackCapabilities[t];if(e.callback===s)i.resolve(e.data);else{if(e.callback!==n)throw new Error("Unexpected callback case");i.reject(wrapReason(e.reason))}return}const a=this.actionHandler[e.action];if(!a)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const t=this.sourceName,r=e.sourceName;new Promise((function(t){t(a(e.data))})).then((function(n){i.postMessage({sourceName:t,targetName:r,callback:s,callbackId:e.callbackId,data:n})}),(function(s){i.postMessage({sourceName:t,targetName:r,callback:n,callbackId:e.callbackId,reason:wrapReason(s)})}))}else e.streamId?this.#lr(e):a(e.data)};i.addEventListener("message",this._onComObjOnMessage)}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(t){n.reject(t)}return n.promise}sendWithStream(t,e,s,n){const r=this.streamId++,o=this.sourceName,l=this.targetName,h=this.comObj;return new ReadableStream({start:i=>{const s=Promise.withResolvers();this.streamControllers[r]={controller:i,startCall:s,pullCall:null,cancelCall:null,isClosed:!1};h.postMessage({sourceName:o,targetName:l,action:t,streamId:r,data:e,desiredSize:i.desiredSize},n);return s.promise},pull:t=>{const e=Promise.withResolvers();this.streamControllers[r].pullCall=e;h.postMessage({sourceName:o,targetName:l,stream:d,streamId:r,desiredSize:t.desiredSize});return e.promise},cancel:t=>{(0,i.assert)(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();this.streamControllers[r].cancelCall=e;this.streamControllers[r].isClosed=!0;h.postMessage({sourceName:o,targetName:l,stream:a,streamId:r,reason:wrapReason(t)});return e.promise}},s)}#lr(t){const e=t.streamId,s=this.sourceName,n=t.sourceName,a=this.comObj,r=this,d=this.actionHandler[t.action],c={enqueue(t,i=1,r){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=i;if(o>0&&this.desiredSize<=0){this.sinkCapability=Promise.withResolvers();this.ready=this.sinkCapability.promise}a.postMessage({sourceName:s,targetName:n,stream:l,streamId:e,chunk:t},r)},close(){if(!this.isCancelled){this.isCancelled=!0;a.postMessage({sourceName:s,targetName:n,stream:o,streamId:e});delete r.streamSinks[e]}},error(t){(0,i.assert)(t instanceof Error,"error must have a valid reason");if(!this.isCancelled){this.isCancelled=!0;a.postMessage({sourceName:s,targetName:n,stream:h,streamId:e,reason:wrapReason(t)})}},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};c.sinkCapability.resolve();c.ready=c.sinkCapability.promise;this.streamSinks[e]=c;new Promise((function(e){e(d(t.data,c))})).then((function(){a.postMessage({sourceName:s,targetName:n,stream:u,streamId:e,success:!0})}),(function(t){a.postMessage({sourceName:s,targetName:n,stream:u,streamId:e,reason:wrapReason(t)})}))}#or(t){const e=t.streamId,s=this.sourceName,n=t.sourceName,p=this.comObj,g=this.streamControllers[e],m=this.streamSinks[e];switch(t.stream){case u:t.success?g.startCall.resolve():g.startCall.reject(wrapReason(t.reason));break;case c:t.success?g.pullCall.resolve():g.pullCall.reject(wrapReason(t.reason));break;case d:if(!m){p.postMessage({sourceName:s,targetName:n,stream:c,streamId:e,success:!0});break}m.desiredSize<=0&&t.desiredSize>0&&m.sinkCapability.resolve();m.desiredSize=t.desiredSize;new Promise((function(t){t(m.onPull?.())})).then((function(){p.postMessage({sourceName:s,targetName:n,stream:c,streamId:e,success:!0})}),(function(t){p.postMessage({sourceName:s,targetName:n,stream:c,streamId:e,reason:wrapReason(t)})}));break;case l:(0,i.assert)(g,"enqueue should have stream controller");if(g.isClosed)break;g.controller.enqueue(t.chunk);break;case o:(0,i.assert)(g,"close should have stream controller");if(g.isClosed)break;g.isClosed=!0;g.controller.close();this.#hr(g,e);break;case h:(0,i.assert)(g,"error should have stream controller");g.controller.error(wrapReason(t.reason));this.#hr(g,e);break;case r:t.success?g.cancelCall.resolve():g.cancelCall.reject(wrapReason(t.reason));this.#hr(g,e);break;case a:if(!m)break;new Promise((function(e){e(m.onCancel?.(wrapReason(t.reason)))})).then((function(){p.postMessage({sourceName:s,targetName:n,stream:r,streamId:e,success:!0})}),(function(t){p.postMessage({sourceName:s,targetName:n,stream:r,streamId:e,reason:wrapReason(t)})}));m.sinkCapability.reject(wrapReason(t.reason));m.isCancelled=!0;delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#hr(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]);delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},651:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{MurmurHash3_64:()=>MurmurHash3_64});const i=3285377520,s=4294901760,n=65535;class MurmurHash3_64{constructor(t){this.h1=t?4294967295&t:i;this.h2=t?4294967295&t:i}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>>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 a=i>>2,r=i-4*a,o=new Uint32Array(e.buffer,0,a);let l=0,h=0,d=this.h1,c=this.h2;const u=3432918353,p=461845907,g=11601,m=13715;for(let t=0;t>>17;l=l*p&s|l*m&n;d^=l;d=d<<13|d>>>19;d=5*d+3864292196}else{h=o[t];h=h*u&s|h*g&n;h=h<<15|h>>>17;h=h*p&s|h*m&n;c^=h;c=c<<13|c>>>19;c=5*c+3864292196}l=0;switch(r){case 3:l^=e[4*a+2]<<16;case 2:l^=e[4*a+1]<<8;case 1:l^=e[4*a];l=l*u&s|l*g&n;l=l<<15|l>>>17;l=l*p&s|l*m&n;1&a?d^=l:c^=l}this.h1=d;this.h2=c}hexdigest(){let t=this.h1,e=this.h2;t^=e>>>1;t=3981806797*t&s|36045*t&n;e=4283543511*e&s|(2950163797*(e<<16|t>>>16)&s)>>>16;t^=e>>>1;t=444984403*t&s|60499*t&n;e=3301882366*e&s|(3120437893*(e<<16|t>>>16)&s)>>>16;t^=e>>>1;return(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}},292:(t,__webpack_exports__,e)=>{e.d(__webpack_exports__,{AbortException:()=>AbortException,AnnotationBorderStyleType:()=>f,AnnotationEditorParamsType:()=>c,AnnotationEditorPrefix:()=>h,AnnotationEditorType:()=>d,AnnotationMode:()=>l,AnnotationPrefix:()=>S,AnnotationType:()=>m,BaseException:()=>w,CMapCompressionType:()=>A,FONT_IDENTITY_MATRIX:()=>n,FeatureTest:()=>FeatureTest,FontRenderOps:()=>C,FormatError:()=>FormatError,IDENTITY_MATRIX:()=>s,ImageKind:()=>g,InvalidPDFException:()=>InvalidPDFException,LINE_FACTOR:()=>r,MAX_IMAGE_SIZE_TO_CACHE:()=>a,MissingPDFException:()=>MissingPDFException,OPS:()=>v,PasswordException:()=>PasswordException,PasswordResponses:()=>y,PermissionFlag:()=>u,RenderingIntentFlag:()=>o,TextRenderingMode:()=>p,UnexpectedResponseException:()=>UnexpectedResponseException,UnknownErrorException:()=>UnknownErrorException,Util:()=>Util,VerbosityLevel:()=>b,assert:()=>assert,bytesToString:()=>bytesToString,createValidAbsoluteUrl:()=>createValidAbsoluteUrl,getUuid:()=>getUuid,getVerbosityLevel:()=>getVerbosityLevel,info:()=>info,isNodeJS:()=>i,normalizeUnicode:()=>normalizeUnicode,objectFromMap:()=>objectFromMap,setVerbosityLevel:()=>setVerbosityLevel,shadow:()=>shadow,string32:()=>string32,stringToBytes:()=>stringToBytes,unreachable:()=>unreachable,warn:()=>warn});const i=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),s=[1,0,0,1,0,0],n=[.001,0,0,.001,0,0],a=1e7,r=1.35,o={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},l={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},h="pdfjs_internal_editor_",d={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},c={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},u={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},p={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},g={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},m={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},f={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},b={ERRORS:0,WARNINGS:1,INFOS:5},A={NONE:0,BINARY:1},v={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},y={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let E=b.WARNINGS;function setVerbosityLevel(t){Number.isInteger(t)&&(E=t)}function getVerbosityLevel(){return E}function info(t){E>=b.INFOS&&console.log(`Info: ${t}`)}function warn(t){E>=b.WARNINGS&&console.log(`Warning: ${t}`)}function unreachable(t){throw new Error(t)}function assert(t,e){t||unreachable(e)}function createValidAbsoluteUrl(t,e=null,i=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}`)}if(i.tryConvertEncoding)try{t=function stringToUTF8String(t){return decodeURIComponent(escape(t))}(t)}catch{}}const s=e?new URL(t,e):new URL(t);if(function _isValidProtocol(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 shadow(t,e,i,s=!1){Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1});return i}const w=function BaseExceptionClosure(){function BaseException(t,e){this.constructor===BaseException&&unreachable("Cannot initialize BaseException.");this.message=t;this.name=e}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();class PasswordException extends w{constructor(t,e){super(t,"PasswordException");this.code=e}}class UnknownErrorException extends w{constructor(t,e){super(t,"UnknownErrorException");this.details=e}}class InvalidPDFException extends w{constructor(t){super(t,"InvalidPDFException")}}class MissingPDFException extends w{constructor(t){super(t,"MissingPDFException")}}class UnexpectedResponseException extends w{constructor(t,e){super(t,"UnexpectedResponseException");this.status=e}}class FormatError extends w{constructor(t){super(t,"FormatError")}}class AbortException extends w{constructor(t){super(t,"AbortException")}}function bytesToString(t){"object"==typeof t&&void 0!==t?.length||unreachable("Invalid argument for bytesToString");const e=t.length,i=8192;if(e>24&255,t>>16&255,t>>8&255,255&t)}function objectFromMap(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e}class FeatureTest{static get isLittleEndian(){return shadow(this,"isLittleEndian",function isLittleEndian(){const t=new Uint8Array(4);t[0]=1;return 1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return shadow(this,"isEvalSupported",function isEvalSupported(){try{new Function("");return!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?shadow(this,"platform",{isMac:navigator.platform.includes("Mac")}):shadow(this,"platform",{isMac:!1})}static get isCSSRoundSupported(){return shadow(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const _=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));class Util{static makeHexColor(t,e,i){return`#${_[t]}${_[e]}${_[i]}`}static scaleMinMax(t,e){let i;if(t[0]){if(t[0]<0){i=e[0];e[0]=e[2];e[2]=i}e[0]*=t[0];e[2]*=t[0];if(t[3]<0){i=e[1];e[1]=e[3];e[3]=i}e[1]*=t[3];e[3]*=t[3]}else{i=e[0];e[0]=e[1];e[1]=i;i=e[2];e[2]=e[3];e[3]=i;if(t[1]<0){i=e[1];e[1]=e[3];e[3]=i}e[1]*=t[1];e[3]*=t[1];if(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);if(t[0]>t[2]){e[0]=t[2];e[2]=t[0]}if(t[1]>t[3]){e[1]=t[3];e[3]=t[1]}return 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#dr(t,e,i,s,n,a,r,o,l,h){if(l<=0||l>=1)return;const d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*n+3*l*a)+3*c*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#cr(t,e,i,s,n,a,r,o,l,h,d,c){if(Math.abs(l)<1e-12){Math.abs(h)>=1e-12&&this.#dr(t,e,i,s,n,a,r,o,-d/h,c);return}const u=h**2-4*d*l;if(u<0)return;const p=Math.sqrt(u),g=2*l;this.#dr(t,e,i,s,n,a,r,o,(-h+p)/g,c);this.#dr(t,e,i,s,n,a,r,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,n,a,r,o,l){if(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)}else l=[Math.min(t,r),Math.min(e,o),Math.max(t,r),Math.max(e,o)];this.#cr(t,i,n,r,e,s,a,o,3*(3*(i-n)-t+r),6*(t-2*i+n),3*(i-t),l);this.#cr(t,i,n,r,e,s,a,o,3*(3*(s-a)-e+o),6*(e-2*s+a),3*(s-e),l);return l}}let x=null,T=null;function normalizeUnicode(t){if(!x){x=/([\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;T=new Map([["ſt","ſt"]])}return t.replaceAll(x,((t,e,i)=>e?e.normalize("NFKC"):T.get(i)))}function getUuid(){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 bytesToString(t)}const S="pdfjs_internal_id_",C={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8}}},a={};function __webpack_require__(t){var e=a[t];if(void 0!==e)return e.exports;var i=a[t]={exports:{}};n[t](i,i.exports,__webpack_require__);return i.exports}t="function"==typeof Symbol?Symbol("webpack queues"):"__webpack_queues__",e="function"==typeof Symbol?Symbol("webpack exports"):"__webpack_exports__",i="function"==typeof Symbol?Symbol("webpack error"):"__webpack_error__",s=t=>{if(t&&t.d<1){t.d=1;t.forEach((t=>t.r--));t.forEach((t=>t.r--?t.r++:t()))}},__webpack_require__.a=(n,a,r)=>{var o;r&&((o=[]).d=-1);var l,h,d,c=new Set,u=n.exports,p=new Promise(((t,e)=>{d=e;h=t}));p[e]=u;p[t]=t=>(o&&t(o),c.forEach(t),p.catch((t=>{})));n.exports=p;a((n=>{l=(n=>n.map((n=>{if(null!==n&&"object"==typeof n){if(n[t])return n;if(n.then){var a=[];a.d=0;n.then((t=>{r[e]=t;s(a)}),(t=>{r[i]=t;s(a)}));var r={};r[t]=t=>t(a);return r}}var o={};o[t]=t=>{};o[e]=n;return o})))(n);var a,getResult=()=>l.map((t=>{if(t[i])throw t[i];return t[e]})),r=new Promise((e=>{(a=()=>e(getResult)).r=0;var fnQueue=t=>t!==o&&!c.has(t)&&(c.add(t),t&&!t.d&&(a.r++,t.push(a)));l.map((e=>e[t](fnQueue)))}));return a.r?r:getResult()}),(t=>(t?d(p[i]=t):h(u),s(o))));o&&o.d<0&&(o.d=0)};__webpack_require__.d=(t,e)=>{for(var i in e)__webpack_require__.o(e,i)&&!__webpack_require__.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})};__webpack_require__.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var __webpack_exports__=__webpack_require__(228),r=(__webpack_exports__=globalThis.pdfjsLib=await (globalThis.pdfjsLibPromise=__webpack_exports__)).AbortException,o=__webpack_exports__.AnnotationEditorLayer,l=__webpack_exports__.AnnotationEditorParamsType,h=__webpack_exports__.AnnotationEditorType,d=__webpack_exports__.AnnotationEditorUIManager,c=__webpack_exports__.AnnotationLayer,u=__webpack_exports__.AnnotationMode,p=__webpack_exports__.CMapCompressionType,g=__webpack_exports__.ColorPicker,m=__webpack_exports__.DOMSVGFactory,f=__webpack_exports__.DrawLayer,b=__webpack_exports__.FeatureTest,A=__webpack_exports__.GlobalWorkerOptions,v=__webpack_exports__.ImageKind,y=__webpack_exports__.InvalidPDFException,E=__webpack_exports__.MissingPDFException,w=__webpack_exports__.OPS,_=__webpack_exports__.Outliner,x=__webpack_exports__.PDFDataRangeTransport,T=__webpack_exports__.PDFDateString,S=__webpack_exports__.PDFWorker,C=__webpack_exports__.PasswordResponses,M=__webpack_exports__.PermissionFlag,P=__webpack_exports__.PixelsPerInch,R=__webpack_exports__.RenderingCancelledException,F=__webpack_exports__.UnexpectedResponseException,k=__webpack_exports__.Util,D=__webpack_exports__.VerbosityLevel,I=__webpack_exports__.XfaLayer,L=__webpack_exports__.build,O=__webpack_exports__.createValidAbsoluteUrl,N=__webpack_exports__.fetchData,B=__webpack_exports__.getDocument,H=__webpack_exports__.getFilenameFromUrl,U=__webpack_exports__.getPdfFilenameFromUrl,z=__webpack_exports__.getXfaPageViewport,V=__webpack_exports__.isDataScheme,j=__webpack_exports__.isPdfFile,G=__webpack_exports__.noContextMenu,$=__webpack_exports__.normalizeUnicode,W=__webpack_exports__.renderTextLayer,q=__webpack_exports__.setLayerDimensions,K=__webpack_exports__.shadow,X=__webpack_exports__.updateTextLayer,Y=__webpack_exports__.version;export{r as AbortException,o as AnnotationEditorLayer,l as AnnotationEditorParamsType,h as AnnotationEditorType,d as AnnotationEditorUIManager,c as AnnotationLayer,u as AnnotationMode,p as CMapCompressionType,g as ColorPicker,m as DOMSVGFactory,f as DrawLayer,b as FeatureTest,A as GlobalWorkerOptions,v as ImageKind,y as InvalidPDFException,E as MissingPDFException,w as OPS,_ as Outliner,x as PDFDataRangeTransport,T as PDFDateString,S as PDFWorker,C as PasswordResponses,M as PermissionFlag,P as PixelsPerInch,R as RenderingCancelledException,F as UnexpectedResponseException,k as Util,D as VerbosityLevel,I as XfaLayer,L as build,O as createValidAbsoluteUrl,N as fetchData,B as getDocument,H as getFilenameFromUrl,U as getPdfFilenameFromUrl,z as getXfaPageViewport,V as isDataScheme,j as isPdfFile,G as noContextMenu,$ as normalizeUnicode,W as renderTextLayer,q as setLayerDimensions,K as shadow,X as updateTextLayer,Y as version}; \ No newline at end of file