/** * @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(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 n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"getVerbosityLevel",{enumerable:!0,get:function(){return i.getVerbosityLevel}}),Object.defineProperty(t,"setVerbosityLevel",{enumerable:!0,get:function(){return i.setVerbosityLevel}}),Object.defineProperty(t,"Jbig2mage",{enumerable:!0,get:function(){return r.Jbig2mage}}),Object.defineProperty(t,"JpegImage",{enumerable:!0,get:function(){return s.JpegImage}}),Object.defineProperty(t,"JpxImage",{enumerable:!0,get:function(){return o.JpxImage}});var i=n(1),r=n(3),s=n(7),o=n(8)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.arrayByteLength=u,t.arraysToBytes=function(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let n=0;for(let i=0;it}),e.promise=new Promise((function(n,i){e.resolve=function(e){t=!0,n(e)},e.reject=function(e){t=!0,i(e)}})),e},t.getVerbosityLevel=function(){return r},t.info=function(e){r>=i.INFOS&&console.log(`Info: ${e}`)},t.isArrayBuffer=function(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength},t.isArrayEqual=function(e,t){if(e.length!==t.length)return!1;return e.every((function(e,n){return e===t[n]}))},t.isBool=function(e){return"boolean"==typeof e},t.isEmptyObj=function(e){for(const t in e)return!1;return!0},t.isNum=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSameOrigin=function(e,t){let n;try{if(n=new URL(e),!n.origin||"null"===n.origin)return!1}catch(e){return!1}const i=new URL(t,n);return n.origin===i.origin},t.createValidAbsoluteUrl=function(e,t){if(!e)return null;try{const n=t?new URL(e,t):new URL(e);if(function(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(n))return n}catch(e){}return null},t.removeNullCharacters=function(e){if("string"!=typeof e)return s("The argument for removeNullCharacters must be a string."),e;return e.replace(h,"")},t.setVerbosityLevel=function(e){Number.isInteger(e)&&(r=e)},t.shadow=c,t.string32=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},t.stringToBytes=f,t.stringToPDFString=function(e){const t=e.length,n=[];if("þ"===e[0]&&"ÿ"===e[1])for(let i=2;i=i.WARNINGS&&console.log(`Warning: ${e}`)}function o(e){throw new Error(e)}function a(e,t){e||o(t)}function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!1}),n}const l=function(){function e(t){this.constructor===e&&o("Cannot initialize BaseException."),this.message=t,this.name=this.constructor.name}return e.prototype=new Error,e.constructor=e,e}();t.BaseException=l;t.PasswordException=class extends l{constructor(e,t){super(e),this.code=t}};t.UnknownErrorException=class extends l{constructor(e,t){super(e),this.details=t}};t.InvalidPDFException=class extends l{};t.MissingPDFException=class extends l{};t.UnexpectedResponseException=class extends l{constructor(e,t){super(e),this.status=t}};t.FormatError=class extends l{};t.AbortException=class extends l{};const h=/\x00/g;function f(e){a("string"==typeof e,"Invalid argument for stringToBytes");const t=e.length,n=new Uint8Array(t);for(let i=0;ie[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){function n(e,t){return e-t}const i=[e[0],e[2],t[0],t[2]].sort(n),r=[e[1],e[3],t[1],t[3]].sort(n),s=[];return e=g.normalizeRect(e),t=g.normalizeRect(t),i[0]===e[0]&&i[1]===t[0]||i[0]===t[0]&&i[1]===e[0]?(s[0]=i[1],s[2]=i[2],r[0]===e[1]&&r[1]===t[1]||r[0]===t[1]&&r[1]===e[1]?(s[1]=r[1],s[3]=r[2],s):null):null}}t.Util=g;const b=[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 v=function(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function(t,n,i=!1){if(!i&&URL.createObjectURL){const e=new Blob([t],{type:n});return URL.createObjectURL(e)}let r=`data:${n};base64,`;for(let n=0,i=t.length;n>2]+e[(3&s)<<4|o>>4]+e[n+1>6:64]+e[n+2>>0}var o=s(1),a=s(1)?s(1)?s(1)?s(1)?s(1)?s(32)+4436:s(12)+340:s(8)+84:s(6)+20:s(4)+4:s(2);return 0===o?a:a>0?-a:null}function c(e,t,n){for(var i=e.getContexts("IAID"),r=1,s=0;s=M&&k=B)for(X=X<<1&v,d=0;d=0&&L=0&&(A=F[S][L])&&(X|=A<=e?M<<=1:M=M<<1|T[E][D];for(u=0;u=C||D<0||D>=w?M<<=1:M=M<<1|i[E][D];var B=I.readBit(k,M);O[A]=B}}return T}function g(e,t,i,r,s,o,l,h,f,u,d,p,g,b,v,y,x,w,C){if(e&&t)throw new a("refinement with Huffman is not supported");var P,T,I=[];for(P=0;P1&&(r=e?C.readBits(w):n(L,"IAIT",S));var D=l*O+r,M=e?b.symbolIDTable.decode(C):c(L,S,f),B=t&&(e?C.readBit():n(L,"IARI",S)),U=h[M],R=U[0].length,_=U.length;if(B){var F=n(L,"IARDW",S),N=n(L,"IARDH",S);U=m(R+=F,_+=N,v,U,(F>>1)+n(L,"IARDX",S),(N>>1)+n(L,"IARDY",S),!1,y,x)}var z,H,X,Y=D-(1&p?0:_-1),q=E-(2&p?R-1:0);if(u){for(z=0;z<_;z++)if(T=I[q+z]){X=U[z];var j=Math.min(i-Y,R);switch(g){case 0:for(H=0;H>5&7,f=[31&c],u=t+6;if(7===c){h=536870911&(0,r.readUint32)(e,u-1),u+=3;var d=h+7>>3;for(f[0]=e[u++];--d>0;)f.push(e[u++])}else if(5===c||6===c)throw new a("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>>24&255,C[3]=v.height>>16&255,C[4]=v.height>>8&255,C[5]=255&v.height,m=u,g=e.length;m>2&3,u.huffmanDWSelector=d>>4&3,u.bitmapSizeSelector=d>>6&1,u.aggregationInstancesSelector=d>>7&1,u.bitmapCodingContextUsed=!!(256&d),u.bitmapCodingContextRetained=!!(512&d),u.template=d>>10&3,u.refinementTemplate=d>>12&1,h+=2,!u.huffman){for(o=0===u.template?4:1,i=[],s=0;s>2&3,p.stripSize=1<>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,p.huffman){var g=(0,r.readUint16)(l,h);h+=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){for(i=[],s=0;s<2;s++)i.push({x:(0,r.readInt8)(l,h),y:(0,r.readInt8)(l,h+1)}),h+=2;p.refinementAt=i}p.numberOfSymbolInstances=(0,r.readUint32)(l,h),h+=4,n=[p,c.referredTo,l,h,f];break;case 16:const e={},t=l[h++];e.mmr=!!(1&t),e.template=t>>1&3,e.patternWidth=l[h++],e.patternHeight=l[h++],e.maxPatternIndex=(0,r.readUint32)(l,h),h+=4,n=[e,c.number,l,h,f];break;case 22:case 23:const P={};P.info=y(l,h),h+=x;const T=l[h++];P.mmr=!!(1&T),P.template=T>>1&3,P.enableSkip=!!(8&T),P.combinationOperator=T>>4&7,P.defaultPixelValue=T>>7&1,P.gridWidth=(0,r.readUint32)(l,h),h+=4,P.gridHeight=(0,r.readUint32)(l,h),h+=4,P.gridOffsetX=4294967295&(0,r.readUint32)(l,h),h+=4,P.gridOffsetY=4294967295&(0,r.readUint32)(l,h),h+=4,P.gridVectorX=(0,r.readUint16)(l,h),h+=2,P.gridVectorY=(0,r.readUint16)(l,h),h+=2,n=[P,c.referredTo,l,h,f];break;case 38:case 39:var b={};b.info=y(l,h),h+=x;var v=l[h++];if(b.mmr=!!(1&v),b.template=v>>1&3,b.prediction=!!(8&v),!b.mmr){for(o=0===b.template?4:1,i=[],s=0;s>2&1,w.combinationOperator=C>>3&3,w.requiresBuffer=!!(32&C),w.combinationOperatorOverride=!!(64&C),n=[w];break;case 49:case 50:case 51:break;case 53:n=[c.number,l,h,f];break;case 62:break;default:throw new a(`segment type ${c.typeName}(${c.type})`+" is not implemented")}var P="on"+c.typeName;P in t&&t[P].apply(t,n)}function C(e,t){for(var n=0,i=e.length;n0&&this.rootNode.buildTree(n,n.prefixLength-1)}}P.prototype={onPageInformation:function(e){this.currentPageInfo=e;var t=e.width+7>>3,n=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var i=0,r=n.length;i>3,f=o.combinationOperatorOverride?e.combinationOperator:o.combinationOperator,u=this.buffer,d=128>>(7&e.x),p=e.y*h+(e.x>>3);switch(f){case 0:for(n=0;n>=1)||(r=128,s++);p+=h}break;case 2:for(n=0;n>=1)||(r=128,s++);p+=h}break;default:throw new a(`operator ${f} is not supported`)}},onImmediateGenericRegion:function(e,n,i,r){var s=e.info,o=new t(n,i,r),a=p(e.mmr,s.width,s.height,e.template,e.prediction,null,e.at,o);this.drawBitmap(s,a)},onImmediateLosslessGenericRegion:function(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function(e,i,s,o,l,h){let f,u;e.huffman&&(f=function(e,t,n){let i,r,s,o,c=0;switch(e.huffmanDHSelector){case 0:case 1:i=L(e.huffmanDHSelector+4);break;case 3:i=A(c,t,n),c++;break;default:throw new a("invalid Huffman DH selector")}switch(e.huffmanDWSelector){case 0:case 1:r=L(e.huffmanDWSelector+2);break;case 3:r=A(c,t,n),c++;break;default:throw new a("invalid Huffman DW selector")}e.bitmapSizeSelector?(s=A(c,t,n),c++):s=L(1);o=e.aggregationInstancesSelector?A(c,t,n):L(1);return{tableDeltaHeight:i,tableDeltaWidth:r,tableBitmapSize:s,tableAggregateInstances:o}}(e,s,this.customTables),u=new O(o,l,h));var d=this.symbols;d||(this.symbols=d={});for(var b=[],v=0,y=s.length;v1)k=g(e,t,r,x,0,O,1,i.concat(y),w,0,0,1,0,l,u,d,b,0,v);else{var A=c(P,C,w),M=n(P,"IARDX",C),B=n(P,"IARDY",C);k=m(r,x,u,A=32){let n,i,o;switch(t){case 32:if(0===e)throw new a("no previous value in symbol ID table");i=r.readBits(2)+3,n=s[e-1].prefixLength;break;case 33:i=r.readBits(3)+3,n=0;break;case 34:i=r.readBits(7)+11,n=0;break;default:throw new a("invalid code length in symbol ID table")}for(o=0;o=0;y--)E=e?D(A,h,f,!0):p(!1,h,f,n,!1,null,S,b),L[y]=E;for(M=0;M=0;x--)U=L[x][M][B]^U,R|=U<>8,N=d+M*m-B*g>>8,F>=0&&F+T<=i&&N>=0&&N+I<=s)for(y=0;y=s))for(H=v[t],z=_[y],x=0;x=0&&e>1&7),l=1+(i>>4&7),h=[];let f,u,d=s;do{f=a.readBits(c),u=a.readBits(l),h.push(new T([d,f,u,0])),d+=1<>t&1;if(t<=0)this.children[n]=new I(e);else{let i=this.children[n];i||(this.children[n]=i=new I(null)),i.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 a("invalid Huffman data");return t.decodeNode(e)}},k.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){const t=e.length;let n=0;for(let i=0;i>n&1,n--}if(i&&!l){const e=5;for(let t=0;t=this.end)throw new a("end of data while reading bit");this.currentByte=this.data[this.position++],this.shift=7}const e=this.currentByte>>this.shift&1;return this.shift--,e},readBits(e){let t,n=0;for(t=e-1;t>=0;t--)n|=this.readBit()<=this.end?-1:this.data[this.position++]}},M.prototype={parseChunks:e=>function(e){for(var t=new P,n=0,i=e.length;n>=1}return{imgData:u,width:l,height:h}}(e);return this.width=n,this.height=i,t}},M}();t.Jbig2Image=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getLookupTableFactory=function(e){let t;return function(){return e&&(t=Object.create(null),e(t),e=null),t}},t.getInheritableProperty=function({dict:e,key:t,getArray:n=!1,stopWhenFound:r=!0}){let s,o=0;for(;e;){const a=n?e.getArray(t):e.get(t);if(void 0!==a){if(r)return a;s||(s=[]),s.push(a)}if(++o>100){(0,i.warn)(`getInheritableProperty: maximum loop count exceeded for "${t}"`);break}e=e.get("Parent")}return s},t.toRomanNumerals=function(e,t=!1){(0,i.assert)(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const n=[];let r;for(;e>=1e3;)e-=1e3,n.push("M");r=e/100|0,e%=100,n.push(a[r]),r=e/10|0,e%=10,n.push(a[10+r]),n.push(a[20+e]);const s=n.join("");return t?s.toLowerCase():s},t.log2=function(e){if(e<=0)return 0;return Math.ceil(Math.log2(e))},t.readInt8=function(e,t){return e[t]<<24>>24},t.readUint16=function(e,t){return e[t]<<8|e[t+1]},t.readUint32=function(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0},t.isWhiteSpace=function(e){return 32===e||9===e||13===e||10===e},t.XRefParseException=t.XRefEntryException=t.MissingDataException=void 0;var i=n(1);class r extends i.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`),this.begin=e,this.end=t}}t.MissingDataException=r;class s extends i.BaseException{}t.XRefEntryException=s;class o extends i.BaseException{}t.XRefParseException=o;const a=["","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,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ArithmeticDecoder=void 0;const i=[{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{constructor(e,t,n){this.data=e,this.bp=t,this.dataEnd=n,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;255===e[t]?e[t+1]>143?(this.clow+=65280,this.ct=8):(t++,this.clow+=e[t]<<9,this.ct=7,this.bp=t):(t++,this.clow+=t65535&&(this.chigh+=this.clow>>16,this.clow&=65535)}readBit(e,t){let n=e[t]>>1,r=1&e[t];const s=i[n],o=s.qe;let a,c=this.a-o;if(this.chigh>15&1,this.clow=this.clow<<1&65535,this.ct--}while(0==(32768&c));return this.a=c,e[t]=n<<1|r,a}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CCITTFaxDecoder=void 0;var i=n(1);const r=function(){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]],n=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]],r=[[-1,-1],[-1,-1],[12,-2],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]],s=[[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[11,23],[11,23],[12,50],[12,51],[12,44],[12,45],[12,46],[12,47],[12,57],[12,58],[12,61],[12,256],[10,16],[10,16],[10,16],[10,16],[10,17],[10,17],[10,17],[10,17],[12,48],[12,49],[12,62],[12,63],[12,30],[12,31],[12,32],[12,33],[12,40],[12,41],[11,22],[11,22],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[12,128],[12,192],[12,26],[12,27],[12,28],[12,29],[11,19],[11,19],[11,20],[11,20],[12,34],[12,35],[12,36],[12,37],[12,38],[12,39],[11,21],[11,21],[12,42],[12,43],[10,0],[10,0],[10,0],[10,0],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12]],o=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[6,9],[6,8],[5,7],[5,7],[4,6],[4,6],[4,6],[4,6],[4,5],[4,5],[4,5],[4,5],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2]];function a(e,t={}){if(!e||"function"!=typeof e.next)throw new Error('CCITTFaxDecoder - invalid "source" parameter.');this.source=e,this.eof=!1,this.encoding=t.K||0,this.eoline=t.EndOfLine||!1,this.byteAlign=t.EncodedByteAlign||!1,this.columns=t.Columns||1728,this.rows=t.Rows||0;let n,i=t.EndOfBlock;for(null==i&&(i=!0),this.eoblock=i,this.black=t.BlackIs1||!1,this.codingLine=new Uint32Array(this.columns+1),this.refLine=new Uint32Array(this.columns+2),this.codingLine[0]=this.columns,this.codingPos=0,this.row=0,this.nextLine2D=this.encoding<0,this.inputBits=0,this.inputBuf=0,this.outputBits=0,this.rowsDone=!1;0===(n=this._lookBits(12));)this._eatBits(1);1===n&&this._eatBits(12),this.encoding>0&&(this.nextLine2D=!this._lookBits(1),this._eatBits(1))}return a.prototype={readNextChar(){if(this.eof)return-1;const e=this.refLine,t=this.codingLine,n=this.columns;let r,s,o,a,c;if(0===this.outputBits){if(this.rowsDone&&(this.eof=!0),this.eof)return-1;let o,c,l;if(this.err=!1,this.nextLine2D){for(a=0;t[a]=64);do{c+=l=this._getWhiteCode()}while(l>=64)}else{do{o+=l=this._getWhiteCode()}while(l>=64);do{c+=l=this._getBlackCode()}while(l>=64)}for(this._addPixels(t[this.codingPos]+o,s),t[this.codingPos]0?--r:++r;e[r]<=t[this.codingPos]&&e[r]0?--r:++r;e[r]<=t[this.codingPos]&&e[r]0?--r:++r;e[r]<=t[this.codingPos]&&e[r]=64);else do{o+=l=this._getWhiteCode()}while(l>=64);this._addPixels(t[this.codingPos]+o,s),s^=1}let h=!1;if(this.byteAlign&&(this.inputBits&=-8),this.eoblock||this.row!==this.rows-1){if(o=this._lookBits(12),this.eoline)for(;-1!==o&&1!==o;)this._eatBits(1),o=this._lookBits(12);else for(;0===o;)this._eatBits(1),o=this._lookBits(12);1===o?(this._eatBits(12),h=!0):-1===o&&(this.eof=!0)}else this.rowsDone=!0;if(!this.eof&&this.encoding>0&&!this.rowsDone&&(this.nextLine2D=!this._lookBits(1),this._eatBits(1)),this.eoblock&&h&&this.byteAlign){if(o=this._lookBits(12),1===o){if(this._eatBits(12),this.encoding>0&&(this._lookBits(1),this._eatBits(1)),this.encoding>=0)for(a=0;a<4;++a)o=this._lookBits(12),1!==o&&(0,i.info)("bad rtc code: "+o),this._eatBits(12),this.encoding>0&&(this._lookBits(1),this._eatBits(1));this.eof=!0}}else if(this.err&&this.eoline){for(;;){if(o=this._lookBits(13),-1===o)return this.eof=!0,-1;if(o>>1==1)break;this._eatBits(1)}this._eatBits(12),this.encoding>0&&(this._eatBits(1),this.nextLine2D=!(1&o))}t[0]>0?this.outputBits=t[this.codingPos=0]:this.outputBits=t[this.codingPos=1],this.row++}if(this.outputBits>=8)c=1&this.codingPos?0:255,this.outputBits-=8,0===this.outputBits&&t[this.codingPos]o?(c<<=o,1&this.codingPos||(c|=255>>8-o),this.outputBits-=o,o=0):(c<<=this.outputBits,1&this.codingPos||(c|=255>>8-this.outputBits),o-=this.outputBits,this.outputBits=0,t[this.codingPos]0&&(c<<=o,o=0))}while(o)}return this.black&&(c^=255),c},_addPixels(e,t){const n=this.codingLine;let r=this.codingPos;e>n[r]&&(e>this.columns&&((0,i.info)("row is wrong length"),this.err=!0,e=this.columns),1&r^t&&++r,n[r]=e),this.codingPos=r},_addPixelsNeg(e,t){const n=this.codingLine;let r=this.codingPos;if(e>n[r])e>this.columns&&((0,i.info)("row is wrong length"),this.err=!0,e=this.columns),1&r^t&&++r,n[r]=e;else if(e0&&e=r){const t=n[e-r];if(t[0]===i)return this._eatBits(i),[!0,t[1],!0]}}return[!1,0,!1]},_getTwoDimCode(){let t,n=0;if(this.eoblock){if(n=this._lookBits(7),t=e[n],t&&t[0]>0)return this._eatBits(t[0]),t[1]}else{const t=this._findTableCode(1,7,e);if(t[0]&&t[2])return t[1]}return(0,i.info)("Bad two dim code"),-1},_getWhiteCode(){let e,r=0;if(this.eoblock){if(r=this._lookBits(12),-1===r)return 1;if(e=r>>5==0?t[r]:n[r>>3],e[0]>0)return this._eatBits(e[0]),e[1]}else{let e=this._findTableCode(1,9,n);if(e[0])return e[1];if(e=this._findTableCode(11,12,t),e[0])return e[1]}return(0,i.info)("bad white code"),this._eatBits(1),1},_getBlackCode(){let e,t;if(this.eoblock){if(e=this._lookBits(13),-1===e)return 1;if(t=e>>7==0?r[e]:e>>9==0&&e>>7!=0?s[(e>>1)-64]:o[e>>7],t[0]>0)return this._eatBits(t[0]),t[1]}else{let e=this._findTableCode(2,6,o);if(e[0])return e[1];if(e=this._findTableCode(7,12,s,64),e[0])return e[1];if(e=this._findTableCode(10,13,r),e[0])return e[1]}return(0,i.info)("bad black code"),this._eatBits(1),1},_lookBits(e){let t;for(;this.inputBits>16-e;this.inputBuf=this.inputBuf<<8|t,this.inputBits+=8}return this.inputBuf>>this.inputBits-e&65535>>16-e},_eatBits(e){(this.inputBits-=e)<0&&(this.inputBits=0)}},a}();t.CCITTFaxDecoder=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegImage=void 0;var i=n(1),r=n(4);class s extends i.BaseException{constructor(e){super(`JPEG error: ${e}`)}}class o extends i.BaseException{constructor(e,t){super(e),this.scanLines=t}}class a extends i.BaseException{}var c=function(){var e=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);function t({decodeTransform:e=null,colorTransform:t=-1}={}){this._decodeTransform=e,this._colorTransform=t}function n(e,t){for(var n,i,r=0,s=[],o=16;o>0&&!e[o-1];)o--;s.push({children:[],index:0});var a,c=s[0];for(n=0;n0;)c=s.pop();for(c.index++,s.push(c);s.length<=n;)s.push(a={children:[],index:0}),c.children[c.index]=a.children,c=a;r++}n+10)return C--,w>>C&1;if(255===(w=t[n++])){var e=t[n++];if(e){if(220===e&&b){n+=2;const e=(0,r.readUint16)(t,n);if(n+=2,e>0&&e!==l.scanLines)throw new o("Found DNL marker (0xFFDC) while parsing scan data",e)}else if(217===e){if(b){const e=8*A;if(e>0&&e>>7}function T(e){for(var t=e;;){switch(typeof(t=t[P()])){case"number":return t;case"object":continue}throw new s("invalid huffman sequence")}}function I(e){for(var t=0;e>0;)t=t<<1|P(),e--;return t}function k(e){if(1===e)return 1===P()?1:-1;var t=I(e);return t>=1<0)S--;else for(var i=d,r=p;i<=r;){var s=T(t.huffmanTableAC),o=15&s,a=s>>4;if(0!==o){var c=e[i+=a];t.blockData[n+c]=k(o)*(1<>4,0===(i=15&r))c<15?(S=I(c)+(1<>4;if(0!==a){var l=e[s+=c];t.blockData[n+l]=k(a),s++}else{if(c<15)break;s+=16}}};var z,H,X,Y,q=0;for(H=1===N?h[0].blocksPerLine*h[0].blocksPerColumn:v*l.mcusPerColumn;q=65488&&W<=65495))break;n+=2}return(z=u(t,n))&&z.invalid&&((0,i.warn)("decodeScan - unexpected Scan data, current marker is: "+z.invalid),n=z.offset),n-x}function h(e,t,n){var i,r,o,a,c,l,h,f,u,d,p,m,g,b,v,y,x,w=e.quantizationTable,C=e.blockData;if(!w)throw new s("missing required Quantization Table.");for(var P=0;P<64;P+=8)u=C[t+P],d=C[t+P+1],p=C[t+P+2],m=C[t+P+3],g=C[t+P+4],b=C[t+P+5],v=C[t+P+6],y=C[t+P+7],u*=w[P],0!=(d|p|m|g|b|v|y)?(d*=w[P+1],p*=w[P+2],m*=w[P+3],g*=w[P+4],b*=w[P+5],r=(i=(i=5793*u+128>>8)+(r=5793*g+128>>8)+1>>1)-r,x=3784*(o=p)+1567*(a=v*=w[P+6])+128>>8,o=1567*o-3784*a+128>>8,h=(c=(c=2896*(d-(y*=w[P+7]))+128>>8)+(h=b<<4)+1>>1)-h,l=(f=(f=2896*(d+y)+128>>8)+(l=m<<4)+1>>1)-l,a=(i=i+(a=x)+1>>1)-a,o=(r=r+o+1>>1)-o,x=2276*c+3406*f+2048>>12,c=3406*c-2276*f+2048>>12,f=x,x=799*l+4017*h+2048>>12,l=4017*l-799*h+2048>>12,h=x,n[P]=i+f,n[P+7]=i-f,n[P+1]=r+h,n[P+6]=r-h,n[P+2]=o+l,n[P+5]=o-l,n[P+3]=a+c,n[P+4]=a-c):(x=5793*u+512>>10,n[P]=x,n[P+1]=x,n[P+2]=x,n[P+3]=x,n[P+4]=x,n[P+5]=x,n[P+6]=x,n[P+7]=x);for(var T=0;T<8;++T)u=n[T],0!=((d=n[T+8])|(p=n[T+16])|(m=n[T+24])|(g=n[T+32])|(b=n[T+40])|(v=n[T+48])|(y=n[T+56]))?(r=(i=4112+((i=5793*u+2048>>12)+(r=5793*g+2048>>12)+1>>1))-r,x=3784*(o=p)+1567*(a=v)+2048>>12,o=1567*o-3784*a+2048>>12,a=x,h=(c=(c=2896*(d-y)+2048>>12)+(h=b)+1>>1)-h,l=(f=(f=2896*(d+y)+2048>>12)+(l=m)+1>>1)-l,x=2276*c+3406*f+2048>>12,c=3406*c-2276*f+2048>>12,f=x,x=799*l+4017*h+2048>>12,l=4017*l-799*h+2048>>12,(u=(i=i+a+1>>1)+f)<16?u=0:u>=4080?u=255:u>>=4,(d=(r=r+o+1>>1)+(h=x))<16?d=0:d>=4080?d=255:d>>=4,(p=(o=r-o)+l)<16?p=0:p>=4080?p=255:p>>=4,(m=(a=i-a)+c)<16?m=0:m>=4080?m=255:m>>=4,(g=a-c)<16?g=0:g>=4080?g=255:g>>=4,(b=o-l)<16?b=0:b>=4080?b=255:b>>=4,(v=r-h)<16?v=0:v>=4080?v=255:v>>=4,(y=i-f)<16?y=0:y>=4080?y=255:y>>=4,C[t+T]=u,C[t+T+8]=d,C[t+T+16]=p,C[t+T+24]=m,C[t+T+32]=g,C[t+T+40]=b,C[t+T+48]=v,C[t+T+56]=y):(x=(x=5793*u+8192>>14)<-2040?0:x>=2024?255:x+2056>>4,C[t+T]=x,C[t+T+8]=x,C[t+T+16]=x,C[t+T+24]=x,C[t+T+32]=x,C[t+T+40]=x,C[t+T+48]=x,C[t+T+56]=x)}function f(e,t){for(var n=t.blocksPerLine,i=t.blocksPerColumn,r=new Int16Array(64),s=0;s=i)return null;var o=(0,r.readUint16)(e,t);if(o>=65472&&o<=65534)return{invalid:null,marker:o,offset:t};for(var a=(0,r.readUint16)(e,s);!(a>=65472&&a<=65534);){if(++s>=i)return null;a=(0,r.readUint16)(e,s)}return{invalid:o.toString(16),marker:a,offset:s}}return t.prototype={parse(t,{dnlScanLines:c=null}={}){function h(){const e=(0,r.readUint16)(t,g);let n=(g+=2)+e-2;var s=u(t,n,g);s&&s.invalid&&((0,i.warn)("readDataBlock - incorrect length, current marker is: "+s.invalid),n=s.offset);var o=t.subarray(g,n);return g+=o.length,o}function d(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),n=Math.ceil(e.scanLines/8/e.maxV),i=0;i>4==0)for(I=0;I<64;I++)A[e[I]]=t[g++];else{if(O>>4!=1)throw new s("DQT - invalid table spec");for(I=0;I<64;I++)A[e[I]]=(0,r.readUint16)(t,g),g+=2}x[15&O]=A}break;case 65472:case 65473:case 65474:if(p)throw new s("Only single frame JPEGs supported");g+=2,(p={}).extended=65473===P,p.progressive=65474===P,p.precision=t[g++];const f=(0,r.readUint16)(t,g);g+=2,p.scanLines=c||f,p.samplesPerLine=(0,r.readUint16)(t,g),g+=2,p.components=[],p.componentIds={};var E,D=t[g++],M=0,B=0;for(T=0;T>4,R=15&t[g+1];M>4==0?C:w)[15&F]=n(N,H)}break;case 65501:g+=2,m=(0,r.readUint16)(t,g),g+=2;break;case 65498:const Z=1==++y&&!c;g+=2;var X,Y=t[g++],q=[];for(T=0;T>4],X.huffmanTableAC=w[15&W],q.push(X)}var G=t[g++],V=t[g++],J=t[g++];try{var K=l(t,g,p,q,m,G,V,J>>4,15&J,Z);g+=K}catch(e){if(e instanceof o)return(0,i.warn)(`${e.message} -- attempting to re-parse the JPEG image.`),this.parse(t,{dnlScanLines:e.scanLines});if(e instanceof a){(0,i.warn)(`${e.message} -- ignoring the rest of the image data.`);break e}throw e}break;case 65500:g+=4;break;case 65535:255!==t[g]&&g--;break;default:const $=u(t,g-2,g-3);if($&&$.invalid){(0,i.warn)("JpegImage.parse - unexpected data, current marker is: "+$.invalid),g=$.offset;break}if(g>=t.length-1){(0,i.warn)("JpegImage.parse - reached the end of the image data without finding an EOI marker (0xFFD9).");break e}throw new s("JpegImage.parse - unknown marker: "+P.toString(16))}P=(0,r.readUint16)(t,g),g+=2}for(this.width=p.samplesPerLine,this.height=p.scanLines,this.jfif=b,this.adobe=v,this.components=[],T=0;T>8)+C[f+1];return y},get _isColorConversionNeeded(){return this.adobe?!!this.adobe.transformCode:3===this.numComponents?0!==this._colorTransform:1===this._colorTransform},_convertYccToRgb:function(e){for(var t,n,i,r=0,s=e.length;r4)throw new s("Unsupported color mode");var r=this._getLinearizedBlockData(e,t,i);if(1===this.numComponents&&n){for(var o=r.length,a=new Uint8ClampedArray(3*o),c=0,l=0;l0?Math.min(i.xcb,r.PPx-1):Math.min(i.xcb,r.PPx),r.ycb_=n>0?Math.min(i.ycb,r.PPy-1):Math.min(i.ycb,r.PPy),r}function l(e,t,n){var i=1<t.trx0?Math.ceil(t.trx1/i)-Math.floor(t.trx0/i):0,l=t.try1>t.try0?Math.ceil(t.try1/r)-Math.floor(t.try0/r):0,h=c*l;t.precinctParameters={precinctWidth:i,precinctHeight:r,numprecinctswide:c,numprecinctshigh:l,numprecincts:h,precinctWidthInSubband:o,precinctHeightInSubband:a}}function h(e,t,n){var i,r,s,o,a=n.xcb_,c=n.ycb_,l=1<>a,u=t.tby0>>c,d=t.tbx1+l-1>>a,p=t.tby1+h-1>>c,m=t.resolution.precinctParameters,g=[],b=[];for(r=u;rv.cbxMax&&(v.cbxMax=i),rv.cbyMax&&(v.cbyMax=r)):b[o]=v={cbxMin:i,cbyMin:r,cbxMax:i,cbyMax:r},s.precinct=v}}t.codeblockParameters={codeblockWidth:a,codeblockHeight:c,numcodeblockwide:d-f+1,numcodeblockhigh:p-u+1},t.codeblocks=g,t.precincts=b}function f(e,t,n){for(var i=[],r=e.subbands,s=0,o=r.length;se.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[h],n=t.precinctParameters.numprecincts;de.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],n=t.precinctParameters.numprecincts;de.codingStyleParameters.decompositionLevelsCount)){var s=e.resolutions[n],a=s.precinctParameters.numprecincts;if(!(r>=a)){for(;t=0;--g){var b=c.resolutions[g],v=m*b.precinctParameters.precinctWidth,y=m*b.precinctParameters.precinctHeight;f=Math.min(f,v),u=Math.min(u,y),d=Math.max(d,b.precinctParameters.numprecinctswide),p=Math.max(p,b.precinctParameters.numprecinctshigh),h[g]={width:v,height:y},m<<=1}n=Math.min(n,f),i=Math.min(i,u),r=Math.max(r,d),s=Math.max(s,p),o[a]={resolutions:h,minWidth:f,minHeight:u,maxNumWide:d,maxNumHigh:p}}return{components:o,minWidth:n,minHeight:i,maxNumWide:r,maxNumHigh:s}}function y(e){for(var t=e.SIZ,n=e.currentTile.index,i=e.tiles[n],r=t.Csiz,s=0;s>>(a-=e)&(1<0;){var N=C.shift();void 0===(x=N.codeblock).data&&(x.data=[]),x.data.push({data:t,start:n+o,end:n+o+N.dataLength,codingpasses:N.codingpasses}),o+=N.dataLength}}}return o}function w(e,t,n,i,r,o,a,c){for(var l=i.tbx0,h=i.tby0,f=i.tbx1-i.tbx0,u=i.codeblocks,d="H"===i.type.charAt(0)?1:0,p="H"===i.type.charAt(1)?t:0,m=0,g=u.length;m=o?B:B*(1<0?1-b:0));var S=v.subbands[P],A=e[S.type];w(C,y,0,S,d?1:2**(u+A-k)*(1+I/2048),h+k-1,d,f)}m.push({width:y,height:x,items:C})}var E=p.calculate(m,r.tcx0,r.tcy0);return{left:r.tcx0,top:r.tcy0,width:E.width,height:E.height,items:E.items}}function P(e,t){for(var n=e.SIZ.Csiz,i=e.tiles[t],r=0;r>24&255,c>>16&255,c>>8&255,255&c);(0,i.warn)("Unsupported header type "+c+" ("+d+")")}h&&(t+=l)}else this.parseCodestream(e,0,e.length)},parseImageProperties:function(e){for(var t=e.getByte();t>=0;){if(65361===(t<<8|(t=e.getByte()))){e.skip(4);var n=e.getInt32()>>>0,i=e.getInt32()>>>0,r=e.getInt32()>>>0,s=e.getInt32()>>>0;e.skip(16);var a=e.getUint16();return this.width=n-r,this.height=i-s,this.componentsCount=a,void(this.bitsPerComponent=8)}}throw new o("No size marker found in JPX stream")},parseCodestream:function(e,t,s){var c={},l=!1;try{for(var h=t;h+1>5,p=[];u>3,O.mu=0):(O.epsilon=e[u]>>3,O.mu=(7&e[u])<<8|e[u+1],u+=2),p.push(O)}L.SPqcds=p,c.mainHeader?c.QCD=L:(c.currentTile.QCD=L,c.currentTile.QCC=[]);break;case 65373:v=(0,r.readUint16)(e,h);var A,E={};switch(u=h+2,c.SIZ.Csiz<257?A=e[u++]:(A=(0,r.readUint16)(e,u),u+=2),31&(d=e[u++])){case 0:m=8,g=!0;break;case 1:m=16,g=!1;break;case 2:m=16,g=!0;break;default:throw new Error("Invalid SQcd value "+d)}for(E.noQuantization=8===m,E.scalarExpounded=g,E.guardBits=d>>5,p=[];u>3,O.mu=0):(O.epsilon=e[u]>>3,O.mu=(7&e[u])<<8|e[u+1],u+=2),p.push(O);E.SPqcds=p,c.mainHeader?c.QCC[A]=E:c.currentTile.QCC[A]=E;break;case 65362:v=(0,r.readUint16)(e,h);var D={};u=h+2;var M=e[u++];D.entropyCoderWithCustomPrecincts=!!(1&M),D.sopMarkerUsed=!!(2&M),D.ephMarkerUsed=!!(4&M),D.progressionOrder=e[u++],D.layersCount=(0,r.readUint16)(e,u),u+=2,D.multipleComponentTransform=e[u++],D.decompositionLevelsCount=e[u++],D.xcb=2+(15&e[u++]),D.ycb=2+(15&e[u++]);var B=e[u++];if(D.selectiveArithmeticCodingBypass=!!(1&B),D.resetContextProbabilities=!!(2&B),D.terminationOnEachCodingPass=!!(4&B),D.verticallyStripe=!!(8&B),D.predictableTermination=!!(16&B),D.segmentationSymbolUsed=!!(32&B),D.reversibleTransformation=e[u++],D.entropyCoderWithCustomPrecincts){for(var U=[];u>4})}D.precinctsSizes=U}var _=[];if(D.selectiveArithmeticCodingBypass&&_.push("selectiveArithmeticCodingBypass"),D.resetContextProbabilities&&_.push("resetContextProbabilities"),D.terminationOnEachCodingPass&&_.push("terminationOnEachCodingPass"),D.verticallyStripe&&_.push("verticallyStripe"),D.predictableTermination&&_.push("predictableTermination"),_.length>0)throw l=!0,new Error("Unsupported COD options ("+_.join(", ")+")");c.mainHeader?c.COD=D:(c.currentTile.COD=D,c.currentTile.COC=[]);break;case 65424:v=(0,r.readUint16)(e,h),(b={}).index=(0,r.readUint16)(e,h+2),b.length=(0,r.readUint32)(e,h+4),b.dataEnd=b.length+h-2,b.partIndex=e[h+8],b.partsCount=e[h+9],c.mainHeader=!1,0===b.partIndex&&(b.COD=c.COD,b.COC=c.COC.slice(0),b.QCD=c.QCD,b.QCC=c.QCC.slice(0)),c.currentTile=b;break;case 65427:0===(b=c.currentTile).partIndex&&(P(c,b.index),y(c)),x(c,e,h,v=b.dataEnd-h);break;case 65365:case 65367:case 65368:case 65380:v=(0,r.readUint16)(e,h);break;case 65363:throw new Error("Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("Unknown codestream code: "+f.toString(16))}h+=v}}catch(e){if(l||this.failOnCorruptedImage)throw new o(e.message);(0,i.warn)("JPX: Trying to recover from: "+e.message)}this.tiles=function(e){for(var t=e.SIZ,n=e.components,i=t.Csiz,r=[],s=0,o=e.tiles.length;s>2);v[x++]=e+g>>h,v[x++]=e>>h,v[x++]=e+m>>h}else for(u=0;u>h,v[x++]=p-.34413*m-.71414*g>>h,v[x++]=p+1.772*m>>h;if(w)for(u=0,x=3;u>h}else for(a=0;a>h,x+=i}r.push(y)}return r}(c),this.width=c.SIZ.Xsiz-c.SIZ.XOsiz,this.height=c.SIZ.Ysiz-c.SIZ.YOsiz,this.componentsCount=c.SIZ.Csiz}};var T=function(){function e(e,t){var n=(0,r.log2)(Math.max(e,t))+1;this.levels=[];for(var i=0;i>=1,t>>=1,i++}i--,(n=this.levels[i]).items[n.index]=r,this.currentLevel=i,delete this.value},incrementValue:function(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],n=t.items[t.index];return--e<0?(this.value=n,!1):(this.currentLevel=e,(t=this.levels[e]).items[t.index]=n,!0)}},e}(),I=function(){function e(e,t,n){var i=(0,r.log2)(Math.max(e,t))+1;this.levels=[];for(var s=0;sn)return this.currentLevel=i,this.propagateValues(),!1;e>>=1,t>>=1,i++}return this.currentLevel=i-1,!0},incrementValue:function(e){var t=this.levels[this.currentLevel];t.items[t.index]=e+1,this.propagateValues()},propagateValues:function(){for(var e=this.currentLevel,t=this.levels[e],n=t.items[t.index];--e>=0;)(t=this.levels[e]).items[t.index]=n},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],n=t.items[t.index];return t.items[t.index]=255,!(--e<0)&&(this.currentLevel=e,(t=this.levels[e]).items[t.index]=n,!0)}},e}(),k=function(){var e=new Uint8Array([0,5,8,0,3,7,8,0,4,7,8,0,0,0,0,0,1,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8]),t=new Uint8Array([0,3,4,0,5,7,7,0,8,8,8,0,0,0,0,0,1,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8]),n=new Uint8Array([0,1,2,0,1,2,2,0,2,2,2,0,0,0,0,0,3,4,5,0,4,5,5,0,5,5,5,0,0,0,0,0,6,7,7,0,7,7,7,0,7,7,7,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8]);function i(i,r,s,o,a){let c;this.width=i,this.height=r,c="HH"===s?n:"HL"===s?t:e,this.contextLabelTable=c;var l=i*r;let h;this.neighborsSignificance=new Uint8Array(l),this.coefficentsSign=new Uint8Array(l),h=a>14?new Uint32Array(l):a>6?new Uint16Array(l):new Uint8Array(l),this.coefficentsMagnitude=h,this.processingFlags=new Uint8Array(l);var f=new Uint8Array(l);if(0!==o)for(var u=0;u0,c=t+10&&(i=n-s,a&&(r[i-1]+=16),c&&(r[i+1]+=16),r[i]+=4),e+1=n)break;if(o[u]&=-2,!i[u]&&s[u]){var m=c[s[u]];if(e.readBit(a,m)){var g=this.decodeSignBit(p,f,u);r[u]=g,i[u]=1,this.setNeighborsSignificance(p,f,u),o[u]|=2}l[u]++,o[u]|=1}}},decodeSignBit:function(e,t,n){var i,r,s,o,a,c,l=this.width,h=this.height,f=this.coefficentsMagnitude,u=this.coefficentsSign;o=t>0&&0!==f[n-1],t+10&&0!==f[n-l],e+1=0?(a=9+i,c=this.decoder.readBit(this.contexts,a)):(a=9-i,c=1^this.decoder.readBit(this.contexts,a)),c},runMagnitudeRefinementPass:function(){for(var e,t=this.decoder,n=this.width,i=this.height,r=this.coefficentsMagnitude,s=this.neighborsSignificance,o=this.contexts,a=this.bitsDecoded,c=this.processingFlags,l=n*i,h=4*n,f=0;f>1,c=-1.586134342059924,l=-.052980118572961,h=.882911075530934,f=.443506852043971,u=1.230174104914001;for(i=(t|=0)-3,r=a+4;r--;i+=2)e[i]*=.8128930661159609;for(s=f*e[(i=t-2)-1],r=a+3;r--&&(o=f*e[i+1],e[i]=u*e[i]-s-o,r--);i+=2)s=f*e[(i+=2)+1],e[i]=u*e[i]-s-o;for(s=h*e[(i=t-1)-1],r=a+2;r--&&(o=h*e[i+1],e[i]-=s+o,r--);i+=2)s=h*e[(i+=2)+1],e[i]-=s+o;for(s=l*e[(i=t)-1],r=a+1;r--&&(o=l*e[i+1],e[i]-=s+o,r--);i+=2)s=l*e[(i+=2)+1],e[i]-=s+o;if(0!==a)for(s=c*e[(i=t+1)-1],r=a;r--&&(o=c*e[i+1],e[i]-=s+o,r--);i+=2)s=c*e[(i+=2)+1],e[i]-=s+o},e}(),O=function(){function e(){S.call(this)}return e.prototype=Object.create(S.prototype),e.prototype.filter=function(e,t,n){var i,r,s=n>>1;for(i=t|=0,r=s+1;r--;i+=2)e[i]-=e[i-1]+e[i+1]+2>>2;for(i=t+1,r=s;r--;i+=2)e[i]+=e[i-1]+e[i+1]>>1},e}();return t}();t.JpxImage=a}])}));