@ckhordiasma/pdfjs-dist
Version:
Generic build of Mozilla's PDF.js library, with additional access to XFA information through API
22 lines • 105 kB
JavaScript
/**
* @licstart The following is the entire license notice for the
* Javascript code in this page
*
* Copyright 2020 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @licend The above is the entire license notice for the
* Javascript code in this page
*/
!function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/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 function(e){var t={};function __w_pdfjs_require__(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};e[r].call(n.exports,n,n.exports,__w_pdfjs_require__);n.l=!0;return n.exports}__w_pdfjs_require__.m=e;__w_pdfjs_require__.c=t;__w_pdfjs_require__.d=function(e,t,r){__w_pdfjs_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})};__w_pdfjs_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});Object.defineProperty(e,"__esModule",{value:!0})};__w_pdfjs_require__.t=function(e,t){1&t&&(e=__w_pdfjs_require__(e));if(8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);__w_pdfjs_require__.r(r);Object.defineProperty(r,"default",{enumerable:!0,value:e});if(2&t&&"string"!=typeof e)for(var n in e)__w_pdfjs_require__.d(r,n,function(t){return e[t]}.bind(null,n));return r};__w_pdfjs_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};__w_pdfjs_require__.d(t,"a",t);return t};__w_pdfjs_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};__w_pdfjs_require__.p="";return __w_pdfjs_require__(__w_pdfjs_require__.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});Object.defineProperty(t,"getVerbosityLevel",{enumerable:!0,get:function(){return n.getVerbosityLevel}});Object.defineProperty(t,"setVerbosityLevel",{enumerable:!0,get:function(){return n.setVerbosityLevel}});Object.defineProperty(t,"Jbig2mage",{enumerable:!0,get:function(){return i.Jbig2mage}});Object.defineProperty(t,"JpegImage",{enumerable:!0,get:function(){return o.JpegImage}});Object.defineProperty(t,"JpxImage",{enumerable:!0,get:function(){return s.JpxImage}});var n=r(1),i=r(4),o=r(8),s=r(9)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.arrayByteLength=arrayByteLength;t.arraysToBytes=function arraysToBytes(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let r=0;for(let n=0;n<t;n++)r+=arrayByteLength(e[n]);let n=0;const i=new Uint8Array(r);for(let r=0;r<t;r++){let t=e[r];t instanceof Uint8Array||(t="string"==typeof t?stringToBytes(t):new Uint8Array(t));const o=t.byteLength;i.set(t,n);n+=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;if(t<8192)return String.fromCharCode.apply(null,e);const r=[];for(let n=0;n<t;n+=8192){const i=Math.min(n+8192,t),o=e.subarray(n,i);r.push(String.fromCharCode.apply(null,o))}return r.join("")};t.createPromiseCapability=function createPromiseCapability(){const e=Object.create(null);let t=!1;Object.defineProperty(e,"settled",{get:()=>t});e.promise=new Promise((function(r,n){e.resolve=function(e){t=!0;r(e)};e.reject=function(e){t=!0;n(e)}}));return e};t.escapeString=function escapeString(e){return e.replace(/([\(\)\\])/g,"\\$1")};t.encodeToXmlString=function encodeToXmlString(e){const t=[];let r=0;for(let n=0,i=e.length;n<i;n++){const i=e.codePointAt(n);if(32<=i&&i<=126){const o=h[i];if(o){r<n&&t.push(e.substring(r,n));t.push(o);r=n+1}}else{r<n&&t.push(e.substring(r,n));t.push(`&#x${i.toString(16).toUpperCase()};`);i>55295&&(i<57344||i>65533)&&n++;r=n+1}}if(0===t.length)return e;r<e.length&&t.push(e.substring(r,e.length));return t.join("")};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>=n.INFOS&&console.log("Info: "+e)};t.isArrayBuffer=function isArrayBuffer(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength};t.isArrayEqual=function isArrayEqual(e,t){if(e.length!==t.length)return!1;return e.every((function(e,r){return e===t[r]}))};t.isBool=function isBool(e){return"boolean"==typeof e};t.isNum=function isNum(e){return"number"==typeof e};t.isString=function isString(e){return"string"==typeof e};t.isSameOrigin=function isSameOrigin(e,t){let r;try{r=new URL(e);if(!r.origin||"null"===r.origin)return!1}catch(e){return!1}const n=new URL(t,r);return r.origin===n.origin};t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e,t){if(!e)return null;try{const r=t?new URL(e,t):new URL(e);if(function _isValidProtocol(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r))return r}catch(e){}return null};t.removeNullCharacters=function removeNullCharacters(e){if("string"!=typeof e){warn("The argument for removeNullCharacters must be a string.");return e}return e.replace(s,"")};t.setVerbosityLevel=function setVerbosityLevel(e){Number.isInteger(e)&&(i=e)};t.shadow=shadow;t.string32=function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)};t.stringToBytes=stringToBytes;t.stringToPDFString=function stringToPDFString(e){const t=e.length,r=[];if("þ"===e[0]&&"ÿ"===e[1])for(let n=2;n<t;n+=2)r.push(String.fromCharCode(e.charCodeAt(n)<<8|e.charCodeAt(n+1)));else if("ÿ"===e[0]&&"þ"===e[1])for(let n=2;n<t;n+=2)r.push(String.fromCharCode(e.charCodeAt(n+1)<<8|e.charCodeAt(n)));else for(let n=0;n<t;++n){const t=d[e.charCodeAt(n)];r.push(t?String.fromCharCode(t):e.charAt(n))}return r.join("")};t.stringToUTF8String=function stringToUTF8String(e){return decodeURIComponent(escape(e))};t.utf8StringToString=function utf8StringToString(e){return unescape(encodeURIComponent(e))};t.warn=warn;t.unreachable=unreachable;t.IsEvalSupportedCached=t.IsLittleEndianCached=t.createObjectURL=t.FormatError=t.Util=t.UnknownErrorException=t.UnexpectedResponseException=t.TextRenderingMode=t.StreamType=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.MissingPDFException=t.InvalidPDFException=t.AbortException=t.CMapCompressionType=t.ImageKind=t.FontType=t.AnnotationType=t.AnnotationStateModelType=t.AnnotationReviewState=t.AnnotationReplyType=t.AnnotationMarkedState=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationBorderStyleType=t.UNSUPPORTED_FEATURES=t.VerbosityLevel=t.OPS=t.IDENTITY_MATRIX=t.FONT_IDENTITY_MATRIX=t.BaseException=void 0;r(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.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 n={ERRORS:0,WARNINGS:1,INFOS:5};t.VerbosityLevel=n;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=n.WARNINGS;function warn(e){i>=n.WARNINGS&&console.log("Warning: "+e)}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function shadow(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1});return r}const 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,r=new Uint8Array(t);for(let n=0;n<t;++n)r[n]=255&e.charCodeAt(n);return r}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=["rgb(",0,",",0,",",0,")"];class Util{static makeCssRgb(e,t,r){l[1]=e;l[3]=t;l[5]=r;return l.join("")}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 r=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])/r,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/r]}static getAxialAlignedBoundingBox(e,t){const r=Util.applyTransform(e,t),n=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(r[0],n[0],i[0],o[0]),Math.min(r[1],n[1],i[1],o[1]),Math.max(r[0],n[0],i[0],o[0]),Math.max(r[1],n[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]],r=e[0]*t[0]+e[1]*t[2],n=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=(r+o)/2,a=Math.sqrt((r+o)*(r+o)-4*(r*o-i*n))/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 r=[e[0],e[2],t[0],t[2]].sort(compare),n=[e[1],e[3],t[1],t[3]].sort(compare),i=[];e=Util.normalizeRect(e);t=Util.normalizeRect(t);if(!(r[0]===e[0]&&r[1]===t[0]||r[0]===t[0]&&r[1]===e[0]))return null;i[0]=r[1];i[2]=r[2];if(!(n[0]===e[1]&&n[1]===t[1]||n[0]===t[1]&&n[1]===e[1]))return null;i[1]=n[1];i[3]=n[2];return i}}t.Util=Util;const d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];const f=function createObjectURLClosure(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function createObjectURL(t,r,n=!1){if(!n&&URL.createObjectURL){const e=new Blob([t],{type:r});return URL.createObjectURL(e)}let i=`data:${r};base64,`;for(let r=0,n=t.length;r<n;r+=3){const o=255&t[r],s=255&t[r+1],a=255&t[r+2];i+=e[o>>2]+e[(3&o)<<4|s>>4]+e[r+1<n?(15&s)<<2|a>>6:64]+e[r+2<n?63&a:64]}return i}}();t.createObjectURL=f;const h={60:"<",62:">",38:"&",34:""",39:"'"}},function(e,t,r){"use strict";r(3)},function(e,t,r){"use strict";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},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Jbig2Image=void 0;var n=r(1),i=r(5),o=r(6),s=r(7);class Jbig2Error extends n.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,r){this.data=e;this.start=t;this.end=r}DecodingContext.prototype={get decoder(){var e=new o.ArithmeticDecoder(this.data,this.start,this.end);return(0,n.shadow)(this,"decoder",e)},get contextCache(){var e=new ContextCache;return(0,n.shadow)(this,"contextCache",e)}};function decodeInteger(e,t,r){var n=e.getContexts(t),i=1;function readBits(e){for(var t=0,o=0;o<e;o++){var s=r.readBit(n,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,r){for(var n=e.getContexts("IAID"),i=1,o=0;o<r;o++){i=i<<1|t.readBit(n,i)}return r<31?i&(1<<r)-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}]],r=[{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,r,n,i,o,s,c,l){if(e){return decodeMMRBitmap(new Reader(l.data,l.start,l.end),r,n,!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,r){var n,i,o,s,a,c,l,d=r.decoder,f=r.contextCache.getContexts("GB"),h=[];for(i=0;i<t;i++){a=h[i]=new Uint8Array(e);c=i<1?a:h[i-1];n=(l=i<2?a:h[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=d.readBit(f,n);n=(31735&n)<<1|(o+3<e?l[o+3]<<11:0)|(o+4<e?c[o+4]<<4:0)|s}}return h}(r,n,l);var d=!!s,f=t[i].concat(c);f.sort((function(e,t){return e.y-t.y||e.x-t.x}));var h,u,p=f.length,m=new Int8Array(p),g=new Int8Array(p),b=[],x=0,y=0,v=0,w=0;for(u=0;u<p;u++){m[u]=f[u].x;g[u]=f[u].y;y=Math.min(y,f[u].x);v=Math.max(v,f[u].x);w=Math.min(w,f[u].y);u<p-1&&f[u].y===f[u+1].y&&f[u].x===f[u+1].x-1?x|=1<<p-1-u:b.push(u)}var T=b.length,C=new Int8Array(T),I=new Int8Array(T),P=new Uint16Array(T);for(h=0;h<T;h++){u=b[h];C[h]=f[u].x;I[h]=f[u].y;P[h]=1<<p-1-u}for(var S,k,_,E,B,L=-y,D=-w,M=r-v,A=a[i],O=new Uint8Array(r),R=[],U=l.decoder,F=l.contextCache.getContexts("GB"),N=0,H=0,J=0;J<n;J++){if(o){if(N^=U.readBit(F,A)){R.push(O);continue}}O=new Uint8Array(O);R.push(O);for(S=0;S<r;S++)if(d&&s[J][S])O[S]=0;else{if(S>=L&&S<M&&J>=D){H=H<<1&x;for(u=0;u<T;u++){k=J+I[u];_=S+C[u];(E=R[k][_])&&(H|=E=P[u])}}else{H=0;B=p-1;for(u=0;u<p;u++,B--)(_=S+m[u])>=0&&_<r&&(k=J+g[u])>=0&&(E=R[k][_])&&(H|=E<<B)}var z=U.readBit(F,H);O[S]=z}}return R}function decodeRefinement(e,t,n,i,o,s,a,l,d){var f=r[n].coding;0===n&&(f=f.concat([l[0]]));var h,u=f.length,p=new Int32Array(u),m=new Int32Array(u);for(h=0;h<u;h++){p[h]=f[h].x;m[h]=f[h].y}var g=r[n].reference;0===n&&(g=g.concat([l[1]]));var b=g.length,x=new Int32Array(b),y=new Int32Array(b);for(h=0;h<b;h++){x[h]=g[h].x;y[h]=g[h].y}for(var v=i[0].length,w=i.length,T=c[n],C=[],I=d.decoder,P=d.contextCache.getContexts("GR"),S=0,k=0;k<t;k++){if(a){if(S^=I.readBit(P,T))throw new Jbig2Error("prediction is not supported")}var _=new Uint8Array(e);C.push(_);for(var E=0;E<e;E++){var B,L,D=0;for(h=0;h<u;h++){B=k+m[h];L=E+p[h];B<0||L<0||L>=e?D<<=1:D=D<<1|C[B][L]}for(h=0;h<b;h++){B=k+y[h]-s;L=E+x[h]-o;B<0||B>=w||L<0||L>=v?D<<=1:D=D<<1|i[B][L]}var M=I.readBit(P,D);_[E]=M}}return C}function decodeTextRegion(e,t,r,n,i,o,s,a,c,l,d,f,h,u,p,m,g,b,x){if(e&&t)throw new Jbig2Error("refinement with Huffman is not supported");var y,v,w=[];for(y=0;y<n;y++){v=new Uint8Array(r);if(i)for(var T=0;T<r;T++)v[T]=i;w.push(v)}var C=g.decoder,I=g.contextCache,P=e?-u.tableDeltaT.decode(x):-decodeInteger(I,"IADT",C),S=0;y=0;for(;y<o;){P+=e?u.tableDeltaT.decode(x):decodeInteger(I,"IADT",C);for(var k=S+=e?u.tableFirstS.decode(x):decodeInteger(I,"IAFS",C);;){let n=0;s>1&&(n=e?x.readBits(b):decodeInteger(I,"IAIT",C));var _=s*P+n,E=e?u.symbolIDTable.decode(x):decodeIAID(I,C,c),B=t&&(e?x.readBit():decodeInteger(I,"IARI",C)),L=a[E],D=L[0].length,M=L.length;if(B){var A=decodeInteger(I,"IARDW",C),O=decodeInteger(I,"IARDH",C);L=decodeRefinement(D+=A,M+=O,p,L,(A>>1)+decodeInteger(I,"IARDX",C),(O>>1)+decodeInteger(I,"IARDY",C),!1,m,g)}var R,U,F,N=_-(1&f?0:M-1),H=k-(2&f?D-1:0);if(l){for(R=0;R<M;R++)if(v=w[H+R]){F=L[R];var J=Math.min(r-N,D);switch(h){case 0:for(U=0;U<J;U++)v[N+U]|=F[U];break;case 2:for(U=0;U<J;U++)v[N+U]^=F[U];break;default:throw new Jbig2Error(`operator ${h} is not supported`)}}k+=M-1}else{for(U=0;U<M;U++)if(v=w[N+U]){F=L[U];switch(h){case 0:for(R=0;R<D;R++)v[H+R]|=F[R];break;case 2:for(R=0;R<D;R++)v[H+R]^=F[R];break;default:throw new Jbig2Error(`operator ${h} is not supported`)}}k+=D-1}y++;var z=e?u.tableDeltaS.decode(x):decodeInteger(I,"IADS",C);if(null===z)break;k+=z+d}}return w}function readSegmentHeader(t,r){var n={};n.number=(0,i.readUint32)(t,r);var o=t[r+4],s=63&o;if(!e[s])throw new Jbig2Error("invalid segment type: "+s);n.type=s;n.typeName=e[s];n.deferredNonRetain=!!(128&o);var a=!!(64&o),c=t[r+5],d=c>>5&7,f=[31&c],h=r+6;if(7===c){d=536870911&(0,i.readUint32)(t,h-1);h+=3;var u=d+7>>3;f[0]=t[h++];for(;--u>0;)f.push(t[h++])}else if(5===c||6===c)throw new Jbig2Error("invalid referred-to flags");n.retainBits=f;let p=4;n.number<=256?p=1:n.number<=65536&&(p=2);var m,g,b=[];for(m=0;m<d;m++){let e;e=1===p?t[h]:2===p?(0,i.readUint16)(t,h):(0,i.readUint32)(t,h);b.push(e);h+=p}n.referredTo=b;if(a){n.pageAssociation=(0,i.readUint32)(t,h);h+=4}else n.pageAssociation=t[h++];n.length=(0,i.readUint32)(t,h);h+=4;if(4294967295===n.length){if(38!==s)throw new Jbig2Error("invalid unknown segment length");var x=readRegionSegmentInformation(t,h),y=!!(1&t[h+l]),v=new Uint8Array(6);if(!y){v[0]=255;v[1]=172}v[2]=x.height>>>24&255;v[3]=x.height>>16&255;v[4]=x.height>>8&255;v[5]=255&x.height;for(m=h,g=t.length;m<g;m++){for(var w=0;w<6&&v[w]===t[m+w];)w++;if(6===w){n.length=m+6;break}}if(4294967295===n.length)throw new Jbig2Error("segment end was not found")}n.headerEnd=h;return n}function readSegments(e,t,r,n){for(var i=[],o=r;o<n;){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 r,n,o,s,a=e.header,c=e.data,d=e.start,f=e.end;switch(a.type){case 0:var h={},u=(0,i.readUint16)(c,d);h.huffman=!!(1&u);h.refinement=!!(2&u);h.huffmanDHSelector=u>>2&3;h.huffmanDWSelector=u>>4&3;h.bitmapSizeSelector=u>>6&1;h.aggregationInstancesSelector=u>>7&1;h.bitmapCodingContextUsed=!!(256&u);h.bitmapCodingContextRetained=!!(512&u);h.template=u>>10&3;h.refinementTemplate=u>>12&1;d+=2;if(!h.huffman){s=0===h.template?4:1;n=[];for(o=0;o<s;o++){n.push({x:(0,i.readInt8)(c,d),y:(0,i.readInt8)(c,d+1)});d+=2}h.at=n}if(h.refinement&&!h.refinementTemplate){n=[];for(o=0;o<2;o++){n.push({x:(0,i.readInt8)(c,d),y:(0,i.readInt8)(c,d+1)});d+=2}h.refinementAt=n}h.numberOfExportedSymbols=(0,i.readUint32)(c,d);d+=4;h.numberOfNewSymbols=(0,i.readUint32)(c,d);d+=4;r=[h,a.number,a.referredTo,c,d,f];break;case 6:case 7:var p={};p.info=readRegionSegmentInformation(c,d);d+=l;var m=(0,i.readUint16)(c,d);d+=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,d);d+=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){n=[];for(o=0;o<2;o++){n.push({x:(0,i.readInt8)(c,d),y:(0,i.readInt8)(c,d+1)});d+=2}p.refinementAt=n}p.numberOfSymbolInstances=(0,i.readUint32)(c,d);d+=4;r=[p,a.referredTo,c,d,f];break;case 16:const e={},t=c[d++];e.mmr=!!(1&t);e.template=t>>1&3;e.patternWidth=c[d++];e.patternHeight=c[d++];e.maxPatternIndex=(0,i.readUint32)(c,d);d+=4;r=[e,a.number,c,d,f];break;case 22:case 23:const w={};w.info=readRegionSegmentInformation(c,d);d+=l;const T=c[d++];w.mmr=!!(1&T);w.template=T>>1&3;w.enableSkip=!!(8&T);w.combinationOperator=T>>4&7;w.defaultPixelValue=T>>7&1;w.gridWidth=(0,i.readUint32)(c,d);d+=4;w.gridHeight=(0,i.readUint32)(c,d);d+=4;w.gridOffsetX=4294967295&(0,i.readUint32)(c,d);d+=4;w.gridOffsetY=4294967295&(0,i.readUint32)(c,d);d+=4;w.gridVectorX=(0,i.readUint16)(c,d);d+=2;w.gridVectorY=(0,i.readUint16)(c,d);d+=2;r=[w,a.referredTo,c,d,f];break;case 38:case 39:var b={};b.info=readRegionSegmentInformation(c,d);d+=l;var x=c[d++];b.mmr=!!(1&x);b.template=x>>1&3;b.prediction=!!(8&x);if(!b.mmr){s=0===b.template?4:1;n=[];for(o=0;o<s;o++){n.push({x:(0,i.readInt8)(c,d),y:(0,i.readInt8)(c,d+1)});d+=2}b.at=n}r=[b,c,d,f];break;case 48:var y={width:(0,i.readUint32)(c,d),height:(0,i.readUint32)(c,d+4),resolutionX:(0,i.readUint32)(c,d+8),resolutionY:(0,i.readUint32)(c,d+12)};4294967295===y.height&&delete y.height;var v=c[d+16];(0,i.readUint16)(c,d+17);y.lossless=!!(1&v);y.refinement=!!(2&v);y.defaultPixelValue=v>>2&1;y.combinationOperator=v>>3&3;y.requiresBuffer=!!(32&v);y.combinationOperatorOverride=!!(64&v);r=[y];break;case 49:case 50:case 51:break;case 53:r=[a.number,c,d,f];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,r)}function processSegments(e,t){for(var r=0,n=e.length;r<n;r++)processSegment(e[r],t)}function SimpleSegmentVisitor(){}SimpleSegmentVisitor.prototype={onPageInformation:function SimpleSegmentVisitor_onPageInformation(e){this.currentPageInfo=e;var t=e.width+7>>3,r=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var n=0,i=r.length;n<i;n++)r[n]=255;this.buffer=r},drawBitmap:function SimpleSegmentVisitor_drawBitmap(e,t){var r,n,i,o,s=this.currentPageInfo,a=e.width,c=e.height,l=s.width+7>>3,d=s.combinationOperatorOverride?e.combinationOperator:s.combinationOperator,f=this.buffer,h=128>>(7&e.x),u=e.y*l+(e.x>>3);switch(d){case 0:for(r=0;r<c;r++){i=h;o=u;for(n=0;n<a;n++){t[r][n]&&(f[o]|=i);if(!(i>>=1)){i=128;o++}}u+=l}break;case 2:for(r=0;r<c;r++){i=h;o=u;for(n=0;n<a;n++){t[r][n]&&(f[o]^=i);if(!(i>>=1)){i=128;o++}}u+=l}break;default:throw new Jbig2Error(`operator ${d} is not supported`)}},onImmediateGenericRegion:function SimpleSegmentVisitor_onImmediateGenericRegion(e,t,r,n){var i=e.info,o=new DecodingContext(t,r,n),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,r,n,o,s){let a,c;if(e.huffman){a=function getSymbolDictionaryHuffmanTables(e,t,r){let n,i,o,s,a=0;switch(e.huffmanDHSelector){case 0:case 1:n=getStandardTable(e.huffmanDHSelector+4);break;case 3:n=getCustomHuffmanTable(a,t,r);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,r);a++;break;default:throw new Jbig2Error("invalid Huffman DW selector")}if(e.bitmapSizeSelector){o=getCustomHuffmanTable(a,t,r);a++}else o=getStandardTable(1);s=e.aggregationInstancesSelector?getCustomHuffmanTable(a,t,r):getStandardTable(1);return{tableDeltaHeight:n,tableDeltaWidth:i,tableBitmapSize:o,tableAggregateInstances:s}}(e,r,this.customTables);c=new Reader(n,o,s)}var l=this.symbols;l||(this.symbols=l={});for(var d=[],f=0,h=r.length;f<h;f++){const e=l[r[f]];e&&(d=d.concat(e))}var u=new DecodingContext(n,o,s);l[t]=function decodeSymbolDictionary(e,t,r,n,o,s,a,c,l,d,f,h){if(e&&t)throw new Jbig2Error("symbol refinement with Huffman is not supported");var u=[],p=0,m=(0,i.log2)(r.length+n),g=f.decoder,b=f.contextCache;let x,y;if(e){x=getStandardTable(1);y=[];m=Math.max(m,1)}for(;u.length<n;){p+=e?s.tableDeltaHeight.decode(h):decodeInteger(b,"IADH",g);let n=0,i=0;const o=e?y.length:0;for(;;){var v,w=e?s.tableDeltaWidth.decode(h):decodeInteger(b,"IADW",g);if(null===w)break;n+=w;i+=n;if(t){var T=decodeInteger(b,"IAAI",g);if(T>1)v=decodeTextRegion(e,t,n,p,0,T,1,r.concat(u),m,0,0,1,0,s,l,d,f,0,h);else{var C=decodeIAID(b,g,m),I=decodeInteger(b,"IARDX",g),P=decodeInteger(b,"IARDY",g);v=decodeRefinement(n,p,l,C<r.length?r[C]:u[C-r.length],I,P,!1,d,f)}u.push(v)}else if(e)y.push(n);else{v=decodeBitmap(!1,n,p,a,!1,null,c,f);u.push(v)}}if(e&&!t){const e=s.tableBitmapSize.decode(h);h.byteAlign();let t;if(0===e)t=readUncompressedBitmap(h,i,p);else{const r=h.end,n=h.position+e;h.end=n;t=decodeMMRBitmap(h,i,p,!1);h.end=r;h.position=n}const r=y.length;if(o===r-1)u.push(t);else{let e,n,i,s,a,c=0;for(e=o;e<r;e++){s=y[e];i=c+s;a=[];for(n=0;n<p;n++)a.push(t[n].subarray(c,i));u.push(a);c=i}}}}for(var S=[],k=[],_=!1,E=r.length+n;k.length<E;){for(var B=e?x.decode(h):decodeInteger(b,"IAEX",g);B--;)k.push(_);_=!_}for(var L=0,D=r.length;L<D;L++)k[L]&&S.push(r[L]);for(var M=0;M<n;L++,M++)k[L]&&S.push(u[M]);return S}(e.huffman,e.refinement,d,e.numberOfNewSymbols,e.numberOfExportedSymbols,a,e.template,e.at,e.refinementTemplate,e.refinementAt,u,c)},onImmediateTextRegion:function SimpleSegmentVisitor_onImmediateTextRegion(e,t,r,n,o){var s=e.info;let a,c;for(var l=this.symbols,d=[],f=0,h=t.length;f<h;f++){const e=l[t[f]];e&&(d=d.concat(e))}var u=(0,i.log2)(d.length);if(e.huffman){c=new Reader(r,n,o);a=function getTextRegionHuffmanTables(e,t,r,n,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<n;){const t=s.decode(i);if(t>=32){let r,n,s;switch(t){case 32:if(0===e)throw new Jbig2Error("no previous value in symbol ID table");n=i.readBits(2)+3;r=o[e-1].prefixLength;break;case 33:n=i.readBits(3)+3;r=0;break;case 34:n=i.readBits(7)+11;r=0;break;default:throw new Jbig2Error("invalid code length in symbol ID table")}for(s=0;s<n;s++){o.push(new HuffmanLine([e,r,0,0]));e++}}else{o.push(new HuffmanLine([e,t,0,0]));e++}}i.byteAlign();const a=new HuffmanTable(o,!1);let c,l,d,f=0;switch(e.huffmanFS){case 0:case 1:c=getStandardTable(e.huffmanFS+6);break;case 3:c=getCustomHuffmanTable(f,t,r);f++;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(f,t,r);f++;break;default:throw new Jbig2Error("invalid Huffman DS selector")}switch(e.huffmanDT){case 0:case 1:case 2:d=getStandardTable(e.huffmanDT+11);break;case 3:d=getCustomHuffmanTable(f,t,r);f++;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:d}}(e,t,this.customTables,d.length,c)}var p=new DecodingContext(r,n,o),m=decodeTextRegion(e.huffman,e.refinement,s.width,s.height,e.defaultPixelValue,e.numberOfSymbolInstances,e.stripSize,d,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,r,n,i){let o=this.patterns;o||(this.patterns=o={});const s=new DecodingContext(r,n,i);o[t]=function decodePatternDictionary(e,t,r,n,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,(n+1)*t,r,i,!1,null,s,o),c=[];for(let e=0;e<=n;e++){const n=[],i=t*e,o=i+t;for(let e=0;e<r;e++)n.push(a[e].subarray(i,o));c.push(n)}return c}(e.mmr,e.patternWidth,e.patternHeight,e.maxPatternIndex,e.template,s)},onImmediateHalftoneRegion(e,t,r,n,o){const s=this.patterns[t[0]],a=e.info,c=new DecodingContext(r,n,o),l=function decodeHalftoneRegion(e,t,r,n,o,s,a,c,l,d,f,h,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,x,y;for(b=0;b<o;b++){y=new Uint8Array(n);if(s)for(x=0;x<n;x++)y[x]=s;g.push(y)}const v=t.length,w=t[0],T=w[0].length,C=w.length,I=(0,i.log2)(v),P=[];if(!e){P.push({x:r<=1?3:2,y:-1});if(0===r){P.push({x:-3,y:-1});P.push({x:2,y:-2});P.push({x:-2,y:-2})}}const S=[];let k,_,E,B,L,D,M,A,O,R,U;e&&(k=new Reader(m.data,m.start,m.end));for(b=I-1;b>=0;b--){_=e?decodeMMRBitmap(k,l,d,!0):decodeBitmap(!1,l,d,r,!1,null,P,m);S[b]=_}for(E=0;E<d;E++)for(B=0;B<l;B++){L=0;D=0;for(x=I-1;x>=0;x--){L=S[x][E][B]^L;D|=L<<x}M=t[D];A=f+E*p+B*u>>8;O=h+E*u-B*p>>8;if(A>=0&&A+T<=n&&O>=0&&O+C<=o)for(b=0;b<C;b++){U=g[O+b];R=M[b];for(x=0;x<T;x++)U[A+x]|=R[x]}else{let e,t;for(b=0;b<C;b++){t=O+b;if(!(t<0||t>=o)){U=g[t];R=M[b];for(x=0;x<T;x++){e=A+x;e>=0&&e<n&&(U[e]|=R[x])}}}}}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,r,n){let o=this.customTables;o||(this.customTables=o={});o[e]=function decodeTablesSegment(e,t,r){const n=e[t],o=4294967295&(0,i.readUint32)(e,t+1),s=4294967295&(0,i.readUint32)(e,t+5),a=new Reader(e,t+9,r),c=1+(n>>1&7),l=1+(n>>4&7),d=[];let f,h,u=o;do{f=a.readBits(c);h=a.readBits(l);d.push(new HuffmanLine([u,f,h,0]));u+=1<<h}while(u<s);f=a.readBits(c);d.push(new HuffmanLine([o-1,f,32,0,"lower"]));f=a.readBits(c);d.push(new HuffmanLine([s,f,32,0]));if(1&n){f=a.readBits(c);d.push(new HuffmanLine([f,0]))}return new HuffmanTable(d,!1)}(t,r,n)}};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 r=e.prefixCode>>t&1;if(t<=0)this.children[r]=new HuffmanTreeNode(e);else{let n=this.children[r];n||(this.children[r]=n=new HuffmanTreeNode(null));n.buildTree(e,t-1)}},decodeNode(e){if(this.isLeaf){if(this.isOOB)return null;const t=e.readBits(this.rangeLength);return this.rangeLow+(this.isLowerRange?-t:t)}const t=this.children[e.readBit()];if(!t)throw new Jbig2Error("invalid Huffman data");return t.decodeNode(e)}};function HuffmanTable(e,t){t||this.assignPrefixCodes(e);this.rootNode=new HuffmanTreeNode(null);for(let t=0,r=e.length;t<r;t++){const r=e[t];r.prefixLength>0&&this.rootNode.buildTree(r,r.prefixLength-1)}}HuffmanTable.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){const t=e.length;let r=0;for(let n=0;n<t;n++)r=Math.max(r,e[n].prefixLength);const n=new Uint32Array(r+1);for(let r=0;r<t;r++)n[e[r].prefixLength]++;let i,o,s,a=1,c=0;n[0]=0;for(;a<=r;){c=c+n[a-1]<<1;i=c;o=0;for(;o<t;){s=e[o];if(s.prefixLength===a){s.prefixCode=i;i++}o++}a++}}};const d={};function getStandardTable(e){let t,r=d[e];if(r)return r;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,r=t.length;e<r;e++)t[e]=new HuffmanLine(t[e]);r=new HuffmanTable(t,!0);d[e]=r;return r}function Reader(e,t,r){this.data=e;this.start=t;this.end=r;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,r=0;for(t=e-1;t>=0;t--)r|=this.readBit()<<t;return r},byteAlign(){this.shift=-1},next(){return this.position>=this.end?-1:this.data[this.position++]}};function getCustomHuffmanTable(e,t,r){let n=0;for(let i=0,o=t.length;i<o;i++){const o=r[t[i]];if(o){if(e===n)return o;n++}}throw new Jbig2Error("can't find custom Huffman table")}function readUncompressedBitmap(e,t,r){const n=[];for(let i=0;i<r;i++){const r=new Uint8Array(t);n.push(r);for(let n=0;n<t;n++)r[n]=e.readBit();e.byteAlign()}return n}function decodeMMRBitmap(e,t,r,n){const i={K:-1,Columns:t,Rows:r,BlackIs1:!0,EndOfBlock:n},o=new s.CCITTFaxDecoder(e,i),a=[];let c,l=!1;for(let e=0;e<r;e++){const e=new Uint8Array(t);a.push(e);let r=-1;for(let n=0;n<t;n++){if(r<0){c=o.readNextChar();if(-1===c){c=0;l=!0}r=7}e[n]=c>>r&1;r--}}if(n&&!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,r=0,n=e.length;r<n;r++){var i=e[r];processSegments(readSegments({},i.data,i.start,i.end),t)}return t.buffer}(e),parse(e){const{imgData:t,width:r,height:n}=function parseJbig2(e){const t=e.length;let r=0;if(151!==e[r]||74!==e[r+1]||66!==e[r+2]||50!==e[r+3]||13!==e[r+4]||10!==e[r+5]||26!==e[r+6]||10!==e[r+7])throw new Jbig2Error("parseJbig2 - invalid header.");const n=Object.create(null);r+=8;const o=e[r++];n.randomAccess=!(1&o);if(!(2&o)){n.numberOfPages=(0,i.readUint32)(e,r);r+=4}const s=readSegments(n,e,r,t),a=new SimpleSegmentVisitor;processSegments(s,a);const{width:c,height:l}=a.currentPageInfo,d=a.buffer,f=new Uint8ClampedArray(c*l);let h=0,u=0;for(let e=0;e<l;e++){let e,t=0;for(let r=0;r<c;r++){if(!t){t=128;e=d[u++]}f[h++]=e&t?0:255;t>>=1}}return{imgData:f,width:c,height:l}}(e);this.width=r;this.height=n;return t}};return Jbig2Image}();t.Jbig2Image=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.getLookupTableFactory=function getLookupTableFactory(e){let t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}};t.getInheritableProperty=function getInheritableProperty({dict:e,key:t,getArray:r=!1,stopWhenFound:i=!0}){let o,s=0;for(;e;){const a=r?e.getArray(t):e.get(t);if(void 0!==a){if(i)return a;o||(o=[]);o.push(a)}if(++s>100){(0,n.warn)(`getInheritableProperty: maximum loop count exceeded for "${t}"`);break}e=e.get("Parent")}return o};t.toRomanNumerals=function toRomanNumerals(e,t=!1){(0,n.assert)(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const r=[];let o;for(;e>=1e3;){e-=1e3;r.push("M")}o=e/100|0;e%=100;r.push(i[o]);o=e/10|0;e%=10;r.push(i[10+o]);r.push(i[20+e]);const s=r.join("");return t?s.toLowerCase():s};t.log2=function log2(e){if(e<=0)return 0;return Math.ceil(Math.log2(e))};t.parseXFAPath=function parseXFAPath(e){const t=/(.+)\[([0-9]+)\]$/;return e.split(".").map(e=>{const r=e.match(t);return r?{name:r[1],pos:parseInt(r[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.isWhiteSpace=function isWhiteSpace(e){return 32===e||9===e||13===e||10===e};t.XRefParseException=t.XRefEntryException=t.MissingDataException=void 0;var n=r(1);class MissingDataException extends n.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`);this.begin=e;this.end=t}}t.MissingDataException=MissingDataException;class XRefEntryException extends n.BaseException{}t.XRefEntryException=XRefEntryException;class XRefParseException extends n.BaseException{}t.XRefParseException=XRefParseException;const i=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ArithmeticDecoder=void 0;const n=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];t.ArithmeticDecoder=class ArithmeticDecoder{constructor(e,t,r){this.data=e;this.bp=t;this.dataEnd=r;this.chigh=e[t];this.clow=0;this.byteIn();this.chigh=this.chigh<<7&65535|this.clow>>9&127;this.clow=this.clow<<7&65535;this.ct-=7;this.a=32768}byteIn(){const e=this.data;let t=this.bp;if(255===e[t])if(e[t+1]>143){this.clow+=65280;this.ct=8}else{t++;this.clow+=e[t]<<9;this.ct=7;this.bp=t}else{t++;this.clow+=t<this.dataEnd?e[t]<<8:65280;this.ct=8;this.bp=t}if(this.clow>65535){this.chigh+=this.clow>>16;this.clow&=65535}}readBit(e,t){let r=e[t]>>1,i=1&e[t];const o=n[r],s=o.qe;let a,c=this.a-s;if(this.chigh<s)if(c<s){c=s;a=i;r=o.nmps}else{c=s;a=1^i;1===o.switchFlag&&(i=a);r=o.nlps}else{this.chigh-=s;if(0!=(32768&c)){this.a=c;return i}if(c<s){a=1^i;1===o.switchFlag&&(i=a);r=o.nlps}else{a=i;r=o.nmps}}do{0===this.ct&&this.byteIn();c<<=1;this.chigh=this.chigh<<1&65535|this.clow>>15&1;this.clow=this.clow<<1&65535;this.ct--}while(0==(32768&c));this.a=c;e[t]=r<<1|i;return a}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.CCITTFaxDecoder=void 0;var n=r(1);const i=function CCITTFaxDecoder(){const e=[[-1,-1],[-1,-1],[7,8],[7,7],[6,6],[6,6],[6,5],[6,5],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2]],t=[[-1,-1],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[12,1984],[12,2048],[12,2112],[12,2176],[12,2240],[12,2304],[11,1856],[11,1856],[11,1920],[11,1920],[12,2368],[12,2432],[12,2496],[12,2560]],r=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],