diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2015-01-16 09:41:02 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2015-01-16 09:41:02 +0300 |
commit | a72e2b704d8044d649028a3e5602cc877036cae0 (patch) | |
tree | 68fb4ceb7874e45bf837ad9ebc2ca48f4b9a11a3 /webtorrent.min.js | |
parent | 7392ab5c94fe9fb86b3e09927341fcd633529d92 (diff) |
build
Diffstat (limited to 'webtorrent.min.js')
-rw-r--r-- | webtorrent.min.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/webtorrent.min.js b/webtorrent.min.js index 945ff71..fc911b1 100644 --- a/webtorrent.min.js +++ b/webtorrent.min.js @@ -1,5 +1,5 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.WebTorrent=e()}}(function(){return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t){function n(e,t){var i=this;if(!(i instanceof n))return new n(e,t);s.Readable.call(i,t),r("new filestream %s",JSON.stringify(t)),t||(t={}),t.start||(t.start=0),t.end||(t.end=e.length-1),i.length=t.end-t.start+1;var a=t.start+e.offset,u=t.pieceLength;i.startPiece=a/u|0,i.endPiece=(t.end+e.offset)/u|0,i._extname=o.extname(e.name),i._storage=e.storage,i._piece=i.startPiece,i._missing=i.length,i._reading=!1,i._notifying=!1,i._destroyed=!1,i._criticalLength=Math.min(1048576/u|0,2),i._offset=a-i.startPiece*u}t.exports=n;var r=e("debug")("webtorrent:file-stream"),i=e("inherits"),o=e("path"),s=e("stream"),a=e("./video-stream");i(n,s.Readable),n.prototype._read=function(){r("_read");var e=this;e._reading||(e._reading=!0,e.notify())},n.prototype.notify=function(){r("notify");var e=this;if(e._reading&&0!==e._missing){if(!e._storage.bitfield.get(e._piece))return e._storage.emit("critical",e._piece,e._piece+e._criticalLength);if(!e._notifying){e._notifying=!0;var t=e._piece;r("before read %s",t),e._storage.read(e._piece++,function(n,i){if(r("after read %s (buffer.length %s) (err %s)",t,i.length,n&&n.message||n),e._notifying=!1,!e._destroyed){if(n)return e._storage.emit("error",n),e.destroy(n);e._offset&&(i=i.slice(e._offset),e._offset=0),e._missing<i.length&&(i=i.slice(0,e._missing)),e._missing-=i.length,r("pushing buffer of length %s",i.length),e._reading=!1,e.push(i),0===e._missing&&e.push(null)}})}}},n.prototype.pipe=function(e){var t=this,n=s.Readable.prototype.pipe;if(e&&"VIDEO"===e.nodeName){var r=".webm"===t._extname?'video/webm; codecs="vorbis,vp8"':".mp4"===t._extname?'video/mp4; codecs="avc1.42c01e,mp4a.40.2"':void 0;return n.call(t,new a(e,{type:r}))}return n.call(t,e)},n.prototype.destroy=function(){var e=this;e._destroyed||(e._destroyed=!0)}},{"./video-stream":5,debug:44,inherits:53,path:17,stream:30}],2:[function(e,t){function n(e,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)})}var r=this;r.swarm=e,r.numPieces=t,r.swarm.wires.forEach(n),r.swarm.on("wire",function(e){r.recalculate(),n(e)}),r.recalculate()}t.exports=n,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 n=0;n<e.numPieces;++n)e.pieces[n]+=t.peerPieces.get(n)})},n.prototype.getRarestPiece=function(e){var t=this,n=[],r=1/0;e=e||function(){return!0};for(var i=0;i<t.numPieces;++i)if(e(i)){var o=t.pieces[i];o===r?n.push(i):r>o&&(n=[i],r=o)}return n.length>0?n[Math.random()*n.length|0]:-1}},{}],3:[function(e,t){(function(n,r){function i(){}function o(e,t,n,r){var i=this;d.call(i),f.enabled||i.setMaxListeners(0),i.index=e,i.hash=t,i.noVerify=!!r,"number"==typeof n?(i.buffer=null,i.length=n):(i.buffer=n,i.length=n.length),i._reset()}function s(e,t,n,r){var i=this;d.call(i),f.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=n,i.pieceLength=r,i.done=!1,i.pieces.forEach(function(e){e.on("done",function(){i._checkDone()})}),i._checkDone()}function a(e,t){var n=this;d.call(n),f.enabled||n.setMaxListeners(0),t=t||{},n.bitfield=new u(e.pieces.length),n.done=!1,n.closed=!1,n.readonly=!0,t.nobuffer||(n.buffer=new r(e.length));var i=n.pieceLength=e.pieceLength,a=e.lastPieceLength,c=e.pieces.length;n.pieces=e.pieces.map(function(e,r){var s=r*i,u=s+(r===c-1?a:i),f=n.buffer?n.buffer.slice(s,u):u-s,h=new o(r,e,f,!!t.noVerify);return h.on("done",n._onPieceDone.bind(n,h)),h}),n.files=e.files.map(function(e){var t=e.offset,r=t+e.length-1,o=t/i|0,a=r/i|0,u=n.pieces.slice(o,a+1),c=new s(n,e,u,i);return c.on("done",n._onFileDone.bind(n,c)),c})}t.exports=a;var u=e("bitfield"),c=e("block-stream"),f=e("debug")("webtorrent:storage"),h=e("dezalgo"),l=e("end-of-stream"),d=e("events").EventEmitter,p=e("extend.js"),g=e("./file-stream"),m=e("inherits"),y=e("multistream"),v=e("once"),_=e("simple-sha1"),w=16384,b=0,k=1,E=2;m(o,d),o.prototype.readBlock=function(e,t,n){var r=this;return n=h(n),r.buffer&&r._verifyOffset(e)?void n(null,r.buffer.slice(e,e+t)):n(new Error("invalid block offset "+e))},o.prototype.writeBlock=function(e,t,n){var r=this;if(n=h(n),!r._verifyOffset(e)||!r._verifyBlock(e,t))return n(new Error("invalid block "+e+":"+t.length));r._lazyAllocBuffer();var i=e/w;return r.blocks[i]===E?n(null):(t.copy(r.buffer,e),r.blocks[i]=E,r.blocksWritten+=1,r.blocksWritten===r.blocks.length&&r.verify(),void n(null))},o.prototype.reserveBlock=function(e){for(var t=this,n=t.blocks.length,r=0;n>r;r++)if((!t.blocks[r]||e)&&t.blocks[r]!==E)return t.blocks[r]=k,{offset:r*w,length:r===n-1?t.length-r*w:w};return null},o.prototype.cancelBlock=function(e){var t=this;if(!t.buffer||!t._verifyOffset(e))return!1;var n=e/w;return t.blocks[n]===k&&(t.blocks[n]=b),!0},o.prototype._reset=function(){var e=this;e.verified=!1,e.blocks=new r(Math.ceil(e.length/w)),e.blocks.fill(0),e.blocksWritten=0},o.prototype.verify=function(e){function t(){n.verified?n.emit("done"):(n.emit("warning",new Error("piece "+n.index+" failed verification; "+r+" expected "+n.hash)),n._reset())}var n=this;if(e=e||n.buffer,!n.verified&&e){if(n.noVerify)return n.verified=!0,void t();var r;_(e,function(e){r=e,n.verified=r===n.hash,t()})}},o.prototype._verifyOffset=function(e){var t=this;return e%w===0?!0:(t.emit("warning",new Error("piece "+t.index+" invalid offset "+e+" not multiple of "+w+" bytes")),!1)},o.prototype._verifyBlock=function(e,t){var n=this;return t.length===w?!0:t.length===n.length-e&&n.length-e<w?!0:(n.emit("warning",new Error("piece "+n.index+" invalid block of size "+t.length+" bytes")),!1)},o.prototype._lazyAllocBuffer=function(){var e=this;e.buffer||(e.buffer=new r(e.length))},m(s,d),s.prototype.select=function(){var e=this;e.pieces.length>0&&e.storage.emit("select",e.pieces[0].index,e.pieces[e.pieces.length-1].index,!1)},s.prototype.deselect=function(){var e=this;e.pieces.length>0&&e.storage.emit("deselect",e.pieces[0].index,e.pieces[e.pieces.length-1].index,!1)},s.prototype.createReadStream=function(e){var t=this;e=p({pieceLength:t.pieceLength},e);var n=new g(t,e);return t.storage.emit("select",n.startPiece,n.endPiece,!0,n.notify.bind(n)),l(n,function(){t.storage.emit("deselect",n.startPiece,n.endPiece,!0)}),n},s.prototype.getBlobURL=function(e){var t=this;t.getBuffer(function(t,n){if(t)return e(t);var r=URL.createObjectURL(new Blob([n]));e(null,r)})},s.prototype.getBuffer=function(e){var t=this,n=new r(t.length),i=0;t.createReadStream().on("data",function(e){e.copy(n,i),i+=e.length}).on("end",function(){e(null,n)})},s.prototype._checkDone=function(){var e=this;e.done=e.pieces.every(function(e){return e.verified}),e.done&&n.nextTick(function(){e.emit("done")})},m(a,d),a.BLOCK_LENGTH=w,a.prototype.load=function(e,t){var n=this;Array.isArray(e)||(e=[e]),t=v(t||function(){}),n.once("done",function(){t(null)});var r=0;new y(e).pipe(new c(n.pieceLength,{nopad:!0})).on("data",function(e){var t=r;r+=1;var i=0,o=new c(w,{nopad:!0});o.on("data",function(e){var r=i*w;i+=1,n.writeBlock(t,r,e)}),o.end(e)}).on("error",t)},Object.defineProperty(a.prototype,"downloaded",{get:function(){var e=this;return e.pieces.reduce(function(e,t){return e+(t.verified?t.length:t.blocksWritten*w)},0)}}),Object.defineProperty(a.prototype,"numMissing",{get:function(){for(var e=this,t=e.pieces.length,n=0,r=e.pieces.length;r>n;n++)t-=e.bitfield.get(n);return t}}),a.prototype.readBlock=function(e,t,n,r){var i=this;r=h(r);var o=i.pieces[e];return o?void o.readBlock(t,n,r):r(new Error("invalid piece index "+e))},a.prototype.writeBlock=function(e,t,n,r){var o=this;if(r||(r=i),r=h(r),o.readonly)return r(new Error("cannot write to readonly storage"));var s=o.pieces[e];return s?void s.writeBlock(t,n,r):r(new Error("invalid piece index "+e))},a.prototype.read=function(e,t,n,i){function o(){if(0>=c)return n(null,r.concat(f));var t=u,i=Math.min(w,c);u+=i,c-=i,s.readBlock(e,t,i,function(e,t){return e?n(e):(f.push(t),void o())})}var s=this;"function"==typeof t&&(i=n,n=t,t=null),n=h(n);var a=s.pieces[e];if(!a)return n(new Error("invalid piece index "+e));if(!a.verified&&!i)return n(new Error("Storage.read called on incomplete piece "+e));var u=0,c=a.length;if(t&&(u=t.offset||0,c=t.length||c),a.buffer)return n(null,a.buffer.slice(u,u+c));var f=[];o()},a.prototype.reserveBlock=function(e,t){var n=this,r=n.pieces[e];return r?r.reserveBlock(t):null},a.prototype.cancelBlock=function(e,t){var n=this,r=n.pieces[e];return r?r.cancelBlock(t):!1},a.prototype.remove=function(e){e&&h(e)(null)},a.prototype.close=function(e){var t=this;t.closed=!0,e&&h(e)(null)},a.prototype._onPieceDone=function(e){var t=this;t.bitfield.set(e.index),f("piece done "+e.index+" ("+t.numMissing+" still missing)"),t.emit("piece",e)},a.prototype._onFileDone=function(e){var t=this;f("file done "+e.name),t.emit("file",e),t._checkDone()},a.prototype._checkDone=function(){var e=this;!e.done&&e.files.every(function(e){return e.done})&&(e.done=!0,e.emit("done"))}}).call(this,e("_process"),e("buffer").Buffer)},{"./file-stream":1,_process:18,bitfield:6,"block-stream":7,buffer:11,debug:44,dezalgo:47,"end-of-stream":50,events:15,"extend.js":51,inherits:53,multistream:54,once:56,"simple-sha1":68}],4:[function(e,t){(function(n){function r(){}function i(e,t){function r(e){i.parsedTorrent=m(e),i.infoHash=i.parsedTorrent.infoHash,i.parsedTorrent.name&&(i.name=i.parsedTorrent.name),i.swarm=new v(i.infoHash,i.client.peerId,{handshake:{dht:!!i.client.dht}}),y(i.swarm,i,["warning","error"]),i.swarm.on("wire",i._onWire.bind(i)),i.swarm.on("download",i.client.downloadSpeed.bind(i.client)),i.swarm.on("upload",i.client.uploadSpeed.bind(i.client)),n.browser?i._onSwarmListening():i.swarm.listen(i.client.torrentPort,i._onSwarmListening.bind(i)),n.nextTick(function(){i.emit("infoHash")})}var i=this;h.call(i),c.enabled||i.setMaxListeners(0),c("new torrent"),i.client=t.client,i.hotswapEnabled="hotswap"in t?t.hotswap:!0,i.verify=t.verify,i.storageOpts=t.storageOpts,i.chokeTimeout=t.chokeTimeout||I,i.pieceTimeout=t.pieceTimeout||S,i.strategy=t.strategy||"sequential",i._rechokeNumSlots=t.uploads===!1||0===t.uploads?0:+t.uploads||10,i._rechokeOptimisticWire=null,i._rechokeOptimisticTime=0,i._rechokeIntervalId=null,i.ready=!1,i.files=[],i.metadata=null,i.parsedTorrent=null,i.storage=null,i.numBlockedPeers=0,i._amInterested=!1,i._destroyed=!1,i._selections=[],i._critical=[],i._storageImpl=t.storage||E;var o=e&&e.parsedTorrent||m(e);if(o&&o.infoHash)r(o);else if("function"==typeof d&&/^https?:/.test(e))d.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,t){return e?i.emit("error",new Error("error downloading torrent: "+e.message)):void r(t)});else{if("function"!=typeof l.readFile)throw new Error("invalid torrent id");l.readFile(e,function(e,t){return e?i.emit("error",new Error("invalid torrent id")):void r(t)})}}function o(e,t){return Math.ceil(2+t*e.downloadSpeed()/E.BLOCK_LENGTH)}function s(e){return Math.random()*e|0}function a(e,t){for(var n=e.map(function(e,t){return t}),r=n.length-1;r>0;--r){var i=s(r+1),o=n[r];n[r]=n[i],n[i]=o}n.forEach(function(n){t(e[n],n,e)})}t.exports=i;var u=e("addr-to-ip-port"),c=e("debug")("webtorrent:torrent"),f=e("torrent-discovery"),h=e("events").EventEmitter,l=e("fs"),d=e("simple-get"),p=e("inherits"),g=e("run-parallel"),m=e("parse-torrent"),y=e("re-emitter"),v=e("bittorrent-swarm"),_=e("ut_metadata"),w=e("ut_pex"),b=e("./rarity-map"),k=e("./server"),E=e("./storage"),x=131072,S=1e4,I=5e3,A=3*E.BLOCK_LENGTH,L=.5,B=1,T=1e4,R=2;p(i,h),Object.defineProperty(i.prototype,"length",{get:function(){return this.parsedTorrent&&this.parsedTorrent.length||0}}),Object.defineProperty(i.prototype,"timeRemaining",{get:function(){return 0===this.swarm.downloadSpeed()?1/0:(this.length-this.downloaded)/this.swarm.downloadSpeed()*1e3}}),Object.defineProperty(i.prototype,"progress",{get:function(){return this.parsedTorrent&&this.downloaded/this.parsedTorrent.length||0}}),Object.defineProperty(i.prototype,"downloaded",{get:function(){return this.storage&&this.storage.downloaded||0}}),Object.defineProperty(i.prototype,"uploaded",{get:function(){return this.swarm.uploaded}}),Object.defineProperty(i.prototype,"ratio",{get:function(){return this.uploaded&&this.downloaded/this.uploaded||0}}),Object.defineProperty(i.prototype,"magnetURI",{get:function(){return m.toMagnetURI(this.parsedTorrent)}}),i.prototype._onSwarmListening=function(e){var t=this;t._destroyed||(t.client.torrentPort=e,t.discovery=new f({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)),y(t.discovery,t,["dhtAnnounce","warning","error"]),t.parsedTorrent.info&&t._onMetadata(t.parsedTorrent),t.emit("listening",e))},i.prototype._onMetadata=function(e){var t=this;if(!t.metadata&&!t._destroyed){if(c("got metadata"),e&&e.infoHash)t.metadata=m.toTorrentFile(e),t.parsedTorrent=e;else{t.metadata=e;try{t.parsedTorrent=m(t.metadata)}catch(r){return t.emit("error",r)}}t.name=t.parsedTorrent.name,t.discovery.setTorrent(t.parsedTorrent),t.rarityMap=new b(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(){t.discovery.tracker&&t.discovery.tracker.complete(),c("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){e.ut_metadata&&e.ut_metadata.setMetadata(t.metadata),t._onWireWithMetadata(e)}),n.nextTick(t.verify?function(){c("verifying existing torrent data");var e=0,n=0;g(t.storage.pieces.map(function(r){return function(i){t.storage.read(r.index,function(o,s){e+=1,t.emit("verifying",{percentDone:100*e/t.storage.pieces.length,percentVerified:100*n/t.storage.pieces.length}),!o&&s&&(r.verify(s),n+=r.verified,c("piece "+(r.verified?"verified":"invalid")+" "+r.index)),i()},!0)}}),t._onStorage.bind(t))}:t._onStorage.bind(t)),n.nextTick(function(){t.emit("metadata")})}},i.prototype.destroy=function(e){var t=this;c("destroy"),t._destroyed=!0,clearInterval(t._rechokeIntervalId);var n=[];t.swarm&&n.push(function(e){t.swarm.destroy(e)}),t.discovery&&n.push(function(e){t.discovery.stop(e)}),t.storage&&n.push(function(e){t.storage.close(e)}),g(n,e)},i.prototype.addPeer=function(e){var t=this;return"string"==typeof e&&t.client.blocked&&t.client.blocked.contains(u(e)[0])?(t.numBlockedPeers+=1,t.emit("blocked-peer",e),!1):(t.emit("peer",e),t.swarm.addPeer(e),!0)},i.prototype.select=function(e,t,n,i){var o=this;if(e>t||0>e||t>=o.storage.pieces.length)throw new Error("invalid selection ",e,":",t);n=Number(n)||0,c("select %s-%s (priority %s)",e,t,n),o._selections.push({from:e,to:t,offset:0,priority:n,notify:i||r}),o._selections.sort(function(e,t){return t.priority-e.priority}),o._updateSelections()},i.prototype.deselect=function(e,t,n){var r=this;n=Number(n)||0,c("deselect %s-%s (priority %s)",e,t,n);for(var i=0;i<r._selections.length;++i){var o=r._selections[i];if(o.from===e&&o.to===t&&o.priority===n){r._selections.splice(i--,1);break}}r._updateSelections()},i.prototype.critical=function(e,t){var n=this;c("critical %s-%s",e,t);for(var r=e;t>=r;++r)n._critical[r]=!0;n._updateSelections()},i.prototype._onWire=function(e){var t=this;e.use(_(t.metadata)),t.metadata||(e.ut_metadata.on("metadata",function(e){c("got metadata via ut_metadata"),t._onMetadata(e)}),e.ut_metadata.fetch()),"function"==typeof w&&e.use(w()),e.ut_pex&&e.ut_pex.on("peer",function(e){c("got peer via ut_pex "+e),t.addPeer(e)}),e.ut_pex&&e.ut_pex.on("dropped",function(e){e in t.swarm._peers||t.swarm.removePeer(e)}),e.setKeepAlive(!0),e.peerExtensions.dht&&t.client.dht&&t.client.dht.port&&e.port(t.client.dht.port),e.on("port",function(){c("port message from "+e.remoteAddress)}),e.on("timeout",function(){c("wire timeout from "+e.remoteAddress),e.destroy()}),e.setTimeout(t.pieceTimeout),t.metadata&&t._onWireWithMetadata(e)},i.prototype._onWireWithMetadata=function(e){function t(){r._destroyed||e._destroyed||(r.swarm.numQueued>2*(r.swarm.numConns-r.swarm.numPeers)&&e.amInterested?e.destroy():i=setTimeout(t,o))}function n(){if(e.peerPieces.length===r.storage.pieces.length){for(;s<r.storage.pieces.length;++s)if(!e.peerPieces.get(s))return;e.isSeeder=!0,e.choke()}}var r=this,i=null,o=r.chokeTimeout,s=0;e.on("bitfield",function(){n(),r._update()}),e.on("have",function(){n(),r._update()}),e.once("interested",function(){e.unchoke()}),e.on("close",function(){clearTimeout(i)}),e.on("choke",function(){clearTimeout(i),i=setTimeout(t,o)}),e.on("unchoke",function(){clearTimeout(i),r._update()}),e.on("request",function(t,n,i,o){return i>x?(c(e.remoteAddress,"requested invalid block size",i),e.destroy()):void r.storage.readBlock(t,n,i,o)}),e.bitfield(r.storage.bitfield),e.interested(),i=setTimeout(t,o),e.isSeeder=!1,n()},i.prototype._onStorage=function(){var e=this;c("on storage"),e.storage.readonly=!1,e.select(0,e.storage.pieces.length-1,!1),e._rechokeIntervalId=setInterval(e._rechoke.bind(e),T),e._rechokeIntervalId.unref&&e._rechokeIntervalId.unref(),n.nextTick(function(){e.ready=!0,e.emit("ready")})},i.prototype._onStoragePiece=function(e){var t=this;c("piece done %s",e.index),t._reservations[e.index]=null,t.swarm.wires.forEach(function(t){t.have(e.index)}),t._gcSelections()},i.prototype._updateSelections=function(){var e=this;if(e.swarm&&!e._destroyed){if(!e.metadata)return e.once("metadata",e._updateSelections.bind(e));n.nextTick(e._gcSelections.bind(e)),e._updateInterest(),e._update()}},i.prototype._gcSelections=function(){for(var e=this,t=0;t<e._selections.length;t++){for(var n=e._selections[t],r=n.offset;e.storage.bitfield.get(n.from+n.offset)&&n.from+n.offset<n.to;)n.offset++;r!==n.offset&&n.notify(),n.to===n.from+n.offset&&e.storage.bitfield.get(n.from+n.offset)&&(e._selections.splice(t--,1),n.notify(),e._updateInterest())}e._selections.length||e.emit("idle")},i.prototype._updateInterest=function(){var e=this,t=e._amInterested;e._amInterested=!!e._selections.length,e.swarm.wires.forEach(function(t){e._amInterested?t.interested():t.uninterested()}),t!==e._amInterested&&e.emit(e._amInterested?"interested":"uninterested")},i.prototype._update=function(){var e=this;e._destroyed||a(e.swarm.wires,e._updateWire.bind(e))},i.prototype._updateWire=function(e){function t(t,n,r,i){return function(o){return o>=t&&n>=o&&!(o in r)&&e.peerPieces.get(o)&&(!i||i(o))}}function n(){if(!e.requests.length)for(var n=a._selections.length;n--;){var r,i=a._selections[n];if("rarest"===a.strategy)for(var o=i.from+i.offset,s=i.to,u=s-o+1,c={},f=0,h=t(o,s,c);u>f&&(r=a.rarityMap.getRarestPiece(h),!(0>r));){if(a._request(e,r,!1))return;c[r]=!0,f+=1}else for(r=i.to;r>=i.from+i.offset;--r)if(e.peerPieces.get(r)&&a._request(e,r,!1))return}}function r(){var t=e.downloadSpeed()||1;if(t>A)return function(){return!0};var n=Math.max(1,e.requests.length)*E.BLOCK_LENGTH/t,r=10,i=0;return function(e){if(!r||a.storage.bitfield.get(e))return!0;for(var o=a.storage.pieces[e],s=o.blocks.length-o.blocksWritten;i<a.swarm.wires.length;i++){var u=a.swarm.wires[i],c=u.downloadSpeed();if(!(A>c||t>=c||!u.peerPieces.get(e)||(s-=c*n)>0))return r--,!1}return!0}}function i(e){for(var t=e,n=e;n<a._selections.length&&a._selections[n].priority;n++)t=n;var r=a._selections[e];a._selections[e]=a._selections[t],a._selections[t]=r}function s(n){if(e.requests.length>=c)return!0;for(var o=r(),s=0;s<a._selections.length;s++){var u,f=a._selections[s];if("rarest"===a.strategy)for(var h=f.from+f.offset,l=f.to,d=l-h+1,p={},g=0,m=t(h,l,p,o);d>g&&(u=a.rarityMap.getRarestPiece(m),!(0>u));){for(;a._request(e,u,a._critical[u]||n););if(!(e.requests.length<c))return f.priority&&i(s),!0;p[u]=!0,g++}else for(u=f.from+f.offset;u<=f.to;u++)if(e.peerPieces.get(u)&&o(u)){for(;a._request(e,u,a._critical[u]||n););if(!(e.requests.length<c))return f.priority&&i(s),!0}}return!1}var a=this;if(!e.peerChoking){if(!e.downloaded)return n();var u=o(e,L);if(!(e.requests.length>=u)){var c=o(e,B);s(!1)||s(!0)}}},i.prototype._rechoke=function(){function e(e,t){return e.downloadSpeed!==t.downloadSpeed?t.downloadSpeed-e.downloadSpeed:e.uploadSpeed!==t.uploadSpeed?t.uploadSpeed-e.uploadSpeed:e.wire.amChoking!==t.wire.amChoking?e.wire.amChoking?1:-1:e.salt-t.salt}var t=this;t._rechokeOptimisticTime>0?t._rechokeOptimisticTime-=1:t._rechokeOptimisticWire=null;var n=[];t.swarm.wires.forEach(function(e){e.isSeeder||e===t._rechokeOptimisticWire||n.push({wire:e,downloadSpeed:e.downloadSpeed(),uploadSpeed:e.uploadSpeed(),salt:Math.random(),isChoked:!0})}),n.sort(e);for(var r=0,i=0;i<n.length&&r<t._rechokeNumSlots;++i)n[i].isChoked=!1,n[i].wire.peerInterested&&(r+=1);if(!t._rechokeOptimisticWire&&i<n.length&&t._rechokeNumSlots){var o=n.slice(i).filter(function(e){return e.wire.peerInterested}),a=o[s(o.length)];a&&(a.isChoked=!1,t._rechokeOptimisticWire=a.wire,t._rechokeOptimisticTime=R)}n.forEach(function(e){e.wire.amChoking!==e.isChoked&&(e.isChoked?e.wire.choke():e.wire.unchoke())})},i.prototype._hotswap=function(e,t){var n=this;if(!n.hotswapEnabled)return!1;var r=e.downloadSpeed();if(r<E.BLOCK_LENGTH)return!1;if(!n._reservations[t])return!1;var i=n._reservations[t];if(!i)return!1;var o,s,a=1/0;for(s=0;s<i.length;s++){var u=i[s];if(u&&u!==e){var c=u.downloadSpeed();c>=A||2*c>r||c>a||(o=u,a=c)}}if(!o)return!1;for(s=0;s<i.length;s++)i[s]===o&&(i[s]=null);for(s=0;s<o.requests.length;s++){var f=o.requests[s];f.piece===t&&n.storage.cancelBlock(t,f.offset)}return n.emit("hotswap",o,e,t),!0},i.prototype._request=function(e,t,r){function i(r,o){return s.ready?(l[d]===e&&(l[d]=null),r?(c("error getting piece "+t+"(offset: "+h.offset+" length: "+h.length+") from "+e.remoteAddress+" "+r.message),s.storage.cancelBlock(t,h.offset),n.nextTick(s._update.bind(s)),!1):void s.storage.writeBlock(t,h.offset,o,function(e){e&&(c("error writing block"),s.storage.cancelBlock(t,h.offset)),n.nextTick(s._update.bind(s))})):void s.once("ready",function(){i(r,o)})}var s=this,a=e.requests.length;if(s.storage.bitfield.get(t))return!1;var u=o(e,B);if(a>=u)return!1;var f=0===e.requests.length&&s.storage.numMissing<30,h=s.storage.reserveBlock(t,f);if(!h&&!f&&r&&s._hotswap(e,t)&&(h=s.storage.reserveBlock(t,!1)),!h)return!1;var l=s._reservations[t];l||(l=s._reservations[t]=[]);var d=l.indexOf(null);return-1===d&&(d=l.length),l[d]=e,e.request(t,h.offset,h.length,i),!0},i.prototype.createServer=function(e){var t=this;return"function"==typeof k?new k(t,e):void 0}}).call(this,e("_process"))},{"./rarity-map":2,"./server":10,"./storage":3,_process:18,"addr-to-ip-port":10,"bittorrent-swarm":81,debug:44,events:15,fs:8,inherits:53,"parse-torrent":57,"re-emitter":66,"run-parallel":67,"simple-get":10,"torrent-discovery":71,ut_metadata:77,ut_pex:10}],5:[function(e,t){function n(e,t){var i=this;if(!(i instanceof n))return new n(e,t);s.Writable.call(i,t),i.video=e,t=t||{},t.type=t.type||'video/webm; codecs="vorbis,vp8"',r("new videostream %s %s",e,JSON.stringify(t)),i._mediaSource=new a,i._playing=!1,i._sourceBuffer=null,i._cb=null,i.video.src=window.URL.createObjectURL(i._mediaSource);var u=o(function(){i._sourceBuffer=i._mediaSource.addSourceBuffer(t.type),i._sourceBuffer.addEventListener("updateend",i._flow.bind(i)),i._flow()});i._mediaSource.addEventListener("webkitsourceopen",u,!1),i._mediaSource.addEventListener("sourceopen",u,!1),i.on("finish",function(){r("finish"),i._mediaSource.endOfStream()}),window.vs=i}t.exports=n;var r=e("debug")("webtorrent:video-stream"),i=e("inherits"),o=e("once"),s=e("stream"),a="undefined"!=typeof window&&(window.MediaSource||window.WebKitMediaSource);i(n,s.Writable),n.prototype._write=function(e,t,n){var i=this;return i._sourceBuffer?i._sourceBuffer.updating?n(new Error("Cannot append buffer while source buffer updating")):(i._sourceBuffer.appendBuffer(e),r("appendBuffer %s",e.length),i._cb=n,void(i._playing||(i.video.play(),i._playing=!0))):void(i._cb=function(r){return r?n(r):void i._write(e,t,n)})},n.prototype._flow=function(){var e=this;r("flow"),e._cb&&e._cb(null)}},{debug:44,inherits:53,once:56,stream:30}],6:[function(e,t){(function(e){function n(e,t){return this instanceof n?(0===arguments.length&&(e=0),this.grow=t&&(isFinite(t.grow)&&r(t.grow)||t.grow)||0,("number"==typeof e||void 0===e)&&(e=new i(r(e)),e.fill&&e.fill(0)),void(this.buffer=e)):new n(e)}function r(e){var t=e>>3;return e%8!==0&&t++,t}var i="undefined"!=typeof e?e:"undefined"!=typeof Int8Array?Int8Array:function(e){for(var t=new Array(e),n=0;e>n;n++)t[n]=0};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 n=e>>3;t||1===arguments.length?(this._grow(n+1),this.buffer[n]|=128>>e%8):n<this.buffer.length&&(this.buffer[n]&=~(128>>e%8))},n.prototype._grow=function(e){if(this.buffer.length<e&&e<=this.grow){var t=new i(e);t.fill&&t.fill(0);for(var n=0;n<this.buffer.length;n++)t[n]=this.buffer[n];this.buffer=t}},"undefined"!=typeof t&&(t.exports=n)}).call(this,e("buffer").Buffer)},{buffer:11}],7:[function(e,t){(function(n,r){function i(e,t){if(this.writable=this.readable=!0,this._opt=t||{},this._chunkSize=e||512,this._offset=0,this._buffer=[],this._bufferLength=0,this._opt.nopad)this._zeroes=!1;else{this._zeroes=new r(this._chunkSize);for(var n=0;n<this._chunkSize;n++)this._zeroes[n]=0}}t.exports=i;{var o=e("stream").Stream,s=e("inherits"),a=e("assert").ok;n.env.DEBUG?console.error:function(){}}s(i,o),i.prototype.write=function(e){if(this._ended)throw new Error("BlockStream: write after end");if(e&&!r.isBuffer(e)&&(e=new r(e+"")),e.length&&(this._buffer.push(e),this._bufferLength+=e.length),this._bufferLength>=this._chunkSize){if(this._paused)return this._needDrain=!0,!1;this._emitChunk()}return!0},i.prototype.pause=function(){this._paused=!0},i.prototype.resume=function(){return this._paused=!1,this._emitChunk()},i.prototype.end=function(e){"function"==typeof e&&(cb=e,e=null),e&&this.write(e),this._ended=!0,this.flush()},i.prototype.flush=function(){this._emitChunk(!0)},i.prototype._emitChunk=function(e){if(e&&this._zeroes){var t=this._bufferLength%this._chunkSize;0!==t&&(t=this._chunkSize-t),t>0&&(this._buffer.push(this._zeroes.slice(0,t)),this._bufferLength+=t)}if(!this._emitting&&!this._paused){this._emitting=!0;for(var n=0;this._bufferLength>=this._chunkSize&&(e||!this._paused);){for(var i,o=0,s=this._chunkSize;s>0&&(e||!this._paused);){var u=this._buffer[n],c=u.length-this._offset;i||s>c?(i=i||new r(this._chunkSize),u.copy(i,o,this._offset,this._offset+Math.min(c,s))):i=u.length===s&&0===this._offset?u:u.slice(this._offset,this._offset+s),c>s?(this._offset+=s,s=0):(s-=c,o+=c,n++,this._offset=0)}this._bufferLength-=this._chunkSize,a(i.length===this._chunkSize),this.emit("data",i),i=null}if(this._buffer=this._buffer.slice(n),this._paused)return this._needsDrain=!0,void(this._emitting=!1);var f=this._buffer.length;if(e&&!this._zeroes&&f){if(1===f)this._offset?this.emit("data",this._buffer[0].slice(this._offset)):this.emit("data",this._buffer[0]);else{for(var s=this._bufferLength,i=new r(s),o=0,h=0;f>h;h++){var u=this._buffer[h],c=u.length-this._offset;u.copy(i,o,this._offset),this._offset=0,o+=c,this._bufferLength-=c}this.emit("data",i)}this._buffer.length=0,this._bufferLength=0,this._offset=0}this._needDrain&&(this._needDrain=!1,this.emit("drain")),0===this._bufferLength&&this._ended&&!this._endEmitted&&(this._endEmitted=!0,this.emit("end")),this._emitting=!1}}}).call(this,e("_process"),e("buffer").Buffer)},{_process:18,assert:9,buffer:11,inherits:53,stream:30}],8:[function(){},{}],9:[function(e,t){function n(e,t){return l.isUndefined(t)?""+t:l.isNumber(t)&&!isFinite(t)?t.toString():l.isFunction(t)||l.isRegExp(t)?t.toString():t}function r(e,t){return l.isString(e)?e.length<t?e:e.slice(0,t):e}function i(e){return r(JSON.stringify(e.actual,n),128)+" "+e.operator+" "+r(JSON.stringify(e.expected,n),128)}function o(e,t,n,r,i){throw new g.AssertionError({message:n,actual:e,expected:t,operator:r,stackStartFunction:i})}function s(e,t){e||o(e,!0,t,"==",g.ok)}function a(e,t){if(e===t)return!0;if(l.isBuffer(e)&&l.isBuffer(t)){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return l.isDate(e)&&l.isDate(t)?e.getTime()===t.getTime():l.isRegExp(e)&&l.isRegExp(t)?e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase:l.isObject(e)||l.isObject(t)?c(e,t):e==t}function u(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function c(e,t){if(l.isNullOrUndefined(e)||l.isNullOrUndefined(t))return!1;if(e.prototype!==t.prototype)return!1;if(l.isPrimitive(e)||l.isPrimitive(t))return e===t;var n=u(e),r=u(t);if(n&&!r||!n&&r)return!1;if(n)return e=d.call(e),t=d.call(t),a(e,t);var i,o,s=m(e),c=m(t);if(s.length!=c.length)return!1;for(s.sort(),c.sort(),o=s.length-1;o>=0;o--)if(s[o]!=c[o])return!1;for(o=s.length-1;o>=0;o--)if(i=s[o],!a(e[i],t[i]))return!1;return!0}function f(e,t){return e&&t?"[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t?!0:t.call({},e)===!0?!0:!1:!1}function h(e,t,n,r){var i;l.isString(n)&&(r=n,n=null);try{t()}catch(s){i=s}if(r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&o(i,n,"Missing expected exception"+r),!e&&f(i,n)&&o(i,n,"Got unwanted exception"+r),e&&i&&n&&!f(i,n)||!e&&i)throw i}var l=e("util/"),d=Array.prototype.slice,p=Object.prototype.hasOwnProperty,g=t.exports=s;g.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=i(this),this.generatedMessage=!0);var t=e.stackStartFunction||o;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,s=t.name,a=r.indexOf("\n"+s);if(a>=0){var u=r.indexOf("\n",a+1);r=r.substring(u+1)}this.stack=r}}},l.inherits(g.AssertionError,Error),g.fail=o,g.ok=s,g.equal=function(e,t,n){e!=t&&o(e,t,n,"==",g.equal)},g.notEqual=function(e,t,n){e==t&&o(e,t,n,"!=",g.notEqual)},g.deepEqual=function(e,t,n){a(e,t)||o(e,t,n,"deepEqual",g.deepEqual)},g.notDeepEqual=function(e,t,n){a(e,t)&&o(e,t,n,"notDeepEqual",g.notDeepEqual)},g.strictEqual=function(e,t,n){e!==t&&o(e,t,n,"===",g.strictEqual)},g.notStrictEqual=function(e,t,n){e===t&&o(e,t,n,"!==",g.notStrictEqual)},g["throws"]=function(){h.apply(this,[!0].concat(d.call(arguments)))},g.doesNotThrow=function(){h.apply(this,[!1].concat(d.call(arguments)))},g.ifError=function(e){if(e)throw e};var m=Object.keys||function(e){var t=[];for(var n in e)p.call(e,n)&&t.push(n);return t}},{"util/":33}],10:[function(e,t,n){arguments[4][8][0].apply(n,arguments)},{dup:8}],11:[function(e,t,n){function r(e,t,n){if(!(this instanceof r))return new r(e,t,n);var i,o=typeof e;if("number"===o)i=e>0?e>>>0:0;else if("string"===o)i=r.byteLength(e,t); -else{if("object"!==o||null===e)throw new TypeError("must start with number, buffer, array or string");"Buffer"===e.type&&O(e.data)&&(e=e.data),i=+e.length>0?Math.floor(+e.length):0}if(i>U)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+U.toString(16)+" bytes");var s;r.TYPED_ARRAY_SUPPORT?s=r._augment(new Uint8Array(i)):(s=this,s.length=i,s._isBuffer=!0);var a;if(r.TYPED_ARRAY_SUPPORT&&"number"==typeof e.byteLength)s._set(e);else if(I(e))if(r.isBuffer(e))for(a=0;i>a;a++)s[a]=e.readUInt8(a);else for(a=0;i>a;a++)s[a]=(e[a]%256+256)%256;else if("string"===o)s.write(e,0,t);else if("number"===o&&!r.TYPED_ARRAY_SUPPORT&&!n)for(a=0;i>a;a++)s[a]=0;return i>0&&i<=r.poolSize&&(s.parent=D),s}function i(e,t,n){if(!(this instanceof i))return new i(e,t,n);var o=new r(e,t,n);return delete o.parent,o}function o(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;r>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[n+s]=a}return s}function s(e,t,n,r){var i=C(L(t,e.length-n),e,n,r);return i}function a(e,t,n,r){var i=C(B(t),e,n,r);return i}function u(e,t,n,r){return a(e,t,n,r)}function c(e,t,n,r){var i=C(R(t),e,n,r);return i}function f(e,t,n,r){var i=C(T(t,e.length-n),e,n,r,2);return i}function h(e,t,n){return j.fromByteArray(0===t&&n===e.length?e:e.slice(t,n))}function l(e,t,n){var r="",i="";n=Math.min(e.length,n);for(var o=t;n>o;o++)e[o]<=127?(r+=M(i)+String.fromCharCode(e[o]),i=""):i+="%"+e[o].toString(16);return r+M(i)}function d(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(127&e[i]);return r}function p(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function g(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=A(e[o]);return i}function m(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function y(e,t,n){if(e%1!==0||0>e)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function v(e,t,n,i,o,s){if(!r.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>o||s>t)throw new RangeError("value is out of bounds");if(n+i>e.length)throw new RangeError("index out of range")}function _(e,t,n,r){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);o>i;i++)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function w(e,t,n,r){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);o>i;i++)e[n+i]=t>>>8*(r?i:3-i)&255}function b(e,t,n,r,i,o){if(t>i||o>t)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function k(e,t,n,r,i){return i||b(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),P.write(e,t,n,r,23,4),n+4}function E(e,t,n,r,i){return i||b(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),P.write(e,t,n,r,52,8),n+8}function x(e){if(e=S(e).replace(z,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function S(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function I(e){return O(e)||r.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function A(e){return 16>e?"0"+e.toString(16):e.toString(16)}function L(e,t){var n,r=e.length,i=null;t=t||1/0;for(var o=[],s=0;r>s;s++){if(n=e.charCodeAt(s),n>55295&&57344>n){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(56320>n){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&((t-=3)>-1&&o.push(239,191,189),i=null);if(128>n){if((t-=1)<0)break;o.push(n)}else if(2048>n){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(2097152>n))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function B(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t}function T(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);s++)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}function R(e){return j.toByteArray(x(e))}function C(e,t,n,r,i){i&&(r-=r%i);for(var o=0;r>o&&!(o+n>=t.length||o>=e.length);o++)t[o+n]=e[o];return o}function M(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}var j=e("base64-js"),P=e("ieee754"),O=e("is-array");n.Buffer=r,n.SlowBuffer=i,n.INSPECT_MAX_BYTES=50,r.poolSize=8192;var U=1073741823,D={};r.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(n){return!1}}(),r.isBuffer=function(e){return!(null==e||!e._isBuffer)},r.compare=function(e,t){if(!r.isBuffer(e)||!r.isBuffer(t))throw new TypeError("Arguments must be Buffers");for(var n=e.length,i=t.length,o=0,s=Math.min(n,i);s>o&&e[o]===t[o];o++);return o!==s&&(n=e[o],i=t[o]),i>n?-1:n>i?1:0},r.isEncoding=function(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!0;default:return!1}},r.concat=function(e,t){if(!O(e))throw new TypeError("Usage: Buffer.concat(list[, length])");if(0===e.length)return new r(0);if(1===e.length)return e[0];var n;if(void 0===t)for(t=0,n=0;n<e.length;n++)t+=e[n].length;var i=new r(t),o=0;for(n=0;n<e.length;n++){var s=e[n];s.copy(i,o),o+=s.length}return i},r.byteLength=function(e,t){var n;switch(e+="",t||"utf8"){case"ascii":case"binary":case"raw":n=e.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*e.length;break;case"hex":n=e.length>>>1;break;case"utf8":case"utf-8":n=L(e).length;break;case"base64":n=R(e).length;break;default:n=e.length}return n},r.prototype.length=void 0,r.prototype.parent=void 0,r.prototype.toString=function(e,t,n){var r=!1;if(t>>>=0,n=void 0===n||1/0===n?this.length:n>>>0,e||(e="utf8"),0>t&&(t=0),n>this.length&&(n=this.length),t>=n)return"";for(;;)switch(e){case"hex":return g(this,t,n);case"utf8":case"utf-8":return l(this,t,n);case"ascii":return d(this,t,n);case"binary":return p(this,t,n);case"base64":return h(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}},r.prototype.equals=function(e){if(!r.isBuffer(e))throw new TypeError("Argument must be a Buffer");return 0===r.compare(this,e)},r.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},r.prototype.compare=function(e){if(!r.isBuffer(e))throw new TypeError("Argument must be a Buffer");return r.compare(this,e)},r.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},r.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},r.prototype.write=function(e,t,n,r){if(isFinite(t))isFinite(n)||(r=n,n=void 0);else{var i=r;r=t,t=n,n=i}if(t=Number(t)||0,0>n||0>t||t>this.length)throw new RangeError("attempt to write outside buffer bounds");var h=this.length-t;n?(n=Number(n),n>h&&(n=h)):n=h,r=String(r||"utf8").toLowerCase();var l;switch(r){case"hex":l=o(this,e,t,n);break;case"utf8":case"utf-8":l=s(this,e,t,n);break;case"ascii":l=a(this,e,t,n);break;case"binary":l=u(this,e,t,n);break;case"base64":l=c(this,e,t,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=f(this,e,t,n);break;default:throw new TypeError("Unknown encoding: "+r)}return l},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),e>t&&(t=e);var i;if(r.TYPED_ARRAY_SUPPORT)i=r._augment(this.subarray(e,t));else{var o=t-e;i=new r(o,void 0,!0);for(var s=0;o>s;s++)i[s]=this[s+e]}return i.length&&(i.parent=this.parent||this),i},r.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||y(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},r.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||y(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},r.prototype.readUInt8=function(e,t){return t||y(e,1,this.length),this[e]},r.prototype.readUInt16LE=function(e,t){return t||y(e,2,this.length),this[e]|this[e+1]<<8},r.prototype.readUInt16BE=function(e,t){return t||y(e,2,this.length),this[e]<<8|this[e+1]},r.prototype.readUInt32LE=function(e,t){return t||y(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},r.prototype.readUInt32BE=function(e,t){return t||y(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},r.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||y(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*t)),r},r.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||y(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},r.prototype.readInt8=function(e,t){return t||y(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},r.prototype.readInt16LE=function(e,t){t||y(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt16BE=function(e,t){t||y(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt32LE=function(e,t){return t||y(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},r.prototype.readInt32BE=function(e,t){return t||y(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},r.prototype.readFloatLE=function(e,t){return t||y(e,4,this.length),P.read(this,e,!0,23,4)},r.prototype.readFloatBE=function(e,t){return t||y(e,4,this.length),P.read(this,e,!1,23,4)},r.prototype.readDoubleLE=function(e,t){return t||y(e,8,this.length),P.read(this,e,!0,52,8)},r.prototype.readDoubleBE=function(e,t){return t||y(e,8,this.length),P.read(this,e,!1,52,8)},r.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||v(this,e,t,n,Math.pow(2,8*n),0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i>>>0&255;return t+n},r.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||v(this,e,t,n,Math.pow(2,8*n),0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o>>>0&255;return t+n},r.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,1,255,0),r.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e,t+1},r.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):_(this,e,t,!0),t+2},r.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):_(this,e,t,!1),t+2},r.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e):w(this,e,t,!0),t+4},r.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):w(this,e,t,!1),t+4},r.prototype.writeIntLE=function(e,t,n,r){e=+e,t>>>=0,r||v(this,e,t,n,Math.pow(2,8*n-1)-1,-Math.pow(2,8*n-1));var i=0,o=1,s=0>e?1:0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=(e/o>>0)-s&255;return t+n},r.prototype.writeIntBE=function(e,t,n,r){e=+e,t>>>=0,r||v(this,e,t,n,Math.pow(2,8*n-1)-1,-Math.pow(2,8*n-1));var i=n-1,o=1,s=0>e?1:0;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=(e/o>>0)-s&255;return t+n},r.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,1,127,-128),r.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=e,t+1},r.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):_(this,e,t,!0),t+2},r.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):_(this,e,t,!1),t+2},r.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,2147483647,-2147483648),r.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):w(this,e,t,!0),t+4},r.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):w(this,e,t,!1),t+4},r.prototype.writeFloatLE=function(e,t,n){return k(this,e,t,!0,n)},r.prototype.writeFloatBE=function(e,t,n){return k(this,e,t,!1,n)},r.prototype.writeDoubleLE=function(e,t,n){return E(this,e,t,!0,n)},r.prototype.writeDoubleBE=function(e,t,n){return E(this,e,t,!1,n)},r.prototype.copy=function(e,t,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&n>i&&(i=n),i===n)return 0;if(0===e.length||0===o.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>n||n>=o.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);var s=i-n;if(1e3>s||!r.TYPED_ARRAY_SUPPORT)for(var a=0;s>a;a++)e[a+t]=this[a+n];else e._set(this.subarray(n,n+s),t);return s},r.prototype.fill=function(e,t,n){if(e||(e=0),t||(t=0),n||(n=this.length),t>n)throw new RangeError("end < start");if(n!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var r;if("number"==typeof e)for(r=t;n>r;r++)this[r]=e;else{var i=L(e.toString()),o=i.length;for(r=t;n>r;r++)this[r]=i[r%o]}return this}},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(r.TYPED_ARRAY_SUPPORT)return new r(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;n>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var H=r.prototype;r._augment=function(e){return e.constructor=r,e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=H.get,e.set=H.set,e.write=H.write,e.toString=H.toString,e.toLocaleString=H.toString,e.toJSON=H.toJSON,e.equals=H.equals,e.compare=H.compare,e.copy=H.copy,e.slice=H.slice,e.readUIntLE=H.readUIntLE,e.readUIntBE=H.readUIntBE,e.readUInt8=H.readUInt8,e.readUInt16LE=H.readUInt16LE,e.readUInt16BE=H.readUInt16BE,e.readUInt32LE=H.readUInt32LE,e.readUInt32BE=H.readUInt32BE,e.readIntLE=H.readIntLE,e.readIntBE=H.readIntBE,e.readInt8=H.readInt8,e.readInt16LE=H.readInt16LE,e.readInt16BE=H.readInt16BE,e.readInt32LE=H.readInt32LE,e.readInt32BE=H.readInt32BE,e.readFloatLE=H.readFloatLE,e.readFloatBE=H.readFloatBE,e.readDoubleLE=H.readDoubleLE,e.readDoubleBE=H.readDoubleBE,e.writeUInt8=H.writeUInt8,e.writeUIntLE=H.writeUIntLE,e.writeUIntBE=H.writeUIntBE,e.writeUInt16LE=H.writeUInt16LE,e.writeUInt16BE=H.writeUInt16BE,e.writeUInt32LE=H.writeUInt32LE,e.writeUInt32BE=H.writeUInt32BE,e.writeIntLE=H.writeIntLE,e.writeIntBE=H.writeIntBE,e.writeInt8=H.writeInt8,e.writeInt16LE=H.writeInt16LE,e.writeInt16BE=H.writeInt16BE,e.writeInt32LE=H.writeInt32LE,e.writeInt32BE=H.writeInt32BE,e.writeFloatLE=H.writeFloatLE,e.writeFloatBE=H.writeFloatBE,e.writeDoubleLE=H.writeDoubleLE,e.writeDoubleBE=H.writeDoubleBE,e.fill=H.fill,e.inspect=H.inspect,e.toArrayBuffer=H.toArrayBuffer,e};var z=/[^+\/0-9A-z\-]/g},{"base64-js":12,ieee754:13,"is-array":14}],12:[function(e,t,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===s||t===h?62:t===a||t===l?63:u>t?-1:u+10>t?t-u+26+26:f+26>t?t-f:c+26>t?t-c+26:void 0}function n(e){function n(e){c[h++]=e}var r,i,s,a,u,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=e.length;u="="===e.charAt(f-2)?2:"="===e.charAt(f-1)?1:0,c=new o(3*e.length/4-u),s=u>0?e.length-4:e.length;var h=0;for(r=0,i=0;s>r;r+=4,i+=3)a=t(e.charAt(r))<<18|t(e.charAt(r+1))<<12|t(e.charAt(r+2))<<6|t(e.charAt(r+3)),n((16711680&a)>>16),n((65280&a)>>8),n(255&a);return 2===u?(a=t(e.charAt(r))<<2|t(e.charAt(r+1))>>4,n(255&a)):1===u&&(a=t(e.charAt(r))<<10|t(e.charAt(r+1))<<4|t(e.charAt(r+2))>>2,n(a>>8&255),n(255&a)),c}function i(e){function t(e){return r.charAt(e)}function n(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,o,s,a=e.length%3,u="";for(i=0,s=e.length-a;s>i;i+=3)o=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u+=n(o);switch(a){case 1:o=e[e.length-1],u+=t(o>>2),u+=t(o<<4&63),u+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1],u+=t(o>>10),u+=t(o>>4&63),u+=t(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0),h="-".charCodeAt(0),l="_".charCodeAt(0);e.toByteArray=n,e.fromByteArray=i}("undefined"==typeof n?this.base64js={}:n)},{}],13:[function(e,t,n){n.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,c=u>>1,f=-7,h=n?i-1:0,l=n?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+e[t+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?0/0:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,h=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,g=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||1/0===t?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+h>=1?l/u:l*Math.pow(2,1-h),t*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(t*u-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[n+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[n+d]=255&s,d+=p,s/=256,c-=8);e[n+d-p]|=128*g}},{}],14:[function(e,t){var n=Array.isArray,r=Object.prototype.toString;t.exports=n||function(e){return!!e&&"[object Array]"==r.call(e)}},{}],15:[function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,i,a,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];n.apply(this,a)}else if(o(n)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(c=n.slice(),i=c.length,u=0;i>u;u++)c[u].apply(this,a)}return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned){var i;i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(a=s;a-->0;)if(n[a]===t||n[a].listener&&n[a].listener===t){i=a;break}if(0>i)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?r(e._events[t])?1:e._events[t].length:0}},{}],16:[function(e,t){t.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},{}],17:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];"."===i?e.splice(r,1):".."===i?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,o=function(e){return i.exec(e).slice(1)};n.resolve=function(){for(var n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,i="/"===s.charAt(0))}return n=t(r(n.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(e){var i=n.isAbsolute(e),o="/"===s(e,-1);return e=t(r(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&o&&(e+="/"),(i?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,function(e){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),s=Math.min(i.length,o.length),a=s,u=0;s>u;u++)if(i[u]!==o[u]){a=u;break}for(var c=[],u=a;u<i.length;u++)c.push("..");return c=c.concat(o.slice(a)),c.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){var t=o(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},n.basename=function(e,t){var n=o(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){return o(e)[3]};var s="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return 0>t&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:18}],18:[function(e,t){function n(){if(!s){s=!0;for(var e,t=o.length;t;){e=o,o=[];for(var n=-1;++n<t;)e[n]();t=o.length}s=!1}}function r(){}var i=t.exports={},o=[],s=!1;i.nextTick=function(e){o.push(e),s||setTimeout(n,0)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.on=r,i.addListener=r,i.once=r,i.off=r,i.removeListener=r,i.removeAllListeners=r,i.emit=r,i.binding=function(){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],19:[function(e,t){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":20}],20:[function(e,t){(function(n){function r(e){return this instanceof r?(u.call(this,e),c.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",i)):new r(e)}function i(){this.allowHalfOpen||this._writableState.ended||n.nextTick(this.end.bind(this))}function o(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}t.exports=r;var s=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},a=e("core-util-is");a.inherits=e("inherits");var u=e("./_stream_readable"),c=e("./_stream_writable");a.inherits(r,u),o(s(c.prototype),function(e){r.prototype[e]||(r.prototype[e]=c.prototype[e])})}).call(this,e("_process"))},{"./_stream_readable":22,"./_stream_writable":24,_process:18,"core-util-is":25,inherits:53}],21:[function(e,t){function n(e){return this instanceof n?void r.call(this,e):new n(e)}t.exports=n;var r=e("./_stream_transform"),i=e("core-util-is");i.inherits=e("inherits"),i.inherits(n,r),n.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":23,"core-util-is":25,inherits:53}],22:[function(e,t){(function(n){function r(t){t=t||{};var n=t.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=!1,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.calledRead=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!t.objectMode,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(L||(L=e("string_decoder/").StringDecoder),this.decoder=new L(t.encoding),this.encoding=t.encoding)}function i(e){return this instanceof i?(this._readableState=new r(e,this),this.readable=!0,void I.call(this)):new i(e)}function o(e,t,n,r,i){var o=c(t,n);if(o)e.emit("error",o);else if(null===n||void 0===n)t.reading=!1,t.ended||f(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else!t.decoder||i||r||(n=t.decoder.write(n)),t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):(t.reading=!1,t.buffer.push(n)),t.needReadable&&h(e),d(e,t);else i||(t.reading=!1);return s(t)}function s(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function a(e){if(e>=B)e=B;else{e--;for(var t=1;32>t;t<<=1)e|=e>>t;e++}return e}function u(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function c(e,t){var n=null;return x.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function f(e,t){if(t.decoder&&!t.ended){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.length>0?h(e):w(e)}function h(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,t.sync?n.nextTick(function(){l(e)}):l(e))}function l(e){e.emit("readable")}function d(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(function(){p(e,t)}))}function p(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function g(e){return function(){var t=e._readableState;t.awaitDrain--,0===t.awaitDrain&&m(e)}}function m(e){function t(e){var t=e.write(n);!1===t&&r.awaitDrain++}var n,r=e._readableState;for(r.awaitDrain=0;r.pipesCount&&null!==(n=e.read());)if(1===r.pipesCount?t(r.pipes,0,null):b(r.pipes,t),e.emit("data",n),r.awaitDrain>0)return;return 0===r.pipesCount?(r.flowing=!1,void(S.listenerCount(e,"data")>0&&v(e))):void(r.ranOut=!0)}function y(){this._readableState.ranOut&&(this._readableState.ranOut=!1,m(this))}function v(e,t){var r=e._readableState;if(r.flowing)throw new Error("Cannot switch to old mode now.");var i=t||!1,o=!1;e.readable=!0,e.pipe=I.prototype.pipe,e.on=e.addListener=I.prototype.on,e.on("readable",function(){o=!0;for(var t;!i&&null!==(t=e.read());)e.emit("data",t);null===t&&(o=!1,e._readableState.needReadable=!0)}),e.pause=function(){i=!0,this.emit("pause")},e.resume=function(){i=!1,o?n.nextTick(function(){e.emit("readable")}):this.read(0),this.emit("resume")},e.emit("readable")}function _(e,t){var n,r=t.buffer,i=t.length,o=!!t.decoder,s=!!t.objectMode;if(0===r.length)return null;if(0===i)n=null;else if(s)n=r.shift();else if(!e||e>=i)n=o?r.join(""):x.concat(r,i),r.length=0;else if(e<r[0].length){var a=r[0];n=a.slice(0,e),r[0]=a.slice(e)}else if(e===r[0].length)n=r.shift();else{n=o?"":new x(e);for(var u=0,c=0,f=r.length;f>c&&e>u;c++){var a=r[0],h=Math.min(e-u,a.length);o?n+=a.slice(0,h):a.copy(n,u,0,h),h<a.length?r[0]=a.slice(h):r.shift(),u+=h}}return n}function w(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");!t.endEmitted&&t.calledRead&&(t.ended=!0,n.nextTick(function(){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}))}function b(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function k(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}t.exports=i;var E=e("isarray"),x=e("buffer").Buffer;i.ReadableState=r;var S=e("events").EventEmitter;S.listenerCount||(S.listenerCount=function(e,t){return e.listeners(t).length});var I=e("stream"),A=e("core-util-is");A.inherits=e("inherits");var L;A.inherits(i,I),i.prototype.push=function(e,t){var n=this._readableState;return"string"!=typeof e||n.objectMode||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new x(e,t),t="")),o(this,n,e,t,!1)},i.prototype.unshift=function(e){var t=this._readableState;return o(this,t,e,"",!0)},i.prototype.setEncoding=function(t){L||(L=e("string_decoder/").StringDecoder),this._readableState.decoder=new L(t),this._readableState.encoding=t};var B=8388608;i.prototype.read=function(e){var t=this._readableState;t.calledRead=!0;var n,r=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return h(this),null;if(e=u(e,t),0===e&&t.ended)return n=null,t.length>0&&t.decoder&&(n=_(e,t),t.length-=n.length),0===t.length&&w(this),n;var i=t.needReadable;return t.length-e<=t.highWaterMark&&(i=!0),(t.ended||t.reading)&&(i=!1),i&&(t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1),i&&!t.reading&&(e=u(r,t)),n=e>0?_(e,t):null,null===n&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),t.ended&&!t.endEmitted&&0===t.length&&w(this),n},i.prototype._read=function(){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,t){function r(e){e===f&&o()}function i(){e.end()}function o(){e.removeListener("close",a),e.removeListener("finish",u),e.removeListener("drain",p),e.removeListener("error",s),e.removeListener("unpipe",r),f.removeListener("end",i),f.removeListener("end",o),(!e._writableState||e._writableState.needDrain)&&p() -}function s(t){c(),e.removeListener("error",s),0===S.listenerCount(e,"error")&&e.emit("error",t)}function a(){e.removeListener("finish",u),c()}function u(){e.removeListener("close",a),c()}function c(){f.unpipe(e)}var f=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1;var l=(!t||t.end!==!1)&&e!==n.stdout&&e!==n.stderr,d=l?i:o;h.endEmitted?n.nextTick(d):f.once("end",d),e.on("unpipe",r);var p=g(f);return e.on("drain",p),e._events&&e._events.error?E(e._events.error)?e._events.error.unshift(s):e._events.error=[s,e._events.error]:e.on("error",s),e.once("close",a),e.once("finish",u),e.emit("pipe",f),h.flowing||(this.on("readable",y),h.flowing=!0,n.nextTick(function(){m(f)})),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,this.removeListener("readable",y),t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,this.removeListener("readable",y),t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var i=k(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,t){var n=I.prototype.on.call(this,e,t);if("data"!==e||this._readableState.flowing||v(this),"readable"===e&&this.readable){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&h(this,r):this.read(0))}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){v(this),this.read(0),this.emit("resume")},i.prototype.pause=function(){v(this,!0),this.emit("pause")},i.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!==i&&void 0!==i)&&(t.objectMode||i&&i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)"function"==typeof e[i]&&"undefined"==typeof this[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return b(o,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(){n&&(n=!1,e.resume())},r},i._fromList=_}).call(this,e("_process"))},{_process:18,buffer:11,"core-util-is":25,events:15,inherits:53,isarray:16,stream:30,"string_decoder/":31}],23:[function(e,t){function n(e,t){this.afterTransform=function(e,n){return r(t,e,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function r(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!==n&&void 0!==n&&e.push(n),i&&i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&e._read(o.highWaterMark)}function i(e){if(!(this instanceof i))return new i(e);s.call(this,e);var t=(this._transformState=new n(e,this),this);this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("finish",function(){"function"==typeof this._flush?this._flush(function(e){o(t,e)}):o(t)})}function o(e,t){if(t)return e.emit("error",t);var n=e._writableState,r=(e._readableState,e._transformState);if(n.length)throw new Error("calling transform done when ws.length != 0");if(r.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}t.exports=i;var s=e("./_stream_duplex"),a=e("core-util-is");a.inherits=e("inherits"),a.inherits(i,s),i.prototype.push=function(e,t){return this._transformState.needTransform=!1,s.prototype.push.call(this,e,t)},i.prototype._transform=function(){throw new Error("not implemented")},i.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},i.prototype._read=function(){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0}},{"./_stream_duplex":20,"core-util-is":25,inherits:53}],24:[function(e,t){(function(n){function r(e,t,n){this.chunk=e,this.encoding=t,this.callback=n}function i(e,t){e=e||{};var n=e.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.objectMode=!!e.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var r=e.decodeStrings===!1;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){d(t,e)},this.writecb=null,this.writelen=0,this.buffer=[],this.errorEmitted=!1}function o(t){var n=e("./_stream_duplex");return this instanceof o||this instanceof n?(this._writableState=new i(t,this),this.writable=!0,void k.call(this)):new o(t)}function s(e,t,r){var i=new Error("write after end");e.emit("error",i),n.nextTick(function(){r(i)})}function a(e,t,r,i){var o=!0;if(!w.isBuffer(r)&&"string"!=typeof r&&null!==r&&void 0!==r&&!t.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s),n.nextTick(function(){i(s)}),o=!1}return o}function u(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new w(t,n)),t}function c(e,t,n,i,o){n=u(t,n,i),w.isBuffer(n)&&(i="buffer");var s=t.objectMode?1:n.length;t.length+=s;var a=t.length<t.highWaterMark;return a||(t.needDrain=!0),t.writing?t.buffer.push(new r(n,i,o)):f(e,t,s,n,i,o),a}function f(e,t,n,r,i,o){t.writelen=n,t.writecb=o,t.writing=!0,t.sync=!0,e._write(r,i,t.onwrite),t.sync=!1}function h(e,t,r,i,o){r?n.nextTick(function(){o(i)}):o(i),e._writableState.errorEmitted=!0,e.emit("error",i)}function l(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function d(e,t){var r=e._writableState,i=r.sync,o=r.writecb;if(l(r),t)h(e,r,i,t,o);else{var s=y(e,r);s||r.bufferProcessing||!r.buffer.length||m(e,r),i?n.nextTick(function(){p(e,r,s,o)}):p(e,r,s,o)}}function p(e,t,n,r){n||g(e,t),r(),n&&v(e,t)}function g(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function m(e,t){t.bufferProcessing=!0;for(var n=0;n<t.buffer.length;n++){var r=t.buffer[n],i=r.chunk,o=r.encoding,s=r.callback,a=t.objectMode?1:i.length;if(f(e,t,a,i,o,s),t.writing){n++;break}}t.bufferProcessing=!1,n<t.buffer.length?t.buffer=t.buffer.slice(n):t.buffer.length=0}function y(e,t){return t.ending&&0===t.length&&!t.finished&&!t.writing}function v(e,t){var n=y(e,t);return n&&(t.finished=!0,e.emit("finish")),n}function _(e,t,r){t.ending=!0,v(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0}t.exports=o;var w=e("buffer").Buffer;o.WritableState=i;var b=e("core-util-is");b.inherits=e("inherits");var k=e("stream");b.inherits(o,k),o.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},o.prototype.write=function(e,t,n){var r=this._writableState,i=!1;return"function"==typeof t&&(n=t,t=null),w.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=function(){}),r.ended?s(this,r,n):a(this,r,e,n)&&(i=c(this,r,e,t,n)),i},o.prototype._write=function(e,t,n){n(new Error("not implemented"))},o.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),"undefined"!=typeof e&&null!==e&&this.write(e,t),r.ending||r.finished||_(this,r,n)}}).call(this,e("_process"))},{"./_stream_duplex":20,_process:18,buffer:11,"core-util-is":25,inherits:53,stream:30}],25:[function(e,t,n){(function(e){function t(e){return Array.isArray(e)}function r(e){return"boolean"==typeof e}function i(e){return null===e}function o(e){return null==e}function s(e){return"number"==typeof e}function a(e){return"string"==typeof e}function u(e){return"symbol"==typeof e}function c(e){return void 0===e}function f(e){return h(e)&&"[object RegExp]"===y(e)}function h(e){return"object"==typeof e&&null!==e}function l(e){return h(e)&&"[object Date]"===y(e)}function d(e){return h(e)&&("[object Error]"===y(e)||e instanceof Error)}function p(e){return"function"==typeof e}function g(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function m(t){return e.isBuffer(t)}function y(e){return Object.prototype.toString.call(e)}n.isArray=t,n.isBoolean=r,n.isNull=i,n.isNullOrUndefined=o,n.isNumber=s,n.isString=a,n.isSymbol=u,n.isUndefined=c,n.isRegExp=f,n.isObject=h,n.isDate=l,n.isError=d,n.isFunction=p,n.isPrimitive=g,n.isBuffer=m}).call(this,e("buffer").Buffer)},{buffer:11}],26:[function(e,t){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":21}],27:[function(e,t,n){var r=e("stream");n=t.exports=e("./lib/_stream_readable.js"),n.Stream=r,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.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){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":23}],29:[function(e,t){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":24}],30:[function(e,t){function n(){r.call(this)}t.exports=n;var r=e("events").EventEmitter,i=e("inherits");i(n,r),n.Readable=e("readable-stream/readable.js"),n.Writable=e("readable-stream/writable.js"),n.Duplex=e("readable-stream/duplex.js"),n.Transform=e("readable-stream/transform.js"),n.PassThrough=e("readable-stream/passthrough.js"),n.Stream=n,n.prototype.pipe=function(e,t){function n(t){e.writable&&!1===e.write(t)&&c.pause&&c.pause()}function i(){c.readable&&c.resume&&c.resume()}function o(){f||(f=!0,e.end())}function s(){f||(f=!0,"function"==typeof e.destroy&&e.destroy())}function a(e){if(u(),0===r.listenerCount(this,"error"))throw e}function u(){c.removeListener("data",n),e.removeListener("drain",i),c.removeListener("end",o),c.removeListener("close",s),c.removeListener("error",a),e.removeListener("error",a),c.removeListener("end",u),c.removeListener("close",u),e.removeListener("close",u)}var c=this;c.on("data",n),e.on("drain",i),e._isStdio||t&&t.end===!1||(c.on("end",o),c.on("close",s));var f=!1;return c.on("error",a),e.on("error",a),c.on("end",u),c.on("close",u),e.on("close",u),e.emit("pipe",c),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,n){function r(e){if(e&&!u(e))throw new Error("Unknown encoding: "+e)}function i(e){return e.toString(this.encoding)}function o(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function s(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var a=e("buffer").Buffer,u=a.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!0;default:return!1}},c=n.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),r(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=i)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};c.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";e=e.slice(n,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var r=t.charCodeAt(t.length-1);if(!(r>=55296&&56319>=r)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;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,r=t.charCodeAt(i);if(r>=55296&&56319>=r){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},c.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(2>=t&&n>>4==14){this.charLength=3;break}if(3>=t&&n>>3==30){this.charLength=4;break}}this.charReceived=t},c.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t}},{buffer:11}],32:[function(e,t){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],33:[function(e,t,n){(function(t,r){function i(e,t){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),g(t)?r.showHidden=t:t&&n._extend(r,t),b(r.showHidden)&&(r.showHidden=!1),b(r.depth)&&(r.depth=2),b(r.colors)&&(r.colors=!1),b(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e){return e}function a(e){var t={};return e.forEach(function(e){t[e]=!0}),t}function u(e,t,r){if(e.customInspect&&t&&I(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return _(i)||(i=u(e,i,r)),i}var o=c(e,t);if(o)return o;var s=Object.keys(t),g=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),S(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(t);if(0===s.length){if(I(t)){var m=t.name?": "+t.name:"";return e.stylize("[Function"+m+"]","special")}if(k(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(x(t))return e.stylize(Date.prototype.toString.call(t),"date");if(S(t))return f(t)}var y="",v=!1,w=["{","}"];if(p(t)&&(v=!0,w=["[","]"]),I(t)){var b=t.name?": "+t.name:"";y=" [Function"+b+"]"}if(k(t)&&(y=" "+RegExp.prototype.toString.call(t)),x(t)&&(y=" "+Date.prototype.toUTCString.call(t)),S(t)&&(y=" "+f(t)),0===s.length&&(!v||0==t.length))return w[0]+y+w[1];if(0>r)return k(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var E;return E=v?h(e,t,r,g,s):s.map(function(n){return l(e,t,r,g,n,v)}),e.seen.pop(),d(E,y,w)}function c(e,t){if(b(t))return e.stylize("undefined","undefined");if(_(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return v(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i){for(var o=[],s=0,a=t.length;a>s;++s)o.push(R(t,String(s))?l(e,t,n,r,String(s),!0):"");return i.forEach(function(i){i.match(/^\d+$/)||o.push(l(e,t,n,r,i,!0))}),o}function l(e,t,n,r,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),R(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=m(n)?u(e,c.value,null):u(e,c.value,n-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n"))):a=e.stylize("[Circular]","special")),b(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function p(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function m(e){return null===e}function y(e){return null==e}function v(e){return"number"==typeof e}function _(e){return"string"==typeof e}function w(e){return"symbol"==typeof e}function b(e){return void 0===e}function k(e){return E(e)&&"[object RegExp]"===L(e)}function E(e){return"object"==typeof e&&null!==e}function x(e){return E(e)&&"[object Date]"===L(e)}function S(e){return E(e)&&("[object Error]"===L(e)||e instanceof Error)}function I(e){return"function"==typeof e}function A(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function L(e){return Object.prototype.toString.call(e)}function B(e){return 10>e?"0"+e.toString(10):e.toString(10)}function T(){var e=new Date,t=[B(e.getHours()),B(e.getMinutes()),B(e.getSeconds())].join(":");return[e.getDate(),P[e.getMonth()],t].join(" ")}function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var C=/%[sdj%]/g;n.format=function(e){if(!_(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(i(arguments[n]));return t.join(" ")}for(var n=1,r=arguments,o=r.length,s=String(e).replace(C,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}}),a=r[n];o>n;a=r[++n])s+=m(a)||!E(a)?" "+a:" "+i(a);return s},n.deprecate=function(e,i){function o(){if(!s){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),s=!0}return e.apply(this,arguments)}if(b(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(t.noDeprecation===!0)return e;var s=!1;return o};var M,j={};n.debuglog=function(e){if(b(M)&&(M=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!j[e])if(new RegExp("\\b"+e+"\\b","i").test(M)){var r=t.pid;j[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else j[e]=function(){};return j[e]},n.inspect=i,i.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]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=g,n.isNull=m,n.isNullOrUndefined=y,n.isNumber=v,n.isString=_,n.isSymbol=w,n.isUndefined=b,n.isRegExp=k,n.isObject=E,n.isDate=x,n.isError=S,n.isFunction=I,n.isPrimitive=A,n.isBuffer=e("./support/isBuffer");var P=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",T(),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!E(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":32,_process:18,inherits:53}],34:[function(e,t){(function(n,r){function i(e,t,n){"function"==typeof t&&(n=t,t={}),t||(t={}),o(e,t,function(e,r){return e?n(e):void c(r,t,n)})}function o(e,t,i){"function"==typeof t&&(i=t,t={}),t||(t={}),l(e)&&(e=Array.prototype.slice.call(e)),(h(e)||r.isBuffer(e)||d(e))&&(e=[e]);var o;if(Array.isArray(e)&&e.length>0){if(t.name=t.name||e[0].name,void 0===t.name)throw new Error("missing option 'name' and unable to infer it from input[0].name");1!==e.length||e[0].name||(e[0].name=t.name),o=e.map(function(e){var n={};if(h(e))n.getStream=p(e),n.length=e.size;else if(r.isBuffer(e))n.getStream=g(e),n.length=e.length;else{if(!d(e))throw new Error("input must contain only File|Blob|Buffer|Stream objects");if(!t.pieceLength)throw new Error("must specify `pieceLength` option if input is Stream");n.getStream=y(e,n),n.length=0}if(!e.name)throw new Error("missing requied `name` property on input");return n.path=[e.name],n}),n.nextTick(function(){i(null,o)})}else{if("string"!=typeof e)throw new Error("invalid input type");t.name=t.name||b.basename(e),a(s,e,function(t,n){if(t)return i(t);n=Array.isArray(n)?E(n):[n];var r=b.normalize(e);r[r.length-1]!==b.sep&&(r+=b.sep),n.forEach(function(e){e.getStream=m(e.path),e.path=e.path.replace(r,"").split(b.sep)}),i(null,n)})}}function s(e,t){t=I(t),x.stat(e,function(n,r){if(n)return t(n);var i={length:r.size,path:e};t(null,i)})}function a(e,t,n){x.readdir(t,function(r,i){r&&"ENOTDIR"===r.code?e(t,n):r?n(r):A(i.map(function(n){return function(r){a(e,b.join(t,n),r)}}),n)})}function u(e,t,n){function i(){f&&0===u&&n(null,new r(o.join(""),"hex"),s)}n=I(n);var o=[],s=0,a=e.map(function(e){return e.getStream}),u=0,c=0,f=!1;new S(a).pipe(new _(t,{nopad:!0})).on("data",function(e){s+=e.length;var t=c;L(e,function(e){o[t]=e,u-=1,i()}),u+=1,c+=1}).on("end",function(){f=!0,i()}).on("error",n)}function c(e,n,r){var i=void 0!==n.announceList?n.announceList:void 0!==n.announce?n.announce.map(function(e){return[e]}):t.exports.announceList,o={info:{name:n.name},announce:i[0][0],"announce-list":i,"creation date":Number(n.creationDate)||Date.now(),encoding:"UTF-8"};void 0!==n.comment&&(o.info.comment=n.comment),void 0!==n.createdBy&&(o.info["created by"]=n.createdBy),void 0!==n["private"]&&(o.info["private"]=Number(n["private"])),void 0!==n.urlList&&(o["url-list"]=n.urlList);var s=1===e.length,a=n.pieceLength||w(e.reduce(f,0));o.info["piece length"]=a,u(e,a,function(t,n,i){return t?r(t):(o.info.pieces=n,e.forEach(function(e){delete e.getStream}),s?o.info.length=i:o.info.files=e,void r(null,v.encode(o)))})}function f(e,t){return e+t.length}function h(e){return"undefined"!=typeof Blob&&e instanceof Blob}function l(e){return"function"==typeof FileList&&e instanceof FileList}function d(e){return"object"==typeof e&&"function"==typeof e.pipe}function p(e){return function(){return new k(e)}}function g(e){return function(){var t=new B.PassThrough;return t.end(e),t}}function m(e){return function(){return x.createReadStream(e)}}function y(e,t){return function(){var n=new T;return n._transform=function(e,n,r){t.length+=e.length,this.push(e),r()},e.pipe(n),n}}t.exports=i,t.exports.announceList=[["udp://tracker.publicbt.com:80"],["udp://tracker.openbittorrent.com:80"],["udp://tracker.webtorrent.io:80"],["wss://tracker.webtorrent.io"]],t.exports.parseInput=o;var v=e("bencode"),_=e("block-stream"),w=e("piece-length"),b=e("path"),k=e("filestream/read"),E=e("flatten"),x=e("fs"),S=e("multistream"),I=e("once"),A=e("run-parallel"),L=e("simple-sha1"),B=e("stream"),T=B.Transform}).call(this,e("_process"),e("buffer").Buffer)},{_process:18,bencode:35,"block-stream":7,buffer:11,"filestream/read":40,flatten:41,fs:8,multistream:54,once:56,path:17,"piece-length":42,"run-parallel":67,"simple-sha1":68,stream:30}],35:[function(e,t){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":36,"./lib/encode":37}],36:[function(e,t){(function(e){function n(t,r){return n.position=0,n.encoding=r||null,n.data=e.isBuffer(t)?t:new e(t),n.next()}n.position=0,n.data=null,n.encoding=null,n.next=function(){switch(n.data[n.position]){case 100:return n.dictionary();case 108:return n.list();case 105:return n.integer();default:return n.bytes()}},n.find=function(e){for(var t=n.position,r=n.data.length,i=n.data;r>t;){if(i[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")},n.dictionary=function(){n.position++;for(var e={};101!==n.data[n.position];)e[n.bytes()]=n.next();return n.position++,e},n.list=function(){n.position++;for(var e=[];101!==n.data[n.position];)e.push(n.next());return n.position++,e},n.integer=function(){var e=n.find(101),t=n.data.toString("ascii",n.position+1,e);return n.position+=e+1-n.position,parseInt(t,10)},n.bytes=function(){var e=n.find(58),t=parseInt(n.data.toString("ascii",n.position,e),10),r=++e+t;return n.position=r,n.encoding?n.data.toString(n.encoding,e,r):n.data.slice(e,r)},t.exports=n}).call(this,e("buffer").Buffer)},{buffer:11}],37:[function(e,t){(function(e){function n(t){var r=[];return n._encode(r,t),e.concat(r)}n._floatConversionDetected=!1,n._encode=function(t,r){if(e.isBuffer(r))return t.push(new e(r.length+":")),void t.push(r);switch(typeof r){case"string":n.bytes(t,r);break;case"number":n.number(t,r);break;case"object":r.constructor===Array?n.list(t,r):n.dict(t,r)}};var r=new e("e"),i=new e("d"),o=new e("l");n.bytes=function(t,n){t.push(new e(e.byteLength(n)+":"+n))},n.number=function(t,r){var i=2147483648,o=r/i<<0,s=r%i<<0,a=o*i+s;t.push(new e("i"+a+"e")),a===r||n._floatConversionDetected||(n._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+r+'":','Bencoding only defines support for integers, value was converted to "'+a+'"'),console.trace())},n.dict=function(e,t){e.push(i);for(var o,s=0,a=Object.keys(t).sort(),u=a.length;u>s;s++)o=a[s],n.bytes(e,o),n._encode(e,t[o]);e.push(r)},n.list=function(e,t){var i=0,s=t.length;for(e.push(o);s>i;i++)n._encode(e,t[i]);e.push(r)},t.exports=n}).call(this,e("buffer").Buffer)},{buffer:11}],38:[function(e,t){(function(n){var r=e("is-typedarray").strict;t.exports=function(e){var t=n.TYPED_ARRAY_SUPPORT?n._augment:function(e){return new n(e)};return e instanceof Uint8Array?t(e):e instanceof ArrayBuffer?t(new Uint8Array(e)):r(e)?t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):new n(e)}}).call(this,e("buffer").Buffer)},{buffer:11,"is-typedarray":39}],39:[function(e,t){function n(e){return r(e)||i(e)}function r(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 i(e){return s[o.call(e)]}t.exports=n,n.strict=r,n.loose=i;var o=Object.prototype.toString,s={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],40:[function(e,t){"use strict";function n(e,t){return this instanceof n?(t=t||{},r.call(this,s({objectMode:!0},t)),this._offset=0,this._eof=!1,this._metasent=!t.meta,this._metadata={name:e.name,size:e.size,extension:e.name.replace(o,"$1")},t.mime&&"function"==typeof t.mime.lookup&&(this._metadata.type=t.mime.lookup(this._metadata.extension)),this.reader=new FileReader,this.reader.onprogress=this._handleProgress.bind(this),this.reader.onload=this._handleLoad.bind(this),void this.reader.readAsArrayBuffer(e)):new n(e,t)}var r=e("stream").Readable,i=e("util"),o=/^.*\.(\w+)$/,s=e("extend.js"),a=e("typedarray-to-buffer");i.inherits(n,r),t.exports=n,n.prototype._read=function(e){function t(){var i,o=n._offset,s=n._offset+e,u=r.result&&r.result.byteLength,c=2===r.readyState&&s>u;return u&&(c||u>s)?(i=a(new Uint8Array(r.result,o,Math.min(e,r.result.byteLength-o))),n._offset=o+i.length,n._eof=0===i.length,n.push(i.length>0?i:null)):void n.once("readable",t)}var n=this,r=this.reader;return this._metasent?void t():(this._metasent=!0,this.push("meta|"+JSON.stringify(this._metadata)))},n.prototype._handleLoad=function(){this.emit("readable")},n.prototype._handleProgress=function(){this.emit("readable")}},{"extend.js":51,stream:30,"typedarray-to-buffer":38,util:33}],41:[function(e,t){t.exports=function(e,t){function n(e,r){return e.reduce(function(e,i){return e.concat(Array.isArray(i)&&t>r?n(i,r+1):i)},[])}return t="number"==typeof t?t:1/0,n(e,1)}},{}],42:[function(e,t){for(var n=e("closest-to"),r=[],i=14;22>=i;i++)r.push(Math.pow(2,i));t.exports=function(e){return n(e/Math.pow(2,10),r)}},{"closest-to":43}],43:[function(e,t){t.exports=function(e,t){var n=1/0,r=0,i=null;t.sort(function(e,t){return e-t});for(var o=0,s=t.length;s>o&&(r=Math.abs(e-t[o]),!(r>=n));o++)n=r,i=t[o];return i}},{}],44:[function(e,t,n){function r(){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}function i(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return e;var r="color: "+this.color;e=[e[0],r,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0,o=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r),e}function o(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{null==e?u.removeItem("debug"):u.debug=e}catch(t){}}function a(){var e;try{e=u.debug}catch(t){}return e}n=t.exports=e("./debug"),n.log=o,n.formatArgs=i,n.save=s,n.load=a,n.useColors=r;var u;u="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:window.localStorage,n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){return JSON.stringify(e)},n.enable(a())},{"./debug":45}],45:[function(e,t,n){function r(){return n.colors[f++%n.colors.length]}function i(e){function t(){}function i(){var e=i,t=+new Date,o=t-(c||t);e.diff=o,e.prev=c,e.curr=t,c=t,null==e.useColors&&(e.useColors=n.useColors()),null==e.color&&e.useColors&&(e.color=r());var s=Array.prototype.slice.call(arguments);s[0]=n.coerce(s[0]),"string"!=typeof s[0]&&(s=["%o"].concat(s));var a=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,r){if("%%"===t)return t;a++;var i=n.formatters[r];if("function"==typeof i){var o=s[a];t=i.call(e,o),s.splice(a,1),a--}return t}),"function"==typeof n.formatArgs&&(s=n.formatArgs.apply(e,s));var u=i.log||n.log||console.log.bind(console);u.apply(e,s)}t.enabled=!1,i.enabled=!0;var o=n.enabled(e)?i:t;return o.namespace=e,o}function o(e){n.save(e);for(var t=(e||"").split(/[\s,]+/),r=t.length,i=0;r>i;i++)t[i]&&(e=t[i].replace(/\*/g,".*?"),"-"===e[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))}function s(){n.enable("")}function a(e){var t,r;for(t=0,r=n.skips.length;r>t;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;r>t;t++)if(n.names[t].test(e))return!0;return!1}function u(e){return e instanceof Error?e.stack||e.message:e}n=t.exports=i,n.coerce=u,n.disable=s,n.enable=o,n.enabled=a,n.humanize=e("ms"),n.names=[],n.skips=[],n.formatters={};var c,f=0},{ms:46}],46:[function(e,t){function n(e){var t=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"y":return n*f;case"days":case"day":case"d":return n*c;case"hours":case"hour":case"h":return n*u;case"minutes":case"minute":case"m":return n*a;case"seconds":case"second":case"s":return n*s;case"ms":return n}}}function r(e){return e>=c?Math.round(e/c)+"d":e>=u?Math.round(e/u)+"h":e>=a?Math.round(e/a)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function i(e){return o(e,c,"day")||o(e,u,"hour")||o(e,a,"minute")||o(e,s,"second")||e+" ms"}function o(e,t,n){return t>e?void 0:1.5*t>e?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}var s=1e3,a=60*s,u=60*a,c=24*u,f=365.25*c;t.exports=function(e,t){return t=t||{},"string"==typeof e?n(e):t["long"]?i(e):r(e)}},{}],47:[function(e,t){function n(e){var t=!0; -return i(function(){t=!1}),function(){var n=arguments,r=this;t?i(function(){e.apply(r,n)}):e.apply(r,n)}}var r=e("wrappy");t.exports=r(n);var i=e("asap")},{asap:48,wrappy:49}],48:[function(e,t){(function(e){function n(){for(;i.next;){i=i.next;var e=i.task;i.task=void 0;var t=i.domain;t&&(i.domain=void 0,t.enter());try{e()}catch(r){if(u)throw t&&t.exit(),setTimeout(n,0),t&&t.enter(),r;setTimeout(function(){throw r},0)}t&&t.exit()}s=!1}function r(t){o=o.next={task:t,domain:u&&e.domain,next:null},s||(s=!0,a())}var i={task:void 0,next:null},o=i,s=!1,a=void 0,u=!1;if("undefined"!=typeof e&&e.nextTick)u=!0,a=function(){e.nextTick(n)};else if("function"==typeof setImmediate)a="undefined"!=typeof window?setImmediate.bind(window,n):function(){setImmediate(n)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=n,a=function(){c.port2.postMessage(0)}}else a=function(){setTimeout(n,0)};t.exports=r}).call(this,e("_process"))},{_process:18}],49:[function(e,t){function n(e,t){function r(){for(var t=new Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),i=t[t.length-1];return"function"==typeof r&&r!==i&&Object.keys(i).forEach(function(e){r[e]=i[e]}),r}if(e&&t)return n(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(t){r[t]=e[t]}),r}t.exports=n},{}],50:[function(e,t){var n=e("once"),r=function(){},i=function(e){return e.setHeader&&"function"==typeof e.abort},o=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},s=function(e,t,a){if("function"==typeof t)return s(e,null,t);t||(t={}),a=n(a||r);var u=e._writableState,c=e._readableState,f=t.readable||t.readable!==!1&&e.readable,h=t.writable||t.writable!==!1&&e.writable,l=function(){e.writable||d()},d=function(){h=!1,f||a()},p=function(){f=!1,h||a()},g=function(e){a(e?new Error("exited with error code: "+e):null)},m=function(){return(!f||c&&c.ended)&&(!h||u&&u.ended)?void 0:a(new Error("premature close"))},y=function(){e.req.on("finish",d)};return i(e)?(e.on("complete",d),e.on("abort",m),e.req?y():e.on("request",y)):h&&!u&&(e.on("end",l),e.on("close",l)),o(e)&&e.on("exit",g),e.on("end",p),e.on("finish",d),t.error!==!1&&e.on("error",a),e.on("close",m),function(){e.removeListener("complete",d),e.removeListener("abort",m),e.removeListener("request",y),e.req&&e.req.removeListener("finish",d),e.removeListener("end",l),e.removeListener("close",l),e.removeListener("finish",d),e.removeListener("exit",g),e.removeListener("end",p),e.removeListener("error",a),e.removeListener("close",m)}};t.exports=s},{once:56}],51:[function(e,t){t.exports=function(e){for(var t,n=[].slice.call(arguments,1),r=0,i=n.length;i>r;r++){t=n[r];for(var o in t)e[o]=t[o]}return e}},{}],52:[function(e,t){var n=t.exports=function(e,t){if(t||(t=16),void 0===e&&(e=128),0>=e)return"0";for(var r=Math.log(Math.pow(2,e))/Math.log(t),i=2;1/0===r;i*=2)r=Math.log(Math.pow(2,e/i))/Math.log(t)*i;for(var o=r-Math.floor(r),s="",i=0;i<Math.floor(r);i++){var a=Math.floor(Math.random()*t).toString(t);s=a+s}if(o){var u=Math.pow(t,o),a=Math.floor(Math.random()*u).toString(t);s=a+s}var c=parseInt(s,t);return 1/0!==c&&c>=Math.pow(2,e)?n(e,t):s};n.rack=function(e,t,r){var i=function(i){var s=0;do{if(s++>10){if(!r)throw new Error("too many ID collisions, use more bits");e+=r}var a=n(e,t)}while(Object.hasOwnProperty.call(o,a));return o[a]=i,a},o=i.hats={};return i.get=function(e){return i.hats[e]},i.set=function(e,t){return i.hats[e]=t,i},i.bits=e||128,i.base=t||16,i}},{}],53:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],54:[function(e,t){function n(e,t){return this instanceof n?(o.Readable.call(this,t),this.destroyed=!1,this._drained=!1,this._forwarding=!1,this._current=null,this._queue=e.map(r),void this._next()):new n(e,t)}function r(e){if(!e||"function"==typeof e||e._readableState)return e;var t=(new o.Readable).wrap(e);return e.destroy&&(t.destroy=e.destroy.bind(e)),t}t.exports=n;var i=e("inherits"),o=e("stream");i(n,o.Readable),n.obj=function(e){return new n(e,{objectMode:!0,highWaterMark:16})},n.prototype._read=function(){this._drained=!0,this._forward()},n.prototype._forward=function(){if(!this._forwarding&&this._drained){this._forwarding=!0;for(var e;null!==(e=this._current.read());)this._drained=this.push(e);this._forwarding=!1}},n.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),this._queue.forEach(function(e){e.destroy&&e.destroy()}),e&&this.emit("error",e),this.emit("close"))},n.prototype._next=function(){function e(){o._forward()}function t(){s._readableState.ended||o.destroy()}function n(){o._current=null,s.removeListener("readable",e),s.removeListener("end",n),s.removeListener("error",i),s.removeListener("close",t),o._next()}function i(e){o.destroy(e)}var o=this,s=this._queue.shift();return"function"==typeof s&&(s=r(s())),s?(this._current=s,s.on("readable",e),s.on("end",n),s.on("error",i),void s.on("close",t)):void this.push(null)}},{inherits:53,stream:30}],55:[function(e,t,n){arguments[4][49][0].apply(n,arguments)},{dup:49}],56:[function(e,t){function n(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}var r=e("wrappy");t.exports=r(n),n.proto=n(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:!0})})},{wrappy:55}],57:[function(e,t){(function(n){var r=e("magnet-uri"),i=e("parse-torrent-file");t.exports=function(e){if("string"==typeof e&&/magnet:/.test(e))return r(e);if("string"==typeof e&&(40===e.length||32===e.length)){var t=r("magnet:?xt=urn:btih:"+e);return t?{infoHash:t.infoHash}:null}if(n.isBuffer(e)&&20===e.length)return{infoHash:e.toString("hex")};if(!n.isBuffer(e))return e&&e.infoHash?e:null;try{return i(e)}catch(o){return console.log(o),null}},t.exports.toMagnetURI=r.encode,t.exports.toTorrentFile=i.encode}).call(this,e("buffer").Buffer)},{buffer:11,"magnet-uri":58,"parse-torrent-file":62}],58:[function(e,t){(function(n){function r(e){var t={},r=e.split("magnet:?")[1];if(!r||0===r.length)return t;var i=r.split("&");i.forEach(function(e){var n=e.split("=");if(2===n.length){var r=n[0],i=n[1];if("dn"===r&&(i=decodeURIComponent(i).replace(/\+/g," ")),("tr"===r||"xs"===r||"as"===r)&&(i=decodeURIComponent(i)),"kt"===r&&(i=decodeURIComponent(i).split("+")),t[r])if(Array.isArray(t[r]))t[r].push(i);else{var o=t[r];t[r]=[o,i]}else t[r]=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 n(s[1],"hex").toString("hex");else if(s=e.match(/^urn:btih:(.{32})/)){var r=o.decode(s[1]);t.infoHash=new n(r,"binary").toString("hex")}})}return t.dn&&(t.name=t.dn),t.kt&&(t.keywords=t.kt),"string"==typeof t.tr?t.announce=[t.tr]:Array.isArray(t.tr)&&(t.announce=t.tr),t.announce&&(t.announceList=t.announce.map(function(e){return[e]})),t}function i(e){e=s({},e),e.infoHash&&!e.xt&&(e.xt="urn:btih:"+e.infoHash),e.name&&!e.dn&&(e.dn=e.name),e.keywords&&!e.kt&&(e.kt=e.keywords),e.announce&&!e.tr&&(e.tr=e.announce),e.announceList&&!e.tr&&(e.tr=a(e.announceList));var t="magnet:?";return Object.keys(e).filter(function(e){return 2===e.length}).forEach(function(n,r){var i=Array.isArray(e[n])?e[n]:[e[n]];i.forEach(function(e,i){!(r>0||i>0)||"kt"===n&&0!==i||(t+="&"),"dn"===n&&(e=encodeURIComponent(e).replace(/%20/g,"+")),("tr"===n||"xs"===n||"as"===n)&&(e=encodeURIComponent(e)),"kt"===n&&(e=encodeURIComponent(e)),t+="kt"===n&&i>0?"+"+e:n+"="+e})}),t}t.exports=r,t.exports.decode=r,t.exports.encode=i;var o=e("thirty-two"),s=e("extend.js"),a=e("flatten")}).call(this,e("buffer").Buffer)},{buffer:11,"extend.js":51,flatten:59,"thirty-two":60}],59:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{dup:41}],60:[function(e,t,n){var r=e("./thirty-two");n.encode=r.encode,n.decode=r.decode},{"./thirty-two":61}],61:[function(e,t,n){(function(e){function t(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}var r="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",i=[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];n.encode=function(n){var i=0,o=0,s=0,a=0,u=new e(8*t(n));for(e.isBuffer(n)||(n=new e(n));i<n.length;){var c=n[i];s>3?(a=c&255>>s,s=(s+5)%8,a=a<<s|(i+1<n.length?n[i+1]:0)>>8-s,i++):(a=c>>8-(s+5)&31,s=(s+5)%8,0==s&&i++),u[o]=r.charCodeAt(a),o++}for(i=o;i<u.length;i++)u[i]=61;return u},n.decode=function(t){var n,r=0,o=0,s=0;e.isBuffer(t)||(t=new e(t));for(var a=new e(Math.ceil(5*t.length/8)),u=0;u<t.length&&61!=t[u];u++){var c=t[u]-48;if(!(c<i.length))throw new Error("Invalid input - it is not base32 encoded string");o=i[c],3>=r?(r=(r+5)%8,0==r?(n|=o,a[s]=n,s++,n=0):n|=255&o<<8-r):(r=(r+5)%8,n|=255&o>>>r,a[s]=n,s++,n=255&o<<8-r)}return a.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:11}],62:[function(e,t){(function(n){function r(e){n.isBuffer(e)&&(e=u.decode(e)),a(e.info,"info"),a(e.info.name,"info.name"),a(e.info["piece length"],"info['piece length']"),a(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(function(e){a("number"==typeof e.length,"info.files[0].length"),a(e.path,"info.files[0].path")}):a(e.info.length,"info.length");var t={};t.info=e.info,t.infoBuffer=u.encode(e.info),t.infoHash=f.sync(t.infoBuffer),t.name=e.info.name.toString(),t["private"]=!!e.info["private"],e["creation date"]&&(t.created=new Date(1e3*e["creation date"])),n.isBuffer(e.comment)&&(t.comment=e.comment.toString());var r=e["announce-list"];r||(r=e.announce?[[e.announce]]:[]),t.announceList=r.map(function(e){return e.map(function(e){return e.toString()})}),t.announce=[].concat.apply([],t.announceList),t.urlList=(e["url-list"]||[]).map(function(e){return e.toString()});var i=e.info.files||[e.info];t.files=i.map(function(e,n){var r=[].concat(e.name||t.name,e.path||[]).map(function(e){return e.toString()});return{path:c.join.apply(null,[c.sep].concat(r)).slice(1),name:r[r.length-1],length:e.length,offset:i.slice(0,n).reduce(o,0)}}),t.length=i.reduce(o,0);var h=t.files[t.files.length-1];return t.pieceLength=e.info["piece length"],t.lastPieceLength=(h.offset+h.length)%t.pieceLength||t.pieceLength,t.pieces=s(e.info.pieces),t}function i(e){var t={info:e.info};return e.announce&&e.announce[0]&&(t.announce=e.announce[0]),e.announceList&&(t["announce-list"]=e.announceList.map(function(e){return e.map(function(e){return e=new n(e,"utf8"),t.announce||(t.announce=e),e})})),e.created&&(t["creation date"]=e.created.getTime()/1e3|0),u.encode(t)}function o(e,t){return e+t.length}function s(e){for(var t=[],n=0;n<e.length;n+=20)t.push(e.slice(n,n+20).toString("hex"));return t}function a(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}t.exports=r,t.exports.decode=r,t.exports.encode=i;var u=e("bencode"),c=e("path"),f=e("simple-sha1")}).call(this,e("buffer").Buffer)},{bencode:63,buffer:11,path:17,"simple-sha1":68}],63:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"./lib/decode":64,"./lib/encode":65,dup:35}],64:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{buffer:11,dup:36}],65:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:11,dup:37}],66:[function(e,t){function n(e,t,n){Array.isArray(n)||(n=[n]),n.forEach(function(n){e.on(n,function(){var e=[].slice.call(arguments);e.unshift(n),t.emit.apply(t,e)})})}function r(e,t){var r=new i;return n(e,r,t),r}t.exports=n,t.exports.filter=r;var i=e("events").EventEmitter},{events:15}],67:[function(e,t){t.exports=function(e,t){function n(e,n,o){r[e]=o,(0===--i||n)&&(t&&t(n,r),t=null)}var r,i,o;Array.isArray(e)?(r=[],i=e.length):(o=Object.keys(e),r={},i=o.length),i?o?o.forEach(function(t){e[t](n.bind(void 0,t))}):e.forEach(function(e,t){e(n.bind(void 0,t))}):(t&&t(null,r),t=null)}},{}],68:[function(e,t){function n(e,t){return u?("string"==typeof e&&(e=r(e)),void u.digest({name:"sha-1"},e).then(function(e){t(i(new Uint8Array(e)))},function(){t(c(e))})):void setTimeout(t,0,c(e))}function r(e){for(var t=e.length,n=new Uint8Array(t),r=0;t>r;r++)n[r]=e.charCodeAt(r);return n}function i(e){for(var t=e.length,n=[],r=0;t>r;r++){var i=e[r];n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")}var o=e("rusha"),s=new o,a=window.crypto||window.msCrypto||{},u=a.subtle||a.webkitSubtle,c=s.digest.bind(s);try{u.digest({name:"sha-1"},new Uint8Array)}catch(f){u=!1}delete window.Rusha,t.exports=n,t.exports.sync=c},{rusha:69}],69:[function(e,t){(function(e){!function(){function n(e){"use strict";var t={fill:0},n=function(e){for(e+=9;e%64>0;e+=1);return e},o=function(e,t){for(var n=t>>2;n<e.length;n++)e[n]=0},a=function(e,t,n){e[t>>2]|=128<<24-(t%4<<3),e[((t>>2)+2&-16)+15]=n<<3},u=function(e,t,n,r,i){var o,s=this,a=i%4,u=r%4,c=r-u;if(c>0)switch(a){case 0:e[i+3|0]=s.charCodeAt(n);case 1:e[i+2|0]=s.charCodeAt(n+1);case 2:e[i+1|0]=s.charCodeAt(n+2);case 3:e[0|i]=s.charCodeAt(n+3)}for(o=a;c>o;o=o+4|0)t[i+o>>2]=s.charCodeAt(n+o)<<24|s.charCodeAt(n+o+1)<<16|s.charCodeAt(n+o+2)<<8|s.charCodeAt(n+o+3);switch(u){case 3:e[i+c+1|0]=s.charCodeAt(n+c+2);case 2:e[i+c+2|0]=s.charCodeAt(n+c+1);case 1:e[i+c+3|0]=s.charCodeAt(n+c)}},c=function(e,t,n,r,i){var o,s=this,a=i%4,u=r%4,c=r-u;if(c>0)switch(a){case 0:e[i+3|0]=s[n];case 1:e[i+2|0]=s[n+1];case 2:e[i+1|0]=s[n+2];case 3:e[0|i]=s[n+3]}for(o=4-a;c>o;o=o+=4)t[i+o>>2]=s[n+o]<<24|s[n+o+1]<<16|s[n+o+2]<<8|s[n+o+3];switch(u){case 3:e[i+c+1|0]=s[n+c+2];case 2:e[i+c+2|0]=s[n+c+1];case 1:e[i+c+3|0]=s[n+c]}},f=function(e,t,n,r,o){var s,a=this,u=o%4,c=r%4,f=r-c,h=new Uint8Array(i.readAsArrayBuffer(a.slice(n,n+r)));if(f>0)switch(u){case 0:e[o+3|0]=h[0];case 1:e[o+2|0]=h[1];case 2:e[o+1|0]=h[2];case 3:e[0|o]=h[3]}for(s=4-u;f>s;s=s+=4)t[o+s>>2]=h[s]<<24|h[s+1]<<16|h[s+2]<<8|h[s+3];switch(c){case 3:e[o+f+1|0]=h[f+2];case 2:e[o+f+2|0]=h[f+1];case 1:e[o+f+3|0]=h[f]}},h=function(e){switch(s.getDataType(e)){case"string":return u.bind(e);case"array":return c.bind(e);case"buffer":return c.bind(e);case"arraybuffer":return c.bind(new Uint8Array(e));case"view":return c.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return f.bind(e)}},l=function(e){var t,n,r="0123456789abcdef",i=[],o=new Uint8Array(e);for(t=0;t<o.length;t++)n=o[t],i[t]=r.charAt(n>>4&15)+r.charAt(n>>0&15);return i.join("")},d=function(e){var t;if(65536>=e)return 65536;if(16777216>e)for(t=1;e>t;t<<=1);else for(t=16777216;e>t;t+=16777216);return t},p=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(d(t.padMaxChunkLen+320+20)),t.h32=new Int32Array(t.heap),t.h8=new Int8Array(t.heap),t.core=r({Int32Array:Int32Array,DataView:DataView},{},t.heap),t.buffer=null};p(e||65536);var g=function(e,t){var n=new Int32Array(e,t+320,5);n[0]=1732584193,n[1]=-271733879,n[2]=-1732584194,n[3]=271733878,n[4]=-1009589776},m=function(e,r){var i=n(e),s=new Int32Array(t.heap,0,i>>2);return o(s,e),a(s,e,r),i},y=function(e,n,r){h(e)(t.h8,t.h32,n,r,0)},v=function(e,n,r,i,o){var s=r;o&&(s=m(r,i)),y(e,n,r),t.core.hash(s,t.padMaxChunkLen)},_=function(e,t){var n=new Int32Array(e,t+320,5),r=new Int32Array(5),i=new DataView(r.buffer);return i.setInt32(0,n[0],!1),i.setInt32(4,n[1],!1),i.setInt32(8,n[2],!1),i.setInt32(12,n[3],!1),i.setInt32(16,n[4],!1),r},w=this.rawDigest=function(e){var n=e.byteLength||e.length||e.size;g(t.heap,t.padMaxChunkLen);var r=0,i=t.maxChunkLen;for(r=0;n>r+i;r+=i)v(e,r,i,n,!1);return v(e,r,n-r,n,!0),_(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return l(w(e).buffer)}}function r(e,t,n){"use asm";function r(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,a=0,u=0,c=0,f=0,h=0,l=0,d=0,p=0,g=0,m=0;for(o=i[t+320>>2]|0,a=i[t+324>>2]|0,c=i[t+328>>2]|0,h=i[t+332>>2]|0,d=i[t+336>>2]|0,n=0;(n|0)<(e|0);n=n+64|0){for(s=o,u=a,f=c,l=h,p=d,r=0;(r|0)<64;r=r+4|0)m=i[n+r>>2]|0,g=((o<<5|o>>>27)+(a&c|~a&h)|0)+((m+d|0)+1518500249|0)|0,d=h,h=c,c=a<<30|a>>>2,a=o,o=g,i[e+r>>2]=m;for(r=e+64|0;(r|0)<(e+80|0);r=r+4|0)m=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31,g=((o<<5|o>>>27)+(a&c|~a&h)|0)+((m+d|0)+1518500249|0)|0,d=h,h=c,c=a<<30|a>>>2,a=o,o=g,i[r>>2]=m;for(r=e+80|0;(r|0)<(e+160|0);r=r+4|0)m=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31,g=((o<<5|o>>>27)+(a^c^h)|0)+((m+d|0)+1859775393|0)|0,d=h,h=c,c=a<<30|a>>>2,a=o,o=g,i[r>>2]=m;for(r=e+160|0;(r|0)<(e+240|0);r=r+4|0)m=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31,g=((o<<5|o>>>27)+(a&c|a&h|c&h)|0)+((m+d|0)-1894007588|0)|0,d=h,h=c,c=a<<30|a>>>2,a=o,o=g,i[r>>2]=m;for(r=e+240|0;(r|0)<(e+320|0);r=r+4|0)m=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31,g=((o<<5|o>>>27)+(a^c^h)|0)+((m+d|0)-899497514|0)|0,d=h,h=c,c=a<<30|a>>>2,a=o,o=g,i[r>>2]=m;o=o+s|0,a=a+u|0,c=c+f|0,h=h+l|0,d=d+p|0}i[t+320>>2]=o,i[t+324>>2]=a,i[t+328>>2]=c,i[t+332>>2]=h,i[t+336>>2]=d}var i=new e.Int32Array(n);return{hash:r}}if("undefined"!=typeof t&&(t.exports=n),"undefined"!=typeof window&&(window.Rusha=n),"undefined"!=typeof FileReaderSync){var i=new FileReaderSync,o=new n(4194304);self.onmessage=function(e){var t,n=e.data.data;try{t=o.digest(n),self.postMessage({id:e.data.id,hash:t})}catch(r){self.postMessage({id:e.data.id,error:r.name})}}}var s={getDataType:function(t){if("string"==typeof t)return"string";if(t instanceof Array)return"array";if("undefined"!=typeof e&&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.")}}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],70:[function(e,t){var n=1,r=65535,i=4,o=function(){n=n+1&r},s=setInterval(o,1e3/i|0);s.unref&&s.unref(),t.exports=function(e){var t=i*(e||5),o=[0],s=1,a=n-1&r;return function(e){var u=n-a&r;for(u>t&&(u=t),a=n;u--;)s===t&&(s=0),o[s]=o[0===s?t-1:s-1],s++;e&&(o[s-1]+=e);var c=o[s-1],f=o.length<t?0:o[s===t?0:s];return o.length<i?c:(c-f)*i/o.length}}},{}],71:[function(e,t){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(s.call(t),a(t,{announce:[],dht:"function"==typeof o,rtcConfig:null,peerId:null,port:0,tracker:!0},e),!t.peerId)throw new Error("peerId required");if(!n.browser&&!t.port)throw new Error("port required");!n.browser||t.announce&&0!==t.announce.length||console.warn("Warning: must specify a tracker server to discover peers (required in browser because DHT is not implemented yet) (you can use wss://tracker.webtorrent.io)"),t._externalDHT=!1,t._performedDHTLookup=!1,t._createDHT(t.dhtPort)}t.exports=r;var i=e("debug")("torrent-discovery"),o=e("bittorrent-dht/client"),s=e("events").EventEmitter,a=e("extend.js"),u=e("inherits"),c=e("re-emitter"),f=e("bittorrent-tracker/client");u(r,s),r.prototype.setTorrent=function(e){var t=this;if(!t.torrent){if(e&&e.infoHash)t.torrent=e,t.infoHash=e.infoHash;else{if(t.infoHash)return;t.infoHash=e}i("setTorrent %s",e),t.tracker&&t.tracker!==!0?t.tracker.torrentLength=e.length:t._createTracker(),t.dht&&(t.dht.ready?t._dhtLookupAndAnnounce():t.dht.on("ready",t._dhtLookupAndAnnounce.bind(t)))}},r.prototype.stop=function(e){var t=this;t.tracker&&t.tracker.stop&&t.tracker.stop(),!t._externalDHT&&t.dht&&t.dht.destroy?t.dht.destroy(e):n.nextTick(function(){e(null)})},r.prototype._createDHT=function(e){var t=this;t.dht&&(t.dht?t._externalDHT=!0:t.dht=new o,c(t.dht,t,["peer","error","warning"]),t._externalDHT||t.dht.listen(e))},r.prototype._createTracker=function(){var e=this;if(e.tracker){var t=e.torrent||{infoHash:e.infoHash,announce:e.announce};e.tracker=n.browser?new f(e.peerId,t,{rtcConfig:e.rtcConfig}):new f(e.peerId,e.port,t),c(e.tracker,e,["peer","warning","error"]),e.tracker.start()}},r.prototype._dhtLookupAndAnnounce=function(){var e=this;e._performedDHTLookup||(e._performedDHTLookup=!0,i("lookup"),e.dht.lookup(e.infoHash,function(t){!t&&e.port&&(i("dhtAnnounce"),e.dht.announce(e.infoHash,e.port,function(){e.emit("dhtAnnounce")}))}))}}).call(this,e("_process"))},{_process:18,"bittorrent-dht/client":10,"bittorrent-tracker/client":72,debug:44,events:15,"extend.js":51,inherits:53,"re-emitter":66}],72:[function(e,t){(function(n){function r(e,t,o){var u=this;return u instanceof r?(a.call(u),u._opts=o||{},u._peerId=n.isBuffer(e)?e:new n(e,"hex"),u._infoHash=n.isBuffer(t.infoHash)?t.infoHash:new n(t.infoHash,"hex"),u.torrentLength=t.length,u._numWant=u._opts.numWant||d,u._intervalMs=u._opts.interval||18e5,s("new client %s",u._infoHash.toString("hex")),"string"==typeof t.announce&&(t.announce=[t.announce]),void(u._trackers=(t.announce||[]).filter(function(e){return 0===e.indexOf("ws://")||0===e.indexOf("wss://")}).map(function(e){return new i(u,e,u._opts)}))):new r(e,t,o)}function i(e,t,n){var r=this;a.call(r),r._opts=n||{},r._announceUrl=t,r._peers={},s("new tracker %s",t),r.client=e,r.ready=!1,r._socket=null,r._intervalMs=r.client._intervalMs,r._interval=null}function o(e){return new n(e,"binary").toString("hex")}t.exports=r;var s=e("debug")("webtorrent-tracker"),a=e("events").EventEmitter,u=e("extend.js"),c=e("hat"),f=e("inherits"),h=e("simple-peer"),l=e("simple-websocket"),d=15;f(r,a);var p={};r.prototype.start=function(e){var t=this;t._trackers.forEach(function(t){t.start(e)})},r.prototype.stop=function(e){var t=this;t._trackers.forEach(function(t){t.stop(e)})},r.prototype.complete=function(e){var t=this;t._trackers.forEach(function(t){t.complete(e)})},r.prototype.update=function(e){var t=this;t._trackers.forEach(function(t){t.update(e)})},r.prototype.setInterval=function(e){var t=this;t._intervalMs=e,t._trackers.forEach(function(t){t.setInterval(e)})},f(i,a),i.prototype.start=function(e){var t=this;e=e||{},e.event="started",s("sent `start` %s %s",t._announceUrl,JSON.stringify(e)),t._announce(e),t.setInterval(t._intervalMs)},i.prototype.stop=function(e){var t=this;e=e||{},e.event="stopped",s("sent `stop` %s %s",t._announceUrl,JSON.stringify(e)),t._announce(e),t.setInterval(0)},i.prototype.complete=function(e){var t=this;e=e||{},e.event="completed",e.downloaded=e.downloaded||t.torrentLength||0,s("sent `complete` %s %s",t._announceUrl,JSON.stringify(e)),t._announce(e)},i.prototype.update=function(e){var t=this;e=e||{},s("sent `update` %s %s",t._announceUrl,JSON.stringify(e)),t._announce(e)},i.prototype._init=function(e){var t=this;e&&t.once("ready",e),t._socket||(p[t._announceUrl]?(t._socket=p[t._announceUrl],t._onSocketReady()):(t._socket=p[t._announceUrl]=new l(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)))},i.prototype._onSocketReady=function(){var e=this;e.ready=!0,e.emit("ready")},i.prototype._onSocketWarning=function(e){s("tracker warning %s",e.message)},i.prototype._onSocketMessage=function(e){var t=this;if("object"!=typeof e||null===e)return t.client.emit("warning",new Error("Invalid tracker response"));if(e.info_hash===t.client._infoHash.toString("binary")){s("received %s from %s",JSON.stringify(e),t._announceUrl);var n=e["failure reason"];if(n)return t.client.emit("warning",new Error(n));var r=e["warning message"];r&&t.client.emit("warning",new Error(r));var i=e.interval||e["min interval"];i&&!t._opts.interval&&0!==t._intervalMs&&t.setInterval(1e3*i);var a=e["tracker id"];a&&(t._trackerId=a),e.complete&&t.client.emit("update",{announce:t._announceUrl,complete:e.complete,incomplete:e.incomplete});var u;e.offer&&(u=new h({trickle:!1,config:t._opts.rtcConfig}),u.id=o(e.peer_id),u.once("signal",function(n){var r={info_hash:t.client._infoHash.toString("binary"),peer_id:t.client._peerId.toString("binary"),to_peer_id:e.peer_id,answer:n,offer_id:e.offer_id};t._trackerId&&(r.trackerid=t._trackerId),t._send(r)}),u.signal(e.offer),t.client.emit("peer",u)),e.answer&&(u=t._peers[e.offer_id],u?(u.id=o(e.peer_id),u.signal(e.answer),t.client.emit("peer",u)):s("got unexpected answer: "+JSON.stringify(e.answer)))}},i.prototype._announce=function(e){var t=this;return t.ready?void t._generateOffers(function(n){e=u({uploaded:0,downloaded:0,info_hash:t.client._infoHash.toString("binary"),peer_id:t.client._peerId.toString("binary"),offers:n},e),null!=t.client.torrentLength&&null==e.left&&(e.left=t.client.torrentLength-(e.downloaded||0)),t._trackerId&&(e.trackerid=t._trackerId),t._send(e)}):t._init(t._announce.bind(t,e))},i.prototype._send=function(e){var t=this;s("send %s",JSON.stringify(e)),t._socket.send(e)},i.prototype._generateOffers=function(e){function t(){var e=c(160),t=r._peers[e]=new h({initiator:!0,trickle:!1,config:r._opts.rtcConfig});t.once("signal",function(t){i.push({offer:t,offer_id:e}),n()})}function n(){i.length===r.client._numWant&&(s("generated %s offers",r.client._numWant),e(i))}var r=this,i=[];s("generating %s offers",r.client._numWant);for(var o=0;o<r.client._numWant;++o)t()},i.prototype.setInterval=function(e){var t=this;clearInterval(t._interval),t._intervalMs=e,e&&(t._interval=setInterval(t.update.bind(t),t._intervalMs))}}).call(this,e("buffer").Buffer)},{buffer:11,debug:44,events:15,"extend.js":51,hat:52,inherits:53,"simple-peer":73,"simple-websocket":76}],73:[function(e,t){function n(e){var t=this;return t instanceof n?(s.call(t),e=a({initiator:!1,stream:!1,config:n.config,constraints:n.constraints,channelName:e&&e.initiator?u(160):null,trickle:!0},e),a(t,e),o("new peer initiator: %s channelName: %s",t.initiator,t.channelName),t.destroyed=!1,t.ready=!1,t._pcReady=!1,t._channelReady=!1,t._dataStreams=[],t._iceComplete=!1,t._pc=new p(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),t._channel=null,t.stream&&t._setupVideo(t.stream),t._pc.onaddstream=t._onAddStream.bind(t),void(t.initiator?(t._setupData({channel:t._pc.createDataChannel(t.channelName)}),t._pc.onnegotiationneeded=h(function(){t._pc.createOffer(function(e){i(e),t._pc.setLocalDescription(e);var n=function(){t.emit("signal",t._pc.localDescription||e)};t.trickle||t._iceComplete?n():t.once("_iceComplete",n)},t._onError.bind(t))}),window.mozRTCPeerConnection&&setTimeout(function(){t._pc.onnegotiationneeded()},0)):t._pc.ondatachannel=t._setupData.bind(t))):new n(e)}function r(e){var t=this;l.Duplex.call(t,e),t._peer=e._peer,o("new stream")}function i(e){var t=e.sdp.split("b=AS:30");t.length>1&&(e.sdp=t[0]+"b=AS:1638400"+t[1])}t.exports=n;var o=e("debug")("simple-peer"),s=e("events").EventEmitter,a=e("extend.js"),u=e("hat"),c=e("inherits"),f=e("is-typedarray"),h=e("once"),l=e("stream"),d=e("typedarray-to-buffer"),p="undefined"!=typeof window&&(window.mozRTCPeerConnection||window.RTCPeerConnection||window.webkitRTCPeerConnection),g="undefined"!=typeof window&&(window.mozRTCSessionDescription||window.RTCSessionDescription||window.webkitRTCSessionDescription),m="undefined"!=typeof window&&(window.mozRTCIceCandidate||window.RTCIceCandidate||window.webkitRTCIceCandidate);c(n,s),n.config={iceServers:[{url:"stun:23.21.150.121"}]},n.constraints={},n.prototype.send=function(e,t){var n=this;return n._channelReady?(o("send %s",e),n._channel.send(f.strict(e)||e instanceof ArrayBuffer||e instanceof Blob||"string"==typeof e?e:JSON.stringify(e)),void(t&&t(null))):n.once("ready",n.send.bind(n,e,t))},n.prototype.signal=function(e){var t=this;if(!t.destroyed){if("string"==typeof e)try{e=JSON.parse(e)}catch(n){e={}}if(o("signal %s",JSON.stringify(e)),e.sdp&&t._pc.setRemoteDescription(new g(e),function(){var e="offer"===t._pc.remoteDescription.type;e&&t._pc.createAnswer(function(e){i(e),t._pc.setLocalDescription(e);var n=function(){t.emit("signal",t._pc.localDescription||e)};t.trickle||t._iceComplete?n():t.once("_iceComplete",n)},t._onError.bind(t))},t._onError.bind(t)),e.candidate)try{t._pc.addIceCandidate(new m(e.candidate))}catch(n){t.destroy(new Error("error adding candidate, "+n.message))}e.sdp||e.candidate||t.destroy(new Error("signal() called with invalid signal data"))}},n.prototype.destroy=function(e,t){var n=this;if(!n.destroyed){if(o("destroy (error: %s)",e&&e.message),n.destroyed=!0,n.ready=!1,"function"==typeof e&&(t=e,e=null),t&&n.once("close",t),n._pc){try{n._pc.close()}catch(e){}n._pc.oniceconnectionstatechange=null,n._pc.onsignalingstatechange=null,n._pc.onicecandidate=null}if(n._channel){try{n._channel.close()}catch(e){}n._channel.onmessage=null,n._channel.onopen=null,n._channel.onclose=null}n._pc=null,n._channel=null,n._dataStreams.forEach(function(t){e&&t.emit("error",e),t._readableState.ended||t.push(null),t._writableState.finished||t.end()}),n._dataStreams=[],e&&n.emit("error",e),n.emit("close")}},n.prototype.getDataStream=function(e){var t=this;if(t.destroyed)throw new Error("peer is destroyed");var n=new r(a({_peer:t},e));return t._dataStreams.push(n),n},n.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)},n.prototype._setupVideo=function(e){var t=this;t._pc.addStream(e)},n.prototype._onIceConnectionStateChange=function(){var e=this;if(!e.destroyed){var t=e._pc.iceGatheringState,n=e._pc.iceConnectionState;e.emit("iceConnectionStateChange",t,n),o("iceConnectionStateChange %s %s",t,n),("connected"===n||"completed"===n)&&(e._pcReady=!0,e._maybeReady()),("disconnected"===n||"closed"===n)&&e.destroy()}},n.prototype._maybeReady=function(){var e=this;o("maybeReady pc %s channel %s",e._pcReady,e._channelReady),!e.ready&&e._pcReady&&e._channelReady&&(o("ready"),e.ready=!0,e.emit("ready"))},n.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||(e.emit("signalingStateChange",e._pc.signalingState),o("signalingStateChange %s",e._pc.signalingState))},n.prototype._onIceCandidate=function(e){var t=this;t.destroyed||(e.candidate&&t.trickle?t.emit("signal",{candidate:e.candidate}):e.candidate||(t._iceComplete=!0,t.emit("_iceComplete")))},n.prototype._onChannelMessage=function(e){var t=this;if(!t.destroyed){var n=e.data;if(o("receive %s",n),n instanceof ArrayBuffer)n=d(new Uint8Array(n)),t.emit("message",n);else try{t.emit("message",JSON.parse(n))}catch(r){t.emit("message",n)}t._dataStreams.forEach(function(e){e.push(n)})}},n.prototype._onChannelOpen=function(){var e=this;e.destroyed||(e._channelReady=!0,e._maybeReady())},n.prototype._onChannelClose=function(){var e=this;e.destroyed||(e._channelReady=!1,e.destroy())},n.prototype._onAddStream=function(e){var t=this;t.destroyed||t.emit("stream",e.stream)},n.prototype._onError=function(e){var t=this;t.destroyed||(o("error %s",e.message),t.destroy(e))},c(r,l.Duplex),r.prototype.destroy=function(){var e=this;e._peer.destroy()},r.prototype._read=function(){},r.prototype._write=function(e,t,n){var r=this;r._peer.send(e,n)}},{debug:44,events:15,"extend.js":51,hat:52,inherits:53,"is-typedarray":74,once:56,stream:30,"typedarray-to-buffer":75}],74:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{dup:39}],75:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{buffer:11,dup:38,"is-typedarray":74}],76:[function(e,t){function n(e,t){return this instanceof n?(r.call(this),t||(t={}),this._url=e,this._reconnect=void 0!==t.reconnect?t.reconnect:s,void this._init()):new n(e,t) -}t.exports=n;var r=e("events").EventEmitter,i=e("inherits"),o=e("once"),s=5e3;i(n,r),n.prototype.send=function(e){this._ws&&this._ws.readyState===WebSocket.OPEN&&("object"==typeof e&&(e=JSON.stringify(e)),this._ws.send(e))},n.prototype.destroy=function(e){e&&this.once("close",e);try{this._ws.close()}catch(t){this._onclose()}},n.prototype._init=function(){this._errored=!1,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))},n.prototype._onopen=function(){this.emit("ready")},n.prototype._onerror=function(e){this._errored=!0,this.destroy(),this._reconnect?(this._timeout=setTimeout(this._init.bind(this),this._reconnect),this.emit("warning",e)):this.emit("error",e)},n.prototype._onmessage=function(e){var t=e.data;try{t=JSON.parse(e.data)}catch(n){}this.emit("message",t)},n.prototype._onclose=function(){clearTimeout(this._timeout),this._ws&&(this._ws.onopen=null,this._ws.onerror=null,this._ws.onmessage=null,this._ws.onclose=null),this._ws=null,this._errored||this.emit("close")}},{events:15,inherits:53,once:56}],77:[function(e,t){(function(n){var r=e("bencode"),i=e("bitfield"),o=e("events").EventEmitter,s=e("inherits"),a=e("simple-sha1"),u=1e7,c=1e3,f=16384;t.exports=function(e){function t(t){o.call(this),this._wire=t,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._fetching=!1,this._bitfield=new i(0,{grow:c}),n.isBuffer(e)&&this.setMetadata(e)}return s(t,o),t.prototype.name="ut_metadata",t.prototype.onHandshake=function(e){this._infoHash=e,this._infoHashHex=e.toString("hex")},t.prototype.onExtendedHandshake=function(e){return e.m&&e.m.ut_metadata?e.metadata_size?e.metadata_size>u?this.emit("warning",new Error("Peer gave maliciously large metadata size")):(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/f),this._remainingRejects=2*this._numPieces,void(this._fetching&&this._requestPieces())):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))},t.prototype.onMessage=function(e){var t,n;try{var i=e.toString(),o=i.indexOf("ee")+2;t=r.decode(i.substring(0,o)),n=e.slice(o)}catch(s){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece)}},t.prototype.fetch=function(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())},t.prototype.cancel=function(){this._fetching=!1},t.prototype.setMetadata=function(e){if(this._metadataComplete)return!0;try{var t=r.decode(e).info;t&&(e=r.encode(t))}catch(n){}return this._infoHashHex&&this._infoHashHex!==a.sync(e)?!1:(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",r.encode({info:r.decode(this.metadata)})),!0)},t.prototype._send=function(e,t){var i=r.encode(e);n.isBuffer(t)&&(i=n.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,n){var r={msg_type:1,piece:e};"number"==typeof n&&(r.total_size=n),this._send(r,t)},t.prototype._reject=function(e){this._send({msg_type:2,piece:e})},t.prototype._onRequest=function(e){if(!this._metadataComplete)return void this._reject(e);var t=e*f,n=t+f;n>this._metadataSize&&(n=this._metadataSize);var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)},t.prototype._onData=function(e,t){t.length>f||(t.copy(this.metadata,e*f),this._bitfield.set(e),this._checkDone())},t.prototype._onReject=function(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))},t.prototype._requestPieces=function(){this.metadata=new n(this._metadataSize);for(var e=0;e<this._numPieces;e++)this._request(e)},t.prototype._checkDone=function(){for(var e=!0,t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}if(e){var n=this.setMetadata(this.metadata);n||this._failedMetadata()}},t.prototype._failedMetadata=function(){this._bitfield=new i(0,{grow:c}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))},t}}).call(this,e("buffer").Buffer)},{bencode:78,bitfield:6,buffer:11,events:15,inherits:53,"simple-sha1":68}],78:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"./lib/decode":79,"./lib/encode":80,dup:35}],79:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{buffer:11,dup:36}],80:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:11,dup:37}],81:[function(e,t){(function(n){function r(e,t,n){this.swarm=e,this.stream=t,this.id=n;var r=this.wire=new f;this.timeout=null,this.handshaked=!1,this.paused=!0;var i=u(function(){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),r.once("end",i),r.once("close",i),r.once("error",i),r.once("finish",i),r.on("handshake",this._onHandshake.bind(this)),t.pipe(r).pipe(t)}function i(e,t,r){return this instanceof i?(s.call(this),r||(r={}),this.infoHash="string"==typeof e?new n(e,"hex"):e,this.infoHashHex=this.infoHash.toString("hex"),this.peerId="string"==typeof t?new n(t,"hex"):t,this.peerIdHex=this.peerId.toString("hex"),o("new swarm i %s p %s",this.infoHashHex,this.peerIdHex),this.handshake=r.handshake,this.maxPeers=r.maxPeers||h,this.downloaded=0,this.uploaded=0,this.downloadSpeed=c(),this.uploadSpeed=c(),this.wires=[],this._queue=[],this._peers={},this.paused=!1,void(this.destroyed=!1)):new i(e,t,r)}t.exports=i;var o=e("debug")("webtorrent-swarm"),s=e("events").EventEmitter,a=e("inherits"),u=e("once"),c=e("speedometer"),f=e("bittorrent-protocol"),h=30,l=25e3;r.prototype.destroy=function(){o("peer destroy"),this.stream&&this.stream.destroy(),this.wire&&this.wire.destroy(),this.timeout&&clearTimeout(this.timeout),this.stream=null,this.wire=null,this.timeout=null},r.prototype.handshake=function(){this.paused=!1,this.wire.handshake(this.swarm.infoHash,this.swarm.peerId,this.swarm.handshake),o("sent handshake i %s p %s",this.swarm.infoHashHex,this.swarm.peerIdHex),this.handshaked||(this.timeout=setTimeout(function(){this.destroy()}.bind(this),l))},r.prototype._onHandshake=function(e){var t=e.toString("hex");return o("got handshake %s",t),this.swarm.destroyed||t!==this.swarm.infoHashHex?this.destroy():(this.handshaked=!0,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),void this.swarm.emit("wire",this.wire))},a(i,s),Object.defineProperty(i.prototype,"ratio",{get:function(){return 0===this.downloaded?0:this.uploaded/this.downloaded}}),Object.defineProperty(i.prototype,"numQueued",{get:function(){return this._queue.length}}),Object.defineProperty(i.prototype,"numPeers",{get:function(){return this.wires.length}}),i.prototype.addPeer=function(e){if(!this.destroyed&&!this._peers[e.id]){var t=e.getDataStream(),n=new r(this,t,e.id);this._peers[e.id]=n,this._queue.push(n),this._drain()}},i.prototype.pause=function(){o("pause"),this.paused=!0},i.prototype.resume=function(){o("resume"),this.paused=!1,this._drain()},i.prototype.removePeer=function(e){o("removePeer %s",e),this._removePeer(e),this._drain()},i.prototype._removePeer=function(e){o("_removePeer %s",e),e.destroy()},i.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0,e&&this.once("close",e),o("destroy");for(var t in this._peers)this._removePeer(t);this.emit("close")}},i.prototype._drain=function(){if(!(this.paused||this.destroyed||this.numPeers>=this.maxPeers)){o("drain %s queued %s peers %s max",this.numQueued,this.numPeers,this.maxPeers);var e=this._queue.shift();e&&e.handshake()}}}).call(this,e("buffer").Buffer)},{"bittorrent-protocol":82,buffer:11,debug:44,events:15,inherits:53,once:56,speedometer:70}],82:[function(e,t){(function(n){function r(e,t,n,r){this.piece=e,this.offset=t,this.length=n,this.callback=r}function i(){return this instanceof i?(d.Duplex.call(this),c("new wire"),this.amChoking=!0,this.amInterested=!1,this.peerChoking=!0,this.peerInterested=!1,this.peerPieces=new a(0,{grow:p}),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=l(),this.downloadSpeed=l(),this._keepAlive=null,this._timeout=null,this._timeoutMs=0,this.destroyed=!1,this._finished=!1,this._buffer=[],this._bufferSize=0,this._parser=null,this._parserSize=0,this.on("finish",this._onfinish),void this._parseHandshake()):new i}function o(e,t,n,r){for(var i=0;i<e.length;i++){var o=e[i];if(o.piece===t&&o.offset===n&&o.length===r)return 0===i?e.shift():e.splice(i,1),o}return null}function s(e){try{return u.decode(e)}catch(t){console.warn(t)}}t.exports=i;var a=e("bitfield"),u=e("bencode"),c=e("debug")("bittorrent-protocol"),f=e("extend.js"),h=e("inherits"),l=e("speedometer"),d=e("stream"),p=4e5,g=new n("BitTorrent protocol"),m=new n([0,0,0,0]),y=new n([0,0,0,1,0]),v=new n([0,0,0,1,1]),_=new n([0,0,0,1,2]),w=new n([0,0,0,1,3]),b=[0,0,0,0,0,0,0,0],k=[0,0,0,3,9,0,0];h(i,d.Duplex),i.prototype.setKeepAlive=function(e){clearInterval(this._keepAlive),e!==!1&&(this._keepAlive=setInterval(this._push.bind(this,m),6e4))},i.prototype.setTimeout=function(e){this._clearTimeout(),this._timeoutMs=e,this._updateTimeout()},i.prototype.destroy=function(){this.destroyed=!0,this.end()},i.prototype.end=function(){this._onUninterested(),this._onChoke(),d.Duplex.prototype.end.apply(this,arguments)},i.prototype.use=function(e){function t(){}var n=e.prototype.name;if(!n)throw new Error("Extension API requires a named function, e.g. function name() {}");var r=this._nextExt,i=new e(this);"function"!=typeof i.onHandshake&&(i.onHandshake=t),"function"!=typeof i.onExtendedHandshake&&(i.onExtendedHandshake=t),"function"!=typeof i.onMessage&&(i.onMessage=t),this.extendedMapping[r]=n,this._ext[n]=i,this[n]=i,this._nextExt+=1},i.prototype.handshake=function(e,t,r){if("string"==typeof e&&(e=new n(e,"hex")),"string"==typeof t&&(t=new n(t,"hex")),20!==e.length||20!==t.length)throw new Error("infoHash and peerId MUST have length 20");var i=new n(b);i[5]|=16,r&&r.dht&&(i[7]|=1),this._push(n.concat([g,i,e,t]))},i.prototype.choke=function(){if(!this.amChoking){for(this.amChoking=!0;this.peerRequests.length;)this.peerRequests.pop();this._push(y)}},i.prototype.unchoke=function(){this.amChoking&&(this.amChoking=!1,this._push(v))},i.prototype.interested=function(){this.amInterested||(this.amInterested=!0,this._push(_))},i.prototype.uninterested=function(){this.amInterested&&(this.amInterested=!1,this._push(w))},i.prototype.have=function(e){this._message(4,[e],null)},i.prototype.bitfield=function(e){n.isBuffer(e)||(e=e.buffer),this._message(5,[],e)},i.prototype.request=function(e,t,n,i){return i||(i=function(){}),this._finished?i(new Error("wire is closed")):this.peerChoking?i(new Error("peer is choking")):(this.requests.push(new r(e,t,n,i)),this._updateTimeout(),void this._message(6,[e,t,n],null))},i.prototype.piece=function(e,t,n){this.uploaded+=n.length,this.uploadSpeed(n.length),this.emit("upload",n.length),this._message(7,[e,t],n)},i.prototype.cancel=function(e,t,n){this._callback(o(this.requests,e,t,n),new Error("request was cancelled"),null),this._message(8,[e,t,n],null)},i.prototype.port=function(e){var t=new n(k);t.writeUInt16BE(e,5),this._push(t)},i.prototype.extended=function(e,t){if("string"==typeof e&&this.peerExtendedMapping[e]&&(e=this.peerExtendedMapping[e]),"number"!=typeof e)throw new Error("Unrecognized extension: "+e);var r=new n([e]),i=n.isBuffer(t)?t:u.encode(t);this._message(20,[],n.concat([r,i]))},i.prototype._onKeepAlive=function(){this.emit("keep-alive")},i.prototype._onHandshake=function(e,t,n){this.peerId=t,this.peerExtensions=n,this.emit("handshake",e,t,n);var r;for(r in this._ext)this._ext[r].onHandshake(e,t,n);if(n.extended){var i=f({},this.extendedHandshake);i.m={};for(var o in this.extendedMapping)r=this.extendedMapping[o],i.m[r]=Number(o);this.extended(0,u.encode(i))}},i.prototype._onChoke=function(){for(this.peerChoking=!0,this.emit("choke");this.requests.length;)this._callback(this.requests.shift(),new Error("peer is choking"),null)},i.prototype._onUnchoke=function(){this.peerChoking=!1,this.emit("unchoke")},i.prototype._onInterested=function(){this.peerInterested=!0,this.emit("interested")},i.prototype._onUninterested=function(){this.peerInterested=!1,this.emit("uninterested")},i.prototype._onHave=function(e){this.peerPieces.get(e)||(this.peerPieces.set(e,!0),this.emit("have",e))},i.prototype._onBitField=function(e){this.peerPieces=new a(e),this.emit("bitfield",this.peerPieces)},i.prototype._onRequest=function(e,t,n){if(!this.amChoking){var i=function(r,i){s===o(this.peerRequests,e,t,n)&&(r||this.piece(e,t,i))}.bind(this),s=new r(e,t,n,i);this.peerRequests.push(s),this.emit("request",e,t,n,i)}},i.prototype._onPiece=function(e,t,n){this._callback(o(this.requests,e,t,n.length),null,n),this.downloaded+=n.length,this.downloadSpeed(n.length),this.emit("download",n.length),this.emit("piece",e,t,n)},i.prototype._onCancel=function(e,t,n){o(this.peerRequests,e,t,n),this.emit("cancel",e,t,n)},i.prototype._onPort=function(e){this.emit("port",e)},i.prototype._onExtended=function(e,t){var n,r;if(0===e&&(n=s(t))){if(this.peerExtendedHandshake=n,"object"==typeof n.m)for(r in n.m)this.peerExtendedMapping[r]=Number(n.m[r].toString());for(r in this._ext)this.peerExtendedMapping[r]&&this._ext[r].onExtendedHandshake(this.peerExtendedHandshake);this.emit("extended","handshake",this.peerExtendedHandshake)}else this.extendedMapping[e]&&(e=this.extendedMapping[e],this._ext[e]&&this._ext[e].onMessage(t)),this.emit("extended",e,t)},i.prototype._onTimeout=function(){this._callback(this.requests.shift(),new Error("request has timed out"),null),this.emit("timeout")},i.prototype._push=function(e){return this._finished?void 0:this.push(e)},i.prototype._write=function(e,t,r){for(this._bufferSize+=e.length,this._buffer.push(e);this._bufferSize>=this._parserSize;){var i=1===this._buffer.length?this._buffer[0]:n.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[i.slice(this._parserSize)]:[],this._parser(i.slice(0,this._parserSize))}r(null)},i.prototype._read=function(){},i.prototype._callback=function(e,t,n){e&&(this._clearTimeout(),this.peerChoking||this._finished||this._updateTimeout(),e.callback(t,n))},i.prototype._clearTimeout=function(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)},i.prototype._updateTimeout=function(){this._timeoutMs&&this.requests.length&&!this._timeout&&(this._timeout=setTimeout(this._onTimeout.bind(this),this._timeoutMs))},i.prototype._parse=function(e,t){this._parserSize=e,this._parser=t},i.prototype._message=function(e,t,r){var i=r?r.length:0,o=new n(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),r&&this._push(r)},i.prototype._onmessagelength=function(e){var t=e.readUInt32BE(0);t>0?this._parse(t,this._onmessage):(this._onKeepAlive(),this._parse(4,this._onmessagelength))},i.prototype._onmessage=function(e){switch(this._parse(4,this._onmessagelength),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))}this.emit("unknownmessage",e)},i.prototype._parseHandshake=function(){this._parse(1,function(e){var t=e.readUInt8(0);this._parse(t+48,function(e){var n=e.slice(0,t);return"BitTorrent protocol"!==n.toString()?(c("Error: wire not speaking BitTorrent protocol (%s)",n.toString()),void this.end()):(e=e.slice(t),this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(1&e[7]),extended:!!(16&e[5])}),void this._parse(4,this._onmessagelength))}.bind(this))}.bind(this))},i.prototype._onfinish=function(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAlive),this._parse(Number.MAX_VALUE,function(){}),this.peerRequests=[];this.requests.length;)this._callback(this.requests.shift(),new Error("wire was closed"),null)}}).call(this,e("buffer").Buffer)},{bencode:83,bitfield:6,buffer:11,debug:44,"extend.js":51,inherits:53,speedometer:70,stream:30}],83:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"./lib/decode":84,"./lib/encode":85,dup:35}],84:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{buffer:11,dup:36}],85:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:11,dup:37}],86:[function(e,t){t.exports=function n(e,t){return void 0===t?function(t){return n(e,t)}:(e-=t.toString().length,e>0?new Array(e+(/\./.test(t)?2:1)).join("0")+t:t+"")}},{}],87:[function(e,t){(function(n,r){function i(e){function t(){o.ready=!0,o.emit("ready")}var o=this;return o instanceof i?(e||(e={}),u.call(o),s.enabled||o.setMaxListeners(0),o.torrentPort=e.torrentPort||0,o.tracker=void 0!==e.tracker?e.tracker:!0,o.rtcConfig=e.rtcConfig,o.torrents=[],o.downloadSpeed=g(),o.uploadSpeed=g(),o.storage="function"==typeof e.storage?e.storage:e.storage!==!1&&"function"==typeof y?y:v,o.peerId=void 0===e.peerId?new r("-WW"+w+"-"+f(48),"utf8"):"string"==typeof e.peerId?new r(e.peerId,"hex"):e.peerId,o.peerIdHex=o.peerId.toString("hex"),o.nodeId=void 0===e.nodeId?new r(f(160),"hex"):"string"==typeof e.nodeId?new r(e.nodeId,"hex"):e.nodeId,o.nodeIdHex=o.nodeId.toString("hex"),e.dht!==!1&&"function"==typeof a&&(o.dht=new a(c({nodeId:o.nodeId},e.dht)),o.dht.listen(e.dhtPort)),s("new webtorrent (peerId %s, nodeId %s)",o.peerIdHex,o.nodeIdHex),void("function"==typeof l?l(e.blocklist,{headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,n){o.blocked=n,t()}):n.nextTick(t))):new i(e)}t.exports=i;var o=e("create-torrent"),s=e("debug")("webtorrent"),a=e("bittorrent-dht/client"),u=e("events").EventEmitter,c=e("extend.js"),f=e("hat"),h=e("inherits"),l=e("load-ip-set"),d=e("run-parallel"),p=e("parse-torrent"),g=e("speedometer"),m=e("zero-fill"),y=e("./lib/fs-storage"),v=e("./lib/storage"),_=e("./lib/torrent");h(i,u);var w=(e("./package.json").version||"0.25.0").match(/([0-9]+)/g).slice(0,2).map(m(2)).join("");Object.defineProperty(i.prototype,"ratio",{get:function(){var e=this,t=e.torrents.reduce(function(e,t){return e+t.uploaded},0),n=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/n}}),i.prototype.get=function(e){var t=this,n=p(e);if(!n||!n.infoHash)return null;for(var r=0,i=t.torrents.length;i>r;r++){var o=t.torrents[r];if(o.infoHash===n.infoHash)return o}return null},i.prototype.add=i.prototype.download=function(e,t,n){function r(e){o.infoHash===e.infoHash&&(n(o),i.removeListener("torrent",r))}var i=this;s("add %s",e),"function"==typeof t&&(n=t,t={}),t||(t={}),t.client=i,t.storage=t.storage||i.storage,t.storageOpts||(t.storageOpts={}),t.tmp&&(t.storageOpts.tmp=t.tmp);var o=new _(e,c({client:i},t));return i.torrents.push(o),n&&i.on("torrent",r),o.on("error",function(e){i.emit("error",e,o)}),o.on("listening",function(e){i.emit("listening",e,o)}),o.on("ready",function(){s("torrent"),i.emit("torrent",o)}),o},i.prototype.seed=function(e,t,n){var r=this;"function"==typeof t&&(n=t,t={}),t||(t={}),t.storageOpts||(t.storageOpts={}),t.storageOpts.noVerify=!0,o.parseInput(e,t,function(i,s){if(i)return r.emit("error",i);var a=s.map(function(e){return e.getStream});o(e,t,function(e,i){return e?r.emit("error",e):void r.add(i,t,function(e){var t=[function(t){e.storage.load(a,t)}];r.dht&&t.push(function(t){e.on("dhtAnnounce",t)}),d(t,function(t){return t?r.emit("error",t):(n&&n(e),void r.emit("seed",e))})})})})},i.prototype.remove=function(e,t){var n=this,r=n.get(e);if(!r)throw new Error("No torrent with id "+e);s("remove"),n.torrents.splice(n.torrents.indexOf(r),1),r.destroy(t)},i.prototype.destroy=function(e){var t=this;s("destroy");var n=t.torrents.map(function(e){return function(n){t.remove(e.infoHash,n)}});t.dht&&n.push(function(e){t.dht.destroy(e)}),d(n,e)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/fs-storage":10,"./lib/storage":3,"./lib/torrent":4,"./package.json":10,_process:18,"bittorrent-dht/client":10,buffer:11,"create-torrent":34,debug:44,events:15,"extend.js":51,hat:52,inherits:53,"load-ip-set":10,"parse-torrent":57,"run-parallel":67,speedometer:70,"zero-fill":86}]},{},[87])(87)});
\ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.WebTorrent=e()}}(function(){return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t){function n(e,t){var i=this;if(!(i instanceof n))return new n(e,t);s.Readable.call(i,t),r("new filestream %s",JSON.stringify(t)),t||(t={}),t.start||(t.start=0),t.end||(t.end=e.length-1),i.length=t.end-t.start+1;var a=t.start+e.offset,u=t.pieceLength;i.startPiece=a/u|0,i.endPiece=(t.end+e.offset)/u|0,i._extname=o.extname(e.name),i._storage=e.storage,i._piece=i.startPiece,i._missing=i.length,i._reading=!1,i._notifying=!1,i._destroyed=!1,i._criticalLength=Math.min(1048576/u|0,2),i._offset=a-i.startPiece*u}t.exports=n;var r=e("debug")("webtorrent:file-stream"),i=e("inherits"),o=e("path"),s=e("stream"),a=e("./video-stream");i(n,s.Readable),n.prototype._read=function(){r("_read");var e=this;e._reading||(e._reading=!0,e.notify())},n.prototype.notify=function(){r("notify");var e=this;if(e._reading&&0!==e._missing){if(!e._storage.bitfield.get(e._piece))return e._storage.emit("critical",e._piece,e._piece+e._criticalLength);if(!e._notifying){e._notifying=!0;var t=e._piece;r("before read %s",t),e._storage.read(e._piece++,function(n,i){if(r("after read %s (buffer.length %s) (err %s)",t,i.length,n&&n.message||n),e._notifying=!1,!e._destroyed){if(n)return e._storage.emit("error",n),e.destroy(n);e._offset&&(i=i.slice(e._offset),e._offset=0),e._missing<i.length&&(i=i.slice(0,e._missing)),e._missing-=i.length,r("pushing buffer of length %s",i.length),e._reading=!1,e.push(i),0===e._missing&&e.push(null)}})}}},n.prototype.pipe=function(e){var t=this,n=s.Readable.prototype.pipe;if(!e||"VIDEO"!==e.nodeName&&"AUDIO"!==e.nodeName)return n.call(t,e);var r=".webm"===t._extname?'video/webm; codecs="vorbis,vp8"':".mp4"===t._extname?'video/mp4; codecs="avc1.42c01e,mp4a.40.2"':".mp3"===t._extname?"audio/mpeg":void 0;return n.call(t,new a(e,{type:r}))},n.prototype.destroy=function(){var e=this;e._destroyed||(e._destroyed=!0)}},{"./video-stream":5,debug:44,inherits:53,path:17,stream:30}],2:[function(e,t){function n(e,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)})}var r=this;r.swarm=e,r.numPieces=t,r.swarm.wires.forEach(n),r.swarm.on("wire",function(e){r.recalculate(),n(e)}),r.recalculate()}t.exports=n,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 n=0;n<e.numPieces;++n)e.pieces[n]+=t.peerPieces.get(n)})},n.prototype.getRarestPiece=function(e){var t=this,n=[],r=1/0;e=e||function(){return!0};for(var i=0;i<t.numPieces;++i)if(e(i)){var o=t.pieces[i];o===r?n.push(i):r>o&&(n=[i],r=o)}return n.length>0?n[Math.random()*n.length|0]:-1}},{}],3:[function(e,t){(function(n,r){function i(){}function o(e,t,n,r){var i=this;d.call(i),f.enabled||i.setMaxListeners(0),i.index=e,i.hash=t,i.noVerify=!!r,"number"==typeof n?(i.buffer=null,i.length=n):(i.buffer=n,i.length=n.length),i._reset()}function s(e,t,n,r){var i=this;d.call(i),f.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=n,i.pieceLength=r,i.done=!1,i.pieces.forEach(function(e){e.on("done",function(){i._checkDone()})}),i._checkDone()}function a(e,t){var n=this;d.call(n),f.enabled||n.setMaxListeners(0),t=t||{},n.bitfield=new u(e.pieces.length),n.done=!1,n.closed=!1,n.readonly=!0,t.nobuffer||(n.buffer=new r(e.length));var i=n.pieceLength=e.pieceLength,a=e.lastPieceLength,c=e.pieces.length;n.pieces=e.pieces.map(function(e,r){var s=r*i,u=s+(r===c-1?a:i),f=n.buffer?n.buffer.slice(s,u):u-s,h=new o(r,e,f,!!t.noVerify);return h.on("done",n._onPieceDone.bind(n,h)),h}),n.files=e.files.map(function(e){var t=e.offset,r=t+e.length-1,o=t/i|0,a=r/i|0,u=n.pieces.slice(o,a+1),c=new s(n,e,u,i);return c.on("done",n._onFileDone.bind(n,c)),c})}t.exports=a;var u=e("bitfield"),c=e("block-stream"),f=e("debug")("webtorrent:storage"),h=e("dezalgo"),l=e("end-of-stream"),d=e("events").EventEmitter,p=e("extend.js"),g=e("./file-stream"),m=e("inherits"),y=e("multistream"),v=e("once"),_=e("simple-sha1"),w=16384,b=0,k=1,E=2;m(o,d),o.prototype.readBlock=function(e,t,n){var r=this;return n=h(n),r.buffer&&r._verifyOffset(e)?void n(null,r.buffer.slice(e,e+t)):n(new Error("invalid block offset "+e))},o.prototype.writeBlock=function(e,t,n){var r=this;if(n=h(n),!r._verifyOffset(e)||!r._verifyBlock(e,t))return n(new Error("invalid block "+e+":"+t.length));r._lazyAllocBuffer();var i=e/w;return r.blocks[i]===E?n(null):(t.copy(r.buffer,e),r.blocks[i]=E,r.blocksWritten+=1,r.blocksWritten===r.blocks.length&&r.verify(),void n(null))},o.prototype.reserveBlock=function(e){for(var t=this,n=t.blocks.length,r=0;n>r;r++)if((!t.blocks[r]||e)&&t.blocks[r]!==E)return t.blocks[r]=k,{offset:r*w,length:r===n-1?t.length-r*w:w};return null},o.prototype.cancelBlock=function(e){var t=this;if(!t.buffer||!t._verifyOffset(e))return!1;var n=e/w;return t.blocks[n]===k&&(t.blocks[n]=b),!0},o.prototype._reset=function(){var e=this;e.verified=!1,e.blocks=new r(Math.ceil(e.length/w)),e.blocks.fill(0),e.blocksWritten=0},o.prototype.verify=function(e){function t(){n.verified?n.emit("done"):(n.emit("warning",new Error("piece "+n.index+" failed verification; "+r+" expected "+n.hash)),n._reset())}var n=this;if(e=e||n.buffer,!n.verified&&e){if(n.noVerify)return n.verified=!0,void t();var r;_(e,function(e){r=e,n.verified=r===n.hash,t()})}},o.prototype._verifyOffset=function(e){var t=this;return e%w===0?!0:(t.emit("warning",new Error("piece "+t.index+" invalid offset "+e+" not multiple of "+w+" bytes")),!1)},o.prototype._verifyBlock=function(e,t){var n=this;return t.length===w?!0:t.length===n.length-e&&n.length-e<w?!0:(n.emit("warning",new Error("piece "+n.index+" invalid block of size "+t.length+" bytes")),!1)},o.prototype._lazyAllocBuffer=function(){var e=this;e.buffer||(e.buffer=new r(e.length))},m(s,d),s.prototype.select=function(){var e=this;e.pieces.length>0&&e.storage.emit("select",e.pieces[0].index,e.pieces[e.pieces.length-1].index,!1)},s.prototype.deselect=function(){var e=this;e.pieces.length>0&&e.storage.emit("deselect",e.pieces[0].index,e.pieces[e.pieces.length-1].index,!1)},s.prototype.createReadStream=function(e){var t=this;e=p({pieceLength:t.pieceLength},e);var n=new g(t,e);return t.storage.emit("select",n.startPiece,n.endPiece,!0,n.notify.bind(n)),l(n,function(){t.storage.emit("deselect",n.startPiece,n.endPiece,!0)}),n},s.prototype.getBlobURL=function(e){var t=this;t.getBuffer(function(t,n){if(t)return e(t);var r=URL.createObjectURL(new Blob([n]));e(null,r)})},s.prototype.getBuffer=function(e){var t=this,n=new r(t.length),i=0;t.createReadStream().on("data",function(e){e.copy(n,i),i+=e.length}).on("end",function(){e(null,n)})},s.prototype._checkDone=function(){var e=this;e.done=e.pieces.every(function(e){return e.verified}),e.done&&n.nextTick(function(){e.emit("done")})},m(a,d),a.BLOCK_LENGTH=w,a.prototype.load=function(e,t){var n=this;Array.isArray(e)||(e=[e]),t=v(t||function(){}),n.once("done",function(){t(null)});var r=0;new y(e).pipe(new c(n.pieceLength,{nopad:!0})).on("data",function(e){var t=r;r+=1;var i=0,o=new c(w,{nopad:!0});o.on("data",function(e){var r=i*w;i+=1,n.writeBlock(t,r,e)}),o.end(e)}).on("error",t)},Object.defineProperty(a.prototype,"downloaded",{get:function(){var e=this;return e.pieces.reduce(function(e,t){return e+(t.verified?t.length:t.blocksWritten*w)},0)}}),Object.defineProperty(a.prototype,"numMissing",{get:function(){for(var e=this,t=e.pieces.length,n=0,r=e.pieces.length;r>n;n++)t-=e.bitfield.get(n);return t}}),a.prototype.readBlock=function(e,t,n,r){var i=this;r=h(r);var o=i.pieces[e];return o?void o.readBlock(t,n,r):r(new Error("invalid piece index "+e))},a.prototype.writeBlock=function(e,t,n,r){var o=this;if(r||(r=i),r=h(r),o.readonly)return r(new Error("cannot write to readonly storage"));var s=o.pieces[e];return s?void s.writeBlock(t,n,r):r(new Error("invalid piece index "+e))},a.prototype.read=function(e,t,n,i){function o(){if(0>=c)return n(null,r.concat(f));var t=u,i=Math.min(w,c);u+=i,c-=i,s.readBlock(e,t,i,function(e,t){return e?n(e):(f.push(t),void o())})}var s=this;"function"==typeof t&&(i=n,n=t,t=null),n=h(n);var a=s.pieces[e];if(!a)return n(new Error("invalid piece index "+e));if(!a.verified&&!i)return n(new Error("Storage.read called on incomplete piece "+e));var u=0,c=a.length;if(t&&(u=t.offset||0,c=t.length||c),a.buffer)return n(null,a.buffer.slice(u,u+c));var f=[];o()},a.prototype.reserveBlock=function(e,t){var n=this,r=n.pieces[e];return r?r.reserveBlock(t):null},a.prototype.cancelBlock=function(e,t){var n=this,r=n.pieces[e];return r?r.cancelBlock(t):!1},a.prototype.remove=function(e){e&&h(e)(null)},a.prototype.close=function(e){var t=this;t.closed=!0,e&&h(e)(null)},a.prototype._onPieceDone=function(e){var t=this;t.bitfield.set(e.index),f("piece done "+e.index+" ("+t.numMissing+" still missing)"),t.emit("piece",e)},a.prototype._onFileDone=function(e){var t=this;f("file done "+e.name),t.emit("file",e),t._checkDone()},a.prototype._checkDone=function(){var e=this;!e.done&&e.files.every(function(e){return e.done})&&(e.done=!0,e.emit("done"))}}).call(this,e("_process"),e("buffer").Buffer)},{"./file-stream":1,_process:18,bitfield:6,"block-stream":7,buffer:11,debug:44,dezalgo:47,"end-of-stream":50,events:15,"extend.js":51,inherits:53,multistream:54,once:56,"simple-sha1":68}],4:[function(e,t){(function(n){function r(){}function i(e,t){function r(e){i.parsedTorrent=m(e),i.infoHash=i.parsedTorrent.infoHash,i.parsedTorrent.name&&(i.name=i.parsedTorrent.name),i.swarm=new v(i.infoHash,i.client.peerId,{handshake:{dht:!!i.client.dht}}),y(i.swarm,i,["warning","error"]),i.swarm.on("wire",i._onWire.bind(i)),i.swarm.on("download",i.client.downloadSpeed.bind(i.client)),i.swarm.on("upload",i.client.uploadSpeed.bind(i.client)),n.browser?i._onSwarmListening():i.swarm.listen(i.client.torrentPort,i._onSwarmListening.bind(i)),n.nextTick(function(){i.emit("infoHash")})}var i=this;h.call(i),c.enabled||i.setMaxListeners(0),c("new torrent"),i.client=t.client,i.hotswapEnabled="hotswap"in t?t.hotswap:!0,i.verify=t.verify,i.storageOpts=t.storageOpts,i.chokeTimeout=t.chokeTimeout||I,i.pieceTimeout=t.pieceTimeout||S,i.strategy=t.strategy||"sequential",i._rechokeNumSlots=t.uploads===!1||0===t.uploads?0:+t.uploads||10,i._rechokeOptimisticWire=null,i._rechokeOptimisticTime=0,i._rechokeIntervalId=null,i.ready=!1,i.files=[],i.metadata=null,i.parsedTorrent=null,i.storage=null,i.numBlockedPeers=0,i._amInterested=!1,i._destroyed=!1,i._selections=[],i._critical=[],i._storageImpl=t.storage||E;var o=e&&e.parsedTorrent||m(e);if(o&&o.infoHash)r(o);else if("function"==typeof d&&/^https?:/.test(e))d.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,t){return e?i.emit("error",new Error("error downloading torrent: "+e.message)):void r(t)});else{if("function"!=typeof l.readFile)throw new Error("invalid torrent id");l.readFile(e,function(e,t){return e?i.emit("error",new Error("invalid torrent id")):void r(t)})}}function o(e,t){return Math.ceil(2+t*e.downloadSpeed()/E.BLOCK_LENGTH)}function s(e){return Math.random()*e|0}function a(e,t){for(var n=e.map(function(e,t){return t}),r=n.length-1;r>0;--r){var i=s(r+1),o=n[r];n[r]=n[i],n[i]=o}n.forEach(function(n){t(e[n],n,e)})}t.exports=i;var u=e("addr-to-ip-port"),c=e("debug")("webtorrent:torrent"),f=e("torrent-discovery"),h=e("events").EventEmitter,l=e("fs"),d=e("simple-get"),p=e("inherits"),g=e("run-parallel"),m=e("parse-torrent"),y=e("re-emitter"),v=e("bittorrent-swarm"),_=e("ut_metadata"),w=e("ut_pex"),b=e("./rarity-map"),k=e("./server"),E=e("./storage"),x=131072,S=1e4,I=5e3,A=3*E.BLOCK_LENGTH,L=.5,B=1,T=1e4,R=2;p(i,h),Object.defineProperty(i.prototype,"length",{get:function(){return this.parsedTorrent&&this.parsedTorrent.length||0}}),Object.defineProperty(i.prototype,"timeRemaining",{get:function(){return 0===this.swarm.downloadSpeed()?1/0:(this.length-this.downloaded)/this.swarm.downloadSpeed()*1e3}}),Object.defineProperty(i.prototype,"progress",{get:function(){return this.parsedTorrent&&this.downloaded/this.parsedTorrent.length||0}}),Object.defineProperty(i.prototype,"downloaded",{get:function(){return this.storage&&this.storage.downloaded||0}}),Object.defineProperty(i.prototype,"uploaded",{get:function(){return this.swarm.uploaded}}),Object.defineProperty(i.prototype,"ratio",{get:function(){return this.uploaded&&this.downloaded/this.uploaded||0}}),Object.defineProperty(i.prototype,"magnetURI",{get:function(){return m.toMagnetURI(this.parsedTorrent)}}),i.prototype._onSwarmListening=function(e){var t=this;t._destroyed||(t.client.torrentPort=e,t.discovery=new f({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)),y(t.discovery,t,["dhtAnnounce","warning","error"]),t.parsedTorrent.info&&t._onMetadata(t.parsedTorrent),t.emit("listening",e))},i.prototype._onMetadata=function(e){var t=this;if(!t.metadata&&!t._destroyed){if(c("got metadata"),e&&e.infoHash)t.metadata=m.toTorrentFile(e),t.parsedTorrent=e;else{t.metadata=e;try{t.parsedTorrent=m(t.metadata)}catch(r){return t.emit("error",r)}}t.name=t.parsedTorrent.name,t.discovery.setTorrent(t.parsedTorrent),t.rarityMap=new b(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(){t.discovery.tracker&&t.discovery.tracker.complete(),c("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){e.ut_metadata&&e.ut_metadata.setMetadata(t.metadata),t._onWireWithMetadata(e)}),n.nextTick(t.verify?function(){c("verifying existing torrent data");var e=0,n=0;g(t.storage.pieces.map(function(r){return function(i){t.storage.read(r.index,function(o,s){e+=1,t.emit("verifying",{percentDone:100*e/t.storage.pieces.length,percentVerified:100*n/t.storage.pieces.length}),!o&&s&&(r.verify(s),n+=r.verified,c("piece "+(r.verified?"verified":"invalid")+" "+r.index)),i()},!0)}}),t._onStorage.bind(t))}:t._onStorage.bind(t)),n.nextTick(function(){t.emit("metadata")})}},i.prototype.destroy=function(e){var t=this;c("destroy"),t._destroyed=!0,clearInterval(t._rechokeIntervalId);var n=[];t.swarm&&n.push(function(e){t.swarm.destroy(e)}),t.discovery&&n.push(function(e){t.discovery.stop(e)}),t.storage&&n.push(function(e){t.storage.close(e)}),g(n,e)},i.prototype.addPeer=function(e){var t=this;return"string"==typeof e&&t.client.blocked&&t.client.blocked.contains(u(e)[0])?(t.numBlockedPeers+=1,t.emit("blocked-peer",e),!1):(t.emit("peer",e),t.swarm.addPeer(e),!0)},i.prototype.select=function(e,t,n,i){var o=this;if(e>t||0>e||t>=o.storage.pieces.length)throw new Error("invalid selection ",e,":",t);n=Number(n)||0,c("select %s-%s (priority %s)",e,t,n),o._selections.push({from:e,to:t,offset:0,priority:n,notify:i||r}),o._selections.sort(function(e,t){return t.priority-e.priority}),o._updateSelections()},i.prototype.deselect=function(e,t,n){var r=this;n=Number(n)||0,c("deselect %s-%s (priority %s)",e,t,n);for(var i=0;i<r._selections.length;++i){var o=r._selections[i];if(o.from===e&&o.to===t&&o.priority===n){r._selections.splice(i--,1);break}}r._updateSelections()},i.prototype.critical=function(e,t){var n=this;c("critical %s-%s",e,t);for(var r=e;t>=r;++r)n._critical[r]=!0;n._updateSelections()},i.prototype._onWire=function(e){var t=this;e.use(_(t.metadata)),t.metadata||(e.ut_metadata.on("metadata",function(e){c("got metadata via ut_metadata"),t._onMetadata(e)}),e.ut_metadata.fetch()),"function"==typeof w&&e.use(w()),e.ut_pex&&e.ut_pex.on("peer",function(e){c("got peer via ut_pex "+e),t.addPeer(e)}),e.ut_pex&&e.ut_pex.on("dropped",function(e){e in t.swarm._peers||t.swarm.removePeer(e)}),e.setKeepAlive(!0),e.peerExtensions.dht&&t.client.dht&&t.client.dht.port&&e.port(t.client.dht.port),e.on("port",function(){c("port message from "+e.remoteAddress)}),e.on("timeout",function(){c("wire timeout from "+e.remoteAddress),e.destroy()}),e.setTimeout(t.pieceTimeout),t.metadata&&t._onWireWithMetadata(e)},i.prototype._onWireWithMetadata=function(e){function t(){r._destroyed||e._destroyed||(r.swarm.numQueued>2*(r.swarm.numConns-r.swarm.numPeers)&&e.amInterested?e.destroy():i=setTimeout(t,o))}function n(){if(e.peerPieces.length===r.storage.pieces.length){for(;s<r.storage.pieces.length;++s)if(!e.peerPieces.get(s))return;e.isSeeder=!0,e.choke()}}var r=this,i=null,o=r.chokeTimeout,s=0;e.on("bitfield",function(){n(),r._update()}),e.on("have",function(){n(),r._update()}),e.once("interested",function(){e.unchoke()}),e.on("close",function(){clearTimeout(i)}),e.on("choke",function(){clearTimeout(i),i=setTimeout(t,o)}),e.on("unchoke",function(){clearTimeout(i),r._update()}),e.on("request",function(t,n,i,o){return i>x?(c(e.remoteAddress,"requested invalid block size",i),e.destroy()):void r.storage.readBlock(t,n,i,o)}),e.bitfield(r.storage.bitfield),e.interested(),i=setTimeout(t,o),e.isSeeder=!1,n()},i.prototype._onStorage=function(){var e=this;c("on storage"),e.storage.readonly=!1,e.select(0,e.storage.pieces.length-1,!1),e._rechokeIntervalId=setInterval(e._rechoke.bind(e),T),e._rechokeIntervalId.unref&&e._rechokeIntervalId.unref(),n.nextTick(function(){e.ready=!0,e.emit("ready")})},i.prototype._onStoragePiece=function(e){var t=this;c("piece done %s",e.index),t._reservations[e.index]=null,t.swarm.wires.forEach(function(t){t.have(e.index)}),t._gcSelections()},i.prototype._updateSelections=function(){var e=this;if(e.swarm&&!e._destroyed){if(!e.metadata)return e.once("metadata",e._updateSelections.bind(e));n.nextTick(e._gcSelections.bind(e)),e._updateInterest(),e._update()}},i.prototype._gcSelections=function(){for(var e=this,t=0;t<e._selections.length;t++){for(var n=e._selections[t],r=n.offset;e.storage.bitfield.get(n.from+n.offset)&&n.from+n.offset<n.to;)n.offset++;r!==n.offset&&n.notify(),n.to===n.from+n.offset&&e.storage.bitfield.get(n.from+n.offset)&&(e._selections.splice(t--,1),n.notify(),e._updateInterest())}e._selections.length||e.emit("idle")},i.prototype._updateInterest=function(){var e=this,t=e._amInterested;e._amInterested=!!e._selections.length,e.swarm.wires.forEach(function(t){e._amInterested?t.interested():t.uninterested()}),t!==e._amInterested&&e.emit(e._amInterested?"interested":"uninterested")},i.prototype._update=function(){var e=this;e._destroyed||a(e.swarm.wires,e._updateWire.bind(e))},i.prototype._updateWire=function(e){function t(t,n,r,i){return function(o){return o>=t&&n>=o&&!(o in r)&&e.peerPieces.get(o)&&(!i||i(o))}}function n(){if(!e.requests.length)for(var n=a._selections.length;n--;){var r,i=a._selections[n];if("rarest"===a.strategy)for(var o=i.from+i.offset,s=i.to,u=s-o+1,c={},f=0,h=t(o,s,c);u>f&&(r=a.rarityMap.getRarestPiece(h),!(0>r));){if(a._request(e,r,!1))return;c[r]=!0,f+=1}else for(r=i.to;r>=i.from+i.offset;--r)if(e.peerPieces.get(r)&&a._request(e,r,!1))return}}function r(){var t=e.downloadSpeed()||1;if(t>A)return function(){return!0};var n=Math.max(1,e.requests.length)*E.BLOCK_LENGTH/t,r=10,i=0;return function(e){if(!r||a.storage.bitfield.get(e))return!0;for(var o=a.storage.pieces[e],s=o.blocks.length-o.blocksWritten;i<a.swarm.wires.length;i++){var u=a.swarm.wires[i],c=u.downloadSpeed();if(!(A>c||t>=c||!u.peerPieces.get(e)||(s-=c*n)>0))return r--,!1}return!0}}function i(e){for(var t=e,n=e;n<a._selections.length&&a._selections[n].priority;n++)t=n;var r=a._selections[e];a._selections[e]=a._selections[t],a._selections[t]=r}function s(n){if(e.requests.length>=c)return!0;for(var o=r(),s=0;s<a._selections.length;s++){var u,f=a._selections[s];if("rarest"===a.strategy)for(var h=f.from+f.offset,l=f.to,d=l-h+1,p={},g=0,m=t(h,l,p,o);d>g&&(u=a.rarityMap.getRarestPiece(m),!(0>u));){for(;a._request(e,u,a._critical[u]||n););if(!(e.requests.length<c))return f.priority&&i(s),!0;p[u]=!0,g++}else for(u=f.from+f.offset;u<=f.to;u++)if(e.peerPieces.get(u)&&o(u)){for(;a._request(e,u,a._critical[u]||n););if(!(e.requests.length<c))return f.priority&&i(s),!0}}return!1}var a=this;if(!e.peerChoking){if(!e.downloaded)return n();var u=o(e,L);if(!(e.requests.length>=u)){var c=o(e,B);s(!1)||s(!0)}}},i.prototype._rechoke=function(){function e(e,t){return e.downloadSpeed!==t.downloadSpeed?t.downloadSpeed-e.downloadSpeed:e.uploadSpeed!==t.uploadSpeed?t.uploadSpeed-e.uploadSpeed:e.wire.amChoking!==t.wire.amChoking?e.wire.amChoking?1:-1:e.salt-t.salt}var t=this;t._rechokeOptimisticTime>0?t._rechokeOptimisticTime-=1:t._rechokeOptimisticWire=null;var n=[];t.swarm.wires.forEach(function(e){e.isSeeder||e===t._rechokeOptimisticWire||n.push({wire:e,downloadSpeed:e.downloadSpeed(),uploadSpeed:e.uploadSpeed(),salt:Math.random(),isChoked:!0})}),n.sort(e);for(var r=0,i=0;i<n.length&&r<t._rechokeNumSlots;++i)n[i].isChoked=!1,n[i].wire.peerInterested&&(r+=1);if(!t._rechokeOptimisticWire&&i<n.length&&t._rechokeNumSlots){var o=n.slice(i).filter(function(e){return e.wire.peerInterested}),a=o[s(o.length)];a&&(a.isChoked=!1,t._rechokeOptimisticWire=a.wire,t._rechokeOptimisticTime=R)}n.forEach(function(e){e.wire.amChoking!==e.isChoked&&(e.isChoked?e.wire.choke():e.wire.unchoke())})},i.prototype._hotswap=function(e,t){var n=this;if(!n.hotswapEnabled)return!1;var r=e.downloadSpeed();if(r<E.BLOCK_LENGTH)return!1;if(!n._reservations[t])return!1;var i=n._reservations[t];if(!i)return!1;var o,s,a=1/0;for(s=0;s<i.length;s++){var u=i[s];if(u&&u!==e){var c=u.downloadSpeed();c>=A||2*c>r||c>a||(o=u,a=c)}}if(!o)return!1;for(s=0;s<i.length;s++)i[s]===o&&(i[s]=null);for(s=0;s<o.requests.length;s++){var f=o.requests[s];f.piece===t&&n.storage.cancelBlock(t,f.offset)}return n.emit("hotswap",o,e,t),!0},i.prototype._request=function(e,t,r){function i(r,o){return s.ready?(l[d]===e&&(l[d]=null),r?(c("error getting piece "+t+"(offset: "+h.offset+" length: "+h.length+") from "+e.remoteAddress+" "+r.message),s.storage.cancelBlock(t,h.offset),n.nextTick(s._update.bind(s)),!1):void s.storage.writeBlock(t,h.offset,o,function(e){e&&(c("error writing block"),s.storage.cancelBlock(t,h.offset)),n.nextTick(s._update.bind(s))})):void s.once("ready",function(){i(r,o)})}var s=this,a=e.requests.length;if(s.storage.bitfield.get(t))return!1;var u=o(e,B);if(a>=u)return!1;var f=0===e.requests.length&&s.storage.numMissing<30,h=s.storage.reserveBlock(t,f);if(!h&&!f&&r&&s._hotswap(e,t)&&(h=s.storage.reserveBlock(t,!1)),!h)return!1;var l=s._reservations[t];l||(l=s._reservations[t]=[]);var d=l.indexOf(null);return-1===d&&(d=l.length),l[d]=e,e.request(t,h.offset,h.length,i),!0},i.prototype.createServer=function(e){var t=this;return"function"==typeof k?new k(t,e):void 0}}).call(this,e("_process"))},{"./rarity-map":2,"./server":10,"./storage":3,_process:18,"addr-to-ip-port":10,"bittorrent-swarm":81,debug:44,events:15,fs:8,inherits:53,"parse-torrent":57,"re-emitter":66,"run-parallel":67,"simple-get":10,"torrent-discovery":71,ut_metadata:77,ut_pex:10}],5:[function(e,t){function n(e,t){var i=this;if(!(i instanceof n))return new n(e,t);s.Writable.call(i,t),i.video=e,t=t||{},t.type=t.type||'video/webm; codecs="vorbis,vp8"',r("new videostream %s %s",e,JSON.stringify(t)),i._mediaSource=new a,i._playing=!1,i._sourceBuffer=null,i._cb=null,i.video.src=window.URL.createObjectURL(i._mediaSource);var u=o(function(){i._sourceBuffer=i._mediaSource.addSourceBuffer(t.type),i._sourceBuffer.addEventListener("updateend",i._flow.bind(i)),i._flow()});i._mediaSource.addEventListener("webkitsourceopen",u,!1),i._mediaSource.addEventListener("sourceopen",u,!1),i.on("finish",function(){r("finish"),i._mediaSource.endOfStream()}),window.vs=i}t.exports=n;var r=e("debug")("webtorrent:video-stream"),i=e("inherits"),o=e("once"),s=e("stream"),a="undefined"!=typeof window&&(window.MediaSource||window.WebKitMediaSource);i(n,s.Writable),n.prototype._write=function(e,t,n){var i=this;return i._sourceBuffer?i._sourceBuffer.updating?n(new Error("Cannot append buffer while source buffer updating")):(i._sourceBuffer.appendBuffer(e),r("appendBuffer %s",e.length),i._cb=n,void(i._playing||(i.video.play(),i._playing=!0))):void(i._cb=function(r){return r?n(r):void i._write(e,t,n)})},n.prototype._flow=function(){var e=this;r("flow"),e._cb&&e._cb(null)}},{debug:44,inherits:53,once:56,stream:30}],6:[function(e,t){(function(e){function n(e,t){return this instanceof n?(0===arguments.length&&(e=0),this.grow=t&&(isFinite(t.grow)&&r(t.grow)||t.grow)||0,("number"==typeof e||void 0===e)&&(e=new i(r(e)),e.fill&&e.fill(0)),void(this.buffer=e)):new n(e)}function r(e){var t=e>>3;return e%8!==0&&t++,t}var i="undefined"!=typeof e?e:"undefined"!=typeof Int8Array?Int8Array:function(e){for(var t=new Array(e),n=0;e>n;n++)t[n]=0};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 n=e>>3;t||1===arguments.length?(this._grow(n+1),this.buffer[n]|=128>>e%8):n<this.buffer.length&&(this.buffer[n]&=~(128>>e%8))},n.prototype._grow=function(e){if(this.buffer.length<e&&e<=this.grow){var t=new i(e);t.fill&&t.fill(0);for(var n=0;n<this.buffer.length;n++)t[n]=this.buffer[n];this.buffer=t}},"undefined"!=typeof t&&(t.exports=n)}).call(this,e("buffer").Buffer)},{buffer:11}],7:[function(e,t){(function(n,r){function i(e,t){if(this.writable=this.readable=!0,this._opt=t||{},this._chunkSize=e||512,this._offset=0,this._buffer=[],this._bufferLength=0,this._opt.nopad)this._zeroes=!1;else{this._zeroes=new r(this._chunkSize);for(var n=0;n<this._chunkSize;n++)this._zeroes[n]=0}}t.exports=i;{var o=e("stream").Stream,s=e("inherits"),a=e("assert").ok;n.env.DEBUG?console.error:function(){}}s(i,o),i.prototype.write=function(e){if(this._ended)throw new Error("BlockStream: write after end");if(e&&!r.isBuffer(e)&&(e=new r(e+"")),e.length&&(this._buffer.push(e),this._bufferLength+=e.length),this._bufferLength>=this._chunkSize){if(this._paused)return this._needDrain=!0,!1;this._emitChunk()}return!0},i.prototype.pause=function(){this._paused=!0},i.prototype.resume=function(){return this._paused=!1,this._emitChunk()},i.prototype.end=function(e){"function"==typeof e&&(cb=e,e=null),e&&this.write(e),this._ended=!0,this.flush()},i.prototype.flush=function(){this._emitChunk(!0)},i.prototype._emitChunk=function(e){if(e&&this._zeroes){var t=this._bufferLength%this._chunkSize;0!==t&&(t=this._chunkSize-t),t>0&&(this._buffer.push(this._zeroes.slice(0,t)),this._bufferLength+=t)}if(!this._emitting&&!this._paused){this._emitting=!0;for(var n=0;this._bufferLength>=this._chunkSize&&(e||!this._paused);){for(var i,o=0,s=this._chunkSize;s>0&&(e||!this._paused);){var u=this._buffer[n],c=u.length-this._offset;i||s>c?(i=i||new r(this._chunkSize),u.copy(i,o,this._offset,this._offset+Math.min(c,s))):i=u.length===s&&0===this._offset?u:u.slice(this._offset,this._offset+s),c>s?(this._offset+=s,s=0):(s-=c,o+=c,n++,this._offset=0)}this._bufferLength-=this._chunkSize,a(i.length===this._chunkSize),this.emit("data",i),i=null}if(this._buffer=this._buffer.slice(n),this._paused)return this._needsDrain=!0,void(this._emitting=!1);var f=this._buffer.length;if(e&&!this._zeroes&&f){if(1===f)this._offset?this.emit("data",this._buffer[0].slice(this._offset)):this.emit("data",this._buffer[0]);else{for(var s=this._bufferLength,i=new r(s),o=0,h=0;f>h;h++){var u=this._buffer[h],c=u.length-this._offset;u.copy(i,o,this._offset),this._offset=0,o+=c,this._bufferLength-=c}this.emit("data",i)}this._buffer.length=0,this._bufferLength=0,this._offset=0}this._needDrain&&(this._needDrain=!1,this.emit("drain")),0===this._bufferLength&&this._ended&&!this._endEmitted&&(this._endEmitted=!0,this.emit("end")),this._emitting=!1}}}).call(this,e("_process"),e("buffer").Buffer)},{_process:18,assert:9,buffer:11,inherits:53,stream:30}],8:[function(){},{}],9:[function(e,t){function n(e,t){return l.isUndefined(t)?""+t:l.isNumber(t)&&!isFinite(t)?t.toString():l.isFunction(t)||l.isRegExp(t)?t.toString():t}function r(e,t){return l.isString(e)?e.length<t?e:e.slice(0,t):e}function i(e){return r(JSON.stringify(e.actual,n),128)+" "+e.operator+" "+r(JSON.stringify(e.expected,n),128)}function o(e,t,n,r,i){throw new g.AssertionError({message:n,actual:e,expected:t,operator:r,stackStartFunction:i})}function s(e,t){e||o(e,!0,t,"==",g.ok)}function a(e,t){if(e===t)return!0;if(l.isBuffer(e)&&l.isBuffer(t)){if(e.length!=t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}return l.isDate(e)&&l.isDate(t)?e.getTime()===t.getTime():l.isRegExp(e)&&l.isRegExp(t)?e.source===t.source&&e.global===t.global&&e.multiline===t.multiline&&e.lastIndex===t.lastIndex&&e.ignoreCase===t.ignoreCase:l.isObject(e)||l.isObject(t)?c(e,t):e==t}function u(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function c(e,t){if(l.isNullOrUndefined(e)||l.isNullOrUndefined(t))return!1;if(e.prototype!==t.prototype)return!1;if(l.isPrimitive(e)||l.isPrimitive(t))return e===t;var n=u(e),r=u(t);if(n&&!r||!n&&r)return!1;if(n)return e=d.call(e),t=d.call(t),a(e,t);var i,o,s=m(e),c=m(t);if(s.length!=c.length)return!1;for(s.sort(),c.sort(),o=s.length-1;o>=0;o--)if(s[o]!=c[o])return!1;for(o=s.length-1;o>=0;o--)if(i=s[o],!a(e[i],t[i]))return!1;return!0}function f(e,t){return e&&t?"[object RegExp]"==Object.prototype.toString.call(t)?t.test(e):e instanceof t?!0:t.call({},e)===!0?!0:!1:!1}function h(e,t,n,r){var i;l.isString(n)&&(r=n,n=null);try{t()}catch(s){i=s}if(r=(n&&n.name?" ("+n.name+").":".")+(r?" "+r:"."),e&&!i&&o(i,n,"Missing expected exception"+r),!e&&f(i,n)&&o(i,n,"Got unwanted exception"+r),e&&i&&n&&!f(i,n)||!e&&i)throw i}var l=e("util/"),d=Array.prototype.slice,p=Object.prototype.hasOwnProperty,g=t.exports=s;g.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=i(this),this.generatedMessage=!0);var t=e.stackStartFunction||o;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var n=new Error;if(n.stack){var r=n.stack,s=t.name,a=r.indexOf("\n"+s);if(a>=0){var u=r.indexOf("\n",a+1);r=r.substring(u+1)}this.stack=r}}},l.inherits(g.AssertionError,Error),g.fail=o,g.ok=s,g.equal=function(e,t,n){e!=t&&o(e,t,n,"==",g.equal)},g.notEqual=function(e,t,n){e==t&&o(e,t,n,"!=",g.notEqual)},g.deepEqual=function(e,t,n){a(e,t)||o(e,t,n,"deepEqual",g.deepEqual)},g.notDeepEqual=function(e,t,n){a(e,t)&&o(e,t,n,"notDeepEqual",g.notDeepEqual)},g.strictEqual=function(e,t,n){e!==t&&o(e,t,n,"===",g.strictEqual)},g.notStrictEqual=function(e,t,n){e===t&&o(e,t,n,"!==",g.notStrictEqual)},g["throws"]=function(){h.apply(this,[!0].concat(d.call(arguments)))},g.doesNotThrow=function(){h.apply(this,[!1].concat(d.call(arguments)))},g.ifError=function(e){if(e)throw e};var m=Object.keys||function(e){var t=[];for(var n in e)p.call(e,n)&&t.push(n);return t}},{"util/":33}],10:[function(e,t,n){arguments[4][8][0].apply(n,arguments)},{dup:8}],11:[function(e,t,n){function r(e,t,n){if(!(this instanceof r))return new r(e,t,n);var i,o=typeof e; +if("number"===o)i=e>0?e>>>0:0;else if("string"===o)i=r.byteLength(e,t);else{if("object"!==o||null===e)throw new TypeError("must start with number, buffer, array or string");"Buffer"===e.type&&O(e.data)&&(e=e.data),i=+e.length>0?Math.floor(+e.length):0}if(i>U)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+U.toString(16)+" bytes");var s;r.TYPED_ARRAY_SUPPORT?s=r._augment(new Uint8Array(i)):(s=this,s.length=i,s._isBuffer=!0);var a;if(r.TYPED_ARRAY_SUPPORT&&"number"==typeof e.byteLength)s._set(e);else if(I(e))if(r.isBuffer(e))for(a=0;i>a;a++)s[a]=e.readUInt8(a);else for(a=0;i>a;a++)s[a]=(e[a]%256+256)%256;else if("string"===o)s.write(e,0,t);else if("number"===o&&!r.TYPED_ARRAY_SUPPORT&&!n)for(a=0;i>a;a++)s[a]=0;return i>0&&i<=r.poolSize&&(s.parent=D),s}function i(e,t,n){if(!(this instanceof i))return new i(e,t,n);var o=new r(e,t,n);return delete o.parent,o}function o(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;r>s;s++){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[n+s]=a}return s}function s(e,t,n,r){var i=C(L(t,e.length-n),e,n,r);return i}function a(e,t,n,r){var i=C(B(t),e,n,r);return i}function u(e,t,n,r){return a(e,t,n,r)}function c(e,t,n,r){var i=C(R(t),e,n,r);return i}function f(e,t,n,r){var i=C(T(t,e.length-n),e,n,r,2);return i}function h(e,t,n){return j.fromByteArray(0===t&&n===e.length?e:e.slice(t,n))}function l(e,t,n){var r="",i="";n=Math.min(e.length,n);for(var o=t;n>o;o++)e[o]<=127?(r+=M(i)+String.fromCharCode(e[o]),i=""):i+="%"+e[o].toString(16);return r+M(i)}function d(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(127&e[i]);return r}function p(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function g(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=A(e[o]);return i}function m(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function y(e,t,n){if(e%1!==0||0>e)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function v(e,t,n,i,o,s){if(!r.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>o||s>t)throw new RangeError("value is out of bounds");if(n+i>e.length)throw new RangeError("index out of range")}function _(e,t,n,r){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);o>i;i++)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function w(e,t,n,r){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);o>i;i++)e[n+i]=t>>>8*(r?i:3-i)&255}function b(e,t,n,r,i,o){if(t>i||o>t)throw new RangeError("value is out of bounds");if(n+r>e.length)throw new RangeError("index out of range");if(0>n)throw new RangeError("index out of range")}function k(e,t,n,r,i){return i||b(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),P.write(e,t,n,r,23,4),n+4}function E(e,t,n,r,i){return i||b(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),P.write(e,t,n,r,52,8),n+8}function x(e){if(e=S(e).replace(z,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function S(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function I(e){return O(e)||r.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function A(e){return 16>e?"0"+e.toString(16):e.toString(16)}function L(e,t){var n,r=e.length,i=null;t=t||1/0;for(var o=[],s=0;r>s;s++){if(n=e.charCodeAt(s),n>55295&&57344>n){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(56320>n){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=i-55296<<10|n-56320|65536,i=null}else i&&((t-=3)>-1&&o.push(239,191,189),i=null);if(128>n){if((t-=1)<0)break;o.push(n)}else if(2048>n){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(2097152>n))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function B(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t}function T(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);s++)n=e.charCodeAt(s),r=n>>8,i=n%256,o.push(i),o.push(r);return o}function R(e){return j.toByteArray(x(e))}function C(e,t,n,r,i){i&&(r-=r%i);for(var o=0;r>o&&!(o+n>=t.length||o>=e.length);o++)t[o+n]=e[o];return o}function M(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}var j=e("base64-js"),P=e("ieee754"),O=e("is-array");n.Buffer=r,n.SlowBuffer=i,n.INSPECT_MAX_BYTES=50,r.poolSize=8192;var U=1073741823,D={};r.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(n){return!1}}(),r.isBuffer=function(e){return!(null==e||!e._isBuffer)},r.compare=function(e,t){if(!r.isBuffer(e)||!r.isBuffer(t))throw new TypeError("Arguments must be Buffers");for(var n=e.length,i=t.length,o=0,s=Math.min(n,i);s>o&&e[o]===t[o];o++);return o!==s&&(n=e[o],i=t[o]),i>n?-1:n>i?1:0},r.isEncoding=function(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!0;default:return!1}},r.concat=function(e,t){if(!O(e))throw new TypeError("Usage: Buffer.concat(list[, length])");if(0===e.length)return new r(0);if(1===e.length)return e[0];var n;if(void 0===t)for(t=0,n=0;n<e.length;n++)t+=e[n].length;var i=new r(t),o=0;for(n=0;n<e.length;n++){var s=e[n];s.copy(i,o),o+=s.length}return i},r.byteLength=function(e,t){var n;switch(e+="",t||"utf8"){case"ascii":case"binary":case"raw":n=e.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*e.length;break;case"hex":n=e.length>>>1;break;case"utf8":case"utf-8":n=L(e).length;break;case"base64":n=R(e).length;break;default:n=e.length}return n},r.prototype.length=void 0,r.prototype.parent=void 0,r.prototype.toString=function(e,t,n){var r=!1;if(t>>>=0,n=void 0===n||1/0===n?this.length:n>>>0,e||(e="utf8"),0>t&&(t=0),n>this.length&&(n=this.length),t>=n)return"";for(;;)switch(e){case"hex":return g(this,t,n);case"utf8":case"utf-8":return l(this,t,n);case"ascii":return d(this,t,n);case"binary":return p(this,t,n);case"base64":return h(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}},r.prototype.equals=function(e){if(!r.isBuffer(e))throw new TypeError("Argument must be a Buffer");return 0===r.compare(this,e)},r.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},r.prototype.compare=function(e){if(!r.isBuffer(e))throw new TypeError("Argument must be a Buffer");return r.compare(this,e)},r.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},r.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},r.prototype.write=function(e,t,n,r){if(isFinite(t))isFinite(n)||(r=n,n=void 0);else{var i=r;r=t,t=n,n=i}if(t=Number(t)||0,0>n||0>t||t>this.length)throw new RangeError("attempt to write outside buffer bounds");var h=this.length-t;n?(n=Number(n),n>h&&(n=h)):n=h,r=String(r||"utf8").toLowerCase();var l;switch(r){case"hex":l=o(this,e,t,n);break;case"utf8":case"utf-8":l=s(this,e,t,n);break;case"ascii":l=a(this,e,t,n);break;case"binary":l=u(this,e,t,n);break;case"base64":l=c(this,e,t,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":l=f(this,e,t,n);break;default:throw new TypeError("Unknown encoding: "+r)}return l},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),e>t&&(t=e);var i;if(r.TYPED_ARRAY_SUPPORT)i=r._augment(this.subarray(e,t));else{var o=t-e;i=new r(o,void 0,!0);for(var s=0;o>s;s++)i[s]=this[s+e]}return i.length&&(i.parent=this.parent||this),i},r.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||y(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},r.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||y(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},r.prototype.readUInt8=function(e,t){return t||y(e,1,this.length),this[e]},r.prototype.readUInt16LE=function(e,t){return t||y(e,2,this.length),this[e]|this[e+1]<<8},r.prototype.readUInt16BE=function(e,t){return t||y(e,2,this.length),this[e]<<8|this[e+1]},r.prototype.readUInt32LE=function(e,t){return t||y(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},r.prototype.readUInt32BE=function(e,t){return t||y(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},r.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||y(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return i*=128,r>=i&&(r-=Math.pow(2,8*t)),r},r.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||y(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},r.prototype.readInt8=function(e,t){return t||y(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},r.prototype.readInt16LE=function(e,t){t||y(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt16BE=function(e,t){t||y(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},r.prototype.readInt32LE=function(e,t){return t||y(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},r.prototype.readInt32BE=function(e,t){return t||y(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},r.prototype.readFloatLE=function(e,t){return t||y(e,4,this.length),P.read(this,e,!0,23,4)},r.prototype.readFloatBE=function(e,t){return t||y(e,4,this.length),P.read(this,e,!1,23,4)},r.prototype.readDoubleLE=function(e,t){return t||y(e,8,this.length),P.read(this,e,!0,52,8)},r.prototype.readDoubleBE=function(e,t){return t||y(e,8,this.length),P.read(this,e,!1,52,8)},r.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||v(this,e,t,n,Math.pow(2,8*n),0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i>>>0&255;return t+n},r.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||v(this,e,t,n,Math.pow(2,8*n),0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o>>>0&255;return t+n},r.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,1,255,0),r.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e,t+1},r.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):_(this,e,t,!0),t+2},r.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,65535,0),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):_(this,e,t,!1),t+2},r.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e):w(this,e,t,!0),t+4},r.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,4294967295,0),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):w(this,e,t,!1),t+4},r.prototype.writeIntLE=function(e,t,n,r){e=+e,t>>>=0,r||v(this,e,t,n,Math.pow(2,8*n-1)-1,-Math.pow(2,8*n-1));var i=0,o=1,s=0>e?1:0;for(this[t]=255&e;++i<n&&(o*=256);)this[t+i]=(e/o>>0)-s&255;return t+n},r.prototype.writeIntBE=function(e,t,n,r){e=+e,t>>>=0,r||v(this,e,t,n,Math.pow(2,8*n-1)-1,-Math.pow(2,8*n-1));var i=n-1,o=1,s=0>e?1:0;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=(e/o>>0)-s&255;return t+n},r.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,1,127,-128),r.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=e,t+1},r.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):_(this,e,t,!0),t+2},r.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,2,32767,-32768),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):_(this,e,t,!1),t+2},r.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,2147483647,-2147483648),r.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):w(this,e,t,!0),t+4},r.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||v(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),r.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):w(this,e,t,!1),t+4},r.prototype.writeFloatLE=function(e,t,n){return k(this,e,t,!0,n)},r.prototype.writeFloatBE=function(e,t,n){return k(this,e,t,!1,n)},r.prototype.writeDoubleLE=function(e,t,n){return E(this,e,t,!0,n)},r.prototype.writeDoubleBE=function(e,t,n){return E(this,e,t,!1,n)},r.prototype.copy=function(e,t,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&n>i&&(i=n),i===n)return 0;if(0===e.length||0===o.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>n||n>=o.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);var s=i-n;if(1e3>s||!r.TYPED_ARRAY_SUPPORT)for(var a=0;s>a;a++)e[a+t]=this[a+n];else e._set(this.subarray(n,n+s),t);return s},r.prototype.fill=function(e,t,n){if(e||(e=0),t||(t=0),n||(n=this.length),t>n)throw new RangeError("end < start");if(n!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>n||n>this.length)throw new RangeError("end out of bounds");var r;if("number"==typeof e)for(r=t;n>r;r++)this[r]=e;else{var i=L(e.toString()),o=i.length;for(r=t;n>r;r++)this[r]=i[r%o]}return this}},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(r.TYPED_ARRAY_SUPPORT)return new r(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;n>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var H=r.prototype;r._augment=function(e){return e.constructor=r,e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=H.get,e.set=H.set,e.write=H.write,e.toString=H.toString,e.toLocaleString=H.toString,e.toJSON=H.toJSON,e.equals=H.equals,e.compare=H.compare,e.copy=H.copy,e.slice=H.slice,e.readUIntLE=H.readUIntLE,e.readUIntBE=H.readUIntBE,e.readUInt8=H.readUInt8,e.readUInt16LE=H.readUInt16LE,e.readUInt16BE=H.readUInt16BE,e.readUInt32LE=H.readUInt32LE,e.readUInt32BE=H.readUInt32BE,e.readIntLE=H.readIntLE,e.readIntBE=H.readIntBE,e.readInt8=H.readInt8,e.readInt16LE=H.readInt16LE,e.readInt16BE=H.readInt16BE,e.readInt32LE=H.readInt32LE,e.readInt32BE=H.readInt32BE,e.readFloatLE=H.readFloatLE,e.readFloatBE=H.readFloatBE,e.readDoubleLE=H.readDoubleLE,e.readDoubleBE=H.readDoubleBE,e.writeUInt8=H.writeUInt8,e.writeUIntLE=H.writeUIntLE,e.writeUIntBE=H.writeUIntBE,e.writeUInt16LE=H.writeUInt16LE,e.writeUInt16BE=H.writeUInt16BE,e.writeUInt32LE=H.writeUInt32LE,e.writeUInt32BE=H.writeUInt32BE,e.writeIntLE=H.writeIntLE,e.writeIntBE=H.writeIntBE,e.writeInt8=H.writeInt8,e.writeInt16LE=H.writeInt16LE,e.writeInt16BE=H.writeInt16BE,e.writeInt32LE=H.writeInt32LE,e.writeInt32BE=H.writeInt32BE,e.writeFloatLE=H.writeFloatLE,e.writeFloatBE=H.writeFloatBE,e.writeDoubleLE=H.writeDoubleLE,e.writeDoubleBE=H.writeDoubleBE,e.fill=H.fill,e.inspect=H.inspect,e.toArrayBuffer=H.toArrayBuffer,e};var z=/[^+\/0-9A-z\-]/g},{"base64-js":12,ieee754:13,"is-array":14}],12:[function(e,t,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===s||t===h?62:t===a||t===l?63:u>t?-1:u+10>t?t-u+26+26:f+26>t?t-f:c+26>t?t-c+26:void 0}function n(e){function n(e){c[h++]=e}var r,i,s,a,u,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=e.length;u="="===e.charAt(f-2)?2:"="===e.charAt(f-1)?1:0,c=new o(3*e.length/4-u),s=u>0?e.length-4:e.length;var h=0;for(r=0,i=0;s>r;r+=4,i+=3)a=t(e.charAt(r))<<18|t(e.charAt(r+1))<<12|t(e.charAt(r+2))<<6|t(e.charAt(r+3)),n((16711680&a)>>16),n((65280&a)>>8),n(255&a);return 2===u?(a=t(e.charAt(r))<<2|t(e.charAt(r+1))>>4,n(255&a)):1===u&&(a=t(e.charAt(r))<<10|t(e.charAt(r+1))<<4|t(e.charAt(r+2))>>2,n(a>>8&255),n(255&a)),c}function i(e){function t(e){return r.charAt(e)}function n(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,o,s,a=e.length%3,u="";for(i=0,s=e.length-a;s>i;i+=3)o=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u+=n(o);switch(a){case 1:o=e[e.length-1],u+=t(o>>2),u+=t(o<<4&63),u+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1],u+=t(o>>10),u+=t(o>>4&63),u+=t(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0),h="-".charCodeAt(0),l="_".charCodeAt(0);e.toByteArray=n,e.fromByteArray=i}("undefined"==typeof n?this.base64js={}:n)},{}],13:[function(e,t,n){n.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,c=u>>1,f=-7,h=n?i-1:0,l=n?-1:1,d=e[t+h];for(h+=l,o=d&(1<<-f)-1,d>>=-f,f+=a;f>0;o=256*o+e[t+h],h+=l,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+e[t+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return s?0/0:1/0*(d?-1:1);s+=Math.pow(2,r),o-=c}return(d?-1:1)*s*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,h=f>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,g=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||1/0===t?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+h>=1?l/u:l*Math.pow(2,1-h),t*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(t*u-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[n+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[n+d]=255&s,d+=p,s/=256,c-=8);e[n+d-p]|=128*g}},{}],14:[function(e,t){var n=Array.isArray,r=Object.prototype.toString;t.exports=n||function(e){return!!e&&"[object Array]"==r.call(e)}},{}],15:[function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,i,a,u,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(t=arguments[1],t instanceof Error)throw t;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];n.apply(this,a)}else if(o(n)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(c=n.slice(),i=c.length,u=0;i>u;u++)c[u].apply(this,a)}return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned){var i;i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(a=s;a-->0;)if(n[a]===t||n[a].listener&&n[a].listener===t){i=a;break}if(0>i)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?r(e._events[t])?1:e._events[t].length:0}},{}],16:[function(e,t){t.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},{}],17:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];"."===i?e.splice(r,1):".."===i?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,o=function(e){return i.exec(e).slice(1)};n.resolve=function(){for(var n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,i="/"===s.charAt(0))}return n=t(r(n.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(e){var i=n.isAbsolute(e),o="/"===s(e,-1);return e=t(r(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&o&&(e+="/"),(i?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,function(e){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),s=Math.min(i.length,o.length),a=s,u=0;s>u;u++)if(i[u]!==o[u]){a=u;break}for(var c=[],u=a;u<i.length;u++)c.push("..");return c=c.concat(o.slice(a)),c.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){var t=o(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},n.basename=function(e,t){var n=o(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){return o(e)[3]};var s="b"==="ab".substr(-1)?function(e,t,n){return e.substr(t,n)}:function(e,t,n){return 0>t&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:18}],18:[function(e,t){function n(){if(!s){s=!0;for(var e,t=o.length;t;){e=o,o=[];for(var n=-1;++n<t;)e[n]();t=o.length}s=!1}}function r(){}var i=t.exports={},o=[],s=!1;i.nextTick=function(e){o.push(e),s||setTimeout(n,0)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.on=r,i.addListener=r,i.once=r,i.off=r,i.removeListener=r,i.removeAllListeners=r,i.emit=r,i.binding=function(){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],19:[function(e,t){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":20}],20:[function(e,t){(function(n){function r(e){return this instanceof r?(u.call(this,e),c.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",i)):new r(e)}function i(){this.allowHalfOpen||this._writableState.ended||n.nextTick(this.end.bind(this))}function o(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}t.exports=r;var s=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},a=e("core-util-is");a.inherits=e("inherits");var u=e("./_stream_readable"),c=e("./_stream_writable");a.inherits(r,u),o(s(c.prototype),function(e){r.prototype[e]||(r.prototype[e]=c.prototype[e])})}).call(this,e("_process"))},{"./_stream_readable":22,"./_stream_writable":24,_process:18,"core-util-is":25,inherits:53}],21:[function(e,t){function n(e){return this instanceof n?void r.call(this,e):new n(e)}t.exports=n;var r=e("./_stream_transform"),i=e("core-util-is");i.inherits=e("inherits"),i.inherits(n,r),n.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":23,"core-util-is":25,inherits:53}],22:[function(e,t){(function(n){function r(t){t=t||{};var n=t.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=!1,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.calledRead=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!t.objectMode,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(L||(L=e("string_decoder/").StringDecoder),this.decoder=new L(t.encoding),this.encoding=t.encoding)}function i(e){return this instanceof i?(this._readableState=new r(e,this),this.readable=!0,void I.call(this)):new i(e)}function o(e,t,n,r,i){var o=c(t,n);if(o)e.emit("error",o);else if(null===n||void 0===n)t.reading=!1,t.ended||f(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else!t.decoder||i||r||(n=t.decoder.write(n)),t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):(t.reading=!1,t.buffer.push(n)),t.needReadable&&h(e),d(e,t);else i||(t.reading=!1);return s(t)}function s(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function a(e){if(e>=B)e=B;else{e--;for(var t=1;32>t;t<<=1)e|=e>>t;e++}return e}function u(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function c(e,t){var n=null;return x.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function f(e,t){if(t.decoder&&!t.ended){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.length>0?h(e):w(e)}function h(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,t.sync?n.nextTick(function(){l(e)}):l(e))}function l(e){e.emit("readable")}function d(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(function(){p(e,t)}))}function p(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function g(e){return function(){var t=e._readableState;t.awaitDrain--,0===t.awaitDrain&&m(e)}}function m(e){function t(e){var t=e.write(n);!1===t&&r.awaitDrain++}var n,r=e._readableState;for(r.awaitDrain=0;r.pipesCount&&null!==(n=e.read());)if(1===r.pipesCount?t(r.pipes,0,null):b(r.pipes,t),e.emit("data",n),r.awaitDrain>0)return;return 0===r.pipesCount?(r.flowing=!1,void(S.listenerCount(e,"data")>0&&v(e))):void(r.ranOut=!0)}function y(){this._readableState.ranOut&&(this._readableState.ranOut=!1,m(this))}function v(e,t){var r=e._readableState;if(r.flowing)throw new Error("Cannot switch to old mode now.");var i=t||!1,o=!1;e.readable=!0,e.pipe=I.prototype.pipe,e.on=e.addListener=I.prototype.on,e.on("readable",function(){o=!0;for(var t;!i&&null!==(t=e.read());)e.emit("data",t);null===t&&(o=!1,e._readableState.needReadable=!0)}),e.pause=function(){i=!0,this.emit("pause")},e.resume=function(){i=!1,o?n.nextTick(function(){e.emit("readable")}):this.read(0),this.emit("resume")},e.emit("readable")}function _(e,t){var n,r=t.buffer,i=t.length,o=!!t.decoder,s=!!t.objectMode;if(0===r.length)return null;if(0===i)n=null;else if(s)n=r.shift();else if(!e||e>=i)n=o?r.join(""):x.concat(r,i),r.length=0;else if(e<r[0].length){var a=r[0];n=a.slice(0,e),r[0]=a.slice(e)}else if(e===r[0].length)n=r.shift();else{n=o?"":new x(e);for(var u=0,c=0,f=r.length;f>c&&e>u;c++){var a=r[0],h=Math.min(e-u,a.length);o?n+=a.slice(0,h):a.copy(n,u,0,h),h<a.length?r[0]=a.slice(h):r.shift(),u+=h}}return n}function w(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");!t.endEmitted&&t.calledRead&&(t.ended=!0,n.nextTick(function(){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}))}function b(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function k(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}t.exports=i;var E=e("isarray"),x=e("buffer").Buffer;i.ReadableState=r;var S=e("events").EventEmitter;S.listenerCount||(S.listenerCount=function(e,t){return e.listeners(t).length});var I=e("stream"),A=e("core-util-is");A.inherits=e("inherits");var L;A.inherits(i,I),i.prototype.push=function(e,t){var n=this._readableState;return"string"!=typeof e||n.objectMode||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new x(e,t),t="")),o(this,n,e,t,!1)},i.prototype.unshift=function(e){var t=this._readableState;return o(this,t,e,"",!0)},i.prototype.setEncoding=function(t){L||(L=e("string_decoder/").StringDecoder),this._readableState.decoder=new L(t),this._readableState.encoding=t};var B=8388608;i.prototype.read=function(e){var t=this._readableState;t.calledRead=!0;var n,r=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return h(this),null;if(e=u(e,t),0===e&&t.ended)return n=null,t.length>0&&t.decoder&&(n=_(e,t),t.length-=n.length),0===t.length&&w(this),n;var i=t.needReadable;return t.length-e<=t.highWaterMark&&(i=!0),(t.ended||t.reading)&&(i=!1),i&&(t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1),i&&!t.reading&&(e=u(r,t)),n=e>0?_(e,t):null,null===n&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),t.ended&&!t.endEmitted&&0===t.length&&w(this),n},i.prototype._read=function(){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,t){function r(e){e===f&&o()}function i(){e.end()}function o(){e.removeListener("close",a),e.removeListener("finish",u),e.removeListener("drain",p),e.removeListener("error",s),e.removeListener("unpipe",r),f.removeListener("end",i),f.removeListener("end",o),(!e._writableState||e._writableState.needDrain)&&p() +}function s(t){c(),e.removeListener("error",s),0===S.listenerCount(e,"error")&&e.emit("error",t)}function a(){e.removeListener("finish",u),c()}function u(){e.removeListener("close",a),c()}function c(){f.unpipe(e)}var f=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1;var l=(!t||t.end!==!1)&&e!==n.stdout&&e!==n.stderr,d=l?i:o;h.endEmitted?n.nextTick(d):f.once("end",d),e.on("unpipe",r);var p=g(f);return e.on("drain",p),e._events&&e._events.error?E(e._events.error)?e._events.error.unshift(s):e._events.error=[s,e._events.error]:e.on("error",s),e.once("close",a),e.once("finish",u),e.emit("pipe",f),h.flowing||(this.on("readable",y),h.flowing=!0,n.nextTick(function(){m(f)})),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,this.removeListener("readable",y),t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,this.removeListener("readable",y),t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var i=k(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,t){var n=I.prototype.on.call(this,e,t);if("data"!==e||this._readableState.flowing||v(this),"readable"===e&&this.readable){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&h(this,r):this.read(0))}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){v(this),this.read(0),this.emit("resume")},i.prototype.pause=function(){v(this,!0),this.emit("pause")},i.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!==i&&void 0!==i)&&(t.objectMode||i&&i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)"function"==typeof e[i]&&"undefined"==typeof this[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return b(o,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(){n&&(n=!1,e.resume())},r},i._fromList=_}).call(this,e("_process"))},{_process:18,buffer:11,"core-util-is":25,events:15,inherits:53,isarray:16,stream:30,"string_decoder/":31}],23:[function(e,t){function n(e,t){this.afterTransform=function(e,n){return r(t,e,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function r(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!==n&&void 0!==n&&e.push(n),i&&i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&e._read(o.highWaterMark)}function i(e){if(!(this instanceof i))return new i(e);s.call(this,e);var t=(this._transformState=new n(e,this),this);this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("finish",function(){"function"==typeof this._flush?this._flush(function(e){o(t,e)}):o(t)})}function o(e,t){if(t)return e.emit("error",t);var n=e._writableState,r=(e._readableState,e._transformState);if(n.length)throw new Error("calling transform done when ws.length != 0");if(r.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}t.exports=i;var s=e("./_stream_duplex"),a=e("core-util-is");a.inherits=e("inherits"),a.inherits(i,s),i.prototype.push=function(e,t){return this._transformState.needTransform=!1,s.prototype.push.call(this,e,t)},i.prototype._transform=function(){throw new Error("not implemented")},i.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},i.prototype._read=function(){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0}},{"./_stream_duplex":20,"core-util-is":25,inherits:53}],24:[function(e,t){(function(n){function r(e,t,n){this.chunk=e,this.encoding=t,this.callback=n}function i(e,t){e=e||{};var n=e.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.objectMode=!!e.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var r=e.decodeStrings===!1;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){d(t,e)},this.writecb=null,this.writelen=0,this.buffer=[],this.errorEmitted=!1}function o(t){var n=e("./_stream_duplex");return this instanceof o||this instanceof n?(this._writableState=new i(t,this),this.writable=!0,void k.call(this)):new o(t)}function s(e,t,r){var i=new Error("write after end");e.emit("error",i),n.nextTick(function(){r(i)})}function a(e,t,r,i){var o=!0;if(!w.isBuffer(r)&&"string"!=typeof r&&null!==r&&void 0!==r&&!t.objectMode){var s=new TypeError("Invalid non-string/buffer chunk");e.emit("error",s),n.nextTick(function(){i(s)}),o=!1}return o}function u(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new w(t,n)),t}function c(e,t,n,i,o){n=u(t,n,i),w.isBuffer(n)&&(i="buffer");var s=t.objectMode?1:n.length;t.length+=s;var a=t.length<t.highWaterMark;return a||(t.needDrain=!0),t.writing?t.buffer.push(new r(n,i,o)):f(e,t,s,n,i,o),a}function f(e,t,n,r,i,o){t.writelen=n,t.writecb=o,t.writing=!0,t.sync=!0,e._write(r,i,t.onwrite),t.sync=!1}function h(e,t,r,i,o){r?n.nextTick(function(){o(i)}):o(i),e._writableState.errorEmitted=!0,e.emit("error",i)}function l(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function d(e,t){var r=e._writableState,i=r.sync,o=r.writecb;if(l(r),t)h(e,r,i,t,o);else{var s=y(e,r);s||r.bufferProcessing||!r.buffer.length||m(e,r),i?n.nextTick(function(){p(e,r,s,o)}):p(e,r,s,o)}}function p(e,t,n,r){n||g(e,t),r(),n&&v(e,t)}function g(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function m(e,t){t.bufferProcessing=!0;for(var n=0;n<t.buffer.length;n++){var r=t.buffer[n],i=r.chunk,o=r.encoding,s=r.callback,a=t.objectMode?1:i.length;if(f(e,t,a,i,o,s),t.writing){n++;break}}t.bufferProcessing=!1,n<t.buffer.length?t.buffer=t.buffer.slice(n):t.buffer.length=0}function y(e,t){return t.ending&&0===t.length&&!t.finished&&!t.writing}function v(e,t){var n=y(e,t);return n&&(t.finished=!0,e.emit("finish")),n}function _(e,t,r){t.ending=!0,v(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0}t.exports=o;var w=e("buffer").Buffer;o.WritableState=i;var b=e("core-util-is");b.inherits=e("inherits");var k=e("stream");b.inherits(o,k),o.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},o.prototype.write=function(e,t,n){var r=this._writableState,i=!1;return"function"==typeof t&&(n=t,t=null),w.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=function(){}),r.ended?s(this,r,n):a(this,r,e,n)&&(i=c(this,r,e,t,n)),i},o.prototype._write=function(e,t,n){n(new Error("not implemented"))},o.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),"undefined"!=typeof e&&null!==e&&this.write(e,t),r.ending||r.finished||_(this,r,n)}}).call(this,e("_process"))},{"./_stream_duplex":20,_process:18,buffer:11,"core-util-is":25,inherits:53,stream:30}],25:[function(e,t,n){(function(e){function t(e){return Array.isArray(e)}function r(e){return"boolean"==typeof e}function i(e){return null===e}function o(e){return null==e}function s(e){return"number"==typeof e}function a(e){return"string"==typeof e}function u(e){return"symbol"==typeof e}function c(e){return void 0===e}function f(e){return h(e)&&"[object RegExp]"===y(e)}function h(e){return"object"==typeof e&&null!==e}function l(e){return h(e)&&"[object Date]"===y(e)}function d(e){return h(e)&&("[object Error]"===y(e)||e instanceof Error)}function p(e){return"function"==typeof e}function g(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function m(t){return e.isBuffer(t)}function y(e){return Object.prototype.toString.call(e)}n.isArray=t,n.isBoolean=r,n.isNull=i,n.isNullOrUndefined=o,n.isNumber=s,n.isString=a,n.isSymbol=u,n.isUndefined=c,n.isRegExp=f,n.isObject=h,n.isDate=l,n.isError=d,n.isFunction=p,n.isPrimitive=g,n.isBuffer=m}).call(this,e("buffer").Buffer)},{buffer:11}],26:[function(e,t){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":21}],27:[function(e,t,n){var r=e("stream");n=t.exports=e("./lib/_stream_readable.js"),n.Stream=r,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.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){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":23}],29:[function(e,t){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":24}],30:[function(e,t){function n(){r.call(this)}t.exports=n;var r=e("events").EventEmitter,i=e("inherits");i(n,r),n.Readable=e("readable-stream/readable.js"),n.Writable=e("readable-stream/writable.js"),n.Duplex=e("readable-stream/duplex.js"),n.Transform=e("readable-stream/transform.js"),n.PassThrough=e("readable-stream/passthrough.js"),n.Stream=n,n.prototype.pipe=function(e,t){function n(t){e.writable&&!1===e.write(t)&&c.pause&&c.pause()}function i(){c.readable&&c.resume&&c.resume()}function o(){f||(f=!0,e.end())}function s(){f||(f=!0,"function"==typeof e.destroy&&e.destroy())}function a(e){if(u(),0===r.listenerCount(this,"error"))throw e}function u(){c.removeListener("data",n),e.removeListener("drain",i),c.removeListener("end",o),c.removeListener("close",s),c.removeListener("error",a),e.removeListener("error",a),c.removeListener("end",u),c.removeListener("close",u),e.removeListener("close",u)}var c=this;c.on("data",n),e.on("drain",i),e._isStdio||t&&t.end===!1||(c.on("end",o),c.on("close",s));var f=!1;return c.on("error",a),e.on("error",a),c.on("end",u),c.on("close",u),e.on("close",u),e.emit("pipe",c),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,n){function r(e){if(e&&!u(e))throw new Error("Unknown encoding: "+e)}function i(e){return e.toString(this.encoding)}function o(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function s(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var a=e("buffer").Buffer,u=a.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!0;default:return!1}},c=n.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),r(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=i)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};c.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";e=e.slice(n,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var r=t.charCodeAt(t.length-1);if(!(r>=55296&&56319>=r)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var i=e.length;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,r=t.charCodeAt(i);if(r>=55296&&56319>=r){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},c.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(2>=t&&n>>4==14){this.charLength=3;break}if(3>=t&&n>>3==30){this.charLength=4;break}}this.charReceived=t},c.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t}},{buffer:11}],32:[function(e,t){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],33:[function(e,t,n){(function(t,r){function i(e,t){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),g(t)?r.showHidden=t:t&&n._extend(r,t),b(r.showHidden)&&(r.showHidden=!1),b(r.depth)&&(r.depth=2),b(r.colors)&&(r.colors=!1),b(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e){return e}function a(e){var t={};return e.forEach(function(e){t[e]=!0}),t}function u(e,t,r){if(e.customInspect&&t&&I(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return _(i)||(i=u(e,i,r)),i}var o=c(e,t);if(o)return o;var s=Object.keys(t),g=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),S(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return f(t);if(0===s.length){if(I(t)){var m=t.name?": "+t.name:"";return e.stylize("[Function"+m+"]","special")}if(k(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(x(t))return e.stylize(Date.prototype.toString.call(t),"date");if(S(t))return f(t)}var y="",v=!1,w=["{","}"];if(p(t)&&(v=!0,w=["[","]"]),I(t)){var b=t.name?": "+t.name:"";y=" [Function"+b+"]"}if(k(t)&&(y=" "+RegExp.prototype.toString.call(t)),x(t)&&(y=" "+Date.prototype.toUTCString.call(t)),S(t)&&(y=" "+f(t)),0===s.length&&(!v||0==t.length))return w[0]+y+w[1];if(0>r)return k(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var E;return E=v?h(e,t,r,g,s):s.map(function(n){return l(e,t,r,g,n,v)}),e.seen.pop(),d(E,y,w)}function c(e,t){if(b(t))return e.stylize("undefined","undefined");if(_(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return v(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}function f(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i){for(var o=[],s=0,a=t.length;a>s;++s)o.push(R(t,String(s))?l(e,t,n,r,String(s),!0):"");return i.forEach(function(i){i.match(/^\d+$/)||o.push(l(e,t,n,r,i,!0))}),o}function l(e,t,n,r,i,o){var s,a,c;if(c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},c.get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),R(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=m(n)?u(e,c.value,null):u(e,c.value,n-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n"))):a=e.stylize("[Circular]","special")),b(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function p(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function m(e){return null===e}function y(e){return null==e}function v(e){return"number"==typeof e}function _(e){return"string"==typeof e}function w(e){return"symbol"==typeof e}function b(e){return void 0===e}function k(e){return E(e)&&"[object RegExp]"===L(e)}function E(e){return"object"==typeof e&&null!==e}function x(e){return E(e)&&"[object Date]"===L(e)}function S(e){return E(e)&&("[object Error]"===L(e)||e instanceof Error)}function I(e){return"function"==typeof e}function A(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function L(e){return Object.prototype.toString.call(e)}function B(e){return 10>e?"0"+e.toString(10):e.toString(10)}function T(){var e=new Date,t=[B(e.getHours()),B(e.getMinutes()),B(e.getSeconds())].join(":");return[e.getDate(),P[e.getMonth()],t].join(" ")}function R(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var C=/%[sdj%]/g;n.format=function(e){if(!_(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(i(arguments[n]));return t.join(" ")}for(var n=1,r=arguments,o=r.length,s=String(e).replace(C,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}}),a=r[n];o>n;a=r[++n])s+=m(a)||!E(a)?" "+a:" "+i(a);return s},n.deprecate=function(e,i){function o(){if(!s){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),s=!0}return e.apply(this,arguments)}if(b(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(t.noDeprecation===!0)return e;var s=!1;return o};var M,j={};n.debuglog=function(e){if(b(M)&&(M=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!j[e])if(new RegExp("\\b"+e+"\\b","i").test(M)){var r=t.pid;j[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else j[e]=function(){};return j[e]},n.inspect=i,i.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]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=g,n.isNull=m,n.isNullOrUndefined=y,n.isNumber=v,n.isString=_,n.isSymbol=w,n.isUndefined=b,n.isRegExp=k,n.isObject=E,n.isDate=x,n.isError=S,n.isFunction=I,n.isPrimitive=A,n.isBuffer=e("./support/isBuffer");var P=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",T(),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!E(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":32,_process:18,inherits:53}],34:[function(e,t){(function(n,r){function i(e,t,n){"function"==typeof t&&(n=t,t={}),t||(t={}),o(e,t,function(e,r){return e?n(e):void f(r,t,n)})}function o(e,t,i){if("function"==typeof t&&(i=t,t={}),t||(t={}),d(e)&&(e=Array.prototype.slice.call(e)),Array.isArray(e)||(e=[e]),0===e.length)throw new Error("invalid input type");if(t.name||(t.name=e[0].name||"string"==typeof e[0]&&k.basename(e)),void 0===t.name)throw new Error("missing option 'name' and unable to infer it from input[0].name");1!==e.length||e[0].name||(e[0].name=t.name);var o=e.reduce(function(e,t){return e+Number("string"==typeof t)},0);L(e.map(function(e){return function(n){var i={};if(l(e))i.getStream=g(e),i.length=e.size;else if(r.isBuffer(e))i.getStream=m(e),i.length=e.length;else{if(!p(e)){if("string"==typeof e){var a=o>1;return void s(e,a,n)}throw new Error("invalid input type in array")}if(!t.pieceLength)throw new Error("must specify `pieceLength` option if input is Stream");i.getStream=v(e,i),i.length=0}if(!e.name)throw new Error("missing requied `name` property on input");i.path=[e.name],n(null,i)}}),function(e,t){return e?i(e):(t=x(t),void(0===o?n.nextTick(function(){i(null,t)}):i(null,t)))})}function s(e,t,n){u(a,e,function(r,i){if(r)return n(r);i=Array.isArray(i)?x(i):[i];var o=k.normalize(e);t||1===i.length?o=o.slice(0,o.lastIndexOf(k.sep)+1):o[o.length-1]!==k.sep&&(o+=k.sep),i.forEach(function(e){e.getStream=y(e.path),e.path=e.path.replace(o,"").split(k.sep)}),n(null,i)})}function a(e,t){t=A(t),S.stat(e,function(n,r){if(n)return t(n);var i={length:r.size,path:e};t(null,i)})}function u(e,t,n){S.readdir(t,function(r,i){r&&"ENOTDIR"===r.code?e(t,n):r?n(r):L(i.map(function(n){return function(r){u(e,k.join(t,n),r)}}),n)})}function c(e,t,n){function i(){f&&0===u&&n(null,new r(o.join(""),"hex"),s)}n=A(n);var o=[],s=0,a=e.map(function(e){return e.getStream}),u=0,c=0,f=!1;new I(a).pipe(new w(t,{nopad:!0})).on("data",function(e){s+=e.length;var t=c;B(e,function(e){o[t]=e,u-=1,i()}),u+=1,c+=1}).on("end",function(){f=!0,i()}).on("error",n)}function f(e,n,r){var i=void 0!==n.announceList?n.announceList:void 0!==n.announce?n.announce.map(function(e){return[e]}):t.exports.announceList,o={info:{name:n.name},announce:i[0][0],"announce-list":i,"creation date":Number(n.creationDate)||Date.now(),encoding:"UTF-8"};void 0!==n.comment&&(o.info.comment=n.comment),void 0!==n.createdBy&&(o.info["created by"]=n.createdBy),void 0!==n["private"]&&(o.info["private"]=Number(n["private"])),void 0!==n.urlList&&(o["url-list"]=n.urlList);var s=1===e.length,a=n.pieceLength||b(e.reduce(h,0));o.info["piece length"]=a,c(e,a,function(t,n,i){return t?r(t):(o.info.pieces=n,e.forEach(function(e){delete e.getStream}),s?o.info.length=i:o.info.files=e,void r(null,_.encode(o)))})}function h(e,t){return e+t.length}function l(e){return"undefined"!=typeof Blob&&e instanceof Blob}function d(e){return"function"==typeof FileList&&e instanceof FileList}function p(e){return"object"==typeof e&&"function"==typeof e.pipe}function g(e){return function(){return new E(e)}}function m(e){return function(){var t=new T.PassThrough;return t.end(e),t}}function y(e){return function(){return S.createReadStream(e)}}function v(e,t){return function(){var n=new R;return n._transform=function(e,n,r){t.length+=e.length,this.push(e),r()},e.pipe(n),n}}t.exports=i,t.exports.announceList=[["udp://tracker.publicbt.com:80"],["udp://tracker.openbittorrent.com:80"],["udp://tracker.webtorrent.io:80"],["wss://tracker.webtorrent.io"]],t.exports.parseInput=o;var _=e("bencode"),w=e("block-stream"),b=e("piece-length"),k=e("path"),E=e("filestream/read"),x=e("flatten"),S=e("fs"),I=e("multistream"),A=e("once"),L=e("run-parallel"),B=e("simple-sha1"),T=e("stream"),R=T.Transform}).call(this,e("_process"),e("buffer").Buffer)},{_process:18,bencode:35,"block-stream":7,buffer:11,"filestream/read":40,flatten:41,fs:8,multistream:54,once:56,path:17,"piece-length":42,"run-parallel":67,"simple-sha1":68,stream:30}],35:[function(e,t){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":36,"./lib/encode":37}],36:[function(e,t){(function(e){function n(t,r){return n.position=0,n.encoding=r||null,n.data=e.isBuffer(t)?t:new e(t),n.next()}n.position=0,n.data=null,n.encoding=null,n.next=function(){switch(n.data[n.position]){case 100:return n.dictionary();case 108:return n.list();case 105:return n.integer();default:return n.bytes()}},n.find=function(e){for(var t=n.position,r=n.data.length,i=n.data;r>t;){if(i[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")},n.dictionary=function(){n.position++;for(var e={};101!==n.data[n.position];)e[n.bytes()]=n.next();return n.position++,e},n.list=function(){n.position++;for(var e=[];101!==n.data[n.position];)e.push(n.next());return n.position++,e},n.integer=function(){var e=n.find(101),t=n.data.toString("ascii",n.position+1,e);return n.position+=e+1-n.position,parseInt(t,10)},n.bytes=function(){var e=n.find(58),t=parseInt(n.data.toString("ascii",n.position,e),10),r=++e+t;return n.position=r,n.encoding?n.data.toString(n.encoding,e,r):n.data.slice(e,r)},t.exports=n}).call(this,e("buffer").Buffer)},{buffer:11}],37:[function(e,t){(function(e){function n(t){var r=[];return n._encode(r,t),e.concat(r)}n._floatConversionDetected=!1,n._encode=function(t,r){if(e.isBuffer(r))return t.push(new e(r.length+":")),void t.push(r);switch(typeof r){case"string":n.bytes(t,r);break;case"number":n.number(t,r);break;case"object":r.constructor===Array?n.list(t,r):n.dict(t,r)}};var r=new e("e"),i=new e("d"),o=new e("l");n.bytes=function(t,n){t.push(new e(e.byteLength(n)+":"+n))},n.number=function(t,r){var i=2147483648,o=r/i<<0,s=r%i<<0,a=o*i+s;t.push(new e("i"+a+"e")),a===r||n._floatConversionDetected||(n._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+r+'":','Bencoding only defines support for integers, value was converted to "'+a+'"'),console.trace())},n.dict=function(e,t){e.push(i);for(var o,s=0,a=Object.keys(t).sort(),u=a.length;u>s;s++)o=a[s],n.bytes(e,o),n._encode(e,t[o]);e.push(r)},n.list=function(e,t){var i=0,s=t.length;for(e.push(o);s>i;i++)n._encode(e,t[i]);e.push(r)},t.exports=n}).call(this,e("buffer").Buffer)},{buffer:11}],38:[function(e,t){(function(n){var r=e("is-typedarray").strict;t.exports=function(e){var t=n.TYPED_ARRAY_SUPPORT?n._augment:function(e){return new n(e)};return e instanceof Uint8Array?t(e):e instanceof ArrayBuffer?t(new Uint8Array(e)):r(e)?t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):new n(e)}}).call(this,e("buffer").Buffer)},{buffer:11,"is-typedarray":39}],39:[function(e,t){function n(e){return r(e)||i(e)}function r(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 i(e){return s[o.call(e)]}t.exports=n,n.strict=r,n.loose=i;var o=Object.prototype.toString,s={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],40:[function(e,t){"use strict";function n(e,t){return this instanceof n?(t=t||{},r.call(this,s({objectMode:!0},t)),this._offset=0,this._eof=!1,this._metasent=!t.meta,this._metadata={name:e.name,size:e.size,extension:e.name.replace(o,"$1")},t.mime&&"function"==typeof t.mime.lookup&&(this._metadata.type=t.mime.lookup(this._metadata.extension)),this.reader=new FileReader,this.reader.onprogress=this._handleProgress.bind(this),this.reader.onload=this._handleLoad.bind(this),void this.reader.readAsArrayBuffer(e)):new n(e,t)}var r=e("stream").Readable,i=e("util"),o=/^.*\.(\w+)$/,s=e("extend.js"),a=e("typedarray-to-buffer");i.inherits(n,r),t.exports=n,n.prototype._read=function(e){function t(){var i,o=n._offset,s=n._offset+e,u=r.result&&r.result.byteLength,c=2===r.readyState&&s>u;return u&&(c||u>s)?(i=a(new Uint8Array(r.result,o,Math.min(e,r.result.byteLength-o))),n._offset=o+i.length,n._eof=0===i.length,n.push(i.length>0?i:null)):void n.once("readable",t)}var n=this,r=this.reader;return this._metasent?void t():(this._metasent=!0,this.push("meta|"+JSON.stringify(this._metadata)))},n.prototype._handleLoad=function(){this.emit("readable")},n.prototype._handleProgress=function(){this.emit("readable")}},{"extend.js":51,stream:30,"typedarray-to-buffer":38,util:33}],41:[function(e,t){t.exports=function(e,t){function n(e,r){return e.reduce(function(e,i){return e.concat(Array.isArray(i)&&t>r?n(i,r+1):i)},[])}return t="number"==typeof t?t:1/0,n(e,1)}},{}],42:[function(e,t){for(var n=e("closest-to"),r=[],i=14;22>=i;i++)r.push(Math.pow(2,i));t.exports=function(e){return n(e/Math.pow(2,10),r)}},{"closest-to":43}],43:[function(e,t){t.exports=function(e,t){var n=1/0,r=0,i=null;t.sort(function(e,t){return e-t});for(var o=0,s=t.length;s>o&&(r=Math.abs(e-t[o]),!(r>=n));o++)n=r,i=t[o];return i}},{}],44:[function(e,t,n){function r(){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}function i(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return e;var r="color: "+this.color;e=[e[0],r,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0,o=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r),e}function o(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{null==e?u.removeItem("debug"):u.debug=e}catch(t){}}function a(){var e;try{e=u.debug}catch(t){}return e}n=t.exports=e("./debug"),n.log=o,n.formatArgs=i,n.save=s,n.load=a,n.useColors=r;var u;u="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:window.localStorage,n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){return JSON.stringify(e)},n.enable(a())},{"./debug":45}],45:[function(e,t,n){function r(){return n.colors[f++%n.colors.length]}function i(e){function t(){}function i(){var e=i,t=+new Date,o=t-(c||t);e.diff=o,e.prev=c,e.curr=t,c=t,null==e.useColors&&(e.useColors=n.useColors()),null==e.color&&e.useColors&&(e.color=r());var s=Array.prototype.slice.call(arguments);s[0]=n.coerce(s[0]),"string"!=typeof s[0]&&(s=["%o"].concat(s));var a=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,r){if("%%"===t)return t;a++;var i=n.formatters[r];if("function"==typeof i){var o=s[a];t=i.call(e,o),s.splice(a,1),a--}return t}),"function"==typeof n.formatArgs&&(s=n.formatArgs.apply(e,s));var u=i.log||n.log||console.log.bind(console);u.apply(e,s)}t.enabled=!1,i.enabled=!0;var o=n.enabled(e)?i:t;return o.namespace=e,o}function o(e){n.save(e);for(var t=(e||"").split(/[\s,]+/),r=t.length,i=0;r>i;i++)t[i]&&(e=t[i].replace(/\*/g,".*?"),"-"===e[0]?n.skips.push(new RegExp("^"+e.substr(1)+"$")):n.names.push(new RegExp("^"+e+"$")))}function s(){n.enable("")}function a(e){var t,r;for(t=0,r=n.skips.length;r>t;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;r>t;t++)if(n.names[t].test(e))return!0;return!1}function u(e){return e instanceof Error?e.stack||e.message:e}n=t.exports=i,n.coerce=u,n.disable=s,n.enable=o,n.enabled=a,n.humanize=e("ms"),n.names=[],n.skips=[],n.formatters={};var c,f=0},{ms:46}],46:[function(e,t){function n(e){var t=/^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"y":return n*f;case"days":case"day":case"d":return n*c;case"hours":case"hour":case"h":return n*u;case"minutes":case"minute":case"m":return n*a;case"seconds":case"second":case"s":return n*s;case"ms":return n}}}function r(e){return e>=c?Math.round(e/c)+"d":e>=u?Math.round(e/u)+"h":e>=a?Math.round(e/a)+"m":e>=s?Math.round(e/s)+"s":e+"ms"}function i(e){return o(e,c,"day")||o(e,u,"hour")||o(e,a,"minute")||o(e,s,"second")||e+" ms"}function o(e,t,n){return t>e?void 0:1.5*t>e?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s" +}var s=1e3,a=60*s,u=60*a,c=24*u,f=365.25*c;t.exports=function(e,t){return t=t||{},"string"==typeof e?n(e):t["long"]?i(e):r(e)}},{}],47:[function(e,t){function n(e){var t=!0;return i(function(){t=!1}),function(){var n=arguments,r=this;t?i(function(){e.apply(r,n)}):e.apply(r,n)}}var r=e("wrappy");t.exports=r(n);var i=e("asap")},{asap:48,wrappy:49}],48:[function(e,t){(function(e){function n(){for(;i.next;){i=i.next;var e=i.task;i.task=void 0;var t=i.domain;t&&(i.domain=void 0,t.enter());try{e()}catch(r){if(u)throw t&&t.exit(),setTimeout(n,0),t&&t.enter(),r;setTimeout(function(){throw r},0)}t&&t.exit()}s=!1}function r(t){o=o.next={task:t,domain:u&&e.domain,next:null},s||(s=!0,a())}var i={task:void 0,next:null},o=i,s=!1,a=void 0,u=!1;if("undefined"!=typeof e&&e.nextTick)u=!0,a=function(){e.nextTick(n)};else if("function"==typeof setImmediate)a="undefined"!=typeof window?setImmediate.bind(window,n):function(){setImmediate(n)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=n,a=function(){c.port2.postMessage(0)}}else a=function(){setTimeout(n,0)};t.exports=r}).call(this,e("_process"))},{_process:18}],49:[function(e,t){function n(e,t){function r(){for(var t=new Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),i=t[t.length-1];return"function"==typeof r&&r!==i&&Object.keys(i).forEach(function(e){r[e]=i[e]}),r}if(e&&t)return n(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(t){r[t]=e[t]}),r}t.exports=n},{}],50:[function(e,t){var n=e("once"),r=function(){},i=function(e){return e.setHeader&&"function"==typeof e.abort},o=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},s=function(e,t,a){if("function"==typeof t)return s(e,null,t);t||(t={}),a=n(a||r);var u=e._writableState,c=e._readableState,f=t.readable||t.readable!==!1&&e.readable,h=t.writable||t.writable!==!1&&e.writable,l=function(){e.writable||d()},d=function(){h=!1,f||a()},p=function(){f=!1,h||a()},g=function(e){a(e?new Error("exited with error code: "+e):null)},m=function(){return(!f||c&&c.ended)&&(!h||u&&u.ended)?void 0:a(new Error("premature close"))},y=function(){e.req.on("finish",d)};return i(e)?(e.on("complete",d),e.on("abort",m),e.req?y():e.on("request",y)):h&&!u&&(e.on("end",l),e.on("close",l)),o(e)&&e.on("exit",g),e.on("end",p),e.on("finish",d),t.error!==!1&&e.on("error",a),e.on("close",m),function(){e.removeListener("complete",d),e.removeListener("abort",m),e.removeListener("request",y),e.req&&e.req.removeListener("finish",d),e.removeListener("end",l),e.removeListener("close",l),e.removeListener("finish",d),e.removeListener("exit",g),e.removeListener("end",p),e.removeListener("error",a),e.removeListener("close",m)}};t.exports=s},{once:56}],51:[function(e,t){t.exports=function(e){for(var t,n=[].slice.call(arguments,1),r=0,i=n.length;i>r;r++){t=n[r];for(var o in t)e[o]=t[o]}return e}},{}],52:[function(e,t){var n=t.exports=function(e,t){if(t||(t=16),void 0===e&&(e=128),0>=e)return"0";for(var r=Math.log(Math.pow(2,e))/Math.log(t),i=2;1/0===r;i*=2)r=Math.log(Math.pow(2,e/i))/Math.log(t)*i;for(var o=r-Math.floor(r),s="",i=0;i<Math.floor(r);i++){var a=Math.floor(Math.random()*t).toString(t);s=a+s}if(o){var u=Math.pow(t,o),a=Math.floor(Math.random()*u).toString(t);s=a+s}var c=parseInt(s,t);return 1/0!==c&&c>=Math.pow(2,e)?n(e,t):s};n.rack=function(e,t,r){var i=function(i){var s=0;do{if(s++>10){if(!r)throw new Error("too many ID collisions, use more bits");e+=r}var a=n(e,t)}while(Object.hasOwnProperty.call(o,a));return o[a]=i,a},o=i.hats={};return i.get=function(e){return i.hats[e]},i.set=function(e,t){return i.hats[e]=t,i},i.bits=e||128,i.base=t||16,i}},{}],53:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],54:[function(e,t){function n(e,t){return this instanceof n?(o.Readable.call(this,t),this.destroyed=!1,this._drained=!1,this._forwarding=!1,this._current=null,this._queue=e.map(r),void this._next()):new n(e,t)}function r(e){if(!e||"function"==typeof e||e._readableState)return e;var t=(new o.Readable).wrap(e);return e.destroy&&(t.destroy=e.destroy.bind(e)),t}t.exports=n;var i=e("inherits"),o=e("stream");i(n,o.Readable),n.obj=function(e){return new n(e,{objectMode:!0,highWaterMark:16})},n.prototype._read=function(){this._drained=!0,this._forward()},n.prototype._forward=function(){if(!this._forwarding&&this._drained){this._forwarding=!0;for(var e;null!==(e=this._current.read());)this._drained=this.push(e);this._forwarding=!1}},n.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),this._queue.forEach(function(e){e.destroy&&e.destroy()}),e&&this.emit("error",e),this.emit("close"))},n.prototype._next=function(){function e(){o._forward()}function t(){s._readableState.ended||o.destroy()}function n(){o._current=null,s.removeListener("readable",e),s.removeListener("end",n),s.removeListener("error",i),s.removeListener("close",t),o._next()}function i(e){o.destroy(e)}var o=this,s=this._queue.shift();return"function"==typeof s&&(s=r(s())),s?(this._current=s,s.on("readable",e),s.on("end",n),s.on("error",i),void s.on("close",t)):void this.push(null)}},{inherits:53,stream:30}],55:[function(e,t,n){arguments[4][49][0].apply(n,arguments)},{dup:49}],56:[function(e,t){function n(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}var r=e("wrappy");t.exports=r(n),n.proto=n(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:!0})})},{wrappy:55}],57:[function(e,t){(function(n){var r=e("magnet-uri"),i=e("parse-torrent-file");t.exports=function(e){if("string"==typeof e&&/magnet:/.test(e))return r(e);if("string"==typeof e&&(40===e.length||32===e.length)){var t=r("magnet:?xt=urn:btih:"+e);return t?{infoHash:t.infoHash}:null}if(n.isBuffer(e)&&20===e.length)return{infoHash:e.toString("hex")};if(!n.isBuffer(e))return e&&e.infoHash?e:null;try{return i(e)}catch(o){return null}},t.exports.toMagnetURI=r.encode,t.exports.toTorrentFile=i.encode}).call(this,e("buffer").Buffer)},{buffer:11,"magnet-uri":58,"parse-torrent-file":62}],58:[function(e,t){(function(n){function r(e){var t={},r=e.split("magnet:?")[1];if(!r||0===r.length)return t;var i=r.split("&");i.forEach(function(e){var n=e.split("=");if(2===n.length){var r=n[0],i=n[1];if("dn"===r&&(i=decodeURIComponent(i).replace(/\+/g," ")),("tr"===r||"xs"===r||"as"===r)&&(i=decodeURIComponent(i)),"kt"===r&&(i=decodeURIComponent(i).split("+")),t[r])if(Array.isArray(t[r]))t[r].push(i);else{var o=t[r];t[r]=[o,i]}else t[r]=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 n(s[1],"hex").toString("hex");else if(s=e.match(/^urn:btih:(.{32})/)){var r=o.decode(s[1]);t.infoHash=new n(r,"binary").toString("hex")}})}return t.dn&&(t.name=t.dn),t.kt&&(t.keywords=t.kt),"string"==typeof t.tr?t.announce=[t.tr]:Array.isArray(t.tr)&&(t.announce=t.tr),t.announce&&(t.announceList=t.announce.map(function(e){return[e]})),t}function i(e){e=s({},e),e.infoHash&&!e.xt&&(e.xt="urn:btih:"+e.infoHash),e.name&&!e.dn&&(e.dn=e.name),e.keywords&&!e.kt&&(e.kt=e.keywords),e.announce&&!e.tr&&(e.tr=e.announce),e.announceList&&!e.tr&&(e.tr=a(e.announceList));var t="magnet:?";return Object.keys(e).filter(function(e){return 2===e.length}).forEach(function(n,r){var i=Array.isArray(e[n])?e[n]:[e[n]];i.forEach(function(e,i){!(r>0||i>0)||"kt"===n&&0!==i||(t+="&"),"dn"===n&&(e=encodeURIComponent(e).replace(/%20/g,"+")),("tr"===n||"xs"===n||"as"===n)&&(e=encodeURIComponent(e)),"kt"===n&&(e=encodeURIComponent(e)),t+="kt"===n&&i>0?"+"+e:n+"="+e})}),t}t.exports=r,t.exports.decode=r,t.exports.encode=i;var o=e("thirty-two"),s=e("extend.js"),a=e("flatten")}).call(this,e("buffer").Buffer)},{buffer:11,"extend.js":51,flatten:59,"thirty-two":60}],59:[function(e,t,n){arguments[4][41][0].apply(n,arguments)},{dup:41}],60:[function(e,t,n){var r=e("./thirty-two");n.encode=r.encode,n.decode=r.decode},{"./thirty-two":61}],61:[function(e,t,n){(function(e){function t(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}var r="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",i=[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];n.encode=function(n){var i=0,o=0,s=0,a=0,u=new e(8*t(n));for(e.isBuffer(n)||(n=new e(n));i<n.length;){var c=n[i];s>3?(a=c&255>>s,s=(s+5)%8,a=a<<s|(i+1<n.length?n[i+1]:0)>>8-s,i++):(a=c>>8-(s+5)&31,s=(s+5)%8,0==s&&i++),u[o]=r.charCodeAt(a),o++}for(i=o;i<u.length;i++)u[i]=61;return u},n.decode=function(t){var n,r=0,o=0,s=0;e.isBuffer(t)||(t=new e(t));for(var a=new e(Math.ceil(5*t.length/8)),u=0;u<t.length&&61!=t[u];u++){var c=t[u]-48;if(!(c<i.length))throw new Error("Invalid input - it is not base32 encoded string");o=i[c],3>=r?(r=(r+5)%8,0==r?(n|=o,a[s]=n,s++,n=0):n|=255&o<<8-r):(r=(r+5)%8,n|=255&o>>>r,a[s]=n,s++,n=255&o<<8-r)}return a.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:11}],62:[function(e,t){(function(n){function r(e){n.isBuffer(e)&&(e=u.decode(e)),a(e.info,"info"),a(e.info.name,"info.name"),a(e.info["piece length"],"info['piece length']"),a(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(function(e){a("number"==typeof e.length,"info.files[0].length"),a(e.path,"info.files[0].path")}):a(e.info.length,"info.length");var t={};t.info=e.info,t.infoBuffer=u.encode(e.info),t.infoHash=f.sync(t.infoBuffer),t.name=e.info.name.toString(),t["private"]=!!e.info["private"],e["creation date"]&&(t.created=new Date(1e3*e["creation date"])),n.isBuffer(e.comment)&&(t.comment=e.comment.toString());var r=e["announce-list"];r||(r=e.announce?[[e.announce]]:[]),t.announceList=r.map(function(e){return e.map(function(e){return e.toString()})}),t.announce=[].concat.apply([],t.announceList),t.urlList=(e["url-list"]||[]).map(function(e){return e.toString()});var i=e.info.files||[e.info];t.files=i.map(function(e,n){var r=[].concat(e.name||t.name,e.path||[]).map(function(e){return e.toString()});return{path:c.join.apply(null,[c.sep].concat(r)).slice(1),name:r[r.length-1],length:e.length,offset:i.slice(0,n).reduce(o,0)}}),t.length=i.reduce(o,0);var h=t.files[t.files.length-1];return t.pieceLength=e.info["piece length"],t.lastPieceLength=(h.offset+h.length)%t.pieceLength||t.pieceLength,t.pieces=s(e.info.pieces),t}function i(e){var t={info:e.info};return e.announce&&e.announce[0]&&(t.announce=e.announce[0]),e.announceList&&(t["announce-list"]=e.announceList.map(function(e){return e.map(function(e){return e=new n(e,"utf8"),t.announce||(t.announce=e),e})})),e.created&&(t["creation date"]=e.created.getTime()/1e3|0),u.encode(t)}function o(e,t){return e+t.length}function s(e){for(var t=[],n=0;n<e.length;n+=20)t.push(e.slice(n,n+20).toString("hex"));return t}function a(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}t.exports=r,t.exports.decode=r,t.exports.encode=i;var u=e("bencode"),c=e("path"),f=e("simple-sha1")}).call(this,e("buffer").Buffer)},{bencode:63,buffer:11,path:17,"simple-sha1":68}],63:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"./lib/decode":64,"./lib/encode":65,dup:35}],64:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{buffer:11,dup:36}],65:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:11,dup:37}],66:[function(e,t){function n(e,t,n){Array.isArray(n)||(n=[n]),n.forEach(function(n){e.on(n,function(){var e=[].slice.call(arguments);e.unshift(n),t.emit.apply(t,e)})})}function r(e,t){var r=new i;return n(e,r,t),r}t.exports=n,t.exports.filter=r;var i=e("events").EventEmitter},{events:15}],67:[function(e,t){t.exports=function(e,t){function n(e,n,o){r[e]=o,(0===--i||n)&&(t&&t(n,r),t=null)}var r,i,o;Array.isArray(e)?(r=[],i=e.length):(o=Object.keys(e),r={},i=o.length),i?o?o.forEach(function(t){e[t](n.bind(void 0,t))}):e.forEach(function(e,t){e(n.bind(void 0,t))}):(t&&t(null,r),t=null)}},{}],68:[function(e,t){function n(e,t){return u?("string"==typeof e&&(e=r(e)),void u.digest({name:"sha-1"},e).then(function(e){t(i(new Uint8Array(e)))},function(){t(c(e))})):void setTimeout(t,0,c(e))}function r(e){for(var t=e.length,n=new Uint8Array(t),r=0;t>r;r++)n[r]=e.charCodeAt(r);return n}function i(e){for(var t=e.length,n=[],r=0;t>r;r++){var i=e[r];n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")}var o=e("rusha"),s=new o,a=window.crypto||window.msCrypto||{},u=a.subtle||a.webkitSubtle,c=s.digest.bind(s);try{u.digest({name:"sha-1"},new Uint8Array)["catch"](function(){u=!1})}catch(f){u=!1}delete window.Rusha,t.exports=n,t.exports.sync=c},{rusha:69}],69:[function(e,t){(function(e){!function(){function n(e){"use strict";var t={fill:0},n=function(e){for(e+=9;e%64>0;e+=1);return e},o=function(e,t){for(var n=t>>2;n<e.length;n++)e[n]=0},a=function(e,t,n){e[t>>2]|=128<<24-(t%4<<3),e[((t>>2)+2&-16)+15]=n<<3},u=function(e,t,n,r,i){var o,s=this,a=i%4,u=r%4,c=r-u;if(c>0)switch(a){case 0:e[i+3|0]=s.charCodeAt(n);case 1:e[i+2|0]=s.charCodeAt(n+1);case 2:e[i+1|0]=s.charCodeAt(n+2);case 3:e[0|i]=s.charCodeAt(n+3)}for(o=a;c>o;o=o+4|0)t[i+o>>2]=s.charCodeAt(n+o)<<24|s.charCodeAt(n+o+1)<<16|s.charCodeAt(n+o+2)<<8|s.charCodeAt(n+o+3);switch(u){case 3:e[i+c+1|0]=s.charCodeAt(n+c+2);case 2:e[i+c+2|0]=s.charCodeAt(n+c+1);case 1:e[i+c+3|0]=s.charCodeAt(n+c)}},c=function(e,t,n,r,i){var o,s=this,a=i%4,u=r%4,c=r-u;if(c>0)switch(a){case 0:e[i+3|0]=s[n];case 1:e[i+2|0]=s[n+1];case 2:e[i+1|0]=s[n+2];case 3:e[0|i]=s[n+3]}for(o=4-a;c>o;o=o+=4)t[i+o>>2]=s[n+o]<<24|s[n+o+1]<<16|s[n+o+2]<<8|s[n+o+3];switch(u){case 3:e[i+c+1|0]=s[n+c+2];case 2:e[i+c+2|0]=s[n+c+1];case 1:e[i+c+3|0]=s[n+c]}},f=function(e,t,n,r,o){var s,a=this,u=o%4,c=r%4,f=r-c,h=new Uint8Array(i.readAsArrayBuffer(a.slice(n,n+r)));if(f>0)switch(u){case 0:e[o+3|0]=h[0];case 1:e[o+2|0]=h[1];case 2:e[o+1|0]=h[2];case 3:e[0|o]=h[3]}for(s=4-u;f>s;s=s+=4)t[o+s>>2]=h[s]<<24|h[s+1]<<16|h[s+2]<<8|h[s+3];switch(c){case 3:e[o+f+1|0]=h[f+2];case 2:e[o+f+2|0]=h[f+1];case 1:e[o+f+3|0]=h[f]}},h=function(e){switch(s.getDataType(e)){case"string":return u.bind(e);case"array":return c.bind(e);case"buffer":return c.bind(e);case"arraybuffer":return c.bind(new Uint8Array(e));case"view":return c.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return f.bind(e)}},l=function(e){var t,n,r="0123456789abcdef",i=[],o=new Uint8Array(e);for(t=0;t<o.length;t++)n=o[t],i[t]=r.charAt(n>>4&15)+r.charAt(n>>0&15);return i.join("")},d=function(e){var t;if(65536>=e)return 65536;if(16777216>e)for(t=1;e>t;t<<=1);else for(t=16777216;e>t;t+=16777216);return t},p=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(d(t.padMaxChunkLen+320+20)),t.h32=new Int32Array(t.heap),t.h8=new Int8Array(t.heap),t.core=r({Int32Array:Int32Array,DataView:DataView},{},t.heap),t.buffer=null};p(e||65536);var g=function(e,t){var n=new Int32Array(e,t+320,5);n[0]=1732584193,n[1]=-271733879,n[2]=-1732584194,n[3]=271733878,n[4]=-1009589776},m=function(e,r){var i=n(e),s=new Int32Array(t.heap,0,i>>2);return o(s,e),a(s,e,r),i},y=function(e,n,r){h(e)(t.h8,t.h32,n,r,0)},v=function(e,n,r,i,o){var s=r;o&&(s=m(r,i)),y(e,n,r),t.core.hash(s,t.padMaxChunkLen)},_=function(e,t){var n=new Int32Array(e,t+320,5),r=new Int32Array(5),i=new DataView(r.buffer);return i.setInt32(0,n[0],!1),i.setInt32(4,n[1],!1),i.setInt32(8,n[2],!1),i.setInt32(12,n[3],!1),i.setInt32(16,n[4],!1),r},w=this.rawDigest=function(e){var n=e.byteLength||e.length||e.size;g(t.heap,t.padMaxChunkLen);var r=0,i=t.maxChunkLen;for(r=0;n>r+i;r+=i)v(e,r,i,n,!1);return v(e,r,n-r,n,!0),_(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return l(w(e).buffer)}}function r(e,t,n){"use asm";function r(e,t){e|=0,t|=0;var n=0,r=0,o=0,s=0,a=0,u=0,c=0,f=0,h=0,l=0,d=0,p=0,g=0,m=0;for(o=i[t+320>>2]|0,a=i[t+324>>2]|0,c=i[t+328>>2]|0,h=i[t+332>>2]|0,d=i[t+336>>2]|0,n=0;(n|0)<(e|0);n=n+64|0){for(s=o,u=a,f=c,l=h,p=d,r=0;(r|0)<64;r=r+4|0)m=i[n+r>>2]|0,g=((o<<5|o>>>27)+(a&c|~a&h)|0)+((m+d|0)+1518500249|0)|0,d=h,h=c,c=a<<30|a>>>2,a=o,o=g,i[e+r>>2]=m;for(r=e+64|0;(r|0)<(e+80|0);r=r+4|0)m=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31,g=((o<<5|o>>>27)+(a&c|~a&h)|0)+((m+d|0)+1518500249|0)|0,d=h,h=c,c=a<<30|a>>>2,a=o,o=g,i[r>>2]=m;for(r=e+80|0;(r|0)<(e+160|0);r=r+4|0)m=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31,g=((o<<5|o>>>27)+(a^c^h)|0)+((m+d|0)+1859775393|0)|0,d=h,h=c,c=a<<30|a>>>2,a=o,o=g,i[r>>2]=m;for(r=e+160|0;(r|0)<(e+240|0);r=r+4|0)m=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31,g=((o<<5|o>>>27)+(a&c|a&h|c&h)|0)+((m+d|0)-1894007588|0)|0,d=h,h=c,c=a<<30|a>>>2,a=o,o=g,i[r>>2]=m;for(r=e+240|0;(r|0)<(e+320|0);r=r+4|0)m=(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])<<1|(i[r-12>>2]^i[r-32>>2]^i[r-56>>2]^i[r-64>>2])>>>31,g=((o<<5|o>>>27)+(a^c^h)|0)+((m+d|0)-899497514|0)|0,d=h,h=c,c=a<<30|a>>>2,a=o,o=g,i[r>>2]=m;o=o+s|0,a=a+u|0,c=c+f|0,h=h+l|0,d=d+p|0}i[t+320>>2]=o,i[t+324>>2]=a,i[t+328>>2]=c,i[t+332>>2]=h,i[t+336>>2]=d}var i=new e.Int32Array(n);return{hash:r}}if("undefined"!=typeof t&&(t.exports=n),"undefined"!=typeof window&&(window.Rusha=n),"undefined"!=typeof FileReaderSync){var i=new FileReaderSync,o=new n(4194304);self.onmessage=function(e){var t,n=e.data.data;try{t=o.digest(n),self.postMessage({id:e.data.id,hash:t})}catch(r){self.postMessage({id:e.data.id,error:r.name})}}}var s={getDataType:function(t){if("string"==typeof t)return"string";if(t instanceof Array)return"array";if("undefined"!=typeof e&&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.")}}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],70:[function(e,t){var n=1,r=65535,i=4,o=function(){n=n+1&r},s=setInterval(o,1e3/i|0);s.unref&&s.unref(),t.exports=function(e){var t=i*(e||5),o=[0],s=1,a=n-1&r;return function(e){var u=n-a&r;for(u>t&&(u=t),a=n;u--;)s===t&&(s=0),o[s]=o[0===s?t-1:s-1],s++;e&&(o[s-1]+=e);var c=o[s-1],f=o.length<t?0:o[s===t?0:s];return o.length<i?c:(c-f)*i/o.length}}},{}],71:[function(e,t){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(s.call(t),a(t,{announce:[],dht:"function"==typeof o,rtcConfig:null,peerId:null,port:0,tracker:!0},e),!t.peerId)throw new Error("peerId required");if(!n.browser&&!t.port)throw new Error("port required");!n.browser||t.announce&&0!==t.announce.length||console.warn("Warning: must specify a tracker server to discover peers (required in browser because DHT is not implemented yet) (you can use wss://tracker.webtorrent.io)"),t._externalDHT=!1,t._performedDHTLookup=!1,t._createDHT(t.dhtPort)}t.exports=r;var i=e("debug")("torrent-discovery"),o=e("bittorrent-dht/client"),s=e("events").EventEmitter,a=e("extend.js"),u=e("inherits"),c=e("re-emitter"),f=e("bittorrent-tracker/client");u(r,s),r.prototype.setTorrent=function(e){var t=this;if(!t.torrent){if(e&&e.infoHash)t.torrent=e,t.infoHash=e.infoHash;else{if(t.infoHash)return;t.infoHash=e}i("setTorrent %s",e),t.tracker&&t.tracker!==!0?t.tracker.torrentLength=e.length:t._createTracker(),t.dht&&(t.dht.ready?t._dhtLookupAndAnnounce():t.dht.on("ready",t._dhtLookupAndAnnounce.bind(t)))}},r.prototype.stop=function(e){var t=this;t.tracker&&t.tracker.stop&&t.tracker.stop(),!t._externalDHT&&t.dht&&t.dht.destroy?t.dht.destroy(e):n.nextTick(function(){e(null)})},r.prototype._createDHT=function(e){var t=this;t.dht&&(t.dht?t._externalDHT=!0:t.dht=new o,c(t.dht,t,["peer","error","warning"]),t._externalDHT||t.dht.listen(e))},r.prototype._createTracker=function(){var e=this;if(e.tracker){var t=e.torrent||{infoHash:e.infoHash,announce:e.announce};e.tracker=n.browser?new f(e.peerId,t,{rtcConfig:e.rtcConfig}):new f(e.peerId,e.port,t),c(e.tracker,e,["peer","warning","error"]),e.tracker.start()}},r.prototype._dhtLookupAndAnnounce=function(){var e=this;e._performedDHTLookup||(e._performedDHTLookup=!0,i("lookup"),e.dht.lookup(e.infoHash,function(t){!t&&e.port&&(i("dhtAnnounce"),e.dht.announce(e.infoHash,e.port,function(){e.emit("dhtAnnounce")}))}))}}).call(this,e("_process"))},{_process:18,"bittorrent-dht/client":10,"bittorrent-tracker/client":72,debug:44,events:15,"extend.js":51,inherits:53,"re-emitter":66}],72:[function(e,t){(function(n){function r(e,t,o){var u=this;return u instanceof r?(a.call(u),u._opts=o||{},u._peerId=n.isBuffer(e)?e:new n(e,"hex"),u._infoHash=n.isBuffer(t.infoHash)?t.infoHash:new n(t.infoHash,"hex"),u.torrentLength=t.length,u._numWant=u._opts.numWant||d,u._intervalMs=u._opts.interval||18e5,s("new client %s",u._infoHash.toString("hex")),"string"==typeof t.announce&&(t.announce=[t.announce]),void(u._trackers=(t.announce||[]).filter(function(e){return 0===e.indexOf("ws://")||0===e.indexOf("wss://")}).map(function(e){return new i(u,e,u._opts)}))):new r(e,t,o)}function i(e,t,n){var r=this;a.call(r),r._opts=n||{},r._announceUrl=t,r._peers={},s("new tracker %s",t),r.client=e,r.ready=!1,r._socket=null,r._intervalMs=r.client._intervalMs,r._interval=null}function o(e){return new n(e,"binary").toString("hex")}t.exports=r;var s=e("debug")("webtorrent-tracker"),a=e("events").EventEmitter,u=e("extend.js"),c=e("hat"),f=e("inherits"),h=e("simple-peer"),l=e("simple-websocket"),d=15;f(r,a);var p={};r.prototype.start=function(e){var t=this;t._trackers.forEach(function(t){t.start(e)})},r.prototype.stop=function(e){var t=this;t._trackers.forEach(function(t){t.stop(e)})},r.prototype.complete=function(e){var t=this;t._trackers.forEach(function(t){t.complete(e)})},r.prototype.update=function(e){var t=this;t._trackers.forEach(function(t){t.update(e)})},r.prototype.setInterval=function(e){var t=this;t._intervalMs=e,t._trackers.forEach(function(t){t.setInterval(e)})},f(i,a),i.prototype.start=function(e){var t=this;e=e||{},e.event="started",s("sent `start` %s %s",t._announceUrl,JSON.stringify(e)),t._announce(e),t.setInterval(t._intervalMs)},i.prototype.stop=function(e){var t=this;e=e||{},e.event="stopped",s("sent `stop` %s %s",t._announceUrl,JSON.stringify(e)),t._announce(e),t.setInterval(0)},i.prototype.complete=function(e){var t=this;e=e||{},e.event="completed",e.downloaded=e.downloaded||t.torrentLength||0,s("sent `complete` %s %s",t._announceUrl,JSON.stringify(e)),t._announce(e)},i.prototype.update=function(e){var t=this;e=e||{},s("sent `update` %s %s",t._announceUrl,JSON.stringify(e)),t._announce(e)},i.prototype._init=function(e){var t=this;e&&t.once("ready",e),t._socket||(p[t._announceUrl]?(t._socket=p[t._announceUrl],t._onSocketReady()):(t._socket=p[t._announceUrl]=new l(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)))},i.prototype._onSocketReady=function(){var e=this;e.ready=!0,e.emit("ready")},i.prototype._onSocketWarning=function(e){s("tracker warning %s",e.message)},i.prototype._onSocketMessage=function(e){var t=this;if("object"!=typeof e||null===e)return t.client.emit("warning",new Error("Invalid tracker response"));if(e.info_hash===t.client._infoHash.toString("binary")){s("received %s from %s",JSON.stringify(e),t._announceUrl);var n=e["failure reason"];if(n)return t.client.emit("warning",new Error(n));var r=e["warning message"];r&&t.client.emit("warning",new Error(r));var i=e.interval||e["min interval"];i&&!t._opts.interval&&0!==t._intervalMs&&t.setInterval(1e3*i);var a=e["tracker id"];a&&(t._trackerId=a),e.complete&&t.client.emit("update",{announce:t._announceUrl,complete:e.complete,incomplete:e.incomplete});var u;e.offer&&(u=new h({trickle:!1,config:t._opts.rtcConfig}),u.id=o(e.peer_id),u.once("signal",function(n){var r={info_hash:t.client._infoHash.toString("binary"),peer_id:t.client._peerId.toString("binary"),to_peer_id:e.peer_id,answer:n,offer_id:e.offer_id};t._trackerId&&(r.trackerid=t._trackerId),t._send(r)}),u.signal(e.offer),t.client.emit("peer",u)),e.answer&&(u=t._peers[e.offer_id],u?(u.id=o(e.peer_id),u.signal(e.answer),t.client.emit("peer",u)):s("got unexpected answer: "+JSON.stringify(e.answer)))}},i.prototype._announce=function(e){var t=this;return t.ready?void t._generateOffers(function(n){e=u({uploaded:0,downloaded:0,info_hash:t.client._infoHash.toString("binary"),peer_id:t.client._peerId.toString("binary"),offers:n},e),null!=t.client.torrentLength&&null==e.left&&(e.left=t.client.torrentLength-(e.downloaded||0)),t._trackerId&&(e.trackerid=t._trackerId),t._send(e)}):t._init(t._announce.bind(t,e))},i.prototype._send=function(e){var t=this;s("send %s",JSON.stringify(e)),t._socket.send(e)},i.prototype._generateOffers=function(e){function t(){var e=c(160),t=r._peers[e]=new h({initiator:!0,trickle:!1,config:r._opts.rtcConfig});t.once("signal",function(t){i.push({offer:t,offer_id:e}),n()})}function n(){i.length===r.client._numWant&&(s("generated %s offers",r.client._numWant),e(i))}var r=this,i=[];s("generating %s offers",r.client._numWant);for(var o=0;o<r.client._numWant;++o)t()},i.prototype.setInterval=function(e){var t=this;clearInterval(t._interval),t._intervalMs=e,e&&(t._interval=setInterval(t.update.bind(t),t._intervalMs))}}).call(this,e("buffer").Buffer)},{buffer:11,debug:44,events:15,"extend.js":51,hat:52,inherits:53,"simple-peer":73,"simple-websocket":76}],73:[function(e,t){function n(e){var t=this;return t instanceof n?(s.call(t),e=a({initiator:!1,stream:!1,config:n.config,constraints:n.constraints,channelName:e&&e.initiator?u(160):null,trickle:!0},e),a(t,e),o("new peer initiator: %s channelName: %s",t.initiator,t.channelName),t.destroyed=!1,t.ready=!1,t._pcReady=!1,t._channelReady=!1,t._dataStreams=[],t._iceComplete=!1,t._pc=new p(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),t._channel=null,t.stream&&t._setupVideo(t.stream),t._pc.onaddstream=t._onAddStream.bind(t),void(t.initiator?(t._setupData({channel:t._pc.createDataChannel(t.channelName)}),t._pc.onnegotiationneeded=h(function(){t._pc.createOffer(function(e){i(e),t._pc.setLocalDescription(e);var n=function(){t.emit("signal",t._pc.localDescription||e)};t.trickle||t._iceComplete?n():t.once("_iceComplete",n)},t._onError.bind(t))}),window.mozRTCPeerConnection&&setTimeout(function(){t._pc.onnegotiationneeded()},0)):t._pc.ondatachannel=t._setupData.bind(t))):new n(e)}function r(e){var t=this;l.Duplex.call(t,e),t._peer=e._peer,o("new stream")}function i(e){var t=e.sdp.split("b=AS:30");t.length>1&&(e.sdp=t[0]+"b=AS:1638400"+t[1])}t.exports=n;var o=e("debug")("simple-peer"),s=e("events").EventEmitter,a=e("extend.js"),u=e("hat"),c=e("inherits"),f=e("is-typedarray"),h=e("once"),l=e("stream"),d=e("typedarray-to-buffer"),p="undefined"!=typeof window&&(window.mozRTCPeerConnection||window.RTCPeerConnection||window.webkitRTCPeerConnection),g="undefined"!=typeof window&&(window.mozRTCSessionDescription||window.RTCSessionDescription||window.webkitRTCSessionDescription),m="undefined"!=typeof window&&(window.mozRTCIceCandidate||window.RTCIceCandidate||window.webkitRTCIceCandidate);c(n,s),n.config={iceServers:[{url:"stun:23.21.150.121"}]},n.constraints={},n.prototype.send=function(e,t){var n=this;return n._channelReady?(o("send %s",e),n._channel.send(f.strict(e)||e instanceof ArrayBuffer||e instanceof Blob||"string"==typeof e?e:JSON.stringify(e)),void(t&&t(null))):n.once("ready",n.send.bind(n,e,t))},n.prototype.signal=function(e){var t=this;if(!t.destroyed){if("string"==typeof e)try{e=JSON.parse(e)}catch(n){e={}}if(o("signal %s",JSON.stringify(e)),e.sdp&&t._pc.setRemoteDescription(new g(e),function(){var e="offer"===t._pc.remoteDescription.type;e&&t._pc.createAnswer(function(e){i(e),t._pc.setLocalDescription(e);var n=function(){t.emit("signal",t._pc.localDescription||e)};t.trickle||t._iceComplete?n():t.once("_iceComplete",n)},t._onError.bind(t))},t._onError.bind(t)),e.candidate)try{t._pc.addIceCandidate(new m(e.candidate))}catch(n){t.destroy(new Error("error adding candidate, "+n.message))}e.sdp||e.candidate||t.destroy(new Error("signal() called with invalid signal data"))}},n.prototype.destroy=function(e,t){var n=this;if(!n.destroyed){if(o("destroy (error: %s)",e&&e.message),n.destroyed=!0,n.ready=!1,"function"==typeof e&&(t=e,e=null),t&&n.once("close",t),n._pc){try{n._pc.close()}catch(e){}n._pc.oniceconnectionstatechange=null,n._pc.onsignalingstatechange=null,n._pc.onicecandidate=null}if(n._channel){try{n._channel.close()}catch(e){}n._channel.onmessage=null,n._channel.onopen=null,n._channel.onclose=null}n._pc=null,n._channel=null,n._dataStreams.forEach(function(t){e&&t.emit("error",e),t._readableState.ended||t.push(null),t._writableState.finished||t.end()}),n._dataStreams=[],e&&n.emit("error",e),n.emit("close")}},n.prototype.getDataStream=function(e){var t=this;if(t.destroyed)throw new Error("peer is destroyed");var n=new r(a({_peer:t},e));return t._dataStreams.push(n),n},n.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)},n.prototype._setupVideo=function(e){var t=this;t._pc.addStream(e)},n.prototype._onIceConnectionStateChange=function(){var e=this;if(!e.destroyed){var t=e._pc.iceGatheringState,n=e._pc.iceConnectionState;e.emit("iceConnectionStateChange",t,n),o("iceConnectionStateChange %s %s",t,n),("connected"===n||"completed"===n)&&(e._pcReady=!0,e._maybeReady()),("disconnected"===n||"closed"===n)&&e.destroy()}},n.prototype._maybeReady=function(){var e=this;o("maybeReady pc %s channel %s",e._pcReady,e._channelReady),!e.ready&&e._pcReady&&e._channelReady&&(o("ready"),e.ready=!0,e.emit("ready"))},n.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||(e.emit("signalingStateChange",e._pc.signalingState),o("signalingStateChange %s",e._pc.signalingState))},n.prototype._onIceCandidate=function(e){var t=this;t.destroyed||(e.candidate&&t.trickle?t.emit("signal",{candidate:e.candidate}):e.candidate||(t._iceComplete=!0,t.emit("_iceComplete")))},n.prototype._onChannelMessage=function(e){var t=this;if(!t.destroyed){var n=e.data;if(o("receive %s",n),n instanceof ArrayBuffer)n=d(new Uint8Array(n)),t.emit("message",n);else try{t.emit("message",JSON.parse(n))}catch(r){t.emit("message",n)}t._dataStreams.forEach(function(e){e.push(n)})}},n.prototype._onChannelOpen=function(){var e=this;e.destroyed||(e._channelReady=!0,e._maybeReady())},n.prototype._onChannelClose=function(){var e=this;e.destroyed||(e._channelReady=!1,e.destroy())},n.prototype._onAddStream=function(e){var t=this;t.destroyed||t.emit("stream",e.stream)},n.prototype._onError=function(e){var t=this;t.destroyed||(o("error %s",e.message),t.destroy(e))},c(r,l.Duplex),r.prototype.destroy=function(){var e=this;e._peer.destroy()},r.prototype._read=function(){},r.prototype._write=function(e,t,n){var r=this;r._peer.send(e,n)}},{debug:44,events:15,"extend.js":51,hat:52,inherits:53,"is-typedarray":74,once:56,stream:30,"typedarray-to-buffer":75}],74:[function(e,t,n){arguments[4][39][0].apply(n,arguments)},{dup:39}],75:[function(e,t,n){arguments[4][38][0].apply(n,arguments)},{buffer:11,dup:38,"is-typedarray":74}],76:[function(e,t){function n(e,t){return this instanceof n?(r.call(this),t||(t={}),this._url=e,this._reconnect=void 0!==t.reconnect?t.reconnect:s,void this._init()):new n(e,t) +}t.exports=n;var r=e("events").EventEmitter,i=e("inherits"),o=e("once"),s=5e3;i(n,r),n.prototype.send=function(e){this._ws&&this._ws.readyState===WebSocket.OPEN&&("object"==typeof e&&(e=JSON.stringify(e)),this._ws.send(e))},n.prototype.destroy=function(e){e&&this.once("close",e);try{this._ws.close()}catch(t){this._onclose()}},n.prototype._init=function(){this._errored=!1,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))},n.prototype._onopen=function(){this.emit("ready")},n.prototype._onerror=function(e){this._errored=!0,this.destroy(),this._reconnect?(this._timeout=setTimeout(this._init.bind(this),this._reconnect),this.emit("warning",e)):this.emit("error",e)},n.prototype._onmessage=function(e){var t=e.data;try{t=JSON.parse(e.data)}catch(n){}this.emit("message",t)},n.prototype._onclose=function(){clearTimeout(this._timeout),this._ws&&(this._ws.onopen=null,this._ws.onerror=null,this._ws.onmessage=null,this._ws.onclose=null),this._ws=null,this._errored||this.emit("close")}},{events:15,inherits:53,once:56}],77:[function(e,t){(function(n){var r=e("bencode"),i=e("bitfield"),o=e("events").EventEmitter,s=e("inherits"),a=e("simple-sha1"),u=1e7,c=1e3,f=16384;t.exports=function(e){function t(t){o.call(this),this._wire=t,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._fetching=!1,this._bitfield=new i(0,{grow:c}),n.isBuffer(e)&&this.setMetadata(e)}return s(t,o),t.prototype.name="ut_metadata",t.prototype.onHandshake=function(e){this._infoHash=e,this._infoHashHex=e.toString("hex")},t.prototype.onExtendedHandshake=function(e){return e.m&&e.m.ut_metadata?e.metadata_size?e.metadata_size>u?this.emit("warning",new Error("Peer gave maliciously large metadata size")):(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/f),this._remainingRejects=2*this._numPieces,void(this._fetching&&this._requestPieces())):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))},t.prototype.onMessage=function(e){var t,n;try{var i=e.toString(),o=i.indexOf("ee")+2;t=r.decode(i.substring(0,o)),n=e.slice(o)}catch(s){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece)}},t.prototype.fetch=function(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())},t.prototype.cancel=function(){this._fetching=!1},t.prototype.setMetadata=function(e){if(this._metadataComplete)return!0;try{var t=r.decode(e).info;t&&(e=r.encode(t))}catch(n){}return this._infoHashHex&&this._infoHashHex!==a.sync(e)?!1:(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",r.encode({info:r.decode(this.metadata)})),!0)},t.prototype._send=function(e,t){var i=r.encode(e);n.isBuffer(t)&&(i=n.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,n){var r={msg_type:1,piece:e};"number"==typeof n&&(r.total_size=n),this._send(r,t)},t.prototype._reject=function(e){this._send({msg_type:2,piece:e})},t.prototype._onRequest=function(e){if(!this._metadataComplete)return void this._reject(e);var t=e*f,n=t+f;n>this._metadataSize&&(n=this._metadataSize);var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)},t.prototype._onData=function(e,t){t.length>f||(t.copy(this.metadata,e*f),this._bitfield.set(e),this._checkDone())},t.prototype._onReject=function(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))},t.prototype._requestPieces=function(){this.metadata=new n(this._metadataSize);for(var e=0;e<this._numPieces;e++)this._request(e)},t.prototype._checkDone=function(){for(var e=!0,t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}if(e){var n=this.setMetadata(this.metadata);n||this._failedMetadata()}},t.prototype._failedMetadata=function(){this._bitfield=new i(0,{grow:c}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))},t}}).call(this,e("buffer").Buffer)},{bencode:78,bitfield:6,buffer:11,events:15,inherits:53,"simple-sha1":68}],78:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"./lib/decode":79,"./lib/encode":80,dup:35}],79:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{buffer:11,dup:36}],80:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:11,dup:37}],81:[function(e,t){(function(n){function r(e,t,n){this.swarm=e,this.stream=t,this.id=n;var r=this.wire=new f;this.timeout=null,this.handshaked=!1,this.paused=!0;var i=u(function(){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),r.once("end",i),r.once("close",i),r.once("error",i),r.once("finish",i),r.on("handshake",this._onHandshake.bind(this)),t.pipe(r).pipe(t)}function i(e,t,r){return this instanceof i?(s.call(this),r||(r={}),this.infoHash="string"==typeof e?new n(e,"hex"):e,this.infoHashHex=this.infoHash.toString("hex"),this.peerId="string"==typeof t?new n(t,"hex"):t,this.peerIdHex=this.peerId.toString("hex"),o("new swarm i %s p %s",this.infoHashHex,this.peerIdHex),this.handshake=r.handshake,this.maxPeers=r.maxPeers||h,this.downloaded=0,this.uploaded=0,this.downloadSpeed=c(),this.uploadSpeed=c(),this.wires=[],this._queue=[],this._peers={},this.paused=!1,void(this.destroyed=!1)):new i(e,t,r)}t.exports=i;var o=e("debug")("webtorrent-swarm"),s=e("events").EventEmitter,a=e("inherits"),u=e("once"),c=e("speedometer"),f=e("bittorrent-protocol"),h=30,l=25e3;r.prototype.destroy=function(){o("peer destroy"),this.stream&&this.stream.destroy(),this.wire&&this.wire.destroy(),this.timeout&&clearTimeout(this.timeout),this.stream=null,this.wire=null,this.timeout=null},r.prototype.handshake=function(){this.paused=!1,this.wire.handshake(this.swarm.infoHash,this.swarm.peerId,this.swarm.handshake),o("sent handshake i %s p %s",this.swarm.infoHashHex,this.swarm.peerIdHex),this.handshaked||(this.timeout=setTimeout(function(){this.destroy()}.bind(this),l))},r.prototype._onHandshake=function(e){var t=e.toString("hex");return o("got handshake %s",t),this.swarm.destroyed||t!==this.swarm.infoHashHex?this.destroy():(this.handshaked=!0,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),void this.swarm.emit("wire",this.wire))},a(i,s),Object.defineProperty(i.prototype,"ratio",{get:function(){return 0===this.downloaded?0:this.uploaded/this.downloaded}}),Object.defineProperty(i.prototype,"numQueued",{get:function(){return this._queue.length}}),Object.defineProperty(i.prototype,"numPeers",{get:function(){return this.wires.length}}),i.prototype.addPeer=function(e){if(!this.destroyed&&!this._peers[e.id]){var t=e.getDataStream(),n=new r(this,t,e.id);this._peers[e.id]=n,this._queue.push(n),this._drain()}},i.prototype.pause=function(){o("pause"),this.paused=!0},i.prototype.resume=function(){o("resume"),this.paused=!1,this._drain()},i.prototype.removePeer=function(e){o("removePeer %s",e),this._removePeer(e),this._drain()},i.prototype._removePeer=function(e){o("_removePeer %s",e),e.destroy()},i.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0,e&&this.once("close",e),o("destroy");for(var t in this._peers)this._removePeer(t);this.emit("close")}},i.prototype._drain=function(){if(!(this.paused||this.destroyed||this.numPeers>=this.maxPeers)){o("drain %s queued %s peers %s max",this.numQueued,this.numPeers,this.maxPeers);var e=this._queue.shift();e&&e.handshake()}}}).call(this,e("buffer").Buffer)},{"bittorrent-protocol":82,buffer:11,debug:44,events:15,inherits:53,once:56,speedometer:70}],82:[function(e,t){(function(n){function r(e,t,n,r){this.piece=e,this.offset=t,this.length=n,this.callback=r}function i(){return this instanceof i?(d.Duplex.call(this),c("new wire"),this.amChoking=!0,this.amInterested=!1,this.peerChoking=!0,this.peerInterested=!1,this.peerPieces=new a(0,{grow:p}),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=l(),this.downloadSpeed=l(),this._keepAlive=null,this._timeout=null,this._timeoutMs=0,this.destroyed=!1,this._finished=!1,this._buffer=[],this._bufferSize=0,this._parser=null,this._parserSize=0,this.on("finish",this._onfinish),void this._parseHandshake()):new i}function o(e,t,n,r){for(var i=0;i<e.length;i++){var o=e[i];if(o.piece===t&&o.offset===n&&o.length===r)return 0===i?e.shift():e.splice(i,1),o}return null}function s(e){try{return u.decode(e)}catch(t){console.warn(t)}}t.exports=i;var a=e("bitfield"),u=e("bencode"),c=e("debug")("bittorrent-protocol"),f=e("extend.js"),h=e("inherits"),l=e("speedometer"),d=e("stream"),p=4e5,g=new n("BitTorrent protocol"),m=new n([0,0,0,0]),y=new n([0,0,0,1,0]),v=new n([0,0,0,1,1]),_=new n([0,0,0,1,2]),w=new n([0,0,0,1,3]),b=[0,0,0,0,0,0,0,0],k=[0,0,0,3,9,0,0];h(i,d.Duplex),i.prototype.setKeepAlive=function(e){clearInterval(this._keepAlive),e!==!1&&(this._keepAlive=setInterval(this._push.bind(this,m),6e4))},i.prototype.setTimeout=function(e){this._clearTimeout(),this._timeoutMs=e,this._updateTimeout()},i.prototype.destroy=function(){this.destroyed=!0,this.end()},i.prototype.end=function(){this._onUninterested(),this._onChoke(),d.Duplex.prototype.end.apply(this,arguments)},i.prototype.use=function(e){function t(){}var n=e.prototype.name;if(!n)throw new Error("Extension API requires a named function, e.g. function name() {}");var r=this._nextExt,i=new e(this);"function"!=typeof i.onHandshake&&(i.onHandshake=t),"function"!=typeof i.onExtendedHandshake&&(i.onExtendedHandshake=t),"function"!=typeof i.onMessage&&(i.onMessage=t),this.extendedMapping[r]=n,this._ext[n]=i,this[n]=i,this._nextExt+=1},i.prototype.handshake=function(e,t,r){if("string"==typeof e&&(e=new n(e,"hex")),"string"==typeof t&&(t=new n(t,"hex")),20!==e.length||20!==t.length)throw new Error("infoHash and peerId MUST have length 20");var i=new n(b);i[5]|=16,r&&r.dht&&(i[7]|=1),this._push(n.concat([g,i,e,t]))},i.prototype.choke=function(){if(!this.amChoking){for(this.amChoking=!0;this.peerRequests.length;)this.peerRequests.pop();this._push(y)}},i.prototype.unchoke=function(){this.amChoking&&(this.amChoking=!1,this._push(v))},i.prototype.interested=function(){this.amInterested||(this.amInterested=!0,this._push(_))},i.prototype.uninterested=function(){this.amInterested&&(this.amInterested=!1,this._push(w))},i.prototype.have=function(e){this._message(4,[e],null)},i.prototype.bitfield=function(e){n.isBuffer(e)||(e=e.buffer),this._message(5,[],e)},i.prototype.request=function(e,t,n,i){return i||(i=function(){}),this._finished?i(new Error("wire is closed")):this.peerChoking?i(new Error("peer is choking")):(this.requests.push(new r(e,t,n,i)),this._updateTimeout(),void this._message(6,[e,t,n],null))},i.prototype.piece=function(e,t,n){this.uploaded+=n.length,this.uploadSpeed(n.length),this.emit("upload",n.length),this._message(7,[e,t],n)},i.prototype.cancel=function(e,t,n){this._callback(o(this.requests,e,t,n),new Error("request was cancelled"),null),this._message(8,[e,t,n],null)},i.prototype.port=function(e){var t=new n(k);t.writeUInt16BE(e,5),this._push(t)},i.prototype.extended=function(e,t){if("string"==typeof e&&this.peerExtendedMapping[e]&&(e=this.peerExtendedMapping[e]),"number"!=typeof e)throw new Error("Unrecognized extension: "+e);var r=new n([e]),i=n.isBuffer(t)?t:u.encode(t);this._message(20,[],n.concat([r,i]))},i.prototype._onKeepAlive=function(){this.emit("keep-alive")},i.prototype._onHandshake=function(e,t,n){this.peerId=t,this.peerExtensions=n,this.emit("handshake",e,t,n);var r;for(r in this._ext)this._ext[r].onHandshake(e,t,n);if(n.extended){var i=f({},this.extendedHandshake);i.m={};for(var o in this.extendedMapping)r=this.extendedMapping[o],i.m[r]=Number(o);this.extended(0,u.encode(i))}},i.prototype._onChoke=function(){for(this.peerChoking=!0,this.emit("choke");this.requests.length;)this._callback(this.requests.shift(),new Error("peer is choking"),null)},i.prototype._onUnchoke=function(){this.peerChoking=!1,this.emit("unchoke")},i.prototype._onInterested=function(){this.peerInterested=!0,this.emit("interested")},i.prototype._onUninterested=function(){this.peerInterested=!1,this.emit("uninterested")},i.prototype._onHave=function(e){this.peerPieces.get(e)||(this.peerPieces.set(e,!0),this.emit("have",e))},i.prototype._onBitField=function(e){this.peerPieces=new a(e),this.emit("bitfield",this.peerPieces)},i.prototype._onRequest=function(e,t,n){if(!this.amChoking){var i=function(r,i){s===o(this.peerRequests,e,t,n)&&(r||this.piece(e,t,i))}.bind(this),s=new r(e,t,n,i);this.peerRequests.push(s),this.emit("request",e,t,n,i)}},i.prototype._onPiece=function(e,t,n){this._callback(o(this.requests,e,t,n.length),null,n),this.downloaded+=n.length,this.downloadSpeed(n.length),this.emit("download",n.length),this.emit("piece",e,t,n)},i.prototype._onCancel=function(e,t,n){o(this.peerRequests,e,t,n),this.emit("cancel",e,t,n)},i.prototype._onPort=function(e){this.emit("port",e)},i.prototype._onExtended=function(e,t){var n,r;if(0===e&&(n=s(t))){if(this.peerExtendedHandshake=n,"object"==typeof n.m)for(r in n.m)this.peerExtendedMapping[r]=Number(n.m[r].toString());for(r in this._ext)this.peerExtendedMapping[r]&&this._ext[r].onExtendedHandshake(this.peerExtendedHandshake);this.emit("extended","handshake",this.peerExtendedHandshake)}else this.extendedMapping[e]&&(e=this.extendedMapping[e],this._ext[e]&&this._ext[e].onMessage(t)),this.emit("extended",e,t)},i.prototype._onTimeout=function(){this._callback(this.requests.shift(),new Error("request has timed out"),null),this.emit("timeout")},i.prototype._push=function(e){return this._finished?void 0:this.push(e)},i.prototype._write=function(e,t,r){for(this._bufferSize+=e.length,this._buffer.push(e);this._bufferSize>=this._parserSize;){var i=1===this._buffer.length?this._buffer[0]:n.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[i.slice(this._parserSize)]:[],this._parser(i.slice(0,this._parserSize))}r(null)},i.prototype._read=function(){},i.prototype._callback=function(e,t,n){e&&(this._clearTimeout(),this.peerChoking||this._finished||this._updateTimeout(),e.callback(t,n))},i.prototype._clearTimeout=function(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)},i.prototype._updateTimeout=function(){this._timeoutMs&&this.requests.length&&!this._timeout&&(this._timeout=setTimeout(this._onTimeout.bind(this),this._timeoutMs))},i.prototype._parse=function(e,t){this._parserSize=e,this._parser=t},i.prototype._message=function(e,t,r){var i=r?r.length:0,o=new n(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),r&&this._push(r)},i.prototype._onmessagelength=function(e){var t=e.readUInt32BE(0);t>0?this._parse(t,this._onmessage):(this._onKeepAlive(),this._parse(4,this._onmessagelength))},i.prototype._onmessage=function(e){switch(this._parse(4,this._onmessagelength),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))}this.emit("unknownmessage",e)},i.prototype._parseHandshake=function(){this._parse(1,function(e){var t=e.readUInt8(0);this._parse(t+48,function(e){var n=e.slice(0,t);return"BitTorrent protocol"!==n.toString()?(c("Error: wire not speaking BitTorrent protocol (%s)",n.toString()),void this.end()):(e=e.slice(t),this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(1&e[7]),extended:!!(16&e[5])}),void this._parse(4,this._onmessagelength))}.bind(this))}.bind(this))},i.prototype._onfinish=function(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAlive),this._parse(Number.MAX_VALUE,function(){}),this.peerRequests=[];this.requests.length;)this._callback(this.requests.shift(),new Error("wire was closed"),null)}}).call(this,e("buffer").Buffer)},{bencode:83,bitfield:6,buffer:11,debug:44,"extend.js":51,inherits:53,speedometer:70,stream:30}],83:[function(e,t,n){arguments[4][35][0].apply(n,arguments)},{"./lib/decode":84,"./lib/encode":85,dup:35}],84:[function(e,t,n){arguments[4][36][0].apply(n,arguments)},{buffer:11,dup:36}],85:[function(e,t,n){arguments[4][37][0].apply(n,arguments)},{buffer:11,dup:37}],86:[function(e,t){t.exports=function n(e,t){return void 0===t?function(t){return n(e,t)}:(e-=t.toString().length,e>0?new Array(e+(/\./.test(t)?2:1)).join("0")+t:t+"")}},{}],87:[function(e,t){(function(n,r){function i(e){function t(){o.ready=!0,o.emit("ready")}var o=this;return o instanceof i?(e||(e={}),u.call(o),s.enabled||o.setMaxListeners(0),o.torrentPort=e.torrentPort||0,o.tracker=void 0!==e.tracker?e.tracker:!0,o.rtcConfig=e.rtcConfig,o.torrents=[],o.downloadSpeed=g(),o.uploadSpeed=g(),o.storage="function"==typeof e.storage?e.storage:e.storage!==!1&&"function"==typeof y?y:v,o.peerId=void 0===e.peerId?new r("-WW"+w+"-"+f(48),"utf8"):"string"==typeof e.peerId?new r(e.peerId,"hex"):e.peerId,o.peerIdHex=o.peerId.toString("hex"),o.nodeId=void 0===e.nodeId?new r(f(160),"hex"):"string"==typeof e.nodeId?new r(e.nodeId,"hex"):e.nodeId,o.nodeIdHex=o.nodeId.toString("hex"),e.dht!==!1&&"function"==typeof a&&(o.dht=new a(c({nodeId:o.nodeId},e.dht)),o.dht.listen(e.dhtPort)),s("new webtorrent (peerId %s, nodeId %s)",o.peerIdHex,o.nodeIdHex),void("function"==typeof l?l(e.blocklist,{headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,n){o.blocked=n,t()}):n.nextTick(t))):new i(e)}t.exports=i;var o=e("create-torrent"),s=e("debug")("webtorrent"),a=e("bittorrent-dht/client"),u=e("events").EventEmitter,c=e("extend.js"),f=e("hat"),h=e("inherits"),l=e("load-ip-set"),d=e("run-parallel"),p=e("parse-torrent"),g=e("speedometer"),m=e("zero-fill"),y=e("./lib/fs-storage"),v=e("./lib/storage"),_=e("./lib/torrent");h(i,u);var w=(e("./package.json").version||"0.26.0").match(/([0-9]+)/g).slice(0,2).map(m(2)).join("");Object.defineProperty(i.prototype,"ratio",{get:function(){var e=this,t=e.torrents.reduce(function(e,t){return e+t.uploaded},0),n=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/n}}),i.prototype.get=function(e){var t=this,n=p(e);if(!n||!n.infoHash)return null;for(var r=0,i=t.torrents.length;i>r;r++){var o=t.torrents[r];if(o.infoHash===n.infoHash)return o}return null},i.prototype.add=i.prototype.download=function(e,t,n){function r(e){o.infoHash===e.infoHash&&(n(o),i.removeListener("torrent",r))}var i=this;s("add %s",e),"function"==typeof t&&(n=t,t={}),t||(t={}),t.client=i,t.storage=t.storage||i.storage,t.storageOpts||(t.storageOpts={}),t.tmp&&(t.storageOpts.tmp=t.tmp);var o=new _(e,c({client:i},t));return i.torrents.push(o),n&&i.on("torrent",r),o.on("error",function(e){i.emit("error",e,o)}),o.on("listening",function(e){i.emit("listening",e,o)}),o.on("ready",function(){s("torrent"),i.emit("torrent",o)}),o},i.prototype.seed=function(e,t,n){var r=this;"function"==typeof t&&(n=t,t={}),t||(t={}),t.storageOpts||(t.storageOpts={}),t.storageOpts.noVerify=!0,o.parseInput(e,t,function(i,s){if(i)return r.emit("error",i);var a=s.map(function(e){return e.getStream});o(e,t,function(e,i){return e?r.emit("error",e):void r.add(i,t,function(e){var t=[function(t){e.storage.load(a,t)}];r.dht&&t.push(function(t){e.on("dhtAnnounce",t)}),d(t,function(t){return t?r.emit("error",t):(n&&n(e),void r.emit("seed",e))})})})})},i.prototype.remove=function(e,t){var n=this,r=n.get(e);if(!r)throw new Error("No torrent with id "+e);s("remove"),n.torrents.splice(n.torrents.indexOf(r),1),r.destroy(t)},i.prototype.destroy=function(e){var t=this;s("destroy");var n=t.torrents.map(function(e){return function(n){t.remove(e.infoHash,n)}});t.dht&&n.push(function(e){t.dht.destroy(e)}),d(n,e)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/fs-storage":10,"./lib/storage":3,"./lib/torrent":4,"./package.json":10,_process:18,"bittorrent-dht/client":10,buffer:11,"create-torrent":34,debug:44,events:15,"extend.js":51,hat:52,inherits:53,"load-ip-set":10,"parse-torrent":57,"run-parallel":67,speedometer:70,"zero-fill":86}]},{},[87])(87)});
\ No newline at end of file |