text: (function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.WebTorrent=e()}})(function(){var e,t,r;return function n(e,t,r){function i(s,a){if(!t[s]){if(!e[s]){var f=typeof require=="function"&&require;if(!a&&f)return f(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[s]={exports:{}};e[s][0].call(c.exports,function(t){var r=e[s][1][t];return i(r?r:t)},c,c.exports,n,e,t,r)}return t[s].exports}var o=typeof require=="function"&&require;for(var s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,r){t.exports=f;var n=e("debug")("webtorrent:file-stream");var i=e("inherits");var o=e("path");var s=e("stream");var a=e("./media-stream");i(f,s.Readable);function f(e,t){var r=this;if(!(r instanceof f))return new f(e,t);s.Readable.call(r,t);n("new filestream %s",JSON.stringify(t));if(!t)t={};if(!t.start)t.start=0;if(!t.end)t.end=e.length-1;r.length=t.end-t.start+1;var i=t.start+e.offset;var a=t.pieceLength;r.startPiece=i/a|0;r.endPiece=(t.end+e.offset)/a|0;r._extname=o.extname(e.name);r._storage=e.storage;r._piece=r.startPiece;r._missing=r.length;r._reading=false;r._notifying=false;r._destroyed=false;r._criticalLength=Math.min(1024*1024/a|0,2);r._offset=i-r.startPiece*a}f.prototype._read=function(){n("_read");var e=this;if(e._reading)return;e._reading=true;e.notify()};f.prototype.notify=function(){n("notify");var e=this;if(!e._reading||e._missing===0)return;if(!e._storage.bitfield.get(e._piece)){return e._storage.emit("critical",e._piece,e._piece+e._criticalLength)}if(e._notifying)return;e._notifying=true;var t=e._piece;n("before read %s",t);e._storage.read(e._piece++,function(r,i){n("after read %s (length %s) (err %s)",t,i.length,r&&r.message);e._notifying=false;if(e._destroyed)return;if(r){e._storage.emit("error",r);return e.destroy(r)}if(e._offset){i=i.slice(e._offset);e._offset=0}if(e._missing<i.length){i=i.slice(0,e._missing)}e._missing-=i.length;n("pushing buffer of length %s",i.length);e._reading=false;e.push(i);if(e._missing===0)e.push(null)})};f.prototype.pipe=function(e){var t=this;var r=s.Readable.prototype.pipe;if(e&&(e.nodeName==="VIDEO"||e.nodeName==="AUDIO")){var n={".webm":'video/webm; codecs="vorbis,vp8"',".mp4":'video/mp4; codecs="avc1.42c01e,mp4a.40.2"',".mp3":"audio/mpeg"}[t._extname];return r.call(t,new a(e,{type:n}))}else{return r.call(t,e)}};f.prototype.destroy=function(){var e=this;if(e._destroyed)return;e._destroyed=true}},{"./media-stream":2,debug:86,inherits:94,path:40,stream:57}],2:[function(e,t,r){t.exports=f;var n=e("debug")("webtorrent:media-stream");var i=e("inherits");var o=e("once");var s=e("stream");var a=typeof window!=="undefined"&&window.MediaSource;i(f,s.Writable);function f(e,t){var r=this;if(!(r instanceof f))return new f(e,t);s.Writable.call(r,t);if(!a)throw new Error("web browser lacks MediaSource support");r.media=e;t=t||{};t.type=t.type||'video/webm; codecs="vorbis,vp8"';n("new mediastream %s %s",e,JSON.stringify(t));r._mediaSource=new a;r._sourceBuffer=null;r._cb=null;r.media.src=window.URL.createObjectURL(r._mediaSource);var i=o(function(){r._sourceBuffer=r._mediaSource.addSourceBuffer(t.type);r._sourceBuffer.addEventListener("updateend",r._flow.bind(r));r._flow()});r._mediaSource.addEventListener("webkitsourceopen",i,false);r._mediaSource.addEventListener("sourceopen",i,false);r.on("finish",function(){n("finish");r._mediaSource.endOfStream()});window.vs=r}f.prototype._write=function(e,t,r){var i=this;if(!i._sourceBuffer){i._cb=function(n){if(n)return r(n);i._write(e,t,r)};return}if(i._sourceBuffer.updating){return r(new Error("Cannot append buffer while source buffer updating"))}i._sourceBuffer.appendBuffer(e);n("appendBuffer %s",e.length);i._cb=r};f.prototype._flow=function(){var e=this;n("flow");if(e._cb){e._cb(null)}}},{debug:86,inherits:94,once:98,stream:57}],3:[function(e,t,r){t.exports=n;function n(e,t){var r=this;r.swarm=e;r.numPieces=t;function n(e){e.on("have",function(e){r.pieces[e]++});e.on("bitfield",r.recalculate.bind(r));e.on("close",function(){for(var t=0;t<r.numPieces;++t){r.pieces[t]-=e.peerPieces.get(t)}})}r.swarm.wires.forEach(n);r.swarm.on("wire",function(e){r.recalculate();n(e)});r.recalculate()}n.prototype.recalculate=function(){var e=this;e.pieces=[];for(var t=0;t<e.numPieces;++t){e.pieces[t]=0}e.swarm.wires.forEach(function(t){for(var r=0;r<e.numPieces;++r){e.pieces[r]+=t.peerPieces.get(r)}})};n.prototype.getRarestPiece=function(e){var t=this;var r=[];var n=Infinity;e=e||function(){return true};for(var i=0;i<t.numPieces;++i){if(!e(i))continue;var o=t.pieces[i];if(o===n){r.push(i)}else if(o<n){r=[i];n=o}}if(r.length>0){return r[Math.random()*r.length|0]}else{return-1}}},{}],4:[function(e,t,r){(function(r,n,i){t.exports=E;var o=e("bitfield");var s=e("block-stream");var a=e("debug")("webtorrent:storage");var f=e("dezalgo");var u=e("end-of-stream");var c=e("events").EventEmitter;var l=e("./file-stream");var h=e("inherits");var d=e("multistream");var p=e("once");var g=e("simple-sha1");var v=16*1024;var m=0;var y=1;var _=2;function w(){}h(b,c);function b(e,t,r,n){var i=this;c.call(i);if(!a.enabled)i.setMaxListeners(0);i.index=e;i.hash=t;i.noVerify=!!n;if(typeof r==="number"){i.buffer=null;i.length=r}else{i.buffer=r;i.length=r.length}i._reset()}b.prototype.readBlock=function(e,t,r){var n=this;r=f(r);if(!n.buffer||!n._verifyOffset(e)){return r(new Error("invalid block offset "+e))}r(null,n.buffer.slice(e,e+t))};b.prototype.writeBlock=function(e,t,r){var n=this;r=f(r);if(!n._verifyOffset(e)||!n._verifyBlock(e,t)){return r(new Error("invalid block "+e+":"+t.length))}n._lazyAllocBuffer();var i=e/v;if(n.blocks[i]===_){return r(null)}t.copy(n.buffer,e);n.blocks[i]=_;n.blocksWritten+=1;if(n.blocksWritten===n.blocks.length){n.verify()}r(null)};b.prototype.reserveBlock=function(e){var t=this;var r=t.blocks.length;for(var n=0;n<r;n++){if(t.blocks[n]&&!e||t.blocks[n]===_){continue}t.blocks[n]=y;return{offset:n*v,length:n===r-1?t.length-n*v:v}}return null};b.prototype.cancelBlock=function(e){var t=this;if(!t._verifyOffset(e)){return false}var r=e/v;if(t.blocks[r]===y){t.blocks[r]=m}return true};b.prototype._reset=function(){var e=this;e.verified=false;e.blocks=new i(Math.ceil(e.length/v));e.blocks.fill(0);e.blocksWritten=0};b.prototype.verify=function(e){var t=this;e=e||t.buffer;if(t.verified||!e){return}if(t.noVerify){t.verified=true;r();return}g(e,function(e){t.verified=e===t.hash;r()});function r(){if(t.verified){t.emit("done")}else{t.emit("warning",new Error("piece "+t.index+" failed verification"));t._reset()}}};b.prototype._verifyOffset=function(e){var t=this;if(e%v===0){return true}else{t.emit("warning",new Error("invalid block offset "+e+", not multiple of "+v));return false}};b.prototype._verifyBlock=function(e,t){var r=this;if(t.length===v){return true}else if(t.length===r.length-e&&r.length-e<v){return true}else{r.emit("warning",new Error("invalid block size "+t.length));return false}};b.prototype._lazyAllocBuffer=function(){var e=this;if(!e.buffer){e.buffer=new i(e.length)}};h(k,c);function k(e,t,r,n){var i=this;c.call(i);if(!a.enabled)i.setMaxListeners(0);i.storage=e;i.name=t.name;i.path=t.path;i.length=t.length;i.offset=t.offset;i.pieces=r;i.pieceLength=n;i.done=false;i.pieces.forEach(function(e){e.on("done",function(){i._checkDone()})});i._checkDone()}k.prototype.select=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var r=e.pieces[e.pieces.length-1].index;e.storage.emit("select",t,r,false)}};k.prototype.deselect=function(){var e=this;if(e.pieces.length>0){var t=e.pieces[0].index;var r=e.pieces[e.pieces.length-1].index;e.storage.emit("deselect",t,r,false)}};k.prototype.createReadStream=function(e){var t=this;if(!e)e={};if(e.pieceLength==null)e.pieceLength=t.pieceLength;var r=new l(t,e);t.storage.emit("select",r.startPiece,r.endPiece,true,r.notify.bind(r));u(r,function(){t.storage.emit("deselect",r.startPiece,r.endPiece,true)});return r};k.prototype.getBlobURL=function(e){var t=this;if(n.URL===undefined||n.Blob===undefined){return e(new Error("file.getBlobURL requires window.URL window.Blob support"))}t.getBuffer(function(t,r){if(t)return e(t);var i=n.URL.createObjectURL(new n.Blob([r]));e(null,i)})};k.prototype.getBuffer=function(e){var t=this;var r=new i(t.length);var n=0;t.createReadStream().on("data",function(e){e.copy(r,n);n+=e.length}).on("end",function(){e(null,r)})};k.prototype._checkDone=function(){var e=this;e.done=e.pieces.every(function(e){return e.verified});if(e.done){r.nextTick(function(){e.emit("done")})}};h(E,c);function E(e,t){var r=this;c.call(r);if(!a.enabled)r.setMaxListeners(0);if(!t)t={};r.bitfield=new o(e.pieces.length);r.done=false;r.closed=false;r.readonly=true;if(!t.nobuffer){r.buffer=new i(e.length)}var n=r.pieceLength=e.pieceLength;var s=e.lastPieceLength;var f=e.pieces.length;r.pieces=e.pieces.map(function(e,i){var o=i*n;var a=o+(i===f-1?s:n);var u=r.buffer?r.buffer.slice(o,a):a-o;var c=new b(i,e,u,!!t.noVerify);c.on("done",r._onPieceDone.bind(r,c));return c});r.files=e.files.map(function(e){var t=e.offset;var i=t+e.length-1;var o=t/n|0;var s=i/n|0;var a=r.pieces.slice(o,s+1);var f=new k(r,e,a,n);f.on("done",r._onFileDone.bind(r,f));return f})}E.BLOCK_LENGTH=v;E.prototype.load=function(e,t){var r=this;if(!Array.isArray(e))e=[e];t=p(t||function(){});r.once("done",function(){t(null)});var n=0;new d(e).pipe(new s(r.pieceLength,{nopad:true})).on("data",function(e){var t=n;n+=1;var i=0;var o=new s(v,{nopad:true});o.on("data",function(e){var n=i*v;i+=1;r.writeBlock(t,n,e)});o.end(e)}).on("error",t)};Object.defineProperty(E.prototype,"downloaded",{get:function(){var e=this;return e.pieces.reduce(function(e,t){return e+(t.verified?t.length:t.blocksWritten*v)},0)}});Object.defineProperty(E.prototype,"numMissing",{get:function(){var e=this;var t=e.pieces.length;for(var r=0,n=e.pieces.length;r<n;r++){t-=e.bitfield.get(r)}return t}});E.prototype.readBlock=function(e,t,r,n){var i=this;n=f(n);var o=i.pieces[e];if(!o)return n(new Error("invalid piece index "+e));o.readBlock(t,r,n)};E.prototype.writeBlock=function(e,t,r,n){var i=this;if(!n)n=w;n=f(n);if(i.readonly)return n(new Error("cannot write to readonly storage"));var o=i.pieces[e];if(!o)return n(new Error("invalid piece index "+e));o.writeBlock(t,r,n)};E.prototype.read=function(e,t,r,n){var o=this;if(typeof t==="function"){n=r;r=t;t=null}r=f(r);var s=o.pieces[e];if(!s){return r(new Error("invalid piece index "+e))}if(!s.verified&&!n){return r(new Error("Storage.read called on incomplete piece "+e))}var a=0;var u=s.length;if(t){a=t.offset||0;u=t.length||u}if(s.buffer){return r(null,s.buffer.slice(a,a+u))}var c=[];function l(){if(u<=0)return r(null,i.concat(c));var t=a;var n=Math.min(v,u);a+=n;u-=n;o.readBlock(e,t,n,function(e,t){if(e)return r(e);c.push(t);l()})}l()};E.prototype.reserveBlock=function(e,t){var r=this;var n=r.pieces[e];if(!n)return null;return n.reserveBlock(t)};E.prototype.cancelBlock=function(e,t){var r=this;var n=r.pieces[e];if(!n)return false;return n.cancelBlock(t)};E.prototype.remove=function(e){if(e)f(e)(null)};E.prototype.close=function(e){var t=this;t.closed=true;if(e)f(e)(null)};E.prototype._onPieceDone=function(e){var t=this;t.bitfield.set(e.index);a("piece done "+e.index+" ("+t.numMissing+" still missing)");t.emit("piece",e)};E.prototype._onFileDone=function(e){var t=this;a("file done "+e.name);t.emit("file",e);t._checkDone()};E.prototype._checkDone=function(){var e=this;if(!e.done&&e.files.every(function(e){return e.done})){e.done=true;e.emit("done")}}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./file-stream":1,_process:41,bitfield:6,"block-stream":30,buffer:34,debug:86,dezalgo:89,"end-of-stream":92,events:38,inherits:94,multistream:95,once:98,"simple-sha1":117}],5:[function(e,t,r){(function(r){t.exports=L;var n=e("addr-to-ip-port");var i=e("create-torrent");var o=e("debug")("webtorrent:torrent");var s=e("torrent-discovery");var a=e("events").EventEmitter;var f=e("fs");var u=e("simple-get");var c=e("inherits");var l=e("run-parallel");var h=e("parse-torrent");var d=e("re-emitter");var p=e("bittorrent-swarm");var g=e("ut_metadata");var v=e("ut_pex");var m=e("./rarity-map");var y=e("./server");var _=e("./storage");var w=128*1024;var b=1e4;var k=5e3;var E=3*_.BLOCK_LENGTH;var x=.5;var S=1;var A=1e4;var I=2;function C(){}c(L,a);function L(e,t){var n=this;a.call(n);if(!o.enabled)n.setMaxListeners(0);o("new torrent");n.opts=t;n.client=t.client;n.hotswapEnabled="hotswap"in t?t.hotswap:true;n.verify=t.verify;n.chokeTimeout=t.chokeTimeout||k;n.pieceTimeout=t.pieceTimeout||b;n.strategy=t.strategy||"sequential";n._rechokeNumSlots=t.uploads===false||t.uploads===0?0:+t.uploads||10;n._rechokeOptimisticWire=null;n._rechokeOptimisticTime=0;n._rechokeIntervalId=null;n.ready=false;n.files=[];n.metadata=null;n.parsedTorrent=null;n.storage=null;n.numBlockedPeers=0;n._amInterested=false;n._destroyed=false;n._selections=[];n._critical=[];n._storageImpl=t.storage||_;var s;try{s=e&&e.parsedTorrent||h(e)}catch(c){}if(s&&s.infoHash){l(s)}else if(typeof u==="function"&&/^https?:/.test(e)){u.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,t){if(e){e=new Error("Error downloading torrent: "+e.message);return n.emit("error",e)}l(t)})}else if(typeof f.readFile==="function"){f.readFile(e,function(e,t){if(e)return n.emit("error",new Error("Invalid torrent identifier"));l(t)})}else throw new Error("Invalid torrent identifier");function l(e){try{n.parsedTorrent=h(e)}catch(t){return n.emit("error",new Error("Malformed torrent data: "+t.message))}n.infoHash=n.parsedTorrent.infoHash;if(!n.infoHash){return n.emit("error",new Error("Malformed torrent data: Missing info hash."))}if(n.parsedTorrent.name)n.name=n.parsedTorrent.name;if(n.parsedTorrent.announce.length===0){n.parsedTorrent.announceList=i.announceList;n.parsedTorrent.announce=[].concat.apply([],i.announceList)}n.swarm=new p(n.infoHash,n.client.peerId,{handshake:{dht:!!n.client.dht}});d(n.swarm,n,["warning","error"]);n.swarm.on("wire",n._onWire.bind(n));n.swarm.on("download",n.client.downloadSpeed.bind(n.client));n.swarm.on("upload",n.client.uploadSpeed.bind(n.client));n.swarm.listen(n.client.torrentPort,n._onSwarmListening.bind(n));r.nextTick(function(){n.emit("infoHash")})}}Object.defineProperty(L.prototype,"length",{get:function(){return this.parsedTorrent&&this.parsedTorrent.length||0}});Object.defineProperty(L.prototype,"timeRemaining",{get:function(){if(this.swarm.downloadSpeed()===0)return Infinity;else return(this.length-this.downloaded)/this.swarm.downloadSpeed()*1e3}});Object.defineProperty(L.prototype,"progress",{get:function(){return this.parsedTorrent&&this.downloaded/this.parsedTorrent.length||0}});Object.defineProperty(L.prototype,"downloaded",{get:function(){return this.storage&&this.storage.downloaded||0}});Object.defineProperty(L.prototype,"uploaded",{get:function(){return this.swarm.uploaded}});Object.defineProperty(L.prototype,"ratio",{get:function(){return this.uploaded&&this.downloaded/this.uploaded||0}});Object.defineProperty(L.prototype,"magnetURI",{get:function(){return h.toMagnetURI(this.parsedTorrent)}});L.prototype._onSwarmListening=function(){var e=this;if(e._destroyed)return;if(e.swarm.server)e.client.torrentPort=e.swarm.address().port;e.discovery=new s({announce:e.parsedTorrent.announce,dht:e.client.dht,tracker:e.client.tracker,peerId:e.client.peerId,port:e.client.torrentPort,rtcConfig:e.client._rtcConfig,wrtc:e.client._wrtc});e.discovery.setTorrent(e.infoHash);e.discovery.on("peer",e.addPeer.bind(e));d(e.discovery,e,["dhtAnnounce","warning","error"]);if(e.parsedTorrent.info)e._onMetadata(e.parsedTorrent);e.emit("listening",e.client.torrentPort)};L.prototype._onMetadata=function(e){var t=this;if(t.metadata||t._destroyed)return;o("got metadata");if(e&&e.infoHash){t.metadata=h.toTorrentFile(e);t.parsedTorrent=e}else{t.metadata=e;try{t.parsedTorrent=h(t.metadata)}catch(n){return t.emit("error",n)}}t.name=t.parsedTorrent.name;t.discovery.setTorrent(t.parsedTorrent);t.rarityMap=new m(t.swarm,t.parsedTorrent.pieces.length);t.storage=new t._storageImpl(t.parsedTorrent,t.opts);t.storage.on("piece",t._onStoragePiece.bind(t));t.storage.on("file",function(e){t.emit("file",e)});t._reservations=t.storage.pieces.map(function(){return[]});t.storage.on("done",function(){if(t.discovery.tracker)t.discovery.tracker.complete();o("torrent "+t.infoHash+" done");t.emit("done")});t.storage.on("select",t.select.bind(t));t.storage.on("deselect",t.deselect.bind(t));t.storage.on("critical",t.critical.bind(t));t.storage.files.forEach(function(e){t.files.push(e)});t.swarm.wires.forEach(function(e){if(e.ut_metadata)e.ut_metadata.setMetadata(t.metadata);t._onWireWithMetadata(e)});if(t.verify){r.nextTick(function(){o("verifying existing torrent data");var e=0;var r=0;l(t.storage.pieces.map(function(n){return function(i){t.storage.read(n.index,function(s,a){e+=1;t.emit("verifying",{percentDone:100*e/t.storage.pieces.length,percentVerified:100*r/t.storage.pieces.length});if(!s&&a){n.verify(a);r+=n.verified;o("piece "+(n.verified?"verified":"invalid")+" "+n.index)}i()},true)}}),t._onStorage.bind(t))})}else{r.nextTick(t._onStorage.bind(t))}r.nextTick(function(){t.emit("metadata")})};L.prototype.destroy=function(e){var t=this;o("destroy");t._destroyed=true;clearInterval(t._rechokeIntervalId);var r=[];if(t.swarm)r.push(function(e){t.swarm.destroy(e)});if(t.discovery)r.push(function(e){t.discovery.stop(e)});if(t.storage)r.push(function(e){t.storage.close(e)});l(r,e)};L.prototype.addPeer=function(e){var t=this;if(typeof e==="string"&&t.client.blocked&&t.client.blocked.contains(n(e)[0])){t.numBlockedPeers+=1;t.emit("blockedPeer",e);return false}else{t.emit("peer",e);t.swarm.addPeer(e);return true}};L.prototype.select=function(e,t,r,n){var i=this;if(e>t||e<0||t>=i.storage.pieces.length){throw new Error("invalid selection ",e,":",t)}r=Number(r)||0;o("select %s-%s (priority %s)",e,t,r);i._selections.push({from:e,to:t,offset:0,priority:r,notify:n||C});i._selections.sort(function(e,t){return t.priority-e.priority});i._updateSelections()};L.prototype.deselect=function(e,t,r){var n=this;r=Number(r)||0;o("deselect %s-%s (priority %s)",e,t,r);for(var i=0;i<n._selections.length;++i){var s=n._selections[i];if(s.from===e&&s.to===t&&s.priority===r){n._selections.splice(i--,1);break}}n._updateSelections()};L.prototype.critical=function(e,t){var r=this;o("critical %s-%s",e,t);for(var n=e;n<=t;++n){r._critical[n]=true}r._updateSelections()};L.prototype._onWire=function(e){var t=this;e.use(g(t.metadata));if(!t.metadata){e.ut_metadata.on("metadata",function(e){o("got metadata via ut_metadata");t._onMetadata(e)});e.ut_metadata.fetch()}if(typeof v==="function"){e.use(v());e.ut_pex.on("peer",function(r){o("ut_pex: got peer: %s (from %s)",r,e.remoteAddress);t.addPeer(r)});e.ut_pex.on("dropped",function(r){o("ut_pex: dropped peer: %s (from %s)",r,e.remoteAddress);if(!(r in t.swarm._peers))t.swarm._removePeer(r)})}e.setKeepAlive(true);if(e.peerExtensions.dht&&t.client.dht&&t.client.dht.listening){e.port(t.client.dht.address().port)}e.on("port",function(r){o("port: %s (from %s)",r,e.remoteAddress);var i=n(e.remoteAddress);if(t.client.dht)t.client.dht.addNode(i[0]+":"+r)});e.on("timeout",function(){o("wire timeout (%s)",e.remoteAddress);e.destroy()});e.setTimeout(t.pieceTimeout,true);if(t.metadata){t._onWireWithMetadata(e)}};L.prototype._onWireWithMetadata=function(e){var t=this;var r=null;var n=t.chokeTimeout;function i(){if(t._destroyed||e._destroyed)return;if(t.swarm.numQueued>2*(t.swarm.numConns-t.swarm.numPeers)&&e.amInterested){e.destroy()}else{r=setTimeout(i,n);if(r.unref)r.unref()}}var s=0;function a(){if(e.peerPieces.length!==t.storage.pieces.length)return;for(;s<t.storage.pieces.length;++s){if(!e.peerPieces.get(s))return}e.isSeeder=true;e.choke()}e.on("bitfield",function(){a();t._update()});e.on("have",function(){a();t._update()});e.once("interested",function(){e.unchoke()});e.on("close",function(){clearTimeout(r)});e.on("choke",function(){clearTimeout(r);r=setTimeout(i,n);if(r.unref)r.unref()});e.on("unchoke",function(){clearTimeout(r);t._update()});e.on("request",function(r,n,i,s){if(i>w){o(e.remoteAddress,"requested invalid block size",i);return e.destroy()}t.storage.readBlock(r,n,i,s)});e.bitfield(t.storage.bitfield);e.interested();r=setTimeout(i,n);if(r.unref)r.unref();e.isSeeder=false;a()};L.prototype._onStorage=function(){var e=this;if(e._destroyed)return;o("on storage");e.storage.readonly=false;e.select(0,e.storage.pieces.length-1,false);e._rechokeIntervalId=setInterval(e._rechoke.bind(e),A);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();r.nextTick(function(){e.ready=true;e.emit("ready")})};L.prototype._onStoragePiece=function(e){var t=this;o("piece done %s",e.index);t._reservations[e.index]=null;t.swarm.wires.forEach(function(t){t.have(e.index)});t._gcSelections()};L.prototype._updateSelections=function(){var e=this;if(!e.swarm||e._destroyed)return;if(!e.metadata)return e.once("metadata",e._updateSelections.bind(e));r.nextTick(e._gcSelections.bind(e));e._updateInterest();e._update()};L.prototype._gcSelections=function(){var e=this;for(var t=0;t<e._selections.length;t++){var r=e._selections[t];var n=r.offset;while(e.storage.bitfield.get(r.from+r.offset)&&r.from+r.offset<r.to){r.offset++}if(n!==r.offset)r.notify();if(r.to!==r.from+r.offset)continue;if(!e.storage.bitfield.get(r.from+r.offset))continue;e._selections.splice(t--,1);r.notify();e._updateInterest()}if(!e._selections.length)e.emit("idle")};L.prototype._updateInterest=function(){var e=this;var t=e._amInterested;e._amInterested=!!e._selections.length;e.swarm.wires.forEach(function(t){if(e._amInterested)t.interested();else t.uninterested()});if(t===e._amInterested)return;if(e._amInterested)e.emit("interested");else e.emit("uninterested")};L.prototype._update=function(){var e=this;if(e._destroyed)return;R(e.swarm.wires,e._updateWire.bind(e))};L.prototype._updateWire=function(e){var t=this;if(e.peerChoking)return;if(!e.downloaded)return o();var r=T(e,x);if(e.requests.length>=r)return;var n=T(e,S);f(false)||f(true);function i(t,r,n,i){return function(o){return o>=t&&o<=r&&!(o in n)&&e.peerPieces.get(o)&&(!i||i(o))}}function o(){if(e.requests.length)return;for(var r=t._selections.length;r--;){var n=t._selections[r];var o;if(t.strategy==="rarest"){var s=n.from+n.offset;var a=n.to;var f=a-s+1;var u={};var c=0;var l=i(s,a,u);while(c<f){o=t.rarityMap.getRarestPiece(l);if(o<0)break;if(t._request(e,o,false))return;u[o]=true;c+=1}}else{for(o=n.to;o>=n.from+n.offset;--o){if(!e.peerPieces.get(o))continue;if(t._request(e,o,false))return}}}}function s(){var r=e.downloadSpeed()||1;if(r>E)return function(){return true};var n=Math.max(1,e.requests.length)*_.BLOCK_LENGTH/r;var i=10;var o=0;return function(e){if(!i||t.storage.bitfield.get(e))return true;var s=t.storage.pieces[e];var a=s.blocks.length-s.blocksWritten;for(;o<t.swarm.wires.length;o++){var f=t.swarm.wires[o];var u=f.downloadSpeed();if(u<E)continue;if(u<=r)continue;if(!f.peerPieces.get(e))continue;if((a-=u*n)>0)continue;i--;return false}return true}}function a(e){var r=e;for(var n=e;n<t._selections.length&&t._selections[n].priority;n++){r=n}var i=t._selections[e];t._selections[e]=t._selections[r];t._selections[r]=i}function f(r){if(e.requests.length>=n)return true;var o=s();for(var f=0;f<t._selections.length;f++){var u=t._selections[f];var c;if(t.strategy==="rarest"){var l=u.from+u.offset;var h=u.to;var d=h-l+1;var p={};var g=0;var v=i(l,h,p,o);while(g<d){c=t.rarityMap.getRarestPiece(v);if(c<0)break;while(t._request(e,c,t._critical[c]||r)){}if(e.requests.length<n){p[c]=true;g++;continue}if(u.priority)a(f);return true}}else{for(c=u.from+u.offset;c<=u.to;c++){if(!e.peerPieces.get(c)||!o(c))continue;while(t._request(e,c,t._critical[c]||r)){}if(e.requests.length<n)continue;if(u.priority)a(f);return true}}}return false}};L.prototype._rechoke=function(){var e=this;if(e._rechokeOptimisticTime>0)e._rechokeOptimisticTime-=1;else e._rechokeOptimisticWire=null;var t=[];e.swarm.wires.forEach(function(r){if(!r.isSeeder&&r!==e._rechokeOptimisticWire){t.push({wire:r,downloadSpeed:r.downloadSpeed(),uploadSpeed:r.uploadSpeed(),salt:Math.random(),isChoked:true})}});t.sort(s);var r=0;var n=0;for(;n<t.length&&r<e._rechokeNumSlots;++n){t[n].isChoked=false;if(t[n].wire.peerInterested)r+=1}if(!e._rechokeOptimisticWire&&n<t.length&&e._rechokeNumSlots){var i=t.slice(n).filter(function(e){return e.wire.peerInterested});var o=i[B(i.length)];if(o){o.isChoked=false;e._rechokeOptimisticWire=o.wire;e._rechokeOptimisticTime=I}}t.forEach(function(e){if(e.wire.amChoking!==e.isChoked){if(e.isChoked)e.wire.choke();else e.wire.unchoke()}});function s(e,t){if(e.downloadSpeed!==t.downloadSpeed){return t.downloadSpeed-e.downloadSpeed}if(e.uploadSpeed!==t.uploadSpeed){return t.uploadSpeed-e.uploadSpeed}if(e.wire.amChoking!==t.wire.amChoking){return e.wire.amChoking?1:-1}return e.salt-t.salt}};L.prototype._hotswap=function(e,t){var r=this;if(!r.hotswapEnabled)return false;var n=e.downloadSpeed();if(n<_.BLOCK_LENGTH)return false;if(!r._reservations[t])return false;var i=r._reservations[t];if(!i){return false}var o=Infinity;var s;var a;for(a=0;a<i.length;a++){var f=i[a];if(!f||f===e)continue;var u=f.downloadSpeed();if(u>=E)continue;if(2*u>n||u>o)continue;s=f;o=u}if(!s)return false;for(a=0;a<i.length;a++){if(i[a]===s)i[a]=null}for(a=0;a<s.requests.length;a++){var c=s.requests[a];if(c.piece!==t)continue;r.storage.cancelBlock(t,c.offset)}r.emit("hotswap",s,e,t);return true};L.prototype._request=function(e,t,n){var i=this;var s=e.requests.length;if(i.storage.bitfield.get(t))return false;var a=T(e,S);if(s>=a)return false;var f=e.requests.length===0&&i.storage.numMissing<30;var u=i.storage.reserveBlock(t,f);if(!u&&!f&&n&&i._hotswap(e,t)){u=i.storage.reserveBlock(t,false)}if(!u)return false;var c=i._reservations[t];if(!c){c=i._reservations[t]=[]}var l=c.indexOf(null);if(l===-1)l=c.length;c[l]=e;function h(n,s){if(!i.ready){i.once("ready",function(){h(n,s)});return}if(c[l]===e)c[l]=null;if(n){o("error getting piece %s (offset: %s length: %s) from %s: %s",t,u.offset,u.length,e.remoteAddress,n.message);i.storage.cancelBlock(t,u.offset);r.nextTick(i._update.bind(i));return false}else{o("got piece %s (offset: %s length: %s) from %s",t,u.offset,u.length,e.remoteAddress);i.storage.writeBlock(t,u.offset,s,function(e){if(e){o("error writing block");i.storage.cancelBlock(t,u.offset)}r.nextTick(i._update.bind(i))})}}e.request(t,u.offset,u.length,h);return true};L.prototype.createServer=function(e){var t=this;if(typeof y==="function"){return new y(t,e)}};function T(e,t){return Math.ceil(2+t*e.downloadSpeed()/_.BLOCK_LENGTH)}function B(e){return Math.random()*e|0}function R(e,t){var r=e.map(function(e,t){return t});for(var n=r.length-1;n>0;--n){var i=B(n+1);var o=r[n];r[n]=r[i];r[i]=o}r.forEach(function(r){t(e[r],r,e)})}}).call(this,e("_process"))},{"./rarity-map":3,"./server":33,"./storage":4,_process:41,"addr-to-ip-port":33,"bittorrent-swarm":7,"create-torrent":62,debug:86,events:38,fs:31,inherits:94,"parse-torrent":99,"re-emitter":112,"run-parallel":113,"simple-get":33,"torrent-discovery":120,ut_metadata:159,ut_pex:33}],6:[function(e,t,r){(function(e){var r=typeof e!=="undefined"?e:typeof Int8Array!=="undefined"?Int8Array:function(e){var t=new Array(e);for(var r=0;r<e;r++)t[r]=0};function n(e,t){if(!(this instanceof n)){return new n(e,t)}if(arguments.length===0){e=0}this.grow=t&&(isFinite(t.grow)&&i(t.grow)||t.grow)||0;if(typeof e==="number"||e===undefined){e=new r(i(e));if(e.fill)e.fill(0)}this.buffer=e}function i(e){var t=e>>3;if(e%8!==0)t++;return t}n.prototype.get=function(e){var t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)};n.prototype.set=function(e,t){var r=e>>3;if(t||arguments.length===1){if(this.buffer.length<r+1)this._grow(Math.max(r+1,Math.min(2*this.buffer.length,this.grow)));this.buffer[r]|=128>>e%8}else if(r<this.buffer.length){this.buffer[r]&=~(128>>e%8)}};n.prototype._grow=function(e){if(this.buffer.length<e&&e<=this.grow){var t=new r(e);if(t.fill)t.fill(0);if(this.buffer.copy)this.buffer.copy(t,0);else{for(var n=0;n<this.buffer.length;n++){t[n]=this.buffer[n]}}this.buffer=t}};if(typeof t!=="undefined")t.exports=n}).call(this,e("buffer").Buffer)},{buffer:34}],7:[function(e,t,r){(function(r,n){t.exports=g;var i=e("addr-to-ip-port");var o=e("debug")("bittorrent-swarm");var s=e("dezalgo");var a=e("events").EventEmitter;var f=e("inherits");var u=e("net");var c=e("./lib/peer");var l=e("speedometer");var h=e("./lib/tcp-pool");var d=55;var p=[1e3,5e3,15e3,3e4,6e4,12e4,3e5,6e5];f(g,a);function g(e,t,r){var i=this;if(!(i instanceof g))return new g(e,t,r);a.call(i);i.infoHash=typeof e==="string"?new n(e,"hex"):e;i.infoHashHex=i.infoHash.toString("hex");i.peerId=typeof t==="string"?new n(t,"hex"):t;i.peerIdHex=i.peerId.toString("hex");if(!r)r={};o("new swarm (i %s p %s)",i.infoHashHex,i.peerIdHex);i.handshakeOpts=r.handshake;i.maxConns=r.maxConns!==undefined?r.maxConns:d;i.destroyed=false;i.listening=false;i.paused=false;i.server=null;i.wires=[];i._queue=[];i._peers={};i._peersLength=0;i._port=0;i.downloaded=0;i.uploaded=0;i.downloadSpeed=l();i.uploadSpeed=l()}Object.defineProperty(g.prototype,"ratio",{get:function(){var e=this;return e.uploaded/e.downloaded||0}});Object.defineProperty(g.prototype,"numQueued",{get:function(){var e=this;return e._queue.length+(e._peersLength-e.numConns)}});Object.defineProperty(g.prototype,"numConns",{get:function(){var e=this;var t=0;for(var r in e._peers){var n=e._peers[r];if(n&&n.conn)t+=1}return t}});Object.defineProperty(g.prototype,"numPeers",{get:function(){var e=this;return e.wires.length}});g.prototype.addPeer=function(e){var t=this;if(t.destroyed){if(e&&e.destroy)e.destroy();return}if(typeof e==="string"&&!t._validAddr(e)){o("ignoring invalid peer %s (from swarm.addPeer)",e);return}var r=e&&e.id||e;if(t._peers[r])return;o("addPeer %s",r);var n;if(typeof e==="string"){n=c.createOutgoingTCPPeer(e,t);t._queue.push(n);t._drain()}else{n=c.createWebRTCPeer(e,t)}t._peers[n.id]=n;t._peersLength+=1};g.prototype._addIncomingPeer=function(e){var t=this;if(t.destroyed||t.paused)return e.destroy();if(!t._validAddr(e.addr)){o("ignoring invalid peer %s (from incoming)",e.addr);return e.destroy()}t._peers[e.id]=e;t._peersLength+=1};g.prototype._removePeer=function(e){var t=this;var r=t._peers[e];if(!r)return;o("_removePeer %s",e);t._peers[e]=null;t._peersLength-=1;r.destroy()};g.prototype.pause=function(){var e=this;if(e.destroyed)return;o("pause");e.paused=true};g.prototype.resume=function(){var e=this;if(e.destroyed)return;o("resume");e.paused=false;e._drain()};g.prototype.listen=function(e,t){var n=this;if(typeof e==="function"){t=e;e=undefined}if(t)t=s(t);if(n.listening)throw new Error("swarm already listening");if(r.browser){t()}else{n._port=e||h.getDefaultListenPort(n.infoHashHex);if(t)n.once("listening",t);o("listen %s",e);var i=h.addSwarm(n);n.server=i.server}};g.prototype._onListening=function(e){var t=this;t._port=e;t.listening=true;t.emit("listening")};g.prototype.address=function(){var e=this;return e.server.address()};g.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;t.listening=false;t.paused=false;if(e)t.once("close",e);o("destroy");for(var n in t._peers){t._removePeer(n)}h.removeSwarm(t);r.nextTick(function(){t.emit("close")})};g.prototype._drain=function(){var e=this;if(e.destroyed||e.paused||e.numConns>=e.maxConns)return;o("drain (%s queued, %s/%s peers)",e.numQueued,e.numPeers,e.maxConns);var t=e._queue.shift();if(!t)return;o("tcp connect attempt to %s",t.addr);var r=i(t.addr);var n=t.conn=u.connect(r[1],r[0]);n.once("connect",function(){
  t.onConnect()});n.once("error",function(){t.destroy()});t.setTimeout();n.on("close",function(){if(e.destroyed||t.retries>=p.length){return}function r(){var r=c.createOutgoingTCPPeer(t.addr,e);r.retries=t.retries+1;e._queue.push(r);e._drain()}var n=setTimeout(r,p[t.retries]);if(n.unref)n.unref()})};g.prototype._onError=function(e){var t=this;t.emit("error",e);t.destroy()};g.prototype._validAddr=function(e){var t=this;var r=i(e);var n=r[0];var o=r[1];return o>0&&o<65535&&!(n==="127.0.0.1"&&o===t._port)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/peer":8,"./lib/tcp-pool":9,_process:41,"addr-to-ip-port":33,buffer:34,debug:22,dezalgo:25,events:38,inherits:28,net:33,speedometer:29}],8:[function(e,t,r){var n=e("bittorrent-protocol");var i=25e3;r.createWebRTCPeer=function(e,t){var r=new o(e.id);r.conn=e;r.swarm=t;if(r.conn.connected){r.onConnect()}else{r.conn.once("connect",function(){r.onConnect()});r.conn.once("error",function(){r.destroy()});r.setTimeout()}return r};r.createIncomingTCPPeer=function(e,t){var r=new o(t);r.conn=e;r.addr=e.remoteAddress+":"+e.remotePort;r.onConnect();return r};r.createOutgoingTCPPeer=function(e,t){var r=new o(e);r.swarm=t;r.addr=e;return r};function o(e){var t=this;t.id=e;t.addr=null;t.conn=null;t.swarm=null;t.wire=null;t.destroyed=false;t.timeout=null;t.retries=0;t.gotHandshake=false;t.sentHandshake=false}o.prototype.onConnect=function(){var e=this;function t(){e.destroy()}var r=e.conn;r.once("end",t);r.once("close",t);r.once("finish",t);r.once("error",t);var i=e.wire=new n;i.once("end",t);i.once("finish",t);i.once("error",t);e.wire.remoteAddress=e.addr||r.remoteAddress+":"+r.remotePort;i.once("handshake",function(t){e.onHandshake(t)});e.setTimeout();r.pipe(i).pipe(r);if(e.swarm)e.handshake()};o.prototype.onHandshake=function(e){var t=this;if(!t.swarm)return;if(t.swarm.destroyed||e.toString("hex")!==t.swarm.infoHashHex){t.destroy();return}t.clearTimeout();t.gotHandshake=true;t.retries=0;t.wire.on("download",function(e){t.swarm.downloaded+=e;t.swarm.downloadSpeed(e);t.swarm.emit("download",e)});t.wire.on("upload",function(e){t.swarm.uploaded+=e;t.swarm.uploadSpeed(e);t.swarm.emit("upload",e)});if(!t.sentHandshake)t.handshake();t.swarm.wires.push(t.wire);t.swarm.emit("wire",t.wire)};o.prototype.handshake=function(){var e=this;e.wire.handshake(e.swarm.infoHash,e.swarm.peerId,e.swarm.handshakeOpts);e.sentHandshake=true};o.prototype.setTimeout=function(){var e=this;if(e.timeout)clearTimeout(e.timeout);e.timeout=setTimeout(function(){e.destroy()},i);if(e.timeout.unref)e.timeout.unref()};o.prototype.clearTimeout=function(){var e=this;if(e.timeout)clearTimeout(e.timeout);e.timeout=null};o.prototype.destroy=function(){var e=this;if(e.destroyed)return;e.destroyed=true;if(e.conn)e.conn.destroy();e.swarm.wires.splice(e.swarm.wires.indexOf(e.wire),1);if(e.wire)e.wire.destroy();if(e.swarm){e.swarm._removePeer(e.id);e.swarm._drain()}if(e.timeout)clearTimeout(e.timeout);e.timeout=null;e.conn=null;e.swarm=null;e.wire=null}},{"bittorrent-protocol":10}],9:[function(e,t,r){(function(r){t.exports=a;var n=e("dezalgo");var i=e("net");var o=e("./peer");var s={};function a(e){var t=this;t.port=e;t.listening=false;t.swarms={};t.pendingConns=[];t.server=i.createServer();t.server.on("connection",function(e){t._onConnection(e)});t.server.on("error",function(e){t._onError(e)});t.server.on("listening",function(){t._onListening()});t.server.listen(t.port)}a.addSwarm=function(e){var t=s[e._port];if(!t)t=s[e._port]=new a(e._port);t.addSwarm(e);return t};a.removeSwarm=function(e){var t=s[e._port];if(!t)return;t.removeSwarm(e);var r=0;for(var n in t.swarms){var i=t.swarms[n];if(i)r+=1}if(r===0)t.destroy()};a.getDefaultListenPort=function(e){for(var t in s){var r=s[t];if(r&&!r.swarms[e])return r.port}return 0};a.prototype.addSwarm=function(e){var t=this;if(t.listening){r.nextTick(function(){e._onListening(t.port)})}if(t.swarms[e.infoHashHex]){r.nextTick(function(){e._onError(new Error("There is already a swarm with info hash "+e.infoHashHex+" "+"listening on port "+e._port))});return}t.swarms[e.infoHashHex]=e};a.prototype.removeSwarm=function(e){var t=this;t.swarms[e.infoHashHex]=null};a.prototype.destroy=function(e){var t=this;if(e)e=n(e);t.listening=false;t.pendingConns.forEach(function(e){e.destroy()});s[t.port]=null;try{t.server.close(e)}catch(r){if(e)e(null)}};a.prototype._onListening=function(){var e=this;var t=e.server.address().port;if(t!==e.port){s[e.port]=null;e.port=t;s[e.port]=e}e.listening=true;for(var r in e.swarms){var n=e.swarms[r];if(n)n._onListening(e.port)}};a.prototype._onConnection=function(e){var t=this;t.pendingConns.push(e);e.once("close",r);function r(){t.pendingConns.splice(t.pendingConns.indexOf(e))}var n=o.createIncomingTCPPeer(e);n.wire.once("handshake",function(i){r();e.removeListener("close",r);var o=t.swarms[i.toString("hex")];if(o){n.swarm=o;o._addIncomingPeer(n);n.onHandshake(i)}else{n.destroy()}})};a.prototype._onError=function(e){var t=this;t.destroy();for(var r in t.swarms){var n=t.swarms[r];if(n){t.removeSwarm(n);n._onError(e)}}}}).call(this,e("_process"))},{"./peer":8,_process:41,dezalgo:25,net:33}],10:[function(e,t,r){(function(r){t.exports=w;var n=e("bitfield");var i=e("bencode");var o=e("debug")("bittorrent-protocol");var s=e("xtend");var a=e("inherits");var f=e("speedometer");var u=e("stream");var c=4e5;var l=new r("BitTorrent protocol");var h=new r([0,0,0,0]);var d=new r([0,0,0,1,0]);var p=new r([0,0,0,1,1]);var g=new r([0,0,0,1,2]);var v=new r([0,0,0,1,3]);var m=[0,0,0,0,0,0,0,0];var y=[0,0,0,3,9,0,0];function _(e,t,r,n){this.piece=e;this.offset=t;this.length=r;this.callback=n}a(w,u.Duplex);function w(){if(!(this instanceof w))return new w;u.Duplex.call(this);o("new wire");this.amChoking=true;this.amInterested=false;this.peerChoking=true;this.peerInterested=false;this.peerPieces=new n(0,{grow:c});this.peerExtensions={};this.requests=[];this.peerRequests=[];this.extendedMapping={};this.peerExtendedMapping={};this.extendedHandshake={};this.peerExtendedHandshake={};this._ext={};this._nextExt=1;this.uploaded=0;this.downloaded=0;this.uploadSpeed=f();this.downloadSpeed=f();this._keepAlive=null;this._timeout=null;this._timeoutMs=0;this.destroyed=false;this._finished=false;this._buffer=[];this._bufferSize=0;this._parser=null;this._parserSize=0;this.on("finish",this._onfinish);this._parseHandshake()}w.prototype.setKeepAlive=function(e){clearInterval(this._keepAlive);if(e===false)return;this._keepAlive=setInterval(this._push.bind(this,h),6e4)};w.prototype.setTimeout=function(e,t){this._clearTimeout();this._timeoutMs=e;this._timeoutUnref=!!t;this._updateTimeout()};w.prototype.destroy=function(){this.destroyed=true;this.end()};w.prototype.end=function(){this._onUninterested();this._onChoke();u.Duplex.prototype.end.apply(this,arguments)};w.prototype.use=function(e){var t=e.prototype.name;if(!t){throw new Error("Extension API requires a named function, e.g. function name() {}")}var r=this._nextExt;var n=new e(this);function i(){}if(typeof n.onHandshake!=="function"){n.onHandshake=i}if(typeof n.onExtendedHandshake!=="function"){n.onExtendedHandshake=i}if(typeof n.onMessage!=="function"){n.onMessage=i}this.extendedMapping[r]=t;this._ext[t]=n;this[t]=n;this._nextExt+=1};w.prototype.handshake=function(e,t,n){if(typeof e==="string")e=new r(e,"hex");if(typeof t==="string")t=new r(t,"hex");if(e.length!==20||t.length!==20){throw new Error("infoHash and peerId MUST have length 20")}var i=new r(m);i[5]|=16;if(n&&n.dht)i[7]|=1;this._push(r.concat([l,i,e,t]));this._handshakeSent=true;if(this.peerExtensions.extended){this._sendExtendedHandshake()}};w.prototype._sendExtendedHandshake=function(){var e=s(this.extendedHandshake);e.m={};for(var t in this.extendedMapping){var r=this.extendedMapping[t];e.m[r]=Number(t)}this.extended(0,i.encode(e))};w.prototype.choke=function(){if(this.amChoking)return;this.amChoking=true;this.peerRequests.splice(0,this.peerRequests.length);this._push(d)};w.prototype.unchoke=function(){if(!this.amChoking)return;this.amChoking=false;this._push(p)};w.prototype.interested=function(){if(this.amInterested)return;this.amInterested=true;this._push(g)};w.prototype.uninterested=function(){if(!this.amInterested)return;this.amInterested=false;this._push(v)};w.prototype.have=function(e){this._message(4,[e],null)};w.prototype.bitfield=function(e){if(!r.isBuffer(e))e=e.buffer;this._message(5,[],e)};w.prototype.request=function(e,t,r,n){if(!n)n=function(){};if(this._finished)return n(new Error("wire is closed"));if(this.peerChoking)return n(new Error("peer is choking"));this.requests.push(new _(e,t,r,n));this._updateTimeout();this._message(6,[e,t,r],null)};w.prototype.piece=function(e,t,r){this.uploaded+=r.length;this.uploadSpeed(r.length);this.emit("upload",r.length);this._message(7,[e,t],r)};w.prototype.cancel=function(e,t,r){this._callback(b(this.requests,e,t,r),new Error("request was cancelled"),null);this._message(8,[e,t,r],null)};w.prototype.port=function(e){var t=new r(y);t.writeUInt16BE(e,5);this._push(t)};w.prototype.extended=function(e,t){if(typeof e==="string"&&this.peerExtendedMapping[e]){e=this.peerExtendedMapping[e]}if(typeof e==="number"){var n=new r([e]);var o=r.isBuffer(t)?t:i.encode(t);this._message(20,[],r.concat([n,o]))}else{throw new Error("Unrecognized extension: "+e)}};w.prototype._onKeepAlive=function(){this.emit("keep-alive")};w.prototype._onHandshake=function(e,t,r){this.peerId=t;this.peerExtensions=r;this.emit("handshake",e,t,r);var n;for(n in this._ext){this._ext[n].onHandshake(e,t,r)}if(r.extended&&this._handshakeSent){this._sendExtendedHandshake()}};w.prototype._onChoke=function(){this.peerChoking=true;this.emit("choke");while(this.requests.length){this._callback(this.requests.shift(),new Error("peer is choking"),null)}};w.prototype._onUnchoke=function(){this.peerChoking=false;this.emit("unchoke")};w.prototype._onInterested=function(){this.peerInterested=true;this.emit("interested")};w.prototype._onUninterested=function(){this.peerInterested=false;this.emit("uninterested")};w.prototype._onHave=function(e){if(this.peerPieces.get(e))return;this.peerPieces.set(e,true);this.emit("have",e)};w.prototype._onBitField=function(e){this.peerPieces=new n(e);this.emit("bitfield",this.peerPieces)};w.prototype._onRequest=function(e,t,r){if(this.amChoking)return;var n=function(n,o){if(i!==b(this.peerRequests,e,t,r))return;if(n)return;this.piece(e,t,o)}.bind(this);var i=new _(e,t,r,n);this.peerRequests.push(i);this.emit("request",e,t,r,n)};w.prototype._onPiece=function(e,t,r){this._callback(b(this.requests,e,t,r.length),null,r);this.downloaded+=r.length;this.downloadSpeed(r.length);this.emit("download",r.length);this.emit("piece",e,t,r)};w.prototype._onCancel=function(e,t,r){b(this.peerRequests,e,t,r);this.emit("cancel",e,t,r)};w.prototype._onPort=function(e){this.emit("port",e)};w.prototype._onExtended=function(e,t){var r,n;if(e===0&&(r=k(t))){this.peerExtendedHandshake=r;if(typeof r.m==="object"){for(n in r.m){this.peerExtendedMapping[n]=Number(r.m[n].toString())}}for(n in this._ext){if(this.peerExtendedMapping[n]){this._ext[n].onExtendedHandshake(this.peerExtendedHandshake)}}this.emit("extended","handshake",this.peerExtendedHandshake)}else{if(this.extendedMapping[e]){e=this.extendedMapping[e];if(this._ext[e]){this._ext[e].onMessage(t)}}this.emit("extended",e,t)}};w.prototype._onTimeout=function(){this._callback(this.requests.shift(),new Error("request has timed out"),null);this.emit("timeout")};w.prototype._push=function(e){if(this._finished)return;return this.push(e)};w.prototype._write=function(e,t,n){this._bufferSize+=e.length;this._buffer.push(e);while(this._bufferSize>=this._parserSize){var i=this._buffer.length===1?this._buffer[0]:r.concat(this._buffer);this._bufferSize-=this._parserSize;this._buffer=this._bufferSize?[i.slice(this._parserSize)]:[];this._parser(i.slice(0,this._parserSize))}n(null)};w.prototype._read=function(){};w.prototype._callback=function(e,t,r){if(!e)return;this._clearTimeout();if(!this.peerChoking&&!this._finished)this._updateTimeout();e.callback(t,r)};w.prototype._clearTimeout=function(){if(!this._timeout)return;clearTimeout(this._timeout);this._timeout=null};w.prototype._updateTimeout=function(){if(!this._timeoutMs||!this.requests.length||this._timeout)return;this._timeout=setTimeout(this._onTimeout.bind(this),this._timeoutMs);if(this._timeoutUnref&&this._timeout.unref)this._timeout.unref()};w.prototype._parse=function(e,t){this._parserSize=e;this._parser=t};w.prototype._message=function(e,t,n){var i=n?n.length:0;var o=new r(5+4*t.length);o.writeUInt32BE(o.length+i-4,0);o[4]=e;for(var s=0;s<t.length;s++){o.writeUInt32BE(t[s],5+4*s)}this._push(o);if(n)this._push(n)};w.prototype._onmessagelength=function(e){var t=e.readUInt32BE(0);if(t>0){this._parse(t,this._onmessage)}else{this._onKeepAlive();this._parse(4,this._onmessagelength)}};w.prototype._onmessage=function(e){this._parse(4,this._onmessagelength);switch(e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this.emit("unknownmessage",e)}};w.prototype._parseHandshake=function(){this._parse(1,function(e){var t=e.readUInt8(0);this._parse(t+48,function(e){var r=e.slice(0,t);if(r.toString()!=="BitTorrent protocol"){o("Error: wire not speaking BitTorrent protocol (%s)",r.toString());this.end();return}e=e.slice(t);this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(e[7]&1),extended:!!(e[5]&16)});this._parse(4,this._onmessagelength)}.bind(this))}.bind(this))};w.prototype._onfinish=function(){this._finished=true;this.push(null);while(this.read()){}clearInterval(this._keepAlive);this._parse(Number.MAX_VALUE,function(){});this.peerRequests=[];while(this.requests.length){this._callback(this.requests.shift(),new Error("wire was closed"),null)}};function b(e,t,r,n){for(var i=0;i<e.length;i++){var o=e[i];if(o.piece!==t||o.offset!==r||o.length!==n)continue;if(i===0)e.shift();else e.splice(i,1);return o}return null}function k(e){try{return i.decode(e)}catch(t){console.warn(t)}}}).call(this,e("buffer").Buffer)},{bencode:11,bitfield:15,buffer:34,debug:16,inherits:19,speedometer:20,stream:57,xtend:21}],11:[function(e,t,r){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":12,"./lib/encode":14}],12:[function(e,t,r){(function(r){var n=e("./dict");function i(e,t){i.position=0;i.encoding=t||null;i.data=!r.isBuffer(e)?new r(e):e;return i.next()}i.position=0;i.data=null;i.encoding=null;i.next=function(){switch(i.data[i.position]){case 100:return i.dictionary();break;case 108:return i.list();break;case 105:return i.integer();break;default:return i.bytes();break}};i.find=function(e){var t=i.position;var r=i.data.length;var n=i.data;while(t<r){if(n[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")};i.dictionary=function(){i.position++;var e=new n;while(i.data[i.position]!==101){e.binarySet(i.bytes(),i.next())}i.position++;return e};i.list=function(){i.position++;var e=[];while(i.data[i.position]!==101){e.push(i.next())}i.position++;return e};i.integer=function(){var e=i.find(101);var t=i.data.toString("ascii",i.position+1,e);i.position+=e+1-i.position;return parseInt(t,10)};i.bytes=function(){var e=i.find(58);var t=parseInt(i.data.toString("ascii",i.position,e),10);var r=++e+t;i.position=r;return i.encoding?i.data.toString(i.encoding,e,r):i.data.slice(e,r)};t.exports=i}).call(this,e("buffer").Buffer)},{"./dict":13,buffer:34}],13:[function(e,t,r){var n=t.exports=function i(){Object.defineProperty(this,"_keys",{enumerable:false,value:[]})};n.prototype.binaryKeys=function o(){return this._keys.slice()};n.prototype.binarySet=function s(e,t){this._keys.push(e);this[e]=t}},{}],14:[function(e,t,r){(function(e){function r(t){var n=[];r._encode(n,t);return e.concat(n)}r._floatConversionDetected=false;r._encode=function(t,n){if(e.isBuffer(n)){t.push(new e(n.length+":"));t.push(n);return}switch(typeof n){case"string":r.bytes(t,n);break;case"number":r.number(t,n);break;case"object":n.constructor===Array?r.list(t,n):r.dict(t,n);break}};var n=new e("e"),i=new e("d"),o=new e("l");r.bytes=function(t,r){t.push(new e(e.byteLength(r)+":"+r))};r.number=function(t,n){var i=2147483648;var o=n/i<<0;var s=n%i<<0;var a=o*i+s;t.push(new e("i"+a+"e"));if(a!==n&&!r._floatConversionDetected){r._floatConversionDetected=true;console.warn('WARNING: Possible data corruption detected with value "'+n+'":','Bencoding only defines support for integers, value was converted to "'+a+'"');console.trace()}};r.dict=function(e,t){e.push(i);var o=0;var s;var a=Object.keys(t).sort();var f=a.length;for(;o<f;o++){s=a[o];r.bytes(e,s);r._encode(e,t[s])}e.push(n)};r.list=function(e,t){var i=0,s=1;var a=t.length;e.push(o);for(;i<a;i++){r._encode(e,t[i])}e.push(n)};t.exports=r}).call(this,e("buffer").Buffer)},{buffer:34}],15:[function(e,t,r){arguments[4][6][0].apply(r,arguments)},{buffer:34,dup:6}],16:[function(e,t,r){r=t.exports=e("./debug");r.log=s;r.formatArgs=o;r.save=a;r.load=f;r.useColors=i;var n;if(typeof chrome!=="undefined"&&typeof chrome.storage!=="undefined")n=chrome.storage.local;else n=u();r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function i(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}r.formatters.j=function(e){return JSON.stringify(e)};function o(){var e=arguments;var t=this.useColors;e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff);if(!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0;var o=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;i++;if("%c"===e){o=i}});e.splice(o,0,n);return e}function s(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(e){try{if(null==e){n.removeItem("debug")}else{n.debug=e}}catch(t){}}function f(){var e;try{e=n.debug}catch(t){}return e}r.enable(f());function u(){try{return window.localStorage}catch(e){}}},{"./debug":17}],17:[function(e,t,r){r=t.exports=s;r.coerce=c;r.disable=f;r.enable=a;r.enabled=u;r.humanize=e("ms");r.names=[];r.skips=[];r.formatters={};var n=0;var i;function o(){return r.colors[n++%r.colors.length]}function s(e){function t(){}t.enabled=false;function n(){var e=n;var t=+new Date;var s=t-(i||t);e.diff=s;e.prev=i;e.curr=t;i=t;if(null==e.useColors)e.useColors=r.useColors();if(null==e.color&&e.useColors)e.color=o();var a=Array.prototype.slice.call(arguments);a[0]=r.coerce(a[0]);if("string"!==typeof a[0]){a=["%o"].concat(a)}var f=0;a[0]=a[0].replace(/%([a-z%])/g,function(t,n){if(t==="%%")return t;f++;var i=r.formatters[n];if("function"===typeof i){var o=a[f];t=i.call(e,o);a.splice(f,1);f--}return t});if("function"===typeof r.formatArgs){a=r.formatArgs.apply(e,a)}var u=n.log||r.log||console.log.bind(console);u.apply(e,a)}n.enabled=true;var s=r.enabled(e)?n:t;s.namespace=e;return s}function a(e){r.save(e);var t=(e||"").split(/[\s,]+/);var n=t.length;for(var i=0;i<n;i++){if(!t[i])continue;e=t[i].replace(/\*/g,".*?");if(e[0]==="-"){r.skips.push(new RegExp("^"+e.substr(1)+"$"))}else{r.names.push(new RegExp("^"+e+"$"))}}}function f(){r.enable("")}function u(e){var t,n;for(t=0,n=r.skips.length;t<n;t++){if(r.skips[t].test(e)){return false}}for(t=0,n=r.names.length;t<n;t++){if(r.names[t].test(e)){return true}}return false}function c(e){if(e instanceof Error)return e.stack||e.message;return e}},{ms:18}],18:[function(e,t,r){var n=1e3;var i=n*60;var o=i*60;var s=o*24;var a=s*365.25;t.exports=function(e,t){t=t||{};if("string"==typeof e)return f(e);return t.long?c(e):u(e)};function f(e){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);var f=(t[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}function u(e){if(e>=s)return Math.round(e/s)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}function c(e){return l(e,s,"day")||l(e,o,"hour")||l(e,i,"minute")||l(e,n,"second")||e+" ms"}function l(e,t,r){if(e<t)return;if(e<t*1.5)return Math.floor(e/t)+" "+r;return Math.ceil(e/t)+" "+r+"s"}},{}],19:[function(e,t,r){if(typeof Object.create==="function"){t.exports=function n(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{t.exports=function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}}},{}],20:[function(e,t,r){var n=1;var i=65535;var o=4;var s=function(){n=n+1&i};var a=setInterval(s,1e3/o|0);if(a.unref)a.unref();t.exports=function(e){var t=o*(e||5);var r=[0];var s=1;var a=n-1&i;return function(e){var f=n-a&i;if(f>t)f=t;a=n;while(f--){if(s===t)s=0;r[s]=r[s===0?t-1:s-1];s++}if(e)r[s-1]+=e;var u=r[s-1];var c=r.length<t?0:r[s===t?0:s];return r.length<o?u:(u-c)*o/r.length}}},{}],21:[function(e,t,r){t.exports=n;function n(){var e={};for(var t=0;t<arguments.length;t++){var r=arguments[t];for(var n in r){if(r.hasOwnProperty(n)){e[n]=r[n]}}}return e}},{}],22:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./debug":23,dup:16}],23:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{dup:17,ms:24}],24:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],25:[function(e,t,r){var n=e("wrappy");t.exports=n(o);var i=e("asap");function o(e){var t=true;i(function(){t=false});return function r(){var r=arguments;var n=this;if(t)i(function(){e.apply(n,r)});else e.apply(n,r)}}},{asap:26,wrappy:27}],26:[function(e,t,r){(function(e){var r={task:void 0,next:null};var n=r;var i=false;var o=void 0;var s=false;function a(){while(r.next){r=r.next;var e=r.task;r.task=void 0;var t=r.domain;if(t){r.domain=void 0;t.enter()}try{e()}catch(n){if(s){if(t){t.exit()}setTimeout(a,0);if(t){t.enter()}throw n}else{setTimeout(function(){throw n},0)}}if(t){t.exit()}}i=false}if(typeof e!=="undefined"&&e.nextTick){s=true;o=function(){e.nextTick(a)}}else if(typeof setImmediate==="function"){if(typeof window!=="undefined"){o=setImmediate.bind(window,a)}else{o=function(){setImmediate(a)}}}else if(typeof MessageChannel!=="undefined"){var f=new MessageChannel;f.port1.onmessage=a;o=function(){f.port2.postMessage(0)}}else{o=function(){setTimeout(a,0)}}function u(t){n=n.next={task:t,domain:s&&e.domain,next:null};if(!i){i=true;o()}}t.exports=u}).call(this,e("_process"))},{_process:41}],27:[function(e,t,r){t.exports=n;function n(e,t){if(e&&t)return n(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach(function(t){r[t]=e[t]});return r;function r(){var t=new Array(arguments.length);for(var r=0;r<t.length;r++){t[r]=arguments[r]}var n=e.apply(this,t);var i=t[t.length-1];if(typeof n==="function"&&n!==i){Object.keys(i).forEach(function(e){n[e]=i[e]})}return n}}},{}],28:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],29:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],30:[function(e,t,r){(function(r,n){t.exports=f;var i=e("stream").Stream,o=e("inherits"),s=e("assert").ok,a=r.env.DEBUG?console.error:function(){};function f(e,t){this.writable=this.readable=true;this._opt=t||{};this._chunkSize=e||512;this._offset=0;this._buffer=[];this._bufferLength=0;if(this._opt.nopad)this._zeroes=false;else{this._zeroes=new n(this._chunkSize);for(var r=0;r<this._chunkSize;r++){this._zeroes[r]=0}}}o(f,i);f.prototype.write=function(e){if(this._ended)throw new Error("BlockStream: write after end");if(e&&!n.isBuffer(e))e=new n(e+"");if(e.length){this._buffer.push(e);this._bufferLength+=e.length}if(this._bufferLength>=this._chunkSize){if(this._paused){this._needDrain=true;return false}this._emitChunk()}return true};f.prototype.pause=function(){this._paused=true};f.prototype.resume=function(){this._paused=false;return this._emitChunk()};f.prototype.end=function(e){if(typeof e==="function")cb=e,e=null;if(e)this.write(e);this._ended=true;this.flush()};f.prototype.flush=function(){this._emitChunk(true)};f.prototype._emitChunk=function(e){if(e&&this._zeroes){var t=this._bufferLength%this._chunkSize;if(t!==0)t=this._chunkSize-t;if(t>0){this._buffer.push(this._zeroes.slice(0,t));this._bufferLength+=t}}if(this._emitting||this._paused)return;this._emitting=true;var r=0;while(this._bufferLength>=this._chunkSize&&(e||!this._paused)){var i,o=0,a=this._chunkSize;while(a>0&&(e||!this._paused)){var f=this._buffer[r],u=f.length-this._offset;if(i||u<a){i=i||new n(this._chunkSize);f.copy(i,o,this._offset,this._offset+Math.min(u,a))}else if(f.length===a&&this._offset===0){i=f}else{i=f.slice(this._offset,this._offset+a)}if(u>a){this._offset+=a;a=0}else{a-=u;o+=u;r++;this._offset=0}}this._bufferLength-=this._chunkSize;s(i.length===this._chunkSize);this.emit("data",i);i=null}this._buffer=this._buffer.slice(r);if(this._paused){this._needsDrain=true;this._emitting=false;return}var c=this._buffer.length;if(e&&!this._zeroes&&c){if(c===1){if(this._offset){this.emit("data",this._buffer[0].slice(this._offset))}else{this.emit("data",this._buffer[0])}}else{var a=this._bufferLength,i=new n(a),o=0;for(var l=0;l<c;l++){var f=this._buffer[l],u=f.length-this._offset;f.copy(i,o,this._offset);this._offset=0;o+=u;this._bufferLength-=u}this.emit("data",i)}this._buffer.length=0;this._bufferLength=0;this._offset=0}if(this._needDrain){this._needDrain=false;this.emit("drain")}if(this._bufferLength===0&&this._ended&&!this._endEmitted){this._endEmitted=true;this.emit("end")}this._emitting=false}}).call(this,e("_process"),e("buffer").Buffer)},{_process:41,assert:32,buffer:34,inherits:94,stream:57}],31:[function(e,t,r){},{}],32:[function(e,t,r){var n=e("util/");var i=Array.prototype.slice;var o=Object.prototype.hasOwnProperty;var s=t.exports=l;s.AssertionError=function y(e){this.name="AssertionError";this.actual=e.actual;this.expected=e.expected;this.operator=e.operator;if(e.message){this.message=e.message;this.generatedMessage=false}else{this.message=u(this);this.generatedMessage=true}var t=e.stackStartFunction||c;if(Error.captureStackTrace){Error.captureStackTrace(this,t)}else{var r=new Error;if(r.stack){var n=r.stack;var i=t.name;var o=n.indexOf("\n"+i);if(o>=0){var s=n.indexOf("\n",o+1);n=n.substring(s+1)}this.stack=n}}};n.inherits(s.AssertionError,Error);function a(e,t){if(n.isUndefined(t)){return""+t}if(n.isNumber(t)&&!isFinite(t)){return t.toString()}if(n.isFunction(t)||n.isRegExp(t)){return t.toString()}return t}function f(e,t){if(n.isString(e)){return e.length<t?e:e.slice(0,t)}else{return e}}function u(e){return f(JSON.stringify(e.actual,a),128)+" "+e.operator+" "+f(JSON.stringify(e.expected,a),128)}function c(e,t,r,n,i){throw new s.AssertionError({message:r,actual:e,expected:t,operator:n,stackStartFunction:i})}s.fail=c;function l(e,t){if(!e)c(e,true,t,"==",s.ok)}s.ok=l;s.equal=function _(e,t,r){if(e!=t)c(e,t,r,"==",s.equal)};s.notEqual=function w(e,t,r){if(e==t){c(e,t,r,"!=",s.notEqual)}};s.deepEqual=function b(e,t,r){if(!h(e,t)){c(e,t,r,"deepEqual",s.deepEqual)}};function h(e,t){if(e===t){return true}else if(n.isBuffer(e)&&n.isBuffer(t)){if(e.length!=t.length)return false;for(var r=0;r<e.length;r++){if(e[r]!==t[r])return false}return true}else if(n.isDate(e)&&n.isDate(t)){return e.getTime()===t.getTime()}else if(n.isRegExp(e)&&n.isRegExp(t)){return e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase}else if(!n.isObject(e)&&!n.isObject(t)){return e==t}else{return p(e,t)}}function d(e){return Object.prototype.toString.call(e)=="[object Arguments]"}function p(e,t){if(n.isNullOrUndefined(e)||n.isNullOrUndefined(t))return false;if(e.prototype!==t.prototype)return false;if(n.isPrimitive(e)||n.isPrimitive(t)){return e===t}var r=d(e),o=d(t);if(r&&!o||!r&&o)return false;if(r){e=i.call(e);t=i.call(t);return h(e,t)}var s=m(e),a=m(t),f,u;if(s.length!=a.length)return false;s.sort();a.sort();for(u=s.length-1;u>=0;u--){if(s[u]!=a[u])return false}for(u=s.length-1;u>=0;u--){f=s[u];if(!h(e[f],t[f]))return false}return true}s.notDeepEqual=function k(e,t,r){if(h(e,t)){c(e,t,r,"notDeepEqual",s.notDeepEqual)}};s.strictEqual=function E(e,t,r){if(e!==t){c(e,t,r,"===",s.strictEqual)}};s.notStrictEqual=function x(e,t,r){if(e===t){c(e,t,r,"!==",s.notStrictEqual)}};function g(e,t){if(!e||!t){return false}if(Object.prototype.toString.call(t)=="[object RegExp]"){return t.test(e)}else if(e instanceof t){return true}else if(t.call({},e)===true){return true}return false}function v(e,t,r,i){var o;if(n.isString(r)){i=r;r=null}try{t()}catch(s){o=s}i=(r&&r.name?" ("+r.name+").":".")+(i?" "+i:".");if(e&&!o){c(o,r,"Missing expected exception"+i)}if(!e&&g(o,r)){c(o,r,"Got unwanted exception"+i)}if(e&&o&&r&&!g(o,r)||!e&&o){throw o}}s.throws=function(e,t,r){v.apply(this,[true].concat(i.call(arguments)))};s.doesNotThrow=function(e,t){v.apply(this,[false].concat(i.call(arguments)))};s.ifError=function(e){if(e){throw e}};var m=Object.keys||function(e){var t=[];for(var r in e){if(o.call(e,r))t.push(r)}return t}},{"util/":61}],33:[function(e,t,r){arguments[4][31][0].apply(r,arguments)},{dup:31}],34:[function(e,t,r){var n=e("base64-js");var i=e("ieee754");var o=e("is-array");r.Buffer=f;r.SlowBuffer=_;r.INSPECT_MAX_BYTES=50;f.poolSize=8192;var s=1073741823;var a={};f.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0);var t=new Uint8Array(e);t.foo=function(){return 42};return t.foo()===42&&typeof t.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(r){return false}}();function f(e){if(!(this instanceof f)){if(arguments.length>1)return new f(e,arguments[1]);return new f(e)}this.length=0;this.parent=undefined;if(typeof e==="number"){return u(this,e)}if(typeof e==="string"){return c(this,e,arguments.length>1?arguments[1]:"utf8")}return l(this,e)}function u(e,t){e=m(e,t<0?0:y(t)|0);if(!f.TYPED_ARRAY_SUPPORT){for(var r=0;r<t;r++){e[r]=0}}return e}function c(e,t,r){if(typeof r!=="string"||r==="")r="utf8";var n=w(t,r)|0;e=m(e,n);e.write(t,r);return e}function l(e,t){if(f.isBuffer(t))return h(e,t);if(o(t))return d(e,t);if(t==null){throw new TypeError("must start with number, buffer, array or string")}if(typeof ArrayBuffer!=="undefined"&&t.buffer instanceof ArrayBuffer){return p(e,t)}if(t.length)return g(e,t);return v(e,t)}function h(e,t){var r=y(t.length)|0;e=m(e,r);t.copy(e,0,0,r);return e}function d(e,t){var r=y(t.length)|0;e=m(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function p(e,t){var r=y(t.length)|0;e=m(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function g(e,t){var r=y(t.length)|0;e=m(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function v(e,t){var r;var n=0;if(t.type==="Buffer"&&o(t.data)){r=t.data;n=y(r.length)|0}e=m(e,n);for(var i=0;i<n;i+=1){e[i]=r[i]&255}return e}function m(e,t){if(f.TYPED_ARRAY_SUPPORT){e=f._augment(new Uint8Array(t))}else{e.length=t;e._isBuffer=true}var r=t!==0&&t<=f.poolSize>>>1;if(r)e.parent=a;return e;
  
  }function y(e){if(e>=s){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+s.toString(16)+" bytes")}return e|0}function _(e,t){if(!(this instanceof _))return new _(e,t);var r=new f(e,t);delete r.parent;return r}f.isBuffer=function Z(e){return!!(e!=null&&e._isBuffer)};f.compare=function X(e,t){if(!f.isBuffer(e)||!f.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var r=e.length;var n=t.length;var i=0;var o=Math.min(r,n);while(i<o){if(e[i]!==t[i])break;++i}if(i!==o){r=e[i];n=t[i]}if(r<n)return-1;if(n<r)return 1;return 0};f.isEncoding=function Q(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};f.concat=function ee(e,t){if(!o(e))throw new TypeError("list argument must be an Array of Buffers.");if(e.length===0){return new f(0)}else if(e.length===1){return e[0]}var r;if(t===undefined){t=0;for(r=0;r<e.length;r++){t+=e[r].length}}var n=new f(t);var i=0;for(r=0;r<e.length;r++){var s=e[r];s.copy(n,i);i+=s.length}return n};function w(e,t){if(typeof e!=="string")e=String(e);if(e.length===0)return 0;switch(t||"utf8"){case"ascii":case"binary":case"raw":return e.length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e.length*2;case"hex":return e.length>>>1;case"utf8":case"utf-8":return Y(e).length;case"base64":return $(e).length;default:return e.length}}f.byteLength=w;f.prototype.length=undefined;f.prototype.parent=undefined;f.prototype.toString=function te(e,t,r){var n=false;t=t|0;r=r===undefined||r===Infinity?this.length:r|0;if(!e)e="utf8";if(t<0)t=0;if(r>this.length)r=this.length;if(r<=t)return"";while(true){switch(e){case"hex":return B(this,t,r);case"utf8":case"utf-8":return C(this,t,r);case"ascii":return L(this,t,r);case"binary":return T(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}};f.prototype.equals=function re(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return f.compare(this,e)===0};f.prototype.inspect=function ne(){var e="";var t=r.INSPECT_MAX_BYTES;if(this.length>0){e=this.toString("hex",0,t).match(/.{2}/g).join(" ");if(this.length>t)e+=" ... "}return"<Buffer "+e+">"};f.prototype.compare=function ie(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return 0;return f.compare(this,e)};f.prototype.indexOf=function oe(e,t){if(t>2147483647)t=2147483647;else if(t<-2147483648)t=-2147483648;t>>=0;if(this.length===0)return-1;if(t>=this.length)return-1;if(t<0)t=Math.max(this.length+t,0);if(typeof e==="string"){if(e.length===0)return-1;return String.prototype.indexOf.call(this,e,t)}if(f.isBuffer(e)){return r(this,e,t)}if(typeof e==="number"){if(f.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,e,t)}return r(this,[e],t)}function r(e,t,r){var n=-1;for(var i=0;r+i<e.length;i++){if(e[r+i]===t[n===-1?0:i-n]){if(n===-1)n=i;if(i-n+1===t.length)return r+n}else{n=-1}}return-1}throw new TypeError("val must be string, number or Buffer")};f.prototype.get=function se(e){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(e)};f.prototype.set=function ae(e,t){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(e,t)};function b(e,t,r,n){r=Number(r)||0;var i=e.length-r;if(!n){n=i}else{n=Number(n);if(n>i){n=i}}var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");if(n>o/2){n=o/2}for(var s=0;s<n;s++){var a=parseInt(t.substr(s*2,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[r+s]=a}return s}function k(e,t,r,n){return G(Y(t,e.length-r),e,r,n)}function E(e,t,r,n){return G(J(t),e,r,n)}function x(e,t,r,n){return E(e,t,r,n)}function S(e,t,r,n){return G($(t),e,r,n)}function A(e,t,r,n){return G(V(t,e.length-r),e,r,n)}f.prototype.write=function fe(e,t,r,n){if(t===undefined){n="utf8";r=this.length;t=0}else if(r===undefined&&typeof t==="string"){n=t;r=this.length;t=0}else if(isFinite(t)){t=t|0;if(isFinite(r)){r=r|0;if(n===undefined)n="utf8"}else{n=r;r=undefined}}else{var i=n;n=t;t=r|0;r=i}var o=this.length-t;if(r===undefined||r>o)r=o;if(e.length>0&&(r<0||t<0)||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!n)n="utf8";var s=false;for(;;){switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return k(this,e,t,r);case"ascii":return E(this,e,t,r);case"binary":return x(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase();s=true}}};f.prototype.toJSON=function ue(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function I(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function C(e,t,r){var n="";var i="";r=Math.min(e.length,r);for(var o=t;o<r;o++){if(e[o]<=127){n+=K(i)+String.fromCharCode(e[o]);i=""}else{i+="%"+e[o].toString(16)}}return n+K(i)}function L(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;i++){n+=String.fromCharCode(e[i]&127)}return n}function T(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;i++){n+=String.fromCharCode(e[i])}return n}function B(e,t,r){var n=e.length;if(!t||t<0)t=0;if(!r||r<0||r>n)r=n;var i="";for(var o=t;o<r;o++){i+=W(e[o])}return i}function R(e,t,r){var n=e.slice(t,r);var i="";for(var o=0;o<n.length;o+=2){i+=String.fromCharCode(n[o]+n[o+1]*256)}return i}f.prototype.slice=function ce(e,t){var r=this.length;e=~~e;t=t===undefined?r:~~t;if(e<0){e+=r;if(e<0)e=0}else if(e>r){e=r}if(t<0){t+=r;if(t<0)t=0}else if(t>r){t=r}if(t<e)t=e;var n;if(f.TYPED_ARRAY_SUPPORT){n=f._augment(this.subarray(e,t))}else{var i=t-e;n=new f(i,undefined);for(var o=0;o<i;o++){n[o]=this[o+e]}}if(n.length)n.parent=this.parent||this;return n};function j(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUIntLE=function le(e,t,r){e=e|0;t=t|0;if(!r)j(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){n+=this[e+o]*i}return n};f.prototype.readUIntBE=function he(e,t,r){e=e|0;t=t|0;if(!r){j(e,t,this.length)}var n=this[e+--t];var i=1;while(t>0&&(i*=256)){n+=this[e+--t]*i}return n};f.prototype.readUInt8=function de(e,t){if(!t)j(e,1,this.length);return this[e]};f.prototype.readUInt16LE=function pe(e,t){if(!t)j(e,2,this.length);return this[e]|this[e+1]<<8};f.prototype.readUInt16BE=function ge(e,t){if(!t)j(e,2,this.length);return this[e]<<8|this[e+1]};f.prototype.readUInt32LE=function ve(e,t){if(!t)j(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUInt32BE=function me(e,t){if(!t)j(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function ye(e,t,r){e=e|0;t=t|0;if(!r)j(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){n+=this[e+o]*i}i*=128;if(n>=i)n-=Math.pow(2,8*t);return n};f.prototype.readIntBE=function _e(e,t,r){e=e|0;t=t|0;if(!r)j(e,t,this.length);var n=t;var i=1;var o=this[e+--n];while(n>0&&(i*=256)){o+=this[e+--n]*i}i*=128;if(o>=i)o-=Math.pow(2,8*t);return o};f.prototype.readInt8=function we(e,t){if(!t)j(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};f.prototype.readInt16LE=function be(e,t){if(!t)j(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};f.prototype.readInt16BE=function ke(e,t){if(!t)j(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};f.prototype.readInt32LE=function Ee(e,t){if(!t)j(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function xe(e,t){if(!t)j(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function Se(e,t){if(!t)j(e,4,this.length);return i.read(this,e,true,23,4)};f.prototype.readFloatBE=function Ae(e,t){if(!t)j(e,4,this.length);return i.read(this,e,false,23,4)};f.prototype.readDoubleLE=function Ie(e,t){if(!t)j(e,8,this.length);return i.read(this,e,true,52,8)};f.prototype.readDoubleBE=function Ce(e,t){if(!t)j(e,8,this.length);return i.read(this,e,false,52,8)};function P(e,t,r,n,i,o){if(!f.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||t<o)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range")}f.prototype.writeUIntLE=function Le(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n)P(this,e,t,r,Math.pow(2,8*r),0);var i=1;var o=0;this[t]=e&255;while(++o<r&&(i*=256)){this[t+o]=e/i&255}return t+r};f.prototype.writeUIntBE=function Te(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n)P(this,e,t,r,Math.pow(2,8*r),0);var i=r-1;var o=1;this[t+i]=e&255;while(--i>=0&&(o*=256)){this[t+i]=e/o&255}return t+r};f.prototype.writeUInt8=function Be(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,1,255,0);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function O(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,o=Math.min(e.length-r,2);i<o;i++){e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}}f.prototype.writeUInt16LE=function Re(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{O(this,e,t,true)}return t+2};f.prototype.writeUInt16BE=function je(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{O(this,e,t,false)}return t+2};function M(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,o=Math.min(e.length-r,4);i<o;i++){e[r+i]=t>>>(n?i:3-i)*8&255}}f.prototype.writeUInt32LE=function Pe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e}else{M(this,e,t,true)}return t+4};f.prototype.writeUInt32BE=function Oe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{M(this,e,t,false)}return t+4};f.prototype.writeIntLE=function Me(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=0;var s=1;var a=e<0?1:0;this[t]=e&255;while(++o<r&&(s*=256)){this[t+o]=(e/s>>0)-a&255}return t+r};f.prototype.writeIntBE=function Ue(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);P(this,e,t,r,i-1,-i)}var o=r-1;var s=1;var a=e<0?1:0;this[t+o]=e&255;while(--o>=0&&(s*=256)){this[t+o]=(e/s>>0)-a&255}return t+r};f.prototype.writeInt8=function De(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,1,127,-128);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e;return t+1};f.prototype.writeInt16LE=function He(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{O(this,e,t,true)}return t+2};f.prototype.writeInt16BE=function Ne(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{O(this,e,t,false)}return t+2};f.prototype.writeInt32LE=function ze(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,2147483647,-2147483648);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{M(this,e,t,true)}return t+4};f.prototype.writeInt32BE=function qe(e,t,r){e=+e;t=t|0;if(!r)P(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{M(this,e,t,false)}return t+4};function U(e,t,r,n,i,o){if(t>i||t<o)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function D(e,t,r,n,o){if(!o){U(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,r,n,23,4);return r+4}f.prototype.writeFloatLE=function Fe(e,t,r){return D(this,e,t,true,r)};f.prototype.writeFloatBE=function We(e,t,r){return D(this,e,t,false,r)};function H(e,t,r,n,o){if(!o){U(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,r,n,52,8);return r+8}f.prototype.writeDoubleLE=function Ye(e,t,r){return H(this,e,t,true,r)};f.prototype.writeDoubleBE=function Je(e,t,r){return H(this,e,t,false,r)};f.prototype.copy=function Ve(e,t,r,n){if(!r)r=0;if(!n&&n!==0)n=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(n>0&&n<r)n=r;if(n===r)return 0;if(e.length===0||this.length===0)return 0;if(t<0){throw new RangeError("targetStart out of bounds")}if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");if(n>this.length)n=this.length;if(e.length-t<n-r){n=e.length-t+r}var i=n-r;if(i<1e3||!f.TYPED_ARRAY_SUPPORT){for(var o=0;o<i;o++){e[o+t]=this[o+r]}}else{e._set(this.subarray(r,r+i),t)}return i};f.prototype.fill=function $e(e,t,r){if(!e)e=0;if(!t)t=0;if(!r)r=this.length;if(r<t)throw new RangeError("end < start");if(r===t)return;if(this.length===0)return;if(t<0||t>=this.length)throw new RangeError("start out of bounds");if(r<0||r>this.length)throw new RangeError("end out of bounds");var n;if(typeof e==="number"){for(n=t;n<r;n++){this[n]=e}}else{var i=Y(e.toString());var o=i.length;for(n=t;n<r;n++){this[n]=i[n%o]}}return this};f.prototype.toArrayBuffer=function Ge(){if(typeof Uint8Array!=="undefined"){if(f.TYPED_ARRAY_SUPPORT){return new f(this).buffer}else{var e=new Uint8Array(this.length);for(var t=0,r=e.length;t<r;t+=1){e[t]=this[t]}return e.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var N=f.prototype;f._augment=function Ke(e){e.constructor=f;e._isBuffer=true;e._set=e.set;e.get=N.get;e.set=N.set;e.write=N.write;e.toString=N.toString;e.toLocaleString=N.toString;e.toJSON=N.toJSON;e.equals=N.equals;e.compare=N.compare;e.indexOf=N.indexOf;e.copy=N.copy;e.slice=N.slice;e.readUIntLE=N.readUIntLE;e.readUIntBE=N.readUIntBE;e.readUInt8=N.readUInt8;e.readUInt16LE=N.readUInt16LE;e.readUInt16BE=N.readUInt16BE;e.readUInt32LE=N.readUInt32LE;e.readUInt32BE=N.readUInt32BE;e.readIntLE=N.readIntLE;e.readIntBE=N.readIntBE;e.readInt8=N.readInt8;e.readInt16LE=N.readInt16LE;e.readInt16BE=N.readInt16BE;e.readInt32LE=N.readInt32LE;e.readInt32BE=N.readInt32BE;e.readFloatLE=N.readFloatLE;e.readFloatBE=N.readFloatBE;e.readDoubleLE=N.readDoubleLE;e.readDoubleBE=N.readDoubleBE;e.writeUInt8=N.writeUInt8;e.writeUIntLE=N.writeUIntLE;e.writeUIntBE=N.writeUIntBE;e.writeUInt16LE=N.writeUInt16LE;e.writeUInt16BE=N.writeUInt16BE;e.writeUInt32LE=N.writeUInt32LE;e.writeUInt32BE=N.writeUInt32BE;e.writeIntLE=N.writeIntLE;e.writeIntBE=N.writeIntBE;e.writeInt8=N.writeInt8;e.writeInt16LE=N.writeInt16LE;e.writeInt16BE=N.writeInt16BE;e.writeInt32LE=N.writeInt32LE;e.writeInt32BE=N.writeInt32BE;e.writeFloatLE=N.writeFloatLE;e.writeFloatBE=N.writeFloatBE;e.writeDoubleLE=N.writeDoubleLE;e.writeDoubleBE=N.writeDoubleBE;e.fill=N.fill;e.inspect=N.inspect;e.toArrayBuffer=N.toArrayBuffer;return e};var z=/[^+\/0-9A-z\-]/g;function q(e){e=F(e).replace(z,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function F(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function W(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function Y(e,t){t=t||Infinity;var r;var n=e.length;var i=null;var o=[];var s=0;for(;s<n;s++){r=e.charCodeAt(s);if(r>55295&&r<57344){if(i){if(r<56320){if((t-=3)>-1)o.push(239,191,189);i=r;continue}else{r=i-55296<<10|r-56320|65536;i=null}}else{if(r>56319){if((t-=3)>-1)o.push(239,191,189);continue}else if(s+1===n){if((t-=3)>-1)o.push(239,191,189);continue}else{i=r;continue}}}else if(i){if((t-=3)>-1)o.push(239,191,189);i=null}if(r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<2097152){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return o}function J(e){var t=[];for(var r=0;r<e.length;r++){t.push(e.charCodeAt(r)&255)}return t}function V(e,t){var r,n,i;var o=[];for(var s=0;s<e.length;s++){if((t-=2)<0)break;r=e.charCodeAt(s);n=r>>8;i=r%256;o.push(i);o.push(n)}return o}function $(e){return n.toByteArray(q(e))}function G(e,t,r,n){for(var i=0;i<n;i++){if(i+r>=t.length||i>=e.length)break;t[i+r]=e[i]}return i}function K(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}},{"base64-js":35,ieee754:36,"is-array":37}],35:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){"use strict";var t=typeof Uint8Array!=="undefined"?Uint8Array:Array;var r="+".charCodeAt(0);var i="/".charCodeAt(0);var o="0".charCodeAt(0);var s="a".charCodeAt(0);var a="A".charCodeAt(0);var f="-".charCodeAt(0);var u="_".charCodeAt(0);function c(e){var t=e.charCodeAt(0);if(t===r||t===f)return 62;if(t===i||t===u)return 63;if(t<o)return-1;if(t<o+10)return t-o+26+26;if(t<a+26)return t-a;if(t<s+26)return t-s+26}function l(e){var r,n,i,o,s,a;if(e.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var f=e.length;s="="===e.charAt(f-2)?2:"="===e.charAt(f-1)?1:0;a=new t(e.length*3/4-s);i=s>0?e.length-4:e.length;var u=0;function l(e){a[u++]=e}for(r=0,n=0;r<i;r+=4,n+=3){o=c(e.charAt(r))<<18|c(e.charAt(r+1))<<12|c(e.charAt(r+2))<<6|c(e.charAt(r+3));l((o&16711680)>>16);l((o&65280)>>8);l(o&255)}if(s===2){o=c(e.charAt(r))<<2|c(e.charAt(r+1))>>4;l(o&255)}else if(s===1){o=c(e.charAt(r))<<10|c(e.charAt(r+1))<<4|c(e.charAt(r+2))>>2;l(o>>8&255);l(o&255)}return a}function h(e){var t,r=e.length%3,i="",o,s;function a(e){return n.charAt(e)}function f(e){return a(e>>18&63)+a(e>>12&63)+a(e>>6&63)+a(e&63)}for(t=0,s=e.length-r;t<s;t+=3){o=(e[t]<<16)+(e[t+1]<<8)+e[t+2];i+=f(o)}switch(r){case 1:o=e[e.length-1];i+=a(o>>2);i+=a(o<<4&63);i+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1];i+=a(o>>10);i+=a(o>>4&63);i+=a(o<<2&63);i+="=";break}return i}e.toByteArray=l;e.fromByteArray=h})(typeof r==="undefined"?this.base64js={}:r)},{}],36:[function(e,t,r){r.read=function(e,t,r,n,i){var o,s,a=i*8-n-1,f=(1<<a)-1,u=f>>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];l+=h;o=d&(1<<-c)-1;d>>=-c;c+=a;for(;c>0;o=o*256+e[t+l],l+=h,c-=8);s=o&(1<<-c)-1;o>>=-c;c+=n;for(;c>0;s=s*256+e[t+l],l+=h,c-=8);if(o===0){o=1-u}else if(o===f){return s?NaN:(d?-1:1)*Infinity}else{s=s+Math.pow(2,n);o=o-u}return(d?-1:1)*s*Math.pow(2,o-n)};r.write=function(e,t,r,n,i,o){var s,a,f,u=o*8-i-1,c=(1<<u)-1,l=c>>1,h=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){a=isNaN(t)?1:0;s=c}else{s=Math.floor(Math.log(t)/Math.LN2);if(t*(f=Math.pow(2,-s))<1){s--;f*=2}if(s+l>=1){t+=h/f}else{t+=h*Math.pow(2,1-l)}if(t*f>=2){s++;f/=2}if(s+l>=c){a=0;s=c}else if(s+l>=1){a=(t*f-1)*Math.pow(2,i);s=s+l}else{a=t*Math.pow(2,l-1)*Math.pow(2,i);s=0}}for(;i>=8;e[r+d]=a&255,d+=p,a/=256,i-=8);s=s<<i|a;u+=i;for(;u>0;e[r+d]=s&255,d+=p,s/=256,u-=8);e[r+d-p]|=g*128}},{}],37:[function(e,t,r){var n=Array.isArray;var i=Object.prototype.toString;t.exports=n||function(e){return!!e&&"[object Array]"==i.call(e)}},{}],38:[function(e,t,r){function n(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=n;n.EventEmitter=n;n.prototype._events=undefined;n.prototype._maxListeners=undefined;n.defaultMaxListeners=10;n.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};n.prototype.emit=function(e){var t,r,n,o,f,u;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||s(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}throw TypeError('Uncaught, unspecified "error" event.')}}r=this._events[e];if(a(r))return false;if(i(r)){switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:n=arguments.length;o=new Array(n-1);for(f=1;f<n;f++)o[f-1]=arguments[f];r.apply(this,o)}}else if(s(r)){n=arguments.length;o=new Array(n-1);for(f=1;f<n;f++)o[f-1]=arguments[f];u=r.slice();n=u.length;for(f=0;f<n;f++)u[f].apply(this,o)}return true};n.prototype.addListener=function(e,t){var r;if(!i(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,i(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(s(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(s(this._events[e])&&!this._events[e].warned){var r;if(!a(this._maxListeners)){r=this._maxListeners}else{r=n.defaultMaxListeners}if(r&&r>0&&this._events[e].length>r){this._events[e].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[e].length);if(typeof console.trace==="function"){console.trace()}}}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=false;function n(){this.removeListener(e,n);if(!r){r=true;t.apply(this,arguments)}}n.listener=t;this.on(e,n);return this};n.prototype.removeListener=function(e,t){var r,n,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];o=r.length;n=-1;if(r===t||i(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(s(r)){for(a=o;a-->0;){if(r[a]===t||r[a].listener&&r[a].listener===t){n=a;break}}if(n<0)return this;if(r.length===1){r.length=0;delete this._events[e]}else{r.splice(n,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[e])delete this._events[e];return this}if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}this.removeAllListeners("removeListener");this._events={};return this}r=this._events[e];if(i(r)){this.removeListener(e,r)}else{while(r.length)this.removeListener(e,r[r.length-1])}delete this._events[e];return this};n.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(i(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};n.listenerCount=function(e,t){var r;if(!e._events||!e._events[t])r=0;else if(i(e._events[t]))r=1;else r=e._events[t].length;return r};function i(e){return typeof e==="function"}function o(e){return typeof e==="number"}function s(e){return typeof e==="object"&&e!==null}function a(e){return e===void 0}},{}],39:[function(e,t,r){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],40:[function(e,t,r){(function(e){function t(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var i=function(e){return n.exec(e).slice(1)};r.resolve=function(){var r="",n=false;for(var i=arguments.length-1;i>=-1&&!n;i--){var s=i>=0?arguments[i]:e.cwd();if(typeof s!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!s){continue}r=s+"/"+r;n=s.charAt(0)==="/"}r=t(o(r.split("/"),function(e){return!!e}),!n).join("/");return(n?"/":"")+r||"."};r.normalize=function(e){var n=r.isAbsolute(e),i=s(e,-1)==="/";e=t(o(e.split("/"),function(e){return!!e}),!n).join("/");if(!e&&!n){e="."}if(e&&i){e+="/"}return(n?"/":"")+e};r.isAbsolute=function(e){return e.charAt(0)==="/"};r.join=function(){var e=Array.prototype.slice.call(arguments,0);return r.normalize(o(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))};r.relative=function(e,t){e=r.resolve(e).substr(1);t=r.resolve(t).substr(1);function n(e){var t=0;for(;t<e.length;t++){if(e[t]!=="")break}var r=e.length-1;for(;r>=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var i=n(e.split("/"));var o=n(t.split("/"));var s=Math.min(i.length,o.length);var a=s;for(var f=0;f<s;f++){if(i[f]!==o[f]){a=f;break}}var u=[];for(var f=a;f<i.length;f++){u.push("..")}u=u.concat(o.slice(a));return u.join("/")};r.sep="/";r.delimiter=":";r.dirname=function(e){var t=i(e),r=t[0],n=t[1];if(!r&&!n){return"."}if(n){n=n.substr(0,n.length-1)}return r+n};r.basename=function(e,t){var r=i(e)[2];if(t&&r.substr(-1*t.length)===t){r=r.substr(0,r.length-t.length)}return r};r.extname=function(e){return i(e)[3]};function o(e,t){if(e.filter)return e.filter(t);var r=[];for(var n=0;n<e.length;n++){if(t(e[n],n,e))r.push(e[n])}return r}var s="ab".substr(-1)==="b"?function(e,t,r){return e.substr(t,r)}:function(e,t,r){if(t<0)t=e.length+t;return e.substr(t,r)}}).call(this,e("_process"))},{_process:41}],41:[function(e,t,r){var n=t.exports={};var i=[];var o=false;var s;var a=-1;function f(){o=false;if(s.length){i=s.concat(i)}else{a=-1}if(i.length){u()}}function u(){if(o){return}var e=setTimeout(f);o=true;var t=i.length;while(t){s=i;i=[];while(++a<t){s[a].run()}a=-1;t=i.length}s=null;o=false;clearTimeout(e)}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1){for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}}i.push(new c(e,t));if(!o){setTimeout(u,0)}};function c(e,t){this.fun=e;this.array=t}c.prototype.run=function(){this.fun.apply(null,this.array)};n.title="browser";n.browser=true;n.env={};n.argv=[];n.version="";n.versions={};function l(){}n.on=l;n.addListener=l;n.once=l;n.off=l;n.removeListener=l;n.removeAllListeners=l;n.emit=l;n.binding=function(e){throw new Error("process.binding is not supported")};n.cwd=function(){return"/"};n.chdir=function(e){throw new Error("process.chdir is not supported")};n.umask=function(){return 0}},{}],42:[function(t,r,n){(function(t){(function(i){var o=typeof n=="object"&&n&&!n.nodeType&&n;var s=typeof r=="object"&&r&&!r.nodeType&&r;var a=typeof t=="object"&&t;if(a.global===a||a.window===a||a.self===a){i=a}var f,u=2147483647,c=36,l=1,h=26,d=38,p=700,g=72,v=128,m="-",y=/^xn--/,_=/[^\x20-\x7E]/,w=/[\x2E\u3002\uFF0E\uFF61]/g,b={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=c-l,E=Math.floor,x=String.fromCharCode,S;function A(e){throw RangeError(b[e])}function I(e,t){var r=e.length;var n=[];while(r--){n[r]=t(e[r])}return n}function C(e,t){var r=e.split("@");var n="";if(r.length>1){n=r[0]+"@";e=r[1]}e=e.replace(w,".");var i=e.split(".");var o=I(i,t).join(".");return n+o}function L(e){var t=[],r=0,n=e.length,i,o;while(r<n){i=e.charCodeAt(r++);if(i>=55296&&i<=56319&&r<n){o=e.charCodeAt(r++);if((o&64512)==56320){t.push(((i&1023)<<10)+(o&1023)+65536)}else{t.push(i);r--}}else{t.push(i)}}return t}function T(e){return I(e,function(e){var t="";if(e>65535){e-=65536;t+=x(e>>>10&1023|55296);e=56320|e&1023}t+=x(e);return t}).join("")}function B(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return c}function R(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function j(e,t,r){var n=0;e=r?E(e/p):e>>1;e+=E(e/t);for(;e>k*h>>1;n+=c){e=E(e/k)}return E(n+(k+1)*e/(e+d))}function P(e){var t=[],r=e.length,n,i=0,o=v,s=g,a,f,d,p,y,_,w,b,k;a=e.lastIndexOf(m);if(a<0){a=0}for(f=0;f<a;++f){if(e.charCodeAt(f)>=128){A("not-basic")}t.push(e.charCodeAt(f))}for(d=a>0?a+1:0;d<r;){for(p=i,y=1,_=c;;_+=c){if(d>=r){A("invalid-input")}w=B(e.charCodeAt(d++));if(w>=c||w>E((u-i)/y)){A("overflow")}i+=w*y;b=_<=s?l:_>=s+h?h:_-s;if(w<b){break}k=c-b;if(y>E(u/k)){A("overflow")}y*=k}n=t.length+1;s=j(i-p,n,p==0);if(E(i/n)>u-o){A("overflow")}o+=E(i/n);i%=n;t.splice(i++,0,o)}return T(t)}function O(e){var t,r,n,i,o,s,a,f,d,p,y,_=[],w,b,k,S;e=L(e);w=e.length;t=v;r=0;o=g;for(s=0;s<w;++s){y=e[s];if(y<128){_.push(x(y))}}n=i=_.length;if(i){_.push(m)}while(n<w){for(a=u,s=0;s<w;++s){y=e[s];if(y>=t&&y<a){a=y}}b=n+1;if(a-t>E((u-r)/b)){A("overflow")}r+=(a-t)*b;t=a;for(s=0;s<w;++s){y=e[s];if(y<t&&++r>u){A("overflow")}if(y==t){for(f=r,d=c;;d+=c){p=d<=o?l:d>=o+h?h:d-o;if(f<p){break}S=f-p;k=c-p;_.push(x(R(p+S%k,0)));f=E(S/k)}_.push(x(R(f,0)));o=j(r,b,n==i);r=0;++n}}++r;++t}return _.join("")}function M(e){return C(e,function(e){return y.test(e)?P(e.slice(4).toLowerCase()):e})}function U(e){return C(e,function(e){return _.test(e)?"xn--"+O(e):e})}f={version:"1.3.2",ucs2:{decode:L,encode:T},decode:P,encode:O,toASCII:U,toUnicode:M};if(typeof e=="function"&&typeof e.amd=="object"&&e.amd){e("punycode",function(){return f})}else if(o&&s){if(r.exports==o){s.exports=f}else{for(S in f){f.hasOwnProperty(S)&&(o[S]=f[S])}}}else{i.punycode=f}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],43:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&";r=r||"=";var s={};if(typeof e!=="string"||e.length===0){return s}var a=/\+/g;e=e.split(t);var f=1e3;if(o&&typeof o.maxKeys==="number"){f=o.maxKeys}var u=e.length;if(f>0&&u>f){u=f}for(var c=0;c<u;++c){var l=e[c].replace(a,"%20"),h=l.indexOf(r),d,p,g,v;if(h>=0){d=l.substr(0,h);p=l.substr(h+1)}else{d=l;p=""}g=decodeURIComponent(d);v=decodeURIComponent(p);if(!n(s,g)){s[g]=v}else if(i(s[g])){s[g].push(v)}else{s[g]=[s[g],v]}}return s};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],44:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,a){t=t||"&";r=r||"=";if(e===null){e=undefined}if(typeof e==="object"){return o(s(e),function(s){var a=encodeURIComponent(n(s))+r;if(i(e[s])){return o(e[s],function(e){return a+encodeURIComponent(n(e))}).join(t)}else{return a+encodeURIComponent(n(e[s]))}}).join(t)}if(!a)return"";return encodeURIComponent(n(a))+r+encodeURIComponent(n(e))};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};function o(e,t){if(e.map)return e.map(t);var r=[];for(var n=0;n<e.length;n++){r.push(t(e[n],n))}return r}var s=Object.keys||function(e){var t=[];for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t.push(r)}return t}},{}],45:[function(e,t,r){"use strict";r.decode=r.parse=e("./decode");r.encode=r.stringify=e("./encode")},{"./decode":43,"./encode":44}],46:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":47}],47:[function(e,t,r){(function(r){t.exports=a;var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};var i=e("core-util-is");i.inherits=e("inherits");var o=e("./_stream_readable");var s=e("./_stream_writable");i.inherits(a,o);u(n(s.prototype),function(e){if(!a.prototype[e])a.prototype[e]=s.prototype[e]});function a(e){if(!(this instanceof a))return new a(e);o.call(this,e);s.call(this,e);if(e&&e.readable===false)this.readable=false;if(e&&e.writable===false)this.writable=false;this.allowHalfOpen=true;if(e&&e.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",f)}function f(){if(this.allowHalfOpen||this._writableState.ended)return;r.nextTick(this.end.bind(this))}function u(e,t){for(var r=0,n=e.length;r<n;r++){t(e[r],r)}}}).call(this,e("_process"))},{"./_stream_readable":49,"./_stream_writable":51,_process:41,"core-util-is":52,inherits:94}],48:[function(e,t,r){t.exports=o;var n=e("./_stream_transform");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(o,n);function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}o.prototype._transform=function(e,t,r){
  r(null,e)}},{"./_stream_transform":50,"core-util-is":52,inherits:94}],49:[function(e,t,r){(function(r){t.exports=l;var n=e("isarray");var i=e("buffer").Buffer;l.ReadableState=c;var o=e("events").EventEmitter;if(!o.listenerCount)o.listenerCount=function(e,t){return e.listeners(t).length};var s=e("stream");var a=e("core-util-is");a.inherits=e("inherits");var f;var u=e("util");if(u&&u.debuglog){u=u.debuglog("stream")}else{u=function(){}}a.inherits(l,s);function c(t,r){var n=e("./_stream_duplex");t=t||{};var i=t.highWaterMark;var o=t.objectMode?16:16*1024;this.highWaterMark=i||i===0?i:o;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=null;this.ended=false;this.endEmitted=false;this.reading=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!t.objectMode;if(r instanceof n)this.objectMode=this.objectMode||!!t.readableObjectMode;this.defaultEncoding=t.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(t.encoding){if(!f)f=e("string_decoder/").StringDecoder;this.decoder=new f(t.encoding);this.encoding=t.encoding}}function l(t){var r=e("./_stream_duplex");if(!(this instanceof l))return new l(t);this._readableState=new c(t,this);this.readable=true;s.call(this)}l.prototype.push=function(e,t){var r=this._readableState;if(a.isString(e)&&!r.objectMode){t=t||r.defaultEncoding;if(t!==r.encoding){e=new i(e,t);t=""}}return h(this,r,e,t,false)};l.prototype.unshift=function(e){var t=this._readableState;return h(this,t,e,"",true)};function h(e,t,r,n,i){var o=m(t,r);if(o){e.emit("error",o)}else if(a.isNullOrUndefined(r)){t.reading=false;if(!t.ended)y(e,t)}else if(t.objectMode||r&&r.length>0){if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{if(t.decoder&&!i&&!n)r=t.decoder.write(r);if(!i)t.reading=false;if(t.flowing&&t.length===0&&!t.sync){e.emit("data",r);e.read(0)}else{t.length+=t.objectMode?1:r.length;if(i)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)_(e)}b(e,t)}}else if(!i){t.reading=false}return d(t)}function d(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}l.prototype.setEncoding=function(t){if(!f)f=e("string_decoder/").StringDecoder;this._readableState.decoder=new f(t);this._readableState.encoding=t;return this};var p=8388608;function g(e){if(e>=p){e=p}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function v(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(isNaN(e)||a.isNull(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=g(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}l.prototype.read=function(e){u("read",e);var t=this._readableState;var r=e;if(!a.isNumber(e)||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){u("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)C(this);else _(this);return null}e=v(e,t);if(e===0&&t.ended){if(t.length===0)C(this);return null}var n=t.needReadable;u("need readable",n);if(t.length===0||t.length-e<t.highWaterMark){n=true;u("length less than watermark",n)}if(t.ended||t.reading){n=false;u("reading or ended",n)}if(n){u("do read");t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(n&&!t.reading)e=v(r,t);var i;if(e>0)i=I(e,t);else i=null;if(a.isNull(i)){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(r!==e&&t.ended&&t.length===0)C(this);if(!a.isNull(i))this.emit("data",i);return i};function m(e,t){var r=null;if(!a.isBuffer(t)&&!a.isString(t)&&!a.isNullOrUndefined(t)&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function y(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;_(e)}function _(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){u("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)r.nextTick(function(){w(e)});else w(e)}}function w(e){u("emit readable");e.emit("readable");A(e)}function b(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){k(e,t)})}}function k(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){u("maybeReadMore read 0");e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}l.prototype._read=function(e){this.emit("error",new Error("not implemented"))};l.prototype.pipe=function(e,t){var i=this;var s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e);break}s.pipesCount+=1;u("pipe count=%d opts=%j",s.pipesCount,t);var a=(!t||t.end!==false)&&e!==r.stdout&&e!==r.stderr;var f=a?l:d;if(s.endEmitted)r.nextTick(f);else i.once("end",f);e.on("unpipe",c);function c(e){u("onunpipe");if(e===i){d()}}function l(){u("onend");e.end()}var h=E(i);e.on("drain",h);function d(){u("cleanup");e.removeListener("close",v);e.removeListener("finish",m);e.removeListener("drain",h);e.removeListener("error",g);e.removeListener("unpipe",c);i.removeListener("end",l);i.removeListener("end",d);i.removeListener("data",p);if(s.awaitDrain&&(!e._writableState||e._writableState.needDrain))h()}i.on("data",p);function p(t){u("ondata");var r=e.write(t);if(false===r){u("false write response, pause",i._readableState.awaitDrain);i._readableState.awaitDrain++;i.pause()}}function g(t){u("onerror",t);y();e.removeListener("error",g);if(o.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",g);else if(n(e._events.error))e._events.error.unshift(g);else e._events.error=[g,e._events.error];function v(){e.removeListener("finish",m);y()}e.once("close",v);function m(){u("onfinish");e.removeListener("close",v);y()}e.once("finish",m);function y(){u("unpipe");i.unpipe(e)}e.emit("pipe",i);if(!s.flowing){u("pipe resume");i.resume()}return e};function E(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&o.listenerCount(e,"data")){t.flowing=true;A(e)}}}l.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1){if(e&&e!==t.pipes)return this;if(!e)e=t.pipes;t.pipes=null;t.pipesCount=0;t.flowing=false;if(e)e.emit("unpipe",this);return this}if(!e){var r=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var i=T(t.pipes,e);if(i===-1)return this;t.pipes.splice(i,1);t.pipesCount-=1;if(t.pipesCount===1)t.pipes=t.pipes[0];e.emit("unpipe",this);return this};l.prototype.on=function(e,t){var n=s.prototype.on.call(this,e,t);if(e==="data"&&false!==this._readableState.flowing){this.resume()}if(e==="readable"&&this.readable){var i=this._readableState;if(!i.readableListening){i.readableListening=true;i.emittedReadable=false;i.needReadable=true;if(!i.reading){var o=this;r.nextTick(function(){u("readable nexttick read 0");o.read(0)})}else if(i.length){_(this,i)}}}return n};l.prototype.addListener=l.prototype.on;l.prototype.resume=function(){var e=this._readableState;if(!e.flowing){u("resume");e.flowing=true;if(!e.reading){u("resume read 0");this.read(0)}x(this,e)}return this};function x(e,t){if(!t.resumeScheduled){t.resumeScheduled=true;r.nextTick(function(){S(e,t)})}}function S(e,t){t.resumeScheduled=false;e.emit("resume");A(e);if(t.flowing&&!t.reading)e.read(0)}l.prototype.pause=function(){u("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){u("pause");this._readableState.flowing=false;this.emit("pause")}return this};function A(e){var t=e._readableState;u("flow",t.flowing);if(t.flowing){do{var r=e.read()}while(null!==r&&t.flowing)}}l.prototype.wrap=function(e){var t=this._readableState;var r=false;var n=this;e.on("end",function(){u("wrapped end");if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)n.push(e)}n.push(null)});e.on("data",function(i){u("wrapped data");if(t.decoder)i=t.decoder.write(i);if(!i||!t.objectMode&&!i.length)return;var o=n.push(i);if(!o){r=true;e.pause()}});for(var i in e){if(a.isFunction(e[i])&&a.isUndefined(this[i])){this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i)}}var o=["error","close","destroy","pause","resume"];L(o,function(t){e.on(t,n.emit.bind(n,t))});n._read=function(t){u("wrapped _read",t);if(r){r=false;e.resume()}};return n};l._fromList=I;function I(e,t){var r=t.buffer;var n=t.length;var o=!!t.decoder;var s=!!t.objectMode;var a;if(r.length===0)return null;if(n===0)a=null;else if(s)a=r.shift();else if(!e||e>=n){if(o)a=r.join("");else a=i.concat(r,n);r.length=0}else{if(e<r[0].length){var f=r[0];a=f.slice(0,e);r[0]=f.slice(e)}else if(e===r[0].length){a=r.shift()}else{if(o)a="";else a=new i(e);var u=0;for(var c=0,l=r.length;c<l&&u<e;c++){var f=r[0];var h=Math.min(e-u,f.length);if(o)a+=f.slice(0,h);else f.copy(a,u,0,h);if(h<f.length)r[0]=f.slice(h);else r.shift();u+=h}}}return a}function C(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function L(e,t){for(var r=0,n=e.length;r<n;r++){t(e[r],r)}}function T(e,t){for(var r=0,n=e.length;r<n;r++){if(e[r]===t)return r}return-1}}).call(this,e("_process"))},{"./_stream_duplex":47,_process:41,buffer:34,"core-util-is":52,events:38,inherits:94,isarray:39,stream:57,"string_decoder/":58,util:33}],50:[function(e,t,r){t.exports=a;var n=e("./_stream_duplex");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(a,n);function o(e,t){this.afterTransform=function(e,r){return s(t,e,r)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function s(e,t,r){var n=e._transformState;n.transforming=false;var o=n.writecb;if(!o)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null;n.writecb=null;if(!i.isNullOrUndefined(r))e.push(r);if(o)o(t);var s=e._readableState;s.reading=false;if(s.needReadable||s.length<s.highWaterMark){e._read(s.highWaterMark)}}function a(e){if(!(this instanceof a))return new a(e);n.call(this,e);this._transformState=new o(e,this);var t=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("prefinish",function(){if(i.isFunction(this._flush))this._flush(function(e){f(t,e)});else f(t)})}a.prototype.push=function(e,t){this._transformState.needTransform=false;return n.prototype.push.call(this,e,t)};a.prototype._transform=function(e,t,r){throw new Error("not implemented")};a.prototype._write=function(e,t,r){var n=this._transformState;n.writecb=r;n.writechunk=e;n.writeencoding=t;if(!n.transforming){var i=this._readableState;if(n.needTransform||i.needReadable||i.length<i.highWaterMark)this._read(i.highWaterMark)}};a.prototype._read=function(e){var t=this._transformState;if(!i.isNull(t.writechunk)&&t.writecb&&!t.transforming){t.transforming=true;this._transform(t.writechunk,t.writeencoding,t.afterTransform)}else{t.needTransform=true}};function f(e,t){if(t)return e.emit("error",t);var r=e._writableState;var n=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(n.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":47,"core-util-is":52,inherits:94}],51:[function(e,t,r){(function(r){t.exports=f;var n=e("buffer").Buffer;f.WritableState=a;var i=e("core-util-is");i.inherits=e("inherits");var o=e("stream");i.inherits(f,o);function s(e,t,r){this.chunk=e;this.encoding=t;this.callback=r}function a(t,r){var n=e("./_stream_duplex");t=t||{};var i=t.highWaterMark;var o=t.objectMode?16:16*1024;this.highWaterMark=i||i===0?i:o;this.objectMode=!!t.objectMode;if(r instanceof n)this.objectMode=this.objectMode||!!t.writableObjectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var s=t.decodeStrings===false;this.decodeStrings=!s;this.defaultEncoding=t.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){v(r,e)};this.writecb=null;this.writelen=0;this.buffer=[];this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}function f(t){var r=e("./_stream_duplex");if(!(this instanceof f)&&!(this instanceof r))return new f(t);this._writableState=new a(t,this);this.writable=true;o.call(this)}f.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function u(e,t,n){var i=new Error("write after end");e.emit("error",i);r.nextTick(function(){n(i)})}function c(e,t,n,o){var s=true;if(!i.isBuffer(n)&&!i.isString(n)&&!i.isNullOrUndefined(n)&&!t.objectMode){var a=new TypeError("Invalid non-string/buffer chunk");e.emit("error",a);r.nextTick(function(){o(a)});s=false}return s}f.prototype.write=function(e,t,r){var n=this._writableState;var o=false;if(i.isFunction(t)){r=t;t=null}if(i.isBuffer(e))t="buffer";else if(!t)t=n.defaultEncoding;if(!i.isFunction(r))r=function(){};if(n.ended)u(this,n,r);else if(c(this,n,e,r)){n.pendingcb++;o=h(this,n,e,t,r)}return o};f.prototype.cork=function(){var e=this._writableState;e.corked++};f.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.buffer.length)_(this,e)}};function l(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&i.isString(t)){t=new n(t,r)}return t}function h(e,t,r,n,o){r=l(t,r,n);if(i.isBuffer(r))n="buffer";var a=t.objectMode?1:r.length;t.length+=a;var f=t.length<t.highWaterMark;if(!f)t.needDrain=true;if(t.writing||t.corked)t.buffer.push(new s(r,n,o));else d(e,t,false,a,r,n,o);return f}function d(e,t,r,n,i,o,s){t.writelen=n;t.writecb=s;t.writing=true;t.sync=true;if(r)e._writev(i,t.onwrite);else e._write(i,o,t.onwrite);t.sync=false}function p(e,t,n,i,o){if(n)r.nextTick(function(){t.pendingcb--;o(i)});else{t.pendingcb--;o(i)}e._writableState.errorEmitted=true;e.emit("error",i)}function g(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function v(e,t){var n=e._writableState;var i=n.sync;var o=n.writecb;g(n);if(t)p(e,n,i,t,o);else{var s=w(e,n);if(!s&&!n.corked&&!n.bufferProcessing&&n.buffer.length){_(e,n)}if(i){r.nextTick(function(){m(e,n,s,o)})}else{m(e,n,s,o)}}}function m(e,t,r,n){if(!r)y(e,t);t.pendingcb--;n();k(e,t)}function y(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function _(e,t){t.bufferProcessing=true;if(e._writev&&t.buffer.length>1){var r=[];for(var n=0;n<t.buffer.length;n++)r.push(t.buffer[n].callback);t.pendingcb++;d(e,t,true,t.length,t.buffer,"",function(e){for(var n=0;n<r.length;n++){t.pendingcb--;r[n](e)}});t.buffer=[]}else{for(var n=0;n<t.buffer.length;n++){var i=t.buffer[n];var o=i.chunk;var s=i.encoding;var a=i.callback;var f=t.objectMode?1:o.length;d(e,t,false,f,o,s,a);if(t.writing){n++;break}}if(n<t.buffer.length)t.buffer=t.buffer.slice(n);else t.buffer.length=0}t.bufferProcessing=false}f.prototype._write=function(e,t,r){r(new Error("not implemented"))};f.prototype._writev=null;f.prototype.end=function(e,t,r){var n=this._writableState;if(i.isFunction(e)){r=e;e=null;t=null}else if(i.isFunction(t)){r=t;t=null}if(!i.isNullOrUndefined(e))this.write(e,t);if(n.corked){n.corked=1;this.uncork()}if(!n.ending&&!n.finished)E(this,n,r)};function w(e,t){return t.ending&&t.length===0&&!t.finished&&!t.writing}function b(e,t){if(!t.prefinished){t.prefinished=true;e.emit("prefinish")}}function k(e,t){var r=w(e,t);if(r){if(t.pendingcb===0){b(e,t);t.finished=true;e.emit("finish")}else b(e,t)}return r}function E(e,t,n){t.ending=true;k(e,t);if(n){if(t.finished)r.nextTick(n);else e.once("finish",n)}t.ended=true}}).call(this,e("_process"))},{"./_stream_duplex":47,_process:41,buffer:34,"core-util-is":52,inherits:94,stream:57}],52:[function(e,t,r){(function(e){function t(e){return Array.isArray(e)}r.isArray=t;function n(e){return typeof e==="boolean"}r.isBoolean=n;function i(e){return e===null}r.isNull=i;function o(e){return e==null}r.isNullOrUndefined=o;function s(e){return typeof e==="number"}r.isNumber=s;function a(e){return typeof e==="string"}r.isString=a;function f(e){return typeof e==="symbol"}r.isSymbol=f;function u(e){return e===void 0}r.isUndefined=u;function c(e){return l(e)&&m(e)==="[object RegExp]"}r.isRegExp=c;function l(e){return typeof e==="object"&&e!==null}r.isObject=l;function h(e){return l(e)&&m(e)==="[object Date]"}r.isDate=h;function d(e){return l(e)&&(m(e)==="[object Error]"||e instanceof Error)}r.isError=d;function p(e){return typeof e==="function"}r.isFunction=p;function g(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=g;function v(t){return e.isBuffer(t)}r.isBuffer=v;function m(e){return Object.prototype.toString.call(e)}}).call(this,e("buffer").Buffer)},{buffer:34}],53:[function(e,t,r){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":48}],54:[function(e,t,r){r=t.exports=e("./lib/_stream_readable.js");r.Stream=e("stream");r.Readable=r;r.Writable=e("./lib/_stream_writable.js");r.Duplex=e("./lib/_stream_duplex.js");r.Transform=e("./lib/_stream_transform.js");r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":47,"./lib/_stream_passthrough.js":48,"./lib/_stream_readable.js":49,"./lib/_stream_transform.js":50,"./lib/_stream_writable.js":51,stream:57}],55:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":50}],56:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":51}],57:[function(e,t,r){t.exports=o;var n=e("events").EventEmitter;var i=e("inherits");i(o,n);o.Readable=e("readable-stream/readable.js");o.Writable=e("readable-stream/writable.js");o.Duplex=e("readable-stream/duplex.js");o.Transform=e("readable-stream/transform.js");o.PassThrough=e("readable-stream/passthrough.js");o.Stream=o;function o(){n.call(this)}o.prototype.pipe=function(e,t){var r=this;function i(t){if(e.writable){if(false===e.write(t)&&r.pause){r.pause()}}}r.on("data",i);function o(){if(r.readable&&r.resume){r.resume()}}e.on("drain",o);if(!e._isStdio&&(!t||t.end!==false)){r.on("end",a);r.on("close",f)}var s=false;function a(){if(s)return;s=true;e.end()}function f(){if(s)return;s=true;if(typeof e.destroy==="function")e.destroy()}function u(e){c();if(n.listenerCount(this,"error")===0){throw e}}r.on("error",u);e.on("error",u);function c(){r.removeListener("data",i);e.removeListener("drain",o);r.removeListener("end",a);r.removeListener("close",f);r.removeListener("error",u);e.removeListener("error",u);r.removeListener("end",c);r.removeListener("close",c);e.removeListener("close",c)}r.on("end",c);r.on("close",c);e.on("close",c);e.emit("pipe",r);return e}},{events:38,inherits:94,"readable-stream/duplex.js":46,"readable-stream/passthrough.js":53,"readable-stream/readable.js":54,"readable-stream/transform.js":55,"readable-stream/writable.js":56}],58:[function(e,t,r){var n=e("buffer").Buffer;var i=n.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return true;default:return false}};function o(e){if(e&&!i(e)){throw new Error("Unknown encoding: "+e)}}var s=r.StringDecoder=function(e){this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,"");o(e);switch(this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2;this.detectIncompleteChar=f;break;case"base64":this.surrogateSize=3;this.detectIncompleteChar=u;break;default:this.write=a;return}this.charBuffer=new n(6);this.charReceived=0;this.charLength=0};s.prototype.write=function(e){var t="";while(this.charLength){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;e.copy(this.charBuffer,this.charReceived,0,r);this.charReceived+=r;if(this.charReceived<this.charLength){return""}e=e.slice(r,e.length);t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var n=t.charCodeAt(t.length-1);if(n>=55296&&n<=56319){this.charLength+=this.surrogateSize;t="";continue}this.charReceived=this.charLength=0;if(e.length===0){return t}break}this.detectIncompleteChar(e);var i=e.length;if(this.charLength){e.copy(this.charBuffer,0,e.length-this.charReceived,i);i-=this.charReceived}t+=e.toString(this.encoding,0,i);var i=t.length-1;var n=t.charCodeAt(i);if(n>=55296&&n<=56319){var o=this.surrogateSize;this.charLength+=o;this.charReceived+=o;this.charBuffer.copy(this.charBuffer,o,0,o);e.copy(this.charBuffer,0,0,o);return t.substring(0,i)}return t};s.prototype.detectIncompleteChar=function(e){var t=e.length>=3?3:e.length;for(;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t};s.prototype.end=function(e){var t="";if(e&&e.length)t=this.write(e);if(this.charReceived){var r=this.charReceived;var n=this.charBuffer;var i=this.encoding;t+=n.slice(0,r).toString(i)}return t};function a(e){return e.toString(this.encoding)}function f(e){this.charReceived=e.length%2;this.charLength=this.charReceived?2:0}function u(e){this.charReceived=e.length%3;this.charLength=this.charReceived?3:0}},{buffer:34}],59:[function(e,t,r){var n=e("punycode");r.parse=_;r.resolve=b;r.resolveObject=k;r.format=w;r.Url=i;function i(){this.protocol=null;this.slashes=null;this.auth=null;this.host=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.query=null;this.pathname=null;this.path=null;this.href=null}var o=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,a=["<",">",'"',"`"," ","\r","\n","	"],f=["{","}","|","\\","^","`"].concat(a),u=["'"].concat(f),c=["%","/","?",";","#"].concat(u),l=["/","?","#"],h=255,d=/^[a-z0-9A-Z_-]{0,63}$/,p=/^([a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:true,"javascript:":true},v={javascript:true,"javascript:":true},m={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},y=e("querystring");function _(e,t,r){if(e&&x(e)&&e instanceof i)return e;var n=new i;n.parse(e,t,r);return n}i.prototype.parse=function(e,t,r){if(!E(e)){throw new TypeError("Parameter 'url' must be a string, not "+typeof e)}var i=e;i=i.trim();var s=o.exec(i);if(s){s=s[0];var a=s.toLowerCase();this.protocol=a;i=i.substr(s.length)}if(r||s||i.match(/^\/\/[^@\/]+@[^@\/]+/)){var f=i.substr(0,2)==="//";if(f&&!(s&&v[s])){i=i.substr(2);this.slashes=true}}if(!v[s]&&(f||s&&!m[s])){var _=-1;for(var w=0;w<l.length;w++){var b=i.indexOf(l[w]);if(b!==-1&&(_===-1||b<_))_=b}var k,x;if(_===-1){x=i.lastIndexOf("@")}else{x=i.lastIndexOf("@",_)}if(x!==-1){k=i.slice(0,x);i=i.slice(x+1);this.auth=decodeURIComponent(k)}_=-1;for(var w=0;w<c.length;w++){var b=i.indexOf(c[w]);if(b!==-1&&(_===-1||b<_))_=b}if(_===-1)_=i.length;this.host=i.slice(0,_);i=i.slice(_);this.parseHost();this.hostname=this.hostname||"";var S=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!S){var A=this.hostname.split(/\./);for(var w=0,I=A.length;w<I;w++){var C=A[w];if(!C)continue;if(!C.match(d)){var L="";for(var T=0,B=C.length;T<B;T++){if(C.charCodeAt(T)>127){L+="x"}else{L+=C[T]}}if(!L.match(d)){var R=A.slice(0,w);var j=A.slice(w+1);var P=C.match(p);if(P){R.push(P[1]);j.unshift(P[2])}if(j.length){i="/"+j.join(".")+i}this.hostname=R.join(".");break}}}}if(this.hostname.length>h){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!S){var O=this.hostname.split(".");var M=[];for(var w=0;w<O.length;++w){var U=O[w];M.push(U.match(/[^A-Za-z0-9_-]/)?"xn--"+n.encode(U):U)}this.hostname=M.join(".")}var D=this.port?":"+this.port:"";var H=this.hostname||"";this.host=H+D;this.href+=this.host;if(S){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(i[0]!=="/"){i="/"+i}}}if(!g[a]){for(var w=0,I=u.length;w<I;w++){var N=u[w];var z=encodeURIComponent(N);if(z===N){z=escape(N)}i=i.split(N).join(z)}}var q=i.indexOf("#");if(q!==-1){this.hash=i.substr(q);i=i.slice(0,q)}var F=i.indexOf("?");if(F!==-1){this.search=i.substr(F);this.query=i.substr(F+1);if(t){this.query=y.parse(this.query)}i=i.slice(0,F)}else if(t){this.search="";this.query={}}if(i)this.pathname=i;if(m[a]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var D=this.pathname||"";var U=this.search||"";this.path=D+U}this.href=this.format();return this};function w(e){if(E(e))e=_(e);if(!(e instanceof i))return i.prototype.format.call(e);return e.format()}i.prototype.format=function(){var e=this.auth||"";if(e){e=encodeURIComponent(e);e=e.replace(/%3A/i,":");e+="@"}var t=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=false,o="";if(this.host){i=e+this.host}else if(this.hostname){i=e+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]");if(this.port){i+=":"+this.port}}if(this.query&&x(this.query)&&Object.keys(this.query).length){o=y.stringify(this.query)}var s=this.search||o&&"?"+o||"";if(t&&t.substr(-1)!==":")t+=":";if(this.slashes||(!t||m[t])&&i!==false){i="//"+(i||"");if(r&&r.charAt(0)!=="/")r="/"+r}else if(!i){i=""}if(n&&n.charAt(0)!=="#")n="#"+n;if(s&&s.charAt(0)!=="?")s="?"+s;r=r.replace(/[?#]/g,function(e){return encodeURIComponent(e)});s=s.replace("#","%23");return t+i+r+s+n};function b(e,t){return _(e,false,true).resolve(t)}i.prototype.resolve=function(e){return this.resolveObject(_(e,false,true)).format()};function k(e,t){if(!e)return t;return _(e,false,true).resolveObject(t)}i.prototype.resolveObject=function(e){if(E(e)){var t=new i;t.parse(e,false,true);e=t}var r=new i;Object.keys(this).forEach(function(e){r[e]=this[e]},this);r.hash=e.hash;if(e.href===""){r.href=r.format();return r}if(e.slashes&&!e.protocol){Object.keys(e).forEach(function(t){if(t!=="protocol")r[t]=e[t]});if(m[r.protocol]&&r.hostname&&!r.pathname){r.path=r.pathname="/"}r.href=r.format();return r}if(e.protocol&&e.protocol!==r.protocol){if(!m[e.protocol]){Object.keys(e).forEach(function(t){r[t]=e[t]});r.href=r.format();return r}r.protocol=e.protocol;if(!e.host&&!v[e.protocol]){var n=(e.pathname||"").split("/");while(n.length&&!(e.host=n.shift()));if(!e.host)e.host="";if(!e.hostname)e.hostname="";if(n[0]!=="")n.unshift("");if(n.length<2)n.unshift("");r.pathname=n.join("/")}else{r.pathname=e.pathname}r.search=e.search;r.query=e.query;r.host=e.host||"";r.auth=e.auth;r.hostname=e.hostname||e.host;r.port=e.port;if(r.pathname||r.search){var o=r.pathname||"";var s=r.search||"";r.path=o+s}r.slashes=r.slashes||e.slashes;r.href=r.format();return r}var a=r.pathname&&r.pathname.charAt(0)==="/",f=e.host||e.pathname&&e.pathname.charAt(0)==="/",u=f||a||r.host&&e.pathname,c=u,l=r.pathname&&r.pathname.split("/")||[],n=e.pathname&&e.pathname.split("/")||[],h=r.protocol&&!m[r.protocol];if(h){r.hostname="";r.port=null;if(r.host){if(l[0]==="")l[0]=r.host;else l.unshift(r.host)}r.host="";if(e.protocol){e.hostname=null;e.port=null;if(e.host){if(n[0]==="")n[0]=e.host;else n.unshift(e.host)}e.host=null}u=u&&(n[0]===""||l[0]==="")}if(f){r.host=e.host||e.host===""?e.host:r.host;r.hostname=e.hostname||e.hostname===""?e.hostname:r.hostname;r.search=e.search;r.query=e.query;l=n}else if(n.length){if(!l)l=[];l.pop();l=l.concat(n);r.search=e.search;r.query=e.query}else if(!A(e.search)){if(h){r.hostname=r.host=l.shift();var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}r.search=e.search;r.query=e.query;if(!S(r.pathname)||!S(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.href=r.format();return r}if(!l.length){r.pathname=null;if(r.search){r.path="/"+r.search}else{r.path=null}r.href=r.format();return r}var p=l.slice(-1)[0];var g=(r.host||e.host)&&(p==="."||p==="..")||p==="";var y=0;for(var _=l.length;_>=0;_--){p=l[_];if(p=="."){l.splice(_,1)}else if(p===".."){l.splice(_,1);y++}else if(y){l.splice(_,1);y--}}if(!u&&!c){for(;y--;y){l.unshift("..")}}if(u&&l[0]!==""&&(!l[0]||l[0].charAt(0)!=="/")){l.unshift("")}if(g&&l.join("/").substr(-1)!=="/"){l.push("")}var w=l[0]===""||l[0]&&l[0].charAt(0)==="/";if(h){r.hostname=r.host=w?"":l.length?l.shift():"";var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}u=u||r.host&&l.length;if(u&&!w){l.unshift("")}if(!l.length){r.pathname=null;r.path=null}else{r.pathname=l.join("/")}if(!S(r.pathname)||!S(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.auth=e.auth||r.auth;r.slashes=r.slashes||e.slashes;r.href=r.format();return r};i.prototype.parseHost=function(){var e=this.host;var t=s.exec(e);if(t){t=t[0];if(t!==":"){this.port=t.substr(1)}e=e.substr(0,e.length-t.length)}if(e)this.hostname=e};function E(e){return typeof e==="string"}function x(e){return typeof e==="object"&&e!==null}function S(e){return e===null}function A(e){return e==null}},{punycode:42,querystring:45}],60:[function(e,t,r){t.exports=function n(e){return e&&typeof e==="object"&&typeof e.copy==="function"&&typeof e.fill==="function"&&typeof e.readUInt8==="function"}},{}],61:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!k(e)){var t=[];for(var r=0;r<arguments.length;r++){t.push(a(arguments[r]))}return t.join(" ")}var r=1;var n=arguments;var o=n.length;var s=String(e).replace(i,function(e){if(e==="%%")return"%";if(r>=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return e}});for(var f=n[r];r<o;f=n[++r]){if(_(f)||!A(f)){s+=" "+f}else{s+=" "+a(f)}}return s};r.deprecate=function(e,i){if(x(n.process)){return function(){return r.deprecate(e,i).apply(this,arguments)}}if(t.noDeprecation===true){return e}var o=false;function s(){if(!o){if(t.throwDeprecation){throw new Error(i)}else if(t.traceDeprecation){console.trace(i)}else{console.error(i)}o=true}return e.apply(this,arguments)}return s};var o={};var s;r.debuglog=function(e){if(x(s))s=t.env.NODE_DEBUG||"";e=e.toUpperCase();if(!o[e]){if(new RegExp("\\b"+e+"\\b","i").test(s)){var n=t.pid;o[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else{o[e]=function(){}}}return o[e]};function a(e,t){var n={seen:[],stylize:u};if(arguments.length>=3)n.depth=arguments[2];if(arguments.length>=4)n.colors=arguments[3];if(y(t)){n.showHidden=t}else if(t){r._extend(n,t)}if(x(n.showHidden))n.showHidden=false;if(x(n.depth))n.depth=2;if(x(n.colors))n.colors=false;if(x(n.customInspect))n.customInspect=true;if(n.colors)n.stylize=f;return l(n,e,n.depth)}r.inspect=a;a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};a.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function f(e,t){var r=a.styles[t];if(r){return"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m"}else{return e}}function u(e,t){return e}function c(e){var t={};e.forEach(function(e,r){t[e]=true});return t}function l(e,t,n){if(e.customInspect&&t&&L(t.inspect)&&t.inspect!==r.inspect&&!(t.constructor&&t.constructor.prototype===t)){var i=t.inspect(n,e);if(!k(i)){i=l(e,i,n)}return i}var o=h(e,t);if(o){return o}var s=Object.keys(t);var a=c(s);if(e.showHidden){s=Object.getOwnPropertyNames(t)}if(C(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0)){return d(t)}if(s.length===0){if(L(t)){var f=t.name?": "+t.name:"";return e.stylize("[Function"+f+"]","special");
  
  }if(S(t)){return e.stylize(RegExp.prototype.toString.call(t),"regexp")}if(I(t)){return e.stylize(Date.prototype.toString.call(t),"date")}if(C(t)){return d(t)}}var u="",y=false,_=["{","}"];if(m(t)){y=true;_=["[","]"]}if(L(t)){var w=t.name?": "+t.name:"";u=" [Function"+w+"]"}if(S(t)){u=" "+RegExp.prototype.toString.call(t)}if(I(t)){u=" "+Date.prototype.toUTCString.call(t)}if(C(t)){u=" "+d(t)}if(s.length===0&&(!y||t.length==0)){return _[0]+u+_[1]}if(n<0){if(S(t)){return e.stylize(RegExp.prototype.toString.call(t),"regexp")}else{return e.stylize("[Object]","special")}}e.seen.push(t);var b;if(y){b=p(e,t,n,a,s)}else{b=s.map(function(r){return g(e,t,n,a,r,y)})}e.seen.pop();return v(b,u,_)}function h(e,t){if(x(t))return e.stylize("undefined","undefined");if(k(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(b(t))return e.stylize(""+t,"number");if(y(t))return e.stylize(""+t,"boolean");if(_(t))return e.stylize("null","null")}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,r,n,i){var o=[];for(var s=0,a=t.length;s<a;++s){if(O(t,String(s))){o.push(g(e,t,r,n,String(s),true))}else{o.push("")}}i.forEach(function(i){if(!i.match(/^\d+$/)){o.push(g(e,t,r,n,i,true))}});return o}function g(e,t,r,n,i,o){var s,a,f;f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]};if(f.get){if(f.set){a=e.stylize("[Getter/Setter]","special")}else{a=e.stylize("[Getter]","special")}}else{if(f.set){a=e.stylize("[Setter]","special")}}if(!O(n,i)){s="["+i+"]"}if(!a){if(e.seen.indexOf(f.value)<0){if(_(r)){a=l(e,f.value,null)}else{a=l(e,f.value,r-1)}if(a.indexOf("\n")>-1){if(o){a=a.split("\n").map(function(e){return"  "+e}).join("\n").substr(2)}else{a="\n"+a.split("\n").map(function(e){return"   "+e}).join("\n")}}}else{a=e.stylize("[Circular]","special")}}if(x(s)){if(o&&i.match(/^\d+$/)){return a}s=JSON.stringify(""+i);if(s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){s=s.substr(1,s.length-2);s=e.stylize(s,"name")}else{s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");s=e.stylize(s,"string")}}return s+": "+a}function v(e,t,r){var n=0;var i=e.reduce(function(e,t){n++;if(t.indexOf("\n")>=0)n++;return e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(i>60){return r[0]+(t===""?"":t+"\n ")+" "+e.join(",\n  ")+" "+r[1]}return r[0]+t+" "+e.join(", ")+" "+r[1]}function m(e){return Array.isArray(e)}r.isArray=m;function y(e){return typeof e==="boolean"}r.isBoolean=y;function _(e){return e===null}r.isNull=_;function w(e){return e==null}r.isNullOrUndefined=w;function b(e){return typeof e==="number"}r.isNumber=b;function k(e){return typeof e==="string"}r.isString=k;function E(e){return typeof e==="symbol"}r.isSymbol=E;function x(e){return e===void 0}r.isUndefined=x;function S(e){return A(e)&&B(e)==="[object RegExp]"}r.isRegExp=S;function A(e){return typeof e==="object"&&e!==null}r.isObject=A;function I(e){return A(e)&&B(e)==="[object Date]"}r.isDate=I;function C(e){return A(e)&&(B(e)==="[object Error]"||e instanceof Error)}r.isError=C;function L(e){return typeof e==="function"}r.isFunction=L;function T(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=T;r.isBuffer=e("./support/isBuffer");function B(e){return Object.prototype.toString.call(e)}function R(e){return e<10?"0"+e.toString(10):e.toString(10)}var j=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date;var t=[R(e.getHours()),R(e.getMinutes()),R(e.getSeconds())].join(":");return[e.getDate(),j[e.getMonth()],t].join(" ")}r.log=function(){console.log("%s - %s",P(),r.format.apply(r,arguments))};r.inherits=e("inherits");r._extend=function(e,t){if(!t||!A(t))return e;var r=Object.keys(t);var n=r.length;while(n--){e[r[n]]=t[r[n]]}return e};function O(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":60,_process:41,inherits:94}],62:[function(e,t,r){(function(r){t.exports=g;t.exports.announceList=[["udp://tracker.publicbt.com:80"],["udp://tracker.openbittorrent.com:80"],["udp://open.demonii.com:1337"],["udp://tracker.webtorrent.io:80"],["wss://tracker.webtorrent.io"]];t.exports.parseInput=v;var n=e("bencode");var i=e("block-stream");var o=e("piece-length");var s=e("path");var a=e("filestream/read");var f=e("flatten");var u=e("fs");var c=e("multistream");var l=e("once");var h=e("run-parallel");var d=e("simple-sha1");var p=e("stream");function g(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};v(e,t,function(e,n){if(e)return r(e);k(n,t,r)})}function v(e,t,n){if(typeof t==="function"){n=t;t={}}if(!t)t={};if(Array.isArray(e)&&e.length===0)throw new Error("invalid input type");if(S(e))e=Array.prototype.slice.call(e);if(!Array.isArray(e))e=[e];if(!t.name)t.name=e[0]&&e[0].name;if(!t.name)t.name=typeof e[0]==="string"&&s.basename(e[0]);if(t.name===undefined){throw new Error("missing option 'name' and unable to infer it from input[0].name")}if(e.length===1&&!e[0].name)e[0].name=t.name;var i=e.reduce(function(e,t){return e+Number(typeof t==="string")},0);h(e.map(function(e){return function(n){var o={};if(x(e)){o.getStream=I(e);o.length=e.size}else if(r.isBuffer(e)){o.getStream=C(e);o.length=e.length}else if(A(e)){if(!t.pieceLength){throw new Error("must specify `pieceLength` option if input is Stream")}o.getStream=T(e,o);o.length=0}else if(typeof e==="string"){var a=i>1;m(e,a,n);return}else{throw new Error("invalid input type in array")}if(!e.name)throw new Error("missing requied `name` property on input");o.path=e.name.split(s.sep);n(null,o)}}),function(e,t){if(e)return n(e);t=f(t);n(null,t)})}function m(e,t,r){_(y,e,function(n,i){if(n)return r(n);if(Array.isArray(i))i=f(i);else i=[i];var o=s.normalize(e);if(t||i.length===1){o=o.slice(0,o.lastIndexOf(s.sep)+1)}else{if(o[o.length-1]!==s.sep)o+=s.sep}i.forEach(function(e){e.getStream=L(e.path);e.path=e.path.replace(o,"").split(s.sep)});r(null,i)})}function y(e,t){t=l(t);u.stat(e,function(r,n){if(r)return t(r);var i={length:n.size,path:e};t(null,i)})}function _(e,t,r){u.readdir(t,function(n,i){if(n&&n.code==="ENOTDIR"){e(t,r)}else if(n){r(n)}else{h(i.filter(w).map(function(r){return function(n){_(e,s.join(t,r),n)}}),r)}})}function w(e){return e[0]!=="."}function b(e,t,n){n=l(n);var o=[];var s=0;var a=e.map(function(e){return e.getStream});var f=0;var u=0;var h=false;new c(a).pipe(new i(t,{nopad:true})).on("data",function(e){s+=e.length;var t=u;d(e,function(e){o[t]=e;f-=1;p()});f+=1;u+=1}).on("end",function(){h=true;p()}).on("error",n);function p(){if(h&&f===0){n(null,new r(o.join(""),"hex"),s)}}}function k(e,r,i){var s=r.announceList!==undefined?r.announceList:r.announce!==undefined?r.announce.map(function(e){return[e]}):t.exports.announceList;var a={info:{name:r.name},announce:s[0][0],"announce-list":s,"creation date":Number(r.creationDate)||Date.now(),encoding:"UTF-8"};if(r.comment!==undefined)a.info.comment=r.comment;if(r.createdBy!==undefined)a.info["created by"]=r.createdBy;if(r.private!==undefined)a.info.private=Number(r.private);if(r.sslCert!==undefined)a.info["ssl-cert"]=r.sslCert;if(r.urlList!==undefined)a["url-list"]=r.urlList;var f=e.length===1;var u=r.pieceLength||o(e.reduce(E,0));a.info["piece length"]=u;b(e,u,function(t,r,o){if(t)return i(t);a.info.pieces=r;e.forEach(function(e){delete e.getStream});if(!f){a.info.files=e}else{a.info.length=o}i(null,n.encode(a))})}function E(e,t){return e+t.length}function x(e){return typeof Blob!=="undefined"&&e instanceof Blob}function S(e){return typeof FileList==="function"&&e instanceof FileList}function A(e){return typeof e==="object"&&typeof e.pipe==="function"}function I(e){return function(){return new a(e)}}function C(e){return function(){var t=new p.PassThrough;t.end(e);return t}}function L(e){return function(){return u.createReadStream(e)}}function T(e,t){return function(){var r=new p.Transform;r._transform=function(e,r,n){t.length+=e.length;this.push(e);n()};e.pipe(r);return r}}}).call(this,e("buffer").Buffer)},{bencode:63,"block-stream":67,buffer:34,"filestream/read":72,flatten:73,fs:31,multistream:74,once:77,path:40,"piece-length":78,"run-parallel":80,"simple-sha1":84,stream:57}],63:[function(e,t,r){arguments[4][11][0].apply(r,arguments)},{"./lib/decode":64,"./lib/encode":66,dup:11}],64:[function(e,t,r){arguments[4][12][0].apply(r,arguments)},{"./dict":65,buffer:34,dup:12}],65:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{dup:13}],66:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{buffer:34,dup:14}],67:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{_process:41,assert:32,buffer:34,dup:30,inherits:68,stream:57}],68:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],69:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],70:[function(e,t,r){(function(r){var n=e("is-typedarray").strict;t.exports=function(e){var t=r.TYPED_ARRAY_SUPPORT?r._augment:function(e){return new r(e)};if(e instanceof Uint8Array){return t(e)}else if(e instanceof ArrayBuffer){return t(new Uint8Array(e))}else if(n(e)){return t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}else{return new r(e)}}}).call(this,e("buffer").Buffer)},{buffer:34,"is-typedarray":71}],71:[function(e,t,r){t.exports=o;o.strict=s;o.loose=a;var n=Object.prototype.toString;var i={"[object Int8Array]":true,"[object Int16Array]":true,"[object Int32Array]":true,"[object Uint8Array]":true,"[object Uint16Array]":true,"[object Uint32Array]":true,"[object Float32Array]":true,"[object Float64Array]":true};function o(e){return s(e)||a(e)}function s(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function a(e){return i[n.call(e)]}},{}],72:[function(e,t,r){var n=e("stream").Readable;var i=e("inherits");var o=/^.*\.(\w+)$/;var s=e("typedarray-to-buffer");function a(e,t){var r=this;if(!(this instanceof a)){return new a(e,t)}t=t||{};n.call(this,t);this._offset=0;this._eof=false;this.reader=new FileReader;this.reader.onprogress=this._handleProgress.bind(this);this.reader.onload=this._handleLoad.bind(this);this._generateHeaderBlocks(e,t,function(t,n){if(t){return r.emit("error",t)}r._headerBlocks=n||[];r.reader.readAsArrayBuffer(e)})}i(a,n);t.exports=a;a.prototype._generateHeaderBlocks=function(e,t,r){r(null,[])};a.prototype._read=function(e){var t=this;var r=this.reader;function n(){var i=t._offset;var o=t._offset+e;var a=r.result&&r.result.byteLength;var f=r.readyState===2&&o>a;var u;if(a&&(f||a>o)){u=s(new Uint8Array(r.result,i,Math.min(e,r.result.byteLength-i)));t._offset=i+u.length;t._eof=u.length===0;return t.push(u.length>0?u:null)}t.once("readable",n)}if(this._headerBlocks.length>0){return this.push(this._headerBlocks.shift())}n()};a.prototype._handleLoad=function(e){this.emit("readable")};a.prototype._handleProgress=function(e){this.emit("readable")}},{inherits:69,stream:57,"typedarray-to-buffer":70}],73:[function(e,t,r){t.exports=function n(e,t){t=typeof t=="number"?t:Infinity;return r(e,1);function r(e,n){return e.reduce(function(e,i){if(Array.isArray(i)&&n<t){return e.concat(r(i,n+1))}else{return e.concat(i)}},[])}}},{}],74:[function(e,t,r){t.exports=o;var n=e("inherits");var i=e("stream");n(o,i.Readable);function o(e,t){if(!(this instanceof o))return new o(e,t);i.Readable.call(this,t);this.destroyed=false;this._drained=false;this._forwarding=false;this._current=null;this._queue=e.map(s);this._next()}o.obj=function(e){return new o(e,{objectMode:true,highWaterMark:16})};o.prototype._read=function(){this._drained=true;this._forward()};o.prototype._forward=function(){if(this._forwarding||!this._drained)return;this._forwarding=true;var e;while((e=this._current.read())!==null){this._drained=this.push(e)}this._forwarding=false};o.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;if(this._current&&this._current.destroy)this._current.destroy();this._queue.forEach(function(e){if(e.destroy)e.destroy()});if(e)this.emit("error",e);this.emit("close")};o.prototype._next=function(){var e=this;var t=this._queue.shift();if(typeof t==="function")t=s(t());if(!t){this.push(null);return}this._current=t;t.on("readable",r);t.on("end",i);t.on("error",o);t.on("close",n);function r(){e._forward()}function n(){if(!t._readableState.ended){e.destroy()}}function i(){e._current=null;t.removeListener("readable",r);t.removeListener("end",i);t.removeListener("error",o);t.removeListener("close",n);e._next()}function o(t){e.destroy(t)}};function s(e){if(!e||typeof e==="function"||e._readableState)return e;var t=(new i.Readable).wrap(e);if(e.destroy){t.destroy=e.destroy.bind(e)}return t}},{inherits:75,stream:57}],75:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],76:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],77:[function(e,t,r){var n=e("wrappy");t.exports=n(i);i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:true})});function i(e){var t=function(){if(t.called)return t.value;t.called=true;return t.value=e.apply(this,arguments)};t.called=false;return t}},{wrappy:76}],78:[function(e,t,r){var n=e("closest-to");var i=[];for(var o=14;o<=22;o++){i.push(Math.pow(2,o))}t.exports=function(e){return n(e/Math.pow(2,10),i)}},{"closest-to":79}],79:[function(e,t,r){t.exports=function(e,t){var r=Infinity;var n=0;var i=null;t.sort(function(e,t){return e-t});for(var o=0,s=t.length;o<s;o++){n=Math.abs(e-t[o]);if(n>=r){break}r=n;i=t[o]}return i}},{}],80:[function(e,t,r){var n=e("dezalgo");t.exports=function(e,t){if(t)t=n(t);var r,i,o;if(Array.isArray(e)){r=[];i=e.length}else{o=Object.keys(e);r={};i=o.length}function s(e,n,o){r[e]=o;if(--i===0||n){if(t)t(n,r);t=null}}if(!i){if(t)t(null,r);t=null}else if(o){o.forEach(function(t){e[t](s.bind(undefined,t))})}else{e.forEach(function(e,t){e(s.bind(undefined,t))})}}},{dezalgo:81}],81:[function(e,t,r){arguments[4][25][0].apply(r,arguments)},{asap:82,dup:25,wrappy:83}],82:[function(e,t,r){arguments[4][26][0].apply(r,arguments)},{_process:41,dup:26}],83:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],84:[function(e,t,r){var n=e("rusha");var i=new n;var o=window.crypto||window.msCrypto||{};var s=o.subtle||o.webkitSubtle;var a=i.digest.bind(i);try{s.digest({name:"sha-1"},new Uint8Array).catch(function(){s=false})}catch(f){s=false}function u(e,t){if(!s){setTimeout(t,0,a(e));return}if(typeof e==="string"){e=c(e)}s.digest({name:"sha-1"},e).then(function r(e){t(l(new Uint8Array(e)))},function n(r){t(a(e))})}function c(e){var t=e.length;var r=new Uint8Array(t);for(var n=0;n<t;n++){r[n]=e.charCodeAt(n)}return r}function l(e){var t=e.length;var r=[];for(var n=0;n<t;n++){var i=e[n];r.push((i>>>4).toString(16));r.push((i&15).toString(16))}return r.join("")}t.exports=u;t.exports.sync=a},{rusha:85}],85:[function(e,t,r){(function(e){(function(){if(typeof t!=="undefined"){t.exports=o}else if(typeof window!=="undefined"){window.Rusha=o}if(typeof FileReaderSync!=="undefined"){var r=new FileReaderSync,n=new o(4*1024*1024);self.onmessage=function a(e){var t,r=e.data.data;try{t=n.digest(r);self.postMessage({id:e.data.id,hash:t})}catch(i){self.postMessage({id:e.data.id,error:i.name})}}}var i={getDataType:function(t){if(typeof t==="string"){return"string"}if(t instanceof Array){return"array"}if(typeof e!=="undefined"&&e.Buffer&&e.Buffer.isBuffer(t)){return"buffer"}if(t instanceof ArrayBuffer){return"arraybuffer"}if(t.buffer instanceof ArrayBuffer){return"view"}if(t instanceof Blob){return"blob"}throw new Error("Unsupported data type.")}};function o(e){"use strict";var t={fill:0};var n=function(e){for(e+=9;e%64>0;e+=1);return e};var o=function(e,t){for(var r=t>>2;r<e.length;r++)e[r]=0};var a=function(e,t,r){e[t>>2]|=128<<24-(t%4<<3);e[((t>>2)+2&~15)+14]=r>>29;e[((t>>2)+2&~15)+15]=r<<3};var f=function(e,t,r,n,i){var o=this,s,a=i%4,f=n%4,u=n-f;if(u>0){switch(a){case 0:e[i+3|0]=o.charCodeAt(r);case 1:e[i+2|0]=o.charCodeAt(r+1);case 2:e[i+1|0]=o.charCodeAt(r+2);case 3:e[i|0]=o.charCodeAt(r+3)}}for(s=a;s<u;s=s+4|0){t[i+s>>2]=o.charCodeAt(r+s)<<24|o.charCodeAt(r+s+1)<<16|o.charCodeAt(r+s+2)<<8|o.charCodeAt(r+s+3)}switch(f){case 3:e[i+u+1|0]=o.charCodeAt(r+u+2);case 2:e[i+u+2|0]=o.charCodeAt(r+u+1);case 1:e[i+u+3|0]=o.charCodeAt(r+u)}};var u=function(e,t,r,n,i){var o=this,s,a=i%4,f=n%4,u=n-f;if(u>0){switch(a){case 0:e[i+3|0]=o[r];case 1:e[i+2|0]=o[r+1];case 2:e[i+1|0]=o[r+2];case 3:e[i|0]=o[r+3]}}for(s=4-a;s<u;s=s+=4|0){t[i+s>>2]=o[r+s]<<24|o[r+s+1]<<16|o[r+s+2]<<8|o[r+s+3]}switch(f){case 3:e[i+u+1|0]=o[r+u+2];case 2:e[i+u+2|0]=o[r+u+1];case 1:e[i+u+3|0]=o[r+u]}};var c=function(e,t,n,i,o){var s=this,a,f=o%4,u=i%4,c=i-u;var l=new Uint8Array(r.readAsArrayBuffer(s.slice(n,n+i)));if(c>0){switch(f){case 0:e[o+3|0]=l[0];case 1:e[o+2|0]=l[1];case 2:e[o+1|0]=l[2];case 3:e[o|0]=l[3]}}for(a=4-f;a<c;a=a+=4|0){t[o+a>>2]=l[a]<<24|l[a+1]<<16|l[a+2]<<8|l[a+3]}switch(u){case 3:e[o+c+1|0]=l[c+2];case 2:e[o+c+2|0]=l[c+1];case 1:e[o+c+3|0]=l[c]}};var l=function(e){switch(i.getDataType(e)){case"string":return f.bind(e);case"array":return u.bind(e);case"buffer":return u.bind(e);case"arraybuffer":return u.bind(new Uint8Array(e));case"view":return u.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return c.bind(e)}};var h=function(e,t){switch(i.getDataType(e)){case"string":return e.slice(t);case"array":return e.slice(t);case"buffer":return e.slice(t);case"arraybuffer":return e.slice(t);case"view":return e.buffer.slice(t)}};var d=function(e){var t,r,n="0123456789abcdef",i=[],o=new Uint8Array(e);for(t=0;t<o.length;t++){r=o[t];i[t]=n.charAt(r>>4&15)+n.charAt(r>>0&15)}return i.join("")};var p=function(e){var t;if(e<=65536)return 65536;if(e<16777216){for(t=1;t<e;t=t<<1);}else{for(t=16777216;t<e;t+=16777216);}return t};var g=function(e){if(e%64>0){throw new Error("Chunk size must be a multiple of 128 bit")}t.maxChunkLen=e;t.padMaxChunkLen=n(e);t.heap=new ArrayBuffer(p(t.padMaxChunkLen+320+20));t.h32=new Int32Array(t.heap);t.h8=new Int8Array(t.heap);t.core=s({Int32Array:Int32Array,DataView:DataView},{},t.heap);t.buffer=null};g(e||64*1024);var v=function(e,t){var r=new Int32Array(e,t+320,5);r[0]=1732584193;r[1]=-271733879;r[2]=-1732584194;r[3]=271733878;r[4]=-1009589776};var m=function(e,r){var i=n(e);var s=new Int32Array(t.heap,0,i>>2);o(s,e);a(s,e,r);return i};var y=function(e,r,n){l(e)(t.h8,t.h32,r,n,0)};var _=function(e,r,n,i,o){var s=n;if(o){s=m(n,i)}y(e,r,n);t.core.hash(s,t.padMaxChunkLen)};var w=function(e,t){var r=new Int32Array(e,t+320,5);var n=new Int32Array(5);var i=new DataView(n.buffer);i.setInt32(0,r[0],false);i.setInt32(4,r[1],false);i.setInt32(8,r[2],false);i.setInt32(12,r[3],false);i.setInt32(16,r[4],false);return n};var b=this.rawDigest=function(e){var r=e.byteLength||e.length||e.size||0;v(t.heap,t.padMaxChunkLen);var n=0,i=t.maxChunkLen,o;for(n=0;r>n+i;n+=i){_(e,n,i,r,false)}_(e,n,r-n,r,true);return w(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return d(b(e).buffer)}}function s(e,t,r){"use asm";var n=new e.Int32Array(r);function i(e,t){e=e|0;t=t|0;var r=0,i=0,o=0,s=0,a=0,f=0,u=0,c=0,l=0,h=0,d=0,p=0,g=0,v=0;o=n[t+320>>2]|0;a=n[t+324>>2]|0;u=n[t+328>>2]|0;l=n[t+332>>2]|0;d=n[t+336>>2]|0;for(r=0;(r|0)<(e|0);r=r+64|0){s=o;f=a;c=u;h=l;p=d;for(i=0;(i|0)<64;i=i+4|0){v=n[r+i>>2]|0;g=((o<<5|o>>>27)+(a&u|~a&l)|0)+((v+d|0)+1518500249|0)|0;d=l;l=u;u=a<<30|a>>>2;a=o;o=g;n[e+i>>2]=v}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){v=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(a&u|~a&l)|0)+((v+d|0)+1518500249|0)|0;d=l;l=u;u=a<<30|a>>>2;a=o;o=g;n[i>>2]=v}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){v=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(a^u^l)|0)+((v+d|0)+1859775393|0)|0;d=l;l=u;u=a<<30|a>>>2;a=o;o=g;n[i>>2]=v}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){v=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(a&u|a&l|u&l)|0)+((v+d|0)-1894007588|0)|0;d=l;l=u;u=a<<30|a>>>2;a=o;o=g;n[i>>2]=v}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){v=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;g=((o<<5|o>>>27)+(a^u^l)|0)+((v+d|0)-899497514|0)|0;d=l;l=u;u=a<<30|a>>>2;a=o;o=g;n[i>>2]=v}o=o+s|0;a=a+f|0;u=u+c|0;l=l+h|0;d=d+p|0}n[t+320>>2]=o;n[t+324>>2]=a;n[t+328>>2]=u;n[t+332>>2]=l;n[t+336>>2]=d}return{hash:i}}})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],86:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./debug":87,dup:16}],87:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{dup:17,ms:88}],88:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],89:[function(e,t,r){arguments[4][25][0].apply(r,arguments)},{asap:90,dup:25,wrappy:91}],90:[function(e,t,r){arguments[4][26][0].apply(r,arguments)},{_process:41,dup:26}],91:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],92:[function(e,t,r){var n=e("once");var i=function(){};var o=function(e){return e.setHeader&&typeof e.abort==="function"};var s=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3};var a=function(e,t,r){if(typeof t==="function")return a(e,null,t);if(!t)t={};r=n(r||i);var f=e._writableState;var u=e._readableState;var c=t.readable||t.readable!==false&&e.readable;var l=t.writable||t.writable!==false&&e.writable;var h=function(){if(!e.writable)d()};var d=function(){l=false;if(!c)r()};var p=function(){c=false;if(!l)r()};var g=function(e){r(e?new Error("exited with error code: "+e):null)};var v=function(){if(c&&!(u&&u.ended))return r(new Error("premature close"));if(l&&!(f&&f.ended))return r(new Error("premature close"))};var m=function(){e.req.on("finish",d)};if(o(e)){e.on("complete",d);e.on("abort",v);if(e.req)m();else e.on("request",m)}else if(l&&!f){e.on("end",h);e.on("close",h)}if(s(e))e.on("exit",g);e.on("end",p);e.on("finish",d);if(t.error!==false)e.on("error",r);e.on("close",v);return function(){e.removeListener("complete",d);e.removeListener("abort",v);e.removeListener("request",m);if(e.req)e.req.removeListener("finish",d);e.removeListener("end",h);e.removeListener("close",h);e.removeListener("finish",d);e.removeListener("exit",g);e.removeListener("end",p);e.removeListener("error",r);e.removeListener("close",v)}};t.exports=a},{once:98}],93:[function(e,t,r){var n=t.exports=function(e,t){if(!t)t=16;if(e===undefined)e=128;if(e<=0)return"0";var r=Math.log(Math.pow(2,e))/Math.log(t);for(var i=2;r===Infinity;i*=2){r=Math.log(Math.pow(2,e/i))/Math.log(t)*i}var o=r-Math.floor(r);var s="";for(var i=0;i<Math.floor(r);i++){var a=Math.floor(Math.random()*t).toString(t);s=a+s}if(o){var f=Math.pow(t,o);var a=Math.floor(Math.random()*f).toString(t);s=a+s}var u=parseInt(s,t);if(u!==Infinity&&u>=Math.pow(2,e)){return n(e,t)}else return s};n.rack=function(e,t,r){var i=function(i){var s=0;do{if(s++>10){if(r)e+=r;else throw new Error("too many ID collisions, use more bits")}var a=n(e,t)}while(Object.hasOwnProperty.call(o,a));o[a]=i;return a};var o=i.hats={};i.get=function(e){return i.hats[e]};i.set=function(e,t){i.hats[e]=t;return i};i.bits=e||128;i.base=t||16;return i}},{}],94:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],95:[function(e,t,r){arguments[4][74][0].apply(r,arguments)},{dup:74,inherits:96,stream:57}],96:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],97:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],98:[function(e,t,r){arguments[4][77][0].apply(r,arguments)},{dup:77,wrappy:97}],99:[function(e,t,r){(function(r){var n=e("magnet-uri");var i=e("parse-torrent-file");t.exports=function o(e){var t=e&&e.length;if(typeof e==="string"&&/magnet:/.test(e)){return n(e)}else if(typeof e==="string"&&(t===40||t===32)){return n("magnet:?xt=urn:btih:"+e)}else if(r.isBuffer(e)&&t===20){return n("magnet:?xt=urn:btih:"+e.toString("hex"))}else if(r.isBuffer(e)){return i(e)}else if(e&&e.infoHash){return e}else{throw new Error("Invalid torrent identifier")}};t.exports.toMagnetURI=n.encode;t.exports.toTorrentFile=i.encode}).call(this,e("buffer").Buffer)},{buffer:34,"magnet-uri":100,"parse-torrent-file":105}],100:[function(e,t,r){(function(r){t.exports=s;t.exports.decode=s;t.exports.encode=a;var n=e("thirty-two");var i=e("xtend");var o=e("flatten");function s(e){var t={};var i=e.split("magnet:?")[1];var o=i&&i.length>=0?i.split("&"):[];o.forEach(function(e){var r=e.split("=");if(r.length!==2)return;var n=r[0];var i=r[1];if(n==="dn")i=decodeURIComponent(i).replace(/\+/g," ");if(n==="tr"||n==="xs"||n==="as"||n==="ws"){i=decodeURIComponent(i)}if(n==="kt")i=decodeURIComponent(i).split("+");if(t[n]){if(Array.isArray(t[n])){t[n].push(i)}else{var o=t[n];t[n]=[o,i]}}else{t[n]=i}});var s;if(t.xt){var a=Array.isArray(t.xt)?t.xt:[t.xt];a.forEach(function(e){if(s=e.match(/^urn:btih:(.{40})/)){t.infoHash=new r(s[1],"hex").toString("hex")}else if(s=e.match(/^urn:btih:(.{32})/)){var i=n.decode(s[1]);t.infoHash=new r(i,"binary").toString("hex")}})}if(t.dn)t.name=t.dn;if(t.kt)t.keywords=t.kt;if(typeof t.tr==="string")t.announce=[t.tr];else if(Array.isArray(t.tr))t.announce=t.tr;else t.announce=[];t.announceList=t.announce.map(function(e){return[e]});t.urlList=[];if(typeof t.as==="string"||Array.isArray(t.as)){t.urlList=t.urlList.concat(t.as)}if(typeof t.ws==="string"||Array.isArray(t.ws)){t.urlList=t.urlList.concat(t.ws)}return t}function a(e){e=i(e);if(e.infoHash)e.xt="urn:btih:"+e.infoHash;if(e.name)e.dn=e.name;if(e.keywords)e.kt=e.keywords;if(e.announce)e.tr=e.announce;if(e.announceList)e.tr=o(e.announceList);if(e.urlList){e.ws=o(e.urlList);delete e.as}var t="magnet:?";Object.keys(e).filter(function(e){return e.length===2}).forEach(function(r,n){var i=Array.isArray(e[r])?e[r]:[e[r]];i.forEach(function(e,i){if((n>0||i>0)&&(r!=="kt"||i===0))t+="&";if(r==="dn")e=encodeURIComponent(e).replace(/%20/g,"+");if(r==="tr"||r==="xs"||r==="as"||r==="ws"){e=encodeURIComponent(e)}if(r==="kt")e=encodeURIComponent(e);if(r==="kt"&&i>0)t+="+"+e;else t+=r+"="+e})});return t}}).call(this,e("buffer").Buffer)},{buffer:34,flatten:101,"thirty-two":102,xtend:104}],101:[function(e,t,r){arguments[4][73][0].apply(r,arguments)},{dup:73}],102:[function(e,t,r){var n=e("./thirty-two");r.encode=n.encode;r.decode=n.decode},{"./thirty-two":103}],103:[function(e,t,r){(function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";var n=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];function i(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}r.encode=function(r){var n=0;var o=0;var s=0;var a=0;var f=new e(i(r)*8);if(!e.isBuffer(r)){r=new e(r)}while(n<r.length){var u=r[n];if(s>3){a=u&255>>s;s=(s+5)%8;a=a<<s|(n+1<r.length?r[n+1]:0)>>8-s;n++}else{a=u>>8-(s+5)&31;s=(s+5)%8;if(s==0)n++}f[o]=t.charCodeAt(a);o++}for(n=o;n<f.length;n++)f[n]=61;return f};r.decode=function(t){var r=0;var i=0;var o;var s=0;if(!e.isBuffer(t)){t=new e(t)}var a=new e(Math.ceil(t.length*5/8));for(var f=0;f<t.length;f++){if(t[f]==61){break}var u=t[f]-48;if(u<n.length){i=n[u];if(r<=3){r=(r+5)%8;if(r==0){o|=i;a[s]=o;s++;o=0}else{o|=255&i<<8-r}}else{r=(r+5)%8;o|=255&i>>>r;a[s]=o;s++;o=255&i<<8-r}}else{throw new Error("Invalid input - it is not base32 encoded string")}}return a.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:34}],104:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],105:[function(e,t,r){(function(r){t.exports=s;t.exports.decode=s;t.exports.encode=a;var n=e("bencode");var i=e("path");var o=e("simple-sha1");function s(e){if(r.isBuffer(e)){e=n.decode(e)}c(e.info,"info");c(e.info.name,"info.name");c(e.info["piece length"],"info['piece length']");c(e.info.pieces,"info.pieces");if(e.info.files){e.info.files.forEach(function(e){c(typeof e.length==="number","info.files[0].length");c(e.path,"info.files[0].path")})}else{c(typeof e.info.length==="number","info.length")}var t={};t.info=e.info;t.infoBuffer=n.encode(e.info);t.infoHash=o.sync(t.infoBuffer);t.name=e.info.name.toString();t.private=!!e.info.private;if(e["creation date"])t.created=new Date(e["creation date"]*1e3);if(r.isBuffer(e.comment))t.comment=e.comment.toString();var s=e["announce-list"];if(!s){if(e.announce){s=[[e.announce]]}else{s=[]}}t.announceList=s.map(function(e){return e.map(function(e){return e.toString()})});t.announce=[].concat.apply([],t.announceList);if(r.isBuffer(e["url-list"])){e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]}t.urlList=(e["url-list"]||[]).map(function(e){return e.toString()});var a=e.info.files||[e.info];t.files=a.map(function(e,r){var n=[].concat(e.name||t.name,e.path||[]).map(function(e){return e.toString()});return{path:i.join.apply(null,[i.sep].concat(n)).slice(1),name:n[n.length-1],length:e.length,offset:a.slice(0,r).reduce(f,0)}});t.length=a.reduce(f,0);var l=t.files[t.files.length-1];t.pieceLength=e.info["piece length"];t.lastPieceLength=(l.offset+l.length)%t.pieceLength||t.pieceLength;t.pieces=u(e.info.pieces);return t}function a(e){var t={info:e.info};if(e.announce&&e.announce[0]){t.announce=e.announce[0]}if(e.announceList){t["announce-list"]=e.announceList.map(function(e){return e.map(function(e){e=new r(e,"utf8");if(!t.announce){t.announce=e}return e})})}if(e.created){t["creation date"]=e.created.getTime()/1e3|0}return n.encode(t)}function f(e,t){return e+t.length}function u(e){var t=[];for(var r=0;r<e.length;r+=20){t.push(e.slice(r,r+20).toString("hex"))}return t}function c(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}}).call(this,e("buffer").Buffer)},{bencode:106,buffer:34,path:40,"simple-sha1":110}],106:[function(e,t,r){arguments[4][11][0].apply(r,arguments)},{"./lib/decode":107,"./lib/encode":109,dup:11}],107:[function(e,t,r){arguments[4][12][0].apply(r,arguments)},{"./dict":108,buffer:34,dup:12}],108:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{dup:13}],109:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{buffer:34,dup:14}],110:[function(e,t,r){arguments[4][84][0].apply(r,arguments)},{dup:84,rusha:111}],111:[function(e,t,r){arguments[4][85][0].apply(r,arguments)},{dup:85}],112:[function(e,t,r){t.exports=i;t.exports.filter=o;var n=e("events").EventEmitter;function i(e,t,r){if(!Array.isArray(r))r=[r];var n=[];r.forEach(function(r){var i=function(){var e=[].slice.call(arguments);e.unshift(r);t.emit.apply(t,e)};n.push(i);e.on(r,i)});return function i(){r.forEach(function(t,r){e.removeListener(t,n[r])})}}function o(e,t){var r=new n;i(e,r,t);return r}},{events:38}],113:[function(e,t,r){arguments[4][80][0].apply(r,arguments)},{dezalgo:114,dup:80}],114:[function(e,t,r){arguments[4][25][0].apply(r,arguments)},{asap:115,dup:25,wrappy:116}],115:[function(e,t,r){arguments[4][26][0].apply(r,arguments)},{_process:41,dup:26}],116:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],117:[function(e,t,r){arguments[4][84][0].apply(r,arguments)},{dup:84,rusha:118}],118:[function(e,t,r){arguments[4][85][0].apply(r,arguments)},{dup:85}],119:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20}],120:[function(e,t,r){(function(r){t.exports=c;var n=e("debug")("torrent-discovery");var i=e("bittorrent-dht/client");var o=e("events").EventEmitter;var s=e("xtend/mutable");var a=e("inherits");var f=e("re-emitter");var u=e("bittorrent-tracker/client");a(c,o);function c(e){var t=this;if(!(t instanceof c))return new c(e);o.call(t);s(t,{announce:[],dht:typeof i==="function",rtcConfig:null,peerId:null,
  port:0,tracker:true,wrtc:null},e);t._externalDHT=typeof t.dht==="object";t._performedDHTLookup=false;if(!t.peerId)throw new Error("peerId required");if(!r.browser&&!t.port)throw new Error("port required");if(t.dht)t._createDHT(t.dhtPort)}c.prototype.setTorrent=function(e){var t=this;if(t.torrent)return;if(e&&e.infoHash){t.torrent=e;t.infoHash=e.infoHash}else{if(t.infoHash)return;t.infoHash=e}n("setTorrent %s",t.infoHash);if(t.tracker&&t.tracker!==true){t.tracker.torrentLength=e.length}else{t._createTracker()}if(t.dht){if(t.dht.ready)t._dhtLookupAndAnnounce();else t.dht.on("ready",t._dhtLookupAndAnnounce.bind(t))}};c.prototype.stop=function(e){var t=this;if(t.tracker&&t.tracker.stop)t.tracker.stop();if(!t._externalDHT&&t.dht&&t.dht.destroy)t.dht.destroy(e);else r.nextTick(function(){e(null)})};c.prototype._createDHT=function(e){var t=this;if(!t._externalDHT)t.dht=new i;f(t.dht,t,["error","warning"]);t.dht.on("peer",function(e,r){if(r===t.infoHash)t.emit("peer",e)});if(!t._externalDHT)t.dht.listen(e)};c.prototype._createTracker=function(){var e=this;if(!e.tracker)return;var t=e.torrent||{infoHash:e.infoHash,announce:e.announce};var r={rtcConfig:e.rtcConfig,wrtc:e.wrtc};e.tracker=new u(e.peerId,e.port,t,r);f(e.tracker,e,["peer","warning","error"]);e.tracker.start()};c.prototype._dhtLookupAndAnnounce=function(){var e=this;if(e._performedDHTLookup)return;e._performedDHTLookup=true;n("dht lookup");e.dht.lookup(e.infoHash,function(t){if(t||!e.port)return;n("dht announce");e.dht.announce(e.infoHash,e.port,function(){n("dht announce complete");e.emit("dhtAnnounce")})})}}).call(this,e("_process"))},{_process:41,"bittorrent-dht/client":33,"bittorrent-tracker/client":121,debug:153,events:38,inherits:156,"re-emitter":157,"xtend/mutable":158}],121:[function(e,t,r){(function(r){t.exports=h;var n=e("debug")("bittorrent-tracker");var i=e("events").EventEmitter;var o=e("inherits");var s=e("once");var a=e("url");var f=e("./lib/common");var u=e("./lib/http-tracker");var c=e("./lib/udp-tracker");var l=e("./lib/websocket-tracker");o(h,i);function h(e,t,o,s){var d=this;if(!(d instanceof h))return new h(e,t,o,s);i.call(d);if(!s)s={};d._peerId=r.isBuffer(e)?e:new r(e,"hex");d._port=t;d._infoHash=r.isBuffer(o.infoHash)?o.infoHash:new r(o.infoHash,"hex");d.torrentLength=o.length;d._rtcConfig=s.rtcConfig;d._wrtc=s.wrtc;d._numWant=s.numWant||f.DEFAULT_ANNOUNCE_PEERS;d._intervalMs=s.interval||f.DEFAULT_ANNOUNCE_INTERVAL;n("new client %s",d._infoHash.toString("hex"));if(typeof o.announce==="string")o.announce=[o.announce];if(o.announce==null)o.announce=[];var p={interval:d._intervalMs};var g=!!d._wrtc||typeof window!=="undefined";d._trackers=o.announce.map(function(e){var t=a.parse(e).protocol;if((t==="http:"||t==="https:")&&typeof u==="function"){return new u(d,e,p)}else if(t==="udp:"&&typeof c==="function"){return new c(d,e,p)}else if((t==="ws:"||t==="wss:")&&g){return new l(d,e,p)}return null}).filter(Boolean)}h.scrape=function(e,t,n){n=s(n);var i=new r("01234567890123456789");var o=6881;var a={infoHash:Array.isArray(t)?t[0]:t,announce:[e]};var f=new h(i,o,a);f.once("error",n);var u=Array.isArray(t)?t.length:1;var c={};f.on("scrape",function(e){u-=1;c[e.infoHash]=e;if(u===0){f.destroy();var t=Object.keys(c);if(t.length===1){n(null,c[t[0]])}else{n(null,c)}}});t=Array.isArray(t)?t.map(function(e){return new r(e,"hex")}):new r(t,"hex");f.scrape({infoHash:t})};h.prototype.start=function(e){var t=this;n("send `start`");e=t._defaultAnnounceOpts(e);e.event="started";t._announce(e);t._trackers.forEach(function(e){e.setInterval(t._intervalMs)})};h.prototype.stop=function(e){var t=this;n("send `stop`");e=t._defaultAnnounceOpts(e);e.event="stopped";t._announce(e);t.destroy()};h.prototype.complete=function(e){var t=this;n("send `complete`");if(!e)e={};if(e.downloaded==null&&t.torrentLength!=null){e.downloaded=t.torrentLength}e=t._defaultAnnounceOpts(e);e.event="completed";t._announce(e)};h.prototype.update=function(e){var t=this;n("send `update`");e=t._defaultAnnounceOpts(e);if(e.event)delete e.event;t._announce(e)};h.prototype._announce=function(e){var t=this;t._trackers.forEach(function(t){t.announce(e)})};h.prototype.scrape=function(e){var t=this;n("send `scrape`");if(!e)e={};t._trackers.forEach(function(t){t.scrape(e)})};h.prototype.setInterval=function(e){var t=this;n("setInterval");t._intervalMs=e;t._trackers.forEach(function(t){t.setInterval(e)})};h.prototype.destroy=function(){var e=this;n("destroy");e._trackers.forEach(function(e){if(e.destroy)e.destroy();e.setInterval(0)})};h.prototype._defaultAnnounceOpts=function(e){var t=this;if(!e)e={};if(e.numWant==null)e.numWant=t._numWant;if(e.uploaded==null)e.uploaded=0;if(e.downloaded==null)e.downloaded=0;if(e.left==null&&t.torrentLength!=null){e.left=t.torrentLength-e.downloaded}return e}}).call(this,e("buffer").Buffer)},{"./lib/common":123,"./lib/http-tracker":33,"./lib/udp-tracker":33,"./lib/websocket-tracker":124,buffer:34,debug:125,events:38,inherits:129,once:131,url:59}],122:[function(e,t,r){(function(t){var n=e("querystring");r.IPV4_RE=/^[\d\.]+$/;r.IPV6_RE=/^[\da-fA-F:]+$/;r.CONNECTION_ID=t.concat([i(1047),i(655366528)]);r.ACTIONS={CONNECT:0,ANNOUNCE:1,SCRAPE:2,ERROR:3};r.EVENTS={update:0,completed:1,started:2,stopped:3};r.EVENT_IDS={0:"update",1:"completed",2:"started",3:"stopped"};r.EVENT_NAMES={update:"update",completed:"complete",started:"start",stopped:"stop"};function i(e){var r=new t(4);r.writeUInt32BE(e,0);return r}r.toUInt32=i;r.querystringParse=function(e){var t=n.unescape;n.unescape=unescape;var r=n.parse(e);n.unescape=t;return r};r.querystringStringify=function(e){var t=n.escape;n.escape=escape;var r=n.stringify(e);r=r.replace(/[\@\*\/\+]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});n.escape=t;return r}}).call(this,e("buffer").Buffer)},{buffer:34,querystring:45}],123:[function(e,t,r){(function(t){var n=e("xtend/mutable");r.DEFAULT_ANNOUNCE_INTERVAL=30*60*1e3;r.DEFAULT_ANNOUNCE_PEERS=50;r.MAX_ANNOUNCE_PEERS=82;r.binaryToHex=function(e){return new t(e,"binary").toString("hex")};r.hexToBinary=function(e){return new t(e,"hex").toString("binary")};var i=e("./common-node");n(r,i)}).call(this,e("buffer").Buffer)},{"./common-node":122,buffer:34,"xtend/mutable":152}],124:[function(e,t,r){t.exports=l;var n=e("debug")("bittorrent-tracker:websocket-tracker");var i=e("events").EventEmitter;var o=e("hat");var s=e("inherits");var a=e("simple-peer");var f=e("simple-websocket");var u=e("./common");var c={};s(l,i);function l(e,t,r){var o=this;i.call(o);n("new websocket tracker %s",t);o.client=e;o._opts=r;o._announceUrl=t;o._peers={};o._socket=null;o._intervalMs=o.client._intervalMs;o._interval=null;if(c[t])o._socket=c[t];else o._socket=c[t]=new f(t);o._socket.on("error",o._onSocketError.bind(o));o._socket.on("data",o._onSocketData.bind(o))}l.prototype.announce=function(e){var t=this;if(!t._socket.connected){return t._socket.on("connect",t.announce.bind(t,e))}e.info_hash=t.client._infoHash.toString("binary");e.peer_id=t.client._peerId.toString("binary");if(e.numWant>5)e.numWant=5;t._generateOffers(e.numWant,function(r){e.offers=r;if(t._trackerId){e.trackerid=t._trackerId}t._send(e)})};l.prototype.scrape=function(e){var t=this;t._onSocketError(new Error("scrape not supported "+t._announceUrl))};l.prototype.setInterval=function(e){var t=this;clearInterval(t._interval);t._intervalMs=e;if(e){var r=t.announce.bind(t,t.client._defaultAnnounceOpts());t._interval=setInterval(r,t._intervalMs)}};l.prototype._onSocketError=function(e){var t=this;t.client.emit("error",e)};l.prototype._onSocketData=function(e){var t=this;if(!(typeof e==="object"&&e!==null)){return t.client.emit("warning",new Error("Invalid tracker response"))}if(e.info_hash!==t.client._infoHash.toString("binary")){return t.client.emit("warning",new Error("Invalid tracker response"))}n("received %s from %s",JSON.stringify(e),t._announceUrl);var r=e["failure reason"];if(r)return t.client.emit("warning",new Error(r));var i=e["warning message"];if(i)t.client.emit("warning",new Error(i));var o=e.interval||e["min interval"];if(o&&!t._opts.interval&&t._intervalMs!==0){t.setInterval(o*1e3)}var s=e["tracker id"];if(s){t._trackerId=s}if(e.complete){t.client.emit("update",{announce:t._announceUrl,complete:e.complete,incomplete:e.incomplete})}var f;if(e.offer){f=new a({trickle:false,config:t.client._rtcConfig,wrtc:t.client._wrtc});f.id=u.binaryToHex(e.peer_id);f.once("signal",function(r){var n={info_hash:t.client._infoHash.toString("binary"),peer_id:t.client._peerId.toString("binary"),to_peer_id:e.peer_id,answer:r,offer_id:e.offer_id};if(t._trackerId)n.trackerid=t._trackerId;t._send(n)});f.signal(e.offer);t.client.emit("peer",f)}if(e.answer){f=t._peers[u.binaryToHex(e.offer_id)];if(f){f.id=u.binaryToHex(e.peer_id);f.signal(e.answer);t.client.emit("peer",f)}else{n("got unexpected answer: "+JSON.stringify(e.answer))}}};l.prototype._send=function(e){var t=this;n("send %s",JSON.stringify(e));t._socket.send(e)};l.prototype._generateOffers=function(e,t){var r=this;var i=[];n("generating %s offers",e);for(var s=0;s<e;++s){f()}function f(){var e=o(160);var t=r._peers[e]=new a({initiator:true,trickle:false,config:r.client._rtcConfig,wrtc:r.client._wrtc});t.once("signal",function(t){i.push({offer:t,offer_id:u.hexToBinary(e)});c()})}function c(){if(i.length===e){n("generated %s offers",e);t(i)}}}},{"./common":123,debug:125,events:38,hat:128,inherits:129,"simple-peer":132,"simple-websocket":144}],125:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./debug":126,dup:16}],126:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{dup:17,ms:127}],127:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],128:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],129:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],130:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],131:[function(e,t,r){arguments[4][77][0].apply(r,arguments)},{dup:77,wrappy:130}],132:[function(e,t,r){(function(r){t.exports=l;var n=e("debug")("simple-peer");var i=e("xtend/mutable");var o=e("hat");var s=e("inherits");var a=e("is-typedarray");var f=e("once");var u=e("stream");var c=e("typedarray-to-buffer");s(l,u.Duplex);function l(e){var t=this;if(!(t instanceof l))return new l(e);if(!e)e={};i(t,{initiator:false,stream:false,config:l.config,constraints:l.constraints,channelName:e&&e.initiator?o(160):null,trickle:true,allowHalfOpen:false,highWaterMark:1024*1024},e);u.Duplex.call(t,e);var r=e.wrtc||h();if(!r&&typeof window==="undefined"){throw new Error("Missing WebRTC support - You must supply "+"`opts.wrtc` in this environment")}else if(!r){throw new Error("Missing WebRTC support - is this a supported browser?")}t._wrtc=r;t._debug("new peer (initiator: %s)",t.initiator);t.destroyed=false;t.connected=false;t.remoteAddress=undefined;t.remoteFamily=undefined;t.remotePort=undefined;t.localAddress=undefined;t.localPort=undefined;t._pcReady=false;t._channelReady=false;t._iceComplete=false;t._channel=null;t._buffer=[];t._pc=new t._wrtc.RTCPeerConnection(t.config,t.constraints);t._pc.oniceconnectionstatechange=t._onIceConnectionStateChange.bind(t);t._pc.onsignalingstatechange=t._onSignalingStateChange.bind(t);t._pc.onicecandidate=t._onIceCandidate.bind(t);if(t.stream)t._pc.addStream(t.stream);t._pc.onaddstream=t._onAddStream.bind(t);if(t.initiator){t._setupData({channel:t._pc.createDataChannel(t.channelName)});t._pc.onnegotiationneeded=f(t._createOffer.bind(t));if(typeof window==="undefined"||!window.webkitRTCPeerConnection){t._pc.onnegotiationneeded()}}else{t._pc.ondatachannel=t._setupData.bind(t)}t.on("finish",function(){if(t.connected){setTimeout(function(){t._destroy()},100)}else{t.once("connect",function(){setTimeout(function(){t._destroy()},100)})}});t._interval=setInterval(function(){if(!t._cb||!t._channel||t._channel.bufferedAmount)return;t._debug("removing backpressure");var e=t._cb;t._cb=null;e()},150);if(t._interval.unref)t._interval.unref()}l.config={iceServers:[{url:"stun:23.21.150.121",urls:"stun:23.21.150.121"}]};l.constraints={};Object.defineProperty(l.prototype,"bufferSize",{get:function(){var e=this;return e._channel&&e._channel.bufferedAmount||0}});l.prototype.address=function(){var e=this;return{port:e.localPort,family:"IPv4",address:e.localAddress}};l.prototype.send=function(e,t){var r=this;if(!t)t=p;r._write(e,undefined,t)};l.prototype.signal=function(e){var t=this;if(t.destroyed)throw new Error("cannot signal after peer is destroyed");if(typeof e==="string"){try{e=JSON.parse(e)}catch(r){e={}}}t._debug("signal()");if(e.sdp){t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e),function(){if(t._pc.remoteDescription.type==="offer")t._createAnswer()},t._onError.bind(t))}if(e.candidate){try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e.candidate),p,t._onError.bind(t))}catch(r){t._destroy(new Error("error adding candidate: "+r.message))}}if(!e.sdp&&!e.candidate){t._destroy(new Error("signal() called with invalid signal data"))}};l.prototype.destroy=function(e){var t=this;t._destroy(null,e)};l.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);r._debug("destroy (error: %s)",e&&e.message);r.destroyed=true;r.connected=false;r._pcReady=false;r._channelReady=false;clearInterval(r._interval);r._interval=null;if(r._pc){try{r._pc.close()}catch(e){}r._pc.oniceconnectionstatechange=null;r._pc.onsignalingstatechange=null;r._pc.onicecandidate=null}if(r._channel){try{r._channel.close()}catch(e){}r._channel.onmessage=null;r._channel.onopen=null;r._channel.onclose=null}r._pc=null;r._channel=null;r.readable=r.writable=false;if(!r._readableState.ended)r.push(null);if(!r._writableState.finished)r.end();if(e)r.emit("error",e);r.emit("close")};l.prototype._setupData=function(e){var t=this;t._channel=e.channel;t.channelName=t._channel.label;t._channel.binaryType="arraybuffer";t._channel.onmessage=t._onChannelMessage.bind(t);t._channel.onopen=t._onChannelOpen.bind(t);t._channel.onclose=t._onChannelClose.bind(t)};l.prototype._read=function(){};l.prototype._write=function(e,t,n){var i=this;if(i.destroyed)return n(new Error("cannot write after peer is destroyed"));var o=e.length||e.byteLength||e.size;if(!i.connected){i._debug("_write before ready: length %d",o);i._buffer.push(e);n(null);return}i._debug("_write: length %d",o);if(a.strict(e)||e instanceof ArrayBuffer||typeof e==="string"||typeof Blob!=="undefined"&&e instanceof Blob){i._channel.send(e)}else if(r.isBuffer(e)){i._channel.send(new Uint8Array(e))}else{i._channel.send(JSON.stringify(e))}if(i._channel.bufferedAmount){i._debug("applying backpressure (bufferedAmount %s)",i._channel.bufferedAmount);i._cb=n}else{n(null)}};l.prototype._createOffer=function(){var e=this;if(e.destroyed)return;e._pc.createOffer(function(t){if(e.destroyed)return;d(t);e._pc.setLocalDescription(t,p,e._onError.bind(e));var r=function(){e._debug("signal");e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.offerConstraints)};l.prototype._createAnswer=function(){var e=this;if(e.destroyed)return;e._pc.createAnswer(function(t){if(e.destroyed)return;d(t);e._pc.setLocalDescription(t,p,e._onError.bind(e));var r=function(){e._debug("signal");e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.answerConstraints)};l.prototype._onIceConnectionStateChange=function(){var e=this;if(e.destroyed)return;var t=e._pc.iceGatheringState;var r=e._pc.iceConnectionState;e._debug("iceConnectionStateChange %s %s",t,r);e.emit("iceConnectionStateChange",t,r);if(r==="connected"||r==="completed"){e._pcReady=true;e._maybeReady()}if(r==="disconnected"||r==="closed"){e._destroy()}};l.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady);if(e.connected||e._connecting||!e._pcReady||!e._channelReady)return;e._connecting=true;if(typeof window!=="undefined"&&!!window.mozRTCPeerConnection){e._pc.getStats(null,function(e){var r=[];e.forEach(function(e){r.push(e)});t(r)},e._onError.bind(e))}else{e._pc.getStats(function(e){var r=[];e.result().forEach(function(e){var t={};e.names().forEach(function(r){t[r]=e.stat(r)});t.id=e.id;t.type=e.type;t.timestamp=e.timestamp;r.push(t)});t(r)})}function t(t){t.forEach(function(t){if(t.type==="remotecandidate"){e.remoteAddress=t.ipAddress;e.remoteFamily="IPv4";e.remotePort=Number(t.portNumber);e._debug("connect remote: %s:%s (%s)",e.remoteAddress,e.remotePort,e.remoteFamily)}else if(t.type==="localcandidate"&&t.candidateType==="host"){e.localAddress=t.ipAddress;e.localPort=Number(t.portNumber);e._debug("connect local: %s:%s",e.localAddress,e.localPort)}});e._connecting=false;e.connected=true;e._buffer.forEach(function(t){e.send(t)});e._buffer=[];e._debug("connect");e.emit("connect")}};l.prototype._onSignalingStateChange=function(){var e=this;if(e.destroyed)return;e._debug("signalingStateChange %s",e._pc.signalingState);e.emit("signalingStateChange",e._pc.signalingState)};l.prototype._onIceCandidate=function(e){var t=this;if(t.destroyed)return;if(e.candidate&&t.trickle){t.emit("signal",{candidate:e.candidate})}else if(!e.candidate){t._iceComplete=true;t.emit("_iceComplete")}};l.prototype._onChannelMessage=function(e){var t=this;if(t.destroyed)return;var r=e.data;t._debug("on channel message: length %d",r.byteLength||r.length);if(r instanceof ArrayBuffer){r=c(new Uint8Array(r));t.push(r)}else{try{r=JSON.parse(r)}catch(n){}t.emit("data",r)}};l.prototype._onChannelOpen=function(){var e=this;if(e.connected||e.destroyed)return;e._debug("on channel open");e._channelReady=true;e._maybeReady()};l.prototype._onChannelClose=function(){var e=this;if(e.destroyed)return;e._debug("on channel close");e._destroy()};l.prototype._onAddStream=function(e){var t=this;if(t.destroyed)return;t._debug("on add stream");t.emit("stream",e.stream)};l.prototype._onError=function(e){var t=this;if(t.destroyed)return;t._debug("error %s",e.message||e);t._destroy(e)};l.prototype._debug=function(){var e=this;var t=[].slice.call(arguments);var r=e.channelName&&e.channelName.substring(0,7);t[0]="["+r+"] "+t[0];n.apply(null,t)};function h(){if(typeof window==="undefined")return null;var e={RTCPeerConnection:window.mozRTCPeerConnection||window.RTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.mozRTCSessionDescription||window.RTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.mozRTCIceCandidate||window.RTCIceCandidate||window.webkitRTCIceCandidate};if(!e.RTCPeerConnection)return null;return e}function d(e){var t=e.sdp.split("b=AS:30");if(t.length>1)e.sdp=t[0]+"b=AS:1638400"+t[1]}function p(){}}).call(this,e("buffer").Buffer)},{buffer:34,debug:133,hat:136,inherits:137,"is-typedarray":138,once:140,stream:57,"typedarray-to-buffer":141,"xtend/mutable":143}],133:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./debug":134,dup:16}],134:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{dup:17,ms:135}],135:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],136:[function(e,t,r){arguments[4][93][0].apply(r,arguments)},{dup:93}],137:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],138:[function(e,t,r){arguments[4][71][0].apply(r,arguments)},{dup:71}],139:[function(e,t,r){arguments[4][27][0].apply(r,arguments)},{dup:27}],140:[function(e,t,r){arguments[4][77][0].apply(r,arguments)},{dup:77,wrappy:139}],141:[function(e,t,r){arguments[4][70][0].apply(r,arguments)},{buffer:34,dup:70,"is-typedarray":142}],142:[function(e,t,r){arguments[4][71][0].apply(r,arguments)},{dup:71}],143:[function(e,t,r){t.exports=n;function n(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r){if(r.hasOwnProperty(n)){e[n]=r[n]}}}return e}},{}],144:[function(e,t,r){(function(r){t.exports=c;var n=e("debug")("simple-websocket");var i=e("inherits");var o=e("is-typedarray");var s=e("stream");var a=e("typedarray-to-buffer");var f=e("ws");var u=typeof window!=="undefined"?window.WebSocket:f;i(c,s.Duplex);function c(e,t){var r=this;if(!(r instanceof c))return new c(e,t);if(!t)t={};n("new websocket: %s %o",e,t);t.allowHalfOpen=false;s.Duplex.call(r,t);r.url=e;r.connected=false;r.destroyed=false;r._buffer=[];r._ws=new u(r.url);r._ws.binaryType="arraybuffer";r._ws.onopen=r._onOpen.bind(r);r._ws.onmessage=r._onMessage.bind(r);r._ws.onclose=r._onClose.bind(r);r._ws.onerror=r._onError.bind(r);r.on("finish",function(){if(r.connected){r._destroy()}else{r.once("connect",function(){setTimeout(function(){r._destroy()},100)})}})}c.prototype.send=function(e,t){var r=this;if(!t)t=l;r._write(e,undefined,t)};c.prototype.destroy=function(e){var t=this;t._destroy(null,e)};c.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);n("destroy (error: %s)",e&&e.message);r.connected=false;r.destroyed=true;if(r._ws){try{r._ws.close()}catch(e){}r._ws.onopen=null;r._ws.onmessage=null;r._ws.onclose=null;r._ws.onerror=null}r._ws=null;this.readable=this.writable=false;if(!r._readableState.ended)r.push(null);if(!r._writableState.finished)r.end();if(e)r.emit("error",e);r.emit("close")};c.prototype._read=function(){};c.prototype._write=function(e,t,i){var s=this;if(s.destroyed)return i(new Error("cannot write after socket is destroyed"));var a=e.length||e.byteLength||e.size;if(!s.connected){n("_write before ready: length %d",a);s._buffer.push(e);i(null);return}n("_write: length %d",a);if(o.strict(e)||e instanceof ArrayBuffer||r.isBuffer(e)||typeof e==="string"||typeof Blob!=="undefined"&&e instanceof Blob){s._ws.send(e)}else{s._ws.send(JSON.stringify(e))}i(null)};c.prototype._onMessage=function(e){var t=this;if(t.destroyed)return;var i=e.data;n("on message: length %d",i.byteLength||i.length);if(i instanceof ArrayBuffer){i=a(new Uint8Array(i));t.push(i)}else if(r.isBuffer(i)){t.push(i)}else{try{i=JSON.parse(i)}catch(o){}t.emit("data",i)}};c.prototype._onOpen=function(){var e=this;if(e.connected||e.destroyed)return;e.connected=true;e._buffer.forEach(function(t){e.send(t)});e._buffer=[];n("connect");e.emit("connect")};c.prototype._onClose=function(){var e=this;if(e.destroyed)return;n("on close");e._destroy()};c.prototype._onError=function(){var e=this;if(e.destroyed)return;var t=new Error("connection error to "+e.url);n("error: %s",t.message||t);e._destroy(t)};function l(){}}).call(this,e("buffer").Buffer)},{buffer:34,debug:145,inherits:148,"is-typedarray":149,stream:57,"typedarray-to-buffer":150,ws:33}],145:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./debug":146,dup:16}],146:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{dup:17,ms:147}],147:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],148:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],149:[function(e,t,r){arguments[4][71][0].apply(r,arguments)},{dup:71}],150:[function(e,t,r){arguments[4][70][0].apply(r,arguments)},{buffer:34,dup:70,"is-typedarray":151}],151:[function(e,t,r){arguments[4][71][0].apply(r,arguments)},{dup:71}],152:[function(e,t,r){arguments[4][143][0].apply(r,arguments)},{dup:143}],153:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./debug":154,dup:16}],154:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{dup:17,ms:155}],155:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],156:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],157:[function(e,t,r){arguments[4][112][0].apply(r,arguments)},{dup:112,events:38}],158:[function(e,t,r){arguments[4][143][0].apply(r,arguments)},{dup:143}],159:[function(e,t,r){(function(r){var n=e("bencode");var i=e("bitfield");var o=e("events").EventEmitter;var s=e("inherits");var a=e("simple-sha1");var f=1e7;var u=1e3;var c=16*1024;t.exports=function(e){s(t,o);function t(t){o.call(this);this._wire=t;this._metadataComplete=false;this._metadataSize=null;this._remainingRejects=null;this._fetching=false;this._bitfield=new i(0,{grow:u});if(r.isBuffer(e)){this.setMetadata(e)}}t.prototype.name="ut_metadata";t.prototype.onHandshake=function(e,t,r){this._infoHash=e;this._infoHashHex=e.toString("hex")};t.prototype.onExtendedHandshake=function(e){if(!e.m||!e.m.ut_metadata){return this.emit("warning",new Error("Peer does not support ut_metadata"))}if(!e.metadata_size){return this.emit("warning",new Error("Peer does not have metadata"))}if(e.metadata_size>f){return this.emit("warning",new Error("Peer gave maliciously large metadata size"))}this._metadataSize=e.metadata_size;this._numPieces=Math.ceil(this._metadataSize/c);this._remainingRejects=this._numPieces*2;if(this._fetching){this._requestPieces()}};t.prototype.onMessage=function(e){var t,r;try{var i=e.toString();var o=i.indexOf("ee")+2;t=n.decode(i.substring(0,o));r=e.slice(o)}catch(s){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,r,t.total_size);break;case 2:this._onReject(t.piece);break}};t.prototype.fetch=function(){if(this._metadataComplete){return}this._fetching=true;if(this._metadataSize){this._requestPieces()}};t.prototype.cancel=function(){this._fetching=false};t.prototype.setMetadata=function(e){if(this._metadataComplete)return true;try{var t=n.decode(e).info;if(t){e=n.encode(t)}}catch(r){}if(this._infoHashHex&&this._infoHashHex!==a.sync(e)){return false}this.cancel();this.metadata=e;this._metadataComplete=true;this._metadataSize=this.metadata.length;this._wire.extendedHandshake.metadata_size=this._metadataSize;this.emit("metadata",n.encode({info:n.decode(this.metadata)}));return true};t.prototype._send=function(e,t){var i=n.encode(e);if(r.isBuffer(t)){i=r.concat([i,t])}this._wire.extended("ut_metadata",i)};t.prototype._request=function(e){this._send({msg_type:0,piece:e})};t.prototype._data=function(e,t,r){var n={msg_type:1,piece:e};if(typeof r==="number"){n.total_size=r}this._send(n,t)};t.prototype._reject=function(e){this._send({msg_type:2,piece:e})};t.prototype._onRequest=function(e){if(!this._metadataComplete){this._reject(e);return}var t=e*c;var r=t+c;if(r>this._metadataSize){r=this._metadataSize}var n=this.metadata.slice(t,r);this._data(e,n,this._metadataSize)};t.prototype._onData=function(e,t,r){if(t.length>c){return}t.copy(this.metadata,e*c);this._bitfield.set(e);this._checkDone()};t.prototype._onReject=function(e){if(this._remainingRejects>0&&this._fetching){this._request(e);this._remainingRejects-=1}else{this.emit("warning",new Error('Peer sent "reject" too much'))}};t.prototype._requestPieces=function(){this.metadata=new r(this._metadataSize);for(var e=0;e<this._numPieces;e++){this._request(e)}};t.prototype._checkDone=function(){var e=true;for(var t=0;t<this._numPieces;t++){if(!this._bitfield.get(t)){e=false;break}}if(!e)return;var r=this.setMetadata(this.metadata);if(!r){this._failedMetadata()}};t.prototype._failedMetadata=function(){this._bitfield=new i(0,{grow:u});this._remainingRejects-=this._numPieces;if(this._remainingRejects>0){this._requestPieces()}else{this.emit("warning",new Error("Peer sent invalid metadata"))}};return t}}).call(this,e("buffer").Buffer)},{bencode:160,bitfield:164,buffer:34,events:38,inherits:165,"simple-sha1":166}],160:[function(e,t,r){arguments[4][11][0].apply(r,arguments)},{"./lib/decode":161,"./lib/encode":163,dup:11}],161:[function(e,t,r){arguments[4][12][0].apply(r,arguments)},{"./dict":162,buffer:34,dup:12}],162:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{dup:13}],163:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{buffer:34,dup:14}],164:[function(e,t,r){arguments[4][6][0].apply(r,arguments)},{buffer:34,dup:6}],165:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],166:[function(e,t,r){arguments[4][84][0].apply(r,arguments)},{dup:84,rusha:167}],167:[function(e,t,r){arguments[4][85][0].apply(r,arguments)},{dup:85}],168:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],169:[function(e,t,r){t.exports=function n(e,t,r){if(t===undefined){return function(t,r){return n(e,t,r)}}if(r===undefined)r="0";e-=t.toString().length;if(e>0)return new Array(e+(/\./.test(t)?2:1)).join(r)+t;return t+""}},{}],170:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.36.0",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/fs-storage":false,"./server":false,"addr-to-ip-port":false,"bittorrent-dht/client":false,"load-ip-set":false,"simple-get":false,ut_pex:false},bugs:{url:"https://github.com/feross/webtorrent/issues"},dependencies:{"addr-to-ip-port":"^1.0.1",bitfield:"^1.0.2","bittorrent-dht":"^3.0.0","bittorrent-swarm":"^2.0.0","block-stream":"0.0.7",clivas:"^0.2.0","create-torrent":"^3.4.0",debug:"^2.1.0",dezalgo:"^1.0.1","end-of-stream":"^1.0.0",hat:"0.0.3",inherits:"^2.0.1",inquirer:"^0.8.0","load-ip-set":"^1.0.3",mime:"^1.2.11",minimist:"^1.1.0",mkdirp:"^0.5.0",moment:"^2.8.3",multistream:"^1.4.2","network-address":"^1.0.0",once:"^1.3.1","parse-torrent":"^4.0.0","pretty-bytes":"^1.0.1",pump:"^1.0.0","random-access-file":"^0.3.1","range-parser":"^1.0.2","re-emitter":"^1.0.0",rimraf:"^2.2.5","run-parallel":"^1.0.0","simple-get":"^1.0.0","simple-sha1":"^2.0.0",speedometer:"^0.1.2",thunky:"^0.1.0","torrent-discovery":"^3.0.0",ut_metadata:"^2.1.0",ut_pex:"^1.0.1","windows-no-runnable":"0.0.6",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^4.0.0",brfs:"^1.2.0",browserify:"^10.0.0","run-auto":"^1.0.0",standard:"^3.1.1",tape:"^4.0.0","uglify-js":"^2.4.15",zelda:"^2.0.0",zuul:"^3.0.0"},homepage:"http://webtorrent.io",keywords:["torrent","bittorrent","bittorrent client","streaming","download","webrtc","webrtc data","webtorrent","mad science"],license:"MIT",main:"index.js",optionalDependencies:{"airplay-js":"^0.2.3","chromecast-js":"^0.1.4",nodebmc:"0.0.5"},repository:{type:"git",url:"git://github.com/feross/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | uglifyjs -m > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && node ./bin/test.js","test-browser":"zuul -- test/basic.js","test-browser-local":"zuul --local -- test/basic.js","test-node":"tape test/*.js"}}},{}],171:[function(e,t,r){(function(r,n,i){t.exports=b;var o=e("create-torrent");var s=e("debug")("webtorrent");var a=e("bittorrent-dht/client");var f=e("events").EventEmitter;var u=e("xtend");var c=e("hat");var l=e("inherits");var h=e("load-ip-set");var d=e("run-parallel");var p=e("parse-torrent");var g=e("speedometer");var v=e("zero-fill");var m=e("./lib/fs-storage");var y=e("./lib/storage");var _=e("./lib/torrent");l(b,f);var w=e("./package.json").version.match(/([0-9]+)/g).slice(0,2).map(v(2)).join("");function b(e){var t=this;if(!(t instanceof b))return new b(e);if(!e)e={};f.call(t);if(!s.enabled)t.setMaxListeners(0);t.destroyed=false;t.torrentPort=e.torrentPort||0;t.tracker=e.tracker!==undefined?e.tracker:true;t._rtcConfig=e.rtcConfig;t._wrtc=e.wrtc||n.WRTC;t.torrents=[];t.downloadSpeed=g();t.uploadSpeed=g();t.storage=typeof e.storage==="function"?e.storage:e.storage!==false&&typeof m==="function"?m:y;t.peerId=e.peerId===undefined?new i("-WW"+w+"-"+c(48),"utf8"):typeof e.peerId==="string"?new i(e.peerId,"hex"):e.peerId;t.peerIdHex=t.peerId.toString("hex");t.nodeId=e.nodeId===undefined?new i(c(160),"hex"):typeof e.nodeId==="string"?new i(e.nodeId,"hex"):e.nodeId;t.nodeIdHex=t.nodeId.toString("hex");if(e.dht!==false&&typeof a==="function"){t.dht=new a(u({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}s("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof h==="function"){h(e.blocklist,{headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,r){if(e)return t.error("failed to load blocklist: "+e.message);t.blocked=r;o()})}else r.nextTick(o);function o(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(b.prototype,"ratio",{
  get:function(){var e=this;var t=e.torrents.reduce(function(e,t){return e+t.uploaded},0);var r=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/r}});b.prototype.get=function(e){var t=this;var r=p(e);if(!r.infoHash)throw new Error("Invalid torrent identifier");for(var n=0,i=t.torrents.length;n<i;n++){var o=t.torrents[n];if(o.infoHash===r.infoHash)return o}return null};b.prototype.add=b.prototype.download=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");s("add");if(typeof t==="function"){r=t;t={}}if(!t)t={};t.client=n;t.storage=t.storage||n.storage;var i=new _(e,t);n.torrents.push(i);function o(e){if(i.infoHash===e.infoHash){r(i);n.removeListener("torrent",o)}}if(r)n.on("torrent",o);i.on("error",function(e){n.emit("error",e,i)});i.on("listening",function(e){n.emit("listening",e,i)});i.on("ready",function(){s("torrent");n.emit("torrent",i)});return i};b.prototype.seed=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");s("seed");if(typeof t==="function"){r=t;t={}}if(!t)t={};t.noVerify=true;o.parseInput(e,t,function(i,s){if(i)return n.emit("error",i);var a=s.map(function(e){return e.getStream});o(e,t,function(e,i){if(e)return n.emit("error",e);if(n.destroyed)return;n.add(i,t,function(e){var t=[function(t){e.storage.load(a,t)}];if(n.dht){t.push(function(t){e.on("dhtAnnounce",t)})}d(t,function(t){if(t)return n.emit("error",t);if(r)r(e);n.emit("seed",e)})})})})};b.prototype.remove=function(e,t){var r=this;var n=r.get(e);if(!n)throw new Error("No torrent with id "+e);s("remove");r.torrents.splice(r.torrents.indexOf(n),1);n.destroy(t)};b.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}};b.prototype.destroy=function(e){var t=this;t.destroyed=true;s("destroy");var r=t.torrents.map(function(e){return function(r){t.remove(e.infoHash,r)}});if(t.dht){r.push(function(e){t.dht.destroy(e)})}d(r,e)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./lib/fs-storage":33,"./lib/storage":4,"./lib/torrent":5,"./package.json":170,_process:41,"bittorrent-dht/client":33,buffer:34,"create-torrent":62,debug:86,events:38,hat:93,inherits:94,"load-ip-set":33,"parse-torrent":99,"run-parallel":113,speedometer:119,xtend:168,"zero-fill":169}]},{},[171])(171)});