Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-03-20 01:07:50 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-03-20 01:07:50 +0300
commit840258e44825d88b3a0780334b0382fc272b1c99 (patch)
tree8f80f9687c6420579610b0705634e0740901bd12 /webtorrent.min.js
parentd8a0fdbcfd18650c058b49d7e4708573cbbfec95 (diff)
build
Diffstat (limited to 'webtorrent.min.js')
-rw-r--r--webtorrent.min.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/webtorrent.min.js b/webtorrent.min.js
index cc53db8..d7c42a7 100644
--- a/webtorrent.min.js
+++ b/webtorrent.min.js
@@ -1,8 +1,7 @@
-(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:55,inherits:63,path:17,stream:30}],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._playing=false;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;if(!i._playing){i.media.play();i._playing=true}};f.prototype._flow=function(){var e=this;n("flow");if(e._cb){e._cb(null)}}},{debug:55,inherits:63,once:67,stream:30}],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);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:18,bitfield:6,"block-stream":7,buffer:11,debug:55,dezalgo:58,"end-of-stream":61,events:15,inherits:63,multistream:64,once:67,"simple-sha1":83}],5:[function(e,t,r){(function(r){t.exports=L;var n=e("addr-to-ip-port");var i=e("debug")("webtorrent:torrent");var o=e("torrent-discovery");var s=e("events").EventEmitter;var a=e("fs");var f=e("simple-get");var u=e("inherits");var c=e("run-parallel");var l=e("parse-torrent");var h=e("re-emitter");var d=e("bittorrent-swarm");var p=e("ut_metadata");var g=e("ut_pex");var v=e("./rarity-map");var m=e("./server");var y=e("./storage");var _=128*1024;var w=1e4;var b=5e3;var k=3*y.BLOCK_LENGTH;var E=.5;var x=1;var S=1e4;var I=2;function A(){}u(L,s);function L(e,t){var n=this;s.call(n);if(!i.enabled)n.setMaxListeners(0);i("new torrent");n.client=t.client;n.hotswapEnabled="hotswap"in t?t.hotswap:true;n.verify=t.verify;n.storageOpts=t.storageOpts;n.chokeTimeout=t.chokeTimeout||b;n.pieceTimeout=t.pieceTimeout||w;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||y;var o;try{o=e&&e.parsedTorrent||l(e)}catch(u){}if(o&&o.infoHash){c(o)}else if(typeof f==="function"&&/^https?:/.test(e)){f.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)}c(t)})}else if(typeof a.readFile==="function"){a.readFile(e,function(e,t){if(e)return n.emit("error",new Error("Invalid torrent identifier"));c(t)})}else throw new Error("Invalid torrent identifier");function c(e){try{n.parsedTorrent=l(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;n.swarm=new d(n.infoHash,n.client.peerId,{handshake:{dht:!!n.client.dht}});h(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));if(r.browser){n._onSwarmListening()}else{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 l.toMagnetURI(this.parsedTorrent)}});L.prototype._onSwarmListening=function(e){var t=this;if(t._destroyed)return;t.client.torrentPort=e;t.discovery=new o({announce:t.parsedTorrent.announce,dht:t.client.dht,tracker:t.client.tracker,peerId:t.client.peerId,port:e,rtcConfig:t.client.rtcConfig});t.discovery.setTorrent(t.infoHash);t.discovery.on("peer",t.addPeer.bind(t));h(t.discovery,t,["dhtAnnounce","warning","error"]);if(t.parsedTorrent.info)t._onMetadata(t.parsedTorrent);t.emit("listening",e)};L.prototype._onMetadata=function(e){var t=this;if(t.metadata||t._destroyed)return;i("got metadata");if(e&&e.infoHash){t.metadata=l.toTorrentFile(e);t.parsedTorrent=e}else{t.metadata=e;try{t.parsedTorrent=l(t.metadata)}catch(n){return t.emit("error",n)}}t.name=t.parsedTorrent.name;t.discovery.setTorrent(t.parsedTorrent);t.rarityMap=new v(t.swarm,t.parsedTorrent.pieces.length);t.storage=new t._storageImpl(t.parsedTorrent,t.storageOpts);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();i("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(){i("verifying existing torrent data");var e=0;var r=0;c(t.storage.pieces.map(function(n){return function(o){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;i("piece "+(n.verified?"verified":"invalid")+" "+n.index)}o()},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;i("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)});c(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("blocked-peer",e);return false}else{t.emit("peer",e);t.swarm.addPeer(e);return true}};L.prototype.select=function(e,t,r,n){var o=this;if(e>t||e<0||t>=o.storage.pieces.length){throw new Error("invalid selection ",e,":",t)}r=Number(r)||0;i("select %s-%s (priority %s)",e,t,r);o._selections.push({from:e,to:t,offset:0,priority:r,notify:n||A});o._selections.sort(function(e,t){return t.priority-e.priority});o._updateSelections()};L.prototype.deselect=function(e,t,r){var n=this;r=Number(r)||0;i("deselect %s-%s (priority %s)",e,t,r);for(var o=0;o<n._selections.length;++o){var s=n._selections[o];if(s.from===e&&s.to===t&&s.priority===r){n._selections.splice(o--,1);break}}n._updateSelections()};L.prototype.critical=function(e,t){var r=this;i("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(p(t.metadata));if(!t.metadata){e.ut_metadata.on("metadata",function(e){i("got metadata via ut_metadata");t._onMetadata(e)});e.ut_metadata.fetch()}if(typeof g==="function"){e.use(g());e.ut_pex.on("peer",function(e){i("got peer via ut_pex "+e);t.addPeer(e)});e.ut_pex.on("dropped",function(e){if(!(e in t.swarm._peers))t.swarm.removePeer(e)})}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(t){i("port %s message from %s",t,e.remoteAddress)});e.on("timeout",function(){i("wire timeout from "+e.remoteAddress);e.destroy()});e.setTimeout(t.pieceTimeout);if(t.metadata){t._onWireWithMetadata(e)}};L.prototype._onWireWithMetadata=function(e){var t=this;var r=null;var n=t.chokeTimeout;function o(){if(t._destroyed||e._destroyed)return;if(t.swarm.numQueued>2*(t.swarm.numConns-t.swarm.numPeers)&&e.amInterested){e.destroy()}else{r=setTimeout(o,n)}}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(o,n)});e.on("unchoke",function(){clearTimeout(r);t._update()});e.on("request",function(r,n,o,s){if(o>_){i(e.remoteAddress,"requested invalid block size",o);return e.destroy()}t.storage.readBlock(r,n,o,s)});e.bitfield(t.storage.bitfield);e.interested();r=setTimeout(o,n);e.isSeeder=false;a()};L.prototype._onStorage=function(){var e=this;if(e._destroyed)return;i("on storage");e.storage.readonly=false;e.select(0,e.storage.pieces.length-1,false);e._rechokeIntervalId=setInterval(e._rechoke.bind(e),S);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();r.nextTick(function(){e.ready=true;e.emit("ready")})};L.prototype._onStoragePiece=function(e){var t=this;i("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=B(e,E);if(e.requests.length>=r)return;var n=B(e,x);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>k)return function(){return true};var n=Math.max(1,e.requests.length)*y.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<k)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[T(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<y.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>=k)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 o=this;var s=e.requests.length;if(o.storage.bitfield.get(t))return false;var a=B(e,x);if(s>=a)return false;var f=e.requests.length===0&&o.storage.numMissing<30;var u=o.storage.reserveBlock(t,f);if(!u&&!f&&n&&o._hotswap(e,t)){u=o.storage.reserveBlock(t,false)}if(!u)return false;var c=o._reservations[t];if(!c){c=o._reservations[t]=[]}var l=c.indexOf(null);if(l===-1)l=c.length;c[l]=e;function h(n,s){if(!o.ready){o.once("ready",function(){h(n,s)});return}if(c[l]===e)c[l]=null;if(n){i("error getting piece %s (offset: %s length: %s) from %s: %s",t,u.offset,u.length,e.remoteAddress,n.message);o.storage.cancelBlock(t,u.offset);r.nextTick(o._update.bind(o));return false}else{i("got piece %s (offset: %s length: %s) from %s",t,u.offset,u.length,e.remoteAddress);o.storage.writeBlock(t,u.offset,s,function(e){if(e){i("error writing block");o.storage.cancelBlock(t,u.offset)}r.nextTick(o._update.bind(o))})}}e.request(t,u.offset,u.length,h);return true};L.prototype.createServer=function(e){var t=this;if(typeof m==="function"){return new m(t,e)}};function B(e,t){return Math.ceil(2+t*e.downloadSpeed()/y.BLOCK_LENGTH)}function T(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=T(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":10,"./storage":4,_process:18,"addr-to-ip-port":10,"bittorrent-swarm":128,debug:55,events:15,fs:8,inherits:63,"parse-torrent":68,"re-emitter":81,"run-parallel":82,"simple-get":10,"torrent-discovery":86,ut_metadata:119,ut_pex:10}],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:11}],7:[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:18,assert:9,buffer:11,inherits:63,stream:30}],8:[function(e,t,r){},{}],9:[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/":33}],10:[function(e,t,r){arguments[4][8][0].apply(r,arguments)},{dup:8}],11:[function(e,t,r){var n=e("base64-js");var i=e("ieee754");var o=e("is-array");r.Buffer=f;r.SlowBuffer=u;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,t){var r=this;if(!(r instanceof f))return new f(e,t);var n=typeof e;var i;if(n==="number"){i=+e}else if(n==="string"){i=f.byteLength(e,t)}else if(n==="object"&&e!==null){if(e.type==="Buffer"&&o(e.data))e=e.data;i=+e.length}else{throw new TypeError("must start with number, buffer, array or string")}if(i>s){throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes")}if(i<0)i=0;else i>>>=0;if(f.TYPED_ARRAY_SUPPORT){r=f._augment(new Uint8Array(i))}else{r.length=i;r._isBuffer=true}var u;if(f.TYPED_ARRAY_SUPPORT&&typeof e.byteLength==="number"){r._set(e)}else if(C(e)){if(f.isBuffer(e)){for(u=0;u<i;u++){r[u]=e.readUInt8(u)}}else{for(u=0;u<i;u++){r[u]=(e[u]%256+256)%256}}}else if(n==="string"){r.write(e,0,t)}else if(n==="number"&&!f.TYPED_ARRAY_SUPPORT){for(u=0;u<i;u++){r[u]=0}}if(i>0&&i<=f.poolSize)r.parent=a;return r}function u(e,t){if(!(this instanceof u))return new u(e,t);var r=new f(e,t);delete r.parent;return r}f.isBuffer=function N(e){return!!(e!=null&&e._isBuffer)};f.compare=function q(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;for(var i=0,o=Math.min(r,n);i<o&&e[i]===t[i];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 W(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 F(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};f.byteLength=function Y(e,t){var r;e=e+"";switch(t||"utf8"){case"ascii":case"binary":case"raw":r=e.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=e.length*2;break;case"hex":r=e.length>>>1;break;case"utf8":case"utf-8":r=O(e).length;break;case"base64":r=D(e).length;break;default:r=e.length}return r};f.prototype.length=undefined;f.prototype.parent=undefined;f.prototype.toString=function J(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 w(this,t,r);case"utf8":case"utf-8":return m(this,t,r);case"ascii":return y(this,t,r);case"binary":return _(this,t,r);case"base64":return v(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}};f.prototype.equals=function G(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 V(){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 $(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 K(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 Q(e){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(e)};f.prototype.set=function X(e,t){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(e,t)};function c(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 l(e,t,r,n){var i=H(O(t,e.length-r),e,r,n);return i}function h(e,t,r,n){var i=H(j(t),e,r,n);return i}function d(e,t,r,n){return h(e,t,r,n)}function p(e,t,r,n){var i=H(D(t),e,r,n);return i}function g(e,t,r,n){var i=H(U(t,e.length-r),e,r,n);return i}f.prototype.write=function Z(e,t,r,n){if(isFinite(t)){if(!isFinite(r)){n=r;r=undefined}}else{var i=n;n=t;t=r;r=i}t=Number(t)||0;if(r<0||t<0||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}var o=this.length-t;if(!r){r=o}else{r=Number(r);if(r>o){r=o}}n=String(n||"utf8").toLowerCase();var s;switch(n){case"hex":s=c(this,e,t,r);break;case"utf8":case"utf-8":s=l(this,e,t,r);break;case"ascii":s=h(this,e,t,r);break;case"binary":s=d(this,e,t,r);break;case"base64":s=p(this,e,t,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":s=g(this,e,t,r);break;default:throw new TypeError("Unknown encoding: "+n)}return s};f.prototype.toJSON=function ee(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function v(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function m(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+=z(i)+String.fromCharCode(e[o]);i=""}else{i+="%"+e[o].toString(16)}}return n+z(i)}function y(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 _(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 w(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+=P(e[o])}return i}function b(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 te(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 k(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 re(e,t,r){e=e>>>0;t=t>>>0;if(!r)k(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 ne(e,t,r){e=e>>>0;t=t>>>0;if(!r){k(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 ie(e,t){if(!t)k(e,1,this.length);return this[e]};f.prototype.readUInt16LE=function oe(e,t){if(!t)k(e,2,this.length);return this[e]|this[e+1]<<8};f.prototype.readUInt16BE=function se(e,t){if(!t)k(e,2,this.length);return this[e]<<8|this[e+1]};f.prototype.readUInt32LE=function ae(e,t){if(!t)k(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUInt32BE=function fe(e,t){if(!t)k(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function ue(e,t,r){e=e>>>0;t=t>>>0;if(!r)k(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 ce(e,t,r){e=e>>>0;t=t>>>0;if(!r)k(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 le(e,t){if(!t)k(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};f.prototype.readInt16LE=function he(e,t){if(!t)k(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};f.prototype.readInt16BE=function de(e,t){if(!t)k(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};f.prototype.readInt32LE=function pe(e,t){if(!t)k(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function ge(e,t){if(!t)k(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function ve(e,t){if(!t)k(e,4,this.length);return i.read(this,e,true,23,4)};f.prototype.readFloatBE=function me(e,t){if(!t)k(e,4,this.length);return i.read(this,e,false,23,4)};f.prototype.readDoubleLE=function ye(e,t){if(!t)k(e,8,this.length);return i.read(this,e,true,52,8)};f.prototype.readDoubleBE=function _e(e,t){if(!t)k(e,8,this.length);return i.read(this,e,false,52,8)};function E(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 we(e,t,r,n){e=+e;t=t>>>0;r=r>>>0;if(!n)E(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>>>0&255}return t+r};f.prototype.writeUIntBE=function be(e,t,r,n){e=+e;t=t>>>0;r=r>>>0;if(!n)E(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>>>0&255}return t+r};f.prototype.writeUInt8=function ke(e,t,r){e=+e;t=t>>>0;if(!r)E(this,e,t,1,255,0);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function x(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 Ee(e,t,r){e=+e;t=t>>>0;if(!r)E(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{x(this,e,t,true)}return t+2};f.prototype.writeUInt16BE=function xe(e,t,r){e=+e;t=t>>>0;if(!r)E(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{x(this,e,t,false)}return t+2};function S(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 Se(e,t,r){e=+e;t=t>>>0;if(!r)E(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{S(this,e,t,true)}return t+4};f.prototype.writeUInt32BE=function Ie(e,t,r){e=+e;t=t>>>0;if(!r)E(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{S(this,e,t,false)}return t+4};f.prototype.writeIntLE=function Ae(e,t,r,n){e=+e;t=t>>>0;if(!n){E(this,e,t,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1))}var i=0;var o=1;var s=e<0?1:0;this[t]=e&255;while(++i<r&&(o*=256)){this[t+i]=(e/o>>0)-s&255}return t+r};f.prototype.writeIntBE=function Le(e,t,r,n){e=+e;t=t>>>0;if(!n){E(this,e,t,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1))}var i=r-1;var o=1;var s=e<0?1:0;this[t+i]=e&255;while(--i>=0&&(o*=256)){this[t+i]=(e/o>>0)-s&255}return t+r};f.prototype.writeInt8=function Be(e,t,r){e=+e;t=t>>>0;if(!r)E(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 Te(e,t,r){e=+e;t=t>>>0;if(!r)E(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{x(this,e,t,true)}return t+2};f.prototype.writeInt16BE=function Re(e,t,r){e=+e;t=t>>>0;if(!r)E(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{x(this,e,t,false)}return t+2};f.prototype.writeInt32LE=function Me(e,t,r){e=+e;t=t>>>0;if(!r)E(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{S(this,e,t,true)}return t+4};f.prototype.writeInt32BE=function Ce(e,t,r){e=+e;t=t>>>0;if(!r)E(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{S(this,e,t,false)}return t+4};function I(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 A(e,t,r,n,o){if(!o){I(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,r,n,23,4);return r+4}f.prototype.writeFloatLE=function Pe(e,t,r){return A(this,e,t,true,r)};f.prototype.writeFloatBE=function Oe(e,t,r){return A(this,e,t,false,r)};function L(e,t,r,n,o){if(!o){I(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,r,n,52,8);return r+8}f.prototype.writeDoubleLE=function je(e,t,r){return L(this,e,t,true,r)};f.prototype.writeDoubleBE=function Ue(e,t,r){return L(this,e,t,false,r)};f.prototype.copy=function De(e,t,r,n){var i=this;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||i.length===0)return 0;if(t<0){throw new RangeError("targetStart out of bounds")}if(r<0||r>=i.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 o=n-r;if(o<1e3||!f.TYPED_ARRAY_SUPPORT){for(var s=0;s<o;s++){e[s+t]=this[s+r]}}else{e._set(this.subarray(r,r+o),t)}return o};f.prototype.fill=function He(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=O(e.toString());var o=i.length;for(n=t;n<r;n++){this[n]=i[n%o]}}return this};f.prototype.toArrayBuffer=function ze(){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 B=f.prototype;f._augment=function Ne(e){e.constructor=f;e._isBuffer=true;e._get=e.get;e._set=e.set;e.get=B.get;e.set=B.set;e.write=B.write;e.toString=B.toString;e.toLocaleString=B.toString;e.toJSON=B.toJSON;e.equals=B.equals;e.compare=B.compare;e.indexOf=B.indexOf;e.copy=B.copy;e.slice=B.slice;e.readUIntLE=B.readUIntLE;e.readUIntBE=B.readUIntBE;e.readUInt8=B.readUInt8;e.readUInt16LE=B.readUInt16LE;e.readUInt16BE=B.readUInt16BE;e.readUInt32LE=B.readUInt32LE;e.readUInt32BE=B.readUInt32BE;e.readIntLE=B.readIntLE;e.readIntBE=B.readIntBE;e.readInt8=B.readInt8;e.readInt16LE=B.readInt16LE;e.readInt16BE=B.readInt16BE;e.readInt32LE=B.readInt32LE;e.readInt32BE=B.readInt32BE;e.readFloatLE=B.readFloatLE;e.readFloatBE=B.readFloatBE;e.readDoubleLE=B.readDoubleLE;e.readDoubleBE=B.readDoubleBE;e.writeUInt8=B.writeUInt8;e.writeUIntLE=B.writeUIntLE;e.writeUIntBE=B.writeUIntBE;e.writeUInt16LE=B.writeUInt16LE;e.writeUInt16BE=B.writeUInt16BE;e.writeUInt32LE=B.writeUInt32LE;e.writeUInt32BE=B.writeUInt32BE;e.writeIntLE=B.writeIntLE;e.writeIntBE=B.writeIntBE;e.writeInt8=B.writeInt8;e.writeInt16LE=B.writeInt16LE;e.writeInt16BE=B.writeInt16BE;e.writeInt32LE=B.writeInt32LE;e.writeInt32BE=B.writeInt32BE;e.writeFloatLE=B.writeFloatLE;e.writeFloatBE=B.writeFloatBE;e.writeDoubleLE=B.writeDoubleLE;e.writeDoubleBE=B.writeDoubleBE;e.fill=B.fill;e.inspect=B.inspect;e.toArrayBuffer=B.toArrayBuffer;return e};var T=/[^+\/0-9A-z\-]/g;function R(e){e=M(e).replace(T,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function M(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function C(e){return o(e)||f.isBuffer(e)||e&&typeof e==="object"&&typeof e.length==="number"}function P(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function O(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 U(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 D(e){return n.toByteArray(R(e))}function H(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 z(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}},{"base64-js":12,ieee754:13,"is-array":14}],12:[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)},{}],13:[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}},{}],14:[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)}},{}],15:[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}},{}],16:[function(e,t,r){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],17:[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:18}],18:[function(e,t,r){var n=t.exports={};var i=[];var o=false;function s(){if(o){return}o=true;var e;var t=i.length;while(t){e=i;i=[];var r=-1;while(++r<t){e[r]()}t=i.length}o=false}n.nextTick=function(e){i.push(e);if(!o){setTimeout(s,0)}};n.title="browser";n.browser=true;n.env={};n.argv=[];n.version="";n.versions={};function a(){}n.on=a;n.addListener=a;n.once=a;n.off=a;n.removeListener=a;n.removeAllListeners=a;n.emit=a;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}},{}],19:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":20}],20:[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":22,"./_stream_writable":24,_process:18,"core-util-is":25,inherits:63}],21:[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":23,"core-util-is":25,inherits:63}],22:[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)L(this);else _(this);return null}e=v(e,t);if(e===0&&t.ended){if(t.length===0)L(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=A(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)L(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");I(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;I(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");I(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 I(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"];B(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=A;function A(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 L(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 B(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":20,_process:18,buffer:11,"core-util-is":25,events:15,inherits:63,isarray:16,stream:30,"string_decoder/":31,util:10}],23:[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":20,"core-util-is":25,inherits:63}],24:[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":20,_process:18,buffer:11,"core-util-is":25,inherits:63,stream:30}],25:[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:11}],26:[function(e,t,r){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":21}],27:[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":20,"./lib/_stream_passthrough.js":21,"./lib/_stream_readable.js":22,"./lib/_stream_transform.js":23,"./lib/_stream_writable.js":24,stream:30}],28:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":23}],29:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":24}],30:[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:15,inherits:63,"readable-stream/duplex.js":19,"readable-stream/passthrough.js":26,"readable-stream/readable.js":27,"readable-stream/transform.js":28,"readable-stream/writable.js":29}],31:[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:11}],32:[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"}},{}],33:[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)||!I(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&&B(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(L(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0)){return d(t)}if(s.length===0){if(B(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(A(t)){return e.stylize(Date.prototype.toString.call(t),"date")}if(L(t)){return d(t)}}var u="",y=false,_=["{","}"];if(m(t)){y=true;_=["[","]"]}if(B(t)){var w=t.name?": "+t.name:"";u=" [Function"+w+"]"}if(S(t)){u=" "+RegExp.prototype.toString.call(t)}if(A(t)){u=" "+Date.prototype.toUTCString.call(t)}if(L(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 I(e)&&R(e)==="[object RegExp]"}r.isRegExp=S;function I(e){return typeof e==="object"&&e!==null}r.isObject=I;function A(e){return I(e)&&R(e)==="[object Date]"}r.isDate=A;function L(e){return I(e)&&(R(e)==="[object Error]"||e instanceof Error)}r.isError=L;function B(e){return typeof e==="function"}r.isFunction=B;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 R(e){return Object.prototype.toString.call(e)}function M(e){return e<10?"0"+e.toString(10):e.toString(10)}var C=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date;var t=[M(e.getHours()),M(e.getMinutes()),M(e.getSeconds())].join(":");return[e.getDate(),C[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||!I(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":32,_process:18,inherits:63}],34:[function(e,t,r){(function(r,n){t.exports=m;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=y;var i=e("bencode");var o=e("block-stream");var s=e("piece-length");var a=e("path");var f=e("filestream/read");var u=e("flatten");var c=e("fs");var l=e("multistream");var h=e("once");var d=e("run-parallel");var p=e("simple-sha1");var g=e("stream");var v=g.Transform;function m(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};y(e,t,function(e,n){if(e)return r(e);E(n,t,r)})}function y(e,t,i){if(typeof t==="function"){i=t;t={}}if(!t)t={};if(I(e))e=Array.prototype.slice.call(e);if(!Array.isArray(e))e=[e];if(e.length===0)throw new Error("invalid input type");if(!t.name)t.name=e[0].name||typeof e[0]==="string"&&a.basename(e);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 o=e.reduce(function(e,t){return e+Number(typeof t==="string")},0);d(e.map(function(e){return function(r){var i={};if(S(e)){i.getStream=L(e);i.length=e.size}else if(n.isBuffer(e)){i.getStream=B(e);i.length=e.length}else if(A(e)){if(!t.pieceLength)throw new Error("must specify `pieceLength` option if input is Stream");i.getStream=R(e,i);i.length=0}else if(typeof e==="string"){var s=o>1;_(e,s,r);return}else{throw new Error("invalid input type in array")}if(!e.name)throw new Error("missing requied `name` property on input");i.path=e.name.split(a.sep);r(null,i)}}),function(e,t){if(e)return i(e);t=u(t);if(o===0)r.nextTick(function(){i(null,t)});else i(null,t)})}function _(e,t,r){b(w,e,function(n,i){if(n)return r(n);if(Array.isArray(i))i=u(i);else i=[i];var o=a.normalize(e);if(t||i.length===1){o=o.slice(0,o.lastIndexOf(a.sep)+1)}else{if(o[o.length-1]!==a.sep)o+=a.sep}i.forEach(function(e){e.getStream=T(e.path);e.path=e.path.replace(o,"").split(a.sep)});r(null,i)})}function w(e,t){t=h(t);c.stat(e,function(r,n){if(r)return t(r);var i={length:n.size,path:e};t(null,i)})}function b(e,t,r){c.readdir(t,function(n,i){if(n&&n.code==="ENOTDIR"){e(t,r)}else if(n){r(n)}else{d(i.map(function(r){return function(n){b(e,a.join(t,r),n)}}),r)}})}function k(e,t,r){r=h(r);var i=[];var s=0;var a=e.map(function(e){return e.getStream});var f=0;var u=0;var c=false;new l(a).pipe(new o(t,{nopad:true})).on("data",function(e){s+=e.length;var t=u;p(e,function(e){i[t]=e;f-=1;d()});f+=1;u+=1}).on("end",function(){c=true;d()}).on("error",r);function d(){if(c&&f===0)r(null,new n(i.join(""),"hex"),s)}}function E(e,r,n){var o=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:o[0][0],"announce-list":o,"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||s(e.reduce(x,0));a.info["piece length"]=u;k(e,u,function(t,r,o){if(t)return n(t);a.info.pieces=r;e.forEach(function(e){delete e.getStream});if(!f){a.info.files=e}else{a.info.length=o}n(null,i.encode(a))})}function x(e,t){return e+t.length}function S(e){return typeof Blob!=="undefined"&&e instanceof Blob}function I(e){return typeof FileList==="function"&&e instanceof FileList}function A(e){return typeof e==="object"&&typeof e.pipe==="function"}function L(e){return function(){return new f(e)}}function B(e){return function(){var t=new g.PassThrough;t.end(e);return t}}function T(e){return function(){return c.createReadStream(e)}}function R(e,t){return function(){var r=new v;r._transform=function(e,r,n){t.length+=e.length;this.push(e);n()};e.pipe(r);return r}}}).call(this,e("_process"),e("buffer").Buffer)},{_process:18,bencode:35,"block-stream":39,buffer:11,"filestream/read":44,flatten:45,fs:8,multistream:46,once:49,path:17,"piece-length":50,"run-parallel":52,"simple-sha1":53,stream:30}],35:[function(e,t,r){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":36,"./lib/encode":38}],36:[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;
+(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:45,inherits:53,path:17,stream:30}],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._playing=false;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;if(!i._playing){i.media.play();i._playing=true}};f.prototype._flow=function(){var e=this;n("flow");if(e._cb){e._cb(null)}}},{debug:45,inherits:53,once:56,stream:30}],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);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:18,bitfield:6,"block-stream":7,buffer:11,debug:45,dezalgo:48,"end-of-stream":51,events:15,inherits:53,multistream:54,once:56,"simple-sha1":69}],5:[function(e,t,r){(function(r){t.exports=L;var n=e("addr-to-ip-port");var i=e("debug")("webtorrent:torrent");var o=e("torrent-discovery");var s=e("events").EventEmitter;var a=e("fs");var f=e("simple-get");var u=e("inherits");var c=e("run-parallel");var l=e("parse-torrent");var h=e("re-emitter");var d=e("bittorrent-swarm");var p=e("ut_metadata");var g=e("ut_pex");var v=e("./rarity-map");var m=e("./server");var y=e("./storage");var _=128*1024;var w=1e4;var b=5e3;var k=3*y.BLOCK_LENGTH;var E=.5;var x=1;var S=1e4;var I=2;function A(){}u(L,s);function L(e,t){var n=this;s.call(n);if(!i.enabled)n.setMaxListeners(0);i("new torrent");n.client=t.client;n.hotswapEnabled="hotswap"in t?t.hotswap:true;n.verify=t.verify;n.storageOpts=t.storageOpts;n.chokeTimeout=t.chokeTimeout||b;n.pieceTimeout=t.pieceTimeout||w;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||y;var o;try{o=e&&e.parsedTorrent||l(e)}catch(u){}if(o&&o.infoHash){c(o)}else if(typeof f==="function"&&/^https?:/.test(e)){f.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)}c(t)})}else if(typeof a.readFile==="function"){a.readFile(e,function(e,t){if(e)return n.emit("error",new Error("Invalid torrent identifier"));c(t)})}else throw new Error("Invalid torrent identifier");function c(e){try{n.parsedTorrent=l(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;n.swarm=new d(n.infoHash,n.client.peerId,{handshake:{dht:!!n.client.dht}});h(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));if(r.browser){n._onSwarmListening()}else{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 l.toMagnetURI(this.parsedTorrent)}});L.prototype._onSwarmListening=function(e){var t=this;if(t._destroyed)return;t.client.torrentPort=e;t.discovery=new o({announce:t.parsedTorrent.announce,dht:t.client.dht,tracker:t.client.tracker,peerId:t.client.peerId,port:e,rtcConfig:t.client.rtcConfig});t.discovery.setTorrent(t.infoHash);t.discovery.on("peer",t.addPeer.bind(t));h(t.discovery,t,["dhtAnnounce","warning","error"]);if(t.parsedTorrent.info)t._onMetadata(t.parsedTorrent);t.emit("listening",e)};L.prototype._onMetadata=function(e){var t=this;if(t.metadata||t._destroyed)return;i("got metadata");if(e&&e.infoHash){t.metadata=l.toTorrentFile(e);t.parsedTorrent=e}else{t.metadata=e;try{t.parsedTorrent=l(t.metadata)}catch(n){return t.emit("error",n)}}t.name=t.parsedTorrent.name;t.discovery.setTorrent(t.parsedTorrent);t.rarityMap=new v(t.swarm,t.parsedTorrent.pieces.length);t.storage=new t._storageImpl(t.parsedTorrent,t.storageOpts);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();i("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(){i("verifying existing torrent data");var e=0;var r=0;c(t.storage.pieces.map(function(n){return function(o){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;i("piece "+(n.verified?"verified":"invalid")+" "+n.index)}o()},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;i("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)});c(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("blocked-peer",e);return false}else{t.emit("peer",e);t.swarm.addPeer(e);return true}};L.prototype.select=function(e,t,r,n){var o=this;if(e>t||e<0||t>=o.storage.pieces.length){throw new Error("invalid selection ",e,":",t)}r=Number(r)||0;i("select %s-%s (priority %s)",e,t,r);o._selections.push({from:e,to:t,offset:0,priority:r,notify:n||A});o._selections.sort(function(e,t){return t.priority-e.priority});o._updateSelections()};L.prototype.deselect=function(e,t,r){var n=this;r=Number(r)||0;i("deselect %s-%s (priority %s)",e,t,r);for(var o=0;o<n._selections.length;++o){var s=n._selections[o];if(s.from===e&&s.to===t&&s.priority===r){n._selections.splice(o--,1);break}}n._updateSelections()};L.prototype.critical=function(e,t){var r=this;i("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(p(t.metadata));if(!t.metadata){e.ut_metadata.on("metadata",function(e){i("got metadata via ut_metadata");t._onMetadata(e)});e.ut_metadata.fetch()}if(typeof g==="function"){e.use(g());e.ut_pex.on("peer",function(e){i("got peer via ut_pex "+e);t.addPeer(e)});e.ut_pex.on("dropped",function(e){if(!(e in t.swarm._peers))t.swarm.removePeer(e)})}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(t){i("port %s message from %s",t,e.remoteAddress)});e.on("timeout",function(){i("wire timeout from "+e.remoteAddress);e.destroy()});e.setTimeout(t.pieceTimeout);if(t.metadata){t._onWireWithMetadata(e)}};L.prototype._onWireWithMetadata=function(e){var t=this;var r=null;var n=t.chokeTimeout;function o(){if(t._destroyed||e._destroyed)return;if(t.swarm.numQueued>2*(t.swarm.numConns-t.swarm.numPeers)&&e.amInterested){e.destroy()}else{r=setTimeout(o,n)}}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(o,n)});e.on("unchoke",function(){clearTimeout(r);t._update()});e.on("request",function(r,n,o,s){if(o>_){i(e.remoteAddress,"requested invalid block size",o);return e.destroy()}t.storage.readBlock(r,n,o,s)});e.bitfield(t.storage.bitfield);e.interested();r=setTimeout(o,n);e.isSeeder=false;a()};L.prototype._onStorage=function(){var e=this;if(e._destroyed)return;i("on storage");e.storage.readonly=false;e.select(0,e.storage.pieces.length-1,false);e._rechokeIntervalId=setInterval(e._rechoke.bind(e),S);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();r.nextTick(function(){e.ready=true;e.emit("ready")})};L.prototype._onStoragePiece=function(e){var t=this;i("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=B(e,E);if(e.requests.length>=r)return;var n=B(e,x);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>k)return function(){return true};var n=Math.max(1,e.requests.length)*y.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<k)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[T(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<y.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>=k)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 o=this;var s=e.requests.length;if(o.storage.bitfield.get(t))return false;var a=B(e,x);if(s>=a)return false;var f=e.requests.length===0&&o.storage.numMissing<30;var u=o.storage.reserveBlock(t,f);if(!u&&!f&&n&&o._hotswap(e,t)){u=o.storage.reserveBlock(t,false)}if(!u)return false;var c=o._reservations[t];if(!c){c=o._reservations[t]=[]}var l=c.indexOf(null);if(l===-1)l=c.length;c[l]=e;function h(n,s){if(!o.ready){o.once("ready",function(){h(n,s)});return}if(c[l]===e)c[l]=null;if(n){i("error getting piece %s (offset: %s length: %s) from %s: %s",t,u.offset,u.length,e.remoteAddress,n.message);o.storage.cancelBlock(t,u.offset);r.nextTick(o._update.bind(o));return false}else{i("got piece %s (offset: %s length: %s) from %s",t,u.offset,u.length,e.remoteAddress);o.storage.writeBlock(t,u.offset,s,function(e){if(e){i("error writing block");o.storage.cancelBlock(t,u.offset)}r.nextTick(o._update.bind(o))})}}e.request(t,u.offset,u.length,h);return true};L.prototype.createServer=function(e){var t=this;if(typeof m==="function"){return new m(t,e)}};function B(e,t){return Math.ceil(2+t*e.downloadSpeed()/y.BLOCK_LENGTH)}function T(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=T(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":10,"./storage":4,_process:18,"addr-to-ip-port":10,"bittorrent-swarm":83,debug:45,events:15,fs:8,inherits:53,"parse-torrent":57,"re-emitter":67,"run-parallel":68,"simple-get":10,"torrent-discovery":72,ut_metadata:78,ut_pex:10}],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:11}],7:[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:18,assert:9,buffer:11,inherits:53,stream:30}],8:[function(e,t,r){},{}],9:[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/":33}],10:[function(e,t,r){arguments[4][8][0].apply(r,arguments)},{dup:8}],11:[function(e,t,r){var n=e("base64-js");var i=e("ieee754");var o=e("is-array");r.Buffer=f;r.SlowBuffer=u;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,t){var r=this;if(!(r instanceof f))return new f(e,t);var n=typeof e;var i;if(n==="number"){i=+e}else if(n==="string"){i=f.byteLength(e,t)}else if(n==="object"&&e!==null){if(e.type==="Buffer"&&o(e.data))e=e.data;i=+e.length}else{throw new TypeError("must start with number, buffer, array or string")}if(i>s){throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes")}if(i<0)i=0;else i>>>=0;if(f.TYPED_ARRAY_SUPPORT){r=f._augment(new Uint8Array(i))}else{r.length=i;r._isBuffer=true}var u;if(f.TYPED_ARRAY_SUPPORT&&typeof e.byteLength==="number"){r._set(e)}else if(C(e)){if(f.isBuffer(e)){for(u=0;u<i;u++){r[u]=e.readUInt8(u)}}else{for(u=0;u<i;u++){r[u]=(e[u]%256+256)%256}}}else if(n==="string"){r.write(e,0,t)}else if(n==="number"&&!f.TYPED_ARRAY_SUPPORT){for(u=0;u<i;u++){r[u]=0}}if(i>0&&i<=f.poolSize)r.parent=a;return r}function u(e,t){if(!(this instanceof u))return new u(e,t);var r=new f(e,t);delete r.parent;return r}f.isBuffer=function N(e){return!!(e!=null&&e._isBuffer)};f.compare=function q(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;for(var i=0,o=Math.min(r,n);i<o&&e[i]===t[i];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 W(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 F(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};f.byteLength=function Y(e,t){var r;e=e+"";switch(t||"utf8"){case"ascii":case"binary":case"raw":r=e.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=e.length*2;break;case"hex":r=e.length>>>1;break;case"utf8":case"utf-8":r=P(e).length;break;case"base64":r=D(e).length;break;default:r=e.length}return r};f.prototype.length=undefined;f.prototype.parent=undefined;f.prototype.toString=function J(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 w(this,t,r);case"utf8":case"utf-8":return m(this,t,r);case"ascii":return y(this,t,r);case"binary":return _(this,t,r);case"base64":return v(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return b(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}};f.prototype.equals=function G(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 V(){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 K(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 $(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 Q(e){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(e)};f.prototype.set=function X(e,t){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(e,t)};function c(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 l(e,t,r,n){var i=H(P(t,e.length-r),e,r,n);return i}function h(e,t,r,n){var i=H(O(t),e,r,n);return i}function d(e,t,r,n){return h(e,t,r,n)}function p(e,t,r,n){var i=H(D(t),e,r,n);return i}function g(e,t,r,n){var i=H(U(t,e.length-r),e,r,n);return i}f.prototype.write=function Z(e,t,r,n){if(isFinite(t)){if(!isFinite(r)){n=r;r=undefined}}else{var i=n;n=t;t=r;r=i}t=Number(t)||0;if(r<0||t<0||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}var o=this.length-t;if(!r){r=o}else{r=Number(r);if(r>o){r=o}}n=String(n||"utf8").toLowerCase();var s;switch(n){case"hex":s=c(this,e,t,r);break;case"utf8":case"utf-8":s=l(this,e,t,r);break;case"ascii":s=h(this,e,t,r);break;case"binary":s=d(this,e,t,r);break;case"base64":s=p(this,e,t,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":s=g(this,e,t,r);break;default:throw new TypeError("Unknown encoding: "+n)}return s};f.prototype.toJSON=function ee(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function v(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function m(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+=z(i)+String.fromCharCode(e[o]);i=""}else{i+="%"+e[o].toString(16)}}return n+z(i)}function y(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 _(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 w(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+=j(e[o])}return i}function b(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 te(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 k(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 re(e,t,r){e=e>>>0;t=t>>>0;if(!r)k(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 ne(e,t,r){e=e>>>0;t=t>>>0;if(!r){k(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 ie(e,t){if(!t)k(e,1,this.length);return this[e]};f.prototype.readUInt16LE=function oe(e,t){if(!t)k(e,2,this.length);return this[e]|this[e+1]<<8};f.prototype.readUInt16BE=function se(e,t){if(!t)k(e,2,this.length);return this[e]<<8|this[e+1]};f.prototype.readUInt32LE=function ae(e,t){if(!t)k(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUInt32BE=function fe(e,t){if(!t)k(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function ue(e,t,r){e=e>>>0;t=t>>>0;if(!r)k(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 ce(e,t,r){e=e>>>0;t=t>>>0;if(!r)k(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 le(e,t){if(!t)k(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};f.prototype.readInt16LE=function he(e,t){if(!t)k(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};f.prototype.readInt16BE=function de(e,t){if(!t)k(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};f.prototype.readInt32LE=function pe(e,t){if(!t)k(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function ge(e,t){if(!t)k(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function ve(e,t){if(!t)k(e,4,this.length);return i.read(this,e,true,23,4)};f.prototype.readFloatBE=function me(e,t){if(!t)k(e,4,this.length);return i.read(this,e,false,23,4)};f.prototype.readDoubleLE=function ye(e,t){if(!t)k(e,8,this.length);return i.read(this,e,true,52,8)};f.prototype.readDoubleBE=function _e(e,t){if(!t)k(e,8,this.length);return i.read(this,e,false,52,8)};function E(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 we(e,t,r,n){e=+e;t=t>>>0;r=r>>>0;if(!n)E(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>>>0&255}return t+r};f.prototype.writeUIntBE=function be(e,t,r,n){e=+e;t=t>>>0;r=r>>>0;if(!n)E(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>>>0&255}return t+r};f.prototype.writeUInt8=function ke(e,t,r){e=+e;t=t>>>0;if(!r)E(this,e,t,1,255,0);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function x(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 Ee(e,t,r){e=+e;t=t>>>0;if(!r)E(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{x(this,e,t,true)}return t+2};f.prototype.writeUInt16BE=function xe(e,t,r){e=+e;t=t>>>0;if(!r)E(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{x(this,e,t,false)}return t+2};function S(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 Se(e,t,r){e=+e;t=t>>>0;if(!r)E(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{S(this,e,t,true)}return t+4};f.prototype.writeUInt32BE=function Ie(e,t,r){e=+e;t=t>>>0;if(!r)E(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{S(this,e,t,false)}return t+4};f.prototype.writeIntLE=function Ae(e,t,r,n){e=+e;t=t>>>0;if(!n){E(this,e,t,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1))}var i=0;var o=1;var s=e<0?1:0;this[t]=e&255;while(++i<r&&(o*=256)){this[t+i]=(e/o>>0)-s&255}return t+r};f.prototype.writeIntBE=function Le(e,t,r,n){e=+e;t=t>>>0;if(!n){E(this,e,t,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1))}var i=r-1;var o=1;var s=e<0?1:0;this[t+i]=e&255;while(--i>=0&&(o*=256)){this[t+i]=(e/o>>0)-s&255}return t+r};f.prototype.writeInt8=function Be(e,t,r){e=+e;t=t>>>0;if(!r)E(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 Te(e,t,r){e=+e;t=t>>>0;if(!r)E(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{x(this,e,t,true)}return t+2};f.prototype.writeInt16BE=function Re(e,t,r){e=+e;t=t>>>0;if(!r)E(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{x(this,e,t,false)}return t+2};f.prototype.writeInt32LE=function Me(e,t,r){e=+e;t=t>>>0;if(!r)E(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{S(this,e,t,true)}return t+4};f.prototype.writeInt32BE=function Ce(e,t,r){e=+e;t=t>>>0;if(!r)E(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{S(this,e,t,false)}return t+4};function I(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 A(e,t,r,n,o){if(!o){I(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,r,n,23,4);return r+4}f.prototype.writeFloatLE=function je(e,t,r){return A(this,e,t,true,r)};f.prototype.writeFloatBE=function Pe(e,t,r){return A(this,e,t,false,r)};function L(e,t,r,n,o){if(!o){I(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,r,n,52,8);return r+8}f.prototype.writeDoubleLE=function Oe(e,t,r){return L(this,e,t,true,r)};f.prototype.writeDoubleBE=function Ue(e,t,r){return L(this,e,t,false,r)};f.prototype.copy=function De(e,t,r,n){var i=this;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||i.length===0)return 0;if(t<0){throw new RangeError("targetStart out of bounds")}if(r<0||r>=i.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 o=n-r;if(o<1e3||!f.TYPED_ARRAY_SUPPORT){for(var s=0;s<o;s++){e[s+t]=this[s+r]}}else{e._set(this.subarray(r,r+o),t)}return o};f.prototype.fill=function He(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=P(e.toString());var o=i.length;for(n=t;n<r;n++){this[n]=i[n%o]}}return this};f.prototype.toArrayBuffer=function ze(){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 B=f.prototype;f._augment=function Ne(e){e.constructor=f;e._isBuffer=true;e._get=e.get;e._set=e.set;e.get=B.get;e.set=B.set;e.write=B.write;e.toString=B.toString;e.toLocaleString=B.toString;e.toJSON=B.toJSON;e.equals=B.equals;e.compare=B.compare;e.indexOf=B.indexOf;e.copy=B.copy;e.slice=B.slice;e.readUIntLE=B.readUIntLE;e.readUIntBE=B.readUIntBE;e.readUInt8=B.readUInt8;e.readUInt16LE=B.readUInt16LE;e.readUInt16BE=B.readUInt16BE;e.readUInt32LE=B.readUInt32LE;e.readUInt32BE=B.readUInt32BE;e.readIntLE=B.readIntLE;e.readIntBE=B.readIntBE;e.readInt8=B.readInt8;e.readInt16LE=B.readInt16LE;e.readInt16BE=B.readInt16BE;e.readInt32LE=B.readInt32LE;e.readInt32BE=B.readInt32BE;e.readFloatLE=B.readFloatLE;e.readFloatBE=B.readFloatBE;e.readDoubleLE=B.readDoubleLE;e.readDoubleBE=B.readDoubleBE;e.writeUInt8=B.writeUInt8;e.writeUIntLE=B.writeUIntLE;e.writeUIntBE=B.writeUIntBE;e.writeUInt16LE=B.writeUInt16LE;e.writeUInt16BE=B.writeUInt16BE;e.writeUInt32LE=B.writeUInt32LE;e.writeUInt32BE=B.writeUInt32BE;e.writeIntLE=B.writeIntLE;e.writeIntBE=B.writeIntBE;e.writeInt8=B.writeInt8;e.writeInt16LE=B.writeInt16LE;e.writeInt16BE=B.writeInt16BE;e.writeInt32LE=B.writeInt32LE;e.writeInt32BE=B.writeInt32BE;e.writeFloatLE=B.writeFloatLE;e.writeFloatBE=B.writeFloatBE;e.writeDoubleLE=B.writeDoubleLE;e.writeDoubleBE=B.writeDoubleBE;e.fill=B.fill;e.inspect=B.inspect;e.toArrayBuffer=B.toArrayBuffer;return e};var T=/[^+\/0-9A-z\-]/g;function R(e){e=M(e).replace(T,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function M(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function C(e){return o(e)||f.isBuffer(e)||e&&typeof e==="object"&&typeof e.length==="number"}function j(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function P(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 O(e){var t=[];for(var r=0;r<e.length;r++){t.push(e.charCodeAt(r)&255)}return t}function U(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 D(e){return n.toByteArray(R(e))}function H(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 z(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}},{"base64-js":12,ieee754:13,"is-array":14}],12:[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)},{}],13:[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}},{}],14:[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)}},{}],15:[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}},{}],16:[function(e,t,r){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],17:[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:18}],18:[function(e,t,r){var n=t.exports={};var i=[];var o=false;function s(){if(o){return}o=true;var e;var t=i.length;while(t){e=i;i=[];var r=-1;while(++r<t){e[r]()}t=i.length}o=false}n.nextTick=function(e){i.push(e);if(!o){setTimeout(s,0)}};n.title="browser";n.browser=true;n.env={};n.argv=[];n.version="";n.versions={};function a(){}n.on=a;n.addListener=a;n.once=a;n.off=a;n.removeListener=a;n.removeAllListeners=a;n.emit=a;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}},{}],19:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":20}],20:[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":22,"./_stream_writable":24,_process:18,"core-util-is":25,inherits:53}],21:[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":23,"core-util-is":25,inherits:53}],22:[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)L(this);else _(this);return null}e=v(e,t);if(e===0&&t.ended){if(t.length===0)L(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=A(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)L(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");I(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;I(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");I(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 I(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"];B(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=A;function A(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 L(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 B(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":20,_process:18,buffer:11,"core-util-is":25,events:15,inherits:53,isarray:16,stream:30,"string_decoder/":31,util:10}],23:[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":20,"core-util-is":25,inherits:53}],24:[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":20,_process:18,buffer:11,"core-util-is":25,inherits:53,stream:30}],25:[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:11}],26:[function(e,t,r){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":21}],27:[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":20,"./lib/_stream_passthrough.js":21,"./lib/_stream_readable.js":22,"./lib/_stream_transform.js":23,"./lib/_stream_writable.js":24,stream:30}],28:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":23}],29:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":24}],30:[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:15,inherits:53,"readable-stream/duplex.js":19,"readable-stream/passthrough.js":26,"readable-stream/readable.js":27,"readable-stream/transform.js":28,"readable-stream/writable.js":29}],31:[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:11}],32:[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"}},{}],33:[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)||!I(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&&B(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(L(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0)){return d(t)}if(s.length===0){if(B(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(A(t)){return e.stylize(Date.prototype.toString.call(t),"date")}if(L(t)){return d(t)}}var u="",y=false,_=["{","}"];if(m(t)){y=true;_=["[","]"]}if(B(t)){var w=t.name?": "+t.name:"";u=" [Function"+w+"]"}if(S(t)){u=" "+RegExp.prototype.toString.call(t)}if(A(t)){u=" "+Date.prototype.toUTCString.call(t)}if(L(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(P(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(!P(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 I(e)&&R(e)==="[object RegExp]"}r.isRegExp=S;function I(e){return typeof e==="object"&&e!==null}r.isObject=I;function A(e){return I(e)&&R(e)==="[object Date]"}r.isDate=A;function L(e){return I(e)&&(R(e)==="[object Error]"||e instanceof Error)}r.isError=L;function B(e){return typeof e==="function"}r.isFunction=B;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 R(e){return Object.prototype.toString.call(e)}function M(e){return e<10?"0"+e.toString(10):e.toString(10)}var C=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function j(){var e=new Date;var t=[M(e.getHours()),M(e.getMinutes()),M(e.getSeconds())].join(":");return[e.getDate(),C[e.getMonth()],t].join(" ")}r.log=function(){console.log("%s - %s",j(),r.format.apply(r,arguments))};r.inherits=e("inherits");r._extend=function(e,t){if(!t||!I(t))return e;var r=Object.keys(t);var n=r.length;while(n--){e[r[n]]=t[r[n]]}return e};function P(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":32,_process:18,inherits:53}],34:[function(e,t,r){(function(r,n){t.exports=m;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=y;var i=e("bencode");var o=e("block-stream");var s=e("piece-length");var a=e("path");var f=e("filestream/read");var u=e("flatten");var c=e("fs");var l=e("multistream");var h=e("once");var d=e("run-parallel");var p=e("simple-sha1");var g=e("stream");var v=g.Transform;function m(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};y(e,t,function(e,n){if(e)return r(e);E(n,t,r)})}function y(e,t,i){if(typeof t==="function"){i=t;t={}}if(!t)t={};if(I(e))e=Array.prototype.slice.call(e);if(!Array.isArray(e))e=[e];if(e.length===0)throw new Error("invalid input type");if(!t.name)t.name=e[0].name||typeof e[0]==="string"&&a.basename(e);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 o=e.reduce(function(e,t){return e+Number(typeof t==="string")},0);d(e.map(function(e){return function(r){var i={};if(S(e)){i.getStream=L(e);i.length=e.size}else if(n.isBuffer(e)){i.getStream=B(e);i.length=e.length}else if(A(e)){if(!t.pieceLength)throw new Error("must specify `pieceLength` option if input is Stream");i.getStream=R(e,i);i.length=0}else if(typeof e==="string"){var s=o>1;_(e,s,r);return}else{throw new Error("invalid input type in array")}if(!e.name)throw new Error("missing requied `name` property on input");i.path=e.name.split(a.sep);r(null,i)}}),function(e,t){if(e)return i(e);t=u(t);if(o===0)r.nextTick(function(){i(null,t)});else i(null,t)})}function _(e,t,r){b(w,e,function(n,i){if(n)return r(n);if(Array.isArray(i))i=u(i);else i=[i];var o=a.normalize(e);if(t||i.length===1){o=o.slice(0,o.lastIndexOf(a.sep)+1)}else{if(o[o.length-1]!==a.sep)o+=a.sep}i.forEach(function(e){e.getStream=T(e.path);e.path=e.path.replace(o,"").split(a.sep)});r(null,i)})}function w(e,t){t=h(t);c.stat(e,function(r,n){if(r)return t(r);var i={length:n.size,path:e};t(null,i)})}function b(e,t,r){c.readdir(t,function(n,i){if(n&&n.code==="ENOTDIR"){e(t,r)}else if(n){r(n)}else{d(i.map(function(r){return function(n){b(e,a.join(t,r),n)}}),r)}})}function k(e,t,r){r=h(r);var i=[];var s=0;var a=e.map(function(e){return e.getStream});var f=0;var u=0;var c=false;new l(a).pipe(new o(t,{nopad:true})).on("data",function(e){s+=e.length;var t=u;p(e,function(e){i[t]=e;f-=1;d()});f+=1;u+=1}).on("end",function(){c=true;d()}).on("error",r);function d(){if(c&&f===0)r(null,new n(i.join(""),"hex"),s)}}function E(e,r,n){var o=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:o[0][0],"announce-list":o,"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||s(e.reduce(x,0));a.info["piece length"]=u;k(e,u,function(t,r,o){if(t)return n(t);a.info.pieces=r;e.forEach(function(e){delete e.getStream});if(!f){a.info.files=e}else{a.info.length=o}n(null,i.encode(a))})}function x(e,t){return e+t.length}function S(e){return typeof Blob!=="undefined"&&e instanceof Blob}function I(e){return typeof FileList==="function"&&e instanceof FileList}function A(e){return typeof e==="object"&&typeof e.pipe==="function"}function L(e){return function(){return new f(e)}}function B(e){return function(){var t=new g.PassThrough;t.end(e);return t}}function T(e){return function(){return c.createReadStream(e)}}function R(e,t){return function(){var r=new v;r._transform=function(e,r,n){t.length+=e.length;this.push(e);n()};e.pipe(r);return r}}}).call(this,e("_process"),e("buffer").Buffer)},{_process:18,bencode:35,"block-stream":7,buffer:11,"filestream/read":41,flatten:42,fs:8,multistream:54,once:56,path:17,"piece-length":43,"run-parallel":68,"simple-sha1":69,stream:30}],35:[function(e,t,r){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":36,"./lib/encode":38}],36:[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":37,buffer:11}],37:[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}},{}],38:[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:11}],39:[function(e,t,r){arguments[4][7][0].apply(r,arguments)},{_process:18,assert:9,buffer:11,dup:7,inherits:40,stream:30}],40:[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}}},{}],41:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],42:[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:11,"is-typedarray":43}],43:[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)]}},{}],44:[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:41,stream:30,"typedarray-to-buffer":42}],45:[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)}},[])}}},{}],46:[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:47,stream:30}],47:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],48:[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}}},{}],49:[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:48}],50:[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":51}],51:[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}},{}],52:[function(e,t,r){t.exports=function(e,t){var r,n,i;if(Array.isArray(e)){r=[];n=e.length}else{i=Object.keys(e);r={};n=i.length}function o(e,i,o){r[e]=o;if(--n===0||i){t&&t(i,r);t=null}}if(!n){t&&t(null,r);t=null}else if(i){i.forEach(function(t){e[t](o.bind(undefined,t))})}else{e.forEach(function(e,t){e(o.bind(undefined,t))})}}},{}],53:[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:54}],54:[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:{})},{}],55:[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":56}],56:[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:57}],57:[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"}},{}],58:[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:59,wrappy:60}],59:[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:18}],60:[function(e,t,r){arguments[4][48][0].apply(r,arguments)},{dup:48}],61:[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:67}],62:[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}},{}],63:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],64:[function(e,t,r){arguments[4][46][0].apply(r,arguments)},{dup:46,inherits:65,stream:30}],65:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],66:[function(e,t,r){arguments[4][48][0].apply(r,arguments)},{dup:48}],67:[function(e,t,r){arguments[4][49][0].apply(r,arguments)},{dup:49,wrappy:66}],68:[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{infoHash: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:11,"magnet-uri":69,"parse-torrent-file":74}],69:[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:11,flatten:70,"thirty-two":71,xtend:73}],70:[function(e,t,r){arguments[4][45][0].apply(r,arguments)},{dup:45}],71:[function(e,t,r){var n=e("./thirty-two");r.encode=n.encode;r.decode=n.decode},{"./thirty-two":72}],72:[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:11}],73:[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}},{}],74:[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(e.info.length,"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:75,buffer:11,path:17,"simple-sha1":79}],75:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./lib/decode":76,"./lib/encode":78,dup:35}],76:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{"./dict":77,buffer:11,dup:36}],77:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{dup:37}],78:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{buffer:11,dup:38}],79:[function(e,t,r){arguments[4][53][0].apply(r,arguments)},{dup:53,rusha:80}],80:[function(e,t,r){arguments[4][54][0].apply(r,arguments)},{dup:54}],81:[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];r.forEach(function(r){e.on(r,function(){var e=[].slice.call(arguments);e.unshift(r);t.emit.apply(t,e)})})}function o(e,t){var r=new n;i(e,r,t);return r}},{events:15}],82:[function(e,t,r){arguments[4][52][0].apply(r,arguments)},{dup:52}],83:[function(e,t,r){arguments[4][53][0].apply(r,arguments)},{dup:53,rusha:84}],84:[function(e,t,r){arguments[4][54][0].apply(r,arguments)},{dup:54}],85:[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}}},{}],86:[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},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(r.browser&&(!t.announce||t.announce.length===0)){console.warn("Warning: specify a tracker server to discover peers. "+"Required in browser because DHT is not implemented yet. "+"(You can use wss://tracker.webtorrent.io.)")}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};e.tracker=r.browser?new u(e.peerId,t,{rtcConfig:e.rtcConfig}):new u(e.peerId,e.port,t);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:18,"bittorrent-dht/client":10,"bittorrent-tracker/client":92,debug:87,events:15,inherits:90,"re-emitter":91,"xtend/mutable":118}],87:[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=window.localStorage;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())},{"./debug":88}],88:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{dup:56,ms:89}],89:[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+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|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"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"h":return r*o;case"minutes":case"minute":case"m":return r*i;case"seconds":case"second":case"s":return r*n;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"}},{}],90:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],91:[function(e,t,r){arguments[4][81][0].apply(r,arguments)},{dup:81,events:15}],92:[function(e,t,r){(function(r){t.exports=h;var n=e("debug")("webtorrent-tracker");var i=e("events").EventEmitter;var o=e("xtend");var s=e("hat");var a=e("inherits");var f=e("simple-peer");var u=e("simple-websocket");var c=15;a(h,i);var l={};function h(e,t,o){var s=this;if(!(s instanceof h))return new h(e,t,o);i.call(s);s._opts=o||{};s._peerId=r.isBuffer(e)?e:new r(e,"hex");s._infoHash=r.isBuffer(t.infoHash)?t.infoHash:new r(t.infoHash,"hex");s.torrentLength=t.length;s._numWant=s._opts.numWant||c;s._intervalMs=s._opts.interval||30*60*1e3;n("new client %s",s._infoHash.toString("hex"));if(typeof t.announce==="string")t.announce=[t.announce];s._trackers=(t.announce||[]).filter(function(e){return e.indexOf("ws://")===0||e.indexOf("wss://")===0}).map(function(e){return new d(s,e,s._opts)})}h.prototype.start=function(e){var t=this;t._trackers.forEach(function(t){t.start(e)})};h.prototype.stop=function(e){var t=this;t._trackers.forEach(function(t){t.stop(e)})};h.prototype.complete=function(e){var t=this;t._trackers.forEach(function(t){t.complete(e)})};h.prototype.update=function(e){var t=this;t._trackers.forEach(function(t){t.update(e)})};h.prototype.setInterval=function(e){var t=this;t._intervalMs=e;t._trackers.forEach(function(t){t.setInterval(e)})};a(d,i);function d(e,t,r){var o=this;i.call(o);o._opts=r||{};o._announceUrl=t;o._peers={};n("new tracker %s",t);o.client=e;o.ready=false;o._socket=null;o._intervalMs=o.client._intervalMs;o._interval=null}d.prototype.start=function(e){var t=this;e=e||{};e.event="started";n("sent `start` %s %s",t._announceUrl,JSON.stringify(e));t._announce(e);t.setInterval(t._intervalMs)};d.prototype.stop=function(e){var t=this;e=e||{};e.event="stopped";n("sent `stop` %s %s",t._announceUrl,JSON.stringify(e));t._announce(e);t.setInterval(0)};d.prototype.complete=function(e){var t=this;e=e||{};e.event="completed";e.downloaded=e.downloaded||t.torrentLength||0;n("sent `complete` %s %s",t._announceUrl,JSON.stringify(e));t._announce(e)};d.prototype.update=function(e){var t=this;e=e||{};n("sent `update` %s %s",t._announceUrl,JSON.stringify(e));t._announce(e)};d.prototype._init=function(e){var t=this;if(e)t.once("ready",e);if(t._socket)return;if(l[t._announceUrl]){t._socket=l[t._announceUrl];t._onSocketReady()}else{t._socket=l[t._announceUrl]=new u(t._announceUrl);t._socket.on("ready",t._onSocketReady.bind(t))}t._socket.on("warning",t._onSocketWarning.bind(t));t._socket.on("error",t._onSocketWarning.bind(t));t._socket.on("message",t._onSocketMessage.bind(t))};d.prototype._onSocketReady=function(){var e=this;e.ready=true;e.emit("ready")};d.prototype._onSocketWarning=function(e){n("tracker warning %s",e.message)};d.prototype._onSocketMessage=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;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 a;if(e.offer){a=new f({trickle:false,config:t._opts.rtcConfig});a.id=p(e.peer_id);a.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)});a.signal(e.offer);t.client.emit("peer",a)}if(e.answer){a=t._peers[e.offer_id];if(a){a.id=p(e.peer_id);a.signal(e.answer);t.client.emit("peer",a)}else{n("got unexpected answer: "+JSON.stringify(e.answer))}}};d.prototype._announce=function(e){var t=this;if(!t.ready)return t._init(t._announce.bind(t,e));t._generateOffers(function(r){e=o({uploaded:0,downloaded:0,info_hash:t.client._infoHash.toString("binary"),peer_id:t.client._peerId.toString("binary"),offers:r},e);if(t.client.torrentLength!=null&&e.left==null){e.left=t.client.torrentLength-(e.downloaded||0)}if(t._trackerId){e.trackerid=t._trackerId}t._send(e)})};d.prototype._send=function(e){var t=this;n("send %s",JSON.stringify(e));t._socket.send(e)};d.prototype._generateOffers=function(e){var t=this;var r=[];n("generating %s offers",t.client._numWant);for(var i=0;i<t.client._numWant;++i){o()}function o(){var e=s(160);var n=t._peers[e]=new f({initiator:true,trickle:false,config:t._opts.rtcConfig});n.once("signal",function(t){r.push({offer:t,offer_id:e});a()})}function a(){if(r.length===t.client._numWant){n("generated %s offers",t.client._numWant);e(r)}}};d.prototype.setInterval=function(e){var t=this;clearInterval(t._interval);t._intervalMs=e;if(e){t._interval=setInterval(t.update.bind(t),t._intervalMs)}};function p(e){return new r(e,"binary").toString("hex")}}).call(this,e("buffer").Buffer)},{buffer:11,debug:93,events:15,hat:96,inherits:97,"simple-peer":98,"simple-websocket":113,xtend:117}],93:[function(e,t,r){arguments[4][55][0].apply(r,arguments)},{"./debug":94,dup:55}],94:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{dup:56,ms:95}],95:[function(e,t,r){arguments[4][57][0].apply(r,arguments)},{dup:57}],96:[function(e,t,r){arguments[4][62][0].apply(r,arguments)},{dup:62}],97:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],98:[function(e,t,r){(function(r){t.exports=g;var n=e("debug")("simple-peer");var i=e("dezalgo");var o=e("xtend/mutable");var s=e("hat");var a=e("inherits");var f=e("is-typedarray");var u=e("once");var c=e("stream");var l=e("typedarray-to-buffer");var h=typeof window!=="undefined"&&(window.mozRTCPeerConnection||window.RTCPeerConnection||window.webkitRTCPeerConnection);var d=typeof window!=="undefined"&&(window.mozRTCSessionDescription||window.RTCSessionDescription||window.webkitRTCSessionDescription);var p=typeof window!=="undefined"&&(window.mozRTCIceCandidate||window.RTCIceCandidate||window.webkitRTCIceCandidate);a(g,c.Duplex);function g(e){var t=this;if(!(t instanceof g))return new g(e);if(!e)e={};e.allowHalfOpen=false;c.Duplex.call(t,e);o(t,{initiator:false,stream:false,config:g.config,constraints:g.constraints,channelName:e&&e.initiator?s(160):null,trickle:true},e);t._debug("new peer (initiator: %s)",t.initiator);t.destroyed=false;t.connected=false;t._pcReady=false;t._channelReady=false;t._iceComplete=false;t._channel=null;t._buffer=[];t._pc=new h(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._setupVideo(t.stream);t._pc.onaddstream=t._onAddStream.bind(t);if(t.initiator){t._setupData({channel:t._pc.createDataChannel(t.channelName)});t._pc.onnegotiationneeded=u(t._createOffer.bind(t));if(window.mozRTCPeerConnection){setTimeout(function(){t._pc.onnegotiationneeded()},0)}}else{t._pc.ondatachannel=t._setupData.bind(t)}t.on("finish",function(){if(t.connected){t.destroy()}else{t.once("connect",function(){setTimeout(function(){t.destroy()},100)})}})}g.config={iceServers:[{url:"stun:23.21.150.121",urls:"stun:23.21.150.121"}]};g.constraints={};g.prototype.send=function(e,t){var r=this;if(t)t=i(t);else t=m;r._write(e,undefined,t)};g.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 d(e),function(){if(t._pc.remoteDescription.type==="offer")t._createAnswer()},t._onError.bind(t))}if(e.candidate){try{t._pc.addIceCandidate(new p(e.candidate),m,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"))}};g.prototype.destroy=function(e,t){var r=this;if(r.destroyed)return;if(typeof e==="function"){t=e;e=null}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;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;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")};g.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)};g.prototype._setupVideo=function(e){var t=this;t._pc.addStream(e)};g.prototype._read=function(){};g.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._channelReady){i._debug("_write before ready: length %d",o);i._buffer.push(e);n(null);return}i._debug("_write: length %d",o);if(f.strict(e)||e instanceof ArrayBuffer||typeof e==="string"||r.Blob&&e instanceof r.Blob){i._channel.send(e)}else{i._channel.send(JSON.stringify(e))}n(null)};g.prototype._createOffer=function(){var e=this;if(e.destroyed)return;e._pc.createOffer(function(t){if(e.destroyed)return;v(t);e._pc.setLocalDescription(t,m,e._onError.bind(e));var r=function(){e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e))};g.prototype._createAnswer=function(){var e=this;if(e.destroyed)return;e._pc.createAnswer(function(t){if(e.destroyed)return;v(t);e._pc.setLocalDescription(t,m,e._onError.bind(e));var r=function(){e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e))};g.prototype._onIceConnectionStateChange=function(){var e=this;if(e.destroyed)return;var t=e._pc.iceGatheringState;var r=e._pc.iceConnectionState;e.emit("iceConnectionStateChange",t,r);e._debug("iceConnectionStateChange %s %s",t,r);if(r==="connected"||r==="completed"){e._pcReady=true;e._maybeReady()}if(r==="disconnected"||r==="closed"){e.destroy()}};g.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady);if(!e.connected&&e._pcReady&&e._channelReady){e.connected=true;e._buffer.forEach(function(t){e.send(t)});e._buffer=[];e._debug("connect");e.emit("connect")}};g.prototype._onSignalingStateChange=function(){var e=this;if(e.destroyed)return;e.emit("signalingStateChange",e._pc.signalingState);e._debug("signalingStateChange %s",e._pc.signalingState)};g.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")}};g.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=l(new Uint8Array(r));t.push(r)}else{try{r=JSON.parse(r)}catch(n){}t.emit("data",r)}};g.prototype._onChannelOpen=function(){var e=this;if(e.destroyed)return;e._debug("on channel open");e._channelReady=true;e._maybeReady()};g.prototype._onChannelClose=function(){var e=this;if(e.destroyed)return;e._debug("on channel close");e.destroy()};g.prototype._onAddStream=function(e){var t=this;if(t.destroyed)return;t._debug("on add stream");t.emit("stream",e.stream)};g.prototype._onError=function(e){var t=this;if(t.destroyed)return;t._debug("error %s",e.message||e);t.destroy(e)};g.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 v(e){var t=e.sdp.split("b=AS:30");if(t.length>1)e.sdp=t[0]+"b=AS:1638400"+t[1]}function m(){}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{debug:99,dezalgo:102,hat:105,inherits:106,"is-typedarray":107,once:109,stream:30,"typedarray-to-buffer":110,"xtend/mutable":112}],99:[function(e,t,r){arguments[4][55][0].apply(r,arguments)},{"./debug":100,dup:55}],100:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{dup:56,ms:101}],101:[function(e,t,r){arguments[4][57][0].apply(r,arguments)},{dup:57}],102:[function(e,t,r){arguments[4][58][0].apply(r,arguments)},{asap:103,dup:58,wrappy:104}],103:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{_process:18,dup:59}],104:[function(e,t,r){arguments[4][48][0].apply(r,arguments)},{dup:48}],105:[function(e,t,r){arguments[4][62][0].apply(r,arguments)},{dup:62}],106:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],107:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{dup:43}],108:[function(e,t,r){arguments[4][48][0].apply(r,arguments)},{dup:48}],109:[function(e,t,r){arguments[4][49][0].apply(r,arguments)},{dup:49,wrappy:108}],110:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{buffer:11,dup:42,"is-typedarray":111}],111:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{dup:43}],112:[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}},{}],113:[function(e,t,r){t.exports=a;var n=e("events").EventEmitter;var i=e("inherits");var o=e("once");var s=5e3;i(a,n);function a(e,t){if(!(this instanceof a))return new a(e,t);n.call(this);if(!t)t={};this._url=e;this._reconnect=t.reconnect!==undefined?t.reconnect:s;this._init()}a.prototype.send=function(e){if(this._ws&&this._ws.readyState===WebSocket.OPEN){if(typeof e==="object")e=JSON.stringify(e);this._ws.send(e)}};a.prototype.destroy=function(e){if(e)this.once("close",e);try{this._ws.close()}catch(t){this._onclose()}};a.prototype._init=function(){this._errored=false;this._ws=new WebSocket(this._url);this._ws.onopen=this._onopen.bind(this);this._ws.onmessage=this._onmessage.bind(this);this._ws.onclose=this._onclose.bind(this);this._ws.onerror=o(this._onerror.bind(this))};a.prototype._onopen=function(){this.emit("ready")};a.prototype._onerror=function(e){this._errored=true;this.destroy();if(this._reconnect){this._timeout=setTimeout(this._init.bind(this),this._reconnect);this.emit("warning",e)}else{this.emit("error",e)}};a.prototype._onmessage=function(e){var t=e.data;try{t=JSON.parse(e.data)}catch(r){}this.emit("message",t)};a.prototype._onclose=function(){clearTimeout(this._timeout);if(this._ws){this._ws.onopen=null;this._ws.onerror=null;this._ws.onmessage=null;this._ws.onclose=null}this._ws=null;if(!this._errored)this.emit("close")}},{events:15,inherits:114,once:116}],114:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],115:[function(e,t,r){arguments[4][48][0].apply(r,arguments)},{dup:48}],116:[function(e,t,r){arguments[4][49][0].apply(r,arguments)},{dup:49,wrappy:115}],117:[function(e,t,r){arguments[4][73][0].apply(r,arguments)},{dup:73}],118:[function(e,t,r){arguments[4][112][0].apply(r,arguments)},{dup:112}],119:[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:120,bitfield:124,buffer:11,events:15,inherits:125,"simple-sha1":126}],120:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./lib/decode":121,"./lib/encode":123,dup:35}],121:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{"./dict":122,buffer:11,dup:36}],122:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{dup:37}],123:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{buffer:11,dup:38}],124:[function(e,t,r){arguments[4][6][0].apply(r,arguments)},{buffer:11,dup:6}],125:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],126:[function(e,t,r){arguments[4][53][0].apply(r,arguments)},{dup:53,rusha:127}],127:[function(e,t,r){arguments[4][54][0].apply(r,arguments)},{dup:54}],128:[function(e,t,r){(function(r){t.exports=h;var n=e("debug")("webtorrent-swarm");var i=e("events").EventEmitter;var o=e("inherits");var s=e("once");var a=e("speedometer");var f=e("bittorrent-protocol");var u=30;var c=25e3;function l(e,t,r){this.swarm=e;this.stream=t;this.id=r;var n=this.wire=new f;this.timeout=null;this.handshaked=false;this.paused=true;var i=s(function(){if(this.handshaked)this.swarm.wires.splice(this.swarm.wires.indexOf(this.wire),1);this.destroy();this.swarm._drain();this.swarm._peers[this.id]=null}.bind(this));t.once("end",i);t.once("error",i);t.once("close",i);t.once("finish",i);n.once("end",i);n.once("close",i);n.once("error",i);n.once("finish",i);n.on("handshake",this._onHandshake.bind(this));t.pipe(n).pipe(t)}l.prototype.destroy=function(){n("peer destroy");if(this.stream)this.stream.destroy();if(this.wire)this.wire.destroy();if(this.timeout)clearTimeout(this.timeout);this.stream=null;this.wire=null;this.timeout=null};l.prototype.handshake=function(){this.paused=false;this.wire.handshake(this.swarm.infoHash,this.swarm.peerId,this.swarm.handshake);n("sent handshake i %s p %s",this.swarm.infoHashHex,this.swarm.peerIdHex);if(!this.handshaked){this.timeout=setTimeout(function(){this.destroy()}.bind(this),c)}};l.prototype._onHandshake=function(e){var t=e.toString("hex");n("got handshake %s",t);if(this.swarm.destroyed||t!==this.swarm.infoHashHex){return this.destroy()}this.handshaked=true;clearTimeout(this.timeout);this.wire.on("download",function(e){this.swarm.downloaded+=e;this.swarm.downloadSpeed(e);this.swarm.emit("download",e)}.bind(this));this.wire.on("upload",function(e){this.swarm.uploaded+=e;this.swarm.uploadSpeed(e);this.swarm.emit("upload",e)}.bind(this));this.swarm.wires.push(this.wire);this.swarm.emit("wire",this.wire)};o(h,i);function h(e,t,o){if(!(this instanceof h))return new h(e,t,o);i.call(this);if(!o)o={};this.infoHash=typeof e==="string"?new r(e,"hex"):e;this.infoHashHex=this.infoHash.toString("hex");this.peerId=typeof t==="string"?new r(t,"hex"):t;this.peerIdHex=this.peerId.toString("hex");n("new swarm i %s p %s",this.infoHashHex,this.peerIdHex);this.handshake=o.handshake;this.maxPeers=o.maxPeers||u;this.downloaded=0;this.uploaded=0;this.downloadSpeed=a();this.uploadSpeed=a();this.wires=[];this._queue=[];this._peers={};this.paused=false;this.destroyed=false}Object.defineProperty(h.prototype,"ratio",{get:function(){if(this.downloaded===0)return 0;else return this.uploaded/this.downloaded}});Object.defineProperty(h.prototype,"numQueued",{get:function(){return this._queue.length}});Object.defineProperty(h.prototype,"numPeers",{get:function(){return this.wires.length}});h.prototype.addPeer=function(e){if(this.destroyed)return;if(this._peers[e.id])return;var t=new l(this,e,e.id);this._peers[e.id]=t;this._queue.push(t);this._drain()};h.prototype.pause=function(){n("pause");this.paused=true};h.prototype.resume=function(){n("resume");this.paused=false;this._drain()};h.prototype.removePeer=function(e){n("removePeer %s",e);this._removePeer(e);this._drain()};h.prototype._removePeer=function(e){n("_removePeer %s",e);e.destroy()};h.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;if(e)this.once("close",e);n("destroy");for(var t in this._peers){this._removePeer(t)}this.emit("close")};h.prototype._drain=function(){if(this.paused||this.destroyed||this.numPeers>=this.maxPeers)return;n("drain %s queued %s peers %s max",this.numQueued,this.numPeers,this.maxPeers);var e=this._queue.shift();if(e){e.handshake()}}}).call(this,e("buffer").Buffer)},{"bittorrent-protocol":129,buffer:11,debug:141,events:15,inherits:144,once:146,speedometer:147}],129:[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){this._clearTimeout();this._timeoutMs=e;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)};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:130,bitfield:134,buffer:11,debug:135,inherits:138,speedometer:139,stream:30,xtend:140}],130:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./lib/decode":131,"./lib/encode":133,dup:35}],131:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{"./dict":132,buffer:11,dup:36}],132:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{dup:37}],133:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{buffer:11,dup:38}],134:[function(e,t,r){arguments[4][6][0].apply(r,arguments)},{buffer:11,dup:6}],135:[function(e,t,r){arguments[4][87][0].apply(r,arguments)},{"./debug":136,dup:87}],136:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{dup:56,ms:137}],137:[function(e,t,r){arguments[4][89][0].apply(r,arguments)},{dup:89}],138:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],139:[function(e,t,r){arguments[4][85][0].apply(r,arguments)},{dup:85}],140:[function(e,t,r){arguments[4][73][0].apply(r,arguments)},{dup:73}],141:[function(e,t,r){arguments[4][87][0].apply(r,arguments)},{"./debug":142,dup:87}],142:[function(e,t,r){arguments[4][56][0].apply(r,arguments)},{dup:56,ms:143}],143:[function(e,t,r){arguments[4][89][0].apply(r,arguments)},{dup:89}],144:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],145:[function(e,t,r){arguments[4][48][0].apply(r,arguments)},{dup:48}],146:[function(e,t,r){arguments[4][49][0].apply(r,arguments)},{dup:49,wrappy:145}],147:[function(e,t,r){arguments[4][85][0].apply(r,arguments)},{dup:85}],148:[function(e,t,r){arguments[4][73][0].apply(r,arguments)},{dup:73}],149:[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+""}},{}],150:[function(e,t,r){(function(r,n){t.exports=w;var i=e("create-torrent");var o=e("debug")("webtorrent");var s=e("bittorrent-dht/client");var a=e("events").EventEmitter;var f=e("xtend");var u=e("hat");var c=e("inherits");var l=e("load-ip-set");var h=e("run-parallel");var d=e("parse-torrent");var p=e("speedometer");var g=e("zero-fill");var v=e("./lib/fs-storage");var m=e("./lib/storage");var y=e("./lib/torrent");c(w,a);var _=(e("./package.json").version||"0.29.3").match(/([0-9]+)/g).slice(0,2).map(g(2)).join("");function w(e){var t=this;if(!(t instanceof w))return new w(e);if(!e)e={};a.call(t);if(!o.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.torrents=[];t.downloadSpeed=p();t.uploadSpeed=p();t.storage=typeof e.storage==="function"?e.storage:e.storage!==false&&typeof v==="function"?v:m;t.peerId=e.peerId===undefined?new n("-WW"+_+"-"+u(48),"utf8"):typeof e.peerId==="string"?new n(e.peerId,"hex"):e.peerId;t.peerIdHex=t.peerId.toString("hex");t.nodeId=e.nodeId===undefined?new n(u(160),"hex"):typeof e.nodeId==="string"?new n(e.nodeId,"hex"):e.nodeId;t.nodeIdHex=t.nodeId.toString("hex");if(e.dht!==false&&typeof s==="function"){t.dht=new s(f({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}o("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof l==="function"){l(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;i()})}else r.nextTick(i);function i(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(w.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}});w.prototype.get=function(e){var t=this;var r=d(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};w.prototype.add=w.prototype.download=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");o("add");if(typeof t==="function"){r=t;t={}}if(!t)t={};t.client=n;t.storage=t.storage||n.storage;if(!t.storageOpts)t.storageOpts={};if(t.tmp)t.storageOpts.tmp=t.tmp;var i=new y(e,t);n.torrents.push(i);function s(e){if(i.infoHash===e.infoHash){r(i);n.removeListener("torrent",s)}}if(r)n.on("torrent",s);i.on("error",function(e){n.emit("error",e,i)});i.on("listening",function(e){n.emit("listening",e,i)});i.on("ready",function(){o("torrent");n.emit("torrent",i)});return i};w.prototype.seed=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");o("seed");if(typeof t==="function"){r=t;t={}}if(!t)t={};if(!t.storageOpts)t.storageOpts={};t.storageOpts.noVerify=true;i.parseInput(e,t,function(o,s){if(o)return n.emit("error",o);var a=s.map(function(e){return e.getStream});i(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)})}h(t,function(t){if(t)return n.emit("error",t);if(r)r(e);n.emit("seed",e)})})})})};w.prototype.remove=function(e,t){var r=this;var n=r.get(e);if(!n)throw new Error("No torrent with id "+e);o("remove");r.torrents.splice(r.torrents.indexOf(n),1);n.destroy(t)};w.prototype.destroy=function(e){var t=this;t.destroyed=true;o("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)})}h(r,e)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/fs-storage":10,"./lib/storage":4,"./lib/torrent":5,"./package.json":10,_process:18,"bittorrent-dht/client":10,buffer:11,"create-torrent":34,debug:55,events:15,hat:62,inherits:63,"load-ip-set":10,"parse-torrent":68,"run-parallel":82,speedometer:85,xtend:148,"zero-fill":149}]},{},[150])(150)}); \ No newline at end of file
+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":37,buffer:11}],37:[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}},{}],38:[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:11}],39:[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:11,"is-typedarray":40}],40:[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)]}},{}],41:[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:53,stream:30,"typedarray-to-buffer":39}],42:[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)}},[])}}},{}],43:[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":44}],44:[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}},{}],45:[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":46}],46:[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:47}],47:[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"}},{}],48:[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:49,wrappy:50}],49:[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:18}],50:[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}}},{}],51:[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:56}],52:[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}},{}],53:[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}}},{}],54:[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:53,stream:30}],55:[function(e,t,r){arguments[4][50][0].apply(r,arguments)},{dup:50}],56:[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:55}],57:[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{infoHash: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:11,"magnet-uri":58,"parse-torrent-file":62}],58:[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:11,flatten:59,"thirty-two":60,xtend:89}],59:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{dup:42}],60:[function(e,t,r){var n=e("./thirty-two");r.encode=n.encode;r.decode=n.decode},{"./thirty-two":61}],61:[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:11}],62:[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(e.info.length,"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:63,buffer:11,path:17,"simple-sha1":69}],63:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./lib/decode":64,"./lib/encode":66,dup:35}],64:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{"./dict":65,buffer:11,dup:36}],65:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{dup:37}],66:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{buffer:11,dup:38}],67:[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];r.forEach(function(r){e.on(r,function(){var e=[].slice.call(arguments);e.unshift(r);t.emit.apply(t,e)})})}function o(e,t){var r=new n;i(e,r,t);return r}},{events:15}],68:[function(e,t,r){t.exports=function(e,t){var r,n,i;if(Array.isArray(e)){r=[];n=e.length}else{i=Object.keys(e);r={};n=i.length}function o(e,i,o){r[e]=o;if(--n===0||i){t&&t(i,r);t=null}}if(!n){t&&t(null,r);t=null}else if(i){i.forEach(function(t){e[t](o.bind(undefined,t))})}else{e.forEach(function(e,t){e(o.bind(undefined,t))})}}},{}],69:[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:70}],70:[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:{})},{}],71:[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}}},{}],72:[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},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(r.browser&&(!t.announce||t.announce.length===0)){console.warn("Warning: specify a tracker server to discover peers. "+"Required in browser because DHT is not implemented yet. "+"(You can use wss://tracker.webtorrent.io.)")}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};e.tracker=r.browser?new u(e.peerId,t,{rtcConfig:e.rtcConfig}):new u(e.peerId,e.port,t);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:18,"bittorrent-dht/client":10,"bittorrent-tracker/client":73,debug:45,events:15,inherits:53,"re-emitter":67,"xtend/mutable":90}],73:[function(e,t,r){(function(r){t.exports=h;var n=e("debug")("webtorrent-tracker");var i=e("events").EventEmitter;var o=e("xtend");var s=e("hat");var a=e("inherits");var f=e("simple-peer");var u=e("simple-websocket");var c=15;a(h,i);var l={};function h(e,t,o){var s=this;if(!(s instanceof h))return new h(e,t,o);i.call(s);s._opts=o||{};s._peerId=r.isBuffer(e)?e:new r(e,"hex");s._infoHash=r.isBuffer(t.infoHash)?t.infoHash:new r(t.infoHash,"hex");s.torrentLength=t.length;s._numWant=s._opts.numWant||c;s._intervalMs=s._opts.interval||30*60*1e3;n("new client %s",s._infoHash.toString("hex"));if(typeof t.announce==="string")t.announce=[t.announce];s._trackers=(t.announce||[]).filter(function(e){return e.indexOf("ws://")===0||e.indexOf("wss://")===0}).map(function(e){return new d(s,e,s._opts)})}h.prototype.start=function(e){var t=this;t._trackers.forEach(function(t){t.start(e)})};h.prototype.stop=function(e){var t=this;t._trackers.forEach(function(t){t.stop(e)})};h.prototype.complete=function(e){var t=this;t._trackers.forEach(function(t){
+t.complete(e)})};h.prototype.update=function(e){var t=this;t._trackers.forEach(function(t){t.update(e)})};h.prototype.setInterval=function(e){var t=this;t._intervalMs=e;t._trackers.forEach(function(t){t.setInterval(e)})};a(d,i);function d(e,t,r){var o=this;i.call(o);o._opts=r||{};o._announceUrl=t;o._peers={};n("new tracker %s",t);o.client=e;o.ready=false;o._socket=null;o._intervalMs=o.client._intervalMs;o._interval=null}d.prototype.start=function(e){var t=this;e=e||{};e.event="started";n("sent `start` %s %s",t._announceUrl,JSON.stringify(e));t._announce(e);t.setInterval(t._intervalMs)};d.prototype.stop=function(e){var t=this;e=e||{};e.event="stopped";n("sent `stop` %s %s",t._announceUrl,JSON.stringify(e));t._announce(e);t.setInterval(0)};d.prototype.complete=function(e){var t=this;e=e||{};e.event="completed";e.downloaded=e.downloaded||t.torrentLength||0;n("sent `complete` %s %s",t._announceUrl,JSON.stringify(e));t._announce(e)};d.prototype.update=function(e){var t=this;e=e||{};n("sent `update` %s %s",t._announceUrl,JSON.stringify(e));t._announce(e)};d.prototype._init=function(e){var t=this;if(e)t.once("ready",e);if(t._socket)return;if(l[t._announceUrl]){t._socket=l[t._announceUrl];t._onSocketReady()}else{t._socket=l[t._announceUrl]=new u(t._announceUrl);t._socket.on("ready",t._onSocketReady.bind(t))}t._socket.on("warning",t._onSocketWarning.bind(t));t._socket.on("error",t._onSocketWarning.bind(t));t._socket.on("message",t._onSocketMessage.bind(t))};d.prototype._onSocketReady=function(){var e=this;e.ready=true;e.emit("ready")};d.prototype._onSocketWarning=function(e){n("tracker warning %s",e.message)};d.prototype._onSocketMessage=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;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 a;if(e.offer){a=new f({trickle:false,config:t._opts.rtcConfig});a.id=p(e.peer_id);a.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)});a.signal(e.offer);t.client.emit("peer",a)}if(e.answer){a=t._peers[e.offer_id];if(a){a.id=p(e.peer_id);a.signal(e.answer);t.client.emit("peer",a)}else{n("got unexpected answer: "+JSON.stringify(e.answer))}}};d.prototype._announce=function(e){var t=this;if(!t.ready)return t._init(t._announce.bind(t,e));t._generateOffers(function(r){e=o({uploaded:0,downloaded:0,info_hash:t.client._infoHash.toString("binary"),peer_id:t.client._peerId.toString("binary"),offers:r},e);if(t.client.torrentLength!=null&&e.left==null){e.left=t.client.torrentLength-(e.downloaded||0)}if(t._trackerId){e.trackerid=t._trackerId}t._send(e)})};d.prototype._send=function(e){var t=this;n("send %s",JSON.stringify(e));t._socket.send(e)};d.prototype._generateOffers=function(e){var t=this;var r=[];n("generating %s offers",t.client._numWant);for(var i=0;i<t.client._numWant;++i){o()}function o(){var e=s(160);var n=t._peers[e]=new f({initiator:true,trickle:false,config:t._opts.rtcConfig});n.once("signal",function(t){r.push({offer:t,offer_id:e});a()})}function a(){if(r.length===t.client._numWant){n("generated %s offers",t.client._numWant);e(r)}}};d.prototype.setInterval=function(e){var t=this;clearInterval(t._interval);t._intervalMs=e;if(e){t._interval=setInterval(t.update.bind(t),t._intervalMs)}};function p(e){return new r(e,"binary").toString("hex")}}).call(this,e("buffer").Buffer)},{buffer:11,debug:45,events:15,hat:52,inherits:53,"simple-peer":74,"simple-websocket":77,xtend:89}],74:[function(e,t,r){(function(r){t.exports=g;var n=e("debug")("simple-peer");var i=e("dezalgo");var o=e("xtend/mutable");var s=e("hat");var a=e("inherits");var f=e("is-typedarray");var u=e("once");var c=e("stream");var l=e("typedarray-to-buffer");var h=typeof window!=="undefined"&&(window.mozRTCPeerConnection||window.RTCPeerConnection||window.webkitRTCPeerConnection);var d=typeof window!=="undefined"&&(window.mozRTCSessionDescription||window.RTCSessionDescription||window.webkitRTCSessionDescription);var p=typeof window!=="undefined"&&(window.mozRTCIceCandidate||window.RTCIceCandidate||window.webkitRTCIceCandidate);a(g,c.Duplex);function g(e){var t=this;if(!(t instanceof g))return new g(e);if(!e)e={};e.allowHalfOpen=false;c.Duplex.call(t,e);o(t,{initiator:false,stream:false,config:g.config,constraints:g.constraints,channelName:e&&e.initiator?s(160):null,trickle:true},e);t._debug("new peer (initiator: %s)",t.initiator);t.destroyed=false;t.connected=false;t._pcReady=false;t._channelReady=false;t._iceComplete=false;t._channel=null;t._buffer=[];t._pc=new h(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._setupVideo(t.stream);t._pc.onaddstream=t._onAddStream.bind(t);if(t.initiator){t._setupData({channel:t._pc.createDataChannel(t.channelName)});t._pc.onnegotiationneeded=u(t._createOffer.bind(t));if(window.mozRTCPeerConnection){setTimeout(function(){t._pc.onnegotiationneeded()},0)}}else{t._pc.ondatachannel=t._setupData.bind(t)}t.on("finish",function(){if(t.connected){t._destroy()}else{t.once("connect",function(){setTimeout(function(){t._destroy()},100)})}})}g.config={iceServers:[{url:"stun:23.21.150.121",urls:"stun:23.21.150.121"}]};g.constraints={};g.prototype.send=function(e,t){var r=this;if(t)t=i(t);else t=m;r._write(e,undefined,t)};g.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 d(e),function(){if(t._pc.remoteDescription.type==="offer")t._createAnswer()},t._onError.bind(t))}if(e.candidate){try{t._pc.addIceCandidate(new p(e.candidate),m,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"))}};g.prototype.destroy=function(e){var t=this;t._destroy(null,e)};g.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;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;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")};g.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)};g.prototype._setupVideo=function(e){var t=this;t._pc.addStream(e)};g.prototype._read=function(){};g.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._channelReady){i._debug("_write before ready: length %d",o);i._buffer.push(e);n(null);return}i._debug("_write: length %d",o);if(f.strict(e)||e instanceof ArrayBuffer||typeof e==="string"||r.Blob&&e instanceof r.Blob){i._channel.send(e)}else{i._channel.send(JSON.stringify(e))}n(null)};g.prototype._createOffer=function(){var e=this;if(e.destroyed)return;e._pc.createOffer(function(t){if(e.destroyed)return;v(t);e._pc.setLocalDescription(t,m,e._onError.bind(e));var r=function(){e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e))};g.prototype._createAnswer=function(){var e=this;if(e.destroyed)return;e._pc.createAnswer(function(t){if(e.destroyed)return;v(t);e._pc.setLocalDescription(t,m,e._onError.bind(e));var r=function(){e.emit("signal",e._pc.localDescription||t)};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e))};g.prototype._onIceConnectionStateChange=function(){var e=this;if(e.destroyed)return;var t=e._pc.iceGatheringState;var r=e._pc.iceConnectionState;e.emit("iceConnectionStateChange",t,r);e._debug("iceConnectionStateChange %s %s",t,r);if(r==="connected"||r==="completed"){e._pcReady=true;e._maybeReady()}if(r==="disconnected"||r==="closed"){e._destroy()}};g.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady);if(!e.connected&&e._pcReady&&e._channelReady){e.connected=true;e._buffer.forEach(function(t){e.send(t)});e._buffer=[];e._debug("connect");e.emit("connect")}};g.prototype._onSignalingStateChange=function(){var e=this;if(e.destroyed)return;e.emit("signalingStateChange",e._pc.signalingState);e._debug("signalingStateChange %s",e._pc.signalingState)};g.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")}};g.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=l(new Uint8Array(r));t.push(r)}else{try{r=JSON.parse(r)}catch(n){}t.emit("data",r)}};g.prototype._onChannelOpen=function(){var e=this;if(e.destroyed)return;e._debug("on channel open");e._channelReady=true;e._maybeReady()};g.prototype._onChannelClose=function(){var e=this;if(e.destroyed)return;e._debug("on channel close");e._destroy()};g.prototype._onAddStream=function(e){var t=this;if(t.destroyed)return;t._debug("on add stream");t.emit("stream",e.stream)};g.prototype._onError=function(e){var t=this;if(t.destroyed)return;t._debug("error %s",e.message||e);t._destroy(e)};g.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 v(e){var t=e.sdp.split("b=AS:30");if(t.length>1)e.sdp=t[0]+"b=AS:1638400"+t[1]}function m(){}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{debug:45,dezalgo:48,hat:52,inherits:53,"is-typedarray":75,once:56,stream:30,"typedarray-to-buffer":76,"xtend/mutable":90}],75:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{dup:40}],76:[function(e,t,r){arguments[4][39][0].apply(r,arguments)},{buffer:11,dup:39,"is-typedarray":75}],77:[function(e,t,r){t.exports=a;var n=e("events").EventEmitter;var i=e("inherits");var o=e("once");var s=5e3;i(a,n);function a(e,t){if(!(this instanceof a))return new a(e,t);n.call(this);if(!t)t={};this._url=e;this._reconnect=t.reconnect!==undefined?t.reconnect:s;this._init()}a.prototype.send=function(e){if(this._ws&&this._ws.readyState===WebSocket.OPEN){if(typeof e==="object")e=JSON.stringify(e);this._ws.send(e)}};a.prototype.destroy=function(e){if(e)this.once("close",e);try{this._ws.close()}catch(t){this._onclose()}};a.prototype._init=function(){this._errored=false;this._ws=new WebSocket(this._url);this._ws.onopen=this._onopen.bind(this);this._ws.onmessage=this._onmessage.bind(this);this._ws.onclose=this._onclose.bind(this);this._ws.onerror=o(this._onerror.bind(this))};a.prototype._onopen=function(){this.emit("ready")};a.prototype._onerror=function(e){this._errored=true;this.destroy();if(this._reconnect){this._timeout=setTimeout(this._init.bind(this),this._reconnect);this.emit("warning",e)}else{this.emit("error",e)}};a.prototype._onmessage=function(e){var t=e.data;try{t=JSON.parse(e.data)}catch(r){}this.emit("message",t)};a.prototype._onclose=function(){clearTimeout(this._timeout);if(this._ws){this._ws.onopen=null;this._ws.onerror=null;this._ws.onmessage=null;this._ws.onclose=null}this._ws=null;if(!this._errored)this.emit("close")}},{events:15,inherits:53,once:56}],78:[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:79,bitfield:6,buffer:11,events:15,inherits:53,"simple-sha1":69}],79:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./lib/decode":80,"./lib/encode":82,dup:35}],80:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{"./dict":81,buffer:11,dup:36}],81:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{dup:37}],82:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{buffer:11,dup:38}],83:[function(e,t,r){(function(r){t.exports=h;var n=e("debug")("webtorrent-swarm");var i=e("events").EventEmitter;var o=e("inherits");var s=e("once");var a=e("speedometer");var f=e("bittorrent-protocol");var u=30;var c=25e3;function l(e,t,r){this.swarm=e;this.stream=t;this.id=r;var n=this.wire=new f;this.timeout=null;this.handshaked=false;this.paused=true;var i=s(function(){if(this.handshaked)this.swarm.wires.splice(this.swarm.wires.indexOf(this.wire),1);this.destroy();this.swarm._drain();this.swarm._peers[this.id]=null}.bind(this));t.once("end",i);t.once("error",i);t.once("close",i);t.once("finish",i);n.once("end",i);n.once("close",i);n.once("error",i);n.once("finish",i);n.on("handshake",this._onHandshake.bind(this));t.pipe(n).pipe(t)}l.prototype.destroy=function(){n("peer destroy");if(this.stream)this.stream.destroy();if(this.wire)this.wire.destroy();if(this.timeout)clearTimeout(this.timeout);this.stream=null;this.wire=null;this.timeout=null};l.prototype.handshake=function(){this.paused=false;this.wire.handshake(this.swarm.infoHash,this.swarm.peerId,this.swarm.handshake);n("sent handshake i %s p %s",this.swarm.infoHashHex,this.swarm.peerIdHex);if(!this.handshaked){this.timeout=setTimeout(function(){this.destroy()}.bind(this),c)}};l.prototype._onHandshake=function(e){var t=e.toString("hex");n("got handshake %s",t);if(this.swarm.destroyed||t!==this.swarm.infoHashHex){return this.destroy()}this.handshaked=true;clearTimeout(this.timeout);this.wire.on("download",function(e){this.swarm.downloaded+=e;this.swarm.downloadSpeed(e);this.swarm.emit("download",e)}.bind(this));this.wire.on("upload",function(e){this.swarm.uploaded+=e;this.swarm.uploadSpeed(e);this.swarm.emit("upload",e)}.bind(this));this.swarm.wires.push(this.wire);this.swarm.emit("wire",this.wire)};o(h,i);function h(e,t,o){if(!(this instanceof h))return new h(e,t,o);i.call(this);if(!o)o={};this.infoHash=typeof e==="string"?new r(e,"hex"):e;this.infoHashHex=this.infoHash.toString("hex");this.peerId=typeof t==="string"?new r(t,"hex"):t;this.peerIdHex=this.peerId.toString("hex");n("new swarm i %s p %s",this.infoHashHex,this.peerIdHex);this.handshake=o.handshake;this.maxPeers=o.maxPeers||u;this.downloaded=0;this.uploaded=0;this.downloadSpeed=a();this.uploadSpeed=a();this.wires=[];this._queue=[];this._peers={};this.paused=false;this.destroyed=false}Object.defineProperty(h.prototype,"ratio",{get:function(){if(this.downloaded===0)return 0;else return this.uploaded/this.downloaded}});Object.defineProperty(h.prototype,"numQueued",{get:function(){return this._queue.length}});Object.defineProperty(h.prototype,"numPeers",{get:function(){return this.wires.length}});h.prototype.addPeer=function(e){if(this.destroyed)return;if(this._peers[e.id])return;var t=new l(this,e,e.id);this._peers[e.id]=t;this._queue.push(t);this._drain()};h.prototype.pause=function(){n("pause");this.paused=true};h.prototype.resume=function(){n("resume");this.paused=false;this._drain()};h.prototype.removePeer=function(e){n("removePeer %s",e);this._removePeer(e);this._drain()};h.prototype._removePeer=function(e){n("_removePeer %s",e);e.destroy()};h.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;if(e)this.once("close",e);n("destroy");for(var t in this._peers){this._removePeer(t)}this.emit("close")};h.prototype._drain=function(){if(this.paused||this.destroyed||this.numPeers>=this.maxPeers)return;n("drain %s queued %s peers %s max",this.numQueued,this.numPeers,this.maxPeers);var e=this._queue.shift();if(e){e.handshake()}}}).call(this,e("buffer").Buffer)},{"bittorrent-protocol":84,buffer:11,debug:45,events:15,inherits:53,once:56,speedometer:71}],84:[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){this._clearTimeout();this._timeoutMs=e;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)};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:85,bitfield:6,buffer:11,debug:45,inherits:53,speedometer:71,stream:30,xtend:89}],85:[function(e,t,r){arguments[4][35][0].apply(r,arguments)},{"./lib/decode":86,"./lib/encode":88,dup:35}],86:[function(e,t,r){arguments[4][36][0].apply(r,arguments)},{"./dict":87,buffer:11,dup:36}],87:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{dup:37}],88:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{buffer:11,dup:38}],89:[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}},{}],90:[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}},{}],91:[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+""}},{}],92:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.29.4",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,"bittorrent-swarm":"webtorrent-swarm","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":"^1.0.0","block-stream":"0.0.7",clivas:"^0.1.4","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":"^2.0.1",ut_metadata:"^2.1.0",ut_pex:"^1.0.1","webtorrent-swarm":"0.x","windows-no-runnable":"0.0.6",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^3.1.2",brfs:"^1.2.0",browserify:"^9.0.3","run-auto":"^1.0.0",standard:"^3.1.1",tape:"^3.0.3","uglify-js":"^2.4.15",zelda:"^2.0.0",zuul:"^2.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",start:"node ./bin/cmd.js",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"},testling:{files:"test/basic.js"}}},{}],93:[function(e,t,r){(function(r,n){t.exports=w;var i=e("create-torrent");var o=e("debug")("webtorrent");var s=e("bittorrent-dht/client");var a=e("events").EventEmitter;var f=e("xtend");var u=e("hat");var c=e("inherits");var l=e("load-ip-set");var h=e("run-parallel");var d=e("parse-torrent");var p=e("speedometer");var g=e("zero-fill");var v=e("./lib/fs-storage");var m=e("./lib/storage");var y=e("./lib/torrent");c(w,a);var _=e("./package.json").version.match(/([0-9]+)/g).slice(0,2).map(g(2)).join("");function w(e){var t=this;if(!(t instanceof w))return new w(e);if(!e)e={};a.call(t);if(!o.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.torrents=[];t.downloadSpeed=p();t.uploadSpeed=p();t.storage=typeof e.storage==="function"?e.storage:e.storage!==false&&typeof v==="function"?v:m;t.peerId=e.peerId===undefined?new n("-WW"+_+"-"+u(48),"utf8"):typeof e.peerId==="string"?new n(e.peerId,"hex"):e.peerId;t.peerIdHex=t.peerId.toString("hex");t.nodeId=e.nodeId===undefined?new n(u(160),"hex"):typeof e.nodeId==="string"?new n(e.nodeId,"hex"):e.nodeId;t.nodeIdHex=t.nodeId.toString("hex");if(e.dht!==false&&typeof s==="function"){t.dht=new s(f({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}o("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof l==="function"){l(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;i()})}else r.nextTick(i);function i(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(w.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}});w.prototype.get=function(e){var t=this;var r=d(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};w.prototype.add=w.prototype.download=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");o("add");if(typeof t==="function"){r=t;t={}}if(!t)t={};t.client=n;t.storage=t.storage||n.storage;if(!t.storageOpts)t.storageOpts={};if(t.tmp)t.storageOpts.tmp=t.tmp;var i=new y(e,t);n.torrents.push(i);function s(e){if(i.infoHash===e.infoHash){r(i);n.removeListener("torrent",s)}}if(r)n.on("torrent",s);i.on("error",function(e){n.emit("error",e,i)});i.on("listening",function(e){n.emit("listening",e,i)});i.on("ready",function(){o("torrent");n.emit("torrent",i)});return i};w.prototype.seed=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");o("seed");if(typeof t==="function"){r=t;t={}}if(!t)t={};if(!t.storageOpts)t.storageOpts={};t.storageOpts.noVerify=true;i.parseInput(e,t,function(o,s){if(o)return n.emit("error",o);var a=s.map(function(e){return e.getStream});i(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)})}h(t,function(t){if(t)return n.emit("error",t);if(r)r(e);n.emit("seed",e)})})})})};w.prototype.remove=function(e,t){var r=this;var n=r.get(e);if(!n)throw new Error("No torrent with id "+e);o("remove");r.torrents.splice(r.torrents.indexOf(n),1);n.destroy(t)};w.prototype.destroy=function(e){var t=this;t.destroyed=true;o("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)})}h(r,e)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/fs-storage":10,"./lib/storage":4,"./lib/torrent":5,"./package.json":92,_process:18,"bittorrent-dht/client":10,buffer:11,"create-torrent":34,debug:45,events:15,hat:52,inherits:53,"load-ip-set":10,"parse-torrent":57,"run-parallel":68,speedometer:71,xtend:89,"zero-fill":91}]},{},[93])(93)}); \ No newline at end of file