UNPKG

pdfjs-dist

Version:

Generic build of Mozilla's PDF.js library.

26 lines 1.26 MB
/** * @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.108 * pdfjsBuild = 0365cbde0 */ const e=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),t=[1/0,1/0,-1/0,-1/0],n=new Float32Array(t),a=[.001,0,0,.001,0,0],s=.35/1.35,r="http://www.w3.org/2000/svg",i=1,o=2,l=4,f=8,c=16,h=64,u=128,m=256,p="pdfjs_internal_editor_",d=3,g=9,b=13,w=15,j=101,k={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},y=1,q=2,v=3,S=0,x=4,C=1,F=2,T=3,R={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},O="Group",H="R",D=0,M=4,N=1,E=2,_=4,z=16,L=32,U=128,W=512,X=1,K=2,G=4096,V=8192,$=32768,Y=65536,J=131072,Q=1048576,Z=2097152,ee=8388608,te=16777216,ne=1,ae=2,se=3,re=4,ie=5,oe={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"},le={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"},fe={O:"PageOpen",C:"PageClose"},ce=1,he=5,ue=1,me=2,pe=3,de=4,ge=5,be=6,we=7,je=8,ke=9,ye=10,qe=11,ve=12,Se=13,Ae=14,xe=15,Ce=16,Ie=17,Fe=18,Te=19,Re=20,Oe=21,He=22,Be=23,De=24,Me=25,Ne=26,Pe=27,Ee=28,_e=29,ze=30,Le=31,Ue=32,We=33,Xe=34,Ke=35,Ge=36,Ve=37,$e=38,Ye=39,Je=40,Qe=41,Ze=42,et=43,tt=44,nt=45,at=46,st=47,rt=48,it=49,ot=50,lt=51,ft=52,ct=53,ht=54,ut=55,mt=56,pt=57,dt=58,gt=59,bt=60,wt=61,jt=62,kt=63,yt=64,qt=65,vt=66,St=67,At=68,xt=69,Ct=70,It=71,Ft=72,Tt=73,Rt=74,Ot=75,Ht=76,Bt=77,Dt=80,Mt=81,Nt=83,Pt=84,Et=85,_t=86,zt=87,Lt=88,Ut=89,Wt=90,Xt=91,Kt=92,Gt=93,Vt=94,$t=0,Yt=1,Jt=2,Qt=3,Zt=4,en=1,tn=2;let nn=ce;function getVerbosityLevel(){return nn}function info(e){nn>=he&&console.info(`Info: ${e}`)}function warn(e){nn>=ce&&console.warn(`Warning: ${e}`)}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function createValidAbsoluteUrl(e,t=null,n=null){if(!e)return null;if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=stringToUTF8String(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:":return!0;default:return!1}}(a)?a:null}function shadow(e,t,n,a=!1){Object.defineProperty(e,t,{value:n,enumerable:!a,configurable:!0,writable:!1});return n}const an=function BaseExceptionClosure(){function BaseException(e,t){this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();class PasswordException extends an{constructor(e,t){super(e,"PasswordException");this.code=t}}class UnknownErrorException extends an{constructor(e,t){super(e,"UnknownErrorException");this.details=t}}class InvalidPDFException extends an{constructor(e){super(e,"InvalidPDFException")}}class ResponseException extends an{constructor(e,t,n){super(e,"ResponseException");this.status=t;this.missing=n}}class FormatError extends an{constructor(e){super(e,"FormatError")}}class AbortException extends an{constructor(e){super(e,"AbortException")}}function bytesToString(e){"object"==typeof e&&void 0!==e?.length||unreachable("Invalid argument for bytesToString");const t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);const a=[];for(let s=0;s<t;s+=n){const r=Math.min(s+n,t),i=e.subarray(s,r);a.push(String.fromCharCode.apply(null,i))}return a.join("")}function stringToBytes(e){"string"!=typeof e&&unreachable("Invalid argument for stringToBytes");const t=e.length,n=new Uint8Array(t);for(let a=0;a<t;++a)n[a]=255&e.charCodeAt(a);return n}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"));return shadow(this,"isCanvasFilterSupported",void 0!==e?.filter)}static get isAlphaColorInputSupported(){return shadow(this,"isAlphaColorInputSupported",!1)}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,n){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[n]}`}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,n=0){const a=e[n],s=e[n+1];e[n]=a*t[0]+s*t[2]+t[4];e[n+1]=a*t[1]+s*t[3]+t[5]}static applyTransformToBezier(e,t,n=0){const a=t[0],s=t[1],r=t[2],i=t[3],o=t[4],l=t[5];for(let t=0;t<6;t+=2){const f=e[n+t],c=e[n+t+1];e[n+t]=f*a+c*r+o;e[n+t+1]=f*s+c*i+l}}static applyInverseTransform(e,t){const n=e[0],a=e[1],s=t[0]*t[3]-t[1]*t[2];e[0]=(n*t[3]-a*t[2]+t[2]*t[5]-t[4]*t[3])/s;e[1]=(-n*t[1]+a*t[0]+t[4]*t[1]-t[5]*t[0])/s}static axialAlignedBoundingBox(e,t,n){const a=t[0],s=t[1],r=t[2],i=t[3],o=t[4],l=t[5],f=e[0],c=e[1],h=e[2],u=e[3];let m=a*f+o,p=m,d=a*h+o,g=d,b=i*c+l,w=b,j=i*u+l,k=j;if(0!==s||0!==r){const e=s*f,t=s*h,n=r*c,a=r*u;m+=n;g+=n;d+=a;p+=a;b+=e;k+=e;j+=t;w+=t}n[0]=Math.min(n[0],m,d,p,g);n[1]=Math.min(n[1],b,j,w,k);n[2]=Math.max(n[2],m,d,p,g);n[3]=Math.max(n[3],b,j,w,k)}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 n=e[0],a=e[1],s=e[2],r=e[3],i=n**2+a**2,o=n*s+a*r,l=s**2+r**2,f=(i+l)/2,c=Math.sqrt(f**2-(i*l-o**2));t[0]=Math.sqrt(f+c||1);t[1]=Math.sqrt(f-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 n=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(n>a)return null;const s=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),r=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return s>r?null:[n,s,a,r]}static pointBoundingBox(e,t,n){n[0]=Math.min(n[0],e);n[1]=Math.min(n[1],t);n[2]=Math.max(n[2],e);n[3]=Math.max(n[3],t)}static rectBoundingBox(e,t,n,a,s){s[0]=Math.min(s[0],e,n);s[1]=Math.min(s[1],t,a);s[2]=Math.max(s[2],e,n);s[3]=Math.max(s[3],t,a)}static#e(e,t,n,a,s,r,i,o,l,f){if(l<=0||l>=1)return;const c=1-l,h=l*l,u=h*l,m=c*(c*(c*e+3*l*t)+3*h*n)+u*a,p=c*(c*(c*s+3*l*r)+3*h*i)+u*o;f[0]=Math.min(f[0],m);f[1]=Math.min(f[1],p);f[2]=Math.max(f[2],m);f[3]=Math.max(f[3],p)}static#t(e,t,n,a,s,r,i,o,l,f,c,h){if(Math.abs(l)<1e-12){Math.abs(f)>=1e-12&&this.#e(e,t,n,a,s,r,i,o,-c/f,h);return}const u=f**2-4*c*l;if(u<0)return;const m=Math.sqrt(u),p=2*l;this.#e(e,t,n,a,s,r,i,o,(-f+m)/p,h);this.#e(e,t,n,a,s,r,i,o,(-f-m)/p,h)}static bezierBoundingBox(e,t,n,a,s,r,i,o,l){l[0]=Math.min(l[0],e,i);l[1]=Math.min(l[1],t,o);l[2]=Math.max(l[2],e,i);l[3]=Math.max(l[3],t,o);this.#t(e,n,s,i,t,a,r,o,3*(3*(n-s)-e+i),6*(e-2*n+s),3*(n-e),l);this.#t(e,n,s,i,t,a,r,o,3*(3*(a-r)-t+o),6*(t-2*a+r),3*(a-t),l)}}function stringToUTF8String(e){return decodeURIComponent(escape(e))}function utf8StringToString(e){return unescape(encodeURIComponent(e))}function isArrayEqual(e,t){if(e.length!==t.length)return!1;for(let n=0,a=e.length;n<a;n++)if(e[n]!==t[n])return!1;return!0}let sn=null,rn=null;const makeArr=()=>[],makeMap=()=>new Map,makeObj=()=>Object.create(null),makeSet=()=>new Set;"function"!=typeof Iterator.prototype.join&&(Iterator.prototype.join=function(e){return[...this].join(e)});const on=Symbol("CIRCULAR_REF"),ln=Symbol("EOF");let fn=Object.create(null),cn=Object.create(null),hn=Object.create(null);class Name{constructor(e){this.name=e}static get(e){return cn[e]||=new Name(e)}}class Cmd{constructor(e){this.cmd=e}static get(e){return fn[e]||=new Cmd(e)}}const un=function nonSerializableClosure(){return un};class Dict{__nonSerializable__=un;#n=new Map;objId=null;suppressEncryption=!1;xref;constructor(e=null){this.xref=e}assignXref(e){this.xref=e}get size(){return this.#n.size}#a(e,t,n,a){let s=this.#n.get(t);if(void 0===s&&void 0!==n){s=this.#n.get(n);void 0===s&&void 0!==a&&(s=this.#n.get(a))}return s instanceof Ref&&this.xref?e?this.xref.fetchAsync(s,this.suppressEncryption):this.xref.fetch(s,this.suppressEncryption):s}get(e,t,n){return this.#a(!1,e,t,n)}async getAsync(e,t,n){return this.#a(!0,e,t,n)}getArray(e,t,n){let a=this.#a(!1,e,t,n);if(Array.isArray(a)){a=a.slice();for(let e=0,t=a.length;e<t;e++)a[e]instanceof Ref&&this.xref&&(a[e]=this.xref.fetch(a[e],this.suppressEncryption))}return a}getRaw(e){return this.#n.get(e)}getKeys(){return this.#n.keys()}getRawValues(){return this.#n.values()}getRawEntries(){return this.#n.entries()}set(e,t){this.#n.set(e,t)}setIfNotExists(e,t){this.has(e)||this.set(e,t)}setIfNumber(e,t){"number"==typeof t&&this.set(e,t)}setIfArray(e,t){(Array.isArray(t)||ArrayBuffer.isView(t))&&this.set(e,t)}setIfDefined(e,t){null!=t&&this.set(e,t)}setIfName(e,t){"string"==typeof t?this.set(e,Name.get(t)):t instanceof Name&&this.set(e,t)}setIfDict(e,t){t instanceof Dict&&this.set(e,t)}has(e){return this.#n.has(e)}*[Symbol.iterator](){for(const[e,t]of this.#n)yield[e,t instanceof Ref&&this.xref?this.xref.fetch(t,this.suppressEncryption):t]}static get empty(){const e=new Dict(null);e.set=(e,t)=>{unreachable("Should not call `set` on the empty dictionary.")};return shadow(this,"empty",e)}static merge({xref:e,dictArray:t,mergeSubDicts:n=!1}){const a=new Dict(e),s=new Map;for(const e of t)if(e instanceof Dict)for(const[t,a]of e.getRawEntries()){const e=s.getOrInsertComputed(t,makeArr);(!e.length||n&&a instanceof Dict)&&e.push(a)}for(const[t,n]of s){if(1===n.length||!(n[0]instanceof Dict)){a.set(t,n[0]);continue}const s=new Dict(e);for(const e of n)for(const[t,n]of e.getRawEntries())s.setIfNotExists(t,n);s.size>0&&a.set(t,s)}s.clear();return a.size>0?a:Dict.empty}clone(){const e=new Dict(this.xref);for(const[t,n]of this.#n)e.set(t,n);return e}delete(e){this.#n.delete(e)}}class Ref{#s;constructor(e,t,n){this.#s=e;this.num=t;this.gen=n}toString(){return this.#s}static fromString(e){const t=hn[e];if(t)return t;const n=/^(\d+)R(\d*)$/.exec(e);if(!n||"0"===n[1])return null;const a=parseInt(n[1],10),s=n[2]?parseInt(n[2],10):0;return hn[e]=new Ref(e,a,s)}static get(e,t){const n=0===t?`${e}R`:`${e}R${t}`;return hn[n]||=new Ref(n,e,t)}}class RefSet{constructor(e=null){this._set=new Set(e?._set)}has(e){return this._set.has(e.toString())}put(e){this._set.add(e.toString())}remove(e){this._set.delete(e.toString())}[Symbol.iterator](){return this._set.values()}clear(){this._set.clear()}}class RefSetCache{_map=new Map;get size(){return this._map.size}get(e){return this._map.get(e.toString())}has(e){return this._map.has(e.toString())}put(e,t){this._map.set(e.toString(),t)}putAlias(e,t){this._map.set(e.toString(),this.get(t))}getOrPutComputed(e,t){const n=this._map,a=e.toString();n.has(a)||n.set(a,t(e));return n.get(a)}[Symbol.iterator](){return this._map.values()}clear(){this._map.clear()}*values(){yield*this._map.values()}*items(){for(const[e,t]of this._map)yield[Ref.fromString(e),t]}*keys(){for(const e of this._map.keys())yield Ref.fromString(e)}}function isName(e,t){return e instanceof Name&&(void 0===t||e.name===t)}function isCmd(e,t){return e instanceof Cmd&&(void 0===t||e.cmd===t)}function isDict(e,t){return e instanceof Dict&&(void 0===t||isName(e.get("Type"),t))}function isRefsEqual(e,t){return e.num===t.num&&e.gen===t.gen}class BaseStream{get length(){unreachable("Abstract getter `length` accessed")}get isEmpty(){unreachable("Abstract getter `isEmpty` accessed")}get isDataLoaded(){return shadow(this,"isDataLoaded",!0)}getByte(){unreachable("Abstract method `getByte` called")}getBytes(e){unreachable("Abstract method `getBytes` called")}async getImageData(e,t){return this.getBytes(e,t)}async asyncGetBytes(){unreachable("Abstract method `asyncGetBytes` called")}get isAsync(){return!1}get isAsyncDecoder(){return!1}get isImageStream(){return!1}get canAsyncDecodeImageFromBuffer(){return!1}async getTransferableImage(){return null}peekByte(){const e=this.getByte();-1!==e&&this.pos--;return e}peekBytes(e){const t=this.getBytes(e);this.pos-=t.length;return t}getUint16(){const e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t}getInt32(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()}getByteRange(e,t){unreachable("Abstract method `getByteRange` called")}getString(e){return bytesToString(this.getBytes(e))}skip(e){this.pos+=e||1}reset(){unreachable("Abstract method `reset` called")}moveStart(){unreachable("Abstract method `moveStart` called")}makeSubStream(e,t,n=null){unreachable("Abstract method `makeSubStream` called")}clone(){unreachable("Abstract method `clone` called")}getBaseStreams(){return null}getOriginalStream(){return this.stream?.getOriginalStream()||this}}function stringToAsciiOrUTF16BE(e){return null==e||function isAscii(e){return"string"==typeof e&&(!e||/^[\x00-\x7F]*$/.test(e))}(e)?e:stringToUTF16String(e,!0)}function stringToUTF16HexString(e){const t=[];for(let n=0,a=e.length;n<a;n++){const a=e.charCodeAt(n);t.push(Util.hexNums[a>>8&255],Util.hexNums[255&a])}return t.join("")}function stringToUTF16String(e,t=!1){const n=[];t&&n.push("þÿ");for(let t=0,a=e.length;t<a;t++){const a=e.charCodeAt(t);n.push(String.fromCharCode(a>>8&255),String.fromCharCode(255&a))}return n.join("")}const mn=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function stringToPDFString(e,t=!1){if(e[0]>="ï"){let n;if("þ"===e[0]&&"ÿ"===e[1]){n="utf-16be";e.length%2==1&&(e=e.slice(0,-1))}else if("ÿ"===e[0]&&"þ"===e[1]){n="utf-16le";e.length%2==1&&(e=e.slice(0,-1))}else"ï"===e[0]&&"»"===e[1]&&"¿"===e[2]&&(n="utf-8");if(n)try{const a=new TextDecoder(n,{fatal:!0}),s=stringToBytes(e),r=a.decode(s);return t||!r.includes("")?r:r.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g,"")}catch(e){warn(`stringToPDFString: "${e}".`)}}const n=[];for(let a=0,s=e.length;a<s;a++){const r=e.charCodeAt(a);if(!t&&27===r){for(;++a<s&&27!==e.charCodeAt(a););continue}const i=mn[r];n.push(i?String.fromCharCode(i):e.charAt(a))}return n.join("")}const pn=/^[1-9]\.\d$/,dn=2**31-1,gn=[1,0,0,1,0,0],bn=["ColorSpace","ExtGState","Font","Pattern","Properties","Shading","XObject"],wn=["ExtGState","Font","Properties","XObject"];function getLookupTableFactory(e){let t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}}class MissingDataException extends an{constructor(e,t){super(`Missing data [${e}, ${t})`,"MissingDataException");this.begin=e;this.end=t}}class ParserEOFException extends an{constructor(e){super(e,"ParserEOFException")}}class XRefEntryException extends an{constructor(e){super(e,"XRefEntryException")}}class XRefParseException extends an{constructor(e){super(e,"XRefParseException")}}function arrayBuffersToBytes(e){const t=e.length;if(0===t)return new Uint8Array(0);if(1===t)return new Uint8Array(e[0]);let n=0;for(let a=0;a<t;a++)n+=e[a].byteLength;const a=new Uint8Array(n);let s=0;for(let n=0;n<t;n++){const t=new Uint8Array(e[n]);a.set(t,s);s+=t.byteLength}return a}async function fetchBinaryData(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch file "${e}" with "${t.statusText}".`);return t.bytes()}function getInheritableProperty({dict:e,key:t,getArray:n=!1,stopWhenFound:a=!0}){let s;const r=new RefSet;for(;e instanceof Dict&&(!e.objId||!r.has(e.objId));){e.objId&&r.put(e.objId);const i=n?e.getArray(t):e.get(t);if(void 0!==i){if(a)return i;(s||=[]).push(i)}e=e.get("Parent")}return s}function deepCompare(e,t){if(e===t)return!0;if(e instanceof Ref&&t instanceof Ref)return isRefsEqual(e,t);if(e instanceof Name&&t instanceof Name)return e.name===t.name;if(e instanceof Dict&&t instanceof Dict){if(e.size!==t.size)return!1;for(const[n,a]of e.getRawEntries()){const e=t.getRaw(n);if(void 0===e||!deepCompare(a,e))return!1}return!0}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0,a=e.length;n<a;n++)if(!deepCompare(e[n],t[n]))return!1;return!0}return!1}const jn=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"];function toRomanNumerals(e,t=!1){assert(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const n="M".repeat(e/1e3|0)+jn[e%1e3/100|0]+jn[10+(e%100/10|0)]+jn[20+e%10];return t?n.toLowerCase():n}function isWhiteSpace(e){return 32===e||9===e||13===e||10===e}function isNumberArray(e,t){return Array.isArray(e)?(null===t||e.length===t)&&e.every(e=>"number"==typeof e):ArrayBuffer.isView(e)&&!(e instanceof BigInt64Array||e instanceof BigUint64Array)&&(null===t||e.length===t)}function lookupMatrix(e,t){return isNumberArray(e,6)?e:t}function lookupRect(e,t){return isNumberArray(e,4)?e:t}function lookupNormalRect(e,t){return isNumberArray(e,4)?Util.normalizeRect(e):t}function parseXFAPath(e){const t=/(.+)\[(\d+)\]$/;return e.split(".").map(e=>{const n=e.match(t);return n?{name:n[1],pos:parseInt(n[2],10)}:{name:e,pos:0}})}function escapePDFName(e){const t=[];let n=0;for(let a=0,s=e.length;a<s;a++){const s=e.charCodeAt(a);if(s<33||s>126||35===s||40===s||41===s||60===s||62===s||91===s||93===s||123===s||125===s||47===s||37===s){n<a&&t.push(e.substring(n,a));t.push(`#${s.toString(16).padStart(2,"0")}`);n=a+1}}if(0===t.length)return e;n<e.length&&t.push(e.substring(n));return t.join("")}function escapeString(e){return e.replaceAll(/([()\\\n\r])/g,e=>"\n"===e?"\\n":"\r"===e?"\\r":`\\${e}`)}function _collectJS(e,t,n,a){if(!e)return;let s=null;if(e instanceof Ref){if(a.has(e))return;s=e;a.put(s);e=t.fetch(e)}if(Array.isArray(e))for(const s of e)_collectJS(s,t,n,a);else if(e instanceof Dict){if(isName(e.get("S"),"JavaScript")){const t=e.get("JS");let a;t instanceof BaseStream?a=t.getString():"string"==typeof t&&(a=t);a&&=stringToPDFString(a,!0).replaceAll("\0","");a&&n.push(a.trim())}_collectJS(e.getRaw("Next"),t,n,a)}s&&a.remove(s)}function collectActions(e,t,n){const a=Object.create(null),s=getInheritableProperty({dict:t,key:"AA",stopWhenFound:!1});if(s)for(let t=s.length-1;t>=0;t--){const r=s[t];if(r instanceof Dict)for(const[t,s]of r.getRawEntries()){const r=n[t];if(!r)continue;const i=[];_collectJS(s,e,i,new RefSet);i.length>0&&(a[r]=i)}}if(t.has("A")){const n=[];_collectJS(t.get("A"),e,n,new RefSet);n.length>0&&(a.Action=n)}return Object.keys(a).length?a:null}const kn={60:"&lt;",62:"&gt;",38:"&amp;",34:"&quot;",39:"&apos;"};function*codePointIter(e){for(let t=0,n=e.length;t<n;t++){const n=e.codePointAt(t);n>55295&&(n<57344||n>65533)&&t++;yield n}}function encodeToXmlString(e){const t=[];let n=0;for(let a=0,s=e.length;a<s;a++){const s=e.codePointAt(a);if(32<=s&&s<=126){const r=kn[s];if(r){n<a&&t.push(e.substring(n,a));t.push(r);n=a+1}}else{n<a&&t.push(e.substring(n,a));t.push(`&#x${s.toString(16).toUpperCase()};`);s>65535&&a++;n=a+1}}if(0===t.length)return e;n<e.length&&t.push(e.substring(n));return t.join("")}function validateFontName(e,t=!1){const n=/^("|').*("|')$/.exec(e);if(n&&n[1]===n[2]){if(new RegExp(`[^\\\\]${n[1]}`).test(e.slice(1,-1))){t&&warn(`FontFamily contains unescaped ${n[1]}: ${e}.`);return!1}}else for(const n of e.split(/[ \t]+/))if(/^(?:\d|-[\d-])/.test(n)||!/^[\w\\-]+$/.test(n)){t&&warn(`FontFamily contains invalid <custom-ident>: ${e}.`);return!1}return!0}function validateCSSFont(e){const t=new Set(["100","200","300","400","500","600","700","800","900","1000","normal","bold","bolder","lighter"]),{fontFamily:n,fontWeight:a,italicAngle:s}=e;if(!validateFontName(n,!0))return!1;const r=a?a.toString():"";e.fontWeight=t.has(r)?r:"400";const i=parseFloat(s);e.italicAngle=isNaN(i)||i<-90||i>90?"14":s.toString();return!0}function recoverJsURL(e){const t=new RegExp("^\\s*("+["app.launchURL","window.open","xfa.host.gotoURL"].join("|").replaceAll(".","\\.")+")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))","i").exec(e);return t?.[2]?{url:t[2],newWindow:"app.launchURL"===t[1]&&"true"===t[3]}:null}function numberToString(e){if(Number.isInteger(e))return e.toString();const t=Math.round(100*e);return t%100==0?(t/100).toString():t%10==0?e.toFixed(1):e.toFixed(2)}function getNewAnnotationsMap(e){if(!e)return null;const t=new Map;for(const[n,a]of e)n.startsWith(p)&&t.getOrInsertComputed(a.pageIndex,makeArr).push(a);return t.size>0?t:null}function getModificationDate(e=new Date){e instanceof Date||(e=new Date(e));return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")}function getRotationMatrix(e,t,n){switch(e){case 90:return[0,1,-1,0,t,0];case 180:return[-1,0,0,-1,t,n];case 270:return[0,-1,1,0,0,n];default:throw new Error("Invalid rotation")}}function getSizeInBytes(e){return Math.ceil(Math.ceil(Math.log2(1+e))/8)}const yn=1===new Uint8Array(new Uint32Array([1]).buffer)[0]?4278190080:255,qn=~yn;class QCMS{static#r=null;static _memory=null;static _destBuffer=null;static _destOffset=0;static _keepAlpha=!1;static get _memoryArray(){const e=this.#r;return e?.byteLength?e:this.#r=new Uint8Array(this._memory.buffer)}}const vn=Object.freeze({RGB8:0,0:"RGB8",RGBA8:1,1:"RGBA8",BGRA8:2,2:"BGRA8",Gray8:3,3:"Gray8",GrayA8:4,4:"GrayA8",CMYK:5,5:"CMYK"}),Sn=Object.freeze({Perceptual:0,0:"Perceptual",RelativeColorimetric:1,1:"RelativeColorimetric",Saturation:2,2:"Saturation",AbsoluteColorimetric:3,3:"AbsoluteColorimetric"});function qcms_convert_array(e,t,n){const a=passArray8ToWasm0(t,Rn.__wbindgen_malloc),s=On;Rn.qcms_convert_array(e,a,s,n)}function __wbg_get_imports(){return{__proto__:null,"./qcms_bg.js":{__proto__:null,__wbg___wbindgen_throw_344f42d3211c4765:function(e,t){throw new Error(function getStringFromWasm0(e,t){return function decodeText(e,t){In+=t;if(In>=Cn){xn=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});xn.decode();In=t}return xn.decode(getUint8ArrayMemory0().subarray(e,e+t))}(e>>>0,t)}(e,t))},__wbg_copy_result_0d15f3bf9d9012ae:function(e,t){!function copy_result(e,t){const{_destBuffer:n,_destOffset:a,_keepAlpha:s,_memoryArray:r}=QCMS;if(!s){n.set(r.subarray(e,e+t),a);return}const i=t>>2,o=n.byteOffset+a;if(!(3&(o|e))){const t=new Uint32Array(n.buffer,o,i),a=new Uint32Array(QCMS._memory.buffer,e,i);for(let e=0;e<i;e++)t[e]=t[e]&yn|a[e]&qn;return}for(let s=e,i=e+t,o=a;s<i;s+=4,o+=4){n[o]=r[s];n[o+1]=r[s+1];n[o+2]=r[s+2]}}(e>>>0,t>>>0)},__wbindgen_init_externref_table:function(){const e=Rn.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0);e.set(t+0,void 0);e.set(t+1,null);e.set(t+2,!0);e.set(t+3,!1)}}}}let An=null;function getUint8ArrayMemory0(){null!==An&&0!==An.byteLength||(An=new Uint8Array(Rn.memory.buffer));return An}function passArray8ToWasm0(e,t){const n=t(1*e.length,1)>>>0;getUint8ArrayMemory0().set(e,n/1);On=e.length;return n}let xn=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});xn.decode();const Cn=2146435072;let In=0;let Fn,Tn,Rn,On=0;function __wbg_finalize_init(e,t){Tn=e;Rn=e.exports;Fn=t;An=null;Rn.__wbindgen_start();return Rn}function MathClamp(e,t,n){return Math.min(Math.max(e,t),n)}function isDefaultDecodeHelper(e,t){if(!Array.isArray(e))return!0;const n=e.length;if(n<t){warn("Decode map length is too short.");return!0}if(n>t){info("Truncating too long decode map.");e.length=t}return!1}class ColorSpace{static#i=new Uint8ClampedArray(3);constructor(e,t){this.name=e;this.numComps=t}getRgb(e,t,n=new Uint8ClampedArray(3)){this.getRgbItem(e,t,n,0);return n}getRgbHex(e,t){const n=this.getRgb(e,t,ColorSpace.#i);return Util.makeHexColor(n[0],n[1],n[2])}getRgbItem(e,t,n,a){unreachable("Should not call ColorSpace.getRgbItem")}getRgbBuffer(e,t,n,a,s,r,i){unreachable("Should not call ColorSpace.getRgbBuffer")}getRgbItems(e,t,n,a,s){const{numComps:r}=this;for(let i=0,o=0;i<t;i++,o+=r){this.getRgbItem(e,o,n,a);a+=3+s}}getOutputLength(e,t){unreachable("Should not call ColorSpace.getOutputLength")}isPassthrough(e){return!1}isDefaultDecode(e,t){return ColorSpace.isDefaultDecode(e,this.numComps)}fillRgb(e,t,n,a,s,r,i,o,l){const f=t*n;let c=null;const h=1<<i,u=n!==s||t!==a;if(this.isPassthrough(i))c=o;else if(1===this.numComps&&f>h&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){const t=i<=8?new Uint8Array(h):new Uint16Array(h);for(let e=0;e<h;e++)t[e]=e;const n=new Uint8ClampedArray(3*h);this.getRgbBuffer(t,0,h,n,0,i,0);if(u){c=new Uint8Array(3*f);let e=0;for(let t=0;t<f;++t){const a=3*o[t];c[e++]=n[a];c[e++]=n[a+1];c[e++]=n[a+2]}}else{let t=0;for(let a=0;a<f;++a){const s=3*o[a];e[t++]=n[s];e[t++]=n[s+1];e[t++]=n[s+2];t+=l}}}else if(u){c=new Uint8ClampedArray(3*f);this.getRgbBuffer(o,0,f,c,0,i,0)}else this.getRgbBuffer(o,0,a*r,e,0,i,l);if(c)if(u)!function resizeRgbImage(e,t,n,a,s,r,i){i=1!==i?0:i;const o=n/s,l=a/r;let f,c=0;const h=new Uint16Array(s),u=3*n;for(let e=0;e<s;e++)h[e]=3*Math.floor(e*o);for(let n=0;n<r;n++){const a=Math.floor(n*l)*u;for(let n=0;n<s;n++){f=a+h[n];t[c++]=e[f++];t[c++]=e[f++];t[c++]=e[f++];c+=i}}}(c,e,t,n,a,s,l);else{let t=0,n=0;for(let s=0,i=a*r;s<i;s++){e[t++]=c[n++];e[t++]=c[n++];e[t++]=c[n++];t+=l}}}get usesZeroToOneRange(){return shadow(this,"usesZeroToOneRange",!0)}static isDefaultDecode(e,t){if(isDefaultDecodeHelper(e,2*t))return!0;for(let t=0,n=e.length;t<n;t+=2)if(0!==e[t]||1!==e[t+1])return!1;return!0}}class AlternateCS extends ColorSpace{constructor(e,t,n){super("Alternate",e);this.base=t;this.tintFn=n;this.tmpBuf=new Float32Array(t.numComps)}getRgbItem(e,t,n,a){const s=this.tmpBuf;this.tintFn(e,t,s,0);this.base.getRgbItem(s,0,n,a)}getRgbItems(e,t,n,a,s){const{base:r,numComps:i,tintFn:o}=this,l=r.numComps,f=new Float32Array(t*l);for(let n=0,a=0,s=0;n<t;n++){o(e,a,f,s);a+=i;s+=l}r.getRgbItems(f,t,n,a,s)}getRgbBuffer(e,t,n,a,s,r,i){const o=this.tintFn,l=this.base,f=1/((1<<r)-1),c=l.numComps,h=l.usesZeroToOneRange,u=(l.isPassthrough(8)||!h)&&0===i;let m=u?s:0;const p=u?a:new Uint8ClampedArray(c*n),d=this.numComps,g=new Float32Array(d),b=new Float32Array(c);let w,j;for(w=0;w<n;w++){for(j=0;j<d;j++)g[j]=e[t++]*f;o(g,0,b,0);if(h)for(j=0;j<c;j++)p[m++]=255*b[j];else{l.getRgbItem(b,0,p,m);m+=c}}u||l.getRgbBuffer(p,0,n,a,s,8,i)}getOutputLength(e,t){return this.base.getOutputLength(e*this.base.numComps/this.numComps,t)}}class PatternCS extends ColorSpace{constructor(e){super("Pattern",null);this.base=e}isDefaultDecode(e,t){unreachable("Should not call PatternCS.isDefaultDecode")}}class IndexedCS extends ColorSpace{#o;constructor(e,t,n){super("Indexed",1);this.highVal=t;const a=t+1,s=e.numComps*a,r=new Uint8Array(s);if(n instanceof BaseStream)r.set(n.getBytes(s));else{if("string"!=typeof n)throw new FormatError(`IndexedCS - unrecognized lookup table: ${n}`);for(let e=0;e<s;++e)r[e]=n.charCodeAt(e)}this.#o=new Uint8ClampedArray(3*a);e.getRgbBuffer(r,0,a,this.#o,0,8,0)}getRgbItem(e,t,n,a){const s=this.#o,r=3*MathClamp(Math.round(e[t]),0,this.highVal);n[a]=s[r];n[a+1]=s[r+1];n[a+2]=s[r+2]}getRgbBuffer(e,t,n,a,s,r,i){const{highVal:o}=this,l=this.#o;for(let r=0;r<n;++r){const n=3*MathClamp(Math.round(e[t++]),0,o);a[s++]=l[n];a[s++]=l[n+1];a[s++]=l[n+2];s+=i}}getOutputLength(e,t){return e*(3+t)}isDefaultDecode(e,t){if(isDefaultDecodeHelper(e,2))return!0;if(!Number.isInteger(t)||t<1){warn("Bits per component is not correct");return!0}return 0===e[0]&&e[1]===(1<<t)-1}}class DeviceGrayCS extends ColorSpace{constructor(){super("DeviceGray",1)}getRgbItem(e,t,n,a){const s=255*e[t];n[a]=n[a+1]=n[a+2]=s}getRgbBuffer(e,t,n,a,s,r,i){const o=255/((1<<r)-1);let l=t,f=s;for(let t=0;t<n;++t){const t=o*e[l++];a[f++]=t;a[f++]=t;a[f++]=t;f+=i}}getOutputLength(e,t){return e*(3+t)}}class DeviceRgbCS extends ColorSpace{constructor(){super("DeviceRGB",3)}getRgbItem(e,t,n,a){n[a]=255*e[t];n[a+1]=255*e[t+1];n[a+2]=255*e[t+2]}getRgbBuffer(e,t,n,a,s,r,i){if(8===r&&0===i){a.set(e.subarray(t,t+3*n),s);return}const o=255/((1<<r)-1);let l=t,f=s;for(let t=0;t<n;++t){a[f++]=o*e[l++];a[f++]=o*e[l++];a[f++]=o*e[l++];f+=i}}getOutputLength(e,t){return e*(3+t)/3|0}isPassthrough(e){return 8===e}}class DeviceRgbaCS extends ColorSpace{constructor(){super("DeviceRGBA",4)}getOutputLength(e,t){return 4*e}isPassthrough(e){return 8===e}fillRgb(e,t,n,a,s,r,i,o,l){n!==s||t!==a?function resizeRgbaImage(e,t,n,a,s,r,i){const o=n/s,l=a/r;let f=0;const c=new Uint16Array(s);if(1===i){for(let e=0;e<s;e++)c[e]=Math.floor(e*o);const a=new Uint32Array(e.buffer),i=new Uint32Array(t.buffer),h=FeatureTest.isLittleEndian?16777215:4294967040;for(let e=0;e<r;e++){const t=a.subarray(Math.floor(e*l)*n);for(let e=0;e<s;e++)i[f++]|=t[c[e]]&h}}else{const a=4,i=n*a;for(let e=0;e<s;e++)c[e]=Math.floor(e*o)*a;for(let n=0;n<r;n++){const a=e.subarray(Math.floor(n*l)*i);for(let e=0;e<s;e++){const n=c[e];t[f++]=a[n];t[f++]=a[n+1];t[f++]=a[n+2]}}}}(o,e,t,n,a,s,l):function copyRgbaImage(e,t,n){if(1===n){const n=new Uint32Array(e.buffer),a=new Uint32Array(t.buffer),s=FeatureTest.isLittleEndian?16777215:4294967040;for(let e=0,t=n.length;e<t;e++)a[e]|=n[e]&s}else{let n=0;for(let a=0,s=e.length;a<s;a+=4){t[n++]=e[a];t[n++]=e[a+1];t[n++]=e[a+2]}}}(o,e,l)}}class DeviceCmykCS extends ColorSpace{constructor(){super("DeviceCMYK",4)}#l(e,t,n,a,s){const r=e[t]*n,i=e[t+1]*n,o=e[t+2]*n,l=e[t+3]*n;a[s]=255+r*(-4.387332384609988*r+54.48615194189176*i+18.82290502165302*o+212.25662451639585*l-285.2331026137004)+i*(1.7149763477362134*i-5.6096736904047315*o+-17.873870861415444*l-5.497006427196366)+o*(-2.5217340131683033*o-21.248923337353073*l+17.5119270841813)+l*(-21.86122147463605*l-189.48180835922747);a[s+1]=255+r*(8.841041422036149*r+60.118027045597366*i+6.871425592049007*o+31.159100130055922*l-79.2970844816548)+i*(-15.310361306967817*i+17.575251261109482*o+131.35250912493976*l-190.9453302588951)+o*(4.444339102852739*o+9.8632861493405*l-24.86741582555878)+l*(-20.737325471181034*l-187.80453709719578);a[s+2]=255+r*(.8842522430003296*r+8.078677503112928*i+30.89978309703729*o-.23883238689178934*l-14.183576799673286)+i*(10.49593273432072*i+63.02378494754052*o+50.606957656360734*l-112.23884253719248)+o*(.03296041114873217*o+115.60384449646641*l-193.58209356861505)+l*(-22.33816807309886*l-180.12613974708367)}getRgbItem(e,t,n,a){this.#l(e,t,1,n,a)}getRgbBuffer(e,t,n,a,s,r,i){const o=1/((1<<r)-1);for(let r=0;r<n;r++){this.#l(e,t,o,a,s);t+=4;s+=3+i}}getOutputLength(e,t){return e/4*(3+t)|0}}class CalGrayCS extends ColorSpace{constructor(e,t,n){super("CalGray",1);if(!e)throw new FormatError("WhitePoint missing - required for color space CalGray");[this.XW,this.YW,this.ZW]=e;[this.XB,this.YB,this.ZB]=t||[0,0,0];this.G=n||1;if(this.XW<0||this.ZW<0||1!==this.YW)throw new FormatError(`Invalid WhitePoint components for ${this.name}, no fallback available`);if(this.XB<0||this.YB<0||this.ZB<0){info(`Invalid BlackPoint for ${this.name}, falling back to default.`);this.XB=this.YB=this.ZB=0}0===this.XB&&0===this.YB&&0===this.ZB||warn(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ZB: ${this.ZB}, only default values are supported.`);if(this.G<1){info(`Invalid Gamma: ${this.G} for ${this.name}, falling back to default.`);this.G=1}}#l(e,t,n,a,s){const r=(e[t]*s)**this.G,i=this.YW*r,o=Math.max(295.8*i**.3333333333333333-40.8,0);n[a]=o;n[a+1]=o;n[a+2]=o}getRgbItem(e,t,n,a){this.#l(e,t,n,a,1)}getRgbBuffer(e,t,n,a,s,r,i){const o=1/((1<<r)-1);for(let r=0;r<n;++r){this.#l(e,t,a,s,o);t+=1;s+=3+i}}getOutputLength(e,t){return e*(3+t)}}class CalRGBCS extends ColorSpace{static#f=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]);static#c=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]);static#h=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]);static#u=new Float32Array([1,1,1]);static#m=new Float32Array(3);static#p=new Float32Array(3);static#d=new Float32Array(3);static#g=(24/116)**3/8;constructor(e,t,n,a){super("CalRGB",3);if(!e)throw new FormatError("WhitePoint missing - required for color space CalRGB");const[s,r,i]=this.whitePoint=e,[o,l,f]=this.blackPoint=t||new Float32Array(3);[this.GR,this.GG,this.GB]=n||new Float32Array([1,1,1]);[this.MXA,this.MYA,this.MZA,this.MXB,this.MYB,this.MZB,this.MXC,this.MYC,this.MZC]=a||new Float32Array([1,0,0,0,1,0,0,0,1]);if(s<0||i<0||1!==r)throw new FormatError(`Invalid WhitePoint components for ${this.name}, no fallback available`);if(o<0||l<0||f<0){info(`Invalid BlackPoint for ${this.name} [${o}, ${l}, ${f}], falling back to default.`);this.blackPoint=new Float32Array(3)}if(this.GR<0||this.GG<0||this.GB<0){info(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ${this.name}, falling back to default.`);this.GR=this.GG=this.GB=1}}#b(e,t,n){n[0]=e[0]*t[0]+e[1]*t[1]+e[2]*t[2];n[1]=e[3]*t[0]+e[4]*t[1]+e[5]*t[2];n[2]=e[6]*t[0]+e[7]*t[1]+e[8]*t[2]}#w(e,t,n){n[0]=1*t[0]/e[0];n[1]=1*t[1]/e[1];n[2]=1*t[2]/e[2]}#j(e,t,n){n[0]=.95047*t[0]/e[0];n[1]=1*t[1]/e[1];n[2]=1.08883*t[2]/e[2]}#k(e){return e<=.0031308?MathClamp(12.92*e,0,1):e>=.99554525?1:MathClamp(1.055*e**(1/2.4)-.055,0,1)}#y(e){return e<0?-this.#y(-e):e>8?((e+16)/116)**3:e*CalRGBCS.#g}#q(e,t,n){if(0===e[0]&&0===e[1]&&0===e[2]){n[0]=t[0];n[1]=t[1];n[2]=t[2];return}const a=this.#y(0),s=(1-a)/(1-this.#y(e[0])),r=1-s,i=(1-a)/(1-this.#y(e[1])),o=1-i,l=(1-a)/(1-this.#y(e[2])),f=1-l;n[0]=t[0]*s+r;n[1]=t[1]*i+o;n[2]=t[2]*l+f}#v(e,t,n){if(1===e[0]&&1===e[2]){n[0]=t[0];n[1]=t[1];n[2]=t[2];return}const a=n;this.#b(CalRGBCS.#f,t,a);const s=CalRGBCS.#m;this.#w(e,a,s);this.#b(CalRGBCS.#c,s,n)}#S(e,t,n){const a=n;this.#b(CalRGBCS.#f,t,a);const s=CalRGBCS.#m;this.#j(e,a,s);this.#b(CalRGBCS.#c,s,n)}#l(e,t,n,a,s){const r=MathClamp(e[t]*s,0,1),i=MathClamp(e[t+1]*s,0,1),o=MathClamp(e[t+2]*s,0,1),l=1===r?1:r**this.GR,f=1===i?1:i**this.GG,c=1===o?1:o**this.GB,h=this.MXA*l+this.MXB*f+this.MXC*c,u=this.MYA*l+this.MYB*f+this.MYC*c,m=this.MZA*l+this.MZB*f+this.MZC*c,p=CalRGBCS.#p;p[0]=h;p[1]=u;p[2]=m;const d=CalRGBCS.#d;this.#v(this.whitePoint,p,d);const g=CalRGBCS.#p;this.#q(this.blackPoint,d,g);const b=CalRGBCS.#d;this.#S(CalRGBCS.#u,g,b);const w=CalRGBCS.#p;this.#b(CalRGBCS.#h,b,w);n[a]=255*this.#k(w[0]);n[a+1]=255*this.#k(w[1]);n[a+2]=255*this.#k(w[2])}getRgbItem(e,t,n,a){this.#l(e,t,n,a,1)}getRgbBuffer(e,t,n,a,s,r,i){const o=1/((1<<r)-1);for(let r=0;r<n;++r){this.#l(e,t,a,s,o);t+=3;s+=3+i}}getOutputLength(e,t){return e*(3+t)/3|0}}class LabCS extends ColorSpace{constructor(e,t,n){super("Lab",3);if(!e)throw new FormatError("WhitePoint missing - required for color space Lab");[this.XW,this.YW,this.ZW]=e;[this.amin,this.amax,this.bmin,this.bmax]=n||[-100,100,-100,100];[this.XB,this.YB,this.ZB]=t||[0,0,0];if(this.XW<0||this.ZW<0||1!==this.YW)throw new FormatError("Invalid WhitePoint components, no fallback available");if(this.XB<0||this.YB<0||this.ZB<0){info("Invalid BlackPoint, falling back to default");this.XB=this.YB=this.ZB=0}if(this.amin>this.amax||this.bmin>this.bmax){info("Invalid Range, falling back to defaults");this.amin=-100;this.amax=100;this.bmin=-100;this.bmax=100}}#A(e){return e>=6/29?e**3:108/841*(e-4/29)}#x(e,t,n,a){return n+e*(a-n)/t}#l(e,t,n,a,s){let r=e[t],i=e[t+1],o=e[t+2];if(!1!==n){r=this.#x(r,n,0,100);i=this.#x(i,n,this.amin,this.amax);o=this.#x(o,n,this.bmin,this.bmax)}i>this.amax?i=this.amax:i<this.amin&&(i=this.amin);o>this.bmax?o=this.bmax:o<this.bmin&&(o=this.bmin);const l=(r+16)/116,f=l+i/500,c=l-o/200,h=this.XW*this.#A(f),u=this.YW*this.#A(l),m=this.ZW*this.#A(c);let p,d,g;if(this.ZW<1){p=3.1339*h+-1.617*u+-.4906*m;d=-.9785*h+1.916*u+.0333*m;g=.072*h+-.229*u+1.4057*m}else{p=3.2406*h+-1.5372*u+-.4986*m;d=-.9689*h+1.8758*u+.0415*m;g=.0557*h+-.204*u+1.057*m}a[s]=255*Math.sqrt(p);a[s+1]=255*Math.sqrt(d);a[s+2]=255*Math.sqrt(g)}getRgbItem(e,t,n,a){this.#l(e,t,!1,n,a)}getRgbBuffer(e,t,n,a,s,r,i){const o=(1<<r)-1;for(let r=0;r<n;r++){this.#l(e,t,o,a,s);t+=3;s+=3+i}}getOutputLength(e,t){return e*(3+t)/3|0}isDefaultDecode(e,t){return!0}get usesZeroToOneRange(){return shadow(this,"usesZeroToOneRange",!1)}}function fetchSync(e){const t=new XMLHttpRequest;t.open("GET",e,!1);t.responseType="arraybuffer";t.send(null);return t.response}class IccColorSpace extends ColorSpace{#C;#I;static#F=!0;static#T=null;static#R=null;constructor(e,t,n){if(!IccColorSpace.isUsable)throw new Error("No ICC color space support");super(t,n);let a;switch(n){case 1:a=vn.Gray8;this.#I=(e,t)=>function qcms_convert_one(e,t){return Rn.qcms_convert_one(e,t)>>>0}(this.#C,255*e[t]);break;case 3:a=vn.RGB8;this.#I=(e,t)=>function qcms_convert_three(e,t,n,a){return Rn.qcms_convert_three(e,t,n,a)>>>0}(this.#C,255*e[t],255*e[t+1],255*e[t+2]);break;case 4:a=vn.CMYK;this.#I=(e,t)=>function qcms_convert_four(e,t,n,a,s){return Rn.qcms_convert_four(e,t,n,a,s)>>>0}(this.#C,255*e[t],255*e[t+1],255*e[t+2],255*e[t+3]);break;default:throw new Error(`Unsupported number of components: ${n}`)}this.#C=function qcms_transformer_from_memory(e,t,n){const a=passArray8ToWasm0(e,Rn.__wbindgen_malloc),s=On;return Rn.qcms_transformer_from_memory(a,s,t,n)>>>0}(e,a,Sn.Perceptual);if(!this.#C)throw new Error("Failed to create ICC color space");IccColorSpace.#R||=new FinalizationRegistry(e=>{!function qcms_drop_transformer(e){Rn.qcms_drop_transformer(e)}(e)});IccColorSpace.#R.register(this,this.#C)}getRgbHex(e,t){const n=this.#I(e,t);return Util.makeHexColor(n>>16,n>>8&255,255&n)}getRgbItem(e,t,n,a){const s=this.#I(e,t);n[a]=s>>16;n[a+1]=s>>8&255;n[a+2]=255&s}getRgbItems(e,t,n,a,s){const{numComps:r}=this,i=t*r,o=new Uint8Array(i);for(let t=0;t<i;t++)o[t]=255*e[t];QCMS._destBuffer=n;QCMS._destOffset=a;QCMS._keepAlpha=1===s;qcms_convert_array(this.#C,o,1===s);QCMS._destBuffer=null}getRgbBuffer(e,t,n,a,s,r,i){e=e.subarray(t,t+n*this.numComps);if(8!==r){const t=255/((1<<r)-1);for(let n=0,a=e.length;n<a;n++)e[n]*=t}QCMS._destBuffer=a;QCMS._destOffset=s;QCMS._keepAlpha=1===i&&a.buffer!==e.buffer;qcms_convert_array(this.#C,e,1===i);QCMS._destBuffer=null}getOutputLength(e,t){return e/this.numComps*(3+t)|0}static setOptions({useWasm:e,useWorkerFetch:t,wasmUrl:n}){if(t){this.#F=e;this.#T=n}else this.#F=!1}static get isUsable(){let e=!1;if(this.#F)if(this.#T)try{this._module=function initSync(e){if(void 0!==Rn)return Rn;void 0!==e&&(Object.getPrototypeOf(e)===Object.prototype?({module:e}=e):console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));const t=__wbg_get_imports();e instanceof WebAssembly.Module||(e=new WebAssembly.Module(e));return __wbg_finalize_init(new WebAssembly.Instance(e,t),e)}({module:fetchSync(`${this.#T}qcms_bg.wasm`)});e=!!this._module;QCMS._memory=this._module.memory}catch(e){warn(`ICCBased color space: "${e}".`)}else warn("No ICC color space support due to missing `wasmUrl` API option");return shadow(this,"isUsable",e)}}class CmykICCBasedCS extends IccColorSpace{static#O;constructor(){super(new Uint8Array(fetchSync(`${CmykICCBasedCS.#O}CGATS001Compat-v2-micro.icc`)),"DeviceCMYK",4)}static setOptions({iccUrl:e}){this.#O=e}static get isUsable(){let e=!1;IccColorSpace.isUsable&&(this.#O?e=!0:warn("No CMYK ICC profile support due to missing `iccUrl` API option"));return shadow(this,"isUsable",e)}}class Stream extends BaseStream{constructor(e,t,n,a){super();this.bytes=e instanceof Uint8Array?e:new Uint8Array(e);this.start=t||0;this.pos=this.start;this.end=t+n||this.bytes.length;this.dict=a}get length(){return this.end-this.start}get isEmpty(){return 0===this.length}getByte(){return this.pos>=this.end?-1:this.bytes[this.pos++]}getBytes(e){const t=this.pos,n=e?Math.min(t+e,this.end):this.end;this.pos=n;return this.bytes.subarray(t,n)}getByteRange(e,t){e<0&&(e=0);t>this.end&&(t=this.end);return this.bytes.subarray(e,t)}reset(){this.pos=this.start}moveStart(){this.start=this.pos}makeSubStream(e,t,n=null){return new Stream(this.bytes.buffer,e,t,n)}clone(){return new Stream(this.bytes.buffer,this.start,this.length,this.dict?.clone())}}class StringStream extends Stream{constructor(e,t=null){super(stringToBytes(e),NaN,NaN,t)}}class NullStream extends Stream{constructor(){super(new Uint8Array(0))}}class ChunkedStream extends Stream{progressiveDataLength=0;_lastSuccessfulEnsureByteChunk=-1;_loadedChunks=new Set;constructor(e,t,n){super(new Uint8Array(e),0,e,null);this.chunkSize=t;this.numChunks=Math.ceil(e/t);this.manager=n}getMissingChunks(){const e=[];for(let t=0,n=this.numChunks;t<n;++t)this._loadedChunks.has(t)||e.push(t);return e}get numChunksLoaded(){return this._loadedChunks.size}get isDataLoaded(){return this.numChunksLoaded===this.numChunks}onReceiveData(e,t){const n=this.chunkSize;if(e%n!==0)throw new Error(`Bad begin offset: ${e}`);const a=e+t.byteLength;if(a%n!==0&&a!==this.bytes.length)throw new Error(`Bad end offset: ${a}`);this.bytes.set(new Uint8Array(t),e);const s=Math.floor(e/n),r=Math.floor((a-1)/n)+1;for(let e=s;e<r;++e)this._loadedChunks.add(e)}onReceiveProgressiveData(e){let t=this.progressiveDataLength;const n=Math.floor(t/this.chunkSize);this.bytes.set(new Uint8Array(e),t);t+=e.byteLength;this.progressiveDataLength=t;const a=t>=this.end?this.numChunks:Math.floor(t/this.chunkSize);for(let e=n;e<a;++e)this._loadedChunks.add(e)}ensureByte(e){if(e<this.progressiveDataLength)return;const t=Math.floor(e/this.chunkSize);if(!(t>this.numChunks)&&t!==this._lastSuccessfulEnsureByteChunk){if(!this._loadedChunks.has(t))throw new MissingDataException(e,e+1);this._lastSuccessfulEnsureByteChunk=t}}ensureRange(e,t){if(e>=t)return;if(t<=this.progressiveDataLength)return;const n=Math.floor(e/this.chunkSize);if(n>this.numChunks)return;const a=Math.min(Math.floor((t-1)/this.chunkSize)+1,this.numChunks);for(let s=n;s<a;++s)if(!this._loadedChunks.has(s))throw new MissingDataException(e,t)}nextEmptyChunk(e){const t=this.numChunks;for(let n=0;n<t;++n){const a=(e+n)%t;if(!this._loadedChunks.has(a))return a}return null}hasChunk(e){return this._loadedChunks.has(e)}getByte(){const e=this.pos;if(e>=this.end)return-1;e>=this.progressiveDataLength&&this.ensureByte(e);return this.bytes[this.pos++]}getBytes(e){const t=this.pos,n=e?Math.min(t+e,this.end):this.end;n>this.progressiveDataLength&&this.ensureRange(t,n);this.pos=n;return this.bytes.subarray(t,n)}getByteRange(e,t){e<0&&(e=0);t>this.end&&(t=this.end);t>this.progressiveDataLength&&this.ensureRange(e,t);return this.bytes.subarray(e,t)}makeSubStream(e,t,n=null){t?e+t>this.progressiveDataLength&&this.ensureRange(e,e+t):e>=this.progressiveDataLength&&this.ensureByte(e);function ChunkedStreamSubstream(){}ChunkedStreamSubstream.prototype=Object.create(this);ChunkedStreamSubstream.prototype.getMissingChunks=function(){const e=this.chunkSize,t=Math.floor(this.start/e),n=Math.floor((this.end-1)/e)+1,a=[];for(let e=t;e<n;++e)this._loadedChunks.has(e)||a.push(e);return a};Object.defineProperty(ChunkedStreamSubstream.prototype,"isDataLoaded",{get(){return this.numChunksLoaded===this.numChunks||0===this.getMissingChunks().length},configurable:!0});const a=new ChunkedStreamSubstream;a.pos=a.start=e;a.end=e+t||this.end;a.dict=n;return a}getBaseStreams(){return[this]}}class ChunkedStreamManager{#H=!1;currRequestId=0;_chunksNeededByRequest=new Map;#B=Promise.withResolvers();_promisesByRequest=new Map;_requestsByChunk=new Map;constructor(e,t){this.length=t.length;this.chunkSize=t.rangeChunkSize;this.stream=new ChunkedStream(this.length,this.chunkSize,this);this.pdfStream=e;this.disableAutoFetch=t.disableAutoFetch;this.msgHandler=t.msgHandler}async sendRequest(e,t){const n=this.pdfStream.getRangeReader(e,t);let a=[];for(;;){const{value:e,done:t}=await n.read();if(this.#H){a=null;return}if(t)break;a.push(e)}if(0===a.length&&this.disableAutoFetch)return;const s=arrayBuffersToBytes(a);a=null;this.onReceiveData({chunk:s.buffer,begin:e})}requestAllChunks(e=!1){if(!e){const e=this.stream.getMissingChunks();this._requestChunks(e)}return this.#B.promise}_requestChunks(e){const t=this.currRequestId++,n=new Set;this._chunksNeededByRequest.set(t,n);for(const t of e)this.stream.hasChunk(t)||n.add(t);if(0===n.size)return Promise.resolve();const a=Promise.withResolvers();this._promisesByRequest.set(t,a);const s=[];for(const e of n){this._requestsByChunk.getOrInsertComputed(e,()=>{s.push(e);return[]}).push(t)}if(s.length>0){const e=this.groupChunks(s);for(const t of e){const e=t.beginChunk*this.chunkSize,n=Math.min(t.endChunk*this.chunkSize,this.length);this.sendRequest(e,n).catch(a.reject)}}return a.promise.catch(e=>{if(!this.#H)throw e})}getStream(){return this.stream}requestRange(e,t){t=Math.min(t,this.length);const n=this.getBeginChunk(e),a=this.getEndChunk(t),s=[];for(let e=n;e<a;++e)s.push(e);return this._requestChunks(s)}requestRanges(e=[]){const t=[];for(const n of e){const e=this.getBeginChunk(n.begin),a=this.getEndChunk(n.end);for(let n=e;n<a;++n)t.includes(n)||t.push(n)}t.sort((e,t)=>e-t);return this._requestChunks(t)}groupChunks(e){const t=[];let n=-1,a=-1;for(let s=0,r=e.length;s<r;++s){const r=e[s];n<0&&(n=r);if(a>=0&&a+1!==r){t.push({beginChunk:n,endChunk:a+1});n=r}s+1===e.length&&t.push({beginChunk:n,endChunk:r+1});a=r}return t}onReceiveData(e){const{chunkSize:t,length:n,stream:a}=this,s=e.chunk,r=void 0===e.begin,i=r?a.progressiveDataLength:e.begin,o=i+s.byteLength,l=Math.floor(i/t),f=o<n?Math.floor(o/t):Math.ceil(o/t);r?a.onReceiveProgressiveData(s):a.onReceiveData(i,s);a.isDataLoaded&&this.#B.resolve(a);const c=[];for(let e=l;e<f;++e){const t=this._requestsByChunk.get(e);if(t){this._requestsByChunk.delete(e);for(const n of t){const t=this._chunksNeededByRequest.get(n);t.has(e)&&t.delete(e);t.size>0||c.push(n)}}}if(!this.disableAutoFetch&&0===this._requestsByChunk.size){let e;if(1===a.numChunksLoaded){const t=a.numChunks-1;a.hasChunk(t)||(e=t)}else e=a.nextEmptyChunk(f);Number.isInteger(e)&&this._requestChunks([e])}for(const e of c){const t=this._promisesByRequest.get(e);this._promisesByRequest.delete(e);t.resolve()}this.msgHandler.send("DocProgress",{loaded:MathClamp(a.numChunksLoaded*t,a.progressiveDataLength,n),total:n})}getBeginChunk(e){return Math.floor(e/this.chunkSize)}getEndChunk(e){return Math.floor((e-1)/this.chunkSize)+1}abort(e){this.#H=!0;this.pdfStream?.cancelAllRequests(e);for(const t of this._promisesByRequest.values())t.reject(e);this.#B.reject(e)}}function convertToRGBA(e){switch(e.kind){case C:return convertBlackAndWhiteToRGBA(e);case F:return function convertRGBToRGBA({src:e,srcPos:t=0,dest:n,destPos:a=0,width:s,height:r}){let i=0;const o=s*r*3,l=o>>2,f=new Uint32Array(e.buffer,t,l),c=FeatureTest.isLittleEndian?4278190080:255;if(FeatureTest.isLittleEndian){for(;i<l-2;i+=3,a+=4){const e=f[i],t=f[i+1],s=f[i+2];n[a]=e|c;n[a+1]=e>>>24|t<<8|c;n[a+2]=t>>>16|s<<16|c;n[a+3]=s>>>8|c}for(let s=4*i,r=t+o;s<r;s+=3)n[a++]=e[s]|e[s+1]<<8|e[s+2]<<16|c}else{for(;i<l-2;i+=3,a+=4){const e=f[i],t=f[i+1],s=f[i+2];n[a]=e|c;n[a+1]=e<<24|t>>>8|c;n[a+2]=t<<16|s>>>16|c;n[a+3]=s<<8|c}for(let s=4*i,r=t+o;s<r;s+=3)n[a++]=e[s]<<24|e[s+1]<<16|e[s+2]<<8|c}return{srcPos:t+o,destPos:a}}(e)}return null}function convertBlackAndWhiteToRGBA({src:e,srcPos:t=0,dest:n,width:a,height:s,nonBlackColor:r=4294967295,inverseDecode:i=!1}){const o=FeatureTest.isLittleEndian?4278190080:255,[l,f]=i?[r,o]:[o,r],c=a>>3,h=7&a,u=l^f,m=e.length;n=new Uint32Array(n.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];n[p]=l^-(a>>7&1)&u;n[p+1]=l^-(a>>6&1)&u;n[p+2]=l^-(a>>5&1)&u;n[p+3]=l^-(a>>4&1)&u;n[p+4]=l^-(a>>3&1)&u;n[p+5]=l^-(a>>2&1)&u;n[p+6]=l^-(a>>1&1)&u;n[p+7]=l^-(1&a)&u}if(0===h)continue;const a=t<m?e[t++]:255;for(let e=0;e<h;++e,++p)n[p]=l^-(a>>7-e&1)&u}return{srcPos:t,destPos:p}}class ImageResizer{static#D=2048;static#M=FeatureTest.isImageDecoderSupported;constructor(e,t){this._