UNPKG

pdfjs-dist

Version:

Generic build of Mozilla's PDF.js library.

21 lines • 423 kB
/** * @licstart The following is the entire license notice for the * JavaScript code in this page * * Copyright 2024 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @licend The above is the entire license notice for the * JavaScript code in this page */var A={d:(I,g)=>{for(var B in g)A.o(g,B)&&!A.o(I,B)&&Object.defineProperty(I,B,{enumerable:!0,get:g[B]})},o:(A,I)=>Object.prototype.hasOwnProperty.call(A,I)},__webpack_exports__ = globalThis.pdfjsImageDecoders = {};A.d(__webpack_exports__,{Jbig2Error:()=>Jbig2Error,Jbig2Image:()=>Jbig2Image,JpegError:()=>JpegError,JpegImage:()=>JpegImage,JpxError:()=>JpxError,JpxImage:()=>JpxImage,VerbosityLevel:()=>I,getVerbosityLevel:()=>getVerbosityLevel,setVerbosityLevel:()=>setVerbosityLevel});"object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&process.type;const I={ERRORS:0,WARNINGS:1,INFOS:5};let g=I.WARNINGS;function setVerbosityLevel(A){Number.isInteger(A)&&(g=A)}function getVerbosityLevel(){return g}function info(A){g>=I.INFOS&&console.log(`Info: ${A}`)}function util_warn(A){g>=I.WARNINGS&&console.log(`Warning: ${A}`)}function unreachable(A){throw new Error(A)}function shadow(A,I,g,B=!1){Object.defineProperty(A,I,{value:g,enumerable:!B,configurable:!0,writable:!1});return g}const B=function BaseExceptionClosure(){function BaseException(A,I){this.message=A;this.name=I}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();class FormatError extends B{constructor(A){super(A,"FormatError")}}function bytesToString(A){"object"==typeof A&&void 0!==A?.length||unreachable("Invalid argument for bytesToString");const I=A.length,g=8192;if(I<g)return String.fromCharCode.apply(null,A);const B=[];for(let Q=0;Q<I;Q+=g){const C=Math.min(Q+g,I),E=A.subarray(Q,C);B.push(String.fromCharCode.apply(null,E))}return B.join("")}class util_FeatureTest{static get isLittleEndian(){return shadow(this,"isLittleEndian",function isLittleEndian(){const A=new Uint8Array(4);A[0]=1;return 1===new Uint32Array(A.buffer,0,1)[0]}())}static get isEvalSupported(){return shadow(this,"isEvalSupported",function isEvalSupported(){try{new Function("");return!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return shadow(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?shadow(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):shadow(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return shadow(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}Array.from(Array(256).keys(),(A=>A.toString(16).padStart(2,"0")));"function"!=typeof Promise.try&&(Promise.try=function(A,...I){return new Promise((g=>{g(A(...I))}))});Symbol("CIRCULAR_REF"),Symbol("EOF");Object.create(null),Object.create(null),Object.create(null);Symbol.iterator;Symbol.iterator;Symbol.iterator;class base_stream_BaseStream{get length(){unreachable("Abstract getter `length` accessed")}get isEmpty(){unreachable("Abstract getter `isEmpty` accessed")}get isDataLoaded(){return shadow(this,"isDataLoaded",!0)}getByte(){unreachable("Abstract method `getByte` called")}getBytes(A){unreachable("Abstract method `getBytes` called")}async getImageData(A,I){return this.getBytes(A,I)}async asyncGetBytes(){unreachable("Abstract method `asyncGetBytes` called")}get isAsync(){return!1}get canAsyncDecodeImageFromBuffer(){return!1}async getTransferableImage(){return null}peekByte(){const A=this.getByte();-1!==A&&this.pos--;return A}peekBytes(A){const I=this.getBytes(A);this.pos-=I.length;return I}getUint16(){const A=this.getByte(),I=this.getByte();return-1===A||-1===I?-1:(A<<8)+I}getInt32(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()}getByteRange(A,I){unreachable("Abstract method `getByteRange` called")}getString(A){return bytesToString(this.getBytes(A))}skip(A){this.pos+=A||1}reset(){unreachable("Abstract method `reset` called")}moveStart(){unreachable("Abstract method `moveStart` called")}makeSubStream(A,I,g=null){unreachable("Abstract method `makeSubStream` called")}getBaseStreams(){return null}}function log2(A){return A>0?Math.ceil(Math.log2(A)):0}function readInt8(A,I){return A[I]<<24>>24}function readUint16(A,I){return A[I]<<8|A[I+1]}function readUint32(A,I){return(A[I]<<24|A[I+1]<<16|A[I+2]<<8|A[I+3])>>>0}const Q=[{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}];class ArithmeticDecoder{constructor(A,I,g){this.data=A;this.bp=I;this.dataEnd=g;this.chigh=A[I];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 A=this.data;let I=this.bp;if(255===A[I])if(A[I+1]>143){this.clow+=65280;this.ct=8}else{I++;this.clow+=A[I]<<9;this.ct=7;this.bp=I}else{I++;this.clow+=I<this.dataEnd?A[I]<<8:65280;this.ct=8;this.bp=I}if(this.clow>65535){this.chigh+=this.clow>>16;this.clow&=65535}}readBit(A,I){let g=A[I]>>1,B=1&A[I];const C=Q[g],E=C.qe;let i,o=this.a-E;if(this.chigh<E)if(o<E){o=E;i=B;g=C.nmps}else{o=E;i=1^B;1===C.switchFlag&&(B=i);g=C.nlps}else{this.chigh-=E;if(32768&o){this.a=o;return B}if(o<E){i=1^B;1===C.switchFlag&&(B=i);g=C.nlps}else{i=B;g=C.nmps}}do{0===this.ct&&this.byteIn();o<<=1;this.chigh=this.chigh<<1&65535|this.clow>>15&1;this.clow=this.clow<<1&65535;this.ct--}while(!(32768&o));this.a=o;A[I]=g<<1|B;return i}}const C=-1,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]],i=[[-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]],o=[[-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]],D=[[-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]],h=[[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]],F=[[-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]];class CCITTFaxDecoder{constructor(A,I={}){if("function"!=typeof A?.next)throw new Error('CCITTFaxDecoder - invalid "source" parameter.');this.source=A;this.eof=!1;this.encoding=I.K||0;this.eoline=I.EndOfLine||!1;this.byteAlign=I.EncodedByteAlign||!1;this.columns=I.Columns||1728;this.rows=I.Rows||0;this.eoblock=I.EndOfBlock??!0;this.black=I.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;let g;for(;0===(g=this._lookBits(12));)this._eatBits(1);1===g&&this._eatBits(12);if(this.encoding>0){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}}readNextChar(){if(this.eof)return-1;const A=this.refLine,I=this.codingLine,g=this.columns;let B,Q,E,i,o;if(0===this.outputBits){this.rowsDone&&(this.eof=!0);if(this.eof)return-1;this.err=!1;let E,o,D;if(this.nextLine2D){for(i=0;I[i]<g;++i)A[i]=I[i];A[i++]=g;A[i]=g;I[0]=0;this.codingPos=0;B=0;Q=0;for(;I[this.codingPos]<g;){E=this._getTwoDimCode();switch(E){case 0:this._addPixels(A[B+1],Q);A[B+1]<g&&(B+=2);break;case 1:E=o=0;if(Q){do{E+=D=this._getBlackCode()}while(D>=64);do{o+=D=this._getWhiteCode()}while(D>=64)}else{do{E+=D=this._getWhiteCode()}while(D>=64);do{o+=D=this._getBlackCode()}while(D>=64)}this._addPixels(I[this.codingPos]+E,Q);I[this.codingPos]<g&&this._addPixels(I[this.codingPos]+o,1^Q);for(;A[B]<=I[this.codingPos]&&A[B]<g;)B+=2;break;case 7:this._addPixels(A[B]+3,Q);Q^=1;if(I[this.codingPos]<g){++B;for(;A[B]<=I[this.codingPos]&&A[B]<g;)B+=2}break;case 5:this._addPixels(A[B]+2,Q);Q^=1;if(I[this.codingPos]<g){++B;for(;A[B]<=I[this.codingPos]&&A[B]<g;)B+=2}break;case 3:this._addPixels(A[B]+1,Q);Q^=1;if(I[this.codingPos]<g){++B;for(;A[B]<=I[this.codingPos]&&A[B]<g;)B+=2}break;case 2:this._addPixels(A[B],Q);Q^=1;if(I[this.codingPos]<g){++B;for(;A[B]<=I[this.codingPos]&&A[B]<g;)B+=2}break;case 8:this._addPixelsNeg(A[B]-3,Q);Q^=1;if(I[this.codingPos]<g){B>0?--B:++B;for(;A[B]<=I[this.codingPos]&&A[B]<g;)B+=2}break;case 6:this._addPixelsNeg(A[B]-2,Q);Q^=1;if(I[this.codingPos]<g){B>0?--B:++B;for(;A[B]<=I[this.codingPos]&&A[B]<g;)B+=2}break;case 4:this._addPixelsNeg(A[B]-1,Q);Q^=1;if(I[this.codingPos]<g){B>0?--B:++B;for(;A[B]<=I[this.codingPos]&&A[B]<g;)B+=2}break;case C:this._addPixels(g,0);this.eof=!0;break;default:info("bad 2d code");this._addPixels(g,0);this.err=!0}}}else{I[0]=0;this.codingPos=0;Q=0;for(;I[this.codingPos]<g;){E=0;if(Q)do{E+=D=this._getBlackCode()}while(D>=64);else do{E+=D=this._getWhiteCode()}while(D>=64);this._addPixels(I[this.codingPos]+E,Q);Q^=1}}let h=!1;this.byteAlign&&(this.inputBits&=-8);if(this.eoblock||this.row!==this.rows-1){E=this._lookBits(12);if(this.eoline)for(;E!==C&&1!==E;){this._eatBits(1);E=this._lookBits(12)}else for(;0===E;){this._eatBits(1);E=this._lookBits(12)}if(1===E){this._eatBits(12);h=!0}else E===C&&(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){E=this._lookBits(12);if(1===E){this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}if(this.encoding>=0)for(i=0;i<4;++i){E=this._lookBits(12);1!==E&&info("bad rtc code: "+E);this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}}this.eof=!0}}else if(this.err&&this.eoline){for(;;){E=this._lookBits(13);if(E===C){this.eof=!0;return-1}if(E>>1==1)break;this._eatBits(1)}this._eatBits(12);if(this.encoding>0){this._eatBits(1);this.nextLine2D=!(1&E)}}this.outputBits=I[0]>0?I[this.codingPos=0]:I[this.codingPos=1];this.row++}if(this.outputBits>=8){o=1&this.codingPos?0:255;this.outputBits-=8;if(0===this.outputBits&&I[this.codingPos]<g){this.codingPos++;this.outputBits=I[this.codingPos]-I[this.codingPos-1]}}else{E=8;o=0;do{if("number"!=typeof this.outputBits)throw new FormatError('Invalid /CCITTFaxDecode data, "outputBits" must be a number.');if(this.outputBits>E){o<<=E;1&this.codingPos||(o|=255>>8-E);this.outputBits-=E;E=0}else{o<<=this.outputBits;1&this.codingPos||(o|=255>>8-this.outputBits);E-=this.outputBits;this.outputBits=0;if(I[this.codingPos]<g){this.codingPos++;this.outputBits=I[this.codingPos]-I[this.codingPos-1]}else if(E>0){o<<=E;E=0}}}while(E)}this.black&&(o^=255);return o}_addPixels(A,I){const g=this.codingLine;let B=this.codingPos;if(A>g[B]){if(A>this.columns){info("row is wrong length");this.err=!0;A=this.columns}1&B^I&&++B;g[B]=A}this.codingPos=B}_addPixelsNeg(A,I){const g=this.codingLine;let B=this.codingPos;if(A>g[B]){if(A>this.columns){info("row is wrong length");this.err=!0;A=this.columns}1&B^I&&++B;g[B]=A}else if(A<g[B]){if(A<0){info("invalid code");this.err=!0;A=0}for(;B>0&&A<g[B-1];)--B;g[B]=A}this.codingPos=B}_findTableCode(A,I,g,B){const Q=B||0;for(let B=A;B<=I;++B){let A=this._lookBits(B);if(A===C)return[!0,1,!1];B<I&&(A<<=I-B);if(!Q||A>=Q){const I=g[A-Q];if(I[0]===B){this._eatBits(B);return[!0,I[1],!0]}}}return[!1,0,!1]}_getTwoDimCode(){let A,I=0;if(this.eoblock){I=this._lookBits(7);A=E[I];if(A?.[0]>0){this._eatBits(A[0]);return A[1]}}else{const A=this._findTableCode(1,7,E);if(A[0]&&A[2])return A[1]}info("Bad two dim code");return C}_getWhiteCode(){let A,I=0;if(this.eoblock){I=this._lookBits(12);if(I===C)return 1;A=I>>5?o[I>>3]:i[I];if(A[0]>0){this._eatBits(A[0]);return A[1]}}else{let A=this._findTableCode(1,9,o);if(A[0])return A[1];A=this._findTableCode(11,12,i);if(A[0])return A[1]}info("bad white code");this._eatBits(1);return 1}_getBlackCode(){let A,I;if(this.eoblock){A=this._lookBits(13);if(A===C)return 1;I=A>>7?!(A>>9)&&A>>7?h[(A>>1)-64]:F[A>>7]:D[A];if(I[0]>0){this._eatBits(I[0]);return I[1]}}else{let A=this._findTableCode(2,6,F);if(A[0])return A[1];A=this._findTableCode(7,12,h,64);if(A[0])return A[1];A=this._findTableCode(10,13,D);if(A[0])return A[1]}info("bad black code");this._eatBits(1);return 1}_lookBits(A){let I;for(;this.inputBits<A;){if(-1===(I=this.source.next()))return 0===this.inputBits?C:this.inputBuf<<A-this.inputBits&65535>>16-A;this.inputBuf=this.inputBuf<<8|I;this.inputBits+=8}return this.inputBuf>>this.inputBits-A&65535>>16-A}_eatBits(A){(this.inputBits-=A)<0&&(this.inputBits=0)}}class Jbig2Error extends B{constructor(A){super(A,"Jbig2Error")}}class ContextCache{getContexts(A){return A in this?this[A]:this[A]=new Int8Array(65536)}}class DecodingContext{constructor(A,I,g){this.data=A;this.start=I;this.end=g}get decoder(){return shadow(this,"decoder",new ArithmeticDecoder(this.data,this.start,this.end))}get contextCache(){return shadow(this,"contextCache",new ContextCache)}}function decodeInteger(A,I,g){const B=A.getContexts(I);let Q=1;function readBits(A){let I=0;for(let C=0;C<A;C++){const A=g.readBit(B,Q);Q=Q<256?Q<<1|A:511&(Q<<1|A)|256;I=I<<1|A}return I>>>0}const C=readBits(1),E=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);let i;0===C?i=E:E>0&&(i=-E);return i>=-2147483648&&i<=2147483647?i:null}function decodeIAID(A,I,g){const B=A.getContexts("IAID");let Q=1;for(let A=0;A<g;A++){Q=Q<<1|I.readBit(B,Q)}return g<31?Q&(1<<g)-1:2147483647&Q}const s=["SymbolDictionary",null,null,null,"IntermediateTextRegion",null,"ImmediateTextRegion","ImmediateLosslessTextRegion",null,null,null,null,null,null,null,null,"PatternDictionary",null,null,null,"IntermediateHalftoneRegion",null,"ImmediateHalftoneRegion","ImmediateLosslessHalftoneRegion",null,null,null,null,null,null,null,null,null,null,null,null,"IntermediateGenericRegion",null,"ImmediateGenericRegion","ImmediateLosslessGenericRegion","IntermediateGenericRefinementRegion",null,"ImmediateGenericRefinementRegion","ImmediateLosslessGenericRefinementRegion",null,null,null,null,"PageInformation","EndOfPage","EndOfStripe","EndOfFile","Profiles","Tables",null,null,null,null,null,null,null,null,"Extension"],G=[[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:2,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-2,y:0},{x:-1,y:0}],[{x:-3,y:-1},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}]],a=[{coding:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:-1,y:1},{x:0,y:1},{x:1,y:1}]},{coding:[{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:0,y:1},{x:1,y:1}]}],y=[39717,1941,229,405],w=[32,8];function decodeBitmap(A,I,g,B,Q,C,E,i){if(A){return decodeMMRBitmap(new Reader(i.data,i.start,i.end),I,g,!1)}if(0===B&&!C&&!Q&&4===E.length&&3===E[0].x&&-1===E[0].y&&-3===E[1].x&&-1===E[1].y&&2===E[2].x&&-2===E[2].y&&-2===E[3].x&&-2===E[3].y)return function decodeBitmapTemplate0(A,I,g){const B=g.decoder,Q=g.contextCache.getContexts("GB"),C=[];let E,i,o,D,h,F,s;for(i=0;i<I;i++){h=C[i]=new Uint8Array(A);F=i<1?h:C[i-1];s=i<2?h:C[i-2];E=s[0]<<13|s[1]<<12|s[2]<<11|F[0]<<7|F[1]<<6|F[2]<<5|F[3]<<4;for(o=0;o<A;o++){h[o]=D=B.readBit(Q,E);E=(31735&E)<<1|(o+3<A?s[o+3]<<11:0)|(o+4<A?F[o+4]<<4:0)|D}}return C}(I,g,i);const o=!!C,D=G[B].concat(E);D.sort((function(A,I){return A.y-I.y||A.x-I.x}));const h=D.length,F=new Int8Array(h),s=new Int8Array(h),a=[];let w,R,S=0,J=0,c=0,U=0;for(R=0;R<h;R++){F[R]=D[R].x;s[R]=D[R].y;J=Math.min(J,D[R].x);c=Math.max(c,D[R].x);U=Math.min(U,D[R].y);R<h-1&&D[R].y===D[R+1].y&&D[R].x===D[R+1].x-1?S|=1<<h-1-R:a.push(R)}const k=a.length,N=new Int8Array(k),t=new Int8Array(k),Y=new Uint16Array(k);for(w=0;w<k;w++){R=a[w];N[w]=D[R].x;t[w]=D[R].y;Y[w]=1<<h-1-R}const H=-J,e=-U,M=I-c,n=y[B];let K=new Uint8Array(I);const L=[],d=i.decoder,r=i.contextCache.getContexts("GB");let l,q,f,b,W,Z=0,x=0;for(let A=0;A<g;A++){if(Q){Z^=d.readBit(r,n);if(Z){L.push(K);continue}}K=new Uint8Array(K);L.push(K);for(l=0;l<I;l++){if(o&&C[A][l]){K[l]=0;continue}if(l>=H&&l<M&&A>=e){x=x<<1&S;for(R=0;R<k;R++){q=A+t[R];f=l+N[R];b=L[q][f];if(b){b=Y[R];x|=b}}}else{x=0;W=h-1;for(R=0;R<h;R++,W--){f=l+F[R];if(f>=0&&f<I){q=A+s[R];if(q>=0){b=L[q][f];b&&(x|=b<<W)}}}}const g=d.readBit(r,x);K[l]=g}}return L}function decodeRefinement(A,I,g,B,Q,C,E,i,o){let D=a[g].coding;0===g&&(D=D.concat([i[0]]));const h=D.length,F=new Int32Array(h),s=new Int32Array(h);let G;for(G=0;G<h;G++){F[G]=D[G].x;s[G]=D[G].y}let y=a[g].reference;0===g&&(y=y.concat([i[1]]));const R=y.length,S=new Int32Array(R),J=new Int32Array(R);for(G=0;G<R;G++){S[G]=y[G].x;J[G]=y[G].y}const c=B[0].length,U=B.length,k=w[g],N=[],t=o.decoder,Y=o.contextCache.getContexts("GR");let H=0;for(let g=0;g<I;g++){if(E){H^=t.readBit(Y,k);if(H)throw new Jbig2Error("prediction is not supported")}const I=new Uint8Array(A);N.push(I);for(let E=0;E<A;E++){let i,o,D=0;for(G=0;G<h;G++){i=g+s[G];o=E+F[G];i<0||o<0||o>=A?D<<=1:D=D<<1|N[i][o]}for(G=0;G<R;G++){i=g+J[G]-C;o=E+S[G]-Q;i<0||i>=U||o<0||o>=c?D<<=1:D=D<<1|B[i][o]}const a=t.readBit(Y,D);I[E]=a}}return N}function decodeTextRegion(A,I,g,B,Q,C,E,i,o,D,h,F,s,G,a,y,w,R,S){if(A&&I)throw new Jbig2Error("refinement with Huffman is not supported");const J=[];let c,U;for(c=0;c<B;c++){U=new Uint8Array(g);if(Q)for(let A=0;A<g;A++)U[A]=Q;J.push(U)}const k=w.decoder,N=w.contextCache;let t=A?-G.tableDeltaT.decode(S):-decodeInteger(N,"IADT",k),Y=0;c=0;for(;c<C;){t+=A?G.tableDeltaT.decode(S):decodeInteger(N,"IADT",k);Y+=A?G.tableFirstS.decode(S):decodeInteger(N,"IAFS",k);let B=Y;for(;;){let Q=0;E>1&&(Q=A?S.readBits(R):decodeInteger(N,"IAIT",k));const C=E*t+Q,Y=A?G.symbolIDTable.decode(S):decodeIAID(N,k,o),H=I&&(A?S.readBit():decodeInteger(N,"IARI",k));let e=i[Y],M=e[0].length,n=e.length;if(H){const A=decodeInteger(N,"IARDW",k),I=decodeInteger(N,"IARDH",k);M+=A;n+=I;e=decodeRefinement(M,n,a,e,(A>>1)+decodeInteger(N,"IARDX",k),(I>>1)+decodeInteger(N,"IARDY",k),!1,y,w)}let K=0;D?1&F?K=n-1:B+=n-1:F>1?B+=M-1:K=M-1;const L=C-(1&F?0:n-1),d=B-(2&F?M-1:0);let r,l,q;if(D)for(r=0;r<n;r++){U=J[d+r];if(!U)continue;q=e[r];const A=Math.min(g-L,M);switch(s){case 0:for(l=0;l<A;l++)U[L+l]|=q[l];break;case 2:for(l=0;l<A;l++)U[L+l]^=q[l];break;default:throw new Jbig2Error(`operator ${s} is not supported`)}}else for(l=0;l<n;l++){U=J[L+l];if(U){q=e[l];switch(s){case 0:for(r=0;r<M;r++)U[d+r]|=q[r];break;case 2:for(r=0;r<M;r++)U[d+r]^=q[r];break;default:throw new Jbig2Error(`operator ${s} is not supported`)}}}c++;const f=A?G.tableDeltaS.decode(S):decodeInteger(N,"IADS",k);if(null===f)break;B+=K+f+h}}return J}function readSegmentHeader(A,I){const g={};g.number=readUint32(A,I);const B=A[I+4],Q=63&B;if(!s[Q])throw new Jbig2Error("invalid segment type: "+Q);g.type=Q;g.typeName=s[Q];g.deferredNonRetain=!!(128&B);const C=!!(64&B),E=A[I+5];let i=E>>5&7;const o=[31&E];let D=I+6;if(7===E){i=536870911&readUint32(A,D-1);D+=3;let I=i+7>>3;o[0]=A[D++];for(;--I>0;)o.push(A[D++])}else if(5===E||6===E)throw new Jbig2Error("invalid referred-to flags");g.retainBits=o;let h=4;g.number<=256?h=1:g.number<=65536&&(h=2);const F=[];let G,a;for(G=0;G<i;G++){let I;I=1===h?A[D]:2===h?readUint16(A,D):readUint32(A,D);F.push(I);D+=h}g.referredTo=F;if(C){g.pageAssociation=readUint32(A,D);D+=4}else g.pageAssociation=A[D++];g.length=readUint32(A,D);D+=4;if(4294967295===g.length){if(38!==Q)throw new Jbig2Error("invalid unknown segment length");{const I=readRegionSegmentInformation(A,D),B=!!(1&A[D+R]),Q=6,C=new Uint8Array(Q);if(!B){C[0]=255;C[1]=172}C[2]=I.height>>>24&255;C[3]=I.height>>16&255;C[4]=I.height>>8&255;C[5]=255&I.height;for(G=D,a=A.length;G<a;G++){let I=0;for(;I<Q&&C[I]===A[G+I];)I++;if(I===Q){g.length=G+Q;break}}if(4294967295===g.length)throw new Jbig2Error("segment end was not found")}}g.headerEnd=D;return g}function readSegments(A,I,g,B){const Q=[];let C=g;for(;C<B;){const g=readSegmentHeader(I,C);C=g.headerEnd;const B={header:g,data:I};if(!A.randomAccess){B.start=C;C+=g.length;B.end=C}Q.push(B);if(51===g.type)break}if(A.randomAccess)for(let A=0,I=Q.length;A<I;A++){Q[A].start=C;C+=Q[A].header.length;Q[A].end=C}return Q}function readRegionSegmentInformation(A,I){return{width:readUint32(A,I),height:readUint32(A,I+4),x:readUint32(A,I+8),y:readUint32(A,I+12),combinationOperator:7&A[I+16]}}const R=17;function processSegment(A,I){const g=A.header,B=A.data,Q=A.end;let C,E,i,o,D=A.start;switch(g.type){case 0:const A={},I=readUint16(B,D);A.huffman=!!(1&I);A.refinement=!!(2&I);A.huffmanDHSelector=I>>2&3;A.huffmanDWSelector=I>>4&3;A.bitmapSizeSelector=I>>6&1;A.aggregationInstancesSelector=I>>7&1;A.bitmapCodingContextUsed=!!(256&I);A.bitmapCodingContextRetained=!!(512&I);A.template=I>>10&3;A.refinementTemplate=I>>12&1;D+=2;if(!A.huffman){o=0===A.template?4:1;E=[];for(i=0;i<o;i++){E.push({x:readInt8(B,D),y:readInt8(B,D+1)});D+=2}A.at=E}if(A.refinement&&!A.refinementTemplate){E=[];for(i=0;i<2;i++){E.push({x:readInt8(B,D),y:readInt8(B,D+1)});D+=2}A.refinementAt=E}A.numberOfExportedSymbols=readUint32(B,D);D+=4;A.numberOfNewSymbols=readUint32(B,D);D+=4;C=[A,g.number,g.referredTo,B,D,Q];break;case 6:case 7:const h={};h.info=readRegionSegmentInformation(B,D);D+=R;const F=readUint16(B,D);D+=2;h.huffman=!!(1&F);h.refinement=!!(2&F);h.logStripSize=F>>2&3;h.stripSize=1<<h.logStripSize;h.referenceCorner=F>>4&3;h.transposed=!!(64&F);h.combinationOperator=F>>7&3;h.defaultPixelValue=F>>9&1;h.dsOffset=F<<17>>27;h.refinementTemplate=F>>15&1;if(h.huffman){const A=readUint16(B,D);D+=2;h.huffmanFS=3&A;h.huffmanDS=A>>2&3;h.huffmanDT=A>>4&3;h.huffmanRefinementDW=A>>6&3;h.huffmanRefinementDH=A>>8&3;h.huffmanRefinementDX=A>>10&3;h.huffmanRefinementDY=A>>12&3;h.huffmanRefinementSizeSelector=!!(16384&A)}if(h.refinement&&!h.refinementTemplate){E=[];for(i=0;i<2;i++){E.push({x:readInt8(B,D),y:readInt8(B,D+1)});D+=2}h.refinementAt=E}h.numberOfSymbolInstances=readUint32(B,D);D+=4;C=[h,g.referredTo,B,D,Q];break;case 16:const s={},G=B[D++];s.mmr=!!(1&G);s.template=G>>1&3;s.patternWidth=B[D++];s.patternHeight=B[D++];s.maxPatternIndex=readUint32(B,D);D+=4;C=[s,g.number,B,D,Q];break;case 22:case 23:const a={};a.info=readRegionSegmentInformation(B,D);D+=R;const y=B[D++];a.mmr=!!(1&y);a.template=y>>1&3;a.enableSkip=!!(8&y);a.combinationOperator=y>>4&7;a.defaultPixelValue=y>>7&1;a.gridWidth=readUint32(B,D);D+=4;a.gridHeight=readUint32(B,D);D+=4;a.gridOffsetX=4294967295&readUint32(B,D);D+=4;a.gridOffsetY=4294967295&readUint32(B,D);D+=4;a.gridVectorX=readUint16(B,D);D+=2;a.gridVectorY=readUint16(B,D);D+=2;C=[a,g.referredTo,B,D,Q];break;case 38:case 39:const w={};w.info=readRegionSegmentInformation(B,D);D+=R;const S=B[D++];w.mmr=!!(1&S);w.template=S>>1&3;w.prediction=!!(8&S);if(!w.mmr){o=0===w.template?4:1;E=[];for(i=0;i<o;i++){E.push({x:readInt8(B,D),y:readInt8(B,D+1)});D+=2}w.at=E}C=[w,B,D,Q];break;case 48:const J={width:readUint32(B,D),height:readUint32(B,D+4),resolutionX:readUint32(B,D+8),resolutionY:readUint32(B,D+12)};4294967295===J.height&&delete J.height;const c=B[D+16];readUint16(B,D+17);J.lossless=!!(1&c);J.refinement=!!(2&c);J.defaultPixelValue=c>>2&1;J.combinationOperator=c>>3&3;J.requiresBuffer=!!(32&c);J.combinationOperatorOverride=!!(64&c);C=[J];break;case 49:case 50:case 51:case 62:break;case 53:C=[g.number,B,D,Q];break;default:throw new Jbig2Error(`segment type ${g.typeName}(${g.type}) is not implemented`)}const h="on"+g.typeName;h in I&&I[h].apply(I,C)}function processSegments(A,I){for(let g=0,B=A.length;g<B;g++)processSegment(A[g],I)}class SimpleSegmentVisitor{onPageInformation(A){this.currentPageInfo=A;const I=A.width+7>>3,g=new Uint8ClampedArray(I*A.height);A.defaultPixelValue&&g.fill(255);this.buffer=g}drawBitmap(A,I){const g=this.currentPageInfo,B=A.width,Q=A.height,C=g.width+7>>3,E=g.combinationOperatorOverride?A.combinationOperator:g.combinationOperator,i=this.buffer,o=128>>(7&A.x);let D,h,F,s,G=A.y*C+(A.x>>3);switch(E){case 0:for(D=0;D<Q;D++){F=o;s=G;for(h=0;h<B;h++){I[D][h]&&(i[s]|=F);F>>=1;if(!F){F=128;s++}}G+=C}break;case 2:for(D=0;D<Q;D++){F=o;s=G;for(h=0;h<B;h++){I[D][h]&&(i[s]^=F);F>>=1;if(!F){F=128;s++}}G+=C}break;default:throw new Jbig2Error(`operator ${E} is not supported`)}}onImmediateGenericRegion(A,I,g,B){const Q=A.info,C=new DecodingContext(I,g,B),E=decodeBitmap(A.mmr,Q.width,Q.height,A.template,A.prediction,null,A.at,C);this.drawBitmap(Q,E)}onImmediateLosslessGenericRegion(){this.onImmediateGenericRegion(...arguments)}onSymbolDictionary(A,I,g,B,Q,C){let E,i;if(A.huffman){E=function getSymbolDictionaryHuffmanTables(A,I,g){let B,Q,C,E,i=0;switch(A.huffmanDHSelector){case 0:case 1:B=getStandardTable(A.huffmanDHSelector+4);break;case 3:B=getCustomHuffmanTable(i,I,g);i++;break;default:throw new Jbig2Error("invalid Huffman DH selector")}switch(A.huffmanDWSelector){case 0:case 1:Q=getStandardTable(A.huffmanDWSelector+2);break;case 3:Q=getCustomHuffmanTable(i,I,g);i++;break;default:throw new Jbig2Error("invalid Huffman DW selector")}if(A.bitmapSizeSelector){C=getCustomHuffmanTable(i,I,g);i++}else C=getStandardTable(1);E=A.aggregationInstancesSelector?getCustomHuffmanTable(i,I,g):getStandardTable(1);return{tableDeltaHeight:B,tableDeltaWidth:Q,tableBitmapSize:C,tableAggregateInstances:E}}(A,g,this.customTables);i=new Reader(B,Q,C)}let o=this.symbols;o||(this.symbols=o={});const D=[];for(const A of g){const I=o[A];I&&D.push(...I)}const h=new DecodingContext(B,Q,C);o[I]=function decodeSymbolDictionary(A,I,g,B,Q,C,E,i,o,D,h,F){if(A&&I)throw new Jbig2Error("symbol refinement with Huffman is not supported");const s=[];let G=0,a=log2(g.length+B);const y=h.decoder,w=h.contextCache;let R,S;if(A){R=getStandardTable(1);S=[];a=Math.max(a,1)}for(;s.length<B;){G+=A?C.tableDeltaHeight.decode(F):decodeInteger(w,"IADH",y);let B=0,Q=0;const R=A?S.length:0;for(;;){const R=A?C.tableDeltaWidth.decode(F):decodeInteger(w,"IADW",y);if(null===R)break;B+=R;Q+=B;let J;if(I){const Q=decodeInteger(w,"IAAI",y);if(Q>1)J=decodeTextRegion(A,I,B,G,0,Q,1,g.concat(s),a,0,0,1,0,C,o,D,h,0,F);else{const A=decodeIAID(w,y,a),I=decodeInteger(w,"IARDX",y),Q=decodeInteger(w,"IARDY",y);J=decodeRefinement(B,G,o,A<g.length?g[A]:s[A-g.length],I,Q,!1,D,h)}s.push(J)}else if(A)S.push(B);else{J=decodeBitmap(!1,B,G,E,!1,null,i,h);s.push(J)}}if(A&&!I){const A=C.tableBitmapSize.decode(F);F.byteAlign();let I;if(0===A)I=readUncompressedBitmap(F,Q,G);else{const g=F.end,B=F.position+A;F.end=B;I=decodeMMRBitmap(F,Q,G,!1);F.end=g;F.position=B}const g=S.length;if(R===g-1)s.push(I);else{let A,B,Q,C,E,i=0;for(A=R;A<g;A++){C=S[A];Q=i+C;E=[];for(B=0;B<G;B++)E.push(I[B].subarray(i,Q));s.push(E);i=Q}}}}const J=[],c=[];let U,k,N=!1;const t=g.length+B;for(;c.length<t;){let I=A?R.decode(F):decodeInteger(w,"IAEX",y);for(;I--;)c.push(N);N=!N}for(U=0,k=g.length;U<k;U++)c[U]&&J.push(g[U]);for(let A=0;A<B;U++,A++)c[U]&&J.push(s[A]);return J}(A.huffman,A.refinement,D,A.numberOfNewSymbols,A.numberOfExportedSymbols,E,A.template,A.at,A.refinementTemplate,A.refinementAt,h,i)}onImmediateTextRegion(A,I,g,B,Q){const C=A.info;let E,i;const o=this.symbols,D=[];for(const A of I){const I=o[A];I&&D.push(...I)}const h=log2(D.length);if(A.huffman){i=new Reader(g,B,Q);E=function getTextRegionHuffmanTables(A,I,g,B,Q){const C=[];for(let A=0;A<=34;A++){const I=Q.readBits(4);C.push(new HuffmanLine([A,I,0,0]))}const E=new HuffmanTable(C,!1);C.length=0;for(let A=0;A<B;){const I=E.decode(Q);if(I>=32){let g,B,E;switch(I){case 32:if(0===A)throw new Jbig2Error("no previous value in symbol ID table");B=Q.readBits(2)+3;g=C[A-1].prefixLength;break;case 33:B=Q.readBits(3)+3;g=0;break;case 34:B=Q.readBits(7)+11;g=0;break;default:throw new Jbig2Error("invalid code length in symbol ID table")}for(E=0;E<B;E++){C.push(new HuffmanLine([A,g,0,0]));A++}}else{C.push(new HuffmanLine([A,I,0,0]));A++}}Q.byteAlign();const i=new HuffmanTable(C,!1);let o,D,h,F=0;switch(A.huffmanFS){case 0:case 1:o=getStandardTable(A.huffmanFS+6);break;case 3:o=getCustomHuffmanTable(F,I,g);F++;break;default:throw new Jbig2Error("invalid Huffman FS selector")}switch(A.huffmanDS){case 0:case 1:case 2:D=getStandardTable(A.huffmanDS+8);break;case 3:D=getCustomHuffmanTable(F,I,g);F++;break;default:throw new Jbig2Error("invalid Huffman DS selector")}switch(A.huffmanDT){case 0:case 1:case 2:h=getStandardTable(A.huffmanDT+11);break;case 3:h=getCustomHuffmanTable(F,I,g);F++;break;default:throw new Jbig2Error("invalid Huffman DT selector")}if(A.refinement)throw new Jbig2Error("refinement with Huffman is not supported");return{symbolIDTable:i,tableFirstS:o,tableDeltaS:D,tableDeltaT:h}}(A,I,this.customTables,D.length,i)}const F=new DecodingContext(g,B,Q),s=decodeTextRegion(A.huffman,A.refinement,C.width,C.height,A.defaultPixelValue,A.numberOfSymbolInstances,A.stripSize,D,h,A.transposed,A.dsOffset,A.referenceCorner,A.combinationOperator,E,A.refinementTemplate,A.refinementAt,F,A.logStripSize,i);this.drawBitmap(C,s)}onImmediateLosslessTextRegion(){this.onImmediateTextRegion(...arguments)}onPatternDictionary(A,I,g,B,Q){let C=this.patterns;C||(this.patterns=C={});const E=new DecodingContext(g,B,Q);C[I]=function decodePatternDictionary(A,I,g,B,Q,C){const E=[];if(!A){E.push({x:-I,y:0});0===Q&&E.push({x:-3,y:-1},{x:2,y:-2},{x:-2,y:-2})}const i=decodeBitmap(A,(B+1)*I,g,Q,!1,null,E,C),o=[];for(let A=0;A<=B;A++){const B=[],Q=I*A,C=Q+I;for(let A=0;A<g;A++)B.push(i[A].subarray(Q,C));o.push(B)}return o}(A.mmr,A.patternWidth,A.patternHeight,A.maxPatternIndex,A.template,E)}onImmediateHalftoneRegion(A,I,g,B,Q){const C=this.patterns[I[0]],E=A.info,i=new DecodingContext(g,B,Q),o=function decodeHalftoneRegion(A,I,g,B,Q,C,E,i,o,D,h,F,s,G,a){if(E)throw new Jbig2Error("skip is not supported");if(0!==i)throw new Jbig2Error(`operator "${i}" is not supported in halftone region`);const y=[];let w,R,S;for(w=0;w<Q;w++){S=new Uint8Array(B);if(C)for(R=0;R<B;R++)S[R]=C;y.push(S)}const J=I.length,c=I[0],U=c[0].length,k=c.length,N=log2(J),t=[];if(!A){t.push({x:g<=1?3:2,y:-1});0===g&&t.push({x:-3,y:-1},{x:2,y:-2},{x:-2,y:-2})}const Y=[];let H,e,M,n,K,L,d,r,l,q,f;A&&(H=new Reader(a.data,a.start,a.end));for(w=N-1;w>=0;w--){e=A?decodeMMRBitmap(H,o,D,!0):decodeBitmap(!1,o,D,g,!1,null,t,a);Y[w]=e}for(M=0;M<D;M++)for(n=0;n<o;n++){K=0;L=0;for(R=N-1;R>=0;R--){K^=Y[R][M][n];L|=K<<R}d=I[L];r=h+M*G+n*s>>8;l=F+M*s-n*G>>8;if(r>=0&&r+U<=B&&l>=0&&l+k<=Q)for(w=0;w<k;w++){f=y[l+w];q=d[w];for(R=0;R<U;R++)f[r+R]|=q[R]}else{let A,I;for(w=0;w<k;w++){I=l+w;if(!(I<0||I>=Q)){f=y[I];q=d[w];for(R=0;R<U;R++){A=r+R;A>=0&&A<B&&(f[A]|=q[R])}}}}}return y}(A.mmr,C,A.template,E.width,E.height,A.defaultPixelValue,A.enableSkip,A.combinationOperator,A.gridWidth,A.gridHeight,A.gridOffsetX,A.gridOffsetY,A.gridVectorX,A.gridVectorY,i);this.drawBitmap(E,o)}onImmediateLosslessHalftoneRegion(){this.onImmediateHalftoneRegion(...arguments)}onTables(A,I,g,B){let Q=this.customTables;Q||(this.customTables=Q={});Q[A]=function decodeTablesSegment(A,I,g){const B=A[I],Q=4294967295&readUint32(A,I+1),C=4294967295&readUint32(A,I+5),E=new Reader(A,I+9,g),i=1+(B>>1&7),o=1+(B>>4&7),D=[];let h,F,s=Q;do{h=E.readBits(i);F=E.readBits(o);D.push(new HuffmanLine([s,h,F,0]));s+=1<<F}while(s<C);h=E.readBits(i);D.push(new HuffmanLine([Q-1,h,32,0,"lower"]));h=E.readBits(i);D.push(new HuffmanLine([C,h,32,0]));if(1&B){h=E.readBits(i);D.push(new HuffmanLine([h,0]))}return new HuffmanTable(D,!1)}(I,g,B)}}class HuffmanLine{constructor(A){if(2===A.length){this.isOOB=!0;this.rangeLow=0;this.prefixLength=A[0];this.rangeLength=0;this.prefixCode=A[1];this.isLowerRange=!1}else{this.isOOB=!1;this.rangeLow=A[0];this.prefixLength=A[1];this.rangeLength=A[2];this.prefixCode=A[3];this.isLowerRange="lower"===A[4]}}}class HuffmanTreeNode{constructor(A){this.children=[];if(A){this.isLeaf=!0;this.rangeLength=A.rangeLength;this.rangeLow=A.rangeLow;this.isLowerRange=A.isLowerRange;this.isOOB=A.isOOB}else this.isLeaf=!1}buildTree(A,I){const g=A.prefixCode>>I&1;if(I<=0)this.children[g]=new HuffmanTreeNode(A);else{let B=this.children[g];B||(this.children[g]=B=new HuffmanTreeNode(null));B.buildTree(A,I-1)}}decodeNode(A){if(this.isLeaf){if(this.isOOB)return null;const I=A.readBits(this.rangeLength);return this.rangeLow+(this.isLowerRange?-I:I)}const I=this.children[A.readBit()];if(!I)throw new Jbig2Error("invalid Huffman data");return I.decodeNode(A)}}class HuffmanTable{constructor(A,I){I||this.assignPrefixCodes(A);this.rootNode=new HuffmanTreeNode(null);for(let I=0,g=A.length;I<g;I++){const g=A[I];g.prefixLength>0&&this.rootNode.buildTree(g,g.prefixLength-1)}}decode(A){return this.rootNode.decodeNode(A)}assignPrefixCodes(A){const I=A.length;let g=0;for(let B=0;B<I;B++)g=Math.max(g,A[B].prefixLength);const B=new Uint32Array(g+1);for(let g=0;g<I;g++)B[A[g].prefixLength]++;let Q,C,E,i=1,o=0;B[0]=0;for(;i<=g;){o=o+B[i-1]<<1;Q=o;C=0;for(;C<I;){E=A[C];if(E.prefixLength===i){E.prefixCode=Q;Q++}C++}i++}}}const S={};function getStandardTable(A){let I,g=S[A];if(g)return g;switch(A){case 1:I=[[0,1,4,0],[16,2,8,2],[272,3,16,6],[65808,3,32,7]];break;case 2:I=[[0,1,0,0],[1,2,0,2],[2,3,0,6],[3,4,3,14],[11,5,6,30],[75,6,32,62],[6,63]];break;case 3:I=[[-256,8,8,254],[0,1,0,0],[1,2,0,2],[2,3,0,6],[3,4,3,14],[11,5,6,30],[-257,8,32,255,"lower"],[75,7,32,126],[6,62]];break;case 4:I=[[1,1,0,0],[2,2,0,2],[3,3,0,6],[4,4,3,14],[12,5,6,30],[76,5,32,31]];break;case 5:I=[[-255,7,8,126],[1,1,0,0],[2,2,0,2],[3,3,0,6],[4,4,3,14],[12,5,6,30],[-256,7,32,127,"lower"],[76,6,32,62]];break;case 6:I=[[-2048,5,10,28],[-1024,4,9,8],[-512,4,8,9],[-256,4,7,10],[-128,5,6,29],[-64,5,5,30],[-32,4,5,11],[0,2,7,0],[128,3,7,2],[256,3,8,3],[512,4,9,12],[1024,4,10,13],[-2049,6,32,62,"lower"],[2048,6,32,63]];break;case 7:I=[[-1024,4,9,8],[-512,3,8,0],[-256,4,7,9],[-128,5,6,26],[-64,5,5,27],[-32,4,5,10],[0,4,5,11],[32,5,5,28],[64,5,6,29],[128,4,7,12],[256,3,8,1],[512,3,9,2],[1024,3,10,3],[-1025,5,32,30,"lower"],[2048,5,32,31]];break;case 8:I=[[-15,8,3,252],[-7,9,1,508],[-5,8,1,253],[-3,9,0,509],[-2,7,0,124],[-1,4,0,10],[0,2,1,0],[2,5,0,26],[3,6,0,58],[4,3,4,4],[20,6,1,59],[22,4,4,11],[38,4,5,12],[70,5,6,27],[134,5,7,28],[262,6,7,60],[390,7,8,125],[646,6,10,61],[-16,9,32,510,"lower"],[1670,9,32,511],[2,1]];break;case 9:I=[[-31,8,4,252],[-15,9,2,508],[-11,8,2,253],[-7,9,1,509],[-5,7,1,124],[-3,4,1,10],[-1,3,1,2],[1,3,1,3],[3,5,1,26],[5,6,1,58],[7,3,5,4],[39,6,2,59],[43,4,5,11],[75,4,6,12],[139,5,7,27],[267,5,8,28],[523,6,8,60],[779,7,9,125],[1291,6,11,61],[-32,9,32,510,"lower"],[3339,9,32,511],[2,0]];break;case 10:I=[[-21,7,4,122],[-5,8,0,252],[-4,7,0,123],[-3,5,0,24],[-2,2,2,0],[2,5,0,25],[3,6,0,54],[4,7,0,124],[5,8,0,253],[6,2,6,1],[70,5,5,26],[102,6,5,55],[134,6,6,56],[198,6,7,57],[326,6,8,58],[582,6,9,59],[1094,6,10,60],[2118,7,11,125],[-22,8,32,254,"lower"],[4166,8,32,255],[2,2]];break;case 11:I=[[1,1,0,0],[2,2,1,2],[4,4,0,12],[5,4,1,13],[7,5,1,28],[9,5,2,29],[13,6,2,60],[17,7,2,122],[21,7,3,123],[29,7,4,124],[45,7,5,125],[77,7,6,126],[141,7,32,127]];break;case 12:I=[[1,1,0,0],[2,2,0,2],[3,3,1,6],[5,5,0,28],[6,5,1,29],[8,6,1,60],[10,7,0,122],[11,7,1,123],[13,7,2,124],[17,7,3,125],[25,7,4,126],[41,8,5,254],[73,8,32,255]];break;case 13:I=[[1,1,0,0],[2,3,0,4],[3,4,0,12],[4,5,0,28],[5,4,1,13],[7,3,3,5],[15,6,1,58],[17,6,2,59],[21,6,3,60],[29,6,4,61],[45,6,5,62],[77,7,6,126],[141,7,32,127]];break;case 14:I=[[-2,3,0,4],[-1,3,0,5],[0,1,0,0],[1,3,0,6],[2,3,0,7]];break;case 15:I=[[-24,7,4,124],[-8,6,2,60],[-4,5,1,28],[-2,4,0,12],[-1,3,0,4],[0,1,0,0],[1,3,0,5],[2,4,0,13],[3,5,1,29],[5,6,2,61],[9,7,4,125],[-25,7,32,126,"lower"],[25,7,32,127]];break;default:throw new Jbig2Error(`standard table B.${A} does not exist`)}for(let A=0,g=I.length;A<g;A++)I[A]=new HuffmanLine(I[A]);g=new HuffmanTable(I,!0);S[A]=g;return g}class Reader{constructor(A,I,g){this.data=A;this.start=I;this.end=g;this.position=I;this.shift=-1;this.currentByte=0}readBit(){if(this.shift<0){if(this.position>=this.end)throw new Jbig2Error("end of data while reading bit");this.currentByte=this.data[this.position++];this.shift=7}const A=this.currentByte>>this.shift&1;this.shift--;return A}readBits(A){let I,g=0;for(I=A-1;I>=0;I--)g|=this.readBit()<<I;return g}byteAlign(){this.shift=-1}next(){return this.position>=this.end?-1:this.data[this.position++]}}function getCustomHuffmanTable(A,I,g){let B=0;for(let Q=0,C=I.length;Q<C;Q++){const C=g[I[Q]];if(C){if(A===B)return C;B++}}throw new Jbig2Error("can't find custom Huffman table")}function readUncompressedBitmap(A,I,g){const B=[];for(let Q=0;Q<g;Q++){const g=new Uint8Array(I);B.push(g);for(let B=0;B<I;B++)g[B]=A.readBit();A.byteAlign()}return B}function decodeMMRBitmap(A,I,g,B){const Q=new CCITTFaxDecoder(A,{K:-1,Columns:I,Rows:g,BlackIs1:!0,EndOfBlock:B}),C=[];let E,i=!1;for(let A=0;A<g;A++){const A=new Uint8Array(I);C.push(A);let g=-1;for(let B=0;B<I;B++){if(g<0){E=Q.readNextChar();if(-1===E){E=0;i=!0}g=7}A[B]=E>>g&1;g--}}if(B&&!i){const A=5;for(let I=0;I<A&&-1!==Q.readNextChar();I++);}return C}class Jbig2Image{parseChunks(A){return function parseJbig2Chunks(A){const I=new SimpleSegmentVisitor;for(let g=0,B=A.length;g<B;g++){const B=A[g];processSegments(readSegments({},B.data,B.start,B.end),I)}return I.buffer}(A)}parse(A){const{imgData:I,width:g,height:B}=function parseJbig2(A){const I=A.length;let g=0;if(151!==A[g]||74!==A[g+1]||66!==A[g+2]||50!==A[g+3]||13!==A[g+4]||10!==A[g+5]||26!==A[g+6]||10!==A[g+7])throw new Jbig2Error("parseJbig2 - invalid header.");const B=Object.create(null);g+=8;const Q=A[g++];B.randomAccess=!(1&Q);if(!(2&Q)){B.numberOfPages=readUint32(A,g);g+=4}const C=readSegments(B,A,g,I),E=new SimpleSegmentVisitor;processSegments(C,E);const{width:i,height:o}=E.currentPageInfo,D=E.buffer,h=new Uint8ClampedArray(i*o);let F=0,s=0;for(let A=0;A<o;A++){let A,I=0;for(let g=0;g<i;g++){if(!I){I=128;A=D[s++]}h[F++]=A&I?0:255;I>>=1}}return{imgData:h,width:i,height:o}}(A);this.width=g;this.height=B;return I}}class JpegError extends B{constructor(A){super(A,"JpegError")}}class DNLMarkerError extends B{constructor(A,I){super(A,"DNLMarkerError");this.scanLines=I}}class EOIMarkerError extends B{constructor(A){super(A,"EOIMarkerError")}}const J=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),c=4017,U=799,k=3406,N=2276,t=1567,Y=3784,H=5793,e=2896;function buildHuffmanTable(A,I){let g,B,Q=0,C=16;for(;C>0&&!A[C-1];)C--;const E=[{children:[],index:0}];let i,o=E[0];for(g=0;g<C;g++){for(B=0;B<A[g];B++){o=E.pop();o.children[o.index]=I[Q];for(;o.index>0;)o=E.pop();o.index++;E.push(o);for(;E.length<=g;){E.push(i={children:[],index:0});o.children[o.index]=i.children;o=i}Q++}if(g+1<C){E.push(i={children:[],index:0});o.children[o.index]=i.children;o=i}}return E[0].children}function getBlockBufferOffset(A,I,g){return 64*((A.blocksPerLine+1)*I+g)}function decodeScan(A,I,g,B,Q,C,E,i,o,D=!1){const h=g.mcusPerLine,F=g.progressive,s=I;let G=0,a=0;function readBit(){if(a>0){a--;return G>>a&1}G=A[I++];if(255===G){const B=A[I++];if(B){if(220===B&&D){const B=readUint16(A,I+=2);I+=2;if(B>0&&B!==g.scanLines)throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data",B)}else if(217===B){if(D){const A=S*(8===g.precision?8:0);if(A>0&&Math.round(g.scanLines/A)>=5)throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, possibly caused by incorrect `scanLines` parameter",A)}throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data")}throw new JpegError(`unexpected marker ${(G<<8|B).toString(16)}`)}}a=7;return G>>>7}function decodeHuffman(A){let I=A;for(;;){I=I[readBit()];switch(typeof I){case"number":return I;case"object":continue}throw new JpegError("invalid huffman sequence")}}function receive(A){let I=0;for(;A>0;){I=I<<1|readBit();A--}return I}function receiveAndExtend(A){if(1===A)return 1===readBit()?1:-1;const I=receive(A);return I>=1<<A-1?I:I+(-1<<A)+1}let y=0;let w,R=0;let S=0;function decodeMcu(A,I,g,B,Q){const C=g%h;S=(g/h|0)*A.v+B;const E=C*A.h+Q;I(A,getBlockBufferOffset(A,S,E))}function decodeBlock(A,I,g){S=g/A.blocksPerLine|0;const B=g%A.blocksPerLine;I(A,getBlockBufferOffset(A,S,B))}const c=B.length;let U,k,N,t,Y,H;H=F?0===C?0===i?function decodeDCFirst(A,I){const g=decodeHuffman(A.huffmanTableDC),B=0===g?0:receiveAndExtend(g)<<o;A.blockData[I]=A.pred+=B}:function decodeDCSuccessive(A,I){A.blockData[I]|=readBit()<<o}:0===i?function decodeACFirst(A,I){if(y>0){y--;return}let g=C;const B=E;for(;g<=B;){const B=decodeHuffman(A.huffmanTableAC),Q=15&B,C=B>>4;if(0===Q){if(C<15){y=receive(C)+(1<<C)-1;break}g+=16;continue}g+=C;const E=J[g];A.blockData[I+E]=rece