/** * @licstart The following is the entire license notice for the * Javascript code in this page * * Copyright 2020 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 */ !function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf.worker",[],t):"object"==typeof exports?exports["pdfjs-dist/build/pdf.worker"]=t():e["pdfjs-dist/build/pdf.worker"]=e.pdfjsWorker=t()}(this,(function(){return function(e){var t={};function __w_pdfjs_require__(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};e[r].call(a.exports,a,a.exports,__w_pdfjs_require__);a.l=!0;return a.exports}__w_pdfjs_require__.m=e;__w_pdfjs_require__.c=t;__w_pdfjs_require__.d=function(e,t,r){__w_pdfjs_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})};__w_pdfjs_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});Object.defineProperty(e,"__esModule",{value:!0})};__w_pdfjs_require__.t=function(e,t){1&t&&(e=__w_pdfjs_require__(e));if(8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);__w_pdfjs_require__.r(r);Object.defineProperty(r,"default",{enumerable:!0,value:e});if(2&t&&"string"!=typeof e)for(var a in e)__w_pdfjs_require__.d(r,a,function(t){return e[t]}.bind(null,a));return r};__w_pdfjs_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};__w_pdfjs_require__.d(t,"a",t);return t};__w_pdfjs_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};__w_pdfjs_require__.p="";return __w_pdfjs_require__(__w_pdfjs_require__.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});Object.defineProperty(t,"WorkerMessageHandler",{enumerable:!0,get:function(){return a.WorkerMessageHandler}});var a=r(1)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.WorkerMessageHandler=t.WorkerTask=void 0;var a=r(2),i=r(5),n=r(6),s=r(27),o=r(4),c=r(46),l=r(47),h=r(8);class WorkerTask{constructor(e){this.name=e;this.terminated=!1;this._capability=(0,a.createPromiseCapability)()}get finished(){return this._capability.promise}finish(){this._capability.resolve()}terminate(){this.terminated=!0}ensureNotTerminated(){if(this.terminated)throw new Error("Worker task was terminated")}}t.WorkerTask=WorkerTask;class WorkerMessageHandler{static setup(e,t){var r=!1;e.on("test",(function wphSetupTest(t){if(r)return;r=!0;if(!(t instanceof Uint8Array)){e.send("test",null);return}const a=255===t[0];e.postMessageTransfers=a;e.send("test",{supportTransfers:a})}));e.on("configure",(function wphConfigure(e){(0,a.setVerbosityLevel)(e.verbosity)}));e.on("GetDocRequest",(function wphSetupDoc(e){return WorkerMessageHandler.createDocumentHandler(e,t)}))}static createDocumentHandler(e,t){var r,o=!1,u=null,d=[];const f=(0,a.getVerbosityLevel)(),g=e.apiVersion;if("2.6.347"!==g)throw new Error(`The API version "${g}" does not match the Worker version "2.6.347".`);const m=[];for(const e in[])m.push(e);if(m.length)throw new Error("The `Array.prototype` contains unexpected enumerable properties: "+m.join(", ")+"; thus breaking e.g. `for...in` iteration of `Array`s.");if("undefined"==typeof ReadableStream||void 0===Promise.allSettled)throw new Error("The browser/environment lacks native support for critical functionality used by the PDF.js library (e.g. `ReadableStream` and/or `Promise.allSettled`); please use an ES5-compatible build instead.");var p=e.docId,b=e.docBaseUrl,y=e.docId+"_worker",v=new c.MessageHandler(y,p,t);v.postMessageTransfers=e.postMessageTransfers;function ensureNotTerminated(){if(o)throw new Error("Worker was terminated")}function startWorkerTask(e){d.push(e)}function finishWorkerTask(e){e.finish();var t=d.indexOf(e);d.splice(t,1)}async function loadDocument(e){await r.ensureDoc("checkHeader");await r.ensureDoc("parseStartXRef");await r.ensureDoc("parse",[e]);e||await r.ensureDoc("checkFirstPage");const[t,a]=await Promise.all([r.ensureDoc("numPages"),r.ensureDoc("fingerprint")]);return{numPages:t,fingerprint:a}}function getPdfManager(e,t){var r=(0,a.createPromiseCapability)();let i;var s=e.source;if(s.data){try{i=new n.LocalPdfManager(p,s.data,s.password,t,b);r.resolve(i)}catch(e){r.reject(e)}return r.promise}var o,c=[];try{o=new l.PDFWorkerStream(v)}catch(e){r.reject(e);return r.promise}var h=o.getFullReader();h.headersReady.then((function(){if(h.isRangeSupported){var e=s.disableAutoFetch||h.isStreamingSupported;i=new n.NetworkPdfManager(p,o,{msgHandler:v,password:s.password,length:h.contentLength,disableAutoFetch:e,rangeChunkSize:s.rangeChunkSize},t,b);for(let e=0;e{let r=[];for(const e of t)r=e.filter(e=>null!==e).reduce((e,t)=>e.concat(t),r);if(0===r.length)return e.bytes;const n=o.xref;let c=Object.create(null);if(n.trailer){const e=Object.create(null),t=n.trailer.get("Info")||null;t&&t.forEach((t,r)=>{(0,a.isString)(t)&&(0,a.isString)(r)&&(e[t]=(0,a.stringToPDFString)(r))});c={rootRef:n.trailer.getRaw("Root")||null,encrypt:n.trailer.getRaw("Encrypt")||null,newRef:n.getNewRef(),infoRef:n.trailer.getRaw("Info")||null,info:e,fileIds:n.trailer.getRaw("ID")||null,startXRef:o.startXRef,filename:i}}n.resetNewRef();return(0,s.incrementalUpdate)(e.bytes,c,r)})}));v.on("GetOperatorList",(function wphSetupRenderPage(e,t){var i=e.pageIndex;r.getPage(i).then((function(r){var n=new WorkerTask("GetOperatorList: page "+i);startWorkerTask(n);const s=f>=a.VerbosityLevel.INFOS?Date.now():0;r.getOperatorList({handler:v,sink:t,task:n,intent:e.intent,renderInteractiveForms:e.renderInteractiveForms,annotationStorage:e.annotationStorage}).then((function(e){finishWorkerTask(n);s&&(0,a.info)(`page=${i+1} - getOperatorList: time=${Date.now()-s}ms, len=${e.length}`);t.close()}),(function(e){finishWorkerTask(n);if(!n.terminated){v.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorOperatorList});t.error(e)}}))}))}),this);v.on("GetTextContent",(function wphExtractText(e,t){var i=e.pageIndex;t.onPull=function(e){};t.onCancel=function(e){};r.getPage(i).then((function(r){var n=new WorkerTask("GetTextContent: page "+i);startWorkerTask(n);const s=f>=a.VerbosityLevel.INFOS?Date.now():0;r.extractTextContent({handler:v,task:n,sink:t,normalizeWhitespace:e.normalizeWhitespace,combineTextItems:e.combineTextItems}).then((function(){finishWorkerTask(n);s&&(0,a.info)(`page=${i+1} - getTextContent: time=`+(Date.now()-s)+"ms");t.close()}),(function(e){finishWorkerTask(n);n.terminated||t.error(e)}))}))}));v.on("FontFallback",(function(e){return r.fontFallback(e.id,v)}));v.on("Cleanup",(function wphCleanup(e){return r.cleanup(!0)}));v.on("Terminate",(function wphTerminate(e){o=!0;const t=[];if(r){r.terminate(new a.AbortException("Worker was terminated."));const e=r.cleanup();t.push(e);r=null}else(0,i.clearPrimitiveCaches)();u&&u(new a.AbortException("Worker was terminated."));d.forEach((function(e){t.push(e.finished);e.terminate()}));return Promise.all(t).then((function(){v.destroy();v=null}))}));v.on("Ready",(function wphReady(t){!function setupDoc(e){function onSuccess(e){ensureNotTerminated();v.send("GetDoc",{pdfInfo:e})}function onFailure(e){ensureNotTerminated();if(e instanceof a.PasswordException){var t=new WorkerTask("PasswordException: response "+e.code);startWorkerTask(t);v.sendWithPromise("PasswordRequest",e).then((function({password:e}){finishWorkerTask(t);r.updatePassword(e);pdfManagerReady()})).catch((function(){finishWorkerTask(t);v.send("DocException",e)}))}else e instanceof a.InvalidPDFException||e instanceof a.MissingPDFException||e instanceof a.UnexpectedResponseException||e instanceof a.UnknownErrorException?v.send("DocException",e):v.send("DocException",new a.UnknownErrorException(e.message,e.toString()))}function pdfManagerReady(){ensureNotTerminated();loadDocument(!1).then(onSuccess,(function(e){ensureNotTerminated();if(e instanceof h.XRefParseException){r.requestLoadedStream();r.onLoadedStream().then((function(){ensureNotTerminated();loadDocument(!0).then(onSuccess,onFailure)}))}else onFailure(e)}))}ensureNotTerminated();getPdfManager(e,{maxImageSize:e.maxImageSize,disableFontFace:e.disableFontFace,ignoreErrors:e.ignoreErrors,isEvalSupported:e.isEvalSupported,fontExtraProperties:e.fontExtraProperties}).then((function(e){if(o){e.terminate(new a.AbortException("Worker was terminated."));throw new Error("Worker was terminated")}(r=e).onLoadedStream().then((function(e){v.send("DataLoaded",{length:e.bytes.byteLength})}))})).then(pdfManagerReady,onFailure)}(e);e=null}));return y}static initializeFromPort(e){var t=new c.MessageHandler("worker","main",e);WorkerMessageHandler.setup(t,e);t.send("ready",null)}}t.WorkerMessageHandler=WorkerMessageHandler;"undefined"==typeof window&&!o.isNodeJS&&"undefined"!=typeof self&&function isMessagePort(e){return"function"==typeof e.postMessage&&"onmessage"in e}(self)&&WorkerMessageHandler.initializeFromPort(self)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.arrayByteLength=arrayByteLength;t.arraysToBytes=function arraysToBytes(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let r=0;for(let a=0;at});e.promise=new Promise((function(r,a){e.resolve=function(e){t=!0;r(e)};e.reject=function(e){t=!0;a(e)}}));return e};t.escapeString=function escapeString(e){return e.replace(/([\(\)\\])/g,"\\$1")};t.getModificationDate=function getModificationDate(e=new Date(Date.now())){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),(e.getUTCDate()+1).toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")};t.getVerbosityLevel=function getVerbosityLevel(){return i};t.info=function info(e){i>=a.INFOS&&console.log("Info: "+e)};t.isArrayBuffer=function isArrayBuffer(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength};t.isArrayEqual=function isArrayEqual(e,t){if(e.length!==t.length)return!1;return e.every((function(e,r){return e===t[r]}))};t.isBool=function isBool(e){return"boolean"==typeof e};t.isNum=function isNum(e){return"number"==typeof e};t.isString=function isString(e){return"string"==typeof e};t.isSameOrigin=function isSameOrigin(e,t){let r;try{r=new URL(e);if(!r.origin||"null"===r.origin)return!1}catch(e){return!1}const a=new URL(t,r);return r.origin===a.origin};t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e,t){if(!e)return null;try{const r=t?new URL(e,t):new URL(e);if(function _isValidProtocol(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r))return r}catch(e){}return null};t.removeNullCharacters=function removeNullCharacters(e){if("string"!=typeof e){warn("The argument for removeNullCharacters must be a string.");return e}return e.replace(s,"")};t.setVerbosityLevel=function setVerbosityLevel(e){Number.isInteger(e)&&(i=e)};t.shadow=shadow;t.string32=function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)};t.stringToBytes=stringToBytes;t.stringToPDFString=function stringToPDFString(e){const t=e.length,r=[];if("þ"===e[0]&&"ÿ"===e[1])for(let a=2;a=a.WARNINGS&&console.log("Warning: "+e)}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function shadow(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1});return r}const n=function BaseExceptionClosure(){function BaseException(e){this.constructor===BaseException&&unreachable("Cannot initialize BaseException.");this.message=e;this.name=this.constructor.name}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();t.BaseException=n;t.PasswordException=class PasswordException extends n{constructor(e,t){super(e);this.code=t}};t.UnknownErrorException=class UnknownErrorException extends n{constructor(e,t){super(e);this.details=t}};t.InvalidPDFException=class InvalidPDFException extends n{};t.MissingPDFException=class MissingPDFException extends n{};t.UnexpectedResponseException=class UnexpectedResponseException extends n{constructor(e,t){super(e);this.status=t}};t.FormatError=class FormatError extends n{};t.AbortException=class AbortException extends n{};const s=/\x00/g;function stringToBytes(e){assert("string"==typeof e,"Invalid argument for stringToBytes");const t=e.length,r=new Uint8Array(t);for(let a=0;ae[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){function compare(e,t){return e-t}const r=[e[0],e[2],t[0],t[2]].sort(compare),a=[e[1],e[3],t[1],t[3]].sort(compare),i=[];e=Util.normalizeRect(e);t=Util.normalizeRect(t);if(!(r[0]===e[0]&&r[1]===t[0]||r[0]===t[0]&&r[1]===e[0]))return null;i[0]=r[1];i[2]=r[2];if(!(a[0]===e[1]&&a[1]===t[1]||a[0]===t[1]&&a[1]===e[1]))return null;i[1]=a[1];i[3]=a[2];return i}}t.Util=Util;const h=[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];const u=function createObjectURLClosure(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function createObjectURL(t,r,a=!1){if(!a&&URL.createObjectURL){const e=new Blob([t],{type:r});return URL.createObjectURL(e)}let i=`data:${r};base64,`;for(let r=0,a=t.length;r>2]+e[(3&n)<<4|s>>4]+e[r+1>6:64]+e[r+20?a:Dict.empty}const i=new Map;for(const e of t)if(e instanceof Dict)for(const[t,r]of Object.entries(e._map)){let e=i.get(t);if(void 0===e){e=[];i.set(t,e)}e.push(r)}for(const[t,r]of i){if(1===r.length||!(r[0]instanceof Dict)){a._map[t]=r[0];continue}const i=new Dict(e);for(const e of r)if(e instanceof Dict)for(const[t,r]of Object.entries(e._map))void 0===i._map[t]&&(i._map[t]=r);i.size>0&&(a._map[t]=i)}i.clear();return a.size>0?a:Dict.empty};return Dict}();t.Dict=s;var o=function RefClosure(){let e=Object.create(null);function Ref(e,t){this.num=e;this.gen=t}Ref.prototype={toString:function Ref_toString(){return 0===this.gen?this.num+"R":`${this.num}R${this.gen}`}};Ref.get=function(t,r){const a=0===r?t+"R":`${t}R${r}`,i=e[a];return i||(e[a]=new Ref(t,r))};Ref._clearCache=function(){e=Object.create(null)};return Ref}();t.Ref=o;t.RefSet=class RefSet{constructor(){this._set=new Set}has(e){return this._set.has(e.toString())}put(e){this._set.add(e.toString())}remove(e){this._set.delete(e.toString())}};t.RefSetCache=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))}forEach(e){for(const t of this._map.values())e(t)}clear(){this._map.clear()}};function isName(e,t){return e instanceof i&&(void 0===t||e.name===t)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.NetworkPdfManager=t.LocalPdfManager=void 0;var a=r(2),i=r(7),n=r(8),s=r(9),o=r(12);class BasePdfManager{constructor(){this.constructor===BasePdfManager&&(0,a.unreachable)("Cannot initialize BasePdfManager.")}get docId(){return this._docId}get password(){return this._password}get docBaseUrl(){let e=null;if(this._docBaseUrl){const t=(0,a.createValidAbsoluteUrl)(this._docBaseUrl);t?e=t.href:(0,a.warn)(`Invalid absolute docBaseUrl: "${this._docBaseUrl}".`)}return(0,a.shadow)(this,"docBaseUrl",e)}onLoadedStream(){(0,a.unreachable)("Abstract method `onLoadedStream` called")}ensureDoc(e,t){return this.ensure(this.pdfDocument,e,t)}ensureXRef(e,t){return this.ensure(this.pdfDocument.xref,e,t)}ensureCatalog(e,t){return this.ensure(this.pdfDocument.catalog,e,t)}getPage(e){return this.pdfDocument.getPage(e)}fontFallback(e,t){return this.pdfDocument.fontFallback(e,t)}cleanup(e=!1){return this.pdfDocument.cleanup(e)}async ensure(e,t,r){(0,a.unreachable)("Abstract method `ensure` called")}requestRange(e,t){(0,a.unreachable)("Abstract method `requestRange` called")}requestLoadedStream(){(0,a.unreachable)("Abstract method `requestLoadedStream` called")}sendProgressiveData(e){(0,a.unreachable)("Abstract method `sendProgressiveData` called")}updatePassword(e){this._password=e}terminate(e){(0,a.unreachable)("Abstract method `terminate` called")}}t.LocalPdfManager=class LocalPdfManager extends BasePdfManager{constructor(e,t,r,a,i){super();this._docId=e;this._password=r;this._docBaseUrl=i;this.evaluatorOptions=a;const n=new o.Stream(t);this.pdfDocument=new s.PDFDocument(this,n);this._loadedStreamPromise=Promise.resolve(n)}async ensure(e,t,r){const a=e[t];return"function"==typeof a?a.apply(e,r):a}requestRange(e,t){return Promise.resolve()}requestLoadedStream(){}onLoadedStream(){return this._loadedStreamPromise}terminate(e){}};t.NetworkPdfManager=class NetworkPdfManager extends BasePdfManager{constructor(e,t,r,a,n){super();this._docId=e;this._password=r.password;this._docBaseUrl=n;this.msgHandler=r.msgHandler;this.evaluatorOptions=a;this.streamManager=new i.ChunkedStreamManager(t,{msgHandler:r.msgHandler,length:r.length,disableAutoFetch:r.disableAutoFetch,rangeChunkSize:r.rangeChunkSize});this.pdfDocument=new s.PDFDocument(this,this.streamManager.getStream())}async ensure(e,t,r){try{const a=e[t];return"function"==typeof a?a.apply(e,r):a}catch(a){if(!(a instanceof n.MissingDataException))throw a;await this.requestRange(a.begin,a.end);return this.ensure(e,t,r)}}requestRange(e,t){return this.streamManager.requestRange(e,t)}requestLoadedStream(){this.streamManager.requestAllChunks()}sendProgressiveData(e){this.streamManager.onReceiveData({chunk:e})}onLoadedStream(){return this.streamManager.onLoadedStream()}terminate(e){this.streamManager.abort(e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ChunkedStreamManager=t.ChunkedStream=void 0;var a=r(2),i=r(8);class ChunkedStream{constructor(e,t,r){this.bytes=new Uint8Array(e);this.start=0;this.pos=0;this.end=e;this.chunkSize=t;this._loadedChunks=new Set;this.numChunks=Math.ceil(e/t);this.manager=r;this.progressiveDataLength=0;this.lastSuccessfulEnsureByteChunk=-1}getMissingChunks(){const e=[];for(let t=0,r=this.numChunks;t=this.end?this.numChunks:Math.floor(t/this.chunkSize);for(let e=r;e=t)return;if(t<=this.progressiveDataLength)return;const r=this.chunkSize,a=Math.floor(e/r),n=Math.floor((t-1)/r)+1;for(let r=a;r=this.end)return-1;e>=this.progressiveDataLength&&this.ensureByte(e);return this.bytes[this.pos++]}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()}getBytes(e,t=!1){const r=this.bytes,a=this.pos,i=this.end;if(!e){i>this.progressiveDataLength&&this.ensureRange(a,i);const e=r.subarray(a,i);return t?new Uint8ClampedArray(e):e}let n=a+e;n>i&&(n=i);n>this.progressiveDataLength&&this.ensureRange(a,n);this.pos=n;const s=r.subarray(a,n);return t?new Uint8ClampedArray(s):s}peekByte(){const e=this.getByte();-1!==e&&this.pos--;return e}peekBytes(e,t=!1){const r=this.getBytes(e,t);this.pos-=r.length;return r}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)}skip(e){e||(e=1);this.pos+=e}reset(){this.pos=this.start}moveStart(){this.start=this.pos}makeSubStream(e,t,r){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),r=Math.floor((this.end-1)/e)+1,a=[];for(let e=t;e{const readChunk=s=>{try{if(!s.done){const e=s.value;i.push(e);n+=(0,a.arrayByteLength)(e);r.isStreamingSupported&&this.onProgress({loaded:n});r.read().then(readChunk,t);return}const o=(0,a.arraysToBytes)(i);i=null;e(o)}catch(e){t(e)}};r.read().then(readChunk,t)}).then(t=>{this.aborted||this.onReceiveData({chunk:t,begin:e})})}requestAllChunks(){const e=this.stream.getMissingChunks();this._requestChunks(e);return this._loadedStreamCapability.promise}_requestChunks(e){const t=this.currRequestId++,r=new Set;this._chunksNeededByRequest.set(t,r);for(const t of e)this.stream.hasChunk(t)||r.add(t);if(0===r.size)return Promise.resolve();const i=(0,a.createPromiseCapability)();this._promisesByRequest.set(t,i);const n=[];for(const e of r){let r=this._requestsByChunk.get(e);if(!r){r=[];this._requestsByChunk.set(e,r);n.push(e)}r.push(t)}if(n.length>0){const e=this.groupChunks(n);for(const t of e){const e=t.beginChunk*this.chunkSize,r=Math.min(t.endChunk*this.chunkSize,this.length);this.sendRequest(e,r)}}return i.promise.catch(e=>{if(!this.aborted)throw e})}getStream(){return this.stream}requestRange(e,t){t=Math.min(t,this.length);const r=this.getBeginChunk(e),a=this.getEndChunk(t),i=[];for(let e=r;e=0&&a+1!==n){t.push({beginChunk:r,endChunk:a+1});r=n}i+1===e.length&&t.push({beginChunk:r,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,r=void 0===e.begin,a=r?this.progressiveDataLength:e.begin,i=a+t.byteLength,n=Math.floor(a/this.chunkSize),s=i0||o.push(r)}}}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(s);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&&this.pdfNetworkStream.cancelAllRequests(e);for(const t of this._promisesByRequest.values())t.reject(e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.getLookupTableFactory=function getLookupTableFactory(e){let t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}};t.getInheritableProperty=function getInheritableProperty({dict:e,key:t,getArray:r=!1,stopWhenFound:i=!0}){let n,s=0;for(;e;){const o=r?e.getArray(t):e.get(t);if(void 0!==o){if(i)return o;n||(n=[]);n.push(o)}if(++s>100){(0,a.warn)(`getInheritableProperty: maximum loop count exceeded for "${t}"`);break}e=e.get("Parent")}return n};t.toRomanNumerals=function toRomanNumerals(e,t=!1){(0,a.assert)(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const r=[];let n;for(;e>=1e3;){e-=1e3;r.push("M")}n=e/100|0;e%=100;r.push(i[n]);n=e/10|0;e%=10;r.push(i[10+n]);r.push(i[20+e]);const s=r.join("");return t?s.toLowerCase():s};t.log2=function log2(e){if(e<=0)return 0;return Math.ceil(Math.log2(e))};t.readInt8=function readInt8(e,t){return e[t]<<24>>24};t.readUint16=function readUint16(e,t){return e[t]<<8|e[t+1]};t.readUint32=function readUint32(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0};t.isWhiteSpace=function isWhiteSpace(e){return 32===e||9===e||13===e||10===e};t.XRefParseException=t.XRefEntryException=t.MissingDataException=void 0;var a=r(2);class MissingDataException extends a.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`);this.begin=e;this.end=t}}t.MissingDataException=MissingDataException;class XRefEntryException extends a.BaseException{}t.XRefEntryException=XRefEntryException;class XRefParseException extends a.BaseException{}t.XRefParseException=XRefParseException;const i=["","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(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.PDFDocument=t.Page=void 0;var a=r(2),i=r(10),n=r(5),s=r(8),o=r(12),c=r(25),l=r(22),h=r(11),u=r(26),d=r(28);const f=[0,0,612,792];function isAnnotationRenderable(e,t){return"display"===t&&e.viewable||"print"===t&&e.printable}class Page{constructor({pdfManager:e,xref:t,pageIndex:r,pageDict:a,ref:i,globalIdFactory:n,fontCache:s,builtInCMapCache:o,globalImageCache:c}){this.pdfManager=e;this.pageIndex=r;this.pageDict=a;this.xref=t;this.ref=i;this.fontCache=s;this.builtInCMapCache=o;this.globalImageCache=c;this.evaluatorOptions=e.evaluatorOptions;this.resourcesPromise=null;const l={obj:0};this._localIdFactory=class extends n{static createObjId(){return`p${r}_${++l.obj}`}}}_getInheritableProperty(e,t=!1){const r=(0,s.getInheritableProperty)({dict:this.pageDict,key:e,getArray:t,stopWhenFound:!1});return Array.isArray(r)?1!==r.length&&(0,n.isDict)(r[0])?n.Dict.merge({xref:this.xref,dictArray:r}):r[0]:r}get content(){return this.pageDict.get("Contents")}get resources(){return(0,a.shadow)(this,"resources",this._getInheritableProperty("Resources")||n.Dict.empty)}_getBoundingBox(e){const t=this._getInheritableProperty(e,!0);if(Array.isArray(t)&&4===t.length){if(t[2]-t[0]!=0&&t[3]-t[1]!=0)return t;(0,a.warn)(`Empty /${e} entry.`)}return null}get mediaBox(){return(0,a.shadow)(this,"mediaBox",this._getBoundingBox("MediaBox")||f)}get cropBox(){return(0,a.shadow)(this,"cropBox",this._getBoundingBox("CropBox")||this.mediaBox)}get userUnit(){let e=this.pageDict.get("UserUnit");(!(0,a.isNum)(e)||e<=0)&&(e=1);return(0,a.shadow)(this,"userUnit",e)}get view(){const{cropBox:e,mediaBox:t}=this;let r;if(e===t||(0,a.isArrayEqual)(e,t))r=t;else{const i=a.Util.intersect(e,t);i&&i[2]-i[0]!=0&&i[3]-i[1]!=0?r=i:(0,a.warn)("Empty /CropBox and /MediaBox intersection.")}return(0,a.shadow)(this,"view",r||t)}get rotate(){let e=this._getInheritableProperty("Rotate")||0;e%90!=0?e=0:e>=360?e%=360:e<0&&(e=(e%360+360)%360);return(0,a.shadow)(this,"rotate",e)}getContentStream(){const e=this.content;let t;if(Array.isArray(e)){const r=this.xref,a=[];for(const t of e)a.push(r.fetchIfRef(t));t=new o.StreamsSequenceStream(a)}else t=(0,n.isStream)(e)?e:new o.NullStream;return t}save(e,t,r){const i=new d.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions});return this._parsedAnnotations.then((function(e){const n=[];for(const s of e)isAnnotationRenderable(s,"print")&&n.push(s.save(i,t,r).catch((function(e){(0,a.warn)(`save - ignoring annotation data during "${t.name}" task: "${e}".`);return null})));return Promise.all(n)}))}loadResources(e){this.resourcesPromise||(this.resourcesPromise=this.pdfManager.ensure(this,"resources"));return this.resourcesPromise.then(()=>new i.ObjectLoader(this.resources,e,this.xref).load())}getOperatorList({handler:e,sink:t,task:r,intent:i,renderInteractiveForms:n,annotationStorage:s}){const o=this.pdfManager.ensure(this,"getContentStream"),c=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),l=new d.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions}),h=Promise.all([o,c]).then(([a])=>{const n=new u.OperatorList(i,t);e.send("StartRenderPage",{transparency:l.hasBlendModes(this.resources),pageIndex:this.pageIndex,intent:i});return l.getOperatorList({stream:a,task:r,resources:this.resources,operatorList:n}).then((function(){return n}))});return Promise.all([h,this._parsedAnnotations]).then((function([e,t]){if(0===t.length){e.flush(!0);return{length:e.totalLength}}const o=[];for(const e of t)isAnnotationRenderable(e,i)&&o.push(e.getOperatorList(l,r,n,s).catch((function(e){(0,a.warn)(`getOperatorList - ignoring annotation data during "${r.name}" task: "${e}".`);return null})));return Promise.all(o).then((function(t){e.addOp(a.OPS.beginAnnotations,[]);for(const r of t)e.addOpList(r);e.addOp(a.OPS.endAnnotations,[]);e.flush(!0);return{length:e.totalLength}}))}))}extractTextContent({handler:e,task:t,normalizeWhitespace:r,sink:a,combineTextItems:i}){const n=this.pdfManager.ensure(this,"getContentStream"),s=this.loadResources(["ExtGState","XObject","Font"]);return Promise.all([n,s]).then(([n])=>new d.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions}).getTextContent({stream:n,task:t,resources:this.resources,normalizeWhitespace:r,combineTextItems:i,sink:a}))}getAnnotationsData(e){return this._parsedAnnotations.then((function(t){const r=[];for(let a=0,i=t.length;a{const e=[];for(const t of this.annotations)e.push(c.AnnotationFactory.create(this.xref,t,this.pdfManager,this._localIdFactory).catch((function(e){(0,a.warn)(`_parsedAnnotations: "${e}".`);return null})));return Promise.all(e).then((function(e){return e.filter(e=>!!e)}))});return(0,a.shadow)(this,"_parsedAnnotations",e)}}t.Page=Page;const g=new Uint8Array([37,80,68,70,45]),m=new Uint8Array([115,116,97,114,116,120,114,101,102]),p=new Uint8Array([101,110,100,111,98,106]),b=/^[1-9]\.[0-9]$/;function find(e,t,r=1024,a=!1){const i=t.length,n=e.peekBytes(r),s=n.length-i;if(s<=0)return!1;if(a){const r=i-1;let a=n.length-1;for(;a>=r;){let s=0;for(;s=i){e.pos+=a-r;return!0}a--}}else{let r=0;for(;r<=s;){let a=0;for(;a=i){e.pos+=r;return!0}r++}}return!1}t.PDFDocument=class PDFDocument{constructor(e,t){let r;if((0,n.isStream)(t))r=t;else{if(!(0,a.isArrayBuffer)(t))throw new Error("PDFDocument: Unknown argument type");r=new o.Stream(t)}if(r.length<=0)throw new a.InvalidPDFException("The PDF file is empty, i.e. its size is zero bytes.");this.pdfManager=e;this.stream=r;this.xref=new i.XRef(r,e);this._pagePromises=[];this._version=null;const s={font:0};this._globalIdFactory=class{static getDocId(){return"g_"+e.docId}static createFontId(){return"f"+ ++s.font}static createObjId(){(0,a.unreachable)("Abstract method `createObjId` called.")}}}parse(e){this.xref.parse(e);this.catalog=new i.Catalog(this.pdfManager,this.xref);this.catalog.version&&(this._version=this.catalog.version)}get linearization(){let e=null;try{e=h.Linearization.create(this.stream)}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)(e)}return(0,a.shadow)(this,"linearization",e)}get startXRef(){const e=this.stream;let t=0;if(this.linearization){e.reset();find(e,p)&&(t=e.pos+6-e.start)}else{const r=1024,a=m.length;let i=!1,n=e.end;for(;!i&&n>0;){n-=r-a;n<0&&(n=0);e.pos=n;i=find(e,m,r,!0)}if(i){e.skip(9);let r;do{r=e.getByte()}while((0,s.isWhiteSpace)(r));let a="";for(;r>=32&&r<=57;){a+=String.fromCharCode(r);r=e.getByte()}t=parseInt(a,10);isNaN(t)&&(t=0)}}return(0,a.shadow)(this,"startXRef",t)}checkHeader(){const e=this.stream;e.reset();if(!find(e,g))return;e.moveStart();let t,r="";for(;(t=e.getByte())>32&&!(r.length>=12);)r+=String.fromCharCode(t);this._version||(this._version=r.substring(5))}parseStartXRef(){this.xref.setStartXRef(this.startXRef)}get numPages(){const e=this.linearization,t=e?e.numPages:this.catalog.numPages;return(0,a.shadow)(this,"numPages",t)}_hasOnlyDocumentSignatures(e,t=0){return e.every(e=>{if((e=this.xref.fetchIfRef(e)).has("Kids")){if(++t>10){(0,a.warn)("_hasOnlyDocumentSignatures: maximum recursion depth reached");return!1}return this._hasOnlyDocumentSignatures(e.get("Kids"),t)}const r=(0,n.isName)(e.get("FT"),"Sig"),i=e.get("Rect"),s=Array.isArray(i)&&i.every(e=>0===e);return r&&s})}get formInfo(){const e={hasAcroForm:!1,hasXfa:!1},t=this.catalog.acroForm;if(!t)return(0,a.shadow)(this,"formInfo",e);try{const r=t.get("XFA"),a=Array.isArray(r)&&r.length>0||(0,n.isStream)(r)&&!r.isEmpty;e.hasXfa=a;const i=t.get("Fields"),s=Array.isArray(i)&&i.length>0,o=!!(1&t.get("SigFlags"))&&this._hasOnlyDocumentSignatures(i);e.hasAcroForm=s&&!o}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)("Cannot fetch form information.")}return(0,a.shadow)(this,"formInfo",e)}get documentInfo(){const e={Title:a.isString,Author:a.isString,Subject:a.isString,Keywords:a.isString,Creator:a.isString,Producer:a.isString,CreationDate:a.isString,ModDate:a.isString,Trapped:n.isName};let t=this._version;if("string"!=typeof t||!b.test(t)){(0,a.warn)("Invalid PDF header version number: "+t);t=null}const r={PDFFormatVersion:t,IsLinearized:!!this.linearization,IsAcroFormPresent:this.formInfo.hasAcroForm,IsXFAPresent:this.formInfo.hasXfa,IsCollectionPresent:!!this.catalog.collection};let i;try{i=this.xref.trailer.get("Info")}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)("The document information dictionary is invalid.")}if((0,n.isDict)(i))for(const t of i.getKeys()){const s=i.get(t);if(e[t])e[t](s)?r[t]="string"!=typeof s?s:(0,a.stringToPDFString)(s):(0,a.info)(`Bad value in document info for "${t}".`);else if("string"==typeof t){let e;if((0,a.isString)(s))e=(0,a.stringToPDFString)(s);else{if(!((0,n.isName)(s)||(0,a.isNum)(s)||(0,a.isBool)(s))){(0,a.info)(`Unsupported value in document info for (custom) "${t}".`);continue}e=s}r.Custom||(r.Custom=Object.create(null));r.Custom[t]=e}}return(0,a.shadow)(this,"documentInfo",r)}get fingerprint(){let e;const t=this.xref.trailer.get("ID");e=Array.isArray(t)&&t[0]&&(0,a.isString)(t[0])&&"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"!==t[0]?(0,a.stringToBytes)(t[0]):(0,l.calculateMD5)(this.stream.getByteRange(0,1024),0,1024);const r=[];for(let t=0,a=e.length;t{if((0,n.isDict)(e,"Page")||(0,n.isDict)(e)&&!e.has("Type")&&e.has("Contents")){i&&!t.pageKidsCountCache.has(i)&&t.pageKidsCountCache.put(i,1);return[e,i]}throw new a.FormatError("The Linearization dictionary doesn't point to a valid Page dictionary.")}).catch(r=>{(0,a.info)(r);return t.getPageDict(e)})}getPage(e){if(void 0!==this._pagePromises[e])return this._pagePromises[e];const{catalog:t,linearization:r}=this,a=r&&r.pageFirst===e?this._getLinearizationPage(e):t.getPageDict(e);return this._pagePromises[e]=a.then(([r,a])=>new Page({pdfManager:this.pdfManager,xref:this.xref,pageIndex:e,pageDict:r,ref:a,globalIdFactory:this._globalIdFactory,fontCache:t.fontCache,builtInCMapCache:t.builtInCMapCache,globalImageCache:t.globalImageCache}))}checkFirstPage(){return this.getPage(0).catch(async e=>{if(e instanceof s.XRefEntryException){this._pagePromises.length=0;await this.cleanup();throw new s.XRefParseException}})}fontFallback(e,t){return this.catalog.fontFallback(e,t)}async cleanup(e=!1){return this.catalog?this.catalog.cleanup(e):(0,n.clearPrimitiveCaches)()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.FileSpec=t.XRef=t.ObjectLoader=t.Catalog=void 0;var a=r(2),i=r(5),n=r(11),s=r(8),o=r(22),c=r(23),l=r(24);function fetchDestination(e){return(0,i.isDict)(e)?e.get("D"):e}class Catalog{constructor(e,t){this.pdfManager=e;this.xref=t;this._catDict=t.getCatalogObj();if(!(0,i.isDict)(this._catDict))throw new a.FormatError("Catalog object is not a dictionary.");this.fontCache=new i.RefSetCache;this.builtInCMapCache=new Map;this.globalImageCache=new l.GlobalImageCache;this.pageKidsCountCache=new i.RefSetCache}get version(){const e=this._catDict.get("Version");return(0,i.isName)(e)?(0,a.shadow)(this,"version",e.name):(0,a.shadow)(this,"version",null)}get collection(){let e=null;try{const t=this._catDict.get("Collection");(0,i.isDict)(t)&&t.size>0&&(e=t)}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)("Cannot fetch Collection entry; assuming no collection is present.")}return(0,a.shadow)(this,"collection",e)}get acroForm(){let e=null;try{const t=this._catDict.get("AcroForm");(0,i.isDict)(t)&&t.size>0&&(e=t)}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)("Cannot fetch AcroForm entry; assuming no forms are present.")}return(0,a.shadow)(this,"acroForm",e)}get metadata(){const e=this._catDict.getRaw("Metadata");if(!(0,i.isRef)(e))return(0,a.shadow)(this,"metadata",null);const t=!(this.xref.encrypt&&this.xref.encrypt.encryptMetadata),r=this.xref.fetch(e,t);let n;if(r&&(0,i.isDict)(r.dict)){const e=r.dict.get("Type"),t=r.dict.get("Subtype");if((0,i.isName)(e,"Metadata")&&(0,i.isName)(t,"XML"))try{n=(0,a.stringToUTF8String)((0,a.bytesToString)(r.getBytes()))}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)("Skipping invalid metadata.")}}return(0,a.shadow)(this,"metadata",n)}get toplevelPagesDict(){const e=this._catDict.get("Pages");if(!(0,i.isDict)(e))throw new a.FormatError("Invalid top-level pages dictionary.");return(0,a.shadow)(this,"toplevelPagesDict",e)}get documentOutline(){let e=null;try{e=this._readDocumentOutline()}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.warn)("Unable to read document outline.")}return(0,a.shadow)(this,"documentOutline",e)}_readDocumentOutline(){let e=this._catDict.get("Outlines");if(!(0,i.isDict)(e))return null;e=e.getRaw("First");if(!(0,i.isRef)(e))return null;const t={items:[]},r=[{obj:e,parent:t}],n=new i.RefSet;n.put(e);const s=this.xref,o=new Uint8ClampedArray(3);for(;r.length>0;){const t=r.shift(),l=s.fetchIfRef(t.obj);if(null===l)continue;if(!l.has("Title"))throw new a.FormatError("Invalid outline item encountered.");const h={url:null,dest:null};Catalog.parseDestDictionary({destDict:l,resultObj:h,docBaseUrl:this.pdfManager.docBaseUrl});const u=l.get("Title"),d=l.get("F")||0,f=l.getArray("C"),g=l.get("Count");let m=o;!Array.isArray(f)||3!==f.length||0===f[0]&&0===f[1]&&0===f[2]||(m=c.ColorSpace.singletons.rgb.getRgb(f,0));const p={dest:h.dest,url:h.url,unsafeUrl:h.unsafeUrl,newWindow:h.newWindow,title:(0,a.stringToPDFString)(u),color:m,count:Number.isInteger(g)?g:void 0,bold:!!(2&d),italic:!!(1&d),items:[]};t.parent.items.push(p);e=l.getRaw("First");if((0,i.isRef)(e)&&!n.has(e)){r.push({obj:e,parent:p});n.put(e)}e=l.getRaw("Next");if((0,i.isRef)(e)&&!n.has(e)){r.push({obj:e,parent:t.parent});n.put(e)}}return t.items.length>0?t.items:null}get permissions(){let e=null;try{e=this._readPermissions()}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.warn)("Unable to read permissions.")}return(0,a.shadow)(this,"permissions",e)}_readPermissions(){const e=this.xref.trailer.get("Encrypt");if(!(0,i.isDict)(e))return null;let t=e.get("P");if(!(0,a.isNum)(t))return null;t+=2**32;const r=[];for(const e in a.PermissionFlag){const i=a.PermissionFlag[e];t&i&&r.push(i)}return r}get optionalContentConfig(){let e=null;try{const t=this._catDict.get("OCProperties");if(!t)return(0,a.shadow)(this,"optionalContentConfig",null);const r=t.get("D");if(!r)return(0,a.shadow)(this,"optionalContentConfig",null);const n=t.get("OCGs");if(!Array.isArray(n))return(0,a.shadow)(this,"optionalContentConfig",null);const s=[],o=[];for(const e of n){if(!(0,i.isRef)(e))continue;o.push(e);const t=this.xref.fetchIfRef(e);s.push({id:e.toString(),name:(0,a.isString)(t.get("Name"))?(0,a.stringToPDFString)(t.get("Name")):null,intent:(0,a.isString)(t.get("Intent"))?(0,a.stringToPDFString)(t.get("Intent")):null})}e=this._readOptionalContentConfig(r,o);e.groups=s}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.warn)("Unable to read optional content config: "+e)}return(0,a.shadow)(this,"optionalContentConfig",e)}_readOptionalContentConfig(e,t){function parseOnOff(e){const r=[];if(Array.isArray(e))for(const a of e)(0,i.isRef)(a)&&t.includes(a)&&r.push(a.toString());return r}function parseOrder(e,r=0){if(!Array.isArray(e))return null;const a=[];for(const s of e){if((0,i.isRef)(s)&&t.includes(s)){n.put(s);a.push(s.toString());continue}const e=parseNestedOrder(s,r);e&&a.push(e)}if(r>0)return a;const s=[];for(const e of t)n.has(e)||s.push(e.toString());s.length&&a.push({name:null,order:s});return a}function parseNestedOrder(e,t){if(++t>s){(0,a.warn)("parseNestedOrder - reached MAX_NESTED_LEVELS.");return null}const i=r.fetchIfRef(e);if(!Array.isArray(i))return null;const n=r.fetchIfRef(i[0]);if("string"!=typeof n)return null;const o=parseOrder(i.slice(1),t);return o&&o.length?{name:(0,a.stringToPDFString)(n),order:o}:null}const r=this.xref,n=new i.RefSet,s=10;return{name:(0,a.isString)(e.get("Name"))?(0,a.stringToPDFString)(e.get("Name")):null,creator:(0,a.isString)(e.get("Creator"))?(0,a.stringToPDFString)(e.get("Creator")):null,baseState:(0,i.isName)(e.get("BaseState"))?e.get("BaseState").name:null,on:parseOnOff(e.get("ON")),off:parseOnOff(e.get("OFF")),order:parseOrder(e.get("Order")),groups:null}}get numPages(){const e=this.toplevelPagesDict.get("Count");if(!Number.isInteger(e))throw new a.FormatError("Page count in top-level pages dictionary is not an integer.");return(0,a.shadow)(this,"numPages",e)}get destinations(){const e=this._readDests(),t=Object.create(null);if(e instanceof NameTree){const r=e.getAll();for(const e in r)t[e]=fetchDestination(r[e])}else e instanceof i.Dict&&e.forEach((function(e,r){r&&(t[e]=fetchDestination(r))}));return(0,a.shadow)(this,"destinations",t)}getDestination(e){const t=this._readDests();return t instanceof NameTree||t instanceof i.Dict?fetchDestination(t.get(e)||null):null}_readDests(){const e=this._catDict.get("Names");return e&&e.has("Dests")?new NameTree(e.getRaw("Dests"),this.xref):this._catDict.has("Dests")?this._catDict.get("Dests"):void 0}get pageLabels(){let e=null;try{e=this._readPageLabels()}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.warn)("Unable to read page labels.")}return(0,a.shadow)(this,"pageLabels",e)}_readPageLabels(){const e=this._catDict.getRaw("PageLabels");if(!e)return null;const t=new Array(this.numPages);let r=null,n="";const o=new NumberTree(e,this.xref).getAll();let c="",l=1;for(let e=0,h=this.numPages;e=1))throw new a.FormatError("Invalid start in PageLabel dictionary.");l=e}else l=1}switch(r){case"D":c=l;break;case"R":case"r":c=(0,s.toRomanNumerals)(l,"r"===r);break;case"A":case"a":const e=26,t=65,i=97,n="a"===r?i:t,o=l-1,h=String.fromCharCode(n+o%e),u=[];for(let t=0,r=o/e|0;t<=r;t++)u.push(h);c=u.join("");break;default:if(r)throw new a.FormatError(`Invalid style "${r}" in PageLabel dictionary.`);c=""}t[e]=n+c;l++}return t}get pageLayout(){const e=this._catDict.get("PageLayout");let t="";if((0,i.isName)(e))switch(e.name){case"SinglePage":case"OneColumn":case"TwoColumnLeft":case"TwoColumnRight":case"TwoPageLeft":case"TwoPageRight":t=e.name}return(0,a.shadow)(this,"pageLayout",t)}get pageMode(){const e=this._catDict.get("PageMode");let t="UseNone";if((0,i.isName)(e))switch(e.name){case"UseNone":case"UseOutlines":case"UseThumbs":case"FullScreen":case"UseOC":case"UseAttachments":t=e.name}return(0,a.shadow)(this,"pageMode",t)}get viewerPreferences(){const e={HideToolbar:a.isBool,HideMenubar:a.isBool,HideWindowUI:a.isBool,FitWindow:a.isBool,CenterWindow:a.isBool,DisplayDocTitle:a.isBool,NonFullScreenPageMode:i.isName,Direction:i.isName,ViewArea:i.isName,ViewClip:i.isName,PrintArea:i.isName,PrintClip:i.isName,PrintScaling:i.isName,Duplex:i.isName,PickTrayByPDFSize:a.isBool,PrintPageRange:Array.isArray,NumCopies:Number.isInteger},t=this._catDict.get("ViewerPreferences");let r=null;if((0,i.isDict)(t))for(const i in e){if(!t.has(i))continue;const n=t.get(i);if(!e[i](n)){(0,a.info)(`Bad value in ViewerPreferences for "${i}".`);continue}let s;switch(i){case"NonFullScreenPageMode":switch(n.name){case"UseNone":case"UseOutlines":case"UseThumbs":case"UseOC":s=n.name;break;default:s="UseNone"}break;case"Direction":switch(n.name){case"L2R":case"R2L":s=n.name;break;default:s="L2R"}break;case"ViewArea":case"ViewClip":case"PrintArea":case"PrintClip":switch(n.name){case"MediaBox":case"CropBox":case"BleedBox":case"TrimBox":case"ArtBox":s=n.name;break;default:s="CropBox"}break;case"PrintScaling":switch(n.name){case"None":case"AppDefault":s=n.name;break;default:s="AppDefault"}break;case"Duplex":switch(n.name){case"Simplex":case"DuplexFlipShortEdge":case"DuplexFlipLongEdge":s=n.name;break;default:s="None"}break;case"PrintPageRange":if(n.length%2!=0)break;n.every((e,t,r)=>Number.isInteger(e)&&e>0&&(0===t||e>=r[t-1])&&e<=this.numPages)&&(s=n);break;case"NumCopies":n>0&&(s=n);break;default:if("boolean"!=typeof n)throw new a.FormatError("viewerPreferences - expected a boolean value for: "+i);s=n}if(void 0!==s){r||(r=Object.create(null));r[i]=s}else(0,a.info)(`Bad value in ViewerPreferences for "${i}".`)}return(0,a.shadow)(this,"viewerPreferences",r)}get openAction(){const e=this._catDict.get("OpenAction");let t=null;if((0,i.isDict)(e)){const r=new i.Dict(this.xref);r.set("A",e);const a={url:null,dest:null,action:null};Catalog.parseDestDictionary({destDict:r,resultObj:a});if(Array.isArray(a.dest)){t||(t=Object.create(null));t.dest=a.dest}else if(a.action){t||(t=Object.create(null));t.action=a.action}}else if(Array.isArray(e)){t||(t=Object.create(null));t.dest=e}return(0,a.shadow)(this,"openAction",t)}get attachments(){const e=this._catDict.get("Names");let t=null;if(e&&e.has("EmbeddedFiles")){const r=new NameTree(e.getRaw("EmbeddedFiles"),this.xref).getAll();for(const e in r){const i=new u(r[e],this.xref);t||(t=Object.create(null));t[(0,a.stringToPDFString)(e)]=i.serializable}}return(0,a.shadow)(this,"attachments",t)}get javaScript(){const e=this._catDict.get("Names");let t=null;function appendIfJavaScriptDict(e){const r=e.get("S");if(!(0,i.isName)(r,"JavaScript"))return;let n=e.get("JS");if((0,i.isStream)(n))n=(0,a.bytesToString)(n.getBytes());else if(!(0,a.isString)(n))return;t||(t=[]);t.push((0,a.stringToPDFString)(n))}if(e&&e.has("JavaScript")){const t=new NameTree(e.getRaw("JavaScript"),this.xref).getAll();for(const e in t){const r=t[e];(0,i.isDict)(r)&&appendIfJavaScriptDict(r)}}const r=this._catDict.get("OpenAction");(0,i.isDict)(r)&&(0,i.isName)(r.get("S"),"JavaScript")&&appendIfJavaScriptDict(r);return(0,a.shadow)(this,"javaScript",t)}fontFallback(e,t){const r=[];this.fontCache.forEach((function(e){r.push(e)}));return Promise.all(r).then(r=>{for(const a of r)if(a.loadedName===e){a.fallback(t);return}})}cleanup(e=!1){(0,i.clearPrimitiveCaches)();this.globalImageCache.clear(e);this.pageKidsCountCache.clear();const t=[];this.fontCache.forEach((function(e){t.push(e)}));return Promise.all(t).then(e=>{for(const{dict:t}of e)delete t.translated;this.fontCache.clear();this.builtInCMapCache.clear()})}getPageDict(e){const t=(0,a.createPromiseCapability)(),r=[this._catDict.getRaw("Pages")],n=new i.RefSet,s=this.xref,o=this.pageKidsCountCache;let c,l=0;!function next(){for(;r.length;){const h=r.pop();if((0,i.isRef)(h)){c=o.get(h);if(c>0&&l+c=0){const t=h.objId;t&&!o.has(t)&&o.put(t,c);if(l+c<=e){l+=c;continue}}const u=h.get("Kids");if(!Array.isArray(u)){if((0,i.isName)(h.get("Type"),"Page")||!h.has("Type")&&h.has("Contents")){if(l===e){t.resolve([h,null]);return}l++;continue}t.reject(new a.FormatError("Page dictionary kids object is not an array."));return}for(let e=u.length-1;e>=0;e--)r.push(u[e])}t.reject(new Error(`Page index ${e} not found.`))}();return t.promise}getPageIndex(e){const t=this.xref;let r=0;return function next(n){return function pagesBeforeRef(r){let n,s=0;return t.fetchAsync(r).then((function(t){if((0,i.isRefsEqual)(r,e)&&!(0,i.isDict)(t,"Page")&&(!(0,i.isDict)(t)||t.has("Type")||!t.has("Contents")))throw new a.FormatError("The reference does not point to a /Page dictionary.");if(!t)return null;if(!(0,i.isDict)(t))throw new a.FormatError("Node must be a dictionary.");n=t.getRaw("Parent");return t.getAsync("Parent")})).then((function(e){if(!e)return null;if(!(0,i.isDict)(e))throw new a.FormatError("Parent must be a dictionary.");return e.getAsync("Kids")})).then((function(e){if(!e)return null;const o=[];let c=!1;for(let n=0,l=e.length;n0;){var h=l[0],u=l[1];if(!Number.isInteger(h)||!Number.isInteger(u))throw new a.FormatError(`Invalid XRef range fields: ${h}, ${u}`);if(!Number.isInteger(s)||!Number.isInteger(o)||!Number.isInteger(c))throw new a.FormatError(`Invalid XRef entry fields length: ${h}, ${u}`);for(t=i.entryNum;t=e.length);){r+=String.fromCharCode(a);a=e[t]}return r}function skipUntil(e,t,r){for(var a=r.length,i=e.length,n=0;t=a)break;t++;n++}return n}var e=/^(\d+)\s+(\d+)\s+obj\b/;const t=/\bendobj[\b\s]$/,r=/\s+(\d+\s+\d+\s+obj[\b\s<])$/;var o=new Uint8Array([116,114,97,105,108,101,114]),c=new Uint8Array([115,116,97,114,116,120,114,101,102]);const l=new Uint8Array([111,98,106]);var h=new Uint8Array([47,88,82,101,102]);this.entries.length=0;var u=this.stream;u.pos=0;for(var d,f,g=u.getBytes(),m=u.start,p=g.length,b=[],y=[];m=p)break;v=g[m]}while(10!==v&&13!==v);else++m}for(d=0,f=y.length;d0;){const s=t.fetchIfRef(n.shift());if(!(0,i.isDict)(s))continue;if(s.has("Kids")){const e=s.get("Kids");for(let t=0,i=e.length;t10){(0,a.warn)(`Search depth limit reached for "${this._type}" tree.`);return null}const n=r.get("Kids");if(!Array.isArray(n))return null;let s=0,o=n.length-1;for(;s<=o;){const a=s+o>>1,i=t.fetchIfRef(n[a]).get("Limits");if(et.fetchIfRef(i[1]))){r=t.fetchIfRef(n[a]);break}s=a+1}}if(s>o)return null}const n=r.get(this._type);if(Array.isArray(n)){let r=0,i=n.length-2;for(;r<=i;){const a=r+i>>1,s=a+(1&a),o=t.fetchIfRef(n[s]);if(eo))return t.fetchIfRef(n[s+1]);r=s+2}}(0,a.info)(`Falling back to an exhaustive search, for key "${e}", in "${this._type}" tree.`);for(let r=0,i=n.length;r>")&&!(0,n.isEOF)(this.buf1);){if(!(0,n.isName)(this.buf1)){(0,i.info)("Malformed dictionary: key must be a name object");this.shift();continue}const t=this.buf1.name;this.shift();if((0,n.isEOF)(this.buf1))break;a.set(t,this.getObj(e))}if((0,n.isEOF)(this.buf1)){if(!this.recoveryMode)throw new i.FormatError("End of file inside dictionary");return a}if((0,n.isCmd)(this.buf2,"stream"))return this.allowStreams?this.makeStream(a,e):a;this.shift();return a;default:return t}if(Number.isInteger(t)){if(Number.isInteger(this.buf1)&&(0,n.isCmd)(this.buf2,"R")){const e=n.Ref.get(t,this.buf1);this.shift();this.shift();return e}return t}return"string"==typeof t&&e?e.decryptString(t):t}findDefaultInlineStreamEnd(e){const t=this.lexer,r=e.pos;let a,o,c=0;for(;-1!==(a=e.getByte());)if(0===c)c=69===a?1:0;else if(1===c)c=73===a?2:0;else{(0,i.assert)(2===c,"findDefaultInlineStreamEnd - invalid state.");if(32===a||10===a||13===a){o=e.pos;const r=e.peekBytes(10);for(let e=0,t=r.length;e127))){c=0;break}}if(2!==c)continue;if(t.knownCommands){const e=t.peekObj();e instanceof n.Cmd&&!t.knownCommands[e.cmd]&&(c=0)}else(0,i.warn)("findDefaultInlineStreamEnd - `lexer.knownCommands` is undefined.");if(2===c)break}else c=0}if(-1===a){(0,i.warn)("findDefaultInlineStreamEnd: Reached the end of the stream without finding a valid EI marker");if(o){(0,i.warn)('... trying to recover by using the last "EI" occurrence.');e.skip(-(e.pos-o))}}let l=4;e.skip(-l);a=e.peekByte();e.skip(l);(0,s.isWhiteSpace)(a)||l--;return e.pos-l-r}findDCTDecodeInlineStreamEnd(e){const t=e.pos;let r,a,n=!1;for(;-1!==(r=e.getByte());)if(255===r){switch(e.getByte()){case 0:break;case 255:e.skip(-1);break;case 217:n=!0;break;case 192:case 193:case 194:case 195:case 197:case 198:case 199:case 201:case 202:case 203:case 205:case 206:case 207:case 196:case 204:case 218:case 219:case 220:case 221:case 222:case 223:case 224:case 225:case 226:case 227:case 228:case 229:case 230:case 231:case 232:case 233:case 234:case 235:case 236:case 237:case 238:case 239:case 254:a=e.getUint16();a>2?e.skip(a-2):e.skip(-2)}if(n)break}const s=e.pos-t;if(-1===r){(0,i.warn)("Inline DCTDecode image stream: EOI marker not found, searching for /EI/ instead.");e.skip(-s);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return s}findASCII85DecodeInlineStreamEnd(e){const t=e.pos;let r;for(;-1!==(r=e.getByte());)if(126===r){const t=e.pos;r=e.peekByte();for(;(0,s.isWhiteSpace)(r);){e.skip();r=e.peekByte()}if(62===r){e.skip();break}if(e.pos>t){const t=e.peekBytes(2);if(69===t[0]&&73===t[1])break}}const a=e.pos-t;if(-1===r){(0,i.warn)("Inline ASCII85Decode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-a);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return a}findASCIIHexDecodeInlineStreamEnd(e){const t=e.pos;let r;for(;-1!==(r=e.getByte())&&62!==r;);const a=e.pos-t;if(-1===r){(0,i.warn)("Inline ASCIIHexDecode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-a);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return a}inlineStreamSkipEI(e){let t,r=0;for(;-1!==(t=e.getByte());)if(0===r)r=69===t?1:0;else if(1===r)r=73===t?2:0;else if(2===r)break}makeInlineImage(e){const t=this.lexer,r=t.stream,a=new n.Dict(this.xref);let s;for(;!(0,n.isCmd)(this.buf1,"ID")&&!(0,n.isEOF)(this.buf1);){if(!(0,n.isName)(this.buf1))throw new i.FormatError("Dictionary key must be a name object");const t=this.buf1.name;this.shift();if((0,n.isEOF)(this.buf1))break;a.set(t,this.getObj(e))}-1!==t.beginInlineImagePos&&(s=r.pos-t.beginInlineImagePos);const o=a.get("Filter","F");let c;if((0,n.isName)(o))c=o.name;else if(Array.isArray(o)){const e=this.xref.fetchIfRef(o[0]);(0,n.isName)(e)&&(c=e.name)}const l=r.pos;let h;h="DCTDecode"===c||"DCT"===c?this.findDCTDecodeInlineStreamEnd(r):"ASCII85Decode"===c||"A85"===c?this.findASCII85DecodeInlineStreamEnd(r):"ASCIIHexDecode"===c||"AHx"===c?this.findASCIIHexDecodeInlineStreamEnd(r):this.findDefaultInlineStreamEnd(r);let u,d=r.makeSubStream(l,h,a);if(h<1e3&&s<5552){const e=d.getBytes();d.reset();const a=r.pos;r.pos=t.beginInlineImagePos;const i=r.getBytes(s);r.pos=a;u=computeAdler32(e)+"_"+computeAdler32(i);const o=this.imageCache[u];if(void 0!==o){this.buf2=n.Cmd.get("EI");this.shift();o.reset();return o}}e&&(d=e.createStream(d,h));d=this.filter(d,a,h);d.dict=a;if(void 0!==u){d.cacheKey=`inline_${h}_${u}`;this.imageCache[u]=d}this.buf2=n.Cmd.get("EI");this.shift();return d}_findStreamLength(e,t){const{stream:r}=this.lexer;r.pos=e;const a=t.length;for(;r.pos=a){r.pos+=s;return r.pos-e}s++}r.pos+=n}return-1}makeStream(e,t){const r=this.lexer;let a=r.stream;r.skipToNextLine();const o=a.pos-1;let c=e.get("Length");if(!Number.isInteger(c)){(0,i.info)(`Bad length "${c}" in stream`);c=0}a.pos=o+c;r.nextChar();if(this.tryShift()&&(0,n.isCmd)(this.buf2,"endstream"))this.shift();else{const e=new Uint8Array([101,110,100,115,116,114,101,97,109]);let t=this._findStreamLength(o,e);if(t<0){const r=1;for(let n=1;n<=r;n++){const r=e.length-n,c=e.slice(0,r),l=this._findStreamLength(o,c);if(l>=0){const e=a.peekBytes(r+1)[r];if(!(0,s.isWhiteSpace)(e))break;(0,i.info)(`Found "${(0,i.bytesToString)(c)}" when searching for endstream command.`);t=l;break}}if(t<0)throw new i.FormatError("Missing endstream command.")}c=t;r.nextChar();this.shift();this.shift()}this.shift();a=a.makeSubStream(o,c,e);t&&(a=t.createStream(a,c));a=this.filter(a,e,c);a.dict=e;return a}filter(e,t,r){let a=t.get("Filter","F"),s=t.get("DecodeParms","DP");if((0,n.isName)(a)){Array.isArray(s)&&(0,i.warn)("/DecodeParms should not contain an Array, when /Filter contains a Name.");return this.makeFilter(e,a.name,r,s)}let o=r;if(Array.isArray(a)){const t=a,r=s;for(let c=0,l=t.length;c=48&&e<=57?15&e:e>=65&&e<=70||e>=97&&e<=102?9+(15&e):-1}class Lexer{constructor(e,t=null){this.stream=e;this.nextChar();this.strBuf=[];this.knownCommands=t;this._hexStringNumWarn=0;this.beginInlineImagePos=-1}nextChar(){return this.currentChar=this.stream.getByte()}peekChar(){return this.stream.peekByte()}getNumber(){let e=this.currentChar,t=!1,r=0,a=0;if(45===e){a=-1;e=this.nextChar();45===e&&(e=this.nextChar())}else if(43===e){a=1;e=this.nextChar()}if(10===e||13===e)do{e=this.nextChar()}while(10===e||13===e);if(46===e){r=10;e=this.nextChar()}if(e<48||e>57){if(10===r&&0===a&&((0,s.isWhiteSpace)(e)||-1===e)){(0,i.warn)("Lexer.getNumber - treating a single decimal point as zero.");return 0}throw new i.FormatError(`Invalid number: ${String.fromCharCode(e)} (charCode ${e})`)}a=a||1;let n=e-48,o=0,c=1;for(;(e=this.nextChar())>=0;)if(e>=48&&e<=57){const a=e-48;if(t)o=10*o+a;else{0!==r&&(r*=10);n=10*n+a}}else if(46===e){if(0!==r)break;r=1}else if(45===e)(0,i.warn)("Badly formatted number: minus sign in the middle");else{if(69!==e&&101!==e)break;e=this.peekChar();if(43===e||45===e){c=45===e?-1:1;this.nextChar()}else if(e<48||e>57)break;t=!0}0!==r&&(n/=r);t&&(n*=10**(c*o));return a*n}getString(){let e=1,t=!1;const r=this.strBuf;r.length=0;let a=this.nextChar();for(;;){let n=!1;switch(0|a){case-1:(0,i.warn)("Unterminated string");t=!0;break;case 40:++e;r.push("(");break;case 41:if(0==--e){this.nextChar();t=!0}else r.push(")");break;case 92:a=this.nextChar();switch(a){case-1:(0,i.warn)("Unterminated string");t=!0;break;case 110:r.push("\n");break;case 114:r.push("\r");break;case 116:r.push("\t");break;case 98:r.push("\b");break;case 102:r.push("\f");break;case 92:case 40:case 41:r.push(String.fromCharCode(a));break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:let e=15&a;a=this.nextChar();n=!0;if(a>=48&&a<=55){e=(e<<3)+(15&a);a=this.nextChar();if(a>=48&&a<=55){n=!1;e=(e<<3)+(15&a)}}r.push(String.fromCharCode(e));break;case 13:10===this.peekChar()&&this.nextChar();break;case 10:break;default:r.push(String.fromCharCode(a))}break;default:r.push(String.fromCharCode(a))}if(t)break;n||(a=this.nextChar())}return r.join("")}getName(){let e,t;const r=this.strBuf;r.length=0;for(;(e=this.nextChar())>=0&&!u[e];)if(35===e){e=this.nextChar();if(u[e]){(0,i.warn)("Lexer_getName: NUMBER SIGN (#) should be followed by a hexadecimal number.");r.push("#");break}const a=toHexDigit(e);if(-1!==a){t=e;e=this.nextChar();const n=toHexDigit(e);if(-1===n){(0,i.warn)(`Lexer_getName: Illegal digit (${String.fromCharCode(e)}) in hexadecimal number.`);r.push("#",String.fromCharCode(t));if(u[e])break;r.push(String.fromCharCode(e));continue}r.push(String.fromCharCode(a<<4|n))}else r.push("#",String.fromCharCode(e))}else r.push(String.fromCharCode(e));r.length>127&&(0,i.warn)("Name token is longer than allowed by the spec: "+r.length);return n.Name.get(r.join(""))}_hexStringWarn(e){5!=this._hexStringNumWarn++?this._hexStringNumWarn>5||(0,i.warn)("getHexString - ignoring invalid character: "+e):(0,i.warn)("getHexString - ignoring additional invalid characters.")}getHexString(){const e=this.strBuf;e.length=0;let t,r,a=this.currentChar,n=!0;this._hexStringNumWarn=0;for(;;){if(a<0){(0,i.warn)("Unterminated hex string");break}if(62===a){this.nextChar();break}if(1!==u[a]){if(n){t=toHexDigit(a);if(-1===t){this._hexStringWarn(a);a=this.nextChar();continue}}else{r=toHexDigit(a);if(-1===r){this._hexStringWarn(a);a=this.nextChar();continue}e.push(String.fromCharCode(t<<4|r))}n=!n;a=this.nextChar()}else a=this.nextChar()}return e.join("")}getObj(){let e=!1,t=this.currentChar;for(;;){if(t<0)return n.EOF;if(e)10!==t&&13!==t||(e=!1);else if(37===t)e=!0;else if(1!==u[t])break;t=this.nextChar()}switch(0|t){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return this.getNumber();case 40:return this.getString();case 47:return this.getName();case 91:this.nextChar();return n.Cmd.get("[");case 93:this.nextChar();return n.Cmd.get("]");case 60:t=this.nextChar();if(60===t){this.nextChar();return n.Cmd.get("<<")}return this.getHexString();case 62:t=this.nextChar();if(62===t){this.nextChar();return n.Cmd.get(">>")}return n.Cmd.get(">");case 123:this.nextChar();return n.Cmd.get("{");case 125:this.nextChar();return n.Cmd.get("}");case 41:this.nextChar();throw new i.FormatError("Illegal character: "+t)}let r=String.fromCharCode(t);const a=this.knownCommands;let s=a&&void 0!==a[r];for(;(t=this.nextChar())>=0&&!u[t];){const e=r+String.fromCharCode(t);if(s&&void 0===a[e])break;if(128===r.length)throw new i.FormatError("Command token too long: "+r.length);r=e;s=a&&void 0!==a[r]}if("true"===r)return!0;if("false"===r)return!1;if("null"===r)return null;"BI"===r&&(this.beginInlineImagePos=this.stream.pos);return n.Cmd.get(r)}peekObj(){const e=this.stream.pos,t=this.currentChar,r=this.beginInlineImagePos;let a;try{a=this.getObj()}catch(e){if(e instanceof s.MissingDataException)throw e;(0,i.warn)("peekObj: "+e)}this.stream.pos=e;this.currentChar=t;this.beginInlineImagePos=r;return a}skipToNextLine(){let e=this.currentChar;for(;e>=0;){if(13===e){e=this.nextChar();10===e&&this.nextChar();break}if(10===e){this.nextChar();break}e=this.nextChar()}}}t.Lexer=Lexer;t.Linearization=class Linearization{static create(e){function getInt(e,t,r=!1){const a=e.get(t);if(Number.isInteger(a)&&(r?a>=0:a>0))return a;throw new Error(`The "${t}" parameter in the linearization dictionary is invalid.`)}const t=new Parser({lexer:new Lexer(e),xref:null}),r=t.getObj(),a=t.getObj(),s=t.getObj(),o=t.getObj();let c,l;if(!(Number.isInteger(r)&&Number.isInteger(a)&&(0,n.isCmd)(s,"obj")&&(0,n.isDict)(o)&&(0,i.isNum)(c=o.get("Linearized"))&&c>0))return null;if((l=getInt(o,"L"))!==e.length)throw new Error('The "L" parameter in the linearization dictionary does not equal the stream length.');return{length:l,hints:function getHints(e){const t=e.get("H");let r;if(Array.isArray(t)&&(2===(r=t.length)||4===r)){for(let e=0;e0))throw new Error(`Hint (${e}) in the linearization dictionary is invalid.`)}return t}throw new Error("Hint array in the linearization dictionary is invalid.")}(o),objectNumberFirst:getInt(o,"O"),endFirst:getInt(o,"E"),numPages:getInt(o,"N"),mainXRefEntriesOffset:getInt(o,"T"),pageFirst:o.has("P")?getInt(o,"P",!0):0}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.LZWStream=t.StringStream=t.StreamsSequenceStream=t.Stream=t.RunLengthStream=t.PredictorStream=t.NullStream=t.FlateStream=t.DecodeStream=t.DecryptStream=t.AsciiHexStream=t.Ascii85Stream=void 0;var a=r(2),i=r(5),n=r(8),s=function StreamClosure(){function Stream(e,t,r,a){this.bytes=e instanceof Uint8Array?e:new Uint8Array(e);this.start=t||0;this.pos=this.start;this.end=t+r||this.bytes.length;this.dict=a}Stream.prototype={get length(){return this.end-this.start},get isEmpty(){return 0===this.length},getByte:function Stream_getByte(){return this.pos>=this.end?-1:this.bytes[this.pos++]},getUint16:function Stream_getUint16(){var e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t},getInt32:function Stream_getInt32(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()},getBytes(e,t=!1){var r=this.bytes,a=this.pos,i=this.end;if(!e){const e=r.subarray(a,i);return t?new Uint8ClampedArray(e):e}var n=a+e;n>i&&(n=i);this.pos=n;const s=r.subarray(a,n);return t?new Uint8ClampedArray(s):s},peekByte:function Stream_peekByte(){var e=this.getByte();-1!==e&&this.pos--;return e},peekBytes(e,t=!1){var r=this.getBytes(e,t);this.pos-=r.length;return r},getByteRange(e,t){e<0&&(e=0);t>this.end&&(t=this.end);return this.bytes.subarray(e,t)},skip:function Stream_skip(e){e||(e=1);this.pos+=e},reset:function Stream_reset(){this.pos=this.start},moveStart:function Stream_moveStart(){this.start=this.pos},makeSubStream:function Stream_makeSubStream(e,t,r){return new Stream(this.bytes.buffer,e,t,r)}};return Stream}();t.Stream=s;var o=function StringStreamClosure(){function StringStream(e){const t=(0,a.stringToBytes)(e);s.call(this,t)}StringStream.prototype=s.prototype;return StringStream}();t.StringStream=o;var c=function DecodeStreamClosure(){var e=new Uint8Array(0);function DecodeStream(t){this._rawMinBufferLength=t||0;this.pos=0;this.bufferLength=0;this.eof=!1;this.buffer=e;this.minBufferLength=512;if(t)for(;this.minBufferLengthi&&(r=i)}else{for(;!this.eof;)this.readBlock();r=this.bufferLength}this.pos=r;const n=this.buffer.subarray(a,r);return!t||n instanceof Uint8ClampedArray?n:new Uint8ClampedArray(n)},peekByte:function DecodeStream_peekByte(){var e=this.getByte();-1!==e&&this.pos--;return e},peekBytes(e,t=!1){var r=this.getBytes(e,t);this.pos-=r.length;return r},makeSubStream:function DecodeStream_makeSubStream(e,t,r){for(var a=e+t;this.bufferLength<=a&&!this.eof;)this.readBlock();return new s(this.buffer,e,t,r)},getByteRange(e,t){(0,a.unreachable)("Should not call DecodeStream.getByteRange")},skip:function DecodeStream_skip(e){e||(e=1);this.pos+=e},reset:function DecodeStream_reset(){this.pos=0},getBaseStreams:function DecodeStream_getBaseStreams(){return this.str&&this.str.getBaseStreams?this.str.getBaseStreams():[]}};return DecodeStream}();t.DecodeStream=c;var l=function StreamsSequenceStreamClosure(){function StreamsSequenceStream(e){this.streams=e;let t=0;for(let r=0,a=e.length;r>e;this.codeSize=i-=e;return t};FlateStream.prototype.getCode=function FlateStream_getCode(e){for(var t,r=this.str,i=e[0],n=e[1],s=this.codeSize,o=this.codeBuf;s>16,h=65535&c;if(l<1||s>l;this.codeSize=s-l;return h};FlateStream.prototype.generateHuffmanTable=function flateStreamGenerateHuffmanTable(e){var t,r=e.length,a=0;for(t=0;ta&&(a=e[t]);for(var i=1<>=1}for(t=h;t>=1)){var h,u;if(1===l){h=i;u=n}else{if(2!==l)throw new a.FormatError("Unknown block type in flate stream");var d,f=this.getBits(5)+257,g=this.getBits(5)+1,m=this.getBits(4)+4,p=new Uint8Array(e.length);for(d=0;d0;)S[d++]=w}h=this.generateHuffmanTable(S.subarray(0,f));u=this.generateHuffmanTable(S.subarray(f,k))}for(var A=(s=this.buffer)?s.length:0,T=this.bufferLength;;){var I=this.getCode(h);if(I<256){T+1>=A&&(A=(s=this.ensureBuffer(T+1)).length);s[T++]=I}else{if(256===I){this.bufferLength=T;return}var F=(I=t[I-=257])>>16;F>0&&(F=this.getBits(F));o=(65535&I)+F;I=this.getCode(u);(F=(I=r[I])>>16)>0&&(F=this.getBits(F));var P=(65535&I)+F;T+o>=A&&(A=(s=this.ensureBuffer(T+o)).length);for(var E=0;E15))throw new a.FormatError("Unsupported predictor: "+n);this.readBlock=2===n?this.readBlockTiff:this.readBlockPng;this.str=e;this.dict=e.dict;var s=this.colors=r.get("Colors")||1,o=this.bits=r.get("BitsPerComponent")||8,l=this.columns=r.get("Columns")||1;this.pixBytes=s*o+7>>3;this.rowBytes=l*s*o+7>>3;c.call(this,t);return this}PredictorStream.prototype=Object.create(c.prototype);PredictorStream.prototype.readBlockTiff=function predictorStreamReadBlockTiff(){var e=this.rowBytes,t=this.bufferLength,r=this.ensureBuffer(t+e),a=this.bits,i=this.colors,n=this.str.getBytes(e);this.eof=!n.length;if(!this.eof){var s,o=0,c=0,l=0,h=0,u=t;if(1===a&&1===i)for(s=0;s>1;d^=d>>2;o=(1&(d^=d>>4))<<7;r[u++]=d}else if(8===a){for(s=0;s>8&255;r[u++]=255&g}}else{var m=new Uint8Array(i+1),p=(1<>l-a)&p;l-=a;c=c<=8){r[y++]=c>>h-8&255;h-=8}}h>0&&(r[y++]=(c<<8-h)+(o&(1<<8-h)-1))}this.bufferLength+=e}};PredictorStream.prototype.readBlockPng=function predictorStreamReadBlockPng(){var e=this.rowBytes,t=this.pixBytes,r=this.str.getByte(),i=this.str.getBytes(e);this.eof=!i.length;if(!this.eof){var n=this.bufferLength,s=this.ensureBuffer(n+e),o=s.subarray(n-e,n);0===o.length&&(o=new Uint8Array(e));var c,l,h,u=n;switch(r){case 0:for(c=0;c>1)+i[c];for(;c>1)+i[c]&255;u++}break;case 4:for(c=0;c0;e=(0,this.decrypt)(e,!t);var r,a=this.bufferLength,i=e.length,n=this.ensureBuffer(a+i);for(r=0;r=0;--a){r[i+a]=255&o;o>>=8}}}else this.eof=!0};return Ascii85Stream}();t.Ascii85Stream=f;var g=function AsciiHexStreamClosure(){function AsciiHexStream(e,t){this.str=e;this.dict=e.dict;this.firstDigit=-1;t&&(t*=.5);c.call(this,t)}AsciiHexStream.prototype=Object.create(c.prototype);AsciiHexStream.prototype.readBlock=function AsciiHexStream_readBlock(){var e=this.str.getBytes(8e3);if(e.length){for(var t=e.length+1>>1,r=this.ensureBuffer(this.bufferLength+t),a=this.bufferLength,i=this.firstDigit,n=0,s=e.length;n=48&&c<=57)o=15&c;else{if(!(c>=65&&c<=70||c>=97&&c<=102)){if(62===c){this.eof=!0;break}continue}o=9+(15&c)}if(i<0)i=o;else{r[a++]=i<<4|o;i=-1}}if(i>=0&&this.eof){r[a++]=i<<4;i=-1}this.firstDigit=i;this.bufferLength=a}else this.eof=!0};return AsciiHexStream}();t.AsciiHexStream=g;var m=function RunLengthStreamClosure(){function RunLengthStream(e,t){this.str=e;this.dict=e.dict;c.call(this,t)}RunLengthStream.prototype=Object.create(c.prototype);RunLengthStream.prototype.readBlock=function RunLengthStream_readBlock(){var e=this.str.getBytes(2);if(!e||e.length<2||128===e[0])this.eof=!0;else{var t,r=this.bufferLength,a=e[0];if(a<128){(t=this.ensureBuffer(r+a+1))[r++]=e[1];if(a>0){var i=this.str.getBytes(a);t.set(i,r);r+=a}}else{a=257-a;var n=e[1];t=this.ensureBuffer(r+a+1);for(var s=0;s>>t&(1<0;if(b<256){d[0]=b;f=1}else{if(!(b>=258)){if(256===b){h=9;s=258;f=0;continue}this.eof=!0;delete this.lzwState;break}if(b=0;t--){d[t]=o[r];r=l[r]}else d[f++]=d[0]}if(y){l[s]=u;c[s]=c[u]+1;o[s]=d[0];h=++s+n&s+n-1?h:0|Math.min(Math.log(s+n)/.6931471805599453+1,12)}u=b;if(a<(g+=f)){do{a+=512}while(ae.getByte()};this.ccittFaxDecoder=new i.CCITTFaxDecoder(s,{K:r.get("K"),EndOfLine:r.get("EndOfLine"),EncodedByteAlign:r.get("EncodedByteAlign"),Columns:r.get("Columns"),Rows:r.get("Rows"),EndOfBlock:r.get("EndOfBlock"),BlackIs1:r.get("BlackIs1")});n.DecodeStream.call(this,t)}CCITTFaxStream.prototype=Object.create(n.DecodeStream.prototype);CCITTFaxStream.prototype.readBlock=function(){for(;!this.eof;){const e=this.ccittFaxDecoder.readNextChar();if(-1===e){this.eof=!0;return}this.ensureBuffer(this.bufferLength+1);this.buffer[this.bufferLength++]=e}};return CCITTFaxStream}();t.CCITTFaxStream=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.CCITTFaxDecoder=void 0;var a=r(2);const i=function CCITTFaxDecoder(){const e=[[-1,-1],[-1,-1],[7,8],[7,7],[6,6],[6,6],[6,5],[6,5],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2]],t=[[-1,-1],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[12,1984],[12,2048],[12,2112],[12,2176],[12,2240],[12,2304],[11,1856],[11,1856],[11,1920],[11,1920],[12,2368],[12,2432],[12,2496],[12,2560]],r=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]],i=[[-1,-1],[-1,-1],[12,-2],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]],n=[[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[11,23],[11,23],[12,50],[12,51],[12,44],[12,45],[12,46],[12,47],[12,57],[12,58],[12,61],[12,256],[10,16],[10,16],[10,16],[10,16],[10,17],[10,17],[10,17],[10,17],[12,48],[12,49],[12,62],[12,63],[12,30],[12,31],[12,32],[12,33],[12,40],[12,41],[11,22],[11,22],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[12,128],[12,192],[12,26],[12,27],[12,28],[12,29],[11,19],[11,19],[11,20],[11,20],[12,34],[12,35],[12,36],[12,37],[12,38],[12,39],[11,21],[11,21],[12,42],[12,43],[10,0],[10,0],[10,0],[10,0],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12]],s=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[6,9],[6,8],[5,7],[5,7],[4,6],[4,6],[4,6],[4,6],[4,5],[4,5],[4,5],[4,5],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2]];function CCITTFaxDecoder(e,t={}){if(!e||"function"!=typeof e.next)throw new Error('CCITTFaxDecoder - invalid "source" parameter.');this.source=e;this.eof=!1;this.encoding=t.K||0;this.eoline=t.EndOfLine||!1;this.byteAlign=t.EncodedByteAlign||!1;this.columns=t.Columns||1728;this.rows=t.Rows||0;let r,a=t.EndOfBlock;null==a&&(a=!0);this.eoblock=a;this.black=t.BlackIs1||!1;this.codingLine=new Uint32Array(this.columns+1);this.refLine=new Uint32Array(this.columns+2);this.codingLine[0]=this.columns;this.codingPos=0;this.row=0;this.nextLine2D=this.encoding<0;this.inputBits=0;this.inputBuf=0;this.outputBits=0;this.rowsDone=!1;for(;0===(r=this._lookBits(12));)this._eatBits(1);1===r&&this._eatBits(12);if(this.encoding>0){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}}CCITTFaxDecoder.prototype={readNextChar(){if(this.eof)return-1;const e=this.refLine,t=this.codingLine,r=this.columns;let i,n,s,o,c;if(0===this.outputBits){this.rowsDone&&(this.eof=!0);if(this.eof)return-1;this.err=!1;let s,c,l;if(this.nextLine2D){for(o=0;t[o]=64);do{c+=l=this._getWhiteCode()}while(l>=64)}else{do{s+=l=this._getWhiteCode()}while(l>=64);do{c+=l=this._getBlackCode()}while(l>=64)}this._addPixels(t[this.codingPos]+s,n);t[this.codingPos]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]=64);else do{s+=l=this._getWhiteCode()}while(l>=64);this._addPixels(t[this.codingPos]+s,n);n^=1}}let h=!1;this.byteAlign&&(this.inputBits&=-8);if(this.eoblock||this.row!==this.rows-1){s=this._lookBits(12);if(this.eoline)for(;-1!==s&&1!==s;){this._eatBits(1);s=this._lookBits(12)}else for(;0===s;){this._eatBits(1);s=this._lookBits(12)}if(1===s){this._eatBits(12);h=!0}else-1===s&&(this.eof=!0)}else this.rowsDone=!0;if(!this.eof&&this.encoding>0&&!this.rowsDone){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}if(this.eoblock&&h&&this.byteAlign){s=this._lookBits(12);if(1===s){this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}if(this.encoding>=0)for(o=0;o<4;++o){s=this._lookBits(12);1!==s&&(0,a.info)("bad rtc code: "+s);this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}}this.eof=!0}}else if(this.err&&this.eoline){for(;;){s=this._lookBits(13);if(-1===s){this.eof=!0;return-1}if(s>>1==1)break;this._eatBits(1)}this._eatBits(12);if(this.encoding>0){this._eatBits(1);this.nextLine2D=!(1&s)}}t[0]>0?this.outputBits=t[this.codingPos=0]:this.outputBits=t[this.codingPos=1];this.row++}if(this.outputBits>=8){c=1&this.codingPos?0:255;this.outputBits-=8;if(0===this.outputBits&&t[this.codingPos]s){c<<=s;1&this.codingPos||(c|=255>>8-s);this.outputBits-=s;s=0}else{c<<=this.outputBits;1&this.codingPos||(c|=255>>8-this.outputBits);s-=this.outputBits;this.outputBits=0;if(t[this.codingPos]0){c<<=s;s=0}}}while(s)}this.black&&(c^=255);return c},_addPixels(e,t){const r=this.codingLine;let i=this.codingPos;if(e>r[i]){if(e>this.columns){(0,a.info)("row is wrong length");this.err=!0;e=this.columns}1&i^t&&++i;r[i]=e}this.codingPos=i},_addPixelsNeg(e,t){const r=this.codingLine;let i=this.codingPos;if(e>r[i]){if(e>this.columns){(0,a.info)("row is wrong length");this.err=!0;e=this.columns}1&i^t&&++i;r[i]=e}else if(e0&&e=i){const t=r[e-i];if(t[0]===a){this._eatBits(a);return[!0,t[1],!0]}}}return[!1,0,!1]},_getTwoDimCode(){let t,r=0;if(this.eoblock){r=this._lookBits(7);t=e[r];if(t&&t[0]>0){this._eatBits(t[0]);return t[1]}}else{const t=this._findTableCode(1,7,e);if(t[0]&&t[2])return t[1]}(0,a.info)("Bad two dim code");return-1},_getWhiteCode(){let e,i=0;if(this.eoblock){i=this._lookBits(12);if(-1===i)return 1;e=i>>5==0?t[i]:r[i>>3];if(e[0]>0){this._eatBits(e[0]);return e[1]}}else{let e=this._findTableCode(1,9,r);if(e[0])return e[1];e=this._findTableCode(11,12,t);if(e[0])return e[1]}(0,a.info)("bad white code");this._eatBits(1);return 1},_getBlackCode(){let e,t;if(this.eoblock){e=this._lookBits(13);if(-1===e)return 1;t=e>>7==0?i[e]:e>>9==0&&e>>7!=0?n[(e>>1)-64]:s[e>>7];if(t[0]>0){this._eatBits(t[0]);return t[1]}}else{let e=this._findTableCode(2,6,s);if(e[0])return e[1];e=this._findTableCode(7,12,n,64);if(e[0])return e[1];e=this._findTableCode(10,13,i);if(e[0])return e[1]}(0,a.info)("bad black code");this._eatBits(1);return 1},_lookBits(e){let t;for(;this.inputBits>16-e;this.inputBuf=this.inputBuf<<8|t;this.inputBits+=8}return this.inputBuf>>this.inputBits-e&65535>>16-e},_eatBits(e){(this.inputBits-=e)<0&&(this.inputBits=0)}};return CCITTFaxDecoder}();t.CCITTFaxDecoder=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Jbig2Stream=void 0;var a=r(5),i=r(12),n=r(16),s=r(2);const o=function Jbig2StreamClosure(){function Jbig2Stream(e,t,r,a){this.stream=e;this.maybeLength=t;this.dict=r;this.params=a;i.DecodeStream.call(this,t)}Jbig2Stream.prototype=Object.create(i.DecodeStream.prototype);Object.defineProperty(Jbig2Stream.prototype,"bytes",{get(){return(0,s.shadow)(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0});Jbig2Stream.prototype.ensureBuffer=function(e){};Jbig2Stream.prototype.readBlock=function(){if(this.eof)return;const e=new n.Jbig2Image,t=[];if((0,a.isDict)(this.params)){const e=this.params.get("JBIG2Globals");if((0,a.isStream)(e)){const r=e.getBytes();t.push({data:r,start:0,end:r.length})}}t.push({data:this.bytes,start:0,end:this.bytes.length});const r=e.parseChunks(t),i=r.length;for(let e=0;e>>0}var n=readBits(1),s=readBits(1)?readBits(1)?readBits(1)?readBits(1)?readBits(1)?readBits(32)+4436:readBits(12)+340:readBits(8)+84:readBits(6)+20:readBits(4)+4:readBits(2);return 0===n?s:s>0?-s:null}function decodeIAID(e,t,r){for(var a=e.getContexts("IAID"),i=1,n=0;n=B&&T=O){q=q<<1&y;for(f=0;f=0&&F=0&&(P=N[I][F])&&(q|=P<=e?O<<=1:O=O<<1|C[E][B]}for(d=0;d=k||B<0||B>=w?O<<=1:O=O<<1|i[E][B]}var M=x.readBit(A,O);F[P]=M}}return C}function decodeTextRegion(e,t,r,a,i,n,s,o,c,l,h,u,d,f,g,m,p,b,y){if(e&&t)throw new Jbig2Error("refinement with Huffman is not supported");var v,w,k=[];for(v=0;v1&&(a=e?y.readBits(b):decodeInteger(x,"IAIT",C));var F=s*A+a,P=e?f.symbolIDTable.decode(y):decodeIAID(x,C,c),E=t&&(e?y.readBit():decodeInteger(x,"IARI",C)),B=o[P],O=B[0].length,M=B.length;if(E){var D=decodeInteger(x,"IARDW",C),R=decodeInteger(x,"IARDH",C);B=decodeRefinement(O+=D,M+=R,g,B,(D>>1)+decodeInteger(x,"IARDX",C),(R>>1)+decodeInteger(x,"IARDY",C),!1,m,p)}var N,L,_,U=F-(1&u?0:M-1),q=I-(2&u?O-1:0);if(l){for(N=0;N>5&7,u=[31&c],d=r+6;if(7===c){h=536870911&(0,i.readUint32)(t,d-1);d+=3;var f=h+7>>3;u[0]=t[d++];for(;--f>0;)u.push(t[d++])}else if(5===c||6===c)throw new Jbig2Error("invalid referred-to flags");a.retainBits=u;let g=4;a.number<=256?g=1:a.number<=65536&&(g=2);var m,p,b=[];for(m=0;m>>24&255;w[3]=y.height>>16&255;w[4]=y.height>>8&255;w[5]=255&y.height;for(m=d,p=t.length;m>2&3;d.huffmanDWSelector=f>>4&3;d.bitmapSizeSelector=f>>6&1;d.aggregationInstancesSelector=f>>7&1;d.bitmapCodingContextUsed=!!(256&f);d.bitmapCodingContextRetained=!!(512&f);d.template=f>>10&3;d.refinementTemplate=f>>12&1;h+=2;if(!d.huffman){s=0===d.template?4:1;a=[];for(n=0;n>2&3;g.stripSize=1<>4&3;g.transposed=!!(64&m);g.combinationOperator=m>>7&3;g.defaultPixelValue=m>>9&1;g.dsOffset=m<<17>>27;g.refinementTemplate=m>>15&1;if(g.huffman){var p=(0,i.readUint16)(c,h);h+=2;g.huffmanFS=3&p;g.huffmanDS=p>>2&3;g.huffmanDT=p>>4&3;g.huffmanRefinementDW=p>>6&3;g.huffmanRefinementDH=p>>8&3;g.huffmanRefinementDX=p>>10&3;g.huffmanRefinementDY=p>>12&3;g.huffmanRefinementSizeSelector=!!(16384&p)}if(g.refinement&&!g.refinementTemplate){a=[];for(n=0;n<2;n++){a.push({x:(0,i.readInt8)(c,h),y:(0,i.readInt8)(c,h+1)});h+=2}g.refinementAt=a}g.numberOfSymbolInstances=(0,i.readUint32)(c,h);h+=4;r=[g,o.referredTo,c,h,u];break;case 16:const e={},t=c[h++];e.mmr=!!(1&t);e.template=t>>1&3;e.patternWidth=c[h++];e.patternHeight=c[h++];e.maxPatternIndex=(0,i.readUint32)(c,h);h+=4;r=[e,o.number,c,h,u];break;case 22:case 23:const k={};k.info=readRegionSegmentInformation(c,h);h+=l;const S=c[h++];k.mmr=!!(1&S);k.template=S>>1&3;k.enableSkip=!!(8&S);k.combinationOperator=S>>4&7;k.defaultPixelValue=S>>7&1;k.gridWidth=(0,i.readUint32)(c,h);h+=4;k.gridHeight=(0,i.readUint32)(c,h);h+=4;k.gridOffsetX=4294967295&(0,i.readUint32)(c,h);h+=4;k.gridOffsetY=4294967295&(0,i.readUint32)(c,h);h+=4;k.gridVectorX=(0,i.readUint16)(c,h);h+=2;k.gridVectorY=(0,i.readUint16)(c,h);h+=2;r=[k,o.referredTo,c,h,u];break;case 38:case 39:var b={};b.info=readRegionSegmentInformation(c,h);h+=l;var y=c[h++];b.mmr=!!(1&y);b.template=y>>1&3;b.prediction=!!(8&y);if(!b.mmr){s=0===b.template?4:1;a=[];for(n=0;n>2&1;v.combinationOperator=w>>3&3;v.requiresBuffer=!!(32&w);v.combinationOperatorOverride=!!(64&w);r=[v];break;case 49:case 50:case 51:break;case 53:r=[o.number,c,h,u];break;case 62:break;default:throw new Jbig2Error(`segment type ${o.typeName}(${o.type}) is not implemented`)}var k="on"+o.typeName;k in t&&t[k].apply(t,r)}function processSegments(e,t){for(var r=0,a=e.length;r>3,r=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var a=0,i=r.length;a>3,h=s.combinationOperatorOverride?e.combinationOperator:s.combinationOperator,u=this.buffer,d=128>>(7&e.x),f=e.y*l+(e.x>>3);switch(h){case 0:for(r=0;r>=1)){i=128;n++}}f+=l}break;case 2:for(r=0;r>=1)){i=128;n++}}f+=l}break;default:throw new Jbig2Error(`operator ${h} is not supported`)}},onImmediateGenericRegion:function SimpleSegmentVisitor_onImmediateGenericRegion(e,t,r,a){var i=e.info,n=new DecodingContext(t,r,a),s=decodeBitmap(e.mmr,i.width,i.height,e.template,e.prediction,null,e.at,n);this.drawBitmap(i,s)},onImmediateLosslessGenericRegion:function SimpleSegmentVisitor_onImmediateLosslessGenericRegion(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function SimpleSegmentVisitor_onSymbolDictionary(e,t,r,a,n,s){let o,c;if(e.huffman){o=function getSymbolDictionaryHuffmanTables(e,t,r){let a,i,n,s,o=0;switch(e.huffmanDHSelector){case 0:case 1:a=getStandardTable(e.huffmanDHSelector+4);break;case 3:a=getCustomHuffmanTable(o,t,r);o++;break;default:throw new Jbig2Error("invalid Huffman DH selector")}switch(e.huffmanDWSelector){case 0:case 1:i=getStandardTable(e.huffmanDWSelector+2);break;case 3:i=getCustomHuffmanTable(o,t,r);o++;break;default:throw new Jbig2Error("invalid Huffman DW selector")}if(e.bitmapSizeSelector){n=getCustomHuffmanTable(o,t,r);o++}else n=getStandardTable(1);s=e.aggregationInstancesSelector?getCustomHuffmanTable(o,t,r):getStandardTable(1);return{tableDeltaHeight:a,tableDeltaWidth:i,tableBitmapSize:n,tableAggregateInstances:s}}(e,r,this.customTables);c=new Reader(a,n,s)}var l=this.symbols;l||(this.symbols=l={});for(var h=[],u=0,d=r.length;u1)w=decodeTextRegion(e,t,a,g,0,S,1,r.concat(f),m,0,0,1,0,s,l,h,u,0,d);else{var C=decodeIAID(b,p,m),x=decodeInteger(b,"IARDX",p),A=decodeInteger(b,"IARDY",p);w=decodeRefinement(a,g,l,C=32){let r,a,s;switch(t){case 32:if(0===e)throw new Jbig2Error("no previous value in symbol ID table");a=i.readBits(2)+3;r=n[e-1].prefixLength;break;case 33:a=i.readBits(3)+3;r=0;break;case 34:a=i.readBits(7)+11;r=0;break;default:throw new Jbig2Error("invalid code length in symbol ID table")}for(s=0;s=0;b--){F=e?decodeMMRBitmap(I,l,h,!0):decodeBitmap(!1,l,h,r,!1,null,A,m);T[b]=F}for(P=0;P=0;y--){B=T[y][P][E]^B;O|=B<>8;R=d+P*f-E*g>>8;if(D>=0&&D+S<=a&&R>=0&&R+C<=n)for(b=0;b=n)){L=p[t];N=M[b];for(y=0;y=0&&e>1&7),l=1+(a>>4&7),h=[];let u,d,f=n;do{u=o.readBits(c);d=o.readBits(l);h.push(new HuffmanLine([f,u,d,0]));f+=1<>t&1;if(t<=0)this.children[r]=new HuffmanTreeNode(e);else{let a=this.children[r];a||(this.children[r]=a=new HuffmanTreeNode(null));a.buildTree(e,t-1)}},decodeNode(e){if(this.isLeaf){if(this.isOOB)return null;const t=e.readBits(this.rangeLength);return this.rangeLow+(this.isLowerRange?-t:t)}const t=this.children[e.readBit()];if(!t)throw new Jbig2Error("invalid Huffman data");return t.decodeNode(e)}};function HuffmanTable(e,t){t||this.assignPrefixCodes(e);this.rootNode=new HuffmanTreeNode(null);for(let t=0,r=e.length;t0&&this.rootNode.buildTree(r,r.prefixLength-1)}}HuffmanTable.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){const t=e.length;let r=0;for(let a=0;a=this.end)throw new Jbig2Error("end of data while reading bit");this.currentByte=this.data[this.position++];this.shift=7}const e=this.currentByte>>this.shift&1;this.shift--;return e},readBits(e){let t,r=0;for(t=e-1;t>=0;t--)r|=this.readBit()<=this.end?-1:this.data[this.position++]}};function getCustomHuffmanTable(e,t,r){let a=0;for(let i=0,n=t.length;i>r&1;r--}}if(a&&!l){const e=5;for(let t=0;tfunction parseJbig2Chunks(e){for(var t=new SimpleSegmentVisitor,r=0,a=e.length;r>=1}}return{imgData:u,width:c,height:l}}(e);this.width=r;this.height=a;return t}};return Jbig2Image}();t.Jbig2Image=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ArithmeticDecoder=void 0;const a=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];t.ArithmeticDecoder=class ArithmeticDecoder{constructor(e,t,r){this.data=e;this.bp=t;this.dataEnd=r;this.chigh=e[t];this.clow=0;this.byteIn();this.chigh=this.chigh<<7&65535|this.clow>>9&127;this.clow=this.clow<<7&65535;this.ct-=7;this.a=32768}byteIn(){const e=this.data;let t=this.bp;if(255===e[t])if(e[t+1]>143){this.clow+=65280;this.ct=8}else{t++;this.clow+=e[t]<<9;this.ct=7;this.bp=t}else{t++;this.clow+=t65535){this.chigh+=this.clow>>16;this.clow&=65535}}readBit(e,t){let r=e[t]>>1,i=1&e[t];const n=a[r],s=n.qe;let o,c=this.a-s;if(this.chigh>15&1;this.clow=this.clow<<1&65535;this.ct--}while(0==(32768&c));this.a=c;e[t]=r<<1|i;return o}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.JpegStream=void 0;var a=r(12),i=r(5),n=r(19),s=r(2);const o=function JpegStreamClosure(){function JpegStream(e,t,r,i){let n;for(;-1!==(n=e.getByte());)if(255===n){e.skip(-1);break}this.stream=e;this.maybeLength=t;this.dict=r;this.params=i;a.DecodeStream.call(this,t)}JpegStream.prototype=Object.create(a.DecodeStream.prototype);Object.defineProperty(JpegStream.prototype,"bytes",{get:function JpegStream_bytes(){return(0,s.shadow)(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0});JpegStream.prototype.ensureBuffer=function(e){};JpegStream.prototype.readBlock=function(){if(this.eof)return;const e={decodeTransform:void 0,colorTransform:void 0},t=this.dict.getArray("Decode","D");if(this.forceRGB&&Array.isArray(t)){const r=this.dict.get("BitsPerComponent")||8,a=t.length,i=new Int32Array(a);let n=!1;const s=(1<0&&!e[s-1];)s--;n.push({children:[],index:0});var o,c=n[0];for(r=0;r0;)c=n.pop();c.index++;n.push(c);for(;n.length<=r;){n.push(o={children:[],index:0});c.children[c.index]=o.children;c=o}i++}if(r+10){b--;return p>>b&1}p=t[r++];if(255===p){var e=t[r++];if(e){if(220===e&&d){r+=2;const e=(0,i.readUint16)(t,r);r+=2;if(e>0&&e!==n.scanLines)throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data",e)}else if(217===e){if(d){const e=k*(8===n.precision?8:0);if(e>0&&Math.round(n.scanLines/e)>=10)throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, possibly caused by incorrect `scanLines` parameter",e)}throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data")}throw new JpegError("unexpected marker "+(p<<8|e).toString(16))}}b=7;return p>>>7}function decodeHuffman(e){for(var t=e;;){switch(typeof(t=t[readBit()])){case"number":return t;case"object":continue}throw new JpegError("invalid huffman sequence")}}function receive(e){for(var t=0;e>0;){t=t<<1|readBit();e--}return t}function receiveAndExtend(e){if(1===e)return 1===readBit()?1:-1;var t=receive(e);return t>=1<0)y--;else for(var a=c,i=l;a<=i;){var n=decodeHuffman(t.huffmanTableAC),s=15&n,o=n>>4;if(0!==s){var h=e[a+=o];t.blockData[r+h]=receiveAndExtend(s)*(1<>4;if(0===(a=15&i))if(o<15){y=receive(o)+(1<>4;if(0!==o){var l=e[n+=c];t.blockData[r+l]=receiveAndExtend(o);n++}else{if(c<15)break;n+=16}}};var P,E,B,O,M=0;E=1===F?s[0].blocksPerLine*s[0].blocksPerColumn:f*n.mcusPerColumn;for(;M<=E;){var D=o?Math.min(E-M,o):E;if(D>0){for(C=0;C0?"unexpected":"excessive";(0,a.warn)(`decodeScan - ${e} MCU data, current marker is: ${P.invalid}`);r=P.offset}if(!(P.marker>=65488&&P.marker<=65495))break;r+=2}return r-m}function quantizeAndInverse(e,t,r){var a,i,n,s,o,c,l,h,u,d,f,g,m,p,b,y,v,w=e.quantizationTable,k=e.blockData;if(!w)throw new JpegError("missing required Quantization Table.");for(var S=0;S<64;S+=8){u=k[t+S];d=k[t+S+1];f=k[t+S+2];g=k[t+S+3];m=k[t+S+4];p=k[t+S+5];b=k[t+S+6];y=k[t+S+7];u*=w[S];if(0!=(d|f|g|m|p|b|y)){d*=w[S+1];f*=w[S+2];g*=w[S+3];m*=w[S+4];p*=w[S+5];i=(a=(a=5793*u+128>>8)+(i=5793*m+128>>8)+1>>1)-i;v=3784*(n=f)+1567*(s=b*=w[S+6])+128>>8;n=1567*n-3784*s+128>>8;l=(o=(o=2896*(d-(y*=w[S+7]))+128>>8)+(l=p<<4)+1>>1)-l;c=(h=(h=2896*(d+y)+128>>8)+(c=g<<4)+1>>1)-c;s=(a=a+(s=v)+1>>1)-s;n=(i=i+n+1>>1)-n;v=2276*o+3406*h+2048>>12;o=3406*o-2276*h+2048>>12;h=v;v=799*c+4017*l+2048>>12;c=4017*c-799*l+2048>>12;l=v;r[S]=a+h;r[S+7]=a-h;r[S+1]=i+l;r[S+6]=i-l;r[S+2]=n+c;r[S+5]=n-c;r[S+3]=s+o;r[S+4]=s-o}else{v=5793*u+512>>10;r[S]=v;r[S+1]=v;r[S+2]=v;r[S+3]=v;r[S+4]=v;r[S+5]=v;r[S+6]=v;r[S+7]=v}}for(var C=0;C<8;++C){u=r[C];if(0!=((d=r[C+8])|(f=r[C+16])|(g=r[C+24])|(m=r[C+32])|(p=r[C+40])|(b=r[C+48])|(y=r[C+56]))){i=(a=4112+((a=5793*u+2048>>12)+(i=5793*m+2048>>12)+1>>1))-i;v=3784*(n=f)+1567*(s=b)+2048>>12;n=1567*n-3784*s+2048>>12;s=v;l=(o=(o=2896*(d-y)+2048>>12)+(l=p)+1>>1)-l;c=(h=(h=2896*(d+y)+2048>>12)+(c=g)+1>>1)-c;v=2276*o+3406*h+2048>>12;o=3406*o-2276*h+2048>>12;h=v;v=799*c+4017*l+2048>>12;c=4017*c-799*l+2048>>12;(u=(a=a+s+1>>1)+h)<16?u=0:u>=4080?u=255:u>>=4;(d=(i=i+n+1>>1)+(l=v))<16?d=0:d>=4080?d=255:d>>=4;(f=(n=i-n)+c)<16?f=0:f>=4080?f=255:f>>=4;(g=(s=a-s)+o)<16?g=0:g>=4080?g=255:g>>=4;(m=s-o)<16?m=0:m>=4080?m=255:m>>=4;(p=n-c)<16?p=0:p>=4080?p=255:p>>=4;(b=i-l)<16?b=0:b>=4080?b=255:b>>=4;(y=a-h)<16?y=0:y>=4080?y=255:y>>=4;k[t+C]=u;k[t+C+8]=d;k[t+C+16]=f;k[t+C+24]=g;k[t+C+32]=m;k[t+C+40]=p;k[t+C+48]=b;k[t+C+56]=y}else{v=(v=5793*u+8192>>14)<-2040?0:v>=2024?255:v+2056>>4;k[t+C]=v;k[t+C+8]=v;k[t+C+16]=v;k[t+C+24]=v;k[t+C+32]=v;k[t+C+40]=v;k[t+C+48]=v;k[t+C+56]=v}}}function buildComponentData(e,t){for(var r=t.blocksPerLine,a=t.blocksPerColumn,i=new Int16Array(64),n=0;n=a)return null;var s=(0,i.readUint16)(e,t);if(s>=65472&&s<=65534)return{invalid:null,marker:s,offset:t};for(var o=(0,i.readUint16)(e,n);!(o>=65472&&o<=65534);){if(++n>=a)return null;o=(0,i.readUint16)(e,n)}return{invalid:s.toString(16),marker:o,offset:n}}JpegImage.prototype={parse(t,{dnlScanLines:r=null}={}){function readDataBlock(){const e=(0,i.readUint16)(t,o);let r=(o+=2)+e-2;var n=findNextFileMarker(t,r,o);if(n&&n.invalid){(0,a.warn)("readDataBlock - incorrect length, current marker is: "+n.invalid);r=n.offset}var s=t.subarray(o,r);o+=s.length;return s}function prepareComponents(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),r=Math.ceil(e.scanLines/8/e.maxV),a=0;a>4==0)for(p=0;p<64;p++)k[e[p]]=t[o++];else{if(w>>4!=1)throw new JpegError("DQT - invalid table spec");for(p=0;p<64;p++){k[e[p]]=(0,i.readUint16)(t,o);o+=2}}u[15&w]=k}break;case 65472:case 65473:case 65474:if(n)throw new JpegError("Only single frame JPEGs supported");o+=2;(n={}).extended=65473===g;n.progressive=65474===g;n.precision=t[o++];const H=(0,i.readUint16)(t,o);o+=2;n.scanLines=r||H;n.samplesPerLine=(0,i.readUint16)(t,o);o+=2;n.components=[];n.componentIds={};var S,C=t[o++],x=0,A=0;for(m=0;m>4,I=15&t[o+1];x>4==0?f:d)[15&P]=buildHuffmanTable(E,O)}break;case 65501:o+=2;s=(0,i.readUint16)(t,o);o+=2;break;case 65498:const G=1==++h&&!r;o+=2;var M,D=t[o++],R=[];for(m=0;m>4];M.huffmanTableAC=d[15&L];R.push(M)}var _=t[o++],U=t[o++],q=t[o++];try{var j=decodeScan(t,o,n,R,s,_,U,q>>4,15&q,G);o+=j}catch(e){if(e instanceof DNLMarkerError){(0,a.warn)(e.message+" -- attempting to re-parse the JPEG image.");return this.parse(t,{dnlScanLines:e.scanLines})}if(e instanceof EOIMarkerError){(0,a.warn)(e.message+" -- ignoring the rest of the image data.");break e}throw e}break;case 65500:o+=4;break;case 65535:255!==t[o]&&o--;break;default:const W=findNextFileMarker(t,o-2,o-3);if(W&&W.invalid){(0,a.warn)("JpegImage.parse - unexpected data, current marker is: "+W.invalid);o=W.offset;break}if(o>=t.length-1){(0,a.warn)("JpegImage.parse - reached the end of the image data without finding an EOI marker (0xFFD9).");break e}throw new JpegError("JpegImage.parse - unknown marker: "+g.toString(16))}g=(0,i.readUint16)(t,o);o+=2}this.width=n.samplesPerLine;this.height=n.scanLines;this.jfif=c;this.adobe=l;this.components=[];for(m=0;m>8)+S[u+1];return v},get _isColorConversionNeeded(){return this.adobe?!!this.adobe.transformCode:3===this.numComponents?0!==this._colorTransform&&(82!==this.components[0].index||71!==this.components[1].index||66!==this.components[2].index):1===this._colorTransform},_convertYccToRgb:function convertYccToRgb(e){for(var t,r,a,i=0,n=e.length;i4)throw new JpegError("Unsupported color mode");var i=this._getLinearizedBlockData(e,t,a);if(1===this.numComponents&&r){for(var n=i.length,s=new Uint8ClampedArray(3*n),o=0,c=0;c>24&255,o>>16&255,o>>8&255,255&o);(0,a.warn)("Unsupported header type "+o+" ("+d+")")}l&&(t+=c)}else this.parseCodestream(e,0,e.length)},parseImageProperties:function JpxImage_parseImageProperties(e){for(var t=e.getByte();t>=0;){if(65361===(t<<8|(t=e.getByte()))){e.skip(4);var r=e.getInt32()>>>0,a=e.getInt32()>>>0,i=e.getInt32()>>>0,n=e.getInt32()>>>0;e.skip(16);var s=e.getUint16();this.width=r-i;this.height=a-n;this.componentsCount=s;this.bitsPerComponent=8;return}}throw new JpxError("No size marker found in JPX stream")},parseCodestream:function JpxImage_parseCodestream(e,t,r){var n={},s=!1;try{for(var o=t;o+1>5;u=[];for(;l>3;S.mu=0}else{S.epsilon=e[l]>>3;S.mu=(7&e[l])<<8|e[l+1];l+=2}u.push(S)}k.SPqcds=u;if(n.mainHeader)n.QCD=k;else{n.currentTile.QCD=k;n.currentTile.QCC=[]}break;case 65373:m=(0,i.readUint16)(e,o);var C,x={};l=o+2;if(n.SIZ.Csiz<257)C=e[l++];else{C=(0,i.readUint16)(e,l);l+=2}switch(31&(h=e[l++])){case 0:d=8;f=!0;break;case 1:d=16;f=!1;break;case 2:d=16;f=!0;break;default:throw new Error("Invalid SQcd value "+h)}x.noQuantization=8===d;x.scalarExpounded=f;x.guardBits=h>>5;u=[];for(;l>3;S.mu=0}else{S.epsilon=e[l]>>3;S.mu=(7&e[l])<<8|e[l+1];l+=2}u.push(S)}x.SPqcds=u;n.mainHeader?n.QCC[C]=x:n.currentTile.QCC[C]=x;break;case 65362:m=(0,i.readUint16)(e,o);var A={};l=o+2;var T=e[l++];A.entropyCoderWithCustomPrecincts=!!(1&T);A.sopMarkerUsed=!!(2&T);A.ephMarkerUsed=!!(4&T);A.progressionOrder=e[l++];A.layersCount=(0,i.readUint16)(e,l);l+=2;A.multipleComponentTransform=e[l++];A.decompositionLevelsCount=e[l++];A.xcb=2+(15&e[l++]);A.ycb=2+(15&e[l++]);var I=e[l++];A.selectiveArithmeticCodingBypass=!!(1&I);A.resetContextProbabilities=!!(2&I);A.terminationOnEachCodingPass=!!(4&I);A.verticallyStripe=!!(8&I);A.predictableTermination=!!(16&I);A.segmentationSymbolUsed=!!(32&I);A.reversibleTransformation=e[l++];if(A.entropyCoderWithCustomPrecincts){for(var F=[];l>4})}A.precinctsSizes=F}var E=[];A.selectiveArithmeticCodingBypass&&E.push("selectiveArithmeticCodingBypass");A.resetContextProbabilities&&E.push("resetContextProbabilities");A.terminationOnEachCodingPass&&E.push("terminationOnEachCodingPass");A.verticallyStripe&&E.push("verticallyStripe");A.predictableTermination&&E.push("predictableTermination");if(E.length>0){s=!0;throw new Error("Unsupported COD options ("+E.join(", ")+")")}if(n.mainHeader)n.COD=A;else{n.currentTile.COD=A;n.currentTile.COC=[]}break;case 65424:m=(0,i.readUint16)(e,o);(g={}).index=(0,i.readUint16)(e,o+2);g.length=(0,i.readUint32)(e,o+4);g.dataEnd=g.length+o-2;g.partIndex=e[o+8];g.partsCount=e[o+9];n.mainHeader=!1;if(0===g.partIndex){g.COD=n.COD;g.COC=n.COC.slice(0);g.QCD=n.QCD;g.QCC=n.QCC.slice(0)}n.currentTile=g;break;case 65427:if(0===(g=n.currentTile).partIndex){initializeTile(n,g.index);buildPackets(n)}parseTilePackets(n,e,o,m=g.dataEnd-o);break;case 65365:case 65367:case 65368:case 65380:m=(0,i.readUint16)(e,o);break;case 65363:throw new Error("Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("Unknown codestream code: "+c.toString(16))}o+=m}}catch(e){if(s||this.failOnCorruptedImage)throw new JpxError(e.message);(0,a.warn)("JPX: Trying to recover from: "+e.message)}this.tiles=function transformComponents(e){for(var t=e.SIZ,r=e.components,a=t.Csiz,i=[],n=0,s=e.tiles.length;n>2);y[w++]=e+p>>h;y[w++]=e>>h;y[w++]=e+m>>h}else for(d=0;d>h;y[w++]=g-.34413*m-.71414*p>>h;y[w++]=g+1.772*m>>h}if(k)for(d=0,w=3;d>h}else for(o=0;o>h;w+=a}}i.push(v)}return i}(n);this.width=n.SIZ.Xsiz-n.SIZ.XOsiz;this.height=n.SIZ.Ysiz-n.SIZ.YOsiz;this.componentsCount=n.SIZ.Csiz}};function calculateComponentDimensions(e,t){e.x0=Math.ceil(t.XOsiz/e.XRsiz);e.x1=Math.ceil(t.Xsiz/e.XRsiz);e.y0=Math.ceil(t.YOsiz/e.YRsiz);e.y1=Math.ceil(t.Ysiz/e.YRsiz);e.width=e.x1-e.x0;e.height=e.y1-e.y0}function calculateTileGrids(e,t){for(var r,a=e.SIZ,i=[],n=Math.ceil((a.Xsiz-a.XTOsiz)/a.XTsiz),s=Math.ceil((a.Ysiz-a.YTOsiz)/a.YTsiz),o=0;o0?Math.min(a.xcb,i.PPx-1):Math.min(a.xcb,i.PPx);i.ycb_=r>0?Math.min(a.ycb,i.PPy-1):Math.min(a.ycb,i.PPy);return i}function buildPrecincts(e,t,r){var a=1<t.trx0?Math.ceil(t.trx1/a)-Math.floor(t.trx0/a):0,l=t.try1>t.try0?Math.ceil(t.try1/i)-Math.floor(t.try0/i):0,h=c*l;t.precinctParameters={precinctWidth:a,precinctHeight:i,numprecinctswide:c,numprecinctshigh:l,numprecincts:h,precinctWidthInSubband:s,precinctHeightInSubband:o}}function buildCodeblocks(e,t,r){var a,i,n,s,o=r.xcb_,c=r.ycb_,l=1<>o,d=t.tby0>>c,f=t.tbx1+l-1>>o,g=t.tby1+h-1>>c,m=t.resolution.precinctParameters,p=[],b=[];for(i=d;iy.cbxMax&&(y.cbxMax=a);iy.cbyMax&&(y.cbyMax=i)}else b[s]=y={cbxMin:a,cbyMin:i,cbxMax:a,cbyMax:i};n.precinct=y}}t.codeblockParameters={codeblockWidth:o,codeblockHeight:c,numcodeblockwide:f-u+1,numcodeblockhigh:g-d+1};t.codeblocks=p;t.precincts=b}function createPacket(e,t,r){for(var a=[],i=e.subbands,n=0,s=i.length;ne.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],r=t.precinctParameters.numprecincts;ue.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[c],r=t.precinctParameters.numprecincts;ul.codingStyleParameters.decompositionLevelsCount)){var e=l.resolutions[r],n=e.precinctParameters.numprecincts;if(!(i>=n)){for(;t=0;--p){var b=c.resolutions[p],y=m*b.precinctParameters.precinctWidth,v=m*b.precinctParameters.precinctHeight;u=Math.min(u,y);d=Math.min(d,v);f=Math.max(f,b.precinctParameters.numprecinctswide);g=Math.max(g,b.precinctParameters.numprecinctshigh);h[p]={width:y,height:v};m<<=1}r=Math.min(r,u);a=Math.min(a,d);i=Math.max(i,f);n=Math.max(n,g);s[o]={resolutions:h,minWidth:u,minHeight:d,maxNumWide:f,maxNumHigh:g}}return{components:s,minWidth:r,minHeight:a,maxNumWide:i,maxNumHigh:n}}function buildPackets(e){for(var t=e.SIZ,r=e.currentTile.index,a=e.tiles[r],i=t.Csiz,n=0;n>>(l-=e)&(1<0;){var D=v.shift();void 0===(b=D.codeblock).data&&(b.data=[]);b.data.push({data:a,start:n+c,end:n+c+D.dataLength,codingpasses:D.codingpasses});c+=D.dataLength}}}return c}function copyCoefficients(e,t,r,a,i,o,c,l){for(var h=a.tbx0,u=a.tby0,d=a.tbx1-a.tbx0,f=a.codeblocks,g="H"===a.type.charAt(0)?1:0,m="H"===a.type.charAt(1)?t:0,p=0,b=f.length;p=o?D:D*(1<0?1-v:0)}var F=w.subbands[x],P=e[F.type];copyCoefficients(C,k,0,F,m?1:2**(g+P-I)*(1+T/2048),d+I-1,m,f)}b.push({width:k,height:S,items:C})}var E=p.calculate(b,i.tcx0,i.tcy0);return{left:i.tcx0,top:i.tcy0,width:E.width,height:E.height,items:E.items}}function initializeTile(e,t){for(var r=e.SIZ.Csiz,a=e.tiles[t],i=0;i>=1;t>>=1;a++}a--;(r=this.levels[a]).items[r.index]=i;this.currentLevel=a;delete this.value},incrementValue:function TagTree_incrementValue(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function TagTree_nextLevel(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];if(--e<0){this.value=r;return!1}this.currentLevel=e;(t=this.levels[e]).items[t.index]=r;return!0}};return TagTree}(),r=function InclusionTreeClosure(){function InclusionTree(e,t,r){var a=(0,i.log2)(Math.max(e,t))+1;this.levels=[];for(var n=0;nr){this.currentLevel=a;this.propagateValues();return!1}e>>=1;t>>=1;a++}this.currentLevel=a-1;return!0},incrementValue:function InclusionTree_incrementValue(e){var t=this.levels[this.currentLevel];t.items[t.index]=e+1;this.propagateValues()},propagateValues:function InclusionTree_propagateValues(){for(var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];--e>=0;)(t=this.levels[e]).items[t.index]=r},nextLevel:function InclusionTree_nextLevel(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];t.items[t.index]=255;if(--e<0)return!1;this.currentLevel=e;(t=this.levels[e]).items[t.index]=r;return!0}};return InclusionTree}(),s=function BitModelClosure(){var e=new Uint8Array([0,5,8,0,3,7,8,0,4,7,8,0,0,0,0,0,1,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8]),t=new Uint8Array([0,3,4,0,5,7,7,0,8,8,8,0,0,0,0,0,1,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8]),r=new Uint8Array([0,1,2,0,1,2,2,0,2,2,2,0,0,0,0,0,3,4,5,0,4,5,5,0,5,5,5,0,0,0,0,0,6,7,7,0,7,7,7,0,7,7,7,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8]);function BitModel(a,i,n,s,o){this.width=a;this.height=i;let c;c="HH"===n?r:"HL"===n?t:e;this.contextLabelTable=c;var l=a*i;this.neighborsSignificance=new Uint8Array(l);this.coefficentsSign=new Uint8Array(l);let h;h=o>14?new Uint32Array(l):o>6?new Uint16Array(l):new Uint8Array(l);this.coefficentsMagnitude=h;this.processingFlags=new Uint8Array(l);var u=new Uint8Array(l);if(0!==s)for(var d=0;d0,c=t+10){a=r-n;o&&(i[a-1]+=16);c&&(i[a+1]+=16);i[a]+=4}if(e+1=r)break;s[d]&=-2;if(!a[d]&&n[d]){var m=c[n[d]];if(e.readBit(o,m)){var p=this.decodeSignBit(g,u,d);i[d]=p;a[d]=1;this.setNeighborsSignificance(g,u,d);s[d]|=2}l[d]++;s[d]|=1}}},decodeSignBit:function BitModel_decodeSignBit(e,t,r){var a,i,n,s,o,c,l=this.width,h=this.height,u=this.coefficentsMagnitude,d=this.coefficentsSign;s=t>0&&0!==u[r-1];if(t+10&&0!==u[r-l];if(e+1=0){o=9+a;c=this.decoder.readBit(this.contexts,o)}else{o=9-a;c=1^this.decoder.readBit(this.contexts,o)}return c},runMagnitudeRefinementPass:function BitModel_runMagnitudeRefinementPass(){for(var e,t=this.decoder,r=this.width,a=this.height,i=this.coefficentsMagnitude,n=this.neighborsSignificance,s=this.contexts,o=this.bitsDecoded,c=this.processingFlags,l=r*a,h=4*r,u=0;u>1,c=-1.586134342059924,l=-.052980118572961,h=.882911075530934,u=.443506852043971,d=1.230174104914001;a=(t|=0)-3;for(i=o+4;i--;a+=2)e[a]*=.8128930661159609;n=u*e[(a=t-2)-1];for(i=o+3;i--;a+=2){s=u*e[a+1];e[a]=d*e[a]-n-s;if(!i--)break;n=u*e[(a+=2)+1];e[a]=d*e[a]-n-s}n=h*e[(a=t-1)-1];for(i=o+2;i--;a+=2){s=h*e[a+1];e[a]-=n+s;if(!i--)break;n=h*e[(a+=2)+1];e[a]-=n+s}n=l*e[(a=t)-1];for(i=o+1;i--;a+=2){s=l*e[a+1];e[a]-=n+s;if(!i--)break;n=l*e[(a+=2)+1];e[a]-=n+s}if(0!==o){n=c*e[(a=t+1)-1];for(i=o;i--;a+=2){s=c*e[a+1];e[a]-=n+s;if(!i--)break;n=c*e[(a+=2)+1];e[a]-=n+s}}};return IrreversibleTransform}(),l=function ReversibleTransformClosure(){function ReversibleTransform(){o.call(this)}ReversibleTransform.prototype=Object.create(o.prototype);ReversibleTransform.prototype.filter=function reversibleTransformFilter(e,t,r){var a,i,n=r>>1;for(a=t|=0,i=n+1;i--;a+=2)e[a]-=e[a-1]+e[a+1]+2>>2;for(a=t+1,i=n;i--;a+=2)e[a]+=e[a-1]+e[a+1]>>1};return ReversibleTransform}();return JpxImage}();t.JpxImage=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.calculateSHA512=t.calculateSHA384=t.calculateSHA256=t.calculateMD5=t.PDF20=t.PDF17=t.CipherTransformFactory=t.ARCFourCipher=t.AES256Cipher=t.AES128Cipher=void 0;var a=r(2),i=r(5),n=r(12),s=function ARCFourCipherClosure(){function ARCFourCipher(e){this.a=0;this.b=0;var t,r,a=new Uint8Array(256),i=0,n=e.length;for(t=0;t<256;++t)a[t]=t;for(t=0;t<256;++t){i=i+(r=a[t])+e[t%n]&255;a[t]=a[i];a[i]=r}this.s=a}ARCFourCipher.prototype={encryptBlock:function ARCFourCipher_encryptBlock(e){var t,r,a,i=e.length,n=this.a,s=this.b,o=this.s,c=new Uint8Array(i);for(t=0;t>5&255;f[n++]=i>>13&255;f[n++]=i>>21&255;f[n++]=i>>>29&255;f[n++]=0;f[n++]=0;f[n++]=0;var g=new Int32Array(16);for(n=0;n>>32-C)|0;b=k}c=c+b|0;l=l+y|0;h=h+v|0;u=u+w|0}return new Uint8Array([255&c,c>>8&255,c>>16&255,c>>>24&255,255&l,l>>8&255,l>>16&255,l>>>24&255,255&h,h>>8&255,h>>16&255,h>>>24&255,255&u,u>>8&255,u>>16&255,u>>>24&255])}}();t.calculateMD5=o;var c=function Word64Closure(){function Word64(e,t){this.high=0|e;this.low=0|t}Word64.prototype={and:function Word64_and(e){this.high&=e.high;this.low&=e.low},xor:function Word64_xor(e){this.high^=e.high;this.low^=e.low},or:function Word64_or(e){this.high|=e.high;this.low|=e.low},shiftRight:function Word64_shiftRight(e){if(e>=32){this.low=this.high>>>e-32|0;this.high=0}else{this.low=this.low>>>e|this.high<<32-e;this.high=this.high>>>e|0}},shiftLeft:function Word64_shiftLeft(e){if(e>=32){this.high=this.low<>>32-e;this.low=this.low<>>e|r<<32-e;this.high=r>>>e|t<<32-e},not:function Word64_not(){this.high=~this.high;this.low=~this.low},add:function Word64_add(e){var t=(this.low>>>0)+(e.low>>>0),r=(this.high>>>0)+(e.high>>>0);t>4294967295&&(r+=1);this.low=0|t;this.high=0|r},copyTo:function Word64_copyTo(e,t){e[t]=this.high>>>24&255;e[t+1]=this.high>>16&255;e[t+2]=this.high>>8&255;e[t+3]=255&this.high;e[t+4]=this.low>>>24&255;e[t+5]=this.low>>16&255;e[t+6]=this.low>>8&255;e[t+7]=255&this.low},assign:function Word64_assign(e){this.high=e.high;this.low=e.low}};return Word64}(),l=function calculateSHA256Closure(){function rotr(e,t){return e>>>t|e<<32-t}function ch(e,t,r){return e&t^~e&r}function maj(e,t,r){return e&t^e&r^t&r}function sigma(e){return rotr(e,2)^rotr(e,13)^rotr(e,22)}function sigmaPrime(e){return rotr(e,6)^rotr(e,11)^rotr(e,25)}function littleSigma(e){return rotr(e,7)^rotr(e,18)^e>>>3}var e=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];return function hash(t,r,a){var i,n,s,o=1779033703,c=3144134277,l=1013904242,h=2773480762,u=1359893119,d=2600822924,f=528734635,g=1541459225,m=64*Math.ceil((a+9)/64),p=new Uint8Array(m);for(i=0;i>>29&255;p[i++]=a>>21&255;p[i++]=a>>13&255;p[i++]=a>>5&255;p[i++]=a<<3&255;var b,y=new Uint32Array(64);for(i=0;i>>10)+y[n-7]+littleSigma(y[n-15])+y[n-16]|0;var v,w,k=o,S=c,C=l,x=h,A=u,T=d,I=f,F=g;for(n=0;n<64;++n){v=F+sigmaPrime(A)+ch(A,T,I)+e[n]+y[n];w=sigma(k)+maj(k,S,C);F=I;I=T;T=A;A=x+v|0;x=C;C=S;S=k;k=v+w|0}o=o+k|0;c=c+S|0;l=l+C|0;h=h+x|0;u=u+A|0;d=d+T|0;f=f+I|0;g=g+F|0}return new Uint8Array([o>>24&255,o>>16&255,o>>8&255,255&o,c>>24&255,c>>16&255,c>>8&255,255&c,l>>24&255,l>>16&255,l>>8&255,255&l,h>>24&255,h>>16&255,h>>8&255,255&h,u>>24&255,u>>16&255,u>>8&255,255&u,d>>24&255,d>>16&255,d>>8&255,255&d,f>>24&255,f>>16&255,f>>8&255,255&f,g>>24&255,g>>16&255,g>>8&255,255&g])}}();t.calculateSHA256=l;var h=function calculateSHA512Closure(){function ch(e,t,r,a,i){e.assign(t);e.and(r);i.assign(t);i.not();i.and(a);e.xor(i)}function maj(e,t,r,a,i){e.assign(t);e.and(r);i.assign(t);i.and(a);e.xor(i);i.assign(r);i.and(a);e.xor(i)}function sigma(e,t,r){e.assign(t);e.rotateRight(28);r.assign(t);r.rotateRight(34);e.xor(r);r.assign(t);r.rotateRight(39);e.xor(r)}function sigmaPrime(e,t,r){e.assign(t);e.rotateRight(14);r.assign(t);r.rotateRight(18);e.xor(r);r.assign(t);r.rotateRight(41);e.xor(r)}function littleSigma(e,t,r){e.assign(t);e.rotateRight(1);r.assign(t);r.rotateRight(8);e.xor(r);r.assign(t);r.shiftRight(7);e.xor(r)}function littleSigmaPrime(e,t,r){e.assign(t);e.rotateRight(19);r.assign(t);r.rotateRight(61);e.xor(r);r.assign(t);r.shiftRight(6);e.xor(r)}var e=[new c(1116352408,3609767458),new c(1899447441,602891725),new c(3049323471,3964484399),new c(3921009573,2173295548),new c(961987163,4081628472),new c(1508970993,3053834265),new c(2453635748,2937671579),new c(2870763221,3664609560),new c(3624381080,2734883394),new c(310598401,1164996542),new c(607225278,1323610764),new c(1426881987,3590304994),new c(1925078388,4068182383),new c(2162078206,991336113),new c(2614888103,633803317),new c(3248222580,3479774868),new c(3835390401,2666613458),new c(4022224774,944711139),new c(264347078,2341262773),new c(604807628,2007800933),new c(770255983,1495990901),new c(1249150122,1856431235),new c(1555081692,3175218132),new c(1996064986,2198950837),new c(2554220882,3999719339),new c(2821834349,766784016),new c(2952996808,2566594879),new c(3210313671,3203337956),new c(3336571891,1034457026),new c(3584528711,2466948901),new c(113926993,3758326383),new c(338241895,168717936),new c(666307205,1188179964),new c(773529912,1546045734),new c(1294757372,1522805485),new c(1396182291,2643833823),new c(1695183700,2343527390),new c(1986661051,1014477480),new c(2177026350,1206759142),new c(2456956037,344077627),new c(2730485921,1290863460),new c(2820302411,3158454273),new c(3259730800,3505952657),new c(3345764771,106217008),new c(3516065817,3606008344),new c(3600352804,1432725776),new c(4094571909,1467031594),new c(275423344,851169720),new c(430227734,3100823752),new c(506948616,1363258195),new c(659060556,3750685593),new c(883997877,3785050280),new c(958139571,3318307427),new c(1322822218,3812723403),new c(1537002063,2003034995),new c(1747873779,3602036899),new c(1955562222,1575990012),new c(2024104815,1125592928),new c(2227730452,2716904306),new c(2361852424,442776044),new c(2428436474,593698344),new c(2756734187,3733110249),new c(3204031479,2999351573),new c(3329325298,3815920427),new c(3391569614,3928383900),new c(3515267271,566280711),new c(3940187606,3454069534),new c(4118630271,4000239992),new c(116418474,1914138554),new c(174292421,2731055270),new c(289380356,3203993006),new c(460393269,320620315),new c(685471733,587496836),new c(852142971,1086792851),new c(1017036298,365543100),new c(1126000580,2618297676),new c(1288033470,3409855158),new c(1501505948,4234509866),new c(1607167915,987167468),new c(1816402316,1246189591)];return function hash(t,r,a,i){var n,s,o,l,h,u,d,f;if(i=!!i){n=new c(3418070365,3238371032);s=new c(1654270250,914150663);o=new c(2438529370,812702999);l=new c(355462360,4144912697);h=new c(1731405415,4290775857);u=new c(2394180231,1750603025);d=new c(3675008525,1694076839);f=new c(1203062813,3204075428)}else{n=new c(1779033703,4089235720);s=new c(3144134277,2227873595);o=new c(1013904242,4271175723);l=new c(2773480762,1595750129);h=new c(1359893119,2917565137);u=new c(2600822924,725511199);d=new c(528734635,4215389547);f=new c(1541459225,327033209)}var g,m,p,b=128*Math.ceil((a+17)/128),y=new Uint8Array(b);for(g=0;g>>29&255;y[g++]=a>>21&255;y[g++]=a>>13&255;y[g++]=a>>5&255;y[g++]=a<<3&255;var v=new Array(80);for(g=0;g<80;g++)v[g]=new c(0,0);var w,k,S=new c(0,0),C=new c(0,0),x=new c(0,0),A=new c(0,0),T=new c(0,0),I=new c(0,0),F=new c(0,0),P=new c(0,0),E=new c(0,0),B=new c(0,0),O=new c(0,0),M=new c(0,0);for(g=0;g=1;--e){r=n[13];n[13]=n[9];n[9]=n[5];n[5]=n[1];n[1]=r;r=n[14];a=n[10];n[14]=n[6];n[10]=n[2];n[6]=r;n[2]=a;r=n[15];a=n[11];i=n[7];n[15]=n[3];n[11]=r;n[7]=a;n[3]=i;for(let e=0;e<16;++e)n[e]=this._inv_s[n[e]];for(let r=0,a=16*e;r<16;++r,++a)n[r]^=t[a];for(let e=0;e<16;e+=4){const t=this._mix[n[e]],a=this._mix[n[e+1]],i=this._mix[n[e+2]],s=this._mix[n[e+3]];r=t^a>>>8^a<<24^i>>>16^i<<16^s>>>24^s<<8;n[e]=r>>>24&255;n[e+1]=r>>16&255;n[e+2]=r>>8&255;n[e+3]=255&r}}r=n[13];n[13]=n[9];n[9]=n[5];n[5]=n[1];n[1]=r;r=n[14];a=n[10];n[14]=n[6];n[10]=n[2];n[6]=r;n[2]=a;r=n[15];a=n[11];i=n[7];n[15]=n[3];n[11]=r;n[7]=a;n[3]=i;for(let e=0;e<16;++e){n[e]=this._inv_s[n[e]];n[e]^=t[e]}return n}_encrypt(e,t){const r=this._s;let a,i,n;const s=new Uint8Array(16);s.set(e);for(let e=0;e<16;++e)s[e]^=t[e];for(let e=1;e=a;--r)if(e[r]!==t){t=0;break}o-=t;n[n.length-1]=e.subarray(0,16-t)}}const c=new Uint8Array(o);for(let e=0,t=0,r=n.length;e=256&&(o=255&(27^o))}for(let t=0;t<4;++t){r[e]=a^=r[e-32];e++;r[e]=i^=r[e-32];e++;r[e]=n^=r[e-32];e++;r[e]=s^=r[e-32];e++}}return r}}t.AES256Cipher=AES256Cipher;var f=function PDF17Closure(){function compareByteArrays(e,t){if(e.length!==t.length)return!1;for(var r=0;rn-32;){var s=e.length+a.length+r.length,o=new Uint8Array(64*s),c=concatArrays(e,a);c=concatArrays(c,r);for(var d=0,f=0;d<64;d++,f+=s)o.set(c,f);i=new AES128Cipher(a.subarray(0,16)).encrypt(o,a.subarray(16,32));for(var g=0,m=0;m<16;m++){g*=1;g%=3;g+=(i[m]>>>0)%3;g%=3}0===g?a=l(i,0,i.length):1===g?a=u(i,0,i.length):2===g&&(a=h(i,0,i.length));n++}return a.subarray(0,32)}function PDF20(){}function compareByteArrays(e,t){if(e.length!==t.length)return!1;for(var r=0;r>8&255;g[m++]=n>>16&255;g[m++]=n>>>24&255;for(u=0,d=t.length;u=4&&!h){g[m++]=255;g[m++]=255;g[m++]=255;g[m++]=255}var p=o(g,0,m),b=l>>3;if(c>=3)for(u=0;u<50;++u)p=o(p,0,b);var y,v=p.subarray(0,b);if(c>=3){for(m=0;m<32;++m)g[m]=e[m];for(u=0,d=t.length;u>3;if(a>=3)for(n=0;n<50;++n)d=o(d,0,d.length);if(a>=3){u=r;var g,m=new Uint8Array(f);for(n=19;n>=0;n--){for(g=0;g=4){var O=r.get("CF");(0,i.isDict)(O)&&(O.suppressEncryption=!0);this.cf=O;this.stmf=r.get("StmF")||t;this.strf=r.get("StrF")||t;this.eff=r.get("EFF")||this.stmf}}function buildObjectKey(e,t,r,a){var i,n,s=new Uint8Array(r.length+9);for(i=0,n=r.length;i>8&255;s[i++]=e>>16&255;s[i++]=255&t;s[i++]=t>>8&255;if(a){s[i++]=115;s[i++]=65;s[i++]=108;s[i++]=84}return o(s,0,i).subarray(0,Math.min(r.length+5,16))}function buildCipherConstructor(e,t,r,n,o){if(!(0,i.isName)(t))throw new a.FormatError("Invalid crypt filter name.");var c,l=e.get(t.name);null!=l&&(c=l.get("CFM"));if(!c||"None"===c.name)return function cipherTransformFactoryBuildCipherConstructorNone(){return new d};if("V2"===c.name)return function cipherTransformFactoryBuildCipherConstructorV2(){return new s(buildObjectKey(r,n,o,!1))};if("AESV2"===c.name)return function cipherTransformFactoryBuildCipherConstructorAESV2(){return new AES128Cipher(buildObjectKey(r,n,o,!0))};if("AESV3"===c.name)return function cipherTransformFactoryBuildCipherConstructorAESV3(){return new AES256Cipher(o)};throw new a.FormatError("Unknown crypto method")}CipherTransformFactory.prototype={createCipherTransform:function CipherTransformFactory_createCipherTransform(e,t){if(4===this.algorithm||5===this.algorithm)return new m(buildCipherConstructor(this.cf,this.stmf,e,t,this.encryptionKey),buildCipherConstructor(this.cf,this.strf,e,t,this.encryptionKey));var r=buildObjectKey(e,t,this.encryptionKey,!1),a=function buildCipherCipherConstructor(){return new s(r)};return new m(a,a)}};return CipherTransformFactory}();t.CipherTransformFactory=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ColorSpace=void 0;var a=r(2),i=r(5),n=r(8);class ColorSpace{constructor(e,t){this.constructor===ColorSpace&&(0,a.unreachable)("Cannot initialize ColorSpace.");this.name=e;this.numComps=t}getRgb(e,t){const r=new Uint8ClampedArray(3);this.getRgbItem(e,t,r,0);return r}getRgbItem(e,t,r,i){(0,a.unreachable)("Should not call ColorSpace.getRgbItem")}getRgbBuffer(e,t,r,i,n,s,o){(0,a.unreachable)("Should not call ColorSpace.getRgbBuffer")}getOutputLength(e,t){(0,a.unreachable)("Should not call ColorSpace.getOutputLength")}isPassthrough(e){return!1}isDefaultDecode(e,t){return ColorSpace.isDefaultDecode(e,this.numComps)}fillRgb(e,t,r,a,i,n,s,o,c){const l=t*r;let h=null;const u=1<u&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){const t=s<=8?new Uint8Array(u):new Uint16Array(u);for(let e=0;e=.99554525?1:adjustToRange(0,1,1.055*e**(1/2.4)-.055)}function adjustToRange(e,t,r){return Math.max(e,Math.min(t,r))}function decodeL(e){return e<0?-decodeL(-e):e>8?((e+16)/116)**3:e*((24/116)**3/8)}function convertToRgb(a,c,l,h,u,d){const f=adjustToRange(0,1,c[l]*d),g=adjustToRange(0,1,c[l+1]*d),m=adjustToRange(0,1,c[l+2]*d),p=1===f?1:f**a.GR,b=1===g?1:g**a.GG,y=1===m?1:m**a.GB,v=a.MXA*p+a.MXB*b+a.MXC*y,w=a.MYA*p+a.MYB*b+a.MYC*y,k=a.MZA*p+a.MZB*b+a.MZC*y,S=s;S[0]=v;S[1]=w;S[2]=k;const C=o;!function normalizeWhitePointToFlat(r,a,i){if(1===r[0]&&1===r[2]){i[0]=a[0];i[1]=a[1];i[2]=a[2];return}const s=i;matrixProduct(e,a,s);const o=n;!function convertToFlat(e,t,r){r[0]=1*t[0]/e[0];r[1]=1*t[1]/e[1];r[2]=1*t[2]/e[2]}(r,s,o);matrixProduct(t,o,i)}(a.whitePoint,S,C);const x=s;!function compensateBlackPoint(e,t,r){if(0===e[0]&&0===e[1]&&0===e[2]){r[0]=t[0];r[1]=t[1];r[2]=t[2];return}const a=decodeL(0),i=(1-a)/(1-decodeL(e[0])),n=1-i,s=(1-a)/(1-decodeL(e[1])),o=1-s,c=(1-a)/(1-decodeL(e[2])),l=1-c;r[0]=t[0]*i+n;r[1]=t[1]*s+o;r[2]=t[2]*c+l}(a.blackPoint,C,x);const A=o;!function normalizeWhitePointToD65(r,a,i){const s=i;matrixProduct(e,a,s);const o=n;!function convertToD65(e,t,r){r[0]=.95047*t[0]/e[0];r[1]=1*t[1]/e[1];r[2]=1.08883*t[2]/e[2]}(r,s,o);matrixProduct(t,o,i)}(i,x,A);const T=s;matrixProduct(r,A,T);h[u]=255*sRGBTransferFunction(T[0]);h[u+1]=255*sRGBTransferFunction(T[1]);h[u+2]=255*sRGBTransferFunction(T[2])}return class CalRGBCS extends ColorSpace{constructor(e,t,r,i){super("CalRGB",3);if(!e)throw new a.FormatError("WhitePoint missing - required for color space CalRGB");t=t||new Float32Array(3);r=r||new Float32Array([1,1,1]);i=i||new Float32Array([1,0,0,0,1,0,0,0,1]);const n=e[0],s=e[1],o=e[2];this.whitePoint=e;const c=t[0],l=t[1],h=t[2];this.blackPoint=t;this.GR=r[0];this.GG=r[1];this.GB=r[2];this.MXA=i[0];this.MYA=i[1];this.MZA=i[2];this.MXB=i[3];this.MYB=i[4];this.MZB=i[5];this.MXC=i[6];this.MYC=i[7];this.MZC=i[8];if(n<0||o<0||1!==s)throw new a.FormatError("Invalid WhitePoint components for "+this.name+", no fallback available");if(c<0||l<0||h<0){(0,a.info)(`Invalid BlackPoint for ${this.name} [${c}, ${l}, ${h}], falling back to default.`);this.blackPoint=new Float32Array(3)}if(this.GR<0||this.GG<0||this.GB<0){(0,a.info)(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for `+this.name+", falling back to default.");this.GR=this.GG=this.GB=1}}getRgbItem(e,t,r,a){convertToRgb(this,e,t,r,a,1)}getRgbBuffer(e,t,r,a,i,n,s){const o=1/((1<=6/29?e*e*e:108/841*(e-4/29);return t}function decode(e,t,r,a){return r+e*(a-r)/t}function convertToRgb(e,t,r,a,i,n){let s=t[r],o=t[r+1],c=t[r+2];if(!1!==a){s=decode(s,a,0,100);o=decode(o,a,e.amin,e.amax);c=decode(c,a,e.bmin,e.bmax)}o>e.amax?o=e.amax:oe.bmax?c=e.bmax:cthis.amax||this.bmin>this.bmax){(0,a.info)("Invalid Range, falling back to defaults");this.amin=-100;this.amax=100;this.bmin=-100;this.bmax=100}}getRgbItem(e,t,r,a){convertToRgb(this,e,t,!1,r,a)}getRgbBuffer(e,t,r,a,i,n,s){const o=(1<=GlobalImageCache.MAX_IMAGES_TO_CACHE)}addPageIndex(e,t){let r=this._refCache.get(e);if(!r){r=new Set;this._refCache.put(e,r)}r.add(t)}getData(e,t){const r=this._refCache.get(e);if(!r)return null;if(r.size=GlobalImageCache.MAX_IMAGES_TO_CACHE?(0,a.info)("GlobalImageCache.setData - ignoring image above MAX_IMAGES_TO_CACHE."):this._imageCache.put(e,t))}clear(e=!1){e||this._refCache.clear();this._imageCache.clear()}}t.GlobalImageCache=GlobalImageCache},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.getQuadPoints=getQuadPoints;t.MarkupAnnotation=t.AnnotationFactory=t.AnnotationBorderStyle=t.Annotation=void 0;var a=r(2),i=r(10),n=r(5),s=r(23),o=r(8),c=r(26),l=r(12),h=r(27);t.AnnotationFactory=class AnnotationFactory{static create(e,t,r,a){return r.ensureCatalog("acroForm").then(i=>r.ensure(this,"_create",[e,t,r,a,i]))}static _create(e,t,r,i,s){const c=e.fetchIfRef(t);if(!(0,n.isDict)(c))return;const l=(0,n.isRef)(t)?t.toString():"annot_"+i.createObjId();let h=c.get("Subtype");h=(0,n.isName)(h)?h.name:null;const u={xref:e,ref:t,dict:c,subtype:h,id:l,pdfManager:r,acroForm:s instanceof n.Dict?s:n.Dict.empty};switch(h){case"Link":return new LinkAnnotation(u);case"Text":return new TextAnnotation(u);case"Widget":let e=(0,o.getInheritableProperty)({dict:c,key:"FT"});e=(0,n.isName)(e)?e.name:null;switch(e){case"Tx":return new TextWidgetAnnotation(u);case"Btn":return new ButtonWidgetAnnotation(u);case"Ch":return new ChoiceWidgetAnnotation(u)}(0,a.warn)('Unimplemented widget field type "'+e+'", falling back to base field type.');return new WidgetAnnotation(u);case"Popup":return new PopupAnnotation(u);case"FreeText":return new FreeTextAnnotation(u);case"Line":return new LineAnnotation(u);case"Square":return new SquareAnnotation(u);case"Circle":return new CircleAnnotation(u);case"PolyLine":return new PolylineAnnotation(u);case"Polygon":return new PolygonAnnotation(u);case"Caret":return new CaretAnnotation(u);case"Ink":return new InkAnnotation(u);case"Highlight":return new HighlightAnnotation(u);case"Underline":return new UnderlineAnnotation(u);case"Squiggly":return new SquigglyAnnotation(u);case"StrikeOut":return new StrikeOutAnnotation(u);case"Stamp":return new StampAnnotation(u);case"FileAttachment":return new FileAttachmentAnnotation(u);default:h?(0,a.warn)('Unimplemented annotation type "'+h+'", falling back to base annotation.'):(0,a.warn)("Annotation is missing the required /Subtype.");return new Annotation(u)}}};function getQuadPoints(e,t){if(!e.has("QuadPoints"))return null;const r=e.getArray("QuadPoints");if(!Array.isArray(r)||r.length%8>0)return null;const a=[];for(let e=0,i=r.length/8;et[2]||st[3])return null;a[e].push({x:n,y:s})}}return a}function getTransformMatrix(e,t,r){const[i,n,s,o]=a.Util.getAxialAlignedBoundingBox(t,r);if(i===s||n===o)return[1,0,0,1,e[0],e[1]];const c=(e[2]-e[0])/(s-i),l=(e[3]-e[1])/(o-n);return[c,0,0,l,e[0]-i*c,e[1]-n*l]}class Annotation{constructor(e){const t=e.dict;this.setContents(t.get("Contents"));this.setModificationDate(t.get("M"));this.setFlags(t.get("F"));this.setRectangle(t.getArray("Rect"));this.setColor(t.getArray("C"));this.setBorderStyle(t);this.setAppearance(t);this.data={annotationFlags:this.flags,borderStyle:this.borderStyle,color:this.color,contents:this.contents,hasAppearance:!!this.appearance,id:e.id,modificationDate:this.modificationDate,rect:this.rectangle,subtype:e.subtype}}_hasFlag(e,t){return!!(e&t)}_isViewable(e){return!this._hasFlag(e,a.AnnotationFlag.INVISIBLE)&&!this._hasFlag(e,a.AnnotationFlag.HIDDEN)&&!this._hasFlag(e,a.AnnotationFlag.NOVIEW)}_isPrintable(e){return this._hasFlag(e,a.AnnotationFlag.PRINT)&&!this._hasFlag(e,a.AnnotationFlag.INVISIBLE)&&!this._hasFlag(e,a.AnnotationFlag.HIDDEN)}get viewable(){return 0===this.flags||this._isViewable(this.flags)}get printable(){return 0!==this.flags&&this._isPrintable(this.flags)}setContents(e){this.contents=(0,a.stringToPDFString)(e||"")}setModificationDate(e){this.modificationDate=(0,a.isString)(e)?e:null}setFlags(e){this.flags=Number.isInteger(e)&&e>0?e:0}hasFlag(e){return this._hasFlag(this.flags,e)}setRectangle(e){Array.isArray(e)&&4===e.length?this.rectangle=a.Util.normalizeRect(e):this.rectangle=[0,0,0,0]}setColor(e){const t=new Uint8ClampedArray(3);if(Array.isArray(e))switch(e.length){case 0:this.color=null;break;case 1:s.ColorSpace.singletons.gray.getRgbItem(e,0,t,0);this.color=t;break;case 3:s.ColorSpace.singletons.rgb.getRgbItem(e,0,t,0);this.color=t;break;case 4:s.ColorSpace.singletons.cmyk.getRgbItem(e,0,t,0);this.color=t;break;default:this.color=t}else this.color=t}setBorderStyle(e){this.borderStyle=new AnnotationBorderStyle;if((0,n.isDict)(e))if(e.has("BS")){const t=e.get("BS"),r=t.get("Type");if(!r||(0,n.isName)(r,"Border")){this.borderStyle.setWidth(t.get("W"),this.rectangle);this.borderStyle.setStyle(t.get("S"));this.borderStyle.setDashArray(t.getArray("D"))}}else if(e.has("Border")){const t=e.getArray("Border");if(Array.isArray(t)&&t.length>=3){this.borderStyle.setHorizontalCornerRadius(t[0]);this.borderStyle.setVerticalCornerRadius(t[1]);this.borderStyle.setWidth(t[2],this.rectangle);4===t.length&&this.borderStyle.setDashArray(t[3])}}else this.borderStyle.setWidth(0)}setAppearance(e){this.appearance=null;const t=e.get("AP");if(!(0,n.isDict)(t))return;const r=t.get("N");if((0,n.isStream)(r)){this.appearance=r;return}if(!(0,n.isDict)(r))return;const a=e.get("AS");(0,n.isName)(a)&&r.has(a.name)&&(this.appearance=r.get(a.name))}loadResources(e){return this.appearance.dict.getAsync("Resources").then(t=>{if(!t)return;return new i.ObjectLoader(t,e,t.xref).load().then((function(){return t}))})}getOperatorList(e,t,r,i){if(!this.appearance)return Promise.resolve(new c.OperatorList);const n=this.appearance,s=this.data,o=n.dict,l=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),h=o.getArray("BBox")||[0,0,1,1],u=o.getArray("Matrix")||[1,0,0,1,0,0],d=getTransformMatrix(s.rect,h,u);return l.then(r=>{const i=new c.OperatorList;i.addOp(a.OPS.beginAnnotation,[s.rect,d,u]);return e.getOperatorList({stream:n,task:t,resources:r,operatorList:i}).then(()=>{i.addOp(a.OPS.endAnnotation,[]);n.reset();return i})})}async save(e,t,r){return null}}t.Annotation=Annotation;class AnnotationBorderStyle{constructor(){this.width=1;this.style=a.AnnotationBorderStyleType.SOLID;this.dashArray=[3];this.horizontalCornerRadius=0;this.verticalCornerRadius=0}setWidth(e,t=[0,0,0,0]){if((0,n.isName)(e))this.width=0;else if(Number.isInteger(e)){if(e>0){const r=(t[2]-t[0])/2,i=(t[3]-t[1])/2;if(r>0&&i>0&&(e>r||e>i)){(0,a.warn)("AnnotationBorderStyle.setWidth - ignoring width: "+e);e=1}}this.width=e}}setStyle(e){if((0,n.isName)(e))switch(e.name){case"S":this.style=a.AnnotationBorderStyleType.SOLID;break;case"D":this.style=a.AnnotationBorderStyleType.DASHED;break;case"B":this.style=a.AnnotationBorderStyleType.BEVELED;break;case"I":this.style=a.AnnotationBorderStyleType.INSET;break;case"U":this.style=a.AnnotationBorderStyleType.UNDERLINE}}setDashArray(e){if(Array.isArray(e)&&e.length>0){let t=!0,r=!0;for(const a of e){if(!(+a>=0)){t=!1;break}a>0&&(r=!1)}t&&!r?this.dashArray=e:this.width=0}else e&&(this.width=0)}setHorizontalCornerRadius(e){Number.isInteger(e)&&(this.horizontalCornerRadius=e)}setVerticalCornerRadius(e){Number.isInteger(e)&&(this.verticalCornerRadius=e)}}t.AnnotationBorderStyle=AnnotationBorderStyle;class MarkupAnnotation extends Annotation{constructor(e){super(e);const t=e.dict;if(t.has("IRT")){const e=t.getRaw("IRT");this.data.inReplyTo=(0,n.isRef)(e)?e.toString():null;const r=t.get("RT");this.data.replyType=(0,n.isName)(r)?r.name:a.AnnotationReplyType.REPLY}if(this.data.replyType===a.AnnotationReplyType.GROUP){const e=t.get("IRT");this.data.title=(0,a.stringToPDFString)(e.get("T")||"");this.setContents(e.get("Contents"));this.data.contents=this.contents;if(e.has("CreationDate")){this.setCreationDate(e.get("CreationDate"));this.data.creationDate=this.creationDate}else this.data.creationDate=null;if(e.has("M")){this.setModificationDate(e.get("M"));this.data.modificationDate=this.modificationDate}else this.data.modificationDate=null;this.data.hasPopup=e.has("Popup");if(e.has("C")){this.setColor(e.getArray("C"));this.data.color=this.color}else this.data.color=null}else{this.data.title=(0,a.stringToPDFString)(t.get("T")||"");this.setCreationDate(t.get("CreationDate"));this.data.creationDate=this.creationDate;this.data.hasPopup=t.has("Popup");t.has("C")||(this.data.color=null)}}setCreationDate(e){this.creationDate=(0,a.isString)(e)?e:null}}t.MarkupAnnotation=MarkupAnnotation;class WidgetAnnotation extends Annotation{constructor(e){super(e);const t=e.dict,r=this.data;this.ref=e.ref;r.annotationType=a.AnnotationType.WIDGET;r.fieldName=this._constructFieldName(t);const i=(0,o.getInheritableProperty)({dict:t,key:"V",getArray:!0});r.fieldValue=this._decodeFormValue(i);r.alternativeText=(0,a.stringToPDFString)(t.get("TU")||"");r.defaultAppearance=(0,o.getInheritableProperty)({dict:t,key:"DA"})||e.acroForm.get("DA")||"";const s=(0,o.getInheritableProperty)({dict:t,key:"FT"});r.fieldType=(0,n.isName)(s)?s.name:null;this.fieldResources=(0,o.getInheritableProperty)({dict:t,key:"DR"})||e.acroForm.get("DR")||n.Dict.empty;r.fieldFlags=(0,o.getInheritableProperty)({dict:t,key:"Ff"});(!Number.isInteger(r.fieldFlags)||r.fieldFlags<0)&&(r.fieldFlags=0);r.readOnly=this.hasFieldFlag(a.AnnotationFieldFlag.READONLY);if("Sig"===r.fieldType){r.fieldValue=null;this.setFlags(a.AnnotationFlag.HIDDEN)}}_constructFieldName(e){if(!e.has("T")&&!e.has("Parent")){(0,a.warn)("Unknown field name, falling back to empty field name.");return""}if(!e.has("Parent"))return(0,a.stringToPDFString)(e.get("T"));const t=[];e.has("T")&&t.unshift((0,a.stringToPDFString)(e.get("T")));let r=e;for(;r.has("Parent");){r=r.get("Parent");if(!(0,n.isDict)(r))break;r.has("T")&&t.unshift((0,a.stringToPDFString)(r.get("T")))}return t.join(".")}_decodeFormValue(e){return Array.isArray(e)?e.filter(e=>(0,a.isString)(e)).map(e=>(0,a.stringToPDFString)(e)):(0,n.isName)(e)?(0,a.stringToPDFString)(e.name):(0,a.isString)(e)?(0,a.stringToPDFString)(e):null}hasFieldFlag(e){return!!(this.data.fieldFlags&e)}getOperatorList(e,t,r,i){return r?Promise.resolve(new c.OperatorList):this._hasText?this._getAppearance(e,t,i).then(n=>{if(this.appearance&&null===n)return super.getOperatorList(e,t,r,i);const s=new c.OperatorList;if(!this.data.defaultAppearance||null===n)return s;const o=[1,0,0,1,0,0],h=[0,0,this.data.rect[2]-this.data.rect[0],this.data.rect[3]-this.data.rect[1]],u=getTransformMatrix(this.data.rect,h,o);s.addOp(a.OPS.beginAnnotation,[this.data.rect,u,o]);const d=new l.StringStream(n);return e.getOperatorList({stream:d,task:t,resources:this.fieldResources,operatorList:s}).then((function(){s.addOp(a.OPS.endAnnotation,[]);return s}))}):super.getOperatorList(e,t,r,i)}async save(e,t,r){if(this.data.fieldValue===r[this.data.id])return null;let i=await this._getAppearance(e,t,r);if(null===i)return null;const s=e.xref.fetchIfRef(this.ref);if(!(0,n.isDict)(s))return null;const o=[0,0,this.data.rect[2]-this.data.rect[0],this.data.rect[3]-this.data.rect[1]],c=e.xref.getNewRef(),l=new n.Dict(e.xref);l.set("N",c);const u=r[this.data.id],d=e.xref.encrypt;let f=null,g=null;if(d){f=d.createCipherTransform(this.ref.num,this.ref.gen);g=d.createCipherTransform(c.num,c.gen);i=g.encryptString(i)}s.set("V",u);s.set("AP",l);s.set("M","D:"+(0,a.getModificationDate)());const m=new n.Dict(e.xref);m.set("Length",i.length);m.set("Subtype",n.Name.get("Form"));m.set("Resources",this.fieldResources);m.set("BBox",o);const p=[`${this.ref.num} ${this.ref.gen} obj\n`];(0,h.writeDict)(s,p,f);p.push("\nendobj\n");const b=[`${c.num} ${c.gen} obj\n`];(0,h.writeDict)(m,b,g);b.push(" stream\n");b.push(i);b.push("\nendstream\nendobj\n");return[{ref:this.ref,data:p.join("")},{ref:c,data:b.join("")}]}async _getAppearance(e,t,r){const i=this.hasFieldFlag(a.AnnotationFieldFlag.PASSWORD);if(!r||i)return null;const n=r[this.data.id];if(""===n)return"";const s=this.data.rect[3]-this.data.rect[1],o=this.data.rect[2]-this.data.rect[0],c=await this._getFontData(e,t),[l,h]=c;let u=c[2];u=this._computeFontSize(l,h,u,s);let d=l.descent;isNaN(d)&&(d=0);const f=2+Math.abs(d)*u,g=this.data.defaultAppearance,m=this.data.textAlignment;if(this.data.comb)return this._getCombAppearance(g,n,o,2,f);if(this.data.multiLine)return this._getMultilineAppearance(g,n,l,u,o,s,m,2,f);if(0===m||m>2)return"/Tx BMC q BT "+g+` 1 0 0 1 2 ${f} Tm (${(0,a.escapeString)(n)}) Tj ET Q EMC`;return"/Tx BMC q BT "+g+" 1 0 0 1 0 0 Tm "+this._renderText(n,l,u,o,m,2,f)+" ET Q EMC"}async _getFontData(e,t){const r=new c.OperatorList,a={fontSize:0,font:null,fontName:null,clone(){return this}};await e.getOperatorList({stream:new l.StringStream(this.data.defaultAppearance),task:t,resources:this.fieldResources,operatorList:r,initialState:a});return[a.font,a.fontName,a.fontSize]}_computeFontSize(e,t,r,a){if(null===r||0===r){const i=.7*(e.charsToGlyphs("M",!0)[0].width/1e3);r=Math.max(1,Math.floor(a/(1.5*i)));let n=new RegExp(`/${t}\\s+[0-9.]+\\s+Tf`);-1===this.data.defaultAppearance.search(n)&&(n=new RegExp(`/${t}\\s+Tf`));this.data.defaultAppearance=this.data.defaultAppearance.replace(n,`/${t} ${r} Tf`)}return r}_renderText(e,t,r,i,n,s,o){const c=t.charsToGlyphs(e),l=r/1e3;let h,u=0;for(const e of c)u+=e.width*l;h=1===n?(i-u)/2:2===n?i-u-s:s;h=h.toFixed(2);return`${h} ${o=o.toFixed(2)} Td (${(0,a.escapeString)(e)}) Tj`}}class TextWidgetAnnotation extends WidgetAnnotation{constructor(e){super(e);this._hasText=!0;const t=e.dict;(0,a.isString)(this.data.fieldValue)||(this.data.fieldValue="");let r=(0,o.getInheritableProperty)({dict:t,key:"Q"});(!Number.isInteger(r)||r<0||r>2)&&(r=null);this.data.textAlignment=r;let i=(0,o.getInheritableProperty)({dict:t,key:"MaxLen"});(!Number.isInteger(i)||i<0)&&(i=null);this.data.maxLen=i;this.data.multiLine=this.hasFieldFlag(a.AnnotationFieldFlag.MULTILINE);this.data.comb=this.hasFieldFlag(a.AnnotationFieldFlag.COMB)&&!this.hasFieldFlag(a.AnnotationFieldFlag.MULTILINE)&&!this.hasFieldFlag(a.AnnotationFieldFlag.PASSWORD)&&!this.hasFieldFlag(a.AnnotationFieldFlag.FILESELECT)&&null!==this.data.maxLen}_getCombAppearance(e,t,r,i,n){const s=(r/this.data.maxLen).toFixed(2),o=[];for(const e of t)o.push(`(${(0,a.escapeString)(e)}) Tj`);return"/Tx BMC q BT "+e+` 1 0 0 1 ${i} ${n} Tm ${o.join(` ${s} 0 Td `)} ET Q EMC`}_getMultilineAppearance(e,t,r,a,i,n,s,o,c){const l=t.split(/\r\n|\r|\n/),h=[],u=i-2*o;for(const e of l){const t=this._splitLine(e,r,a,u);for(const e of t){const t=0===h.length?o:0;h.push(this._renderText(e,r,a,i,s,t,-a))}}return"/Tx BMC q BT "+e+` 1 0 0 1 0 ${n} Tm ${h.join("\n")} ET Q EMC`}_splitLine(e,t,r,a){if(e.length<=1)return[e];const i=r/1e3,n=t.charsToGlyphs(" ",!0)[0].width*i,s=[];let o=-1,c=0,l=0;for(let r=0,h=e.length;ra){s.push(e.substring(c,r));c=r;l=n;o=-1}else{l+=n;o=r}else{const n=t.charsToGlyphs(h,!1)[0].width*i;if(l+n>a)if(-1!==o){s.push(e.substring(c,o+1));c=r=o+1;o=-1;l=0}else{s.push(e.substring(c,r));c=r;l=n}else l+=n}}c1e3){u=Math.max(u,g);m+=f+2;g=0;f=0}d.push({transform:p,x:g,y:m,w:b.width,h:b.height});g+=b.width+2;f=Math.max(f,b.height)}var y=Math.max(u,g)+1,v=m+f+1,w=new Uint8ClampedArray(y*v*4),k=y<<2;for(h=0;h=0;){S[A-4]=S[A];S[A-3]=S[A+1];S[A-2]=S[A+2];S[A-1]=S[A+3];S[A+C]=S[A+C-4];S[A+C+1]=S[A+C-3];S[A+C+2]=S[A+C-2];S[A+C+3]=S[A+C-1];A-=k}}r.splice(s,4*l,a.OPS.paintInlineImageXObjectGroup);i.splice(s,4*l,[{width:y,height:v,kind:a.ImageKind.RGBA_32BPP,data:w},d]);return s+1}));addState(e,[a.OPS.save,a.OPS.transform,a.OPS.paintImageMaskXObject,a.OPS.restore],null,(function iterateImageMaskGroup(e,t){var r=e.fnArray,i=(t-(e.iCurr-3))%4;switch(i){case 0:return r[t]===a.OPS.save;case 1:return r[t]===a.OPS.transform;case 2:return r[t]===a.OPS.paintImageMaskXObject;case 3:return r[t]===a.OPS.restore}throw new Error("iterateImageMaskGroup - invalid pos: "+i)}),(function foundImageMaskGroup(e,t){var r,i=e.fnArray,n=e.argsArray,s=e.iCurr,o=s-3,c=s-2,l=s-1,h=Math.floor((t-o)/4);if((h=function handlePaintSolidColorImageMask(e,t,r,i){for(var n=e+2,s=0;s=4&&r[n-4]===r[s]&&r[n-3]===r[o]&&r[n-2]===r[c]&&r[n-1]===r[l]&&a[n-4][0]===h&&a[n-4][1]===u){d++;f-=5}for(var g=f+4,m=1;m=a)break}i=(i||e)[t[r]];if(i&&!Array.isArray(i)){s.iCurr=r;r++;if(!i.checkFn||(0,i.checkFn)(s)){n=i;i=null}else i=null}else r++}this.state=i;this.match=n;this.lastProcessed=r},push(e,t){this.queue.fnArray.push(e);this.queue.argsArray.push(t);this._optimize()},flush(){for(;this.match;){const e=this.queue.fnArray.length;this.lastProcessed=(0,this.match.processFn)(this.context,e);this.match=null;this.state=null;this._optimize()}},reset(){this.state=null;this.match=null;this.lastProcessed=0}};return QueueOptimizer}(),n=function NullOptimizerClosure(){function NullOptimizer(e){this.queue=e}NullOptimizer.prototype={push(e,t){this.queue.fnArray.push(e);this.queue.argsArray.push(t)},flush(){},reset(){}};return NullOptimizer}(),s=function OperatorListClosure(){function OperatorList(e,t){this._streamSink=t;this.fnArray=[];this.argsArray=[];this.optimizer=t&&"oplist"!==e?new i(this):new n(this);this.dependencies=new Set;this._totalLength=0;this.weight=0;this._resolved=t?null:Promise.resolve()}OperatorList.prototype={get length(){return this.argsArray.length},get ready(){return this._resolved||this._streamSink.ready},get totalLength(){return this._totalLength+this.length},addOp(e,t){this.optimizer.push(e,t);this.weight++;this._streamSink&&(this.weight>=1e3||this.weight>=995&&(e===a.OPS.restore||e===a.OPS.endText))&&this.flush()},addDependency(e){if(!this.dependencies.has(e)){this.dependencies.add(e);this.addOp(a.OPS.dependency,[e])}},addDependencies(e){for(const t of e)this.addDependency(t)},addOpList(e){if(e instanceof OperatorList){for(const t of e.dependencies)this.dependencies.add(t);for(var t=0,r=e.length;te.ref.num-t.ref.num);const u=[[0,1,65535]],d=[0,1];let f=0;for(const{ref:e,data:t}of r){f=Math.max(f,l);u.push([1,l,Math.min(e.gen,65535)]);l+=t.length;d.push(e.num);d.push(1);c.push(t)}s.set("Index",d);if(0!==t.fileIds.length){const e=function computeMD5(e,t){const r=Math.floor(Date.now()/1e3),i=t.filename||"",s=[r.toString(),i,e.toString()];let o=s.reduce((e,t)=>e+t.length,0);for(const e of Object.values(t.info)){s.push(e);o+=e.length}const c=new Uint8Array(o);let l=0;for(const e of s){writeString(e,l,c);l+=e.length}return(0,a.bytesToString)((0,n.calculateMD5)(c))}(l,t);s.set("ID",[t.fileIds[0],e])}const g=[1,Math.ceil(Math.log2(f)/8),2],m=(g[0]+g[1]+g[2])*u.length;s.set("W",g);s.set("Length",m);c.push(`${o.num} ${o.gen} obj\n`);writeDict(s,c,null);c.push(" stream\n");const p=c.reduce((e,t)=>e+t.length,0),b=`\nendstream\nendobj\nstartxref\n${l}\n%%EOF\n`,y=new Uint8Array(e.length+p+m+b.length);y.set(e);let v=e.length;for(const e of c){writeString(e,v,y);v+=e.length}for(const[e,t,r]of u){v=writeInt(e,g[0],v,y);v=writeInt(t,g[1],v,y);v=writeInt(r,g[2],v,y)}writeString(b,v,y);return y};var a=r(2),i=r(5),n=r(22);function writeDict(e,t,r){t.push("<<");for(const a of e.getKeys()){t.push(` /${a} `);writeValue(e.getRaw(a),t,r)}t.push(">>")}function writeValue(e,t,r){if((0,i.isName)(e))t.push("/"+e.name);else if((0,i.isRef)(e))t.push(`${e.num} ${e.gen} R`);else if(Array.isArray(e))!function writeArray(e,t,r){t.push("[");let a=!0;for(const i of e){a?a=!1:t.push(" ");writeValue(i,t,r)}t.push("]")}(e,t,r);else if("string"==typeof e){null!==r&&(e=r.encryptString(e));t.push(`(${(0,a.escapeString)(e)})`)}else"number"==typeof e?t.push(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)}(e)):(0,i.isDict)(e)?writeDict(e,t,r):(0,i.isStream)(e)&&function writeStream(e,t,r){writeDict(e.dict,t,r);t.push(" stream\n");let i=(0,a.bytesToString)(e.getBytes());null!==r&&(i=r.encryptString(i));t.push(i);t.push("\nendstream\n")}(e,t,r)}function writeInt(e,t,r,a){for(let i=t+r-1;i>r-1;i--){a[i]=255&e;e>>=8}return r+t}function writeString(e,t,r){for(let a=0,i=e.length;ag){(0,a.warn)("Image exceeded maximum allowed size and was removed.");return}if(c.get("ImageMask","IM")||!1){var m=c.get("Width","W"),p=c.get("Height","H"),y=m+7>>3,v=t.getBytes(y*p,!0),w=c.getArray("Decode","D");(d=S.PDFImage.createMask({imgArray:v,width:m,height:p,imageIsFromDecodeStream:t instanceof b.DecodeStream,inverseDecode:!!w&&w[0]>0})).cached=!!n;f=[d];i.addOp(a.OPS.paintImageMaskXObject,f);n&&s.set(n,l,{fn:a.OPS.paintImageMaskXObject,args:f});return}var k=c.get("SMask","SM")||!1,C=c.get("Mask")||!1;if(r&&!k&&!C&&h+u<200){const n=new S.PDFImage({xref:this.xref,res:e,image:t,isInline:r,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:o});d=n.createImageData(!0);i.addOp(a.OPS.paintInlineImageXObject,[d]);return}let x="img_"+this.idFactory.createObjId(),A=!1;if(this.parsingType3Font)x=`${this.idFactory.getDocId()}_type3_${x}`;else if(l){A=this.globalImageCache.shouldCache(l,this.pageIndex);A&&(x=`${this.idFactory.getDocId()}_${x}`)}i.addDependency(x);f=[x,h,u];S.PDFImage.buildImage({xref:this.xref,res:e,image:t,isInline:r,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:o}).then(e=>{d=e.createImageData(!1);return this._sendImgData(x,d,A)}).catch(e=>{(0,a.warn)(`Unable to decode image "${x}": "${e}".`);return this._sendImgData(x,null,A)});i.addOp(a.OPS.paintImageXObject,f);if(n){s.set(n,l,{fn:a.OPS.paintImageXObject,args:f});if(l){(0,a.assert)(!r,"Cannot cache an inline image globally.");this.globalImageCache.addPageIndex(l,this.pageIndex);A&&this.globalImageCache.setData(l,{objId:x,fn:a.OPS.paintImageXObject,args:f})}}}handleSMask(e,t,r,a,i,n){var s=e.get("G"),o={subtype:e.get("S").name,backdrop:e.get("BC")},c=e.get("TR");if((0,d.isPDFFunction)(c)){const e=this._pdfFunctionFactory.create(c);for(var l=new Uint8Array(256),h=new Float32Array(1),u=0;u<256;u++){h[0]=u/255;e(h,0,h,0);l[u]=255*h[0]|0}o.transferMap=l}return this.buildFormXObject(t,s,o,r,a,i.state.clone(),n)}handleTransferFunction(e){let t;if(Array.isArray(e))t=e;else{if(!(0,d.isPDFFunction)(e))return null;t=[e]}const r=[];let a=0,i=0;for(const e of t){const t=this.xref.fetchIfRef(e);a++;if((0,n.isName)(t,"Identity")){r.push(null);continue}if(!(0,d.isPDFFunction)(t))return null;const s=this._pdfFunctionFactory.create(t),o=new Uint8Array(256),c=new Float32Array(1);for(let e=0;e<256;e++){c[0]=e/255;s(c,0,c,0);o[e]=255*c[0]|0}r.push(o);i++}return 1!==a&&4!==a||0===i?null:r}handleTilingType(e,t,r,i,s,o,c){const l=new k.OperatorList,h=n.Dict.merge({xref:this.xref,dictArray:[s.get("Resources"),r]});return this.getOperatorList({stream:i,task:c,resources:h,operatorList:l}).then((function(){return(0,u.getTilingPatternIR)({fnArray:l.fnArray,argsArray:l.argsArray},s,t)})).then((function(t){o.addDependencies(l.dependencies);o.addOp(e,t)}),e=>{if(!(e instanceof a.AbortException)){if(!this.options.ignoreErrors)throw e;this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorTilingPattern});(0,a.warn)(`handleTilingType - ignoring pattern: "${e}".`)}})}handleSetFont(e,t,r,i,n,o){var c,l=0;if(t){t=t.slice();c=t[0].name;l=t[1]}return this.loadFont(c,r,e).then(t=>t.font.isType3Font?t.loadType3Data(this,e,n).then((function(){i.addDependencies(t.type3Dependencies);return t})).catch(e=>{this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontLoadType3});return new TranslatedFont({loadedName:"g_font_error",font:new s.ErrorFont("Type3 font load error: "+e),dict:t.font,extraProperties:this.options.fontExtraProperties})}):t).then(e=>{o.font=e.font;o.fontSize=l;o.fontName=c;e.send(this.handler);return e.loadedName})}handleText(e,t){const r=t.font,i=r.charsToGlyphs(e);if(r.data){(!!(t.textRenderingMode&a.TextRenderingMode.ADD_TO_PATH_FLAG)||"Pattern"===t.fillColorSpace.name||r.disableFontFace||this.options.disableFontFace)&&PartialEvaluator.buildFontPaths(r,i,this.handler)}return i}ensureStateFont(e){if(e.font)return;const t=new a.FormatError("Missing setFont (Tf) operator before text rendering operator.");if(!this.options.ignoreErrors)throw t;this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontState});(0,a.warn)(`ensureStateFont: "${t}".`)}async setGState({resources:e,gState:t,operatorList:r,cacheKey:i,task:s,stateManager:o,localGStateCache:c,localColorSpaceCache:l}){const h=t.objId;let u=!0;for(var d=[],f=t.getKeys(),g=Promise.resolve(),m=0,p=f.length;mthis.handleSetFont(e,null,c[0],r,s,o.state).then((function(e){r.addDependency(e);d.push([i,[e,c[1]]])})));break;case"BM":d.push([i,normalizeBlendMode(c)]);break;case"SMask":if((0,n.isName)(c,"None")){d.push([i,!1]);break}if((0,n.isDict)(c)){u=!1;g=g.then(()=>this.handleSMask(c,e,r,s,o,l));d.push([i,!0])}else(0,a.warn)("Unsupported SMask type");break;case"TR":const t=this.handleTransferFunction(c);d.push([i,t]);break;case"OP":case"op":case"OPM":case"BG":case"BG2":case"UCR":case"UCR2":case"TR2":case"HT":case"SM":case"SA":case"AIS":case"TK":(0,a.info)("graphic state operator "+i);break;default:(0,a.info)("Unknown graphic state operator "+i)}}return g.then((function(){d.length>0&&r.addOp(a.OPS.setGState,[d]);u&&c.set(i,h,d)}))}loadFont(e,t,r){const errorFont=()=>Promise.resolve(new TranslatedFont({loadedName:"g_font_error",font:new s.ErrorFont(`Font "${e}" is not available.`),dict:t,extraProperties:this.options.fontExtraProperties}));var i,o=this.xref;if(t){if(!(0,n.isRef)(t))throw new a.FormatError('The "font" object should be a reference.');i=t}else{var c=r.get("Font");c&&(i=c.getRaw(e))}if(!i){const r=`Font "${e||t&&t.toString()}" is not available`;if(!this.options.ignoreErrors&&!this.parsingType3Font){(0,a.warn)(r+".");return errorFont()}this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontMissing});(0,a.warn)(r+" -- attempting to fallback to a default font.");i=PartialEvaluator.fallbackFontDict}if(this.fontCache.has(i))return this.fontCache.get(i);t=o.fetchIfRef(i);if(!(0,n.isDict)(t))return errorFont();if(t.translated)return t.translated;var l=(0,a.createPromiseCapability)(),h=this.preEvaluateFont(t);const{descriptor:u,hash:d}=h;var f,g,m=(0,n.isRef)(i);m&&(f="f"+i.toString());if(d&&(0,n.isDict)(u)){u.fontAliases||(u.fontAliases=Object.create(null));var p=u.fontAliases;if(p[d]){var b=p[d].aliasRef;if(m&&b&&this.fontCache.has(b)){this.fontCache.putAlias(i,b);return this.fontCache.get(i)}}else p[d]={fontID:this.idFactory.createFontId()};m&&(p[d].aliasRef=i);f=p[d].fontID}if(m)this.fontCache.put(i,l.promise);else{f||(f=this.idFactory.createFontId());this.fontCache.put("id_"+f,l.promise)}(0,a.assert)(f&&f.startsWith("f"),'The "fontID" must be (correctly) defined.');t.loadedName=`${this.idFactory.getDocId()}_${f}`;t.translated=l.promise;try{g=this.translateFont(h)}catch(e){g=Promise.reject(e)}g.then(e=>{if(void 0!==e.fontType){o.stats.fontTypes[e.fontType]=!0}l.resolve(new TranslatedFont({loadedName:t.loadedName,font:e,dict:t,extraProperties:this.options.fontExtraProperties}))}).catch(e=>{this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontTranslate});try{var r=u&&u.get("FontFile3"),i=r&&r.get("Subtype"),n=(0,s.getFontType)(h.type,i&&i.name);o.stats.fontTypes[n]=!0}catch(e){}l.resolve(new TranslatedFont({loadedName:t.loadedName,font:new s.ErrorFont(e instanceof Error?e.message:e),dict:t,extraProperties:this.options.fontExtraProperties}))});return l.promise}buildPath(e,t,r,i=!1){var n=e.length-1;r||(r=[]);if(n<0||e.fnArray[n]!==a.OPS.constructPath){if(i){(0,a.warn)(`Encountered path operator "${t}" inside of a text object.`);e.addOp(a.OPS.save,null)}e.addOp(a.OPS.constructPath,[[t],r]);i&&e.addOp(a.OPS.restore,null)}else{var s=e.argsArray[n];s[0].push(t);Array.prototype.push.apply(s[1],r)}}parseColorSpace({cs:e,resources:t,localColorSpaceCache:r}){return p.ColorSpace.parseAsync({cs:e,xref:this.xref,resources:t,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:r}).catch(e=>{if(e instanceof a.AbortException)return null;if(this.options.ignoreErrors){this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorColorSpace});(0,a.warn)(`parseColorSpace - ignoring ColorSpace: "${e}".`);return null}throw e})}async handleColorN(e,t,r,i,s,o,c,l){var h,d=r[r.length-1];if((0,n.isName)(d)&&(h=s.get(d.name))){var f=(0,n.isStream)(h)?h.dict:h,g=f.get("PatternType");if(g===x){var m=i.base?i.base.getRgb(r,0):null;return this.handleTilingType(t,m,o,h,f,e,c)}if(g===A){var p=f.get("Shading"),b=f.getArray("Matrix");h=u.Pattern.parseShading(p,b,this.xref,o,this.handler,this._pdfFunctionFactory,l);e.addOp(t,h.getIR());return}throw new a.FormatError("Unknown PatternType: "+g)}throw new a.FormatError("Unknown PatternName: "+d)}async parseMarkedContentProps(e,t){let r;if((0,n.isName)(e)){r=t.get("Properties").get(e.name)}else{if(!(0,n.isDict)(e))throw new a.FormatError("Optional content properties malformed.");r=e}const i=r.get("Type").name;if("OCG"===i)return{type:i,id:r.objId};if("OCMD"===i){const e=r.get("OCGs");if(Array.isArray(e)||(0,n.isDict)(e)){const t=[];Array.isArray(e)?r.get("OCGs").forEach(e=>{t.push(e.toString())}):t.push(e.objId);let a=null;r.get("VE")&&(a=!0);return{type:i,ids:t,policy:(0,n.isName)(r.get("P"))?r.get("P").name:null,expression:a}}if((0,n.isRef)(e))return{type:i,id:e.toString()}}return null}getOperatorList({stream:e,task:t,resources:r,operatorList:i,initialState:s=null}){r=r||n.Dict.empty;s=s||new EvalState;if(!i)throw new Error('getOperatorList: missing "operatorList" parameter');var o=this,c=this.xref;let l=!1;const h=new g.LocalImageCache,d=new g.LocalColorSpaceCache,f=new g.LocalGStateCache;var m=r.get("XObject")||n.Dict.empty,b=r.get("Pattern")||n.Dict.empty,y=new StateManager(s),v=new EvaluatorPreprocessor(e,c,y),w=new TimeSlotManager;function closePendingRestoreOPS(e){for(var t=0,r=v.savedStatesDepth;t0&&i.addOp(a.OPS.setGState,[e]);I=null;continue}}next(new Promise((function(e,s){if(!x)throw new a.FormatError("GState must be referred to by name.");const c=r.get("ExtGState");if(!(c instanceof n.Dict))throw new a.FormatError("ExtGState should be a dictionary.");const l=c.get(x);if(!(l instanceof n.Dict))throw new a.FormatError("GState should be a dictionary.");o.setGState({resources:r,gState:l,operatorList:i,cacheKey:x,task:t,stateManager:y,localGStateCache:f,localColorSpaceCache:d}).then(e,s)})).catch((function(e){if(!(e instanceof a.AbortException)){if(!o.options.ignoreErrors)throw e;o.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorExtGState});(0,a.warn)(`getOperatorList - ignoring ExtGState: "${e}".`)}})));return;case a.OPS.moveTo:case a.OPS.lineTo:case a.OPS.curveTo:case a.OPS.curveTo2:case a.OPS.curveTo3:case a.OPS.closePath:case a.OPS.rectangle:o.buildPath(i,F,I,l);continue;case a.OPS.markPoint:case a.OPS.markPointProps:case a.OPS.beginCompat:case a.OPS.endCompat:continue;case a.OPS.beginMarkedContentProps:if(!(0,n.isName)(I[0])){(0,a.warn)("Expected name for beginMarkedContentProps arg0="+I[0]);continue}if("OC"===I[0].name){next(o.parseMarkedContentProps(I[1],r).then(e=>{i.addOp(a.OPS.beginMarkedContentProps,["OC",e])}).catch(e=>{if(!(e instanceof a.AbortException)){if(!o.options.ignoreErrors)throw e;o.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorMarkedContent});(0,a.warn)(`getOperatorList - ignoring beginMarkedContentProps: "${e}".`)}}));return}I=[I[0].name];break;case a.OPS.beginMarkedContent:case a.OPS.endMarkedContent:default:if(null!==I){for(k=0,S=I.length;k{if(!(e instanceof a.AbortException)){if(!this.options.ignoreErrors)throw e;this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorOperatorList});(0,a.warn)(`getOperatorList - ignoring errors during "${t.name}" task: "${e}".`);closePendingRestoreOPS()}})}getTextContent({stream:e,task:t,resources:r,stateManager:i=null,normalizeWhitespace:s=!1,combineTextItems:o=!1,sink:c,seenStyles:h=Object.create(null)}){r=r||n.Dict.empty;i=i||new StateManager(new TextState);var u=/\s/g,d={items:[],styles:Object.create(null)},f={initialized:!1,str:[],width:0,height:0,vertical:!1,lastAdvanceWidth:0,lastAdvanceHeight:0,textAdvanceScale:0,spaceWidth:0,fakeSpaceMin:1/0,fakeMultiSpaceMin:1/0,fakeMultiSpaceMax:-0,textRunBreakAllowed:!1,transform:null,fontName:null},p=this,b=this.xref,y=null;const v=new g.LocalImageCache,w=new g.LocalGStateCache;var k,S=new EvaluatorPreprocessor(e,b,i);function ensureTextContentItem(){if(f.initialized)return f;var e=k.font;if(!(e.loadedName in h)){h[e.loadedName]=!0;d.styles[e.loadedName]={fontFamily:e.fallbackName,ascent:e.ascent,descent:e.descent,vertical:e.vertical}}f.fontName=e.loadedName;var t=[k.fontSize*k.textHScale,0,0,k.fontSize,0,k.textRise];if(e.isType3Font&&k.fontSize<=1&&!(0,a.isArrayEqual)(k.fontMatrix,a.FONT_IDENTITY_MATRIX)){const r=e.bbox[3]-e.bbox[1];r>0&&(t[3]*=r*k.fontMatrix[3])}var r=a.Util.transform(k.ctm,a.Util.transform(k.textMatrix,t));f.transform=r;if(e.vertical){f.width=Math.sqrt(r[0]*r[0]+r[1]*r[1]);f.height=0;f.vertical=!0}else{f.width=0;f.height=Math.sqrt(r[2]*r[2]+r[3]*r[3]);f.vertical=!1}var i=k.textLineMatrix[0],n=k.textLineMatrix[1],s=Math.sqrt(i*i+n*n);i=k.ctm[0];n=k.ctm[1];var o=Math.sqrt(i*i+n*n);f.textAdvanceScale=o*s;f.lastAdvanceWidth=0;f.lastAdvanceHeight=0;var c=e.spaceWidth/1e3*k.fontSize;if(c){f.spaceWidth=c;f.fakeSpaceMin=.3*c;f.fakeMultiSpaceMin=1.5*c;f.fakeMultiSpaceMax=4*c;f.textRunBreakAllowed=!e.isMonospace}else{f.spaceWidth=0;f.fakeSpaceMin=1/0;f.fakeMultiSpaceMin=1/0;f.fakeMultiSpaceMax=0;f.textRunBreakAllowed=!1}f.initialized=!0;return f}function replaceWhitespace(e){for(var t,r=0,a=e.length;r=32&&t<=127;)r++;return r0&&addFakeSpaces(f,r.str)}var g=0,m=0;if(t.vertical){i+=m=c*k.fontMatrix[0]*k.fontSize+d}else{a+=g=(c*k.fontMatrix[0]*k.fontSize+d)*k.textHScale}k.translateTextMatrix(g,m);r.str.push(h)}if(t.vertical){r.lastAdvanceHeight=i;r.height+=Math.abs(i)}else{r.lastAdvanceWidth=a;r.width+=a}return r}function addFakeSpaces(e,t){if(!(e0;)t.push(" ")}function flushTextContentItem(){if(f.initialized){f.vertical?f.height*=f.textAdvanceScale:f.width*=f.textAdvanceScale;d.items.push(function runBidiTransform(e){var t=e.str.join(""),r=(0,m.bidi)(t,-1,e.vertical);return{str:s?replaceWhitespace(r.str):r.str,dir:r.dir,width:e.width,height:e.height,transform:e.transform,fontName:e.fontName}}(f));f.initialized=!1;f.str.length=0}}function enqueueChunk(){const e=d.items.length;if(e>0){c.enqueue(d,e);d.items=[];d.styles=Object.create(null)}}var C=new TimeSlotManager;return new Promise((function promiseBody(e,l){const next=function(t){enqueueChunk();Promise.all([t,c.ready]).then((function(){try{promiseBody(e,l)}catch(e){l(e)}}),l)};t.ensureNotTerminated();C.reset();for(var u,g={},m=[];!(u=C.check());){m.length=0;g.args=m;if(!S.read(g))break;k=i.state;var x,A=g.fn;m=g.args;switch(0|A){case a.OPS.setFont:var I=m[0].name,F=m[1];if(k.font&&I===k.fontName&&F===k.fontSize)break;flushTextContentItem();k.fontName=I;k.fontSize=F;next(handleSetFont(I,null));return;case a.OPS.setTextRise:flushTextContentItem();k.textRise=m[0];break;case a.OPS.setHScale:flushTextContentItem();k.textHScale=m[0]/100;break;case a.OPS.setLeading:flushTextContentItem();k.leading=m[0];break;case a.OPS.moveText:var P=!!k.font&&0===(k.font.vertical?m[0]:m[1]);x=m[0]-m[1];if(o&&P&&f.initialized&&x>0&&x<=f.fakeMultiSpaceMax){k.translateTextLineMatrix(m[0],m[1]);f.width+=m[0]-f.lastAdvanceWidth;f.height+=m[1]-f.lastAdvanceHeight;addFakeSpaces(m[0]-f.lastAdvanceWidth-(m[1]-f.lastAdvanceHeight),f.str);break}flushTextContentItem();k.translateTextLineMatrix(m[0],m[1]);k.textMatrix=k.textLineMatrix.slice();break;case a.OPS.setLeadingMoveText:flushTextContentItem();k.leading=-m[1];k.translateTextLineMatrix(m[0],m[1]);k.textMatrix=k.textLineMatrix.slice();break;case a.OPS.nextLine:flushTextContentItem();k.carriageReturn();break;case a.OPS.setTextMatrix:x=k.calcTextLineMatrixAdvance(m[0],m[1],m[2],m[3],m[4],m[5]);if(o&&null!==x&&f.initialized&&x.value>0&&x.value<=f.fakeMultiSpaceMax){k.translateTextLineMatrix(x.width,x.height);f.width+=x.width-f.lastAdvanceWidth;f.height+=x.height-f.lastAdvanceHeight;addFakeSpaces(x.width-f.lastAdvanceWidth-(x.height-f.lastAdvanceHeight),f.str);break}flushTextContentItem();k.setTextMatrix(m[0],m[1],m[2],m[3],m[4],m[5]);k.setTextLineMatrix(m[0],m[1],m[2],m[3],m[4],m[5]);break;case a.OPS.setCharSpacing:k.charSpacing=m[0];break;case a.OPS.setWordSpacing:k.wordSpacing=m[0];break;case a.OPS.beginText:flushTextContentItem();k.textMatrix=a.IDENTITY_MATRIX.slice();k.textLineMatrix=a.IDENTITY_MATRIX.slice();break;case a.OPS.showSpacedText:if(!i.state.font){p.ensureStateFont(i.state);continue}for(var E,B=m[0],O=0,M=B.length;Of.fakeMultiSpaceMax)||(f.height+=E)}else{E=(x=-x)*k.textHScale;k.translateTextMatrix(E,0);(D=f.textRunBreakAllowed&&x>f.fakeMultiSpaceMax)||(f.width+=E)}D?flushTextContentItem():x>0&&addFakeSpaces(x,f.str)}break;case a.OPS.showText:if(!i.state.font){p.ensureStateFont(i.state);continue}buildTextContentItem(m[0]);break;case a.OPS.nextLineShowText:if(!i.state.font){p.ensureStateFont(i.state);continue}flushTextContentItem();k.carriageReturn();buildTextContentItem(m[0]);break;case a.OPS.nextLineSetSpacingShowText:if(!i.state.font){p.ensureStateFont(i.state);continue}flushTextContentItem();k.wordSpacing=m[0];k.charSpacing=m[1];k.carriageReturn();buildTextContentItem(m[2]);break;case a.OPS.paintXObject:flushTextContentItem();y||(y=r.get("XObject")||n.Dict.empty);var R=m[0].name;if(R&&v.getByName(R))break;next(new Promise((function(e,l){if(!R)throw new a.FormatError("XObject must be referred to by name.");let u=y.getRaw(R);if(u instanceof n.Ref){if(v.getByRef(u)){e();return}u=b.fetch(u)}if(!(0,n.isStream)(u))throw new a.FormatError("XObject should be a stream");const d=u.dict.get("Subtype");if(!(0,n.isName)(d))throw new a.FormatError("XObject should have a Name subtype");if("Form"!==d.name){v.set(R,u.dict.objId,!0);e();return}const f=i.state.clone(),g=new StateManager(f),m=u.dict.getArray("Matrix");Array.isArray(m)&&6===m.length&&g.transform(m);enqueueChunk();const w={enqueueInvoked:!1,enqueue(e,t){this.enqueueInvoked=!0;c.enqueue(e,t)},get desiredSize(){return c.desiredSize},get ready(){return c.ready}};p.getTextContent({stream:u,task:t,resources:u.dict.get("Resources")||r,stateManager:g,normalizeWhitespace:s,combineTextItems:o,sink:w,seenStyles:h}).then((function(){w.enqueueInvoked||v.set(R,u.dict.objId,!0);e()}),l)})).catch((function(e){if(!(e instanceof a.AbortException)){if(!p.options.ignoreErrors)throw e;(0,a.warn)(`getTextContent - ignoring XObject: "${e}".`)}})));return;case a.OPS.setGState:if((R=m[0].name)&&w.getByName(R))break;next(new Promise((function(e,t){if(!R)throw new a.FormatError("GState must be referred to by name.");const i=r.get("ExtGState");if(!(i instanceof n.Dict))throw new a.FormatError("ExtGState should be a dictionary.");const s=i.get(R);if(!(s instanceof n.Dict))throw new a.FormatError("GState should be a dictionary.");const o=s.get("Font");if(o){flushTextContentItem();k.fontName=null;k.fontSize=o[1];handleSetFont(null,o[0]).then(e,t)}else{w.set(R,s.objId,!0);e()}})).catch((function(e){if(!(e instanceof a.AbortException)){if(!p.options.ignoreErrors)throw e;(0,a.warn)(`getTextContent - ignoring ExtGState: "${e}".`)}})));return}if(d.items.length>=c.desiredSize){u=!0;break}}if(u)next(T);else{flushTextContentItem();enqueueChunk();e()}})).catch(e=>{if(!(e instanceof a.AbortException)){if(!this.options.ignoreErrors)throw e;(0,a.warn)(`getTextContent - ignoring errors during "${t.name}" task: "${e}".`);flushTextContentItem();enqueueChunk()}})}extractDataStructures(e,t,r){const i=this.xref;let c;var l=e.get("ToUnicode")||t.get("ToUnicode"),h=l?this.readToUnicode(l):Promise.resolve(void 0);if(r.composite){var u=e.get("CIDSystemInfo");(0,n.isDict)(u)&&(r.cidSystemInfo={registry:(0,a.stringToPDFString)(u.get("Registry")),ordering:(0,a.stringToPDFString)(u.get("Ordering")),supplement:u.get("Supplement")});var d=e.get("CIDToGIDMap");(0,n.isStream)(d)&&(c=d.getBytes())}var f,g=[],m=null;if(e.has("Encoding")){f=e.get("Encoding");if((0,n.isDict)(f)){m=f.get("BaseEncoding");m=(0,n.isName)(m)?m.name:null;if(f.has("Differences"))for(var p=f.get("Differences"),b=0,y=0,v=p.length;y0;r.dict=e;return h.then(e=>{r.toUnicode=e;return this.buildToUnicode(r)}).then(e=>{r.toUnicode=e;c&&(r.cidToGidMap=this.readCidToGidMap(c,e));return r})}_buildSimpleFontToUnicode(e,t=!1){(0,a.assert)(!e.composite,"Must be a simple font.");const r=[],i=e.defaultEncoding.slice(),n=e.baseEncodingName,c=e.differences;for(const e in c){const t=c[e];".notdef"!==t&&(i[e]=t)}const h=(0,y.getGlyphsUnicode)();for(const a in i){let s=i[a];if(""!==s)if(void 0!==h[s])r[a]=String.fromCharCode(h[s]);else{let i=0;switch(s[0]){case"G":3===s.length&&(i=parseInt(s.substring(1),16));break;case"g":5===s.length&&(i=parseInt(s.substring(1),16));break;case"C":case"c":if(s.length>=3&&s.length<=4){const r=s.substring(1);if(t){i=parseInt(r,16);break}i=+r;if(Number.isNaN(i)&&Number.isInteger(parseInt(r,16)))return this._buildSimpleFontToUnicode(e,!0)}break;default:const r=(0,l.getUnicodeForGlyph)(s,h);-1!==r&&(i=r)}if(i>0&&i<=1114111&&Number.isInteger(i)){if(n&&i===+a){const e=(0,o.getEncoding)(n);if(e&&(s=e[a])){r[a]=String.fromCharCode(h[s]);continue}}r[a]=String.fromCodePoint(i)}}}return new s.ToUnicodeMap(r)}buildToUnicode(e){e.hasIncludedToUnicodeMap=!!e.toUnicode&&e.toUnicode.length>0;if(e.hasIncludedToUnicodeMap){!e.composite&&e.hasEncoding&&(e.fallbackToUnicode=this._buildSimpleFontToUnicode(e));return Promise.resolve(e.toUnicode)}if(!e.composite)return Promise.resolve(this._buildSimpleFontToUnicode(e));if(e.composite&&(e.cMap.builtInCMap&&!(e.cMap instanceof i.IdentityCMap)||"Adobe"===e.cidSystemInfo.registry&&("GB1"===e.cidSystemInfo.ordering||"CNS1"===e.cidSystemInfo.ordering||"Japan1"===e.cidSystemInfo.ordering||"Korea1"===e.cidSystemInfo.ordering))){const t=e.cidSystemInfo.registry,r=e.cidSystemInfo.ordering,o=n.Name.get(t+"-"+r+"-UCS2");return i.CMapFactory.create({encoding:o,fetchBuiltInCMap:this._fetchBuiltInCMapBound,useCMap:null}).then((function(t){const r=e.cMap,i=[];r.forEach((function(e,r){if(r>65535)throw new a.FormatError("Max size of CID is 65,535");const n=t.lookup(r);n&&(i[e]=String.fromCharCode((n.charCodeAt(0)<<8)+n.charCodeAt(1)))}));return new s.ToUnicodeMap(i)}))}return Promise.resolve(new s.IdentityToUnicodeMap(e.firstChar,e.lastChar))}readToUnicode(e){var t=e;return(0,n.isName)(t)?i.CMapFactory.create({encoding:t,fetchBuiltInCMap:this._fetchBuiltInCMapBound,useCMap:null}).then((function(e){return e instanceof i.IdentityCMap?new s.IdentityToUnicodeMap(0,65535):new s.ToUnicodeMap(e.getMap())})):(0,n.isStream)(t)?i.CMapFactory.create({encoding:t,fetchBuiltInCMap:this._fetchBuiltInCMapBound,useCMap:null}).then((function(e){if(e instanceof i.IdentityCMap)return new s.IdentityToUnicodeMap(0,65535);var t=new Array(e.length);e.forEach((function(e,r){for(var a=[],i=0;i{if(e instanceof a.AbortException)return null;if(this.options.ignoreErrors){this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontToUnicode});(0,a.warn)(`readToUnicode - ignoring ToUnicode data: "${e}".`);return null}throw e}):Promise.resolve(null)}readCidToGidMap(e,t){for(var r=[],a=0,i=e.length;a>1;(0!==n||t.has(i))&&(r[i]=n)}return r}extractWidths(e,t,r){var a,i,o,c,l,h,u,d,f=this.xref,g=[],m=0,p=[];if(r.composite){m=e.has("DW")?e.get("DW"):1e3;if(d=e.get("W"))for(i=0,o=d.length;i{if(e){const r=[];let a=f;for(let t=0,i=e.length;tthis.extractDataStructures(o,r,t)).then(e=>{this.extractWidths(o,l,e);"Type3"===u&&(e.isType3Font=!0);return new s.Font(v.name,x,e)})}static buildFontPaths(e,t,r){function buildPath(t){e.renderer.hasBuiltPath(t)||r.send("commonobj",[`${e.loadedName}_path_${t}`,"FontPath",e.renderer.getPathJs(t)])}for(const e of t){buildPath(e.fontChar);const t=e.accent;t&&t.fontChar&&buildPath(t.fontChar)}}static get fallbackFontDict(){const e=new n.Dict;e.set("BaseFont",n.Name.get("PDFJS-FallbackFont"));e.set("Type",n.Name.get("FallbackType"));e.set("Subtype",n.Name.get("FallbackType"));e.set("Encoding",n.Name.get("WinAnsiEncoding"));return(0,a.shadow)(this,"fallbackFontDict",e)}}t.PartialEvaluator=PartialEvaluator;class TranslatedFont{constructor({loadedName:e,font:t,dict:r,extraProperties:a=!1}){this.loadedName=e;this.font=t;this.dict=r;this._extraProperties=a;this.type3Loaded=null;this.type3Dependencies=t.isType3Font?new Set:null;this.sent=!1}send(e){if(!this.sent){this.sent=!0;e.send("commonobj",[this.loadedName,"Font",this.font.exportData(this._extraProperties)])}}fallback(e){if(!this.font.data)return;this.font.disableFontFace=!0;const t=this.font.glyphCacheValues;PartialEvaluator.buildFontPaths(this.font,t,e)}loadType3Data(e,t,r){if(this.type3Loaded)return this.type3Loaded;if(!this.font.isType3Font)throw new Error("Must be a Type3 font.");var i=Object.create(e.options);i.ignoreErrors=!1;var n=e.clone(i);n.parsingType3Font=!0;const s=this.font,o=this.type3Dependencies;var c=Promise.resolve(),l=this.dict.get("CharProcs"),h=this.dict.get("Resources")||t,u=Object.create(null);for(const e of l.getKeys())c=c.then((function(){var t=l.get(e),i=new k.OperatorList;return n.getOperatorList({stream:t,task:r,resources:h,operatorList:i}).then((function(){u[e]=i.getIR();for(const e of i.dependencies)o.add(e)})).catch((function(t){(0,a.warn)(`Type3 font resource "${e}" is not available.`);const r=new k.OperatorList;u[e]=r.getIR()}))}));this.type3Loaded=c.then((function(){s.charProcOperatorList=u}));return this.type3Loaded}}class StateManager{constructor(e){this.state=e;this.stateStack=[]}save(){var e=this.state;this.stateStack.push(this.state);this.state=e.clone()}restore(){var e=this.stateStack.pop();e&&(this.state=e)}transform(e){this.state.ctm=a.Util.transform(this.state.ctm,e)}}class TextState{constructor(){this.ctm=new Float32Array(a.IDENTITY_MATRIX);this.fontName=null;this.fontSize=0;this.font=null;this.fontMatrix=a.FONT_IDENTITY_MATRIX;this.textMatrix=a.IDENTITY_MATRIX.slice();this.textLineMatrix=a.IDENTITY_MATRIX.slice();this.charSpacing=0;this.wordSpacing=0;this.leading=0;this.textHScale=1;this.textRise=0}setTextMatrix(e,t,r,a,i,n){var s=this.textMatrix;s[0]=e;s[1]=t;s[2]=r;s[3]=a;s[4]=i;s[5]=n}setTextLineMatrix(e,t,r,a,i,n){var s=this.textLineMatrix;s[0]=e;s[1]=t;s[2]=r;s[3]=a;s[4]=i;s[5]=n}translateTextMatrix(e,t){var r=this.textMatrix;r[4]=r[0]*e+r[2]*t+r[4];r[5]=r[1]*e+r[3]*t+r[5]}translateTextLineMatrix(e,t){var r=this.textLineMatrix;r[4]=r[0]*e+r[2]*t+r[4];r[5]=r[1]*e+r[3]*t+r[5]}calcTextLineMatrixAdvance(e,t,r,a,i,n){var s=this.font;if(!s)return null;var o=this.textLineMatrix;if(e!==o[0]||t!==o[1]||r!==o[2]||a!==o[3])return null;var c=i-o[4],l=n-o[5];if(s.vertical&&0!==c||!s.vertical&&0!==l)return null;var h,u,d=e*a-t*r;if(s.vertical){h=-l*r/d;u=l*e/d}else{h=c*a/d;u=-c*t/d}return{width:h,height:u,value:s.vertical?u:h}}calcRenderMatrix(e){var t=[this.fontSize*this.textHScale,0,0,this.fontSize,0,this.textRise];return a.Util.transform(e,a.Util.transform(this.textMatrix,t))}carriageReturn(){this.translateTextLineMatrix(0,-this.leading);this.textMatrix=this.textLineMatrix.slice()}clone(){var e=Object.create(this);e.textMatrix=this.textMatrix.slice();e.textLineMatrix=this.textLineMatrix.slice();e.fontMatrix=this.fontMatrix.slice();return e}}class EvalState{constructor(){this.ctm=new Float32Array(a.IDENTITY_MATRIX);this.font=null;this.textRenderingMode=a.TextRenderingMode.FILL;this.fillColorSpace=p.ColorSpace.singletons.gray;this.strokeColorSpace=p.ColorSpace.singletons.gray}clone(){return Object.create(this)}}class EvaluatorPreprocessor{static get opMap(){const e=(0,c.getLookupTableFactory)((function(e){e.w={id:a.OPS.setLineWidth,numArgs:1,variableArgs:!1};e.J={id:a.OPS.setLineCap,numArgs:1,variableArgs:!1};e.j={id:a.OPS.setLineJoin,numArgs:1,variableArgs:!1};e.M={id:a.OPS.setMiterLimit,numArgs:1,variableArgs:!1};e.d={id:a.OPS.setDash,numArgs:2,variableArgs:!1};e.ri={id:a.OPS.setRenderingIntent,numArgs:1,variableArgs:!1};e.i={id:a.OPS.setFlatness,numArgs:1,variableArgs:!1};e.gs={id:a.OPS.setGState,numArgs:1,variableArgs:!1};e.q={id:a.OPS.save,numArgs:0,variableArgs:!1};e.Q={id:a.OPS.restore,numArgs:0,variableArgs:!1};e.cm={id:a.OPS.transform,numArgs:6,variableArgs:!1};e.m={id:a.OPS.moveTo,numArgs:2,variableArgs:!1};e.l={id:a.OPS.lineTo,numArgs:2,variableArgs:!1};e.c={id:a.OPS.curveTo,numArgs:6,variableArgs:!1};e.v={id:a.OPS.curveTo2,numArgs:4,variableArgs:!1};e.y={id:a.OPS.curveTo3,numArgs:4,variableArgs:!1};e.h={id:a.OPS.closePath,numArgs:0,variableArgs:!1};e.re={id:a.OPS.rectangle,numArgs:4,variableArgs:!1};e.S={id:a.OPS.stroke,numArgs:0,variableArgs:!1};e.s={id:a.OPS.closeStroke,numArgs:0,variableArgs:!1};e.f={id:a.OPS.fill,numArgs:0,variableArgs:!1};e.F={id:a.OPS.fill,numArgs:0,variableArgs:!1};e["f*"]={id:a.OPS.eoFill,numArgs:0,variableArgs:!1};e.B={id:a.OPS.fillStroke,numArgs:0,variableArgs:!1};e["B*"]={id:a.OPS.eoFillStroke,numArgs:0,variableArgs:!1};e.b={id:a.OPS.closeFillStroke,numArgs:0,variableArgs:!1};e["b*"]={id:a.OPS.closeEOFillStroke,numArgs:0,variableArgs:!1};e.n={id:a.OPS.endPath,numArgs:0,variableArgs:!1};e.W={id:a.OPS.clip,numArgs:0,variableArgs:!1};e["W*"]={id:a.OPS.eoClip,numArgs:0,variableArgs:!1};e.BT={id:a.OPS.beginText,numArgs:0,variableArgs:!1};e.ET={id:a.OPS.endText,numArgs:0,variableArgs:!1};e.Tc={id:a.OPS.setCharSpacing,numArgs:1,variableArgs:!1};e.Tw={id:a.OPS.setWordSpacing,numArgs:1,variableArgs:!1};e.Tz={id:a.OPS.setHScale,numArgs:1,variableArgs:!1};e.TL={id:a.OPS.setLeading,numArgs:1,variableArgs:!1};e.Tf={id:a.OPS.setFont,numArgs:2,variableArgs:!1};e.Tr={id:a.OPS.setTextRenderingMode,numArgs:1,variableArgs:!1};e.Ts={id:a.OPS.setTextRise,numArgs:1,variableArgs:!1};e.Td={id:a.OPS.moveText,numArgs:2,variableArgs:!1};e.TD={id:a.OPS.setLeadingMoveText,numArgs:2,variableArgs:!1};e.Tm={id:a.OPS.setTextMatrix,numArgs:6,variableArgs:!1};e["T*"]={id:a.OPS.nextLine,numArgs:0,variableArgs:!1};e.Tj={id:a.OPS.showText,numArgs:1,variableArgs:!1};e.TJ={id:a.OPS.showSpacedText,numArgs:1,variableArgs:!1};e["'"]={id:a.OPS.nextLineShowText,numArgs:1,variableArgs:!1};e['"']={id:a.OPS.nextLineSetSpacingShowText,numArgs:3,variableArgs:!1};e.d0={id:a.OPS.setCharWidth,numArgs:2,variableArgs:!1};e.d1={id:a.OPS.setCharWidthAndBounds,numArgs:6,variableArgs:!1};e.CS={id:a.OPS.setStrokeColorSpace,numArgs:1,variableArgs:!1};e.cs={id:a.OPS.setFillColorSpace,numArgs:1,variableArgs:!1};e.SC={id:a.OPS.setStrokeColor,numArgs:4,variableArgs:!0};e.SCN={id:a.OPS.setStrokeColorN,numArgs:33,variableArgs:!0};e.sc={id:a.OPS.setFillColor,numArgs:4,variableArgs:!0};e.scn={id:a.OPS.setFillColorN,numArgs:33,variableArgs:!0};e.G={id:a.OPS.setStrokeGray,numArgs:1,variableArgs:!1};e.g={id:a.OPS.setFillGray,numArgs:1,variableArgs:!1};e.RG={id:a.OPS.setStrokeRGBColor,numArgs:3,variableArgs:!1};e.rg={id:a.OPS.setFillRGBColor,numArgs:3,variableArgs:!1};e.K={id:a.OPS.setStrokeCMYKColor,numArgs:4,variableArgs:!1};e.k={id:a.OPS.setFillCMYKColor,numArgs:4,variableArgs:!1};e.sh={id:a.OPS.shadingFill,numArgs:1,variableArgs:!1};e.BI={id:a.OPS.beginInlineImage,numArgs:0,variableArgs:!1};e.ID={id:a.OPS.beginImageData,numArgs:0,variableArgs:!1};e.EI={id:a.OPS.endInlineImage,numArgs:1,variableArgs:!1};e.Do={id:a.OPS.paintXObject,numArgs:1,variableArgs:!1};e.MP={id:a.OPS.markPoint,numArgs:1,variableArgs:!1};e.DP={id:a.OPS.markPointProps,numArgs:2,variableArgs:!1};e.BMC={id:a.OPS.beginMarkedContent,numArgs:1,variableArgs:!1};e.BDC={id:a.OPS.beginMarkedContentProps,numArgs:2,variableArgs:!1};e.EMC={id:a.OPS.endMarkedContent,numArgs:0,variableArgs:!1};e.BX={id:a.OPS.beginCompat,numArgs:0,variableArgs:!1};e.EX={id:a.OPS.endCompat,numArgs:0,variableArgs:!1};e.BM=null;e.BD=null;e.true=null;e.fa=null;e.fal=null;e.fals=null;e.false=null;e.nu=null;e.nul=null;e.null=null}));return(0,a.shadow)(this,"opMap",e())}static get MAX_INVALID_PATH_OPS(){return(0,a.shadow)(this,"MAX_INVALID_PATH_OPS",20)}constructor(e,t,r){this.parser=new f.Parser({lexer:new f.Lexer(e,EvaluatorPreprocessor.opMap),xref:t});this.stateManager=r;this.nonProcessedArgs=[];this._numInvalidPathOPS=0}get savedStatesDepth(){return this.stateManager.stateStack.length}read(e){for(var t=e.args;;){var r=this.parser.getObj();if(r instanceof n.Cmd){var i=r.cmd,s=EvaluatorPreprocessor.opMap[i];if(!s){(0,a.warn)(`Unknown command "${i}".`);continue}var o=s.id,c=s.numArgs,l=null!==t?t.length:0;if(s.variableArgs)l>c&&(0,a.info)(`Command ${i}: expected [0, ${c}] args, but received ${l} args.`);else{if(l!==c){for(var h=this.nonProcessedArgs;l>c;){h.push(t.shift());l--}for(;l=a.OPS.moveTo&&o<=a.OPS.endPath&&++this._numInvalidPathOPS>EvaluatorPreprocessor.MAX_INVALID_PATH_OPS)throw new a.FormatError("Invalid "+e);(0,a.warn)("Skipping "+e);null!==t&&(t.length=0);continue}}this.preprocessCommand(o,t);e.fn=o;e.args=t;return!0}if(r===n.EOF)return!1;if(null!==r){null===t&&(t=[]);t.push(r);if(t.length>33)throw new a.FormatError("Too many arguments")}}}preprocessCommand(e,t){switch(0|e){case a.OPS.save:this.stateManager.save();break;case a.OPS.restore:this.stateManager.restore();break;case a.OPS.transform:this.stateManager.transform(t)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.CMapFactory=t.IdentityCMap=t.CMap=void 0;var a=r(2),i=r(5),n=r(11),s=r(8),o=r(12),c=["Adobe-GB1-UCS2","Adobe-CNS1-UCS2","Adobe-Japan1-UCS2","Adobe-Korea1-UCS2","78-EUC-H","78-EUC-V","78-H","78-RKSJ-H","78-RKSJ-V","78-V","78ms-RKSJ-H","78ms-RKSJ-V","83pv-RKSJ-H","90ms-RKSJ-H","90ms-RKSJ-V","90msp-RKSJ-H","90msp-RKSJ-V","90pv-RKSJ-H","90pv-RKSJ-V","Add-H","Add-RKSJ-H","Add-RKSJ-V","Add-V","Adobe-CNS1-0","Adobe-CNS1-1","Adobe-CNS1-2","Adobe-CNS1-3","Adobe-CNS1-4","Adobe-CNS1-5","Adobe-CNS1-6","Adobe-GB1-0","Adobe-GB1-1","Adobe-GB1-2","Adobe-GB1-3","Adobe-GB1-4","Adobe-GB1-5","Adobe-Japan1-0","Adobe-Japan1-1","Adobe-Japan1-2","Adobe-Japan1-3","Adobe-Japan1-4","Adobe-Japan1-5","Adobe-Japan1-6","Adobe-Korea1-0","Adobe-Korea1-1","Adobe-Korea1-2","B5-H","B5-V","B5pc-H","B5pc-V","CNS-EUC-H","CNS-EUC-V","CNS1-H","CNS1-V","CNS2-H","CNS2-V","ETHK-B5-H","ETHK-B5-V","ETen-B5-H","ETen-B5-V","ETenms-B5-H","ETenms-B5-V","EUC-H","EUC-V","Ext-H","Ext-RKSJ-H","Ext-RKSJ-V","Ext-V","GB-EUC-H","GB-EUC-V","GB-H","GB-V","GBK-EUC-H","GBK-EUC-V","GBK2K-H","GBK2K-V","GBKp-EUC-H","GBKp-EUC-V","GBT-EUC-H","GBT-EUC-V","GBT-H","GBT-V","GBTpc-EUC-H","GBTpc-EUC-V","GBpc-EUC-H","GBpc-EUC-V","H","HKdla-B5-H","HKdla-B5-V","HKdlb-B5-H","HKdlb-B5-V","HKgccs-B5-H","HKgccs-B5-V","HKm314-B5-H","HKm314-B5-V","HKm471-B5-H","HKm471-B5-V","HKscs-B5-H","HKscs-B5-V","Hankaku","Hiragana","KSC-EUC-H","KSC-EUC-V","KSC-H","KSC-Johab-H","KSC-Johab-V","KSC-V","KSCms-UHC-H","KSCms-UHC-HW-H","KSCms-UHC-HW-V","KSCms-UHC-V","KSCpc-EUC-H","KSCpc-EUC-V","Katakana","NWP-H","NWP-V","RKSJ-H","RKSJ-V","Roman","UniCNS-UCS2-H","UniCNS-UCS2-V","UniCNS-UTF16-H","UniCNS-UTF16-V","UniCNS-UTF32-H","UniCNS-UTF32-V","UniCNS-UTF8-H","UniCNS-UTF8-V","UniGB-UCS2-H","UniGB-UCS2-V","UniGB-UTF16-H","UniGB-UTF16-V","UniGB-UTF32-H","UniGB-UTF32-V","UniGB-UTF8-H","UniGB-UTF8-V","UniJIS-UCS2-H","UniJIS-UCS2-HW-H","UniJIS-UCS2-HW-V","UniJIS-UCS2-V","UniJIS-UTF16-H","UniJIS-UTF16-V","UniJIS-UTF32-H","UniJIS-UTF32-V","UniJIS-UTF8-H","UniJIS-UTF8-V","UniJIS2004-UTF16-H","UniJIS2004-UTF16-V","UniJIS2004-UTF32-H","UniJIS2004-UTF32-V","UniJIS2004-UTF8-H","UniJIS2004-UTF8-V","UniJISPro-UCS2-HW-V","UniJISPro-UCS2-V","UniJISPro-UTF8-V","UniJISX0213-UTF32-H","UniJISX0213-UTF32-V","UniJISX02132004-UTF32-H","UniJISX02132004-UTF32-V","UniKS-UCS2-H","UniKS-UCS2-V","UniKS-UTF16-H","UniKS-UTF16-V","UniKS-UTF32-H","UniKS-UTF32-V","UniKS-UTF8-H","UniKS-UTF8-V","V","WP-Symbol"];class CMap{constructor(e=!1){this.codespaceRanges=[[],[],[],[]];this.numCodespaceRanges=0;this._map=[];this.name="";this.vertical=!1;this.useCMap=null;this.builtInCMap=e}addCodespaceRange(e,t,r){this.codespaceRanges[e-1].push(t,r);this.numCodespaceRanges++}mapCidRange(e,t,r){if(t-e>2**24-1)throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");for(;e<=t;)this._map[e++]=r++}mapBfRange(e,t,r){if(t-e>2**24-1)throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");for(var a=r.length-1;e<=t;){this._map[e++]=r;r=r.substring(0,a)+String.fromCharCode(r.charCodeAt(a)+1)}}mapBfRangeToArray(e,t,r){if(t-e>2**24-1)throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");const a=r.length;let i=0;for(;e<=t&&i>>0;const s=i[n];for(let e=0,t=s.length;e=t&&a<=i){r.charcode=a;r.length=n+1;return}}}r.charcode=0;r.length=1}get length(){return this._map.length}get isIdentityCMap(){if("Identity-H"!==this.name&&"Identity-V"!==this.name)return!1;if(65536!==this._map.length)return!1;for(let e=0;e<65536;e++)if(this._map[e]!==e)return!1;return!0}}t.CMap=CMap;class IdentityCMap extends CMap{constructor(e,t){super();this.vertical=e;this.addCodespaceRange(t,0,65535)}mapCidRange(e,t,r){(0,a.unreachable)("should not call mapCidRange")}mapBfRange(e,t,r){(0,a.unreachable)("should not call mapBfRange")}mapBfRangeToArray(e,t,r){(0,a.unreachable)("should not call mapBfRangeToArray")}mapOne(e,t){(0,a.unreachable)("should not call mapCidOne")}lookup(e){return Number.isInteger(e)&&e<=65535?e:void 0}contains(e){return Number.isInteger(e)&&e<=65535}forEach(e){for(let t=0;t<=65535;t++)e(t,t)}charCodeOf(e){return Number.isInteger(e)&&e<=65535?e:-1}getMap(){const e=new Array(65536);for(let t=0;t<=65535;t++)e[t]=t;return e}get length(){return 65536}get isIdentityCMap(){(0,a.unreachable)("should not access .isIdentityCMap")}}t.IdentityCMap=IdentityCMap;var l=function BinaryCMapReaderClosure(){function hexToInt(e,t){for(var r=0,a=0;a<=t;a++)r=r<<8|e[a];return r>>>0}function hexToStr(e,t){return 1===t?String.fromCharCode(e[0],e[1]):3===t?String.fromCharCode(e[0],e[1],e[2],e[3]):String.fromCharCode.apply(null,e.subarray(0,t+1))}function addHex(e,t,r){for(var a=0,i=r;i>=0;i--){a+=e[i]+t[i];e[i]=255&a;a>>=8}}function incHex(e,t){for(var r=1,a=t;a>=0&&r>0;a--){r+=e[a];e[a]=255&r;r>>=8}}function BinaryCMapStream(e){this.buffer=e;this.pos=0;this.end=e.length;this.tmpBuf=new Uint8Array(19)}BinaryCMapStream.prototype={readByte(){return this.pos>=this.end?-1:this.buffer[this.pos++]},readNumber(){var e,t=0;do{var r=this.readByte();if(r<0)throw new a.FormatError("unexpected EOF in bcmap");e=!(128&r);t=t<<7|127&r}while(!e);return t},readSigned(){var e=this.readNumber();return 1&e?~(e>>>1):e>>>1},readHex(e,t){e.set(this.buffer.subarray(this.pos,this.pos+t+1));this.pos+=t+1},readHexNumber(e,t){var r,i=this.tmpBuf,n=0;do{var s=this.readByte();if(s<0)throw new a.FormatError("unexpected EOF in bcmap");r=!(128&s);i[n++]=127&s}while(!r);for(var o=t,c=0,l=0;o>=0;){for(;l<8&&i.length>0;){c=i[--n]<>=8;l-=8}},readHexSigned(e,t){this.readHexNumber(e,t);for(var r=1&e[t]?255:0,a=0,i=0;i<=t;i++){a=(1&a)<<8|e[i];e[i]=a>>1^r}},readString(){for(var e=this.readNumber(),t="",r=0;r=0;){var m=c>>5;if(7!==m){var p=!!(16&c),b=15&c;if(b+1>16)throw new Error("processBinaryCMap: Invalid dataSize.");var y,v=n.readNumber();switch(m){case 0:n.readHex(h,b);n.readHexNumber(u,b);addHex(u,h,b);t.addCodespaceRange(b+1,hexToInt(h,b),hexToInt(u,b));for(y=1;y>>0}function expectString(e){if(!(0,a.isString)(e))throw new a.FormatError("Malformed CMap: expected string.")}function expectInt(e){if(!Number.isInteger(e))throw new a.FormatError("Malformed CMap: expected int.")}function parseBfChar(e,t){for(;;){var r=t.getObj();if((0,i.isEOF)(r))break;if((0,i.isCmd)(r,"endbfchar"))return;expectString(r);var a=strToInt(r);expectString(r=t.getObj());var n=r;e.mapOne(a,n)}}function parseBfRange(e,t){for(;;){var r=t.getObj();if((0,i.isEOF)(r))break;if((0,i.isCmd)(r,"endbfrange"))return;expectString(r);var n=strToInt(r);expectString(r=t.getObj());var s=strToInt(r);r=t.getObj();if(Number.isInteger(r)||(0,a.isString)(r)){var o=Number.isInteger(r)?String.fromCharCode(r):r;e.mapBfRange(n,s,o)}else{if(!(0,i.isCmd)(r,"["))break;r=t.getObj();for(var c=[];!(0,i.isCmd)(r,"]")&&!(0,i.isEOF)(r);){c.push(r);r=t.getObj()}e.mapBfRangeToArray(n,s,c)}}throw new a.FormatError("Invalid bf range.")}function parseCidChar(e,t){for(;;){var r=t.getObj();if((0,i.isEOF)(r))break;if((0,i.isCmd)(r,"endcidchar"))return;expectString(r);var a=strToInt(r);expectInt(r=t.getObj());var n=r;e.mapOne(a,n)}}function parseCidRange(e,t){for(;;){var r=t.getObj();if((0,i.isEOF)(r))break;if((0,i.isCmd)(r,"endcidrange"))return;expectString(r);var a=strToInt(r);expectString(r=t.getObj());var n=strToInt(r);expectInt(r=t.getObj());var s=r;e.mapCidRange(a,n,s)}}function parseCodespaceRange(e,t){for(;;){var r=t.getObj();if((0,i.isEOF)(r))break;if((0,i.isCmd)(r,"endcodespacerange"))return;if(!(0,a.isString)(r))break;var n=strToInt(r);r=t.getObj();if(!(0,a.isString)(r))break;var s=strToInt(r);e.addCodespaceRange(r.length,n,s)}throw new a.FormatError("Invalid codespace range.")}function parseWMode(e,t){var r=t.getObj();Number.isInteger(r)&&(e.vertical=!!r)}function parseCMapName(e,t){var r=t.getObj();(0,i.isName)(r)&&(0,a.isString)(r.name)&&(e.name=r.name)}function parseCMap(e,t,r,n){var o,c;e:for(;;)try{var l=t.getObj();if((0,i.isEOF)(l))break;if((0,i.isName)(l)){"WMode"===l.name?parseWMode(e,t):"CMapName"===l.name&&parseCMapName(e,t);o=l}else if((0,i.isCmd)(l))switch(l.cmd){case"endcmap":break e;case"usecmap":(0,i.isName)(o)&&(c=o.name);break;case"begincodespacerange":parseCodespaceRange(e,t);break;case"beginbfchar":parseBfChar(e,t);break;case"begincidchar":parseCidChar(e,t);break;case"beginbfrange":parseBfRange(e,t);break;case"begincidrange":parseCidRange(e,t)}}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.warn)("Invalid cMap data: "+e);continue}!n&&c&&(n=c);return n?extendCMap(e,r,n):Promise.resolve(e)}function extendCMap(e,t,r){return createBuiltInCMap(r,t).then((function(t){e.useCMap=t;if(0===e.numCodespaceRanges){for(var r=e.useCMap.codespaceRanges,a=0;a=this.firstChar&&e<=this.lastChar?e:-1},amend(e){(0,a.unreachable)("Should not call amend()")}};return IdentityToUnicodeMap}();t.IdentityToUnicodeMap=k;var S=function OpenTypeFileBuilderClosure(){function writeInt16(e,t,r){e[t]=r>>8&255;e[t+1]=255&r}function writeInt32(e,t,r){e[t]=r>>24&255;e[t+1]=r>>16&255;e[t+2]=r>>8&255;e[t+3]=255&r}function writeData(e,t,r){var a,i;if(r instanceof Uint8Array)e.set(r,t);else if("string"==typeof r)for(a=0,i=r.length;ar;){r<<=1;a++}var i=r*t;return{range:i,entry:a,rangeShift:t*e-i}};OpenTypeFileBuilder.prototype={toArray:function OpenTypeFileBuilder_toArray(){var e=this.sfnt,t=this.tables,r=Object.keys(t);r.sort();var i,n,s,o,c,h=r.length,u=12+16*h,d=[u];for(i=0;i>>0;d.push(u)}var f=new Uint8Array(u);for(i=0;i>>0}writeInt32(f,u+4,m);writeInt32(f,u+8,d[i]);writeInt32(f,u+12,t[c].length);u+=16}return f},addTable:function OpenTypeFileBuilder_addTable(e,t){if(e in this.tables)throw new Error("Table "+e+" already exists");this.tables[e]=t}};return OpenTypeFileBuilder}(),C=function FontClosure(){function Font(e,t,r){var i;this.name=e;this.loadedName=r.loadedName;this.isType3Font=r.isType3Font;this.missingFile=!1;this.glyphCache=Object.create(null);this.isSerifFont=!!(r.flags&b.Serif);this.isSymbolicFont=!!(r.flags&b.Symbolic);this.isMonospace=!!(r.flags&b.FixedPitch);var n=r.type,s=r.subtype;this.type=n;this.subtype=s;let o="sans-serif";this.isMonospace?o="monospace":this.isSerifFont&&(o="serif");this.fallbackName=o;this.differences=r.differences;this.widths=r.widths;this.defaultWidth=r.defaultWidth;this.composite=r.composite;this.cMap=r.cMap;this.ascent=r.ascent/1e3;this.descent=r.descent/1e3;this.fontMatrix=r.fontMatrix;this.bbox=r.bbox;this.defaultEncoding=r.defaultEncoding;this.toUnicode=r.toUnicode;this.fallbackToUnicode=r.fallbackToUnicode||new w;this.toFontChar=[];if("Type3"!==r.type){this.cidEncoding=r.cidEncoding;this.vertical=!!r.vertical;if(this.vertical){this.vmetrics=r.vmetrics;this.defaultVMetrics=r.defaultVMetrics}if(t&&!t.isEmpty){[n,s]=function getFontFileType(e,{type:t,subtype:r,composite:i}){let n,s;if(function isTrueTypeFile(e){var t=e.peekBytes(4);return 65536===(0,l.readUint32)(t,0)||"true"===(0,a.bytesToString)(t)}(e)||isTrueTypeCollectionFile(e))n=i?"CIDFontType2":"TrueType";else if(function isOpenTypeFile(e){var t=e.peekBytes(4);return"OTTO"===(0,a.bytesToString)(t)}(e))n=i?"CIDFontType2":"OpenType";else if(function isType1File(e){var t=e.peekBytes(2);if(37===t[0]&&33===t[1])return!0;if(128===t[0]&&1===t[1])return!0;return!1}(e))n=i?"CIDFontType0":"MMType1"===t?"MMType1":"Type1";else if(function isCFFFile(e){const t=e.peekBytes(4);if(t[0]>=1&&t[3]>=1&&t[3]<=4)return!0;return!1}(e))if(i){n="CIDFontType0";s="CIDFontType0C"}else{n="MMType1"===t?"MMType1":"Type1";s="Type1C"}else{(0,a.warn)("getFontFileType: Unable to detect correct font file Type/Subtype.");n=t;s=r}return[n,s]}(t,r);n===this.type&&s===this.subtype||(0,a.info)(`Inconsistent font file Type/SubType, expected: ${this.type}/${this.subtype} but found: ${n}/${s}.`);try{var c;switch(n){case"MMType1":(0,a.info)("MMType1 font ("+e+"), falling back to Type1.");case"Type1":case"CIDFontType0":this.mimetype="font/opentype";var h="Type1C"===s||"CIDFontType0C"===s?new T(t,r):new A(e,t,r);adjustWidths(r);c=this.convert(e,h,r);break;case"OpenType":case"TrueType":case"CIDFontType2":this.mimetype="font/opentype";c=this.checkAndRepair(e,t,r);if(this.isOpenType){adjustWidths(r);n="OpenType"}break;default:throw new a.FormatError(`Font ${n} is not supported`)}}catch(e){(0,a.warn)(e);this.fallbackToSystemFont();return}this.data=c;this.fontType=getFontType(n,s);this.fontMatrix=r.fontMatrix;this.widths=r.widths;this.defaultWidth=r.defaultWidth;this.toUnicode=r.toUnicode;this.seacMap=r.seacMap}else{t&&(0,a.warn)('Font file is empty in "'+e+'" ('+this.loadedName+")");this.fallbackToSystemFont()}}else{for(i=0;i<256;i++)this.toFontChar[i]=this.differences[i]||r.defaultEncoding[i];this.fontType=a.FontType.TYPE3}}function int16(e,t){return(e<<8)+t}function signedInt16(e,t){var r=(e<<8)+t;return 32768&r?r-65536:r}function string16(e){return String.fromCharCode(e>>8&255,255&e)}function safeString16(e){e>32767?e=32767:e<-32768&&(e=-32768);return String.fromCharCode(e>>8&255,255&e)}function isTrueTypeCollectionFile(e){const t=e.peekBytes(4);return"ttcf"===(0,a.bytesToString)(t)}function buildToFontChar(e,t,r){for(var a,i=[],n=0,s=e.length;nc){if(++s>=g.length){(0,a.warn)("Ran out of space in font private use area.");break}o=g[s][0];c=g[s][1]}var u=o++;0===h&&(h=r);i[u]=h;n[l]=u}}return{toFontChar:n,charCodeToGlyphId:i,nextAvailableFontCharCode:o}}function createCmapTable(e,t){var r,i,n,s,o=function getRanges(e,t){var r=[];for(var a in e)e[a]>=t||r.push({fontCharCode:0|a,glyphId:e[a]});0===r.length&&r.push({fontCharCode:0,glyphId:0});r.sort((function fontGetRangesSort(e,t){return e.fontCharCode-t.fontCharCode}));for(var i=[],n=r.length,s=0;s65535?2:1,l="\0\0"+string16(c)+"\0\0"+(0,a.string32)(4+8*c);for(r=o.length-1;r>=0&&!(o[r][0]<=65535);--r);var h=r+1;o[r][0]<65535&&65535===o[r][1]&&(o[r][1]=65534);var u,d,f,g,m=o[r][1]<65535?1:0,p=h+m,b=S.getSearchParams(p,2),y="",v="",w="",k="",C="",x=0;for(r=0,i=h;r0){v+="ÿÿ";y+="ÿÿ";w+="\0";k+="\0\0"}var I="\0\0"+string16(2*p)+string16(b.range)+string16(b.entry)+string16(b.rangeShift)+v+"\0\0"+y+w+k+C,F="",P="";if(c>1){l+="\0\0\n"+(0,a.string32)(4+8*c+4+I.length);F="";for(r=0,i=o.length;r(u|=0)||!l)&&(l=u);h 123 are reserved for internal usage");o|=1<65535&&(h=65535)}else{l=0;h=255}var f=e.bbox||[0,0,0,0],g=r.unitsPerEm||1/(e.fontMatrix||a.FONT_IDENTITY_MATRIX)[0],m=e.ascentScaled?1:g/1e3,p=r.ascent||Math.round(m*(e.ascent||f[3])),b=r.descent||Math.round(m*(e.descent||f[1]));b>0&&e.descent>0&&f[1]<0&&(b=-b);var y=r.yMax||p,v=-r.yMin||-b;return"\0$ô\0\0\0Š»\0\0\0ŒŠ»\0\0ß\x001\0\0\0\0"+String.fromCharCode(e.fixedPitch?9:0)+"\0\0\0\0\0\0"+(0,a.string32)(i)+(0,a.string32)(n)+(0,a.string32)(s)+(0,a.string32)(o)+"*21*"+string16(e.italicAngle?1:0)+string16(l||e.firstChar)+string16(h||e.lastChar)+string16(p)+string16(b)+"\0d"+string16(y)+string16(v)+"\0\0\0\0\0\0\0\0"+string16(e.xHeight)+string16(e.capHeight)+string16(0)+string16(l||e.firstChar)+"\0"}function createPostTable(e){var t=Math.floor(65536*e.italicAngle);return"\0\0\0"+(0,a.string32)(t)+"\0\0\0\0"+(0,a.string32)(e.fixedPitch)+"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}function createNameTable(e,t){t||(t=[[],[]]);var r,a,i,n,s,o=[t[0][0]||"Original licence",t[0][1]||e,t[0][2]||"Unknown",t[0][3]||"uniqueID",t[0][4]||e,t[0][5]||"Version 0.11",t[0][6]||"",t[0][7]||"Unknown",t[0][8]||"Unknown",t[0][9]||"Unknown"],c=[];for(r=0,a=o.length;r0;if(u&&"CIDFontType2"===t&&this.cidEncoding.startsWith("Identity-")){const t=(0,o.getGlyphMapForStandardFonts)(),r=[];for(const e in t)r[+e]=t[e];if(/Arial-?Black/i.test(e)){var d=(0,o.getSupplementalGlyphMapForArialBlack)();for(const e in d)r[+e]=d[e]}else if(/Calibri/i.test(e)){const e=(0,o.getSupplementalGlyphMapForCalibri)();for(const t in e)r[+t]=e[t]}this.toUnicode instanceof k||this.toUnicode.forEach((function(e,t){r[+e]=t}));this.toFontChar=r;this.toUnicode=new w(r)}else if(/Symbol/i.test(i))this.toFontChar=buildToFontChar(s.SymbolSetEncoding,(0,n.getGlyphsUnicode)(),this.differences);else if(/Dingbats/i.test(i)){/Wingdings/i.test(e)&&(0,a.warn)("Non-embedded Wingdings font, falling back to ZapfDingbats.");this.toFontChar=buildToFontChar(s.ZapfDingbatsEncoding,(0,n.getDingbatsGlyphsUnicode)(),this.differences)}else if(u)this.toFontChar=buildToFontChar(this.defaultEncoding,(0,n.getGlyphsUnicode)(),this.differences);else{const t=(0,n.getGlyphsUnicode)(),r=[];this.toUnicode.forEach((e,a)=>{if(!this.composite){var i=this.differences[e]||this.defaultEncoding[e];const r=(0,c.getUnicodeForGlyph)(i,t);-1!==r&&(a=r)}r[+e]=a});if(this.composite&&this.toUnicode instanceof k&&/Verdana/i.test(e)){const e=(0,o.getGlyphMapForStandardFonts)();for(const t in e)r[+t]=e[t]}this.toFontChar=r}this.loadedName=i.split("-")[0];this.fontType=getFontType(t,r)},checkAndRepair:function Font_checkAndRepair(e,t,r){const o=["OS/2","cmap","head","hhea","hmtx","maxp","name","post","loca","glyf","fpgm","prep","cvt ","CFF "];function readTables(e,t){const r=Object.create(null);r["OS/2"]=null;r.cmap=null;r.head=null;r.hhea=null;r.hmtx=null;r.maxp=null;r.name=null;r.post=null;for(let a=0;a>>0,i=e.getInt32()>>>0,n=e.getInt32()>>>0,s=e.pos;e.pos=e.start?e.start:0;e.skip(i);var o=e.getBytes(n);e.pos=s;if("head"===t){o[8]=o[9]=o[10]=o[11]=0;o[17]|=32}return{tag:t,checksum:r,length:n,offset:i,data:o}}function readOpenTypeHeader(e){return{version:(0,a.bytesToString)(e.getBytes(4)),numTables:e.getUint16(),searchRange:e.getUint16(),entrySelector:e.getUint16(),rangeShift:e.getUint16()}}function sanitizeGlyph(e,t,r,a,i,n){var s={length:0,sizeOfInstructions:0};if(r-t<=12)return s;var o=e.subarray(t,r),c=signedInt16(o[0],o[1]);if(c<0){!function writeSignedInt16(e,t,r){e[t+1]=r;e[t]=r>>>8}(o,0,c=-1);a.set(o,i);s.length=o.length;return s}var l,h=10,u=0;for(l=0;lo.length)return s;if(!n&&f>0){a.set(o.subarray(0,d),i);a.set([0,0],i+d);a.set(o.subarray(g,y),i+d+2);y-=f;o.length-y>3&&(y=y+3&-4);s.length=y;return s}if(o.length-y>3){y=y+3&-4;a.set(o.subarray(0,y),i);s.length=y;return s}a.set(o,i);s.length=o.length;return s}function readNameTable(e){var r=(t.start?t.start:0)+e.offset;t.pos=r;var i=[[],[]],n=e.length,s=r+n;if(0!==t.getUint16()||n<6)return i;var o,c,l=t.getUint16(),h=t.getUint16(),u=[];for(o=0;os)){t.pos=g;var m=f.name;if(f.encoding){for(var p="",b=0,y=f.length;b0&&(h+=S-1)}}else{if(b||v){(0,a.warn)("TT: nested FDEFs not allowed");p=!0}b=!0;d=h;s=f.pop();t.functionsDefined[s]={data:l,i:h}}else if(!b&&!v){s=f[f.length-1];if(isNaN(s))(0,a.info)("TT: CALL empty stack (or invalid entry).");else{t.functionsUsed[s]=!0;if(s in t.functionsStackDeltas){const e=f.length+t.functionsStackDeltas[s];if(e<0){(0,a.warn)("TT: CALL invalid functions stack delta.");t.hintsValid=!1;return}f.length=e}else if(s in t.functionsDefined&&!m.includes(s)){g.push({data:l,i:h,stackTop:f.length-1});m.push(s);if(!(o=t.functionsDefined[s])){(0,a.warn)("TT: CALL non-existent function");t.hintsValid=!1;return}l=o.data;h=o.i}}}if(!b&&!v){let e=0;k<=142?e=c[k]:k>=192&&k<=223?e=-1:k>=224&&(e=-2);if(k>=113&&k<=117){i=f.pop();isNaN(i)||(e=2*-i)}for(;e<0&&f.length>0;){f.pop();e++}for(;e>0;){f.push(NaN);e--}}}t.tooComplexToFollowFunctions=p;var C=[l];h>l.length&&C.push(new Uint8Array(h-l.length));if(d>u){(0,a.warn)("TT: complementing a missing function tail");C.push(new Uint8Array([34,45]))}!function foldTTTable(e,t){if(t.length>1){var r,a,i=0;for(r=0,a=t.length;r>>0,s=[];for(let t=0;t>>0);const o={ttcTag:t,majorVersion:r,minorVersion:i,numFonts:n,offsetTable:s};switch(r){case 1:return o;case 2:o.dsigTag=e.getInt32()>>>0;o.dsigLength=e.getInt32()>>>0;o.dsigOffset=e.getInt32()>>>0;return o}throw new a.FormatError(`Invalid TrueType Collection majorVersion: ${r}.`)}(e);for(let n=0;n0||!(r.cMap instanceof u.IdentityCMap));if("OTTO"===l.version&&!t||!h.head||!h.hhea||!h.maxp||!h.post){g=new d.Stream(h["CFF "].data);f=new T(g,r);adjustWidths(r);return this.convert(e,f,r)}delete h.glyf;delete h.loca;delete h.fpgm;delete h.prep;delete h["cvt "];this.isOpenType=!0}if(!h.maxp)throw new a.FormatError('Required "maxp" table is not found');t.pos=(t.start||0)+h.maxp.offset;var p=t.getInt32();const b=t.getUint16();let v=b+1,w=!0;if(v>65535){w=!1;v=b;(0,a.warn)("Not enough space in glyfs to duplicate first glyph.")}var k=0,C=0;if(p>=65536&&h.maxp.length>=22){t.pos+=8;if(t.getUint16()>2){h.maxp.data[14]=0;h.maxp.data[15]=2}t.pos+=4;k=t.getUint16();t.pos+=4;C=t.getUint16()}h.maxp.data[4]=v>>8;h.maxp.data[5]=255&v;var x=function sanitizeTTPrograms(e,t,r,i){var n={functionsDefined:[],functionsUsed:[],functionsStackDeltas:[],tooComplexToFollowFunctions:!1,hintsValid:!0};e&&sanitizeTTProgram(e,n);t&&sanitizeTTProgram(t,n);e&&function checkInvalidFunctions(e,t){if(!e.tooComplexToFollowFunctions)if(e.functionsDefined.length>t){(0,a.warn)("TT: more functions defined than expected");e.hintsValid=!1}else for(var r=0,i=e.functionsUsed.length;rt){(0,a.warn)("TT: invalid function id: "+r);e.hintsValid=!1;return}if(e.functionsUsed[r]&&!e.functionsDefined[r]){(0,a.warn)("TT: undefined function: "+r);e.hintsValid=!1;return}}}(n,i);if(r&&1&r.length){var s=new Uint8Array(r.length+1);s.set(r.data);r.data=s}return n.hintsValid}(h.fpgm,h.prep,h["cvt "],k);if(!x){delete h.fpgm;delete h.prep;delete h["cvt "]}!function sanitizeMetrics(e,t,r,i,n){if(t){e.pos=(e.start?e.start:0)+t.offset;e.pos+=4;e.pos+=2;e.pos+=2;e.pos+=2;e.pos+=2;e.pos+=2;e.pos+=2;e.pos+=2;e.pos+=2;e.pos+=2;e.pos+=2;e.pos+=8;e.pos+=2;var s=e.getUint16();if(s>i){(0,a.info)("The numOfMetrics ("+s+") should not be greater than the numGlyphs ("+i+")");s=i;t.data[34]=(65280&s)>>8;t.data[35]=255&s}var o=i-s-(r.length-4*s>>1);if(o>0){var c=new Uint8Array(r.length+2*o);c.set(r.data);if(n){c[r.length]=r.data[2];c[r.length+1]=r.data[3]}r.data=c}}else r&&(r.data=null)}(t,h.hhea,h.hmtx,v,w);if(!h.head)throw new a.FormatError('Required "head" table is not found');!function sanitizeHead(e,t,r){var i=e.data,n=function int32(e,t,r,a){return(e<<24)+(t<<16)+(r<<8)+a}(i[0],i[1],i[2],i[3]);if(n>>16!=1){(0,a.info)("Attempting to fix invalid version in head table: "+n);i[0]=0;i[1]=1;i[2]=0;i[3]=0}var s=int16(i[50],i[51]);if(s<0||s>1){(0,a.info)("Attempting to fix invalid indexToLocFormat in head table: "+s);var o=t+1;if(r===o<<1){i[50]=0;i[51]=0}else{if(r!==o<<2)throw new a.FormatError("Could not fix indexToLocFormat: "+s);i[50]=0;i[51]=1}}}(h.head,b,m?h.loca.length:0);var A=Object.create(null);if(m){var I=int16(h.head.data[50],h.head.data[51]),F=function sanitizeGlyphLocations(e,t,r,a,i,n,s){var o,c,l;if(a){o=4;c=function fontItemDecodeLong(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]};l=function fontItemEncodeLong(e,t,r){e[t]=r>>>24&255;e[t+1]=r>>16&255;e[t+2]=r>>8&255;e[t+3]=255&r}}else{o=2;c=function fontItemDecode(e,t){return e[t]<<9|e[t+1]<<1};l=function fontItemEncode(e,t,r){e[t]=r>>9&255;e[t+1]=r>>1&255}}var h=n?r+1:r,u=o*(1+h),d=new Uint8Array(u);d.set(e.data.subarray(0,u));e.data=d;var f,g,m=t.data,p=m.length,b=new Uint8Array(p);const y=[];for(f=0,g=0;fp&&(e=p);y.push({index:f,offset:e,endOffset:0})}y.sort((e,t)=>e.offset-t.offset);for(f=0;fe.index-t.index);var v=Object.create(null),w=0;l(d,0,w);for(f=0,g=o;fs&&(s=k.sizeOfInstructions);l(d,g,w+=S)}if(0===w){var C=new Uint8Array([0,1,0,0,0,0,0,0,0,0,0,0,0,0,49,0]);for(f=0,g=o;fx+w)t.data=b.subarray(0,x+w);else{t.data=new Uint8Array(x+w);t.data.set(b.subarray(0,w))}t.data.set(b.subarray(0,x),w);l(e.data,d.length-o,w+x)}else t.data=b.subarray(0,w);return{missingGlyphs:v,maxSizeOfInstructions:s}}(h.loca,h.glyf,b,I,x,w,C);A=F.missingGlyphs;if(p>=65536&&h.maxp.length>=22){h.maxp.data[26]=F.maxSizeOfInstructions>>8;h.maxp.data[27]=255&F.maxSizeOfInstructions}}if(!h.hhea)throw new a.FormatError('Required "hhea" table is not found');if(0===h.hhea.data[10]&&0===h.hhea.data[11]){h.hhea.data[10]=255;h.hhea.data[11]=255}var P={unitsPerEm:int16(h.head.data[18],h.head.data[19]),yMax:int16(h.head.data[42],h.head.data[43]),yMin:signedInt16(h.head.data[38],h.head.data[39]),ascent:int16(h.hhea.data[4],h.hhea.data[5]),descent:signedInt16(h.hhea.data[6],h.hhea.data[7])};this.ascent=P.ascent/P.unitsPerEm;this.descent=P.descent/P.unitsPerEm;h.post&&function readPostScriptTable(e,r,i){var n=(t.start?t.start:0)+e.offset;t.pos=n;var s,o=n+e.length,c=t.getInt32();t.skip(28);var l,h=!0;switch(c){case 65536:s=y;break;case 131072:var u=t.getUint16();if(u!==i){h=!1;break}var d=[];for(l=0;l=32768){h=!1;break}d.push(f)}if(!h)break;for(var g=[],m=[];t.pos65535)throw new a.FormatError("Max size of CID is 65,535");var r=-1;O?r=t:void 0!==B[t]&&(r=B[t]);r>=0&&r>>0,g=!1;if(!o||o.platformId!==u||o.encodingId!==d){if(0!==u||0!==d&&1!==d&&3!==d)if(1===u&&0===d)g=!0;else if(3!==u||1!==d||!i&&o){if(r&&3===u&&0===d){g=!0;l=!0}}else{g=!0;r||(l=!0)}else g=!0;g&&(o={platformId:u,encodingId:d,offset:f});if(l)break}}o&&(t.pos=s+o.offset);if(!o||-1===t.peekByte()){(0,a.warn)("Could not find a preferred cmap table.");return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:!1}}var m=t.getUint16();t.skip(4);var p,b,y=!1,v=[];if(0===m){for(p=0;p<256;p++){var w=t.getByte();w&&v.push({charCode:p,glyphId:w})}y=!0}else if(4===m){var k=t.getUint16()>>1;t.skip(6);var S,C=[];for(S=0;S>1)-(k-S);n.offsetIndex=T;x=Math.max(x,T+n.end-n.start+1)}else n.offsetIndex=-1}var I=[];for(p=0;p=61440&&t<=61695&&(t&=255);E[t]=N[e].glyphId}if(r.glyphNames&&e.length)for(let t=0;t<256;++t)if(void 0===E[t]&&e[t]){U=e[t];const a=r.glyphNames.indexOf(U);a>0&&hasGlyph(a)&&(E[t]=a)}}0===E.length&&(E[0]=0);let H=v-1;w||(H=0);var z=adjustMapping(E,hasGlyph,H);this.toFontChar=z.toFontChar;h.cmap={tag:"cmap",data:createCmapTable(z.charCodeToGlyphId,v)};h["OS/2"]&&function validateOS2Table(e,t){t.pos=(t.start||0)+e.offset;var r=t.getUint16();t.skip(60);var a=t.getUint16();if(r<4&&768&a)return!1;if(t.getUint16()>t.getUint16())return!1;t.skip(6);if(0===t.getUint16())return!1;e.data[8]=e.data[9]=0;return!0}(h["OS/2"],t)||(h["OS/2"]={tag:"OS/2",data:createOS2Table(r,z.charCodeToGlyphId,P)});if(!m)try{g=new d.Stream(h["CFF "].data);f=new i.CFFParser(g,r,!0).parse();f.duplicateFirstGlyph();var G=new i.CFFCompiler(f);h["CFF "].data=G.compile()}catch(e){(0,a.warn)("Failed to compile font "+r.loadedName)}if(h.name){var W=readNameTable(h.name);h.name.data=createNameTable(e,W)}else h.name={tag:"name",data:createNameTable(this.name)};var X=new S(l.version);for(var V in h)X.addTable(V,h[V].data);return X.toArray()},convert:function Font_convert(e,t,r){r.fixedPitch=!1;r.builtInEncoding&&function adjustToUnicode(e,t){if(!e.hasIncludedToUnicodeMap&&!(e.hasEncoding||t===e.defaultEncoding||e.toUnicode instanceof k)){var r=[],a=(0,n.getGlyphsUnicode)();for(var i in t){var s=t[i],o=(0,c.getUnicodeForGlyph)(s,a);-1!==o&&(r[i]=String.fromCharCode(o))}e.toUnicode.amend(r)}}(r,r.builtInEncoding);let i=1;t instanceof T&&(i=t.numGlyphs-1);var o=t.getGlyphMapping(r),l=adjustMapping(o,t.hasGlyphId.bind(t),i);this.toFontChar=l.toFontChar;var h=t.numGlyphs;function getCharCodes(e,t){var r=null;for(var a in e)if(t===e[a]){r||(r=[]);r.push(0|a)}return r}function createCharCode(e,t){for(var r in e)if(t===e[r])return 0|r;l.charCodeToGlyphId[l.nextAvailableFontCharCode]=t;return l.nextAvailableFontCharCode++}var u=t.seacs;if(u&&u.length){var d=r.fontMatrix||a.FONT_IDENTITY_MATRIX,f=t.getCharset(),g=Object.create(null);for(var m in u){var p=u[m|=0],b=s.StandardEncoding[p[2]],y=s.StandardEncoding[p[3]],v=f.indexOf(b),w=f.indexOf(y);if(!(v<0||w<0)){var C={x:p[0]*d[0]+p[1]*d[2]+d[4],y:p[0]*d[1]+p[1]*d[3]+d[5]},x=getCharCodes(o,m);if(x)for(let e=0,t=x.length;e=0?a:0}}else if(l)for(i in t)c[i]=t[i];else{o=s.StandardEncoding;for(i=0;i=0?a:0}}var h,u=e.differences;if(u)for(i in u){var d=u[i];if(-1===(a=r.indexOf(d))){h||(h=(0,n.getGlyphsUnicode)());var f=recoverGlyphName(d,h);f!==d&&(a=r.indexOf(f))}c[i]=a>=0?a:0}return c}var A=function Type1FontClosure(){function findBlock(e,t,r){for(var a,i=e.length,n=t.length,s=i-n,o=r,c=!1;o=n){o+=a;for(;o=0&&(n[s]=r)}return type1FontGlyphMapping(e,n,a)},hasGlyphId:function Type1Font_hasGlyphID(e){return!(e<0||e>=this.numGlyphs)&&(0===e||this.charstrings[e-1].charstring.length>0)},getSeacs:function Type1Font_getSeacs(e){var t,r,a=[];for(t=0,r=e.length;t0;y--)b[y]-=b[y-1];g.setByName(p,b)}}s.topDict.privateDict=g;var v=new i.CFFIndex;for(l=0,h=a.length;l=t)throw new a.FormatError("Invalid CFF header");if(0!==r){(0,a.info)("cff data is shifted");e=e.subarray(r);this.bytes=e}var i=e[0],n=e[1],s=e[2],o=e[3];return{obj:new CFFHeader(i,n,s,o),endPos:s}}parseDict(e){var t=0;function parseOperand(){var r=e[t++];if(30===r)return function parseFloatOperand(){var r="";const a=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];var i=e.length;for(;t>4,o=15&n;if(15===s)break;r+=a[s];if(15===o)break;r+=a[o]}return parseFloat(r)}();if(28===r)return r=((r=e[t++])<<24|e[t++]<<16)>>16;if(29===r)return r=(r=(r=(r=e[t++])<<8|e[t++])<<8|e[t++])<<8|e[t++];if(r>=32&&r<=246)return r-139;if(r>=247&&r<=250)return 256*(r-247)+e[t++]+108;if(r>=251&&r<=254)return-256*(r-251)-e[t++]-108;(0,a.warn)('CFFParser_parseDict: "'+r+'" is a reserved command.');return NaN}var r=[],i=[];t=0;for(var n=e.length;t10)return!1;for(var o=r.stackSize,c=r.stack,l=i.length,h=0;h>16;h+=2;o++}else if(14===u){if(o>=4){o-=4;if(this.seacAnalysisEnabled){r.seac=c.slice(o,o+4);return!1}}d=e[u]}else if(u>=32&&u<=246){c[o]=u-139;o++}else if(u>=247&&u<=254){c[o]=u<251?(u-247<<8)+i[h]+108:-(u-251<<8)-i[h]-108;h++;o++}else if(255===u){c[o]=(i[h]<<24|i[h+1]<<16|i[h+2]<<8|i[h+3])/65536;h+=4;o++}else if(19===u||20===u){r.hints+=o>>1;h+=r.hints+7>>3;o%=2;d=e[u]}else{if(10===u||29===u){var g;if(!(g=10===u?n:s)){d=e[u];(0,a.warn)("Missing subrsIndex for "+d.id);return!1}var m=32768;g.count<1240?m=107:g.count<33900&&(m=1131);var p=c[--o]+m;if(p<0||p>=g.count||isNaN(p)){d=e[u];(0,a.warn)("Out of bounds subrIndex for "+d.id);return!1}r.stackSize=o;r.callDepth++;if(!this.parseCharString(r,g.get(p),n,s))return!1;r.callDepth--;o=r.stackSize;continue}if(11===u){r.stackSize=o;return!0}d=e[u]}if(d){if(d.stem){r.hints+=o>>1;if(3===u||23===u)r.hasVStems=!0;else if(r.hasVStems&&(1===u||18===u)){(0,a.warn)("CFF stem hints are in wrong order");i[h-1]=1===u?3:23}}if("min"in d&&!r.undefStack&&o=2&&d.stem?o%=2:o>1&&(0,a.warn)("Found too many parameters for stack-clearing command");o>0&&c[o-1]>=0&&(r.width=c[o-1])}if("stackDelta"in d){"stackFn"in d&&d.stackFn(c,o);o+=d.stackDelta}else if(d.stackClearing)o=0;else if(d.resetStack){o=0;r.undefStack=!1}else if(d.undefStack){o=0;r.undefStack=!0;r.firstStackClearing=!1}}}r.stackSize=o;return!0}parseCharStrings({charStrings:e,localSubrIndex:t,globalSubrIndex:r,fdSelect:i,fdArray:n,privateDict:s}){for(var o=[],c=[],l=e.count,h=0;h=n.length){(0,a.warn)("Invalid fd index for glyph index.");f=!1}f&&(g=(m=n[p].privateDict).subrsIndex)}else t&&(g=t);f&&(f=this.parseCharString(d,u,g,r));if(null!==d.width){const e=m.getByName("nominalWidthX");c[h]=e+d.width}else{const e=m.getByName("defaultWidthX");c[h]=e}null!==d.seac&&(o[h]=d.seac);f||e.set(h,new Uint8Array([14]))}return{charStrings:e,seacs:o,widths:c}}emptyPrivateDictionary(e){var t=this.createDict(l,[],e.strings);e.setByKey(18,[0,0]);e.privateDict=t}parsePrivateDict(e){if(e.hasName("Private")){var t=e.getByName("Private");if(Array.isArray(t)&&2===t.length){var r=t[0],a=t[1];if(0===r||a>=this.bytes.length)this.emptyPrivateDictionary(e);else{var i=a+r,n=this.bytes.subarray(a,i),s=this.parseDict(n),o=this.createDict(l,s,e.strings);e.privateDict=o;if(o.getByName("Subrs")){var c=o.getByName("Subrs"),h=a+c;if(0===c||h>=this.bytes.length)this.emptyPrivateDictionary(e);else{var u=this.parseIndex(h);o.subrsIndex=u.obj}}}}else e.removeByName("Private")}else this.emptyPrivateDictionary(e)}parseCharsets(e,t,r,n){if(0===e)return new CFFCharset(!0,h.ISO_ADOBE,i.ISOAdobeCharset);if(1===e)return new CFFCharset(!0,h.EXPERT,i.ExpertCharset);if(2===e)return new CFFCharset(!0,h.EXPERT_SUBSET,i.ExpertSubsetCharset);var s=this.bytes,o=e,c=s[e++];const l=[n?0:".notdef"];var u,d,f;t-=1;switch(c){case 0:for(f=0;f=65535)(0,a.warn)("Not enough space in charstrings to duplicate first glyph.");else{var e=this.charStrings.get(0);this.charStrings.add(e);this.isCIDFont&&this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0])}}hasGlyphId(e){return!(e<0||e>=this.charStrings.count)&&this.charStrings.get(e).length>0}}t.CFF=CFF;class CFFHeader{constructor(e,t,r,a){this.major=e;this.minor=t;this.hdrSize=r;this.offSize=a}}t.CFFHeader=CFFHeader;class CFFStrings{constructor(){this.strings=[]}get(e){return e>=0&&e<=390?s[e]:e-391<=this.strings.length?this.strings[e-391]:s[0]}getSID(e){let t=s.indexOf(e);if(-1!==t)return t;t=this.strings.indexOf(e);return-1!==t?t+391:-1}add(e){this.strings.push(e)}get count(){return this.strings.length}}t.CFFStrings=CFFStrings;class CFFIndex{constructor(){this.objects=[];this.length=0}add(e){this.length+=e.length;this.objects.push(e)}set(e,t){this.length+=t.length-this.objects[e].length;this.objects[e]=t}get(e){return this.objects[e]}get count(){return this.objects.length}}t.CFFIndex=CFFIndex;class CFFDict{constructor(e,t){this.keyToNameMap=e.keyToNameMap;this.nameToKeyMap=e.nameToKeyMap;this.defaults=e.defaults;this.types=e.types;this.opcodes=e.opcodes;this.order=e.order;this.strings=t;this.values=Object.create(null)}setByKey(e,t){if(!(e in this.keyToNameMap))return!1;var r=t.length;if(0===r)return!0;for(var i=0;i=this.fdSelect.length?-1:this.fdSelect[e]}}t.CFFFDSelect=CFFFDSelect;class CFFOffsetTracker{constructor(){this.offsets=Object.create(null)}isTracking(e){return e in this.offsets}track(e,t){if(e in this.offsets)throw new a.FormatError("Already tracking location of "+e);this.offsets[e]=t}offset(e){for(var t in this.offsets)this.offsets[t]+=e}setEntryLocation(e,t,r){if(!(e in this.offsets))throw new a.FormatError("Not tracking location of "+e);for(var i=r.data,n=this.offsets[e],s=0,o=t.length;s>24&255;i[h]=f>>16&255;i[u]=f>>8&255;i[d]=255&f}}}class CFFCompiler{constructor(e){this.cff=e}compile(){var e=this.cff,t={data:[],length:0,add:function CFFCompiler_add(e){this.data=this.data.concat(e);this.length=this.data.length}},r=this.compileHeader(e.header);t.add(r);var i=this.compileNameIndex(e.names);t.add(i);if(e.isCIDFont&&e.topDict.hasName("FontMatrix")){var n=e.topDict.getByName("FontMatrix");e.topDict.removeByName("FontMatrix");for(var s=0,o=e.fdArray.length;s=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?[28,e>>8&255,255&e]:[29,e>>24&255,e>>16&255,e>>8&255,255&e]}compileHeader(e){return[e.major,e.minor,e.hdrSize,e.offSize]}compileNameIndex(e){for(var t=new CFFIndex,r=0,i=e.length;r"~"||"["===l||"]"===l||"("===l||")"===l||"{"===l||"}"===l||"<"===l||">"===l||"/"===l||"%"===l)&&(l="_");o[c]=l}""===(o=o.join(""))&&(o="Bad_Font_Name");t.add((0,a.stringToBytes)(o))}return this.compileIndex(t)}compileTopDicts(e,t,r){for(var a=[],i=new CFFIndex,n=0,s=e.length;n>8&255,255&s]);else{n=new Uint8Array(1+2*s);n[0]=0;let t=0;const i=e.charset.length;let o=!1;for(let s=1;s>8&255;n[s+1]=255&c}}return this.compileTypedArray(n)}compileEncoding(e){return this.compileTypedArray(e.raw)}compileFDSelect(e){const t=e.format;let r,a;switch(t){case 0:r=new Uint8Array(1+e.fdSelect.length);r[0]=t;for(a=0;a>8&255,255&i,n];for(a=1;a>8&255,255&a,t);n=t}}const o=(s.length-3)/3;s[1]=o>>8&255;s[2]=255&o;s.push(a>>8&255,255&a);r=new Uint8Array(s)}return this.compileTypedArray(r)}compileTypedArray(e){for(var t=[],r=0,a=e.length;r>8&255,255&a],o=1;for(i=0;i>8&255,255&c):3===n?s.push(c>>16&255,c>>8&255,255&c):s.push(c>>>24&255,c>>16&255,c>>8&255,255&c);r[i]&&(c+=r[i].length)}for(i=0;i=65520&&e<=65535?0:e>=62976&&e<=63743?i()[e]||e:173===e?45:e};t.reverseIfRtl=function reverseIfRtl(e){var t=e.length;if(t<=1||!function isRTLRangeFor(e){var t=n[13];return e>=t.begin&&e=(t=n[11]).begin&&e=0;a--)r+=e[a];return r};t.getUnicodeRangeFor=function getUnicodeRangeFor(e){for(var t=0,r=n.length;t=a.begin&&e=5&&i<=7))return-1;a=e.substring(1)}if(a===a.toUpperCase()&&(r=parseInt(a,16))>=0)return r}return-1}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.FontRendererFactory=void 0;var a=r(2),i=r(31),n=r(34),s=r(33),o=r(12),c=function FontRendererFactoryClosure(){function getLong(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function getUshort(e,t){return e[t]<<8|e[t+1]}function getSubroutineBias(e){const t=e.length;let r=32768;t<1240?r=107:t<33900&&(r=1131);return r}function parseCmap(e,t,r){var i,n,s,o=1===getUshort(e,t+2)?getLong(e,t+8):getLong(e,t+16),c=getUshort(e,t+o);if(4===c){getUshort(e,t+o+2);var l=getUshort(e,t+o+6)>>1;n=t+o+14;i=[];for(s=0;s>1;r=0&&e>16,s=0,o=0;i+=10;if(n<0)do{a=e[i]<<8|e[i+1];var c,l,h=e[i+2]<<8|e[i+3];i+=4;if(1&a){c=(e[i]<<24|e[i+1]<<16)>>16;l=(e[i+2]<<24|e[i+3]<<16)>>16;i+=4}else{c=e[i++];l=e[i++]}if(2&a){s=c;o=l}else{s=0;o=0}var u=1,d=1,f=0,g=0;if(8&a){u=d=(e[i]<<24|e[i+1]<<16)/1073741824;i+=2}else if(64&a){u=(e[i]<<24|e[i+1]<<16)/1073741824;d=(e[i+2]<<24|e[i+3]<<16)/1073741824;i+=4}else if(128&a){u=(e[i]<<24|e[i+1]<<16)/1073741824;f=(e[i+2]<<24|e[i+3]<<16)/1073741824;g=(e[i+4]<<24|e[i+5]<<16)/1073741824;d=(e[i+6]<<24|e[i+7]<<16)/1073741824;i+=8}var m=r.glyphs[h];if(m){t.push({cmd:"save"});t.push({cmd:"transform",args:[u,f,g,d,s,o]});compileGlyf(m,t,r);t.push({cmd:"restore"})}}while(32&a);else{var p,b,y=[];for(p=0;p0;)w.push({flags:a})}for(p=0;p>16;i+=2;break;case 2:s-=e[i++];break;case 18:s+=e[i++]}w[p].x=s}for(p=0;p>16;i+=2;break;case 4:o-=e[i++];break;case 36:o+=e[i++]}w[p].y=o}var S=0;for(i=0;i>1;v=!0;break;case 4:c+=n.pop();moveTo(o,c);v=!0;break;case 5:for(;n.length>0;){o+=n.shift();c+=n.shift();lineTo(o,c)}break;case 6:for(;n.length>0;){lineTo(o+=n.shift(),c);if(0===n.length)break;c+=n.shift();lineTo(o,c)}break;case 7:for(;n.length>0;){c+=n.shift();lineTo(o,c);if(0===n.length)break;lineTo(o+=n.shift(),c)}break;case 8:for(;n.length>0;){u=o+n.shift();f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d+n.shift();c=g+n.shift();bezierCurveTo(u,f,d,g,o,c)}break;case 10:b=n.pop();y=null;if(r.isCFFCIDFont){const e=r.fdSelect.getFDIndex(i);if(e>=0&&eMath.abs(c-S)?o+=n.shift():c+=n.shift();bezierCurveTo(u,f,d,g,o,c);break;default:throw new a.FormatError("unknown operator: 12 "+w)}break;case 14:if(n.length>=4){var C=n.pop(),x=n.pop();c=n.pop();o=n.pop();t.push({cmd:"save"});t.push({cmd:"translate",args:[o,c]});var A=lookupCmap(r.cmap,String.fromCharCode(r.glyphNameMap[s.StandardEncoding[C]]));compileCharString(r.glyphs[A.glyphId],t,r,A.glyphId);t.push({cmd:"restore"});A=lookupCmap(r.cmap,String.fromCharCode(r.glyphNameMap[s.StandardEncoding[x]]));compileCharString(r.glyphs[A.glyphId],t,r,A.glyphId)}return;case 18:l+=n.length>>1;v=!0;break;case 19:case 20:h+=(l+=n.length>>1)+7>>3;v=!0;break;case 21:c+=n.pop();moveTo(o+=n.pop(),c);v=!0;break;case 22:moveTo(o+=n.pop(),c);v=!0;break;case 23:l+=n.length>>1;v=!0;break;case 24:for(;n.length>2;){u=o+n.shift();f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d+n.shift();c=g+n.shift();bezierCurveTo(u,f,d,g,o,c)}o+=n.shift();c+=n.shift();lineTo(o,c);break;case 25:for(;n.length>6;){o+=n.shift();c+=n.shift();lineTo(o,c)}u=o+n.shift();f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d+n.shift();c=g+n.shift();bezierCurveTo(u,f,d,g,o,c);break;case 26:n.length%2&&(o+=n.shift());for(;n.length>0;){u=o;f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d;c=g+n.shift();bezierCurveTo(u,f,d,g,o,c)}break;case 27:n.length%2&&(c+=n.shift());for(;n.length>0;)bezierCurveTo(u=o+n.shift(),f=c,d=u+n.shift(),g=f+n.shift(),o=d+n.shift(),c=g);break;case 28:n.push((e[h]<<24|e[h+1]<<16)>>16);h+=2;break;case 29:b=n.pop()+r.gsubrsBias;(y=r.gsubrs[b])&&parse(y);break;case 30:for(;n.length>0;){u=o;f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d+n.shift();c=g+(1===n.length?n.shift():0);bezierCurveTo(u,f,d,g,o,c);if(0===n.length)break;u=o+n.shift();f=c;d=u+n.shift();g=f+n.shift();c=g+n.shift();bezierCurveTo(u,f,d,g,o=d+(1===n.length?n.shift():0),c)}break;case 31:for(;n.length>0;){u=o+n.shift();f=c;d=u+n.shift();g=f+n.shift();c=g+n.shift();bezierCurveTo(u,f,d,g,o=d+(1===n.length?n.shift():0),c);if(0===n.length)break;u=o;f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d+n.shift();c=g+(1===n.length?n.shift():0);bezierCurveTo(u,f,d,g,o,c)}break;default:if(w<32)throw new a.FormatError("unknown operator: "+w);if(w<247)n.push(w-139);else if(w<251)n.push(256*(w-247)+e[h++]+108);else if(w<255)n.push(256*-(w-251)-e[h++]-108);else{n.push((e[h]<<24|e[h+1]<<16|e[h+2]<<8|e[h+3])/65536);h+=4}}v&&(n.length=0)}}(e)}(e,t,this,r)}}return{create:function FontRendererFactory_create(e,t){for(var r,i,n,s,o,c,l=new Uint8Array(e.data),h=getUshort(l,4),u=0,d=12;ua)return!0;for(var i=a-e,n=i;n>8&255,255&s);else{s=65536*s|0;this.output.push(255,s>>24&255,s>>16&255,s>>8&255,255&s)}}this.output.push.apply(this.output,t);r?this.stack.splice(i,e):this.stack.length=0;return!1}};return Type1CharString}(),c=function Type1ParserClosure(){function isHexDigit(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function decrypt(e,t,r){if(r>=e.length)return new Uint8Array(0);var a,i,n=0|t;for(a=0;a>8;n=52845*(c+n)+22719&65535}return o}function isSpecial(e){return 47===e||91===e||93===e||123===e||125===e||40===e||41===e}function Type1Parser(e,t,r){if(t){var a=e.getBytes(),s=!((isHexDigit(a[0])||(0,i.isWhiteSpace)(a[0]))&&isHexDigit(a[1])&&isHexDigit(a[2])&&isHexDigit(a[3])&&isHexDigit(a[4])&&isHexDigit(a[5])&&isHexDigit(a[6])&&isHexDigit(a[7]));e=new n.Stream(s?decrypt(a,55665,4):function decryptAscii(e,t,r){var a,i,n=0|t,s=e.length,o=new Uint8Array(s>>>1);for(a=0,i=0;a>8;n=52845*(h+n)+22719&65535}}}return o.slice(r,i)}(a,55665,4))}this.seacAnalysisEnabled=!!r;this.stream=e;this.nextChar()}Type1Parser.prototype={readNumberArray:function Type1Parser_readNumberArray(){this.getToken();for(var e=[];;){var t=this.getToken();if(null===t||"]"===t||"}"===t)break;e.push(parseFloat(t||0))}return e},readNumber:function Type1Parser_readNumber(){var e=this.getToken();return parseFloat(e||0)},readInt:function Type1Parser_readInt(){var e=this.getToken();return 0|parseInt(e||0,10)},readBoolean:function Type1Parser_readBoolean(){return"true"===this.getToken()?1:0},nextChar:function Type1_nextChar(){return this.currentChar=this.stream.getByte()},getToken:function Type1Parser_getToken(){for(var e=!1,t=this.currentChar;;){if(-1===t)return null;if(e)10!==t&&13!==t||(e=!1);else if(37===t)e=!0;else if(!(0,i.isWhiteSpace)(t))break;t=this.nextChar()}if(isSpecial(t)){this.nextChar();return String.fromCharCode(t)}var r="";do{r+=String.fromCharCode(t);t=this.nextChar()}while(t>=0&&!(0,i.isWhiteSpace)(t)&&!isSpecial(t));return r},readCharStrings:function Type1Parser_readCharStrings(e,t){return-1===t?e:decrypt(e,4330,t)},extractFontProgram:function Type1Parser_extractFontProgram(e){var t=this.stream,r=[],a=[],i=Object.create(null);i.lenIV=4;for(var n,s,c,l,h,u={subrs:[],charstrings:[],properties:{privateData:i}};null!==(n=this.getToken());)if("/"===n)switch(n=this.getToken()){case"CharStrings":this.getToken();this.getToken();this.getToken();this.getToken();for(;null!==(n=this.getToken())&&"end"!==n;)if("/"===n){var d=this.getToken();s=this.readInt();this.getToken();c=s>0?t.getBytes(s):new Uint8Array(0);l=u.properties.privateData.lenIV;h=this.readCharStrings(c,l);this.nextChar();"noaccess"===(n=this.getToken())&&this.getToken();a.push({glyph:d,encoded:h})}break;case"Subrs":this.readInt();this.getToken();for(;"dup"===this.getToken();){const e=this.readInt();s=this.readInt();this.getToken();c=s>0?t.getBytes(s):new Uint8Array(0);l=u.properties.privateData.lenIV;h=this.readCharStrings(c,l);this.nextChar();"noaccess"===(n=this.getToken())&&this.getToken();r[e]=h}break;case"BlueValues":case"OtherBlues":case"FamilyBlues":case"FamilyOtherBlues":var f=this.readNumberArray();f.length>0&&f.length,0;break;case"StemSnapH":case"StemSnapV":u.properties.privateData[n]=this.readNumberArray();break;case"StdHW":case"StdVW":u.properties.privateData[n]=this.readNumberArray()[0];break;case"BlueShift":case"lenIV":case"BlueFuzz":case"BlueScale":case"LanguageGroup":case"ExpansionFactor":u.properties.privateData[n]=this.readNumber();break;case"ForceBold":u.properties.privateData[n]=this.readBoolean()}for(var g=0;g-1&&void 0===e.widths[t]&&t>=e.firstChar&&t<=e.lastChar&&(e.widths[t]=m.width)}}return u},extractFontHeader:function Type1Parser_extractFontHeader(e){for(var t;null!==(t=this.getToken());)if("/"===t)switch(t=this.getToken()){case"FontMatrix":var r=this.readNumberArray();e.fontMatrix=r;break;case"Encoding":var i,n=this.getToken();if(/^\d+$/.test(n)){i=[];var s=0|parseInt(n,10);this.getToken();for(var o=0;o=d||I<=0)(0,a.info)("Bad shading domain.");else{var P,E=new Float32Array(l.numComps),B=new Float32Array(1);for(let e=0;e<=10;e++){B[0]=u+e*I;T(B,0,E,0);P=l.getRgb(E,0);var O=a.Util.makeCssRgb(P[0],P[1],P[2]);F.push([e/10,O])}var M="transparent";if(e.has("Background")){P=l.getRgb(e.get("Background"),0);M=a.Util.makeCssRgb(P[0],P[1],P[2])}if(!m){F.unshift([0,M]);F[1][0]+=g.SMALL_NUMBER}if(!p){F[F.length-1][0]-=g.SMALL_NUMBER;F.push([1,M])}this.colorStops=F}}RadialAxial.prototype={getIR:function RadialAxial_getIR(){var e,t,r,i,n,s=this.coordsArr,l=this.shadingType;if(l===o){t=[s[0],s[1]];r=[s[2],s[3]];i=null;n=null;e="axial"}else if(l===c){t=[s[0],s[1]];r=[s[3],s[4]];i=s[2];n=s[5];e="radial"}else(0,a.unreachable)("getPattern type unknown: "+l);var h=this.matrix;if(h){t=a.Util.applyTransform(t,h);r=a.Util.applyTransform(r,h);if(l===c){var u=a.Util.singularValueDecompose2dScale(h);i*=u[0];n*=u[1]}}return["RadialAxial",e,this.bbox,this.colorStops,t,r,i,n]}};return RadialAxial}();g.Mesh=function MeshClosure(){function MeshStreamReader(e,t){this.stream=e;this.context=t;this.buffer=0;this.bufferLength=0;var r=t.numComps;this.tmpCompsBuf=new Float32Array(r);var a=t.colorSpace.numComps;this.tmpCsCompsBuf=t.colorFn?new Float32Array(a):this.tmpCompsBuf}MeshStreamReader.prototype={get hasData(){if(this.stream.end)return this.stream.pos0)return!0;var e=this.stream.getByte();if(e<0)return!1;this.buffer=e;this.bufferLength=8;return!0},readBits:function MeshStreamReader_readBits(e){var t=this.buffer,r=this.bufferLength;if(32===e){if(0===r)return(this.stream.getByte()<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte())>>>0;t=t<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte();var a=this.stream.getByte();this.buffer=a&(1<>r)>>>0}if(8===e&&0===r)return this.stream.getByte();for(;r>r},align:function MeshStreamReader_align(){this.buffer=0;this.bufferLength=0},readFlag:function MeshStreamReader_readFlag(){return this.readBits(this.context.bitsPerFlag)},readCoordinate:function MeshStreamReader_readCoordinate(){var e=this.context.bitsPerCoordinate,t=this.readBits(e),r=this.readBits(e),a=this.context.decode,i=e<32?1/((1<o?o:t;r=r>c?c:r;a=a>c)*h;l&=(1<r?e=r:e0&&(d=i[h-1]);var f=a[1];h>1,c=a.length>>1,u=new l(s),d=Object.create(null),f=8192,g=new Float32Array(c);return function constructPostScriptFromIRResult(e,t,r,a){var i,s,l="",h=g;for(i=0;i(v=n[2*i+1]))&&(s=v);p[i]=s}if(f>0){f--;d[l]=p}r.set(p,a)}else r.set(m,a)}}}}();var c=function PostScriptStackClosure(){function PostScriptStack(e){this.stack=e?Array.prototype.slice.call(e,0):[]}PostScriptStack.prototype={push:function PostScriptStack_push(e){if(this.stack.length>=100)throw new Error("PostScript function stack overflow.");this.stack.push(e)},pop:function PostScriptStack_pop(){if(this.stack.length<=0)throw new Error("PostScript function stack underflow.");return this.stack.pop()},copy:function PostScriptStack_copy(e){if(this.stack.length+e>=100)throw new Error("PostScript function stack overflow.");for(var t=this.stack,r=t.length-e,a=e-1;a>=0;a--,r++)t.push(t[r])},index:function PostScriptStack_index(e){this.push(this.stack[this.stack.length-e-1])},roll:function PostScriptStack_roll(e,t){var r,a,i,n=this.stack,s=n.length-e,o=n.length-1,c=s+(t-Math.floor(t/e)*e);for(r=s,a=o;r0?n.push(r<>a);break;case"ceiling":r=n.pop();n.push(Math.ceil(r));break;case"copy":r=n.pop();n.copy(r);break;case"cos":r=n.pop();n.push(Math.cos(r));break;case"cvi":r=0|n.pop();n.push(r);break;case"cvr":break;case"div":a=n.pop();r=n.pop();n.push(r/a);break;case"dup":n.copy(1);break;case"eq":a=n.pop();r=n.pop();n.push(r===a);break;case"exch":n.roll(2,1);break;case"exp":a=n.pop();r=n.pop();n.push(r**a);break;case"false":n.push(!1);break;case"floor":r=n.pop();n.push(Math.floor(r));break;case"ge":a=n.pop();r=n.pop();n.push(r>=a);break;case"gt":a=n.pop();r=n.pop();n.push(r>a);break;case"idiv":a=n.pop();r=n.pop();n.push(r/a|0);break;case"index":r=n.pop();n.index(r);break;case"le":a=n.pop();r=n.pop();n.push(r<=a);break;case"ln":r=n.pop();n.push(Math.log(r));break;case"log":r=n.pop();n.push(Math.log(r)/Math.LN10);break;case"lt":a=n.pop();r=n.pop();n.push(r=t?new AstLiteral(t):e.max<=t?e:new AstMin(e,t)}function PostScriptCompiler(){}PostScriptCompiler.prototype={compile:function PostScriptCompiler_compile(e,t,r){var a,i,n,s,o,c,l,h,u=[],d=[],f=t.length>>1,g=r.length>>1,m=0;for(let e=0;ee.min){s.unshift("Math.max(",i,", ");s.push(")")}if(n=0&&(t>=65&&t<=90||t>=97&&t<=122);)r.push(String.fromCharCode(t));const a=r.join("");switch(a.toLowerCase()){case"if":return o.IF;case"ifelse":return o.IFELSE;default:return o.getOperator(a)}}getNumber(){let e=this.currentChar;const t=this.strBuf;t.length=0;t[0]=String.fromCharCode(e);for(;(e=this.nextChar())>=0&&(e>=48&&e<=57||45===e||46===e);)t.push(String.fromCharCode(e));const r=parseFloat(t.join(""));if(isNaN(r))throw new a.FormatError("Invalid floating point number: "+r);return r}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.bidi=function bidi(e,t,r){var c=!0,l=e.length;if(0===l||r)return createBidiText(e,c,r);s.length=l;o.length=l;var h,u,d=0;for(h=0;h=0&&"ET"===o[k];--k)o[k]="EN";for(k=h+1;k0&&(C=o[h-1]);var x=v;S+1A&&isOdd(A)&&(I=A)}for(A=T;A>=I;--A){var F=-1;for(h=0,u=m.length;h=0){reverseValues(s,F,h);F=-1}}else F<0&&(F=h);F>=0&&reverseValues(s,F,m.length)}for(h=0,u=s.length;h"!==P||(s[h]="")}return createBidiText(s.join(""),c)};var a=r(2),i=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],n=["AN","AN","AN","AN","AN","AN","ON","ON","AL","ET","ET","AL","CS","AL","ON","ON","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","ON","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","AL","AL","AL","AL","AL","AL"];function isOdd(e){return 0!=(1&e)}function isEven(e){return 0==(1&e)}function findUnequal(e,t,r){for(var a=t,i=e.length;a>>8;t[r++]=255&i}}}else{if(!(0,a.isArrayBuffer)(e))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");t=e;r=t.byteLength}const i=r>>2,n=r-4*i,s=new Uint32Array(t.buffer,0,i);let o=0,c=0,l=this.h1,h=this.h2;const u=3432918353,d=461845907;for(let e=0;e>>17;o=o*d&4294901760|13715*o&65535;l^=o;l=l<<13|l>>>19;l=5*l+3864292196}else{c=s[e];c=c*u&4294901760|11601*c&65535;c=c<<15|c>>>17;c=c*d&4294901760|13715*c&65535;h^=c;h=h<<13|h>>>19;h=5*h+3864292196}o=0;switch(n){case 3:o^=t[4*i+2]<<16;case 2:o^=t[4*i+1]<<8;case 1:o^=t[4*i];o=o*u&4294901760|11601*o&65535;o=o<<15|o>>>17;o=o*d&4294901760|13715*o&65535;1&i?l^=o:h^=o}this.h1=l;this.h2=h}hexdigest(){let e=this.h1,t=this.h2;e^=t>>>1;e=3981806797*e&4294901760|36045*e&65535;t=4283543511*t&4294901760|(2950163797*(t<<16|e>>>16)&4294901760)>>>16;e^=t>>>1;e=444984403*e&4294901760|60499*e&65535;t=3301882366*t&4294901760|(3120437893*(t<<16|e>>>16)&4294901760)>>>16;e^=t>>>1;const r=(e>>>0).toString(16),a=(t>>>0).toString(16);return r.padStart(8,"0")+a.padStart(8,"0")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.PDFImage=void 0;var a=r(2),i=r(5),n=r(23),s=r(12),o=r(18),c=r(21);function decodeAndClamp(e,t,r,a){(e=t+e*r)<0?e=0:e>a&&(e=a);return e}function resizeImageMask(e,t,r,a,i,n){var s=i*n;let o;o=t<=8?new Uint8Array(s):t<=16?new Uint16Array(s):new Uint32Array(s);var c,l,h,u,d=r/i,f=a/n,g=0,m=new Uint16Array(i),p=r;for(c=0;c0&&Number.isInteger(r.height)&&r.height>0&&(r.width!==p||r.height!==b)){(0,a.warn)("PDFImage - using the Width/Height of the image data, rather than the image dictionary.");p=r.width;b=r.height}if(p<1||b<1)throw new a.FormatError(`Invalid image width: ${p} or height: ${b}`);this.width=p;this.height=b;this.interpolate=f.get("Interpolate","I")||!1;this.imageMask=f.get("ImageMask","IM")||!1;this.matte=f.get("Matte")||!1;var y=r.bitsPerComponent;if(!y&&!(y=f.get("BitsPerComponent","BPC"))){if(!this.imageMask)throw new a.FormatError("Bits per component missing in image: "+this.imageMask);y=1}this.bpc=y;if(!this.imageMask){let o=f.getRaw("ColorSpace")||f.getRaw("CS");if(!o){(0,a.info)("JPX images (which do not require color spaces)");switch(r.numComps){case 1:o=i.Name.get("DeviceGray");break;case 3:o=i.Name.get("DeviceRGB");break;case 4:o=i.Name.get("DeviceCMYK");break;default:throw new Error(`JPX images with ${r.numComps} color components not supported.`)}}this.colorSpace=n.ColorSpace.parse({cs:o,xref:e,resources:s?t:null,pdfFunctionFactory:u,localColorSpaceCache:d});this.numComps=this.colorSpace.numComps}this.decode=f.getArray("Decode","D");this.needsDecode=!1;if(this.decode&&(this.colorSpace&&!this.colorSpace.isDefaultDecode(this.decode,y)||h&&!n.ColorSpace.isDefaultDecode(this.decode,1))){this.needsDecode=!0;var v=(1<>3)*r,c=e.byteLength;if(!a||i&&!(o===c))if(i){(n=new Uint8ClampedArray(o)).set(e);for(s=c;s>7&1;o[d+1]=l>>6&1;o[d+2]=l>>5&1;o[d+3]=l>>4&1;o[d+4]=l>>3&1;o[d+5]=l>>2&1;o[d+6]=l>>1&1;o[d+7]=1&l;d+=8}if(d>=1}}}else{var b=0;l=0;for(d=0,c=n;d>y;r<0?r=0:r>u&&(r=u);o[d]=r;l&=(1<f[y+1]){m=255;break}}s[l]=m}}if(s)for(l=0,u=3,h=t*i;l>3;if(!e){var f;"DeviceGray"===this.colorSpace.name&&1===u?f=a.ImageKind.GRAYSCALE_1BPP:"DeviceRGB"!==this.colorSpace.name||8!==u||this.needsDecode||(f=a.ImageKind.RGB_24BPP);if(f&&!this.smask&&!this.mask&&r===l&&i===h){n.kind=f;t=this.getImageBytes(h*d);if(this.image instanceof s.DecodeStream)n.data=t;else{var g=new Uint8ClampedArray(t.length);g.set(t);n.data=g}if(this.needsDecode){(0,a.assert)(f===a.ImageKind.GRAYSCALE_1BPP,"PDFImage.createImageData: The image must be grayscale.");for(var m=n.data,p=0,b=m.length;p>3,l=this.getImageBytes(s*c),h=this.getComponents(l);if(1!==o){this.needsDecode&&this.decodeBuffer(h);i=n*s;var u=255/((1<{const t=e.data;if(t.targetName!==this.sourceName)return;if(t.stream){this._processStreamMessage(t);return}if(t.callback){const e=t.callbackId,r=this.callbackCapabilities[e];if(!r)throw new Error("Cannot resolve callback "+e);delete this.callbackCapabilities[e];if(t.callback===i)r.resolve(t.data);else{if(t.callback!==n)throw new Error("Unexpected callback case");r.reject(wrapReason(t.reason))}return}const a=this.actionHandler[t.action];if(!a)throw new Error("Unknown action from worker: "+t.action);if(t.callbackId){const e=this.sourceName,s=t.sourceName;new Promise((function(e){e(a(t.data))})).then((function(a){r.postMessage({sourceName:e,targetName:s,callback:i,callbackId:t.callbackId,data:a})}),(function(a){r.postMessage({sourceName:e,targetName:s,callback:n,callbackId:t.callbackId,reason:wrapReason(a)})}))}else t.streamId?this._createStreamSink(t):a(t.data)};r.addEventListener("message",this._onComObjOnMessage)}on(e,t){const r=this.actionHandler;if(r[e])throw new Error(`There is already an actionName called "${e}"`);r[e]=t}send(e,t,r){this._postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},r)}sendWithPromise(e,t,r){const i=this.callbackId++,n=(0,a.createPromiseCapability)();this.callbackCapabilities[i]=n;try{this._postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},r)}catch(e){n.reject(e)}return n.promise}sendWithStream(e,t,r,i){const n=this.streamId++,o=this.sourceName,c=this.targetName,l=this.comObj;return new ReadableStream({start:r=>{const s=(0,a.createPromiseCapability)();this.streamControllers[n]={controller:r,startCall:s,pullCall:null,cancelCall:null,isClosed:!1};this._postMessage({sourceName:o,targetName:c,action:e,streamId:n,data:t,desiredSize:r.desiredSize},i);return s.promise},pull:e=>{const t=(0,a.createPromiseCapability)();this.streamControllers[n].pullCall=t;l.postMessage({sourceName:o,targetName:c,stream:u,streamId:n,desiredSize:e.desiredSize});return t.promise},cancel:e=>{(0,a.assert)(e instanceof Error,"cancel must have a valid reason");const t=(0,a.createPromiseCapability)();this.streamControllers[n].cancelCall=t;this.streamControllers[n].isClosed=!0;l.postMessage({sourceName:o,targetName:c,stream:s,streamId:n,reason:wrapReason(e)});return t.promise}},r)}_createStreamSink(e){const t=this,r=this.actionHandler[e.action],i=e.streamId,n=this.sourceName,s=e.sourceName,o=this.comObj,u={enqueue(e,r=1,o){if(this.isCancelled)return;const c=this.desiredSize;this.desiredSize-=r;if(c>0&&this.desiredSize<=0){this.sinkCapability=(0,a.createPromiseCapability)();this.ready=this.sinkCapability.promise}t._postMessage({sourceName:n,targetName:s,stream:l,streamId:i,chunk:e},o)},close(){if(!this.isCancelled){this.isCancelled=!0;o.postMessage({sourceName:n,targetName:s,stream:c,streamId:i});delete t.streamSinks[i]}},error(e){(0,a.assert)(e instanceof Error,"error must have a valid reason");if(!this.isCancelled){this.isCancelled=!0;o.postMessage({sourceName:n,targetName:s,stream:h,streamId:i,reason:wrapReason(e)})}},sinkCapability:(0,a.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};u.sinkCapability.resolve();u.ready=u.sinkCapability.promise;this.streamSinks[i]=u;new Promise((function(t){t(r(e.data,u))})).then((function(){o.postMessage({sourceName:n,targetName:s,stream:f,streamId:i,success:!0})}),(function(e){o.postMessage({sourceName:n,targetName:s,stream:f,streamId:i,reason:wrapReason(e)})}))}_processStreamMessage(e){const t=e.streamId,r=this.sourceName,i=e.sourceName,n=this.comObj;switch(e.stream){case f:e.success?this.streamControllers[t].startCall.resolve():this.streamControllers[t].startCall.reject(wrapReason(e.reason));break;case d:e.success?this.streamControllers[t].pullCall.resolve():this.streamControllers[t].pullCall.reject(wrapReason(e.reason));break;case u:if(!this.streamSinks[t]){n.postMessage({sourceName:r,targetName:i,stream:d,streamId:t,success:!0});break}this.streamSinks[t].desiredSize<=0&&e.desiredSize>0&&this.streamSinks[t].sinkCapability.resolve();this.streamSinks[t].desiredSize=e.desiredSize;const{onPull:g}=this.streamSinks[e.streamId];new Promise((function(e){e(g&&g())})).then((function(){n.postMessage({sourceName:r,targetName:i,stream:d,streamId:t,success:!0})}),(function(e){n.postMessage({sourceName:r,targetName:i,stream:d,streamId:t,reason:wrapReason(e)})}));break;case l:(0,a.assert)(this.streamControllers[t],"enqueue should have stream controller");if(this.streamControllers[t].isClosed)break;this.streamControllers[t].controller.enqueue(e.chunk);break;case c:(0,a.assert)(this.streamControllers[t],"close should have stream controller");if(this.streamControllers[t].isClosed)break;this.streamControllers[t].isClosed=!0;this.streamControllers[t].controller.close();this._deleteStreamController(t);break;case h:(0,a.assert)(this.streamControllers[t],"error should have stream controller");this.streamControllers[t].controller.error(wrapReason(e.reason));this._deleteStreamController(t);break;case o:e.success?this.streamControllers[t].cancelCall.resolve():this.streamControllers[t].cancelCall.reject(wrapReason(e.reason));this._deleteStreamController(t);break;case s:if(!this.streamSinks[t])break;const{onCancel:m}=this.streamSinks[e.streamId];new Promise((function(t){t(m&&m(wrapReason(e.reason)))})).then((function(){n.postMessage({sourceName:r,targetName:i,stream:o,streamId:t,success:!0})}),(function(e){n.postMessage({sourceName:r,targetName:i,stream:o,streamId:t,reason:wrapReason(e)})}));this.streamSinks[t].sinkCapability.reject(wrapReason(e.reason));this.streamSinks[t].isCancelled=!0;delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}async _deleteStreamController(e){await Promise.allSettled([this.streamControllers[e].startCall,this.streamControllers[e].pullCall,this.streamControllers[e].cancelCall].map((function(e){return e&&e.promise})));delete this.streamControllers[e]}_postMessage(e,t){t&&this.postMessageTransfers?this.comObj.postMessage(e,t):this.comObj.postMessage(e)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.PDFWorkerStream=void 0;var a=r(2);t.PDFWorkerStream=class PDFWorkerStream{constructor(e){this._msgHandler=e;this._contentLength=null;this._fullRequestReader=null;this._rangeRequestReaders=[]}getFullReader(){(0,a.assert)(!this._fullRequestReader,"PDFWorkerStream.getFullReader can only be called once.");this._fullRequestReader=new PDFWorkerStreamReader(this._msgHandler);return this._fullRequestReader}getRangeReader(e,t){const r=new PDFWorkerStreamRangeReader(e,t,this._msgHandler);this._rangeRequestReaders.push(r);return r}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e);this._rangeRequestReaders.slice(0).forEach((function(t){t.cancel(e)}))}};class PDFWorkerStreamReader{constructor(e){this._msgHandler=e;this.onProgress=null;this._contentLength=null;this._isRangeSupported=!1;this._isStreamingSupported=!1;const t=this._msgHandler.sendWithStream("GetReader");this._reader=t.getReader();this._headersReady=this._msgHandler.sendWithPromise("ReaderHeadersReady").then(e=>{this._isStreamingSupported=e.isStreamingSupported;this._isRangeSupported=e.isRangeSupported;this._contentLength=e.contentLength})}get headersReady(){return this._headersReady}get contentLength(){return this._contentLength}get isStreamingSupported(){return this._isStreamingSupported}get isRangeSupported(){return this._isRangeSupported}async read(){const{value:e,done:t}=await this._reader.read();return t?{value:void 0,done:!0}:{value:e.buffer,done:!1}}cancel(e){this._reader.cancel(e)}}class PDFWorkerStreamRangeReader{constructor(e,t,r){this._msgHandler=r;this.onProgress=null;const a=this._msgHandler.sendWithStream("GetRangeReader",{begin:e,end:t});this._reader=a.getReader()}get isStreamingSupported(){return!1}async read(){const{value:e,done:t}=await this._reader.read();return t?{value:void 0,done:!0}:{value:e.buffer,done:!1}}cancel(e){this._reader.cancel(e)}}}])}));