pdfjs-dist
Version:
Generic build of Mozilla's PDF.js library.
22 lines • 110 kB
JavaScript
/**
* @licstart The following is the entire license notice for the
* Javascript code in this page
*
* Copyright 2021 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/image_decoders/pdf.image_decoders",[],t):"object"==typeof exports?exports["pdfjs-dist/image_decoders/pdf.image_decoders"]=t():e["pdfjs-dist/image_decoders/pdf.image_decoders"]=e.pdfjsImageDecoders=t()}(this,(function(){return(()=>{"use strict";var e=[,(e,t,n)=>{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 n=0;for(let r=0;r<t;r++)n+=arrayByteLength(e[r]);let r=0;const i=new Uint8Array(n);for(let n=0;n<t;n++){let t=e[n];t instanceof Uint8Array||(t="string"==typeof t?stringToBytes(t):new Uint8Array(t));const o=t.byteLength;i.set(t,r);r+=o}return i};t.assert=assert;t.bytesToString=function bytesToString(e){assert(null!==e&&"object"==typeof e&&void 0!==e.length,"Invalid argument for bytesToString");const t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);const r=[];for(let i=0;i<t;i+=n){const o=Math.min(i+n,t),s=e.subarray(i,o);r.push(String.fromCharCode.apply(null,s))}return r.join("")};t.createObjectURL=function createObjectURL(e,t="",n=!1){if(URL.createObjectURL&&!n)return URL.createObjectURL(new Blob([e],{type:t}));const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let i=`data:${t};base64,`;for(let t=0,n=e.length;t<n;t+=3){const o=255&e[t],s=255&e[t+1],a=255&e[t+2];i+=r[o>>2]+r[(3&o)<<4|s>>4]+r[t+1<n?(15&s)<<2|a>>6:64]+r[t+2<n?63&a:64]}return i};t.createPromiseCapability=function createPromiseCapability(){const e=Object.create(null);let t=!1;Object.defineProperty(e,"settled",{get:()=>t});e.promise=new Promise((function(n,r){e.resolve=function(e){t=!0;n(e)};e.reject=function(e){t=!0;r(e)}}));return e};t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e,t){if(!e)return null;try{const n=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}}(n))return n}catch(e){}return null};t.escapeString=function escapeString(e){return e.replace(/([()\\\n\r])/g,(e=>"\n"===e?"\\n":"\r"===e?"\\r":`\\${e}`))};t.getModificationDate=function getModificationDate(e=new Date){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")};t.getVerbosityLevel=function getVerbosityLevel(){return i};t.info=function info(e){i>=r.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;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0};t.isAscii=function isAscii(e){return/^[\x00-\x7F]*$/.test(e)};t.isBool=function isBool(e){return"boolean"==typeof e};t.isNum=function isNum(e){return"number"==typeof e};t.isSameOrigin=function isSameOrigin(e,t){let n;try{n=new URL(e);if(!n.origin||"null"===n.origin)return!1}catch(e){return!1}const r=new URL(t,n);return n.origin===r.origin};t.isString=function isString(e){return"string"==typeof e};t.objectFromMap=function objectFromMap(e){const t=Object.create(null);for(const[n,r]of e)t[n]=r;return t};t.objectSize=function objectSize(e){return Object.keys(e).length};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,n=[];if("þ"===e[0]&&"ÿ"===e[1])for(let r=2;r<t;r+=2)n.push(String.fromCharCode(e.charCodeAt(r)<<8|e.charCodeAt(r+1)));else if("ÿ"===e[0]&&"þ"===e[1])for(let r=2;r<t;r+=2)n.push(String.fromCharCode(e.charCodeAt(r+1)<<8|e.charCodeAt(r)));else for(let r=0;r<t;++r){const t=f[e.charCodeAt(r)];n.push(t?String.fromCharCode(t):e.charAt(r))}return n.join("")};t.stringToUTF16BEString=function stringToUTF16BEString(e){const t=["þÿ"];for(let n=0,r=e.length;n<r;n++){const r=e.charCodeAt(n);t.push(String.fromCharCode(r>>8&255));t.push(String.fromCharCode(255&r))}return t.join("")};t.stringToUTF8String=function stringToUTF8String(e){return decodeURIComponent(escape(e))};t.unreachable=unreachable;t.utf8StringToString=function utf8StringToString(e){return unescape(encodeURIComponent(e))};t.warn=warn;t.VerbosityLevel=t.Util=t.UNSUPPORTED_FEATURES=t.UnknownErrorException=t.UnexpectedResponseException=t.TextRenderingMode=t.StreamType=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.PageActionEventType=t.OPS=t.MissingPDFException=t.IsLittleEndianCached=t.IsEvalSupportedCached=t.InvalidPDFException=t.ImageKind=t.IDENTITY_MATRIX=t.FormatError=t.FontType=t.FONT_IDENTITY_MATRIX=t.DocumentActionEventType=t.CMapCompressionType=t.BaseException=t.AnnotationType=t.AnnotationStateModelType=t.AnnotationReviewState=t.AnnotationReplyType=t.AnnotationMarkedState=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 0;n(2);t.IDENTITY_MATRIX=[1,0,0,1,0,0];t.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];t.PermissionFlag={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};t.TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};t.ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};t.AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};t.AnnotationStateModelType={MARKED:"Marked",REVIEW:"Review"};t.AnnotationMarkedState={MARKED:"Marked",UNMARKED:"Unmarked"};t.AnnotationReviewState={ACCEPTED:"Accepted",REJECTED:"Rejected",CANCELLED:"Cancelled",COMPLETED:"Completed",NONE:"None"};t.AnnotationReplyType={GROUP:"Group",REPLY:"R"};t.AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};t.AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};t.AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};t.AnnotationActionEventType={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"};t.DocumentActionEventType={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};t.PageActionEventType={O:"PageOpen",C:"PageClose"};t.StreamType={UNKNOWN:"UNKNOWN",FLATE:"FLATE",LZW:"LZW",DCT:"DCT",JPX:"JPX",JBIG:"JBIG",A85:"A85",AHX:"AHX",CCF:"CCF",RLX:"RLX"};t.FontType={UNKNOWN:"UNKNOWN",TYPE1:"TYPE1",TYPE1C:"TYPE1C",CIDFONTTYPE0:"CIDFONTTYPE0",CIDFONTTYPE0C:"CIDFONTTYPE0C",TRUETYPE:"TRUETYPE",CIDFONTTYPE2:"CIDFONTTYPE2",TYPE3:"TYPE3",OPENTYPE:"OPENTYPE",TYPE0:"TYPE0",MMTYPE1:"MMTYPE1"};const r={ERRORS:0,WARNINGS:1,INFOS:5};t.VerbosityLevel=r;t.CMapCompressionType={NONE:0,BINARY:1,STREAM:2};t.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};t.UNSUPPORTED_FEATURES={unknown:"unknown",forms:"forms",javaScript:"javaScript",smask:"smask",shadingPattern:"shadingPattern",font:"font",errorTilingPattern:"errorTilingPattern",errorExtGState:"errorExtGState",errorXObject:"errorXObject",errorFontLoadType3:"errorFontLoadType3",errorFontState:"errorFontState",errorFontMissing:"errorFontMissing",errorFontTranslate:"errorFontTranslate",errorColorSpace:"errorColorSpace",errorOperatorList:"errorOperatorList",errorFontToUnicode:"errorFontToUnicode",errorFontLoadNative:"errorFontLoadNative",errorFontGetPath:"errorFontGetPath",errorMarkedContent:"errorMarkedContent"};t.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let i=r.WARNINGS;function warn(e){i>=r.WARNINGS&&console.log(`Warning: ${e}`)}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function shadow(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!1});return n}const o=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=o;t.PasswordException=class PasswordException extends o{constructor(e,t){super(e);this.code=t}};t.UnknownErrorException=class UnknownErrorException extends o{constructor(e,t){super(e);this.details=t}};t.InvalidPDFException=class InvalidPDFException extends o{};t.MissingPDFException=class MissingPDFException extends o{};t.UnexpectedResponseException=class UnexpectedResponseException extends o{constructor(e,t){super(e);this.status=t}};t.FormatError=class FormatError extends o{};t.AbortException=class AbortException extends o{};const s=/\x00/g;function stringToBytes(e){assert("string"==typeof e,"Invalid argument for stringToBytes");const t=e.length,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=255&e.charCodeAt(r);return n}function arrayByteLength(e){if(void 0!==e.length)return e.length;assert(void 0!==e.byteLength,"arrayByteLength - invalid argument.");return e.byteLength}const a={get value(){return shadow(this,"value",function isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return 1===new Uint32Array(e.buffer,0,1)[0]}())}};t.IsLittleEndianCached=a;const c={get value(){return shadow(this,"value",function isEvalSupported(){try{new Function("");return!0}catch(e){return!1}}())}};t.IsEvalSupportedCached=c;const l=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));class Util{static makeHexColor(e,t,n){return`#${l[e]}${l[t]}${l[n]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){const n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){const n=Util.applyTransform(e,t),r=Util.applyTransform(e.slice(2,4),t),i=Util.applyTransform([e[0],e[3]],t),o=Util.applyTransform([e[2],e[1]],t);return[Math.min(n[0],r[0],i[0],o[0]),Math.min(n[1],r[1],i[1],o[1]),Math.max(n[0],r[0],i[0],o[0]),Math.max(n[1],r[1],i[1],o[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static apply3dTransform(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],r=e[0]*t[1]+e[1]*t[3],i=e[2]*t[0]+e[3]*t[2],o=e[2]*t[1]+e[3]*t[3],s=(n+o)/2,a=Math.sqrt((n+o)**2-4*(n*o-i*r))/2,c=s+a||1,l=s-a||1;return[Math.sqrt(c),Math.sqrt(l)]}static normalizeRect(e){const t=e.slice(0);if(e[0]>e[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){function compare(e,t){return e-t}const n=[e[0],e[2],t[0],t[2]].sort(compare),r=[e[1],e[3],t[1],t[3]].sort(compare),i=[];e=Util.normalizeRect(e);t=Util.normalizeRect(t);if(!(n[0]===e[0]&&n[1]===t[0]||n[0]===t[0]&&n[1]===e[0]))return null;i[0]=n[1];i[2]=n[2];if(!(r[0]===e[1]&&r[1]===t[1]||r[0]===t[1]&&r[1]===e[1]))return null;i[1]=r[1];i[3]=r[2];return i}}t.Util=Util;const f=[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]},(e,t,n)=>{n(3)},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.isNodeJS=void 0;const n=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type);t.isNodeJS=n},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.Jbig2Image=void 0;var r=n(1),i=n(5),o=n(7),s=n(8);class Jbig2Error extends r.BaseException{constructor(e){super(`JBIG2 error: ${e}`)}}var a=function Jbig2ImageClosure(){function ContextCache(){}ContextCache.prototype={getContexts(e){return e in this?this[e]:this[e]=new Int8Array(65536)}};function DecodingContext(e,t,n){this.data=e;this.start=t;this.end=n}DecodingContext.prototype={get decoder(){var e=new o.ArithmeticDecoder(this.data,this.start,this.end);return(0,r.shadow)(this,"decoder",e)},get contextCache(){var e=new ContextCache;return(0,r.shadow)(this,"contextCache",e)}};function decodeInteger(e,t,n){var r=e.getContexts(t),i=1;function readBits(e){for(var t=0,o=0;o<e;o++){var s=n.readBit(r,i);i=i<256?i<<1|s:511&(i<<1|s)|256;t=t<<1|s}return t>>>0}var o=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===o?s:s>0?-s:null}function decodeIAID(e,t,n){for(var r=e.getContexts("IAID"),i=1,o=0;o<n;o++){i=i<<1|t.readBit(r,i)}return n<31?i&(1<<n)-1:2147483647&i}var e=["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"],t=[[{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}]],n=[{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}]}],a=[39717,1941,229,405],c=[32,8];function decodeBitmap(e,n,r,i,o,s,c,l){if(e){return decodeMMRBitmap(new Reader(l.data,l.start,l.end),n,r,!1)}if(0===i&&!s&&!o&&4===c.length&&3===c[0].x&&-1===c[0].y&&-3===c[1].x&&-1===c[1].y&&2===c[2].x&&-2===c[2].y&&-2===c[3].x&&-2===c[3].y)return function decodeBitmapTemplate0(e,t,n){var r,i,o,s,a,c,l,f=n.decoder,h=n.contextCache.getContexts("GB"),d=[];for(i=0;i<t;i++){a=d[i]=new Uint8Array(e);c=i<1?a:d[i-1];r=(l=i<2?a:d[i-2])[0]<<13|l[1]<<12|l[2]<<11|c[0]<<7|c[1]<<6|c[2]<<5|c[3]<<4;for(o=0;o<e;o++){a[o]=s=f.readBit(h,r);r=(31735&r)<<1|(o+3<e?l[o+3]<<11:0)|(o+4<e?c[o+4]<<4:0)|s}}return d}(n,r,l);var f=!!s,h=t[i].concat(c);h.sort((function(e,t){return e.y-t.y||e.x-t.x}));var d,u,p=h.length,m=new Int8Array(p),g=new Int8Array(p),b=[],y=0,v=0,x=0,w=0;for(u=0;u<p;u++){m[u]=h[u].x;g[u]=h[u].y;v=Math.min(v,h[u].x);x=Math.max(x,h[u].x);w=Math.min(w,h[u].y);u<p-1&&h[u].y===h[u+1].y&&h[u].x===h[u+1].x-1?y|=1<<p-1-u:b.push(u)}var C=b.length,T=new Int8Array(C),I=new Int8Array(C),S=new Uint16Array(C);for(d=0;d<C;d++){u=b[d];T[d]=h[u].x;I[d]=h[u].y;S[d]=1<<p-1-u}for(var P,k,E,_,B,D=-v,A=-w,L=n-x,R=a[i],O=new Uint8Array(n),M=[],U=l.decoder,F=l.contextCache.getContexts("GB"),N=0,H=0,J=0;J<r;J++){if(o){if(N^=U.readBit(F,R)){M.push(O);continue}}O=new Uint8Array(O);M.push(O);for(P=0;P<n;P++)if(f&&s[J][P])O[P]=0;else{if(P>=D&&P<L&&J>=A){H=H<<1&y;for(u=0;u<C;u++){k=J+I[u];E=P+T[u];(_=M[k][E])&&(H|=_=S[u])}}else{H=0;B=p-1;for(u=0;u<p;u++,B--)(E=P+m[u])>=0&&E<n&&(k=J+g[u])>=0&&(_=M[k][E])&&(H|=_<<B)}var z=U.readBit(F,H);O[P]=z}}return M}function decodeRefinement(e,t,r,i,o,s,a,l,f){var h=n[r].coding;0===r&&(h=h.concat([l[0]]));var d,u=h.length,p=new Int32Array(u),m=new Int32Array(u);for(d=0;d<u;d++){p[d]=h[d].x;m[d]=h[d].y}var g=n[r].reference;0===r&&(g=g.concat([l[1]]));var b=g.length,y=new Int32Array(b),v=new Int32Array(b);for(d=0;d<b;d++){y[d]=g[d].x;v[d]=g[d].y}for(var x=i[0].length,w=i.length,C=c[r],T=[],I=f.decoder,S=f.contextCache.getContexts("GR"),P=0,k=0;k<t;k++){if(a){if(P^=I.readBit(S,C))throw new Jbig2Error("prediction is not supported")}var E=new Uint8Array(e);T.push(E);for(var _=0;_<e;_++){var B,D,A=0;for(d=0;d<u;d++){B=k+m[d];D=_+p[d];B<0||D<0||D>=e?A<<=1:A=A<<1|T[B][D]}for(d=0;d<b;d++){B=k+v[d]-s;D=_+y[d]-o;B<0||B>=w||D<0||D>=x?A<<=1:A=A<<1|i[B][D]}var L=I.readBit(S,A);E[_]=L}}return T}function decodeTextRegion(e,t,n,r,i,o,s,a,c,l,f,h,d,u,p,m,g,b,y){if(e&&t)throw new Jbig2Error("refinement with Huffman is not supported");var v,x,w=[];for(v=0;v<r;v++){x=new Uint8Array(n);if(i)for(var C=0;C<n;C++)x[C]=i;w.push(x)}var T=g.decoder,I=g.contextCache,S=e?-u.tableDeltaT.decode(y):-decodeInteger(I,"IADT",T),P=0;v=0;for(;v<o;){S+=e?u.tableDeltaT.decode(y):decodeInteger(I,"IADT",T);for(var k=P+=e?u.tableFirstS.decode(y):decodeInteger(I,"IAFS",T);;){let r=0;s>1&&(r=e?y.readBits(b):decodeInteger(I,"IAIT",T));var E=s*S+r,_=e?u.symbolIDTable.decode(y):decodeIAID(I,T,c),B=t&&(e?y.readBit():decodeInteger(I,"IARI",T)),D=a[_],A=D[0].length,L=D.length;if(B){var R=decodeInteger(I,"IARDW",T),O=decodeInteger(I,"IARDH",T);D=decodeRefinement(A+=R,L+=O,p,D,(R>>1)+decodeInteger(I,"IARDX",T),(O>>1)+decodeInteger(I,"IARDY",T),!1,m,g)}var M,U,F,N=E-(1&h?0:L-1),H=k-(2&h?A-1:0);if(l){for(M=0;M<L;M++)if(x=w[H+M]){F=D[M];var J=Math.min(n-N,A);switch(d){case 0:for(U=0;U<J;U++)x[N+U]|=F[U];break;case 2:for(U=0;U<J;U++)x[N+U]^=F[U];break;default:throw new Jbig2Error(`operator ${d} is not supported`)}}k+=L-1}else{for(U=0;U<L;U++)if(x=w[N+U]){F=D[U];switch(d){case 0:for(M=0;M<A;M++)x[H+M]|=F[M];break;case 2:for(M=0;M<A;M++)x[H+M]^=F[M];break;default:throw new Jbig2Error(`operator ${d} is not supported`)}}k+=A-1}v++;var z=e?u.tableDeltaS.decode(y):decodeInteger(I,"IADS",T);if(null===z)break;k+=z+f}}return w}function readSegmentHeader(t,n){var r={};r.number=(0,i.readUint32)(t,n);var o=t[n+4],s=63&o;if(!e[s])throw new Jbig2Error("invalid segment type: "+s);r.type=s;r.typeName=e[s];r.deferredNonRetain=!!(128&o);var a=!!(64&o),c=t[n+5],f=c>>5&7,h=[31&c],d=n+6;if(7===c){f=536870911&(0,i.readUint32)(t,d-1);d+=3;var u=f+7>>3;h[0]=t[d++];for(;--u>0;)h.push(t[d++])}else if(5===c||6===c)throw new Jbig2Error("invalid referred-to flags");r.retainBits=h;let p=4;r.number<=256?p=1:r.number<=65536&&(p=2);var m,g,b=[];for(m=0;m<f;m++){let e;e=1===p?t[d]:2===p?(0,i.readUint16)(t,d):(0,i.readUint32)(t,d);b.push(e);d+=p}r.referredTo=b;if(a){r.pageAssociation=(0,i.readUint32)(t,d);d+=4}else r.pageAssociation=t[d++];r.length=(0,i.readUint32)(t,d);d+=4;if(4294967295===r.length){if(38!==s)throw new Jbig2Error("invalid unknown segment length");var y=readRegionSegmentInformation(t,d),v=!!(1&t[d+l]),x=new Uint8Array(6);if(!v){x[0]=255;x[1]=172}x[2]=y.height>>>24&255;x[3]=y.height>>16&255;x[4]=y.height>>8&255;x[5]=255&y.height;for(m=d,g=t.length;m<g;m++){for(var w=0;w<6&&x[w]===t[m+w];)w++;if(6===w){r.length=m+6;break}}if(4294967295===r.length)throw new Jbig2Error("segment end was not found")}r.headerEnd=d;return r}function readSegments(e,t,n,r){for(var i=[],o=n;o<r;){var s=readSegmentHeader(t,o);o=s.headerEnd;var a={header:s,data:t};if(!e.randomAccess){a.start=o;o+=s.length;a.end=o}i.push(a);if(51===s.type)break}if(e.randomAccess)for(var c=0,l=i.length;c<l;c++){i[c].start=o;o+=i[c].header.length;i[c].end=o}return i}function readRegionSegmentInformation(e,t){return{width:(0,i.readUint32)(e,t),height:(0,i.readUint32)(e,t+4),x:(0,i.readUint32)(e,t+8),y:(0,i.readUint32)(e,t+12),combinationOperator:7&e[t+16]}}var l=17;function processSegment(e,t){var n,r,o,s,a=e.header,c=e.data,f=e.start,h=e.end;switch(a.type){case 0:var d={},u=(0,i.readUint16)(c,f);d.huffman=!!(1&u);d.refinement=!!(2&u);d.huffmanDHSelector=u>>2&3;d.huffmanDWSelector=u>>4&3;d.bitmapSizeSelector=u>>6&1;d.aggregationInstancesSelector=u>>7&1;d.bitmapCodingContextUsed=!!(256&u);d.bitmapCodingContextRetained=!!(512&u);d.template=u>>10&3;d.refinementTemplate=u>>12&1;f+=2;if(!d.huffman){s=0===d.template?4:1;r=[];for(o=0;o<s;o++){r.push({x:(0,i.readInt8)(c,f),y:(0,i.readInt8)(c,f+1)});f+=2}d.at=r}if(d.refinement&&!d.refinementTemplate){r=[];for(o=0;o<2;o++){r.push({x:(0,i.readInt8)(c,f),y:(0,i.readInt8)(c,f+1)});f+=2}d.refinementAt=r}d.numberOfExportedSymbols=(0,i.readUint32)(c,f);f+=4;d.numberOfNewSymbols=(0,i.readUint32)(c,f);f+=4;n=[d,a.number,a.referredTo,c,f,h];break;case 6:case 7:var p={};p.info=readRegionSegmentInformation(c,f);f+=l;var m=(0,i.readUint16)(c,f);f+=2;p.huffman=!!(1&m);p.refinement=!!(2&m);p.logStripSize=m>>2&3;p.stripSize=1<<p.logStripSize;p.referenceCorner=m>>4&3;p.transposed=!!(64&m);p.combinationOperator=m>>7&3;p.defaultPixelValue=m>>9&1;p.dsOffset=m<<17>>27;p.refinementTemplate=m>>15&1;if(p.huffman){var g=(0,i.readUint16)(c,f);f+=2;p.huffmanFS=3&g;p.huffmanDS=g>>2&3;p.huffmanDT=g>>4&3;p.huffmanRefinementDW=g>>6&3;p.huffmanRefinementDH=g>>8&3;p.huffmanRefinementDX=g>>10&3;p.huffmanRefinementDY=g>>12&3;p.huffmanRefinementSizeSelector=!!(16384&g)}if(p.refinement&&!p.refinementTemplate){r=[];for(o=0;o<2;o++){r.push({x:(0,i.readInt8)(c,f),y:(0,i.readInt8)(c,f+1)});f+=2}p.refinementAt=r}p.numberOfSymbolInstances=(0,i.readUint32)(c,f);f+=4;n=[p,a.referredTo,c,f,h];break;case 16:const e={},t=c[f++];e.mmr=!!(1&t);e.template=t>>1&3;e.patternWidth=c[f++];e.patternHeight=c[f++];e.maxPatternIndex=(0,i.readUint32)(c,f);f+=4;n=[e,a.number,c,f,h];break;case 22:case 23:const w={};w.info=readRegionSegmentInformation(c,f);f+=l;const C=c[f++];w.mmr=!!(1&C);w.template=C>>1&3;w.enableSkip=!!(8&C);w.combinationOperator=C>>4&7;w.defaultPixelValue=C>>7&1;w.gridWidth=(0,i.readUint32)(c,f);f+=4;w.gridHeight=(0,i.readUint32)(c,f);f+=4;w.gridOffsetX=4294967295&(0,i.readUint32)(c,f);f+=4;w.gridOffsetY=4294967295&(0,i.readUint32)(c,f);f+=4;w.gridVectorX=(0,i.readUint16)(c,f);f+=2;w.gridVectorY=(0,i.readUint16)(c,f);f+=2;n=[w,a.referredTo,c,f,h];break;case 38:case 39:var b={};b.info=readRegionSegmentInformation(c,f);f+=l;var y=c[f++];b.mmr=!!(1&y);b.template=y>>1&3;b.prediction=!!(8&y);if(!b.mmr){s=0===b.template?4:1;r=[];for(o=0;o<s;o++){r.push({x:(0,i.readInt8)(c,f),y:(0,i.readInt8)(c,f+1)});f+=2}b.at=r}n=[b,c,f,h];break;case 48:var v={width:(0,i.readUint32)(c,f),height:(0,i.readUint32)(c,f+4),resolutionX:(0,i.readUint32)(c,f+8),resolutionY:(0,i.readUint32)(c,f+12)};4294967295===v.height&&delete v.height;var x=c[f+16];(0,i.readUint16)(c,f+17);v.lossless=!!(1&x);v.refinement=!!(2&x);v.defaultPixelValue=x>>2&1;v.combinationOperator=x>>3&3;v.requiresBuffer=!!(32&x);v.combinationOperatorOverride=!!(64&x);n=[v];break;case 49:case 50:case 51:break;case 53:n=[a.number,c,f,h];break;case 62:break;default:throw new Jbig2Error(`segment type ${a.typeName}(${a.type}) is not implemented`)}var w="on"+a.typeName;w in t&&t[w].apply(t,n)}function processSegments(e,t){for(var n=0,r=e.length;n<r;n++)processSegment(e[n],t)}function SimpleSegmentVisitor(){}SimpleSegmentVisitor.prototype={onPageInformation:function SimpleSegmentVisitor_onPageInformation(e){this.currentPageInfo=e;var t=e.width+7>>3,n=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var r=0,i=n.length;r<i;r++)n[r]=255;this.buffer=n},drawBitmap:function SimpleSegmentVisitor_drawBitmap(e,t){var n,r,i,o,s=this.currentPageInfo,a=e.width,c=e.height,l=s.width+7>>3,f=s.combinationOperatorOverride?e.combinationOperator:s.combinationOperator,h=this.buffer,d=128>>(7&e.x),u=e.y*l+(e.x>>3);switch(f){case 0:for(n=0;n<c;n++){i=d;o=u;for(r=0;r<a;r++){t[n][r]&&(h[o]|=i);if(!(i>>=1)){i=128;o++}}u+=l}break;case 2:for(n=0;n<c;n++){i=d;o=u;for(r=0;r<a;r++){t[n][r]&&(h[o]^=i);if(!(i>>=1)){i=128;o++}}u+=l}break;default:throw new Jbig2Error(`operator ${f} is not supported`)}},onImmediateGenericRegion:function SimpleSegmentVisitor_onImmediateGenericRegion(e,t,n,r){var i=e.info,o=new DecodingContext(t,n,r),s=decodeBitmap(e.mmr,i.width,i.height,e.template,e.prediction,null,e.at,o);this.drawBitmap(i,s)},onImmediateLosslessGenericRegion:function SimpleSegmentVisitor_onImmediateLosslessGenericRegion(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function SimpleSegmentVisitor_onSymbolDictionary(e,t,n,r,o,s){let a,c;if(e.huffman){a=function getSymbolDictionaryHuffmanTables(e,t,n){let r,i,o,s,a=0;switch(e.huffmanDHSelector){case 0:case 1:r=getStandardTable(e.huffmanDHSelector+4);break;case 3:r=getCustomHuffmanTable(a,t,n);a++;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(a,t,n);a++;break;default:throw new Jbig2Error("invalid Huffman DW selector")}if(e.bitmapSizeSelector){o=getCustomHuffmanTable(a,t,n);a++}else o=getStandardTable(1);s=e.aggregationInstancesSelector?getCustomHuffmanTable(a,t,n):getStandardTable(1);return{tableDeltaHeight:r,tableDeltaWidth:i,tableBitmapSize:o,tableAggregateInstances:s}}(e,n,this.customTables);c=new Reader(r,o,s)}var l=this.symbols;l||(this.symbols=l={});for(var f=[],h=0,d=n.length;h<d;h++){const e=l[n[h]];e&&(f=f.concat(e))}var u=new DecodingContext(r,o,s);l[t]=function decodeSymbolDictionary(e,t,n,r,o,s,a,c,l,f,h,d){if(e&&t)throw new Jbig2Error("symbol refinement with Huffman is not supported");var u=[],p=0,m=(0,i.log2)(n.length+r),g=h.decoder,b=h.contextCache;let y,v;if(e){y=getStandardTable(1);v=[];m=Math.max(m,1)}for(;u.length<r;){p+=e?s.tableDeltaHeight.decode(d):decodeInteger(b,"IADH",g);let r=0,i=0;const o=e?v.length:0;for(;;){var x,w=e?s.tableDeltaWidth.decode(d):decodeInteger(b,"IADW",g);if(null===w)break;r+=w;i+=r;if(t){var C=decodeInteger(b,"IAAI",g);if(C>1)x=decodeTextRegion(e,t,r,p,0,C,1,n.concat(u),m,0,0,1,0,s,l,f,h,0,d);else{var T=decodeIAID(b,g,m),I=decodeInteger(b,"IARDX",g),S=decodeInteger(b,"IARDY",g);x=decodeRefinement(r,p,l,T<n.length?n[T]:u[T-n.length],I,S,!1,f,h)}u.push(x)}else if(e)v.push(r);else{x=decodeBitmap(!1,r,p,a,!1,null,c,h);u.push(x)}}if(e&&!t){const e=s.tableBitmapSize.decode(d);d.byteAlign();let t;if(0===e)t=readUncompressedBitmap(d,i,p);else{const n=d.end,r=d.position+e;d.end=r;t=decodeMMRBitmap(d,i,p,!1);d.end=n;d.position=r}const n=v.length;if(o===n-1)u.push(t);else{let e,r,i,s,a,c=0;for(e=o;e<n;e++){s=v[e];i=c+s;a=[];for(r=0;r<p;r++)a.push(t[r].subarray(c,i));u.push(a);c=i}}}}for(var P=[],k=[],E=!1,_=n.length+r;k.length<_;){for(var B=e?y.decode(d):decodeInteger(b,"IAEX",g);B--;)k.push(E);E=!E}for(var D=0,A=n.length;D<A;D++)k[D]&&P.push(n[D]);for(var L=0;L<r;D++,L++)k[D]&&P.push(u[L]);return P}(e.huffman,e.refinement,f,e.numberOfNewSymbols,e.numberOfExportedSymbols,a,e.template,e.at,e.refinementTemplate,e.refinementAt,u,c)},onImmediateTextRegion:function SimpleSegmentVisitor_onImmediateTextRegion(e,t,n,r,o){var s=e.info;let a,c;for(var l=this.symbols,f=[],h=0,d=t.length;h<d;h++){const e=l[t[h]];e&&(f=f.concat(e))}var u=(0,i.log2)(f.length);if(e.huffman){c=new Reader(n,r,o);a=function getTextRegionHuffmanTables(e,t,n,r,i){const o=[];for(let e=0;e<=34;e++){const t=i.readBits(4);o.push(new HuffmanLine([e,t,0,0]))}const s=new HuffmanTable(o,!1);o.length=0;for(let e=0;e<r;){const t=s.decode(i);if(t>=32){let n,r,s;switch(t){case 32:if(0===e)throw new Jbig2Error("no previous value in symbol ID table");r=i.readBits(2)+3;n=o[e-1].prefixLength;break;case 33:r=i.readBits(3)+3;n=0;break;case 34:r=i.readBits(7)+11;n=0;break;default:throw new Jbig2Error("invalid code length in symbol ID table")}for(s=0;s<r;s++){o.push(new HuffmanLine([e,n,0,0]));e++}}else{o.push(new HuffmanLine([e,t,0,0]));e++}}i.byteAlign();const a=new HuffmanTable(o,!1);let c,l,f,h=0;switch(e.huffmanFS){case 0:case 1:c=getStandardTable(e.huffmanFS+6);break;case 3:c=getCustomHuffmanTable(h,t,n);h++;break;default:throw new Jbig2Error("invalid Huffman FS selector")}switch(e.huffmanDS){case 0:case 1:case 2:l=getStandardTable(e.huffmanDS+8);break;case 3:l=getCustomHuffmanTable(h,t,n);h++;break;default:throw new Jbig2Error("invalid Huffman DS selector")}switch(e.huffmanDT){case 0:case 1:case 2:f=getStandardTable(e.huffmanDT+11);break;case 3:f=getCustomHuffmanTable(h,t,n);h++;break;default:throw new Jbig2Error("invalid Huffman DT selector")}if(e.refinement)throw new Jbig2Error("refinement with Huffman is not supported");return{symbolIDTable:a,tableFirstS:c,tableDeltaS:l,tableDeltaT:f}}(e,t,this.customTables,f.length,c)}var p=new DecodingContext(n,r,o),m=decodeTextRegion(e.huffman,e.refinement,s.width,s.height,e.defaultPixelValue,e.numberOfSymbolInstances,e.stripSize,f,u,e.transposed,e.dsOffset,e.referenceCorner,e.combinationOperator,a,e.refinementTemplate,e.refinementAt,p,e.logStripSize,c);this.drawBitmap(s,m)},onImmediateLosslessTextRegion:function SimpleSegmentVisitor_onImmediateLosslessTextRegion(){this.onImmediateTextRegion.apply(this,arguments)},onPatternDictionary(e,t,n,r,i){let o=this.patterns;o||(this.patterns=o={});const s=new DecodingContext(n,r,i);o[t]=function decodePatternDictionary(e,t,n,r,i,o){const s=[];if(!e){s.push({x:-t,y:0});if(0===i){s.push({x:-3,y:-1});s.push({x:2,y:-2});s.push({x:-2,y:-2})}}const a=decodeBitmap(e,(r+1)*t,n,i,!1,null,s,o),c=[];for(let e=0;e<=r;e++){const r=[],i=t*e,o=i+t;for(let e=0;e<n;e++)r.push(a[e].subarray(i,o));c.push(r)}return c}(e.mmr,e.patternWidth,e.patternHeight,e.maxPatternIndex,e.template,s)},onImmediateHalftoneRegion(e,t,n,r,o){const s=this.patterns[t[0]],a=e.info,c=new DecodingContext(n,r,o),l=function decodeHalftoneRegion(e,t,n,r,o,s,a,c,l,f,h,d,u,p,m){if(a)throw new Jbig2Error("skip is not supported");if(0!==c)throw new Jbig2Error("operator "+c+" is not supported in halftone region");const g=[];let b,y,v;for(b=0;b<o;b++){v=new Uint8Array(r);if(s)for(y=0;y<r;y++)v[y]=s;g.push(v)}const x=t.length,w=t[0],C=w[0].length,T=w.length,I=(0,i.log2)(x),S=[];if(!e){S.push({x:n<=1?3:2,y:-1});if(0===n){S.push({x:-3,y:-1});S.push({x:2,y:-2});S.push({x:-2,y:-2})}}const P=[];let k,E,_,B,D,A,L,R,O,M,U;e&&(k=new Reader(m.data,m.start,m.end));for(b=I-1;b>=0;b--){E=e?decodeMMRBitmap(k,l,f,!0):decodeBitmap(!1,l,f,n,!1,null,S,m);P[b]=E}for(_=0;_<f;_++)for(B=0;B<l;B++){D=0;A=0;for(y=I-1;y>=0;y--){D=P[y][_][B]^D;A|=D<<y}L=t[A];R=h+_*p+B*u>>8;O=d+_*u-B*p>>8;if(R>=0&&R+C<=r&&O>=0&&O+T<=o)for(b=0;b<T;b++){U=g[O+b];M=L[b];for(y=0;y<C;y++)U[R+y]|=M[y]}else{let e,t;for(b=0;b<T;b++){t=O+b;if(!(t<0||t>=o)){U=g[t];M=L[b];for(y=0;y<C;y++){e=R+y;e>=0&&e<r&&(U[e]|=M[y])}}}}}return g}(e.mmr,s,e.template,a.width,a.height,e.defaultPixelValue,e.enableSkip,e.combinationOperator,e.gridWidth,e.gridHeight,e.gridOffsetX,e.gridOffsetY,e.gridVectorX,e.gridVectorY,c);this.drawBitmap(a,l)},onImmediateLosslessHalftoneRegion(){this.onImmediateHalftoneRegion.apply(this,arguments)},onTables(e,t,n,r){let o=this.customTables;o||(this.customTables=o={});o[e]=function decodeTablesSegment(e,t,n){const r=e[t],o=4294967295&(0,i.readUint32)(e,t+1),s=4294967295&(0,i.readUint32)(e,t+5),a=new Reader(e,t+9,n),c=1+(r>>1&7),l=1+(r>>4&7),f=[];let h,d,u=o;do{h=a.readBits(c);d=a.readBits(l);f.push(new HuffmanLine([u,h,d,0]));u+=1<<d}while(u<s);h=a.readBits(c);f.push(new HuffmanLine([o-1,h,32,0,"lower"]));h=a.readBits(c);f.push(new HuffmanLine([s,h,32,0]));if(1&r){h=a.readBits(c);f.push(new HuffmanLine([h,0]))}return new HuffmanTable(f,!1)}(t,n,r)}};function HuffmanLine(e){if(2===e.length){this.isOOB=!0;this.rangeLow=0;this.prefixLength=e[0];this.rangeLength=0;this.prefixCode=e[1];this.isLowerRange=!1}else{this.isOOB=!1;this.rangeLow=e[0];this.prefixLength=e[1];this.rangeLength=e[2];this.prefixCode=e[3];this.isLowerRange="lower"===e[4]}}function HuffmanTreeNode(e){this.children=[];if(e){this.isLeaf=!0;this.rangeLength=e.rangeLength;this.rangeLow=e.rangeLow;this.isLowerRange=e.isLowerRange;this.isOOB=e.isOOB}else this.isLeaf=!1}HuffmanTreeNode.prototype={buildTree(e,t){const n=e.prefixCode>>t&1;if(t<=0)this.children[n]=new HuffmanTreeNode(e);else{let r=this.children[n];r||(this.children[n]=r=new HuffmanTreeNode(null));r.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,n=e.length;t<n;t++){const n=e[t];n.prefixLength>0&&this.rootNode.buildTree(n,n.prefixLength-1)}}HuffmanTable.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){const t=e.length;let n=0;for(let r=0;r<t;r++)n=Math.max(n,e[r].prefixLength);const r=new Uint32Array(n+1);for(let n=0;n<t;n++)r[e[n].prefixLength]++;let i,o,s,a=1,c=0;r[0]=0;for(;a<=n;){c=c+r[a-1]<<1;i=c;o=0;for(;o<t;){s=e[o];if(s.prefixLength===a){s.prefixCode=i;i++}o++}a++}}};const f={};function getStandardTable(e){let t,n=f[e];if(n)return n;switch(e){case 1:t=[[0,1,4,0],[16,2,8,2],[272,3,16,6],[65808,3,32,7]];break;case 2:t=[[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:t=[[-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:t=[[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:t=[[-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:t=[[-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:t=[[-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:t=[[-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:t=[[-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:t=[[-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:t=[[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:t=[[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:t=[[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:t=[[-2,3,0,4],[-1,3,0,5],[0,1,0,0],[1,3,0,6],[2,3,0,7]];break;case 15:t=[[-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.${e} does not exist`)}for(let e=0,n=t.length;e<n;e++)t[e]=new HuffmanLine(t[e]);n=new HuffmanTable(t,!0);f[e]=n;return n}function Reader(e,t,n){this.data=e;this.start=t;this.end=n;this.position=t;this.shift=-1;this.currentByte=0}Reader.prototype={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 e=this.currentByte>>this.shift&1;this.shift--;return e},readBits(e){let t,n=0;for(t=e-1;t>=0;t--)n|=this.readBit()<<t;return n},byteAlign(){this.shift=-1},next(){return this.position>=this.end?-1:this.data[this.position++]}};function getCustomHuffmanTable(e,t,n){let r=0;for(let i=0,o=t.length;i<o;i++){const o=n[t[i]];if(o){if(e===r)return o;r++}}throw new Jbig2Error("can't find custom Huffman table")}function readUncompressedBitmap(e,t,n){const r=[];for(let i=0;i<n;i++){const n=new Uint8Array(t);r.push(n);for(let r=0;r<t;r++)n[r]=e.readBit();e.byteAlign()}return r}function decodeMMRBitmap(e,t,n,r){const i={K:-1,Columns:t,Rows:n,BlackIs1:!0,EndOfBlock:r},o=new s.CCITTFaxDecoder(e,i),a=[];let c,l=!1;for(let e=0;e<n;e++){const e=new Uint8Array(t);a.push(e);let n=-1;for(let r=0;r<t;r++){if(n<0){c=o.readNextChar();if(-1===c){c=0;l=!0}n=7}e[r]=c>>n&1;n--}}if(r&&!l){const e=5;for(let t=0;t<e&&-1!==o.readNextChar();t++);}return a}function Jbig2Image(){}Jbig2Image.prototype={parseChunks:e=>function parseJbig2Chunks(e){for(var t=new SimpleSegmentVisitor,n=0,r=e.length;n<r;n++){var i=e[n];processSegments(readSegments({},i.data,i.start,i.end),t)}return t.buffer}(e),parse(e){const{imgData:t,width:n,height:r}=function parseJbig2(e){const t=e.length;let n=0;if(151!==e[n]||74!==e[n+1]||66!==e[n+2]||50!==e[n+3]||13!==e[n+4]||10!==e[n+5]||26!==e[n+6]||10!==e[n+7])throw new Jbig2Error("parseJbig2 - invalid header.");const r=Object.create(null);n+=8;const o=e[n++];r.randomAccess=!(1&o);if(!(2&o)){r.numberOfPages=(0,i.readUint32)(e,n);n+=4}const s=readSegments(r,e,n,t),a=new SimpleSegmentVisitor;processSegments(s,a);const{width:c,height:l}=a.currentPageInfo,f=a.buffer,h=new Uint8ClampedArray(c*l);let d=0,u=0;for(let e=0;e<l;e++){let e,t=0;for(let n=0;n<c;n++){if(!t){t=128;e=f[u++]}h[d++]=e&t?0:255;t>>=1}}return{imgData:h,width:c,height:l}}(e);this.width=n;this.height=r;return t}};return Jbig2Image}();t.Jbig2Image=a},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.collectActions=function collectActions(e,t,n){const o=Object.create(null),s=getInheritableProperty({dict:t,key:"AA",stopWhenFound:!1});if(s)for(let t=s.length-1;t>=0;t--){const r=s[t];if(r instanceof i.Dict)for(const t of r.getKeys()){const s=n[t];if(!s)continue;const a=r.getRaw(t),c=new i.RefSet,l=[];_collectJS(a,e,l,c);l.length>0&&(o[s]=l)}}if(t.has("A")){const n=t.get("A"),r=new i.RefSet,s=[];_collectJS(n,e,s,r);s.length>0&&(o.Action=s)}return(0,r.objectSize)(o)>0?o:null};t.encodeToXmlString=function encodeToXmlString(e){const t=[];let n=0;for(let r=0,i=e.length;r<i;r++){const i=e.codePointAt(r);if(32<=i&&i<=126){const o=s[i];if(o){n<r&&t.push(e.substring(n,r));t.push(o);n=r+1}}else{n<r&&t.push(e.substring(n,r));t.push(`&#x${i.toString(16).toUpperCase()};`);i>55295&&(i<57344||i>65533)&&r++;n=r+1}}if(0===t.length)return e;n<e.length&&t.push(e.substring(n,e.length));return t.join("")};t.escapePDFName=function escapePDFName(e){const t=[];let n=0;for(let r=0,i=e.length;r<i;r++){const i=e.charCodeAt(r);if(i<33||i>126||35===i||40===i||41===i||60===i||62===i||91===i||93===i||123===i||125===i||47===i||37===i){n<r&&t.push(e.substring(n,r));t.push(`#${i.toString(16)}`);n=r+1}}if(0===t.length)return e;n<e.length&&t.push(e.substring(n,e.length));return t.join("")};t.getArrayLookupTableFactory=function getArrayLookupTableFactory(e){let t;return function(){if(e){let n=e();e=null;t=Object.create(null);for(let e=0,r=n.length;e<r;e+=2)t[n[e]]=n[e+1];n=null}return t}};t.getInheritableProperty=getInheritableProperty;t.getLookupTableFactory=function getLookupTableFactory(e){let t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}};t.isWhiteSpace=function isWhiteSpace(e){return 32===e||9===e||13===e||10===e};t.log2=function log2(e){if(e<=0)return 0;return Math.ceil(Math.log2(e))};t.parseXFAPath=function parseXFAPath(e){const t=/(.+)\[([0-9]+)\]$/;return e.split(".").map((e=>{const n=e.match(t);return n?{name:n[1],pos:parseInt(n[2],10)}:{name:e,pos:0}}))};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.toRomanNumerals=function toRomanNumerals(e,t=!1){(0,r.assert)(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const n=[];let i;for(;e>=1e3;){e-=1e3;n.push("M")}i=e/100|0;e%=100;n.push(o[i]);i=e/10|0;e%=10;n.push(o[10+i]);n.push(o[20+e]);const s=n.join("");return t?s.toLowerCase():s};t.XRefParseException=t.XRefEntryException=t.MissingDataException=void 0;var r=n(1),i=n(6);class MissingDataException extends r.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`);this.begin=e;this.end=t}}t.MissingDataException=MissingDataException;class XRefEntryException extends r.BaseException{}t.XRefEntryException=XRefEntryException;class XRefParseException extends r.BaseException{}t.XRefParseException=XRefParseException;function getInheritableProperty({dict:e,key:t,getArray:n=!1,stopWhenFound:r=!0}){let o;const s=new i.RefSet;for(;e instanceof i.Dict&&(!e.objId||!s.has(e.objId));){e.objId&&s.put(e.objId);const i=n?e.getArray(t):e.get(t);if(void 0!==i){if(r)return i;o||(o=[]);o.push(i)}e=e.get("Parent")}return o}const o=["","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 _collectJS(e,t,n,o){if(!e)return;let s=null;if((0,i.isRef)(e)){if(o.has(e))return;s=e;o.put(s);e=t.fetch(e)}if(Array.isArray(e))for(const r of e)_collectJS(r,t,n,o);else if(e instanceof i.Dict){if((0,i.isName)(e.get("S"),"JavaScript")&&e.has("JS")){const t=e.get("JS");let o;o=(0,i.isStream)(t)?(0,r.bytesToString)(t.getBytes()):t;o=(0,r.stringToPDFString)(o);o&&n.push(o)}_collectJS(e.getRaw("Next"),t,n,o)}s&&o.remove(s)}const s={60:"<",62:">",38:"&",34:""",39:"'"}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.clearPrimitiveCaches=function clearPrimitiveCaches(){s._clearCache();o._clearCache();c._clearCache()};t.isCmd=function isCmd(e,t){return e instanceof s&&(void 0===t||e.cmd===t)};t.isDict=function isDict(e,t){return e instanceof a&&(void 0===t||isName(e.get("Type"),t))};t.isEOF=function isEOF(e){return e===i};t.isName=isName;t.isRef=function isRef(e){return e instanceof c};t.isRefsEqual=function isRefsEqual(e,t){return e.num===t.num&&e.gen===t.gen};t.isStream=function isStream(e){return"object"==typeof e&&null!==e&&void 0!==e.getBytes};t.RefSetCache=t.RefSet=t.Ref=t.Name=t.EOF=t.Dict=t.Cmd=void 0;var r=n(1);const i={};t.EOF=i;const o=function NameClosure(){let e=Object.create(null);function Name(e){this.name=e}Name.prototype={};Name.get=function Name_get(t){const n=e[t];return n||(e[t]=new Name(t))};Name._clearCache=function(){e=Object.create(null)};return Name}();t.Name=o;const s=function CmdClosure(){let e=Object.create(null);function Cmd(e){this.cmd=e}Cmd.prototype={};Cmd.get=function Cmd_get(t){const n=e[t];return n||(e[t]=new Cmd(t))};Cmd._clearCache=function(){e=Object.create(null)};return Cmd}();t.Cmd=s;const a=function DictClosure(){const e=function nonSerializableClosure(){return e};function Dict(t){this._map=Object.create(null);this.xref=t;this.objId=null;this.suppressEncryption=!1;this.__nonSerializable__=e}Dict.prototype={assignXref:function Dict_assignXref(e){this.xref=e},get size(){return Object.keys(this._map).length},get(e,t,n){let r=this._map[e];if(void 0===r&&void 0!==t){r=this._map[t];void 0===r&&void 0!==n&&(r=this._map[n])}return r instanceof c&&this.xref?this.xref.fetch(r,this.suppressEncryption):r},async getAsync(e,t,n){let r=this._map[e];if(void 0===r&&void 0!==t){r=this._map[t];void 0===r&&void 0!==n&&(r=this._map[n])}return r instanceof c&&this.xref?this.xref.fetchAsync(r,this.suppressEncryption):r},getArray(e,t,n){let r=this.get(e,t,n);if(!Array.isArray(r)||!this.xref)return r;r=r.slice();for(let e=0,t=r.length;e<t;e++)r[e]instanceof c&&(r[e]=this.xref.fetch(r[e],this.suppressEncryption));return r},getRaw:function Dict_getRaw(e){return this._map[e]},getKeys:function Dict_getKeys(){return Object.keys(this._map)},getRawValues:function Dict_getRawValues(){return Object.values(this._map)},set:function Dict_set(e,t){this._map[e]=t},has:function Dict_has(e){return void 0!==this._map[e]},forEach:function Dict_forEach(e){for(const t in this._map)e(t,this.get(t))}};Dict.empty=function(){const e=new Dict(null);e.set=(e,t)=>{(0,r.unreachable)("Should not call `set` on the empty dictionary.")};return e}();Dict.merge=function({xref:e,dictArray:t,mergeSubDicts:n=!1}){const r=new Dict(e);if(!n){for(const e of t)if(e instanceof Dict)for(const[t,n]of Object.entries(e._map))void 0===r._map[t]&&(r._map[t]=n);return r.size>0?r:Dict.empty}const i=new Map;for(const e of t)if(e instanceof Dict)for(const[t,n]of Object.entries(e._map)){let e=i.get(t);if(void 0===e){e=[];i.set(t,e)}e.push(n)}for(const[t,n]of i){if(1===n.length||!(n[0]instanceof Dict)){r._map[t]=n[0];continue}const i=new Dict(e);for(const e of n)if(e instanceof Dict)for(const[t,n]of Object.entries(e._map))void 0===i._map[t]&&(i._map[t]=n);i.size>0&&(r._map[t]=i)}i.clear();return r.size>0?r:Dict.empty};return Dict}();t.Dict=a;const c=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,n){const r=0===n?`${t}R`:`${t}R${n}`,i=e[r];return i||(e[r]=new Ref(t,n))};Ref._clearCache=function(){e=Object.create(null)};return Ref}();t.Ref=c;t.RefSet=class RefSet{constructor(e=null){this._set=new Set(e&&e._set)}has(e){return this._set.has(e.toString())}put(e){this._set.add(e.toString())}remove(e){this._set.delete(e.toString())}forEach(e){for(const t of this._set.values())e(t)}clear(){this._set.clear()}};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 o&&(void 0===t||e.name