(function(){}).call(this);var e,t=function(){function t(){this._src=null,this._parser=new e.JpegImage,this.onload=null}return t.prototype={get src(){return this._src},set src(e){this.load(e)},get width(){return this._parser.width},get height(){return this._parser.height},load:function(e){this._src=e, /** * @license * Copyright 2015 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. */ function(e,t){if(0!==e.indexOf("data:")){var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=function(){t(r.response)},r.send(null)}else{for(var n=e.indexOf("base64,")+7,i=atob(e.substring(n)),a=new Uint8Array(i.length),s=i.length-1;s>=0;s--)a[s]=i.charCodeAt(s);t(a.buffer)}}(e,function(e){this.parse(new Uint8Array(e)),this.onload&&this.onload()}.bind(this))},parse:function(e){this._parser.parse(e)},getData:function(e,t){return this._parser.getData(e,t,!1)},copyToImageData:function(e){if(2===this._parser.numComponents||this._parser.numComponents>4)throw new Error("Unsupported amount of components");var t,r,n=e.width,i=e.height,a=n*i*4,s=e.data;if(1!==this._parser.numComponents){var o=this._parser.getData(n,i,!0);for(t=0,r=0;t0&&!e[s-1];)s--;a.push({children:[],index:0});var o,c=a[0];for(r=0;r0;)c=a.pop();for(c.index++,a.push(c);a.length<=r;)a.push(o={children:[],index:0}),c.children[c.index]=o.children,c=o;i++}r+10)return d--,m>>d&1;if(255===(m=t[r++])){var e=t[r++];if(e)throw"unexpected marker: "+(m<<8|e).toString(16)}return d=7,m>>>7}function g(e){for(var t=e;;){if("number"==typeof(t=t[v()]))return t;if("object"!=typeof t)throw"invalid huffman sequence"}}function b(e){for(var t=0;e>0;)t=t<<1|v(),e--;return t}function y(e){if(1===e)return 1===v()?1:-1;var t=b(e);return t>=1<0)w--;else for(var n=o,i=c;n<=i;){var a=g(t.huffmanTableAC),s=15&a,l=a>>4;if(0!==s){var f=e[n+=l];t.blockData[r+f]=y(s)*(1<>4,0==(n=15&i))l<15?(w=b(l)+(1<>4;if(0!==o){var l=e[a+=c];t.blockData[r+l]=y(o),a++}else{if(c<15)break;a+=16}}};var z,O,F,B,q=0;for(O=1===L?a[0].blocksPerLine*a[0].blocksPerColumn:f*i.mcusPerColumn,s||(s=O);q=65488&&z<=65495))break;r+=2}return r-p}function a(e,t,r){for(var n,i,a,s,o,c,l,h,f,u,p,m,d,v,g,b,y,x=e.quantizationTable,w=e.blockData,C=0;C<64;C+=8)f=w[t+C],u=w[t+C+1],p=w[t+C+2],m=w[t+C+3],d=w[t+C+4],v=w[t+C+5],g=w[t+C+6],b=w[t+C+7],f*=x[C],0!=(u|p|m|d|v|g|b)?(u*=x[C+1],p*=x[C+2],m*=x[C+3],d*=x[C+4],v*=x[C+5],i=(n=(n=5793*f+128>>8)+(i=5793*d+128>>8)+1>>1)-i,y=3784*(a=p)+1567*(s=g*=x[C+6])+128>>8,a=1567*a-3784*s+128>>8,l=(o=(o=2896*(u-(b*=x[C+7]))+128>>8)+(l=v<<4)+1>>1)-l,c=(h=(h=2896*(u+b)+128>>8)+(c=m<<4)+1>>1)-c,s=(n=n+(s=y)+1>>1)-s,a=(i=i+a+1>>1)-a,y=2276*o+3406*h+2048>>12,o=3406*o-2276*h+2048>>12,h=y,y=799*c+4017*l+2048>>12,c=4017*c-799*l+2048>>12,l=y,r[C]=n+h,r[C+7]=n-h,r[C+1]=i+l,r[C+6]=i-l,r[C+2]=a+c,r[C+5]=a-c,r[C+3]=s+o,r[C+4]=s-o):(y=5793*f+512>>10,r[C]=y,r[C+1]=y,r[C+2]=y,r[C+3]=y,r[C+4]=y,r[C+5]=y,r[C+6]=y,r[C+7]=y);for(var P=0;P<8;++P)f=r[P],0!=((u=r[P+8])|(p=r[P+16])|(m=r[P+24])|(d=r[P+32])|(v=r[P+40])|(g=r[P+48])|(b=r[P+56]))?(i=(n=4112+((n=5793*f+2048>>12)+(i=5793*d+2048>>12)+1>>1))-i,y=3784*(a=p)+1567*(s=g)+2048>>12,a=1567*a-3784*s+2048>>12,s=y,l=(o=(o=2896*(u-b)+2048>>12)+(l=v)+1>>1)-l,c=(h=(h=2896*(u+b)+2048>>12)+(c=m)+1>>1)-c,y=2276*o+3406*h+2048>>12,o=3406*o-2276*h+2048>>12,h=y,y=799*c+4017*l+2048>>12,c=4017*c-799*l+2048>>12,f=(f=(n=n+s+1>>1)+h)<16?0:f>=4080?255:f>>4,u=(u=(i=i+a+1>>1)+(l=y))<16?0:u>=4080?255:u>>4,p=(p=(a=i-a)+c)<16?0:p>=4080?255:p>>4,m=(m=(s=n-s)+o)<16?0:m>=4080?255:m>>4,d=(d=s-o)<16?0:d>=4080?255:d>>4,v=(v=a-c)<16?0:v>=4080?255:v>>4,g=(g=i-l)<16?0:g>=4080?255:g>>4,b=(b=n-h)<16?0:b>=4080?255:b>>4,w[t+P]=f,w[t+P+8]=u,w[t+P+16]=p,w[t+P+24]=m,w[t+P+32]=d,w[t+P+40]=v,w[t+P+48]=g,w[t+P+56]=b):(y=(y=5793*f+8192>>14)<-2040?0:y>=2024?255:y+2056>>4,w[t+P]=y,w[t+P+8]=y,w[t+P+16]=y,w[t+P+24]=y,w[t+P+32]=y,w[t+P+40]=y,w[t+P+48]=y,w[t+P+56]=y)}function s(e,t){for(var r=t.blocksPerLine,i=t.blocksPerColumn,s=new Int16Array(64),o=0;o=255?255:e}return t.prototype={parse:function(t){function n(){var e=t[f]<<8|t[f+1];return f+=2,e}function a(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),r=Math.ceil(e.scanLines/8/e.maxV),n=0;n>4==0)for(y=0;y<64;y++)k[e[y]]=t[f++];else{if(P>>4!=1)throw"DQT: invalid table spec";for(y=0;y<64;y++)k[e[y]]=n()}m[15&P]=k}break;case 65472:case 65473:case 65474:if(o)throw"Only single frame JPEGs supported";n(),(o={}).extended=65473===g,o.progressive=65474===g,o.precision=t[f++],o.scanLines=n(),o.samplesPerLine=n(),o.components=[],o.componentIds={};var I,M=t[f++],S=0,T=0;for(b=0;b>4,D=15&t[f+1];S>4==0?v:d)[15&O]=r(F,q)}break;case 65501:n(),c=n();break;case 65498:n();var E,R=t[f++],U=[];for(b=0;b>4],E.huffmanTableAC=d[15&_],U.push(E)}var J=t[f++],H=t[f++],Y=t[f++],G=i(t,f,o,U,c,J,H,Y>>4,15&Y);f+=G;break;case 65535:255!==t[f]&&f--;break;default:if(255===t[f-3]&&t[f-2]>=192&&t[f-2]<=254){f-=3;break}throw"unknown JPEG marker "+g.toString(16)}g=n()}for(this.width=o.samplesPerLine,this.height=o.scanLines,this.jfif=u,this.adobe=p,this.components=[],b=0;b>8)+x[h+1];return b},_isColorConversionNeeded:function(){return!(!this.adobe||!this.adobe.transformCode)||3===this.numComponents},_convertYccToRgb:function(e){for(var t,r,n,i=0,a=e.length;i=0?255:l<=s?0:255+l*(1/255/255)|0,e[a++]=h>=0?255:h<=s?0:255+h*(1/255/255)|0,e[a++]=f>=0?255:f<=s?0:255+f*(1/255/255)|0}return e},getData:function(e,t,r){if(this.numComponents>4)throw"Unsupported color mode";var n=this._getLinearizedBlockData(e,t);if(3===this.numComponents)return this._convertYccToRgb(n);if(4===this.numComponents){if(this._isColorConversionNeeded())return r?this._convertYcckToRgb(n):this._convertYcckToCmyk(n);if(r)return this._convertCmykToRgb(n)}return n}},t}(),r=function(){var e=[{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}];function t(e,t,r){this.data=e,this.bp=t,this.dataEnd=r,this.chigh=e[t],this.clow=0,this.byteIn(),this.chigh=this.chigh<<7&65535|this.clow>>9&127,this.clow=this.clow<<7&65535,this.ct-=7,this.a=32768}return t.prototype={byteIn:function(){var e=this.data,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:function(t,r){var n,i=t[r]>>1,a=1&t[r],s=e[i],o=s.qe,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,t[r]=i<<1|a,n}},t}(),n=function(){var e={LL:0,LH:1,HL:1,HH:2};function t(){this.failOnCorruptedImage=!1}function n(e,t){e.x0=Math.ceil(t.XOsiz/e.XRsiz),e.x1=Math.ceil(t.Xsiz/e.XRsiz),e.y0=Math.ceil(t.YOsiz/e.YRsiz),e.y1=Math.ceil(t.Ysiz/e.YRsiz),e.width=e.x1-e.x0,e.height=e.y1-e.y0}function i(e,t){for(var r,n=e.SIZ,i=[],a=Math.ceil((n.Xsiz-n.XTOsiz)/n.XTsiz),s=Math.ceil((n.Ysiz-n.YTOsiz)/n.YTsiz),o=0;o0?Math.min(n.xcb,i.PPx-1):Math.min(n.xcb,i.PPx),i.ycb_=r>0?Math.min(n.ycb,i.PPy-1):Math.min(n.ycb,i.PPy),i}function l(e,t,r){var n=1<t.trx0?Math.ceil(t.trx1/n)-Math.floor(t.trx0/n):0,l=t.try1>t.try0?Math.ceil(t.try1/i)-Math.floor(t.try0/i):0,h=c*l;t.precinctParameters={precinctWidth:n,precinctHeight:i,numprecinctswide:c,numprecinctshigh:l,numprecincts:h,precinctWidthInSubband:s,precinctHeightInSubband:o}}function h(e,t,r){var n,i,a,s,o=r.xcb_,c=r.ycb_,l=1<>o,u=t.tby0>>c,p=t.tbx1+l-1>>o,m=t.tby1+h-1>>c,d=t.resolution.precinctParameters,v=[],g=[];for(i=u;ib.cbxMax&&(b.cbxMax=n),ib.cbyMax&&(b.cbyMax=i)):g[s]=b={cbxMin:n,cbyMin:i,cbxMax:n,cbyMax:i},a.precinct=b}t.codeblockParameters={codeblockWidth:o,codeblockHeight:c,numcodeblockwide:p-f+1,numcodeblockhigh:m-u+1},t.codeblocks=v,t.precincts=g}function p(e,t,r){for(var n=[],i=e.subbands,a=0,s=i.length;ae.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],r=t.precinctParameters.numprecincts;fe.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[c],r=t.precinctParameters.numprecincts;fe.codingStyleParameters.decompositionLevelsCount)){var a=e.resolutions[r],s=a.precinctParameters.numprecincts;if(!(i>=s)){for(;t=0;--v){var g=c.resolutions[v],b=d*g.precinctParameters.precinctWidth,y=d*g.precinctParameters.precinctHeight;f=Math.min(f,b),u=Math.min(u,y),p=Math.max(p,g.precinctParameters.numprecinctswide),m=Math.max(m,g.precinctParameters.numprecinctshigh),h[v]={width:b,height:y},d<<=1}r=Math.min(r,f),n=Math.min(n,u),i=Math.max(i,p),a=Math.max(a,m),s[o]={resolutions:h,minWidth:f,minHeight:u,maxNumWide:p,maxNumHigh:m}}return{components:s,minWidth:r,minHeight:n,maxNumWide:i,maxNumHigh:a}}function w(e){for(var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=t.Csiz,a=0;a>>(o-=e)&(1<0;){var U=C.shift();void 0===(x=U.codeblock).data&&(x.data=[]),x.data.push({data:t,start:r+s,end:r+s+U.dataLength,codingpasses:U.codingpasses}),s+=U.dataLength}}}return s}function P(e,t,n,i,a,s,o,c){for(var l=i.tbx0,h=i.tby0,f=i.tbx1-i.tbx0,u=i.codeblocks,p="H"===i.type.charAt(0)?1:0,m="H"===i.type.charAt(1)?t:0,d=0,v=u.length;d=s?F:F*(1<0?1-g:0));var S=b.subbands[C],T=e[S.type];P(w,y,0,S,p?1:Math.pow(2,u+T-M)*(1+I/2048),h+M-1,p,f)}d.push({width:y,height:x,items:w})}var A=m.calculate(d,i.tcx0,i.tcy0);return{left:i.tcx0,top:i.tcy0,width:A.width,height:A.height,items:A.items}}function I(e,t){for(var r=e.SIZ.Csiz,n=e.tiles[t],i=0;i>24&255,a>>16&255,a>>8&255,255&a);f("Unsupported header type "+a+" ("+m+")")}l&&(t+=s)}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 r=e.getInt32()>>>0,n=e.getInt32()>>>0,i=e.getInt32()>>>0,a=e.getInt32()>>>0;e.skip(16);var s=e.getUint16();return this.width=r-i,this.height=n-a,this.componentsCount=s,void(this.bitsPerComponent=8)}throw new Error("JPX Error: No size marker found in JPX stream")},parseCodestream:function(e,t,r){var a={};try{for(var s=!1,l=t;l+1>5,m=[];u>3,A.mu=0):(A.epsilon=e[u]>>3,A.mu=(7&e[u])<<8|e[u+1],u+=2),m.push(A)}T.SPqcds=m,a.mainHeader?a.QCD=T:(a.currentTile.QCD=T,a.currentTile.QCC=[]);break;case 65373:b=o(e,l);var D,L={};switch(u=l+2,a.SIZ.Csiz<257?D=e[u++]:(D=o(e,u),u+=2),31&(p=e[u++])){case 0:d=8,v=!0;break;case 1:d=16,v=!1;break;case 2:d=16,v=!0;break;default:throw new Error("JPX Error: Invalid SQcd value "+p)}for(L.noQuantization=8===d,L.scalarExpounded=v,L.guardBits=p>>5,m=[];u>3,A.mu=0):(A.epsilon=e[u]>>3,A.mu=(7&e[u])<<8|e[u+1],u+=2),m.push(A);L.SPqcds=m,a.mainHeader?a.QCC[D]=L:a.currentTile.QCC[D]=L;break;case 65362:b=o(e,l);var z={};u=l+2;var O=e[u++];z.entropyCoderWithCustomPrecincts=!!(1&O),z.sopMarkerUsed=!!(2&O),z.ephMarkerUsed=!!(4&O),z.progressionOrder=e[u++],z.layersCount=o(e,u),u+=2,z.multipleComponentTransform=e[u++],z.decompositionLevelsCount=e[u++],z.xcb=2+(15&e[u++]),z.ycb=2+(15&e[u++]);var F=e[u++];if(z.selectiveArithmeticCodingBypass=!!(1&F),z.resetContextProbabilities=!!(2&F),z.terminationOnEachCodingPass=!!(4&F),z.verticalyStripe=!!(8&F),z.predictableTermination=!!(16&F),z.segmentationSymbolUsed=!!(32&F),z.reversibleTransformation=e[u++],z.entropyCoderWithCustomPrecincts){for(var B=[];u>4})}z.precinctsSizes=B}var E=[];if(z.selectiveArithmeticCodingBypass&&E.push("selectiveArithmeticCodingBypass"),z.resetContextProbabilities&&E.push("resetContextProbabilities"),z.terminationOnEachCodingPass&&E.push("terminationOnEachCodingPass"),z.verticalyStripe&&E.push("verticalyStripe"),z.predictableTermination&&E.push("predictableTermination"),E.length>0)throw s=!0,new Error("JPX Error: Unsupported COD options ("+E.join(", ")+")");a.mainHeader?a.COD=z:(a.currentTile.COD=z,a.currentTile.COC=[]);break;case 65424:b=o(e,l),(g={}).index=o(e,l+2),g.length=c(e,l+4),g.dataEnd=g.length+l-2,g.partIndex=e[l+8],g.partsCount=e[l+9],a.mainHeader=!1,0===g.partIndex&&(g.COD=a.COD,g.COC=a.COC.slice(0),g.QCD=a.QCD,g.QCC=a.QCC.slice(0)),a.currentTile=g;break;case 65427:0===(g=a.currentTile).partIndex&&(I(a,g.index),w(a)),C(a,e,l,b=g.dataEnd-l);break;case 65365:case 65367:case 65368:case 65380:b=o(e,l);break;case 65363:throw new Error("JPX Error: Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("JPX Error: Unknown codestream code: "+h.toString(16))}l+=b}}catch(e){if(s||this.failOnCorruptedImage)throw e;f("Trying to recover from "+e.message)}this.tiles=function(e){for(var t=e.SIZ,r=e.components,n=t.Csiz,i=[],a=0,s=e.tiles.length;a>2))+y,C=w+b,S[A++]=x<=0?0:x>=u?255:x>>h,S[A++]=w<=0?0:w>=u?255:w>>h,S[A++]=C<=0?0:C>=u?255:C>>h;else for(d=0;d=u?255:x>>h,S[A++]=w<=0?0:w>=u?255:w>>h,S[A++]=C<=0?0:C>=u?255:C>>h;if(D)for(d=0,A=3;d=m?255:P+f>>h}else for(o=0;o=u?255:I+f>>h,A+=n}i.push(T)}return i}(a),this.width=a.SIZ.Xsiz-a.SIZ.XOsiz,this.height=a.SIZ.Ysiz-a.SIZ.YOsiz,this.componentsCount=a.SIZ.Csiz}};var M=function(){function e(e,t){var r=a(Math.max(e,t))+1;this.levels=[];for(var n=0;n>=1,t>>=1,n++}n--,(r=this.levels[n]).items[r.index]=i,this.currentLevel=n,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],r=t.items[t.index];return--e<0?(this.value=r,!1):(this.currentLevel=e,(t=this.levels[e]).items[t.index]=r,!0)}},e}(),S=function(){function e(e,t,r){var n=a(Math.max(e,t))+1;this.levels=[];for(var i=0;ir)return this.currentLevel=n,this.propagateValues(),!1;e>>=1,t>>=1,n++}return this.currentLevel=n-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],r=t.items[t.index];--e>=0;)(t=this.levels[e]).items[t.index]=r},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];return t.items[t.index]=255,!(--e<0||(this.currentLevel=e,(t=this.levels[e]).items[t.index]=r,0))}},e}(),T=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]),r=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 n(n,i,a,s,o){this.width=n,this.height=i,this.contextLabelTable="HH"===a?r:"HL"===a?t:e;var c=n*i;this.neighborsSignificance=new Uint8Array(c),this.coefficentsSign=new Uint8Array(c),this.coefficentsMagnitude=o>14?new Uint32Array(c):o>6?new Uint16Array(c):new Uint8Array(c),this.processingFlags=new Uint8Array(c);var l=new Uint8Array(c);if(0!==s)for(var h=0;h0,c=t+10&&(n=r-a,o&&(i[n-1]+=16),c&&(i[n+1]+=16),i[n]+=4),e+1=r)break;if(s[u]&=-2,!n[u]&&a[u]){var d=c[a[u]];if(e.readBit(o,d)){var v=this.decodeSignBit(m,f,u);i[u]=v,n[u]=1,this.setNeighborsSignificance(m,f,u),s[u]|=2}l[u]++,s[u]|=1}}},decodeSignBit:function(e,t,r){var n,i,a,s,o,c,l=this.width,h=this.height,f=this.coefficentsMagnitude,u=this.coefficentsSign;s=t>0&&0!==f[r-1],t+10&&0!==f[r-l],e+1=0?(o=9+n,c=this.decoder.readBit(this.contexts,o)):(o=9-n,c=1^this.decoder.readBit(this.contexts,o)),c},runMagnitudeRefinementPass:function(){for(var e,t=this.decoder,r=this.width,n=this.height,i=this.coefficentsMagnitude,a=this.neighborsSignificance,s=this.contexts,o=this.bitsDecoded,c=this.processingFlags,l=r*n,h=4*r,f=0;f>1,c=-1.586134342059924,l=-.052980118572961,h=.882911075530934,f=.443506852043971,u=1.230174104914001;for(n=(t|=0)-3,i=o+4;i--;n+=2)e[n]*=.8128930661159609;for(a=f*e[(n=t-2)-1],i=o+3;i--&&(s=f*e[n+1],e[n]=u*e[n]-a-s,i--);n+=2)a=f*e[(n+=2)+1],e[n]=u*e[n]-a-s;for(a=h*e[(n=t-1)-1],i=o+2;i--&&(s=h*e[n+1],e[n]-=a+s,i--);n+=2)a=h*e[(n+=2)+1],e[n]-=a+s;for(a=l*e[(n=t)-1],i=o+1;i--&&(s=l*e[n+1],e[n]-=a+s,i--);n+=2)a=l*e[(n+=2)+1],e[n]-=a+s;if(0!==o)for(a=c*e[(n=t+1)-1],i=o;i--&&(s=c*e[n+1],e[n]-=a+s,i--);n+=2)a=c*e[(n+=2)+1],e[n]-=a+s},e}(),L=function(){function e(){A.call(this)}return e.prototype=Object.create(A.prototype),e.prototype.filter=function(e,t,r){var n,i,a=r>>1;for(n=t|=0,i=a+1;i--;n+=2)e[n]-=e[n-1]+e[n+1]+2>>2;for(n=t+1,i=a;i--;n+=2)e[n]+=e[n-1]+e[n+1]>>1},e}();return t}(),i=function(){function e(){}function t(e,t,r){this.data=e,this.start=t,this.end=r}function n(e,t,r){var n=e.getContexts(t),i=1;function a(e){for(var t=0,a=0;a>>0}var s=a(1),o=a(1)?a(1)?a(1)?a(1)?a(1)?a(32)+4436:a(12)+340:a(8)+84:a(6)+20:a(4)+4:a(2);return 0===s?o:o>0?-o:null}function i(e,t,r){for(var n=e.getContexts("IAID"),i=1,a=0;a=z&&S=O)for(_=_<<1&y,p=0;p=0&&A=0&&(D=E[T][A])&&(_|=D<=e?O<<=1:O=O<<1|k[L][z];for(f=0;f=C||z<0||z>=w?O<<=1:O=O<<1|n[L][z];var F=I.readBit(M,O);A[D]=F}}return k}function b(e,t,r,a,s,o,c,l,f,u,p,m,d,v,b,y,x){e&&h("JBIG2 error: huffman is not supported");var w,C,P=[];for(w=0;w>1)+n(M,"IARDX",I),(E>>1)+n(M,"IARDY",I),!1,y,x)}var R,U,X,_=D-(1&m?0:B),J=A-(2&m?F:0);if(u){for(R=0;R>5&7,u=[31&s],p=t+6;if(7===s){l=536870911&c(e,p-1),p+=3;var m=l+7>>3;for(u[0]=e[p++];--m>0;)u.push(e[p++])}else 5!==s&&6!==s||h("JBIG2 error: invalid referred-to flags");r.retainBits=u;var d,v,g=r.number<=256?1:r.number<=65536?2:4,b=[];for(d=0;d>>24&255,k[3]=x.height>>16&255,k[4]=x.height>>8&255,k[5]=255&x.height,d=p,v=e.length;d>2&3,m.huffmanDWSelector=d>>4&3,m.bitmapSizeSelector=d>>6&1,m.aggregationInstancesSelector=d>>7&1,m.bitmapCodingContextUsed=!!(256&d),m.bitmapCodingContextRetained=!!(512&d),m.template=d>>10&3,m.refinementTemplate=d>>12&1,u+=2,!m.huffman){for(a=0===m.template?4:1,n=[],i=0;i>2&3),v.referenceCorner=g>>4&3,v.transposed=!!(64&g),v.combinationOperator=g>>7&3,v.defaultPixelValue=g>>9&1,v.dsOffset=g<<17>>27,v.refinementTemplate=g>>15&1,v.huffman){var b=o(f,u);u+=2,v.huffmanFS=3&b,v.huffmanDS=b>>2&3,v.huffmanDT=b>>4&3,v.huffmanRefinementDW=b>>6&3,v.huffmanRefinementDH=b>>8&3,v.huffmanRefinementDX=b>>10&3,v.huffmanRefinementDY=b>>12&3,v.huffmanRefinementSizeSelector=!!(14&b)}if(v.refinement&&!v.refinementTemplate){for(n=[],i=0;i<2;i++)n.push({x:s(f,u),y:s(f,u+1)}),u+=2;v.refinementAt=n}v.numberOfSymbolInstances=c(f,u),u+=4,v.huffman&&h("JBIG2 error: huffman is not supported"),r=[v,l.referredTo,f,u,p];break;case 38:case 39:var y={};y.info=w(f,u),u+=C;var x=f[u++];if(y.mmr=!!(1&x),y.template=x>>1&3,y.prediction=!!(8&x),!y.mmr){for(a=0===y.template?4:1,n=[],i=0;i>2&1,P.combinationOperator=k>>3&3,P.requiresBuffer=!!(32&k),P.combinationOperatorOverride=!!(64&k),r=[P];break;case 49:case 50:case 51:case 62:break;default:h("JBIG2 error: segment type "+l.typeName+"("+l.type+") is not implemented")}var I="on"+l.typeName;I in t&&t[I].apply(t,r)}function k(e,t){for(var r=0,n=e.length;r>3,r=new Uint8Array(t*e.height);if(e.defaultPixelValue)for(var n=0,i=r.length;n>3,f=s.combinationOperatorOverride?e.combinationOperator:s.combinationOperator,u=this.buffer,p=128>>(7&e.x),m=e.y*l+(e.x>>3);switch(f){case 0:for(r=0;r>=1)||(i=128,a++);m+=l}break;case 2:for(r=0;r>=1)||(i=128,a++);m+=l}break;default:h("JBIG2 error: operator "+f+" is not supported")}},onImmediateGenericRegion:function(e,r,n,i){var a=e.info,s=new t(r,n,i),o=v(e.mmr,a.width,a.height,e.template,e.prediction,null,e.at,s);this.drawBitmap(a,o)},onImmediateLosslessGenericRegion:function(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function(e,r,s,o,c,l){e.huffman&&h("JBIG2 error: huffman is not supported");var f=this.symbols;f||(this.symbols=f={});for(var u=[],p=0,m=s.length;p1)k=b(e,t,P,y,0,M,1,r.concat(d),x,0,0,1,0,0,u,p,m);else{var S=i(C,w,x),T=n(C,"IARDX",w),A=n(C,"IARDY",w);k=g(P,y,u,St;)t<<=1,r++;return r}function s(e,t){return e[t]<<24>>24}function o(e,t){return e[t]<<8|e[t+1]}function c(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1}),r}var h=function(){throw console.error.apply(console,arguments),new Error("PDFJS error: "+arguments[0])},f=function(){console.warn.apply(console,arguments)},u=function(){console.info.apply(console,arguments)};i.prototype.parse=function(e){var t=0,r=e.length;151===e[t]&&74===e[t+1]&&66===e[t+2]&&50===e[t+3]&&13===e[t+4]&&10===e[t+5]&&26===e[t+6]&&10===e[t+7]||h("JBIG2 error: invalid header");var n={};t+=8;var i=e[t++];n.randomAccess=!(1&i),2&i||(n.numberOfPages=c(e,t),t+=4);for(var a=this.parseChunks([{data:e,start:t,end:r}]),s=a.currentPageInfo.width,o=a.currentPageInfo.height,l=a.buffer,f=(e=new Uint8Array(s*o),0),u=0,p=0;p>=1;this.width=s,this.height=o,this.data=e},e.JpegImage=t,e.JpxImage=n,e.Jbig2Image=i}(e||(e={}));var r=e.JpegImage,n=e.JpxImage,i=e.Jbig2Image;