ngx-extended-pdf-viewer
Version:
Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.
38 lines • 1.34 MB
JavaScript
/**
* @licstart The following is the entire license notice for the
* JavaScript code in this page
*
* Copyright 2024 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
*/
/**
* pdfjsVersion = 6.2.1097
* pdfjsBuild = 0c545ef64
*/
class ngx_console_NgxConsole{static log(e,t){ngx_console_NgxConsole.ngxConsoleFilter("log",e)&&(void 0!==t?console.log("%s",e,t):console.log(e))}static error(e,t){ngx_console_NgxConsole.ngxConsoleFilter("error",e)&&(void 0!==t?console.error("%s",e,t):console.error(e))}static warn(e,t){ngx_console_NgxConsole.ngxConsoleFilter("warn",e)&&(void 0!==t?console.warn("%s",e,t):console.warn(e))}static debug(e,t){ngx_console_NgxConsole.ngxConsoleFilter("debug",e)&&(void 0!==t?console.warn("%s",e,t):console.warn(e))}get ngxConsoleFilter(){return ngx_console_NgxConsole.ngxConsoleFilter}set ngxConsoleFilter(e){ngx_console_NgxConsole.ngxConsoleFilter=e}reset(){ngx_console_NgxConsole.ngxConsoleFilter=(e,t)=>!0}}!function _defineProperty(e,t,i){return(t=function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(ngx_console_NgxConsole,"ngxConsoleFilter",(e,t)=>!0);var e;function _assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const t=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),i=[1/0,1/0,-1/0,-1/0],a=new Float32Array(i),s=[.001,0,0,.001,0,0],n="http://www.w3.org/2000/svg",r=1,o=2,l=4,d=16,c=32,h=64,u=128,_=256,p={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},g="pdfjs_internal_id_",m="pdfjs_internal_editor_",f={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},v={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,INK_COLOR_AND_OPACITY:24,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},P={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},w=0,F=1,b=2,y=3,S=3,C=4,x={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},k={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,RICHMEDIA:27},E=1,A=2,G=3,B=4,M=5,I={ERRORS:0,WARNINGS:1,INFOS:5},T={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},D=0,L=1,N=2,R=3,O=4,W={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let j=I.WARNINGS;function setVerbosityLevel(e){Number.isInteger(e)&&(j=e)}function getVerbosityLevel(){return j}function info(e){j>=I.INFOS&&("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope||Window&&ngx_console_NgxConsole?ngx_console_NgxConsole.log(`Info: ${e}`):console.log(`Info: ${e}`))}function warn(e){j>=I.WARNINGS&&("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope||Window&&ngx_console_NgxConsole?ngx_console_NgxConsole.log(`Warning: ${e}`):console.log(`Warning: ${e}`))}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function createValidAbsoluteUrl(e,t=null,i=null){if(!e)return null;if(i&&"string"==typeof e){if(i.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(i.tryConvertEncoding)try{e=function stringToUTF8String(e){return decodeURIComponent(escape(e))}(e)}catch{}}const a=t?URL.parse(e,t):URL.parse(e);return function _isValidProtocol(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":case"capacitor":return!0;default:return!1}}(a)?a:null}function updateUrlHash(e,t,i=!1){const a=URL.parse(e);if(a){a.hash=t;return a.href}return i&&createValidAbsoluteUrl(e,"http://example.com")?e.split("#",1)[0]+""+(t?`#${t}`:""):""}function stripPath(e){return e.substring(e.lastIndexOf("/")+1)}function shadow(e,t,i,a=!1){Object.defineProperty(e,t,{value:i,enumerable:!a,configurable:!0,writable:!1});return i}const V=function BaseExceptionClosure(){function BaseException(e,t){this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();class PasswordException extends V{constructor(e,t){super(e,"PasswordException");this.code=t}}class UnknownErrorException extends V{constructor(e,t){super(e,"UnknownErrorException");this.details=t}}class InvalidPDFException extends V{constructor(e){super(e,"InvalidPDFException")}}class ResponseException extends V{constructor(e,t,i){super(e,"ResponseException");this.status=t;this.missing=i}}class FormatError extends V{constructor(e){super(e,"FormatError")}}class AbortException extends V{constructor(e){super(e,"AbortException")}}function stringToBytes(e){"string"!=typeof e&&unreachable("Invalid argument for stringToBytes");const t=e.length,i=new Uint8Array(t);for(let a=0;a<t;++a)i[a]=255&e.charCodeAt(a);return i}class FeatureTest{static get isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return shadow(this,"isLittleEndian",1===new Uint32Array(e.buffer,0,1)[0])}static get isOffscreenCanvasSupported(){return shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return shadow(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get isFloat16ArraySupported(){return shadow(this,"isFloat16ArraySupported","undefined"!=typeof Float16Array)}static get isSanitizerSupported(){return shadow(this,"isSanitizerSupported","undefined"!=typeof Sanitizer)}static get platform(){const{platform:e,userAgent:t}=navigator;return shadow(this,"platform",{isAndroid:t.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:t.includes("Firefox")})}static get isCanvasFilterSupported(){let e;this.isOffscreenCanvasSupported?e=new OffscreenCanvas(1,1).getContext("2d"):"undefined"!=typeof document&&(e=document.createElement("canvas").getContext("2d"));return shadow(this,"isCanvasFilterSupported",void 0!==e?.filter)}static get isAlphaColorInputSupported(){if("undefined"==typeof document)return shadow(this,"isAlphaColorInputSupported",!1);const e=document.createElement("input");e.type="color";e.setAttribute("alpha","");e.value="#ff000080";return shadow(this,"isAlphaColorInputSupported","#ff0000"!==e.value)}static get isBackdropFilterSupported(){return shadow(this,"isBackdropFilterSupported","undefined"!=typeof CSS&&CSS.supports("backdrop-filter","blur(1px)"))}}class Util{static get hexNums(){return shadow(this,"hexNums",Array.from(Array(256).keys(),e=>e.toString(16).padStart(2,"0")))}static makeHexColor(e,t,i){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[i]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static multiplyByDOMMatrix(e,t){return[e[0]*t.a+e[2]*t.b,e[1]*t.a+e[3]*t.b,e[0]*t.c+e[2]*t.d,e[1]*t.c+e[3]*t.d,e[0]*t.e+e[2]*t.f+e[4],e[1]*t.e+e[3]*t.f+e[5]]}static applyTransform(e,t,i=0){const a=e[i],s=e[i+1];e[i]=a*t[0]+s*t[2]+t[4];e[i+1]=a*t[1]+s*t[3]+t[5]}static applyTransformToBezier(e,t,i=0){const a=t[0],s=t[1],n=t[2],r=t[3],o=t[4],l=t[5];for(let t=0;t<6;t+=2){const d=e[i+t],c=e[i+t+1];e[i+t]=d*a+c*n+o;e[i+t+1]=d*s+c*r+l}}static applyInverseTransform(e,t){const i=e[0],a=e[1],s=t[0]*t[3]-t[1]*t[2];e[0]=(i*t[3]-a*t[2]+t[2]*t[5]-t[4]*t[3])/s;e[1]=(-i*t[1]+a*t[0]+t[4]*t[1]-t[5]*t[0])/s}static axialAlignedBoundingBox(e,t,i){const a=t[0],s=t[1],n=t[2],r=t[3],o=t[4],l=t[5],d=e[0],c=e[1],h=e[2],u=e[3];let _=a*d+o,p=_,g=a*h+o,m=g,f=r*c+l,v=f,P=r*u+l,w=P;if(0!==s||0!==n){const e=s*d,t=s*h,i=n*c,a=n*u;_+=i;m+=i;g+=a;p+=a;f+=e;w+=e;P+=t;v+=t}i[0]=Math.min(i[0],_,g,p,m);i[1]=Math.min(i[1],f,P,v,w);i[2]=Math.max(i[2],_,g,p,m);i[3]=Math.max(i[3],f,P,v,w)}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){const i=e[0],a=e[1],s=e[2],n=e[3],r=i**2+a**2,o=i*s+a*n,l=s**2+n**2,d=(r+l)/2,c=Math.sqrt(d**2-(r*l-o**2));t[0]=Math.sqrt(d+c||1);t[1]=Math.sqrt(d-c||1)}static normalizeRect(e){const t=e.slice(0);if(e[0]>e[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){const i=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(i>a)return null;const s=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),n=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return s>n?null:[i,s,a,n]}static pointBoundingBox(e,t,i){i[0]=Math.min(i[0],e);i[1]=Math.min(i[1],t);i[2]=Math.max(i[2],e);i[3]=Math.max(i[3],t)}static rectBoundingBox(e,t,i,a,s){s[0]=Math.min(s[0],e,i);s[1]=Math.min(s[1],t,a);s[2]=Math.max(s[2],e,i);s[3]=Math.max(s[3],t,a)}static bezierBoundingBox(e,t,i,a,s,n,r,o,l){l[0]=Math.min(l[0],e,r);l[1]=Math.min(l[1],t,o);l[2]=Math.max(l[2],e,r);l[3]=Math.max(l[3],t,o);_assertClassBrand(Util,this,_getExtremum).call(this,e,i,s,r,t,a,n,o,3*(3*(i-s)-e+r),6*(e-2*i+s),3*(i-e),l);_assertClassBrand(Util,this,_getExtremum).call(this,e,i,s,r,t,a,n,o,3*(3*(a-n)-t+o),6*(t-2*a+n),3*(a-t),l)}}e=Util;function _getExtremumOnCurve(e,t,i,a,s,n,r,o,l,d){if(l<=0||l>=1)return;const c=1-l,h=l*l,u=h*l,_=c*(c*(c*e+3*l*t)+3*h*i)+u*a,p=c*(c*(c*s+3*l*n)+3*h*r)+u*o;d[0]=Math.min(d[0],_);d[1]=Math.min(d[1],p);d[2]=Math.max(d[2],_);d[3]=Math.max(d[3],p)}function _getExtremum(t,i,a,s,n,r,o,l,d,c,h,u){if(Math.abs(d)<1e-12){Math.abs(c)>=1e-12&&_assertClassBrand(e,this,_getExtremumOnCurve).call(this,t,i,a,s,n,r,o,l,-h/c,u);return}const _=c**2-4*h*d;if(_<0)return;const p=Math.sqrt(_),g=2*d;_assertClassBrand(e,this,_getExtremumOnCurve).call(this,t,i,a,s,n,r,o,l,(-c+p)/g,u);_assertClassBrand(e,this,_getExtremumOnCurve).call(this,t,i,a,s,n,r,o,l,(-c-p)/g,u)}let U=null,z=null;function normalizeUnicode(e){if(!U){U=/([\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;z=new Map([["ſt","ſt"]])}return e.replaceAll(U,(e,t,i)=>t?t.normalize("NFKC"):z.get(i))}function getUuid(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=new Uint8Array(32);crypto.getRandomValues(e);return function bytesToString(e){"object"==typeof e&&void 0!==e?.length||unreachable("Invalid argument for bytesToString");const t=e.length,i=8192;if(t<i)return String.fromCharCode.apply(null,e);const a=[];for(let s=0;s<t;s+=i){const n=Math.min(s+i,t),r=e.subarray(s,n);a.push(String.fromCharCode.apply(null,r))}return a.join("")}(e)}const makeArr=()=>[],makeMap=()=>new Map,makeObj=()=>Object.create(null);"function"!=typeof Iterator.prototype.join&&(Iterator.prototype.join=function(e){return[...this].join(e)});function MathClamp(e,t,i){return Math.min(Math.max(e,t),i)}class PageViewport{constructor({viewBox:e,userUnit:t,scale:i,rotation:a,offsetX:s=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=e;this.userUnit=t;this.scale=i;this.rotation=a;this.offsetX=s;this.offsetY=n;i*=t;const o=(e[2]+e[0])/2,l=(e[3]+e[1])/2;let d,c,h,u,_,p,g,m;(a%=360)<0&&(a+=360);switch(a){case 180:d=-1;c=0;h=0;u=1;break;case 90:d=0;c=1;h=1;u=0;break;case 270:d=0;c=-1;h=-1;u=0;break;case 0:d=1;c=0;h=0;u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(r){h=-h;u=-u}if(0===d){_=Math.abs(l-e[1])*i+s;p=Math.abs(o-e[0])*i+n;g=(e[3]-e[1])*i;m=(e[2]-e[0])*i}else{_=Math.abs(o-e[0])*i+s;p=Math.abs(l-e[1])*i+n;g=(e[2]-e[0])*i;m=(e[3]-e[1])*i}this.transform=[d*i,c*i,h*i,u*i,_-d*i*o-h*i*l,p-c*i*o-u*i*l];this.width=g;this.height=m}get rawDims(){const e=this.viewBox;return shadow(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:i=this.offsetX,offsetY:a=this.offsetY,dontFlip:s=!1}={}){return new PageViewport({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:t,offsetX:i,offsetY:a,dontFlip:s})}convertToViewportPoint(e,t){const i=[e,t];Util.applyTransform(i,this.transform);return i}convertToPdfPoint(e,t){const i=[e,t];Util.applyInverseTransform(i,this.transform);return i}}class XfaText{static textContent(e){const t=[],i={items:t,styles:Object.create(null)};!function walk(e){if(!e)return;let i=null;const a=e.name;if("#text"===a)i=e.value;else{if(!XfaText.shouldBuildText(a))return;e?.attributes?.textContent?i=e.attributes.textContent:e.value&&(i=e.value)}null!==i&&t.push({str:i});if(e.children)for(const t of e.children)walk(t)}(e);return i}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}function xfa_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const H=/url\(|image-set\(/i,$=/^on/i;class XfaLayer{static get _allowedHtmlElements(){return shadow(this,"_allowedHtmlElements",new Set(["a","b","br","button","div","i","img","input","label","li","ol","option","p","select","span","sub","sup","textarea","ul"]))}static get _allowedSvgElements(){return shadow(this,"_allowedSvgElements",new Set(["ellipse","line","path","rect","svg"]))}static get _allowedRichTextElements(){return shadow(this,"_allowedRichTextElements",new Set(["a","b","br","div","i","li","ol","p","span","sub","sup","ul"]))}static get _allowedRichTextAttributes(){return shadow(this,"_allowedRichTextAttributes",new Set(["class","dir","style"]))}static get _allowedRichTextStyles(){return shadow(this,"_allowedRichTextStyles",new Set(["color","font","fontFamily","fontSize","fontStretch","fontStyle","fontWeight","kerningMode","letterSpacing","lineHeight","margin","marginBottom","marginLeft","marginRight","marginTop","orphans","paddingLeft","paddingRight","breakAfter","breakBefore","breakInside","tabInterval","tabStop","textAlign","textDecoration","textIndent","transform","verticalAlign","widows"]))}static setupStorage(e,t,i,a,s){const n=window.getFormValueFromAngular(e);n.value&&a.setValue(t,n);const r=a.getValue(t,{value:null}),o=n.value?n:r;window.registerXFAField(e,o,r);e.addEventListener("updateFromAngular",e=>a.setValue(t,{value:e.detail}));switch(i.name){case"textarea":null!==o.value&&(e.textContent=o.value);if("print"===s)break;e.addEventListener("input",i=>{window.updateAngularFormValue(e,{value:i.target.value});a.setValue(t,{value:i.target.value})});break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){o.value===i.attributes.xfaOn?e.setAttribute("checked",!0):e.removeAttribute("checked");if("print"===s)break;e.addEventListener("change",i=>{window.updateAngularFormValue(e,{value:i.target.checked?i.target.getAttribute("xfaOn"):i.target.getAttribute("xfaOff")});a.setValue(t,{value:i.target.checked?i.target.getAttribute("xfaOn"):i.target.getAttribute("xfaOff")})})}else{null!==o.value&&e.setAttribute("value",o.value);if("print"===s)break;e.addEventListener("input",i=>{window.updateAngularFormValue(e,{value:i.target.value});a.setValue(t,{value:i.target.value})})}break;case"select":if(null!==o.value){e.setAttribute("value",o.value);for(const e of i.children)e.attributes.value===o.value?e.attributes.selected=!0:Object.hasOwn(e.attributes,"selected")&&delete e.attributes.selected}e.addEventListener("input",i=>{const s=i.target.options,n=-1===s.selectedIndex?"":s[s.selectedIndex].value;window.updateAngularFormValue(e,{value:n});a.setValue(t,{value:n})})}}static setAttributes({html:e,element:t,storage:i=null,intent:a,linkService:s}){const{attributes:n}=t,r=e instanceof HTMLAnchorElement;"radio"===n.type&&(n.name=`${n.name}-${a}`);for(const[t,i]of Object.entries(n))if(null!=i&&!$.test(t)&&("richText"!==a||this._allowedRichTextAttributes.has(t)))switch(t){case"class":i.length&&e.setAttribute(t,i.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",i);break;case"style":if("richText"===a){const t=this._allowedRichTextStyles;for(const[a,s]of Object.entries(i))t.has(a)&&!H.test(s)&&(e.style[a]=s)}else Object.assign(e.style,i);break;case"textContent":e.textContent=i;break;default:(!r||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,i)}r&&s?.addLinkAttributes(e,n.href,n.newWindow);i&&n.dataId&&this.setupStorage(e,n.dataId,t,i)}static render(e){const t=e.annotationStorage,i=e.linkService,a=e.xfaHtml,s=e.intent||"display",n=xfa_layer_assertClassBrand(XfaLayer,this,_createElement).call(this,a.name,a.attributes?.xmlns,s)??document.createElement("div");a.attributes&&this.setAttributes({html:n,element:a,intent:s,linkService:i});const r="richText"!==s,o=e.div;o.append(n);if(e.viewport){const t=`matrix(${e.viewport.transform.join(",")})`;o.style.transform=t}r&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===a.children.length){if(a.value){const e=document.createTextNode(a.value);n.append(e);r&&XfaText.shouldBuildText(a.name)&&l.push(e)}return{textDivs:l}}const d=[[a,-1,n]];for(;d.length>0;){const[e,a,n]=d.at(-1);if(a+1===e.children.length){d.pop();continue}const o=e.children[++d.at(-1)[1]];if(null===o)continue;const{name:c}=o;if("#text"===c){const e=document.createTextNode(o.value);l.push(e);n.append(e);continue}const h=xfa_layer_assertClassBrand(XfaLayer,this,_createElement).call(this,c,o.attributes?.xmlns,s);if(h){n.append(h);o.attributes&&this.setAttributes({html:h,element:o,storage:t,intent:s,linkService:i});if(o.children?.length>0)d.push([o,-1,h]);else if(o.value){const e=document.createTextNode(o.value);r&&XfaText.shouldBuildText(c)&&l.push(e);h.append(e)}}}for(const e of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:l}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t;e.div.hidden=!1}static getPageViewport(e,{scale:t=1,rotation:i=0}){const{width:a,height:s}=e.attributes.style;return new PageViewport({viewBox:[0,0,parseInt(a,10),parseInt(s,10)],userUnit:1,scale:t,rotation:i})}}function _createElement(e,t,i){return"richText"===i?!t&&this._allowedRichTextElements.has(e)?document.createElement(e):null:t?t===n&&this._allowedSvgElements.has(e)?document.createElementNS(n,e):null:this._allowedHtmlElements.has(e)?document.createElement(e):null}var K;function _classPrivateFieldInitSpec(e,t,i){(function _checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function _classPrivateFieldGet(e,t){return e.get(display_utils_assertClassBrand(e,t))}function display_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function display_utils_defineProperty(e,t,i){return(t=function display_utils_toPropertyKey(e){var t=function display_utils_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class PixelsPerInch{}K=PixelsPerInch;display_utils_defineProperty(PixelsPerInch,"CSS",96);display_utils_defineProperty(PixelsPerInch,"PDF",72);display_utils_defineProperty(PixelsPerInch,"PDF_TO_CSS_UNITS",K.CSS/K.PDF);async function fetchData(e,t="text"){if(isValidFetchUrl(e,document.baseURI)){const i=await fetch(e);if(!i.ok)throw new Error(i.statusText);switch(t){case"blob":return i.blob();case"bytes":return i.bytes();case"json":return i.json()}return i.text()}return new Promise((i,a)=>{const s=new XMLHttpRequest;s.open("GET",e,!0);s.responseType="bytes"===t?"arraybuffer":t;s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE)if(200!==s.status&&0!==s.status)a(new Error(s.statusText));else{switch(t){case"bytes":i(new Uint8Array(s.response));return;case"blob":case"json":i(s.response);return}i(s.responseText)}};s.send(null)})}class RenderingCancelledException extends V{constructor(e,t=0){super(e,"RenderingCancelledException");this.extraDelay=t}}function isDataScheme(e){const t=e.length;let i=0;for(;i<t&&""===e[i].trim();)i++;return"data:"===e.substring(i,i+5).toLowerCase()}function isPdfFile(e){return"string"==typeof e&&/\.pdf$/i.test(e)}function getPdfFilenameFromUrl(e,t="document.pdf"){if(t&&"document.pdf"!==t)return t;if("string"!=typeof e)return t;if(isDataScheme(e)){warn('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');return t}const i=(e=>{try{return new URL(e)}catch{}try{return new URL(decodeURIComponent(e))}catch{}try{return new URL(e,"https://foo.bar")}catch{}try{return new URL(decodeURIComponent(e),"https://foo.bar")}catch{}return null})(e);if(!i)return t;const decode=e=>{try{let t=decodeURIComponent(e);if(t.includes("/")){t=stripPath(t);if(4===t.length&&a.test(t))return e}return t}catch{return e}},a=/\.pdf$/i,s=stripPath(i.pathname);if(a.test(s))return decode(s);if(i.searchParams.size>0){const getLast=e=>[...e].findLast(e=>a.test(e)),e=getLast(i.searchParams.values())??getLast(i.searchParams.keys());if(e)return decode(e)}if(i.hash){const e=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(e)return decode(e[0])}return t}var X=new WeakMap;class StatTimer{constructor(){_classPrivateFieldInitSpec(this,X,new Map);display_utils_defineProperty(this,"times",[])}time(e){_classPrivateFieldGet(X,this).has(e)&&warn(`Timer is already running for ${e}`);_classPrivateFieldGet(X,this).set(e,Date.now())}timeEnd(e){_classPrivateFieldGet(X,this).has(e)||warn(`Timer has not been started for ${e}`);this.times.push({name:e,start:_classPrivateFieldGet(X,this).get(e),end:Date.now()});_classPrivateFieldGet(X,this).delete(e)}toString(){const e=Math.max(...this.times.map(e=>e.name.length));return this.times.map(t=>`${t.name.padEnd(e)} ${t.end-t.start}ms\n`).join("")}}function isValidFetchUrl(e,t){const i=t?URL.parse(e,t):URL.parse(e);return/https?:|blob:|capacitor:/.test(i?.protocol??"")}function noContextMenu(e){e.preventDefault()}function stopEvent(e){e.preventDefault();e.stopPropagation()}class PDFDateString{static toDateObject(e){if(e instanceof Date)return e;if(!e||"string"!=typeof e)return null;display_utils_assertClassBrand(PDFDateString,this,q)._||(q._=display_utils_assertClassBrand(PDFDateString,this,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+\\-])?(\\d{2})?'?(\\d{2})?'?")));const t=display_utils_assertClassBrand(PDFDateString,this,q)._.exec(e);if(!t)return null;const i=parseInt(t[1],10);let a=parseInt(t[2],10);a=a>=1&&a<=12?a-1:0;let s=parseInt(t[3],10);s=s>=1&&s<=31?s:1;let n=parseInt(t[4],10);n=n>=0&&n<=23?n:0;let r=parseInt(t[5],10);r=r>=0&&r<=59?r:0;let o=parseInt(t[6],10);o=o>=0&&o<=59?o:0;const l=t[7]||"Z";let d=parseInt(t[8],10);d=d>=0&&d<=23?d:0;let c=parseInt(t[9],10)||0;c=c>=0&&c<=59?c:0;if("-"===l){n+=d;r+=c}else if("+"===l){n-=d;r-=c}return new Date(Date.UTC(i,a,s,n,r,o))}}var q={_:void 0};function getRGBA(e){if(e.startsWith("#")){const t=e.slice(1);return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),t.length>=8?parseInt(t.slice(6,8),16)/255:1]}if(e.startsWith("rgb(")){const[t,i,a]=e.slice(4,-1).split(",").map(e=>parseInt(e,10));return[t,i,a,1]}if(e.startsWith("rgba(")){const t=e.slice(5,-1).split(",");return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseFloat(t[3])]}const t=e.match(/^color\(srgb\s+([\d.]+)\s+([\d.]+)\s+([\d.]+)(?:\s*\/\s*([\d.]+|none))?\)$/);return t?[Math.round(255*parseFloat(t[1])),Math.round(255*parseFloat(t[2])),Math.round(255*parseFloat(t[3])),void 0!==t[4]&&"none"!==t[4]?parseFloat(t[4]):1]:null}function getRGB(e){const t=getRGBA(e);if(!t){warn(`Not a valid color format: "${e}"`);return[0,0,0]}return t.slice(0,3)}function getCurrentTransform(e){const{a:t,b:i,c:a,d:s,e:n,f:r}=e.getTransform();return[t,i,a,s,n,r]}function getCurrentTransformInverse(e){const{a:t,b:i,c:a,d:s,e:n,f:r}=e.getTransform().invertSelf();return[t,i,a,s,n,r]}function setLayerDimensions(e,t,i=!1,a=!0){if(t instanceof PageViewport){const{pageWidth:a,pageHeight:s}=t.rawDims,{style:n}=e,r=`round(down, var(--total-scale-factor) * ${a}px, var(--scale-round-x))`,o=`round(down, var(--total-scale-factor) * ${s}px, var(--scale-round-y))`;if(i&&t.rotation%180!=0){n.width=o;n.height=r}else{n.width=r;n.height=o}}a&&e.setAttribute("data-main-rotation",t.rotation)}class OutputScale{constructor(){const{pixelRatio:e}=OutputScale;this.sx=e;this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(e,t,i,a,s=-1){let n=1/0,r=1/0,o=1/0;(i=OutputScale.capPixels(i,s))>0&&(n=Math.sqrt(i/(e*t)));if(-1!==a){r=a/e;o=a/t}const l=Math.min(n,r,o);if(this.sx>l||this.sy>l){this.sx=l;this.sy=l;return!0}return!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(e,t){if(t>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+t/100));return e>0?Math.min(e,i):i}return e}}const Y=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class ColorScheme{static get isDarkMode(){return shadow(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}class CSSConstants{static get commentForegroundColor(){const e=document.createElement("ngx-extended-pdf-viewer");e.style.display="block";const t=document.createElement("span");t.classList.add("commentPopup","comment","sidebar");const{style:i}=t;i.width=i.height="0";i.display="none";i.color="var(--comment-fg-color)";e.append(t);document.body.append(e);const{color:a}=window.getComputedStyle(t);e.remove();return shadow(this,"commentForegroundColor",getRGB(a))}}function applyOpacity(e,t){const i=255*(1-(t=MathClamp(t??1,0,1)));return e.map(e=>Math.round(e*t+i))}function RGBToHSL(e,t){const i=e[0]/255,a=e[1]/255,s=e[2]/255,n=Math.max(i,a,s),r=Math.min(i,a,s),o=(n+r)/2;if(n===r)t[0]=t[1]=0;else{const e=n-r;t[1]=o<.5?e/(n+r):e/(2-n-r);switch(n){case i:t[0]=60*((a-s)/e+(a<s?6:0));break;case a:t[0]=60*((s-i)/e+2);break;case s:t[0]=60*((i-a)/e+4)}}t[2]=o}function HSLToRGB(e,t){const i=e[0],a=e[1],s=e[2],n=(1-Math.abs(2*s-1))*a,r=n*(1-Math.abs(i/60%2-1)),o=s-n/2;switch(Math.floor(i/60)){case 0:t[0]=n+o;t[1]=r+o;t[2]=o;break;case 1:t[0]=r+o;t[1]=n+o;t[2]=o;break;case 2:t[0]=o;t[1]=n+o;t[2]=r+o;break;case 3:t[0]=o;t[1]=r+o;t[2]=n+o;break;case 4:t[0]=r+o;t[1]=o;t[2]=n+o;break;case 5:case 6:t[0]=n+o;t[1]=o;t[2]=r+o}}function computeLuminance(e){return e<=.03928?e/12.92:((e+.055)/1.055)**2.4}function contrastRatio(e,t,i){HSLToRGB(e,i);i.map(computeLuminance);const a=.2126*i[0]+.7152*i[1]+.0722*i[2];HSLToRGB(t,i);i.map(computeLuminance);const s=.2126*i[0]+.7152*i[1]+.0722*i[2];return a>s?(a+.05)/(s+.05):(s+.05)/(a+.05)}const Z=new Map;function findContrastColor(e,t){const i=e[0]+256*e[1]+65536*e[2]+16777216*t[0]+4294967296*t[1]+1099511627776*t[2];let a=Z.get(i);if(a)return a;const s=new Float32Array(9),n=s.subarray(0,3),r=s.subarray(3,6);RGBToHSL(e,r);const o=s.subarray(6,9);RGBToHSL(t,o);const l=o[2]<.5,d=l?12:4.5;r[2]=l?Math.sqrt(r[2]):1-Math.sqrt(1-r[2]);if(contrastRatio(r,o,n)<d){let e,t;if(l){e=r[2];t=1}else{e=0;t=r[2]}const i=.005;for(;t-e>i;){const i=r[2]=(e+t)/2;l===contrastRatio(r,o,n)<d?e=i:t=i}r[2]=l?t:e}HSLToRGB(r,n);a=Util.makeHexColor(Math.round(255*n[0]),Math.round(255*n[1]),Math.round(255*n[2]));Z.set(i,a);return a}function renderRichText({html:e,dir:t,className:i},a){const s=document.createDocumentFragment();if("string"==typeof e){const i=document.createElement("p");i.dir=t||"auto";const a=e.split(/\r\n?|\n/);for(let e=0,t=a.length;e<t;++e){const s=a[e];i.append(document.createTextNode(s));e<t-1&&i.append(document.createElement("br"))}s.append(i)}else XfaLayer.render({xfaHtml:e,div:s,intent:"richText"});s.firstElementChild.classList.add("richText",i);a.append(s)}function makePathFromDrawOPS(e){const t=new Path2D;if(!e)return t;for(let i=0,a=e.length;i<a;)switch(e[i++]){case D:t.moveTo(e[i++],e[i++]);break;case L:t.lineTo(e[i++],e[i++]);break;case N:t.bezierCurveTo(e[i++],e[i++],e[i++],e[i++],e[i++],e[i++]);break;case R:t.quadraticCurveTo(e[i++],e[i++],e[i++],e[i++]);break;case O:t.closePath();break;default:warn(`Unrecognized drawing path operator: ${e[i-1]}`)}return t}function _classPrivateMethodInitSpec(e,t){toolbar_checkPrivateRedeclaration(e,t),t.add(e)}function toolbar_classPrivateFieldInitSpec(e,t,i){toolbar_checkPrivateRedeclaration(e,t),t.set(e,i)}function toolbar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function _classPrivateGetter(e,t,i){return i(toolbar_assertClassBrand(e,t))}function toolbar_classPrivateFieldGet(e,t){return e.get(toolbar_assertClassBrand(e,t))}function _classPrivateFieldSet(e,t,i){return e.set(toolbar_assertClassBrand(e,t),i),i}function toolbar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Q=new WeakMap,J=new WeakMap,ee=new WeakMap,te=new WeakMap,ie=new WeakMap,ae=new WeakMap,se=new WeakMap,ne=new WeakMap,re=new WeakSet;class EditorToolbar{constructor(e){_classPrivateMethodInitSpec(this,re);toolbar_classPrivateFieldInitSpec(this,Q,null);toolbar_classPrivateFieldInitSpec(this,J,null);toolbar_classPrivateFieldInitSpec(this,ee,void 0);toolbar_classPrivateFieldInitSpec(this,te,null);toolbar_classPrivateFieldInitSpec(this,ie,null);toolbar_classPrivateFieldInitSpec(this,ae,null);toolbar_classPrivateFieldInitSpec(this,se,null);toolbar_classPrivateFieldInitSpec(this,ne,null);_classPrivateFieldSet(ee,this,e);oe._||(oe._=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=_classPrivateFieldSet(Q,this,document.createElement("div"));e.classList.add("editToolbar","hidden");e.setAttribute("role","toolbar");const t=toolbar_classPrivateFieldGet(ee,this)._uiManager._signal;if(t instanceof AbortSignal&&!t.aborted){e.addEventListener("contextmenu",noContextMenu,{signal:t});e.addEventListener("pointerdown",_pointerDown,{signal:t})}const i=_classPrivateFieldSet(te,this,document.createElement("div"));i.className="buttons";e.append(i);const a=toolbar_classPrivateFieldGet(ee,this).toolbarPosition;if(a){const{style:t}=e,i="ltr"===toolbar_classPrivateFieldGet(ee,this)._uiManager.direction?1-a[0]:a[0];t.insetInlineEnd=100*i+"%";t.top=`calc(${100*a[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return toolbar_classPrivateFieldGet(Q,this)}hide(){toolbar_classPrivateFieldGet(Q,this).classList.add("hidden");toolbar_classPrivateFieldGet(J,this)?.hideDropdown()}show(){toolbar_classPrivateFieldGet(Q,this).classList.remove("hidden");toolbar_classPrivateFieldGet(ie,this)?.shown();toolbar_classPrivateFieldGet(ae,this)?.shown()}addDeleteButton(){const{editorType:e,_uiManager:t}=toolbar_classPrivateFieldGet(ee,this),i=document.createElement("button");i.classList.add("basic","deleteButton");i.tabIndex=0;i.setAttribute("data-l10n-id",oe._[e]);toolbar_assertClassBrand(re,this,_addListenersToElement).call(this,i)&&i.addEventListener("click",e=>{t.delete()},{signal:t._signal});toolbar_classPrivateFieldGet(te,this).append(i)}async addAltText(e){const t=await e.render();toolbar_assertClassBrand(re,this,_addListenersToElement).call(this,t);toolbar_classPrivateFieldGet(te,this).append(t,_classPrivateGetter(re,this,_get_divider));_classPrivateFieldSet(ie,this,e)}addComment(e,t=null){if(toolbar_classPrivateFieldGet(ae,this))return;const i=e.renderForToolbar();if(!i)return;toolbar_assertClassBrand(re,this,_addListenersToElement).call(this,i);const a=_classPrivateFieldSet(se,this,_classPrivateGetter(re,this,_get_divider));if(t){toolbar_classPrivateFieldGet(te,this).insertBefore(i,t);toolbar_classPrivateFieldGet(te,this).insertBefore(a,t)}else toolbar_classPrivateFieldGet(te,this).append(i,a);_classPrivateFieldSet(ae,this,e);e.toolbar=this}addColorPicker(e){if(toolbar_classPrivateFieldGet(J,this))return;_classPrivateFieldSet(J,this,e);const t=e.renderButton();toolbar_assertClassBrand(re,this,_addListenersToElement).call(this,t);toolbar_classPrivateFieldGet(te,this).append(t,_classPrivateGetter(re,this,_get_divider))}async addEditSignatureButton(e){const t=_classPrivateFieldSet(ne,this,await e.renderEditButton(toolbar_classPrivateFieldGet(ee,this)));toolbar_assertClassBrand(re,this,_addListenersToElement).call(this,t);toolbar_classPrivateFieldGet(te,this).append(t,_classPrivateGetter(re,this,_get_divider))}removeButton(e){if("comment"===e){toolbar_classPrivateFieldGet(ae,this)?.removeToolbarCommentButton();_classPrivateFieldSet(ae,this,null);toolbar_classPrivateFieldGet(se,this)?.remove();_classPrivateFieldSet(se,this,null)}}async addButton(e,t){switch(e){case"colorPicker":t&&this.addColorPicker(t);break;case"altText":t&&await this.addAltText(t);break;case"editSignature":t&&await this.addEditSignatureButton(t);break;case"delete":this.addDeleteButton();break;case"comment":t&&this.addComment(t)}}async addButtonBefore(e,t,i){if(!t&&"comment"===e)return;const a=toolbar_classPrivateFieldGet(te,this).querySelector(i);a&&"comment"===e&&this.addComment(t,a)}updateEditSignatureButton(e){toolbar_classPrivateFieldGet(ne,this)&&(toolbar_classPrivateFieldGet(ne,this).title=e)}remove(){toolbar_classPrivateFieldGet(Q,this).remove();toolbar_classPrivateFieldGet(J,this)?.destroy();_classPrivateFieldSet(J,this,null)}}function _pointerDown(e){e.stopPropagation()}function _focusIn(e){toolbar_classPrivateFieldGet(ee,this)._focusEventsAllowed=!1;stopEvent(e)}function _focusOut(e){toolbar_classPrivateFieldGet(ee,this)._focusEventsAllowed=!0;stopEvent(e)}function _addListenersToElement(e){const t=toolbar_classPrivateFieldGet(ee,this)._uiManager._signal;if(!(t instanceof AbortSignal)||t.aborted)return!1;e.addEventListener("focusin",toolbar_assertClassBrand(re,this,_focusIn).bind(this),{capture:!0,signal:t});e.addEventListener("focusout",toolbar_assertClassBrand(re,this,_focusOut).bind(this),{capture:!0,signal:t});e.addEventListener("contextmenu",noContextMenu,{signal:t});return!0}function _get_divider(e){const t=document.createElement("div");t.className="divider";return t}var oe={_:null},le=new WeakMap,de=new WeakMap,ce=new WeakMap,he=new WeakSet;class FloatingToolbar{constructor(e){_classPrivateMethodInitSpec(this,he);toolbar_classPrivateFieldInitSpec(this,le,null);toolbar_classPrivateFieldInitSpec(this,de,null);toolbar_classPrivateFieldInitSpec(this,ce,void 0);_classPrivateFieldSet(ce,this,e)}show(e,t,i){const[a,s]=toolbar_assertClassBrand(he,this,_getLastPoint).call(this,t,i),{style:n}=toolbar_classPrivateFieldGet(de,this)||_classPrivateFieldSet(de,this,toolbar_assertClassBrand(he,this,_render).call(this));e.append(toolbar_classPrivateFieldGet(de,this));n.insetInlineEnd=100*a+"%";n.top=`calc(${100*s}% + var(--editor-toolbar-vert-offset))`}hide(){toolbar_classPrivateFieldGet(de,this).remove()}}function _render(){const e=_classPrivateFieldSet(de,this,document.createElement("div"));e.className="editToolbar";e.setAttribute("role","toolbar");const t=toolbar_classPrivateFieldGet(ce,this)._signal;t instanceof AbortSignal&&!t.aborted&&e.addEventListener("contextmenu",noContextMenu,{signal:t});const i=_classPrivateFieldSet(le,this,document.createElement("div"));i.className="buttons";e.append(i);toolbar_classPrivateFieldGet(ce,this).hasCommentManager()&&toolbar_assertClassBrand(he,this,_makeButton).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{toolbar_classPrivateFieldGet(ce,this).commentSelection("floating_button")});toolbar_assertClassBrand(he,this,_makeButton).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{toolbar_classPrivateFieldGet(ce,this).highlightSelection("floating_button")});return e}function _getLastPoint(e,t){let i=0,a=0;for(const s of e){const e=s.y+s.height;if(e<i)continue;const n=s.x+(t?s.width:0);if(e>i){a=n;i=e}else t?n>a&&(a=n):n<a&&(a=n)}return[t?1-a:a,i]}function _makeButton(e,t,i,a){const s=document.createElement("button");s.classList.add("basic",e);s.tabIndex=0;s.setAttribute("data-l10n-id",t);const n=document.createElement("span");s.append(n);n.className="visuallyHidden";n.setAttribute("data-l10n-id",i);const r=toolbar_classPrivateFieldGet(ce,this)._signal;if(r instanceof AbortSignal&&!r.aborted){s.addEventListener("contextmenu",noContextMenu,{signal:r});s.addEventListener("click",a,{signal:r})}toolbar_classPrivateFieldGet(le,this).append(s)}const ue=Object.freeze({internal:"bdf2a9e9-edfb-4a31-900e-7cce1775f13e"});var _e,pe;function tools_defineProperty(e,t,i){return(t=function tools_toPropertyKey(e){var t=function tools_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function tools_classPrivateMethodInitSpec(e,t){tools_checkPrivateRedeclaration(e,t),t.add(e)}function tools_classPrivateFieldInitSpec(e,t,i){tools_checkPrivateRedeclaration(e,t),t.set(e,i)}function tools_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function tools_classPrivateFieldGet(e,t){return e.get(tools_assertClassBrand(e,t))}function tools_classPrivateFieldSet(e,t,i){return e.set(tools_assertClassBrand(e,t),i),i}function tools_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function bindEvents(e,t,i){for(const a of i)t.addEventListener(a,e[a].bind(e))}var ge=new WeakMap,me=new WeakMap,fe=new WeakMap,ve=new WeakMap,Pe=new WeakMap,we=new WeakMap;class CurrentPointers{constructor(e){tools_classPrivateFieldInitSpec(this,ge,NaN);tools_classPrivateFieldInitSpec(this,me,null);tools_classPrivateFieldInitSpec(this,fe,NaN);tools_classPrivateFieldInitSpec(this,ve,null);tools_classPrivateFieldInitSpec(this,Pe,null);tools_classPrivateFieldInitSpec(this,we,-1/0);window.addEventListener("pointerdown",({pointerType:e})=>{tools_classPrivateFieldSet(Pe,this,e);tools_classPrivateFieldSet(we,this,performance.now())},{capture:!0,signal:e})}pickOwner(e,t){if(!e||t)return null;return performance.now()-tools_classPrivateFieldGet(we,this)<=Fe._?tools_classPrivateFieldGet(Pe,this):null}claimFor(e){tools_classPrivateFieldSet(ve,this,e??null)}setPointerTypeIfUnset(e){tools_classPrivateFieldGet(ve,this)??tools_classPrivateFieldSet(ve,this,e)}initializeAndAddPointerId(e){(tools_classPrivateFieldGet(me,this)||tools_classPrivateFieldSet(me,this,new Set)).add(e)}setPointer(e,t){tools_classPrivateFieldGet(ge,this)||tools_classPrivateFieldSet(ge,this,t);tools_classPrivateFieldGet(ve,this)??tools_classPrivateFieldSet(ve,this,e)}setTimeStamp(e){tools_classPrivateFieldSet(fe,this,e)}isSamePointerId(e){return tools_classPrivateFieldGet(ge,this)===e}isSamePointerIdOrRemove(e){if(tools_classPrivateFieldGet(ge,this)===e)return!0;tools_classPrivateFieldGet(me,this)?.delete(e);return!1}isSamePointerType(e){return tools_classPrivateFieldGet(ve,this)===e}isInitializedAndDifferentPointerType(e){return null!==tools_classPrivateFieldGet(ve,this)&&!this.isSamePointerType(e)}isSameTimeStamp(e){return tools_classPrivateFieldGet(fe,this)===e}isUsingMultiplePointers(){return tools_classPrivateFieldGet(me,this)?.size>=1}clearPointerIds(){tools_classPrivateFieldSet(ge,this,NaN);tools_classPrivateFieldSet(me,this,null)}clearTimeStamp(){tools_classPrivateFieldSet(fe,this,NaN)}}var Fe={_:1e3},be=new WeakMap;class IdManager{constructor(){tools_classPrivateFieldInitSpec(this,be,0)}get id(){var e,t;return`${m}${tools_classPrivateFieldSet(be,this,(e=tools_classPrivateFieldGet(be,this),t=e++,e)),t}`}}var ye=new WeakMap,Se=new WeakMap,Ce=new WeakMap,xe=new WeakSet;class ImageManager{constructor(){tools_classPrivateMethodInitSpec(this,xe);tools_classPrivateFieldInitSpec(this,ye,getUuid());tools_classPrivateFieldInitSpec(this,Se,0);tools_classPrivateFieldInitSpec(this,Ce,null)}static get _isSVGFittingCanvas(){const e=`data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="${n}"><rect width="1" height="1" style="fill:red;"/></svg>`,t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=e;return shadow(this,"_isSVGFittingCanvas",i.decode().then(()=>{t.drawImage(i,0,0,1,1,0,0,1,3);return 0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]}))}async getFromFile(e){const{lastModified:t,name:i,size:a,type:s}=e;return tools_assertClassBrand(xe,this,_get).call(this,`${t}_${i}_${a}_${s}`,e)}async getFromUrl(e){return tools_assertClassBrand(xe,this,_get).call(this,e,e)}async getFromBlob(e,t){const i=await t;return tools_assertClassBrand(xe,this,_get).call(this,e,i)}async getFromId(e){tools_classPrivateFieldGet(Ce,this)||tools_classPrivateFieldSet(Ce,this,new Map);const t=tools_classPrivateFieldGet(Ce,this).get(e);if(!t)return null;if(t.bitmap){t.refCounter+=1;return t}if(t.file)return this.getFromFile(t.file);if(t.blobPromise){const{blobPromise:e}=t;delete t.blobPromise;return this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){var i,a;tools_classPrivateFieldGet(Ce,this)||tools_classPrivateFieldSet(Ce,this,new Map);let s=tools_classPrivateFieldGet(Ce,this).get(e);if(s?.bitmap){s.refCounter+=1;return s}const n=new OffscreenCanvas(t.width,t.height);n.getContext("2d").drawImage(t,0,0);s={bitmap:n.transferToImageBitmap(),id:`image_${tools_classPrivateFieldGet(ye,this)}_${tools_classPrivateFieldSet(Se,this,(i=tools_classPrivateFieldGet(Se,this),a=i++,i)),a}`,refCounter:1,isSvg:!1};tools_classPrivateFieldGet(Ce,this).set(e,s);tools_classPrivateFieldGet(Ce,this).set(s.id,s);return s}getSvgUrl(e){const t=tools_classPrivateFieldGet(Ce,this).get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){tools_classPrivateFieldGet(Ce,this)||tools_classPrivateFieldSet(Ce,this,new Map);const t=tools_classPrivateFieldGet(Ce,this).get(e);if(!t)return;t.refCounter-=1;if(0!==t.refCounter)return;const{bitmap:i}=t;if(!t.url&&!t.file){const e=new OffscreenCanvas(i.width,i.height);e.getContext("bitmaprenderer").transferFromImageBitmap(i);t.blobPromise=e.convertToBlob()}i.close?.();t.bitmap=null}isValidId(e){return e.startsWith(`image_${tools_classPrivateFieldGet(ye,this)}_`)}}_e=ImageManager;async function _get(e,t){tools_classPrivateFieldGet(Ce,this)||tools_classPrivateFieldSet(Ce,this,new Map);let i=tools_classPrivateFieldGet(Ce,this).get(e);if(null===i)return null;if(i?.bitmap){i.refCounter+=1;return i}try{var a,s;i||={bitmap:null,id:`image_${tools_classPrivateFieldGet(ye,this)}_${tools_classPrivateFieldSet(Se,this,(a=tools_classPrivateFieldGet(Se,this),s=a++,a)),s}`,refCounter:0,isSvg:!1};let e;if("string"==typeof t){i.url=t;e=await fetchData(t,"blob")}else t instanceof File?e=i.file=t:t instanceof Blob&&(e=t);if("image/svg+xml"===e.type){const t=_e._isSVGFittingCanvas,a=new FileReader,s=new Image,n=new Promise((e,n)=>{s.onload=()=>{i.bitmap=s;i.isSvg=!0;e()};a.onload=async()=>{const e=i.svgUrl=a.result;s.src=await t?`${e}#svgView(preserveAspectRatio(none))`:e};s.onerror=a.onerror=n});a.readAsDataURL(e);await n}else i.bitmap=await createImageBitmap(e);i.refCounter=1}catch(e){warn(e);i=null}tools_classPrivateFieldGet(Ce,this).set(e,i);i&&tools_classPrivateFieldGet(Ce,this).set(i.id,i);return i}var ke=new WeakMap,Ee=new WeakMap,Ae=new WeakMap,Ge=new WeakMap;class CommandManager{constructor(e=128){tools_classPrivateFieldInitSpec(this,ke,[]);tools_classPrivateFieldInitSpec(this,Ee,!1);tools_classPrivateFieldInitSpec(this,Ae,void 0);tools_classPrivateFieldInitSpec(this,Ge,-1);tools_classPrivateFieldSet(Ae,this,e)}add({cmd:e,undo:t,post:i,mustExec:a,type:s=NaN,overwriteIfSameType:n=!1,keepUndo:r=!1}){a&&e();if(tools_classPrivateFieldGet(Ee,this))return;const o={cmd:e,undo:t,post:i,type:s};if(-1===tools_classPrivateFieldGet(Ge,this)){tools_classPrivateFieldGet(ke,this).length>0&&(tools_classPrivateFieldGet(ke,this).length=0);tools_classPrivateFieldSet(Ge,this,0);tools_classPrivateFieldGet(ke,this).push(o);return}if(n&&tools_classPrivateFieldGet(ke,this)[tools_classPrivateFieldGet(Ge,this)].type===s){r&&(o.undo=tools_classPrivateFieldGet(ke,this)[tools_classPrivateFieldGet(Ge,this)].undo);tools_classPrivateFieldGet(ke,this)[tools_classPrivateFieldGet(Ge,this)]=o;return}const l=tools_classPrivateFieldGet(Ge,this)+1;if(l===tools_classPrivateFieldGet(Ae,this))tools_classPrivateFieldGet(ke,this).splice(0,1);else{tools_classPrivateFieldSet(Ge,this,l);l<tools_classPrivateFieldGet(ke,this).length&&tools_classPrivateFieldGet(ke,this).splice(l)}tools_classPrivateFieldGet(ke,this).push(o)}undo(){if(-1===tools_classPrivateFieldGet(Ge,this))return;tools_classPrivateFieldSet(Ee,this,!0);const{undo:e,post:t}=tools_classPrivateFieldGet(ke,this)[tools_classPrivateFieldGet(Ge,this)];e();t?.();tools_classPrivateFieldSet(Ee,this,!1);tools_classPrivateFieldSet(Ge,this,tools_classPrivateFieldGet(Ge,this)-1)}redo(){if(tools_classPrivateFieldGet(Ge,this)<tools_classPrivateFieldGet(ke,this).length-1){tools_classPrivateFieldSet(Ge,this,tools_classPrivateFieldGet(Ge,this)+1);tools_classPrivateFieldSet(Ee,this,!0);const{cmd:e,post:t}=tools_classPrivateFieldGet(ke,this)[tools_classPrivateFieldGet(Ge,this)];e();t?.();tools_classPrivateFieldSet(Ee,this,!1)}}hasSomethingToUndo(){return-1!==tools_classPrivateFieldGet(Ge,this)}hasSomethingToRedo(){return tools_classPrivateFieldGet(Ge,this)<tools_classPrivateFieldGet(ke,this).length-1}cleanType(e){if(-1!==tools_classPrivateFieldGet(Ge,this)){for(let t=tools_classPrivateFieldGet(Ge,this);t>=0;t--)if(tools_classPrivateFieldGet(ke,this)[t].type!==e){tools_classPrivateFieldGet(ke,this).splice(t+1,tools_classPrivateFieldGet(Ge,this)-t);tools_classPrivateFieldSet(Ge,this,t);return}tools_classPrivateFieldGet(ke,this).length=0;tools_classPrivateFieldSet(Ge,this,-1)}}destroy(){tools_classPrivateFieldSet(ke,this,null)}reset(){tools_classPrivateFieldSet(ke,this,[]);tools_classPrivateFieldSet(Ge,this,-1);tools_classPrivateFieldSet(Ee,this,!1)}}class KeyboardManager{constructor(e){this.callbacks=new Map;const{isMac:t}=FeatureTest.platform;for(const[i,a,s={}]of e){const e=i.some(e=>e.startsWith("mac+"));for(const n of i){let i=n;if(e){const e=n.startsWith("mac+");if(t!==e)continue;e&&(i=n.slice(4))}const[r,o]=_parseShortcut.call(KeyboardManager,i);null!==r&&this.callbacks.getOrInsertComputed(r,makeArr).push({callback:a,options:s,modifiers:o})}}}exec(e,t){let i=this.callbacks.get(t.key);if(!i){if(/^[a-z]$/i.test(t.key))return;const e=_codeToKey.call(KeyboardManager,t.code);if(null===e||e===t.key)return;i=this.callbacks.get(e);if(!i)return}const a=(t.altKey?KeyboardManager.ALT:0)|(t.ctrlKey?KeyboardManager.CTRL:0)|(t.metaKey?KeyboardManager.META:0)|(t.shiftKey?KeyboardManager.SHIFT:0),s=i.find(e=>e.modifiers===a);if(!s)return;const{callback:n,options:{bubbles:r=!1,args:o=[],checker:l=null}}=s;if(!l||l(e,t)){n.bind(e,...o,t)();r||stopEvent(t)}}}pe=KeyboardManager;function _parseShortcut(e){let t=null,i=0;for(let a of e.split("+")){a=a.trim();if(!a)continue;const s=a.toUpperCase(),n=pe[s];if(n)i|=n;else{if(null!==t){warn(`KeyboardManager: multiple keys in shortcut "${e}"`);break}t="SPACE"===s?" ":a}}null===t&&warn(`KeyboardManager: no key found in shortcut "${e}"`);return[t,i]}function _codeToKey(e){const t=/^(?:Key([A-Z])|(?:Digit|Numpad)(\d))$/.exec(e);return t?t[1]?.toLowerCase()??t[2]:null}tools_defineProperty(KeyboardManager,"ALT",1);tools_defineProperty(KeyboardManager,"CTRL",2);tools_defineProperty(KeyboardManager,"META",4);tools_defineProperty(KeyboardManager,"SHIFT",8);class ColorManager{get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);!function getColorValues(e){const t=document.createElement("span");t.style.visibility="hidden";t.style.colorScheme="only light";document.body.append(t);for(const i of e.keys()){t.style.color=i;const a=window.getComputedStyle(t).color;e.set(i,getRGB(a))}t.remove()}(e);return shadow(this,"_colors",e)}convert(e){const t=getRGB(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(const[e,i]of this._colors)if(i.every((e,i)=>e===t[i]))return ColorManager._colorsMapping.get(e);return t}getHexCode(e){const t=this._colors.get(e);return t?Util.makeHexColor(...t):e}}tools_defineProperty(ColorManager,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));var Be=new WeakMap,Me=new WeakMap,Ie=new WeakMap,Te=new WeakMap,De=new WeakMap,Le=new WeakMap,Ne=new WeakMap,Re=new WeakMap,Oe=new WeakMap,We=new WeakMap,je=new WeakMap,Ve=new WeakMap,Ue=new WeakMap,ze=new WeakMap,He=new WeakMap,$e=new WeakMap,Ke=new WeakMap,Xe=new WeakMap,qe=new WeakMap,Ye=new WeakMap,Ze=new WeakMap,Qe=new WeakMap,Je=new WeakMap,et=new WeakMap,tt=new WeakMap,it=new WeakMap,at=new WeakMap,st=new WeakMap,nt=new WeakMap,rt=new WeakMap,ot=new WeakMap,lt=new WeakMap,dt=new WeakMap,ct=new WeakMap,ht=new WeakMap,ut=new WeakMap,_t=new WeakMap,pt=new WeakMap,gt=new WeakMap,mt=new WeakMap,ft=new WeakMap,vt=new WeakMap,Pt=new WeakMap,wt=new WeakMap,Ft=new WeakMap,bt=new WeakMap,yt=new WeakMap,St=new WeakMap,Ct=new WeakMap,xt=new WeakMap,kt=new WeakMap,Et=new WeakMap,At=new WeakSet;class AnnotationEditorUIManager{static get _keyboardManager(){const e=AnnotationEditorUIManager.prototype,arrowChecker=e=>tools_classPrivateFieldGet(Ct,e).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&e.hasSomethingToControl(),textInputChecker=(e,{target:t})=>{if(t instanceof HTMLInputElement){const{type:e}=t;return"text"!==e&&"number"!==e}return!0},t=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return shadow(this,"_keyboardManager",new KeyboardManager([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:textInputChecker}],[["ctrl+z","mac+meta+z"],e.undo,{checker:textInputChecker}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.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"],e.delete,{checker:textInputChecker}],[["Enter"],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&tools_classPrivateFieldGet(Ct,e).contains(t)&&!e.isEnterHandled}],[["Space"],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&tools_classPrivateFieldGet(Ct,e).contains(document.activeElement)}],[["Escape"],e.unselectAll],[["ArrowLeft"],e.translateSelectedEditors,{args:[-t,0],checker:arrowChecker}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:arrowChecker}],[["ArrowRight"],e.translateSelectedEditors,{args:[t,0],checker:arrowChecker}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:arrowChecker}],[["ArrowUp"],e.translateSelectedEditors,{args:[0,-t],checker:arrowChecker}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:arrowChecker}],[["ArrowDown"],e.translateSelectedEditors,{args:[0,t],checker:arrowChecker}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:arrowChecker}]]))}constructor(e,t,i,a,s,n,r,o,l,d,c,h,u,_,p,g){tools_classPrivateMethodInitSpec(this,At);tools_classPrivateFieldInitSpec(this,Be,new AbortController);tools_classPrivateFieldInitSpec(this,Me,null);tools_classPrivateFieldInitSpec(this,Ie,null);tools_classPrivateFieldInitSpec(this,Te,new Map);tools_classPrivateFieldInitSpec(this,De,new Map);tools_classPrivateFieldInitSpec(this,Le,null);tools_classPrivateFieldInitSpec(this,Ne,null);tools_classPrivateFieldInitSpec(this,Re,null);tools_classPrivateFieldInitSpec(this,Oe,null);tools_classPrivateFieldInitSpec(this,We,new CommandManager);tools_classPrivateFieldInitSpec(this,je,null);tools_classPrivateFieldInitSpec(this,Ve,null);tools_classPrivateFieldInitSpec(this,Ue,null);tools_classPrivateFieldInitSpec(this,ze,0);tools_classPrivateFieldInitSpec(this,He,null);tools_classPrivateFieldInitSpec(this,$e,new Set);tools_classPrivateFieldInitSpec(this,Ke,null);tools_classPrivateFieldInitSpec(this,Xe,null);tools_classPrivateFieldInitSpec(this,qe,new Set);tools_defineProperty(this,"_editorUndoBar",null);tools_classPrivateFieldInitSpec(this,Ye,!1);tools_classPrivateFieldInitSpec(this,Ze,!1);tools_classPrivateFieldInitSpec(this,Qe,!1);tools_classPrivateFieldInitSpec(this,Je,null);tools_classPrivateFieldInitSpec(this,et,null);tools_classPrivateFieldInitSpec(this,tt,null);tools_classPrivateFieldInitSpec(this,it,null);tools_classPrivateFieldInitSpec(this,at,!1);tools_classPrivateFieldInitSpec(this,st,null);tools_classPrivateFieldInitSpec(this,nt,new IdManager);tools_classPrivateFieldInitSpec(this,rt,!1);tools_classPrivateFieldInitSpec(this,ot,!1);tools_classPrivateFieldInitSpec(this,lt,!1);tools_classPrivateFieldInitSpec(this,dt,null);tools_classPrivateFieldInitSpec(this,ct,null);tools_classPrivateFieldInitSpec(this,ht,null);tools_classPrivateFieldInitSpec(this,ut,null);tools_classPrivateFieldInitSpec(this,_t,null);tools_classPrivateFieldInitSpec(this,pt,f.NONE);tools_classPrivateFieldInitSpec(this,gt,!1);tools_classPrivateFieldInitSpec(this,mt,new Set);tools_classPrivateFieldInitSpec(this,ft,null);tools_classPrivateFieldInitSpec(this,vt,null);tools_classPrivateFieldInitSpec(this,Pt,null);tools_classPrivateFieldInitSpec(this,wt,null);tools_classPrivateFieldInitSpec(this,Ft,null);tools_classPrivateFieldInitSpec(this,bt,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});tools_classPrivateFieldInitSpec(this,yt,[0,0]);tools_classPrivateFieldInitSpec(this,St,null);tools_classPrivateFieldInitSpec(this,Ct,null);tools_classPrivateFieldInitSpec(this,xt,null);tools_classPrivateFieldInitSpec(this,kt,null);tools_classPrivateFieldInitSpec(this,Et,null);const m=this._signal=tools_classPrivateFieldGet(Be,this).signal;tools_classPrivateFieldSet(Ct,this,e);tools_classPrivateFieldSet(xt,this,t);tools_classPrivateFieldSet(kt,this,i);tools_classPrivateFieldSet(Ne,this,a);tools_classPrivateFieldSet(je,this,s);tools_classPrivateFieldSet(vt,this,n);tools_classPrivateFieldSet(Ft,this,o);this._eventBus=r;const v={signal:m,...ue};r.on("editingaction",this.onEditingAction.bind(this),v);r.on("pagechanging",this.onPageChanging.bind(this),v);r.on("scalechanging",this.onScaleChanging.bind(this),v);r.on("rotationchanging",this.onRotationChanging.bind(this),v);r.on("setpreference",this.onSetPreference.bind(this),v);r.on("switchannotationeditorparams",e=>this.updateParams(e.type,e.value),v);window.addEventListener("pointerdown",()=>{tools_classPrivateFieldSet(ot,this,!0)},{capture:!0,signal:m});tools_classPrivateFieldSet(He,this,new CurrentPointers(m));window.addEventListener("pointerup",()=>{tools_classPrivateFieldSet(ot,this,!1)},{capture:!0,signal:m});window.addEventListener("beforeunload",this.endCurrentEditing.bind(this),{capture:!0,signal:m});tools_assertClassBrand(At,this,_addSelectionListener).call(this);tools_assertClassBrand(At,this,_addDragAndDropListeners).call(this);tools_assertClassBrand(At,this,_addKeyboardManager).call(this);tools_classPrivateFieldSet(Re,this,o.annotationStorage);tools_classPrivateFieldSet(Je,this,o.filterFactory);tools_classPrivateFieldSet(Pt,this,l);tools_classPrivateFieldSet(it,this,d||null);tools_classPrivateFieldSet(Ye,this,c);tools_classPrivateFieldSet(Ze,this,h);tools_classPrivateFieldSet(Qe,this,u);tools_classPrivateFieldSet(_t,this,_||null);this.viewParameters={realScale:PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0};this.isShiftKeyDown=!1;this._editorUndoBar=p||null;this._supportsPinchToZoom=!1!==g;s?.setSidebarUiManager(this)}destroy(){tools_classPrivateFieldGet(Et,this)?.resolve();tools_classPrivateFieldSet(Et,this,null);tools_classPrivateFieldGet(Be,this)?.abort();tools_classPrivateFieldSet(Be,this,null);this._signal=null;for(const e of tools_classPrivateFieldGet(De,this).values())e.destroy();tools_classPrivateFieldGet(De,this).clear();tools_classPrivateFieldGet(Te,this).clear();tools_classPrivateFieldGet(qe,this).clear();tools_classPrivateFieldGet(ut,this)?.clear();tools_classPrivateFieldSet(Me,this,null);tools_classPrivateFieldGet(mt,this).clear();tools_classPrivateFieldGet(We,this).destroy();tools_classPrivateFieldGet(Ne,this)?.destroy();tools_classPrivateFieldGet(je,this)?.destroy();tools_classPrivateFieldGet(vt,this)?.destroy();tools_classPrivateFieldGet(st,this)?.hide();tools_classPrivateFieldSet(st,this,null);tools_classPrivateFieldGet(ht,this)?.destroy();tools_classPrivateFieldSet(ht,this,null);tools_classPrivateFieldSet(Ie,this,null);if(tools_classPrivateFieldGet(et,this)){clearTimeout(tools_classPrivateFieldGet(et,this));tools_classPrivateFieldSet(et,this,null)}if(tools_classPrivateFieldGet(St,this)){clearTimeout(tools_classPrivateFieldGet(St,this));tools_classPrivateFieldSet(St,this,null)}this._editorUndoBar?.destroy();tools_classPrivateFieldSet(Ft,this,null)}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return tools_classPrivateFieldGet(_t,this)}get useNewAltTextFlow(){return tools_classPrivateFieldGet(Ze,this)}get useNewAltTextWhenAddingImage(){return tools_classPrivateFieldGet(Qe,this)}get hcmFilter(){return shadow(this,"hcmFilter",tools_classPrivateFieldGet(Pt,this)?tools_classPrivateFieldGet(Je,this).addHCMFilter(tools_classPrivateFieldGet(Pt,this).foreground,tools_classPrivateFieldGet(Pt,this).background):"none")}get direction(){return shadow(this,"direction",getComputedStyle(tools_classPrivateFieldGet(Ct,this)).direction)}get _highlightColors(){return shadow(this,"_highlightColors",tools_classPrivateFieldGet(it,this)?new Map(tools_classPrivateFieldGet(it,this).split(",").map(e=>{(e=e.split("=").map(e=>e.trim()))[1]=e[1].toUpperCase();return e})):null)}get highlightColors(){const{_highlightColors:e}=this;if(!e)return shadow(this,"highlightColors",null);const t=new Map,i=!!tools_classPrivateFieldGet(Pt,this);for(const[a,s]of e){const e=a.endsWith("_HCM");i&&e?t.set(a.replace("_HCM",""),s):i||e||t.set(a,s)}return shadow(this,"highlightColors",t)}get highlightColorNames(){return shadow(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}getNonHCMColor(e){if(!this._highlightColors)return e;const t=this.highlightColorNames.get(e);return this._highlightColors.get(t)||e}getNonHCMColorName(e){return this.highlightColorNames.get(e)||e}setCurrentDrawingSession(e){if(e){this.unselectAll();this.disableUserSelect(!0)}else this.disableUserSelect(!1);tools_classPrivateFieldSet(Ue,this,e)}setMainHighlightColorPicker(e){tools_classPrivateFieldSet(ht,this,e)}editAltText(e,t=!1){tools_classPrivateFieldGet(Ne,this)?.editAltText(this,e,t)}hasCommentManager(){return!!tools_classPrivateFieldGet(je,this)}editComment(e,t,i,a){tools_classPrivateFieldGet(je,this)?.showDialog(this,e,t,i,a)}selectComment(e,t){const i=tools_classPrivateFieldGet(De,this).get(e),a=i?.getEditorByUID(t);a?.toggleComment(!0,!0)}updateComment(e){tools_classPrivateFieldGet(je,this)?.updateComment(e.getData())}updatePopupColor(e){tools_classPrivateFieldGet(je,this)?.updatePopupColor(e)}removeComment(e){tools_classPrivateFieldGet(je,this)?.removeComments([e.uid])}deleteComment(e,t){const undo=()=>{e.comment=t};this.addCommands({cmd:()=>{this._editorUndoBar?.show(undo,"comment");this.toggleComment(null);e.comment=null},undo,mustExec:!0})}toggleComment(e,t,i=void 0){tools_classPrivateFieldGet(je,this)?.toggleCommentPopup(e,t,i)}makeCommentColor(e,t){return e&&tools_classPrivateFieldGet(je,this)?.makeCommentColor(e,t)||null}getCommentDialogElement(){return tools_classPrivateFieldGet(je,this)?.dialogElement||null}async waitForEditorsRendered(e){if(tools_classPrivateFieldGet(De,this).has(e-1))return;const{resolve:t,promise:i}=Promise.withResolvers(),onEditorsRendered=i=>{if(i.pageNumber===e){this._eventBus.off("editorsrendered",onEditorsRendered);t()}};this._eventBus.on("editorsrendered",onEditorsRendered,ue);await i}getSignature(e){tools_classPrivateFieldGet(vt,this)?.getSignature({uiManager:this,editor:e})}get signatureManager(){return tools_classPrivateFieldGet(vt,this)}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal,...ue});this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){if("enableNewAltTextWhenAddingImage"===e)tools_classPrivateFieldSet(Qe,this,t)}onPageChanging({pageNumber:e}){tools_classPrivateFieldSet(ze,this,e-1)}deletePage(e){for(const t of this.getEditors(e))t.remove();tools_classPrivateFieldGet(De,this).delete(e);tools_classPrivateFieldGet(ze,this)===e&&tools_classPrivateFieldSet(ze,this,0)}focusMainContainer(){tools_classPrivateFieldGet(Ct,this).focus()}findParent(e,t){for(const i of tools_classPrivateFieldGet(De,this).values()){const{x:a,y:s,width:n,height:r}=i.div.getBoundingClientRect();if(e>=a&&e<=a+n&&t>=s&&t<=s+r)return i}return null}disableUserSelect(e=!1){tools_classPrivateFieldGet(xt,this).classList.toggle("noUserSelect",e)}addShouldRescale(e){tools_classPrivateFieldGet(qe,this).add(e)}removeShouldRescale(e){tools_classPrivateFieldGet(qe,this).delete(e)}onScaleChanging({scale:e}){this.commitOrRemove();this.viewParameters.realScale=e*PixelsPerInch.PDF_TO_CSS_UNITS;for(const e of tools_classPrivateFieldGet(qe,this))e.onScaleChanging();tools_classPrivateFieldGet(Ue,this)?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove();this.viewParameters.rotation=e}highlightSelection(e="",t=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:a,anchorOffset:s,focusNode:n,focusOffset:r}=i,o=i.toString(),l=tools_assertClassBrand(At,this,_getAnchorElementForSelection).call(this,i).closest(".textLayer"),d=this.getSelectionBoxes(l);if(!d)return;i.empty();const c=tools_assertClassBrand(At,this,_getLayerForTextLayer).call(this,l),h=tools_classPrivateFieldGet(pt,this)===f.NONE,callback=()=>{const i=c?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:d,anchorNode:a,anchorOffset:s,focusNode:n,focusOffset:r,text:o});h&&this.showAllEditors("highlight",!0,!0);t&&i?.editComment()};h?this.switchToMode(f.HIGHLIGHT,callback):callback()}commentSelection(e=""){this.highlightSelection(e,!0)}endCurrentEditing(){this.commitOrRemove();this.currentLayer?.endDrawingSession(!1)}getAndRemoveDataFromAnnotationStorage(e){if(!tools_classPrivateFieldGet(Re,this))return null;const t=`${m}${e}`,i=tools_classPrivateFieldGet(Re,this).getRawValue(t);i&&tools_classPrivateFieldGet(Re,this).remove(t);return i}addToAnnotationStorage(e){e.isEmpty()||!tools_classPrivateFieldGet(Re,this)||tools_classPrivateFieldGet(Re,this).has(e.id)||tools_classPrivateFieldGet(Re,this).setValue(e.id,e)}a11yAlert(e,t=null){const i=tools_classPrivateFieldGet(kt,this);if(i){i.setAttribute("data-l10n-id",e);t?i.setAttribute("data-l10n-args",JSON.stringify(t)):i.removeAttribute("data-l10n-args")}}blur(){this.isShiftKeyDown=!1;if(tools_classPrivateFieldGet(at,this)){tools_classPrivateFieldSet(at,this,!1);tools_assertClassBrand(At,this,_onSelectEnd).call(this,"main_toolbar")}if(!this.hasSelection)return;const{activeElement:e}=document;for(const t of tools_classPrivateFieldGet(mt,this))if(t.div.contains(e)){tools_classPrivateFieldSet(ct,this,[t,e]);t._focusEventsAllowed=!1;break}}focus(){if(!tools_classPrivateFieldGet(ct,this))return;const[e,t]=tools_classPrivateFieldGet(ct,this);tools_classPrivateFieldSet(ct,this,null);t.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal});t.focus()}addEditListeners(){tools_assertClassBrand(At,this,_addKeyboardManager).call(this);this.setEditingState(!0)}removeEditListeners(){tools_assertClassBrand(At,this,_removeKeyboardManager).call(this);this.setEditingState(!1)}dragOver(e){for(const{type:t}of e.dataTransfer.items)for(const i of tools_classPrivateFieldGet(Xe,this))if(i.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect="copy";e.preventDefault();return}}drop(e){for(const t of e.dataTransfer.items)for(const i of tools_classPrivateFieldGet(Xe,this))if(i.isHandlingMimeForPasting(t.type)){i.paste(t,this.currentLayer);e.preventDefault();return}}copy(e){e.preventDefault();tools_classPrivateFieldGet(Me,this)?.commitOrRemove();if(!this.hasSelection)return;const t=[];for(const e of tools_classPrivateFieldGet(mt,this)){const i=e.serialize(!0);i&&t.push(i)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e);this.delete()}async paste(e){e.preventDefault();const{clipboardData:t}=e;for(const e of t.items)for(const t of tools_classPrivateFieldGet(Xe,this))if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}const i=t.getData("application/pdfjs");await this.addSerializedEditor(i)}async addSerializedEditor(e,t=!1,i=!1,a=!0,s=!0){if(!e)return;try{"string"==typeof e&&(e=JSON.parse(e))}catch(e){warn(`paste: "${e.message}".`);return}if(!Array.isArray(e))return;const n=tools_classPrivateFieldGet(pt,this);t&&n===f.NONE&&await this.updateMode(f.FREETEXT);this.unselectAll();tools_classPrivateFieldSet(gt,this,!0);try{const t=[];for(const s of e){const e=void 0===s.pageIndex,n=a||e,r=n?this.currentLayer:this.getLayer(s.pageIndex);if(!r){warn(`addSerializedEditor: the annotation editor layer for page ${n?tools_classPrivateFieldGet(ze,this):s.pageIndex} is not rendered yet. Wait for the "annotationeditorlayerrendered" event (not "annotationlayerrendered") before adding an annotation to that page.`);continue}const o=await r.deserialize(s);if(o){o.doNotMove=i;t.push(o)}else warn(`addSerializedEditor: could not restore the annotation of type ${s.annotationType}. Skipping it.`)}const cmd=()=>{for(const e of t)tools_assertClassBrand(At,this,_addEditorToLayer).call(this,e);s&&tools_assertClassBrand(At,this,_selectEditors).call(this,t)},undo=()=>{for(const e of t)e.remove()};this.addCommands({cmd,undo,mustExec:!0});for(const e of t)e._dispatchAddedEvent()}catch(e){warn(`paste: "${e.message}".`)}finally{tools_classPrivateFieldSet(gt,this,!1)}t&&n!==tools_classPrivateFieldGet(pt,this)&&await this.updateMode(n)}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0);tools_classPrivateFieldGet(pt,this)===f.NONE||this.isEditorHandlingKeyboard||AnnotationEditorUIManager._keyboardManager.exec(this,e)}keyup(e){if(this.isShiftKeyDown&&"Shift"===e.key){this.isShiftKeyDown=!1;if(tools_classPrivateFieldGet(at,this)){tools_classPrivateFieldSet(at,this,!1);tools_assertClassBrand(At,this,_onSelectEnd).call(this,"main_toolbar")}}}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}updatePageIndex(e,t){for(const i of this.getEditors(e))i.pageIndex=t;const i=tools_classPrivateFieldGet(Le,this).get(e);if(i){i.pageIndex=t;tools_classPrivateFieldGet(De,this).set(t,i);tools_classPrivateFieldGet(rt,this)?i.enable():i.disable()}}startUpdatePages(){tools_classPrivateFieldSet(Le,this,new Map(tools_classPrivateFieldGet(De,this)));tools_classPrivateFieldGet(De,this).clear()}endUpdatePages(){tools_classPrivateFieldSet(Le,this,null)}clonePage(e,t){for(const i of this.getEditors(e)){const e=i.serialize(i.mode!==f.HIGHLIGHT);if(e){e.pageIndex=t;e.id=this.getId();e.isClone=!0;delete e.popupRef;tools_classPrivateFieldGet(Re,this).setValue(e.id,e)}}}findClonesForPage(e){const t=[],{pageIndex:i}=e;for(const[a,s]of tools_classPrivateFieldGet(Re,this))if(s.pageIndex===i&&s.isClone){tools_classPrivateFieldGet(Re,this).remove(a);t.push(e.deserialize(s).then(t=>{if(t){t.isClone=!0;e.addOrRebuild(t)}}))}return Promise.all(t)}setEditingState(e){if(e){tools_assertClassBrand(At,this,_addFocusManager).call(this);tools_assertClassBrand(At,this,_addCopyPasteListeners).call(this);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{isEditing:tools_classPrivateFieldGet(pt,this)!==f.NONE,isEmpty:tools_assertClassBrand(At,this,_isEmpty).call(this),hasSomethingToUndo:tools_classPrivateFieldGet(We,this).hasSomethingToUndo(),hasSomethingToRedo:tools_classPrivateFieldGet(We,this).hasSomethingToRedo(),hasSelectedEditor:!1})}else{tools_assertClassBrand(At,this,_removeFocusManager).call(this);tools_assertClassBrand(At,this,_removeCopyPasteListeners).call(this);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{isEditing:!1});this.disableUserSelect(!1)}}registerEditorTypes(e){if(!tools_classPrivateFieldGet(Xe,this)){tools_classPrivateFieldSet(Xe,this,e);for(const e of tools_classPrivateFieldGet(Xe,this))tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.defaultPropertiesToUpdate)}}getId(){return tools_classPrivateFieldGet(nt,this).id}get currentLayer(){return tools_classPrivateFieldGet(De,this).get(tools_classPrivateFieldGet(ze,this))}getLayer(e){return tools_classPrivateFieldGet(De,this).get(e)}get isRestoringAnnotations(){return tools_classPrivateFieldGet(gt,this)}get currentPageIndex(){return tools_classPrivateFieldGet(ze,this)}get currentPointers(){return tools_classPrivateFieldGet(He,this)}addLayer(e){tools_classPrivateFieldGet(De,this).set(e.pageIndex,e);tools_classPrivateFieldGet(rt,this)?e.enable():e.disable()}removeLayer(e){tools_classPrivateFieldGet(De,this).delete(e.pageIndex)}async updateMode(e,t=null,i=!1,a=!1,s=!1,n=!1){if(tools_classPrivateFieldGet(pt,this)===e)return;const r=tools_classPrivateFieldGet(He,this).pickOwner(i,a);if(tools_classPrivateFieldGet(Et,this)){await tools_classPrivateFieldGet(Et,this).promise;if(!tools_classPrivateFieldGet(Et,this))return}tools_classPrivateFieldSet(Et,this,Promise.withResolvers());tools_classPrivateFieldGet(Ue,this)?.commitOrRemove();tools_classPrivateFieldGet(pt,this)===f.POPUP&&tools_classPrivateFieldGet(je,this)?.hideSidebar();tools_classPrivateFieldGet(je,this)?.destroyPopup();tools_classPrivateFieldSet(pt,this,e);tools_classPrivateFieldGet(He,this).claimFor(r);if(e!==f.NONE){for(const e of tools_classPrivateFieldGet(Te,this).values())e.addStandaloneCommentButton();e===f.SIGNATURE&&await(tools_classPrivateFieldGet(vt,this)?.loadSignatures());this.setEditingState(!0);await tools_assertClassBrand(At,this,_enableAll).call(this);this.unselectAll();for(const t of tools_classPrivateFieldGet(De,this).values())t.updateMode(e);if(e===f.POPUP){tools_classPrivateFieldGet(Ie,this)||tools_classPrivateFieldSet(Ie,this,await tools_classPrivateFieldGet(Ft,this).getAnnotationsByType(new Set(tools_classPrivateFieldGet(Xe,this).map(e=>e._editorType))));const e=new Set,t=[];for(const i of tools_classPrivateFieldGet(Te,this).values()){const{annotationElementId:a,hasComment:s,deleted:n}=i;a&&e.add(a);s&&!n&&t.push(i.getData())}for(const i of tools_classPrivateFieldGet(Ie,this)){const{id:a,popupRef:s,contentsObj:n}=i;s&&n?.str&&!e.has(a)&&!tools_classPrivateFieldGet($e,this).has(a)&&t.push(i)}tools_classPrivateFieldGet(je,this)?.showSidebar(t)}if(t){for(const e of tools_classPrivateFieldGet(Te,this).values())if(e.uid===t){this.setSelected(e);n?e.editComment():s?e.enterInEditMode():e.focus()}else e.unselect();tools_classPrivateFieldGet(Et,this).resolve()}else{a&&this.addNewEditorFromKeyboard();tools_classPrivateFieldGet(Et,this).resolve()}}else{this.setEditingState(!1);tools_assertClassBrand(At,this,_disableAll).call(this);for(const e of tools_classPrivateFieldGet(Te,this).values())e.hideStandaloneCommentButton();this._editorUndoBar?.hide();this.toggleComment(null);tools_classPrivateFieldGet(Et,this).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e.mode!==tools_classPrivateFieldGet(pt,this)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...e})}updateParams(e,t){if(tools_classPrivateFieldGet(Xe,this)){switch(e){case v.CREATE:this.currentLayer.addNewEditor(t);return;case v.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}});(tools_classPrivateFieldGet(wt,this)||tools_classPrivateFieldSet(wt,this,new Map)).set(e,t);this.showAllEditors("highlight",t)}if(this.hasSelection){for(const i of tools_classPrivateFieldGet(mt,this))i.updateParams(e,t);if(e===v.HIGHLIGHT_COLOR||e===v.HIGHLIGHT_THICKNESS)for(const i of tools_classPrivateFieldGet(Xe,this))i.updateDefaultParams(e,t)}else for(const i of tools_classPrivateFieldGet(Xe,this))i.updateDefaultParams(e,t)}}showAllEditors(e,t,i=!1){for(const i of tools_classPrivateFieldGet(Te,this).values())i.editorType===e&&i.show(t);(tools_classPrivateFieldGet(wt,this)?.get(v.HIGHLIGHT_SHOW_ALL)??!0)!==t&&tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,[[v.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(tools_classPrivateFieldGet(lt,this)!==e){tools_classPrivateFieldSet(lt,this,e);for(const t of tools_classPrivateFieldGet(De,this).values()){e?t.disableClick():t.enableClick();t.div.classList.toggle("waiting",e)}}}*getEditors(e){for(const t of tools_classPrivateFieldGet(Te,this).values())t.pageIndex===e&&(yield t)}getEditor(e){return tools_classPrivateFieldGet(Te,this).get(e)}addEditor(e){tools_classPrivateFieldGet(Te,this).set(e.id,e)}removeEditor(e){if(e.div.contains(document.activeElement)){tools_classPrivateFieldGet(et,this)&&clearTimeout(tools_classPrivateFieldGet(et,this));tools_classPrivateFieldSet(et,this,setTimeout(()=>{this.focusMainContainer();tools_classPrivateFieldSet(et,this,null)},0))}tools_classPrivateFieldGet(Te,this).delete(e.id);e.annotationElementId&&tools_classPrivateFieldGet(ut,this)?.delete(e.annotationElementId);this.unselect(e);e.annotationElementId&&tools_classPrivateFieldGet($e,this).has(e.annotationElementId)||tools_classPrivateFieldGet(Re,this)?.remove(e.id)}addDeletedAnnotationElement(e){tools_classPrivateFieldGet($e,this).add(e.annotationElementId);this.addChangedExistingAnnotation(e);e.deleted=!0}isDeletedAnnotationElement(e){return tools_classPrivateFieldGet($e,this).has(e)}removeDeletedAnnotationElement(e){tools_classPrivateFieldGet($e,this).delete(e.annotationElementId);this.removeChangedExistingAnnotation(e);e.deleted=!1}setActiveEditor(e){if(tools_classPrivateFieldGet(Me,this)!==e){tools_classPrivateFieldSet(Me,this,e);e&&tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate)}}updateUI(e){(function tools_classPrivateGetter(e,t,i){return i(tools_assertClassBrand(e,t))})(At,this,_get_lastSelectedEditor)===e&&tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate)}updateUIForDefaultProperties(e){tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.defaultPropertiesToUpdate)}toggleSelected(e){if(tools_classPrivateFieldGet(mt,this).has(e)){tools_classPrivateFieldGet(mt,this).delete(e);e.unselect();tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:this.hasSelection})}else{tools_classPrivateFieldGet(mt,this).add(e);e.select();tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:!0})}}setSelected(e){this.updateToolbar({mode:e.mode,editId:e.uid});tools_classPrivateFieldGet(Ue,this)?.commitOrRemove();for(const t of tools_classPrivateFieldGet(mt,this))t!==e&&t.unselect();tools_classPrivateFieldGet(je,this)?.destroyPopup();tools_classPrivateFieldGet(mt,this).clear();tools_classPrivateFieldGet(mt,this).add(e);e.select();tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,e.propertiesToUpdate);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:!0})}get firstSelectedEditor(){return tools_classPrivateFieldGet(mt,this).values().next().value}unselect(e){e.unselect();tools_classPrivateFieldGet(mt,this).delete(e);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==tools_classPrivateFieldGet(mt,this).size}get isEnterHandled(){return 1===tools_classPrivateFieldGet(mt,this).size&&this.firstSelectedEditor.isEnterHandled}undo(){tools_classPrivateFieldGet(We,this).undo();tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:tools_classPrivateFieldGet(We,this).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:tools_assertClassBrand(At,this,_isEmpty).call(this)});this._editorUndoBar?.hide()}redo(){tools_classPrivateFieldGet(We,this).redo();tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:tools_classPrivateFieldGet(We,this).hasSomethingToRedo(),isEmpty:tools_assertClassBrand(At,this,_isEmpty).call(this)})}addCommands(e){tools_classPrivateFieldGet(We,this).add(e);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:tools_assertClassBrand(At,this,_isEmpty).call(this)})}cleanUndoStack(e){tools_classPrivateFieldGet(We,this).cleanType(e)}delete(){this.commitOrRemove();const e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const t=e?[e]:[...tools_classPrivateFieldGet(mt,this)],undo=()=>{for(const e of t)tools_assertClassBrand(At,this,_addEditorToLayer).call(this,e)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(undo,1===t.length?t[0].editorType:t.length);for(const e of t)e.remove()},undo,mustExec:!0})}commitOrRemove(){tools_classPrivateFieldGet(Me,this)?.commitOrRemove()}hasSomethingToControl(){return tools_classPrivateFieldGet(Me,this)||this.hasSelection}selectAll(){for(const e of tools_classPrivateFieldGet(mt,this))e.commit();tools_assertClassBrand(At,this,_selectEditors).call(this,tools_classPrivateFieldGet(Te,this).values())}unselectAll(){if(tools_classPrivateFieldGet(Me,this)){tools_classPrivateFieldGet(Me,this).commitOrRemove();if(tools_classPrivateFieldGet(pt,this)!==f.NONE)return}if(!tools_classPrivateFieldGet(Ue,this)?.commitOrRemove()){tools_classPrivateFieldGet(je,this)?.destroyPopup();if(this.hasSelection){for(const e of tools_classPrivateFieldGet(mt,this))e.unselect();tools_classPrivateFieldGet(mt,this).clear();tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:!1})}}}translateSelectedEditors(e,t,i=!1){i||this.commitOrRemove();if(!this.hasSelection)return;tools_classPrivateFieldGet(yt,this)[0]+=e;tools_classPrivateFieldGet(yt,this)[1]+=t;const[a,s]=tools_classPrivateFieldGet(yt,this),n=[...tools_classPrivateFieldGet(mt,this)];tools_classPrivateFieldGet(St,this)&&clearTimeout(tools_classPrivateFieldGet(St,this));tools_classPrivateFieldSet(St,this,setTimeout(()=>{tools_classPrivateFieldSet(St,this,null);tools_classPrivateFieldGet(yt,this)[0]=tools_classPrivateFieldGet(yt,this)[1]=0;this.addCommands({cmd:()=>{for(const e of n)if(tools_classPrivateFieldGet(Te,this).has(e.id)){e.translateInPage(a,s);e.translationDone()}},undo:()=>{for(const e of n)if(tools_classPrivateFieldGet(Te,this).has(e.id)){e.translateInPage(-a,-s);e.translationDone()}},mustExec:!1})},1e3));for(const i of n){i.translateInPage(e,t);i.translationDone()}}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0);tools_classPrivateFieldSet(Ke,this,new Map);for(const e of tools_classPrivateFieldGet(mt,this))tools_classPrivateFieldGet(Ke,this).set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!tools_classPrivateFieldGet(Ke,this))return!1;this.disableUserSelect(!1);const e=tools_classPrivateFieldGet(Ke,this);tools_classPrivateFieldSet(Ke,this,null);let t=!1;for(const[{x:i,y:a,pageIndex:s},n]of e){n.newX=i;n.newY=a;n.newPageIndex=s;t||=i!==n.savedX||a!==n.savedY||s!==n.savedPageIndex}if(!t)return!1;const move=(e,t,i,a)=>{if(tools_classPrivateFieldGet(Te,this).has(e.id)){const s=tools_classPrivateFieldGet(De,this).get(a);if(s)e._setParentAndPosition(s,t,i);else{e.pageIndex=a;e.x=t;e.y=i}}};this.addCommands({cmd:()=>{for(const[t,{newX:i,newY:a,newPageIndex:s,savedX:n,savedY:r,savedPageIndex:o}]of e){move(t,i,a,s);this._eventBus?.dispatch("annotation-editor-event",{source:t,type:"moved",page:s+1,editorType:t.constructor.name,id:t.uid,previousValue:{x:n,y:r,page:o+1},value:{x:i,y:a,page:s+1}})}},undo:()=>{for(const[t,{savedX:i,savedY:a,savedPageIndex:s}]of e)move(t,i,a,s)},mustExec:!0});return!0}dragSelectedEditors(e,t){if(tools_classPrivateFieldGet(Ke,this))for(const i of tools_classPrivateFieldGet(Ke,this).keys())i.drag(e,t)}rebuild(e){if(null===e.parent){const t=this.getLayer(e.pageIndex);if(t){t.changeParent(e);t.addOrRebuild(e)}else{this.addEditor(e);this.addToAnnotationStorage(e);e.rebuild()}}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===tools_classPrivateFieldGet(mt,this).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return tools_classPrivateFieldGet(Me,this)===e}getActive(){return tools_classPrivateFieldGet(Me,this)}getMode(){return tools_classPrivateFieldGet(pt,this)}isEditingMode(){return tools_classPrivateFieldGet(pt,this)!==f.NONE}get imageManager(){return shadow(this,"imageManager",new ImageManager)}removeEditors(e=()=>!0){let t=!1;tools_classPrivateFieldGet(Te,this).forEach(i=>{if(i?.serialize()&&e(i.serialize())){i.remove();t=!0}});if(t){tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSomethingToUndo:!1,hasSomethingToRedo:!1,isEmpty:tools_assertClassBrand(At,this,_isEmpty).call(this)});tools_classPrivateFieldGet(We,this).reset()}}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let i=0,a=t.rangeCount;i<a;i++)if(!e.contains(t.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:a,width:s,height:n}=e.getBoundingClientRect();let r;switch(e.getAttribute("data-main-rotation")){case"90":r=(e,t,r,o)=>({x:(t-a)/n,y:1-(e+r-i)/s,width:o/n,height:r/s});break;case"180":r=(e,t,r,o)=>({x:1-(e+r-i)/s,y:1-(t+o-a)/n,width:r/s,height:o/n});break;case"270":r=(e,t,r,o)=>({x:1-(t+o-a)/n,y:(e-i)/s,width:o/n,height:r/s});break;default:r=(e,t,r,o)=>({x:(e-i)/s,y:(t-a)/n,width:r/s,height:o/n})}const o=[];for(let e=0,i=t.rangeCount;e<i;e++){const i=t.getRangeAt(e);if(!i.collapsed)for(const{x:e,y:t,width:a,height:s}of i.getClientRects())0!==a&&0!==s&&o.push(r(e,t,a,s))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:e,id:t}){(tools_classPrivateFieldGet(Oe,this)||tools_classPrivateFieldSet(Oe,this,new Map)).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){tools_classPrivateFieldGet(Oe,this)?.delete(e)}renderAnnotationElement(e){const t=tools_classPrivateFieldGet(Oe,this)?.get(e.data.id);if(!t)return;const i=tools_classPrivateFieldGet(Re,this).getRawValue(t);i&&(tools_classPrivateFieldGet(pt,this)!==f.NONE||i.hasBeenModified)&&i.renderAnnotationElement(e)}setMissingCanvas(e,t,i){const a=tools_classPrivateFieldGet(ut,this)?.get(e);if(a){a.setCanvas(t,i);tools_classPrivateFieldGet(ut,this).delete(e)}}addMissingCanvas(e,t){(tools_classPrivateFieldGet(ut,this)||tools_classPrivateFieldSet(ut,this,new Map)).set(e,t)}}function _getAnchorElementForSelection({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}function _getLayerForTextLayer(e){const{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(const t of tools_classPrivateFieldGet(De,this).values())if(t.hasTextLayer(e))return t;return null}function _displayFloatingToolbar(){const e=document.getSelection();if(!e||e.isCollapsed)return;const t=tools_assertClassBrand(At,this,_getAnchorElementForSelection).call(this,e).closest(".textLayer"),i=this.getSelectionBoxes(t);if(i){tools_classPrivateFieldGet(st,this)||tools_classPrivateFieldSet(st,this,new FloatingToolbar(this));tools_classPrivateFieldGet(st,this).show(t,i,"ltr"===this.direction)}}function _selectionChange(){const e=document.getSelection();if(!e||e.isCollapsed){if(tools_classPrivateFieldGet(ft,this)){tools_classPrivateFieldGet(st,this)?.hide();tools_classPrivateFieldSet(ft,this,null);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedText:!1})}return}const{anchorNode:t}=e;if(t===tools_classPrivateFieldGet(ft,this))return;const i=tools_assertClassBrand(At,this,_getAnchorElementForSelection).call(this,e).closest(".textLayer");if(i){tools_classPrivateFieldGet(st,this)?.hide();tools_classPrivateFieldSet(ft,this,t);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedText:!0});if(tools_classPrivateFieldGet(pt,this)===f.HIGHLIGHT||tools_classPrivateFieldGet(pt,this)===f.NONE){tools_classPrivateFieldGet(pt,this)===f.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0);tools_classPrivateFieldSet(at,this,this.isShiftKeyDown);if(!this.isShiftKeyDown){const e=tools_classPrivateFieldGet(pt,this)===f.HIGHLIGHT?tools_assertClassBrand(At,this,_getLayerForTextLayer).call(this,i):null;e?.toggleDrawing();if(tools_classPrivateFieldGet(ot,this)){const t=new AbortController,i=this.combinedSignal(t),pointerup=i=>{if("pointerup"!==i.type||0===i.button){t.abort();e?.toggleDrawing(!0);"pointerup"===i.type&&tools_assertClassBrand(At,this,_onSelectEnd).call(this,"main_toolbar")}};window.addEventListener("pointerup",pointerup,{signal:i});window.addEventListener("blur",pointerup,{signal:i})}else{e?.toggleDrawing(!0);tools_assertClassBrand(At,this,_onSelectEnd).call(this,"main_toolbar")}}}}else if(tools_classPrivateFieldGet(ft,this)){tools_classPrivateFieldGet(st,this)?.hide();tools_classPrivateFieldSet(ft,this,null);tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedText:!1})}}function _onSelectEnd(e=""){tools_classPrivateFieldGet(pt,this)===f.HIGHLIGHT?this.highlightSelection(e):tools_classPrivateFieldGet(Ye,this)&&tools_assertClassBrand(At,this,_displayFloatingToolbar).call(this)}function _addSelectionListener(){document.addEventListener("selectionchange",tools_assertClassBrand(At,this,_selectionChange).bind(this),{signal:this._signal})}function _addFocusManager(){if(tools_classPrivateFieldGet(tt,this))return;tools_classPrivateFieldSet(tt,this,new AbortController);const e=this.combinedSignal(tools_classPrivateFieldGet(tt,this));window.addEventListener("focus",this.focus.bind(this),{signal:e});window.addEventListener("blur",this.blur.bind(this),{signal:e})}function _removeFocusManager(){tools_classPrivateFieldGet(tt,this)?.abort();tools_classPrivateFieldSet(tt,this,null)}function _addKeyboardManager(){if(tools_classPrivateFieldGet(dt,this))return;tools_classPrivateFieldSet(dt,this,new AbortController);const e=this.combinedSignal(tools_classPrivateFieldGet(dt,this));window.addEventListener("keydown",this.keydown.bind(this),{signal:e});window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}function _removeKeyboardManager(){tools_classPrivateFieldGet(dt,this)?.abort();tools_classPrivateFieldSet(dt,this,null)}function _addCopyPasteListeners(){if(tools_classPrivateFieldGet(Ve,this))return;tools_classPrivateFieldSet(Ve,this,new AbortController);const e=this.combinedSignal(tools_classPrivateFieldGet(Ve,this));document.addEventListener("copy",this.copy.bind(this),{signal:e});document.addEventListener("cut",this.cut.bind(this),{signal:e});document.addEventListener("paste",this.paste.bind(this),{signal:e})}function _removeCopyPasteListeners(){tools_classPrivateFieldGet(Ve,this)?.abort();tools_classPrivateFieldSet(Ve,this,null)}function _addDragAndDropListeners(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e});document.addEventListener("drop",this.drop.bind(this),{signal:e})}function _dispatchUpdateStates(e){if(Object.entries(e).some(([e,t])=>tools_classPrivateFieldGet(bt,this)[e]!==t)){this._eventBus.dispatch("editingstateschanged",{source:this,details:Object.assign(tools_classPrivateFieldGet(bt,this),e)});tools_classPrivateFieldGet(pt,this)===f.HIGHLIGHT&&!1===e.hasSelectedEditor&&tools_assertClassBrand(At,this,_dispatchUpdateUI).call(this,[[v.HIGHLIGHT_FREE,!0]])}}function _dispatchUpdateUI(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}async function _enableAll(){if(!tools_classPrivateFieldGet(rt,this)){tools_classPrivateFieldSet(rt,this,!0);const e=[];for(const t of tools_classPrivateFieldGet(De,this).values())e.push(t.enable());await Promise.all(e);for(const e of tools_classPrivateFieldGet(Te,this).values())e.enable()}}function _disableAll(){this.unselectAll();if(tools_classPrivateFieldGet(rt,this)){tools_classPrivateFieldSet(rt,this,!1);for(const e of tools_classPrivateFieldGet(De,this).values())e.disable();for(const e of tools_classPrivateFieldGet(Te,this).values())e.disable()}}function _addEditorToLayer(e){const t=tools_classPrivateFieldGet(De,this).get(e.pageIndex);if(t)t.addOrRebuild(e);else{this.addEditor(e);this.addToAnnotationStorage(e)}}function _get_lastSelectedEditor(e){let t=null;for(t of tools_classPrivateFieldGet(mt,e));return t}function _isEmpty(){if(0===tools_classPrivateFieldGet(Te,this).size)return!0;if(1===tools_classPrivateFieldGet(Te,this).size)for(const e of tools_classPrivateFieldGet(Te,this).values())return e.isEmpty();return!1}function _selectEditors(e){for(const e of tools_classPrivateFieldGet(mt,this))e.unselect();tools_classPrivateFieldGet(mt,this).clear();for(const t of e)if(!t.isEmpty()){tools_classPrivateFieldGet(mt,this).add(t);t.select()}tools_assertClassBrand(At,this,_dispatchUpdateStates).call(this,{hasSelectedEditor:this.hasSelection})}tools_defineProperty(AnnotationEditorUIManager,"TRANSLATE_SMALL",1);tools_defineProperty(AnnotationEditorUIManager,"TRANSLATE_BIG",10);function alt_text_classPrivateFieldInitSpec(e,t,i){alt_text_checkPrivateRedeclaration(e,t),t.set(e,i)}function alt_text_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function alt_text_classPrivateGetter(e,t,i){return i(alt_text_assertClassBrand(e,t))}function alt_text_classPrivateFieldGet(e,t){return e.get(alt_text_assertClassBrand(e,t))}function alt_text_classPrivateFieldSet(e,t,i){return e.set(alt_text_assertClassBrand(e,t),i),i}function alt_text_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Gt=new WeakMap,Bt=new WeakMap,Mt=new WeakMap,It=new WeakMap,Tt=new WeakMap,Dt=new WeakMap,Lt=new WeakMap,Nt=new WeakMap,Rt=new WeakMap,Ot=new WeakMap,Wt=new WeakMap,jt=new WeakMap,Vt=new WeakSet;class AltText{constructor(e){!function alt_text_classPrivateMethodInitSpec(e,t){alt_text_checkPrivateRedeclaration(e,t),t.add(e)}(this,Vt);alt_text_classPrivateFieldInitSpec(this,Gt,null);alt_text_classPrivateFieldInitSpec(this,Bt,!1);alt_text_classPrivateFieldInitSpec(this,Mt,null);alt_text_classPrivateFieldInitSpec(this,It,null);alt_text_classPrivateFieldInitSpec(this,Tt,null);alt_text_classPrivateFieldInitSpec(this,Dt,null);alt_text_classPrivateFieldInitSpec(this,Lt,!1);alt_text_classPrivateFieldInitSpec(this,Nt,null);alt_text_classPrivateFieldInitSpec(this,Rt,null);alt_text_classPrivateFieldInitSpec(this,Ot,null);alt_text_classPrivateFieldInitSpec(this,Wt,null);alt_text_classPrivateFieldInitSpec(this,jt,!1);alt_text_classPrivateFieldSet(Rt,this,e);alt_text_classPrivateFieldSet(jt,this,e._uiManager.useNewAltTextFlow);Ut._||(Ut._=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(e){AltText._l10n??=e}async render(){const e=alt_text_classPrivateFieldSet(Mt,this,document.createElement("button"));e.className="altText";e.tabIndex="0";const t=alt_text_classPrivateFieldSet(It,this,document.createElement("span"));e.append(t);if(alt_text_classPrivateFieldGet(jt,this)){e.classList.add("new");e.setAttribute("data-l10n-id",Ut._.missing);t.setAttribute("data-l10n-id",Ut._["missing-label"])}else{e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button");t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label")}const i=alt_text_classPrivateFieldGet(Rt,this)._uiManager._signal;e.addEventListener("contextmenu",noContextMenu,{signal:i});e.addEventListener("pointerdown",e=>e.stopPropagation(),{signal:i});const onClick=e=>{e.preventDefault();alt_text_classPrivateFieldGet(Rt,this)._uiManager.editAltText(alt_text_classPrivateFieldGet(Rt,this));alt_text_classPrivateFieldGet(jt,this)&&alt_text_classPrivateFieldGet(Rt,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:alt_text_classPrivateGetter(Vt,this,_get_label)}})};e.addEventListener("click",onClick,{capture:!0,signal:i});e.addEventListener("keydown",t=>{if(t.target===e&&"Enter"===t.key){alt_text_classPrivateFieldSet(Lt,this,!0);onClick(t)}},{signal:i});await alt_text_assertClassBrand(Vt,this,_setState).call(this);return e}finish(){if(alt_text_classPrivateFieldGet(Mt,this)){alt_text_classPrivateFieldGet(Mt,this).focus({focusVisible:alt_text_classPrivateFieldGet(Lt,this)});alt_text_classPrivateFieldSet(Lt,this,!1)}}isEmpty(){return alt_text_classPrivateFieldGet(jt,this)?null===alt_text_classPrivateFieldGet(Gt,this):!alt_text_classPrivateFieldGet(Gt,this)&&!alt_text_classPrivateFieldGet(Bt,this)}hasData(){return alt_text_classPrivateFieldGet(jt,this)?null!==alt_text_classPrivateFieldGet(Gt,this)||!!alt_text_classPrivateFieldGet(Ot,this):this.isEmpty()}get guessedText(){return alt_text_classPrivateFieldGet(Ot,this)}async setGuessedText(e){if(null===alt_text_classPrivateFieldGet(Gt,this)){alt_text_classPrivateFieldSet(Ot,this,e);alt_text_classPrivateFieldSet(Wt,this,await AltText._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}));alt_text_assertClassBrand(Vt,this,_setState).call(this)}}toggleAltTextBadge(e=!1){if(alt_text_classPrivateFieldGet(jt,this)&&!alt_text_classPrivateFieldGet(Gt,this)){if(!alt_text_classPrivateFieldGet(Nt,this)){const e=alt_text_classPrivateFieldSet(Nt,this,document.createElement("div"));e.className="noAltTextBadge";alt_text_classPrivateFieldGet(Rt,this).div.append(e)}alt_text_classPrivateFieldGet(Nt,this).classList.toggle("hidden",!e)}else{alt_text_classPrivateFieldGet(Nt,this)?.remove();alt_text_classPrivateFieldSet(Nt,this,null)}}serialize(e){let t=alt_text_classPrivateFieldGet(Gt,this);e||alt_text_classPrivateFieldGet(Ot,this)!==t||(t=alt_text_classPrivateFieldGet(Wt,this));return{altText:t,decorative:alt_text_classPrivateFieldGet(Bt,this),guessedText:alt_text_classPrivateFieldGet(Ot,this),textWithDisclaimer:alt_text_classPrivateFieldGet(Wt,this)}}get data(){return{altText:alt_text_classPrivateFieldGet(Gt,this),decorative:alt_text_classPrivateFieldGet(Bt,this)}}set data({altText:e,decorative:t,guessedText:i,textWithDisclaimer:a,cancel:s=!1}){if(i){alt_text_classPrivateFieldSet(Ot,this,i);alt_text_classPrivateFieldSet(Wt,this,a)}if(alt_text_classPrivateFieldGet(Gt,this)!==e||alt_text_classPrivateFieldGet(Bt,this)!==t){if(!s){alt_text_classPrivateFieldSet(Gt,this,e);alt_text_classPrivateFieldSet(Bt,this,t)}alt_text_assertClassBrand(Vt,this,_setState).call(this)}}toggle(e=!1){if(alt_text_classPrivateFieldGet(Mt,this)){if(!e&&alt_text_classPrivateFieldGet(Dt,this)){clearTimeout(alt_text_classPrivateFieldGet(Dt,this));alt_text_classPrivateFieldSet(Dt,this,null)}alt_text_classPrivateFieldGet(Mt,this).disabled=!e}}shown(){alt_text_classPrivateFieldGet(Rt,this)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:alt_text_classPrivateGetter(Vt,this,_get_label)}})}destroy(){alt_text_classPrivateFieldGet(Mt,this)?.remove();alt_text_classPrivateFieldSet(Mt,this,null);alt_text_classPrivateFieldSet(It,this,null);alt_text_classPrivateFieldSet(Tt,this,null);alt_text_classPrivateFieldGet(Nt,this)?.remove();alt_text_classPrivateFieldSet(Nt,this,null)}}function _get_label(e){return(alt_text_classPrivateFieldGet(Gt,e)?"added":null===alt_text_classPrivateFieldGet(Gt,e)&&e.guessedText&&"review")||"missing"}async function _setState(){const e=alt_text_classPrivateFieldGet(Mt,this);if(!e)return;if(alt_text_classPrivateFieldGet(jt,this)){e.classList.toggle("done",!!alt_text_classPrivateFieldGet(Gt,this));e.setAttribute("data-l10n-id",Ut._[alt_text_classPrivateGetter(Vt,this,_get_label)]);alt_text_classPrivateFieldGet(It,this)?.setAttribute("data-l10n-id",Ut._[`${alt_text_classPrivateGetter(Vt,this,_get_label)}-label`]);if(!alt_text_classPrivateFieldGet(Gt,this)){alt_text_classPrivateFieldGet(Tt,this)?.remove();return}}else{if(!alt_text_classPrivateFieldGet(Gt,this)&&!alt_text_classPrivateFieldGet(Bt,this)){e.classList.remove("done");alt_text_classPrivateFieldGet(Tt,this)?.remove();return}e.classList.add("done");e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=alt_text_classPrivateFieldGet(Tt,this);if(!t){alt_text_classPrivateFieldSet(Tt,this,t=document.createElement("span"));t.className="tooltip";t.setAttribute("role","tooltip");t.id=`alt-text-tooltip-${alt_text_classPrivateFieldGet(Rt,this).id}`;const i=100,a=alt_text_classPrivateFieldGet(Rt,this)._uiManager._signal;a.addEventListener("abort",()=>{clearTimeout(alt_text_classPrivateFieldGet(Dt,this));alt_text_classPrivateFieldSet(Dt,this,null)},{once:!0});e.addEventListener("mouseenter",()=>{alt_text_classPrivateFieldSet(Dt,this,setTimeout(()=>{alt_text_classPrivateFieldSet(Dt,this,null);alt_text_classPrivateFieldGet(Tt,this).classList.add("show");alt_text_classPrivateFieldGet(Rt,this)._reportTelemetry({action:"alt_text_tooltip"})},i))},{signal:a});e.addEventListener("mouseleave",()=>{if(alt_text_classPrivateFieldGet(Dt,this)){clearTimeout(alt_text_classPrivateFieldGet(Dt,this));alt_text_classPrivateFieldSet(Dt,this,null)}alt_text_classPrivateFieldGet(Tt,this)?.classList.remove("show")},{signal:a})}if(alt_text_classPrivateFieldGet(Bt,this))t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip");else{t.removeAttribute("data-l10n-id");t.textContent=alt_text_classPrivateFieldGet(Gt,this)}t.parentNode||e.append(t);const i=alt_text_classPrivateFieldGet(Rt,this).getElementForAltText();i?.setAttribute("aria-describedby",t.id)}var Ut={_:null};!function alt_text_defineProperty(e,t,i){return(t=function alt_text_toPropertyKey(e){var t=function alt_text_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(AltText,"_l10n",null);function comment_classPrivateFieldInitSpec(e,t,i){comment_checkPrivateRedeclaration(e,t),t.set(e,i)}function comment_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function comment_classPrivateFieldGet(e,t){return e.get(comment_assertClassBrand(e,t))}function comment_classPrivateFieldSet(e,t,i){return e.set(comment_assertClassBrand(e,t),i),i}function comment_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var zt=new WeakMap,Ht=new WeakMap,$t=new WeakMap,Kt=new WeakMap,Xt=new WeakMap,qt=new WeakMap,Yt=new WeakMap,Zt=new WeakMap,Qt=new WeakMap,Jt=new WeakMap,ei=new WeakSet;class Comment{constructor(e){!function comment_classPrivateMethodInitSpec(e,t){comment_checkPrivateRedeclaration(e,t),t.add(e)}(this,ei);comment_classPrivateFieldInitSpec(this,zt,null);comment_classPrivateFieldInitSpec(this,Ht,null);comment_classPrivateFieldInitSpec(this,$t,!1);comment_classPrivateFieldInitSpec(this,Kt,null);comment_classPrivateFieldInitSpec(this,Xt,null);comment_classPrivateFieldInitSpec(this,qt,null);comment_classPrivateFieldInitSpec(this,Yt,null);comment_classPrivateFieldInitSpec(this,Zt,null);comment_classPrivateFieldInitSpec(this,Qt,!1);comment_classPrivateFieldInitSpec(this,Jt,null);comment_classPrivateFieldSet(Kt,this,e)}renderForToolbar(){const e=comment_classPrivateFieldSet(Ht,this,document.createElement("button"));e.className="comment";return comment_assertClassBrand(ei,this,comment_render).call(this,e,!1)}renderForStandalone(){const e=comment_classPrivateFieldSet(zt,this,document.createElement("button"));e.className="annotationCommentButton";const t=comment_classPrivateFieldGet(Kt,this).commentButtonPosition;if(t){const{style:i}=e;i.insetInlineEnd=`calc(${100*("ltr"===comment_classPrivateFieldGet(Kt,this)._uiManager.direction?1-t[0]:t[0])}% - var(--comment-button-dim))`;i.top=`calc(${100*t[1]}% - var(--comment-button-dim))`;const a=comment_classPrivateFieldGet(Kt,this).commentButtonColor;a&&(i.backgroundColor=a)}return comment_assertClassBrand(ei,this,comment_render).call(this,e,!0)}focusButton(){setTimeout(()=>{(comment_classPrivateFieldGet(zt,this)??comment_classPrivateFieldGet(Ht,this))?.focus()},0)}onUpdatedColor(){if(!comment_classPrivateFieldGet(zt,this))return;const e=comment_classPrivateFieldGet(Kt,this).commentButtonColor;e&&(comment_classPrivateFieldGet(zt,this).style.backgroundColor=e);comment_classPrivateFieldGet(Kt,this)._uiManager.updatePopupColor(comment_classPrivateFieldGet(Kt,this))}get commentButtonWidth(){return(comment_classPrivateFieldGet(zt,this)?.getBoundingClientRect().width??0)/comment_classPrivateFieldGet(Kt,this).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(comment_classPrivateFieldGet(Jt,this))return comment_classPrivateFieldGet(Jt,this);if(!comment_classPrivateFieldGet(zt,this))return null;const{x:e,y:t,height:i}=comment_classPrivateFieldGet(zt,this).getBoundingClientRect(),{x:a,y:s,width:n,height:r}=comment_classPrivateFieldGet(Kt,this).parent.boundingClientRect;return[(e-a)/n,(t+i-s)/r]}set commentPopupPositionInLayer(e){comment_classPrivateFieldSet(Jt,this,e)}hasDefaultPopupPosition(){return null===comment_classPrivateFieldGet(Jt,this)}removeStandaloneCommentButton(){comment_classPrivateFieldGet(zt,this)?.remove();comment_classPrivateFieldSet(zt,this,null)}removeToolbarCommentButton(){comment_classPrivateFieldGet(Ht,this)?.remove();comment_classPrivateFieldSet(Ht,this,null)}setCommentButtonStates({selected:e,hasPopup:t}){if(comment_classPrivateFieldGet(zt,this)){comment_classPrivateFieldGet(zt,this).classList.toggle("selected",e);comment_classPrivateFieldGet(zt,this).ariaExpanded=t}}edit(e){const t=this.commentPopupPositionInLayer;let i,a;if(t)[i,a]=t;else{[i,a]=comment_classPrivateFieldGet(Kt,this).commentButtonPosition;const{width:e,height:t,x:s,y:n}=comment_classPrivateFieldGet(Kt,this);i=s+i*e;a=n+a*t}const s=comment_classPrivateFieldGet(Kt,this).parent.boundingClientRect,{x:n,y:r,width:o,height:l}=s;comment_classPrivateFieldGet(Kt,this)._uiManager.editComment(comment_classPrivateFieldGet(Kt,this),n+i*o,r+a*l,{...e,parentDimensions:s})}finish(){if(comment_classPrivateFieldGet(Ht,this)){comment_classPrivateFieldGet(Ht,this).focus({focusVisible:comment_classPrivateFieldGet($t,this)});comment_classPrivateFieldSet($t,this,!1)}}isDeleted(){return comment_classPrivateFieldGet(Qt,this)||""===comment_classPrivateFieldGet(Yt,this)}isEmpty(){return null===comment_classPrivateFieldGet(Yt,this)}hasBeenEdited(){return this.isDeleted()||comment_classPrivateFieldGet(Yt,this)!==comment_classPrivateFieldGet(Xt,this)}serialize(){return this.data}get data(){return{text:comment_classPrivateFieldGet(Yt,this),richText:comment_classPrivateFieldGet(qt,this),date:comment_classPrivateFieldGet(Zt,this),deleted:this.isDeleted()}}set data(e){e!==comment_classPrivateFieldGet(Yt,this)&&comment_classPrivateFieldSet(qt,this,null);if(null!==e){comment_classPrivateFieldSet(Yt,this,e);comment_classPrivateFieldSet(Zt,this,new Date);comment_classPrivateFieldSet(Qt,this,!1);comment_classPrivateFieldGet(Kt,this).eventBus?.dispatch("annotation-editor-event",{source:comment_classPrivateFieldGet(Kt,this),type:"commented",page:comment_classPrivateFieldGet(Kt,this).pageIndex+1,editorType:comment_classPrivateFieldGet(Kt,this).constructor.name,id:comment_classPrivateFieldGet(Kt,this).uid,value:comment_classPrivateFieldGet(Kt,this)})}else{comment_classPrivateFieldSet(Yt,this,"");comment_classPrivateFieldSet(Qt,this,!0);comment_classPrivateFieldGet(Kt,this).eventBus?.dispatch("annotation-editor-event",{source:comment_classPrivateFieldGet(Kt,this),type:"commentRemoved",page:comment_classPrivateFieldGet(Kt,this).pageIndex+1,editorType:comment_classPrivateFieldGet(Kt,this).constructor.name,id:comment_classPrivateFieldGet(Kt,this).uid,value:comment_classPrivateFieldGet(Kt,this)})}}restoreData({text:e,richText:t,date:i}){comment_classPrivateFieldSet(Yt,this,e);comment_classPrivateFieldSet(qt,this,t);comment_classPrivateFieldSet(Zt,this,i);comment_classPrivateFieldSet(Qt,this,!1)}setInitialText(e,t=null){comment_classPrivateFieldSet(Xt,this,e);this.data=e;comment_classPrivateFieldSet(Zt,this,null);comment_classPrivateFieldSet(qt,this,t)}setDate(e){const t=e&&new Date(e);!t||isNaN(t)?comment_classPrivateFieldSet(Zt,this,new Date):comment_classPrivateFieldSet(Zt,this,t)}shown(){}destroy(){comment_classPrivateFieldGet(Ht,this)?.remove();comment_classPrivateFieldSet(Ht,this,null);comment_classPrivateFieldGet(zt,this)?.remove();comment_classPrivateFieldSet(zt,this,null);comment_classPrivateFieldSet(Yt,this,"");comment_classPrivateFieldSet(qt,this,null);comment_classPrivateFieldSet(Zt,this,null);comment_classPrivateFieldSet(Kt,this,null);comment_classPrivateFieldSet($t,this,!1);comment_classPrivateFieldSet(Qt,this,!1)}}function comment_render(e,t){if(!comment_classPrivateFieldGet(Kt,this)._uiManager.hasCommentManager())return null;e.tabIndex="0";e.ariaHasPopup="dialog";if(t){e.ariaControls="commentPopup";e.setAttribute("data-l10n-id","pdfjs-show-comment-button")}else{e.ariaControlsElements=[comment_classPrivateFieldGet(Kt,this)._uiManager.getCommentDialogElement()];e.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button")}const i=comment_classPrivateFieldGet(Kt,this)._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return e;e.addEventListener("contextmenu",noContextMenu,{signal:i});if(t){e.addEventListener("focusin",e=>{comment_classPrivateFieldGet(Kt,this)._focusEventsAllowed=!1;stopEvent(e)},{capture:!0,signal:i});e.addEventListener("focusout",e=>{comment_classPrivateFieldGet(Kt,this)._focusEventsAllowed=!0;stopEvent(e)},{capture:!0,signal:i})}e.addEventListener("pointerdown",e=>e.stopPropagation(),{signal:i});const onClick=t=>{t.preventDefault();e===comment_classPrivateFieldGet(Ht,this)?this.edit():comment_classPrivateFieldGet(Kt,this).toggleComment(!0)};e.addEventListener("click",onClick,{capture:!0,signal:i});e.addEventListener("keydown",t=>{if(t.target===e&&"Enter"===t.key){comment_classPrivateFieldSet($t,this,!0);onClick(t)}},{signal:i});e.addEventListener("pointerenter",()=>{comment_classPrivateFieldGet(Kt,this).toggleComment(!1,!0)},{signal:i});e.addEventListener("pointerleave",()=>{comment_classPrivateFieldGet(Kt,this).toggleComment(!1,!1)},{signal:i});return e}function touch_manager_classPrivateFieldInitSpec(e,t,i){touch_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function touch_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function touch_manager_classPrivateFieldGet(e,t){return e.get(touch_manager_assertClassBrand(e,t))}function touch_manager_classPrivateFieldSet(e,t,i){return e.set(touch_manager_assertClassBrand(e,t),i),i}function touch_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var ti,ii=new WeakMap,ai=new WeakMap,si=new WeakMap,ni=new WeakMap,ri=new WeakMap,oi=new WeakMap,li=new WeakMap,di=new WeakMap,ci=new WeakMap,hi=new WeakMap,ui=new WeakMap,_i=new WeakMap,pi=new WeakSet;class TouchManager{constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:i=null,onPinchStart:a=null,onPinching:s=null,onPinchEnd:n=null,signal:r}){!function touch_manager_classPrivateMethodInitSpec(e,t){touch_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,pi);touch_manager_classPrivateFieldInitSpec(this,ii,void 0);touch_manager_classPrivateFieldInitSpec(this,ai,!1);touch_manager_classPrivateFieldInitSpec(this,si,null);touch_manager_classPrivateFieldInitSpec(this,ni,void 0);touch_manager_classPrivateFieldInitSpec(this,ri,void 0);touch_manager_classPrivateFieldInitSpec(this,oi,void 0);touch_manager_classPrivateFieldInitSpec(this,li,void 0);touch_manager_classPrivateFieldInitSpec(this,di,null);touch_manager_classPrivateFieldInitSpec(this,ci,void 0);touch_manager_classPrivateFieldInitSpec(this,hi,null);touch_manager_classPrivateFieldInitSpec(this,ui,void 0);touch_manager_classPrivateFieldInitSpec(this,_i,null);touch_manager_classPrivateFieldSet(ii,this,e);touch_manager_classPrivateFieldSet(si,this,i);touch_manager_classPrivateFieldSet(ni,this,t);touch_manager_classPrivateFieldSet(ri,this,a);touch_manager_classPrivateFieldSet(oi,this,s);touch_manager_classPrivateFieldSet(li,this,n);touch_manager_classPrivateFieldSet(ui,this,new AbortController);touch_manager_classPrivateFieldSet(ci,this,AbortSignal.any([r,touch_manager_classPrivateFieldGet(ui,this).signal]));e.addEventListener("touchstart",touch_manager_assertClassBrand(pi,this,_onTouchStart).bind(this),{passive:!1,signal:touch_manager_classPrivateFieldGet(ci,this)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/OutputScale.pixelRatio}destroy(){touch_manager_classPrivateFieldGet(ui,this)?.abort();touch_manager_classPrivateFieldSet(ui,this,null);touch_manager_classPrivateFieldGet(di,this)?.abort();touch_manager_classPrivateFieldSet(di,this,null)}}function _onTouchStart(e){if(touch_manager_classPrivateFieldGet(ni,this)?.call(this))return;if(1===e.touches.length){if(touch_manager_classPrivateFieldGet(di,this))return;const e=touch_manager_classPrivateFieldSet(di,this,new AbortController),t=AbortSignal.any([touch_manager_classPrivateFieldGet(ci,this),e.signal]),i=touch_manager_classPrivateFieldGet(ii,this),a={capture:!0,signal:t,passive:!1},cancelPointerDown=e=>{if("touch"===e.pointerType){touch_manager_classPrivateFieldGet(di,this)?.abort();touch_manager_classPrivateFieldSet(di,this,null)}};i.addEventListener("pointerdown",e=>{if("touch"===e.pointerType){stopEvent(e);cancelPointerDown(e)}},a);i.addEventListener("pointerup",cancelPointerDown,a);i.addEventListener("pointercancel",cancelPointerDown,a);return}if(!touch_manager_classPrivateFieldGet(_i,this)){touch_manager_classPrivateFieldSet(_i,this,new AbortController);const e=AbortSignal.any([touch_manager_classPrivateFieldGet(ci,this),touch_manager_classPrivateFieldGet(_i,this).signal]),t=touch_manager_classPrivateFieldGet(ii,this),i={signal:e,capture:!1,passive:!1};t.addEventListener("touchmove",touch_manager_assertClassBrand(pi,this,_onTouchMove).bind(this),i);const a=touch_manager_assertClassBrand(pi,this,_onTouchEnd).bind(this);t.addEventListener("touchend",a,i);t.addEventListener("touchcancel",a,i);i.capture=!0;t.addEventListener("pointerdown",stopEvent,i);t.addEventListener("pointermove",stopEvent,i);t.addEventListener("pointercancel",stopEvent,i);t.addEventListener("pointerup",stopEvent,i);touch_manager_classPrivateFieldGet(ri,this)?.call(this)}stopEvent(e);if(2!==e.touches.length||touch_manager_classPrivateFieldGet(si,this)?.call(this)){touch_manager_classPrivateFieldSet(hi,this,null);return}let[t,i]=e.touches;t.identifier>i.identifier&&([t,i]=[i,t]);touch_manager_classPrivateFieldSet(hi,this,{touch0X:t.screenX,touch0Y:t.screenY,touch1X:i.screenX,touch1Y:i.screenY})}function _onTouchMove(e){if(!touch_manager_classPrivateFieldGet(hi,this)||2!==e.touches.length)return;stopEvent(e);let[t,i]=e.touches;t.identifier>i.identifier&&([t,i]=[i,t]);const{screenX:a,screenY:s}=t,{screenX:n,screenY:r}=i,o=touch_manager_classPrivateFieldGet(hi,this),{touch0X:l,touch0Y:d,touch1X:c,touch1Y:h}=o,u=c-l,_=h-d,p=n-a,g=r-s,m=Math.hypot(p,g)||1,f=Math.hypot(u,_)||1;if(!touch_manager_classPrivateFieldGet(ai,this)&&Math.abs(f-m)<=this.MIN_TOUCH_DISTANCE_TO_PINCH)return;o.touch0X=a;o.touch0Y=s;o.touch1X=n;o.touch1Y=r;if(!touch_manager_classPrivateFieldGet(ai,this)){touch_manager_classPrivateFieldSet(ai,this,!0);return}const v=[(t.screenX+i.screenX)/2,(t.screenY+i.screenY)/2];touch_manager_classPrivateFieldGet(oi,this)?.call(this,v,f,m)}function _onTouchEnd(e){if(!(e.touches.length>=2)){if(touch_manager_classPrivateFieldGet(_i,this)){touch_manager_classPrivateFieldGet(_i,this).abort();touch_manager_classPrivateFieldSet(_i,this,null);touch_manager_classPrivateFieldGet(li,this)?.call(this)}if(touch_manager_classPrivateFieldGet(hi,this)){stopEvent(e);touch_manager_classPrivateFieldSet(hi,this,null);touch_manager_classPrivateFieldSet(ai,this,!1)}}}function editor_defineProperty(e,t,i){return(t=function editor_toPropertyKey(e){var t=function editor_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function editor_classPrivateFieldInitSpec(e,t,i){editor_checkPrivateRedeclaration(e,t),t.set(e,i)}function editor_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function editor_classPrivateFieldSet(e,t,i){return e.set(editor_assertClassBrand(e,t),i),i}function editor_classPrivateFieldGet(e,t){return e.get(editor_assertClassBrand(e,t))}function editor_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var gi=new WeakMap,mi=new WeakMap,fi=new WeakMap,vi=new WeakMap,Pi=new WeakMap,wi=new WeakMap,Fi=new WeakMap,bi=new WeakMap,yi=new WeakMap,Si=new WeakMap,Ci=new WeakMap,xi=new WeakMap,ki=new WeakMap,Ei=new WeakMap,Ai=new WeakMap,Gi=new WeakMap,Bi=new WeakMap,Mi=new WeakMap,Ii=new WeakMap,Ti=new WeakMap,Di=new WeakMap,Li=new WeakMap,Ni=new WeakMap,Ri=new WeakMap,Oi=new WeakMap,Wi=new WeakMap,ji=new WeakMap,Vi=new WeakSet;class AnnotationEditor{static get _resizerKeyboardManager(){const e=AnnotationEditor.prototype._resizeWithKeyboard,t=AnnotationEditorUIManager.TRANSLATE_SMALL,i=AnnotationEditorUIManager.TRANSLATE_BIG;return shadow(this,"_resizerKeyboardManager",new KeyboardManager([[["ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-i,0]}],[["ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[i,0]}],[["ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-i]}],[["ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,i]}],[["Escape"],AnnotationEditor.prototype._stopResizingWithKeyboard]]))}constructor(e){!function editor_classPrivateMethodInitSpec(e,t){editor_checkPrivateRedeclaration(e,t),t.add(e)}(this,Vi);editor_classPrivateFieldInitSpec(this,gi,null);editor_classPrivateFieldInitSpec(this,mi,null);editor_classPrivateFieldInitSpec(this,fi,null);editor_classPrivateFieldInitSpec(this,vi,null);editor_classPrivateFieldInitSpec(this,Pi,null);editor_classPrivateFieldInitSpec(this,wi,!1);editor_classPrivateFieldInitSpec(this,Fi,null);editor_classPrivateFieldInitSpec(this,bi,"");editor_classPrivateFieldInitSpec(this,yi,!1);editor_classPrivateFieldInitSpec(this,Si,null);editor_classPrivateFieldInitSpec(this,Ci,null);editor_classPrivateFieldInitSpec(this,xi,null);editor_classPrivateFieldInitSpec(this,ki,null);editor_classPrivateFieldInitSpec(this,Ei,null);editor_classPrivateFieldInitSpec(this,Ai,"");editor_classPrivateFieldInitSpec(this,Gi,!1);editor_classPrivateFieldInitSpec(this,Bi,null);editor_classPrivateFieldInitSpec(this,Mi,!1);editor_classPrivateFieldInitSpec(this,Ii,!1);editor_classPrivateFieldInitSpec(this,Ti,!1);editor_classPrivateFieldInitSpec(this,Di,null);editor_classPrivateFieldInitSpec(this,Li,0);editor_classPrivateFieldInitSpec(this,Ni,0);editor_classPrivateFieldInitSpec(this,Ri,null);editor_classPrivateFieldInitSpec(this,Oi,null);editor_defineProperty(this,"isSelected",!1);editor_defineProperty(this,"_isCopy",!1);editor_defineProperty(this,"_editToolbar",null);editor_defineProperty(this,"_initialOptions",Object.create(null));editor_defineProperty(this,"_initialData",null);editor_defineProperty(this,"_isVisible",!0);editor_defineProperty(this,"_uiManager",null);editor_defineProperty(this,"_focusEventsAllowed",!0);editor_classPrivateFieldInitSpec(this,Wi,!1);editor_classPrivateFieldInitSpec(this,ji,AnnotationEditor._zIndex++);editor_defineProperty(this,"doNotMove",!1);editor_defineProperty(this,"customId",null);this.parent=e.parent;this.id=e.id;this.width=this.height=null;this.pageIndex=e.parent.pageIndex;this.name=e.name;this.div=null;this._uiManager=e.uiManager;this.annotationElementId=null;this._willKeepAspectRatio=!1;this._initialOptions.isCentered=e.isCentered;this._structTreeParentId=null;this.annotationElementId=e.annotationElementId||null;this.creationDate=e.creationDate||new Date;this.modificationDate=e.modificationDate||null;this.canAddComment=!0;const{rotation:t,rawDims:{pageWidth:i,pageHeight:a,pageX:s,pageY:n}}=this.parent.viewport;this.rotation=t;this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360;this.pageDimensions=[i,a];this.pageTranslation=[s,n];const[r,o]=this.parentDimensions;this.x=e.x/r;this.y=e.y/o;this.isAttachedToDOM=!1;this.deleted=!1;this.eventBus=e.eventBus}updatePageIndex(e){this.pageIndex=e}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return shadow(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new FakeEditor({id:e._uiManager.getId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId;t.deleted=!0;t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){AnnotationEditor._l10n??=e;AnnotationEditor._l10nAlert??=Object.freeze({highlight:"pdfjs-editor-highlight-added-alert",freetext:"pdfjs-editor-freetext-added-alert",ink:"pdfjs-editor-ink-added-alert",stamp:"pdfjs-editor-stamp-added-alert",signature:"pdfjs-editor-signature-added-alert"});AnnotationEditor._l10nResizer??=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"});if(-1!==AnnotationEditor._borderLineWidth)return;const i=getComputedStyle(document.documentElement);AnnotationEditor._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){unreachable("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return editor_classPrivateFieldGet(Wi,this)}set _isDraggable(e){editor_classPrivateFieldSet(Wi,this,e);this.div?.classList.toggle("draggable",e)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(2*e);this.y+=this.width*e/(2*t);break;case 180:this.x+=this.width/2;this.y+=this.height/2;break;case 270:this.x+=this.height*t/(2*e);this.y-=this.width*e/(2*t);break;default:this.x-=this.width/2;this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=editor_classPrivateFieldGet(ji,this)}setParent(e){if(null!==e){this.pageIndex=e.pageIndex;this.pageDimensions=e.pageDimensions}else{editor_assertClassBrand(Vi,this,_stopResizing).call(this);editor_classPrivateFieldGet(ki,this)?.remove();editor_classPrivateFieldSet(ki,this,null)}this.parent=e}focusin(e){this._focusEventsAllowed&&(editor_classPrivateFieldGet(Gi,this)?editor_classPrivateFieldSet(Gi,this,!1):this.parent.setSelected(this))}focusout(e){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const t=e.relatedTarget;if(!t?.closest(`#${this.id}`)){e.preventDefault();this.parent?.isMultipleSelection||this.commitOrRemove()}}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){if(this.isInEditMode()){this.addToAnnotationStorage();this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"commit",page:this.pageIndex+1,editorType:this.constructor.name,value:this,id:this.uid})}}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,i,a){const[s,n]=this.parentDimensions;[i,a]=this.screenToPageTranslation(i,a);this.doNotMove&&([i,a]=[0,0]);this.x=(e+i)/s;this.y=(t+a)/n;this.fixAndSetPosition()}_moveAfterPaste(e,t){if(this.isClone){delete this.isClone;return}const[i,a]=this.parentDimensions;this.setAt(e*i,t*a,this.width*i,this.height*a);this.doNotMove||this._onTranslated()}translate(e,t){editor_assertClassBrand(Vi,this,_translate).call(this,this.parentDimensions,e,t)}translateInPage(e,t){editor_classPrivateFieldGet(Bi,this)||editor_classPrivateFieldSet(Bi,this,[this.x,this.y,this.width,this.height]);editor_assertClassBrand(Vi,this,_translate).call(this,this.pageDimensions,e,t);this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(e,t){editor_classPrivateFieldGet(Bi,this)||editor_classPrivateFieldSet(Bi,this,[this.x,this.y,this.width,this.height]);const{div:i,parentDimensions:[a,s]}=this;this.x+=e/a;this.y+=t/s;if(this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:e,y:t}=this.div.getBoundingClientRect();if(this.parent.findNewParent(this,e,t)){this.x-=Math.floor(this.x);this.y-=Math.floor(this.y)}}let{x:n,y:r}=this;const[o,l]=this.getBaseTranslation();n+=o;r+=l;const{style:d}=i;d.left=`${(100*n).toFixed(2)}%`;d.top=`${(100*r).toFixed(2)}%`;this._onTranslating(n,r);i.scrollIntoView({block:"nearest"})}_onTranslating(e,t){}_onTranslated(e,t){this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"moved",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:{x:e,y:t}})}_dispatchEditorEvent(e,t=null){const i={source:this,type:e,page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,...t};for(const e of Object.keys(i))void 0===i[e]&&delete i[e];this.eventBus?.dispatch("annotation-editor-event",i)}get addedEventValue(){return{}}_dispatchAddedEvent(){this._dispatchEditorEvent("added",{value:this.addedEventValue})}get _hasBeenMoved(){return!!editor_classPrivateFieldGet(Bi,this)&&(editor_classPrivateFieldGet(Bi,this)[0]!==this.x||editor_classPrivateFieldGet(Bi,this)[1]!==this.y)}get _hasBeenResized(){return!!editor_classPrivateFieldGet(Bi,this)&&(editor_classPrivateFieldGet(Bi,this)[2]!==this.width||editor_classPrivateFieldGet(Bi,this)[3]!==this.height)}getBaseTranslation(){const[e,t]=this.parentDimensions,{_borderLineWidth:i}=AnnotationEditor,a=i/e,s=i/t;switch(this.rotation){case 90:return[-a,s];case 180:return[a,s];case 270:return[a,-s];default:return[-a,-s]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:t},pageDimensions:[i,a]}=this;let{x:s,y:n,width:r,height:o}=this;r*=i;o*=a;s*=i;n*=a;if(this._mustFixPosition)switch(e){case 0:s=MathClamp(s,0,i-r);n=MathClamp(n,0,a-o);break;case 90:s=MathClamp(s,0,i-o);n=MathClamp(n,r,a);break;case 180:s=MathClamp(s,r,i);n=MathClamp(n,o,a);break;case 270:s=MathClamp(s,o,i);n=MathClamp(n,0,a-r)}this.x=s/=i;this.y=n/=a;const[l,d]=this.getBaseTranslation();s+=l;n+=d;t.left=`${(100*s).toFixed(2)}%`;t.top=`${(100*n).toFixed(2)}%`;this.moveInDOM()}screenToPageTranslation(e,t){return _rotatePoint.call(AnnotationEditor,e,t,this.parentRotation)}pageTranslationToScreen(e,t){return _rotatePoint.call(AnnotationEditor,e,t,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,i]}=this;return[t*e,i*e]}setDims(){const{div:{style:e},width:t,height:i}=this;e.width=`${(100*t).toFixed(2)}%`;e.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(e){return Math.round(1e4*e)/1e4}_onResizing(){}altTextFinish(){editor_classPrivateFieldGet(fi,this)?.finish();this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"altTextChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:editor_classPrivateFieldGet(fi,this)})}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||editor_classPrivateFieldGet(Ii,this))return this._editToolbar;this._editToolbar=new EditorToolbar(this);this.div.append(this._editToolbar.render());const{toolbarButtons:e}=this;if(e)for(const[t,i]of e)await this._editToolbar.addButton(t,i);this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton());this._editToolbar.addButton("delete");return this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){this._editToolbar?.remove();this._editToolbar=null;editor_classPrivateFieldGet(fi,this)?.destroy()}addContainer(e){const t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){if(!editor_classPrivateFieldGet(fi,this)){AltText.initialize(AnnotationEditor._l10n);editor_classPrivateFieldSet(fi,this,new AltText(this));if(editor_classPrivateFieldGet(gi,this)){editor_classPrivateFieldGet(fi,this).data=editor_classPrivateFieldGet(gi,this);editor_classPrivateFieldSet(gi,this,null)}}return editor_classPrivateFieldGet(fi,this)}get altTextData(){return editor_classPrivateFieldGet(fi,this)?.data}set altTextData(e){editor_classPrivateFieldGet(fi,this)&&(editor_classPrivateFieldGet(fi,this).data=e)}get guessedAltText(){return editor_classPrivateFieldGet(fi,this)?.guessedText}async setGuessedAltText(e){await(editor_classPrivateFieldGet(fi,this)?.setGuessedText(e))}serializeAltText(e){return editor_classPrivateFieldGet(fi,this)?.serialize(e)}hasAltText(){return!!editor_classPrivateFieldGet(fi,this)&&!editor_classPrivateFieldGet(fi,this).isEmpty()}hasAltTextData(){return editor_classPrivateFieldGet(fi,this)?.hasData()??!1}focusCommentButton(){editor_classPrivateFieldGet(vi,this)?.focusButton()}addCommentButton(){return this.canAddComment?editor_classPrivateFieldGet(vi,this)||editor_classPrivateFieldSet(vi,this,new Comment(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager())if(editor_classPrivateFieldGet(Pi,this))this._uiManager.isEditingMode()&&editor_classPrivateFieldGet(Pi,this).classList.remove("hidden");else if(this.hasComment){editor_classPrivateFieldSet(Pi,this,editor_classPrivateFieldGet(vi,this).renderForStandalone());this.div.append(editor_classPrivateFieldGet(Pi,this))}}removeStandaloneCommentButton(){editor_classPrivateFieldGet(vi,this).removeStandaloneCommentButton();editor_classPrivateFieldSet(Pi,this,null)}hideStandaloneCommentButton(){editor_classPrivateFieldGet(Pi,this)?.classList.add("hidden")}get comment(){if(!editor_classPrivateFieldGet(vi,this))return null;const{data:{richText:e,text:t,date:i,deleted:a}}=editor_classPrivateFieldGet(vi,this);return{text:t,richText:e,date:i,deleted:a,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(e){editor_classPrivateFieldGet(vi,this)||editor_classPrivateFieldSet(vi,this,new Comment(this));"object"==typeof e&&null!==e?editor_classPrivateFieldGet(vi,this).restoreData(e):editor_classPrivateFieldGet(vi,this).data=e;if(this.hasComment){this.removeCommentButtonFromToolbar();this.addStandaloneCommentButton();this._uiManager.updateComment(this)}else{this.addCommentButtonInToolbar();this.removeStandaloneCommentButton();this._uiManager.removeComment(this)}}setCommentData({comment:e,popupRef:t,richText:i,commentDate:a}){if(!t)return;editor_classPrivateFieldGet(vi,this)||editor_classPrivateFieldSet(vi,this,new Comment(this));editor_classPrivateFieldGet(vi,this).setInitialText(e,i);a&&editor_classPrivateFieldGet(vi,this).setDate(a);if(!this.annotationElementId)return;const s=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);s&&this.updateFromAnnotationLayer(s)}get hasEditedComment(){return editor_classPrivateFieldGet(vi,this)?.hasBeenEdited()}get hasDeletedComment(){return editor_classPrivateFieldGet(vi,this)?.isDeleted()}get hasComment(){return!!editor_classPrivateFieldGet(vi,this)&&!editor_classPrivateFieldGet(vi,this).isEmpty()&&!editor_classPrivateFieldGet(vi,this).isDeleted()}async editComment(e){editor_classPrivateFieldGet(vi,this)||editor_classPrivateFieldSet(vi,this,new Comment(this));editor_classPrivateFieldGet(vi,this).edit(e)}toggleComment(e,t=void 0){this.hasComment&&this._uiManager.toggleComment(this,e,t)}setSelectedCommentButton(e){editor_classPrivateFieldGet(vi,this).setSelectedButton(e)}addComment(e,t=!1){if(this.hasEditedComment||t&&this.hasComment){const t=180,i=100,[,,,a]=e.rect,[s]=this.pageDimensions,[n]=this.pageTranslation,r=n+s+1,o=a-i,l=r+t;e.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[r,o,l,a],date:this.comment.date?.toISOString()}}}updateFromAnnotationLayer({popup:{contents:e,deleted:t}}){editor_classPrivateFieldGet(vi,this).data=t?null:e}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360);e.className=this.name;e.setAttribute("id",this.id);e.tabIndex=editor_classPrivateFieldGet(wi,this)?-1:0;e.setAttribute("role","application");this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId);this._isVisible||e.classList.add("hidden");this.setInForeground();editor_assertClassBrand(Vi,this,_addFocusListeners).call(this);const[t,i]=this.parentDimensions;if(this.parentRotation%180!=0){e.style.maxWidth=`${(100*i/t).toFixed(2)}%`;e.style.maxHeight=`${(100*t/i).toFixed(2)}%`}const[a,s]=this.getInitialTranslation();this.translate(a,s);bindEvents(this,e,["keydown","pointerdown","dblclick"]);this.isResizable&&this._uiManager._supportsPinchToZoom&&(editor_classPrivateFieldGet(Oi,this)||editor_classPrivateFieldSet(Oi,this,new TouchManager({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:editor_assertClassBrand(Vi,this,_touchPinchStartCallback).bind(this),onPinching:editor_assertClassBrand(Vi,this,_touchPinchCallback).bind(this),onPinchEnd:editor_assertClassBrand(Vi,this,_touchPinchEndCallback).bind(this),signal:this._uiManager._signal})));this.addStandaloneCommentButton();this._uiManager._editorUndoBar?.hide();return e}pointerdown(e){const{isMac:t}=FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t)e.preventDefault();else{editor_classPrivateFieldSet(Gi,this,!0);this._isDraggable?editor_assertClassBrand(Vi,this,_setUpDragSession).call(this,e):editor_assertClassBrand(Vi,this,_selectOnPointerEvent).call(this,e)}}_onStartDragging(){}_onStopDragging(){}moveInDOM(){editor_classPrivateFieldGet(Di,this)&&clearTimeout(editor_classPrivateFieldGet(Di,this));editor_classPrivateFieldSet(Di,this,setTimeout(()=>{editor_classPrivateFieldSet(Di,this,null);this.parent?.moveEditorInDOM(this)},0))}_setParentAndPosition(e,t,i){e.changeParent(this);this.x=t;this.y=i;this.fixAndSetPosition();this._onTranslated()}getRect(e,t,i=this.rotation){const a=this.parentScale,[s,n]=this.pageDimensions,[r,o]=this.pageTranslation,l=e/a,d=t/a,c=this.x*s,h=this.y*n,u=this.width*s,_=this.height*n;switch(i){case 0:return[c+l+r,n-h-d-_+o,c+l+u+r,n-h-d+o];case 90:return[c+d+r,n-h+l+o,c+d+_+r,n-h+l+u+o];case 180:return[c-l-u+r,n-h+d+o,c-l+r,n-h+d+_+o];case 270:return[c-d-_+r,n-h-l-u+o,c-d+r,n-h-l+o];default:throw new Error("Invalid rotation")}}get normalizedPageRect(){const[e,t]=this.pageDimensions,[i,a]=this.pageTranslation,[s,n,r,o]=this.getRect(0,0),l=Math.min(s,r)-i,d=Math.max(s,r)-i,c=Math.min(n,o)-a,h=Math.max(n,o)-a;return{x:l/e,y:(t-h)/t,width:(d-l)/e,height:(h-c)/t}}getRectInCurrentCoords(e,t){const[i,a,s,n]=e,r=s-i,o=n-a;switch(this.rotation){case 0:return[i,t-n,r,o];case 90:return[i,t-a,o,r];case 180:return[s,t-a,r,o];case 270:return[s,t-n,o,r];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&AnnotationEditor._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){editor_classPrivateFieldGet(vi,this)?.onUpdatedColor()}getData(){const{comment:{text:e,color:t,date:i,opacity:a,deleted:s,richText:n},uid:r,pageIndex:o,creationDate:l,modificationDate:d}=this;return{id:r,pageIndex:o,rect:this.getPDFRect(),richText:n,contentsObj:{str:e},creationDate:l,modificationDate:i||d,popupRef:!s,color:t,opacity:a}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){if(this.isInEditMode())return!1;this.parent.setEditingState(!1);editor_classPrivateFieldSet(Ii,this,!0);return!0}disableEditMode(){if(!this.isInEditMode())return!1;this.parent.setEditingState(!0);editor_classPrivateFieldSet(Ii,this,!1);return!0}isInEditMode(){return editor_classPrivateFieldGet(Ii,this)}shouldGetKeyboardEvents(){return editor_classPrivateFieldGet(Ti,this)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:t,bottom:i,right:a}=this.getClientDimensions(),{innerHeight:s,innerWidth:n}=window;return t<n&&a>0&&e<s&&i>0}rebuild(){editor_assertClassBrand(Vi,this,_addFocusListeners).call(this)}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,t=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(e,t,i){const a=new this.prototype.constructor({parent:t,id:i.getId(),uiManager:i,annotationElementId:e.annotationElementId,eventBus:t.eventBus,creationDate:e.creationDate,modificationDate:e.modificationDate});a.rotation=e.rotation;editor_classPrivateFieldSet(gi,a,e.accessibilityData);a._isCopy=e.isCopy||!1;void 0!==e.customId&&null!==e.customId&&(a.customId=e.customId);const[s,n]=a.pageDimensions,[r,o,l,d]=a.getRectInCurrentCoords(e.rect,n);a.x=r/s;a.y=o/n;a.width=l/s;a.height=d/n;return a}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){editor_classPrivateFieldGet(Ei,this)?.abort();editor_classPrivateFieldSet(Ei,this,null);this.isEmpty()||this.commit();this.parent?this.parent.remove(this):this._uiManager.removeEditor(this);this.hideCommentPopup();if(editor_classPrivateFieldGet(Di,this)){clearTimeout(editor_classPrivateFieldGet(Di,this));editor_classPrivateFieldSet(Di,this,null)}editor_assertClassBrand(Vi,this,_stopResizing).call(this);this.removeEditToolbar();if(editor_classPrivateFieldGet(Ri,this)){for(const e of editor_classPrivateFieldGet(Ri,this).values())clearTimeout(e);editor_classPrivateFieldSet(Ri,this,null)}this.parent=null;this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"removed",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:this});editor_classPrivateFieldGet(Oi,this)?.destroy();editor_classPrivateFieldSet(Oi,this,null);editor_classPrivateFieldGet(ki,this)?.remove();editor_classPrivateFieldSet(ki,this,null)}get isResizable(){return!1}makeResizable(){if(this.isResizable){editor_assertClassBrand(Vi,this,_createResizers).call(this);editor_classPrivateFieldGet(Si,this).classList.remove("hidden")}}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[e,t]}=this,[i,a,s,n]=this.getPDFRect();return[AnnotationEditor._round(i+(s-i)*e),AnnotationEditor._round(a+(n-a)*(1-t))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return editor_classPrivateFieldGet(vi,this).commentPopupPositionInLayer}set commentPopupPosition(e){editor_classPrivateFieldGet(vi,this).commentPopupPositionInLayer=e}hasDefaultPopupPosition(){return editor_classPrivateFieldGet(vi,this).hasDefaultPopupPosition()}get commentButtonWidth(){return editor_classPrivateFieldGet(vi,this).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(e){editor_classPrivateFieldGet(vi,this)?.setCommentButtonStates(e)}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this);editor_classPrivateFieldSet(xi,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const t=editor_classPrivateFieldGet(Si,this).children;if(!editor_classPrivateFieldGet(mi,this)){editor_classPrivateFieldSet(mi,this,Array.from(t));const e=editor_assertClassBrand(Vi,this,_resizerKeydown).bind(this),i=editor_assertClassBrand(Vi,this,_resizerBlur).bind(this),a=this._uiManager._signal;for(const t of editor_classPrivateFieldGet(mi,this)){const s=t.getAttribute("data-resizer-name");t.setAttribute("role","spinbutton");t.addEventListener("keydown",e,{signal:a});t.addEventListener("blur",i,{signal:a});t.addEventListener("focus",editor_assertClassBrand(Vi,this,_resizerFocus).bind(this,s),{signal:a});t.setAttribute("data-l10n-id",AnnotationEditor._l10nResizer[s])}}const i=editor_classPrivateFieldGet(mi,this)[0];let a=0;for(const e of t){if(e===i)break;a++}const s=(360-this.rotation+this.parentRotation)%360/90*(editor_classPrivateFieldGet(mi,this).length/4);if(s!==a){if(s<a)for(let e=0;e<a-s;e++)editor_classPrivateFieldGet(Si,this).append(editor_classPrivateFieldGet(Si,this).firstElementChild);else if(s>a)for(let e=0;e<s-a;e++)editor_classPrivateFieldGet(Si,this).firstElementChild.before(editor_classPrivateFieldGet(Si,this).lastElementChild);let e=0;for(const i of t){const t=editor_classPrivateFieldGet(mi,this)[e++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",AnnotationEditor._l10nResizer[t])}}editor_assertClassBrand(Vi,this,_setResizerTabIndex).call(this,0);editor_classPrivateFieldSet(Ti,this,!0);editor_classPrivateFieldGet(Si,this).firstElementChild.focus({focusVisible:!0});e.preventDefault();e.stopImmediatePropagation()}_resizeWithKeyboard(e,t){editor_classPrivateFieldGet(Ti,this)&&editor_assertClassBrand(Vi,this,_resizerPointermove).call(this,editor_classPrivateFieldGet(Ai,this),{deltaX:e,deltaY:t,fromKeyboard:!0})}_stopResizingWithKeyboard(){editor_assertClassBrand(Vi,this,_stopResizing).call(this);this.div.focus()}select(){if(this.isSelected&&this._editToolbar)this._editToolbar.show();else{this.isSelected=!0;this.makeResizable();this.div?.classList.add("selectedEditor");if(this._editToolbar){this._editToolbar?.show();editor_classPrivateFieldGet(fi,this)?.toggleAltTextBadge(!1)}else this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()})}}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){if(this.isSelected){this.isSelected=!1;editor_classPrivateFieldGet(Si,this)?.classList.add("hidden");this.div?.classList.remove("selectedEditor");this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0});this._editToolbar?.hide();editor_classPrivateFieldGet(fi,this)?.toggleAltTextBadge(!0);this.hideCommentPopup()}}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(e,t){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){if(this.canChangeContent){this.enableEditMode();this.div.focus()}}dblclick(e){if("BUTTON"!==e.target.nodeName){this.enterInEditMode();this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid})}}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return editor_classPrivateFieldGet(Mi,this)}set isEditing(e){editor_classPrivateFieldSet(Mi,this,e);if(this.parent)if(e){this.parent.setSelected(this);this.parent.setActiveEditor(this)}else this.parent.setActiveEditor(null)}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){editor_classPrivateFieldGet(Ri,this)||editor_classPrivateFieldSet(Ri,this,new Map);const{action:t}=e;let i=editor_classPrivateFieldGet(Ri,this).get(t);i&&clearTimeout(i);i=setTimeout(()=>{this._reportTelemetry(e);editor_classPrivateFieldGet(Ri,this).delete(t);0===editor_classPrivateFieldGet(Ri,this).size&&editor_classPrivateFieldSet(Ri,this,null)},AnnotationEditor._telemetryTimeout);editor_classPrivateFieldGet(Ri,this).set(t,i);return}e.type||=this.editorType;this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e);this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0);editor_classPrivateFieldSet(wi,this,!1)}disable(){this.div&&(this.div.tabIndex=-1);editor_classPrivateFieldSet(wi,this,!0)}updateFakeAnnotationElement(e){if(editor_classPrivateFieldGet(ki,this)||this.deleted)if(this.deleted){editor_classPrivateFieldGet(ki,this).remove();editor_classPrivateFieldSet(ki,this,null)}else(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&editor_classPrivateFieldGet(ki,this).updateEdited({rect:this.getPDFRect(),popup:this.comment});else editor_classPrivateFieldSet(ki,this,e.addFakeAnnotation(this))}renderAnnotationElement(e){if(this.deleted){e.hide();return null}let t=e.container.querySelector(".annotationContent");if(t){if("CANVAS"===t.nodeName){const e=t;t=document.createElement("div");t.classList.add("annotationContent",this.editorType);e.before(t)}}else{t=document.createElement("div");t.classList.add("annotationContent",this.editorType);e.container.prepend(t)}return t}resetAnnotationElement(e){const{firstElementChild:t}=e.container;"DIV"===t?.nodeName&&t.classList.contains("annotationContent")&&t.remove()}}ti=AnnotationEditor;function _translate([e,t],i,a){[i,a]=this.screenToPageTranslation(i,a);this.x+=i/e;this.y+=a/t;this._onTranslating(this.x,this.y);this.fixAndSetPosition()}function _rotatePoint(e,t,i){switch(i){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}function _getRotationMatrix(e){switch(e){case 90:{const[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}function _createResizers(){if(editor_classPrivateFieldGet(Si,this))return;editor_classPrivateFieldSet(Si,this,document.createElement("div"));editor_classPrivateFieldGet(Si,this).classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const i of e){const e=document.createElement("div");editor_classPrivateFieldGet(Si,this).append(e);e.classList.add("resizer",i);e.setAttribute("data-resizer-name",i);e.addEventListener("pointerdown",editor_assertClassBrand(Vi,this,_resizerPointerdown).bind(this,i),{signal:t});e.addEventListener("contextmenu",noContextMenu,{signal:t});e.tabIndex=-1}this.div.prepend(editor_classPrivateFieldGet(Si,this))}function _resizerPointerdown(e,t){t.preventDefault();const{isMac:i}=FeatureTest.platform;if(0!==t.button||t.ctrlKey&&i)return;editor_classPrivateFieldGet(fi,this)?.toggle(!1);const a=this._isDraggable;this._isDraggable=!1;editor_classPrivateFieldSet(Ci,this,[t.screenX,t.screenY]);const s=new AbortController,n=this._uiManager.combinedSignal(s);this.parent.togglePointerEvents(!1);window.addEventListener("pointermove",editor_assertClassBrand(Vi,this,_resizerPointermove).bind(this,e),{passive:!0,capture:!0,signal:n});window.addEventListener("touchmove",stopEvent,{passive:!1,signal:n});window.addEventListener("contextmenu",noContextMenu,{signal:n});editor_classPrivateFieldSet(xi,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const r=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const pointerUpCallback=()=>{s.abort();this.parent.togglePointerEvents(!0);editor_classPrivateFieldGet(fi,this)?.toggle(!0);this._isDraggable=a;this.parent.div.style.cursor=r;this.div.style.cursor=o;editor_assertClassBrand(Vi,this,_addResizeToUndoStack).call(this)};window.addEventListener("pointerup",pointerUpCallback,{signal:n});window.addEventListener("blur",pointerUpCallback,{signal:n})}function _resize(e,t,i,a){this.width=i;this.height=a;this.x=e;this.y=t;this.setDims();this.fixAndSetPosition();this._onResized()}function _addResizeToUndoStack(){if(!editor_classPrivateFieldGet(xi,this))return;const{savedX:e,savedY:t,savedWidth:i,savedHeight:a}=editor_classPrivateFieldGet(xi,this);editor_classPrivateFieldSet(xi,this,null);const s=this.x,n=this.y,r=this.width,o=this.height;if(s!==e||n!==t||r!==i||o!==a){this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"sizeChanged",editorType:this.constructor.name,id:this.uid,page:this.pageIndex+1,value:{x:e,y:t,width:i,height:a}});this.addCommands({cmd:editor_assertClassBrand(Vi,this,_resize).bind(this,s,n,r,o),undo:editor_assertClassBrand(Vi,this,_resize).bind(this,e,t,i,a),mustExec:!0})}}function _resizerPointermove(e,t){const[i,a]=this.parentDimensions,s=this.x,n=this.y,r=this.width,o=this.height,l=ti.MIN_SIZE/i,d=ti.MIN_SIZE/a,c=editor_assertClassBrand(Vi,this,_getRotationMatrix).call(this,this.rotation),transf=(e,t)=>[c[0]*e+c[2]*t,c[1]*e+c[3]*t],h=editor_assertClassBrand(Vi,this,_getRotationMatrix).call(this,360-this.rotation);let u,_,p=!1,g=!1;switch(e){case"topLeft":p=!0;u=(e,t)=>[0,0];_=(e,t)=>[e,t];break;case"topMiddle":u=(e,t)=>[e/2,0];_=(e,t)=>[e/2,t];break;case"topRight":p=!0;u=(e,t)=>[e,0];_=(e,t)=>[0,t];break;case"middleRight":g=!0;u=(e,t)=>[e,t/2];_=(e,t)=>[0,t/2];break;case"bottomRight":p=!0;u=(e,t)=>[e,t];_=(e,t)=>[0,0];break;case"bottomMiddle":u=(e,t)=>[e/2,t];_=(e,t)=>[e/2,0];break;case"bottomLeft":p=!0;u=(e,t)=>[0,t];_=(e,t)=>[e,0];break;case"middleLeft":g=!0;u=(e,t)=>[0,t/2];_=(e,t)=>[e,t/2]}const m=u(r,o),f=_(r,o);let v=transf(...f);const P=ti._round(s+v[0]),w=ti._round(n+v[1]);let F,b,y=1,S=1;if(t.fromKeyboard)({deltaX:F,deltaY:b}=t);else{const{screenX:e,screenY:i}=t,[a,s]=editor_classPrivateFieldGet(Ci,this);[F,b]=this.screenToPageTranslation(e-a,i-s);editor_classPrivateFieldGet(Ci,this)[0]=e;editor_classPrivateFieldGet(Ci,this)[1]=i}[F,b]=(C=F/i,x=b/a,[h[0]*C+h[2]*x,h[1]*C+h[3]*x]);var C,x;if(p){const e=Math.hypot(r,o);y=S=Math.max(Math.min(Math.hypot(f[0]-m[0]-F,f[1]-m[1]-b)/e,1/r,1/o),l/r,d/o)}else g?y=MathClamp(Math.abs(f[0]-m[0]-F),l,1)/r:S=MathClamp(Math.abs(f[1]-m[1]-b),d,1)/o;const k=ti._round(r*y),E=ti._round(o*S);v=transf(..._(k,E));const A=P-v[0],G=w-v[1];editor_classPrivateFieldGet(Bi,this)||editor_classPrivateFieldSet(Bi,this,[this.x,this.y,this.width,this.height]);this.width=k;this.height=E;this.x=A;this.y=G;this.setDims();this.fixAndSetPosition();this._onResizing()}function _touchPinchStartCallback(){editor_classPrivateFieldSet(xi,this,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});editor_classPrivateFieldGet(fi,this)?.toggle(!1);this.parent.togglePointerEvents(!1)}function _touchPinchCallback(e,t,i){let a=i/t*.7+1-.7;if(1===a)return;const s=editor_assertClassBrand(Vi,this,_getRotationMatrix).call(this,this.rotation),transf=(e,t)=>[s[0]*e+s[2]*t,s[1]*e+s[3]*t],[n,r]=this.parentDimensions,o=this.x,l=this.y,d=this.width,c=this.height,h=ti.MIN_SIZE/n,u=ti.MIN_SIZE/r;a=Math.max(Math.min(a,1/d,1/c),h/d,u/c);const _=ti._round(d*a),p=ti._round(c*a);if(_===d&&p===c)return;editor_classPrivateFieldGet(Bi,this)||editor_classPrivateFieldSet(Bi,this,[o,l,d,c]);const g=transf(d/2,c/2),m=ti._round(o+g[0]),f=ti._round(l+g[1]),v=transf(_/2,p/2);this.x=m-v[0];this.y=f-v[1];this.width=_;this.height=p;this.setDims();this.fixAndSetPosition();this._onResizing()}function _touchPinchEndCallback(){editor_classPrivateFieldGet(fi,this)?.toggle(!0);this.parent.togglePointerEvents(!0);editor_assertClassBrand(Vi,this,_addResizeToUndoStack).call(this)}function _selectOnPointerEvent(e){const{isMac:t}=FeatureTest.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}function _setUpDragSession(e){const{isSelected:t}=this;this._uiManager.setUpDragSession();let i=!1;const a=new AbortController,s=this._uiManager.combinedSignal(a),n={capture:!0,passive:!1,signal:s},cancelDrag=e=>{a.abort();editor_classPrivateFieldSet(Fi,this,null);editor_classPrivateFieldSet(Gi,this,!1);this._uiManager.endDragSession()||editor_assertClassBrand(Vi,this,_selectOnPointerEvent).call(this,e);i&&this._onStopDragging()};if(t){editor_classPrivateFieldSet(Li,this,e.clientX);editor_classPrivateFieldSet(Ni,this,e.clientY);editor_classPrivateFieldSet(Fi,this,e.pointerId);editor_classPrivateFieldSet(bi,this,e.pointerType);window.addEventListener("pointermove",e=>{if(!i){i=!0;this._uiManager.toggleComment(this,!0,!1);this._onStartDragging()}const{clientX:t,clientY:a,pointerId:s}=e;if(s!==editor_classPrivateFieldGet(Fi,this)){stopEvent(e);return}const[n,r]=this.screenToPageTranslation(t-editor_classPrivateFieldGet(Li,this),a-editor_classPrivateFieldGet(Ni,this));editor_classPrivateFieldSet(Li,this,t);editor_classPrivateFieldSet(Ni,this,a);this._uiManager.dragSelectedEditors(n,r)},n);window.addEventListener("touchmove",stopEvent,n);window.addEventListener("pointerdown",e=>{e.pointerType===editor_classPrivateFieldGet(bi,this)&&(editor_classPrivateFieldGet(Oi,this)||e.isPrimary)&&cancelDrag(e);stopEvent(e)},n)}const pointerUpCallback=e=>{editor_classPrivateFieldGet(Fi,this)&&editor_classPrivateFieldGet(Fi,this)!==e.pointerId?stopEvent(e):cancelDrag(e)};window.addEventListener("pointerup",pointerUpCallback,{signal:s});window.addEventListener("blur",pointerUpCallback,{signal:s})}function _addFocusListeners(){if(editor_classPrivateFieldGet(Ei,this)||!this.div)return;editor_classPrivateFieldSet(Ei,this,new AbortController);const e=this._uiManager.combinedSignal(editor_classPrivateFieldGet(Ei,this));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e});this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}function _resizerKeydown(e){ti._resizerKeyboardManager.exec(this,e)}function _resizerBlur(e){editor_classPrivateFieldGet(Ti,this)&&e.relatedTarget?.parentNode!==editor_classPrivateFieldGet(Si,this)&&editor_assertClassBrand(Vi,this,_stopResizing).call(this)}function _resizerFocus(e){editor_classPrivateFieldSet(Ai,this,editor_classPrivateFieldGet(Ti,this)?e:"")}function _setResizerTabIndex(e){if(editor_classPrivateFieldGet(mi,this))for(const t of editor_classPrivateFieldGet(mi,this))t.tabIndex=e}function _stopResizing(){editor_classPrivateFieldSet(Ti,this,!1);editor_assertClassBrand(Vi,this,_setResizerTabIndex).call(this,-1);editor_assertClassBrand(Vi,this,_addResizeToUndoStack).call(this)}editor_defineProperty(AnnotationEditor,"_l10n",null);editor_defineProperty(AnnotationEditor,"_l10nAlert",null);editor_defineProperty(AnnotationEditor,"_l10nResizer",null);editor_defineProperty(AnnotationEditor,"_borderLineWidth",-1);editor_defineProperty(AnnotationEditor,"_colorManager",new ColorManager);editor_defineProperty(AnnotationEditor,"_zIndex",1);editor_defineProperty(AnnotationEditor,"_telemetryTimeout",1e3);class FakeEditor extends AnnotationEditor{constructor(e){super(e);this.annotationElementId=e.annotationElementId;this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ui=3285377520,zi=4294901760,Hi=65535;class MurmurHash3_64{constructor(e){this.h1=e?4294967295&e:Ui;this.h2=e?4294967295&e:Ui}update(e){let t,i;if("string"==typeof e){t=new Uint8Array(2*e.length);i=0;for(let a=0,s=e.length;a<s;a++){const s=e.charCodeAt(a);if(s<=255)t[i++]=s;else{t[i++]=s>>>8;t[i++]=255&s}}}else{if(!ArrayBuffer.isView(e))throw new Error("Invalid data format, must be a string or TypedArray.");t=e.slice();i=t.byteLength}const a=i>>2,s=i-4*a,n=new Uint32Array(t.buffer,0,a);let r=0,o=0,l=this.h1,d=this.h2;const c=3432918353,h=461845907,u=11601,_=13715;for(let e=0;e<a;e++)if(1&e){r=n[e];r=r*c&zi|r*u&Hi;r=r<<15|r>>>17;r=r*h&zi|r*_&Hi;l^=r;l=l<<13|l>>>19;l=5*l+3864292196}else{o=n[e];o=o*c&zi|o*u&Hi;o=o<<15|o>>>17;o=o*h&zi|o*_&Hi;d^=o;d=d<<13|d>>>19;d=5*d+3864292196}r=0;switch(s){case 3:r^=t[4*a+2]<<16;case 2:r^=t[4*a+1]<<8;case 1:r^=t[4*a];r=r*c&zi|r*u&Hi;r=r<<15|r>>>17;r=r*h&zi|r*_&Hi;1&a?l^=r:d^=r}this.h1=l;this.h2=d}hexdigest(){let e=this.h1,t=this.h2;e^=t>>>1;e=3981806797*e&zi|36045*e&Hi;t=4283543511*t&zi|(2950163797*(t<<16|e>>>16)&zi)>>>16;e^=t>>>1;e=444984403*e&zi|60499*e&Hi;t=3301882366*t&zi|(3120437893*(t<<16|e>>>16)&zi)>>>16;e^=t>>>1;return(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}function annotation_storage_defineProperty(e,t,i){return(t=function annotation_storage_toPropertyKey(e){var t=function annotation_storage_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function annotation_storage_classPrivateFieldInitSpec(e,t,i){annotation_storage_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_storage_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_storage_classPrivateFieldSet(e,t,i){return e.set(annotation_storage_assertClassBrand(e,t),i),i}function annotation_storage_classPrivateFieldGet(e,t){return e.get(annotation_storage_assertClassBrand(e,t))}function annotation_storage_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const $i=Object.freeze({map:null,hash:"",transfer:void 0});var Ki=new WeakMap,Xi=new WeakMap,qi=new WeakMap,Yi=new WeakMap,Zi=new WeakSet;class AnnotationStorage{constructor(){!function annotation_storage_classPrivateMethodInitSpec(e,t){annotation_storage_checkPrivateRedeclaration(e,t),t.add(e)}(this,Zi);annotation_storage_classPrivateFieldInitSpec(this,Ki,!1);annotation_storage_classPrivateFieldInitSpec(this,Xi,null);annotation_storage_classPrivateFieldInitSpec(this,qi,null);annotation_storage_classPrivateFieldInitSpec(this,Yi,new Map);annotation_storage_defineProperty(this,"onSetModified",null);annotation_storage_defineProperty(this,"onResetModified",null);annotation_storage_defineProperty(this,"onAnnotationEditor",null)}getValue(e,t){const i=annotation_storage_classPrivateFieldGet(Yi,this).get(e);return void 0===i?t:Object.assign(t,i)}getRawValue(e){return annotation_storage_classPrivateFieldGet(Yi,this).get(e)}remove(e){const t=annotation_storage_classPrivateFieldGet(Yi,this).get(e);if(void 0!==t){t instanceof AnnotationEditor&&annotation_storage_classPrivateFieldGet(qi,this).delete(t.annotationElementId);annotation_storage_classPrivateFieldGet(Yi,this).delete(e);0===annotation_storage_classPrivateFieldGet(Yi,this).size&&this.resetModified();annotation_storage_classPrivateFieldGet(Yi,this).values().some(e=>e instanceof AnnotationEditor)||this.onAnnotationEditor?.(null)}}setValue(e,t){const i=annotation_storage_classPrivateFieldGet(Yi,this).get(e);let a=!1;if(void 0!==i){for(const[e,s]of Object.entries(t))if(i[e]!==s){a=!0;i[e]=s}}else{a=!0;annotation_storage_classPrivateFieldGet(Yi,this).set(e,t)}a&&annotation_storage_assertClassBrand(Zi,this,_setModified).call(this);if(t instanceof AnnotationEditor){(annotation_storage_classPrivateFieldGet(qi,this)||annotation_storage_classPrivateFieldSet(qi,this,new Map)).set(t.annotationElementId,t);this.onAnnotationEditor?.(t.constructor._type)}}has(e){return annotation_storage_classPrivateFieldGet(Yi,this).has(e)}get size(){return annotation_storage_classPrivateFieldGet(Yi,this).size}resetModified(){if(annotation_storage_classPrivateFieldGet(Ki,this)){annotation_storage_classPrivateFieldSet(Ki,this,!1);this.onResetModified?.()}}get print(){return new PrintAnnotationStorage(this)}get serializable(){if(0===annotation_storage_classPrivateFieldGet(Yi,this).size)return $i;const e=new Map,t=new MurmurHash3_64,i=[],a=Object.create(null);let s=!1;for(const[i,n]of annotation_storage_classPrivateFieldGet(Yi,this)){const r=n instanceof AnnotationEditor?n.serialize(!1,a):n;if(n.page){n.pageIndex=n.page._pageIndex;delete n.page}if(r){e.set(i,r);t.update(`${i}:${JSON.stringify(r)}`);s||=!!r.bitmap}}if(s)for(const t of e.values())t.bitmap&&i.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:i}:$i}get editorStats(){let e=null;const t=new Map;let i=0,a=0;for(const s of annotation_storage_classPrivateFieldGet(Yi,this).values()){if(!(s instanceof AnnotationEditor)){s.popup&&(s.popup.deleted?a+=1:i+=1);continue}s.isCommentDeleted?a+=1:s.hasEditedComment&&(i+=1);const n=s.telemetryFinalData;if(!n)continue;const{type:r}=n;t.getOrInsertComputed(r,()=>Object.getPrototypeOf(s).constructor);e||=Object.create(null);const o=e[r]||=new Map;for(const[e,t]of Object.entries(n)){if("type"===e)continue;const i=o.getOrInsertComputed(e,makeMap);i.set(t,(i.get(t)??0)+1)}}if(a>0||i>0){e||=Object.create(null);e.comments={deleted:a,edited:i}}if(!e)return null;for(const[i,a]of t)e[i]=a.computeTelemetryFinalData(e[i]);return e}resetModifiedIds(){annotation_storage_classPrivateFieldSet(Xi,this,null)}updateEditor(e,t){const i=annotation_storage_classPrivateFieldGet(qi,this)?.get(e);if(i){i.updateFromAnnotationLayer(t);return!0}return!1}getEditor(e){return annotation_storage_classPrivateFieldGet(qi,this)?.get(e)||null}get modifiedIds(){if(annotation_storage_classPrivateFieldGet(Xi,this))return annotation_storage_classPrivateFieldGet(Xi,this);const e=[];if(annotation_storage_classPrivateFieldGet(qi,this))for(const t of annotation_storage_classPrivateFieldGet(qi,this).values())t.serialize()&&e.push(t.annotationElementId);let t="";if(e.length){const i=new MurmurHash3_64;i.update(e.join(","));t=i.hexdigest()}return annotation_storage_classPrivateFieldSet(Xi,this,{ids:new Set(e),hash:t})}[Symbol.iterator](){return annotation_storage_classPrivateFieldGet(Yi,this).entries()}}function _setModified(){if(!annotation_storage_classPrivateFieldGet(Ki,this)){annotation_storage_classPrivateFieldSet(Ki,this,!0);this.onSetModified?.()}}var Qi=new WeakMap;class PrintAnnotationStorage extends AnnotationStorage{constructor(e){super();annotation_storage_classPrivateFieldInitSpec(this,Qi,$i);const{serializable:t}=e;if(t===$i)return;const{map:i,hash:a,transfer:s}=t,n=structuredClone(i,s?{transfer:s}:null);annotation_storage_classPrivateFieldSet(Qi,this,{map:n,hash:a,transfer:[]})}get print(){unreachable("Should not call PrintAnnotationStorage.print")}get serializable(){return annotation_storage_classPrivateFieldGet(Qi,this)}get modifiedIds(){return shadow(this,"modifiedIds",{ids:new Set,hash:""})}}function canvas_dependency_tracker_defineProperty(e,t,i){return(t=function canvas_dependency_tracker_toPropertyKey(e){var t=function canvas_dependency_tracker_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function canvas_dependency_tracker_classPrivateFieldInitSpec(e,t,i){canvas_dependency_tracker_checkPrivateRedeclaration(e,t),t.set(e,i)}function canvas_dependency_tracker_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function canvas_dependency_tracker_classPrivateFieldGet(e,t){return e.get(canvas_dependency_tracker_assertClassBrand(e,t))}function canvas_dependency_tracker_classPrivateFieldSet(e,t,i){return e.set(canvas_dependency_tracker_assertClassBrand(e,t),i),i}function canvas_dependency_tracker_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Ji="__forcedDependency",{floor:ea,ceil:ta}=Math;function expandBBox(e,t,i,a,s,n){e[4*t+0]=Math.min(e[4*t+0],i);e[4*t+1]=Math.min(e[4*t+1],a);e[4*t+2]=Math.max(e[4*t+2],s);e[4*t+3]=Math.max(e[4*t+3],n)}const ia=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];var aa=new WeakMap,sa=new WeakMap;class BBoxReader{constructor(e,t){canvas_dependency_tracker_classPrivateFieldInitSpec(this,aa,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,sa,void 0);canvas_dependency_tracker_classPrivateFieldSet(aa,this,e);canvas_dependency_tracker_classPrivateFieldSet(sa,this,t)}get length(){return canvas_dependency_tracker_classPrivateFieldGet(aa,this).length}isEmpty(e){return canvas_dependency_tracker_classPrivateFieldGet(aa,this)[e]===ia}minX(e){return canvas_dependency_tracker_classPrivateFieldGet(sa,this)[4*e+0]/256}minY(e){return canvas_dependency_tracker_classPrivateFieldGet(sa,this)[4*e+1]/256}maxX(e){return(canvas_dependency_tracker_classPrivateFieldGet(sa,this)[4*e+2]+1)/256}maxY(e){return(canvas_dependency_tracker_classPrivateFieldGet(sa,this)[4*e+3]+1)/256}}const ensureDebugMetadata=(e,t)=>e?.getOrInsertComputed(t,()=>({dependencies:new Set,isRenderingOperation:!1}));var na=new WeakMap,ra=new WeakMap,oa=new WeakMap,la=new WeakMap,da=new WeakMap,ca=new WeakMap,ha=new WeakMap,ua=new WeakSet;class CanvasBBoxTracker{constructor(e,t){!function canvas_dependency_tracker_classPrivateMethodInitSpec(e,t){canvas_dependency_tracker_checkPrivateRedeclaration(e,t),t.add(e)}(this,ua);canvas_dependency_tracker_classPrivateFieldInitSpec(this,na,[[1,0,0,1,0,0]]);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ra,[-1/0,-1/0,1/0,1/0]);canvas_dependency_tracker_classPrivateFieldInitSpec(this,oa,new Float64Array(i));canvas_dependency_tracker_defineProperty(this,"_pendingBBoxIdx",-1);canvas_dependency_tracker_classPrivateFieldInitSpec(this,la,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,da,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ca,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ha,void 0);canvas_dependency_tracker_defineProperty(this,"_savesStack",[]);canvas_dependency_tracker_defineProperty(this,"_markedContentStack",[]);canvas_dependency_tracker_classPrivateFieldSet(la,this,e.width);canvas_dependency_tracker_classPrivateFieldSet(da,this,e.height);canvas_dependency_tracker_assertClassBrand(ua,this,_initializeBBoxes).call(this,t)}growOperationsCount(e){e>=canvas_dependency_tracker_classPrivateFieldGet(ha,this).length&&canvas_dependency_tracker_assertClassBrand(ua,this,_initializeBBoxes).call(this,e,canvas_dependency_tracker_classPrivateFieldGet(ha,this))}get clipBox(){return canvas_dependency_tracker_classPrivateFieldGet(ra,this)}save(e){canvas_dependency_tracker_classPrivateFieldSet(ra,this,{__proto__:canvas_dependency_tracker_classPrivateFieldGet(ra,this)});this._savesStack.push(e);return this}restore(e,t){const i=Object.getPrototypeOf(canvas_dependency_tracker_classPrivateFieldGet(ra,this));if(null===i)return this;canvas_dependency_tracker_classPrivateFieldSet(ra,this,i);const a=this._savesStack.pop();if(void 0!==a){t?.(a,e);canvas_dependency_tracker_classPrivateFieldGet(ha,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(ha,this)[a]}return this}recordOpenMarker(e){this._savesStack.push(e);return this}getOpenMarker(){return 0===this._savesStack.length?null:this._savesStack.at(-1)}recordCloseMarker(e,t){const i=this._savesStack.pop();if(void 0!==i){t?.(i,e);canvas_dependency_tracker_classPrivateFieldGet(ha,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(ha,this)[i]}return this}beginMarkedContent(e){this._markedContentStack.push(e);return this}endMarkedContent(e,t){const i=this._markedContentStack.pop();if(void 0!==i){t?.(i,e);canvas_dependency_tracker_classPrivateFieldGet(ha,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(ha,this)[i]}return this}pushBaseTransform(e){canvas_dependency_tracker_classPrivateFieldGet(na,this).push(Util.multiplyByDOMMatrix(canvas_dependency_tracker_classPrivateFieldGet(na,this).at(-1),e.getTransform()));return this}popBaseTransform(){canvas_dependency_tracker_classPrivateFieldGet(na,this).length>1&&canvas_dependency_tracker_classPrivateFieldGet(na,this).pop();return this}resetBBox(e){if(this._pendingBBoxIdx!==e){this._pendingBBoxIdx=e;canvas_dependency_tracker_classPrivateFieldGet(oa,this).set(i,0)}return this}recordClipBox(e,t,a,s,n,r){const o=Util.multiplyByDOMMatrix(canvas_dependency_tracker_classPrivateFieldGet(na,this).at(-1),t.getTransform()),l=i.slice();Util.axialAlignedBoundingBox([a,n,s,r],o,l);const d=Util.intersect(canvas_dependency_tracker_classPrivateFieldGet(ra,this),l);if(d){canvas_dependency_tracker_classPrivateFieldGet(ra,this)[0]=d[0];canvas_dependency_tracker_classPrivateFieldGet(ra,this)[1]=d[1];canvas_dependency_tracker_classPrivateFieldGet(ra,this)[2]=d[2];canvas_dependency_tracker_classPrivateFieldGet(ra,this)[3]=d[3]}else{canvas_dependency_tracker_classPrivateFieldGet(ra,this)[0]=canvas_dependency_tracker_classPrivateFieldGet(ra,this)[1]=1/0;canvas_dependency_tracker_classPrivateFieldGet(ra,this)[2]=canvas_dependency_tracker_classPrivateFieldGet(ra,this)[3]=-1/0}return this}recordBBox(e,t,a,s,n,r){const o=canvas_dependency_tracker_classPrivateFieldGet(ra,this);if(o[0]===1/0)return this;const l=Util.multiplyByDOMMatrix(canvas_dependency_tracker_classPrivateFieldGet(na,this).at(-1),t.getTransform());if(o[0]===-1/0){Util.axialAlignedBoundingBox([a,n,s,r],l,canvas_dependency_tracker_classPrivateFieldGet(oa,this));return this}const d=i.slice();Util.axialAlignedBoundingBox([a,n,s,r],l,d);canvas_dependency_tracker_classPrivateFieldGet(oa,this)[0]=MathClamp(d[0],o[0],canvas_dependency_tracker_classPrivateFieldGet(oa,this)[0]);canvas_dependency_tracker_classPrivateFieldGet(oa,this)[1]=MathClamp(d[1],o[1],canvas_dependency_tracker_classPrivateFieldGet(oa,this)[1]);canvas_dependency_tracker_classPrivateFieldGet(oa,this)[2]=MathClamp(d[2],canvas_dependency_tracker_classPrivateFieldGet(oa,this)[2],o[2]);canvas_dependency_tracker_classPrivateFieldGet(oa,this)[3]=MathClamp(d[3],canvas_dependency_tracker_classPrivateFieldGet(oa,this)[3],o[3]);return this}recordFullPageBBox(e){canvas_dependency_tracker_classPrivateFieldGet(oa,this)[0]=Math.max(0,canvas_dependency_tracker_classPrivateFieldGet(ra,this)[0]);canvas_dependency_tracker_classPrivateFieldGet(oa,this)[1]=Math.max(0,canvas_dependency_tracker_classPrivateFieldGet(ra,this)[1]);canvas_dependency_tracker_classPrivateFieldGet(oa,this)[2]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(la,this),canvas_dependency_tracker_classPrivateFieldGet(ra,this)[2]);canvas_dependency_tracker_classPrivateFieldGet(oa,this)[3]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(da,this),canvas_dependency_tracker_classPrivateFieldGet(ra,this)[3]);return this}recordOperation(e,t=!1,i){if(this._pendingBBoxIdx!==e)return this;const a=ea(256*canvas_dependency_tracker_classPrivateFieldGet(oa,this)[0]/canvas_dependency_tracker_classPrivateFieldGet(la,this)),s=ea(256*canvas_dependency_tracker_classPrivateFieldGet(oa,this)[1]/canvas_dependency_tracker_classPrivateFieldGet(da,this)),n=ta(256*canvas_dependency_tracker_classPrivateFieldGet(oa,this)[2]/canvas_dependency_tracker_classPrivateFieldGet(la,this)),r=ta(256*canvas_dependency_tracker_classPrivateFieldGet(oa,this)[3]/canvas_dependency_tracker_classPrivateFieldGet(da,this));expandBBox(canvas_dependency_tracker_classPrivateFieldGet(ca,this),e,a,s,n,r);if(i)for(const t of i)for(const i of t)i!==e&&expandBBox(canvas_dependency_tracker_classPrivateFieldGet(ca,this),i,a,s,n,r);t||(this._pendingBBoxIdx=-1);return this}bboxToClipBoxDropOperation(e){if(this._pendingBBoxIdx===e){this._pendingBBoxIdx=-1;canvas_dependency_tracker_classPrivateFieldGet(ra,this)[0]=Math.max(canvas_dependency_tracker_classPrivateFieldGet(ra,this)[0],canvas_dependency_tracker_classPrivateFieldGet(oa,this)[0]);canvas_dependency_tracker_classPrivateFieldGet(ra,this)[1]=Math.max(canvas_dependency_tracker_classPrivateFieldGet(ra,this)[1],canvas_dependency_tracker_classPrivateFieldGet(oa,this)[1]);canvas_dependency_tracker_classPrivateFieldGet(ra,this)[2]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(ra,this)[2],canvas_dependency_tracker_classPrivateFieldGet(oa,this)[2]);canvas_dependency_tracker_classPrivateFieldGet(ra,this)[3]=Math.min(canvas_dependency_tracker_classPrivateFieldGet(ra,this)[3],canvas_dependency_tracker_classPrivateFieldGet(oa,this)[3])}return this}take(){return new BBoxReader(canvas_dependency_tracker_classPrivateFieldGet(ha,this),canvas_dependency_tracker_classPrivateFieldGet(ca,this))}takeDebugMetadata(){throw new Error("Unreachable")}recordSimpleData(e,t){return this}recordIncrementalData(e,t){return this}resetIncrementalData(e,t){return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,i){return this}recordFutureForcedDependency(e,t){return this}inheritSimpleDataAsFutureForcedDependencies(e){return this}inheritPendingDependenciesAsFutureForcedDependencies(){return this}recordCharacterBBox(e,t,i,a=1,s=0,n=0,r){return this}getSimpleIndex(e){}recordDependencies(e,t){return this}recordNamedDependency(e,t){return this}recordShowTextOperation(e,t=!1){return this}}function _initializeBBoxes(e,t){const i=new ArrayBuffer(4*e);canvas_dependency_tracker_classPrivateFieldSet(ca,this,new Uint8ClampedArray(i));canvas_dependency_tracker_classPrivateFieldSet(ha,this,new Uint32Array(i));if(t&&t.length>0){canvas_dependency_tracker_classPrivateFieldGet(ha,this).set(t);canvas_dependency_tracker_classPrivateFieldGet(ha,this).fill(ia,t.length)}else canvas_dependency_tracker_classPrivateFieldGet(ha,this).fill(ia)}var _a=new WeakMap,pa=new WeakMap,ga=new WeakMap,ma=new WeakMap,fa=new WeakMap,va=new WeakMap,Pa=new WeakMap,wa=new WeakMap;class CanvasDependencyTracker{constructor(e,t=!1){canvas_dependency_tracker_classPrivateFieldInitSpec(this,_a,{__proto__:null});canvas_dependency_tracker_classPrivateFieldInitSpec(this,pa,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Ji]:[]});canvas_dependency_tracker_classPrivateFieldInitSpec(this,ga,new Map);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ma,new Set);canvas_dependency_tracker_classPrivateFieldInitSpec(this,fa,new Map);canvas_dependency_tracker_classPrivateFieldInitSpec(this,va,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Pa,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,wa,void 0);canvas_dependency_tracker_classPrivateFieldSet(wa,this,e);if(t){canvas_dependency_tracker_classPrivateFieldSet(va,this,new Map);canvas_dependency_tracker_classPrivateFieldSet(Pa,this,(e,t)=>{ensureDebugMetadata(canvas_dependency_tracker_classPrivateFieldGet(va,this),t).dependencies.add(e)})}}get clipBox(){return canvas_dependency_tracker_classPrivateFieldGet(wa,this).clipBox}growOperationsCount(e){canvas_dependency_tracker_classPrivateFieldGet(wa,this).growOperationsCount(e)}save(e){canvas_dependency_tracker_classPrivateFieldSet(_a,this,{__proto__:canvas_dependency_tracker_classPrivateFieldGet(_a,this)});canvas_dependency_tracker_classPrivateFieldSet(pa,this,{__proto__:canvas_dependency_tracker_classPrivateFieldGet(pa,this),transform:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(pa,this).transform},moveText:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(pa,this).moveText},sameLineText:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(pa,this).sameLineText},[Ji]:{__proto__:canvas_dependency_tracker_classPrivateFieldGet(pa,this)[Ji]}});canvas_dependency_tracker_classPrivateFieldGet(wa,this).save(e);return this}restore(e){canvas_dependency_tracker_classPrivateFieldGet(wa,this).restore(e,canvas_dependency_tracker_classPrivateFieldGet(Pa,this));const t=Object.getPrototypeOf(canvas_dependency_tracker_classPrivateFieldGet(_a,this));if(null===t)return this;canvas_dependency_tracker_classPrivateFieldSet(_a,this,t);canvas_dependency_tracker_classPrivateFieldSet(pa,this,Object.getPrototypeOf(canvas_dependency_tracker_classPrivateFieldGet(pa,this)));return this}recordOpenMarker(e){canvas_dependency_tracker_classPrivateFieldGet(wa,this).recordOpenMarker(e,canvas_dependency_tracker_classPrivateFieldGet(Pa,this));return this}getOpenMarker(){return canvas_dependency_tracker_classPrivateFieldGet(wa,this).getOpenMarker()}recordCloseMarker(e){canvas_dependency_tracker_classPrivateFieldGet(wa,this).recordCloseMarker(e,canvas_dependency_tracker_classPrivateFieldGet(Pa,this));return this}beginMarkedContent(e){canvas_dependency_tracker_classPrivateFieldGet(wa,this).beginMarkedContent(e);return this}endMarkedContent(e){canvas_dependency_tracker_classPrivateFieldGet(wa,this).endMarkedContent(e,canvas_dependency_tracker_classPrivateFieldGet(Pa,this));return this}pushBaseTransform(e){canvas_dependency_tracker_classPrivateFieldGet(wa,this).pushBaseTransform(e);return this}popBaseTransform(){canvas_dependency_tracker_classPrivateFieldGet(wa,this).popBaseTransform();return this}recordSimpleData(e,t){canvas_dependency_tracker_classPrivateFieldGet(_a,this)[e]=t;return this}recordIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(pa,this)[e].push(t);return this}resetIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(pa,this)[e].length=0;return this}recordNamedData(e,t){canvas_dependency_tracker_classPrivateFieldGet(ga,this).set(e,t);return this}recordSimpleDataFromNamed(e,t,i){canvas_dependency_tracker_classPrivateFieldGet(_a,this)[e]=canvas_dependency_tracker_classPrivateFieldGet(ga,this).get(t)??i}recordFutureForcedDependency(e,t){this.recordIncrementalData(Ji,t);return this}inheritSimpleDataAsFutureForcedDependencies(e){for(const t of e)t in canvas_dependency_tracker_classPrivateFieldGet(_a,this)&&this.recordFutureForcedDependency(t,canvas_dependency_tracker_classPrivateFieldGet(_a,this)[t]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const e of canvas_dependency_tracker_classPrivateFieldGet(ma,this))this.recordFutureForcedDependency(Ji,e);return this}resetBBox(e){canvas_dependency_tracker_classPrivateFieldGet(wa,this).resetBBox(e);return this}recordClipBox(e,t,i,a,s,n){canvas_dependency_tracker_classPrivateFieldGet(wa,this).recordClipBox(e,t,i,a,s,n);return this}recordBBox(e,t,i,a,s,n){canvas_dependency_tracker_classPrivateFieldGet(wa,this).recordBBox(e,t,i,a,s,n);return this}recordCharacterBBox(e,t,i,a=1,s=0,n=0,r){const o=i.bbox;let l,d;if(o){l=o[2]!==o[0]&&o[3]!==o[1]&&canvas_dependency_tracker_classPrivateFieldGet(fa,this).get(i);if(!1!==l){d=[0,0,0,0];Util.axialAlignedBoundingBox(o,i.fontMatrix,d);1===a&&0===s&&0===n||function scaleCharBBox(e,t,i,a,s){let n;if(e){if(e<0){n=s[0];s[0]=s[2];s[2]=n}s[0]*=e;s[2]*=e;if(t<0){n=s[1];s[1]=s[3];s[3]=n}s[1]*=t;s[3]*=t}else s.fill(0);s[0]+=i;s[1]+=a;s[2]+=i;s[3]+=a}(a,-a,s,n,d);if(l)return this.recordBBox(e,t,d[0],d[2],d[1],d[3])}}if(!r)return this.recordFullPageBBox(e);const c=r();if(o&&d&&void 0===l){l=d[0]<=s-c.actualBoundingBoxLeft&&d[2]>=s+c.actualBoundingBoxRight&&d[1]<=n-c.actualBoundingBoxAscent&&d[3]>=n+c.actualBoundingBoxDescent;canvas_dependency_tracker_classPrivateFieldGet(fa,this).set(i,l);if(l)return this.recordBBox(e,t,d[0],d[2],d[1],d[3])}return this.recordBBox(e,t,s-c.actualBoundingBoxLeft,s+c.actualBoundingBoxRight,n-c.actualBoundingBoxAscent,n+c.actualBoundingBoxDescent)}recordFullPageBBox(e){canvas_dependency_tracker_classPrivateFieldGet(wa,this).recordFullPageBBox(e);return this}getSimpleIndex(e){return canvas_dependency_tracker_classPrivateFieldGet(_a,this)[e]}recordDependencies(e,t){const i=canvas_dependency_tracker_classPrivateFieldGet(ma,this),a=canvas_dependency_tracker_classPrivateFieldGet(_a,this),s=canvas_dependency_tracker_classPrivateFieldGet(pa,this);for(const e of t)e in canvas_dependency_tracker_classPrivateFieldGet(_a,this)?i.add(a[e]):e in s&&s[e].forEach(i.add,i);return this}recordNamedDependency(e,t){canvas_dependency_tracker_classPrivateFieldGet(ga,this).has(t)&&canvas_dependency_tracker_classPrivateFieldGet(ma,this).add(canvas_dependency_tracker_classPrivateFieldGet(ga,this).get(t));return this}recordOperation(e,t=!1){this.recordDependencies(e,[Ji]);if(canvas_dependency_tracker_classPrivateFieldGet(va,this)){const t=ensureDebugMetadata(canvas_dependency_tracker_classPrivateFieldGet(va,this),e),{dependencies:i}=t;canvas_dependency_tracker_classPrivateFieldGet(ma,this).forEach(i.add,i);canvas_dependency_tracker_classPrivateFieldGet(wa,this)._savesStack.forEach(i.add,i);canvas_dependency_tracker_classPrivateFieldGet(wa,this)._markedContentStack.forEach(i.add,i);i.delete(e);t.isRenderingOperation=!0}const i=!t&&e===canvas_dependency_tracker_classPrivateFieldGet(wa,this)._pendingBBoxIdx;canvas_dependency_tracker_classPrivateFieldGet(wa,this).recordOperation(e,t,[canvas_dependency_tracker_classPrivateFieldGet(ma,this),canvas_dependency_tracker_classPrivateFieldGet(wa,this)._savesStack,canvas_dependency_tracker_classPrivateFieldGet(wa,this)._markedContentStack]);i&&canvas_dependency_tracker_classPrivateFieldGet(ma,this).clear();return this}recordShowTextOperation(e,t=!1){const i=Array.from(canvas_dependency_tracker_classPrivateFieldGet(ma,this));this.recordOperation(e,t);this.recordIncrementalData("sameLineText",e);for(const e of i)this.recordIncrementalData("sameLineText",e);return this}bboxToClipBoxDropOperation(e,t=!1){const i=!t&&e===canvas_dependency_tracker_classPrivateFieldGet(wa,this)._pendingBBoxIdx;canvas_dependency_tracker_classPrivateFieldGet(wa,this).bboxToClipBoxDropOperation(e);i&&canvas_dependency_tracker_classPrivateFieldGet(ma,this).clear();return this}take(){canvas_dependency_tracker_classPrivateFieldGet(fa,this).clear();return canvas_dependency_tracker_classPrivateFieldGet(wa,this).take()}takeDebugMetadata(){return canvas_dependency_tracker_classPrivateFieldGet(va,this)}}var Fa=new WeakMap,ba=new WeakMap,ya=new WeakMap,Sa=new WeakMap,Ca=new WeakMap;class CanvasNestedDependencyTracker{constructor(e,t,i){canvas_dependency_tracker_classPrivateFieldInitSpec(this,Fa,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ba,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,ya,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Sa,0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ca,0);if(e instanceof CanvasNestedDependencyTracker&&canvas_dependency_tracker_classPrivateFieldGet(ya,e)===!!i)return e;canvas_dependency_tracker_classPrivateFieldSet(Fa,this,e);canvas_dependency_tracker_classPrivateFieldSet(ba,this,t);canvas_dependency_tracker_classPrivateFieldSet(ya,this,!!i)}get clipBox(){return canvas_dependency_tracker_classPrivateFieldGet(Fa,this).clipBox}growOperationsCount(){throw new Error("Unreachable")}save(e){var t;canvas_dependency_tracker_classPrivateFieldSet(Ca,this,(t=canvas_dependency_tracker_classPrivateFieldGet(Ca,this),t++,t));canvas_dependency_tracker_classPrivateFieldGet(Fa,this).save(canvas_dependency_tracker_classPrivateFieldGet(ba,this));return this}restore(e){if(canvas_dependency_tracker_classPrivateFieldGet(Ca,this)>0){var t;canvas_dependency_tracker_classPrivateFieldGet(Fa,this).restore(canvas_dependency_tracker_classPrivateFieldGet(ba,this));canvas_dependency_tracker_classPrivateFieldSet(Ca,this,(t=canvas_dependency_tracker_classPrivateFieldGet(Ca,this),t--,t))}return this}recordOpenMarker(e){var t;canvas_dependency_tracker_classPrivateFieldSet(Sa,this,(t=canvas_dependency_tracker_classPrivateFieldGet(Sa,this),t++,t));return this}getOpenMarker(){return canvas_dependency_tracker_classPrivateFieldGet(Sa,this)>0?canvas_dependency_tracker_classPrivateFieldGet(ba,this):canvas_dependency_tracker_classPrivateFieldGet(Fa,this).getOpenMarker()}recordCloseMarker(e){var t;canvas_dependency_tracker_classPrivateFieldSet(Sa,this,(t=canvas_dependency_tracker_classPrivateFieldGet(Sa,this),t--,t));return this}beginMarkedContent(e){return this}endMarkedContent(e){return this}pushBaseTransform(e){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).pushBaseTransform(e);return this}popBaseTransform(){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).popBaseTransform();return this}recordSimpleData(e,t){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordSimpleData(e,canvas_dependency_tracker_classPrivateFieldGet(ba,this));return this}recordIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordIncrementalData(e,canvas_dependency_tracker_classPrivateFieldGet(ba,this));return this}resetIncrementalData(e,t){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).resetIncrementalData(e,canvas_dependency_tracker_classPrivateFieldGet(ba,this));return this}recordNamedData(e,t){return this}recordSimpleDataFromNamed(e,t,i){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordSimpleDataFromNamed(e,t,canvas_dependency_tracker_classPrivateFieldGet(ba,this));return this}recordFutureForcedDependency(e,t){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordFutureForcedDependency(e,canvas_dependency_tracker_classPrivateFieldGet(ba,this));return this}inheritSimpleDataAsFutureForcedDependencies(e){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).inheritSimpleDataAsFutureForcedDependencies(e);return this}inheritPendingDependenciesAsFutureForcedDependencies(){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).inheritPendingDependenciesAsFutureForcedDependencies();return this}resetBBox(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this)||canvas_dependency_tracker_classPrivateFieldGet(Fa,this).resetBBox(canvas_dependency_tracker_classPrivateFieldGet(ba,this));return this}recordClipBox(e,t,i,a,s,n){canvas_dependency_tracker_classPrivateFieldGet(ya,this)||canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordClipBox(canvas_dependency_tracker_classPrivateFieldGet(ba,this),t,i,a,s,n);return this}recordBBox(e,t,i,a,s,n){canvas_dependency_tracker_classPrivateFieldGet(ya,this)||canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordBBox(canvas_dependency_tracker_classPrivateFieldGet(ba,this),t,i,a,s,n);return this}recordCharacterBBox(e,t,i,a,s,n,r){canvas_dependency_tracker_classPrivateFieldGet(ya,this)||canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordCharacterBBox(canvas_dependency_tracker_classPrivateFieldGet(ba,this),t,i,a,s,n,r);return this}recordFullPageBBox(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this)||canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordFullPageBBox(canvas_dependency_tracker_classPrivateFieldGet(ba,this));return this}getSimpleIndex(e){return canvas_dependency_tracker_classPrivateFieldGet(Fa,this).getSimpleIndex(e)}recordDependencies(e,t){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordDependencies(canvas_dependency_tracker_classPrivateFieldGet(ba,this),t);return this}recordNamedDependency(e,t){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordNamedDependency(canvas_dependency_tracker_classPrivateFieldGet(ba,this),t);return this}recordOperation(e){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordOperation(canvas_dependency_tracker_classPrivateFieldGet(ba,this),!0);return this}recordShowTextOperation(e){canvas_dependency_tracker_classPrivateFieldGet(Fa,this).recordShowTextOperation(canvas_dependency_tracker_classPrivateFieldGet(ba,this),!0);return this}bboxToClipBoxDropOperation(e){canvas_dependency_tracker_classPrivateFieldGet(ya,this)||canvas_dependency_tracker_classPrivateFieldGet(Fa,this).bboxToClipBoxDropOperation(canvas_dependency_tracker_classPrivateFieldGet(ba,this),!0);return this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const xa=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],ka=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],Ea=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],Aa=["filter","fillColor","fillAlpha"],Ga=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],Ba=["transform"],Ma=["transform","fillColor"];var Ia=new WeakMap,Ta=new WeakMap,Da=new WeakMap,La=new WeakMap,Na=new WeakMap;class CanvasImagesTracker{constructor(e){canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ia,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Ta,void 0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Da,4);canvas_dependency_tracker_classPrivateFieldInitSpec(this,La,0);canvas_dependency_tracker_classPrivateFieldInitSpec(this,Na,new Ra._(6*canvas_dependency_tracker_classPrivateFieldGet(Da,this)));canvas_dependency_tracker_classPrivateFieldSet(Ia,this,e.width);canvas_dependency_tracker_classPrivateFieldSet(Ta,this,e.height)}record(e,t,a,s){var n;if(canvas_dependency_tracker_classPrivateFieldGet(La,this)===canvas_dependency_tracker_classPrivateFieldGet(Da,this)){canvas_dependency_tracker_classPrivateFieldSet(Da,this,2*canvas_dependency_tracker_classPrivateFieldGet(Da,this));const e=new Ra._(6*canvas_dependency_tracker_classPrivateFieldGet(Da,this));e.set(canvas_dependency_tracker_classPrivateFieldGet(Na,this));canvas_dependency_tracker_classPrivateFieldSet(Na,this,e)}const r=getCurrentTransform(e);let o;if(s[0]!==1/0){const e=i.slice();Util.axialAlignedBoundingBox([0,-a,t,0],r,e);const n=Util.intersect(s,e);if(!n)return;const[l,d,c,h]=n;if(l!==e[0]||d!==e[1]||c!==e[2]||h!==e[3]){const e=Math.atan2(r[1],r[0]),t=Math.abs(Math.sin(e)),i=Math.abs(Math.cos(e));if(t<1e-6||i<1e-6||Math.abs(t-i)<1e-6)o=[l,d,l,h,c,d];else{const e=c-l,a=h-d,s=t*t,n=i*i,r=i*t,u=n-s,_=(a*n-e*r)/u;o=[l+(a*r-e*s)/u,d,l,d+_,c,h-_]}}}if(!o){o=[0,-a,0,0,t,-a];Util.applyTransform(o,r,0);Util.applyTransform(o,r,2);Util.applyTransform(o,r,4)}o[0]/=canvas_dependency_tracker_classPrivateFieldGet(Ia,this);o[1]/=canvas_dependency_tracker_classPrivateFieldGet(Ta,this);o[2]/=canvas_dependency_tracker_classPrivateFieldGet(Ia,this);o[3]/=canvas_dependency_tracker_classPrivateFieldGet(Ta,this);o[4]/=canvas_dependency_tracker_classPrivateFieldGet(Ia,this);o[5]/=canvas_dependency_tracker_classPrivateFieldGet(Ta,this);canvas_dependency_tracker_classPrivateFieldGet(Na,this).set(o,6*canvas_dependency_tracker_classPrivateFieldGet(La,this));canvas_dependency_tracker_classPrivateFieldSet(La,this,(n=canvas_dependency_tracker_classPrivateFieldGet(La,this),n++,n))}take(){return canvas_dependency_tracker_classPrivateFieldGet(Na,this).subarray(0,6*canvas_dependency_tracker_classPrivateFieldGet(La,this))}}var Ra={_:FeatureTest.isFloat16ArraySupported?Float16Array:Float32Array};function font_loader_defineProperty(e,t,i){return(t=function font_loader_toPropertyKey(e){var t=function font_loader_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function font_loader_classPrivateFieldInitSpec(e,t,i){font_loader_checkPrivateRedeclaration(e,t),t.set(e,i)}function font_loader_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function font_loader_classPrivateFieldSet(e,t,i){return e.set(font_loader_assertClassBrand(e,t),i),i}function font_loader_classPrivateFieldGet(e,t){return e.get(font_loader_assertClassBrand(e,t))}function font_loader_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Oa=new WeakMap,Wa=new WeakMap,ja=new WeakSet;class FontLoader{constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){!function font_loader_classPrivateMethodInitSpec(e,t){font_loader_checkPrivateRedeclaration(e,t),t.add(e)}(this,ja);font_loader_classPrivateFieldInitSpec(this,Oa,new Set);font_loader_classPrivateFieldInitSpec(this,Wa,null);this._document=e;this.nativeFontFaces=new Set;this.styleElement=null;this.loadingRequests=[];this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e);this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e);this._document.fonts.delete(e)}insertRule(e){const t=font_loader_assertClassBrand(ja,this,_getStyleSheet).call(this);t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear();font_loader_classPrivateFieldGet(Oa,this).clear();if(font_loader_classPrivateFieldGet(Wa,this)){const{adoptedStyleSheets:e}=this._document;e?.includes(font_loader_classPrivateFieldGet(Wa,this))&&(this._document.adoptedStyleSheets=e.filter(e=>e!==font_loader_classPrivateFieldGet(Wa,this)));font_loader_classPrivateFieldSet(Wa,this,null)}if(this.styleElement){this.styleElement.remove();this.styleElement=null}}async loadSystemFont({systemFontInfo:e,disableFontFace:t,_inspectFont:i}){if(e&&!font_loader_classPrivateFieldGet(Oa,this).has(e.loadedName)){assert(!t,"loadSystemFont shouldn't be called when `disableFontFace` is set.");if(this.isFontLoadingAPISupported){const{loadedName:t,src:a,style:s}=e,n=new FontFace(t,a,s);this.addNativeFontFace(n);try{await n.load();font_loader_classPrivateFieldGet(Oa,this).add(t);i?.(e)}catch{warn(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`);this.removeNativeFontFace(n)}return}unreachable("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;e.attached=!0;if(e.systemFontInfo){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(i){warn(`Failed to load font '${t.family}': '${i}'.`);e.disableFontFace=!0;throw i}}return}const t=e.createFontFaceRule();if(t){this.insertRule(t);if(this.isSyncFontLoadingSupported)return;await new Promise(t=>{const i=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,i)})}}get isFontLoadingAPISupported(){return shadow(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return shadow(this,"isSyncFontLoadingSupported",t||FeatureTest.platform.isFirefox)}_queueLoadingCallback(e){const{loadingRequests:t}=this,i={done:!1,complete:function completeRequest(){assert(!i.done,"completeRequest() cannot be called twice.");i.done=!0;for(;t.length>0&&t[0].done;){const e=t.shift();setTimeout(e.callback,0)}},callback:e};t.push(i);return i}get _loadTestFont(){return shadow(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(e,t){function int32(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function spliceString(e,t,i,a){return e.substring(0,t)+a+e.substring(t+i)}let i,a;const s=this._document.createElement("canvas");s.width=1;s.height=1;const n=s.getContext("2d");let r=0;const o=`lt${Date.now()}${this.loadTestFontId++}`;let l=this._loadTestFont;l=spliceString(l,976,o.length,o);const d=1482184792;let c=int32(l,16);for(i=0,a=o.length-3;i<a;i+=4)c=c-d+int32(o,i)|0;i<o.length&&(c=c-d+int32(o+"XXX",i)|0);l=spliceString(l,16,4,function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}(c));const h=`@font-face {font-family:"${o}";src:${`url(data:font/opentype;base64,${btoa(l)});`}}`;this.insertRule(h);const u=this._document.createElement("div");u.style.visibility="hidden";u.style.width=u.style.height="10px";u.style.position="absolute";u.style.top=u.style.left="0px";for(const t of[e.loadedName,o]){const e=this._document.createElement("span");e.textContent="Hi";e.style.fontFamily=t;u.append(e)}this._document.body.append(u);!function isFontReady(e,t){if(++r>30){warn("Load test font never loaded.");t();return}n.font="30px "+e;n.fillText(".",0,20);n.getImageData(0,0,1,1).data[3]>0?t():setTimeout(isFontReady.bind(null,e,t))}(o,()=>{u.remove();t.complete()})}}function _getStyleSheet(){if(font_loader_classPrivateFieldGet(Wa,this))return font_loader_classPrivateFieldGet(Wa,this);const e=this._document.defaultView?.CSSStyleSheet||globalThis.CSSStyleSheet;if(!this.styleElement&&e){const{adoptedStyleSheets:t}=this._document;if(t){const i=new e;t.push(i);return font_loader_classPrivateFieldSet(Wa,this,i)}}if(!this.styleElement){this.styleElement=this._document.createElement("style");this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)}return font_loader_classPrivateFieldSet(Wa,this,this.styleElement.sheet)}var Va,Ua=new WeakMap;class FontFaceObject{constructor(e,t=null,i,a){font_loader_defineProperty(this,"compiledGlyphs",Object.create(null));font_loader_classPrivateFieldInitSpec(this,Ua,void 0);font_loader_classPrivateFieldSet(Ua,this,e);this._inspectFont=t;i&&(this.charProcOperatorList=i);a&&Object.assign(this,a)}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`);e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});this._inspectFont?.(this);return e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${this.data.toBase64()});`;let t;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`);t=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${e}}`}else t=`@font-face {font-family:"${this.loadedName}";src:${e}}`;this._inspectFont?.(this,e);return t}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];const i=this.loadedName+"_path_"+t;let a;try{a=e.get(i)}catch(e){warn(`getPathGenerator - ignoring character: "${e}".`)}const s=makePathFromDrawOPS(a?.path);this.fontExtraProperties||e.delete(i);return this.compiledGlyphs[t]=s}get black(){return font_loader_classPrivateFieldGet(Ua,this).black}get bold(){return font_loader_classPrivateFieldGet(Ua,this).bold}get disableFontFace(){return font_loader_classPrivateFieldGet(Ua,this).disableFontFace}set disableFontFace(e){shadow(this,"disableFontFace",!!e)}get fontExtraProperties(){return font_loader_classPrivateFieldGet(Ua,this).fontExtraProperties}get isInvalidPDFjsFont(){return font_loader_classPrivateFieldGet(Ua,this).isInvalidPDFjsFont}get isType3Font(){return font_loader_classPrivateFieldGet(Ua,this).isType3Font}get italic(){return font_loader_classPrivateFieldGet(Ua,this).italic}get missingFile(){return font_loader_classPrivateFieldGet(Ua,this).missingFile}get remeasure(){return font_loader_classPrivateFieldGet(Ua,this).remeasure}get vertical(){return font_loader_classPrivateFieldGet(Ua,this).vertical}get ascent(){return font_loader_classPrivateFieldGet(Ua,this).ascent}get defaultWidth(){return font_loader_classPrivateFieldGet(Ua,this).defaultWidth}get descent(){return font_loader_classPrivateFieldGet(Ua,this).descent}get bbox(){return font_loader_classPrivateFieldGet(Ua,this).bbox}get fontMatrix(){return font_loader_classPrivateFieldGet(Ua,this).fontMatrix}get fallbackName(){return font_loader_classPrivateFieldGet(Ua,this).fallbackName}get loadedName(){return font_loader_classPrivateFieldGet(Ua,this).loadedName}get mimetype(){return font_loader_classPrivateFieldGet(Ua,this).mimetype}get name(){return font_loader_classPrivateFieldGet(Ua,this).name}get data(){return font_loader_classPrivateFieldGet(Ua,this).data}clearData(){font_loader_classPrivateFieldGet(Ua,this).clearData()}get cssFontInfo(){return font_loader_classPrivateFieldGet(Ua,this).cssFontInfo}get systemFontInfo(){return font_loader_classPrivateFieldGet(Ua,this).systemFontInfo}get defaultVMetrics(){return font_loader_classPrivateFieldGet(Ua,this).defaultVMetrics}}function obj_bin_transform_utils_defineProperty(e,t,i){return(t=function obj_bin_transform_utils_toPropertyKey(e){var t=function obj_bin_transform_utils_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class CSS_FONT_INFO{}obj_bin_transform_utils_defineProperty(CSS_FONT_INFO,"strings",["fontFamily","fontWeight","italicAngle"]);class SYSTEM_FONT_INFO{}obj_bin_transform_utils_defineProperty(SYSTEM_FONT_INFO,"strings",["css","loadedName","baseFontName","src"]);class FONT_INFO{}Va=FONT_INFO;obj_bin_transform_utils_defineProperty(FONT_INFO,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]);obj_bin_transform_utils_defineProperty(FONT_INFO,"numbers",["ascent","defaultWidth","descent"]);obj_bin_transform_utils_defineProperty(FONT_INFO,"strings",["fallbackName","loadedName","mimetype","name"]);obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_NUMBERS",Math.ceil(2*Va.bools.length/8));obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_BBOX",Va.OFFSET_NUMBERS+8*Va.numbers.length);obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_FONT_MATRIX",Va.OFFSET_BBOX+1+8);obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_DEFAULT_VMETRICS",Va.OFFSET_FONT_MATRIX+1+48);obj_bin_transform_utils_defineProperty(FONT_INFO,"OFFSET_STRINGS",Va.OFFSET_DEFAULT_VMETRICS+1+6);class PATTERN_INFO{}obj_bin_transform_utils_defineProperty(PATTERN_INFO,"KIND",0);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"HAS_BBOX",1);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"HAS_BACKGROUND",2);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"SHADING_TYPE",3);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_COORD",4);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_COLOR",8);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_STOP",12);obj_bin_transform_utils_defineProperty(PATTERN_INFO,"N_FIGURES",16);function obj_bin_transform_display_classPrivateMethodInitSpec(e,t){obj_bin_transform_display_checkPrivateRedeclaration(e,t),t.add(e)}function obj_bin_transform_display_classPrivateFieldInitSpec(e,t,i){obj_bin_transform_display_checkPrivateRedeclaration(e,t),t.set(e,i)}function obj_bin_transform_display_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function obj_bin_transform_display_classPrivateFieldGet(e,t){return e.get(obj_bin_transform_display_assertClassBrand(e,t))}function obj_bin_transform_display_classPrivateFieldSet(e,t,i){return e.set(obj_bin_transform_display_assertClassBrand(e,t),i),i}function obj_bin_transform_display_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var za=new WeakMap,Ha=new WeakMap,$a=new WeakMap,Ka=new WeakSet;class CssFontInfo{constructor(e){obj_bin_transform_display_classPrivateMethodInitSpec(this,Ka);obj_bin_transform_display_classPrivateFieldInitSpec(this,za,void 0);obj_bin_transform_display_classPrivateFieldInitSpec(this,Ha,new TextDecoder);obj_bin_transform_display_classPrivateFieldInitSpec(this,$a,void 0);obj_bin_transform_display_classPrivateFieldSet(za,this,e);obj_bin_transform_display_classPrivateFieldSet($a,this,new DataView(e))}get fontFamily(){return obj_bin_transform_display_assertClassBrand(Ka,this,_readString).call(this,0)}get fontWeight(){return obj_bin_transform_display_assertClassBrand(Ka,this,_readString).call(this,1)}get italicAngle(){return obj_bin_transform_display_assertClassBrand(Ka,this,_readString).call(this,2)}}function _readString(e){assert(e<CSS_FONT_INFO.strings.length,"Invalid string index");let t=0;for(let i=0;i<e;i++)t+=obj_bin_transform_display_classPrivateFieldGet($a,this).getUint32(t)+4;const i=obj_bin_transform_display_classPrivateFieldGet($a,this).getUint32(t);return obj_bin_transform_display_classPrivateFieldGet(Ha,this).decode(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(za,this),t+4,i))}var Xa=new WeakMap,qa=new WeakMap,Ya=new WeakMap,Za=new WeakSet;class SystemFontInfo{constructor(e){obj_bin_transform_display_classPrivateMethodInitSpec(this,Za);obj_bin_transform_display_classPrivateFieldInitSpec(this,Xa,void 0);obj_bin_transform_display_classPrivateFieldInitSpec(this,qa,new TextDecoder);obj_bin_transform_display_classPrivateFieldInitSpec(this,Ya,void 0);obj_bin_transform_display_classPrivateFieldSet(Xa,this,e);obj_bin_transform_display_classPrivateFieldSet(Ya,this,new DataView(e))}get guessFallback(){return 0!==obj_bin_transform_display_classPrivateFieldGet(Ya,this).getUint8(0)}get css(){return obj_bin_transform_display_assertClassBrand(Za,this,_readString2).call(this,0)}get loadedName(){return obj_bin_transform_display_assertClassBrand(Za,this,_readString2).call(this,1)}get baseFontName(){return obj_bin_transform_display_assertClassBrand(Za,this,_readString2).call(this,2)}get src(){return obj_bin_transform_display_assertClassBrand(Za,this,_readString2).call(this,3)}get style(){let e=1;e+=4+obj_bin_transform_display_classPrivateFieldGet(Ya,this).getUint32(e);const t=obj_bin_transform_display_classPrivateFieldGet(Ya,this).getUint32(e),i=obj_bin_transform_display_classPrivateFieldGet(qa,this).decode(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Xa,this),e+4,t));e+=4+t;const a=obj_bin_transform_display_classPrivateFieldGet(Ya,this).getUint32(e);return{style:i,weight:obj_bin_transform_display_classPrivateFieldGet(qa,this).decode(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Xa,this),e+4,a))}}}function _readString2(e){assert(e<SYSTEM_FONT_INFO.strings.length,"Invalid string index");let t=5;for(let i=0;i<e;i++)t+=obj_bin_transform_display_classPrivateFieldGet(Ya,this).getUint32(t)+4;const i=obj_bin_transform_display_classPrivateFieldGet(Ya,this).getUint32(t);return obj_bin_transform_display_classPrivateFieldGet(qa,this).decode(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Xa,this),t+4,i))}var Qa=new WeakMap,Ja=new WeakMap,es=new WeakMap,ts=new WeakSet;class FontInfo{constructor({buffer:e,extra:t}){obj_bin_transform_display_classPrivateMethodInitSpec(this,ts);obj_bin_transform_display_classPrivateFieldInitSpec(this,Qa,void 0);obj_bin_transform_display_classPrivateFieldInitSpec(this,Ja,new TextDecoder);obj_bin_transform_display_classPrivateFieldInitSpec(this,es,void 0);obj_bin_transform_display_classPrivateFieldSet(Qa,this,e);obj_bin_transform_display_classPrivateFieldSet(es,this,new DataView(e));t&&Object.assign(this,t)}get black(){return obj_bin_transform_display_assertClassBrand(ts,this,_readBoolean).call(this,0)}get bold(){return obj_bin_transform_display_assertClassBrand(ts,this,_readBoolean).call(this,1)}get disableFontFace(){return obj_bin_transform_display_assertClassBrand(ts,this,_readBoolean).call(this,2)}get fontExtraProperties(){return obj_bin_transform_display_assertClassBrand(ts,this,_readBoolean).call(this,3)}get isInvalidPDFjsFont(){return obj_bin_transform_display_assertClassBrand(ts,this,_readBoolean).call(this,4)}get isType3Font(){return obj_bin_transform_display_assertClassBrand(ts,this,_readBoolean).call(this,5)}get italic(){return obj_bin_transform_display_assertClassBrand(ts,this,_readBoolean).call(this,6)}get missingFile(){return obj_bin_transform_display_assertClassBrand(ts,this,_readBoolean).call(this,7)}get remeasure(){return obj_bin_transform_display_assertClassBrand(ts,this,_readBoolean).call(this,8)}get vertical(){return obj_bin_transform_display_assertClassBrand(ts,this,_readBoolean).call(this,9)}get ascent(){return obj_bin_transform_display_assertClassBrand(ts,this,_readNumber).call(this,0)}get defaultWidth(){return obj_bin_transform_display_assertClassBrand(ts,this,_readNumber).call(this,1)}get descent(){return obj_bin_transform_display_assertClassBrand(ts,this,_readNumber).call(this,2)}get bbox(){return obj_bin_transform_display_assertClassBrand(ts,this,_readArray).call(this,FONT_INFO.OFFSET_BBOX,4,"getInt16",2)}get fontMatrix(){return obj_bin_transform_display_assertClassBrand(ts,this,_readArray).call(this,FONT_INFO.OFFSET_FONT_MATRIX,6,"getFloat64",8)}get defaultVMetrics(){return obj_bin_transform_display_assertClassBrand(ts,this,_readArray).call(this,FONT_INFO.OFFSET_DEFAULT_VMETRICS,3,"getInt16",2)}get fallbackName(){return obj_bin_transform_display_assertClassBrand(ts,this,_readString3).call(this,0)}get loadedName(){return obj_bin_transform_display_assertClassBrand(ts,this,_readString3).call(this,1)}get mimetype(){return obj_bin_transform_display_assertClassBrand(ts,this,_readString3).call(this,2)}get name(){return obj_bin_transform_display_assertClassBrand(ts,this,_readString3).call(this,3)}get data(){const{offset:e,length:t}=obj_bin_transform_display_assertClassBrand(ts,this,_getDataOffsets).call(this);return 0===t?void 0:new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Qa,this),e+4,t)}clearData(){const{offset:e,length:t}=obj_bin_transform_display_assertClassBrand(ts,this,_getDataOffsets).call(this);if(0!==t){obj_bin_transform_display_classPrivateFieldGet(es,this).setUint32(e,0);obj_bin_transform_display_classPrivateFieldSet(Qa,this,new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Qa,this),0,e+4).slice().buffer);obj_bin_transform_display_classPrivateFieldSet(es,this,new DataView(obj_bin_transform_display_classPrivateFieldGet(Qa,this)))}}get cssFontInfo(){let e=FONT_INFO.OFFSET_STRINGS;e+=4+obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(e);e+=4+obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(e);const t=obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(e);if(0===t)return null;const i=new Uint8Array(t);i.set(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Qa,this),e+4,t));return new CssFontInfo(i.buffer)}get systemFontInfo(){let e=FONT_INFO.OFFSET_STRINGS;e+=4+obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(e);const t=obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(e);if(0===t)return null;const i=new Uint8Array(t);i.set(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Qa,this),e+4,t));return new SystemFontInfo(i.buffer)}}function _readBoolean(e){assert(e<FONT_INFO.bools.length,"Invalid boolean index");const t=Math.floor(e/4),i=2*e%8,a=obj_bin_transform_display_classPrivateFieldGet(es,this).getUint8(t)>>i&3;return 0===a?void 0:2===a}function _readNumber(e){assert(e<FONT_INFO.numbers.length,"Invalid number index");return obj_bin_transform_display_classPrivateFieldGet(es,this).getFloat64(FONT_INFO.OFFSET_NUMBERS+8*e)}function _readArray(e,t,i,a){const s=obj_bin_transform_display_classPrivateFieldGet(es,this).getUint8(e);if(0===s)return;assert(s===t,"Invalid array length.");e+=1;const n=new Array(s);for(let t=0;t<s;t++){n[t]=obj_bin_transform_display_classPrivateFieldGet(es,this)[i](e,!0);e+=a}return n}function _readString3(e){assert(e<FONT_INFO.strings.length,"Invalid string index");let t=FONT_INFO.OFFSET_STRINGS+4;for(let i=0;i<e;i++)t+=obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(t)+4;const i=obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(t);return obj_bin_transform_display_classPrivateFieldGet(Ja,this).decode(new Uint8Array(obj_bin_transform_display_classPrivateFieldGet(Qa,this),t+4,i))}function _getDataOffsets(){let e=FONT_INFO.OFFSET_STRINGS;e+=4+obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(e);e+=4+obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(e);e+=4+obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(e);return{offset:e,length:obj_bin_transform_display_classPrivateFieldGet(es,this).getUint32(e)}}class PatternInfo{constructor(e){this.buffer=e;this.view=new DataView(e);this.data=new Uint8Array(e)}getIR(){const e=this.view,t=this.data[PATTERN_INFO.KIND],a=!!this.data[PATTERN_INFO.HAS_BBOX],s=!!this.data[PATTERN_INFO.HAS_BACKGROUND],n=e.getUint32(PATTERN_INFO.N_COORD,!0),r=e.getUint32(PATTERN_INFO.N_COLOR,!0),o=e.getUint32(PATTERN_INFO.N_STOP,!0);let l=20;const d=new Float32Array(this.buffer,l,2*n);l+=8*n;const c=new Uint8Array(this.buffer,l,4*r);l+=4*r;const h=[];for(let t=0;t<o;++t){const t=e.getFloat32(l,!0);l+=4;const i=e.getUint32(l,!0);l+=4;h.push([t,`#${i.toString(16).padStart(6,"0")}`])}let u=null;if(a){u=[];for(let t=0;t<4;++t){u.push(e.getFloat32(l,!0));l+=4}}let _=null;if(s){_=new Uint8Array(this.buffer,l,3);l+=3}if(1===t)return["RadialAxial","axial",u,h,Array.from(d.slice(0,2)),Array.from(d.slice(2,4)),null,null];if(2===t)return["RadialAxial","radial",u,h,[d[0],d[1]],[d[3],d[4]],d[2],d[5]];if(3===t){const e=this.data[PATTERN_INFO.SHADING_TYPE];let t=null;if(d.length>0){t=i.slice();for(let e=0,i=d.length;e<i;e+=2)Util.pointBoundingBox(d[e],d[e+1],t)}return["Mesh",e,d,c,n,t,u,_]}throw new Error(`Unsupported pattern kind: ${t}`)}}var is=new WeakMap;class FontPathInfo{constructor(e){obj_bin_transform_display_classPrivateFieldInitSpec(this,is,void 0);obj_bin_transform_display_classPrivateFieldSet(is,this,e)}get path(){return FeatureTest.isFloat16ArraySupported?new Float16Array(obj_bin_transform_display_classPrivateFieldGet(is,this)):new Float32Array(obj_bin_transform_display_classPrivateFieldGet(is,this))}}function api_utils_classPrivateFieldInitSpec(e,t,i){(function api_utils_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function api_utils_classPrivateFieldGet(e,t){return e.get(function api_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}function getFactoryUrlProp(e){if("string"!=typeof e)return null;if(e.endsWith("/"))return e;throw new Error(`Invalid factory url: "${e}" must include trailing slash.`)}const isRefProxy=e=>"object"==typeof e&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0,as=function _isValidExplicitDest(e,t,i){if(!Array.isArray(i)||i.length<2)return!1;const[a,s,...n]=i;if(!e(a)&&!Number.isInteger(a))return!1;if(!t(s))return!1;const r=n.length;let o=!0;switch(s.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return 0===r;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(4!==r)return!1;o=!1;break;default:return!1}for(const e of n)if(!("number"==typeof e||o&&null===e))return!1;return!0}.bind(null,isRefProxy,e=>"object"==typeof e&&"string"==typeof e?.name);var ss=new WeakMap,ns=new WeakMap;class LoopbackPort{constructor(){api_utils_classPrivateFieldInitSpec(this,ss,new Map);api_utils_classPrivateFieldInitSpec(this,ns,Promise.resolve())}postMessage(e,t){const i={data:structuredClone(e,t?{transfer:t}:null)};api_utils_classPrivateFieldGet(ns,this).then(()=>{for(const[e]of api_utils_classPrivateFieldGet(ss,this))e.call(this,i)})}addEventListener(e,t,i=null){let a=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted){warn("LoopbackPort - cannot use an `aborted` signal.");return}const onAbort=()=>this.removeEventListener(e,t);a=()=>s.removeEventListener("abort",onAbort);s.addEventListener("abort",onAbort)}api_utils_classPrivateFieldGet(ss,this).set(t,a)}removeEventListener(e,t){const i=api_utils_classPrivateFieldGet(ss,this).get(t);i?.();api_utils_classPrivateFieldGet(ss,this).delete(t)}terminate(){for(const[,e]of api_utils_classPrivateFieldGet(ss,this))e?.();api_utils_classPrivateFieldGet(ss,this).clear()}}function message_handler_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function message_handler_classPrivateFieldGet(e,t){return e.get(message_handler_assertClassBrand(e,t))}function message_handler_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const rs=1,os=2,ls=1,ds=2,cs=3,hs=4,us=5,_s=6,ps=7,gs=8;function onFn(){}function wrapReason(e){if(e instanceof AbortException||e instanceof InvalidPDFException||e instanceof PasswordException||e instanceof ResponseException||e instanceof UnknownErrorException)return e;e instanceof Error||"object"==typeof e&&null!==e||unreachable('wrapReason: Expected "reason" to be a (possibly cloned) Error.');switch(e.name){case"AbortException":return new AbortException(e.message);case"InvalidPDFException":return new InvalidPDFException(e.message);case"PasswordException":return new PasswordException(e.message,e.code);case"ResponseException":return new ResponseException(e.message,e.status,e.missing);case"UnknownErrorException":return new UnknownErrorException(e.message,e.details)}return new UnknownErrorException(e.message,e.toString())}var ms=new WeakMap,fs=new WeakSet;class MessageHandler{constructor(e,t,i){!function message_handler_classPrivateMethodInitSpec(e,t){message_handler_checkPrivateRedeclaration(e,t),t.add(e)}(this,fs);!function message_handler_classPrivateFieldInitSpec(e,t,i){message_handler_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,ms,new AbortController);this.sourceName=e;this.targetName=t;this.comObj=i;this.callbackId=1;this.streamId=1;this.streamSinks=Object.create(null);this.streamControllers=Object.create(null);this.callbackCapabilities=Object.create(null);this.actionHandler=Object.create(null);i.addEventListener("message",message_handler_assertClassBrand(fs,this,_onMessage).bind(this),{signal:message_handler_classPrivateFieldGet(ms,this).signal})}on(e,t){const i=this.actionHandler;if(i[e])throw new Error(`There is already an actionName called "${e}"`);i[e]=t}send(e,t,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},i)}sendWithPromise(e,t,i){const a=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[a]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:a,data:t},i)}catch(e){s.reject(e)}return s.promise}sendWithStream(e,t,i,a){const s=this.streamId++,n=this.sourceName,r=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();this.streamControllers[s]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1};o.postMessage({sourceName:n,targetName:r,action:e,streamId:s,data:t,desiredSize:i.desiredSize},a);return l.promise},pull:e=>{const t=Promise.withResolvers();this.streamControllers[s].pullCall=t;o.postMessage({sourceName:n,targetName:r,stream:_s,streamId:s,desiredSize:e.desiredSize});return t.promise},cancel:e=>{assert(e instanceof Error,"cancel must have a valid reason");const t=Promise.withResolvers();this.streamControllers[s].cancelCall=t;this.streamControllers[s].isClosed=!0;o.postMessage({sourceName:n,targetName:r,stream:ls,streamId:s,reason:wrapReason(e)});return t.promise}},i)}destroy(){message_handler_classPrivateFieldGet(ms,this)?.abort();!function message_handler_classPrivateFieldSet(e,t,i){return e.set(message_handler_assertClassBrand(e,t),i),i}(ms,this,null)}}function _onMessage({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream){message_handler_assertClassBrand(fs,this,_processStreamMessage).call(this,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===rs)i.resolve(e.data);else{if(e.callback!==os)throw new Error("Unexpected callback case");i.reject(wrapReason(e.reason))}return}const t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const i=this.sourceName,a=e.sourceName,s=this.comObj;Promise.try(t,e.data).then(function(t){s.postMessage({sourceName:i,targetName:a,callback:rs,callbackId:e.callbackId,data:t})},function(t){s.postMessage({sourceName:i,targetName:a,callback:os,callbackId:e.callbackId,reason:wrapReason(t)})});return}e.streamId?message_handler_assertClassBrand(fs,this,_createStreamSink).call(this,e):t(e.data)}function _createStreamSink(e){const t=e.streamId,i=this.sourceName,a=e.sourceName,s=this.comObj,n=this,r=this.actionHandler[e.action],o={enqueue(e,n=1,r){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=n;if(o>0&&this.desiredSize<=0){this.sinkCapability=Promise.withResolvers();this.ready=this.sinkCapability.promise}s.postMessage({sourceName:i,targetName:a,stream:hs,streamId:t,chunk:e},r)},close(){if(!this.isCancelled){this.isCancelled=!0;s.postMessage({sourceName:i,targetName:a,stream:cs,streamId:t});delete n.streamSinks[t]}},error(e){assert(e instanceof Error,"error must have a valid reason");if(!this.isCancelled){this.isCancelled=!0;s.postMessage({sourceName:i,targetName:a,stream:us,streamId:t,reason:wrapReason(e)})}},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};o.sinkCapability.resolve();o.ready=o.sinkCapability.promise;this.streamSinks[t]=o;Promise.try(r,e.data,o).then(function(){s.postMessage({sourceName:i,targetName:a,stream:gs,streamId:t,success:!0})},function(e){s.postMessage({sourceName:i,targetName:a,stream:gs,streamId:t,reason:wrapReason(e)})})}function _processStreamMessage(e){const t=e.streamId,i=this.sourceName,a=e.sourceName,s=this.comObj,n=this.streamControllers[t],r=this.streamSinks[t];switch(e.stream){case gs:e.success?n.startCall.resolve():n.startCall.reject(wrapReason(e.reason));break;case ps:e.success?n.pullCall.resolve():n.pullCall.reject(wrapReason(e.reason));break;case _s:if(!r){s.postMessage({sourceName:i,targetName:a,stream:ps,streamId:t,success:!0});break}r.desiredSize<=0&&e.desiredSize>0&&r.sinkCapability.resolve();r.desiredSize=e.desiredSize;Promise.try(r.onPull||onFn).then(function(){s.postMessage({sourceName:i,targetName:a,stream:ps,streamId:t,success:!0})},function(e){s.postMessage({sourceName:i,targetName:a,stream:ps,streamId:t,reason:wrapReason(e)})});break;case hs:assert(n,"enqueue should have stream controller");if(n.isClosed)break;n.controller.enqueue(e.chunk);break;case cs:assert(n,"close should have stream controller");if(n.isClosed)break;n.isClosed=!0;n.controller.close();message_handler_assertClassBrand(fs,this,_deleteStreamController).call(this,n,t);break;case us:assert(n,"error should have stream controller");n.controller.error(wrapReason(e.reason));message_handler_assertClassBrand(fs,this,_deleteStreamController).call(this,n,t);break;case ds:e.success?n.cancelCall.resolve():n.cancelCall.reject(wrapReason(e.reason));message_handler_assertClassBrand(fs,this,_deleteStreamController).call(this,n,t);break;case ls:if(!r)break;const o=wrapReason(e.reason);Promise.try(r.onCancel||onFn,o).then(function(){s.postMessage({sourceName:i,targetName:a,stream:ds,streamId:t,success:!0})},function(e){s.postMessage({sourceName:i,targetName:a,stream:ds,streamId:t,reason:wrapReason(e)})});r.sinkCapability.reject(o);r.isCancelled=!0;delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}async function _deleteStreamController(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]);delete this.streamControllers[t]}function binary_data_factory_classPrivateFieldInitSpec(e,t,i){(function binary_data_factory_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function binary_data_factory_classPrivateFieldGet(e,t){return e.get(function binary_data_factory_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}var vs=new WeakMap;class BaseBinaryDataFactory{constructor({cMapUrl:e=null,standardFontDataUrl:t=null,wasmUrl:i=null}){binary_data_factory_classPrivateFieldInitSpec(this,vs,Object.freeze({cMapUrl:"CMap",standardFontDataUrl:"font",wasmUrl:"wasm"}));this.cMapUrl=e;this.standardFontDataUrl=t;this.wasmUrl=i}async fetch({kind:e,filename:t}){switch(e){case"cMapUrl":case"standardFontDataUrl":case"wasmUrl":break;default:unreachable(`Not implemented: ${e}`)}const i=this[e];if(!i)throw new Error(`Ensure that the \`${e}\` API parameter is provided.`);const a=`${i}${t}`;return this._fetch(a,e).catch(t=>{throw new Error(`Unable to load ${binary_data_factory_classPrivateFieldGet(vs,this)[e]} data at: ${a}`)})}async _fetch(e,t){unreachable("Abstract method `_fetch` called.")}}class DOMBinaryDataFactory extends BaseBinaryDataFactory{async _fetch(e,t){const i="cMapUrl"!==t||e.endsWith(".bcmap")?"bytes":"text",a=await fetchData(e,i);return a instanceof Uint8Array?a:stringToBytes(a)}}function canvas_factory_classPrivateFieldInitSpec(e,t,i){(function canvas_factory_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function canvas_factory_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Ps=new WeakMap;class BaseCanvasFactory{constructor({enableHWA:e=!1}){canvas_factory_classPrivateFieldInitSpec(this,Ps,!1);!function canvas_factory_classPrivateFieldSet(e,t,i){return e.set(canvas_factory_assertClassBrand(e,t),i),i}(Ps,this,e)}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(e,t);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!(a=Ps,s=this,a.get(canvas_factory_assertClassBrand(a,s)))})};var a,s}reset({canvas:e},t,i){if(!e)throw new Error("Canvas is not specified");if(t<=0||i<=0)throw new Error("Invalid canvas size");e.width=t;e.height=i}destroy(e){const{canvas:t}=e;if(!t)throw new Error("Canvas is not specified");t.width=t.height=0;e.canvas=null;e.context=null}_createCanvas(e,t){unreachable("Abstract method `_createCanvas` called.")}}class DOMCanvasFactory extends BaseCanvasFactory{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t});this._document=e}_createCanvas(e,t){const i=this._document.createElement("canvas");i.width=e;i.height=t;return i}}function filter_factory_classPrivateFieldInitSpec(e,t,i){filter_factory_checkPrivateRedeclaration(e,t),t.set(e,i)}function filter_factory_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function filter_factory_classPrivateGetter(e,t,i){return i(filter_factory_assertClassBrand(e,t))}function filter_factory_classPrivateFieldGet(e,t){return e.get(filter_factory_assertClassBrand(e,t))}function filter_factory_classPrivateFieldSet(e,t,i){return e.set(filter_factory_assertClassBrand(e,t),i),i}function filter_factory_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class BaseFilterFactory{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addKnockoutFilter(e=0){return"none"}addHighlightHCMFilter(e,t,i,a,s){return"none"}addSelectionHCMFilter(e,t){return"none"}addSelectionFilter(){return"none"}createSelectionStyle(e=null){return null}destroy(e=!1){}}var ws=new WeakMap,Fs=new WeakMap,bs=new WeakMap,ys=new WeakMap,Ss=new WeakMap,Cs=new WeakMap,xs=new WeakMap,ks=new WeakSet;class DOMFilterFactory extends BaseFilterFactory{constructor({docId:e,ownerDocument:t=globalThis.document}){super();!function filter_factory_classPrivateMethodInitSpec(e,t){filter_factory_checkPrivateRedeclaration(e,t),t.add(e)}(this,ks);filter_factory_classPrivateFieldInitSpec(this,ws,void 0);filter_factory_classPrivateFieldInitSpec(this,Fs,void 0);filter_factory_classPrivateFieldInitSpec(this,bs,void 0);filter_factory_classPrivateFieldInitSpec(this,ys,void 0);filter_factory_classPrivateFieldInitSpec(this,Ss,void 0);filter_factory_classPrivateFieldInitSpec(this,Cs,void 0);filter_factory_classPrivateFieldInitSpec(this,xs,0);filter_factory_classPrivateFieldSet(ys,this,e);filter_factory_classPrivateFieldSet(Ss,this,t)}addFilter(e){var t,i;if(!e)return"none";let a=filter_factory_classPrivateGetter(ks,this,_get_cache).get(e);if(a)return a;const[s,n,r]=filter_factory_assertClassBrand(ks,this,_createTables).call(this,e),o=1===e.length?s:`${s}${n}${r}`;a=filter_factory_classPrivateGetter(ks,this,_get_cache).get(o);if(a){filter_factory_classPrivateGetter(ks,this,_get_cache).set(e,a);return a}const l=`g_${filter_factory_classPrivateFieldGet(ys,this)}_transfer_map_${filter_factory_classPrivateFieldSet(xs,this,(t=filter_factory_classPrivateFieldGet(xs,this),i=t++,t)),i}`,d=filter_factory_assertClassBrand(ks,this,_createUrl).call(this,l);filter_factory_classPrivateGetter(ks,this,_get_cache).set(e,d);filter_factory_classPrivateGetter(ks,this,_get_cache).set(o,d);const c=filter_factory_assertClassBrand(ks,this,_createFilter).call(this,l);filter_factory_assertClassBrand(ks,this,_addTransferMapConversion).call(this,s,n,r,c);return d}addHCMFilter(e,t){const i=`${e}-${t}`,a="base";let s=filter_factory_classPrivateGetter(ks,this,_get_hcmCache).get(a);if(s?.key===i)return s.url;if(s){s.filter?.remove();s.key=i;s.url="none";s.filter=null}else{s={key:i,url:"none",filter:null};filter_factory_classPrivateGetter(ks,this,_get_hcmCache).set(a,s)}if(!e||!t)return s.url;const n=filter_factory_assertClassBrand(ks,this,_getRGB).call(this,e);e=Util.makeHexColor(...n);const r=filter_factory_assertClassBrand(ks,this,_getRGB).call(this,t);t=Util.makeHexColor(...r);filter_factory_assertClassBrand(ks,this,_resetDefsColor).call(this);if("#000000"===e&&"#ffffff"===t||e===t)return s.url;const o=new Array(256);for(let e=0;e<=255;e++){const t=e/255;o[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const l=o.join(","),d=`g_${filter_factory_classPrivateFieldGet(ys,this)}_hcm_filter`,c=s.filter=filter_factory_assertClassBrand(ks,this,_createFilter).call(this,d);filter_factory_assertClassBrand(ks,this,_addTransferMapConversion).call(this,l,l,l,c);filter_factory_assertClassBrand(ks,this,_addGrayConversion).call(this,c);const getSteps=(e,t)=>{const i=n[e]/255,a=r[e]/255,s=new Array(t+1);for(let e=0;e<=t;e++)s[e]=i+e/t*(a-i);return s.join(",")};filter_factory_assertClassBrand(ks,this,_addTransferMapConversion).call(this,getSteps(0,5),getSteps(1,5),getSteps(2,5),c);s.url=filter_factory_assertClassBrand(ks,this,_createUrl).call(this,d);return s.url}addSelectionHCMFilter(e,t){return this.addHighlightHCMFilter("selection",e,t,"HighlightText","Highlight")}addSelectionFilter(){return this.addHighlightHCMFilter("selection_default","black","white","HighlightText","Highlight")}createSelectionStyle(e=null){const t=e?this.addSelectionHCMFilter(e.foreground,e.background):this.addSelectionFilter();return"none"!==t&&FeatureTest.platform.isFirefox?{"backdrop-filter":t,"background-color":"transparent"}:null}addAlphaFilter(e){var t,i;let a=filter_factory_classPrivateGetter(ks,this,_get_cache).get(e);if(a)return a;const[s]=filter_factory_assertClassBrand(ks,this,_createTables).call(this,[e]),n=`alpha_${s}`;a=filter_factory_classPrivateGetter(ks,this,_get_cache).get(n);if(a){filter_factory_classPrivateGetter(ks,this,_get_cache).set(e,a);return a}const r=`g_${filter_factory_classPrivateFieldGet(ys,this)}_alpha_map_${filter_factory_classPrivateFieldSet(xs,this,(t=filter_factory_classPrivateFieldGet(xs,this),i=t++,t)),i}`,o=filter_factory_assertClassBrand(ks,this,_createUrl).call(this,r);filter_factory_classPrivateGetter(ks,this,_get_cache).set(e,o);filter_factory_classPrivateGetter(ks,this,_get_cache).set(n,o);const l=filter_factory_assertClassBrand(ks,this,_createFilter).call(this,r);filter_factory_assertClassBrand(ks,this,_addTransferMapAlphaConversion).call(this,s,l);return o}addLuminosityFilter(e){var t,i;let a,s,n=filter_factory_classPrivateGetter(ks,this,_get_cache).get(e||"luminosity");if(n)return n;if(e){[a]=filter_factory_assertClassBrand(ks,this,_createTables).call(this,[e]);s=`luminosity_${a}`}else s="luminosity";n=filter_factory_classPrivateGetter(ks,this,_get_cache).get(s);if(n){filter_factory_classPrivateGetter(ks,this,_get_cache).set(e,n);return n}const r=`g_${filter_factory_classPrivateFieldGet(ys,this)}_luminosity_map_${filter_factory_classPrivateFieldSet(xs,this,(t=filter_factory_classPrivateFieldGet(xs,this),i=t++,t)),i}`,o=filter_factory_assertClassBrand(ks,this,_createUrl).call(this,r);filter_factory_classPrivateGetter(ks,this,_get_cache).set(e,o);filter_factory_classPrivateGetter(ks,this,_get_cache).set(s,o);const l=filter_factory_assertClassBrand(ks,this,_createFilter).call(this,r);filter_factory_assertClassBrand(ks,this,_addLuminosityConversion).call(this,l);e&&filter_factory_assertClassBrand(ks,this,_addTransferMapAlphaConversion).call(this,a,l);return o}addKnockoutFilter(e=0){var t,i;const a=e>0?Math.min(1/e,1e6):1e6,s=`knockout_${a}`,r=filter_factory_classPrivateGetter(ks,this,_get_cache).get(s);if(r)return r;const o=`g_${filter_factory_classPrivateFieldGet(ys,this)}_knockout_filter_${filter_factory_classPrivateFieldSet(xs,this,(t=filter_factory_classPrivateFieldGet(xs,this),i=t++,t)),i}`,l=filter_factory_assertClassBrand(ks,this,_createUrl).call(this,o);filter_factory_classPrivateGetter(ks,this,_get_cache).set(s,l);const d=filter_factory_assertClassBrand(ks,this,_createFilter).call(this,o),c=filter_factory_classPrivateFieldGet(Ss,this).createElementNS(n,"feComponentTransfer");d.append(c);const h=filter_factory_classPrivateFieldGet(Ss,this).createElementNS(n,"feFuncA");h.setAttribute("type","linear");h.setAttribute("slope",`${a}`);h.setAttribute("intercept","0");c.append(h);return l}addHighlightHCMFilter(e,t,i,a,s){const n=`${t}-${i}-${a}-${s}`;let r=filter_factory_classPrivateGetter(ks,this,_get_hcmCache).get(e);if(r?.key===n)return r.url;if(r){r.filter?.remove();r.key=n;r.url="none";r.filter=null}else{r={key:n,url:"none",filter:null};filter_factory_classPrivateGetter(ks,this,_get_hcmCache).set(e,r)}if(!t||!i)return r.url;const[o,l]=[t,i].map(filter_factory_assertClassBrand(ks,this,_getRGB).bind(this));let d=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[h,u]=[a,s].map(filter_factory_assertClassBrand(ks,this,_getOpaqueTextColor).bind(this));c<d&&([d,c,h,u]=[c,d,u,h]);filter_factory_assertClassBrand(ks,this,_resetDefsColor).call(this);const getSteps=(e,t,i)=>{const a=new Array(256),s=(c-d)/i,n=e/255,r=(t-e)/(255*i);let o=0;for(let e=0;e<=i;e++){const t=Math.round(d+e*s),i=n+e*r;for(let e=o;e<=t;e++)a[e]=i;o=t+1}for(let e=o;e<256;e++)a[e]=a[o-1];return a.join(",")},_=`g_${filter_factory_classPrivateFieldGet(ys,this)}_hcm_${e}_filter`,p=r.filter=filter_factory_assertClassBrand(ks,this,_createFilter).call(this,_);filter_factory_assertClassBrand(ks,this,_addGrayConversion).call(this,p);filter_factory_assertClassBrand(ks,this,_addTransferMapConversion).call(this,getSteps(h[0],u[0],5),getSteps(h[1],u[1],5),getSteps(h[2],u[2],5),p);r.url=filter_factory_assertClassBrand(ks,this,_createUrl).call(this,_);return r.url}destroy(e=!1){if(!e||!filter_factory_classPrivateFieldGet(Cs,this)?.size){filter_factory_classPrivateFieldGet(bs,this)?.parentNode.parentNode.remove();filter_factory_classPrivateFieldSet(bs,this,null);filter_factory_classPrivateFieldGet(Fs,this)?.clear();filter_factory_classPrivateFieldSet(Fs,this,null);filter_factory_classPrivateFieldGet(Cs,this)?.clear();filter_factory_classPrivateFieldSet(Cs,this,null);filter_factory_classPrivateFieldSet(xs,this,0)}}}function _get_cache(e){return filter_factory_classPrivateFieldGet(Fs,e)||filter_factory_classPrivateFieldSet(Fs,e,new Map)}function _get_hcmCache(e){return filter_factory_classPrivateFieldGet(Cs,e)||filter_factory_classPrivateFieldSet(Cs,e,new Map)}function _get_defs(e){if(!filter_factory_classPrivateFieldGet(bs,e)){const t=filter_factory_classPrivateFieldGet(Ss,e).createElement("div"),{style:i}=t;i.colorScheme="only light";i.visibility="hidden";i.contain="strict";i.width=i.height=0;i.position="absolute";i.top=i.left=0;i.zIndex=-1;const a=filter_factory_classPrivateFieldGet(Ss,e).createElementNS(n,"svg");a.setAttribute("width",0);a.setAttribute("height",0);filter_factory_classPrivateFieldSet(bs,e,filter_factory_classPrivateFieldGet(Ss,e).createElementNS(n,"defs"));t.append(a);a.append(filter_factory_classPrivateFieldGet(bs,e));filter_factory_classPrivateFieldGet(Ss,e).body.append(t)}return filter_factory_classPrivateFieldGet(bs,e)}function _createTables(e){if(1===e.length){const t=e[0],i=new Array(256);for(let e=0;e<256;e++)i[e]=t[e]/255;const a=i.join(",");return[a,a,a]}const[t,i,a]=e,s=new Array(256),n=new Array(256),r=new Array(256);for(let e=0;e<256;e++){s[e]=t[e]/255;n[e]=i[e]/255;r[e]=a[e]/255}return[s.join(","),n.join(","),r.join(",")]}function _createUrl(e){if(void 0===filter_factory_classPrivateFieldGet(ws,this)){filter_factory_classPrivateFieldSet(ws,this,"");const e=filter_factory_classPrivateFieldGet(Ss,this).URL;e!==filter_factory_classPrivateFieldGet(Ss,this).baseURI&&(isDataScheme(e)?warn('#createUrl: ignore "data:"-URL for performance reasons.'):filter_factory_classPrivateFieldSet(ws,this,updateUrlHash(e,"")))}return`url(${filter_factory_classPrivateFieldGet(ws,this)}#${e})`}function _addLuminosityConversion(e){const t=filter_factory_classPrivateFieldGet(Ss,this).createElementNS(n,"feColorMatrix");t.setAttribute("type","matrix");t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0");e.append(t)}function _addGrayConversion(e){const t=filter_factory_classPrivateFieldGet(Ss,this).createElementNS(n,"feColorMatrix");t.setAttribute("type","matrix");t.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");e.append(t)}function _createFilter(e){const t=filter_factory_classPrivateFieldGet(Ss,this).createElementNS(n,"filter");t.setAttribute("color-interpolation-filters","sRGB");t.setAttribute("id",e);filter_factory_classPrivateGetter(ks,this,_get_defs).append(t);return t}function _appendFeFunc(e,t,i){const a=filter_factory_classPrivateFieldGet(Ss,this).createElementNS(n,t);a.setAttribute("type","discrete");a.setAttribute("tableValues",i);e.append(a)}function _addTransferMapConversion(e,t,i,a){const s=filter_factory_classPrivateFieldGet(Ss,this).createElementNS(n,"feComponentTransfer");a.append(s);filter_factory_assertClassBrand(ks,this,_appendFeFunc).call(this,s,"feFuncR",e);filter_factory_assertClassBrand(ks,this,_appendFeFunc).call(this,s,"feFuncG",t);filter_factory_assertClassBrand(ks,this,_appendFeFunc).call(this,s,"feFuncB",i)}function _addTransferMapAlphaConversion(e,t){const i=filter_factory_classPrivateFieldGet(Ss,this).createElementNS(n,"feComponentTransfer");t.append(i);filter_factory_assertClassBrand(ks,this,_appendFeFunc).call(this,i,"feFuncA",e)}function _getRGB(e){filter_factory_classPrivateGetter(ks,this,_get_defs).style.color="CanvasText";filter_factory_classPrivateGetter(ks,this,_get_defs).style.backgroundColor=e;return getRGB(getComputedStyle(filter_factory_classPrivateGetter(ks,this,_get_defs)).getPropertyValue("background-color"))}function _getRGBA(e){filter_factory_classPrivateGetter(ks,this,_get_defs).style.color="CanvasText";filter_factory_classPrivateGetter(ks,this,_get_defs).style.backgroundColor=e;return getRGBA(getComputedStyle(filter_factory_classPrivateGetter(ks,this,_get_defs)).getPropertyValue("background-color"))}function _resetDefsColor(){filter_factory_classPrivateGetter(ks,this,_get_defs).style.color="";filter_factory_classPrivateGetter(ks,this,_get_defs).style.backgroundColor=""}function _getOpaqueTextColor(e){const[t,i,a,s]=filter_factory_assertClassBrand(ks,this,_getRGBA).call(this,e);if(1===s)return[t,i,a];const[n,r,o]=filter_factory_assertClassBrand(ks,this,_getRGB).call(this,"Canvas");return[blend(t,n,s),blend(i,r,s),blend(a,o,s)]}function blend(e,t,i){return Math.round(i*e+(1-i)*t)}class NodeFilterFactory extends BaseFilterFactory{}class NodeCanvasFactory extends BaseCanvasFactory{_createCanvas(e,t){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,t)}}class NodeBinaryDataFactory extends BaseBinaryDataFactory{async _fetch(e,t){return async function node_utils_fetchData(e){const t=process.getBuiltinModule("fs/promises"),i=await t.readFile(e);return new Uint8Array(i)}(e)}}function convertBlackAndWhiteToRGBA({src:e,srcPos:t=0,dest:i,width:a,height:s,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const o=FeatureTest.isLittleEndian?4278190080:255,[l,d]=r?[n,o]:[o,n],c=a>>3,h=7&a,u=l^d,_=e.length;i=new Uint32Array(i.buffer);let p=0;for(let a=0;a<s;++a){for(const a=t+c;t<a;++t,p+=8){const a=e[t];i[p]=l^-(a>>7&1)&u;i[p+1]=l^-(a>>6&1)&u;i[p+2]=l^-(a>>5&1)&u;i[p+3]=l^-(a>>4&1)&u;i[p+4]=l^-(a>>3&1)&u;i[p+5]=l^-(a>>2&1)&u;i[p+6]=l^-(a>>1&1)&u;i[p+7]=l^-(1&a)&u}if(0===h)continue;const a=t<_?e[t++]:255;for(let e=0;e<h;++e,++p)i[p]=l^-(a>>7-e&1)&u}return{srcPos:t,destPos:p}}function convertRGBToRGBA({src:e,srcPos:t=0,dest:i,destPos:a=0,width:s,height:n}){let r=0;const o=s*n*3,l=o>>2,d=new Uint32Array(e.buffer,t,l),c=FeatureTest.isLittleEndian?4278190080:255;if(FeatureTest.isLittleEndian){for(;r<l-2;r+=3,a+=4){const e=d[r],t=d[r+1],s=d[r+2];i[a]=e|c;i[a+1]=e>>>24|t<<8|c;i[a+2]=t>>>16|s<<16|c;i[a+3]=s>>>8|c}for(let s=4*r,n=t+o;s<n;s+=3)i[a++]=e[s]|e[s+1]<<8|e[s+2]<<16|c}else{for(;r<l-2;r+=3,a+=4){const e=d[r],t=d[r+1],s=d[r+2];i[a]=e|c;i[a+1]=e<<24|t>>>8|c;i[a+2]=t<<16|s>>>16|c;i[a+3]=s<<8|c}for(let s=4*r,n=t+o;s<n;s+=3)i[a++]=e[s]<<24|e[s+1]<<16|e[s+2]<<8|c}return{srcPos:t+o,destPos:a}}function webgpu_classPrivateFieldInitSpec(e,t,i){webgpu_checkPrivateRedeclaration(e,t),t.set(e,i)}function webgpu_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function webgpu_classPrivateFieldGet(e,t){return e.get(webgpu_assertClassBrand(e,t))}function webgpu_classPrivateFieldSet(e,t,i){return e.set(webgpu_assertClassBrand(e,t),i),i}function webgpu_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Es=new WeakMap,As=new WeakMap,Gs=new WeakMap,Bs=new WeakMap,Ms=new WeakSet;async function _initGPU(){if(!globalThis.navigator?.gpu)return!1;try{const e=await navigator.gpu.requestAdapter();if(!e)return!1;webgpu_classPrivateFieldSet(Bs,this,navigator.gpu.getPreferredCanvasFormat());webgpu_classPrivateFieldSet(As,this,await e.requestDevice());return!0}catch{return!1}}const Is=new class WebGPU{constructor(){!function webgpu_classPrivateMethodInitSpec(e,t){webgpu_checkPrivateRedeclaration(e,t),t.add(e)}(this,Ms);webgpu_classPrivateFieldInitSpec(this,Es,null);webgpu_classPrivateFieldInitSpec(this,As,null);webgpu_classPrivateFieldInitSpec(this,Gs,null);webgpu_classPrivateFieldInitSpec(this,Bs,null)}init(){return webgpu_classPrivateFieldGet(Es,this)||webgpu_classPrivateFieldSet(Es,this,webgpu_assertClassBrand(Ms,this,_initGPU).call(this))}get isReady(){return null!==webgpu_classPrivateFieldGet(As,this)}loadMeshShader(){if(!webgpu_classPrivateFieldGet(As,this)||webgpu_classPrivateFieldGet(Gs,this))return;const e=webgpu_classPrivateFieldGet(As,this).createShaderModule({code:"\nstruct Uniforms {\n offsetX : f32,\n offsetY : f32,\n scaleX : f32,\n scaleY : f32,\n paddedWidth : f32,\n paddedHeight : f32,\n borderSize : f32,\n _pad : f32,\n};\n\n@group(0) @binding(0) var<uniform> u : Uniforms;\n\nstruct VertexInput {\n @location(0) position : vec2<f32>,\n @location(1) color : vec4<f32>,\n};\n\nstruct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) color : vec3<f32>,\n};\n\n@vertex\nfn vs_main(in : VertexInput) -> VertexOutput {\n var out : VertexOutput;\n let cx = (in.position.x + u.offsetX) * u.scaleX;\n let cy = (in.position.y + u.offsetY) * u.scaleY;\n out.position = vec4<f32>(\n ((cx + u.borderSize) / u.paddedWidth) * 2.0 - 1.0,\n 1.0 - ((cy + u.borderSize) / u.paddedHeight) * 2.0,\n 0.0,\n 1.0\n );\n out.color = in.color.rgb;\n return out;\n}\n\n@fragment\nfn fs_main(in : VertexOutput) -> @location(0) vec4<f32> {\n return vec4<f32>(in.color, 1.0);\n}\n"});webgpu_classPrivateFieldSet(Gs,this,webgpu_classPrivateFieldGet(As,this).createRenderPipeline({layout:"auto",vertex:{module:e,entryPoint:"vs_main",buffers:[{arrayStride:8,attributes:[{shaderLocation:0,offset:0,format:"float32x2"}]},{arrayStride:4,attributes:[{shaderLocation:1,offset:0,format:"unorm8x4"}]}]},fragment:{module:e,entryPoint:"fs_main",targets:[{format:webgpu_classPrivateFieldGet(Bs,this)}]},primitive:{topology:"triangle-list"}}))}draw(e,t,i,a,s,n,r,o){this.loadMeshShader();const l=webgpu_classPrivateFieldGet(As,this),{offsetX:d,offsetY:c,scaleX:h,scaleY:u}=a,_=l.createBuffer({size:Math.max(e.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});e.byteLength>0&&l.queue.writeBuffer(_,0,e);const p=l.createBuffer({size:Math.max(t.byteLength,4),usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST});t.byteLength>0&&l.queue.writeBuffer(p,0,t);const g=l.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST});l.queue.writeBuffer(g,0,new Float32Array([d,c,h,u,n,r,o,0]));const m=l.createBindGroup({layout:webgpu_classPrivateFieldGet(Gs,this).getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:g}}]}),f=new OffscreenCanvas(n,r),v=f.getContext("webgpu");v.configure({device:l,format:webgpu_classPrivateFieldGet(Bs,this),alphaMode:s?"opaque":"premultiplied"});const P=s?{r:s[0]/255,g:s[1]/255,b:s[2]/255,a:1}:{r:0,g:0,b:0,a:0},w=l.createCommandEncoder(),F=w.beginRenderPass({colorAttachments:[{view:v.getCurrentTexture().createView(),clearValue:P,loadOp:"clear",storeOp:"store"}]});if(i>0){F.setPipeline(webgpu_classPrivateFieldGet(Gs,this));F.setBindGroup(0,m);F.setVertexBuffer(0,_);F.setVertexBuffer(1,p);F.draw(i)}F.end();l.queue.submit([w.finish()]);_.destroy();p.destroy();g.destroy();return f.transferToImageBitmap()}};function pattern_helper_defineProperty(e,t,i){return(t=function pattern_helper_toPropertyKey(e){var t=function pattern_helper_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const Ts="Fill",Ds="Stroke",Ls="Shading";function applyBoundingBox(e,t){if(!t)return;const i=t[2]-t[0],a=t[3]-t[1],s=new Path2D;s.rect(t[0],t[1],i,a);e.clip(s)}class BaseShadingPattern{constructor(){pattern_helper_defineProperty(this,"matrix",null)}isModifyingCurrentTransform(){return!1}getPattern(){unreachable("Abstract method `getPattern` called.")}}class RadialAxialShadingPattern extends BaseShadingPattern{constructor(e){super();this._type=e[1];this._bbox=e[2];this._colorStops=e[3];this._p0=e[4];this._p1=e[5];this._r0=e[6];this._r1=e[7]}isOriginBased(){return 0===this._p0[0]&&0===this._p0[1]&&(!this.isRadial()||0===this._p1[0]&&0===this._p1[1])}isRadial(){return"radial"===this._type}areConic(){if(!this.isRadial())return!1;const e=Math.hypot(this._p0[0]-this._p1[0],this._p0[1]-this._p1[1]);return e+this._r1>this._r0&&e+this._r0>this._r1}_createGradient(e,t=null){let i,a=this._p0,s=this._p1;if(t){a=a.slice();s=s.slice();Util.applyTransform(a,t);Util.applyTransform(s,t)}if("axial"===this._type)i=e.createLinearGradient(a[0],a[1],s[0],s[1]);else if("radial"===this._type){let n=this._r0,r=this._r1;if(t){const e=new Float32Array(2);Util.singularValueDecompose2dScale(t,e);n*=e[0];r*=e[0]}i=e.createRadialGradient(a[0],a[1],n,s[0],s[1],r)}for(const e of this._colorStops)i.addColorStop(e[0],e[1]);return i}_createReversedGradient(e,t=null){let i=this._p1,a=this._p0;if(t){i=i.slice();a=a.slice();Util.applyTransform(i,t);Util.applyTransform(a,t)}let s=this._r1,n=this._r0;if(t){const e=new Float32Array(2);Util.singularValueDecompose2dScale(t,e);s*=e[0];n*=e[0]}const r=e.createRadialGradient(i[0],i[1],s,a[0],a[1],n),o=this._colorStops.map(([e,t])=>[1-e,t]).reverse();for(const[e,t]of o)r.addColorStop(e,t);return r}getPattern(e,t,i,a){let s;if(a===Ds||a===Ts){if(this.isOriginBased()){let a=Util.transform(i,t.baseTransform);this.matrix&&(a=Util.transform(a,this.matrix));const s=.001,n=Math.hypot(a[0],a[1]),r=Math.hypot(a[2],a[3]),o=(a[0]*a[2]+a[1]*a[3])/(n*r);if(Math.abs(o)<s){if(!this.isRadial())return this._createGradient(e,a);if(Math.abs(n-r)<s)return this._createGradient(e,a)}}const n=t.current.getClippedPathBoundingBox(a,getCurrentTransform(e))||[0,0,0,0],r=Math.ceil(n[2]-n[0])||1,o=Math.ceil(n[3]-n[1])||1,l=t.canvasFactory.create(r,o),d=l.context;d.clearRect(0,0,d.canvas.width,d.canvas.height);d.beginPath();d.rect(0,0,d.canvas.width,d.canvas.height);d.translate(-n[0],-n[1]);i=Util.transform(i,[1,0,0,1,n[0],n[1]]);d.transform(...t.baseTransform);this.matrix&&d.transform(...this.matrix);applyBoundingBox(d,this._bbox);if(this.areConic()){d.fillStyle=this._createReversedGradient(d);d.fill()}d.fillStyle=this._createGradient(d);d.fill();s=e.createPattern(l.canvas,"no-repeat");t.canvasFactory.destroy(l);const c=new DOMMatrix(i);s.setTransform(c)}else{if(this.areConic()){e.save();applyBoundingBox(e,this._bbox);e.fillStyle=this._createReversedGradient(e);e.fillRect(-1e10,-1e10,2e10,2e10);e.restore()}applyBoundingBox(e,this._bbox);s=this._createGradient(e)}return s}}function drawTriangle(e,t,i,a,s,n,r,o){const l=t.coords,d=t.colors,c=e.data,h=4*e.width;let u;if(l[2*i+1]>l[2*a+1]){u=i;i=a;a=u;u=n;n=r;r=u}if(l[2*a+1]>l[2*s+1]){u=a;a=s;s=u;u=r;r=o;o=u}if(l[2*i+1]>l[2*a+1]){u=i;i=a;a=u;u=n;n=r;r=u}const _=(l[2*i]+t.offsetX)*t.scaleX,p=(l[2*i+1]+t.offsetY)*t.scaleY,g=(l[2*a]+t.offsetX)*t.scaleX,m=(l[2*a+1]+t.offsetY)*t.scaleY,f=(l[2*s]+t.offsetX)*t.scaleX,v=(l[2*s+1]+t.offsetY)*t.scaleY;if(p>=v)return;const P=d[4*n],w=d[4*n+1],F=d[4*n+2],b=d[4*r],y=d[4*r+1],S=d[4*r+2],C=d[4*o],x=d[4*o+1],k=d[4*o+2],E=Math.round(p),A=Math.round(v);let G,B,M,I,T,D,L,N;for(let e=E;e<=A;e++){if(e<m){const t=e<p?0:(p-e)/(p-m);G=_-(_-g)*t;B=P-(P-b)*t;M=w-(w-y)*t;I=F-(F-S)*t}else{let t;t=e>v?1:m===v?0:(m-e)/(m-v);G=g-(g-f)*t;B=b-(b-C)*t;M=y-(y-x)*t;I=S-(S-k)*t}let t;t=e<p?0:e>v?1:(p-e)/(p-v);T=_-(_-f)*t;D=P-(P-C)*t;L=w-(w-x)*t;N=F-(F-k)*t;const i=Math.round(Math.min(G,T)),a=Math.round(Math.max(G,T));let s=h*e+4*i;for(let e=i;e<=a;e++){t=(G-e)/(G-T);t<0?t=0:t>1&&(t=1);c[s++]=B-(B-D)*t|0;c[s++]=M-(M-L)*t|0;c[s++]=I-(I-N)*t|0;c[s++]=255}}}class MeshShadingPattern extends BaseShadingPattern{constructor(e){super();this._posData=e[2];this._colData=e[3];this._vertexCount=e[4];this._bounds=e[5];this._bbox=e[6];this._background=e[7];!function loadMeshShader(){Is.loadMeshShader()}()}_createMeshCanvas(e,t,i){const a=Math.floor(this._bounds[0]),s=Math.floor(this._bounds[1]),n=Math.ceil(this._bounds[2])-a,r=Math.ceil(this._bounds[3])-s,o=Math.min(Math.ceil(Math.abs(n*e[0]*1.1)),3e3)||1,l=Math.min(Math.ceil(Math.abs(r*e[1]*1.1)),3e3)||1,d=n?n/o:1,c=r?r/l:1,h={coords:this._posData,colors:this._colData,offsetX:-a,offsetY:-s,scaleX:1/d,scaleY:1/c},u=o+4,_=l+4,p=i.create(u,_);if(function isGPUReady(){return Is.isReady}()&&this._vertexCount>48)p.context.drawImage(function drawMeshWithGPU(e,t,i,a,s,n,r,o){return Is.draw(e,t,i,a,s,n,r,o)}(this._posData,this._colData,this._vertexCount,h,t,u,_,2),0,0);else{const e=p.context.createImageData(o,l);if(t){const i=e.data;for(let e=0,a=i.length;e<a;e+=4){i[e]=t[0];i[e+1]=t[1];i[e+2]=t[2];i[e+3]=255}}for(let t=0,i=this._vertexCount;t<i;t+=3)drawTriangle(e,h,t,t+1,t+2,t,t+1,t+2);p.context.putImageData(e,2,2)}return{canvas:p.canvas,offsetX:a-2*d,offsetY:s-2*c,scaleX:d,scaleY:c}}isModifyingCurrentTransform(){return!0}getPattern(e,t,i,a){applyBoundingBox(e,this._bbox);const s=new Float32Array(2);if(a===Ls)Util.singularValueDecompose2dScale(getCurrentTransform(e),s);else if(this.matrix){Util.singularValueDecompose2dScale(this.matrix,s);const[e,i]=s;Util.singularValueDecompose2dScale(t.baseTransform,s);s[0]*=e;s[1]*=i}else Util.singularValueDecompose2dScale(t.baseTransform,s);const n=this._createMeshCanvas(s,a===Ls?null:this._background,t.canvasFactory);if(a!==Ls){e.setTransform(...t.baseTransform);this.matrix&&e.transform(...this.matrix)}e.translate(n.offsetX,n.offsetY);e.scale(n.scaleX,n.scaleY);const r=e.createPattern(n.canvas,"no-repeat");t.canvasFactory.destroy(n);return r}}class DummyShadingPattern extends BaseShadingPattern{getPattern(){return"hotpink"}}const Ns=1,Rs=2;class TilingPattern{constructor(e,t,i,a){this.color=e[1];this.operatorList=e[2];this.matrix=e[3];this.bbox=e[4];this.xstep=e[5];this.ystep=e[6];this.paintType=e[7];this.tilingType=e[8];this.needsIsolation=e[9]??!0;this.ctx=t;this.canvasGraphicsFactory=i;this.baseTransform=a;this.patternBaseMatrix=this.matrix?Util.transform(a,this.matrix):a}canSkipPatternCanvas([e,t,i,a]){const[s,n,r,o]=this.bbox,l=Math.abs(this.xstep),d=Math.abs(this.ystep);if(e>l+1e-6||t>d+1e-6)return null;const c=Math.floor((i-r)/l)+1,h=Math.ceil((i+e-s)/l)-1,u=Math.floor((a-o)/d)+1,_=Math.ceil((a+t-n)/d)-1;return h<=c&&_<=u?[c,u]:null}updatePatternDims(e,t){const i=Util.inverseTransform(this.patternBaseMatrix),a=[e[0],e[1]],s=[e[2],e[3]];Util.applyTransform(a,i);Util.applyTransform(s,i);t[0]=Math.abs(s[0]-a[0]);t[1]=Math.abs(s[1]-a[1]);t[2]=Math.min(a[0],s[0]);t[3]=Math.min(a[1],s[1])}_renderTileCanvas(e,t,i,a){const[s,n,r,o]=this.bbox,l=e.canvasFactory.create(i.size,a.size),d=l.context,c=this.canvasGraphicsFactory.createCanvasGraphics(d,t);c.groupLevel=e.groupLevel;this.setFillAndStrokeStyleToContext(c,this.paintType,this.color);d.translate(-i.scale*s,-a.scale*n);c.transform(0,i.scale,0,0,a.scale,0,0);d.save();c.dependencyTracker?.save();this.clipBbox(c,s,n,r,o);c.baseTransform=getCurrentTransform(c.ctx);c.executeOperatorList(this.operatorList);c.endDrawing();c.dependencyTracker?.restore();d.restore();return l}_getCombinedScales(){const e=new Float32Array(2);Util.singularValueDecompose2dScale(this.matrix,e);const[t,i]=e;Util.singularValueDecompose2dScale(this.baseTransform,e);return[t*e[0],i*e[1]]}drawPattern(e,t,i=!1,[a,s],n){const[r,o,l,d]=this.bbox,c=e.dependencyTracker;c&&(e.dependencyTracker=new CanvasNestedDependencyTracker(c,n));e.save();i?e.ctx.clip(t,"evenodd"):e.ctx.clip(t);e.ctx.setTransform(...this.patternBaseMatrix);e.ctx.translate(a*this.xstep,s*this.ystep);if(this.needsIsolation||1!==e.ctx.globalAlpha||"source-over"!==e.ctx.globalCompositeOperation||e.inSMaskMode){const t=l-r,i=d-o,[a,s]=this._getCombinedScales(),c=this.getSizeAndScale(t,this.ctx.canvas.width,a),h=this.getSizeAndScale(i,this.ctx.canvas.height,s),u=this._renderTileCanvas(e,n,c,h);e.ctx.drawImage(u.canvas,r,o,t,i);e.canvasFactory.destroy(u)}else{this.setFillAndStrokeStyleToContext(e,this.paintType,this.color);this.clipBbox(e,r,o,l,d);e.baseTransformStack.push(e.baseTransform);e.baseTransform=getCurrentTransform(e.ctx);e.executeOperatorList(this.operatorList);e.baseTransform=e.baseTransformStack.pop()}e.restore();c&&(e.dependencyTracker=c)}createPatternCanvas(e,t){const[i,a,s,n]=this.bbox,r=s-i,o=n-a;let{xstep:l,ystep:d}=this;l=Math.abs(l);d=Math.abs(d);info("TilingType: "+this.tilingType);const[c,h]=this._getCombinedScales();let u=r,_=o,p=!1,g=!1;Math.ceil(l*c)>=Math.ceil(r*c)?u=l:p=!0;Math.ceil(d*h)>=Math.ceil(o*h)?_=d:g=!0;const m=this.getSizeAndScale(u,this.ctx.canvas.width,c),f=this.getSizeAndScale(_,this.ctx.canvas.height,h),v=this._renderTileCanvas(e,t,m,f);if(p||g){const t=v.canvas;p&&(u=l);g&&(_=d);const s=this.getSizeAndScale(u,this.ctx.canvas.width,c),n=this.getSizeAndScale(_,this.ctx.canvas.height,h),m=s.size,f=n.size,P=e.canvasFactory.create(m,f),w=P.context,F=p?Math.floor(r/l):0,b=g?Math.floor(o/d):0;for(let e=0;e<=F;e++)for(let i=0;i<=b;i++)w.drawImage(t,m*e,f*i,m,f,0,0,m,f);e.canvasFactory.destroy(v);return{canvas:P.canvas,canvasEntry:P,scaleX:s.scale,scaleY:n.scale,offsetX:i,offsetY:a}}return{canvas:v.canvas,canvasEntry:v,scaleX:m.scale,scaleY:f.scale,offsetX:i,offsetY:a}}getSizeAndScale(e,t,i){const a=Math.max(TilingPattern.MAX_PATTERN_SIZE,t);let s=Math.ceil(e*i);s>=a?s=a:i=s/e;return{scale:i,size:s}}clipBbox(e,t,i,a,s){const n=a-t,r=s-i,o=new Path2D;o.rect(t,i,n,r);Util.axialAlignedBoundingBox([t,i,a,s],getCurrentTransform(e.ctx),e.current.minMax);e.ctx.clip(o);e.current.updateClipFromPath()}setFillAndStrokeStyleToContext(e,t,i){const a=e.ctx,s=e.current;s.patternFill=s.patternStroke=!1;switch(t){case Ns:const{fillStyle:e,strokeStyle:n}=this.ctx;a.fillStyle=s.fillColor=e;a.strokeStyle=s.strokeColor=n;break;case Rs:a.fillStyle=a.strokeStyle=i;s.fillColor=s.strokeColor=i;break;default:throw new FormatError(`Unsupported paint type: ${t}`)}}isModifyingCurrentTransform(){return!1}getPattern(e,t,i,a,s){const n=a!==Ls?Util.transform(i,this.patternBaseMatrix):i,r=this.createPatternCanvas(t,s);let o=new DOMMatrix(n);o=o.translate(r.offsetX,r.offsetY);o=o.scale(1/r.scaleX,1/r.scaleY);const l=e.createPattern(r.canvas,"repeat");t.canvasFactory.destroy(r.canvasEntry);l.setTransform(o);return l}}pattern_helper_defineProperty(TilingPattern,"MAX_PATTERN_SIZE",3e3);function canvas_classPrivateFieldInitSpec(e,t,i){canvas_checkPrivateRedeclaration(e,t),t.set(e,i)}function canvas_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function canvas_classPrivateFieldSet(e,t,i){return e.set(canvas_assertClassBrand(e,t),i),i}function canvas_classPrivateFieldGet(e,t){return e.get(canvas_assertClassBrand(e,t))}function canvas_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function canvas_defineProperty(e,t,i){return(t=function canvas_toPropertyKey(e){var t=function canvas_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const Os=16,Ws=new DOMMatrix,js=new Float32Array(2);function mirrorContextOperations(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");const i=new Map;for(const a of["save","restore","rotate","scale","translate","transform","setTransform","resetTransform","clip","moveTo","lineTo","bezierCurveTo","quadraticCurveTo","arc","arcTo","ellipse","rect","roundRect","closePath","beginPath"]){const s=e[a];if("function"==typeof s&&"function"==typeof t[a]){i.set(a,s);e[a]=function(...e){t[a](...e);return s.apply(this,e)}}}e._removeMirroring=()=>{for(const[t,a]of i)e[t]=a;delete e._removeMirroring}}function drawImageAtIntegerCoords(e,t,i,a,s,n,r,o,l,d){const[c,h,u,_,p,g]=getCurrentTransform(e);if(0===h&&0===u){const m=r*c+p,f=Math.round(m),v=o*_+g,P=Math.round(v),w=(r+l)*c+p,F=Math.abs(Math.round(w)-f)||1,b=(o+d)*_+g,y=Math.abs(Math.round(b)-P)||1;e.setTransform(Math.sign(c),0,0,Math.sign(_),f,P);e.drawImage(t,i,a,s,n,0,0,F,y);e.setTransform(c,h,u,_,p,g);return[F,y]}if(0===c&&0===_){const m=o*u+p,f=Math.round(m),v=r*h+g,P=Math.round(v),w=(o+d)*u+p,F=Math.abs(Math.round(w)-f)||1,b=(r+l)*h+g,y=Math.abs(Math.round(b)-P)||1;e.setTransform(0,Math.sign(h),Math.sign(u),0,f,P);e.drawImage(t,i,a,s,n,0,0,y,F);e.setTransform(c,h,u,_,p,g);return[y,F]}e.drawImage(t,i,a,s,n,r,o,l,d);return[Math.hypot(c,h)*l,Math.hypot(u,_)*d]}class CanvasExtraState{constructor(e,t){canvas_defineProperty(this,"alphaIsShape",!1);canvas_defineProperty(this,"fontSize",0);canvas_defineProperty(this,"fontSizeScale",1);canvas_defineProperty(this,"textMatrix",null);canvas_defineProperty(this,"textMatrixScale",1);canvas_defineProperty(this,"fontMatrix",s);canvas_defineProperty(this,"leading",0);canvas_defineProperty(this,"x",0);canvas_defineProperty(this,"y",0);canvas_defineProperty(this,"lineX",0);canvas_defineProperty(this,"lineY",0);canvas_defineProperty(this,"charSpacing",0);canvas_defineProperty(this,"wordSpacing",0);canvas_defineProperty(this,"textHScale",1);canvas_defineProperty(this,"textRenderingMode",w);canvas_defineProperty(this,"textRise",0);canvas_defineProperty(this,"fillColor","#000000");canvas_defineProperty(this,"strokeColor","#000000");canvas_defineProperty(this,"tilingPatternDims",null);canvas_defineProperty(this,"patternFill",!1);canvas_defineProperty(this,"patternStroke",!1);canvas_defineProperty(this,"fillAlpha",1);canvas_defineProperty(this,"strokeAlpha",1);canvas_defineProperty(this,"lineWidth",1);canvas_defineProperty(this,"activeSMask",null);canvas_defineProperty(this,"transferMaps","none");canvas_defineProperty(this,"minMax",a.slice());this.clipBox=new Float32Array([0,0,e,t])}clone(){const e=Object.create(this);e.clipBox=this.clipBox.slice();e.minMax=this.minMax.slice();e.tilingPatternDims=this.tilingPatternDims?.slice();return e}getPathBoundingBox(e=Ts,t=null){const i=this.minMax.slice();if(e===Ds){t||unreachable("Stroke bounding box must include transform.");Util.singularValueDecompose2dScale(t,js);const e=js[0]*this.lineWidth/2,a=js[1]*this.lineWidth/2;i[0]-=e;i[1]-=a;i[2]+=e;i[3]+=a}return i}updateClipFromPath(){const e=Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(e){this.clipBox.set(e,0);this.minMax.set(a,0)}getClippedPathBoundingBox(e=Ts,t=null){return Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function putBinaryImageData(e,t){const{width:i,height:a,kind:s}=t,n=a%Os,r=(a-n)/Os,o=0===n?r:r+1,l=e.createImageData(i,Os);let d=0;const c=t.data,h=l.data;let u;if(s===x.GRAYSCALE_1BPP)for(u=0;u<o;u++){({srcPos:d}=convertBlackAndWhiteToRGBA({src:c,srcPos:d,dest:h,width:i,height:u<r?Os:n}));e.putImageData(l,0,u*Os)}else if(s===x.RGBA_32BPP){let t=0,a=i*Os*4;for(u=0;u<r;u++){h.set(c.subarray(d,d+a));d+=a;e.putImageData(l,0,t);t+=Os}if(u<o){a=i*n*4;h.set(c.subarray(d,d+a));e.putImageData(l,0,t)}}else{if(s!==x.RGB_24BPP)throw new Error(`bad image kind: ${s}`);for(u=0;u<o;u++){({srcPos:d}=convertRGBToRGBA({src:c,srcPos:d,dest:new Uint32Array(h.buffer),width:i,height:u<r?Os:n}));e.putImageData(l,0,u*Os)}}}function putBinaryImageMask(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}const{width:i,height:a}=t,s=a%Os,n=(a-s)/Os,r=0===s?n:n+1,o=e.createImageData(i,Os);let l=0;const d=t.data,c=o.data;for(let t=0;t<r;t++){({srcPos:l}=convertBlackAndWhiteToRGBA({src:d,srcPos:l,dest:c,width:i,height:t<n?Os:s,nonBlackColor:0}));e.putImageData(o,0,t*Os)}}function copyCtxState(e,t){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const a of i)void 0!==e[a]&&(t[a]=e[a]);if(void 0!==e.setLineDash){t.setLineDash(e.getLineDash());t.lineDashOffset=e.lineDashOffset}}function resetCtxToDefault(e){e.strokeStyle=e.fillStyle="#000000";e.fillRule="nonzero";e.globalAlpha=1;e.lineWidth=1;e.lineCap="butt";e.lineJoin="miter";e.miterLimit=10;e.globalCompositeOperation="source-over";e.font="10px sans-serif";if(void 0!==e.setLineDash){e.setLineDash([]);e.lineDashOffset=0}const{filter:t}=e;"none"!==t&&""!==t&&(e.filter="none")}function getImageSmoothingEnabled(e,t){if(t)return!0;Util.singularValueDecompose2dScale(e,js);const i=Math.fround(OutputScale.pixelRatio*PixelsPerInch.PDF_TO_CSS_UNITS);return js[0]<=i&&js[1]<=i}const Vs=["butt","round","square"],Us=["miter","round","bevel"],zs={},Hs={};var $s=new WeakMap,Ks=new WeakMap,Xs=new WeakMap,qs=new WeakMap,Ys=new WeakMap,Zs=new WeakMap,Qs=new WeakMap,Js=new WeakMap,en=new WeakMap,tn=new WeakMap,an=new WeakSet;class CanvasGraphics{constructor(e,t,i,a,s,{optionalContentConfig:n,markedContentStack:r=null},o,l,d,c){!function canvas_classPrivateMethodInitSpec(e,t){canvas_checkPrivateRedeclaration(e,t),t.add(e)}(this,an);canvas_classPrivateFieldInitSpec(this,$s,0);canvas_classPrivateFieldInitSpec(this,Ks,0);canvas_classPrivateFieldInitSpec(this,Xs,null);canvas_classPrivateFieldInitSpec(this,qs,null);canvas_classPrivateFieldInitSpec(this,Ys,null);canvas_classPrivateFieldInitSpec(this,Zs,null);canvas_classPrivateFieldInitSpec(this,Qs,1);canvas_classPrivateFieldInitSpec(this,Js,void 0);canvas_classPrivateFieldInitSpec(this,en,null);canvas_classPrivateFieldInitSpec(this,tn,[]);this.ctx=e;this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.stateStack=[];this.pendingClip=null;this.pendingEOFill=!1;this.commonObjs=t;this.objs=i;this.canvasFactory=a;this.filterFactory=s;this.groupStack=[];this.baseTransform=null;this.baseTransformStack=[];this.groupLevel=0;this.smaskStack=[];this.tempSMask=null;this.smaskGroupCanvases=[];this.smaskPreparedEntry=null;this.smaskPreparedFor=null;this.smaskPreparedOffsetX=0;this.smaskPreparedOffsetY=0;this.smaskPreparedOOBAlpha=null;this.suspendedCtx=null;this.contentVisible=!0;this.markedContentStack=r||[];this.optionalContentConfig=n;this.cachedPatterns=new Map;this.annotationCanvasMap=o;this.viewportScale=1;this.outputScaleX=1;this.outputScaleY=1;this.pageColors=l;this._cachedScaleForStroking=[-1,0];this._cachedGetSinglePixelWidth=null;this._cachedBitmapsMap=new Map;this.dependencyTracker=d??null;this.imagesTracker=c??null}getObject(e,t,i=null){if("string"==typeof t){this.dependencyTracker?.recordNamedDependency(e,t);return t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t)}return i}beginDrawing({transform:e,viewport:t,transparency:i=!1,background:a=null}){const s=this.ctx.canvas.width,n=this.ctx.canvas.height,r=this.ctx.fillStyle;this.ctx.fillStyle=a||"#ffffff";this.ctx.fillRect(0,0,s,n);this.ctx.fillStyle=r;if(i){const e=this.transparentCanvasEntry=this.canvasFactory.create(s,n);this.compositeCtx=this.ctx;({canvas:this.transparentCanvas,context:this.ctx}=e);this.ctx.save();this.ctx.transform(...getCurrentTransform(this.compositeCtx))}this.ctx.save();resetCtxToDefault(this.ctx);if(e){this.ctx.transform(...e);this.outputScaleX=e[0];this.outputScaleY=e[3]}this.ctx.transform(...t.transform);this.viewportScale=t.scale;this.baseTransform=getCurrentTransform(this.ctx)}executeOperatorList(e,t,i,a,s){const n=e.argsArray,r=e.fnArray;let o=t||0;const l=n.length;if(l===o)return o;const d=l-o>10&&"function"==typeof i,c=d?Date.now()+15:0;let h=0;const u=this.commonObjs,_=this.objs;let p,g;for(;;){if(void 0!==a){if(o===a.nextBreakPoint){a.breakIt(o,i);return o}if(a.shouldSkip(o)){if(++o===l)return o;continue}}if(!s||s(o)){p=r[o];g=n[o]??null;if(p!==T.dependency)null===g?this[p](o):this[p](o,...g);else for(const e of g){this.dependencyTracker?.recordNamedData(e,o);const t=e.startsWith("g_")?u:_;if(!t.has(e)){t.get(e,i);return o}}}o++;if(o===l)return o;if(d&&++h>10){if(Date.now()>c){i();return o}h=0}}}endDrawing(){canvas_assertClassBrand(an,this,_restoreInitialState).call(this);for(const e of this.smaskGroupCanvases)this.canvasFactory.destroy(e);this.smaskGroupCanvases.length=0;this._clearPreparedSMask();this.tempSMask=null;this.smaskStack.length=0;for(const e of canvas_classPrivateFieldGet(tn,this))canvas_assertClassBrand(an,this,_destroyKnockoutPools).call(this,e);canvas_classPrivateFieldGet(tn,this).length=0;canvas_classPrivateFieldSet(Xs,this,null);canvas_classPrivateFieldSet(qs,this,null);canvas_classPrivateFieldSet(Ys,this,null);canvas_classPrivateFieldSet(Zs,this,null);canvas_classPrivateFieldSet(Qs,this,1);canvas_classPrivateFieldSet(en,this,null);canvas_classPrivateFieldSet(Ks,this,0);canvas_classPrivateFieldSet($s,this,0);this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear();canvas_assertClassBrand(an,this,_drawFilter).call(this)}_scaleImage(e,t){const i=e.width??e.displayWidth,a=e.height??e.displayHeight,s=[];let n=Math.max(Math.hypot(t[0],t[1]),1),r=Math.max(Math.hypot(t[2],t[3]),1),o=i,l=a;for(;n>2&&o>1||r>2&&l>1;){let e=o,t=l;if(n>2&&o>1){e=Math.ceil(o/2);n/=o/e}if(r>2&&l>1){t=Math.ceil(l/2);r/=l/t}s.push({newWidth:e,newHeight:t});o=e;l=t}if(0===s.length)return{img:e,paintWidth:i,paintHeight:a,tmpCanvas:null};if(1===s.length){const{newWidth:t,newHeight:n}=s[0],r=this.canvasFactory.create(t,n);r.context.drawImage(e,0,0,i,a,0,0,t,n);return{img:r.canvas,paintWidth:t,paintHeight:n,tmpCanvas:r}}let d=this.canvasFactory.create(1,1),c=this.canvasFactory.create(1,1),h=i,u=a,_=e;for(const{newWidth:e,newHeight:t}of s){this.canvasFactory.reset(c,e,t);c.context.drawImage(_,0,0,h,u,0,0,e,t);[d,c]=[c,d];_=d.canvas;h=e;u=t}this.canvasFactory.destroy(c);return{img:d.canvas,paintWidth:h,paintHeight:u,tmpCanvas:d}}_createMaskCanvas(e,t){const i=this.ctx,{width:s,height:n}=t,r=this.current.fillColor,o=this.current.patternFill,l=getCurrentTransform(i);let d,c,h,u;if((t.bitmap||t.data)&&t.count>1){const i=t.bitmap||t.data.buffer;c=JSON.stringify(o?l:[l.slice(0,4),r]);d=this._cachedBitmapsMap.getOrInsertComputed(i,makeMap);const a=d.get(c);if(a&&!o){const t=Math.round(Math.min(l[0],l[2])+l[4]),i=Math.round(Math.min(l[1],l[3])+l[5]);this.dependencyTracker?.recordDependencies(e,Ma);return{canvas:a,offsetX:t,offsetY:i}}h=a}if(!h){u=this.canvasFactory.create(s,n);putBinaryImageMask(u.context,t)}let _=Util.transform(l,[1/s,0,0,-1/n,0,0]);_=Util.transform(_,[1,0,0,1,0,-n]);const p=a.slice();Util.axialAlignedBoundingBox([0,0,s,n],_,p);const[g,m,f,v]=p,P=Math.round(f-g)||1,w=Math.round(v-m)||1,F=this.canvasFactory.create(P,w),b=F.context,y=g,S=m;b.translate(-y,-S);b.transform(..._);let C=null;if(!h){const e=this._scaleImage(u.canvas,getCurrentTransformInverse(b));h=e.img;C=e.tmpCanvas;if(h!==u.canvas){this.canvasFactory.destroy(u);u=null}if(d&&o){d.set(c,h);C=null;u=null}}b.imageSmoothingEnabled=getImageSmoothingEnabled(getCurrentTransform(b),t.interpolate);drawImageAtIntegerCoords(b,h,0,0,h.width,h.height,0,0,s,n);C&&this.canvasFactory.destroy(C);u&&this.canvasFactory.destroy(u);b.globalCompositeOperation="source-in";const x=Util.transform(getCurrentTransformInverse(b),[1,0,0,1,-y,-S]);b.fillStyle=o?r.getPattern(i,this,x,Ts,e):r;b.fillRect(0,0,s,n);d&&!o&&d.set(c,F.canvas);this.dependencyTracker?.recordDependencies(e,Ma);return{canvas:F.canvas,canvasEntry:d&&!o?null:F,offsetX:Math.round(y),offsetY:Math.round(S)}}setLineWidth(e,t){this.dependencyTracker?.recordSimpleData("lineWidth",e);t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1);this.current.lineWidth=t;this.ctx.lineWidth=t}setLineCap(e,t){this.dependencyTracker?.recordSimpleData("lineCap",e);this.ctx.lineCap=Vs[t]}setLineJoin(e,t){this.dependencyTracker?.recordSimpleData("lineJoin",e);this.ctx.lineJoin=Us[t]}setMiterLimit(e,t){this.dependencyTracker?.recordSimpleData("miterLimit",e);this.ctx.miterLimit=t}setDash(e,t,i){this.dependencyTracker?.recordSimpleData("dash",e);const a=this.ctx;if(void 0!==a.setLineDash){a.setLineDash(t);a.lineDashOffset=i}}setRenderingIntent(e,t){}setFlatness(e,t){}setGState(e,t){for(const[i,a]of t)switch(i){case"LW":this.setLineWidth(e,a);break;case"LC":this.setLineCap(e,a);break;case"LJ":this.setLineJoin(e,a);break;case"ML":this.setMiterLimit(e,a);break;case"D":this.setDash(e,a[0],a[1]);break;case"RI":this.setRenderingIntent(e,a);break;case"FL":this.setFlatness(e,a);break;case"Font":this.setFont(e,a[0],a[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",e);this.current.strokeAlpha=a;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",e);this.ctx.globalAlpha=this.current.fillAlpha=a;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",e);this.ctx.globalCompositeOperation=a;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",e);this.current.activeSMask=a?this.tempSMask:null;this.current.activeSMask&&(this.current.activeSMask.blendMode=this.ctx.globalCompositeOperation);this.tempSMask=null;this.checkSMaskState(e);break;case"TR":this.dependencyTracker?.recordSimpleData("filter",e);this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(a)}}get inSMaskMode(){return!!this.suspendedCtx}_clearPreparedSMask(){if(this.smaskPreparedEntry){this.canvasFactory.destroy(this.smaskPreparedEntry);this.smaskPreparedEntry=null}this.smaskPreparedFor=null;this.smaskPreparedOffsetX=0;this.smaskPreparedOffsetY=0;this.smaskPreparedOOBAlpha=null}_ensurePreparedSMask(e){if(e!==this.smaskPreparedFor){this._clearPreparedSMask();this._prepareSMaskCanvas(e)}}checkSMaskState(e){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode(e):!this.current.activeSMask&&t?this.endSMaskMode():this.current.activeSMask&&t&&this._ensurePreparedSMask(this.current.activeSMask)}_prepareSMaskCanvas(e){const{canvas:t,subtype:i,backdrop:a,transferMap:s}=e,n="Luminosity"===i||"Alpha"===i&&s;if(!(n||"Luminosity"===i&&a)){this.smaskPreparedFor=e;return}let r;if("Luminosity"===i&&a){const[e,t,i]=getRGBA(a),n=Math.round(.3*e+.59*t+.11*i);r=s?.[n]??n}else r=s?.[0]??0;const{width:o,height:l}=this.ctx.canvas,d=o*l<4*(t.width*t.height),c=n?{url:"Alpha"===i?this.filterFactory.addAlphaFilter(s):this.filterFactory.addLuminosityFilter(s),subtype:i,transferMap:s}:null,h="Luminosity"===i?a:null;let u,_,p;if(d){u=this._bakeSMaskCanvas(t,e.offsetX,e.offsetY,o,l,h,c);_=0;p=0}else{u=this._bakeSMaskCanvas(t,0,0,t.width,t.height,h,c);_=e.offsetX;p=e.offsetY}this.smaskPreparedEntry=u;this.smaskPreparedFor=e;this.smaskPreparedOffsetX=_;this.smaskPreparedOffsetY=p;this.smaskPreparedOOBAlpha=d||0===r?null:r}_bakeSMaskCanvas(e,t,i,a,s,n,r){n||r||unreachable("_bakeSMaskCanvas with neither backdrop nor filter");const o=this.canvasFactory.create(a,s),l=o.context;l.drawImage(e,t,i);if(n){l.globalCompositeOperation="destination-atop";l.fillStyle=n;l.fillRect(0,0,a,s)}if(!r)return o;const d=this.canvasFactory.create(a,s),c=d.context;c.filter=r.url;const h=FeatureTest.isCanvasFilterSupported&&"none"!==c.filter&&""!==c.filter;c.drawImage(o.canvas,0,0);FeatureTest.isCanvasFilterSupported&&(c.filter="none");if(!h){const e=c.getImageData(0,0,a,s),{data:t}=e,{transferMap:i}=r;if("Luminosity"===r.subtype)for(let e=0,a=t.length;e<a;e+=4){const a=.3*t[e]+.59*t[e+1]+.11*t[e+2]+.5|0;t[e]=t[e+1]=t[e+2]=0;t[e+3]=i?.[a]??a}else for(let e=3,a=t.length;e<a;e+=4)t[e]=i[t[e]];c.putImageData(e,0,0)}this.canvasFactory.destroy(o);return d}beginSMaskMode(e){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const{width:t,height:i}=this.ctx.canvas,a=this.canvasFactory.create(t,i);this.smaskScratchCanvas=a;this.suspendedCtx=this.ctx;const s=this.ctx=a.context;s.setTransform(this.suspendedCtx.getTransform());copyCtxState(this.suspendedCtx,s);mirrorContextOperations(s,this.suspendedCtx);this._ensurePreparedSMask(this.current.activeSMask);this.setGState(e,[["BM","source-over"]])}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;this.canvasFactory.destroy(this.smaskScratchCanvas);this.smaskScratchCanvas=null;this._clearPreparedSMask()}compose(e){if(!this.current.activeSMask)return;e=e?[Math.floor(e[0]),Math.floor(e[1]),Math.ceil(e[2]),Math.ceil(e[3])]:[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,i=this.suspendedCtx,a=canvas_classPrivateFieldGet(Ks,this)>0&&i===this.ctx;this.composeSMask(a?null:i,t,this.ctx,e);if(!a){this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height);this.ctx.restore()}}composeSMask(e,t,i,a){const s=a[0],n=a[1],r=a[2]-s,o=a[3]-n;if(0===r||0===o)return;const l=this.smaskPreparedEntry;if(l){let e=s,a=n,d=r,c=o;const h=this.smaskPreparedOOBAlpha,u=null!==h;if(u){e=Math.max(s,t.offsetX);a=Math.max(n,t.offsetY);d=Math.min(s+r,t.offsetX+t.canvas.width)-e;c=Math.min(n+o,t.offsetY+t.canvas.height)-a}if(d>0&&c>0){const t=e-this.smaskPreparedOffsetX,s=a-this.smaskPreparedOffsetY;i.save();i.globalAlpha=1;i.setTransform(1,0,0,1,0,0);const n=new Path2D;n.rect(e,a,d,c);i.clip(n);i.globalCompositeOperation="destination-in";i.drawImage(l.canvas,t,s,d,c,e,a,d,c);i.restore()}u&&h<255&&this._applySMaskOOBAlpha(i,s,n,r,o,e,a,e+d,a+c,h)}else this.genericComposeSMask(t,i,r,o,s,n);if(e){e.save();e.globalAlpha=1;e.globalCompositeOperation=t.blendMode||"source-over";e.setTransform(1,0,0,1,0,0);e.drawImage(i.canvas,s,n,r,o,s,n,r,o);e.restore()}}_applySMaskOOBAlpha(e,t,i,a,s,n,r,o,l,d){const c=n<o&&r<l;if(c&&n===t&&r===i&&o===t+a&&l===i+s)return;const h=new Path2D;h.rect(t,i,a,s);c&&h.rect(n,r,o-n,l-r);e.save();e.globalAlpha=d/255;e.setTransform(1,0,0,1,0,0);e.clip(h,"evenodd");e.globalCompositeOperation="destination-in";e.fillStyle="#000000";e.fillRect(t,i,a,s);e.restore()}genericComposeSMask(e,t,i,a,s,n){const{context:r,offsetX:o,offsetY:l}=e;t.save();t.globalAlpha=1;t.setTransform(1,0,0,1,0,0);const d=new Path2D;d.rect(s,n,i,a);t.clip(d);t.globalCompositeOperation="destination-in";t.drawImage(r.canvas,s-o,n-l,i,a,s,n,i,a);t.restore()}save(e){this.inSMaskMode&©CtxState(this.ctx,this.suspendedCtx);this.ctx.save();const t=this.current;this.stateStack.push(t);this.current=t.clone();this.dependencyTracker?.save(e)}restore(e){this.dependencyTracker?.restore(e);if(0!==this.stateStack.length){this.current=this.stateStack.pop();this.ctx.restore();if(this.inSMaskMode){copyCtxState(this.suspendedCtx,this.ctx);this.ctx.setTransform(this.suspendedCtx.getTransform())}this.checkSMaskState(e);this.pendingClip=null;this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null}else this.inSMaskMode&&this.endSMaskMode()}transform(e,t,i,a,s,n,r){this.dependencyTracker?.recordIncrementalData("transform",e);this.ctx.transform(t,i,a,s,n,r);this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null}constructPath(e,t,i,a){let[s]=i;if(!a){s||=i[0]=new Path2D;t!==T.stroke&&t!==T.closeStroke&&(this.current.tilingPatternDims=null);this[t](e,s);return}if(null!==this.dependencyTracker){const i=t===T.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(e).recordBBox(e,this.ctx,a[0]-i,a[2]+i,a[1]-i,a[3]+i).recordDependencies(e,["transform"])}s instanceof Path2D||(s=i[0]=makePathFromDrawOPS(s));Util.axialAlignedBoundingBox(a,getCurrentTransform(this.ctx),this.current.minMax);const n=this.current.tilingPatternDims;if(n&&t!==T.stroke&&t!==T.closeStroke&&this.current.fillColor instanceof TilingPattern){const e=Util.intersect(this.current.clipBox,this.current.minMax);e?this.current.fillColor.updatePatternDims(e,n):this.current.tilingPatternDims=null}this[t](e,s);this._pathStartIdx=e}closePath(e){this.ctx.closePath()}stroke(e,t,i=!0){const a=i&&canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,this.current.strokeAlpha),s=this.ctx,n=this.current.strokeColor;s.globalAlpha=this.current.strokeAlpha;if(this.contentVisible)if("object"==typeof n&&n?.getPattern){const i=n.isModifyingCurrentTransform()?s.getTransform():null;s.save();s.strokeStyle=n.getPattern(s,this,getCurrentTransformInverse(s),Ds,e);if(i){const e=new Path2D;e.addPath(t,s.getTransform().invertSelf().multiplySelf(i));t=e}this.rescaleAndStroke(t,!1);s.restore()}else this.rescaleAndStroke(t,!0);this.dependencyTracker?.recordDependencies(e,xa);i&&this.consumePath(e,t,this.current.getClippedPathBoundingBox(Ds,getCurrentTransform(this.ctx)));s.globalAlpha=this.current.fillAlpha;canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,a)}closeStroke(e,t){this.stroke(e,t)}fill(e,t,i=!0){const a=i&&canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx,n=this.current.fillColor,r=this.current.patternFill;let o=!1;const l=this.current.getClippedPathBoundingBox();this.dependencyTracker?.recordDependencies(e,ka);if(r){const r=this.current.tilingPatternDims,d=r&&n.canSkipPatternCanvas(r);if(d){n.drawPattern(this,t,this.pendingEOFill,d,e);this.pendingEOFill=!1;i&&this.consumePath(e,t,l);this.current.tilingPatternDims=null;canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,a);return}const c=n.isModifyingCurrentTransform()?s.getTransform():null;this.dependencyTracker?.save(e);s.save();s.fillStyle=n.getPattern(s,this,getCurrentTransformInverse(s),Ts,e);if(c){const e=new Path2D;e.addPath(t,s.getTransform().invertSelf().multiplySelf(c));t=e}o=!0}if(this.contentVisible&&null!==l)if(this.pendingEOFill){s.fill(t,"evenodd");this.pendingEOFill=!1}else s.fill(t);if(o){s.restore();this.dependencyTracker?.restore(e)}i&&this.consumePath(e,t,l);canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,a)}eoFill(e,t){this.pendingEOFill=!0;this.fill(e,t)}fillStroke(e,t){const i=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,Math.min(this.current.fillAlpha,this.current.strokeAlpha));this.fill(e,t,!1);this.stroke(e,t,!1);this.consumePath(e,t);canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,i)}eoFillStroke(e,t){this.pendingEOFill=!0;this.fillStroke(e,t)}closeFillStroke(e,t){this.fillStroke(e,t)}closeEOFillStroke(e,t){this.pendingEOFill=!0;this.fillStroke(e,t)}endPath(e,t){this.consumePath(e,t)}rawFillPath(e,t){const i=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,this.current.fillAlpha);this.ctx.fill(t);this.dependencyTracker?.recordDependencies(e,Aa).recordOperation(e);canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,i)}clip(e){this.dependencyTracker?.recordFutureForcedDependency("clipMode",e);this.pendingClip=zs}eoClip(e){this.dependencyTracker?.recordFutureForcedDependency("clipMode",e);this.pendingClip=Hs}beginText(e){this.current.textMatrix=null;this.current.textMatrixScale=1;this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0;this.dependencyTracker?.recordOpenMarker(e).resetIncrementalData("sameLineText").resetIncrementalData("moveText",e)}endText(e){const t=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;void 0!==t&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",e);i.recordCloseMarker(e)}if(void 0!==t){const e=new Path2D,a=i.getTransform().invertSelf();for(const{transform:i,x:s,y:n,fontSize:r,path:o}of t)o&&e.addPath(o,new DOMMatrix(i).preMultiplySelf(a).translate(s,n).scale(r,-r));i.clip(e)}delete this.pendingTextPaths}setCharSpacing(e,t){this.dependencyTracker?.recordSimpleData("charSpacing",e);this.current.charSpacing=t}setWordSpacing(e,t){this.dependencyTracker?.recordSimpleData("wordSpacing",e);this.current.wordSpacing=t}setHScale(e,t){this.dependencyTracker?.recordSimpleData("hScale",e);this.current.textHScale=t/100}setLeading(e,t){this.dependencyTracker?.recordSimpleData("leading",e);this.current.leading=-t}setFont(e,t,i){this.dependencyTracker?.recordSimpleData("font",e).recordSimpleDataFromNamed("fontObj",t,e);const a=this.commonObjs.get(t),n=this.current;if(!a)throw new Error(`Can't find font for ${t}`);n.fontMatrix=a.fontMatrix||s;0!==n.fontMatrix[0]&&0!==n.fontMatrix[3]||warn("Invalid font matrix for font "+t);if(i<0){i=-i;n.fontDirection=-1}else n.fontDirection=1;this.current.font=a;this.current.fontSize=i;if(a.isType3Font)return;const r=a.loadedName||"sans-serif",o=a.systemFontInfo?.css||`"${r}", ${a.fallbackName}`;let l="normal";a.black?l="900":a.bold&&(l="bold");const d=a.italic?"italic":"normal",c=MathClamp(i,16,100);this.current.fontSizeScale=i/c;this.ctx.font=`${d} ${l} ${c}px ${o}`}setTextRenderingMode(e,t){this.dependencyTracker?.recordSimpleData("textRenderingMode",e);this.current.textRenderingMode=t}setTextRise(e,t){this.dependencyTracker?.recordSimpleData("textRise",e);this.current.textRise=t}moveText(e,t,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",e);this.current.x=this.current.lineX+=t;this.current.y=this.current.lineY+=i}setLeadingMoveText(e,t,i){this.setLeading(e,-i);this.moveText(e,t,i)}setTextMatrix(e,t){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",e);const{current:i}=this;i.textMatrix=t;i.textMatrixScale=Math.hypot(t[0],t[1]);i.x=i.lineX=0;i.y=i.lineY=0}nextLine(e){this.moveText(e,0,this.current.leading);this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??e)}paintChar(e,t,i,a,s,n){const r=this.ctx,o=this.current,l=o.font,d=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,h=d&S,u=!!(d&C),_=o.patternFill&&!l.missingFile,p=o.patternStroke&&!l.missingFile;let g;(l.disableFontFace||u||_||p)&&!l.missingFile&&(g=l.getPathGenerator(this.commonObjs,t));if(g&&(l.disableFontFace||_||p)){r.save();r.translate(i,a);r.scale(c,-c);this.dependencyTracker?.recordCharacterBBox(e,r,l);let t;if(h===w||h===b)if(s){t=r.getTransform();r.setTransform(...s);const e=canvas_assertClassBrand(an,this,_getScaledPath).call(this,g,t,s);r.fill(e)}else r.fill(g);if(h===F||h===b)if(n){t||=r.getTransform();r.setTransform(...n);const{a:e,b:i,c:a,d:s}=t,o=Util.inverseTransform(n),l=Util.transform([e,i,a,s,0,0],o);Util.singularValueDecompose2dScale(l,js);r.lineWidth*=Math.max(js[0],js[1])/c;r.stroke(canvas_assertClassBrand(an,this,_getScaledPath).call(this,g,t,n))}else{r.lineWidth/=c;r.stroke(g)}r.restore()}else{if(h===w||h===b){r.fillText(t,i,a);this.dependencyTracker?.recordCharacterBBox(e,r,l,c,i,a,()=>r.measureText(t))}if(h===F||h===b){this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(e,r,l,c,i,a,()=>r.measureText(t)).recordDependencies(e,xa);r.strokeText(t,i,a)}}if(u){(this.pendingTextPaths||=[]).push({transform:getCurrentTransform(r),x:i,y:a,fontSize:c,path:g});this.dependencyTracker?.recordCharacterBBox(e,r,l,c,i,a)}}get isFontSubpixelAAEnabled(){const e=this.canvasFactory.create(10,10),t=e.context;t.scale(1.5,1);t.fillText("I",0,10);const i=t.getImageData(0,0,10,10).data;this.canvasFactory.destroy(e);let a=!1;for(let e=3;e<i.length;e+=4)if(i[e]>0&&i[e]<255){a=!0;break}return shadow(this,"isFontSubpixelAAEnabled",a)}showText(e,t){if(this.dependencyTracker){this.dependencyTracker.recordDependencies(e,Ga).resetBBox(e);this.current.textRenderingMode&C&&this.dependencyTracker.recordFutureForcedDependency("textClip",e).inheritPendingDependenciesAsFutureForcedDependencies()}const i=this.current,a=i.font;if(a.isType3Font){const a=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,i.fillAlpha);this.showType3Text(e,t);this.dependencyTracker?.recordShowTextOperation(e);canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,a);return}const s=i.fontSize;if(0===s){this.dependencyTracker?.recordOperation(e);return}const n=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,i.fillAlpha),r=this.ctx,o=i.fontSizeScale,l=i.charSpacing,d=i.wordSpacing,c=i.fontDirection,h=i.textHScale*c,u=t.length,_=a.vertical,p=_?1:-1,g=a.defaultVMetrics,m=s*i.fontMatrix[0],f=i.textRenderingMode===w&&!a.disableFontFace&&!i.patternFill;r.save();i.textMatrix&&r.transform(...i.textMatrix);r.translate(i.x,i.y+i.textRise);c>0?r.scale(h,-1):r.scale(h,1);let v,P;const y=i.textRenderingMode&S,x=y===w||y===b,k=y===F||y===b;let E=i.lineWidth;const A=i.textMatrixScale;0===A||0===E?k&&(E=this.getSinglePixelWidth()):E/=A;if(1!==o){r.scale(o,o);E/=o}r.lineWidth=E;if(x&&i.patternFill){r.save();const t=i.fillColor.getPattern(r,this,getCurrentTransformInverse(r),Ts,e);v=getCurrentTransform(r);r.restore();r.fillStyle=t}if(k&&i.patternStroke){r.save();const t=i.strokeColor.getPattern(r,this,getCurrentTransformInverse(r),Ds,e);P=getCurrentTransform(r);r.restore();r.strokeStyle=t}if(a.isInvalidPDFjsFont){const a=[];let s=0;for(const e of t){a.push(e.unicode);s+=e.width}const o=a.join("");r.fillText(o,0,0);if(null!==this.dependencyTracker){const t=r.measureText(o);this.dependencyTracker.recordBBox(e,this.ctx,-t.actualBoundingBoxLeft,t.actualBoundingBoxRight,-t.actualBoundingBoxAscent,t.actualBoundingBoxDescent).recordShowTextOperation(e)}i.x+=s*m*h;r.restore();this.compose();canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,n);return}let G,B=0;for(G=0;G<u;++G){const i=t[G];if("number"==typeof i){B+=p*i*s/1e3;continue}let n=!1;const h=(i.isSpace?d:0)+l,u=i.fontChar,w=i.accent;let F,b,y,S=i.width;if(_){const e=i.vmetric||g,t=-(i.vmetric?e[1]:.5*S)*m,a=e[2]*m;S=e?-e[0]:S;F=t/o;b=(B+a)/o}else{F=B/o;b=0}if(a.remeasure&&S>0){y=r.measureText(u);const e=1e3*y.width/s*o;if(S<e&&this.isFontSubpixelAAEnabled){const t=S/e;n=!0;r.save();r.scale(t,1);F/=t}else S!==e&&(F+=(S-e)/2e3*s/o)}if(this.contentVisible&&(i.isInFont||a.missingFile))if(f&&!w){r.fillText(u,F,b);this.dependencyTracker?.recordCharacterBBox(e,r,y?{bbox:null}:a,s/o,F,b,()=>y??r.measureText(u))}else{this.paintChar(e,u,F,b,v,P);if(w){const t=F+s*w.offset.x/o,i=b-s*w.offset.y/o;this.paintChar(e,w.fontChar,t,i,v,P)}}B+=_?S*m-h*c:S*m+h*c;n&&r.restore()}_?i.y-=B:i.x+=B*h;r.restore();this.compose();this.dependencyTracker?.recordShowTextOperation(e);canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,n)}showType3Text(e,t){const i=this.ctx,a=this.current,n=a.font,r=a.fontSize,o=a.fontDirection,l=n.vertical?1:-1,d=a.charSpacing,c=a.wordSpacing,h=a.textHScale*o,u=a.fontMatrix||s,_=t.length;let p,g,m,f;if(a.textRenderingMode===y||0===r)return;this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null;i.save();a.textMatrix&&i.transform(...a.textMatrix);i.translate(a.x,a.y+a.textRise);i.scale(h,o);const v=this.dependencyTracker;this.dependencyTracker=v?new CanvasNestedDependencyTracker(v,e):null;for(p=0;p<_;++p){g=t[p];if("number"==typeof g){f=l*g*r/1e3;this.ctx.translate(f,0);a.x+=f*h;continue}const e=(g.isSpace?c:0)+d,s=n.charProcOperatorList[g.operatorListId];if(s){if(this.contentVisible){this.save();if(s.fnArray[0]===T.setCharWidth){a.fillAlpha=a.strokeAlpha=1;i.globalAlpha=1}i.scale(r,r);i.transform(...u);this.executeOperatorList(s);this.restore()}}else warn(`Type3 character "${g.operatorListId}" is not available.`);const o=[g.width,0];Util.applyTransform(o,u);m=o[0]*r+e;i.translate(m,0);a.x+=m*h}i.restore();v&&(this.dependencyTracker=v)}setCharWidth(e,t,i){}setCharWidthAndBounds(e,t,i,a,s,n,r){const o=new Path2D;o.rect(a,s,n-a,r-s);this.ctx.clip(o);this.dependencyTracker?.recordBBox(e,this.ctx,a,n,s,r).recordClipBox(e,this.ctx,a,n,s,r);this.endPath(e)}getColorN_Pattern(e,t){let i;if("TilingPattern"===t[0]){const e=this.baseTransform||getCurrentTransform(this.ctx),a={createCanvasGraphics:(e,t)=>new CanvasGraphics(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new CanvasNestedDependencyTracker(this.dependencyTracker,t,!0):null)};i=new TilingPattern(t,this.ctx,a,e)}else i=this._getPattern(e,t[1],t[2]);return i}setStrokeColorN(e,...t){this.dependencyTracker?.recordSimpleData("strokeColor",e);this.current.strokeColor=this.getColorN_Pattern(e,t);this.current.patternStroke=!0}setFillColorN(e,...t){this.dependencyTracker?.recordSimpleData("fillColor",e);const i=this.current.fillColor=this.getColorN_Pattern(e,t);this.current.patternFill=!0;this.current.tilingPatternDims=i instanceof TilingPattern?[0,0,0,0]:null}setStrokeRGBColor(e,t){this.dependencyTracker?.recordSimpleData("strokeColor",e);this.ctx.strokeStyle=this.current.strokeColor=t;this.current.patternStroke=!1}setStrokeTransparent(e){this.dependencyTracker?.recordSimpleData("strokeColor",e);this.ctx.strokeStyle=this.current.strokeColor="transparent";this.current.patternStroke=!1}setFillRGBColor(e,t){this.dependencyTracker?.recordSimpleData("fillColor",e);this.ctx.fillStyle=this.current.fillColor=t;this.current.patternFill=!1;this.current.tilingPatternDims=null}setFillTransparent(e){this.dependencyTracker?.recordSimpleData("fillColor",e);this.ctx.fillStyle=this.current.fillColor="transparent";this.current.patternFill=!1;this.current.tilingPatternDims=null}_getPattern(e,t,i=null){const a=this.cachedPatterns.getOrInsertComputed(t,()=>function getShadingPattern(e){switch(e[0]){case"RadialAxial":return new RadialAxialShadingPattern(e);case"Mesh":return new MeshShadingPattern(e);case"Dummy":return new DummyShadingPattern}throw new Error(`Unknown IR type: ${e[0]}`)}(this.getObject(e,t)));i&&(a.matrix=i);return a}shadingFill(e,t){if(!this.contentVisible)return;const i=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx;this.save(e);const n=this._getPattern(e,t);s.fillStyle=n.getPattern(s,this,getCurrentTransformInverse(s),Ls,e);const r=getCurrentTransformInverse(s);if(r){const{width:e,height:t}=s.canvas,i=a.slice();Util.axialAlignedBoundingBox([0,0,e,t],r,i);const[n,o,l,d]=i;this.ctx.fillRect(n,o,l-n,d-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(e).recordFullPageBBox(e).recordDependencies(e,Ba).recordDependencies(e,ka).recordOperation(e);this.compose(this.current.getClippedPathBoundingBox());this.restore(e);canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,i)}beginInlineImage(){unreachable("Should not call beginInlineImage")}beginImageData(){unreachable("Should not call beginImageData")}paintFormXObjectBegin(e,t,i){if(this.contentVisible){this.save(e);this.baseTransformStack.push(this.baseTransform);t&&this.transform(e,...t);this.baseTransform=getCurrentTransform(this.ctx);if(i){Util.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[t,a,s,n]=i,r=new Path2D;r.rect(t,a,s-t,n-a);this.ctx.clip(r);this.dependencyTracker?.recordClipBox(e,this.ctx,t,s,a,n);this.endPath(e)}}}paintFormXObjectEnd(e){if(this.contentVisible){this.restore(e);this.baseTransform=this.baseTransformStack.pop()}}beginGroup(e,t){if(!this.contentVisible)return;this.save(e);const{inSMaskMode:i}=this;if(i){this.endSMaskMode();this.current.activeSMask=null}const s=this.ctx;if(!(t.needsIsolation&&(t.isolated||t.hasSoftMask)||t.knockout||t.isGray||0!==canvas_classPrivateFieldGet($s,this)||1!==s.globalAlpha||"source-over"!==s.globalCompositeOperation||i)){if(t.bbox){let e=new Path2D;const[i,a,n,r]=t.bbox;e.rect(i,a,n-i,r-a);if(t.matrix){const i=new Path2D;i.addPath(e,new DOMMatrix(t.matrix));e=i}s.clip(e)}this.groupStack.push(null);canvas_classPrivateFieldGet(tn,this).push(null);this.groupLevel++;return}t.isolated||t.knockout||0!==canvas_classPrivateFieldGet($s,this)||info("TODO: Fully support non-isolated non-knockout groups.");const n=getCurrentTransform(s);t.matrix&&s.transform(...t.matrix);const r=[0,0,s.canvas.width,s.canvas.height];let o;if(t.bbox){o=a.slice();Util.axialAlignedBoundingBox(t.bbox,getCurrentTransform(s),o);o=Util.intersect(o,r)||[0,0,0,0]}else o=r;const l=Math.floor(o[0]),d=Math.floor(o[1]),c=Math.max(Math.ceil(o[2])-l,1),h=Math.max(Math.ceil(o[3])-d,1);this.current.startNewPathAndClipBox([0,0,c,h]);const u=this.canvasFactory.create(c,h);t.smask&&this.smaskGroupCanvases.push(u);const _=u.context,p=t.knockout&&!t.isolated?s:null,g=!t.isolated&&!t.knockout&&!t.smask&&t.needsIsolation&&canvas_classPrivateFieldGet($s,this)>0,m=t.knockout?this.canvasFactory.create(c,h):null,f=canvas_classPrivateFieldGet($s,this);if(t.knockout){var v;canvas_classPrivateFieldSet($s,this,(v=canvas_classPrivateFieldGet($s,this),v++,v))}else canvas_classPrivateFieldSet($s,this,0);_.translate(-l,-d);_.transform(...n);const P=!t.isolated&&!t.smask&&t.needsIsolation,w=P&&!i&&0===f&&!t.knockout&&!t.isGray&&t.hasSoftMask&&1===s.globalAlpha&&"source-over"===s.globalCompositeOperation&&"none"===this.current.transferMaps;if(P&&(i||w)){_.save();_.setTransform(1,0,0,1,0,0);_.drawImage(s.canvas,-l,-d);_.restore()}if(t.bbox){let e=new Path2D;const[i,a,s,n]=t.bbox;e.rect(i,a,s-i,n-a);if(t.matrix){const i=new Path2D;i.addPath(e,new DOMMatrix(t.matrix));e=i}_.clip(e)}t.smask&&this.smaskStack.push({canvas:u.canvas,context:_,offsetX:l,offsetY:d,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null});if(!t.smask||this.dependencyTracker){s.setTransform(1,0,0,1,0,0);s.translate(l,d);s.save()}copyCtxState(s,_);this.ctx=_;this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s);this.setGState(e,[["BM","source-over"],["ca",1],["CA",1],["TR",null]]);this.groupStack.push(s);canvas_classPrivateFieldGet(tn,this).push({backdropCtx:p,savedKnockoutLevel:f,offsetX:l,offsetY:d,hasInnerBackdrop:g,replaceBackdrop:w,knockoutMaskEntry:m,knockoutTempEntry:null,knockoutBackdropEntry:null});this.groupLevel++}endGroup(e,t){if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,s=this.groupStack.pop(),n=canvas_classPrivateFieldGet(tn,this).pop();n&&canvas_classPrivateFieldSet($s,this,n.savedKnockoutLevel);if(null!==s){t.isGray&&canvas_assertClassBrand(an,this,_convertGroupToGray).call(this,i);this.ctx=s;this.ctx.imageSmoothingEnabled=!1;this.dependencyTracker?.popBaseTransform();if(t.smask){this.tempSMask=this.smaskStack.pop();this.restore(e);if(this.dependencyTracker){this.ctx.restore();this.inSMaskMode&&this.ctx.setTransform(this.suspendedCtx.getTransform())}canvas_assertClassBrand(an,this,_destroyKnockoutPools).call(this,n)}else{this.ctx.restore();const t=getCurrentTransform(this.ctx);this.restore(e);this.ctx.save();this.ctx.setTransform(...t);const r=a.slice();Util.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],t,r);const o=canvas_classPrivateFieldGet(tn,this).at(-1);if(canvas_classPrivateFieldGet($s,this)>0)if(n.hasInnerBackdrop){const{width:e,height:a}=i.canvas,r=this.canvasFactory.create(e,a),o=r.context;o.drawImage(s.canvas,n.offsetX,n.offsetY,e,a,0,0,e,a);o.globalCompositeOperation="source-over";o.drawImage(i.canvas,0,0);const l=canvas_assertClassBrand(an,this,_createKnockoutMaskCanvas).call(this,i.canvas);o.globalCompositeOperation="destination-in";o.drawImage(l.canvas,0,0);const d=this.ctx.globalCompositeOperation,c=this.ctx.globalAlpha,h=this.ctx.filter;this.ctx.save();this.ctx.setTransform(...t);this.ctx.globalAlpha=1;FeatureTest.isCanvasFilterSupported&&(this.ctx.filter="none");this.ctx.globalCompositeOperation="destination-out";this.ctx.drawImage(l.canvas,0,0);this.ctx.globalCompositeOperation=d;this.ctx.globalAlpha=c;FeatureTest.isCanvasFilterSupported&&(this.ctx.filter=h??"none");this.ctx.drawImage(r.canvas,0,0);this.ctx.restore();this.canvasFactory.destroy(l);this.canvasFactory.destroy(r)}else{const e=o?.backdropCtx??null;canvas_assertClassBrand(an,this,_compositeKnockoutSurface).call(this,this.ctx,i.canvas,{backdropCanvas:e?.canvas??null,destTransform:t,backdropOffset:e?[o.offsetX+n.offsetX,o.offsetY+n.offsetY]:[0,0],sourceAlpha:this.ctx.globalAlpha,sourceFilter:this.ctx.filter})}else{if(n.replaceBackdrop){const e=new Path2D;e.rect(0,0,i.canvas.width,i.canvas.height);this.ctx.clip(e);this.ctx.globalCompositeOperation="copy"}this.ctx.drawImage(i.canvas,0,0)}this.ctx.restore();this.canvasFactory.destroy({canvas:i.canvas,context:i});canvas_assertClassBrand(an,this,_destroyKnockoutPools).call(this,n);this.compose(r)}}else this.restore(e)}beginAnnotation(e,t,i,a,s,n,r){canvas_assertClassBrand(an,this,_restoreInitialState).call(this);resetCtxToDefault(this.ctx);this.ctx.save();this.save(e);this.baseTransform&&this.ctx.setTransform(...this.baseTransform);if(i){const s=i[2]-i[0],o=i[3]-i[1];if(n&&this.annotationCanvasMap){(a=a.slice())[4]-=i[0];a[5]-=i[1];(i=i.slice())[0]=i[1]=0;i[2]=s;i[3]=o;Util.singularValueDecompose2dScale(getCurrentTransform(this.ctx),js);const{viewportScale:e}=this,n=Math.ceil(s*this.outputScaleX*e),l=Math.ceil(o*this.outputScaleY*e);this.annotationCanvas=this.canvasFactory.create(n,l);const{canvas:d,context:c}=this.annotationCanvas;if(r){const e=this.annotationCanvasMap.getOrInsertComputed(t,makeArr);d.setAttribute("data-canvas-name",r);const i=e.findIndex(e=>e.getAttribute("data-canvas-name")===r);-1===i?e.push(d):e[i]=d}else this.annotationCanvasMap.set(t,d);this.annotationCanvas.savedCtx=this.ctx;this.ctx=c;this.ctx.save();this.ctx.setTransform(js[0],0,0,-js[1],0,o*js[1]);resetCtxToDefault(this.ctx)}else{resetCtxToDefault(this.ctx);this.endPath(e);const t=new Path2D;t.rect(i[0],i[1],s,o);this.ctx.clip(t)}}this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.baseTransformStack.push(this.baseTransform);this.transform(e,...a);this.transform(e,...s);this.baseTransform=getCurrentTransform(this.ctx)}endAnnotation(e){if(this.annotationCanvas){this.ctx.restore();canvas_assertClassBrand(an,this,_drawFilter).call(this);this.ctx=this.annotationCanvas.savedCtx;delete this.annotationCanvas.savedCtx;delete this.annotationCanvas}this.baseTransform=this.baseTransformStack.pop()}paintImageMaskXObject(e,t){if(!this.contentVisible)return;const i=t.count;(t=this.getObject(e,t.data,t)).count=i;const a=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx,n=this._createMaskCanvas(e,t),r=n.canvas;s.save();s.setTransform(1,0,0,1,0,0);s.drawImage(r,n.offsetX,n.offsetY);this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,n.offsetX,n.offsetX+r.width,n.offsetY,n.offsetY+r.height).recordOperation(e);s.restore();n.canvasEntry&&this.canvasFactory.destroy(n.canvasEntry);this.compose();canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,a)}paintImageMaskXObjectRepeat(e,t,i,a=0,s=0,n,r){if(!this.contentVisible)return;t=this.getObject(e,t.data,t);const o=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,this.current.fillAlpha),l=this.ctx;l.save();const d=getCurrentTransform(l);l.transform(i,a,s,n,0,0);const c=this._createMaskCanvas(e,t);l.setTransform(1,0,0,1,c.offsetX-d[4],c.offsetY-d[5]);this.dependencyTracker?.resetBBox(e);for(let t=0,o=r.length;t<o;t+=2){const o=Util.transform(d,[i,a,s,n,r[t],r[t+1]]);l.drawImage(c.canvas,o[4],o[5]);this.dependencyTracker?.recordBBox(e,this.ctx,o[4],o[4]+c.canvas.width,o[5],o[5]+c.canvas.height)}l.restore();c.canvasEntry&&this.canvasFactory.destroy(c.canvasEntry);this.compose();this.dependencyTracker?.recordOperation(e);canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,o)}paintImageMaskXObjectGroup(e,t){if(!this.contentVisible)return;const i=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,this.current.fillAlpha),a=this.ctx,s=this.current.fillColor,n=this.current.patternFill;this.dependencyTracker?.resetBBox(e).recordDependencies(e,Ma);for(const i of t){const{data:t,width:r,height:o,transform:l}=i,d=this.canvasFactory.create(r,o),c=d.context;c.save();putBinaryImageMask(c,this.getObject(e,t,i));c.globalCompositeOperation="source-in";c.fillStyle=n?s.getPattern(c,this,getCurrentTransformInverse(a),Ts,e):s;c.fillRect(0,0,r,o);c.restore();a.save();a.transform(...l);a.scale(1,-1);drawImageAtIntegerCoords(a,d.canvas,0,0,r,o,0,-1,1,1);this.canvasFactory.destroy(d);this.dependencyTracker?.recordBBox(e,a,0,r,0,o);a.restore()}this.compose();this.dependencyTracker?.recordOperation(e);canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,i)}paintImageXObject(e,t){if(!this.contentVisible)return;const i=this.getObject(e,t);i?this.paintInlineImageXObject(e,i):warn("Dependent image isn't ready yet")}paintImageXObjectRepeat(e,t,i,a,s){if(!this.contentVisible)return;const n=this.getObject(e,t);if(!n){warn("Dependent image isn't ready yet");return}const r=n.width,o=n.height,l=[];for(let e=0,t=s.length;e<t;e+=2)l.push({transform:[i,0,0,a,s[e],s[e+1]],x:0,y:0,w:r,h:o});this.paintInlineImageXObjectGroup(e,n,l)}applyTransferMapsToCanvas(e){if("none"!==this.current.transferMaps){e.filter=this.current.transferMaps;e.drawImage(e.canvas,0,0);e.filter="none"}return e.canvas}applyTransferMapsToBitmap(e){if("none"===this.current.transferMaps)return{img:e.bitmap,canvasEntry:null};const{bitmap:t,width:i,height:a}=e,s=this.canvasFactory.create(i,a),n=s.context;n.filter=this.current.transferMaps;n.drawImage(t,0,0);n.filter="none";return{img:s.canvas,canvasEntry:s}}paintInlineImageXObject(e,t){if(!this.contentVisible)return;const i=t.width,a=t.height,s=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,this.current.fillAlpha),n=this.ctx;this.save(e);const{filter:r}=n;"none"!==r&&""!==r&&(n.filter="none");n.scale(1/i,-1/a);let o,l=null;if(t.bitmap){const e=this.applyTransferMapsToBitmap(t);o=e.img;l=e.canvasEntry}else{const e=this.canvasFactory.create(i,a);putBinaryImageData(e.context,t);o=this.applyTransferMapsToCanvas(e.context);l=e}const d=this._scaleImage(o,getCurrentTransformInverse(n));n.imageSmoothingEnabled=getImageSmoothingEnabled(getCurrentTransform(n),t.interpolate);if(this.dependencyTracker){this.dependencyTracker.resetBBox(e).recordBBox(e,n,0,i,-a,0).recordDependencies(e,Ea).recordOperation(e);this.imagesTracker?.record(n,i,a,this.dependencyTracker.clipBox)}drawImageAtIntegerCoords(n,d.img,0,0,d.paintWidth,d.paintHeight,0,-a,i,a);d.tmpCanvas&&this.canvasFactory.destroy(d.tmpCanvas);l&&this.canvasFactory.destroy(l);this.compose();this.restore(e);canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,s)}paintInlineImageXObjectGroup(e,t,i){if(!this.contentVisible)return;const a=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,this.current.fillAlpha),s=this.ctx;let n,r=null;if(t.bitmap)n=t.bitmap;else{const e=t.width,i=t.height,a=this.canvasFactory.create(e,i);putBinaryImageData(a.context,t);n=this.applyTransferMapsToCanvas(a.context);r=a}this.dependencyTracker?.resetBBox(e);for(const t of i){s.save();s.transform(...t.transform);s.scale(1,-1);drawImageAtIntegerCoords(s,n,t.x,t.y,t.w,t.h,0,-1,1,1);this.dependencyTracker?.recordBBox(e,s,0,1,-1,0);s.restore()}r&&this.canvasFactory.destroy(r);this.dependencyTracker?.recordOperation(e);this.compose();canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,a)}paintSolidColorImageMask(e){if(!this.contentVisible)return;const t=canvas_assertClassBrand(an,this,_beginKnockoutElement).call(this,this.current.fillAlpha);this.dependencyTracker?.resetBBox(e).recordBBox(e,this.ctx,0,1,0,1).recordDependencies(e,ka).recordOperation(e);this.ctx.fillRect(0,0,1,1);this.compose();canvas_assertClassBrand(an,this,_endKnockoutElement).call(this,t)}markPoint(e,t){}markPointProps(e,t,i){}beginMarkedContent(e,t){this.dependencyTracker?.beginMarkedContent(e);this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t,i){this.dependencyTracker?.beginMarkedContent(e);"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(e){this.dependencyTracker?.endMarkedContent(e);this.markedContentStack.pop();this.contentVisible=this.isContentVisible()}beginCompat(e){}endCompat(e){}consumePath(e,t,i){const a=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath();this.pendingClip||this.compose(i);const s=this.ctx;if(this.pendingClip){a||(this.pendingClip===Hs?s.clip(t,"evenodd"):s.clip(t));this.pendingClip=null;this.dependencyTracker?.bboxToClipBoxDropOperation(e).recordFutureForcedDependency("clipPath",e)}else this.dependencyTracker?.recordOperation(e);this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=getCurrentTransform(this.ctx);if(0===e[1]&&0===e[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const t=Math.abs(e[0]*e[3]-e[2]*e[1]),i=Math.hypot(e[0],e[2]),a=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(i,a)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:e}=this.current,{a:t,b:i,c:a,d:s}=this.ctx.getTransform();let n,r;if(0===i&&0===a){const i=Math.abs(t),a=Math.abs(s);if(i===a)if(0===e)n=r=1/i;else{const t=i*e;n=r=t<1?1/t:1}else if(0===e){n=1/i;r=1/a}else{const t=i*e,s=a*e;n=t<1?1/t:1;r=s<1?1/s:1}}else{const o=Math.abs(t*s-i*a),l=Math.hypot(t,i),d=Math.hypot(a,s);if(0===e){n=d/o;r=l/o}else{const t=e*o;n=d>t?d/t:1;r=l>t?l/t:1}}this._cachedScaleForStroking[0]=n;this._cachedScaleForStroking[1]=r}return this._cachedScaleForStroking}rescaleAndStroke(e,t){const{ctx:i,current:{lineWidth:a}}=this,[s,n]=this.getScaleForStroking();if(s===n){i.lineWidth=(a||1)*s;i.stroke(e);return}const r=i.getLineDash();t&&i.save();i.scale(s,n);Ws.a=1/s;Ws.d=1/n;const o=new Path2D;o.addPath(e,Ws);if(r.length>0){const e=Math.max(s,n);i.setLineDash(r.map(t=>t/e));i.lineDashOffset/=e}i.lineWidth=a||1;i.stroke(o);t&&i.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}function _restoreInitialState(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null;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.canvasFactory.destroy(this.transparentCanvasEntry);this.transparentCanvas=null;this.transparentCanvasEntry=null}}function _drawFilter(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){const t=this.ctx.filter;this.ctx.filter=e;this.ctx.drawImage(this.ctx.canvas,0,0);this.ctx.filter=t}}}function _createKnockoutMaskCanvas(e,t=null,i=1){const{width:a,height:s}=e,n=t??this.canvasFactory.create(a,s),r=n.context,o=(i=Math.round(255*i)/255)<1;o&&void 0===canvas_classPrivateFieldGet(Js,this)&&canvas_classPrivateFieldSet(Js,this,FeatureTest.isCanvasFilterSupported?new Map:"none");let l="none";o&&canvas_classPrivateFieldGet(Js,this)instanceof Map&&(l=canvas_classPrivateFieldGet(Js,this).getOrInsertComputed(i,()=>this.filterFactory.addKnockoutFilter(i)));if(!o||"none"!==l){if(t){r.save();r.setTransform(1,0,0,1,0,0);r.clearRect(0,0,a,s);r.restore()}r.filter=l;r.drawImage(e,0,0);r.filter="none";return n}const d=e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,a,s),c=r.createImageData(a,s),h=d.data,u=c.data,_=i>0?1/i:1e6;for(let e=3,t=h.length;e<t;e+=4)u[e]=Math.min(Math.round(h[e]*_),255);r.putImageData(c,0,0);return n}function _getOrCreatePooledEntry(e,t,i,a){let s=e?.[t]??null;if(s&&(s.canvas.width!==i||s.canvas.height!==a)){this.canvasFactory.destroy(s);s=null}if(!s){s=this.canvasFactory.create(i,a);e&&(e[t]=s);return s}const n=s.context;n.save();n.setTransform(1,0,0,1,0,0);n.clearRect(0,0,i,a);n.restore();return s}function _compositeKnockoutSurface(e,t,i={}){const{backdropCanvas:a=null,destTransform:s=[1,0,0,1,0,0],backdropOffset:n=[0,0],reuseMaskEntry:r=null,poolMeta:o=null,sourceAlpha:l=1,sourceFilter:d="none",knockoutAlpha:c=1}=i,{width:h,height:u}=t,_=canvas_assertClassBrand(an,this,_createKnockoutMaskCanvas).call(this,t,r,c),p=e.globalCompositeOperation;e.save();e.setTransform(...s);e.globalAlpha=1;FeatureTest.isCanvasFilterSupported&&(e.filter="none");e.globalCompositeOperation="destination-out";e.drawImage(_.canvas,0,0);if(a){const[t,i]=n,s=canvas_assertClassBrand(an,this,_getOrCreatePooledEntry).call(this,o,"knockoutBackdropEntry",h,u),r=s.context;r.drawImage(a,t,i,h,u,0,0,h,u);r.globalCompositeOperation="destination-in";r.drawImage(_.canvas,0,0);r.globalCompositeOperation="source-over";e.globalCompositeOperation="destination-over";e.drawImage(s.canvas,0,0);o||this.canvasFactory.destroy(s)}e.globalCompositeOperation=p;e.globalAlpha=l;FeatureTest.isCanvasFilterSupported&&(e.filter=d??"none");e.drawImage(t,0,0);e.restore();r||this.canvasFactory.destroy(_)}function _beginKnockoutElement(e=1){var t;if(0===canvas_classPrivateFieldGet($s,this)||canvas_classPrivateFieldGet(Ks,this)>0||!this.contentVisible)return!1;canvas_classPrivateFieldSet(Ks,this,(t=canvas_classPrivateFieldGet(Ks,this),t++,t));canvas_classPrivateFieldSet(Qs,this,e);const i=canvas_classPrivateFieldGet(tn,this).at(-1),{canvas:a}=this.ctx,s=canvas_assertClassBrand(an,this,_getOrCreatePooledEntry).call(this,i,"knockoutTempEntry",a.width,a.height);canvas_classPrivateFieldSet(Xs,this,s);const n=s.context;n.save();n.setTransform(this.ctx.getTransform());copyCtxState(this.ctx,n);canvas_classPrivateFieldSet(Zs,this,n.globalCompositeOperation);n.globalCompositeOperation="source-over";mirrorContextOperations(n,this.ctx);canvas_classPrivateFieldSet(en,this,i);canvas_classPrivateFieldSet(qs,this,this.ctx);canvas_classPrivateFieldSet(Ys,this,this.suspendedCtx);this.ctx=n;this.inSMaskMode&&(this.suspendedCtx=n);return!0}function _endKnockoutElement(e){if(!e)return;const t=canvas_classPrivateFieldGet(Xs,this),i=canvas_classPrivateFieldGet(qs,this),a=canvas_classPrivateFieldGet(Ys,this),s=t.context;canvas_classPrivateFieldSet(Xs,this,null);canvas_classPrivateFieldSet(qs,this,null);canvas_classPrivateFieldSet(Ys,this,null);this.inSMaskMode&&this.suspendedCtx===s&&this.ctx!==s&&this.endSMaskMode();this.inSMaskMode&&(this.suspendedCtx=a);this.ctx._removeMirroring();this.ctx.globalCompositeOperation=canvas_classPrivateFieldGet(Zs,this);canvas_classPrivateFieldSet(Zs,this,null);copyCtxState(this.ctx,i);this.ctx=i;const n=canvas_classPrivateFieldGet(en,this);canvas_classPrivateFieldSet(en,this,null);const r=canvas_classPrivateFieldGet(Qs,this);canvas_classPrivateFieldSet(Qs,this,1);try{canvas_assertClassBrand(an,this,_compositeKnockoutSurface).call(this,a??i,t.canvas,{backdropCanvas:n?.backdropCtx?.canvas??null,backdropOffset:n?.backdropCtx?[n.offsetX,n.offsetY]:[0,0],reuseMaskEntry:n?.knockoutMaskEntry??null,poolMeta:n,knockoutAlpha:r})}finally{var o;s.restore();canvas_classPrivateFieldSet(Ks,this,(o=canvas_classPrivateFieldGet(Ks,this),o--,o));n||this.canvasFactory.destroy(t)}}function _getScaledPath(e,t,i){const a=new Path2D;a.addPath(e,new DOMMatrix(i).invertSelf().multiplySelf(t));return a}function _convertGroupToGray(e){const{canvas:t}=e,{width:i,height:a}=t;if(FeatureTest.isCanvasFilterSupported){e.save();e.setTransform(1,0,0,1,0,0);e.filter="grayscale(1)";e.globalAlpha=1;e.globalCompositeOperation="copy";e.drawImage(t,0,0);e.restore();return}const s=e.getImageData(0,0,i,a),{data:n}=s;for(let e=0,t=n.length;e<t;e+=4){const t=.2126*n[e]+.7152*n[e+1]+.0722*n[e+2]+.5|0;n[e]=n[e+1]=n[e+2]=t}e.putImageData(s,0,0)}function _destroyKnockoutPools(e){if(e){if(e.knockoutMaskEntry){this.canvasFactory.destroy(e.knockoutMaskEntry);e.knockoutMaskEntry=null}if(e.knockoutTempEntry){this.canvasFactory.destroy(e.knockoutTempEntry);e.knockoutTempEntry=null}if(e.knockoutBackdropEntry){this.canvasFactory.destroy(e.knockoutBackdropEntry);e.knockoutBackdropEntry=null}}}for(const e in T)void 0!==CanvasGraphics.prototype[e]&&(CanvasGraphics.prototype[T[e]]=CanvasGraphics.prototype[e]);function base_pdf_stream_defineProperty(e,t,i){return(t=function base_pdf_stream_toPropertyKey(e){var t=function base_pdf_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function base_pdf_stream_classPrivateFieldInitSpec(e,t,i){(function base_pdf_stream_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function base_pdf_stream_classPrivateFieldGet(e,t){return e.get(base_pdf_stream_assertClassBrand(e,t))}function base_pdf_stream_classPrivateFieldSet(e,t,i){return e.set(base_pdf_stream_assertClassBrand(e,t),i),i}function base_pdf_stream_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var sn=new WeakMap,nn=new WeakMap;class BasePDFStream{constructor(e,t,i){base_pdf_stream_classPrivateFieldInitSpec(this,sn,null);base_pdf_stream_classPrivateFieldInitSpec(this,nn,null);base_pdf_stream_defineProperty(this,"_fullReader",null);base_pdf_stream_defineProperty(this,"_rangeReaders",new Set);base_pdf_stream_defineProperty(this,"_source",null);this._source=e;base_pdf_stream_classPrivateFieldSet(sn,this,t);base_pdf_stream_classPrivateFieldSet(nn,this,i)}get _progressiveDataLength(){return this._fullReader?._loaded??0}getFullReader(){assert(!this._fullReader,"BasePDFStream.getFullReader can only be called once.");return this._fullReader=new(base_pdf_stream_classPrivateFieldGet(sn,this))(this)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const i=new(base_pdf_stream_classPrivateFieldGet(nn,this))(this,e,t);this._rangeReaders.add(i);return i}cancelAllRequests(e){this._fullReader?.cancel(e);for(const t of new Set(this._rangeReaders))t.cancel(e)}}class BasePDFStreamReader{constructor(e){base_pdf_stream_defineProperty(this,"onProgress",null);base_pdf_stream_defineProperty(this,"_contentLength",0);base_pdf_stream_defineProperty(this,"_filename",null);base_pdf_stream_defineProperty(this,"_headersCapability",Promise.withResolvers());base_pdf_stream_defineProperty(this,"_isRangeSupported",!1);base_pdf_stream_defineProperty(this,"_isStreamingSupported",!1);base_pdf_stream_defineProperty(this,"_loaded",0);base_pdf_stream_defineProperty(this,"_stream",null);this._stream=e}_callOnProgress(){this.onProgress?.({loaded:this._loaded,total:this._contentLength})}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(){unreachable("Abstract method `read` called")}cancel(e){unreachable("Abstract method `cancel` called")}}class BasePDFStreamRangeReader{constructor(e,t,i){base_pdf_stream_defineProperty(this,"_stream",null);this._stream=e}async read(){unreachable("Abstract method `read` called")}cancel(e){unreachable("Abstract method `cancel` called")}}function createHeaders(e,t){const i=new Headers;if(!e||!t||"object"!=typeof t)return i;for(const e in t){const a=t[e];void 0!==a&&i.append(e,a)}return i}function getResponseOrigin(e){return URL.parse(e)?.origin??null}function validateRangeRequestCapabilities({responseHeaders:e,isHttp:t,rangeChunkSize:i,disableRange:a}){const s={contentLength:0,isRangeSupported:!1},n=parseInt(e.get("Content-Length"),10);if(!Number.isInteger(n))return s;s.contentLength=n;if(n<=2*i)return s;if(a||!t)return s;if("bytes"!==e.get("Accept-Ranges"))return s;"identity"===(e.get("Content-Encoding")||"identity")&&(s.isRangeSupported=!0);return s}function extractFilenameFromHeader(e){const t=e.get("Content-Disposition");if(t){let e=function getFilenameFromContentDispositionHeader(e){let t=!0,i=toParamRegExp("filename\\*","i").exec(e);if(i){i=i[1];let e=rfc2616unquote(i);e=unescape(e);e=rfc5987decode(e);e=rfc2047decode(e);return fixupEncoding(e)}i=function rfc2231getparam(e){const t=[];let i;const a=toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=a.exec(e));){let[,e,a,s]=i;e=parseInt(e,10);if(e in t){if(0===e)break}else t[e]=[a,s]}const s=[];for(let e=0;e<t.length&&e in t;++e){let[i,a]=t[e];a=rfc2616unquote(a);if(i){a=unescape(a);0===e&&(a=rfc5987decode(a))}s.push(a)}return s.join("")}(e);if(i)return fixupEncoding(rfc2047decode(i));i=toParamRegExp("filename","i").exec(e);if(i){i=i[1];let e=rfc2616unquote(i);e=rfc2047decode(e);return fixupEncoding(e)}function toParamRegExp(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function textdecode(e,i){if(e){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const a=new TextDecoder(e,{fatal:!0}),s=stringToBytes(i);i=a.decode(s);t=!1}catch{}}return i}function fixupEncoding(e){if(t&&/[\x80-\xff]/.test(e)){e=textdecode("utf-8",e);t&&(e=textdecode("iso-8859-1",e))}return e}function rfc2616unquote(e){if(e.startsWith('"')){const t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){const i=t[e].indexOf('"');if(-1!==i){t[e]=t[e].slice(0,i);t.length=e+1}t[e]=t[e].replaceAll(/\\(.)/g,"$1")}e=t.join('"')}return e}function rfc5987decode(e){const t=e.indexOf("'");return-1===t?e:textdecode(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,""))}function rfc2047decode(e){return!e.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QB])\?((?:[^?]|\?(?!=))*)\?=/gi,function(e,t,i,a){if("q"===i||"Q"===i)return textdecode(t,a=(a=a.replaceAll("_"," ")).replaceAll(/=([0-9a-f]{2})/gi,function(e,t){return String.fromCharCode(parseInt(t,16))}));try{a=atob(a)}catch{}return textdecode(t,a)})}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(isPdfFile(e))return e}return null}function createResponseError(e,t){return new ResponseException(`Unexpected server response (${e}) while retrieving PDF "${t.href}".`,e,404===e||0===e&&"file:"===t.protocol)}function ensureResponseOrigin(e,t){if(e!==t)throw new Error(`Expected range response-origin "${e}" to match "${t}".`)}function fetch_stream_defineProperty(e,t,i){return(t=function fetch_stream_toPropertyKey(e){var t=function fetch_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function fetchUrl(e,t,i,a){return fetch(e,{method:"GET",headers:t,signal:a.signal,mode:"cors",credentials:i?"include":"same-origin",redirect:"follow"})}function ensureResponseStatus(e,t){if(200!==e&&206!==e)throw createResponseError(e,t)}function getArrayBuffer(e){if(e instanceof Uint8Array)return e.buffer;if(e instanceof ArrayBuffer)return e;throw new Error(`getArrayBuffer - unexpected data: ${e}`)}class PDFFetchStream extends BasePDFStream{constructor(e){super(e,PDFFetchStreamReader,PDFFetchStreamRangeReader);fetch_stream_defineProperty(this,"_responseOrigin",null);const{httpHeaders:t,url:i}=e;assert(/https?:|blob:|capacitor:/.test(i.protocol),"PDFFetchStream only supports http(s)://, blob:, and capacitor:// URLs.");this.headers=createHeaders(!0,t)}}class PDFFetchStreamReader extends BasePDFStreamReader{constructor(e){super(e);fetch_stream_defineProperty(this,"_abortController",new AbortController);fetch_stream_defineProperty(this,"_reader",null);const{disableRange:t,disableStream:i,rangeChunkSize:a,url:s,withCredentials:n}=e._source;this._isStreamingSupported=!i;const r=new Headers(e.headers);fetchUrl(s,r,n,this._abortController).then(i=>{e._responseOrigin=getResponseOrigin(i.url);ensureResponseStatus(i.status,s);this._reader=i.body.getReader();const n=i.headers,{contentLength:r,isRangeSupported:o}=validateRangeRequestCapabilities({responseHeaders:n,isHttp:!0,rangeChunkSize:a,disableRange:t});this._contentLength=r;this._isRangeSupported=o;this._filename=extractFilenameFromHeader(n);!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new AbortException("Streaming is disabled."));this._headersCapability.resolve()}).catch(this._headersCapability.reject)}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};this._loaded+=e.byteLength;this._callOnProgress();return{value:getArrayBuffer(e),done:!1}}cancel(e){this._reader?.cancel(e);this._abortController.abort()}}class PDFFetchStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);fetch_stream_defineProperty(this,"_abortController",new AbortController);fetch_stream_defineProperty(this,"_readCapability",Promise.withResolvers());fetch_stream_defineProperty(this,"_reader",null);const{url:a,withCredentials:s}=e._source,n=new Headers(e.headers);n.append("Range",`bytes=${t}-${i-1}`);fetchUrl(a,n,s,this._abortController).then(t=>{ensureResponseOrigin(getResponseOrigin(t.url),e._responseOrigin);ensureResponseStatus(t.status,a);this._reader=t.body.getReader();this._readCapability.resolve()}).catch(this._readCapability.reject)}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:{value:getArrayBuffer(e),done:!1}}cancel(e){this._reader?.cancel(e);this._abortController.abort()}}function transport_stream_classPrivateFieldInitSpec(e,t,i){transport_stream_checkPrivateRedeclaration(e,t),t.set(e,i)}function transport_stream_classPrivateFieldGet(e,t){return e.get(transport_stream_assertClassBrand(e,t))}function transport_stream_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function transport_stream_defineProperty(e,t,i){return(t=function transport_stream_toPropertyKey(e){var t=function transport_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function transport_stream_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function transport_stream_getArrayBuffer(e){return e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}function endRequests(){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}var rn=new WeakSet;class PDFDataTransportStream extends BasePDFStream{constructor(e){super(e,PDFDataTransportStreamReader,PDFDataTransportStreamRangeReader);!function transport_stream_classPrivateMethodInitSpec(e,t){transport_stream_checkPrivateRedeclaration(e,t),t.add(e)}(this,rn);transport_stream_defineProperty(this,"_progressiveDone",!1);transport_stream_defineProperty(this,"_queuedChunks",[]);const{pdfDataRangeTransport:t}=e,{initialData:i,progressiveDone:a}=t;if(i?.length>0){const e=transport_stream_getArrayBuffer(i);this._queuedChunks.push(e)}this._progressiveDone=a;t.transportReady(e=>{switch(e.type){case"range":case"progressiveRead":transport_stream_assertClassBrand(rn,this,_onReceiveData).call(this,e.begin,e.chunk);break;case"progressiveDone":this._fullReader?.progressiveDone();this._progressiveDone=!0}})}getFullReader(){const e=super.getFullReader();this._queuedChunks=null;return e}getRangeReader(e,t){const i=super.getRangeReader(e,t);if(i){i.onDone=()=>this._rangeReaders.delete(i);this._source.pdfDataRangeTransport.requestDataRange(e,t)}return i}cancelAllRequests(e){super.cancelAllRequests(e);this._source.pdfDataRangeTransport.abort()}}function _onReceiveData(e,t){const i=transport_stream_getArrayBuffer(t);if(void 0===e)this._fullReader?this._fullReader._enqueue(i):this._queuedChunks.push(i);else{const t=this._rangeReaders.keys().find(t=>t._begin===e);assert(t,"#onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.");t._enqueue(i)}}var on=new WeakMap;class PDFDataTransportStreamReader extends BasePDFStreamReader{constructor(e){super(e);transport_stream_classPrivateFieldInitSpec(this,on,endRequests.bind(this));transport_stream_defineProperty(this,"_done",!1);transport_stream_defineProperty(this,"_queuedChunks",null);transport_stream_defineProperty(this,"_requests",[]);const{pdfDataRangeTransport:t,disableRange:i,disableStream:a}=e._source,{length:s,contentDispositionFilename:n}=t;this._queuedChunks=e._queuedChunks||[];for(const e of this._queuedChunks)this._loaded+=e.byteLength;this._done=e._progressiveDone;this._contentLength=s;this._isStreamingSupported=!a;this._isRangeSupported=!i;isPdfFile(n)&&(this._filename=n);this._headersCapability.resolve();const r=this._loaded;Promise.resolve().then(()=>{r>0&&this._loaded===r&&this._callOnProgress()})}_enqueue(e){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunks.push(e);this._loaded+=e.byteLength;this._callOnProgress()}}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;transport_stream_classPrivateFieldGet(on,this).call(this)}progressiveDone(){this._done||=!0;0===this._queuedChunks.length&&transport_stream_classPrivateFieldGet(on,this).call(this)}}var ln=new WeakMap;class PDFDataTransportStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);transport_stream_classPrivateFieldInitSpec(this,ln,endRequests.bind(this));transport_stream_defineProperty(this,"onDone",null);transport_stream_defineProperty(this,"_begin",-1);transport_stream_defineProperty(this,"_done",!1);transport_stream_defineProperty(this,"_queuedChunk",null);transport_stream_defineProperty(this,"_requests",[]);this._begin=t}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});transport_stream_classPrivateFieldGet(ln,this).call(this)}this._done=!0;this.onDone?.()}}async read(){if(this._queuedChunk){const e=this._queuedChunk;this._queuedChunk=null;return{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;transport_stream_classPrivateFieldGet(ln,this).call(this);this.onDone?.()}}function network_classPrivateMethodInitSpec(e,t){network_checkPrivateRedeclaration(e,t),t.add(e)}function network_defineProperty(e,t,i){return(t=function network_toPropertyKey(e){var t=function network_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function network_classPrivateFieldInitSpec(e,t,i){network_checkPrivateRedeclaration(e,t),t.set(e,i)}function network_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function network_classPrivateFieldGet(e,t){return e.get(network_assertClassBrand(e,t))}function network_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var dn=new WeakMap,cn=new WeakSet;class PDFNetworkStream extends BasePDFStream{constructor(e){super(e,PDFNetworkStreamReader,PDFNetworkStreamRangeReader);network_classPrivateMethodInitSpec(this,cn);network_classPrivateFieldInitSpec(this,dn,new WeakMap);network_defineProperty(this,"_responseOrigin",null);const{httpHeaders:t,url:i}=e;this.url=i;this.isHttp=/https?:/.test(i.protocol);this.headers=createHeaders(this.isHttp,t)}_request(e){const t=new XMLHttpRequest,i={validateStatus:null,onHeadersReceived:e.onHeadersReceived,onDone:e.onDone,onError:e.onError,onProgress:e.onProgress};network_classPrivateFieldGet(dn,this).set(t,i);t.open("GET",this.url);t.withCredentials=this._source.withCredentials;for(const[e,i]of this.headers)t.setRequestHeader(e,i);if(this.isHttp&&"begin"in e&&"end"in e){t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`);i.validateStatus=e=>206===e||200===e}else i.validateStatus=e=>200===e;t.responseType="arraybuffer";assert(e.onError,"Expected `onError` callback to be provided.");t.onerror=()=>e.onError(t.status);t.onreadystatechange=network_assertClassBrand(cn,this,_onStateChange).bind(this,t);t.onprogress=network_assertClassBrand(cn,this,_onProgress).bind(this,t);t.send(null);return t}_abortRequest(e){if(network_classPrivateFieldGet(dn,this).has(e)){network_classPrivateFieldGet(dn,this).delete(e);e.abort()}}getRangeReader(e,t){const i=super.getRangeReader(e,t);i&&(i.onClosed=()=>this._rangeReaders.delete(i));return i}}function _onProgress(e,t){const i=network_classPrivateFieldGet(dn,this).get(e);i?.onProgress?.(t)}function _onStateChange(e,t){const i=network_classPrivateFieldGet(dn,this).get(e);if(!i)return;if(e.readyState>=2&&i.onHeadersReceived){i.onHeadersReceived();delete i.onHeadersReceived}if(4!==e.readyState)return;if(!network_classPrivateFieldGet(dn,this).has(e))return;network_classPrivateFieldGet(dn,this).delete(e);if(0===e.status&&this.isHttp){i.onError(e.status);return}const a=e.status||200;if(!i.validateStatus(a)){i.onError(e.status);return}const s=function network_getArrayBuffer(e){return"string"!=typeof e?e:stringToBytes(e).buffer}(e.response);if(206===a){const t=e.getResponseHeader("Content-Range");if(/bytes \d+-\d+\/\d+/.test(t))i.onDone(s);else{warn('Missing or invalid "Content-Range" header.');i.onError(0)}}else s?i.onDone(s):i.onError(e.status)}var hn=new WeakMap,un=new WeakSet;class PDFNetworkStreamReader extends BasePDFStreamReader{constructor(e){super(e);network_classPrivateMethodInitSpec(this,un);network_classPrivateFieldInitSpec(this,hn,endRequests.bind(this));network_defineProperty(this,"_cachedChunks",[]);network_defineProperty(this,"_done",!1);network_defineProperty(this,"_requests",[]);network_defineProperty(this,"_storedError",null);this._fullRequestXhr=e._request({onHeadersReceived:network_assertClassBrand(un,this,_onHeadersReceived).bind(this),onDone:network_assertClassBrand(un,this,_onDone).bind(this),onError:network_assertClassBrand(un,this,_onError).bind(this),onProgress:network_assertClassBrand(un,this,_onProgress2).bind(this)})}async read(){await this._headersCapability.promise;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 e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;this._headersCapability.reject(e);network_classPrivateFieldGet(hn,this).call(this);this._stream._abortRequest(this._fullRequestXhr);this._fullRequestXhr=null}}function _onHeadersReceived(){const e=this._stream,{disableRange:t,rangeChunkSize:i}=e._source,a=this._fullRequestXhr;e._responseOrigin=getResponseOrigin(a.responseURL);const s=a.getAllResponseHeaders(),n=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(e=>{const[t,...i]=e.split(": ");return[t,i.join(": ")]}):[]),{contentLength:r,isRangeSupported:o}=validateRangeRequestCapabilities({responseHeaders:n,isHttp:e.isHttp,rangeChunkSize:i,disableRange:t});this._contentLength=r;this._isRangeSupported=o;this._filename=extractFilenameFromHeader(n);this._isRangeSupported&&e._abortRequest(a);this._headersCapability.resolve()}function _onDone(e){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._cachedChunks.push(e);this._done=!0;0===this._cachedChunks.length&&network_classPrivateFieldGet(hn,this).call(this)}function _onError(e){this._storedError=createResponseError(e,this._stream.url);this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0;this._cachedChunks.length=0}function _onProgress2(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}var _n=new WeakMap,pn=new WeakSet;class PDFNetworkStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);network_classPrivateMethodInitSpec(this,pn);network_classPrivateFieldInitSpec(this,_n,endRequests.bind(this));network_defineProperty(this,"onClosed",null);network_defineProperty(this,"_done",!1);network_defineProperty(this,"_queuedChunk",null);network_defineProperty(this,"_requests",[]);network_defineProperty(this,"_storedError",null);this._requestXhr=e._request({begin:t,end:i,onHeadersReceived:network_assertClassBrand(pn,this,_onHeadersReceived2).bind(this),onDone:network_assertClassBrand(pn,this,_onDone2).bind(this),onError:network_assertClassBrand(pn,this,_onError2).bind(this),onProgress:null})}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const e=this._queuedChunk;this._queuedChunk=null;return{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();this._requests.push(e);return e.promise}cancel(e){this._done=!0;network_classPrivateFieldGet(_n,this).call(this);this._stream._abortRequest(this._requestXhr);this.onClosed?.()}}function _onHeadersReceived2(){const e=getResponseOrigin(this._requestXhr?.responseURL);try{ensureResponseOrigin(e,this._stream._responseOrigin)}catch(e){this._storedError=e;network_assertClassBrand(pn,this,_onError2).call(this,0)}}function _onDone2(e){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;network_classPrivateFieldGet(_n,this).call(this);this.onClosed?.()}function _onError2(e){this._storedError??=createResponseError(e,this._stream.url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0;this._queuedChunk=null}function node_stream_defineProperty(e,t,i){return(t=function node_stream_toPropertyKey(e){var t=function node_stream_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function getReadableStream(e,t=null){const i=process.getBuiltinModule("fs"),{Readable:a}=process.getBuiltinModule("stream"),s=i.createReadStream(e,t);return a.toWeb(s)}class PDFNodeStream extends BasePDFStream{constructor(e){super(e,PDFNodeStreamReader,PDFNodeStreamRangeReader);const{url:t}=e;assert("file:"===t.protocol,"PDFNodeStream only supports file:// URLs.")}}class PDFNodeStreamReader extends BasePDFStreamReader{constructor(e){super(e);node_stream_defineProperty(this,"_reader",null);const{disableRange:t,disableStream:i,rangeChunkSize:a,url:s}=e._source;this._isStreamingSupported=!i;process.getBuiltinModule("fs/promises").lstat(s).then(e=>{const i=getReadableStream(s);this._reader=i.getReader();const{size:n}=e;this._contentLength=n;this._isRangeSupported=!t&&n>2*a;!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new AbortException("Streaming is disabled."));this._headersCapability.resolve()}).catch(e=>{"ENOENT"===e.code&&(e=createResponseError(0,s));this._headersCapability.reject(e)})}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};this._loaded+=e.byteLength;this._callOnProgress();return{value:getArrayBuffer(e),done:!1}}cancel(e){this._reader?.cancel(e)}}class PDFNodeStreamRangeReader extends BasePDFStreamRangeReader{constructor(e,t,i){super(e,t,i);node_stream_defineProperty(this,"_readCapability",Promise.withResolvers());node_stream_defineProperty(this,"_reader",null);const{url:a}=e._source;try{const e=getReadableStream(a,{start:t,end:i-1});this._reader=e.getReader();this._readCapability.resolve()}catch(e){this._readCapability.reject(e)}}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:{value:getArrayBuffer(e),done:!1}}cancel(e){this._reader?.cancel(e)}}function worker_options_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class GlobalWorkerOptions{static get workerPort(){return worker_options_assertClassBrand(GlobalWorkerOptions,this,gn)._}static set workerPort(e){if(!("undefined"!=typeof Worker&&e instanceof Worker)&&null!==e)throw new Error("Invalid `workerPort` type.");gn._=worker_options_assertClassBrand(GlobalWorkerOptions,this,e)}static get workerSrc(){return worker_options_assertClassBrand(GlobalWorkerOptions,this,mn)._}static set workerSrc(e){if("string"!=typeof e)throw new Error("Invalid `workerSrc` type.");mn._=worker_options_assertClassBrand(GlobalWorkerOptions,this,e)}}var gn={_:null},mn={_:""};function metadata_classPrivateFieldInitSpec(e,t,i){(function metadata_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function metadata_classPrivateFieldGet(e,t){return e.get(metadata_assertClassBrand(e,t))}function metadata_classPrivateFieldSet(e,t,i){return e.set(metadata_assertClassBrand(e,t),i),i}function metadata_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var fn=new WeakMap,vn=new WeakMap;class Metadata{constructor({parsedData:e,rawData:t}){metadata_classPrivateFieldInitSpec(this,fn,void 0);metadata_classPrivateFieldInitSpec(this,vn,void 0);metadata_classPrivateFieldSet(fn,this,e);metadata_classPrivateFieldSet(vn,this,t)}getRaw(){return metadata_classPrivateFieldGet(vn,this)}get(e){return metadata_classPrivateFieldGet(fn,this).get(e)??null}[Symbol.iterator](){return metadata_classPrivateFieldGet(fn,this).entries()}}function optional_content_config_defineProperty(e,t,i){return(t=function optional_content_config_toPropertyKey(e){var t=function optional_content_config_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function optional_content_config_classPrivateFieldInitSpec(e,t,i){optional_content_config_checkPrivateRedeclaration(e,t),t.set(e,i)}function optional_content_config_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function optional_content_config_classPrivateFieldGet(e,t){return e.get(optional_content_config_assertClassBrand(e,t))}function optional_content_config_classPrivateFieldSet(e,t,i){return e.set(optional_content_config_assertClassBrand(e,t),i),i}function optional_content_config_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Pn=Symbol("INTERNAL");var wn=new WeakMap,Fn=new WeakMap,bn=new WeakMap,yn=new WeakMap;class OptionalContentGroup{constructor(e,{name:t,intent:i,usage:a,rbGroups:s}){optional_content_config_classPrivateFieldInitSpec(this,wn,!1);optional_content_config_classPrivateFieldInitSpec(this,Fn,!1);optional_content_config_classPrivateFieldInitSpec(this,bn,!1);optional_content_config_classPrivateFieldInitSpec(this,yn,!0);optional_content_config_classPrivateFieldSet(wn,this,!!(e&o));optional_content_config_classPrivateFieldSet(Fn,this,!!(e&l));this.name=t;this.intent=i;this.usage=a;this.rbGroups=s}get visible(){if(optional_content_config_classPrivateFieldGet(bn,this))return optional_content_config_classPrivateFieldGet(yn,this);if(!optional_content_config_classPrivateFieldGet(yn,this))return!1;const{print:e,view:t}=this.usage;return optional_content_config_classPrivateFieldGet(wn,this)?"OFF"!==t?.viewState:!optional_content_config_classPrivateFieldGet(Fn,this)||"OFF"!==e?.printState}_setVisible(e,t,i=!1){e!==Pn&&unreachable("Internal method `_setVisible` called.");optional_content_config_classPrivateFieldSet(bn,this,i);optional_content_config_classPrivateFieldSet(yn,this,t)}get serializable(){return{userSet:optional_content_config_classPrivateFieldGet(bn,this),visible:optional_content_config_classPrivateFieldGet(yn,this)}}}var Sn=new WeakMap,Cn=new WeakMap,xn=new WeakMap,kn=new WeakMap,En=new WeakMap,An=new WeakSet;class OptionalContentConfig{constructor(e,t=o,i=null){!function optional_content_config_classPrivateMethodInitSpec(e,t){optional_content_config_checkPrivateRedeclaration(e,t),t.add(e)}(this,An);optional_content_config_classPrivateFieldInitSpec(this,Sn,null);optional_content_config_classPrivateFieldInitSpec(this,Cn,new Map);optional_content_config_classPrivateFieldInitSpec(this,xn,null);optional_content_config_classPrivateFieldInitSpec(this,kn,null);optional_content_config_classPrivateFieldInitSpec(this,En,void 0);optional_content_config_defineProperty(this,"creator",null);optional_content_config_defineProperty(this,"name",null);optional_content_config_classPrivateFieldSet(En,this,e);this.renderingIntent=t;if(null!==e){this.name=e.name;this.creator=e.creator;optional_content_config_classPrivateFieldSet(kn,this,e.order);for(const i of e.groups)optional_content_config_classPrivateFieldGet(Cn,this).set(i.id,new OptionalContentGroup(t,i));if(i){i.size!==optional_content_config_classPrivateFieldGet(Cn,this).size&&unreachable("Incorrect serialized groupState.");for(const[e,t]of i)optional_content_config_classPrivateFieldGet(Cn,this).get(e)._setVisible(Pn,t.visible,t.userSet)}else{if("OFF"===e.baseState)for(const e of optional_content_config_classPrivateFieldGet(Cn,this).values())e._setVisible(Pn,!1);for(const t of e.on)optional_content_config_classPrivateFieldGet(Cn,this).get(t)._setVisible(Pn,!0);for(const t of e.off)optional_content_config_classPrivateFieldGet(Cn,this).get(t)._setVisible(Pn,!1)}optional_content_config_classPrivateFieldSet(xn,this,this.getHash())}}isVisible(e){if(0===optional_content_config_classPrivateFieldGet(Cn,this).size)return!0;if(!e){info("Optional content group not defined.");return!0}if("OCG"===e.type){if(!optional_content_config_classPrivateFieldGet(Cn,this).has(e.id)){warn(`Optional content group not found: ${e.id}`);return!0}return optional_content_config_classPrivateFieldGet(Cn,this).get(e.id).visible}if("OCMD"===e.type){if(e.expression)return optional_content_config_assertClassBrand(An,this,_evaluateVisibilityExpression).call(this,e.expression);if(!e.policy||"AnyOn"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(Cn,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(optional_content_config_classPrivateFieldGet(Cn,this).get(t).visible)return!0}return!1}if("AllOn"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(Cn,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(!optional_content_config_classPrivateFieldGet(Cn,this).get(t).visible)return!1}return!0}if("AnyOff"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(Cn,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(!optional_content_config_classPrivateFieldGet(Cn,this).get(t).visible)return!0}return!1}if("AllOff"===e.policy){for(const t of e.ids){if(!optional_content_config_classPrivateFieldGet(Cn,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}if(optional_content_config_classPrivateFieldGet(Cn,this).get(t).visible)return!1}return!0}warn(`Unknown optional content policy ${e.policy}.`);return!0}warn(`Unknown group type ${e.type}.`);return!0}setVisibility(e,t=!0,i=!0){const a=optional_content_config_classPrivateFieldGet(Cn,this).get(e);if(a){if(i&&t&&a.rbGroups.length)for(const t of a.rbGroups)for(const i of t)i!==e&&optional_content_config_classPrivateFieldGet(Cn,this).get(i)?._setVisible(Pn,!1,!0);a._setVisible(Pn,!!t,!0);optional_content_config_classPrivateFieldSet(Sn,this,null)}else warn(`Optional content group not found: ${e}`)}setOCGState({state:e,preserveRB:t}){let i;for(const a of e){switch(a){case"ON":case"OFF":case"Toggle":i=a;continue}const e=optional_content_config_classPrivateFieldGet(Cn,this).get(a);if(e)switch(i){case"ON":this.setVisibility(a,!0,t);break;case"OFF":this.setVisibility(a,!1,t);break;case"Toggle":this.setVisibility(a,!e.visible,t)}}optional_content_config_classPrivateFieldSet(Sn,this,null)}get hasInitialVisibility(){return null===optional_content_config_classPrivateFieldGet(xn,this)||this.getHash()===optional_content_config_classPrivateFieldGet(xn,this)}getOrder(){return optional_content_config_classPrivateFieldGet(Cn,this).size?optional_content_config_classPrivateFieldGet(kn,this)?optional_content_config_classPrivateFieldGet(kn,this).slice():[...optional_content_config_classPrivateFieldGet(Cn,this).keys()]:null}getGroup(e){return optional_content_config_classPrivateFieldGet(Cn,this).get(e)||null}getHash(){if(null!==optional_content_config_classPrivateFieldGet(Sn,this))return optional_content_config_classPrivateFieldGet(Sn,this);const e=new MurmurHash3_64;for(const[t,i]of optional_content_config_classPrivateFieldGet(Cn,this))e.update(`${t}:${i.visible}`);return optional_content_config_classPrivateFieldSet(Sn,this,e.hexdigest())}[Symbol.iterator](){return optional_content_config_classPrivateFieldGet(Cn,this).entries()}get serializable(){const e=new Map;for(const[t,i]of optional_content_config_classPrivateFieldGet(Cn,this))e.set(t,i.serializable);return{data:optional_content_config_classPrivateFieldGet(En,this),renderingIntent:this.renderingIntent,groupState:e}}static fromSerializable({data:e,renderingIntent:t,groupState:i}){return new OptionalContentConfig(e,t,i)}}function _evaluateVisibilityExpression(e){const t=e.length;if(t<2)return!0;const i=e[0];for(let a=1;a<t;a++){const t=e[a];let s;if(Array.isArray(t))s=optional_content_config_assertClassBrand(An,this,_evaluateVisibilityExpression).call(this,t);else{if(!optional_content_config_classPrivateFieldGet(Cn,this).has(t)){warn(`Optional content group not found: ${t}`);return!0}s=optional_content_config_classPrivateFieldGet(Cn,this).get(t).visible}switch(i){case"And":if(!s)return!1;break;case"Or":if(s)return!0;break;case"Not":return!s;default:return!0}}return"And"===i}function pages_mapper_classPrivateFieldInitSpec(e,t,i){pages_mapper_checkPrivateRedeclaration(e,t),t.set(e,i)}function pages_mapper_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pages_mapper_classPrivateFieldSet(e,t,i){return e.set(pages_mapper_assertClassBrand(e,t),i),i}function pages_mapper_classPrivateFieldGet(e,t){return e.get(pages_mapper_assertClassBrand(e,t))}function pages_mapper_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Gn=new WeakMap,Bn=new WeakMap,Mn=new WeakMap,In=new WeakMap,Tn=new WeakMap,Dn=new WeakSet;class PagesMapper{constructor(){!function pages_mapper_classPrivateMethodInitSpec(e,t){pages_mapper_checkPrivateRedeclaration(e,t),t.add(e)}(this,Dn);pages_mapper_classPrivateFieldInitSpec(this,Gn,null);pages_mapper_classPrivateFieldInitSpec(this,Bn,null);pages_mapper_classPrivateFieldInitSpec(this,Mn,0);pages_mapper_classPrivateFieldInitSpec(this,In,null);pages_mapper_classPrivateFieldInitSpec(this,Tn,null)}get pagesNumber(){return pages_mapper_classPrivateFieldGet(Mn,this)}set pagesNumber(e){if(pages_mapper_classPrivateFieldGet(Mn,this)!==e){pages_mapper_classPrivateFieldSet(Mn,this,e);pages_mapper_classPrivateFieldSet(Gn,this,null);pages_mapper_classPrivateFieldSet(Bn,this,null)}}movePages(e,t,i){pages_mapper_assertClassBrand(Dn,this,_ensureInit).call(this);const a=pages_mapper_classPrivateFieldGet(Gn,this),s=pages_mapper_assertClassBrand(Dn,this,_buildIdToPageNumber).call(this),n=t.length,r=new Uint32Array(n);let o=0;for(let e=0;e<n;e++){const s=t[e]-1;r[e]=a[s];s<i&&o++}const l=pages_mapper_classPrivateFieldGet(Mn,this),d=l-n,c=MathClamp(i-o,0,d);for(let t=0,i=0;t<l;t++)e.has(t+1)||(a[i++]=a[t]);a.copyWithin(c+n,c,d);a.set(r,c);pages_mapper_assertClassBrand(Dn,this,_updatePrevPageNumbers).call(this,s);a.every((e,t)=>e===t+1)&&pages_mapper_classPrivateFieldSet(Gn,this,null)}deletePages(e){pages_mapper_assertClassBrand(Dn,this,_ensureInit).call(this);const t=pages_mapper_classPrivateFieldGet(Gn,this),i=pages_mapper_assertClassBrand(Dn,this,_buildIdToPageNumber).call(this);pages_mapper_classPrivateFieldSet(Tn,this,{pageNumberToId:t.slice(),pagesNumber:pages_mapper_classPrivateFieldGet(Mn,this),prevPageNumbers:pages_mapper_classPrivateFieldGet(Bn,this).slice()});const a=pages_mapper_classPrivateFieldGet(Mn,this)-e.length;pages_mapper_classPrivateFieldSet(Mn,this,a);const s=pages_mapper_classPrivateFieldSet(Gn,this,new Uint32Array(a));pages_mapper_classPrivateFieldSet(Bn,this,new Int32Array(a));let n=0,r=0;for(const i of e){const e=i-1;if(e!==n){s.set(t.subarray(n,e),r);r+=e-n}n=e+1}n<t.length&&s.set(t.subarray(n),r);pages_mapper_assertClassBrand(Dn,this,_updatePrevPageNumbers).call(this,i,new Set(e))}cancelDelete(){if(pages_mapper_classPrivateFieldGet(Tn,this)){pages_mapper_classPrivateFieldSet(Gn,this,pages_mapper_classPrivateFieldGet(Tn,this).pageNumberToId);pages_mapper_classPrivateFieldSet(Mn,this,pages_mapper_classPrivateFieldGet(Tn,this).pagesNumber);pages_mapper_classPrivateFieldSet(Bn,this,pages_mapper_classPrivateFieldGet(Tn,this).prevPageNumbers);pages_mapper_classPrivateFieldSet(Tn,this,null)}}cleanSavedData(){pages_mapper_classPrivateFieldSet(Tn,this,null)}copyPages(e){pages_mapper_assertClassBrand(Dn,this,_ensureInit).call(this);pages_mapper_classPrivateFieldSet(In,this,{pageNumbers:e,pageIds:e.map(e=>pages_mapper_classPrivateFieldGet(Gn,this)[e-1])})}cancelCopy(){pages_mapper_classPrivateFieldSet(In,this,null)}pastePages(e){pages_mapper_assertClassBrand(Dn,this,_ensureInit).call(this);const t=pages_mapper_classPrivateFieldGet(Gn,this),i=pages_mapper_assertClassBrand(Dn,this,_buildIdToPageNumber).call(this),{pageNumbers:a,pageIds:s}=pages_mapper_classPrivateFieldGet(In,this),n=pages_mapper_classPrivateFieldGet(Mn,this)+a.length;pages_mapper_classPrivateFieldSet(Mn,this,n);const r=pages_mapper_classPrivateFieldSet(Gn,this,new Uint32Array(n));pages_mapper_classPrivateFieldSet(Bn,this,new Int32Array(n));r.set(t.subarray(0,e),0);r.set(s,e);r.set(t.subarray(e),e+a.length);pages_mapper_assertClassBrand(Dn,this,_updatePrevPageNumbers).call(this,i,null,e,a);pages_mapper_classPrivateFieldSet(In,this,null)}hasBeenAltered(){return null!==pages_mapper_classPrivateFieldGet(Gn,this)}getPageMappingForSaving(e=null){e??=pages_mapper_assertClassBrand(Dn,this,_buildIdToPageNumber).call(this);let t=0;for(const i of e.values())t=Math.max(t,i.length);const i=new Array(t);for(let e=0;e<t;e++)i[e]={document:null,pageIndices:[],includePages:[]};for(const[t,a]of e)for(let e=0,s=a.length;e<s;e++)i[e].includePages.push([t-1,a[e]-1]);for(const{includePages:e,pageIndices:t}of i){e.sort((e,t)=>e[0]-t[0]);for(let i=0,a=e.length;i<a;i++){t.push(e[i][1]);e[i]=e[i][0]}}return i}extractPages(e){e=Array.from(e).sort((e,t)=>e-t);const t=new Map;for(let i=0,a=e.length;i<a;i++){const a=this.getPageId(e[i]);t.getOrInsertComputed(a,makeArr).push(i+1)}return this.getPageMappingForSaving(t)}getPrevPageNumber(e){return pages_mapper_classPrivateFieldGet(Bn,this)?.[e-1]??0}getPageNumber(e){if(!pages_mapper_classPrivateFieldGet(Gn,this))return e;const t=pages_mapper_classPrivateFieldGet(Gn,this);for(let i=0,a=pages_mapper_classPrivateFieldGet(Mn,this);i<a;i++)if(t[i]===e)return i+1;return 0}getPageId(e){return pages_mapper_classPrivateFieldGet(Gn,this)?.[e-1]??e}getMapping(){return pages_mapper_classPrivateFieldGet(Gn,this)?.subarray(0,this.pagesNumber)}}function _ensureInit(){if(pages_mapper_classPrivateFieldGet(Gn,this))return;const e=pages_mapper_classPrivateFieldGet(Mn,this),t=pages_mapper_classPrivateFieldSet(Gn,this,new Uint32Array(e));for(let i=0;i<e;i++)t[i]=i+1;pages_mapper_classPrivateFieldSet(Bn,this,new Int32Array(t))}function _buildIdToPageNumber(){const e=new Map,t=pages_mapper_classPrivateFieldGet(Gn,this);for(let i=0,a=pages_mapper_classPrivateFieldGet(Mn,this);i<a;i++){const a=t[i],s=e.get(a);s?s.push(i+1):e.set(a,[i+1])}return e}function _updatePrevPageNumbers(e,t=null,i=-1,a=null){const s=pages_mapper_classPrivateFieldGet(Bn,this),n=pages_mapper_classPrivateFieldGet(Gn,this),r=i+(a?.length??0),o=new Map;for(let l=0,d=pages_mapper_classPrivateFieldGet(Mn,this);l<d;l++){if(l>=i&&l<r){s[l]=-a[l-i];continue}const d=n[l],c=e.get(d);let h=o.get(d)||0;if(t&&c)for(;h<c.length&&t.has(c[h]);)h++;s[l]=c?.[h];o.set(d,h+1)}}function pdf_objects_classPrivateFieldInitSpec(e,t,i){(function pdf_objects_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function pdf_objects_classPrivateFieldGet(e,t){return e.get(function pdf_objects_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}const Ln=Symbol("INITIAL_DATA"),dataObj=()=>({...Promise.withResolvers(),data:Ln});var Nn,Rn=new WeakMap;class PDFObjects{constructor(){pdf_objects_classPrivateFieldInitSpec(this,Rn,new Map)}get(e,t=null){if(t){const i=pdf_objects_classPrivateFieldGet(Rn,this).getOrInsertComputed(e,dataObj);i.promise.then(()=>t(i.data));return null}const i=pdf_objects_classPrivateFieldGet(Rn,this).get(e);if(!i||i.data===Ln)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return i.data}has(e){const t=pdf_objects_classPrivateFieldGet(Rn,this).get(e);return!!t&&t.data!==Ln}delete(e){const t=pdf_objects_classPrivateFieldGet(Rn,this).get(e);if(!t||t.data===Ln)return!1;pdf_objects_classPrivateFieldGet(Rn,this).delete(e);return!0}resolve(e,t=null){const i=pdf_objects_classPrivateFieldGet(Rn,this).getOrInsertComputed(e,dataObj);if(i.data!==Ln)throw new Error(`Object already resolved ${e}.`);i.data=t;i.resolve()}clear(){for(const{data:e}of pdf_objects_classPrivateFieldGet(Rn,this).values())e?.bitmap?.close();pdf_objects_classPrivateFieldGet(Rn,this).clear()}*[Symbol.iterator](){for(const[e,{data:t}]of pdf_objects_classPrivateFieldGet(Rn,this))t!==Ln&&(yield[e,t])}}function text_layer_classPrivateFieldInitSpec(e,t,i){text_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_layer_classPrivateFieldGet(e,t){return e.get(text_layer_assertClassBrand(e,t))}function text_layer_classPrivateFieldSet(e,t,i){return e.set(text_layer_assertClassBrand(e,t),i),i}function text_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var On=new WeakMap,Wn=new WeakMap,jn=new WeakMap,Vn=new WeakMap,Un=new WeakMap,zn=new WeakMap,Hn=new WeakMap,$n=new WeakMap,Kn=new WeakMap,Xn=new WeakMap,qn=new WeakMap,Yn=new WeakMap,Zn=new WeakMap,Qn=new WeakMap,Jn=new WeakMap,er=new WeakMap,tr=new WeakMap,ir=new WeakMap,ar=new WeakMap,sr=new WeakSet;class TextLayer{constructor({textContentSource:e,images:t,container:i,viewport:a}){!function text_layer_classPrivateMethodInitSpec(e,t){text_layer_checkPrivateRedeclaration(e,t),t.add(e)}(this,sr);text_layer_classPrivateFieldInitSpec(this,On,Promise.withResolvers());text_layer_classPrivateFieldInitSpec(this,Wn,null);text_layer_classPrivateFieldInitSpec(this,jn,!1);text_layer_classPrivateFieldInitSpec(this,Vn,!!globalThis.FontInspector?.enabled);text_layer_classPrivateFieldInitSpec(this,Un,null);text_layer_classPrivateFieldInitSpec(this,zn,null);text_layer_classPrivateFieldInitSpec(this,Hn,null);text_layer_classPrivateFieldInitSpec(this,$n,0);text_layer_classPrivateFieldInitSpec(this,Kn,0);text_layer_classPrivateFieldInitSpec(this,Xn,null);text_layer_classPrivateFieldInitSpec(this,qn,null);text_layer_classPrivateFieldInitSpec(this,Yn,0);text_layer_classPrivateFieldInitSpec(this,Zn,0);text_layer_classPrivateFieldInitSpec(this,Qn,Object.create(null));text_layer_classPrivateFieldInitSpec(this,Jn,[]);text_layer_classPrivateFieldInitSpec(this,er,null);text_layer_classPrivateFieldInitSpec(this,tr,[]);text_layer_classPrivateFieldInitSpec(this,ir,new WeakMap);text_layer_classPrivateFieldInitSpec(this,ar,null);if(e instanceof ReadableStream)text_layer_classPrivateFieldSet(er,this,e);else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');text_layer_classPrivateFieldSet(er,this,new ReadableStream({start(t){t.enqueue(e);t.close()}}))}text_layer_classPrivateFieldSet(Wn,this,text_layer_classPrivateFieldSet(qn,this,i));text_layer_classPrivateFieldSet(Un,this,t);text_layer_classPrivateFieldSet(Zn,this,a.scale*OutputScale.pixelRatio);text_layer_classPrivateFieldSet(Yn,this,a.rotation);text_layer_classPrivateFieldSet(Hn,this,{div:null,properties:null,ctx:null});const{pageWidth:s,pageHeight:n,pageX:r,pageY:o}=a.rawDims;text_layer_classPrivateFieldSet(ar,this,[1,0,0,-1,-r,o+n]);text_layer_classPrivateFieldSet(Kn,this,s);text_layer_classPrivateFieldSet($n,this,n);_ensureMinFontSizeComputed.call(TextLayer);i.style.setProperty("--min-font-size",dr._);setLayerDimensions(i,a);text_layer_classPrivateFieldGet(On,this).promise.finally(()=>{cr._.delete(this);text_layer_classPrivateFieldSet(Hn,this,null);text_layer_classPrivateFieldSet(Qn,this,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:e,isFirefox:t}=FeatureTest.platform;return shadow(this,"fontFamilyMap",new Map([["sans-serif",(e&&t?"Calibri, ":"")+"sans-serif"],["monospace",(e&&t?"Lucida Console, ":"")+"monospace"]]))}render(){text_layer_classPrivateFieldGet(Un,this)&&text_layer_classPrivateFieldGet(Wn,this).append(text_layer_classPrivateFieldGet(Un,this).render());const pump=()=>{text_layer_classPrivateFieldGet(Xn,this).read().then(({value:e,done:t})=>{if(t)text_layer_classPrivateFieldGet(On,this).resolve();else{text_layer_classPrivateFieldGet(zn,this)??text_layer_classPrivateFieldSet(zn,this,e.lang);Object.assign(text_layer_classPrivateFieldGet(Qn,this),e.styles);text_layer_assertClassBrand(sr,this,_processItems).call(this,e.items);pump()}},text_layer_classPrivateFieldGet(On,this).reject)};text_layer_classPrivateFieldSet(Xn,this,text_layer_classPrivateFieldGet(er,this).getReader());cr._.add(this);pump();return text_layer_classPrivateFieldGet(On,this).promise}update({viewport:e,onBefore:t=null}){const i=e.scale*OutputScale.pixelRatio,a=e.rotation;if(a!==text_layer_classPrivateFieldGet(Yn,this)){t?.();text_layer_classPrivateFieldSet(Yn,this,a);setLayerDimensions(text_layer_classPrivateFieldGet(qn,this),{rotation:a})}if(i!==text_layer_classPrivateFieldGet(Zn,this)){t?.();text_layer_classPrivateFieldSet(Zn,this,i);const e={div:null,properties:null,ctx:_getCtx.call(TextLayer,text_layer_classPrivateFieldGet(zn,this))};for(const t of text_layer_classPrivateFieldGet(tr,this)){e.properties=text_layer_classPrivateFieldGet(ir,this).get(t);e.div=t;text_layer_assertClassBrand(sr,this,_layout).call(this,e)}}}cancel(){const e=new AbortException("TextLayer task cancelled.");text_layer_classPrivateFieldGet(Xn,this)?.cancel(e).catch(()=>{});text_layer_classPrivateFieldSet(Xn,this,null);text_layer_classPrivateFieldGet(On,this).reject(e)}get textDivs(){return text_layer_classPrivateFieldGet(tr,this)}get textContentItemsStr(){return text_layer_classPrivateFieldGet(Jn,this)}static cleanup(){if(!(text_layer_assertClassBrand(TextLayer,this,cr)._.size>0)){text_layer_assertClassBrand(TextLayer,this,rr)._.clear();for(const{canvas:e}of text_layer_assertClassBrand(TextLayer,this,or)._.values())e.remove();text_layer_assertClassBrand(TextLayer,this,or)._.clear()}}}Nn=TextLayer;function _processItems(e){if(text_layer_classPrivateFieldGet(jn,this))return;text_layer_classPrivateFieldGet(Hn,this).ctx??=_getCtx.call(Nn,text_layer_classPrivateFieldGet(zn,this));const t=text_layer_classPrivateFieldGet(tr,this),i=text_layer_classPrivateFieldGet(Jn,this);for(const a of e){if(t.length>1e5){warn("Ignoring additional textDivs for performance reasons.");text_layer_classPrivateFieldSet(jn,this,!0);return}if(void 0!==a.str){i.push(a.str);text_layer_assertClassBrand(sr,this,_appendText).call(this,a)}else if("beginMarkedContentProps"===a.type||"beginMarkedContent"===a.type){const e=text_layer_classPrivateFieldGet(Wn,this);text_layer_classPrivateFieldSet(Wn,this,document.createElement("span"));text_layer_classPrivateFieldGet(Wn,this).classList.add("markedContent");a.id&&text_layer_classPrivateFieldGet(Wn,this).setAttribute("id",a.id);"Artifact"===a.tag&&(text_layer_classPrivateFieldGet(Wn,this).ariaHidden=!0);e.append(text_layer_classPrivateFieldGet(Wn,this))}else"endMarkedContent"===a.type&&text_layer_classPrivateFieldSet(Wn,this,text_layer_classPrivateFieldGet(Wn,this).parentNode)}}function _appendText(e){const t=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};text_layer_classPrivateFieldGet(tr,this).push(t);const a=Util.transform(text_layer_classPrivateFieldGet(ar,this),e.transform);let s=Math.atan2(a[1],a[0]);const n=text_layer_classPrivateFieldGet(Qn,this)[e.fontName];n.vertical&&(s+=Math.PI/2);let r=text_layer_classPrivateFieldGet(Vn,this)&&n.fontSubstitution||n.fontFamily;r=Nn.fontFamilyMap.get(r)||r;const o=Math.hypot(a[2],a[3]),l=o*_getAscent.call(Nn,r,n,text_layer_classPrivateFieldGet(zn,this));let d,c;if(0===s){d=a[4];c=a[5]-l}else{d=a[4]+l*Math.sin(s);c=a[5]-l*Math.cos(s)}const h=t.style;h.left=`${(100*d/text_layer_classPrivateFieldGet(Kn,this)).toFixed(2)}%`;h.top=`${(100*c/text_layer_classPrivateFieldGet($n,this)).toFixed(2)}%`;h.setProperty("--font-height",`${o.toFixed(2)}px`);h.fontFamily=r;i.fontSize=o;t.setAttribute("role","presentation");t.textContent=e.str;t.dir=e.dir;text_layer_classPrivateFieldGet(Vn,this)&&(t.dataset.fontName=n.fontSubstitutionLoadedName||e.fontName);0!==s&&(i.angle=s*(180/Math.PI));let u=!1;if(e.str.length>1)u=!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&&(u=!0)}u&&(i.canvasWidth=n.vertical?e.height:e.width);text_layer_classPrivateFieldGet(ir,this).set(t,i);text_layer_classPrivateFieldGet(Hn,this).div=t;text_layer_classPrivateFieldGet(Hn,this).properties=i;text_layer_assertClassBrand(sr,this,_layout).call(this,text_layer_classPrivateFieldGet(Hn,this));i.hasText&&text_layer_classPrivateFieldGet(Wn,this).append(t);if(i.hasEOL){const e=document.createElement("br");e.setAttribute("role","presentation");text_layer_classPrivateFieldGet(Wn,this).append(e)}}function _layout(e){const{div:t,properties:i,ctx:a}=e,{style:s}=t;if(0!==i.canvasWidth&&i.hasText){const{fontFamily:e}=s,{canvasWidth:n,fontSize:r}=i;_ensureCtxFont.call(Nn,a,r*text_layer_classPrivateFieldGet(Zn,this),e);try{const{width:e}=a.measureText(t.textContent);e>0&&(transform=`scaleX(${n*text_layer_classPrivateFieldGet(Zn,this)/e}) ${transform}`)}catch(e){}const{width:o}=a.measureText(t.textContent);o>0&&s.setProperty("--scale-x",n*text_layer_classPrivateFieldGet(Zn,this)/o)}0!==i.angle&&s.setProperty("--rotate",`${i.angle}deg`)}function _getCtx(e=null){let t=text_layer_assertClassBrand(Nn,this,or)._.get(e||="");if(!t){const i=document.createElement("canvas");i.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none;letter-spacing:normal;word-spacing:normal";i.lang=e;i.width=i.height=0;document.body.append(i);t=i.getContext("2d",{alpha:!1,willReadFrequently:!0});text_layer_assertClassBrand(Nn,this,or)._.set(e,t);text_layer_assertClassBrand(Nn,this,lr)._.set(t,{size:0,family:""})}return t}function _ensureCtxFont(e,t,i){const a=text_layer_assertClassBrand(Nn,this,lr)._.get(e);if(t!==a.size||i!==a.family){e.font=`${t}px ${i}`;a.size=t;a.family=i}}function _ensureMinFontSizeComputed(){if(null!==text_layer_assertClassBrand(Nn,this,dr)._)return;const e=document.createElement("div");e.style.opacity=0;e.style.lineHeight=1;e.style.fontSize="1px";e.style.position="absolute";e.textContent="X";document.body.append(e);dr._=text_layer_assertClassBrand(Nn,this,e.getBoundingClientRect().height);e.remove()}function _getAscent(e,t,i){const a=text_layer_assertClassBrand(Nn,this,rr)._.get(e);if(a)return a;const s=text_layer_assertClassBrand(Nn,this,_getCtx).call(this,i);s.canvas.width=s.canvas.height=30;text_layer_assertClassBrand(Nn,this,_ensureCtxFont).call(this,s,30,e);const n=s.measureText(""),r=n?.fontBoundingBoxAscent,o=Math.abs(n?.fontBoundingBoxDescent);s.canvas.width=s.canvas.height=0;let l=.8;if(r)l=r/(r+o);else{FeatureTest.platform.isFirefox&&warn("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering.");t.ascent?l=t.ascent:t.descent&&(l=1+t.descent)}text_layer_assertClassBrand(Nn,this,rr)._.set(e,l);return l}var nr,rr={_:new Map},or={_:new Map},lr={_:new WeakMap},dr={_:null},cr={_:new Set};function app_options_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}{var hr=new Map;const{maxTouchPoints:e,platform:t,userAgent:i}=navigator,a=/Android/.test(i);(/\b(?:iPad|iPhone|iPod)(?=;)/.test(i)||"MacIntel"===t&&e>1||a)&&hr.set("maxCanvasPixels",5242880);a&&hr.set("useSystemFonts",!1)}const ur=1,_r=2,pr=4,gr=8,mr=16,fr=128,vr={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},Pr=new Map([["allowedGlobalEvents",{value:null,kind:ur}],["canvasMaxAreaInBytes",{value:-1,kind:ur+pr}],["isInAutomation",{value:!1,kind:ur}],["localeProperties",{value:{lang:navigator.language||"en-US"},kind:ur}],["maxCanvasDim",{value:32767,kind:ur+_r}],["nimbusDataStr",{value:"",kind:ur}],["supportsCaretBrowsingMode",{value:!1,kind:ur}],["supportsDocumentFonts",{value:!0,kind:ur}],["supportsDownloading",{value:!0,kind:ur}],["supportsIntegratedFind",{value:!1,kind:ur}],["supportsMouseWheelZoomCtrlKey",{value:!0,kind:ur}],["supportsMouseWheelZoomMetaKey",{value:!0,kind:ur}],["supportsPinchToZoom",{value:!0,kind:ur}],["supportsPrinting",{value:!0,kind:ur}],["toolbarDensity",{value:0,kind:ur+mr}],["defaultCacheSize",{value:50,kind:_r}],["passwordPrompt",{value:null,kind:_r}],["enableDragAndDrop",{value:!0,kind:_r}],["pageViewMode",{value:"multiple",kind:_r}],["findController",{value:null,kind:_r}],["secondaryFindController",{value:null,kind:_r}],["maxZoom",{value:10,kind:_r}],["minZoom",{value:.1,kind:_r}],["pdfBackgroundColor",{value:"",kind:_r+fr}],["removePageBorders",{value:!1,kind:_r+fr}],["readingDirection",{value:"auto",kind:_r+fr}],["enablePageReordering",{value:!0,kind:_r+fr}],["altTextLearnMoreUrl",{value:"",kind:_r+fr}],["annotationEditorMode",{value:0,kind:_r+fr}],["annotationMode",{value:2,kind:_r+fr}],["capCanvasAreaFactor",{value:200,kind:_r+fr}],["commentLearnMoreUrl",{value:"",kind:_r+fr}],["cursorToolOnLoad",{value:0,kind:_r+fr}],["debuggerSrc",{value:"./debugger.mjs",kind:_r}],["defaultUrl",{value:"compressed.tracemonkey-pldi-09.pdf",kind:_r}],["defaultZoomDelay",{value:400,kind:_r+fr}],["defaultZoomValue",{value:"auto",kind:_r+fr}],["disableHistory",{value:!1,kind:_r}],["disablePageLabels",{value:!1,kind:_r+fr}],["disablePreferences",{value:!1,kind:_r}],["enableAltText",{value:!1,kind:_r+fr}],["enableAltTextModelDownload",{value:!0,kind:_r+fr+mr}],["enableAutoLinking",{value:!0,kind:_r+fr}],["enableComment",{value:!1,kind:_r+fr}],["enableDetailCanvas",{value:!0,kind:_r}],["enableGuessAltText",{value:!0,kind:_r+fr+mr}],["enableHighlightFloatingButton",{value:!1,kind:_r+fr}],["enableMerge",{value:!1,kind:_r+fr}],["enableNewAltTextWhenAddingImage",{value:!0,kind:_r+fr}],["enableNewBadge",{value:!1,kind:_r+fr}],["enableOptimizedPartialRendering",{value:!1,kind:_r+fr}],["enablePermissions",{value:!1,kind:_r+fr}],["enablePrintAutoRotate",{value:!0,kind:_r+fr}],["enableScripting",{value:!1,kind:_r+fr}],["enableSelectionRendering",{value:!0,kind:_r+fr}],["enableSignatureEditor",{value:!1,kind:_r+fr}],["enableSignatureVerification",{value:!1,kind:_r+fr}],["enableSplitMerge",{value:!1,kind:_r+fr}],["enableUpdatedAddImage",{value:!1,kind:_r+fr}],["externalLinkRel",{value:"noopener noreferrer nofollow",kind:_r}],["externalLinkTarget",{value:0,kind:_r+fr}],["highlightEditorColors",{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F,yellow_HCM=#FFFFCC,green_HCM=#53FFBC,blue_HCM=#80EBFF,pink_HCM=#F6B8FF,red_HCM=#C50043",kind:_r+fr}],["historyUpdateUrl",{value:!1,kind:_r+fr}],["ignoreDestinationZoom",{value:!1,kind:_r+fr}],["imageResourcesPath",{value:"./images/",kind:_r}],["imagesRightClickMinSize",{value:-1,kind:_r+fr}],["maxCanvasPixels",{value:2**25,kind:_r}],["minDurationToUpdateCanvas",{value:500,kind:_r}],["forcePageColors",{value:!1,kind:_r+fr}],["pageColorsBackground",{value:"Canvas",kind:_r+fr}],["pageColorsForeground",{value:"CanvasText",kind:_r+fr}],["pdfBugEnabled",{value:!1,kind:_r+fr}],["postMessageAfterPrintCallback",{value:!1,kind:_r+fr}],["printResolution",{value:150,kind:_r}],["sandboxBundleSrc",{value:"../build/pdf.sandbox.mjs",kind:_r}],["sidebarViewOnLoad",{value:-1,kind:_r+fr}],["scrollModeOnLoad",{value:-1,kind:_r+fr}],["spreadModeOnLoad",{value:-1,kind:_r+fr}],["textLayerMode",{value:1,kind:_r+fr}],["viewerCssTheme",{value:0,kind:_r+fr}],["viewOnLoad",{value:0,kind:_r+fr}],["useWasm",{value:!0,kind:pr}],["cMapPacked",{value:!0,kind:pr}],["cMapUrl",{value:"../web/cmaps/",kind:pr}],["disableAutoFetch",{value:!1,kind:pr+fr}],["disableFontFace",{value:!1,kind:pr+fr}],["disableRange",{value:!1,kind:pr+fr}],["disableStream",{value:!1,kind:pr+fr}],["docBaseUrl",{value:"",kind:pr}],["enableHWA",{value:!0,kind:pr+fr}],["enableWebGPU",{value:!0,kind:pr+fr}],["enableXfa",{value:!0,kind:pr+fr}],["fontExtraProperties",{value:!1,kind:pr}],["iccUrl",{value:"../web/iccs/",kind:pr}],["isOffscreenCanvasSupported",{value:!0,kind:pr}],["maxImageSize",{value:-1,kind:pr}],["pdfBug",{value:!1,kind:pr}],["standardFontDataUrl",{value:"../web/standard_fonts/",kind:pr}],["useSystemFonts",{value:void 0,kind:pr,type:vr.BOOLEAN+vr.UNDEFINED}],["verbosity",{value:1,kind:pr}],["wasmUrl",{value:"../web/wasm/",kind:pr}],["enableOpenActionJavaScript",{value:!1,kind:gr}],["enableCatalogAAJavaScript",{value:!1,kind:gr}],["workerPort",{value:null,kind:gr}],["workerSrc",{value:"../build/pdf.worker.mjs",kind:gr}]]);class AppOptions{static get(e){return app_options_assertClassBrand(AppOptions,this,yr)._.get(e)}static getAll(e=null,t=!1){const i=Object.create(null);for(const[a,s]of Pr)(!e||e&s.kind)&&(i[a]=t?s.value:app_options_assertClassBrand(AppOptions,this,yr)._.get(a));return i}static set(e,t){this.setAll({[e]:t})}static setAll(e,t=!1){this._hasInvokedSet||=!0;let i;for(const a in e){if("positionPopupDialogsWithJavaScript"===a)continue;const s=Pr.get(a);let n=e[a];if(s&&!(typeof n==typeof s.value||vr[(typeof n).toUpperCase()]&s.type)){"number"==typeof s?.value&&"string"==typeof n&&(Number.isNaN(Number(n))||(n=Number(n)));if(!(typeof n==typeof s.value||vr[(typeof n).toUpperCase()]&s.type||["maxZoom","minZoom","passwordPrompt","defaultZoomValue","findController","pdfBackgroundColor"].includes(a))){console.error("Invalid AppOptions value: "+a+" = "+n);continue}}const r=s?.kind;if(!t||r&ur||r&fr){this.eventBus&&r&mr&&(i||=new Map).set(a,n);app_options_assertClassBrand(AppOptions,this,yr)._.set(a,n)}else console.error("Invalid AppOptions parameter: "+a+" = "+n)}if(i)for(const[e,t]of i)this.eventBus.dispatch(e.toLowerCase(),{source:this,value:t})}}nr=AppOptions;!function app_options_defineProperty(e,t,i){return(t=function app_options_toPropertyKey(e){var t=function app_options_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(AppOptions,"eventBus",void 0);var wr,Fr,br,yr={_:new Map};(()=>{for(const[e,t]of Pr)app_options_assertClassBrand(nr,nr,yr)._.set(e,t.value);for(const[e,t]of hr)app_options_assertClassBrand(nr,nr,yr)._.set(e,t);nr._hasInvokedSet=!1;nr._checkDisablePreferences=()=>{if(nr.get("disablePreferences"))return!0;nr._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.');return!1}})();function api_classPrivateGetter(e,t,i){return i(api_assertClassBrand(e,t))}function api_classPrivateMethodInitSpec(e,t){api_checkPrivateRedeclaration(e,t),t.add(e)}function api_classPrivateFieldInitSpec(e,t,i){api_checkPrivateRedeclaration(e,t),t.set(e,i)}function api_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function api_classPrivateFieldSet(e,t,i){return e.set(api_assertClassBrand(e,t),i),i}function api_classPrivateFieldGet(e,t){return e.get(api_assertClassBrand(e,t))}function api_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function api_defineProperty(e,t,i){return(t=function api_toPropertyKey(e){var t=function api_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function getDocument(e={}){const i=new PDFDocumentLoadingTask,{docId:a}=i,s=e.url?function getUrlProp(e,i){if(e instanceof URL)return e;if("string"==typeof e){if(t){if(/^[a-z][a-z0-9\-+.]+:/i.test(e))return new URL(e);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(e))}if(i)return new URL(e,window.location.origin+i);const a=URL.parse(e,window.location);if(a)return a}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(e.url,e.baseHref):null,n=e.data?function getDataProp(e){if(t&&"undefined"!=typeof Buffer&&e instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return stringToBytes(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||"object"==typeof e&&!isNaN(e?.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(e.data):null,r=e.httpHeaders||null,o=!0===e.withCredentials,l=e.password??null,d=e.range instanceof PDFDataRangeTransport?e.range:null,c=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:65536;let h=e.worker instanceof PDFWorker?e.worker:null;const u=e.verbosity,_="string"!=typeof e.docBaseUrl||isDataScheme(e.docBaseUrl)?null:e.docBaseUrl,p=getFactoryUrlProp("function"==typeof e.cMapUrl?e.cMapUrl():"string"==typeof e.cMapUrl?e.cMapUrl:null),g=!1!==e.cMapPacked,m=getFactoryUrlProp(e.iccUrl),f=getFactoryUrlProp("function"==typeof e.standardFontDataUrl?e.standardFontDataUrl():"string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null),v=getFactoryUrlProp(e.wasmUrl),P=!0!==e.stopAtErrors,w=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,F="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!t,b="boolean"==typeof e.isImageDecoderSupported?e.isImageDecoderSupported:!t,y=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,S="boolean"==typeof e.disableFontFace?e.disableFontFace:t,C=!0===e.fontExtraProperties,x=!0===e.enableXfa,k=e.ownerDocument||globalThis.document,E=!0===e.disableRange,A=!0===e.disableStream,G=!0===e.disableAutoFetch,B=!0===e.pdfBug,M=e.CanvasFactory||(t?NodeCanvasFactory:DOMCanvasFactory),I=e.FilterFactory||(t?NodeFilterFactory:DOMFilterFactory),T=e.BinaryDataFactory||(t?NodeBinaryDataFactory:DOMBinaryDataFactory),D=!0===e.enableHWA,L=!0===e.enableWebGPU?function initGPU(){return Is.init()}():Promise.resolve(!1),N=!1!==e.useWasm,R=e.pagesMapper||new PagesMapper,O="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!t&&!S,W="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:!!(T===DOMBinaryDataFactory&&p&&g&&f&&v&&isValidFetchUrl(p,document.baseURI)&&isValidFetchUrl(f,document.baseURI)&&isValidFetchUrl(v,document.baseURI));setVerbosityLevel(u);const j={canvasFactory:new M({ownerDocument:k,enableHWA:D}),filterFactory:new I({docId:a,ownerDocument:k}),binaryDataFactory:W?null:new T({cMapUrl:p,standardFontDataUrl:f,wasmUrl:v})};if(!h){const t={verbosity:u,port:GlobalWorkerOptions.workerPort,cspPolicyService:e.cspPolicyService};h=PDFWorker.create(t);i._worker=h}const V={docId:a,apiVersion:"6.2.1097",data:n,password:l,disableAutoFetch:G,rangeChunkSize:c,docBaseUrl:_,enableXfa:x,enableOpenActionJavaScript:AppOptions.get("enableOpenActionJavaScript"),enableCatalogAAJavaScript:AppOptions.get("enableCatalogAAJavaScript"),evaluatorOptions:{maxImageSize:w,disableFontFace:S,ignoreErrors:P,isOffscreenCanvasSupported:F,isImageDecoderSupported:b,canvasMaxAreaInBytes:y,fontExtraProperties:C,useSystemFonts:O,useWasm:N,useWorkerFetch:W,cMapUrl:p,cMapPacked:g,iccUrl:m,standardFontDataUrl:f,wasmUrl:v,hasGPU:!1}},U={ownerDocument:k,pdfBug:B,styleElement:null,enableHWA:D,loadingParams:{disableAutoFetch:G,enableXfa:x}};Promise.all([h.promise,L]).then(function([,e]){if(h.destroyed)throw new Error("Worker was destroyed");V.evaluatorOptions.hasGPU=e;const l=h.messageHandler.sendWithPromise("GetDocRequest",V,n?[n.buffer]:null);let u;if(n);else if(d)u=new PDFDataTransportStream({pdfDataRangeTransport:d,disableRange:E,disableStream:A});else{if(!s)throw new Error("getDocument - expected either `data`, `range`, or `url` parameter.");{const e=function getNetworkStream(e){return isValidFetchUrl(e)?PDFFetchStream:t?PDFNodeStream:PDFNetworkStream}(s);u=new e({url:s,httpHeaders:r,withCredentials:o,rangeChunkSize:c,disableRange:E,disableStream:A})}}return l.then(e=>{if(h.destroyed)throw new Error("Worker was destroyed");const t=new MessageHandler(a,e,h.port),s=new WorkerTransport(t,i,u,U,j,R);i._transport=s;if(i.destroyed)throw new Error("Loading aborted");t.send("Ready",null)})}).catch(i._capability.reject).finally(i._setupCapability.resolve);return i}class PDFDocumentLoadingTask{constructor(){api_defineProperty(this,"_capability",Promise.withResolvers());api_defineProperty(this,"_setupCapability",Promise.withResolvers());api_defineProperty(this,"_transport",null);api_defineProperty(this,"_worker",null);api_defineProperty(this,"docId",`d${Sr._=(wr=Sr._,Fr=wr++,wr),Fr}`);api_defineProperty(this,"destroyed",!1);api_defineProperty(this,"onPassword",null);api_defineProperty(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;this._capability.promise.catch(()=>{});try{this._worker?.port&&(this._worker._pendingDestroy=!0);await this._setupCapability.promise;await(this._transport?.destroy())}catch(e){this._worker?.port&&delete this._worker._pendingDestroy;throw e}this._transport=null;this._worker?.destroy();this._worker=null}async getData(){return this._transport.getData()}}var Sr={_:0},Cr=new WeakMap,xr=new WeakMap;class PDFDataRangeTransport{constructor(e,t,i=!1,a=null){api_classPrivateFieldInitSpec(this,Cr,Promise.withResolvers());api_classPrivateFieldInitSpec(this,xr,null);this.length=e;this.initialData=t;this.progressiveDone=i;this.contentDispositionFilename=a}onDataRange(e,t){api_classPrivateFieldGet(xr,this).call(this,{type:"range",begin:e,chunk:t})}onDataProgressiveRead(e){api_classPrivateFieldGet(Cr,this).promise.then(()=>{api_classPrivateFieldGet(xr,this).call(this,{type:"progressiveRead",chunk:e})})}onDataProgressiveDone(){api_classPrivateFieldGet(Cr,this).promise.then(()=>{api_classPrivateFieldGet(xr,this).call(this,{type:"progressiveDone"})})}transportReady(e){api_classPrivateFieldSet(xr,this,e);api_classPrivateFieldGet(Cr,this).resolve()}requestDataRange(e,t){unreachable("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class PDFDocumentProxy{constructor(e,t){this._pdfInfo=e;this._transport=t}get pagesMapper(){return this._transport.pagesMapper}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return shadow(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAttachmentContent(e){return this._transport.getAttachmentContent(e)}getAnnotationsByType(e,t){return this._transport.getAnnotationsByType(e,t)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(e=null){return this._transport.saveDocument(e)}extractPages(e){return this._transport.extractPages(e)}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getRawData(e){return this._transport.getRawData(e)}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}getSignatures(){return this._transport.getSignatures()}getSignatureData(e){return this._transport.getSignatureData(e)}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var kr=new WeakMap,Er=new WeakMap,Ar=new WeakSet;class PDFPageProxy{constructor(e,t,i,a,s=!1){api_classPrivateMethodInitSpec(this,Ar);api_classPrivateFieldInitSpec(this,kr,!1);api_classPrivateFieldInitSpec(this,Er,null);this._pageIndex=e;this._pageInfo=t;this._transport=i;this._stats=s?new StatTimer:null;this._pdfBug=s;this.commonObjs=i.commonObjs;this.objs=new PDFObjects;this._intentStates=new Map;this.destroyed=!1;this.recordedBBoxes=null;api_classPrivateFieldSet(Er,this,a);this.imageCoordinates=null}clone(e){const t=new PDFPageProxy(e,this._pageInfo,this._transport,api_classPrivateFieldGet(Er,this),this._pdfBug);t.clonedFromIndex=this.clonedFromIndex??this._pageIndex;this._transport.updatePage(t);return t}get pageNumber(){return this._pageIndex+1}set pageNumber(e){this._pageIndex=e-1;this._transport.updatePage(this)}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:i=0,offsetY:a=0,dontFlip:s=!1}={}){return new PageViewport({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:i,offsetY:a,dontFlip:s})}getAnnotations({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return shadow(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,canvas:t=e.canvas,viewport:i,intent:a="display",annotationMode:s=p.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:o=null,annotationCanvasMap:d=null,pageColors:c=null,printAnnotationStorage:h=null,isEditing:u=!1,recordImages:_=!1,recordOperations:g=!1,operationsFilter:m=null}){this._stats?.time("Overall");const f=this._transport.getRenderingIntent(a,s,h,u),{renderingIntent:v,cacheKey:P}=f;api_classPrivateFieldSet(kr,this,!1);o||=this._transport.getOptionalContentConfig(v);const w=this._intentStates.getOrInsertComputed(P,makeObj);if(w.streamReaderCancelTimeout){clearTimeout(w.streamReaderCancelTimeout);w.streamReaderCancelTimeout=null}const F=!!(v&l);if(!w.displayReadyCapability){w.displayReadyCapability=Promise.withResolvers();w.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(f)}const b=!(!this._pdfBug||!globalThis.StepperManager?.enabled),y=!!t&&!this.recordedBBoxes&&(g||b),S=!!t&&!this.imageCoordinates&&_,complete=e=>{w.renderTasks.delete(k);if(y){const e=k.gfx?.dependencyTracker.take();if(e){k.stepper?.setOperatorBBoxes(e,k.gfx.dependencyTracker.takeDebugMetadata());g&&(this.recordedBBoxes=e)}}S&&!e&&(this.imageCoordinates=k.gfx?.imagesTracker.take());F&&api_classPrivateFieldSet(kr,this,!0);api_assertClassBrand(Ar,this,_tryCleanup).call(this);if(e){k.capability.reject(e);this._abortOperatorList({intentState:w,reason:e instanceof Error?e:new Error(e)})}else k.capability.resolve();if(this._stats){this._stats.timeEnd("Rendering");this._stats.timeEnd("Overall");globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats)}};let C=null,x=null;(y||S)&&(x=new CanvasBBoxTracker(t,w.operatorList.length));y&&(C=new CanvasDependencyTracker(x,b));const k=new InternalRenderTask({callback:complete,params:{canvas:t,canvasContext:e,dependencyTracker:C??x,imagesTracker:S?new CanvasImagesTracker(t):null,viewport:i,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:d,operatorList:w.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!F,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,operationsFilter:m});(w.renderTasks||=new Set).add(k);const E=k.task;Promise.all([w.displayReadyCapability.promise,o]).then(([e,t])=>{if(this.destroyed)complete();else{this._stats?.time("Rendering");if(!(t.renderingIntent&v))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");k.initializeGraphics({transparency:e,optionalContentConfig:t});k.operatorListChanged()}}).catch(complete);return E}getOperatorList({intent:e="display",annotationMode:t=p.ENABLE,printAnnotationStorage:i=null,isEditing:a=!1}={}){const s=this._transport.getRenderingIntent(e,t,i,a,!0),n=this._intentStates.getOrInsertComputed(s.cacheKey,makeObj);let r;if(!n.opListReadCapability){r=Object.create(null);r.operatorListChanged=function operatorListChanged(){if(n.operatorList.lastChunk){n.opListReadCapability.resolve(n.operatorList);n.renderTasks.delete(r)}};n.opListReadCapability=Promise.withResolvers();(n.renderTasks||=new Set).add(r);n.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(s)}return n.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageId:api_classPrivateFieldGet(Er,this).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}async getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then(e=>XfaText.textContent(e));const t=this.streamTextContent(e),i={items:[],styles:Object.create(null),lang:null},a=t.getReader();try{for(;;){const{value:e,done:t}=await a.read();if(t)break;i.lang??=e.lang;Object.assign(i.styles,e.styles);i.items.push(...e.items)}}finally{a.releaseLock()}return i}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values()){this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0});if(!t.opListReadCapability)for(const i of t.renderTasks){e.push(i.completed);i.cancel()}}this.objs.clear();api_classPrivateFieldSet(kr,this,!1);return Promise.all(e)}cleanup(e=!1){api_classPrivateFieldSet(kr,this,!0);const t=api_assertClassBrand(Ar,this,_tryCleanup).call(this);e&&t&&(this._stats&&=new StatTimer);return t}_startRenderPage(e,t){const i=this._intentStates.get(t);if(i){this._stats?.timeEnd("Page Request");i.displayReadyCapability?.resolve(e)}}_renderPageChunk(e,t){for(let i=0,a=e.length;i<a;i++){t.operatorList.fnArray.push(e.fnArray[i]);t.operatorList.argsArray.push(e.argsArray[i])}t.operatorList.lastChunk=e.lastChunk;t.operatorList.separateAnnots=e.separateAnnots;for(const e of t.renderTasks)e.operatorListChanged();e.lastChunk&&api_assertClassBrand(Ar,this,_tryCleanup).call(this)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:i,modifiedIds:a}){const{map:s,transfer:n}=i,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageId:api_classPrivateFieldGet(Er,this).getPageId(this._pageIndex+1)-1,pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:s,modifiedIds:a},void 0,n).getReader(),o=this._intentStates.get(t);o.streamReader=r;const pump=()=>{r.read().then(({value:e,done:t})=>{if(t)o.streamReader=null;else if(!this._transport.destroyed){this._renderPageChunk(e,o);pump()}},e=>{o.streamReader=null;if(!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const e of o.renderTasks)e.operatorListChanged();api_assertClassBrand(Ar,this,_tryCleanup).call(this)}if(o.displayReadyCapability)o.displayReadyCapability.reject(e);else{if(!o.opListReadCapability)throw e;o.opListReadCapability.reject(e)}}})};pump()}_abortOperatorList({intentState:e,reason:t,force:i=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout){clearTimeout(e.streamReaderCancelTimeout);e.streamReaderCancelTimeout=null}if(!i){if(e.renderTasks.size>0)return;if(t instanceof RenderingCancelledException){let i=100;t.extraDelay>0&&t.extraDelay<1e3&&(i+=t.extraDelay);e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null;this._abortOperatorList({intentState:e,reason:t,force:!0})},i);return}}e.streamReader.cancel(new AbortException(t.message)).catch(()=>{});e.streamReader=null;if(!this._transport.destroyed){for(const[t,i]of this._intentStates)if(i===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}function _tryCleanup(){if(!api_classPrivateFieldGet(kr,this)||this.destroyed)return!1;for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;this._intentStates.clear();this.objs.clear();api_classPrivateFieldSet(kr,this,!1);return!0}var Gr=new WeakMap,Br=new WeakMap,Mr=new WeakMap,Ir=new WeakMap,Tr=new WeakSet;class PDFWorker{constructor({name:e=null,port:t=null,verbosity:i=getVerbosityLevel(),cspPolicyService:a}={}){api_classPrivateMethodInitSpec(this,Tr);api_classPrivateFieldInitSpec(this,Gr,Promise.withResolvers());api_classPrivateFieldInitSpec(this,Br,null);api_classPrivateFieldInitSpec(this,Mr,null);api_classPrivateFieldInitSpec(this,Ir,null);this.name=e;this.destroyed=!1;this.verbosity=i;if(t){if(Nr._.has(t))throw new Error("Cannot use more than one PDFWorker per port.");Nr._.set(t,this);api_assertClassBrand(Tr,this,_initializeFromPort).call(this,t)}else this._initialize(a)}get promise(){return api_classPrivateFieldGet(Gr,this).promise}get port(){return api_classPrivateFieldGet(Mr,this)}get messageHandler(){return api_classPrivateFieldGet(Br,this)}_initialize(e){if(Lr._||_get_mainThreadWorkerMessageHandler(PDFWorker)){api_assertClassBrand(Tr,this,_setupFakeWorker).call(this);return}let{workerSrc:t}=PDFWorker;try{PDFWorker._isSameOrigin(window.location,t)||(t=PDFWorker._createCDNWrapper(new URL(t,window.location).href));const i=new Worker(e.generateTrustedURL(t),{type:"module"}),a=new MessageHandler("main","worker",i),terminateEarly=()=>{s.abort();a.destroy();i.terminate();this.destroyed?api_classPrivateFieldGet(Gr,this).reject(new Error("Worker was destroyed")):api_assertClassBrand(Tr,this,_setupFakeWorker).call(this)},s=new AbortController;i.addEventListener("error",()=>{api_classPrivateFieldGet(Ir,this)||terminateEarly()},{signal:s.signal});a.on("test",e=>{s.abort();if(!this.destroyed&&e){api_classPrivateFieldSet(Br,this,a);api_classPrivateFieldSet(Mr,this,i);api_classPrivateFieldSet(Ir,this,i);api_assertClassBrand(Tr,this,_resolve).call(this)}else terminateEarly()});a.on("ready",e=>{s.abort();if(this.destroyed)terminateEarly();else try{sendTest()}catch{api_assertClassBrand(Tr,this,_setupFakeWorker).call(this)}});const sendTest=()=>{const e=new Uint8Array;a.send("test",e,[e.buffer])};sendTest();return}catch{info("The worker has been disabled.")}api_assertClassBrand(Tr,this,_setupFakeWorker).call(this)}destroy(){this.destroyed=!0;api_classPrivateFieldGet(Ir,this)?.terminate();api_classPrivateFieldSet(Ir,this,null);Nr._.delete(api_classPrivateFieldGet(Mr,this));api_classPrivateFieldSet(Mr,this,null);api_classPrivateFieldGet(Br,this)?.destroy();api_classPrivateFieldSet(Br,this,null)}static create(e){const t=api_assertClassBrand(PDFWorker,this,Nr)._.get(e?.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new PDFWorker(e)}static get workerSrc(){if(GlobalWorkerOptions.workerSrc)return GlobalWorkerOptions.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return shadow(this,"_setupFakeWorkerGlobal",(async()=>{if(api_classPrivateGetter(PDFWorker,this,_get_mainThreadWorkerMessageHandler))return api_classPrivateGetter(PDFWorker,this,_get_mainThreadWorkerMessageHandler);return(await import(
/*webpackIgnore: true*/
/*@vite-ignore*/
this.workerSrc)).WorkerMessageHandler})())}}br=PDFWorker;function _resolve(){api_classPrivateFieldGet(Gr,this).resolve();api_classPrivateFieldGet(Br,this).send("configure",{verbosity:this.verbosity})}function _initializeFromPort(e){api_classPrivateFieldSet(Mr,this,e);api_classPrivateFieldSet(Br,this,new MessageHandler("main","worker",e));api_classPrivateFieldGet(Br,this).on("ready",()=>{});api_assertClassBrand(Tr,this,_resolve).call(this)}function _setupFakeWorker(){if(!Lr._){warn("Setting up fake worker.");Lr._=!0}br._setupFakeWorkerGlobal.then(e=>{var t,i;if(this.destroyed){api_classPrivateFieldGet(Gr,this).reject(new Error("Worker was destroyed"));return}const a=new LoopbackPort;api_classPrivateFieldSet(Mr,this,a);const s=`fake${Dr._=(t=Dr._,i=t++,t),i}`,n=new MessageHandler(s+"_worker",s,a);e.setup(n,a);api_classPrivateFieldSet(Br,this,new MessageHandler(s,s+"_worker",a));api_assertClassBrand(Tr,this,_resolve).call(this)}).catch(e=>{api_classPrivateFieldGet(Gr,this).reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}function _get_mainThreadWorkerMessageHandler(e){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}var Dr={_:0},Lr={_:!1},Nr={_:new WeakMap};(()=>{if(t){Lr._=api_assertClassBrand(br,br,!0);GlobalWorkerOptions.workerSrc||="./pdf.worker.mjs"}br._isSameOrigin=(e,t)=>{const i=URL.parse(e);if(!i?.origin||"null"===i.origin)return!1;const a=new URL(t,i);return i.origin===a.origin};br._createCDNWrapper=e=>{const t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}})();var Rr=new WeakMap,Or=new WeakMap,Wr=new WeakMap,jr=new WeakMap,Vr=new WeakMap,Ur=new WeakMap,zr=new WeakMap,Hr=new WeakSet;class WorkerTransport{constructor(e,t,i,a,s,n){api_classPrivateMethodInitSpec(this,Hr);api_defineProperty(this,"downloadInfoCapability",Promise.withResolvers());api_classPrivateFieldInitSpec(this,Rr,null);api_classPrivateFieldInitSpec(this,Or,new Map);api_classPrivateFieldInitSpec(this,Wr,null);api_classPrivateFieldInitSpec(this,jr,new Map);api_classPrivateFieldInitSpec(this,Vr,new Map);api_classPrivateFieldInitSpec(this,Ur,new Map);api_classPrivateFieldInitSpec(this,zr,null);this.messageHandler=e;this.loadingTask=t;api_classPrivateFieldSet(Wr,this,i);this.commonObjs=new PDFObjects;this.fontLoader=new FontLoader({ownerDocument:a.ownerDocument,styleElement:a.styleElement});this.enableHWA=a.enableHWA;this.loadingParams=a.loadingParams;this._params=a;this.canvasFactory=s.canvasFactory;this.filterFactory=s.filterFactory;this.binaryDataFactory=s.binaryDataFactory;this.pagesMapper=n;this.destroyed=!1;this.destroyCapability=null;this.setupMessageHandler()}updatePage(e){const{_pageIndex:t}=e;api_classPrivateFieldGet(jr,this).set(t,e);api_classPrivateFieldGet(Vr,this).set(t,Promise.resolve(e))}get annotationStorage(){return shadow(this,"annotationStorage",new AnnotationStorage)}getRenderingIntent(e,t=p.ENABLE,i=null,a=!1,s=!1){let n=o,g=$i;switch(e){case"any":n=r;break;case"display":break;case"print":n=l;break;default:warn(`getRenderingIntent - invalid intent: ${e}`)}const m=n&l&&i instanceof PrintAnnotationStorage?i:this.annotationStorage;switch(t){case p.DISABLE:n+=h;break;case p.ENABLE:break;case p.ENABLE_FORMS:n+=d;break;case p.ENABLE_STORAGE:n+=c;g=m.serializable;break;default:warn(`getRenderingIntent - invalid annotationMode: ${t}`)}a&&(n+=u);s&&(n+=_);const{ids:f,hash:v}=m.modifiedIds;return{renderingIntent:n,cacheKey:[n,g.hash,v].join("_"),annotationStorageSerializable:g,modifiedIds:f}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0;this.destroyCapability=Promise.withResolvers();api_classPrivateFieldGet(zr,this)?.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const t of api_classPrivateFieldGet(jr,this).values())e.push(t._destroy());api_classPrivateFieldGet(jr,this).clear();api_classPrivateFieldGet(Vr,this).clear();api_classPrivateFieldGet(Ur,this).clear();Object.hasOwn(this,"annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);e.push(t);Promise.all(e).then(()=>{this.commonObjs.clear();this.fontLoader.clear();api_classPrivateFieldGet(Or,this).clear();this.filterFactory.destroy();TextLayer.cleanup();api_classPrivateFieldGet(Wr,this)?.cancelAllRequests(new AbortException("Worker was terminated."));this.messageHandler?.destroy();this.messageHandler=null;this.destroyCapability.resolve()},this.destroyCapability.reject);return this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(e,t)=>{assert(api_classPrivateFieldGet(Wr,this),"GetReader - no `BasePDFStream` instance available.");api_classPrivateFieldSet(Rr,this,api_classPrivateFieldGet(Wr,this).getFullReader());api_classPrivateFieldGet(Rr,this).onProgress=e=>api_assertClassBrand(Hr,this,api_onProgress).call(this,e);t.onPull=()=>{api_classPrivateFieldGet(Rr,this).read().then(function({value:e,done:i}){if(i)t.close();else{assert(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(e),1,[e])}}).catch(e=>{t.error(e)})};t.onCancel=e=>{api_classPrivateFieldGet(Rr,this).cancel(e);t.ready.catch(e=>{if(!this.destroyed)throw e})}});e.on("ReaderHeadersReady",async e=>{await api_classPrivateFieldGet(Rr,this).headersReady;const{isStreamingSupported:t,isRangeSupported:i,contentLength:a}=api_classPrivateFieldGet(Rr,this);t&&i&&(api_classPrivateFieldGet(Rr,this).onProgress=null);return{isStreamingSupported:t,isRangeSupported:i,contentLength:a}});e.on("GetRangeReader",(e,t)=>{assert(api_classPrivateFieldGet(Wr,this),"GetRangeReader - no `BasePDFStream` instance available.");const i=api_classPrivateFieldGet(Wr,this).getRangeReader(e.begin,e.end);if(i){t.onPull=()=>{i.read().then(function({value:e,done:i}){if(i)t.close();else{assert(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(e),1,[e])}}).catch(e=>{t.error(e)})};t.onCancel=e=>{i.cancel(e);t.ready.catch(e=>{if(!this.destroyed)throw e})}}else t.close()});e.on("GetDoc",({pdfInfo:e})=>{this.pagesMapper.pagesNumber=e.numPages;this._numPages=e.numPages;this._htmlForXfa=e.htmlForXfa;delete e.htmlForXfa;t._capability.resolve(new PDFDocumentProxy(e,this))});e.on("DocException",e=>{t._capability.reject(wrapReason(e))});e.on("PasswordRequest",e=>{api_classPrivateFieldSet(zr,this,Promise.withResolvers());try{if(!t.onPassword)throw wrapReason(e);const updatePassword=e=>{e instanceof Error?api_classPrivateFieldGet(zr,this).reject(e):api_classPrivateFieldGet(zr,this).resolve({password:e})};t.onPassword(updatePassword,e.code)}catch(e){api_classPrivateFieldGet(zr,this).reject(e)}return api_classPrivateFieldGet(zr,this).promise});e.on("DataLoaded",e=>{api_assertClassBrand(Hr,this,api_onProgress).call(this,{loaded:e.length,total:e.length});this.downloadInfoCapability.resolve(e)});e.on("StartRenderPage",e=>{if(this.destroyed)return;api_classPrivateFieldGet(jr,this).get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)});e.on("commonobj",([t,i,a])=>{if(this.destroyed)return null;if(this.commonObjs.has(t))return null;switch(i){case"Font":if("error"in a){const e=a.error;warn(`Error during font loading: ${e}`);this.commonObjs.resolve(t,e);break}const s=new FontInfo(a),n=this._params.pdfBug&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,r=new FontFaceObject(s,n,a.charProcOperatorList,a.extra);this.fontLoader.bind(r).catch(()=>e.sendWithPromise("FontFallback",{id:t})).finally(()=>{r.fontExtraProperties||r.clearData();this.commonObjs.resolve(t,r)});break;case"CopyLocalImage":const{imageRef:o}=a;assert(o,"The imageRef must be defined.");for(const e of api_classPrivateFieldGet(jr,this).values())for(const[,i]of e.objs){if(i?.ref!==o)continue;if(!i.dataLen)return null;const e=structuredClone(i);this.commonObjs.resolve(t,e);return i.dataLen}break;case"FontPath":this.commonObjs.resolve(t,new FontPathInfo(a));break;case"Image":this.commonObjs.resolve(t,a);break;case"Pattern":const l=new PatternInfo(a);this.commonObjs.resolve(t,l.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null});e.on("obj",([e,t,i,a])=>{if(this.destroyed)return;const s=api_classPrivateFieldGet(jr,this).get(t);if(!s.objs.has(e))if(0!==s._intentStates.size)switch(i){case"Image":case"Pattern":s.objs.resolve(e,a);break;default:throw new Error(`Got unknown object type ${i}`)}else a?.bitmap?.close()});e.on("DocProgress",e=>{this.destroyed||api_assertClassBrand(Hr,this,api_onProgress).call(this,e)});e.on("FetchBinaryData",async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.binaryDataFactory)throw new Error("`BinaryDataFactory` not initialized, see the `useWorkerFetch` parameter.");return this.binaryDataFactory.fetch(e)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(e=null){this.annotationStorage.size<=0&&warn("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:i}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:api_classPrivateFieldGet(Rr,this)?.filename??null,pageOrder:e},i).finally(()=>{this.annotationStorage.resetModified()})}extractPages(e){const t={pageInfos:e};let i;const a=globalThis.ImageBitmap;if("function"==typeof a){const t=Array.isArray(e)?e:[e];for(const e of t)e?.image instanceof a&&(i||=[]).push(e.image)}if(this.annotationStorage.size>0){const e=this.annotationStorage.serializable;let{map:a}=e;e.transfer?.length&&(i?i.push(...e.transfer):i=e.transfer);const s=this.pagesMapper.getMapping();if(s){const e=new Map;for(const[t,i]of a){if(void 0!==i?.pageIndex&&i.pageIndex>=0&&i.pageIndex<s.length){const a=s[i.pageIndex]-1;if(a!==i.pageIndex){e.set(t,{...i,pageIndex:a});continue}}e.set(t,i)}a=e}t.annotationStorage=a}return this.messageHandler.sendWithPromise("ExtractPages",t,i).finally(()=>{this.annotationStorage.resetModified()})}getPage(e){if(!Number.isInteger(e)||e<=0||e>this.pagesMapper.pagesNumber)return Promise.reject(new Error("Invalid page request."));const t=e-1,i=this.pagesMapper.getPageId(e)-1,a=api_classPrivateFieldGet(Vr,this).get(t);if(a)return a;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:i}).then(e=>{if(this.destroyed)throw new Error("Transport destroyed");e.refStr&&api_classPrivateFieldGet(Ur,this).set(e.refStr,i);const a=new PDFPageProxy(t,e,this,this.pagesMapper,this._params.pdfBug);api_classPrivateFieldGet(jr,this).set(t,a);return a});api_classPrivateFieldGet(Vr,this).set(t,s);return s}async getPageIndex(e){if(!isRefProxy(e))throw new Error("Invalid pageIndex request.");const t=await this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}),i=this.pagesMapper.getPageNumber(t+1);if(0===i)throw new Error("GetPageIndex: page has been removed.");return i-1}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:this.pagesMapper.getPageId(e+1)-1,intent:t})}getFieldObjects(){return api_assertClassBrand(Hr,this,_cacheSimpleMethod).call(this,"GetFieldObjects")}getSignatures(){return api_assertClassBrand(Hr,this,_cacheSimpleMethod).call(this,"GetSignatures")}getSignatureData(e){return this.messageHandler.sendWithPromise("GetSignatureData",e)}hasJSActions(){return api_assertClassBrand(Hr,this,_cacheSimpleMethod).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAttachmentContent(e){return this.messageHandler.sendWithPromise("GetAttachmentContent",e)}getAnnotationsByType(e,t){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:e,pageIndexesToSkip:t})}getDocJSActions(){return api_assertClassBrand(Hr,this,_cacheSimpleMethod).call(this,"GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:this.pagesMapper.getPageId(e+1)-1})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return api_assertClassBrand(Hr,this,_cacheSimpleMethod).call(this,"GetOptionalContentConfig").then(t=>new OptionalContentConfig(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata";return api_classPrivateFieldGet(Or,this).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,null).then(e=>({info:e[0],metadata:e[1]?new Metadata(e[1]):null,contentDispositionFilename:api_classPrivateFieldGet(Rr,this)?.filename??null,contentLength:api_classPrivateFieldGet(Rr,this)?.contentLength??null,hasStructTree:e[2]})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}getRawData(e){return this.messageHandler.sendWithPromise("GetRawData",e)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of api_classPrivateFieldGet(jr,this).values()){if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`)}this.commonObjs.clear();e||this.fontLoader.clear();api_classPrivateFieldGet(Or,this).clear();this.filterFactory.destroy(!0);TextLayer.cleanup()}}cachedPageNumber(e){if(!isRefProxy(e))return null;const t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`,i=api_classPrivateFieldGet(Ur,this).get(t);if(i>=0){const e=this.pagesMapper.getPageNumber(i+1);if(0!==e)return e}return null}}function _cacheSimpleMethod(e,t=null){return api_classPrivateFieldGet(Or,this).getOrInsertComputed(e,()=>this.messageHandler.sendWithPromise(e,t))}function api_onProgress({loaded:e,total:t}){this.loadingTask.onProgress?.({loaded:e,total:t,percent:t?MathClamp(Math.round(e/t*100),0,100):NaN})}class RenderTask{constructor(e){api_defineProperty(this,"_internalRenderTask",null);api_defineProperty(this,"onContinue",null);api_defineProperty(this,"onError",null);this._internalRenderTask=e}get promise(){return this._internalRenderTask.capability.promise}cancel(e=0){this._internalRenderTask.cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=this._internalRenderTask.operatorList;if(!e)return!1;const{annotationCanvasMap:t}=this._internalRenderTask;return e.form||e.canvas&&t?.size>0}get imageCoordinates(){return this._internalRenderTask.imageCoordinates||null}}var $r=new WeakMap;class InternalRenderTask{constructor({callback:e,params:t,objs:i,commonObjs:a,annotationCanvasMap:s,operatorList:n,pageIndex:r,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:d=!1,pdfBug:c=!1,pageColors:h=null,enableHWA:u=!1,operationsFilter:_=null}){api_classPrivateFieldInitSpec(this,$r,null);this.callback=e;this.params=t;this.objs=i;this.commonObjs=a;this.annotationCanvasMap=s;this.operatorListIdx=null;this.operatorList=n;this._pageIndex=r;this.canvasFactory=o;this.filterFactory=l;this._pdfBug=c;this.pageColors=h;this.running=!1;this.graphicsReadyCallback=null;this.graphicsReady=!1;this._useRequestAnimationFrame=!0===d&&"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=t.canvas;this._canvasContext=t.canvas?null:t.canvasContext;this._enableHWA=u;this._dependencyTracker=t.dependencyTracker;this._imagesTracker=t.imagesTracker;this._operationsFilter=_}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(this.cancelled)return;if(this._canvas){if(Kr._.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.");Kr._.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{viewport:i,transform:a,background:s,dependencyTracker:n,imagesTracker:r}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new CanvasGraphics(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors,n,r);this.gfx.beginDrawing({transform:a,viewport:i,transparency:e,background:s});this.operatorListIdx=0;this.graphicsReady=!0;this.graphicsReadyCallback?.()}cancel(e=null,t=0){this.running=!1;this.cancelled=!0;this.gfx?.endDrawing();if(api_classPrivateFieldGet($r,this)){window.cancelAnimationFrame(api_classPrivateFieldGet($r,this));api_classPrivateFieldSet($r,this,null)}Kr._.delete(this._canvas);e||=new RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,t);this.callback(e);this.task.onError?.(e)}operatorListChanged(){if(this.graphicsReady){this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length);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?api_classPrivateFieldSet($r,this,window.requestAnimationFrame(()=>{api_classPrivateFieldSet($r,this,null);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,this._operationsFilter);if(this.operatorListIdx===this.operatorList.argsArray.length){this.running=!1;if(this.operatorList.lastChunk){this.gfx.endDrawing();Kr._.delete(this._canvas);this.callback()}}}}}var Kr={_:new WeakSet};const Xr="6.2.1097",qr="0c545ef64";var Yr;function color_picker_classPrivateFieldInitSpec(e,t,i){color_picker_checkPrivateRedeclaration(e,t),t.set(e,i)}function color_picker_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function color_picker_classPrivateGetter(e,t,i){return i(color_picker_assertClassBrand(e,t))}function color_picker_classPrivateFieldGet(e,t){return e.get(color_picker_assertClassBrand(e,t))}function color_picker_classPrivateFieldSet(e,t,i){return e.set(color_picker_assertClassBrand(e,t),i),i}function color_picker_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Zr=new WeakMap,Qr=new WeakMap,Jr=new WeakMap,eo=new WeakMap,to=new WeakMap,io=new WeakMap,ao=new WeakMap,so=new WeakMap,no=new WeakMap,ro=new WeakMap,oo=new WeakSet;class ColorPicker{static get _keyboardManager(){return shadow(this,"_keyboardManager",new KeyboardManager([[["Escape"],ColorPicker.prototype._hideDropdownFromKeyboard],[["Space"],ColorPicker.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight"],ColorPicker.prototype._moveToNext],[["ArrowUp","ArrowLeft"],ColorPicker.prototype._moveToPrevious],[["Home"],ColorPicker.prototype._moveToBeginning],[["End"],ColorPicker.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){!function color_picker_classPrivateMethodInitSpec(e,t){color_picker_checkPrivateRedeclaration(e,t),t.add(e)}(this,oo);color_picker_classPrivateFieldInitSpec(this,Zr,null);color_picker_classPrivateFieldInitSpec(this,Qr,null);color_picker_classPrivateFieldInitSpec(this,Jr,void 0);color_picker_classPrivateFieldInitSpec(this,eo,null);color_picker_classPrivateFieldInitSpec(this,to,!1);color_picker_classPrivateFieldInitSpec(this,io,!1);color_picker_classPrivateFieldInitSpec(this,ao,null);color_picker_classPrivateFieldInitSpec(this,so,void 0);color_picker_classPrivateFieldInitSpec(this,no,null);color_picker_classPrivateFieldInitSpec(this,ro,null);if(e){color_picker_classPrivateFieldSet(io,this,!1);color_picker_classPrivateFieldSet(ao,this,e)}else color_picker_classPrivateFieldSet(io,this,!0);color_picker_classPrivateFieldSet(ro,this,e?._uiManager||t);color_picker_classPrivateFieldSet(so,this,color_picker_classPrivateFieldGet(ro,this)._eventBus);color_picker_classPrivateFieldSet(Jr,this,e?.color?.toUpperCase()||color_picker_classPrivateFieldGet(ro,this)?.highlightColors.values().next().value||"#FFFF98");lo._||(lo._=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}renderButton(){const e=color_picker_classPrivateFieldSet(Zr,this,document.createElement("button"));e.className="colorPicker";e.tabIndex="0";e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button");e.ariaHasPopup="true";color_picker_classPrivateFieldGet(ao,this)&&(e.ariaControls=`${color_picker_classPrivateFieldGet(ao,this).id}_colorpicker_dropdown`);const t=color_picker_classPrivateFieldGet(ro,this)._signal;e.addEventListener("click",color_picker_assertClassBrand(oo,this,_openDropdown).bind(this),{signal:t});e.addEventListener("keydown",color_picker_assertClassBrand(oo,this,_keyDown).bind(this),{signal:t});const i=color_picker_classPrivateFieldSet(Qr,this,document.createElement("span"));i.className="swatch";i.ariaHidden="true";i.style.backgroundColor=color_picker_classPrivateFieldGet(Jr,this);e.append(i);return e}renderMainDropdown(){const e=color_picker_classPrivateFieldSet(eo,this,color_picker_assertClassBrand(oo,this,_getDropdownRoot).call(this));e.ariaOrientation="horizontal";e.ariaLabelledBy="highlightColorPickerLabel";return e}_colorSelectFromKeyboard(e){if(e.target===color_picker_classPrivateFieldGet(Zr,this)){color_picker_assertClassBrand(oo,this,_openDropdown).call(this,e);return}const t=e.target.getAttribute("data-color");t&&color_picker_assertClassBrand(oo,this,_colorSelect).call(this,t,e)}_moveToNext(e){color_picker_classPrivateGetter(oo,this,_get_isDropdownVisible)?e.target!==color_picker_classPrivateFieldGet(Zr,this)?e.target.nextSibling?.focus():color_picker_classPrivateFieldGet(eo,this).firstElementChild?.focus():color_picker_assertClassBrand(oo,this,_openDropdown).call(this,e)}_moveToPrevious(e){if(e.target!==color_picker_classPrivateFieldGet(eo,this)?.firstElementChild&&e.target!==color_picker_classPrivateFieldGet(Zr,this)){color_picker_classPrivateGetter(oo,this,_get_isDropdownVisible)||color_picker_assertClassBrand(oo,this,_openDropdown).call(this,e);e.target.previousSibling?.focus()}else color_picker_classPrivateGetter(oo,this,_get_isDropdownVisible)&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){color_picker_classPrivateGetter(oo,this,_get_isDropdownVisible)?color_picker_classPrivateFieldGet(eo,this).firstElementChild?.focus():color_picker_assertClassBrand(oo,this,_openDropdown).call(this,e)}_moveToEnd(e){color_picker_classPrivateGetter(oo,this,_get_isDropdownVisible)?color_picker_classPrivateFieldGet(eo,this).lastElementChild?.focus():color_picker_assertClassBrand(oo,this,_openDropdown).call(this,e)}hideDropdown(){color_picker_classPrivateFieldGet(eo,this)?.classList.add("hidden");color_picker_classPrivateFieldGet(Zr,this).ariaExpanded="false";color_picker_classPrivateFieldGet(no,this)?.abort();color_picker_classPrivateFieldSet(no,this,null)}_hideDropdownFromKeyboard(){if(!color_picker_classPrivateFieldGet(io,this))if(color_picker_classPrivateGetter(oo,this,_get_isDropdownVisible)){this.hideDropdown();color_picker_classPrivateFieldGet(Zr,this).focus({preventScroll:!0,focusVisible:color_picker_classPrivateFieldGet(to,this)})}else color_picker_classPrivateFieldGet(ao,this)?.unselect()}updateColor(e){color_picker_classPrivateFieldGet(Qr,this)&&(color_picker_classPrivateFieldGet(Qr,this).style.backgroundColor=e);if(!color_picker_classPrivateFieldGet(eo,this))return;const t=color_picker_classPrivateFieldGet(ro,this).highlightColors.values();for(const i of color_picker_classPrivateFieldGet(eo,this).children)i.ariaSelected=t.next().value===e.toUpperCase()}destroy(){color_picker_classPrivateFieldGet(Zr,this)?.remove();color_picker_classPrivateFieldSet(Zr,this,null);color_picker_classPrivateFieldSet(Qr,this,null);color_picker_classPrivateFieldGet(eo,this)?.remove();color_picker_classPrivateFieldSet(eo,this,null)}}Yr=ColorPicker;function _getDropdownRoot(){const e=document.createElement("div"),t=color_picker_classPrivateFieldGet(ro,this)._signal;e.addEventListener("contextmenu",noContextMenu,{signal:t});e.className="dropdown";e.role="listbox";e.ariaMultiSelectable="false";e.ariaOrientation="vertical";e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");color_picker_classPrivateFieldGet(ao,this)&&(e.id=`${color_picker_classPrivateFieldGet(ao,this).id}_colorpicker_dropdown`);for(const[i,a]of color_picker_classPrivateFieldGet(ro,this).highlightColors){const s=document.createElement("button");s.tabIndex="0";s.role="option";s.setAttribute("data-color",a);s.title=i;s.setAttribute("data-l10n-id",lo._[i]);const n=document.createElement("span");s.append(n);n.className="swatch";n.style.backgroundColor=a;s.ariaSelected=a===color_picker_classPrivateFieldGet(Jr,this);s.addEventListener("click",color_picker_assertClassBrand(oo,this,_colorSelect).bind(this,a),{signal:t});e.append(s)}e.addEventListener("keydown",color_picker_assertClassBrand(oo,this,_keyDown).bind(this),{signal:t});return e}function _colorSelect(e,t){t.stopPropagation();color_picker_classPrivateFieldGet(so,this).dispatch("switchannotationeditorparams",{source:this,type:v.HIGHLIGHT_COLOR,value:e});this.updateColor(e)}function _keyDown(e){Yr._keyboardManager.exec(this,e)}function _openDropdown(e){if(color_picker_classPrivateGetter(oo,this,_get_isDropdownVisible)){this.hideDropdown();return}color_picker_classPrivateFieldSet(to,this,0===e.detail);if(!color_picker_classPrivateFieldGet(no,this)){color_picker_classPrivateFieldSet(no,this,new AbortController);window.addEventListener("pointerdown",color_picker_assertClassBrand(oo,this,color_picker_pointerDown).bind(this),{signal:color_picker_classPrivateFieldGet(ro,this).combinedSignal(color_picker_classPrivateFieldGet(no,this))})}color_picker_classPrivateFieldGet(Zr,this).ariaExpanded="true";if(color_picker_classPrivateFieldGet(eo,this)){color_picker_classPrivateFieldGet(eo,this).classList.remove("hidden");return}const t=color_picker_classPrivateFieldSet(eo,this,color_picker_assertClassBrand(oo,this,_getDropdownRoot).call(this));color_picker_classPrivateFieldGet(Zr,this).append(t)}function color_picker_pointerDown(e){color_picker_classPrivateFieldGet(eo,this)?.contains(e.target)||this.hideDropdown()}function _get_isDropdownVisible(e){return color_picker_classPrivateFieldGet(eo,e)&&!color_picker_classPrivateFieldGet(eo,e).classList.contains("hidden")}var lo={_:null},co=new WeakMap,ho=new WeakMap,uo=new WeakMap,_o=new WeakMap;class BasicColorPicker{constructor(e){color_picker_classPrivateFieldInitSpec(this,co,null);color_picker_classPrivateFieldInitSpec(this,ho,!1);color_picker_classPrivateFieldInitSpec(this,uo,null);color_picker_classPrivateFieldInitSpec(this,_o,null);color_picker_classPrivateFieldSet(uo,this,e);color_picker_classPrivateFieldSet(_o,this,e._uiManager);po._||(po._=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(color_picker_classPrivateFieldGet(co,this))return color_picker_classPrivateFieldGet(co,this);const{editorType:e,colorType:t,colorAndOpacityType:i,opacityType:a,color:s,opacity:n}=color_picker_classPrivateFieldGet(uo,this),r=color_picker_classPrivateFieldSet(ho,this,FeatureTest.isAlphaColorInputSupported&&void 0!==a),o=color_picker_classPrivateFieldSet(co,this,document.createElement("input"));o.type="color";if(r){o.setAttribute("alpha","");const e=Util.hexNums[Math.round(255*(n??1))];o.value=(s||"#000000")+e}else o.value=s||"#000000";o.className="basicColorPicker";o.tabIndex=0;o.setAttribute("data-l10n-id",po._[e]);o.addEventListener("input",()=>{if(r){const e=getRGBA(o.value);if(!e)return;const[s,n,r,l]=e,d=Util.makeHexColor(s,n,r);if(void 0!==i)color_picker_classPrivateFieldGet(_o,this).updateParams(i,{color:d,opacity:l});else{color_picker_classPrivateFieldGet(_o,this).updateParams(t,d);color_picker_classPrivateFieldGet(_o,this).updateParams(a,l)}}else color_picker_classPrivateFieldGet(_o,this).updateParams(t,o.value)},{signal:color_picker_classPrivateFieldGet(_o,this)._signal});return o}update(e){if(color_picker_classPrivateFieldGet(co,this))if(color_picker_classPrivateFieldGet(ho,this)){const t=Util.hexNums[Math.round(255*color_picker_classPrivateFieldGet(uo,this).opacity)];color_picker_classPrivateFieldGet(co,this).value=e+t}else color_picker_classPrivateFieldGet(co,this).value=e}updateOpacity(e){if(!color_picker_classPrivateFieldGet(co,this)||!color_picker_classPrivateFieldGet(ho,this))return;const t=Util.hexNums[Math.round(255*e)];color_picker_classPrivateFieldGet(co,this).value=color_picker_classPrivateFieldGet(uo,this).color+t}destroy(){color_picker_classPrivateFieldGet(co,this)?.remove();color_picker_classPrivateFieldSet(co,this,null)}hideDropdown(){}}var po={_:null};function makeColorComp(e){return Math.floor(255*MathClamp(e,0,1)).toString(16).padStart(2,"0")}function scaleAndClamp(e){return 255*MathClamp(e,0,1)}class ColorConverters{static CMYK_G([e,t,i,a]){return["G",1-Math.min(1,.3*e+.59*i+.11*t+a)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return[e=scaleAndClamp(e),e,e]}static G_HTML([e]){const t=makeColorComp(e);return`#${t}${t}${t}`}static RGB_G([e,t,i]){return["G",.3*e+.59*t+.11*i]}static RGB_rgb(e){return e.map(scaleAndClamp)}static RGB_HTML(e){return`#${e.map(makeColorComp).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,i,a]){return["RGB",1-Math.min(1,e+a),1-Math.min(1,i+a),1-Math.min(1,t+a)]}static CMYK_rgb([e,t,i,a]){return[scaleAndClamp(1-Math.min(1,e+a)),scaleAndClamp(1-Math.min(1,i+a)),scaleAndClamp(1-Math.min(1,t+a))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,i]){const a=1-e,s=1-t,n=1-i;return["CMYK",a,s,n,Math.min(a,s,n)]}}class BaseSVGFactory{create(e,t,i=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const a=this._createSVG("svg:svg");a.setAttribute("version","1.1");if(!i){a.setAttribute("width",`${e}px`);a.setAttribute("height",`${t}px`)}a.setAttribute("preserveAspectRatio","none");a.setAttribute("viewBox",`0 0 ${e} ${t}`);return a}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){unreachable("Abstract method `_createSVG` called.")}}class DOMSVGFactory extends BaseSVGFactory{_createSVG(e){return document.createElementNS(n,e)}}function annotation_layer_defineProperty(e,t,i){return(t=function annotation_layer_toPropertyKey(e){var t=function annotation_layer_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function _toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function annotation_layer_classPrivateGetter(e,t,i){return i(annotation_layer_assertClassBrand(e,t))}function annotation_layer_classPrivateMethodInitSpec(e,t){annotation_layer_checkPrivateRedeclaration(e,t),t.add(e)}function annotation_layer_classPrivateFieldInitSpec(e,t,i){annotation_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_layer_classPrivateFieldSet(e,t,i){return e.set(annotation_layer_assertClassBrand(e,t),i),i}function annotation_layer_classPrivateFieldGet(e,t){return e.get(annotation_layer_assertClassBrand(e,t))}function annotation_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const go=new WeakSet,mo=60*(new Date).getTimezoneOffset()*1e3;class AnnotationElementFactory{static create(e){switch(e.data.annotationType){case k.LINK:return new LinkAnnotationElement(e);case k.TEXT:return new TextAnnotationElement(e);case k.WIDGET:switch(e.data.fieldType){case"Tx":return new TextWidgetAnnotationElement(e);case"Btn":return e.data.radioButton?new RadioButtonWidgetAnnotationElement(e):e.data.checkBox?new CheckboxWidgetAnnotationElement(e):new PushButtonWidgetAnnotationElement(e);case"Ch":return new ChoiceWidgetAnnotationElement(e);case"Sig":return new SignatureWidgetAnnotationElement(e)}return new WidgetAnnotationElement(e);case k.POPUP:return new PopupAnnotationElement(e);case k.FREETEXT:return new FreeTextAnnotationElement(e);case k.LINE:return new LineAnnotationElement(e);case k.SQUARE:return new SquareAnnotationElement(e);case k.CIRCLE:return new CircleAnnotationElement(e);case k.POLYLINE:return new PolylineAnnotationElement(e);case k.CARET:return new CaretAnnotationElement(e);case k.INK:return new InkAnnotationElement(e);case k.POLYGON:return new PolygonAnnotationElement(e);case k.HIGHLIGHT:return new HighlightAnnotationElement(e);case k.UNDERLINE:return new UnderlineAnnotationElement(e);case k.SQUIGGLY:return new SquigglyAnnotationElement(e);case k.STRIKEOUT:return new StrikeOutAnnotationElement(e);case k.STAMP:return new StampAnnotationElement(e);case k.FILEATTACHMENT:return new FileAttachmentAnnotationElement(e);case k.RICHMEDIA:case k.SCREEN:case k.SOUND:return new MediaAnnotationElement(e);default:return new AnnotationElement(e)}}}var fo=new WeakMap,vo=new WeakMap,Po=new WeakMap,wo=new WeakSet;class AnnotationElement{constructor(e,{isRenderable:t=!1,ignoreBorder:i=!1,createQuadrilaterals:a=!1}={}){annotation_layer_classPrivateMethodInitSpec(this,wo);annotation_layer_classPrivateFieldInitSpec(this,fo,null);annotation_layer_classPrivateFieldInitSpec(this,vo,!1);annotation_layer_classPrivateFieldInitSpec(this,Po,null);this.isRenderable=t;this.data=e.data;this.layer=e.layer;this.linkService=e.linkService;this.downloadManager=e.downloadManager;this.imageResourcesPath=e.imageResourcesPath;this.renderForms=e.renderForms;this.svgFactory=e.svgFactory;this.annotationStorage=e.annotationStorage;this.enableComment=e.enableComment;this.enableScripting=e.enableScripting;this.hasJSActions=e.hasJSActions;this._fieldObjects=e.fieldObjects;this.parent=e.parent;this.hasOwnCommentButton=!1;t&&(this.contentElement=this.container=this._createContainer(i));a&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:e,richText:t}){return!(!e?.str&&!t?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return AnnotationElement._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:e}=this,t=this.annotationStorage?.getEditor(e.id);return t?t.getData():e}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const e=this.annotationStorage?.getEditor(this.data.id);if(e)return e.commentButtonPositionInPage;const{quadPoints:t,inkLists:i,rect:a}=this.data;let s=-1/0,n=-1/0;if(t?.length>=8){for(let e=0;e<t.length;e+=8)if(t[e+1]>n){n=t[e+1];s=t[e+2]}else t[e+1]===n&&(s=Math.max(s,t[e+2]));return[s,n]}if(i?.length>=1){for(const e of i)for(let t=0,i=e.length;t<i;t+=2)if(e[t+1]>n){n=e[t+1];s=e[t]}else e[t+1]===n&&(s=Math.max(s,e[t]));if(s!==1/0)return[s,n]}return a?[a[2],a[3]]:null}_normalizePoint(e){const{page:{view:t},viewport:{rawDims:{pageWidth:i,pageHeight:a,pageX:s,pageY:n}}}=this.parent;e[1]=t[3]-e[1]+t[1];e[0]=100*(e[0]-s)/i;e[1]=100*(e[1]-n)/a;return e}get commentText(){const{data:e}=this;return this.annotationStorage.getRawValue(`${m}${e.id}`)?.popup?.contents||e.contentsObj?.str||""}set commentText(e){const{data:t}=this,i={deleted:!e,contents:e||""};this.annotationStorage.updateEditor(t.id,{popup:i})||this.annotationStorage.setValue(`${m}${t.id}`,{id:t.id,annotationType:t.annotationType,page:this.parent.page,popup:i,popupRef:t.popupRef,modificationDate:new Date});e||this.removePopup()}removePopup(){(annotation_layer_classPrivateFieldGet(Po,this)?.popup||this.popup)?.remove();annotation_layer_classPrivateFieldSet(Po,this,this.popup=null)}updateEdited(e){if(!this.container)return;e.rect&&(annotation_layer_classPrivateFieldGet(fo,this)||annotation_layer_classPrivateFieldSet(fo,this,{rect:this.data.rect.slice(0)}));const{rect:t,popup:i}=e;t&&annotation_layer_assertClassBrand(wo,this,_setRectEdited).call(this,t);let a=annotation_layer_classPrivateFieldGet(Po,this)?.popup||this.popup;if(!a&&i?.text){this._createPopup(i);a=annotation_layer_classPrivateFieldGet(Po,this).popup}if(a){a.updateEdited(e);if(i?.deleted){a.remove();annotation_layer_classPrivateFieldSet(Po,this,null);this.popup=null}}}resetEdited(){if(annotation_layer_classPrivateFieldGet(fo,this)){annotation_layer_assertClassBrand(wo,this,_setRectEdited).call(this,annotation_layer_classPrivateFieldGet(fo,this).rect);annotation_layer_classPrivateFieldGet(Po,this)?.popup.resetEdited();annotation_layer_classPrivateFieldSet(fo,this,null)}}_createContainer(e){const{data:t,parent:{page:i,viewport:a}}=this,s=document.createElement("section");s.setAttribute("data-annotation-id",t.id);this instanceof WidgetAnnotationElement||this instanceof LinkAnnotationElement||this instanceof MediaAnnotationElement||(s.tabIndex=0);const{style:n}=s;n.zIndex=this.parent.zIndex;this.parent.zIndex+=2;t.alternativeText&&(s.title=t.alternativeText);t.noRotate&&s.classList.add("norotate");if(!t.rect||this instanceof PopupAnnotationElement){const{rotation:e}=t;t.hasOwnCanvas||0===e||this.setRotation(e,s);return s}const{width:r,height:o}=this;if(!e&&t.borderStyle.width>0){n.borderWidth=`${t.borderStyle.width}px`;const e=t.borderStyle.horizontalCornerRadius,i=t.borderStyle.verticalCornerRadius;if(e>0||i>0){const t=`calc(${e}px * var(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;n.borderRadius=t}else if(this instanceof RadioButtonWidgetAnnotationElement){const e=`calc(${r}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;n.borderRadius=e}switch(t.borderStyle.style){case E:n.borderStyle="solid";break;case A:n.borderStyle="dashed";break;case G:warn("Unimplemented border style: beveled");break;case B:warn("Unimplemented border style: inset");break;case M:n.borderBottomStyle="solid"}const a=t.borderColor||null;if(a){annotation_layer_classPrivateFieldSet(vo,this,!0);n.borderColor=Util.makeHexColor(...a)}else n.borderWidth=0}const l=Util.normalizeRect([t.rect[0],i.view[3]-t.rect[1]+i.view[1],t.rect[2],i.view[3]-t.rect[3]+i.view[1]]),{pageWidth:d,pageHeight:c,pageX:h,pageY:u}=a.rawDims;n.left=100*(l[0]-h)/d+"%";n.top=100*(l[1]-u)/c+"%";const{rotation:_}=t;if(t.hasOwnCanvas||0===_){n.width=100*r/d+"%";n.height=100*o/c+"%"}else this.setRotation(_,s);return s}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:a}=this.parent.viewport.rawDims;let{width:s,height:n}=this;e%180!=0&&([s,n]=[n,s]);t.style.width=100*s/i+"%";t.style.height=100*n/a+"%";t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const setColor=(e,t,i)=>{const a=i.detail[e],s=a[0],n=a.slice(1);i.target.style[t]=ColorConverters[`${s}_HTML`](n);this.annotationStorage.setValue(this.data.id,{[t]:ColorConverters[`${s}_rgb`](n)})};return shadow(this,"_commonActions",{display:e=>{const{display:t}=e.detail,i=t%2==1;this.container.style.visibility=i?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===t||2===t})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:t}=e.detail;this.container.style.visibility=t?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{setColor("bgColor","backgroundColor",e)},fillColor:e=>{setColor("fillColor","backgroundColor",e)},fgColor:e=>{setColor("fgColor","color",e)},textColor:e=>{setColor("textColor","color",e)},borderColor:e=>{setColor("borderColor","borderColor",e)},strokeColor:e=>{setColor("strokeColor","borderColor",e)},rotation:e=>{const t=e.detail.rotation;this.setRotation(t);this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){const i=this._commonActions;for(const a of Object.keys(t.detail)){const s=e[a]||i[a];s?.(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const i=this._commonActions;for(const[a,s]of Object.entries(t)){const n=i[a];if(n){n({detail:{[a]:s},target:e});delete t[a]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,i,a,s]=this.data.rect.map(e=>Math.fround(e));if(8===e.length){const[n,r,o,l]=e.subarray(2,6);if(a===n&&s===r&&t===o&&i===l)return}const{style:r}=this.container;let o;if(annotation_layer_classPrivateFieldGet(vo,this)){const{borderColor:e,borderWidth:t}=r;r.borderWidth=0;o=["url('data:image/svg+xml;utf8,",`<svg xmlns="${n}" preserveAspectRatio="none" viewBox="0 0 1 1">`,`<g fill="transparent" stroke="${e}" stroke-width="${t}">`];this.container.classList.add("hasBorder")}const l=a-t,d=s-i,{svgFactory:c}=this,h=c.createElement("svg");h.classList.add("quadrilateralsContainer");h.setAttribute("width",0);h.setAttribute("height",0);h.role="none";const u=c.createElement("defs");h.append(u);const _=c.createElement("clipPath"),p=`clippath_${this.data.id}`;_.setAttribute("id",p);_.setAttribute("clipPathUnits","objectBoundingBox");u.append(_);for(let i=2,a=e.length;i<a;i+=8){const a=e[i],n=e[i+1],r=e[i+2],h=e[i+3],u=c.createElement("rect"),p=(r-t)/l,g=(s-n)/d,m=(a-r)/l,f=(n-h)/d;u.setAttribute("x",p);u.setAttribute("y",g);u.setAttribute("width",m);u.setAttribute("height",f);_.append(u);o?.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${g}" width="${m}" height="${f}"/>`)}if(annotation_layer_classPrivateFieldGet(vo,this)){o.push("</g></svg>')");r.backgroundImage=o.join("")}this.container.append(h);this.container.style.clipPath=`url(#${p})`}_createPopup(e=null){const{data:t}=this;let i,a;if(e){i={str:e.text};a=e.date}else{i=t.contentsObj;a=t.modificationDate}annotation_layer_classPrivateFieldSet(Po,this,new PopupAnnotationElement({data:{color:t.color,titleObj:t.titleObj,modificationDate:a,contentsObj:i,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(annotation_layer_classPrivateFieldGet(Po,this)||this.popup||this.data.popupRef)}get extraPopupElement(){return annotation_layer_classPrivateFieldGet(Po,this)}render(){unreachable("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const i=[];if(this._fieldObjects){const a=this._fieldObjects[e]||[];for(const{page:e,id:s,exportValues:n}of a){if(-1===e)continue;if(s===t)continue;const a="string"==typeof n?n:null,r=document.querySelector(`[data-element-id="${s}"]`);!r||go.has(r)?i.push({id:s,exportValue:a,domElement:r}):warn(`_getElementsByName - element not allowed: ${s}`)}return i}for(const a of document.getElementsByName(e)){const{exportValue:e}=a,s=a.getAttribute("data-element-id");s!==t&&(go.has(a)&&i.push({id:s,exportValue:e,domElement:a}))}return i}show(){this.container&&(this.container.hidden=!1);this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0);this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t,mustEnterInEditMode:!0})})}updateOC(e){if(!this.data.oc||!e)return;e.isVisible(this.data.oc)?this.show():this.hide()}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":Util.makeHexColor(...t)}}function _setRectEdited(e){const{container:{style:t},data:{rect:i,rotation:a},parent:{viewport:{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:o}}}}=this;i?.splice(0,4,...e);t.left=100*(e[0]-r)/s+"%";t.top=100*(n-e[3]+o)/n+"%";if(0===a){t.width=100*(e[2]-e[0])/s+"%";t.height=100*(e[3]-e[1])/n+"%"}else this.setRotation(a)}class EditorAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.editor=e.editor}render(){this.container.className="editorAnnotation";return this.container}createOrUpdatePopup(){const{editor:e}=this;e.hasComment&&this._createPopup(e.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(e){this.editor.comment=e;e||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id);this.container.remove();this.container=null;this.removePopup()}}var Fo=new WeakSet;class LinkAnnotationElement extends AnnotationElement{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0});annotation_layer_classPrivateMethodInitSpec(this,Fo);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:t}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let a=!1;if(e.url){t.addLinkAttributes(i,e.url,e.newWindow);a=!0}else if(e.action){this._bindNamedAction(i,e.action,e.overlaidText);a=!0}else if(e.attachment){annotation_layer_assertClassBrand(Fo,this,_bindAttachment).call(this,i,e.attachmentId,e.attachment,e.overlaidText,e.attachmentDest);a=!0}else if(e.setOCGState){annotation_layer_assertClassBrand(Fo,this,_bindSetOCGState).call(this,i,e.setOCGState,e.overlaidText);a=!0}else if(e.dest){this._bindLink(i,e.dest,e.overlaidText);a=!0}else{if(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions){this._bindJSAction(i,e);a=!0}if(e.resetForm){this._bindResetFormAction(i,e.resetForm);a=!0}else if(this.isTooltipOnly&&!a){this._bindLink(i,"");a=!0}}this.container.classList.add("linkAnnotation");if(a){this.contentElement=i;this.container.append(i)}return this.container}_bindLink(e,t,i=""){e.href=this.linkService.getDestinationHash(t);e.onclick=()=>{t&&this.linkService.goToDestination(t);return!1};(t||""===t)&&annotation_layer_assertClassBrand(Fo,this,_setInternalLink).call(this);i&&(e.title=i)}_bindNamedAction(e,t,i=""){e.href=this.linkService.getAnchorUrl("");e.onclick=()=>{this.linkService.executeNamedAction(t);return!1};i&&(e.title=i);annotation_layer_assertClassBrand(Fo,this,_setInternalLink).call(this)}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const a of Object.keys(t.actions)){const s=i.get(a);s&&(e[s]=()=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:a}});return!1})}t.overlaidText&&(e.title=t.overlaidText);e.onclick||=()=>!1;annotation_layer_assertClassBrand(Fo,this,_setInternalLink).call(this)}_bindResetFormAction(e,t){const i=e.onclick;i||(e.href=this.linkService.getAnchorUrl(""));annotation_layer_assertClassBrand(Fo,this,_setInternalLink).call(this);if(this._fieldObjects)e.onclick=()=>{i?.();const{fields:e,refs:a,include:s}=t,n=[];if(0!==e.length||0!==a.length){const t=new Set(a);for(const i of e){const e=this._fieldObjects[i]||[];for(const{id:i}of e)t.add(i)}for(const e of Object.values(this._fieldObjects))for(const i of e)t.has(i.id)===s&&n.push(i)}else for(const e of Object.values(this._fieldObjects))n.push(...e);const r=this.annotationStorage,o=[];for(const e of n){const{id:t}=e;o.push(t);switch(e.type){case"text":{const i=e.defaultValue||"";r.setValue(t,{value:i});window.updateAngularFormValue(t,{value:i});break}case"checkbox":case"radiobutton":{const i=e.defaultValue===e.exportValues;r.setValue(t,{value:i});window.updateAngularFormValue(t,{value:i});break}case"combobox":case"listbox":{const i=e.defaultValue||"";r.setValue(t,{value:i});window.updateAngularFormValue(t,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${t}"]`);i&&(go.has(i)?i.dispatchEvent(new Event("resetform")):warn(`_bindResetFormAction - element not allowed: ${t}`))}this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}});return!1};else{warn('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.');i||(e.onclick=()=>!1)}}}function _setInternalLink(){this.container.setAttribute("data-internal-link","")}function _bindAttachment(e,t,i,a="",s=null){e.href=this.linkService.getAnchorUrl("");i.description?e.title=i.description:a&&(e.title=a);const openAttachment=async()=>{const e=await this.linkService.getAttachmentContent(t);e&&this.downloadManager?.openOrDownloadData(e,i.filename,s)};e.onclick=()=>{openAttachment();return!1};annotation_layer_assertClassBrand(Fo,this,_setInternalLink).call(this)}function _bindSetOCGState(e,t,i=""){e.href=this.linkService.getAnchorUrl("");e.onclick=()=>{this.linkService.executeSetOCGState(t);return!1};i&&(e.title=i);annotation_layer_assertClassBrand(Fo,this,_setInternalLink).call(this)}class TextAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg";e.setAttribute("data-l10n-id","pdfjs-text-annotation-type");e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name}));if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.append(e);return this.container}}class WidgetAnnotationElement extends AnnotationElement{render(){return this.container}_getKeyModifier(e){return FeatureTest.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,i,a,s){i.includes("mouse")?e.addEventListener(i,e=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:s(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(i,e=>{if("blur"===i){if(!t.focused)return;t.focused=!1}else if("focus"===i){if(t.focused)return;t.focused=!0}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:a,value:s(e)}})})}_setEventListeners(e,t,i,a){for(const[s,n]of i)if("Action"===n||this.data.actions?.[n]){"Focus"!==n&&"Blur"!==n||(t||={focused:!1});this._setEventListener(e,t,s,n,a);"Focus"!==n||this.data.actions?.Blur?"Blur"!==n||this.data.actions?.Focus||this._setEventListener(e,t,"focus","Focus",null):this._setEventListener(e,t,"blur","Blur",null)}}_setTextStyle(e){const t=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,a=this.data.defaultAppearanceData.fontSize||9,s=e.style;let n;const roundToOneDecimal=e=>Math.round(10*e)/10;if(this.data.multiLine){const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(1.35*a))||1);n=Math.min(a,roundToOneDecimal(t/1.35))}else{const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);n=Math.min(a,roundToOneDecimal(e/1.35))}s.fontSize=`calc(${n}px * var(--total-scale-factor))`;s.color=Util.makeHexColor(...i);null===this.data.textAlignment||this.data.comb||(s.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required");e.setAttribute("aria-required",t)}}class TextWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,i,a){const s=this.annotationStorage;for(const n of this._getElementsByName(e.name,e.id)){n.domElement&&(n.domElement[t]=i);s.setValue(n.id,{[a]:i})}}render(){const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const a=window.getFormValueFromAngular(this.data.fieldName),s=e.getValue(t,{value:this.data.fieldValue}),n=a.value?a:s;if(a!==s){e.setValue(t,{value:a.value});n.formattedValue=a.value}let r=n.value||"";const o=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&r.length>o&&(r=r.slice(0,o));let l=n.formattedValue||this.data.textContent?.join("\n")||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));const d={userValue:r,formattedValue:l,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){i=document.createElement("textarea");i.textContent=l??r;this.data.doNotScroll&&(i.style.overflowY="hidden")}else{i=document.createElement("input");i.type=this.data.password?"password":"text";i.setAttribute("value",l??r);this.data.doNotScroll&&(i.style.overflowX="hidden")}if(this.data.hasOwnCanvas){this.container.classList.add("hasOwnCanvas");e.has(t)&&this.container.classList.add("sandboxModified")}go.add(i);this.contentElement=i;i.setAttribute("data-element-id",t);i.disabled=this.data.readOnly;i.name=this.data.fieldName;i.tabIndex=0;const{datetimeFormat:c,datetimeType:h,timeStep:u}=this.data,_=!!h&&this.enableScripting;c&&(i.title=c);this._setRequired(i,this.data.required);o&&(i.maxLength=o);i.addEventListener("input",a=>{e.setValue(t,{value:a.target.value});window.updateAngularFormValue(t,{value:a.target.value});this.setPropertyOnSiblings(i,"value",a.target.value,"value");d.formattedValue=null});i.addEventListener("resetform",e=>{const t=this.data.defaultFieldValue??"";i.value=d.userValue=t;d.formattedValue=null});let blurListener=e=>{const{formattedValue:t}=d;null!=t&&(e.target.value=t);e.target.scrollLeft=0};window.registerAcroformField(t,i,n.value,void 0,this.data.fieldValue);i.addEventListener("updateFromAngular",i=>{d.formattedValue=null;e.setValue(t,{value:i.detail})});if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",e=>{if(d.focused)return;const{target:t}=e;if(_){t.type=h;u&&(t.step=u)}if(d.userValue){const e=d.userValue;if(_)if("time"===h){const i=new Date(e),a=[i.getHours(),i.getMinutes(),i.getSeconds()];t.value=a.map(e=>e.toString().padStart(2,"0")).join(":")}else t.value=new Date(e-mo).toISOString().split("date"===h?"T":".",1)[0];else t.value=e}d.lastCommittedValue=t.value;d.commitKey=1;this.data.actions?.Focus||(d.focused=!0)});i.addEventListener("updatefromsandbox",i=>{this.container.classList.add("sandboxModified");const a={value(i){d.userValue=i.detail.value??"";if(!_){e.setValue(t,{value:d.userValue.toString()});window.updateAngularFormValue(t,{value:d.userValue.toString()})}i.target.value=d.userValue},formattedValue(i){const{formattedValue:a}=i.detail;d.formattedValue=a;null!=a&&i.target!==document.activeElement&&(i.target.value=a);const s={formattedValue:a};_&&(s.value=a);e.setValue(t,s);window.updateAngularFormValue(t,{formattedValue:a})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:i=>{const{charLimit:a}=i.detail,{target:s}=i;if(0===a){s.removeAttribute("maxLength");return}s.setAttribute("maxLength",a);let n=d.userValue;if(n&&!(n.length<=a)){n=n.slice(0,a);s.value=d.userValue=n;e.setValue(t,{value:n});window.updateAngularFormValue(t,{value:n});this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:n,willCommit:!0,commitKey:1,selStart:s.selectionStart,selEnd:s.selectionEnd}})}}};this._dispatchEventFromSandbox(a,i)});i.addEventListener("keydown",e=>{d.commitKey=1;let i=-1;"Escape"===e.key?i=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(d.commitKey=3):i=2;if(-1===i)return;const{value:a}=e.target;if(d.lastCommittedValue!==a){d.lastCommittedValue=a;d.userValue=a;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:a,willCommit:!0,commitKey:i,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})}});const a=blurListener;blurListener=null;i.addEventListener("blur",e=>{if(!d.focused)return;this.data.actions?.Blur||(d.focused=!1);const{target:i}=e;let{value:s}=i;if(_){if(s&&"time"===h){const e=s.split(":").map(e=>parseInt(e,10));s=new Date(2e3,0,1,e[0],e[1],e[2]||0).valueOf();i.step=""}else{s.includes("T")||(s=`${s}T00:00`);s=new Date(s).valueOf()}i.type="text"}d.userValue=s;d.lastCommittedValue!==s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:s,willCommit:!0,commitKey:d.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}});a(e)});this.data.actions?.Keystroke&&i.addEventListener("beforeinput",e=>{d.lastCommittedValue=null;const{data:i,target:a}=e,{value:s,selectionStart:n,selectionEnd:r}=a;let o=n,l=r;switch(e.inputType){case"deleteWordBackward":{const e=s.substring(0,n).match(/\w*\W*$/);e&&(o-=e[0].length);break}case"deleteWordForward":{const e=s.substring(n).match(/^\W*\w*/);e&&(l+=e[0].length);break}case"deleteContentBackward":n===r&&(o-=1);break;case"deleteContentForward":n===r&&(l+=1)}e.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:s,change:i||"",willCommit:!1,selStart:o,selEnd:l}})});this._setEventListeners(i,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.value)}blurListener&&i.addEventListener("blur",blurListener);if(this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/o;i.classList.add("comb");i.style.setProperty("--comb-width",`calc(${e}px * var(--total-scale-factor))`);const t=this.data.textAlignment;if(1===t||2===t){const setCombOffset=()=>{const e=o-i.value.length;i.style.setProperty("--comb-offset",`${1===t?e>>1:e}`)};setCombOffset();for(const e of["input","blur","resetform","updatefromsandbox"])i.addEventListener(e,setCombOffset)}}}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(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,i=t.id,a=window.getFormValueFromAngular(this.data.fieldName),s=e.getValue(i,{value:t.exportValue===t.fieldValue}).value;let n;a.value&&(n=!0===a.value||a.value===t.exportValue);let r=void 0!==n?n:s,o=!1;if("string"==typeof r){r=r===t.exportValue;e.setValue(i,{value:r});o=!0}else if(void 0!==a?.value&&a.value!==s){r=!0===a.value||a.value===t.exportValue?t.exportValue:void 0;e.setValue(i,{value:r})}this.container.classList.add("buttonWidgetAnnotation","checkBox");const l=document.createElement("input");go.add(l);l.setAttribute("data-element-id",i);l.disabled=t.readOnly;this._setRequired(l,this.data.required);l.type="checkbox";l.name=t.fieldName;r&&l.setAttribute("checked",!0);l.setAttribute("exportValue",t.exportValue);l.tabIndex=0;l.addEventListener("change",a=>{const{name:s,checked:n}=a.target;for(const a of this._getElementsByName(s,i)){const s=n&&a.exportValue===t.exportValue;a.domElement&&(a.domElement.checked=s);e.setValue(a.id,{value:s});window.updateAngularFormValue(i,{value:s})}e.setValue(i,{value:n});window.updateAngularFormValue(i,{value:n})});l.addEventListener("resetform",e=>{const i=t.defaultFieldValue||"Off";e.target.checked=i===t.exportValue});window.registerAcroformField(i,l,r?t.exportValue:void 0,void 0,this.data.fieldValue);l.addEventListener("updateFromAngular",t=>e.setValue(i,{value:t.detail}));o&&window.updateAngularFormValue(i,{value:r});if(this.enableScripting&&this.hasJSActions){l.addEventListener("updatefromsandbox",t=>{const a={value(t){t.target.checked="Off"!==t.detail.value;e.setValue(i,{value:t.target.checked});window.updateAngularFormValue(i,{value:t.target.value})}};this._dispatchEventFromSandbox(a,t)});this._setEventListeners(l,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.checked)}this._setDefaultPropertiesFromJS(l);this.container.append(l);return this.container}}class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,i=t.id,a=window.getFormValueFromAngular(this.data.fieldName),s=null!==t.buttonValue&&t.fieldValue===t.buttonValue?t.buttonValue:void 0,n=e.getValue(i,{value:s}).value;let r=a.value??n;if("string"==typeof r||a!==n){r=r===t.buttonValue;e.setValue(i,{value:r})}else r&&window.updateAngularFormValue(i,{value:t.buttonValue});if(r)for(const a of this._getElementsByName(t.fieldName,i))e.setValue(a.id,{value:!1});const o=document.createElement("input");go.add(o);o.setAttribute("data-element-id",i);o.disabled=t.readOnly;this._setRequired(o,this.data.required);o.type="radio";o.name=t.fieldName;r&&o.setAttribute("checked",!0);o.tabIndex=0;o.addEventListener("change",t=>{const{name:a,checked:s}=t.target;for(const t of this._getElementsByName(a,i)){e.setValue(t.id,{value:!1});window.updateAngularFormValue(t.id,{value:!1})}e.setValue(i,{value:s});window.updateAngularFormValue(i,{value:s})});o.addEventListener("resetform",e=>{const i=t.defaultFieldValue;e.target.checked=null!=i&&i===t.buttonValue});window.registerAcroformField(i,o,r?t.buttonValue:void 0,t.buttonValue,this.data.fieldValue);o.addEventListener("updateFromAngular",t=>e.setValue(i,{value:t.detail}));if(this.enableScripting&&this.hasJSActions){const a=t.buttonValue;o.addEventListener("updatefromsandbox",t=>{const s={value:t=>{const s=a===t.detail.value;for(const a of this._getElementsByName(t.target.name)){const t=s&&a.id===i;a.domElement&&(a.domElement.checked=t);e.setValue(a.id,{value:t});window.updateAngularFormValue(i,{value:t})}}};this._dispatchEventFromSandbox(s,t)});this._setEventListeners(o,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.checked)}this._setDefaultPropertiesFromJS(o);this.container.append(o);return this.container}}class PushButtonWidgetAnnotationElement extends LinkAnnotationElement{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;if(this.enableScripting&&this.hasJSActions&&t){this._setDefaultPropertiesFromJS(t);t.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({},e)})}return e}}class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,i=window.getFormValueFromAngular(this.data.fieldName),a=e.getValue(t,{value:this.data.fieldValue}),s=i.value?i:a;i!==a&&e.setValue(t,{value:i.value});const n=document.createElement("select");go.add(n);n.setAttribute("data-element-id",t);n.disabled=this.data.readOnly;this._setRequired(n,this.data.required);n.name=this.data.fieldName;n.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;if(!this.data.combo){n.size=this.data.options.length;this.data.multiSelect&&(n.multiple=!0)}n.addEventListener("resetform",e=>{const t=this.data.defaultFieldValue;for(const e of n.options)e.selected=e.value===t});const fixDisplayValue=(e,t)=>{const i=t.replaceAll(" "," ");e.textContent=i;i!==t&&e.setAttribute("display-value",t)};for(const e of this.data.options){const t=document.createElement("option");fixDisplayValue(t,e.displayValue);t.value=e.exportValue;if(s.value.includes(e.exportValue)){t.setAttribute("selected",!0);r=!1}n.append(t)}let o=null;if(r){const e=document.createElement("option");e.value=" ";e.setAttribute("hidden",!0);e.setAttribute("selected",!0);n.prepend(e);o=()=>{e.remove();n.removeEventListener("input",o);o=null};n.addEventListener("input",o)}const getValue=e=>{const t=e?"value":"textContent",{options:i,multiple:a}=n;return a?Array.prototype.filter.call(i,e=>e.selected).map(e=>e[t]):-1===i.selectedIndex?null:i[i.selectedIndex][t]};let l=getValue(!1);const getItems=e=>{const t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.getAttribute("display-value")||e.textContent,exportValue:e.value}))};window.registerAcroformField(t,n,l,void 0,this.data.fieldValue);n.addEventListener("updateFromAngular",i=>e.setValue(t,{value:i.detail}));if(this.enableScripting&&this.hasJSActions){n.addEventListener("updatefromsandbox",i=>{const a={value(i){o?.();const a=i.detail.value,s=new Set(Array.isArray(a)?a:[a]);for(const e of n.options)e.selected=s.has(e.value);e.setValue(t,{value:getValue(!0)});l=getValue(!1);window.updateAngularFormValue(t,{value:l})},multipleSelection(e){n.multiple=!0},remove(i){const a=n.options,s=i.detail.remove;a[s].selected=!1;n.remove(s);if(a.length>0){-1===Array.prototype.findIndex.call(a,e=>e.selected)&&(a[0].selected=!0)}e.setValue(t,{value:getValue(!0),items:getItems(i)});l=getValue(!1)},clear(i){for(;0!==n.length;)n.remove(0);e.setValue(t,{value:null,items:[]});l=getValue(!1);window.updateAngularFormValue(t,{value:l})},insert(i){const{index:a,displayValue:s,exportValue:r}=i.detail.insert,o=n.children[a],d=document.createElement("option");fixDisplayValue(d,s);d.value=r;o?o.before(d):n.append(d);e.setValue(t,{value:getValue(!0),items:getItems(i)});l=getValue(!1);window.updateAngularFormValue(t,{value:l})},items(i){const{items:a}=i.detail;for(;0!==n.length;)n.remove(0);for(const e of a){const{displayValue:t,exportValue:i}=e,a=document.createElement("option");fixDisplayValue(a,t);a.value=i;n.append(a)}n.options.length>0&&(n.options[0].selected=!0);e.setValue(t,{value:getValue(!0),items:getItems(i)});l=getValue(!1);window.updateAngularFormValue(t,{value:l})},indices(i){const a=new Set(i.detail.indices);for(const e of i.target.options)e.selected=a.has(e.index);e.setValue(t,{value:getValue(!0)});l=getValue(!1);window.updateAngularFormValue(t,{value:l})},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(a,i)});n.addEventListener("input",i=>{const a=getValue(!0),s=getValue(!1);e.setValue(t,{value:a});window.updateAngularFormValue(t,{value:a});i.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:l,change:s,changeEx:a,willCommit:!1,commitKey:1,keyDown:!1}})});this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],e=>e.target.value)}else n.addEventListener("input",function(i){e.setValue(t,{value:getValue(!0)});window.updateAngularFormValue(t,{value:getValue(!0)})});this.data.combo&&this._setTextStyle(n);this._setBackgroundColor(n);this._setDefaultPropertiesFromJS(n);this.container.append(n);return this.container}}var bo=new WeakSet;class PopupAnnotationElement extends AnnotationElement{constructor(e){const{data:t,elements:i,parent:a}=e,s=!!a._commentManager;super(e,{isRenderable:!s&&AnnotationElement._hasPopupData(t)});annotation_layer_classPrivateMethodInitSpec(this,bo);this.elements=i;if(s&&AnnotationElement._hasPopupData(t)){const e=this.popup=annotation_layer_assertClassBrand(bo,this,_createPopup).call(this);for(const t of i)t.popup=e}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation");e.role="comment";const t=this.popup=annotation_layer_assertClassBrand(bo,this,_createPopup).call(this),i=[];for(const e of this.elements){e.popup=t;e.container.ariaHasPopup="dialog";i.push(e.data.id);e.addHighlightArea()}this.container.setAttribute("aria-controls",i.map(e=>`${g}${e}`).join(","));return this.container}}function _createPopup(){return new PopupElement({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})}var yo=new WeakMap,So=new WeakMap,Co=new WeakMap,xo=new WeakMap,ko=new WeakMap,Eo=new WeakMap,Ao=new WeakMap,Go=new WeakMap,Bo=new WeakMap,Mo=new WeakMap,Io=new WeakMap,To=new WeakMap,Do=new WeakMap,Lo=new WeakMap,No=new WeakMap,Ro=new WeakMap,Oo=new WeakMap,Wo=new WeakMap,jo=new WeakMap,Vo=new WeakMap,Uo=new WeakMap,zo=new WeakMap,Ho=new WeakMap,$o=new WeakMap,Ko=new WeakMap,Xo=new WeakMap,qo=new WeakSet;class PopupElement{constructor({container:e,color:t,elements:i,titleObj:a,modificationDate:s,contentsObj:n,richText:r,parent:o,rect:l,parentRect:d,open:c,commentManager:h=null}){annotation_layer_classPrivateMethodInitSpec(this,qo);annotation_layer_classPrivateFieldInitSpec(this,yo,null);annotation_layer_classPrivateFieldInitSpec(this,So,annotation_layer_assertClassBrand(qo,this,annotation_layer_keyDown).bind(this));annotation_layer_classPrivateFieldInitSpec(this,Co,annotation_layer_assertClassBrand(qo,this,_hide).bind(this));annotation_layer_classPrivateFieldInitSpec(this,xo,annotation_layer_assertClassBrand(qo,this,_show).bind(this));annotation_layer_classPrivateFieldInitSpec(this,ko,annotation_layer_assertClassBrand(qo,this,_toggle).bind(this));annotation_layer_classPrivateFieldInitSpec(this,Eo,null);annotation_layer_classPrivateFieldInitSpec(this,Ao,null);annotation_layer_classPrivateFieldInitSpec(this,Go,null);annotation_layer_classPrivateFieldInitSpec(this,Bo,null);annotation_layer_classPrivateFieldInitSpec(this,Mo,null);annotation_layer_classPrivateFieldInitSpec(this,Io,null);annotation_layer_classPrivateFieldInitSpec(this,To,null);annotation_layer_classPrivateFieldInitSpec(this,Do,!1);annotation_layer_classPrivateFieldInitSpec(this,Lo,null);annotation_layer_classPrivateFieldInitSpec(this,No,null);annotation_layer_classPrivateFieldInitSpec(this,Ro,null);annotation_layer_classPrivateFieldInitSpec(this,Oo,null);annotation_layer_classPrivateFieldInitSpec(this,Wo,null);annotation_layer_classPrivateFieldInitSpec(this,jo,null);annotation_layer_classPrivateFieldInitSpec(this,Vo,null);annotation_layer_classPrivateFieldInitSpec(this,Uo,null);annotation_layer_classPrivateFieldInitSpec(this,zo,null);annotation_layer_classPrivateFieldInitSpec(this,Ho,null);annotation_layer_classPrivateFieldInitSpec(this,$o,!1);annotation_layer_classPrivateFieldInitSpec(this,Ko,null);annotation_layer_classPrivateFieldInitSpec(this,Xo,null);annotation_layer_classPrivateFieldSet(Ao,this,e);annotation_layer_classPrivateFieldSet(zo,this,a);annotation_layer_classPrivateFieldSet(Go,this,n);annotation_layer_classPrivateFieldSet(Uo,this,r);annotation_layer_classPrivateFieldSet(Io,this,o);annotation_layer_classPrivateFieldSet(Eo,this,t);annotation_layer_classPrivateFieldSet(Vo,this,l);annotation_layer_classPrivateFieldSet(To,this,d);annotation_layer_classPrivateFieldSet(Mo,this,i);annotation_layer_classPrivateFieldSet(yo,this,h);annotation_layer_classPrivateFieldSet(Ko,this,i[0]);annotation_layer_classPrivateFieldSet(Bo,this,PDFDateString.toDateObject(s));this.trigger=i.flatMap(e=>e.getElementsToTriggerPopup());if(!h){annotation_layer_assertClassBrand(qo,this,_addEventListeners).call(this);annotation_layer_classPrivateFieldGet(Ao,this).hidden=!0;c&&annotation_layer_assertClassBrand(qo,this,_toggle).call(this)}}renderCommentButton(){if(annotation_layer_classPrivateFieldGet(Oo,this)){annotation_layer_classPrivateFieldGet(Oo,this).parentNode||annotation_layer_classPrivateFieldGet(Ko,this).container.after(annotation_layer_classPrivateFieldGet(Oo,this));return}annotation_layer_classPrivateFieldGet(Wo,this)||annotation_layer_assertClassBrand(qo,this,_setCommentButtonPosition).call(this);if(!annotation_layer_classPrivateFieldGet(Wo,this))return;const{signal:e}=annotation_layer_classPrivateFieldSet(No,this,new AbortController),t=annotation_layer_classPrivateFieldGet(Ko,this).hasOwnCommentButton,togglePopup=()=>{annotation_layer_classPrivateFieldGet(yo,this).toggleCommentPopup(this,!0,void 0,!t)},showPopup=()=>{annotation_layer_classPrivateFieldGet(yo,this).toggleCommentPopup(this,!1,!0,!t)},hidePopup=()=>{annotation_layer_classPrivateFieldGet(yo,this).toggleCommentPopup(this,!1,!1)};if(t){annotation_layer_classPrivateFieldSet(Oo,this,annotation_layer_classPrivateFieldGet(Ko,this).container);for(const t of this.trigger){t.ariaHasPopup="dialog";t.ariaControls="commentPopup";t.addEventListener("keydown",annotation_layer_classPrivateFieldGet(So,this),{signal:e});t.addEventListener("click",togglePopup,{signal:e});t.addEventListener("pointerenter",showPopup,{signal:e});t.addEventListener("pointerleave",hidePopup,{signal:e});t.classList.add("popupTriggerArea")}}else{const t=annotation_layer_classPrivateFieldSet(Oo,this,document.createElement("button"));t.className="annotationCommentButton";const i=annotation_layer_classPrivateFieldGet(Ko,this).container;t.style.zIndex=parseInt(i.style.zIndex,10)+1;t.tabIndex=0;t.ariaHasPopup="dialog";t.ariaControls="commentPopup";t.setAttribute("data-l10n-id","pdfjs-show-comment-button");annotation_layer_assertClassBrand(qo,this,_updateColor).call(this);annotation_layer_assertClassBrand(qo,this,_updateCommentButtonPosition).call(this);t.addEventListener("keydown",annotation_layer_classPrivateFieldGet(So,this),{signal:e});t.addEventListener("click",togglePopup,{signal:e});t.addEventListener("pointerenter",showPopup,{signal:e});t.addEventListener("pointerleave",hidePopup,{signal:e});i.after(t)}}get commentButtonColor(){const{color:e,opacity:t}=annotation_layer_classPrivateFieldGet(Ko,this).commentData;return e?annotation_layer_classPrivateFieldGet(Io,this)._commentManager.makeCommentColor(e,t):null}focusCommentButton(){setTimeout(()=>{annotation_layer_classPrivateFieldGet(Oo,this)?.focus()},0)}getData(){const{richText:e,color:t,opacity:i,creationDate:a,modificationDate:s}=annotation_layer_classPrivateFieldGet(Ko,this).commentData;return{contentsObj:{str:this.comment},richText:e,color:t,opacity:i,creationDate:a,modificationDate:s}}get elementBeforePopup(){return annotation_layer_classPrivateFieldGet(Oo,this)}get comment(){annotation_layer_classPrivateFieldGet(Xo,this)||annotation_layer_classPrivateFieldSet(Xo,this,annotation_layer_classPrivateFieldGet(Ko,this).commentText);return annotation_layer_classPrivateFieldGet(Xo,this)}set comment(e){e!==this.comment&&(annotation_layer_classPrivateFieldGet(Ko,this).commentText=annotation_layer_classPrivateFieldSet(Xo,this,e))}focus(){annotation_layer_classPrivateFieldGet(Ko,this).container?.focus()}get parentBoundingClientRect(){return annotation_layer_classPrivateFieldGet(Ko,this).layer.getBoundingClientRect()}setCommentButtonStates({selected:e,hasPopup:t}){if(annotation_layer_classPrivateFieldGet(Oo,this)){annotation_layer_classPrivateFieldGet(Oo,this).classList.toggle("selected",e);annotation_layer_classPrivateFieldGet(Oo,this).ariaExpanded=t}}setSelectedCommentButton(e){annotation_layer_classPrivateFieldGet(Oo,this).classList.toggle("selected",e)}get commentPopupPosition(){if(annotation_layer_classPrivateFieldGet(jo,this))return annotation_layer_classPrivateFieldGet(jo,this);const{x:e,y:t,height:i}=annotation_layer_classPrivateFieldGet(Oo,this).getBoundingClientRect(),{x:a,y:s,width:n,height:r}=annotation_layer_classPrivateFieldGet(Ko,this).layer.getBoundingClientRect();return[(e-a)/n,(t+i-s)/r]}set commentPopupPosition(e){annotation_layer_classPrivateFieldSet(jo,this,e)}hasDefaultPopupPosition(){return null===annotation_layer_classPrivateFieldGet(jo,this)}get commentButtonPosition(){return annotation_layer_classPrivateFieldGet(Wo,this)}get commentButtonWidth(){return annotation_layer_classPrivateFieldGet(Oo,this).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(e){const[t,i]=annotation_layer_classPrivateFieldGet(jo,this)||this.commentButtonPosition.map(e=>e/100),a=this.parentBoundingClientRect,{x:s,y:n,width:r,height:o}=a;annotation_layer_classPrivateFieldGet(yo,this).showDialog(null,this,s+t*r,n+i*o,{...e,parentDimensions:a})}render(){if(annotation_layer_classPrivateFieldGet(Lo,this))return;const e=annotation_layer_classPrivateFieldSet(Lo,this,document.createElement("div"));e.className="popup";if(annotation_layer_classPrivateFieldGet(Eo,this)){const t=e.style.outlineColor=Util.makeHexColor(...annotation_layer_classPrivateFieldGet(Eo,this));e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}const t=document.createElement("span");t.className="header";if(annotation_layer_classPrivateFieldGet(zo,this)?.str){const e=document.createElement("span");e.className="title";t.append(e);({dir:e.dir,str:e.textContent}=annotation_layer_classPrivateFieldGet(zo,this))}e.append(t);if(annotation_layer_classPrivateFieldGet(Bo,this)){const e=document.createElement("time");e.className="popupDate";e.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string");e.setAttribute("data-l10n-args",JSON.stringify({dateObj:annotation_layer_classPrivateFieldGet(Bo,this).valueOf()}));e.dateTime=annotation_layer_classPrivateFieldGet(Bo,this).toISOString();t.append(e)}renderRichText({html:annotation_layer_classPrivateGetter(qo,this,_get_html)||annotation_layer_classPrivateFieldGet(Go,this).str,dir:annotation_layer_classPrivateFieldGet(Go,this)?.dir,className:"popupContent"},e);annotation_layer_classPrivateFieldGet(Ao,this).append(e)}updateEdited({rect:e,popup:t,deleted:i}){if(annotation_layer_classPrivateFieldGet(yo,this)){if(i){this.remove();annotation_layer_classPrivateFieldSet(Xo,this,null)}else if(t)if(t.deleted)this.remove();else{annotation_layer_assertClassBrand(qo,this,_updateColor).call(this);annotation_layer_classPrivateFieldSet(Xo,this,t.text)}if(e){annotation_layer_classPrivateFieldSet(Wo,this,null);annotation_layer_assertClassBrand(qo,this,_setCommentButtonPosition).call(this);annotation_layer_assertClassBrand(qo,this,_updateCommentButtonPosition).call(this)}}else if(i||t?.deleted)this.remove();else{annotation_layer_assertClassBrand(qo,this,_addEventListeners).call(this);annotation_layer_classPrivateFieldGet(Ho,this)||annotation_layer_classPrivateFieldSet(Ho,this,{contentsObj:annotation_layer_classPrivateFieldGet(Go,this),richText:annotation_layer_classPrivateFieldGet(Uo,this)});e&&annotation_layer_classPrivateFieldSet(Ro,this,null);if(t&&t.text){annotation_layer_classPrivateFieldSet(Uo,this,annotation_layer_assertClassBrand(qo,this,_makePopupContent).call(this,t.text));annotation_layer_classPrivateFieldSet(Bo,this,PDFDateString.toDateObject(t.date));annotation_layer_classPrivateFieldSet(Go,this,null)}annotation_layer_classPrivateFieldGet(Lo,this)?.remove();annotation_layer_classPrivateFieldSet(Lo,this,null)}}resetEdited(){if(annotation_layer_classPrivateFieldGet(Ho,this)){({contentsObj:_toSetter(annotation_layer_classPrivateFieldSet,[Go,this])._,richText:_toSetter(annotation_layer_classPrivateFieldSet,[Uo,this])._}=annotation_layer_classPrivateFieldGet(Ho,this));annotation_layer_classPrivateFieldSet(Ho,this,null);annotation_layer_classPrivateFieldGet(Lo,this)?.remove();annotation_layer_classPrivateFieldSet(Lo,this,null);annotation_layer_classPrivateFieldSet(Ro,this,null)}}remove(){annotation_layer_classPrivateFieldGet(No,this)?.abort();annotation_layer_classPrivateFieldSet(No,this,null);annotation_layer_classPrivateFieldGet(Lo,this)?.remove();annotation_layer_classPrivateFieldSet(Lo,this,null);annotation_layer_classPrivateFieldSet($o,this,!1);annotation_layer_classPrivateFieldSet(Do,this,!1);annotation_layer_classPrivateFieldGet(Oo,this)?.remove();annotation_layer_classPrivateFieldSet(Oo,this,null);if(this.trigger)for(const e of this.trigger)e.classList.remove("popupTriggerArea")}forceHide(){annotation_layer_classPrivateFieldSet($o,this,this.isVisible);annotation_layer_classPrivateFieldGet($o,this)&&(annotation_layer_classPrivateFieldGet(Ao,this).hidden=!0)}maybeShow(){if(!annotation_layer_classPrivateFieldGet(yo,this)){annotation_layer_assertClassBrand(qo,this,_addEventListeners).call(this);if(annotation_layer_classPrivateFieldGet($o,this)){annotation_layer_classPrivateFieldGet(Lo,this)||annotation_layer_assertClassBrand(qo,this,_show).call(this);annotation_layer_classPrivateFieldSet($o,this,!1);annotation_layer_classPrivateFieldGet(Ao,this).hidden=!1}}}get isVisible(){return!annotation_layer_classPrivateFieldGet(yo,this)&&!1===annotation_layer_classPrivateFieldGet(Ao,this).hidden}}function _addEventListeners(){if(annotation_layer_classPrivateFieldGet(No,this))return;annotation_layer_classPrivateFieldSet(No,this,new AbortController);const{signal:e}=annotation_layer_classPrivateFieldGet(No,this);for(const t of this.trigger){t.addEventListener("click",annotation_layer_classPrivateFieldGet(ko,this),{signal:e});t.addEventListener("pointerenter",annotation_layer_classPrivateFieldGet(xo,this),{signal:e});t.addEventListener("pointerleave",annotation_layer_classPrivateFieldGet(Co,this),{signal:e});t.classList.add("popupTriggerArea")}for(const t of annotation_layer_classPrivateFieldGet(Mo,this))t.container?.addEventListener("keydown",annotation_layer_classPrivateFieldGet(So,this),{signal:e})}function _setCommentButtonPosition(){const e=annotation_layer_classPrivateFieldGet(Mo,this).find(e=>e.hasCommentButton);e&&annotation_layer_classPrivateFieldSet(Wo,this,e._normalizePoint(e.commentButtonPosition))}function _updateCommentButtonPosition(){if(annotation_layer_classPrivateFieldGet(Ko,this).extraPopupElement&&!annotation_layer_classPrivateFieldGet(Ko,this).editor)return;annotation_layer_classPrivateFieldGet(Oo,this)||this.renderCommentButton();const[e,t]=annotation_layer_classPrivateFieldGet(Wo,this),{style:i}=annotation_layer_classPrivateFieldGet(Oo,this);i.left=`calc(${e}%)`;i.top=`calc(${t}% - var(--comment-button-dim))`}function _updateColor(){if(!annotation_layer_classPrivateFieldGet(Ko,this).extraPopupElement){annotation_layer_classPrivateFieldGet(Oo,this)||this.renderCommentButton();annotation_layer_classPrivateFieldGet(Oo,this).style.backgroundColor=this.commentButtonColor||""}}function _get_html(e){const t=annotation_layer_classPrivateFieldGet(Uo,e),i=annotation_layer_classPrivateFieldGet(Go,e);return!t?.str||i?.str&&i.str!==t.str?null:annotation_layer_classPrivateFieldGet(Uo,e).html||null}function _get_fontSize(e){return annotation_layer_classPrivateGetter(qo,e,_get_html)?.attributes?.style?.fontSize||0}function _get_fontColor(e){return annotation_layer_classPrivateGetter(qo,e,_get_html)?.attributes?.style?.color||null}function _makePopupContent(e){const t=[],i={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},a={style:{color:annotation_layer_classPrivateGetter(qo,this,_get_fontColor),fontSize:annotation_layer_classPrivateGetter(qo,this,_get_fontSize)?`calc(${annotation_layer_classPrivateGetter(qo,this,_get_fontSize)}px * var(--total-scale-factor))`:""}};for(const i of e.split("\n"))t.push({name:"span",value:i,attributes:a});return i}function annotation_layer_keyDown(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||("Enter"===e.key||"Escape"===e.key&&annotation_layer_classPrivateFieldGet(Do,this))&&annotation_layer_assertClassBrand(qo,this,_toggle).call(this)}function _setPosition(){if(null!==annotation_layer_classPrivateFieldGet(Ro,this))return;const{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:i,pageX:a,pageY:s}}}=annotation_layer_classPrivateFieldGet(Io,this);let n=!!annotation_layer_classPrivateFieldGet(To,this),r=annotation_layer_classPrivateFieldGet(n?To:Vo,this);for(const e of annotation_layer_classPrivateFieldGet(Mo,this))if(!r||null!==Util.intersect(e.data.rect,r)){r=e.data.rect;n=!0;break}const o=Util.normalizeRect([r[0],e[3]-r[1]+e[1],r[2],e[3]-r[3]+e[1]]),l=n?r[2]-r[0]+5:0,d=o[0]+l,c=o[1];annotation_layer_classPrivateFieldSet(Ro,this,[100*(d-a)/t,100*(c-s)/i]);const{style:h}=annotation_layer_classPrivateFieldGet(Ao,this);h.left=`${annotation_layer_classPrivateFieldGet(Ro,this)[0]}%`;h.top=`${annotation_layer_classPrivateFieldGet(Ro,this)[1]}%`}function _toggle(){if(annotation_layer_classPrivateFieldGet(yo,this))annotation_layer_classPrivateFieldGet(yo,this).toggleCommentPopup(this,!1);else{annotation_layer_classPrivateFieldSet(Do,this,!annotation_layer_classPrivateFieldGet(Do,this));if(annotation_layer_classPrivateFieldGet(Do,this)){annotation_layer_assertClassBrand(qo,this,_show).call(this);annotation_layer_classPrivateFieldGet(Ao,this).addEventListener("click",annotation_layer_classPrivateFieldGet(ko,this));annotation_layer_classPrivateFieldGet(Ao,this).addEventListener("keydown",annotation_layer_classPrivateFieldGet(So,this))}else{annotation_layer_assertClassBrand(qo,this,_hide).call(this);annotation_layer_classPrivateFieldGet(Ao,this).removeEventListener("click",annotation_layer_classPrivateFieldGet(ko,this));annotation_layer_classPrivateFieldGet(Ao,this).removeEventListener("keydown",annotation_layer_classPrivateFieldGet(So,this))}}}function _show(){annotation_layer_classPrivateFieldGet(Lo,this)||this.render();if(this.isVisible)annotation_layer_classPrivateFieldGet(Do,this)&&annotation_layer_classPrivateFieldGet(Ao,this).classList.add("focused");else{annotation_layer_assertClassBrand(qo,this,_setPosition).call(this);annotation_layer_classPrivateFieldGet(Ao,this).hidden=!1;annotation_layer_classPrivateFieldGet(Ao,this).style.zIndex=parseInt(annotation_layer_classPrivateFieldGet(Ao,this).style.zIndex,10)+1e3;const e=annotation_layer_classPrivateFieldGet(Ao,this).closest(".page");e&&(e.style.overflow="visible")}}function _hide(){annotation_layer_classPrivateFieldGet(Ao,this).classList.remove("focused");if(annotation_layer_classPrivateFieldGet(Do,this)||!this.isVisible)return;annotation_layer_classPrivateFieldGet(Ao,this).hidden=!0;annotation_layer_classPrivateFieldGet(Ao,this).style.zIndex=parseInt(annotation_layer_classPrivateFieldGet(Ao,this).style.zIndex,10)-1e3;const e=annotation_layer_classPrivateFieldGet(Ao,this).closest(".page");e&&(e.style.overflow="")}class FreeTextAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.textContent=e.data.textContent;this.textPosition=e.data.textPosition;this.annotationEditorType=f.FREETEXT}render(){this.container.classList.add("freeTextAnnotation");if(this.textContent){const e=this.contentElement=document.createElement("div");e.classList.add("annotationTextContent");e.setAttribute("role","comment");for(const t of this.textContent){const i=document.createElement("span");i.textContent=t;e.append(i)}this.container.append(e)}if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this._editOnDoubleClick();return this.container}}var Yo=new WeakMap;class LineAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,Yo,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:t,height:i}=this,a=this.svgFactory.create(t,i,!0),s=annotation_layer_classPrivateFieldSet(Yo,this,this.svgFactory.createElement("svg:line"));s.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]);s.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]);s.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]);s.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]);s.setAttribute("stroke-width",e.borderStyle.width||1);s.setAttribute("stroke","transparent");s.setAttribute("fill","transparent");a.append(s);this.container.append(a);if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(Yo,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var Zo=new WeakMap;class SquareAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,Zo,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:t,height:i}=this,a=this.svgFactory.create(t,i,!0),s=e.borderStyle.width,n=annotation_layer_classPrivateFieldSet(Zo,this,this.svgFactory.createElement("svg:rect"));n.setAttribute("x",s/2);n.setAttribute("y",s/2);n.setAttribute("width",t-s);n.setAttribute("height",i-s);n.setAttribute("stroke-width",s||1);n.setAttribute("stroke","transparent");n.setAttribute("fill","transparent");a.append(n);this.container.append(a);if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(Zo,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var Qo=new WeakMap;class CircleAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,Qo,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:t,height:i}=this,a=this.svgFactory.create(t,i,!0),s=e.borderStyle.width,n=annotation_layer_classPrivateFieldSet(Qo,this,this.svgFactory.createElement("svg:ellipse"));n.setAttribute("cx",t/2);n.setAttribute("cy",i/2);n.setAttribute("rx",t/2-s/2);n.setAttribute("ry",i/2-s/2);n.setAttribute("stroke-width",s||1);n.setAttribute("stroke","transparent");n.setAttribute("fill","transparent");a.append(n);this.container.append(a);if(!e.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(Qo,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}var Jo=new WeakMap;class PolylineAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateFieldInitSpec(this,Jo,null);this.containerClassName="polylineAnnotation";this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:t,borderStyle:i,popupRef:a},width:s,height:n}=this;if(!t)return this.container;const r=this.svgFactory.create(s,n,!0);let o=[];for(let i=0,a=t.length;i<a;i+=2){const a=t[i]-e[0],s=e[3]-t[i+1];o.push(`${a},${s}`)}o=o.join(" ");const l=annotation_layer_classPrivateFieldSet(Jo,this,this.svgFactory.createElement(this.svgElementName));l.setAttribute("points",o);l.setAttribute("stroke-width",i.width||1);l.setAttribute("stroke","transparent");l.setAttribute("fill","transparent");r.append(l);this.container.append(r);if(!a&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(Jo,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}class PolygonAnnotationElement extends PolylineAnnotationElement{constructor(e){super(e);this.containerClassName="polygonAnnotation";this.svgElementName="svg:polygon"}}class CaretAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("caretAnnotation");if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}return this.container}}var el=new WeakMap,tl=new WeakMap,il=new WeakSet;class InkAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});annotation_layer_classPrivateMethodInitSpec(this,il);annotation_layer_classPrivateFieldInitSpec(this,el,null);annotation_layer_classPrivateFieldInitSpec(this,tl,[]);this.containerClassName="inkAnnotation";this.svgElementName="svg:polyline";this.annotationEditorType="InkHighlight"===this.data.it?f.HIGHLIGHT:f.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:t,inkLists:i,borderStyle:a,popupRef:s}}=this,{transform:n,width:r,height:o}=annotation_layer_assertClassBrand(il,this,_getTransform).call(this,t,e),l=this.svgFactory.create(r,o,!0),d=annotation_layer_classPrivateFieldSet(el,this,this.svgFactory.createElement("svg:g"));l.append(d);d.setAttribute("stroke-width",a.width||1);d.setAttribute("stroke-linecap","round");d.setAttribute("stroke-linejoin","round");d.setAttribute("stroke-miterlimit",10);d.setAttribute("stroke","transparent");d.setAttribute("fill","transparent");d.setAttribute("transform",n);for(const e of i){const t=this.svgFactory.createElement(this.svgElementName);annotation_layer_classPrivateFieldGet(tl,this).push(t);t.setAttribute("points",e.join(","));d.append(t)}if(!s&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.append(l);this._editOnDoubleClick();return this.container}updateEdited(e){super.updateEdited(e);const{thickness:t,points:i,rect:a}=e,s=annotation_layer_classPrivateFieldGet(el,this);t>=0&&s.setAttribute("stroke-width",t||1);if(i)for(let e=0,t=annotation_layer_classPrivateFieldGet(tl,this).length;e<t;e++)annotation_layer_classPrivateFieldGet(tl,this)[e].setAttribute("points",i[e].join(","));if(a){const{transform:e,width:t,height:i}=annotation_layer_assertClassBrand(il,this,_getTransform).call(this,this.data.rotation,a);s.parentElement.setAttribute("viewBox",`0 0 ${t} ${i}`);s.setAttribute("transform",e)}}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(tl,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}function _getTransform(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}class HighlightAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0});this.annotationEditorType=f.HIGHLIGHT}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("highlightAnnotation");this._editOnDoubleClick();if(e){const t=document.createElement("mark");t.classList.add("overlaidText");t.textContent=e;this.container.append(t)}return this.container}}class UnderlineAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("underlineAnnotation");if(e){const t=document.createElement("u");t.classList.add("overlaidText");t.textContent=e;this.container.append(t)}return this.container}}class SquigglyAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("squigglyAnnotation");if(e){const t=document.createElement("u");t.classList.add("overlaidText");t.textContent=e;this.container.append(t)}return this.container}}class StrikeOutAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:e,popupRef:t}}=this;if(!t&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this.container.classList.add("strikeoutAnnotation");if(e){const t=document.createElement("s");t.classList.add("overlaidText");t.textContent=e;this.container.append(t)}return this.container}}class StampAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.annotationEditorType=f.STAMP}render(){this.container.classList.add("stampAnnotation");this.container.setAttribute("role","img");if(!this.data.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}this._editOnDoubleClick();return this.container}}var al=new WeakMap,sl=new WeakSet;class FileAttachmentAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0});annotation_layer_classPrivateMethodInitSpec(this,sl);annotation_layer_classPrivateFieldInitSpec(this,al,null);const{fileId:t,file:i}=this.data;this.filename=i.filename;this.content=i.content;this.fileId=t;this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,attachmentId:this.fileId,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:t}=this;let i;if(t.hasAppearance||0===t.fillAlpha)i=document.createElement("div");else{i=document.createElement("img");i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`;t.fillAlpha&&t.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*t.fillAlpha)}%);`)}i.addEventListener("dblclick",annotation_layer_assertClassBrand(sl,this,_download).bind(this));annotation_layer_classPrivateFieldSet(al,this,i);const{isMac:a}=FeatureTest.platform;e.addEventListener("keydown",e=>{"Enter"===e.key&&(a?e.metaKey:e.ctrlKey)&&annotation_layer_assertClassBrand(sl,this,_download).call(this)});if(!t.popupRef&&this.hasPopupData){this.hasOwnCommentButton=!0;this._createPopup()}else i.classList.add("popupTriggerArea");e.append(i);return e}getElementsToTriggerPopup(){return annotation_layer_classPrivateFieldGet(al,this)}addHighlightArea(){this.container.classList.add("highlightArea")}}async function _download(){const{fileId:e,filename:t,content:i}=this,a=await this.linkService.getAttachmentContent(e)||i;a&&this.downloadManager?.openOrDownloadData(a,t)}var nl=new WeakMap,rl=new WeakMap,ol=new WeakMap,ll=new WeakSet;class MediaAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!!e.data.richMedia});annotation_layer_classPrivateMethodInitSpec(this,ll);annotation_layer_classPrivateFieldInitSpec(this,nl,new AbortController);annotation_layer_classPrivateFieldInitSpec(this,rl,null);annotation_layer_classPrivateFieldInitSpec(this,ol,null)}render(){this.container.classList.add("mediaAnnotation");const{filename:e}=this.data.richMedia,t=document.createElement("button");t.className="mediaPlayButton";t.type="button";t.title=t.ariaLabel=e;t.addEventListener("click",()=>annotation_layer_assertClassBrand(ll,this,_load).call(this,t),{signal:annotation_layer_classPrivateFieldGet(nl,this).signal});this.container.append(t);return this.container}destroy(){annotation_layer_classPrivateFieldGet(nl,this).abort();if(annotation_layer_classPrivateFieldGet(ol,this)){annotation_layer_classPrivateFieldGet(ol,this).pause();annotation_layer_classPrivateFieldGet(ol,this).removeAttribute("src");annotation_layer_classPrivateFieldGet(ol,this).load();annotation_layer_classPrivateFieldSet(ol,this,null)}annotation_layer_assertClassBrand(ll,this,_revokeContentUrl).call(this)}}async function _load(e){const{fileId:t,filename:i,contentType:a}=this.data.richMedia;e.disabled=!0;let s;try{s=await this.linkService.getAttachmentContent(t)}catch{return}finally{e.disabled=!1}if(!s||!e.isConnected)return;const{signal:n}=annotation_layer_classPrivateFieldGet(nl,this),r=URL.createObjectURL(new Blob([s],{type:a}));annotation_layer_classPrivateFieldSet(rl,this,r);const o=a.startsWith("audio/"),l=document.createElement(o?"audio":"video");annotation_layer_classPrivateFieldSet(ol,this,l);l.className="mediaContent";this._setBackgroundColor(l);l.src=r;l.title=i;l.controls=!0;l.autoplay=!0;l.tabIndex=0;if(o){let e=!1,t=!1;const updateControls=()=>{l.controls=e||t};this.container.addEventListener("pointerenter",()=>{e=!0;updateControls()},{signal:n});this.container.addEventListener("pointerleave",()=>{e=!1;updateControls()},{signal:n});this.container.addEventListener("focusin",()=>{t=!0;updateControls()},{signal:n});this.container.addEventListener("focusout",()=>{t=!1;updateControls()},{signal:n})}l.addEventListener("emptied",()=>annotation_layer_assertClassBrand(ll,this,_revokeContentUrl).call(this,r),{once:!0,signal:n});e.replaceWith(l);l.play().catch(()=>{})}function _revokeContentUrl(e=annotation_layer_classPrivateFieldGet(rl,this)){if(e&&e===annotation_layer_classPrivateFieldGet(rl,this)){URL.revokeObjectURL(e);annotation_layer_classPrivateFieldSet(rl,this,null)}}var dl,cl=new WeakMap,hl=new WeakMap,ul=new WeakMap,_l=new WeakMap,pl=new WeakMap,gl=new WeakMap,ml=new WeakMap,fl=new WeakMap,vl=new WeakSet;class AnnotationLayer{constructor({div:e,accessibilityManager:t,annotationCanvasMap:i,annotationEditorUIManager:a,page:s,viewport:n,structTreeLayer:r,commentManager:o,linkService:l,annotationStorage:d}){annotation_layer_classPrivateMethodInitSpec(this,vl);annotation_layer_classPrivateFieldInitSpec(this,cl,null);annotation_layer_classPrivateFieldInitSpec(this,hl,null);annotation_layer_classPrivateFieldInitSpec(this,ul,null);annotation_layer_classPrivateFieldInitSpec(this,_l,new Map);annotation_layer_classPrivateFieldInitSpec(this,pl,null);annotation_layer_classPrivateFieldInitSpec(this,gl,null);annotation_layer_classPrivateFieldInitSpec(this,ml,[]);annotation_layer_classPrivateFieldInitSpec(this,fl,!1);annotation_layer_defineProperty(this,"zIndex",0);this.div=e;annotation_layer_classPrivateFieldSet(cl,this,t);annotation_layer_classPrivateFieldSet(hl,this,i);annotation_layer_classPrivateFieldSet(pl,this,r||null);annotation_layer_classPrivateFieldSet(gl,this,l||null);annotation_layer_classPrivateFieldSet(ul,this,d||new AnnotationStorage);this.page=s;this.viewport=n;this._annotationEditorUIManager=a;this._commentManager=o||null}hasEditableAnnotations(){return annotation_layer_classPrivateFieldGet(_l,this).size>0}async render(e){const{annotations:t,optionalContentConfig:i}=e,a=this.div;setLayerDimensions(a,this.viewport);const s=new Map,n=[],r={data:null,layer:a,linkService:annotation_layer_classPrivateFieldGet(gl,this),downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,svgFactory:new DOMSVGFactory,annotationStorage:annotation_layer_classPrivateFieldGet(ul,this),enableComment:!0===e.enableComment,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const e of t){if(e.noHTML)continue;const t=e.annotationType===k.POPUP;if(t){const t=s.get(e.id);if(!t)continue;if(!this._commentManager){n.push(e);continue}r.elements=t}else if(e.rect[2]===e.rect[0]||e.rect[3]===e.rect[1])continue;r.data=e;const a=AnnotationElementFactory.create(r);if(!a.isRenderable)continue;if(!t){annotation_layer_classPrivateFieldGet(ml,this).push(a);e.popupRef&&s.getOrInsertComputed(e.popupRef,makeArr).push(a)}const o=a.render();e.hidden&&(o.style.visibility="hidden");a.updateOC(i);if(a._isEditable){annotation_layer_classPrivateFieldGet(_l,this).set(a.data.id,a);this._annotationEditorUIManager?.renderAnnotationElement(a)}}await annotation_layer_assertClassBrand(vl,this,_addElementsToDOM).call(this);for(const e of n){const t=r.elements=s.get(e.id);r.data=e;const i=AnnotationElementFactory.create(r);if(!i.isRenderable)continue;const a=i.render();i.contentElement.id=`${g}${e.id}`;e.hidden&&(a.style.visibility="hidden");t.at(-1).container.after(a)}annotation_layer_assertClassBrand(vl,this,_setAnnotationCanvasMap).call(this)}async addLinkAnnotations(e){const t={data:null,layer:this.div,linkService:annotation_layer_classPrivateFieldGet(gl,this),svgFactory:new DOMSVGFactory,parent:this};for(const i of e){i.borderStyle||=AnnotationLayer._defaultBorderStyle;t.data=i;const e=AnnotationElementFactory.create(t);if(e.isRenderable){e.render();e.contentElement.id=`${g}${i.id}`;annotation_layer_classPrivateFieldGet(ml,this).push(e)}}await annotation_layer_assertClassBrand(vl,this,_addElementsToDOM).call(this)}update({viewport:e,optionalContentConfig:t}){const i=this.div;this.viewport=e;setLayerDimensions(i,{rotation:e.rotation});for(const e of annotation_layer_classPrivateFieldGet(ml,this))e.updateOC(t);annotation_layer_assertClassBrand(vl,this,_setAnnotationCanvasMap).call(this);i.hidden=!1}destroy(){for(const e of annotation_layer_classPrivateFieldGet(ml,this)){e.destroy?.();annotation_layer_classPrivateFieldGet(cl,this)?.removePointerInTextLayer(e.contentElement)}annotation_layer_classPrivateFieldGet(ml,this).length=0;annotation_layer_classPrivateFieldGet(_l,this).clear();this.div.replaceChildren()}refreshCanvases(){annotation_layer_assertClassBrand(vl,this,_setAnnotationCanvasMap).call(this)}getEditableAnnotations(){return annotation_layer_classPrivateFieldGet(_l,this).values()}getEditableAnnotation(e){return annotation_layer_classPrivateFieldGet(_l,this).get(e)}addFakeAnnotation(e){const{div:t}=this,{id:i,rotation:a}=e,s=new EditorAnnotationElement({data:{id:i,rect:e.getPDFRect(),rotation:a},editor:e,layer:t,parent:this,enableComment:!!this._commentManager,linkService:annotation_layer_classPrivateFieldGet(gl,this),annotationStorage:annotation_layer_classPrivateFieldGet(ul,this)});s.render();s.contentElement.id=`${g}${i}`;s.createOrUpdatePopup();annotation_layer_classPrivateFieldGet(ml,this).push(s);return s}removeAnnotation(e){const t=annotation_layer_classPrivateFieldGet(ml,this).findIndex(t=>t.data.id===e);if(t<0)return;const[i]=annotation_layer_classPrivateFieldGet(ml,this).splice(t,1);annotation_layer_classPrivateFieldGet(cl,this)?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(e){if(0!==e.length){for(const t of e)t.updateFakeAnnotationElement(this);annotation_layer_assertClassBrand(vl,this,_addElementsToDOM).call(this)}}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}static get _defaultBorderStyle(){return shadow(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:E,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}}async function _addElementsToDOM(){if(0===annotation_layer_classPrivateFieldGet(ml,this).length)return;this.div.replaceChildren();const e=[];if(!annotation_layer_classPrivateFieldGet(fl,this)){annotation_layer_classPrivateFieldSet(fl,this,!0);for(const{contentElement:t,data:{id:i}}of annotation_layer_classPrivateFieldGet(ml,this)){const a=t.id=`${g}${i}`;e.push(annotation_layer_classPrivateFieldGet(pl,this)?.getAriaAttributes(a).then(e=>{if(e)for(const[i,a]of e)t.setAttribute(i,a)}))}}annotation_layer_classPrivateFieldGet(ml,this).sort(({data:{rect:[e,t,i,a]}},{data:{rect:[s,n,r,o]}})=>{if(e===i&&t===a)return 1;if(s===r&&n===o)return-1;const l=(t+a)/2,d=(n+o)/2;if(l>=o&&d<=t)return-1;if(d>=a&&l<=n)return 1;return(e+i)/2-(s+r)/2});const t=document.createDocumentFragment();for(const e of annotation_layer_classPrivateFieldGet(ml,this)){t.append(e.container);this._commentManager?(e.extraPopupElement?.popup||e.popup)?.renderCommentButton():e.extraPopupElement&&t.append(e.extraPopupElement.render())}this.div.append(t);await Promise.all(e);if(annotation_layer_classPrivateFieldGet(cl,this))for(const e of annotation_layer_classPrivateFieldGet(ml,this))annotation_layer_classPrivateFieldGet(cl,this).addPointerInTextLayer(e.contentElement,!1)}function _setAnnotationCanvasMap(){if(!annotation_layer_classPrivateFieldGet(hl,this))return;const e=this.div;for(const[t,i]of annotation_layer_classPrivateFieldGet(hl,this)){const a=e.querySelector(`[data-annotation-id="${t}"]`);if(!a)continue;if(Array.isArray(i))for(const e of i){e.className="annotationContent";e.ariaHidden=!0}else{i.className="annotationContent";i.ariaHidden=!0}const s=[];for(const e of a.children)"CANVAS"===e.nodeName&&s.push(e);for(const e of s)e.remove();const n=Array.isArray(i)?i[0]:i,{firstChild:r}=a;r?r.classList.contains("annotationContent")?r.after(n):r.before(n):a.append(n);if(Array.isArray(i)){let e=n;for(let t=1,a=i.length;t<a;t++){e.after(i[t]);e=i[t]}}annotation_layer_classPrivateFieldGet(hl,this).delete(t);const o=annotation_layer_classPrivateFieldGet(_l,this).get(t);if(o)if(o._hasNoCanvas){this._annotationEditorUIManager?.setMissingCanvas(t,a.id,i);o._hasNoCanvas=!1}else o.canvas=i}}function freetext_defineProperty(e,t,i){return(t=function freetext_toPropertyKey(e){var t=function freetext_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function freetext_classPrivateFieldInitSpec(e,t,i){freetext_checkPrivateRedeclaration(e,t),t.set(e,i)}function freetext_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function freetext_classPrivateFieldGet(e,t){return e.get(freetext_assertClassBrand(e,t))}function freetext_classPrivateFieldSet(e,t,i){return e.set(freetext_assertClassBrand(e,t),i),i}function freetext_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Pl=/\r\n?|\n/g;var wl=new WeakMap,Fl=new WeakMap,bl=new WeakMap,yl=new WeakMap,Sl=new WeakSet;class FreeTextEditor extends AnnotationEditor{static get _keyboardManager(){const e=FreeTextEditor.prototype,arrowChecker=e=>e.isEmpty(),t=AnnotationEditorUIManager.TRANSLATE_SMALL,i=AnnotationEditorUIManager.TRANSLATE_BIG;return shadow(this,"_keyboardManager",new KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter"],e.commitOrRemove],[["Escape"],e.commitOrRemove],[["ArrowLeft"],e._translateEmpty,{args:[-t,0],checker:arrowChecker}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:arrowChecker}],[["ArrowRight"],e._translateEmpty,{args:[t,0],checker:arrowChecker}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[i,0],checker:arrowChecker}],[["ArrowUp"],e._translateEmpty,{args:[0,-t],checker:arrowChecker}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:arrowChecker}],[["ArrowDown"],e._translateEmpty,{args:[0,t],checker:arrowChecker}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,i],checker:arrowChecker}]]))}constructor(e){super({...e,name:"freeTextEditor"});!function freetext_classPrivateMethodInitSpec(e,t){freetext_checkPrivateRedeclaration(e,t),t.add(e)}(this,Sl);freetext_classPrivateFieldInitSpec(this,wl,"");freetext_classPrivateFieldInitSpec(this,Fl,`${this.id}-editor`);freetext_classPrivateFieldInitSpec(this,bl,null);freetext_classPrivateFieldInitSpec(this,yl,void 0);freetext_defineProperty(this,"_colorPicker",null);this.color=e.color||FreeTextEditor._defaultColor||AnnotationEditor._defaultLineColor;freetext_classPrivateFieldSet(yl,this,e.fontSize||FreeTextEditor._defaultFontSize);this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.freetext);this.canAddComment=!1}static initialize(e,t){AnnotationEditor.initialize(e,t);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case v.FREETEXT_SIZE:FreeTextEditor._defaultFontSize=t;break;case v.FREETEXT_COLOR:FreeTextEditor._defaultColor=t}}updateParams(e,t){switch(e){case v.FREETEXT_SIZE:freetext_assertClassBrand(Sl,this,_updateFontSize).call(this,t);break;case v.FREETEXT_COLOR:freetext_assertClassBrand(Sl,this,freetext_updateColor).call(this,t)}}static get defaultPropertiesToUpdate(){return[[v.FREETEXT_SIZE,FreeTextEditor._defaultFontSize],[v.FREETEXT_COLOR,FreeTextEditor._defaultColor||AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[v.FREETEXT_SIZE,freetext_classPrivateFieldGet(yl,this)],[v.FREETEXT_COLOR,this.color]]}get toolbarButtons(){this._colorPicker||=new BasicColorPicker(this);return[["colorPicker",this._colorPicker]]}get colorType(){return v.FREETEXT_COLOR}onUpdatedColor(){this.editorDiv.style.color=this.color;this._colorPicker?.update(this.color);super.onUpdatedColor()}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){const e=this.parentScale;return[-FreeTextEditor._internalPadding*e,-(FreeTextEditor._internalPadding+freetext_classPrivateFieldGet(yl,this))*e]}rebuild(){if(this.parent){super.rebuild();null!==this.div&&(this.isAttachedToDOM||this.parent.add(this))}}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled");this.editorDiv.contentEditable=!0;this._isDraggable=!1;this.div.removeAttribute("aria-activedescendant");freetext_classPrivateFieldSet(bl,this,new AbortController);const e=this._uiManager.combinedSignal(freetext_classPrivateFieldGet(bl,this));this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e});this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e});this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e});this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e});this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e});return!0}disableEditMode(){if(!super.disableEditMode())return!1;this.overlayDiv.classList.add("enabled");this.editorDiv.contentEditable=!1;this.div.setAttribute("aria-activedescendant",freetext_classPrivateFieldGet(Fl,this));this._isDraggable=!0;freetext_classPrivateFieldGet(bl,this)?.abort();freetext_classPrivateFieldSet(bl,this,null);this.div.focus({preventScroll:!0});this.isEditing=!1;this.parent.div.classList.add("freetextEditing");return!0}focusin(e){if(this._focusEventsAllowed){super.focusin(e);e.target!==this.editorDiv&&this.editorDiv.focus()}}onceAdded(e){if(!this.width){this.enableEditMode();e&&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()}commit(){if(!this.isInEditMode())return;super.commit();this.disableEditMode();const e=freetext_classPrivateFieldGet(wl,this),t=freetext_classPrivateFieldSet(wl,this,freetext_assertClassBrand(Sl,this,_extractText).call(this).trimEnd());if(e===t)return;const setText=e=>{freetext_classPrivateFieldSet(wl,this,e);if(e){freetext_assertClassBrand(Sl,this,_setContent).call(this);this._uiManager.rebuild(this);freetext_assertClassBrand(Sl,this,_setEditorDimensions).call(this)}else this.remove()};this.addCommands({cmd:()=>{setText(t)},undo:()=>{setText(e)},mustExec:!1});freetext_assertClassBrand(Sl,this,_setEditorDimensions).call(this);this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"textChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:t,previousValue:e})}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode();this.editorDiv.focus()}keydown(e){if(e.target===this.div&&"Enter"===e.key){this.enterInEditMode();e.preventDefault()}}editorDivKeydown(e){FreeTextEditor._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment");this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox");this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy||this.annotationElementId){e=this.x;t=this.y}super.render();this.editorDiv=document.createElement("div");this.editorDiv.className="internal";this.editorDiv.setAttribute("id",freetext_classPrivateFieldGet(Fl,this));this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2");this.editorDiv.setAttribute("data-l10n-attrs","default-content");this.enableEditing();this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;i.fontSize=`calc(${freetext_classPrivateFieldGet(yl,this)}px * var(--total-scale-factor))`;i.color=this.color;this.div.append(this.editorDiv);this.overlayDiv=document.createElement("div");this.overlayDiv.classList.add("overlay","enabled");this.div.append(this.overlayDiv);if(this._isCopy||this.annotationElementId){const[i,a]=this.parentDimensions;if(this.annotationElementId){const{position:s}=this._initialData;let[n,r]=this.getInitialTranslation();[n,r]=this.pageTranslationToScreen(n,r);const[o,l]=this.pageDimensions,[d,c]=this.pageTranslation;let h,u;switch(this.rotation){case 0:h=e+(s[0]-d)/o;u=t+this.height-(s[1]-c)/l;break;case 90:h=e+(s[0]-d)/o;u=t-(s[1]-c)/l;[n,r]=[r,-n];break;case 180:h=e-this.width+(s[0]-d)/o;u=t-(s[1]-c)/l;[n,r]=[-n,-r];break;case 270:h=e+(s[0]-d-this.height*l)/o;u=t+(s[1]-c-this.width*o)/l;[n,r]=[-r,n]}this.setAt(h*i,u*a,n,r)}else this._moveAfterPaste(e,t);freetext_assertClassBrand(Sl,this,_setContent).call(this);this._isDraggable=!0;this.editorDiv.contentEditable=!1}else{this._isDraggable=!1;this.editorDiv.contentEditable=!0}return this.div}editorDivPaste(e){const t=e.clipboardData||window.clipboardData,{types:i}=t;if(1===i.length&&"text/plain"===i[0])return;e.preventDefault();const a=_deserializeContent.call(FreeTextEditor,t.getData("text")||"").replaceAll(Pl,"\n");if(!a)return;const s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize();s.deleteFromDocument();const n=s.getRangeAt(0);if(!a.includes("\n")){n.insertNode(document.createTextNode(a));this.editorDiv.normalize();s.collapseToStart();return}const{startContainer:r,startOffset:o}=n,l=[],d=[];if(r.nodeType===Node.TEXT_NODE){const e=r.parentElement;d.push(r.nodeValue.slice(o).replaceAll(Pl,""));if(e!==this.editorDiv){let t=l;for(const i of this.editorDiv.childNodes)i!==e?t.push(_getNodeContent.call(FreeTextEditor,i)):t=d}l.push(r.nodeValue.slice(0,o).replaceAll(Pl,""))}else if(r===this.editorDiv){let e=l,t=0;for(const i of this.editorDiv.childNodes){t++===o&&(e=d);e.push(_getNodeContent.call(FreeTextEditor,i))}}freetext_classPrivateFieldSet(wl,this,`${l.join("\n")}${a}${d.join("\n")}`);freetext_assertClassBrand(Sl,this,_setContent).call(this);const c=new Range;let h=Math.sumPrecise(l.map(e=>e.length));for(const{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){const t=e.nodeValue.length;if(h<=t){c.setStart(e,h);c.setEnd(e,h);break}h-=t}s.removeAllRanges();s.addRange(c)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=FreeTextEditor._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,t,i){let a=null;if(e instanceof FreeTextAnnotationElement){const{data:{defaultAppearanceData:{fontSize:t,fontColor:i},rect:s,rotation:n,id:r,popupRef:o,richText:l,contentsObj:d,creationDate:c,modificationDate:h},textContent:u,textPosition:_,parent:{page:{pageNumber:p}}}=e;if(!u?.length)return null;a=e={annotationType:f.FREETEXT,color:Array.from(i),fontSize:t,value:u.join("\n"),position:_,pageIndex:p-1,rect:s.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:o,comment:d?.str||null,richText:l,creationDate:c,modificationDate:h}}else{const{popup:t,popupRef:i}=e;a=e={...e,popupRef:i||!(!t||!t.contents||t.deleted)||null,comment:!t?.deleted&&t?.contents||null,commentDate:!t?.deleted&&t?.date||null}}const s=await super.deserialize(e,t,i);freetext_classPrivateFieldSet(yl,s,e.fontSize);s.color=Util.makeHexColor(...e.color);freetext_classPrivateFieldSet(wl,s,_deserializeContent.call(FreeTextEditor,e.value));s._initialData=a;e.comment&&s.setCommentData(e);return s}serialize(e=!1,t=null,i=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const a=AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),s=Object.assign(super.serialize(e,t),{color:a,fontSize:freetext_classPrivateFieldGet(yl,this),value:freetext_assertClassBrand(Sl,this,_serializeContent).call(this)});this.addComment(s,this._isCopy);if(e){i&&(s.id=this.uid);s.isCopy=!0;return s}if(this.annotationElementId&&!freetext_assertClassBrand(Sl,this,_hasElementChanged).call(this,s))return null;s.id=this.uid;return s}renderAnnotationElement(e){const t=super.renderAnnotationElement(e);if(!t)return null;const{style:i}=t;i.fontSize=`calc(${freetext_classPrivateFieldGet(yl,this)}px * var(--total-scale-factor))`;i.color=this.color;t.replaceChildren();for(const e of freetext_classPrivateFieldGet(wl,this).split("\n")){const i=document.createElement("div");i.append(e?document.createTextNode(e):document.createElement("br"));t.append(i)}e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:freetext_classPrivateFieldGet(wl,this)}});return t}resetAnnotationElement(e){super.resetAnnotationElement(e);e.resetEdited()}}dl=FreeTextEditor;function _updateFontSize(e){const setFontsize=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--total-scale-factor))`;this.translate(0,-(e-freetext_classPrivateFieldGet(yl,this))*this.parentScale);freetext_classPrivateFieldSet(yl,this,e);freetext_assertClassBrand(Sl,this,_setEditorDimensions).call(this)},t=freetext_classPrivateFieldGet(yl,this);this.addCommands({cmd:setFontsize.bind(this,e),undo:setFontsize.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0});this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"fontSizeChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:e,previousValue:freetext_classPrivateFieldGet(yl,this)})}function freetext_updateColor(e){const setColor=e=>{this.color=e;this.onUpdatedColor()},t=this.color;this.addCommands({cmd:setColor.bind(this,e),undo:setColor.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0});this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"colorChanged",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:e,previousValue:t})}function _extractText(){const e=[];this.editorDiv.normalize();let t=null;for(const i of this.editorDiv.childNodes)if(t?.nodeType!==Node.TEXT_NODE||"BR"!==i.nodeName){e.push(_getNodeContent.call(dl,i));t=i}return e.join("\n")}function _setEditorDimensions(){const[e,t]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:e,div:t}=this,a=t.style.display,s=t.classList.contains("hidden");t.classList.remove("hidden");t.style.display="hidden";e.div.append(this.div);i=t.getBoundingClientRect();t.remove();t.style.display=a;t.classList.toggle("hidden",s)}if(this.rotation%180==this.parentRotation%180){this.width=i.width/e;this.height=i.height/t}else{this.width=i.height/e;this.height=i.width/t}this.fixAndSetPosition()}function _getNodeContent(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Pl,"")}function _setContent(){this.editorDiv.replaceChildren();if(freetext_classPrivateFieldGet(wl,this))for(const e of freetext_classPrivateFieldGet(wl,this).split("\n")){const t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br"));this.editorDiv.append(t)}}function _serializeContent(){return freetext_classPrivateFieldGet(wl,this).replaceAll(" "," ")}function _deserializeContent(e){return e.replaceAll(" "," ")}function _hasElementChanged(e){const{value:t,fontSize:i,color:a,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==t||e.fontSize!==i||e.color.some((e,t)=>e!==a[t])||e.pageIndex!==s}freetext_defineProperty(FreeTextEditor,"_freeTextDefaultContent","");freetext_defineProperty(FreeTextEditor,"_internalPadding",0);freetext_defineProperty(FreeTextEditor,"_defaultColor",null);freetext_defineProperty(FreeTextEditor,"_defaultFontSize",10);freetext_defineProperty(FreeTextEditor,"_type","freetext");freetext_defineProperty(FreeTextEditor,"_editorType",f.FREETEXT);class Outline{toSVGPath(){unreachable("Abstract method `toSVGPath` must be implemented.")}get box(){unreachable("Abstract getter `box` must be implemented.")}serialize(e,t){unreachable("Abstract method `serialize` must be implemented.")}static _rescale(e,t,i,a,s,n){n||=new Float32Array(e.length);for(let r=0,o=e.length;r<o;r+=2){n[r]=t+e[r]*a;n[r+1]=i+e[r+1]*s}return n}static _rescaleAndSwap(e,t,i,a,s,n){n||=new Float32Array(e.length);for(let r=0,o=e.length;r<o;r+=2){n[r]=t+e[r+1]*a;n[r+1]=i+e[r]*s}return n}static _translate(e,t,i,a){a||=new Float32Array(e.length);for(let s=0,n=e.length;s<n;s+=2){a[s]=t+e[s];a[s+1]=i+e[s+1]}return a}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,i,a,s){switch(s){case 90:return[1-t/i,e/a];case 180:return[1-e/i,1-t/a];case 270:return[t/i,1-e/a];default:return[e/i,t/a]}}static createBezierPoints(e,t,i,a,s,n){return[(e+5*i)/6,(t+5*a)/6,(5*i+s)/6,(5*a+n)/6,(i+s)/2,(a+n)/2]}}!function outline_defineProperty(e,t,i){return(t=function outline_toPropertyKey(e){var t=function outline_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(Outline,"PRECISION",1e-4);function freedraw_classPrivateMethodInitSpec(e,t){freedraw_checkPrivateRedeclaration(e,t),t.add(e)}function freedraw_classPrivateFieldInitSpec(e,t,i){freedraw_checkPrivateRedeclaration(e,t),t.set(e,i)}function freedraw_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function freedraw_classPrivateFieldGet(e,t){return e.get(freedraw_assertClassBrand(e,t))}function freedraw_classPrivateFieldSet(e,t,i){return e.set(freedraw_assertClassBrand(e,t),i),i}function freedraw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Cl=new WeakMap,xl=new WeakMap,kl=new WeakMap,El=new WeakMap,Al=new WeakMap,Gl=new WeakMap,Bl=new WeakMap,Ml=new WeakMap,Il=new WeakMap,Tl=new WeakMap,Dl=new WeakMap,Ll=new WeakMap,Nl=new WeakMap,Rl=new WeakSet;class FreeDrawOutliner{constructor({x:e,y:t},i,a,s,n,r=0){freedraw_classPrivateMethodInitSpec(this,Rl);freedraw_classPrivateFieldInitSpec(this,Cl,void 0);freedraw_classPrivateFieldInitSpec(this,xl,[]);freedraw_classPrivateFieldInitSpec(this,kl,void 0);freedraw_classPrivateFieldInitSpec(this,El,void 0);freedraw_classPrivateFieldInitSpec(this,Al,[]);freedraw_classPrivateFieldInitSpec(this,Gl,new Float32Array(18));freedraw_classPrivateFieldInitSpec(this,Bl,void 0);freedraw_classPrivateFieldInitSpec(this,Ml,void 0);freedraw_classPrivateFieldInitSpec(this,Il,void 0);freedraw_classPrivateFieldInitSpec(this,Tl,void 0);freedraw_classPrivateFieldInitSpec(this,Dl,void 0);freedraw_classPrivateFieldInitSpec(this,Ll,void 0);freedraw_classPrivateFieldInitSpec(this,Nl,[]);freedraw_classPrivateFieldSet(Cl,this,i);freedraw_classPrivateFieldSet(Ll,this,s*a);freedraw_classPrivateFieldSet(El,this,n);freedraw_classPrivateFieldGet(Gl,this).set([NaN,NaN,NaN,NaN,e,t],6);freedraw_classPrivateFieldSet(kl,this,r);freedraw_classPrivateFieldSet(Tl,this,Ol._*a);freedraw_classPrivateFieldSet(Il,this,Wl._*a);freedraw_classPrivateFieldSet(Dl,this,a);freedraw_classPrivateFieldGet(Nl,this).push(e,t)}isEmpty(){return isNaN(freedraw_classPrivateFieldGet(Gl,this)[8])}add({x:e,y:t}){freedraw_classPrivateFieldSet(Bl,this,e);freedraw_classPrivateFieldSet(Ml,this,t);const[i,a,s,n]=freedraw_classPrivateFieldGet(Cl,this);let[r,o,l,d]=freedraw_classPrivateFieldGet(Gl,this).subarray(8,12);const c=e-l,h=t-d,u=Math.hypot(c,h);if(u<freedraw_classPrivateFieldGet(Il,this))return!1;const _=u-freedraw_classPrivateFieldGet(Tl,this),p=_/u,g=p*c,m=p*h;let f=r,v=o;r=l;o=d;l+=g;d+=m;freedraw_classPrivateFieldGet(Nl,this)?.push(e,t);const P=g/_,w=-m/_*freedraw_classPrivateFieldGet(Ll,this),F=P*freedraw_classPrivateFieldGet(Ll,this);freedraw_classPrivateFieldGet(Gl,this).set(freedraw_classPrivateFieldGet(Gl,this).subarray(2,8),0);freedraw_classPrivateFieldGet(Gl,this).set([l+w,d+F],4);freedraw_classPrivateFieldGet(Gl,this).set(freedraw_classPrivateFieldGet(Gl,this).subarray(14,18),12);freedraw_classPrivateFieldGet(Gl,this).set([l-w,d-F],16);if(isNaN(freedraw_classPrivateFieldGet(Gl,this)[6])){if(0===freedraw_classPrivateFieldGet(Al,this).length){freedraw_classPrivateFieldGet(Gl,this).set([r+w,o+F],2);freedraw_classPrivateFieldGet(Al,this).push(NaN,NaN,NaN,NaN,(r+w-i)/s,(o+F-a)/n);freedraw_classPrivateFieldGet(Gl,this).set([r-w,o-F],14);freedraw_classPrivateFieldGet(xl,this).push(NaN,NaN,NaN,NaN,(r-w-i)/s,(o-F-a)/n)}freedraw_classPrivateFieldGet(Gl,this).set([f,v,r,o,l,d],6);return!this.isEmpty()}freedraw_classPrivateFieldGet(Gl,this).set([f,v,r,o,l,d],6);if(Math.abs(Math.atan2(v-o,f-r)-Math.atan2(m,g))<Math.PI/2){[r,o,l,d]=freedraw_classPrivateFieldGet(Gl,this).subarray(2,6);freedraw_classPrivateFieldGet(Al,this).push(NaN,NaN,NaN,NaN,((r+l)/2-i)/s,((o+d)/2-a)/n);[r,o,f,v]=freedraw_classPrivateFieldGet(Gl,this).subarray(14,18);freedraw_classPrivateFieldGet(xl,this).push(NaN,NaN,NaN,NaN,((f+r)/2-i)/s,((v+o)/2-a)/n);return!0}[f,v,r,o,l,d]=freedraw_classPrivateFieldGet(Gl,this).subarray(0,6);freedraw_classPrivateFieldGet(Al,this).push(((f+5*r)/6-i)/s,((v+5*o)/6-a)/n,((5*r+l)/6-i)/s,((5*o+d)/6-a)/n,((r+l)/2-i)/s,((o+d)/2-a)/n);[l,d,r,o,f,v]=freedraw_classPrivateFieldGet(Gl,this).subarray(12,18);freedraw_classPrivateFieldGet(xl,this).push(((f+5*r)/6-i)/s,((v+5*o)/6-a)/n,((5*r+l)/6-i)/s,((5*o+d)/6-a)/n,((r+l)/2-i)/s,((o+d)/2-a)/n);return!0}toSVGPath(){if(this.isEmpty())return"";const e=freedraw_classPrivateFieldGet(Al,this),t=freedraw_classPrivateFieldGet(xl,this);if(isNaN(freedraw_classPrivateFieldGet(Gl,this)[6])&&!this.isEmpty())return freedraw_assertClassBrand(Rl,this,_toSVGPathTwoPoints).call(this);const i=[];i.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);freedraw_assertClassBrand(Rl,this,_toSVGPathEnd).call(this,i);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);freedraw_assertClassBrand(Rl,this,_toSVGPathStart).call(this,i);return i.join(" ")}newFreeDrawOutline(e,t,i,a,s,n){return new FreeDrawOutline(e,t,i,a,s,n)}getOutlines(){const e=freedraw_classPrivateFieldGet(Al,this),t=freedraw_classPrivateFieldGet(xl,this),i=freedraw_classPrivateFieldGet(Gl,this),[a,s,n,r]=freedraw_classPrivateFieldGet(Cl,this),o=new Float32Array((freedraw_classPrivateFieldGet(Nl,this)?.length??0)+2);for(let e=0,t=o.length-2;e<t;e+=2){o[e]=(freedraw_classPrivateFieldGet(Nl,this)[e]-a)/n;o[e+1]=(freedraw_classPrivateFieldGet(Nl,this)[e+1]-s)/r}o[o.length-2]=(freedraw_classPrivateFieldGet(Bl,this)-a)/n;o[o.length-1]=(freedraw_classPrivateFieldGet(Ml,this)-s)/r;if(isNaN(i[6])&&!this.isEmpty())return freedraw_assertClassBrand(Rl,this,_getOutlineTwoPoints).call(this,o);const l=new Float32Array(freedraw_classPrivateFieldGet(Al,this).length+24+freedraw_classPrivateFieldGet(xl,this).length);let d=e.length;for(let t=0;t<d;t+=2)if(isNaN(e[t]))l[t]=l[t+1]=NaN;else{l[t]=e[t];l[t+1]=e[t+1]}d=freedraw_assertClassBrand(Rl,this,_getOutlineEnd).call(this,l,d);for(let e=t.length-6;e>=6;e-=6)for(let i=0;i<6;i+=2)if(isNaN(t[e+i])){l[d]=l[d+1]=NaN;d+=2}else{l[d]=t[e+i];l[d+1]=t[e+i+1];d+=2}freedraw_assertClassBrand(Rl,this,_getOutlineStart).call(this,l,d);return this.newFreeDrawOutline(l,o,freedraw_classPrivateFieldGet(Cl,this),freedraw_classPrivateFieldGet(Dl,this),freedraw_classPrivateFieldGet(kl,this),freedraw_classPrivateFieldGet(El,this))}}function _getLastCoords(){const e=freedraw_classPrivateFieldGet(Gl,this).subarray(4,6),t=freedraw_classPrivateFieldGet(Gl,this).subarray(16,18),[i,a,s,n]=freedraw_classPrivateFieldGet(Cl,this);return[(freedraw_classPrivateFieldGet(Bl,this)+(e[0]-t[0])/2-i)/s,(freedraw_classPrivateFieldGet(Ml,this)+(e[1]-t[1])/2-a)/n,(freedraw_classPrivateFieldGet(Bl,this)+(t[0]-e[0])/2-i)/s,(freedraw_classPrivateFieldGet(Ml,this)+(t[1]-e[1])/2-a)/n]}function _toSVGPathTwoPoints(){const[e,t,i,a]=freedraw_classPrivateFieldGet(Cl,this),[s,n,r,o]=freedraw_assertClassBrand(Rl,this,_getLastCoords).call(this);return`M${(freedraw_classPrivateFieldGet(Gl,this)[2]-e)/i} ${(freedraw_classPrivateFieldGet(Gl,this)[3]-t)/a} L${(freedraw_classPrivateFieldGet(Gl,this)[4]-e)/i} ${(freedraw_classPrivateFieldGet(Gl,this)[5]-t)/a} L${s} ${n} L${r} ${o} L${(freedraw_classPrivateFieldGet(Gl,this)[16]-e)/i} ${(freedraw_classPrivateFieldGet(Gl,this)[17]-t)/a} L${(freedraw_classPrivateFieldGet(Gl,this)[14]-e)/i} ${(freedraw_classPrivateFieldGet(Gl,this)[15]-t)/a} Z`}function _toSVGPathStart(e){const t=freedraw_classPrivateFieldGet(xl,this);e.push(`L${t[4]} ${t[5]} Z`)}function _toSVGPathEnd(e){const[t,i,a,s]=freedraw_classPrivateFieldGet(Cl,this),n=freedraw_classPrivateFieldGet(Gl,this).subarray(4,6),r=freedraw_classPrivateFieldGet(Gl,this).subarray(16,18),[o,l,d,c]=freedraw_assertClassBrand(Rl,this,_getLastCoords).call(this);e.push(`L${(n[0]-t)/a} ${(n[1]-i)/s} L${o} ${l} L${d} ${c} L${(r[0]-t)/a} ${(r[1]-i)/s}`)}function _getOutlineTwoPoints(e){const t=freedraw_classPrivateFieldGet(Gl,this),[i,a,s,n]=freedraw_classPrivateFieldGet(Cl,this),[r,o,l,d]=freedraw_assertClassBrand(Rl,this,_getLastCoords).call(this),c=new Float32Array(36);c.set([NaN,NaN,NaN,NaN,(t[2]-i)/s,(t[3]-a)/n,NaN,NaN,NaN,NaN,(t[4]-i)/s,(t[5]-a)/n,NaN,NaN,NaN,NaN,r,o,NaN,NaN,NaN,NaN,l,d,NaN,NaN,NaN,NaN,(t[16]-i)/s,(t[17]-a)/n,NaN,NaN,NaN,NaN,(t[14]-i)/s,(t[15]-a)/n],0);return this.newFreeDrawOutline(c,e,freedraw_classPrivateFieldGet(Cl,this),freedraw_classPrivateFieldGet(Dl,this),freedraw_classPrivateFieldGet(kl,this),freedraw_classPrivateFieldGet(El,this))}function _getOutlineStart(e,t){const i=freedraw_classPrivateFieldGet(xl,this);e.set([NaN,NaN,NaN,NaN,i[4],i[5]],t);return t+6}function _getOutlineEnd(e,t){const i=freedraw_classPrivateFieldGet(Gl,this).subarray(4,6),a=freedraw_classPrivateFieldGet(Gl,this).subarray(16,18),[s,n,r,o]=freedraw_classPrivateFieldGet(Cl,this),[l,d,c,h]=freedraw_assertClassBrand(Rl,this,_getLastCoords).call(this);e.set([NaN,NaN,NaN,NaN,(i[0]-s)/r,(i[1]-n)/o,NaN,NaN,NaN,NaN,l,d,NaN,NaN,NaN,NaN,c,h,NaN,NaN,NaN,NaN,(a[0]-s)/r,(a[1]-n)/o],t);return t+24}var Ol={_:8},Wl={_:Ol._+2},jl=new WeakMap,Vl=new WeakMap,Ul=new WeakMap,zl=new WeakMap,Hl=new WeakMap,$l=new WeakMap,Kl=new WeakMap,Xl=new WeakSet;class FreeDrawOutline extends Outline{constructor(e,t,i,a,s,n){super();freedraw_classPrivateMethodInitSpec(this,Xl);freedraw_classPrivateFieldInitSpec(this,jl,void 0);freedraw_classPrivateFieldInitSpec(this,Vl,new Float32Array(4));freedraw_classPrivateFieldInitSpec(this,Ul,void 0);freedraw_classPrivateFieldInitSpec(this,zl,void 0);freedraw_classPrivateFieldInitSpec(this,Hl,void 0);freedraw_classPrivateFieldInitSpec(this,$l,void 0);freedraw_classPrivateFieldInitSpec(this,Kl,void 0);freedraw_classPrivateFieldSet(Kl,this,e);freedraw_classPrivateFieldSet(Hl,this,t);freedraw_classPrivateFieldSet(jl,this,i);freedraw_classPrivateFieldSet($l,this,a);freedraw_classPrivateFieldSet(Ul,this,s);freedraw_classPrivateFieldSet(zl,this,n);this.firstPoint=[NaN,NaN];this.lastPoint=[NaN,NaN];freedraw_assertClassBrand(Xl,this,_computeMinMax).call(this,n);const[r,o,l,d]=freedraw_classPrivateFieldGet(Vl,this);for(let t=0,i=e.length;t<i;t+=2){e[t]=(e[t]-r)/l;e[t+1]=(e[t+1]-o)/d}for(let e=0,i=t.length;e<i;e+=2){t[e]=(t[e]-r)/l;t[e+1]=(t[e+1]-o)/d}}toSVGPath(){const e=[`M${freedraw_classPrivateFieldGet(Kl,this)[4]} ${freedraw_classPrivateFieldGet(Kl,this)[5]}`];for(let t=6,i=freedraw_classPrivateFieldGet(Kl,this).length;t<i;t+=6)isNaN(freedraw_classPrivateFieldGet(Kl,this)[t])?e.push(`L${freedraw_classPrivateFieldGet(Kl,this)[t+4]} ${freedraw_classPrivateFieldGet(Kl,this)[t+5]}`):e.push(`C${freedraw_classPrivateFieldGet(Kl,this)[t]} ${freedraw_classPrivateFieldGet(Kl,this)[t+1]} ${freedraw_classPrivateFieldGet(Kl,this)[t+2]} ${freedraw_classPrivateFieldGet(Kl,this)[t+3]} ${freedraw_classPrivateFieldGet(Kl,this)[t+4]} ${freedraw_classPrivateFieldGet(Kl,this)[t+5]}`);e.push("Z");return e.join(" ")}serialize([e,t,i,a],s){const n=i-e,r=a-t;let o,l;switch(s){case 0:o=Outline._rescale(freedraw_classPrivateFieldGet(Kl,this),e,a,n,-r);l=Outline._rescale(freedraw_classPrivateFieldGet(Hl,this),e,a,n,-r);break;case 90:o=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(Kl,this),e,t,n,r);l=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(Hl,this),e,t,n,r);break;case 180:o=Outline._rescale(freedraw_classPrivateFieldGet(Kl,this),i,t,-n,r);l=Outline._rescale(freedraw_classPrivateFieldGet(Hl,this),i,t,-n,r);break;case 270:o=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(Kl,this),i,a,-n,-r);l=Outline._rescaleAndSwap(freedraw_classPrivateFieldGet(Hl,this),i,a,-n,-r)}return{outline:Array.from(o),points:[Array.from(l)]}}get box(){return freedraw_classPrivateFieldGet(Vl,this)}newOutliner(e,t,i,a,s,n=0){return new FreeDrawOutliner(e,t,i,a,s,n)}getNewOutline(e,t){const[i,a,s,n]=freedraw_classPrivateFieldGet(Vl,this),[r,o,l,d]=freedraw_classPrivateFieldGet(jl,this),c=s*l,h=n*d,u=i*l+r,_=a*d+o,p=this.newOutliner({x:freedraw_classPrivateFieldGet(Hl,this)[0]*c+u,y:freedraw_classPrivateFieldGet(Hl,this)[1]*h+_},freedraw_classPrivateFieldGet(jl,this),freedraw_classPrivateFieldGet($l,this),e,freedraw_classPrivateFieldGet(zl,this),t??freedraw_classPrivateFieldGet(Ul,this));for(let e=2;e<freedraw_classPrivateFieldGet(Hl,this).length;e+=2)p.add({x:freedraw_classPrivateFieldGet(Hl,this)[e]*c+u,y:freedraw_classPrivateFieldGet(Hl,this)[e+1]*h+_});return p.getOutlines()}}function _computeMinMax(e){const t=freedraw_classPrivateFieldGet(Kl,this);let a=t[4],s=t[5];const n=[a,s,a,s];let r=a,o=s,l=a,d=s;const c=e?Math.max:Math.min,h=new Float32Array(4);for(let e=6,u=t.length;e<u;e+=6){const u=t[e+4],_=t[e+5];if(isNaN(t[e])){Util.pointBoundingBox(u,_,n);if(o>_){r=u;o=_}else o===_&&(r=c(r,u));if(d<_){l=u;d=_}else d===_&&(l=c(l,u))}else{h.set(i,0);Util.bezierBoundingBox(a,s,...t.slice(e,e+6),h);Util.rectBoundingBox(...h,n);if(o>h[1]){r=h[0];o=h[1]}else o===h[1]&&(r=c(r,h[0]));if(d<h[3]){l=h[2];d=h[3]}else d===h[3]&&(l=c(l,h[2]))}a=u;s=_}const u=freedraw_classPrivateFieldGet(Vl,this);u[0]=n[0]-freedraw_classPrivateFieldGet(Ul,this);u[1]=n[1]-freedraw_classPrivateFieldGet(Ul,this);u[2]=n[2]-n[0]+2*freedraw_classPrivateFieldGet(Ul,this);u[3]=n[3]-n[1]+2*freedraw_classPrivateFieldGet(Ul,this);this.firstPoint=[r,o];this.lastPoint=[l,d]}function highlight_classPrivateFieldInitSpec(e,t,i){highlight_checkPrivateRedeclaration(e,t),t.set(e,i)}function highlight_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function highlight_classPrivateFieldSet(e,t,i){return e.set(highlight_assertClassBrand(e,t),i),i}function highlight_classPrivateFieldGet(e,t){return e.get(highlight_assertClassBrand(e,t))}function highlight_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var ql=new WeakMap,Yl=new WeakMap,Zl=new WeakMap,Ql=new WeakMap,Jl=new WeakMap,ed=new WeakSet;class HighlightOutliner{constructor(e,t=0,a=0,s=!0){!function highlight_classPrivateMethodInitSpec(e,t){highlight_checkPrivateRedeclaration(e,t),t.add(e)}(this,ed);highlight_classPrivateFieldInitSpec(this,ql,void 0);highlight_classPrivateFieldInitSpec(this,Yl,void 0);highlight_classPrivateFieldInitSpec(this,Zl,void 0);highlight_classPrivateFieldInitSpec(this,Ql,[]);highlight_classPrivateFieldInitSpec(this,Jl,[]);const n=i.slice(),r=10**-4;for(const{x:i,y:a,width:s,height:o}of e){const e=Math.floor((i-t)/r)*r,l=Math.ceil((i+s+t)/r)*r,d=Math.floor((a-t)/r)*r,c=Math.ceil((a+o+t)/r)*r,h=[e,d,c,!0],u=[l,d,c,!1];highlight_classPrivateFieldGet(Ql,this).push(h,u);Util.rectBoundingBox(e,d,l,c,n)}const o=n[2]-n[0]+2*a,l=n[3]-n[1]+2*a,d=n[0]-a,c=n[1]-a;let h=s?-1/0:1/0,u=1/0;const _=highlight_classPrivateFieldGet(Ql,this).at(s?-1:-2),p=[_[0],_[2]];for(const e of highlight_classPrivateFieldGet(Ql,this)){const[t,i,a,n]=e;if(!n&&s)if(i<u){u=i;h=t}else i===u&&(h=Math.max(h,t));else if(n&&!s)if(i<u){u=i;h=t}else i===u&&(h=Math.min(h,t));e[0]=(t-d)/o;e[1]=(i-c)/l;e[2]=(a-c)/l}highlight_classPrivateFieldSet(ql,this,new Float32Array([d,c,o,l]));highlight_classPrivateFieldSet(Yl,this,[h,u]);highlight_classPrivateFieldSet(Zl,this,p)}getOutlines(){highlight_classPrivateFieldGet(Ql,this).sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);const e=[];for(const t of highlight_classPrivateFieldGet(Ql,this))if(t[3]){e.push(...highlight_assertClassBrand(ed,this,_breakEdge).call(this,t));highlight_assertClassBrand(ed,this,_insert).call(this,t)}else{highlight_assertClassBrand(ed,this,_remove).call(this,t);e.push(...highlight_assertClassBrand(ed,this,_breakEdge).call(this,t))}return highlight_assertClassBrand(ed,this,_getOutlines).call(this,e)}}function _getOutlines(e){const t=[],i=new Set;for(const i of e){const[e,a,s]=i;t.push([e,a,i],[e,s,i])}t.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,a=t.length;e<a;e+=2){const a=t[e][2],s=t[e+1][2];a.push(s);s.push(a);i.add(a);i.add(s)}const a=[];let s;for(;i.size>0;){const e=i.values().next().value;let[t,n,r,o,l]=e;i.delete(e);let d=t,c=n;s=[t,r];a.push(s);for(;;){let e;if(i.has(o))e=o;else{if(!i.has(l))break;e=l}i.delete(e);[t,n,r,o,l]=e;if(d!==t){s.push(d,c,t,c===n?n:r);d=t}c=c===n?r:n}s.push(d,c)}return new HighlightOutline(a,highlight_classPrivateFieldGet(ql,this),highlight_classPrivateFieldGet(Yl,this),highlight_classPrivateFieldGet(Zl,this))}function _binarySearch(e){const t=highlight_classPrivateFieldGet(Jl,this);let i=0,a=t.length-1;for(;i<=a;){const s=i+a>>1,n=t[s][0];if(n===e)return s;n<e?i=s+1:a=s-1}return a+1}function _insert([,e,t]){const i=highlight_assertClassBrand(ed,this,_binarySearch).call(this,e);highlight_classPrivateFieldGet(Jl,this).splice(i,0,[e,t])}function _remove([,e,t]){const i=highlight_assertClassBrand(ed,this,_binarySearch).call(this,e);for(let a=i;a<highlight_classPrivateFieldGet(Jl,this).length;a++){const[i,s]=highlight_classPrivateFieldGet(Jl,this)[a];if(i!==e)break;if(i===e&&s===t){highlight_classPrivateFieldGet(Jl,this).splice(a,1);return}}for(let a=i-1;a>=0;a--){const[i,s]=highlight_classPrivateFieldGet(Jl,this)[a];if(i!==e)break;if(i===e&&s===t){highlight_classPrivateFieldGet(Jl,this).splice(a,1);return}}}function _breakEdge(e){const[t,i,a]=e,s=[[t,i,a]],n=highlight_assertClassBrand(ed,this,_binarySearch).call(this,a);for(let e=0;e<n;e++){const[i,a]=highlight_classPrivateFieldGet(Jl,this)[e];for(let e=0,n=s.length;e<n;e++){const[,r,o]=s[e];if(!(a<=r||o<=i))if(r>=i)if(o>a)s[e][1]=a;else{if(1===n)return[];s.splice(e,1);e--;n--}else{s[e][2]=i;o>a&&s.push([t,a,o])}}}return s}var td,id=new WeakMap,ad=new WeakMap;class HighlightOutline extends Outline{constructor(e,t,i,a){super();highlight_classPrivateFieldInitSpec(this,id,void 0);highlight_classPrivateFieldInitSpec(this,ad,void 0);highlight_classPrivateFieldSet(ad,this,e);highlight_classPrivateFieldSet(id,this,t);this.firstPoint=i;this.lastPoint=a}toSVGPath(){const e=[];for(const t of highlight_classPrivateFieldGet(ad,this)){let[i,a]=t;e.push(`M${i} ${a}`);for(let s=2;s<t.length;s+=2){const n=t[s],r=t[s+1];if(n===i){e.push(`V${r}`);a=r}else if(r===a){e.push(`H${n}`);i=n}}e.push("Z")}return e.join(" ")}serialize([e,t,i,a],s){const n=[],r=i-e,o=a-t;for(const t of highlight_classPrivateFieldGet(ad,this)){const i=new Array(t.length);for(let s=0;s<t.length;s+=2){i[s]=e+t[s]*r;i[s+1]=a-t[s+1]*o}n.push(i)}return n}get box(){return highlight_classPrivateFieldGet(id,this)}}class FreeHighlightOutliner extends FreeDrawOutliner{newFreeDrawOutline(e,t,i,a,s,n){return new FreeHighlightOutline(e,t,i,a,s,n)}}class FreeHighlightOutline extends FreeDrawOutline{newOutliner(e,t,i,a,s,n=0){return new FreeHighlightOutliner(e,t,i,a,s,n)}}function highlight_defineProperty(e,t,i){return(t=function highlight_toPropertyKey(e){var t=function highlight_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function editor_highlight_classPrivateFieldInitSpec(e,t,i){editor_highlight_checkPrivateRedeclaration(e,t),t.set(e,i)}function editor_highlight_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function highlight_toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function editor_highlight_classPrivateFieldGet(e,t){return e.get(editor_highlight_assertClassBrand(e,t))}function editor_highlight_classPrivateFieldSet(e,t,i){return e.set(editor_highlight_assertClassBrand(e,t),i),i}function editor_highlight_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var sd,nd=new WeakMap,rd=new WeakMap,od=new WeakMap,ld=new WeakMap,dd=new WeakMap,cd=new WeakMap,hd=new WeakMap,ud=new WeakMap,_d=new WeakMap,pd=new WeakMap,gd=new WeakMap,md=new WeakMap,fd=new WeakMap,vd=new WeakMap,Pd=new WeakMap,wd=new WeakMap,Fd=new WeakMap,bd=new WeakMap,yd=new WeakSet;class HighlightEditor extends AnnotationEditor{static get _keyboardManager(){const e=HighlightEditor.prototype;return shadow(this,"_keyboardManager",new KeyboardManager([[["ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:"highlightEditor"});!function editor_highlight_classPrivateMethodInitSpec(e,t){editor_highlight_checkPrivateRedeclaration(e,t),t.add(e)}(this,yd);editor_highlight_classPrivateFieldInitSpec(this,nd,null);editor_highlight_classPrivateFieldInitSpec(this,rd,0);editor_highlight_classPrivateFieldInitSpec(this,od,void 0);editor_highlight_classPrivateFieldInitSpec(this,ld,null);editor_highlight_classPrivateFieldInitSpec(this,dd,null);editor_highlight_classPrivateFieldInitSpec(this,cd,null);editor_highlight_classPrivateFieldInitSpec(this,hd,null);editor_highlight_classPrivateFieldInitSpec(this,ud,0);editor_highlight_classPrivateFieldInitSpec(this,_d,null);editor_highlight_classPrivateFieldInitSpec(this,pd,null);editor_highlight_classPrivateFieldInitSpec(this,gd,null);editor_highlight_classPrivateFieldInitSpec(this,md,!1);editor_highlight_classPrivateFieldInitSpec(this,fd,null);editor_highlight_classPrivateFieldInitSpec(this,vd,null);editor_highlight_classPrivateFieldInitSpec(this,Pd,null);editor_highlight_classPrivateFieldInitSpec(this,wd,"");editor_highlight_classPrivateFieldInitSpec(this,Fd,void 0);editor_highlight_classPrivateFieldInitSpec(this,bd,"");this.color=e.color||HighlightEditor._defaultColor;editor_highlight_classPrivateFieldSet(Fd,this,e.thickness||HighlightEditor._defaultThickness);this.opacity=e.opacity||HighlightEditor._defaultOpacity;editor_highlight_classPrivateFieldSet(od,this,e.boxes||null);editor_highlight_classPrivateFieldSet(bd,this,e.methodOfCreation||"");editor_highlight_classPrivateFieldSet(wd,this,e.text||"");this._isDraggable=!1;this.defaultL10nId="pdfjs-editor-highlight-editor";if(e.highlightId>-1){editor_highlight_classPrivateFieldSet(md,this,!0);editor_highlight_assertClassBrand(yd,this,_createFreeOutlines).call(this,e);editor_highlight_assertClassBrand(yd,this,_addToDrawLayer).call(this)}else if(editor_highlight_classPrivateFieldGet(od,this)){editor_highlight_classPrivateFieldSet(nd,this,e.anchorNode);editor_highlight_classPrivateFieldSet(rd,this,e.anchorOffset);editor_highlight_classPrivateFieldSet(hd,this,e.focusNode);editor_highlight_classPrivateFieldSet(ud,this,e.focusOffset);editor_highlight_assertClassBrand(yd,this,_createOutlines).call(this);editor_highlight_assertClassBrand(yd,this,_addToDrawLayer).call(this);this.rotate(this.rotation)}this._uiManager?.isRestoringAnnotations||this._dispatchAddedEvent();this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.highlight)}get addedEventValue(){return{color:this.color,thickness:editor_highlight_classPrivateFieldGet(Fd,this),isFreeHighlight:editor_highlight_classPrivateFieldGet(md,this),text:editor_highlight_classPrivateFieldGet(wd,this)}}get telemetryInitialData(){return{action:"added",type:editor_highlight_classPrivateFieldGet(md,this)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:editor_highlight_classPrivateFieldGet(Fd,this),methodOfCreation:editor_highlight_classPrivateFieldGet(bd,this)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,t){AnnotationEditor.initialize(e,t);HighlightEditor._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:HighlightEditor._defaultColor=t;break;case v.HIGHLIGHT_THICKNESS:HighlightEditor._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return editor_highlight_classPrivateFieldGet(vd,this)}get commentButtonPosition(){return editor_highlight_classPrivateFieldGet(fd,this)}updateParams(e,t){switch(e){case v.HIGHLIGHT_COLOR:editor_highlight_assertClassBrand(yd,this,highlight_updateColor).call(this,t);break;case v.HIGHLIGHT_THICKNESS:editor_highlight_assertClassBrand(yd,this,_updateThickness).call(this,t)}}static get defaultPropertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,HighlightEditor._defaultColor],[v.HIGHLIGHT_THICKNESS,HighlightEditor._defaultThickness]]}get propertiesToUpdate(){return[[v.HIGHLIGHT_COLOR,this.color||HighlightEditor._defaultColor],[v.HIGHLIGHT_THICKNESS,editor_highlight_classPrivateFieldGet(Fd,this)||HighlightEditor._defaultThickness],[v.HIGHLIGHT_FREE,editor_highlight_classPrivateFieldGet(md,this)]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(gd,this),{root:{fill:this.color,"fill-opacity":this.opacity}});editor_highlight_classPrivateFieldGet(dd,this)?.updateColor(this.color);super.onUpdatedColor()}get toolbarButtons(){if(this._uiManager.highlightColors){return[["colorPicker",editor_highlight_classPrivateFieldSet(dd,this,new ColorPicker({editor:this}))]]}return super.toolbarButtons}disableEditing(){super.disableEditing();this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing();this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(editor_highlight_assertClassBrand(yd,this,_getRotation).call(this))}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,editor_highlight_assertClassBrand(yd,this,_getRotation).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);e&&this.div.focus()}remove(){editor_highlight_assertClassBrand(yd,this,_cleanDrawLayer).call(this);this._reportTelemetry({action:"deleted"});super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){editor_highlight_assertClassBrand(yd,this,_addToDrawLayer).call(this);this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e)editor_highlight_assertClassBrand(yd,this,_cleanDrawLayer).call(this);else if(e){editor_highlight_assertClassBrand(yd,this,_addToDrawLayer).call(this,e);t=!this.parent&&this.div?.classList.contains("selectedEditor")}super.setParent(e);this.show(this._isVisible);t&&this.select()}rotate(e){const{drawLayer:t}=this.parent;let i;if(editor_highlight_classPrivateFieldGet(md,this)){e=(e-this.rotation+360)%360;i=_rotateBbox.call(HighlightEditor,editor_highlight_classPrivateFieldGet(pd,this).box,e)}else i=_rotateBbox.call(HighlightEditor,[this.x,this.y,this.width,this.height],e);t.updateProperties(editor_highlight_classPrivateFieldGet(gd,this),{bbox:i,root:{"data-main-rotation":e}});t.updateProperties(editor_highlight_classPrivateFieldGet(Pd,this),{bbox:_rotateBbox.call(HighlightEditor,editor_highlight_classPrivateFieldGet(cd,this).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();if(editor_highlight_classPrivateFieldGet(wd,this)){e.setAttribute("aria-label",editor_highlight_classPrivateFieldGet(wd,this));e.setAttribute("role","mark")}editor_highlight_classPrivateFieldGet(md,this)?e.classList.add("free"):this.div.addEventListener("keydown",editor_highlight_assertClassBrand(yd,this,_keydown).bind(this),{signal:this._uiManager._signal});const t=editor_highlight_classPrivateFieldSet(_d,this,document.createElement("div"));e.append(t);t.setAttribute("aria-hidden","true");t.className="internal";t.style.clipPath=editor_highlight_classPrivateFieldGet(ld,this);this.setDims();bindEvents(this,editor_highlight_classPrivateFieldGet(_d,this),["pointerover","pointerleave"]);this.enableEditing();return e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(Pd,this),{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(Pd,this),{rootClass:{hovered:!1}})}_moveCaret(e){this.parent.unselect(this);switch(e){case 0:case 2:editor_highlight_assertClassBrand(yd,this,_setCaret).call(this,!0);break;case 1:case 3:editor_highlight_assertClassBrand(yd,this,_setCaret).call(this,!1)}}select(){super.select();editor_highlight_classPrivateFieldGet(Pd,this)&&this.parent?.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(Pd,this),{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect();if(editor_highlight_classPrivateFieldGet(Pd,this)){this.parent?.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(Pd,this),{rootClass:{selected:!1}});editor_highlight_classPrivateFieldGet(md,this)||editor_highlight_assertClassBrand(yd,this,_setCaret).call(this,!1)}}get _mustFixPosition(){return!editor_highlight_classPrivateFieldGet(md,this)}show(e=this._isVisible){super.show(e);if(this.parent){this.parent.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(gd,this),{rootClass:{hidden:!e}});this.parent.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(Pd,this),{rootClass:{hidden:!e}})}}static startHighlighting(e,t,{target:i,x:a,y:s}){const{x:n,y:r,width:o,height:l}=i.getBoundingClientRect(),d=new AbortController,c=e.combinedSignal(d),pointerUpCallback=t=>{d.abort();editor_highlight_assertClassBrand(HighlightEditor,this,_endHighlight).call(this,e,t)};window.addEventListener("blur",pointerUpCallback,{signal:c});window.addEventListener("pointerup",pointerUpCallback,{signal:c});window.addEventListener("pointerdown",stopEvent,{capture:!0,passive:!1,signal:c});window.addEventListener("contextmenu",noContextMenu,{signal:c});i.addEventListener("pointermove",editor_highlight_assertClassBrand(HighlightEditor,this,_highlightMove).bind(this,e),{signal:c});this._freeHighlight=new FreeHighlightOutliner({x:a,y:s},[n,r,o,l],e.scale,this._defaultThickness/2,t,.001);({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static async deserialize(e,t,i){let a=null;if(e instanceof HighlightAnnotationElement){const{data:{quadPoints:t,rect:i,rotation:s,id:n,color:r,opacity:o,popupRef:l,richText:d,contentsObj:c,creationDate:h,modificationDate:u},parent:{page:{pageNumber:_}}}=e;a=e={annotationType:f.HIGHLIGHT,color:Array.from(r),opacity:o,quadPoints:t,boxes:null,pageIndex:_-1,rect:i.slice(0),rotation:s,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:d,comment:c?.str||null,creationDate:h,modificationDate:u}}else if(e.annotationType&&e.annotationType===f.HIGHLIGHT){let t,{quadPoints:i,outlines:s,rect:n,rotation:r,id:o,color:l,opacity:d,popup:c,popupRef:h,pageIndex:u,thickness:_}=e;i&&(Array.isArray(i)||(i=Object.values(i)));if(!i&&s){if(Array.isArray(s))t=s.map(e=>e);else{if("object"!=typeof s||!s.points){console.error("Unexpected outlines format");return null}t=[s.points.flat()]}_=_||e.thickness||1}a=e={annotationType:f.HIGHLIGHT,color:Array.from(l),opacity:d,quadPoints:i,inkLists:t,thickness:_,boxes:null,pageIndex:u,rect:n.slice(0),rotation:r,id:o,deleted:!1,isCopy:e.isCopy,customId:e.customId,popupRef:h||!(!c||!c.contents||c.deleted)||null,comment:!c?.deleted&&c?.contents||null,commentDate:!c?.deleted&&c?.date||null}}else if(e instanceof InkAnnotationElement){const{data:{inkLists:t,rect:i,rotation:s,id:n,color:r,borderStyle:{rawWidth:o},popupRef:l,richText:d,contentsObj:c,creationDate:h,modificationDate:u},parent:{page:{pageNumber:_}}}=e;a=e={annotationType:f.HIGHLIGHT,color:Array.from(r),thickness:o,inkLists:t,boxes:null,pageIndex:_-1,rect:i.slice(0),rotation:s,annotationElementId:n,id:n,deleted:!1,popupRef:l,richText:d,comment:c?.str||null,creationDate:h,modificationDate:u}}const{color:s,quadPoints:n,inkLists:r,outlines:o,opacity:l}=e,d=await super.deserialize(e,t,i);d.color=Util.makeHexColor(...s);d.opacity=l||1;r&&editor_highlight_classPrivateFieldSet(Fd,d,e.thickness);d._initialData=a;e.comment&&d.setCommentData(e);const[c,h]=d.pageDimensions,[u,_]=d.pageTranslation;if(n){const e=editor_highlight_classPrivateFieldSet(od,d,[]);for(let t=0;t<n.length;t+=8)e.push({x:(n[t]-u)/c,y:1-(n[t+1]-_)/h,width:(n[t+2]-n[t])/c,height:(n[t+1]-n[t+5])/h});editor_highlight_assertClassBrand(yd,d,_createOutlines).call(d);editor_highlight_assertClassBrand(yd,d,_addToDrawLayer).call(d);d.rotate(d.rotation)}else if(r||o){editor_highlight_classPrivateFieldSet(md,d,!0);const e=(r||o.points)[0],i={x:e[0]-u,y:h-(e[1]-_)},a=new FreeHighlightOutliner(i,[0,0,c,h],1,editor_highlight_classPrivateFieldGet(Fd,d)/2,!0,.001);for(let t=0,s=e.length;t<s;t+=2){i.x=e[t]-u;i.y=h-(e[t+1]-_);a.add(i)}const{id:s,clipPathId:n}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:a.toSVGPath()}},!0,!0);editor_highlight_assertClassBrand(yd,d,_createFreeOutlines).call(d,{highlightOutlines:a.getOutlines(),highlightId:s,clipPathId:n});editor_highlight_assertClassBrand(yd,d,_addToDrawLayer).call(d);d.rotate(d.parentRotation)}return d}serialize(e=!1,t=null,i=!1){if(this.isEmpty()||e&&!i)return null;if(this.deleted)return this.serializeDeleted();const a=AnnotationEditor._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),s=super.serialize(e,t);Object.assign(s,{color:a,opacity:this.opacity,thickness:editor_highlight_classPrivateFieldGet(Fd,this),quadPoints:editor_highlight_assertClassBrand(yd,this,_serializeBoxes).call(this),outlines:editor_highlight_assertClassBrand(yd,this,_serializeOutlines).call(this,s.rect)});this.addComment(s,this._isCopy);if(e&&i){s.id=this.uid;s.isCopy=!0;return s}if(this.annotationElementId&&!editor_highlight_assertClassBrand(yd,this,highlight_hasElementChanged).call(this,s))return null;s.id=this.uid;return s}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}static canCreateNewEmptyEditor(){return!1}}td=HighlightEditor;function _createOutlines(){const e=new HighlightOutliner(editor_highlight_classPrivateFieldGet(od,this),.001);editor_highlight_classPrivateFieldSet(pd,this,e.getOutlines());[this.x,this.y,this.width,this.height]=editor_highlight_classPrivateFieldGet(pd,this).box;const t=new HighlightOutliner(editor_highlight_classPrivateFieldGet(od,this),.0025,.001,"ltr"===this._uiManager.direction);editor_highlight_classPrivateFieldSet(cd,this,t.getOutlines());const{firstPoint:i}=editor_highlight_classPrivateFieldGet(pd,this);editor_highlight_classPrivateFieldSet(fd,this,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]);const{lastPoint:a}=editor_highlight_classPrivateFieldGet(cd,this);editor_highlight_classPrivateFieldSet(vd,this,[(a[0]-this.x)/this.width,(a[1]-this.y)/this.height])}function _createFreeOutlines({highlightOutlines:e,highlightId:t,clipPathId:i}){editor_highlight_classPrivateFieldSet(pd,this,e);editor_highlight_classPrivateFieldSet(cd,this,e.getNewOutline(editor_highlight_classPrivateFieldGet(Fd,this)/2+1.5,.0025));if(t>=0){editor_highlight_classPrivateFieldSet(gd,this,t);editor_highlight_classPrivateFieldSet(ld,this,i);this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}});editor_highlight_classPrivateFieldSet(Pd,this,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:editor_highlight_classPrivateFieldGet(cd,this).box,path:{d:editor_highlight_classPrivateFieldGet(cd,this).toSVGPath()}},!0))}else if(this.parent){const t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(gd,this),{bbox:_rotateBbox.call(td,editor_highlight_classPrivateFieldGet(pd,this).box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}});this.parent.drawLayer.updateProperties(editor_highlight_classPrivateFieldGet(Pd,this),{bbox:_rotateBbox.call(td,editor_highlight_classPrivateFieldGet(cd,this).box,t),path:{d:editor_highlight_classPrivateFieldGet(cd,this).toSVGPath()}})}const[a,s,n,r]=e.box;switch(this.rotation){case 0:this.x=a;this.y=s;this.width=n;this.height=r;break;case 90:{const[e,t]=this.parentDimensions;this.x=s;this.y=1-a;this.width=n*t/e;this.height=r*e/t;break}case 180:this.x=1-a;this.y=1-s;this.width=n;this.height=r;break;case 270:{const[e,t]=this.parentDimensions;this.x=1-s;this.y=a;this.width=n*t/e;this.height=r*e/t;break}}const{firstPoint:o}=e;editor_highlight_classPrivateFieldSet(fd,this,[(o[0]-a)/n,(o[1]-s)/r]);const{lastPoint:l}=editor_highlight_classPrivateFieldGet(cd,this);editor_highlight_classPrivateFieldSet(vd,this,[(l[0]-a)/n,(l[1]-s)/r])}function highlight_updateColor(e){const setColorAndOpacity=(e,t)=>{this.color=e;this.opacity=t;this.onUpdatedColor()},t=this.color,i=this.opacity;this.addCommands({cmd:setColorAndOpacity.bind(this,e,td._defaultOpacity),undo:setColorAndOpacity.bind(this,t,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0);this._dispatchEditorEvent("colorChanged",{value:e,previousValue:t})}function _updateThickness(e){const t=editor_highlight_classPrivateFieldGet(Fd,this),setThickness=e=>{editor_highlight_classPrivateFieldSet(Fd,this,e);editor_highlight_assertClassBrand(yd,this,_changeThickness).call(this,e)};this.addCommands({cmd:setThickness.bind(this,e),undo:setThickness.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0});this._reportTelemetry({action:"thickness_changed",thickness:e},!0);this._dispatchEditorEvent("thicknessChanged",{value:e,previousValue:t})}function _changeThickness(e){if(editor_highlight_classPrivateFieldGet(md,this)){editor_highlight_assertClassBrand(yd,this,_createFreeOutlines).call(this,{highlightOutlines:editor_highlight_classPrivateFieldGet(pd,this).getNewOutline(e/2)});this.fixAndSetPosition();this.setDims()}}function _cleanDrawLayer(){if(null!==editor_highlight_classPrivateFieldGet(gd,this)&&this.parent){this.parent.drawLayer.remove(editor_highlight_classPrivateFieldGet(gd,this));editor_highlight_classPrivateFieldSet(gd,this,null);this.parent.drawLayer.remove(editor_highlight_classPrivateFieldGet(Pd,this));editor_highlight_classPrivateFieldSet(Pd,this,null)}}function _addToDrawLayer(e=this.parent){if(null===editor_highlight_classPrivateFieldGet(gd,this)){({id:highlight_toSetter(editor_highlight_classPrivateFieldSet,[gd,this])._,clipPathId:highlight_toSetter(editor_highlight_classPrivateFieldSet,[ld,this])._}=e.drawLayer.draw({bbox:editor_highlight_classPrivateFieldGet(pd,this).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:editor_highlight_classPrivateFieldGet(md,this)},path:{d:editor_highlight_classPrivateFieldGet(pd,this).toSVGPath()}},!1,!0));editor_highlight_classPrivateFieldSet(Pd,this,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:editor_highlight_classPrivateFieldGet(md,this)},bbox:editor_highlight_classPrivateFieldGet(cd,this).box,path:{d:editor_highlight_classPrivateFieldGet(cd,this).toSVGPath()}},editor_highlight_classPrivateFieldGet(md,this)));editor_highlight_classPrivateFieldGet(_d,this)&&(editor_highlight_classPrivateFieldGet(_d,this).style.clipPath=editor_highlight_classPrivateFieldGet(ld,this))}}function _rotateBbox([e,t,i,a],s){switch(s){case 90:return[1-t-a,e,a,i];case 180:return[1-e-i,1-t-a,i,a];case 270:return[t,1-e-i,a,i]}return[e,t,i,a]}function _keydown(e){td._keyboardManager.exec(this,e)}function _setCaret(e){if(!editor_highlight_classPrivateFieldGet(nd,this))return;const t=window.getSelection();e?t.setPosition(editor_highlight_classPrivateFieldGet(nd,this),editor_highlight_classPrivateFieldGet(rd,this)):t.setPosition(editor_highlight_classPrivateFieldGet(hd,this),editor_highlight_classPrivateFieldGet(ud,this))}function _getRotation(){return editor_highlight_classPrivateFieldGet(md,this)?this.rotation:0}function _serializeBoxes(){if(editor_highlight_classPrivateFieldGet(md,this))return null;const[e,t]=this.pageDimensions,[i,a]=this.pageTranslation,s=editor_highlight_classPrivateFieldGet(od,this),n=new Float32Array(8*s.length);let r=0;for(const{x:o,y:l,width:d,height:c}of s){const s=o*e+i,h=(1-l)*t+a;n[r]=n[r+4]=s;n[r+1]=n[r+3]=h;n[r+2]=n[r+6]=s+d*e;n[r+5]=n[r+7]=h-c*t;r+=8}return n}function _serializeOutlines(e){return editor_highlight_classPrivateFieldGet(pd,this).serialize(e,editor_highlight_assertClassBrand(yd,this,_getRotation).call(this))}function _highlightMove(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}function _endHighlight(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"});this._freeHighlightId=-1;this._freeHighlight=null;this._freeHighlightClipId=""}function highlight_hasElementChanged(e){const{color:t}=this._initialData;return this.hasEditedComment||e.color.some((e,i)=>e!==t[i])}highlight_defineProperty(HighlightEditor,"_defaultColor",null);highlight_defineProperty(HighlightEditor,"_defaultOpacity",1);highlight_defineProperty(HighlightEditor,"_defaultThickness",12);highlight_defineProperty(HighlightEditor,"_type","highlight");highlight_defineProperty(HighlightEditor,"_editorType",f.HIGHLIGHT);highlight_defineProperty(HighlightEditor,"_freeHighlightId",-1);highlight_defineProperty(HighlightEditor,"_freeHighlight",null);highlight_defineProperty(HighlightEditor,"_freeHighlightClipId","");function draw_defineProperty(e,t,i){return(t=function draw_toPropertyKey(e){var t=function draw_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function draw_classPrivateFieldInitSpec(e,t,i){draw_checkPrivateRedeclaration(e,t),t.set(e,i)}function draw_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function draw_classPrivateFieldSet(e,t,i){return e.set(draw_assertClassBrand(e,t),i),i}function draw_classPrivateFieldGet(e,t){return e.get(draw_assertClassBrand(e,t))}function draw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Sd=new WeakMap;class DrawingOptions{constructor(){draw_classPrivateFieldInitSpec(this,Sd,Object.create(null))}updateProperty(e,t){this[e]=t;this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(const[t,i]of Object.entries(e))t.startsWith("_")||this.updateProperty(t,i)}updateSVGProperty(e,t){draw_classPrivateFieldGet(Sd,this)[e]=t}toSVGProperties(){const e=draw_classPrivateFieldGet(Sd,this);draw_classPrivateFieldSet(Sd,this,Object.create(null));return{root:e}}reset(){draw_classPrivateFieldSet(Sd,this,Object.create(null))}updateAll(e=this){this.updateProperties(e)}clone(){unreachable("Not implemented")}}var Cd=new WeakMap,xd=new WeakMap,kd=new WeakSet;class DrawingEditor extends AnnotationEditor{constructor(e){super(e);!function draw_classPrivateMethodInitSpec(e,t){draw_checkPrivateRedeclaration(e,t),t.add(e)}(this,kd);draw_classPrivateFieldInitSpec(this,Cd,null);draw_classPrivateFieldInitSpec(this,xd,void 0);draw_defineProperty(this,"_colorPicker",null);draw_defineProperty(this,"_drawId",null);draw_classPrivateFieldSet(xd,this,e.mustBeCommitted||!1);this._addOutlines(e)}onUpdatedColor(){this._colorPicker?.update(this.color);super.onUpdatedColor()}onUpdatedOpacity(){this._colorPicker?.updateOpacity?.(this.opacity)}_addOutlines(e){if(e.drawOutlines){draw_assertClassBrand(kd,this,_createDrawOutlines).call(this,e);draw_assertClassBrand(kd,this,draw_addToDrawLayer).call(this)}}static _mergeSVGProperties(e,t){const i=new Set(Object.keys(e));for(const[a,s]of Object.entries(t))i.has(a)?Object.assign(e[a],s):e[a]=s;return e}static getDefaultDrawingOptions(e){unreachable("Not implemented")}static get typesMap(){unreachable("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,t);if(this._currentParent){Ed._.updateProperty(i,t);this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}updateParams(e,t){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,t)}static get defaultPropertiesToUpdate(){const e=[],t=this._defaultDrawingOptions;for(const[i,a]of this.typesMap)e.push([i,t[a]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:t}=this;for(const[i,a]of this.constructor.typesMap)e.push([i,t[a]]);return e}_updateProperty(e,t,i){const a=this._drawingOptions,s=a[t],setter=s=>{a.updateProperty(t,s);const n=draw_classPrivateFieldGet(Cd,this).updateProperty(t,s);n&&draw_assertClassBrand(kd,this,_updateBbox).call(this,n);this.parent?.drawLayer.updateProperties(this._drawId,a.toSVGProperties());this._dispatchDrawPropertyEvent(t,i);e===this.colorType?this.onUpdatedColor():e===this.opacityType&&this.onUpdatedOpacity()};this.addCommands({cmd:setter.bind(this,i),undo:setter.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_updateColorAndOpacity(e,t){const i=this.constructor.typesMap.get(this.colorType),a=this.constructor.typesMap.get(this.opacityType),s=this._drawingOptions,n=s[i],r=s[a],setter=(e,t)=>{s.updateProperty(i,e);s.updateProperty(a,t);draw_classPrivateFieldGet(Cd,this).updateProperty(i,e);draw_classPrivateFieldGet(Cd,this).updateProperty(a,t);this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties());this.onUpdatedColor();this.onUpdatedOpacity()};this.addCommands({cmd:setter.bind(this,e,t),undo:setter.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:v.INK_COLOR_AND_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties(draw_classPrivateFieldGet(Cd,this).getPathResizingSVGProperties(draw_assertClassBrand(kd,this,_convertToDrawSpace).call(this)),{bbox:draw_assertClassBrand(kd,this,_rotateBox).call(this)}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties(draw_classPrivateFieldGet(Cd,this).getPathResizedSVGProperties(draw_assertClassBrand(kd,this,_convertToDrawSpace).call(this)),{bbox:draw_assertClassBrand(kd,this,_rotateBox).call(this)}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:draw_assertClassBrand(kd,this,_rotateBox).call(this)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties(draw_classPrivateFieldGet(Cd,this).getPathTranslatedSVGProperties(draw_assertClassBrand(kd,this,_convertToDrawSpace).call(this),this.parentDimensions),{bbox:draw_assertClassBrand(kd,this,_rotateBox).call(this)}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit();this.disableEditMode();this.disableEditing()}disableEditing(){super.disableEditing();this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing();this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this);this._isDraggable=!0;if(draw_classPrivateFieldGet(xd,this)){draw_classPrivateFieldSet(xd,this,!1);this.commit();this.parent.setSelected(this);e&&this.isOnScreen&&this.div.focus()}}remove(){draw_assertClassBrand(kd,this,draw_cleanDrawLayer).call(this);super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){draw_assertClassBrand(kd,this,draw_addToDrawLayer).call(this);draw_assertClassBrand(kd,this,_updateBbox).call(this,draw_classPrivateFieldGet(Cd,this).box);this.isAttachedToDOM||this.parent.add(this)}}}setParent(e){let t=!1;if(this.parent&&!e){this._uiManager.removeShouldRescale(this);draw_assertClassBrand(kd,this,draw_cleanDrawLayer).call(this)}else if(e){this._uiManager.addShouldRescale(this);draw_assertClassBrand(kd,this,draw_addToDrawLayer).call(this,e);t=!this.parent&&this.div?.classList.contains("selectedEditor")}super.setParent(e);t&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,DrawingEditor._mergeSVGProperties({bbox:draw_assertClassBrand(kd,this,_rotateBox).call(this)},draw_classPrivateFieldGet(Cd,this).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&draw_assertClassBrand(kd,this,_updateBbox).call(this,draw_classPrivateFieldGet(Cd,this).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}const i=super.render();i.classList.add("draw");const a=document.createElement("div");i.append(a);a.setAttribute("aria-hidden","true");a.className="internal";this.setDims();this._uiManager.addShouldRescale(this);this.disableEditing();this._isCopy&&this._moveAfterPaste(e,t);return i}static createDrawerInstance(e,t,i,a,s){unreachable("Not implemented")}static startDrawing(e,t,i,a){const{target:s,offsetX:n,offsetY:r,pointerId:o,pointerType:l}=a,d=t.currentPointers;if(d.isInitializedAndDifferentPointerType(l))return;Bd._=d;const{viewport:{rotation:c}}=e,{width:h,height:u}=s.getBoundingClientRect();Ad._?.abort();const _=Ad._=new AbortController,p=e.combinedSignal(_);d.setPointer(l,o);window.addEventListener("pointerup",e=>{d.isSamePointerIdOrRemove(e.pointerId)&&this._endDraw(e)},{signal:p});window.addEventListener("pointercancel",e=>{d.isSamePointerIdOrRemove(e.pointerId)&&this._currentParent.endDrawingSession()},{signal:p});window.addEventListener("pointerdown",e=>{if(d.isSamePointerType(e.pointerType)){d.initializeAndAddPointerId(e.pointerId);if(Ed._&&Ed._.isCancellable()){Ed._.removeLastElement();Ed._.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)}}},{capture:!0,passive:!1,signal:p});window.addEventListener("contextmenu",noContextMenu,{signal:p});s.addEventListener("pointermove",this._drawMove.bind(this),{signal:p});s.addEventListener("touchmove",e=>{d.isSameTimeStamp(e.timeStamp)&&stopEvent(e)},{signal:p});e.toggleDrawing();this._dispatchDrawingEvent("drawingStarted");t._editorUndoBar?.hide();if(Ed._)e.drawLayer.updateProperties(this._currentDrawId,Ed._.startNew(n,r,h,u,c));else{t.updateUIForDefaultProperties(this);Ed._=this.createDrawerInstance(n,r,h,u,c);Gd._=this.getDefaultDrawingOptions();this._currentParent=e;({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(Gd._.toSVGProperties(),Ed._.defaultSVGProperties),!0,!1))}}static _drawMove(e){const t=Bd._;if(!Ed._||!t)return;const{offsetX:i,offsetY:a,pointerId:s}=e;if(t.isSamePointerId(s))if(t.isUsingMultiplePointers())this._endDraw(e);else{this._currentParent.drawLayer.updateProperties(this._currentDrawId,Ed._.add(i,a));t.setTimeStamp(e.timeStamp);stopEvent(e)}}static _cleanup(e){if(e){this._currentDrawId=-1;this._currentParent=null;Ed._=null;Gd._=null;Bd._?.clearTimeStamp()}if(Ad._){Ad._.abort();Ad._=null;Bd._?.clearPointerIds()}e&&(Bd._=null)}static _endDraw(e){const t=this._currentParent;if(t){t.toggleDrawing(!0);this._dispatchDrawingEvent("drawingStopped");this._cleanup(!1);e?.target===t.div&&t.drawLayer.updateProperties(this._currentDrawId,Ed._.end(e.offsetX,e.offsetY));this._dispatchBezierPathChangedEvent();if(this.supportMultipleDrawings){const e=Ed._,i=this._currentDrawId,a=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(i,e.setLastElement(a))},undo:()=>{t.drawLayer.updateProperties(i,e.removeLastElement())},mustExec:!1,type:v.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const t=this._currentParent;if(!t)return null;t.toggleDrawing(!0);t.cleanUndoStack(v.DRAW_STEP);if(!Ed._.isEmpty()){const{pageDimensions:[i,a],scale:s}=t,n=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Ed._.getOutlines(i*s,a*s,s,this._INNER_MARGIN),drawingOptions:Gd._,mustBeCommitted:!e});this._cleanup(!0);return n}t.drawLayer.remove(this._currentDrawId);this._cleanup(!0);return null}createDrawingOptions(e){}static deserializeDraw(e,t,i,a,s,n){unreachable("Not implemented")}static async deserialize(e,t,i){const{rawDims:{pageWidth:a,pageHeight:s,pageX:n,pageY:r}}=t.viewport,o=this.deserializeDraw(n,r,a,s,this._INNER_MARGIN,e),l=await super.deserialize(e,t,i);l.createDrawingOptions(e);draw_assertClassBrand(kd,l,_createDrawOutlines).call(l,{drawOutlines:o});draw_assertClassBrand(kd,l,draw_addToDrawLayer).call(l);l.onScaleChanging();l.rotate();return l}serializeDraw(e){const[t,i]=this.pageTranslation,[a,s]=this.pageDimensions;return draw_classPrivateFieldGet(Cd,this).serialize([t,i,a,s],e)}renderAnnotationElement(e){e.updateEdited({rect:this.getPDFRect()});return null}static canCreateNewEmptyEditor(){return!1}_dispatchDrawPropertyEvent(e,t){const i={stroke:"colorChanged","stroke-width":"thicknessChanged","stroke-opacity":"opacityChanged"}[e];i&&this._dispatchEditorEvent(i,{value:t})}static _dispatchDrawingEvent(e){this.eventBus?.dispatch("annotation-editor-event",{source:this,type:e,editorType:this.name})}static _dispatchBezierPathChangedEvent(){this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"bezierPathChanged",page:this._currentParent?this._currentParent.pageIndex+1:NaN,editorType:this.name})}}sd=DrawingEditor;function _createDrawOutlines({drawOutlines:e,drawId:t,drawingOptions:i}){draw_classPrivateFieldSet(Cd,this,e);this._drawingOptions||=i;this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert[this.editorType]);if(t>=0){this._drawId=t;this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)}else this._drawId=draw_assertClassBrand(kd,this,_createDrawing).call(this,e,this.parent);draw_assertClassBrand(kd,this,_updateBbox).call(this,e.box)}function _createDrawing(e,t){const{id:i}=t.drawLayer.draw(sd._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i}function draw_cleanDrawLayer(){if(null!==this._drawId&&this.parent){this.parent.drawLayer.remove(this._drawId);this._drawId=null;this._drawingOptions.reset()}}function draw_addToDrawLayer(e=this.parent){if(null===this._drawId||this.parent!==e)if(null===this._drawId){this._drawingOptions.updateAll();this._drawId=draw_assertClassBrand(kd,this,_createDrawing).call(this,draw_classPrivateFieldGet(Cd,this),e)}else this.parent.drawLayer.updateParent(this._drawId,e.drawLayer)}function _convertToParentSpace([e,t,i,a]){const{parentDimensions:[s,n],rotation:r}=this;switch(r){case 90:return[t,1-e,i*(n/s),a*(s/n)];case 180:return[1-e,1-t,i,a];case 270:return[1-t,e,i*(n/s),a*(s/n)];default:return[e,t,i,a]}}function _convertToDrawSpace(){const{x:e,y:t,width:i,height:a,parentDimensions:[s,n],rotation:r}=this;switch(r){case 90:return[1-t,e,i*(s/n),a*(n/s)];case 180:return[1-e,1-t,i,a];case 270:return[t,1-e,i*(s/n),a*(n/s)];default:return[e,t,i,a]}}function _updateBbox(e){[this.x,this.y,this.width,this.height]=draw_assertClassBrand(kd,this,_convertToParentSpace).call(this,e);if(this.div){this.fixAndSetPosition();this.setDims()}this._onResized()}function _rotateBox(){const{x:e,y:t,width:i,height:a,rotation:s,parentRotation:n,parentDimensions:[r,o]}=this;switch((4*s+n)/90){case 1:return[1-t-a,e,a,i];case 2:return[1-e-i,1-t-a,i,a];case 3:return[t,1-e-i,a,i];case 4:return[e,t-i*(r/o),a*(o/r),i*(r/o)];case 5:return[1-t,e,i*(r/o),a*(o/r)];case 6:return[1-e-a*(o/r),1-t,a*(o/r),i*(r/o)];case 7:return[t-i*(r/o),1-e-a*(o/r),i*(r/o),a*(o/r)];case 8:return[e-i,t-a,i,a];case 9:return[1-t,e-i,a,i];case 10:return[1-e,1-t,i,a];case 11:return[t-a,1-e,a,i];case 12:return[e-a*(o/r),t,a*(o/r),i*(r/o)];case 13:return[1-t-i*(r/o),e-a*(o/r),i*(r/o),a*(o/r)];case 14:return[1-e,1-t-i*(r/o),a*(o/r),i*(r/o)];case 15:return[t,1-e,i*(r/o),a*(o/r)];default:return[e,t,i,a]}}draw_defineProperty(DrawingEditor,"_currentDrawId",-1);draw_defineProperty(DrawingEditor,"_currentParent",null);var Ed={_:null},Ad={_:null},Gd={_:null},Bd={_:null};draw_defineProperty(DrawingEditor,"_INNER_MARGIN",3);function inkdraw_classPrivateMethodInitSpec(e,t){inkdraw_checkPrivateRedeclaration(e,t),t.add(e)}function inkdraw_classPrivateFieldInitSpec(e,t,i){inkdraw_checkPrivateRedeclaration(e,t),t.set(e,i)}function inkdraw_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function inkdraw_classPrivateFieldGet(e,t){return e.get(inkdraw_assertClassBrand(e,t))}function inkdraw_classPrivateFieldSet(e,t,i){return e.set(inkdraw_assertClassBrand(e,t),i),i}function inkdraw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Md=new WeakMap,Id=new WeakMap,Td=new WeakMap,Dd=new WeakMap,Ld=new WeakMap,Nd=new WeakMap,Rd=new WeakMap,Od=new WeakMap,Wd=new WeakMap,jd=new WeakMap,Vd=new WeakMap,Ud=new WeakSet;class InkDrawOutliner{constructor(e,t,i,a,s,n){inkdraw_classPrivateMethodInitSpec(this,Ud);inkdraw_classPrivateFieldInitSpec(this,Md,new Float64Array(6));inkdraw_classPrivateFieldInitSpec(this,Id,void 0);inkdraw_classPrivateFieldInitSpec(this,Td,void 0);inkdraw_classPrivateFieldInitSpec(this,Dd,void 0);inkdraw_classPrivateFieldInitSpec(this,Ld,void 0);inkdraw_classPrivateFieldInitSpec(this,Nd,void 0);inkdraw_classPrivateFieldInitSpec(this,Rd,"");inkdraw_classPrivateFieldInitSpec(this,Od,0);inkdraw_classPrivateFieldInitSpec(this,Wd,new InkDrawOutline);inkdraw_classPrivateFieldInitSpec(this,jd,void 0);inkdraw_classPrivateFieldInitSpec(this,Vd,void 0);inkdraw_classPrivateFieldSet(jd,this,i);inkdraw_classPrivateFieldSet(Vd,this,a);inkdraw_classPrivateFieldSet(Dd,this,s);inkdraw_classPrivateFieldSet(Ld,this,n);[e,t]=inkdraw_assertClassBrand(Ud,this,_normalizePoint).call(this,e,t);const r=inkdraw_classPrivateFieldSet(Id,this,[NaN,NaN,NaN,NaN,e,t]);inkdraw_classPrivateFieldSet(Nd,this,[e,t]);inkdraw_classPrivateFieldSet(Td,this,[{line:r,points:inkdraw_classPrivateFieldGet(Nd,this)}]);inkdraw_classPrivateFieldGet(Md,this).set(r,0)}updateProperty(e,t){"stroke-width"===e&&inkdraw_classPrivateFieldSet(Ld,this,t)}isEmpty(){return!inkdraw_classPrivateFieldGet(Td,this)?.length}isCancellable(){return inkdraw_classPrivateFieldGet(Nd,this).length<=10}add(e,t){[e,t]=inkdraw_assertClassBrand(Ud,this,_normalizePoint).call(this,e,t);const[i,a,s,n]=inkdraw_classPrivateFieldGet(Md,this).subarray(2,6),r=e-s,o=t-n;if(Math.hypot(inkdraw_classPrivateFieldGet(jd,this)*r,inkdraw_classPrivateFieldGet(Vd,this)*o)<=2)return null;inkdraw_classPrivateFieldGet(Nd,this).push(e,t);if(isNaN(i)){inkdraw_classPrivateFieldGet(Md,this).set([s,n,e,t],2);inkdraw_classPrivateFieldGet(Id,this).push(NaN,NaN,NaN,NaN,e,t);return{path:{d:this.toSVGPath()}}}isNaN(inkdraw_classPrivateFieldGet(Md,this)[0])&&inkdraw_classPrivateFieldGet(Id,this).splice(6,6);inkdraw_classPrivateFieldGet(Md,this).set([i,a,s,n,e,t],0);inkdraw_classPrivateFieldGet(Id,this).push(...Outline.createBezierPoints(i,a,s,n,e,t));return{path:{d:this.toSVGPath()}}}end(e,t){const i=this.add(e,t);return i||(2===inkdraw_classPrivateFieldGet(Nd,this).length?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,i,a,s){inkdraw_classPrivateFieldSet(jd,this,i);inkdraw_classPrivateFieldSet(Vd,this,a);inkdraw_classPrivateFieldSet(Dd,this,s);[e,t]=inkdraw_assertClassBrand(Ud,this,_normalizePoint).call(this,e,t);const n=inkdraw_classPrivateFieldSet(Id,this,[NaN,NaN,NaN,NaN,e,t]);inkdraw_classPrivateFieldSet(Nd,this,[e,t]);const r=inkdraw_classPrivateFieldGet(Td,this).at(-1);if(r){r.line=new Float32Array(r.line);r.points=new Float32Array(r.points)}inkdraw_classPrivateFieldGet(Td,this).push({line:n,points:inkdraw_classPrivateFieldGet(Nd,this)});inkdraw_classPrivateFieldGet(Md,this).set(n,0);inkdraw_classPrivateFieldSet(Od,this,0);this.toSVGPath();return null}getLastElement(){return inkdraw_classPrivateFieldGet(Td,this).at(-1)}setLastElement(e){if(!inkdraw_classPrivateFieldGet(Td,this))return inkdraw_classPrivateFieldGet(Wd,this).setLastElement(e);inkdraw_classPrivateFieldGet(Td,this).push(e);inkdraw_classPrivateFieldSet(Id,this,e.line);inkdraw_classPrivateFieldSet(Nd,this,e.points);inkdraw_classPrivateFieldSet(Od,this,0);return{path:{d:this.toSVGPath()}}}removeLastElement(){if(!inkdraw_classPrivateFieldGet(Td,this))return inkdraw_classPrivateFieldGet(Wd,this).removeLastElement();inkdraw_classPrivateFieldGet(Td,this).pop();inkdraw_classPrivateFieldSet(Rd,this,"");for(let e=0,t=inkdraw_classPrivateFieldGet(Td,this).length;e<t;e++){const{line:t,points:i}=inkdraw_classPrivateFieldGet(Td,this)[e];inkdraw_classPrivateFieldSet(Id,this,t);inkdraw_classPrivateFieldSet(Nd,this,i);inkdraw_classPrivateFieldSet(Od,this,0);this.toSVGPath()}return{path:{d:inkdraw_classPrivateFieldGet(Rd,this)}}}toSVGPath(){const e=Outline.svgRound(inkdraw_classPrivateFieldGet(Id,this)[4]),t=Outline.svgRound(inkdraw_classPrivateFieldGet(Id,this)[5]);if(2===inkdraw_classPrivateFieldGet(Nd,this).length){inkdraw_classPrivateFieldSet(Rd,this,`${inkdraw_classPrivateFieldGet(Rd,this)} M ${e} ${t} Z`);return inkdraw_classPrivateFieldGet(Rd,this)}if(inkdraw_classPrivateFieldGet(Nd,this).length<=6){const i=inkdraw_classPrivateFieldGet(Rd,this).lastIndexOf("M");inkdraw_classPrivateFieldSet(Rd,this,`${inkdraw_classPrivateFieldGet(Rd,this).slice(0,i)} M ${e} ${t}`);inkdraw_classPrivateFieldSet(Od,this,6)}if(4===inkdraw_classPrivateFieldGet(Nd,this).length){const e=Outline.svgRound(inkdraw_classPrivateFieldGet(Id,this)[10]),t=Outline.svgRound(inkdraw_classPrivateFieldGet(Id,this)[11]);inkdraw_classPrivateFieldSet(Rd,this,`${inkdraw_classPrivateFieldGet(Rd,this)} L ${e} ${t}`);inkdraw_classPrivateFieldSet(Od,this,12);return inkdraw_classPrivateFieldGet(Rd,this)}const i=[];if(0===inkdraw_classPrivateFieldGet(Od,this)){i.push(`M ${e} ${t}`);inkdraw_classPrivateFieldSet(Od,this,6)}for(let e=inkdraw_classPrivateFieldGet(Od,this),t=inkdraw_classPrivateFieldGet(Id,this).length;e<t;e+=6){const[t,a,s,n,r,o]=inkdraw_classPrivateFieldGet(Id,this).slice(e,e+6).map(Outline.svgRound);i.push(`C${t} ${a} ${s} ${n} ${r} ${o}`)}inkdraw_classPrivateFieldSet(Rd,this,inkdraw_classPrivateFieldGet(Rd,this)+i.join(" "));inkdraw_classPrivateFieldSet(Od,this,inkdraw_classPrivateFieldGet(Id,this).length);return inkdraw_classPrivateFieldGet(Rd,this)}getOutlines(e,t,i,a){const s=inkdraw_classPrivateFieldGet(Td,this).at(-1);s.line=new Float32Array(s.line);s.points=new Float32Array(s.points);inkdraw_classPrivateFieldGet(Wd,this).build(inkdraw_classPrivateFieldGet(Td,this),e,t,i,inkdraw_classPrivateFieldGet(Dd,this),inkdraw_classPrivateFieldGet(Ld,this),a);inkdraw_classPrivateFieldSet(Md,this,null);inkdraw_classPrivateFieldSet(Id,this,null);inkdraw_classPrivateFieldSet(Td,this,null);inkdraw_classPrivateFieldSet(Rd,this,null);return inkdraw_classPrivateFieldGet(Wd,this)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}function _normalizePoint(e,t){return Outline._normalizePoint(e,t,inkdraw_classPrivateFieldGet(jd,this),inkdraw_classPrivateFieldGet(Vd,this),inkdraw_classPrivateFieldGet(Dd,this))}var zd=new WeakMap,Hd=new WeakMap,$d=new WeakMap,Kd=new WeakMap,Xd=new WeakMap,qd=new WeakMap,Yd=new WeakMap,Zd=new WeakMap,Qd=new WeakMap,Jd=new WeakSet;class InkDrawOutline extends Outline{constructor(...e){super(...e);inkdraw_classPrivateMethodInitSpec(this,Jd);inkdraw_classPrivateFieldInitSpec(this,zd,void 0);inkdraw_classPrivateFieldInitSpec(this,Hd,0);inkdraw_classPrivateFieldInitSpec(this,$d,void 0);inkdraw_classPrivateFieldInitSpec(this,Kd,void 0);inkdraw_classPrivateFieldInitSpec(this,Xd,void 0);inkdraw_classPrivateFieldInitSpec(this,qd,void 0);inkdraw_classPrivateFieldInitSpec(this,Yd,void 0);inkdraw_classPrivateFieldInitSpec(this,Zd,void 0);inkdraw_classPrivateFieldInitSpec(this,Qd,void 0)}build(e,t,i,a,s,n,r){inkdraw_classPrivateFieldSet(Xd,this,t);inkdraw_classPrivateFieldSet(qd,this,i);inkdraw_classPrivateFieldSet(Yd,this,a);inkdraw_classPrivateFieldSet(Zd,this,s);inkdraw_classPrivateFieldSet(Qd,this,n);inkdraw_classPrivateFieldSet($d,this,r??0);inkdraw_classPrivateFieldSet(Kd,this,e);inkdraw_assertClassBrand(Jd,this,_computeBbox).call(this)}get thickness(){return inkdraw_classPrivateFieldGet(Qd,this)}setLastElement(e){inkdraw_classPrivateFieldGet(Kd,this).push(e);return{path:{d:this.toSVGPath()}}}removeLastElement(){inkdraw_classPrivateFieldGet(Kd,this).pop();return{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:t}of inkdraw_classPrivateFieldGet(Kd,this)){e.push(`M${Outline.svgRound(t[4])} ${Outline.svgRound(t[5])}`);if(6!==t.length)if(12===t.length&&isNaN(t[6]))e.push(`L${Outline.svgRound(t[10])} ${Outline.svgRound(t[11])}`);else for(let i=6,a=t.length;i<a;i+=6){const[a,s,n,r,o,l]=t.subarray(i,i+6).map(Outline.svgRound);e.push(`C${a} ${s} ${n} ${r} ${o} ${l}`)}else e.push("Z")}return e.join("")}serialize([e,t,i,a],s){const n=[],r=[],[o,l,d,c]=inkdraw_assertClassBrand(Jd,this,_getBBoxWithNoMargin).call(this);let h,u,_,p,g,m,f,v,P;switch(inkdraw_classPrivateFieldGet(Zd,this)){case 0:P=Outline._rescale;h=e;u=t+a;_=i;p=-a;g=e+o*i;m=t+(1-l-c)*a;f=e+(o+d)*i;v=t+(1-l)*a;break;case 90:P=Outline._rescaleAndSwap;h=e;u=t;_=i;p=a;g=e+l*i;m=t+o*a;f=e+(l+c)*i;v=t+(o+d)*a;break;case 180:P=Outline._rescale;h=e+i;u=t;_=-i;p=a;g=e+(1-o-d)*i;m=t+l*a;f=e+(1-o)*i;v=t+(l+c)*a;break;case 270:P=Outline._rescaleAndSwap;h=e+i;u=t+a;_=-i;p=-a;g=e+(1-l-c)*i;m=t+(1-o-d)*a;f=e+(1-l)*i;v=t+(1-o)*a}for(const{line:e,points:t}of inkdraw_classPrivateFieldGet(Kd,this)){n.push(P(e,h,u,_,p,s?new Array(e.length):null));r.push(P(t,h,u,_,p,s?new Array(t.length):null))}return{lines:n,points:r,rect:[g,m,f,v]}}static deserialize(e,t,i,a,s,{paths:{lines:n,points:r},rotation:o,thickness:l}){const d=[];let c,h,u,_,p;switch(o){case 0:p=Outline._rescale;c=-e/i;h=t/a+1;u=1/i;_=-1/a;break;case 90:p=Outline._rescaleAndSwap;c=-t/a;h=-e/i;u=1/a;_=1/i;break;case 180:p=Outline._rescale;c=e/i+1;h=-t/a;u=-1/i;_=1/a;break;case 270:p=Outline._rescaleAndSwap;c=t/a+1;h=e/i+1;u=-1/a;_=-1/i}if(!n){n=[];for(const e of r){const t=e.length;if(2===t){n.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(4===t){n.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}const i=new Float32Array(3*(t-2));n.push(i);let[a,s,r,o]=e.subarray(0,4);i.set([NaN,NaN,NaN,NaN,a,s],0);for(let n=4;n<t;n+=2){const t=e[n],l=e[n+1];i.set(Outline.createBezierPoints(a,s,r,o,t,l),3*(n-2));[a,s,r,o]=[r,o,t,l]}}}for(let e=0,t=n.length;e<t;e++)d.push({line:p(n[e].map(e=>e??NaN),c,h,u,_),points:p(r[e].map(e=>e??NaN),c,h,u,_)});const g=new this.prototype.constructor;g.build(d,i,a,1,o,l,s);return g}get box(){return inkdraw_classPrivateFieldGet(zd,this)}updateProperty(e,t){return"stroke-width"===e?inkdraw_assertClassBrand(Jd,this,inkdraw_updateThickness).call(this,t):null}updateParentDimensions([e,t],i){const[a,s]=inkdraw_assertClassBrand(Jd,this,_getMarginComponents).call(this);inkdraw_classPrivateFieldSet(Xd,this,e);inkdraw_classPrivateFieldSet(qd,this,t);inkdraw_classPrivateFieldSet(Yd,this,i);const[n,r]=inkdraw_assertClassBrand(Jd,this,_getMarginComponents).call(this),o=n-a,l=r-s,d=inkdraw_classPrivateFieldGet(zd,this);d[0]-=o;d[1]-=l;d[2]+=2*o;d[3]+=2*l;return d}updateRotation(e){inkdraw_classPrivateFieldSet(Hd,this,e);return{path:{transform:this.rotationTransform}}}get viewBox(){return inkdraw_classPrivateFieldGet(zd,this).map(Outline.svgRound).join(" ")}get defaultProperties(){const[e,t]=inkdraw_classPrivateFieldGet(zd,this);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Outline.svgRound(e)} ${Outline.svgRound(t)}`}}}get rotationTransform(){const[,,e,t]=inkdraw_classPrivateFieldGet(zd,this);let i=0,a=0,s=0,n=0,r=0,o=0;switch(inkdraw_classPrivateFieldGet(Hd,this)){case 90:a=t/e;s=-e/t;r=e;break;case 180:i=-1;n=-1;r=e;o=t;break;case 270:a=-t/e;s=e/t;o=t;break;default:return""}return`matrix(${i} ${a} ${s} ${n} ${Outline.svgRound(r)} ${Outline.svgRound(o)})`}getPathResizingSVGProperties([e,t,i,a]){const[s,n]=inkdraw_assertClassBrand(Jd,this,_getMarginComponents).call(this),[r,o,l,d]=inkdraw_classPrivateFieldGet(zd,this);if(Math.abs(l-s)<=Outline.PRECISION||Math.abs(d-n)<=Outline.PRECISION){const s=e+i/2-(r+l/2),n=t+a/2-(o+d/2);return{path:{"transform-origin":`${Outline.svgRound(e)} ${Outline.svgRound(t)}`,transform:`${this.rotationTransform} translate(${s} ${n})`}}}const c=(i-2*s)/(l-2*s),h=(a-2*n)/(d-2*n),u=l/i,_=d/a;return{path:{"transform-origin":`${Outline.svgRound(r)} ${Outline.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${_}) translate(${Outline.svgRound(s)} ${Outline.svgRound(n)}) scale(${c} ${h}) translate(${Outline.svgRound(-s)} ${Outline.svgRound(-n)})`}}}getPathResizedSVGProperties([e,t,i,a]){const[s,n]=inkdraw_assertClassBrand(Jd,this,_getMarginComponents).call(this),r=inkdraw_classPrivateFieldGet(zd,this),[o,l,d,c]=r;r[0]=e;r[1]=t;r[2]=i;r[3]=a;if(Math.abs(d-s)<=Outline.PRECISION||Math.abs(c-n)<=Outline.PRECISION){const s=e+i/2-(o+d/2),n=t+a/2-(l+c/2);for(const{line:e,points:t}of inkdraw_classPrivateFieldGet(Kd,this)){Outline._translate(e,s,n,e);Outline._translate(t,s,n,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Outline.svgRound(e)} ${Outline.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const h=(i-2*s)/(d-2*s),u=(a-2*n)/(c-2*n),_=-h*(o+s)+e+s,p=-u*(l+n)+t+n;if(1!==h||1!==u||0!==_||0!==p)for(const{line:e,points:t}of inkdraw_classPrivateFieldGet(Kd,this)){Outline._rescale(e,_,p,h,u,e);Outline._rescale(t,_,p,h,u,t)}return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Outline.svgRound(e)} ${Outline.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],i){const[a,s]=i,n=inkdraw_classPrivateFieldGet(zd,this),r=e-n[0],o=t-n[1];if(inkdraw_classPrivateFieldGet(Xd,this)===a&&inkdraw_classPrivateFieldGet(qd,this)===s)for(const{line:e,points:t}of inkdraw_classPrivateFieldGet(Kd,this)){Outline._translate(e,r,o,e);Outline._translate(t,r,o,t)}else{const e=inkdraw_classPrivateFieldGet(Xd,this)/a,t=inkdraw_classPrivateFieldGet(qd,this)/s;inkdraw_classPrivateFieldSet(Xd,this,a);inkdraw_classPrivateFieldSet(qd,this,s);for(const{line:i,points:a}of inkdraw_classPrivateFieldGet(Kd,this)){Outline._rescale(i,r,o,e,t,i);Outline._rescale(a,r,o,e,t,a)}n[2]*=e;n[3]*=t}n[0]=e;n[1]=t;return{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Outline.svgRound(e)} ${Outline.svgRound(t)}`}}}get defaultSVGProperties(){const e=inkdraw_classPrivateFieldGet(zd,this);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Outline.svgRound(e[0])} ${Outline.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}function _getMarginComponents(e=inkdraw_classPrivateFieldGet(Qd,this)){const t=inkdraw_classPrivateFieldGet($d,this)+e/2*inkdraw_classPrivateFieldGet(Yd,this);return inkdraw_classPrivateFieldGet(Zd,this)%180==0?[t/inkdraw_classPrivateFieldGet(Xd,this),t/inkdraw_classPrivateFieldGet(qd,this)]:[t/inkdraw_classPrivateFieldGet(qd,this),t/inkdraw_classPrivateFieldGet(Xd,this)]}function _getBBoxWithNoMargin(){const[e,t,i,a]=inkdraw_classPrivateFieldGet(zd,this),[s,n]=inkdraw_assertClassBrand(Jd,this,_getMarginComponents).call(this,0);return[e+s,t+n,i-2*s,a-2*n]}function _computeBbox(){const e=inkdraw_classPrivateFieldSet(zd,this,a.slice());for(const{line:t}of inkdraw_classPrivateFieldGet(Kd,this)){if(t.length<=12){for(let i=4,a=t.length;i<a;i+=6)Util.pointBoundingBox(t[i],t[i+1],e);continue}let i=t[4],a=t[5];for(let s=6,n=t.length;s<n;s+=6){const[n,r,o,l,d,c]=t.subarray(s,s+6);Util.bezierBoundingBox(i,a,n,r,o,l,d,c,e);i=d;a=c}}const[t,i]=inkdraw_assertClassBrand(Jd,this,_getMarginComponents).call(this);e[0]=MathClamp(e[0]-t,0,1);e[1]=MathClamp(e[1]-i,0,1);e[2]=MathClamp(e[2]+t,0,1);e[3]=MathClamp(e[3]+i,0,1);e[2]-=e[0];e[3]-=e[1]}function inkdraw_updateThickness(e){const[t,i]=inkdraw_assertClassBrand(Jd,this,_getMarginComponents).call(this);inkdraw_classPrivateFieldSet(Qd,this,e);const[a,s]=inkdraw_assertClassBrand(Jd,this,_getMarginComponents).call(this),[n,r]=[a-t,s-i],o=inkdraw_classPrivateFieldGet(zd,this);o[0]-=n;o[1]-=r;o[2]+=2*n;o[3]+=2*r;return o}function ink_classPrivateMethodInitSpec(e,t){(function ink_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function ink_defineProperty(e,t,i){return(t=function ink_toPropertyKey(e){var t=function ink_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class InkDrawingOptions extends DrawingOptions{constructor(e){super();this._viewParameters=e;super.updateProperties({fill:"none",stroke:AnnotationEditor._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){if("stroke-width"===e){t??=this["stroke-width"];t*=this._viewParameters.realScale}super.updateSVGProperty(e,t)}clone(){const e=new InkDrawingOptions(this._viewParameters);e.updateAll(this);return e}}var ec,tc=new WeakSet;class InkEditor extends DrawingEditor{constructor(e){super({...e,name:"inkEditor"});ink_classPrivateMethodInitSpec(this,tc);this._willKeepAspectRatio=!0;this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,t){AnnotationEditor.initialize(e,t);this._defaultDrawingOptions=new InkDrawingOptions(t.viewParameters)}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!0}static get typesMap(){return shadow(this,"typesMap",new Map([[v.INK_THICKNESS,"stroke-width"],[v.INK_COLOR,"stroke"],[v.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,t,i,a,s){return new InkDrawOutliner(e,t,i,a,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,t,i,a,s,n){return InkDrawOutline.deserialize(e,t,i,a,s,n)}static async deserialize(e,t,i){let a=null;if(e instanceof InkAnnotationElement){const{data:{inkLists:t,rect:i,rotation:s,id:n,color:r,opacity:o,borderStyle:{rawWidth:l},popupRef:d,richText:c,contentsObj:h,creationDate:u,modificationDate:_},parent:{page:{pageNumber:p}}}=e;a=e={annotationType:f.INK,color:Array.from(r),thickness:l,opacity:o,paths:{points:t},boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:n,id:n,deleted:!1,popupRef:d,richText:c,comment:h?.str||null,creationDate:u,modificationDate:_}}else{const{popup:t,popupRef:i}=e;a=e={...e,popupRef:i||!(!t||!t.contents||t.deleted)||null,comment:!t?.deleted&&t?.contents||null,commentDate:!t?.deleted&&t?.date||null}}const s=await super.deserialize(e,t,i);s._initialData=a;e.comment&&s.setCommentData(e);return s}get toolbarButtons(){this._colorPicker||=new BasicColorPicker(this);return[["colorPicker",this._colorPicker]]}get colorType(){return v.INK_COLOR}get colorAndOpacityType(){return v.INK_COLOR_AND_OPACITY}get opacityType(){return v.INK_OPACITY}updateParams(e,t){e!==v.INK_COLOR_AND_OPACITY?super.updateParams(e,t):this._updateColorAndOpacity(t.color,t.opacity)}static updateDefaultParams(e,t){if(e!==v.INK_COLOR_AND_OPACITY)super.updateDefaultParams(e,t);else{super.updateDefaultParams(v.INK_COLOR,t.color);super.updateDefaultParams(v.INK_OPACITY,t.opacity)}}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:t,parent:i}=this;t.updateSVGProperty("stroke-width");i.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;if(e){super.onScaleChangingWhenDrawing();this._defaultDrawingOptions.updateSVGProperty("stroke-width");e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties())}}createDrawingOptions({color:e,thickness:t,opacity:i}){this._drawingOptions=InkEditor.getDefaultDrawingOptions({stroke:Util.makeHexColor(...e),"stroke-width":t,"stroke-opacity":i})}serialize(e=!1,t=null,i=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:a,points:s}=this.serializeDraw(e),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":o}}=this,l=Object.assign(super.serialize(e,t),{color:AnnotationEditor._colorManager.convert(n),opacity:r,thickness:o,paths:{lines:a,points:s}});this.addComment(l,this._isCopy);if(e){i&&(l.id=this.uid);l.isCopy=!0;return l}if(this.annotationElementId&&!function ink_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(tc,this,ink_hasElementChanged).call(this,l))return null;l.id=this.uid;return l}renderAnnotationElement(e){if(this.deleted){e.hide();return null}const{points:t,rect:i}=this.serializeDraw(!1);e.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:t,popup:this.comment});return null}}function ink_hasElementChanged(e){const{color:t,thickness:i,opacity:a,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((e,i)=>e!==t[i])||e.thickness!==i||e.opacity!==a||e.pageIndex!==s}ink_defineProperty(InkEditor,"_type","ink");ink_defineProperty(InkEditor,"_editorType",f.INK);ink_defineProperty(InkEditor,"_defaultDrawingOptions",null);class ContourDrawOutline extends InkDrawOutline{toSVGPath(){let e=super.toSVGPath();e.endsWith("Z")||(e+="Z");return e}}function signaturedraw_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class SignatureExtractor{static extractContoursFromText(e,{fontFamily:t,fontStyle:i,fontWeight:a},s,n,r,o){let l=new OffscreenCanvas(1,1),d=l.getContext("2d",{alpha:!1});const c=d.font=`${i} ${a} 200px ${t}`,{actualBoundingBoxLeft:h,actualBoundingBoxRight:u,actualBoundingBoxAscent:_,actualBoundingBoxDescent:p,fontBoundingBoxAscent:g,fontBoundingBoxDescent:m,width:f}=d.measureText(e),v=1.5,P=Math.ceil(Math.max(Math.abs(h)+Math.abs(u)||0,f)*v),w=Math.ceil(Math.max(Math.abs(_)+Math.abs(p)||200,Math.abs(g)+Math.abs(m)||200)*v);l=new OffscreenCanvas(P,w);d=l.getContext("2d",{alpha:!0,willReadFrequently:!0});d.font=c;d.filter="grayscale(1)";d.fillStyle="white";d.fillRect(0,0,P,w);d.fillStyle="black";d.fillText(e,.5*P/2,1.5*w/2);const F=signaturedraw_assertClassBrand(SignatureExtractor,this,_toUint).call(this,d.getImageData(0,0,P,w).data),b=signaturedraw_assertClassBrand(SignatureExtractor,this,_getHistogram).call(this,F),y=signaturedraw_assertClassBrand(SignatureExtractor,this,_guessThreshold).call(this,b),S=signaturedraw_assertClassBrand(SignatureExtractor,this,_findContours).call(this,F,P,w,y);return this.processDrawnLines({lines:{curves:S,width:P,height:w},pageWidth:s,pageHeight:n,rotation:r,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(e,t,i,a,s){const[n,r,o]=signaturedraw_assertClassBrand(SignatureExtractor,this,_getGrayPixels).call(this,e),[l,d]=signaturedraw_assertClassBrand(SignatureExtractor,this,_bilateralFilter).call(this,n,r,o,Math.hypot(r,o)*signaturedraw_assertClassBrand(SignatureExtractor,this,ic)._.sigmaSFactor,signaturedraw_assertClassBrand(SignatureExtractor,this,ic)._.sigmaR,signaturedraw_assertClassBrand(SignatureExtractor,this,ic)._.kernelSize),c=signaturedraw_assertClassBrand(SignatureExtractor,this,_guessThreshold).call(this,d),h=signaturedraw_assertClassBrand(SignatureExtractor,this,_findContours).call(this,l,r,o,c);return this.processDrawnLines({lines:{curves:h,width:r,height:o},pageWidth:t,pageHeight:i,rotation:a,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:e,pageWidth:t,pageHeight:i,rotation:a,innerMargin:s,mustSmooth:n,areContours:r}){a%180!=0&&([t,i]=[i,t]);const{curves:o,width:l,height:d}=e,c=e.thickness??0,h=[],u=Math.min(t/l,i/d),_=u/t,p=u/i,g=[];for(const{points:e}of o){const t=n?signaturedraw_assertClassBrand(SignatureExtractor,this,_douglasPeucker).call(this,e):e;if(!t)continue;g.push(t);const i=t.length,a=new Float32Array(i),s=new Float32Array(3*(2===i?2:i-2));h.push({line:s,points:a});if(2===i){a[0]=t[0]*_;a[1]=t[1]*p;s.set([NaN,NaN,NaN,NaN,a[0],a[1]],0);continue}let[r,o,l,d]=t;r*=_;o*=p;l*=_;d*=p;a.set([r,o,l,d],0);s.set([NaN,NaN,NaN,NaN,r,o],0);for(let e=4;e<i;e+=2){const i=a[e]=t[e]*_,n=a[e+1]=t[e+1]*p;s.set(Outline.createBezierPoints(r,o,l,d,i,n),3*(e-2));[r,o,l,d]=[l,d,i,n]}}if(0===h.length)return null;const m=r?new ContourDrawOutline:new InkDrawOutline;m.build(h,t,i,1,a,r?0:c,s);return{outline:m,newCurves:g,areContours:r,thickness:c,width:l,height:d}}static async compressSignature({outlines:e,areContours:t,thickness:i,width:a,height:s}){let n,r=1/0,o=-1/0,l=0;for(const t of e){l+=t.length;for(let e=2,i=t.length;e<i;e++){const i=t[e]-t[e-2];r=Math.min(r,i);o=Math.max(o,i)}}n=r>=-128&&o<=127?Int8Array:r>=-32768&&o<=32767?Int16Array:Int32Array;const d=e.length,c=8+3*d,h=new Uint32Array(c);let u=0;h[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(l-2*d)*n.BYTES_PER_ELEMENT;h[u++]=0;h[u++]=a;h[u++]=s;h[u++]=t?0:1;h[u++]=Math.max(0,Math.floor(i??0));h[u++]=d;h[u++]=n.BYTES_PER_ELEMENT;for(const t of e){h[u++]=t.length-2;h[u++]=t[0];h[u++]=t[1]}const _=new CompressionStream("deflate-raw"),p=_.writable.getWriter();await p.ready;p.write(h);const g=n.prototype.constructor;for(const t of e){const e=new g(t.length-2);for(let i=2,a=t.length;i<a;i++)e[i-2]=t[i]-t[i-2];p.write(e)}p.close();return(await new Response(_.readable).bytes()).toBase64()}static async decompressSignature(e){try{const t=Uint8Array.fromBase64(e),{readable:i,writable:a}=new DecompressionStream("deflate-raw"),s=a.getWriter();await s.ready;s.write(t).then(async()=>{await s.ready;await s.close()}).catch(()=>{});let n=null,r=0;for await(const e of i){n||=new Uint8Array(new Uint32Array(e.buffer,0,4)[0]);n.set(e,r);r+=e.length}const o=new Uint32Array(n.buffer,0,n.length>>2),l=o[1];if(0!==l)throw new Error(`Invalid version: ${l}`);const d=o[2],c=o[3],h=0===o[4],u=o[5],_=o[6],p=o[7],g=[],m=(8+3*_)*Uint32Array.BYTES_PER_ELEMENT;let f;switch(p){case Int8Array.BYTES_PER_ELEMENT:f=new Int8Array(n.buffer,m);break;case Int16Array.BYTES_PER_ELEMENT:f=new Int16Array(n.buffer,m);break;case Int32Array.BYTES_PER_ELEMENT:f=new Int32Array(n.buffer,m)}r=0;for(let e=0;e<_;e++){const t=o[3*e+8],i=new Float32Array(t+2);g.push(i);for(let t=0;t<2;t++)i[t]=o[3*e+8+t+1];for(let e=0;e<t;e++)i[e+2]=i[e]+f[r++]}return{areContours:h,thickness:u,outlines:g,width:d,height:c}}catch(e){warn(`decompressSignature: ${e}`);return null}}}ec=SignatureExtractor;function _neighborIndexToId(e,t,i,a){a-=t;return 0===(i-=e)?a>0?0:4:1===i?a+6:2-a}function _clockwiseNonZero(e,t,i,a,s,n,r){const o=signaturedraw_assertClassBrand(ec,this,_neighborIndexToId).call(this,i,a,s,n);for(let s=0;s<8;s++){const n=(-s+o-r+16)%8;if(0!==e[(i+signaturedraw_assertClassBrand(ec,this,ac)._[2*n])*t+(a+signaturedraw_assertClassBrand(ec,this,ac)._[2*n+1])])return n}return-1}function _counterClockwiseNonZero(e,t,i,a,s,n,r){const o=signaturedraw_assertClassBrand(ec,this,_neighborIndexToId).call(this,i,a,s,n);for(let s=0;s<8;s++){const n=(s+o+r+16)%8;if(0!==e[(i+signaturedraw_assertClassBrand(ec,this,ac)._[2*n])*t+(a+signaturedraw_assertClassBrand(ec,this,ac)._[2*n+1])])return n}return-1}function _findContours(e,t,i,a){const s=e.length,n=new Int32Array(s);for(let t=0;t<s;t++)n[t]=e[t]<=a?1:0;for(let e=1;e<i-1;e++)n[e*t]=n[e*t+t-1]=0;for(let e=0;e<t;e++)n[e]=n[t*i-1-e]=0;let r,o=1;const l=[];for(let e=1;e<i-1;e++){r=1;for(let i=1;i<t-1;i++){const a=e*t+i,s=n[a];if(0===s)continue;let d=e,c=i;if(1===s&&0===n[a-1]){o+=1;c-=1}else{if(!(s>=1&&0===n[a+1])){1!==s&&(r=Math.abs(s));continue}o+=1;c+=1;s>1&&(r=s)}const h=[i,e],u=c===i+1,_={isHole:u,points:h,id:o,parent:0};l.push(_);let p;for(const e of l)if(e.id===r){p=e;break}p?p.isHole?_.parent=u?p.parent:r:_.parent=u?r:p.parent:_.parent=u?r:0;const g=signaturedraw_assertClassBrand(ec,this,_clockwiseNonZero).call(this,n,t,e,i,d,c,0);if(-1===g){n[a]=-o;1!==n[a]&&(r=Math.abs(n[a]));continue}let m=signaturedraw_assertClassBrand(ec,this,ac)._[2*g],f=signaturedraw_assertClassBrand(ec,this,ac)._[2*g+1];const v=e+m,P=i+f;d=v;c=P;let w=e,F=i;for(;;){const s=signaturedraw_assertClassBrand(ec,this,_counterClockwiseNonZero).call(this,n,t,w,F,d,c,1);m=signaturedraw_assertClassBrand(ec,this,ac)._[2*s];f=signaturedraw_assertClassBrand(ec,this,ac)._[2*s+1];const l=w+m,u=F+f;h.push(u,l);const _=w*t+F;0===n[_+1]?n[_]=-o:1===n[_]&&(n[_]=o);if(l===e&&u===i&&w===v&&F===P){1!==n[a]&&(r=Math.abs(n[a]));break}d=w;c=F;w=l;F=u}}}return l}function _douglasPeuckerHelper(e,t,i,a){if(i-t<=4){for(let s=t;s<i-2;s+=2)a.push(e[s],e[s+1]);return}const s=e[t],n=e[t+1],r=e[i-4]-s,o=e[i-3]-n,l=Math.hypot(r,o),d=r/l,c=o/l,h=d*n-c*s,u=o/r,_=1/l,p=Math.atan(u),g=Math.cos(p),m=Math.sin(p),f=_*(Math.abs(g)+Math.abs(m)),v=_*(1-f+f**2),P=Math.max(Math.atan(Math.abs(m+g)*v),Math.atan(Math.abs(m-g)*v));let w=0,F=t;for(let a=t+2;a<i-2;a+=2){const t=Math.abs(h-d*e[a+1]+c*e[a]);if(t>w){F=a;w=t}}if(w>(l*P)**2){signaturedraw_assertClassBrand(ec,this,_douglasPeuckerHelper).call(this,e,t,F+2,a);signaturedraw_assertClassBrand(ec,this,_douglasPeuckerHelper).call(this,e,F,i,a)}else a.push(s,n)}function _douglasPeucker(e){const t=[],i=e.length;signaturedraw_assertClassBrand(ec,this,_douglasPeuckerHelper).call(this,e,0,i,t);t.push(e[i-2],e[i-1]);return t.length<=4?null:t}function _bilateralFilter(e,t,i,a,s,n){const r=new Float32Array(n**2),o=-2*a**2,l=n>>1;for(let e=0;e<n;e++){const t=(e-l)**2;for(let i=0;i<n;i++)r[e*n+i]=Math.exp((t+(i-l)**2)/o)}const d=new Float32Array(256),c=-2*s**2;for(let e=0;e<256;e++)d[e]=Math.exp(e**2/c);const h=e.length,u=new Uint8Array(h),_=new Uint32Array(256);for(let a=0;a<i;a++)for(let s=0;s<t;s++){const o=a*t+s,c=e[o];let h=0,p=0;for(let o=0;o<n;o++){const u=a+o-l;if(!(u<0||u>=i))for(let i=0;i<n;i++){const a=s+i-l;if(a<0||a>=t)continue;const _=e[u*t+a],g=r[o*n+i]*d[Math.abs(_-c)];h+=_*g;p+=g}}_[u[o]=Math.round(h/p)]++}return[u,_]}function _getHistogram(e){const t=new Uint32Array(256);for(const i of e)t[i]++;return t}function _toUint(e){const t=e.length,i=new Uint8ClampedArray(t>>2);let a=-1/0,s=1/0;for(let t=0,n=i.length;t<n;t++){const n=i[t]=e[t<<2];a=Math.max(a,n);s=Math.min(s,n)}const n=255/(a-s);for(let e=0,t=i.length;e<t;e++)i[e]=(i[e]-s)*n;return i}function _guessThreshold(e){let t,i=-1/0,a=-1/0;const s=e.findIndex(e=>0!==e);let n=s,r=s;for(t=s;t<256;t++){const s=e[t];if(s>i){if(t-n>a){a=t-n;r=t-1}i=s;n=t}}for(t=r-1;t>=0&&!(e[t]>e[t+1]);t--);return t}function _getGrayPixels(e){const t=e,{width:i,height:a}=e,{maxDim:s}=signaturedraw_assertClassBrand(ec,this,ic)._;let n=i,r=a;if(i>s||a>s){let o=i,l=a,d=Math.log2(Math.max(i,a)/s);const c=Math.floor(d);d=d===c?c-1:c;for(let i=0;i<d;i++){n=Math.ceil(o/2);r=Math.ceil(l/2);const i=new OffscreenCanvas(n,r);i.getContext("2d").drawImage(e,0,0,o,l,0,0,n,r);o=n;l=r;e!==t&&e.close();e=i.transferToImageBitmap()}const h=Math.min(s/n,s/r);n=Math.round(n*h);r=Math.round(r*h)}const o=new OffscreenCanvas(n,r).getContext("2d",{willReadFrequently:!0});o.fillStyle="white";o.fillRect(0,0,n,r);o.filter="grayscale(1)";o.drawImage(e,0,0,e.width,e.height,0,0,n,r);const l=o.getImageData(0,0,n,r).data;return[signaturedraw_assertClassBrand(ec,this,_toUint).call(this,l),n,r]}var ic={_:{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}},ac={_:new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1])};function signature_defineProperty(e,t,i){return(t=function signature_toPropertyKey(e){var t=function signature_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function signature_classPrivateFieldInitSpec(e,t,i){(function signature_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function signature_classPrivateFieldGet(e,t){return e.get(signature_assertClassBrand(e,t))}function signature_classPrivateFieldSet(e,t,i){return e.set(signature_assertClassBrand(e,t),i),i}function signature_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}class SignatureOptions extends DrawingOptions{constructor(){super();super.updateProperties({fill:AnnotationEditor._defaultLineColor,"stroke-width":0})}clone(){const e=new SignatureOptions;e.updateAll(this);return e}}class DrawnSignatureOptions extends InkDrawingOptions{constructor(e){super(e);super.updateProperties({stroke:AnnotationEditor._defaultLineColor,"stroke-width":1})}clone(){const e=new DrawnSignatureOptions(this._viewParameters);e.updateAll(this);return e}}var sc=new WeakMap,nc=new WeakMap,rc=new WeakMap,oc=new WeakMap;class SignatureEditor extends DrawingEditor{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});signature_classPrivateFieldInitSpec(this,sc,!1);signature_classPrivateFieldInitSpec(this,nc,null);signature_classPrivateFieldInitSpec(this,rc,null);signature_classPrivateFieldInitSpec(this,oc,null);this._willKeepAspectRatio=!0;signature_classPrivateFieldSet(rc,this,e.signatureData||null);signature_classPrivateFieldSet(nc,this,null);this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,t){AnnotationEditor.initialize(e,t);this._defaultDrawingOptions=new SignatureOptions;this._defaultDrawnSignatureOptions=new DrawnSignatureOptions(t.viewParameters)}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();t.updateProperties(e);return t}static get supportMultipleDrawings(){return!1}static get typesMap(){return shadow(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!signature_classPrivateFieldGet(nc,this)}}static computeTelemetryFinalData(e){const t=e.get("hasDescription");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,t;const{_isCopy:i}=this;if(i){this._isCopy=!1;e=this.x;t=this.y}super.render();if(null===this._drawId)if(signature_classPrivateFieldGet(rc,this)){const{lines:e,mustSmooth:t,areContours:i,description:a,uuid:s,heightInPage:n}=signature_classPrivateFieldGet(rc,this),{rawDims:{pageWidth:r,pageHeight:o},rotation:l}=this.parent.viewport,d=SignatureExtractor.processDrawnLines({lines:e,pageWidth:r,pageHeight:o,rotation:l,innerMargin:SignatureEditor._INNER_MARGIN,mustSmooth:t,areContours:i});this.addSignature(d,n,a,s)}else{this.div.setAttribute("data-l10n-args",JSON.stringify({description:""}));this.div.hidden=!0;this._uiManager.getSignature(this)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:signature_classPrivateFieldGet(nc,this)||""}));if(i){this._isCopy=!0;this._moveAfterPaste(e,t)}return this.div}setUuid(e){signature_classPrivateFieldSet(oc,this,e);this.addEditToolbar()}getUuid(){return signature_classPrivateFieldGet(oc,this)}get description(){return signature_classPrivateFieldGet(nc,this)}set description(e){signature_classPrivateFieldSet(nc,this,e);if(this.div){this.div.setAttribute("data-l10n-args",JSON.stringify({description:e}));super.addEditToolbar().then(t=>{t?.updateEditSignatureButton(e)})}}getSignaturePreview(){const{newCurves:e,areContours:t,thickness:i,width:a,height:s}=signature_classPrivateFieldGet(rc,this),n=Math.max(a,s);return{areContours:t,outline:SignatureExtractor.processDrawnLines({lines:{curves:e.map(e=>({points:e})),thickness:i,width:a,height:s},pageWidth:n,pageHeight:n,rotation:0,innerMargin:0,mustSmooth:!1,areContours:t}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,t,i,a){const{x:s,y:n}=this,{outline:r}=signature_classPrivateFieldSet(rc,this,e);signature_classPrivateFieldSet(sc,this,r instanceof ContourDrawOutline);this.description=i;let o;if(signature_classPrivateFieldGet(sc,this))o=SignatureEditor.getDefaultDrawingOptions();else{o=SignatureEditor._defaultDrawnSignatureOptions.clone();o.updateProperties({"stroke-width":r.thickness})}this._addOutlines({drawOutlines:r,drawingOptions:o});const[,l]=this.pageDimensions;let d=t/l;d=d>=1?.5:d;this.width*=d/this.height;if(this.width>=1){d*=.9/this.width;this.width=.9}this.height=d;this.setDims();this.x=s;this.y=n;this.center();this._onResized();this.onScaleChanging();this.rotate();this._uiManager.addToAnnotationStorage(this);this.setUuid(a);this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!a,hasDescription:!!i}});this.div.hidden=!1;this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"signatureAdded",page:this.pageIndex+1,editorType:this.constructor.name,id:this.uid,value:this,description:i})}getFromImage(e){const{rawDims:{pageWidth:t,pageHeight:i},rotation:a}=this.parent.viewport;return SignatureExtractor.process(e,t,i,a,SignatureEditor._INNER_MARGIN)}getFromText(e,t){const{rawDims:{pageWidth:i,pageHeight:a},rotation:s}=this.parent.viewport;return SignatureExtractor.extractContoursFromText(e,t,i,a,s,SignatureEditor._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:t,pageHeight:i},rotation:a}=this.parent.viewport;return SignatureExtractor.processDrawnLines({lines:e,pageWidth:t,pageHeight:i,rotation:a,innerMargin:SignatureEditor._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:t}){if(e)this._drawingOptions=SignatureEditor.getDefaultDrawingOptions();else{this._drawingOptions=SignatureEditor._defaultDrawnSignatureOptions.clone();this._drawingOptions.updateProperties({"stroke-width":t})}}serialize(e=!1,t=null,i=!1){if(this.isEmpty())return null;const{lines:a,points:s}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":n}}=this,r=Object.assign(super.serialize(e,t),{isSignature:!0,areContours:signature_classPrivateFieldGet(sc,this),color:[0,0,0],thickness:signature_classPrivateFieldGet(sc,this)?0:n});this.addComment(r,this._isCopy);if(e){r.paths={lines:a,points:s};r.uuid=signature_classPrivateFieldGet(oc,this);r.isCopy=!0}else{r.lines=a;i&&(r.id=this.uid)}signature_classPrivateFieldGet(nc,this)&&(r.accessibilityData={type:"Figure",alt:signature_classPrivateFieldGet(nc,this)});return r}static deserializeDraw(e,t,i,a,s,n){return n.areContours?ContourDrawOutline.deserialize(e,t,i,a,s,n):InkDrawOutline.deserialize(e,t,i,a,s,n)}static async deserialize(e,t,i){const a=await super.deserialize(e,t,i);signature_classPrivateFieldSet(sc,a,e.areContours);a.description=e.accessibilityData?.alt||"";signature_classPrivateFieldSet(oc,a,e.uuid);return a}}signature_defineProperty(SignatureEditor,"_type","signature");signature_defineProperty(SignatureEditor,"_editorType",f.SIGNATURE);signature_defineProperty(SignatureEditor,"_defaultDrawingOptions",null);function stamp_defineProperty(e,t,i){return(t=function stamp_toPropertyKey(e){var t=function stamp_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function stamp_classPrivateFieldInitSpec(e,t,i){stamp_checkPrivateRedeclaration(e,t),t.set(e,i)}function stamp_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function stamp_classPrivateFieldGet(e,t){return e.get(stamp_assertClassBrand(e,t))}function stamp_classPrivateFieldSet(e,t,i){return e.set(stamp_assertClassBrand(e,t),i),i}function stamp_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var lc=new WeakMap,dc=new WeakMap,cc=new WeakMap,hc=new WeakMap,uc=new WeakMap,_c=new WeakMap,pc=new WeakMap,gc=new WeakMap,mc=new WeakMap,fc=new WeakMap,vc=new WeakMap,Pc=new WeakSet;class StampEditor extends AnnotationEditor{constructor(e){super({...e,name:"stampEditor"});!function stamp_classPrivateMethodInitSpec(e,t){stamp_checkPrivateRedeclaration(e,t),t.add(e)}(this,Pc);stamp_classPrivateFieldInitSpec(this,lc,null);stamp_classPrivateFieldInitSpec(this,dc,null);stamp_classPrivateFieldInitSpec(this,cc,null);stamp_classPrivateFieldInitSpec(this,hc,null);stamp_classPrivateFieldInitSpec(this,uc,null);stamp_classPrivateFieldInitSpec(this,_c,"");stamp_classPrivateFieldInitSpec(this,pc,null);stamp_classPrivateFieldInitSpec(this,gc,!1);stamp_classPrivateFieldInitSpec(this,mc,null);stamp_classPrivateFieldInitSpec(this,fc,!1);stamp_classPrivateFieldInitSpec(this,vc,!1);stamp_classPrivateFieldSet(hc,this,e.bitmapUrl);stamp_classPrivateFieldSet(uc,this,e.bitmapFile);this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,t){AnnotationEditor.initialize(e,t)}static isHandlingMimeForPasting(e){return Y.includes(e)}static paste(e,t){t.pasteEditor({mode:f.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1);super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){const t=e.get("hasAltText");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:a,width:s,height:n}=e||this.copyCanvas(null,null,!0).imageData,r=await i.guess({name:"altText",request:{data:a,width:s,height:n,channels:a.length/(s*n)}});if(!r)throw new Error("No response from the AI service.");if(r.error)throw new Error("Error from the AI service.");if(r.cancel)return null;if(!r.output)throw new Error("No valid response from the AI service.");const o=r.output;await this.setGuessedAltText(o);t&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1});return o}remove(){if(stamp_classPrivateFieldGet(dc,this)){stamp_classPrivateFieldSet(lc,this,null);this._uiManager.imageManager.deleteId(stamp_classPrivateFieldGet(dc,this));stamp_classPrivateFieldGet(pc,this)?.remove();stamp_classPrivateFieldSet(pc,this,null);if(stamp_classPrivateFieldGet(mc,this)){clearTimeout(stamp_classPrivateFieldGet(mc,this));stamp_classPrivateFieldSet(mc,this,null)}}super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){stamp_classPrivateFieldGet(dc,this)&&null===stamp_classPrivateFieldGet(pc,this)&&stamp_assertClassBrand(Pc,this,_getBitmap).call(this);this.isAttachedToDOM||this.parent.add(this)}}else stamp_classPrivateFieldGet(dc,this)&&stamp_assertClassBrand(Pc,this,_getBitmap).call(this)}onceAdded(e){this._isDraggable=!0;e&&this.div.focus()}isEmpty(){return!(stamp_classPrivateFieldGet(cc,this)||stamp_classPrivateFieldGet(lc,this)||stamp_classPrivateFieldGet(hc,this)||stamp_classPrivateFieldGet(uc,this)||stamp_classPrivateFieldGet(dc,this)||stamp_classPrivateFieldGet(gc,this))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this._isCopy){e=this.x;t=this.y}super.render();this.div.hidden=!0;this.createAltText();stamp_classPrivateFieldGet(gc,this)||(stamp_classPrivateFieldGet(lc,this)?stamp_assertClassBrand(Pc,this,_createCanvas).call(this):stamp_assertClassBrand(Pc,this,_getBitmap).call(this));this._isCopy&&this._moveAfterPaste(e,t);this._uiManager.addShouldRescale(this);return this.div}setCanvas(e,t){const{id:i,bitmap:a}=this._uiManager.imageManager.getFromCanvas(e,t);t.remove();if(i&&this._uiManager.imageManager.isValidId(i)){stamp_classPrivateFieldSet(dc,this,i);a&&stamp_classPrivateFieldSet(lc,this,a);stamp_classPrivateFieldSet(gc,this,!1);stamp_assertClassBrand(Pc,this,_createCanvas).call(this)}}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==stamp_classPrivateFieldGet(mc,this)&&clearTimeout(stamp_classPrivateFieldGet(mc,this));stamp_classPrivateFieldSet(mc,this,setTimeout(()=>{stamp_classPrivateFieldSet(mc,this,null);stamp_assertClassBrand(Pc,this,_drawBitmap).call(this)},200))}copyCanvas(e,t,i=!1){e||=224;const{width:a,height:s}=stamp_classPrivateFieldGet(lc,this),n=new OutputScale;let r=stamp_classPrivateFieldGet(lc,this),o=a,l=s,d=null;if(t){if(a>t||s>t){const e=Math.min(t/a,t/s);o=Math.floor(a*e);l=Math.floor(s*e)}d=document.createElement("canvas");const e=d.width=Math.ceil(o*n.sx),i=d.height=Math.ceil(l*n.sy);stamp_classPrivateFieldGet(fc,this)||(r=stamp_assertClassBrand(Pc,this,_scaleBitmap).call(this,e,i));const c=d.getContext("2d");c.filter=this._uiManager.hcmFilter;let h="white",u="#cfcfd8";if("none"!==this._uiManager.hcmFilter)u="black";else if(ColorScheme.isDarkMode){h="#8f8f9d";u="#42414d"}const _=15,p=_*n.sx,g=_*n.sy,m=new OffscreenCanvas(2*p,2*g),f=m.getContext("2d");f.fillStyle=h;f.fillRect(0,0,2*p,2*g);f.fillStyle=u;f.fillRect(0,0,p,g);f.fillRect(p,g,p,g);c.fillStyle=c.createPattern(m,"repeat");c.fillRect(0,0,e,i);c.drawImage(r,0,0,r.width,r.height,0,0,e,i)}let c=null;if(i){let t,i;if(n.symmetric&&r.width<e&&r.height<e){t=r.width;i=r.height}else{r=stamp_classPrivateFieldGet(lc,this);if(a>e||s>e){const n=Math.min(e/a,e/s);t=Math.floor(a*n);i=Math.floor(s*n);stamp_classPrivateFieldGet(fc,this)||(r=stamp_assertClassBrand(Pc,this,_scaleBitmap).call(this,t,i))}}const o=new OffscreenCanvas(t,i).getContext("2d",{willReadFrequently:!0});o.drawImage(r,0,0,r.width,r.height,0,0,t,i);c={width:t,height:i,data:o.getImageData(0,0,t,i).data}}return{canvas:d,width:o,height:l,imageData:c}}static async deserialize(e,t,i){let a=null,s=!1;if(e instanceof StampAnnotationElement){const{data:{rect:n,rotation:r,id:o,structParent:l,popupRef:d,richText:c,contentsObj:h,creationDate:u,modificationDate:_},container:p,parent:{page:{pageNumber:m}},canvas:v}=e;let P,w;if(v){delete e.canvas;({id:P,bitmap:w}=i.imageManager.getFromCanvas(p.id,v));v.remove()}else{s=!0;e._hasNoCanvas=!0}const F=(await t._structTree.getAriaAttributes(`${g}${o}`))?.get("aria-label")||"";a=e={annotationType:f.STAMP,bitmapId:P,bitmap:w,pageIndex:m-1,rect:n.slice(0),rotation:r,annotationElementId:o,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:F},isSvg:!1,structParent:l,popupRef:d,richText:c,comment:h?.str||null,creationDate:u,modificationDate:_}}else{const{popup:t,popupRef:i}=e;a=e={...e,popupRef:i||!(!t||!t.contents||t.deleted)||null,comment:!t?.deleted&&t?.contents||null,commentDate:!t?.deleted&&t?.date||null}}const n=await super.deserialize(e,t,i),{rect:r,bitmap:o,bitmapUrl:l,bitmapId:d,isSvg:c,accessibilityData:h}=e;if(s){i.addMissingCanvas(e.id,n);stamp_classPrivateFieldSet(gc,n,!0)}else if(d&&i.imageManager.isValidId(d)){stamp_classPrivateFieldSet(dc,n,d);o&&stamp_classPrivateFieldSet(lc,n,o)}else stamp_classPrivateFieldSet(hc,n,l);stamp_classPrivateFieldSet(fc,n,c);const[u,_]=n.pageDimensions;n.width=(r[2]-r[0])/u;n.height=(r[3]-r[1])/_;h&&(n.altTextData=h);n._initialData=a;e.comment&&n.setCommentData(e);stamp_classPrivateFieldSet(vc,n,!!a);return n}serialize(e=!1,t=null,i=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const a=Object.assign(super.serialize(e,t),{bitmapId:stamp_classPrivateFieldGet(dc,this),isSvg:stamp_classPrivateFieldGet(fc,this)});this.addComment(a,this._isCopy);if(e){a.bitmapUrl=stamp_assertClassBrand(Pc,this,_serializeBitmap).call(this,!0);a.accessibilityData=this.serializeAltText(!0);i&&(a.id=this.uid);a.isCopy=!0;return a}const{decorative:s,altText:n}=this.serializeAltText(!1);!s&&n&&(a.accessibilityData={type:"Figure",alt:n});if(this.annotationElementId){const e=stamp_assertClassBrand(Pc,this,stamp_hasElementChanged).call(this,a);if(e.isSame)return null;e.isSameAltText?delete a.accessibilityData:a.accessibilityData.structParent=this._initialData.structParent??-1;a.id=this.uid;delete a.bitmapId;return a}if(null===t)return a;t.stamps||=new Map;const r=stamp_classPrivateFieldGet(fc,this)?(a.rect[2]-a.rect[0])*(a.rect[3]-a.rect[1]):null;if(t.stamps.has(stamp_classPrivateFieldGet(dc,this))){if(stamp_classPrivateFieldGet(fc,this)){const e=t.stamps.get(stamp_classPrivateFieldGet(dc,this));if(r>e.area){e.area=r;e.serialized.bitmap.close();e.serialized.bitmap=stamp_assertClassBrand(Pc,this,_serializeBitmap).call(this,!1)}}}else{t.stamps.set(stamp_classPrivateFieldGet(dc,this),{area:r,serialized:a});a.bitmap=stamp_assertClassBrand(Pc,this,_serializeBitmap).call(this,!1)}return a}renderAnnotationElement(e){if(this.deleted){e.hide();return null}e.updateEdited({rect:this.getPDFRect(),popup:this.comment});return null}}function _getBitmapFetched(e,t=!1){if(e){stamp_classPrivateFieldSet(lc,this,e.bitmap);if(!t){stamp_classPrivateFieldSet(dc,this,e.id);stamp_classPrivateFieldSet(fc,this,e.isSvg)}e.file&&stamp_classPrivateFieldSet(_c,this,e.file.name);stamp_assertClassBrand(Pc,this,_createCanvas).call(this)}else this.remove()}function _getBitmapDone(){stamp_classPrivateFieldSet(cc,this,null);this._uiManager.enableWaiting(!1);if(stamp_classPrivateFieldGet(pc,this))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&stamp_classPrivateFieldGet(lc,this))this.addEditToolbar().then(()=>{this._editToolbar.hide();this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&stamp_classPrivateFieldGet(lc,this)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}function _getBitmap(){if(stamp_classPrivateFieldGet(dc,this)){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(stamp_classPrivateFieldGet(dc,this)).then(e=>stamp_assertClassBrand(Pc,this,_getBitmapFetched).call(this,e,!0)).finally(()=>stamp_assertClassBrand(Pc,this,_getBitmapDone).call(this));return}if(stamp_classPrivateFieldGet(hc,this)){const e=stamp_classPrivateFieldGet(hc,this);stamp_classPrivateFieldSet(hc,this,null);this._uiManager.enableWaiting(!0);stamp_classPrivateFieldSet(cc,this,this._uiManager.imageManager.getFromUrl(e).then(e=>stamp_assertClassBrand(Pc,this,_getBitmapFetched).call(this,e)).finally(()=>stamp_assertClassBrand(Pc,this,_getBitmapDone).call(this)));return}if(stamp_classPrivateFieldGet(uc,this)){const e=stamp_classPrivateFieldGet(uc,this);stamp_classPrivateFieldSet(uc,this,null);this._uiManager.enableWaiting(!0);stamp_classPrivateFieldSet(cc,this,this._uiManager.imageManager.getFromFile(e).then(e=>stamp_assertClassBrand(Pc,this,_getBitmapFetched).call(this,e)).finally(()=>stamp_assertClassBrand(Pc,this,_getBitmapDone).call(this)));return}const e=document.createElement("input");e.type="file";e.accept=Y.join(",");const t=this._uiManager._signal;stamp_classPrivateFieldSet(cc,this,new Promise(i=>{e.addEventListener("change",async()=>{if(e.files&&0!==e.files.length){this._uiManager.enableWaiting(!0);const t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}});stamp_assertClassBrand(Pc,this,_getBitmapFetched).call(this,t)}else this.remove();i()},{signal:t});e.addEventListener("cancel",()=>{this.remove();i()},{signal:t})}).finally(()=>stamp_assertClassBrand(Pc,this,_getBitmapDone).call(this)));e.click()}function _createCanvas(){const{div:e}=this;let{width:t,height:i}=stamp_classPrivateFieldGet(lc,this);const[a,s]=this.pageDimensions,n=.75;if(this.width){t=this.width*a;i=this.height*s}else if(t>n*a||i>n*s){const e=Math.min(n*a/t,n*s/i);t*=e;i*=e}this._uiManager.enableWaiting(!1);const r=stamp_classPrivateFieldSet(pc,this,document.createElement("canvas"));r.setAttribute("role","img");this.addContainer(r);this.width=t/a;this.height=i/s;this.setDims();this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1);stamp_assertClassBrand(Pc,this,_drawBitmap).call(this);if(!stamp_classPrivateFieldGet(vc,this)){this.parent.addUndoableEditor(this);stamp_classPrivateFieldSet(vc,this,!0)}this._reportTelemetry({action:"inserted_image"});this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"imageAdded",page:this.pageIndex+1,id:this.uid,editorType:this.constructor.name,value:r,width:t,height:i,fileName:stamp_classPrivateFieldGet(_c,this)});stamp_classPrivateFieldGet(_c,this)&&this.div.setAttribute("aria-description",stamp_classPrivateFieldGet(_c,this));this.annotationElementId||this._uiManager.a11yAlert(AnnotationEditor._l10nAlert.stamp)}function _scaleBitmap(e,t){const{width:i,height:a}=stamp_classPrivateFieldGet(lc,this);let s=i,n=a,r=stamp_classPrivateFieldGet(lc,this);for(;s>2*e||n>2*t;){const i=s,a=n;s>2*e&&(s=Math.ceil(s/2));n>2*t&&(n=Math.ceil(n/2));const o=new OffscreenCanvas(s,n);o.getContext("2d").drawImage(r,0,0,i,a,0,0,s,n);r=o.transferToImageBitmap()}return r}function _drawBitmap(){const[e,t]=this.parentDimensions,{width:i,height:a}=this,s=new OutputScale,n=Math.ceil(i*e*s.sx),r=Math.ceil(a*t*s.sy),o=stamp_classPrivateFieldGet(pc,this);if(!o||o.width===n&&o.height===r)return;o.width=n;o.height=r;const l=stamp_classPrivateFieldGet(fc,this)?stamp_classPrivateFieldGet(lc,this):stamp_assertClassBrand(Pc,this,_scaleBitmap).call(this,n,r),d=o.getContext("2d");d.filter=this._uiManager.hcmFilter;d.drawImage(l,0,0,l.width,l.height,0,0,n,r)}function _serializeBitmap(e){if(e){if(stamp_classPrivateFieldGet(fc,this)){const e=this._uiManager.imageManager.getSvgUrl(stamp_classPrivateFieldGet(dc,this));if(e)return e}const e=document.createElement("canvas");({width:e.width,height:e.height}=stamp_classPrivateFieldGet(lc,this));e.getContext("2d").drawImage(stamp_classPrivateFieldGet(lc,this),0,0);return e.toDataURL()}if(stamp_classPrivateFieldGet(fc,this)){const[e,t]=this.pageDimensions,i=Math.round(this.width*e*PixelsPerInch.PDF_TO_CSS_UNITS),a=Math.round(this.height*t*PixelsPerInch.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(i,a);s.getContext("2d").drawImage(stamp_classPrivateFieldGet(lc,this),0,0,stamp_classPrivateFieldGet(lc,this).width,stamp_classPrivateFieldGet(lc,this).height,0,0,i,a);return s.transferToImageBitmap()}return structuredClone(stamp_classPrivateFieldGet(lc,this))}function stamp_hasElementChanged(e){const{pageIndex:t,accessibilityData:{altText:i}}=this._initialData,a=e.pageIndex===t,s=(e.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&a&&s,isSameAltText:s}}stamp_defineProperty(StampEditor,"_type","stamp");stamp_defineProperty(StampEditor,"_editorType",f.STAMP);function annotation_editor_layer_classPrivateFieldInitSpec(e,t,i){annotation_editor_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_editor_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_editor_layer_classPrivateGetter(e,t,i){return i(annotation_editor_layer_assertClassBrand(e,t))}function annotation_editor_layer_classPrivateFieldGet(e,t){return e.get(annotation_editor_layer_assertClassBrand(e,t))}function annotation_editor_layer_classPrivateFieldSet(e,t,i){return e.set(annotation_editor_layer_assertClassBrand(e,t),i),i}function annotation_editor_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var wc=new WeakMap,Fc=new WeakMap,bc=new WeakMap,yc=new WeakMap,Sc=new WeakMap,Cc=new WeakMap,xc=new WeakMap,kc=new WeakMap,Ec=new WeakMap,Ac=new WeakMap,Gc=new WeakMap,Bc=new WeakMap,Mc=new WeakMap,Ic=new WeakMap,Tc=new WeakMap,Dc=new WeakMap,Lc=new WeakSet;class AnnotationEditorLayer{constructor({uiManager:e,pageIndex:t,div:i,structTreeLayer:a,accessibilityManager:s,annotationLayer:n,drawLayer:r,textLayer:o,viewport:l,l10n:d,eventBus:c}){!function annotation_editor_layer_classPrivateMethodInitSpec(e,t){annotation_editor_layer_checkPrivateRedeclaration(e,t),t.add(e)}(this,Lc);annotation_editor_layer_classPrivateFieldInitSpec(this,wc,void 0);annotation_editor_layer_classPrivateFieldInitSpec(this,Fc,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,bc,null);annotation_editor_layer_classPrivateFieldInitSpec(this,yc,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Sc,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Cc,new Map);annotation_editor_layer_classPrivateFieldInitSpec(this,xc,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,kc,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,Ec,!1);annotation_editor_layer_classPrivateFieldInitSpec(this,Ac,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Gc,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Bc,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Mc,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Ic,null);annotation_editor_layer_classPrivateFieldInitSpec(this,Tc,-1);annotation_editor_layer_classPrivateFieldInitSpec(this,Dc,void 0);const h=[...Rc._.values()];if(!AnnotationEditorLayer._initialized){AnnotationEditorLayer._initialized=!0;for(const t of h){t.eventBus=c;t.initialize(d,e)}}e.registerEditorTypes(h);annotation_editor_layer_classPrivateFieldSet(Dc,this,e);this.pageIndex=t;this.div=i;annotation_editor_layer_classPrivateFieldSet(wc,this,s);annotation_editor_layer_classPrivateFieldSet(bc,this,n);this.viewport=l;annotation_editor_layer_classPrivateFieldSet(Bc,this,o);this.drawLayer=r;this._structTree=a;annotation_editor_layer_classPrivateFieldGet(Dc,this).addLayer(this);this.eventBus=c}get isEmpty(){return 0===annotation_editor_layer_classPrivateFieldGet(Cc,this).size}get isInvisible(){return this.isEmpty&&annotation_editor_layer_classPrivateFieldGet(Dc,this).getMode()===f.NONE}updateToolbar(e){annotation_editor_layer_classPrivateFieldGet(Dc,this).updateToolbar(e)}updateMode(e=annotation_editor_layer_classPrivateFieldGet(Dc,this).getMode()){annotation_editor_layer_assertClassBrand(Lc,this,_cleanup).call(this);switch(e){case f.NONE:this.div.classList.toggle("nonEditing",!0);this.disableTextSelection();this.togglePointerEvents(!1);this.toggleAnnotationLayerPointerEvents(!0);this.disableClick();return;case f.INK:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick();break;case f.HIGHLIGHT:this.enableTextSelection();this.togglePointerEvents(!1);this.disableClick();break;default:this.disableTextSelection();this.togglePointerEvents(!0);this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;t.toggle("nonEditing",!1);if(e===f.POPUP)t.toggle("commentEditing",!0);else{t.toggle("commentEditing",!1);for(const i of Rc._.values())t.toggle(`${i._type}Editing`,e===i._editorType)}this.div.hidden=!1}hasTextLayer(e){return e===annotation_editor_layer_classPrivateFieldGet(Bc,this)?.div}setEditingState(e){annotation_editor_layer_classPrivateFieldGet(Dc,this).setEditingState(e)}addCommands(e){annotation_editor_layer_classPrivateFieldGet(Dc,this).addCommands(e)}cleanUndoStack(e){annotation_editor_layer_classPrivateFieldGet(Dc,this).cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){annotation_editor_layer_classPrivateFieldGet(bc,this)?.togglePointerEvents(e)}async enable(){annotation_editor_layer_classPrivateFieldSet(Ec,this,!0);this.div.tabIndex=0;this.togglePointerEvents(!0);this.div.classList.toggle("nonEditing",!1);annotation_editor_layer_classPrivateFieldGet(Ic,this)?.abort();annotation_editor_layer_classPrivateFieldSet(Ic,this,null);const e=new Set;for(const t of annotation_editor_layer_classPrivateGetter(Lc,this,_get_allEditorsIterator)){t.enableEditing();t.show(!0);if(t.annotationElementId){annotation_editor_layer_classPrivateFieldGet(Dc,this).removeChangedExistingAnnotation(t);e.add(t.annotationElementId)}}const t=annotation_editor_layer_classPrivateFieldGet(bc,this);if(t)for(const i of t.getEditableAnnotations()){i.hide();if(annotation_editor_layer_classPrivateFieldGet(Dc,this).isDeletedAnnotationElement(i.data.id))continue;if(e.has(i.data.id))continue;const t=await this.deserialize(i);if(t){this.addOrRebuild(t);t.enableEditing()}}annotation_editor_layer_classPrivateFieldSet(Ec,this,!1);annotation_editor_layer_classPrivateFieldGet(Dc,this)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){annotation_editor_layer_classPrivateFieldSet(kc,this,!0);this.div.tabIndex=-1;this.togglePointerEvents(!1);this.div.classList.toggle("nonEditing",!0);if(annotation_editor_layer_classPrivateFieldGet(Bc,this)&&!annotation_editor_layer_classPrivateFieldGet(Ic,this)){annotation_editor_layer_classPrivateFieldSet(Ic,this,new AbortController);const e=annotation_editor_layer_classPrivateFieldGet(Dc,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(Ic,this));annotation_editor_layer_classPrivateFieldGet(Bc,this).div.addEventListener("pointerdown",e=>{const{clientX:t,clientY:i,timeStamp:a}=e;if(a-annotation_editor_layer_classPrivateFieldGet(Tc,this)>500){annotation_editor_layer_classPrivateFieldSet(Tc,this,a);return}annotation_editor_layer_classPrivateFieldSet(Tc,this,-1);const{classList:s}=this.div;s.toggle("getElements",!0);const n=document.elementsFromPoint(t,i);s.toggle("getElements",!1);if(!this.div.contains(n[0]))return;let r;const o=new RegExp(`^${m}[0-9]+$`);for(const e of n)if(o.test(e.id)){r=e.id;break}if(!r)return;const l=annotation_editor_layer_classPrivateFieldGet(Cc,this).get(r);if(null===l?.annotationElementId){stopEvent(e);l.dblclick(e)}},{signal:e,capture:!0})}const e=annotation_editor_layer_classPrivateFieldGet(bc,this),t=[];if(e){const i=new Map,a=new Map;for(const e of annotation_editor_layer_classPrivateGetter(Lc,this,_get_allEditorsIterator)){e.disableEditing();if(e.annotationElementId)if(null===e.serialize()){a.set(e.annotationElementId,e);this.getEditableAnnotation(e.annotationElementId)?.show();e.remove()}else i.set(e.annotationElementId,e);else t.push(e)}for(const t of e.getEditableAnnotations()){const{id:e}=t.data;if(annotation_editor_layer_classPrivateFieldGet(Dc,this).isDeletedAnnotationElement(e)){t.updateEdited({deleted:!0});continue}let s=a.get(e);if(s){s.resetAnnotationElement(t);s.show(!1);t.show()}else{s=i.get(e);if(s){annotation_editor_layer_classPrivateFieldGet(Dc,this).addChangedExistingAnnotation(s);s.renderAnnotationElement(t)&&s.show(!1)}t.show()}}}annotation_editor_layer_assertClassBrand(Lc,this,_cleanup).call(this);this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const e of Rc._.values())i.remove(`${e._type}Editing`);this.disableTextSelection();this.toggleAnnotationLayerPointerEvents(!0);e?.updateFakeAnnotations(t);annotation_editor_layer_classPrivateFieldSet(kc,this,!1)}getEditableAnnotation(e){return annotation_editor_layer_classPrivateFieldGet(bc,this)?.getEditableAnnotation(e)||null}setActiveEditor(e){annotation_editor_layer_classPrivateFieldGet(Dc,this).getActive()!==e&&annotation_editor_layer_classPrivateFieldGet(Dc,this).setActiveEditor(e)}enableTextSelection(){this.div.tabIndex=-1;if(annotation_editor_layer_classPrivateFieldGet(Bc,this)?.div&&!annotation_editor_layer_classPrivateFieldGet(Mc,this)){annotation_editor_layer_classPrivateFieldSet(Mc,this,new AbortController);const e=annotation_editor_layer_classPrivateFieldGet(Dc,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(Mc,this));annotation_editor_layer_classPrivateFieldGet(Bc,this).div.addEventListener("pointerdown",annotation_editor_layer_assertClassBrand(Lc,this,_textLayerPointerDown).bind(this),{signal:e});annotation_editor_layer_classPrivateFieldGet(Bc,this).div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0;if(annotation_editor_layer_classPrivateFieldGet(Bc,this)?.div&&annotation_editor_layer_classPrivateFieldGet(Mc,this)){annotation_editor_layer_classPrivateFieldGet(Mc,this).abort();annotation_editor_layer_classPrivateFieldSet(Mc,this,null);annotation_editor_layer_classPrivateFieldGet(Bc,this).div.classList.remove("highlighting")}}enableClick(){if(annotation_editor_layer_classPrivateFieldGet(yc,this))return;annotation_editor_layer_classPrivateFieldSet(yc,this,new AbortController);const e=annotation_editor_layer_classPrivateFieldGet(Dc,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(yc,this));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e});this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){annotation_editor_layer_classPrivateFieldGet(yc,this)?.abort();annotation_editor_layer_classPrivateFieldSet(yc,this,null)}attach(e){annotation_editor_layer_classPrivateFieldGet(Cc,this).set(e.id,e);const{annotationElementId:t}=e;t&&annotation_editor_layer_classPrivateFieldGet(Dc,this).isDeletedAnnotationElement(t)&&annotation_editor_layer_classPrivateFieldGet(Dc,this).removeDeletedAnnotationElement(e)}detach(e){annotation_editor_layer_classPrivateFieldGet(Cc,this).delete(e.id);annotation_editor_layer_classPrivateFieldGet(wc,this)?.removePointerInTextLayer(e.contentDiv);!annotation_editor_layer_classPrivateFieldGet(kc,this)&&e.annotationElementId&&annotation_editor_layer_classPrivateFieldGet(Dc,this).addDeletedAnnotationElement(e)}remove(e){this.detach(e);annotation_editor_layer_classPrivateFieldGet(Dc,this).removeEditor(e);e.div.remove();e.isAttachedToDOM=!1}changeParent(e){if(e.parent!==this){if(e.parent&&e.annotationElementId){annotation_editor_layer_classPrivateFieldGet(Dc,this).addDeletedAnnotationElement(e);AnnotationEditor.deleteAnnotationElement(e);e.annotationElementId=null}this.attach(e);e.parent?.detach(e);e.setParent(this);if(e.div&&e.isAttachedToDOM){e.div.remove();this.div.append(e.div)}}}add(e){if(e.parent!==this||!e.isAttachedToDOM){this.changeParent(e);annotation_editor_layer_classPrivateFieldGet(Dc,this).addEditor(e);this.attach(e);if(!e.isAttachedToDOM){const t=e.render();this.div.append(t);e.isAttachedToDOM=!0}e.fixAndSetPosition();e.onceAdded(!annotation_editor_layer_classPrivateFieldGet(Ec,this)&&!annotation_editor_layer_classPrivateFieldGet(Dc,this).isRestoringAnnotations);annotation_editor_layer_classPrivateFieldGet(Dc,this).addToAnnotationStorage(e);e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;const{activeElement:t}=document;if(e.div.contains(t)&&!annotation_editor_layer_classPrivateFieldGet(Sc,this)){e._focusEventsAllowed=!1;annotation_editor_layer_classPrivateFieldSet(Sc,this,setTimeout(()=>{annotation_editor_layer_classPrivateFieldSet(Sc,this,null);if(e.div.contains(document.activeElement))e._focusEventsAllowed=!0;else{e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:annotation_editor_layer_classPrivateFieldGet(Dc,this)._signal});t.focus()}},0))}e._structTreeParentId=annotation_editor_layer_classPrivateFieldGet(wc,this)?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){if(e.needsToBeRebuilt()){e.parent||=this;e.rebuild();e.show()}else this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getEditorByUID(e){for(const t of annotation_editor_layer_classPrivateFieldGet(Cc,this).values())if(t.uid===e)return t;return null}combinedSignal(e){return annotation_editor_layer_classPrivateFieldGet(Dc,this).combinedSignal(e)}canCreateNewEmptyEditor(){return annotation_editor_layer_classPrivateGetter(Lc,this,_get_currentEditorType)?.canCreateNewEmptyEditor()}async pasteEditor(e,t){this.updateToolbar(e);await annotation_editor_layer_classPrivateFieldGet(Dc,this).updateMode(e.mode);const{offsetX:i,offsetY:a}=annotation_editor_layer_assertClassBrand(Lc,this,_getCenterPoint).call(this),s=annotation_editor_layer_classPrivateFieldGet(Dc,this).getId(),n=annotation_editor_layer_assertClassBrand(Lc,this,_createNewEditor).call(this,{parent:this,id:s,x:i,y:a,uiManager:annotation_editor_layer_classPrivateFieldGet(Dc,this),isCentered:!0,...t});n&&this.add(n)}async deserialize(e){return await(Rc._.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,annotation_editor_layer_classPrivateFieldGet(Dc,this)))||null}createAndAddNewEditor(e,t,i={}){const a=annotation_editor_layer_classPrivateFieldGet(Dc,this).getId(),s=annotation_editor_layer_assertClassBrand(Lc,this,_createNewEditor).call(this,{parent:this,id:a,x:e.offsetX,y:e.offsetY,uiManager:annotation_editor_layer_classPrivateFieldGet(Dc,this),isCentered:t,eventBus:this.eventBus,...i});s&&this.add(s);return s}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(e={}){this.createAndAddNewEditor(annotation_editor_layer_assertClassBrand(Lc,this,_getCenterPoint).call(this),!0,e)}setSelected(e){annotation_editor_layer_classPrivateFieldGet(Dc,this).setSelected(e)}toggleSelected(e){annotation_editor_layer_classPrivateFieldGet(Dc,this).toggleSelected(e)}unselect(e){annotation_editor_layer_classPrivateFieldGet(Dc,this).unselect(e)}pointerup(e){const{isMac:t}=FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(!annotation_editor_layer_classPrivateFieldGet(xc,this))return;annotation_editor_layer_classPrivateFieldSet(xc,this,!1);if(annotation_editor_layer_classPrivateGetter(Lc,this,_get_currentEditorType)?.isDrawer&&annotation_editor_layer_classPrivateGetter(Lc,this,_get_currentEditorType).supportMultipleDrawings)return;if(!annotation_editor_layer_classPrivateFieldGet(Fc,this)){annotation_editor_layer_classPrivateFieldSet(Fc,this,!0);return}const i=annotation_editor_layer_classPrivateFieldGet(Dc,this).getMode();i!==f.STAMP&&i!==f.POPUP&&i!==f.SIGNATURE?this.createAndAddNewEditor(e,!1):annotation_editor_layer_classPrivateFieldGet(Dc,this).unselectAll()}pointerdown(e){const{pointerType:t}=e,i=annotation_editor_layer_classPrivateFieldGet(Dc,this).currentPointers;if(annotation_editor_layer_classPrivateFieldGet(Dc,this).getMode()===f.HIGHLIGHT){if(i.isInitializedAndDifferentPointerType(t))return;i.setPointerTypeIfUnset(t);this.enableTextSelection()}else if(annotation_editor_layer_classPrivateFieldGet(Dc,this).getMode()===f.INK&&i.isInitializedAndDifferentPointerType(t))return;if(annotation_editor_layer_classPrivateFieldGet(xc,this)){annotation_editor_layer_classPrivateFieldSet(xc,this,!1);return}const{isMac:a}=FeatureTest.platform;if(0!==e.button||e.ctrlKey&&a)return;if(e.target!==this.div)return;annotation_editor_layer_classPrivateFieldSet(xc,this,!0);if(annotation_editor_layer_classPrivateGetter(Lc,this,_get_currentEditorType)?.isDrawer){this.startDrawingSession(e);return}const s=annotation_editor_layer_classPrivateFieldGet(Dc,this).getActive();annotation_editor_layer_classPrivateFieldSet(Fc,this,!s||s.isEmpty())}startDrawingSession(e){this.div.focus({preventScroll:!0});if(annotation_editor_layer_classPrivateFieldGet(Ac,this)){annotation_editor_layer_classPrivateGetter(Lc,this,_get_currentEditorType).startDrawing(this,annotation_editor_layer_classPrivateFieldGet(Dc,this),!1,e);return}annotation_editor_layer_classPrivateFieldGet(Dc,this).setCurrentDrawingSession(this);annotation_editor_layer_classPrivateFieldSet(Ac,this,new AbortController);const t=annotation_editor_layer_classPrivateFieldGet(Dc,this).combinedSignal(annotation_editor_layer_classPrivateFieldGet(Ac,this));this.div.addEventListener("blur",({relatedTarget:e})=>{if(e&&!this.div.contains(e)){annotation_editor_layer_classPrivateFieldSet(Gc,this,null);this.commitOrRemove()}},{signal:t});annotation_editor_layer_classPrivateGetter(Lc,this,_get_currentEditorType).startDrawing(this,annotation_editor_layer_classPrivateFieldGet(Dc,this),!1,e)}pause(e){if(e){const{activeElement:e}=document;this.div.contains(e)&&annotation_editor_layer_classPrivateFieldSet(Gc,this,e);return}annotation_editor_layer_classPrivateFieldGet(Gc,this)&&setTimeout(()=>{annotation_editor_layer_classPrivateFieldGet(Gc,this)?.focus();annotation_editor_layer_classPrivateFieldSet(Gc,this,null)},0)}endDrawingSession(e=!1){if(!annotation_editor_layer_classPrivateFieldGet(Ac,this))return null;annotation_editor_layer_classPrivateFieldGet(Dc,this).setCurrentDrawingSession(null);annotation_editor_layer_classPrivateFieldGet(Ac,this).abort();annotation_editor_layer_classPrivateFieldSet(Ac,this,null);annotation_editor_layer_classPrivateFieldSet(Gc,this,null);return annotation_editor_layer_classPrivateGetter(Lc,this,_get_currentEditorType).endDrawing(e)}findNewParent(e,t,i){const a=annotation_editor_layer_classPrivateFieldGet(Dc,this).findParent(t,i);if(null===a||a===this)return!1;a.changeParent(e);return!0}commitOrRemove(){if(annotation_editor_layer_classPrivateFieldGet(Ac,this)){this.endDrawingSession();return!0}return!1}onScaleChanging(){annotation_editor_layer_classPrivateFieldGet(Ac,this)&&annotation_editor_layer_classPrivateGetter(Lc,this,_get_currentEditorType).onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove();if(annotation_editor_layer_classPrivateFieldGet(Dc,this).getActive()?.parent===this){annotation_editor_layer_classPrivateFieldGet(Dc,this).commitOrRemove();annotation_editor_layer_classPrivateFieldGet(Dc,this).setActiveEditor(null)}if(annotation_editor_layer_classPrivateFieldGet(Sc,this)){clearTimeout(annotation_editor_layer_classPrivateFieldGet(Sc,this));annotation_editor_layer_classPrivateFieldSet(Sc,this,null)}for(const e of annotation_editor_layer_classPrivateFieldGet(Cc,this).values()){annotation_editor_layer_classPrivateFieldGet(wc,this)?.removePointerInTextLayer(e.contentDiv);e.setParent(null);e.isAttachedToDOM=!1;e.div.remove()}this.div=null;annotation_editor_layer_classPrivateFieldGet(Cc,this).clear();annotation_editor_layer_classPrivateFieldGet(Dc,this).removeLayer(this)}async render({viewport:e}){this.viewport=e;setLayerDimensions(this.div,e);for(const e of annotation_editor_layer_classPrivateFieldGet(Dc,this).getEditors(this.pageIndex)){this.add(e);e.rebuild()}await annotation_editor_layer_classPrivateFieldGet(Dc,this).findClonesForPage(this);this.div.hidden=this.isEmpty;this.updateMode()}update({viewport:e}){annotation_editor_layer_classPrivateFieldGet(Dc,this).commitOrRemove();annotation_editor_layer_assertClassBrand(Lc,this,_cleanup).call(this);const t=this.viewport.rotation,i=e.rotation;this.viewport=e;setLayerDimensions(this.div,{rotation:i});if(t!==i)for(const e of annotation_editor_layer_classPrivateFieldGet(Cc,this).values())e.rotate(i)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return annotation_editor_layer_classPrivateFieldGet(Dc,this).viewParameters.realScale}}function _get_allEditorsIterator(e){return 0!==annotation_editor_layer_classPrivateFieldGet(Cc,e).size?annotation_editor_layer_classPrivateFieldGet(Cc,e).values():annotation_editor_layer_classPrivateFieldGet(Dc,e).getEditors(e.pageIndex)}function _textLayerPointerDown(e){annotation_editor_layer_classPrivateFieldGet(Dc,this).unselectAll();const{target:t}=e;if(t===annotation_editor_layer_classPrivateFieldGet(Bc,this).div||("img"===t.getAttribute("role")||t.classList.contains("endOfContent")||t.classList.contains("textLayerImages")||t.classList.contains("textLayerImagePlaceholder"))&&annotation_editor_layer_classPrivateFieldGet(Bc,this).div.contains(t)){const{isMac:t}=FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t)return;annotation_editor_layer_classPrivateFieldGet(Dc,this).showAllEditors("highlight",!0,!0);annotation_editor_layer_classPrivateFieldGet(Bc,this).div.classList.add("free");this.toggleDrawing();this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"drawingStarted",editorType:"HighlightEditor"});HighlightEditor.startHighlighting(this,"ltr"===annotation_editor_layer_classPrivateFieldGet(Dc,this).direction,{target:annotation_editor_layer_classPrivateFieldGet(Bc,this).div,x:e.x,y:e.y});annotation_editor_layer_classPrivateFieldGet(Bc,this).div.addEventListener("pointerup",()=>{annotation_editor_layer_classPrivateFieldGet(Bc,this).div.classList.remove("free");this.toggleDrawing(!0);this.eventBus?.dispatch("annotation-editor-event",{source:this,type:"drawingStopped",editorType:"HighlightEditor"})},{once:!0,signal:annotation_editor_layer_classPrivateFieldGet(Dc,this)._signal});e.preventDefault()}}function _get_currentEditorType(e){return Rc._.get(annotation_editor_layer_classPrivateFieldGet(Dc,e).getMode())}function _createNewEditor(e){const t=annotation_editor_layer_classPrivateGetter(Lc,this,_get_currentEditorType);return t?new t.prototype.constructor(e):null}function _getCenterPoint(){const{x:e,y:t,width:i,height:a}=this.boundingClientRect,s=Math.max(0,e),n=Math.max(0,t),r=(s+Math.min(window.innerWidth,e+i))/2-e,o=(n+Math.min(window.innerHeight,t+a))/2-t,[l,d]=this.viewport.rotation%180==0?[r,o]:[o,r];return{offsetX:l,offsetY:d}}function _cleanup(){for(const e of annotation_editor_layer_classPrivateFieldGet(Cc,this).values())e.isEmpty()&&e.remove()}!function annotation_editor_layer_defineProperty(e,t,i){return(t=function annotation_editor_layer_toPropertyKey(e){var t=function annotation_editor_layer_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}(AnnotationEditorLayer,"_initialized",!1);var Nc,Rc={_:new Map([FreeTextEditor,InkEditor,StampEditor,HighlightEditor,SignatureEditor].map(e=>[e._editorType,e]))};function draw_layer_classPrivateFieldInitSpec(e,t,i){draw_layer_checkPrivateRedeclaration(e,t),t.set(e,i)}function draw_layer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function draw_layer_classPrivateFieldGet(e,t){return e.get(draw_layer_assertClassBrand(e,t))}function draw_layer_classPrivateFieldSet(e,t,i){return e.set(draw_layer_assertClassBrand(e,t),i),i}function draw_layer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function compareTextLayers(e,t){return e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function getTextLayer(e){return e?e.nodeType===Node.ELEMENT_NODE?e.closest(".textLayer"):e.parentElement?.closest(".textLayer")||null:null}function isPointBefore(e,t,i,a){if(e===i)return t<=a;const s=e.compareDocumentPosition(i);return!!(s&Node.DOCUMENT_POSITION_FOLLOWING)||!(s&Node.DOCUMENT_POSITION_PRECEDING)&&null}function normalizeEdgeBoundary(e,t,i){if(e.nodeType!==Node.ELEMENT_NODE||!e.classList.contains("textLayer")||t!==e.childNodes.length)return{container:e,offset:t};let a=e.lastChild;a?.nodeType===Node.ELEMENT_NODE&&a.classList.contains("endOfContent")&&(a=a.previousSibling);return a&&i.contains(a)?a.nodeType===Node.TEXT_NODE?{container:a,offset:a.textContent.length}:{container:a,offset:a.childNodes.length}:null}var Oc=new WeakMap,Wc=new WeakMap,jc=new WeakMap,Vc=new WeakMap,Uc=new WeakMap,zc=new WeakMap,Hc=new WeakMap,$c=new WeakSet;class DrawLayer{constructor({filterFactory:e=null,pageColors:t=null,pageIndex:i,textLayer:a=null}){!function draw_layer_classPrivateMethodInitSpec(e,t){draw_layer_checkPrivateRedeclaration(e,t),t.add(e)}(this,$c);draw_layer_classPrivateFieldInitSpec(this,Oc,null);draw_layer_classPrivateFieldInitSpec(this,Wc,new Map);draw_layer_classPrivateFieldInitSpec(this,jc,null);draw_layer_classPrivateFieldInitSpec(this,Vc,null);draw_layer_classPrivateFieldInitSpec(this,Uc,null);draw_layer_classPrivateFieldInitSpec(this,zc,null);draw_layer_classPrivateFieldInitSpec(this,Hc,new Map);this.pageIndex=i;draw_layer_classPrivateFieldSet(Vc,this,e);draw_layer_classPrivateFieldSet(Uc,this,t);if(a){const e=Jc._.get(a);if(e?.selectionDiv){e.selectionDiv.remove();Yc._.delete(e.selectionDiv)}Jc._.set(a,{drawLayer:this});Qc._.add(a);draw_layer_classPrivateFieldSet(jc,this,a);draw_layer_classPrivateFieldSet(zc,this,new MutationObserver(e=>{if(draw_layer_classPrivateFieldGet(Oc,this)&&draw_layer_classPrivateFieldGet(jc,this)?.isConnected&&_hasSelection.call(DrawLayer))for(const{addedNodes:t}of e)for(const e of t)if(e.nodeType===Node.ELEMENT_NODE&&e.classList.contains("endOfContent")){draw_layer_selectionChange.call(DrawLayer);return}}));draw_layer_classPrivateFieldGet(zc,this).observe(a,{childList:!0});if(null===qc._){qc._=new AbortController;const{signal:e}=qc._;document.addEventListener("selectionchange",draw_layer_selectionChange.bind(DrawLayer),{signal:e});document.addEventListener("pointerdown",()=>{Zc._=!0},{signal:e});document.addEventListener("pointerup",()=>{Zc._=!1},{signal:e});window.addEventListener("blur",()=>{Zc._=!1},{signal:e})}}}setParent(e){if(draw_layer_classPrivateFieldGet(Oc,this)){if(draw_layer_classPrivateFieldGet(Oc,this)!==e){if(draw_layer_classPrivateFieldGet(Wc,this).size>0)for(const t of draw_layer_classPrivateFieldGet(Wc,this).values()){t.remove();e.append(t)}draw_layer_classPrivateFieldSet(Oc,this,e)}}else{draw_layer_classPrivateFieldSet(Oc,this,e);draw_layer_classPrivateFieldGet(jc,this)?.isConnected&&_hasSelection.call(DrawLayer)&&draw_layer_selectionChange.call(DrawLayer)}}static get _svgFactory(){return shadow(this,"_svgFactory",new DOMSVGFactory)}draw(e,t=!1,i=!1){var a,s;const n=(Kc._=(a=Kc._,s=a++,a),s),r=draw_layer_assertClassBrand($c,this,_createSVG).call(this),o=DrawLayer._svgFactory.createElement("defs");r.append(o);const l=DrawLayer._svgFactory.createElement("path");o.append(l);const d=`path_${n}`;l.setAttribute("id",d);l.setAttribute("vector-effect","non-scaling-stroke");t&&draw_layer_classPrivateFieldGet(Hc,this).set(n,l);const c=i?draw_layer_assertClassBrand($c,this,_createClipPath).call(this,o,d):null,h=DrawLayer._svgFactory.createElement("use");r.append(h);h.setAttribute("href",`#${d}`);this.updateProperties(r,e);draw_layer_classPrivateFieldGet(Wc,this).set(n,r);return{id:n,clipPathId:`url(#${c})`}}drawOutline(e,t){var i,a;const s=(Kc._=(i=Kc._,a=i++,i),a),n=draw_layer_assertClassBrand($c,this,_createSVG).call(this),r=DrawLayer._svgFactory.createElement("defs");n.append(r);const o=DrawLayer._svgFactory.createElement("path");r.append(o);const l=`path_${s}`;o.setAttribute("id",l);o.setAttribute("vector-effect","non-scaling-stroke");let d;if(t){const e=DrawLayer._svgFactory.createElement("mask");r.append(e);d=`mask_${s}`;e.setAttribute("id",d);e.setAttribute("maskUnits","objectBoundingBox");const t=DrawLayer._svgFactory.createElement("rect");e.append(t);t.setAttribute("width","1");t.setAttribute("height","1");t.setAttribute("fill","white");const i=DrawLayer._svgFactory.createElement("use");e.append(i);i.setAttribute("href",`#${l}`);i.setAttribute("stroke","none");i.setAttribute("fill","black");i.setAttribute("fill-rule","nonzero");i.classList.add("mask")}const c=DrawLayer._svgFactory.createElement("use");n.append(c);c.setAttribute("href",`#${l}`);d&&c.setAttribute("mask",`url(#${d})`);const h=c.cloneNode();n.append(h);c.classList.add("mainOutline");h.classList.add("secondaryOutline");this.updateProperties(n,e);draw_layer_classPrivateFieldGet(Wc,this).set(s,n);return s}finalizeDraw(e,t){draw_layer_classPrivateFieldGet(Hc,this).delete(e);this.updateProperties(e,t)}updateProperties(e,t){if(!t)return;const{root:i,bbox:a,rootClass:s,path:n}=t,r="number"==typeof e?draw_layer_classPrivateFieldGet(Wc,this).get(e):e;if(r){i&&draw_layer_assertClassBrand($c,this,_updateProperties).call(this,r,i);a&&_setBox.call(DrawLayer,r,a);if(s){const{classList:e}=r;for(const[t,i]of Object.entries(s))e.toggle(t,i)}if(n){const e=r.firstElementChild.firstElementChild;draw_layer_assertClassBrand($c,this,_updateProperties).call(this,e,n)}}}updateParent(e,t){if(t===this)return;const i=draw_layer_classPrivateFieldGet(Wc,this).get(e);if(i){draw_layer_classPrivateFieldGet(Oc,t).append(i);draw_layer_classPrivateFieldGet(Wc,this).delete(e);draw_layer_classPrivateFieldGet(Wc,t).set(e,i)}}remove(e){draw_layer_classPrivateFieldGet(Hc,this).delete(e);if(null!==draw_layer_classPrivateFieldGet(Oc,this)){draw_layer_classPrivateFieldGet(Wc,this).get(e).remove();draw_layer_classPrivateFieldGet(Wc,this).delete(e)}}destroy(){draw_layer_classPrivateFieldSet(Oc,this,null);for(const e of draw_layer_classPrivateFieldGet(Wc,this).values())e.remove();draw_layer_classPrivateFieldGet(Wc,this).clear();draw_layer_classPrivateFieldGet(Hc,this).clear();draw_layer_classPrivateFieldGet(zc,this)?.disconnect();draw_layer_classPrivateFieldSet(zc,this,null);if(draw_layer_classPrivateFieldGet(jc,this)){const e=Jc._.get(draw_layer_classPrivateFieldGet(jc,this));if(e?.drawLayer===this){_cleanupTextLayerSelection.call(DrawLayer,draw_layer_classPrivateFieldGet(jc,this));Jc._.delete(draw_layer_classPrivateFieldGet(jc,this));Qc._.delete(draw_layer_classPrivateFieldGet(jc,this));if(0===Qc._.size){qc._?.abort();qc._=null;Zc._=!1}}draw_layer_classPrivateFieldSet(jc,this,null)}}}Nc=DrawLayer;function _cleanupTextLayerSelection(e){const t=draw_layer_assertClassBrand(Nc,this,Jc)._.get(e);if(t?.selectionDiv){t.selectionDiv.remove();draw_layer_assertClassBrand(Nc,this,Yc)._.delete(t.selectionDiv);t.selectionDiv=null;t.path=null}}function _hasSelection(){const e=document.getSelection();return!!e&&!e.isCollapsed}function _getOrderedTextLayers(){return draw_layer_assertClassBrand(Nc,this,Qc)._.keys().filter(e=>e.isConnected).toArray().sort(compareTextLayers)}function draw_layer_selectionChange(){const e=document.getSelection();if(!e||e.isCollapsed){for(const e of draw_layer_assertClassBrand(Nc,this,Yc)._)e.remove();draw_layer_assertClassBrand(Nc,this,Yc)._.clear();return}const t=new WeakMap,i=draw_layer_assertClassBrand(Nc,this,_getOrderedTextLayers).call(this),a=[];for(let t=0,s=e.rangeCount;t<s;t++){const s=e.getRangeAt(t);if(s.collapsed)continue;let{startContainer:n,startOffset:r,endContainer:o,endOffset:l}=s,d=getTextLayer(n),c=getTextLayer(o);const h=null===d,u=null===c;if(draw_layer_assertClassBrand(Nc,this,Zc)._&&h!==u)return;if(1===e.rangeCount){const{anchorNode:t,anchorOffset:i,focusNode:a,focusOffset:s}=e,h=getTextLayer(t),u=getTextLayer(a),_=isPointBefore(t,i,a,s);if(h&&u&&null!==_)if(_){n=t;r=i;d=h;o=a;l=s;c=u}else{n=a;r=s;d=u;o=t;l=i;c=h}}const _=i.filter(e=>s.intersectsNode(e));if(0===_.length)continue;let p=!1;if(!d){d=_[0];n=d;r=0;p=!0}if(!c){c=_.at(-1);o=c;l=c.childNodes.length;p=!0}if(o.nodeType===Node.ELEMENT_NODE)if(o.classList.contains("endOfContent")){const e=o.previousSibling;if(!e)continue;o=e;l=e.nodeType===Node.TEXT_NODE?e.textContent.length:e.childNodes.length}else if(o.classList.contains("textLayer")&&o.childNodes.length===l){const e=normalizeEdgeBoundary(o,l,c);if(!e)continue;o=e.container;l=e.offset}if(n.nodeType===Node.ELEMENT_NODE){const e=normalizeEdgeBoundary(n,r,d);if(!e)continue;n=e.container;r=e.offset}if(d!==c||p||!_.includes(d))for(const e of _){const t=e.firstChild;if(!t)continue;const i=document.createRange();e===d?i.setStart(n,r):i.setStartBefore(t);if(e===c)i.setEnd(o,l);else{const t=e.lastChild;if(!t)continue;if(t.nodeType===Node.ELEMENT_NODE&&t.classList.contains("endOfContent")){const e=t.previousSibling;if(!e)continue;i.setEndAfter(e)}else i.setEndAfter(t)}i.collapsed||a.push([i,e])}else a.push([s,d])}const s=new Set(a.map(e=>e[1]));for(const e of draw_layer_assertClassBrand(Nc,this,Qc)._)s.has(e)||draw_layer_assertClassBrand(Nc,this,_cleanupTextLayerSelection).call(this,e);for(const[e,i]of a){const a=Jc._.get(i);if(!a)continue;let s=t.get(i);if(!s){const e=i.getBoundingClientRect();s=(t,i,a,s)=>({x:(t-e.x)/e.width,y:(i-e.y)/e.height,width:a/e.width,height:s/e.height});t.set(i,s)}const o=[];for(let{x:t,y:i,width:a,height:n}of e.getClientRects())if(0!==a&&0!==n){({x:t,y:i,width:a,height:n}=s(t,i,a,n));1===a&&1===n||o.push(`M${t} ${i} h${a} v${n} h-${a} Z`)}if(0===o.length)continue;const l=a.drawLayer;let d=a.selectionDiv,c=a.path;if(!d){var n,r;const e=`clip_selection_${Xc._=(n=Xc._,r=n++,n),r}`;d=document.createElement("div");d.className="selection";d.style.clipPath=`url(#${e})`;const t=draw_layer_classPrivateFieldGet(Vc,l)?.createSelectionStyle(draw_layer_classPrivateFieldGet(Uc,l));if(t)for(const[e,i]of Object.entries(t))d.style.setProperty(e,i);const i=Nc._svgFactory.create(1,1,!0);i.setAttribute("aria-hidden","true");i.setAttribute("width","100%");i.setAttribute("height","100%");const s=Nc._svgFactory.createElement("clipPath");s.setAttribute("id",e);s.setAttribute("clipPathUnits","objectBoundingBox");c=Nc._svgFactory.createElement("path");s.append(c);i.append(s);d.append(i);a.path=c;a.selectionDiv=d}if(!d.parentNode&&draw_layer_classPrivateFieldGet(Oc,l)){draw_layer_classPrivateFieldGet(Oc,l).append(d);draw_layer_assertClassBrand(Nc,this,Yc)._.add(d)}c.setAttribute("d",o.join(" "))}}function _setBox(e,[t,i,a,s]){const{style:n}=e;n.top=100*i+"%";n.left=100*t+"%";n.width=100*a+"%";n.height=100*s+"%"}function _createSVG(){const e=Nc._svgFactory.create(1,1,!0);draw_layer_classPrivateFieldGet(Oc,this).append(e);e.setAttribute("aria-hidden","true");return e}function _createClipPath(e,t){const i=Nc._svgFactory.createElement("clipPath");e.append(i);const a=`clip_${t}`;i.setAttribute("id",a);i.setAttribute("clipPathUnits","objectBoundingBox");const s=Nc._svgFactory.createElement("use");i.append(s);s.setAttribute("href",`#${t}`);s.classList.add("clip");return a}function _updateProperties(e,t){for(const[i,a]of Object.entries(t))null===a?e.removeAttribute(i):e.setAttribute(i,a)}var Kc={_:0},Xc={_:0},qc={_:null},Yc={_:new Set},Zc={_:!1},Qc={_:new Set},Jc={_:new WeakMap};function text_layer_images_classPrivateFieldInitSpec(e,t,i){text_layer_images_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_layer_images_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_layer_images_classPrivateFieldGet(e,t){return e.get(text_layer_images_assertClassBrand(e,t))}function text_layer_images_classPrivateFieldSet(e,t,i){return e.set(text_layer_images_assertClassBrand(e,t),i),i}function text_layer_images_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function percentage(e){return`${(100*e).toFixed(2)}%`}var eh=new WeakMap,th=new WeakMap,ih=new WeakMap,ah=new WeakMap,sh=new WeakMap,nh=new WeakMap,rh=new WeakSet;class TextLayerImages{constructor(e,t,i,a){!function text_layer_images_classPrivateMethodInitSpec(e,t){text_layer_images_checkPrivateRedeclaration(e,t),t.add(e)}(this,rh);text_layer_images_classPrivateFieldInitSpec(this,eh,[]);text_layer_images_classPrivateFieldInitSpec(this,th,new Map);text_layer_images_classPrivateFieldInitSpec(this,ih,null);text_layer_images_classPrivateFieldInitSpec(this,ah,0);text_layer_images_classPrivateFieldInitSpec(this,sh,0);text_layer_images_classPrivateFieldInitSpec(this,nh,0);text_layer_images_classPrivateFieldSet(ah,this,e);text_layer_images_classPrivateFieldSet(eh,this,t);text_layer_images_classPrivateFieldSet(sh,this,i.rawDims.pageWidth);text_layer_images_classPrivateFieldSet(nh,this,i.rawDims.pageHeight);text_layer_images_classPrivateFieldSet(ih,this,a)}render(){const e=document.createElement("div");e.className="textLayerImages";for(let t=0;t<text_layer_images_classPrivateFieldGet(eh,this).length;t+=6){const i=text_layer_images_assertClassBrand(rh,this,_createImagePlaceholder).call(this,text_layer_images_classPrivateFieldGet(eh,this).subarray(t,t+6));i&&e.append(i)}e.addEventListener("contextmenu",e=>{if(!(e.target instanceof HTMLCanvasElement))return;const t=e.target,i=text_layer_images_classPrivateFieldGet(th,this).get(t);if(!i)return;const a=oh._?.deref();if(a===t)return;if(a){a.width=0;a.height=0}oh._=new WeakRef(t);const{inverseTransform:s,x1:n,y1:r,width:o,height:l}=i,d=text_layer_images_classPrivateFieldGet(ih,this).call(this),c=Math.ceil(n*d.width),h=Math.ceil(r*d.height),u=Math.floor((n+o/text_layer_images_classPrivateFieldGet(sh,this))*d.width),_=Math.floor((r+l/text_layer_images_classPrivateFieldGet(nh,this))*d.height);t.width=u-c;t.height=_-h;const p=t.getContext("2d");p.setTransform(...s);p.translate(-c,-h);p.drawImage(d,0,0)});return e}}function _createImagePlaceholder([e,t,i,a,s,n]){const r=Math.hypot((s-e)*text_layer_images_classPrivateFieldGet(sh,this),(n-t)*text_layer_images_classPrivateFieldGet(nh,this)),o=Math.hypot((i-e)*text_layer_images_classPrivateFieldGet(sh,this),(a-t)*text_layer_images_classPrivateFieldGet(nh,this));if(r<text_layer_images_classPrivateFieldGet(ah,this)||o<text_layer_images_classPrivateFieldGet(ah,this))return null;const l=[(s-e)*text_layer_images_classPrivateFieldGet(sh,this)/r,(n-t)*text_layer_images_classPrivateFieldGet(nh,this)/r,(i-e)*text_layer_images_classPrivateFieldGet(sh,this)/o,(a-t)*text_layer_images_classPrivateFieldGet(nh,this)/o,0,0],d=Util.inverseTransform(l),c=document.createElement("canvas");c.className="textLayerImagePlaceholder";c.width=0;c.height=0;Object.assign(c.style,{opacity:0,position:"absolute",left:percentage(e),top:percentage(t),width:percentage(r/text_layer_images_classPrivateFieldGet(sh,this)),height:percentage(o/text_layer_images_classPrivateFieldGet(nh,this)),transformOrigin:"0% 0%",transform:`matrix(${l.join(",")})`});text_layer_images_classPrivateFieldGet(th,this).set(c,{inverseTransform:d,width:r,height:o,x1:e,y1:t});return c}var oh={_:null};globalThis._pdfjsTestingUtils={HighlightOutliner};globalThis.pdfjsLib={AbortException,AnnotationEditorLayer,AnnotationEditorParamsType:v,AnnotationEditorType:f,AnnotationEditorUIManager,AnnotationLayer,AnnotationMode:p,AnnotationType:k,applyOpacity,build:qr,ColorPicker,createValidAbsoluteUrl,CSSConstants,DOMSVGFactory,DrawLayer,FeatureTest,fetchData,findContrastColor,getDocument,getFilenameFromUrl:function getFilenameFromUrl(e){[e]=e.split(/[#?]/,1);return stripPath(e)},getPdfFilenameFromUrl,getRGB,getRGBA,getUuid,GlobalWorkerOptions,ImageKind:x,InvalidPDFException,isDataScheme,isPdfFile,isValidExplicitDest:as,makeArr,makeMap,makeObj,makeSet:()=>new Set,MathClamp,noContextMenu,normalizeUnicode,OPS:T,OutputScale,PasswordException,PasswordResponses:W,PDFDataRangeTransport,PDFDateString,PDFWorker,PermissionFlag:P,PixelsPerInch,RenderingCancelledException,renderRichText,ResponseException,setLayerDimensions,shadow,SignatureExtractor,stopEvent,SupportedImageMimeTypes:Y,TextLayer,TextLayerImages,TouchManager,updateUrlHash,Util,VerbosityLevel:I,version:Xr,XfaLayer};function ui_utils_classPrivateFieldInitSpec(e,t,i){(function ui_utils_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function ui_utils_classPrivateFieldGet(e,t){return e.get(ui_utils_assertClassBrand(e,t))}function ui_utils_classPrivateFieldSet(e,t,i){return e.set(ui_utils_assertClassBrand(e,t),i),i}function ui_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const lh=0,dh=1,ch=2,hh=3,uh=-1,_h=0,ph=1,gh=2,mh=3,fh=4,vh=0,Ph=1,wh=2,Fh={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},bh={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2},yh=0,Sh=1,Ch=-3,xh=/\bprint\s*\(/;let kh=null;function cancelPendingHiddenScroll(){if(kh){for(const e of kh.observers)e.disconnect();clearInterval(kh.pollInterval);clearTimeout(kh.watchdog);kh=null}}function scrollIntoView(e,t,i=!1,a=!1){if(e.classList.contains("stf__item")||e.parentElement?.classList.contains("stf__item")||e.parentElement?.parentElement?.classList.contains("stf__item"))return;if(a){setTimeout(()=>{let i=e.parentElement;for(;i&&i!==document.body&&i!==document.documentElement;){const a=getComputedStyle(i).overflowY;if(("auto"===a||"scroll"===a)&&i.scrollHeight>i.clientHeight){const a=e.getBoundingClientRect(),s=i.getBoundingClientRect();let n=i.scrollTop+(a.top-s.top),r=i.scrollLeft+(a.left-s.left);if(t){void 0!==t.top&&(n+=t.top);void 0!==t.left&&(r+=t.left)}i.scrollTop=n;void 0!==t?.left&&(i.scrollLeft=r);return}i=i.parentElement}const a=e.getBoundingClientRect();let s=window.scrollY+a.top;void 0!==t?.top&&(s+=t.top);window.scrollTo(window.scrollX,s)},0);return}let s=e.offsetParent;if(!s){cancelPendingHiddenScroll();if(!e.isConnected){ngx_console_NgxConsole.warn("offsetParent is not set -- cannot scroll viewer (element is not attached)");return}ngx_console_NgxConsole.warn("offsetParent is not set -- scroll deferred until viewer becomes visible");let s=t,n=i,r=a;const tryReplay=()=>{if(!e.isConnected){cancelPendingHiddenScroll();return}if(!e.offsetParent)return;const t=s,i=n,a=r;s=null;n=null;r=null;cancelPendingHiddenScroll();requestAnimationFrame(()=>{requestAnimationFrame(()=>{scrollIntoView(e,t,i,a)})})},o=[];if("undefined"!=typeof ResizeObserver){const t=new ResizeObserver(tryReplay);t.observe(e);o.push(t)}if("undefined"!=typeof IntersectionObserver){const t=new IntersectionObserver(tryReplay,{rootMargin:"99999px"});t.observe(e);o.push(t)}const l=setInterval(tryReplay,250),d=setTimeout(()=>{s=null;n=null;r=null;cancelPendingHiddenScroll()},1e4);kh={observers:o,pollInterval:l,watchdog:d};return}let n=e.offsetTop+e.clientTop,r=e.offsetLeft+e.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth;){n+=s.offsetTop;r+=s.offsetLeft;s=s.offsetParent;if(!s)return}if("viewer"===s.id&&s.offsetParent){const e=s.offsetParent,t=getComputedStyle(e);if("auto"===t.overflow||"scroll"===t.overflow||"auto"===t.overflowX||"scroll"===t.overflowX){n+=s.offsetTop;r+=s.offsetLeft;s=e}}if(t){void 0!==t.top&&(n+=t.top);if(void 0!==t.left){r+=t.left;s.scrollLeft=r}}else if(function isDivInViewport(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}(e))return;s.scrollTop=n}function watchScroll(e,t,i=void 0){const debounceScroll=function(i){s||(s=window.requestAnimationFrame(function viewAreaElementScrolled(){s=null;const i=e.scrollLeft,n=a.lastX;i!==n&&(a.right=i>n);a.lastX=i;const r=e.scrollTop,o=a.lastY;r!==o&&(a.down=r>o);a.lastY=r;t(a)}))},a={right:!0,down:!0,lastX:e.scrollLeft,lastY:e.scrollTop,_eventHandler:debounceScroll};let s=null;e.addEventListener("scroll",debounceScroll,{useCapture:!0,signal:i});i?.addEventListener("abort",()=>window.cancelAnimationFrame(s),{once:!0});return a}function parseQueryString(e){const t=new Map;for(const[i,a]of new URLSearchParams(e))t.set(i.toLowerCase(),a);return t}const Eh=/[\x00-\x1F]/g;function removeNullCharacters(e,t=!1){return Eh.test(e)?t?e.replaceAll(Eh,e=>"\0"===e?"":" "):e.replaceAll("\0",""):e}function binarySearchFirstItem(e,t,i=0){let a=i,s=e.length-1;if(s<0||!t(e[s]))return e.length;if(t(e[a]))return a;for(;a<s;){const i=a+s>>1;t(e[i])?s=i:a=i+1}return a}function approximateFraction(e){if(Math.floor(e)===e)return[e,1];const t=1/e;if(t>8)return[1,8];if(Math.floor(t)===t)return[1,t];const i=e>1?t:e;let a=0,s=1,n=1,r=1;for(;;){const e=a+n,t=s+r;if(t>8)break;if(i<=e/t){n=e;r=t}else{a=e;s=t}}return i-a/s<n/r-i?i===e?[a,s]:[s,a]:i===e?[n,r]:[r,n]}function floorToDivide(e,t){return e-e%t}function getVisibleElements({scrollEl:e,views:t,sortByVisibility:i=!1,horizontal:a=!1,rtl:s=!1}){const n=e.scrollTop,r=n+e.clientHeight,o=e.scrollLeft,l=o+e.clientWidth;const d=[],c=new Set,h=t.length;let u=binarySearchFirstItem(t,a?function isElementNextAfterViewHorizontally(e){const t=e.div,i=t.offsetLeft+t.clientLeft,a=i+t.clientWidth;return s?i<l:a>o}:function isElementBottomAfterViewTop(e){const t=e.div;return t.offsetTop+t.clientTop+t.clientHeight>n});u>0&&u<h&&!a&&(u=function backtrackBeforeAllVisibleElements(e,t,i){if(e<2)return e;let a=t[e].div,s=a.offsetTop+a.clientTop;if(s>=i){a=t[e-1].div;s=a.offsetTop+a.clientTop}for(let i=e-2;i>=0;--i){a=t[i].div;if(a.offsetTop+a.clientTop+a.clientHeight<=s)break;e=i}return e}(u,t,n));let _=a?l:-1;for(let e=u;e<h;e++){const i=t[e],s=i.div,h=s.offsetLeft+s.clientLeft,u=s.offsetTop+s.clientTop,p=s.clientWidth,g=s.clientHeight,m=h+p,f=u+g;if(-1===_)f>=r&&(_=f);else if((a?h:u)>_)break;if(f<=n||u>=r||m<=o||h>=l)continue;const v=Math.max(0,n-u),P=Math.max(0,o-h),w=v+Math.max(0,f-r),F=(p-(P+Math.max(0,m-l)))/p,b=(g-w)/g*F*100|0;d.push({id:i.id,x:h,y:u,visibleArea:100===b?null:{minX:P,minY:v,maxX:Math.min(m,l)-h,maxY:Math.min(f,r)-u},view:i,percent:b,widthPercent:100*F|0});c.add(i.id)}const p=d[0],g=d.at(-1);i&&d.sort(function(e,t){const i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id});return{first:p,last:g,views:d,ids:c}}function normalizeWheelEventDirection(e){let t=Math.hypot(e.deltaX,e.deltaY);const i=Math.atan2(e.deltaY,e.deltaX);-.25*Math.PI<i&&i<.75*Math.PI&&(t=-t);return t}function isValidRotation(e){return Number.isInteger(e)&&e%90==0}function isValidScrollMode(e){return Number.isInteger(e)&&Object.values(Fh).includes(e)&&e!==Fh.UNKNOWN}function isValidSpreadMode(e){return Number.isInteger(e)&&Object.values(bh).includes(e)&&e!==bh.UNKNOWN}function isPortraitOrientation(e){return e.width<=e.height}const Ah=new Promise(function(e){window.requestAnimationFrame(e)});function getDocStyle(e){return(e?.closest(".html")??document.documentElement).style}var Gh=new WeakMap,Bh=new WeakMap,Mh=new WeakMap,Ih=new WeakMap,Th=new WeakMap;class ProgressBar{constructor(e){ui_utils_classPrivateFieldInitSpec(this,Gh,null);ui_utils_classPrivateFieldInitSpec(this,Bh,null);ui_utils_classPrivateFieldInitSpec(this,Mh,0);ui_utils_classPrivateFieldInitSpec(this,Ih,null);ui_utils_classPrivateFieldInitSpec(this,Th,!0);ui_utils_classPrivateFieldSet(Gh,this,e.classList);ui_utils_classPrivateFieldSet(Ih,this,e.style)}get percent(){return ui_utils_classPrivateFieldGet(Mh,this)}set percent(e){ui_utils_classPrivateFieldSet(Mh,this,e);if(isNaN(e))ui_utils_classPrivateFieldGet(Gh,this).add("indeterminate");else{ui_utils_classPrivateFieldGet(Gh,this).remove("indeterminate");ui_utils_classPrivateFieldGet(Ih,this).setProperty("--progressBar-percent",`${ui_utils_classPrivateFieldGet(Mh,this)}%`)}}setWidth(e){if(!e)return;const t=e.parentNode.offsetWidth-e.offsetWidth;t>0&&ui_utils_classPrivateFieldGet(Ih,this).setProperty("--progressBar-end-offset",`${t}px`)}setDisableAutoFetch(e=5e3){if(100!==ui_utils_classPrivateFieldGet(Mh,this)&&!isNaN(ui_utils_classPrivateFieldGet(Mh,this))){ui_utils_classPrivateFieldGet(Bh,this)&&clearTimeout(ui_utils_classPrivateFieldGet(Bh,this));this.show();ui_utils_classPrivateFieldSet(Bh,this,setTimeout(()=>{ui_utils_classPrivateFieldSet(Bh,this,null);this.hide()},e))}}hide(){if(ui_utils_classPrivateFieldGet(Th,this)){ui_utils_classPrivateFieldSet(Th,this,!1);ui_utils_classPrivateFieldGet(Gh,this).add("hidden")}}show(){if(!ui_utils_classPrivateFieldGet(Th,this)){ui_utils_classPrivateFieldSet(Th,this,!0);ui_utils_classPrivateFieldGet(Gh,this).remove("hidden")}}}function getActiveOrFocusedElement(){let e=document,t=e.activeElement||e.querySelector(":focus");for(;t?.shadowRoot;){e=t.shadowRoot;t=e.activeElement||e.querySelector(":focus")}return t}function apiPageLayoutToViewerModes(e){let t=Fh.VERTICAL,i=bh.NONE;switch(e){case"SinglePage":t=Fh.PAGE;break;case"OneColumn":break;case"TwoPageLeft":t=Fh.PAGE;case"TwoColumnLeft":i=bh.ODD;break;case"TwoPageRight":t=Fh.PAGE;case"TwoColumnRight":i=bh.EVEN}return{scrollMode:t,spreadMode:i}}function toggleCheckedBtn(e,t,i=null){e.classList.toggle("toggled",t);e.setAttribute("aria-checked",t);i?.classList.toggle("hidden",!t)}function toggleSelectedBtn(e,t,i=null){e.classList.toggle("selected",t);e.setAttribute("aria-selected",t);i?.classList.toggle("hidden",!t)}function toggleExpandedBtn(e,t,i=null){e?.classList.toggle("toggled",t);e?.setAttribute("aria-expanded",t);i?.classList.toggle("hidden",!t);if(i&&!i.classList.contains("hidden")){const t=e.getBoundingClientRect(),a=e.closest("#toolbarViewer");if(a){const e=a.getBoundingClientRect().right-t.right;i.style.removeProperty("inset-inline-end");i.style.setProperty("inset-inline-end",e+"px")}}}const Dh=function(){const e=document.createElement("div");e.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)";return"calc(1320px)"===e.style.width?Math.fround:e=>e}();const Lh="bdf2a9e9-edfb-4a31-900e-7cce1775f13e",Nh=Object.freeze({internal:Lh});function pdf_link_service_defineProperty(e,t,i){return(t=function pdf_link_service_toPropertyKey(e){var t=function pdf_link_service_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const Rh={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class PDFLinkService{constructor({eventBus:e,externalLinkTarget:t=null,externalLinkRel:i=null,ignoreDestinationZoom:a=!1}={}){pdf_link_service_defineProperty(this,"externalLinkEnabled",!0);this.eventBus=e;this.externalLinkTarget=t;this.externalLinkRel=i;this._ignoreDestinationZoom=a;this.baseUrl=null;this.pdfDocument=null;this.pdfViewer=null;this.pdfHistory=null}setDocument(e,t=null){this.baseUrl=t;this.pdfDocument=e}setViewer(e){this.pdfViewer=e}setHistory(e){this.pdfHistory=e}get pagesCount(){return this.pdfDocument?.pagesMapper.pagesNumber||0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(e){this.pdfDocument&&(this.pdfViewer.currentPageNumber=e)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(e){this.pdfDocument&&(this.pdfViewer.pagesRotation=e)}get isInPresentationMode(){return!!this.pdfDocument&&this.pdfViewer.isInPresentationMode}async goToDestination(e){if(!this.pdfDocument)return;let t,i,a;if("string"==typeof e){t=e;i=await this.pdfDocument.getDestination(e)}else{t=null;i=await e}if(!Array.isArray(i)){console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${e}".`);return}const[s]=i;if(s&&"object"==typeof s){a=this.pdfDocument.cachedPageNumber(s);if(!a)try{a=await this.pdfDocument.getPageIndex(s)+1}catch{ngx_console_NgxConsole.error(`goToDestination: "${s}" is not a valid page reference, for dest="${e}".`);return}}else Number.isInteger(s)&&(a=s+1);if(!a||a<1||a>this.pagesCount){ngx_console_NgxConsole.error(`goToDestination: "${a}" is not a valid page number, for dest="${e}".`);return}if(this.pdfHistory){this.pdfHistory.pushCurrentPosition();this.pdfHistory.push({namedDest:t,explicitDest:i,pageNumber:a})}if("book"===this.pdfViewer.pageViewMode&&this.pdfViewer.pageFlip){this.pdfViewer.ensureAdjacentPagesAreLoaded();this.pdfViewer.pageFlip.flip(a-1)}else this.pdfViewer.scrollPageIntoView({pageNumber:a,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom});const n=new AbortController;this.eventBus.on("textlayerrendered",e=>{if(e.pageNumber===a){e.source.textLayer.div.focus();n.abort()}},{signal:n.signal,...Nh})}goToPage(e){if(!this.pdfDocument)return;const t="string"==typeof e&&this.pdfViewer.pageLabelToPageNumber(e)||0|e;if(!(Number.isInteger(t)&&t>0&&t<=this.pagesCount)){ngx_console_NgxConsole.error(`PDFLinkService.goToPage: "${e}" is not a valid page.`);return}if(this.pdfHistory){this.pdfHistory.pushCurrentPosition();this.pdfHistory.pushPage(t)}const i=this.pdfViewer.currentPageNumber;this.pdfViewer.scrollPageIntoView({pageNumber:t});if("book"===this.pdfViewer.pageViewMode&&this.pdfViewer.pageFlip&&i!==t){Math.abs(i-t)<=2?this.pdfViewer.pageFlip.flip(t-1):this.pdfViewer.pageFlip.turnToPage(t-1);this.pdfViewer.ensureAdjacentPagesAreLoaded()}}goToXY(e,t,i,a={}){this.pdfViewer.scrollPageIntoView({pageNumber:e,destArray:[null,{name:"XYZ"},t,i],ignoreDestinationZoom:!0,...a})}async getAttachmentContent(e){try{return await(this.pdfDocument?.getAttachmentContent(e))}catch(e){e instanceof PasswordException||console.warn(`Unable to load attachment content: ${e}`)}return null}addLinkAttributes(e,t,i=!1){if(!t||"string"!=typeof t)throw new Error('A valid "url" parameter must provided.');const a=i?Rh.BLANK:this.externalLinkTarget,s=this.externalLinkRel;let n=t;const r=URL.parse(t);if(r?.username||r?.password){r.username=r.password="";n=r.href}if(this.externalLinkEnabled){e.href=t;e.title=n}else{e.href="";e.title=`Disabled: ${n}`;e.onclick=()=>!1}let o="";switch(a){case Rh.NONE:break;case Rh.SELF:o="_self";break;case Rh.BLANK:o="_blank";break;case Rh.PARENT:o="_parent";break;case Rh.TOP:o="_top"}e.target=o;e.rel="string"==typeof s?s:"noopener noreferrer nofollow"}getDestinationHash(e){if("string"==typeof e){if(e.length>0)return this.getAnchorUrl("#"+escape(e))}else if(Array.isArray(e)){const t=JSON.stringify(e);if(t.length>0)return this.getAnchorUrl("#"+escape(t))}return this.getAnchorUrl("")}getAnchorUrl(e){return this.baseUrl?this.baseUrl+e:e}setHash(e){if(!this.pdfDocument)return;let t,i;if(e.includes("=")){const a=parseQueryString(e);if(a.has("search")){const e=a.get("search").replaceAll('"',""),t="true"===a.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:t?e:e.match(/\S+/g)})}a.has("page")&&(t=0|a.get("page")||1);if(a.has("zoom")){const e=a.get("zoom").split(","),t=e[0],s=parseFloat(t);t.includes("Fit")?"Fit"===t||"FitB"===t?i=[null,{name:t}]:"FitH"===t||"FitBH"===t||"FitV"===t||"FitBV"===t?i=[null,{name:t},e.length>1?0|e[1]:null]:"FitR"===t?5!==e.length?ngx_console_NgxConsole.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:t},0|e[1],0|e[2],0|e[3],0|e[4]]:ngx_console_NgxConsole.error(`PDFLinkService.setHash: "${t}" is not a valid zoom value.`):i=[null,{name:"XYZ"},e.length>1?0|e[1]:null,e.length>2?0|e[2]:null,s?s/100:t]}i?this.pdfViewer.scrollPageIntoView({pageNumber:t||this.page,destArray:i,allowNegativeOffset:!0}):t&&(this.page=t);a.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:a.get("pagemode")});a.has("nameddest")&&this.goToDestination(a.get("nameddest"));return}i=unescape(e);try{i=JSON.parse(i);Array.isArray(i)||(i=i.toString())}catch{}"string"==typeof i||as(i)?this.goToDestination(i):console.error(`PDFLinkService.setHash: "${unescape(e)}" is not a valid destination.`)}executeNamedAction(e){if(this.pdfDocument){switch(e){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1}this.eventBus.dispatch("namedaction",{source:this,action:e})}}async executeSetOCGState(e){if(!this.pdfDocument)return;const t=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;if(t===this.pdfDocument){i.setOCGState(e);this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i)}}}class SimpleLinkService extends PDFLinkService{setDocument(e,t=null){}}function event_utils_classPrivateFieldInitSpec(e,t,i){(function event_utils_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function event_utils_classPrivateFieldGet(e,t){return e.get(event_utils_assertClassBrand(e,t))}function event_utils_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Oh="event",Wh="timeout";async function waitOnEventOrTimeout({target:e,name:t,delay:i=0}){if("object"!=typeof e||!t||"string"!=typeof t||!(Number.isInteger(i)&&i>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:a,resolve:s}=Promise.withResolvers(),n=new AbortController;function handler(e){n.abort();clearTimeout(l);s(e)}const r=e instanceof EventBus?"on":"addEventListener",o=e instanceof EventBus?{signal:n.signal,...Nh}:{signal:n.signal};e[r](t,handler.bind(null,Oh),o);const l=setTimeout(handler.bind(null,Wh),i);return a}var jh=new WeakMap;class EventBus{constructor(){event_utils_classPrivateFieldInitSpec(this,jh,Object.create(null));Object.seal(this)}_on(e,t,i=null){this.on(e,t,{...i||{},internal:Lh})}_off(e,t,i=null){this.off(e,t,i)}on(e,t,i=null){let a=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted){console.error("Cannot use an `aborted` signal.");return}const onAbort=()=>this.off(e,t);a=()=>s.removeEventListener("abort",onAbort);s.addEventListener("abort",onAbort)}(event_utils_classPrivateFieldGet(jh,this)[e]??=[]).push({listener:t,internal:i?.internal===Lh,once:!0===i?.once,rmAbort:a})}off(e,t,i=null){const a=event_utils_classPrivateFieldGet(jh,this)[e];if(a)for(let e=0,i=a.length;e<i;e++){const i=a[e];if(i.listener===t){i.rmAbort?.();a.splice(e,1);return}}}dispatch(e,t){const i=event_utils_classPrivateFieldGet(jh,this)[e];if(!i?.length)return;let a;for(const{listener:s,internal:n,once:r}of i.slice(0)){r&&this.off(e,s);n?s(t):(a??=[]).push(s)}if(a)for(const e of a)e(t)}destroy(){let e;for(e in event_utils_classPrivateFieldGet(jh,this))event_utils_classPrivateFieldGet(jh,this)[e].length=0}}class BaseExternalServices{updateFindControlState(e){}updateFindMatchesCount(e){}initPassiveLoading(){}reportTelemetry(e){}reportText(e){}async createL10n(){throw new Error("Not implemented: createL10n")}createScripting(){throw new Error("Not implemented: createScripting")}createSignatureStorage(){throw new Error("Not implemented: createSignatureStorage")}createSignatureVerifier(){return null}updateEditorStates(e){throw new Error("Not implemented: updateEditorStates")}dispatchGlobalEvent(e){}}function preferences_classPrivateFieldInitSpec(e,t,i){(function preferences_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function preferences_classPrivateFieldGet(e,t){return e.get(preferences_assertClassBrand(e,t))}function preferences_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Vh=new WeakMap,Uh=new WeakMap;class BasePreferences{constructor(){preferences_classPrivateFieldInitSpec(this,Vh,Object.freeze(AppOptions.getAll(fr,!0)));preferences_classPrivateFieldInitSpec(this,Uh,null);!function preferences_classPrivateFieldSet(e,t,i){return e.set(preferences_assertClassBrand(e,t),i),i}(Uh,this,this._readFromStorage(preferences_classPrivateFieldGet(Vh,this)).then(({browserPrefs:e,prefs:t})=>{AppOptions._checkDisablePreferences()||AppOptions.setAll({...e,...t},!0)}))}async _writeToStorage(e){throw new Error("Not implemented: _writeToStorage")}async _readFromStorage(e){throw new Error("Not implemented: _readFromStorage")}async reset(){await preferences_classPrivateFieldGet(Uh,this);AppOptions.setAll(preferences_classPrivateFieldGet(Vh,this),!0);await this._writeToStorage(preferences_classPrivateFieldGet(Vh,this))}async set(e,t){await preferences_classPrivateFieldGet(Uh,this);AppOptions.setAll({[e]:t},!0);await this._writeToStorage(AppOptions.getAll(fr))}async get(e){await preferences_classPrivateFieldGet(Uh,this);return AppOptions.get(e)}get defaults(){return preferences_classPrivateFieldGet(Vh,this)}get initializedPromise(){return preferences_classPrivateFieldGet(Uh,this)}}class FluentType{constructor(e){this.value=e}valueOf(){return this.value}}class FluentNone extends FluentType{constructor(e="???"){super(e)}toString(e){return`{${this.value}}`}}class FluentNumber extends FluentType{constructor(e,t={}){super(e);this.opts=t}toString(e){if(e)try{return e.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(t){e.reportError(t)}return this.value.toString(10)}}class FluentDateTime extends FluentType{static supportsValue(e){if("number"==typeof e)return!0;if(e instanceof Date)return!0;if(e instanceof FluentType)return FluentDateTime.supportsValue(e.valueOf());if("Temporal"in globalThis){const t=globalThis.Temporal;if(e instanceof t.Instant||e instanceof t.PlainDateTime||e instanceof t.PlainDate||e instanceof t.PlainMonthDay||e instanceof t.PlainTime||e instanceof t.PlainYearMonth)return!0}return!1}constructor(e,t={}){if(e instanceof FluentDateTime){t={...e.opts,...t};e=e.value}else e instanceof FluentType&&(e=e.valueOf());"object"==typeof e&&"calendarId"in e&&void 0===t.calendar&&(t={...t,calendar:e.calendarId});super(e);this.opts=t}[Symbol.toPrimitive](e){return"string"===e?this.toString():this.toNumber()}toNumber(){const e=this.value;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();if("epochMilliseconds"in e)return e.epochMilliseconds;if("toZonedDateTime"in e)return e.toZonedDateTime("UTC").epochMilliseconds;throw new TypeError("Unwrapping a non-number value as a number")}toString(e){if(e)try{return e.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(t){e.reportError(t)}return"number"==typeof this.value||this.value instanceof Date?new Date(this.value).toISOString():this.value.toString()}}function match(e,t,i){if(i===t)return!0;if(i instanceof FluentNumber&&t instanceof FluentNumber&&i.value===t.value)return!0;if(t instanceof FluentNumber&&"string"==typeof i){if(i===e.memoizeIntlObject(Intl.PluralRules,t.opts).select(t.value))return!0}return!1}function getDefault(e,t,i){if(t[i])return resolvePattern(e,t[i].value);e.reportError(new RangeError("No default"));return new FluentNone}function getArguments(e,t){const i=[],a=Object.create(null);for(const s of t)"narg"===s.type?a[s.name]=resolveExpression(e,s.value):i.push(resolveExpression(e,s));return{positional:i,named:a}}function resolveExpression(e,t){switch(t.type){case"str":return t.value;case"num":return new FluentNumber(t.value,{minimumFractionDigits:t.precision});case"var":return function resolveVariableReference(e,{name:t}){let i;if(e.params){if(!Object.prototype.hasOwnProperty.call(e.params,t))return new FluentNone(`$${t}`);i=e.params[t]}else{if(!e.args||!Object.prototype.hasOwnProperty.call(e.args,t)){e.reportError(new ReferenceError(`Unknown variable: $${t}`));return new FluentNone(`$${t}`)}i=e.args[t]}if(i instanceof FluentType)return i;switch(typeof i){case"string":return i;case"number":return new FluentNumber(i);case"object":if(FluentDateTime.supportsValue(i))return new FluentDateTime(i);default:e.reportError(new TypeError(`Variable type not supported: $${t}, ${typeof i}`));return new FluentNone(`$${t}`)}}(e,t);case"mesg":return function resolveMessageReference(e,{name:t,attr:i}){const a=e.bundle._messages.get(t);if(!a){e.reportError(new ReferenceError(`Unknown message: ${t}`));return new FluentNone(t)}if(i){const s=a.attributes[i];if(s)return resolvePattern(e,s);e.reportError(new ReferenceError(`Unknown attribute: ${i}`));return new FluentNone(`${t}.${i}`)}if(a.value)return resolvePattern(e,a.value);e.reportError(new ReferenceError(`No value: ${t}`));return new FluentNone(t)}(e,t);case"term":return function resolveTermReference(e,{name:t,attr:i,args:a}){const s=`-${t}`,n=e.bundle._terms.get(s);if(!n){e.reportError(new ReferenceError(`Unknown term: ${s}`));return new FluentNone(s)}if(i){const t=n.attributes[i];if(t){e.params=getArguments(e,a).named;const i=resolvePattern(e,t);e.params=null;return i}e.reportError(new ReferenceError(`Unknown attribute: ${i}`));return new FluentNone(`${s}.${i}`)}e.params=getArguments(e,a).named;const r=resolvePattern(e,n.value);e.params=null;return r}(e,t);case"func":return function resolveFunctionReference(e,{name:t,args:i}){let a=e.bundle._functions[t];if(!a){e.reportError(new ReferenceError(`Unknown function: ${t}()`));return new FluentNone(`${t}()`)}if("function"!=typeof a){e.reportError(new TypeError(`Function ${t}() is not callable`));return new FluentNone(`${t}()`)}try{let t=getArguments(e,i);return a(t.positional,t.named)}catch(i){e.reportError(i);return new FluentNone(`${t}()`)}}(e,t);case"select":return function resolveSelectExpression(e,{selector:t,variants:i,star:a}){let s=resolveExpression(e,t);if(s instanceof FluentNone)return getDefault(e,i,a);for(const t of i){if(match(e,s,resolveExpression(e,t.key)))return resolvePattern(e,t.value)}return getDefault(e,i,a)}(e,t);default:return new FluentNone}}function resolveComplexPattern(e,t){if(e.dirty.has(t)){e.reportError(new RangeError("Cyclic reference"));return new FluentNone}e.dirty.add(t);const i=[],a=e.bundle._useIsolating&&t.length>1;for(const s of t)if("string"!=typeof s){e.placeables++;if(e.placeables>100){e.dirty.delete(t);throw new RangeError(`Too many placeables expanded: ${e.placeables}, max allowed is 100`)}a&&i.push("");i.push(resolveExpression(e,s).toString(e));a&&i.push("")}else i.push(e.bundle._transform(s));e.dirty.delete(t);return i.join("")}function resolvePattern(e,t){return"string"==typeof t?e.bundle._transform(t):resolveComplexPattern(e,t)}class Scope{constructor(e,t,i){this.dirty=new WeakSet;this.params=null;this.placeables=0;this.bundle=e;this.errors=t;this.args=i}reportError(e){if(!(this.errors&&e instanceof Error))throw e;this.errors.push(e)}memoizeIntlObject(e,t){let i=this.bundle._intls.get(e);if(!i){i={};this.bundle._intls.set(e,i)}let a=JSON.stringify(t);i[a]||(i[a]=new e(this.bundle.locales,t));return i[a]}}function values(e,t){const i=Object.create(null);for(const[a,s]of Object.entries(e))t.includes(a)&&(i[a]=s.valueOf());return i}const zh=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function NUMBER(e,t){let i=e[0];if(i instanceof FluentNone)return new FluentNone(`NUMBER(${i.valueOf()})`);if(i instanceof FluentNumber)return new FluentNumber(i.valueOf(),{...i.opts,...values(t,zh)});if(i instanceof FluentDateTime)return new FluentNumber(i.toNumber(),{...values(t,zh)});throw new TypeError("Invalid argument to NUMBER")}const Hh=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function DATETIME(e,t){let i=e[0];if(i instanceof FluentNone)return new FluentNone(`DATETIME(${i.valueOf()})`);if(i instanceof FluentDateTime||i instanceof FluentNumber)return new FluentDateTime(i,values(t,Hh));throw new TypeError("Invalid argument to DATETIME")}const $h=new Map;class FluentBundle{constructor(e,{functions:t,useIsolating:i=!0,transform:a=e=>e}={}){this._terms=new Map;this._messages=new Map;this.locales=Array.isArray(e)?e:[e];this._functions={NUMBER,DATETIME,...t};this._useIsolating=i;this._transform=a;this._intls=function getMemoizerForLocale(e){const t=Array.isArray(e)?e.join(" "):e;let i=$h.get(t);if(void 0===i){i=new Map;$h.set(t,i)}return i}(e)}hasMessage(e){return this._messages.has(e)}getMessage(e){return this._messages.get(e)}addResource(e,{allowOverrides:t=!1}={}){const i=[];for(let a=0;a<e.body.length;a++){let s=e.body[a];if(s.id.startsWith("-")){if(!1===t&&this._terms.has(s.id)){i.push(new Error(`Attempt to override an existing term: "${s.id}"`));continue}this._terms.set(s.id,s)}else{if(!1===t&&this._messages.has(s.id)){i.push(new Error(`Attempt to override an existing message: "${s.id}"`));continue}this._messages.set(s.id,s)}}return i}formatPattern(e,t=null,i=null){if("string"==typeof e)return this._transform(e);let a=new Scope(this,i,t);try{return resolveComplexPattern(a,e).toString(a)}catch(e){if(a.errors&&e instanceof Error){a.errors.push(e);return(new FluentNone).toString(a)}throw e}}}const Kh=/^(-?[a-zA-Z][\w-]*) *= */gm,Xh=/\.([a-zA-Z][\w-]*) *= */y,qh=/\*?\[/y,Yh=/(-?[0-9]+(?:\.([0-9]+))?)/y,Zh=/([a-zA-Z][\w-]*)/y,Qh=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,Jh=/^[A-Z][A-Z0-9_-]*$/,eu=/([^{}\n\r]+)/y,tu=/([^\\"\n\r]*)/y,iu=/\\([\\"])/y,au=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,su=/^\n+/,nu=/ +$/,ru=/ *\r?\n/g,ou=/( *)$/,lu=/{\s*/y,du=/\s*}/y,cu=/\[\s*/y,hu=/\s*] */y,uu=/\s*\(\s*/y,_u=/\s*->\s*/y,pu=/\s*:\s*/y,gu=/\s*,?\s*/y,mu=/\s+/y;class FluentResource{constructor(e){this.body=[];Kh.lastIndex=0;let t=0;for(;;){let i=Kh.exec(e);if(null===i)break;t=Kh.lastIndex;try{this.body.push(parseMessage(i[1]))}catch(e){if(e instanceof SyntaxError)continue;throw e}}function test(i){i.lastIndex=t;return i.test(e)}function consumeChar(i,a){if(e[t]===i){t++;return!0}if(a)throw new a(`Expected ${i}`);return!1}function consumeToken(e,i){if(test(e)){t=e.lastIndex;return!0}if(i)throw new i(`Expected ${e.toString()}`);return!1}function match(i){i.lastIndex=t;let a=i.exec(e);if(null===a)throw new SyntaxError(`Expected ${i.toString()}`);t=i.lastIndex;return a}function match1(e){return match(e)[1]}function parseMessage(e){let t=parsePattern(),i=function parseAttributes(){let e=Object.create(null);for(;test(Xh);){let t=match1(Xh),i=parsePattern();if(null===i)throw new SyntaxError("Expected attribute value");e[t]=i}return e}();if(null===t&&0===Object.keys(i).length)throw new SyntaxError("Expected message value or attributes");return{id:e,value:t,attributes:i}}function parsePattern(){let i;test(eu)&&(i=match1(eu));if("{"===e[t]||"}"===e[t])return parsePatternElements(i?[i]:[],1/0);let a=parseIndent();if(a){if(i)return parsePatternElements([i,a],a.length);a.value=trim(a.value,su);return parsePatternElements([a],a.length)}return i?trim(i,nu):null}function parsePatternElements(i=[],a){for(;;){if(test(eu)){i.push(match1(eu));continue}if("{"===e[t]){i.push(parsePlaceable());continue}if("}"===e[t])throw new SyntaxError("Unbalanced closing brace");let s=parseIndent();if(!s)break;i.push(s);a=Math.min(a,s.length)}let s=i.length-1,n=i[s];"string"==typeof n&&(i[s]=trim(n,nu));let r=[];for(let e of i){e instanceof Indent&&(e=e.value.slice(0,e.value.length-a));e&&r.push(e)}return r}function parsePlaceable(){consumeToken(lu,SyntaxError);let e=parseInlineExpression();if(consumeToken(du))return e;if(consumeToken(_u)){let t=function parseVariants(){let e,t=[],i=0;for(;test(qh);){consumeChar("*")&&(e=i);let a=parseVariantKey(),s=parsePattern();if(null===s)throw new SyntaxError("Expected variant value");t[i++]={key:a,value:s}}if(0===i)return null;if(void 0===e)throw new SyntaxError("Expected default variant");return{variants:t,star:e}}();consumeToken(du,SyntaxError);return{type:"select",selector:e,...t}}throw new SyntaxError("Unclosed placeable")}function parseInlineExpression(){if("{"===e[t])return parsePlaceable();if(test(Qh)){let[,i,a,s=null]=match(Qh);if("$"===i)return{type:"var",name:a};if(consumeToken(uu)){let n=function parseArguments(){let i=[];for(;;){switch(e[t]){case")":t++;return i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(parseArgument());consumeToken(gu)}}();if("-"===i)return{type:"term",name:a,attr:s,args:n};if(Jh.test(a))return{type:"func",name:a,args:n};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:a,attr:s,args:[]}:{type:"mesg",name:a,attr:s}}return parseLiteral()}function parseArgument(){let e=parseInlineExpression();return"mesg"!==e.type?e:consumeToken(pu)?{type:"narg",name:e.name,value:parseLiteral()}:e}function parseVariantKey(){consumeToken(cu,SyntaxError);let e;e=test(Yh)?parseNumberLiteral():{type:"str",value:match1(Zh)};consumeToken(hu,SyntaxError);return e}function parseLiteral(){if(test(Yh))return parseNumberLiteral();if('"'===e[t])return function parseStringLiteral(){consumeChar('"',SyntaxError);let i="";for(;;){i+=match1(tu);if("\\"!==e[t]){if(consumeChar('"'))return{type:"str",value:i};throw new SyntaxError("Unclosed string literal")}i+=parseEscapeSequence()}}();throw new SyntaxError("Invalid expression")}function parseNumberLiteral(){let[,e,t=""]=match(Yh),i=t.length;return{type:"num",value:parseFloat(e),precision:i}}function parseEscapeSequence(){if(test(iu))return match1(iu);if(test(au)){let[,e,t]=match(au),i=parseInt(e||t,16);return i<=55295||57344<=i?String.fromCodePoint(i):"�"}throw new SyntaxError("Unknown escape sequence")}function parseIndent(){let i=t;consumeToken(mu);switch(e[t]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return makeIndent(e.slice(i,t))}return" "===e[t-1]&&makeIndent(e.slice(i,t))}function trim(e,t){return e.replace(t,"")}function makeIndent(e){let t=e.replace(ru,"\n"),i=ou.exec(e)[1].length;return new Indent(t,i)}}}class Indent{constructor(e,t){this.value=e;this.length=t}}const fu=/<|&#?\w+;/,vu={"http://www.w3.org/1999/xhtml":["em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","bdi","bdo","span","br","wbr"]},Pu={"http://www.w3.org/1999/xhtml":{global:["title","aria-description","aria-label","aria-valuetext"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]},"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul":{global:["accesskey","aria-label","aria-valuetext","label","title","tooltiptext"],description:["value"],key:["key","keycode"],label:["value"],textbox:["placeholder","value"]}};function translateElement(e,t){const{value:i}=t;if("string"==typeof i)if("title"===e.localName&&"http://www.w3.org/1999/xhtml"===e.namespaceURI)e.textContent=i;else if(fu.test(i)){const t=e.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");t.innerHTML=i;!function overlayChildNodes(e,t){for(const i of e.childNodes)if(i.nodeType!==i.TEXT_NODE){if(i.hasAttribute("data-l10n-name")){const a=getNodeForNamedElement(t,i);e.replaceChild(a,i);continue}if(isElementAllowed(i)){const t=createSanitizedElement(i);e.replaceChild(t,i);continue}console.warn(`An element of forbidden type "${i.localName}" was found in the translation. Only safe text-level elements and elements with data-l10n-name are allowed.`);e.replaceChild(createTextNodeFromTextContent(i),i)}t.textContent="";t.appendChild(e)}(t.content,e)}else e.textContent=i;overlayAttributes(t,e)}function hasAttribute(e,t){if(!e)return!1;for(let i of e)if(i.name===t)return!0;return!1}function overlayAttributes(e,t){const i=t.hasAttribute("data-l10n-attrs")?t.getAttribute("data-l10n-attrs").split(",").map(e=>e.trim()):null;for(const a of Array.from(t.attributes))isAttrNameLocalizable(a.name,t,i)&&!hasAttribute(e.attributes,a.name)&&t.removeAttribute(a.name);if(e.attributes)for(const a of Array.from(e.attributes))isAttrNameLocalizable(a.name,t,i)&&t.getAttribute(a.name)!==a.value&&t.setAttribute(a.name,a.value)}function getNodeForNamedElement(e,t){const i=t.getAttribute("data-l10n-name"),a=e.querySelector(`[data-l10n-name="${i}"]`);if(!a){console.warn(`An element named "${i}" wasn't found in the source.`);return createTextNodeFromTextContent(t)}if(a.localName!==t.localName){console.warn(`An element named "${i}" was found in the translation but its type ${t.localName} didn't match the element found in the source (${a.localName}).`);return createTextNodeFromTextContent(t)}e.removeChild(a);return shallowPopulateUsing(t,a.cloneNode(!1))}function createSanitizedElement(e){const t=e.ownerDocument.createElement(e.localName);return shallowPopulateUsing(e,t)}function createTextNodeFromTextContent(e){return e.ownerDocument.createTextNode(e.textContent)}function isElementAllowed(e){const t=vu[e.namespaceURI];return t&&t.includes(e.localName)}function isAttrNameLocalizable(e,t,i=null){if(i&&i.includes(e))return!0;const a=Pu[t.namespaceURI];if(!a)return!1;const s=e.toLowerCase(),n=t.localName;if(a.global.includes(s))return!0;if(!a[n])return!1;if(a[n].includes(s))return!0;if("http://www.w3.org/1999/xhtml"===t.namespaceURI&&"input"===n&&"value"===s){const e=t.type.toLowerCase();if("submit"===e||"button"===e||"reset"===e)return!0}return!1}function shallowPopulateUsing(e,t){t.textContent=e.textContent;overlayAttributes(e,t);return t}class CachedIterable extends Array{static from(e){return e instanceof this?e:new this(e)}}Symbol.iterator;class CachedAsyncIterable extends CachedIterable{constructor(e){super();if(Symbol.asyncIterator in Object(e))this.iterator=e[Symbol.asyncIterator]();else{if(!(Symbol.iterator in Object(e)))throw new TypeError("Argument must implement the iteration protocol.");this.iterator=e[Symbol.iterator]()}}[Symbol.asyncIterator](){const e=this;let t=0;return{async next(){e.length<=t&&e.push(e.iterator.next());return e[t++]}}}async touchNext(e=1){let t=0;for(;t++<e;){const e=this[this.length-1];if(e&&(await e).done)break;this.push(this.iterator.next())}return this[this.length-1]}}class Localization{constructor(e=[],t){this.resourceIds=e;this.generateBundles=t;this.onChange(!0)}addResourceIds(e,t=!1){this.resourceIds.push(...e);this.onChange(t);return this.resourceIds.length}removeResourceIds(e){this.resourceIds=this.resourceIds.filter(t=>!e.includes(t));this.onChange();return this.resourceIds.length}async formatWithFallback(e,t){const i=[];let a=!1;for await(const s of this.bundles){a=!0;const n=keysFromBundle(t,s,e,i);if(0===n.size)break;if("undefined"!=typeof console){const e=s.locales[0],t=Array.from(n).join(", ");console.warn(`[fluent] Missing translations in ${e}: ${t}`)}}a||"undefined"==typeof console||console.warn(`[fluent] Request for keys failed because no resource bundles got generated.\n keys: ${JSON.stringify(e)}.\n resourceIds: ${JSON.stringify(this.resourceIds)}.`);return i}formatMessages(e){return this.formatWithFallback(e,messageFromBundle)}formatValues(e){return this.formatWithFallback(e,valueFromBundle)}async formatValue(e,t){const[i]=await this.formatValues([{id:e,args:t}]);return i}handleEvent(){this.onChange()}onChange(e=!1){this.bundles=CachedAsyncIterable.from(this.generateBundles(this.resourceIds));e&&this.bundles.touchNext(2)}}function valueFromBundle(e,t,i,a){return i.value?e.formatPattern(i.value,a,t):null}function messageFromBundle(e,t,i,a){const s={value:null,attributes:null};i.value&&(s.value=e.formatPattern(i.value,a,t));let n=Object.keys(i.attributes);if(n.length>0){s.attributes=new Array(n.length);for(let[r,o]of n.entries()){let n=e.formatPattern(i.attributes[o],a,t);s.attributes[r]={name:o,value:n}}}return s}function keysFromBundle(e,t,i,a){const s=[],n=new Set;i.forEach(({id:i,args:r},o)=>{if(void 0!==a[o])return;let l=t.getMessage(i);if(l){s.length=0;a[o]=e(t,s,l,r);if(s.length>0&&"undefined"!=typeof console){const e=t.locales[0],a=s.join(", ");console.warn(`[fluent][resolver] errors in ${e}/${i}: ${a}.`)}}else n.add(i)});return n}const wu="data-l10n-id",Fu="data-l10n-args",bu=`[${wu}]`;class DOMLocalization extends Localization{constructor(e,t){super(e,t);this.roots=new Set;this.pendingrAF=null;this.pendingElements=new Set;this.windowElement=null;this.mutationObserver=null;this.observerConfig={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:[wu,Fu]}}onChange(e=!1){super.onChange(e);this.roots&&this.translateRoots()}setAttributes(e,t,i){e.setAttribute(wu,t);i?e.setAttribute(Fu,JSON.stringify(i)):e.removeAttribute(Fu);return e}getAttributes(e){return{id:e.getAttribute(wu),args:JSON.parse(e.getAttribute(Fu)||null)}}connectRoot(e){for(const t of this.roots)if(t===e||t.contains(e)||e.contains(t))throw new Error("Cannot add a root that overlaps with existing root.");if(this.windowElement){if(this.windowElement!==e.ownerDocument.defaultView)throw new Error("Cannot connect a root:\n DOMLocalization already has a root from a different window.")}else{this.windowElement=e.ownerDocument.defaultView;this.mutationObserver=new this.windowElement.MutationObserver(e=>this.translateMutations(e))}this.roots.add(e);this.mutationObserver.observe(e,this.observerConfig)}disconnectRoot(e){this.roots.delete(e);this.pauseObserving();if(0===this.roots.size){this.mutationObserver=null;this.windowElement&&this.pendingrAF&&this.windowElement.cancelAnimationFrame(this.pendingrAF);this.windowElement=null;this.pendingrAF=null;this.pendingElements.clear();return!0}this.resumeObserving();return!1}translateRoots(){const e=Array.from(this.roots);return Promise.all(e.map(e=>this.translateFragment(e)))}pauseObserving(){if(this.mutationObserver){this.translateMutations(this.mutationObserver.takeRecords());this.mutationObserver.disconnect()}}resumeObserving(){if(this.mutationObserver)for(const e of this.roots)this.mutationObserver.observe(e,this.observerConfig)}translateMutations(e){for(const t of e)switch(t.type){case"attributes":t.target.hasAttribute("data-l10n-id")&&this.pendingElements.add(t.target);break;case"childList":for(const e of t.addedNodes)if(e.nodeType===e.ELEMENT_NODE)if(e.childElementCount)for(const t of this.getTranslatables(e))this.pendingElements.add(t);else e.hasAttribute(wu)&&this.pendingElements.add(e)}this.pendingElements.size>0&&null===this.pendingrAF&&(this.pendingrAF=this.windowElement.requestAnimationFrame(()=>{this.translateElements(Array.from(this.pendingElements));this.pendingElements.clear();this.pendingrAF=null}))}translateFragment(e){return this.translateElements(this.getTranslatables(e))}async translateElements(e){if(!e.length)return;const t=e.map(this.getKeysForElement),i=await this.formatMessages(t);return this.applyTranslations(e,i)}applyTranslations(e,t){this.pauseObserving();for(let i=0;i<e.length;i++)void 0!==t[i]&&translateElement(e[i],t[i]);this.resumeObserving()}getTranslatables(e){const t=Array.from(e.querySelectorAll(bu));"function"==typeof e.hasAttribute&&e.hasAttribute(wu)&&t.push(e);return t}getKeysForElement(e){return{id:e.getAttribute(wu),args:JSON.parse(e.getAttribute(Fu)||null)}}}function l10n_classPrivateFieldInitSpec(e,t,i){(function l10n_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function l10n_classPrivateFieldGet(e,t){return e.get(l10n_assertClassBrand(e,t))}function l10n_classPrivateFieldSet(e,t,i){return e.set(l10n_assertClassBrand(e,t),i),i}function l10n_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var yu=new WeakMap,Su=new WeakMap,Cu=new WeakMap,xu=new WeakMap;class L10n{constructor({lang:e,isRTL:t},i=null){l10n_classPrivateFieldInitSpec(this,yu,void 0);l10n_classPrivateFieldInitSpec(this,Su,void 0);l10n_classPrivateFieldInitSpec(this,Cu,void 0);l10n_classPrivateFieldInitSpec(this,xu,void 0);l10n_classPrivateFieldSet(Cu,this,_fixupLangCode.call(L10n,e));l10n_classPrivateFieldSet(xu,this,i);l10n_classPrivateFieldSet(yu,this,t??_isRTL.call(L10n,l10n_classPrivateFieldGet(Cu,this))?"rtl":"ltr")}_setL10n(e){l10n_classPrivateFieldSet(xu,this,e)}getLanguage(){return l10n_classPrivateFieldGet(Cu,this)}getDirection(){return l10n_classPrivateFieldGet(yu,this)}async get(e,t=null,i){if(Array.isArray(e)){e=e.map(e=>({id:e}));return(await l10n_classPrivateFieldGet(xu,this).formatMessages(e)).map(e=>e.value)}const a=await l10n_classPrivateFieldGet(xu,this).formatMessages([{id:e,args:t}]);return a[0]?.value||i}async translate(e){(l10n_classPrivateFieldGet(Su,this)||l10n_classPrivateFieldSet(Su,this,new Set)).add(e);try{l10n_classPrivateFieldGet(xu,this).connectRoot(e)}catch{}await l10n_classPrivateFieldGet(xu,this).translateRoots()}async translateOnce(e){try{await l10n_classPrivateFieldGet(xu,this).translateElements([e])}catch(e){console.error("translateOnce:",e)}}async destroy(){if(l10n_classPrivateFieldGet(Su,this)){for(const e of l10n_classPrivateFieldGet(Su,this))l10n_classPrivateFieldGet(xu,this).disconnectRoot(e);l10n_classPrivateFieldGet(Su,this).clear();l10n_classPrivateFieldSet(Su,this,null)}l10n_classPrivateFieldGet(xu,this).pauseObserving()}pause(){l10n_classPrivateFieldGet(xu,this).pauseObserving()}resume(){l10n_classPrivateFieldGet(xu,this).resumeObserving()}}function _fixupLangCode(e){return{en:"en-us",es:"es-es",fy:"fy-nl",ga:"ga-ie",gu:"gu-in",hi:"hi-in",hy:"hy-am",nb:"nb-no",ne:"ne-np",nn:"nn-no",pa:"pa-in",pt:"pt-pt",sv:"sv-se",zh:"zh-cn"}[e=e?.toLowerCase()||"en-us"]||e}function _isRTL(e){const t=e.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(t)}var ku;function genericl10n_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function PLATFORM(){const{isAndroid:e,isLinux:t,isMac:i,isWindows:a}=FeatureTest.platform;return t?"linux":a?"windows":i?"macos":e?"android":"other"}function createBundle(e,t){const i=new FluentResource(t),a=new FluentBundle(e,{functions:{PLATFORM}}),s=a.addResource(i);s.length&&console.error("L10n errors",s);return a}class genericl10n_GenericL10n extends L10n{constructor(e){super({lang:e});const t=e?_generateBundles.bind(genericl10n_GenericL10n,"en-us",this.getLanguage()):_generateBundlesFallback.bind(genericl10n_GenericL10n,this.getLanguage());this._setL10n(new DOMLocalization([],t))}}ku=genericl10n_GenericL10n;async function*_generateBundles(e,t){const{baseURL:i,paths:a}=await genericl10n_assertClassBrand(ku,this,_getPaths).call(this),s=[t];if(e!==t){const i=t.split("-",1)[0];i!==t&&s.push(i);s.push(e)}const n=s.map(e=>[e,genericl10n_assertClassBrand(ku,this,_createBundle).call(this,e,i,a)]);for(const[e,t]of n){const i=await t;i?yield i:"en-us"===e&&(yield genericl10n_assertClassBrand(ku,this,_createBundleFallback).call(this,e))}}async function _createBundle(e,t,i){const a=i[e];if(!a)return null;const s=new URL(a,t);return createBundle(e,await fetchData(s,"text"))}async function _getPaths(){try{const{href:e}=document.querySelector('link[type="application/l10n"]'),t=await fetchData(e,"json");return{baseURL:e.substring(0,e.lastIndexOf("/")+1)||"./",paths:t}}catch{}return{baseURL:"./",paths:Object.create(null)}}async function*_generateBundlesFallback(e){yield genericl10n_assertClassBrand(ku,this,_createBundleFallback).call(this,e)}async function _createBundleFallback(e){return createBundle(e,'pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties…\npdfjs-document-properties-button-label = Document Properties…\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } × { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } × { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing…\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title1 =\n .title = Page { $page } of { $total }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-thumb-page-checkbox1 =\n .title = Select page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document…\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-color-picker-free-text-input =\n .title = Change text color\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-color-picker-ink-input =\n .title = Change drawing color\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-comment-floating-button =\n .title = Comment\n .aria-label = Comment\npdfjs-comment-floating-button-label = Comment\npdfjs-editor-comment-button =\n .title = Comment\n .aria-label = Comment\npdfjs-editor-comment-button-label = Comment\npdfjs-editor-signature-button =\n .title = Add signature\npdfjs-editor-signature-button-label = Add signature\npdfjs-editor-highlight-editor =\n .aria-label = Highlight editor\npdfjs-editor-ink-editor =\n .aria-label = Drawing editor\npdfjs-editor-signature-editor1 =\n .aria-description = Signature editor: { $description }\npdfjs-editor-stamp-editor =\n .aria-label = Image editor\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-remove-signature-button =\n .title = Remove signature\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-editor-add-signature-container =\n .aria-label = Signature controls and saved signatures\npdfjs-editor-signature-add-signature-button =\n .title = Add new signature\npdfjs-editor-signature-add-signature-button-label = Add new signature\npdfjs-editor-add-saved-signature-button =\n .title = Saved signature: { $description }\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\npdfjs-editor-comments-sidebar-title =\n { $count ->\n [one] Comment\n *[other] Comments\n }\npdfjs-editor-comments-sidebar-close-button =\n .title = Close the sidebar\n .aria-label = Close the sidebar\npdfjs-editor-comments-sidebar-close-button-label = Close the sidebar\npdfjs-editor-comments-sidebar-no-comments1 = See something noteworthy? Highlight it and leave a comment.\npdfjs-editor-comments-sidebar-no-comments-link = Learn more\npdfjs-editor-alt-text-button =\n .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n .aria-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, “A young man sits down at a table to eat a meal”\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner — resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle — resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner — resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right — resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner — resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle — resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner — resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left — resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here…\npdfjs-editor-new-alt-text-description = Short description for people who can’t see the image or when the image doesn’t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn’t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can’t see the image or when the image doesn’t load.\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-highlight-added-alert = Highlight added\npdfjs-editor-freetext-added-alert = Text added\npdfjs-editor-ink-added-alert = Drawing added\npdfjs-editor-stamp-added-alert = Image added\npdfjs-editor-signature-added-alert = Signature added\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-signature = Signature removed\npdfjs-editor-undo-bar-message-comment = Comment removed\npdfjs-editor-undo-bar-message-multiple =\n { $count ->\n [one] { $count } annotation removed\n *[other] { $count } annotations removed\n }\npdfjs-editor-undo-bar-undo-button =\n .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n .title = Close\npdfjs-editor-undo-bar-close-button-label = Close\npdfjs-editor-add-signature-dialog-label = This modal allows the user to create a signature to add to a PDF document. The user can edit the name (which also serves as the alt text), and optionally save the signature for repeated use.\npdfjs-editor-add-signature-dialog-title = Add a signature\npdfjs-editor-add-signature-type-button = Type\n .title = Type\npdfjs-editor-add-signature-draw-button = Draw\n .title = Draw\npdfjs-editor-add-signature-image-button = Image\n .title = Image\npdfjs-editor-add-signature-type-input =\n .aria-label = Type your signature\n .placeholder = Type your signature\npdfjs-editor-add-signature-draw-placeholder = Draw your signature\npdfjs-editor-add-signature-draw-thickness-range-label = Thickness\npdfjs-editor-add-signature-draw-thickness-range =\n .title = Drawing thickness: { $thickness }\npdfjs-editor-add-signature-image-placeholder = Drag a file here to upload\npdfjs-editor-add-signature-image-browse-link =\n { PLATFORM() ->\n [macos] Or choose image files\n *[other] Or browse image files\n }\npdfjs-editor-add-signature-description-label = Description (alt text)\npdfjs-editor-add-signature-description-input =\n .title = Description (alt text)\npdfjs-editor-add-signature-description-default-when-drawing = Signature\npdfjs-editor-add-signature-clear-button-label = Clear signature\npdfjs-editor-add-signature-clear-button =\n .title = Clear signature\npdfjs-editor-add-signature-save-checkbox = Save signature\npdfjs-editor-add-signature-save-warning-message = You’ve reached the limit of 5 saved signatures. Remove one to save more.\npdfjs-editor-add-signature-image-upload-error-title = Couldn’t upload image\npdfjs-editor-add-signature-image-upload-error-description = Check your network connection or try another image.\npdfjs-editor-add-signature-image-no-data-error-title = Can’t convert this image into a signature\npdfjs-editor-add-signature-image-no-data-error-description = Please try uploading a different image.\npdfjs-editor-add-signature-error-close-button = Close\npdfjs-editor-add-signature-cancel-button = Cancel\npdfjs-editor-add-signature-add-button = Add\npdfjs-editor-delete-signature-button1 =\n .title = Remove saved signature\npdfjs-editor-delete-signature-button-label1 = Remove saved signature\npdfjs-editor-add-signature-edit-button-label = Edit description\npdfjs-editor-edit-signature-dialog-title = Edit description\npdfjs-editor-edit-signature-update-button = Update\npdfjs-show-comment-button =\n .title = Show comment\npdfjs-editor-edit-comment-popup-button-label = Edit comment\npdfjs-editor-edit-comment-popup-button =\n .title = Edit comment\npdfjs-editor-delete-comment-popup-button-label = Remove comment\npdfjs-editor-delete-comment-popup-button =\n .title = Remove comment\npdfjs-editor-edit-comment-dialog-title-when-editing = Edit comment\npdfjs-editor-edit-comment-dialog-save-button-when-editing = Update\npdfjs-editor-edit-comment-dialog-title-when-adding = Add comment\npdfjs-editor-edit-comment-dialog-save-button-when-adding = Add\npdfjs-editor-edit-comment-dialog-text-input =\n .placeholder = Start typing…\npdfjs-editor-edit-comment-dialog-cancel-button = Cancel\npdfjs-editor-add-comment-button =\n .title = Add comment\npdfjs-toggle-views-manager-button1 =\n .title = Manage pages\npdfjs-toggle-views-manager-notification-button =\n .title = Toggle Sidebar (document contains thumbnails/outline/attachments/layers)\npdfjs-toggle-views-manager-button1-label = Manage pages\npdfjs-views-manager-sidebar =\n .aria-label = Sidebar\npdfjs-views-manager-sidebar-resizer =\n .aria-label = Sidebar resizer\npdfjs-views-manager-view-selector-button =\n .title = Views\npdfjs-views-manager-view-selector-button-label = Views\npdfjs-views-manager-pages-title = Pages\npdfjs-views-manager-outlines-title1 = Document outline\n .title = Document outline (double-click to expand/collapse all items)\npdfjs-views-manager-attachments-title = Attachments\npdfjs-views-manager-layers-title1 = Layers\n .title = Layers (double-click to reset all layers to the default state)\npdfjs-views-manager-pages-option-label = Pages\npdfjs-views-manager-outlines-option-label = Document outline\npdfjs-views-manager-attachments-option-label = Attachments\npdfjs-views-manager-layers-option-label = Layers\npdfjs-views-manager-add-file-button =\n .title = Add file\npdfjs-views-manager-add-file-button-label = Add file\npdfjs-views-manager-pages-status-action-label =\n { $count ->\n [one] { $count } selected\n *[other] { $count } selected\n }\npdfjs-views-manager-pages-status-none-action-label = Select pages\npdfjs-views-manager-pages-status-action-button-label = Manage\npdfjs-views-manager-pages-status-copy-button-label = Copy\npdfjs-views-manager-pages-status-cut-button-label = Cut\npdfjs-views-manager-pages-status-delete-button-label = Delete\npdfjs-views-manager-pages-status-export-selected-button-label = Export selected…\npdfjs-views-manager-status-undo-cut-label =\n { $count ->\n [one] 1 page cut\n *[other] { $count } pages cut\n }\npdfjs-views-manager-pages-status-undo-copy-label =\n { $count ->\n [one] 1 page copied\n *[other] { $count } pages copied\n }\npdfjs-views-manager-pages-status-undo-delete-label =\n { $count ->\n [one] 1 page deleted\n *[other] { $count } pages deleted\n }\npdfjs-views-manager-pages-status-waiting-ready-label = Getting your file ready…\npdfjs-views-manager-pages-status-waiting-uploading-label = Uploading file…\npdfjs-views-manager-status-warning-cut-label = Couldn’t cut. Refresh page and try again.\npdfjs-views-manager-status-warning-copy-label = Couldn’t copy. Refresh page and try again.\npdfjs-views-manager-status-warning-delete-label = Couldn’t delete. Refresh page and try again.\npdfjs-views-manager-status-warning-save-label = Couldn’t save. Refresh page and try again.\npdfjs-views-manager-status-undo-button-label = Undo\npdfjs-views-manager-status-done-button-label = Done\npdfjs-views-manager-status-close-button =\n .title = Close\npdfjs-views-manager-status-close-button-label = Close\npdfjs-views-manager-paste-button-label = Paste\npdfjs-views-manager-paste-button-before =\n .title = Paste before the first page\npdfjs-views-manager-paste-button-after =\n .title = Paste after page { $page }\npdfjs-new-badge-content = NEW\npdfjs-views-manager-waiting-for-file = Uploading file…\npdfjs-digital-signature-properties-button =\n .title = Digital signature properties\n .aria-label = Digital signature properties\npdfjs-digital-signature-properties-button-label = Digital signature properties\npdfjs-digital-signature-properties-banner-verified = Document was signed with a valid digital signature\npdfjs-digital-signature-properties-banner-unknown =\n { $count ->\n [one] Document signed but { $count } digital signature could not be verified\n *[other] Document signed but { $count } digital signatures could not be verified\n }\npdfjs-digital-signature-properties-banner-untrusted =\n { $count ->\n [one] Document signed with { $count } certificate that is not trusted\n *[other] Document signed with { $count } certificates that are not trusted\n }\npdfjs-digital-signature-properties-banner-expired =\n { $count ->\n [one] Document signed with { $count } expired certificate\n *[other] Document signed with { $count } expired certificates\n }\npdfjs-digital-signature-properties-banner-invalid =\n { $count ->\n [one] Document has { $count } invalid digital signature\n *[other] Document has { $count } invalid digital signatures\n }\npdfjs-digital-signature-properties-banner-revoked =\n { $count ->\n [one] Document signed with { $count } revoked certificate\n *[other] Document signed with { $count } revoked certificates\n }\npdfjs-digital-signature-properties-status-verified = Status: Signature verified\npdfjs-digital-signature-properties-status-invalid = Status: Signature invalid\npdfjs-digital-signature-properties-status-unknown = Status: Unable to verify (unsupported)\npdfjs-digital-signature-properties-certificate-trusted = Certificate: Trusted ({ $issuer })\npdfjs-digital-signature-properties-certificate-unknown = Certificate: Unavailable\npdfjs-digital-signature-properties-certificate-untrusted = Certificate: Untrusted\npdfjs-digital-signature-properties-certificate-untrusted-unknown-issuer = Certificate: Unknown issuer ({ $issuer })\npdfjs-digital-signature-properties-certificate-untrusted-self-signed = Certificate: Self-signed ({ $issuer })\npdfjs-digital-signature-properties-certificate-untrusted-untrusted-issuer = Certificate: Untrusted issuer ({ $issuer })\npdfjs-digital-signature-properties-certificate-expired = Certificate: Expired\npdfjs-digital-signature-properties-certificate-expired-with-date = Certificate: Expired ({ DATETIME($dateObj, dateStyle: "medium") })\npdfjs-digital-signature-properties-certificate-revoked = Certificate: Revoked\npdfjs-digital-signature-properties-view-certificate = View certificate\npdfjs-digital-signature-properties-reason = Reason: { $reason }\npdfjs-digital-signature-properties-timestamp = Timestamp: { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-digital-signature-properties-sub-signatures =\n { $count ->\n [one] Sub-signature ({ $count })\n *[other] Sub-signatures ({ $count })\n }')}class GenericScripting{constructor(e,t){"Function"===e?.constructor?.name&&(e=e());this._ready=new Promise((i,a)=>{import(
/*webpackIgnore: true*/
/*@vite-ignore*/
e).then(e=>{i(e.QuickJSSandbox(new URL(t,location.href).href))}).catch(a)})}async createSandbox(e){(await this._ready).create(e)}async dispatchEventInSandbox(e){const t=await this._ready;setTimeout(()=>t.dispatchEvent(e),0)}async destroySandbox(){(await this._ready).nukeSandbox()}}function generic_signature_storage_classPrivateFieldInitSpec(e,t,i){generic_signature_storage_checkPrivateRedeclaration(e,t),t.set(e,i)}function generic_signature_storage_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function generic_signature_storage_classPrivateFieldGet(e,t){return e.get(generic_signature_storage_assertClassBrand(e,t))}function generic_signature_storage_classPrivateFieldSet(e,t,i){return e.set(generic_signature_storage_assertClassBrand(e,t),i),i}function generic_signature_storage_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Eu="pdfjs.signature";var Au=new WeakMap,Gu=new WeakMap,Bu=new WeakMap,Mu=new WeakSet;class SignatureStorage{constructor(e,t){!function generic_signature_storage_classPrivateMethodInitSpec(e,t){generic_signature_storage_checkPrivateRedeclaration(e,t),t.add(e)}(this,Mu);generic_signature_storage_classPrivateFieldInitSpec(this,Au,void 0);generic_signature_storage_classPrivateFieldInitSpec(this,Gu,null);generic_signature_storage_classPrivateFieldInitSpec(this,Bu,null);generic_signature_storage_classPrivateFieldSet(Au,this,e);generic_signature_storage_classPrivateFieldSet(Bu,this,t)}async getAll(){if(generic_signature_storage_classPrivateFieldGet(Bu,this)){window.addEventListener("storage",({key:e})=>{if(e===Eu){generic_signature_storage_classPrivateFieldSet(Gu,this,null);generic_signature_storage_classPrivateFieldGet(Au,this)?.dispatch("storedsignatureschanged",{source:this})}},{signal:generic_signature_storage_classPrivateFieldGet(Bu,this)});generic_signature_storage_classPrivateFieldSet(Bu,this,null)}if(!generic_signature_storage_classPrivateFieldGet(Gu,this)){generic_signature_storage_classPrivateFieldSet(Gu,this,new Map);const e=localStorage.getItem(Eu);if(e)for(const[t,i]of Object.entries(JSON.parse(e)))generic_signature_storage_classPrivateFieldGet(Gu,this).set(t,i)}return generic_signature_storage_classPrivateFieldGet(Gu,this)}async isFull(){return 5===await this.size()}async size(){return(await this.getAll()).size}async create(e){if(await this.isFull())return null;const t=getUuid();generic_signature_storage_classPrivateFieldGet(Gu,this).set(t,e);generic_signature_storage_assertClassBrand(Mu,this,_save).call(this);return t}async delete(e){const t=await this.getAll();if(!t.has(e))return!1;t.delete(e);generic_signature_storage_assertClassBrand(Mu,this,_save).call(this);return!0}}function _save(){localStorage.setItem(Eu,JSON.stringify(Object.fromEntries(generic_signature_storage_classPrivateFieldGet(Gu,this))))}class ExternalServices extends BaseExternalServices{constructor(){super()}async createL10n(){return new genericl10n_GenericL10n(AppOptions.get("localeProperties")?.lang)}createScripting(){return new GenericScripting(AppOptions.get("sandboxBundleSrc"),AppOptions.get("wasmUrl"))}createSignatureStorage(e,t){return new SignatureStorage(e,t)}createSignatureVerifier(){return null}}0;function new_alt_text_manager_classPrivateMethodInitSpec(e,t){new_alt_text_manager_checkPrivateRedeclaration(e,t),t.add(e)}function new_alt_text_manager_classPrivateFieldInitSpec(e,t,i){new_alt_text_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function new_alt_text_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function new_alt_text_manager_toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function new_alt_text_manager_classPrivateFieldGet(e,t){return e.get(new_alt_text_manager_assertClassBrand(e,t))}function new_alt_text_manager_classPrivateFieldSet(e,t,i){return e.set(new_alt_text_manager_assertClassBrand(e,t),i),i}function new_alt_text_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Iu=new WeakMap,Tu=new WeakMap,Du=new WeakMap,Lu=new WeakMap,Nu=new WeakMap,Ru=new WeakMap,Ou=new WeakMap,Wu=new WeakMap,ju=new WeakMap,Vu=new WeakMap,Uu=new WeakMap,zu=new WeakMap,Hu=new WeakMap,$u=new WeakMap,Ku=new WeakMap,Xu=new WeakMap,qu=new WeakMap,Yu=new WeakMap,Zu=new WeakMap,Qu=new WeakMap,Ju=new WeakMap,e_=new WeakMap,t_=new WeakMap,i_=new WeakMap,a_=new WeakMap,s_=new WeakSet;class NewAltTextManager{constructor({descriptionContainer:e,dialog:t,imagePreview:i,cancelButton:a,disclaimer:s,notNowButton:n,saveButton:r,textarea:o,learnMore:l,errorCloseButton:d,createAutomaticallyButton:c,downloadModel:h,downloadModelDescription:u,title:_},p,g){new_alt_text_manager_classPrivateMethodInitSpec(this,s_);new_alt_text_manager_classPrivateFieldInitSpec(this,Iu,new_alt_text_manager_assertClassBrand(s_,this,_cancel).bind(this));new_alt_text_manager_classPrivateFieldInitSpec(this,Tu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Du,null);new_alt_text_manager_classPrivateFieldInitSpec(this,Lu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Nu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Ru,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Ou,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Wu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,ju,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Vu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Uu,!1);new_alt_text_manager_classPrivateFieldInitSpec(this,zu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Hu,null);new_alt_text_manager_classPrivateFieldInitSpec(this,$u,null);new_alt_text_manager_classPrivateFieldInitSpec(this,Ku,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Xu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,qu,!1);new_alt_text_manager_classPrivateFieldInitSpec(this,Yu,!1);new_alt_text_manager_classPrivateFieldInitSpec(this,Zu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Qu,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,Ju,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,e_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,t_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,i_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,a_,null);new_alt_text_manager_classPrivateFieldSet(Lu,this,a);new_alt_text_manager_classPrivateFieldSet(Tu,this,c);new_alt_text_manager_classPrivateFieldSet(Nu,this,e);new_alt_text_manager_classPrivateFieldSet(Ru,this,t);new_alt_text_manager_classPrivateFieldSet(Ou,this,s);new_alt_text_manager_classPrivateFieldSet(Qu,this,n);new_alt_text_manager_classPrivateFieldSet(Ku,this,i);new_alt_text_manager_classPrivateFieldSet(e_,this,o);new_alt_text_manager_classPrivateFieldSet(Zu,this,l);new_alt_text_manager_classPrivateFieldSet(t_,this,_);new_alt_text_manager_classPrivateFieldSet(Wu,this,h);new_alt_text_manager_classPrivateFieldSet(ju,this,u);new_alt_text_manager_classPrivateFieldSet(Ju,this,p);new_alt_text_manager_classPrivateFieldSet(Vu,this,g);t.addEventListener("close",new_alt_text_manager_assertClassBrand(s_,this,_close).bind(this));t.addEventListener("contextmenu",e=>{e.target!==new_alt_text_manager_classPrivateFieldGet(e_,this)&&e.preventDefault()});a.addEventListener("click",new_alt_text_manager_classPrivateFieldGet(Iu,this));n.addEventListener("click",new_alt_text_manager_classPrivateFieldGet(Iu,this));r.addEventListener("click",new_alt_text_manager_assertClassBrand(s_,this,new_alt_text_manager_save).bind(this));d.addEventListener("click",()=>{new_alt_text_manager_assertClassBrand(s_,this,_toggleError).call(this,!1)});c.addEventListener("click",async()=>{const e="true"!==c.getAttribute("aria-pressed");new_alt_text_manager_classPrivateFieldGet(Du,this)._reportTelemetry({action:"pdfjs.image.alt_text.ai_generation_check",data:{status:e}});if(new_alt_text_manager_classPrivateFieldGet(i_,this)){const t=await new_alt_text_manager_classPrivateFieldGet(i_,this).mlManager.isEnabledFor("altText");new_alt_text_manager_classPrivateFieldGet(Tu,this).disabled=!0;if(e&&!t){new_alt_text_manager_classPrivateFieldGet(e_,this).value="";new_alt_text_manager_assertClassBrand(s_,this,_setProgress).call(this);new_alt_text_manager_classPrivateFieldGet(i_,this).setPreference("enableGuessAltText",!0);await new_alt_text_manager_classPrivateFieldGet(i_,this).mlManager.downloadModel("altText");new_alt_text_manager_assertClassBrand(s_,this,_setPref).call(this,"enableAltTextModelDownload",!0)}else if(!e&&t){new_alt_text_manager_classPrivateFieldGet(i_,this).setPreference("enableGuessAltText",!1);await new_alt_text_manager_classPrivateFieldGet(i_,this).mlManager.deleteModel("altText");new_alt_text_manager_assertClassBrand(s_,this,_setPref).call(this,"enableAltTextModelDownload",!1)}new_alt_text_manager_classPrivateFieldGet(Tu,this).disabled=!1;await new_alt_text_manager_classPrivateFieldGet(i_,this).mlManager.toggleService("altText",e)}new_alt_text_manager_assertClassBrand(s_,this,_toggleGuessAltText).call(this,e,!1)});o.addEventListener("focus",()=>{new_alt_text_manager_classPrivateFieldSet(Yu,this,new_alt_text_manager_classPrivateFieldGet(qu,this));new_alt_text_manager_assertClassBrand(s_,this,_toggleLoading).call(this,!1);new_alt_text_manager_assertClassBrand(s_,this,_toggleTitleAndDisclaimer).call(this)});o.addEventListener("blur",()=>{o.value||new_alt_text_manager_assertClassBrand(s_,this,_toggleLoading).call(this,new_alt_text_manager_classPrivateFieldGet(Yu,this));new_alt_text_manager_assertClassBrand(s_,this,_toggleTitleAndDisclaimer).call(this)});o.addEventListener("input",()=>{new_alt_text_manager_assertClassBrand(s_,this,_toggleTitleAndDisclaimer).call(this)});o.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||r.disabled||new_alt_text_manager_assertClassBrand(s_,this,new_alt_text_manager_save).call(this)});g.on("enableguessalttext",({value:e})=>{new_alt_text_manager_assertClassBrand(s_,this,_toggleGuessAltText).call(this,e,!1)},Nh);new_alt_text_manager_classPrivateFieldGet(Ju,this).register(t);new_alt_text_manager_classPrivateFieldGet(Zu,this).addEventListener("click",()=>{new_alt_text_manager_classPrivateFieldGet(Du,this)._reportTelemetry({action:"pdfjs.image.alt_text.info",data:{topic:"alt_text"}})})}async editAltText(e,t,i){if(new_alt_text_manager_classPrivateFieldGet(Du,this)||!t)return;if(i&&t.hasAltTextData()){t.altTextFinish();return}new_alt_text_manager_classPrivateFieldSet(Uu,this,i);const{mlManager:a}=e,s=!!a;new_alt_text_manager_assertClassBrand(s_,this,_toggleTitleAndDisclaimer).call(this);a&&!a.isReady("altText")?a.hasProgress?new_alt_text_manager_assertClassBrand(s_,this,_setProgress).call(this):new_alt_text_manager_classPrivateFieldGet(Tu,this).setAttribute("aria-pressed",!1):new_alt_text_manager_classPrivateFieldGet(Wu,this).classList.toggle("hidden",!0);const n=a?.isEnabledFor("altText");new_alt_text_manager_classPrivateFieldSet(Du,this,t);new_alt_text_manager_classPrivateFieldSet(i_,this,e);new_alt_text_manager_classPrivateFieldGet(i_,this).removeEditListeners();({altText:new_alt_text_manager_toSetter(new_alt_text_manager_classPrivateFieldSet,[a_,this])._}=t.altTextData);new_alt_text_manager_classPrivateFieldGet(e_,this).value=new_alt_text_manager_classPrivateFieldGet(a_,this)??"";let r,o,l;if(a){({canvas:r,width:o,height:l,imageData:new_alt_text_manager_toSetter(new_alt_text_manager_classPrivateFieldSet,[Xu,this])._}=t.copyCanvas(224,180,!0));s&&new_alt_text_manager_assertClassBrand(s_,this,_toggleGuessAltText).call(this,await n,!0)}else({canvas:r,width:o,height:l}=t.copyCanvas(224,180,!1));r.setAttribute("role","presentation");const{style:d}=r;d.width=`${o}px`;d.height=`${l}px`;new_alt_text_manager_classPrivateFieldGet(Ku,this).append(r);new_alt_text_manager_assertClassBrand(s_,this,_toggleNotNow).call(this);new_alt_text_manager_assertClassBrand(s_,this,_toggleAI).call(this,s);new_alt_text_manager_assertClassBrand(s_,this,_toggleError).call(this,!1);try{await new_alt_text_manager_classPrivateFieldGet(Ju,this).open(new_alt_text_manager_classPrivateFieldGet(Ru,this))}catch(e){new_alt_text_manager_assertClassBrand(s_,this,_close).call(this);throw e}}destroy(){new_alt_text_manager_classPrivateFieldSet(i_,this,null);new_alt_text_manager_assertClassBrand(s_,this,_finish).call(this)}}function _setPref(e,t){new_alt_text_manager_classPrivateFieldGet(Vu,this).dispatch("setpreference",{source:this,name:e,value:t})}function _toggleLoading(e){if(new_alt_text_manager_classPrivateFieldGet(i_,this)&&new_alt_text_manager_classPrivateFieldGet(qu,this)!==e){new_alt_text_manager_classPrivateFieldSet(qu,this,e);new_alt_text_manager_classPrivateFieldGet(Nu,this).classList.toggle("loading",e)}}function _toggleError(e){new_alt_text_manager_classPrivateFieldGet(i_,this)&&new_alt_text_manager_classPrivateFieldGet(Ru,this).classList.toggle("error",e)}async function _toggleGuessAltText(e,t){if(new_alt_text_manager_classPrivateFieldGet(i_,this)){new_alt_text_manager_classPrivateFieldGet(Ru,this).classList.toggle("aiDisabled",!e);new_alt_text_manager_classPrivateFieldGet(Tu,this).setAttribute("aria-pressed",e);if(e){const{altTextLearnMoreUrl:e}=new_alt_text_manager_classPrivateFieldGet(i_,this).mlManager;e&&(new_alt_text_manager_classPrivateFieldGet(Zu,this).href=e);new_alt_text_manager_assertClassBrand(s_,this,_mlGuessAltText).call(this,t)}else{new_alt_text_manager_assertClassBrand(s_,this,_toggleLoading).call(this,!1);new_alt_text_manager_classPrivateFieldSet(qu,this,!1);new_alt_text_manager_assertClassBrand(s_,this,_toggleTitleAndDisclaimer).call(this)}}}function _toggleNotNow(){new_alt_text_manager_classPrivateFieldGet(Qu,this).classList.toggle("hidden",!new_alt_text_manager_classPrivateFieldGet(Uu,this));new_alt_text_manager_classPrivateFieldGet(Lu,this).classList.toggle("hidden",new_alt_text_manager_classPrivateFieldGet(Uu,this))}function _toggleAI(e){if(new_alt_text_manager_classPrivateFieldGet(i_,this)&&new_alt_text_manager_classPrivateFieldGet(Hu,this)!==e){new_alt_text_manager_classPrivateFieldSet(Hu,this,e);new_alt_text_manager_classPrivateFieldGet(Ru,this).classList.toggle("noAi",!e);new_alt_text_manager_assertClassBrand(s_,this,_toggleTitleAndDisclaimer).call(this)}}function _toggleTitleAndDisclaimer(){const e=new_alt_text_manager_classPrivateFieldGet(qu,this)||new_alt_text_manager_classPrivateFieldGet(zu,this)&&new_alt_text_manager_classPrivateFieldGet(zu,this)===new_alt_text_manager_classPrivateFieldGet(e_,this).value;new_alt_text_manager_classPrivateFieldGet(Ou,this).hidden=!e;const t=new_alt_text_manager_classPrivateFieldGet(qu,this)||!!new_alt_text_manager_classPrivateFieldGet(e_,this).value;if(new_alt_text_manager_classPrivateFieldGet($u,this)!==t){new_alt_text_manager_classPrivateFieldSet($u,this,t);new_alt_text_manager_classPrivateFieldGet(t_,this).setAttribute("data-l10n-id",t?"pdfjs-editor-new-alt-text-dialog-edit-label":"pdfjs-editor-new-alt-text-dialog-add-label")}}async function _mlGuessAltText(e){if(new_alt_text_manager_classPrivateFieldGet(qu,this))return;if(new_alt_text_manager_classPrivateFieldGet(e_,this).value)return;if(e&&null!==new_alt_text_manager_classPrivateFieldGet(a_,this))return;new_alt_text_manager_classPrivateFieldSet(zu,this,new_alt_text_manager_classPrivateFieldGet(Du,this).guessedAltText);if(null===new_alt_text_manager_classPrivateFieldGet(a_,this)&&new_alt_text_manager_classPrivateFieldGet(zu,this)){new_alt_text_manager_assertClassBrand(s_,this,_addAltText).call(this,new_alt_text_manager_classPrivateFieldGet(zu,this));return}new_alt_text_manager_assertClassBrand(s_,this,_toggleLoading).call(this,!0);new_alt_text_manager_assertClassBrand(s_,this,_toggleTitleAndDisclaimer).call(this);let t=!1;try{const e=await new_alt_text_manager_classPrivateFieldGet(Du,this).mlGuessAltText(new_alt_text_manager_classPrivateFieldGet(Xu,this),!1);if(e){new_alt_text_manager_classPrivateFieldSet(zu,this,e);new_alt_text_manager_classPrivateFieldSet(Yu,this,new_alt_text_manager_classPrivateFieldGet(qu,this));new_alt_text_manager_classPrivateFieldGet(qu,this)&&new_alt_text_manager_assertClassBrand(s_,this,_addAltText).call(this,e)}}catch(e){console.error(e);t=!0}new_alt_text_manager_assertClassBrand(s_,this,_toggleLoading).call(this,!1);new_alt_text_manager_assertClassBrand(s_,this,_toggleTitleAndDisclaimer).call(this);t&&new_alt_text_manager_classPrivateFieldGet(i_,this)&&new_alt_text_manager_assertClassBrand(s_,this,_toggleError).call(this,!0)}function _addAltText(e){if(new_alt_text_manager_classPrivateFieldGet(i_,this)&&!new_alt_text_manager_classPrivateFieldGet(e_,this).value){new_alt_text_manager_classPrivateFieldGet(e_,this).value=e;new_alt_text_manager_assertClassBrand(s_,this,_toggleTitleAndDisclaimer).call(this)}}function _setProgress(){new_alt_text_manager_classPrivateFieldGet(Wu,this).classList.toggle("hidden",!1);const callback=async({detail:{finished:e,total:t,totalLoaded:i}})=>{const a=1e6;i=Math.min(.99*t,i);const s=new_alt_text_manager_classPrivateFieldGet(ju,this).ariaValueMax=Math.round(t/a),n=new_alt_text_manager_classPrivateFieldGet(ju,this).ariaValueNow=Math.round(i/a);new_alt_text_manager_classPrivateFieldGet(ju,this).setAttribute("data-l10n-args",JSON.stringify({totalSize:s,downloadedSize:n}));if(!e)return;new_alt_text_manager_classPrivateFieldGet(Vu,this).off("loadaiengineprogress",callback);new_alt_text_manager_classPrivateFieldGet(Wu,this).classList.toggle("hidden",!0);new_alt_text_manager_assertClassBrand(s_,this,_toggleAI).call(this,!0);if(!new_alt_text_manager_classPrivateFieldGet(i_,this))return;const{mlManager:r}=new_alt_text_manager_classPrivateFieldGet(i_,this);r.toggleService("altText",!0);new_alt_text_manager_assertClassBrand(s_,this,_toggleGuessAltText).call(this,await r.isEnabledFor("altText"),!0)};new_alt_text_manager_classPrivateFieldGet(Vu,this).on("loadaiengineprogress",callback,Nh)}function _cancel(){new_alt_text_manager_classPrivateFieldGet(Du,this).altTextData={cancel:!0};const e=new_alt_text_manager_classPrivateFieldGet(e_,this).value.trim();new_alt_text_manager_classPrivateFieldGet(Du,this)._reportTelemetry({action:"pdfjs.image.alt_text.dismiss",data:{alt_text_type:e?"present":"empty",flow:new_alt_text_manager_classPrivateFieldGet(Uu,this)?"image_add":"alt_text_edit"}});new_alt_text_manager_classPrivateFieldGet(Du,this)._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!0,alt_text_type:"skipped"}});new_alt_text_manager_assertClassBrand(s_,this,_finish).call(this)}function _finish(){new_alt_text_manager_classPrivateFieldGet(Ju,this).closeIfActive(new_alt_text_manager_classPrivateFieldGet(Ru,this))}function _close(){const e=new_alt_text_manager_classPrivateFieldGet(Ku,this).firstElementChild;e.remove();e.width=e.height=0;new_alt_text_manager_classPrivateFieldSet(Xu,this,null);new_alt_text_manager_assertClassBrand(s_,this,_toggleLoading).call(this,!1);new_alt_text_manager_classPrivateFieldGet(i_,this)?.addEditListeners();new_alt_text_manager_classPrivateFieldGet(Du,this).altTextFinish();new_alt_text_manager_classPrivateFieldGet(i_,this)?.setSelected(new_alt_text_manager_classPrivateFieldGet(Du,this));new_alt_text_manager_classPrivateFieldSet(Du,this,null);new_alt_text_manager_classPrivateFieldSet(i_,this,null)}function _extractWords(e){return new Set(e.toLowerCase().split(/[^\p{L}\p{N}]+/gu).filter(e=>!!e))}function new_alt_text_manager_save(){const e=new_alt_text_manager_classPrivateFieldGet(e_,this).value.trim();new_alt_text_manager_classPrivateFieldGet(Du,this).altTextData={altText:e,decorative:!1};new_alt_text_manager_classPrivateFieldGet(Du,this).altTextData.guessedAltText=new_alt_text_manager_classPrivateFieldGet(zu,this);if(new_alt_text_manager_classPrivateFieldGet(zu,this)&&new_alt_text_manager_classPrivateFieldGet(zu,this)!==e){const t=new_alt_text_manager_assertClassBrand(s_,this,_extractWords).call(this,new_alt_text_manager_classPrivateFieldGet(zu,this)),i=new_alt_text_manager_assertClassBrand(s_,this,_extractWords).call(this,e);new_alt_text_manager_classPrivateFieldGet(Du,this)._reportTelemetry({action:"pdfjs.image.alt_text.user_edit",data:{total_words:t.size,words_removed:t.difference(i).size,words_added:i.difference(t).size}})}new_alt_text_manager_classPrivateFieldGet(Du,this)._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!0,alt_text_type:e?"present":"empty"}});new_alt_text_manager_classPrivateFieldGet(Du,this)._reportTelemetry({action:"pdfjs.image.alt_text.save",data:{alt_text_type:e?"present":"empty",flow:new_alt_text_manager_classPrivateFieldGet(Uu,this)?"image_add":"alt_text_edit"}});new_alt_text_manager_assertClassBrand(s_,this,_finish).call(this)}var n_=new WeakMap,r_=new WeakMap,o_=new WeakMap,l_=new WeakMap,d_=new WeakMap,c_=new WeakMap,h_=new WeakSet;class ImageAltTextSettings{constructor({dialog:e,createModelButton:t,learnMore:i,closeButton:a,showAltTextDialogButton:s},n,r,o){new_alt_text_manager_classPrivateMethodInitSpec(this,h_);new_alt_text_manager_classPrivateFieldInitSpec(this,n_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,r_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,o_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,l_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,d_,void 0);new_alt_text_manager_classPrivateFieldInitSpec(this,c_,void 0);new_alt_text_manager_classPrivateFieldSet(r_,this,e);new_alt_text_manager_classPrivateFieldSet(n_,this,t);new_alt_text_manager_classPrivateFieldSet(c_,this,s);new_alt_text_manager_classPrivateFieldSet(d_,this,n);new_alt_text_manager_classPrivateFieldSet(o_,this,r);new_alt_text_manager_classPrivateFieldSet(l_,this,o);const{altTextLearnMoreUrl:l}=o;l&&(i.href=l);e.addEventListener("contextmenu",noContextMenu);t.addEventListener("click",async e=>{const t=new_alt_text_manager_assertClassBrand(h_,this,_togglePref).call(this,"enableGuessAltText",e);await(t?new_alt_text_manager_assertClassBrand(h_,this,new_alt_text_manager_download).call(this,!0):new_alt_text_manager_assertClassBrand(h_,this,_delete).call(this,!0));await o.toggleService("altText",t);new_alt_text_manager_assertClassBrand(h_,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.settings_ai_generation_check",data:{status:t}})});s.addEventListener("click",e=>{const t=new_alt_text_manager_assertClassBrand(h_,this,_togglePref).call(this,"enableNewAltTextWhenAddingImage",e);new_alt_text_manager_assertClassBrand(h_,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.settings_edit_alt_text_check",data:{status:t}})});a.addEventListener("click",new_alt_text_manager_assertClassBrand(h_,this,_finish2).bind(this));i.addEventListener("click",()=>{new_alt_text_manager_assertClassBrand(h_,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.info",data:{topic:"ai_generation"}})});r.on("enablealttextmodeldownload",({value:e})=>{e?new_alt_text_manager_assertClassBrand(h_,this,new_alt_text_manager_download).call(this,!1):new_alt_text_manager_assertClassBrand(h_,this,_delete).call(this,!1)},Nh);new_alt_text_manager_classPrivateFieldGet(d_,this).register(e)}async open({enableGuessAltText:e,enableNewAltTextWhenAddingImage:t}){const{enableAltTextModelDownload:i}=new_alt_text_manager_classPrivateFieldGet(l_,this);new_alt_text_manager_classPrivateFieldGet(n_,this).setAttribute("aria-pressed",i&&e);new_alt_text_manager_classPrivateFieldGet(c_,this).setAttribute("aria-pressed",t);await new_alt_text_manager_classPrivateFieldGet(d_,this).open(new_alt_text_manager_classPrivateFieldGet(r_,this));new_alt_text_manager_assertClassBrand(h_,this,_reportTelemetry).call(this,{type:"stamp",action:"pdfjs.image.alt_text.settings_displayed"})}}function _reportTelemetry(e){new_alt_text_manager_classPrivateFieldGet(o_,this).dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}async function new_alt_text_manager_download(e=!1){if(e){await new_alt_text_manager_classPrivateFieldGet(l_,this).downloadModel("altText");new_alt_text_manager_assertClassBrand(h_,this,_setPref2).call(this,"enableGuessAltText",!0);new_alt_text_manager_classPrivateFieldGet(l_,this).toggleService("altText",!0);new_alt_text_manager_assertClassBrand(h_,this,_setPref2).call(this,"enableAltTextModelDownload",!0)}}async function _delete(e=!1){if(e){await new_alt_text_manager_classPrivateFieldGet(l_,this).deleteModel("altText");new_alt_text_manager_assertClassBrand(h_,this,_setPref2).call(this,"enableGuessAltText",!1);new_alt_text_manager_assertClassBrand(h_,this,_setPref2).call(this,"enableAltTextModelDownload",!1)}new_alt_text_manager_classPrivateFieldGet(n_,this).setAttribute("aria-pressed",!1)}function _togglePref(e,{target:t}){const i="true"!==t.getAttribute("aria-pressed");new_alt_text_manager_assertClassBrand(h_,this,_setPref2).call(this,e,i);t.setAttribute("aria-pressed",i);return i}function _setPref2(e,t){new_alt_text_manager_classPrivateFieldGet(o_,this).dispatch("setpreference",{source:this,name:e,value:t})}function _finish2(){new_alt_text_manager_classPrivateFieldGet(d_,this).closeIfActive(new_alt_text_manager_classPrivateFieldGet(r_,this))}function alt_text_manager_classPrivateFieldInitSpec(e,t,i){alt_text_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function alt_text_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function alt_text_manager_classPrivateFieldGet(e,t){return e.get(alt_text_manager_assertClassBrand(e,t))}function alt_text_manager_classPrivateFieldSet(e,t,i){return e.set(alt_text_manager_assertClassBrand(e,t),i),i}function alt_text_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var u_=new WeakMap,__=new WeakMap,p_=new WeakMap,g_=new WeakMap,m_=new WeakMap,f_=new WeakMap,v_=new WeakMap,P_=new WeakMap,w_=new WeakMap,F_=new WeakMap,b_=new WeakMap,y_=new WeakMap,S_=new WeakMap,C_=new WeakMap,x_=new WeakMap,k_=new WeakMap,E_=new WeakMap,A_=new WeakMap,G_=new WeakSet;class AltTextManager{constructor({dialog:e,optionDescription:t,optionDecorative:i,textarea:a,cancelButton:s,saveButton:n},r,o,l){!function alt_text_manager_classPrivateMethodInitSpec(e,t){alt_text_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,G_);alt_text_manager_classPrivateFieldInitSpec(this,u_,null);alt_text_manager_classPrivateFieldInitSpec(this,__,null);alt_text_manager_classPrivateFieldInitSpec(this,p_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,g_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,m_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,f_,!1);alt_text_manager_classPrivateFieldInitSpec(this,v_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,P_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,w_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,F_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,b_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,y_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,S_,null);alt_text_manager_classPrivateFieldInitSpec(this,C_,null);alt_text_manager_classPrivateFieldInitSpec(this,x_,null);alt_text_manager_classPrivateFieldInitSpec(this,k_,null);alt_text_manager_classPrivateFieldInitSpec(this,E_,void 0);alt_text_manager_classPrivateFieldInitSpec(this,A_,null);alt_text_manager_classPrivateFieldSet(g_,this,e);alt_text_manager_classPrivateFieldSet(v_,this,t);alt_text_manager_classPrivateFieldSet(P_,this,i);alt_text_manager_classPrivateFieldSet(b_,this,a);alt_text_manager_classPrivateFieldSet(p_,this,s);alt_text_manager_classPrivateFieldSet(F_,this,n);alt_text_manager_classPrivateFieldSet(w_,this,o);alt_text_manager_classPrivateFieldSet(m_,this,l);alt_text_manager_classPrivateFieldSet(E_,this,r);const d=alt_text_manager_assertClassBrand(G_,this,_updateUIState).bind(this);e.addEventListener("close",alt_text_manager_assertClassBrand(G_,this,alt_text_manager_close).bind(this));e.addEventListener("contextmenu",e=>{e.target!==alt_text_manager_classPrivateFieldGet(b_,this)&&e.preventDefault()});s.addEventListener("click",alt_text_manager_assertClassBrand(G_,this,alt_text_manager_finish).bind(this));n.addEventListener("click",alt_text_manager_assertClassBrand(G_,this,alt_text_manager_save).bind(this));t.addEventListener("change",d);i.addEventListener("change",d);a.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||n.disabled||alt_text_manager_assertClassBrand(G_,this,alt_text_manager_save).call(this)});alt_text_manager_classPrivateFieldGet(w_,this).register(e)}async editAltText(e,t){if(alt_text_manager_classPrivateFieldGet(__,this)||!t)return;alt_text_manager_assertClassBrand(G_,this,_createSVGElement).call(this);alt_text_manager_classPrivateFieldSet(f_,this,!1);alt_text_manager_classPrivateFieldSet(u_,this,new AbortController);const i={signal:alt_text_manager_classPrivateFieldGet(u_,this).signal},a=alt_text_manager_assertClassBrand(G_,this,_onClick).bind(this);for(const e of[alt_text_manager_classPrivateFieldGet(v_,this),alt_text_manager_classPrivateFieldGet(P_,this),alt_text_manager_classPrivateFieldGet(b_,this),alt_text_manager_classPrivateFieldGet(F_,this),alt_text_manager_classPrivateFieldGet(p_,this)])e.addEventListener("click",a,i);const{altText:s,decorative:n}=t.altTextData;if(!0===n){alt_text_manager_classPrivateFieldGet(P_,this).checked=!0;alt_text_manager_classPrivateFieldGet(v_,this).checked=!1}else{alt_text_manager_classPrivateFieldGet(P_,this).checked=!1;alt_text_manager_classPrivateFieldGet(v_,this).checked=!0}alt_text_manager_classPrivateFieldSet(S_,this,alt_text_manager_classPrivateFieldGet(b_,this).value=s?.trim()||"");alt_text_manager_assertClassBrand(G_,this,_updateUIState).call(this);alt_text_manager_classPrivateFieldSet(__,this,t);alt_text_manager_classPrivateFieldSet(y_,this,e);alt_text_manager_classPrivateFieldGet(y_,this).removeEditListeners();alt_text_manager_classPrivateFieldSet(C_,this,new AbortController);alt_text_manager_classPrivateFieldGet(m_,this).on("resize",alt_text_manager_assertClassBrand(G_,this,alt_text_manager_setPosition).bind(this),{signal:alt_text_manager_classPrivateFieldGet(C_,this).signal,...Nh});try{await alt_text_manager_classPrivateFieldGet(w_,this).open(alt_text_manager_classPrivateFieldGet(g_,this));alt_text_manager_assertClassBrand(G_,this,alt_text_manager_setPosition).call(this)}catch(e){alt_text_manager_assertClassBrand(G_,this,alt_text_manager_close).call(this);throw e}}destroy(){alt_text_manager_classPrivateFieldSet(y_,this,null);alt_text_manager_assertClassBrand(G_,this,alt_text_manager_finish).call(this);alt_text_manager_classPrivateFieldGet(x_,this)?.remove();alt_text_manager_classPrivateFieldSet(x_,this,alt_text_manager_classPrivateFieldSet(k_,this,null))}}function _createSVGElement(){if(alt_text_manager_classPrivateFieldGet(x_,this))return;const e=new DOMSVGFactory,t=alt_text_manager_classPrivateFieldSet(x_,this,e.createElement("svg"));t.setAttribute("width","0");t.setAttribute("height","0");const i=e.createElement("defs");t.append(i);const a=e.createElement("mask");i.append(a);a.setAttribute("id","alttext-manager-mask");a.setAttribute("maskContentUnits","objectBoundingBox");let s=e.createElement("rect");a.append(s);s.setAttribute("fill","white");s.setAttribute("width","1");s.setAttribute("height","1");s.setAttribute("x","0");s.setAttribute("y","0");s=alt_text_manager_classPrivateFieldSet(k_,this,e.createElement("rect"));a.append(s);s.setAttribute("fill","black");alt_text_manager_classPrivateFieldGet(g_,this).append(t)}function alt_text_manager_setPosition(){if(!alt_text_manager_classPrivateFieldGet(__,this))return;const e=alt_text_manager_classPrivateFieldGet(g_,this),{style:t}=e,{x:i,y:a,width:s,height:n}=alt_text_manager_classPrivateFieldGet(E_,this).getBoundingClientRect(),{innerWidth:r,innerHeight:o}=window,{width:l,height:d}=e.getBoundingClientRect(),{x:c,y:h,width:u,height:_}=alt_text_manager_classPrivateFieldGet(__,this).getClientDimensions(),p=10,g="ltr"===alt_text_manager_classPrivateFieldGet(y_,this).direction,m=Math.max(c,i),f=Math.min(c+u,i+s),v=Math.max(h,a),P=Math.min(h+_,a+n);alt_text_manager_classPrivateFieldGet(k_,this).setAttribute("width",""+(f-m)/r);alt_text_manager_classPrivateFieldGet(k_,this).setAttribute("height",""+(P-v)/o);alt_text_manager_classPrivateFieldGet(k_,this).setAttribute("x",""+m/r);alt_text_manager_classPrivateFieldGet(k_,this).setAttribute("y",""+v/o);let w=null,F=Math.max(h,0);F+=Math.min(o-(F+d),0);g?c+u+p+l<r?w=c+u+p:c>l+p&&(w=c-l-p):c>l+p?w=c-l-p:c+u+p+l<r&&(w=c+u+p);if(null===w){F=null;w=Math.max(c,0);w+=Math.min(r-(w+l),0);h>d+p?F=h-d-p:h+_+p+d<o&&(F=h+_+p)}if(null!==F){e.classList.add("positioned");g?t.left=`${w}px`:t.right=r-w-l+"px";t.top=`${F}px`}else{e.classList.remove("positioned");t.left="";t.top=""}}function alt_text_manager_finish(){alt_text_manager_classPrivateFieldGet(w_,this).closeIfActive(alt_text_manager_classPrivateFieldGet(g_,this))}function alt_text_manager_close(){alt_text_manager_classPrivateFieldGet(__,this)._reportTelemetry(alt_text_manager_classPrivateFieldGet(A_,this)||{action:"alt_text_cancel",alt_text_keyboard:!alt_text_manager_classPrivateFieldGet(f_,this)});alt_text_manager_classPrivateFieldSet(A_,this,null);alt_text_manager_assertClassBrand(G_,this,_removeOnClickListeners).call(this);alt_text_manager_classPrivateFieldGet(y_,this)?.addEditListeners();alt_text_manager_classPrivateFieldGet(C_,this)?.abort();alt_text_manager_classPrivateFieldSet(C_,this,null);alt_text_manager_classPrivateFieldGet(__,this).altTextFinish();alt_text_manager_classPrivateFieldSet(__,this,null);alt_text_manager_classPrivateFieldSet(y_,this,null)}function _updateUIState(){alt_text_manager_classPrivateFieldGet(b_,this).disabled=alt_text_manager_classPrivateFieldGet(P_,this).checked}function alt_text_manager_save(){const e=alt_text_manager_classPrivateFieldGet(b_,this).value.trim(),t=alt_text_manager_classPrivateFieldGet(P_,this).checked;alt_text_manager_classPrivateFieldGet(__,this).altTextData={altText:e,decorative:t};alt_text_manager_classPrivateFieldSet(A_,this,{action:"alt_text_save",alt_text_description:!!e,alt_text_edit:!!alt_text_manager_classPrivateFieldGet(S_,this)&&alt_text_manager_classPrivateFieldGet(S_,this)!==e,alt_text_decorative:t,alt_text_keyboard:!alt_text_manager_classPrivateFieldGet(f_,this)});alt_text_manager_assertClassBrand(G_,this,alt_text_manager_finish).call(this)}function _onClick(e){if(0!==e.detail){alt_text_manager_classPrivateFieldSet(f_,this,!0);alt_text_manager_assertClassBrand(G_,this,_removeOnClickListeners).call(this)}}function _removeOnClickListeners(){alt_text_manager_classPrivateFieldGet(u_,this)?.abort();alt_text_manager_classPrivateFieldSet(u_,this,null)}function annotation_editor_params_classPrivateMethodInitSpec(e,t){(function annotation_editor_params_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}var B_,M_=new WeakSet;class AnnotationEditorParams{constructor(e,t){annotation_editor_params_classPrivateMethodInitSpec(this,M_);this.eventBus=t;(function annotation_editor_params_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")})(M_,this,_bindListeners).call(this,e)}}function _bindListeners({editorFreeTextFontSize:e,editorFreeTextColor:t,editorInkColor:i,editorInkThickness:a,editorInkOpacity:s,editorStampAddImage:n,editorFreeHighlightThickness:r,editorHighlightShowAll:o,editorSignatureAddSignature:l}){const{eventBus:d}=this,dispatchEvent=(e,t)=>{d.dispatch("switchannotationeditorparams",{source:this,type:v[e],value:t})};e.addEventListener("input",function(){dispatchEvent("FREETEXT_SIZE",this.valueAsNumber)});t.addEventListener("input",function(){dispatchEvent("FREETEXT_COLOR",this.value)});let c,h;if(FeatureTest.isAlphaColorInputSupported){i.setAttribute("alpha","");s.closest(".editorParamsSetter")?.remove();let e="#000000",t=1;i.addEventListener("input",function(){const i=getRGBA(this.value);if(!i)return;const[a,s,n,r]=i,o=Util.makeHexColor(a,s,n);e=o;t=r;dispatchEvent("INK_COLOR_AND_OPACITY",{color:o,opacity:r})});c=a=>{e=a;const s=Util.hexNums[Math.round(255*t)];i.value=e+s};h=a=>{t=a;const s=Util.hexNums[Math.round(255*t)];i.value=e+s}}else{i.addEventListener("input",function(){dispatchEvent("INK_COLOR",this.value)});s.addEventListener("input",function(){dispatchEvent("INK_OPACITY",this.valueAsNumber)});c=e=>{i.value=e};h=e=>{s.value=e}}a.addEventListener("input",function(){dispatchEvent("INK_THICKNESS",this.valueAsNumber)});n.addEventListener("click",()=>{d.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{action:"pdfjs.image.add_image_click"}}});dispatchEvent("CREATE")});r.addEventListener("input",function(){dispatchEvent("HIGHLIGHT_THICKNESS",this.valueAsNumber)});o.addEventListener("click",function(){const e="true"===this.getAttribute("aria-pressed");this.setAttribute("aria-pressed",!e);dispatchEvent("HIGHLIGHT_SHOW_ALL",!e)});l?.addEventListener("click",()=>{dispatchEvent("CREATE")});d.on("annotationeditorparamschanged",i=>{for(const[s,n]of i.details)switch(s){case v.FREETEXT_SIZE:e.value=n;break;case v.FREETEXT_COLOR:t.value=n;break;case v.INK_COLOR:c(n);break;case v.INK_THICKNESS:a.value=n;break;case v.INK_OPACITY:h(n);break;case v.HIGHLIGHT_COLOR:d.dispatch("mainhighlightcolorpickerupdatecolor",{source:this,value:n});break;case v.HIGHLIGHT_THICKNESS:r.value=n;break;case v.HIGHLIGHT_FREE:r.disabled=!n;break;case v.HIGHLIGHT_SHOW_ALL:o.setAttribute("aria-pressed",n)}},Nh)}function caret_browsing_classPrivateFieldInitSpec(e,t,i){caret_browsing_checkPrivateRedeclaration(e,t),t.set(e,i)}function caret_browsing_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function caret_browsing_classPrivateFieldGet(e,t){return e.get(caret_browsing_assertClassBrand(e,t))}function caret_browsing_classPrivateFieldSet(e,t,i){return e.set(caret_browsing_assertClassBrand(e,t),i),i}function caret_browsing_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const I_=.1;var T_=new WeakMap,D_=new WeakMap,L_=new WeakMap,N_=new WeakSet;class CaretBrowsingMode{constructor(e,t,i,a){!function caret_browsing_classPrivateMethodInitSpec(e,t){caret_browsing_checkPrivateRedeclaration(e,t),t.add(e)}(this,N_);caret_browsing_classPrivateFieldInitSpec(this,T_,void 0);caret_browsing_classPrivateFieldInitSpec(this,D_,0);caret_browsing_classPrivateFieldInitSpec(this,L_,void 0);caret_browsing_classPrivateFieldSet(T_,this,t);caret_browsing_classPrivateFieldSet(L_,this,i);if(!a)return;caret_browsing_classPrivateFieldSet(D_,this,a.getBoundingClientRect().height);const s=new ResizeObserver(e=>{for(const t of e)if(t.target===a){caret_browsing_classPrivateFieldSet(D_,this,Math.floor(t.borderBoxSize[0].blockSize));break}});s.observe(a);e.addEventListener("abort",()=>s.disconnect(),{once:!0})}moveCaret(e,t){const i=document.getSelection();if(0===i.rangeCount)return;const{focusNode:a}=i,s=a.nodeType!==Node.ELEMENT_NODE?a.parentElement:a,n=s.closest(".textLayer");if(!n)return;const r=document.createTreeWalker(n,NodeFilter.SHOW_TEXT);r.currentNode=a;const o=s.getBoundingClientRect();let l=null;const d=(e?r.previousSibling:r.nextSibling).bind(r);for(;d();){const e=r.currentNode.parentElement;if(!caret_browsing_assertClassBrand(N_,this,_isOnSameLine).call(this,o,e.getBoundingClientRect())){l=e;break}}if(!l){const s=caret_browsing_assertClassBrand(N_,this,_getNodeOnNextPage).call(this,n,e);if(!s)return;if(t){const t=(e?r.firstChild():r.lastChild())||a;i.extend(t,e?0:t.length);const n=document.createRange();n.setStart(s,e?s.length:0);n.setEnd(s,e?s.length:0);i.addRange(n);return}const[o]=caret_browsing_assertClassBrand(N_,this,_getCaretPosition).call(this,i,e),{parentElement:l}=s;caret_browsing_assertClassBrand(N_,this,_setCaretPosition).call(this,t,i,l,l.getBoundingClientRect(),o);return}const[c,h]=caret_browsing_assertClassBrand(N_,this,_getCaretPosition).call(this,i,e),u=l.getBoundingClientRect();if(caret_browsing_assertClassBrand(N_,this,_isUnderOver).call(this,u,c,h,e))caret_browsing_assertClassBrand(N_,this,_setCaretPosition).call(this,t,i,l,u,c);else{for(;d();){const a=r.currentNode.parentElement,s=a.getBoundingClientRect();if(!caret_browsing_assertClassBrand(N_,this,_isOnSameLine).call(this,u,s))break;if(caret_browsing_assertClassBrand(N_,this,_isUnderOver).call(this,s,c,h,e)){caret_browsing_assertClassBrand(N_,this,_setCaretPosition).call(this,t,i,a,s,c);return}}caret_browsing_assertClassBrand(N_,this,_setCaretPosition).call(this,t,i,l,u,c)}}}B_=CaretBrowsingMode;function _isOnSameLine(e,t){const i=e.y,a=e.bottom,s=e.y+e.height/2,n=t.y,r=t.bottom,o=t.y+t.height/2;return i<=o&&o<=a||n<=s&&s<=r}function _isUnderOver(e,t,i,a){const s=e.y+e.height/2;return(a?i>=s:i<=s)&&e.x-I_<=t&&t<=e.right+I_}function _isVisible(e){return e.top>=caret_browsing_classPrivateFieldGet(D_,this)&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function _getCaretPosition(e,t){const{focusNode:i,focusOffset:a}=e,s=document.createRange();s.setStart(i,a);s.setEnd(i,a);const n=s.getBoundingClientRect();return[n.x,t?n.top:n.bottom]}function _caretPositionFromPoint(e,t){if(!document.caretPositionFromPoint){const{startContainer:i,startOffset:a}=document.caretRangeFromPoint(e,t);return{offsetNode:i,offset:a}}return document.caretPositionFromPoint(e,t)}function _setCaretPositionHelper(e,t,i,a,s){s||=a.getBoundingClientRect();if(t<=s.x+I_){i?e.extend(a.firstChild,0):e.setPosition(a.firstChild,0);return}if(s.right-I_<=t){const{lastChild:t}=a;i?e.extend(t,t.length):e.setPosition(t,t.length);return}const n=s.y+s.height/2;let r=_caretPositionFromPoint.call(B_,t,n),o=r.offsetNode?.parentElement;if(o&&o!==a){const e=document.elementsFromPoint(t,n),i=[];for(const t of e){if(t===a)break;const{style:e}=t;i.push([t,e.visibility]);e.visibility="hidden"}r=_caretPositionFromPoint.call(B_,t,n);o=r.offsetNode?.parentElement;for(const[e,t]of i)e.style.visibility=t}o===a?i?e.extend(r.offsetNode,r.offset):e.setPosition(r.offsetNode,r.offset):i?e.extend(a.firstChild,0):e.setPosition(a.firstChild,0)}function _setCaretPosition(e,t,i,a,s){if(caret_browsing_assertClassBrand(N_,this,_isVisible).call(this,a))caret_browsing_assertClassBrand(N_,this,_setCaretPositionHelper).call(this,t,s,e,i,a);else{caret_browsing_classPrivateFieldGet(T_,this).addEventListener("scrollend",caret_browsing_assertClassBrand(N_,this,_setCaretPositionHelper).bind(this,t,s,e,i,null),{once:!0});i.scrollIntoView()}}function _getNodeOnNextPage(e,t){for(;;){const i=e.closest(".page"),a=parseInt(i.getAttribute("data-page-number"),10),s=t?a-1:a+1;if(!(e=caret_browsing_classPrivateFieldGet(L_,this).querySelector(`.page[data-page-number="${s}"] .textLayer`)))return null;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=t?n.lastChild():n.firstChild();if(r)return r}}function sidebar_classPrivateFieldInitSpec(e,t,i){sidebar_checkPrivateRedeclaration(e,t),t.set(e,i)}function sidebar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function sidebar_classPrivateFieldGet(e,t){return e.get(sidebar_assertClassBrand(e,t))}function sidebar_classPrivateFieldSet(e,t,i){return e.set(sidebar_assertClassBrand(e,t),i),i}function sidebar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var R_=new WeakMap,O_=new WeakMap,W_=new WeakMap,j_=new WeakMap,V_=new WeakMap,U_=new WeakMap,z_=new WeakMap,H_=new WeakMap,$_=new WeakMap,K_=new WeakSet;class Sidebar{constructor({sidebar:e,resizer:t,toggleButton:i},a,s,n){!function sidebar_classPrivateMethodInitSpec(e,t){sidebar_checkPrivateRedeclaration(e,t),t.add(e)}(this,K_);sidebar_classPrivateFieldInitSpec(this,R_,0);sidebar_classPrivateFieldInitSpec(this,O_,0);sidebar_classPrivateFieldInitSpec(this,W_,void 0);sidebar_classPrivateFieldInitSpec(this,j_,null);sidebar_classPrivateFieldInitSpec(this,V_,void 0);sidebar_classPrivateFieldInitSpec(this,U_,void 0);sidebar_classPrivateFieldInitSpec(this,z_,!1);sidebar_classPrivateFieldInitSpec(this,H_,void 0);sidebar_classPrivateFieldInitSpec(this,$_,0);if(!e){console.warn("[Sidebar] sidebar element is null, skipping initialization");this._sidebar=null;return}this._sidebar=e;sidebar_classPrivateFieldSet(W_,this,a===s?-1:1);sidebar_classPrivateFieldSet(V_,this,t);sidebar_classPrivateFieldSet(U_,this,s);const r=window.getComputedStyle(e);sidebar_classPrivateFieldSet(R_,this,sidebar_classPrivateFieldSet(O_,this,parseFloat(r.getPropertyValue("--sidebar-width"))));t.ariaValueMin=parseFloat(r.getPropertyValue("--sidebar-min-width"))||0;t.ariaValueMax=parseFloat(r.getPropertyValue("--sidebar-max-width"))||1/0;t.ariaValueNow=sidebar_classPrivateFieldGet(O_,this);sidebar_assertClassBrand(K_,this,_makeSidebarResizable).call(this);this._isOpen=!1;e.hidden=!0;n?.addEventListener("abort",this.destroy.bind(this),{once:!0});sidebar_classPrivateFieldSet(H_,this,new ResizeObserver(([{borderBoxSize:[{inlineSize:e}]}])=>{isNaN(sidebar_classPrivateFieldGet($_,this))||sidebar_classPrivateFieldSet($_,this,sidebar_classPrivateFieldGet($_,this)+sidebar_classPrivateFieldGet(W_,this)*(e-sidebar_classPrivateFieldGet(O_,this)));sidebar_assertClassBrand(K_,this,_setWidth).call(this,e)}));sidebar_classPrivateFieldGet(H_,this).observe(e)}get width(){return sidebar_classPrivateFieldGet(O_,this)}set width(e){this._sidebar&&(this._sidebar.style.width=`${e}px`)}onStartResizing(){}onStopResizing(){}onResizing(e){}toggle(e=!this._isOpen){this._sidebar&&(this._sidebar.hidden=!(this._isOpen=e))}destroy(){sidebar_classPrivateFieldGet(H_,this)?.disconnect();sidebar_classPrivateFieldSet(H_,this,null)}}function _makeSidebarResizable(){if(!this._sidebar)return;const e=this._sidebar.style;let t;const cancelResize=()=>{sidebar_classPrivateFieldSet(j_,this,null);this._sidebar.classList.remove("resizing");t?.abort();t=null;sidebar_classPrivateFieldSet(z_,this,!1);this.onStopResizing();sidebar_classPrivateFieldSet($_,this,NaN)};sidebar_classPrivateFieldGet(V_,this).addEventListener("pointerdown",i=>{if(t){cancelResize();return}this.onStartResizing();const{clientX:a}=i;stopEvent(i);sidebar_classPrivateFieldSet($_,this,a);t=new AbortController;const{signal:s}=t,n=this._sidebar;n.classList.add("resizing");n.parentElement.style.minWidth=0;window.addEventListener("contextmenu",noContextMenu,{signal:s});window.addEventListener("pointermove",i=>{if(t&&!(Math.abs(i.clientX-sidebar_classPrivateFieldGet($_,this))<1)){stopEvent(i);e.width=`${Math.round(sidebar_classPrivateFieldGet(O_,this)+sidebar_classPrivateFieldGet(W_,this)*(i.clientX-sidebar_classPrivateFieldGet($_,this)))}px`}},{signal:s,capture:!0});window.addEventListener("blur",cancelResize,{signal:s});window.addEventListener("pointerup",e=>{if(t){cancelResize();stopEvent(e)}},{signal:s})});sidebar_classPrivateFieldGet(V_,this).addEventListener("keydown",t=>{const{key:i}=t,a="ArrowLeft"===i;if(a||"ArrowRight"===i){if(!sidebar_classPrivateFieldGet(z_,this)){this._sidebar.classList.add("resizing");sidebar_classPrivateFieldSet(z_,this,!0);this.onStartResizing()}const i=(t.ctrlKey||t.metaKey?10:1)*(a?-1:1);clearTimeout(sidebar_classPrivateFieldGet(j_,this));sidebar_classPrivateFieldSet(j_,this,setTimeout(cancelResize,400));e.width=`${Math.round(sidebar_classPrivateFieldGet(O_,this)+sidebar_classPrivateFieldGet(W_,this)*i)}px`;stopEvent(t)}})}function _setWidth(e){sidebar_classPrivateFieldSet(O_,this,e);sidebar_classPrivateFieldGet(V_,this).ariaValueNow=Math.round(e);sidebar_classPrivateFieldGet(U_,this)&&this._sidebar?.parentElement&&(this._sidebar.parentElement.style.insetInlineStart=`${(sidebar_classPrivateFieldGet(R_,this)-e).toFixed(3)}px`);this.onResizing(e)}function comment_manager_classPrivateMethodInitSpec(e,t){comment_manager_checkPrivateRedeclaration(e,t),t.add(e)}function comment_manager_classPrivateFieldInitSpec(e,t,i){comment_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function comment_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function comment_manager_classPrivateFieldGet(e,t){return e.get(comment_manager_assertClassBrand(e,t))}function comment_manager_classPrivateFieldSet(e,t,i){return e.set(comment_manager_assertClassBrand(e,t),i),i}function comment_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var X_=new WeakMap,q_=new WeakMap,Y_=new WeakMap;class CommentManager{constructor(e,t,i,a,s,n,r,o){comment_manager_classPrivateFieldInitSpec(this,X_,void 0);comment_manager_classPrivateFieldInitSpec(this,q_,void 0);comment_manager_classPrivateFieldInitSpec(this,Y_,void 0);const l=new Intl.DateTimeFormat(void 0,{dateStyle:"long"});this.dialogElement=e.dialog;comment_manager_classPrivateFieldSet(X_,this,new CommentDialog(e,s,i,n));comment_manager_classPrivateFieldSet(q_,this,new CommentPopup(i,l,n,this.dialogElement));comment_manager_classPrivateFieldSet(Y_,this,new CommentSidebar(t,i,a,comment_manager_classPrivateFieldGet(q_,this),l,n,o));comment_manager_classPrivateFieldGet(q_,this).sidebar=comment_manager_classPrivateFieldGet(Y_,this);Z_._=r}setSidebarUiManager(e){comment_manager_classPrivateFieldGet(Y_,this).setUIManager(e)}showSidebar(e){comment_manager_classPrivateFieldGet(Y_,this).show(e)}hideSidebar(){comment_manager_classPrivateFieldGet(Y_,this).hide()}removeComments(e){comment_manager_classPrivateFieldGet(Y_,this).removeComments(e)}selectComment(e){comment_manager_classPrivateFieldGet(Y_,this).selectComment(null,e)}addComment(e){comment_manager_classPrivateFieldGet(Y_,this).addComment(e)}updateComment(e){comment_manager_classPrivateFieldGet(Y_,this).updateComment(e)}toggleCommentPopup(e,t,i,a){t&&this.selectComment(e.uid);comment_manager_classPrivateFieldGet(q_,this).toggle(e,t,i,a)}destroyPopup(){comment_manager_classPrivateFieldGet(q_,this).destroy()}updatePopupColor(e){comment_manager_classPrivateFieldGet(q_,this).updateColor(e)}showDialog(e,t,i,a,s){return comment_manager_classPrivateFieldGet(X_,this).open(e,t,i,a,s)}makeCommentColor(e,t){return CommentManager._makeCommentColor(e,t)}static _makeCommentColor(e,t){return comment_manager_assertClassBrand(CommentManager,this,Z_)._?null:findContrastColor(applyOpacity(e,t??1),CSSConstants.commentForegroundColor)}destroy(){comment_manager_classPrivateFieldGet(X_,this).destroy();comment_manager_classPrivateFieldGet(Y_,this).hide();comment_manager_classPrivateFieldGet(q_,this).destroy()}}var Z_={_:null},Q_=new WeakMap,J_=new WeakMap,ep=new WeakMap,tp=new WeakMap,ip=new WeakMap,ap=new WeakMap,sp=new WeakMap,np=new WeakMap,rp=new WeakMap,op=new WeakMap,lp=new WeakMap,dp=new WeakMap,cp=new WeakMap,hp=new WeakMap,up=new WeakMap,_p=new WeakSet;class CommentSidebar extends Sidebar{constructor({learnMoreUrl:e,sidebar:t,sidebarResizer:i,commentsList:a,commentCount:s,sidebarTitle:n,closeButton:r,commentToolbarButton:o},l,d,c,h,u,_){super({sidebar:t,resizer:i,toggleButton:o},u,!0,_);comment_manager_classPrivateMethodInitSpec(this,_p);comment_manager_classPrivateFieldInitSpec(this,Q_,null);comment_manager_classPrivateFieldInitSpec(this,J_,void 0);comment_manager_classPrivateFieldInitSpec(this,ep,comment_manager_assertClassBrand(_p,this,_commentClick).bind(this));comment_manager_classPrivateFieldInitSpec(this,tp,comment_manager_assertClassBrand(_p,this,_commentKeydown).bind(this));comment_manager_classPrivateFieldInitSpec(this,ip,void 0);comment_manager_classPrivateFieldInitSpec(this,ap,void 0);comment_manager_classPrivateFieldInitSpec(this,sp,void 0);comment_manager_classPrivateFieldInitSpec(this,np,void 0);comment_manager_classPrivateFieldInitSpec(this,rp,void 0);comment_manager_classPrivateFieldInitSpec(this,op,void 0);comment_manager_classPrivateFieldInitSpec(this,lp,void 0);comment_manager_classPrivateFieldInitSpec(this,dp,void 0);comment_manager_classPrivateFieldInitSpec(this,cp,null);comment_manager_classPrivateFieldInitSpec(this,hp,null);comment_manager_classPrivateFieldInitSpec(this,up,null);if(!t)return;comment_manager_classPrivateFieldSet(rp,this,n);comment_manager_classPrivateFieldSet(ap,this,a);comment_manager_classPrivateFieldSet(sp,this,s);comment_manager_classPrivateFieldSet(op,this,e);comment_manager_classPrivateFieldSet(lp,this,d);comment_manager_classPrivateFieldSet(ip,this,r);comment_manager_classPrivateFieldSet(dp,this,c);comment_manager_classPrivateFieldSet(np,this,h);comment_manager_classPrivateFieldSet(J_,this,l);r.addEventListener("click",()=>{l.dispatch("switchannotationeditormode",{source:this,mode:f.NONE})});const keyDownCallback=e=>{if("ArrowDown"===e.key||"Home"===e.key||"F6"===e.key){comment_manager_classPrivateFieldGet(ap,this).firstElementChild.focus();stopEvent(e)}else if("ArrowUp"===e.key||"End"===e.key){comment_manager_classPrivateFieldGet(ap,this).lastElementChild.focus();stopEvent(e)}};o?.addEventListener("keydown",keyDownCallback);t.addEventListener("keydown",keyDownCallback)}setUIManager(e){comment_manager_classPrivateFieldSet(up,this,e)}show(e){comment_manager_classPrivateFieldSet(cp,this,new WeakMap);comment_manager_classPrivateFieldSet(hp,this,new Map);comment_manager_classPrivateFieldSet(Q_,this,e);e.sort(comment_manager_assertClassBrand(_p,this,_sortComments).bind(this));if(0!==e.length){const t=document.createDocumentFragment();for(const i of e)t.append(comment_manager_assertClassBrand(_p,this,_createCommentElement).call(this,i));comment_manager_assertClassBrand(_p,this,_setCommentsCount).call(this,t);comment_manager_classPrivateFieldGet(ap,this).append(t)}else comment_manager_assertClassBrand(_p,this,_setCommentsCount).call(this);this._sidebar.hidden=!1;comment_manager_classPrivateFieldGet(J_,this).dispatch("reporttelemetry",{source:this,details:{type:"commentSidebar",data:{numberOfAnnotations:e.length}}})}hide(){this._sidebar.hidden=!0;comment_manager_classPrivateFieldGet(ap,this).replaceChildren();comment_manager_classPrivateFieldSet(cp,this,null);comment_manager_classPrivateFieldSet(hp,this,null);comment_manager_classPrivateFieldSet(Q_,this,null)}removeComments(e){if(0!==e.length&&comment_manager_classPrivateFieldGet(hp,this))if(0!==new Set(comment_manager_classPrivateFieldGet(hp,this).keys()).difference(new Set(e)).size)for(const t of e)comment_manager_assertClassBrand(_p,this,_removeComment).call(this,t);else comment_manager_assertClassBrand(_p,this,_removeAll).call(this)}focusComment(e){const t=comment_manager_classPrivateFieldGet(hp,this).get(e);if(t){this._sidebar.scrollTop=t.offsetTop-this._sidebar.offsetTop;for(const e of comment_manager_classPrivateFieldGet(ap,this).children)e.classList.toggle("selected",e===t)}}updateComment(e){if(!comment_manager_classPrivateFieldGet(hp,this))return;const{id:t,creationDate:i,modificationDate:a,richText:s,contentsObj:n,popupRef:r}=e;r&&(s||n?.str)||comment_manager_assertClassBrand(_p,this,_removeComment).call(this,t);const o=comment_manager_classPrivateFieldGet(hp,this).get(t);if(!o)return;const l=comment_manager_classPrivateFieldGet(cp,this).get(o);let d=binarySearchFirstItem(comment_manager_classPrivateFieldGet(Q_,this),e=>comment_manager_assertClassBrand(_p,this,_sortComments).call(this,e,l)>=0);if(!(d>=comment_manager_classPrivateFieldGet(Q_,this).length)){comment_manager_assertClassBrand(_p,this,_setDate).call(this,o.firstElementChild,a||i);comment_manager_assertClassBrand(_p,this,_setText).call(this,o.lastElementChild,s,n);comment_manager_classPrivateFieldGet(Q_,this).splice(d,1);d=binarySearchFirstItem(comment_manager_classPrivateFieldGet(Q_,this),t=>comment_manager_assertClassBrand(_p,this,_sortComments).call(this,t,e)>=0);comment_manager_classPrivateFieldGet(Q_,this).splice(d,0,e);d>=comment_manager_classPrivateFieldGet(ap,this).children.length?comment_manager_classPrivateFieldGet(ap,this).append(o):comment_manager_classPrivateFieldGet(ap,this).insertBefore(o,comment_manager_classPrivateFieldGet(ap,this).children[d])}}selectComment(e,t=null){if(!comment_manager_classPrivateFieldGet(hp,this))return;const i=!e;e||=comment_manager_classPrivateFieldGet(hp,this).get(t);for(const t of comment_manager_classPrivateFieldGet(ap,this).children)t.classList.toggle("selected",t===e);i&&e?.scrollIntoView({behavior:"instant",block:"center"})}addComment(e){if(comment_manager_classPrivateFieldGet(hp,this)?.has(e.id))return;const{popupRef:t,contentsObj:i}=e;if(!t||!i?.str)return;const a=comment_manager_assertClassBrand(_p,this,_createCommentElement).call(this,e);if(0===comment_manager_classPrivateFieldGet(Q_,this).length){comment_manager_classPrivateFieldGet(ap,this).replaceChildren(a);comment_manager_classPrivateFieldGet(Q_,this).push(e);comment_manager_assertClassBrand(_p,this,_setCommentsCount).call(this);return}const s=binarySearchFirstItem(comment_manager_classPrivateFieldGet(Q_,this),t=>comment_manager_assertClassBrand(_p,this,_sortComments).call(this,t,e)>=0);comment_manager_classPrivateFieldGet(Q_,this).splice(s,0,e);s>=comment_manager_classPrivateFieldGet(ap,this).children.length?comment_manager_classPrivateFieldGet(ap,this).append(a):comment_manager_classPrivateFieldGet(ap,this).insertBefore(a,comment_manager_classPrivateFieldGet(ap,this).children[s]);comment_manager_assertClassBrand(_p,this,_setCommentsCount).call(this)}}function _removeComment(e){const t=comment_manager_classPrivateFieldGet(hp,this)?.get(e);if(!t)return;const i=comment_manager_classPrivateFieldGet(cp,this).get(t),a=binarySearchFirstItem(comment_manager_classPrivateFieldGet(Q_,this),e=>comment_manager_assertClassBrand(_p,this,_sortComments).call(this,e,i)>=0);if(!(a>=comment_manager_classPrivateFieldGet(Q_,this).length)){comment_manager_classPrivateFieldGet(Q_,this).splice(a,1);t.remove();comment_manager_classPrivateFieldGet(hp,this).delete(e);comment_manager_assertClassBrand(_p,this,_setCommentsCount).call(this)}}function _removeAll(){comment_manager_classPrivateFieldGet(ap,this).replaceChildren();comment_manager_classPrivateFieldSet(cp,this,new WeakMap);comment_manager_classPrivateFieldGet(hp,this).clear();comment_manager_classPrivateFieldGet(Q_,this).length=0;comment_manager_assertClassBrand(_p,this,_setCommentsCount).call(this)}function _setCommentsCount(e=comment_manager_classPrivateFieldGet(ap,this)){const t=comment_manager_classPrivateFieldGet(hp,this).size;comment_manager_classPrivateFieldGet(rp,this).setAttribute("data-l10n-args",JSON.stringify({count:t}));comment_manager_classPrivateFieldGet(sp,this).textContent=t;0===t&&e.append(comment_manager_assertClassBrand(_p,this,_createZeroCommentElement).call(this))}function _createZeroCommentElement(){const e=document.createElement("li");e.classList.add("sidebarComment","noComments");const t=document.createElement("div");t.className="sidebarCommentText";t.setAttribute("data-l10n-id","pdfjs-editor-comments-sidebar-no-comments1");e.append(t);if(comment_manager_classPrivateFieldGet(op,this)){const t=document.createElement("a");t.setAttribute("data-l10n-id","pdfjs-editor-comments-sidebar-no-comments-link");t.href=comment_manager_classPrivateFieldGet(op,this);t.target="_blank";t.rel="noopener noreferrer";e.append(t)}return e}function _setDate(e,t){t=PDFDateString.toDateObject(t);e.dateTime=t.toISOString();e.textContent=comment_manager_classPrivateFieldGet(np,this).format(t)}function _setText(e,t,i){e.replaceChildren();renderRichText({html:!t?.str||i?.str&&t.str!==i.str?i?.str:t.html,dir:i?.dir||"auto",className:"richText"},e)}function _createCommentElement(e){const{id:t,creationDate:i,modificationDate:a,richText:s,contentsObj:n,color:r,opacity:o}=e,l=document.createElement("li");l.role="button";l.className="sidebarComment";l.tabIndex=-1;l.style.backgroundColor=r&&CommentManager._makeCommentColor(r,o)||"";const d=document.createElement("time");comment_manager_assertClassBrand(_p,this,_setDate).call(this,d,a||i);const c=document.createElement("div");c.className="sidebarCommentText";comment_manager_assertClassBrand(_p,this,_setText).call(this,c,s,n);l.append(d,c);l.addEventListener("click",comment_manager_classPrivateFieldGet(ep,this));l.addEventListener("keydown",comment_manager_classPrivateFieldGet(tp,this));comment_manager_classPrivateFieldGet(cp,this).set(l,e);comment_manager_classPrivateFieldGet(hp,this).set(t,l);return l}async function _commentClick({currentTarget:e}){if(e.classList.contains("selected")){e.classList.remove("selected");comment_manager_classPrivateFieldGet(dp,this)._hide();return}const t=comment_manager_classPrivateFieldGet(cp,this).get(e);if(!t)return;comment_manager_classPrivateFieldGet(dp,this)._hide();const{id:i,pageIndex:a,rect:s}=t,n=a+1,r=comment_manager_classPrivateFieldGet(up,this)?.waitForEditorsRendered(n);comment_manager_classPrivateFieldGet(lp,this)?.goToXY(n,s[0],s[3],{center:"both"});this.selectComment(e);await r;comment_manager_classPrivateFieldGet(up,this)?.selectComment(a,i)}function _commentKeydown(e){const{key:t,currentTarget:i}=e;switch(t){case"ArrowDown":(i.nextElementSibling||comment_manager_classPrivateFieldGet(ap,this).firstElementChild).focus();stopEvent(e);break;case"ArrowUp":(i.previousElementSibling||comment_manager_classPrivateFieldGet(ap,this).lastElementChild).focus();stopEvent(e);break;case"Home":comment_manager_classPrivateFieldGet(ap,this).firstElementChild.focus();stopEvent(e);break;case"End":comment_manager_classPrivateFieldGet(ap,this).lastElementChild.focus();stopEvent(e);break;case"Enter":case" ":comment_manager_assertClassBrand(_p,this,_commentClick).call(this,e);stopEvent(e);break;case"ShiftTab":comment_manager_classPrivateFieldGet(ip,this).focus();stopEvent(e)}}function _sortComments(e,t){const i=PDFDateString.toDateObject(e.modificationDate||e.creationDate),a=PDFDateString.toDateObject(t.modificationDate||t.creationDate);return i!==a?null!==i&&null!==a?a-i:null!==i?-1:1:e.pageIndex!==t.pageIndex?e.pageIndex-t.pageIndex:e.rect[3]!==t.rect[3]?t.rect[3]-e.rect[3]:e.rect[0]!==t.rect[0]?e.rect[0]-t.rect[0]:e.rect[1]!==t.rect[1]?t.rect[1]-e.rect[1]:e.rect[2]!==t.rect[2]?e.rect[2]-t.rect[2]:e.id.localeCompare(t.id)}var pp=new WeakMap,gp=new WeakMap,mp=new WeakMap,fp=new WeakMap,vp=new WeakMap,Pp=new WeakMap,wp=new WeakMap,Fp=new WeakMap,bp=new WeakMap,yp=new WeakMap,Sp=new WeakMap,Cp=new WeakMap,xp=new WeakMap,kp=new WeakMap,Ep=new WeakMap,Ap=new WeakSet;class CommentDialog{constructor({dialog:e,toolbar:t,title:i,textInput:a,cancelButton:s,saveButton:n},r,o,l){comment_manager_classPrivateMethodInitSpec(this,Ap);comment_manager_classPrivateFieldInitSpec(this,pp,void 0);comment_manager_classPrivateFieldInitSpec(this,gp,void 0);comment_manager_classPrivateFieldInitSpec(this,mp,void 0);comment_manager_classPrivateFieldInitSpec(this,fp,"");comment_manager_classPrivateFieldInitSpec(this,vp,"");comment_manager_classPrivateFieldInitSpec(this,Pp,void 0);comment_manager_classPrivateFieldInitSpec(this,wp,void 0);comment_manager_classPrivateFieldInitSpec(this,Fp,void 0);comment_manager_classPrivateFieldInitSpec(this,bp,void 0);comment_manager_classPrivateFieldInitSpec(this,yp,0);comment_manager_classPrivateFieldInitSpec(this,Sp,0);comment_manager_classPrivateFieldInitSpec(this,Cp,0);comment_manager_classPrivateFieldInitSpec(this,xp,0);comment_manager_classPrivateFieldInitSpec(this,kp,void 0);comment_manager_classPrivateFieldInitSpec(this,Ep,void 0);comment_manager_classPrivateFieldSet(pp,this,e);comment_manager_classPrivateFieldSet(Pp,this,a);comment_manager_classPrivateFieldSet(mp,this,r);comment_manager_classPrivateFieldSet(Ep,this,o);comment_manager_classPrivateFieldSet(Fp,this,n);comment_manager_classPrivateFieldSet(wp,this,i);comment_manager_classPrivateFieldSet(kp,this,l);const d=comment_manager_assertClassBrand(Ap,this,comment_manager_finish).bind(this);e.addEventListener("close",d);e.addEventListener("contextmenu",e=>{e.target!==comment_manager_classPrivateFieldGet(Pp,this)&&e.preventDefault()});s.addEventListener("click",d);n.addEventListener("click",comment_manager_assertClassBrand(Ap,this,comment_manager_save).bind(this));a.addEventListener("input",()=>{n.disabled=a.value===comment_manager_classPrivateFieldGet(fp,this)});a.addEventListener("keydown",e=>{!e.ctrlKey&&!e.metaKey||"Enter"!==e.key||n.disabled||comment_manager_assertClassBrand(Ap,this,comment_manager_save).call(this)});let c;const cancelDrag=()=>{e.classList.remove("dragging");c?.abort();c=null};t.addEventListener("pointerdown",t=>{if(c){cancelDrag();return}const{clientX:i,clientY:a}=t;stopEvent(t);comment_manager_classPrivateFieldSet(yp,this,i);comment_manager_classPrivateFieldSet(Sp,this,a);c=new AbortController;const{signal:s}=c,{innerHeight:n,innerWidth:r}=window;e.classList.add("dragging");window.addEventListener("pointermove",e=>{if(!c)return;const{clientX:t,clientY:i}=e;comment_manager_assertClassBrand(Ap,this,comment_manager_setPosition).call(this,comment_manager_classPrivateFieldGet(Cp,this)+(t-comment_manager_classPrivateFieldGet(yp,this))/r,comment_manager_classPrivateFieldGet(xp,this)+(i-comment_manager_classPrivateFieldGet(Sp,this))/n);comment_manager_classPrivateFieldSet(yp,this,t);comment_manager_classPrivateFieldSet(Sp,this,i);stopEvent(e)},{signal:s});window.addEventListener("blur",cancelDrag,{signal:s});window.addEventListener("pointerup",e=>{if(c){cancelDrag();stopEvent(e)}},{signal:s})});r.register(e)}async open(e,t,i,a,s){if(t){comment_manager_classPrivateFieldSet(bp,this,e);comment_manager_classPrivateFieldSet(gp,this,t)}const{contentsObj:{str:n},color:r,opacity:o}=t.getData(),{style:l}=comment_manager_classPrivateFieldGet(pp,this);if(r){l.backgroundColor=CommentManager._makeCommentColor(r,o);l.borderColor=Util.makeHexColor(...r)}else l.backgroundColor=l.borderColor="";comment_manager_classPrivateFieldSet(vp,this,n||"");const d=comment_manager_classPrivateFieldGet(Pp,this);d.value=comment_manager_classPrivateFieldSet(fp,this,comment_manager_classPrivateFieldGet(vp,this));if(n){comment_manager_classPrivateFieldGet(wp,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-title-when-editing");comment_manager_classPrivateFieldGet(Fp,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-save-button-when-editing")}else{comment_manager_classPrivateFieldGet(wp,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-title-when-adding");comment_manager_classPrivateFieldGet(Fp,this).setAttribute("data-l10n-id","pdfjs-editor-edit-comment-dialog-save-button-when-adding")}s?.height&&(d.style.height=`${s.height}px`);comment_manager_classPrivateFieldGet(bp,this)?.removeEditListeners();comment_manager_classPrivateFieldGet(Fp,this).disabled=!0;const c=s?.parentDimensions,{innerHeight:h,innerWidth:u}=window;if(t.hasDefaultPopupPosition()){const{dialogWidth:e,dialogHeight:t}=this._dialogDimensions;if(c)if(comment_manager_classPrivateFieldGet(kp,this)&&i+e>Math.min(c.x+c.width,u)){i-=e-comment_manager_classPrivateFieldGet(gp,this).commentButtonWidth*c.width}else if(!comment_manager_classPrivateFieldGet(kp,this)){const t=comment_manager_classPrivateFieldGet(gp,this).commentButtonWidth*c.width;i-e<Math.max(0,c.x)?i=Math.max(0,i):i-=e-t}const n=Math.max(t,s?.height||0);a+n>h&&(a=h-n);a<0&&(a=0)}i=MathClamp(i/u,0,1);a=MathClamp(a/h,0,1);comment_manager_assertClassBrand(Ap,this,comment_manager_setPosition).call(this,i,a);await comment_manager_classPrivateFieldGet(mp,this).open(comment_manager_classPrivateFieldGet(pp,this));d.focus()}get _dialogDimensions(){const e=comment_manager_classPrivateFieldGet(pp,this),{style:t}=e;t.opacity="0";t.display="block";const{width:i,height:a}=e.getBoundingClientRect();t.opacity=t.display="";return shadow(this,"_dialogDimensions",{dialogWidth:i,dialogHeight:a})}destroy(){comment_manager_classPrivateFieldSet(bp,this,null);comment_manager_classPrivateFieldSet(gp,this,null);comment_manager_assertClassBrand(Ap,this,comment_manager_finish).call(this)}}async function comment_manager_save(){comment_manager_classPrivateFieldGet(gp,this).comment=comment_manager_classPrivateFieldGet(Pp,this).value;comment_manager_assertClassBrand(Ap,this,comment_manager_finish).call(this)}function comment_manager_setPosition(e,t){comment_manager_classPrivateFieldSet(Cp,this,e);comment_manager_classPrivateFieldSet(xp,this,t);const{style:i}=comment_manager_classPrivateFieldGet(pp,this);i.left=100*e+"%";i.top=100*t+"%"}function comment_manager_finish(){if(!comment_manager_classPrivateFieldGet(gp,this))return;const e=comment_manager_classPrivateFieldGet(Pp,this).value!==comment_manager_classPrivateFieldGet(vp,this);comment_manager_classPrivateFieldGet(Ep,this).dispatch("reporttelemetry",{source:this,details:{type:"comment",data:{edited:e}}});e&&comment_manager_classPrivateFieldGet(Ep,this)?.dispatch("annotation-editor-event",{source:this,type:comment_manager_classPrivateFieldGet(Pp,this).value?"commented":"commentRemoved",page:comment_manager_classPrivateFieldGet(gp,this).pageIndex+1,id:comment_manager_classPrivateFieldGet(gp,this).uid,editorType:comment_manager_classPrivateFieldGet(gp,this).constructor.name,value:comment_manager_classPrivateFieldGet(gp,this)});comment_manager_classPrivateFieldGet(gp,this)?.focusCommentButton();comment_manager_classPrivateFieldSet(gp,this,null);comment_manager_classPrivateFieldGet(Pp,this).value=comment_manager_classPrivateFieldSet(fp,this,comment_manager_classPrivateFieldSet(vp,this,""));comment_manager_classPrivateFieldGet(mp,this).closeIfActive(comment_manager_classPrivateFieldGet(pp,this));comment_manager_classPrivateFieldGet(Pp,this).style.height="";comment_manager_classPrivateFieldGet(bp,this)?.addEditListeners();comment_manager_classPrivateFieldSet(bp,this,null)}var Gp=new WeakMap,Bp=new WeakMap,Mp=new WeakMap,Ip=new WeakMap,Tp=new WeakMap,Dp=new WeakMap,Lp=new WeakMap,Np=new WeakMap,Rp=new WeakMap,Op=new WeakMap,Wp=new WeakMap,jp=new WeakMap,Vp=new WeakMap,Up=new WeakMap,zp=new WeakMap,Hp=new WeakMap,$p=new WeakSet;class CommentPopup{constructor(e,t,i,a){comment_manager_classPrivateMethodInitSpec(this,$p);comment_manager_classPrivateFieldInitSpec(this,Gp,null);comment_manager_classPrivateFieldInitSpec(this,Bp,void 0);comment_manager_classPrivateFieldInitSpec(this,Mp,void 0);comment_manager_classPrivateFieldInitSpec(this,Ip,void 0);comment_manager_classPrivateFieldInitSpec(this,Tp,null);comment_manager_classPrivateFieldInitSpec(this,Dp,void 0);comment_manager_classPrivateFieldInitSpec(this,Lp,null);comment_manager_classPrivateFieldInitSpec(this,Np,null);comment_manager_classPrivateFieldInitSpec(this,Rp,null);comment_manager_classPrivateFieldInitSpec(this,Op,0);comment_manager_classPrivateFieldInitSpec(this,Wp,0);comment_manager_classPrivateFieldInitSpec(this,jp,0);comment_manager_classPrivateFieldInitSpec(this,Vp,0);comment_manager_classPrivateFieldInitSpec(this,Up,null);comment_manager_classPrivateFieldInitSpec(this,zp,!1);comment_manager_classPrivateFieldInitSpec(this,Hp,!1);comment_manager_classPrivateFieldSet(Bp,this,e);comment_manager_classPrivateFieldSet(Ip,this,t);comment_manager_classPrivateFieldSet(Dp,this,i);comment_manager_classPrivateFieldSet(Mp,this,a);this.sidebar=null}get _popupWidth(){const e=document.createElement("ngx-extended-pdf-viewer");e.style.opacity="0";e.style.display="block";const t=document.createElement("div");t.classList.add("zoom");e.append(t);const i=comment_manager_assertClassBrand($p,this,comment_manager_createPopup).call(this);i.style.display="block";t.append(i);document.body.append(e);const a=i.getBoundingClientRect().width;i.remove();e.remove();i.style.display="";return shadow(this,"_popupWidth",a)}updateColor(e){if(comment_manager_classPrivateFieldGet(Tp,this)!==e||!comment_manager_classPrivateFieldGet(Hp,this))return;const{color:t,opacity:i}=e.getData();comment_manager_classPrivateFieldGet(Lp,this).style.backgroundColor=t&&CommentManager._makeCommentColor(t,i)||""}_hide(e){const t=comment_manager_assertClassBrand($p,this,comment_manager_createPopup).call(this);t.classList.toggle("hidden",!0);t.classList.toggle("selected",!1);(e||comment_manager_classPrivateFieldGet(Tp,this))?.setCommentButtonStates({selected:!1,hasPopup:!1});comment_manager_classPrivateFieldSet(Tp,this,null);comment_manager_classPrivateFieldSet(zp,this,!1);comment_manager_classPrivateFieldSet(Hp,this,!1);comment_manager_classPrivateFieldGet(Np,this).replaceChildren();this.sidebar.selectComment(null)}toggle(e,t,i=void 0,a=!0){if(!e){this.destroy();return}if(t)i??=comment_manager_classPrivateFieldGet(Tp,this)!==e||(!comment_manager_classPrivateFieldGet(zp,this)||!comment_manager_classPrivateFieldGet(Hp,this));else{if(comment_manager_classPrivateFieldGet(zp,this))return;i??=!comment_manager_classPrivateFieldGet(Hp,this)}if(!i){this._hide(e);return}comment_manager_classPrivateFieldSet(Hp,this,!0);comment_manager_classPrivateFieldGet(Tp,this)!==e&&comment_manager_classPrivateFieldGet(Tp,this)?.setCommentButtonStates({selected:!1,hasPopup:!1});const s=comment_manager_assertClassBrand($p,this,comment_manager_createPopup).call(this);comment_manager_classPrivateFieldGet(Gp,this).classList.toggle("hidden",!a);s.classList.toggle("hidden",!1);s.classList.toggle("selected",t);comment_manager_classPrivateFieldSet(zp,this,t);comment_manager_classPrivateFieldSet(Tp,this,e);e.setCommentButtonStates({selected:t,hasPopup:!0});const{contentsObj:n,richText:r,creationDate:o,modificationDate:l,color:d,opacity:c}=e.getData();s.style.backgroundColor=d&&CommentManager._makeCommentColor(d,c)||"";comment_manager_classPrivateFieldGet(Np,this).replaceChildren();const h=!r?.str||n?.str&&r.str!==n.str?n?.str:r.html;h&&renderRichText({html:h,dir:n?.dir||"auto",className:"richText"},comment_manager_classPrivateFieldGet(Np,this));comment_manager_classPrivateFieldGet(Rp,this).textContent=comment_manager_classPrivateFieldGet(Ip,this).format(PDFDateString.toDateObject(l||o));comment_manager_assertClassBrand($p,this,_setPosition2).call(this,...e.commentPopupPosition,e.hasDefaultPopupPosition());e.elementBeforePopup.after(s);s.addEventListener("focus",({relatedTarget:e})=>{comment_manager_classPrivateFieldSet(Up,this,e)},{once:!0});t&&setTimeout(()=>s.focus(),0)}destroy(){this._hide();comment_manager_classPrivateFieldGet(Lp,this)?.remove();comment_manager_classPrivateFieldSet(Lp,this,comment_manager_classPrivateFieldSet(Np,this,comment_manager_classPrivateFieldSet(Rp,this,null)));comment_manager_classPrivateFieldSet(Op,this,comment_manager_classPrivateFieldSet(Wp,this,1/0));comment_manager_classPrivateFieldSet(jp,this,comment_manager_classPrivateFieldSet(Vp,this,0));comment_manager_classPrivateFieldSet(Up,this,null)}}function comment_manager_createPopup(){if(comment_manager_classPrivateFieldGet(Lp,this))return comment_manager_classPrivateFieldGet(Lp,this);const e=comment_manager_classPrivateFieldSet(Lp,this,document.createElement("div"));e.className="commentPopup";e.id="commentPopup";e.tabIndex=-1;e.role="dialog";e.ariaModal="false";e.addEventListener("contextmenu",noContextMenu);e.addEventListener("keydown",e=>{if("Escape"===e.key){this.toggle(comment_manager_classPrivateFieldGet(Tp,this),!0,!1);comment_manager_classPrivateFieldGet(Up,this)?.focus();stopEvent(e)}});e.addEventListener("click",()=>{e.focus()});const t=document.createElement("div");t.className="commentPopupTop";const i=comment_manager_classPrivateFieldSet(Rp,this,document.createElement("time"));i.className="commentPopupTime";const a=comment_manager_classPrivateFieldSet(Gp,this,document.createElement("div"));a.className="commentPopupButtons";const s=document.createElement("button");s.classList.add("commentPopupEdit","toolbarButton");s.tabIndex=0;s.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-popup-button");s.ariaHasPopup="dialog";s.ariaControlsElements=[comment_manager_classPrivateFieldGet(Mp,this)];const n=document.createElement("span");n.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-popup-button-label");s.append(n);s.addEventListener("click",()=>{const e=comment_manager_classPrivateFieldGet(Tp,this),t=parseFloat(getComputedStyle(comment_manager_classPrivateFieldGet(Np,this)).height);this.toggle(e,!0,!1);e.editComment({height:t})});s.addEventListener("contextmenu",noContextMenu);const r=document.createElement("button");r.classList.add("commentPopupDelete","toolbarButton");r.tabIndex=0;r.setAttribute("data-l10n-id","pdfjs-editor-delete-comment-popup-button");const o=document.createElement("span");o.setAttribute("data-l10n-id","pdfjs-editor-delete-comment-popup-button-label");r.append(o);r.addEventListener("click",()=>{comment_manager_classPrivateFieldGet(Bp,this).dispatch("reporttelemetry",{source:this,details:{type:"comment",data:{deleted:!0}}});const e=comment_manager_classPrivateFieldGet(Tp,this),t=e.comment;comment_manager_classPrivateFieldGet(Bp,this)?.dispatch("annotation-editor-event",{source:this,type:"commentRemoved",page:e.pageIndex+1,id:e.uid,editorType:e.constructor.name,value:e});this.destroy();t?.text?e._uiManager.deleteComment(e,t):e.comment=null;e.focus()});r.addEventListener("contextmenu",noContextMenu);a.append(s,r);t.append(i,a);const l=document.createElement("hr"),d=comment_manager_classPrivateFieldSet(Np,this,document.createElement("div"));d.className="commentPopupText";e.append(t,l,d);let c;const cancelDrag=()=>{e.classList.remove("dragging");c?.abort();c=null};t.addEventListener("pointerdown",t=>{if(c){cancelDrag();return}const{target:i,clientX:s,clientY:n}=t;if(a.contains(i))return;stopEvent(t);const{width:r,height:o}=comment_manager_classPrivateFieldGet(Tp,this).parentBoundingClientRect;comment_manager_classPrivateFieldSet(Op,this,s);comment_manager_classPrivateFieldSet(Wp,this,n);c=new AbortController;const{signal:l}=c;e.classList.add("dragging");window.addEventListener("pointermove",e=>{if(!c)return;const{clientX:t,clientY:i}=e;comment_manager_assertClassBrand($p,this,_setPosition2).call(this,comment_manager_classPrivateFieldGet(jp,this)+(t-comment_manager_classPrivateFieldGet(Op,this))/r,comment_manager_classPrivateFieldGet(Vp,this)+(i-comment_manager_classPrivateFieldGet(Wp,this))/o,!1);comment_manager_classPrivateFieldSet(Op,this,t);comment_manager_classPrivateFieldSet(Wp,this,i);stopEvent(e)},{signal:l});window.addEventListener("blur",cancelDrag,{signal:l});window.addEventListener("pointerup",e=>{if(c){cancelDrag();stopEvent(e)}},{signal:l})});return e}function _setPosition2(e,t,i){if(i){const t=comment_manager_classPrivateFieldGet(Tp,this).parentBoundingClientRect,i=this._popupWidth/t.width;if(comment_manager_classPrivateFieldGet(Dp,this)&&e+i>1||!comment_manager_classPrivateFieldGet(Dp,this)&&e-i>=0){e-=i-comment_manager_classPrivateFieldGet(Tp,this).commentButtonWidth}const a=.02;e=comment_manager_classPrivateFieldGet(Dp,this)?Math.max(e,-t.x/t.width+a):Math.min(e,(window.innerWidth-t.x)/t.width-i-a)}else comment_manager_classPrivateFieldGet(Tp,this).commentPopupPosition=[e,t];comment_manager_classPrivateFieldSet(jp,this,e);comment_manager_classPrivateFieldSet(Vp,this,t);const{style:a}=comment_manager_classPrivateFieldGet(Lp,this);a.left=100*e+"%";a.top=100*t+"%"}function base_download_manager_classPrivateFieldInitSpec(e,t,i){(function base_download_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function base_download_manager_classPrivateFieldGet(e,t){return e.get(function base_download_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(e,t))}var Kp=new WeakMap;class BaseDownloadManager{constructor(){base_download_manager_classPrivateFieldInitSpec(this,Kp,new WeakMap)}_triggerDownload(e,t,i,a=!1){throw new Error("Not implemented: _triggerDownload")}_getOpenDataUrl(e,t,i=null){throw new Error("Not implemented: _getOpenDataUrl")}downloadData(e,t,i){const a=URL.createObjectURL(new Blob([e],{type:i}));this._triggerDownload(a,a,t,!0)}openOrDownloadData(e,t,i=null){const a=isPdfFile(t),s=a?"application/pdf":"";if(a){const a=base_download_manager_classPrivateFieldGet(Kp,this).getOrInsertComputed(e,()=>URL.createObjectURL(new Blob([e],{type:s})));try{const e=this._getOpenDataUrl(a,t,i);window.open(e);return!0}catch(t){console.error("openOrDownloadData:",t);URL.revokeObjectURL(a);base_download_manager_classPrivateFieldGet(Kp,this).delete(e)}}this.downloadData(e,t,s);return!1}download(e,t,i){const a=e?URL.createObjectURL(new Blob([e],{type:"application/pdf"})):null;this._triggerDownload(a,t,i)}}class DownloadManager extends BaseDownloadManager{_triggerDownload(e,t,i,a=!1){if(!e&&!a){if(!createValidAbsoluteUrl(t,"http://example.com"))throw new Error(`_triggerDownload - not a valid URL: ${t}`);e=t+"#pdfjs.action=download"}const s=document.createElement("a");s.href=e;s.target="_parent";"download"in s&&(s.download=i);(document.body||document.documentElement).append(s);s.click();s.remove()}_getOpenDataUrl(e,t,i=null){return e}}function editor_undo_bar_defineProperty(e,t,i){return(t=function editor_undo_bar_toPropertyKey(e){var t=function editor_undo_bar_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function editor_undo_bar_classPrivateFieldInitSpec(e,t,i){(function editor_undo_bar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function editor_undo_bar_classPrivateFieldGet(e,t){return e.get(editor_undo_bar_assertClassBrand(e,t))}function editor_undo_bar_classPrivateFieldSet(e,t,i){return e.set(editor_undo_bar_assertClassBrand(e,t),i),i}function editor_undo_bar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Xp=new WeakMap,qp=new WeakMap,Yp=new WeakMap,Zp=new WeakMap,Qp=new WeakMap,Jp=new WeakMap,eg=new WeakMap,tg=new WeakMap;class EditorUndoBar{constructor({container:e,message:t,undoButton:i,closeButton:a},s){editor_undo_bar_classPrivateFieldInitSpec(this,Xp,null);editor_undo_bar_classPrivateFieldInitSpec(this,qp,void 0);editor_undo_bar_classPrivateFieldInitSpec(this,Yp,null);editor_undo_bar_classPrivateFieldInitSpec(this,Zp,null);editor_undo_bar_classPrivateFieldInitSpec(this,Qp,null);editor_undo_bar_defineProperty(this,"isOpen",!1);editor_undo_bar_classPrivateFieldInitSpec(this,Jp,void 0);editor_undo_bar_classPrivateFieldInitSpec(this,eg,null);editor_undo_bar_classPrivateFieldInitSpec(this,tg,void 0);editor_undo_bar_classPrivateFieldSet(qp,this,e);editor_undo_bar_classPrivateFieldSet(Jp,this,t);editor_undo_bar_classPrivateFieldSet(tg,this,i);editor_undo_bar_classPrivateFieldSet(Xp,this,a);editor_undo_bar_classPrivateFieldSet(Yp,this,s)}destroy(){editor_undo_bar_classPrivateFieldGet(Qp,this)?.abort();editor_undo_bar_classPrivateFieldSet(Qp,this,null);this.hide()}show(e,t){if(!editor_undo_bar_classPrivateFieldGet(Qp,this)){editor_undo_bar_classPrivateFieldSet(Qp,this,new AbortController);const e={signal:editor_undo_bar_classPrivateFieldGet(Qp,this).signal},t={signal:editor_undo_bar_classPrivateFieldGet(Qp,this).signal,...Nh},i=this.hide.bind(this);editor_undo_bar_classPrivateFieldGet(qp,this).addEventListener("contextmenu",noContextMenu,e);editor_undo_bar_classPrivateFieldGet(Xp,this).addEventListener("click",i,e);editor_undo_bar_classPrivateFieldGet(Yp,this).on("beforeprint",i,t);editor_undo_bar_classPrivateFieldGet(Yp,this).on("download",i,t)}this.hide();if("string"==typeof t)editor_undo_bar_classPrivateFieldGet(Jp,this).setAttribute("data-l10n-id",ig._[t]);else{editor_undo_bar_classPrivateFieldGet(Jp,this).setAttribute("data-l10n-id",ig._._multiple);editor_undo_bar_classPrivateFieldGet(Jp,this).setAttribute("data-l10n-args",JSON.stringify({count:t}))}this.isOpen=!0;editor_undo_bar_classPrivateFieldGet(qp,this).hidden=!1;editor_undo_bar_classPrivateFieldSet(eg,this,new AbortController);editor_undo_bar_classPrivateFieldGet(tg,this).addEventListener("click",()=>{e();this.hide()},{signal:editor_undo_bar_classPrivateFieldGet(eg,this).signal});editor_undo_bar_classPrivateFieldSet(Zp,this,setTimeout(()=>{editor_undo_bar_classPrivateFieldGet(qp,this).contains(document.activeElement)||editor_undo_bar_classPrivateFieldGet(qp,this).focus();editor_undo_bar_classPrivateFieldSet(Zp,this,null)},100))}hide(){if(this.isOpen){this.isOpen=!1;editor_undo_bar_classPrivateFieldGet(qp,this).hidden=!0;editor_undo_bar_classPrivateFieldGet(eg,this)?.abort();editor_undo_bar_classPrivateFieldSet(eg,this,null);if(editor_undo_bar_classPrivateFieldGet(Zp,this)){clearTimeout(editor_undo_bar_classPrivateFieldGet(Zp,this));editor_undo_bar_classPrivateFieldSet(Zp,this,null)}}}}var ig={_:Object.freeze({highlight:"pdfjs-editor-undo-bar-message-highlight",freetext:"pdfjs-editor-undo-bar-message-freetext",stamp:"pdfjs-editor-undo-bar-message-stamp",ink:"pdfjs-editor-undo-bar-message-ink",signature:"pdfjs-editor-undo-bar-message-signature",comment:"pdfjs-editor-undo-bar-message-comment",_multiple:"pdfjs-editor-undo-bar-message-multiple"})};function overlay_manager_classPrivateFieldInitSpec(e,t,i){(function overlay_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function overlay_manager_classPrivateFieldSet(e,t,i){return e.set(overlay_manager_assertClassBrand(e,t),i),i}function overlay_manager_classPrivateFieldGet(e,t){return e.get(overlay_manager_assertClassBrand(e,t))}function overlay_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var ag=new WeakMap,sg=new WeakMap;class OverlayManager{constructor(){overlay_manager_classPrivateFieldInitSpec(this,ag,new WeakMap);overlay_manager_classPrivateFieldInitSpec(this,sg,null)}get active(){return overlay_manager_classPrivateFieldGet(sg,this)}async register(e,t=!1){if("object"!=typeof e)throw new Error("Not enough parameters.");if(overlay_manager_classPrivateFieldGet(ag,this).has(e))throw new Error("The overlay is already registered.");overlay_manager_classPrivateFieldGet(ag,this).set(e,{canForceClose:t});e.addEventListener("cancel",({target:e})=>{overlay_manager_classPrivateFieldGet(sg,this)===e&&overlay_manager_classPrivateFieldSet(sg,this,null)})}unregister(e){if(!overlay_manager_classPrivateFieldGet(ag,this).has(e))throw new Error("The overlay does not exist.");overlay_manager_classPrivateFieldGet(ag,this).delete(e)}async open(e){if(!overlay_manager_classPrivateFieldGet(ag,this).has(e))throw new Error("The overlay does not exist.");if(overlay_manager_classPrivateFieldGet(sg,this)){if(overlay_manager_classPrivateFieldGet(sg,this)===e)throw new Error("The overlay is already active.");if(!overlay_manager_classPrivateFieldGet(ag,this).get(e).canForceClose)throw new Error("Another overlay is currently active.");await this.close()}overlay_manager_classPrivateFieldSet(sg,this,e);e.showModal();e.classList.remove("hidden")}async close(e=overlay_manager_classPrivateFieldGet(sg,this),t=!1){if(!overlay_manager_classPrivateFieldGet(ag,this).has(e)){if(t)return;throw new Error("The overlay does not exist.")}if(!overlay_manager_classPrivateFieldGet(sg,this)){if(t)return;throw new Error("The overlay is currently not active.")}if(overlay_manager_classPrivateFieldGet(sg,this)!==e){if(t)return;throw new Error("Another overlay is currently active.")}e.close();overlay_manager_classPrivateFieldSet(sg,this,null)}async closeIfActive(e){overlay_manager_classPrivateFieldGet(sg,this)===e&&await this.close(e)}}function password_prompt_classPrivateFieldInitSpec(e,t,i){password_prompt_checkPrivateRedeclaration(e,t),t.set(e,i)}function password_prompt_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function password_prompt_classPrivateFieldSet(e,t,i){return e.set(password_prompt_assertClassBrand(e,t),i),i}function password_prompt_classPrivateFieldGet(e,t){return e.get(password_prompt_assertClassBrand(e,t))}function password_prompt_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var ng=new WeakMap,rg=new WeakMap,og=new WeakMap,lg=new WeakSet;class PasswordPrompt{constructor(e,t,i=!1){!function password_prompt_classPrivateMethodInitSpec(e,t){password_prompt_checkPrivateRedeclaration(e,t),t.add(e)}(this,lg);password_prompt_classPrivateFieldInitSpec(this,ng,null);password_prompt_classPrivateFieldInitSpec(this,rg,null);password_prompt_classPrivateFieldInitSpec(this,og,null);this.dialog=e.dialog;this.label=e.label;this.input=e.input;this.submitButton=e.submitButton;this.cancelButton=e.cancelButton;this.overlayManager=t;this._isViewerEmbedded=i;this.submitButton.addEventListener("click",password_prompt_assertClassBrand(lg,this,_verify).bind(this));this.cancelButton.addEventListener("click",this.close.bind(this));this.input.addEventListener("keydown",e=>{if(13===e.keyCode){password_prompt_assertClassBrand(lg,this,_verify).call(this);e.preventDefault()}});this.overlayManager.register(this.dialog,!0);this.dialog.addEventListener("close",password_prompt_assertClassBrand(lg,this,password_prompt_cancel).bind(this))}async open(){await(password_prompt_classPrivateFieldGet(ng,this)?.promise);password_prompt_classPrivateFieldSet(ng,this,Promise.withResolvers());try{await this.overlayManager.open(this.dialog);this.input.type="password";this.input.focus()}catch(e){password_prompt_classPrivateFieldGet(ng,this).resolve();throw e}const e=password_prompt_classPrivateFieldGet(og,this)===W.INCORRECT_PASSWORD;this._isViewerEmbedded&&!e||this.input.focus();this.label.setAttribute("data-l10n-id",e?"pdfjs-password-invalid":"pdfjs-password-label")}async close(){this.overlayManager.closeIfActive(this.dialog);this.input.value="";this.input.type="text"}async setUpdateCallback(e,t){password_prompt_classPrivateFieldGet(ng,this)&&await password_prompt_classPrivateFieldGet(ng,this).promise;password_prompt_classPrivateFieldSet(rg,this,e);password_prompt_classPrivateFieldSet(og,this,t)}}function _verify(){const e=this.input.value;e?.length>0&&password_prompt_assertClassBrand(lg,this,_invokeCallback).call(this,e)}function password_prompt_cancel(){password_prompt_assertClassBrand(lg,this,_invokeCallback).call(this,new Error("PasswordPrompt cancelled."));password_prompt_classPrivateFieldGet(ng,this).resolve()}function _invokeCallback(e){if(password_prompt_classPrivateFieldGet(rg,this)){this.close();this.input.value="";password_prompt_classPrivateFieldGet(rg,this).call(this,e);password_prompt_classPrivateFieldSet(rg,this,null)}}const dg="selected";class BaseTreeViewer{constructor(e){this.container=e.container;this.eventBus=e.eventBus;this._l10n=e.l10n;this.reset()}reset(){this._pdfDocument=null;this._lastToggleIsShow=!0;this._currentTreeItem=null;this.container.replaceChildren();this.container.classList.remove("withNesting")}_dispatchEvent(e){throw new Error("Not implemented: _dispatchEvent")}_bindLink(e,t){throw new Error("Not implemented: _bindLink")}_normalizeTextContent(e){return removeNullCharacters(e,!0)||"–"}_addToggleButton(e,t=!1){const i=document.createElement("div");i.className="treeItemToggler";t&&i.classList.add("treeItemsHidden");e.prepend(i)}_toggleTreeItem(e,t=!1){this._l10n.pause();this._lastToggleIsShow=t;for(const i of e.querySelectorAll(".treeItemToggler"))i.classList.toggle("treeItemsHidden",!t);this._l10n.resume()}_toggleAllTreeItems(){this._toggleTreeItem(this.container,!this._lastToggleIsShow)}_finishRendering(e,t,i=!1){if(i){this.container.classList.add("withNesting");this._lastToggleIsShow=!e.querySelector(".treeItemsHidden");this.container.addEventListener("click",e=>{const{target:t}=e;if(t.classList.contains("treeItemToggler")){stopEvent(e);t.classList.toggle("treeItemsHidden");if(e.shiftKey){const e=!t.classList.contains("treeItemsHidden");this._toggleTreeItem(t.parentNode,e)}}})}this._l10n.pause();this.container.append(e);this._l10n.resume();this._dispatchEvent(t)}render(e){throw new Error("Not implemented: render")}_updateCurrentTreeItem(e=null){if(this._currentTreeItem){this._currentTreeItem.classList.remove(dg);this._currentTreeItem=null}if(e){e.classList.add(dg);this._currentTreeItem=e}}_scrollToCurrentTreeItem(e){if(!e)return;this._l10n.pause();let t=e.parentNode;for(;t&&t!==this.container;){if(t.classList.contains("treeItem")){const e=t.firstElementChild;e?.classList.remove("treeItemsHidden")}t=t.parentNode}this._l10n.resume();this._updateCurrentTreeItem(e);e.scrollIntoView({behavior:"instant",block:"center",inline:"center",container:"nearest"})}}function pdf_attachment_viewer_classPrivateMethodInitSpec(e,t){(function pdf_attachment_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}var cg=new WeakSet;class PDFAttachmentViewer extends BaseTreeViewer{constructor(e){super(e);pdf_attachment_viewer_classPrivateMethodInitSpec(this,cg);this.downloadManager=e.downloadManager;this.linkService=e.linkService;this.eventBus.on("fileattachmentannotation",function pdf_attachment_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}(cg,this,_appendAttachment).bind(this),Nh)}reset(e=!1){super.reset();this._attachments=null;e||(this._renderedCapability=Promise.withResolvers());this._pendingDispatchEvent=!1}async _dispatchEvent(e){this._renderedCapability.resolve();if(0===e&&!this._pendingDispatchEvent){this._pendingDispatchEvent=!0;await waitOnEventOrTimeout({target:this.eventBus,name:"annotationlayerrendered",delay:1e3});if(!this._pendingDispatchEvent)return}this._pendingDispatchEvent=!1;this.eventBus.dispatch("attachmentsloaded",{source:this,attachmentsCount:e})}_bindLink(e,{attachmentId:t,content:i,description:a,filename:s}){a&&(e.title=a);const openAttachment=async()=>{const e=t?await this.linkService.getAttachmentContent(t):i;e&&this.downloadManager?.openOrDownloadData(e,s)};e.onclick=()=>{openAttachment();return!1}}render({attachments:e,keepRenderedCapability:t=!1}){this._attachments&&this.reset(t);this._attachments=e||null;if(!e){this._dispatchEvent(0);return}const i=document.createDocumentFragment(),a=document.createElement("ul");i.append(a);let s=0;for(const[t,i]of e){const e=document.createElement("li");a.append(e);const n=document.createElement("a");e.append(n);this._bindLink(n,{...i,attachmentId:i.attachmentId??t});n.textContent=this._normalizeTextContent(i.filename);s++}this._finishRendering(i,s)}}function _appendAttachment(e){const t=this._renderedCapability.promise;t.then(()=>{if(t!==this._renderedCapability.promise)return;const i=new Map(this._attachments);if(!i.has(e.filename)){i.set(e.filename,e);this.render({attachments:i,keepRenderedCapability:!0})}})}function grab_to_pan_classPrivateFieldInitSpec(e,t,i){grab_to_pan_checkPrivateRedeclaration(e,t),t.set(e,i)}function grab_to_pan_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function grab_to_pan_classPrivateFieldSet(e,t,i){return e.set(grab_to_pan_assertClassBrand(e,t),i),i}function grab_to_pan_classPrivateFieldGet(e,t){return e.get(grab_to_pan_assertClassBrand(e,t))}function grab_to_pan_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const hg="grab-to-pan-grab";var ug=new WeakMap,_g=new WeakMap,pg=new WeakMap,gg=new WeakSet;class GrabToPan{constructor({element:e}){!function grab_to_pan_classPrivateMethodInitSpec(e,t){grab_to_pan_checkPrivateRedeclaration(e,t),t.add(e)}(this,gg);grab_to_pan_classPrivateFieldInitSpec(this,ug,null);grab_to_pan_classPrivateFieldInitSpec(this,_g,null);grab_to_pan_classPrivateFieldInitSpec(this,pg,null);this.element=e;this.document=e.ownerDocument;(this.overlay=document.createElement("div")).className="grab-to-pan-grabbing"}activate(){if(!grab_to_pan_classPrivateFieldGet(ug,this)){grab_to_pan_classPrivateFieldSet(ug,this,new AbortController);this.element.addEventListener("mousedown",grab_to_pan_assertClassBrand(gg,this,_onMouseDown).bind(this),{capture:!0,signal:grab_to_pan_classPrivateFieldGet(ug,this).signal});this.element.classList.add(hg)}}deactivate(){if(grab_to_pan_classPrivateFieldGet(ug,this)){grab_to_pan_classPrivateFieldGet(ug,this).abort();grab_to_pan_classPrivateFieldSet(ug,this,null);grab_to_pan_assertClassBrand(gg,this,_endPan).call(this);this.element.classList.remove(hg)}}ignoreTarget(e){return e.matches("a[href], a[href] *, input, textarea, button, button *, select, option")}}function _onMouseDown(e){if(0!==e.button||this.ignoreTarget(e.target))return;if(e.originalTarget)try{e.originalTarget.tagName}catch{return}this.scrollLeftStart=this.element.scrollLeft;this.scrollTopStart=this.element.scrollTop;this.clientXStart=e.clientX;this.clientYStart=e.clientY;if(isOverPerfectScrollbar(this.clientXStart,this.clientYStart,"ps__rail-x"))return;if(isOverPerfectScrollbar(this.clientXStart,this.clientYStart,"ps__rail-y"))return;grab_to_pan_classPrivateFieldSet(_g,this,new AbortController);const t=grab_to_pan_assertClassBrand(gg,this,_endPan).bind(this),i={capture:!0,signal:grab_to_pan_classPrivateFieldGet(_g,this).signal};this.document.addEventListener("mousemove",grab_to_pan_assertClassBrand(gg,this,_onMouseMove).bind(this),i);this.document.addEventListener("mouseup",t,i);grab_to_pan_classPrivateFieldSet(pg,this,new AbortController);this.element.addEventListener("scroll",t,{capture:!0,signal:grab_to_pan_classPrivateFieldGet(pg,this).signal});stopEvent(e);const a=document.activeElement;a&&!a.contains(e.target)&&a.blur()}function _onMouseMove(e){grab_to_pan_classPrivateFieldGet(pg,this)?.abort();grab_to_pan_classPrivateFieldSet(pg,this,null);if(!(1&e.buttons)){grab_to_pan_assertClassBrand(gg,this,_endPan).call(this);return}const t=e.clientX-this.clientXStart,i=e.clientY-this.clientYStart;this.element.scrollTo({top:this.scrollTopStart-i,left:this.scrollLeftStart-t,behavior:"instant"});this.overlay.parentNode||document.body.append(this.overlay)}function _endPan(){grab_to_pan_classPrivateFieldGet(_g,this)?.abort();grab_to_pan_classPrivateFieldSet(_g,this,null);grab_to_pan_classPrivateFieldGet(pg,this)?.abort();grab_to_pan_classPrivateFieldSet(pg,this,null);this.overlay.remove()}function isOverPerfectScrollbar(e,t,i){const a=document.getElementsByClassName(i);if(a&&1===a.length){var{top:s,right:n,bottom:r,left:o}=a[0].getBoundingClientRect();if(t>=s&&t<=r&&e<=n&&e>=o)return!0}return!1}function pdf_cursor_tools_classPrivateFieldInitSpec(e,t,i){pdf_cursor_tools_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_cursor_tools_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_cursor_tools_classPrivateFieldSet(e,t,i){return e.set(pdf_cursor_tools_assertClassBrand(e,t),i),i}function pdf_cursor_tools_classPrivateFieldGet(e,t){return e.get(pdf_cursor_tools_assertClassBrand(e,t))}function pdf_cursor_tools_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var mg=new WeakMap,fg=new WeakMap,vg=new WeakSet;class PDFCursorTools{constructor({container:e,eventBus:t,cursorToolOnLoad:i=yh}){!function pdf_cursor_tools_classPrivateMethodInitSpec(e,t){pdf_cursor_tools_checkPrivateRedeclaration(e,t),t.add(e)}(this,vg);pdf_cursor_tools_classPrivateFieldInitSpec(this,mg,yh);pdf_cursor_tools_classPrivateFieldInitSpec(this,fg,null);this.container=e;this.eventBus=t;pdf_cursor_tools_assertClassBrand(vg,this,pdf_cursor_tools_addEventListeners).call(this);Promise.resolve().then(()=>{this.switchTool(i)})}get activeTool(){return pdf_cursor_tools_classPrivateFieldGet(mg,this)}switchTool(e){null===pdf_cursor_tools_classPrivateFieldGet(fg,this)&&pdf_cursor_tools_assertClassBrand(vg,this,_switchTool).call(this,e)}get _handTool(){return shadow(this,"_handTool",new GrabToPan({element:this.container}))}}function _switchTool(e,t=!1){if(e===pdf_cursor_tools_classPrivateFieldGet(mg,this)){null!==pdf_cursor_tools_classPrivateFieldGet(fg,this)&&this.eventBus.dispatch("cursortoolchanged",{source:this,tool:e,disabled:t});return}const disableActiveTool=()=>{switch(pdf_cursor_tools_classPrivateFieldGet(mg,this)){case yh:break;case Sh:this._handTool.deactivate()}};switch(e){case yh:disableActiveTool();break;case Sh:disableActiveTool();this._handTool.activate();break;case Ch:disableActiveTool();break;default:ngx_console_NgxConsole.error(`switchTool: "${e}" is an unsupported value.`);return}pdf_cursor_tools_classPrivateFieldSet(mg,this,e);this.eventBus.dispatch("cursortoolchanged",{source:this,tool:e,disabled:t})}function pdf_cursor_tools_addEventListeners(){const{eventBus:e}=this;e.on("switchcursortool",e=>{if(e.reset){if(null!==pdf_cursor_tools_classPrivateFieldGet(fg,this)){t=f.NONE;i=dh;enableActive()}}else this.switchTool(e.tool)},Nh);let t=f.NONE,i=dh;const disableActive=()=>{pdf_cursor_tools_classPrivateFieldGet(fg,this)??pdf_cursor_tools_classPrivateFieldSet(fg,this,pdf_cursor_tools_classPrivateFieldGet(mg,this));pdf_cursor_tools_assertClassBrand(vg,this,_switchTool).call(this,yh,!0)},enableActive=()=>{if(null!==pdf_cursor_tools_classPrivateFieldGet(fg,this)&&t===f.NONE&&i===dh){pdf_cursor_tools_assertClassBrand(vg,this,_switchTool).call(this,pdf_cursor_tools_classPrivateFieldGet(fg,this));pdf_cursor_tools_classPrivateFieldSet(fg,this,null)}};e.on("annotationeditormodechanged",({mode:e})=>{t=e;e===f.NONE?enableActive():disableActive()},Nh);e.on("presentationmodechanged",({state:e})=>{i=e;e===dh?enableActive():e===hh&&disableActive()},Nh)}function pdf_document_properties_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_document_properties_classPrivateFieldSet(e,t,i){return e.set(pdf_document_properties_assertClassBrand(e,t),i),i}function pdf_document_properties_classPrivateFieldGet(e,t){return e.get(pdf_document_properties_assertClassBrand(e,t))}function pdf_document_properties_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const Pg=["en-us","en-lr","my"],wg={"8.5x11":"pdfjs-document-properties-page-size-name-letter","8.5x14":"pdfjs-document-properties-page-size-name-legal"},Fg={"297x420":"pdfjs-document-properties-page-size-name-a-three","210x297":"pdfjs-document-properties-page-size-name-a-four"};function getPageName(e,t,i){return i[`${t?e.width:e.height}x${t?e.height:e.width}`]}var bg=new WeakMap,yg=new WeakSet;class PDFDocumentProperties{constructor({dialog:e,fields:t,closeButton:i},a,s,n,r,o){!function pdf_document_properties_classPrivateMethodInitSpec(e,t){pdf_document_properties_checkPrivateRedeclaration(e,t),t.add(e)}(this,yg);!function pdf_document_properties_classPrivateFieldInitSpec(e,t,i){pdf_document_properties_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,bg,null);this.dialog=e;this.fields=t;this.overlayManager=a;this.l10n=n;this._fileNameLookup=r;this.eventBus=s;this._titleLookup=o;pdf_document_properties_assertClassBrand(yg,this,_reset).call(this);i.addEventListener("click",this.close.bind(this));this.overlayManager.register(this.dialog);s.on("pagechanging",e=>{this._currentPageNumber=e.pageNumber},Nh);s.on("rotationchanging",e=>{this._pagesRotation=e.pagesRotation},Nh)}async open(){await Promise.all([this.overlayManager.open(this.dialog),this._dataAvailableCapability.promise]);this.eventBus.dispatch("propertiesdialogopen",this);const e=this._currentPageNumber,t=this._pagesRotation;if(pdf_document_properties_classPrivateFieldGet(bg,this)&&e===pdf_document_properties_classPrivateFieldGet(bg,this)._currentPageNumber&&t===pdf_document_properties_classPrivateFieldGet(bg,this)._pagesRotation){pdf_document_properties_assertClassBrand(yg,this,_updateUI).call(this);return}const[{info:i,metadata:a,contentLength:s},n]=await Promise.all([this.pdfDocument.getMetadata(),this.pdfDocument.getPage(e).catch(t=>{console.error(`PDFDocumentProperties - unable to get page ${e}.`,t);return null})]),[r,o,l,d,c,h,u]=await Promise.all([this._fileNameLookup(),pdf_document_properties_assertClassBrand(yg,this,_parseFileSize).call(this,s),this._titleLookup(),pdf_document_properties_assertClassBrand(yg,this,_parseDate).call(this,a?.get("xmp:createdate"),i.CreationDate),pdf_document_properties_assertClassBrand(yg,this,_parseDate).call(this,a?.get("xmp:modifydate"),i.ModDate),pdf_document_properties_assertClassBrand(yg,this,_parsePageSize).call(this,n,t),pdf_document_properties_assertClassBrand(yg,this,_parseLinearization).call(this,i.IsLinearized)]);pdf_document_properties_classPrivateFieldSet(bg,this,Object.freeze({fileName:r,fileSize:o,title:l,author:a?.get("dc:creator")?.join("\n")||i.Author,subject:a?.get("dc:subject")?.join("\n")||i.Subject,keywords:a?.get("pdf:keywords")||i.Keywords,creationDate:d,modificationDate:c,creator:a?.get("xmp:creatortool")||i.Creator,producer:a?.get("pdf:producer")||i.Producer,version:i.PDFFormatVersion,pageCount:this.pdfDocument.numPages,pageSize:h,linearized:u,_currentPageNumber:e,_pagesRotation:t}));pdf_document_properties_assertClassBrand(yg,this,_updateUI).call(this);const{length:_}=await this.pdfDocument.getDownloadInfo();if(s===_)return;const p=Object.assign(Object.create(null),pdf_document_properties_classPrivateFieldGet(bg,this));p.fileSize=await pdf_document_properties_assertClassBrand(yg,this,_parseFileSize).call(this,_);pdf_document_properties_classPrivateFieldSet(bg,this,Object.freeze(p));pdf_document_properties_assertClassBrand(yg,this,_updateUI).call(this)}async close(){this.overlayManager.close(this.dialog,!0);this.eventBus.dispatch("propertiesdialogclose",this)}setDocument(e){if(this.pdfDocument){pdf_document_properties_assertClassBrand(yg,this,_reset).call(this);pdf_document_properties_assertClassBrand(yg,this,_updateUI).call(this)}if(e){this.pdfDocument=e;this._dataAvailableCapability.resolve()}}}function _reset(){this.pdfDocument=null;pdf_document_properties_classPrivateFieldSet(bg,this,null);this._dataAvailableCapability=Promise.withResolvers();this._currentPageNumber=1;this._pagesRotation=0}function _updateUI(){if(!pdf_document_properties_classPrivateFieldGet(bg,this)||this.overlayManager.active===this.dialog)for(const e in this.fields){const t=pdf_document_properties_classPrivateFieldGet(bg,this)?.[e];this.fields[e].textContent=t||0===t?t:"-"}}async function _parseFileSize(e=0){const t=e/1024,i=t/1024;return t?this.l10n.get(i>=1?"pdfjs-document-properties-size-mb":"pdfjs-document-properties-size-kb",{mb:i,kb:t,b:e}):void 0}async function _parsePageSize(e,t){if(!e)return;let i=function getPageSizeInches({view:e,userUnit:t,rotate:i}){const[a,s,n,r]=e,o=i%180!=0,l=(n-a)/72*t,d=(r-s)/72*t;return{width:o?d:l,height:o?l:d}}(e);t%180!=0&&(i={width:i.height,height:i.width});const a=isPortraitOrientation(i),s=Pg.includes(this.l10n.getLanguage());let n={width:Math.round(100*i.width)/100,height:Math.round(100*i.height)/100},r={width:Math.round(25.4*i.width*10)/10,height:Math.round(25.4*i.height*10)/10},o=getPageName(n,a,wg)||getPageName(r,a,Fg);if(!(o||Number.isInteger(r.width)&&Number.isInteger(r.height))){const e={width:25.4*i.width,height:25.4*i.height},t={width:Math.round(r.width),height:Math.round(r.height)};if(Math.abs(e.width-t.width)<.1&&Math.abs(e.height-t.height)<.1){o=getPageName(t,a,Fg);if(o){n={width:Math.round(t.width/25.4*100)/100,height:Math.round(t.height/25.4*100)/100};r=t}}}const[{width:l,height:d},c,h,u]=await Promise.all([s?n:r,this.l10n.get(s?"pdfjs-document-properties-page-size-unit-inches":"pdfjs-document-properties-page-size-unit-millimeters"),o&&this.l10n.get(o),this.l10n.get(a?"pdfjs-document-properties-page-size-orientation-portrait":"pdfjs-document-properties-page-size-orientation-landscape")]);return this.l10n.get(h?"pdfjs-document-properties-page-size-dimension-name-string":"pdfjs-document-properties-page-size-dimension-string",{width:l,height:d,unit:c,name:h,orientation:u})}async function _parseDate(e,t){const i=Date.parse(e)||PDFDateString.toDateObject(t);return i?this.l10n.get("pdfjs-document-properties-date-time-string",{dateObj:i.valueOf()}):void 0}function _parseLinearization(e){return this.l10n.get(e?"pdfjs-document-properties-linearized-yes":"pdfjs-document-properties-linearized-no")}let Sg,Cg=null,xg=null;function isWordBreakAt(e,t){xg||=new Intl.Segmenter(void 0,{granularity:"grapheme"});const i=xg.segment(e),a=i.containing(t);if(a.index!==t)return!1;Cg||=new Intl.Segmenter(void 0,{granularity:"word"});const s=i.containing(t-1).segment;return Cg.segment(s+a.segment).containing(s.length).index===s.length}function isEntireWord(e,t,i){const a=t+i;return(0===t||isWordBreakAt(e,t))&&(a===e.length||isWordBreakAt(e,a))}function pdf_find_controller_classPrivateFieldInitSpec(e,t,i){pdf_find_controller_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_find_controller_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_find_controller_classPrivateGetter(e,t,i){return i(pdf_find_controller_assertClassBrand(e,t))}function pdf_find_controller_classPrivateFieldGet(e,t){return e.get(pdf_find_controller_assertClassBrand(e,t))}function pdf_find_controller_classPrivateFieldSet(e,t,i){return e.set(pdf_find_controller_assertClassBrand(e,t),i),i}function pdf_find_controller_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const kg=0,Eg=1,Ag=2,Gg=3,Bg=new Map([["‐","-"],["‘","'"],["’","'"],["‚","'"],["‛","'"],["“",'"'],["”",'"'],["„",'"'],["‟",'"'],["¼","1/4"],["½","1/2"],["¾","3/4"]]),Mg=new Set([12441,12442,2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,3642,3770,3972,4153,4154,5908,5940,6098,6752,6980,7082,7083,7154,7155,11647,43014,43052,43204,43347,43456,43766,44013,3158,3953,3954,3962,3963,3964,3965,3968,3956]);let Ig;const Tg=/\p{M}+/gu,Dg=/([+^$|])|(\p{P}+)|(\s+)|(\p{M})|(\p{L})/gu,Lg=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,Ng=new Map,Rg=new Map;let Og=null,Wg=null;function normalize(e,t={}){const i=[];let a;for(;null!==(a=Lg.exec(e));){let{index:e}=a;for(const t of a[0]){let a=Ng.get(t);if(!a){a=t.normalize("NFD").length;Ng.set(t,a)}i.push([a,e++])}}const s=i.length>0,n=t.ignoreDashEOL??!1;let r;if(!s&&Og)r=Og;else if(s&&Wg)r=Wg;else{const e=Bg.keys().join(""),t=function getNormalizeWithNFKC(){if(!Sg){const e=[],t=[],i=/^\p{M}$/u;for(let a=0;a<65536;a++){if(a>=55296&&a<=57343)continue;const s=String.fromCharCode(a);if(s.normalize("NFKC")!==s&&!i.test(s)){if(2!==t.length){t[0]=t[1]=a;continue}if(t[1]+1!==a){t[0]===t[1]?e.push(String.fromCharCode(t[0])):e.push(`${String.fromCharCode(t[0])}-${String.fromCharCode(t[1])}`);t[0]=t[1]=a}else t[1]=a}}const a=e.join("");if(Sg){if(a!==Sg){for(let e=1;e<a.length;e++)if(a[e]!==Sg[e]){console.log(`Difference at index ${e}: U+${a.charCodeAt(e).toString(16).toUpperCase().padStart(4,"0")}!== U+${Sg.charCodeAt(e).toString(16).toUpperCase().padStart(4,"0")}`);break}throw new Error("getNormalizeWithNFKC - update the `NormalizeWithNFKC` string.")}}else Sg=a}return Sg}();r=new RegExp([`[${e}]`,`[${t}]`,`${"(?:゙|゚)"}\\n`,"\\p{M}+(?:-\\n)?",`${"\\p{Ll}-\\n(?=\\p{Ll})|\\p{Lu}-\\n(?=\\p{L})"}`,"\\S-\\n",`${"(?:\\p{Ideographic}|[-ヿ])"}\\n`,"\\n",s?"[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]":"\\u0000"].map(e=>`(${e})`).join("|"),"gmu");s?Wg=r:Og=r}const o=[];for(;null!==(a=Tg.exec(e));)o.push([a[0].length,a.index]);let l=e.normalize("NFD");const d=[0,0];let c=0,h=0,u=0,_=0,p=0,g=!1;l=l.replace(r,(e,t,a,s,r,l,m,f,v,P,w)=>{w-=_;if(t){const e=Bg.get(t),i=e.length;for(let e=1;e<i;e++)d.push(w-u+e,u-e);u-=i-1;return e}if(a){const e=Rg.getOrInsertComputed(a,()=>a.normalize("NFKC")),t=e.length;for(let e=1;e<t;e++)d.push(w-u+e,u-e);u-=t-1;return e}if(s){g=!0;if(w+p===o[c]?.[1])++c;else{d.push(w-1-u+1,u-1);u-=1;_+=1}d.push(w-u+1,u);_+=1;p+=1;return s.charAt(0)}if(r){const e=r.endsWith("\n"),t=e?r.length-2:r.length;g=!0;let i=t;if(w+p===o[c]?.[1]){i-=o[c][0];++c}for(let e=1;e<=i;e++)d.push(w-1-u+e,u-e);u-=i;_+=i;if(e){w+=t-1;d.push(w-u+1,1+u);u+=1;_+=1;p+=1;return r.slice(0,t)}return r}if(l){if(n){_+=1;p+=1;return l.slice(0,-1)}const e=l.length-2;d.push(w-u+e,1+u);u+=1;_+=1;p+=1;return l.slice(0,-2)}if(m){_+=1;p+=1;return m.slice(0,-1)}if(f){const e=f.length-1;d.push(w-u+e,u);_+=1;p+=1;return f.slice(0,-1)}if(v){d.push(w-u+1,u-1);u-=1;_+=1;p+=1;return" "}if(w+p===i[h]?.[1]){const e=i[h][0]-1;++h;for(let t=1;t<=e;t++)d.push(w-(u-t),u-t);u-=e;_+=e}return P});d.push(l.length,u);const m=new Uint32Array(d.length>>1),f=new Int32Array(d.length>>1);for(let e=0,t=d.length;e<t;e+=2){m[e>>1]=d[e];f[e>>1]=d[e+1]}return[l,[m,f],g]}function getOriginalIndex(e,t,i){if(!e)return[t,i];const[a,s]=e,n=t,r=t+i-1;let o=binarySearchFirstItem(a,e=>e>=n);a[o]>n&&--o;let l=binarySearchFirstItem(a,e=>e>=r,o);a[l]>r&&--l;const d=n+s[o];return[d,r+s[l]+1-d]}var jg=new WeakMap,Vg=new WeakMap,Ug=new WeakMap,zg=new WeakMap,Hg=new WeakMap,$g=new WeakMap,Kg=new WeakSet;class PDFFindController{constructor({linkService:e,eventBus:t,delay:i=250,updateMatchesCountOnProgress:a=!0,pageViewMode:s,listenToEventBus:n}){!function pdf_find_controller_classPrivateMethodInitSpec(e,t){pdf_find_controller_checkPrivateRedeclaration(e,t),t.add(e)}(this,Kg);pdf_find_controller_classPrivateFieldInitSpec(this,jg,null);pdf_find_controller_classPrivateFieldInitSpec(this,Vg,!0);pdf_find_controller_classPrivateFieldInitSpec(this,Ug,0);pdf_find_controller_classPrivateFieldInitSpec(this,zg,0);pdf_find_controller_classPrivateFieldInitSpec(this,Hg,null);pdf_find_controller_classPrivateFieldInitSpec(this,$g,null);this._linkService=e;this._eventBus=t;pdf_find_controller_classPrivateFieldSet(Vg,this,a);this._pageViewMode=s;pdf_find_controller_classPrivateFieldSet(Ug,this,i);this.onIsPageVisible=null;pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_reset).call(this);this._eventBus.on("pageviewmodechanged",({pageViewMode:e})=>{this._pageViewMode=e});if(n){t.on("find",pdf_find_controller_assertClassBrand(Kg,this,_onFind).bind(this),Nh);t.on("findbarclose",pdf_find_controller_assertClassBrand(Kg,this,_onFindBarClose).bind(this),Nh);t.on("pagesedited",pdf_find_controller_assertClassBrand(Kg,this,_onPagesEdited).bind(this),Nh)}}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get pageMatchesColor(){return this._pageMatchesColor}get selected(){return this._selected}get state(){return pdf_find_controller_classPrivateFieldGet(jg,this)}setDocument(e){this._pdfDocument&&pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_reset).call(this);if(e){this._pdfDocument=e;this._firstPageCapability.resolve()}}ngxFind(e){const t=[];this._findResultResolvers=[];for(let e=0,i=this._linkService.pagesCount;e<i;e++){const{promise:i,resolve:a}=Promise.withResolvers();t[e]=i;this._findResultResolvers[e]=a}pdf_find_controller_assertClassBrand(Kg,this,_onFind).call(this,e);return t}ngxFindNext(){const e={...pdf_find_controller_classPrivateFieldGet(jg,this),type:"again",findPrevious:!1};pdf_find_controller_assertClassBrand(Kg,this,_onFind).call(this,e)}ngxFindPrevious(){const e={...pdf_find_controller_classPrivateFieldGet(jg,this),type:"again",findPrevious:!0};pdf_find_controller_assertClassBrand(Kg,this,_onFind).call(this,e)}scrollMatchIntoView({element:e=null,pageIndex:t=-1,matchIndex:i=-1}){if(!pdf_find_controller_classPrivateFieldGet(jg,this)?.dontScrollIntoView&&this._scrollMatches&&e){this._scrollMatches=!1;"infinite-scroll"===this._pageViewMode?scrollIntoView(e,{top:-50,left:0},!0,!0):e.scrollIntoView({block:"start",inline:"center"})}}_convertToRegExpString(e,t){const{matchDiacritics:i}=pdf_find_controller_classPrivateFieldGet(jg,this);let a=!1;const addExtraWhitespaces=(t,i)=>t===e?i:e.startsWith(t)?`${i}[ ]*`:e.endsWith(t)?`[ ]*${i}`:`[ ]*${i}[ ]*`,s="[ ]*";(e=e.replaceAll(Dg,(e,s,n,r,o,l)=>{if(s)return addExtraWhitespaces(s,RegExp.escape(s));if(n)return addExtraWhitespaces(n,RegExp.escape(n));if(r)return"[ ]+";if(i)return o||l;if(o)return Mg.has(o.charCodeAt(0))?o:"";if(t){a=!0;return`${l}\\p{M}*`}return l})).endsWith(s)&&(e=e.slice(0,e.length-4));if(i&&t){Ig||=String.fromCharCode(...Mg);a=!0;e=`${e}(?=[${Ig}]|[^\\p{M}]|$)`}return[a,e]}_calculateMatch(e){var t;if(!pdf_find_controller_classPrivateFieldGet(jg,this))return;const i=pdf_find_controller_classPrivateGetter(Kg,this,_get_query);if(0===i.length)return;const a=this._pageContents[e],s=this.match(i,a,e),n=this._pageMatches[e]=[],r=this._pageMatchesLength[e]=[],o=this._pageMatchesColor[e]=[],l=this._pageDiffs[e];s?.forEach(({index:e,length:t,color:i})=>{const[a,s]=getOriginalIndex(l,e,t);if(s){n.push(a);r.push(s);o.push(i||0)}});pdf_find_controller_classPrivateFieldGet(jg,this).highlightAll&&pdf_find_controller_assertClassBrand(Kg,this,_updatePage).call(this,e);if(this._resumePageIdx===e){this._resumePageIdx=null;pdf_find_controller_assertClassBrand(Kg,this,_nextPageMatch).call(this)}const d=n.length;this._matchesCountTotal+=d;pdf_find_controller_classPrivateFieldGet(Vg,this)?d>0&&pdf_find_controller_assertClassBrand(Kg,this,_updateUIResultsCount).call(this,e):pdf_find_controller_classPrivateFieldSet(zg,this,(t=pdf_find_controller_classPrivateFieldGet(zg,this),++t))===this._linkService.pagesCount&&pdf_find_controller_assertClassBrand(Kg,this,_updateUIResultsCount).call(this,e)}match(e,t,i){const a=this._hasDiacritics[i];let s=!1;const{caseSensitive:n,findMultiple:r,matchRegExp:o}=pdf_find_controller_classPrivateFieldGet(jg,this);r&&"string"==typeof e&&(e=e.trim().split(/\s+/));let l=null;if(o&&"string"==typeof e){e=new RegExp(e,n?"g":"gi");s=a}else if("string"==typeof e)[s,e]=this._convertToRegExpString(e,a);else{const t=[...e];e=e.sort().reverse().map(e=>{const[t,i]=this._convertToRegExpString(e,a);s||=t;return`(${i})`}).join("|");l=[...t].sort().reverse().map(e=>t.indexOf(e))}if(!e)return;const{entireWord:d}=pdf_find_controller_classPrivateFieldGet(jg,this);e=new RegExp(e,`g${s?"u":""}${n?"":"i"}`);const c=[];let h;for(;null!==(h=e.exec(t));){if(d&&!isEntireWord(t,h.index,h[0].length))continue;let e=0;if(l)for(let t=1;t<h.length;t++)if(void 0!==h[t]){e=l[t-1]%5;break}c.push({index:h.index,length:h[0].length,color:e})}return c}}function _onFind(e){if(!e)return;const t=this._pdfDocument,{type:i}=e;(null===pdf_find_controller_classPrivateFieldGet(jg,this)||pdf_find_controller_assertClassBrand(Kg,this,_shouldDirtyMatch).call(this,e))&&(this._dirtyMatch=!0);pdf_find_controller_classPrivateFieldSet(jg,this,e);if("highlightallchange"!==i)pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_updateUIState).call(this,Gg);else{const e=this._pageMatches.some(e=>e.length>0),t=!this.state?.query||e;pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_updateUIState).call(this,t?kg:Eg)}this._firstPageCapability.promise.then(()=>{if(!this._pdfDocument||t&&this._pdfDocument!==t)return;pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_extractText).call(this);const e=!this._highlightMatches,a=!!this._findTimeout;if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}if(i)if(this._dirtyMatch)pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this);else if("again"===i){pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this);e&&pdf_find_controller_classPrivateFieldGet(jg,this).highlightAll&&pdf_find_controller_assertClassBrand(Kg,this,_updateAllPages).call(this)}else if("highlightallchange"===i){a?pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this):this._highlightMatches=!0;pdf_find_controller_assertClassBrand(Kg,this,_updateAllPages).call(this)}else pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this);else this._findTimeout=setTimeout(()=>{pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this);this._findTimeout=null},pdf_find_controller_classPrivateFieldGet(Ug,this))})}function pdf_find_controller_reset(){this._highlightMatches=!1;this._scrollMatches=!1;this._pdfDocument=null;this._pageMatches=[];this._pageMatchesLength=[];this._pageMatchesColor=[];pdf_find_controller_classPrivateFieldSet(zg,this,0);pdf_find_controller_classPrivateFieldSet(jg,this,null);this._selected={pageIdx:-1,matchIdx:-1};this._offset={pageIdx:null,matchIdx:null,wrapped:!1};this._extractTextPromises=[];this._findResultResolvers=[];this._pageContents=[];this._pageDiffs=[];this._hasDiacritics=[];this._matchesCountTotal=0;this._pagesToSearch=null;this._pendingFindMatches=new Set;this._resumePageIdx=null;this._dirtyMatch=!1;clearTimeout(this._findTimeout);this._findTimeout=null;pdf_find_controller_classPrivateFieldSet(Hg,this,null);this._firstPageCapability=Promise.withResolvers()}function _get_query(e){const{query:t}=pdf_find_controller_classPrivateFieldGet(jg,e);if("string"==typeof t){if(t!==e._rawQuery){e._rawQuery=t;[e._normalizedQuery]=normalize(t)}return e._normalizedQuery}return(t||[]).filter(e=>!!e).map(e=>normalize(e)[0])}function _shouldDirtyMatch(e){const t=e.query,i=pdf_find_controller_classPrivateFieldGet(jg,this).query,a=typeof t;if(a!==typeof i)return!0;if("string"===a){if(t!==i)return!0}else if(JSON.stringify(t)!==JSON.stringify(i))return!0;switch(e.type){case"again":const e=this._selected.pageIdx+1,t=this._linkService;return e>=1&&e<=t.pagesCount&&e!==t.page&&!(this.onIsPageVisible?.(e)??1);case"highlightallchange":return!1}return!0}function pdf_find_controller_extractText(){if(this._extractTextPromises.length>0)return;let e=Promise.resolve();const t={disableNormalization:!0},i=this._pdfDocument;for(let a=0,s=this._linkService.pagesCount;a<s;a++){const{promise:s,resolve:n}=Promise.withResolvers();this._extractTextPromises[a]=s;e=e.then(async()=>{if(i===this._pdfDocument){try{const e=await i.getPage(a+1),s=await e.getTextContent(t);if(i!==this._pdfDocument){n();return}const r=[];for(const e of s.items){r.push(e.str);e.hasEOL&&r.push("\n")}[this._pageContents[a],this._pageDiffs[a],this._hasDiacritics[a]]=normalize(r.join(""))}catch(e){if(i!==this._pdfDocument){n();return}ngx_console_NgxConsole.error(`Unable to get text content for page ${a+1}`,e);[this._pageContents[a],this._pageDiffs[a],this._hasDiacritics[a]]=["",null,!1]}n()}else n()})}}function _updatePage(e){this._scrollMatches&&this._selected.pageIdx===e&&(this.state.dontScrollIntoView||(this._linkService.page=e+1));this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:e})}function _updateAllPages(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}function _nextMatch(){const e=pdf_find_controller_classPrivateFieldGet(jg,this).findPrevious,t=this._linkService.page-1,i=this._linkService.pagesCount;this._highlightMatches=!0;if(this._dirtyMatch){this._dirtyMatch=!1;this._selected.pageIdx=this._selected.matchIdx=-1;this._offset.pageIdx=t;this._offset.matchIdx=null;this._offset.wrapped=!1;this._resumePageIdx=null;this._pageMatches.length=0;this._pageMatchesLength.length=0;pdf_find_controller_classPrivateFieldSet(zg,this,0);this._matchesCountTotal=0;pdf_find_controller_assertClassBrand(Kg,this,_updateAllPages).call(this);for(let e=0;e<i;e++)if(!this._pendingFindMatches.has(e)){this._pendingFindMatches.add(e);this._extractTextPromises[e].then(()=>{this._pendingFindMatches.delete(e);this._calculateMatch(e)})}}if(0===pdf_find_controller_classPrivateGetter(Kg,this,_get_query).length){pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_updateUIState).call(this,kg);return}if(this._resumePageIdx)return;const a=this._offset;this._pagesToSearch=i;if(null!==a.matchIdx){const t=this._pageMatches[a.pageIdx].length;if(!e&&a.matchIdx+1<t||e&&a.matchIdx>0){a.matchIdx=e?a.matchIdx-1:a.matchIdx+1;pdf_find_controller_assertClassBrand(Kg,this,_updateMatch).call(this,!0);return}pdf_find_controller_assertClassBrand(Kg,this,_advanceOffsetPage).call(this,e)}pdf_find_controller_assertClassBrand(Kg,this,_nextPageMatch).call(this)}function _matchesReady(e){const t=this._offset,i=e.length,a=pdf_find_controller_classPrivateFieldGet(jg,this).findPrevious;if(i){t.matchIdx=a?i-1:0;pdf_find_controller_assertClassBrand(Kg,this,_updateMatch).call(this,!0);return!0}pdf_find_controller_assertClassBrand(Kg,this,_advanceOffsetPage).call(this,a);if(t.wrapped){t.matchIdx=null;if(this._pagesToSearch<0){pdf_find_controller_assertClassBrand(Kg,this,_updateMatch).call(this,!1);return!0}}return!1}function _nextPageMatch(){null!==this._resumePageIdx&&ngx_console_NgxConsole.error("There can only be one pending page.");let e=null;do{const t=this._offset.pageIdx;e=this._pageMatches[t];if(!e){this._resumePageIdx=t;break}}while(!pdf_find_controller_assertClassBrand(Kg,this,_matchesReady).call(this,e))}function _advanceOffsetPage(e){const t=this._offset,i=this._linkService.pagesCount;t.pageIdx=e?t.pageIdx-1:t.pageIdx+1;t.matchIdx=null;this._pagesToSearch--;if(t.pageIdx>=i||t.pageIdx<0){t.pageIdx=e?i-1:0;t.wrapped=!0}}function _updateMatch(e=!1){let t=Eg;const i=this._offset.wrapped;this._offset.wrapped=!1;if(e){const e=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx;this._selected.matchIdx=this._offset.matchIdx;t=i?Ag:kg;-1!==e&&e!==this._selected.pageIdx&&pdf_find_controller_assertClassBrand(Kg,this,_updatePage).call(this,e)}pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_updateUIState).call(this,t,pdf_find_controller_classPrivateFieldGet(jg,this).findPrevious);if(-1!==this._selected.pageIdx){this._scrollMatches=!0;pdf_find_controller_assertClassBrand(Kg,this,_updatePage).call(this,this._selected.pageIdx)}}function _onPagesEdited({pagesMapper:e,type:t,pageNumbers:i}){if(0===this._extractTextPromises.length)return;if("copy"===t){const e=new Map,t=new Map,a=new Map,s=new Map;for(const n of i){e.set(n,this._extractTextPromises[n-1]);t.set(n,this._pageContents[n-1]);a.set(n,this._pageDiffs[n-1]);s.set(n,this._hasDiacritics[n-1])}pdf_find_controller_classPrivateFieldSet(Hg,this,{promises:e,contents:t,diffs:a,diacritics:s});return}if("cancelCopy"===t){pdf_find_controller_classPrivateFieldSet(Hg,this,null);return}"delete"===t&&pdf_find_controller_classPrivateFieldSet($g,this,{promises:this._extractTextPromises,contents:this._pageContents,diffs:this._pageDiffs,diacritics:this._hasDiacritics});if("cancelDelete"===t){this._extractTextPromises=pdf_find_controller_classPrivateFieldGet($g,this).promises;this._pageContents=pdf_find_controller_classPrivateFieldGet($g,this).contents;this._pageDiffs=pdf_find_controller_classPrivateFieldGet($g,this).diffs;this._hasDiacritics=pdf_find_controller_classPrivateFieldGet($g,this).diacritics;return}if("cleanSavedData"===t){pdf_find_controller_classPrivateFieldSet($g,this,null);return}if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}this._resumePageIdx=null;this._dirtyMatch=!0;const a=this._extractTextPromises,s=this._pageContents,n=this._pageDiffs,r=this._hasDiacritics,o=this._extractTextPromises=[],l=this._pageContents=[],d=this._pageDiffs=[],c=this._hasDiacritics=[];for(let t=1,i=e.pagesNumber;t<=i;t++){const i=e.getPrevPageNumber(t);if(i<0){const e=-i;o.push(pdf_find_controller_classPrivateFieldGet(Hg,this)?.promises.get(e)||Promise.resolve());l.push(pdf_find_controller_classPrivateFieldGet(Hg,this)?.contents.get(e)??"");d.push(pdf_find_controller_classPrivateFieldGet(Hg,this)?.diffs.get(e)??null);c.push(pdf_find_controller_classPrivateFieldGet(Hg,this)?.diacritics.get(e)??!1);continue}o.push(a[i-1]||Promise.resolve());l.push(s[i-1]??"");d.push(n[i-1]??null);c.push(r[i-1]??!1)}pdf_find_controller_classPrivateFieldGet(jg,this)&&pdf_find_controller_assertClassBrand(Kg,this,_nextMatch).call(this)}function _onFindBarClose(e){const t=this._pdfDocument;this._firstPageCapability.promise.then(()=>{if(this._pdfDocument&&(!t||this._pdfDocument===t)){if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}if(this._resumePageIdx){this._resumePageIdx=null;this._dirtyMatch=!0}pdf_find_controller_assertClassBrand(Kg,this,pdf_find_controller_updateUIState).call(this,kg);this._highlightMatches=!1;pdf_find_controller_assertClassBrand(Kg,this,_updateAllPages).call(this)}})}function _requestMatchesCount(){const{pageIdx:e,matchIdx:t}=this._selected;let i=0,a=this._matchesCountTotal;if(-1!==t){for(let t=0;t<e;t++)i+=this._pageMatches[t]?.length||0;i+=t+1}(i<1||i>a)&&(i=a=0);return{current:i,total:a}}function _updateUIResultsCount(e){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:pdf_find_controller_assertClassBrand(Kg,this,_requestMatchesCount).call(this)});const t=this._pageMatches[e].length;if(this._findResultResolvers&&this._findResultResolvers[e]){this._findResultResolvers[e](t);this._findResultResolvers[e]=null}}function pdf_find_controller_updateUIState(e,t=!1){(pdf_find_controller_classPrivateFieldGet(Vg,this)||pdf_find_controller_classPrivateFieldGet(zg,this)===this._linkService.pagesCount&&e!==Gg)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:e,previous:t,entireWord:pdf_find_controller_classPrivateFieldGet(jg,this)?.entireWord??null,matchesCount:pdf_find_controller_assertClassBrand(Kg,this,_requestMatchesCount).call(this),rawQuery:pdf_find_controller_classPrivateFieldGet(jg,this)?.query??null})}function pdf_find_bar_defineProperty(e,t,i){return(t=function pdf_find_bar_toPropertyKey(e){var t=function pdf_find_bar_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function pdf_find_bar_classPrivateFieldInitSpec(e,t,i){pdf_find_bar_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_find_bar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_find_bar_classPrivateFieldGet(e,t){return e.get(pdf_find_bar_assertClassBrand(e,t))}function pdf_find_bar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Xg=new WeakMap,qg=new WeakMap,Yg=new WeakSet;class PDFFindBar{constructor(e,t,i){!function pdf_find_bar_classPrivateMethodInitSpec(e,t){pdf_find_bar_checkPrivateRedeclaration(e,t),t.add(e)}(this,Yg);pdf_find_bar_classPrivateFieldInitSpec(this,Xg,void 0);pdf_find_bar_classPrivateFieldInitSpec(this,qg,new ResizeObserver(pdf_find_bar_assertClassBrand(Yg,this,_resizeObserverCallback).bind(this)));pdf_find_bar_defineProperty(this,"opened",!1);this.bar=e.bar;this.toggleButton=e.toggleButton;this.findField=e.findField;this.highlightAll=e.highlightAllCheckbox;this.currentPage=e.findCurrentPageCheckbox;this.pageRange=e.findPageRangeField;this.caseSensitive=e.caseSensitiveCheckbox;this.findMultipleCheckbox=e.findMultipleCheckbox;this.matchRegExpCheckbox=e.matchRegExpCheckbox;this.matchDiacritics=e.matchDiacriticsCheckbox;this.entireWord=e.entireWordCheckbox;this.findMsg=e.findMsg;this.findResultsCount=e.findResultsCount;this.findPreviousButton=e.findPreviousButton;this.findNextButton=e.findNextButton;this.eventBus=i;!function pdf_find_bar_classPrivateFieldSet(e,t,i){return e.set(pdf_find_bar_assertClassBrand(e,t),i),i}(Xg,this,t);i._on("closeopenpopovers",({source:e})=>{e!==this&&this.close()});const a=new Map(Array.from([[this.highlightAll,"highlightallchange"],[this.caseSensitive,"casesensitivitychange"],[this.entireWord,"entirewordchange"],[this.matchDiacritics,"diacriticmatchingchange"],[this.findMultipleCheckbox,"findmultiplechange"]]).filter(([e])=>e&&e instanceof Element));this.toggleButton&&(function isInsideNgxExtendedPdfViewer(e){let t=e;for(;t;){if("ngx-extended-pdf-viewer"===t.tagName.toLowerCase())return!0;t=t.parentElement}return!1}(this.toggleButton)||this.toggleButton.addEventListener("click",()=>{this.toggle()}));this.findField.addEventListener("input",()=>{this.dispatchEvent("")});this.findField.parentElement.addEventListener("keydown",e=>{const{keyCode:t}=e;13!==t&&27!==t&&e.stopPropagation();e.metaKey&&"ArrowDown"===e.key&&e.preventDefault();e.metaKey&&"ArrowUp"===e.key&&e.preventDefault()});this.bar.addEventListener("keydown",e=>{const{keyCode:t,shiftKey:i,target:s}=e;switch(t){case 13:if(s===this.findField)this.dispatchEvent("again",i);else if(a.has(s)){s.checked=!s.checked;this.dispatchEvent(a.get(s))}break;case 27:this.close();e.stopPropagation()}});this.findPreviousButton.addEventListener("click",()=>{this.dispatchEvent("again",!0)});this.findNextButton.addEventListener("click",()=>{this.dispatchEvent("again",!1)});for(const[e,t]of a)e.addEventListener("click",()=>{this.dispatchEvent(t)});this.matchRegExpCheckbox?.addEventListener("click",()=>{if(this.matchRegExpCheckbox.checked){this.findMultipleCheckbox.checked=!1;this.findMultipleCheckbox.disabled=!0;this.matchDiacritics.checked=!1;this.matchDiacritics.disabled=!0;this.entireWord.checked=!1;this.entireWord.disabled=!0}else{this.findMultipleCheckbox.disabled=!1;this.matchDiacritics.disabled=!1;this.entireWord.disabled=!1}this.dispatchEvent("findregexpchange")})}reset(){this.updateUIState()}dispatchEvent(e,t=!1){this.eventBus.dispatch("find",{source:this,type:e,query:this.findField.value,caseSensitive:this.caseSensitive.checked,findMultiple:this.findMultipleCheckbox?.checked,matchRegExp:this.matchRegExpCheckbox?.checked,entireWord:this.entireWord.checked,highlightAll:this.highlightAll.checked,findPrevious:t,matchDiacritics:this.matchDiacritics.checked})}updateUIState(e,t,i){const{findField:a,findMsg:s}=this;let n="",r="";switch(e){case kg:break;case Gg:r="pending";break;case Eg:n="pdfjs-find-not-found";r="notFound";break;case Ag:n=t?"pdfjs-find-reached-top":"pdfjs-find-reached-bottom"}a.setAttribute("data-status",r);a.setAttribute("aria-invalid",e===Eg);s.setAttribute("data-status",r);if(n)s.setAttribute("data-l10n-id",n);else{s.removeAttribute("data-l10n-id");s.textContent=""}this.updateResultsCount(i)}updateResultsCount({current:e=0,total:t=0}={}){const{findResultsCount:i}=this;if(t>0){const a=1e3;i.setAttribute("data-l10n-id",t>a?"pdfjs-find-match-count-limit":"pdfjs-find-match-count");i.setAttribute("data-l10n-args",JSON.stringify({limit:a,current:e,total:t}))}else{i.removeAttribute("data-l10n-id");i.textContent=""}}open(){this.eventBus.dispatch("closeopenpopovers",{source:this});if(!this.opened){pdf_find_bar_classPrivateFieldGet(qg,this).observe(pdf_find_bar_classPrivateFieldGet(Xg,this));pdf_find_bar_classPrivateFieldGet(qg,this).observe(this.bar);this.opened=!0;toggleExpandedBtn(this.toggleButton,!0,this.bar)}if(this.findField){"function"==typeof this.findField.select&&this.findField.select();"function"==typeof this.findField.focus&&this.findField.focus()}this.dispatchEvent("");this.eventBus.dispatch("findbaropen",{source:this})}close(){if(this.opened){pdf_find_bar_classPrivateFieldGet(qg,this).disconnect();this.opened=!1;toggleExpandedBtn(this.toggleButton,!1,this.bar);this.eventBus.dispatch("findbarclose",{source:this})}}toggle(){this.opened?this.close():this.open()}}function _resizeObserverCallback(){const{bar:e}=this;e.classList.remove("wrapContainers");e.clientHeight>e.firstElementChild.clientHeight&&e.classList.add("wrapContainers")}function pdf_history_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_history_classPrivateFieldSet(e,t,i){return e.set(pdf_history_assertClassBrand(e,t),i),i}function pdf_history_classPrivateFieldGet(e,t){return e.get(pdf_history_assertClassBrand(e,t))}function pdf_history_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function getCurrentHash(){return document.location.hash}var Zg=new WeakMap,Qg=new WeakSet;class PDFHistory{constructor({linkService:e,eventBus:t}){!function pdf_history_classPrivateMethodInitSpec(e,t){pdf_history_checkPrivateRedeclaration(e,t),t.add(e)}(this,Qg);!function pdf_history_classPrivateFieldInitSpec(e,t,i){pdf_history_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,Zg,null);this.linkService=e;this.eventBus=t;this._initialized=!1;this._fingerprint="";this.reset();this.eventBus.on("pagesinit",()=>{this._isPagesLoaded=!1;this.eventBus.on("pagesloaded",e=>{this._isPagesLoaded=!!e.pagesCount},{once:!0,...Nh})},Nh)}initialize({fingerprint:e,resetHistory:t=!1,updateUrl:i=!1}){if(!e||"string"!=typeof e){ngx_console_NgxConsole.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');return}this._initialized&&this.reset();const a=""!==this._fingerprint&&this._fingerprint!==e;this._fingerprint=e;this._updateUrl=!0===i;this._initialized=!0;pdf_history_assertClassBrand(Qg,this,_bindEvents).call(this);const s=window.history.state;this._popStateInProgress=!1;this._blockHashChange=0;this._currentHash=getCurrentHash();this._numPositionUpdates=0;this._uid=this._maxUid=0;this._destination=null;this._position=null;if(!pdf_history_assertClassBrand(Qg,this,_isValidState).call(this,s,!0)||t){const{hash:e,page:i,rotation:s}=pdf_history_assertClassBrand(Qg,this,_parseCurrentHash).call(this,!0);if(!e||a||t){pdf_history_assertClassBrand(Qg,this,_pushOrReplaceState).call(this,null,!0);return}pdf_history_assertClassBrand(Qg,this,_pushOrReplaceState).call(this,{hash:e,page:i,rotation:s},!0);return}const n=s.destination;pdf_history_assertClassBrand(Qg,this,_updateInternalState).call(this,n,s.uid,!0);void 0!==n.rotation&&(this._initialRotation=n.rotation);if(n.dest){this._initialBookmark=JSON.stringify(n.dest);this._destination.page=null}else n.hash?this._initialBookmark=n.hash:n.page&&(this._initialBookmark=`page=${n.page}`)}reset(){if(this._initialized){pdf_history_assertClassBrand(Qg,this,_pageHide).call(this);this._initialized=!1;pdf_history_assertClassBrand(Qg,this,_unbindEvents).call(this)}if(this._updateViewareaTimeout){clearTimeout(this._updateViewareaTimeout);this._updateViewareaTimeout=null}this._initialBookmark=null;this._initialRotation=null}push({namedDest:e=null,explicitDest:t,pageNumber:i}){if(!this._initialized)return;if(e&&"string"!=typeof e){ngx_console_NgxConsole.error(`PDFHistory.push: "${e}" is not a valid namedDest parameter.`);return}if(!Array.isArray(t)){ngx_console_NgxConsole.error(`PDFHistory.push: "${t}" is not a valid explicitDest parameter.`);return}if(!pdf_history_assertClassBrand(Qg,this,_isValidPage).call(this,i)&&(null!==i||this._destination)){ngx_console_NgxConsole.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);return}const a=e||JSON.stringify(t);if(!a)return;let s=!1;if(this._destination&&(function isDestHashesEqual(e,t){if("string"!=typeof e||"string"!=typeof t)return!1;if(e===t)return!0;if(parseQueryString(e).get("nameddest")===t)return!0;return!1}(this._destination.hash,a)||function isDestArraysEqual(e,t){function isEntryEqual(e,t){if(typeof e!=typeof t)return!1;if(Array.isArray(e)||Array.isArray(t))return!1;if(null!==e&&"object"==typeof e&&null!==t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!isEntryEqual(e[i],t[i]))return!1;return!0}return e===t||Number.isNaN(e)&&Number.isNaN(t)}if(!Array.isArray(e)||!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(let i=0,a=e.length;i<a;i++)if(!isEntryEqual(e[i],t[i]))return!1;return!0}(this._destination.dest,t))){if(this._destination.page)return;s=!0}if(!this._popStateInProgress||s){pdf_history_assertClassBrand(Qg,this,_pushOrReplaceState).call(this,{dest:t,hash:a,page:i,rotation:this.linkService.rotation},s);if(!this._popStateInProgress){this._popStateInProgress=!0;Promise.resolve().then(()=>{this._popStateInProgress=!1})}}}pushPage(e){if(this._initialized)if(pdf_history_assertClassBrand(Qg,this,_isValidPage).call(this,e)){if(this._destination?.page!==e&&!this._popStateInProgress){pdf_history_assertClassBrand(Qg,this,_pushOrReplaceState).call(this,{dest:null,hash:`page=${e}`,page:e,rotation:this.linkService.rotation});if(!this._popStateInProgress){this._popStateInProgress=!0;Promise.resolve().then(()=>{this._popStateInProgress=!1})}}}else ngx_console_NgxConsole.error(`PDFHistory.pushPage: "${e}" is not a valid page number.`)}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&pdf_history_assertClassBrand(Qg,this,_tryPushCurrentPosition).call(this)}back(){if(!this._initialized||this._popStateInProgress)return;const e=window.history.state;pdf_history_assertClassBrand(Qg,this,_isValidState).call(this,e)&&e.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const e=window.history.state;pdf_history_assertClassBrand(Qg,this,_isValidState).call(this,e)&&e.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}}function _pushOrReplaceState(e,t=!1){const i=t||!this._destination,a={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:e};pdf_history_assertClassBrand(Qg,this,_updateInternalState).call(this,e,a.uid);let s;if(this._updateUrl&&e?.hash){const{href:t,protocol:i}=document.location;"file:"!==i&&(s=updateUrlHash(t,e.hash))}i?window.history.replaceState(a,"",s):window.history.pushState(a,"",s)}function _tryPushCurrentPosition(e=!1){if(!this._position)return;let t=this._position;if(e){t=Object.assign(Object.create(null),this._position);t.temporary=!0}if(!this._destination){pdf_history_assertClassBrand(Qg,this,_pushOrReplaceState).call(this,t);return}if(this._destination.temporary){pdf_history_assertClassBrand(Qg,this,_pushOrReplaceState).call(this,t,!0);return}if(this._destination.hash===t.hash)return;if(!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=t.first&&this._destination.page<=t.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}pdf_history_assertClassBrand(Qg,this,_pushOrReplaceState).call(this,t,i)}function _isValidPage(e){return Number.isInteger(e)&&e>0&&e<=this.linkService.pagesCount}function _isValidState(e,t=!1){if(!e)return!1;if(e.fingerprint!==this._fingerprint){if(!t)return!1;{if("string"!=typeof e.fingerprint||e.fingerprint.length!==this._fingerprint.length)return!1;const[t]=performance.getEntriesByType("navigation");if("reload"!==t?.type)return!1}}return!(!Number.isInteger(e.uid)||e.uid<0)&&(null!==e.destination&&"object"==typeof e.destination)}function _updateInternalState(e,t,i=!1){if(this._updateViewareaTimeout){clearTimeout(this._updateViewareaTimeout);this._updateViewareaTimeout=null}i&&e?.temporary&&delete e.temporary;this._destination=e;this._uid=t;this._maxUid=Math.max(this._maxUid,t);this._numPositionUpdates=0}function _parseCurrentHash(e=!1){const t=unescape(getCurrentHash()).substring(1),i=parseQueryString(t),a=i.get("nameddest")||"";let s=0|i.get("page");(!pdf_history_assertClassBrand(Qg,this,_isValidPage).call(this,s)||e&&a.length>0)&&(s=null);return{hash:t,page:s,rotation:this.linkService.rotation}}function _updateViewarea({location:e}){if(this._updateViewareaTimeout){clearTimeout(this._updateViewareaTimeout);this._updateViewareaTimeout=null}this._position={hash:e.pdfOpenParams.substring(1),page:this.linkService.page,first:e.pageNumber,rotation:e.rotation};if(!this._popStateInProgress){this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++;this._updateViewareaTimeout=setTimeout(()=>{this._popStateInProgress||pdf_history_assertClassBrand(Qg,this,_tryPushCurrentPosition).call(this,!0);this._updateViewareaTimeout=null},1e3)}}function _popState({state:e}){const t=getCurrentHash(),i=this._currentHash!==t;this._currentHash=t;if(!e){this._uid++;const{hash:e,page:t,rotation:i}=pdf_history_assertClassBrand(Qg,this,_parseCurrentHash).call(this);pdf_history_assertClassBrand(Qg,this,_pushOrReplaceState).call(this,{hash:e,page:t,rotation:i},!0);return}if(!pdf_history_assertClassBrand(Qg,this,_isValidState).call(this,e))return;this._popStateInProgress=!0;if(i){this._blockHashChange++;waitOnEventOrTimeout({target:window,name:"hashchange",delay:1e3}).then(()=>{this._blockHashChange--})}const a=e.destination;pdf_history_assertClassBrand(Qg,this,_updateInternalState).call(this,a,e.uid,!0);isValidRotation(a.rotation)&&(this.linkService.rotation=a.rotation);a.dest?this.linkService.goToDestination(a.dest):a.hash?this.linkService.setHash&&this.linkService.setHash(a.hash):a.page&&(this.linkService.page=a.page);Promise.resolve().then(()=>{this._popStateInProgress=!1})}function _pageHide(){this._destination&&!this._destination.temporary||pdf_history_assertClassBrand(Qg,this,_tryPushCurrentPosition).call(this)}function _bindEvents(){if(pdf_history_classPrivateFieldGet(Zg,this))return;pdf_history_classPrivateFieldSet(Zg,this,new AbortController);const{signal:e}=pdf_history_classPrivateFieldGet(Zg,this);this.eventBus.on("updateviewarea",pdf_history_assertClassBrand(Qg,this,_updateViewarea).bind(this),{signal:e,...Nh});window.addEventListener("popstate",pdf_history_assertClassBrand(Qg,this,_popState).bind(this),{signal:e});window.addEventListener("pagehide",pdf_history_assertClassBrand(Qg,this,_pageHide).bind(this),{signal:e})}function _unbindEvents(){pdf_history_classPrivateFieldGet(Zg,this)?.abort();pdf_history_classPrivateFieldSet(Zg,this,null)}function pdf_layer_viewer_classPrivateMethodInitSpec(e,t){(function pdf_layer_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function pdf_layer_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Jg=new WeakSet;class PDFLayerViewer extends BaseTreeViewer{constructor(e){super(e);pdf_layer_viewer_classPrivateMethodInitSpec(this,Jg);const{eventBus:t}=this;t.on("optionalcontentconfigchanged",e=>{pdf_layer_viewer_assertClassBrand(Jg,this,_updateLayers).call(this,e.promise)},Nh);t.on("resetlayers",()=>{pdf_layer_viewer_assertClassBrand(Jg,this,_updateLayers).call(this)},Nh);t.on("togglelayerstree",this._toggleAllTreeItems.bind(this),Nh)}reset(){super.reset();this._optionalContentConfig=null;this._optionalContentVisibility?.clear();this._optionalContentVisibility=null}_dispatchEvent(e){this.eventBus.dispatch("layersloaded",{source:this,layersCount:e})}_bindLink(e,{groupId:t,input:i}){const setVisibility=()=>{const e=i.checked;this._optionalContentConfig.setVisibility(t,e);const a=this._optionalContentVisibility.get(t);a&&(a.visible=e);this.eventBus.dispatch("optionalcontentconfig",{source:this,promise:Promise.resolve(this._optionalContentConfig)})};e.onclick=t=>{if(t.target===i){setVisibility();return!0}if(t.target!==e)return!0;i.checked=!i.checked;setVisibility();return!1}}_setNestedName(e,{name:t=null}){if("string"!=typeof t){e.setAttribute("data-l10n-id","pdfjs-additional-layers");e.style.fontStyle="italic";this._l10n.translateOnce(e)}else e.textContent=this._normalizeTextContent(t)}_addToggleButton(e,{name:t=null}){super._addToggleButton(e,null===t)}_toggleAllTreeItems(){this._optionalContentConfig&&super._toggleAllTreeItems()}render({optionalContentConfig:e,pdfDocument:t}){this._optionalContentConfig&&this.reset();this._optionalContentConfig=e||null;this._pdfDocument=t||null;const i=e?.getOrder();if(!i){this._dispatchEvent(0);return}this._optionalContentVisibility=new Map;const a=document.createDocumentFragment(),s=[{parent:a,groups:i}];let n=0,r=!1;for(;s.length>0;){const t=s.shift();for(const i of t.groups){const a=document.createElement("div");a.className="treeItem";const o=document.createElement("a");a.append(o);if("object"==typeof i){r=!0;this._addToggleButton(a,i);this._setNestedName(o,i);const e=document.createElement("div");e.className="treeItems";a.append(e);s.push({parent:e,groups:i.order})}else{const t=e.getGroup(i),a=document.createElement("label"),s=document.createElement("input");a.append(s,document.createTextNode(this._normalizeTextContent(t.name)));this._bindLink(o,{groupId:i,input:s});s.type="checkbox";s.checked=t.visible;this._optionalContentVisibility.set(i,{input:s,visible:s.checked});o.append(a);n++}t.parent.append(a)}}this._finishRendering(a,n,r)}}async function _updateLayers(e=null){if(!this._optionalContentConfig)return;const t=this._pdfDocument,i=await(e||t.getOptionalContentConfig({intent:"display"}));if(t===this._pdfDocument)if(e)for(const[e,t]of this._optionalContentVisibility){const a=i.getGroup(e);a&&t.visible!==a.visible&&(t.input.checked=t.visible=!t.visible)}else{this.eventBus.dispatch("optionalcontentconfig",{source:this,promise:Promise.resolve(i)});this.render({optionalContentConfig:i,pdfDocument:this._pdfDocument})}}class PDFOutlineViewer extends BaseTreeViewer{constructor(e){super(e);this.linkService=e.linkService;this.downloadManager=e.downloadManager;const{eventBus:t}=this;t.on("toggleoutlinetree",this._toggleAllTreeItems.bind(this),Nh);t.on("currentoutlineitem",this._currentOutlineItem.bind(this),Nh);t.on("pagechanging",e=>{this._currentPageNumber=e.pageNumber},Nh);t.on("pagesloaded",e=>{this._isPagesLoaded=!!e.pagesCount;this._currentOutlineItemCapability?.resolve(this._isPagesLoaded)},Nh);t.on("sidebarviewchanged",e=>{this._sidebarView=e.view},Nh)}reset(){super.reset();this._outline=null;this._pageNumberToDestHashCapability=null;this._currentPageNumber=1;this._isPagesLoaded=null;this._currentOutlineItemCapability?.resolve(!1);this._currentOutlineItemCapability=null}_dispatchEvent(e){this._currentOutlineItemCapability=Promise.withResolvers();0===e||this._pdfDocument?.loadingParams.disableAutoFetch?this._currentOutlineItemCapability.resolve(!1):null!==this._isPagesLoaded&&this._currentOutlineItemCapability.resolve(this._isPagesLoaded);this.eventBus.dispatch("outlineloaded",{source:this,outlineCount:e,currentOutlineItemPromise:this._currentOutlineItemCapability.promise})}_bindLink(e,{url:t,newWindow:i,action:a,attachmentId:s,attachment:n,dest:r,setOCGState:o}){const{linkService:l}=this;if(t)l.addLinkAttributes(e,t,i);else if(a){e.href=l.getAnchorUrl("");e.onclick=()=>{l.executeNamedAction(a);return!1}}else{if(s&&n){e.href=l.getAnchorUrl("");const openAttachment=async()=>{const e=await l.getAttachmentContent(s);e&&this.downloadManager?.openOrDownloadData(e,n.filename)};e.onclick=()=>{openAttachment();return!1};return}if(o){e.href=l.getAnchorUrl("");e.onclick=()=>{l.executeSetOCGState(o);return!1}}else{e.href=l.getDestinationHash(r);e.onclick=e=>{this._updateCurrentTreeItem(e.target.parentNode);r&&l.goToDestination(r);return!1}}}}_setStyles(e,{bold:t,italic:i}){t&&(e.style.fontWeight="bold");i&&(e.style.fontStyle="italic")}_addToggleButton(e,{count:t,items:i}){let a=!1;if(t<0){let e=i.length;if(e>0){const t=[...i];for(;t.length>0;){const{count:i,items:a}=t.shift();if(i>0&&a.length>0){e+=a.length;t.push(...a)}}}Math.abs(t)===e&&(a=!0)}super._addToggleButton(e,a)}_toggleAllTreeItems(){this._outline&&super._toggleAllTreeItems()}render({outline:e,pdfDocument:t}){this._outline&&this.reset();this._outline=e||null;this._pdfDocument=t||null;if(!e){this._dispatchEvent(0);return}const i=document.createDocumentFragment(),a=[{parent:i,items:e}];let s=0,n=!1;for(;a.length>0;){const e=a.shift();for(const t of e.items){const i=document.createElement("div");i.className="treeItem";const r=document.createElement("a");this._bindLink(r,t);this._setStyles(r,t);r.textContent=this._normalizeTextContent(t.title);i.append(r);if(t.items.length>0){n=!0;this._addToggleButton(i,t);const e=document.createElement("div");e.className="treeItems";i.append(e);a.push({parent:e,items:t.items})}e.parent.append(i);s++}}this._finishRendering(i,s,n)}async _currentOutlineItem(){if(!this._isPagesLoaded)throw new Error("_currentOutlineItem: All pages have not been loaded.");if(!this._outline||!this._pdfDocument)return;const e=await this._getPageNumberToDestHash(this._pdfDocument);if(e){this._updateCurrentTreeItem(null);if(this._sidebarView===gh)for(let t=this._currentPageNumber;t>0;t--){const i=e.get(t);if(!i)continue;const a=this.container.querySelector(`a[href="${i}"]`);if(a){this._scrollToCurrentTreeItem(a.parentNode);break}}}}async _getPageNumberToDestHash(e){if(this._pageNumberToDestHashCapability)return this._pageNumberToDestHashCapability.promise;this._pageNumberToDestHashCapability=Promise.withResolvers();const t=new Map,i=new Map,a=[{nesting:0,items:this._outline}];for(;a.length>0;){const s=a.shift(),n=s.nesting;for(const{dest:r,items:o}of s.items){let s,l;if("string"==typeof r){s=await e.getDestination(r);if(e!==this._pdfDocument)return null}else s=r;if(Array.isArray(s)){const[a]=s;a&&"object"==typeof a?l=e.cachedPageNumber(a):Number.isInteger(a)&&(l=a+1);if(Number.isInteger(l)&&(!t.has(l)||n>i.get(l))){const e=this.linkService.getDestinationHash(r);t.set(l,e);i.set(l,n)}}o.length>0&&a.push({nesting:n+1,items:o})}}this._pageNumberToDestHashCapability.resolve(t.size>0?t:null);return this._pageNumberToDestHashCapability.promise}}function pdf_presentation_mode_classPrivateFieldInitSpec(e,t,i){pdf_presentation_mode_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_presentation_mode_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_presentation_mode_classPrivateFieldGet(e,t){return e.get(pdf_presentation_mode_assertClassBrand(e,t))}function pdf_presentation_mode_classPrivateFieldSet(e,t,i){return e.set(pdf_presentation_mode_assertClassBrand(e,t),i),i}function pdf_presentation_mode_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const em="pdfPresentationMode",tm="pdfPresentationModeControls",im=Math.PI/6;var am=new WeakMap,sm=new WeakMap,nm=new WeakMap,rm=new WeakMap,om=new WeakSet;class PDFPresentationMode{constructor({container:e,pdfViewer:t,eventBus:i}){!function pdf_presentation_mode_classPrivateMethodInitSpec(e,t){pdf_presentation_mode_checkPrivateRedeclaration(e,t),t.add(e)}(this,om);pdf_presentation_mode_classPrivateFieldInitSpec(this,am,lh);pdf_presentation_mode_classPrivateFieldInitSpec(this,sm,null);pdf_presentation_mode_classPrivateFieldInitSpec(this,nm,null);pdf_presentation_mode_classPrivateFieldInitSpec(this,rm,null);this.container=e;this.pdfViewer=t;this.eventBus=i;this.contextMenuOpen=!1;this.mouseScrollTimeStamp=0;this.mouseScrollDelta=0;this.touchSwipeState=null}async request(){const{container:e,pdfViewer:t}=this;if(this.active||!t.pagesCount||!e.requestFullscreen)return!1;pdf_presentation_mode_assertClassBrand(om,this,_addFullscreenChangeListeners).call(this);pdf_presentation_mode_assertClassBrand(om,this,_notifyStateChange).call(this,ch);const i=e.requestFullscreen();pdf_presentation_mode_classPrivateFieldSet(sm,this,{pageNumber:t.currentPageNumber,scaleValue:t.currentScaleValue,scrollMode:t.scrollMode,spreadMode:null,annotationEditorMode:null});if(!(t.spreadMode===bh.NONE||t.pageViewsReady&&t.hasEqualPageSizes)){ngx_console_NgxConsole.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes.");pdf_presentation_mode_classPrivateFieldGet(sm,this).spreadMode=t.spreadMode}t.annotationEditorMode!==f.DISABLE&&(pdf_presentation_mode_classPrivateFieldGet(sm,this).annotationEditorMode=t.annotationEditorMode);try{await i;t.focus();return!0}catch{pdf_presentation_mode_assertClassBrand(om,this,_removeFullscreenChangeListeners).call(this);pdf_presentation_mode_assertClassBrand(om,this,_notifyStateChange).call(this,dh)}return!1}get active(){return pdf_presentation_mode_classPrivateFieldGet(am,this)===ch||pdf_presentation_mode_classPrivateFieldGet(am,this)===hh}_prepareFullscreenMode(){const e=document.getElementsByClassName("zoom")[0].parentElement,t=e.parentElement;this.ngxContainer=t;for(let i=0;i<t.childElementCount;i++)t.children.item(i)===e&&(this.ngxContainerIndex=i);t.removeChild(e);document.body.append(e);const i=document.body.children;for(let t=0;t<i.length;t++){const a=i.item(t);a!==e&&a instanceof HTMLElement&&a.classList.add("hidden-by-fullscreen")}document.getElementById("sidebarContainer").classList.add("hidden-by-fullscreen");document.getElementsByClassName("toolbar")[0].classList.add("hidden-by-fullscreen")}_tidyUpFullscreenMode(){if(this.ngxContainer){const e=document.getElementsByClassName("zoom")[0].parentElement;document.body.removeChild(e);this.ngxContainerIndex>=this.ngxContainer.childElementCount?this.ngxContainer.append(e):this.ngxContainer.insertBefore(e,this.ngxContainer.children.item(this.ngxContainerIndex));this.ngxContainer=void 0;const t=document.body.children;for(let i=0;i<t.length;i++){const a=t.item(i);a!==e&&a instanceof HTMLElement&&a.classList.contains("hidden-by-fullscreen")&&a.classList.remove("hidden-by-fullscreen")}document.getElementById("sidebarContainer").classList.remove("hidden-by-fullscreen");document.getElementsByClassName("toolbar")[0].classList.remove("hidden-by-fullscreen")}}}function _mouseWheel(e){if(!this.active)return;if(e.target.closest?.(".mediaAnnotation"))return;e.preventDefault();const t=function normalizeWheelEventDelta(e){const t=e.deltaMode;let i=normalizeWheelEventDirection(e);t===WheelEvent.DOM_DELTA_PIXEL?i/=900:t===WheelEvent.DOM_DELTA_LINE&&(i/=30);return i}(e),i=Date.now(),a=this.mouseScrollTimeStamp;if(!(i>a&&i-a<50)){(this.mouseScrollDelta>0&&t<0||this.mouseScrollDelta<0&&t>0)&&pdf_presentation_mode_assertClassBrand(om,this,_resetMouseScrollState).call(this);this.mouseScrollDelta+=t;if(Math.abs(this.mouseScrollDelta)>=.1){const e=this.mouseScrollDelta;pdf_presentation_mode_assertClassBrand(om,this,_resetMouseScrollState).call(this);(e>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}}}function _notifyStateChange(e){pdf_presentation_mode_classPrivateFieldSet(am,this,e);this.eventBus.dispatch("presentationmodechanged",{source:this,state:e})}function _enter(){pdf_presentation_mode_assertClassBrand(om,this,_notifyStateChange).call(this,hh);this.container.classList.add(em);setTimeout(()=>{this.pdfViewer.scrollMode=Fh.PAGE;null!==pdf_presentation_mode_classPrivateFieldGet(sm,this).spreadMode&&(this.pdfViewer.spreadMode=bh.NONE);this.pdfViewer.currentPageNumber=pdf_presentation_mode_classPrivateFieldGet(sm,this).pageNumber;this.pdfViewer.currentScaleValue="page-fit";null!==pdf_presentation_mode_classPrivateFieldGet(sm,this).annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:f.NONE})},0);pdf_presentation_mode_assertClassBrand(om,this,_addWindowListeners).call(this);pdf_presentation_mode_assertClassBrand(om,this,_showControls).call(this);this.contextMenuOpen=!1;document.getSelection().empty()}function _exit(){const e=this.pdfViewer.currentPageNumber;this.container.classList.remove(em);setTimeout(()=>{pdf_presentation_mode_assertClassBrand(om,this,_removeFullscreenChangeListeners).call(this);pdf_presentation_mode_assertClassBrand(om,this,_notifyStateChange).call(this,dh);this.pdfViewer.scrollMode=pdf_presentation_mode_classPrivateFieldGet(sm,this).scrollMode;null!==pdf_presentation_mode_classPrivateFieldGet(sm,this).spreadMode&&(this.pdfViewer.spreadMode=pdf_presentation_mode_classPrivateFieldGet(sm,this).spreadMode);this.pdfViewer.currentScaleValue=pdf_presentation_mode_classPrivateFieldGet(sm,this).scaleValue;this.pdfViewer.currentPageNumber=e;null!==pdf_presentation_mode_classPrivateFieldGet(sm,this).annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:pdf_presentation_mode_classPrivateFieldGet(sm,this).annotationEditorMode});pdf_presentation_mode_classPrivateFieldSet(sm,this,null)},0);pdf_presentation_mode_assertClassBrand(om,this,_removeWindowListeners).call(this);pdf_presentation_mode_assertClassBrand(om,this,_hideControls).call(this);pdf_presentation_mode_assertClassBrand(om,this,_resetMouseScrollState).call(this);this.contextMenuOpen=!1}function _mouseDown(e){if(this.contextMenuOpen){this.contextMenuOpen=!1;e.preventDefault()}else if(0===e.button&&!(e.target.href&&e.target.parentNode?.hasAttribute("data-internal-link")||e.target.closest?.(".mediaAnnotation"))){e.preventDefault();e.shiftKey?this.pdfViewer.previousPage():this.pdfViewer.nextPage()}}function _contextMenu(){this.contextMenuOpen=!0}function _showControls(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(tm);this.controlsTimeout=setTimeout(()=>{this.container.classList.remove(tm);delete this.controlsTimeout},3e3)}function _hideControls(){if(this.controlsTimeout){clearTimeout(this.controlsTimeout);this.container.classList.remove(tm);delete this.controlsTimeout}}function _resetMouseScrollState(){this.mouseScrollTimeStamp=0;this.mouseScrollDelta=0}function _touchSwipe(e){if(this.active)if(e.target.closest?.(".mediaAnnotation"))this.touchSwipeState=null;else if(e.touches.length>1)this.touchSwipeState=null;else switch(e.type){case"touchstart":this.touchSwipeState={startX:e.touches[0].pageX,startY:e.touches[0].pageY,endX:e.touches[0].pageX,endY:e.touches[0].pageY};break;case"touchmove":if(null===this.touchSwipeState)return;this.touchSwipeState.endX=e.touches[0].pageX;this.touchSwipeState.endY=e.touches[0].pageY;e.preventDefault();break;case"touchend":if(null===this.touchSwipeState)return;let t=0;const i=this.touchSwipeState.endX-this.touchSwipeState.startX,a=this.touchSwipeState.endY-this.touchSwipeState.startY,s=Math.abs(Math.atan2(a,i));Math.abs(i)>50&&(s<=im||s>=Math.PI-im)?t=i:Math.abs(a)>50&&Math.abs(s-Math.PI/2)<=im&&(t=a);t>0?this.pdfViewer.previousPage():t<0&&this.pdfViewer.nextPage()}}function _addWindowListeners(){if(pdf_presentation_mode_classPrivateFieldGet(rm,this))return;pdf_presentation_mode_classPrivateFieldSet(rm,this,new AbortController);const{signal:e}=pdf_presentation_mode_classPrivateFieldGet(rm,this),t=pdf_presentation_mode_assertClassBrand(om,this,_touchSwipe).bind(this);window.addEventListener("mousemove",pdf_presentation_mode_assertClassBrand(om,this,_showControls).bind(this),{signal:e});window.addEventListener("mousedown",pdf_presentation_mode_assertClassBrand(om,this,_mouseDown).bind(this),{signal:e});window.addEventListener("wheel",pdf_presentation_mode_assertClassBrand(om,this,_mouseWheel).bind(this),{passive:!1,signal:e});window.addEventListener("keydown",pdf_presentation_mode_assertClassBrand(om,this,_resetMouseScrollState).bind(this),{signal:e});window.addEventListener("contextmenu",pdf_presentation_mode_assertClassBrand(om,this,_contextMenu).bind(this),{signal:e});window.addEventListener("touchstart",t,{signal:e});window.addEventListener("touchmove",t,{signal:e});window.addEventListener("touchend",t,{signal:e})}function _removeWindowListeners(){pdf_presentation_mode_classPrivateFieldGet(rm,this)?.abort();pdf_presentation_mode_classPrivateFieldSet(rm,this,null)}function _addFullscreenChangeListeners(){if(!pdf_presentation_mode_classPrivateFieldGet(nm,this)){pdf_presentation_mode_classPrivateFieldSet(nm,this,new AbortController);window.addEventListener("fullscreenchange",()=>{document.fullscreenElement?pdf_presentation_mode_assertClassBrand(om,this,_enter).call(this):pdf_presentation_mode_assertClassBrand(om,this,_exit).call(this)},{signal:pdf_presentation_mode_classPrivateFieldGet(nm,this).signal})}}function _removeFullscreenChangeListeners(){pdf_presentation_mode_classPrivateFieldGet(nm,this)?.abort();pdf_presentation_mode_classPrivateFieldSet(nm,this,null)}function xfa_layer_builder_defineProperty(e,t,i){return(t=function xfa_layer_builder_toPropertyKey(e){var t=function xfa_layer_builder_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function xfa_layer_builder_classPrivateFieldInitSpec(e,t,i){(function xfa_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function xfa_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var lm=new WeakMap;class XfaLayerBuilder{constructor({pdfPage:e,annotationStorage:t=null,linkService:i,xfaHtml:a=null}){xfa_layer_builder_classPrivateFieldInitSpec(this,lm,!1);xfa_layer_builder_defineProperty(this,"div",null);this.pdfPage=e;this.annotationStorage=t;this.linkService=i;this.xfaHtml=a}async render({viewport:e,intent:t="display"}){let i;if("print"===t)i=this.xfaHtml;else{i=await this.pdfPage.getXfa();if(function xfa_layer_builder_classPrivateFieldGet(e,t){return e.get(xfa_layer_builder_assertClassBrand(e,t))}(lm,this)||!i)return{textDivs:[]}}const a=!!this.div,s={viewport:e.clone({dontFlip:!0}),div:this.div??=document.createElement("div"),xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:t};return a?XfaLayer.update(s):XfaLayer.render(s)}cancel(){!function xfa_layer_builder_classPrivateFieldSet(e,t,i){return e.set(xfa_layer_builder_assertClassBrand(e,t),i),i}(lm,this,!0)}hide(){this.div&&(this.div.hidden=!0)}}class BasePrintServiceFactory{static initGlobals(e){}static get supportsPrinting(){throw new Error("Not implemented: supportsPrinting")}static createPrintService(e){throw new Error("Not implemented: createPrintService")}}function canvasTest(e){const t=e.sizes.shift(),i=Math.max(Math.ceil(t[0]),1),a=Math.max(Math.ceil(t[1]),1),s=[i-1,a-1,1,1],n=performance.now(),r="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;let o,l;if(r){o=new OffscreenCanvas(1,1);l=new OffscreenCanvas(i,a)}else{o=document.createElement("canvas");o.width=1;o.height=1;l=document.createElement("canvas");l.width=i;l.height=a}const d=o.getContext("2d"),c=l.getContext("2d");if(c){c.fillRect.apply(c,s);d.drawImage(l,i-1,a-1,1,1,0,0,1,1)}const h=d&&0!==d.getImageData(0,0,1,1).data[3],u=parseInt(performance.now()-n);[o,l].forEach(e=>{e.height=0;e.width=0});if(r){postMessage({width:i,height:a,testTime:u,isTestPass:h});!h&&e.sizes.length&&setTimeout(()=>{canvasTest(e)},0)}else if(h)e.onSuccess({width:i,height:a,testTime:u});else{e.onError({width:i,height:a,testTime:u});e.sizes.length&&setTimeout(()=>{canvasTest(e)},0)}return h}const dm={area:[16384,14188,11402,11180,10836,8192,4096,1],height:[8388607,65535,32767,16384,8192,4096,1],width:[4194303,65535,32767,16384,8192,4096,1]},cm={max:null,min:1,sizes:[],step:1024,useWorker:!1,onError:Function.prototype,onSuccess:Function.prototype},hm={};function createSizesArray(e){const t=e.width===e.height,i=1===e.height,a=1===e.width,s=[];if(e.width&&e.height){const n=e.min||cm.min,r=e.step||cm.step;let o=Math.max(e.width,e.height);for(;o>=n;){const e=t||i?o:1,n=t||a?o:1;s.push([e,n]);o-=r}}else e.sizes.forEach(e=>{const n=t||i?e:1,r=t||a?e:1;s.push([n,r])});return s}function handleMethod(e){const t="undefined"!=typeof window,i=t&&"Promise"in window,a=t&&"HTMLCanvasElement"in window,s=t&&"OffscreenCanvas"in window,n=URL.createObjectURL(new Blob([])).slice(-36),r=performance.now(),{onError:o,onSuccess:l,...d}=e,getTotalTime=()=>parseInt(performance.now()-r);let c=null;if(!a)return!1;if(e.useWorker&&s){const e=`\n var canvasTest = ${canvasTest.toString()};\n onmessage = function(e) {\n canvasTest(e.data);\n };\n `,t=new Blob([e],{type:"application/javascript"}),i=URL.createObjectURL(t);c=new Worker(i);URL.revokeObjectURL(i);c.onmessage=function(e){const{width:t,height:i,testTime:a,isTestPass:s}=e.data,r={width:t,height:i,testTime:a,totalTime:getTotalTime()};if(s){hm[n].onSuccess(r);delete hm[n]}else hm[n].onError(r)}}if(i)return new Promise(t=>{const i={...e,onError(i){let{width:a,height:s,testTime:n}=i;const r={width:a,height:s,testTime:n,totalTime:getTotalTime()};let l;if(0===e.sizes.length)l=!0;else{const[[t,i]]=e.sizes.slice(-1);l=a===t&&s===i}o(r);l&&t({...r,success:!1})},onSuccess(e){let{width:i,height:a,testTime:s}=e;const n={width:i,height:a,testTime:s,totalTime:getTotalTime()};l(n);t({...n,success:!0})}};if(c){const{onError:e,onSuccess:t}=i;hm[n]={onError:e,onSuccess:t};c.postMessage(d)}else canvasTest(i)});if(!c)return canvasTest(e);hm[n]={onError:o,onSuccess:l};c.postMessage(d)}const um={maxArea(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=createSizesArray({width:e.max,height:e.max,min:e.min,step:e.step,sizes:[...dm.area]});return handleMethod({...cm,...e,sizes:t})},maxHeight(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=createSizesArray({width:1,height:e.max,min:e.min,step:e.step,sizes:[...dm.height]});return handleMethod({...cm,...e,sizes:t})},maxWidth(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=createSizesArray({width:e.max,height:1,min:e.min,step:e.step,sizes:[...dm.width]});return handleMethod({...cm,...e,sizes:t})},test(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={...cm,...e};t.sizes=[...t.sizes];t.width&&t.height&&(t.sizes=[[t.width,t.height]]);return handleMethod(t)}};function max_canvas_size_defineProperty(e,t,i){return(t=function max_canvas_size_toPropertyKey(e){var t=function max_canvas_size_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}class MaxCanvasSize{static async determineMaxArea(){const{success:e,width:t,height:i}=await um.maxArea({useWorker:!0});if(!e){MaxCanvasSize.maxWidth=4096;MaxCanvasSize.maxArea=16777216;return 4096}MaxCanvasSize.maxArea=t*i;return MaxCanvasSize.maxArea}static async determineMaxWidth(){const{width:e}=await um.maxWidth({useWorker:!0});MaxCanvasSize.maxWidth=e;return MaxCanvasSize.maxWidth}static async determineMaxHeight(){const{height:e}=await um.maxHeight({useWorker:!0});MaxCanvasSize.maxHeight=e;return MaxCanvasSize.maxHeight}static async determineMaxDimensions(){if(MaxCanvasSize.maxWidth)return MaxCanvasSize.maxWidth;await this.determineMaxArea();await this.determineMaxHeight();await this.determineMaxWidth();return MaxCanvasSize.maxWidth}static async reduceToMaxCanvasSize(e,t){let i=1;if(e>=4096||t>=4096){await this.determineMaxDimensions();i=Math.max(e/MaxCanvasSize.maxWidth,t/MaxCanvasSize.maxHeight,Math.sqrt(e*t/MaxCanvasSize.maxArea));i>1&&(i=Math.ceil(1+100*i)/100)}return i}}max_canvas_size_defineProperty(MaxCanvasSize,"maxWidth",null);max_canvas_size_defineProperty(MaxCanvasSize,"maxHeight",null);max_canvas_size_defineProperty(MaxCanvasSize,"maxArea",null);let _m=null,pm=null,gm=null,mm={initialized:!1};class PDFPrintService{constructor({pdfDocument:e,pagesOverview:t,printResolution:i,printAnnotationStoragePromise:a=null,eventBus:s,cspPolicyService:n,pageOrder:r=null},o,l){this.pdfDocument=e;this.pagesOverview=t;this._printResolution=i||150;this.pageOrder=r||Array.from({length:e.numPages},(e,t)=>t+1);this._optionalContentConfigPromise=e.getOptionalContentConfig({intent:"print"});this._printAnnotationStoragePromise=a||Promise.resolve();this.currentPage=-1;this.scratchCanvas=document.createElement("canvas");this.eventBus=s;this.filteredPageCount=l;this.isInPDFPrintRange=o;this.cspPolicyService=n;this._blobUrls=[]}layout(){this.throwIfInactive();const e=document.querySelector("body");e.setAttribute("data-pdfjsprinting",!0);document.querySelector("html").setAttribute("data-pdfjsprinting",!0);const{width:t,height:i}=this.pagesOverview[0];this.pagesOverview.every(e=>e.width===t&&e.height===i)||ngx_console_NgxConsole.warn("Not all pages have the same size. The printed result may be incorrect!");this.pageStyleSheet=document.createElement("style");const a=`@page { size: ${t}pt ${i}pt;}`;this.cspPolicyService?this.cspPolicyService.addTrustedCSS(this.pageStyleSheet,a):this.pageStyleSheet.textContent=a;e.append(this.pageStyleSheet)}destroy(){if(_m!==this)return;this.printContainer.remove();this.printContainer=null;document.querySelector("body").removeAttribute("data-pdfjsprinting");document.querySelector("html").removeAttribute("data-pdfjsprinting");if(this.pageStyleSheet){this.pageStyleSheet.remove();this.pageStyleSheet=null}if(this._blobURLs){for(const e of this._blobURLs)URL.revokeObjectURL(e);this._blobURLs=null}this.scratchCanvas.width=this.scratchCanvas.height=0;this.scratchCanvas=null;for(const e of this._blobUrls)URL.revokeObjectURL(e);this._blobUrls=[];_m=null;ensureOverlay().then(function(){gm.closeIfActive(pm);gm.unregister(pm);vm=void 0})}renderPages(){if(this.pdfDocument.isPureXfa){!function getXfaHtmlForPrinting(e,t){const i=t.allXfaHtml,a=new SimpleLinkService,s=Math.round(100*PixelsPerInch.PDF_TO_CSS_UNITS)/100;for(const n of i.children){const i=document.createElement("div");i.className="xfaPrintedPage";e.append(i);const r=new XfaLayerBuilder({pdfPage:null,annotationStorage:t.annotationStorage,linkService:a,xfaHtml:n}),o=XfaLayer.getPageViewport(n,{scale:s});r.render({viewport:o,intent:"print"});i.append(r.div)}}(this.printContainer,this.pdfDocument);return Promise.resolve()}const e=this.pagesOverview.length,renderNextPage=(t,i)=>{this.throwIfInactive();for(;;){++this.currentPage;if(this.currentPage>=e)break;if(!this.isInPDFPrintRange||this.isInPDFPrintRange(this.currentPage))break}if(this.currentPage>=e){renderProgress(this.filteredPageCount??e,this.filteredPageCount??e,this.eventBus);t();return}const a=this.currentPage;renderProgress(a,this.filteredPageCount??e,this.eventBus);(async function renderPage(e,t,i,a,s,n,r){const o=_m.scratchCanvas;let l=s/PixelsPerInch.PDF;const d=Math.floor(a.width*l),c=Math.floor(a.height*l),h=await MaxCanvasSize.reduceToMaxCanvasSize(d,c);if(h>1){const e=Math.round(100*(h-1));l=Math.ceil(.95*l/h);warn(`Page ${i}: Reduced the maximum resolution by ${e}% because the browser can't render larger canvases. The resolution is now ${l*PixelsPerInch.PDF} DPI.`)}o.width=Math.floor(a.width*l);o.height=Math.floor(a.height*l);const u=o.getContext("2d");u.save();u.fillStyle="rgb(255, 255, 255)";u.fillRect(0,0,o.width,o.height);u.restore();return Promise.all([t.getPage(i),r]).then(function([e,t]){const i={canvas:o,transform:[l,0,0,l,0,0],viewport:e.getViewport({scale:1,rotation:a.rotation}),intent:"print",annotationMode:p.ENABLE_STORAGE,optionalContentConfigPromise:n,printAnnotationStorage:t};return e.render(i).promise.catch(e=>{e instanceof RenderingCancelledException||ngx_console_NgxConsole.error(e);throw e})})})(0,this.pdfDocument,this.pageOrder[a],this.pagesOverview[a],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function(){renderNextPage(t,i)},i)};return new Promise(renderNextPage)}useRenderedPage(){this.throwIfInactive();const e=document.createElement("img"),{promise:t,resolve:i,reject:a}=Promise.withResolvers();e.onload=i;e.onerror=()=>{ngx_console_NgxConsole.error("Failed to load printed page image via blob URL, falling back to data URL.");try{e.onerror=()=>{ngx_console_NgxConsole.error("Print failed: could not load page image even with data URL fallback.");a(new Error("Failed to load printed page image."))};e.src=this.scratchCanvas.toDataURL()}catch(e){ngx_console_NgxConsole.error("Print failed: toDataURL fallback also failed.",e);a(e)}};try{this.scratchCanvas.toBlob(t=>{if(!t){ngx_console_NgxConsole.warn("Print: toBlob returned null, falling back to data URL.");try{e.src=this.scratchCanvas.toDataURL()}catch(e){ngx_console_NgxConsole.error("Print failed: both toBlob and toDataURL failed.",e);a(e)}return}const i=URL.createObjectURL(t);this._blobUrls.push(i);e.src=i})}catch(t){ngx_console_NgxConsole.warn("Print: toBlob threw, falling back to data URL.",t);try{e.src=this.scratchCanvas.toDataURL()}catch(e){ngx_console_NgxConsole.error("Print failed: both toBlob and toDataURL failed.",e);a(e)}}const s=document.createElement("div");s.className="printedPage";s.append(e);this.printContainer.append(s);t.catch(()=>{});return t}performPrint(){this.throwIfInactive();return new Promise(e=>{setTimeout(()=>{if(!this.active){e();return}fm.call(window);const t=navigator.platform&&["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document,i=/Android/i.test(navigator.userAgent);setTimeout(e,t||i?1500:100)},0)})}get active(){return this===_m}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const fm=window.print;function dispatchEvent(e){const t=new CustomEvent(e,{bubbles:!1,cancelable:!1,detail:"custom"});window.dispatchEvent(t)}function abort(){if(_m){_m.destroy();dispatchEvent("afterprint")}}function renderProgress(e,t,i){pm=document.getElementById("printServiceDialog");const a=Math.round(100*e/t),s=pm.querySelector("progress"),n=pm.querySelector(".relative-progress");s.value=a;n.setAttribute("data-l10n-args",JSON.stringify({progress:a}));i.dispatch("progress",{source:this,type:"print",total:t,page:e,percent:100*e/t})}window.addEventListener("keydown",function(e){if(80===e.keyCode&&(e.ctrlKey||e.metaKey)&&!e.altKey&&(!e.shiftKey||window.chrome||window.opera)){window.print();e.preventDefault();e.stopImmediatePropagation()}},!0);if("onbeforeprint"in window){const stopPropagationIfNeeded=function(e){"custom"!==e.detail&&e.stopImmediatePropagation()};window.addEventListener("beforeprint",stopPropagationIfNeeded);window.addEventListener("afterprint",stopPropagationIfNeeded)}let vm;function ensureOverlay(){if(!vm){gm=mm.overlayManager;if(!gm)throw new Error("The overlay manager has not yet been initialized.");pm=document.getElementById("printServiceDialog");vm=gm.register(pm,!0);document.getElementById("printCancel").onclick=abort;pm.addEventListener("close",abort)}return vm}class PDFPrintServiceFactory extends BasePrintServiceFactory{static initGlobals(e){mm=e}static get supportsPrinting(){return shadow(this,"supportsPrinting",!0)}static createPrintService(e){if(_m)throw new Error("The print service is created and active.");PDFPrintServiceFactory.enablePrint||ngx_console_NgxConsole.debug("The print service is disabled.");return _m=new PDFPrintService(e,PDFPrintServiceFactory.isInPDFPrintRange,PDFPrintServiceFactory.filteredPageCount)}}function renderable_view_defineProperty(e,t,i){return(t=function renderable_view_toPropertyKey(e){var t=function renderable_view_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const Pm={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3};class RenderableView{constructor(){renderable_view_defineProperty(this,"renderingId","");renderable_view_defineProperty(this,"renderTask",null);renderable_view_defineProperty(this,"resume",null)}get renderingState(){throw new Error("Abstract getter `renderingState` accessed")}set renderingState(e){throw new Error("Abstract setter `renderingState` accessed")}async draw(){throw new Error("Not implemented: draw")}}function pdf_rendering_queue_defineProperty(e,t,i){return(t=function pdf_rendering_queue_toPropertyKey(e){var t=function pdf_rendering_queue_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function pdf_rendering_queue_classPrivateFieldInitSpec(e,t,i){(function pdf_rendering_queue_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function pdf_rendering_queue_classPrivateFieldSet(e,t,i){return e.set(pdf_rendering_queue_assertClassBrand(e,t),i),i}function pdf_rendering_queue_classPrivateFieldGet(e,t){return e.get(pdf_rendering_queue_assertClassBrand(e,t))}function pdf_rendering_queue_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var wm=new WeakMap,Fm=new WeakMap,bm=new WeakMap,ym=new WeakMap;class PDFRenderingQueue{constructor(){pdf_rendering_queue_classPrivateFieldInitSpec(this,wm,null);pdf_rendering_queue_classPrivateFieldInitSpec(this,Fm,null);pdf_rendering_queue_classPrivateFieldInitSpec(this,bm,null);pdf_rendering_queue_classPrivateFieldInitSpec(this,ym,null);pdf_rendering_queue_defineProperty(this,"isThumbnailViewEnabled",!1);pdf_rendering_queue_defineProperty(this,"onIdle",null);pdf_rendering_queue_defineProperty(this,"printing",!1);Object.defineProperty(this,"hasViewer",{value:()=>!!pdf_rendering_queue_classPrivateFieldGet(ym,this)})}setViewer(e){pdf_rendering_queue_classPrivateFieldSet(ym,this,e)}setThumbnailViewer(e){pdf_rendering_queue_classPrivateFieldSet(bm,this,e)}isHighestPriority(e){return pdf_rendering_queue_classPrivateFieldGet(wm,this)===e.renderingId}renderHighestPriority(e){if(pdf_rendering_queue_classPrivateFieldGet(Fm,this)){clearTimeout(pdf_rendering_queue_classPrivateFieldGet(Fm,this));pdf_rendering_queue_classPrivateFieldSet(Fm,this,null)}pdf_rendering_queue_classPrivateFieldGet(ym,this).forceRendering(e)||this.isThumbnailViewEnabled&&pdf_rendering_queue_classPrivateFieldGet(bm,this)?.forceRendering()||this.printing||this.onIdle&&pdf_rendering_queue_classPrivateFieldSet(Fm,this,setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(e,t,i,a=!1,s=!1){const n=e.views,r=n.length;if(0===r)return null;for(let e=0;e<r;e++){const t=n[e].view;if(!this.isViewFinished(t))return t}if(!s)for(let e=0;e<r;e++){const{detailView:t}=n[e].view;if(t&&!this.isViewFinished(t))return t}const o=e.first.id,l=e.last.id;if(l-o+1>r){const a=e.ids;for(let e=1,s=l-o;e<s;e++){const s=i?o+e:l-e;if(a.has(s))continue;const n=t[s-1];if(!this.isViewFinished(n))return n}}let d=i?l:o-2,c=t[d];if(c&&!this.isViewFinished(c))return c;if(a){d+=i?1:-1;c=t[d];if(c&&!this.isViewFinished(c))return c}return null}isViewFinished(e){return e.renderingState===Pm.FINISHED}renderView(e){switch(e.renderingState){case Pm.FINISHED:return!1;case Pm.PAUSED:pdf_rendering_queue_classPrivateFieldSet(wm,this,e.renderingId);e.resume();break;case Pm.RUNNING:pdf_rendering_queue_classPrivateFieldSet(wm,this,e.renderingId);break;case Pm.INITIAL:pdf_rendering_queue_classPrivateFieldSet(wm,this,e.renderingId);e.draw().finally(()=>{this.renderHighestPriority()}).catch(e=>{e instanceof RenderingCancelledException||ngx_console_NgxConsole.error("renderView:",e)})}return!0}}function pdf_scripting_manager_classPrivateFieldInitSpec(e,t,i){pdf_scripting_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_scripting_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_scripting_manager_classPrivateFieldGet(e,t){return e.get(pdf_scripting_manager_assertClassBrand(e,t))}function pdf_scripting_manager_classPrivateFieldSet(e,t,i){return e.set(pdf_scripting_manager_assertClassBrand(e,t),i),i}function pdf_scripting_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Sm=new WeakMap,Cm=new WeakMap,xm=new WeakMap,km=new WeakMap,Em=new WeakMap,Am=new WeakMap,Gm=new WeakMap,Bm=new WeakMap,Mm=new WeakMap,Im=new WeakMap,Tm=new WeakMap,Dm=new WeakMap,Lm=new WeakSet;class PDFScriptingManager{constructor({eventBus:e,externalServices:t=null,docProperties:i=null}){!function pdf_scripting_manager_classPrivateMethodInitSpec(e,t){pdf_scripting_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,Lm);pdf_scripting_manager_classPrivateFieldInitSpec(this,Sm,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Cm,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,xm,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,km,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Em,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Am,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Gm,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Bm,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Mm,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Im,!1);pdf_scripting_manager_classPrivateFieldInitSpec(this,Tm,null);pdf_scripting_manager_classPrivateFieldInitSpec(this,Dm,null);pdf_scripting_manager_classPrivateFieldSet(Em,this,e);pdf_scripting_manager_classPrivateFieldSet(Am,this,t);pdf_scripting_manager_classPrivateFieldSet(xm,this,i)}setViewer(e){pdf_scripting_manager_classPrivateFieldSet(Mm,this,e)}async setDocument(e){pdf_scripting_manager_classPrivateFieldGet(Bm,this)&&await pdf_scripting_manager_assertClassBrand(Lm,this,_destroyScripting).call(this);pdf_scripting_manager_classPrivateFieldSet(Bm,this,e);if(!e)return;const[t,i,a]=await Promise.all([e.getFieldObjects(),e.getCalculationOrderIds(),e.getJSActions()]);if(!t&&!a){await pdf_scripting_manager_assertClassBrand(Lm,this,_destroyScripting).call(this);return}if(e!==pdf_scripting_manager_classPrivateFieldGet(Bm,this))return;if(t){pdf_scripting_manager_classPrivateFieldSet(Gm,this,new Set);for(const e of Object.values(t))for(const{id:t}of e)pdf_scripting_manager_classPrivateFieldGet(Gm,this).add(t)}try{pdf_scripting_manager_classPrivateFieldSet(Tm,this,pdf_scripting_manager_assertClassBrand(Lm,this,_initScripting).call(this))}catch(e){ngx_console_NgxConsole.error("setDocument:",e);await pdf_scripting_manager_assertClassBrand(Lm,this,_destroyScripting).call(this);return}const s=pdf_scripting_manager_classPrivateFieldGet(Em,this);pdf_scripting_manager_classPrivateFieldSet(km,this,new AbortController);const n={signal:pdf_scripting_manager_classPrivateFieldGet(km,this).signal,...Nh};s.on("updatefromsandbox",e=>{e?.source===window&&pdf_scripting_manager_assertClassBrand(Lm,this,_updateFromSandbox).call(this,e.detail)},n);s.on("dispatcheventinsandbox",e=>{pdf_scripting_manager_classPrivateFieldGet(Tm,this)?.dispatchEventInSandbox(e.detail)},n);s.on("pagechanging",({pageNumber:e,previous:t})=>{if(e!==t){pdf_scripting_manager_assertClassBrand(Lm,this,_dispatchPageClose).call(this,t);pdf_scripting_manager_assertClassBrand(Lm,this,_dispatchPageOpen).call(this,e)}},n);s.on("pagerendered",({pageNumber:e})=>{this._pageOpenPending.has(e)&&e===pdf_scripting_manager_classPrivateFieldGet(Mm,this).currentPageNumber&&pdf_scripting_manager_assertClassBrand(Lm,this,_dispatchPageOpen).call(this,e)},n);s.on("pagesdestroy",async()=>{await pdf_scripting_manager_assertClassBrand(Lm,this,_dispatchPageClose).call(this,pdf_scripting_manager_classPrivateFieldGet(Mm,this).currentPageNumber);await(pdf_scripting_manager_classPrivateFieldGet(Tm,this)?.dispatchEventInSandbox({id:"doc",name:"WillClose"}));pdf_scripting_manager_classPrivateFieldGet(Sm,this)?.resolve()},n);try{const n=await pdf_scripting_manager_classPrivateFieldGet(xm,this).call(this,e);if(e!==pdf_scripting_manager_classPrivateFieldGet(Bm,this))return;await pdf_scripting_manager_classPrivateFieldGet(Tm,this).createSandbox({objects:t,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...n,actions:a}});s.dispatch("sandboxcreated",{source:this})}catch(e){ngx_console_NgxConsole.error("setDocument:",e);await pdf_scripting_manager_assertClassBrand(Lm,this,_destroyScripting).call(this);return}await(pdf_scripting_manager_classPrivateFieldGet(Tm,this)?.dispatchEventInSandbox({id:"doc",name:"Open"}));await pdf_scripting_manager_assertClassBrand(Lm,this,_dispatchPageOpen).call(this,pdf_scripting_manager_classPrivateFieldGet(Mm,this).currentPageNumber,!0);Promise.resolve().then(()=>{e===pdf_scripting_manager_classPrivateFieldGet(Bm,this)&&pdf_scripting_manager_classPrivateFieldSet(Im,this,!0)})}async dispatchWillSave(){return pdf_scripting_manager_classPrivateFieldGet(Tm,this)?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return pdf_scripting_manager_classPrivateFieldGet(Tm,this)?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(pdf_scripting_manager_classPrivateFieldGet(Tm,this)){await(pdf_scripting_manager_classPrivateFieldGet(Dm,this)?.promise);pdf_scripting_manager_classPrivateFieldSet(Dm,this,Promise.withResolvers());try{await pdf_scripting_manager_classPrivateFieldGet(Tm,this).dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(e){pdf_scripting_manager_classPrivateFieldGet(Dm,this).resolve();pdf_scripting_manager_classPrivateFieldSet(Dm,this,null);throw e}await pdf_scripting_manager_classPrivateFieldGet(Dm,this).promise}}async dispatchDidPrint(){return pdf_scripting_manager_classPrivateFieldGet(Tm,this)?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return pdf_scripting_manager_classPrivateFieldGet(Cm,this)?.promise||null}get ready(){return pdf_scripting_manager_classPrivateFieldGet(Im,this)}get _pageOpenPending(){return shadow(this,"_pageOpenPending",new Set)}get _visitedPages(){return shadow(this,"_visitedPages",new Map)}}async function _updateFromSandbox(e){const t=pdf_scripting_manager_classPrivateFieldGet(Mm,this),i=t.isInPresentationMode||t.isChangingPresentationMode,{id:a,siblings:s,command:n,value:r}=e;if(!a){switch(n){case"clear":ngx_console_NgxConsole.clear();break;case"error":ngx_console_NgxConsole.error(r);break;case"layout":if(!i){const e=apiPageLayoutToViewerModes(r);t.spreadMode=e.spreadMode}break;case"page-num":t.currentPageNumber=r+1;break;case"print":await t.pagesPromise;pdf_scripting_manager_classPrivateFieldGet(Em,this).dispatch("print",{source:this});break;case"println":ngx_console_NgxConsole.log(r);break;case"zoom":i||(t.currentScaleValue=r);break;case"SaveAs":pdf_scripting_manager_classPrivateFieldGet(Em,this).dispatch("download",{source:this});break;case"FirstPage":t.currentPageNumber=1;break;case"LastPage":t.currentPageNumber=t.pagesCount;break;case"NextPage":t.nextPage();break;case"PrevPage":t.previousPage();break;case"ZoomViewIn":i||t.increaseScale();break;case"ZoomViewOut":i||t.decreaseScale();break;case"WillPrintFinished":pdf_scripting_manager_classPrivateFieldGet(Dm,this)?.resolve();pdf_scripting_manager_classPrivateFieldSet(Dm,this,null)}return}if(i&&e.focus)return;delete e.id;delete e.siblings;const o=s?[a,...s]:[a];for(const t of o){if(!pdf_scripting_manager_classPrivateFieldGet(Gm,this)?.has(t))continue;const i=document.querySelector(`[data-element-id="${t}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:e})):pdf_scripting_manager_classPrivateFieldGet(Bm,this)?.annotationStorage.setValue(t,e)}}async function _dispatchPageOpen(e,t=!1){const i=pdf_scripting_manager_classPrivateFieldGet(Bm,this),a=this._visitedPages;t&&pdf_scripting_manager_classPrivateFieldSet(Sm,this,Promise.withResolvers());if(!pdf_scripting_manager_classPrivateFieldGet(Sm,this))return;const s=pdf_scripting_manager_classPrivateFieldGet(Mm,this).getPageView(e-1);if(s?.renderingState!==Pm.FINISHED){this._pageOpenPending.add(e);return}this._pageOpenPending.delete(e);const n=(async()=>{const t=await(a.has(e)?null:s.pdfPage?.getJSActions());i===pdf_scripting_manager_classPrivateFieldGet(Bm,this)&&await(pdf_scripting_manager_classPrivateFieldGet(Tm,this)?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:e,actions:t}))})();a.set(e,n)}async function _dispatchPageClose(e){const t=pdf_scripting_manager_classPrivateFieldGet(Bm,this),i=this._visitedPages;if(!pdf_scripting_manager_classPrivateFieldGet(Sm,this))return;if(this._pageOpenPending.has(e))return;const a=i.get(e);if(a){i.set(e,null);await a;t===pdf_scripting_manager_classPrivateFieldGet(Bm,this)&&await(pdf_scripting_manager_classPrivateFieldGet(Tm,this)?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:e}))}}function _initScripting(){pdf_scripting_manager_classPrivateFieldSet(Cm,this,Promise.withResolvers());if(pdf_scripting_manager_classPrivateFieldGet(Tm,this))throw new Error("#initScripting: Scripting already exists.");return pdf_scripting_manager_classPrivateFieldGet(Am,this).createScripting()}async function _destroyScripting(){pdf_scripting_manager_classPrivateFieldSet(Gm,this,null);if(pdf_scripting_manager_classPrivateFieldGet(Tm,this)){if(pdf_scripting_manager_classPrivateFieldGet(Sm,this)){await Promise.race([pdf_scripting_manager_classPrivateFieldGet(Sm,this).promise,new Promise(e=>{setTimeout(e,1e3)})]).catch(()=>{});pdf_scripting_manager_classPrivateFieldSet(Sm,this,null)}pdf_scripting_manager_classPrivateFieldSet(Bm,this,null);try{await pdf_scripting_manager_classPrivateFieldGet(Tm,this).destroySandbox()}catch{}pdf_scripting_manager_classPrivateFieldGet(Dm,this)?.reject(new Error("Scripting destroyed."));pdf_scripting_manager_classPrivateFieldSet(Dm,this,null);pdf_scripting_manager_classPrivateFieldGet(km,this)?.abort();pdf_scripting_manager_classPrivateFieldSet(km,this,null);this._pageOpenPending.clear();this._visitedPages.clear();pdf_scripting_manager_classPrivateFieldSet(Tm,this,null);pdf_scripting_manager_classPrivateFieldSet(Im,this,!1);pdf_scripting_manager_classPrivateFieldGet(Cm,this)?.resolve()}else{pdf_scripting_manager_classPrivateFieldSet(Bm,this,null);pdf_scripting_manager_classPrivateFieldGet(Cm,this)?.resolve()}}function menu_classPrivateFieldInitSpec(e,t,i){menu_checkPrivateRedeclaration(e,t),t.set(e,i)}function menu_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function menu_classPrivateFieldGet(e,t){return e.get(menu_assertClassBrand(e,t))}function menu_classPrivateFieldSet(e,t,i){return e.set(menu_assertClassBrand(e,t),i),i}function menu_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Nm=new WeakMap,Rm=new WeakMap,Om=new WeakMap,Wm=new WeakMap,jm=new WeakMap,Vm=new WeakMap,Um=new WeakMap,zm=new WeakSet;class Menu{constructor(e,t,i){!function menu_classPrivateMethodInitSpec(e,t){menu_checkPrivateRedeclaration(e,t),t.add(e)}(this,zm);menu_classPrivateFieldInitSpec(this,Nm,void 0);menu_classPrivateFieldInitSpec(this,Rm,void 0);menu_classPrivateFieldInitSpec(this,Om,void 0);menu_classPrivateFieldInitSpec(this,Wm,null);menu_classPrivateFieldInitSpec(this,jm,new AbortController);menu_classPrivateFieldInitSpec(this,Vm,-1);menu_classPrivateFieldInitSpec(this,Um,menu_assertClassBrand(zm,this,_onFocusOut).bind(this));menu_classPrivateFieldSet(Rm,this,e);menu_classPrivateFieldSet(Nm,this,t);if(Array.isArray(i))menu_classPrivateFieldSet(Om,this,i);else{menu_classPrivateFieldSet(Om,this,[]);for(const e of menu_classPrivateFieldGet(Rm,this).querySelectorAll("button"))menu_classPrivateFieldGet(Om,this).push(e)}menu_assertClassBrand(zm,this,_setUpMenu).call(this)}destroy(){menu_assertClassBrand(zm,this,_closeMenu).call(this);menu_classPrivateFieldGet(jm,this)?.abort();menu_classPrivateFieldSet(jm,this,null)}}function _closeMenu(){if(!menu_classPrivateFieldGet(Wm,this))return;const e=menu_classPrivateFieldGet(Rm,this);menu_classPrivateFieldGet(Nm,this).ariaExpanded="false";menu_classPrivateFieldGet(Wm,this).abort();menu_classPrivateFieldSet(Wm,this,null);e.contains(document.activeElement)&&setTimeout(()=>{e.contains(document.activeElement)||menu_classPrivateFieldGet(Nm,this).focus()},0);menu_classPrivateFieldSet(Vm,this,-1)}function _openMenu(){if(menu_classPrivateFieldGet(Wm,this))return;const e=menu_classPrivateFieldGet(Rm,this);menu_classPrivateFieldGet(Nm,this).ariaExpanded="true";menu_classPrivateFieldSet(Wm,this,new AbortController);const t=AbortSignal.any([menu_classPrivateFieldGet(jm,this).signal,menu_classPrivateFieldGet(Wm,this).signal]);window.addEventListener("pointerdown",({target:t})=>{menu_classPrivateFieldGet(Nm,this).contains(t)||e.contains(t)||menu_assertClassBrand(zm,this,_closeMenu).call(this)},{signal:t});const i=menu_assertClassBrand(zm,this,_closeMenu).bind(this);window.addEventListener("blur",i,{signal:t});e.addEventListener("focusout",menu_classPrivateFieldGet(Um,this),{signal:t})}function _onFocusOut({relatedTarget:e}){menu_classPrivateFieldGet(Nm,this).contains(e)||menu_classPrivateFieldGet(Rm,this).contains(e)||menu_assertClassBrand(zm,this,_closeMenu).call(this)}function _setUpMenu(){menu_classPrivateFieldGet(Nm,this).addEventListener("click",e=>{menu_classPrivateFieldGet(Wm,this)?menu_assertClassBrand(zm,this,_closeMenu).call(this):menu_assertClassBrand(zm,this,_openMenu).call(this)});menu_classPrivateFieldGet(Nm,this).addEventListener("focusout",menu_classPrivateFieldGet(Um,this));const{signal:e}=menu_classPrivateFieldGet(jm,this);menu_classPrivateFieldGet(Rm,this).addEventListener("keydown",e=>{switch(e.key){case"Escape":menu_assertClassBrand(zm,this,_closeMenu).call(this);stopEvent(e);break;case"ArrowDown":menu_assertClassBrand(zm,this,_goToNextItem).call(this,e.target,!0);stopEvent(e);break;case"ArrowUp":menu_assertClassBrand(zm,this,_goToNextItem).call(this,e.target,!1);stopEvent(e);break;case"Home":menu_classPrivateFieldGet(Om,this).find(e=>!e.disabled&&!e.classList.contains("hidden"))?.focus();stopEvent(e);break;case"End":menu_classPrivateFieldGet(Om,this).findLast(e=>!e.disabled&&!e.classList.contains("hidden"))?.focus();stopEvent(e);break;default:const{key:t}=e;if(!/^\p{L}$/u.test(t))break;const i=t.toLocaleLowerCase();menu_assertClassBrand(zm,this,_goToNextItem).call(this,e.target,!0,e=>e.textContent.trim().toLowerCase().startsWith(i));stopEvent(e)}},{signal:e,capture:!0});menu_classPrivateFieldGet(Rm,this).addEventListener("contextmenu",noContextMenu,{signal:e});menu_classPrivateFieldGet(Rm,this).addEventListener("click",menu_assertClassBrand(zm,this,_closeMenu).bind(this),{signal:e,capture:!0});menu_classPrivateFieldGet(Nm,this).addEventListener("keydown",e=>{switch(e.key){case" ":case"Enter":case"ArrowDown":case"Home":stopEvent(e);menu_classPrivateFieldGet(Wm,this)||menu_assertClassBrand(zm,this,_openMenu).call(this);menu_classPrivateFieldGet(Om,this).find(e=>!e.disabled&&!e.classList.contains("hidden"))?.focus();break;case"ArrowUp":case"End":stopEvent(e);menu_classPrivateFieldGet(Wm,this)||menu_assertClassBrand(zm,this,_openMenu).call(this);menu_classPrivateFieldGet(Om,this).findLast(e=>!e.disabled&&!e.classList.contains("hidden"))?.focus();break;case"Escape":menu_assertClassBrand(zm,this,_closeMenu).call(this);stopEvent(e)}},{signal:e})}function _goToNextItem(e,t,i=()=>!0){const a=-1===menu_classPrivateFieldGet(Vm,this)?menu_classPrivateFieldGet(Om,this).indexOf(e):menu_classPrivateFieldGet(Vm,this),s=menu_classPrivateFieldGet(Om,this).length,n=t?1:s-1;for(let e=(a+n)%s;e!==a;e=(e+n)%s){const t=menu_classPrivateFieldGet(Om,this)[e];if(!t.disabled&&!t.classList.contains("hidden")&&i(t)){t.focus();menu_classPrivateFieldSet(Vm,this,e);break}}}function pdf_thumbnail_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_thumbnail_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}let Hm=0;var $m,Km=new WeakMap,Xm=new WeakSet;class PDFThumbnailView extends RenderableView{constructor({container:e,eventBus:t,id:i,defaultViewport:a,optionalContentConfigPromise:s,linkService:n,renderingQueue:r,maxCanvasPixels:o,maxCanvasDim:l,pageColors:d,enableSplitMerge:c=!1,enablePageReordering:h=!1}){super();!function pdf_thumbnail_view_classPrivateMethodInitSpec(e,t){pdf_thumbnail_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,Xm);!function pdf_thumbnail_view_classPrivateFieldInitSpec(e,t,i){pdf_thumbnail_view_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,Km,Pm.INITIAL);this.id=i;this.renderingId=`thumbnail${i}`;this.pageLabel=null;this.pdfPage=null;this.rotation=0;this.viewport=a;this.pdfPageRotate=a.rotation;this._optionalContentConfigPromise=s||null;this.maxCanvasPixels=o??AppOptions.get("maxCanvasPixels");this.maxCanvasDim=l||AppOptions.get("maxCanvasDim");this.pageColors=d||null;this.eventBus=t;this.linkService=n;this.renderingQueue=r;this.placeholder=null;t.dispatch("rendercustomthumbnail",{pdfThumbnailView:this,linkService:n,id:i,container:e,thumbPageTitlePromiseOrPageL10nArgs:pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageL10nArgs).call(this,!0)});const u=e.querySelector(`.${this.renderingId}`);if(u){this.div=u;this.imageContainer=this.div.querySelector(".thumbnailImageContainer")||this.div;this.image=this.div.querySelector(".thumbnailImage")||this.imageContainer.querySelector("img");this.checkbox=this.div.querySelector("input[type='checkbox']");if(this.image){if(c&&!this.checkbox){const e=this.checkbox=document.createElement("input");e.type="checkbox";e.tabIndex=-1;e.setAttribute("data-l10n-id","pdfjs-thumb-page-checkbox1");e.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageL10nArgs).call(this));this.div.append(e);this.pasteButton=null}}else pdf_thumbnail_view_assertClassBrand(Xm,this,_createStandardThumbnail).call(this,e,i,c,h)}else pdf_thumbnail_view_assertClassBrand(Xm,this,_createStandardThumbnail).call(this,e,i,c);u&&pdf_thumbnail_view_assertClassBrand(Xm,this,_updateDims).call(this);if(h&&this.div){this.div.addEventListener("dragstart",this._dragStartHandler.bind(this));this.div.addEventListener("dragover",this._dragOverHandler.bind(this));this.div.addEventListener("drop",this._dropHandler.bind(this));this.div.addEventListener("mousedown",this._mouseDownHandler.bind(this))}}clone(e,t){const i=new PDFThumbnailView({container:e,id:t,eventBus:this.eventBus,defaultViewport:this.viewport,optionalContentConfigPromise:this._optionalContentConfigPromise,linkService:this.linkService,renderingQueue:this.renderingQueue,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,enableSplitMerge:!!this.checkbox}),{imageContainer:a}=this;if(!a.classList.contains("missingThumbnailImage")){i.image.replaceWith(this.image.cloneNode(!0));i.imageContainer.classList.remove("missingThumbnailImage")}return i}addPasteButton(e){if(this.pasteButton)return;const t=this.pasteButton=document.createElement("button");t.classList.add("thumbnailPasteButton","viewsManagerButton");t.tabIndex=0;t.setAttribute("data-l10n-id","pdfjs-views-manager-paste-button-after");t.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageL10nArgs).call(this));const i=document.createElement("span");i.setAttribute("data-l10n-id","pdfjs-views-manager-paste-button-label");t.append(i);t.addEventListener("click",()=>{e(this.id)});if(1===this.id){const i=this.prevPasteButton=t.cloneNode(!0);i.setAttribute("data-l10n-id","pdfjs-views-manager-paste-button-before");i.addEventListener("click",()=>{e(0)});this.imageContainer.before(i)}this.imageContainer.after(t)}removePasteButton(){this.pasteButton?.remove();this.pasteButton=null;this.prevPasteButton?.remove();this.prevPasteButton=null}toggleSelected(e){this.checkbox&&(this.checkbox.checked=e)}_dragStartHandler(e){e.dataTransfer.setData("text/plain",this.id.toString())}_dragOverHandler(e){e.preventDefault();e.dataTransfer.dropEffect="move";const t=e.currentTarget,i=t.getBoundingClientRect();this._removeDottedLine();i.top<Hm&&i.bottom>Hm||this._showDottedLine(t,i.height,Hm>e.clientY)}_dropHandler(e){e.preventDefault();e.stopPropagation();const t=parseInt(e.dataTransfer.getData("text/plain"),10),i=this.id;this._removeDottedLine();t!==i&&this._movePage(t,i)}_mouseDownHandler(e){Hm=e.clientY}_showDottedLine(e,t,i){const a=document.createElement("div");a.className="dotted-line";i?a.style.setProperty("--dotted-line-margin-x",-t+"px"):a.style.setProperty("--dotted-line-margin-x","6px");e.appendChild(a)}_removeDottedLine(){const e=document.querySelector(".dotted-line");e&&e.parentNode.removeChild(e)}_movePage(e,t){const i=this.div.parentNode,a=i.children[e-1],s=i.children[t-1];a&&s&&AF.movePage(e,t)}updateId(e){this.id=e;this.renderingId=`thumbnail${e}`;this.div.setAttribute("page-number",e);this.imageContainer.setAttribute("page-number",e);this.setPageLabel(this.pageLabel)}get renderingState(){return function pdf_thumbnail_view_classPrivateFieldGet(e,t){return e.get(pdf_thumbnail_view_assertClassBrand(e,t))}(Km,this)}set renderingState(e){!function pdf_thumbnail_view_classPrivateFieldSet(e,t,i){return e.set(pdf_thumbnail_view_assertClassBrand(e,t),i),i}(Km,this,e)}setPdfPage(e){if(!e)return;this.pdfPage=e;this.pdfPageRotate=e.rotate;const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=e.getViewport({scale:1,rotation:t});this.reset()}reset(){this.cancelRendering();this.renderingState=Pm.INITIAL;pdf_thumbnail_view_assertClassBrand(Xm,this,_updateDims).call(this);const{image:e,imageContainer:t}=this,i=e.src;if(i){URL.revokeObjectURL(i);e.src="";t.removeAttribute("data-l10n-id");t.removeAttribute("data-l10n-args");t.classList.add("missingThumbnailImage")}}destroy(){this.reset();this.toggleCurrent(!1);this.div.remove()}update({rotation:e=null}){"number"==typeof e&&(this.rotation=e);const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:1,rotation:t});this.reset()}toggleCurrent(e){const{imageContainer:t}=this;if(e){t.ariaCurrent="page";t.tabIndex=0;this.checkbox&&(this.checkbox.tabIndex=0)}else{t.ariaCurrent=!1;t.tabIndex=-1;this.checkbox&&(this.checkbox.tabIndex=-1)}}cancelRendering(){if(this.renderTask){this.renderTask.cancel();this.renderTask=null}this.resume=null}async draw(){if(this.renderingState!==Pm.INITIAL){ngx_console_NgxConsole.error("Must be in new state before drawing");return}const{pageColors:e,pdfPage:t}=this;if(!t){this.renderingState=Pm.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=Pm.RUNNING;const{canvas:i,transform:a}=pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageDrawContext).call(this,2),s={canvas:i,transform:a,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:e},n=this.renderTask=t.render(s);n.onContinue=e=>{if(this.renderingQueue.isHighestPriority(this))e();else{this.renderingState=Pm.PAUSED;this.resume=()=>{this.renderingState=Pm.RUNNING;e()}}};let r=null;try{await n.promise}catch(e){if(e instanceof RenderingCancelledException)return;r=e}finally{n===this.renderTask&&(this.renderTask=null)}this.renderingState=Pm.FINISHED;await pdf_thumbnail_view_assertClassBrand(Xm,this,_convertCanvasToImage).call(this,i);this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:t});if(r)throw r}setImage(e){if(this.renderingState!==Pm.INITIAL)return;const{thumbnailCanvas:t,pdfPage:i,scale:a}=e;if(t){this.pdfPage||this.setPdfPage(i);if(!(a<this.scale)){this.renderingState=Pm.FINISHED;pdf_thumbnail_view_assertClassBrand(Xm,this,_convertCanvasToImage).call(this,t)}}}setPageLabel(e){this.pageLabel="string"==typeof e?e:null;this.imageContainer.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageL10nArgs).call(this,!0));this.image.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageL10nArgs).call(this));this.checkbox?.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageL10nArgs).call(this))}}function _createStandardThumbnail(e,t,i,a=!1){const s=this.div=document.createElement("div");s.className="thumbnail";s.setAttribute("page-number",t);const n=this.imageContainer=document.createElement("div");s.append(n);n.classList.add("thumbnailImageContainer","missingThumbnailImage");n.role="button";n.tabIndex=-1;n.draggable=!1;n.setAttribute("page-number",t);n.setAttribute("data-l10n-id","pdfjs-thumb-page-title1");n.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageL10nArgs).call(this,!0));const r=this.image=document.createElement("img");n.append(r);a&&(n.draggable=!0);if(i){const e=this.checkbox=document.createElement("input");e.type="checkbox";e.tabIndex=-1;e.setAttribute("data-l10n-id","pdfjs-thumb-page-checkbox1");e.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageL10nArgs).call(this));s.append(e);this.pasteButton=null}pdf_thumbnail_view_assertClassBrand(Xm,this,_updateDims).call(this);e.append(s)}function _updateDims(){const{width:e,height:t}=this.viewport,i=e/t,a=this.canvasWidth=126,s=this.canvasHeight=a/i|0;this.scale=a/e;this.imageContainer.style.height=`${s}px`}function _getPageDrawContext(e=1){const t=new OutputScale,i=e*this.canvasWidth,a=e*this.canvasHeight;t.limitCanvas(i,a,this.maxCanvasPixels,this.maxCanvasDim);const s=document.createElement("canvas");s.width=i*t.sx|0;s.height=a*t.sy|0;return{canvas:s,transform:t.scaled?[t.sx,0,0,t.sy,0,0]:null}}async function _convertCanvasToImage(e){if(this.renderingState!==Pm.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const t=pdf_thumbnail_view_assertClassBrand(Xm,this,_reduceImage).call(this,e),{imageContainer:i,image:a}=this,{promise:s,resolve:n}=Promise.withResolvers();t.toBlob(n);const r=await s;a.src=URL.createObjectURL(r);a.setAttribute("data-l10n-id","pdfjs-thumb-page-canvas");a.setAttribute("data-l10n-args",pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageL10nArgs).call(this));i.classList.remove("missingThumbnailImage")}function _getReducedImageDims(e){const t=e.width<<3,i=e.height<<3,a=new OutputScale;a.sx=a.sy=1;a.limitCanvas(t,i,this.maxCanvasPixels,this.maxCanvasDim);return[t*a.sx|0,i*a.sy|0]}function _reduceImage(e){const{canvas:t}=pdf_thumbnail_view_assertClassBrand(Xm,this,_getPageDrawContext).call(this,1),i=t.getContext("2d",{alpha:!1,willReadFrequently:!1});if(e.width<=2*t.width){i.drawImage(e,0,0,e.width,e.height,0,0,t.width,t.height);return t}let[a,s]=pdf_thumbnail_view_assertClassBrand(Xm,this,_getReducedImageDims).call(this,t);const[n,r]=function getTempCanvas(e,t){const i=new OffscreenCanvas(e,t),a=i.getContext("2d",{alpha:!1});a.save();a.fillStyle="rgb(255, 255, 255)";a.fillRect(0,0,e,t);a.restore();return[i,a]}(a,s);for(;a>e.width||s>e.height;){a>>=1;s>>=1}r.drawImage(e,0,0,e.width,e.height,0,0,a,s);for(;a>2*t.width;){r.drawImage(n,0,0,a,s,0,0,a>>1,s>>1);a>>=1;s>>=1}i.drawImage(n,0,0,a,s,0,0,t.width,t.height);return t}function _getPageL10nArgs(e=!1){return JSON.stringify({page:this.pageLabel??this.id,total:e?this.linkService.pagesCount:void 0})}function pdf_thumbnail_viewer_classPrivateFieldInitSpec(e,t,i){pdf_thumbnail_viewer_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_thumbnail_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_thumbnail_viewer_toSetter(e,t,i){t||(t=[]);var a=t.length++;return Object.defineProperty({},"_",{set:function(s){t[a]=s,e.apply(i,t)}})}function pdf_thumbnail_viewer_classPrivateFieldGet(e,t){return e.get(pdf_thumbnail_viewer_assertClassBrand(e,t))}function pdf_thumbnail_viewer_classPrivateFieldSet(e,t,i){return e.set(pdf_thumbnail_viewer_assertClassBrand(e,t),i),i}function pdf_thumbnail_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const qm={behavior:"instant",block:"nearest",inline:"nearest",container:"nearest"};var Ym=new WeakMap,Zm=new WeakMap,Qm=new WeakMap,Jm=new WeakMap,ef=new WeakMap,tf=new WeakMap,af=new WeakMap,sf=new WeakMap,nf=new WeakMap,rf=new WeakMap,of=new WeakMap,lf=new WeakMap,df=new WeakMap,cf=new WeakMap,hf=new WeakMap,uf=new WeakMap,_f=new WeakMap,pf=new WeakMap,gf=new WeakMap,mf=new WeakMap,ff=new WeakMap,vf=new WeakMap,Pf=new WeakMap,wf=new WeakMap,Ff=new WeakMap,bf=new WeakMap,yf=new WeakMap,Sf=new WeakMap,Cf=new WeakMap,xf=new WeakMap,kf=new WeakMap,Ef=new WeakMap,Af=new WeakMap,Gf=new WeakMap,Bf=new WeakMap,Mf=new WeakMap,If=new WeakMap,Tf=new WeakMap,Df=new WeakMap,Lf=new WeakMap,Nf=new WeakMap,Rf=new WeakMap,Of=new WeakMap,Wf=new WeakMap,jf=new WeakMap,Vf=new WeakSet;class PDFThumbnailViewer{constructor({container:e,eventBus:t,linkService:i,renderingQueue:a,maxCanvasPixels:s,maxCanvasDim:n,pageColors:r,abortSignal:o,enableMerge:l,enableSplitMerge:d,enablePageReordering:c,enableNewBadge:h,statusBar:u,undoBar:_,waitingBar:p,manageMenu:g,addFileComponent:m}){!function pdf_thumbnail_viewer_classPrivateMethodInitSpec(e,t){pdf_thumbnail_viewer_checkPrivateRedeclaration(e,t),t.add(e)}(this,Vf);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Ym,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Zm,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Qm,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Jm,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,ef,void 0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,tf,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,af,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,sf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,nf,NaN);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,rf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,of,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,lf,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,df,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,cf,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,hf,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,uf,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,_f,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,pf,NaN);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,gf,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,mf,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,ff,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,vf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Pf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,wf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Ff,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,bf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,yf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Sf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Cf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,xf,pdf_thumbnail_viewer_assertClassBrand(Vf,this,_pastePages).bind(this));pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,kf,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Ef,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Af,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Gf,0);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Bf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Mf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,If,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Tf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Df,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Lf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Nf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Rf,null);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Of,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,Wf,!1);pdf_thumbnail_viewer_classPrivateFieldInitSpec(this,jf,null);this.scrollableContainer=e.parentElement;this.container=e;this.eventBus=t;this.linkService=i;this.renderingQueue=a;this.maxCanvasPixels=s;this.maxCanvasDim=n;this.pageColors=r||null;pdf_thumbnail_viewer_classPrivateFieldSet(ef,this,o);pdf_thumbnail_viewer_classPrivateFieldSet(Ym,this,l||!1);pdf_thumbnail_viewer_classPrivateFieldSet(Zm,this,d||!1);pdf_thumbnail_viewer_classPrivateFieldSet(Qm,this,c||!1);pdf_thumbnail_viewer_classPrivateFieldSet(Bf,this,u?.viewsManagerStatusActionLabel||null);pdf_thumbnail_viewer_classPrivateFieldSet(If,this,u?.viewsManagerStatusActionDeselectButton||null);pdf_thumbnail_viewer_classPrivateFieldSet(Mf,this,u?.viewsManagerStatusAction||null);pdf_thumbnail_viewer_classPrivateFieldSet(Tf,this,_?.viewsManagerStatusUndo||null);pdf_thumbnail_viewer_classPrivateFieldSet(Df,this,_?.viewsManagerStatusUndoLabel||null);pdf_thumbnail_viewer_classPrivateFieldSet(Lf,this,_?.viewsManagerStatusUndoButton||null);pdf_thumbnail_viewer_classPrivateFieldSet(Nf,this,_?.viewsManagerStatusUndoCloseButton||null);pdf_thumbnail_viewer_classPrivateFieldSet(Rf,this,p||null);if(pdf_thumbnail_viewer_classPrivateFieldGet(Zm,this)&&g){const{button:e,menu:i,copy:a,cut:s,delete:n,exportSelected:r}=g;if(h){const t=document.createElement("span");t.setAttribute("data-l10n-id","pdfjs-new-badge-content");t.classList.add("newBadge");e.parentElement.before(t);pdf_thumbnail_viewer_classPrivateFieldSet(jf,this,t)}t.on("pagesloaded",()=>{e.disabled=!1},{once:!0,...Nh});this._manageMenu=new Menu(i,e,[a,s,n,r]);pdf_thumbnail_viewer_classPrivateFieldSet(vf,this,r);r.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Vf,this,_saveExtractedPages).bind(this));pdf_thumbnail_viewer_classPrivateFieldSet(Pf,this,n);n.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Vf,this,_deletePages).bind(this,"delete"));pdf_thumbnail_viewer_classPrivateFieldSet(wf,this,a);a.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Vf,this,_copyPages).bind(this));pdf_thumbnail_viewer_classPrivateFieldSet(Ff,this,s);s.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Vf,this,_cutPages).bind(this));pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleMenuEntries).call(this,!1);e.disabled=!0;t.on("editingaction",({name:e})=>{switch(e){case"copyPage":pdf_thumbnail_viewer_assertClassBrand(Vf,this,_copyPages).call(this);break;case"cutPage":pdf_thumbnail_viewer_assertClassBrand(Vf,this,_cutPages).call(this);break;case"deletePage":pdf_thumbnail_viewer_assertClassBrand(Vf,this,_deletePages).call(this,"delete");break;case"savePage":pdf_thumbnail_viewer_assertClassBrand(Vf,this,_saveExtractedPages).call(this)}},Nh);this.container.addEventListener("contextmenu",e=>{t.dispatch("editingstateschanged",{source:this,details:{thumbnailId:parseInt(e.target.closest(".thumbnailImageContainer")?.parentElement.getAttribute("page-number"),10)??-1,hasSelectedPages:!!pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)?.size,canDeletePages:pdf_thumbnail_viewer_assertClassBrand(Vf,this,_canDelete).call(this)}})},{signal:o,passive:!0});pdf_thumbnail_viewer_classPrivateFieldGet(Lf,this)?.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Vf,this,_undo).bind(this));pdf_thumbnail_viewer_classPrivateFieldGet(Nf,this)?.addEventListener("click",pdf_thumbnail_viewer_assertClassBrand(Vf,this,_dismissUndo).bind(this,!0));pdf_thumbnail_viewer_classPrivateFieldGet(If,this)?.addEventListener("click",()=>{pdf_thumbnail_viewer_assertClassBrand(Vf,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateStatus).call(this,"select")});pdf_thumbnail_viewer_classPrivateFieldGet(If,this).classList.toggle("hidden",!0)}else g&&(g.button.hidden=!0);if(pdf_thumbnail_viewer_classPrivateFieldGet(Ym,this)&&m?.button&&m.picker){const{picker:e,button:t}=m;e.addEventListener("change",()=>{const t=Array.from(e.files??[]);t.length&&pdf_thumbnail_viewer_assertClassBrand(Vf,this,_mergeFiles).call(this,t,this._currentPageNumber-1)});t.addEventListener("click",()=>{e.click()});pdf_thumbnail_viewer_classPrivateFieldGet(Rf,this)?.closeButton?.addEventListener("click",()=>{pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleBar).call(this,"status");e.value=""})}this.scroll=watchScroll(this.scrollableContainer,pdf_thumbnail_viewer_assertClassBrand(Vf,this,_scrollUpdated).bind(this),o);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_resetView).call(this);pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_addEventListeners).call(this)}getThumbnail(e){return this._thumbnails[e]}scrollThumbnailIntoView(e){if(!this.pdfDocument)return;const t=this._thumbnails[e-1];if(!t){ngx_console_NgxConsole.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');return}if(e!==this._currentPageNumber){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_resetCurrentThumbnail).call(this,e);t.toggleCurrent(!0)}const{first:i,last:a,views:s}=pdf_thumbnail_viewer_assertClassBrand(Vf,this,_getVisibleThumbs).call(this);if(s.length>0){let n=!1;if(e<=i.id||e>=a.id)n=!0;else for(const{id:t,percent:i}of s)if(t===e){n=i<100;break}n&&t.div.scrollIntoView(qm)}this._currentPageNumber=e}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!isValidRotation(e))throw new Error("Invalid thumbnails rotation angle.");if(!this.pdfDocument)return;if(this._pagesRotation===e)return;this._pagesRotation=e;const t={rotation:e};for(const e of this._thumbnails)e.update(t)}swapThumbnails(e,t){let i=this._thumbnails[e].pdfPage;this._thumbnails[e].setPdfPage(this._thumbnails[t].pdfPage);this._thumbnails[t].setPdfPage(i)}cleanup(){for(const e of this._thumbnails)e.renderingState!==Pm.FINISHED&&e.reset()}setDocument(e){this.initialized=!1;if(this.pdfDocument){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_cancelRendering).call(this);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_resetView).call(this)}this.pdfDocument=e;if(!e)return;pdf_thumbnail_viewer_classPrivateFieldSet(ff,this,e.pagesMapper);const t=e.getPage(1),i=e.getOptionalContentConfig({intent:"display"});t.then(t=>{const a=e.numPages,s=t.getViewport({scale:1}),n=document.createDocumentFragment();for(let e=1;e<=a;++e){const t=new PDFThumbnailView({container:n,eventBus:this.eventBus,id:e,defaultViewport:s.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,eventBus:this.eventBus,enableSplitMerge:pdf_thumbnail_viewer_classPrivateFieldGet(Zm,this),enablePageReordering:pdf_thumbnail_viewer_classPrivateFieldGet(Qm,this)});this._thumbnails.push(t)}this._thumbnails[0]?.setPdfPage(t);this._thumbnails[this._currentPageNumber-1].toggleCurrent(!0);this.container.append(n);this.eventBus.dispatch("thumbnailsloaded",{source:this})}).catch(e=>{ngx_console_NgxConsole.error("Unable to initialize thumbnail viewer",e)})}setPageLabels(e){if(this.pdfDocument){if(e)if(Array.isArray(e)&&this.pdfDocument.numPages===e.length)this._pageLabels=e;else{this._pageLabels=null;ngx_console_NgxConsole.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")}else this._pageLabels=null;for(let e=0,t=this._thumbnails.length;e<t;e++)this._thumbnails[e].setPageLabel(this._pageLabels?.[e]??null)}}forceRendering(){const e=pdf_thumbnail_viewer_assertClassBrand(Vf,this,_getVisibleThumbs).call(this),t=pdf_thumbnail_viewer_assertClassBrand(Vf,this,_getScrollAhead).call(this,e),i=this.renderingQueue.getHighestPriority(e,this._thumbnails,t,!1,!0);if(i){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_ensurePdfPageLoaded).call(this,i).then(()=>{this.renderingQueue.renderView(i)});return!0}return!1}hasStructuralChanges(){return pdf_thumbnail_viewer_classPrivateFieldGet(ff,this)?.hasBeenAltered()||!1}getStructuralChanges(){return pdf_thumbnail_viewer_classPrivateFieldGet(ff,this)?.getPageMappingForSaving()||null}stopRendering(){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_cancelRendering).call(this)}}$m=PDFThumbnailViewer;function _scrollUpdated(){this.renderingQueue.renderHighestPriority()}async function _mergeFiles(e,t){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleBar).call(this,"waiting","pdfjs-views-manager-waiting-for-file");const i=[];for(const a of e){const e=a.type?.startsWith("image/");if(!e&&"application/pdf"!==a.type){if("%PDF-"!==await a.slice(0,5).text())continue}if(e){let e;try{e=await _fileToImageBitmap.call($m,a)}catch{continue}i.push({image:e,insertAfter:t})}else i.push({document:await a.bytes(),insertAfter:t})}if(0===i.length){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleBar).call(this,"status");return}const a=pdf_thumbnail_viewer_classPrivateFieldGet(ff,this).pagesNumber,s=this.hasStructuralChanges()?this.getStructuralChanges():[{document:null}];s.push(...i);this.eventBus.on("pagesloaded",()=>{pdf_thumbnail_viewer_classPrivateFieldSet(rf,this,null);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateMenuEntries).call(this);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleBar).call(this,"status");const e=pdf_thumbnail_viewer_classPrivateFieldGet(ff,this).pagesNumber-a;for(let i=t+1,a=t+1+e;i<a;i++){this._thumbnails[i].checkbox&&(this._thumbnails[i].checkbox.checked=!0);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_selectPage).call(this,i+1,!0)}e&&pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateCurrentPage).call(this,t+2,!0)},{once:!0,...Nh});pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"merge"});this.eventBus.dispatch("saveandload",{source:this,data:s})}function _getVisibleThumbs(){return getVisibleElements({scrollEl:this.scrollableContainer,views:this._thumbnails})}function _resetCurrentThumbnail(e){if(!this.pdfDocument)return;const t=this._thumbnails[this._currentPageNumber-1];t?.toggleCurrent(!1);this._currentPageNumber=e}function _resetView(){this._thumbnails=[];this._currentPageNumber=1;this._pageLabels=null;this._pagesRotation=0;this.container.textContent=""}function _cancelRendering(){for(const e of this._thumbnails)e.cancelRendering()}async function _ensurePdfPageLoaded(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);e.pdfPage||e.setPdfPage(t);return t}catch(e){ngx_console_NgxConsole.error("Unable to get page for thumb view",e);return null}}function _getScrollAhead(e){return 1===e.first?.id||e.last?.id!==this._thumbnails.length&&this.scroll.down}function _getScaleFactor(e){return Uf._||(Uf._=parseFloat(getComputedStyle(e).getPropertyValue("--thumbnail-dragging-scale")))}function _fitImageDimensions(e,t,{minSide:i=0,maxSide:a}){const s=Math.max(e,t);let n=1;i>0&&s<i?n=i/s:s>a&&(n=a/s);return 1===n?{width:e,height:t}:{width:Math.max(1,Math.round(e*n)),height:Math.max(1,Math.round(t*n))}}async function _fileToImageBitmap(e){const t=1024;if("image/svg+xml"!==e.type){const t=await createImageBitmap(e),{width:i,height:a}=_fitImageDimensions.call($m,t.width,t.height,{maxSide:4096});if(i===t.width&&a===t.height)return t;const s=new OffscreenCanvas(i,a);s.getContext("2d").drawImage(t,0,0,i,a);t.close();return s.transferToImageBitmap()}const i=URL.createObjectURL(e);try{const e=new Image;e.src=i;await e.decode();const{width:a,height:s}=_fitImageDimensions.call($m,e.naturalWidth||t,e.naturalHeight||t,{minSide:t,maxSide:4096}),n=new OffscreenCanvas(a,s);n.getContext("2d").drawImage(e,0,0,a,s);return n.transferToImageBitmap()}finally{URL.revokeObjectURL(i)}}function _updateThumbnails(e){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_resetCurrentThumbnail).call(this,0);let t=0;const i=pdf_thumbnail_viewer_classPrivateFieldGet(ff,this),a=pdf_thumbnail_viewer_classPrivateFieldSet(yf,this,this._thumbnails),s=this._thumbnails=[],n=document.createDocumentFragment(),r=pdf_thumbnail_viewer_classPrivateFieldGet(kf,this);for(let o=1,l=i.pagesNumber;o<=l;o++){const l=i.getPrevPageNumber(o);if(l<0){let e=pdf_thumbnail_viewer_classPrivateFieldGet(bf,this).get(-l);e.checkbox&&(e.checkbox.checked=!1);if(r){e.updateId(o);n.append(e.div)}else e=e.clone(n,o);s.push(e);continue}l===e&&(t=o);const d=a[l-1];s.push(d);d.updateId(o);d.checkbox&&(d.checkbox.checked=!1);n.append(d.div)}this.container.replaceChildren(n);return t}function _onStartDragging(e){pdf_thumbnail_viewer_classPrivateFieldSet(mf,this,this.scrollableContainer.scrollTop);pdf_thumbnail_viewer_classPrivateFieldSet(gf,this,pdf_thumbnail_viewer_classPrivateFieldGet(mf,this)+this.scrollableContainer.clientHeight);pdf_thumbnail_viewer_classPrivateFieldSet(Jm,this,new AbortController);this.container.classList.add("isDragging");pdf_thumbnail_viewer_classPrivateFieldGet(jf,this)?.classList.add("hidden");const t=parseInt(e.getAttribute("page-number"),10);pdf_thumbnail_viewer_classPrivateFieldSet(nf,this,t-1);if(!pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)?.has(t)){pdf_thumbnail_viewer_classPrivateFieldSet(pf,this,t);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_selectPage).call(this,t,!0)}for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)){const i=this._thumbnails[e-1],a=i.placeholder=document.createElement("div");a.classList.add("thumbnailImageContainer","placeholder");const{div:s,imageContainer:n}=i;s.classList.add("isDragging");a.style.height=getComputedStyle(n).height;n.after(a);if(e!==t){n.classList.add("hidden");continue}if(1===pdf_thumbnail_viewer_classPrivateFieldGet(rf,this).size){n.classList.add("draggingThumbnail");pdf_thumbnail_viewer_classPrivateFieldSet(af,this,n);continue}const r=pdf_thumbnail_viewer_classPrivateFieldSet(af,this,document.createElement("div"));r.classList.add("draggingThumbnail","thumbnailImageContainer","multiple");r.style.height=getComputedStyle(n).height;n.replaceWith(r);n.classList.remove("thumbnailImageContainer");r.append(n);r.setAttribute("data-multiple-count",pdf_thumbnail_viewer_classPrivateFieldGet(rf,this).size)}}function _onStopDragging(e=!1){const t=pdf_thumbnail_viewer_classPrivateFieldGet(af,this);pdf_thumbnail_viewer_classPrivateFieldSet(af,this,null);const i=pdf_thumbnail_viewer_classPrivateFieldGet(nf,this);pdf_thumbnail_viewer_classPrivateFieldSet(nf,this,NaN);pdf_thumbnail_viewer_classPrivateFieldGet(_f,this)?.remove();pdf_thumbnail_viewer_classPrivateFieldSet(_f,this,null);pdf_thumbnail_viewer_classPrivateFieldGet(Jm,this).abort();pdf_thumbnail_viewer_classPrivateFieldSet(Jm,this,null);pdf_thumbnail_viewer_classPrivateFieldGet(jf,this)?.classList.remove("hidden");this.container.classList.remove("isDragging");for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)){const t=this._thumbnails[e-1],{div:i,placeholder:a,imageContainer:s}=t;a.remove();s.classList.remove("draggingThumbnail","hidden");i.classList.remove("isDragging")}if(t.classList.contains("multiple")){const e=t.firstElementChild;t.replaceWith(e);e.classList.add("thumbnailImageContainer")}else t.style.translate="";const a=pdf_thumbnail_viewer_classPrivateFieldGet(rf,this);if(!isNaN(i)&&e&&(1!==a.size||!a.has(i+1)&&!a.has(i+2))){this._thumbnails[this._currentPageNumber-1]?.toggleCurrent(!1);this._currentPageNumber=-1;const e=i+1,t=Array.from(a).sort((e,t)=>e-t),s=pdf_thumbnail_viewer_classPrivateFieldGet(ff,this),n=isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(pf,this))?t[0]:pdf_thumbnail_viewer_classPrivateFieldGet(pf,this);s.movePages(a,t,e);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateCurrentPage).call(this,pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateThumbnails).call(this,n));pdf_thumbnail_viewer_classPrivateFieldSet(sf,this,null);a.clear();pdf_thumbnail_viewer_classPrivateFieldSet(pf,this,NaN);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateStatus).call(this,"select");pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"move"});this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:s,type:"move"})}if(!isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(pf,this))){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_selectPage).call(this,pdf_thumbnail_viewer_classPrivateFieldGet(pf,this),!1);pdf_thumbnail_viewer_classPrivateFieldSet(pf,this,NaN)}}function _clearSelection(){for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(rf,this))this._thumbnails[e-1].toggleSelected(!1);pdf_thumbnail_viewer_classPrivateFieldGet(rf,this).clear()}function _updateCurrentPage(e,t=!1){setTimeout(()=>{this.forceRendering();const i=e||1;this.linkService.goToPage(i);const a=this._thumbnails[i-1];!t&&this.container.contains(document.activeElement)||a.imageContainer.focus()},0)}function _undo(){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateStatus).call(this,"select");if(pdf_thumbnail_viewer_classPrivateFieldGet(bf,this)){pdf_thumbnail_viewer_classPrivateFieldSet(bf,this,null);pdf_thumbnail_viewer_classPrivateFieldGet(ff,this).cancelCopy();pdf_thumbnail_viewer_assertClassBrand(Vf,this,_togglePasteMode).call(this,!1);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:pdf_thumbnail_viewer_classPrivateFieldGet(ff,this),type:"cancelCopy"})}pdf_thumbnail_viewer_classPrivateFieldSet(kf,this,!1);if(pdf_thumbnail_viewer_classPrivateFieldGet(yf,this)){const e=this._thumbnails[this._currentPageNumber-1];e?.toggleCurrent(!1);const t=document.createDocumentFragment();for(let e=1,i=pdf_thumbnail_viewer_classPrivateFieldGet(yf,this).length;e<=i;e++){const i=pdf_thumbnail_viewer_classPrivateFieldGet(yf,this)[e-1];i.updateId(e);i.checkbox&&(i.checkbox.checked=!1);t.append(i.div)}this.container.replaceChildren(t);this._thumbnails=pdf_thumbnail_viewer_classPrivateFieldGet(yf,this);pdf_thumbnail_viewer_classPrivateFieldSet(yf,this,null);const i=e?this._thumbnails.indexOf(e):-1;this._currentPageNumber=i+1;e?.toggleCurrent(-1!==i);pdf_thumbnail_viewer_classPrivateFieldGet(ff,this).cancelDelete();this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:pdf_thumbnail_viewer_classPrivateFieldGet(ff,this),type:"cancelDelete"})}}function _dismissUndo(e){pdf_thumbnail_viewer_classPrivateFieldSet(bf,this,null);if(pdf_thumbnail_viewer_classPrivateFieldGet(Sf,this)){if(pdf_thumbnail_viewer_classPrivateFieldGet(yf,this)){for(const e of pdf_thumbnail_viewer_classPrivateFieldGet(Sf,this))pdf_thumbnail_viewer_classPrivateFieldGet(yf,this)[e-1].destroy();pdf_thumbnail_viewer_classPrivateFieldSet(yf,this,null)}pdf_thumbnail_viewer_classPrivateFieldSet(Sf,this,null)}pdf_thumbnail_viewer_classPrivateFieldSet(kf,this,!1);e&&pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateStatus).call(this,"select");pdf_thumbnail_viewer_assertClassBrand(Vf,this,_togglePasteMode).call(this,!1);pdf_thumbnail_viewer_classPrivateFieldGet(ff,this).cleanSavedData();this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:pdf_thumbnail_viewer_classPrivateFieldGet(ff,this),type:"cleanSavedData"})}function _canDelete(){const e=pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)?.size||0;return e>0&&e<this._thumbnails.length}function _toggleBar(e,t,i){pdf_thumbnail_viewer_classPrivateFieldGet(Mf,this).classList.toggle("hidden","status"!==e);pdf_thumbnail_viewer_classPrivateFieldGet(Rf,this).container.classList.toggle("hidden","waiting"!==e);pdf_thumbnail_viewer_classPrivateFieldGet(Tf,this).classList.toggle("hidden","undo"!==e);pdf_thumbnail_viewer_classPrivateFieldSet(Wf,this,"undo"===e);switch(e){case"waiting":pdf_thumbnail_viewer_classPrivateFieldGet(Rf,this).label.setAttribute("data-l10n-id",t);break;case"undo":pdf_thumbnail_viewer_classPrivateFieldGet(Df,this).setAttribute("data-l10n-id",t);i&&pdf_thumbnail_viewer_classPrivateFieldGet(Df,this).setAttribute("data-l10n-args",JSON.stringify(i));break;case"status":i?pdf_thumbnail_viewer_classPrivateFieldGet(Bf,this).setAttribute("data-l10n-args",JSON.stringify(i)):pdf_thumbnail_viewer_classPrivateFieldGet(Bf,this).removeAttribute("data-l10n-args");pdf_thumbnail_viewer_classPrivateFieldGet(jf,this)?.classList.toggle("hidden",!!i);pdf_thumbnail_viewer_classPrivateFieldGet(If,this).classList.toggle("hidden",!i)}}function _togglePasteMode(e){pdf_thumbnail_viewer_classPrivateFieldSet(Of,this,e);if(e){this.container.classList.add("pasteMode");for(const e of this._thumbnails)e.addPasteButton(pdf_thumbnail_viewer_classPrivateFieldGet(xf,this))}else{this.container.classList.remove("pasteMode");for(const e of this._thumbnails)e.removePasteButton()}}function pdf_thumbnail_viewer_reportTelemetry(e){this.eventBus.dispatch("reporttelemetry",{source:this,details:{type:"pageOrganization",data:e}})}function _saveExtractedPages(){pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"exportSelected"});this.eventBus.dispatch("saveextractedpages",{source:this,data:pdf_thumbnail_viewer_classPrivateFieldGet(ff,this).extractPages(pdf_thumbnail_viewer_classPrivateFieldGet(rf,this))});pdf_thumbnail_viewer_assertClassBrand(Vf,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateStatus).call(this,"select")}function _copyPages(e=!0){if(!pdf_thumbnail_viewer_classPrivateFieldGet(kf,this)){pdf_thumbnail_viewer_classPrivateFieldSet(yf,this,null);pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"copy"})}pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateStatus).call(this,pdf_thumbnail_viewer_classPrivateFieldGet(kf,this)?"cut":"copy");const t=pdf_thumbnail_viewer_classPrivateFieldSet(Cf,this,Uint32Array.from(pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)).sort((e,t)=>e-t)),i=pdf_thumbnail_viewer_classPrivateFieldGet(ff,this);i.copyPages(t);pdf_thumbnail_viewer_classPrivateFieldSet(bf,this,new Map);for(const e of t)pdf_thumbnail_viewer_classPrivateFieldGet(bf,this).set(e,this._thumbnails[e-1]);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:i,pageNumbers:t,type:"copy"});e&&pdf_thumbnail_viewer_assertClassBrand(Vf,this,_clearSelection).call(this);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_togglePasteMode).call(this,!0);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleMenuEntries).call(this,!1)}function _cutPages(){if(pdf_thumbnail_viewer_assertClassBrand(Vf,this,_canDelete).call(this)){pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"cut"});pdf_thumbnail_viewer_classPrivateFieldSet(kf,this,!0);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_copyPages).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_deletePages).call(this,"cut")}}function _pastePages(e){pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"paste"});const t=pdf_thumbnail_viewer_classPrivateFieldGet(ff,this),i=pdf_thumbnail_viewer_classPrivateFieldGet(Cf,this).includes(this._currentPageNumber)?0:this._currentPageNumber;t.pastePages(e);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateThumbnails).call(this,i);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateCurrentPage).call(this,e+1,!0);pdf_thumbnail_viewer_classPrivateFieldSet(sf,this,null);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:t,hasBeenCut:pdf_thumbnail_viewer_classPrivateFieldGet(kf,this),type:"paste"});pdf_thumbnail_viewer_classPrivateFieldSet(bf,this,null);pdf_thumbnail_viewer_classPrivateFieldSet(kf,this,!1);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_togglePasteMode).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleMenuEntries).call(this,!1);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateStatus).call(this,"select")}function _deletePages(e="delete"){if(!pdf_thumbnail_viewer_assertClassBrand(Vf,this,_canDelete).call(this))return;const t=pdf_thumbnail_viewer_classPrivateFieldGet(rf,this);if("delete"===e){pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_reportTelemetry).call(this,{action:"delete"});pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateStatus).call(this,"delete")}const i=pdf_thumbnail_viewer_classPrivateFieldGet(ff,this),a=t.has(this._currentPageNumber)?0:this._currentPageNumber,s=pdf_thumbnail_viewer_classPrivateFieldSet(Sf,this,Uint32Array.from(t).sort((e,t)=>e-t));i.deletePages(s);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateCurrentPage).call(this,pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateThumbnails).call(this,a));pdf_thumbnail_viewer_classPrivateFieldSet(sf,this,null);t.clear();pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateMenuEntries).call(this);this.eventBus.dispatch("pagesedited",{source:this,pagesMapper:i,pageNumbers:s,type:e})}function _updateMenuEntries(){if(!pdf_thumbnail_viewer_classPrivateFieldGet(vf,this))return;const e=pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)?.size||0;pdf_thumbnail_viewer_classPrivateFieldGet(vf,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(wf,this).disabled=!e;pdf_thumbnail_viewer_classPrivateFieldGet(Pf,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(Ff,this).disabled=!pdf_thumbnail_viewer_assertClassBrand(Vf,this,_canDelete).call(this)}function _toggleMenuEntries(e){pdf_thumbnail_viewer_classPrivateFieldGet(vf,this)&&(pdf_thumbnail_viewer_classPrivateFieldGet(vf,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(Pf,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(wf,this).disabled=pdf_thumbnail_viewer_classPrivateFieldGet(Ff,this).disabled=!e)}function _updateStatus(e){if(!pdf_thumbnail_viewer_classPrivateFieldGet(Mf,this)||!pdf_thumbnail_viewer_classPrivateFieldGet(Tf,this))return;const t=pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)?.size||0;if("select"===e){pdf_thumbnail_viewer_classPrivateFieldGet(Bf,this).setAttribute("data-l10n-id",t?"pdfjs-views-manager-pages-status-action-label":"pdfjs-views-manager-pages-status-none-action-label");pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleBar).call(this,"status","",t?{count:t}:null);return}let i;switch(e){case"copy":i="pdfjs-views-manager-pages-status-undo-copy-label";break;case"cut":i="pdfjs-views-manager-status-undo-cut-label";break;case"delete":i="pdfjs-views-manager-pages-status-undo-delete-label"}pdf_thumbnail_viewer_assertClassBrand(Vf,this,_toggleBar).call(this,"undo",i,{count:t});const a="copy"===e;pdf_thumbnail_viewer_classPrivateFieldGet(Lf,this).firstElementChild.setAttribute("data-l10n-id",a?"pdfjs-views-manager-status-done-button-label":"pdfjs-views-manager-status-undo-button-label");pdf_thumbnail_viewer_classPrivateFieldGet(Nf,this).classList.toggle("hidden",a)}function _moveDraggedContainer(e,t){pdf_thumbnail_viewer_classPrivateFieldGet(Ef,this)&&(e=0);(pdf_thumbnail_viewer_classPrivateFieldGet(of,this)+e<0||pdf_thumbnail_viewer_classPrivateFieldGet(of,this)+pdf_thumbnail_viewer_classPrivateFieldGet(df,this)+e>pdf_thumbnail_viewer_classPrivateFieldGet(Af,this))&&(e=0);(pdf_thumbnail_viewer_classPrivateFieldGet(lf,this)+t<0||pdf_thumbnail_viewer_classPrivateFieldGet(lf,this)+pdf_thumbnail_viewer_classPrivateFieldGet(cf,this)+t>pdf_thumbnail_viewer_classPrivateFieldGet(Gf,this))&&(t=0);pdf_thumbnail_viewer_classPrivateFieldSet(of,this,pdf_thumbnail_viewer_classPrivateFieldGet(of,this)+e);pdf_thumbnail_viewer_classPrivateFieldSet(lf,this,pdf_thumbnail_viewer_classPrivateFieldGet(lf,this)+t);pdf_thumbnail_viewer_classPrivateFieldSet(hf,this,pdf_thumbnail_viewer_classPrivateFieldGet(hf,this)+e);pdf_thumbnail_viewer_classPrivateFieldSet(uf,this,pdf_thumbnail_viewer_classPrivateFieldGet(uf,this)+t);pdf_thumbnail_viewer_classPrivateFieldGet(af,this).style.translate=`${pdf_thumbnail_viewer_classPrivateFieldGet(hf,this)}px ${pdf_thumbnail_viewer_classPrivateFieldGet(uf,this)}px`;pdf_thumbnail_viewer_classPrivateFieldGet(lf,this)+pdf_thumbnail_viewer_classPrivateFieldGet(cf,this)>pdf_thumbnail_viewer_classPrivateFieldGet(gf,this)?this.scrollableContainer.scrollTop=Math.min(this.scrollableContainer.scrollTop+20,pdf_thumbnail_viewer_classPrivateFieldGet(Gf,this)):pdf_thumbnail_viewer_classPrivateFieldGet(lf,this)<pdf_thumbnail_viewer_classPrivateFieldGet(mf,this)&&(this.scrollableContainer.scrollTop=Math.max(this.scrollableContainer.scrollTop-20,0));const i=pdf_thumbnail_viewer_assertClassBrand(Vf,this,_findClosestThumbnail).call(this,pdf_thumbnail_viewer_classPrivateFieldGet(of,this)+pdf_thumbnail_viewer_classPrivateFieldGet(df,this)/2,pdf_thumbnail_viewer_classPrivateFieldGet(lf,this)+pdf_thumbnail_viewer_classPrivateFieldGet(cf,this)/2);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_positionDragMarker).call(this,i)}function _positionDragMarker(e){if(!e)return;let t=pdf_thumbnail_viewer_classPrivateFieldGet(_f,this);if(!t){t=pdf_thumbnail_viewer_classPrivateFieldSet(_f,this,document.createElement("div"));t.className="dragMarker";this.container.firstChild.before(t)}const[i,a]=e,s=t.style,{bbox:n,x:r}=pdf_thumbnail_viewer_classPrivateFieldGet(sf,this);let o,l,d,c;if(i<0)if(1===r.length){l=n[1]-15;o=n[0];d=n[2]}else{l=n[1];o=n[0]-15;c=n[3]}else if(1===r.length){l=n[4*i+1]+n[4*i+3]+a;o=n[4*i];d=n[4*i+2]}else{l=n[4*i+1];o=n[4*i]+n[4*i+2]+a;c=n[4*i+3]}s.translate=`${o}px ${l}px`;s.width=d?`${d}px`:"";s.height=c?`${c}px`:""}function _computeThumbnailsPosition(){const e=[],t=[],i=[],a=new Float32Array(4*this._thumbnails.length);let s,n,r,o,l=-1/0,d=-1/0,c=-1;for(let o=0,h=this._thumbnails.length;o<h;o++){const{div:u}=this._thumbnails[o],{offsetTop:_,offsetLeft:p,offsetWidth:g,offsetHeight:m}=u;if(0===g)return;a[4*o]=p;a[4*o+1]=_;a[4*o+2]=g;a[4*o+3]=m;if(p>l){l=p+g/2;s??=l+g;e.push(l)}if(_>d){-1===c&&e.length>1&&(c=h%e.length);d=_+m/2;r??=d+m;t.push(d)}if(c>0&&o>=h-c){const e=p+g/2;i.push(e);n??=e+g}}o=e.length>1?(e[1]-s)/2:t.length>1?(t[1]-r)/2:15;pdf_thumbnail_viewer_classPrivateFieldSet(sf,this,{x:e,y:t,lastX:i,space:o,lastSpace:i.length?(i.at(-1)-n)/2:o,bbox:a});pdf_thumbnail_viewer_classPrivateFieldSet(Ef,this,1===e.length);({clientWidth:pdf_thumbnail_viewer_toSetter(pdf_thumbnail_viewer_classPrivateFieldSet,[Af,this])._,scrollHeight:pdf_thumbnail_viewer_toSetter(pdf_thumbnail_viewer_classPrivateFieldSet,[Gf,this])._}=this.scrollableContainer)}function pdf_thumbnail_viewer_addEventListeners(){this.eventBus.on("resize",({source:e})=>{e.thumbnailsView===this.container&&pdf_thumbnail_viewer_assertClassBrand(Vf,this,_computeThumbnailsPosition).call(this)},Nh);this.container.addEventListener("keydown",e=>{const{target:t}=e,i=t instanceof HTMLInputElement&&"checkbox"===t.type;switch(e.key){case"ArrowLeft":pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!1,!0,i);stopEvent(e);break;case"ArrowRight":pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!0,!0,i);stopEvent(e);break;case"ArrowDown":pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!0,!1,i);stopEvent(e);break;case"ArrowUp":pdf_thumbnail_viewer_assertClassBrand(Vf,this,pdf_thumbnail_viewer_goToNextItem).call(this,t,!1,!1,i);stopEvent(e);break;case"Home":pdf_thumbnail_viewer_assertClassBrand(Vf,this,_focusThumbnailElement).call(this,this._thumbnails[0],i);stopEvent(e);break;case"End":pdf_thumbnail_viewer_assertClassBrand(Vf,this,_focusThumbnailElement).call(this,this._thumbnails.at(-1),i);stopEvent(e);break;case"Enter":case" ":i||pdf_thumbnail_viewer_assertClassBrand(Vf,this,_goToPage).call(this,e);break;case"c":if(pdf_thumbnail_viewer_classPrivateFieldGet(Zm,this)&&(e.ctrlKey||e.metaKey)&&pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)?.size){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_copyPages).call(this);stopEvent(e)}break;case"x":if(pdf_thumbnail_viewer_classPrivateFieldGet(Zm,this)&&(e.ctrlKey||e.metaKey)&&pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)?.size){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_cutPages).call(this);stopEvent(e)}break;case"Delete":case"Backspace":if(pdf_thumbnail_viewer_classPrivateFieldGet(Zm,this)&&!pdf_thumbnail_viewer_classPrivateFieldGet(Of,this)&&pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)?.size){pdf_thumbnail_viewer_assertClassBrand(Vf,this,_deletePages).call(this);stopEvent(e)}}});this.container.addEventListener("click",e=>{const{target:t}=e;if(t instanceof HTMLInputElement){const e=parseInt(t.parentElement.getAttribute("page-number"),10);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_selectPage).call(this,e,t.checked);return}pdf_thumbnail_viewer_assertClassBrand(Vf,this,_goToPage).call(this,e)});pdf_thumbnail_viewer_assertClassBrand(Vf,this,_addDragListeners).call(this);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_addExternalFileDropListeners).call(this)}function _selectPage(e,t){pdf_thumbnail_viewer_classPrivateFieldGet(Wf,this)&&pdf_thumbnail_viewer_assertClassBrand(Vf,this,_dismissUndo).call(this,!1);const i=pdf_thumbnail_viewer_classPrivateFieldGet(rf,this)??pdf_thumbnail_viewer_classPrivateFieldSet(rf,this,new Set);t?i.add(e):i.delete(e);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateMenuEntries).call(this);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_updateStatus).call(this,"select")}function _addDragListeners(){(pdf_thumbnail_viewer_classPrivateFieldGet(Zm,this)||pdf_thumbnail_viewer_classPrivateFieldGet(Qm,this))&&this.container.addEventListener("pointerdown",e=>{const{target:t,clientX:i,clientY:a,pointerId:s}=e;if(0!==e.button||pdf_thumbnail_viewer_classPrivateFieldGet(Of,this)||1===this._thumbnails.length||!isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(nf,this))||!t.classList.contains("thumbnailImageContainer"))return;const n=t.parentElement,r=new AbortController,{signal:o}=r;let l=i,d=a,c=this.scrollableContainer.scrollTop;const h=_getScaleFactor.call($m,t);pdf_thumbnail_viewer_classPrivateFieldSet(uf,this,((h-1)*e.layerY+t.offsetTop)/h);pdf_thumbnail_viewer_classPrivateFieldGet(Ef,this)?pdf_thumbnail_viewer_classPrivateFieldSet(hf,this,t.offsetLeft+.5*(h-1)*t.offsetWidth/h):pdf_thumbnail_viewer_classPrivateFieldSet(hf,this,((h-1)*e.layerX+t.offsetLeft)/h);pdf_thumbnail_viewer_classPrivateFieldSet(of,this,n.offsetLeft+pdf_thumbnail_viewer_classPrivateFieldGet(hf,this));pdf_thumbnail_viewer_classPrivateFieldSet(lf,this,n.offsetTop+pdf_thumbnail_viewer_classPrivateFieldGet(uf,this));pdf_thumbnail_viewer_classPrivateFieldSet(df,this,t.offsetWidth/h);pdf_thumbnail_viewer_classPrivateFieldSet(cf,this,t.offsetHeight/h);this.container.addEventListener("pointermove",e=>{const{clientX:t,clientY:o,pointerId:h}=e;if(isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(nf,this))){if(h!==s||Math.abs(t-i)<=5&&Math.abs(o-a)<=5)return;pdf_thumbnail_viewer_assertClassBrand(Vf,this,_onStartDragging).call(this,n);const stopDragging=(e,t=!1)=>{pdf_thumbnail_viewer_assertClassBrand(Vf,this,_onStopDragging).call(this,t);r.abort()},{signal:e}=pdf_thumbnail_viewer_classPrivateFieldGet(Jm,this);window.addEventListener("touchmove",stopEvent,{passive:!1,signal:e});window.addEventListener("contextmenu",noContextMenu,{signal:e});this.scrollableContainer.addEventListener("scrollend",()=>{const{scrollableContainer:{clientHeight:e,scrollTop:t}}=this;pdf_thumbnail_viewer_classPrivateFieldSet(mf,this,t);pdf_thumbnail_viewer_classPrivateFieldSet(gf,this,t+e);const i=t-c;c=t;pdf_thumbnail_viewer_assertClassBrand(Vf,this,_moveDraggedContainer).call(this,0,i)},{passive:!0,signal:e});window.addEventListener("pointerup",t=>{if(t.pointerId===s){window.addEventListener("click",stopEvent,{capture:!0,once:!0,signal:e});stopEvent(t);stopDragging(t,!0)}},{signal:e});window.addEventListener("blur",stopDragging,{signal:e});window.addEventListener("pointercancel",stopDragging,{signal:e});window.addEventListener("wheel",stopEvent,{passive:!1,signal:e});window.addEventListener("keydown",e=>{"Escape"!==e.key||isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(nf,this))||stopDragging(e)},{signal:e})}const u=t-l,_=o-d;l=t;d=o;pdf_thumbnail_viewer_assertClassBrand(Vf,this,_moveDraggedContainer).call(this,u,_)},{passive:!0,signal:o});window.addEventListener("pointerup",({pointerId:e})=>{e===s&&r.abort()},{signal:o});window.addEventListener("dragstart",stopEvent,{capture:!0,signal:o})})}function _addExternalFileDropListeners(){if(!pdf_thumbnail_viewer_classPrivateFieldGet(Ym,this))return;const e=this.container,t=pdf_thumbnail_viewer_classPrivateFieldGet(ef,this);e.addEventListener("dragenter",e=>{if(!pdf_thumbnail_viewer_classPrivateFieldGet(tf,this)&&isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(nf,this))&&this._thumbnails.length&&(e=>{if(!e)return!1;for(const t of e.items)if("file"===t.kind&&("application/pdf"===t.type||t.type.startsWith("image/")))return!0;return!1})(e.dataTransfer)){e.preventDefault();e.stopPropagation();e.dataTransfer.dropEffect="copy";pdf_thumbnail_viewer_classPrivateFieldSet(tf,this,!0);this.container.classList.add("isDraggingFile");pdf_thumbnail_viewer_classPrivateFieldSet(sf,this,null);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_computeThumbnailsPosition).call(this);pdf_thumbnail_viewer_classPrivateFieldSet(nf,this,NaN)}},{signal:t});e.addEventListener("dragover",t=>{if(!pdf_thumbnail_viewer_classPrivateFieldGet(tf,this))return;t.preventDefault();t.stopPropagation();t.dataTransfer.dropEffect="copy";if(!pdf_thumbnail_viewer_classPrivateFieldGet(sf,this))return;const i=e.getBoundingClientRect(),a=t.clientX-i.left,s=t.clientY-i.top,n=pdf_thumbnail_viewer_assertClassBrand(Vf,this,_findClosestThumbnail).call(this,a,s);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_positionDragMarker).call(this,n)},{signal:t});e.addEventListener("dragleave",t=>{pdf_thumbnail_viewer_classPrivateFieldGet(tf,this)&&(t.relatedTarget&&e.contains(t.relatedTarget)||(({clientX:t,clientY:i})=>{const{left:a,right:s,top:n,bottom:r}=e.getBoundingClientRect();return t>=a&&t<s&&i>=n&&i<r})(t)||pdf_thumbnail_viewer_assertClassBrand(Vf,this,_endExternalFileDrag).call(this))},{signal:t});e.addEventListener("drop",t=>{if(!pdf_thumbnail_viewer_classPrivateFieldGet(tf,this))return;t.preventDefault();t.stopPropagation();const i=Array.from(t.dataTransfer.files??[]);if(isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(nf,this))&&pdf_thumbnail_viewer_classPrivateFieldGet(sf,this)){const i=e.getBoundingClientRect();pdf_thumbnail_viewer_assertClassBrand(Vf,this,_findClosestThumbnail).call(this,t.clientX-i.left,t.clientY-i.top)}const a=isNaN(pdf_thumbnail_viewer_classPrivateFieldGet(nf,this))?-1:pdf_thumbnail_viewer_classPrivateFieldGet(nf,this);pdf_thumbnail_viewer_assertClassBrand(Vf,this,_endExternalFileDrag).call(this);i.length&&pdf_thumbnail_viewer_assertClassBrand(Vf,this,_mergeFiles).call(this,i,a)},{signal:t})}function _endExternalFileDrag(){pdf_thumbnail_viewer_classPrivateFieldSet(tf,this,!1);this.container.classList.remove("isDraggingFile");pdf_thumbnail_viewer_classPrivateFieldGet(_f,this)?.remove();pdf_thumbnail_viewer_classPrivateFieldSet(_f,this,null);pdf_thumbnail_viewer_classPrivateFieldSet(nf,this,NaN)}function _goToPage(e){const t=e.target.closest(".thumbnailImageContainer");if(t){const i=parseInt(t.getAttribute("page-number"),10);this.linkService.goToPage(i);stopEvent(e)}}function _focusThumbnailElement(e,t){t&&e.checkbox?e.checkbox.focus():e.imageContainer.focus()}function pdf_thumbnail_viewer_goToNextItem(e,t,i,a=!1){let s=parseInt(e.parentElement.getAttribute("page-number"),10);isNaN(s)&&(s=this._currentPageNumber);const n=t?1:-1;let r;if(i){const e=MathClamp(s+n,1,this._thumbnails.length+1);r=this._thumbnails[e-1]}else{const e=this._thumbnails[s-1],{x:t,y:i}=e.div.getBoundingClientRect();let a;for(let e=s-1+n;e>=0&&e<this._thumbnails.length;e+=n){const s=this._thumbnails[e],{x:n,y:o}=s.div.getBoundingClientRect();a||o===i||(a=s);if(n===t){r=s;break}}r??=a}r&&pdf_thumbnail_viewer_assertClassBrand(Vf,this,_focusThumbnailElement).call(this,r,a)}function _findClosestThumbnail(e,t){pdf_thumbnail_viewer_classPrivateFieldGet(sf,this)||pdf_thumbnail_viewer_assertClassBrand(Vf,this,_computeThumbnailsPosition).call(this);const{x:i,y:a,lastX:s,space:n,lastSpace:r}=pdf_thumbnail_viewer_classPrivateFieldGet(sf,this),o=pdf_thumbnail_viewer_classPrivateFieldGet(nf,this);let l,d=o%i.length,c=Math.floor(o/i.length),h=c===a.length-1?s:i;if(a[c]<=t&&t<(a[c+1]??1/0)&&h[d]<=e&&e<(h[d+1]??1/0))return null;c=binarySearchFirstItem(a,e=>t<e);if(pdf_thumbnail_viewer_classPrivateFieldGet(Ef,this))l=c-1;else{if(c===a.length)c=a.length-1;else{c=Math.abs(a[c-1]-t)<Math.abs(a[c]-t)?c-1:c}h=c===a.length-1&&s.length>0?s:i;d=binarySearchFirstItem(h,t=>e<t)-1;if(c<0){d<=0&&(d=-1);c=0}l=MathClamp(c*i.length+d,-1,this._thumbnails.length-1)}if(l===o)return null;pdf_thumbnail_viewer_classPrivateFieldSet(nf,this,l);return[l,c===a.length-1&&s.length>0&&d>=0?r:n]}var Uf={_:0};class Page{constructor(e,t){this.state={angle:0,area:[],position:{x:0,y:0},hardAngle:0,hardDrawingAngle:0};this.createdDensity=t;this.nowDrawingDensity=this.createdDensity;this.render=e}setDensity(e){this.createdDensity=e;this.nowDrawingDensity=e}setDrawingDensity(e){this.nowDrawingDensity=e}setPosition(e){this.state.position=e}setAngle(e){this.state.angle=e}setArea(e){this.state.area=e}setHardDrawingAngle(e){this.state.hardDrawingAngle=e}setHardAngle(e){this.state.hardAngle=e;this.state.hardDrawingAngle=e}setOrientation(e){this.orientation=e}getDrawingDensity(){return this.nowDrawingDensity}getDensity(){return this.createdDensity}getHardAngle(){return this.state.hardAngle}}class PageCollection{constructor(e,t){this.pages=[];this.currentPageIndex=0;this.currentSpreadIndex=0;this.landscapeSpread=[];this.portraitSpread=[];this.render=t;this.app=e;this.currentPageIndex=0;this.isShowCover=this.app.getSettings().showCover}destroy(){this.pages=[]}createSpread(){this.landscapeSpread=[];this.portraitSpread=[];for(let e=0;e<this.pages.length;e++)this.portraitSpread.push([e]);let e=0;if(this.isShowCover){this.pages[0].setDensity("hard");this.landscapeSpread.push([e]);e++}for(let t=e;t<this.pages.length;t+=2)if(t<this.pages.length-1)this.landscapeSpread.push([t,t+1]);else{this.landscapeSpread.push([t]);this.pages[t].setDensity("hard")}}getSpread(){return"landscape"===this.render.getOrientation()?this.landscapeSpread:this.portraitSpread}getSpreadIndexByPage(e){const t=this.getSpread();for(let i=0;i<t.length;i++)if(e===t[i][0]||e===t[i][1])return i;return null}getPageCount(){return this.pages.length}getPages(){return this.pages}getPage(e){if(e>=0&&e<this.pages.length)return this.pages[e];throw new Error("Invalid page number")}nextBy(e){const t=this.pages.indexOf(e);return t<this.pages.length-1?this.pages[t+1]:null}prevBy(e){const t=this.pages.indexOf(e);return t>0?this.pages[t-1]:null}getFlippingPage(e){const t=this.currentSpreadIndex;if("portrait"===this.render.getOrientation())return 0===e?this.pages[t].newTemporaryCopy():this.pages[t-1];{const i=0===e?this.getSpread()[t+1]:this.getSpread()[t-1];return 1===i.length||0===e?this.pages[i[0]]:this.pages[i[1]]}}getBottomPage(e){const t=this.currentSpreadIndex;if("portrait"===this.render.getOrientation())return 0===e?this.pages[t+1]:this.pages[t-1];{const i=0===e?this.getSpread()[t+1]:this.getSpread()[t-1];return 1===i.length?this.pages[i[0]]:0===e?this.pages[i[1]]:this.pages[i[0]]}}showNext(){if(this.currentSpreadIndex<this.getSpread().length){this.currentSpreadIndex++;this.showSpread()}}showPrev(){if(this.currentSpreadIndex>0){this.currentSpreadIndex--;this.showSpread()}}getCurrentPageIndex(){return this.currentPageIndex}show(e=null){null===e&&(e=this.currentPageIndex);if(e<0||e>=this.pages.length)return;const t=this.getSpreadIndexByPage(e);if(null!==t){this.currentSpreadIndex=t;this.showSpread()}}getCurrentSpreadIndex(){return this.currentSpreadIndex}setCurrentSpreadIndex(e){if(!(e>=0&&e<this.getSpread().length))throw new Error("Invalid page");this.currentSpreadIndex=e}showSpread(){const e=this.getSpread()[this.currentSpreadIndex];if(2===e.length){this.render.setLeftPage(this.pages[e[0]]);this.render.setRightPage(this.pages[e[1]])}else if("landscape"===this.render.getOrientation())if(e[0]===this.pages.length-1){this.render.setLeftPage(this.pages[e[0]]);this.render.setRightPage(null)}else{this.render.setLeftPage(null);this.render.setRightPage(this.pages[e[0]])}else{this.render.setLeftPage(null);this.render.setRightPage(this.pages[e[0]])}this.currentPageIndex=e[0];this.app.updatePageIndex(this.currentPageIndex)}}class Helper{static GetDistanceBetweenTwoPoint(e,t){return null===e||null===t?1/0:Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}static GetSegmentLength(e){return Helper.GetDistanceBetweenTwoPoint(e[0],e[1])}static GetAngleBetweenTwoLine(e,t){const i=e[0].y-e[1].y,a=t[0].y-t[1].y,s=e[1].x-e[0].x,n=t[1].x-t[0].x;return Math.acos((i*a+s*n)/(Math.sqrt(i*i+s*s)*Math.sqrt(a*a+n*n)))}static PointInRect(e,t){return null===t?null:t.x>=e.left&&t.x<=e.width+e.left&&t.y>=e.top&&t.y<=e.top+e.height?t:null}static GetRotatedPoint(e,t,i){return{x:e.x*Math.cos(i)+e.y*Math.sin(i)+t.x,y:e.y*Math.cos(i)-e.x*Math.sin(i)+t.y}}static LimitPointToCircle(e,t,i){if(Helper.GetDistanceBetweenTwoPoint(e,i)<=t)return i;const a=e.x,s=e.y,n=i.x,r=i.y;let o=Math.sqrt(Math.pow(t,2)*Math.pow(a-n,2)/(Math.pow(a-n,2)+Math.pow(s-r,2)))+a;i.x<0&&(o*=-1);let l=(o-a)*(s-r)/(a-n)+s;a-n+s===0&&(l=t);return{x:o,y:l}}static GetIntersectBetweenTwoSegment(e,t,i){return Helper.PointInRect(e,Helper.GetIntersectBeetwenTwoLine(t,i))}static GetIntersectBeetwenTwoLine(e,t){const i=e[0].y-e[1].y,a=t[0].y-t[1].y,s=e[1].x-e[0].x,n=t[1].x-t[0].x,r=e[0].x*e[1].y-e[1].x*e[0].y,o=t[0].x*t[1].y-t[1].x*t[0].y,l=i*o-a*r,d=s*o-n*r,c=-(r*n-o*s)/(i*n-a*s),h=-(i*o-a*r)/(i*n-a*s);if(isFinite(c)&&isFinite(h))return{x:c,y:h};if(Math.abs(l-d)<.1)throw new Error("Segment included");return null}static GetCordsFromTwoPoint(e,t){const i=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y),s=Math.max(i,a),n=[e];function getCord(e,t,i,a,s){return t>e?e+s*(i/a):t<e?e-s*(i/a):e}for(let r=1;r<=s;r+=1)n.push({x:getCord(e.x,t.x,i,s,r),y:getCord(e.y,t.y,a,s,r)});return n}}class HTMLPage extends Page{constructor(e,t,i){super(e,i);this.copiedElement=null;this.temporaryCopy=null;this.isLoad=!1;this.element=t;this.element.classList.add("stf__item");this.element.classList.add("--"+i)}newTemporaryCopy(){if("hard"===this.nowDrawingDensity)return this;if(null===this.temporaryCopy){this.copiedElement=this.element.cloneNode(!0);this.element.parentElement.appendChild(this.copiedElement);this.temporaryCopy=new HTMLPage(this.render,this.copiedElement,this.nowDrawingDensity)}return this.getTemporaryCopy()}getTemporaryCopy(){return this.temporaryCopy}hideTemporaryCopy(){if(null!==this.temporaryCopy){this.copiedElement.remove();this.copiedElement=null;this.temporaryCopy=null}}draw(e){const t=e||this.nowDrawingDensity,i=this.render.convertToGlobal(this.state.position),a=this.render.getRect().pageWidth,s=this.render.getRect().height;this.element.classList.remove("--simple");const n=`\n position: absolute;\n display: block;\n z-index: ${this.element.style.zIndex};\n left: 0;\n top: 0;\n width: ${a}px;\n height: ${s}px;\n `;"hard"===t?this.drawHard(n):this.drawSoft(i,n)}drawHard(e=""){const t=this.render.getRect().left+this.render.getRect().width/2,i=this.state.hardDrawingAngle,a=e+"\n backface-visibility: hidden;\n -webkit-backface-visibility: hidden;\n clip-path: none;\n -webkit-clip-path: none;\n "+(0===this.orientation?`transform-origin: ${this.render.getRect().pageWidth}px 0;\n transform: translate3d(0, 0, 0) rotateY(${i}deg);`:`transform-origin: 0 0;\n transform: translate3d(${t}px, 0, 0) rotateY(${i}deg);`);this.element.style.cssText=a}drawSoft(e,t=""){let i="polygon( ";for(const e of this.state.area)if(null!==e){let t=1===this.render.getDirection()?{x:-e.x+this.state.position.x,y:e.y-this.state.position.y}:{x:e.x-this.state.position.x,y:e.y-this.state.position.y};t=Helper.GetRotatedPoint(t,{x:0,y:0},this.state.angle);i+=t.x+"px "+t.y+"px, "}i=i.slice(0,-2);i+=")";const a=t+`transform-origin: 0 0; clip-path: ${i}; -webkit-clip-path: ${i};`+(this.render.isSafari()&&0===this.state.angle?`transform: translate(${e.x}px, ${e.y}px);`:`transform: translate3d(${e.x}px, ${e.y}px, 0) rotate(${this.state.angle}rad);`);this.element.style.cssText=a}simpleDraw(e){const t=this.render.getRect(),i=t.pageWidth,a=t.height,s=1===e?t.left+t.pageWidth:t.left,n=t.top;this.element.classList.add("--simple");this.element.style.cssText=`\n position: absolute;\n display: block;\n height: ${a}px;\n left: ${s}px;\n top: ${n}px;\n width: ${i}px;\n z-index: ${this.render.getSettings().startZIndex+1};`}getElement(){return this.element}load(){this.isLoad=!0}setOrientation(e){super.setOrientation(e);this.element.classList.remove("--left","--right");this.element.classList.add(1===e?"--right":"--left")}setDrawingDensity(e){this.element.classList.remove("--soft","--hard");this.element.classList.add("--"+e);super.setDrawingDensity(e)}}class HTMLPageCollection extends PageCollection{constructor(e,t,i,a){super(e,t);this.element=i;this.pagesElement=a}load(){for(const e of this.pagesElement){const t=new HTMLPage(this.render,e,"hard"===e.dataset.density?"hard":"soft");t.load();this.pages.push(t)}this.createSpread()}}class FlipCalculation{constructor(e,t,i,a){this.direction=e;this.corner=t;this.topIntersectPoint=null;this.sideIntersectPoint=null;this.bottomIntersectPoint=null;this.pageWidth=parseInt(i,10);this.pageHeight=parseInt(a,10)}calc(e){try{this.position=this.calcAngleAndPosition(e);this.calculateIntersectPoint(this.position);return!0}catch(e){return!1}}getFlippingClipArea(){const e=[];let t=!1;e.push(this.rect.topLeft);e.push(this.topIntersectPoint);if(null===this.sideIntersectPoint)t=!0;else{e.push(this.sideIntersectPoint);null===this.bottomIntersectPoint&&(t=!1)}e.push(this.bottomIntersectPoint);(t||"bottom"===this.corner)&&e.push(this.rect.bottomLeft);return e}getBottomClipArea(){const e=[];e.push(this.topIntersectPoint);if("top"===this.corner)e.push({x:this.pageWidth,y:0});else{null!==this.topIntersectPoint&&e.push({x:this.pageWidth,y:0});e.push({x:this.pageWidth,y:this.pageHeight})}null!==this.sideIntersectPoint?Helper.GetDistanceBetweenTwoPoint(this.sideIntersectPoint,this.topIntersectPoint)>=10&&e.push(this.sideIntersectPoint):"top"===this.corner&&e.push({x:this.pageWidth,y:this.pageHeight});e.push(this.bottomIntersectPoint);e.push(this.topIntersectPoint);return e}getAngle(){return 0===this.direction?-this.angle:this.angle}getRect(){return this.rect}getPosition(){return this.position}getActiveCorner(){return 0===this.direction?this.rect.topLeft:this.rect.topRight}getDirection(){return this.direction}getFlippingProgress(){return Math.abs((this.position.x-this.pageWidth)/(2*this.pageWidth)*100)}getCorner(){return this.corner}getBottomPagePosition(){return 1===this.direction?{x:this.pageWidth,y:0}:{x:0,y:0}}getShadowStartPoint(){return"top"===this.corner?this.topIntersectPoint:null!==this.sideIntersectPoint?this.sideIntersectPoint:this.topIntersectPoint}getShadowAngle(){const e=Helper.GetAngleBetweenTwoLine(this.getSegmentToShadowLine(),[{x:0,y:0},{x:this.pageWidth,y:0}]);return 0===this.direction?e:Math.PI-e}calcAngleAndPosition(e){let t=e;this.updateAngleAndGeometry(t);t="top"===this.corner?this.checkPositionAtCenterLine(t,{x:0,y:0},{x:0,y:this.pageHeight}):this.checkPositionAtCenterLine(t,{x:0,y:this.pageHeight},{x:0,y:0});if(Math.abs(t.x-this.pageWidth)<1&&Math.abs(t.y)<1)throw new Error("Point is too small");return t}updateAngleAndGeometry(e){this.angle=this.calculateAngle(e);this.rect=this.getPageRect(e)}calculateAngle(e){const t=this.pageWidth-e.x+1,i="bottom"===this.corner?this.pageHeight-e.y:e.y;let a=2*Math.acos(t/Math.sqrt(i*i+t*t));i<0&&(a=-a);const s=Math.PI-a;if(!isFinite(a)||s>=0&&s<.003)throw new Error("The G point is too small");"bottom"===this.corner&&(a=-a);return a}getPageRect(e){return"top"===this.corner?this.getRectFromBasePoint([{x:0,y:0},{x:this.pageWidth,y:0},{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}],e):this.getRectFromBasePoint([{x:0,y:-this.pageHeight},{x:this.pageWidth,y:-this.pageHeight},{x:0,y:0},{x:this.pageWidth,y:0}],e)}getRectFromBasePoint(e,t){return{topLeft:this.getRotatedPoint(e[0],t),topRight:this.getRotatedPoint(e[1],t),bottomLeft:this.getRotatedPoint(e[2],t),bottomRight:this.getRotatedPoint(e[3],t)}}getRotatedPoint(e,t){return{x:e.x*Math.cos(this.angle)+e.y*Math.sin(this.angle)+t.x,y:e.y*Math.cos(this.angle)-e.x*Math.sin(this.angle)+t.y}}calculateIntersectPoint(e){const t={left:-1,top:-1,width:this.pageWidth+2,height:this.pageHeight+2};if("top"===this.corner){this.topIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[e,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]);this.sideIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[e,this.rect.bottomLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]);this.bottomIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])}else{this.topIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[this.rect.topLeft,this.rect.topRight],[{x:0,y:0},{x:this.pageWidth,y:0}]);this.sideIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[e,this.rect.topLeft],[{x:this.pageWidth,y:0},{x:this.pageWidth,y:this.pageHeight}]);this.bottomIntersectPoint=Helper.GetIntersectBetweenTwoSegment(t,[this.rect.bottomLeft,this.rect.bottomRight],[{x:0,y:this.pageHeight},{x:this.pageWidth,y:this.pageHeight}])}}checkPositionAtCenterLine(e,t,i){let a=e;const s=Helper.LimitPointToCircle(t,this.pageWidth,a);if(a!==s){a=s;this.updateAngleAndGeometry(a)}const n=Math.sqrt(Math.pow(this.pageWidth,2)+Math.pow(this.pageHeight,2));let r=this.rect.bottomRight,o=this.rect.topLeft;if("bottom"===this.corner){r=this.rect.topRight;o=this.rect.bottomLeft}if(r.x<=0){const e=Helper.LimitPointToCircle(i,n,o);if(e!==a){a=e;this.updateAngleAndGeometry(a)}}return a}getSegmentToShadowLine(){const e=this.getShadowStartPoint();return[e,e!==this.sideIntersectPoint&&null!==this.sideIntersectPoint?this.sideIntersectPoint:this.bottomIntersectPoint]}}class Flip{constructor(e,t){this.flippingPage=null;this.bottomPage=null;this.calc=null;this.state="read";this.render=e;this.app=t}fold(e){this.setState("user_fold");null===this.calc&&this.start(e);this.do(this.render.convertToPage(e))}flip(e){if(this.app.getSettings().disableFlipByClick&&!this.isPointOnCorners(e))return;null!==this.calc&&this.render.finishAnimation();if(!this.start(e))return;const t=this.getBoundsRect();this.setState("flipping");const i=t.height/10,a="bottom"===this.calc.getCorner()?t.height-i:i,s="bottom"===this.calc.getCorner()?t.height:0;this.calc.calc({x:t.pageWidth-i,y:a});this.animateFlippingTo({x:t.pageWidth-i,y:a},{x:-t.pageWidth,y:s},!0)}start(e){this.reset();const t=this.render.convertToBook(e),i=this.getBoundsRect(),a=this.getDirectionByPoint(t),s=t.y>=i.height/2?"bottom":"top";if(!this.checkDirection(a))return!1;try{this.flippingPage=this.app.getPageCollection().getFlippingPage(a);this.bottomPage=this.app.getPageCollection().getBottomPage(a);if("landscape"===this.render.getOrientation())if(1===a){const e=this.app.getPageCollection().nextBy(this.flippingPage);if(null!==e&&this.flippingPage.getDensity()!==e.getDensity()){this.flippingPage.setDrawingDensity("hard");e.setDrawingDensity("hard")}}else{const e=this.app.getPageCollection().prevBy(this.flippingPage);if(null!==e&&this.flippingPage.getDensity()!==e.getDensity()){this.flippingPage.setDrawingDensity("hard");e.setDrawingDensity("hard")}}this.render.setDirection(a);this.calc=new FlipCalculation(a,s,i.pageWidth.toString(10),i.height.toString(10));return!0}catch(e){return!1}}do(e){if(null!==this.calc&&this.calc.calc(e)){const e=this.calc.getFlippingProgress();this.bottomPage.setArea(this.calc.getBottomClipArea());this.bottomPage.setPosition(this.calc.getBottomPagePosition());this.bottomPage.setAngle(0);this.bottomPage.setHardAngle(0);this.flippingPage.setArea(this.calc.getFlippingClipArea());this.flippingPage.setPosition(this.calc.getActiveCorner());this.flippingPage.setAngle(this.calc.getAngle());0===this.calc.getDirection()?this.flippingPage.setHardAngle(90*(200-2*e)/100):this.flippingPage.setHardAngle(-90*(200-2*e)/100);this.render.setPageRect(this.calc.getRect());this.render.setBottomPage(this.bottomPage);this.render.setFlippingPage(this.flippingPage);this.render.setShadowData(this.calc.getShadowStartPoint(),this.calc.getShadowAngle(),e,this.calc.getDirection())}}flipToPage(e,t){const i=this.app.getPageCollection().getCurrentSpreadIndex(),a=this.app.getPageCollection().getSpreadIndexByPage(e);try{if(a>i){this.app.getPageCollection().setCurrentSpreadIndex(a-1);this.flipNext(t)}if(a<i){this.app.getPageCollection().setCurrentSpreadIndex(a+1);this.flipPrev(t)}}catch(e){}}flipNext(e){this.flip({x:this.render.getRect().left+2*this.render.getRect().pageWidth-10,y:"top"===e?1:this.render.getRect().height-2})}flipPrev(e){this.flip({x:10,y:"top"===e?1:this.render.getRect().height-2})}stopMove(){if(null===this.calc)return;const e=this.calc.getPosition(),t=this.getBoundsRect(),i="bottom"===this.calc.getCorner()?t.height:0;e.x<=0?this.animateFlippingTo(e,{x:-t.pageWidth,y:i},!0):this.animateFlippingTo(e,{x:t.pageWidth,y:i},!1)}showCorner(e){if(!this.checkState("read","fold_corner"))return;const t=this.getBoundsRect(),i=t.pageWidth;if(this.isPointOnCorners(e))if(null===this.calc){if(!this.start(e))return;this.setState("fold_corner");this.calc.calc({x:i-1,y:1});const a=50,s="bottom"===this.calc.getCorner()?t.height-1:1,n="bottom"===this.calc.getCorner()?t.height-a:a;this.animateFlippingTo({x:i-1,y:s},{x:i-a,y:n},!1,!1)}else this.do(this.render.convertToPage(e));else{this.setState("read");this.render.finishAnimation();this.stopMove()}}animateFlippingTo(e,t,i,a=!0){const s=Helper.GetCordsFromTwoPoint(e,t),n=[];for(const e of s)n.push(()=>this.do(e));const r=this.getAnimationDuration(s.length);this.render.startAnimation(n,r,()=>{if(this.calc){i&&(1===this.calc.getDirection()?this.app.turnToPrevPage():this.app.turnToNextPage());if(a){this.render.setBottomPage(null);this.render.setFlippingPage(null);this.render.clearShadow();this.setState("read");this.reset()}}})}getCalculation(){return this.calc}getState(){return this.state}setState(e){if(this.state!==e){this.app.updateState(e);this.state=e}}getDirectionByPoint(e){const t=this.getBoundsRect();if("portrait"===this.render.getOrientation()){if(e.x-t.pageWidth<=t.width/5)return 1}else if(e.x<t.width/2)return 1;return 0}getAnimationDuration(e){const t=this.app.getSettings().flippingTime;return e>=1e3?t:e/1e3*t}checkDirection(e){return 0===e?this.app.getCurrentPageIndex()<this.app.getPageCount()-1:this.app.getCurrentPageIndex()>=1}reset(){this.calc=null;this.flippingPage=null;this.bottomPage=null}getBoundsRect(){return this.render.getRect()}checkState(...e){for(const t of e)if(this.state===t)return!0;return!1}isPointOnCorners(e){const t=this.getBoundsRect(),i=t.pageWidth,a=Math.sqrt(Math.pow(i,2)+Math.pow(t.height,2))/5,s=this.render.convertToBook(e);return s.x>0&&s.y>0&&s.x<t.width&&s.y<t.height&&(s.x<a||s.x>t.width-a)&&(s.y<a||s.y>t.height-a)}}class Render{constructor(e,t){this.leftPage=null;this.rightPage=null;this.flippingPage=null;this.bottomPage=null;this.direction=null;this.orientation=null;this.shadow=null;this.animation=null;this.pageRect=null;this.boundsRect=null;this.timer=0;this.safari=!1;this.setting=t;this.app=e;const i=new RegExp("Version\\/[\\d\\.]+.*Safari/");this.safari=null!==i.exec(window.navigator.userAgent)}render(e){if(null!==this.animation){const t=Math.round((e-this.animation.startedAt)/this.animation.durationFrame);if(t<this.animation.frames.length)this.animation.frames[t]();else{this.animation.onAnimateEnd();this.animation=null}}this.timer=e;this.drawFrame()}start(){this.update();const loop=e=>{this.render(e);requestAnimationFrame(loop)};requestAnimationFrame(loop)}startAnimation(e,t,i){this.finishAnimation();this.animation={frames:e,duration:t,durationFrame:t/e.length,onAnimateEnd:i,startedAt:this.timer}}finishAnimation(){if(null!==this.animation){this.animation.frames[this.animation.frames.length-1]();null!==this.animation.onAnimateEnd&&this.animation.onAnimateEnd()}this.animation=null}update(){this.boundsRect=null;const e=this.calculateBoundsRect();if(this.orientation!==e){this.orientation=e;this.app.updateOrientation(e)}}calculateBoundsRect(){let e="landscape";const t=this.getBlockWidth(),i=t/2,a=this.getBlockHeight()/2,s=this.setting.width/this.setting.height;let n=this.setting.width,r=this.setting.height,o=i-n;if("stretch"===this.setting.size){t<2*this.setting.minWidth&&this.app.getSettings().usePortrait&&(e="portrait");n="portrait"===e?this.getBlockWidth():this.getBlockWidth()/2;n>this.setting.maxWidth&&(n=this.setting.maxWidth);r=n/s;if(r>this.getBlockHeight()){r=this.getBlockHeight();n=r*s}o="portrait"===e?i-n/2-n:i-n}else if(t<2*n&&this.app.getSettings().usePortrait){e="portrait";o=i-n/2-n}this.boundsRect={left:o,top:a-r/2,width:2*n,height:r,pageWidth:n};return e}setShadowData(e,t,i,a){if(!this.app.getSettings().drawShadow)return;const s=100*this.getSettings().maxShadowOpacity;this.shadow={pos:e,angle:t,width:3*this.getRect().pageWidth/4*i/100,opacity:(100-i)*s/100/100,direction:a,progress:2*i}}clearShadow(){this.shadow=null}getBlockWidth(){return this.app.getUI().getDistElement().offsetWidth}getBlockHeight(){return this.app.getUI().getDistElement().offsetHeight}getDirection(){return this.direction}getRect(){null===this.boundsRect&&this.calculateBoundsRect();return this.boundsRect}getSettings(){return this.app.getSettings()}getOrientation(){return this.orientation}setPageRect(e){this.pageRect=e}setDirection(e){this.direction=e}setRightPage(e){null!==e&&e.setOrientation(1);this.rightPage=e}setLeftPage(e){null!==e&&e.setOrientation(0);this.leftPage=e}setBottomPage(e){null!==e&&e.setOrientation(1===this.direction?0:1);this.bottomPage=e}setFlippingPage(e){null!==e&&e.setOrientation(0===this.direction&&"portrait"!==this.orientation?0:1);this.flippingPage=e}convertToBook(e){const t=this.getRect();return{x:e.x-t.left,y:e.y-t.top}}isSafari(){return this.safari}convertToPage(e,t){t||(t=this.direction);const i=this.getRect();return{x:0===t?e.x-i.left-i.width/2:i.width/2-e.x+i.left,y:e.y-i.top}}convertToGlobal(e,t){t||(t=this.direction);if(null==e)return null;const i=this.getRect();return{x:0===t?e.x+i.left+i.width/2:i.width/2-e.x+i.left,y:e.y+i.top}}convertRectToGlobal(e,t){t||(t=this.direction);return{topLeft:this.convertToGlobal(e.topLeft,t),topRight:this.convertToGlobal(e.topRight,t),bottomLeft:this.convertToGlobal(e.bottomLeft,t),bottomRight:this.convertToGlobal(e.bottomRight,t)}}}class UI{constructor(e,t,i){this.cspPolicyService=t.cspPolicyService;this.touchPoint=null;this.swipeTimeout=250;this.onResize=()=>{this.update()};this.onMouseDown=e=>{if(this.checkTarget(e.target)){if(!this.app.getSettings().enableFlipByDrag){this._clickStartPos=this.getMousePos(e.clientX,e.clientY);this._clickStartClientX=e.clientX;this._clickStartClientY=e.clientY;return}const t=this.getMousePos(e.clientX,e.clientY);this.app.startUserTouch(t);e.preventDefault()}};this.onTouchStart=e=>{if(this.checkTarget(e.target)){if(!this.app.getSettings().enableFlipByDrag)return;if(e.changedTouches.length>0){const t=e.changedTouches[0],i=this.getMousePos(t.clientX,t.clientY);this.touchPoint={point:i,time:Date.now()};setTimeout(()=>{null!==this.touchPoint&&this.app.startUserTouch(i)},this.swipeTimeout);this.app.getSettings().mobileScrollSupport||e.preventDefault()}}};this.onMouseUp=e=>{if(this._clickStartPos){const t=e.clientX-this._clickStartClientX,i=e.clientY-this._clickStartClientY;if(t*t+i*i<25){const e=this._clickStartPos;this.app.startUserTouch(e);this.app.userStop(e)}this._clickStartPos=null;return}const t=this.getMousePos(e.clientX,e.clientY);this.app.userStop(t)};this.onMouseMove=e=>{if(!this.app.getSettings().enableFlipByDrag)return;const t=this.getMousePos(e.clientX,e.clientY);this.app.userMove(t,!1)};this.onTouchMove=e=>{if(e.changedTouches.length>0){const t=e.changedTouches[0],i=this.getMousePos(t.clientX,t.clientY);if(this.app.getSettings().mobileScrollSupport){null!==this.touchPoint&&(Math.abs(this.touchPoint.point.x-i.x)>10||"read"!==this.app.getState())&&e.cancelable&&this.app.userMove(i,!0);"read"!==this.app.getState()&&e.preventDefault()}else this.app.userMove(i,!0)}};this.onTouchEnd=e=>{if(e.changedTouches.length>0){const t=e.changedTouches[0],i=this.getMousePos(t.clientX,t.clientY);let a=!1;if(null!==this.touchPoint){const e=i.x-this.touchPoint.point.x,t=Math.abs(i.y-this.touchPoint.point.y);if(Math.abs(e)>this.swipeDistance&&t<2*this.swipeDistance&&Date.now()-this.touchPoint.time<this.swipeTimeout){e>0?this.app.flipPrev(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom"):this.app.flipNext(this.touchPoint.point.y<this.app.getRender().getRect().height/2?"top":"bottom");a=!0}this.touchPoint=null}this.app.userStop(i,a)}};this.parentElement=e;e.classList.add("stf__parent");const a=this.cspPolicyService.createTrustedHTML('<div class="stf__wrapper"></div>');e.insertAdjacentHTML("afterbegin",a);this.wrapper=e.querySelector(".stf__wrapper");this.app=t;const s=this.app.getSettings().usePortrait?1:2;e.style.minWidth=i.minWidth*s+"px";e.style.minHeight=i.minHeight+"px";if("fixed"===i.size){e.style.minWidth=i.width*s+"px";e.style.minHeight=i.height+"px"}if(i.autoSize){e.style.width="100%";e.style.maxWidth=2*i.maxWidth+"px"}e.style.display="block";window.addEventListener("resize",this.onResize,!1);this.swipeDistance=i.swipeDistance}destroy(){this.app.getSettings().useMouseEvents&&this.removeHandlers();this.distElement.remove();this.wrapper.remove()}getDistElement(){return this.distElement}getWrapper(){return this.wrapper}setOrientationStyle(e){this.wrapper.classList.remove("--portrait","--landscape");if("portrait"===e){this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/this.app.getSettings().width*100+"%");this.wrapper.classList.add("--portrait")}else{this.app.getSettings().autoSize&&(this.wrapper.style.paddingBottom=this.app.getSettings().height/(2*this.app.getSettings().width)*100+"%");this.wrapper.classList.add("--landscape")}this.update()}removeHandlers(){window.removeEventListener("resize",this.onResize);this.distElement.removeEventListener("mousedown",this.onMouseDown);this.distElement.removeEventListener("touchstart",this.onTouchStart);window.removeEventListener("mousemove",this.onMouseMove);window.removeEventListener("touchmove",this.onTouchMove);window.removeEventListener("mouseup",this.onMouseUp);window.removeEventListener("touchend",this.onTouchEnd)}setHandlers(){window.addEventListener("resize",this.onResize,!1);if(this.app.getSettings().useMouseEvents){this.distElement.addEventListener("mousedown",this.onMouseDown);this.distElement.addEventListener("touchstart",this.onTouchStart);window.addEventListener("mousemove",this.onMouseMove);window.addEventListener("touchmove",this.onTouchMove,{passive:!this.app.getSettings().mobileScrollSupport});window.addEventListener("mouseup",this.onMouseUp);window.addEventListener("touchend",this.onTouchEnd)}}getMousePos(e,t){const i=this.distElement.getBoundingClientRect();return{x:e-i.left,y:t-i.top}}checkTarget(e){return!this.app.getSettings().clickEventForward||!["a","button"].includes(e.tagName.toLowerCase())}}class HTMLUI extends UI{constructor(e,t,i,a,s){super(e,t,i);this.cspPolicyService=s;const n=this.cspPolicyService.createTrustedHTML('<div class="stf__block"></div>');this.wrapper.insertAdjacentHTML("afterbegin",n);this.distElement=e.querySelector(".stf__block");this.items=a;for(const e of a)this.distElement.appendChild(e);this.setHandlers()}clear(){for(const e of this.items)this.parentElement.appendChild(e)}updateItems(e){this.removeHandlers();this.distElement.innerHTML="";for(const t of e)this.distElement.appendChild(t);this.items=e;this.setHandlers()}update(){this.app.getRender().update()}}class EventObject{constructor(){this.events=new Map}on(e,t){this.events.has(e)?this.events.get(e).push(t):this.events.set(e,[t]);return this}off(e){this.events.delete(e)}trigger(e,t,i=null){if(this.events.has(e))for(const a of this.events.get(e))a({data:i,object:t})}}class HTMLRender extends Render{constructor(e,t,i){super(e,t);this.outerShadow=null;this.innerShadow=null;this.hardShadow=null;this.hardInnerShadow=null;this.element=i;this.createShadows()}createShadows(){const e=this.app.cspPolicyService.createTrustedHTML('<div class="stf__outerShadow"></div>\n <div class="stf__innerShadow"></div>\n <div class="stf__hardShadow"></div>\n <div class="stf__hardInnerShadow"></div>');this.element.insertAdjacentHTML("beforeend",e);this.outerShadow=this.element.querySelector(".stf__outerShadow");this.innerShadow=this.element.querySelector(".stf__innerShadow");this.hardShadow=this.element.querySelector(".stf__hardShadow");this.hardInnerShadow=this.element.querySelector(".stf__hardInnerShadow")}clearShadow(){super.clearShadow();this.outerShadow.style.cssText="display: none";this.innerShadow.style.cssText="display: none";this.hardShadow.style.cssText="display: none";this.hardInnerShadow.style.cssText="display: none"}reload(){this.element.querySelector(".stf__outerShadow")||this.createShadows()}drawHardInnerShadow(){const e=this.getRect(),t=this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress;let i=(100-t)*(2.5*e.pageWidth)/100+20;i>e.pageWidth&&(i=e.pageWidth);let a=`\n display: block;\n z-index: ${(this.getSettings().startZIndex+5).toString(10)};\n width: ${i}px;\n height: ${e.height}px;\n background: linear-gradient(to right,\n rgba(0, 0, 0, ${this.shadow.opacity*t/100}) 5%,\n rgba(0, 0, 0, 0) 100%);\n left: ${e.left+e.width/2}px;\n transform-origin: 0 0;\n `;a+=0===this.getDirection()&&this.shadow.progress>100||1===this.getDirection()&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0);":"transform: translate3d(0, 0, 0) rotateY(180deg);";this.hardInnerShadow.style.cssText=a}drawHardOuterShadow(){const e=this.getRect();let t=(100-(this.shadow.progress>100?200-this.shadow.progress:this.shadow.progress))*(2.5*e.pageWidth)/100+20;t>e.pageWidth&&(t=e.pageWidth);let i=`\n display: block;\n z-index: ${(this.getSettings().startZIndex+4).toString(10)};\n width: ${t}px;\n height: ${e.height}px;\n background: linear-gradient(to left, rgba(0, 0, 0, ${this.shadow.opacity}) 5%, rgba(0, 0, 0, 0) 100%);\n left: ${e.left+e.width/2}px;\n transform-origin: 0 0;\n `;i+=0===this.getDirection()&&this.shadow.progress>100||1===this.getDirection()&&this.shadow.progress<=100?"transform: translate3d(0, 0, 0) rotateY(180deg);":"transform: translate3d(0, 0, 0);";this.hardShadow.style.cssText=i}drawInnerShadow(){const e=this.getRect(),t=3*this.shadow.width/4,i=0===this.getDirection()?t:0,a=0===this.getDirection()?"to left":"to right",s=this.convertToGlobal(this.shadow.pos),n=this.shadow.angle+3*Math.PI/2,r=[this.pageRect.topLeft,this.pageRect.topRight,this.pageRect.bottomRight,this.pageRect.bottomLeft];let o="polygon( ";for(const e of r){let t=1===this.getDirection()?{x:-e.x+this.shadow.pos.x,y:e.y-this.shadow.pos.y}:{x:e.x-this.shadow.pos.x,y:e.y-this.shadow.pos.y};t=Helper.GetRotatedPoint(t,{x:i,y:100},n);o+=t.x+"px "+t.y+"px, "}o=o.slice(0,-2);o+=")";const l=`\n display: block;\n z-index: ${(this.getSettings().startZIndex+10).toString(10)};\n width: ${t}px;\n height: ${2*e.height}px;\n background: linear-gradient(${a},\n rgba(0, 0, 0, ${this.shadow.opacity}) 5%,\n rgba(0, 0, 0, 0.05) 15%,\n rgba(0, 0, 0, ${this.shadow.opacity}) 35%,\n rgba(0, 0, 0, 0) 100%);\n transform-origin: ${i}px 100px;\n transform: translate3d(${s.x-i}px, ${s.y-100}px, 0) rotate(${n}rad);\n clip-path: ${o};\n -webkit-clip-path: ${o};\n `;this.innerShadow.style.cssText=l}drawOuterShadow(){const e=this.getRect(),t=this.convertToGlobal({x:this.shadow.pos.x,y:this.shadow.pos.y}),i=this.shadow.angle+3*Math.PI/2,a=1===this.getDirection()?this.shadow.width:0,s=0===this.getDirection()?"to right":"to left",n=[{x:0,y:0},{x:e.pageWidth,y:0},{x:e.pageWidth,y:e.height},{x:0,y:e.height}];let r="polygon( ";for(const e of n)if(null!==e){let t=1===this.getDirection()?{x:-e.x+this.shadow.pos.x,y:e.y-this.shadow.pos.y}:{x:e.x-this.shadow.pos.x,y:e.y-this.shadow.pos.y};t=Helper.GetRotatedPoint(t,{x:a,y:100},i);r+=t.x+"px "+t.y+"px, "}r=r.slice(0,-2);r+=")";const o=`\n display: block;\n z-index: ${(this.getSettings().startZIndex+10).toString(10)};\n width: ${this.shadow.width}px;\n height: ${2*e.height}px;\n background: linear-gradient(${s}, rgba(0, 0, 0, ${this.shadow.opacity}), rgba(0, 0, 0, 0));\n transform-origin: ${a}px 100px;\n transform: translate3d(${t.x-a}px, ${t.y-100}px, 0) rotate(${i}rad);\n clip-path: ${r};\n -webkit-clip-path: ${r};\n `;this.outerShadow.style.cssText=o}drawLeftPage(){if("portrait"!==this.orientation&&null!==this.leftPage)if(1===this.direction&&null!==this.flippingPage&&"hard"===this.flippingPage.getDrawingDensity()){if(this.flippingPage.getHardAngle()<-90){this.leftPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10);this.leftPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle());this.leftPage.draw(this.flippingPage.getDrawingDensity())}else this.leftPage.getElement().style.display="none"}else this.leftPage.simpleDraw(0)}drawRightPage(){if(null!==this.rightPage)if(0===this.direction&&null!==this.flippingPage&&"hard"===this.flippingPage.getDrawingDensity()){if(this.flippingPage.getHardAngle()>90){this.rightPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10);this.rightPage.setHardDrawingAngle(180+this.flippingPage.getHardAngle());this.rightPage.draw(this.flippingPage.getDrawingDensity())}else this.rightPage.getElement().style.display="none"}else this.rightPage.simpleDraw(1)}drawBottomPage(){if(null===this.bottomPage)return;const e=null!=this.flippingPage?this.flippingPage.getDrawingDensity():null;if("portrait"!==this.orientation||1!==this.direction){this.bottomPage.getElement().style.zIndex=(this.getSettings().startZIndex+3).toString(10);this.bottomPage.draw(e)}}drawFrame(){if(null!==this.flippingPage){if(this.flippingPage.getHardAngle()===this.lastAngle)return;this.lastAngle=this.flippingPage.getHardAngle()}else this.lastAngle=-1234;this.clear();this.drawLeftPage();this.drawRightPage();this.drawBottomPage();if(null!=this.flippingPage){if(this.flippingPage.state.hardDrawingAngle<=90){this.flippingPage.getElement().style.zIndex=(this.getSettings().startZIndex+5).toString(10);this.flippingPage.draw()}else this.flippingPage.getElement().style.display="none"}if(null!=this.shadow&&null!==this.flippingPage)if("soft"===this.flippingPage.getDrawingDensity()){this.drawOuterShadow();this.drawInnerShadow()}else{this.drawHardOuterShadow();this.drawHardInnerShadow()}}clear(){for(const e of this.app.getPageCollection().getPages()){if(e!==this.leftPage&&e!==this.rightPage&&e!==this.flippingPage&&e!==this.bottomPage){const t=e.getElement().style;"none"!==t.display&&(t.cssText="display: none")}e.getTemporaryCopy()!==this.flippingPage&&e.hideTemporaryCopy()}}update(){super.update();null!==this.rightPage&&this.rightPage.setOrientation(1);null!==this.leftPage&&this.leftPage.setOrientation(0)}}class Settings{constructor(){this._default={startPage:0,size:"fixed",width:0,height:0,minWidth:0,maxWidth:0,minHeight:0,maxHeight:0,drawShadow:!0,flippingTime:1e3,usePortrait:!0,startZIndex:0,autoSize:!0,maxShadowOpacity:1,showCover:!1,mobileScrollSupport:!0,swipeDistance:30,clickEventForward:!0,useMouseEvents:!0,showPageCorners:!0,disableFlipByClick:!1,enableFlipByDrag:!0}}getSettings(e){const t=this._default;Object.assign(t,e);if("stretch"!==t.size&&"fixed"!==t.size)throw new Error('Invalid size type. Available only "fixed" and "stretch" value');if(t.width<=0||t.height<=0)throw new Error("Invalid width or height");if(t.flippingTime<=0)throw new Error("Invalid flipping time");if("stretch"===t.size){t.minWidth<=0&&(t.minWidth=100);t.maxWidth<t.minWidth&&(t.maxWidth=2e3);t.minHeight<=0&&(t.minHeight=100);t.maxHeight<t.minHeight&&(t.maxHeight=2e3)}else{t.minWidth=t.width;t.maxWidth=t.width;t.minHeight=t.height;t.maxHeight=t.height}return t}}class PageFlip extends EventObject{constructor(e,t,i){super();this.isUserTouch=!1;this.isUserMove=!1;this.setting=null;this.pages=null;this.setting=(new Settings).getSettings(t);this.block=e;this.cspPolicyService=i}destroy(){this.ui.destroy();this.render=void 0}update(){this.render.update();this.pages.show()}loadFromHTML(e){this.ui=new HTMLUI(this.block,this,this.setting,e,this.cspPolicyService);this.render=new HTMLRender(this,this.setting,this.ui.getDistElement());this.flipController=new Flip(this.render,this);this.pages=new HTMLPageCollection(this,this.render,this.ui.getDistElement(),e);this.pages.load();this.render.start();this.pages.show(this.setting.startPage);setTimeout(()=>{this.ui.update();this.trigger("init",this,{page:this.setting.startPage,mode:this.render.getOrientation()})},1)}updateFromHtml(e){const t=this.pages.getCurrentPageIndex();this.pages.destroy();this.pages=new HTMLPageCollection(this,this.render,this.ui.getDistElement(),e);this.pages.load();this.ui.updateItems(e);this.render.reload();this.pages.show(t);this.trigger("update",this,{page:t,mode:this.render.getOrientation()})}clear(){this.pages.destroy();this.ui.clear()}turnToPrevPage(){this.pages.showPrev()}turnToNextPage(){this.pages.showNext()}turnToPage(e){this.pages.show(e)}flipNext(e="top"){this.flipController.flipNext(e)}flipPrev(e="top"){this.flipController.flipPrev(e)}flip(e,t="top"){this.flipController.flipToPage(e,t)}updateState(e){this.trigger("changeState",this,e)}updatePageIndex(e){this.trigger("flip",this,e)}updateOrientation(e){this.ui.setOrientationStyle(e);this.update();this.trigger("changeOrientation",this,e)}getPageCount(){return this.pages.getPageCount()}getCurrentPageIndex(){return this.pages.getCurrentPageIndex()}getPage(e){return this.pages.getPage(e)}getRender(){return this.render}getFlipController(){return this.flipController}getOrientation(){return this.render.getOrientation()}getBoundsRect(){return this.render.getRect()}getSettings(){return this.setting}getUI(){return this.ui}getState(){return this.flipController.getState()}getPageCollection(){return this.pages}startUserTouch(e){this.mousePosition=e;this.isUserTouch=!0;this.isUserMove=!1}userMove(e,t){if(this.isUserTouch||t||!this.setting.showPageCorners){if(this.isUserTouch&&Helper.GetDistanceBetweenTwoPoint(this.mousePosition,e)>5){this.isUserMove=!0;this.flipController.fold(e)}}else this.flipController.showCorner(e)}userStop(e,t=!1){if(this.isUserTouch){this.isUserTouch=!1;t||(this.isUserMove?this.flipController.stopMove():this.flipController.flip(e))}}}function annotation_editor_layer_builder_classPrivateFieldInitSpec(e,t,i){(function annotation_editor_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function annotation_editor_layer_builder_classPrivateFieldGet(e,t){return e.get(annotation_editor_layer_builder_assertClassBrand(e,t))}function annotation_editor_layer_builder_classPrivateFieldSet(e,t,i){return e.set(annotation_editor_layer_builder_assertClassBrand(e,t),i),i}function annotation_editor_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var zf=new WeakMap,Hf=new WeakMap,$f=new WeakMap,Kf=new WeakMap,Xf=new WeakMap,qf=new WeakMap;class AnnotationEditorLayerBuilder{constructor(e){annotation_editor_layer_builder_classPrivateFieldInitSpec(this,zf,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,Hf,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,$f,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,Kf,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,Xf,null);annotation_editor_layer_builder_classPrivateFieldInitSpec(this,qf,void 0);this.pageIndex=e.pageIndex;this.accessibilityManager=e.accessibilityManager;this.l10n=e.l10n;this.l10n||=new genericl10n_GenericL10n;this.annotationEditorLayer=null;this.div=null;this._cancelled=!1;annotation_editor_layer_builder_classPrivateFieldSet(qf,this,e.uiManager);annotation_editor_layer_builder_classPrivateFieldSet(zf,this,e.annotationLayer||null);annotation_editor_layer_builder_classPrivateFieldSet(Xf,this,e.textLayer||null);annotation_editor_layer_builder_classPrivateFieldSet(Hf,this,e.drawLayer||null);annotation_editor_layer_builder_classPrivateFieldSet($f,this,e.onAppend||null);this.eventBus=e.eventBus;annotation_editor_layer_builder_classPrivateFieldSet(Kf,this,e.structTreeLayer||null)}updatePageIndex(e){this.pageIndex=e;this.annotationEditorLayer?.updatePageIndex(e)}async render({viewport:e,intent:t="display"}){if("display"!==t)return;if(this._cancelled)return;const i=e.clone({dontFlip:!0});if(this.div){this.annotationEditorLayer.update({viewport:i});this.show();return}const a=this.div=document.createElement("div");a.className="annotationEditorLayer";a.hidden=!0;a.dir=annotation_editor_layer_builder_classPrivateFieldGet(qf,this).direction;annotation_editor_layer_builder_classPrivateFieldGet($f,this)?.call(this,a);this.annotationEditorLayer=new AnnotationEditorLayer({uiManager:annotation_editor_layer_builder_classPrivateFieldGet(qf,this),div:a,structTreeLayer:annotation_editor_layer_builder_classPrivateFieldGet(Kf,this),accessibilityManager:this.accessibilityManager,pageIndex:this.pageIndex,l10n:this.l10n,viewport:i,annotationLayer:annotation_editor_layer_builder_classPrivateFieldGet(zf,this),textLayer:annotation_editor_layer_builder_classPrivateFieldGet(Xf,this),drawLayer:annotation_editor_layer_builder_classPrivateFieldGet(Hf,this),eventBus:this.eventBus});const s={viewport:i,div:a,annotations:null,intent:t};await this.annotationEditorLayer.render(s);this.show()}cancel(){this._cancelled=!0;this.div&&this.annotationEditorLayer.destroy()}hide(){if(this.div){this.annotationEditorLayer.pause(!0);this.div.hidden=!0}}show(){if(this.div&&!this.annotationEditorLayer.isInvisible){this.div.hidden=!1;this.annotationEditorLayer.pause(!1)}}}function annotation_layer_builder_classPrivateFieldInitSpec(e,t,i){annotation_layer_builder_checkPrivateRedeclaration(e,t),t.set(e,i)}function annotation_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function annotation_layer_builder_classPrivateFieldGet(e,t){return e.get(annotation_layer_builder_assertClassBrand(e,t))}function annotation_layer_builder_classPrivateFieldSet(e,t,i){return e.set(annotation_layer_builder_assertClassBrand(e,t),i),i}function annotation_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Yf=new WeakMap,Zf=new WeakMap,Qf=new WeakMap,Jf=new WeakMap,ev=new WeakMap,tv=new WeakSet;class AnnotationLayerBuilder{constructor({pdfPage:e,linkService:t,downloadManager:i,annotationStorage:a=null,imageResourcesPath:s="",renderForms:n=!0,enableComment:r=!1,commentManager:o=null,enableScripting:l=!1,hasJSActionsPromise:d=null,fieldObjectsPromise:c=null,annotationCanvasMap:h=null,accessibilityManager:u=null,annotationEditorUIManager:_=null,onAppend:p=null}){!function annotation_layer_builder_classPrivateMethodInitSpec(e,t){annotation_layer_builder_checkPrivateRedeclaration(e,t),t.add(e)}(this,tv);annotation_layer_builder_classPrivateFieldInitSpec(this,Yf,null);annotation_layer_builder_classPrivateFieldInitSpec(this,Zf,null);annotation_layer_builder_classPrivateFieldInitSpec(this,Qf,null);annotation_layer_builder_classPrivateFieldInitSpec(this,Jf,null);annotation_layer_builder_classPrivateFieldInitSpec(this,ev,!1);this.pdfPage=e;this.linkService=t;this.downloadManager=i;this.imageResourcesPath=s;this.renderForms=n;this.annotationStorage=a;this.enableComment=r;annotation_layer_builder_classPrivateFieldSet(Zf,this,o);this.enableScripting=l;this._hasJSActionsPromise=d||Promise.resolve(!1);this._fieldObjectsPromise=c||Promise.resolve(null);this._annotationCanvasMap=h;this._accessibilityManager=u;this._annotationEditorUIManager=_;annotation_layer_builder_classPrivateFieldSet(Qf,this,p);this.annotationLayer=null;this.div=null;this._cancelled=!1;this._eventBus=t.eventBus}async render({viewport:e,intent:t="display",structTreeLayer:i=null,optionalContentConfigPromise:a=null}){if(this.div){const t=await a;if(this._cancelled||!this.annotationLayer)return;this.annotationLayer.update({viewport:e.clone({dontFlip:!0}),optionalContentConfig:t});return}const[s,n,r,o]=await Promise.all([this.pdfPage.getAnnotations({intent:t}),this._hasJSActionsPromise,this._fieldObjectsPromise,a]);if(this._cancelled)return;const l=this.div=document.createElement("div");l.className="annotationLayer";annotation_layer_builder_classPrivateFieldGet(Qf,this)?.call(this,l);annotation_layer_builder_assertClassBrand(tv,this,_initAnnotationLayer).call(this,e,i);if(0!==s.length){await this.annotationLayer.render({annotations:s,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,downloadManager:this.downloadManager,enableComment:this.enableComment,enableScripting:this.enableScripting,hasJSActions:n,fieldObjects:r,optionalContentConfig:o});annotation_layer_builder_classPrivateFieldSet(Yf,this,s);this.linkService.isInPresentationMode&&annotation_layer_builder_assertClassBrand(tv,this,_updatePresentationModeState).call(this,hh);if(!annotation_layer_builder_classPrivateFieldGet(Jf,this)){annotation_layer_builder_classPrivateFieldSet(Jf,this,new AbortController);this._eventBus?.on("presentationmodechanged",e=>{annotation_layer_builder_assertClassBrand(tv,this,_updatePresentationModeState).call(this,e.state)},{signal:annotation_layer_builder_classPrivateFieldGet(Jf,this).signal,...Nh})}}else{annotation_layer_builder_classPrivateFieldSet(Yf,this,s);setLayerDimensions(this.div,e)}}cancel(){this._cancelled=!0;annotation_layer_builder_classPrivateFieldGet(Jf,this)?.abort();annotation_layer_builder_classPrivateFieldSet(Jf,this,null);this.annotationLayer?.destroy()}refreshCanvases(){this.annotationLayer?.refreshCanvases()}hide(){this.div&&(document.querySelector("[data-pdfjsprinting=true]")||(this.div.hidden=!0))}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}async injectLinkAnnotations(e){if(null===annotation_layer_builder_classPrivateFieldGet(Yf,this)||this._cancelled||annotation_layer_builder_classPrivateFieldGet(ev,this))return;annotation_layer_builder_classPrivateFieldSet(ev,this,!0);const t=annotation_layer_builder_classPrivateFieldGet(Yf,this).length?annotation_layer_builder_assertClassBrand(tv,this,_checkInferredLinks).call(this,e):e;t.length&&await this.annotationLayer.addLinkAnnotations(t)}}function _initAnnotationLayer(e,t){this.annotationLayer=new AnnotationLayer({div:this.div,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,annotationStorage:this.annotationStorage,page:this.pdfPage,viewport:e.clone({dontFlip:!0}),structTreeLayer:t,commentManager:annotation_layer_builder_classPrivateFieldGet(Zf,this),linkService:this.linkService})}function _updatePresentationModeState(e){if(!this.div)return;let t=!1;switch(e){case hh:t=!0;break;case dh:break;default:return}for(const e of this.div.childNodes)e.hasAttribute("data-internal-link")||e.classList.contains("mediaAnnotation")||(e.inert=t)}function _checkInferredLinks(e){function annotationRects(e){if(!e.quadPoints)return[e.rect];const t=[];for(let i=2,a=e.quadPoints.length;i<a;i+=8){const a=e.quadPoints[i],s=e.quadPoints[i+1],n=e.quadPoints[i+2],r=e.quadPoints[i+3];t.push([n,r,a,s])}return t}function intersectAnnotations(e,t){const i=[],a=annotationRects(e),s=annotationRects(t);for(const e of a)for(const t of s){const a=Util.intersect(e,t);a&&i.push(a)}return i}function areaRects(e){let t=0;for(const i of e)t+=Math.abs((i[2]-i[0])*(i[3]-i[1]));return t}return e.filter(e=>{let t;for(const i of annotation_layer_builder_classPrivateFieldGet(Yf,this)){if(i.annotationType!==k.LINK)continue;const a=intersectAnnotations(i,e);if(0!==a.length){t??=areaRects(annotationRects(e));if(areaRects(a)/t>.5)return!1}}return!0})}function autolinker_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}function DOMRectToPDF({width:e,height:t,left:i,top:a},s){if(0===e||0===t)return null;const n=s.textLayer.div.getBoundingClientRect(),r=s.getPagePoint(i-n.left,a-n.top),o=s.getPagePoint(i-n.left+e,a-n.top+t);return Util.normalizeRect([r[0],r[1],o[0],o[1]])}function calculateLinkPosition(e,t){const i=e.getClientRects();if(1===i.length)return{rect:DOMRectToPDF(i[0],t)};const a=[1/0,1/0,-1/0,-1/0],s=[];let n=0;for(const e of i){const i=DOMRectToPDF(e,t);if(null!==i){s[n]=s[n+4]=i[0];s[n+1]=s[n+3]=i[3];s[n+2]=s[n+6]=i[2];s[n+5]=s[n+7]=i[1];Util.rectBoundingBox(...i,a);n+=8}}return{quadPoints:s,rect:a}}function textPosition(e,t){let i=e;do{if(i.nodeType===Node.TEXT_NODE){const e=i.textContent.length;if(t<=e)return[i,t];t-=e}else if(i.firstChild){i=i.firstChild;continue}for(;!i.nextSibling&&i!==e;)i=i.parentNode;i!==e&&(i=i.nextSibling)}while(i!==e);throw new Error("Offset is bigger than container's contents length.")}class Autolinker{static findLinks(e){autolinker_assertClassBrand(Autolinker,this,av)._??(av._=autolinker_assertClassBrand(Autolinker,this,/\b(?:https?:\/\/|mailto:|www\.)(?:[\0-\x08\x0E-\x1F\$\+0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]|\/|[\0-\x08\x0E-\x1F!-Z\\\^-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uFEFE\uFF00-\u{10FFFF}]+[\0-\x08\x0E-\x1F\$\+0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}])+|(?=\p{L})[\0-\x08\x0E-\x1F!-'\*-;=\?A-Z\\\^-z\|~-\x9F\xA1-\u0F39\u0F3E-\u167F\u1681-\u169A\u169D-\u1FFF\u200B-\u2019\u201B-\u201D\u201F-\u2027\u202A-\u202E\u2030-\u2044\u2047-\u205E\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2E21\u2E2A-\u2E41\u2E43-\u2E54\u2E5D-\u2FFF\u3001-\u3007\u3012\u3013\u301C\u3020-\uFD3D\uFD40-\uFE16\uFE19-\uFE34\uFE45\uFE46\uFE49-\uFE58\uFE5F-\uFEFE\uFF00-\uFF07\uFF0A-\uFF3A\uFF3C\uFF3E-\uFF5A\uFF5C\uFF5E\uFF61\uFF64-\u{10FFFF}]+@([\0-\x08\x0E-\x1F\$\+\x2D0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]+(?:\.[\0-\x08\x0E-\x1F\$\+\x2D0-9=A-Z\^`-z\|~-\x9F\xA2-\xA6\xA8-\xAA\xAC-\xB5\xB8-\xBA\xBC-\xBE\xC0-\u037D\u037F-\u0386\u0388-\u0559\u0560-\u0588\u058B-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u05F2\u05F5-\u0608\u060B\u060E-\u061A\u061C\u0620-\u0669\u066E-\u06D3\u06D5-\u06FF\u070E-\u07F6\u07FA-\u082F\u083F-\u085D\u085F-\u0963\u0966-\u096F\u0971-\u09FC\u09FE-\u0A75\u0A77-\u0AEF\u0AF1-\u0C76\u0C78-\u0C83\u0C85-\u0DF3\u0DF5-\u0E4E\u0E50-\u0E59\u0E5C-\u0F03\u0F13\u0F15-\u0F39\u0F3E-\u0F84\u0F86-\u0FCF\u0FD5-\u0FD8\u0FDB-\u1049\u1050-\u10FA\u10FC-\u135F\u1369-\u13FF\u1401-\u166D\u166F-\u167F\u1681-\u169A\u169D-\u16EA\u16EE-\u1734\u1737-\u17D3\u17D7\u17DB-\u17FF\u180B-\u1943\u1946-\u1A1D\u1A20-\u1A9F\u1AA7\u1AAE-\u1B4D\u1B50-\u1B59\u1B61-\u1B7C\u1B80-\u1BFB\u1C00-\u1C3A\u1C40-\u1C7D\u1C80-\u1CBF\u1CC8-\u1CD2\u1CD4-\u1FFF\u200B-\u200F\u202A-\u202E\u2044\u2052\u2060-\u207C\u207F-\u208C\u208F-\u2307\u230C-\u2328\u232B-\u2767\u2776-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2CF8\u2CFD\u2D00-\u2D6F\u2D71-\u2DFF\u2E2F\u2E50\u2E51\u2E5E-\u2FFF\u3004-\u3007\u3012\u3013\u3020-\u302F\u3031-\u303C\u303E-\u309F\u30A1-\u30FA\u30FC-\uA4FD\uA500-\uA60C\uA610-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA6F8-\uA873\uA878-\uA8CD\uA8D0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA95E\uA960-\uA9C0\uA9CE-\uA9DD\uA9E0-\uAA5B\uAA60-\uAADD\uAAE0-\uAAEF\uAAF2-\uABEA\uABEC-\uFD3D\uFD40-\uFE0F\uFE1A-\uFE2F\uFE53\uFE62\uFE64-\uFE67\uFE69\uFE6C-\uFEFE\uFF00\uFF04\uFF0B\uFF10-\uFF19\uFF1C-\uFF1E\uFF21-\uFF3A\uFF3E\uFF40-\uFF5A\uFF5C\uFF5E\uFF66-\u{100FF}\u{10103}-\u{1039E}\u{103A0}-\u{103CF}\u{103D1}-\u{1056E}\u{10570}-\u{10856}\u{10858}-\u{1091E}\u{10920}-\u{1093E}\u{10940}-\u{10A4F}\u{10A59}-\u{10A7E}\u{10A80}-\u{10AEF}\u{10AF7}-\u{10B38}\u{10B40}-\u{10B98}\u{10B9D}-\u{10D6D}\u{10D6F}-\u{10EAC}\u{10EAE}-\u{10ECF}\u{10ED1}-\u{10F54}\u{10F5A}-\u{10F85}\u{10F8A}-\u{11046}\u{1104E}-\u{110BA}\u{110BD}\u{110C2}-\u{1113F}\u{11144}-\u{11173}\u{11176}-\u{111C4}\u{111C9}-\u{111CC}\u{111CE}-\u{111DA}\u{111DC}\u{111E0}-\u{11237}\u{1123E}-\u{112A8}\u{112AA}-\u{113D3}\u{113D6}\u{113D9}-\u{1144A}\u{11450}-\u{11459}\u{1145C}\u{1145E}-\u{114C5}\u{114C7}-\u{115C0}\u{115D8}-\u{11640}\u{11644}-\u{1165F}\u{1166D}-\u{116B8}\u{116BA}-\u{1173B}\u{1173F}-\u{1183A}\u{1183C}-\u{11943}\u{11947}-\u{119E1}\u{119E3}-\u{11A3E}\u{11A47}-\u{11A99}\u{11A9D}\u{11AA3}-\u{11AFF}\u{11B0A}-\u{11BE0}\u{11BE2}-\u{11C40}\u{11C46}-\u{11C6F}\u{11C72}-\u{11EF6}\u{11EF9}-\u{11F42}\u{11F50}-\u{11FFE}\u{12000}-\u{1246F}\u{12475}-\u{12FF0}\u{12FF3}-\u{16A6D}\u{16A70}-\u{16AF4}\u{16AF6}-\u{16B36}\u{16B3C}-\u{16B43}\u{16B45}-\u{16D6C}\u{16D70}-\u{16E96}\u{16E9B}-\u{16FE1}\u{16FE3}-\u{1BC9E}\u{1BCA0}-\u{1DA86}\u{1DA8C}-\u{1E5FE}\u{1E600}-\u{1E95D}\u{1E960}-\u{10FFFF}]+)+)/gu));const[t,i]=normalize(e,{ignoreDashEOL:!0}),a=t.matchAll(autolinker_assertClassBrand(Autolinker,this,av)._),s=[];for(const e of a){const[t,a]=e;let n;if(t.startsWith("www.")||t.startsWith("http://")||t.startsWith("https://"))n=t;else if(a){const e=URL.parse(`http://${a}`)?.hostname;if(!e)continue;autolinker_assertClassBrand(Autolinker,this,sv)._??(sv._=autolinker_assertClassBrand(Autolinker,this,/\.\d+$/));if(autolinker_assertClassBrand(Autolinker,this,sv)._.test(e))continue}n??=t.startsWith("mailto:")?t:`mailto:${t}`;const r=createValidAbsoluteUrl(n,null,{addDefaultProtocol:!0});if(r){const[a,n]=getOriginalIndex(i,e.index,t.length);s.push({url:r.href,index:a,length:n})}}return s}static processLinks(e){return this.findLinks(e._textHighlighter.textContentItemsStr.join("\n")).map(t=>{var i,a;return function createLinkAnnotation({url:e,index:t,length:i},a,s){const n=a._textHighlighter,[{begin:r,end:o}]=n._convertMatches([t],[i]),l=new Range;l.setStart(...textPosition(n.textDivs[r.divIdx],r.offset));l.setEnd(...textPosition(n.textDivs[o.divIdx],o.offset));return{id:`inferred_link_${s}`,unsafeUrl:e,url:e,annotationType:k.LINK,rotation:0,...calculateLinkPosition(l,a),borderStyle:null}}(t,e,(iv._=autolinker_assertClassBrand(Autolinker,this,(i=autolinker_assertClassBrand(Autolinker,this,iv)._,a=i++,i)),a))})}}var iv={_:0},av={_:void 0},sv={_:void 0};function base_pdf_page_view_defineProperty(e,t,i){return(t=function base_pdf_page_view_toPropertyKey(e){var t=function base_pdf_page_view_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function base_pdf_page_view_classPrivateFieldInitSpec(e,t,i){base_pdf_page_view_checkPrivateRedeclaration(e,t),t.set(e,i)}function base_pdf_page_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function base_pdf_page_view_classPrivateFieldSet(e,t,i){return e.set(base_pdf_page_view_assertClassBrand(e,t),i),i}function base_pdf_page_view_classPrivateFieldGet(e,t){return e.get(base_pdf_page_view_assertClassBrand(e,t))}function base_pdf_page_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var nv=new WeakMap,rv=new WeakMap,ov=new WeakMap,lv=new WeakMap,dv=new WeakMap,cv=new WeakMap,hv=new WeakMap,uv=new WeakSet;class BasePDFPageView extends RenderableView{constructor(e){super();!function base_pdf_page_view_classPrivateMethodInitSpec(e,t){base_pdf_page_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,uv);base_pdf_page_view_classPrivateFieldInitSpec(this,nv,null);base_pdf_page_view_classPrivateFieldInitSpec(this,rv,null);base_pdf_page_view_classPrivateFieldInitSpec(this,ov,Pm.INITIAL);base_pdf_page_view_classPrivateFieldInitSpec(this,lv,null);base_pdf_page_view_classPrivateFieldInitSpec(this,dv,0);base_pdf_page_view_classPrivateFieldInitSpec(this,cv,null);base_pdf_page_view_defineProperty(this,"canvas",null);base_pdf_page_view_defineProperty(this,"div",null);base_pdf_page_view_defineProperty(this,"enableOptimizedPartialRendering",!1);base_pdf_page_view_defineProperty(this,"enableSelectionRendering",!0);base_pdf_page_view_defineProperty(this,"imagesRightClickMinSize",-1);base_pdf_page_view_defineProperty(this,"eventBus",null);base_pdf_page_view_defineProperty(this,"id",null);base_pdf_page_view_defineProperty(this,"imageCoordinates",null);base_pdf_page_view_defineProperty(this,"pageColors",null);base_pdf_page_view_defineProperty(this,"recordedBBoxes",null);base_pdf_page_view_defineProperty(this,"renderingQueue",null);base_pdf_page_view_classPrivateFieldInitSpec(this,hv,e=>{base_pdf_page_view_classPrivateFieldGet(lv,this)?.call(this,!1);if(!this.renderingQueue||this.renderingQueue.isHighestPriority(this))e();else{this.renderingState=Pm.PAUSED;this.resume=()=>{this.renderingState=Pm.RUNNING;e()}}});this.eventBus=e.eventBus;this.id=e.id;this.pageColors=e.pageColors||null;this.renderingQueue=e.renderingQueue;this.enableOptimizedPartialRendering=e.enableOptimizedPartialRendering??!1;this.enableSelectionRendering=!1!==e.enableSelectionRendering&&FeatureTest.isBackdropFilterSupported;this.imagesRightClickMinSize=e.imagesRightClickMinSize??-1;this.minDurationToUpdateCanvas=e.minDurationToUpdateCanvas??500}get renderingState(){return base_pdf_page_view_classPrivateFieldGet(ov,this)}set renderingState(e){if(e!==base_pdf_page_view_classPrivateFieldGet(ov,this)){base_pdf_page_view_classPrivateFieldSet(ov,this,e);if(base_pdf_page_view_classPrivateFieldGet(nv,this)){clearTimeout(base_pdf_page_view_classPrivateFieldGet(nv,this));base_pdf_page_view_classPrivateFieldSet(nv,this,null)}switch(e){case Pm.PAUSED:this.div.classList.remove("loading");base_pdf_page_view_classPrivateFieldSet(dv,this,0);base_pdf_page_view_classPrivateFieldGet(lv,this)?.call(this,!1);break;case Pm.RUNNING:this.div.classList.add("loadingIcon");base_pdf_page_view_classPrivateFieldSet(nv,this,setTimeout(()=>{this.div.classList.add("loading");base_pdf_page_view_classPrivateFieldSet(nv,this,null)},0));base_pdf_page_view_classPrivateFieldSet(dv,this,Date.now());break;case Pm.INITIAL:case Pm.FINISHED:this.div.classList.remove("loadingIcon","loading");base_pdf_page_view_classPrivateFieldSet(dv,this,0)}}}_createCanvas(e,t=!1){const{pageColors:i}=this,a=!(!i?.background||!i?.foreground),s=this.canvas,n=!s&&!a&&!t;let r=this.canvas=document.createElement("canvas");base_pdf_page_view_classPrivateFieldSet(lv,this,t=>{if(n){let i=base_pdf_page_view_classPrivateFieldGet(cv,this);if(!t&&this.minDurationToUpdateCanvas>0){if(Date.now()-base_pdf_page_view_classPrivateFieldGet(dv,this)<this.minDurationToUpdateCanvas)return;if(!i){i=base_pdf_page_view_classPrivateFieldSet(cv,this,r);r=this.canvas=r.cloneNode(!1);e(r)}}if(i){r.getContext("2d",{alpha:!1}).drawImage(i,0,0);t?base_pdf_page_view_assertClassBrand(uv,this,_resetTempCanvas).call(this):base_pdf_page_view_classPrivateFieldSet(dv,this,Date.now());return}e(r);base_pdf_page_view_classPrivateFieldSet(lv,this,null);return}if(t)if(s){s.parentNode?s.replaceWith(r):e(r);s.width=s.height=0}else e(r)});return{canvas:r,prevCanvas:s}}_resetCanvas(){const{canvas:e}=this;if(e){e.remove();e.width=e.height=0;this.canvas=null;base_pdf_page_view_assertClassBrand(uv,this,_resetTempCanvas).call(this)}}async _drawCanvas(e,t,i){const a=this.renderTask=this.pdfPage.render(e);a.onContinue=base_pdf_page_view_classPrivateFieldGet(hv,this);a.onError=e=>{if(e instanceof RenderingCancelledException){t();base_pdf_page_view_classPrivateFieldSet(rv,this,null)}};let s=null;try{await a.promise;base_pdf_page_view_classPrivateFieldGet(lv,this)?.call(this,!0)}catch(e){if(e instanceof RenderingCancelledException)return;s=e;base_pdf_page_view_classPrivateFieldGet(lv,this)?.call(this,!0)}finally{base_pdf_page_view_classPrivateFieldSet(rv,this,s);if(a===this.renderTask){this.renderTask=null;this.enableOptimizedPartialRendering&&(this.recordedBBoxes??=a.recordedBBoxes);-1!==this.imagesRightClickMinSize&&(this.imageCoordinates??=this.pdfPage.imageCoordinates)}}this.renderingState=Pm.FINISHED;i(a);if(s)throw s}cancelRendering({cancelExtraDelay:e=0}={}){if(this.renderTask){this.renderTask.cancel(e);this.renderTask=null}this.resume=null}dispatchPageRender(){this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id})}dispatchPageRendered(e,t){this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:e,isDetailView:t,timestamp:performance.now(),error:base_pdf_page_view_classPrivateFieldGet(rv,this)})}}function _resetTempCanvas(){if(base_pdf_page_view_classPrivateFieldGet(cv,this)){base_pdf_page_view_classPrivateFieldGet(cv,this).width=base_pdf_page_view_classPrivateFieldGet(cv,this).height=0;base_pdf_page_view_classPrivateFieldSet(cv,this,null)}}function draw_layer_builder_classPrivateFieldInitSpec(e,t,i){(function draw_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function draw_layer_builder_classPrivateFieldSet(e,t,i){return e.set(draw_layer_builder_assertClassBrand(e,t),i),i}function draw_layer_builder_classPrivateFieldGet(e,t){return e.get(draw_layer_builder_assertClassBrand(e,t))}function draw_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var _v=new WeakMap;class DrawLayerBuilder{constructor(e){draw_layer_builder_classPrivateFieldInitSpec(this,_v,null);this.pageIndex=e.pageIndex;this.textLayer=e.textLayer||null;this.filterFactory=e.filterFactory||null;this.pageColors=e.pageColors||null}async render({intent:e="display"}){"display"!==e||draw_layer_builder_classPrivateFieldGet(_v,this)||this._cancelled||draw_layer_builder_classPrivateFieldSet(_v,this,new DrawLayer({pageIndex:this.pageIndex,textLayer:this.textLayer,filterFactory:this.filterFactory,pageColors:this.pageColors}))}cancel(){this._cancelled=!0;draw_layer_builder_classPrivateFieldGet(_v,this)?.destroy();draw_layer_builder_classPrivateFieldSet(_v,this,null)}setParent(e){draw_layer_builder_classPrivateFieldGet(_v,this)?.setParent(e)}getDrawLayer(){return draw_layer_builder_classPrivateFieldGet(_v,this)}}function pdf_page_detail_view_defineProperty(e,t,i){return(t=function pdf_page_detail_view_toPropertyKey(e){var t=function pdf_page_detail_view_toPrimitive(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var a=i.call(e,t||"default");if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function pdf_page_detail_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_page_detail_view_classPrivateFieldGet(e,t){return e.get(pdf_page_detail_view_assertClassBrand(e,t))}function pdf_page_detail_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var pv=new WeakMap,gv=new WeakSet;class PDFPageDetailView extends BasePDFPageView{constructor({pageView:e}){super(e);!function pdf_page_detail_view_classPrivateMethodInitSpec(e,t){pdf_page_detail_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,gv);!function pdf_page_detail_view_classPrivateFieldInitSpec(e,t,i){pdf_page_detail_view_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,pv,null);pdf_page_detail_view_defineProperty(this,"renderingCancelled",!1);this.pageView=e;this.renderingId="detail"+this.id;this.div=e.div}setPdfPage(e){this.pageView.setPdfPage(e)}get pdfPage(){return this.pageView.pdfPage}get renderingState(){return super.renderingState}set renderingState(e){this.renderingCancelled=!1;super.renderingState=e}reset({keepCanvas:e=!1}={}){const t=this.renderingCancelled||this.renderingState===Pm.RUNNING||this.renderingState===Pm.PAUSED;this.cancelRendering();this.renderingState=Pm.INITIAL;this.renderingCancelled=t;e||this._resetCanvas()}update({visibleArea:e=null,underlyingViewUpdated:t=!1}={}){if(t){this.cancelRendering();this.renderingState=Pm.INITIAL;return}if(!pdf_page_detail_view_assertClassBrand(gv,this,_shouldRenderDifferentArea).call(this,e))return;const{viewport:i,maxCanvasPixels:a,capCanvasAreaFactor:s}=this.pageView,n=e.maxX-e.minX,r=e.maxY-e.minY,o=n*r*OutputScale.pixelRatio**2,l=(Math.sqrt(OutputScale.capPixels(a,s)/o)-1)/2;let d=Math.min(1,l);d<0&&(d=0);const c=n*d,h=r*d,u=Math.max(0,e.minX-c),_=Math.min(i.width,e.maxX+c),p=Math.max(0,e.minY-h),g=Math.min(i.height,e.maxY+h);!function pdf_page_detail_view_classPrivateFieldSet(e,t,i){return e.set(pdf_page_detail_view_assertClassBrand(e,t),i),i}(pv,this,{minX:u,minY:p,width:_-u,height:g-p,scale:i.scale});this.reset({keepCanvas:!0})}_getRenderingContext(e,t){const i=this.pageView._getRenderingContext(e,t,!1),a=this.pdfPage.recordedBBoxes;if(!a||!this.enableOptimizedPartialRendering)return i;const{viewport:{width:s,height:n}}=this.pageView,{width:r,height:o,minX:l,minY:d}=pdf_page_detail_view_classPrivateFieldGet(pv,this),c=l/s,h=d/n,u=(l+r)/s,_=(d+o)/n;return{...i,operationsFilter:e=>!a.isEmpty(e)&&(a.minX(e)<=u&&a.maxX(e)>=c&&a.minY(e)<=_&&a.maxY(e)>=h)}}async draw(){if(this.pageView.detailView!==this)return;const e=this.pageView.renderingState===Pm.FINISHED||this.renderingState===Pm.FINISHED;if(this.renderingState!==Pm.INITIAL){NgxConsole.error("Must be in new state before drawing");this.reset()}const{div:t,pdfPage:i,viewport:a}=this.pageView;if(!i){this.renderingState=Pm.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=Pm.RUNNING;const s=this.pageView._ensureCanvasWrapper(),{canvas:n,prevCanvas:r}=this._createCanvas(e=>{"CANVAS"===s.firstElementChild?.tagName?s.firstElementChild.after(e):s.prepend(e)},e);n.ariaHidden=!0;this.enableOptimizedPartialRendering&&(n.className="detailView");const{width:o,height:l}=a,d=pdf_page_detail_view_classPrivateFieldGet(pv,this),{pixelRatio:c}=OutputScale,h=[c,0,0,c,-d.minX*c,-d.minY*c];n.width=d.width*c;n.height=d.height*c;const{style:u}=n;u.width=100*d.width/o+"%";u.height=100*d.height/l+"%";u.top=100*d.minY/l+"%";u.left=100*d.minX/o+"%";const _=this._drawCanvas(this._getRenderingContext(n,h),()=>{this.canvas?.remove();this.canvas=r},()=>{this.pageView._refreshAnnotationLayer();this.dispatchPageRendered(!1,!0)});t.setAttribute("data-loaded",!0);this.dispatchPageRender();return _}}function _shouldRenderDifferentArea(e){if(!pdf_page_detail_view_classPrivateFieldGet(pv,this))return!0;const t=pdf_page_detail_view_classPrivateFieldGet(pv,this).minX,i=pdf_page_detail_view_classPrivateFieldGet(pv,this).minY,a=pdf_page_detail_view_classPrivateFieldGet(pv,this).width+t,s=pdf_page_detail_view_classPrivateFieldGet(pv,this).height+i;if(e.minX<t||e.minY<i||e.maxX>a||e.maxY>s)return!0;const{width:n,height:r,scale:o}=this.pageView.viewport;if(pdf_page_detail_view_classPrivateFieldGet(pv,this).scale!==o)return!0;const l=e.minX-t,d=a-e.maxX,c=e.minY-i,h=s-e.maxY;return t>0&&d/l>3||a<n&&l/d>3||i>0&&h/c>3||s<r&&c/h>3}function struct_tree_layer_builder_classPrivateFieldInitSpec(e,t,i){struct_tree_layer_builder_checkPrivateRedeclaration(e,t),t.set(e,i)}function struct_tree_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function struct_tree_layer_builder_classPrivateFieldGet(e,t){return e.get(struct_tree_layer_builder_assertClassBrand(e,t))}function struct_tree_layer_builder_classPrivateFieldSet(e,t,i){return e.set(struct_tree_layer_builder_assertClassBrand(e,t),i),i}function struct_tree_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const mv={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"rowgroup",TBody:"rowgroup",TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},fv=new Set(["math","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics"]),vv="http://www.w3.org/1998/Math/MathML";class MathMLSanitizer{static get sanitizer(){return shadow(this,"sanitizer",FeatureTest.isSanitizerSupported?new Sanitizer({elements:Array.from(fv.keys(),e=>({name:e,namespace:vv})),replaceWithChildrenElements:[{name:"maction",namespace:vv}],attributes:["dir","displaystyle","mathbackground","mathcolor","mathsize","scriptlevel","encoding","display","linethickness","intent","arg","form","fence","separator","lspace","rspace","stretchy","symmetric","maxsize","minsize","largeop","movablelimits","width","height","depth","voffset","accent","accentunder","columnspan","rowspan"],comments:!1}):null)}}const Pv=/^H(\d+)$/;var wv=new WeakMap,Fv=new WeakMap,bv=new WeakMap,yv=new WeakMap,Sv=new WeakMap,Cv=new WeakMap,xv=new WeakMap,kv=new WeakMap,Ev=new WeakSet;class StructTreeLayerBuilder{constructor(e,t){!function struct_tree_layer_builder_classPrivateMethodInitSpec(e,t){struct_tree_layer_builder_checkPrivateRedeclaration(e,t),t.add(e)}(this,Ev);struct_tree_layer_builder_classPrivateFieldInitSpec(this,wv,void 0);struct_tree_layer_builder_classPrivateFieldInitSpec(this,Fv,null);struct_tree_layer_builder_classPrivateFieldInitSpec(this,bv,void 0);struct_tree_layer_builder_classPrivateFieldInitSpec(this,yv,new Map);struct_tree_layer_builder_classPrivateFieldInitSpec(this,Sv,void 0);struct_tree_layer_builder_classPrivateFieldInitSpec(this,Cv,null);struct_tree_layer_builder_classPrivateFieldInitSpec(this,xv,null);struct_tree_layer_builder_classPrivateFieldInitSpec(this,kv,null);struct_tree_layer_builder_classPrivateFieldSet(wv,this,e.getStructTree());struct_tree_layer_builder_classPrivateFieldSet(Sv,this,t)}async render(){if(struct_tree_layer_builder_classPrivateFieldGet(bv,this))return struct_tree_layer_builder_classPrivateFieldGet(bv,this);const{promise:e,resolve:t,reject:i}=Promise.withResolvers();struct_tree_layer_builder_classPrivateFieldSet(bv,this,e);try{struct_tree_layer_builder_classPrivateFieldSet(Fv,this,struct_tree_layer_builder_assertClassBrand(Ev,this,_walk).call(this,await struct_tree_layer_builder_classPrivateFieldGet(wv,this)))}catch(e){i(e)}struct_tree_layer_builder_classPrivateFieldSet(wv,this,null);struct_tree_layer_builder_classPrivateFieldGet(Fv,this)?.classList.add("structTree");t(struct_tree_layer_builder_classPrivateFieldGet(Fv,this));return e}async getAriaAttributes(e){try{await this.render();return struct_tree_layer_builder_classPrivateFieldGet(yv,this).get(e)}catch{}return null}hide(){struct_tree_layer_builder_classPrivateFieldGet(Fv,this)&&!struct_tree_layer_builder_classPrivateFieldGet(Fv,this).hidden&&(struct_tree_layer_builder_classPrivateFieldGet(Fv,this).hidden=!0)}show(){struct_tree_layer_builder_classPrivateFieldGet(Fv,this)?.hidden&&(struct_tree_layer_builder_classPrivateFieldGet(Fv,this).hidden=!1)}updateTextLayer(){if(struct_tree_layer_builder_classPrivateFieldGet(Cv,this)){for(const[e,t]of struct_tree_layer_builder_classPrivateFieldGet(Cv,this))document.getElementById(e)?.append(t);struct_tree_layer_builder_classPrivateFieldGet(Cv,this).clear();struct_tree_layer_builder_classPrivateFieldSet(Cv,this,null)}if(struct_tree_layer_builder_classPrivateFieldGet(xv,this)){for(const e of struct_tree_layer_builder_classPrivateFieldGet(xv,this)){const t=document.getElementById(e);t&&(t.ariaHidden=!0)}struct_tree_layer_builder_classPrivateFieldGet(xv,this).length=0;struct_tree_layer_builder_classPrivateFieldSet(xv,this,null)}if(struct_tree_layer_builder_classPrivateFieldGet(kv,this)){for(let e=0,t=struct_tree_layer_builder_classPrivateFieldGet(kv,this).length;e<t;e+=2){const t=struct_tree_layer_builder_classPrivateFieldGet(kv,this)[e],i=struct_tree_layer_builder_classPrivateFieldGet(kv,this)[e+1];let a="";for(const e of i){const t=document.getElementById(e);if(t){a+=t.textContent.trim()||"";t.ariaHidden="true"}}a&&(t.textContent=a)}struct_tree_layer_builder_classPrivateFieldGet(kv,this).length=0;struct_tree_layer_builder_classPrivateFieldSet(kv,this,null)}}}function _setAttributes(e,t){const{alt:i,id:a,lang:s}=e;if(void 0!==i){let a=!1;const s=removeNullCharacters(i);for(const t of e.children)if("annotation"===t.type){struct_tree_layer_builder_classPrivateFieldGet(yv,this).getOrInsertComputed(t.id,makeMap).set("aria-label",s);a=!0}a||t.setAttribute("aria-label",s)}void 0!==a&&t.setAttribute("aria-owns",a);void 0!==s&&t.setAttribute("lang",removeNullCharacters(s,!0))}function _addImageInTextLayer(e,t){const{alt:i,bbox:a,children:s}=e,n=s?.[0];if(!struct_tree_layer_builder_classPrivateFieldGet(Sv,this)||!i||!a||"content"!==n?.type)return!1;const{id:r}=n;if(!r)return!1;t.setAttribute("aria-owns",r);const o=document.createElement("span");(struct_tree_layer_builder_classPrivateFieldGet(Cv,this)||struct_tree_layer_builder_classPrivateFieldSet(Cv,this,new Map)).set(r,o);o.setAttribute("role","img");o.setAttribute("aria-label",removeNullCharacters(i));const{pageHeight:l,pageX:d,pageY:c}=struct_tree_layer_builder_classPrivateFieldGet(Sv,this),h="calc(var(--total-scale-factor) *",{style:u}=o;u.width=`${h}${a[2]-a[0]}px)`;u.height=`${h}${a[3]-a[1]}px)`;u.left=`${h}${a[0]-d}px)`;u.top=`${h}${l-a[3]+c}px)`;return!0}function _collectIds(e,t){if(e){"id"in e&&t.push(e.id);for(const i of e.children||[])struct_tree_layer_builder_assertClassBrand(Ev,this,_collectIds).call(this,i,t)}}function _walk(e,t=[]){if(!e)return null;let i,a=!0;if("role"in e){const{role:s}=e;if(fv.has(s)){i=document.createElementNS(vv,s);const t=[];(struct_tree_layer_builder_classPrivateFieldGet(kv,this)||struct_tree_layer_builder_classPrivateFieldSet(kv,this,[])).push(i,t);for(const{type:i,id:a}of e.children||[])"content"===i&&a&&t.push(a)}else i=document.createElement("span");const n=s.match(Pv);if(n){i.setAttribute("role","heading");i.setAttribute("aria-level",n[1])}else mv[s]&&i.setAttribute("role","TH"===s&&"TR"===t.at(-1)?.role&&"TBody"===t.at(-2)?.role?"rowheader":mv[s]);if("Figure"===s&&struct_tree_layer_builder_assertClassBrand(Ev,this,_addImageInTextLayer).call(this,e,i))return i;if("Formula"===s){if(e.mathML&&MathMLSanitizer.sanitizer){a=!1;i.setHTML(e.mathML,{sanitizer:MathMLSanitizer.sanitizer});struct_tree_layer_builder_assertClassBrand(Ev,this,_collectIds).call(this,e,struct_tree_layer_builder_classPrivateFieldGet(xv,this)||struct_tree_layer_builder_classPrivateFieldSet(xv,this,[]));delete e.alt}if(!e.mathML&&1===e.children.length&&"math"!==e.children[0].role){i=document.createElementNS(vv,"math");delete e.alt}}}i||=document.createElement("span");struct_tree_layer_builder_assertClassBrand(Ev,this,_setAttributes).call(this,e,i);if(e.children)if(1===e.children.length&&"id"in e.children[0])struct_tree_layer_builder_assertClassBrand(Ev,this,_setAttributes).call(this,e.children[0],i);else if(a){t.push(e);for(const a of e.children)i.append(struct_tree_layer_builder_assertClassBrand(Ev,this,_walk).call(this,a,t));t.pop()}return i}function text_accessibility_classPrivateFieldInitSpec(e,t,i){text_accessibility_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_accessibility_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_accessibility_classPrivateFieldGet(e,t){return e.get(text_accessibility_assertClassBrand(e,t))}function text_accessibility_classPrivateFieldSet(e,t,i){return e.set(text_accessibility_assertClassBrand(e,t),i),i}function text_accessibility_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Av=new WeakMap,Gv=new WeakMap,Bv=new WeakMap,Mv=new WeakMap,Iv=new WeakSet;class TextAccessibilityManager{constructor(){!function text_accessibility_classPrivateMethodInitSpec(e,t){text_accessibility_checkPrivateRedeclaration(e,t),t.add(e)}(this,Iv);text_accessibility_classPrivateFieldInitSpec(this,Av,!1);text_accessibility_classPrivateFieldInitSpec(this,Gv,null);text_accessibility_classPrivateFieldInitSpec(this,Bv,new Map);text_accessibility_classPrivateFieldInitSpec(this,Mv,new Map)}setTextMapping(e){text_accessibility_classPrivateFieldSet(Gv,this,e)}enable(){if(text_accessibility_classPrivateFieldGet(Av,this))throw new Error("TextAccessibilityManager is already enabled.");if(!text_accessibility_classPrivateFieldGet(Gv,this))throw new Error("Text divs and strings have not been set.");text_accessibility_classPrivateFieldSet(Av,this,!0);text_accessibility_classPrivateFieldSet(Gv,this,text_accessibility_classPrivateFieldGet(Gv,this).slice());text_accessibility_classPrivateFieldGet(Gv,this).sort(_compareElementPositions);if(text_accessibility_classPrivateFieldGet(Bv,this).size>0){const e=text_accessibility_classPrivateFieldGet(Gv,this);for(const[t,i]of text_accessibility_classPrivateFieldGet(Bv,this)){document.getElementById(t)?text_accessibility_assertClassBrand(Iv,this,_addIdToAriaOwns).call(this,t,e[i]):text_accessibility_classPrivateFieldGet(Bv,this).delete(t)}}for(const[e,t]of text_accessibility_classPrivateFieldGet(Mv,this))this.addPointerInTextLayer(e,t);text_accessibility_classPrivateFieldGet(Mv,this).clear()}disable(){if(text_accessibility_classPrivateFieldGet(Av,this)){text_accessibility_classPrivateFieldGet(Mv,this).clear();text_accessibility_classPrivateFieldSet(Gv,this,null);text_accessibility_classPrivateFieldSet(Av,this,!1)}}removePointerInTextLayer(e){if(!text_accessibility_classPrivateFieldGet(Av,this)){text_accessibility_classPrivateFieldGet(Mv,this).delete(e);return}const t=text_accessibility_classPrivateFieldGet(Gv,this);if(!t?.length)return;const{id:i}=e,a=text_accessibility_classPrivateFieldGet(Bv,this).get(i);if(void 0===a)return;const s=t[a];text_accessibility_classPrivateFieldGet(Bv,this).delete(i);let n=s.getAttribute("aria-owns");if(n?.includes(i)){n=n.split(" ").filter(e=>e!==i).join(" ");if(n)s.setAttribute("aria-owns",n);else{s.removeAttribute("aria-owns");s.setAttribute("role","presentation")}}}addPointerInTextLayer(e,t){const{id:i}=e;if(!i)return null;if(!text_accessibility_classPrivateFieldGet(Av,this)){text_accessibility_classPrivateFieldGet(Mv,this).set(e,t);return null}t&&this.removePointerInTextLayer(e);const a=text_accessibility_classPrivateFieldGet(Gv,this);if(!a?.length)return null;const s=binarySearchFirstItem(a,t=>_compareElementPositions.call(TextAccessibilityManager,e,t)<0),n=Math.max(0,s-1),r=a[n];text_accessibility_assertClassBrand(Iv,this,_addIdToAriaOwns).call(this,i,r);text_accessibility_classPrivateFieldGet(Bv,this).set(i,n);const o=r.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(e,t,i,a){const s=this.addPointerInTextLayer(i,a);if(!e.hasChildNodes()){e.append(t);return s}const n=Array.from(e.childNodes).filter(e=>e!==t);if(0===n.length)return s;const r=binarySearchFirstItem(n,e=>_compareElementPositions.call(TextAccessibilityManager,t,e)<0);0===r?n[0].before(t):n[r-1].after(t);return s}}function _compareElementPositions(e,t){const i=e.getBoundingClientRect(),a=t.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===a.width&&0===a.height)return-1;const s=i.y,n=i.y+i.height,r=i.y+i.height/2,o=a.y,l=a.y+a.height,d=a.y+a.height/2;if(r<=o&&d>=n)return-1;if(d<=s&&r>=l)return 1;return i.x+i.width/2-(a.x+a.width/2)}function _addIdToAriaOwns(e,t){const i=t.getAttribute("aria-owns");i?.includes(e)||t.setAttribute("aria-owns",i?`${i} ${e}`:e);t.removeAttribute("role")}function text_highlighter_classPrivateFieldInitSpec(e,t,i){(function text_highlighter_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.set(e,i)}function text_highlighter_classPrivateFieldSet(e,t,i){return e.set(text_highlighter_assertClassBrand(e,t),i),i}function text_highlighter_classPrivateFieldGet(e,t){return e.get(text_highlighter_assertClassBrand(e,t))}function text_highlighter_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Tv,Dv=new WeakMap;class TextHighlighter{constructor({findController:e,customFindController:t,eventBus:i,pageIndex:a}){text_highlighter_classPrivateFieldInitSpec(this,Dv,null);this.findController=e;this.customFindController=t;this.matches=[];this.eventBus=i;this.pageIdx=a;this.textDivs=null;this.textContentItemsStr=null;this.enabled=!1}setTextMapping(e,t){this.textDivs=e;this.textContentItemsStr=t}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(!this.enabled){this.enabled=!0;if(!text_highlighter_classPrivateFieldGet(Dv,this)){text_highlighter_classPrivateFieldSet(Dv,this,new AbortController);this.eventBus.on("updatetextlayermatches",e=>{e.pageIndex!==this.pageIdx&&-1!==e.pageIndex||this._updateMatches()},{signal:text_highlighter_classPrivateFieldGet(Dv,this).signal,...Nh})}this._updateMatches()}}disable(){if(this.enabled){this.enabled=!1;text_highlighter_classPrivateFieldGet(Dv,this)?.abort();text_highlighter_classPrivateFieldSet(Dv,this,null);this._updateMatches(!0)}}_convertMatches(e,t,i="highlight",a=!1,s=!1,n=-1,r=null){if(!e)return[];const{textContentItemsStr:o}=this;let l=0,d=0;const c=o.length-1,h=[];for(let u=0,_=e.length;u<_;u++){let _=e[u];for(;l!==c&&_>=d+o[l].length;){d+=o[l].length;l++}l===o.length&&ngx_console_NgxConsole.error("Could not find a matching mapping");const p={begin:{divIdx:l,offset:_-d},cssClass:i+(r?` color${r[u]}`:""),highlightAll:a,selected:s&&u===n};_+=t[u];for(;l!==c&&_>d+o[l].length;){d+=o[l].length;l++}p.end={divIdx:l,offset:_-d};h.push(p)}return h}_renderMatches(e,t){if(0===e.length)return;const{pageIdx:i}=this,{textContentItemsStr:a,textDivs:s}=this;let n=null;const r={divIdx:-1,offset:void 0};function beginText(e,t){const i=e.divIdx;s[i].textContent="";return appendTextToDiv(i,0,e.offset,t)}function appendTextToDiv(e,t,i,n){let r=s[e];if(r.nodeType===Node.TEXT_NODE){const t=document.createElement("span");r.before(t);t.append(r);s[e]=t;r=t}const o=a[e].substring(t,i),l=document.createTextNode(o);if(n){const e=document.createElement("span");e.className=`${n} appended`;e.append(l);r.append(e);return n.includes("selected")?e:null}r.append(l);return 0}let o=-1,l=-1;for(let a=0;a<e.length;a++){const d=e[a];if(!d.selected&&!d.highlightAll)continue;const c=d.begin;if(c.divIdx===o&&c.offset===l)continue;o=c.divIdx;l=c.offset;const h=d.end,u=d.selected?" selected":"";let _=null;if(n&&c.divIdx===n.divIdx)appendTextToDiv(n.divIdx,n.offset,c.offset);else{null!==n&&appendTextToDiv(n.divIdx,n.offset,r.offset);beginText(c)}if(c.divIdx===h.divIdx)_=appendTextToDiv(c.divIdx,c.offset,h.offset,d.cssClass+u);else{_=appendTextToDiv(c.divIdx,c.offset,r.offset,d.cssClass+" begin"+u);for(let e=c.divIdx+1,t=h.divIdx;e<t;e++)s[e].className=d.cssClass+" middle"+u;beginText(h,d.cssClass+" end"+u)}n=h;d.selected&&t.scrollMatchIntoView({element:_,pageIndex:i,matchIndex:a});if(this.textDivs.length>0){const e=this.textDivs[0].closest(".textLayer").querySelectorAll(`.${d.cssClass}`);this.eventBus.dispatch("renderedtextlayerhighlights",{pageIndex:i,highlights:e})}}n&&appendTextToDiv(n.divIdx,n.offset,r.offset)}_updateMatches(e=!1){if(!this.enabled&&!e)return;const{findController:t,customFindController:i,matches:a,pageIdx:s}=this,{textContentItemsStr:n,textDivs:r}=this;let o=-1;for(const e of a){for(let t=Math.max(o,e.begin.divIdx),i=e.end.divIdx;t<=i;t++){const e=r[t];e.textContent=n[t];e.className=""}o=e.end.divIdx+1}if(e)return;const l=i.pageMatches[s]||null,d=i.pageMatchesLength[s]||null,c=i.pageMatchesColor?.[s]||null,h=t.pageMatches[s]||null,u=this._convertMatches(l,d,"customHighlight",i.state?.highlightAll,s===i.selected.pageIdx,i.selected.matchIdx,c);this.matches=[...u];t?.highlightMatches&&!e||e||this._renderMatches(this.matches,this.customFindController);const _=t.pageMatchesLength[s]||null,p=t.pageMatchesColor?.[s]||null,g=this._convertMatches(h,_,"highlight",t.state?.highlightAll,s===t.selected.pageIdx,t.selected.matchIdx,p);this.matches.push(...g);this.matches.sort((e,t)=>{const i=e.begin.divIdx-t.begin.divIdx;return 0===i?e.begin.offset-t.begin.offset:i});this._renderMatches(this.matches,this.findController)}}function text_layer_builder_classPrivateFieldInitSpec(e,t,i){text_layer_builder_checkPrivateRedeclaration(e,t),t.set(e,i)}function text_layer_builder_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function text_layer_builder_classPrivateFieldGet(e,t){return e.get(text_layer_builder_assertClassBrand(e,t))}function text_layer_builder_classPrivateFieldSet(e,t,i){return e.set(text_layer_builder_assertClassBrand(e,t),i),i}function text_layer_builder_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var Lv=new WeakMap,Nv=new WeakMap,Rv=new WeakMap,Ov=new WeakMap,Wv=new WeakMap,jv=new WeakSet;class TextLayerBuilder{constructor({pdfPage:e,highlighter:t=null,accessibilityManager:i=null,enablePermissions:a=!1,onAppend:s=null,abortSignal:n=null}){!function text_layer_builder_classPrivateMethodInitSpec(e,t){text_layer_builder_checkPrivateRedeclaration(e,t),t.add(e)}(this,jv);text_layer_builder_classPrivateFieldInitSpec(this,Lv,null);text_layer_builder_classPrivateFieldInitSpec(this,Nv,!1);text_layer_builder_classPrivateFieldInitSpec(this,Rv,null);text_layer_builder_classPrivateFieldInitSpec(this,Ov,!1);text_layer_builder_classPrivateFieldInitSpec(this,Wv,null);this.pdfPage=e;this.highlighter=t;this.accessibilityManager=i;text_layer_builder_classPrivateFieldSet(Nv,this,!0===a);text_layer_builder_classPrivateFieldSet(Rv,this,s);text_layer_builder_classPrivateFieldSet(Lv,this,n);this.div=document.createElement("div");this.div.tabIndex=0;this.div.className="textLayer"}async render({viewport:e,images:t,textContentParams:i=null}){if(text_layer_builder_classPrivateFieldGet(Ov,this)&&text_layer_builder_classPrivateFieldGet(Wv,this)){text_layer_builder_classPrivateFieldGet(Wv,this).update({viewport:e,onBefore:this.hide.bind(this)});this.show();return}this.cancel();text_layer_builder_classPrivateFieldSet(Wv,this,new TextLayer({textContentSource:this.pdfPage.streamTextContent(i||{includeMarkedContent:!0,disableNormalization:!0}),images:t,container:this.div,viewport:e}));const{textDivs:a,textContentItemsStr:s}=text_layer_builder_classPrivateFieldGet(Wv,this);this.highlighter?.setTextMapping(a,s);this.accessibilityManager?.setTextMapping(a);await text_layer_builder_classPrivateFieldGet(Wv,this).render();text_layer_builder_classPrivateFieldSet(Ov,this,!0);const n=document.createElement("div");n.className="endOfContent";this.div.append(n);text_layer_builder_assertClassBrand(jv,this,_bindMouse).call(this,n);text_layer_builder_classPrivateFieldGet(Rv,this)?.call(this,this.div);this.highlighter?.enable();this.accessibilityManager?.enable()}hide(){if(!this.div.hidden&&text_layer_builder_classPrivateFieldGet(Ov,this)){this.highlighter?.disable();this.div.hidden=!0}}show(){if(this.div.hidden&&text_layer_builder_classPrivateFieldGet(Ov,this)){this.div.hidden=!1;this.highlighter?.enable()}}cancel(){text_layer_builder_classPrivateFieldGet(Wv,this)?.cancel();text_layer_builder_classPrivateFieldSet(Wv,this,null);text_layer_builder_classPrivateFieldSet(Ov,this,!1);this.div.replaceChildren();this.highlighter?.disable();this.accessibilityManager?.disable();_removeGlobalSelectionListener.call(TextLayerBuilder,this.div)}}Tv=TextLayerBuilder;function _bindMouse(e){const{div:t}=this,i=text_layer_builder_classPrivateFieldGet(Lv,this),a=i?{signal:i}:null;t.addEventListener("mousedown",()=>{t.classList.add("selecting")},a);t.addEventListener("copy",e=>{if(!text_layer_builder_classPrivateFieldGet(Nv,this)){const t=document.getSelection();e.clipboardData.setData("text/plain",removeNullCharacters(normalizeUnicode(t.toString())))}stopEvent(e)},a);Vv._.set(t,e);_enableGlobalSelectionListener.call(Tv,i)}function _removeGlobalSelectionListener(e){text_layer_builder_assertClassBrand(Tv,this,Vv)._.delete(e);if(0===text_layer_builder_assertClassBrand(Tv,this,Vv)._.size){text_layer_builder_assertClassBrand(Tv,this,Uv)._?.abort();Uv._=text_layer_builder_assertClassBrand(Tv,this,null)}}function _enableGlobalSelectionListener(e){if(text_layer_builder_assertClassBrand(Tv,this,Uv)._)return;Uv._=text_layer_builder_assertClassBrand(Tv,this,new AbortController);const t=e?AbortSignal.any([text_layer_builder_assertClassBrand(Tv,this,Uv)._.signal,e]):text_layer_builder_assertClassBrand(Tv,this,Uv)._.signal,reset=(e,t)=>{t.append(e);e.style.width="";e.style.height="";t.classList.remove("selecting")};let i=!1;document.addEventListener("pointerdown",()=>{i=!0},{signal:t});document.addEventListener("pointerup",()=>{i=!1;text_layer_builder_assertClassBrand(Tv,this,Vv)._.forEach(reset)},{signal:t});window.addEventListener("blur",()=>{i=!1;text_layer_builder_assertClassBrand(Tv,this,Vv)._.forEach(reset)},{signal:t});document.addEventListener("keyup",()=>{i||text_layer_builder_assertClassBrand(Tv,this,Vv)._.forEach(reset)},{signal:t});var a,s;document.addEventListener("selectionchange",()=>{const e=document.getSelection();if(0===e.rangeCount){text_layer_builder_assertClassBrand(Tv,this,Vv)._.forEach(reset);return}if(0===text_layer_builder_assertClassBrand(Tv,this,Vv)._.size)return;const t=new Set;for(let i=0;i<e.rangeCount;i++){const a=e.getRangeAt(i);for(const e of text_layer_builder_assertClassBrand(Tv,this,Vv)._.keys())!t.has(e)&&a.intersectsNode(e)&&t.add(e)}for(const[e,i]of text_layer_builder_assertClassBrand(Tv,this,Vv)._)t.has(e)?e.classList.add("selecting"):reset(i,e);if(void 0===a&&!(a="none"===getComputedStyle(text_layer_builder_assertClassBrand(Tv,this,Vv)._.values().next().value).getPropertyValue("-moz-user-select"))){const e=navigator.userAgentData?navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e)?.version:/\bChrome\/(\d+)\b/.exec(navigator.userAgent)?.[1];a=!!e&&parseInt(e,10)>=148}if(a)return;const i=e.getRangeAt(0),n=s&&(0===i.compareBoundaryPoints(Range.END_TO_END,s)||0===i.compareBoundaryPoints(Range.START_TO_END,s));let r=n?i.startContainer:i.endContainer;r.nodeType===Node.TEXT_NODE&&(r=r.parentNode);r.classList?.contains("highlight")&&(r=r.parentNode);if(!n&&0===i.endOffset)do{for(;!r.previousSibling;)r=r.parentNode;r=r.previousSibling}while(!r.childNodes.length);const o=r.parentElement?.closest(".textLayer"),l=text_layer_builder_assertClassBrand(Tv,this,Vv)._.get(o);if(l){l.style.width=o.style.width;l.style.height=o.style.height;l.style.userSelect="text";r.parentElement.insertBefore(l,n?r:r.nextSibling)}s=i.cloneRange()},{signal:t})}var Vv={_:new Map},Uv={_:null};function pdf_page_view_classPrivateFieldInitSpec(e,t,i){pdf_page_view_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_page_view_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_page_view_classPrivateFieldGet(e,t){return e.get(pdf_page_view_assertClassBrand(e,t))}function pdf_page_view_classPrivateFieldSet(e,t,i){return e.set(pdf_page_view_assertClassBrand(e,t),i),i}function pdf_page_view_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const zv=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);var Hv=new WeakMap,$v=new WeakMap,Kv=new WeakMap,Xv=new WeakMap,qv=new WeakMap,Yv=new WeakMap,Zv=new WeakMap,Qv=new WeakMap,Jv=new WeakMap,eP=new WeakMap,tP=new WeakMap,iP=new WeakMap,aP=new WeakMap,sP=new WeakMap,nP=new WeakMap,rP=new WeakMap,oP=new WeakMap,lP=new WeakSet;class PDFPageView extends BasePDFPageView{constructor(e){super(e);!function pdf_page_view_classPrivateMethodInitSpec(e,t){pdf_page_view_checkPrivateRedeclaration(e,t),t.add(e)}(this,lP);pdf_page_view_classPrivateFieldInitSpec(this,Hv,null);pdf_page_view_classPrivateFieldInitSpec(this,$v,p.ENABLE_FORMS);pdf_page_view_classPrivateFieldInitSpec(this,Kv,null);pdf_page_view_classPrivateFieldInitSpec(this,Xv,null);pdf_page_view_classPrivateFieldInitSpec(this,qv,!0);pdf_page_view_classPrivateFieldInitSpec(this,Yv,!1);pdf_page_view_classPrivateFieldInitSpec(this,Zv,!1);pdf_page_view_classPrivateFieldInitSpec(this,Qv,null);pdf_page_view_classPrivateFieldInitSpec(this,Jv,!1);pdf_page_view_classPrivateFieldInitSpec(this,eP,null);pdf_page_view_classPrivateFieldInitSpec(this,tP,null);pdf_page_view_classPrivateFieldInitSpec(this,iP,1);pdf_page_view_classPrivateFieldInitSpec(this,aP,1);pdf_page_view_classPrivateFieldInitSpec(this,sP,Ph);pdf_page_view_classPrivateFieldInitSpec(this,nP,1);pdf_page_view_classPrivateFieldInitSpec(this,rP,{directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0});pdf_page_view_classPrivateFieldInitSpec(this,oP,[null,null,null,null]);const{container:t,defaultViewport:i}=e;this.renderingId="page"+this.id;pdf_page_view_classPrivateFieldSet(Qv,this,e.layerProperties||null);pdf_page_view_classPrivateFieldSet(Hv,this,e.abortSignal||null);this.pdfPage=null;this.pageLabel=null;this.rotation=0;this.scale=e.scale||1;this.viewport=i;this.pdfPageRotate=i.rotation;this._optionalContentConfigPromise=e.optionalContentConfigPromise||null;pdf_page_view_classPrivateFieldSet(sP,this,e.textLayerMode??Ph);pdf_page_view_classPrivateFieldSet($v,this,e.annotationMode??p.ENABLE_FORMS);this.imageResourcesPath=e.imageResourcesPath||"";this.enableDetailCanvas=e.enableDetailCanvas??!0;this.maxCanvasPixels=e.maxCanvasPixels??AppOptions.get("maxCanvasPixels");this.maxCanvasDim=e.maxCanvasDim||AppOptions.get("maxCanvasDim");this.capCanvasAreaFactor=e.capCanvasAreaFactor??AppOptions.get("capCanvasAreaFactor");pdf_page_view_classPrivateFieldSet(qv,this,!1!==e.enableAutoLinking);pdf_page_view_classPrivateFieldSet(Xv,this,e.commentManager||null);this.l10n=e.l10n;this.l10n||=new genericl10n_GenericL10n;this._isStandalone=!this.renderingQueue?.hasViewer();this._container=t;this._annotationCanvasMap=null;this.annotationLayer=null;this.annotationEditorLayer=null;this.textLayer=null;this.xfaLayer=null;this.structTreeLayer=null;this.drawLayer=null;this.detailView=null;const a=document.createElement("div");a.className="page";a.setAttribute("data-page-number",this.id);a.setAttribute("role","region");a.setAttribute("data-l10n-id","pdfjs-page-landmark");a.setAttribute("data-l10n-args",JSON.stringify({page:this.id}));this.div=a;pdf_page_view_assertClassBrand(lP,this,_setDimensions).call(this);t?.append(a);if(this._isStandalone){t?.style.setProperty("--scale-factor",this.scale*PixelsPerInch.PDF_TO_CSS_UNITS);this.pageColors?.background&&t?.style.setProperty("--page-bg-color",this.pageColors.background);const{optionalContentConfigPromise:i}=e;i&&i.then(e=>{i===this._optionalContentConfigPromise&&(pdf_page_view_classPrivateFieldGet(rP,this).initialOptionalContent=e.hasInitialVisibility)});e.l10n||this.l10n.translate(this.div)}}clone(e){const t=new PDFPageView({container:null,eventBus:this.eventBus,pagesColors:this.pageColors,renderingQueue:this.renderingQueue,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,minDurationToUpdateCanvas:this.minDurationToUpdateCanvas,defaultViewport:this.viewport,id:e,layerProperties:pdf_page_view_classPrivateFieldGet(Qv,this),abortSignal:pdf_page_view_classPrivateFieldGet(Hv,this),scale:this.scale,optionalContentConfigPromise:this._optionalContentConfigPromise,textLayerMode:pdf_page_view_classPrivateFieldGet(sP,this),annotationMode:pdf_page_view_classPrivateFieldGet($v,this),imageResourcesPath:this.imageResourcesPath,enableDetailCanvas:this.enableDetailCanvas,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableAutoLinking:pdf_page_view_classPrivateFieldGet(qv,this),commentManager:pdf_page_view_classPrivateFieldGet(Xv,this),l10n:this.l10n});t.setPdfPage(this.pdfPage.clone(e-1));return t}updatePageNumber(e){const t=this.id;if(t!==e){this.id=e;this.renderingId=`page${e}`;this.pdfPage&&(this.pdfPage.pageNumber=e);this.setPageLabel(this.pageLabel);const{div:t}=this;t.setAttribute("data-page-number",e);t.setAttribute("data-l10n-args",JSON.stringify({page:e}));this._textHighlighter.pageIdx=e-1}pdf_page_view_classPrivateFieldGet(Qv,this).annotationEditorUIManager?.updatePageIndex(t-1,e-1)}setPdfPage(e){if(this._isStandalone&&("CanvasText"===this.pageColors?.foreground||"Canvas"===this.pageColors?.background)){this._container?.style.setProperty("--hcm-highlight-filter",e.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight"));this._container?.style.setProperty("--hcm-highlight-selected-filter",e.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))}this.pdfPage=e;this.pdfPageRotate=e.rotate;const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=e.getViewport({scale:this.scale*PixelsPerInch.PDF_TO_CSS_UNITS,rotation:t});pdf_page_view_assertClassBrand(lP,this,_setDimensions).call(this);this.reset()}destroy(){this.reset();this.pdfPage?.cleanup()}deleteMe(e){if(e)this.div.remove();else{this.destroy();pdf_page_view_classPrivateFieldGet(Qv,this).annotationEditorUIManager?.deletePage(this.id)}}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return shadow(this,"_textHighlighter",new TextHighlighter({pageIndex:this.id-1,eventBus:this.eventBus,findController:pdf_page_view_classPrivateFieldGet(Qv,this).findController,customFindController:pdf_page_view_classPrivateFieldGet(Qv,this).customFindController}))}_refreshAnnotationLayer(){this._annotationCanvasMap?.size&&this.annotationLayer?.refreshCanvases()}_resetCanvas(){super._resetCanvas();pdf_page_view_classPrivateFieldSet(eP,this,null)}reset({keepAnnotationLayer:e=!1,keepAnnotationEditorLayer:t=!1,keepXfaLayer:i=!1,keepTextLayer:a=!1,keepCanvasWrapper:s=!1,preserveDetailViewState:n=!1}={}){const r=this.pdfPage?._pdfBug??!1;this.cancelRendering({keepAnnotationLayer:e,keepAnnotationEditorLayer:t,keepXfaLayer:i,keepTextLayer:a});this.renderingState=Pm.INITIAL;const o=this.div,l=o.childNodes,d=e&&this.annotationLayer?.div||null,c=t&&this.annotationEditorLayer?.div||null,h=i&&this.xfaLayer?.div||null,u=a&&this.textLayer?.div||null,_=s&&pdf_page_view_classPrivateFieldGet(Kv,this)||null;for(let e=l.length-1;e>=0;e--){const t=l[e];switch(t){case d:case c:case h:case u:case _:continue}if(r&&t.classList.contains("pdfBugGroupsLayer"))continue;t.remove();const i=pdf_page_view_classPrivateFieldGet(oP,this).indexOf(t);i>=0&&(pdf_page_view_classPrivateFieldGet(oP,this)[i]=null)}o.removeAttribute("data-loaded");d&&this.annotationLayer.hide();c&&this.annotationEditorLayer.hide();h&&this.xfaLayer.hide();u&&this.textLayer.hide();this.structTreeLayer?.hide();if(!s&&pdf_page_view_classPrivateFieldGet(Kv,this)){pdf_page_view_classPrivateFieldSet(Kv,this,null);this._resetCanvas()}if(!n){this.detailView?.reset({keepCanvas:s});s||(this.detailView=null)}}toggleEditingMode(e){pdf_page_view_classPrivateFieldSet(Zv,this,e);this.hasEditableAnnotations()&&this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}updateVisibleArea(e){if(this.enableDetailCanvas)if(pdf_page_view_classPrivateFieldGet(Jv,this)&&this.maxCanvasPixels>0&&e){this.detailView??=new PDFPageDetailView({pageView:this,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,imagesRightClickMinSize:-1});this.detailView.update({visibleArea:e})}else if(this.detailView){this.detailView.reset();this.detailView=null}}update({scale:e=0,rotation:t=null,optionalContentConfigPromise:i=null,drawingDelay:a=-1}){this.scale=e||this.scale;"number"==typeof t&&(this.rotation=t);const s=a>=0&&a<1e3;if(s&&!this.canvas)return;if(i instanceof Promise){this._optionalContentConfigPromise=i;i.then(e=>{i===this._optionalContentConfigPromise&&(pdf_page_view_classPrivateFieldGet(rP,this).initialOptionalContent=e.hasInitialVisibility)})}pdf_page_view_classPrivateFieldGet(rP,this).directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:this.scale*PixelsPerInch.PDF_TO_CSS_UNITS,rotation:n});pdf_page_view_assertClassBrand(lP,this,_setDimensions).call(this);this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale);pdf_page_view_assertClassBrand(lP,this,_computeScale).call(this);if(this.canvas){const e=pdf_page_view_classPrivateFieldGet(Yv,this)&&pdf_page_view_classPrivateFieldGet(Jv,this);if(s||e){if(s&&!e&&this.renderingState!==Pm.FINISHED){this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:a});this.renderingState=Pm.FINISHED;pdf_page_view_classPrivateFieldGet(rP,this).directDrawing=!1}this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!s,hideTextLayer:s});if(!s){this.detailView?.update({underlyingViewUpdated:!0});this.dispatchPageRendered(!0,!1)}return}}this.cssTransform({});this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0,preserveDetailViewState:!0});this.detailView?.update({underlyingViewUpdated:!0})}cancelRendering({keepAnnotationLayer:e=!1,keepAnnotationEditorLayer:t=!1,keepXfaLayer:i=!1,keepTextLayer:a=!1,cancelExtraDelay:s=0}={}){super.cancelRendering({cancelExtraDelay:s});if(this.textLayer&&(!a||!this.textLayer.div)){this.textLayer.cancel();this.textLayer=null}if(this.annotationLayer&&(!e||!this.annotationLayer.div)){this.annotationLayer.cancel();this.annotationLayer=null;this._annotationCanvasMap=null}this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null);if(this.annotationEditorLayer&&(!t||!this.annotationEditorLayer.div)){if(this.drawLayer){this.drawLayer.cancel();this.drawLayer=null}this.annotationEditorLayer.cancel();this.annotationEditorLayer=null}if(this.xfaLayer&&(!i||!this.xfaLayer.div)){this.xfaLayer.cancel();this.xfaLayer=null;this._textHighlighter?.disable()}}cssTransform({redrawAnnotationLayer:e=!1,redrawAnnotationEditorLayer:t=!1,redrawXfaLayer:i=!1,redrawTextLayer:a=!1,hideTextLayer:s=!1}){const{canvas:n}=this;if(!n)return;const r=pdf_page_view_classPrivateFieldGet(eP,this);if(this.viewport!==r){const e=(360+this.viewport.rotation-r.rotation)%360;if(90===e||270===e){const{width:t,height:i}=this.viewport,a=i/t,s=t/i;n.style.transform=`rotate(${e}deg) scale(${a},${s})`}else n.style.transform=0===e?"":`rotate(${e}deg)`}e&&this.annotationLayer&&pdf_page_view_assertClassBrand(lP,this,_renderAnnotationLayer).call(this);if(t&&this.annotationEditorLayer){this.drawLayer&&pdf_page_view_assertClassBrand(lP,this,_renderDrawLayer).call(this);pdf_page_view_assertClassBrand(lP,this,_renderAnnotationEditorLayer).call(this)}i&&this.xfaLayer&&pdf_page_view_assertClassBrand(lP,this,_renderXfaLayer).call(this);if(this.textLayer)if(s){this.textLayer.hide();this.structTreeLayer?.hide()}else a&&pdf_page_view_assertClassBrand(lP,this,_renderTextLayer).call(this)}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(e,t){return this.viewport.convertToPdfPoint(e,t)}_ensureCanvasWrapper(){let e=pdf_page_view_classPrivateFieldGet(Kv,this);if(!e){e=pdf_page_view_classPrivateFieldSet(Kv,this,document.createElement("div"));e.classList.add("canvasWrapper");pdf_page_view_assertClassBrand(lP,this,_addLayer).call(this,e,"canvasWrapper")}return e}_getRenderingContext(e,t,i,a){const s=AppOptions.get("pdfBackgroundColor");return{canvas:e,transform:t,viewport:this.viewport,annotationMode:pdf_page_view_classPrivateFieldGet($v,this),optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:this.pageColors,isEditing:pdf_page_view_classPrivateFieldGet(Zv,this),background:s||null,recordOperations:i,recordImages:a}}async draw(){if(this.renderingState!==Pm.INITIAL){ngx_console_NgxConsole.error("Must be in new state before drawing");this.reset()}const{div:e,l10n:t,pdfPage:i,viewport:a}=this;if(!i){this.renderingState=Pm.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=Pm.RUNNING;const s=this._ensureCanvasWrapper();if(!this.textLayer&&pdf_page_view_classPrivateFieldGet(sP,this)!==vh&&!i.isPureXfa){this._accessibilityManager||=new TextAccessibilityManager;this.textLayer=new TextLayerBuilder({pdfPage:i,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:pdf_page_view_classPrivateFieldGet(sP,this)===wh,onAppend:e=>{this.l10n.pause();pdf_page_view_assertClassBrand(lP,this,_addLayer).call(this,e,"textLayer");this.l10n.resume()},abortSignal:pdf_page_view_classPrivateFieldGet(Hv,this)});this.enableSelectionRendering&&this.textLayer.div.classList.add("selectionRendering")}if(!this.annotationLayer&&pdf_page_view_classPrivateFieldGet($v,this)!==p.DISABLE){const{annotationStorage:e,annotationEditorUIManager:t,downloadManager:a,enableComment:s,enableScripting:n,fieldObjectsPromise:r,hasJSActionsPromise:o,linkService:l}=pdf_page_view_classPrivateFieldGet(Qv,this);this._annotationCanvasMap||=new Map;this.annotationLayer=new AnnotationLayerBuilder({pdfPage:i,annotationStorage:e,imageResourcesPath:this.imageResourcesPath,renderForms:pdf_page_view_classPrivateFieldGet($v,this)===p.ENABLE_FORMS,linkService:l,downloadManager:a,enableComment:s,enableScripting:n,hasJSActionsPromise:o,fieldObjectsPromise:r,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:t,commentManager:pdf_page_view_classPrivateFieldGet(Xv,this),onAppend:e=>{pdf_page_view_assertClassBrand(lP,this,_addLayer).call(this,e,"annotationLayer")}})}const{width:n,height:r}=a;pdf_page_view_classPrivateFieldSet(eP,this,a);const{canvas:o,prevCanvas:l}=this._createCanvas(e=>{s.prepend(e)});o.setAttribute("role","presentation");this.outputScale||pdf_page_view_assertClassBrand(lP,this,_computeScale).call(this);const{outputScale:d}=this;pdf_page_view_classPrivateFieldSet(Yv,this,pdf_page_view_classPrivateFieldGet(Jv,this));const c=approximateFraction(d.sx),h=approximateFraction(d.sy);let u=floorToDivide(n*d.sx,c[0]),_=floorToDivide(r*d.sy,h[0]);const g=await MaxCanvasSize.reduceToMaxCanvasSize(u,_);if(g>1){u/=g;u*=.95;_/=g;_*=.95;const e=Math.round(100*(g/.95-1));warn(`Page ${this.id}: Reduced the maximum resolution by ${e}% because the browser can't render larger canvases.`)}o.width=u;o.height=_;const m=floorToDivide(Dh(n),c[1]),f=floorToDivide(Dh(r),h[1]);d.sx=u/m;d.sy=_/f;if(pdf_page_view_classPrivateFieldGet(iP,this)!==c[1]){e.style.setProperty("--scale-round-x",`${c[1]}px`);pdf_page_view_classPrivateFieldSet(iP,this,c[1])}if(pdf_page_view_classPrivateFieldGet(aP,this)!==h[1]){e.style.setProperty("--scale-round-y",`${h[1]}px`);pdf_page_view_classPrivateFieldSet(aP,this,h[1])}const v=this.enableOptimizedPartialRendering&&pdf_page_view_classPrivateFieldGet(Yv,this)&&!this.recordedBBoxes,P=-1!==this.imagesRightClickMinSize&&!this.imageCoordinates,w=d.scaled?[d.sx,0,0,d.sy,0,0]:null,F=o,b=this._drawCanvas(this._getRenderingContext(o,w,v,P),()=>{l?.remove();this.canvas===F&&this._resetCanvas()},e=>{pdf_page_view_classPrivateFieldGet(rP,this).regularAnnotations=!e.separateAnnots;this.dispatchPageRendered(!1,!1)}).then(async()=>{if(this.renderingState!==Pm.FINISHED)return;this.structTreeLayer||=new StructTreeLayerBuilder(i,a.rawDims);const e=this.textLayer?pdf_page_view_assertClassBrand(lP,this,_renderTextLayer).call(this):null;this.annotationLayer&&await pdf_page_view_assertClassBrand(lP,this,_renderAnnotationLayer).call(this,e);this.drawLayer||=new DrawLayerBuilder({pageIndex:this.id,textLayer:this.enableSelectionRendering?this.textLayer?.div:null,filterFactory:this.pdfPage?.filterFactory,pageColors:this.pageColors});await pdf_page_view_assertClassBrand(lP,this,_renderDrawLayer).call(this);this.drawLayer.setParent(s);const{annotationEditorUIManager:n}=pdf_page_view_classPrivateFieldGet(Qv,this);if(n&&(this.annotationLayer||pdf_page_view_classPrivateFieldGet($v,this)===p.DISABLE)){this.annotationEditorLayer||=new AnnotationEditorLayerBuilder({uiManager:n,pageIndex:this.id-1,l10n:t,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:e=>{pdf_page_view_assertClassBrand(lP,this,_addLayer).call(this,e,"annotationEditorLayer")},eventBus:this.eventBus});pdf_page_view_assertClassBrand(lP,this,_renderAnnotationEditorLayer).call(this)}});if(i.isPureXfa){if(!this.xfaLayer){const{annotationStorage:e,linkService:t}=pdf_page_view_classPrivateFieldGet(Qv,this);this.xfaLayer=new XfaLayerBuilder({pdfPage:i,annotationStorage:e,linkService:t})}pdf_page_view_assertClassBrand(lP,this,_renderXfaLayer).call(this)}e.setAttribute("data-loaded",!0);this.dispatchPageRender();return b}setPageLabel(e){this.pageLabel="string"==typeof e?e:null;this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id}));null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:e,initialOptionalContent:t,regularAnnotations:i}=pdf_page_view_classPrivateFieldGet(rP,this);return e&&t&&i?this.canvas:null}}function _addLayer(e,t){const i=zv.get(t),a=pdf_page_view_classPrivateFieldGet(oP,this)[i];pdf_page_view_classPrivateFieldGet(oP,this)[i]=e;if(a)a.replaceWith(e);else{for(let t=i-1;t>=0;t--){const i=pdf_page_view_classPrivateFieldGet(oP,this)[t];if(i){i.after(e);return}}this.div.prepend(e)}}function _setDimensions(){const{div:e,viewport:t}=this;if(t.userUnit!==pdf_page_view_classPrivateFieldGet(nP,this)){1!==t.userUnit?e.style.setProperty("--user-unit",t.userUnit):e.style.removeProperty("--user-unit");pdf_page_view_classPrivateFieldSet(nP,this,t.userUnit)}if(this.pdfPage){if(pdf_page_view_classPrivateFieldGet(tP,this)===t.rotation)return;pdf_page_view_classPrivateFieldSet(tP,this,t.rotation)}setLayerDimensions(e,t,!0,!1)}function _dispatchLayerRendered(e,t,i){this.eventBus.dispatch(e,{source:this,pageNumber:this.id,error:t,layer:i})}async function _renderAnnotationLayer(e=null){const{annotationLayer:t,textLayer:i}=this;let a=null;try{await this.annotationLayer.render({viewport:this.viewport,intent:"display",structTreeLayer:this.structTreeLayer,optionalContentConfigPromise:this._optionalContentConfigPromise})}catch(e){ngx_console_NgxConsole.error("#renderAnnotationLayer:",e);a=e}finally{pdf_page_view_assertClassBrand(lP,this,_dispatchLayerRendered).call(this,"annotationlayerrendered",a,this.annotationLayer)}pdf_page_view_classPrivateFieldGet(qv,this)&&e&&pdf_page_view_assertClassBrand(lP,this,_injectLinkAnnotations).call(this,e,t,i)}async function _renderAnnotationEditorLayer(){let e=null;try{await this.annotationEditorLayer.render({viewport:this.viewport,intent:"display"})}catch(t){ngx_console_NgxConsole.error("#renderAnnotationEditorLayer:",t);e=t}finally{pdf_page_view_assertClassBrand(lP,this,_dispatchLayerRendered).call(this,"annotationeditorlayerrendered",e,this.annotationEditorLayer)}}async function _renderDrawLayer(){try{await this.drawLayer.render({intent:"display"})}catch(e){ngx_console_NgxConsole.error("#renderDrawLayer:",e)}}async function _renderXfaLayer(){let e=null;try{const e=await this.xfaLayer.render({viewport:this.viewport,intent:"display"});e?.textDivs&&this._textHighlighter&&pdf_page_view_assertClassBrand(lP,this,_buildXfaTextContentItems).call(this,e.textDivs)}catch(t){ngx_console_NgxConsole.error("#renderXfaLayer:",t);e=t}finally{if(this.xfaLayer?.div){this.l10n.pause();pdf_page_view_assertClassBrand(lP,this,_addLayer).call(this,this.xfaLayer.div,"xfaLayer");this.l10n.resume()}pdf_page_view_assertClassBrand(lP,this,_dispatchLayerRendered).call(this,"xfalayerrendered",e,this.xfaLayer)}}async function _renderTextLayer(){let e=null;try{await this.textLayer.render({viewport:this.viewport,images:this.imageCoordinates?new TextLayerImages(this.imagesRightClickMinSize,this.imageCoordinates,this.viewport,()=>this.canvas):null})}catch(t){if(t instanceof AbortException)return;ngx_console_NgxConsole.error("#renderTextLayer:",t);e=t}pdf_page_view_assertClassBrand(lP,this,_dispatchLayerRendered).call(this,"textlayerrendered",e,this.textLayer);pdf_page_view_assertClassBrand(lP,this,_renderStructTreeLayer).call(this)}async function _renderStructTreeLayer(){const e=await(this.structTreeLayer?.render());if(e){this.l10n.pause();this.structTreeLayer?.updateTextLayer();this.canvas&&e.parentNode!==this.canvas&&this.canvas.append(e);this.l10n.resume()}this.structTreeLayer?.show()}async function _buildXfaTextContentItems(e){const t=await this.pdfPage.getTextContent(),i=[];for(const e of t.items)i.push(e.str);this._textHighlighter.setTextMapping(e,i);this._textHighlighter.enable()}async function _injectLinkAnnotations(e,t,i){let a=null;try{await e;if(t!==this.annotationLayer||i!==this.textLayer)return;await t.injectLinkAnnotations(Autolinker.processLinks(this))}catch(e){ngx_console_NgxConsole.error("#injectLinkAnnotations:",e);a=e}pdf_page_view_assertClassBrand(lP,this,_dispatchLayerRendered).call(this,"linkannotationsadded",a)}function _computeScale(){const{width:e,height:t}=this.viewport,i=this.outputScale=new OutputScale;if(0===this.maxCanvasPixels){const e=1/this.scale;i.sx*=e;i.sy*=e;pdf_page_view_classPrivateFieldSet(Jv,this,!0)}else{pdf_page_view_classPrivateFieldSet(Jv,this,i.limitCanvas(e,t,this.maxCanvasPixels,this.maxCanvasDim,this.capCanvasAreaFactor));if(pdf_page_view_classPrivateFieldGet(Jv,this)&&this.enableDetailCanvas){const e=this.enableOptimizedPartialRendering?4:2;i.sx/=e;i.sy/=e}}}function pdf_viewer_classPrivateMethodInitSpec(e,t){pdf_viewer_checkPrivateRedeclaration(e,t),t.add(e)}function pdf_viewer_classPrivateFieldInitSpec(e,t,i){pdf_viewer_checkPrivateRedeclaration(e,t),t.set(e,i)}function pdf_viewer_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function pdf_viewer_classPrivateFieldGet(e,t){return e.get(pdf_viewer_assertClassBrand(e,t))}function pdf_viewer_classPrivateFieldSet(e,t,i){return e.set(pdf_viewer_assertClassBrand(e,t),i),i}function pdf_viewer_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const dP=1e4,cP=5e3,hP=250;function isValidAnnotationEditorMode(e){return Object.values(f).includes(e)&&e!==f.DISABLE}var uP=new WeakMap,_P=new WeakMap,pP=new WeakSet;class PDFPageViewBuffer{constructor(e){pdf_viewer_classPrivateMethodInitSpec(this,pP);pdf_viewer_classPrivateFieldInitSpec(this,uP,new Set);pdf_viewer_classPrivateFieldInitSpec(this,_P,0);pdf_viewer_classPrivateFieldSet(_P,this,e)}push(e){const t=pdf_viewer_classPrivateFieldGet(uP,this);t.has(e)&&t.delete(e);t.add(e);t.size>pdf_viewer_classPrivateFieldGet(_P,this)&&pdf_viewer_assertClassBrand(pP,this,_destroyFirstView).call(this)}resize(e,t=null){pdf_viewer_classPrivateFieldSet(_P,this,e);const i=pdf_viewer_classPrivateFieldGet(uP,this);if(t){const e=i.size;let a=1;for(const s of i){if(t.has(s.id)){i.delete(s);i.add(s)}if(++a>e)break}}for(;i.size>pdf_viewer_classPrivateFieldGet(_P,this);)pdf_viewer_assertClassBrand(pP,this,_destroyFirstView).call(this)}has(e){return pdf_viewer_classPrivateFieldGet(uP,this).has(e)}[Symbol.iterator](){return pdf_viewer_classPrivateFieldGet(uP,this).keys()}}function _destroyFirstView(){const e=pdf_viewer_classPrivateFieldGet(uP,this).keys().next().value;e?.destroy();pdf_viewer_classPrivateFieldGet(uP,this).delete(e)}var gP=new WeakMap,mP=new WeakMap,fP=new WeakMap,vP=new WeakMap,PP=new WeakMap,wP=new WeakMap,FP=new WeakMap,bP=new WeakMap,yP=new WeakMap,SP=new WeakMap,CP=new WeakMap,xP=new WeakMap,kP=new WeakMap,EP=new WeakMap,AP=new WeakMap,GP=new WeakMap,BP=new WeakMap,MP=new WeakMap,IP=new WeakMap,TP=new WeakMap,DP=new WeakMap,LP=new WeakMap,NP=new WeakMap,RP=new WeakMap,OP=new WeakMap,WP=new WeakMap,jP=new WeakMap,VP=new WeakMap,UP=new WeakMap,zP=new WeakMap,HP=new WeakMap,$P=new WeakMap,KP=new WeakMap,XP=new WeakMap,qP=new WeakMap,YP=new WeakMap,ZP=new WeakMap,QP=new WeakMap,JP=new WeakMap,ew=new WeakMap,tw=new WeakMap,iw=new WeakMap,aw=new WeakSet,sw=new WeakMap;class PDFViewer{constructor(e){pdf_viewer_classPrivateMethodInitSpec(this,aw);pdf_viewer_classPrivateFieldInitSpec(this,gP,null);pdf_viewer_classPrivateFieldInitSpec(this,mP,null);pdf_viewer_classPrivateFieldInitSpec(this,fP,null);pdf_viewer_classPrivateFieldInitSpec(this,vP,f.NONE);pdf_viewer_classPrivateFieldInitSpec(this,PP,null);pdf_viewer_classPrivateFieldInitSpec(this,wP,p.ENABLE_FORMS);pdf_viewer_classPrivateFieldInitSpec(this,FP,null);pdf_viewer_classPrivateFieldInitSpec(this,bP,null);pdf_viewer_classPrivateFieldInitSpec(this,yP,null);pdf_viewer_classPrivateFieldInitSpec(this,SP,!1);pdf_viewer_classPrivateFieldInitSpec(this,CP,!1);pdf_viewer_classPrivateFieldInitSpec(this,xP,!1);pdf_viewer_classPrivateFieldInitSpec(this,kP,!1);pdf_viewer_classPrivateFieldInitSpec(this,EP,!0);pdf_viewer_classPrivateFieldInitSpec(this,AP,null);pdf_viewer_classPrivateFieldInitSpec(this,GP,null);pdf_viewer_classPrivateFieldInitSpec(this,BP,0);pdf_viewer_classPrivateFieldInitSpec(this,MP,null);pdf_viewer_classPrivateFieldInitSpec(this,IP,!0);pdf_viewer_classPrivateFieldInitSpec(this,TP,null);pdf_viewer_classPrivateFieldInitSpec(this,DP,null);pdf_viewer_classPrivateFieldInitSpec(this,LP,null);pdf_viewer_classPrivateFieldInitSpec(this,NP,!1);pdf_viewer_classPrivateFieldInitSpec(this,RP,null);pdf_viewer_classPrivateFieldInitSpec(this,OP,0);pdf_viewer_classPrivateFieldInitSpec(this,WP,new ResizeObserver(pdf_viewer_assertClassBrand(aw,this,pdf_viewer_resizeObserverCallback).bind(this)));pdf_viewer_classPrivateFieldInitSpec(this,jP,null);pdf_viewer_classPrivateFieldInitSpec(this,VP,null);pdf_viewer_classPrivateFieldInitSpec(this,UP,null);pdf_viewer_classPrivateFieldInitSpec(this,zP,null);pdf_viewer_classPrivateFieldInitSpec(this,HP,null);pdf_viewer_classPrivateFieldInitSpec(this,$P,!0);pdf_viewer_classPrivateFieldInitSpec(this,KP,Ph);pdf_viewer_classPrivateFieldInitSpec(this,XP,void 0);pdf_viewer_classPrivateFieldInitSpec(this,qP,0);pdf_viewer_classPrivateFieldInitSpec(this,YP,"multiple");pdf_viewer_classPrivateFieldInitSpec(this,ZP,25);pdf_viewer_classPrivateFieldInitSpec(this,QP,.1);pdf_viewer_classPrivateFieldInitSpec(this,JP,null);pdf_viewer_classPrivateFieldInitSpec(this,ew,null);pdf_viewer_classPrivateFieldInitSpec(this,tw,null);pdf_viewer_classPrivateFieldInitSpec(this,iw,null);pdf_viewer_classPrivateFieldInitSpec(this,sw,!1);0;this.container=e.container;this.viewer=e.viewer||e.container.firstElementChild;pdf_viewer_classPrivateFieldSet(JP,this,e.viewerAlert||null);this.eventBus=e.eventBus;this.pageViewMode=e.pageViewMode||"multiple";this.defaultCacheSize=e.defaultCacheSize;pdf_viewer_classPrivateFieldSet(ZP,this,e.maxZoom);pdf_viewer_classPrivateFieldSet(QP,this,e.minZoom);if("DIV"!==this.container?.tagName||"DIV"!==this.viewer?.tagName)throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&"absolute"!==getComputedStyle(this.container).position)throw new Error("The `container` must be absolutely positioned.");pdf_viewer_classPrivateFieldGet(WP,this).observe(this.container);this.linkService=e.linkService||new SimpleLinkService;this.downloadManager=e.downloadManager||null;this.findController=e.findController||null;this.customFindController=e.customFindController||null;pdf_viewer_classPrivateFieldSet(mP,this,e.altTextManager||null);pdf_viewer_classPrivateFieldSet(FP,this,e.commentManager||null);pdf_viewer_classPrivateFieldSet(HP,this,e.signatureManager||null);pdf_viewer_classPrivateFieldSet(yP,this,e.editorUndoBar||null);this.findController&&(this.findController.onIsPageVisible=e=>this._getVisiblePages().ids.has(e));this._scriptingManager=e.scriptingManager||null;pdf_viewer_classPrivateFieldSet(KP,this,e.textLayerMode??Ph);pdf_viewer_classPrivateFieldSet(wP,this,e.annotationMode??p.ENABLE_FORMS);pdf_viewer_classPrivateFieldSet(vP,this,e.annotationEditorMode??f.NONE);pdf_viewer_classPrivateFieldSet(fP,this,e.annotationEditorHighlightColors||null);pdf_viewer_classPrivateFieldSet(SP,this,!0===e.enableHighlightFloatingButton);pdf_viewer_classPrivateFieldSet(xP,this,!0===e.enableUpdatedAddImage);pdf_viewer_classPrivateFieldSet(kP,this,!0===e.enableNewAltTextWhenAddingImage);this.imageResourcesPath=e.imageResourcesPath||"";this.enablePrintAutoRotate=e.enablePrintAutoRotate||!1;this.removePageBorders=e.removePageBorders||!1;this.maxCanvasPixels=e.maxCanvasPixels;this.maxCanvasDim=e.maxCanvasDim;this.capCanvasAreaFactor=e.capCanvasAreaFactor;this.enableDetailCanvas=e.enableDetailCanvas??!0;this.enableOptimizedPartialRendering=e.enableOptimizedPartialRendering??!1;this.enableSelectionRendering=!1!==e.enableSelectionRendering;this.imagesRightClickMinSize=e.imagesRightClickMinSize??-1;this.l10n=e.l10n;this.l10n||=new genericl10n_GenericL10n;pdf_viewer_classPrivateFieldSet(CP,this,e.enablePermissions||!1);this.pageColors=e.pageColors||null;pdf_viewer_classPrivateFieldSet(MP,this,e.mlManager||null);pdf_viewer_classPrivateFieldSet($P,this,!1!==e.supportsPinchToZoom);pdf_viewer_classPrivateFieldSet(EP,this,!1!==e.enableAutoLinking);pdf_viewer_classPrivateFieldSet(BP,this,e.minDurationToUpdateCanvas??500);this._enableFlipByDrag=!0;this.defaultRenderingQueue=!e.renderingQueue;if(this.defaultRenderingQueue){this.renderingQueue=new PDFRenderingQueue;this.renderingQueue.setViewer(this)}else this.renderingQueue=e.renderingQueue;const{abortSignal:t}=e;pdf_viewer_classPrivateFieldSet(AP,this,t||null);t?.addEventListener("abort",()=>{pdf_viewer_classPrivateFieldGet(WP,this).disconnect();pdf_viewer_classPrivateFieldSet(WP,this,null)},{once:!0});this.scroll=watchScroll(this.container,this._scrollUpdate.bind(this),t);this.presentationModeState=lh;this._resetView();this.removePageBorders&&this.viewer.classList.add("removePageBorders");pdf_viewer_assertClassBrand(aw,this,_updateContainerHeightCss).call(this);this.eventBus.on("thumbnailrendered",({pageNumber:e,pdfPage:t})=>{const i=this._pages[e-1];pdf_viewer_classPrivateFieldGet(gP,this).has(i)||t?.cleanup()},Nh);e.l10n||this.l10n.translate(this.container);this.cspPolicyService=e.cspPolicyService}get maxZoom(){return pdf_viewer_classPrivateFieldGet(ZP,this)}set maxZoom(e){pdf_viewer_classPrivateFieldSet(ZP,this,e)}get minZoom(){return pdf_viewer_classPrivateFieldGet(QP,this)}set minZoom(e){pdf_viewer_classPrivateFieldSet(QP,this,e)}setTextLayerMode(e){pdf_viewer_classPrivateFieldSet(KP,this,e)}get pageViewMode(){return pdf_viewer_classPrivateFieldGet(YP,this)}set pageViewMode(e){if(pdf_viewer_classPrivateFieldGet(YP,this)!==e){const t=this._currentPageNumber;pdf_viewer_classPrivateFieldSet(YP,this,e);pdf_viewer_classPrivateFieldSet(XP,this,void 0);"infinite-scroll"===e&&pdf_viewer_assertClassBrand(aw,this,_initOuterScrollListener).call(this);this.eventBus.dispatch("pageviewmodechanged",{source:this,pageViewMode:e});if("infinite-scroll"===e&&t>1){pdf_viewer_classPrivateFieldSet(qP,this,Date.now());setTimeout(()=>{pdf_viewer_classPrivateFieldSet(qP,this,Date.now());pdf_viewer_assertClassBrand(aw,this,_scrollIntoView).call(this,this._pages[t-1])},200)}}}get printingAllowed(){return pdf_viewer_classPrivateFieldGet(IP,this)}get pagesCount(){return this._pages.length}getPageView(e){return this._pages[e]}swapPages(e,t){const i=this._pages[e].pdfPage,a=this._pages[t].pdfPage;this._pages[e].setPdfPage(a);this._pages[t].setPdfPage(i);this.refresh()}getCachedPageViews(){return new Set(pdf_viewer_classPrivateFieldGet(gP,this))}get pageViewsReady(){return this._pages.every(e=>e?.pdfPage)}clearSelection(){const e=document.getSelection();if(e&&!e.isCollapsed)for(let t=0,i=e.rangeCount;t<i;t++)if(e.getRangeAt(t).intersectsNode(this.viewer)){e.removeAllRanges?.();e.empty?.();return}}get renderForms(){return pdf_viewer_classPrivateFieldGet(wP,this)===p.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(e){if(!Number.isInteger(e))throw new Error("Invalid page number.");if(!this.pdfDocument)return;const t=this._currentPageNumber!==e,i=t&&Math.abs(this._currentPageNumber-e)<=2;this._currentPageNumber!==e&&this.clearSelection();this._setCurrentPageNumber(e,!0)||ngx_console_NgxConsole.error(`currentPageNumber: "${e}" is not a valid page.`);if(this.pageFlip&&t){i?this.pageFlip.flip(e-1):this.pageFlip.turnToPage(e-1);this.ensureAdjacentPagesAreLoaded()}}hidePagesDependingOnpageViewMode(){"book"===this.pageViewMode&&(this.pageFlip||setTimeout(()=>{if(!this.pageFlip){const e=this._pages[0].div,t=e.parentElement,i=t.parentElement;i.style.width=2*e.clientWidth+"px";i.style.overflow="hidden";i.style.marginLeft="auto";i.style.marginRight="auto";this.pageFlip=new PageFlip(t,{width:e.clientWidth,height:e.clientHeight,showCover:!0,size:"fixed",enableFlipByDrag:this._enableFlipByDrag},this.cspPolicyService);this.pageFlip.loadFromHTML(this.container.querySelectorAll(".page"));this.pageFlip.on("flip",e=>{this._currentPageNumber!==e.data+1&&this._setCurrentPageNumber(e.data+1,!1)})}},100))}async _setCurrentPageNumber(e,t=!1){if(this._currentPageNumber===e){t&&pdf_viewer_assertClassBrand(aw,this,_resetCurrentPageView).call(this);return!0}if(!(0<e&&e<=this.pagesCount))return!1;const i=this._currentPageNumber;this._currentPageNumber=e;this.hidePagesDependingOnpageViewMode();if("book"===this.pageViewMode||"infinite-scroll"===this.pageViewMode){const e=this._pages[this.currentPageNumber-1];if(e.div.parentElement.classList.contains("spread"))e.div.parentElement.childNodes.forEach(async e=>{const t=Number(e.getAttribute("data-page-number")),i=this._pages[t-1];await pdf_viewer_assertClassBrand(aw,this,pdf_viewer_ensurePdfPageLoaded).call(this,i);this.renderingQueue.renderView(i);e.style.display="inline-block"});else{await pdf_viewer_assertClassBrand(aw,this,pdf_viewer_ensurePdfPageLoaded).call(this,e);this.renderingQueue.renderView(e);"book"===pdf_viewer_classPrivateFieldGet(YP,this)&&this.ensureAdjacentPagesAreLoaded()}}this.eventBus.dispatch("pagechanging",{source:this,pageNumber:e,pageLabel:this._pageLabels?.[e-1]??null,previous:i});t&&pdf_viewer_assertClassBrand(aw,this,_resetCurrentPageView).call(this);return!0}addPageToRenderQueue(e=0){if(e>=0&&e<=this._pages.length-1){const t=this._pages[e];if(t.renderingState===Pm.INITIAL){pdf_viewer_assertClassBrand(aw,this,pdf_viewer_ensurePdfPageLoaded).call(this,t).then(()=>{this.renderingQueue.renderView(t)});return!0}}return!1}async ensureAdjacentPagesAreLoaded(){const e=[0,1,-1,2,-2,-3];let t=0;this.currentPageNumber%2==1&&(t=-1);let i=!1;for(const a of e){const e=this.currentPageNumber+a+t;if(e>=0&&e<this._pages.length)try{const t=this._pages[e];await pdf_viewer_assertClassBrand(aw,this,pdf_viewer_ensurePdfPageLoaded).call(this,t);if(this._pages.some(e=>e.renderingState===Pm.RUNNING||e.renderingState===Pm.PAUSED)||i){const loader=()=>this.adjacentPagesRenderer(loader,e);this.eventBus._on("pagerendered",loader);this.eventBus._on("thumbnailRendered",loader)}else i=this.adjacentPagesRenderer(null,e)}catch(t){ngx_console_NgxConsole.log("Exception during pre-rendering page %s",e,t)}}}adjacentPagesRenderer(e,t){if(this._pages.find(e=>e.renderingState===Pm.RUNNING))return!0;const i=this._pages.find(e=>e.renderingState===Pm.PAUSED);if(i){this.renderingQueue.renderView(i);return!0}if(e){this.eventBus._off("pagerendered",e);this.eventBus._off("thumbnailRendered",e)}if(t>=0&&t<this._pages.length){const e=this._pages[t];if(e.renderingState===Pm.INITIAL){this.renderingQueue.renderView(e);return!0}}return!1}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(e){if(!this.pdfDocument)return;let t=0|e;if(this._pageLabels){const i=this._pageLabels.indexOf(e);i>=0&&(t=i+1)}this._currentPageNumber!==t&&this.clearSelection();this._setCurrentPageNumber(t,!0)||ngx_console_NgxConsole.error(`currentPageLabel: "${e}" is not a valid page.`)}get currentScale(){return 0!==this._currentScale?this._currentScale:1}set currentScale(e){if(isNaN(e))throw new Error("Invalid numeric scale.");this.pdfDocument&&pdf_viewer_assertClassBrand(aw,this,_setScale).call(this,e,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(e){this.pdfDocument&&pdf_viewer_assertClassBrand(aw,this,_setScale).call(this,e,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!isValidRotation(e))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;(e%=360)<0&&(e+=360);if(this._pagesRotation===e)return;this.clearSelection();this._pagesRotation=e;const t=this._currentPageNumber;this.refresh(!0,{rotation:e});this._currentScaleValue&&pdf_viewer_assertClassBrand(aw,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:e,pageNumber:t});this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}get _layerProperties(){const e=this;return shadow(this,"_layerProperties",{get annotationEditorUIManager(){return pdf_viewer_classPrivateFieldGet(PP,e)},get annotationStorage(){return e.pdfDocument?.annotationStorage},get downloadManager(){return e.downloadManager},get enableComment(){return!!pdf_viewer_classPrivateFieldGet(FP,e)},get enableScripting(){return!!e._scriptingManager},get fieldObjectsPromise(){return e.pdfDocument?.getFieldObjects()},get findController(){return e.findController},get customFindController(){return e.customFindController},get hasJSActionsPromise(){return e.pdfDocument?.hasJSActions()},get linkService(){return e.linkService}})}async getAllText(e=null){const t=[],i=[];for(let a=1,s=this.pdfDocument.numPages;a<=s;++a){if(e?.aborted)return null;i.length=0;const s=await this.pdfDocument.getPage(a),{items:n}=await s.getTextContent();for(const e of n){e.str&&i.push(e.str);e.hasEOL&&i.push("\n")}t.push(removeNullCharacters(i.join("")))}return t.join("\n")}setDocument(e){if(this.pdfDocument){this.eventBus.dispatch("pagesdestroy",{source:this});this._cancelRendering();this._resetView();this.findController?.setDocument(null);this.customFindController?.setDocument(null);this._scriptingManager?.setDocument(null);pdf_viewer_classPrivateFieldGet(PP,this)?.destroy();pdf_viewer_classPrivateFieldSet(PP,this,null);pdf_viewer_classPrivateFieldSet(vP,this,f.NONE);pdf_viewer_classPrivateFieldSet(IP,this,!0)}this.pdfDocument=e;if(!e)return;const t=e.numPages,i=e.getPage(1),a=e.getOptionalContentConfig({intent:"display"}),s=pdf_viewer_classPrivateFieldGet(CP,this)?e.getPermissions():Promise.resolve(),{eventBus:n,pageColors:r,viewer:o}=this;pdf_viewer_classPrivateFieldSet(GP,this,new AbortController);const{signal:l}=pdf_viewer_classPrivateFieldGet(GP,this),d={signal:l,...Nh};if(t>dP){ngx_console_NgxConsole.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const e=this._scrollMode=Fh.PAGE;n.dispatch("scrollmodechanged",{source:this,mode:e})}this._pagesCapability.promise.then(()=>{n.dispatch("pagesloaded",{source:this,pagesCount:t})},()=>{});n.on("pagerender",e=>{const t=this._pages[e.pageNumber-1];t&&pdf_viewer_classPrivateFieldGet(gP,this).push(t)},d);const onAfterDraw=e=>{if(!e.cssTransform&&!e.isDetailView){this._onePageRenderedCapability.resolve({timestamp:e.timestamp});n.off("pagerendered",onAfterDraw)}};n.on("pagerendered",onAfterDraw,d);Promise.all([i,s]).then(([i,s])=>{if(e!==this.pdfDocument)return;this._firstPageCapability.resolve(i);this._optionalContentConfigPromise=a;const{annotationEditorMode:d,annotationMode:c,textLayerMode:h}=pdf_viewer_assertClassBrand(aw,this,_initializePermissions).call(this,s);if(h!==vh){const e=pdf_viewer_classPrivateFieldSet(RP,this,document.createElement("div"));e.id="hiddenCopyElement";e.style.cssText="position:absolute;top:0;left:0;width:0;height:0;display:none";o.before(e)}if(d!==f.DISABLE){const t=d;if(e.isPureXfa)ngx_console_NgxConsole.warn("Warning: XFA-editing is not implemented.");else if(isValidAnnotationEditorMode(t)){pdf_viewer_classPrivateFieldSet(PP,this,new AnnotationEditorUIManager(this.container,o,pdf_viewer_classPrivateFieldGet(JP,this),pdf_viewer_classPrivateFieldGet(mP,this),pdf_viewer_classPrivateFieldGet(FP,this),pdf_viewer_classPrivateFieldGet(HP,this),n,e,r,pdf_viewer_classPrivateFieldGet(fP,this),pdf_viewer_classPrivateFieldGet(SP,this),pdf_viewer_classPrivateFieldGet(xP,this),pdf_viewer_classPrivateFieldGet(kP,this),pdf_viewer_classPrivateFieldGet(MP,this),pdf_viewer_classPrivateFieldGet(yP,this),pdf_viewer_classPrivateFieldGet($P,this)));n.dispatch("annotationeditoruimanager",{source:this,uiManager:pdf_viewer_classPrivateFieldGet(PP,this)});if(t!==f.NONE){pdf_viewer_assertClassBrand(aw,this,_preloadEditingData).call(this,t);pdf_viewer_classPrivateFieldGet(PP,this).updateMode(t)}}else ngx_console_NgxConsole.error(`Invalid AnnotationEditor mode: ${t}`)}const u=this._scrollMode===Fh.PAGE?null:o,_=this.currentScale,p=i.getViewport({scale:_*PixelsPerInch.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",p.scale);r?.background&&o.style.setProperty("--page-bg-color",r.background);if("CanvasText"===r?.foreground||"Canvas"===r?.background){o.style.setProperty("--hcm-highlight-filter",e.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight"));o.style.setProperty("--hcm-highlight-selected-filter",e.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText"))}for(let e=1;e<=t;++e){const t=new PDFPageView({container:u,eventBus:n,id:e,scale:_,defaultViewport:p.clone(),optionalContentConfigPromise:a,renderingQueue:this.renderingQueue,textLayerMode:h,annotationMode:c,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,enableSelectionRendering:this.enableSelectionRendering,imagesRightClickMinSize:this.imagesRightClickMinSize,pageColors:r,l10n:this.l10n,layerProperties:this._layerProperties,enableAutoLinking:pdf_viewer_classPrivateFieldGet(EP,this),minDurationToUpdateCanvas:pdf_viewer_classPrivateFieldGet(BP,this),commentManager:pdf_viewer_classPrivateFieldGet(FP,this),abortSignal:pdf_viewer_classPrivateFieldGet(AP,this)});this._pages.push(t)}this._pages[0]?.setPdfPage(i);this._scrollMode===Fh.PAGE?pdf_viewer_assertClassBrand(aw,this,_ensurePageViewVisible).call(this):this._spreadMode!==bh.NONE&&this._updateSpreadMode();n.on("annotationeditorlayerrendered",e=>{pdf_viewer_classPrivateFieldGet(PP,this)&&n.dispatch("annotationeditormodechanged",{source:this,mode:pdf_viewer_classPrivateFieldGet(vP,this)})},{once:!0,signal:l,...Nh});pdf_viewer_assertClassBrand(aw,this,_onePageRenderedOrForceFetch).call(this,l).then(async()=>{if(e!==this.pdfDocument)return;this.findController?.setDocument(e);this.customFindController?.setDocument(e);this._scriptingManager?.setDocument(e);pdf_viewer_classPrivateFieldGet(RP,this)&&document.addEventListener("copy",pdf_viewer_assertClassBrand(aw,this,_copyCallback).bind(this,h),{signal:l});if(e.loadingParams.disableAutoFetch||t>cP){this._pagesCapability.resolve();return}let i=t-1;if(i<=0)this._pagesCapability.resolve();else{"book"===pdf_viewer_classPrivateFieldGet(YP,this)&&await this.ensureAdjacentPagesAreLoaded();for(let a=2;a<=t;++a){const t=e.getPage(a).then(e=>{const t=this._pages[a-1];t.pdfPage||t.setPdfPage(e);0===--i&&this._pagesCapability.resolve()},e=>{ngx_console_NgxConsole.error(`Unable to get page ${a} to initialize viewer`,e);0===--i&&this._pagesCapability.resolve()});a%hP===0&&await t}}});this.hidePagesDependingOnpageViewMode();n.dispatch("pagesinit",{source:this});e.getMetadata().then(({info:t})=>{e===this.pdfDocument&&t.Language&&(o.lang=t.Language)});this.defaultRenderingQueue&&this.update()}).catch(e=>{ngx_console_NgxConsole.error("Unable to initialize viewer",e);this._pagesCapability.reject(e)})}onPagesEdited({pagesMapper:e,type:t,hasBeenCut:i,pageNumbers:a}){if("copy"===t){pdf_viewer_classPrivateFieldSet(ew,this,new Map);for(const e of a)pdf_viewer_classPrivateFieldGet(ew,this).set(e,this._pages[e-1]);return}if("cancelCopy"===t){pdf_viewer_classPrivateFieldSet(ew,this,null);return}if("cut"===t||"delete"===t){pdf_viewer_classPrivateFieldSet(tw,this,this._pages);pdf_viewer_classPrivateFieldSet(iw,this,a)}if("cancelDelete"===t){pdf_viewer_classPrivateFieldSet(iw,this,null);if(!pdf_viewer_classPrivateFieldGet(tw,this))return;const e=this._scrollMode===Fh.PAGE?null:this.viewer;if(e){pdf_viewer_classPrivateFieldGet(PP,this)?.startUpdatePages();const t=document.createDocumentFragment();for(let e=0,i=pdf_viewer_classPrivateFieldGet(tw,this).length;e<i;e++){const i=pdf_viewer_classPrivateFieldGet(tw,this)[e];i.updatePageNumber(e+1);t.append(i.div)}e.replaceChildren(t);pdf_viewer_classPrivateFieldGet(PP,this)?.endUpdatePages()}this._pages=pdf_viewer_classPrivateFieldGet(tw,this);pdf_viewer_classPrivateFieldSet(tw,this,null);return}if("cleanSavedData"===t){if(pdf_viewer_classPrivateFieldGet(iw,this)){if(pdf_viewer_classPrivateFieldGet(tw,this)){for(const e of pdf_viewer_classPrivateFieldGet(iw,this))pdf_viewer_classPrivateFieldGet(tw,this)[e-1].deleteMe();pdf_viewer_classPrivateFieldSet(tw,this,null)}pdf_viewer_classPrivateFieldSet(iw,this,null)}return}this._currentPageNumber=0;const s=this._pages,n=this._pages=[];pdf_viewer_classPrivateFieldGet(PP,this)?.startUpdatePages();for(let t=1,a=e.pagesNumber;t<=a;t++){const a=e.getPrevPageNumber(t);if(a<0){let e=pdf_viewer_classPrivateFieldGet(ew,this).get(-a);if(i)e.updatePageNumber(t);else{pdf_viewer_classPrivateFieldGet(PP,this)?.clonePage(-a-1,t-1);e=e.clone(t)}n.push(e);continue}const r=s[a-1];n.push(r);r.updatePageNumber(t)}pdf_viewer_classPrivateFieldGet(PP,this)?.endUpdatePages();"paste"===t&&pdf_viewer_classPrivateFieldSet(ew,this,null);const r=this._scrollMode===Fh.PAGE?null:this.viewer;if(r){const e=document.createDocumentFragment();for(const{div:t}of n)e.append(t);r.replaceChildren(e)}setTimeout(()=>{this.forceRendering()})}setPageLabels(e){if(this.pdfDocument){if(e)if(Array.isArray(e)&&this.pdfDocument.numPages===e.length)this._pageLabels=e;else{this._pageLabels=null;ngx_console_NgxConsole.error("setPageLabels: Invalid page labels.")}else this._pageLabels=null;for(let e=0,t=this._pages.length;e<t;e++)this._pages[e].setPageLabel(this._pageLabels?.[e]??null)}}_resetView(){this._pages=[];this._currentPageNumber=1;this._currentScale=0;this._currentScaleValue=null;this._pageLabels=null;const e=this.defaultCacheSize||10;pdf_viewer_classPrivateFieldSet(gP,this,new PDFPageViewBuffer(e));this._location=null;this._pagesRotation=0;this._optionalContentConfigPromise=null;this._firstPageCapability=Promise.withResolvers();this._onePageRenderedCapability=Promise.withResolvers();this._pagesCapability=Promise.withResolvers();this._scrollMode=Fh.VERTICAL;this._previousScrollMode=Fh.UNKNOWN;this._spreadMode=bh.NONE;pdf_viewer_classPrivateFieldSet(jP,this,{previousPageNumber:1,scrollDown:!0,pages:[]});pdf_viewer_classPrivateFieldGet(GP,this)?.abort();pdf_viewer_classPrivateFieldSet(GP,this,null);this.viewer.textContent="";this._updateScrollMode();this.viewer.removeAttribute("lang");pdf_viewer_classPrivateFieldGet(RP,this)?.remove();pdf_viewer_classPrivateFieldSet(RP,this,null);pdf_viewer_assertClassBrand(aw,this,_cleanupTimeouts).call(this);pdf_viewer_assertClassBrand(aw,this,_cleanupSwitchAnnotationEditorMode).call(this)}_scrollUpdate(){if(0!==this.pagesCount){pdf_viewer_classPrivateFieldGet(TP,this)&&clearTimeout(pdf_viewer_classPrivateFieldGet(TP,this));pdf_viewer_classPrivateFieldSet(TP,this,setTimeout(()=>{pdf_viewer_classPrivateFieldSet(TP,this,null);this.update()},100));"infinite-scroll"===this.pageViewMode?this.update(!0):this.update()}}scrollPagePosIntoView(e,t){const i=this._pages[e-1].div;if(t){const a={...t};if("string"==typeof a.top&&a.top.endsWith("%")){const e=Number(a.top.replace("%","")),t=this.viewer.querySelector(".page")?.clientHeight;let s=i.clientHeight??t;const n=this.viewer.parentElement.clientHeight;s=Math.max(0,s-n);a.top=e*s/100}if("string"==typeof a.left&&a.left.endsWith("%")){const e=Number(a.left.replace("%","")),t=this.viewer.querySelector(".page")?.clientWidth,s=i.clientWidth??t;a.left=e*s/100}pdf_viewer_assertClassBrand(aw,this,_scrollIntoView).call(this,{div:i,id:e},a)}else pdf_viewer_assertClassBrand(aw,this,_scrollIntoView).call(this,{div:i,id:e})}pageLabelToPageNumber(e){if(!this._pageLabels)return null;const t=this._pageLabels.indexOf(e);return t<0?null:t+1}scrollPageIntoView({pageNumber:e,destArray:t=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:a=!1,center:s=null}){if(!this.pdfDocument)return;const n=Number.isInteger(e)&&this._pages[e-1];if(!n){ngx_console_NgxConsole.error(`scrollPageIntoView: "${e}" is not a valid pageNumber parameter.`);return}if(this.isInPresentationMode||!t){this._setCurrentPageNumber(e,!0);return}let r,o,l=0,d=0,c=0,h=0;const u=n.rotation%180!=0,_=(u?n.height:n.width)/n.scale/PixelsPerInch.PDF_TO_CSS_UNITS,p=(u?n.width:n.height)/n.scale/PixelsPerInch.PDF_TO_CSS_UNITS;let g=0;switch(t[1].name){case"XYZ":l=t[2];d=t[3];g=t[4];l=null!==l?l:0;d=null!==d?d:p;break;case"Fit":case"FitB":g="page-fit";break;case"FitH":case"FitBH":d=t[2];g="page-width";if(null===d&&this._location){l=this._location.left;d=this._location.top}else("number"!=typeof d||d<0)&&(d=p);break;case"FitV":case"FitBV":l=t[2];c=_;h=p;g="page-height";break;case"FitR":l=t[2];d=t[3];c=t[4]-l;h=t[5]-d;let e=40,i=5;this.removePageBorders&&(e=i=0);r=(this.container.clientWidth-e)/c/PixelsPerInch.PDF_TO_CSS_UNITS;o=(this.container.clientHeight-i)/h/PixelsPerInch.PDF_TO_CSS_UNITS;g=Math.min(Math.abs(r),Math.abs(o));break;default:ngx_console_NgxConsole.error(`scrollPageIntoView: "${t[1].name}" is not a valid destination type.`);return}a||(g&&g!==this._currentScale?this.currentScaleValue=g:0===this._currentScale&&(this.currentScaleValue="auto"));pdf_viewer_assertClassBrand(aw,this,pdf_viewer_ensurePdfPageLoaded).call(this,n).then(()=>{this.renderingQueue.renderView(n);"single"===this.pageViewMode&&this.currentPageNumber!==e&&(this.currentPageNumber=e)});if("page-fit"===g&&!t[4]){pdf_viewer_assertClassBrand(aw,this,_scrollIntoView).call(this,n);return}const m=[n.viewport.convertToViewportPoint(l,d),n.viewport.convertToViewportPoint(l+c,d+h)];let f=Math.min(m[0][0],m[1][0]),v=Math.min(m[0][1],m[1][1]);if(s){"both"!==s&&"vertical"!==s||(v-=(this.container.clientHeight-Math.abs(m[1][1]-m[0][1]))/2);"both"!==s&&"horizontal"!==s||(f-=(this.container.clientWidth-Math.abs(m[1][0]-m[0][0]))/2)}else if(!i){f=Math.max(f,0);v=Math.max(v,0)}pdf_viewer_assertClassBrand(aw,this,_scrollIntoView).call(this,n,{left:f,top:v})}_updateLocation(e){const t=this._currentScale,i=this._currentScaleValue,a=parseFloat(i)===t?Math.round(1e4*t)/100:i,s=e.id,n=this._pages[s-1],r=this.container;let o,l;if("infinite-scroll"===this.pageViewMode){const e=r.getBoundingClientRect();pdf_viewer_classPrivateFieldGet(XP,this)||pdf_viewer_classPrivateFieldSet(XP,this,pdf_viewer_assertClassBrand(aw,this,_findAncestorWithScrollbar).call(this,this.container));const t=pdf_viewer_classPrivateFieldGet(XP,this);if(t){const i=t.getBoundingClientRect();o=i.left-e.left;l=i.top-e.top}else{o=-e.left;l=-e.top}}else{o=r.scrollLeft;l=r.scrollTop}const d=n.getPagePoint(o-e.x,l-e.y),c=Math.round(d[0]),h=Math.round(d[1]);let u=`#page=${s}`;this.isInPresentationMode||(u+=`&zoom=${a},${c},${h}`);this._location={pageNumber:s,scale:a,top:h,left:c,rotation:this._pagesRotation,pdfOpenParams:u}}update(e=!1){this.scrollMode===Fh.PAGE?this.viewer.classList.add("singlePageView"):this.viewer.classList.remove("singlePageView");const t=this._getVisiblePages(),i=t.views,a=i.length;if(0===a)return;const s=this.defaultCacheSize||10,n=Math.max(s,2*a+1);pdf_viewer_classPrivateFieldGet(gP,this).resize(n,t.ids);for(const{view:e,visibleArea:t}of i)e.updateVisibleArea(t);for(const e of pdf_viewer_classPrivateFieldGet(gP,this))t.ids.has(e.id)||e.updateVisibleArea(null);this.renderingQueue.renderHighestPriority(t);const r=this._spreadMode===bh.NONE&&(this._scrollMode===Fh.PAGE||this._scrollMode===Fh.VERTICAL),o=this._currentPageNumber;let l=!1;for(const e of i){if(e.percent<100)break;if(e.id===o&&r){l=!0;break}}const d="infinite-scroll"===this.pageViewMode&&Date.now()-pdf_viewer_classPrivateFieldGet(qP,this)<500;this.scrollMode===Fh.PAGE||e||d||this._setCurrentPageNumber(l?this._currentPageNumber:i[0].id);this._updateLocation(t.first);this.eventBus.dispatch("updateviewarea",{source:this,location:this._location});this.hidePagesDependingOnpageViewMode()}async updateBookModeScale(e){if("book"===this.pageViewMode&&this.pageFlip&&e.scale&&e.scale!==e.previousScale){const t=this._pages[0];if(t.pdfPage){const e=t.width,i=t.height,a=t.div.parentElement,s=this.removePageBorders?1:40;a.style.width=`${2*e+s}px`;a.style.height=`${i}px`;this.pageFlip.render.setting.width=e;this.pageFlip.render.setting.height=i;this.pageFlip.render.update()}if(this._enableFlipByDrag){let i=40,a=5;this.removePageBorders&&(i=a=0);const s=(this.container.clientWidth-i)/t.width*t.scale/2,n=(this.container.clientHeight-a)/t.height*t.scale,r=Math.min(s,n),o=e.scale>r+.01;this.pageFlip.setting.enableFlipByDrag=!o}}}set enableFlipByDrag(e){this._enableFlipByDrag=e;this.pageFlip&&(this.pageFlip.setting.enableFlipByDrag=e)}get enableFlipByDrag(){return this._enableFlipByDrag}containsElement(e){return this.container.contains(e)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===hh}get isChangingPresentationMode(){return this.presentationModeState===ch}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){const e=this._scrollMode===Fh.PAGE?pdf_viewer_classPrivateFieldGet(jP,this).pages:this._pages,t=this._scrollMode===Fh.HORIZONTAL,i=t&&this._isContainerRtl;return this._isContainerRtl&&(t||this._scrollMode===Fh.WRAPPED)?this._getVisiblePagesRtl(e):"infinite-scroll"===this.pageViewMode?pdf_viewer_assertClassBrand(aw,this,_getVisiblePagesInfiniteScroll).call(this,e):getVisibleElements({scrollEl:this.container,views:e,sortByVisibility:!0,horizontal:t,rtl:i})}_getVisiblePagesRtl(e){const t=this.container.getBoundingClientRect(),i=[],a=new Set;for(const s of e){const e=s.div.getBoundingClientRect(),n=Math.max(e.left,t.left),r=Math.min(e.right,t.right),o=Math.max(e.top,t.top),l=Math.min(e.bottom,t.bottom),d=Math.max(0,r-n),c=Math.max(0,l-o);if(0===d||0===c)continue;const h=d/e.width,u=h*(c/e.height)*100|0;i.push({id:s.id,x:e.left-t.left,y:e.top-t.top,view:s,percent:u,widthPercent:100*h|0});a.add(s.id)}i.sort((e,t)=>t.x-e.x);return{first:i[0],last:i.at(-1),views:i,ids:a}}cleanup(){for(const e of this._pages)e.renderingState!==Pm.FINISHED&&e.reset()}_cancelRendering(){for(const e of this._pages)e.cancelRendering()}forceRendering(e){const t=e||this._getVisiblePages(),i=pdf_viewer_assertClassBrand(aw,this,pdf_viewer_getScrollAhead).call(this,t),a=this._spreadMode!==bh.NONE&&this._scrollMode!==Fh.HORIZONTAL,s=null!==pdf_viewer_classPrivateFieldGet(VP,this)||null!==pdf_viewer_classPrivateFieldGet(TP,this)&&t.views.some(e=>e.detailView?.renderingCancelled),n=this.renderingQueue.getHighestPriority(t,this._pages,i,a,s);if(n){pdf_viewer_assertClassBrand(aw,this,pdf_viewer_ensurePdfPageLoaded).call(this,n).then(()=>{this.renderingQueue.renderView(n)});return!0}return!1}get hasEqualPageSizes(){const e=this._pages[0];for(let t=1,i=this._pages.length;t<i;++t){const i=this._pages[t];if(i.width!==e.width||i.height!==e.height)return!1}return!0}getPagesOverview(){let e;return this._pages.map(t=>{const i=t.pdfPage.getViewport({scale:1}),a=isPortraitOrientation(i);if(void 0===e)e=a;else if(this.enablePrintAutoRotate&&a!==e)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}})}get optionalContentConfigPromise(){if(!this.pdfDocument)return Promise.resolve(null);if(!this._optionalContentConfigPromise){ngx_console_NgxConsole.error("optionalContentConfigPromise: Not initialized yet.");return this.pdfDocument.getOptionalContentConfig({intent:"display"})}return this._optionalContentConfigPromise}set optionalContentConfigPromise(e){if(!(e instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${e}`);if(this.pdfDocument&&this._optionalContentConfigPromise){this._optionalContentConfigPromise=e;this.refresh(!1,{optionalContentConfigPromise:e});this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:e})}}get scrollMode(){return this._scrollMode}set scrollMode(e){if(this._scrollMode!==e){if(!isValidScrollMode(e))throw new Error(`Invalid scroll mode: ${e}`);if(!(this.pagesCount>dP)){this._previousScrollMode=this._scrollMode;this.clearSelection();this._scrollMode=e;this.eventBus.dispatch("scrollmodechanged",{source:this,mode:e});if(e===Fh.PAGE&&"infinite-scroll"===pdf_viewer_classPrivateFieldGet(YP,this)){pdf_viewer_classPrivateFieldSet(YP,this,"single");this.hidePagesDependingOnpageViewMode();queueMicrotask(()=>{this.eventBus.dispatch("pageviewmodechanged",{source:this,mode:pdf_viewer_classPrivateFieldGet(YP,this)})})}this._updateScrollMode(this._currentPageNumber)}}}_updateScrollMode(e=null){const t=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",t===Fh.HORIZONTAL);i.classList.toggle("scrollWrapped",t===Fh.WRAPPED);if(this.pdfDocument&&e){t===Fh.PAGE?pdf_viewer_assertClassBrand(aw,this,_ensurePageViewVisible).call(this):this._previousScrollMode===Fh.PAGE&&this._updateSpreadMode();this._currentScaleValue&&isNaN(this._currentScaleValue)&&pdf_viewer_assertClassBrand(aw,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});this._setCurrentPageNumber(e,!0);this.update()}}get spreadMode(){return this._spreadMode}set spreadMode(e){if(this._spreadMode!==e){if(!isValidSpreadMode(e))throw new Error(`Invalid spread mode: ${e}`);this.clearSelection();this._spreadMode=e;this.eventBus.dispatch("spreadmodechanged",{source:this,mode:e});this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(e=null){if(!this.pdfDocument)return;const t=this.viewer,i=this._pages;if(this._scrollMode===Fh.PAGE)pdf_viewer_assertClassBrand(aw,this,_ensurePageViewVisible).call(this);else{t.textContent="";if(this._spreadMode===bh.NONE)for(const e of this._pages)t.append(e.div);else{const e=this._spreadMode-1;let a=null;for(let s=0,n=i.length;s<n;++s){if(null===a){a=document.createElement("div");a.className="spread";t.append(a)}else if(s%2===e){a=a.cloneNode(!1);t.append(a)}a.append(i[s].div)}}}this.hidePagesDependingOnpageViewMode();if(e){this._currentScaleValue&&isNaN(this._currentScaleValue)&&pdf_viewer_assertClassBrand(aw,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});this._setCurrentPageNumber(e,!0);this.update()}}nextPage(){const e=this._currentPageNumber,t=this.pagesCount;if(e>=t)return!1;const i=pdf_viewer_assertClassBrand(aw,this,_getPageAdvance).call(this,e,!1)||1;this.currentPageNumber=Math.min(e+i,t);return!0}previousPage(){const e=this._currentPageNumber;if(e<=1)return!1;const t=pdf_viewer_assertClassBrand(aw,this,_getPageAdvance).call(this,e,!0)||1;this.currentPageNumber=Math.max(e-t,1);return!0}updateScale({drawingDelay:e,scaleFactor:t=null,steps:i=null,origin:a}){if(null===i&&null===t)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let s=this._currentScale;if(t>0&&1!==t)s=Math.round(s*t*1e3)/1e3;else if(i){const e=i>0?1.1:1/1.1,t=i>0?Math.ceil:Math.floor;i=Math.abs(i);do{s=t(10*(s*e).toFixed(2))/10}while(--i>0)}s=MathClamp(s,Number(this.minZoom)??.1,Number(this.maxZoom)??25);pdf_viewer_assertClassBrand(aw,this,_setScale).call(this,s,{noScroll:!1,drawingDelay:e,origin:a})}increaseScale(e={}){this.updateScale({...e,steps:e.steps??1})}decreaseScale(e={}){this.updateScale({...e,steps:-(e.steps??1)})}get containerTopLeft(){return pdf_viewer_classPrivateFieldGet(bP,this)||pdf_viewer_classPrivateFieldSet(bP,this,[this.container.offsetTop,this.container.offsetLeft])}get annotationEditorMode(){return pdf_viewer_classPrivateFieldGet(PP,this)?pdf_viewer_classPrivateFieldGet(vP,this):f.DISABLE}set annotationEditorMode({mode:e,editId:t=null,isFromKeyboard:i=!1,mustEnterInEditMode:a=!1,editComment:s=!1}){if(!pdf_viewer_classPrivateFieldGet(PP,this))throw new Error("The AnnotationEditor is not enabled.");if(pdf_viewer_classPrivateFieldGet(vP,this)===e)return;if(!isValidAnnotationEditorMode(e))throw new Error(`Invalid AnnotationEditor mode: ${e}`);if(!this.pdfDocument)return;pdf_viewer_assertClassBrand(aw,this,_preloadEditingData).call(this,e);const{eventBus:n,pdfDocument:r}=this,updater=async()=>{pdf_viewer_assertClassBrand(aw,this,_cleanupSwitchAnnotationEditorMode).call(this);pdf_viewer_classPrivateFieldSet(vP,this,e);await pdf_viewer_classPrivateFieldGet(PP,this).updateMode(e,t,!0,i,a,s);e===pdf_viewer_classPrivateFieldGet(vP,this)&&r===this.pdfDocument&&n.dispatch("annotationeditormodechanged",{source:this,mode:e})};if(e===f.NONE||pdf_viewer_classPrivateFieldGet(vP,this)===f.NONE){const t=e!==f.NONE;t||this.pdfDocument.annotationStorage.resetModifiedIds();this.cleanup();for(const e of this._pages)e.toggleEditingMode(t);const i=pdf_viewer_assertClassBrand(aw,this,_switchToEditAnnotationMode).call(this);if(t&&i){pdf_viewer_assertClassBrand(aw,this,_cleanupSwitchAnnotationEditorMode).call(this);pdf_viewer_classPrivateFieldSet(DP,this,new AbortController);const e=AbortSignal.any([pdf_viewer_classPrivateFieldGet(GP,this).signal,pdf_viewer_classPrivateFieldGet(DP,this).signal]);n.on("pagerendered",({pageNumber:e})=>{i.delete(e);0===i.size&&pdf_viewer_classPrivateFieldSet(LP,this,setTimeout(updater,0))},{signal:e,...Nh});return}}updater()}refresh(e=!1,t=Object.create(null)){if(this.pdfDocument){for(const e of this._pages)e.update(t);pdf_viewer_assertClassBrand(aw,this,_cleanupTimeouts).call(this);e||this.update()}}getSerializedAnnotations(){const e=this.pdfDocument.annotationStorage;if(0===e.size)return null;const t=[];for(const[i,a]of e)if(a&&"function"==typeof a.serialize){const e=a.serialize(!0,null,!0);e&&void 0!==a.customId&&null!==a.customId&&(e.customId=a.customId);e&&void 0!==e.annotationType&&t.push(e)}return t.length>0?t:null}async addEditorAnnotation(e){try{"string"==typeof e&&(e=JSON.parse(e))}catch(e){ngx_console_NgxConsole.error(`Please pass a JSON string or an Array of JSON objects to addEditorAnnotation: "${e.message}".`);return}Array.isArray(e)||(e=[e]);const convertArrayLikeObjectToArray=e=>{if(!e||"object"!=typeof e||Array.isArray(e))return e;const t=Object.keys(e);if(t.length>0&&t.every(e=>/^\d+$/.test(e))){const i=[];for(let a=0;a<t.length;a++)i[a]=e[a];return i}return e};let t=!1;e?.forEach(e=>{e.isCopy=!0;if(15!==e.annotationType){const{rect:t}=e;Array.isArray(t)&&4===t.length&&!t.some(e=>!Number.isFinite(e))||ngx_console_NgxConsole.warn(`addEditorAnnotation(): the annotation of type ${e.annotationType} on page ${(e.pageIndex??0)+1} has no usable rect - it is ${JSON.stringify(t)}, but it needs four numbers ([left, bottom, right, top]). Expect it in the wrong place, or nowhere at all. (Drawings don't need a rect - they sit where their points are - but every other annotation does.)`)}if(15===e.annotationType&&e.paths){if(e.paths.lines){const i=e.paths.lines.map(convertArrayLikeObjectToArray);if(i.some((t,i)=>t!==e.paths.lines[i])){t=!0;e.paths.lines=i}}if(e.paths.points){const i=e.paths.points.map(convertArrayLikeObjectToArray);if(i.some((t,i)=>t!==e.paths.points[i])){t=!0;e.paths.points=i}}}});t&&ngx_console_NgxConsole.warn("Detected and converted legacy ink annotation format (object-with-numeric-keys) to arrays. This format was used in ngx-extended-pdf-viewer versions 22.x - 25.5.x. Please re-export or convert your annotations to use the correct format. The objects with numeric keys were always meant to be arrays.");await pdf_viewer_classPrivateFieldGet(PP,this).addSerializedEditor(e,!0,!0,!1,!1)}removeEditorAnnotations(e=()=>!0){pdf_viewer_classPrivateFieldGet(PP,this).removeEditors(e)}destroyBookMode(){if(this.pageFlip){this.pageFlip.destroy();this.pageFlip=null}}stopRendering(){this._cancelRendering()}}function _findAncestorWithScrollbar(e){let t=e?.parentElement;for(;t;){if(t===document.body||t===document.documentElement)return null;const e=getComputedStyle(t).overflowY;if(("auto"===e||"scroll"===e)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function _initOuterScrollListener(){if(!pdf_viewer_classPrivateFieldGet(sw,this)){pdf_viewer_classPrivateFieldSet(sw,this,!0);document.addEventListener("scroll",e=>{const t=e.target;(t===document||t===document.documentElement||t===document.body||t?.contains?.(this.container))&&this._scrollUpdate()},{capture:!0});window.addEventListener("scroll",()=>this._scrollUpdate())}}function _setPrintingAllowed(e){pdf_viewer_classPrivateFieldSet(IP,this,e);this.eventBus.dispatch("printingallowed",{source:this,isAllowed:e})}function _initializePermissions(e){const t={annotationEditorMode:pdf_viewer_classPrivateFieldGet(vP,this),annotationMode:pdf_viewer_classPrivateFieldGet(wP,this),textLayerMode:pdf_viewer_classPrivateFieldGet(KP,this)};if(!e){pdf_viewer_assertClassBrand(aw,this,_setPrintingAllowed).call(this,!0);return t}pdf_viewer_assertClassBrand(aw,this,_setPrintingAllowed).call(this,e.includes(P.PRINT_HIGH_QUALITY)||e.includes(P.PRINT));e.includes(P.COPY)||pdf_viewer_classPrivateFieldGet(KP,this)!==Ph||(t.textLayerMode=wh);e.includes(P.MODIFY_CONTENTS)||(t.annotationEditorMode=f.DISABLE);e.includes(P.MODIFY_ANNOTATIONS)||e.includes(P.FILL_INTERACTIVE_FORMS)||pdf_viewer_classPrivateFieldGet(wP,this)!==p.ENABLE_FORMS||(t.annotationMode=p.ENABLE);return t}async function _onePageRenderedOrForceFetch(e){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return;const t=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState&&t.resolve()},{signal:AbortSignal.any([e,i.signal])});await Promise.race([this._onePageRenderedCapability.promise,t.promise]);i.abort()}function _copyCallback(e,t){const i=document.getSelection(),{focusNode:a,anchorNode:s}=i;if(s&&a&&i.containsNode(pdf_viewer_classPrivateFieldGet(RP,this))){if(pdf_viewer_classPrivateFieldGet(NP,this)||e===wh){stopEvent(t);return}pdf_viewer_classPrivateFieldSet(NP,this,!0);const{classList:i}=this.viewer;i.add("copyAll");const a=new AbortController,s=new AbortController;window.addEventListener("keydown",e=>{"Escape"===e.key&&s.abort()},{signal:a.signal});this.getAllText(s.signal).then(async e=>{null!==e&&await navigator.clipboard.writeText(e)}).catch(e=>{ngx_console_NgxConsole.warn(`Something goes wrong when extracting the text: ${e.message}`)}).finally(()=>{pdf_viewer_classPrivateFieldSet(NP,this,!1);a.abort();i.remove("copyAll")});stopEvent(t)}}function _ensurePageViewVisible(){if(this._scrollMode!==Fh.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const e=this._currentPageNumber,t=pdf_viewer_classPrivateFieldGet(jP,this),i=this.viewer;i.textContent="";t.pages.length=0;if(this._spreadMode!==bh.NONE||this.isInPresentationMode){const a=new Set,s=this._spreadMode-1;if(-1===s)a.add(e-1);else if(e%2!==s){a.add(e-1);a.add(e)}else{a.add(e-2);a.add(e-1)}const n=document.createElement("div");n.className="spread";if(this.isInPresentationMode){const e=document.createElement("div");e.className="dummyPage";n.append(e)}for(const e of a){const i=this._pages[e];if(i){n.append(i.div);t.pages.push(i)}}i.append(n)}else{const a=this._pages[e-1];i.append(a.div);t.pages.push(a)}t.scrollDown=e>=t.previousPageNumber;t.previousPageNumber=e}function _scrollIntoView(e,t=null){if(!e)return;"infinite-scroll"===this.pageViewMode&&pdf_viewer_classPrivateFieldSet(qP,this,Date.now());const{div:i,id:a}=e;this._currentPageNumber!==a&&this._setCurrentPageNumber(a);if(this._scrollMode===Fh.PAGE){pdf_viewer_assertClassBrand(aw,this,_ensurePageViewVisible).call(this);this.update()}if(!t&&!this.isInPresentationMode){const e=i.offsetLeft+i.clientLeft,a=e+i.clientWidth,{scrollLeft:s,clientWidth:n}=this.container;(this._scrollMode===Fh.HORIZONTAL||e<s||a>s+n)&&(t={left:0,top:0})}!this._isContainerRtl||this._scrollMode!==Fh.HORIZONTAL&&this._scrollMode!==Fh.WRAPPED?scrollIntoView(i,t,!1,"infinite-scroll"===this.pageViewMode):i.scrollIntoView({block:"nearest",inline:"end"});!this._currentScaleValue&&this._location&&(this._location=null)}function _isSameScale(e){return e===this._currentScale||Math.abs(e-this._currentScale)<1e-15}function _setScaleUpdatePages(e,t,{noScroll:i=!1,preset:a=!1,drawingDelay:s=-1,origin:n=null}){const r=isNaN(Number(this.currentScale))?void 0:Number(this.currentScale),o=this.currentScaleValue;this.clearSelection();this._currentScaleValue=t.toString();if(pdf_viewer_assertClassBrand(aw,this,_isSameScale).call(this,e)){a&&this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:t,previousScale:r,previousPresetValue:o,noScroll:i});return}const l=s>=0&&s<1e3;this.viewer.style.setProperty("--scale-factor",e*PixelsPerInch.PDF_TO_CSS_UNITS);this.refresh(!0,{scale:e,drawingDelay:l?s:-1});if(l){if(!pdf_viewer_classPrivateFieldGet(UP,this)&&this._location){pdf_viewer_classPrivateFieldSet(UP,this,{...this._location});pdf_viewer_classPrivateFieldSet(zP,this,r)}null!==pdf_viewer_classPrivateFieldGet(VP,this)&&clearTimeout(pdf_viewer_classPrivateFieldGet(VP,this));pdf_viewer_classPrivateFieldSet(VP,this,setTimeout(()=>{pdf_viewer_classPrivateFieldSet(VP,this,null);pdf_viewer_classPrivateFieldSet(UP,this,null);pdf_viewer_classPrivateFieldSet(zP,this,null);const e=Math.round(100*this._currentScale)/100;e===this._currentScale?this.refresh():pdf_viewer_assertClassBrand(aw,this,_setScale).call(this,e,{noScroll:!0,drawingDelay:-1})},s))}this._currentScale=e;if(!i)if("infinite-scroll"===this.pageViewMode){pdf_viewer_classPrivateFieldGet(XP,this)||pdf_viewer_classPrivateFieldSet(XP,this,pdf_viewer_assertClassBrand(aw,this,_findAncestorWithScrollbar).call(this,this.container));const t=pdf_viewer_classPrivateFieldGet(XP,this),i=e/r;if(t){const e=this.container.getBoundingClientRect();if(Array.isArray(n)){t.scrollTop+=(i-1)*(n[1]-e.top);t.scrollLeft+=(i-1)*(n[0]-e.left)}else{const a=t.getBoundingClientRect();t.scrollTop+=(i-1)*(a.top-e.top);t.scrollLeft+=(i-1)*(a.left-e.left)}}else{const e=this.container.getBoundingClientRect();if(Array.isArray(n)){const t=i-1;window.scrollBy(t*(n[0]-e.left),t*(n[1]-e.top))}else{const t=i-1;window.scrollBy(t*(0-e.left),t*(0-e.top))}}}else{const t=this.container,i=pdf_viewer_classPrivateFieldGet(UP,this)||this._location;let a,s=this._currentPageNumber;if(i&&!this.isInPresentationMode&&!this.isChangingPresentationMode){s=i.pageNumber;a=[null,{name:"XYZ"},i.left,i.top,null]}this.scrollPageIntoView({pageNumber:s,destArray:a,allowNegativeOffset:!0});if(Array.isArray(n)){const i=e/(pdf_viewer_classPrivateFieldGet(zP,this)||r)-1,a=t.getBoundingClientRect();t.scrollLeft+=(n[0]-a.left)*i;t.scrollTop+=(n[1]-a.top)*i}}this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:a?t:void 0,previousScale:r,previousPresetValue:o,noScroll:i});this.defaultRenderingQueue&&this.update()}function _get_pageWidthScaleFactor(e){return e._spreadMode!==bh.NONE&&e._scrollMode!==Fh.HORIZONTAL?2:1}function _setScale(e,t){e||(e="auto");this.maxZoom&&this.maxZoom===this.minZoom&&(e=this.maxZoom);let i=parseFloat(e);if(this._currentScale!==i)if(i>0){t.preset=!1;pdf_viewer_assertClassBrand(aw,this,_setScaleUpdatePages).call(this,i,e,t)}else{const a=this._pages[this._currentPageNumber-1];if(!a)return;let s=40,n=5;if(this.isInPresentationMode){s=n=4;this._spreadMode!==bh.NONE&&(s*=2)}else this.removePageBorders?s=n=0:this._scrollMode===Fh.HORIZONTAL&&([s,n]=[n,s]);let r=(this.container.clientWidth-s)/a.width*a.scale/function pdf_viewer_classPrivateGetter(e,t,i){return i(pdf_viewer_assertClassBrand(e,t))}(aw,this,_get_pageWidthScaleFactor);"book"===this.pageViewMode&&(r/=2);const o=(this.container.clientHeight-n)/a.height*a.scale;switch(e){case"page-actual":i=1;break;case"page-width":i=r;break;case"page-height":i=o;break;case"page-fit":i=Math.min(r,o);break;case"auto":const t=isPortraitOrientation(a)?r:Math.min(o,r);i=Math.min(1.25,t);break;default:ngx_console_NgxConsole.error(`#setScale: "${e}" is an unknown zoom value.`);return}t.preset=!0;pdf_viewer_assertClassBrand(aw,this,_setScaleUpdatePages).call(this,i,e,t)}}function _resetCurrentPageView(){const e=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&pdf_viewer_assertClassBrand(aw,this,_setScale).call(this,this._currentScaleValue,{noScroll:!0});pdf_viewer_assertClassBrand(aw,this,_scrollIntoView).call(this,e)}function _switchToEditAnnotationMode(){const e=this._getVisiblePages(),t=[],{ids:i,views:a}=e;for(const e of a){const{view:a}=e;a.hasEditableAnnotations()?t.push(e):i.delete(a.id)}if(0===t.length)return null;this.renderingQueue.renderHighestPriority({first:t[0],last:t.at(-1),views:t,ids:i});return i}function _getVisiblePagesInfiniteScroll(e){pdf_viewer_classPrivateFieldGet(XP,this)||pdf_viewer_classPrivateFieldSet(XP,this,pdf_viewer_assertClassBrand(aw,this,_findAncestorWithScrollbar).call(this,this.container));const t=pdf_viewer_classPrivateFieldGet(XP,this);let i;i=t?t.getBoundingClientRect():{top:0,left:0,bottom:window.innerHeight,right:window.innerWidth};const a=[],s=new Set;for(const t of e){const e=t.div,n=e.getBoundingClientRect(),r=Math.max(n.left,i.left),o=Math.min(n.right,i.right),l=Math.max(n.top,i.top),d=Math.min(n.bottom,i.bottom),c=Math.max(0,o-r),h=Math.max(0,d-l);if(0===c||0===h)continue;const u=c/n.width,_=u*(h/n.height)*100|0,p=Math.max(0,i.left-n.left),g=Math.max(0,i.top-n.top),m=Math.min(n.width,i.right-n.left),f=Math.min(n.height,i.bottom-n.top);a.push({id:t.id,x:e.offsetLeft+e.clientLeft,y:e.offsetTop+e.clientTop,visibleArea:100===_?null:{minX:p,minY:g,maxX:m,maxY:f},view:t,percent:_,widthPercent:100*u|0});s.add(t.id)}a.sort((e,t)=>{const i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id});return{first:a[0],last:a.at(-1),views:a,ids:s}}async function pdf_viewer_ensurePdfPageLoaded(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);e.pdfPage||e.setPdfPage(t);return t}catch(e){ngx_console_NgxConsole.error("Unable to get page for page view",e);return null}}function pdf_viewer_getScrollAhead(e){if(1===e.first?.id)return!0;if(e.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case Fh.PAGE:return pdf_viewer_classPrivateFieldGet(jP,this).scrollDown;case Fh.HORIZONTAL:return this.scroll.right}return this.scroll.down}function _getPageAdvance(e,t=!1){if("book"===this.pageViewMode)return 2;switch(this._scrollMode){case Fh.WRAPPED:{const{views:i}=this._getVisiblePages(),a=new Map;for(const{id:e,y:t,percent:s,widthPercent:n}of i)0===s||n<100||a.getOrInsertComputed(t,makeArr).push(e);for(const i of a.values()){const a=i.indexOf(e);if(-1===a)continue;const s=i.length;if(1===s)break;if(t)for(let t=a-1,s=0;t>=s;t--){const a=i[t],s=i[t+1]-1;if(a<s)return e-s}else for(let t=a+1,n=s;t<n;t++){const a=i[t],s=i[t-1]+1;if(a>s)return s-e}if(t){const t=i[0];if(t<e)return e-t+1}else{const t=i[s-1];if(t>e)return t-e+1}break}break}case Fh.HORIZONTAL:break;case Fh.PAGE:case Fh.VERTICAL:{if(this._spreadMode===bh.NONE)break;const i=this._spreadMode-1;if(t&&e%2!==i)break;if(!t&&e%2===i)break;const{views:a}=this._getVisiblePages(),s=t?e-1:e+1;for(const{id:e,percent:t,widthPercent:i}of a)if(e===s){if(t>0&&100===i)return 2;break}break}}return 1}function _updateContainerHeightCss(e=this.container.clientHeight){if(e!==pdf_viewer_classPrivateFieldGet(OP,this)){pdf_viewer_classPrivateFieldSet(OP,this,e);getDocStyle(this.container).setProperty("--viewer-container-height",`${e}px`)}}function pdf_viewer_resizeObserverCallback(e){for(const t of e)if(t.target===this.container){pdf_viewer_assertClassBrand(aw,this,_updateContainerHeightCss).call(this,Math.floor(t.borderBoxSize[0].blockSize));pdf_viewer_classPrivateFieldSet(bP,this,null);break}}function _cleanupTimeouts(){if(null!==pdf_viewer_classPrivateFieldGet(VP,this)){clearTimeout(pdf_viewer_classPrivateFieldGet(VP,this));pdf_viewer_classPrivateFieldSet(VP,this,null)}if(null!==pdf_viewer_classPrivateFieldGet(TP,this)){clearTimeout(pdf_viewer_classPrivateFieldGet(TP,this));pdf_viewer_classPrivateFieldSet(TP,this,null)}}function _cleanupSwitchAnnotationEditorMode(){pdf_viewer_classPrivateFieldGet(DP,this)?.abort();pdf_viewer_classPrivateFieldSet(DP,this,null);if(null!==pdf_viewer_classPrivateFieldGet(LP,this)){clearTimeout(pdf_viewer_classPrivateFieldGet(LP,this));pdf_viewer_classPrivateFieldSet(LP,this,null)}}function _preloadEditingData(e){switch(e){case f.STAMP:pdf_viewer_classPrivateFieldGet(MP,this)?.loadModel("altText");break;case f.SIGNATURE:pdf_viewer_classPrivateFieldGet(HP,this)?.loadSignatures()}}function secondary_toolbar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function secondary_toolbar_classPrivateFieldGet(e,t){return e.get(secondary_toolbar_assertClassBrand(e,t))}function secondary_toolbar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var nw=new WeakMap,rw=new WeakSet;class SecondaryToolbar{constructor(e,t){!function secondary_toolbar_classPrivateMethodInitSpec(e,t){secondary_toolbar_checkPrivateRedeclaration(e,t),t.add(e)}(this,rw);!function secondary_toolbar_classPrivateFieldInitSpec(e,t,i){secondary_toolbar_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,nw,void 0);!function secondary_toolbar_classPrivateFieldSet(e,t,i){return e.set(secondary_toolbar_assertClassBrand(e,t),i),i}(nw,this,e);const i=[{element:e.presentationModeButton,eventName:"presentationmode",close:!0},{element:e.printButton,eventName:"print",close:!0},{element:e.downloadButton,eventName:"download",close:!0},{element:e.viewBookmarkButton,eventName:null,close:!0},{element:e.firstPageButton,eventName:"firstpage",close:!0},{element:e.lastPageButton,eventName:"lastpage",close:!0},{element:e.pageRotateCwButton,eventName:"rotatecw",close:!1},{element:e.pageRotateCcwButton,eventName:"rotateccw",close:!1},{element:e.cursorSelectToolButton,eventName:"switchcursortool",eventDetails:{tool:yh},close:!0},{element:e.cursorHandToolButton,eventName:"switchcursortool",eventDetails:{tool:Sh},close:!0},{element:e.scrollPageButton,eventName:"switchscrollmode",eventDetails:{mode:Fh.PAGE},close:!0},{element:e.scrollVerticalButton,eventName:"switchscrollmode",eventDetails:{mode:Fh.VERTICAL},close:!0},{element:e.scrollHorizontalButton,eventName:"switchscrollmode",eventDetails:{mode:Fh.HORIZONTAL},close:!0},{element:e.scrollWrappedButton,eventName:"switchscrollmode",eventDetails:{mode:Fh.WRAPPED},close:!0},{element:e.spreadNoneButton,eventName:"switchspreadmode",eventDetails:{mode:bh.NONE},close:!0},{element:e.spreadOddButton,eventName:"switchspreadmode",eventDetails:{mode:bh.ODD},close:!0},{element:e.spreadEvenButton,eventName:"switchspreadmode",eventDetails:{mode:bh.EVEN},close:!0},{element:e.imageAltTextSettingsButton,eventName:"imagealttextsettings",close:!0},{element:e.documentPropertiesButton,eventName:"documentproperties",close:!0}];i.push({element:e.openFileButton,eventName:"openfile",close:!0});this.eventBus=t;this.opened=!1;secondary_toolbar_assertClassBrand(rw,this,secondary_toolbar_bindListeners).call(this,i);this.reset()}get isOpen(){return this.opened}setPageNumber(e){this.pageNumber=e;secondary_toolbar_assertClassBrand(rw,this,secondary_toolbar_updateUIState).call(this)}setPagesCount(e){this.pagesCount=e;secondary_toolbar_assertClassBrand(rw,this,secondary_toolbar_updateUIState).call(this)}reset(){this.pageNumber=0;this.pagesCount=0;secondary_toolbar_assertClassBrand(rw,this,secondary_toolbar_updateUIState).call(this);this.eventBus.dispatch("switchcursortool",{source:this,reset:!0});secondary_toolbar_assertClassBrand(rw,this,_scrollModeChanged).call(this,{mode:Fh.VERTICAL});secondary_toolbar_assertClassBrand(rw,this,_spreadModeChanged).call(this,{mode:bh.NONE})}open(){if(this.opened)return;this.eventBus.dispatch("closeopenpopovers",{source:this});this.opened=!0;const{toggleButton:e,toolbar:t}=secondary_toolbar_classPrivateFieldGet(nw,this);toggleExpandedBtn(e,!0,t)}close(){if(!this.opened)return;this.opened=!1;const{toggleButton:e,toolbar:t}=secondary_toolbar_classPrivateFieldGet(nw,this);toggleExpandedBtn(e,!1,t)}toggle(){this.opened?this.close():this.open()}}function secondary_toolbar_updateUIState(){const{firstPageButton:e,lastPageButton:t,pageRotateCwButton:i,pageRotateCcwButton:a}=secondary_toolbar_classPrivateFieldGet(nw,this);e.disabled=this.pageNumber<=1;t.disabled=this.pageNumber>=this.pagesCount;i.disabled=0===this.pagesCount;a.disabled=0===this.pagesCount}function secondary_toolbar_bindListeners(e){const{eventBus:t}=this,{toggleButton:i}=secondary_toolbar_classPrivateFieldGet(nw,this);i.addEventListener("click",this.toggle.bind(this));for(const{element:i,eventName:a,close:s,eventDetails:n}of e)i&&i.addEventListener("click",e=>{null!==a&&t.dispatch(a,{source:this,...n});s&&this.close();t.dispatch("reporttelemetry",{source:this,details:{type:"buttons",data:{id:i.id}}})});t._on("cursortoolchanged",secondary_toolbar_assertClassBrand(rw,this,_cursorToolChanged).bind(this));t._on("scrollmodechanged",secondary_toolbar_assertClassBrand(rw,this,_scrollModeChanged).bind(this));t._on("spreadmodechanged",secondary_toolbar_assertClassBrand(rw,this,_spreadModeChanged).bind(this));t._on("closeopenpopovers",({source:e})=>{e!==this&&this.close()})}function _cursorToolChanged({tool:e,disabled:t}){const{cursorSelectToolButton:i,cursorHandToolButton:a}=secondary_toolbar_classPrivateFieldGet(nw,this);toggleCheckedBtn(i,e===yh);toggleCheckedBtn(a,e===Sh);i.disabled=t;a.disabled=t}function _scrollModeChanged({mode:e}){const{scrollPageButton:t,scrollVerticalButton:i,scrollHorizontalButton:a,scrollWrappedButton:s,spreadNoneButton:n,spreadOddButton:r,spreadEvenButton:o}=secondary_toolbar_classPrivateFieldGet(nw,this);toggleCheckedBtn(t,e===Fh.PAGE);toggleCheckedBtn(i,e===Fh.VERTICAL);toggleCheckedBtn(a,e===Fh.HORIZONTAL);toggleCheckedBtn(s,e===Fh.WRAPPED);const l=this.pagesCount>dP;t.disabled=l;i.disabled=l;a.disabled=l;s.disabled=l;const d=e===Fh.HORIZONTAL;n.disabled=d;r.disabled=d;o.disabled=d}function _spreadModeChanged({mode:e}){const{spreadNoneButton:t,spreadOddButton:i,spreadEvenButton:a}=secondary_toolbar_classPrivateFieldGet(nw,this);toggleCheckedBtn(t,e===bh.NONE);toggleCheckedBtn(i,e===bh.ODD);toggleCheckedBtn(a,e===bh.EVEN)}function signature_manager_classPrivateMethodInitSpec(e,t){signature_manager_checkPrivateRedeclaration(e,t),t.add(e)}function signature_manager_classPrivateFieldInitSpec(e,t,i){signature_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function signature_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function signature_manager_classPrivateFieldGet(e,t){return e.get(signature_manager_assertClassBrand(e,t))}function signature_manager_classPrivateFieldSet(e,t,i){return e.set(signature_manager_assertClassBrand(e,t),i),i}function signature_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var ow=new WeakMap,lw=new WeakMap,dw=new WeakMap,cw=new WeakMap,hw=new WeakMap,uw=new WeakMap,_w=new WeakMap,pw=new WeakMap,gw=new WeakMap,mw=new WeakMap,fw=new WeakMap,vw=new WeakMap,Pw=new WeakMap,ww=new WeakMap,Fw=new WeakMap,bw=new WeakMap,yw=new WeakMap,Sw=new WeakMap,Cw=new WeakMap,xw=new WeakMap,kw=new WeakMap,Ew=new WeakMap,Aw=new WeakMap,Gw=new WeakMap,Bw=new WeakMap,Mw=new WeakMap,Iw=new WeakMap,Tw=new WeakMap,Dw=new WeakMap,Lw=new WeakMap,Nw=new WeakMap,Rw=new WeakMap,Ow=new WeakMap,Ww=new WeakMap,jw=new WeakMap,Vw=new WeakMap,Uw=new WeakMap,zw=new WeakMap,Hw=new WeakMap,$w=new WeakSet;class SignatureManager{constructor({dialog:e,panels:t,typeButton:i,typeInput:a,drawButton:s,drawPlaceholder:n,drawSVG:r,drawThickness:o,imageButton:l,imageSVG:d,imagePlaceholder:c,imagePicker:h,imagePickerLink:u,description:_,clearButton:p,cancelButton:g,addButton:m,errorCloseButton:f,errorBar:v,errorTitle:P,errorDescription:w,saveCheckbox:F,saveContainer:b},y,S,C,x,k,E){signature_manager_classPrivateMethodInitSpec(this,$w);signature_manager_classPrivateFieldInitSpec(this,ow,void 0);signature_manager_classPrivateFieldInitSpec(this,lw,null);signature_manager_classPrivateFieldInitSpec(this,dw,void 0);signature_manager_classPrivateFieldInitSpec(this,cw,void 0);signature_manager_classPrivateFieldInitSpec(this,hw,void 0);signature_manager_classPrivateFieldInitSpec(this,uw,void 0);signature_manager_classPrivateFieldInitSpec(this,_w,void 0);signature_manager_classPrivateFieldInitSpec(this,pw,null);signature_manager_classPrivateFieldInitSpec(this,gw,void 0);signature_manager_classPrivateFieldInitSpec(this,mw,null);signature_manager_classPrivateFieldInitSpec(this,fw,"");signature_manager_classPrivateFieldInitSpec(this,vw,null);signature_manager_classPrivateFieldInitSpec(this,Pw,void 0);signature_manager_classPrivateFieldInitSpec(this,ww,void 0);signature_manager_classPrivateFieldInitSpec(this,Fw,void 0);signature_manager_classPrivateFieldInitSpec(this,bw,void 0);signature_manager_classPrivateFieldInitSpec(this,yw,void 0);signature_manager_classPrivateFieldInitSpec(this,Sw,null);signature_manager_classPrivateFieldInitSpec(this,Cw,null);signature_manager_classPrivateFieldInitSpec(this,xw,void 0);signature_manager_classPrivateFieldInitSpec(this,kw,void 0);signature_manager_classPrivateFieldInitSpec(this,Ew,void 0);signature_manager_classPrivateFieldInitSpec(this,Aw,void 0);signature_manager_classPrivateFieldInitSpec(this,Gw,void 0);signature_manager_classPrivateFieldInitSpec(this,Bw,void 0);signature_manager_classPrivateFieldInitSpec(this,Mw,void 0);signature_manager_classPrivateFieldInitSpec(this,Iw,void 0);signature_manager_classPrivateFieldInitSpec(this,Tw,null);signature_manager_classPrivateFieldInitSpec(this,Dw,void 0);signature_manager_classPrivateFieldInitSpec(this,Lw,null);signature_manager_classPrivateFieldInitSpec(this,Nw,null);signature_manager_classPrivateFieldInitSpec(this,Rw,!1);signature_manager_classPrivateFieldInitSpec(this,Ow,void 0);signature_manager_classPrivateFieldInitSpec(this,Ww,!1);signature_manager_classPrivateFieldInitSpec(this,jw,void 0);signature_manager_classPrivateFieldInitSpec(this,Vw,void 0);signature_manager_classPrivateFieldInitSpec(this,Uw,void 0);signature_manager_classPrivateFieldInitSpec(this,zw,void 0);signature_manager_classPrivateFieldInitSpec(this,Hw,null);signature_manager_classPrivateFieldSet(ow,this,m);signature_manager_classPrivateFieldSet(dw,this,p);signature_manager_classPrivateFieldSet(cw,this,_.lastElementChild);signature_manager_classPrivateFieldSet(uw,this,_.firstElementChild);signature_manager_classPrivateFieldSet(_w,this,e);signature_manager_classPrivateFieldSet(Pw,this,r);signature_manager_classPrivateFieldSet(gw,this,n);signature_manager_classPrivateFieldSet(ww,this,o);signature_manager_classPrivateFieldSet(Fw,this,v);signature_manager_classPrivateFieldSet(yw,this,P);signature_manager_classPrivateFieldSet(bw,this,w);signature_manager_classPrivateFieldSet(Aw,this,d);signature_manager_classPrivateFieldSet(Ew,this,c);signature_manager_classPrivateFieldSet(xw,this,h);signature_manager_classPrivateFieldSet(kw,this,u);signature_manager_classPrivateFieldSet(Vw,this,C);signature_manager_classPrivateFieldSet(Gw,this,F);signature_manager_classPrivateFieldSet(Bw,this,b);signature_manager_classPrivateFieldSet(Iw,this,S);signature_manager_classPrivateFieldSet(Dw,this,a);signature_manager_classPrivateFieldSet(jw,this,x);signature_manager_classPrivateFieldSet(zw,this,k);signature_manager_classPrivateFieldSet(Ow,this,E);signature_manager_classPrivateFieldSet(Uw,this,new EditDescriptionDialog(y,C));Kw._||(Kw._=Object.freeze({signature:"pdfjs-editor-add-signature-description-default-when-drawing",errorUploadTitle:"pdfjs-editor-add-signature-image-upload-error-title",errorUploadDescription:"pdfjs-editor-add-signature-image-upload-error-description",errorNoDataTitle:"pdfjs-editor-add-signature-image-no-data-error-title",errorNoDataDescription:"pdfjs-editor-add-signature-image-no-data-error-description"}));e.addEventListener("close",signature_manager_assertClassBrand($w,this,signature_manager_close).bind(this));e.addEventListener("contextmenu",e=>{const{target:t}=e;t!==signature_manager_classPrivateFieldGet(Dw,this)&&t!==signature_manager_classPrivateFieldGet(uw,this)&&e.preventDefault()});e.addEventListener("drop",e=>{stopEvent(e)});g.addEventListener("click",signature_manager_assertClassBrand($w,this,signature_manager_cancel).bind(this));m.addEventListener("click",signature_manager_assertClassBrand($w,this,_add).bind(this));p.addEventListener("click",()=>{signature_manager_assertClassBrand($w,this,signature_manager_reportTelemetry).call(this,{type:"signature",action:"pdfjs.signature.clear",data:{type:signature_manager_classPrivateFieldGet(Lw,this)}});signature_manager_assertClassBrand($w,this,_initTab).call(this,null)},{passive:!0});signature_manager_classPrivateFieldGet(uw,this).addEventListener("input",()=>{signature_manager_classPrivateFieldGet(cw,this).disabled=""===signature_manager_classPrivateFieldGet(uw,this).value},{passive:!0});signature_manager_classPrivateFieldGet(cw,this).addEventListener("click",()=>{signature_manager_classPrivateFieldGet(uw,this).value="";signature_manager_classPrivateFieldGet(cw,this).disabled=!0},{passive:!0});f.addEventListener("click",()=>{v.hidden=!0},{passive:!0});signature_manager_assertClassBrand($w,this,_initTabButtons).call(this,i,s,l,t);h.accept=Y.join(",");E.on("storedsignatureschanged",signature_manager_assertClassBrand($w,this,_signaturesChanged).bind(this),Nh);C.register(e)}getSignature(e){return this.open(e)}async loadSignatures(e=!1){if(!signature_manager_classPrivateFieldGet(Iw,this)||!e&&signature_manager_classPrivateFieldGet(Iw,this).previousElementSibling||!signature_manager_classPrivateFieldGet(zw,this))return;if(!signature_manager_classPrivateFieldGet(Tw,this)){signature_manager_classPrivateFieldSet(Tw,this,signature_manager_classPrivateFieldGet(zw,this).getAll().then(async e=>[e,await Promise.all(Array.from(e.values(),({signatureData:e})=>SignatureExtractor.decompressSignature(e)))]));if(!e)return}const[t,i]=await signature_manager_classPrivateFieldGet(Tw,this);signature_manager_classPrivateFieldSet(Tw,this,null);let a=0;for(const[e,{description:s}]of t){const t=i[a++];if(t){t.curves=t.outlines.map(e=>({points:e}));delete t.outlines;signature_manager_assertClassBrand($w,this,_addToolbarButton).call(this,t,e,s)}}}async renderEditButton(e){const t=document.createElement("button");t.classList.add("altText","editDescription");t.tabIndex=0;e.description&&(t.title=e.description);const i=document.createElement("span");t.append(i);i.setAttribute("data-l10n-id","pdfjs-editor-add-signature-edit-button-label");t.addEventListener("click",()=>{signature_manager_classPrivateFieldGet(Uw,this).open(e)},{passive:!0});return t}async open({uiManager:e,editor:t}){signature_manager_classPrivateFieldGet(lw,this)||signature_manager_classPrivateFieldSet(lw,this,new Map(signature_manager_classPrivateFieldGet(Mw,this).keys().map(e=>[e,{value:"",default:""}])));signature_manager_classPrivateFieldSet(Hw,this,e);signature_manager_classPrivateFieldSet(hw,this,t);signature_manager_classPrivateFieldGet(Hw,this).removeEditListeners();const i=signature_manager_classPrivateFieldSet(Ww,this,await signature_manager_classPrivateFieldGet(zw,this).isFull());signature_manager_classPrivateFieldGet(Bw,this).classList.toggle("fullStorage",i);signature_manager_classPrivateFieldGet(Gw,this).checked=!i;await signature_manager_classPrivateFieldGet(Vw,this).open(signature_manager_classPrivateFieldGet(_w,this));const a=signature_manager_classPrivateFieldGet(Mw,this).get("type");a.focus();a.click()}destroy(){signature_manager_classPrivateFieldSet(Hw,this,null);signature_manager_assertClassBrand($w,this,signature_manager_finish).call(this)}}function _initTabButtons(e,t,i,a){const s=signature_manager_classPrivateFieldSet(Mw,this,new Map([["type",e],["draw",t],["image",i]])),tabCallback=e=>{for(const[t,i]of s)if(i===e.target){i.setAttribute("aria-selected",!0);i.setAttribute("tabindex",0);a.setAttribute("data-selected",t);signature_manager_assertClassBrand($w,this,_initTab).call(this,t)}else{i.setAttribute("aria-selected",!1);i.setAttribute("tabindex",-1)}},n=Array.from(s.values());for(let e=0,t=n.length;e<t;e++){const t=n[e];t.addEventListener("click",tabCallback,{passive:!0});t.addEventListener("keydown",({key:t})=>{"ArrowLeft"!==t&&"ArrowRight"!==t||n[e+("ArrowLeft"===t?-1:1)]?.focus()},{passive:!0})}}function _resetCommon(){signature_manager_classPrivateFieldSet(Rw,this,!1);signature_manager_classPrivateFieldGet(uw,this).value="";signature_manager_classPrivateFieldGet(Lw,this)&&(signature_manager_classPrivateFieldGet(lw,this).get(signature_manager_classPrivateFieldGet(Lw,this)).value="")}function _resetTab(e){switch(e){case"type":signature_manager_classPrivateFieldGet(Dw,this).value="";break;case"draw":signature_manager_classPrivateFieldSet(pw,this,null);signature_manager_classPrivateFieldSet(vw,this,null);signature_manager_classPrivateFieldSet(fw,this,"");signature_manager_classPrivateFieldGet(mw,this)?.remove();signature_manager_classPrivateFieldSet(mw,this,null);signature_manager_classPrivateFieldGet(gw,this).hidden=!1;signature_manager_classPrivateFieldGet(ww,this).value=1;break;case"image":signature_manager_classPrivateFieldGet(Ew,this).hidden=!1;signature_manager_classPrivateFieldGet(Cw,this)?.remove();signature_manager_classPrivateFieldSet(Cw,this,null)}}function _initTab(e){if(e&&signature_manager_classPrivateFieldGet(Lw,this)===e)return;signature_manager_classPrivateFieldGet(Lw,this)&&(signature_manager_classPrivateFieldGet(lw,this).get(signature_manager_classPrivateFieldGet(Lw,this)).value=signature_manager_classPrivateFieldGet(uw,this).value);e&&signature_manager_classPrivateFieldSet(Lw,this,e);signature_manager_classPrivateFieldGet(Fw,this).hidden=!0;const t=!e;t?signature_manager_assertClassBrand($w,this,_resetCommon).call(this):signature_manager_classPrivateFieldGet(uw,this).value=signature_manager_classPrivateFieldGet(lw,this).get(signature_manager_classPrivateFieldGet(Lw,this)).value;signature_manager_classPrivateFieldGet(cw,this).disabled=""===signature_manager_classPrivateFieldGet(uw,this).value;signature_manager_classPrivateFieldGet(Nw,this)?.abort();signature_manager_classPrivateFieldSet(Nw,this,new AbortController);switch(signature_manager_classPrivateFieldGet(Lw,this)){case"type":signature_manager_assertClassBrand($w,this,_initTypeTab).call(this,t);break;case"draw":signature_manager_assertClassBrand($w,this,_initDrawTab).call(this,t);break;case"image":signature_manager_assertClassBrand($w,this,_initImageTab).call(this,t)}}function _disableButtons(e){e&&signature_manager_classPrivateFieldGet(Ww,this)||(signature_manager_classPrivateFieldGet(Gw,this).disabled=!e);signature_manager_classPrivateFieldGet(dw,this).disabled=signature_manager_classPrivateFieldGet(ow,this).disabled=signature_manager_classPrivateFieldGet(uw,this).disabled=!e}function _initTypeTab(e){e&&signature_manager_assertClassBrand($w,this,_resetTab).call(this,"type");signature_manager_assertClassBrand($w,this,_disableButtons).call(this,signature_manager_classPrivateFieldGet(Dw,this).value);const{signal:t}=signature_manager_classPrivateFieldGet(Nw,this),i={passive:!0,signal:t};signature_manager_classPrivateFieldGet(Dw,this).addEventListener("input",()=>{const{value:e}=signature_manager_classPrivateFieldGet(Dw,this);if(!signature_manager_classPrivateFieldGet(Rw,this)){signature_manager_classPrivateFieldGet(lw,this).get("type").default=signature_manager_classPrivateFieldGet(uw,this).value=e;signature_manager_classPrivateFieldGet(cw,this).disabled=""===e}signature_manager_assertClassBrand($w,this,_disableButtons).call(this,e)},i);signature_manager_classPrivateFieldGet(uw,this).addEventListener("input",()=>{signature_manager_classPrivateFieldSet(Rw,this,signature_manager_classPrivateFieldGet(Dw,this).value!==signature_manager_classPrivateFieldGet(uw,this).value)},i)}function _initDrawTab(e){e&&signature_manager_assertClassBrand($w,this,_resetTab).call(this,"draw");signature_manager_assertClassBrand($w,this,_disableButtons).call(this,signature_manager_classPrivateFieldGet(mw,this));const{signal:t}=signature_manager_classPrivateFieldGet(Nw,this),i={signal:t};let a=NaN;const drawCallback=e=>{const{pointerId:s}=e;if(!isNaN(a)&&a!==s)return;a=s;e.preventDefault();signature_manager_classPrivateFieldGet(Pw,this).setPointerCapture(s);const{width:n,height:r}=signature_manager_classPrivateFieldGet(Pw,this).getBoundingClientRect();let{offsetX:o,offsetY:l}=e;o=Math.round(o);l=Math.round(l);e.target===signature_manager_classPrivateFieldGet(gw,this)&&(signature_manager_classPrivateFieldGet(gw,this).hidden=!0);if(!signature_manager_classPrivateFieldGet(pw,this)){signature_manager_classPrivateFieldSet(pw,this,{width:n,height:r,thickness:parseInt(signature_manager_classPrivateFieldGet(ww,this).value,10),curves:[]});signature_manager_assertClassBrand($w,this,_disableButtons).call(this,!0);const e=new DOMSVGFactory,t=signature_manager_classPrivateFieldSet(mw,this,e.createElement("path"));t.setAttribute("stroke-width",signature_manager_classPrivateFieldGet(ww,this).value);signature_manager_classPrivateFieldGet(Pw,this).append(t);signature_manager_classPrivateFieldGet(Pw,this).addEventListener("pointerdown",drawCallback,i);signature_manager_classPrivateFieldGet(gw,this).removeEventListener("pointerdown",drawCallback);""===signature_manager_classPrivateFieldGet(uw,this).value&&signature_manager_classPrivateFieldGet(jw,this).get(Kw._.signature).then(e=>{signature_manager_classPrivateFieldGet(lw,this).get("draw").default=e;signature_manager_classPrivateFieldGet(uw,this).value||=e;signature_manager_classPrivateFieldGet(cw,this).disabled=""===signature_manager_classPrivateFieldGet(uw,this).value})}signature_manager_classPrivateFieldSet(vw,this,[o,l]);signature_manager_classPrivateFieldGet(pw,this).curves.push({points:signature_manager_classPrivateFieldGet(vw,this)});signature_manager_classPrivateFieldSet(fw,this,signature_manager_classPrivateFieldGet(fw,this)+`M ${o} ${l}`);signature_manager_classPrivateFieldGet(mw,this).setAttribute("d",signature_manager_classPrivateFieldGet(fw,this));const d=new AbortController,c={signal:AbortSignal.any([t,d.signal])};signature_manager_classPrivateFieldGet(Pw,this).addEventListener("contextmenu",noContextMenu,c);signature_manager_classPrivateFieldGet(Pw,this).addEventListener("pointermove",e=>{e.preventDefault();let{offsetX:t,offsetY:i}=e;t=Math.round(t);i=Math.round(i);const a=signature_manager_classPrivateFieldGet(vw,this);if(!(t<0||i<0||t>n||i>r||t===a.at(-2)&&i===a.at(-1))){if(a.length>=4){const[e,s,n,r]=a.slice(-4);signature_manager_classPrivateFieldSet(fw,this,signature_manager_classPrivateFieldGet(fw,this)+`C${(e+5*n)/6} ${(s+5*r)/6} ${(5*n+t)/6} ${(5*r+i)/6} ${(n+t)/2} ${(r+i)/2}`)}else signature_manager_classPrivateFieldSet(fw,this,signature_manager_classPrivateFieldGet(fw,this)+`L${t} ${i}`);a.push(t,i);signature_manager_classPrivateFieldGet(mw,this).setAttribute("d",signature_manager_classPrivateFieldGet(fw,this))}},c);signature_manager_classPrivateFieldGet(Pw,this).addEventListener("pointerup",e=>{const{pointerId:t}=e;if(isNaN(a)||a===t){a=NaN;e.preventDefault();signature_manager_classPrivateFieldGet(Pw,this).releasePointerCapture(t);d.abort();if(2===signature_manager_classPrivateFieldGet(vw,this).length){signature_manager_classPrivateFieldSet(fw,this,signature_manager_classPrivateFieldGet(fw,this)+`L${signature_manager_classPrivateFieldGet(vw,this)[0]} ${signature_manager_classPrivateFieldGet(vw,this)[1]}`);signature_manager_classPrivateFieldGet(mw,this).setAttribute("d",signature_manager_classPrivateFieldGet(fw,this))}}},c)};signature_manager_classPrivateFieldGet(pw,this)?signature_manager_classPrivateFieldGet(Pw,this).addEventListener("pointerdown",drawCallback,i):signature_manager_classPrivateFieldGet(gw,this).addEventListener("pointerdown",drawCallback,i);signature_manager_classPrivateFieldGet(ww,this).addEventListener("input",()=>{const{value:e}=signature_manager_classPrivateFieldGet(ww,this);signature_manager_classPrivateFieldGet(ww,this).setAttribute("data-l10n-args",JSON.stringify({thickness:e}));if(signature_manager_classPrivateFieldGet(pw,this)){signature_manager_classPrivateFieldGet(mw,this).setAttribute("stroke-width",e);signature_manager_classPrivateFieldGet(pw,this).thickness=e}},i)}function _showError(e){signature_manager_classPrivateFieldGet(yw,this).setAttribute("data-l10n-id",Kw._[`error${e}Title`]);signature_manager_classPrivateFieldGet(bw,this).setAttribute("data-l10n-id",Kw._[`error${e}Description`]);signature_manager_classPrivateFieldGet(Fw,this).hidden=!1}function _initImageTab(e){e&&signature_manager_assertClassBrand($w,this,_resetTab).call(this,"image");signature_manager_assertClassBrand($w,this,_disableButtons).call(this,signature_manager_classPrivateFieldGet(Cw,this));const{signal:t}=signature_manager_classPrivateFieldGet(Nw,this),i={signal:t},a={passive:!0,signal:t};signature_manager_classPrivateFieldGet(kw,this).addEventListener("keydown",e=>{const{key:t}=e;if("Enter"===t||" "===t){stopEvent(e);signature_manager_classPrivateFieldGet(xw,this).click()}},i);signature_manager_classPrivateFieldGet(xw,this).addEventListener("click",()=>{signature_manager_classPrivateFieldGet(_w,this).classList.toggle("waiting",!0)},a);signature_manager_classPrivateFieldGet(xw,this).addEventListener("change",async()=>{const e=signature_manager_classPrivateFieldGet(xw,this).files?.[0];if(e&&Y.includes(e.type))await signature_manager_assertClassBrand($w,this,_extractSignature).call(this,e);else{signature_manager_assertClassBrand($w,this,_showError).call(this,"Upload");signature_manager_classPrivateFieldGet(_w,this).classList.toggle("waiting",!1)}},a);signature_manager_classPrivateFieldGet(xw,this).addEventListener("cancel",()=>{signature_manager_classPrivateFieldGet(_w,this).classList.toggle("waiting",!1)},a);signature_manager_classPrivateFieldGet(Ew,this).addEventListener("dragover",e=>{const{dataTransfer:t}=e;for(const{type:i}of t.items)if(Y.includes(i)){t.dropEffect="copy"===t.effectAllowed?"copy":"move";stopEvent(e);return}t.dropEffect="none"},i);signature_manager_classPrivateFieldGet(Ew,this).addEventListener("drop",e=>{const{dataTransfer:{files:t}}=e;if(t?.length){for(const e of t)if(Y.includes(e.type)){signature_manager_assertClassBrand($w,this,_extractSignature).call(this,e);break}stopEvent(e);signature_manager_classPrivateFieldGet(_w,this).classList.toggle("waiting",!0)}},i)}async function _extractSignature(e){let t;try{t=await signature_manager_classPrivateFieldGet(Hw,this).imageManager.getFromFile(e)}catch(e){ngx_console_NgxConsole.error("SignatureManager.#extractSignature.",e)}if(!t){signature_manager_assertClassBrand($w,this,_showError).call(this,"Upload");signature_manager_classPrivateFieldGet(_w,this).classList.toggle("waiting",!1);return}const i=signature_manager_classPrivateFieldSet(Sw,this,signature_manager_classPrivateFieldGet(hw,this).getFromImage(t.bitmap));if(!i){signature_manager_assertClassBrand($w,this,_showError).call(this,"NoData");signature_manager_classPrivateFieldGet(_w,this).classList.toggle("waiting",!1);return}const{outline:a}=i;signature_manager_classPrivateFieldGet(Ew,this).hidden=!0;signature_manager_assertClassBrand($w,this,_disableButtons).call(this,!0);const s=new DOMSVGFactory,n=signature_manager_classPrivateFieldSet(Cw,this,s.createElement("path"));signature_manager_classPrivateFieldGet(Aw,this).setAttribute("viewBox",a.viewBox);signature_manager_classPrivateFieldGet(Aw,this).setAttribute("preserveAspectRatio","xMidYMid meet");signature_manager_classPrivateFieldGet(Aw,this).append(n);n.setAttribute("d",a.toSVGPath());signature_manager_classPrivateFieldGet(lw,this).get("image").default=e.name;if(""===signature_manager_classPrivateFieldGet(uw,this).value){signature_manager_classPrivateFieldGet(uw,this).value=e.name||"";signature_manager_classPrivateFieldGet(cw,this).disabled=""===signature_manager_classPrivateFieldGet(uw,this).value}signature_manager_classPrivateFieldGet(_w,this).classList.toggle("waiting",!1)}function _getOutlineForType(){return signature_manager_classPrivateFieldGet(hw,this).getFromText(signature_manager_classPrivateFieldGet(Dw,this).value,window.getComputedStyle(signature_manager_classPrivateFieldGet(Dw,this)))}function _getOutlineForDraw(){const{width:e,height:t}=signature_manager_classPrivateFieldGet(Pw,this).getBoundingClientRect();return signature_manager_classPrivateFieldGet(hw,this).getDrawnSignature(signature_manager_classPrivateFieldGet(pw,this),e,t)}function signature_manager_reportTelemetry(e){signature_manager_classPrivateFieldGet(Ow,this).dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}function _addToolbarButton(e,t,i){const{curves:a,areContours:s,thickness:n,width:r,height:o}=e,l=Math.max(r,o),d=SignatureExtractor.processDrawnLines({lines:{curves:a,thickness:n,width:r,height:o},pageWidth:l,pageHeight:l,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});if(!d)return;const{outline:c}=d,h=new DOMSVGFactory,u=document.createElement("div"),_=document.createElement("button");_.addEventListener("click",()=>{signature_manager_classPrivateFieldGet(Ow,this).dispatch("switchannotationeditorparams",{source:this,type:v.CREATE,value:{signatureData:{lines:{curves:a,thickness:n,width:r,height:o},mustSmooth:!1,areContours:s,description:i,uuid:t,heightInPage:40}}})});u.append(_);u.classList.add("toolbarAddSignatureButtonContainer");const p=h.create(1,1,!0);_.append(p);const g=document.createElement("span");g.ariaHidden=!0;_.append(g);_.classList.add("toolbarAddSignatureButton");_.type="button";g.textContent=i;_.setAttribute("data-l10n-id","pdfjs-editor-add-saved-signature-button");_.setAttribute("data-l10n-args",JSON.stringify({description:i}));_.tabIndex=0;const m=h.createElement("path");p.append(m);p.setAttribute("viewBox",c.viewBox);p.setAttribute("preserveAspectRatio","xMidYMid meet");s&&m.classList.add("contours");m.setAttribute("d",c.toSVGPath());const f=document.createElement("button");u.append(f);f.classList.add("toolbarButton","deleteButton");f.setAttribute("data-l10n-id","pdfjs-editor-delete-signature-button1");f.type="button";f.tabIndex=0;f.addEventListener("click",async()=>{if(await signature_manager_classPrivateFieldGet(zw,this).delete(t)){u.remove();signature_manager_assertClassBrand($w,this,signature_manager_reportTelemetry).call(this,{type:"signature",action:"pdfjs.signature.delete_saved",data:{savedCount:await signature_manager_classPrivateFieldGet(zw,this).size()}})}});const P=document.createElement("span");f.append(P);P.setAttribute("data-l10n-id","pdfjs-editor-delete-signature-button-label1");signature_manager_classPrivateFieldGet(Iw,this).before(u)}async function _signaturesChanged(){const e=signature_manager_classPrivateFieldGet(Iw,this).parentElement;for(;e.firstElementChild!==signature_manager_classPrivateFieldGet(Iw,this);)e.firstElementChild.remove();signature_manager_classPrivateFieldSet(Tw,this,null);await this.loadSignatures(!0)}function signature_manager_cancel(){signature_manager_assertClassBrand($w,this,signature_manager_finish).call(this)}function signature_manager_finish(){signature_manager_classPrivateFieldGet(Vw,this).closeIfActive(signature_manager_classPrivateFieldGet(_w,this))}function signature_manager_close(){null===signature_manager_classPrivateFieldGet(hw,this)._drawId&&signature_manager_classPrivateFieldGet(hw,this).remove();signature_manager_classPrivateFieldGet(Hw,this)?.addEditListeners();signature_manager_classPrivateFieldGet(Nw,this)?.abort();signature_manager_classPrivateFieldSet(Nw,this,null);signature_manager_classPrivateFieldSet(Hw,this,null);signature_manager_classPrivateFieldSet(hw,this,null);signature_manager_assertClassBrand($w,this,_resetCommon).call(this);for(const[e]of signature_manager_classPrivateFieldGet(Mw,this))signature_manager_assertClassBrand($w,this,_resetTab).call(this,e);signature_manager_assertClassBrand($w,this,_disableButtons).call(this,!1);signature_manager_classPrivateFieldSet(Lw,this,null);signature_manager_classPrivateFieldSet(lw,this,null)}async function _add(){let e;const t=signature_manager_classPrivateFieldGet(Lw,this);switch(t){case"type":e=signature_manager_assertClassBrand($w,this,_getOutlineForType).call(this);break;case"draw":e=signature_manager_assertClassBrand($w,this,_getOutlineForDraw).call(this);break;case"image":e=signature_manager_classPrivateFieldGet(Sw,this)}let i=null;const a=signature_manager_classPrivateFieldGet(uw,this).value;if(signature_manager_classPrivateFieldGet(Gw,this).checked){const{newCurves:t,areContours:s,thickness:n,width:r,height:o}=e,l=await SignatureExtractor.compressSignature({outlines:t,areContours:s,thickness:n,width:r,height:o});i=await signature_manager_classPrivateFieldGet(zw,this).create({description:a,signatureData:l});i?signature_manager_assertClassBrand($w,this,_addToolbarButton).call(this,{curves:t.map(e=>({points:e})),areContours:s,thickness:n,width:r,height:o},i,a):ngx_console_NgxConsole.warn("SignatureManager.add: cannot save the signature.")}const s=signature_manager_classPrivateFieldGet(lw,this).get(t);signature_manager_assertClassBrand($w,this,signature_manager_reportTelemetry).call(this,{type:"signature",action:"pdfjs.signature.created",data:{type:t,saved:!!i,savedCount:await signature_manager_classPrivateFieldGet(zw,this).size(),descriptionChanged:a!==s.default}});signature_manager_classPrivateFieldGet(hw,this).addSignature(e,40,signature_manager_classPrivateFieldGet(uw,this).value,i);signature_manager_assertClassBrand($w,this,signature_manager_finish).call(this)}var Kw={_:null},Xw=new WeakMap,qw=new WeakMap,Yw=new WeakMap,Zw=new WeakMap,Qw=new WeakMap,Jw=new WeakMap,eF=new WeakMap,tF=new WeakSet;class EditDescriptionDialog{constructor({dialog:e,description:t,cancelButton:i,updateButton:a,editSignatureView:s},n){signature_manager_classPrivateMethodInitSpec(this,tF);signature_manager_classPrivateFieldInitSpec(this,Xw,void 0);signature_manager_classPrivateFieldInitSpec(this,qw,void 0);signature_manager_classPrivateFieldInitSpec(this,Yw,void 0);signature_manager_classPrivateFieldInitSpec(this,Zw,void 0);signature_manager_classPrivateFieldInitSpec(this,Qw,void 0);signature_manager_classPrivateFieldInitSpec(this,Jw,void 0);signature_manager_classPrivateFieldInitSpec(this,eF,void 0);const r=signature_manager_classPrivateFieldSet(Yw,this,t.firstElementChild);signature_manager_classPrivateFieldSet(Jw,this,s);signature_manager_classPrivateFieldSet(Zw,this,e);signature_manager_classPrivateFieldSet(Qw,this,n);e.addEventListener("close",signature_manager_assertClassBrand(tF,this,_close2).bind(this));e.addEventListener("contextmenu",e=>{e.target!==signature_manager_classPrivateFieldGet(Yw,this)&&e.preventDefault()});i.addEventListener("click",signature_manager_assertClassBrand(tF,this,_cancel2).bind(this));a.addEventListener("click",signature_manager_assertClassBrand(tF,this,_update).bind(this));const o=t.lastElementChild;o.addEventListener("click",()=>{r.value="";o.disabled=!0;a.disabled=""===signature_manager_classPrivateFieldGet(qw,this)});r.addEventListener("input",()=>{const{value:e}=r;o.disabled=""===e;a.disabled=e===signature_manager_classPrivateFieldGet(qw,this);s.setAttribute("aria-label",e)},{passive:!0});n.register(e)}async open(e){signature_manager_classPrivateFieldSet(eF,this,e._uiManager);signature_manager_classPrivateFieldSet(Xw,this,e);signature_manager_classPrivateFieldSet(qw,this,signature_manager_classPrivateFieldGet(Yw,this).value=e.description);signature_manager_classPrivateFieldGet(Yw,this).dispatchEvent(new Event("input"));signature_manager_classPrivateFieldGet(eF,this).removeEditListeners();const{areContours:t,outline:i}=e.getSignaturePreview(),a=(new DOMSVGFactory).createElement("path");signature_manager_classPrivateFieldGet(Jw,this).append(a);signature_manager_classPrivateFieldGet(Jw,this).setAttribute("viewBox",i.viewBox);a.setAttribute("d",i.toSVGPath());t&&a.classList.add("contours");await signature_manager_classPrivateFieldGet(Qw,this).open(signature_manager_classPrivateFieldGet(Zw,this))}}async function _update(){signature_manager_classPrivateFieldGet(Xw,this)._reportTelemetry({action:"pdfjs.signature.edit_description",data:{hasBeenChanged:!0}});signature_manager_classPrivateFieldGet(Xw,this).description=signature_manager_classPrivateFieldGet(Yw,this).value;signature_manager_assertClassBrand(tF,this,signature_manager_finish2).call(this)}function _cancel2(){signature_manager_classPrivateFieldGet(Xw,this)._reportTelemetry({action:"pdfjs.signature.edit_description",data:{hasBeenChanged:!1}});signature_manager_assertClassBrand(tF,this,signature_manager_finish2).call(this)}function signature_manager_finish2(){signature_manager_classPrivateFieldGet(Qw,this).closeIfActive(signature_manager_classPrivateFieldGet(Zw,this))}function _close2(){signature_manager_classPrivateFieldGet(eF,this)?.addEditListeners();signature_manager_classPrivateFieldSet(eF,this,null);signature_manager_classPrivateFieldSet(Xw,this,null);signature_manager_classPrivateFieldGet(Jw,this).firstElementChild.remove()}function digital_signature_properties_manager_classPrivateFieldInitSpec(e,t,i){digital_signature_properties_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}function digital_signature_properties_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function digital_signature_properties_manager_classPrivateGetter(e,t,i){return i(digital_signature_properties_manager_assertClassBrand(e,t))}function digital_signature_properties_manager_classPrivateFieldGet(e,t){return e.get(digital_signature_properties_manager_assertClassBrand(e,t))}function digital_signature_properties_manager_classPrivateFieldSet(e,t,i){return e.set(digital_signature_properties_manager_assertClassBrand(e,t),i),i}function digital_signature_properties_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const iF="pdfjs-digital-signature-properties-status-verified",aF={verified:{priority:0,severity:"verified",bannerId:"pdfjs-digital-signature-properties-banner-verified",statusId:iF},unknown:{priority:1,severity:"error",bannerId:"pdfjs-digital-signature-properties-banner-unknown",statusId:"pdfjs-digital-signature-properties-status-unknown"},untrusted:{priority:2,severity:"warn",bannerId:"pdfjs-digital-signature-properties-banner-untrusted",statusId:iF},expired:{priority:3,severity:"warn",bannerId:"pdfjs-digital-signature-properties-banner-expired",statusId:iF},revoked:{priority:4,severity:"error",bannerId:"pdfjs-digital-signature-properties-banner-revoked",statusId:iF},invalid:{priority:5,severity:"error",bannerId:"pdfjs-digital-signature-properties-banner-invalid",statusId:"pdfjs-digital-signature-properties-status-invalid"}},sF={trusted:"pdfjs-digital-signature-properties-certificate-trusted",unknown:"pdfjs-digital-signature-properties-certificate-unknown",untrusted:"pdfjs-digital-signature-properties-certificate-untrusted",expired:"pdfjs-digital-signature-properties-certificate-expired",revoked:"pdfjs-digital-signature-properties-certificate-revoked"};var nF=new WeakMap,rF=new WeakMap,oF=new WeakMap,lF=new WeakMap,dF=new WeakMap,cF=new WeakMap,hF=new WeakMap,uF=new WeakMap,_F=new WeakMap,pF=new WeakMap,gF=new WeakSet;class SignaturePropertiesManager{constructor({appConfig:e,verifier:t,eventBus:i}){!function digital_signature_properties_manager_classPrivateMethodInitSpec(e,t){digital_signature_properties_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,gF);digital_signature_properties_manager_classPrivateFieldInitSpec(this,nF,void 0);digital_signature_properties_manager_classPrivateFieldInitSpec(this,rF,void 0);digital_signature_properties_manager_classPrivateFieldInitSpec(this,oF,void 0);digital_signature_properties_manager_classPrivateFieldInitSpec(this,lF,[]);digital_signature_properties_manager_classPrivateFieldInitSpec(this,dF,new Map);digital_signature_properties_manager_classPrivateFieldInitSpec(this,cF,new Set);digital_signature_properties_manager_classPrivateFieldInitSpec(this,hF,!1);digital_signature_properties_manager_classPrivateFieldInitSpec(this,uF,!1);digital_signature_properties_manager_classPrivateFieldInitSpec(this,_F,!1);digital_signature_properties_manager_classPrivateFieldInitSpec(this,pF,null);digital_signature_properties_manager_classPrivateFieldSet(nF,this,e);digital_signature_properties_manager_classPrivateFieldSet(rF,this,t);digital_signature_properties_manager_classPrivateFieldSet(oF,this,i);const a=e.signaturePropertiesButton;for(let e=0;e<3;e++){const e=document.createElement("span");e.className="loadingDot";a.append(e)}a.addEventListener("click",()=>{digital_signature_properties_manager_assertClassBrand(gF,this,digital_signature_properties_manager_toggle).call(this)})}get isOpen(){return digital_signature_properties_manager_classPrivateFieldGet(hF,this)}close(){digital_signature_properties_manager_classPrivateFieldGet(hF,this)&&digital_signature_properties_manager_assertClassBrand(gF,this,digital_signature_properties_manager_close).call(this)}shouldCloseOnClick(e){return!!digital_signature_properties_manager_classPrivateFieldGet(hF,this)&&!(digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesButton.contains(e)||digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesPanel.contains(e))}async setDocument(e){if(digital_signature_properties_manager_classPrivateFieldGet(pF,this)){digital_signature_properties_manager_classPrivateFieldSet(lF,this,[]);digital_signature_properties_manager_classPrivateFieldGet(dF,this).clear();digital_signature_properties_manager_classPrivateFieldGet(cF,this).clear();digital_signature_properties_manager_classPrivateFieldSet(_F,this,!1);digital_signature_properties_manager_assertClassBrand(gF,this,_hideButton).call(this);digital_signature_properties_manager_assertClassBrand(gF,this,digital_signature_properties_manager_close).call(this);digital_signature_properties_manager_assertClassBrand(gF,this,_updateButtonState).call(this)}digital_signature_properties_manager_classPrivateFieldSet(pF,this,e);if(!e)return;digital_signature_properties_manager_classPrivateFieldSet(uF,this,!0);digital_signature_properties_manager_assertClassBrand(gF,this,digital_signature_properties_manager_render).call(this);let t;try{t=await e.getSignatures()}catch(e){console.warn("getSignatures failed:",e)}if(e===digital_signature_properties_manager_classPrivateFieldGet(pF,this)){digital_signature_properties_manager_classPrivateFieldSet(lF,this,t||[]);digital_signature_properties_manager_classPrivateFieldSet(uF,this,!1);if(0!==digital_signature_properties_manager_classPrivateFieldGet(lF,this).length){digital_signature_properties_manager_assertClassBrand(gF,this,_showButton).call(this);for(const e of digital_signature_properties_manager_classPrivateFieldGet(lF,this))digital_signature_properties_manager_classPrivateFieldGet(dF,this).set(e.id,{status:"unknown",errorCode:null,message:null,certificate:null,documentModifiedAfterSigning:!e.coversWholeDocument,modificationsAfterSignature:e.modificationsAfterSignature});digital_signature_properties_manager_assertClassBrand(gF,this,digital_signature_properties_manager_render).call(this);digital_signature_properties_manager_assertClassBrand(gF,this,_updateButtonState).call(this);for(const t of digital_signature_properties_manager_classPrivateFieldGet(lF,this))digital_signature_properties_manager_assertClassBrand(gF,this,digital_signature_properties_manager_verify).call(this,t,e)}else digital_signature_properties_manager_assertClassBrand(gF,this,_hideButton).call(this)}}}function _showButton(){const e=digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesButton.parentElement;e&&(e.hidden=!1);const t=digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesSeparator;t&&(t.hidden=!1)}function _hideButton(){const e=digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesButton.parentElement;e&&(e.hidden=!0);const t=digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesSeparator;t&&(t.hidden=!0)}function digital_signature_properties_manager_toggle(){digital_signature_properties_manager_classPrivateFieldGet(hF,this)?digital_signature_properties_manager_assertClassBrand(gF,this,digital_signature_properties_manager_close).call(this):digital_signature_properties_manager_assertClassBrand(gF,this,_open).call(this)}function _open(){digital_signature_properties_manager_classPrivateFieldSet(hF,this,!0);digital_signature_properties_manager_classPrivateFieldGet(oF,this)?.dispatch("switchannotationeditormode",{source:this,mode:f.NONE});digital_signature_properties_manager_classPrivateFieldGet(oF,this)?.dispatch("findbarclose",{source:this});digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesPanel.classList.remove("hidden");digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesButton.setAttribute("aria-expanded","true");digital_signature_properties_manager_classPrivateFieldGet(_F,this)&&digital_signature_properties_manager_assertClassBrand(gF,this,digital_signature_properties_manager_render).call(this)}function digital_signature_properties_manager_close(){digital_signature_properties_manager_classPrivateFieldSet(hF,this,!1);digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesPanel.classList.add("hidden");digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesButton.setAttribute("aria-expanded","false")}function _get_worst(e){let t="verified";for(const i of digital_signature_properties_manager_classPrivateFieldGet(dF,e).values())i?.status&&aF[i.status].priority>aF[t].priority&&(t=i.status);return t}function _get_bannerState(e){if(0===digital_signature_properties_manager_classPrivateFieldGet(dF,e).size)return{worst:"unknown",severity:"error",count:0};const t=digital_signature_properties_manager_classPrivateGetter(gF,e,_get_worst);let i=0;for(const a of digital_signature_properties_manager_classPrivateFieldGet(dF,e).values())a?.status===t&&i++;return{worst:t,severity:aF[t].severity,count:i}}function digital_signature_properties_manager_render(){if(!digital_signature_properties_manager_classPrivateFieldGet(hF,this)){digital_signature_properties_manager_classPrivateFieldSet(_F,this,!0);return}digital_signature_properties_manager_classPrivateFieldSet(_F,this,!1);const e=digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesList,t=digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesBanner,i=document.createDocumentFragment();if(digital_signature_properties_manager_classPrivateFieldGet(uF,this)){t.hidden=!0;e.replaceChildren();return}const{worst:a,severity:s,count:n}=digital_signature_properties_manager_classPrivateGetter(gF,this,_get_bannerState);t.replaceChildren();t.hidden=!1;t.className=`sigBanner ${s}`;t.setAttribute("data-l10n-id",aF[a].bannerId);t.setAttribute("data-l10n-args",JSON.stringify({count:n}));const r=new Map,o=[];for(const e of digital_signature_properties_manager_classPrivateFieldGet(lF,this))e.parentId?r.getOrInsertComputed(e.parentId,makeArr).push(e):o.push(e);const l="verified"===s;for(const e of o)i.append(digital_signature_properties_manager_assertClassBrand(gF,this,_renderCard).call(this,e,r,0,l));e.replaceChildren(i)}function _renderCard(e,t,i,a){const s=t.get(e.id)||[],n=document.createElement("li");n.classList.add("sigCard");0===i&&a&&n.classList.add("sigCard--top-allfine");const r=digital_signature_properties_manager_classPrivateFieldGet(dF,this).get(e.id),o=r?.certificate?.subjectCN;if(o){const e=document.createElement("div");e.className="signer";e.textContent=o;n.append(e)}const l=document.createElement("div");l.classList.add("row",`status--${r.status}`);const d=document.createElement("span");d.setAttribute("data-l10n-id",aF[r.status].statusId);l.append(d);n.append(l);if("invalid"===r.status&&r.message){const e=document.createElement("div");e.className="detail";e.setAttribute("data-l10n-id","pdfjs-digital-signature-properties-reason");e.setAttribute("data-l10n-args",JSON.stringify({reason:r.message}));n.append(e)}const c=r.certificate;let h="unknown";if(c)switch(r.status){case"verified":h="trusted";break;case"expired":h="expired";break;case"revoked":h="revoked";break;case"untrusted":h="untrusted";break;default:h="unknown"}if("invalid"!==r.status){const e=document.createElement("div");e.classList.add("row",`cert--${h}`);const t=document.createElement("span");let i=sF[h],a=null;if(c?.issuerCN&&"trusted"===h)a={issuer:c.issuerCN};else if("expired"===h){const e=function expirationDateForCert(e){if(!e)return null;const t=Date.now(),i=Array.isArray(e.chain)&&e.chain.length?e.chain:[e];for(const e of i){if("string"!=typeof e?.notAfter||!e.notAfter)continue;const i=new Date(e.notAfter),a=i.getTime();if(Number.isFinite(a)&&a<t)return i}return null}(c);if(e){i="pdfjs-digital-signature-properties-certificate-expired-with-date";a={dateObj:e.valueOf()}}}else if("untrusted"===h){const e=function untrustedCertLabel(e,t){const i=(e||"").toUpperCase(),a=t?{issuer:t}:null;return i.includes("UNKNOWN_ISSUER")&&a?{id:"pdfjs-digital-signature-properties-certificate-untrusted-unknown-issuer",args:a}:i.includes("SELF_SIGNED")&&a?{id:"pdfjs-digital-signature-properties-certificate-untrusted-self-signed",args:a}:i.includes("UNTRUSTED_ISSUER")&&a?{id:"pdfjs-digital-signature-properties-certificate-untrusted-untrusted-issuer",args:a}:{id:"pdfjs-digital-signature-properties-certificate-untrusted",args:null}}(r.errorCode,c?.issuerCN);i=e.id;a=e.args}t.setAttribute("data-l10n-id",i);a&&t.setAttribute("data-l10n-args",JSON.stringify(a));e.append(t);n.append(e)}if("untrusted"===r.status&&r.message){const e=document.createElement("div");e.className="detail";e.textContent=r.message;n.append(e)}if("expired"===r.status&&r.message){const e=document.createElement("div");e.className="detail";e.textContent=r.message;n.append(e)}const u=PDFDateString.toDateObject(e.signingTime);if(u){const e=document.createElement("div");e.className="detail";e.setAttribute("data-l10n-id","pdfjs-digital-signature-properties-timestamp");e.setAttribute("data-l10n-args",JSON.stringify({dateObj:u.valueOf()}));n.append(e)}if(c&&"function"==typeof digital_signature_properties_manager_classPrivateFieldGet(rF,this)?.viewCertificate){const e=document.createElement("button");e.className="viewCert";e.type="button";e.setAttribute("data-l10n-id","pdfjs-digital-signature-properties-view-certificate");e.addEventListener("click",e=>{e.stopPropagation();digital_signature_properties_manager_classPrivateFieldGet(rF,this).viewCertificate(c)});n.append(e)}if(s.length>0){const r=document.createElement("ul");r.classList.add("signaturePropertiesList","nested");for(const e of s)r.append(digital_signature_properties_manager_assertClassBrand(gF,this,_renderCard).call(this,e,t,i+1,a));if(0===i){const i=document.createElement("details");i.className="subSignatures";i.open=!0;const a=document.createElement("summary");a.setAttribute("data-l10n-id","pdfjs-digital-signature-properties-sub-signatures");a.setAttribute("data-l10n-args",JSON.stringify({count:digital_signature_properties_manager_assertClassBrand(gF,this,_countDescendants).call(this,e.id,t)}));i.append(a);i.append(r);n.append(i)}else n.append(r)}return n}function _countDescendants(e,t){const i=t.get(e);if(!i)return 0;let a=i.length;for(const e of i)a+=digital_signature_properties_manager_assertClassBrand(gF,this,_countDescendants).call(this,e.id,t);return a}async function digital_signature_properties_manager_verify(e,t){if(!digital_signature_properties_manager_classPrivateFieldGet(rF,this)||digital_signature_properties_manager_classPrivateFieldGet(cF,this).has(e.id))return;digital_signature_properties_manager_classPrivateFieldGet(cF,this).add(e.id);digital_signature_properties_manager_assertClassBrand(gF,this,digital_signature_properties_manager_render).call(this);let i;try{const a=await t.getSignatureData(e.id);if(t!==digital_signature_properties_manager_classPrivateFieldGet(pF,this))return;if(!a)throw new Error("missing signature data");i=await digital_signature_properties_manager_classPrivateFieldGet(rF,this).verify({...e,...a})}catch(t){console.warn("signature verify failed:",t);i={status:"unknown",errorCode:"BRIDGE_ERROR",message:t?.message??null,certificate:null,documentModifiedAfterSigning:!e.coversWholeDocument,modificationsAfterSignature:e.modificationsAfterSignature}}digital_signature_properties_manager_classPrivateFieldGet(cF,this).delete(e.id);if(t===digital_signature_properties_manager_classPrivateFieldGet(pF,this)){digital_signature_properties_manager_classPrivateFieldGet(dF,this).set(e.id,i);digital_signature_properties_manager_assertClassBrand(gF,this,digital_signature_properties_manager_render).call(this);digital_signature_properties_manager_assertClassBrand(gF,this,_updateButtonState).call(this)}}function _updateButtonState(){const e=digital_signature_properties_manager_classPrivateFieldGet(nF,this).signaturePropertiesButton;e.classList.remove("state-loading","state-verified","state-warn","state-error");if(0!==digital_signature_properties_manager_classPrivateFieldGet(lF,this).length)if(digital_signature_properties_manager_classPrivateFieldGet(cF,this).size>0)e.classList.add("state-loading");else switch(digital_signature_properties_manager_classPrivateGetter(gF,this,_get_worst)){case"invalid":case"revoked":case"unknown":e.classList.add("state-error");break;case"expired":case"untrusted":e.classList.add("state-warn");break;default:e.classList.add("state-verified")}}function web_toolbar_classPrivateFieldInitSpec(e,t,i){web_toolbar_checkPrivateRedeclaration(e,t),t.set(e,i)}function web_toolbar_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function web_toolbar_classPrivateFieldGet(e,t){return e.get(web_toolbar_assertClassBrand(e,t))}function toolbar_classPrivateFieldSet(e,t,i){return e.set(web_toolbar_assertClassBrand(e,t),i),i}function web_toolbar_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}var mF=new WeakMap,fF=new WeakMap,vF=new WeakMap,PF=new WeakMap,wF=new WeakMap,FF=new WeakSet;class Toolbar{constructor(e,t,i,a,s,n=0){!function toolbar_classPrivateMethodInitSpec(e,t){web_toolbar_checkPrivateRedeclaration(e,t),t.add(e)}(this,FF);web_toolbar_classPrivateFieldInitSpec(this,mF,null);web_toolbar_classPrivateFieldInitSpec(this,fF,void 0);web_toolbar_classPrivateFieldInitSpec(this,vF,"auto");web_toolbar_classPrivateFieldInitSpec(this,PF,25);web_toolbar_classPrivateFieldInitSpec(this,wF,.1);toolbar_classPrivateFieldSet(fF,this,e);toolbar_classPrivateFieldSet(vF,this,i);toolbar_classPrivateFieldSet(PF,this,s);toolbar_classPrivateFieldSet(wF,this,a);this.eventBus=t;const r=[{element:e.previous,eventName:"previouspage"},{element:e.next,eventName:"nextpage"},{element:e.print,eventName:"print"},{element:e.presentationModeButton,eventName:"presentationmode"},{element:e.download,eventName:"download"},{element:e.movePageUp,eventName:"movePageUp"},{element:e.movePageDown,eventName:"movePageDown"}];web_toolbar_assertClassBrand(FF,this,toolbar_bindListeners).call(this,r);web_toolbar_assertClassBrand(FF,this,_updateToolbarDensity).call(this,{value:n});this.reset()}get maxZoom(){return web_toolbar_classPrivateFieldGet(PF,this)}set maxZoom(e){toolbar_classPrivateFieldSet(PF,this,e)}get minZoom(){return web_toolbar_classPrivateFieldGet(wF,this)}set minZoom(e){toolbar_classPrivateFieldSet(wF,this,e)}setPageNumber(e,t){this.pageNumber=e;this.pageLabel=t;web_toolbar_assertClassBrand(FF,this,toolbar_updateUIState).call(this,!1)}setPagesCount(e,t){this.pagesCount=e;this.hasPageLabels=t;web_toolbar_assertClassBrand(FF,this,toolbar_updateUIState).call(this,!0)}setPageScale(e,t){this.pageScaleValue=(e||t).toString();this.pageScale=t;web_toolbar_assertClassBrand(FF,this,toolbar_updateUIState).call(this,!1)}reset(){toolbar_classPrivateFieldSet(mF,this,null);this.pageNumber=0;this.pageLabel=null;this.hasPageLabels=!1;this.pagesCount=0;const e=web_toolbar_classPrivateFieldGet(vF,this)||"auto";this.pageScaleValue=e;Number(e)&&(this.pageScale=Number(e));web_toolbar_assertClassBrand(FF,this,toolbar_updateUIState).call(this,!0);this.updateLoadingIndicatorState();web_toolbar_assertClassBrand(FF,this,_editorModeChanged).call(this,{mode:f.DISABLE})}updateLoadingIndicatorState(e=!1){const{pageNumber:t}=web_toolbar_classPrivateFieldGet(fF,this);t.classList.toggle("loading",e)}}function _updateToolbarDensity({value:e}){let t="normal";switch(e){case 1:t="compact";break;case 2:t="touch"}document.documentElement.setAttribute("data-toolbar-density",t)}function toolbar_bindListeners(e){const{eventBus:t}=this,{editorHighlightColorPicker:i,editorHighlightButton:a,pageNumber:s,scaleSelect:n}=web_toolbar_classPrivateFieldGet(fF,this),r=this;for(const{element:i,eventName:a,eventDetails:s,telemetry:n}of e)i&&i.addEventListener("click",e=>{null!==a&&t.dispatch(a,{source:this,...s,isFromKeyboard:0===e.detail});n&&t.dispatch("reporttelemetry",{source:this,details:n})});s.addEventListener("click",function(){this.select()});s.addEventListener("change",function(){t.dispatch("pagenumberchanged",{source:r,value:this.value})});t.on("pagesedited",({pagesMapper:e})=>{const t=e.pagesNumber;t!==this.pagesCount&&this.setPagesCount(t,this.hasPageLabels)},Nh);n.addEventListener("change",function(){"custom"!==this.value&&t.dispatch("scalechanged",{source:r,value:this.value})});n.addEventListener("click",function({target:e}){this.value===r.pageScaleValue&&"OPTION"===e.tagName.toUpperCase()&&this.blur()});n.oncontextmenu=noContextMenu;t.on("annotationeditormodechanged",web_toolbar_assertClassBrand(FF,this,_editorModeChanged).bind(this),Nh);t.on("showannotationeditorui",({mode:e})=>{if(e===f.HIGHLIGHT)a.click()},Nh);t.on("toolbardensity",web_toolbar_assertClassBrand(FF,this,_updateToolbarDensity).bind(this),Nh);t._on("closeopenpopovers",({source:e})=>{e!==this&&t.dispatch("switchannotationeditormode",{source:this,mode:f.NONE})});t._on("showannotationeditorui",({mode:e})=>{if(e===f.HIGHLIGHT)a.click()});t._on("spreadmodechanged",()=>{web_toolbar_assertClassBrand(FF,this,toolbar_updateUIState).call(this,!1)});t._on("scrollmodechanged",()=>{web_toolbar_assertClassBrand(FF,this,toolbar_updateUIState).call(this,!1)});if(i){t.on("annotationeditoruimanager",({uiManager:e})=>{const t=toolbar_classPrivateFieldSet(mF,this,new ColorPicker({uiManager:e}));e.setMainHighlightColorPicker(t);i.append(t.renderMainDropdown())},Nh);t.on("mainhighlightcolorpickerupdatecolor",({value:e})=>{web_toolbar_classPrivateFieldGet(mF,this)?.updateColor(e)},Nh)}}function _editorModeChanged({mode:e}){e!==f.NONE&&e!==f.DISABLE&&this.eventBus.dispatch("closeopenpopovers",{source:this});const{editorCommentButton:t,editorCommentParamsToolbar:i,editorFreeTextButton:a,editorFreeTextParamsToolbar:s,editorHighlightButton:n,editorHighlightParamsToolbar:r,editorInkButton:o,editorInkParamsToolbar:l,editorStampButton:d,editorStampParamsToolbar:c,editorSignatureButton:h,editorSignatureParamsToolbar:u}=web_toolbar_classPrivateFieldGet(fF,this);toggleExpandedBtn(t,e===f.POPUP,i);toggleExpandedBtn(a,e===f.FREETEXT,s);toggleExpandedBtn(n,e===f.HIGHLIGHT,r);toggleExpandedBtn(o,e===f.INK,l);toggleExpandedBtn(d,e===f.STAMP,c);toggleExpandedBtn(h,e===f.SIGNATURE,u);const _=e===f.DISABLE;t&&(t.disabled=_);a&&(a.disabled=_);n&&(n.disabled=_);o&&(o.disabled=_);d&&(d.disabled=_);h&&(h.disabled=_)}function toolbar_updateUIState(e=!1){const{pageNumber:t,pagesCount:i,pageScaleValue:a,pageScale:s}=this,n=web_toolbar_classPrivateFieldGet(fF,this);if(e){if(this.hasPageLabels){n.pageNumber.type="text";n.numPages.setAttribute("data-l10n-id","pdfjs-page-of-pages")}else{n.pageNumber.type="number";n.numPages.setAttribute("data-l10n-id","pdfjs-of-pages");n.numPages.setAttribute("data-l10n-args",JSON.stringify({pagesCount:i}))}n.pageNumber.max=i}if(this.hasPageLabels){n.pageNumber.value=this.pageLabel;n.numPages.setAttribute("data-l10n-args",JSON.stringify({pageNumber:t,pagesCount:i}))}else n.pageNumber.value=t;n.previous.disabled=t<=1;n.next.disabled=t>=i;const r=Number(this.minZoom)??.1,o=Number(this.maxZoom)??25;n.zoomOut&&(n.zoomOut.disabled=s<=r);n.zoomIn&&(n.zoomIn.disabled=s>=o);let l=!1;if(n.scaleSelect.options)for(const e of n.scaleSelect.options){const t=parseFloat(e.value),i=parseFloat(a);if(!isNaN(t)&&!isNaN(i)&&Math.abs(t-i)<1e-4||e.value===a){e.selected=!0;l=!0}else e.selected=!1}l||(n.customScaleOption.selected=!0);const d="number"!=typeof s||Number.isNaN(s)?0:Math.round(1e4*s)/100;n.customScaleOption.setAttribute("data-l10n-args",JSON.stringify({scale:d}));this.eventBus.dispatch("updateuistate",{source:this,widget:"Toolbar",pageNumber:t,pagesCount:i,pageScaleValue:a,pageScale:s})}class ViewHistory{constructor(e,t=20){this.fingerprint=e;this.cacheSize=t;this._initializedPromise=this._readFromStorage().then(e=>{const t=JSON.parse(e||"{}");let i=-1;if(Array.isArray(t.files)){for(;t.files.length>=this.cacheSize;)t.files.shift();for(let e=0,a=t.files.length;e<a;e++){if(t.files[e].fingerprint===this.fingerprint){i=e;break}}}else t.files=[];-1===i&&(i=t.files.push({fingerprint:this.fingerprint})-1);this.file=t.files[i];this.database=t})}async _writeToStorage(){if(AppOptions.get("disableHistory"))return;const e=JSON.stringify(this.database);try{localStorage.setItem("pdfjs.history",e)}catch(e){}}async _readFromStorage(){if(!AppOptions.get("disableHistory"))try{return localStorage.getItem("pdfjs.history")}catch(e){return}}async set(e,t){await this._initializedPromise;this.file[e]=t;return this._writeToStorage()}async setMultiple(e){await this._initializedPromise;for(const t in e)this.file[t]=e[t];return this._writeToStorage()}async get(e,t){await this._initializedPromise;const i=this.file[e];return void 0!==i?i:t}async getMultiple(e){await this._initializedPromise;const t=Object.create(null);for(const i in e){const a=this.file[i];t[i]=void 0!==a?a:e[i]}return t}}function views_manager_checkPrivateRedeclaration(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function views_manager_classPrivateFieldGet(e,t){return e.get(views_manager_assertClassBrand(e,t))}function views_manager_assertClassBrand(e,t,i){if("function"==typeof e?e===t:e.has(t))return arguments.length<3?t:i;throw new TypeError("Private element is not present on this object")}const bF="viewsManagerResizing",yF="pdfSidebarNotification";var SF=new WeakMap,CF=new WeakSet;class ViewsManager extends Sidebar{constructor({elements:{outerContainer:e,sidebarContainer:t,toggleButton:i,resizer:a,thumbnailButton:s,outlineButton:n,attachmentsButton:r,layersButton:o,thumbnailsView:l,outlinesView:d,attachmentsView:c,layersView:h,viewsManagerAddFile:{button:u},viewsManagerCurrentOutlineButton:_,viewsManagerSelectorButton:p,viewsManagerSelectorOptions:g,viewsManagerHeaderLabel:m,viewsManagerStatus:f},eventBus:v,l10n:P,enableMerge:w=!1,enableSplitMerge:F=!1,globalAbortSignal:b}){super({sidebar:t,resizer:a,toggleButton:i},"ltr"===P.getDirection(),!1,b);!function views_manager_classPrivateMethodInitSpec(e,t){views_manager_checkPrivateRedeclaration(e,t),t.add(e)}(this,CF);!function views_manager_classPrivateFieldInitSpec(e,t,i){views_manager_checkPrivateRedeclaration(e,t),t.set(e,i)}(this,SF,!window.matchMedia("(prefers-reduced-motion: reduce)").matches);this.isOpen=!1;this.active=ph;this.isInitialViewSet=!1;this.isInitialEventDispatched=!1;this.onToggled=null;this.onUpdateThumbnails=null;this.outerContainer=e;this.sidebarContainer=t;this.toggleButton=i;this.resizer=a;this.thumbnailButton=s;this.outlineButton=n;this.attachmentsButton=r;this.layersButton=o;this.thumbnailsView=l;this.outlinesView=d;this.attachmentsView=c;this.layersView=h;this.viewsManagerAddFileButton=u;this.viewsManagerCurrentOutlineButton=_;this.viewsManagerHeaderLabel=m;this.viewsManagerStatus=f;this.eventBus=v;!F&&f&&(f.hidden=!0);this._enableSplitMerge=F;this._enableMerge=w;w||(u.hidden=!0);this.menu=g&&p?new Menu(g,p,[s,n,r,o]):null;xF._||(xF._=Object.freeze({pagesTitle:"pdfjs-views-manager-pages-title",outlinesTitle:"pdfjs-views-manager-outlines-title1",attachmentsTitle:"pdfjs-views-manager-attachments-title",layersTitle:"pdfjs-views-manager-layers-title1",notificationButton:"pdfjs-toggle-views-manager-notification-button",toggleButton:"pdfjs-toggle-views-manager-button1"}));views_manager_assertClassBrand(CF,this,views_manager_addEventListeners).call(this)}reset(){this.isInitialViewSet=!1;this.isInitialEventDispatched=!1;views_manager_assertClassBrand(CF,this,_hideUINotification).call(this,!0);this.switchView(ph);this.outlineButton.disabled=this.attachmentsButton.disabled=this.layersButton.disabled=!1;this.outlineButton.hidden=!1;this.attachmentsButton.hidden=!1;this.layersButton.hidden=!1;this.viewsManagerCurrentOutlineButton&&(this.viewsManagerCurrentOutlineButton.disabled=!0)}get visibleView(){return this.isOpen?this.active:_h}setInitialView(e=_h){if(!this.isInitialViewSet){this.isInitialViewSet=!0;if(e!==_h&&e!==uh){this.switchView(e,!0);this.isInitialEventDispatched||views_manager_assertClassBrand(CF,this,_dispatchEvent).call(this)}else views_manager_assertClassBrand(CF,this,_dispatchEvent).call(this)}}switchView(e,t=!1){const i=e!==this.active;let a=!1,s=null;switch(e){case _h:this.isOpen&&this.close();return;case ph:s="pagesTitle";this.isOpen&&i&&(a=!0);break;case gh:s="outlinesTitle";if(this.outlineButton.disabled)return;break;case mh:s="attachmentsTitle";if(this.attachmentsButton.disabled)return;break;case fh:s="layersTitle";if(this.layersButton.disabled)return;break;default:ngx_console_NgxConsole.error(`PDFSidebar.switchView: "${e}" is not a valid view.`);return}this._enableSplitMerge&&this.viewsManagerStatus&&(this.viewsManagerStatus.hidden=e!==ph);this.viewsManagerAddFileButton&&(this.viewsManagerAddFileButton.hidden=!this._enableMerge||e!==ph);this.viewsManagerCurrentOutlineButton&&(this.viewsManagerCurrentOutlineButton.hidden=e!==gh);this.viewsManagerHeaderLabel&&this.viewsManagerHeaderLabel.setAttribute("data-l10n-id",xF._[s]||"");this.active=e;toggleSelectedBtn(this.thumbnailButton,e===ph,this.thumbnailsView);toggleSelectedBtn(this.outlineButton,e===gh,this.outlinesView);toggleSelectedBtn(this.attachmentsButton,e===mh,this.attachmentsView);toggleSelectedBtn(this.layersButton,e===fh,this.layersView);if(!t||this.isOpen){if(a){this.onUpdateThumbnails();this.onToggled()}i&&views_manager_assertClassBrand(CF,this,_dispatchEvent).call(this)}else this.open()}open(){if(!this.isOpen&&this._sidebar){this.isOpen=!0;this.onResizing(this.width);this._sidebar.hidden=!1;toggleExpandedBtn(this.toggleButton,!0);this.switchView(this.active);if(views_manager_classPrivateFieldGet(SF,this))queueMicrotask(()=>{this.outerContainer.classList.add("viewsManagerMoving","viewsManagerOpen")});else{this.outerContainer.classList.add("viewsManagerOpen");this.eventBus.dispatch("resize",{source:this,sidebarToggle:!0})}this.active===ph&&this.onUpdateThumbnails();this.onToggled();views_manager_assertClassBrand(CF,this,_dispatchEvent).call(this);views_manager_assertClassBrand(CF,this,_hideUINotification).call(this)}}close(e=null){if(this.isOpen&&this._sidebar){this.isOpen=!1;this._sidebar.hidden=!0;toggleExpandedBtn(this.toggleButton,!1);this.outerContainer.classList.add("viewsManagerMoving");this.outerContainer.classList.remove("viewsManagerOpen");this.onToggled();views_manager_assertClassBrand(CF,this,_dispatchEvent).call(this);this.eventBus.dispatch("resize",{source:this,sidebarToggle:!0});e?.detail>0&&this.toggleButton.blur()}}toggle(e=null){super.toggle();this.isOpen?this.close(e):this.open()}onStartResizing(){this.outerContainer.classList.add(bF)}onStopResizing(){this.eventBus.dispatch("resize",{source:this});this.outerContainer.classList.remove(bF)}onResizing(e){getDocStyle(this.outerContainer).setProperty("--viewsManager-width",`${e}px`)}}function _dispatchEvent(){this.isInitialViewSet&&(this.isInitialEventDispatched||=!0);this.eventBus.dispatch("sidebarviewchanged",{source:this,view:this.visibleView})}function _showUINotification(){this.toggleButton.setAttribute("data-l10n-id",xF._.notificationButton);this.isOpen||this.toggleButton.classList.add(yF)}function _hideUINotification(e=!1){(this.isOpen||e)&&this.toggleButton.classList.remove(yF);e&&this.toggleButton.setAttribute("data-l10n-id",xF._.toggleButton)}function views_manager_addEventListeners(){const{eventBus:e,outerContainer:t}=this;views_manager_classPrivateFieldGet(SF,this)&&this.sidebarContainer&&this.sidebarContainer.addEventListener("transitionend",i=>{if(i.target===this.sidebarContainer){t.classList.remove("viewsManagerMoving");e.dispatch("resize",{source:this,sidebarToggle:!0})}});this.viewsManagerHeaderLabel?.addEventListener("dblclick",t=>{this.active!==gh?this.active===fh&&e.dispatch("resetlayers",{source:this}):e.dispatch("toggleoutlinetree",{source:this})});this.thumbnailButton?.addEventListener("click",()=>{this.switchView(ph)});this.outlineButton?.addEventListener("click",()=>{this.switchView(gh)});this.attachmentsButton?.addEventListener("click",()=>{this.switchView(mh)});this.layersButton?.addEventListener("click",()=>{this.switchView(fh)});this.viewsManagerCurrentOutlineButton?.addEventListener("click",()=>{e.dispatch("currentoutlineitem",{source:this})});const onTreeLoaded=(e,t,i)=>{t.disabled=!e;t.hidden=!e;e?views_manager_assertClassBrand(CF,this,_showUINotification).call(this):this.active===i&&this.switchView(ph)};e.on("outlineloaded",e=>{onTreeLoaded(e.outlineCount,this.outlineButton,gh);e.currentOutlineItemPromise.then(e=>{this.isInitialViewSet&&this.viewsManagerCurrentOutlineButton&&(this.viewsManagerCurrentOutlineButton.disabled=!e)})},Nh);e.on("attachmentsloaded",e=>{onTreeLoaded(e.attachmentsCount,this.attachmentsButton,mh)},Nh);e.on("layersloaded",e=>{onTreeLoaded(e.layersCount,this.layersButton,fh)},Nh);e.on("presentationmodechanged",e=>{e.state===dh&&this.visibleView===ph&&this.onUpdateThumbnails()},Nh)}var xF={_:null};const kF=-1,EF=1,AF={initialBookmark:document.location.hash.substring(1),_initializedCapability:{...Promise.withResolvers(),settled:!1},appConfig:null,pdfDocument:null,pdfLoadingTask:null,printService:null,pdfViewer:null,pdfThumbnailViewer:null,pdfRenderingQueue:null,pdfPresentationMode:null,pdfDocumentProperties:null,pdfLinkService:null,pdfTextExtractor:null,pdfHistory:null,viewsManager:null,pdfOutlineViewer:null,pdfAttachmentViewer:null,pdfLayerViewer:null,pdfCursorTools:null,pdfScriptingManager:null,pdfWorker:null,store:null,downloadManager:null,overlayManager:null,preferences:new class Preferences extends BasePreferences{async _writeToStorage(e){try{localStorage.setItem("pdfjs.preferences",JSON.stringify(e))}catch(e){}}async _readFromStorage(e){try{return{prefs:JSON.parse(localStorage.getItem("pdfjs.preferences"))}}catch(e){return{}}}},toolbar:null,secondaryToolbar:null,eventBus:null,l10n:null,annotationEditorParams:null,signaturePropertiesManager:null,imageAltTextSettings:null,isInitialViewSet:!1,isViewerEmbedded:window.parent!==window,url:"",baseUrl:"",mlManager:null,_downloadUrl:"",_eventBusAC:null,_windowAC:null,_globalAbortController:new AbortController,documentInfo:null,metadata:null,_contentDispositionFilename:null,_contentLength:null,_saveInProgress:!1,_wheelUnusedTicks:0,_wheelUnusedFactor:1,_touchManager:null,_touchUnusedTicks:0,_touchUnusedFactor:1,_PDFBug:null,_hasAnnotationEditors:!1,_title:document.title,_printAnnotationStoragePromise:null,_isCtrlKeyDown:!1,_caretBrowsing:null,_isScrolling:!1,editorUndoBar:null,pageOrder:null,_printPermissionPromise:null,async initialize(e){this.appConfig=e;this.cspPolicyService=e.cspPolicyService;try{await this.preferences.initializedPromise}catch(e){ngx_console_NgxConsole.error("initialize:",e)}AppOptions.get("pdfBugEnabled")&&await this._parseHashParams();let t;switch(AppOptions.get("viewerCssTheme")){case 1:t="light";break;case 2:t="dark"}t&&getDocStyle(e.appContainer).setProperty("color-scheme",t);this.l10n=await this.externalServices.createL10n();(e.appContainer||document.documentElement).dir=this.l10n.getDirection();this.l10n.translate(e.appContainer||document.documentElement);this.isViewerEmbedded&&AppOptions.get("externalLinkTarget")===Rh.NONE&&AppOptions.set("externalLinkTarget",Rh.TOP);await this._initializeViewerComponents();this.bindEvents();this.bindWindowEvents();this._initializedCapability.settled=!0;this._initializedCapability.resolve();this.initializeLoadingBar()},async _parseHashParams(){const e=document.location.hash.substring(1);if(!e)return;const{mainContainer:t,viewerContainer:i}=this.appConfig,a=parseQueryString(e),loadPDFBug=async()=>{if(this._PDFBug)return;const{PDFBug:e}=await import(
/*webpackIgnore: true*/
/*@vite-ignore*/
AppOptions.get("debuggerSrc"));this._PDFBug=e};if("true"===a.get("disableworker"))try{GlobalWorkerOptions.workerSrc||=AppOptions.get("workerSrc");await import(
/*webpackIgnore: true*/
/*@vite-ignore*/
PDFWorker.workerSrc);AppOptions.set("workerPort",null)}catch(e){ngx_console_NgxConsole.error("_parseHashParams:",e)}if(a.has("textlayer"))switch(a.get("textlayer")){case"off":AppOptions.set("textLayerMode",vh);break;case"visible":case"shadow":case"hover":i.classList.add(`textLayer-${a.get("textlayer")}`);try{await loadPDFBug();this._PDFBug.loadCSS()}catch(e){ngx_console_NgxConsole.error("_parseHashParams:",e)}}if(a.has("pdfbug")){const e=a.get("pdfbug").split(",");try{await loadPDFBug();this._PDFBug.init(t,e)}catch(e){ngx_console_NgxConsole.error("_parseHashParams:",e)}const i={pdfBug:!0,fontExtraProperties:!0};globalThis.StepperManager?.enabled&&(i.minDurationToUpdateCanvas=0);AppOptions.setAll(i)}a.has("locale")&&AppOptions.set("localeProperties",{lang:a.get("locale")});const s={disableAutoFetch:e=>"true"===e,disableFontFace:e=>"true"===e,disableHistory:e=>"true"===e,disableRange:e=>"true"===e,disableStream:e=>"true"===e,verbosity:e=>0|e};for(const e in s){const t=s[e],i=e.toLowerCase();a.has(i)&&AppOptions.set(e,t(a.get(i)))}},async _initializeViewerComponents(){const{appConfig:e,externalServices:t,l10n:i,mlManager:a}=this,s=this._globalAbortController.signal,n=new EventBus;this.eventBus=AppOptions.eventBus=n;a?.setEventBus(n,s);const r=this.overlayManager=new OverlayManager,o=this.pdfRenderingQueue=new PDFRenderingQueue;o.onIdle=this._cleanup.bind(this);const l=this.pdfLinkService=new PDFLinkService({eventBus:n,externalLinkTarget:AppOptions.get("externalLinkTarget"),externalLinkRel:AppOptions.get("externalLinkRel"),ignoreDestinationZoom:AppOptions.get("ignoreDestinationZoom")}),d=AppOptions.get("supportsDownloading"),c=this.downloadManager=d?new DownloadManager:null;e.secondaryToolbar?.downloadButton&&(e.secondaryToolbar.downloadButton.hidden=!d);e.toolbar?.download&&(e.toolbar.download.hidden=!d);let h=PDFFindController;AppOptions.get("findController")&&(h=AppOptions.get("findController"));const u=new h({linkService:l,eventBus:n,pageViewMode:AppOptions.get("pageViewMode"),updateMatchesCountOnProgress:!0,listenToEventBus:!1});this.customFindController=u;const _=new h({linkService:l,eventBus:n,pageViewMode:AppOptions.get("pageViewMode"),updateMatchesCountOnProgress:!0,listenToEventBus:!0});this.findController=_;const p=this.pdfScriptingManager=new PDFScriptingManager({eventBus:n,externalServices:t,docProperties:this._scriptingDocProperties.bind(this)}),g=e.mainContainer,m=e.viewerContainer,v=AppOptions.get("annotationEditorMode"),P=AppOptions.get("forcePageColors")||window.matchMedia("(forced-colors: active)").matches,w=P?{background:AppOptions.get("pageColorsBackground"),foreground:AppOptions.get("pageColorsForeground")}:null,F=AppOptions.get("enableMerge"),b=AppOptions.get("enableSplitMerge");let y;y=AppOptions.get("enableUpdatedAddImage")?e.newAltTextDialog?new NewAltTextManager(e.newAltTextDialog,r,n):null:e.altTextDialog?new AltTextManager(e.altTextDialog,g,r,n):null;e.editorUndoBar&&(this.editorUndoBar=new EditorUndoBar(e.editorUndoBar,n));const S=AppOptions.get("enableSignatureEditor")&&e.addSignatureDialog?new SignatureManager(e.addSignatureDialog,e.editSignatureDialog,e.annotationEditorParams?.editorSignatureAddSignature||null,r,i,t.createSignatureStorage(n,s),n):null,C=AppOptions.get("enableComment")&&e.editCommentDialog?new CommentManager(e.editCommentDialog,{learnMoreUrl:AppOptions.get("commentLearnMoreUrl"),sidebar:e.annotationEditorParams?.editorCommentsSidebar||null,sidebarResizer:e.annotationEditorParams?.editorCommentsSidebarResizer||null,commentsList:e.annotationEditorParams?.editorCommentsSidebarList||null,commentCount:e.annotationEditorParams?.editorCommentsSidebarCount||null,sidebarTitle:e.annotationEditorParams?.editorCommentsSidebarTitle||null,closeButton:e.annotationEditorParams?.editorCommentsSidebarCloseButton||null,commentToolbarButton:e.toolbar?.editorCommentButton||null},n,l,r,"ltr"===i.getDirection(),P,s):null,x=AppOptions.get("maxCanvasPixels"),k=AppOptions.get("maxCanvasDim"),E=AppOptions.get("capCanvasAreaFactor"),A=this.pdfViewer=new PDFViewer({container:g,viewer:m,viewerAlert:e.viewerAlert,eventBus:n,renderingQueue:o,linkService:l,downloadManager:c,altTextManager:y,commentManager:C,signatureManager:S,editorUndoBar:this.editorUndoBar,findController:_,customFindController:u,scriptingManager:AppOptions.get("enableScripting")&&p,l10n:i,textLayerMode:AppOptions.get("textLayerMode"),annotationMode:AppOptions.get("annotationMode"),annotationEditorMode:v,annotationEditorHighlightColors:AppOptions.get("highlightEditorColors"),enableHighlightFloatingButton:AppOptions.get("enableHighlightFloatingButton"),enableUpdatedAddImage:AppOptions.get("enableUpdatedAddImage"),enableNewAltTextWhenAddingImage:AppOptions.get("enableNewAltTextWhenAddingImage"),imageResourcesPath:AppOptions.get("imageResourcesPath"),removePageBorders:AppOptions.get("removePageBorders"),enablePrintAutoRotate:AppOptions.get("enablePrintAutoRotate"),maxCanvasPixels:x,maxCanvasDim:k,capCanvasAreaFactor:E,enableDetailCanvas:AppOptions.get("enableDetailCanvas"),pageViewMode:AppOptions.get("pageViewMode"),enablePermissions:AppOptions.get("enablePermissions"),enableOptimizedPartialRendering:AppOptions.get("enableOptimizedPartialRendering"),enableSelectionRendering:AppOptions.get("enableSelectionRendering"),imagesRightClickMinSize:AppOptions.get("imagesRightClickMinSize"),pageColors:w,mlManager:a,abortSignal:s,defaultCacheSize:AppOptions.get("defaultCacheSize"),minZoom:AppOptions.get("minZoom"),maxZoom:AppOptions.get("maxZoom"),cspPolicyService:this.cspPolicyService,supportsPinchToZoom:this.supportsPinchToZoom,enableAutoLinking:AppOptions.get("enableAutoLinking"),minDurationToUpdateCanvas:AppOptions.get("minDurationToUpdateCanvas")});o.setViewer(A);l.setViewer(A);p.setViewer(A);if(e.viewsManager?.thumbnailsView){const{viewsManager:t}=e;this.pdfThumbnailViewer=new PDFThumbnailViewer({container:t.thumbnailsView,eventBus:n,renderingQueue:o,linkService:l,maxCanvasPixels:x,maxCanvasDim:k,pageColors:w,abortSignal:s,enableSplitMerge:b,enableMerge:F,enablePageReordering:AppOptions.get("enablePageReordering"),enableNewBadge:AppOptions.get("enableNewBadge"),statusBar:t.viewsManagerStatusBar,undoBar:t.viewsManagerUndoBar,manageMenu:t.manageMenu,waitingBar:t.viewsManagerWaitingBar,addFileComponent:t.viewsManagerAddFile});o.setThumbnailViewer(this.pdfThumbnailViewer)}if(!this.isViewerEmbedded&&!AppOptions.get("disableHistory")){this.pdfHistory=new PDFHistory({linkService:l,eventBus:n});l.setHistory(this.pdfHistory)}!this.supportsIntegratedFind&&e.findBar&&(this.findBar=new PDFFindBar(e.findBar,e.principalContainer,n));if(e.annotationEditorParams)if(v!==f.DISABLE){const t=e.toolbar?.editorSignatureButton;t&&AppOptions.get("enableSignatureEditor")&&(t.parentElement.hidden=!1);const i=document.getElementById("movePageUp"),a=document.getElementById("movePageDown");if(i&&a)if(AppOptions.get("enablePageReordering")){i.hidden=!1;a.hidden=!1}else{i.hidden=!0;a.hidden=!0}const s=e.toolbar?.editorCommentButton;s&&AppOptions.get("enableComment")&&(s.parentElement.hidden=!1);this.annotationEditorParams=new AnnotationEditorParams(e.annotationEditorParams,n)}else for(const e of["editorModeButtons","editorModeSeparator"])document.getElementById(e)?.classList.add("hidden");a&&e.secondaryToolbar?.imageAltTextSettingsButton&&(this.imageAltTextSettings=new ImageAltTextSettings(e.altTextSettingsDialog,r,n,a));e.documentProperties&&(this.pdfDocumentProperties=new PDFDocumentProperties(e.documentProperties,r,n,i,()=>this._docFilename,()=>this._docTitle));e.secondaryToolbar?.cursorHandToolButton&&(this.pdfCursorTools=new PDFCursorTools({container:g,eventBus:n,cursorToolOnLoad:AppOptions.get("cursorToolOnLoad")}));e.toolbar&&(this.toolbar=new Toolbar(e.toolbar,n,AppOptions.get("defaultZoomValue"),AppOptions.get("minZoom"),AppOptions.get("maxZoom"),AppOptions.get("toolbarDensity")));if(e.secondaryToolbar){if(AppOptions.get("enableAltText")){e.secondaryToolbar.imageAltTextSettingsButton?.classList.remove("hidden");e.secondaryToolbar.imageAltTextSettingsSeparator?.classList.remove("hidden")}this.secondaryToolbar=new SecondaryToolbar(e.secondaryToolbar,n)}this.supportsFullscreen&&(e.toolbar?.presentationModeButton||e.secondaryToolbar?.presentationModeButton)&&(this.pdfPresentationMode=new PDFPresentationMode({container:g,pdfViewer:A,eventBus:n}));const G=AppOptions.get("passwordPrompt");G?this.passwordPrompt=G:e.passwordOverlay&&(this.passwordPrompt=new PasswordPrompt(e.passwordOverlay,r,this.isViewerEmbedded));e.viewsManager?.outlinesView&&(this.pdfOutlineViewer=new PDFOutlineViewer({container:e.viewsManager.outlinesView,eventBus:n,l10n:i,linkService:l,downloadManager:c}));e.viewsManager?.attachmentsView&&(this.pdfAttachmentViewer=new PDFAttachmentViewer({container:e.viewsManager.attachmentsView,eventBus:n,l10n:i,downloadManager:c,linkService:l}));e.viewsManager?.layersView&&(this.pdfLayerViewer=new PDFLayerViewer({container:e.viewsManager.layersView,eventBus:n,l10n:i}));if(e.viewsManager){this.viewsManager=new ViewsManager({elements:e.viewsManager,eventBus:n,l10n:i,enableMerge:F,enableSplitMerge:b,globalAbortSignal:s});this.viewsManager.onToggled=this.forceRendering.bind(this);this.viewsManager.onUpdateThumbnails=()=>{for(const e of A.getCachedPageViews())e.renderingState===Pm.FINISHED&&this.pdfThumbnailViewer.getThumbnail(e.id-1)?.setImage(e);this.pdfThumbnailViewer.scrollThumbnailIntoView(A.currentPageNumber)}}},async run(e){await this.initialize(e);const{appConfig:t,eventBus:i}=this;let a;a=parseQueryString(document.location.search.substring(1)).get("file")??AppOptions.get("defaultUrl");try{a=new URL(a).href}catch{a=encodeURIComponent(a).replaceAll("%2F","/")}validateFileURL(a);const s=this._openFileInput=document.createElement("input");s.id="fileInput";s.className="ngx-extended-pdf-viewer-file-input";s.hidden=!0;s.type="file";s.value=null;s.accept=".pdf,application/pdf";document.body.append(s);s.addEventListener("change",function(e){const{files:t}=e.target;t?.length&&i.dispatch("fileinputchange",{source:this,fileInput:e.target})});t.mainContainer.addEventListener("dragover",function(e){if(AppOptions.get("enableDragAndDrop")){if(!e.dataTransfer?.items)return;for(const t of e.dataTransfer.items)if("application/pdf"===t.type){e.dataTransfer.dropEffect="copy"===e.dataTransfer.effectAllowed?"copy":"move";stopEvent(e);return}}});t.mainContainer.addEventListener("drop",function(e){if(AppOptions.get("enableDragAndDrop")){const t=e.dataTransfer?.files;if(!t||0===t.length||"application/pdf"!==t[0].type)return;stopEvent(e);i.dispatch("fileinputchange",{source:this,fileInput:e.dataTransfer,dropEvent:e})}});if(!AppOptions.get("supportsDocumentFonts")){AppOptions.set("disableFontFace",!0);this.l10n.get("pdfjs-web-fonts-disabled").then(e=>{ngx_console_NgxConsole.warn(e)})}const togglePrintingButtons=e=>{t.toolbar?.print?.classList.toggle("hidden",!e);t.secondaryToolbar?.printButton?.classList.toggle("hidden",!e)};this.supportsPrinting?i.on("printingallowed",({isAllowed:e})=>togglePrintingButtons(e),Nh):togglePrintingButtons(!1);if(!this.supportsFullscreen){t.toolbar.presentationModeButton.classList.add("hidden");t.secondaryToolbar?.presentationModeButton?.classList.add("hidden")}this.supportsIntegratedFind&&t.findBar?.toggleButton?.classList.add("hidden");a?this.open({url:a}):this._hideViewBookmark();const n=new CustomEvent("webviewerinitialized",{bubbles:!0,cancelable:!0,detail:{source:window}});document.dispatchEvent(n)},get externalServices(){return shadow(this,"externalServices",new ExternalServices)},get initialized(){return this._initializedCapability.settled},get initializedPromise(){return this._initializedCapability.promise},updateZoom(e,t,i){this.pdfViewer.isInPresentationMode||this.pdfViewer.updateScale({drawingDelay:AppOptions.get("defaultZoomDelay"),steps:e,scaleFactor:t,origin:i})},zoomIn(){this.updateZoom(1)},zoomOut(){this.updateZoom(-1)},zoomReset(){this.pdfViewer.isInPresentationMode||(this.pdfViewer.currentScaleValue="auto")},touchPinchCallback(e,t,i){if(this.supportsPinchToZoom){const a=this._accumulateFactor(this.pdfViewer.currentScale,i/t,"_touchUnusedFactor");this.updateZoom(null,a,e)}else{const a=30,s=this._accumulateTicks((i-t)/a,"_touchUnusedTicks");this.updateZoom(s,null,e)}},touchPinchEndCallback(){this._touchUnusedTicks=0;this._touchUnusedFactor=1},get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0},get page(){return this.pdfViewer.currentPageNumber},set page(e){this.pdfViewer.currentPageNumber=e},get supportsPrinting(){return shadow(this,"supportsPrinting",AppOptions.get("supportsPrinting")&&PDFPrintServiceFactory.supportsPrinting)},get supportsFullscreen(){return shadow(this,"supportsFullscreen",document.fullscreenEnabled)},get supportsPinchToZoom(){return shadow(this,"supportsPinchToZoom",AppOptions.get("supportsPinchToZoom"))},get supportsIntegratedFind(){return shadow(this,"supportsIntegratedFind",AppOptions.get("supportsIntegratedFind"))},initializeLoadingBar(){const e=document.getElementById("loadingBar"),t=e?new ProgressBar(e):null;t?.hide();return shadow(this,"loadingBar",t)},get supportsMouseWheelZoomCtrlKey(){return shadow(this,"supportsMouseWheelZoomCtrlKey",AppOptions.get("supportsMouseWheelZoomCtrlKey"))},get supportsMouseWheelZoomMetaKey(){return shadow(this,"supportsMouseWheelZoomMetaKey",AppOptions.get("supportsMouseWheelZoomMetaKey"))},get supportsCaretBrowsingMode(){return AppOptions.get("supportsCaretBrowsingMode")},moveCaret(e,t){this._caretBrowsing||=new CaretBrowsingMode(this._globalAbortController.signal,this.appConfig.mainContainer,this.appConfig.viewerContainer,this.appConfig.toolbar?.container);this._caretBrowsing.moveCaret(e,t)},setTitleUsingUrl(e="",t=null){},setTitle(e=this._title){this._title=e;if(this.isViewerEmbedded)return;const t=this._hasChanges()&&!this.pdfRenderingQueue.printing;document.title=`${t?"* ":""}${e}`},get _docFilename(){return this._contentDispositionFilename||getPdfFilenameFromUrl(this.url,AF.appConfig.filenameForDownload)},get _docTitle(){const{documentInfo:e,metadata:t}=this,i=t?.get("dc:title");return i&&"Untitled"!==i&&!/[\uFFF0-\uFFFF]/.test(i)?i:e.Title},_hideViewBookmark(){if(!this.appConfig)return;const{secondaryToolbar:e}=this.appConfig;e?.viewBookmarkButton.classList.add("hidden");e?.presentationModeButton?.classList.contains("hidden")&&document.getElementById("viewBookmarkSeparator")?.classList.add("hidden")},async close(){this._unblockDocumentLoadEvent();this._hideViewBookmark();if(!this.pdfLoadingTask)return;if(this._hasChanges()&&this._hasRealAnnotationChanges())try{await this.downloadOrSave()}catch{}const e=[];e.push(this.pdfLoadingTask.destroy());this.pdfLoadingTask=null;if(this.pdfDocument){this.pdfDocument=null;this.pdfThumbnailViewer?.setDocument(null);this.pdfViewer.setDocument(null);this.pdfLinkService.setDocument(null);this.pdfDocumentProperties?.setDocument(null);this.signaturePropertiesManager?.setDocument(null)}this.pdfLinkService.externalLinkEnabled=!0;this.store=null;this.isInitialViewSet=!1;this.url="";this.baseUrl="";this._downloadUrl="";this.documentInfo=null;this.metadata=null;this._contentDispositionFilename=null;this._contentLength=null;this._saveInProgress=!1;this._hasAnnotationEditors=!1;e.push(this.pdfScriptingManager.destroyPromise,this.passwordPrompt.close());this.setTitle();this.viewsManager?.reset();this.pdfOutlineViewer?.reset();this.pdfAttachmentViewer?.reset();this.pdfLayerViewer?.reset();this.pdfHistory?.reset();this.findBar?.reset();this.toolbar?.reset();this.secondaryToolbar?.reset();this._PDFBug?.cleanup();await Promise.all(e)},async open(e){this.pdfViewer?.destroyBookMode();this.pdfLoadingTask&&await this.close();const t=AppOptions.getAll(gr);t.cspPolicyService=e.cspPolicyService;if(e.workerSrc&&e.workerSrc!==t.workerSrc){t.workerSrc=e.workerSrc;this.pdfWorker=null}Object.assign(GlobalWorkerOptions,t);t.port=t.port??GlobalWorkerOptions.workerPort;t.cspPolicyService=this.cspPolicyService;null===this.pdfWorker&&(this.pdfWorker=t.port?PDFWorker.fromPort(t):new PDFWorker(t));e.data&&isPdfFile(e.filename)?this._contentDispositionFilename=e.filename:e.url&&this.setTitleUsingUrl(e.originalUrl||e.url,e.url);const i=getDocument({...AppOptions.getAll(pr),...e,worker:this.pdfWorker,cspPolicyService:e.cspPolicyService});this.pdfLoadingTask=i;i.onPassword=(e,t)=>{this.isViewerEmbedded&&this._unblockDocumentLoadEvent();this.pdfLinkService.externalLinkEnabled=!1;this.passwordPrompt.setUpdateCallback(e,t);this.passwordPrompt.open()};i.onProgress=e=>{this.progress(e.percent);this.eventBus?.dispatch("progress",{source:this,type:"load",total:e.total,loaded:e.loaded,percent:e.percent})};const a=this.serviceWorkerOptions.showUnverifiedSignatures;return i.promise.then(e=>{e._transport.messageHandler.send("showUnverifiedSignatures",a);this.load(e)},e=>{if(i!==this.pdfLoadingTask)return;this.loadingBar&&(this.loadingBar.percent||=0);let t="pdfjs-loading-error";e instanceof InvalidPDFException?t="pdfjs-invalid-file-error":e instanceof ResponseException&&(t=e.missing?"pdfjs-missing-file-error":"pdfjs-unexpected-response-error");AF.onError&&AF.onError(e);return this._documentError(t,{message:e.message}).then(()=>{throw e})})},async download(){if(!this.downloadManager)return;let e;try{e=await(this.pdfDocument?this.pdfDocument.getData():this.pdfLoadingTask.getData())}catch{}this.downloadManager.download(e,this._downloadUrl,this._docFilename)},async save(e=null){if(!this.downloadManager)return;if(this._saveInProgress)return;this._saveInProgress=!0;await this.pdfScriptingManager.dispatchWillSave();try{const t=await this.pdfDocument.saveDocument(e);this.downloadManager.download(t,this._downloadUrl,this._docFilename)}catch(e){ngx_console_NgxConsole.error("Error when saving the document:",e);await this.download()}finally{await this.pdfScriptingManager.dispatchDidSave();this._saveInProgress=!1}const t=this.pdfDocument?.annotationStorage.editorStats;t&&this.externalServices.reportTelemetry({type:"editing",data:{type:"save",stats:t}})},async downloadOrSave(){if(!this.downloadManager)return;this.pdfViewer._layerProperties.annotationEditorUIManager?.endCurrentEditing();const{classList:e}=this.appConfig.appContainer;e.add("wait");if(this.pdfThumbnailViewer?.hasStructuralChanges()){this.externalServices.reportTelemetry({type:"pageOrganization",data:{action:"save"}});await this.onSavePages({data:this.pdfThumbnailViewer.getStructuralChanges()})}else{const e=this.pdfDocument?.annotationStorage.size>0||!this.pageOrder.every((e,t,i)=>0===t||e>=i[t-1]);await(e?this.save(this.pageOrder):this.download())}delete this._mergedDocumentNeedsSaving;this.setTitle();e.remove("wait")},movePageUp(e){if(!(e.source.pageNumber<=1)){this.pdfViewer.swapPages(e.source.pageNumber-1,e.source.pageNumber-2);this.pdfThumbnailViewer.swapThumbnails(e.source.pageNumber-1,e.source.pageNumber-2);this.page=e.source.pageNumber-1;[this.pageOrder[e.source.pageNumber-2],this.pageOrder[e.source.pageNumber-1]]=[this.pageOrder[e.source.pageNumber-1],this.pageOrder[e.source.pageNumber-2]]}},movePageDown(e){if(e.source.pageNumber!==this.pdfDocument.numPages){this.pdfViewer.swapPages(e.source.pageNumber-1,e.source.pageNumber);this.pdfThumbnailViewer.swapThumbnails(e.source.pageNumber-1,e.source.pageNumber);this.page=e.source.pageNumber+1;[this.pageOrder[e.source.pageNumber-1],this.pageOrder[e.source.pageNumber]]=[this.pageOrder[e.source.pageNumber],this.pageOrder[e.source.pageNumber-1]]}},movePage(e,t){if(e<1||e>this.pdfDocument.numPages||t<1||t>this.pdfDocument.numPages)return;const i=e-1,a=t-1;if(i<a)for(let e=i;e<a;e++){this.pdfViewer.swapPages(e,e+1);this.pdfThumbnailViewer.swapThumbnails(e,e+1);[this.pageOrder[e],this.pageOrder[e+1]]=[this.pageOrder[e+1],this.pageOrder[e]]}else if(i>a)for(let e=i;e>a;e--){this.pdfViewer.swapPages(e,e-1);this.pdfThumbnailViewer.swapThumbnails(e,e-1);[this.pageOrder[e],this.pageOrder[e-1]]=[this.pageOrder[e-1],this.pageOrder[e]]}this.page=t},async _exportWithAnnotations(){if(this._saveInProgress)throw new Error("Already downloading");this._saveInProgress=!0;await this.pdfScriptingManager.dispatchWillSave();try{this._ensureDownloadComplete();const e=await this.pdfDocument.saveDocument();return new Blob([e],{type:"application/pdf"})}catch(e){throw new Error(`Error when saving the document: ${e.message}`)}finally{await this.pdfScriptingManager.dispatchDidSave();this._saveInProgress=!1}},_ensureDownloadComplete(){if(!this.pdfDocument)throw new Error("PDF document not downloaded.")},async _exportWithoutAnnotations(){try{this._ensureDownloadComplete();const e=await this.pdfDocument.getData();return new Blob([e],{type:"application/pdf"})}catch(e){throw new Error(`Error when saving the document: ${e.message}`)}},async export(){return this.pdfDocument?.annotationStorage.size>0?this._exportWithAnnotations():this._exportWithoutAnnotations()},openInExternalApp(){this.downloadOrSave({openInExternalApp:!0})},async _documentError(e,t=null){this._unblockDocumentLoadEvent();const i=await this._otherError(e||"pdfjs-loading-error",t);this.eventBus.dispatch("documenterror",{source:this,message:i,reason:t?.message??null})},async _otherError(e,t=null){const i=await this.l10n.get(e),a=[`PDF.js v${Xr||"?"} (build: ${qr||"?"})`];if(t){a.push(`Message: ${t.message}`);if(t.stack)a.push(`Stack: ${t.stack}`);else{t.filename&&a.push(`File: ${t.filename}`);t.lineNumber&&a.push(`Line: ${t.lineNumber}`)}}ngx_console_NgxConsole.error(`${i}\n\n${a.join("\n")}`);return i},progress(e){if(this.loadingBar&&!(e<=this.loadingBar.percent)){this.loadingBar.percent=e;(this.pdfDocument?.loadingParams.disableAutoFetch??AppOptions.get("disableAutoFetch"))&&this.loadingBar.setDisableAutoFetch()}},load(e){this.pdfDocument=e;this._printPermissionPromise=new Promise(e=>{this.eventBus.on("printingallowed",({isAllowed:t})=>{e(t)},{once:!0,...Nh})});e.getDownloadInfo().then(({length:e})=>{this._contentLength=e;this.loadingBar?.hide();n.then(()=>{this.eventBus?.dispatch("documentloaded",{source:this})})});const t=e.getPageLayout().catch(()=>{}),i=e.getPageMode().catch(()=>{}),a=e.getOpenAction().catch(()=>{});this.toolbar?.setPagesCount(e.numPages,!1);this.secondaryToolbar?.setPagesCount(e.numPages);this.pdfLinkService.setDocument(e);this.pdfDocumentProperties?.setDocument(e);const s=this.pdfViewer;s.setDocument(e);const{firstPagePromise:n,onePageRendered:r,pagesPromise:o}=s;this.pdfThumbnailViewer?.setDocument(e);const l=(this.store=new ViewHistory(e.fingerprints[0])).getMultiple({page:null,zoom:"auto",scrollLeft:"0",scrollTop:"0",rotation:null,sidebarView:uh,scrollMode:Fh.UNKNOWN,spreadMode:bh.UNKNOWN}).catch(()=>{});n.then(n=>{this.loadingBar?.setWidth(this.appConfig.viewerContainer);this._initializeAnnotationStorageCallbacks(e);Promise.all([Ah,l,t,i,a]).then(async([t,i,a,n,r])=>{const l=AppOptions.get("viewOnLoad");this._initializePdfHistory({fingerprint:e.fingerprints[0],viewOnLoad:l,initialDest:r?.get("dest")});const d=this.initialBookmark;let c=AppOptions.get("defaultZoomValue");if(!c||""===c)try{c=await this.store.get("zoom");"string"==typeof c&&(c=c?.replace("%",""));isNaN(Number(c))||(c=Number(c)/100)}catch(e){}!s.currentScaleValue&&c&&""!==c&&(s.currentScaleValue=c);let h=c?`zoom=${c}`:null,u=null,_=AppOptions.get("sidebarViewOnLoad"),p=AppOptions.get("scrollModeOnLoad"),g=AppOptions.get("spreadModeOnLoad");this.eventBus&&this.eventBus.dispatch("storedvaluesavailable",{source:this,fingerprint:e.fingerprints[0],storedZoom:i?.zoom,storedPage:i?.page,defaultZoom:AppOptions.get("defaultZoomValue")});if(i?.page&&l!==EF){h=`page=${i.page}&zoom=${c||i.zoom},${i.scrollLeft},${i.scrollTop}`;u=parseInt(i.rotation,10);_===uh&&(_=0|i.sidebarView);p===Fh.UNKNOWN&&(p=0|i.scrollMode);g===bh.UNKNOWN&&(g=0|i.spreadMode)}n&&_===uh&&(_=function apiPageModeToSidebarView(e){switch(e){case"UseNone":return _h;case"UseThumbs":return ph;case"UseOutlines":return gh;case"UseAttachments":return mh;case"UseOC":return fh}return _h}(n));if(a&&p===Fh.UNKNOWN&&g===bh.UNKNOWN){g=apiPageLayoutToViewerModes(a).spreadMode}this.setInitialView(h,{rotation:u,sidebarView:_,scrollMode:p,spreadMode:g});this.eventBus.dispatch("documentinit",{source:this});await Promise.race([o,new Promise(e=>{setTimeout(e,10)})]);if((d||h)&&!s.hasEqualPageSizes){this.initialBookmark=d;s.currentScaleValue=s.currentScaleValue;this.setInitialView(h)}}).catch(()=>{this.setInitialView()}).then(function(){s.update()})});o.then(()=>{this._unblockDocumentLoadEvent();this._initializeAutoPrint(e,a)},e=>{AF.onError&&AF.onError(e);this._documentError("pdfjs-loading-error",{message:e.message})});r.then(t=>{this.externalServices.reportTelemetry({type:"pageInfo",timestamp:t.timestamp});this.pdfOutlineViewer&&e.getOutline().then(t=>{e===this.pdfDocument&&this.pdfOutlineViewer.render({outline:t,pdfDocument:e})});this.pdfAttachmentViewer&&e.getAttachments().then(t=>{e===this.pdfDocument&&this.pdfAttachmentViewer.render({attachments:t})});this.pdfLayerViewer&&s.optionalContentConfigPromise.then(t=>{e===this.pdfDocument&&this.pdfLayerViewer.render({optionalContentConfig:t,pdfDocument:e})})});this._initializePageLabels(e);this._initializeMetadata(e);this._initializePageOrder(e)},async _scriptingDocProperties(e){if(!this.documentInfo){await new Promise(e=>{this.eventBus.on("metadataloaded",e,{once:!0,...Nh})});if(e!==this.pdfDocument)return null}if(!this._contentLength){await new Promise(e=>{this.eventBus.on("documentloaded",e,{once:!0,...Nh})});if(e!==this.pdfDocument)return null}return{...this.documentInfo,baseURL:this.baseUrl,filesize:this._contentLength,filename:this._docFilename,metadata:this.metadata?.getRaw(),authors:this.metadata?.get("dc:creator"),numPages:this.pagesCount,URL:this.url}},async _initializeAutoPrint(e,t){const[i,a]=await Promise.all([t,this.pdfViewer.enableScripting?null:e.getJSActions()]);if(e!==this.pdfDocument)return;let s="Print"===i?.get("action");if(a){ngx_console_NgxConsole.warn("Warning: JavaScript support is not enabled");for(const e in a){if(s)break;switch(e){case"WillClose":case"WillSave":case"DidSave":case"WillPrint":case"DidPrint":continue}s=a[e].some(e=>xh.test(e))}}s&&this.triggerPrinting()},async _initializeMetadata(e){const{info:t,metadata:i,contentDispositionFilename:a,contentLength:s,hasStructTree:n}=await e.getMetadata();if(e!==this.pdfDocument)return;this.externalServices.reportTelemetry({type:"taggedPDF",data:n});this.documentInfo=t;this.metadata=i;this._contentDispositionFilename??=a;this._contentLength??=s;AppOptions?.get("verbosity")>0&&ngx_console_NgxConsole.log(`PDF ${e.fingerprints[0]} [${t.PDFFormatVersion} ${(i?.get("pdf:producer")||t.Producer||"-").trim()} / ${(i?.get("xmp:creatortool")||t.Creator||"-").trim()}] (PDF.js: ${Xr||"?"} [${qr||"?"}]) modified by ngx-extended-pdf-viewer 30.0.0`);const r=this._docTitle;r?this.setTitle(`${r} - ${this._contentDispositionFilename||this._title}`):this._contentDispositionFilename&&this.setTitle(this._contentDispositionFilename);!t.IsXFAPresent||t.IsAcroFormPresent||e.isPureXfa?!t.IsAcroFormPresent&&!t.IsXFAPresent||this.pdfViewer.renderForms||ngx_console_NgxConsole.warn("Warning: Interactive form support is not enabled"):e.loadingParams.enableXfa?ngx_console_NgxConsole.warn("Warning: XFA Foreground documents are not supported"):ngx_console_NgxConsole.warn("Warning: XFA support is not enabled");if(t.IsSignaturesPresent){this._maybeInitSignatureProperties(e)||ngx_console_NgxConsole.warn("Warning: Digital signatures validation is not supported")}this.eventBus.dispatch("metadataloaded",{source:this})},async _initializePageOrder(e){e===this.pdfDocument&&(this.pageOrder=Array.from({length:this.pdfDocument.numPages},(e,t)=>t+1))},_maybeInitSignatureProperties(e){if(!AppOptions.get("enableSignatureVerification"))return!1;const t=this.externalServices.createSignatureVerifier();if(!t)return!1;if(e!==this.pdfDocument)return!0;this.signaturePropertiesManager??=new SignaturePropertiesManager({appConfig:this.appConfig.toolbar,verifier:t,eventBus:this.eventBus});this.signaturePropertiesManager.setDocument(e);return!0},async _initializePageLabels(e){const t=await e.getPageLabels();if(e!==this.pdfDocument)return;if(!t||AppOptions.get("disablePageLabels"))return;const i=t.length;let a=0,s=0;for(let e=0;e<i;e++){const i=t[e];if(i===(e+1).toString())a++;else{if(""!==i)break;s++}}if(a>=i||s>=i)return;const{pdfViewer:n,pdfThumbnailViewer:r,toolbar:o}=this;n.setPageLabels(t);r?.setPageLabels(t);o?.setPagesCount(i,!0);o?.setPageNumber(n.currentPageNumber,n.currentPageLabel)},_initializePdfHistory({fingerprint:e,viewOnLoad:t,initialDest:i=null}){if(this.pdfHistory){this.pdfHistory.initialize({fingerprint:e,resetHistory:t===EF||!!this._mergedDocumentNeedsSaving,updateUrl:AppOptions.get("historyUpdateUrl")});if(this.pdfHistory.initialBookmark){this.initialBookmark=this.pdfHistory.initialBookmark;this.initialRotation=this.pdfHistory.initialRotation}if(i&&!this.initialBookmark&&t===kF){this.initialBookmark=JSON.stringify(i);this.pdfHistory.push({explicitDest:i,pageNumber:null})}}},_hasChanges(){return this.pdfDocument?.annotationStorage.size>0||this.pdfThumbnailViewer?.hasStructuralChanges()||!0===this._mergedDocumentNeedsSaving},_initialAnnotationValues:null,_initializeAnnotationStorageCallbacks(e){if(e!==this.pdfDocument)return;const{annotationStorage:t}=e;t.onSetModified=()=>{this._annotationStorageModified=!0};t.onResetModified=()=>{delete this._annotationStorageModified;this._initialAnnotationValues=null};t.onAnnotationEditor=e=>{this._hasAnnotationEditors=!!e;this.setTitle()};this.eventBus._on("pagesloaded",()=>{setTimeout(()=>{this._captureInitialAnnotationValues()},200)})},_captureInitialAnnotationValues(){if(!this.pdfDocument?.annotationStorage)return;const e=this.pdfDocument.annotationStorage;this._initialAnnotationValues=new Map;for(const[t,i]of e)this._initialAnnotationValues.set(t,JSON.parse(JSON.stringify(i)))},setInitialAnnotationValues(){if(!this.pdfDocument?.annotationStorage)return;this._initialAnnotationValues=new Map;const e=this.pdfDocument.annotationStorage;for(const[t,i]of e)this._initialAnnotationValues.set(t,JSON.parse(JSON.stringify(i)))},_hasRealAnnotationChanges(){if(!this.pdfDocument?.annotationStorage||!this._initialAnnotationValues)return this._annotationStorageModified;const e=this.pdfDocument.annotationStorage,t=new Map;for(const[i,a]of e)t.set(i,a);if(t.size!==this._initialAnnotationValues.size)return!0;for(const[e,i]of t){const t=this._initialAnnotationValues.get(e);if(!t)return!0;if(JSON.stringify(i)!==JSON.stringify(t))return!0}for(const e of this._initialAnnotationValues.keys())if(!t.has(e))return!0;return!1},setInitialView(e,{rotation:t,sidebarView:i,scrollMode:a,spreadMode:s}={}){const setRotation=e=>{isValidRotation(e)&&(this.pdfViewer.pagesRotation=e)};this.isInitialViewSet=!0;this.viewsManager?.setInitialView(i);((e,t)=>{isValidScrollMode(e)&&(this.pdfViewer.scrollMode=e);isValidSpreadMode(t)&&(this.pdfViewer.spreadMode=t)})(a,s);if(this.initialBookmark){setRotation(this.initialRotation);delete this.initialRotation;this.pdfLinkService.setHash&&this.pdfLinkService.setHash(this.initialBookmark);this.initialBookmark=null}else if(e){setRotation(t);this.pdfLinkService.setHash&&this.pdfLinkService.setHash(e)}this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber,this.pdfViewer.currentPageLabel);this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);if(!this.pdfViewer.currentScaleValue){const e=AppOptions?.get("defaultZoomValue");e&&(this.pdfViewer.currentScaleValue=e)}},_cleanup(){if(this.resizeObserver){this.resizeObserver.disconnect();this.resizeObserver=null}if(this.pdfDocument){this.pdfViewer.cleanup();this.pdfThumbnailViewer?.cleanup();this.pdfDocument.cleanup(AppOptions.get("fontExtraProperties"))}},forceRendering(){this.pdfRenderingQueue.printing=!!this.printService;this.pdfRenderingQueue.isThumbnailViewEnabled=this.viewsManager?.visibleView===ph;this.pdfRenderingQueue.renderHighestPriority()},beforePrint(){this._printAnnotationStoragePromise=this.pdfScriptingManager.dispatchWillPrint().catch(()=>{}).then(()=>this.pdfDocument?.annotationStorage.print);if(!this.printService)if(this.supportsPrinting&&this.pdfViewer.printingAllowed)if(this.pdfViewer.pageViewsReady){this.printService=PDFPrintServiceFactory.createPrintService({pdfDocument:this.pdfDocument,pagesOverview:this.pdfViewer.getPagesOverview(),printResolution:AppOptions.get("printResolution"),printAnnotationStoragePromise:this._printAnnotationStoragePromise,pageOrder:this.pageOrder,eventBus:this.pdfViewer.eventBus,cspPolicyService:this.cspPolicyService});this.forceRendering();this.setTitle();this.printService.layout();this._hasAnnotationEditors&&this.externalServices.reportTelemetry({type:"editing",data:{type:"print",stats:this.pdfDocument?.annotationStorage.editorStats}})}else this.l10n.get("pdfjs-printing-not-ready").then(e=>{window.alert(e)});else this._otherError("pdfjs-printing-not-supported")},afterPrint(){if(this._printAnnotationStoragePromise){this._printAnnotationStoragePromise.then(()=>{this.pdfScriptingManager.dispatchDidPrint()});this._printAnnotationStoragePromise=null}if(this.printService){this.printService.destroy();this.printService=null;this.pdfDocument?.annotationStorage.resetModified()}this.forceRendering();this.setTitle()},rotatePages(e){this.pdfViewer.pagesRotation+=e},requestPresentationMode(){this.pdfPresentationMode?.request()},async triggerPrinting(){this.supportsPrinting&&await this._printPermissionPromise&&this.printPdf()},bindEvents(){if(this._eventBusAC)return;const e={signal:(this._eventBusAC=new AbortController).signal,...Nh},{eventBus:t,externalServices:i,pdfDocumentProperties:a,pdfViewer:s,preferences:n}=this;t.on("resize",onResize.bind(this),e);t.on("hashchange",onHashchange.bind(this),e);t.on("beforeprint",this.beforePrint.bind(this),e);t.on("afterprint",this.afterPrint.bind(this),e);t.on("pagerender",onPageRender.bind(this),e);t.on("pagerendered",onPageRendered.bind(this),e);t.on("updateviewarea",onUpdateViewarea.bind(this),e);t.on("pagechanging",onPageChanging.bind(this),e);t.on("scalechanging",onScaleChanging.bind(this),e);t.on("rotationchanging",onRotationChanging.bind(this),e);t.on("sidebarviewchanged",onSidebarViewChanged.bind(this),e);t.on("pagemode",onPageMode.bind(this),e);t.on("namedaction",onNamedAction.bind(this),e);t.on("toggleSidebar",function({visible:e}){this.viewsManager&&(e?this.viewsManager.open():this.viewsManager.close())}.bind(this),e);t.on("presentationmodechanged",e=>s.presentationModeState=e.state,e);t.on("presentationmode",this.requestPresentationMode.bind(this),e);t.on("switchannotationeditormode",e=>s.annotationEditorMode=e,e);t.on("print",this.triggerPrinting.bind(this),e);t.on("download",this.downloadOrSave.bind(this),e);t.on("movePageUp",this.movePageUp.bind(this),e);t.on("movePageDown",this.movePageDown.bind(this),e);t.on("firstpage",()=>this.page=1,e);t.on("lastpage",()=>this.page=this.pagesCount,e);t.on("nextpage",()=>s.nextPage(),e);t.on("previouspage",()=>s.previousPage(),e);t.on("zoomin",this.zoomIn.bind(this),e);t.on("zoomout",this.zoomOut.bind(this),e);t.on("zoomreset",this.zoomReset.bind(this),e);t.on("pagenumberchanged",onPageNumberChanged.bind(this),e);t.on("scalechanged",e=>s.currentScaleValue=e.value,e);t.on("rotatecw",this.rotatePages.bind(this,90),e);t.on("rotateccw",this.rotatePages.bind(this,-90),e);t.on("optionalcontentconfig",e=>s.optionalContentConfigPromise=e.promise,e);t.on("switchscrollmode",e=>s.scrollMode=e.mode,e);t.on("scrollmodechanged",onViewerModesChanged.bind(this,"scrollMode"),e);t.on("switchspreadmode",e=>s.spreadMode=e.mode,e);t.on("spreadmodechanged",onViewerModesChanged.bind(this,"spreadMode"),e);t.on("imagealttextsettings",onImageAltTextSettings.bind(this),e);t.on("documentproperties",()=>a?.open(),e);t.on("findfromurlhash",onFindFromUrlHash.bind(this),e);t.on("updatefindmatchescount",onUpdateFindMatchesCount.bind(this),e);t.on("updatefindcontrolstate",onUpdateFindControlState.bind(this),e);t.on("fileinputchange",onFileInputChange.bind(this),e);t.on("openfile",onOpenFile.bind(this),e);t.on("pagesedited",this.onPagesEdited.bind(this),e);t.on("saveextractedpages",this.onSavePages.bind(this),e);t.on("saveandload",this.onSaveAndLoad.bind(this),e)},bindWindowEvents(){if(this._windowAC)return;this._windowAC=new AbortController;const{eventBus:e,appConfig:{mainContainer:t},pdfViewer:i,_windowAC:{signal:a}}=this;this._touchManager=new TouchManager({container:window,isPinchingDisabled:()=>i.isInPresentationMode,isPinchingStopped:()=>this.overlayManager?.active,onPinching:this.touchPinchCallback.bind(this),onPinchEnd:this.touchPinchEndCallback.bind(this),signal:a});!function addWindowResolutionChange(e=null){e&&i.refresh();window.matchMedia(`(resolution: ${OutputScale.pixelRatio}dppx)`).addEventListener("change",addWindowResolutionChange,{once:!0,signal:a})}();const s=document.getElementById("viewerContainer");s?.addEventListener("wheel",onWheel.bind(this),{passive:!1,signal:a});window.addEventListener("wheel",onWheel.bind(this),{passive:!1,signal:a});window.addEventListener("click",onClick.bind(this),{signal:a});window.addEventListener("keydown",onKeyDown.bind(this),{signal:a});window.addEventListener("keyup",onKeyUp.bind(this),{signal:a});if(s){let i,a=t.clientWidth,s=t.clientHeight;this.resizeObserver=new ResizeObserver(n=>{const r=t.clientWidth,o=t.clientHeight;if(r!==a||o!==s){clearTimeout(i);i=setTimeout(()=>{t.offsetParent&&e.dispatch("resize",{source:t})},50);a=r;s=o}});this.resizeObserver.observe(t)}else window.addEventListener("resize",()=>e.dispatch("resize",{source:window}),{signal:a});window.addEventListener("hashchange",()=>{e.dispatch("hashchange",{source:window,hash:document.location.hash.substring(1)})},{signal:a});window.addEventListener("beforeprint",()=>e.dispatch("beforeprint",{source:window}),{signal:a});window.addEventListener("afterprint",()=>e.dispatch("afterprint",{source:window}),{signal:a});window.addEventListener("updatefromsandbox",t=>{e.dispatch("updatefromsandbox",{source:window,detail:t.detail})},{signal:a});window.addEventListener("beforeunload",onBeforeUnload.bind(this),{signal:a});if(!("onscrollend"in document.documentElement))return;({scrollTop:this._lastScrollTop,scrollLeft:this._lastScrollLeft}=t);let n,r;const scrollend=()=>{({scrollTop:this._lastScrollTop,scrollLeft:this._lastScrollLeft}=t);clearTimeout(n);if(this._isScrolling){r.abort();r=null;this._isScrolling=!1}};t.addEventListener("scroll",()=>{if(!this._isCtrlKeyDown&&(this._lastScrollTop!==t.scrollTop||this._lastScrollLeft!==t.scrollLeft)){if(!this._isScrolling){r=new AbortController;const e=AbortSignal.any([r.signal,a]);t.addEventListener("scrollend",scrollend,{signal:e});t.addEventListener("blur",scrollend,{signal:e});this._isScrolling=!0}clearTimeout(n);n=setTimeout(scrollend,100)}},{passive:!0,signal:a})},unbindEvents(){this._eventBusAC?.abort();this._eventBusAC=null},unbindWindowEvents(){this._windowAC?.abort();this._windowAC=null;this._touchManager=null},async testingClose(){this.unbindEvents();this.unbindWindowEvents();this._globalAbortController?.abort();this._globalAbortController=null;this.findBar?.close();await Promise.all([this.l10n?.destroy(),this.close()])},onPagesEdited(e){this.pdfViewer.onPagesEdited(e)},async onSavePages({data:e}){if(!this.downloadManager)return;if(!this.pdfDocument)return;const t=await this.pdfDocument.extractPages(e);t?this.downloadManager.download(t,this._downloadUrl,this._docFilename):console.error("Something wrong happened when saving the edited PDF.\nPlease file a bug.")},async onSaveAndLoad({data:e}){if(!this.pdfDocument)return;const t=await this.pdfDocument.extractPages(e);if(t){this._mergedDocumentNeedsSaving=!0;this.open({data:t,filename:this._docFilename})}else console.error("Something wrong happened when saving the edited PDF.\nPlease file a bug.")},_accumulateTicks(e,t){(this[t]>0&&e<0||this[t]<0&&e>0)&&(this[t]=0);this[t]+=e;const i=Math.trunc(this[t]);this[t]-=i;return i},_accumulateFactor(e,t,i){if(1===t)return 1;(this[i]>1&&t<1||this[i]<1&&t>1)&&(this[i]=1);const a=Math.floor(e*t*this[i]*1e3)/(1e3*e);this[i]=t/a;return a},_unblockDocumentLoadEvent(){document.blockUnblockOnload?.(!1);this._unblockDocumentLoadEvent=()=>{}},get scriptingReady(){return this.pdfScriptingManager.ready}};PDFPrintServiceFactory.initGlobals(AF);{const e=new Set(["null","http://mozilla.github.io","https://mozilla.github.io"]);var validateFileURL=function(t){if(!t)return;const i=URL.parse(window.location)?.origin||"null";if(e.has(i))return;const a=URL.parse(t,window.location)?.origin;if(a===i)return;const s=new Error("file origin does not match viewer's");AF._documentError("pdfjs-loading-error",{message:s.message});AF.onError&&AF.onError(s);throw s},onFileInputChange=function(e){if(this.pdfViewer?.isInPresentationMode)return;const t=e.fileInput.files[0];this.open({url:URL.createObjectURL(t),originalUrl:encodeURIComponent(t.name)})},onOpenFile=function(e){this._openFileInput?.click()}}function onPageRender({pageNumber:e}){e===this.page&&this.toolbar?.updateLoadingIndicatorState(!0)}function onPageRendered({pageNumber:e,isDetailView:t,error:i}){e===this.page&&this.toolbar?.updateLoadingIndicatorState(!1);if(!t&&this.viewsManager?.visibleView===ph){const t=this.pdfViewer.getPageView(e-1),i=this.pdfThumbnailViewer?.getThumbnail(e-1);t&&i?.setImage(t)}i&&this._otherError("pdfjs-rendering-error",i)}function onPageMode({mode:e}){let t;switch(e){case"thumbs":t=ph;break;case"bookmarks":case"outline":t=gh;break;case"attachments":t=mh;break;case"layers":t=fh;break;case"none":t=_h;break;default:ngx_console_NgxConsole.error('Invalid "pagemode" hash parameter: '+e);return}this.viewsManager?.switchView(t,!0)}function onNamedAction(e){switch(e.action){case"GoToPage":this.appConfig.toolbar?.pageNumber.select();break;case"Find":this.supportsIntegratedFind||this.findBar?.toggle();break;case"Print":this.triggerPrinting();break;case"SaveAs":this.downloadOrSave()}}function onSidebarViewChanged({view:e}){this.pdfRenderingQueue.isThumbnailViewEnabled=e===ph;this.isInitialViewSet&&this.store?.set("sidebarView",e).catch(()=>{})}function onUpdateViewarea({location:e}){if(this.isInitialViewSet){const t={};void 0===e.pageNumber&&null===e.pageNumber||(t.page=e.pageNumber);e.scale&&(t.zoom=e.scale);e.left&&(t.scrollLeft=e.left);e.top&&(t.scrollTop=e.top);void 0===e.rotation&&null===e.rotation||(t.rotation=e.rotation);AF.store?.setMultiple(t).catch(()=>{})}this.appConfig.secondaryToolbar&&(this.appConfig.secondaryToolbar.viewBookmarkButton.href=this.pdfLinkService.getAnchorUrl(e.pdfOpenParams))}function onViewerModesChanged(e,t){this.isInitialViewSet&&!this.pdfViewer.isInPresentationMode&&this.store?.set(e,t.mode).catch(()=>{})}function onResize(e){const{pdfDocument:t,pdfViewer:i,pdfRenderingQueue:a}=this;if(a.printing&&window.matchMedia("print").matches)return;if(!t)return;const s=e?.sidebarToggle?i.currentPageNumber:0,n=i.currentScaleValue;"auto"!==n&&"page-fit"!==n&&"page-width"!==n||(i.currentScaleValue=n);i.update();s&&i.currentPageNumber!==s&&(i.currentPageNumber=s)}function onHashchange(e){const t=e.hash;t&&(this.isInitialViewSet?this.pdfHistory?.popStateInProgress||this.pdfLinkService.setHash&&this.pdfLinkService.setHash(t):this.initialBookmark=t)}function onPageNumberChanged(e){const{pdfViewer:t}=this;""!==e.value&&this.pdfLinkService.goToPage(e.value);e.value!==t.currentPageNumber.toString()&&e.value!==t.currentPageLabel&&this.toolbar?.setPageNumber(t.currentPageNumber,t.currentPageLabel)}function onImageAltTextSettings(){this.imageAltTextSettings?.open({enableGuessAltText:AppOptions.get("enableGuessAltText"),enableNewAltTextWhenAddingImage:AppOptions.get("enableNewAltTextWhenAddingImage")})}function onFindFromUrlHash(e){this.eventBus.dispatch("find",{source:e.source,type:"",query:e.query,caseSensitive:!1,entireWord:!1,highlightAll:!0,findPrevious:!1,matchDiacritics:!0})}function onUpdateFindMatchesCount({matchesCount:e}){this.supportsIntegratedFind?this.externalServices.updateFindMatchesCount(e):this.findBar?.updateResultsCount(e)}function onUpdateFindControlState({state:e,previous:t,entireWord:i,matchesCount:a,rawQuery:s}){this.supportsIntegratedFind?this.externalServices.updateFindControlState({result:e,findPrevious:t,entireWord:i,matchesCount:a,rawQuery:s}):this.findBar?.updateUIState(e,t,a)}function onScaleChanging(e){this.toolbar?.setPageScale(e.presetValue,e.scale);this.pdfViewer.update(e.noScroll);this.pdfViewer.updateBookModeScale(e)}function onRotationChanging(e){this.pdfThumbnailViewer&&(this.pdfThumbnailViewer.pagesRotation=e.pagesRotation);this.forceRendering();this.pdfViewer.currentPageNumber=e.pageNumber}function onPageChanging({pageNumber:e,pageLabel:t}){this.toolbar?.setPageNumber(e,t);this.secondaryToolbar?.setPageNumber(e);this.viewsManager?.visibleView===ph&&this.pdfThumbnailViewer?.scrollThumbnailIntoView(e);const i=this.pdfViewer.getPageView(e-1);this.toolbar?.updateLoadingIndicatorState(i?.renderingState===Pm.RUNNING);const a=document.getElementById("pageNumber");if(a){const e=new CustomEvent("page-change");a.dispatchEvent(e)}}function onWheel(e){const t=document.getElementById("viewerContainer");if(t.parentNode.querySelector(":hover")!==t)return;const{pdfViewer:i,supportsMouseWheelZoomCtrlKey:a,supportsMouseWheelZoomMetaKey:s,supportsPinchToZoom:n}=this;if(i.isInPresentationMode)return;const r=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(AF?.isKeyIgnored&&AF.isKeyIgnored(r,"WHEEL"))return;const o=e.deltaMode;let l=Math.exp(-e.deltaY/100);const d=e.ctrlKey&&!this._isCtrlKeyDown&&o===WheelEvent.DOM_DELTA_PIXEL&&0===e.deltaX&&(Math.abs(l-1)<.05||!1)&&0===e.deltaZ,c=[e.clientX,e.clientY];if(d||e.ctrlKey&&a||e.metaKey&&s){e.preventDefault();if(this._isScrolling||"hidden"===document.visibilityState||this.overlayManager.active)return;if(d&&n){l=this._accumulateFactor(i.currentScale,l,"_wheelUnusedFactor");this.updateZoom(null,l,c)}else{const t=normalizeWheelEventDirection(e);let i=0;if(o===WheelEvent.DOM_DELTA_LINE||o===WheelEvent.DOM_DELTA_PAGE)i=Math.abs(t)>=1?Math.sign(t):this._accumulateTicks(t,"_wheelUnusedTicks");else{const e=30;i=this._accumulateTicks(t/e,"_wheelUnusedTicks")}this.updateZoom(i,null,c)}}}function closeSecondaryToolbar({target:e}){if(!this.secondaryToolbar?.isOpen)return;const{toolbar:t,secondaryToolbar:i}=this.appConfig;if(this.pdfViewer.containsElement(e)||t?.container.contains(e)&&!i?.toolbar.contains(e)&&!i?.toggleButton.contains(e)){if(e&&e.parentElement===i.toggleButton)return;if(e&&e.parentElement&&e.parentElement.parentElement===i.toggleButton)return;this.secondaryToolbar.close()}}function closeEditorUndoBar(e){this.editorUndoBar?.isOpen&&this.appConfig.secondaryToolbar?.toolbar.contains(e.target)&&this.editorUndoBar.hide()}function closeSignatureProperties({target:e}){this.signaturePropertiesManager?.shouldCloseOnClick(e)&&this.signaturePropertiesManager.close()}function onBeforeUnload(e){if(this._hasChanges()){e.preventDefault();e.returnValue="";return!1}return!0}function onClick(e){closeSecondaryToolbar.call(this,e);closeEditorUndoBar.call(this,e);closeSignatureProperties.call(this,e)}function onKeyUp(e){"Control"===e.key&&(this._isCtrlKeyDown=!1)}function onKeyDown(e){this._isCtrlKeyDown="Control"===e.key;this.editorUndoBar?.isOpen&&9!==e.keyCode&&16!==e.keyCode&&(13!==e.keyCode&&32!==e.keyCode||getActiveOrFocusedElement()!==this.appConfig.editorUndoBar.undoButton)&&this.editorUndoBar.hide();if(this.overlayManager.active)return;const{eventBus:t,pdfViewer:i}=this,a=i.isInPresentationMode;let s=!1,n=!1;const r=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(AF.ngxKeyboardManager&&AF.ngxKeyboardManager.isKeyIgnored.bind(AF.ngxKeyboardManager)(r,e.keyCode))return;if(1===r||8===r||5===r||12===r)switch(e.keyCode){case 70:if(!this.supportsIntegratedFind&&!e.shiftKey){if(AppOptions.get("textLayerMode")!==vh){let e=!1;const t=this.pdfViewer.viewer.closest("#outerContainer")?.querySelector("#primaryViewFind");t&&(e||=!t?.classList.contains("dummy-component"));const i=this.pdfViewer.viewer.closest("#outerContainer")?.querySelector("#secondaryToolbarToggle");if(!i.hidden){const t=this.pdfViewer.viewer.closest("#outerContainer")?.querySelector("#secondaryViewFind");t&&(e||=!t?.classList.contains("dummy-component"))}e&&this.findBar?.open()}s=!0}break;case 71:if(!this.supportsIntegratedFind){const{state:e}=this.findController;if(e){const i={source:window,type:"again",findPrevious:5===r||12===r};t.dispatch("find",{...e,...i})}s=!0}break;case 61:case 107:case 187:case 171:this.zoomIn();s=!0;break;case 173:case 109:case 189:this.zoomOut();s=!0;break;case 48:case 96:if(!a){setTimeout(()=>{this.zoomReset()});s=!1}break;case 38:if(a||this.page>1){this.page=1;s=!0;n=!0}break;case 40:if(a||this.page<this.pagesCount){this.page=this.pagesCount;s=!0;n=!0}}if(1===r||8===r)switch(e.keyCode){case 83:t.dispatch("download",{source:window});s=!0;break;case 79:t.dispatch("openfile",{source:window});s=!0}if(3===r||10===r)switch(e.keyCode){case 80:this.requestPresentationMode();s=!0;this.externalServices.reportTelemetry({type:"buttons",data:{id:"presentationModeKeyboard"}});break;case 71:if(this.appConfig.toolbar){this.appConfig.toolbar.pageNumber.select();s=!0}}if(s){n&&!a&&i.focus();e.preventDefault();return}const o=getActiveOrFocusedElement(),l=o?.tagName.toUpperCase();if(!("INPUT"===l||"TEXTAREA"===l||"SELECT"===l||"BUTTON"===l&&32===e.keyCode||o?.isContentEditable)||27===e.keyCode){if(0===r){let t=0,r=!1;switch(e.keyCode){case 38:if(this.supportsCaretBrowsingMode){this.moveCaret(!0,!1);s=!0;break}case 33:i.isVerticalScrollbarEnabled&&(r=!0);t=-1;break;case 8:a||(r=!0);t=-1;break;case 37:if(this.supportsCaretBrowsingMode)return;i.isHorizontalScrollbarEnabled&&(r=!0);case 75:case 80:t=-1;break;case 27:if(this.secondaryToolbar?.isOpen){this.secondaryToolbar.close();s=!0}if(this.signaturePropertiesManager?.isOpen){this.signaturePropertiesManager.close();s=!0}if(!this.supportsIntegratedFind&&this.findBar?.opened){this.findBar.close();s=!0}if(!s){if([document.getElementById("editorHighlightParamsToolbar"),document.getElementById("editorFreeTextParamsToolbar"),document.getElementById("editorInkParamsToolbar"),document.getElementById("editorStampParamsToolbar"),document.getElementById("editorCommentParamsToolbar"),document.getElementById("editorSignatureParamsToolbar")].find(e=>e&&!e.classList.contains("hidden"))){this.eventBus.dispatch("switchannotationeditormode",{source:this,mode:f.NONE});s=!0}}break;case 40:if(this.supportsCaretBrowsingMode){this.moveCaret(!1,!1);s=!0;break}case 34:i.isVerticalScrollbarEnabled&&(r=!0);t=1;break;case 32:a||(r=!0);t=1;break;case 39:if(this.supportsCaretBrowsingMode)return;i.isHorizontalScrollbarEnabled&&(r=!0);case 74:case 78:t=1;break;case 36:if(a||this.page>1){this.page=1;s=!0;n=!0}break;case 35:if(a||this.page<this.pagesCount){this.page=this.pagesCount;s=!0;n=!0}break;case 83:this.pdfCursorTools?.switchTool(yh);break;case 72:this.pdfCursorTools?.switchTool(Sh);break;case 82:this.rotatePages(90);break;case 115:this.viewsManager?.toggle()}0!==t&&"rtl"===AppOptions.get("readingDirection")&&(t=-t);if(0!==t&&(!r||"page-fit"===i.currentScaleValue)){const{mainContainer:e}=this.appConfig;(function viewerIsAllowedToCaptureKeyEvent(e){let t=document.activeElement;const i=e.closest("ngx-extended-pdf-viewer");for(;t&&t!==document.body;){if(t===i)return!0;if(-1!==t.tabIndex)return!1;t=t.parentElement}return!0})(e)&&(t>0?i.nextPage():i.previousPage());s=!0}}if(4===r)switch(e.keyCode){case 32:if(!a&&"page-fit"!==i.currentScaleValue)break;i.previousPage();s=!0;break;case 38:this.moveCaret(!0,!0);s=!0;break;case 40:this.moveCaret(!1,!0);s=!0;break;case 82:this.rotatePages(-90)}n&&!i.containsElement(o)&&i.focus();s&&e.preventDefault()}}AF.printPdf=function printPdf(){if(this.enablePrint)if(_m)ngx_console_NgxConsole.warn("Ignored this.printPDF() because of a pending print job.");else{ensureOverlay().then(function(){_m&&gm.open(pm)});try{dispatchEvent("beforeprint")}finally{if(_m){const e=_m,t=document.createElement("div");t.id="printContainer";document.body.append(t);e.printContainer=t;_m.renderPages().then(function(){const t=document.getElementById("printServiceDialog");t&&t.classList.add("hidden");return e.performPrint()}).catch(()=>{}).then(()=>{e.active&&abort()})}else{ngx_console_NgxConsole.error("Expected print service to be initialized.");ensureOverlay().then(function(){gm.closeIfActive(pm)})}}}};AF.PDFPrintServiceFactory=PDFPrintServiceFactory;AF.ngxConsole=new ngx_console_NgxConsole;AF.serviceWorkerOptions={showUnverifiedSignatures:!1};const GF={LinkTarget:Rh,RenderingStates:Pm,ScrollMode:Fh,SpreadMode:bh};HTMLCollection.prototype[Symbol.iterator]||(HTMLCollection.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator]);"function"!=typeof window.CustomEvent&&(window.CustomEvent=function CustomEvent(e,t){t=t||{bubbles:!1,cancelable:!1,detail:null};const i=document.createEvent("CustomEvent");i.initCustomEvent(e,t.bubbles,t.cancelable,t.detail);return i});function webViewerLoad(e){const t=function getViewerConfiguration(){return{appContainer:document.getElementsByClassName("body")[0]??document.body,principalContainer:document.getElementById("mainContainer"),mainContainer:document.getElementById("viewerContainer"),viewerContainer:document.getElementById("viewer"),viewerAlert:document.getElementById("viewer-alert"),toolbar:{container:document.getElementById("toolbarContainer"),numPages:document.getElementById("numPages"),pageNumber:document.getElementById("pageNumber"),scaleSelect:document.getElementById("scaleSelect"),customScaleOption:document.getElementById("customScaleOption"),previous:document.getElementById("previous"),next:document.getElementById("next"),zoomIn:document.getElementById("primaryZoomIn")??document.getElementById("zoomInButton"),zoomOut:document.getElementById("primaryZoomOut")??document.getElementById("zoomOutButton"),print:document.getElementById("printButton"),editorCommentButton:document.getElementById("editorCommentButton"),editorCommentParamsToolbar:document.getElementById("editorCommentParamsToolbar"),editorFreeTextButton:document.getElementById("primaryEditorFreeText")??document.getElementById("editorFreeTextButton"),editorFreeTextParamsToolbar:document.getElementById("editorFreeTextParamsToolbar"),editorHighlightButton:document.getElementById("primaryEditorHighlight")??document.getElementById("editorHighlightButton"),editorHighlightParamsToolbar:document.getElementById("editorHighlightParamsToolbar"),editorHighlightColorPicker:document.getElementById("editorHighlightColorPicker"),editorInkButton:document.getElementById("primaryEditorInk")??document.getElementById("editorInkButton"),editorInkParamsToolbar:document.getElementById("editorInkParamsToolbar"),editorStampButton:document.getElementById("primaryEditorStamp")??document.getElementById("editorStampButton"),presentationModeButton:document.getElementById("presentationMode"),editorStampParamsToolbar:document.getElementById("editorStampParamsToolbar"),editorSignatureButton:document.getElementById("primaryEditorSignatureButton")??document.getElementById("editorSignatureButton"),editorSignatureParamsToolbar:document.getElementById("editorSignatureParamsToolbar"),signaturePropertiesButton:document.getElementById("signaturePropertiesButton"),signaturePropertiesPanel:document.getElementById("signaturePropertiesPanel"),signaturePropertiesContainer:document.getElementById("signaturePropertiesContainer"),signaturePropertiesBanner:document.getElementById("signaturePropertiesBanner"),signaturePropertiesList:document.getElementById("signaturePropertiesList"),signaturePropertiesSeparator:document.getElementById("signaturePropertiesSeparator"),download:document.getElementById("downloadButton"),movePageUp:document.getElementById("movePageUpButton"),movePageDown:document.getElementById("movePageDownButton")},secondaryToolbar:{toolbar:document.getElementById("secondaryToolbar"),toggleButton:document.getElementById("secondaryToolbarToggle"),presentationModeButton:document.getElementById("secondaryPresentationMode"),openFileButton:document.getElementById("secondaryOpenFile"),printButton:document.getElementById("secondaryPrintButton"),downloadButton:document.getElementById("secondaryDownload"),viewBookmarkButton:document.getElementById("viewBookmark"),firstPageButton:document.getElementById("firstPage"),lastPageButton:document.getElementById("lastPage"),pageRotateCwButton:document.getElementById("pageRotateCw"),pageRotateCcwButton:document.getElementById("pageRotateCcw"),cursorSelectToolButton:document.getElementById("cursorSelectTool"),cursorHandToolButton:document.getElementById("cursorHandTool"),scrollPageButton:document.getElementById("scrollPage"),scrollVerticalButton:document.getElementById("scrollVertical"),scrollHorizontalButton:document.getElementById("scrollHorizontal"),scrollWrappedButton:document.getElementById("scrollWrapped"),spreadNoneButton:document.getElementById("spreadNone"),spreadOddButton:document.getElementById("spreadOdd"),spreadEvenButton:document.getElementById("spreadEven"),imageAltTextSettingsButton:document.getElementById("imageAltTextSettings"),imageAltTextSettingsSeparator:document.getElementById("imageAltTextSettingsSeparator"),documentPropertiesButton:document.getElementById("documentProperties")},viewsManager:{outerContainer:document.getElementById("outerContainer"),toggleButton:document.getElementById("viewsManagerToggleButton")??document.getElementById("primarySidebarToggle")??document.getElementById("sidebarToggleButton"),sidebarContainer:document.getElementById("viewsManager")??document.getElementById("sidebarContainer"),resizer:document.getElementById("viewsManagerResizer")??document.getElementById("sidebarResizer"),thumbnailButton:document.getElementById("thumbnailsViewMenu")??document.getElementById("viewThumbnail"),outlineButton:document.getElementById("outlinesViewMenu")??document.getElementById("viewOutline"),attachmentsButton:document.getElementById("attachmentsViewMenu")??document.getElementById("viewAttachments"),layersButton:document.getElementById("layersViewMenu")??document.getElementById("viewLayers"),viewsManagerSelectorButton:document.getElementById("viewsManagerSelectorButton"),viewsManagerSelectorOptions:document.getElementById("viewsManagerSelectorOptions"),thumbnailsView:document.getElementById("thumbnailsView")??document.getElementById("thumbnailView"),outlinesView:document.getElementById("outlinesView")??document.getElementById("outlineView"),attachmentsView:document.getElementById("attachmentsView"),layersView:document.getElementById("layersView"),viewsManagerAddFile:{button:document.getElementById("viewsManagerAddFileButton"),picker:document.getElementById("viewsManagerAddFilePicker")},viewsManagerCurrentOutlineButton:document.getElementById("viewsManagerCurrentOutlineButton")??document.getElementById("currentOutlineItem"),viewsManagerHeaderLabel:document.getElementById("viewsManagerHeaderLabel"),viewsManagerStatus:document.getElementById("viewsManagerStatus"),viewsManagerStatusBar:{viewsManagerStatusAction:document.getElementById("viewsManagerStatusAction"),viewsManagerStatusActionDeselectButton:document.getElementById("viewsManagerStatusActionDeselectButton"),viewsManagerStatusActionLabel:document.getElementById("viewsManagerStatusActionLabel")},viewsManagerUndoBar:{viewsManagerStatusUndo:document.getElementById("viewsManagerStatusUndo"),viewsManagerStatusUndoLabel:document.getElementById("viewsManagerStatusUndoLabel"),viewsManagerStatusUndoButton:document.getElementById("viewsManagerStatusUndoButton"),viewsManagerStatusUndoCloseButton:document.getElementById("viewsManagerStatusUndoCloseButton")},viewsManagerWaitingBar:{container:document.getElementById("viewsManagerStatusWaiting"),closeButton:document.getElementById("viewsManagerStatusWaitingCloseButton"),label:document.getElementById("viewsManagerStatusWaitingLabel")},manageMenu:{button:document.getElementById("viewsManagerStatusActionButton"),menu:document.getElementById("viewsManagerStatusActionOptions"),copy:document.getElementById("viewsManagerStatusActionCopy"),cut:document.getElementById("viewsManagerStatusActionCut"),delete:document.getElementById("viewsManagerStatusActionDelete"),exportSelected:document.getElementById("viewsManagerStatusActionExport")}},findBar:{bar:document.getElementById("findbar"),toggleButton:document.getElementById("primaryViewFind")??document.getElementById("viewFindButton"),findField:document.getElementById("findInput"),highlightAllCheckbox:document.getElementById("findHighlightAll"),caseSensitiveCheckbox:document.getElementById("findMatchCase"),findMultipleCheckbox:document.getElementById("findMultiple"),matchRegExpCheckbox:document.getElementById("matchRegExp"),matchDiacriticsCheckbox:document.getElementById("findMatchDiacritics"),entireWordCheckbox:document.getElementById("findEntireWord"),findMsg:document.getElementById("findMsg"),findResultsCount:document.getElementById("findResultsCount"),findPreviousButton:document.getElementById("findPreviousButton")??document.getElementById("findPrevious"),findNextButton:document.getElementById("findNextButton")??document.getElementById("findNext")},passwordOverlay:{dialog:document.getElementById("passwordDialog"),label:document.getElementById("passwordText"),input:document.getElementById("password"),submitButton:document.getElementById("passwordSubmit"),cancelButton:document.getElementById("passwordCancel")},documentProperties:{dialog:document.getElementById("documentPropertiesDialog"),closeButton:document.getElementById("documentPropertiesClose"),fields:{fileName:document.getElementById("fileNameField"),fileSize:document.getElementById("fileSizeField"),title:document.getElementById("titleField"),author:document.getElementById("authorField"),subject:document.getElementById("subjectField"),keywords:document.getElementById("keywordsField"),creationDate:document.getElementById("creationDateField"),modificationDate:document.getElementById("modificationDateField"),creator:document.getElementById("creatorField"),producer:document.getElementById("producerField"),version:document.getElementById("versionField"),pageCount:document.getElementById("pageCountField"),pageSize:document.getElementById("pageSizeField"),linearized:document.getElementById("linearizedField")}},altTextDialog:{dialog:document.getElementById("altTextDialog"),optionDescription:document.getElementById("descriptionButton"),optionDecorative:document.getElementById("decorativeButton"),textarea:document.getElementById("descriptionTextarea"),cancelButton:document.getElementById("altTextCancel"),saveButton:document.getElementById("altTextSave")},newAltTextDialog:{dialog:document.getElementById("newAltTextDialog"),title:document.getElementById("newAltTextTitle"),descriptionContainer:document.getElementById("newAltTextDescriptionContainer"),textarea:document.getElementById("newAltTextDescriptionTextarea"),disclaimer:document.getElementById("newAltTextDisclaimer"),learnMore:document.getElementById("newAltTextLearnMore"),imagePreview:document.getElementById("newAltTextImagePreview"),createAutomatically:document.getElementById("newAltTextCreateAutomatically"),createAutomaticallyButton:document.getElementById("newAltTextCreateAutomaticallyButton"),downloadModel:document.getElementById("newAltTextDownloadModel"),downloadModelDescription:document.getElementById("newAltTextDownloadModelDescription"),error:document.getElementById("newAltTextError"),errorCloseButton:document.getElementById("newAltTextCloseButton"),cancelButton:document.getElementById("newAltTextCancel"),notNowButton:document.getElementById("newAltTextNotNow"),saveButton:document.getElementById("newAltTextSave")},altTextSettingsDialog:{dialog:document.getElementById("altTextSettingsDialog"),createModelButton:document.getElementById("createModelButton"),learnMore:document.getElementById("altTextSettingsLearnMore"),showAltTextDialogButton:document.getElementById("showAltTextDialogButton"),altTextSettingsCloseButton:document.getElementById("altTextSettingsCloseButton"),closeButton:document.getElementById("altTextSettingsCloseButton")},addSignatureDialog:{dialog:document.getElementById("addSignatureDialog"),panels:document.getElementById("addSignatureActionContainer"),typeButton:document.getElementById("addSignatureTypeButton"),typeInput:document.getElementById("addSignatureTypeInput"),drawButton:document.getElementById("addSignatureDrawButton"),drawSVG:document.getElementById("addSignatureDraw"),drawPlaceholder:document.getElementById("addSignatureDrawPlaceholder"),drawThickness:document.getElementById("addSignatureDrawThickness"),imageButton:document.getElementById("addSignatureImageButton"),imageSVG:document.getElementById("addSignatureImage"),imagePlaceholder:document.getElementById("addSignatureImagePlaceholder"),imagePicker:document.getElementById("addSignatureFilePicker"),imagePickerLink:document.getElementById("addSignatureImageBrowse"),description:document.getElementById("addSignatureDescription"),clearButton:document.getElementById("clearSignatureButton"),saveContainer:document.getElementById("addSignatureSaveContainer"),saveCheckbox:document.getElementById("addSignatureSaveCheckbox"),errorBar:document.getElementById("addSignatureError"),errorTitle:document.getElementById("addSignatureErrorTitle"),errorDescription:document.getElementById("addSignatureErrorDescription"),errorCloseButton:document.getElementById("addSignatureErrorCloseButton"),cancelButton:document.getElementById("addSignatureCancelButton"),addButton:document.getElementById("addSignatureAddButton")},editSignatureDialog:{dialog:document.getElementById("editSignatureDescriptionDialog"),description:document.getElementById("editSignatureDescription"),editSignatureView:document.getElementById("editSignatureView"),cancelButton:document.getElementById("editSignatureCancelButton"),updateButton:document.getElementById("editSignatureUpdateButton")},annotationEditorParams:{editorCommentsSidebar:document.getElementById("editorCommentsSidebar"),editorCommentsSidebarCount:document.getElementById("editorCommentsSidebarCount"),editorCommentsSidebarTitle:document.getElementById("editorCommentsSidebarTitle"),editorCommentsSidebarCloseButton:document.getElementById("editorCommentsSidebarCloseButton"),editorCommentsSidebarList:document.getElementById("editorCommentsSidebarList"),editorCommentsSidebarResizer:document.getElementById("editorCommentsSidebarResizer"),editorFreeTextFontSize:document.getElementById("editorFreeTextFontSize"),editorFreeTextColor:document.getElementById("editorFreeTextColor"),editorInkColor:document.getElementById("editorInkColor"),editorInkThickness:document.getElementById("editorInkThickness"),editorInkOpacity:document.getElementById("editorInkOpacity"),editorStampAddImage:document.getElementById("editorStampAddImage"),editorSignatureAddSignature:document.getElementById("editorSignatureAddSignature"),editorFreeHighlightThickness:document.getElementById("editorFreeHighlightThickness"),editorHighlightShowAll:document.getElementById("editorHighlightShowAll")},editorUndoBar:{container:document.getElementById("editorUndoBar"),message:document.getElementById("editorUndoBarMessage"),undoButton:document.getElementById("editorUndoBarUndoButton"),closeButton:document.getElementById("editorUndoBarCloseButton")},editCommentDialog:{dialog:document.getElementById("commentManagerDialog"),toolbar:document.getElementById("commentManagerToolbar"),title:document.getElementById("commentManagerTitle"),textInput:document.getElementById("commentManagerTextInput"),cancelButton:document.getElementById("commentManagerCancelButton"),saveButton:document.getElementById("commentManagerSaveButton")}}}(),i=new CustomEvent("webviewerloaded",{bubbles:!0,cancelable:!0,detail:{source:window}});document.dispatchEvent(i);t.cspPolicyService=e;AF.run(t)}document.blockUnblockOnload?.(!0);globalThis.STANDALONE_VIEWER&&("interactive"===document.readyState||"complete"===document.readyState?webViewerLoad():document.addEventListener("DOMContentLoaded",webViewerLoad,!0));const BF=new CustomEvent("ngxViewerFileHasBeenLoaded",{detail:{PDFViewerApplication:AF,PDFViewerApplicationConstants:GF,PDFViewerApplicationOptions:AppOptions,webViewerLoad}});document.dispatchEvent(BF);export{AF as PDFViewerApplication,GF as PDFViewerApplicationConstants,AppOptions as PDFViewerApplicationOptions,webViewerLoad};