UNPKG

lz4

Version:

LZ4 streaming compression and decompression

10 lines 107 kB
require=function t(e,r,i){function n(s,a){if(!r[s]){if(!e[s]){var h="function"==typeof require&&require;if(!a&&h)return h(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var f=r[s]={exports:{}};e[s][0].call(f.exports,(function(t){return n(e[s][1][t]||t)}),f,f.exports,t,e,r,i)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({"./utils":[function(t,e,r){var i=t("xxhashjs").h32;r.descriptorChecksum=function(t){return i(t,0).toNumber()>>8&255},r.blockChecksum=function(t){return i(t,0).toNumber()},r.streamChecksum=function(t,e){return null===t?e.digest().toNumber():(null===e&&(e=i(0)),e.update(t))},r.readUInt32LE=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},r.bindings=t("./binding")},{"./binding":1,xxhashjs:"xxhashjs"}],1:[function(t,e,r){t("cuint").UINT32;Math.imul||(Math.imul=function(t,e){var r=65535&t,i=65535&e;return r*i+((t>>>16)*i+r*(e>>>16)<<16)|0}),r.uncompress=function(t,e,r,i){for(var n=r=r||0,o=i=i||t.length-r,s=0;n<o;){var a=t[n++],h=a>>4;if(h>0){for(var u=h+240;255===u;)h+=u=t[n++];for(var f=n+h;n<f;)e[s++]=t[n++];if(n===o)return s}var l=t[n++]|t[n++]<<8;if(0===l||l>s)return-(n-2);var c=15&a;for(u=c+240;255===u;)c+=u=t[n++];var p=s-l;for(f=s+c+4;s<f;)e[s++]=e[p++]}return s};function i(t,e,i,n,o,s){var a=o,h=s-o,u=0;if(t.length>=2113929216)throw new Error("input too large");if(t.length>12){var f=r.compressBound(t.length);if(h<f)throw Error("output too small: "+h+" < "+f);for(var l=67,c=t.length-12;i+4<c;){var p=t[i+1]<<8|t[i],d=t[i+3]<<8|t[i+2],m=Math.imul(p|d<<16,2654435761)>>>16,y=n[m]-1;if(n[m]=i+1,y<0||i-y>>>16>0||(t[y+3]<<8|t[y+2])!=d||(t[y+1]<<8|t[y])!=p)i+=l++>>6;else{l=67;var g=i-u,_=i-y;y+=4;for(var b=i+=4;i<c&&t[i]==t[y];)i++,y++;var v=(b=i-b)<15?b:15;if(g>=15){e[a++]=240+v;for(var w=g-15;w>254;w-=255)e[a++]=255;e[a++]=w}else e[a++]=(g<<4)+v;for(var S=0;S<g;S++)e[a++]=t[u+S];if(e[a++]=_,e[a++]=_>>8,b>=15){for(b-=15;b>=255;)b-=255,e[a++]=255;e[a++]=b}u=i}}}if(0==u)return 0;if((g=t.length-u)>=15){e[a++]=240;for(var C=g-15;C>254;C-=255)e[a++]=255;e[a++]=C}else e[a++]=g<<4;for(i=u;i<t.length;)e[a++]=t[i++];return a}r.compressBound=function(t){return t>2113929216?0:t+t/255+16|0},r.compress=function(t,e,r,n){for(var o=new Array(65536),s=0;s<65536;s++)o[s]=0;return i(t,e,0,o,r||0,n||e.length)},r.compressHC=r.compress,r.compressDependent=i},{cuint:10}],2:[function(t,e,r){(function(e){(function(){var i=t("./decoder_stream");r.LZ4_uncompress=function(t,r){var n=[],o=new i(r);return o.on("data",(function(t){n.push(t)})),o.end(t),e.concat(n)}}).call(this)}).call(this,t("buffer").Buffer)},{"./decoder_stream":3,buffer:"buffer"}],3:[function(t,e,r){(function(r){(function(){var i=t("stream").Transform,n=t("util").inherits,o=t("./static"),s=o.utils,a=s.bindings,h=t("./binding"),u=o.STATES,f=o.SIZES;function l(t){if(!(this instanceof l))return new l(t);i.call(this,t),this.options=t||{},this.binding=this.options.useJS?h:a,this.buffer=null,this.pos=0,this.descriptor=null,this.state=u.MAGIC,this.notEnoughData=!1,this.descriptorStart=0,this.streamSize=null,this.dictId=null,this.currentStreamChecksum=null,this.dataBlockSize=0,this.skippableSize=0}n(l,i),l.prototype._transform=function(t,e,i){if(this.skippableSize>0){if(this.skippableSize-=t.length,this.skippableSize>0)return void i();t=t.slice(-this.skippableSize),this.skippableSize=0,this.state=u.MAGIC}this.buffer=this.buffer?r.concat([this.buffer,t],this.buffer.length+t.length):t,this._main(i)},l.prototype.emit_Error=function(t){this.emit("error",new Error(t+" @"+this.pos))},l.prototype.check_Size=function(t){var e=this.buffer.length-this.pos;return e<=0||e<t?(this.notEnoughData&&this.emit_Error("Unexpected end of LZ4 stream"),!0):(this.pos+=t,!1)},l.prototype.read_MagicNumber=function(){var t=this.pos;if(this.check_Size(f.MAGIC))return!0;var e=s.readUInt32LE(this.buffer,t);if((4294967280&e)!==o.MAGICNUMBER_SKIPPABLE)return e!==o.MAGICNUMBER?(this.pos=t,this.emit_Error("Invalid magic number: "+e.toString(16).toUpperCase()),!0):void(this.state=u.DESCRIPTOR);this.state=u.SKIP_SIZE},l.prototype.read_SkippableSize=function(){var t=this.pos;if(this.check_Size(f.SKIP_SIZE))return!0;this.state=u.SKIP_DATA,this.skippableSize=s.readUInt32LE(this.buffer,t)},l.prototype.read_Descriptor=function(){var t=this.pos;if(this.check_Size(f.DESCRIPTOR))return!0;this.descriptorStart=t;var e=this.buffer[t],r=e>>6;if(r!==o.VERSION)return this.pos=t,this.emit_Error("Invalid version: "+r+" != "+o.VERSION),!0;if(e>>1&1)return this.pos=t,this.emit_Error("Reserved bit set"),!0;var i=this.buffer[t+1]>>4&7,n=o.blockMaxSizes[i];if(null===n)return this.pos=t,this.emit_Error("Invalid block max size: "+i),!0;this.descriptor={blockIndependence:Boolean(e>>5&1),blockChecksum:Boolean(e>>4&1),blockMaxSize:n,streamSize:Boolean(e>>3&1),streamChecksum:Boolean(e>>2&1),dict:Boolean(1&e),dictId:0},this.state=u.SIZE},l.prototype.read_Size=function(){if(this.descriptor.streamSize){var t=this.pos;if(this.check_Size(f.SIZE))return!0;this.streamSize=this.buffer.slice(t,t+8)}this.state=u.DICTID},l.prototype.read_DictId=function(){if(this.descriptor.dictId){var t=this.pos;if(this.check_Size(f.DICTID))return!0;this.dictId=s.readUInt32LE(this.buffer,t)}this.state=u.DESCRIPTOR_CHECKSUM},l.prototype.read_DescriptorChecksum=function(){var t=this.pos;if(this.check_Size(f.DESCRIPTOR_CHECKSUM))return!0;var e=this.buffer[t];if(s.descriptorChecksum(this.buffer.slice(this.descriptorStart,t))!==e)return this.pos=t,this.emit_Error("Invalid stream descriptor checksum"),!0;this.state=u.DATABLOCK_SIZE},l.prototype.read_DataBlockSize=function(){var t=this.pos;if(this.check_Size(f.DATABLOCK_SIZE))return!0;var e=s.readUInt32LE(this.buffer,t);e!==o.EOS?(this.dataBlockSize=e,this.state=u.DATABLOCK_DATA):this.state=u.EOS},l.prototype.read_DataBlockData=function(){var t=this.pos,e=this.dataBlockSize;if(2147483648&e&&(e&=2147483647),this.check_Size(e))return!0;this.dataBlock=this.buffer.slice(t,t+e),this.state=u.DATABLOCK_CHECKSUM},l.prototype.read_DataBlockChecksum=function(){var t=this.pos;if(this.descriptor.blockChecksum){if(this.check_Size(f.DATABLOCK_CHECKSUM))return!0;var e=s.readUInt32LE(this.buffer,this.pos-4);if(s.blockChecksum(this.dataBlock)!==e)return this.pos=t,this.emit_Error("Invalid block checksum"),!0}this.state=u.DATABLOCK_UNCOMPRESS},l.prototype.uncompress_DataBlock=function(){var t;if(2147483648&this.dataBlockSize)t=this.dataBlock;else{t=r.alloc(this.descriptor.blockMaxSize);var e=this.binding.uncompress(this.dataBlock,t);if(e<0)return this.emit_Error("Invalid data block: "+-e),!0;e<this.descriptor.blockMaxSize&&(t=t.slice(0,e))}this.dataBlock=null,this.push(t),this.descriptor.streamChecksum&&(this.currentStreamChecksum=s.streamChecksum(t,this.currentStreamChecksum)),this.state=u.DATABLOCK_SIZE},l.prototype.read_EOS=function(){if(this.descriptor.streamChecksum){var t=this.pos;if(this.check_Size(f.EOS))return!0;var e=s.readUInt32LE(this.buffer,t);if(e!==s.streamChecksum(null,this.currentStreamChecksum))return this.pos=t,this.emit_Error("Invalid stream checksum: "+e.toString(16).toUpperCase()),!0}this.state=u.MAGIC},l.prototype._flush=function(t){this.notEnoughData=!0,this._main(t)},l.prototype._main=function(t){for(var e,r=this.pos;!e&&this.pos<this.buffer.length;)this.state===u.MAGIC&&(e=this.read_MagicNumber()),this.state===u.SKIP_SIZE&&(e=this.read_SkippableSize()),this.state===u.DESCRIPTOR&&(e=this.read_Descriptor()),this.state===u.SIZE&&(e=this.read_Size()),this.state===u.DICTID&&(e=this.read_DictId()),this.state===u.DESCRIPTOR_CHECKSUM&&(e=this.read_DescriptorChecksum()),this.state===u.DATABLOCK_SIZE&&(e=this.read_DataBlockSize()),this.state===u.DATABLOCK_DATA&&(e=this.read_DataBlockData()),this.state===u.DATABLOCK_CHECKSUM&&(e=this.read_DataBlockChecksum()),this.state===u.DATABLOCK_UNCOMPRESS&&(e=this.uncompress_DataBlock()),this.state===u.EOS&&(e=this.read_EOS());this.pos>r&&(this.buffer=this.buffer.slice(this.pos),this.pos=0),t()},e.exports=l}).call(this)}).call(this,t("buffer").Buffer)},{"./binding":1,"./static":6,buffer:"buffer",stream:35,util:40}],4:[function(t,e,r){(function(e){(function(){var i=t("./encoder_stream");r.LZ4_compress=function(t,r){var n=[],o=new i(r);return o.on("data",(function(t){n.push(t)})),o.end(t),e.concat(n)}}).call(this)}).call(this,t("buffer").Buffer)},{"./encoder_stream":5,buffer:"buffer"}],5:[function(t,e,r){(function(r){(function(){var i=t("stream").Transform,n=t("util").inherits,o=t("./static"),s=o.utils,a=s.bindings,h=t("./binding"),u=o.STATES,f=o.SIZES,l={blockIndependence:!0,blockChecksum:!1,blockMaxSize:4<<20,streamSize:!1,streamChecksum:!0,dict:!1,dictId:0,highCompression:!1};function c(t){if(!(this instanceof c))return new c(t);i.call(this,t);var e=t||l;e!==l&&Object.keys(l).forEach((function(t){e.hasOwnProperty(t)||(e[t]=l[t])})),this.options=e,this.binding=this.options.useJS?h:a,this.compress=e.highCompression?this.binding.compressHC:this.binding.compress;var r=0;r|=o.VERSION<<6,r|=(1&e.blockIndependence)<<5,r|=(1&e.blockChecksum)<<4,r|=(1&e.streamSize)<<3,r|=(1&e.streamChecksum)<<2,r|=1&e.dict;var n=o.blockMaxSizes.indexOf(e.blockMaxSize);if(n<0)throw new Error("Invalid blockMaxSize: "+e.blockMaxSize);this.descriptor={flg:r,bd:(7&n)<<4},this.buffer=[],this.length=0,this.first=!0,this.checksum=null}n(c,i),c.prototype.headerSize=function(){var t=this.options.streamSize?f.DESCRIPTOR:0,e=this.options.dict?f.DICTID:0;return f.MAGIC+1+1+t+e+1},c.prototype.header=function(){var t=this.headerSize(),e=r.alloc(t);this.state=u.MAGIC,e.writeInt32LE(o.MAGICNUMBER,0),this.state=u.DESCRIPTOR;var i=e.slice(f.MAGIC,e.length-1);i.writeUInt8(this.descriptor.flg,0),i.writeUInt8(this.descriptor.bd,1);var n=2;return this.state=u.SIZE,this.options.streamSize&&(i.writeInt32LE(0,n),i.writeInt32LE(this.size,n+4),n+=f.SIZE),this.state=u.DICTID,this.options.dict&&(i.writeInt32LE(this.dictId,n),n+=f.DICTID),this.state=u.DESCRIPTOR_CHECKSUM,e.writeUInt8(s.descriptorChecksum(i),f.MAGIC+n),e},c.prototype.update_Checksum=function(t){this.state=u.CHECKSUM_UPDATE,this.options.streamChecksum&&(this.checksum=s.streamChecksum(t,this.checksum))},c.prototype.compress_DataBlock=function(t){this.state=u.DATABLOCK_COMPRESS;var e=this.options.blockChecksum?f.DATABLOCK_CHECKSUM:0,i=this.binding.compressBound(t.length),n=r.alloc(f.DATABLOCK_SIZE+i+e),o=n.slice(f.DATABLOCK_SIZE,f.DATABLOCK_SIZE+i),a=this.compress(t,o);(this.state=u.DATABLOCK_SIZE,a>0&&a<=this.options.blockMaxSize?(n.writeUInt32LE(a,0),n=n.slice(0,f.DATABLOCK_SIZE+a+e)):(n.writeInt32LE(2147483648|t.length,0),n=n.slice(0,f.DATABLOCK_SIZE+t.length+e),t.copy(n,f.DATABLOCK_SIZE)),this.state=u.DATABLOCK_CHECKSUM,this.options.blockChecksum)&&n.slice(-e).writeInt32LE(s.blockChecksum(o),0);return this.update_Checksum(t),this.size+=t.length,n},c.prototype._transform=function(t,e,i){t&&(this.buffer.push(t),this.length+=t.length),this.first&&(this.push(this.header()),this.first=!1);var n=this.options.blockMaxSize;if(this.length<n)return i();for(var o=r.concat(this.buffer,this.length),s=0,a=o.length;a>=n;a-=n,s+=n)this.push(this.compress_DataBlock(o.slice(s,s+n)));a>0?(this.buffer=[o.slice(s)],this.length=this.buffer[0].length):(this.buffer=[],this.length=0),i()},c.prototype._flush=function(t){if(this.first&&(this.push(this.header()),this.first=!1),this.length>0){var e=r.concat(this.buffer,this.length);this.buffer=[],this.length=0;var i=this.compress_DataBlock(e);this.push(i)}if(this.options.streamChecksum)this.state=u.CHECKSUM,(n=r.alloc(f.EOS+f.CHECKSUM)).writeUInt32LE(s.streamChecksum(null,this.checksum),f.EOS);else var n=r.alloc(f.EOS);this.state=u.EOS,n.writeInt32LE(o.EOS,0),this.push(n),t()},e.exports=c}).call(this)}).call(this,t("buffer").Buffer)},{"./binding":1,"./static":6,buffer:"buffer",stream:35,util:40}],6:[function(t,e,r){(function(e){(function(){r.MAGICNUMBER=407708164,r.MAGICNUMBER_BUFFER=e.alloc(4),r.MAGICNUMBER_BUFFER.writeUInt32LE(r.MAGICNUMBER,0),r.EOS=0,r.EOS_BUFFER=e.alloc(4),r.EOS_BUFFER.writeUInt32LE(r.EOS,0),r.VERSION=1,r.MAGICNUMBER_SKIPPABLE=407710288,r.blockMaxSizes=[null,null,null,null,65536,262144,1<<20,4<<20],r.extension=".lz4",r.STATES={MAGIC:0,DESCRIPTOR:1,SIZE:2,DICTID:3,DESCRIPTOR_CHECKSUM:4,DATABLOCK_SIZE:5,DATABLOCK_DATA:6,DATABLOCK_CHECKSUM:7,DATABLOCK_UNCOMPRESS:8,DATABLOCK_COMPRESS:9,CHECKSUM:10,CHECKSUM_UPDATE:11,EOS:90,SKIP_SIZE:101,SKIP_DATA:102},r.SIZES={MAGIC:4,DESCRIPTOR:2,SIZE:8,DICTID:4,DESCRIPTOR_CHECKSUM:1,DATABLOCK_SIZE:4,DATABLOCK_CHECKSUM:4,CHECKSUM:4,EOS:4,SKIP_SIZE:4},r.utils=t("./utils")}).call(this)}).call(this,t("buffer").Buffer)},{"./utils":"./utils",buffer:"buffer"}],7:[function(t,e,r){"use strict";r.byteLength=function(t){var e=u(t),r=e[0],i=e[1];return 3*(r+i)/4-i},r.toByteArray=function(t){var e,r,i=u(t),s=i[0],a=i[1],h=new o(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),f=0,l=a>0?s-4:s;for(r=0;r<l;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],h[f++]=e>>16&255,h[f++]=e>>8&255,h[f++]=255&e;2===a&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,h[f++]=255&e);1===a&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,h[f++]=e>>8&255,h[f++]=255&e);return h},r.fromByteArray=function(t){for(var e,r=t.length,n=r%3,o=[],s=0,a=r-n;s<a;s+=16383)o.push(f(t,s,s+16383>a?a:s+16383));1===n?(e=t[r-1],o.push(i[e>>2]+i[e<<4&63]+"==")):2===n&&(e=(t[r-2]<<8)+t[r-1],o.push(i[e>>10]+i[e>>4&63]+i[e<<2&63]+"="));return o.join("")};for(var i=[],n=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,h=s.length;a<h;++a)i[a]=s[a],n[s.charCodeAt(a)]=a;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function f(t,e,r){for(var n,o,s=[],a=e;a<r;a+=3)n=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(i[(o=n)>>18&63]+i[o>>12&63]+i[o>>6&63]+i[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},{}],8:[function(t,e,r){},{}],9:[function(t,e,r){(function(t){(function(){function e(t){return Object.prototype.toString.call(t)}r.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===e(t)},r.isBoolean=function(t){return"boolean"==typeof t},r.isNull=function(t){return null===t},r.isNullOrUndefined=function(t){return null==t},r.isNumber=function(t){return"number"==typeof t},r.isString=function(t){return"string"==typeof t},r.isSymbol=function(t){return"symbol"==typeof t},r.isUndefined=function(t){return void 0===t},r.isRegExp=function(t){return"[object RegExp]"===e(t)},r.isObject=function(t){return"object"==typeof t&&null!==t},r.isDate=function(t){return"[object Date]"===e(t)},r.isError=function(t){return"[object Error]"===e(t)||t instanceof Error},r.isFunction=function(t){return"function"==typeof t},r.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},r.isBuffer=t.isBuffer}).call(this)}).call(this,{isBuffer:t("../../is-buffer/index.js")})},{"../../is-buffer/index.js":16}],10:[function(t,e,r){r.UINT32=t("./lib/uint32"),r.UINT64=t("./lib/uint64")},{"./lib/uint32":11,"./lib/uint64":12}],11:[function(t,e,r){!function(t){r(Math.pow(36,5)),r(Math.pow(16,7)),r(Math.pow(10,9)),r(Math.pow(2,30)),r(36),r(16),r(10),r(2);function r(t,e){return this instanceof r?(this._low=0,this._high=0,this.remainder=null,void 0===e?n.call(this,t):"string"==typeof t?o.call(this,t,e):void i.call(this,t,e)):new r(t,e)}function i(t,e){return this._low=0|t,this._high=0|e,this}function n(t){return this._low=65535&t,this._high=t>>>16,this}function o(t,e){var r=parseInt(t,e||10);return this._low=65535&r,this._high=r>>>16,this}r.prototype.fromBits=i,r.prototype.fromNumber=n,r.prototype.fromString=o,r.prototype.toNumber=function(){return 65536*this._high+this._low},r.prototype.toString=function(t){return this.toNumber().toString(t||10)},r.prototype.add=function(t){var e=this._low+t._low,r=e>>>16;return r+=this._high+t._high,this._low=65535&e,this._high=65535&r,this},r.prototype.subtract=function(t){return this.add(t.clone().negate())},r.prototype.multiply=function(t){var e,r,i=this._high,n=this._low,o=t._high,s=t._low;return e=(r=n*s)>>>16,e+=i*s,e&=65535,e+=n*o,this._low=65535&r,this._high=65535&e,this},r.prototype.div=function(t){if(0==t._low&&0==t._high)throw Error("division by zero");if(0==t._high&&1==t._low)return this.remainder=new r(0),this;if(t.gt(this))return this.remainder=this.clone(),this._low=0,this._high=0,this;if(this.eq(t))return this.remainder=new r(0),this._low=1,this._high=0,this;for(var e=t.clone(),i=-1;!this.lt(e);)e.shiftLeft(1,!0),i++;for(this.remainder=this.clone(),this._low=0,this._high=0;i>=0;i--)e.shiftRight(1),this.remainder.lt(e)||(this.remainder.subtract(e),i>=16?this._high|=1<<i-16:this._low|=1<<i);return this},r.prototype.negate=function(){var t=1+(65535&~this._low);return this._low=65535&t,this._high=~this._high+(t>>>16)&65535,this},r.prototype.equals=r.prototype.eq=function(t){return this._low==t._low&&this._high==t._high},r.prototype.greaterThan=r.prototype.gt=function(t){return this._high>t._high||!(this._high<t._high)&&this._low>t._low},r.prototype.lessThan=r.prototype.lt=function(t){return this._high<t._high||!(this._high>t._high)&&this._low<t._low},r.prototype.or=function(t){return this._low|=t._low,this._high|=t._high,this},r.prototype.and=function(t){return this._low&=t._low,this._high&=t._high,this},r.prototype.not=function(){return this._low=65535&~this._low,this._high=65535&~this._high,this},r.prototype.xor=function(t){return this._low^=t._low,this._high^=t._high,this},r.prototype.shiftRight=r.prototype.shiftr=function(t){return t>16?(this._low=this._high>>t-16,this._high=0):16==t?(this._low=this._high,this._high=0):(this._low=this._low>>t|this._high<<16-t&65535,this._high>>=t),this},r.prototype.shiftLeft=r.prototype.shiftl=function(t,e){return t>16?(this._high=this._low<<t-16,this._low=0,e||(this._high&=65535)):16==t?(this._high=this._low,this._low=0):(this._high=this._high<<t|this._low>>16-t,this._low=this._low<<t&65535,e||(this._high&=65535)),this},r.prototype.rotateLeft=r.prototype.rotl=function(t){var e=this._high<<16|this._low;return e=e<<t|e>>>32-t,this._low=65535&e,this._high=e>>>16,this},r.prototype.rotateRight=r.prototype.rotr=function(t){var e=this._high<<16|this._low;return e=e>>>t|e<<32-t,this._low=65535&e,this._high=e>>>16,this},r.prototype.clone=function(){return new r(this._low,this._high)},"undefined"!=typeof define&&define.amd?define([],(function(){return r})):void 0!==e&&e.exports?e.exports=r:t.UINT32=r}(this)},{}],12:[function(t,e,r){!function(t){var r={16:n(Math.pow(16,5)),10:n(Math.pow(10,5)),2:n(Math.pow(2,5))},i={16:n(16),10:n(10),2:n(2)};function n(t,e,r,i){return this instanceof n?(this.remainder=null,"string"==typeof t?a.call(this,t,e):void 0===e?s.call(this,t):void o.apply(this,arguments)):new n(t,e,r,i)}function o(t,e,r,i){return void 0===r?(this._a00=65535&t,this._a16=t>>>16,this._a32=65535&e,this._a48=e>>>16,this):(this._a00=0|t,this._a16=0|e,this._a32=0|r,this._a48=0|i,this)}function s(t){return this._a00=65535&t,this._a16=t>>>16,this._a32=0,this._a48=0,this}function a(t,e){e=e||10,this._a00=0,this._a16=0,this._a32=0,this._a48=0;for(var i=r[e]||new n(Math.pow(e,5)),o=0,s=t.length;o<s;o+=5){var a=Math.min(5,s-o),h=parseInt(t.slice(o,o+a),e);this.multiply(a<5?new n(Math.pow(e,a)):i).add(new n(h))}return this}n.prototype.fromBits=o,n.prototype.fromNumber=s,n.prototype.fromString=a,n.prototype.toNumber=function(){return 65536*this._a16+this._a00},n.prototype.toString=function(t){var e=i[t=t||10]||new n(t);if(!this.gt(e))return this.toNumber().toString(t);for(var r=this.clone(),o=new Array(64),s=63;s>=0&&(r.div(e),o[s]=r.remainder.toNumber().toString(t),r.gt(e));s--);return o[s-1]=r.toNumber().toString(t),o.join("")},n.prototype.add=function(t){var e=this._a00+t._a00,r=e>>>16,i=(r+=this._a16+t._a16)>>>16,n=(i+=this._a32+t._a32)>>>16;return n+=this._a48+t._a48,this._a00=65535&e,this._a16=65535&r,this._a32=65535&i,this._a48=65535&n,this},n.prototype.subtract=function(t){return this.add(t.clone().negate())},n.prototype.multiply=function(t){var e=this._a00,r=this._a16,i=this._a32,n=this._a48,o=t._a00,s=t._a16,a=t._a32,h=e*o,u=h>>>16,f=(u+=e*s)>>>16;u&=65535,f+=(u+=r*o)>>>16;var l=(f+=e*a)>>>16;return f&=65535,l+=(f+=r*s)>>>16,f&=65535,l+=(f+=i*o)>>>16,l+=e*t._a48,l&=65535,l+=r*a,l&=65535,l+=i*s,l&=65535,l+=n*o,this._a00=65535&h,this._a16=65535&u,this._a32=65535&f,this._a48=65535&l,this},n.prototype.div=function(t){if(0==t._a16&&0==t._a32&&0==t._a48){if(0==t._a00)throw Error("division by zero");if(1==t._a00)return this.remainder=new n(0),this}if(t.gt(this))return this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0,this;if(this.eq(t))return this.remainder=new n(0),this._a00=1,this._a16=0,this._a32=0,this._a48=0,this;for(var e=t.clone(),r=-1;!this.lt(e);)e.shiftLeft(1,!0),r++;for(this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0;r>=0;r--)e.shiftRight(1),this.remainder.lt(e)||(this.remainder.subtract(e),r>=48?this._a48|=1<<r-48:r>=32?this._a32|=1<<r-32:r>=16?this._a16|=1<<r-16:this._a00|=1<<r);return this},n.prototype.negate=function(){var t=1+(65535&~this._a00);return this._a00=65535&t,t=(65535&~this._a16)+(t>>>16),this._a16=65535&t,t=(65535&~this._a32)+(t>>>16),this._a32=65535&t,this._a48=~this._a48+(t>>>16)&65535,this},n.prototype.equals=n.prototype.eq=function(t){return this._a48==t._a48&&this._a00==t._a00&&this._a32==t._a32&&this._a16==t._a16},n.prototype.greaterThan=n.prototype.gt=function(t){return this._a48>t._a48||!(this._a48<t._a48)&&(this._a32>t._a32||!(this._a32<t._a32)&&(this._a16>t._a16||!(this._a16<t._a16)&&this._a00>t._a00))},n.prototype.lessThan=n.prototype.lt=function(t){return this._a48<t._a48||!(this._a48>t._a48)&&(this._a32<t._a32||!(this._a32>t._a32)&&(this._a16<t._a16||!(this._a16>t._a16)&&this._a00<t._a00))},n.prototype.or=function(t){return this._a00|=t._a00,this._a16|=t._a16,this._a32|=t._a32,this._a48|=t._a48,this},n.prototype.and=function(t){return this._a00&=t._a00,this._a16&=t._a16,this._a32&=t._a32,this._a48&=t._a48,this},n.prototype.xor=function(t){return this._a00^=t._a00,this._a16^=t._a16,this._a32^=t._a32,this._a48^=t._a48,this},n.prototype.not=function(){return this._a00=65535&~this._a00,this._a16=65535&~this._a16,this._a32=65535&~this._a32,this._a48=65535&~this._a48,this},n.prototype.shiftRight=n.prototype.shiftr=function(t){return(t%=64)>=48?(this._a00=this._a48>>t-48,this._a16=0,this._a32=0,this._a48=0):t>=32?(t-=32,this._a00=65535&(this._a32>>t|this._a48<<16-t),this._a16=this._a48>>t&65535,this._a32=0,this._a48=0):t>=16?(t-=16,this._a00=65535&(this._a16>>t|this._a32<<16-t),this._a16=65535&(this._a32>>t|this._a48<<16-t),this._a32=this._a48>>t&65535,this._a48=0):(this._a00=65535&(this._a00>>t|this._a16<<16-t),this._a16=65535&(this._a16>>t|this._a32<<16-t),this._a32=65535&(this._a32>>t|this._a48<<16-t),this._a48=this._a48>>t&65535),this},n.prototype.shiftLeft=n.prototype.shiftl=function(t,e){return(t%=64)>=48?(this._a48=this._a00<<t-48,this._a32=0,this._a16=0,this._a00=0):t>=32?(t-=32,this._a48=this._a16<<t|this._a00>>16-t,this._a32=this._a00<<t&65535,this._a16=0,this._a00=0):t>=16?(t-=16,this._a48=this._a32<<t|this._a16>>16-t,this._a32=65535&(this._a16<<t|this._a00>>16-t),this._a16=this._a00<<t&65535,this._a00=0):(this._a48=this._a48<<t|this._a32>>16-t,this._a32=65535&(this._a32<<t|this._a16>>16-t),this._a16=65535&(this._a16<<t|this._a00>>16-t),this._a00=this._a00<<t&65535),e||(this._a48&=65535),this},n.prototype.rotateLeft=n.prototype.rotl=function(t){if(0==(t%=64))return this;if(t>=32){var e=this._a00;if(this._a00=this._a32,this._a32=e,e=this._a48,this._a48=this._a16,this._a16=e,32==t)return this;t-=32}var r=this._a48<<16|this._a32,i=this._a16<<16|this._a00,n=r<<t|i>>>32-t,o=i<<t|r>>>32-t;return this._a00=65535&o,this._a16=o>>>16,this._a32=65535&n,this._a48=n>>>16,this},n.prototype.rotateRight=n.prototype.rotr=function(t){if(0==(t%=64))return this;if(t>=32){var e=this._a00;if(this._a00=this._a32,this._a32=e,e=this._a48,this._a48=this._a16,this._a16=e,32==t)return this;t-=32}var r=this._a48<<16|this._a32,i=this._a16<<16|this._a00,n=r>>>t|i<<32-t,o=i>>>t|r<<32-t;return this._a00=65535&o,this._a16=o>>>16,this._a32=65535&n,this._a48=n>>>16,this},n.prototype.clone=function(){return new n(this._a00,this._a16,this._a32,this._a48)},"undefined"!=typeof define&&define.amd?define([],(function(){return n})):void 0!==e&&e.exports?e.exports=n:t.UINT64=n}(this)},{}],13:[function(t,e,r){var i=Object.create||function(t){var e=function(){};return e.prototype=t,new e},n=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return r},o=Function.prototype.bind||function(t){var e=this;return function(){return e.apply(t,arguments)}};function s(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=i(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}e.exports=s,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._maxListeners=void 0;var a,h=10;try{var u={};Object.defineProperty&&Object.defineProperty(u,"x",{value:0}),a=0===u.x}catch(t){a=!1}function f(t){return void 0===t._maxListeners?s.defaultMaxListeners:t._maxListeners}function l(t,e,r){if(e)t.call(r);else for(var i=t.length,n=w(t,i),o=0;o<i;++o)n[o].call(r)}function c(t,e,r,i){if(e)t.call(r,i);else for(var n=t.length,o=w(t,n),s=0;s<n;++s)o[s].call(r,i)}function p(t,e,r,i,n){if(e)t.call(r,i,n);else for(var o=t.length,s=w(t,o),a=0;a<o;++a)s[a].call(r,i,n)}function d(t,e,r,i,n,o){if(e)t.call(r,i,n,o);else for(var s=t.length,a=w(t,s),h=0;h<s;++h)a[h].call(r,i,n,o)}function m(t,e,r,i){if(e)t.apply(r,i);else for(var n=t.length,o=w(t,n),s=0;s<n;++s)o[s].apply(r,i)}function y(t,e,r,n){var o,s,a;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((s=t._events)?(s.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),a=s[e]):(s=t._events=i(null),t._eventsCount=0),a){if("function"==typeof a?a=s[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),!a.warned&&(o=f(t))&&o>0&&a.length>o){a.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(e)+'" listeners added. Use emitter.setMaxListeners() to increase limit.');h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",h.name,h.message)}}else a=s[e]=r,++t._eventsCount;return t}function g(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),e=0;e<t.length;++e)t[e]=arguments[e];this.listener.apply(this.target,t)}}function _(t,e,r){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},n=o.call(g,i);return n.listener=r,i.wrapFn=n,n}function b(t,e,r){var i=t._events;if(!i)return[];var n=i[e];return n?"function"==typeof n?r?[n.listener||n]:[n]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(n):w(n,n.length):[]}function v(t){var e=this._events;if(e){var r=e[t];if("function"==typeof r)return 1;if(r)return r.length}return 0}function w(t,e){for(var r=new Array(e),i=0;i<e;++i)r[i]=t[i];return r}a?Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return h},set:function(t){if("number"!=typeof t||t<0||t!=t)throw new TypeError('"defaultMaxListeners" must be a positive number');h=t}}):s.defaultMaxListeners=h,s.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},s.prototype.getMaxListeners=function(){return f(this)},s.prototype.emit=function(t){var e,r,i,n,o,s,a="error"===t;if(s=this._events)a=a&&null==s.error;else if(!a)return!1;if(a){if(arguments.length>1&&(e=arguments[1]),e instanceof Error)throw e;var h=new Error('Unhandled "error" event. ('+e+")");throw h.context=e,h}if(!(r=s[t]))return!1;var u="function"==typeof r;switch(i=arguments.length){case 1:l(r,u,this);break;case 2:c(r,u,this,arguments[1]);break;case 3:p(r,u,this,arguments[1],arguments[2]);break;case 4:d(r,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(n=new Array(i-1),o=1;o<i;o++)n[o-1]=arguments[o];m(r,u,this,n)}return!0},s.prototype.addListener=function(t,e){return y(this,t,e,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(t,e){return y(this,t,e,!0)},s.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,_(this,t,e)),this},s.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,_(this,t,e)),this},s.prototype.removeListener=function(t,e){var r,n,o,s,a;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=i(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,s=r.length-1;s>=0;s--)if(r[s]===e||r[s].listener===e){a=r[s].listener,o=s;break}if(o<0)return this;0===o?r.shift():function(t,e){for(var r=e,i=r+1,n=t.length;i<n;r+=1,i+=1)t[r]=t[i];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),n.removeListener&&this.emit("removeListener",t,a||e)}return this},s.prototype.removeAllListeners=function(t){var e,r,o;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=i(null),this._eventsCount=0):r[t]&&(0==--this._eventsCount?this._events=i(null):delete r[t]),this;if(0===arguments.length){var s,a=n(r);for(o=0;o<a.length;++o)"removeListener"!==(s=a[o])&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=i(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(e)for(o=e.length-1;o>=0;o--)this.removeListener(t,e[o]);return this},s.prototype.listeners=function(t){return b(this,t,!0)},s.prototype.rawListeners=function(t){return b(this,t,!1)},s.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):v.call(t,e)},s.prototype.listenerCount=v,s.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]}},{}],14:[function(t,e,r){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ r.read=function(t,e,r,i,n){var o,s,a=8*n-i-1,h=(1<<a)-1,u=h>>1,f=-7,l=r?n-1:0,c=r?-1:1,p=t[e+l];for(l+=c,o=p&(1<<-f)-1,p>>=-f,f+=a;f>0;o=256*o+t[e+l],l+=c,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=i;f>0;s=256*s+t[e+l],l+=c,f-=8);if(0===o)o=1-u;else{if(o===h)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,i),o-=u}return(p?-1:1)*s*Math.pow(2,o-i)},r.write=function(t,e,r,i,n,o){var s,a,h,u=8*o-n-1,f=(1<<u)-1,l=f>>1,c=23===n?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:o-1,d=i?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=f):(s=Math.floor(Math.log(e)/Math.LN2),e*(h=Math.pow(2,-s))<1&&(s--,h*=2),(e+=s+l>=1?c/h:c*Math.pow(2,1-l))*h>=2&&(s++,h/=2),s+l>=f?(a=0,s=f):s+l>=1?(a=(e*h-1)*Math.pow(2,n),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,n),s=0));n>=8;t[r+p]=255&a,p+=d,a/=256,n-=8);for(s=s<<n|a,u+=n;u>0;t[r+p]=255&s,p+=d,s/=256,u-=8);t[r+p-d]|=128*m}},{}],15:[function(t,e,r){"function"==typeof Object.create?e.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},{}],16:[function(t,e,r){function i(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)} /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh <https://feross.org> * @license MIT */ e.exports=function(t){return null!=t&&(i(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&i(t.slice(0,0))}(t)||!!t._isBuffer)}},{}],17:[function(t,e,r){var i={}.toString;e.exports=Array.isArray||function(t){return"[object Array]"==i.call(t)}},{}],18:[function(t,e,r){(function(t){(function(){"use strict";void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,i,n){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,r)}));case 3:return t.nextTick((function(){e.call(null,r,i)}));case 4:return t.nextTick((function(){e.call(null,r,i,n)}));default:for(o=new Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return t.nextTick((function(){e.apply(null,o)}))}}}:e.exports=t}).call(this)}).call(this,t("_process"))},{_process:19}],19:[function(t,e,r){var i,n,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function h(t){if(i===setTimeout)return setTimeout(t,0);if((i===s||!i)&&setTimeout)return i=setTimeout,setTimeout(t,0);try{return i(t,0)}catch(e){try{return i.call(null,t,0)}catch(e){return i.call(this,t,0)}}}!function(){try{i="function"==typeof setTimeout?setTimeout:s}catch(t){i=s}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(t){n=a}}();var u,f=[],l=!1,c=-1;function p(){l&&u&&(l=!1,u.length?f=u.concat(f):c=-1,f.length&&d())}function d(){if(!l){var t=h(p);l=!0;for(var e=f.length;e;){for(u=f,f=[];++c<e;)u&&u[c].run();c=-1,e=f.length}u=null,l=!1,function(t){if(n===clearTimeout)return clearTimeout(t);if((n===a||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(t);try{n(t)}catch(e){try{return n.call(null,t)}catch(e){return n.call(this,t)}}}(t)}}function m(t,e){this.fun=t,this.array=e}function y(){}o.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];f.push(new m(t,e)),1!==f.length||l||h(d)},m.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(t){return[]},o.binding=function(t){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(t){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},{}],20:[function(t,e,r){e.exports=t("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":21}],21:[function(t,e,r){"use strict";var i=t("process-nextick-args"),n=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};e.exports=l;var o=Object.create(t("core-util-is"));o.inherits=t("inherits");var s=t("./_stream_readable"),a=t("./_stream_writable");o.inherits(l,s);for(var h=n(a.prototype),u=0;u<h.length;u++){var f=h[u];l.prototype[f]||(l.prototype[f]=a.prototype[f])}function l(t){if(!(this instanceof l))return new l(t);s.call(this,t),a.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",c)}function c(){this.allowHalfOpen||this._writableState.ended||i.nextTick(p,this)}function p(t){t.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}),l.prototype._destroy=function(t,e){this.push(null),this.end(),i.nextTick(e,t)}},{"./_stream_readable":23,"./_stream_writable":25,"core-util-is":9,inherits:15,"process-nextick-args":18}],22:[function(t,e,r){"use strict";e.exports=o;var i=t("./_stream_transform"),n=Object.create(t("core-util-is"));function o(t){if(!(this instanceof o))return new o(t);i.call(this,t)}n.inherits=t("inherits"),n.inherits(o,i),o.prototype._transform=function(t,e,r){r(null,t)}},{"./_stream_transform":24,"core-util-is":9,inherits:15}],23:[function(t,e,r){(function(r,i){(function(){"use strict";var n=t("process-nextick-args");e.exports=b;var o,s=t("isarray");b.ReadableState=_;t("events").EventEmitter;var a=function(t,e){return t.listeners(e).length},h=t("./internal/streams/stream"),u=t("safe-buffer").Buffer,f=i.Uint8Array||function(){};var l=Object.create(t("core-util-is"));l.inherits=t("inherits");var c=t("util"),p=void 0;p=c&&c.debuglog?c.debuglog("stream"):function(){};var d,m=t("./internal/streams/BufferList"),y=t("./internal/streams/destroy");l.inherits(b,h);var g=["error","close","destroy","pause","resume"];function _(e,r){e=e||{};var i=r instanceof(o=o||t("./_stream_duplex"));this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var n=e.highWaterMark,s=e.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:i&&(s||0===s)?s:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(d||(d=t("string_decoder/").StringDecoder),this.decoder=new d(e.encoding),this.encoding=e.encoding)}function b(e){if(o=o||t("./_stream_duplex"),!(this instanceof b))return new b(e);this._readableState=new _(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),h.call(this)}function v(t,e,r,i,n){var o,s=t._readableState;null===e?(s.reading=!1,function(t,e){if(e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,C(t)}(t,s)):(n||(o=function(t,e){var r;i=e,u.isBuffer(i)||i instanceof f||"string"==typeof e||void 0===e||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var i;return r}(s,e)),o?t.emit("error",o):s.objectMode||e&&e.length>0?("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),i?s.endEmitted?t.emit("error",new Error("stream.unshift() after end event")):w(t,s,e,!0):s.ended?t.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?w(t,s,e,!1):E(t,s)):w(t,s,e,!1))):i||(s.reading=!1));return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(s)}function w(t,e,r,i){e.flowing&&0===e.length&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&C(t)),E(t,e)}Object.defineProperty(b.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),b.prototype.destroy=y.destroy,b.prototype._undestroy=y.undestroy,b.prototype._destroy=function(t,e){this.push(null),e(t)},b.prototype.push=function(t,e){var r,i=this._readableState;return i.objectMode?r=!0:"string"==typeof t&&((e=e||i.defaultEncoding)!==i.encoding&&(t=u.from(t,e),e=""),r=!0),v(this,t,e,!1,r)},b.prototype.unshift=function(t){return v(this,t,null,!0,!1)},b.prototype.isPaused=function(){return!1===this._readableState.flowing},b.prototype.setEncoding=function(e){return d||(d=t("string_decoder/").StringDecoder),this._readableState.decoder=new d(e),this._readableState.encoding=e,this};function S(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function C(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(p("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?n.nextTick(A,t):A(t))}function A(t){p("emit readable"),t.emit("readable"),B(t)}function E(t,e){e.readingMore||(e.readingMore=!0,n.nextTick(x,t,e))}function x(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(p("maybeReadMore read 0"),t.read(0),r!==e.length);)r=e.length;e.readingMore=!1}function k(t){p("readable nexttick read 0"),t.read(0)}function T(t,e){e.reading||(p("resume read 0"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit("resume"),B(t),e.flowing&&!e.reading&&t.read(0)}function B(t){var e=t._readableState;for(p("flow",e.flowing);e.flowing&&null!==t.read(););}function I(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var i;t<e.head.data.length?(i=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):i=t===e.head.data.length?e.shift():r?function(t,e){var r=e.head,i=1,n=r.data;t-=n.length;for(;r=r.next;){var o=r.data,s=t>o.length?o.length:t;if(s===o.length?n+=o:n+=o.slice(0,t),0===(t-=s)){s===o.length?(++i,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=o.slice(s));break}++i}return e.length-=i,n}(t,e):function(t,e){var r=u.allocUnsafe(t),i=e.head,n=1;i.data.copy(r),t-=i.data.length;for(;i=i.next;){var o=i.data,s=t>o.length?o.length:t;if(o.copy(r,r.length-t,0,s),0===(t-=s)){s===o.length?(++n,i.next?e.head=i.next:e.head=e.tail=null):(e.head=i,i.data=o.slice(s));break}++n}return e.length-=n,r}(t,e);return i}(t,e.buffer,e.decoder),r);var r}function M(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,n.nextTick(L,e,t))}function L(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function O(t,e){for(var r=0,i=t.length;r<i;r++)if(t[r]===e)return r;return-1}b.prototype.read=function(t){p("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return p("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?M(this):C(this),null;if(0===(t=S(t,e))&&e.ended)return 0===e.length&&M(this),null;var i,n=e.needReadable;return p("need readable",n),(0===e.length||e.length-t<e.highWaterMark)&&p("length less than watermark",n=!0),e.ended||e.reading?p("reading or ended",n=!1):n&&(p("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=S(r,e))),null===(i=t>0?I(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&M(this)),null!==i&&this.emit("data",i),i},b.prototype._read=function(t){this.emit("error",new Error("_read() is not implemented"))},b.prototype.pipe=function(t,e){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,p("pipe count=%d opts=%j",o.pipesCount,e);var h=(!e||!1!==e.end)&&t!==r.stdout&&t!==r.stderr?f:b;function u(e,r){p("onunpipe"),e===i&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,p("cleanup"),t.removeListener("close",g),t.removeListener("finish",_),t.removeListener("drain",l),t.removeListener("error",y),t.removeListener("unpipe",u),i.removeListener("end",f),i.removeListener("end",b),i.removeListener("data",m),c=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||l())}function f(){p("onend"),t.end()}o.endEmitted?n.nextTick(h):i.once("end",h),t.on("unpipe",u);var l=function(t){return function(){var e=t._readableState;p("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&a(t,"data")&&(e.flowing=!0,B(t))}}(i);t.on("drain",l);var c=!1;var d=!1;function m(e){p("ondata"),d=!1,!1!==t.write(e)||d||((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==O(o.pipes,t))&&!c&&(p("false write response, pause",i._readableState.awaitDrain),i._readableState.awaitDrain++,d=!0),i.pause())}function y(e){p("onerror",e),b(),t.removeListener("error",y),0===a(t,"error")&&t.emit("error",e)}function g(){t.removeListener("finish",_),b()}function _(){p("onfinish"),t.removeListener("close",g),b()}function b(){p("unpipe"),i.unpipe(t)}return i.on("data",m),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?s(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",y),t.once("close",g),t.once("finish",_),t.emit("pipe",i),o.flowing||(p("pipe resume"),i.resume()),t},b.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var i=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<n;o++)i[o].emit("unpipe",this,r);return this}var s=O(e.pipes,t);return-1===s||(e.pipes.splice(s,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},b.prototype.on=function(t,e){var r=h.prototype.on.call(this,t,e);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var i=this._readableState;i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&C(this):n.nextTick(k,this))}return r},b.prototype.addListener=b.prototype.on,b.prototype.resume=function(){var t=this._readableState;return t.flowing||(p("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,n.nextTick(T,t,e))}(this,t)),this},b.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this},b.prototype.wrap=function(t){var e=this,r=this._readableState,i=!1;for(var n in t.on("end",(function(){if(p("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(n){(p("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(e.push(n)||(i=!0,t.pause()))})),t)void 0===this[n]&&"function"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var o=0;o<g.length;o++)t.on(g[o],this.emit.bind(this,g[o]));return this._read=function(e){p("wrapped _read",e),i&&(i=!1,t.resume())},this},Object.defineProperty(b.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),b._fromList=I}).call(this)}).call(this,t("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_stream_duplex":21,"./internal/streams/BufferList":26,"./internal/streams/destroy":27,"./internal/streams/stream":28,_process:19,"core-util-is":9,events:13,inherits:15,isarray:17,"process-nextick-args":18,"safe-buffer":29,"string_decoder/":30,util:8}],24:[function(t,e,r){"use strict";e.exports=s;var i=t("./_stream_duplex"),n=Object.create(t("core-util-is"));function o(t,e){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(!i)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=e&&this.push(e),i(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function s(t){if(!(this instanceof s))return new s(t);i.call(this,t),this._transformState={afterTransform:o.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",a)}function a(){var t=this;"function"==typeof this._flush?this._flush((function(e,r){h(t,e,r)})):h(this,null,null)}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(t._transformState.transforming)throw new Error("Calling transform done when still transforming");return t.push(null)}n.inherits=t("inherits"),n.inherits(s,i),s.prototype.push=function(t,e){return this._transformState.needTransform=!1,i.prototype.push.call(this,t,e)},s.prototype._transform=function(t,e,r){throw new Error("_transform() is not implemented")},s.prototype._write=function(t,e,r){var i=this._transformState;if(i.writecb=r,i.writechunk=t,i.writeencoding=e,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},s.prototype._read=function(t){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},s.prototype._destroy=function(t,e){var r=this;i.prototype._destroy.call(this,t,(function(t){e(t),r