UNPKG

unpdf

Version:

PDF extraction and rendering across all JavaScript runtimes

1 lines 1.38 MB
void 0===globalThis.DOMMatrix&&(globalThis.DOMMatrix=class{}),void 0===globalThis.FinalizationRegistry&&(globalThis.FinalizationRegistry=class{register(){}unregister(){}}),void 0===Promise.withResolvers&&(Promise.withResolvers=function(){let e,t;return{promise:new Promise(((i,a)=>{e=i,t=a})),resolve:e,reject:t}});const e=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),t=[.001,0,0,.001,0,0],i=1.35,a=.35,s=.25925925925925924,n=1,r=2,o=4,l=8,c=16,h=64,u=128,d=256,g="pdfjs_internal_editor_",f=3,p=9,m=13,b=15,y=101,w={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},x=0,S=4,v=1,C=2,k=3,T=1,F=2,M=3,E=4,D=5,_=6,O=7,R=8,N=9,L=10,U=11,j=12,$=13,H=14,q=15,X=16,z=17,W=20,G="Group",V="R",K=1,Y=2,J=4,Z=16,Q=32,ee=128,te=512,ie=1,ae=2,se=4096,ne=8192,re=32768,oe=65536,le=131072,ce=1048576,he=2097152,ue=8388608,de=16777216,ge=1,fe=2,pe=3,me=4,be=5,ye={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"},we={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"},Ae={O:"PageOpen",C:"PageClose"},xe=1,Se=5,ve=1,Ce=2,ke=3,Te=4,Fe=5,Ie=6,Me=7,Ee=8,De=9,_e=10,Oe=11,Re=12,Pe=13,Ne=14,Be=15,Le=16,Ue=17,je=18,$e=19,He=20,qe=21,Xe=22,ze=23,We=24,Ge=25,Ve=26,Ke=27,Ye=28,Je=29,Ze=30,Qe=31,et=32,tt=33,it=34,at=35,st=36,nt=37,rt=38,ot=39,lt=40,ct=41,ht=42,ut=43,dt=44,gt=45,ft=46,pt=47,mt=48,bt=49,yt=50,wt=51,At=52,xt=53,St=54,vt=55,Ct=56,kt=57,Tt=58,Ft=59,It=60,Mt=61,Et=62,Dt=63,_t=64,Ot=65,Rt=66,Pt=67,Nt=68,Bt=69,Lt=70,Ut=71,jt=72,$t=73,Ht=74,qt=75,Xt=76,zt=77,Wt=80,Gt=81,Vt=83,Kt=84,Yt=85,Jt=86,Zt=87,Qt=88,ei=89,ti=90,ii=91,ai=92,si=93,ni=94,ri=0,oi=1,li=2,ci=3,hi=1,ui=2;let di=xe;function info$1(e){di>=Se&&console.log(`Info: ${e}`)}function warn$1(e){di>=xe&&console.log(`Warning: ${e}`)}function unreachable$1(e){throw new Error(e)}function assert$1(e,t){e||unreachable$1(t)}function createValidAbsoluteUrl$1(e,t=null,i=null){if(!e)return null;if(i&&"string"==typeof e){if(i.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(i.tryConvertEncoding)try{e=stringToUTF8String$1(e)}catch{}}const a=t?URL.parse(e,t):URL.parse(e);return function(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(a)?a:null}function shadow$1(e,t,i,a=!1){return Object.defineProperty(e,t,{value:i,enumerable:!a,configurable:!0,writable:!1}),i}const gi=function(){function BaseException(e,t){this.message=e,this.name=t}return BaseException.prototype=new Error,BaseException.constructor=BaseException,BaseException}();let fi=class extends gi{constructor(e,t){super(e,"PasswordException"),this.code=t}},pi=class extends gi{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}},mi=class extends gi{constructor(e){super(e,"InvalidPDFException")}},bi=class extends gi{constructor(e,t,i){super(e,"ResponseException"),this.status=t,this.missing=i}},yi=class extends gi{constructor(e){super(e,"FormatError")}},wi=class extends gi{constructor(e){super(e,"AbortException")}};function bytesToString$1(e){"object"==typeof e&&void 0!==e?.length||unreachable$1("Invalid argument for bytesToString");const t=e.length,i=8192;if(t<i)return String.fromCharCode.apply(null,e);const a=[];for(let s=0;s<t;s+=i){const n=Math.min(s+i,t),r=e.subarray(s,n);a.push(String.fromCharCode.apply(null,r))}return a.join("")}function stringToBytes$1(e){"string"!=typeof e&&unreachable$1("Invalid argument for stringToBytes");const t=e.length,i=new Uint8Array(t);for(let a=0;a<t;++a)i[a]=255&e.charCodeAt(a);return i}function string32$1(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}function objectSize(e){return Object.keys(e).length}class FeatureTest{static get isLittleEndian(){return shadow$1(this,"isLittleEndian",function(){const e=new Uint8Array(4);return e[0]=1,1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return shadow$1(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return shadow$1(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return shadow$1(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){if("undefined"!=typeof navigator&&"string"==typeof navigator?.platform&&"string"==typeof navigator?.userAgent){const{platform:e,userAgent:t}=navigator;return shadow$1(this,"platform",{isAndroid:t.includes("Android"),isLinux:e.includes("Linux"),isMac:e.includes("Mac"),isWindows:e.includes("Win"),isFirefox:t.includes("Firefox")})}return shadow$1(this,"platform",{isAndroid:!1,isLinux:!1,isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return shadow$1(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Ai=Array.from(Array(256).keys(),(e=>e.toString(16).padStart(2,"0")));let xi=class{static makeHexColor(e,t,i){return`#${Ai[e]}${Ai[t]}${Ai[i]}`}static scaleMinMax(e,t){let i;e[0]?(e[0]<0&&(i=t[0],t[0]=t[2],t[2]=i),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(i=t[1],t[1]=t[3],t[3]=i),t[1]*=e[3],t[3]*=e[3]):(i=t[0],t[0]=t[1],t[1]=i,i=t[2],t[2]=t[3],t[3]=i,e[1]<0&&(i=t[1],t[1]=t[3],t[3]=i),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(i=t[0],t[0]=t[2],t[2]=i),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 applyTransform(e,t,i=0){const a=e[i],s=e[i+1];e[i]=a*t[0]+s*t[2]+t[4],e[i+1]=a*t[1]+s*t[3]+t[5]}static applyTransformToBezier(e,t,i=0){const a=t[0],s=t[1],n=t[2],r=t[3],o=t[4],l=t[5];for(let t=0;t<6;t+=2){const c=e[i+t],h=e[i+t+1];e[i+t]=c*a+h*n+o,e[i+t+1]=c*s+h*r+l}}static applyInverseTransform(e,t){const i=e[0],a=e[1],s=t[0]*t[3]-t[1]*t[2];e[0]=(i*t[3]-a*t[2]+t[2]*t[5]-t[4]*t[3])/s,e[1]=(-i*t[1]+a*t[0]+t[4]*t[1]-t[5]*t[0])/s}static axialAlignedBoundingBox(e,t,i){const a=t[0],s=t[1],n=t[2],r=t[3],o=t[4],l=t[5],c=e[0],h=e[1],u=e[2],d=e[3];let g=a*c+o,f=g,p=a*u+o,m=p,b=r*h+l,y=b,w=r*d+l,x=w;if(0!==s||0!==n){const e=s*c,t=s*u,i=n*h,a=n*d;g+=i,m+=i,p+=a,f+=a,b+=e,x+=e,w+=t,y+=t}i[0]=Math.min(i[0],g,p,f,m),i[1]=Math.min(i[1],b,w,y,x),i[2]=Math.max(i[2],g,p,f,m),i[3]=Math.max(i[3],b,w,y,x)}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e,t){const i=e[0],a=e[1],s=e[2],n=e[3],r=i**2+a**2,o=i*s+a*n,l=s**2+n**2,c=(r+l)/2,h=Math.sqrt(c**2-(r*l-o**2));t[0]=Math.sqrt(c+h||1),t[1]=Math.sqrt(c-h||1)}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){const i=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(i>a)return null;const s=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),n=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return s>n?null:[i,s,a,n]}static pointBoundingBox(e,t,i){i[0]=Math.min(i[0],e),i[1]=Math.min(i[1],t),i[2]=Math.max(i[2],e),i[3]=Math.max(i[3],t)}static rectBoundingBox(e,t,i,a,s){s[0]=Math.min(s[0],e,i),s[1]=Math.min(s[1],t,a),s[2]=Math.max(s[2],e,i),s[3]=Math.max(s[3],t,a)}static#e(e,t,i,a,s,n,r,o,l,c){if(l<=0||l>=1)return;const h=1-l,u=l*l,d=u*l,g=h*(h*(h*e+3*l*t)+3*u*i)+d*a,f=h*(h*(h*s+3*l*n)+3*u*r)+d*o;c[0]=Math.min(c[0],g),c[1]=Math.min(c[1],f),c[2]=Math.max(c[2],g),c[3]=Math.max(c[3],f)}static#t(e,t,i,a,s,n,r,o,l,c,h,u){if(Math.abs(l)<1e-12)return void(Math.abs(c)>=1e-12&&this.#e(e,t,i,a,s,n,r,o,-h/c,u));const d=c**2-4*h*l;if(d<0)return;const g=Math.sqrt(d),f=2*l;this.#e(e,t,i,a,s,n,r,o,(-c+g)/f,u),this.#e(e,t,i,a,s,n,r,o,(-c-g)/f,u)}static bezierBoundingBox(e,t,i,a,s,n,r,o,l){l[0]=Math.min(l[0],e,r),l[1]=Math.min(l[1],t,o),l[2]=Math.max(l[2],e,r),l[3]=Math.max(l[3],t,o),this.#t(e,i,s,r,t,a,n,o,3*(3*(i-s)-e+r),6*(e-2*i+s),3*(i-e),l),this.#t(e,i,s,r,t,a,n,o,3*(3*(a-n)-t+o),6*(t-2*a+n),3*(a-t),l)}};const Si=[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){if(e[0]>="ï"){let t;if("þ"===e[0]&&"ÿ"===e[1]?(t="utf-16be",e.length%2==1&&(e=e.slice(0,-1))):"ÿ"===e[0]&&"þ"===e[1]?(t="utf-16le",e.length%2==1&&(e=e.slice(0,-1))):"ï"===e[0]&&"»"===e[1]&&"¿"===e[2]&&(t="utf-8"),t)try{const i=new TextDecoder(t,{fatal:!0}),a=stringToBytes$1(e),s=i.decode(a);return s.includes("")?s.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g,""):s}catch(e){warn$1(`stringToPDFString: "${e}".`)}}const t=[];for(let i=0,a=e.length;i<a;i++){const s=e.charCodeAt(i);if(27===s){for(;++i<a&&27!==e.charCodeAt(i););continue}const n=Si[s];t.push(n?String.fromCharCode(n):e.charAt(i))}return t.join("")}function stringToUTF8String$1(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 i=0,a=e.length;i<a;i++)if(e[i]!==t[i])return!1;return!0}function getModificationDate(e=new Date){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 vi=null,Ci=null;function MathClamp$1(e,t,i){return Math.min(Math.max(e,t),i)}function toHexUtil(e){return Uint8Array.prototype.toHex?e.toHex():Array.from(e,(e=>Ai[e])).join("")}"function"!=typeof Promise.try&&(Promise.try=function(e,...t){return new Promise((i=>{i(e(...t))}))}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(e){return e.reduce(((e,t)=>e+t),0)});const ki=Symbol("CIRCULAR_REF"),Ti=Symbol("EOF");let Fi=Object.create(null),Ii=Object.create(null),Mi=Object.create(null);class Name{constructor(e){this.name=e}static get(e){return Ii[e]||=new Name(e)}}class Cmd{constructor(e){this.cmd=e}static get(e){return Fi[e]||=new Cmd(e)}}const nonSerializable=function(){return nonSerializable};class Dict{constructor(e=null){this._map=new Map,this.xref=e,this.objId=null,this.suppressEncryption=!1,this.__nonSerializable__=nonSerializable}assignXref(e){this.xref=e}get size(){return this._map.size}get(e,t,i){let a=this._map.get(e);return void 0===a&&void 0!==t&&(a=this._map.get(t),void 0===a&&void 0!==i&&(a=this._map.get(i))),a instanceof Ref&&this.xref?this.xref.fetch(a,this.suppressEncryption):a}async getAsync(e,t,i){let a=this._map.get(e);return void 0===a&&void 0!==t&&(a=this._map.get(t),void 0===a&&void 0!==i&&(a=this._map.get(i))),a instanceof Ref&&this.xref?this.xref.fetchAsync(a,this.suppressEncryption):a}getArray(e,t,i){let a=this._map.get(e);if(void 0===a&&void 0!==t&&(a=this._map.get(t),void 0===a&&void 0!==i&&(a=this._map.get(i))),a instanceof Ref&&this.xref&&(a=this.xref.fetch(a,this.suppressEncryption)),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._map.get(e)}getKeys(){return[...this._map.keys()]}getRawValues(){return[...this._map.values()]}set(e,t){this._map.set(e,t)}has(e){return this._map.has(e)}*[Symbol.iterator](){for(const[e,t]of this._map)yield[e,t instanceof Ref&&this.xref?this.xref.fetch(t,this.suppressEncryption):t]}static get empty(){const e=new Dict(null);return e.set=(e,t)=>{unreachable$1("Should not call `set` on the empty dictionary.")},shadow$1(this,"empty",e)}static merge({xref:e,dictArray:t,mergeSubDicts:i=!1}){const a=new Dict(e),s=new Map;for(const e of t)if(e instanceof Dict)for(const[t,a]of e._map){let e=s.get(t);if(void 0===e)e=[],s.set(t,e);else if(!(i&&a instanceof Dict))continue;e.push(a)}for(const[t,i]of s){if(1===i.length||!(i[0]instanceof Dict)){a._map.set(t,i[0]);continue}const s=new Dict(e);for(const e of i)for(const[t,i]of e._map)s._map.has(t)||s._map.set(t,i);s.size>0&&a._map.set(t,s)}return s.clear(),a.size>0?a:Dict.empty}clone(){const e=new Dict(this.xref);for(const t of this.getKeys())e.set(t,this.getRaw(t));return e}delete(e){delete this._map[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=Mi[e];if(t)return t;const i=/^(\d+)R(\d*)$/.exec(e);return i&&"0"!==i[1]?Mi[e]=new Ref(parseInt(i[1]),i[2]?parseInt(i[2]):0):null}static get(e,t){const i=0===t?`${e}R`:`${e}R${t}`;return Mi[i]||=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{constructor(){this._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]}}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$1("Abstract getter `length` accessed")}get isEmpty(){unreachable$1("Abstract getter `isEmpty` accessed")}get isDataLoaded(){return shadow$1(this,"isDataLoaded",!0)}getByte(){unreachable$1("Abstract method `getByte` called")}getBytes(e){unreachable$1("Abstract method `getBytes` called")}async getImageData(e,t){return this.getBytes(e,t)}async asyncGetBytes(){unreachable$1("Abstract method `asyncGetBytes` called")}get isAsync(){return!1}get isAsyncDecoder(){return!1}get canAsyncDecodeImageFromBuffer(){return!1}async getTransferableImage(){return null}peekByte(){const e=this.getByte();return-1!==e&&this.pos--,e}peekBytes(e){const t=this.getBytes(e);return this.pos-=t.length,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$1("Abstract method `getByteRange` called")}getString(e){return bytesToString$1(this.getBytes(e))}skip(e){this.pos+=e||1}reset(){unreachable$1("Abstract method `reset` called")}moveStart(){unreachable$1("Abstract method `moveStart` called")}makeSubStream(e,t,i=null){unreachable$1("Abstract method `makeSubStream` called")}getBaseStreams(){return null}}const Ei=/^[1-9]\.\d$/,Di=2**31-1,_i=[1,0,0,1,0,0],Oi=["ColorSpace","ExtGState","Font","Pattern","Properties","Shading","XObject"],Ri=["ExtGState","Font","Properties","XObject"];function getLookupTableFactory(e){let t;return function(){return e&&(t=Object.create(null),e(t),e=null),t}}class MissingDataException extends gi{constructor(e,t){super(`Missing data [${e}, ${t})`,"MissingDataException"),this.begin=e,this.end=t}}class ParserEOFException extends gi{constructor(e){super(e,"ParserEOFException")}}class XRefEntryException extends gi{constructor(e){super(e,"XRefEntryException")}}class XRefParseException extends gi{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 i=0;for(let a=0;a<t;a++)i+=e[a].byteLength;const a=new Uint8Array(i);let s=0;for(let i=0;i<t;i++){const t=new Uint8Array(e[i]);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 new Uint8Array(await t.arrayBuffer())}function getInheritableProperty({dict:e,key:t,getArray:i=!1,stopWhenFound:a=!0}){let s;const n=new RefSet;for(;e instanceof Dict&&(!e.objId||!n.has(e.objId));){e.objId&&n.put(e.objId);const r=i?e.getArray(t):e.get(t);if(void 0!==r){if(a)return r;(s||=[]).push(r)}e=e.get("Parent")}return s}const Pi=["","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$1(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const i="M".repeat(e/1e3|0)+Pi[e%1e3/100|0]+Pi[10+(e%100/10|0)]+Pi[20+e%10];return t?i.toLowerCase():i}function log2(e){return e>0?Math.ceil(Math.log2(e)):0}function readInt8(e,t){return e[t]<<24>>24}function readInt16(e,t){return(e[t]<<24|e[t+1]<<16)>>16}function readUint16(e,t){return e[t]<<8|e[t+1]}function readUint32(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}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)?xi.normalizeRect(e):t}function parseXFAPath(e){const t=/(.+)\[(\d+)\]$/;return e.split(".").map((e=>{const i=e.match(t);return i?{name:i[1],pos:parseInt(i[2],10)}:{name:e,pos:0}}))}function escapePDFName(e){const t=[];let i=0;for(let a=0,s=e.length;a<s;a++){const s=e.charCodeAt(a);(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)&&(i<a&&t.push(e.substring(i,a)),t.push(`#${s.toString(16)}`),i=a+1)}return 0===t.length?e:(i<e.length&&t.push(e.substring(i,e.length)),t.join(""))}function escapeString(e){return e.replaceAll(/([()\\\n\r])/g,(e=>"\n"===e?"\\n":"\r"===e?"\\r":`\\${e}`))}function _collectJS(e,t,i,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,i,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).replaceAll("\0",""),a&&i.push(a)}_collectJS(e.getRaw("Next"),t,i,a)}s&&a.remove(s)}function collectActions(e,t,i){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 n=s[t];if(n instanceof Dict)for(const t of n.getKeys()){const s=i[t];if(!s)continue;const r=[];_collectJS(n.getRaw(t),e,r,new RefSet),r.length>0&&(a[s]=r)}}if(t.has("A")){const i=[];_collectJS(t.get("A"),e,i,new RefSet),i.length>0&&(a.Action=i)}return objectSize(a)>0?a:null}const Ni={60:"&lt;",62:"&gt;",38:"&amp;",34:"&quot;",39:"&apos;"};function*codePointIter(e){for(let t=0,i=e.length;t<i;t++){const i=e.codePointAt(t);i>55295&&(i<57344||i>65533)&&t++,yield i}}function encodeToXmlString(e){const t=[];let i=0;for(let a=0,s=e.length;a<s;a++){const s=e.codePointAt(a);if(32<=s&&s<=126){const n=Ni[s];n&&(i<a&&t.push(e.substring(i,a)),t.push(n),i=a+1)}else i<a&&t.push(e.substring(i,a)),t.push(`&#x${s.toString(16).toUpperCase()};`),s>55295&&(s<57344||s>65533)&&a++,i=a+1}return 0===t.length?e:(i<e.length&&t.push(e.substring(i,e.length)),t.join(""))}function validateFontName(e,t=!1){const i=/^("|').*("|')$/.exec(e);if(i&&i[1]===i[2]){if(new RegExp(`[^\\\\]${i[1]}`).test(e.slice(1,-1)))return t&&warn$1(`FontFamily contains unescaped ${i[1]}: ${e}.`),!1}else for(const i of e.split(/[ \t]+/))if(/^(\d|(-(\d|-)))/.test(i)||!/^[\w-\\]+$/.test(i))return t&&warn$1(`FontFamily contains invalid <custom-ident>: ${e}.`),!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:i,fontWeight:a,italicAngle:s}=e;if(!validateFontName(i,!0))return!1;const n=a?a.toString():"";e.fontWeight=t.has(n)?n:"400";const r=parseFloat(s);return e.italicAngle=isNaN(r)||r<-90||r>90?"14":s.toString(),!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[i,a]of e){if(!i.startsWith(g))continue;let e=t.get(a.pageIndex);e||(e=[],t.set(a.pageIndex,e)),e.push(a)}return t.size>0?t:null}function stringToAsciiOrUTF16BE(e){return function(e){return/^[\x00-\x7F]*$/.test(e)}(e)?e:stringToUTF16String(e,!0)}function stringToUTF16HexString(e){const t=[];for(let i=0,a=e.length;i<a;i++){const a=e.charCodeAt(i);t.push(Ai[a>>8&255],Ai[255&a])}return t.join("")}function stringToUTF16String(e,t=!1){const i=[];t&&i.push("þÿ");for(let t=0,a=e.length;t<a;t++){const a=e.charCodeAt(t);i.push(String.fromCharCode(a>>8&255),String.fromCharCode(255&a))}return i.join("")}function getRotationMatrix(e,t,i){switch(e){case 90:return[0,1,-1,0,t,0];case 180:return[-1,0,0,-1,t,i];case 270:return[0,-1,1,0,0,i];default:throw new Error("Invalid rotation")}}function getSizeInBytes(e){return Math.ceil(Math.ceil(Math.log2(1+e))/8)}class QCMS{static _module=null;static _mustAddAlpha=!1;static _destBuffer=null}let Bi;const ji="undefined"!=typeof TextDecoder?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):{decode:()=>{throw Error("TextDecoder not available")}};"undefined"!=typeof TextDecoder&&ji.decode();let $i=null;function getUint8ArrayMemory0(){return null!==$i&&0!==$i.byteLength||($i=new Uint8Array(Bi.memory.buffer)),$i}let Hi=0;function passArray8ToWasm0(e,t){const i=t(1*e.length,1)>>>0;return getUint8ArrayMemory0().set(e,i/1),Hi=e.length,i}const qi=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"}),Xi=Object.freeze({Perceptual:0,0:"Perceptual",RelativeColorimetric:1,1:"RelativeColorimetric",Saturation:2,2:"Saturation",AbsoluteColorimetric:3,3:"AbsoluteColorimetric"});function __wbg_get_imports(){const e={wbg:{}};return e.wbg.__wbg_copyresult_b08ee7d273f295dd=function(e,t){!function(e,t){const{_module:i,_mustAddAlpha:a,_destBuffer:s}=QCMS,n=new Uint8Array(i.memory.buffer,e,t);if(n.length!==s.length)if(a)for(let e=0,t=0,i=n.length;e<i;e+=3,t+=4)s[t]=n[e],s[t+1]=n[e+1],s[t+2]=n[e+2],s[t+3]=255;else for(let e=0,t=0,i=n.length;e<i;e+=3,t+=4)s[t]=n[e],s[t+1]=n[e+1],s[t+2]=n[e+2];else s.set(n)}(e>>>0,t>>>0)},e.wbg.__wbg_copyrgb_d60ce17bb05d9b67=function(e){var t;t=e>>>0,QCMS._destBuffer.set(new Uint8Array(QCMS._module.memory.buffer,t,3))},e.wbg.__wbindgen_init_externref_table=function(){const e=Bi.__wbindgen_export_0,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)},e.wbg.__wbindgen_throw=function(e,t){throw new Error((i=e,a=t,i>>>=0,ji.decode(getUint8ArrayMemory0().subarray(i,i+a))));var i,a},e}function initSync(e){if(void 0!==Bi)return Bi;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 function(e){return Bi=e.exports,$i=null,Bi.__wbindgen_start(),Bi}(new WebAssembly.Instance(e,t))}class ColorSpace{constructor(e,t){this.name=e,this.numComps=t}getRgb(e,t){const i=new Uint8ClampedArray(3);return this.getRgbItem(e,t,i,0),i}getRgbItem(e,t,i,a){unreachable$1("Should not call ColorSpace.getRgbItem")}getRgbBuffer(e,t,i,a,s,n,r){unreachable$1("Should not call ColorSpace.getRgbBuffer")}getOutputLength(e,t){unreachable$1("Should not call ColorSpace.getOutputLength")}isPassthrough(e){return!1}isDefaultDecode(e,t){return ColorSpace.isDefaultDecode(e,this.numComps)}fillRgb(e,t,i,a,s,n,r,o,l){const c=t*i;let h=null;const u=1<<r,d=i!==s||t!==a;if(this.isPassthrough(r))h=o;else if(1===this.numComps&&c>u&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){const t=r<=8?new Uint8Array(u):new Uint16Array(u);for(let e=0;e<u;e++)t[e]=e;const i=new Uint8ClampedArray(3*u);if(this.getRgbBuffer(t,0,u,i,0,r,0),d){h=new Uint8Array(3*c);let e=0;for(let t=0;t<c;++t){const a=3*o[t];h[e++]=i[a],h[e++]=i[a+1],h[e++]=i[a+2]}}else{let t=0;for(let a=0;a<c;++a){const s=3*o[a];e[t++]=i[s],e[t++]=i[s+1],e[t++]=i[s+2],t+=l}}}else d?(h=new Uint8ClampedArray(3*c),this.getRgbBuffer(o,0,c,h,0,r,0)):this.getRgbBuffer(o,0,a*n,e,0,r,l);if(h)if(d)!function(e,t,i,a,s,n,r){r=1!==r?0:r;const o=i/s,l=a/n;let c,h=0;const u=new Uint16Array(s),d=3*i;for(let e=0;e<s;e++)u[e]=3*Math.floor(e*o);for(let i=0;i<n;i++){const a=Math.floor(i*l)*d;for(let i=0;i<s;i++)c=a+u[i],t[h++]=e[c++],t[h++]=e[c++],t[h++]=e[c++],h+=r}}(h,e,t,i,a,s,l);else{let t=0,i=0;for(let s=0,r=a*n;s<r;s++)e[t++]=h[i++],e[t++]=h[i++],e[t++]=h[i++],t+=l}}get usesZeroToOneRange(){return shadow$1(this,"usesZeroToOneRange",!0)}static isDefaultDecode(e,t){if(!Array.isArray(e))return!0;if(2*t!==e.length)return warn$1("The decode map is not the correct length"),!0;for(let t=0,i=e.length;t<i;t+=2)if(0!==e[t]||1!==e[t+1])return!1;return!0}}class AlternateCS extends ColorSpace{constructor(e,t,i){super("Alternate",e),this.base=t,this.tintFn=i,this.tmpBuf=new Float32Array(t.numComps)}getRgbItem(e,t,i,a){const s=this.tmpBuf;this.tintFn(e,t,s,0),this.base.getRgbItem(s,0,i,a)}getRgbBuffer(e,t,i,a,s,n,r){const o=this.tintFn,l=this.base,c=1/((1<<n)-1),h=l.numComps,u=l.usesZeroToOneRange,d=(l.isPassthrough(8)||!u)&&0===r;let g=d?s:0;const f=d?a:new Uint8ClampedArray(h*i),p=this.numComps,m=new Float32Array(p),b=new Float32Array(h);let y,w;for(y=0;y<i;y++){for(w=0;w<p;w++)m[w]=e[t++]*c;if(o(m,0,b,0),u)for(w=0;w<h;w++)f[g++]=255*b[w];else l.getRgbItem(b,0,f,g),g+=h}d||l.getRgbBuffer(f,0,i,a,s,8,r)}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$1("Should not call PatternCS.isDefaultDecode")}}class IndexedCS extends ColorSpace{constructor(e,t,i){super("Indexed",1),this.base=e,this.highVal=t;const a=e.numComps*(t+1);if(this.lookup=new Uint8Array(a),i instanceof BaseStream){const e=i.getBytes(a);this.lookup.set(e)}else{if("string"!=typeof i)throw new yi(`IndexedCS - unrecognized lookup table: ${i}`);for(let e=0;e<a;++e)this.lookup[e]=255&i.charCodeAt(e)}}getRgbItem(e,t,i,a){const{base:s,highVal:n,lookup:r}=this,o=MathClamp$1(Math.round(e[t]),0,n)*s.numComps;s.getRgbBuffer(r,o,1,i,a,8,0)}getRgbBuffer(e,t,i,a,s,n,r){const{base:o,highVal:l,lookup:c}=this,{numComps:h}=o,u=o.getOutputLength(h,r);for(let n=0;n<i;++n){const i=MathClamp$1(Math.round(e[t++]),0,l)*h;o.getRgbBuffer(c,i,1,a,s,8,r),s+=u}}getOutputLength(e,t){return this.base.getOutputLength(e*this.base.numComps,t)}isDefaultDecode(e,t){return!Array.isArray(e)||(2!==e.length?(warn$1("Decode map length is not correct"),!0):!Number.isInteger(t)||t<1?(warn$1("Bits per component is not correct"),!0):0===e[0]&&e[1]===(1<<t)-1)}}class DeviceGrayCS extends ColorSpace{constructor(){super("DeviceGray",1)}getRgbItem(e,t,i,a){const s=255*e[t];i[a]=i[a+1]=i[a+2]=s}getRgbBuffer(e,t,i,a,s,n,r){const o=255/((1<<n)-1);let l=t,c=s;for(let t=0;t<i;++t){const t=o*e[l++];a[c++]=t,a[c++]=t,a[c++]=t,c+=r}}getOutputLength(e,t){return e*(3+t)}}class DeviceRgbCS extends ColorSpace{constructor(){super("DeviceRGB",3)}getRgbItem(e,t,i,a){i[a]=255*e[t],i[a+1]=255*e[t+1],i[a+2]=255*e[t+2]}getRgbBuffer(e,t,i,a,s,n,r){if(8===n&&0===r)return void a.set(e.subarray(t,t+3*i),s);const o=255/((1<<n)-1);let l=t,c=s;for(let t=0;t<i;++t)a[c++]=o*e[l++],a[c++]=o*e[l++],a[c++]=o*e[l++],c+=r}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,i,a,s,n,r,o,l){i!==s||t!==a?function(e,t,i,a,s,n,r){const o=i/s,l=a/n;let c=0;const h=new Uint16Array(s);if(1===r){for(let e=0;e<s;e++)h[e]=Math.floor(e*o);const a=new Uint32Array(e.buffer),r=new Uint32Array(t.buffer),u=FeatureTest.isLittleEndian?16777215:4294967040;for(let e=0;e<n;e++){const t=a.subarray(Math.floor(e*l)*i);for(let e=0;e<s;e++)r[c++]|=t[h[e]]&u}}else{const a=4,r=i*a;for(let e=0;e<s;e++)h[e]=Math.floor(e*o)*a;for(let i=0;i<n;i++){const a=e.subarray(Math.floor(i*l)*r);for(let e=0;e<s;e++){const i=h[e];t[c++]=a[i],t[c++]=a[i+1],t[c++]=a[i+2]}}}}(o,e,t,i,a,s,l):function(e,t,i){if(1===i){const i=new Uint32Array(e.buffer),a=new Uint32Array(t.buffer),s=FeatureTest.isLittleEndian?16777215:4294967040;for(let e=0,t=i.length;e<t;e++)a[e]|=i[e]&s}else{let i=0;for(let a=0,s=e.length;a<s;a+=4)t[i++]=e[a],t[i++]=e[a+1],t[i++]=e[a+2]}}(o,e,l)}}class DeviceCmykCS extends ColorSpace{constructor(){super("DeviceCMYK",4)}#i(e,t,i,a,s){const n=e[t]*i,r=e[t+1]*i,o=e[t+2]*i,l=e[t+3]*i;a[s]=255+n*(-4.387332384609988*n+54.48615194189176*r+18.82290502165302*o+212.25662451639585*l-285.2331026137004)+r*(1.7149763477362134*r-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+n*(8.841041422036149*n+60.118027045597366*r+6.871425592049007*o+31.159100130055922*l-79.2970844816548)+r*(-15.310361306967817*r+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+n*(.8842522430003296*n+8.078677503112928*r+30.89978309703729*o-.23883238689178934*l-14.183576799673286)+r*(10.49593273432072*r+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,i,a){this.#i(e,t,1,i,a)}getRgbBuffer(e,t,i,a,s,n,r){const o=1/((1<<n)-1);for(let n=0;n<i;n++)this.#i(e,t,o,a,s),t+=4,s+=3+r}getOutputLength(e,t){return e/4*(3+t)|0}}class CalGrayCS extends ColorSpace{constructor(e,t,i){if(super("CalGray",1),!e)throw new yi("WhitePoint missing - required for color space CalGray");if([this.XW,this.YW,this.ZW]=e,[this.XB,this.YB,this.ZB]=t||[0,0,0],this.G=i||1,this.XW<0||this.ZW<0||1!==this.YW)throw new yi(`Invalid WhitePoint components for ${this.name}, no fallback available`);(this.XB<0||this.YB<0||this.ZB<0)&&(info$1(`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$1(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ZB: ${this.ZB}, only default values are supported.`),this.G<1&&(info$1(`Invalid Gamma: ${this.G} for ${this.name}, falling back to default.`),this.G=1)}#i(e,t,i,a,s){const n=(e[t]*s)**this.G,r=this.YW*n,o=Math.max(295.8*r**.3333333333333333-40.8,0);i[a]=o,i[a+1]=o,i[a+2]=o}getRgbItem(e,t,i,a){this.#i(e,t,i,a,1)}getRgbBuffer(e,t,i,a,s,n,r){const o=1/((1<<n)-1);for(let n=0;n<i;++n)this.#i(e,t,a,s,o),t+=1,s+=3+r}getOutputLength(e,t){return e*(3+t)}}class CalRGBCS extends ColorSpace{static#a=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]);static#s=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]);static#n=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]);static#r=new Float32Array([1,1,1]);static#o=new Float32Array(3);static#l=new Float32Array(3);static#c=new Float32Array(3);static#h=(24/116)**3/8;constructor(e,t,i,a){if(super("CalRGB",3),!e)throw new yi("WhitePoint missing - required for color space CalRGB");const[s,n,r]=this.whitePoint=e,[o,l,c]=this.blackPoint=t||new Float32Array(3);if([this.GR,this.GG,this.GB]=i||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]),s<0||r<0||1!==n)throw new yi(`Invalid WhitePoint components for ${this.name}, no fallback available`);(o<0||l<0||c<0)&&(info$1(`Invalid BlackPoint for ${this.name} [${o}, ${l}, ${c}], falling back to default.`),this.blackPoint=new Float32Array(3)),(this.GR<0||this.GG<0||this.GB<0)&&(info$1(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for ${this.name}, falling back to default.`),this.GR=this.GG=this.GB=1)}#u(e,t,i){i[0]=e[0]*t[0]+e[1]*t[1]+e[2]*t[2],i[1]=e[3]*t[0]+e[4]*t[1]+e[5]*t[2],i[2]=e[6]*t[0]+e[7]*t[1]+e[8]*t[2]}#d(e,t,i){i[0]=1*t[0]/e[0],i[1]=1*t[1]/e[1],i[2]=1*t[2]/e[2]}#g(e,t,i){i[0]=.95047*t[0]/e[0],i[1]=1*t[1]/e[1],i[2]=1.08883*t[2]/e[2]}#f(e){return e<=.0031308?MathClamp$1(12.92*e,0,1):e>=.99554525?1:MathClamp$1(1.055*e**(1/2.4)-.055,0,1)}#p(e){return e<0?-this.#p(-e):e>8?((e+16)/116)**3:e*CalRGBCS.#h}#m(e,t,i){if(0===e[0]&&0===e[1]&&0===e[2])return i[0]=t[0],i[1]=t[1],void(i[2]=t[2]);const a=this.#p(0),s=(1-a)/(1-this.#p(e[0])),n=1-s,r=(1-a)/(1-this.#p(e[1])),o=1-r,l=(1-a)/(1-this.#p(e[2])),c=1-l;i[0]=t[0]*s+n,i[1]=t[1]*r+o,i[2]=t[2]*l+c}#b(e,t,i){if(1===e[0]&&1===e[2])return i[0]=t[0],i[1]=t[1],void(i[2]=t[2]);const a=i;this.#u(CalRGBCS.#a,t,a);const s=CalRGBCS.#o;this.#d(e,a,s),this.#u(CalRGBCS.#s,s,i)}#y(e,t,i){const a=i;this.#u(CalRGBCS.#a,t,a);const s=CalRGBCS.#o;this.#g(e,a,s),this.#u(CalRGBCS.#s,s,i)}#i(e,t,i,a,s){const n=MathClamp$1(e[t]*s,0,1),r=MathClamp$1(e[t+1]*s,0,1),o=MathClamp$1(e[t+2]*s,0,1),l=1===n?1:n**this.GR,c=1===r?1:r**this.GG,h=1===o?1:o**this.GB,u=this.MXA*l+this.MXB*c+this.MXC*h,d=this.MYA*l+this.MYB*c+this.MYC*h,g=this.MZA*l+this.MZB*c+this.MZC*h,f=CalRGBCS.#l;f[0]=u,f[1]=d,f[2]=g;const p=CalRGBCS.#c;this.#b(this.whitePoint,f,p);const m=CalRGBCS.#l;this.#m(this.blackPoint,p,m);const b=CalRGBCS.#c;this.#y(CalRGBCS.#r,m,b);const y=CalRGBCS.#l;this.#u(CalRGBCS.#n,b,y),i[a]=255*this.#f(y[0]),i[a+1]=255*this.#f(y[1]),i[a+2]=255*this.#f(y[2])}getRgbItem(e,t,i,a){this.#i(e,t,i,a,1)}getRgbBuffer(e,t,i,a,s,n,r){const o=1/((1<<n)-1);for(let n=0;n<i;++n)this.#i(e,t,a,s,o),t+=3,s+=3+r}getOutputLength(e,t){return e*(3+t)/3|0}}class LabCS extends ColorSpace{constructor(e,t,i){if(super("Lab",3),!e)throw new yi("WhitePoint missing - required for color space Lab");if([this.XW,this.YW,this.ZW]=e,[this.amin,this.amax,this.bmin,this.bmax]=i||[-100,100,-100,100],[this.XB,this.YB,this.ZB]=t||[0,0,0],this.XW<0||this.ZW<0||1!==this.YW)throw new yi("Invalid WhitePoint components, no fallback available");(this.XB<0||this.YB<0||this.ZB<0)&&(info$1("Invalid BlackPoint, falling back to default"),this.XB=this.YB=this.ZB=0),(this.amin>this.amax||this.bmin>this.bmax)&&(info$1("Invalid Range, falling back to defaults"),this.amin=-100,this.amax=100,this.bmin=-100,this.bmax=100)}#w(e){return e>=6/29?e**3:108/841*(e-4/29)}#A(e,t,i,a){return i+e*(a-i)/t}#i(e,t,i,a,s){let n=e[t],r=e[t+1],o=e[t+2];!1!==i&&(n=this.#A(n,i,0,100),r=this.#A(r,i,this.amin,this.amax),o=this.#A(o,i,this.bmin,this.bmax)),r>this.amax?r=this.amax:r<this.amin&&(r=this.amin),o>this.bmax?o=this.bmax:o<this.bmin&&(o=this.bmin);const l=(n+16)/116,c=l+r/500,h=l-o/200,u=this.XW*this.#w(c),d=this.YW*this.#w(l),g=this.ZW*this.#w(h);let f,p,m;this.ZW<1?(f=3.1339*u+-1.617*d+-.4906*g,p=-.9785*u+1.916*d+.0333*g,m=.072*u+-.229*d+1.4057*g):(f=3.2406*u+-1.5372*d+-.4986*g,p=-.9689*u+1.8758*d+.0415*g,m=.0557*u+-.204*d+1.057*g),a[s]=255*Math.sqrt(f),a[s+1]=255*Math.sqrt(p),a[s+2]=255*Math.sqrt(m)}getRgbItem(e,t,i,a){this.#i(e,t,!1,i,a)}getRgbBuffer(e,t,i,a,s,n,r){const o=(1<<n)-1;for(let n=0;n<i;n++)this.#i(e,t,o,a,s),t+=3,s+=3+r}getOutputLength(e,t){return e*(3+t)/3|0}isDefaultDecode(e,t){return!0}get usesZeroToOneRange(){return shadow$1(this,"usesZeroToOneRange",!1)}}function fetchSync(e){const t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),t.response}class IccColorSpace extends ColorSpace{#x;#S;static#v=!0;static#C=null;static#k=new FinalizationRegistry((e=>{!function(e){Bi.qcms_drop_transformer(e)}(e)}));constructor(e,t,i){if(!IccColorSpace.isUsable)throw new Error("No ICC color space support");let a;switch(super(t,i),i){case 1:a=qi.Gray8,this.#S=(e,t)=>function(e,t){Bi.qcms_convert_one(e,t)}(this.#x,255*e[t]);break;case 3:a=qi.RGB8,this.#S=(e,t)=>{return i=this.#x,a=255*e[t],s=255*e[t+1],n=255*e[t+2],void Bi.qcms_convert_three(i,a,s,n);var i,a,s,n};break;case 4:a=qi.CMYK,this.#S=(e,t)=>{return i=this.#x,a=255*e[t],s=255*e[t+1],n=255*e[t+2],r=255*e[t+3],void Bi.qcms_convert_four(i,a,s,n,r);var i,a,s,n,r};break;default:throw new Error(`Unsupported number of components: ${i}`)}if(this.#x=function(e,t,i){const a=passArray8ToWasm0(e,Bi.__wbindgen_malloc),s=Hi;return Bi.qcms_transformer_from_memory(a,s,t,i)>>>0}(e,a,Xi.Perceptual),!this.#x)throw new Error("Failed to create ICC color space");IccColorSpace.#k.register(this,this.#x)}getRgbItem(e,t,i,a){QCMS._destBuffer=i.subarray(a,a+3),this.#S(e,t),QCMS._destBuffer=null}getRgbBuffer(e,t,i,a,s,n,r){if(e=e.subarray(t,t+i*this.numComps),8!==n){const t=255/((1<<n)-1);for(let i=0,a=e.length;i<a;i++)e[i]*=t}QCMS._mustAddAlpha=r&&a.buffer===e.buffer,QCMS._destBuffer=a.subarray(s,s+i*(3+r)),function(e,t){const i=passArray8ToWasm0(t,Bi.__wbindgen_malloc),a=Hi;Bi.qcms_convert_array(e,i,a)}(this.#x,e),QCMS._mustAddAlpha=!1,QCMS._destBuffer=null}getOutputLength(e,t){return e/this.numComps*(3+t)|0}static setOptions({useWasm:e,useWorkerFetch:t,wasmUrl:i}){t?(this.#v=e,this.#C=i):this.#v=!1}static get isUsable(){let e=!1;if(this.#v)if(this.#C)try{this._module=QCMS._module=initSync({module:fetchSync(`${this.#C}qcms_bg.wasm`)}),e=!!this._module}catch(e){warn$1(`ICCBased color space: "${e}".`)}else warn$1("No ICC color space support due to missing `wasmUrl` API option");return shadow$1(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;return IccColorSpace.isUsable&&(this.#T?e=!0:warn$1("No CMYK ICC profile support due to missing `iccUrl` API option")),shadow$1(this,"isUsable",e)}}class Stream extends BaseStream{constructor(e,t,i,a){super(),this.bytes=e instanceof Uint8Array?e:new Uint8Array(e),this.start=t||0,this.pos=this.start,this.end=t+i||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.bytes,i=this.pos,a=this.end;if(!e)return t.subarray(i,a);let s=i+e;return s>a&&(s=a),this.pos=s,t.subarray(i,s)}getByteRange(e,t){return e<0&&(e=0),t>this.end&&(t=this.end),this.bytes.subarray(e,t)}reset(){this.pos=this.start}moveStart(){this.start=this.pos}makeSubStream(e,t,i=null){return new Stream(this.bytes.buffer,e,t,i)}}class StringStream extends Stream{constructor(e){super(stringToBytes$1(e))}}class NullStream extends Stream{constructor(){super(new Uint8Array(0))}}class ChunkedStream extends Stream{constructor(e,t,i){super(new Uint8Array(e),0,e,null),this.chunkSize=t,this._loadedChunks=new Set,this.numChunks=Math.ceil(e/t),this.manager=i,this.progressiveDataLength=0,this.lastSuccessfulEnsureByteChunk=-1}getMissingChunks(){const e=[];for(let t=0,i=this.numChunks;t<i;++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 i=this.chunkSize;if(e%i!=0)throw new Error(`Bad begin offset: ${e}`);const a=e+t.byteLength;if(a%i!=0&&a!==this.bytes.length)throw new Error(`Bad end offset: ${a}`);this.bytes.set(new Uint8Array(t),e);const s=Math.floor(e/i),n=Math.floor((a-1)/i)+1;for(let e=s;e<n;++e)this._loadedChunks.add(e)}onReceiveProgressiveData(e){let t=this.progressiveDataLength;const i=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=i;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 i=Math.floor(e/this.chunkSize);if(i>this.numChunks)return;const a=Math.min(Math.floor((t-1)/this.chunkSize)+1,this.numChunks);for(let s=i;s<a;++s)if(!this._loadedChunks.has(s))throw new MissingDataException(e,t)}nextEmptyChunk(e){const t=this.numChunks;for(let i=0;i<t;++i){const a=(e+i)%t;if(!this._loadedChunks.has(a))return a}return null}hasChunk(e){return this._loadedChunks.has(e)}getByte(){const e=this.pos;return e>=this.end?-1:(e>=this.progressiveDataLength&&this.ensureByte(e),this.bytes[this.pos++])}getBytes(e){const t=this.bytes,i=this.pos,a=this.end;if(!e)return a>this.progressiveDataLength&&this.ensureRange(i,a),t.subarray(i,a);let s=i+e;return s>a&&(s=a),s>this.progressiveDataLength&&this.ensureRange(i,s),this.pos=s,t.subarray(i,s)}getByteRange(e,t){return e<0&&(e=0),t>this.end&&(t=this.end),t>this.progressiveDataLength&&this.ensureRange(e,t),this.bytes.subarray(e,t)}makeSubStream(e,t,i=null){function ChunkedStreamSubstream(){}t?e+t>this.progressiveDataLength&&this.ensureRange(e,e+t):e>=this.progressiveDataLength&&this.ensureByte(e),ChunkedStreamSubstream.prototype=Object.create(this),ChunkedStreamSubstream.prototype.getMissingChunks=function(){const e=this.chunkSize,t=Math.floor(this.start/e),i=Math.floor((this.end-1)/e)+1,a=[];for(let e=t;e<i;++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;return a.pos=a.start=e,a.end=e+t||this.end,a.dict=i,a}getBaseStreams(){return[this]}}class ChunkedStreamManager{constructor(e,t){this.length=t.length,this.chunkSize=t.rangeChunkSize,this.stream=new ChunkedStream(this.length,this.chunkSize,this),this.pdfNetworkStream=e,this.disableAutoFetch=t.disableAutoFetch,this.msgHandler=t.msgHandler,this.currRequestId=0,this._chunksNeededByRequest=new Map,this._requestsByChunk=new Map,this._promisesByRequest=new Map,this.progressiveDataLength=0,this.aborted=!1,this._loadedStreamCapability=Promise.withResolvers()}sendRequest(e,t){const i=this.pdfNetworkStream.getRangeReader(e,t);i.isStreamingSupported||(i.onProgress=this.onProgress.bind(this));let a=[],s=0;return new Promise(((e,t)=>{const readChunk=({value:n,done:r})=>{try{if(r){const t=arrayBuffersToBytes(a);return a=null,void e(t)}s+=n.byteLength,i.isStreamingSupported&&this.onProgress({loaded:s}),a.push(n),i.read().then(readChunk,t)}catch(e){t(e)}};i.read().then(readChunk,t)})).then((t=>{this.aborted||this.onReceiveData({chunk:t,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++,i=new Set;this._chunksNeededByRequest.set(t,i);for(const t of e)this.stream.hasChunk(t)||i.add(t);if(0===i.size)return Promise.resolve();const a=Promise.withResolvers();this._promisesByRequest.set(t,a);const s=[];for(const e of i){let i=this._requestsByChunk.get(e);i||(i=[],this._requestsByChunk.set(e,i),s.push(e)),i.push(t)}if(s.length>0){const e=this.groupChunks(s);for(const t of e){const e=t.beginChunk*this.chunkSize,i=Math.min(t.endChunk*this.chunkSize,this.length);this.sendRequest(e,i).catch(a.reject)}}return a.promise.catch((e=>{if(!this.aborted)throw e}))}getStream(){return this.stream}requestRange(e,t){t=Math.min(t,this.length);const i=this.getBeginChunk(e),a=this.getEndChunk(t),s=[];for(let e=i;e<a;++e)s.push(e);return this._requestChunks(s)}requestRanges(e=[]){const t=[];for(const i of e){const e=this.getBeginChunk(i.begin),a=this.getEndChunk(i.end);for(let i=e;i<a;++i)t.includes(i)||t.push(i)}return t.sort(((e,t)=>e-t)),this._requestChunks(t)}groupChunks(e){const t=[];let i=-1,a=-1;for(let s=0,n=e.length;s<n;++s){const n=e[s];i<0&&(i=n),a>=0&&a+1!==n&&(t.push({beginChunk:i,endChunk:a+1}),i=n),s+1===e.length&&t.push({beginChunk:i,endChunk:n+1}),a=n}return t}onProgress(e){this.msgHandler.send("DocProgress",{loaded:this.stream.numChunksLoaded*this.chunkSize+e.loaded,total:this.length})}onReceiveData(e){const t=e.chunk,i=void 0===e.begin,a=i?this.progressiveDataLength:e.begin,s=a+t.byteLength,n=Math.floor(a/this.chunkSize),r=s<this.length?Math.floor(s/this.chunkSize):Math.ceil(s/this.chunkSize);i?(this.stream.onReceiveProgressiveData(t),this.progressiveDataLength=s):this.stream.onReceiveData(a,t),this.stream.isDataLoaded&&this._loadedStreamCapability.resolve(this.stream);const o=[];for(let e=n;e<r;++e){const t=this._requestsByChunk.get(e);if(t){this._requestsByChunk.delete(e);for(const i of t){const t=this._chunksNeededByRequest.get(i);t.has(e)&&t.delete(e),t.size>0||o.push(i)}}}if(!this.disableAutoFetch&&0===this._requestsByChunk.size){let e;if(1===this.stream.numChunksLoaded){const t=this.stream.numChunks-1;this.stream.hasChunk(t)||(e=t)}else e=this.stream.nextEmptyChunk(r);Number.isInteger(e)&&this._requestChunks([e])}for(const e of o){const t=this._promisesByRequest.get(e);this._promisesByRequest.delete(e),t.resolve()}this.msgHandler.send("DocProgress",{loaded:this.stream.numChunksLoaded*this.chunkSize,total:this.length})}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.pdfNetworkStream?.cancelAllRequests(e);for(const t of this._promisesByRequest.values())t.reject(e)}}function convertToRGBA(e){switch(e.kind){case v:return convertBlackAndWhiteToRGBA$1(e);case C:return function({src:e,srcPos:t=0,dest:i,destPos:a=0,width:s,height:n}){let r=0;const o=s*n*3,l=o>>2,c=new Uint32Array(e.buffer,t,l);if(FeatureTest.isLittleEndian){for(;r<l-2;r+=3,a+=4){const e=c[r],t=c[r+1],s=c[r+2];i[a]=4278190080|e,i[a+1]=e>>>24|t<<8|4278190080,i[a+2]=t>>>16|s<<16|4278190080,i[a+3]=s>>>8|4278190080}for(let s=4*r,n=t+o;s<n;s+=3)i[a++]=e[s]|e[s+1]<<8|e[s+2]<<16|4278190080}else{for(;r<l-2;r+=3,a+=4){const e=c[r],t=c[r+1],s=c[r+2];i[a]=255|e,i[a+1]=e<<24|t>>>8|255,i[a+2]=t<<16|s>>>16|255,i[a+3]=s<<8|255}for(let s=4*r,n=t+o;s<n;s+=3)i[a++]=e[s]<<24|e[s+1]<<16|e[s+2]<<8|255}return{srcPos:t+o,destPos:a}}(e)}return null}function convertBlackAndWhiteToRGBA$1({src:e,srcPos:t=0,dest:i,width:a,height:s,nonBlackColor:n=4294967295,inverseDecode:r=!1}){const o=FeatureTest.isLittleEndian?4278190080:255,[l,c]=r?[n,o]:[o,n],h=a>>3,u=7&a,d=e.length;i=new Uint32Array(i.buffer);let g=0;for(let a=0;a<s;a++){for(const a=t+h;t<a;t++){const a=t<d?e[t]:255;i[g++]=128&a?c:l,i[g++]=64&a?c:l,i[g++]=32&a?c:l,i[g++]=16&a?c:l,i[g++]=8&a?c:l,i[g++]=4&a?c:l,i[g++]=2&a?c:l,i[g++]=1&a?c:l}if(0===u)continue;const a=t<d?e[t++]:255;for(let e=0;e<u;e++)i[g++]=a&1<<7-e?c:l}return{srcPos:t,destPos:g}}class ImageResizer{static#F=2048;static#I=FeatureTest.isImageDecoderSupported;constructor(e,t){this._imgData=e,this._isMask=t}static get canUseImageDecoder(){return shadow$1(this,"canUseImageDecoder",this.#I?ImageDecoder.isTypeSupported("image/bmp"):Promise.resolve(!1))}static needsToBeResized(e,t){if(e<=this.#F&&t<=this.#F)return!1;const{MAX_DIM:i}=this;if(e>i||t>i)return!0;const a=e*t;if(this._hasMaxArea)return a>this.MAX_AREA;if(a<this.#F**2)return!1;if(this._areGoodDims(e,t))return this.#F=Math.max(this.#F,Math.floor(Math.sqrt(e*t))),!1;this.#F=this._guessMax(this.#F,i,128,0);return a>(this.MAX_AREA=this.#F**2)}static get MAX_DIM(){return shadow$1(this,"MAX_DIM",this._guessMax(2048,65537,0,1))}static get MAX_AREA(){return this._hasMaxArea=!0,shadow$1(this,"MAX_AREA",this._guessMax(this.#F,this.MAX_DIM,128,0)**2)}static set MAX_AREA(e){e>=0&&(this._hasMaxArea=!0,shadow$1(this,"MAX_AREA",e))}static setOptions({canvasMaxAreaInBytes:e=-1,isImageDecoderSupported:t=!1}){this._hasMaxArea||(this.MAX_AREA=e>>2),this.#I=t}static _areGoodDims(e,t){try{const i=new OffscreenCanvas(e,t),a=i.getContext("2d");a.fillRect(0,0,1,1);const s=a.getImageData(0,0,1,1).data[3];return i.width=i.height=1,0!==s}catch{return!1}}static _guessMax(e,t,i,a){for(;e+i+1<t;){const i=Math.floor((e+t)/2),s=a||i;this._areGoodDims(i,s)?e=i:t=i}return e}static async createImage(e,t=!1){return new ImageResizer(e,t)._createImage()}async _createImage(){const{_imgData:e}=this,{width:t,height:i}=e;if(t*i*4>Di){const e=this.#M();if(e)return e}const a=this._encodeBMP();let s,n;await ImageResizer.canUseImageDecoder?(s=new ImageDecoder({data:a,type:"image/bmp",preferAnimation:!1,transfer:[a.buffer]}),n=s.decode().catch((e=>(warn$1(`BMP image decoding failed: ${e}`),createImageBitmap(new Blob([this._encodeBMP().buffer],{type:"image/bmp"}))))).finally((()=>{s.close()}))):n=createImageBitmap(new Blob([a.buffer],{type:"image/bmp"}));const{MAX_AREA:r,MAX_DIM:o}=ImageResizer,l=Math.max(t/o,i/o,Math.sqrt(t*i/r)),c=Math.max(l,2),h=Math.round(10*(l+1.25))/10/c,u=Math.floor(Math.log2(h)),d=new Array(u+2).fill(2);d[0]=c,d.splice(-1,1