UNPKG

blocktrail-sdk-proxy

Version:

FORK BlockTrail's Developer Friendly API binding for NodeJS. With proxy support

1 lines 1.11 MB
var jsPDF=function(e){"use strict";"undefined"==typeof btoa&&(e.btoa=function(e){var t,r,n,i,o,s,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".split(""),c=0,f=0,u="",h=[];do{t=(o=e.charCodeAt(c++)<<16|e.charCodeAt(c++)<<8|e.charCodeAt(c++))>>18&63,r=o>>12&63,n=o>>6&63,i=63&o,h[f++]=a[t]+a[r]+a[n]+a[i]}while(c<e.length);return u=h.join(""),((s=e.length%3)?u.slice(0,s-3):u)+"===".slice(s||3)}),"undefined"==typeof atob&&(e.atob=function(e){var t,r,n,i,o,s,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c=0,f=0,u=[];if(!e)return e;e+="";do{t=(s=a.indexOf(e.charAt(c++))<<18|a.indexOf(e.charAt(c++))<<12|(i=a.indexOf(e.charAt(c++)))<<6|(o=a.indexOf(e.charAt(c++))))>>16&255,r=s>>8&255,n=255&s,u[f++]=64===i?String.fromCharCode(t):64===o?String.fromCharCode(t,r):String.fromCharCode(t,r,n)}while(c<e.length);return u.join("")});var t="function"==typeof Object.keys?function(e){return Object.keys(e).length}:function(e){var t,r=0;for(t in e)e.hasOwnProperty(t)&&r++;return r};function r(n,i,o,s){var a={};"object"==typeof n&&(n=(a=n).orientation,i=a.unit||i,o=a.format||o,s=a.compress||a.compressPdf||s),n=void 0===n?"p":n.toString().toLowerCase(),void 0===i&&(i="mm"),void 0===o&&(o="a4"),void 0===s&&"undefined"==typeof zpipe&&(s=!1);var c,f,u,h,l,d,p,y,b,v=o.toString().toLowerCase(),g=[],m=0,w=s,_={a0:[2383.94,3370.39],a1:[1683.78,2383.94],a2:[1190.55,1683.78],a3:[841.89,1190.55],a4:[595.28,841.89],a5:[419.53,595.28],a6:[297.64,419.53],a7:[209.76,297.64],a8:[147.4,209.76],a9:[104.88,147.4],a10:[73.7,104.88],b0:[2834.65,4008.19],b1:[2004.09,2834.65],b2:[1417.32,2004.09],b3:[1000.63,1417.32],b4:[708.66,1000.63],b5:[498.9,708.66],b6:[354.33,498.9],b7:[249.45,354.33],b8:[175.75,249.45],b9:[124.72,175.75],b10:[87.87,124.72],c0:[2599.37,3676.54],c1:[1836.85,2599.37],c2:[1298.27,1836.85],c3:[918.43,1298.27],c4:[649.13,918.43],c5:[459.21,649.13],c6:[323.15,459.21],c7:[229.61,323.15],c8:[161.57,229.61],c9:[113.39,161.57],c10:[79.37,113.39],letter:[612,792],"government-letter":[576,756],legal:[612,1008],"junior-legal":[576,360],ledger:[1224,792],tabloid:[792,1224]},E=a.textColor||"0 g",S=a.drawColor||"0 G",k=0,A=[],I=2,x=!!a.outToPages,T=[],B={},C={},P=a.fontSize||16,O=a.lineWidth||.200025,M=a.lineHeight||1.15,R={title:"",subject:"",author:"",keywords:"",creator:""},L=0,j=0,D={},N=new PubSub(D),U=function(e){return e.toFixed(2)},H=function(e){return e.toFixed(3)},K=function(e){var t=e.toFixed(0);return e<10?"0"+t:t},z=function(e){x?A[k].push(e):(g.push(e),m+=e.length+1)},F=function(){return T[++I]=m,z(I+" 0 obj"),I},W=function(e){z("stream"),z(e),z("endstream")},q=function(){var e;for(e in z("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]"),z("/Font <<"),B)B.hasOwnProperty(e)&&z("/"+e+" "+B[e].objectNumber+" 0 R");z(">>"),z("/XObject <<"),N.publish("putXobjectDict"),z(">>")},V=function(){!function(){var e,t;for(e in B)B.hasOwnProperty(e)&&((t=B[e]).objectNumber=F(),z("<</BaseFont/"+t.PostScriptName+"/Type/Font"),"string"==typeof t.encoding&&z("/Encoding/"+t.encoding),z("/Subtype/Type1>>"),z("endobj"))}(),N.publish("putResources"),T[2]=m,z("2 0 obj"),z("<<"),q(),z(">>"),z("endobj"),N.publish("postPutResources")},G=function(e,t,r){void 0===C[t]&&(C[t]={}),C[t][r]=e},Y=function(e,r,n,i){var o="F"+(t(B)+1).toString(10),s=B[o]={id:o,PostScriptName:e,fontName:r,fontStyle:n,encoding:i,metadata:{}};return G(o,r,n),N.publish("addFont",s),o},X=function(e,t){return function(e,t){var r,n,i,o,s,a,f,u,h;if(void 0===t&&(t={}),i=t.sourceEncoding?i:"Unicode",s=t.outputEncoding,(t.autoencode||s)&&B[c].metadata&&B[c].metadata[i]&&B[c].metadata[i].encoding&&(o=B[c].metadata[i].encoding,!s&&B[c].encoding&&(s=B[c].encoding),!s&&o.codePages&&(s=o.codePages[0]),"string"==typeof s&&(s=o[s]),s)){for(f=!1,a=[],r=0,n=e.length;r<n;r++)(u=s[e.charCodeAt(r)])?a.push(String.fromCharCode(u)):a.push(e[r]),a[r].charCodeAt(0)>>8&&(f=!0);e=a.join("")}for(r=e.length;void 0===f&&0!==r;)e.charCodeAt(r-1)>>8&&(f=!0),r--;if(f){for(a=t.noBOM?[]:[254,255],r=0,n=e.length;r<n;r++){if((h=(u=e.charCodeAt(r))>>8)>>8)throw new Error("Character at position "+r.toString(10)+" of string '"+e+"' exceeds 16bits. Cannot be encoded into UCS-2 BE");a.push(h),a.push(u-(h<<8))}return String.fromCharCode.apply(void 0,a)}return e}(e,t).replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)")},J=function(){x=!0,A[++k]=[],z(U(O*h)+" w"),z(S),0!==L&&z(L.toString(10)+" J"),0!==j&&z(j.toString(10)+" j"),N.publish("addPage",{pageNumber:k})},Z=function(e,t){var r;void 0===e&&(e=B[c].fontName),void 0===t&&(t=B[c].fontStyle);try{r=C[e][t]}catch(e){r=void 0}if(!r)throw new Error("Unable to look up font label for font '"+e+"', '"+t+"'. Refer to getFontList() for available fonts.");return r},Q=function(){x=!1,I=2,g=[],T=[],z("%PDF-1.3"),function(){var e,t,r,n,i,o;for(p=u*h,y=f*h,e=1;e<=k;e++){if(F(),z("<</Type /Page"),z("/Parent 1 0 R"),z("/Resources 2 0 R"),z("/Contents "+(I+1)+" 0 R>>"),z("endobj"),t=A[e].join("\n"),F(),w){for(r=[],n=0;n<t.length;++n)r[n]=t.charCodeAt(n);for(n in o=adler32cs.from(t),(i=new Deflater(6)).append(new Uint8Array(r)),t=i.flush(),r=[new Uint8Array([120,156]),new Uint8Array(t),new Uint8Array([255&o,o>>8&255,o>>16&255,o>>24&255])],t="",r)r.hasOwnProperty(n)&&(t+=String.fromCharCode.apply(null,r[n]));z("<</Length "+t.length+" /Filter [/FlateDecode]>>")}else z("<</Length "+t.length+">>");W(t),z("endobj")}for(T[1]=m,z("1 0 obj"),z("<</Type /Pages"),b="/Kids [",n=0;n<k;n++)b+=3+2*n+" 0 R ";z(b+"]"),z("/Count "+k),z("/MediaBox [0 0 "+U(p)+" "+U(y)+"]"),z(">>"),z("endobj")}(),V(),F(),z("<<"),function(){z("/Producer (jsPDF "+r.version+")"),R.title&&z("/Title ("+X(R.title)+")"),R.subject&&z("/Subject ("+X(R.subject)+")"),R.author&&z("/Author ("+X(R.author)+")"),R.keywords&&z("/Keywords ("+X(R.keywords)+")"),R.creator&&z("/Creator ("+X(R.creator)+")");var e=new Date;z("/CreationDate (D:"+[e.getFullYear(),K(e.getMonth()+1),K(e.getDate()),K(e.getHours()),K(e.getMinutes()),K(e.getSeconds())].join("")+")")}(),z(">>"),z("endobj"),F(),z("<<"),z("/Type /Catalog"),z("/Pages 1 0 R"),z("/OpenAction [3 0 R /FitH null]"),z("/PageLayout /OneColumn"),N.publish("putCatalog"),z(">>"),z("endobj");var e,t,n,i=m;for(z("xref"),z("0 "+(I+1)),z("0000000000 65535 f "),e=1;e<=I;e++)z((t=T[e],void 0,((n=t.toFixed(0)).length<10?new Array(11-n.length).join("0")+n:n)+" 00000 n "));return z("trailer"),z("<<"),z("/Size "+(I+1)),z("/Root "+I+" 0 R"),z("/Info "+(I-1)+" 0 R"),z(">>"),z("startxref"),z(i),z("%%EOF"),x=!0,g.join("\n")},$=function(e){var t="S";return"F"===e?t="f":"FD"!==e&&"DF"!==e||(t="B"),t},ee=function(){var e,t,r,n;for(t=(e=Q()).length,r=new Uint8Array(new ArrayBuffer(t)),n=0;n<t;n++)r[n]=e.charCodeAt(n);return new Blob([r],{type:"application/pdf"})},te=function(t,r){switch(t){case void 0:return Q();case"save":if(navigator.getUserMedia){if(void 0===e.URL)return D.output("dataurlnewwindow");if(void 0===e.URL.createObjectURL)return D.output("dataurlnewwindow")}saveAs(ee(),r);break;case"blob":return ee();case"datauristring":case"dataurlstring":return"data:application/pdf;base64,"+btoa(Q());case"datauri":case"dataurl":document.location.href="data:application/pdf;base64,"+btoa(Q());break;case"dataurlnewwindow":e.open("data:application/pdf;base64,"+btoa(Q()));break;default:throw new Error('Output type "'+t+'" is not supported.')}};if("pt"===i)h=1;else if("mm"===i)h=72/25.4;else if("cm"===i)h=72/2.54;else{if("in"!==i)throw"Invalid unit: "+i;h=72}if(_.hasOwnProperty(v))f=_[v][1]/h,u=_[v][0]/h;else try{f=o[1],u=o[0]}catch(e){throw"Invalid format: "+o}if("p"===n||"portrait"===n)n="p",u>f&&(l=u,u=f,f=l);else{if("l"!==n&&"landscape"!==n)throw"Invalid orientation: "+n;n="l",f>u&&(l=u,u=f,f=l)}for(d in D.internal={pdfEscape:X,getStyle:$,getFont:function(){return B[Z.apply(D,arguments)]},getFontSize:function(){return P},getLineHeight:function(){return P*M},btoa:btoa,write:function(e,t,r,n){z(1===arguments.length?e:Array.prototype.join.call(arguments," "))},getCoordinateString:function(e){return U(e*h)},getVerticalCoordinateString:function(e){return U((f-e)*h)},collections:{},newObject:F,putStream:W,events:N,scaleFactor:h,pageSize:{width:u,height:f},output:function(e,t){return te(e,t)},getNumberOfPages:function(){return A.length-1},pages:A},D.addPage=function(){return J(),this},D.text=function(e,t,r,n,i){if("number"==typeof e){var o=r;r=t,t=e,e=o}"string"==typeof e&&e.match(/[\n\r]/)&&(e=e.split(/\r\n|\r|\n/g)),"number"==typeof n&&(i=n,n=null);var s="",a="Td";if(i){i*=Math.PI/180;var u=Math.cos(i),l=Math.sin(i);s=[U(u),U(l),U(-1*l),U(u),""].join(" "),a="Tm"}if("noBOM"in(n=n||{})||(n.noBOM=!0),"autoencode"in n||(n.autoencode=!0),"string"==typeof e)e=X(e,n);else{if(!(e instanceof Array))throw new Error('Type of text must be string or Array. "'+e+'" is not recognized.');for(var d=e.concat(),p=[],y=d.length;y--;)p.push(X(d.shift(),n));e=p.join(") Tj\nT* (")}return z("BT\n/"+c+" "+P+" Tf\n"+P*M+" TL\n"+E+"\n"+s+U(t*h)+" "+U((f-r)*h)+" "+a+"\n("+e+") Tj\nET"),this},D.line=function(e,t,r,n){return z(U(e*h)+" "+U((f-t)*h)+" m "+U(r*h)+" "+U((f-n)*h)+" l S"),this},D.lines=function(e,t,r,n,i,o){var s,a,c,u,l,d,p,y,b,v,g,m,w;for("number"==typeof e&&(s=e,a=t,e=r,t=s,r=a),i=$(i),n=void 0===n?[1,1]:n,z(H(t*h)+" "+H((f-r)*h)+" m "),c=n[0],u=n[1],d=e.length,m=t,w=r,l=0;l<d;l++)2===(p=e[l]).length?(m=p[0]*c+m,w=p[1]*u+w,z(H(m*h)+" "+H((f-w)*h)+" l")):(y=p[0]*c+m,b=p[1]*u+w,v=p[2]*c+m,g=p[3]*u+w,m=p[4]*c+m,w=p[5]*u+w,z(H(y*h)+" "+H((f-b)*h)+" "+H(v*h)+" "+H((f-g)*h)+" "+H(m*h)+" "+H((f-w)*h)+" c"));return 1==o&&z(" h"),z(i),this},D.rect=function(e,t,r,n,i){var o=$(i);return z([U(e*h),U((f-t)*h),U(r*h),U(-n*h),"re",o].join(" ")),this},D.triangle=function(e,t,r,n,i,o,s){return this.lines([[r-e,n-t],[i-r,o-n],[e-i,t-o]],e,t,[1,1],s,!0),this},D.roundedRect=function(e,t,r,n,i,o,s){var a=4/3*(Math.SQRT2-1);return this.lines([[r-2*i,0],[i*a,0,i,o-o*a,i,o],[0,n-2*o],[0,o*a,-i*a,o,-i,o],[2*i-r,0],[-i*a,0,-i,-o*a,-i,-o],[0,2*o-n],[0,-o*a,i*a,-o,i,-o]],e+i,t,[1,1],s),this},D.ellipse=function(e,t,r,n,i){var o=$(i),s=4/3*(Math.SQRT2-1)*r,a=4/3*(Math.SQRT2-1)*n;return z([U((e+r)*h),U((f-t)*h),"m",U((e+r)*h),U((f-(t-a))*h),U((e+s)*h),U((f-(t-n))*h),U(e*h),U((f-(t-n))*h),"c"].join(" ")),z([U((e-s)*h),U((f-(t-n))*h),U((e-r)*h),U((f-(t-a))*h),U((e-r)*h),U((f-t)*h),"c"].join(" ")),z([U((e-r)*h),U((f-(t+a))*h),U((e-s)*h),U((f-(t+n))*h),U(e*h),U((f-(t+n))*h),"c"].join(" ")),z([U((e+s)*h),U((f-(t+n))*h),U((e+r)*h),U((f-(t+a))*h),U((e+r)*h),U((f-t)*h),"c",o].join(" ")),this},D.circle=function(e,t,r,n){return this.ellipse(e,t,r,r,n)},D.setProperties=function(e){var t;for(t in R)R.hasOwnProperty(t)&&e[t]&&(R[t]=e[t]);return this},D.setFontSize=function(e){return P=e,this},D.setFont=function(e,t){return c=Z(e,t),this},D.setFontStyle=D.setFontType=function(e){return c=Z(void 0,e),this},D.getFontList=function(){var e,t,r,n={};for(e in C)if(C.hasOwnProperty(e))for(t in n[e]=r=[],C[e])C[e].hasOwnProperty(t)&&r.push(t);return n},D.setLineWidth=function(e){return z((e*h).toFixed(2)+" w"),this},D.setDrawColor=function(e,t,r,n){var i;return i=void 0===t||void 0===n&&e===t===r?"string"==typeof e?e+" G":U(e/255)+" G":void 0===n?"string"==typeof e?[e,t,r,"RG"].join(" "):[U(e/255),U(t/255),U(r/255),"RG"].join(" "):"string"==typeof e?[e,t,r,n,"K"].join(" "):[U(e),U(t),U(r),U(n),"K"].join(" "),z(i),this},D.setFillColor=function(e,t,r,n){var i;return i=void 0===t||void 0===n&&e===t===r?"string"==typeof e?e+" g":U(e/255)+" g":void 0===n?"string"==typeof e?[e,t,r,"rg"].join(" "):[U(e/255),U(t/255),U(r/255),"rg"].join(" "):"string"==typeof e?[e,t,r,n,"k"].join(" "):[U(e),U(t),U(r),U(n),"k"].join(" "),z(i),this},D.setTextColor=function(e,t,r){if("string"==typeof e&&/#[0-9A-Fa-f]{6}/.test(e)){var n=e.replace("#",""),i=parseInt(n,16);e=i>>16&255,t=i>>8&255,r=255&i}return E=0===e&&0===t&&0===r||void 0===t?H(e/255)+" g":[H(e/255),H(t/255),H(r/255),"rg"].join(" "),this},D.CapJoinStyles={0:0,butt:0,but:0,miter:0,1:1,round:1,rounded:1,circle:1,2:2,projecting:2,project:2,square:2,bevel:2},D.setLineCap=function(e){var t=this.CapJoinStyles[e];if(void 0===t)throw new Error("Line cap style of '"+e+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return L=t,z(t.toString(10)+" J"),this},D.setLineJoin=function(e){var t=this.CapJoinStyles[e];if(void 0===t)throw new Error("Line join style of '"+e+"' is not recognized. See or extend .CapJoinStyles property for valid styles");return j=t,z(t.toString(10)+" j"),this},D.output=te,D.save=function(e){D.output("save",e)},r.API)r.API.hasOwnProperty(d)&&("events"===d&&r.API.events.length?function(e,t){var r,n,i;for(i=t.length-1;-1!==i;i--)r=t[i][0],n=t[i][1],e.subscribe.apply(e,[r].concat("function"==typeof n?[n]:n))}(N,r.API.events):D[d]=r.API[d]);return function(){var e,t,r,n,i=[["Helvetica","helvetica","normal"],["Helvetica-Bold","helvetica","bold"],["Helvetica-Oblique","helvetica","italic"],["Helvetica-BoldOblique","helvetica","bolditalic"],["Courier","courier","normal"],["Courier-Bold","courier","bold"],["Courier-Oblique","courier","italic"],["Courier-BoldOblique","courier","bolditalic"],["Times-Roman","times","normal"],["Times-Bold","times","bold"],["Times-Italic","times","italic"],["Times-BoldItalic","times","bolditalic"]];for(e=0,t=i.length;e<t;e++)r=Y(i[e][0],i[e][1],i[e][2],"StandardEncoding"),n=i[e][0].split("-"),G(r,n[0],n[1]||"");N.publish("addFonts",{fonts:B,dictionary:C})}(),c="F1",J(),N.publish("initialized"),D}return e.PubSub=function(e){this.topics={},this.context=e,this.publish=function(e,t){if(this.topics[e]){var r,n,i,o,s=this.topics[e],a=[],c=function(){};for(t=Array.prototype.slice.call(arguments,1),n=0,i=s.length;n<i;n++)r=(o=s[n])[0],o[1]&&(o[0]=c,a.push(n)),r.apply(this.context,t);for(n=0,i=a.length;n<i;n++)s.splice(a[n],1)}},this.subscribe=function(e,t,r){return this.topics[e]?this.topics[e].push([t,r]):this.topics[e]=[[t,r]],{topic:e,callback:t}},this.unsubscribe=function(e){if(this.topics[e.topic]){var t,r,n=this.topics[e.topic];for(t=0,r=n.length;t<r;t++)n[t][0]===e.callback&&n.splice(t,1)}}},r.API={events:[]},r.version="1.0.0-trunk","function"==typeof define?define(function(){return r}):e.jsPDF=r,r}(self);!function(e){"use strict";var t=e.getCharWidthsArray=function(e,t){t||(t={});var r,n,i,o=t.widths?t.widths:this.internal.getFont().metadata.Unicode.widths,s=o.fof?o.fof:1,a=t.kerning?t.kerning:this.internal.getFont().metadata.Unicode.kerning,c=a.fof?a.fof:1,f=0,u=o[0]||s,h=[];for(r=0,n=e.length;r<n;r++)i=e.charCodeAt(r),h.push((o[i]||u)/s+(a[i]&&a[i][f]||0)/c),f=i;return h},r=function(e){for(var t=e.length,r=0;t;)r+=e[--t];return r},n=(e.getStringUnitWidth=function(e,n){return r(t.call(this,e,n))},function(e,t,r,n){for(var i=[],o=0,s=e.length,a=0;o!==s&&a+t[o]<r;)a+=t[o],o++;i.push(e.slice(0,o));var c=o;for(a=0;o!==s;)a+t[o]>n&&(i.push(e.slice(c,o)),a=0,c=o),a+=t[o],o++;return c!==o&&i.push(e.slice(c,o)),i}),i=function(e,i,o){o||(o={});var s,a,c,f,u,h=t(" ",o)[0],l=e.split(" "),d=[],p=[d],y=o.textIndent||0,b=0,v=0;for(c=0,f=l.length;c<f;c++)if(s=l[c],a=t(s,o),y+b+(v=r(a))>i){if(v>i){for(u=n(s,a,i-(y+b),i),d.push(u.shift()),d=[u.pop()];u.length;)p.push([u.shift()]);v=r(a.slice(s.length-d[0].length))}else d=[s];p.push(d),y=v,b=h}else d.push(s),y+=b+v,b=h;var g=[];for(c=0,f=p.length;c<f;c++)g.push(p[c].join(" "));return g};e.splitTextToSize=function(e,t,r){r||(r={});var n,o=r.fontSize||this.internal.getFontSize(),s=function(e){var t={0:1},r={};if(e.widths&&e.kerning)return{widths:e.widths,kerning:e.kerning};var n=this.internal.getFont(e.fontName,e.fontStyle);return n.metadata.Unicode?{widths:n.metadata.Unicode.widths||t,kerning:n.metadata.Unicode.kerning||r}:{widths:t,kerning:r}}.call(this,r);n=e.match(/[\n\r]/)?e.split(/\r\n|\r|\n/g):[e];var a=1*this.internal.scaleFactor*t/o;s.textIndent=r.textIndent?1*r.textIndent*this.internal.scaleFactor/o:0;var c,f,u=[];for(c=0,f=n.length;c<f;c++)u=u.concat(i(n[c],a,s));return u}}(jsPDF.API),function(e){"use strict";var t=["jpeg","jpg","png"],r=function(e){var t=this.internal.newObject(),n=this.internal.write,i=this.internal.putStream;if(e.n=t,n("<</Type /XObject"),n("/Subtype /Image"),n("/Width "+e.w),n("/Height "+e.h),e.cs===this.color_spaces.INDEXED?n("/ColorSpace [/Indexed /DeviceRGB "+(e.pal.length/3-1)+" "+("smask"in e?t+2:t+1)+" 0 R]"):(n("/ColorSpace /"+e.cs),e.cs===this.color_spaces.DEVICE_CMYK&&n("/Decode [1 0 1 0 1 0 1 0]")),n("/BitsPerComponent "+e.bpc),"f"in e&&n("/Filter /"+e.f),"dp"in e&&n("/DecodeParms <<"+e.dp+">>"),"trns"in e&&e.trns.constructor==Array){for(var o="",s=0,a=e.trns.length;s<a;s++)o+=e.trns[s]+" "+e.trns[s]+" ";n("/Mask ["+o+"]")}if("smask"in e&&n("/SMask "+(t+1)+" 0 R"),n("/Length "+e.data.length+">>"),i(e.data),n("endobj"),"smask"in e){var c="/Predictor 15 /Colors 1 /BitsPerComponent "+e.bpc+" /Columns "+e.w,f={w:e.w,h:e.h,cs:"DeviceGray",bpc:e.bpc,dp:c,data:e.smask};"f"in e&&(f.f=e.f),r.call(this,f)}e.cs===this.color_spaces.INDEXED&&(this.internal.newObject(),n("<< /Length "+e.pal.length+">>"),i(this.arrayBufferToBinaryString(new Uint8Array(e.pal))),n("endobj"))},n=function(){var e=this.internal.collections.addImage_images;for(var t in e)r.call(this,e[t])},i=function(){var e,t=this.internal.collections.addImage_images,r=this.internal.write;for(var n in t)r("/I"+(e=t[n]).i,e.n,"0","R")},o=function(e,t){return e||t||(e=-96,t=-96),e<0&&(e=-1*info.w*72/e/this.internal.scaleFactor),t<0&&(t=-1*info.h*72/t/this.internal.scaleFactor),0===e&&(e=t*info.w/info.h),0===t&&(t=e*info.h/info.w),[e,t]};e.color_spaces={DEVICE_RGB:"DeviceRGB",DEVICE_GRAY:"DeviceGray",DEVICE_CMYK:"DeviceCMYK",CAL_GREY:"CalGray",CAL_RGB:"CalRGB",LAB:"Lab",ICC_BASED:"ICCBased",INDEXED:"Indexed",PATTERN:"Pattern",SEPERATION:"Seperation",DEVICE_N:"DeviceN"},e.decode={DCT_DECODE:"DCTDecode",FLATE_DECODE:"FlateDecode",LZW_DECODE:"LZWDecode",JPX_DECODE:"JPXDecode",JBIG2_DECODE:"JBIG2Decode",ASCII85_DECODE:"ASCII85Decode",ASCII_HEX_DECODE:"ASCIIHexDecode",RUN_LENGTH_DECODE:"RunLengthDecode",CCITT_FAX_DECODE:"CCITTFaxDecode"},e.image_compression={NONE:"NONE",FAST:"FAST",MEDIUM:"MEDIUM",SLOW:"SLOW"},e.isString=function(e){return"string"==typeof e},e.extractInfoFromBase64DataURI=function(e){return/^data:([\w]+?\/([\w]+?));base64,(.+?)$/g.exec(e)},e.supportsArrayBuffer=function(){return"function"==typeof ArrayBuffer},e.isArrayBuffer=function(e){return!!this.supportsArrayBuffer()&&e instanceof ArrayBuffer},e.isArrayBufferView=function(e){return!!this.supportsArrayBuffer()&&(e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)},e.binaryStringToUint8Array=function(e){for(var t=e.length,r=new Uint8Array(t),n=0;n<t;n++)r[n]=e.charCodeAt(n);return r},e.arrayBufferToBinaryString=function(e){this.isArrayBuffer(e)&&(e=new Uint8Array(e));for(var t="",r=e.byteLength,n=0;n<r;n++)t+=String.fromCharCode(e[n]);return t},e.arrayBufferToBase64=function(e){for(var t,r="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=new Uint8Array(e),o=i.byteLength,s=o%3,a=o-s,c=0;c<a;c+=3)r+=n[(16515072&(t=i[c]<<16|i[c+1]<<8|i[c+2]))>>18]+n[(258048&t)>>12]+n[(4032&t)>>6]+n[63&t];return 1==s?r+=n[(252&(t=i[a]))>>2]+n[(3&t)<<4]+"==":2==s&&(r+=n[(64512&(t=i[a]<<8|i[a+1]))>>10]+n[(1008&t)>>4]+n[(15&t)<<2]+"="),r},e.createImageInfo=function(e,t,r,n,i,o,s,a,c,f,u,h){var l={alias:a,w:t,h:r,cs:n,bpc:i,i:s,data:e};return o&&(l.f=o),c&&(l.dp=c),f&&(l.trns=f),u&&(l.pal=u),h&&(l.smask=h),l},e.addImage=function(r,s,a,c,f,u,h,l){if("number"==typeof s){var d=u;u=f,f=c,c=a,a=s,s=d||"jpeg"}var p,y,b,v,g,m=function(){var e=this.internal.collections.addImage_images;return e||(this.internal.collections.addImage_images=e={},this.internal.events.subscribe("putResources",n),this.internal.events.subscribe("putXobjectDict",i)),e}.call(this);if((b=l)&&"string"==typeof b&&(b=b.toUpperCase()),l=b in e.image_compression?b:e.image_compression.NONE,s=s.toLowerCase(),function(e){return void 0===e||null===e}(h)&&(h=void 0),"object"==typeof(v=r)&&1===v.nodeType&&(r=function(e,t){var r=document.createElement("canvas");r.width=e.clientWidth||e.width,r.height=e.clientHeight||e.height;var n=r.getContext("2d");if(!n)throw"addImage requires canvas to be supported by browser.";return n.drawImage(e,0,0,r.width,r.height),r.toDataURL("png"==t?"image/png":"image/jpeg")}(r,s)),this.isString(r)){var w=this.extractInfoFromBase64DataURI(r);w?(s=w[2],r=atob(w[3]),this.supportsArrayBuffer()&&(y=r,r=this.binaryStringToUint8Array(r))):255!==r.charCodeAt(0)&&(p=function(e,t){var r;if(t)for(var n in t)if(e===t[n].alias){r=t[n];break}return r}(r,m))}if(g=s,-1===t.indexOf(g))throw new Error("addImage currently only supports formats "+t+", not '"+s+"'");if(function(t){return"function"!=typeof e["process"+t.toUpperCase()]}(s))throw new Error("please ensure that the plugin for '"+s+"' support is added");var _=function(e){var t=0;return e&&(t=Object.keys?Object.keys(e).length:function(e){var t=0;for(var r in e)e.hasOwnProperty(r)&&t++;return t}(e)),t}(m),E=p;if(E||(E=this["process"+s.toUpperCase()](r,_,h,l,y)),!E)throw new Error("An unkwown error occurred whilst processing the image");return function(e,t,r,n,i,s,a){var c=o(r,n),f=this.internal.getCoordinateString,u=this.internal.getVerticalCoordinateString;r=c[0],n=c[1],a[s]=i,this.internal.write("q",f(r),"0 0",f(n),f(e),u(t+n),"cm /I"+i.i,"Do Q")}.call(this,a,c,f,u,E,_,m),this};var s=function(e,t){return e.subarray(t,t+4)};e.processJPEG=function(e,t,r,n,i){var o,a=this.color_spaces.DEVICE_RGB,c=this.decode.DCT_DECODE;return this.isString(e)?(o=function(e){var t;if(255===!e.charCodeAt(0)||216===!e.charCodeAt(1)||255===!e.charCodeAt(2)||224===!e.charCodeAt(3)||!e.charCodeAt(6)==="J".charCodeAt(0)||!e.charCodeAt(7)==="F".charCodeAt(0)||!e.charCodeAt(8)==="I".charCodeAt(0)||!e.charCodeAt(9)==="F".charCodeAt(0)||0===!e.charCodeAt(10))throw new Error("getJpegSize requires a binary string jpeg file");for(var r=256*e.charCodeAt(4)+e.charCodeAt(5),n=4,i=e.length;n<i;){if(n+=r,255!==e.charCodeAt(n))throw new Error("getJpegSize could not find the size of the image");if(192===e.charCodeAt(n+1)||193===e.charCodeAt(n+1)||194===e.charCodeAt(n+1)||195===e.charCodeAt(n+1)||196===e.charCodeAt(n+1)||197===e.charCodeAt(n+1)||198===e.charCodeAt(n+1)||199===e.charCodeAt(n+1))return t=256*e.charCodeAt(n+5)+e.charCodeAt(n+6),[256*e.charCodeAt(n+7)+e.charCodeAt(n+8),t];n+=2,r=256*e.charCodeAt(n)+e.charCodeAt(n+1)}}(e),this.createImageInfo(e,o[0],o[1],a,8,c,t,r)):(this.isArrayBuffer(e)&&(e=new Uint8Array(e)),this.isArrayBufferView(e)?(o=function(e){if(65496!=(e[0]<<8|e[1]))throw new Error("Supplied data is not a JPEG");for(var t,r=e.length,n=(e[4]<<8)+e[5],i=4;i<r;){if(n=((t=s(e,i+=n))[2]<<8)+t[3],(192===t[1]||194===t[1])&&255===t[0]&&n>7)return{width:((t=s(e,i+5))[2]<<8)+t[3],height:(t[0]<<8)+t[1]};i+=2}throw new Error("getJpegSizeFromBytes could not find the size of the image")}(e),e=i||this.arrayBufferToBinaryString(e),this.createImageInfo(e,o.width,o.height,a,8,c,t,r)):null)},e.processJPG=function(e,t,r,n,i){return this.processJPEG(e,t,r,n,i)}}(jsPDF.API);var saveAs=saveAs||navigator.msSaveBlob&&navigator.msSaveBlob.bind(navigator)||function(e){"use strict";var t=e.document,r=e.URL||e.webkitURL||e,n=t.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in n,o=e.webkitRequestFileSystem,s=e.requestFileSystem||o||e.mozRequestFileSystem,a=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},c=0,f=[],u=function(e,t,r){for(var n=(t=[].concat(t)).length;n--;){var i=e["on"+t[n]];if("function"==typeof i)try{i.call(e,r||e)}catch(e){a(e)}}},h=function(r,a){var h,l,d,p,y,b=this,v=r.type,g=!1,m=function(){var t=(e.URL||e.webkitURL||e).createObjectURL(r);return f.push(t),t},w=function(){u(b,"writestart progress write writeend".split(" "))},_=function(){!g&&h||(h=m()),l&&(l.location.href=h),b.readyState=b.DONE,w()},E=function(e){return function(){if(b.readyState!==b.DONE)return e.apply(this,arguments)}},S={create:!0,exclusive:!1};if(b.readyState=b.INIT,a||(a="download"),i&&(h=m(),n.href=h,n.download=a,p=n,(y=t.createEvent("MouseEvents")).initMouseEvent("click",!0,!1,e,0,0,0,0,0,!1,!1,!1,!1,0,null),p.dispatchEvent(y)))return b.readyState=b.DONE,void w();e.chrome&&v&&"application/octet-stream"!==v&&(d=r.slice||r.webkitSlice,r=d.call(r,0,r.size,"application/octet-stream"),g=!0),o&&"download"!==a&&(a+=".download"),l="application/octet-stream"===v||o?e:e.open(),s?(c+=r.size,s(e.TEMPORARY,c,E(function(e){e.root.getDirectory("saved",S,E(function(e){var t=function(){e.getFile(a,S,E(function(e){e.createWriter(E(function(t){t.onwriteend=function(t){l.location.href=e.toURL(),f.push(e),b.readyState=b.DONE,u(b,"writeend",t)},t.onerror=function(){var e=t.error;e.code!==e.ABORT_ERR&&_()},"writestart progress write abort".split(" ").forEach(function(e){t["on"+e]=b["on"+e]}),t.write(r),b.abort=function(){t.abort(),b.readyState=b.DONE},b.readyState=b.WRITING}),_)}),_)};e.getFile(a,{create:!1},E(function(e){e.remove(),t()}),E(function(e){e.code===e.NOT_FOUND_ERR?t():_()}))}),_)}),_)):_()},l=h.prototype;return l.abort=function(){this.readyState=this.DONE,u(this,"abort")},l.readyState=l.INIT=0,l.WRITING=1,l.DONE=2,l.error=l.onwritestart=l.onprogress=l.onwrite=l.onabort=l.onerror=l.onwriteend=null,e.addEventListener("unload",function(){for(var e=f.length;e--;){var t=f[e];"string"==typeof t?r.revokeObjectURL(t):t.remove()}f.length=0},!1),function(e,t){return new h(e,t)}}(self);!function(e){"use strict";var t=function(){var e="function"==typeof Deflater;if(!e)throw new Error("requires deflate.js for compression");return e},r=function(t,r,s,h){var l=5,d=c;switch(h){case e.image_compression.FAST:l=3,d=a;break;case e.image_compression.MEDIUM:l=6,d=f;break;case e.image_compression.SLOW:l=9,d=u}t=o(t,r,s,d);var p=new Uint8Array(n(l)),y=i(t),b=new Deflater(l),v=b.append(t),g=b.flush(),m=p.length+v.length+g.length,w=new Uint8Array(m+4);return w.set(p),w.set(v,p.length),w.set(g,p.length+v.length),w[m++]=y>>>24&255,w[m++]=y>>>16&255,w[m++]=y>>>8&255,w[m++]=255&y,e.arrayBufferToBinaryString(w)},n=function(e,t){var r=Math.LOG2E*Math.log(32768)-8<<4|8,n=r<<8;return n|=Math.min(3,(t-1&255)>>1)<<6,n|=0,[r,255&(n+=31-n%31)]},i=function(e,t){for(var r,n=1,i=0,o=e.length,s=0;o>0;){o-=r=o>t?t:o;do{i+=n+=e[s++]}while(--r);n%=65521,i%=65521}return(i<<16|n)>>>0},o=function(e,t,r,n){for(var i,o,s,a=e.length/t,c=new Uint8Array(e.length+a),f=l(),u=0;u<a;u++){if(s=u*t,i=e.subarray(s,s+t),n)c.set(n(i,r,o),s+u);else{for(var h=0,p=f.length,y=[];h<p;h++)y[h]=f[h](i,r,o);var b=d(y.concat());c.set(y[b],s+u)}o=i}return c},s=function(e,t,r){var n=Array.apply([],e);return n.unshift(0),n},a=function(e,t,r){var n,i=[],o=0,s=e.length;for(i[0]=1;o<s;o++)n=e[o-t]||0,i[o+1]=e[o]-n+256&255;return i},c=function(e,t,r){var n,i=[],o=0,s=e.length;for(i[0]=2;o<s;o++)n=r&&r[o]||0,i[o+1]=e[o]-n+256&255;return i},f=function(e,t,r){var n,i,o=[],s=0,a=e.length;for(o[0]=3;s<a;s++)n=e[s-t]||0,i=r&&r[s]||0,o[s+1]=e[s]+256-(n+i>>>1)&255;return o},u=function(e,t,r){var n,i,o,s,a=[],c=0,f=e.length;for(a[0]=4;c<f;c++)n=e[c-t]||0,i=r&&r[c]||0,o=r&&r[c-t]||0,s=h(n,i,o),a[c+1]=e[c]-s+256&255;return a},h=function(e,t,r){var n=e+t-r,i=Math.abs(n-e),o=Math.abs(n-t),s=Math.abs(n-r);return i<=o&&i<=s?e:o<=s?t:r},l=function(){return[s,a,c,f,u]},d=function(e){for(var t,r,n,i=0,o=e.length;i<o;)((t=p(e[i].slice(1)))<r||!r)&&(r=t,n=i),i++;return n},p=function(e){for(var t=0,r=e.length,n=0;t<r;)n+=Math.abs(e[t++]);return n};e.processPNG=function(n,i,o,s,a){var c,f,u,h,l,d,p=this.color_spaces.DEVICE_RGB,y=this.decode.FLATE_DECODE,b=8;if(this.isString(n),this.isArrayBuffer(n)&&(n=new Uint8Array(n)),this.isArrayBufferView(n)){if("function"!=typeof PNG||"function"!=typeof FlateStream)throw new Error("PNG support requires png.js and zlib.js");if(n=(c=new PNG(n)).imgData,b=c.bits,p=c.colorSpace,h=c.colors,-1!==[4,6].indexOf(c.colorType)){if(8===c.bits)for(var v,g=(B=new(0,window["Uint"+c.pixelBitlength+"Array"])(c.decodePixels().buffer)).length,m=new Uint8Array(g*c.colors),w=new Uint8Array(g),_=c.pixelBitlength-c.bits,E=0,S=0;E<g;E++){for(k=B[E],v=0;v<_;)m[S++]=k>>>v&255,v+=c.bits;w[E]=k>>>v&255}if(16===c.bits){g=(B=new Uint32Array(c.decodePixels().buffer)).length,m=new Uint8Array(g*(32/c.pixelBitlength)*c.colors),w=new Uint8Array(g*(32/c.pixelBitlength));for(var k,A=c.colors>1,I=(E=0,S=0,0);E<g;)k=B[E++],m[S++]=k>>>0&255,A&&(m[S++]=k>>>16&255,k=B[E++],m[S++]=k>>>0&255),w[I++]=k>>>16&255;b=8}s!==e.image_compression.NONE&&t()?(n=r(m,c.width*c.colors,c.colors,s),d=r(w,c.width,1,s)):(n=m,d=w,y=null)}if(3===c.colorType&&(p=this.color_spaces.INDEXED,l=c.palette,c.transparency.indexed)){var x=c.transparency.indexed,T=0;for(E=0,g=x.length;E<g;++E)T+=x[E];if((T/=255)===g-1&&-1!==x.indexOf(0))u=[x.indexOf(0)];else if(T!==g){var B=c.decodePixels();for(w=new Uint8Array(B.length),E=0,g=B.length;E<g;E++)w[E]=x[B[E]];d=r(w,c.width,1)}}return f=y===this.decode.FLATE_DECODE?"/Predictor 15 /Colors "+h+" /BitsPerComponent "+b+" /Columns "+c.width:"/Colors "+h+" /BitsPerComponent "+b+" /Columns "+c.width,(this.isArrayBuffer(n)||this.isArrayBufferView(n))&&(n=this.arrayBufferToBinaryString(n)),(d&&this.isArrayBuffer(d)||this.isArrayBufferView(d))&&(d=this.arrayBufferToBinaryString(d)),this.createImageInfo(n,c.width,c.height,p,b,y,i,o,f,u,l,d)}return info}}(jsPDF.API);var DecodeStream=function(){function e(){this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=null}return e.prototype={ensureBuffer:function(e){var t=this.buffer,r=t?t.byteLength:0;if(e<r)return t;for(var n=512;n<e;)n<<=1;for(var i=new Uint8Array(n),o=0;o<r;++o)i[o]=t[o];return this.buffer=i},getByte:function(){for(var e=this.pos;this.bufferLength<=e;){if(this.eof)return null;this.readBlock()}return this.buffer[this.pos++]},getBytes:function(e){var t=this.pos;if(e){this.ensureBuffer(t+e);for(var r=t+e;!this.eof&&this.bufferLength<r;)this.readBlock();var n=this.bufferLength;r>n&&(r=n)}else{for(;!this.eof;)this.readBlock();r=this.bufferLength}return this.pos=r,this.buffer.subarray(t,r)},lookChar:function(){for(var e=this.pos;this.bufferLength<=e;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var e=this.pos;this.bufferLength<=e;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(e,t,r){for(var n=e+t;this.bufferLength<=n&&!this.eof;)this.readBlock();return new Stream(this.buffer,e,t,r)},skip:function(e){e||(e=1),this.pos+=e},reset:function(){this.pos=0}},e}(),FlateStream=function(){var e=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),t=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),r=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),n=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],i=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];function o(e){throw new Error(e)}function s(e){var t=0,r=e[t++],n=e[t++];-1!=r&&-1!=n||o("Invalid header in flate stream"),8!=(15&r)&&o("Unknown compression method in flate stream"),((r<<8)+n)%31!=0&&o("Bad FCHECK in flate stream"),32&n&&o("FDICT bit set in flate stream"),this.bytes=e,this.bytesPos=t,this.codeSize=0,this.codeBuf=0,DecodeStream.call(this)}return s.prototype=Object.create(DecodeStream.prototype),s.prototype.getBits=function(e){for(var t,r=this.codeSize,n=this.codeBuf,i=this.bytes,s=this.bytesPos;r<e;)void 0===(t=i[s++])&&o("Bad encoding in flate stream"),n|=t<<r,r+=8;return t=n&(1<<e)-1,this.codeBuf=n>>e,this.codeSize=r-=e,this.bytesPos=s,t},s.prototype.getCode=function(e){for(var t=e[0],r=e[1],n=this.codeSize,i=this.codeBuf,s=this.bytes,a=this.bytesPos;n<r;){var c;void 0===(c=s[a++])&&o("Bad encoding in flate stream"),i|=c<<n,n+=8}var f=t[i&(1<<r)-1],u=f>>16,h=65535&f;return(0==n||n<u||0==u)&&o("Bad encoding in flate stream"),this.codeBuf=i>>u,this.codeSize=n-u,this.bytesPos=a,h},s.prototype.generateHuffmanTable=function(e){for(var t=e.length,r=0,n=0;n<t;++n)e[n]>r&&(r=e[n]);for(var i=1<<r,o=new Uint32Array(i),s=1,a=0,c=2;s<=r;++s,a<<=1,c<<=1)for(var f=0;f<t;++f)if(e[f]==s){var u=0,h=a;for(n=0;n<s;++n)u=u<<1|1&h,h>>=1;for(n=u;n<i;n+=c)o[n]=s<<16|f;++a}return[o,r]},s.prototype.readBlock=function(){function s(e,t,r,n,i){for(var o=e.getBits(r)+n;o-- >0;)t[p++]=i}var a=this.getBits(3);if(1&a&&(this.eof=!0),0!=(a>>=1)){var c,f;if(1==a)c=n,f=i;else if(2==a){for(var u=this.getBits(5)+257,h=this.getBits(5)+1,l=this.getBits(4)+4,d=Array(e.length),p=0;p<l;)d[e[p++]]=this.getBits(3);for(var y=this.generateHuffmanTable(d),b=0,v=(p=0,u+h),g=new Array(v);p<v;){var m=this.getCode(y);16==m?s(this,g,2,3,b):17==m?s(this,g,3,3,b=0):18==m?s(this,g,7,11,b=0):g[p++]=b=m}c=this.generateHuffmanTable(g.slice(0,u)),f=this.generateHuffmanTable(g.slice(u,v))}else o("Unknown block type in flate stream");for(var w=(O=this.buffer)?O.length:0,_=this.bufferLength;;){var E=this.getCode(c);if(E<256)_+1>=w&&(w=(O=this.ensureBuffer(_+1)).length),O[_++]=E;else{if(256==E)return void(this.bufferLength=_);var S=(E=t[E-=257])>>16;S>0&&(S=this.getBits(S));b=(65535&E)+S;E=this.getCode(f),(S=(E=r[E])>>16)>0&&(S=this.getBits(S));var k=(65535&E)+S;_+b>=w&&(w=(O=this.ensureBuffer(_+b)).length);for(var A=0;A<b;++A,++_)O[_]=O[_-k]}}}else{var I,x=this.bytes,T=this.bytesPos;void 0===(I=x[T++])&&o("Bad block header in flate stream");var B=I;void 0===(I=x[T++])&&o("Bad block header in flate stream"),B|=I<<8,void 0===(I=x[T++])&&o("Bad block header in flate stream");var C=I;void 0===(I=x[T++])&&o("Bad block header in flate stream"),(C|=I<<8)!=(65535&~B)&&o("Bad uncompressed block length in flate stream"),this.codeBuf=0,this.codeSize=0;var P=this.bufferLength,O=this.ensureBuffer(P+B),M=P+B;this.bufferLength=M;for(var R=P;R<M;++R){if(void 0===(I=x[T++])){this.eof=!0;break}O[R]=I}this.bytesPos=T}},s}();(function(){var e;e=function(){var e,t,r;function n(e){var t,r,n,i,o,s,a,c,f,u,h,l,d,p;for(this.data=e,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},s=null;;){switch(t=this.readUInt32(),f=function(){var e,t;for(t=[],e=0;e<4;++e)t.push(String.fromCharCode(this.data[this.pos++]));return t}.call(this).join("")){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(t);break;case"fcTL":s&&this.animation.frames.push(s),this.pos+=4,s={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},o=this.readUInt16(),i=this.readUInt16()||100,s.delay=1e3*o/i,s.disposeOp=this.data[this.pos++],s.blendOp=this.data[this.pos++],s.data=[];break;case"IDAT":case"fdAT":for("fdAT"===f&&(this.pos+=4,t-=4),e=(null!=s?s.data:void 0)||this.imgData,l=0;0<=t?l<t:l>t;0<=t?++l:--l)e.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(n=this.palette.length/3,this.transparency.indexed=this.read(t),this.transparency.indexed.length>n)throw new Error("More transparent colors than palette size");if((u=n-this.transparency.indexed.length)>0)for(d=0;0<=u?d<u:d>u;0<=u?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(t)[0];break;case 2:this.transparency.rgb=this.read(t)}break;case"tEXt":a=(h=this.read(t)).indexOf(0),c=String.fromCharCode.apply(String,h.slice(0,a)),this.text[c]=String.fromCharCode.apply(String,h.slice(a+1));break;case"IEND":return s&&this.animation.frames.push(s),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(p=this.colorType)||6===p,r=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*r,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=t}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return n.load=function(e,t,r){var i;return"function"==typeof t&&(r=t),(i=new XMLHttpRequest).open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){var e;return e=new n(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=t?t.getContext:void 0)&&e.render(t),"function"==typeof r?r(e):void 0},i.send(null)},0,1,2,0,1,n.prototype.read=function(e){var t,r;for(r=[],t=0;0<=e?t<e:t>e;0<=e?++t:--t)r.push(this.data[this.pos++]);return r},n.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},n.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},n.prototype.decodePixels=function(e){var t,r,n,i,o,s,a,c,f,u,h,l,d,p,y,b,v,g,m,w,_,E,S;if(null==e&&(e=this.imgData),0===e.length)return new Uint8Array(0);for(e=(e=new FlateStream(e)).getBytes(),b=(l=this.pixelBitlength/8)*this.width,d=new Uint8Array(b*this.height),s=e.length,y=0,p=0,r=0;p<s;){switch(e[p++]){case 0:for(i=m=0;m<b;i=m+=1)d[r++]=e[p++];break;case 1:for(i=w=0;w<b;i=w+=1)t=e[p++],o=i<l?0:d[r-l],d[r++]=(t+o)%256;break;case 2:for(i=_=0;_<b;i=_+=1)t=e[p++],n=(i-i%l)/l,v=y&&d[(y-1)*b+n*l+i%l],d[r++]=(v+t)%256;break;case 3:for(i=E=0;E<b;i=E+=1)t=e[p++],n=(i-i%l)/l,o=i<l?0:d[r-l],v=y&&d[(y-1)*b+n*l+i%l],d[r++]=(t+Math.floor((o+v)/2))%256;break;case 4:for(i=S=0;S<b;i=S+=1)t=e[p++],n=(i-i%l)/l,o=i<l?0:d[r-l],0===y?v=g=0:(v=d[(y-1)*b+n*l+i%l],g=n&&d[(y-1)*b+(n-1)*l+i%l]),a=o+v-g,c=Math.abs(a-o),u=Math.abs(a-v),h=Math.abs(a-g),f=c<=u&&c<=h?o:u<=h?v:g,d[r++]=(t+f)%256;break;default:throw new Error("Invalid filter algorithm: "+e[p-1])}y++}return d},n.prototype.decodePalette=function(){var e,t,r,n,i,o,s,a,c;for(r=this.palette,o=this.transparency.indexed||[],i=new Uint8Array((o.length||0)+r.length),n=0,r.length,e=0,t=s=0,a=r.length;s<a;t=s+=3)i[n++]=r[t],i[n++]=r[t+1],i[n++]=r[t+2],i[n++]=null!=(c=o[e++])?c:255;return i},n.prototype.copyToImageData=function(e,t){var r,n,i,o,s,a,c,f,u,h,l;if(n=this.colors,u=null,r=this.hasAlphaChannel,this.palette.length&&(u=null!=(l=this._decodedPalette)?l:this._decodedPalette=this.decodePalette(),n=4,r=!0),f=(i=e.data||e).length,s=u||t,o=a=0,1===n)for(;o<f;)c=u?4*t[o/4]:a,h=s[c++],i[o++]=h,i[o++]=h,i[o++]=h,i[o++]=r?s[c++]:255,a=c;else for(;o<f;)c=u?4*t[o/4]:a,i[o++]=s[c++],i[o++]=s[c++],i[o++]=s[c++],i[o++]=r?s[c++]:255,a=c},n.prototype.decode=function(){var e;return e=new Uint8Array(this.width*this.height*4),this.copyToImageData(e,this.decodePixels()),e},t=document.createElement("canvas"),r=t.getContext("2d"),e=function(e){var n;return r.width=e.width,r.height=e.height,r.clearRect(0,0,e.width,e.height),r.putImageData(e,0,0),(n=new Image).src=t.toDataURL(),n},n.prototype.decodeFrames=function(t){var r,n,i,o,s,a,c,f;if(this.animation){for(f=[],n=s=0,a=(c=this.animation.frames).length;s<a;n=++s)r=c[n],i=t.createImageData(r.width,r.height),o=this.decodePixels(new Uint8Array(r.data)),this.copyToImageData(i,o),r.imageData=i,f.push(r.image=e(i));return f}},n.prototype.renderFrame=function(e,t){var r,n,i;return r=(n=this.animation.frames)[t],i=n[t-1],0===t&&e.clearRect(0,0,this.width,this.height),1===(null!=i?i.disposeOp:void 0)?e.clearRect(i.xOffset,i.yOffset,i.width,i.height):2===(null!=i?i.disposeOp:void 0)&&e.putImageData(i.imageData,i.xOffset,i.yOffset),0===r.blendOp&&e.clearRect(r.xOffset,r.yOffset,r.width,r.height),e.drawImage(r.image,r.xOffset,r.yOffset)},n.prototype.animate=function(e){var t,r,n,i,o,s,a=this;return r=0,s=this.animation,i=s.numFrames,n=s.frames,o=s.numPlays,(t=function(){var s,c;if(s=r++%i,c=n[s],a.renderFrame(e,s),i>1&&r/i<o)return a.animation._timeout=setTimeout(t,c.delay)})()},n.prototype.stopAnimation=function(){var e;return clearTimeout(null!=(e=this.animation)?e._timeout:void 0)},n.prototype.render=function(e){var t,r;return e._png&&e._png.stopAnimation(),e._png=this,e.width=this.width,e.height=this.height,t=e.getContext("2d"),this.animation?(this.decodeFrames(t),this.animate(t)):(r=t.createImageData(this.width,this.height),this.copyToImageData(r,this.decodePixels()),t.putImageData(r,0,0))},n}(),window.PNG=e}).call(this),function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).blocktrailSDK=e()}}(function(){var define,module,exports;return function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!a&&c)return c(s,!0);if(o)return o(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var u=r[s]={exports:{}};t[s][0].call(u.exports,function(e){return i(t[s][1][e]||e)},u,u.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}}()({1:[function(e,t,r){(function(r,Buffer){var n=e("lodash"),i=e("q"),o=e("bitcoinjs-lib"),s=e("bitcoinjs-message"),a=e("bip39"),c=e("./wallet"),f=e("./btccom.convert"),u=e("./blocktrail.convert"),h=e("./rest_client"),l=e("./encryption"),d=e("./keyderivation"),p=e("./encryption_mnemonic"),y=e("./blocktrail"),b=e("randombytes"),v=e("crypto-js"),g=e("./webworkifier");var m=e("./use-webworker")();function w(e,t){return t&&e.then(function(e){i.nextTick(function(){t(null,e)})},function(e){i.nextTick(function(){t(e,null)})}),e}var _=function(e){if(!(this instanceof _))return new _(e);var t,r=_.normalizeNetworkFromOptions(e);e.network=r[0],e.testnet=r[1],e.regtest=r[2],e.apiNetwork=e.apiNetwork||r[3],this.bitcoinCash="BCC"===e.network,this.regtest=e.regtest,this.testnet=e.testnet,this.network=(t=this).bitcoinCash?t.regtest?o.networks.bitcoincashregtest:t.testnet?o.networks.bitcoincashtestnet:o.networks.bitcoincash:t.regtest?o.networks.regtest:t.testnet?o.networks.testnet:o.networks.bitcoin,this.feeSanityCheck=void 0===e.feeSanityCheck||e.feeSanityCheck,this.feeSanityCheckBaseFeeMultiplier=e.feeSanityCheckBaseFeeMultiplier||200,e.apiNetwork=e.apiNetwork||(this.testnet?"t":"")+(e.network||"BTC").toUpperCase(),void 0===e.btccom&&(e.btccom=!0);var i=n.omit(e,"host");this.dataClient=_.initRestClient(i),this.blocktrailClient=_.initRestClient(n.merge({},e,{btccom:!1})),e.btccom?this.converter=new f(this.network,!0):this.converter=new u};_.normalizeNetworkFromOptions=function(e){var t,r="BTC",n=!1,i=!1,o=!1;if(e.network){var s=e.network.toLowerCase().match(/^([rt])?(btc|bch|bcc)$/);if(!s)throw new Error("Invalid network ["+e.network+"]");r="btc"===s[2]?"BTC":"BCC",(t=s[1])&&(o=!0,"r"===t?(n=!0,i=!0):"t"===t&&(n=!0))}return o||(e.regtest?(n=!0,i=!0,t="r"):e.testnet&&(n=!0,t="t")),[r,n,i,(t||"")+r]},_.updateHostOptions=function(e){return!e.btccom&&r.env.BLOCKTRAIL_SDK_API_ENDPOINT&&(e.host=r.env.BLOCKTRAIL_SDK_API_ENDPOINT),e.btccom&&r.env.BLOCKTRAIL_SDK_BTCCOM_API_ENDPOINT&&(e.host=r.env.BLOCKTRAIL_SDK_BTCCOM_API_ENDPOINT),e.btccom&&r.env.BLOCKTRAIL_SDK_THROTTLE_BTCCOM&&(e.throttleRequestsTimeout=r.env.BLOCKTRAIL_SDK_THROTTLE_BTCCOM),e.btccom?(e.host||(e.host=e.btccomhost||("BCC"===e.network?"bch-chain.api.btc.com":"chain.api.btc.com")),e.testnet&&!e.host.match(/tchain/)&&(e.host=e.host.replace(/chain/,"tchain")),e.endpoint||(e.endpoint=e.btccomendpoint||"/"+(e.apiVersion||"v3"))):(e.host||(e.host="wallet-api.btc.com"),e.endpoint||(e.endpoint="/"+(e.apiVersion||"v1")+(e.apiNetwork?"/"+e.apiNetwork:""))),e.host&&0===e.host.indexOf("https://")?(e.https=!0,e.host=e.host.substr(8)):e.host&&0===e.host.indexOf("http://")&&(e.https=!1,e.host=e.host.substr(7)),void 0===e.https&&(e.https=!0),e.port||(e.port=e.https?443:80),e},_.initRestClient=function(e){return e=_.updateHostOptions(e),new h(e)};var E=function(e){return i.when(e).then(function(e){return e.storePrimaryMnemonic&&(e.storeDataOnServer=e.storePrimaryMnemonic),void 0===e.storeDataOnServer&&(e.storeDataOnServer=!e.primarySeed),e})};_.prototype.promisedEncrypt=function(t,r,n){if(m&&"function"==typeof onLoadWorkerLoadAsmCrypto){var o=l.generateSalt(),s=l.generateIV();return g.workify(_.prototype.promisedEncrypt,function(){return e("./webworker")},onLoadWorkerLoadAsmCrypto,{method:"Encryption.encryptWithSaltAndIV",pt:t,pw:r,saltBuf:o,iv:s,iterations:n}).then(function(e){return Buffer.from(e.cipherText.buffer)})}try{return i.when(l.encrypt(t,r,n))}catch(e){return i.reject(e)}},_.prototype.promisedDecrypt=function(t,r){if(m&&"function"==typeof onLoadWorkerLoadAsmCrypto)return g.workify(_.prototype.promisedDecrypt,function(){return e("./webworker")},onLoadWorkerLoadAsmCrypto,{method:"Encryption.decrypt",ct:t,pw:r}).then(function(e){return Buffer.from(e.plainText.buffer)});try{return i.when(l.decrypt(t,r))}catch(e){return i.reject(e)}},_.prototype.produceEncryptedDataV3=function(e,t){var r=this;return i.when(e).then(function(e){return e.storeDataOnServer?i.when().then(function(){if(!e.secret){if(!e.passphrase)throw new y.WalletCreateError("Can't encrypt data without a passphrase");return t(_.CREATE_WALLET_PROGRESS_ENCRYPT_SECRET),e.secret=b(c.WALLET_ENTROPY_BITS/8),r.promisedEncrypt(e.secret,new Buffer(e.passphrase),d.defaultIterations).then(function(t){e.encryptedSecret=t})}if(!(e.secret instanceof Buffer))throw new Error("Secret must be a buffer")}).then(function(){return t(_.CREATE_WALLET_PROGRESS_ENCRYPT_PRIMARY),r.promisedEncrypt(e.primarySeed,e.secret,d.subkeyIterations).then(function(t){e.encryptedPrimarySeed=t})}).then(function(){if(!1!==e.recoverySecret)return t(_.CREATE_WALLET_PROGRESS_ENCRYPT_RECOVERY),e.recoverySecret||(e.recoverySecret=b(c.WALLET_ENTROPY_BITS/8)),r.promisedEncrypt(e.secret,e.recoverySecret,d.defaultIterations).then(function(t){e.recoveryEncryptedSecret=t})}).then(function(){return e}):e})};var S=function(e,t,r){return i.whe