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 P=T>>16;P>0&&(P=this.getBits(P)),s=(65535&T)+P,T=this.getCode(u),T=r[T],P=T>>16,P>0&&(P=this.getBits(P));var R=(65535&T)+P;I+s>=C&&(e=this.ensureBuffer(I+s),C=e.length);for(var E=0;E 0,a.dict=e,s.then(function(e){return a.toUnicode=e,r.buildToUnicode(a)}).then(function(e){return a.toUnicode=e,a})},buildToUnicode:function(e){if(e.hasIncludedToUnicodeMap=!!e.toUnicode&&e.toUnicode.length>0,e.hasIncludedToUnicodeMap)return Promise.resolve(e.toUnicode);var t,a,r;if(!e.composite){t=[];var i=e.defaultEncoding.slice(),n=e.baseEncodingName,s=e.differences;for(a in s)r=s[a],".notdef"!==r&&(i[a]=r);var o=Ie();for(a in i)if(r=i[a],""!==r)if(void 0!==o[r])t[a]=String.fromCharCode(o[r]);else{var c=0;switch(r[0]){case"G":3===r.length&&(c=parseInt(r.substr(1),16));break;case"g":5===r.length&&(c=parseInt(r.substr(1),16));break;case"C":case"c":r.length>=3&&(c=+r.substr(1));break;default:var l=Ce(r,o);l!==-1&&(c=l)}if(c){if(n&&c===+a){var h=ye(n);if(h&&(r=h[a])){t[a]=String.fromCharCode(o[r]);continue}}t[a]=String.fromCharCode(c)}}return Promise.resolve(new ie(t))}if(e.composite&&(e.cMap.builtInCMap&&!(e.cMap instanceof ue)||"Adobe"===e.cidSystemInfo.registry&&("GB1"===e.cidSystemInfo.ordering||"CNS1"===e.cidSystemInfo.ordering||"Japan1"===e.cidSystemInfo.ordering||"Korea1"===e.cidSystemInfo.ordering))){var u=e.cidSystemInfo.registry,d=e.cidSystemInfo.ordering,f=U.get(u+"-"+d+"-UCS2");return he.create({encoding:f,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then(function(a){var r=e.cMap;return t=[],r.forEach(function(e,r){R(r<=65535,"Max size of CID is 65,535");var i=a.lookup(r);i&&(t[e]=String.fromCharCode((i.charCodeAt(0)<<8)+i.charCodeAt(1)))}),new ie(t)})}return Promise.resolve(new re(e.firstChar,e.lastChar))},readToUnicode:function(e){var t=e;return z(t)?he.create({encoding:t,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then(function(e){return e instanceof ue?new re(0,65535):new ie(e.getMap())}):X(t)?he.create({encoding:t,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then(function(e){if(e instanceof ue)return new re(0,65535);var t=new Array(e.length);return e.forEach(function(e,a){for(var r=[],i=0;i 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=F,i=0;i >=1}else{var v=0;for(r=0,d=0,a=o;d>b;l[d]=y<0?0:y>u?u:y,r&=(1<m[w+1]){b=255;break}}o[u]=b}}else h("Unknown mask format.");if(o)for(u=0,g=3,f=t*n;u >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=b;a(e,n,s),t(g,s,i)}function u(e,a,i){var n=i;t(f,a,n);var s=b;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),b=Math.pow(f,e.GG),w=Math.pow(g,e.GB),A=e.MXA*m+e.MXB*b+e.MXC*w,x=e.MYA*m+e.MYB*b+e.MYC*w,S=e.MZA*m+e.MZB*b+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 P=k;u(v,T,P);var R=y;t(p,P,R);var E=i(R[0]),L=i(R[1]),M=i(R[2]);s[o]=Math.round(255*E),s[o+1]=Math.round(255*L),s[o+2]=Math.round(255*M)}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]),v=new Float32Array([1,1,1]),b=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[l]=h}u>0&&(u--,c[f]=m),r.set(m,i)}}}}(),v=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&&c("PostScript function stack overflow."),this.stack.push(e)},pop:function(){return this.stack.length<=0&&c("PostScript function stack underflow."),this.stack.pop()},copy:function(e){this.stack.length+e>=t&&c("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;r0&&void 0!==arguments[0]?arguments[0]:i,t=Object.create(this);return t.options=e,t},hasBlendModes:function(e){if(!G(e))return!1;var t=Object.create(null);e.objId&&(t[e.objId]=!0);for(var a=[e],r=this.xref;a.length;){var i,n,s,o=a.shift(),c=o.get("ExtGState");if(G(c)){var l=c.getKeys();for(n=0,s=l.length;nu)return void N("Image exceeded maximum allowed size and was removed.");var d,f,g=c.get("ImageMask","IM")||!1;if(g){var p=c.get("Width","W"),m=c.get("Height","H"),v=p+7>>3,b=a.getBytes(v*m),y=c.getArray("Decode","D"),k=!!y&&y[0]>0;return d=Z.createMask(b,p,m,a instanceof W,k),d.cached=!0,f=[d],i.addOp(S.paintImageMaskXObject,f),void(n&&(s[n]={fn:S.paintImageMaskXObject,args:f}))}var w=c.get("SMask","SM")||!1,A=c.get("Mask")||!1,x=200;if(r&&!w&&!A&&!(a instanceof V)&&l+hr&&(p=Math.max(p,b),y+=v+2*i,b=0,v=0),m.push({transform:k,x:b,y:y,w:w.width,h:w.height}),b+=w.width+2*i,v=Math.max(v,w.height)}var A=Math.max(p,b)+i,C=y+v+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+b,T[R++]=k<=0?0:k>=d?255:k>>h,T[R++]=w<=0?0:w>=d?255:w>>h,T[R++]=A<=0?0:A>=d?255:A>>h;else for(p=0;p=a)break;if(s[p]&=h,!r[p]&&n[p]){var b=c[n[p]],y=e.readBit(o,b);if(y){var k=this.decodeSignBit(v,g,p);i[p]=k,r[p]=1,this.setNeighborsSignificance(v,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 v=p.name;if(p.encoding){for(var b="",y=0,w=p.length;y0&&O(Me,-1,-1)&&(ce[oe]=Me,Ee=!0)}Ee||(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&&P>2&3),m.referenceCorner=v>>4&3,m.transposed=!!(64&v),m.combinationOperator=v>>7&3,m.defaultPixelValue=v>>9&1,m.dsOffset=v<<17>>27,m.refinementTemplate=v>>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=b(u,d),d+=R;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 N--,F>>N&1;if(F=e[t++],255===F){var a=e[t++];a&&s("JPEG error: unexpected marker "+(F<<8|a).toString(16))}return N=7,F>>>7}function m(e){for(var t=e;;){if(t=t[p()],"number"==typeof t)return t;"object"!==("undefined"==typeof t?"undefined":r(t))&&s("JPEG error: invalid huffman sequence")}}function v(e){for(var t=0;e>0;)t=t<<1|p(),e--;return t}function b(e){if(1===e)return 1===p()?1:-1;var t=v(e);return t>=1<