0;)A[d++]=k}h=this.generateHuffmanTable(A.subarray(0,f)),u=this.generateHuffmanTable(A.subarray(f,w))}else l("Unknown block type in flate stream");e=this.buffer;for(var C=e?e.length:0,I=this.bufferLength;;){var T=this.getCode(h);if(T<256)I+1>=C&&(e=this.ensureBuffer(I+1),C=e.length),e[I++]=T;else{if(256===T)return void(this.bufferLength=I);T-=257,T=a[T];var R=T>>16;R>0&&(R=this.getBits(R)),s=(65535&T)+R,T=this.getCode(u),T=r[T],R=T>>16,R>0&&(R=this.getBits(R));var P=(65535&T)+R;I+s>=C&&(e=this.ensureBuffer(I+s),C=e.length);for(var L=0;L 0?Math.min(r.xcb,i.PPx-1):Math.min(r.xcb,i.PPx),i.ycb_=a>0?Math.min(r.ycb,i.PPy-1):Math.min(r.ycb,i.PPy),i}function i(e,t,a){var r=1< =0?o[i]=r:o[i]=0;else if(c)for(i in t)o[i]=t[i];else for(n=D,i=0;i >=1}else{var b=0;for(r=0,d=0,a=o;d>v;l[d]=y<0?0:y>u?u:y,r&=(1< >2&3,g.huffmanDWSelector=p>>4&3,g.bitmapSizeSelector=p>>6&1,g.aggregationInstancesSelector=p>>7&1,g.bitmapCodingContextUsed=!!(256&p),g.bitmapCodingContextRetained=!!(512&p),g.template=p>>10&3,g.refinementTemplate=p>>12&1,d+=2,!g.huffman){for(s=0===g.template?4:1,r=[],i=0;i15)&&l("Unsupported predictor: "+r),2===r?this.readBlock=this.readBlockTiff:this.readBlock=this.readBlockPng,this.str=e,this.dict=e.dict;var i=this.colors=a.get("Colors")||1,n=this.bits=a.get("BitsPerComponent")||8,s=this.columns=a.get("Columns")||1;return this.pixBytes=i*n+7>>3,this.rowBytes=s*i*n+7>>3,S.call(this,t),this}return e.prototype=Object.create(S.prototype),e.prototype.readBlockTiff=function(){var e=this.rowBytes,t=this.bufferLength,a=this.ensureBuffer(t+e),r=this.bits,i=this.colors,n=this.str.getBytes(e);if(this.eof=!n.length,!this.eof){var s,o=0,c=0,l=0,h=0,u=t;if(1===r&&1===i)for(s=0;s=0;--s)n[o+s]=255&l,l>>=8}},e}(),B=function(){function e(e,t){this.str=e,this.dict=e.dict,this.firstDigit=-1,t&&(t*=.5),S.call(this,t)}return e.prototype=Object.create(S.prototype),e.prototype.readBlock=function(){var e=8e3,t=this.str.getBytes(e);if(!t.length)return void(this.eof=!0);for(var a=t.length+1>>1,r=this.ensureBuffer(this.bufferLength+a),i=this.bufferLength,n=this.firstDigit,s=0,o=t.length;s8?Math.pow((e+16)/116,3):e*w}function l(e,t,a){if(0===e[0]&&0===e[1]&&0===e[2])return a[0]=t[0],a[1]=t[1],void(a[2]=t[2]);var r=c(0),i=r,n=c(e[0]),s=r,o=c(e[1]),l=r,h=c(e[2]),u=(1-i)/(1-n),d=1-u,f=(1-s)/(1-o),g=1-f,p=(1-l)/(1-h),m=1-p;a[0]=t[0]*u+d,a[1]=t[1]*f+g,a[2]=t[2]*p+m}function h(e,r,i){if(1===e[0]&&1===e[2])return i[0]=r[0],i[1]=r[1],void(i[2]=r[2]);var n=i;t(f,r,n);var s=v;a(e,n,s),t(g,s,i)}function u(e,a,i){var n=i;t(f,a,n);var s=v;r(e,n,s),t(g,s,i)}function d(e,a,r,s,o,c){var d=n(0,1,a[r]*c),f=n(0,1,a[r+1]*c),g=n(0,1,a[r+2]*c),m=Math.pow(d,e.GR),v=Math.pow(f,e.GG),w=Math.pow(g,e.GB),A=e.MXA*m+e.MXB*v+e.MXC*w,x=e.MYA*m+e.MYB*v+e.MYC*w,S=e.MZA*m+e.MZB*v+e.MZC*w,C=y;C[0]=A,C[1]=x,C[2]=S;var I=k;h(e.whitePoint,C,I);var T=y;l(e.blackPoint,I,T);var R=k;u(b,T,R);var P=y;t(p,R,P);var L=i(P[0]),E=i(P[1]),O=i(P[2]);s[o]=Math.round(255*L),s[o+1]=Math.round(255*E),s[o+2]=Math.round(255*O)}var f=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]),g=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]),p=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]),b=new Float32Array([1,1,1]),v=new Float32Array(3),y=new Float32Array(3),k=new Float32Array(3),w=Math.pow(24/116,3)/8;return e.prototype={getRgb:function(e,t){var a=new Uint8Array(3);return this.getRgbItem(e,t,a,0),a},getRgbItem:function(e,t,a,r){d(this,e,t,a,r,1)},getRgbBuffer:function(e,t,a,r,i,n,s){for(var o=1/((1<>")&&!w(this.buf1);)if(S(this.buf1)){var i=this.buf1.name;if(this.shift(),w(this.buf1))break;r.set(i,this.getObj(e))}else h("Malformed dictionary: key must be a name object"),this.shift();return w(this.buf1)?(this.recoveryMode||l("End of file inside dictionary"),r):A(this.buf2,"stream")?this.allowStreams?this.makeStream(r,e):r:(this.shift(),r);default:return t}if(d(t)){var n=t;if(d(this.buf1)&&A(this.buf2,"R")){var s=new k(n,this.buf1);return this.shift(),this.shift(),s}return n}if(g(t)){var o=t;return e&&(o=e.decryptString(o)),o}return t},findDefaultInlineStreamEnd:function(e){for(var t,a,r,i,n=69,s=73,o=32,l=10,h=13,u=e.pos,d=0;(t=e.getByte())!==-1;)if(0===d)d=t===n?1:0;else if(1===d)d=t===s?2:0;else if(c(2===d),t===o||t===l||t===h){for(r=5,i=e.peekBytes(r),a=0;ay&&(h=y)),m[c]=h}u>0&&(u--,l[f]=m),r.set(m,i)}}}}(),m=function(){function e(e){this.stack=e?Array.prototype.slice.call(e,0):[]}var t=100;return e.prototype={push:function(e){this.stack.length>=t&&o("PostScript function stack overflow."),this.stack.push(e)},pop:function(){return this.stack.length<=0&&o("PostScript function stack underflow."),this.stack.pop()},copy:function(e){this.stack.length+e>=t&&o("PostScript function stack overflow.");for(var a=this.stack,r=a.length-e,i=e-1;i>=0;i--,r++)a.push(a[r])},index:function(e){this.push(this.stack[this.stack.length-e-1])},roll:function(e,t){var a,r,i,n=this.stack,s=n.length-e,o=n.length-1,c=s+(t-Math.floor(t/e)*e);for(a=s,r=o;ae.min&&(s.unshift("Math.max(",r,", "),s.push(")")),n126||91===l||93===l||40===l||41===l||123===l||125===l||60===l||62===l||47===l||37===l||35===l)?s[o]=95:s[o]=l}t.push(c(s))}return t},parseStringIndex:function(e){for(var t=new S,a=0,r=e.count;a=-107&&e<=107?t=[e+139]:e>=108&&e<=1131?(e-=108,t=[(e>>8)+247,255&e]):e>=-1131&&e<=-108?(e=-e-108,t=[(e>>8)+251,255&e]):t=e>=-32768&&e<=32767?[28,e>>8&255,255&e]:[29,e>>24&255,e>>16&255,e>>8&255,255&e],t},compileHeader:function(e){return[e.major,e.minor,e.hdrSize,e.offSize]},compileNameIndex:function(e){for(var t=new C,a=0,r=e.length;a=n;--r)if(f[r]!==g){g=0;break}d-=g,l[l.length-1]=f.subarray(0,16-g)}}var p=new Uint8Array(d);for(r=0,i=0,n=l.length;r=n;--r)if(f[r]!==g){g=0;break}d-=g,l[l.length-1]=f.subarray(0,16-g)}}var p=new Uint8Array(d);for(r=0,i=0,n=l.length;r=a?this.flush():this.fnArray.length>=r&&(e===S.restore||e===S.endText)&&this.flush())},addDependency:function(e){e in this.dependencies||(this.dependencies[e]=!0,this.addOp(S.dependency,[e]))},addDependencies:function(e){for(var t in e)this.addDependency(t)},addOpList:function(e){I.extendObj(this.dependencies,e.dependencies);for(var t=0,a=e.length;ts&&L("Command "+n+": expected [0,"+s+"] args, but received "+o+" args.");else{if(o!==s){for(var c=this.nonProcessedArgs;o>s;)c.push(t.shift()),o--;for(;or&&(p=Math.max(p,v),y+=b+2*i,v=0,b=0),m.push({transform:k,x:v,y:y,w:w.width,h:w.height}),v+=w.width+2*i,b=Math.max(b,w.height)}var A=Math.max(p,v)+i,C=y+b+i,I=new Uint8Array(A*C*4),T=A<<2;for(g=0;ge.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[h],a=t.precinctParameters.numprecincts;de.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],a=t.precinctParameters.numprecincts;de.codingStyleParameters.decompositionLevelsCount)){var n=e.resolutions[a],s=n.precinctParameters.numprecincts;if(!(i>=s)){for(;t>>d&(1<>2),k=w+y,A=w+v,T[P++]=k<=0?0:k>=d?255:k>>h,T[P++]=w<=0?0:w>=d?255:w>>h,T[P++]=A<=0?0:A>=d?255:A>>h;else for(p=0;p=a)break;if(s[p]&=h,!r[p]&&n[p]){var v=c[n[p]],y=e.readBit(o,v);if(y){var k=this.decodeSignBit(b,g,p);i[p]=k,r[p]=1,this.setNeighborsSignificance(b,g,p),s[p]|=d}l[p]++,s[p]|=u}}},decodeSignBit:function(e,t,a){var r,i,n,s,o,c,l=this.width,h=this.height,u=this.coefficentsMagnitude,d=this.coefficentsSign;s=t>0&&0!==u[a-1],t+1>16,c+=2;break;case 2:h-=e[c++];break;case 18:h+=e[c++]}C[k].x=h}for(k=0;k>16,c+=2;break;case 4:u-=e[c++];break;case 36:u+=e[c++]}C[k].y=u}var T=0;for(c=0;c>1;en)){i.pos=m;var b=p.name;if(p.encoding){for(var v="",y=0,w=p.length;y0&&M(Oe,-1,-1)&&(ce[oe]=Oe,Le=!0)}Le||(ce[oe]=0)}}}else if(0===ye&&0===we)for(W=0;W
>>0}var i=e.getContexts(t),n=1,s=r(1),o=r(1)?r(1)?r(1)?r(1)?r(1)?r(32)+4436:r(12)+340:r(8)+84:r(6)+20:r(4)+4:r(2);return 0===s?o:o>0?-o:null}function r(e,t,a){for(var r=e.getContexts("IAID"),i=1,n=0;n=B&&R>2&3),m.referenceCorner=b>>4&3,m.transposed=!!(64&b),m.combinationOperator=b>>7&3,m.defaultPixelValue=b>>9&1,m.dsOffset=b<<17>>27,m.refinementTemplate=b>>15&1,m.huffman){var y=c(u,d);d+=2,m.huffmanFS=3&y,m.huffmanDS=y>>2&3,m.huffmanDT=y>>4&3,m.huffmanRefinementDW=y>>6&3,m.huffmanRefinementDH=y>>8&3,m.huffmanRefinementDX=y>>10&3,m.huffmanRefinementDY=y>>12&3,m.huffmanRefinementSizeSelector=!!(14&y)}if(m.refinement&&!m.refinementTemplate){for(r=[],i=0;i<2;i++)r.push({x:o(u,d),y:o(u,d+1)}),d+=2;m.refinementAt=r}m.numberOfSymbolInstances=l(u,d),d+=4,m.huffman&&n("JBIG2 error: huffman is not supported"),a=[m,h.referredTo,u,d,f];break;case 38:case 39:var k={};k.info=v(u,d),d+=P;var w=u[d++];if(k.mmr=!!(1&w),k.template=w>>1&3,
k.prediction=!!(8&w),!k.mmr){for(s=0===k.template?4:1,r=[],i=0;i>2&1,A.combinationOperator=x>>3&3,A.requiresBuffer=!!(32&x),A.combinationOperatorOverride=!!(64&x),a=[A];break;case 49:break;case 50:break;case 51:break;case 62:break;default:n("JBIG2 error: segment type "+h.typeName+"("+h.type+") is not implemented")}var S="on"+h.typeName;S in t&&t[S].apply(t,a)}function k(e,t){for(var a=0,r=e.length;a0;)c=n.pop();for(c.index++,n.push(c);n.length<=a;)n.push(o={children:[],index:0}),c.children[c.index]=o.children,c=o;i++}a+10)return M--,B>>M&1;if(B=e[t++],255===B){var a=e[t++];a&&i("JPEG error: unexpected marker "+(B<<8|a).toString(16))}return M=7,B>>>7}function f(e){for(var t=e;;){if(t=t[d()],"number"==typeof t)return t;"object"!=typeof t&&i("JPEG error: invalid huffman sequence")}}function g(e){for(var t=0;e>0;)t=t<<1|d(),e--;return t}function p(e){if(1===e)return 1===d()?1:-1;var t=g(e);return t>=1<