pdfjs-dist
Version:
Generic build of Mozilla's PDF.js library.
22 lines • 134 kB
JavaScript
/**
* @licstart The following is the entire license notice for the
* JavaScript code in this page
*
* Copyright 2022 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()}(globalThis,(()=>(()=>{var e=[,(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.VerbosityLevel=t.Util=t.UnknownErrorException=t.UnexpectedResponseException=t.UNSUPPORTED_FEATURES=t.TextRenderingMode=t.StreamType=t.RenderingIntentFlag=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.PageActionEventType=t.OPS=t.MissingPDFException=t.LINE_FACTOR=t.LINE_DESCENT_FACTOR=t.InvalidPDFException=t.ImageKind=t.IDENTITY_MATRIX=t.FormatError=t.FontType=t.FeatureTest=t.FONT_IDENTITY_MATRIX=t.DocumentActionEventType=t.CMapCompressionType=t.BaseException=t.BASELINE_FACTOR=t.AnnotationType=t.AnnotationStateModelType=t.AnnotationReviewState=t.AnnotationReplyType=t.AnnotationMode=t.AnnotationMarkedState=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationEditorType=t.AnnotationEditorPrefix=t.AnnotationEditorParamsType=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 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=function assert(e,t){e||unreachable(t)};t.bytesToString=function bytesToString(e){"object"==typeof e&&null!==e&&void 0!==e.length||unreachable("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.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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!e)return null;try{if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t&&t.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=stringToUTF8String(e)}catch(e){}}const r=t?new URL(e,t):new URL(e);if(_isValidProtocol(r))return r}catch(e){}return null};t.getModificationDate=function getModificationDate(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;const t=[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")];return t.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.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.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){if(e[0]>="ï"){let t;"þ"===e[0]&&"ÿ"===e[1]?t="utf-16be":"ÿ"===e[0]&&"þ"===e[1]?t="utf-16le":"ï"===e[0]&&"»"===e[1]&&"¿"===e[2]&&(t="utf-8");if(t)try{const n=new TextDecoder(t,{fatal:!0}),r=stringToBytes(e);return n.decode(r)}catch(e){warn(`stringToPDFString: "${e}".`)}}const t=[];for(let n=0,r=e.length;n<r;n++){const r=a[e.charCodeAt(n)];t.push(r?String.fromCharCode(r):e.charAt(n))}return t.join("")};t.stringToUTF8String=stringToUTF8String;t.unreachable=unreachable;t.utf8StringToString=function utf8StringToString(e){return unescape(encodeURIComponent(e))};t.warn=warn;if(!globalThis._pdfjsCompatibilityChecked){globalThis._pdfjsCompatibilityChecked=!0;n(2)}t.IDENTITY_MATRIX=[1,0,0,1,0,0];t.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];t.LINE_FACTOR=1.35;t.LINE_DESCENT_FACTOR=.35;t.BASELINE_FACTOR=.25925925925925924;t.RenderingIntentFlag={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};t.AnnotationMode={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};t.AnnotationEditorPrefix="pdfjs_internal_editor_";t.AnnotationEditorType={DISABLE:-1,NONE:0,FREETEXT:3,INK:15};t.AnnotationEditorParamsType={FREETEXT_SIZE:1,FREETEXT_COLOR:2,FREETEXT_OPACITY:3,INK_COLOR:11,INK_THICKNESS:12,INK_OPACITY:13};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",TYPE1STANDARD:"TYPE1STANDARD",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};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,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};t.UNSUPPORTED_FEATURES={forms:"forms",javaScript:"javaScript",signatures:"signatures",smask:"smask",shadingPattern:"shadingPattern",errorTilingPattern:"errorTilingPattern",errorExtGState:"errorExtGState",errorXObject:"errorXObject",errorFontLoadType3:"errorFontLoadType3",errorFontState:"errorFontState",errorFontMissing:"errorFontMissing",errorFontTranslate:"errorFontTranslate",errorColorSpace:"errorColorSpace",errorOperatorList:"errorOperatorList",errorFontToUnicode:"errorFontToUnicode",errorFontLoadNative:"errorFontLoadNative",errorFontBuildPath:"errorFontBuildPath",errorFontGetPath:"errorFontGetPath",errorMarkedContent:"errorMarkedContent",errorContentSubStream:"errorContentSubStream"};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 _isValidProtocol(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function shadow(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1});return n}const o=function BaseExceptionClosure(){function BaseException(e,t){this.constructor===BaseException&&unreachable("Cannot initialize BaseException.");this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();t.BaseException=o;t.PasswordException=class PasswordException extends o{constructor(e,t){super(e,"PasswordException");this.code=t}};t.UnknownErrorException=class UnknownErrorException extends o{constructor(e,t){super(e,"UnknownErrorException");this.details=t}};t.InvalidPDFException=class InvalidPDFException extends o{constructor(e){super(e,"InvalidPDFException")}};t.MissingPDFException=class MissingPDFException extends o{constructor(e){super(e,"MissingPDFException")}};t.UnexpectedResponseException=class UnexpectedResponseException extends o{constructor(e,t){super(e,"UnexpectedResponseException");this.status=t}};t.FormatError=class FormatError extends o{constructor(e){super(e,"FormatError")}};t.AbortException=class AbortException extends o{constructor(e){super(e,"AbortException")}};function stringToBytes(e){"string"!=typeof e&&unreachable("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;if(void 0!==e.byteLength)return e.byteLength;unreachable("Invalid argument for arrayByteLength")}t.FeatureTest=class FeatureTest{static get isLittleEndian(){return shadow(this,"isLittleEndian",function isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return 1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return shadow(this,"isEvalSupported",function isEvalSupported(){try{new Function("");return!0}catch(e){return!1}}())}static get isOffscreenCanvasSupported(){return shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}};const s=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));class Util{static makeHexColor(e,t,n){return`#${s[e]}${s[t]}${s[n]}`}static scaleMinMax(e,t){let n;if(e[0]){if(e[0]<0){n=t[0];t[0]=t[1];t[1]=n}t[0]*=e[0];t[1]*=e[0];if(e[3]<0){n=t[2];t[2]=t[3];t[3]=n}t[2]*=e[3];t[3]*=e[3]}else{n=t[0];t[0]=t[2];t[2]=n;n=t[1];t[1]=t[3];t[3]=n;if(e[1]<0){n=t[2];t[2]=t[3];t[3]=n}t[2]*=e[1];t[3]*=e[1];if(e[2]<0){n=t[0];t[0]=t[1];t[1]=n}t[0]*=e[2];t[1]*=e[2]}t[0]+=e[4];t[1]+=e[4];t[2]+=e[5];t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){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 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){const n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;const i=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return i>o?null:[n,i,r,o]}static bezierBoundingBox(e,t,n,r,i,o,s,a){const c=[],l=[[],[]];let u,f,h,d,p,g,m,b;for(let l=0;l<2;++l){if(0===l){f=6*e-12*n+6*i;u=-3*e+9*n-9*i+3*s;h=3*n-3*e}else{f=6*t-12*r+6*o;u=-3*t+9*r-9*o+3*a;h=3*r-3*t}if(Math.abs(u)<1e-12){if(Math.abs(f)<1e-12)continue;d=-h/f;0<d&&d<1&&c.push(d)}else{m=f*f-4*h*u;b=Math.sqrt(m);if(!(m<0)){p=(-f+b)/(2*u);0<p&&p<1&&c.push(p);g=(-f-b)/(2*u);0<g&&g<1&&c.push(g)}}}let y,x=c.length;const w=x;for(;x--;){d=c[x];y=1-d;l[0][x]=y*y*y*e+3*y*y*d*n+3*y*d*d*i+d*d*d*s;l[1][x]=y*y*y*t+3*y*y*d*r+3*y*d*d*o+d*d*d*a}l[0][w]=e;l[1][w]=t;l[0][w+1]=s;l[1][w+1]=a;l[0].length=l[1].length=w+2;return[Math.min(...l[0]),Math.min(...l[1]),Math.max(...l[0]),Math.max(...l[1])]}}t.Util=Util;const a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function stringToUTF8String(e){return decodeURIComponent(escape(e))}},(e,t,n)=>{"use strict";var r=n(3);!function checkNodeBtoa(){!globalThis.btoa&&r.isNodeJS&&(globalThis.btoa=function(e){return Buffer.from(e,"binary").toString("base64")})}();!function checkNodeAtob(){!globalThis.atob&&r.isNodeJS&&(globalThis.atob=function(e){return Buffer.from(e,"base64").toString("binary")})}();!function checkDOMMatrix(){!globalThis.DOMMatrix&&r.isNodeJS&&(globalThis.DOMMatrix=require("canvas").DOMMatrix)}();!function checkReadableStream(){!globalThis.ReadableStream&&r.isNodeJS&&(globalThis.ReadableStream=require("web-streams-polyfill/dist/ponyfill.js").ReadableStream)}();!function checkArrayAt(){Array.prototype.at||n(4)}();!function checkTypedArrayAt(){Uint8Array.prototype.at||n(78)}()},(e,t)=>{"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},(e,t,n)=>{n(5);var r=n(77);e.exports=r("Array","at")},(e,t,n)=>{"use strict";var r=n(6),i=n(43),o=n(67),s=n(65),a=n(72);r({target:"Array",proto:!0},{at:function at(e){var t=i(this),n=o(t),r=s(e),a=r>=0?r:n+r;return a<0||a>=n?void 0:t[a]}});a("at")},(e,t,n)=>{var r=n(7),i=n(8).f,o=n(47),s=n(51),a=n(41),c=n(59),l=n(71);e.exports=function(e,t){var n,u,f,h,d,p=e.target,g=e.global,m=e.stat;if(n=g?r:m?r[p]||a(p,{}):(r[p]||{}).prototype)for(u in t){h=t[u];f=e.dontCallGetSet?(d=i(n,u))&&d.value:n[u];if(!l(g?u:p+(m?".":"#")+u,e.forced)&&void 0!==f){if(typeof h==typeof f)continue;c(h,f)}(e.sham||f&&f.sham)&&o(h,"sham",!0);s(n,u,h,e)}}},e=>{var check=function(e){return e&&e.Math==Math&&e};e.exports=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof global&&global)||function(){return this}()||Function("return this")()},(e,t,n)=>{var r=n(9),i=n(11),o=n(13),s=n(14),a=n(15),c=n(21),l=n(42),u=n(45),f=Object.getOwnPropertyDescriptor;t.f=r?f:function getOwnPropertyDescriptor(e,t){e=a(e);t=c(t);if(u)try{return f(e,t)}catch(e){}if(l(e,t))return s(!i(o.f,e,t),e[t])}},(e,t,n)=>{var r=n(10);e.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},e=>{e.exports=function(e){try{return!!e()}catch(e){return!0}}},(e,t,n)=>{var r=n(12),i=Function.prototype.call;e.exports=r?i.bind(i):function(){return i.apply(i,arguments)}},(e,t,n)=>{var r=n(10);e.exports=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))},(e,t)=>{"use strict";var n={}.propertyIsEnumerable,r=Object.getOwnPropertyDescriptor,i=r&&!n.call({1:2},1);t.f=i?function propertyIsEnumerable(e){var t=r(this,e);return!!t&&t.enumerable}:n},e=>{e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},(e,t,n)=>{var r=n(16),i=n(19);e.exports=function(e){return r(i(e))}},(e,t,n)=>{var r=n(17),i=n(10),o=n(18),s=Object,a=r("".split);e.exports=i((function(){return!s("z").propertyIsEnumerable(0)}))?function(e){return"String"==o(e)?a(e,""):s(e)}:s},(e,t,n)=>{var r=n(12),i=Function.prototype,o=i.call,s=r&&i.bind.bind(o,o);e.exports=r?s:function(e){return function(){return o.apply(e,arguments)}}},(e,t,n)=>{var r=n(17),i=r({}.toString),o=r("".slice);e.exports=function(e){return o(i(e),8,-1)}},(e,t,n)=>{var r=n(20),i=TypeError;e.exports=function(e){if(r(e))throw i("Can't call method on "+e);return e}},e=>{e.exports=function(e){return null==e}},(e,t,n)=>{var r=n(22),i=n(26);e.exports=function(e){var t=r(e,"string");return i(t)?t:t+""}},(e,t,n)=>{var r=n(11),i=n(23),o=n(26),s=n(33),a=n(36),c=n(37),l=TypeError,u=c("toPrimitive");e.exports=function(e,t){if(!i(e)||o(e))return e;var n,c=s(e,u);if(c){void 0===t&&(t="default");n=r(c,e,t);if(!i(n)||o(n))return n;throw l("Can't convert object to primitive value")}void 0===t&&(t="number");return a(e,t)}},(e,t,n)=>{var r=n(24),i=n(25),o=i.all;e.exports=i.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:r(e)||e===o}:function(e){return"object"==typeof e?null!==e:r(e)}},(e,t,n)=>{var r=n(25),i=r.all;e.exports=r.IS_HTMLDDA?function(e){return"function"==typeof e||e===i}:function(e){return"function"==typeof e}},e=>{var t="object"==typeof document&&document.all,n=void 0===t&&void 0!==t;e.exports={all:t,IS_HTMLDDA:n}},(e,t,n)=>{var r=n(27),i=n(24),o=n(28),s=n(29),a=Object;e.exports=s?function(e){return"symbol"==typeof e}:function(e){var t=r("Symbol");return i(t)&&o(t.prototype,a(e))}},(e,t,n)=>{var r=n(7),i=n(24),aFunction=function(e){return i(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?aFunction(r[e]):r[e]&&r[e][t]}},(e,t,n)=>{var r=n(17);e.exports=r({}.isPrototypeOf)},(e,t,n)=>{var r=n(30);e.exports=r&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},(e,t,n)=>{var r=n(31),i=n(10);e.exports=!!Object.getOwnPropertySymbols&&!i((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},(e,t,n)=>{var r,i,o=n(7),s=n(32),a=o.process,c=o.Deno,l=a&&a.versions||c&&c.version,u=l&&l.v8;u&&(i=(r=u.split("."))[0]>0&&r[0]<4?1:+(r[0]+r[1]));!i&&s&&(!(r=s.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=s.match(/Chrome\/(\d+)/))&&(i=+r[1]);e.exports=i},(e,t,n)=>{var r=n(27);e.exports=r("navigator","userAgent")||""},(e,t,n)=>{var r=n(34),i=n(20);e.exports=function(e,t){var n=e[t];return i(n)?void 0:r(n)}},(e,t,n)=>{var r=n(24),i=n(35),o=TypeError;e.exports=function(e){if(r(e))return e;throw o(i(e)+" is not a function")}},e=>{var t=String;e.exports=function(e){try{return t(e)}catch(e){return"Object"}}},(e,t,n)=>{var r=n(11),i=n(24),o=n(23),s=TypeError;e.exports=function(e,t){var n,a;if("string"===t&&i(n=e.toString)&&!o(a=r(n,e)))return a;if(i(n=e.valueOf)&&!o(a=r(n,e)))return a;if("string"!==t&&i(n=e.toString)&&!o(a=r(n,e)))return a;throw s("Can't convert object to primitive value")}},(e,t,n)=>{var r=n(7),i=n(38),o=n(42),s=n(44),a=n(30),c=n(29),l=i("wks"),u=r.Symbol,f=u&&u.for,h=c?u:u&&u.withoutSetter||s;e.exports=function(e){if(!o(l,e)||!a&&"string"!=typeof l[e]){var t="Symbol."+e;a&&o(u,e)?l[e]=u[e]:l[e]=c&&f?f(t):h(t)}return l[e]}},(e,t,n)=>{var r=n(39),i=n(40);(e.exports=function(e,t){return i[e]||(i[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.26.1",mode:r?"pure":"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.26.1/LICENSE",source:"https://github.com/zloirock/core-js"})},e=>{e.exports=!1},(e,t,n)=>{var r=n(7),i=n(41),o="__core-js_shared__",s=r[o]||i(o,{});e.exports=s},(e,t,n)=>{var r=n(7),i=Object.defineProperty;e.exports=function(e,t){try{i(r,e,{value:t,configurable:!0,writable:!0})}catch(n){r[e]=t}return t}},(e,t,n)=>{var r=n(17),i=n(43),o=r({}.hasOwnProperty);e.exports=Object.hasOwn||function hasOwn(e,t){return o(i(e),t)}},(e,t,n)=>{var r=n(19),i=Object;e.exports=function(e){return i(r(e))}},(e,t,n)=>{var r=n(17),i=0,o=Math.random(),s=r(1..toString);e.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+s(++i+o,36)}},(e,t,n)=>{var r=n(9),i=n(10),o=n(46);e.exports=!r&&!i((function(){return 7!=Object.defineProperty(o("div"),"a",{get:function(){return 7}}).a}))},(e,t,n)=>{var r=n(7),i=n(23),o=r.document,s=i(o)&&i(o.createElement);e.exports=function(e){return s?o.createElement(e):{}}},(e,t,n)=>{var r=n(9),i=n(48),o=n(14);e.exports=r?function(e,t,n){return i.f(e,t,o(1,n))}:function(e,t,n){e[t]=n;return e}},(e,t,n)=>{var r=n(9),i=n(45),o=n(49),s=n(50),a=n(21),c=TypeError,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,f="enumerable",h="configurable",d="writable";t.f=r?o?function defineProperty(e,t,n){s(e);t=a(t);s(n);if("function"==typeof e&&"prototype"===t&&"value"in n&&d in n&&!n.writable){var r=u(e,t);if(r&&r.writable){e[t]=n.value;n={configurable:h in n?n.configurable:r.configurable,enumerable:f in n?n.enumerable:r.enumerable,writable:!1}}}return l(e,t,n)}:l:function defineProperty(e,t,n){s(e);t=a(t);s(n);if(i)try{return l(e,t,n)}catch(e){}if("get"in n||"set"in n)throw c("Accessors not supported");"value"in n&&(e[t]=n.value);return e}},(e,t,n)=>{var r=n(9),i=n(10);e.exports=r&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},(e,t,n)=>{var r=n(23),i=String,o=TypeError;e.exports=function(e){if(r(e))return e;throw o(i(e)+" is not an object")}},(e,t,n)=>{var r=n(24),i=n(48),o=n(52),s=n(41);e.exports=function(e,t,n,a){a||(a={});var c=a.enumerable,l=void 0!==a.name?a.name:t;r(n)&&o(n,l,a);if(a.global)c?e[t]=n:s(t,n);else{try{a.unsafe?e[t]&&(c=!0):delete e[t]}catch(e){}c?e[t]=n:i.f(e,t,{value:n,enumerable:!1,configurable:!a.nonConfigurable,writable:!a.nonWritable})}return e}},(e,t,n)=>{var r=n(10),i=n(24),o=n(42),s=n(9),a=n(53).CONFIGURABLE,c=n(54),l=n(55),u=l.enforce,f=l.get,h=Object.defineProperty,d=s&&!r((function(){return 8!==h((function(){}),"length",{value:8}).length})),p=String(String).split("String"),g=e.exports=function(e,t,n){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]");n&&n.getter&&(t="get "+t);n&&n.setter&&(t="set "+t);(!o(e,"name")||a&&e.name!==t)&&(s?h(e,"name",{value:t,configurable:!0}):e.name=t);d&&n&&o(n,"arity")&&e.length!==n.arity&&h(e,"length",{value:n.arity});try{n&&o(n,"constructor")&&n.constructor?s&&h(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var r=u(e);o(r,"source")||(r.source=p.join("string"==typeof t?t:""));return e};Function.prototype.toString=g((function toString(){return i(this)&&f(this).source||c(this)}),"toString")},(e,t,n)=>{var r=n(9),i=n(42),o=Function.prototype,s=r&&Object.getOwnPropertyDescriptor,a=i(o,"name"),c=a&&"something"===function something(){}.name,l=a&&(!r||r&&s(o,"name").configurable);e.exports={EXISTS:a,PROPER:c,CONFIGURABLE:l}},(e,t,n)=>{var r=n(17),i=n(24),o=n(40),s=r(Function.toString);i(o.inspectSource)||(o.inspectSource=function(e){return s(e)});e.exports=o.inspectSource},(e,t,n)=>{var r,i,o,s=n(56),a=n(7),c=n(23),l=n(47),u=n(42),f=n(40),h=n(57),d=n(58),p="Object already initialized",g=a.TypeError,m=a.WeakMap;if(s||f.state){var b=f.state||(f.state=new m);b.get=b.get;b.has=b.has;b.set=b.set;r=function(e,t){if(b.has(e))throw g(p);t.facade=e;b.set(e,t);return t};i=function(e){return b.get(e)||{}};o=function(e){return b.has(e)}}else{var y=h("state");d[y]=!0;r=function(e,t){if(u(e,y))throw g(p);t.facade=e;l(e,y,t);return t};i=function(e){return u(e,y)?e[y]:{}};o=function(e){return u(e,y)}}e.exports={set:r,get:i,has:o,enforce:function(e){return o(e)?i(e):r(e,{})},getterFor:function(e){return function(t){var n;if(!c(t)||(n=i(t)).type!==e)throw g("Incompatible receiver, "+e+" required");return n}}}},(e,t,n)=>{var r=n(7),i=n(24),o=r.WeakMap;e.exports=i(o)&&/native code/.test(String(o))},(e,t,n)=>{var r=n(38),i=n(44),o=r("keys");e.exports=function(e){return o[e]||(o[e]=i(e))}},e=>{e.exports={}},(e,t,n)=>{var r=n(42),i=n(60),o=n(8),s=n(48);e.exports=function(e,t,n){for(var a=i(t),c=s.f,l=o.f,u=0;u<a.length;u++){var f=a[u];r(e,f)||n&&r(n,f)||c(e,f,l(t,f))}}},(e,t,n)=>{var r=n(27),i=n(17),o=n(61),s=n(70),a=n(50),c=i([].concat);e.exports=r("Reflect","ownKeys")||function ownKeys(e){var t=o.f(a(e)),n=s.f;return n?c(t,n(e)):t}},(e,t,n)=>{var r=n(62),i=n(69).concat("length","prototype");t.f=Object.getOwnPropertyNames||function getOwnPropertyNames(e){return r(e,i)}},(e,t,n)=>{var r=n(17),i=n(42),o=n(15),s=n(63).indexOf,a=n(58),c=r([].push);e.exports=function(e,t){var n,r=o(e),l=0,u=[];for(n in r)!i(a,n)&&i(r,n)&&c(u,n);for(;t.length>l;)i(r,n=t[l++])&&(~s(u,n)||c(u,n));return u}},(e,t,n)=>{var r=n(15),i=n(64),o=n(67),createMethod=function(e){return function(t,n,s){var a,c=r(t),l=o(c),u=i(s,l);if(e&&n!=n){for(;l>u;)if((a=c[u++])!=a)return!0}else for(;l>u;u++)if((e||u in c)&&c[u]===n)return e||u||0;return!e&&-1}};e.exports={includes:createMethod(!0),indexOf:createMethod(!1)}},(e,t,n)=>{var r=n(65),i=Math.max,o=Math.min;e.exports=function(e,t){var n=r(e);return n<0?i(n+t,0):o(n,t)}},(e,t,n)=>{var r=n(66);e.exports=function(e){var t=+e;return t!=t||0===t?0:r(t)}},e=>{var t=Math.ceil,n=Math.floor;e.exports=Math.trunc||function trunc(e){var r=+e;return(r>0?n:t)(r)}},(e,t,n)=>{var r=n(68);e.exports=function(e){return r(e.length)}},(e,t,n)=>{var r=n(65),i=Math.min;e.exports=function(e){return e>0?i(r(e),9007199254740991):0}},e=>{e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},(e,t)=>{t.f=Object.getOwnPropertySymbols},(e,t,n)=>{var r=n(10),i=n(24),o=/#|\.prototype\./,isForced=function(e,t){var n=a[s(e)];return n==l||n!=c&&(i(t)?r(t):!!t)},s=isForced.normalize=function(e){return String(e).replace(o,".").toLowerCase()},a=isForced.data={},c=isForced.NATIVE="N",l=isForced.POLYFILL="P";e.exports=isForced},(e,t,n)=>{var r=n(37),i=n(73),o=n(48).f,s=r("unscopables"),a=Array.prototype;null==a[s]&&o(a,s,{configurable:!0,value:i(null)});e.exports=function(e){a[s][e]=!0}},(e,t,n)=>{var r,i=n(50),o=n(74),s=n(69),a=n(58),c=n(76),l=n(46),u=n(57),f=u("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return"<script>"+e+"</"+"script>"},NullProtoObjectViaActiveX=function(e){e.write(scriptTag(""));e.close();var t=e.parentWindow.Object;e=null;return t},NullProtoObject=function(){try{r=new ActiveXObject("htmlfile")}catch(e){}NullProtoObject="undefined"!=typeof document?document.domain&&r?NullProtoObjectViaActiveX(r):function(){var e,t=l("iframe");t.style.display="none";c.appendChild(t);t.src=String("javascript:");(e=t.contentWindow.document).open();e.write(scriptTag("document.F=Object"));e.close();return e.F}():NullProtoObjectViaActiveX(r);for(var e=s.length;e--;)delete NullProtoObject.prototype[s[e]];return NullProtoObject()};a[f]=!0;e.exports=Object.create||function create(e,t){var n;if(null!==e){EmptyConstructor.prototype=i(e);n=new EmptyConstructor;EmptyConstructor.prototype=null;n[f]=e}else n=NullProtoObject();return void 0===t?n:o.f(n,t)}},(e,t,n)=>{var r=n(9),i=n(49),o=n(48),s=n(50),a=n(15),c=n(75);t.f=r&&!i?Object.defineProperties:function defineProperties(e,t){s(e);for(var n,r=a(t),i=c(t),l=i.length,u=0;l>u;)o.f(e,n=i[u++],r[n]);return e}},(e,t,n)=>{var r=n(62),i=n(69);e.exports=Object.keys||function keys(e){return r(e,i)}},(e,t,n)=>{var r=n(27);e.exports=r("document","documentElement")},(e,t,n)=>{var r=n(7),i=n(17);e.exports=function(e,t){return i(r[e].prototype[t])}},(e,t,n)=>{n(79)},(e,t,n)=>{"use strict";var r=n(80),i=n(67),o=n(65),s=r.aTypedArray;(0,r.exportTypedArrayMethod)("at",(function at(e){var t=s(this),n=i(t),r=o(e),a=r>=0?r:n+r;return a<0||a>=n?void 0:t[a]}))},(e,t,n)=>{"use strict";var r,i,o,s=n(81),a=n(9),c=n(7),l=n(24),u=n(23),f=n(42),h=n(82),d=n(35),p=n(47),g=n(51),m=n(48).f,b=n(28),y=n(84),x=n(86),w=n(37),T=n(44),S=n(55),C=S.enforce,v=S.get,P=c.Int8Array,E=P&&P.prototype,I=c.Uint8ClampedArray,A=I&&I.prototype,k=P&&y(P),O=E&&y(E),_=Object.prototype,B=c.TypeError,D=w("toStringTag"),M=T("TYPED_ARRAY_TAG"),R="TypedArrayConstructor",L=s&&!!x&&"Opera"!==h(c.opera),U=!1,N={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},j={BigInt64Array:8,BigUint64Array:8},getTypedArrayConstructor=function(e){var t=y(e);if(u(t)){var n=v(t);return n&&f(n,R)?n.TypedArrayConstructor:getTypedArrayConstructor(t)}},isTypedArray=function(e){if(!u(e))return!1;var t=h(e);return f(N,t)||f(j,t)};for(r in N)(o=(i=c[r])&&i.prototype)?C(o).TypedArrayConstructor=i:L=!1;for(r in j)(o=(i=c[r])&&i.prototype)&&(C(o).TypedArrayConstructor=i);if(!L||!l(k)||k===Function.prototype){k=function TypedArray(){throw B("Incorrect invocation")};if(L)for(r in N)c[r]&&x(c[r],k)}if(!L||!O||O===_){O=k.prototype;if(L)for(r in N)c[r]&&x(c[r].prototype,O)}L&&y(A)!==O&&x(A,O);if(a&&!f(O,D)){U=!0;m(O,D,{get:function(){return u(this)?this[M]:void 0}});for(r in N)c[r]&&p(c[r],M,r)}e.exports={NATIVE_ARRAY_BUFFER_VIEWS:L,TYPED_ARRAY_TAG:U&&M,aTypedArray:function(e){if(isTypedArray(e))return e;throw B("Target is not a typed array")},aTypedArrayConstructor:function(e){if(l(e)&&(!x||b(k,e)))return e;throw B(d(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,n,r){if(a){if(n)for(var i in N){var o=c[i];if(o&&f(o.prototype,e))try{delete o.prototype[e]}catch(n){try{o.prototype[e]=t}catch(e){}}}O[e]&&!n||g(O,e,n?t:L&&E[e]||t,r)}},exportTypedArrayStaticMethod:function(e,t,n){var r,i;if(a){if(x){if(n)for(r in N)if((i=c[r])&&f(i,e))try{delete i[e]}catch(e){}if(k[e]&&!n)return;try{return g(k,e,n?t:L&&k[e]||t)}catch(e){}}for(r in N)!(i=c[r])||i[e]&&!n||g(i,e,t)}},getTypedArrayConstructor:getTypedArrayConstructor,isView:function isView(e){if(!u(e))return!1;var t=h(e);return"DataView"===t||f(N,t)||f(j,t)},isTypedArray:isTypedArray,TypedArray:k,TypedArrayPrototype:O}},e=>{e.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},(e,t,n)=>{var r=n(83),i=n(24),o=n(18),s=n(37)("toStringTag"),a=Object,c="Arguments"==o(function(){return arguments}());e.exports=r?o:function(e){var t,n,r;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(n=function(e,t){try{return e[t]}catch(e){}}(t=a(e),s))?n:c?o(t):"Object"==(r=o(t))&&i(t.callee)?"Arguments":r}},(e,t,n)=>{var r={};r[n(37)("toStringTag")]="z";e.exports="[object z]"===String(r)},(e,t,n)=>{var r=n(42),i=n(24),o=n(43),s=n(57),a=n(85),c=s("IE_PROTO"),l=Object,u=l.prototype;e.exports=a?l.getPrototypeOf:function(e){var t=o(e);if(r(t,c))return t[c];var n=t.constructor;return i(n)&&t instanceof n?n.prototype:t instanceof l?u:null}},(e,t,n)=>{var r=n(10);e.exports=!r((function(){function F(){}F.prototype.constructor=null;return Object.getPrototypeOf(new F)!==F.prototype}))},(e,t,n)=>{var r=n(17),i=n(50),o=n(87);e.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,n={};try{(e=r(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]);t=n instanceof Array}catch(e){}return function setPrototypeOf(n,r){i(n);o(r);t?e(n,r):n.__proto__=r;return n}}():void 0)},(e,t,n)=>{var r=n(24),i=String,o=TypeError;e.exports=function(e){if("object"==typeof e||r(e))return e;throw o("Can't set "+i(e)+" as a prototype")}},(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Jbig2Image=void 0;var r=n(1),i=n(89),o=n(92),s=n(93);class Jbig2Error extends r.BaseException{constructor(e){super(`JBIG2 error: ${e}`,"Jbig2Error")}}class ContextCache{getContexts(e){return e in this?this[e]:this[e]=new Int8Array(65536)}}class DecodingContext{constructor(e,t,n){this.data=e;this.start=t;this.end=n}get decoder(){const e=new o.ArithmeticDecoder(this.data,this.start,this.end);return(0,r.shadow)(this,"decoder",e)}get contextCache(){const e=new ContextCache;return(0,r.shadow)(this,"contextCache",e)}}function decodeInteger(e,t,n){const r=e.getContexts(t);let i=1;function readBits(e){let t=0;for(let o=0;o<e;o++){const e=n.readBit(r,i);i=i<256?i<<1|e:511&(i<<1|e)|256;t=t<<1|e}return t>>>0}const 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){const r=e.getContexts("IAID");let i=1;for(let e=0;e<n;e++){i=i<<1|t.readBit(r,i)}return n<31?i&(1<<n)-1:2147483647&i}const a=["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"],c=[[{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}]],l=[{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}]}],u=[39717,1941,229,405],f=[32,8];function decodeBitmap(e,t,n,r,i,o,s,a){if(e){return decodeMMRBitmap(new Reader(a.data,a.start,a.end),t,n,!1)}if(0===r&&!o&&!i&&4===s.length&&3===s[0].x&&-1===s[0].y&&-3===s[1].x&&-1===s[1].y&&2===s[2].x&&-2===s[2].y&&-2===s[3].x&&-2===s[3].y)return function decodeBitmapTemplate0(e,t,n){const r=n.decoder,i=n.contextCache.getContexts("GB"),o=[];let s,a,c,l,u,f,h;for(a=0;a<t;a++){u=o[a]=new Uint8Array(e);f=a<1?u:o[a-1];h=a<2?u:o[a-2];s=h[0]<<13|h[1]<<12|h[2]<<11|f[0]<<7|f[1]<<6|f[2]<<5|f[3]<<4;for(c=0;c<e;c++){u[c]=l=r.readBit(i,s);s=(31735&s)<<1|(c+3<e?h[c+3]<<11:0)|(c+4<e?f[c+4]<<4:0)|l}}return o}(t,n,a);const l=!!o,f=c[r].concat(s);f.sort((function(e,t){return e.y-t.y||e.x-t.x}));const h=f.length,d=new Int8Array(h),p=new Int8Array(h),g=[];let m,b,y=0,x=0,w=0,T=0;for(b=0;b<h;b++){d[b]=f[b].x;p[b]=f[b].y;x=Math.min(x,f[b].x);w=Math.max(w,f[b].x);T=Math.min(T,f[b].y);b<h-1&&f[b].y===f[b+1].y&&f[b].x===f[b+1].x-1?y|=1<<h-1-b:g.push(b)}const S=g.length,C=new Int8Array(S),v=new Int8Array(S),P=new Uint16Array(S);for(m=0;m<S;m++){b=g[m];C[m]=f[b].x;v[m]=f[b].y;P[m]=1<<h-1-b}const E=-x,I=-T,A=t-w,k=u[r];let O=new Uint8Array(t);const _=[],B=a.decoder,D=a.contextCache.getContexts("GB");let M,R,L,U,N,j=0,H=0;for(let e=0;e<n;e++){if(i){j^=B.readBit(D,k);if(j){_.push(O);continue}}O=new Uint8Array(O);_.push(O);for(M=0;M<t;M++){if(l&&o[e][M]){O[M]=0;continue}if(M>=E&&M<A&&e>=I){H=H<<1&y;for(b=0;b<S;b++){R=e+v[b];L=M+C[b];U=_[R][L];if(U){U=P[b];H|=U}}}else{H=0;N=h-1;for(b=0;b<h;b++,N--){L=M+d[b];if(L>=0&&L<t){R=e+p[b];if(R>=0){U=_[R][L];U&&(H|=U<<N)}}}}const n=B.readBit(D,H);O[M]=n}}return _}function decodeRefinement(e,t,n,r,i,o,s,a,c){let u=l[n].coding;0===n&&(u=u.concat([a[0]]));const h=u.length,d=new Int32Array(h),p=new Int32Array(h);let g;for(g=0;g<h;g++){d[g]=u[g].x;p[g]=u[g].y}let m=l[n].reference;0===n&&(m=m.concat([a[1]]));const b=m.length,y=new Int32Array(b),x=new Int32Array(b);for(g=0;g<b;g++){y[g]=m[g].x;x[g]=m[g].y}const w=r[0].length,T=r.length,S=f[n],C=[],v=c.decoder,P=c.contextCache.getContexts("GR");let E=0;for(let n=0;n<t;n++){if(s){E^=v.readBit(P,S);if(E)throw new Jbig2Error("prediction is not supported")}const t=new Uint8Array(e);C.push(t);for(let s=0;s<e;s++){let a,c,l=0;for(g=0;g<h;g++){a=n+p[g];c=s+d[g];a<0||c<0||c>=e?l<<=1:l=l<<1|C[a][c]}for(g=0;g<b;g++){a=n+x[g]-o;c=s+y[g]-i;a<0||a>=T||c<0||c>=w?l<<=1:l=l<<1|r[a][c]}const u=v.readBit(P,l);t[s]=u}}return C}function decodeTextRegion(e,t,n,r,i,o,s,a,c,l,u,f,h,d,p,g,m,b,y){if(e&&t)throw new Jbig2Error("refinement with Huffman is not supported");const x=[];let w,T;for(w=0;w<r;w++){T=new Uint8Array(n);if(i)for(let e=0;e<n;e++)T[e]=i;x.push(T)}const S=m.decoder,C=m.contextCache;let v=e?-d.tableDeltaT.decode(y):-decodeInteger(C,"IADT",S),P=0;w=0;for(;w<o;){v+=e?d.tableDeltaT.decode(y):decodeInteger(C,"IADT",S);P+=e?d.tableFirstS.decode(y):decodeInteger(C,"IAFS",S);let r=P;for(;;){let i=0;s>1&&(i=e?y.readBits(b):decodeInteger(C,"IAIT",S));const o=s*v+i,P=e?d.symbolIDTable.decode(y):decodeIAID(C,S,c),E=t&&(e?y.readBit():decodeInteger(C,"IARI",S));let I=a[P],A=I[0].length,k=I.length;if(E){const e=decodeInteger(C,"IARDW",S),t=decodeInteger(C,"IARDH",S),n=decodeInteger(C,"IARDX",S),r=decodeInteger(C,"IARDY",S);A+=e;k+=t;I=decodeRefinement(A,k,p,I,(e>>1)+n,(t>>1)+r,!1,g,m)}const O=o-(1&f?0:k-1),_=r-(2&f?A-1:0);let B,D,M;if(l){for(B=0;B<k;B++){T=x[_+B];if(!T)continue;M=I[B];const e=Math.min(n-O,A);switch(h){case 0:for(D=0;D<e;D++)T[O+D]|=M[D];break;case 2:for(D=0;D<e;D++)T[O+D]^=M[D];break;default:throw new Jbig2Error(`operator ${h} is not supported`)}}r+=k-1}else{for(D=0;D<k;D++){T=x[O+D];if(T){M=I[D];switch(h){case 0:for(B=0;B<A;B++)T[_+B]|=M[B];break;case 2:for(B=0;B<A;B++)T[_+B]^=M[B];break;default:throw new Jbig2Error(`operator ${h} is not supported`)}}}r+=A-1}w++;const R=e?d.tableDeltaS.decode(y):decodeInteger(C,"IADS",S);if(null===R)break;r+=R+u}}return x}function readSegmentHeader(e,t){const n={};n.number=(0,i.readUint32)(e,t);const r=e[t+4],o=63&r;if(!a[o])throw new Jbig2Error("invalid segment type: "+o);n.type=o;n.typeName=a[o];n.deferredNonRetain=!!(128&r);const s=!!(64&r),c=e[t+5];let l=c>>5&7;const u=[31&c];let f=t+6;if(7===c){l=536870911&(0,i.readUint32)(e,f-1);f+=3;let t=l+7>>3;u[0]=e[f++];for(;--t>0;)u.push(e[f++])}else if(5===c||6===c)throw new Jbig2Error("invalid referred-to flags");n.retainBits=u;let d=4;n.number<=256?d=1:n.number<=65536&&(d=2);const p=[];let g,m;for(g=0;g<l;g++){let t;t=1===d?e[f]:2===d?(0,i.readUint16)(e,f):(0,i.readUint32)(e,f);p.push(t);f+=d}n.referredTo=p;if(s){n.pageAssociation=(0,i.readUint32)(e,f);f+=4}else n.pageAssociation=e[f++];n.length=(0,i.readUint32)(e,f);f+=4;if(4294967295===n.length){if(38!==o)throw new Jbig2Error("invalid unknown segment length");{const t=readRegionSegmentInformation(e,f),r=!!(1&e[f+h]),i=6,o=new Uint8Array(i);if(!r){o[0]=255;o[1]=172}o[2]=t.height>>>24&255;o[3]=t.height>>16&255;o[4]=t.height>>8&255;o[5]=255&t.height;for(g=f,m=e.length;g<m;g++){let t=0;for(;t<i&&o[t]===e[g+t];)t++;if(t===i){n.length=g+i;break}}if(4294967295===n.length)throw new Jbig2Error("segment end was not found")}}n.headerEnd=f;return n}function readSegments(e,t,n,r){const i=[];let o=n;for(;o<r;){const n=readSegmentHeader(t,o);o=n.headerEnd;const r={header:n,data:t};if(!e.randomAccess){r.start=o;o+=n.length;r.end=o}i.push(r);if(51===n.type)break}if(e.randomAccess)for(let e=0,t=i.length;e<t;e++){i[e].start=o;o+=i[e].header.length;i[e].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]}}const h=17;function processSegment(e,t){const n=e.header,r=e.data,o=e.end;let s,a,c,l,u=e.start;switch(n.type){case 0:const e={},t=(0,i.readUint16)(r,u);e.huffman=!!(1&t);e.refinement=!!(2&t);e.huffmanDHSelector=t>>2&3;e.huffmanDWSelector=t>>4&3;e.bitmapSizeSelector=t>>6&1;e.aggregationInstancesSelector=t>>7&1;e.bitmapCodingContextUsed=!!(256&t);e.bitmapCodingContextRetained=!!(512&t);e.template=t>>10&3;e.refinementTemplate=t>>12&1;u+=2;if(!e.huffman){l=0===e.template?4:1;a=[];for(c=0;c<l;c++){a.push({x:(0,i.readInt8)(r,u),y:(0,i.readInt8)(r,u+1)});u+=2}e.at=a}if(e.refinement&&!e.refinementTemplate){a=[];for(c=0;c<2;c++){a.push({x:(0,i.readInt8)(r,u),y:(0,i.readInt8)(r,u+1)});u+=2}e.refinementAt=a}e.numberOfExportedSymbols=(0,i.readUint32)(r,u);u+=4;e.numberOfNewSymbols=(0,i.readUint32)(r,u);u+=4;s=[e,n.number,n.referredTo,r,u,o];break;case 6:case 7:const f={};f.info=readRegionSegmentInformation(r,u);u+=h;const d=(0,i.readUint16)(r,u);u+=2;f.huffman=!!(1&d);f.refinement=!!(2&d);f.logStripSize=d>>2&3;f.stripSize=1<<f.logStripSize;f.referenceCorner=d>>4&3;f.transposed=!!(64&d);f.combinationOperator=d>>7&3;f.defaultPixelValue=d>>9&1;f.dsOffset=d<<17>>27;f.refinementTemplate=d>>15&1;if(f.huffman){const e=(0,i.readUint16)(r,u);u+=2;f.huffmanFS=3&e;f.huffmanDS=e>>2&3;f.huffmanDT=e>>4&3;f.huffmanRefinementDW=e>>6&3;f.huffmanRefinementDH=e>>8&3;f.huffmanRefinementDX=e>>10&3;f.huffmanRefinementDY=e>>12&3;f.huffmanRefinementSizeSelector=!!(16384&e)}if(f.refinement&&!f.refinementTemplate){a=[];for(c=0;c<2;c++){a.push({x:(0,i.readInt8)(r,u),y:(0,i.readInt8)(r,u+1)});u+=2}f.refinementAt=a}f.numberOfSymbolInstances=(0,i.readUint32)(r,u);u+=4;s=[f,n.referredTo,r,u,o];break;case 16:const p={},g=r[u++];p.mmr=!!(1&g);p.template=g>>1&3;p.patternWidth=r[u++];p.patternHeight=r[u++];p.maxPatternIndex=(0,i.readUint32)(r,u);u+=4;s=[p,n.number,r,u,o];break;case 22:case 23:const m={};m.info=readRegionSegmentInformation(r,u);u+=h;const b=r[u++];m.mmr=!!(1&b);m.template=b>>1&3;m.enableSkip=!!(8&b);m.combinationOperator=b>>4&7;m.defaultPixelValue=b>>7&1;m.gridWidth=(0,i.readUint32)(r,u);u+=4;m.gridHeight=(0,i.readUint32)(r,u);u+=4;m.gridOffsetX=4294967295&(0,i.readUint32)(r,u);u+=4;m.gridOffsetY=4294967295&(0,i.readUint32)(r,u);u+=4;m.gridVectorX=(0,i.readUint16)(r,u);u+=2;m.gridVectorY=(0,i.readUint16)(r,u);u+=2;s=[m,n.referredTo,r,u,o];break;case 38:case 39:const y={};y.info=readRegionSegmentInformation(r,u);u+=h;const x=r[u++];y.mmr=!!(1&x);y.template=x>>1&3;y.prediction=!!(8&x);if(!y.mmr){l=0===y.template?4:1;a=[];for(c=0;c<l;c++){a.push({x:(0,i.readInt8)(r,u),y:(0,i.readInt8)(r,u+1)});u+=2}y.at=a}s=[y,r,u,o];break;case 48:const w={width:(0,i.readUint32)(r,u),height:(0,i.readUint32)(r,u+4),resolutionX:(0,i.readUint32)(r,u+8),resolutionY:(0,i.readUint32)(r,u+12)};4294967295===w.height&&delete w.height;const T=r[u+16];(0,i.readUint16)(r,u+17);w.lossless=!!(1&T);w.refinement=!!(2&T);w.defaultPixelValue=T>>2&1;w.combinationOperator=T>>3&3;w.requiresBuffer=!!(32&T);w.combinationOperatorOverride=!!(64&T);s=[w];break;case 49:case 50:case 51:case 62:break;case 53:s=[n.number,r,u,o];break;default:throw new Jbig2Error(`segment type ${n.typeName}(${n.type}) is not implemented`)}const f="on"+n.typeName;f in t&&t[f].apply(t,s)}function processSegments(e,t){for(let n=0,r=e.length;n<r;n++)processSegment(e[n],t)}class SimpleSegmentVisitor{onPageInformation(e){this.currentPageInfo=e;const t=e.width+7>>3,n=new Uint8ClampedArray(t*e.height);e.defaultPixelValue&&n.fill(255);this.buffer=n}drawBitmap(e,t){const n=this.currentPageInfo,r=e.width,i=e.height,o=n.width+7>>3,s=n.combinationOperatorOverride?e.combinationOperator:n.combinationOperator,a=this.buffer,c=128>>(7&e.x);let l,u,f,h,d=e.y*o+(e.x>>3);switch(s){case 0:for(l=0;l<i;l++){f=c;h=d;for(u=0;u<r;u++){t[l][u]&&(a[h]|=f);f>>=1;if(!f){f=128;h++}}d+=o}break;case 2:for(l=0;l<i;l++){f=c;h=d;for(u=0;u<r;u++){t[l][u]&&(a[h]^=f);f>>=1;if(!f){f=128;h++}}d+=o}break;default:throw new Jbig2Error(`operator ${s} is not supported`)}}onImmediateGenericRegion(e,t,n,r){const 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(){this.onImmediateGenericRegion(...arguments)}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)}let l=this.symbols;l||(this.symbols=l={});const u=[];for(const e of n){const t=l[e];t&&u.push(...t)}const f=new DecodingContext(r,o,s);l[t]=function decodeSymbolDictionary(e,t,n,r,o,s,a,c,l,u,f,h){if(e&&t)throw new Jbig2Error("symbol refinement with Huffman is not supported");const d=[];let p=0,g=(0,i.log2)(n.length+r);const m=f.decoder,b=f.contextCache;let y,x;if(e){y=getStandardTable(1);x=[];g=Math.max(g,1)}for(;d.length<r;){p+=e?s.tableDeltaHeight.decode(h):decodeInteger(b,"IADH",m);let r=0,i=0;const o=e?x.length:0;for(;;){const o=e?s.tableDeltaWidth.decode(h):decodeInteger(b,"IADW",m);if(null===o)break;r+=o;i+=r;let y;if(t){const i=decodeInteger(b,"IAAI",m);if(i>1)y=decodeTextRegion(e,t,r,p,0,i,1,n.concat(d),g,0,0,1,0,s,l,u,f,0,h);else{const e=decodeIAID(b,m,g),t=decodeInteger(b,"IARDX",m),i=decodeInteger(b,"IARDY",m);y=decodeRefinement(r,p,l,e<n.length?n[e]:d[e-n.length],t,i,!1,u,f)}d.push(y)}else if(e)x.push(r);else{y=decodeBitmap(!1,r,p,a,!1,null,c,f);d.push(y)}}if(e&&!t){const e=s.tableBitmapSize.decode(h);h.byteAlign();let t;if(0===e)t=readUncompressedBitmap(h,i,p);else{const n=h.end,r=h.position+e;h.end=r;t=decodeMMRBitmap(h,i,p,!1);h.end=n;h.position=r}const n=x.length;if(o===n-1)d.push(t);else{let e,r,i,s,a,c=0;for(e=o;e<n;e++){s=x[e];i=c+s;a=[];for(r=0;r<p;r++)a.push(t[r].subarray(c,i));d.push(a);c=i}}}}const w=[],T=[];let S,C,v=!1;const P=n.length+r;for(;T.length<P;){let t=e?y.decode(h):decodeInteger(b,"IAEX",m);for(;t--;)T.push(v);v=!v}for(S=0,C=n.length;S<C;S++)T[S]&&w.push(n[S]);for(let e=0;e<r;S++,e++)T[S]&&w.push(d[e]);return w}(e.huffman,e.refinement,u,e.numberOfNewSymbols,e.numberOfExportedSymbols,a,e.template,e.at,e.refinementTemplate,e.refinementAt,f,c)}onImmediateTextRegion(e,t,n,r,o){const s=e.info;let a,c;const l=this.symbols,u=[];for(const e of t){const t=l[e];t&&u.push(...t)}const f=(0,i.log2)(u.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].prefi