pdfjs-dist
Version:
Generic build of Mozilla's PDF.js library.
25 lines • 1.23 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 = 5.7.284
* pdfjsBuild = 7e5b36c2d
*/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],a=new Float32Array(t),n=[.001,0,0,.001,0,0],s=1.35,r=.35,i=.25925925925925924,o=1,l=2,f=4,c=8,h=16,u=64,m=128,p=256,d="pdfjs_internal_editor_",g=3,b=9,w=13,j=15,k=101,y={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},q=1,v=2,S=3,x=0,C=4,F=1,T=2,O=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},H="Group",D="R",M=1,N=2,E=4,_=16,z=32,L=128,U=512,X=1,W=2,K=4096,G=8192,V=32768,$=65536,Y=131072,J=1048576,Q=2097152,Z=8388608,ee=16777216,te=1,ae=2,ne=3,se=4,re=5,ie={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"},oe={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"},le={O:"PageOpen",C:"PageClose"},fe=1,ce=5,he=1,ue=2,me=3,pe=4,de=5,ge=6,be=7,we=8,je=9,ke=10,ye=11,qe=12,ve=13,Se=14,Ae=15,xe=16,Ce=17,Ie=18,Fe=19,Te=20,Oe=21,Re=22,He=23,Be=24,De=25,Me=26,Ne=27,Pe=28,Ee=29,_e=30,ze=31,Le=32,Ue=33,Xe=34,We=35,Ke=36,Ge=37,Ve=38,$e=39,Ye=40,Je=41,Qe=42,Ze=43,et=44,tt=45,at=46,nt=47,st=48,rt=49,it=50,ot=51,lt=52,ft=53,ct=54,ht=55,ut=56,mt=57,pt=58,dt=59,gt=60,bt=61,wt=62,jt=63,kt=64,yt=65,qt=66,vt=67,St=68,At=69,xt=70,Ct=71,It=72,Ft=73,Tt=74,Ot=75,Rt=76,Ht=77,Bt=80,Dt=81,Mt=83,Nt=84,Pt=85,Et=86,_t=87,zt=88,Lt=89,Ut=90,Xt=91,Wt=92,Kt=93,Gt=94,Vt=0,$t=1,Yt=2,Jt=3,Qt=4,Zt=1,ea=2;let ta=fe;function getVerbosityLevel(){return ta}function info(e){ta>=ce&&console.info(`Info: ${e}`)}function warn(e){ta>=fe&&console.warn(`Warning: ${e}`)}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function createValidAbsoluteUrl(e,t=null,a=null){if(!e)return null;if(a&&"string"==typeof e){if(a.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(a.tryConvertEncoding)try{e=stringToUTF8String(e)}catch{}}const n=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}}(n)?n:null}function shadow(e,t,a,n=!1){Object.defineProperty(e,t,{value:a,enumerable:!n,configurable:!0,writable:!1});return a}const aa=function BaseExceptionClosure(){function BaseException(e,t){this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();class PasswordException extends aa{constructor(e,t){super(e,"PasswordException");this.code=t}}class UnknownErrorException extends aa{constructor(e,t){super(e,"UnknownErrorException");this.details=t}}class InvalidPDFException extends aa{constructor(e){super(e,"InvalidPDFException")}}class ResponseException extends aa{constructor(e,t,a){super(e,"ResponseException");this.status=t;this.missing=a}}class FormatError extends aa{constructor(e){super(e,"FormatError")}}class AbortException extends aa{constructor(e){super(e,"AbortException")}}function bytesToString(e){"object"==typeof e&&void 0!==e?.length||unreachable("Invalid argument for bytesToString");const t=e.length,a=8192;if(t<a)return String.fromCharCode.apply(null,e);const n=[];for(let s=0;s<t;s+=a){const r=Math.min(s+a,t),i=e.subarray(s,r);n.push(String.fromCharCode.apply(null,i))}return n.join("")}function stringToBytes(e){"string"!=typeof e&&unreachable("Invalid argument for stringToBytes");const t=e.length,a=new Uint8Array(t);for(let n=0;n<t;++n)a[n]=255&e.charCodeAt(n);return a}function objectSize(e){return Object.keys(e).length}class FeatureTest{static get isLittleEndian(){return shadow(this,"isLittleEndian",function isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return 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 isCSSRoundSupported(){return shadow(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}static get isAlphaColorInputSupported(){return shadow(this,"isAlphaColorInputSupported",(()=>{if("undefined"==typeof document)return!1;const e=document.createElement("input");e.type="color";e.setAttribute("alpha","");e.value="#ff000080";return"#ff0000"!==e.value})())}}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,a){return`#${this.hexNums[e]}${this.hexNums[t]}${this.hexNums[a]}`}static domMatrixToTransform(e){return[e.a,e.b,e.c,e.d,e.e,e.f]}static scaleMinMax(e,t){let a;if(e[0]){if(e[0]<0){a=t[0];t[0]=t[2];t[2]=a}t[0]*=e[0];t[2]*=e[0];if(e[3]<0){a=t[1];t[1]=t[3];t[3]=a}t[1]*=e[3];t[3]*=e[3]}else{a=t[0];t[0]=t[1];t[1]=a;a=t[2];t[2]=t[3];t[3]=a;if(e[1]<0){a=t[1];t[1]=t[3];t[3]=a}t[1]*=e[1];t[3]*=e[1];if(e[2]<0){a=t[0];t[0]=t[2];t[2]=a}t[0]*=e[2];t[2]*=e[2]}t[0]+=e[4];t[1]+=e[5];t[2]+=e[4];t[3]+=e[5]}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,a=0){const n=e[a],s=e[a+1];e[a]=n*t[0]+s*t[2]+t[4];e[a+1]=n*t[1]+s*t[3]+t[5]}static applyTransformToBezier(e,t,a=0){const n=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[a+t],c=e[a+t+1];e[a+t]=f*n+c*r+o;e[a+t+1]=f*s+c*i+l}}static applyInverseTransform(e,t){const a=e[0],n=e[1],s=t[0]*t[3]-t[1]*t[2];e[0]=(a*t[3]-n*t[2]+t[2]*t[5]-t[4]*t[3])/s;e[1]=(-a*t[1]+n*t[0]+t[4]*t[1]-t[5]*t[0])/s}static axialAlignedBoundingBox(e,t,a){const n=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=n*f+o,p=m,d=n*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,a=r*c,n=r*u;m+=a;g+=a;d+=n;p+=n;b+=e;k+=e;j+=t;w+=t}a[0]=Math.min(a[0],m,d,p,g);a[1]=Math.min(a[1],b,j,w,k);a[2]=Math.max(a[2],m,d,p,g);a[3]=Math.max(a[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 a=e[0],n=e[1],s=e[2],r=e[3],i=a**2+n**2,o=a*s+n*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 a=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),n=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(a>n)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:[a,s,n,r]}static pointBoundingBox(e,t,a){a[0]=Math.min(a[0],e);a[1]=Math.min(a[1],t);a[2]=Math.max(a[2],e);a[3]=Math.max(a[3],t)}static rectBoundingBox(e,t,a,n,s){s[0]=Math.min(s[0],e,a);s[1]=Math.min(s[1],t,n);s[2]=Math.max(s[2],e,a);s[3]=Math.max(s[3],t,n)}static#e(e,t,a,n,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*a)+u*n,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,a,n,s,r,i,o,l,f,c,h){if(Math.abs(l)<1e-12){Math.abs(f)>=1e-12&&this.#e(e,t,a,n,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,a,n,s,r,i,o,(-f+m)/p,h);this.#e(e,t,a,n,s,r,i,o,(-f-m)/p,h)}static bezierBoundingBox(e,t,a,n,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,a,s,i,t,n,r,o,3*(3*(a-s)-e+i),6*(e-2*a+s),3*(a-e),l);this.#t(e,a,s,i,t,n,r,o,3*(3*(n-r)-t+o),6*(t-2*n+r),3*(n-t),l)}}const na=[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 a;if("þ"===e[0]&&"ÿ"===e[1]){a="utf-16be";e.length%2==1&&(e=e.slice(0,-1))}else if("ÿ"===e[0]&&"þ"===e[1]){a="utf-16le";e.length%2==1&&(e=e.slice(0,-1))}else"ï"===e[0]&&"»"===e[1]&&"¿"===e[2]&&(a="utf-8");if(a)try{const n=new TextDecoder(a,{fatal:!0}),s=stringToBytes(e),r=n.decode(s);return t||!r.includes("")?r:r.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g,"")}catch(e){warn(`stringToPDFString: "${e}".`)}}const a=[];for(let n=0,s=e.length;n<s;n++){const r=e.charCodeAt(n);if(!t&&27===r){for(;++n<s&&27!==e.charCodeAt(n););continue}const i=na[r];a.push(i?String.fromCharCode(i):e.charAt(n))}return a.join("")}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 a=0,n=e.length;a<n;a++)if(e[a]!==t[a])return!1;return!0}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("")}let sa=null,ra=null;const makeArr=()=>[],makeMap=()=>new Map,makeObj=()=>Object.create(null),ia=Symbol("CIRCULAR_REF"),oa=Symbol("EOF");let la=Object.create(null),fa=Object.create(null),ca=Object.create(null);class Name{constructor(e){this.name=e}static get(e){return fa[e]||=new Name(e)}}class Cmd{constructor(e){this.cmd=e}static get(e){return la[e]||=new Cmd(e)}}const ha=function nonSerializableClosure(){return ha};class Dict{__nonSerializable__=ha;#a=new Map;objId=null;suppressEncryption=!1;xref;constructor(e=null){this.xref=e}assignXref(e){this.xref=e}get size(){return this.#a.size}#n(e,t,a,n){let s=this.#a.get(t);if(void 0===s&&void 0!==a){s=this.#a.get(a);void 0===s&&void 0!==n&&(s=this.#a.get(n))}return s instanceof Ref&&this.xref?e?this.xref.fetchAsync(s,this.suppressEncryption):this.xref.fetch(s,this.suppressEncryption):s}get(e,t,a){return this.#n(!1,e,t,a)}async getAsync(e,t,a){return this.#n(!0,e,t,a)}getArray(e,t,a){let n=this.#n(!1,e,t,a);if(Array.isArray(n)){n=n.slice();for(let e=0,t=n.length;e<t;e++)n[e]instanceof Ref&&this.xref&&(n[e]=this.xref.fetch(n[e],this.suppressEncryption))}return n}getRaw(e){return this.#a.get(e)}getKeys(){return this.#a.keys()}getRawValues(){return this.#a.values()}getRawEntries(){return this.#a.entries()}set(e,t){this.#a.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.#a.has(e)}*[Symbol.iterator](){for(const[e,t]of this.#a)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:a=!1}){const n=new Dict(e),s=new Map;for(const e of t)if(e instanceof Dict)for(const[t,n]of e.getRawEntries()){let e=s.get(t);if(void 0===e){e=[];s.set(t,e)}else if(!(a&&n instanceof Dict))continue;e.push(n)}for(const[t,a]of s){if(1===a.length||!(a[0]instanceof Dict)){n.set(t,a[0]);continue}const s=new Dict(e);for(const e of a)for(const[t,a]of e.getRawEntries())s.setIfNotExists(t,a);s.size>0&&n.set(t,s)}s.clear();return n.size>0?n:Dict.empty}clone(){const e=new Dict(this.xref);for(const[t,a]of this.#a)e.set(t,a);return e}delete(e){this.#a.delete(e)}}class Ref{constructor(e,t){this.num=e;this.gen=t}toString(){return 0===this.gen?`${this.num}R`:`${this.num}R${this.gen}`}static fromString(e){const t=ca[e];if(t)return t;const a=/^(\d+)R(\d*)$/.exec(e);return a&&"0"!==a[1]?ca[e]=new Ref(parseInt(a[1],10),a[2]?parseInt(a[2],10):0):null}static get(e,t){const a=0===t?`${e}R`:`${e}R${t}`;return ca[a]||=new Ref(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))}[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,a=null){unreachable("Abstract method `makeSubStream` called")}getBaseStreams(){return null}getOriginalStream(){return this.stream?.getOriginalStream()||this}}const ua=/^[1-9]\.\d$/,ma=2**31-1,pa=[1,0,0,1,0,0],da=["ColorSpace","ExtGState","Font","Pattern","Properties","Shading","XObject"],ga=["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 aa{constructor(e,t){super(`Missing data [${e}, ${t})`,"MissingDataException");this.begin=e;this.end=t}}class ParserEOFException extends aa{constructor(e){super(e,"ParserEOFException")}}class XRefEntryException extends aa{constructor(e){super(e,"XRefEntryException")}}class XRefParseException extends aa{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 a=0;for(let n=0;n<t;n++)a+=e[n].byteLength;const n=new Uint8Array(a);let s=0;for(let a=0;a<t;a++){const t=new Uint8Array(e[a]);n.set(t,s);s+=t.byteLength}return n}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:a=!1,stopWhenFound:n=!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=a?e.getArray(t):e.get(t);if(void 0!==i){if(n)return i;(s||=[]).push(i)}e=e.get("Parent")}return s}function deepCompare(e,t){if(e===t)return!0;if(e instanceof Dict&&t instanceof Dict){if(e.size!==t.size)return!1;for(const[a,n]of e.getRawEntries()){const e=t.getRaw(a);if(void 0===e||!deepCompare(n,e))return!1}return!0}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let a=0,n=e.length;a<n;a++)if(!deepCompare(e[a],t[a]))return!1;return!0}return!1}const ba=["","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 a="M".repeat(e/1e3|0)+ba[e%1e3/100|0]+ba[10+(e%100/10|0)]+ba[20+e%10];return t?a.toLowerCase():a}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 a=e.match(t);return a?{name:a[1],pos:parseInt(a[2],10)}:{name:e,pos:0}})}function escapePDFName(e){const t=[];let a=0;for(let n=0,s=e.length;n<s;n++){const s=e.charCodeAt(n);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){a<n&&t.push(e.substring(a,n));t.push(`#${s.toString(16)}`);a=n+1}}if(0===t.length)return e;a<e.length&&t.push(e.substring(a,e.length));return t.join("")}function escapeString(e){return e.replaceAll(/([()\\\n\r])/g,e=>"\n"===e?"\\n":"\r"===e?"\\r":`\\${e}`)}function _collectJS(e,t,a,n){if(!e)return;let s=null;if(e instanceof Ref){if(n.has(e))return;s=e;n.put(s);e=t.fetch(e)}if(Array.isArray(e))for(const s of e)_collectJS(s,t,a,n);else if(e instanceof Dict){if(isName(e.get("S"),"JavaScript")){const t=e.get("JS");let n;t instanceof BaseStream?n=t.getString():"string"==typeof t&&(n=t);n&&=stringToPDFString(n,!0).replaceAll("\0","");n&&a.push(n.trim())}_collectJS(e.getRaw("Next"),t,a,n)}s&&n.remove(s)}function collectActions(e,t,a){const n=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=a[t];if(!r)continue;const i=[];_collectJS(s,e,i,new RefSet);i.length>0&&(n[r]=i)}}if(t.has("A")){const a=[];_collectJS(t.get("A"),e,a,new RefSet);a.length>0&&(n.Action=a)}return objectSize(n)>0?n:null}const wa={60:"<",62:">",38:"&",34:""",39:"'"};function*codePointIter(e){for(let t=0,a=e.length;t<a;t++){const a=e.codePointAt(t);a>55295&&(a<57344||a>65533)&&t++;yield a}}function encodeToXmlString(e){const t=[];let a=0;for(let n=0,s=e.length;n<s;n++){const s=e.codePointAt(n);if(32<=s&&s<=126){const r=wa[s];if(r){a<n&&t.push(e.substring(a,n));t.push(r);a=n+1}}else{a<n&&t.push(e.substring(a,n));t.push(`&#x${s.toString(16).toUpperCase()};`);s>55295&&(s<57344||s>65533)&&n++;a=n+1}}if(0===t.length)return e;a<e.length&&t.push(e.substring(a,e.length));return t.join("")}function validateFontName(e,t=!1){const a=/^("|').*("|')$/.exec(e);if(a&&a[1]===a[2]){if(new RegExp(`[^\\\\]${a[1]}`).test(e.slice(1,-1))){t&&warn(`FontFamily contains unescaped ${a[1]}: ${e}.`);return!1}}else for(const a of e.split(/[ \t]+/))if(/^(\d|(-(\d|-)))/.test(a)||!/^[\w-\\]+$/.test(a)){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:a,fontWeight:n,italicAngle:s}=e;if(!validateFontName(a,!0))return!1;const r=n?n.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[a,n]of e)a.startsWith(d)&&t.getOrInsertComputed(n.pageIndex,makeArr).push(n);return t.size>0?t:null}function stringToAsciiOrUTF16BE(e){return null==e||function isAscii(e){if("string"!=typeof e)return!1;return!e||/^[\x00-\x7F]*$/.test(e)}(e)?e:stringToUTF16String(e,!0)}function stringToUTF16HexString(e){const t=[];for(let a=0,n=e.length;a<n;a++){const n=e.charCodeAt(a);t.push(Util.hexNums[n>>8&255],Util.hexNums[255&n])}return t.join("")}function stringToUTF16String(e,t=!1){const a=[];t&&a.push("þÿ");for(let t=0,n=e.length;t<n;t++){const n=e.charCodeAt(t);a.push(String.fromCharCode(n>>8&255),String.fromCharCode(255&n))}return a.join("")}function getRotationMatrix(e,t,a){switch(e){case 90:return[0,1,-1,0,t,0];case 180:return[-1,0,0,-1,t,a];case 270:return[0,-1,1,0,0,a];default:throw new Error("Invalid rotation")}}function getSizeInBytes(e){return Math.ceil(Math.ceil(Math.log2(1+e))/8)}class QCMS{static#s=null;static _memory=null;static _mustAddAlpha=!1;static _destBuffer=null;static _destOffset=0;static _destLength=0;static _cssColor="";static _makeHexColor=null;static get _memoryArray(){const e=this.#s;return e?.byteLength?e:this.#s=new Uint8Array(this._memory.buffer)}}const ja=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"}),ka=Object.freeze({Perceptual:0,0:"Perceptual",RelativeColorimetric:1,1:"RelativeColorimetric",Saturation:2,2:"Saturation",AbsoluteColorimetric:3,3:"AbsoluteColorimetric"});function __wbg_get_imports(){return{__proto__:null,"./qcms_bg.js":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw new Error(function getStringFromWasm0(e,t){return function decodeText(e,t){Sa+=t;if(Sa>=va){qa=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});qa.decode();Sa=t}return qa.decode(getUint8ArrayMemory0().subarray(e,e+t))}(e>>>=0,t)}(e,t))},__wbg_copy_result_0d15f3bf9d9012ae:function(e,t){!function copy_result(e,t){const{_mustAddAlpha:a,_destBuffer:n,_destOffset:s,_destLength:r,_memoryArray:i}=QCMS;if(t!==r)if(a)for(let a=e,r=e+t,o=s;a<r;a+=3,o+=4){n[o]=i[a];n[o+1]=i[a+1];n[o+2]=i[a+2];n[o+3]=255}else for(let a=e,r=e+t,o=s;a<r;a+=3,o+=4){n[o]=i[a];n[o+1]=i[a+1];n[o+2]=i[a+2]}else n.set(i.subarray(e,e+t),s)}(e>>>0,t>>>0)},__wbg_copy_rgb_0106d9d9464fce43:function(e){!function copy_rgb(e){const{_destBuffer:t,_destOffset:a,_memoryArray:n}=QCMS;t[a]=n[e];t[a+1]=n[e+1];t[a+2]=n[e+2]}(e>>>0)},__wbg_make_cssRGB_8e24b34f71f5363e:function(e){!function make_cssRGB(e){const{_memoryArray:t}=QCMS;QCMS._cssColor=QCMS._makeHexColor(t[e],t[e+1],t[e+2])}(e>>>0)},__wbindgen_init_externref_table:function(){const e=xa.__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 ya=null;function getUint8ArrayMemory0(){null!==ya&&0!==ya.byteLength||(ya=new Uint8Array(xa.memory.buffer));return ya}function passArray8ToWasm0(e,t){const a=t(1*e.length,1)>>>0;getUint8ArrayMemory0().set(e,a/1);Ca=e.length;return a}let qa=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});qa.decode();const va=2146435072;let Sa=0;let Aa,xa,Ca=0;function __wbg_finalize_init(e,t){xa=e.exports;Aa=t;ya=null;xa.__wbindgen_start();return xa}function MathClamp(e,t,a){return Math.min(Math.max(e,t),a)}function isDefaultDecodeHelper(e,t){if(!Array.isArray(e))return!0;const a=e.length;if(a<t){warn("Decode map length is too short.");return!0}if(a>t){info("Truncating too long decode map.");e.length=t}return!1}class ColorSpace{static#r=new Uint8ClampedArray(3);constructor(e,t){this.name=e;this.numComps=t}getRgb(e,t,a=new Uint8ClampedArray(3)){this.getRgbItem(e,t,a,0);return a}getRgbHex(e,t){const a=this.getRgb(e,t,ColorSpace.#r);return Util.makeHexColor(a[0],a[1],a[2])}getRgbItem(e,t,a,n){unreachable("Should not call ColorSpace.getRgbItem")}getRgbBuffer(e,t,a,n,s,r,i){unreachable("Should not call ColorSpace.getRgbBuffer")}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,a,n,s,r,i,o,l){const f=t*a;let c=null;const h=1<<i,u=a!==s||t!==n;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 a=new Uint8ClampedArray(3*h);this.getRgbBuffer(t,0,h,a,0,i,0);if(u){c=new Uint8Array(3*f);let e=0;for(let t=0;t<f;++t){const n=3*o[t];c[e++]=a[n];c[e++]=a[n+1];c[e++]=a[n+2]}}else{let t=0;for(let n=0;n<f;++n){const s=3*o[n];e[t++]=a[s];e[t++]=a[s+1];e[t++]=a[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,n*r,e,0,i,l);if(c)if(u)!function resizeRgbImage(e,t,a,n,s,r,i){i=1!==i?0:i;const o=a/s,l=n/r;let f,c=0;const h=new Uint16Array(s),u=3*a;for(let e=0;e<s;e++)h[e]=3*Math.floor(e*o);for(let a=0;a<r;a++){const n=Math.floor(a*l)*u;for(let a=0;a<s;a++){f=n+h[a];t[c++]=e[f++];t[c++]=e[f++];t[c++]=e[f++];c+=i}}}(c,e,t,a,n,s,l);else{let t=0,a=0;for(let s=0,i=n*r;s<i;s++){e[t++]=c[a++];e[t++]=c[a++];e[t++]=c[a++];t+=l}}}get usesZeroToOneRange(){return shadow(this,"usesZeroToOneRange",!0)}static isDefaultDecode(e,t){if(isDefaultDecodeHelper(e,2*t))return!0;for(let t=0,a=e.length;t<a;t+=2)if(0!==e[t]||1!==e[t+1])return!1;return!0}}class AlternateCS extends ColorSpace{constructor(e,t,a){super("Alternate",e);this.base=t;this.tintFn=a;this.tmpBuf=new Float32Array(t.numComps)}getRgbItem(e,t,a,n){const s=this.tmpBuf;this.tintFn(e,t,s,0);this.base.getRgbItem(s,0,a,n)}getRgbBuffer(e,t,a,n,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?n:new Uint8ClampedArray(c*a),d=this.numComps,g=new Float32Array(d),b=new Float32Array(c);let w,j;for(w=0;w<a;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,a,n,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{constructor(e,t,a){super("Indexed",1);this.base=e;this.highVal=t;const n=e.numComps*(t+1);this.lookup=new Uint8Array(n);if(a instanceof BaseStream){const e=a.getBytes(n);this.lookup.set(e)}else{if("string"!=typeof a)throw new FormatError(`IndexedCS - unrecognized lookup table: ${a}`);for(let e=0;e<n;++e)this.lookup[e]=255&a.charCodeAt(e)}}getRgbItem(e,t,a,n){const{base:s,highVal:r,lookup:i}=this,o=MathClamp(Math.round(e[t]),0,r)*s.numComps;s.getRgbBuffer(i,o,1,a,n,8,0)}getRgbBuffer(e,t,a,n,s,r,i){const{base:o,highVal:l,lookup:f}=this,{numComps:c}=o,h=o.getOutputLength(c,i);for(let r=0;r<a;++r){const a=MathClamp(Math.round(e[t++]),0,l)*c;o.getRgbBuffer(f,a,1,n,s,8,i);s+=h}}getOutputLength(e,t){return this.base.getOutputLength(e*this.base.numComps,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,a,n){const s=255*e[t];a[n]=a[n+1]=a[n+2]=s}getRgbBuffer(e,t,a,n,s,r,i){const o=255/((1<<r)-1);let l=t,f=s;for(let t=0;t<a;++t){const t=o*e[l++];n[f++]=t;n[f++]=t;n[f++]=t;f+=i}}getOutputLength(e,t){return e*(3+t)}}class DeviceRgbCS extends ColorSpace{constructor(){super("DeviceRGB",3)}getRgbItem(e,t,a,n){a[n]=255*e[t];a[n+1]=255*e[t+1];a[n+2]=255*e[t+2]}getRgbBuffer(e,t,a,n,s,r,i){if(8===r&&0===i){n.set(e.subarray(t,t+3*a),s);return}const o=255/((1<<r)-1);let l=t,f=s;for(let t=0;t<a;++t){n[f++]=o*e[l++];n[f++]=o*e[l++];n[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,a,n,s,r,i,o,l){a!==s||t!==n?function resizeRgbaImage(e,t,a,n,s,r,i){const o=a/s,l=n/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 n=new Uint32Array(e.buffer),i=new Uint32Array(t.buffer),h=FeatureTest.isLittleEndian?16777215:4294967040;for(let e=0;e<r;e++){const t=n.subarray(Math.floor(e*l)*a);for(let e=0;e<s;e++)i[f++]|=t[c[e]]&h}}else{const n=4,i=a*n;for(let e=0;e<s;e++)c[e]=Math.floor(e*o)*n;for(let a=0;a<r;a++){const n=e.subarray(Math.floor(a*l)*i);for(let e=0;e<s;e++){const a=c[e];t[f++]=n[a];t[f++]=n[a+1];t[f++]=n[a+2]}}}}(o,e,t,a,n,s,l):function copyRgbaImage(e,t,a){if(1===a){const a=new Uint32Array(e.buffer),n=new Uint32Array(t.buffer),s=FeatureTest.isLittleEndian?16777215:4294967040;for(let e=0,t=a.length;e<t;e++)n[e]|=a[e]&s}else{let a=0;for(let n=0,s=e.length;n<s;n+=4){t[a++]=e[n];t[a++]=e[n+1];t[a++]=e[n+2]}}}(o,e,l)}}class DeviceCmykCS extends ColorSpace{constructor(){super("DeviceCMYK",4)}#i(e,t,a,n,s){const r=e[t]*a,i=e[t+1]*a,o=e[t+2]*a,l=e[t+3]*a;n[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);n[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);n[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,a,n){this.#i(e,t,1,a,n)}getRgbBuffer(e,t,a,n,s,r,i){const o=1/((1<<r)-1);for(let r=0;r<a;r++){this.#i(e,t,o,n,s);t+=4;s+=3+i}}getOutputLength(e,t){return e/4*(3+t)|0}}class CalGrayCS extends ColorSpace{constructor(e,t,a){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=a||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}}#i(e,t,a,n,s){const r=(e[t]*s)**this.G,i=this.YW*r,o=Math.max(295.8*i**.3333333333333333-40.8,0);a[n]=o;a[n+1]=o;a[n+2]=o}getRgbItem(e,t,a,n){this.#i(e,t,a,n,1)}getRgbBuffer(e,t,a,n,s,r,i){const o=1/((1<<r)-1);for(let r=0;r<a;++r){this.#i(e,t,n,s,o);t+=1;s+=3+i}}getOutputLength(e,t){return e*(3+t)}}class CalRGBCS extends ColorSpace{static#o=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]);static#l=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]);static#f=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]);static#c=new Float32Array([1,1,1]);static#h=new Float32Array(3);static#u=new Float32Array(3);static#m=new Float32Array(3);static#p=(24/116)**3/8;constructor(e,t,a,n){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]=a||new Float32Array([1,1,1]);[this.MXA,this.MYA,this.MZA,this.MXB,this.MYB,this.MZB,this.MXC,this.MYC,this.MZC]=n||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}}#d(e,t,a){a[0]=e[0]*t[0]+e[1]*t[1]+e[2]*t[2];a[1]=e[3]*t[0]+e[4]*t[1]+e[5]*t[2];a[2]=e[6]*t[0]+e[7]*t[1]+e[8]*t[2]}#g(e,t,a){a[0]=1*t[0]/e[0];a[1]=1*t[1]/e[1];a[2]=1*t[2]/e[2]}#b(e,t,a){a[0]=.95047*t[0]/e[0];a[1]=1*t[1]/e[1];a[2]=1.08883*t[2]/e[2]}#w(e){return e<=.0031308?MathClamp(12.92*e,0,1):e>=.99554525?1:MathClamp(1.055*e**(1/2.4)-.055,0,1)}#j(e){return e<0?-this.#j(-e):e>8?((e+16)/116)**3:e*CalRGBCS.#p}#k(e,t,a){if(0===e[0]&&0===e[1]&&0===e[2]){a[0]=t[0];a[1]=t[1];a[2]=t[2];return}const n=this.#j(0),s=(1-n)/(1-this.#j(e[0])),r=1-s,i=(1-n)/(1-this.#j(e[1])),o=1-i,l=(1-n)/(1-this.#j(e[2])),f=1-l;a[0]=t[0]*s+r;a[1]=t[1]*i+o;a[2]=t[2]*l+f}#y(e,t,a){if(1===e[0]&&1===e[2]){a[0]=t[0];a[1]=t[1];a[2]=t[2];return}const n=a;this.#d(CalRGBCS.#o,t,n);const s=CalRGBCS.#h;this.#g(e,n,s);this.#d(CalRGBCS.#l,s,a)}#q(e,t,a){const n=a;this.#d(CalRGBCS.#o,t,n);const s=CalRGBCS.#h;this.#b(e,n,s);this.#d(CalRGBCS.#l,s,a)}#i(e,t,a,n,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.#u;p[0]=h;p[1]=u;p[2]=m;const d=CalRGBCS.#m;this.#y(this.whitePoint,p,d);const g=CalRGBCS.#u;this.#k(this.blackPoint,d,g);const b=CalRGBCS.#m;this.#q(CalRGBCS.#c,g,b);const w=CalRGBCS.#u;this.#d(CalRGBCS.#f,b,w);a[n]=255*this.#w(w[0]);a[n+1]=255*this.#w(w[1]);a[n+2]=255*this.#w(w[2])}getRgbItem(e,t,a,n){this.#i(e,t,a,n,1)}getRgbBuffer(e,t,a,n,s,r,i){const o=1/((1<<r)-1);for(let r=0;r<a;++r){this.#i(e,t,n,s,o);t+=3;s+=3+i}}getOutputLength(e,t){return e*(3+t)/3|0}}class LabCS extends ColorSpace{constructor(e,t,a){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]=a||[-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}}#v(e){return e>=6/29?e**3:108/841*(e-4/29)}#S(e,t,a,n){return a+e*(n-a)/t}#i(e,t,a,n,s){let r=e[t],i=e[t+1],o=e[t+2];if(!1!==a){r=this.#S(r,a,0,100);i=this.#S(i,a,this.amin,this.amax);o=this.#S(o,a,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.#v(f),u=this.YW*this.#v(l),m=this.ZW*this.#v(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}n[s]=255*Math.sqrt(p);n[s+1]=255*Math.sqrt(d);n[s+2]=255*Math.sqrt(g)}getRgbItem(e,t,a,n){this.#i(e,t,!1,a,n)}getRgbBuffer(e,t,a,n,s,r,i){const o=(1<<r)-1;for(let r=0;r<a;r++){this.#i(e,t,o,n,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{#A;#x;static#C=!0;static#I=null;static#F=null;constructor(e,t,a){if(!IccColorSpace.isUsable)throw new Error("No ICC color space support");super(t,a);let n;switch(a){case 1:n=ja.Gray8;this.#x=(e,t,a)=>function qcms_convert_one(e,t,a){xa.qcms_convert_one(e,t,a)}(this.#A,255*e[t],a);break;case 3:n=ja.RGB8;this.#x=(e,t,a)=>function qcms_convert_three(e,t,a,n,s){xa.qcms_convert_three(e,t,a,n,s)}(this.#A,255*e[t],255*e[t+1],255*e[t+2],a);break;case 4:n=ja.CMYK;this.#x=(e,t,a)=>function qcms_convert_four(e,t,a,n,s,r){xa.qcms_convert_four(e,t,a,n,s,r)}(this.#A,255*e[t],255*e[t+1],255*e[t+2],255*e[t+3],a);break;default:throw new Error(`Unsupported number of components: ${a}`)}this.#A=function qcms_transformer_from_memory(e,t,a){const n=passArray8ToWasm0(e,xa.__wbindgen_malloc),s=Ca;return xa.qcms_transformer_from_memory(n,s,t,a)>>>0}(e,n,ka.Perceptual);if(!this.#A)throw new Error("Failed to create ICC color space");IccColorSpace.#F||=new FinalizationRegistry(e=>{!function qcms_drop_transformer(e){xa.qcms_drop_transformer(e)}(e)});IccColorSpace.#F.register(this,this.#A)}getRgbHex(e,t){this.#x(e,t,!0);return QCMS._cssColor}getRgbItem(e,t,a,n){QCMS._destBuffer=a;QCMS._destOffset=n;QCMS._destLength=3;this.#x(e,t,!1);QCMS._destBuffer=null}getRgbBuffer(e,t,a,n,s,r,i){e=e.subarray(t,t+a*this.numComps);if(8!==r){const t=255/((1<<r)-1);for(let a=0,n=e.length;a<n;a++)e[a]*=t}QCMS._mustAddAlpha=i&&n.buffer===e.buffer;QCMS._destBuffer=n;QCMS._destOffset=s;QCMS._destLength=a*(3+i);!function qcms_convert_array(e,t){const a=passArray8ToWasm0(t,xa.__wbindgen_malloc),n=Ca;xa.qcms_convert_array(e,a,n)}(this.#A,e);QCMS._mustAddAlpha=!1;QCMS._destBuffer=null}getOutputLength(e,t){return e/this.numComps*(3+t)|0}static setOptions({useWasm:e,useWorkerFetch:t,wasmUrl:a}){if(t){this.#C=e;this.#I=a}else this.#C=!1}static get isUsable(){let e=!1;if(this.#C)if(this.#I)try{this._module=function initSync(e){if(void 0!==xa)return xa;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.#I}qcms_bg.wasm`)});e=!!this._module;QCMS._memory=this._module.memory;QCMS._makeHexColor=Util.makeHexColor.bind(Util)}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#T;constructor(){super(new Uint8Array(fetchSync(`${CmykICCBasedCS.#T}CGATS001Compat-v2-micro.icc`)),"DeviceCMYK",4)}static setOptions({iccUrl:e}){this.#T=e}static get isUsable(){let e=!1;IccColorSpace.isUsable&&(this.#T?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,a,n){super();this.bytes=e instanceof Uint8Array?e:new Uint8Array(e);this.start=t||0;this.pos=this.start;this.end=t+a||this.bytes.length;this.dict=n}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.bytes,a=this.pos,n=this.end;if(!e){this.pos=n;return t.subarray(a,n)}let s=a+e;s>n&&(s=n);this.pos=s;return t.subarray(a,s)}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,a=null){return new Stream(this.bytes.buffer,e,t,a)}clone(){return new Stream(this.bytes.buffer,this.start,this.end-this.start,this.dict.clone())}}class StringStream extends Stream{constructor(e){super(stringToBytes(e))}}class NullStream extends Stream{constructor(){super(new Uint8Array(0))}}class ChunkedStream extends Stream{progressiveDataLength=0;_lastSuccessfulEnsureByteChunk=-1;_loadedChunks=new Set;constructor(e,t,a){super(new Uint8Array(e),0,e,null);this.chunkSize=t;this.numChunks=Math.ceil(e/t);this.manager=a}getMissingChunks(){const e=[];for(let t=0,a=this.numChunks;t<a;++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 a=this.chunkSize;if(e%a!==0)throw new Error(`Bad begin offset: ${e}`);const n=e+t.byteLength;if(n%a!==0&&n!==this.bytes.length)throw new Error(`Bad end offset: ${n}`);this.bytes.set(new Uint8Array(t),e);const s=Math.floor(e/a),r=Math.floor((n-1)/a)+1;for(let e=s;e<r;++e)this._loadedChunks.add(e)}onReceiveProgressiveData(e){let t=this.progressiveDataLength;const a=Math.floor(t/this.chunkSize);this.bytes.set(new Uint8Array(e),t);t+=e.byteLength;this.progressiveDataLength=t;const n=t>=this.end?this.numChunks:Math.floor(t/this.chunkSize);for(let e=a;e<n;++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 a=Math.floor(e/this.chunkSize);if(a>this.numChunks)return;const n=Math.min(Math.floor((t-1)/this.chunkSize)+1,this.numChunks);for(let s=a;s<n;++s)if(!this._loadedChunks.has(s))throw new MissingDataException(e,t)}nextEmptyChunk(e){const t=this.numChunks;for(let a=0;a<t;++a){const n=(e+a)%t;if(!this._loadedChunks.has(n))return n}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.bytes,a=this.pos,n=this.end;if(!e){n>this.progressiveDataLength&&this.ensureRange(a,n);this.pos=n;return t.subarray(a,n)}let s=a+e;s>n&&(s=n);s>this.progressiveDataLength&&this.ensureRange(a,s);this.pos=s;return t.subarray(a,s)}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,a=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),a=Math.floor((this.end-1)/e)+1,n=[];for(let e=t;e<a;++e)this._loadedChunks.has(e)||n.push(e);return n};Object.defineProperty(ChunkedStreamSubstream.prototype,"isDataLoaded",{get(){return this.numChunksLoaded===this.numChunks||0===this.getMissingChunks().length},configurable:!0});const n=new ChunkedStreamSubstream;n.pos=n.start=e;n.end=e+t||this.end;n.dict=a;return n}getBaseStreams(){return[this]}}class ChunkedStreamManager{aborted=!1;currRequestId=0;_chunksNeededByRequest=new Map;_loadedStreamCapability=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 a=this.pdfStream.getRangeReader(e,t);let n=[];for(;;){const{value:e,done:t}=await a.read();if(this.aborted){n=null;return}if(t)break;n.push(e)}if(0===n.length&&this.disableAutoFetch)return;const s=arrayBuffersToBytes(n);n=null;this.onReceiveData({chunk:s.buffer,begin:e})}requestAllChunks(e=!1){if(!e){const e=this.stream.getMissingChunks();this._requestChunks(e)}return this._loadedStreamCapability.promise}_requestChunks(e){const t=this.currRequestId++,a=new Set;this._chunksNeededByRequest.set(t,a);for(const t of e)this.stream.hasChunk(t)||a.add(t);if(0===a.size)return Promise.resolve();const n=Promise.withResolvers();this._promisesByRequest.set(t,n);const s=[];for(const e of a){let a=this._requestsByChunk.get(e);if(!a){a=[];this._requestsByChunk.set(e,a);s.push(e)}a.push(t)}if(s.length>0){const e=this.groupChunks(s);for(const t of e){const e=t.beginChunk*this.chunkSize,a=Math.min(t.endChunk*this.chunkSize,this.length);this.sendRequest(e,a).catch(n.reject)}}return n.promise.catch(e=>{if(!this.aborted)throw e})}getStream(){return this.stream}requestRange(e,t){t=Math.min(t,this.length);const a=this.getBeginChunk(e),n=this.getEndChunk(t),s=[];for(let e=a;e<n;++e)s.push(e);return this._requestChunks(s)}requestRanges(e=[]){const t=[];for(const a of e){const e=this.getBeginChunk(a.begin),n=this.getEndChunk(a.end);for(let a=e;a<n;++a)t.includes(a)||t.push(a)}t.sort((e,t)=>e-t);return this._requestChunks(t)}groupChunks(e){const t=[];let a=-1,n=-1;for(let s=0,r=e.length;s<r;++s){const r=e[s];a<0&&(a=r);if(n>=0&&n+1!==r){t.push({beginChunk:a,endChunk:n+1});a=r}s+1===e.length&&t.push({beginChunk:a,endChunk:r+1});n=r}return t}onReceiveData(e){const{chunkSize:t,length:a,stream:n}=this,s=e.chunk,r=void 0===e.begin,i=r?n.progressiveDataLength:e.begin,o=i+s.byteLength,l=Math.floor(i/t),f=o<a?Math.floor(o/t):Math.ceil(o/t);r?n.onReceiveProgressiveData(s):n.onReceiveData(i,s);n.isDataLoaded&&this._loadedStreamCapability.resolve(n);const c=[];for(let e=l;e<f;++e){const t=this._requestsByChunk.get(e);if(t){this._requestsByChunk.delete(e);for(const a of t){const t=this._chunksNeededByRequest.get(a);t.has(e)&&t.delete(e);t.size>0||c.push(a)}}}if(!this.disableAutoFetch&&0===this._requestsByChunk.size){let e;if(1===n.numChunksLoaded){const t=n.numChunks-1;n.hasChunk(t)||(e=t)}else e=n.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(n.numChunksLoaded*t,n.progressiveDataLength,a),total:a})}onError(e){this._loadedStreamCapability.reject(e)}getBeginChunk(e){return Math.floor(e/this.chunkSize)}getEndChunk(e){return Math.floor((e-1)/this.chunkSize)+1}abort(e){this.aborted=!0;this.pdfStream?.cancelAllRequests(e);for(const t of this._promisesByRequest.values())t.reject(e)}}function convertToRGBA(e){switch(e.kind){case F:return convertBlackAndWhiteToRGBA(e);case T:return function convertRGBToRGBA({src:e,srcPos:t=0,dest:a,destPos:n=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,n+=4){const e=f[i],t=f[i+1],s=f[i+2];a[n]=e|c;a[n+1]=e>>>24|t<<8|c;a[n+2]=t>>>16|s<<16|c;a[n+3]=s>>>8|c}for(let s=4*i,r=t+o;s<r;s+=3)a[n++]=e[s]|e[s+1]<<8|e[s+2]<<16|c}else{for(;i<l-2;i+=3,n+=4){const e=f[i],t=f[i+1],s=f[i+2];a[n]=e|c;a[n+1]=e<<24|t>>>8|c;a[n+2]=t<<16|s>>>16|c;a[n+3]=s<<8|c}for(let s=4*i,r=t+o;s<r;s+=3)a[n++]=e[s]<<24|e[s+1]<<16|e[s+2]<<8|c}return{srcPos:t+o,destPos:n}}(e)}return null}function convertBlackAndWhiteToRGBA({src:e,srcPos:t=0,dest:a,width:n,height:s,nonBlackColor:r=4294967295,inverseDecode:i=!1}){const o=FeatureTest.isLittleEndian?4278190080:255,[l,f]=i?[r,o]:[o,r],c=n>>3,h=7&n,u=l^f,m=e.length;a=new Uint32Array(a.buffer);let p=0;for(let n=0;n<s;++n){for(const n=t+c;t<n;++t,p+=8){const n=e[t];a[p]=l^-(n>>7&1)&u;a[p+1]=l^-(n>>6&1)&u;a[p+2]=l^-(n>>5&1)&u;a[p+3]=l^-(n>>4&1)&u;a[p+4]=l^-(n>>3&1)&u;a[p+5]=l^-(n>>2&1)&u;a[p+6]=l^-(n>>1&1)&u;a[p+7]=l^-(1&n)&u}