!function(r){"use strict";var e=function(){return"function"!=typeof PNG||"function"!=typeof FlateStream},n=function(e){return e!==r.image_compression.NONE&&t()},t=function(){var r="function"==typeof Deflater;if(!r)throw new Error("requires deflate.js for compression");return r},i=function(e,n,t,i){var f=5,g=l;switch(i){case r.image_compression.FAST:f=3,g=c;break;case r.image_compression.MEDIUM:f=6,g=u;break;case r.image_compression.SLOW:f=9,g=h}e=s(e,n,t,g);var p=new Uint8Array(o(f)),y=a(e),d=new Deflater(f),w=d.append(e),A=d.flush(),m=p.length+w.length+A.length,v=new Uint8Array(m+4);return v.set(p),v.set(w,p.length),v.set(A,p.length+w.length),v[m++]=y>>>24&255,v[m++]=y>>>16&255,v[m++]=y>>>8&255,v[m++]=255&y,r.arrayBufferToBinaryString(v)},o=function(r,e){var n=8,t=Math.LOG2E*Math.log(32768)-8,i=t<<4|n,o=i<<8,a=Math.min(3,(e-1&255)>>1);return o|=a<<6,o|=0,o+=31-o%31,[i,255&o&255]},a=function(r,e){for(var n,t=1,i=65535&t,o=t>>>16&65535,a=r.length,s=0;a>0;){n=a>e?e:a,a-=n;do i+=r[s++],o+=i;while(--n);i%=65521,o%=65521}return(o<<16|i)>>>0},s=function(r,e,n,t){for(var i,o,a,s=r.length/e,f=new Uint8Array(r.length+s),c=p(),l=0;s>l;l++){if(a=l*e,i=r.subarray(a,a+e),t)f.set(t(i,n,o),a+l);else{for(var u=0,h=c.length,g=[];h>u;u++)g[u]=c[u](i,n,o);var d=y(g.concat());f.set(g[d],a+l)}o=i}return f},f=function(r,e,n){var t=Array.apply([],r);return t.unshift(0),t},c=function(r,e,n){var t,i=[],o=0,a=r.length;for(i[0]=1;a>o;o++)t=r[o-e]||0,i[o+1]=r[o]-t+256&255;return i},l=function(r,e,n){var t,i=[],o=0,a=r.length;for(i[0]=2;a>o;o++)t=n&&n[o]||0,i[o+1]=r[o]-t+256&255;return i},u=function(r,e,n){var t,i,o=[],a=0,s=r.length;for(o[0]=3;s>a;a++)t=r[a-e]||0,i=n&&n[a]||0,o[a+1]=r[a]+256-(t+i>>>1)&255;return o},h=function(r,e,n){var t,i,o,a,s=[],f=0,c=r.length;for(s[0]=4;c>f;f++)t=r[f-e]||0,i=n&&n[f]||0,o=n&&n[f-e]||0,a=g(t,i,o),s[f+1]=r[f]-a+256&255;return s},g=function(r,e,n){var t=r+e-n,i=Math.abs(t-r),o=Math.abs(t-e),a=Math.abs(t-n);return o>=i&&a>=i?r:a>=o?e:n},p=function(){return[f,c,l,u,h]},y=function(r){for(var e,n,t,i=0,o=r.length;o>i;)e=d(r[i].slice(1)),(n>e||!n)&&(n=e,t=i),i++;return t},d=function(r){for(var e=0,n=r.length,t=0;n>e;)t+=Math.abs(r[e++]);return t},w=function(e){var n;switch(e){case r.image_compression.FAST:n=11;break;case r.image_compression.MEDIUM:n=13;break;case r.image_compression.SLOW:n=14}return n};r.processPNG=function(r,t,o,a,s){var f,c,l,u,h,g,p=this.color_spaces.DEVICE_RGB,y=this.decode.FLATE_DECODE,d=8;if(this.isArrayBuffer(r)&&(r=new Uint8Array(r)),this.isArrayBufferView(r)){if(e())throw new Error("PNG support requires png.js and zlib.js");if(f=new PNG(r),r=f.imgData,d=f.bits,p=f.colorSpace,u=f.colors,-1!==[4,6].indexOf(f.colorType)){if(8===f.bits)for(var A,m,v=32==f.pixelBitlength?new Uint32Array(f.decodePixels().buffer):16==f.pixelBitlength?new Uint16Array(f.decodePixels().buffer):new Uint8Array(f.decodePixels().buffer),B=v.length,b=new Uint8Array(B*f.colors),E=new Uint8Array(B),P=f.pixelBitlength-f.bits,U=0,x=0;B>U;U++){for(A=v[U],m=0;P>m;)b[x++]=A>>>m&255,m+=f.bits;E[U]=A>>>m&255}if(16===f.bits){for(var A,v=new Uint32Array(f.decodePixels().buffer),B=v.length,b=new Uint8Array(B*(32/f.pixelBitlength)*f.colors),E=new Uint8Array(B*(32/f.pixelBitlength)),D=f.colors>1,U=0,x=0,_=0;B>U;)A=v[U++],b[x++]=A>>>0&255,D&&(b[x++]=A>>>16&255,A=v[U++],b[x++]=A>>>0&255),E[_++]=A>>>16&255;d=8}n(a)?(r=i(b,f.width*f.colors,f.colors,a),g=i(E,f.width,1,a)):(r=b,g=E,y=null)}if(3===f.colorType&&(p=this.color_spaces.INDEXED,h=f.palette,f.transparency.indexed)){for(var M=f.transparency.indexed,C=0,U=0,B=M.length;B>U;++U)C+=M[U];if(C/=255,C===B-1&&-1!==M.indexOf(0))l=[M.indexOf(0)];else if(C!==B){for(var v=f.decodePixels(),E=new Uint8Array(v.length),U=0,B=v.length;B>U;U++)E[U]=M[v[U]];g=i(E,f.width,1)}}var O=w(a);return c=y===this.decode.FLATE_DECODE?"/Predictor "+O+" /Colors "+u+" /BitsPerComponent "+d+" /Columns "+f.width:"/Colors "+u+" /BitsPerComponent "+d+" /Columns "+f.width,(this.isArrayBuffer(r)||this.isArrayBufferView(r))&&(r=this.arrayBufferToBinaryString(r)),(g&&this.isArrayBuffer(g)||this.isArrayBufferView(g))&&(g=this.arrayBufferToBinaryString(g)),this.createImageInfo(r,f.width,f.height,p,d,y,t,o,c,l,h,g,O)}throw new Error("Unsupported PNG image data, try using JPEG instead.")}}(jsPDF.API);