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

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2016-02-08 01:04:19 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-02-08 01:04:19 +0300
commit2d05970bf1a6363463ee93d8a8522ef3e3bb5e4b (patch)
tree7dac2b122a1eb9976af7584912a6cbaa1d1fb219
parent54ea4fd03194b09f59893c115370d8250f4189f7 (diff)
build
-rw-r--r--webtorrent.min.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/webtorrent.min.js b/webtorrent.min.js
index 8b13789..ea5bd5b 100644
--- a/webtorrent.min.js
+++ b/webtorrent.min.js
@@ -1 +1,9 @@
-
+(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.WebTorrent=e()}})(function(){var e,t,r;return function n(e,t,r){function i(s,a){if(!t[s]){if(!e[s]){var f=typeof require=="function"&&require;if(!a&&f)return f(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=t[s]={exports:{}};e[s][0].call(c.exports,function(t){var r=e[s][1][t];return i(r?r:t)},c,c.exports,n,e,t,r)}return t[s].exports}var o=typeof require=="function"&&require;for(var s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,r){t.exports=s;var n=e("debug")("webtorrent:file-stream");var i=e("inherits");var o=e("readable-stream");i(s,o.Readable);function s(e,t){o.Readable.call(this,t);this.destroyed=false;this._torrent=e._torrent;var r=t&&t.start||0;var n=t&&t.end&&t.end<e.length?t.end:e.length-1;var i=e._torrent.pieceLength;this._startPiece=(r+e.offset)/i|0;this._endPiece=(n+e.offset)/i|0;this._piece=this._startPiece;this._offset=r+e.offset-this._startPiece*i;this._missing=n-r+1;this._reading=false;this._notifying=false;this._criticalLength=Math.min(1024*1024/i|0,2)}s.prototype._read=function(){if(this._reading)return;this._reading=true;this._notify()};s.prototype._notify=function(){var e=this;if(!e._reading||e._missing===0)return;if(!e._torrent.bitfield.get(e._piece)){return e._torrent.critical(e._piece,e._piece+e._criticalLength)}if(e._notifying)return;e._notifying=true;var t=e._piece;e._torrent.store.get(t,function(r,i){e._notifying=false;if(e.destroyed)return;if(r)return e.destroy(r);n("read %s (length %s) (err %s)",t,i.length,r&&r.message);if(e._offset){i=i.slice(e._offset);e._offset=0}if(e._missing<i.length){i=i.slice(0,e._missing)}e._missing-=i.length;n("pushing buffer of length %s",i.length);e._reading=false;e.push(i);if(e._missing===0)e.push(null)});e._piece+=1};s.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;if(!this._torrent.destroyed){this._torrent.deselect(this._startPiece,this._endPiece,true)}}},{debug:107,inherits:115,"readable-stream":143}],2:[function(e,t,r){(function(r){t.exports=d;var n=e("end-of-stream");var i=e("events").EventEmitter;var o=e("./file-stream");var s=e("inherits");var a=e("path");var f=e("render-media");var u=e("readable-stream");var c=e("stream-to-blob-url");var l=e("stream-with-known-length-to-buffer");s(d,i);function d(e,t){i.call(this);this._torrent=e;this.name=t.name;this.path=t.path;this.length=t.length;this.offset=t.offset;this.done=false;var r=t.offset;var n=r+t.length-1;this._startPiece=r/this._torrent.pieceLength|0;this._endPiece=n/this._torrent.pieceLength|0;if(this.length===0){this.done=true;this.emit("done")}}d.prototype.select=function(e){if(this.length===0)return;this._torrent.select(this._startPiece,this._endPiece,e)};d.prototype.deselect=function(){if(this.length===0)return;this._torrent.deselect(this._startPiece,this._endPiece,false)};d.prototype.createReadStream=function(e){var t=this;if(this.length===0){var i=new u.PassThrough;r.nextTick(function(){i.end()});return i}var s=new o(t,e);t._torrent.select(s._startPiece,s._endPiece,true,function(){s._notify()});n(s,function(){t._torrent.deselect(s._startPiece,s._endPiece,true)});return s};d.prototype.getBuffer=function(e){l(this.createReadStream(),this.length,e)};d.prototype.getBlobURL=function(e){if(typeof window==="undefined")throw new Error("browser-only method");var t=f.mime[a.extname(this.name).toLowerCase()];c(this.createReadStream(),t,e)};d.prototype.appendTo=function(e,t){if(typeof window==="undefined")throw new Error("browser-only method");f.append(this,e,t)};d.prototype.renderTo=function(e,t){if(typeof window==="undefined")throw new Error("browser-only method");f.render(this,e,t)}}).call(this,e("_process"))},{"./file-stream":1,_process:34,"end-of-stream":110,events:29,inherits:115,path:33,"readable-stream":143,"render-media":144,"stream-to-blob-url":196,"stream-with-known-length-to-buffer":199}],3:[function(e,t,r){t.exports=n;function n(e,t){var r=this;r.pieces=[];r.swarm=e;r.numPieces=t;function n(e){e.on("have",function(e){r.pieces[e]+=1});e.on("bitfield",function(){r.recalculate()});e.on("close",function(){for(var t=0;t<r.numPieces;++t){r.pieces[t]-=e.peerPieces.get(t)}})}r.swarm.wires.forEach(n);r.swarm.on("wire",function(e){r.recalculate();n(e)});r.recalculate()}n.prototype.recalculate=function(){var e=this;for(var t=0;t<e.numPieces;++t){e.pieces[t]=0}e.swarm.wires.forEach(function(t){for(var r=0;r<e.numPieces;++r){e.pieces[r]+=t.peerPieces.get(r)}})};n.prototype.getRarestPiece=function(e){var t=this;var r=[];var n=Infinity;e=e||function(){return true};for(var i=0;i<t.numPieces;++i){if(!e(i))continue;var o=t.pieces[i];if(o===n){r.push(i)}else if(o<n){r=[i];n=o}}if(r.length>0){return r[Math.random()*r.length|0]}else{return-1}}},{}],4:[function(e,t,r){(function(r,n){t.exports=F;var i=e("addr-to-ip-port");var o=e("bitfield");var s=e("chunk-store-stream/write");var a=e("cpus");var f=e("create-torrent");var u=e("debug")("webtorrent:torrent");var c=e("torrent-discovery");var l=e("events").EventEmitter;var d=e("xtend/mutable");var h=e("fs-chunk-store");var p=e("immediate-chunk-store");var m=e("inherits");var v=e("multistream");var g=e("os");var y=e("run-parallel");var _=e("run-parallel-limit");var b=e("parse-torrent");var w=e("path");var E=e("path-exists");var x=e("torrent-piece");var k=e("pump");var S=e("random-iterate");var B=e("re-emitter");var I=e("simple-sha1");var A=e("bittorrent-swarm");var C=e("uniq");var T=e("ut_metadata");var L=e("ut_pex");var R=e("./file");var U=e("./rarity-map");var P=e("./server");var j=128*1024;var O=3e4;var M=5e3;var D=3*x.BLOCK_LENGTH;var N=.5;var H=1;var q=1e4;var z=2;var W=typeof E.sync==="function"?w.join(E.sync("/tmp")?"/tmp":g.tmpDir(),"webtorrent"):"/tmp/webtorrent";m(F,l);function F(e,t){l.call(this);if(!u.enabled)this.setMaxListeners(0);u("new torrent");this.client=t.client;this.announce=t.announce;this.urlList=t.urlList;this.path=t.path;this._store=t.store||h;this.strategy=t.strategy||"sequential";this._rechokeNumSlots=t.uploads===false||t.uploads===0?0:+t.uploads||10;this._rechokeOptimisticWire=null;this._rechokeOptimisticTime=0;this._rechokeIntervalId=null;this.ready=false;this.destroyed=false;this.metadata=null;this.store=null;this.numBlockedPeers=0;this.files=null;this.done=false;this._amInterested=false;this.pieces=[];this._selections=[];this._critical=[];this._servers=[];if(e!=null)this._onTorrentId(e)}Object.defineProperty(F.prototype,"timeRemaining",{get:function(){if(this.done)return 0;if(!this.swarm||this.swarm.downloadSpeed()===0)return Infinity;return(this.length-this.downloaded)/this.swarm.downloadSpeed()*1e3}});Object.defineProperty(F.prototype,"downloaded",{get:function(){if(!this.bitfield)return 0;var e=0;for(var t=0,r=this.pieces.length;t<r;++t){if(this.bitfield.get(t)){e+=t===r-1?this.lastPieceLength:this.pieceLength}else{var n=this.pieces[t];e+=n.length-n.missing}}return e}});Object.defineProperty(F.prototype,"received",{get:function(){return this.swarm?this.swarm.downloaded:0}});Object.defineProperty(F.prototype,"uploaded",{get:function(){return this.swarm?this.swarm.uploaded:0}});Object.defineProperty(F.prototype,"progress",{get:function(){return this.length?this.downloaded/this.length:0}});Object.defineProperty(F.prototype,"ratio",{get:function(){return this.uploaded/(this.downloaded||1)}});Object.defineProperty(F.prototype,"downloadSpeed",{get:function(){return this.swarm?this.swarm.downloadSpeed():0}});Object.defineProperty(F.prototype,"uploadSpeed",{get:function(){return this.swarm?this.swarm.uploadSpeed():0}});Object.defineProperty(F.prototype,"numPeers",{get:function(){return this.swarm?this.swarm.numPeers:0}});Object.defineProperty(F.prototype,"torrentFileBlobURL",{get:function(){if(typeof window==="undefined")throw new Error("browser-only property");if(!this.torrentFile)return null;return URL.createObjectURL(new Blob([this.torrentFile],{type:"application/x-bittorrent"}))}});F.prototype._onTorrentId=function(e){var t=this;if(t.destroyed)return;b.remote(e,function(e,r){if(t.destroyed)return;if(e)return t._onError(e);t._onParsedTorrent(r)})};F.prototype._onParsedTorrent=function(e){var t=this;if(t.destroyed)return;t._processParsedTorrent(e);if(!t.infoHash){return t._onError(new Error("Malformed torrent data: No info hash"))}if(!t.path)t.path=w.join(W,t.infoHash);t.swarm=new A(t.infoHash,t.client.peerId,{handshake:{dht:t.private?false:!!t.client.dht},maxConns:t.client.maxConns});t.swarm.on("error",t._onError.bind(t));t.swarm.on("wire",t._onWire.bind(t));t.swarm.on("download",function(e){t.client._downloadSpeed(e);t.client.emit("download",e);t.emit("download",e)});t.swarm.on("upload",function(e){t.client._uploadSpeed(e);t.client.emit("upload",e);t.emit("upload",e)});t.swarm.listen(t.client.torrentPort,t._onSwarmListening.bind(t));t.emit("infoHash",t.infoHash)};F.prototype._processParsedTorrent=function(e){if(this.announce){e.announce=e.announce.concat(this.announce)}if(this.client.tracker&&n.WEBTORRENT_ANNOUNCE){e.announce=e.announce.concat(n.WEBTORRENT_ANNOUNCE)}if(this.client.tracker&&e.announce.length===0){e.announce=f.announceList.map(function(e){return e[0]})}if(this.urlList){e.urlList=e.urlList.concat(this.urlList)}C(e.announce);C(e.urlList);d(this,e);this.magnetURI=b.toMagnetURI(e);this.torrentFile=b.toTorrentFile(e)};F.prototype._onSwarmListening=function(){var e=this;if(e.destroyed)return;if(e.swarm.server)e.client.torrentPort=e.swarm.address().port;e.discovery=new c({announce:e.announce,dht:e.private?false:e.client.dht,tracker:e.client.tracker,peerId:e.client.peerId,port:e.client.torrentPort,rtcConfig:e.client._rtcConfig,wrtc:e.client._wrtc});e.discovery.on("error",e._onError.bind(e));e.discovery.on("peer",e.addPeer.bind(e));B(e.discovery,e,["trackerAnnounce","dhtAnnounce","warning"]);if(e.info)e._onMetadata(e);else e.discovery.setTorrent(e.infoHash);e.emit("listening",e.client.torrentPort)};F.prototype._onMetadata=function(e){var t=this;if(t.metadata||t.destroyed)return;u("got metadata");var r;if(e&&e.infoHash){r=e}else{try{r=b(e)}catch(n){return t._onError(n)}}t._processParsedTorrent(r);t.metadata=t.torrentFile;t.discovery.setTorrent(t);if(t.urlList)t.urlList.forEach(t.addWebSeed.bind(t));t.rarityMap=new U(t.swarm,t.pieces.length);t.store=new p(new t._store(t.pieceLength,{files:t.files.map(function(e){return{path:w.join(t.path,e.path),length:e.length,offset:e.offset}}),length:t.length}));t.files=t.files.map(function(e){return new R(t,e)});t._hashes=t.pieces;t.pieces=t.pieces.map(function(e,r){var n=r===t.pieces.length-1?t.lastPieceLength:t.pieceLength;return new x(n)});t._reservations=t.pieces.map(function(){return[]});t.bitfield=new o(t.pieces.length);t.swarm.wires.forEach(function(e){if(e.ut_metadata)e.ut_metadata.setMetadata(t.metadata);t._onWireWithMetadata(e)});u("verifying existing torrent data");_(t.pieces.map(function(e,r){return function(e){t.store.get(r,function(n,i){if(n)return e(null);I(i,function(n){if(n===t._hashes[r]){if(!t.pieces[r])return;u("piece verified %s",r);t.pieces[r]=null;t._reservations[r]=null;t.bitfield.set(r,true)}else{u("piece invalid %s",r)}e(null)})})}}),a().length,function(e){if(e)return t._onError(e);u("done verifying");t._onStore()});t.emit("metadata")};F.prototype._onStore=function(){var e=this;if(e.destroyed)return;u("on store");e.select(0,e.pieces.length-1,false);e._rechokeIntervalId=setInterval(e._rechoke.bind(e),q);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();e.ready=true;e.emit("ready");e._checkDone()};F.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;u("destroy");t.client.remove(t);if(t._rechokeIntervalId){clearInterval(t._rechokeIntervalId);t._rechokeIntervalId=null}var r=[];t._servers.forEach(function(e){r.push(function(t){e.destroy(t)})});if(t.swarm)r.push(function(e){t.swarm.destroy(e)});if(t.discovery)r.push(function(e){t.discovery.stop(e)});if(t.store)r.push(function(e){t.store.close(e)});y(r,e)};F.prototype.addPeer=function(e){var t=this;if(t.destroyed)throw new Error("torrent is destroyed");function r(){t.swarm.addPeer(e);t.emit("peer",e)}if(t.client.blocked){var n=typeof e==="string"?e:e.remoteAddress;if(n&&t.client.blocked.contains(i(n)[0])){t.numBlockedPeers+=1;t.emit("blockedPeer",e);return false}}if(t.swarm)r();else t.once("listening",r);return true};F.prototype.addWebSeed=function(e){if(this.destroyed)throw new Error("torrent is destroyed");u("add web seed %s",e);this.swarm.addWebSeed(e,this)};F.prototype.select=function(e,t,r,n){var i=this;if(i.destroyed)throw new Error("torrent is destroyed");if(e>t||e<0||t>=i.pieces.length){throw new Error("invalid selection ",e,":",t)}r=Number(r)||0;u("select %s-%s (priority %s)",e,t,r);i._selections.push({from:e,to:t,offset:0,priority:r,notify:n||$});i._selections.sort(function(e,t){return t.priority-e.priority});i._updateSelections()};F.prototype.deselect=function(e,t,r){var n=this;if(n.destroyed)throw new Error("torrent is destroyed");r=Number(r)||0;u("deselect %s-%s (priority %s)",e,t,r);for(var i=0;i<n._selections.length;++i){var o=n._selections[i];if(o.from===e&&o.to===t&&o.priority===r){n._selections.splice(i--,1);break}}n._updateSelections()};F.prototype.critical=function(e,t){var r=this;if(r.destroyed)throw new Error("torrent is destroyed");u("critical %s-%s",e,t);for(var n=e;n<=t;++n){r._critical[n]=true}r._updateSelections()};F.prototype._onWire=function(e,t){var r=this;u("got wire (%s)",t||"Unknown");if(t){var n=i(t);e.remoteAddress=n[0];e.remotePort=n[1]}if(e.peerExtensions.dht&&r.client.dht&&r.client.dht.listening){e.on("port",function(t){if(!e.remoteAddress)return u("ignoring PORT from peer with no address");if(t===0||t>65536)return u("ignoring invalid PORT from peer");u("port: %s (from %s)",t,e.remoteAddress+":"+e.remotePort);r.client.dht.addNode({host:e.remoteAddress,port:t})});e.port(r.client.dht.address().port)}e.on("timeout",function(){u("wire timeout (%s)",t);e.destroy()});e.setTimeout(O,true);e.setKeepAlive(true);e.use(T(r.metadata));e.ut_metadata.on("warning",function(e){u("ut_metadata warning: %s",e.message)});if(!r.metadata){e.ut_metadata.on("metadata",function(e){u("got metadata via ut_metadata");r._onMetadata(e)});e.ut_metadata.fetch()}if(typeof L==="function"&&!r.private){e.use(L());e.ut_pex.on("peer",function(e){u("ut_pex: got peer: %s (from %s)",e,t);r.addPeer(e)});e.ut_pex.on("dropped",function(e){var n=r.swarm._peers[e];if(n&&!n.connected){u("ut_pex: dropped peer: %s (from %s)",e,t);r.swarm.removePeer(e)}})}r.emit("wire",e,t);if(r.metadata){r._onWireWithMetadata(e)}};F.prototype._onWireWithMetadata=function(e){var t=this;var r=null;function n(){if(t.destroyed||e.destroyed)return;if(t.swarm.numQueued>2*(t.swarm.numConns-t.swarm.numPeers)&&e.amInterested){e.destroy()}else{r=setTimeout(n,M);if(r.unref)r.unref()}}var i=0;function o(){if(e.peerPieces.length!==t.pieces.length)return;for(;i<t.pieces.length;++i){if(!e.peerPieces.get(i))return}e.isSeeder=true;e.choke()}e.on("bitfield",function(){o();t._update()});e.on("have",function(){o();t._update()});e.once("interested",function(){e.unchoke()});e.on("close",function(){clearTimeout(r)});e.on("choke",function(){clearTimeout(r);r=setTimeout(n,M);if(r.unref)r.unref()});e.on("unchoke",function(){clearTimeout(r);t._update()});e.on("request",function(r,n,i,o){if(i>j){return e.destroy()}if(t.pieces[r])return;t.store.get(r,{offset:n,length:i},o)});e.bitfield(t.bitfield);e.interested();r=setTimeout(n,M);if(r.unref)r.unref();e.isSeeder=false;o()};F.prototype._updateSelections=function(){var e=this;if(!e.swarm||e.destroyed)return;if(!e.metadata)return e.once("metadata",e._updateSelections.bind(e));r.nextTick(e._gcSelections.bind(e));e._updateInterest();e._update()};F.prototype._gcSelections=function(){var e=this;for(var t=0;t<e._selections.length;t++){var r=e._selections[t];var n=r.offset;while(e.bitfield.get(r.from+r.offset)&&r.from+r.offset<r.to){r.offset++}if(n!==r.offset)r.notify();if(r.to!==r.from+r.offset)continue;if(!e.bitfield.get(r.from+r.offset))continue;e._selections.splice(t--,1);r.notify();e._updateInterest()}if(!e._selections.length)e.emit("idle")};F.prototype._updateInterest=function(){var e=this;var t=e._amInterested;e._amInterested=!!e._selections.length;e.swarm.wires.forEach(function(t){if(e._amInterested)t.interested();else t.uninterested()});if(t===e._amInterested)return;if(e._amInterested)e.emit("interested");else e.emit("uninterested")};F.prototype._update=function(){var e=this;if(e.destroyed)return;var t=S(e.swarm.wires);var r;while(r=t()){e._updateWire(r)}};F.prototype._updateWire=function(e){var t=this;if(e.peerChoking)return;if(!e.downloaded)return o();var r=Y(e,N);if(e.requests.length>=r)return;var n=Y(e,H);f(false)||f(true);function i(t,r,n,i){return function(o){return o>=t&&o<=r&&!(o in n)&&e.peerPieces.get(o)&&(!i||i(o))}}function o(){if(e.requests.length)return;var r=t._selections.length;while(r--){var n=t._selections[r];var o;if(t.strategy==="rarest"){var s=n.from+n.offset;var a=n.to;var f=a-s+1;var u={};var c=0;var l=i(s,a,u);while(c<f){o=t.rarityMap.getRarestPiece(l);if(o<0)break;if(t._request(e,o,false))return;u[o]=true;c+=1}}else{for(o=n.to;o>=n.from+n.offset;--o){if(!e.peerPieces.get(o))continue;if(t._request(e,o,false))return}}}}function s(){var r=e.downloadSpeed()||1;if(r>D)return function(){return true};var n=Math.max(1,e.requests.length)*x.BLOCK_LENGTH/r;var i=10;var o=0;return function(e){if(!i||t.bitfield.get(e))return true;var s=t.pieces[e].missing;for(;o<t.swarm.wires.length;o++){var a=t.swarm.wires[o];var f=a.downloadSpeed();if(f<D)continue;if(f<=r)continue;if(!a.peerPieces.get(e))continue;if((s-=f*n)>0)continue;i--;return false}return true}}function a(e){var r=e;for(var n=e;n<t._selections.length&&t._selections[n].priority;n++){r=n}var i=t._selections[e];t._selections[e]=t._selections[r];t._selections[r]=i}function f(r){if(e.requests.length>=n)return true;var o=s();for(var f=0;f<t._selections.length;f++){var u=t._selections[f];var c;if(t.strategy==="rarest"){var l=u.from+u.offset;var d=u.to;var h=d-l+1;var p={};var m=0;var v=i(l,d,p,o);while(m<h){c=t.rarityMap.getRarestPiece(v);if(c<0)break;while(t._request(e,c,t._critical[c]||r)){}if(e.requests.length<n){p[c]=true;m++;continue}if(u.priority)a(f);return true}}else{for(c=u.from+u.offset;c<=u.to;c++){if(!e.peerPieces.get(c)||!o(c))continue;while(t._request(e,c,t._critical[c]||r)){}if(e.requests.length<n)continue;if(u.priority)a(f);return true}}}return false}};F.prototype._rechoke=function(){var e=this;if(e._rechokeOptimisticTime>0)e._rechokeOptimisticTime-=1;else e._rechokeOptimisticWire=null;var t=[];e.swarm.wires.forEach(function(r){if(!r.isSeeder&&r!==e._rechokeOptimisticWire){t.push({wire:r,downloadSpeed:r.downloadSpeed(),uploadSpeed:r.uploadSpeed(),salt:Math.random(),isChoked:true})}});t.sort(s);var r=0;var n=0;for(;n<t.length&&r<e._rechokeNumSlots;++n){t[n].isChoked=false;if(t[n].wire.peerInterested)r+=1}if(!e._rechokeOptimisticWire&&n<t.length&&e._rechokeNumSlots){var i=t.slice(n).filter(function(e){return e.wire.peerInterested});var o=i[V(i.length)];if(o){o.isChoked=false;e._rechokeOptimisticWire=o.wire;e._rechokeOptimisticTime=z}}t.forEach(function(e){if(e.wire.amChoking!==e.isChoked){if(e.isChoked)e.wire.choke();else e.wire.unchoke()}});function s(e,t){if(e.downloadSpeed!==t.downloadSpeed){return t.downloadSpeed-e.downloadSpeed}if(e.uploadSpeed!==t.uploadSpeed){return t.uploadSpeed-e.uploadSpeed}if(e.wire.amChoking!==t.wire.amChoking){return e.wire.amChoking?1:-1}return e.salt-t.salt}};F.prototype._hotswap=function(e,t){var r=this;var n=e.downloadSpeed();if(n<x.BLOCK_LENGTH)return false;if(!r._reservations[t])return false;var i=r._reservations[t];if(!i){return false}var o=Infinity;var s;var a;for(a=0;a<i.length;a++){var f=i[a];if(!f||f===e)continue;var u=f.downloadSpeed();if(u>=D)continue;if(2*u>n||u>o)continue;s=f;o=u}if(!s)return false;for(a=0;a<i.length;a++){if(i[a]===s)i[a]=null}for(a=0;a<s.requests.length;a++){var c=s.requests[a];if(c.piece!==t)continue;r.pieces[t].cancel(c.offset/x.BLOCK_SIZE|0)}r.emit("hotswap",s,e,t);return true};F.prototype._request=function(e,t,n){var i=this;var o=e.requests.length;if(i.bitfield.get(t))return false;var s=Y(e,H);if(o>=s)return false;var a=i.pieces[t];var f=a.reserve();if(f===-1&&n&&i._hotswap(e,t)){f=a.reserve()}if(f===-1)return false;var c=i._reservations[t];if(!c)c=i._reservations[t]=[];var l=c.indexOf(null);if(l===-1)l=c.length;c[l]=e;var d=a.chunkOffset(f);var h=a.chunkLength(f);e.request(t,d,h,function m(r,n){if(!i.ready)return i.once("ready",function(){m(r,n)});if(c[l]===e)c[l]=null;if(a!==i.pieces[t])return p();if(r){u("error getting piece %s (offset: %s length: %s) from %s: %s",t,d,h,e.remoteAddress+":"+e.remotePort,r.message);a.cancel(f);p();return}u("got piece %s (offset: %s length: %s) from %s",t,d,h,e.remoteAddress+":"+e.remotePort);if(!a.set(f,n,e))return p();var o=a.flush();I(o,function(e){if(e===i._hashes[t]){if(!i.pieces[t])return;u("piece verified %s",t);i.pieces[t]=null;i._reservations[t]=null;i.bitfield.set(t,true);i.store.put(t,o);i.swarm.wires.forEach(function(e){e.have(t)});i._checkDone()}else{i.pieces[t]=new x(a.length);i.emit("warning",new Error("Piece "+t+" failed verification"))}p()})});function p(){r.nextTick(function(){i._update()})}return true};F.prototype._checkDone=function(){var e=this;if(e.destroyed)return;e.files.forEach(function(t){if(t.done)return;for(var r=t._startPiece;r<=t._endPiece;++r){if(!e.bitfield.get(r))return}t.done=true;t.emit("done");u("file done: "+t.name)});var t=true;for(var r=0;r<e._selections.length;r++){var n=e._selections[r];for(var i=n.from;i<=n.to;i++){if(!e.bitfield.get(i)){t=false;break}}if(!t)break}if(!e.done&&t){e.done=true;e.emit("done");u("torrent done: "+e.infoHash);if(e.discovery.tracker)e.discovery.tracker.complete()}e._gcSelections()};F.prototype.load=function(e,t){var r=this;if(r.destroyed)throw new Error("torrent is destroyed");if(!r.ready)return r.once("ready",function(){r.load(e,t)});if(!Array.isArray(e))e=[e];if(!t)t=$;var n=new v(e);var i=new s(r.store,r.pieceLength);k(n,i,function(e){if(e)return t(e);r.pieces.forEach(function(e,t){r.pieces[t]=null;r._reservations[t]=null;r.bitfield.set(t,true)});r._checkDone();t(null)})};F.prototype.createServer=function(e){if(typeof P!=="function")throw new Error("node.js-only method");if(this.destroyed)throw new Error("torrent is destroyed");var t=new P(this,e);this._servers.push(t);return t};F.prototype.pause=function(){if(this.destroyed)return;this.swarm.pause()};F.prototype.resume=function(){if(this.destroyed)return;this.swarm.resume()};F.prototype._onError=function(e){var t=this;u("torrent error: %s",e.message||e);t.emit("error",e);t.destroy()};function Y(e,t){return Math.ceil(2+t*e.downloadSpeed()/x.BLOCK_LENGTH)}function V(e){return Math.random()*e|0}function $(){}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./file":2,"./rarity-map":3,"./server":24,_process:34,"addr-to-ip-port":5,bitfield:6,"bittorrent-swarm":7,"chunk-store-stream/write":77,cpus:78,"create-torrent":79,debug:107,events:29,"fs-chunk-store":116,"immediate-chunk-store":114,inherits:115,multistream:117,os:24,"parse-torrent":118,path:33,"path-exists":24,pump:128,"random-iterate":131,"re-emitter":132,"run-parallel":184,"run-parallel-limit":183,"simple-sha1":193,"torrent-discovery":202,"torrent-piece":203,uniq:204,ut_metadata:205,ut_pex:24,"xtend/mutable":211}],5:[function(e,t,r){var n=/^\[?([^\]]+)\]?:(\d+)$/;var i={};var o=0;t.exports=function s(e){if(o===1e5)t.exports.reset();if(!i[e]){var r=n.exec(e);if(!r)throw new Error("invalid addr: "+e);i[e]=[r[1],Number(r[2])];o+=1}return i[e]};t.exports.reset=function a(){i={};o=0}},{}],6:[function(e,t,r){(function(e){var r=typeof e!=="undefined"?e:typeof Int8Array!=="undefined"?Int8Array:function(e){var t=new Array(e);for(var r=0;r<e;r++)t[r]=0};function n(e,t){if(!(this instanceof n)){return new n(e,t)}if(arguments.length===0){e=0}this.grow=t&&(isFinite(t.grow)&&i(t.grow)||t.grow)||0;if(typeof e==="number"||e===undefined){e=new r(i(e));if(e.fill&&!e._isBuffer)e.fill(0)}this.buffer=e}function i(e){var t=e>>3;if(e%8!==0)t++;return t}n.prototype.get=function(e){var t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)};n.prototype.set=function(e,t){var r=e>>3;if(t||arguments.length===1){if(this.buffer.length<r+1)this._grow(Math.max(r+1,Math.min(2*this.buffer.length,this.grow)));this.buffer[r]|=128>>e%8}else if(r<this.buffer.length){this.buffer[r]&=~(128>>e%8)}};n.prototype._grow=function(e){if(this.buffer.length<e&&e<=this.grow){var t=new r(e);if(t.fill)t.fill(0);if(this.buffer.copy)this.buffer.copy(t,0);else{for(var n=0;n<this.buffer.length;n++){t[n]=this.buffer[n]}}this.buffer=t}};if(typeof t!=="undefined")t.exports=n}).call(this,e("buffer").Buffer)},{buffer:25}],7:[function(e,t,r){(function(r,n){t.exports=p;var i=e("addr-to-ip-port");var o=e("debug")("bittorrent-swarm");var s=e("events").EventEmitter;var a=e("inherits");var f=e("net");var u=e("speedometer");var c=e("./lib/peer");var l=e("./lib/tcp-pool");var d=55;var h=[1e3,5e3,15e3];a(p,s);function p(e,t,r){var i=this;if(!(i instanceof p))return new p(e,t,r);s.call(i);i.infoHash=typeof e==="string"?e:e.toString("hex");i.infoHashBuffer=new n(i.infoHash,"hex");i.peerId=typeof t==="string"?t:t.toString("hex");i.peerIdBuffer=new n(i.peerId,"hex");if(!r)r={};o("new swarm (i %s p %s)",i.infoHash,i.peerId);i.handshakeOpts=r.handshake;i.maxConns=Number(r.maxConns)||d;i.destroyed=false;i.listening=false;i.paused=false;i.server=null;i.wires=[];i._queue=[];i._peers={};i._peersLength=0;i._port=0;i.downloaded=0;i.uploaded=0;i.downloadSpeed=u();i.uploadSpeed=u()}Object.defineProperty(p.prototype,"ratio",{get:function(){var e=this;return e.uploaded/e.downloaded||0}});Object.defineProperty(p.prototype,"numQueued",{get:function(){var e=this;return e._queue.length+(e._peersLength-e.numConns)}});Object.defineProperty(p.prototype,"numConns",{get:function(){var e=this;var t=0;for(var r in e._peers){var n=e._peers[r];if(n&&n.connected)t+=1}return t}});Object.defineProperty(p.prototype,"numPeers",{get:function(){var e=this;return e.wires.length}});p.prototype.addPeer=function(e){var t=this;t._addPeer(e)};p.prototype._addPeer=function(e){var t=this;if(t.destroyed){if(e&&e.destroy)e.destroy(new Error("swarm already destroyed"));return null}if(typeof e==="string"&&!t._validAddr(e)){o("ignoring invalid peer %s (from swarm.addPeer)",e);return null}var r=e&&e.id||e;if(t._peers[r])return;o("addPeer %s",r);var n;if(typeof e==="string"){n=c.createOutgoingTCPPeer(e,t)}else{if(t.paused){e.destroy(new Error("swarm paused"));return null}n=c.createWebRTCPeer(e,t)}t._peers[n.id]=n;t._peersLength+=1;if(typeof e==="string"){t._queue.push(n);t._drain()}return n};p.prototype.addWebSeed=function(e,t){var r=this;if(r.destroyed)return;if(!/^https?:\/\/.+/.test(e)){o("ignoring invalid web seed %s (from swarm.addWebSeed)",e);return}if(r._peers[e])return;o("addWebSeed %s",e);var n=c.createWebPeer(e,t,r);r._peers[n.id]=n;r._peersLength+=1};p.prototype._addIncomingPeer=function(e){var t=this;if(t.destroyed)return e.destroy(new Error("swarm already destroyed"));if(t.paused)return e.destroy(new Error("swarm paused"));if(!t._validAddr(e.addr)){return e.destroy(new Error("invalid addr "+e.addr+" (from incoming)"))}o("_addIncomingPeer %s",e.id);t._peers[e.id]=e;t._peersLength+=1};p.prototype.removePeer=function(e){var t=this;var r=t._peers[e];if(!r)return;o("removePeer %s",e);t._peers[e]=null;t._peersLength-=1;r.destroy();t._drain()};p.prototype.pause=function(){var e=this;if(e.destroyed)return;o("pause");e.paused=true};p.prototype.resume=function(){var e=this;if(e.destroyed)return;o("resume");e.paused=false;e._drain()};p.prototype.listen=function(e,t,n){var i=this;if(typeof t==="function"){n=t;t=undefined}if(i.listening)throw new Error("swarm already listening");if(n)i.once("listening",n);if(typeof l==="function"){i._port=e||l.getDefaultListenPort(i.infoHash);i._hostname=t;o("listen %s",e);var s=l.addSwarm(i);i.server=s.server}else{r.nextTick(function(){i._onListening(0)})}};p.prototype._onListening=function(e){var t=this;t._port=e;t.listening=true;t.emit("listening")};p.prototype.address=function(){var e=this;if(!e.listening)return null;return e.server?e.server.address():{port:0,family:"IPv4",address:"127.0.0.1"}};p.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;t.listening=false;t.paused=false;if(e)t.once("close",e);o("destroy");for(var n in t._peers){t.removePeer(n)}if(typeof l==="function"){l.removeSwarm(t,function(){t.emit("close")})}else{r.nextTick(function(){t.emit("close")})}};p.prototype._drain=function(){var e=this;o("_drain numConns %s maxConns %s",e.numConns,e.maxConns);if(typeof f.connect!=="function"||e.destroyed||e.paused||e.numConns>=e.maxConns){return}o("drain (%s queued, %s/%s peers)",e.numQueued,e.numPeers,e.maxConns);var t=e._queue.shift();if(!t)return;o("tcp connect attempt to %s",t.addr);var r=i(t.addr);var n={host:r[0],port:r[1]};if(e._hostname)n.localAddress=e._hostname;var s=t.conn=f.connect(n);s.once("connect",function(){t.onConnect()});s.once("error",function(e){t.destroy(e)});t.setConnectTimeout();s.on("close",function(){if(e.destroyed)return;if(t.retries>=h.length){o("conn %s closed: will not re-add (max %s attempts)",t.addr,h.length);return}var r=h[t.retries];o("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,r,t.retries+1);var n=setTimeout(function i(){var r=e._addPeer(t.addr);if(r)r.retries=t.retries+1},r);if(n.unref)n.unref()})};p.prototype._onError=function(e){var t=this;t.emit("error",e);t.destroy()};p.prototype._validAddr=function(e){var t=this;var r=i(e);var n=r[0];var o=r[1];return o>0&&o<65535&&!(n==="127.0.0.1"&&o===t._port)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/peer":8,"./lib/tcp-pool":24,_process:34,"addr-to-ip-port":24,buffer:25,debug:107,events:29,inherits:115,net:24,speedometer:195}],8:[function(e,t,r){var n=e("debug")("bittorrent-swarm:peer");var i=e("./webconn");var o=e("bittorrent-protocol");var s=25e3;var a=25e3;r.createWebRTCPeer=function(e,t){var r=new f(e.id);r.conn=e;r.swarm=t;if(r.conn.connected){r.onConnect()}else{r.conn.once("connect",function(){r.onConnect()});r.conn.once("error",function(e){r.destroy(e)});r.setConnectTimeout()}return r};r.createIncomingTCPPeer=function(e){var t=e.remoteAddress+":"+e.remotePort;var r=new f(t);r.conn=e;r.addr=t;r.onConnect();return r};r.createOutgoingTCPPeer=function(e,t){var r=new f(e);r.addr=e;r.swarm=t;return r};r.createWebPeer=function(e,t,r){var n=new f(e);n.swarm=r;n.conn=new i(e,t);n.onConnect();return n};function f(e){var t=this;t.id=e;n("new Peer %s",e);t.addr=null;t.conn=null;t.swarm=null;t.wire=null;t.connected=false;t.destroyed=false;t.timeout=null;t.retries=0;t.sentHandshake=false}f.prototype.onConnect=function(){var e=this;if(e.destroyed)return;e.connected=true;n("Peer %s connected",e.id);clearTimeout(e.connectTimeout);var t=e.conn;t.once("end",function(){e.destroy()});t.once("close",function(){e.destroy()});t.once("finish",function(){e.destroy()});t.once("error",function(t){e.destroy(t)});var r=e.wire=new o;r.once("end",function(){e.destroy()});r.once("close",function(){e.destroy()});r.once("finish",function(){e.destroy()});r.once("error",function(t){e.destroy(t)});r.once("handshake",function(t,r){e.onHandshake(t,r)});e.setHandshakeTimeout();t.pipe(r).pipe(t);if(e.swarm&&!e.sentHandshake)e.handshake()};f.prototype.onHandshake=function(e,t){var r=this;if(!r.swarm)return;if(r.swarm.destroyed)return r.destroy(new Error("swarm already destroyed"));if(e!==r.swarm.infoHash){return r.destroy(new Error("unexpected handshake info hash for this swarm"))}if(t===r.swarm.peerId){
+return r.destroy(new Error("refusing to handshake with self"))}n("Peer %s got handshake %s",r.id,e);clearTimeout(r.handshakeTimeout);r.retries=0;r.wire.on("download",function(e){if(r.destroyed)return;r.swarm.downloaded+=e;r.swarm.downloadSpeed(e);r.swarm.emit("download",e)});r.wire.on("upload",function(e){if(r.destroyed)return;r.swarm.uploaded+=e;r.swarm.uploadSpeed(e);r.swarm.emit("upload",e)});if(!r.sentHandshake)r.handshake();r.swarm.wires.push(r.wire);var i=r.addr;if(!i&&r.conn.remoteAddress){i=r.conn.remoteAddress+":"+r.conn.remotePort}r.swarm.emit("wire",r.wire,i)};f.prototype.handshake=function(){var e=this;e.wire.handshake(e.swarm.infoHash,e.swarm.peerId,e.swarm.handshakeOpts);e.sentHandshake=true};f.prototype.setConnectTimeout=function(){var e=this;clearTimeout(e.connectTimeout);e.connectTimeout=setTimeout(function(){e.destroy(new Error("connect timeout"))},s);if(e.connectTimeout.unref)e.connectTimeout.unref()};f.prototype.setHandshakeTimeout=function(){var e=this;clearTimeout(e.handshakeTimeout);e.handshakeTimeout=setTimeout(function(){e.destroy(new Error("handshake timeout"))},a);if(e.handshakeTimeout.unref)e.handshakeTimeout.unref()};f.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;t.connected=false;n("destroy %s (error: %s)",t.id,e&&(e.message||e));clearTimeout(t.connectTimeout);clearTimeout(t.handshakeTimeout);var r=t.swarm;var i=t.conn;var o=t.wire;t.conn=null;t.swarm=null;t.wire=null;if(r&&o){var s=r.wires.indexOf(o);if(s>=0)r.wires.splice(s,1)}if(i)i.destroy();if(o)o.destroy();if(r)r.removePeer(t.id)}},{"./webconn":9,"bittorrent-protocol":10,debug:107}],9:[function(e,t,r){t.exports=u;var n=e("bitfield");var i=e("debug")("bittorrent-swarm:webconn");var o=e("simple-get");var s=e("inherits");var a=e("simple-sha1");var f=e("bittorrent-protocol");s(u,f);function u(e,t){var r=this;f.call(this);r.url=e;r.webPeerId=a.sync(e);r.parsedTorrent=t;r.setKeepAlive(true);r.on("handshake",function(e,t){r.handshake(e,r.webPeerId);var i=r.parsedTorrent.pieces.length;var o=new n(i);for(var s=0;s<=i;s++){o.set(s,true)}r.bitfield(o)});r.on("choke",function(){i("choke")});r.on("unchoke",function(){i("unchoke")});r.once("interested",function(){i("interested");r.unchoke()});r.on("uninterested",function(){i("uninterested")});r.on("bitfield",function(){i("bitfield")});r.on("request",function(e,t,n,o){i("request pieceIndex=%d offset=%d length=%d",e,t,n);r.httpRequest(e,t,n,o)})}u.prototype.httpRequest=function(e,t,r,n){var s=this;var a=e*s.parsedTorrent.pieceLength;var f=a+t;var u=f+r-1;i("Requesting pieceIndex=%d offset=%d length=%d start=%d end=%d",e,t,r,f,u);var c={url:s.url,method:"GET",headers:{"user-agent":"WebTorrent (http://webtorrent.io)",range:"bytes="+f+"-"+u}};o.concat(c,function(e,t,r){if(e)return n(e);if(r.statusCode<200||r.statusCode>=300){return n(new Error("Unexpected HTTP status code "+r.statusCode))}i("Got data of length %d",t.length);n(null,t)})}},{bitfield:6,"bittorrent-protocol":10,debug:107,inherits:115,"simple-get":185,"simple-sha1":193}],10:[function(e,t,r){(function(r){t.exports=w;var n=e("bencode");var i=e("bitfield");var o=e("debug")("bittorrent-protocol");var s=e("xtend");var a=e("hat");var f=e("inherits");var u=e("speedometer");var c=e("stream");var l=4e5;var d=new r("BitTorrent protocol");var h=new r([0,0,0,0]);var p=new r([0,0,0,1,0]);var m=new r([0,0,0,1,1]);var v=new r([0,0,0,1,2]);var g=new r([0,0,0,1,3]);var y=[0,0,0,0,0,0,0,0];var _=[0,0,0,3,9,0,0];function b(e,t,r,n){this.piece=e;this.offset=t;this.length=r;this.callback=n}f(w,c.Duplex);function w(){if(!(this instanceof w))return new w;c.Duplex.call(this);this._debugId=a(32);this._debug("new wire");this.peerId=null;this.peerIdBuffer=null;this.amChoking=true;this.amInterested=false;this.peerChoking=true;this.peerInterested=false;this.peerPieces=new i(0,{grow:l});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=u();this.downloadSpeed=u();this._keepAliveInterval=null;this._timeout=null;this._timeoutMs=0;this.destroyed=false;this._finished=false;this._buffer=[];this._bufferSize=0;this._parser=null;this._parserSize=0;this.on("finish",this._onfinish);this._parseHandshake()}w.prototype.setKeepAlive=function(e){this._debug("setKeepAlive %s",e);clearInterval(this._keepAliveInterval);if(e===false)return;this._keepAliveInterval=setInterval(this.keepAlive.bind(this),6e4)};w.prototype.setTimeout=function(e,t){this._debug("setTimeout ms=%d unref=%s",e,t);this._clearTimeout();this._timeoutMs=e;this._timeoutUnref=!!t;this._updateTimeout()};w.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;this._debug("destroy");this.emit("close");this.end()};w.prototype.end=function(){this._debug("end");this._onUninterested();this._onChoke();c.Duplex.prototype.end.apply(this,arguments)};w.prototype.use=function(e){var t=e.prototype.name;if(!t){throw new Error('Extension class requires a "name" property on the prototype')}this._debug("use extension.name=%s",t);var r=this._nextExt;var n=new e(this);function i(){}if(typeof n.onHandshake!=="function"){n.onHandshake=i}if(typeof n.onExtendedHandshake!=="function"){n.onExtendedHandshake=i}if(typeof n.onMessage!=="function"){n.onMessage=i}this.extendedMapping[r]=t;this._ext[t]=n;this[t]=n;this._nextExt+=1};w.prototype.keepAlive=function(){this._debug("keep-alive");this._push(h)};w.prototype.handshake=function(e,t,n){var i,o;if(typeof e==="string"){i=new r(e,"hex")}else{i=e;e=i.toString("hex")}if(typeof t==="string"){o=new r(t,"hex")}else{o=t;t=o.toString("hex")}if(i.length!==20||o.length!==20){throw new Error("infoHash and peerId MUST have length 20")}this._debug("handshake i=%s p=%s exts=%o",e,t,n);var s=new r(y);s[5]|=16;if(n&&n.dht)s[7]|=1;this._push(r.concat([d,s,i,o]));this._handshakeSent=true;if(this.peerExtensions.extended){this._sendExtendedHandshake()}};w.prototype._sendExtendedHandshake=function(){var e=s(this.extendedHandshake);e.m={};for(var t in this.extendedMapping){var r=this.extendedMapping[t];e.m[r]=Number(t)}this.extended(0,n.encode(e))};w.prototype.choke=function(){if(this.amChoking)return;this.amChoking=true;this._debug("choke");this.peerRequests.splice(0,this.peerRequests.length);this._push(p)};w.prototype.unchoke=function(){if(!this.amChoking)return;this.amChoking=false;this._debug("unchoke");this._push(m)};w.prototype.interested=function(){if(this.amInterested)return;this.amInterested=true;this._debug("interested");this._push(v)};w.prototype.uninterested=function(){if(!this.amInterested)return;this.amInterested=false;this._debug("uninterested");this._push(g)};w.prototype.have=function(e){this._debug("have %d",e);this._message(4,[e],null)};w.prototype.bitfield=function(e){this._debug("bitfield");if(!r.isBuffer(e))e=e.buffer;this._message(5,[],e)};w.prototype.request=function(e,t,r,n){if(!n)n=function(){};if(this._finished)return n(new Error("wire is closed"));if(this.peerChoking)return n(new Error("peer is choking"));this._debug("request index=%d offset=%d length=%d",e,t,r);this.requests.push(new b(e,t,r,n));this._updateTimeout();this._message(6,[e,t,r],null)};w.prototype.piece=function(e,t,r){this._debug("piece index=%d offset=%d",e,t);this.uploaded+=r.length;this.uploadSpeed(r.length);this.emit("upload",r.length);this._message(7,[e,t],r)};w.prototype.cancel=function(e,t,r){this._debug("cancel index=%d offset=%d length=%d",e,t,r);this._callback(E(this.requests,e,t,r),new Error("request was cancelled"),null);this._message(8,[e,t,r],null)};w.prototype.port=function(e){this._debug("port %d",e);var t=new r(_);t.writeUInt16BE(e,5);this._push(t)};w.prototype.extended=function(e,t){this._debug("extended ext=%s",e);if(typeof e==="string"&&this.peerExtendedMapping[e]){e=this.peerExtendedMapping[e]}if(typeof e==="number"){var i=new r([e]);var o=r.isBuffer(t)?t:n.encode(t);this._message(20,[],r.concat([i,o]))}else{throw new Error("Unrecognized extension: "+e)}};w.prototype._onKeepAlive=function(){this._debug("got keep-alive");this.emit("keep-alive")};w.prototype._onHandshake=function(e,t,r){var n=e.toString("hex");var i=t.toString("hex");this._debug("got handshake i=%s p=%s exts=%o",n,i,r);this.peerId=i;this.peerIdBuffer=t;this.peerExtensions=r;this.emit("handshake",n,i,r);var o;for(o in this._ext){this._ext[o].onHandshake(n,i,r)}if(r.extended&&this._handshakeSent){this._sendExtendedHandshake()}};w.prototype._onChoke=function(){this.peerChoking=true;this._debug("got choke");this.emit("choke");while(this.requests.length){this._callback(this.requests.shift(),new Error("peer is choking"),null)}};w.prototype._onUnchoke=function(){this.peerChoking=false;this._debug("got unchoke");this.emit("unchoke")};w.prototype._onInterested=function(){this.peerInterested=true;this._debug("got interested");this.emit("interested")};w.prototype._onUninterested=function(){this.peerInterested=false;this._debug("got uninterested");this.emit("uninterested")};w.prototype._onHave=function(e){if(this.peerPieces.get(e))return;this._debug("got have %d",e);this.peerPieces.set(e,true);this.emit("have",e)};w.prototype._onBitField=function(e){this.peerPieces=new i(e);this._debug("got bitfield");this.emit("bitfield",this.peerPieces)};w.prototype._onRequest=function(e,t,r){if(this.amChoking)return;this._debug("got request index=%d offset=%d length=%d",e,t,r);var n=function(n,o){if(i!==E(this.peerRequests,e,t,r))return;if(n)return;this.piece(e,t,o)}.bind(this);var i=new b(e,t,r,n);this.peerRequests.push(i);this.emit("request",e,t,r,n)};w.prototype._onPiece=function(e,t,r){this._debug("got piece index=%d offset=%d",e,t);this._callback(E(this.requests,e,t,r.length),null,r);this.downloaded+=r.length;this.downloadSpeed(r.length);this.emit("download",r.length);this.emit("piece",e,t,r)};w.prototype._onCancel=function(e,t,r){this._debug("got cancel index=%d offset=%d length=%d",e,t,r);E(this.peerRequests,e,t,r);this.emit("cancel",e,t,r)};w.prototype._onPort=function(e){this._debug("got port %d",e);this.emit("port",e)};w.prototype._onExtended=function(e,t){if(e===0){var r;try{r=n.decode(t)}catch(i){this._debug("ignoring invalid extended handshake: %s",i.message||i)}if(!r)return;this.peerExtendedHandshake=r;var o;if(typeof r.m==="object"){for(o in r.m){this.peerExtendedMapping[o]=Number(r.m[o].toString())}}for(o in this._ext){if(this.peerExtendedMapping[o]){this._ext[o].onExtendedHandshake(this.peerExtendedHandshake)}}this._debug("got extended handshake");this.emit("extended","handshake",this.peerExtendedHandshake)}else{if(this.extendedMapping[e]){e=this.extendedMapping[e];if(this._ext[e]){this._ext[e].onMessage(t)}}this._debug("got extended message ext=%s",e);this.emit("extended",e,t)}};w.prototype._onTimeout=function(){this._debug("request timed out");this._callback(this.requests.shift(),new Error("request has timed out"),null);this.emit("timeout")};w.prototype._push=function(e){if(this._finished)return;return this.push(e)};w.prototype._write=function(e,t,n){this._bufferSize+=e.length;this._buffer.push(e);while(this._bufferSize>=this._parserSize){var i=this._buffer.length===1?this._buffer[0]:r.concat(this._buffer);this._bufferSize-=this._parserSize;this._buffer=this._bufferSize?[i.slice(this._parserSize)]:[];this._parser(i.slice(0,this._parserSize))}n(null)};w.prototype._read=function(){};w.prototype._callback=function(e,t,r){if(!e)return;this._clearTimeout();if(!this.peerChoking&&!this._finished)this._updateTimeout();e.callback(t,r)};w.prototype._clearTimeout=function(){if(!this._timeout)return;clearTimeout(this._timeout);this._timeout=null};w.prototype._updateTimeout=function(){if(!this._timeoutMs||!this.requests.length||this._timeout)return;this._timeout=setTimeout(this._onTimeout.bind(this),this._timeoutMs);if(this._timeoutUnref&&this._timeout.unref)this._timeout.unref()};w.prototype._parse=function(e,t){this._parserSize=e;this._parser=t};w.prototype._message=function(e,t,n){var i=n?n.length:0;var o=new r(5+4*t.length);o.writeUInt32BE(o.length+i-4,0);o[4]=e;for(var s=0;s<t.length;s++){o.writeUInt32BE(t[s],5+4*s)}this._push(o);if(n)this._push(n)};w.prototype._onmessagelength=function(e){var t=e.readUInt32BE(0);if(t>0){this._parse(t,this._onmessage)}else{this._onKeepAlive();this._parse(4,this._onmessagelength)}};w.prototype._onmessage=function(e){this._parse(4,this._onmessagelength);switch(e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:this._debug("got unknown message");return this.emit("unknownmessage",e)}};w.prototype._parseHandshake=function(){this._parse(1,function(e){var t=e.readUInt8(0);this._parse(t+48,function(e){var r=e.slice(0,t);if(r.toString()!=="BitTorrent protocol"){this._debug("Error: wire not speaking BitTorrent protocol (%s)",r.toString());this.end();return}e=e.slice(t);this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(e[7]&1),extended:!!(e[5]&16)});this._parse(4,this._onmessagelength)}.bind(this))}.bind(this))};w.prototype._onfinish=function(){this._finished=true;this.push(null);while(this.read()){}clearInterval(this._keepAliveInterval);this._parse(Number.MAX_VALUE,function(){});this.peerRequests=[];while(this.requests.length){this._callback(this.requests.shift(),new Error("wire was closed"),null)}};w.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._debugId+"] "+e[0];o.apply(null,e)};function E(e,t,r,n){for(var i=0;i<e.length;i++){var o=e[i];if(o.piece!==t||o.offset!==r||o.length!==n)continue;if(i===0)e.shift();else e.splice(i,1);return o}return null}}).call(this,e("buffer").Buffer)},{bencode:11,bitfield:6,buffer:25,debug:107,hat:113,inherits:115,speedometer:195,stream:52,xtend:210}],11:[function(e,t,r){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":12,"./lib/encode":14}],12:[function(e,t,r){(function(r){var n=e("./dict");function i(e,t){i.position=0;i.encoding=t||null;i.data=!r.isBuffer(e)?new r(e):e;return i.next()}i.position=0;i.data=null;i.encoding=null;i.next=function(){switch(i.data[i.position]){case 100:return i.dictionary();break;case 108:return i.list();break;case 105:return i.integer();break;default:return i.bytes();break}};i.find=function(e){var t=i.position;var r=i.data.length;var n=i.data;while(t<r){if(n[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")};i.dictionary=function(){i.position++;var e=new n;while(i.data[i.position]!==101){e.binarySet(i.bytes(),i.next())}i.position++;return e};i.list=function(){i.position++;var e=[];while(i.data[i.position]!==101){e.push(i.next())}i.position++;return e};i.integer=function(){var e=i.find(101);var t=i.data.toString("ascii",i.position+1,e);i.position+=e+1-i.position;return parseInt(t,10)};i.bytes=function(){var e=i.find(58);var t=parseInt(i.data.toString("ascii",i.position,e),10);var r=++e+t;i.position=r;return i.encoding?i.data.toString(i.encoding,e,r):i.data.slice(e,r)};t.exports=i}).call(this,e("buffer").Buffer)},{"./dict":13,buffer:25}],13:[function(e,t,r){var n=t.exports=function i(){Object.defineProperty(this,"_keys",{enumerable:false,value:[]})};n.prototype.binaryKeys=function o(){return this._keys.slice()};n.prototype.binarySet=function s(e,t){this._keys.push(e);this[e]=t}},{}],14:[function(e,t,r){(function(e){function r(t){var n=[];r._encode(n,t);return e.concat(n)}r._floatConversionDetected=false;r._encode=function(t,n){if(e.isBuffer(n)){t.push(new e(n.length+":"));t.push(n);return}switch(typeof n){case"string":r.bytes(t,n);break;case"number":r.number(t,n);break;case"object":n.constructor===Array?r.list(t,n):r.dict(t,n);break}};var n=new e("e"),i=new e("d"),o=new e("l");r.bytes=function(t,r){t.push(new e(e.byteLength(r)+":"+r))};r.number=function(t,n){var i=2147483648;var o=n/i<<0;var s=n%i<<0;var a=o*i+s;t.push(new e("i"+a+"e"));if(a!==n&&!r._floatConversionDetected){r._floatConversionDetected=true;console.warn('WARNING: Possible data corruption detected with value "'+n+'":','Bencoding only defines support for integers, value was converted to "'+a+'"');console.trace()}};r.dict=function(e,t){e.push(i);var o=0;var s;var a=Object.keys(t).sort();var f=a.length;for(;o<f;o++){s=a[o];r.bytes(e,s);r._encode(e,t[s])}e.push(n)};r.list=function(e,t){var i=0,s=1;var a=t.length;e.push(o);for(;i<a;i++){r._encode(e,t[i])}e.push(n)};t.exports=r}).call(this,e("buffer").Buffer)},{buffer:25}],15:[function(e,t,r){(function(r,n){t.exports=m;var i=e("events").EventEmitter;var o=e("debug")("bittorrent-tracker");var s=e("inherits");var a=e("once");var f=e("run-parallel");var u=e("uniq");var c=e("url");var l=e("./lib/common");var d=e("./lib/client/http-tracker");var h=e("./lib/client/udp-tracker");var p=e("./lib/client/websocket-tracker");s(m,i);function m(e,t,s,a){var f=this;if(!(f instanceof m))return new m(e,t,s,a);i.call(f);if(!a)a={};f.peerId=typeof e==="string"?e:e.toString("hex");f.peerIdBuffer=new n(f.peerId,"hex");f._peerIdBinary=f.peerIdBuffer.toString("binary");f.infoHash=typeof s.infoHash==="string"?s.infoHash:s.infoHash.toString("hex");f.infoHashBuffer=new n(f.infoHash,"hex");f._infoHashBinary=f.infoHashBuffer.toString("binary");f.torrentLength=s.length;f.destroyed=false;f._port=t;f._rtcConfig=a.rtcConfig;f._wrtc=a.wrtc;o("new client %s",f.infoHash);var l=!!f._wrtc||typeof window!=="undefined";var v=typeof s.announce==="string"?[s.announce]:s.announce==null?[]:s.announce;v=v.map(function(e){e=e.toString();if(e[e.length-1]==="/"){e=e.substring(0,e.length-1)}return e});v=u(v);f._trackers=v.map(function(e){var t=c.parse(e).protocol;if((t==="http:"||t==="https:")&&typeof d==="function"){return new d(f,e)}else if(t==="udp:"&&typeof h==="function"){return new h(f,e)}else if((t==="ws:"||t==="wss:")&&l){return new p(f,e)}else{r.nextTick(function(){var t=new Error("unsupported tracker protocol for "+e);f.emit("warning",t)})}return null}).filter(Boolean)}m.scrape=function(e,t,r){r=a(r);var i=new n("01234567890123456789");var o=6881;var s={infoHash:Array.isArray(t)?t[0]:t,announce:[e]};var f=new m(i,o,s);f.once("error",r);var u=Array.isArray(t)?t.length:1;var c={};f.on("scrape",function(e){u-=1;c[e.infoHash]=e;if(u===0){f.destroy();var t=Object.keys(c);if(t.length===1){r(null,c[t[0]])}else{r(null,c)}}});t=Array.isArray(t)?t.map(function(e){return new n(e,"hex")}):new n(t,"hex");f.scrape({infoHash:t})};m.prototype.start=function(e){var t=this;o("send `start`");e=t._defaultAnnounceOpts(e);e.event="started";t._announce(e);t._trackers.forEach(function(e){e.setInterval()})};m.prototype.stop=function(e){var t=this;o("send `stop`");e=t._defaultAnnounceOpts(e);e.event="stopped";t._announce(e)};m.prototype.complete=function(e){var t=this;o("send `complete`");if(!e)e={};if(e.downloaded==null&&t.torrentLength!=null){e.downloaded=t.torrentLength}e=t._defaultAnnounceOpts(e);e.event="completed";t._announce(e)};m.prototype.update=function(e){var t=this;o("send `update`");e=t._defaultAnnounceOpts(e);if(e.event)delete e.event;t._announce(e)};m.prototype._announce=function(e){var t=this;t._trackers.forEach(function(t){t.announce(e)})};m.prototype.scrape=function(e){var t=this;o("send `scrape`");if(!e)e={};t._trackers.forEach(function(t){t.scrape(e)})};m.prototype.setInterval=function(e){var t=this;o("setInterval %d",e);t._trackers.forEach(function(t){t.setInterval(e)})};m.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;o("destroy");var r=t._trackers.map(function(e){return function(t){e.destroy(t)}});f(r,e);t._trackers=[]};m.prototype._defaultAnnounceOpts=function(e){var t=this;if(!e)e={};if(e.numwant==null)e.numwant=l.DEFAULT_ANNOUNCE_PEERS;if(e.uploaded==null)e.uploaded=0;if(e.downloaded==null)e.downloaded=0;if(e.left==null&&t.torrentLength!=null){e.left=t.torrentLength-e.downloaded}return e}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/client/http-tracker":24,"./lib/client/udp-tracker":24,"./lib/client/websocket-tracker":17,"./lib/common":18,_process:34,buffer:25,debug:107,events:29,inherits:115,once:20,"run-parallel":184,uniq:204,url:60}],16:[function(e,t,r){t.exports=o;var n=e("events").EventEmitter;var i=e("inherits");i(o,n);function o(e,t){var r=this;n.call(r);r.client=e;r.announceUrl=t;r.interval=null;r.destroyed=false}o.prototype.setInterval=function(e){var t=this;if(e==null)e=t.DEFAULT_ANNOUNCE_INTERVAL;clearInterval(t.interval);if(e){var r=t.announce.bind(t,t.client._defaultAnnounceOpts());t.interval=setInterval(r,e);if(t.interval.unref)t.interval.unref()}}},{events:29,inherits:115}],17:[function(e,t,r){t.exports=p;var n=e("debug")("bittorrent-tracker:websocket-tracker");var i=e("hat");var o=e("inherits");var s=e("simple-peer");var a=e("simple-websocket");var f=e("../common");var u=e("./tracker");var c={};var l=30*1e3;var d=5*1e3;var h=50*1e3;o(p,u);function p(e,t,r){var i=this;u.call(i,e,t);n("new websocket tracker %s",t);i.peers={};i.socket=null;i.reconnecting=false;i._openSocket()}p.prototype.DEFAULT_ANNOUNCE_INTERVAL=30*1e3;p.prototype.announce=function(e){var t=this;if(t.destroyed||t.reconnecting)return;if(!t.socket.connected){return t.socket.once("connect",t.announce.bind(t,e))}var r=Math.min(e.numwant,10);t._generateOffers(r,function(n){var i={numwant:r,uploaded:e.uploaded||0,downloaded:e.downloaded,event:e.event,info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,offers:n};if(t._trackerId)i.trackerid=t._trackerId;t._send(i)})};p.prototype.scrape=function(e){var t=this;if(t.destroyed||t.reconnecting)return;t._onSocketError(new Error("scrape not supported "+t.announceUrl))};p.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;clearInterval(t.interval);c[t.announceUrl]=null;t.socket.removeListener("connect",t._onSocketConnectBound);t.socket.removeListener("data",t._onSocketDataBound);t.socket.removeListener("close",t._onSocketCloseBound);t.socket.removeListener("error",t._onSocketErrorBound);t._onSocketConnectBound=null;t._onSocketErrorBound=null;t._onSocketDataBound=null;t._onSocketCloseBound=null;t.socket.on("error",m);try{t.socket.destroy(e)}catch(r){if(e)e()}t.socket=null};p.prototype._openSocket=function(){var e=this;e.destroyed=false;e._onSocketConnectBound=e._onSocketConnect.bind(e);e._onSocketErrorBound=e._onSocketError.bind(e);e._onSocketDataBound=e._onSocketData.bind(e);e._onSocketCloseBound=e._onSocketClose.bind(e);e.socket=c[e.announceUrl];if(!e.socket){e.socket=c[e.announceUrl]=new a(e.announceUrl);e.socket.on("connect",e._onSocketConnectBound)}e.socket.on("data",e._onSocketDataBound);e.socket.on("close",e._onSocketCloseBound);e.socket.on("error",e._onSocketErrorBound)};p.prototype._onSocketConnect=function(){var e=this;if(e.destroyed)return;if(e.reconnecting){e.reconnecting=false;e.announce(e.client._defaultAnnounceOpts())}};p.prototype._onSocketData=function(e){var t=this;if(t.destroyed)return;if(!(typeof e==="object"&&e!==null)){return t.client.emit("warning",new Error("Invalid tracker response"))}if(e.info_hash!==t.client._infoHashBinary){n("ignoring websocket data from %s for %s (looking for %s: reused socket)",t.announceUrl,f.binaryToHex(e.info_hash),t.client.infoHash);return}if(e.peer_id&&e.peer_id===t.client._peerIdBinary){return}n("received %s from %s for %s",JSON.stringify(e),t.announceUrl,t.client.infoHash);var r=e["failure reason"];if(r)return t.client.emit("warning",new Error(r));var i=e["warning message"];if(i)t.client.emit("warning",new Error(i));var o=e.interval||e["min interval"];if(o)t.setInterval(o*1e3);var a=e["tracker id"];if(a){t._trackerId=a}if(e.complete){t.client.emit("update",{announce:t.announceUrl,complete:e.complete,incomplete:e.incomplete})}var u;if(e.offer&&e.peer_id){n("creating peer (from remote offer)");u=new s({trickle:false,config:t.client._rtcConfig,wrtc:t.client._wrtc});u.id=f.binaryToHex(e.peer_id);u.once("signal",function(r){var n={info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:r,offer_id:e.offer_id};if(t._trackerId)n.trackerid=t._trackerId;t._send(n)});u.signal(e.offer);t.client.emit("peer",u)}if(e.answer&&e.peer_id){var c=f.binaryToHex(e.offer_id);u=t.peers[c];if(u){u.id=f.binaryToHex(e.peer_id);u.signal(e.answer);t.client.emit("peer",u);clearTimeout(u.trackerTimeout);u.trackerTimeout=null;t.peers[c]=null}else{n("got unexpected answer: "+JSON.stringify(e.answer))}}};p.prototype._onSocketClose=function(){var e=this;if(e.destroyed)return;e.destroy();e._startReconnectTimer()};p.prototype._onSocketError=function(e){var t=this;if(t.destroyed)return;t.destroy();t.client.emit("warning",e);t._startReconnectTimer()};p.prototype._startReconnectTimer=function(){var e=this;var t=Math.floor(Math.random()*l)+d;e.reconnecting=true;var r=setTimeout(function(){e._openSocket()},t);if(r.unref)r.unref();n("reconnecting socket in %s ms",t)};p.prototype._send=function(e){var t=this;if(t.destroyed)return;var r=JSON.stringify(e);n("send %s",r);t.socket.send(r)};p.prototype._generateOffers=function(e,t){var r=this;var o=[];n("generating %s offers",e);for(var a=0;a<e;++a){u()}function u(){var e=i(160);n("creating peer (from _generateOffers)");var t=r.peers[e]=new s({initiator:true,trickle:false,config:r.client._rtcConfig,wrtc:r.client._wrtc});t.once("signal",function(t){o.push({offer:t,offer_id:f.hexToBinary(e)});c()});t.trackerTimeout=setTimeout(function(){n("tracker timeout: destroying peer");t.trackerTimeout=null;r.peers[e]=null;t.destroy()},h)}function c(){if(o.length===e){n("generated %s offers",e);t(o)}}};function m(){}},{"../common":18,"./tracker":16,debug:107,hat:113,inherits:115,"simple-peer":188,"simple-websocket":21}],18:[function(e,t,r){(function(t){var n=e("xtend/mutable");r.DEFAULT_ANNOUNCE_PEERS=50;r.MAX_ANNOUNCE_PEERS=82;r.binaryToHex=function(e){return new t(e,"binary").toString("hex")};r.hexToBinary=function(e){return new t(e,"hex").toString("binary")};var i=e("./common-node");n(r,i)}).call(this,e("buffer").Buffer)},{"./common-node":24,buffer:25,"xtend/mutable":211}],19:[function(e,t,r){t.exports=n;function n(e,t){if(e&&t)return n(e)(t);if(typeof e!=="function")throw new TypeError("need wrapper function");Object.keys(e).forEach(function(t){r[t]=e[t]});return r;function r(){var t=new Array(arguments.length);for(var r=0;r<t.length;r++){t[r]=arguments[r]}var n=e.apply(this,t);var i=t[t.length-1];if(typeof n==="function"&&n!==i){Object.keys(i).forEach(function(e){n[e]=i[e]})}return n}}},{}],20:[function(e,t,r){var n=e("wrappy");t.exports=n(i);i.proto=i(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return i(this)},configurable:true})});function i(e){var t=function(){if(t.called)return t.value;t.called=true;return t.value=e.apply(this,arguments)};t.called=false;return t}},{wrappy:19}],21:[function(e,t,r){(function(r){t.exports=u;var n=e("debug")("simple-websocket");var i=e("inherits");var o=e("is-typedarray");var s=e("stream");var a=e("ws");var f=typeof window!=="undefined"?window.WebSocket:a;i(u,s.Duplex);function u(e,t){var r=this;if(!(r instanceof u))return new u(e,t);if(!t)t={};n("new websocket: %s %o",e,t);t.allowHalfOpen=false;if(t.highWaterMark==null)t.highWaterMark=1024*1024;s.Duplex.call(r,t);r.url=e;r.connected=false;r.destroyed=false;r._maxBufferedAmount=t.highWaterMark;r._chunk=null;r._cb=null;r._interval=null;r._ws=new f(r.url);r._ws.binaryType="arraybuffer";r._ws.onopen=r._onOpen.bind(r);r._ws.onmessage=r._onMessage.bind(r);r._ws.onclose=r._onClose.bind(r);r._ws.onerror=function(){r._onError(new Error("connection error to "+r.url))};r.on("finish",function(){if(r.connected){setTimeout(function(){r._destroy()},100)}else{r.once("connect",function(){setTimeout(function(){r._destroy()},100)})}})}u.WEBSOCKET_SUPPORT=!!f;u.prototype.send=function(e){var t=this;if(!o.strict(e)&&!(e instanceof ArrayBuffer)&&!r.isBuffer(e)&&typeof e!=="string"&&(typeof Blob==="undefined"||!(e instanceof Blob))){e=JSON.stringify(e)}var i=e.length||e.byteLength||e.size;t._ws.send(e);n("write: %d bytes",i)};u.prototype.destroy=function(e){var t=this;t._destroy(null,e)};u.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);n("destroy (error: %s)",e&&e.message);this.readable=this.writable=false;if(!r._readableState.ended)r.push(null);if(!r._writableState.finished)r.end();r.connected=false;r.destroyed=true;clearInterval(r._interval);r._interval=null;r._chunk=null;r._cb=null;if(r._ws){var i=r._ws;var o=function(){i.onclose=null;r.emit("close")};if(i.readyState===f.CLOSED){o()}else{try{i.onclose=o;i.close()}catch(e){o()}}i.onopen=null;i.onmessage=null;i.onerror=null}r._ws=null;if(e)r.emit("error",e)};u.prototype._read=function(){};u.prototype._write=function(e,t,r){var i=this;if(i.destroyed)return r(new Error("cannot write after socket is destroyed"));if(i.connected){try{i.send(e)}catch(o){return i._onError(o)}if(typeof a!=="function"&&i._ws.bufferedAmount>i._maxBufferedAmount){n("start backpressure: bufferedAmount %d",i._ws.bufferedAmount);i._cb=r}else{r(null)}}else{n("write before connect");i._chunk=e;i._cb=r}};u.prototype._onMessage=function(e){var t=this;if(t.destroyed)return;var i=e.data;n("read: %d bytes",i.byteLength||i.length);if(i instanceof ArrayBuffer){i=new r(i);t.push(i)}else if(r.isBuffer(i)){t.push(i)}else{try{i=JSON.parse(i)}catch(o){}t.emit("data",i)}};u.prototype._onOpen=function(){var e=this;if(e.connected||e.destroyed)return;e.connected=true;if(e._chunk){try{e.send(e._chunk)}catch(t){return e._onError(t)}e._chunk=null;n('sent chunk from "write before connect"');var r=e._cb;e._cb=null;r(null)}if(typeof a!=="function"){e._interval=setInterval(function(){if(!e._cb||!e._ws||e._ws.bufferedAmount>e._maxBufferedAmount){return}n("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref()}n("connect");e.emit("connect")};u.prototype._onClose=function(){var e=this;if(e.destroyed)return;n("on close");e._destroy()};u.prototype._onError=function(e){var t=this;if(t.destroyed)return;n("error: %s",e.message||e);t._destroy(e)}}).call(this,e("buffer").Buffer)},{buffer:25,debug:107,inherits:115,"is-typedarray":22,stream:52,ws:24}],22:[function(e,t,r){t.exports=o;o.strict=s;o.loose=a;var n=Object.prototype.toString;var i={"[object Int8Array]":true,"[object Int16Array]":true,"[object Int32Array]":true,"[object Uint8Array]":true,"[object Uint8ClampedArray]":true,"[object Uint16Array]":true,"[object Uint32Array]":true,"[object Float32Array]":true,"[object Float64Array]":true};function o(e){return s(e)||a(e)}function s(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function a(e){return i[n.call(e)]}},{}],23:[function(e,t,r){},{}],24:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],25:[function(e,t,r){(function(t){"use strict";var n=e("base64-js");var i=e("ieee754");var o=e("isarray");r.Buffer=u;r.SlowBuffer=w;r.INSPECT_MAX_BYTES=50;u.poolSize=8192;var s={};u.TYPED_ARRAY_SUPPORT=t.TYPED_ARRAY_SUPPORT!==undefined?t.TYPED_ARRAY_SUPPORT:a();function a(){try{var e=new Uint8Array(1);e.foo=function(){return 42};return e.foo()===42&&typeof e.subarray==="function"&&e.subarray(1,1).byteLength===0}catch(t){return false}}function f(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function u(e){if(!(this instanceof u)){if(arguments.length>1)return new u(e,arguments[1]);
+return new u(e)}if(!u.TYPED_ARRAY_SUPPORT){this.length=0;this.parent=undefined}if(typeof e==="number"){return c(this,e)}if(typeof e==="string"){return l(this,e,arguments.length>1?arguments[1]:"utf8")}return d(this,e)}u._augment=function(e){e.__proto__=u.prototype;return e};function c(e,t){e=_(e,t<0?0:b(t)|0);if(!u.TYPED_ARRAY_SUPPORT){for(var r=0;r<t;r++){e[r]=0}}return e}function l(e,t,r){if(typeof r!=="string"||r==="")r="utf8";var n=E(t,r)|0;e=_(e,n);e.write(t,r);return e}function d(e,t){if(u.isBuffer(t))return h(e,t);if(o(t))return p(e,t);if(t==null){throw new TypeError("must start with number, buffer, array or string")}if(typeof ArrayBuffer!=="undefined"){if(t.buffer instanceof ArrayBuffer){return m(e,t)}if(t instanceof ArrayBuffer){return v(e,t)}}if(t.length)return g(e,t);return y(e,t)}function h(e,t){var r=b(t.length)|0;e=_(e,r);t.copy(e,0,0,r);return e}function p(e,t){var r=b(t.length)|0;e=_(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function m(e,t){var r=b(t.length)|0;e=_(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function v(e,t){t.byteLength;if(u.TYPED_ARRAY_SUPPORT){e=new Uint8Array(t);e.__proto__=u.prototype}else{e=m(e,new Uint8Array(t))}return e}function g(e,t){var r=b(t.length)|0;e=_(e,r);for(var n=0;n<r;n+=1){e[n]=t[n]&255}return e}function y(e,t){var r;var n=0;if(t.type==="Buffer"&&o(t.data)){r=t.data;n=b(r.length)|0}e=_(e,n);for(var i=0;i<n;i+=1){e[i]=r[i]&255}return e}if(u.TYPED_ARRAY_SUPPORT){u.prototype.__proto__=Uint8Array.prototype;u.__proto__=Uint8Array}else{u.prototype.length=undefined;u.prototype.parent=undefined}function _(e,t){if(u.TYPED_ARRAY_SUPPORT){e=new Uint8Array(t);e.__proto__=u.prototype}else{e.length=t}var r=t!==0&&t<=u.poolSize>>>1;if(r)e.parent=s;return e}function b(e){if(e>=f()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+f().toString(16)+" bytes")}return e|0}function w(e,t){if(!(this instanceof w))return new w(e,t);var r=new u(e,t);delete r.parent;return r}u.isBuffer=function ee(e){return!!(e!=null&&e._isBuffer)};u.compare=function te(e,t){if(!u.isBuffer(e)||!u.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var r=e.length;var n=t.length;var i=0;var o=Math.min(r,n);while(i<o){if(e[i]!==t[i])break;++i}if(i!==o){r=e[i];n=t[i]}if(r<n)return-1;if(n<r)return 1;return 0};u.isEncoding=function re(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};u.concat=function ne(e,t){if(!o(e))throw new TypeError("list argument must be an Array of Buffers.");if(e.length===0){return new u(0)}var r;if(t===undefined){t=0;for(r=0;r<e.length;r++){t+=e[r].length}}var n=new u(t);var i=0;for(r=0;r<e.length;r++){var s=e[r];s.copy(n,i);i+=s.length}return n};function E(e,t){if(typeof e!=="string")e=""+e;var r=e.length;if(r===0)return 0;var n=false;for(;;){switch(t){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return K(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Z(e).length;default:if(n)return K(e).length;t=(""+t).toLowerCase();n=true}}}u.byteLength=E;function x(e,t,r){var n=false;t=t|0;r=r===undefined||r===Infinity?this.length:r|0;if(!e)e="utf8";if(t<0)t=0;if(r>this.length)r=this.length;if(r<=t)return"";while(true){switch(e){case"hex":return O(this,t,r);case"utf8":case"utf-8":return L(this,t,r);case"ascii":return P(this,t,r);case"binary":return j(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();n=true}}}u.prototype._isBuffer=true;u.prototype.toString=function ie(){var e=this.length|0;if(e===0)return"";if(arguments.length===0)return L(this,0,e);return x.apply(this,arguments)};u.prototype.equals=function oe(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return u.compare(this,e)===0};u.prototype.inspect=function se(){var e="";var t=r.INSPECT_MAX_BYTES;if(this.length>0){e=this.toString("hex",0,t).match(/.{2}/g).join(" ");if(this.length>t)e+=" ... "}return"<Buffer "+e+">"};u.prototype.compare=function ae(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return 0;return u.compare(this,e)};u.prototype.indexOf=function fe(e,t){if(t>2147483647)t=2147483647;else if(t<-2147483648)t=-2147483648;t>>=0;if(this.length===0)return-1;if(t>=this.length)return-1;if(t<0)t=Math.max(this.length+t,0);if(typeof e==="string"){if(e.length===0)return-1;return String.prototype.indexOf.call(this,e,t)}if(u.isBuffer(e)){return r(this,e,t)}if(typeof e==="number"){if(u.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,e,t)}return r(this,[e],t)}function r(e,t,r){var n=-1;for(var i=0;r+i<e.length;i++){if(e[r+i]===t[n===-1?0:i-n]){if(n===-1)n=i;if(i-n+1===t.length)return r+n}else{n=-1}}return-1}throw new TypeError("val must be string, number or Buffer")};function k(e,t,r,n){r=Number(r)||0;var i=e.length-r;if(!n){n=i}else{n=Number(n);if(n>i){n=i}}var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");if(n>o/2){n=o/2}for(var s=0;s<n;s++){var a=parseInt(t.substr(s*2,2),16);if(isNaN(a))throw new Error("Invalid hex string");e[r+s]=a}return s}function S(e,t,r,n){return Q(K(t,e.length-r),e,r,n)}function B(e,t,r,n){return Q(J(t),e,r,n)}function I(e,t,r,n){return B(e,t,r,n)}function A(e,t,r,n){return Q(Z(t),e,r,n)}function C(e,t,r,n){return Q(X(t,e.length-r),e,r,n)}u.prototype.write=function ue(e,t,r,n){if(t===undefined){n="utf8";r=this.length;t=0}else if(r===undefined&&typeof t==="string"){n=t;r=this.length;t=0}else if(isFinite(t)){t=t|0;if(isFinite(r)){r=r|0;if(n===undefined)n="utf8"}else{n=r;r=undefined}}else{var i=n;n=t;t=r|0;r=i}var o=this.length-t;if(r===undefined||r>o)r=o;if(e.length>0&&(r<0||t<0)||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!n)n="utf8";var s=false;for(;;){switch(n){case"hex":return k(this,e,t,r);case"utf8":case"utf-8":return S(this,e,t,r);case"ascii":return B(this,e,t,r);case"binary":return I(this,e,t,r);case"base64":return A(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase();s=true}}};u.prototype.toJSON=function ce(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(e,t,r){if(t===0&&r===e.length){return n.fromByteArray(e)}else{return n.fromByteArray(e.slice(t,r))}}function L(e,t,r){r=Math.min(e.length,r);var n=[];var i=t;while(i<r){var o=e[i];var s=null;var a=o>239?4:o>223?3:o>191?2:1;if(i+a<=r){var f,u,c,l;switch(a){case 1:if(o<128){s=o}break;case 2:f=e[i+1];if((f&192)===128){l=(o&31)<<6|f&63;if(l>127){s=l}}break;case 3:f=e[i+1];u=e[i+2];if((f&192)===128&&(u&192)===128){l=(o&15)<<12|(f&63)<<6|u&63;if(l>2047&&(l<55296||l>57343)){s=l}}break;case 4:f=e[i+1];u=e[i+2];c=e[i+3];if((f&192)===128&&(u&192)===128&&(c&192)===128){l=(o&15)<<18|(f&63)<<12|(u&63)<<6|c&63;if(l>65535&&l<1114112){s=l}}}}if(s===null){s=65533;a=1}else if(s>65535){s-=65536;n.push(s>>>10&1023|55296);s=56320|s&1023}n.push(s);i+=a}return U(n)}var R=4096;function U(e){var t=e.length;if(t<=R){return String.fromCharCode.apply(String,e)}var r="";var n=0;while(n<t){r+=String.fromCharCode.apply(String,e.slice(n,n+=R))}return r}function P(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;i++){n+=String.fromCharCode(e[i]&127)}return n}function j(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;i++){n+=String.fromCharCode(e[i])}return n}function O(e,t,r){var n=e.length;if(!t||t<0)t=0;if(!r||r<0||r>n)r=n;var i="";for(var o=t;o<r;o++){i+=G(e[o])}return i}function M(e,t,r){var n=e.slice(t,r);var i="";for(var o=0;o<n.length;o+=2){i+=String.fromCharCode(n[o]+n[o+1]*256)}return i}u.prototype.slice=function le(e,t){var r=this.length;e=~~e;t=t===undefined?r:~~t;if(e<0){e+=r;if(e<0)e=0}else if(e>r){e=r}if(t<0){t+=r;if(t<0)t=0}else if(t>r){t=r}if(t<e)t=e;var n;if(u.TYPED_ARRAY_SUPPORT){n=this.subarray(e,t);n.__proto__=u.prototype}else{var i=t-e;n=new u(i,undefined);for(var o=0;o<i;o++){n[o]=this[o+e]}}if(n.length)n.parent=this.parent||this;return n};function D(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUIntLE=function de(e,t,r){e=e|0;t=t|0;if(!r)D(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){n+=this[e+o]*i}return n};u.prototype.readUIntBE=function he(e,t,r){e=e|0;t=t|0;if(!r){D(e,t,this.length)}var n=this[e+--t];var i=1;while(t>0&&(i*=256)){n+=this[e+--t]*i}return n};u.prototype.readUInt8=function pe(e,t){if(!t)D(e,1,this.length);return this[e]};u.prototype.readUInt16LE=function me(e,t){if(!t)D(e,2,this.length);return this[e]|this[e+1]<<8};u.prototype.readUInt16BE=function ve(e,t){if(!t)D(e,2,this.length);return this[e]<<8|this[e+1]};u.prototype.readUInt32LE=function ge(e,t){if(!t)D(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};u.prototype.readUInt32BE=function ye(e,t){if(!t)D(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};u.prototype.readIntLE=function _e(e,t,r){e=e|0;t=t|0;if(!r)D(e,t,this.length);var n=this[e];var i=1;var o=0;while(++o<t&&(i*=256)){n+=this[e+o]*i}i*=128;if(n>=i)n-=Math.pow(2,8*t);return n};u.prototype.readIntBE=function be(e,t,r){e=e|0;t=t|0;if(!r)D(e,t,this.length);var n=t;var i=1;var o=this[e+--n];while(n>0&&(i*=256)){o+=this[e+--n]*i}i*=128;if(o>=i)o-=Math.pow(2,8*t);return o};u.prototype.readInt8=function we(e,t){if(!t)D(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};u.prototype.readInt16LE=function Ee(e,t){if(!t)D(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};u.prototype.readInt16BE=function xe(e,t){if(!t)D(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};u.prototype.readInt32LE=function ke(e,t){if(!t)D(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};u.prototype.readInt32BE=function Se(e,t){if(!t)D(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};u.prototype.readFloatLE=function Be(e,t){if(!t)D(e,4,this.length);return i.read(this,e,true,23,4)};u.prototype.readFloatBE=function Ie(e,t){if(!t)D(e,4,this.length);return i.read(this,e,false,23,4)};u.prototype.readDoubleLE=function Ae(e,t){if(!t)D(e,8,this.length);return i.read(this,e,true,52,8)};u.prototype.readDoubleBE=function Ce(e,t){if(!t)D(e,8,this.length);return i.read(this,e,false,52,8)};function N(e,t,r,n,i,o){if(!u.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>i||t<o)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range")}u.prototype.writeUIntLE=function Te(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n)N(this,e,t,r,Math.pow(2,8*r),0);var i=1;var o=0;this[t]=e&255;while(++o<r&&(i*=256)){this[t+o]=e/i&255}return t+r};u.prototype.writeUIntBE=function Le(e,t,r,n){e=+e;t=t|0;r=r|0;if(!n)N(this,e,t,r,Math.pow(2,8*r),0);var i=r-1;var o=1;this[t+i]=e&255;while(--i>=0&&(o*=256)){this[t+i]=e/o&255}return t+r};u.prototype.writeUInt8=function Re(e,t,r){e=+e;t=t|0;if(!r)N(this,e,t,1,255,0);if(!u.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e&255;return t+1};function H(e,t,r,n){if(t<0)t=65535+t+1;for(var i=0,o=Math.min(e.length-r,2);i<o;i++){e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}}u.prototype.writeUInt16LE=function Ue(e,t,r){e=+e;t=t|0;if(!r)N(this,e,t,2,65535,0);if(u.TYPED_ARRAY_SUPPORT){this[t]=e&255;this[t+1]=e>>>8}else{H(this,e,t,true)}return t+2};u.prototype.writeUInt16BE=function Pe(e,t,r){e=+e;t=t|0;if(!r)N(this,e,t,2,65535,0);if(u.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e&255}else{H(this,e,t,false)}return t+2};function q(e,t,r,n){if(t<0)t=4294967295+t+1;for(var i=0,o=Math.min(e.length-r,4);i<o;i++){e[r+i]=t>>>(n?i:3-i)*8&255}}u.prototype.writeUInt32LE=function je(e,t,r){e=+e;t=t|0;if(!r)N(this,e,t,4,4294967295,0);if(u.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e&255}else{q(this,e,t,true)}return t+4};u.prototype.writeUInt32BE=function Oe(e,t,r){e=+e;t=t|0;if(!r)N(this,e,t,4,4294967295,0);if(u.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e&255}else{q(this,e,t,false)}return t+4};u.prototype.writeIntLE=function Me(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);N(this,e,t,r,i-1,-i)}var o=0;var s=1;var a=e<0?1:0;this[t]=e&255;while(++o<r&&(s*=256)){this[t+o]=(e/s>>0)-a&255}return t+r};u.prototype.writeIntBE=function De(e,t,r,n){e=+e;t=t|0;if(!n){var i=Math.pow(2,8*r-1);N(this,e,t,r,i-1,-i)}var o=r-1;var s=1;var a=e<0?1:0;this[t+o]=e&255;while(--o>=0&&(s*=256)){this[t+o]=(e/s>>0)-a&255}return t+r};u.prototype.writeInt8=function Ne(e,t,r){e=+e;t=t|0;if(!r)N(this,e,t,1,127,-128);if(!u.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e&255;return t+1};u.prototype.writeInt16LE=function He(e,t,r){e=+e;t=t|0;if(!r)N(this,e,t,2,32767,-32768);if(u.TYPED_ARRAY_SUPPORT){this[t]=e&255;this[t+1]=e>>>8}else{H(this,e,t,true)}return t+2};u.prototype.writeInt16BE=function qe(e,t,r){e=+e;t=t|0;if(!r)N(this,e,t,2,32767,-32768);if(u.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e&255}else{H(this,e,t,false)}return t+2};u.prototype.writeInt32LE=function ze(e,t,r){e=+e;t=t|0;if(!r)N(this,e,t,4,2147483647,-2147483648);if(u.TYPED_ARRAY_SUPPORT){this[t]=e&255;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{q(this,e,t,true)}return t+4};u.prototype.writeInt32BE=function We(e,t,r){e=+e;t=t|0;if(!r)N(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(u.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e&255}else{q(this,e,t,false)}return t+4};function z(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function W(e,t,r,n,o){if(!o){z(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}i.write(e,t,r,n,23,4);return r+4}u.prototype.writeFloatLE=function Fe(e,t,r){return W(this,e,t,true,r)};u.prototype.writeFloatBE=function Ye(e,t,r){return W(this,e,t,false,r)};function F(e,t,r,n,o){if(!o){z(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}i.write(e,t,r,n,52,8);return r+8}u.prototype.writeDoubleLE=function Ve(e,t,r){return F(this,e,t,true,r)};u.prototype.writeDoubleBE=function $e(e,t,r){return F(this,e,t,false,r)};u.prototype.copy=function Ge(e,t,r,n){if(!r)r=0;if(!n&&n!==0)n=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(n>0&&n<r)n=r;if(n===r)return 0;if(e.length===0||this.length===0)return 0;if(t<0){throw new RangeError("targetStart out of bounds")}if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");if(n>this.length)n=this.length;if(e.length-t<n-r){n=e.length-t+r}var i=n-r;var o;if(this===e&&r<t&&t<n){for(o=i-1;o>=0;o--){e[o+t]=this[o+r]}}else if(i<1e3||!u.TYPED_ARRAY_SUPPORT){for(o=0;o<i;o++){e[o+t]=this[o+r]}}else{Uint8Array.prototype.set.call(e,this.subarray(r,r+i),t)}return i};u.prototype.fill=function Ke(e,t,r){if(!e)e=0;if(!t)t=0;if(!r)r=this.length;if(r<t)throw new RangeError("end < start");if(r===t)return;if(this.length===0)return;if(t<0||t>=this.length)throw new RangeError("start out of bounds");if(r<0||r>this.length)throw new RangeError("end out of bounds");var n;if(typeof e==="number"){for(n=t;n<r;n++){this[n]=e}}else{var i=K(e.toString());var o=i.length;for(n=t;n<r;n++){this[n]=i[n%o]}}return this};var Y=/[^+\/0-9A-Za-z-_]/g;function V(e){e=$(e).replace(Y,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function $(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function G(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function K(e,t){t=t||Infinity;var r;var n=e.length;var i=null;var o=[];for(var s=0;s<n;s++){r=e.charCodeAt(s);if(r>55295&&r<57344){if(!i){if(r>56319){if((t-=3)>-1)o.push(239,191,189);continue}else if(s+1===n){if((t-=3)>-1)o.push(239,191,189);continue}i=r;continue}if(r<56320){if((t-=3)>-1)o.push(239,191,189);i=r;continue}r=(i-55296<<10|r-56320)+65536}else if(i){if((t-=3)>-1)o.push(239,191,189)}i=null;if(r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return o}function J(e){var t=[];for(var r=0;r<e.length;r++){t.push(e.charCodeAt(r)&255)}return t}function X(e,t){var r,n,i;var o=[];for(var s=0;s<e.length;s++){if((t-=2)<0)break;r=e.charCodeAt(s);n=r>>8;i=r%256;o.push(i);o.push(n)}return o}function Z(e){return n.toByteArray(V(e))}function Q(e,t,r,n){for(var i=0;i<n;i++){if(i+r>=t.length||i>=e.length)break;t[i+r]=e[i]}return i}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"base64-js":26,ieee754:27,isarray:28}],26:[function(e,t,r){(function(e){"use strict";var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var r=typeof Uint8Array!=="undefined"?Uint8Array:Array;var n="+".charCodeAt(0);var i="/".charCodeAt(0);var o="0".charCodeAt(0);var s="a".charCodeAt(0);var a="A".charCodeAt(0);var f="-".charCodeAt(0);var u="_".charCodeAt(0);function c(e){var t=e.charCodeAt(0);if(t===n||t===f)return 62;if(t===i||t===u)return 63;if(t<o)return-1;if(t<o+10)return t-o+26+26;if(t<a+26)return t-a;if(t<s+26)return t-s+26}function l(e){var t,n,i,o,s,a;if(e.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var f=e.length;s=e.charAt(f-2)==="="?2:e.charAt(f-1)==="="?1:0;a=new r(e.length*3/4-s);i=s>0?e.length-4:e.length;var u=0;function l(e){a[u++]=e}for(t=0,n=0;t<i;t+=4,n+=3){o=c(e.charAt(t))<<18|c(e.charAt(t+1))<<12|c(e.charAt(t+2))<<6|c(e.charAt(t+3));l((o&16711680)>>16);l((o&65280)>>8);l(o&255)}if(s===2){o=c(e.charAt(t))<<2|c(e.charAt(t+1))>>4;l(o&255)}else if(s===1){o=c(e.charAt(t))<<10|c(e.charAt(t+1))<<4|c(e.charAt(t+2))>>2;l(o>>8&255);l(o&255)}return a}function d(e){var r;var n=e.length%3;var i="";var o,s;function a(e){return t.charAt(e)}function f(e){return a(e>>18&63)+a(e>>12&63)+a(e>>6&63)+a(e&63)}for(r=0,s=e.length-n;r<s;r+=3){o=(e[r]<<16)+(e[r+1]<<8)+e[r+2];i+=f(o)}switch(n){case 1:o=e[e.length-1];i+=a(o>>2);i+=a(o<<4&63);i+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1];i+=a(o>>10);i+=a(o>>4&63);i+=a(o<<2&63);i+="=";break;default:break}return i}e.toByteArray=l;e.fromByteArray=d})(typeof r==="undefined"?this.base64js={}:r)},{}],27:[function(e,t,r){r.read=function(e,t,r,n,i){var o,s;var a=i*8-n-1;var f=(1<<a)-1;var u=f>>1;var c=-7;var l=r?i-1:0;var d=r?-1:1;var h=e[t+l];l+=d;o=h&(1<<-c)-1;h>>=-c;c+=a;for(;c>0;o=o*256+e[t+l],l+=d,c-=8){}s=o&(1<<-c)-1;o>>=-c;c+=n;for(;c>0;s=s*256+e[t+l],l+=d,c-=8){}if(o===0){o=1-u}else if(o===f){return s?NaN:(h?-1:1)*Infinity}else{s=s+Math.pow(2,n);o=o-u}return(h?-1:1)*s*Math.pow(2,o-n)};r.write=function(e,t,r,n,i,o){var s,a,f;var u=o*8-i-1;var c=(1<<u)-1;var l=c>>1;var d=i===23?Math.pow(2,-24)-Math.pow(2,-77):0;var h=n?0:o-1;var p=n?1:-1;var m=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){a=isNaN(t)?1:0;s=c}else{s=Math.floor(Math.log(t)/Math.LN2);if(t*(f=Math.pow(2,-s))<1){s--;f*=2}if(s+l>=1){t+=d/f}else{t+=d*Math.pow(2,1-l)}if(t*f>=2){s++;f/=2}if(s+l>=c){a=0;s=c}else if(s+l>=1){a=(t*f-1)*Math.pow(2,i);s=s+l}else{a=t*Math.pow(2,l-1)*Math.pow(2,i);s=0}}for(;i>=8;e[r+h]=a&255,h+=p,a/=256,i-=8){}s=s<<i|a;u+=i;for(;u>0;e[r+h]=s&255,h+=p,s/=256,u-=8){}e[r+h-p]|=m*128}},{}],28:[function(e,t,r){var n={}.toString;t.exports=Array.isArray||function(e){return n.call(e)=="[object Array]"}},{}],29:[function(e,t,r){function n(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=n;n.EventEmitter=n;n.prototype._events=undefined;n.prototype._maxListeners=undefined;n.defaultMaxListeners=10;n.prototype.setMaxListeners=function(e){if(!o(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};n.prototype.emit=function(e){var t,r,n,o,f,u;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||s(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}throw TypeError('Uncaught, unspecified "error" event.')}}r=this._events[e];if(a(r))return false;if(i(r)){switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1);r.apply(this,o)}}else if(s(r)){o=Array.prototype.slice.call(arguments,1);u=r.slice();n=u.length;for(f=0;f<n;f++)u[f].apply(this,o)}return true};n.prototype.addListener=function(e,t){var r;if(!i(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,i(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(s(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(s(this._events[e])&&!this._events[e].warned){if(!a(this._maxListeners)){r=this._maxListeners}else{r=n.defaultMaxListeners}if(r&&r>0&&this._events[e].length>r){this._events[e].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[e].length);if(typeof console.trace==="function"){console.trace()}}}return this};n.prototype.on=n.prototype.addListener;n.prototype.once=function(e,t){if(!i(t))throw TypeError("listener must be a function");var r=false;function n(){this.removeListener(e,n);if(!r){r=true;t.apply(this,arguments)}}n.listener=t;this.on(e,n);return this};n.prototype.removeListener=function(e,t){var r,n,o,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];o=r.length;n=-1;if(r===t||i(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(s(r)){for(a=o;a-- >0;){if(r[a]===t||r[a].listener&&r[a].listener===t){n=a;break}}if(n<0)return this;if(r.length===1){r.length=0;delete this._events[e]}else{r.splice(n,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};n.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[e])delete this._events[e];return this}if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}this.removeAllListeners("removeListener");this._events={};return this}r=this._events[e];if(i(r)){this.removeListener(e,r)}else if(r){while(r.length)this.removeListener(e,r[r.length-1])}delete this._events[e];return this};n.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(i(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;else if(t)return t.length}return 0};n.listenerCount=function(e,t){return e.listenerCount(t)};function i(e){return typeof e==="function"}function o(e){return typeof e==="number"}function s(e){return typeof e==="object"&&e!==null}function a(e){return e===void 0}},{}],30:[function(e,t,r){var n=e("http");var i=t.exports;for(var o in n){if(n.hasOwnProperty(o))i[o]=n[o]}i.request=function(e,t){if(!e)e={};e.scheme="https";e.protocol="https:";return n.request.call(this,e,t)}},{http:53}],31:[function(e,t,r){t.exports=function(e){return!!(e!=null&&(e._isBuffer||e.constructor&&typeof e.constructor.isBuffer==="function"&&e.constructor.isBuffer(e)))}},{}],32:[function(e,t,r){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],33:[function(e,t,r){(function(e){function t(e,t){var r=0;for(var n=e.length-1;n>=0;n--){var i=e[n];if(i==="."){e.splice(n,1)}else if(i===".."){e.splice(n,1);r++}else if(r){e.splice(n,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var i=function(e){return n.exec(e).slice(1)};r.resolve=function(){var r="",n=false;for(var i=arguments.length-1;i>=-1&&!n;i--){var s=i>=0?arguments[i]:e.cwd();if(typeof s!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!s){continue}r=s+"/"+r;n=s.charAt(0)==="/"}r=t(o(r.split("/"),function(e){return!!e}),!n).join("/");return(n?"/":"")+r||"."};r.normalize=function(e){var n=r.isAbsolute(e),i=s(e,-1)==="/";e=t(o(e.split("/"),function(e){return!!e}),!n).join("/");if(!e&&!n){e="."}if(e&&i){e+="/"}return(n?"/":"")+e};r.isAbsolute=function(e){return e.charAt(0)==="/"};r.join=function(){var e=Array.prototype.slice.call(arguments,0);return r.normalize(o(e,function(e,t){if(typeof e!=="string"){throw new TypeError("Arguments to path.join must be strings")}return e}).join("/"))};r.relative=function(e,t){e=r.resolve(e).substr(1);t=r.resolve(t).substr(1);function n(e){var t=0;for(;t<e.length;t++){if(e[t]!=="")break}var r=e.length-1;for(;r>=0;r--){if(e[r]!=="")break}if(t>r)return[];return e.slice(t,r-t+1)}var i=n(e.split("/"));var o=n(t.split("/"));var s=Math.min(i.length,o.length);var a=s;for(var f=0;f<s;f++){if(i[f]!==o[f]){a=f;break}}var u=[];for(var f=a;f<i.length;f++){u.push("..")}u=u.concat(o.slice(a));return u.join("/")};r.sep="/";r.delimiter=":";r.dirname=function(e){var t=i(e),r=t[0],n=t[1];if(!r&&!n){return"."}if(n){n=n.substr(0,n.length-1)}return r+n};r.basename=function(e,t){var r=i(e)[2];if(t&&r.substr(-1*t.length)===t){r=r.substr(0,r.length-t.length)}return r};r.extname=function(e){return i(e)[3]};function o(e,t){if(e.filter)return e.filter(t);var r=[];for(var n=0;n<e.length;n++){if(t(e[n],n,e))r.push(e[n])}return r}var s="ab".substr(-1)==="b"?function(e,t,r){return e.substr(t,r)}:function(e,t,r){if(t<0)t=e.length+t;return e.substr(t,r)}}).call(this,e("_process"))},{_process:34}],34:[function(e,t,r){var n=t.exports={};var i=[];var o=false;var s;var a=-1;function f(){o=false;if(s.length){i=s.concat(i)}else{a=-1}if(i.length){u()}}function u(){if(o){return}var e=setTimeout(f);o=true;var t=i.length;while(t){s=i;i=[];while(++a<t){if(s){s[a].run()}}a=-1;t=i.length}s=null;o=false;clearTimeout(e)}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1){for(var r=1;r<arguments.length;r++){t[r-1]=arguments[r]}}i.push(new c(e,t));if(i.length===1&&!o){setTimeout(u,0)}};function c(e,t){this.fun=e;this.array=t}c.prototype.run=function(){this.fun.apply(null,this.array)};n.title="browser";n.browser=true;n.env={};n.argv=[];n.version="";n.versions={};function l(){}n.on=l;n.addListener=l;n.once=l;n.off=l;n.removeListener=l;n.removeAllListeners=l;n.emit=l;n.binding=function(e){throw new Error("process.binding is not supported")};n.cwd=function(){return"/"};n.chdir=function(e){throw new Error("process.chdir is not supported")};n.umask=function(){return 0}},{}],35:[function(t,r,n){(function(t){(function(i){var o=typeof n=="object"&&n&&!n.nodeType&&n;var s=typeof r=="object"&&r&&!r.nodeType&&r;var a=typeof t=="object"&&t;if(a.global===a||a.window===a||a.self===a){i=a}var f,u=2147483647,c=36,l=1,d=26,h=38,p=700,m=72,v=128,g="-",y=/^xn--/,_=/[^\x20-\x7E]/,b=/[\x2E\u3002\uFF0E\uFF61]/g,w={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=c-l,x=Math.floor,k=String.fromCharCode,S;function B(e){throw new RangeError(w[e])}function I(e,t){var r=e.length;var n=[];while(r--){n[r]=t(e[r])}return n}function A(e,t){var r=e.split("@");var n="";if(r.length>1){n=r[0]+"@";e=r[1]}e=e.replace(b,".");var i=e.split(".");var o=I(i,t).join(".");return n+o}function C(e){var t=[],r=0,n=e.length,i,o;while(r<n){i=e.charCodeAt(r++);if(i>=55296&&i<=56319&&r<n){o=e.charCodeAt(r++);if((o&64512)==56320){t.push(((i&1023)<<10)+(o&1023)+65536)}else{t.push(i);r--}}else{t.push(i)}}return t}function T(e){return I(e,function(e){var t="";if(e>65535){e-=65536;t+=k(e>>>10&1023|55296);e=56320|e&1023}t+=k(e);return t}).join("")}function L(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return c}function R(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function U(e,t,r){var n=0;e=r?x(e/p):e>>1;e+=x(e/t);for(;e>E*d>>1;n+=c){e=x(e/E)}return x(n+(E+1)*e/(e+h))}function P(e){var t=[],r=e.length,n,i=0,o=v,s=m,a,f,h,p,y,_,b,w,E;a=e.lastIndexOf(g);if(a<0){a=0}for(f=0;f<a;++f){if(e.charCodeAt(f)>=128){B("not-basic")}t.push(e.charCodeAt(f))}for(h=a>0?a+1:0;h<r;){for(p=i,y=1,_=c;;_+=c){if(h>=r){B("invalid-input")}b=L(e.charCodeAt(h++));if(b>=c||b>x((u-i)/y)){B("overflow")}i+=b*y;w=_<=s?l:_>=s+d?d:_-s;if(b<w){break}E=c-w;if(y>x(u/E)){B("overflow")}y*=E}n=t.length+1;s=U(i-p,n,p==0);if(x(i/n)>u-o){B("overflow")}o+=x(i/n);i%=n;t.splice(i++,0,o)}return T(t)}function j(e){var t,r,n,i,o,s,a,f,h,p,y,_=[],b,w,E,S;e=C(e);b=e.length;t=v;r=0;o=m;for(s=0;s<b;++s){y=e[s];if(y<128){_.push(k(y))}}n=i=_.length;if(i){_.push(g)}while(n<b){for(a=u,s=0;s<b;++s){y=e[s];if(y>=t&&y<a){a=y}}w=n+1;if(a-t>x((u-r)/w)){B("overflow")}r+=(a-t)*w;t=a;for(s=0;s<b;++s){y=e[s];if(y<t&&++r>u){B("overflow")}if(y==t){for(f=r,h=c;;h+=c){p=h<=o?l:h>=o+d?d:h-o;if(f<p){break}S=f-p;E=c-p;_.push(k(R(p+S%E,0)));f=x(S/E)}_.push(k(R(f,0)));o=U(r,w,n==i);r=0;++n}}++r;++t}return _.join("")}function O(e){return A(e,function(e){return y.test(e)?P(e.slice(4).toLowerCase()):e})}function M(e){return A(e,function(e){return _.test(e)?"xn--"+j(e):e})}f={version:"1.3.2",ucs2:{decode:C,encode:T},decode:P,encode:j,toASCII:M,toUnicode:O};if(typeof e=="function"&&typeof e.amd=="object"&&e.amd){e("punycode",function(){return f})}else if(o&&s){if(r.exports==o){s.exports=f}else{for(S in f){f.hasOwnProperty(S)&&(o[S]=f[S])}}}else{i.punycode=f}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],36:[function(e,t,r){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,o){t=t||"&";r=r||"=";var s={};if(typeof e!=="string"||e.length===0){return s}var a=/\+/g;e=e.split(t);var f=1e3;if(o&&typeof o.maxKeys==="number"){f=o.maxKeys}var u=e.length;if(f>0&&u>f){u=f}for(var c=0;c<u;++c){var l=e[c].replace(a,"%20"),d=l.indexOf(r),h,p,m,v;if(d>=0){h=l.substr(0,d);p=l.substr(d+1)}else{h=l;p=""}m=decodeURIComponent(h);v=decodeURIComponent(p);if(!n(s,m)){s[m]=v}else if(i(s[m])){s[m].push(v)}else{s[m]=[s[m],v]}}return s};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],37:[function(e,t,r){"use strict";var n=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}};t.exports=function(e,t,r,a){t=t||"&";r=r||"=";if(e===null){e=undefined}if(typeof e==="object"){return o(s(e),function(s){var a=encodeURIComponent(n(s))+r;if(i(e[s])){return o(e[s],function(e){return a+encodeURIComponent(n(e))}).join(t)}else{return a+encodeURIComponent(n(e[s]))}}).join(t)}if(!a)return"";return encodeURIComponent(n(a))+r+encodeURIComponent(n(e))};var i=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};function o(e,t){if(e.map)return e.map(t);var r=[];for(var n=0;n<e.length;n++){r.push(t(e[n],n))}return r}var s=Object.keys||function(e){var t=[];for(var r in e){if(Object.prototype.hasOwnProperty.call(e,r))t.push(r)}return t}},{}],38:[function(e,t,r){"use strict";r.decode=r.parse=e("./decode");r.encode=r.stringify=e("./encode")},{"./decode":36,"./encode":37}],39:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":40}],
+40:[function(e,t,r){"use strict";var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=l;var i=e("process-nextick-args");var o=e("core-util-is");o.inherits=e("inherits");var s=e("./_stream_readable");var a=e("./_stream_writable");o.inherits(l,s);var f=n(a.prototype);for(var u=0;u<f.length;u++){var c=f[u];if(!l.prototype[c])l.prototype[c]=a.prototype[c]}function l(e){if(!(this instanceof l))return new l(e);s.call(this,e);a.call(this,e);if(e&&e.readable===false)this.readable=false;if(e&&e.writable===false)this.writable=false;this.allowHalfOpen=true;if(e&&e.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",d)}function d(){if(this.allowHalfOpen||this._writableState.ended)return;i(h,this)}function h(e){e.end()}function p(e,t){for(var r=0,n=e.length;r<n;r++){t(e[r],r)}}},{"./_stream_readable":42,"./_stream_writable":44,"core-util-is":45,inherits:115,"process-nextick-args":46}],41:[function(e,t,r){"use strict";t.exports=o;var n=e("./_stream_transform");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(o,n);function o(e){if(!(this instanceof o))return new o(e);n.call(this,e)}o.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":43,"core-util-is":45,inherits:115}],42:[function(e,t,r){(function(r){"use strict";t.exports=m;var n=e("process-nextick-args");var i=e("isarray");var o=e("buffer").Buffer;m.ReadableState=p;var s=e("events");var a=function(e,t){return e.listeners(t).length};var f;(function(){try{f=e("st"+"ream")}catch(t){}finally{if(!f)f=e("events").EventEmitter}})();var o=e("buffer").Buffer;var u=e("core-util-is");u.inherits=e("inherits");var c=e("util");var l;if(c&&c.debuglog){l=c.debuglog("stream")}else{l=function(){}}var d;u.inherits(m,f);var h;function p(t,r){h=h||e("./_stream_duplex");t=t||{};this.objectMode=!!t.objectMode;if(r instanceof h)this.objectMode=this.objectMode||!!t.readableObjectMode;var n=t.highWaterMark;var i=this.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:i;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=null;this.ended=false;this.endEmitted=false;this.reading=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.defaultEncoding=t.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(t.encoding){if(!d)d=e("string_decoder/").StringDecoder;this.decoder=new d(t.encoding);this.encoding=t.encoding}}var h;function m(t){h=h||e("./_stream_duplex");if(!(this instanceof m))return new m(t);this._readableState=new p(t,this);this.readable=true;if(t&&typeof t.read==="function")this._read=t.read;f.call(this)}m.prototype.push=function(e,t){var r=this._readableState;if(!r.objectMode&&typeof e==="string"){t=t||r.defaultEncoding;if(t!==r.encoding){e=new o(e,t);t=""}}return v(this,r,e,t,false)};m.prototype.unshift=function(e){var t=this._readableState;return v(this,t,e,"",true)};m.prototype.isPaused=function(){return this._readableState.flowing===false};function v(e,t,r,n,i){var o=w(t,r);if(o){e.emit("error",o)}else if(r===null){t.reading=false;E(e,t)}else if(t.objectMode||r&&r.length>0){if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{if(t.decoder&&!i&&!n)r=t.decoder.write(r);if(!i)t.reading=false;if(t.flowing&&t.length===0&&!t.sync){e.emit("data",r);e.read(0)}else{t.length+=t.objectMode?1:r.length;if(i)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)x(e)}S(e,t)}}else if(!i){t.reading=false}return g(t)}function g(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}m.prototype.setEncoding=function(t){if(!d)d=e("string_decoder/").StringDecoder;this._readableState.decoder=new d(t);this._readableState.encoding=t;return this};var y=8388608;function _(e){if(e>=y){e=y}else{e--;e|=e>>>1;e|=e>>>2;e|=e>>>4;e|=e>>>8;e|=e>>>16;e++}return e}function b(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(e===null||isNaN(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=_(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else{return t.length}}return e}m.prototype.read=function(e){l("read",e);var t=this._readableState;var r=e;if(typeof e!=="number"||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){l("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)U(this);else x(this);return null}e=b(e,t);if(e===0&&t.ended){if(t.length===0)U(this);return null}var n=t.needReadable;l("need readable",n);if(t.length===0||t.length-e<t.highWaterMark){n=true;l("length less than watermark",n)}if(t.ended||t.reading){n=false;l("reading or ended",n)}if(n){l("do read");t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(n&&!t.reading)e=b(r,t);var i;if(e>0)i=R(e,t);else i=null;if(i===null){t.needReadable=true;e=0}t.length-=e;if(t.length===0&&!t.ended)t.needReadable=true;if(r!==e&&t.ended&&t.length===0)U(this);if(i!==null)this.emit("data",i);return i};function w(e,t){var r=null;if(!o.isBuffer(t)&&typeof t!=="string"&&t!==null&&t!==undefined&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function E(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;x(e)}function x(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){l("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)n(k,e);else k(e)}}function k(e){l("emit readable");e.emit("readable");L(e)}function S(e,t){if(!t.readingMore){t.readingMore=true;n(B,e,t)}}function B(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){l("maybeReadMore read 0");e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}m.prototype._read=function(e){this.emit("error",new Error("not implemented"))};m.prototype.pipe=function(e,t){var o=this;var s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e);break}s.pipesCount+=1;l("pipe count=%d opts=%j",s.pipesCount,t);var f=(!t||t.end!==false)&&e!==r.stdout&&e!==r.stderr;var u=f?d:m;if(s.endEmitted)n(u);else o.once("end",u);e.on("unpipe",c);function c(e){l("onunpipe");if(e===o){m()}}function d(){l("onend");e.end()}var h=I(o);e.on("drain",h);var p=false;function m(){l("cleanup");e.removeListener("close",y);e.removeListener("finish",_);e.removeListener("drain",h);e.removeListener("error",g);e.removeListener("unpipe",c);o.removeListener("end",d);o.removeListener("end",m);o.removeListener("data",v);p=true;if(s.awaitDrain&&(!e._writableState||e._writableState.needDrain))h()}o.on("data",v);function v(t){l("ondata");var r=e.write(t);if(false===r){if(s.pipesCount===1&&s.pipes[0]===e&&o.listenerCount("data")===1&&!p){l("false write response, pause",o._readableState.awaitDrain);o._readableState.awaitDrain++}o.pause()}}function g(t){l("onerror",t);b();e.removeListener("error",g);if(a(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",g);else if(i(e._events.error))e._events.error.unshift(g);else e._events.error=[g,e._events.error];function y(){e.removeListener("finish",_);b()}e.once("close",y);function _(){l("onfinish");e.removeListener("close",y);b()}e.once("finish",_);function b(){l("unpipe");o.unpipe(e)}e.emit("pipe",o);if(!s.flowing){l("pipe resume");o.resume()}return e};function I(e){return function(){var t=e._readableState;l("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&a(e,"data")){t.flowing=true;L(e)}}}m.prototype.unpipe=function(e){var t=this._readableState;if(t.pipesCount===0)return this;if(t.pipesCount===1){if(e&&e!==t.pipes)return this;if(!e)e=t.pipes;t.pipes=null;t.pipesCount=0;t.flowing=false;if(e)e.emit("unpipe",this);return this}if(!e){var r=t.pipes;var n=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var i=O(t.pipes,e);if(i===-1)return this;t.pipes.splice(i,1);t.pipesCount-=1;if(t.pipesCount===1)t.pipes=t.pipes[0];e.emit("unpipe",this);return this};m.prototype.on=function(e,t){var r=f.prototype.on.call(this,e,t);if(e==="data"&&false!==this._readableState.flowing){this.resume()}if(e==="readable"&&this.readable){var i=this._readableState;if(!i.readableListening){i.readableListening=true;i.emittedReadable=false;i.needReadable=true;if(!i.reading){n(A,this)}else if(i.length){x(this,i)}}}return r};m.prototype.addListener=m.prototype.on;function A(e){l("readable nexttick read 0");e.read(0)}m.prototype.resume=function(){var e=this._readableState;if(!e.flowing){l("resume");e.flowing=true;C(this,e)}return this};function C(e,t){if(!t.resumeScheduled){t.resumeScheduled=true;n(T,e,t)}}function T(e,t){if(!t.reading){l("resume read 0");e.read(0)}t.resumeScheduled=false;e.emit("resume");L(e);if(t.flowing&&!t.reading)e.read(0)}m.prototype.pause=function(){l("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){l("pause");this._readableState.flowing=false;this.emit("pause")}return this};function L(e){var t=e._readableState;l("flow",t.flowing);if(t.flowing){do{var r=e.read()}while(null!==r&&t.flowing)}}m.prototype.wrap=function(e){var t=this._readableState;var r=false;var n=this;e.on("end",function(){l("wrapped end");if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)n.push(e)}n.push(null)});e.on("data",function(i){l("wrapped data");if(t.decoder)i=t.decoder.write(i);if(t.objectMode&&(i===null||i===undefined))return;else if(!t.objectMode&&(!i||!i.length))return;var o=n.push(i);if(!o){r=true;e.pause()}});for(var i in e){if(this[i]===undefined&&typeof e[i]==="function"){this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i)}}var o=["error","close","destroy","pause","resume"];j(o,function(t){e.on(t,n.emit.bind(n,t))});n._read=function(t){l("wrapped _read",t);if(r){r=false;e.resume()}};return n};m._fromList=R;function R(e,t){var r=t.buffer;var n=t.length;var i=!!t.decoder;var s=!!t.objectMode;var a;if(r.length===0)return null;if(n===0)a=null;else if(s)a=r.shift();else if(!e||e>=n){if(i)a=r.join("");else if(r.length===1)a=r[0];else a=o.concat(r,n);r.length=0}else{if(e<r[0].length){var f=r[0];a=f.slice(0,e);r[0]=f.slice(e)}else if(e===r[0].length){a=r.shift()}else{if(i)a="";else a=new o(e);var u=0;for(var c=0,l=r.length;c<l&&u<e;c++){var f=r[0];var d=Math.min(e-u,f.length);if(i)a+=f.slice(0,d);else f.copy(a,u,0,d);if(d<f.length)r[0]=f.slice(d);else r.shift();u+=d}}}return a}function U(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;n(P,t,e)}}function P(e,t){if(!e.endEmitted&&e.length===0){e.endEmitted=true;t.readable=false;t.emit("end")}}function j(e,t){for(var r=0,n=e.length;r<n;r++){t(e[r],r)}}function O(e,t){for(var r=0,n=e.length;r<n;r++){if(e[r]===t)return r}return-1}}).call(this,e("_process"))},{"./_stream_duplex":40,_process:34,buffer:25,"core-util-is":45,events:29,inherits:115,isarray:32,"process-nextick-args":46,"string_decoder/":59,util:24}],43:[function(e,t,r){"use strict";t.exports=a;var n=e("./_stream_duplex");var i=e("core-util-is");i.inherits=e("inherits");i.inherits(a,n);function o(e){this.afterTransform=function(t,r){return s(e,t,r)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function s(e,t,r){var n=e._transformState;n.transforming=false;var i=n.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));n.writechunk=null;n.writecb=null;if(r!==null&&r!==undefined)e.push(r);if(i)i(t);var o=e._readableState;o.reading=false;if(o.needReadable||o.length<o.highWaterMark){e._read(o.highWaterMark)}}function a(e){if(!(this instanceof a))return new a(e);n.call(this,e);this._transformState=new o(this);var t=this;this._readableState.needReadable=true;this._readableState.sync=false;if(e){if(typeof e.transform==="function")this._transform=e.transform;if(typeof e.flush==="function")this._flush=e.flush}this.once("prefinish",function(){if(typeof this._flush==="function")this._flush(function(e){f(t,e)});else f(t)})}a.prototype.push=function(e,t){this._transformState.needTransform=false;return n.prototype.push.call(this,e,t)};a.prototype._transform=function(e,t,r){throw new Error("not implemented")};a.prototype._write=function(e,t,r){var n=this._transformState;n.writecb=r;n.writechunk=e;n.writeencoding=t;if(!n.transforming){var i=this._readableState;if(n.needTransform||i.needReadable||i.length<i.highWaterMark)this._read(i.highWaterMark)}};a.prototype._read=function(e){var t=this._transformState;if(t.writechunk!==null&&t.writecb&&!t.transforming){t.transforming=true;this._transform(t.writechunk,t.writeencoding,t.afterTransform)}else{t.needTransform=true}};function f(e,t){if(t)return e.emit("error",t);var r=e._writableState;var n=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(n.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":40,"core-util-is":45,inherits:115}],44:[function(e,t,r){"use strict";t.exports=d;var n=e("process-nextick-args");var i=e("buffer").Buffer;d.WritableState=l;var o=e("core-util-is");o.inherits=e("inherits");var s={deprecate:e("util-deprecate")};var a;(function(){try{a=e("st"+"ream")}catch(t){}finally{if(!a)a=e("events").EventEmitter}})();var i=e("buffer").Buffer;o.inherits(d,a);function f(){}function u(e,t,r){this.chunk=e;this.encoding=t;this.callback=r;this.next=null}var c;function l(t,r){c=c||e("./_stream_duplex");t=t||{};this.objectMode=!!t.objectMode;if(r instanceof c)this.objectMode=this.objectMode||!!t.writableObjectMode;var n=t.highWaterMark;var i=this.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:i;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var o=t.decodeStrings===false;this.decodeStrings=!o;this.defaultEncoding=t.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){b(r,e)};this.writecb=null;this.writelen=0;this.bufferedRequest=null;this.lastBufferedRequest=null;this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}l.prototype.getBuffer=function A(){var e=this.bufferedRequest;var t=[];while(e){t.push(e);e=e.next}return t};(function(){try{Object.defineProperty(l.prototype,"buffer",{get:s.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer "+"instead.")})}catch(e){}})();var c;function d(t){c=c||e("./_stream_duplex");if(!(this instanceof d)&&!(this instanceof c))return new d(t);this._writableState=new l(t,this);this.writable=true;if(t){if(typeof t.write==="function")this._write=t.write;if(typeof t.writev==="function")this._writev=t.writev}a.call(this)}d.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function h(e,t){var r=new Error("write after end");e.emit("error",r);n(t,r)}function p(e,t,r,o){var s=true;if(!i.isBuffer(r)&&typeof r!=="string"&&r!==null&&r!==undefined&&!t.objectMode){var a=new TypeError("Invalid non-string/buffer chunk");e.emit("error",a);n(o,a);s=false}return s}d.prototype.write=function(e,t,r){var n=this._writableState;var o=false;if(typeof t==="function"){r=t;t=null}if(i.isBuffer(e))t="buffer";else if(!t)t=n.defaultEncoding;if(typeof r!=="function")r=f;if(n.ended)h(this,r);else if(p(this,n,e,r)){n.pendingcb++;o=v(this,n,e,t,r)}return o};d.prototype.cork=function(){var e=this._writableState;e.corked++};d.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest)x(this,e)}};d.prototype.setDefaultEncoding=function C(e){if(typeof e==="string")e=e.toLowerCase();if(!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);this._writableState.defaultEncoding=e};function m(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&typeof t==="string"){t=new i(t,r)}return t}function v(e,t,r,n,o){r=m(t,r,n);if(i.isBuffer(r))n="buffer";var s=t.objectMode?1:r.length;t.length+=s;var a=t.length<t.highWaterMark;if(!a)t.needDrain=true;if(t.writing||t.corked){var f=t.lastBufferedRequest;t.lastBufferedRequest=new u(r,n,o);if(f){f.next=t.lastBufferedRequest}else{t.bufferedRequest=t.lastBufferedRequest}}else{g(e,t,false,s,r,n,o)}return a}function g(e,t,r,n,i,o,s){t.writelen=n;t.writecb=s;t.writing=true;t.sync=true;if(r)e._writev(i,t.onwrite);else e._write(i,o,t.onwrite);t.sync=false}function y(e,t,r,i,o){--t.pendingcb;if(r)n(o,i);else o(i);e._writableState.errorEmitted=true;e.emit("error",i)}function _(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function b(e,t){var r=e._writableState;var i=r.sync;var o=r.writecb;_(r);if(t)y(e,r,i,t,o);else{var s=k(r);if(!s&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest){x(e,r)}if(i){n(w,e,r,s,o)}else{w(e,r,s,o)}}}function w(e,t,r,n){if(!r)E(e,t);t.pendingcb--;n();B(e,t)}function E(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function x(e,t){t.bufferProcessing=true;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=[];var i=[];while(r){i.push(r.callback);n.push(r);r=r.next}t.pendingcb++;t.lastBufferedRequest=null;g(e,t,true,t.length,n,"",function(e){for(var r=0;r<i.length;r++){t.pendingcb--;i[r](e)}})}else{while(r){var o=r.chunk;var s=r.encoding;var a=r.callback;var f=t.objectMode?1:o.length;g(e,t,false,f,o,s,a);r=r.next;if(t.writing){break}}if(r===null)t.lastBufferedRequest=null}t.bufferedRequest=r;t.bufferProcessing=false}d.prototype._write=function(e,t,r){r(new Error("not implemented"))};d.prototype._writev=null;d.prototype.end=function(e,t,r){var n=this._writableState;if(typeof e==="function"){r=e;e=null;t=null}else if(typeof t==="function"){r=t;t=null}if(e!==null&&e!==undefined)this.write(e,t);if(n.corked){n.corked=1;this.uncork()}if(!n.ending&&!n.finished)I(this,n,r)};function k(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function S(e,t){if(!t.prefinished){t.prefinished=true;e.emit("prefinish")}}function B(e,t){var r=k(t);if(r){if(t.pendingcb===0){S(e,t);t.finished=true;e.emit("finish")}else{S(e,t)}}return r}function I(e,t,r){t.ending=true;B(e,t);if(r){if(t.finished)n(r);else e.once("finish",r)}t.ended=true}},{"./_stream_duplex":40,buffer:25,"core-util-is":45,events:29,inherits:115,"process-nextick-args":46,"util-deprecate":47}],45:[function(e,t,r){(function(e){function t(e){if(Array.isArray){return Array.isArray(e)}return v(e)==="[object Array]"}r.isArray=t;function n(e){return typeof e==="boolean"}r.isBoolean=n;function i(e){return e===null}r.isNull=i;function o(e){return e==null}r.isNullOrUndefined=o;function s(e){return typeof e==="number"}r.isNumber=s;function a(e){return typeof e==="string"}r.isString=a;function f(e){return typeof e==="symbol"}r.isSymbol=f;function u(e){return e===void 0}r.isUndefined=u;function c(e){return v(e)==="[object RegExp]"}r.isRegExp=c;function l(e){return typeof e==="object"&&e!==null}r.isObject=l;function d(e){return v(e)==="[object Date]"}r.isDate=d;function h(e){return v(e)==="[object Error]"||e instanceof Error}r.isError=h;function p(e){return typeof e==="function"}r.isFunction=p;function m(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=m;r.isBuffer=e.isBuffer;function v(e){return Object.prototype.toString.call(e)}}).call(this,{isBuffer:e("../../../../insert-module-globals/node_modules/is-buffer/index.js")})},{"../../../../insert-module-globals/node_modules/is-buffer/index.js":31}],46:[function(e,t,r){(function(e){"use strict";if(!e.version||e.version.indexOf("v0.")===0||e.version.indexOf("v1.")===0&&e.version.indexOf("v1.8.")!==0){t.exports=r}else{t.exports=e.nextTick}function r(t){var r=new Array(arguments.length-1);var n=0;while(n<r.length){r[n++]=arguments[n]}e.nextTick(function i(){t.apply(null,r)})}}).call(this,e("_process"))},{_process:34}],47:[function(e,t,r){(function(e){t.exports=r;function r(e,t){if(n("noDeprecation")){return e}var r=false;function i(){if(!r){if(n("throwDeprecation")){throw new Error(t)}else if(n("traceDeprecation")){console.trace(t)}else{console.warn(t)}r=true}return e.apply(this,arguments)}return i}function n(t){try{if(!e.localStorage)return false}catch(r){return false}var n=e.localStorage[t];if(null==n)return false;return String(n).toLowerCase()==="true"}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],48:[function(e,t,r){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":41}],49:[function(e,t,r){var n=function(){try{return e("st"+"ream")}catch(t){}}();r=t.exports=e("./lib/_stream_readable.js");r.Stream=n||r;r.Readable=r;r.Writable=e("./lib/_stream_writable.js");r.Duplex=e("./lib/_stream_duplex.js");r.Transform=e("./lib/_stream_transform.js");r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":40,"./lib/_stream_passthrough.js":41,"./lib/_stream_readable.js":42,"./lib/_stream_transform.js":43,"./lib/_stream_writable.js":44}],50:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":43}],51:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":44}],52:[function(e,t,r){t.exports=o;var n=e("events").EventEmitter;var i=e("inherits");i(o,n);o.Readable=e("readable-stream/readable.js");o.Writable=e("readable-stream/writable.js");o.Duplex=e("readable-stream/duplex.js");o.Transform=e("readable-stream/transform.js");o.PassThrough=e("readable-stream/passthrough.js");o.Stream=o;function o(){n.call(this)}o.prototype.pipe=function(e,t){var r=this;function i(t){if(e.writable){if(false===e.write(t)&&r.pause){r.pause()}}}r.on("data",i);function o(){if(r.readable&&r.resume){r.resume()}}e.on("drain",o);if(!e._isStdio&&(!t||t.end!==false)){r.on("end",a);r.on("close",f)}var s=false;function a(){if(s)return;s=true;e.end()}function f(){if(s)return;s=true;if(typeof e.destroy==="function")e.destroy()}function u(e){c();if(n.listenerCount(this,"error")===0){throw e}}r.on("error",u);e.on("error",u);function c(){r.removeListener("data",i);e.removeListener("drain",o);r.removeListener("end",a);r.removeListener("close",f);r.removeListener("error",u);e.removeListener("error",u);r.removeListener("end",c);r.removeListener("close",c);e.removeListener("close",c)}r.on("end",c);r.on("close",c);e.on("close",c);e.emit("pipe",r);return e}},{events:29,inherits:115,"readable-stream/duplex.js":39,"readable-stream/passthrough.js":48,"readable-stream/readable.js":49,"readable-stream/transform.js":50,"readable-stream/writable.js":51}],53:[function(e,t,r){(function(t){var n=e("./lib/request");var i=e("xtend");var o=e("builtin-status-codes");var s=e("url");var a=r;a.request=function(e,r){if(typeof e==="string")e=s.parse(e);else e=i(e);var o=t.location.protocol.search(/^https?:$/)===-1?"http:":"";var a=e.protocol||o;var f=e.hostname||e.host;var u=e.port;var c=e.path||"/";if(f&&f.indexOf(":")!==-1)f="["+f+"]";e.url=(f?a+"//"+f:"")+(u?":"+u:"")+c;e.method=(e.method||"GET").toUpperCase();e.headers=e.headers||{};var l=new n(e);if(r)l.on("response",r);return l};a.get=function f(e,t){var r=a.request(e,t);r.end();return r};a.Agent=function(){};a.Agent.defaultMaxSockets=4;a.STATUS_CODES=o;a.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./lib/request":55,"builtin-status-codes":57,url:60,xtend:210}],54:[function(e,t,r){(function(e){r.fetch=a(e.fetch)&&a(e.ReadableByteStream);r.blobConstructor=false;try{new Blob([new ArrayBuffer(1)]);r.blobConstructor=true}catch(t){}var n=new e.XMLHttpRequest;n.open("GET",e.location.host?"/":"https://example.com");function i(e){try{n.responseType=e;return n.responseType===e}catch(t){}return false}var o=typeof e.ArrayBuffer!=="undefined";var s=o&&a(e.ArrayBuffer.prototype.slice);r.arraybuffer=o&&i("arraybuffer");r.msstream=!r.fetch&&s&&i("ms-stream");r.mozchunkedarraybuffer=!r.fetch&&o&&i("moz-chunked-arraybuffer");r.overrideMimeType=a(n.overrideMimeType);r.vbArray=a(e.VBArray);function a(e){return typeof e==="function"}n=null}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],55:[function(e,t,r){(function(r,n,i){var o=e("./capability");var s=e("inherits");var a=e("./response");var f=e("stream");var u=e("to-arraybuffer");var c=a.IncomingMessage;var l=a.readyStates;function d(e){if(o.fetch){return"fetch"}else if(o.mozchunkedarraybuffer){return"moz-chunked-arraybuffer"}else if(o.msstream){return"ms-stream"}else if(o.arraybuffer&&e){return"arraybuffer"}else if(o.vbArray&&e){return"text:vbarray"}else{return"text"}}var h=t.exports=function(e){var t=this;f.Writable.call(t);t._opts=e;t._body=[];t._headers={};if(e.auth)t.setHeader("Authorization","Basic "+new i(e.auth).toString("base64"));Object.keys(e.headers).forEach(function(r){t.setHeader(r,e.headers[r])});var r;if(e.mode==="prefer-streaming"){r=false}else if(e.mode==="allow-wrong-content-type"){r=!o.overrideMimeType}else if(!e.mode||e.mode==="default"||e.mode==="prefer-fast"){r=true}else{throw new Error("Invalid value for opts.mode")}t._mode=d(r);t.on("finish",function(){t._onFinish()})};s(h,f.Writable);h.prototype.setHeader=function(e,t){var r=this;var n=e.toLowerCase();if(m.indexOf(n)!==-1)return;r._headers[n]={name:e,value:t}};h.prototype.getHeader=function(e){var t=this;return t._headers[e.toLowerCase()].value};h.prototype.removeHeader=function(e){var t=this;delete t._headers[e.toLowerCase()]};h.prototype._onFinish=function(){var e=this;if(e._destroyed)return;var t=e._opts;var s=e._headers;var a;if(t.method==="POST"||t.method==="PUT"||t.method==="PATCH"){if(o.blobConstructor){a=new n.Blob(e._body.map(function(e){return u(e)}),{type:(s["content-type"]||{}).value||""})}else{a=i.concat(e._body).toString()}}if(e._mode==="fetch"){var f=Object.keys(s).map(function(e){return[s[e].name,s[e].value]});n.fetch(e._opts.url,{method:e._opts.method,headers:f,body:a,mode:"cors",credentials:t.withCredentials?"include":"same-origin"}).then(function(t){e._fetchResponse=t;e._connect()},function(t){e.emit("error",t)})}else{var c=e._xhr=new n.XMLHttpRequest;try{c.open(e._opts.method,e._opts.url,true)}catch(d){r.nextTick(function(){e.emit("error",d)});return}if("responseType"in c)c.responseType=e._mode.split(":")[0];if("withCredentials"in c)c.withCredentials=!!t.withCredentials;if(e._mode==="text"&&"overrideMimeType"in c)c.overrideMimeType("text/plain; charset=x-user-defined");Object.keys(s).forEach(function(e){c.setRequestHeader(s[e].name,s[e].value)});e._response=null;c.onreadystatechange=function(){switch(c.readyState){case l.LOADING:case l.DONE:e._onXHRProgress();break}};if(e._mode==="moz-chunked-arraybuffer"){c.onprogress=function(){e._onXHRProgress()}}c.onerror=function(){if(e._destroyed)return;e.emit("error",new Error("XHR error"))};try{c.send(a)}catch(d){r.nextTick(function(){e.emit("error",d)});return}}};function p(e){try{var t=e.status;return t!==null&&t!==0}catch(r){return false}}h.prototype._onXHRProgress=function(){var e=this;if(!p(e._xhr)||e._destroyed)return;if(!e._response)e._connect();e._response._onXHRProgress()};h.prototype._connect=function(){var e=this;if(e._destroyed)return;e._response=new c(e._xhr,e._fetchResponse,e._mode);e.emit("response",e._response)};h.prototype._write=function(e,t,r){var n=this;n._body.push(e);r()};h.prototype.abort=h.prototype.destroy=function(){var e=this;e._destroyed=true;if(e._response)e._response._destroyed=true;if(e._xhr)e._xhr.abort()};h.prototype.end=function(e,t,r){var n=this;if(typeof e==="function"){r=e;e=undefined}f.Writable.prototype.end.call(n,e,t,r)};h.prototype.flushHeaders=function(){};h.prototype.setTimeout=function(){};h.prototype.setNoDelay=function(){};h.prototype.setSocketKeepAlive=function(){};var m=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./capability":54,"./response":56,_process:34,buffer:25,inherits:115,stream:52,"to-arraybuffer":58}],56:[function(e,t,r){(function(t,n,i){var o=e("./capability");var s=e("inherits");var a=e("stream");var f=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4};var u=r.IncomingMessage=function(e,r,n){var s=this;a.Readable.call(s);s._mode=n;s.headers={};s.rawHeaders=[];s.trailers={};s.rawTrailers=[];s.on("end",function(){t.nextTick(function(){s.emit("close")})});if(n==="fetch"){s._fetchResponse=r;s.statusCode=r.status;s.statusMessage=r.statusText;for(var f,u,c=r.headers[Symbol.iterator]();f=(u=c.next()).value,!u.done;){s.headers[f[0].toLowerCase()]=f[1];s.rawHeaders.push(f[0],f[1])}var l=r.body.getReader();function d(){l.read().then(function(e){if(s._destroyed)return;if(e.done){s.push(null);return}s.push(new i(e.value));d()})}d()}else{s._xhr=e;s._pos=0;s.statusCode=e.status;s.statusMessage=e.statusText;var h=e.getAllResponseHeaders().split(/\r?\n/);h.forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();if(s.headers[r]!==undefined)s.headers[r]+=", "+t[2];else s.headers[r]=t[2];s.rawHeaders.push(t[1],t[2])}});s._charset="x-user-defined";if(!o.overrideMimeType){var p=s.rawHeaders["mime-type"];if(p){var m=p.match(/;\s*charset=([^;])(;|$)/);if(m){s._charset=m[1].toLowerCase()}}if(!s._charset)s._charset="utf-8"}}};s(u,a.Readable);u.prototype._read=function(){};u.prototype._onXHRProgress=function(){var e=this;var t=e._xhr;var r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==f.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(o){}if(r!==null){e.push(new i(r));break}case"text":try{r=t.responseText}catch(o){e._mode="text:vbarray";break}if(r.length>e._pos){var s=r.substr(e._pos);if(e._charset==="x-user-defined"){var a=new i(s.length);for(var u=0;u<s.length;u++)a[u]=s.charCodeAt(u)&255;e.push(a)}else{e.push(s,e._charset)}e._pos=r.length}break;case"arraybuffer":if(t.readyState!==f.DONE)break;r=t.response;e.push(new i(new Uint8Array(r)));break;case"moz-chunked-arraybuffer":r=t.response;if(t.readyState!==f.LOADING||!r)break;e.push(new i(new Uint8Array(r)));break;case"ms-stream":r=t.response;if(t.readyState!==f.LOADING)break;var c=new n.MSStreamReader;c.onprogress=function(){if(c.result.byteLength>e._pos){e.push(new i(new Uint8Array(c.result.slice(e._pos))));e._pos=c.result.byteLength}};c.onload=function(){e.push(null)};c.readAsArrayBuffer(r);break}if(e._xhr.readyState===f.DONE&&e._mode!=="ms-stream"){e.push(null)}}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./capability":54,_process:34,buffer:25,inherits:115,stream:52}],57:[function(e,t,r){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",
+207:"Multi-Status",300:"Multiple Choices",301:"Moved Permanently",302:"Moved Temporarily",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Large",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Unordered Collection",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Time-out",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],58:[function(e,t,r){var n=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(e.byteOffset===0&&e.byteLength===e.buffer.byteLength){return e.buffer}else if(typeof e.buffer.slice==="function"){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}}if(n.isBuffer(e)){var t=new Uint8Array(e.length);var r=e.length;for(var i=0;i<r;i++){t[i]=e[i]}return t.buffer}else{throw new Error("Argument must be a Buffer")}}},{buffer:25}],59:[function(e,t,r){var n=e("buffer").Buffer;var i=n.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return true;default:return false}};function o(e){if(e&&!i(e)){throw new Error("Unknown encoding: "+e)}}var s=r.StringDecoder=function(e){this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,"");o(e);switch(this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2;this.detectIncompleteChar=f;break;case"base64":this.surrogateSize=3;this.detectIncompleteChar=u;break;default:this.write=a;return}this.charBuffer=new n(6);this.charReceived=0;this.charLength=0};s.prototype.write=function(e){var t="";while(this.charLength){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;e.copy(this.charBuffer,this.charReceived,0,r);this.charReceived+=r;if(this.charReceived<this.charLength){return""}e=e.slice(r,e.length);t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var n=t.charCodeAt(t.length-1);if(n>=55296&&n<=56319){this.charLength+=this.surrogateSize;t="";continue}this.charReceived=this.charLength=0;if(e.length===0){return t}break}this.detectIncompleteChar(e);var i=e.length;if(this.charLength){e.copy(this.charBuffer,0,e.length-this.charReceived,i);i-=this.charReceived}t+=e.toString(this.encoding,0,i);var i=t.length-1;var n=t.charCodeAt(i);if(n>=55296&&n<=56319){var o=this.surrogateSize;this.charLength+=o;this.charReceived+=o;this.charBuffer.copy(this.charBuffer,o,0,o);e.copy(this.charBuffer,0,0,o);return t.substring(0,i)}return t};s.prototype.detectIncompleteChar=function(e){var t=e.length>=3?3:e.length;for(;t>0;t--){var r=e[e.length-t];if(t==1&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t};s.prototype.end=function(e){var t="";if(e&&e.length)t=this.write(e);if(this.charReceived){var r=this.charReceived;var n=this.charBuffer;var i=this.encoding;t+=n.slice(0,r).toString(i)}return t};function a(e){return e.toString(this.encoding)}function f(e){this.charReceived=e.length%2;this.charLength=this.charReceived?2:0}function u(e){this.charReceived=e.length%3;this.charLength=this.charReceived?3:0}},{buffer:25}],60:[function(e,t,r){"use strict";var n=e("punycode");var i=e("./util");r.parse=w;r.resolve=x;r.resolveObject=k;r.format=E;r.Url=o;function o(){this.protocol=null;this.slashes=null;this.auth=null;this.host=null;this.port=null;this.hostname=null;this.hash=null;this.search=null;this.query=null;this.pathname=null;this.path=null;this.href=null}var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,f=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["<",">",'"',"`"," ","\r","\n"," "],c=["{","}","|","\\","^","`"].concat(u),l=["'"].concat(c),d=["%","/","?",";","#"].concat(l),h=["/","?","#"],p=255,m=/^[+a-z0-9A-Z_-]{0,63}$/,v=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:true,"javascript:":true},y={javascript:true,"javascript:":true},_={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},b=e("querystring");function w(e,t,r){if(e&&i.isObject(e)&&e instanceof o)return e;var n=new o;n.parse(e,t,r);return n}o.prototype.parse=function(e,t,r){if(!i.isString(e)){throw new TypeError("Parameter 'url' must be a string, not "+typeof e)}var o=e.indexOf("?"),a=o!==-1&&o<e.indexOf("#")?"?":"#",u=e.split(a),c=/\\/g;u[0]=u[0].replace(c,"/");e=u.join(a);var w=e;w=w.trim();if(!r&&e.split("#").length===1){var E=f.exec(w);if(E){this.path=w;this.href=w;this.pathname=E[1];if(E[2]){this.search=E[2];if(t){this.query=b.parse(this.search.substr(1))}else{this.query=this.search.substr(1)}}else if(t){this.search="";this.query={}}return this}}var x=s.exec(w);if(x){x=x[0];var k=x.toLowerCase();this.protocol=k;w=w.substr(x.length)}if(r||x||w.match(/^\/\/[^@\/]+@[^@\/]+/)){var S=w.substr(0,2)==="//";if(S&&!(x&&y[x])){w=w.substr(2);this.slashes=true}}if(!y[x]&&(S||x&&!_[x])){var B=-1;for(var I=0;I<h.length;I++){var A=w.indexOf(h[I]);if(A!==-1&&(B===-1||A<B))B=A}var C,T;if(B===-1){T=w.lastIndexOf("@")}else{T=w.lastIndexOf("@",B)}if(T!==-1){C=w.slice(0,T);w=w.slice(T+1);this.auth=decodeURIComponent(C)}B=-1;for(var I=0;I<d.length;I++){var A=w.indexOf(d[I]);if(A!==-1&&(B===-1||A<B))B=A}if(B===-1)B=w.length;this.host=w.slice(0,B);w=w.slice(B);this.parseHost();this.hostname=this.hostname||"";var L=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!L){var R=this.hostname.split(/\./);for(var I=0,U=R.length;I<U;I++){var P=R[I];if(!P)continue;if(!P.match(m)){var j="";for(var O=0,M=P.length;O<M;O++){if(P.charCodeAt(O)>127){j+="x"}else{j+=P[O]}}if(!j.match(m)){var D=R.slice(0,I);var N=R.slice(I+1);var H=P.match(v);if(H){D.push(H[1]);N.unshift(H[2])}if(N.length){w="/"+N.join(".")+w}this.hostname=D.join(".");break}}}}if(this.hostname.length>p){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!L){this.hostname=n.toASCII(this.hostname)}var q=this.port?":"+this.port:"";var z=this.hostname||"";this.host=z+q;this.href+=this.host;if(L){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(w[0]!=="/"){w="/"+w}}}if(!g[k]){for(var I=0,U=l.length;I<U;I++){var W=l[I];if(w.indexOf(W)===-1)continue;var F=encodeURIComponent(W);if(F===W){F=escape(W)}w=w.split(W).join(F)}}var Y=w.indexOf("#");if(Y!==-1){this.hash=w.substr(Y);w=w.slice(0,Y)}var V=w.indexOf("?");if(V!==-1){this.search=w.substr(V);this.query=w.substr(V+1);if(t){this.query=b.parse(this.query)}w=w.slice(0,V)}else if(t){this.search="";this.query={}}if(w)this.pathname=w;if(_[k]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var q=this.pathname||"";var $=this.search||"";this.path=q+$}this.href=this.format();return this};function E(e){if(i.isString(e))e=w(e);if(!(e instanceof o))return o.prototype.format.call(e);return e.format()}o.prototype.format=function(){var e=this.auth||"";if(e){e=encodeURIComponent(e);e=e.replace(/%3A/i,":");e+="@"}var t=this.protocol||"",r=this.pathname||"",n=this.hash||"",o=false,s="";if(this.host){o=e+this.host}else if(this.hostname){o=e+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]");if(this.port){o+=":"+this.port}}if(this.query&&i.isObject(this.query)&&Object.keys(this.query).length){s=b.stringify(this.query)}var a=this.search||s&&"?"+s||"";if(t&&t.substr(-1)!==":")t+=":";if(this.slashes||(!t||_[t])&&o!==false){o="//"+(o||"");if(r&&r.charAt(0)!=="/")r="/"+r}else if(!o){o=""}if(n&&n.charAt(0)!=="#")n="#"+n;if(a&&a.charAt(0)!=="?")a="?"+a;r=r.replace(/[?#]/g,function(e){return encodeURIComponent(e)});a=a.replace("#","%23");return t+o+r+a+n};function x(e,t){return w(e,false,true).resolve(t)}o.prototype.resolve=function(e){return this.resolveObject(w(e,false,true)).format()};function k(e,t){if(!e)return t;return w(e,false,true).resolveObject(t)}o.prototype.resolveObject=function(e){if(i.isString(e)){var t=new o;t.parse(e,false,true);e=t}var r=new o;var n=Object.keys(this);for(var s=0;s<n.length;s++){var a=n[s];r[a]=this[a]}r.hash=e.hash;if(e.href===""){r.href=r.format();return r}if(e.slashes&&!e.protocol){var f=Object.keys(e);for(var u=0;u<f.length;u++){var c=f[u];if(c!=="protocol")r[c]=e[c]}if(_[r.protocol]&&r.hostname&&!r.pathname){r.path=r.pathname="/"}r.href=r.format();return r}if(e.protocol&&e.protocol!==r.protocol){if(!_[e.protocol]){var l=Object.keys(e);for(var d=0;d<l.length;d++){var h=l[d];r[h]=e[h]}r.href=r.format();return r}r.protocol=e.protocol;if(!e.host&&!y[e.protocol]){var p=(e.pathname||"").split("/");while(p.length&&!(e.host=p.shift()));if(!e.host)e.host="";if(!e.hostname)e.hostname="";if(p[0]!=="")p.unshift("");if(p.length<2)p.unshift("");r.pathname=p.join("/")}else{r.pathname=e.pathname}r.search=e.search;r.query=e.query;r.host=e.host||"";r.auth=e.auth;r.hostname=e.hostname||e.host;r.port=e.port;if(r.pathname||r.search){var m=r.pathname||"";var v=r.search||"";r.path=m+v}r.slashes=r.slashes||e.slashes;r.href=r.format();return r}var g=r.pathname&&r.pathname.charAt(0)==="/",b=e.host||e.pathname&&e.pathname.charAt(0)==="/",w=b||g||r.host&&e.pathname,E=w,x=r.pathname&&r.pathname.split("/")||[],p=e.pathname&&e.pathname.split("/")||[],k=r.protocol&&!_[r.protocol];if(k){r.hostname="";r.port=null;if(r.host){if(x[0]==="")x[0]=r.host;else x.unshift(r.host)}r.host="";if(e.protocol){e.hostname=null;e.port=null;if(e.host){if(p[0]==="")p[0]=e.host;else p.unshift(e.host)}e.host=null}w=w&&(p[0]===""||x[0]==="")}if(b){r.host=e.host||e.host===""?e.host:r.host;r.hostname=e.hostname||e.hostname===""?e.hostname:r.hostname;r.search=e.search;r.query=e.query;x=p}else if(p.length){if(!x)x=[];x.pop();x=x.concat(p);r.search=e.search;r.query=e.query}else if(!i.isNullOrUndefined(e.search)){if(k){r.hostname=r.host=x.shift();var S=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(S){r.auth=S.shift();r.host=r.hostname=S.shift()}}r.search=e.search;r.query=e.query;if(!i.isNull(r.pathname)||!i.isNull(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.href=r.format();return r}if(!x.length){r.pathname=null;if(r.search){r.path="/"+r.search}else{r.path=null}r.href=r.format();return r}var B=x.slice(-1)[0];var I=(r.host||e.host||x.length>1)&&(B==="."||B==="..")||B==="";var A=0;for(var C=x.length;C>=0;C--){B=x[C];if(B==="."){x.splice(C,1)}else if(B===".."){x.splice(C,1);A++}else if(A){x.splice(C,1);A--}}if(!w&&!E){for(;A--;A){x.unshift("..")}}if(w&&x[0]!==""&&(!x[0]||x[0].charAt(0)!=="/")){x.unshift("")}if(I&&x.join("/").substr(-1)!=="/"){x.push("")}var T=x[0]===""||x[0]&&x[0].charAt(0)==="/";if(k){r.hostname=r.host=T?"":x.length?x.shift():"";var S=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(S){r.auth=S.shift();r.host=r.hostname=S.shift()}}w=w||r.host&&x.length;if(w&&!T){x.unshift("")}if(!x.length){r.pathname=null;r.path=null}else{r.pathname=x.join("/")}if(!i.isNull(r.pathname)||!i.isNull(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.auth=e.auth||r.auth;r.slashes=r.slashes||e.slashes;r.href=r.format();return r};o.prototype.parseHost=function(){var e=this.host;var t=a.exec(e);if(t){t=t[0];if(t!==":"){this.port=t.substr(1)}e=e.substr(0,e.length-t.length)}if(e)this.hostname=e}},{"./util":61,punycode:35,querystring:38}],61:[function(e,t,r){"use strict";t.exports={isString:function(e){return typeof e==="string"},isObject:function(e){return typeof e==="object"&&e!==null},isNull:function(e){return e===null},isNullOrUndefined:function(e){return e==null}}},{}],62:[function(e,t,r){t.exports=function n(e){return e&&typeof e==="object"&&typeof e.copy==="function"&&typeof e.fill==="function"&&typeof e.readUInt8==="function"}},{}],63:[function(e,t,r){(function(t,n){var i=/%[sdj%]/g;r.format=function(e){if(!E(e)){var t=[];for(var r=0;r<arguments.length;r++){t.push(a(arguments[r]))}return t.join(" ")}var r=1;var n=arguments;var o=n.length;var s=String(e).replace(i,function(e){if(e==="%%")return"%";if(r>=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return e}});for(var f=n[r];r<o;f=n[++r]){if(_(f)||!B(f)){s+=" "+f}else{s+=" "+a(f)}}return s};r.deprecate=function(e,i){if(k(n.process)){return function(){return r.deprecate(e,i).apply(this,arguments)}}if(t.noDeprecation===true){return e}var o=false;function s(){if(!o){if(t.throwDeprecation){throw new Error(i)}else if(t.traceDeprecation){console.trace(i)}else{console.error(i)}o=true}return e.apply(this,arguments)}return s};var o={};var s;r.debuglog=function(e){if(k(s))s=t.env.NODE_DEBUG||"";e=e.toUpperCase();if(!o[e]){if(new RegExp("\\b"+e+"\\b","i").test(s)){var n=t.pid;o[e]=function(){var t=r.format.apply(r,arguments);console.error("%s %d: %s",e,n,t)}}else{o[e]=function(){}}}return o[e]};function a(e,t){var n={seen:[],stylize:u};if(arguments.length>=3)n.depth=arguments[2];if(arguments.length>=4)n.colors=arguments[3];if(y(t)){n.showHidden=t}else if(t){r._extend(n,t)}if(k(n.showHidden))n.showHidden=false;if(k(n.depth))n.depth=2;if(k(n.colors))n.colors=false;if(k(n.customInspect))n.customInspect=true;if(n.colors)n.stylize=f;return l(n,e,n.depth)}r.inspect=a;a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]};a.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"};function f(e,t){var r=a.styles[t];if(r){return"["+a.colors[r][0]+"m"+e+"["+a.colors[r][1]+"m"}else{return e}}function u(e,t){return e}function c(e){var t={};e.forEach(function(e,r){t[e]=true});return t}function l(e,t,n){if(e.customInspect&&t&&C(t.inspect)&&t.inspect!==r.inspect&&!(t.constructor&&t.constructor.prototype===t)){var i=t.inspect(n,e);if(!E(i)){i=l(e,i,n)}return i}var o=d(e,t);if(o){return o}var s=Object.keys(t);var a=c(s);if(e.showHidden){s=Object.getOwnPropertyNames(t)}if(A(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0)){return h(t)}if(s.length===0){if(C(t)){var f=t.name?": "+t.name:"";return e.stylize("[Function"+f+"]","special")}if(S(t)){return e.stylize(RegExp.prototype.toString.call(t),"regexp")}if(I(t)){return e.stylize(Date.prototype.toString.call(t),"date")}if(A(t)){return h(t)}}var u="",y=false,_=["{","}"];if(g(t)){y=true;_=["[","]"]}if(C(t)){var b=t.name?": "+t.name:"";u=" [Function"+b+"]"}if(S(t)){u=" "+RegExp.prototype.toString.call(t)}if(I(t)){u=" "+Date.prototype.toUTCString.call(t)}if(A(t)){u=" "+h(t)}if(s.length===0&&(!y||t.length==0)){return _[0]+u+_[1]}if(n<0){if(S(t)){return e.stylize(RegExp.prototype.toString.call(t),"regexp")}else{return e.stylize("[Object]","special")}}e.seen.push(t);var w;if(y){w=p(e,t,n,a,s)}else{w=s.map(function(r){return m(e,t,n,a,r,y)})}e.seen.pop();return v(w,u,_)}function d(e,t){if(k(t))return e.stylize("undefined","undefined");if(E(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(w(t))return e.stylize(""+t,"number");if(y(t))return e.stylize(""+t,"boolean");if(_(t))return e.stylize("null","null")}function h(e){return"["+Error.prototype.toString.call(e)+"]"}function p(e,t,r,n,i){var o=[];for(var s=0,a=t.length;s<a;++s){if(j(t,String(s))){o.push(m(e,t,r,n,String(s),true))}else{o.push("")}}i.forEach(function(i){if(!i.match(/^\d+$/)){o.push(m(e,t,r,n,i,true))}});return o}function m(e,t,r,n,i,o){var s,a,f;f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]};if(f.get){if(f.set){a=e.stylize("[Getter/Setter]","special")}else{a=e.stylize("[Getter]","special")}}else{if(f.set){a=e.stylize("[Setter]","special")}}if(!j(n,i)){s="["+i+"]"}if(!a){if(e.seen.indexOf(f.value)<0){if(_(r)){a=l(e,f.value,null)}else{a=l(e,f.value,r-1)}if(a.indexOf("\n")>-1){if(o){a=a.split("\n").map(function(e){return" "+e}).join("\n").substr(2)}else{a="\n"+a.split("\n").map(function(e){return" "+e}).join("\n")}}}else{a=e.stylize("[Circular]","special")}}if(k(s)){if(o&&i.match(/^\d+$/)){return a}s=JSON.stringify(""+i);if(s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)){s=s.substr(1,s.length-2);s=e.stylize(s,"name")}else{s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'");s=e.stylize(s,"string")}}return s+": "+a}function v(e,t,r){var n=0;var i=e.reduce(function(e,t){n++;if(t.indexOf("\n")>=0)n++;return e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);if(i>60){return r[0]+(t===""?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]}return r[0]+t+" "+e.join(", ")+" "+r[1]}function g(e){return Array.isArray(e)}r.isArray=g;function y(e){return typeof e==="boolean"}r.isBoolean=y;function _(e){return e===null}r.isNull=_;function b(e){return e==null}r.isNullOrUndefined=b;function w(e){return typeof e==="number"}r.isNumber=w;function E(e){return typeof e==="string"}r.isString=E;function x(e){return typeof e==="symbol"}r.isSymbol=x;function k(e){return e===void 0}r.isUndefined=k;function S(e){return B(e)&&L(e)==="[object RegExp]"}r.isRegExp=S;function B(e){return typeof e==="object"&&e!==null}r.isObject=B;function I(e){return B(e)&&L(e)==="[object Date]"}r.isDate=I;function A(e){return B(e)&&(L(e)==="[object Error]"||e instanceof Error)}r.isError=A;function C(e){return typeof e==="function"}r.isFunction=C;function T(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=T;r.isBuffer=e("./support/isBuffer");function L(e){return Object.prototype.toString.call(e)}function R(e){return e<10?"0"+e.toString(10):e.toString(10)}var U=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date;var t=[R(e.getHours()),R(e.getMinutes()),R(e.getSeconds())].join(":");return[e.getDate(),U[e.getMonth()],t].join(" ")}r.log=function(){console.log("%s - %s",P(),r.format.apply(r,arguments))};r.inherits=e("inherits");r._extend=function(e,t){if(!t||!B(t))return e;var r=Object.keys(t);var n=r.length;while(n--){e[r[n]]=t[r[n]]}return e};function j(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./support/isBuffer":62,_process:34,inherits:115}],64:[function(e,t,r){(function(r){var n=e("inherits");var i=e("readable-stream").Transform;var o=e("defined");t.exports=s;n(s,i);function s(e,t){if(!(this instanceof s))return new s(e,t);i.call(this);if(!t)t={};if(typeof e==="object"){t=e;e=t.size}this.size=e||512;if(t.nopad)this._zeroPadding=false;else this._zeroPadding=o(t.zeroPadding,true);this._buffered=[];this._bufferedBytes=0}s.prototype._transform=function(e,t,n){this._bufferedBytes+=e.length;this._buffered.push(e);while(this._bufferedBytes>=this.size){var i=r.concat(this._buffered);this._bufferedBytes-=this.size;this.push(i.slice(0,this.size));this._buffered=[i.slice(this.size,i.length)]}n()};s.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new r(this.size-this._bufferedBytes);e.fill(0);this._buffered.push(e);this.push(r.concat(this._buffered));this._buffered=null}else if(this._bufferedBytes){this.push(r.concat(this._buffered));this._buffered=null}this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:25,defined:65,inherits:115,"readable-stream":76}],65:[function(e,t,r){t.exports=function(){for(var e=0;e<arguments.length;e++){if(arguments[e]!==undefined)return arguments[e]}}},{}],66:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{"./_stream_readable":68,"./_stream_writable":70,"core-util-is":71,dup:40,inherits:115,"process-nextick-args":73}],67:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{"./_stream_transform":69,"core-util-is":71,dup:41,inherits:115}],68:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{"./_stream_duplex":66,_process:34,buffer:25,"core-util-is":71,dup:42,events:29,inherits:115,isarray:72,"process-nextick-args":73,"string_decoder/":74,util:24}],69:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{"./_stream_duplex":66,"core-util-is":71,dup:43,inherits:115}],70:[function(e,t,r){arguments[4][44][0].apply(r,arguments)},{"./_stream_duplex":66,buffer:25,"core-util-is":71,dup:44,events:29,inherits:115,"process-nextick-args":73,"util-deprecate":75}],71:[function(e,t,r){(function(e){function t(e){if(Array.isArray){return Array.isArray(e)}return v(e)==="[object Array]"}r.isArray=t;function n(e){return typeof e==="boolean"}r.isBoolean=n;function i(e){return e===null}r.isNull=i;function o(e){return e==null}r.isNullOrUndefined=o;function s(e){return typeof e==="number"}r.isNumber=s;function a(e){return typeof e==="string"}r.isString=a;function f(e){return typeof e==="symbol"}r.isSymbol=f;function u(e){return e===void 0}r.isUndefined=u;function c(e){return v(e)==="[object RegExp]"}r.isRegExp=c;function l(e){return typeof e==="object"&&e!==null}r.isObject=l;function d(e){return v(e)==="[object Date]"}r.isDate=d;function h(e){return v(e)==="[object Error]"||e instanceof Error}r.isError=h;function p(e){return typeof e==="function"}r.isFunction=p;function m(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=m;r.isBuffer=e.isBuffer;function v(e){return Object.prototype.toString.call(e)}}).call(this,{isBuffer:e("../../../../../../../../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js")})},{"../../../../../../../../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js":31}],72:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],73:[function(e,t,r){arguments[4][46][0].apply(r,arguments)},{_process:34,dup:46}],74:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{buffer:25,dup:59}],75:[function(e,t,r){arguments[4][47][0].apply(r,arguments)},{dup:47}],76:[function(e,t,r){arguments[4][49][0].apply(r,arguments)},{"./lib/_stream_duplex.js":66,"./lib/_stream_passthrough.js":67,"./lib/_stream_readable.js":68,"./lib/_stream_transform.js":69,"./lib/_stream_writable.js":70,dup:49}],77:[function(e,t,r){t.exports=s;var n=e("block-stream2");var i=e("inherits");var o=e("stream");i(s,o.Writable);function s(e,t,r){var i=this;if(!(i instanceof s)){return new s(e,t,r)}o.Writable.call(i,r);if(!r)r={};if(!e||!e.put||!e.get){throw new Error("First argument must be an abstract-chunk-store compliant store")}t=Number(t);if(!t)throw new Error("Second argument must be a chunk length");i._blockstream=new n(t,{zeroPadding:false});i._blockstream.on("data",f).on("error",function(e){i.destroy(e)});var a=0;function f(t){if(i.destroyed)return;e.put(a,t);a+=1}i.on("finish",function(){this._blockstream.end()})}s.prototype._write=function(e,t,r){this._blockstream.write(e,t,r)};s.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;if(e)this.emit("error",e);this.emit("close")}},{"block-stream2":64,inherits:115,stream:52}],78:[function(e,t,r){t.exports=function n(){var e=navigator.hardwareConcurrency||1;var n=[];for(var t=0;t<e;t++){n.push({model:"",speed:0,times:{user:0,nice:0,sys:0,idle:0,irq:0}})}return n}},{}],79:[function(e,t,r){(function(r,n,i){t.exports=b;t.exports.parseInput=w;t.exports.announceList=[["udp://tracker.openbittorrent.com:80"],["udp://tracker.internetwarriors.net:1337"],["udp://tracker.leechers-paradise.org:6969"],["udp://tracker.coppersurfer.tk:6969"],["udp://exodus.desync.com:6969"],["wss://tracker.webtorrent.io"],["wss://tracker.btorrent.xyz"]];var o=e("bencode");var s=e("block-stream2");var a=e("piece-length");var f=e("path");var u=e("xtend");var c=e("filestream/read");var l=e("flatten");var d=e("fs");var h=e("is-file");var p=e("junk");var m=e("multistream");var v=e("once");var g=e("run-parallel");var y=e("simple-sha1");var _=e("stream");function b(e,t,r){if(typeof t==="function")return b(e,null,t);t=t?u(t):{};E(e,t,function(e,n,i){if(e)return r(e);t.singleFileTorrent=i;A(n,t,r)})}function w(e,t,r){if(typeof t==="function")return w(e,null,t);t=t?u(t):{};E(e,t,r)}function E(e,t,n){if(Array.isArray(e)&&e.length===0)throw new Error("invalid input type");if(L(e))e=Array.prototype.slice.call(e);if(!Array.isArray(e))e=[e];e=e.map(function(e){if(T(e)&&typeof e.path==="string")return e.path;return e});if(e.length===1&&typeof e[0]!=="string"&&!e[0].name)e[0].name=t.name;var o=null;e.forEach(function(t,r){if(typeof t==="string")return;var n=t.fullPath||t.name;if(!n)throw new Error("missing required `fullPath` or `name` property on input");t.path=n.split("/");if(!t.path[0])t.path.shift();if(t.path.length<2){o=null}else if(r===0&&e.length>1){o=t.path[0]}else if(t.path[0]!==o){o=null}});e=e.filter(function(e){if(typeof e==="string")return true;var t=e.path[e.path.length-1];return B(t)&&p.not(t)});if(o){e.forEach(function(e){if(typeof e==="string")return;e.path.shift()})}if(!t.name&&o)t.name=o;if(!t.name&&e[0]&&e[0].name)t.name=e[0].name;if(!t.name&&typeof e[0]==="string")t.name=f.basename(e[0]);if(t.name===undefined){throw new Error("missing option 'name' and unable to infer it from input[0].name")}var s=e.reduce(function(e,t){return e+Number(typeof t==="string")},0);var a=e.length===1;if(e.length===1&&typeof e[0]==="string"){if(typeof d.stat!=="function"){throw new Error("filesystem paths do not work in the browser")}h(e[0],function(e,t){if(e)return n(e);a=t;u()})}else{r.nextTick(function(){u()})}function u(){g(e.map(function(e){return function(r){var n={};if(T(e)){n.getStream=U(e);n.length=e.size}else if(i.isBuffer(e)){n.getStream=P(e);n.length=e.length}else if(R(e)){if(!t.pieceLength){throw new Error("must specify `pieceLength` option if input is Stream")}n.getStream=O(e,n);n.length=0}else if(typeof e==="string"){if(typeof d.stat!=="function"){throw new Error("filesystem paths do not work in the browser")}var o=s>1||a;x(e,o,r);return}else{throw new Error("invalid input type")}n.path=e.path;r(null,n)}}),function(e,t){if(e)return n(e);t=l(t);n(null,t,a)})}}function x(e,t,r){S(e,k,function(n,i){if(n)return r(n);if(Array.isArray(i))i=l(i);else i=[i];e=f.normalize(e);if(t){e=e.slice(0,e.lastIndexOf(f.sep)+1)}if(e[e.length-1]!==f.sep)e+=f.sep;i.forEach(function(t){t.getStream=j(t.path);t.path=t.path.replace(e,"").split(f.sep)});r(null,i)})}function k(e,t){t=v(t);d.stat(e,function(r,n){if(r)return t(r);var i={length:n.size,path:e};t(null,i)})}function S(e,t,r){d.readdir(e,function(n,i){if(n&&n.code==="ENOTDIR"){t(e,r)}else if(n){r(n)}else{g(i.filter(B).filter(p.not).map(function(r){return function(n){S(f.join(e,r),t,n)}}),r)}})}function B(e){return e[0]!=="."}function I(e,t,r){r=v(r);var n=[];var o=0;var a=e.map(function(e){return e.getStream});var f=0;var u=0;var c=false;var l=new m(a);var d=new s(t,{zeroPadding:false});l.on("error",g);l.pipe(d).on("data",h).on("end",p).on("error",g);function h(e){o+=e.length;var t=u;y(e,function(e){n[t]=e;f-=1;b()});f+=1;u+=1}function p(){c=true;b()}function g(e){_();r(e)}function _(){l.removeListener("error",g);d.removeListener("data",h);d.removeListener("end",p);d.removeListener("error",g)}function b(){if(c&&f===0){_();r(null,new i(n.join(""),"hex"),o)}}}function A(e,r,i){var s=r.announceList;if(!s){if(typeof r.announce==="string")s=[[r.announce]];else if(Array.isArray(r.announce)){s=r.announce.map(function(e){return[e]})}}if(!s)s=[];if(n.WEBTORRENT_ANNOUNCE){if(typeof n.WEBTORRENT_ANNOUNCE==="string"){s.push([[n.WEBTORRENT_ANNOUNCE]])}else if(Array.isArray(n.WEBTORRENT_ANNOUNCE)){s=s.concat(n.WEBTORRENT_ANNOUNCE.map(function(e){return[e]}))}}if(r.announce===undefined&&r.announceList===undefined){s=s.concat(t.exports.announceList)}if(typeof r.urlList==="string")r.urlList=[r.urlList];var f={info:{name:r.name},"creation date":Number(r.creationDate)||Date.now(),encoding:"UTF-8"};if(s.length!==0){f.announce=s[0][0];f["announce-list"]=s}if(r.comment!==undefined)f.comment=r.comment;if(r.createdBy!==undefined)f["created by"]=r.createdBy;if(r.private!==undefined)f.info.private=Number(r.private);if(r.sslCert!==undefined)f.info["ssl-cert"]=r.sslCert;if(r.urlList!==undefined)f["url-list"]=r.urlList;var u=r.pieceLength||a(e.reduce(C,0));f.info["piece length"]=u;I(e,u,function(t,n,s){if(t)return i(t);f.info.pieces=n;e.forEach(function(e){delete e.getStream});if(r.singleFileTorrent){f.info.length=s}else{f.info.files=e}i(null,o.encode(f))})}function C(e,t){return e+t.length}function T(e){return typeof Blob!=="undefined"&&e instanceof Blob}function L(e){return typeof FileList==="function"&&e instanceof FileList}function R(e){return typeof e==="object"&&e!=null&&typeof e.pipe==="function"}function U(e){return function(){return new c(e)}}function P(e){return function(){var t=new _.PassThrough;t.end(e);return t}}function j(e){return function(){return d.createReadStream(e)}}function O(e,t){return function(){var r=new _.Transform;r._transform=function(e,r,n){t.length+=e.length;this.push(e);n()};e.pipe(r);return r}}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{_process:34,bencode:80,"block-stream2":84,buffer:25,"filestream/read":99,flatten:100,fs:23,"is-file":101,junk:102,multistream:117,once:104,path:33,"piece-length":105,"run-parallel":184,"simple-sha1":193,stream:52,xtend:210}],80:[function(e,t,r){arguments[4][11][0].apply(r,arguments)},{"./lib/decode":81,"./lib/encode":83,dup:11}],81:[function(e,t,r){arguments[4][12][0].apply(r,arguments)},{"./dict":82,buffer:25,dup:12}],82:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{dup:13}],83:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{buffer:25,dup:14}],84:[function(e,t,r){arguments[4][64][0].apply(r,arguments)},{buffer:25,defined:85,dup:64,inherits:115,"readable-stream":96}],85:[function(e,t,r){arguments[4][65][0].apply(r,arguments)},{dup:65}],86:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{"./_stream_readable":88,"./_stream_writable":90,"core-util-is":91,dup:40,inherits:115,"process-nextick-args":93}],87:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{"./_stream_transform":89,"core-util-is":91,dup:41,inherits:115}],88:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{"./_stream_duplex":86,_process:34,buffer:25,"core-util-is":91,dup:42,events:29,inherits:115,isarray:92,"process-nextick-args":93,"string_decoder/":94,util:24}],89:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{"./_stream_duplex":86,"core-util-is":91,dup:43,inherits:115}],90:[function(e,t,r){arguments[4][44][0].apply(r,arguments)},{"./_stream_duplex":86,buffer:25,"core-util-is":91,dup:44,events:29,inherits:115,"process-nextick-args":93,"util-deprecate":95}],91:[function(e,t,r){arguments[4][71][0].apply(r,arguments)},{"../../../../../../../../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js":31,dup:71}],92:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],93:[function(e,t,r){arguments[4][46][0].apply(r,arguments)},{_process:34,dup:46}],94:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{buffer:25,dup:59}],95:[function(e,t,r){arguments[4][47][0].apply(r,arguments)},{dup:47}],96:[function(e,t,r){arguments[4][49][0].apply(r,arguments)},{"./lib/_stream_duplex.js":86,"./lib/_stream_passthrough.js":87,"./lib/_stream_readable.js":88,"./lib/_stream_transform.js":89,"./lib/_stream_writable.js":90,dup:49}],97:[function(e,t,r){
+(function(r){var n=e("is-typedarray").strict;t.exports=function i(e){if(n(e)){var t=new r(e.buffer);if(e.byteLength!==e.buffer.byteLength){t=t.slice(e.byteOffset,e.byteOffset+e.byteLength)}return t}else{return new r(e)}}}).call(this,e("buffer").Buffer)},{buffer:25,"is-typedarray":98}],98:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],99:[function(e,t,r){var n=e("stream").Readable;var i=e("inherits");var o=/^.*\.(\w+)$/;var s=e("typedarray-to-buffer");function a(e,t){var r=this;if(!(this instanceof a)){return new a(e,t)}t=t||{};n.call(this,t);this._offset=0;this._ready=false;this._file=e;this._size=e.size;this._chunkSize=t.chunkSize||Math.max(this._size/1e3,200*1024);this.reader=new FileReader;this._generateHeaderBlocks(e,t,function(e,t){if(e){return r.emit("error",e)}if(Array.isArray(t)){t.forEach(function(e){r.push(e)})}r._ready=true;r.emit("_ready")})}i(a,n);t.exports=a;a.prototype._generateHeaderBlocks=function(e,t,r){r(null,[])};a.prototype._read=function(){if(!this._ready){this.once("_ready",this._read.bind(this));return}var e=this;var t=this.reader;var r=this._offset;var n=this._offset+this._chunkSize;if(n>this._size)n=this._size;if(r===this._size){this.destroy();this.push(null);return}t.onload=function(){e._offset=n;e.push(s(t.result))};t.onerror=function(){e.emit("error",t.error)};t.readAsArrayBuffer(this._file.slice(r,n))};a.prototype.destroy=function(){this._file=null;if(this.reader){this.reader.onload=null;this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},{inherits:115,stream:52,"typedarray-to-buffer":97}],100:[function(e,t,r){t.exports=function n(e,t){t=typeof t=="number"?t:Infinity;return r(e,1);function r(e,n){return e.reduce(function(e,i){if(Array.isArray(i)&&n<t){return e.concat(r(i,n+1))}else{return e.concat(i)}},[])}}},{}],101:[function(e,t,r){"use strict";var n=e("fs");t.exports=function o(e,t){if(!t)return i(e);n.stat(e,function(e,r){if(e)return t(e);return t(null,r.isFile())})};t.exports.sync=i;function i(e){return n.existsSync(e)&&n.statSync(e).isFile()}},{fs:23}],102:[function(e,t,r){"use strict";r.re=/^npm-debug\.log$|^\..*\.swp$|^\.DS_Store$|^\.AppleDouble$|^\.LSOverride$|^Icon[\r\?]?|^\._.*|^\.Spotlight-V100$|\.Trashes|^__MACOSX$|~$|^Thumbs\.db$|^ehthumbs\.db$|^Desktop\.ini$/;r.is=function(e){return r.re.test(e)};r.not=r.isnt=function(e){return!r.is(e)}},{}],103:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],104:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,wrappy:103}],105:[function(e,t,r){var n=e("closest-to");var i=[];for(var o=14;o<=22;o++){i.push(Math.pow(2,o))}t.exports=function(e){return n(e/Math.pow(2,10),i)}},{"closest-to":106}],106:[function(e,t,r){t.exports=function(e,t){var r=Infinity;var n=0;var i=null;t.sort(function(e,t){return e-t});for(var o=0,s=t.length;o<s;o++){n=Math.abs(e-t[o]);if(n>=r){break}r=n;i=t[o]}return i}},{}],107:[function(e,t,r){r=t.exports=e("./debug");r.log=o;r.formatArgs=i;r.save=s;r.load=a;r.useColors=n;r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:f();r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function n(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}r.formatters.j=function(e){return JSON.stringify(e)};function i(){var e=arguments;var t=this.useColors;e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+r.humanize(this.diff);if(!t)return e;var n="color: "+this.color;e=[e[0],n,"color: inherit"].concat(Array.prototype.slice.call(e,1));var i=0;var o=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;i++;if("%c"===e){o=i}});e.splice(o,0,n);return e}function o(){return"object"===typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{if(null==e){r.storage.removeItem("debug")}else{r.storage.debug=e}}catch(t){}}function a(){var e;try{e=r.storage.debug}catch(t){}return e}r.enable(a());function f(){try{return window.localStorage}catch(e){}}},{"./debug":108}],108:[function(e,t,r){r=t.exports=s;r.coerce=c;r.disable=f;r.enable=a;r.enabled=u;r.humanize=e("ms");r.names=[];r.skips=[];r.formatters={};var n=0;var i;function o(){return r.colors[n++%r.colors.length]}function s(e){function t(){}t.enabled=false;function n(){var e=n;var t=+new Date;var s=t-(i||t);e.diff=s;e.prev=i;e.curr=t;i=t;if(null==e.useColors)e.useColors=r.useColors();if(null==e.color&&e.useColors)e.color=o();var a=Array.prototype.slice.call(arguments);a[0]=r.coerce(a[0]);if("string"!==typeof a[0]){a=["%o"].concat(a)}var f=0;a[0]=a[0].replace(/%([a-z%])/g,function(t,n){if(t==="%%")return t;f++;var i=r.formatters[n];if("function"===typeof i){var o=a[f];t=i.call(e,o);a.splice(f,1);f--}return t});if("function"===typeof r.formatArgs){a=r.formatArgs.apply(e,a)}var u=n.log||r.log||console.log.bind(console);u.apply(e,a)}n.enabled=true;var s=r.enabled(e)?n:t;s.namespace=e;return s}function a(e){r.save(e);var t=(e||"").split(/[\s,]+/);var n=t.length;for(var i=0;i<n;i++){if(!t[i])continue;e=t[i].replace(/\*/g,".*?");if(e[0]==="-"){r.skips.push(new RegExp("^"+e.substr(1)+"$"))}else{r.names.push(new RegExp("^"+e+"$"))}}}function f(){r.enable("")}function u(e){var t,n;for(t=0,n=r.skips.length;t<n;t++){if(r.skips[t].test(e)){return false}}for(t=0,n=r.names.length;t<n;t++){if(r.names[t].test(e)){return true}}return false}function c(e){if(e instanceof Error)return e.stack||e.message;return e}},{ms:109}],109:[function(e,t,r){var n=1e3;var i=n*60;var o=i*60;var s=o*24;var a=s*365.25;t.exports=function(e,t){t=t||{};if("string"==typeof e)return f(e);return t.long?c(e):u(e)};function f(e){e=""+e;if(e.length>1e4)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var r=parseFloat(t[1]);var f=(t[2]||"ms").toLowerCase();switch(f){case"years":case"year":case"yrs":case"yr":case"y":return r*a;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*o;case"minutes":case"minute":case"mins":case"min":case"m":return r*i;case"seconds":case"second":case"secs":case"sec":case"s":return r*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r}}function u(e){if(e>=s)return Math.round(e/s)+"d";if(e>=o)return Math.round(e/o)+"h";if(e>=i)return Math.round(e/i)+"m";if(e>=n)return Math.round(e/n)+"s";return e+"ms"}function c(e){return l(e,s,"day")||l(e,o,"hour")||l(e,i,"minute")||l(e,n,"second")||e+" ms"}function l(e,t,r){if(e<t)return;if(e<t*1.5)return Math.floor(e/t)+" "+r;return Math.ceil(e/t)+" "+r+"s"}},{}],110:[function(e,t,r){var n=e("once");var i=function(){};var o=function(e){return e.setHeader&&typeof e.abort==="function"};var s=function(e){return e.stdio&&Array.isArray(e.stdio)&&e.stdio.length===3};var a=function(e,t,r){if(typeof t==="function")return a(e,null,t);if(!t)t={};r=n(r||i);var f=e._writableState;var u=e._readableState;var c=t.readable||t.readable!==false&&e.readable;var l=t.writable||t.writable!==false&&e.writable;var d=function(){if(!e.writable)h()};var h=function(){l=false;if(!c)r()};var p=function(){c=false;if(!l)r()};var m=function(e){r(e?new Error("exited with error code: "+e):null)};var v=function(){if(c&&!(u&&u.ended))return r(new Error("premature close"));if(l&&!(f&&f.ended))return r(new Error("premature close"))};var g=function(){e.req.on("finish",h)};if(o(e)){e.on("complete",h);e.on("abort",v);if(e.req)g();else e.on("request",g)}else if(l&&!f){e.on("end",d);e.on("close",d)}if(s(e))e.on("exit",m);e.on("end",p);e.on("finish",h);if(t.error!==false)e.on("error",r);e.on("close",v);return function(){e.removeListener("complete",h);e.removeListener("abort",v);e.removeListener("request",g);if(e.req)e.req.removeListener("finish",h);e.removeListener("end",d);e.removeListener("close",d);e.removeListener("finish",h);e.removeListener("exit",m);e.removeListener("end",p);e.removeListener("error",r);e.removeListener("close",v)}};t.exports=a},{once:112}],111:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],112:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,wrappy:111}],113:[function(e,t,r){var n=t.exports=function(e,t){if(!t)t=16;if(e===undefined)e=128;if(e<=0)return"0";var r=Math.log(Math.pow(2,e))/Math.log(t);for(var i=2;r===Infinity;i*=2){r=Math.log(Math.pow(2,e/i))/Math.log(t)*i}var o=r-Math.floor(r);var s="";for(var i=0;i<Math.floor(r);i++){var a=Math.floor(Math.random()*t).toString(t);s=a+s}if(o){var f=Math.pow(t,o);var a=Math.floor(Math.random()*f).toString(t);s=a+s}var u=parseInt(s,t);if(u!==Infinity&&u>=Math.pow(2,e)){return n(e,t)}else return s};n.rack=function(e,t,r){var i=function(i){var s=0;do{if(s++>10){if(r)e+=r;else throw new Error("too many ID collisions, use more bits")}var a=n(e,t)}while(Object.hasOwnProperty.call(o,a));o[a]=i;return a};var o=i.hats={};i.get=function(e){return i.hats[e]};i.set=function(e,t){i.hats[e]=t;return i};i.bits=e||128;i.base=t||16;return i}},{}],114:[function(e,t,r){(function(e){t.exports=r;function r(e){if(!(this instanceof r))return new r(e);this.store=e;if(!this.store||!this.store.get||!this.store.put){throw new Error("First argument must be abstract-chunk-store compliant")}this.mem=[]}r.prototype.put=function(e,t,r){var n=this;n.mem[e]=t;n.store.put(e,t,function(t){n.mem[e]=null;if(r)r(t)})};r.prototype.get=function(e,t,r){if(typeof t==="function")return this.get(e,null,t);var i=t&&t.offset||0;var o=t&&t.length&&i+t.length;var s=this.mem[e];if(s)return n(r,null,t?s.slice(i,o):s);this.store.get(e,t,r)};r.prototype.close=function(e){this.store.close(e)};r.prototype.destroy=function(e){this.store.destroy(e)};function n(t,r,n){e.nextTick(function(){if(t)t(r,n)})}}).call(this,e("_process"))},{_process:34}],115:[function(e,t,r){if(typeof Object.create==="function"){t.exports=function n(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{t.exports=function i(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}}},{}],116:[function(e,t,r){(function(e){t.exports=r;function r(e,t){if(!(this instanceof r))return new r(e,t);if(!t)t={};this.chunkLength=Number(e);if(!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[];this.closed=false;this.length=Number(t.length)||Infinity;if(this.length!==Infinity){this.lastChunkLength=this.length%this.chunkLength||this.chunkLength;this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1}}r.prototype.put=function(e,t,r){if(this.closed)return n(r,new Error("Storage is closed"));var i=e===this.lastChunkIndex;if(i&&t.length!==this.lastChunkLength){return n(r,new Error("Last chunk length must be "+this.lastChunkLength))}if(!i&&t.length!==this.chunkLength){return n(r,new Error("Chunk length must be "+this.chunkLength))}this.chunks[e]=t;n(r,null)};r.prototype.get=function(e,t,r){if(typeof t==="function")return this.get(e,null,t);if(this.closed)return n(r,new Error("Storage is closed"));var i=this.chunks[e];if(!i)return n(r,new Error("Chunk not found"));if(!t)return n(r,null,i);var o=t.offset||0;var s=t.length||i.length-o;n(r,null,i.slice(o,s+o))};r.prototype.close=r.prototype.destroy=function(e){if(this.closed)return n(e,new Error("Storage is closed"));this.closed=true;this.chunks=null;n(e,null)};function n(t,r,n){e.nextTick(function(){if(t)t(r,n)})}}).call(this,e("_process"))},{_process:34}],117:[function(e,t,r){t.exports=o;var n=e("inherits");var i=e("stream");n(o,i.Readable);function o(e,t){if(!(this instanceof o))return new o(e,t);i.Readable.call(this,t);this.destroyed=false;this._drained=false;this._forwarding=false;this._current=null;this._queue=typeof e==="function"?e:e.map(s);this._next()}o.obj=function(e){return new o(e,{objectMode:true,highWaterMark:16})};o.prototype._read=function(){this._drained=true;this._forward()};o.prototype._forward=function(){if(this._forwarding||!this._drained||!this._current)return;this._forwarding=true;var e;while((e=this._current.read())!==null){this._drained=this.push(e)}this._forwarding=false};o.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;if(this._current&&this._current.destroy)this._current.destroy();if(typeof this._queue!=="function"){this._queue.forEach(function(e){if(e.destroy)e.destroy()})}if(e)this.emit("error",e);this.emit("close")};o.prototype._next=function(){var e=this;e._current=null;if(typeof e._queue==="function"){e._queue(function(t,r){if(t)return e.destroy(t);e._gotNextStream(s(r))})}else{var t=e._queue.shift();if(typeof t==="function")t=s(t());e._gotNextStream(t)}};o.prototype._gotNextStream=function(e){var t=this;if(!e){t.push(null);t.destroy();return}t._current=e;t._forward();e.on("readable",r);e.on("end",i);e.on("error",o);e.on("close",n);function r(){t._forward()}function n(){if(!e._readableState.ended){t.destroy()}}function i(){t._current=null;e.removeListener("readable",r);e.removeListener("end",i);e.removeListener("error",o);e.removeListener("close",n);t._next()}function o(e){t.destroy(e)}};function s(e){if(!e||typeof e==="function"||e._readableState)return e;var t=(new i.Readable).wrap(e);if(e.destroy){t.destroy=e.destroy.bind(e)}return t}},{inherits:115,stream:52}],118:[function(e,t,r){(function(r,n){t.exports=u;t.exports.remote=c;var i=e("blob-to-buffer");var o=e("fs");var s=e("simple-get");var a=e("magnet-uri");var f=e("parse-torrent-file");t.exports.toMagnetURI=a.encode;t.exports.toTorrentFile=f.encode;function u(e){if(typeof e==="string"&&/magnet:/.test(e)){return a(e)}else if(typeof e==="string"&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e))){return a("magnet:?xt=urn:btih:"+e)}else if(r.isBuffer(e)&&e.length===20){return a("magnet:?xt=urn:btih:"+e.toString("hex"))}else if(r.isBuffer(e)){return f(e)}else if(e&&e.infoHash){if(!e.announce)e.announce=[];if(typeof e.announce==="string"){e.announce=[e.announce]}if(!e.urlList)e.urlList=[];return e}else{throw new Error("Invalid torrent identifier")}}function c(e,t){var r;if(typeof t!=="function")throw new Error("second argument must be a Function");try{r=u(e)}catch(a){}if(r&&r.infoHash){n.nextTick(function(){t(null,r)})}else if(l(e)){i(e,function(e,r){if(e)return t(new Error("Error converting Blob: "+e.message));f(r)})}else if(typeof s==="function"&&/^https?:/.test(e)){s.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,r){if(e)return t(new Error("Error downloading torrent: "+e.message));f(r)})}else if(typeof o.readFile==="function"&&typeof e==="string"){o.readFile(e,function(e,r){if(e)return t(new Error("Invalid torrent identifier"));f(r)})}else{n.nextTick(function(){t(new Error("Invalid torrent identifier"))})}function f(e){try{r=u(e)}catch(n){return t(n)}if(r&&r.infoHash)t(null,r);else t(new Error("Invalid torrent identifier"))}}function l(e){return typeof Blob!=="undefined"&&e instanceof Blob}}).call(this,{isBuffer:e("../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js")},e("_process"))},{"../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js":31,_process:34,"blob-to-buffer":119,fs:23,"magnet-uri":120,"parse-torrent-file":123,"simple-get":185}],119:[function(e,t,r){(function(e){t.exports=function r(t,n){if(typeof Blob==="undefined"||!(t instanceof Blob)){throw new Error("first argument must be a Blob")}if(typeof n!=="function"){throw new Error("second argument must be a function")}var i=new FileReader;function o(t){i.removeEventListener("loadend",o,false);if(t.error)n(t.error);else n(null,new e(i.result))}i.addEventListener("loadend",o,false);i.readAsArrayBuffer(t)}}).call(this,e("buffer").Buffer)},{buffer:25}],120:[function(e,t,r){(function(r){t.exports=s;t.exports.decode=s;t.exports.encode=a;var n=e("thirty-two");var i=e("xtend");var o=e("uniq");function s(e){var t={};var i=e.split("magnet:?")[1];var s=i&&i.length>=0?i.split("&"):[];s.forEach(function(e){var r=e.split("=");if(r.length!==2)return;var n=r[0];var i=r[1];if(n==="dn")i=decodeURIComponent(i).replace(/\+/g," ");if(n==="tr"||n==="xs"||n==="as"||n==="ws"){i=decodeURIComponent(i)}if(n==="kt")i=decodeURIComponent(i).split("+");if(t[n]){if(Array.isArray(t[n])){t[n].push(i)}else{var o=t[n];t[n]=[o,i]}}else{t[n]=i}});var a;if(t.xt){var f=Array.isArray(t.xt)?t.xt:[t.xt];f.forEach(function(e){if(a=e.match(/^urn:btih:(.{40})/)){t.infoHash=a[1].toLowerCase()}else if(a=e.match(/^urn:btih:(.{32})/)){var i=n.decode(a[1]);t.infoHash=new r(i,"binary").toString("hex")}})}if(t.infoHash)t.infoHashBuffer=new r(t.infoHash,"hex");if(t.dn)t.name=t.dn;if(t.kt)t.keywords=t.kt;if(typeof t.tr==="string")t.announce=[t.tr];else if(Array.isArray(t.tr))t.announce=t.tr;else t.announce=[];t.urlList=[];if(typeof t.as==="string"||Array.isArray(t.as)){t.urlList=t.urlList.concat(t.as)}if(typeof t.ws==="string"||Array.isArray(t.ws)){t.urlList=t.urlList.concat(t.ws)}o(t.announce);o(t.urlList);return t}function a(e){e=i(e);if(e.infoHashBuffer)e.xt="urn:btih:"+e.infoHashBuffer.toString("hex");if(e.infoHash)e.xt="urn:btih:"+e.infoHash;if(e.name)e.dn=e.name;if(e.keywords)e.kt=e.keywords;if(e.announce)e.tr=e.announce;if(e.urlList){e.ws=e.urlList;delete e.as}var t="magnet:?";Object.keys(e).filter(function(e){return e.length===2}).forEach(function(r,n){var i=Array.isArray(e[r])?e[r]:[e[r]];i.forEach(function(e,i){if((n>0||i>0)&&(r!=="kt"||i===0))t+="&";if(r==="dn")e=encodeURIComponent(e).replace(/%20/g,"+");if(r==="tr"||r==="xs"||r==="as"||r==="ws"){e=encodeURIComponent(e)}if(r==="kt")e=encodeURIComponent(e);if(r==="kt"&&i>0)t+="+"+e;else t+=r+"="+e})});return t}}).call(this,e("buffer").Buffer)},{buffer:25,"thirty-two":121,uniq:204,xtend:210}],121:[function(e,t,r){var n=e("./thirty-two");r.encode=n.encode;r.decode=n.decode},{"./thirty-two":122}],122:[function(e,t,r){(function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";var n=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];function i(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}r.encode=function(r){if(!e.isBuffer(r)){r=new e(r)}var n=0;var o=0;var s=0;var a=0;var f=new e(i(r)*8);while(n<r.length){var u=r[n];if(s>3){a=u&255>>s;s=(s+5)%8;a=a<<s|(n+1<r.length?r[n+1]:0)>>8-s;n++}else{a=u>>8-(s+5)&31;s=(s+5)%8;if(s==0)n++}f[o]=t.charCodeAt(a);o++}for(n=o;n<f.length;n++)f[n]=61;return f};r.decode=function(t){var r=0;var i=0;var o;var s=0;if(!e.isBuffer(t)){t=new e(t)}var a=new e(Math.ceil(t.length*5/8));for(var f=0;f<t.length;f++){if(t[f]==61){break}var u=t[f]-48;if(u<n.length){i=n[u];if(r<=3){r=(r+5)%8;if(r==0){o|=i;a[s]=o;s++;o=0}else{o|=255&i<<8-r}}else{r=(r+5)%8;o|=255&i>>>r;a[s]=o;s++;o=255&i<<8-r}}else{throw new Error("Invalid input - it is not base32 encoded string")}}return a.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:25}],123:[function(e,t,r){(function(r){t.exports=a;t.exports.decode=a;t.exports.encode=f;var n=e("bencode");var i=e("path");var o=e("simple-sha1");var s=e("uniq");function a(e){if(r.isBuffer(e)){e=n.decode(e)}l(e.info,"info");l(e.info["name.utf-8"]||e.info.name,"info.name");l(e.info["piece length"],"info['piece length']");l(e.info.pieces,"info.pieces");if(e.info.files){e.info.files.forEach(function(e){l(typeof e.length==="number","info.files[0].length");l(e["path.utf-8"]||e.path,"info.files[0].path")})}else{l(typeof e.info.length==="number","info.length")}var t={};t.info=e.info;t.infoBuffer=n.encode(e.info);t.infoHash=o.sync(t.infoBuffer);t.infoHashBuffer=new r(t.infoHash,"hex");t.name=(e.info["name.utf-8"]||e.info.name).toString();if(e.info.private!==undefined)t.private=!!e.info.private;if(e["creation date"])t.created=new Date(e["creation date"]*1e3);if(e["created by"])t.createdBy=e["created by"].toString();if(r.isBuffer(e.comment))t.comment=e.comment.toString();t.announce=[];if(e["announce-list"]&&e["announce-list"].length){e["announce-list"].forEach(function(e){e.forEach(function(e){t.announce.push(e.toString())})})}else if(e.announce){t.announce.push(e.announce.toString())}if(r.isBuffer(e["url-list"])){e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]}t.urlList=(e["url-list"]||[]).map(function(e){return e.toString()});s(t.announce);s(t.urlList);var a=e.info.files||[e.info];t.files=a.map(function(e,r){var n=[].concat(t.name,e["path.utf-8"]||e.path||[]).map(function(e){return e.toString()});return{path:i.join.apply(null,[i.sep].concat(n)).slice(1),name:n[n.length-1],length:e.length,offset:a.slice(0,r).reduce(u,0)}});t.length=a.reduce(u,0);var f=t.files[t.files.length-1];t.pieceLength=e.info["piece length"];t.lastPieceLength=(f.offset+f.length)%t.pieceLength||t.pieceLength;t.pieces=c(e.info.pieces);return t}function f(e){var t={info:e.info};t["announce-list"]=e.announce.map(function(e){if(!t.announce)t.announce=e;e=new r(e,"utf8");return[e]});if(e.created){t["creation date"]=e.created.getTime()/1e3|0}if(e.urlList){t["url-list"]=e.urlList}return n.encode(t)}function u(e,t){return e+t.length}function c(e){var t=[];for(var r=0;r<e.length;r+=20){t.push(e.slice(r,r+20).toString("hex"))}return t}function l(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}}).call(this,e("buffer").Buffer)},{bencode:124,buffer:25,path:33,"simple-sha1":193,uniq:204}],124:[function(e,t,r){arguments[4][11][0].apply(r,arguments)},{"./lib/decode":125,"./lib/encode":127,dup:11}],125:[function(e,t,r){arguments[4][12][0].apply(r,arguments)},{"./dict":126,buffer:25,dup:12}],126:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{dup:13}],127:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{buffer:25,dup:14}],128:[function(e,t,r){var n=e("once");var i=e("end-of-stream");var o=e("fs");var s=function(){};var a=function(e){return typeof e==="function"};var f=function(e){return(e instanceof(o.ReadStream||s)||e instanceof(o.WriteStream||s))&&a(e.close)};var u=function(e){return e.setHeader&&a(e.abort)};var c=function(e,t,r,o){o=n(o);var s=false;e.on("close",function(){s=true});i(e,{readable:t,writable:r},function(e){if(e)return o(e);s=true;o()});var c=false;return function(t){if(s)return;if(c)return;c=true;if(f(e))return e.close();if(u(e))return e.abort();if(a(e.destroy))return e.destroy();o(t||new Error("stream was destroyed"))}};var l=function(e){e()};var d=function(e,t){return e.pipe(t)};var h=function(){var e=Array.prototype.slice.call(arguments);var t=a(e[e.length-1]||s)&&e.pop()||s;if(Array.isArray(e[0]))e=e[0];if(e.length<2)throw new Error("pump requires two streams per minimum");var r;var n=e.map(function(i,o){var s=o<e.length-1;var a=o>0;return c(i,s,a,function(e){if(!r)r=e;if(e)n.forEach(l);if(s)return;n.forEach(l);t(r)})});return e.reduce(d)};t.exports=h},{"end-of-stream":110,fs:23,once:130}],129:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],130:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,wrappy:129}],131:[function(e,t,r){var n=function(e){var t=0;return function(){if(t===e.length)return null;var r=e.length-t;var n=Math.random()*r|0;var i=e[t+n];var o=e[t];e[t]=i;e[t+n]=o;t++;return i}};t.exports=n},{}],132:[function(e,t,r){t.exports=i;t.exports.filter=o;var n=e("events").EventEmitter;function i(e,t,r){if(!Array.isArray(r))r=[r];var n=[];r.forEach(function(r){var i=function(){var e=[].slice.call(arguments);e.unshift(r);t.emit.apply(t,e)};n.push(i);e.on(r,i)});return function i(){r.forEach(function(t,r){e.removeListener(t,n[r])})}}function o(e,t){var r=new n;i(e,r,t);return r}},{events:29}],133:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{"./_stream_readable":135,"./_stream_writable":137,"core-util-is":138,dup:40,inherits:115,"process-nextick-args":140}],134:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{"./_stream_transform":136,"core-util-is":138,dup:41,inherits:115}],135:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{"./_stream_duplex":133,_process:34,buffer:25,"core-util-is":138,dup:42,events:29,inherits:115,isarray:139,"process-nextick-args":140,"string_decoder/":141,util:24}],136:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{"./_stream_duplex":133,"core-util-is":138,dup:43,inherits:115}],137:[function(e,t,r){arguments[4][44][0].apply(r,arguments)},{"./_stream_duplex":133,buffer:25,"core-util-is":138,dup:44,events:29,inherits:115,"process-nextick-args":140,"util-deprecate":142}],138:[function(e,t,r){(function(e){function t(e){if(Array.isArray){return Array.isArray(e)}return v(e)==="[object Array]"}r.isArray=t;function n(e){return typeof e==="boolean"}r.isBoolean=n;function i(e){return e===null}r.isNull=i;function o(e){return e==null}r.isNullOrUndefined=o;function s(e){return typeof e==="number"}r.isNumber=s;function a(e){return typeof e==="string"}r.isString=a;function f(e){return typeof e==="symbol"}r.isSymbol=f;function u(e){return e===void 0}r.isUndefined=u;function c(e){return v(e)==="[object RegExp]"}r.isRegExp=c;function l(e){return typeof e==="object"&&e!==null}r.isObject=l;function d(e){return v(e)==="[object Date]"}r.isDate=d;function h(e){return v(e)==="[object Error]"||e instanceof Error}r.isError=h;function p(e){return typeof e==="function"}r.isFunction=p;function m(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=m;r.isBuffer=e.isBuffer;function v(e){return Object.prototype.toString.call(e)}}).call(this,{isBuffer:e("../../../../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js")})},{"../../../../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js":31}],139:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],140:[function(e,t,r){arguments[4][46][0].apply(r,arguments)},{_process:34,dup:46}],141:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{buffer:25,dup:59}],142:[function(e,t,r){arguments[4][47][0].apply(r,arguments)},{dup:47}],143:[function(e,t,r){arguments[4][49][0].apply(r,arguments)},{"./lib/_stream_duplex.js":133,"./lib/_stream_passthrough.js":134,"./lib/_stream_readable.js":135,"./lib/_stream_transform.js":136,"./lib/_stream_writable.js":137,dup:49}],144:[function(e,t,r){(function(t){r.render=y;r.append=_;var n=r.mime=e("./lib/mime.json");var i=e("debug")("render-media");var o=e("is-ascii");var s=e("mediasource");var a=e("path");var f=e("stream-to-blob-url");var u=e("videostream");var c=[".mp4",".m4v",".m4a"];var l=[".mp4",".m4v",".webm"];var d=[".m4a",".mp3"];var h=l.concat(d);var p=[".wav",".aac",".ogg",".oga"];var m=[".jpg",".jpeg",".png",".gif",".bmp"];var v=[".css",".html",".js",".md",".pdf",".txt"];var g=typeof window!=="undefined"&&window.MediaSource;function y(e,t,r){x(e);if(typeof t==="string")t=document.querySelector(t);b(e,function(r){if(t.nodeName!==r.toUpperCase()){var n=a.extname(e.name).toLowerCase();throw new Error('Cannot render "'+n+'" inside a "'+t.nodeName.toLowerCase()+'" element, expected "'+r+'"')}return t},r)}function _(e,t,r){if(!r)r=function(){};x(e);if(typeof t==="string")t=document.querySelector(t);if(t&&(t.nodeName==="VIDEO"||t.nodeName==="AUDIO")){throw new Error("Invalid video/audio node argument. Argument must be root element that "+"video/audio tag will be appended to.")}b(e,function(e){if(e==="video"||e==="audio")return n(e);else return i(e)},function(e,t){if(e&&t)t.remove();r(e,t)});function n(e){var r=i(e);r.controls=true;r.autoplay=true;r.play();t.appendChild(r);return r}function i(e){var r=document.createElement(e);t.appendChild(r);return r}}function b(e,t,r){if(!r)r=function(){};var n=a.extname(e.name).toLowerCase();var f=0;var d;if(h.indexOf(n)>=0){y()}else if(p.indexOf(n)>=0){b()}else if(m.indexOf(n)>=0){x()}else if(v.indexOf(n)>=0){S()}else{B()}function y(){if(!g){return w(r,new Error("Video/audio streaming is not supported in your browser. You can still share "+"or download "+e.name+" (once it's fully downloaded). Use Chrome for "+"MediaSource support."))}var o=l.indexOf(n)>=0?"video":"audio";if(c.indexOf(n)>=0)a();else h();function a(){i("Use `videostream` package for "+e.name);y();d.addEventListener("error",m);d.addEventListener("playing",_);u(e,d)}function h(){i("Use MediaSource API for "+e.name);y();d.addEventListener("error",v);d.addEventListener("playing",_);var t=new s(d);var r=t.createWriteStream(k(e.name));e.createReadStream().pipe(r);if(f)d.currentTime=f}function p(){i("Use Blob URL for "+e.name);y();d.addEventListener("error",I);d.addEventListener("playing",_);E(e,function(e,t){if(e)return I(e);d.src=t;if(f)d.currentTime=f})}function m(e){i("videostream error: fallback to MediaSource API: %o",e.message||e);d.removeEventListener("error",m);d.removeEventListener("playing",_);h()}function v(e){i("MediaSource API error: fallback to Blob URL: %o",e.message||e);d.removeEventListener("error",v);d.removeEventListener("playing",_);p()}function y(){if(!d){d=t(o);d.addEventListener("progress",function(){f=d.currentTime})}}}function _(){d.removeEventListener("playing",_);r(null,d)}function b(){d=t("audio");E(e,function(e,t){if(e)return I(e);d.addEventListener("error",I);d.addEventListener("playing",_);d.src=t})}function x(){d=t("img");E(e,function(t,n){if(t)return I(t);d.src=n;d.alt=e.name;r(null,d)})}function S(){d=t("iframe");E(e,function(e,t){if(e)return I(e);d.src=t;if(n!==".pdf")d.sandbox="allow-forms allow-scripts";r(null,d)})}function B(){i('Unknown file extension "%s" - will attempt to render into iframe',n);var t="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){t+=e}).on("end",s).on("error",r);function s(){if(o(t)){i('File extension "%s" appears ascii, so will render.',n);S()}else{i('File extension "%s" appears non-ascii, will not render.',n);r(new Error('Unsupported file type "'+n+'": Cannot append to DOM'))}}}function I(t){t.message='Error rendering file "'+e.name+'": '+t.message;i(t.message);r(t)}}function w(e,r,n){t.nextTick(function(){e(r,n)})}function E(e,t){var r=a.extname(e.name).toLowerCase();f(e.createReadStream(),n[r],t)}function x(e){if(e==null){throw new Error("file cannot be null or undefined")}if(typeof e.name!=="string"){throw new Error("missing or invalid file.name property")}if(typeof e.createReadStream!=="function"){throw new Error("missing or invalid file.createReadStream property")}}function k(e){var t=a.extname(e).toLowerCase();return{".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4v":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".mp3":"audio/mpeg",".mp4":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".webm":'video/webm; codecs="vorbis, vp8"'}[t]}}).call(this,e("_process"))},{"./lib/mime.json":145,_process:34,debug:107,"is-ascii":146,mediasource:147,path:33,"stream-to-blob-url":196,videostream:182}],145:[function(e,t,r){t.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/csv",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/mp4",".m4v":"video/mp4",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",
+".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},{}],146:[function(e,t,r){var n=127;t.exports=function i(e){for(var t=0,r=e.length;t<r;++t){if(e.charCodeAt(t)>n)return false}return true}},{}],147:[function(e,t,r){t.exports=f;var n=e("inherits");var i=e("readable-stream");var o=e("to-arraybuffer");var s=typeof window!=="undefined"&&window.MediaSource;var a=60;function f(e,t){var r=this;if(!(r instanceof f))return new f(e,t);if(!s)throw new Error("web browser lacks MediaSource support");if(!t)t={};r._bufferDuration=t.bufferDuration||a;r._elem=e;r._mediaSource=new s;r._streams=[];r.detailedError=null;r._errorHandler=function(){r._elem.removeEventListener("error",r._errorHandler);var e=r._streams.slice();e.forEach(function(e){e.destroy(r._elem.error)})};r._elem.addEventListener("error",r._errorHandler);r._elem.src=window.URL.createObjectURL(r._mediaSource)}f.prototype.createWriteStream=function(e){var t=this;return new u(t,e)};f.prototype.error=function(e){var t=this;if(!t.detailedError){t.detailedError=e}try{t._mediaSource.endOfStream("decode")}catch(e){}};n(u,i.Writable);function u(e,t){var r=this;i.Writable.call(r);r._wrapper=e;r._elem=e._elem;r._mediaSource=e._mediaSource;r._allStreams=e._streams;r._allStreams.push(r);r._bufferDuration=e._bufferDuration;r._openHandler=r._onSourceOpen.bind(r,t);r._flowHandler=r._flow.bind(r);if(typeof t==="string"){if(r._mediaSource.readyState==="open"){r._createSourceBuffer(t)}else{r._mediaSource.addEventListener("sourceopen",r._openHandler)}}else if(t._sourceBuffer){t.destroy();r._sourceBuffer=t._sourceBuffer;r._sourceBuffer.addEventListener("updateend",r._flowHandler)}else{throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function")}r._elem.addEventListener("timeupdate",r._flowHandler);r.on("error",r._wrapper.error.bind(r._wrapper));r.on("finish",function(){if(r.destroyed)return;r._finished=true;if(r._allStreams.every(function(e){return e._finished})){try{r._mediaSource.endOfStream()}catch(e){}}})}u.prototype._onSourceOpen=function(e){var t=this;if(t.destroyed)return;t._mediaSource.removeEventListener("sourceopen",t._openHandler);t._createSourceBuffer(e)};u.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;t._allStreams.splice(t._allStreams.indexOf(t),1);t._mediaSource.removeEventListener("sourceopen",t._openHandler);t._elem.removeEventListener("timeupdate",t._flowHandler);if(t._sourceBuffer){t._sourceBuffer.removeEventListener("updateend",t._flowHandler);if(t._mediaSource.readyState==="open"){t._sourceBuffer.abort()}}if(e)t.emit("error",e);t.emit("close")};u.prototype._createSourceBuffer=function(e){var t=this;if(t.destroyed)return;if(s.isTypeSupported(e)){t._sourceBuffer=t._mediaSource.addSourceBuffer(e);t._sourceBuffer.addEventListener("updateend",t._flowHandler);if(t._cb){var r=t._cb;t._cb=null;r()}}else{t.destroy(new Error("The provided type is not supported"))}};u.prototype._write=function(e,t,r){var n=this;if(n.destroyed)return;if(!n._sourceBuffer){n._cb=function(i){if(i)return r(i);n._write(e,t,r)};return}if(n._sourceBuffer.updating){return r(new Error("Cannot append buffer while source buffer updating"))}try{n._sourceBuffer.appendBuffer(o(e))}catch(i){n.destroy(i);return}n._cb=r};u.prototype._flow=function(){var e=this;if(e.destroyed||!e._sourceBuffer||e._sourceBuffer.updating){return}if(e._mediaSource.readyState==="open"){if(e._getBufferDuration()>e._bufferDuration){return}}if(e._cb){var t=e._cb;e._cb=null;t()}};var c=0;u.prototype._getBufferDuration=function(){var e=this;var t=e._sourceBuffer.buffered;var r=e._elem.currentTime;var n=-1;for(var i=0;i<t.length;i++){var o=t.start(i);var s=t.end(i)+c;if(o>r){break}else if(n>=0||r<=s){n=s}}var a=n-r;if(a<0){a=0}return a}},{inherits:115,"readable-stream":158,"to-arraybuffer":159}],148:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{"./_stream_readable":150,"./_stream_writable":152,"core-util-is":153,dup:40,inherits:115,"process-nextick-args":155}],149:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{"./_stream_transform":151,"core-util-is":153,dup:41,inherits:115}],150:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{"./_stream_duplex":148,_process:34,buffer:25,"core-util-is":153,dup:42,events:29,inherits:115,isarray:154,"process-nextick-args":155,"string_decoder/":156,util:24}],151:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{"./_stream_duplex":148,"core-util-is":153,dup:43,inherits:115}],152:[function(e,t,r){arguments[4][44][0].apply(r,arguments)},{"./_stream_duplex":148,buffer:25,"core-util-is":153,dup:44,events:29,inherits:115,"process-nextick-args":155,"util-deprecate":157}],153:[function(e,t,r){arguments[4][71][0].apply(r,arguments)},{"../../../../../../../../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js":31,dup:71}],154:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],155:[function(e,t,r){arguments[4][46][0].apply(r,arguments)},{_process:34,dup:46}],156:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{buffer:25,dup:59}],157:[function(e,t,r){arguments[4][47][0].apply(r,arguments)},{dup:47}],158:[function(e,t,r){arguments[4][49][0].apply(r,arguments)},{"./lib/_stream_duplex.js":148,"./lib/_stream_passthrough.js":149,"./lib/_stream_readable.js":150,"./lib/_stream_transform.js":151,"./lib/_stream_writable.js":152,dup:49}],159:[function(e,t,r){arguments[4][58][0].apply(r,arguments)},{buffer:25,dup:58}],160:[function(e,t,r){var n=e("binary-search");var i=e("events");var o=e("inherits");var s=e("mp4-stream");var a=e("mp4-box-encoding");var f=e("range-slice-stream");t.exports=u;function u(e){var t=this;i.call(t);t._tracks=[];t._fragmentSequence=1;t._file=e;t._decoder=null;t._findMoov(0)}o(u,i);u.prototype._findMoov=function(e){var t=this;if(t._decoder){t._decoder.destroy()}t._decoder=s.decode();var r=t._file.createReadStream({start:e});r.pipe(t._decoder);t._decoder.once("box",function(n){if(n.type==="moov"){t._decoder.decode(function(e){r.destroy();t._processMoov(e)})}else{r.destroy();t._findMoov(e+n.length)}})};function c(e,t){var r=this;r._entries=e;r._countName=t||"count";r._index=0;r._offset=0;r.value=r._entries[0]}c.prototype.inc=function(){var e=this;e._offset++;if(e._offset>=e._entries[e._index][e._countName]){e._index++;e._offset=0}e.value=e._entries[e._index]};u.prototype._processMoov=function(e){var t=this;var r=e.traks;t._tracks=[];var n=null;var i=null;t._hasVideo=false;t._hasAudio=false;for(var o=0;o<r.length;o++){var s=r[o];var a=s.mdia.minf.stbl;var f=a.stsd.entries[0];var u=s.mdia.hdlr.handlerType;var d;var h;if(u==="vide"&&f.type==="avc1"){if(t._hasVideo){continue}t._hasVideo=true;d="avc1";if(f.avcC){d+="."+f.avcC.mimeCodec}h='video/mp4; codecs="'+d+'"'}else if(u==="soun"&&f.type==="mp4a"){if(t._hasAudio){continue}t._hasAudio=true;d="mp4a";if(f.esds&&f.esds.mimeCodec){d+="."+f.esds.mimeCodec}h='audio/mp4; codecs="'+d+'"'}else{continue}var p=[];var m=0;var v=0;var g=0;var y=0;var _=0;var b=0;var w=new c(a.stts.entries);var E=null;if(a.ctts){E=new c(a.ctts.entries)}var x=0;while(true){var k=a.stsc.entries[_];var S=a.stsz.entries[m];var B=w.value.duration;var I=E?E.value.compositionOffset:0;var A=true;if(a.stss){A=a.stss.entries[x]===m+1}p.push({size:S,duration:B,dts:b,presentationOffset:I,sync:A,offset:y+a.stco.entries[g]});m++;if(m>=a.stsz.entries.length){break}v++;y+=S;if(v>=k.samplesPerChunk){v=0;y=0;g++;var C=a.stsc.entries[_+1];if(C&&g+1>=C.firstChunk){_++}}b+=B;w.inc();E&&E.inc();if(A){x++}}s.mdia.mdhd.duration=0;s.tkhd.duration=0;var T=k.sampleDescriptionId;var L={type:"moov",mvhd:e.mvhd,traks:[{tkhd:s.tkhd,mdia:{mdhd:s.mdia.mdhd,hdlr:s.mdia.hdlr,elng:s.mdia.elng,minf:{vmhd:s.mdia.minf.vmhd,smhd:s.mdia.minf.smhd,dinf:s.mdia.minf.dinf,stbl:{stsd:a.stsd,stts:l(),ctts:l(),stsc:l(),stsz:l(),stco:l(),stss:l()}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:s.tkhd.trackId,defaultSampleDescriptionIndex:T,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};t._tracks.push({trackId:s.tkhd.trackId,timeScale:s.mdia.mdhd.timeScale,samples:p,currSample:null,currTime:null,moov:L,mime:h})}e.mvhd.duration=0;t._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};var R=t._tracks.map(function(e){return{mime:e.mime}});t.emit("ready",R)};function l(){return{version:0,flags:0,entries:[]}}u.prototype.seek=function(e,t){var r=this;if(!r._tracks){throw new Error("Not ready yet; wait for 'ready' event")}if(r._fileStream){r._fileStream.destroy();r._fileStream=null}var n=-1;r._tracks.map(function(i,o){if(i.outStream){i.outStream.destroy()}if(i.inStream){i.inStream.destroy();i.inStream=null}var a=i.outStream=s.encode();var f=r._generateFragment(o,e);if(!f){return a.finalize()}if(n===-1||f.ranges[0].start<n){n=f.ranges[0].start}if(t){a.box(r._ftyp,function(e){if(e)return r.emit("error",e);if(a.destroyed)return;a.box(i.moov,function(e){if(e)return r.emit("error",e);u(f)})})}else{u(f)}function u(e){if(a.destroyed)return;a.box(e.moof,function(t){if(t)return r.emit("error",t);if(a.destroyed)return;var n=i.inStream.slice(e.ranges);n.pipe(a.mediaData(e.length,function(e){if(e)return r.emit("error",e);if(a.destroyed)return;var t=r._generateFragment(o);if(!t){return a.finalize()}u(t)}))})}});if(n>=0){var i=r._fileStream=r._file.createReadStream({start:n});r._tracks.forEach(function(e){e.inStream=new f(n);i.pipe(e.inStream)})}return r._tracks.map(function(e){return e.outStream})};u.prototype._findSampleBefore=function(e,t){var r=this;var i=r._tracks[e];var o=Math.floor(i.timeScale*t);var s=n(i.samples,o,function(e,t){var r=e.dts+e.presentationOffset;return r-t});if(s===-1){s=0}else if(s<0){s=-s-2}while(!i.samples[s].sync){s--}return s};var d=1;u.prototype._generateFragment=function(e,t){var r=this;var n=r._tracks[e];var i;if(t!==undefined){i=r._findSampleBefore(e,t)}else{i=n.currSample}if(i>=n.samples.length)return null;var o=n.samples[i].offset;var s=n.samples[i].dts;var a=0;var f=[];for(var u=i;u<n.samples.length;u++){var c=n.samples[u];if(c.sync&&c.dts-s>=n.timeScale*d){break}a+=c.size;var l=f.length-1;if(l<0||f[l].end!==c.offset){f.push({start:c.offset,end:c.offset+c.size})}else{f[l].end+=c.size}}n.currSample=u;return{moof:r._generateMoof(e,i,u),ranges:f,length:a}};u.prototype._generateMoof=function(e,t,r){var n=this;var i=n._tracks[e];var o=[];for(var s=t;s<r;s++){var f=i.samples[s];o.push({sampleDuration:f.duration,sampleSize:f.size,sampleFlags:f.sync?33554432:16842752,sampleCompositionTimeOffset:f.presentationOffset})}var u={type:"moof",mfhd:{sequenceNumber:n._fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:i.trackId},tfdt:{baseMediaDecodeTime:i.samples[t].dts},trun:{flags:3841,dataOffset:8,entries:o}}]};u.trafs[0].trun.dataOffset+=a.encodingLength(u);return u}},{"binary-search":161,events:29,inherits:115,"mp4-box-encoding":164,"mp4-stream":168,"range-slice-stream":181}],161:[function(e,t,r){t.exports=function(e,t,r,n,i){var o,s;if(n===undefined)n=0;else{n=n|0;if(n<0||n>=e.length)throw new RangeError("invalid lower bound")}if(i===undefined)i=e.length-1;else{i=i|0;if(i<n||i>=e.length)throw new RangeError("invalid upper bound")}while(n<=i){o=n+(i-n>>1);s=+r(e[o],t);if(s<0)n=o+1;else if(s>0)i=o-1;else return o}return~n}},{}],162:[function(e,t,r){(function(t){var n=e("./index");var i=e("./descriptor");var o=20828448e5;r.fullBoxes={};var s=["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"];s.forEach(function(e){r.fullBoxes[e]=true});r.ftyp={};r.ftyp.encode=function(e,n,i){n=n?n.slice(i):new t(r.ftyp.encodingLength(e));var o=e.compatibleBrands||[];n.write(e.brand,0,4,"ascii");n.writeUInt32BE(e.brandVersion,4);for(var s=0;s<o.length;s++)n.write(o[s],8+s*4,4,"ascii");r.ftyp.encode.bytes=8+o.length*4;return n};r.ftyp.decode=function(e,t){e=e.slice(t);var r=e.toString("ascii",0,4);var n=e.readUInt32BE(4);var i=[];for(var o=8;o<e.length;o+=4)i.push(e.toString("ascii",o,o+4));return{brand:r,brandVersion:n,compatibleBrands:i}};r.ftyp.encodingLength=function(e){return 8+(e.compatibleBrands||[]).length*4};r.mvhd={};r.mvhd.encode=function(e,n,i){n=n?n.slice(i):new t(96);f(e.ctime||new Date,n,0);f(e.mtime||new Date,n,4);n.writeUInt32BE(e.timeScale||0,8);n.writeUInt32BE(e.duration||0,12);u(e.preferredRate||0,n,16);c(e.preferredVolume||0,n,20);a(n,22,32);l(e.matrix,n,32);n.writeUInt32BE(e.previewTime||0,68);n.writeUInt32BE(e.previewDuration||0,72);n.writeUInt32BE(e.posterTime||0,76);n.writeUInt32BE(e.selectionTime||0,80);n.writeUInt32BE(e.selectionDuration||0,84);n.writeUInt32BE(e.currentTime||0,88);n.writeUInt32BE(e.nextTrackId||0,92);r.mvhd.encode.bytes=96;return n};r.mvhd.decode=function(e,t){e=e.slice(t);return{ctime:p(e,0),mtime:p(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),preferredRate:m(e,16),preferredVolume:v(e,20),matrix:h(e.slice(32,68)),previewTime:e.readUInt32BE(68),previewDuration:e.readUInt32BE(72),posterTime:e.readUInt32BE(76),selectionTime:e.readUInt32BE(80),selectionDuration:e.readUInt32BE(84),currentTime:e.readUInt32BE(88),nextTrackId:e.readUInt32BE(92)}};r.mvhd.encodingLength=function(e){return 96};r.tkhd={};r.tkhd.encode=function(e,n,i){n=n?n.slice(i):new t(80);f(e.ctime||new Date,n,0);f(e.mtime||new Date,n,4);n.writeUInt32BE(e.trackId||0,8);a(n,12,16);n.writeUInt32BE(e.duration||0,16);a(n,20,28);n.writeUInt16BE(e.layer||0,28);n.writeUInt16BE(e.alternateGroup||0,30);n.writeUInt16BE(e.volume||0,32);l(e.matrix,n,36);n.writeUInt32BE(e.trackWidth||0,72);n.writeUInt32BE(e.trackHeight||0,76);r.tkhd.encode.bytes=80;return n};r.tkhd.decode=function(e,t){e=e.slice(t);return{ctime:p(e,0),mtime:p(e,4),trackId:e.readUInt32BE(8),duration:e.readUInt32BE(16),layer:e.readUInt16BE(28),alternateGroup:e.readUInt16BE(30),volume:e.readUInt16BE(32),matrix:h(e.slice(36,72)),trackWidth:e.readUInt32BE(72),trackHeight:e.readUInt32BE(76)}};r.tkhd.encodingLength=function(e){return 80};r.mdhd={};r.mdhd.encode=function(e,n,i){n=n?n.slice(i):new t(20);f(e.ctime||new Date,n,0);f(e.mtime||new Date,n,4);n.writeUInt32BE(e.timeScale||0,8);n.writeUInt32BE(e.duration||0,12);n.writeUInt16BE(e.language||0,16);n.writeUInt16BE(e.quality||0,18);r.mdhd.encode.bytes=20;return n};r.mdhd.decode=function(e,t){e=e.slice(t);return{ctime:p(e,0),mtime:p(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),language:e.readUInt16BE(16),quality:e.readUInt16BE(18)}};r.mdhd.encodingLength=function(e){return 20};r.vmhd={};r.vmhd.encode=function(e,n,i){n=n?n.slice(i):new t(8);n.writeUInt16BE(e.graphicsMode||0,0);var o=e.opcolor||[0,0,0];n.writeUInt16BE(o[0],2);n.writeUInt16BE(o[1],4);n.writeUInt16BE(o[2],6);r.vmhd.encode.bytes=8;return n};r.vmhd.decode=function(e,t){e=e.slice(t);return{graphicsMode:e.readUInt16BE(0),opcolor:[e.readUInt16BE(2),e.readUInt16BE(4),e.readUInt16BE(6)]}};r.vmhd.encodingLength=function(e){return 8};r.smhd={};r.smhd.encode=function(e,n,i){n=n?n.slice(i):new t(4);n.writeUInt16BE(e.balance||0,0);a(n,2,4);r.smhd.encode.bytes=4;return n};r.smhd.decode=function(e,t){e=e.slice(t);return{balance:e.readUInt16BE(0)}};r.smhd.encodingLength=function(e){return 4};r.stsd={};r.stsd.encode=function(e,i,o){i=i?i.slice(o):new t(r.stsd.encodingLength(e));var s=e.entries||[];i.writeUInt32BE(s.length,0);var a=4;for(var f=0;f<s.length;f++){var u=s[f];n.encode(u,i,a);a+=n.encode.bytes}r.stsd.encode.bytes=a;return i};r.stsd.decode=function(e,t,r){e=e.slice(t);var i=e.readUInt32BE(0);var o=new Array(i);var s=4;for(var a=0;a<i;a++){var f=n.decode(e,s,r);o[a]=f;s+=f.length}return{entries:o}};r.stsd.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var r=0;r<e.entries.length;r++){t+=n.encodingLength(e.entries[r])}return t};r.avc1=r.VisualSampleEntry={};r.VisualSampleEntry.encode=function(e,i,o){i=i?i.slice(o):new t(r.VisualSampleEntry.encodingLength(e));a(i,0,6);i.writeUInt16BE(e.dataReferenceIndex||0,6);a(i,8,24);i.writeUInt16BE(e.width||0,24);i.writeUInt16BE(e.height||0,26);i.writeUInt32BE(e.hResolution||4718592,28);i.writeUInt32BE(e.vResolution||4718592,32);a(i,36,40);i.writeUInt16BE(e.frameCount||1,40);var s=e.compressorName||"";var f=Math.min(s.length,31);i.writeUInt8(f,42);i.write(s,43,f,"utf8");i.writeUInt16BE(e.depth||24,74);i.writeInt16BE(-1,76);var u=78;var c=e.children||[];c.forEach(function(e){n.encode(e,i,u);u+=n.encode.bytes});r.VisualSampleEntry.encode.bytes=u};r.VisualSampleEntry.decode=function(e,t,r){e=e.slice(t);var i=r-t;var o=Math.min(e.readUInt8(42),31);var s={dataReferenceIndex:e.readUInt16BE(6),width:e.readUInt16BE(24),height:e.readUInt16BE(26),hResolution:e.readUInt32BE(28),vResolution:e.readUInt32BE(32),frameCount:e.readUInt16BE(40),compressorName:e.toString("utf8",43,43+o),depth:e.readUInt16BE(74),children:[]};var a=78;while(i-a>=8){var f=n.decode(e,a,i);s.children.push(f);s[f.type]=f;a+=f.length}return s};r.VisualSampleEntry.encodingLength=function(e){var t=78;var r=e.children||[];r.forEach(function(e){t+=n.encodingLength(e)});return t};r.avcC={};r.avcC.encode=function(e,n,i){n=n?n.slice(i):t(e.buffer.length);e.buffer.copy(n);r.avcC.encode.bytes=e.buffer.length};r.avcC.decode=function(e,r,n){e=e.slice(r,n);return{mimeCodec:e.toString("hex",1,4),buffer:new t(e)}};r.avcC.encodingLength=function(e){return e.buffer.length};r.mp4a=r.AudioSampleEntry={};r.AudioSampleEntry.encode=function(e,i,o){i=i?i.slice(o):new t(r.AudioSampleEntry.encodingLength(e));a(i,0,6);i.writeUInt16BE(e.dataReferenceIndex||0,6);a(i,8,16);i.writeUInt16BE(e.channelCount||2,16);i.writeUInt16BE(e.sampleSize||16,18);a(i,20,24);i.writeUInt32BE(e.sampleRate||0,24);var s=28;var f=e.children||[];f.forEach(function(e){n.encode(e,i,s);s+=n.encode.bytes});r.AudioSampleEntry.encode.bytes=s};r.AudioSampleEntry.decode=function(e,t,r){e=e.slice(t,r);var i=r-t;var o={dataReferenceIndex:e.readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]};var s=28;while(i-s>=8){var a=n.decode(e,s,i);o.children.push(a);o[a.type]=a;s+=a.length}return o};r.AudioSampleEntry.encodingLength=function(e){var t=28;var r=e.children||[];r.forEach(function(e){t+=n.encodingLength(e)});return t};r.esds={};r.esds.encode=function(e,n,i){n=n?n.slice(i):t(e.buffer.length);e.buffer.copy(n,0);r.esds.encode.bytes=e.buffer.length};r.esds.decode=function(e,r,n){e=e.slice(r,n);var o=i.Descriptor.decode(e,0,e.length);var s=o.tagName==="ESDescriptor"?o:{};var a=s.DecoderConfigDescriptor||{};var f=a.oti||0;var u=a.DecoderSpecificInfo||{};var c=u?(u.buffer.readUInt8(0)&248)>>3:0;var l=null;if(f){l=f.toString(16);if(c){l+="."+c}}return{mimeCodec:l,buffer:new t(e.slice(0))}};r.esds.encodingLength=function(e){return e.buffer.length};r.stsz={};r.stsz.encode=function(e,n,i){var o=e.entries||[];n=n?n.slice(i):t(r.stsz.encodingLength(e));n.writeUInt32BE(0,0);n.writeUInt32BE(o.length,4);for(var s=0;s<o.length;s++){n.writeUInt32BE(o[s],s*4+8)}r.stsz.encode.bytes=8+o.length*4;return n};r.stsz.decode=function(e,t){e=e.slice(t);var r=e.readUInt32BE(0);var n=e.readUInt32BE(4);var i=new Array(n);for(var o=0;o<n;o++){if(r===0){i[o]=e.readUInt32BE(o*4+8)}else{i[o]=r}}return{entries:i}};r.stsz.encodingLength=function(e){return 8+e.entries.length*4};r.stss=r.stco={};r.stco.encode=function(e,n,i){var o=e.entries||[];n=n?n.slice(i):new t(r.stco.encodingLength(e));n.writeUInt32BE(o.length,0);for(var s=0;s<o.length;s++){n.writeUInt32BE(o[s],s*4+4)}r.stco.encode.bytes=4+o.length*4;return n};r.stco.decode=function(e,t){e=e.slice(t);var r=e.readUInt32BE(0);var n=new Array(r);for(var i=0;i<r;i++){n[i]=e.readUInt32BE(i*4+4)}return{entries:n}};r.stco.encodingLength=function(e){return 4+e.entries.length*4};r.stts={};r.stts.encode=function(e,n,i){var o=e.entries||[];n=n?n.slice(i):new t(r.stts.encodingLength(e));n.writeUInt32BE(o.length,0);for(var s=0;s<o.length;s++){var a=s*8+4;n.writeUInt32BE(o[s].count||0,a);n.writeUInt32BE(o[s].duration||0,a+4)}r.stts.encode.bytes=4+e.entries.length*8;return n};r.stts.decode=function(e,t){e=e.slice(t);var r=e.readUInt32BE(0);var n=new Array(r);for(var i=0;i<r;i++){var o=i*8+4;n[i]={count:e.readUInt32BE(o),duration:e.readUInt32BE(o+4)}}return{entries:n}};r.stts.encodingLength=function(e){return 4+e.entries.length*8};r.ctts={};r.ctts.encode=function(e,n,i){var o=e.entries||[];n=n?n.slice(i):new t(r.ctts.encodingLength(e));n.writeUInt32BE(o.length,0);for(var s=0;s<o.length;s++){var a=s*8+4;n.writeUInt32BE(o[s].count||0,a);n.writeUInt32BE(o[s].compositionOffset||0,a+4)}r.ctts.encode.bytes=4+o.length*8;return n};r.ctts.decode=function(e,t){e=e.slice(t);var r=e.readUInt32BE(0);var n=new Array(r);for(var i=0;i<r;i++){var o=i*8+4;n[i]={count:e.readUInt32BE(o),compositionOffset:e.readInt32BE(o+4)}}return{entries:n}};r.ctts.encodingLength=function(e){return 4+e.entries.length*8};r.stsc={};r.stsc.encode=function(e,n,i){var o=e.entries||[];n=n?n.slice(i):new t(r.stsc.encodingLength(e));n.writeUInt32BE(o.length,0);for(var s=0;s<o.length;s++){var a=s*12+4;n.writeUInt32BE(o[s].firstChunk||0,a);n.writeUInt32BE(o[s].samplesPerChunk||0,a+4);n.writeUInt32BE(o[s].sampleDescriptionId||0,a+8)}r.stsc.encode.bytes=4+o.length*12;return n};r.stsc.decode=function(e,t){e=e.slice(t);var r=e.readUInt32BE(0);var n=new Array(r);for(var i=0;i<r;i++){var o=i*12+4;n[i]={firstChunk:e.readUInt32BE(o),samplesPerChunk:e.readUInt32BE(o+4),sampleDescriptionId:e.readUInt32BE(o+8)}}return{entries:n}};r.stsc.encodingLength=function(e){return 4+e.entries.length*12};r.dref={};r.dref.encode=function(e,n,i){n=n?n.slice(i):new t(r.dref.encodingLength(e));var o=e.entries||[];n.writeUInt32BE(o.length,0);var s=4;for(var a=0;a<o.length;a++){var f=o[a];var u=(f.buf?f.buf.length:0)+4+4;n.writeUInt32BE(u,s);s+=4;n.write(f.type,s,4,"ascii");s+=4;if(f.buf){f.buf.copy(n,s);s+=f.buf.length}}r.dref.encode.bytes=s;return n};r.dref.decode=function(e,t){e=e.slice(t);var r=e.readUInt32BE(0);var n=new Array(r);var i=4;for(var o=0;o<r;o++){var s=e.readUInt32BE(i);var a=e.toString("ascii",i+4,i+8);var f=e.slice(i+8,i+s);i+=s;n[o]={type:a,buf:f}}return{entries:n}};r.dref.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var r=0;r<e.entries.length;r++){var n=e.entries[r].buf;t+=(n?n.length:0)+4+4}return t};r.elst={};r.elst.encode=function(e,n,i){var o=e.entries||[];n=n?n.slice(i):new t(r.elst.encodingLength(e));n.writeUInt32BE(o.length,0);for(var s=0;s<o.length;s++){var a=s*12+4;n.writeUInt32BE(o[s].trackDuration||0,a);n.writeUInt32BE(o[s].mediaTime||0,a+4);u(o[s].mediaRate||0,n,a+8)}r.elst.encode.bytes=4+o.length*12;return n};r.elst.decode=function(e,t){e=e.slice(t);var r=e.readUInt32BE(0);var n=new Array(r);for(var i=0;i<r;i++){var o=i*12+4;n[i]={trackDuration:e.readUInt32BE(o),mediaTime:e.readInt32BE(o+4),mediaRate:m(e,o+8)}}return{entries:n}};r.elst.encodingLength=function(e){return 4+e.entries.length*12};r.hdlr={};r.hdlr.encode=function(e,n,i){n=n?n.slice(i):new t(r.hdlr.encodingLength(e));var o=21+(e.name||"").length;n.fill(0,0,o);n.write(e.handlerType||"",4,4,"ascii");d(e.name||"",n,20);r.hdlr.encode.bytes=o;return n};r.hdlr.decode=function(e,t,r){e=e.slice(t);return{handlerType:e.toString("ascii",4,8),name:g(e,20,r)}};r.hdlr.encodingLength=function(e){return 21+(e.name||"").length};r.mehd={};r.mehd.encode=function(e,n,i){n=n?n.slice(i):new t(4);n.writeUInt32BE(e.fragmentDuration||0,0);r.mehd.encode.bytes=4;return n};r.mehd.decode=function(e,t){e=e.slice(t);return{fragmentDuration:e.readUInt32BE(0)}};r.mehd.encodingLength=function(e){return 4};r.trex={};r.trex.encode=function(e,n,i){n=n?n.slice(i):new t(20);n.writeUInt32BE(e.trackId||0,0);n.writeUInt32BE(e.defaultSampleDescriptionIndex||0,4);n.writeUInt32BE(e.defaultSampleDuration||0,8);n.writeUInt32BE(e.defaultSampleSize||0,12);n.writeUInt32BE(e.defaultSampleFlags||0,16);r.trex.encode.bytes=20;return n};r.trex.decode=function(e,t){e=e.slice(t);return{trackId:e.readUInt32BE(0),defaultSampleDescriptionIndex:e.readUInt32BE(4),defaultSampleDuration:e.readUInt32BE(8),defaultSampleSize:e.readUInt32BE(12),defaultSampleFlags:e.readUInt32BE(16)}};r.trex.encodingLength=function(e){return 20};r.mfhd={};r.mfhd.encode=function(e,n,i){n=n?n.slice(i):new t(4);n.writeUInt32BE(e.sequenceNumber||0,0);r.mfhd.encode.bytes=4;return n};r.mfhd.decode=function(e,t){return{sequenceNumber:e.readUint32BE(0)}};r.mfhd.encodingLength=function(e){return 4};r.tfhd={};r.tfhd.encode=function(e,n,i){n=n?n.slice(i):new t(4);n.writeUInt32BE(e.trackId,0);r.tfhd.encode.bytes=4;return n};r.tfhd.decode=function(e,t){};r.tfhd.encodingLength=function(e){return 4};r.tfdt={};r.tfdt.encode=function(e,n,i){n=n?n.slice(i):new t(4);n.writeUInt32BE(e.baseMediaDecodeTime||0,0);r.tfdt.encode.bytes=4;return n};r.tfdt.decode=function(e,t){};r.tfdt.encodingLength=function(e){return 4};r.trun={};r.trun.encode=function(e,n,i){n=n?n.slice(i):new t(8+e.entries.length*16);n.writeUInt32BE(e.entries.length,0);n.writeInt32BE(e.dataOffset,4);var o=8;for(var s=0;s<e.entries.length;s++){var a=e.entries[s];n.writeUInt32BE(a.sampleDuration,o);o+=4;n.writeUInt32BE(a.sampleSize,o);o+=4;n.writeUInt32BE(a.sampleFlags,o);o+=4;n.writeUInt32BE(a.sampleCompositionTimeOffset,o);o+=4}r.trun.encode.bytes=o};r.trun.decode=function(e,t){};r.trun.encodingLength=function(e){return 8+e.entries.length*16};r.mdat={};r.mdat.encode=function(e,t,n){if(e.buffer){e.buffer.copy(t,n);r.mdat.encode.bytes=e.buffer.length}else{r.mdat.encode.bytes=r.mdat.encodingLength(e)}};r.mdat.decode=function(e,r,n){return{buffer:new t(e.slice(r,n))}};r.mdat.encodingLength=function(e){return e.buffer?e.buffer.length:e.contentLength};function a(e,t,r){for(var n=t;n<r;n++)e[n]=0}function f(e,t,r){t.writeUInt32BE(Math.floor((e.getTime()+o)/1e3),r)}function u(e,t,r){t.writeUInt16BE(Math.floor(e)%(256*256),r);t.writeUInt16BE(Math.floor(e*256*256)%(256*256),r+2)}function c(e,t,r){t[r]=Math.floor(e)%256;t[r+1]=Math.floor(e*256)%256}function l(e,t,r){if(!e)e=[0,0,0,0,0,0,0,0,0];for(var n=0;n<e.length;n++){u(e[n],t,r+n*4)}}function d(e,r,n){var i=new t(e,"utf8");i.copy(r,n);r[n+i.length]=0}function h(e){var t=new Array(e.length/4);for(var r=0;r<t.length;r++)t[r]=m(e,r*4);return t}function p(e,t){return new Date(e.readUInt32BE(t)*1e3-o)}function m(e,t){return e.readUInt16BE(t)+e.readUInt16BE(t+2)/(256*256)}function v(e,t){return e[t]+e[t+1]/256}function g(e,t,r){var n;for(n=0;n<r;n++){if(e[t+n]===0){break}}return e.toString("utf8",t,t+n)}}).call(this,e("buffer").Buffer)},{"./descriptor":163,"./index":164,buffer:25}],163:[function(e,t,r){(function(e){var t={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};r.Descriptor={};r.Descriptor.decode=function(n,i,o){var s=n.readUInt8(i);var a=i+1;var f;var u=0;do{f=n.readUInt8(a++);u=u<<7|f&127}while(f&128);var c;var l=t[s];if(r[l]){c=r[l].decode(n,a,o)}else{c={buffer:new e(n.slice(a,a+u))}}c.tag=s;c.tagName=l;c.length=a-i+u;c.contentsLen=u;return c};r.DescriptorArray={};r.DescriptorArray.decode=function(e,n,i){var o=n;var s={};while(o+2<=i){var a=r.Descriptor.decode(e,o,i);o+=a.length;var f=t[a.tag]||"Descriptor"+a.tag;s[f]=a}return s};r.ESDescriptor={};r.ESDescriptor.decode=function(e,t,n){var i=e.readUInt8(t+2);var o=t+3;if(i&128){o+=2}if(i&64){var s=e.readUInt8(o);o+=s+1}if(i&32){o+=2}return r.DescriptorArray.decode(e,o,n)};r.DecoderConfigDescriptor={};r.DecoderConfigDescriptor.decode=function(e,t,n){var i=e.readUInt8(t);var o=r.DescriptorArray.decode(e,t+13,n);o.oti=i;return o}}).call(this,e("buffer").Buffer)},{buffer:25}],164:[function(e,t,r){(function(t){var n=e("uint64be");var i=e("./boxes");var o=4294967295;var s=r;var a=r.containers={moov:["mvhd","meta","traks","mvex"],trak:["tkhd","tref","trgr","edts","meta","mdia","udta"],edts:["elst"],mdia:["mdhd","hdlr","elng","minf"],minf:["vmhd","smhd","hmhd","sthd","nmhd","dinf","stbl"],dinf:["dref"],stbl:["stsd","stts","ctts","cslg","stsc","stsz","stz2","stco","co64","stss","stsh","padb","stdp","sdtp","sbgps","sgpds","subss","saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","trun","sbgps","sgpds","subss","saizs","saios","tfdt","meta"]};s.encode=function(e,r,n){s.encodingLength(e);n=n||0;r=r||new t(e.length);return s._encode(e,r,n)};s._encode=function(e,t,r){var f=e.type;var u=e.length;if(u>o){u=1}t.writeUInt32BE(u,r);t.write(e.type,r+4,4,"ascii");var c=r+8;if(u===1){n.encode(e.length,t,c);c+=8}if(i.fullBoxes[f]){t.writeUInt32BE(e.flags||0,c);t.writeUInt8(e.version||0,c);c+=4}if(a[f]){var l=a[f];l.forEach(function(r){if(r.length===5){var n=e[r]||[];r=r.substr(0,4);n.forEach(function(e){s._encode(e,t,c);c+=s.encode.bytes})}else if(e[r]){s._encode(e[r],t,c);c+=s.encode.bytes}});if(e.otherBoxes){e.otherBoxes.forEach(function(e){s._encode(e,t,c);c+=s.encode.bytes})}}else if(i[f]){var d=i[f].encode;d(e,t,c);c+=d.bytes}else if(e.buffer){var h=e.buffer;h.copy(t,c);c+=e.buffer.length}else{throw new Error("Either `type` must be set to a known type (not'"+f+"') or `buffer` must be set")}s.encode.bytes=c-r;return t};s.readHeaders=function(e,t,r){t=t||0;r=r||e.length;if(r-t<8){return 8}var o=e.readUInt32BE(t);var s=e.toString("ascii",t+4,t+8);var a=t+8;if(o===1){if(r-t<16){return 16}o=n.decode(e,a);a+=8}var f;var u;if(i.fullBoxes[s]){f=e.readUInt8(a);u=e.readUInt32BE(a)&16777215;a+=4}return{length:o,headersLen:a-t,contentLen:o-(a-t),type:s,version:f,flags:u}};s.decode=function(e,t,r){t=t||0;r=r||e.length;var n=s.readHeaders(e,t,r);if(!n||n.length>r-t){throw new Error("Data too short")}return s.decodeWithoutHeaders(n,e,t+n.headersLen,t+n.length)};s.decodeWithoutHeaders=function(e,r,n,o){n=n||0;o=o||r.length;var f=e.type;var u={};if(a[f]){u.otherBoxes=[];var c=a[f];var l=n;while(o-l>=8){var d=s.decode(r,l,o);l+=d.length;if(c.indexOf(d.type)>=0){u[d.type]=d}else if(c.indexOf(d.type+"s")>=0){var h=d.type+"s";var p=u[h]=u[h]||[];p.push(d)}else{u.otherBoxes.push(d)}}}else if(i[f]){var m=i[f].decode;u=m(r,n,o)}else{u.buffer=new t(r.slice(n,o))}u.length=e.length;u.contentLen=e.contentLen;u.type=e.type;u.version=e.version;u.flags=e.flags;return u};s.encodingLength=function(e){var t=e.type;var r=8;if(i.fullBoxes[t]){r+=4}if(a[t]){var n=a[t];n.forEach(function(t){if(t.length===5){var n=e[t]||[];t=t.substr(0,4);n.forEach(function(e){e.type=t;r+=s.encodingLength(e)})}else if(e[t]){var i=e[t];i.type=t;r+=s.encodingLength(i)}});if(e.otherBoxes){e.otherBoxes.forEach(function(e){r+=s.encodingLength(e)})}}else if(i[t]){r+=i[t].encodingLength(e)}else if(e.buffer){r+=e.buffer.length}else{throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set")}if(r>o){r+=8}e.length=r;return r}}).call(this,e("buffer").Buffer)},{"./boxes":162,buffer:25,uint64be:165}],165:[function(e,t,r){(function(e){var t=4294967295;r.encodingLength=function(){return 8};r.encode=function(r,n,i){if(!n)n=new e(8);if(!i)i=0;var o=Math.floor(r/t);var s=r-o*t;n.writeUInt32BE(o,i);n.writeUInt32BE(s,i+4);return n};r.decode=function(r,n){if(!n)n=0;if(!r)r=new e(4);if(!n)n=0;var i=r.readUInt32BE(n);var o=r.readUInt32BE(n+4);return i*t+o;
+};r.encode.bytes=8;r.decode.bytes=8}).call(this,e("buffer").Buffer)},{buffer:25}],166:[function(e,t,r){(function(r){var n=e("readable-stream");var i=e("util");var o=e("next-event");var s=e("mp4-box-encoding");var a=new r(0);t.exports=f;function f(){if(!(this instanceof f))return new f;n.Writable.call(this);this.destroyed=false;this._pending=0;this._missing=0;this._buf=null;this._str=null;this._cb=null;this._ondrain=null;this._writeBuffer=null;this._writeCb=null;this._ondrain=null;this._kick()}i.inherits(f,n.Writable);f.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;if(e)this.emit("error",e);this.emit("close")};f.prototype._write=function(e,t,r){if(this.destroyed)return;var n=!this._str||!this._str._writableState.needDrain;while(e.length&&!this.destroyed){if(!this._missing){this._writeBuffer=e;this._writeCb=r;return}var i=e.length<this._missing?e.length:this._missing;if(this._buf)e.copy(this._buf,this._buf.length-this._missing);else if(this._str)n=this._str.write(i===e.length?e:e.slice(0,i));this._missing-=i;if(!this._missing){var o=this._buf;var s=this._cb;var f=this._str;this._buf=this._cb=this._str=this._ondrain=null;n=true;if(f)f.end();if(s)s(o)}e=i===e.length?a:e.slice(i)}if(this._pending&&!this._missing){this._writeBuffer=e;this._writeCb=r;return}if(n)r();else this._ondrain(r)};f.prototype._buffer=function(e,t){this._missing=e;this._buf=new r(e);this._cb=t};f.prototype._stream=function(e,t){var r=this;this._missing=e;this._str=new u(this);this._ondrain=o(this._str,"drain");this._pending++;this._str.on("end",function(){r._pending--;r._kick()});this._cb=t;return this._str};f.prototype._readBox=function(){var e=this;t(8);function t(n,i){e._buffer(n,function(n){if(i){i=r.concat(i,n)}else{i=n}var o=s.readHeaders(i);if(typeof o==="number"){t(o-i.length,i)}else{e._pending++;e._headers=o;e.emit("box",o)}})}};f.prototype.stream=function(){var e=this;if(!e._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=e._headers;e._headers=null;return e._stream(t.contentLen,null)};f.prototype.decode=function(e){var t=this;if(!t._headers)throw new Error("this function can only be called once after 'box' is emitted");var r=t._headers;t._headers=null;t._buffer(r.contentLen,function(n){var i=s.decodeWithoutHeaders(r,n);e(i);t._pending--;t._kick()})};f.prototype.ignore=function(){var e=this;if(!e._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=e._headers;e._headers=null;this._missing=t.contentLen;this._cb=function(){e._pending--;e._kick()}};f.prototype._kick=function(){if(this._pending)return;if(!this._buf&&!this._str)this._readBox();if(this._writeBuffer){var e=this._writeCb;var t=this._writeBuffer;this._writeBuffer=null;this._writeCb=null;this._write(t,null,e)}};function u(e){this._parent=e;this.destroyed=false;n.PassThrough.call(this)}i.inherits(u,n.PassThrough);u.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;this._parent.destroy(e);if(e)this.emit("error",e);this.emit("close")}}).call(this,e("buffer").Buffer)},{buffer:25,"mp4-box-encoding":164,"next-event":169,"readable-stream":180,util:63}],167:[function(e,t,r){(function(r,n){var i=e("readable-stream");var o=e("util");var s=e("mp4-box-encoding");t.exports=f;function a(){}function f(){if(!(this instanceof f))return new f;i.Readable.call(this);this.destroyed=false;this._reading=false;this._stream=null;this._drain=null;this._want=false;this._onreadable=t;this._onend=r;var e=this;function t(){if(!e._want)return;e._want=false;e._read()}function r(){e._stream=null}}o.inherits(f,i.Readable);f.prototype.mediaData=f.prototype.mdat=function(e,t){var r=new u(this);this.box({type:"mdat",contentLength:e,encodeBufferLen:8,stream:r},t);return r};f.prototype.box=function(e,t){if(!t)t=a;if(this.destroyed)return t(new Error("Encoder is destroyed"));var i;if(e.encodeBufferLen){i=new n(e.encodeBufferLen)}if(e.stream){e.buffer=null;i=s.encode(e,i);this.push(i);this._stream=e.stream;this._stream.on("readable",this._onreadable);this._stream.on("end",this._onend);this._stream.on("end",t);this._forward()}else{i=s.encode(e,i);var o=this.push(i);if(o)return r.nextTick(t);this._drain=t}};f.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;if(this._stream&&this._stream.destroy)this._stream.destroy();this._stream=null;if(this._drain){var t=this._drain;this._drain=null;t(e)}if(e)this.emit("error",e);this.emit("close")};f.prototype.finalize=function(){this.push(null)};f.prototype._forward=function(){if(!this._stream)return;while(!this.destroyed){var e=this._stream.read();if(!e){this._want=!!this._stream;return}if(!this.push(e))return}};f.prototype._read=function(){if(this._reading||this.destroyed)return;this._reading=true;if(this._stream)this._forward();if(this._drain){var e=this._drain;this._drain=null;e()}this._reading=false};function u(e){this._parent=e;this.destroyed=false;i.PassThrough.call(this)}o.inherits(u,i.PassThrough);u.prototype.destroy=function(e){if(this.destroyed)return;this.destroyed=true;this._parent.destroy(e);if(e)this.emit("error",e);this.emit("close")}}).call(this,e("_process"),e("buffer").Buffer)},{_process:34,buffer:25,"mp4-box-encoding":164,"readable-stream":180,util:63}],168:[function(e,t,r){r.decode=e("./decode");r.encode=e("./encode")},{"./decode":166,"./encode":167}],169:[function(e,t,r){t.exports=n;function n(e,t){var r=null;e.on(t,function(e){if(!r)return;var t=r;r=null;t(e)});return function(e){r=e}}},{}],170:[function(e,t,r){arguments[4][40][0].apply(r,arguments)},{"./_stream_readable":172,"./_stream_writable":174,"core-util-is":175,dup:40,inherits:115,"process-nextick-args":177}],171:[function(e,t,r){arguments[4][41][0].apply(r,arguments)},{"./_stream_transform":173,"core-util-is":175,dup:41,inherits:115}],172:[function(e,t,r){arguments[4][42][0].apply(r,arguments)},{"./_stream_duplex":170,_process:34,buffer:25,"core-util-is":175,dup:42,events:29,inherits:115,isarray:176,"process-nextick-args":177,"string_decoder/":178,util:24}],173:[function(e,t,r){arguments[4][43][0].apply(r,arguments)},{"./_stream_duplex":170,"core-util-is":175,dup:43,inherits:115}],174:[function(e,t,r){arguments[4][44][0].apply(r,arguments)},{"./_stream_duplex":170,buffer:25,"core-util-is":175,dup:44,events:29,inherits:115,"process-nextick-args":177,"util-deprecate":179}],175:[function(e,t,r){(function(e){function t(e){if(Array.isArray){return Array.isArray(e)}return v(e)==="[object Array]"}r.isArray=t;function n(e){return typeof e==="boolean"}r.isBoolean=n;function i(e){return e===null}r.isNull=i;function o(e){return e==null}r.isNullOrUndefined=o;function s(e){return typeof e==="number"}r.isNumber=s;function a(e){return typeof e==="string"}r.isString=a;function f(e){return typeof e==="symbol"}r.isSymbol=f;function u(e){return e===void 0}r.isUndefined=u;function c(e){return v(e)==="[object RegExp]"}r.isRegExp=c;function l(e){return typeof e==="object"&&e!==null}r.isObject=l;function d(e){return v(e)==="[object Date]"}r.isDate=d;function h(e){return v(e)==="[object Error]"||e instanceof Error}r.isError=h;function p(e){return typeof e==="function"}r.isFunction=p;function m(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=m;r.isBuffer=e.isBuffer;function v(e){return Object.prototype.toString.call(e)}}).call(this,{isBuffer:e("../../../../../../../../../../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js")})},{"../../../../../../../../../../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js":31}],176:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],177:[function(e,t,r){arguments[4][46][0].apply(r,arguments)},{_process:34,dup:46}],178:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{buffer:25,dup:59}],179:[function(e,t,r){arguments[4][47][0].apply(r,arguments)},{dup:47}],180:[function(e,t,r){arguments[4][49][0].apply(r,arguments)},{"./lib/_stream_duplex.js":170,"./lib/_stream_passthrough.js":171,"./lib/_stream_readable.js":172,"./lib/_stream_transform.js":173,"./lib/_stream_writable.js":174,dup:49}],181:[function(e,t,r){var n=e("inherits");var i=e("stream");t.exports=o;n(o,i.Writable);function o(e){var t=this;if(!(t instanceof o))return new o(e);i.Writable.call(t);t.destroyed=false;t._queue=[];t._position=e||0;t._cb=null;t._buffer=null;t._out=null}o.prototype._write=function(e,t,r){var n=this;var i=true;while(true){if(n.destroyed){return}if(n._queue.length===0){n._buffer=e;n._cb=r;return}n._buffer=null;var o=n._queue[0];var s=Math.max(o.start-n._position,0);var a=o.end-n._position;if(s>=e.length){n._position+=e.length;return r(null)}var f;if(a>e.length){n._position+=e.length;if(s===0){f=e}else{f=e.slice(s)}i=o.stream.write(f)&&i;break}n._position+=a;if(s===0&&a===e.length){f=e}else{f=e.slice(s,a)}i=o.stream.write(f)&&i;if(o.last){o.stream.end()}e=e.slice(a);n._queue.shift()}if(i){r(null)}else{o.stream.once("drain",r.bind(null,null))}};o.prototype.slice=function(e){var t=this;if(t.destroyed)return null;if(!(e instanceof Array)){e=[e]}var r=new i.PassThrough;e.forEach(function(n,i){t._queue.push({start:n.start,end:n.end,stream:r,last:i===e.length-1})});if(t._buffer){t._write(t._buffer,null,t._cb)}return r};o.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;if(e)t.emit("error",e)}},{inherits:115,stream:52}],182:[function(e,t,r){var n=e("events");var i=e("inherits");var o=e("mediasource");var s=e("pump");var a=e("./mp4-remuxer");t.exports=f;function f(e,t,r){var i=this;if(!(this instanceof f))return new f(e,t,r);r=r||{};n.call(i);i._elem=t;i._elemWrapper=new o(t);i._muxer=new a(e);i._tracks=null;i._onWaiting=function(){if(i._tracks){var e=i._muxer.seek(i._elem.currentTime);i._tracks.forEach(function(t,r){t.muxed.destroy();t.muxed=e[r];t.mediaSource=i._elemWrapper.createWriteStream(t.mediaSource)});i._pump()}};i._elem.addEventListener("waiting",i._onWaiting);i._muxer.on("ready",function(e){var t=i._muxer.seek(0,true);i._tracks=e.map(function(e,r){return{muxed:t[r],mediaSource:i._elemWrapper.createWriteStream(e.mime)}});i._pump()});i._muxer.on("error",i.emit.bind(i,"error"))}i(f,n);f.prototype._pump=function(){var e=this;e._tracks.forEach(function(t){s(t.muxed,t.mediaSource,function(t){if(t&&t.message!=="premature close"){e.emit("error",t)}})})};f.prototype.destroy=function(e){var t=this;if(t.destroyed){return}t.destroyed=true;t._elem.removeEventListener("waiting",t._onWaiting);if(t._tracks){t._tracks.forEach(function(e){e.muxed.destroy()})}t._elem.src="";if(e)t.emit("error",e)}},{"./mp4-remuxer":160,events:29,inherits:115,mediasource:147,pump:128}],183:[function(e,t,r){(function(e){t.exports=function(t,r,n){if(typeof r!=="number")throw new Error("second argument must be a Number");var i,o,s,a,f;var u=true;if(Array.isArray(t)){i=[];s=o=t.length}else{a=Object.keys(t);i={};s=o=a.length}function c(t){function r(){if(n)n(t,i);n=null}if(u)e.nextTick(r);else r()}function l(e,r,n){i[e]=n;if(r)f=true;if(--s===0||r){c(r)}else if(!f&&d<o){var u;if(a){u=a[d];d+=1;t[u](l.bind(undefined,u))}else{u=d;d+=1;t[u](l.bind(undefined,u))}}}var d=r;if(!s){c(null)}else if(a){a.some(function(e,n){t[e](l.bind(undefined,e));if(n===r-1)return true})}else{t.some(function(e,t){e(l.bind(undefined,t));if(t===r-1)return true})}u=false}}).call(this,e("_process"))},{_process:34}],184:[function(e,t,r){(function(e){t.exports=function(t,r){var n,i,o;var s=true;if(Array.isArray(t)){n=[];i=t.length}else{o=Object.keys(t);n={};i=o.length}function a(t){function i(){if(r)r(t,n);r=null}if(s)e.nextTick(i);else i()}function f(e,t,r){n[e]=r;if(--i===0||t){a(t)}}if(!i){a(null)}else if(o){o.forEach(function(e){t[e](f.bind(undefined,e))})}else{t.forEach(function(e,t){e(f.bind(undefined,t))})}s=false}}).call(this,e("_process"))},{_process:34}],185:[function(e,t,r){(function(r){t.exports=u;var n=e("xtend");var i=e("http");var o=e("https");var s=e("once");var a=e("unzip-response");var f=e("url");function u(e,t){e=typeof e==="string"?{url:e}:n(e);t=s(t);if(e.url)c(e);if(e.headers==null)e.headers={};if(e.maxRedirects==null)e.maxRedirects=10;var r=e.body;e.body=undefined;if(r&&!e.method)e.method="POST";var f=Object.keys(e.headers).some(function(e){return e.toLowerCase()==="accept-encoding"});if(!f)e.headers["accept-encoding"]="gzip, deflate";var l=e.protocol==="https:"?o:i;var d=l.request(e,function(r){if(r.statusCode>=300&&r.statusCode<400&&"location"in r.headers){e.url=r.headers.location;c(e);r.resume();e.maxRedirects-=1;if(e.maxRedirects>0)u(e,t);else t(new Error("too many redirects"));return}t(null,typeof a==="function"?a(r):r)});d.on("error",t);d.end(r);return d}t.exports.concat=function(e,t){return u(e,function(e,n){if(e)return t(e);var i=[];n.on("data",function(e){i.push(e)});n.on("end",function(){t(null,r.concat(i),n)})})};["get","post","put","patch","head","delete"].forEach(function(e){t.exports[e]=function(t,r){if(typeof t==="string")t={url:t};t.method=e.toUpperCase();return u(t,r)}});function c(e){var t=f.parse(e.url);if(t.hostname)e.hostname=t.hostname;if(t.port)e.port=t.port;if(t.protocol)e.protocol=t.protocol;e.path=t.path;delete e.url}}).call(this,e("buffer").Buffer)},{buffer:25,http:53,https:30,once:187,"unzip-response":24,url:60,xtend:210}],186:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],187:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,wrappy:186}],188:[function(e,t,r){(function(r){t.exports=c;var n=e("debug")("simple-peer");var i=e("get-browser-rtc");var o=e("hat");var s=e("inherits");var a=e("is-typedarray");var f=e("once");var u=e("stream");s(c,u.Duplex);function c(e){var t=this;if(!(t instanceof c))return new c(e);t._debug("new peer %o",e);if(!e)e={};e.allowHalfOpen=false;if(e.highWaterMark==null)e.highWaterMark=1024*1024;u.Duplex.call(t,e);t.initiator=e.initiator||false;t.channelConfig=e.channelConfig||c.channelConfig;t.channelName=e.initiator?e.channelName||o(160):null;t.config=e.config||c.config;t.constraints=e.constraints||c.constraints;t.offerConstraints=e.offerConstraints;t.answerConstraints=e.answerConstraints;t.reconnectTimer=e.reconnectTimer||false;t.sdpTransform=e.sdpTransform||function(e){return e};t.stream=e.stream||false;t.trickle=e.trickle!==undefined?e.trickle:true;t.destroyed=false;t.connected=false;t.remoteAddress=undefined;t.remoteFamily=undefined;t.remotePort=undefined;t.localAddress=undefined;t.localPort=undefined;t._isWrtc=!!e.wrtc;t._wrtc=e.wrtc||i();if(!t._wrtc){if(typeof window==="undefined"){throw new Error("No WebRTC support: Specify `opts.wrtc` option in this environment")}else{throw new Error("No WebRTC support: Not a supported browser")}}t._maxBufferedAmount=e.highWaterMark;t._pcReady=false;t._channelReady=false;t._iceComplete=false;t._channel=null;t._pendingCandidates=[];t._chunk=null;t._cb=null;t._interval=null;t._reconnectTimeout=null;t._pc=new t._wrtc.RTCPeerConnection(t.config,t.constraints);t._pc.oniceconnectionstatechange=t._onIceConnectionStateChange.bind(t);t._pc.onsignalingstatechange=t._onSignalingStateChange.bind(t);t._pc.onicecandidate=t._onIceCandidate.bind(t);if(t.stream)t._pc.addStream(t.stream);t._pc.onaddstream=t._onAddStream.bind(t);if(t.initiator){t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)});t._pc.onnegotiationneeded=f(t._createOffer.bind(t));if(typeof window==="undefined"||!window.webkitRTCPeerConnection){t._pc.onnegotiationneeded()}}else{t._pc.ondatachannel=t._setupData.bind(t)}t.on("finish",function(){if(t.connected){setTimeout(function(){t._destroy()},100)}else{t.once("connect",function(){setTimeout(function(){t._destroy()},100)})}})}c.WEBRTC_SUPPORT=!!i();c.config={iceServers:[{url:"stun:23.21.150.121",urls:"stun:23.21.150.121"}]};c.constraints={};c.channelConfig={};Object.defineProperty(c.prototype,"bufferSize",{get:function(){var e=this;return e._channel&&e._channel.bufferedAmount||0}});c.prototype.address=function(){var e=this;return{port:e.localPort,family:"IPv4",address:e.localAddress}};c.prototype.signal=function(e){var t=this;if(t.destroyed)throw new Error("cannot signal after peer is destroyed");if(typeof e==="string"){try{e=JSON.parse(e)}catch(r){e={}}}t._debug("signal()");function n(e){try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e),l,t._onError.bind(t))}catch(r){t._destroy(new Error("error adding candidate: "+r.message))}}if(e.sdp){t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e),function(){if(t.destroyed)return;if(t._pc.remoteDescription.type==="offer")t._createAnswer();t._pendingCandidates.forEach(n);t._pendingCandidates=[]},t._onError.bind(t))}if(e.candidate){if(t._pc.remoteDescription)n(e.candidate);else t._pendingCandidates.push(e.candidate)}if(!e.sdp&&!e.candidate){t._destroy(new Error("signal() called with invalid signal data"))}};c.prototype.send=function(e){var t=this;if(!a.strict(e)&&!(e instanceof ArrayBuffer)&&!r.isBuffer(e)&&typeof e!=="string"&&(typeof Blob==="undefined"||!(e instanceof Blob))){e=JSON.stringify(e)}if(r.isBuffer(e)&&t._isWrtc){e=new Uint8Array(e)}var n=e.length||e.byteLength||e.size;t._channel.send(e);t._debug("write: %d bytes",n)};c.prototype.destroy=function(e){var t=this;t._destroy(null,e)};c.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);r._debug("destroy (error: %s)",e&&e.message);r.readable=r.writable=false;if(!r._readableState.ended)r.push(null);if(!r._writableState.finished)r.end();r.destroyed=true;r.connected=false;r._pcReady=false;r._channelReady=false;r._chunk=null;r._cb=null;clearInterval(r._interval);clearTimeout(r._reconnectTimeout);if(r._pc){try{r._pc.close()}catch(e){}r._pc.oniceconnectionstatechange=null;r._pc.onsignalingstatechange=null;r._pc.onicecandidate=null}if(r._channel){try{r._channel.close()}catch(e){}r._channel.onmessage=null;r._channel.onopen=null;r._channel.onclose=null}r._pc=null;r._channel=null;if(e)r.emit("error",e);r.emit("close")};c.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)};c.prototype._read=function(){};c.prototype._write=function(e,t,r){var n=this;if(n.destroyed)return r(new Error("cannot write after peer is destroyed"));if(n.connected){try{n.send(e)}catch(i){return n._onError(i)}if(n._channel.bufferedAmount>n._maxBufferedAmount){n._debug("start backpressure: bufferedAmount %d",n._channel.bufferedAmount);n._cb=r}else{r(null)}}else{n._debug("write before connect");n._chunk=e;n._cb=r}};c.prototype._createOffer=function(){var e=this;if(e.destroyed)return;e._pc.createOffer(function(t){if(e.destroyed)return;t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,l,e._onError.bind(e));var r=function(){var r=e._pc.localDescription||t;e._debug("signal");e.emit("signal",{type:r.type,sdp:r.sdp})};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.offerConstraints)};c.prototype._createAnswer=function(){var e=this;if(e.destroyed)return;e._pc.createAnswer(function(t){if(e.destroyed)return;t.sdp=e.sdpTransform(t.sdp);e._pc.setLocalDescription(t,l,e._onError.bind(e));var r=function(){var r=e._pc.localDescription||t;e._debug("signal");e.emit("signal",{type:r.type,sdp:r.sdp})};if(e.trickle||e._iceComplete)r();else e.once("_iceComplete",r)},e._onError.bind(e),e.answerConstraints)};c.prototype._onIceConnectionStateChange=function(){var e=this;if(e.destroyed)return;var t=e._pc.iceGatheringState;var r=e._pc.iceConnectionState;e._debug("iceConnectionStateChange %s %s",t,r);e.emit("iceConnectionStateChange",t,r);if(r==="connected"||r==="completed"){clearTimeout(e._reconnectTimeout);e._pcReady=true;e._maybeReady()}if(r==="disconnected"){if(e.reconnectTimer){clearTimeout(e._reconnectTimeout);e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)}else{e._destroy()}}if(r==="failed"){e._destroy()}if(r==="closed"){e._destroy()}};c.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady);if(e.connected||e._connecting||!e._pcReady||!e._channelReady)return;e._connecting=true;if(!e._pc.getStats){t([])}else if(typeof window!=="undefined"&&!!window.mozRTCPeerConnection){e._pc.getStats(null,function(e){var r=[];e.forEach(function(e){r.push(e)});t(r)},e._onError.bind(e))}else{e._pc.getStats(function(e){var r=[];e.result().forEach(function(e){var t={};e.names().forEach(function(r){t[r]=e.stat(r)});t.id=e.id;t.type=e.type;t.timestamp=e.timestamp;r.push(t)});t(r)})}function t(t){t.forEach(function(t){if(t.type==="remotecandidate"&&t.candidateType==="host"){e.remoteAddress=t.ipAddress;e.remotePort=Number(t.portNumber);e.remoteFamily="IPv4";e._debug("connect remote: %s:%s (%s)",e.remoteAddress,e.remotePort,e.remoteFamily)}else if(t.type==="localcandidate"&&t.candidateType==="host"){e.localAddress=t.ipAddress;e.localPort=Number(t.portNumber);e._debug("connect local: %s:%s",e.localAddress,e.localPort)}});e._connecting=false;e.connected=true;if(e._chunk){try{e.send(e._chunk)}catch(r){return e._onError(r)}e._chunk=null;e._debug('sent chunk from "write before connect"');var n=e._cb;e._cb=null;n(null)}e._interval=setInterval(function(){if(!e._cb||!e._channel||e._channel.bufferedAmount>e._maxBufferedAmount)return;e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref();e._debug("connect");e.emit("connect")}};c.prototype._onSignalingStateChange=function(){var e=this;if(e.destroyed)return;e._debug("signalingStateChange %s",e._pc.signalingState);e.emit("signalingStateChange",e._pc.signalingState)};c.prototype._onIceCandidate=function(e){var t=this;if(t.destroyed)return;if(e.candidate&&t.trickle){t.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}})}else if(!e.candidate){t._iceComplete=true;t.emit("_iceComplete")}};c.prototype._onChannelMessage=function(e){var t=this;if(t.destroyed)return;var n=e.data;t._debug("read: %d bytes",n.byteLength||n.length);if(n instanceof ArrayBuffer){n=new r(n);t.push(n)}else{try{n=JSON.parse(n)}catch(i){}t.emit("data",n)}};c.prototype._onChannelOpen=function(){var e=this;if(e.connected||e.destroyed)return;e._debug("on channel open");e._channelReady=true;e._maybeReady()};c.prototype._onChannelClose=function(){var e=this;if(e.destroyed)return;e._debug("on channel close");e._destroy()};c.prototype._onAddStream=function(e){var t=this;if(t.destroyed)return;t._debug("on add stream");t.emit("stream",e.stream)};c.prototype._onError=function(e){var t=this;if(t.destroyed)return;t._debug("error %s",e.message||e);t._destroy(e)};c.prototype._debug=function(){var e=this;var t=[].slice.call(arguments);var r=e.channelName&&e.channelName.substring(0,7);t[0]="["+r+"] "+t[0];n.apply(null,t)};function l(){}}).call(this,e("buffer").Buffer)},{buffer:25,debug:107,"get-browser-rtc":189,hat:113,inherits:115,"is-typedarray":190,once:192,stream:52}],189:[function(e,t,r){t.exports=function n(){if(typeof window==="undefined")return null;var e={RTCPeerConnection:window.mozRTCPeerConnection||window.RTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.mozRTCSessionDescription||window.RTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.mozRTCIceCandidate||window.RTCIceCandidate||window.webkitRTCIceCandidate};if(!e.RTCPeerConnection)return null;return e}},{}],190:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],191:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],192:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,wrappy:191}],193:[function(e,t,r){var n=e("rusha");var i=new n;var o=window.crypto||window.msCrypto||{};var s=o.subtle||o.webkitSubtle;var a=i.digest.bind(i);try{s.digest({name:"sha-1"},new Uint8Array).catch(function(){s=false})}catch(f){s=false}function u(e,t){if(!s){setTimeout(t,0,a(e));return}if(typeof e==="string"){e=c(e)}s.digest({name:"sha-1"},e).then(function r(e){t(l(new Uint8Array(e)))},function n(r){t(a(e))})}function c(e){var t=e.length;var r=new Uint8Array(t);for(var n=0;n<t;n++){r[n]=e.charCodeAt(n)}return r}function l(e){var t=e.length;var r=[];for(var n=0;n<t;n++){var i=e[n];r.push((i>>>4).toString(16));r.push((i&15).toString(16))}return r.join("")}t.exports=u;t.exports.sync=a},{rusha:194}],194:[function(e,t,r){(function(e){(function(){var r={getDataType:function(t){if(typeof t==="string"){return"string"}if(t instanceof Array){return"array"}if(typeof e!=="undefined"&&e.Buffer&&e.Buffer.isBuffer(t)){return"buffer"}if(t instanceof ArrayBuffer){return"arraybuffer"}if(t.buffer instanceof ArrayBuffer){return"view"}if(t instanceof Blob){return"blob"}throw new Error("Unsupported data type.")}};function n(e){"use strict";var t={fill:0};var o=function(e){for(e+=9;e%64>0;e+=1);return e};var s=function(e,t){for(var r=t>>2;r<e.length;r++)e[r]=0};var a=function(e,t,r){e[t>>2]|=128<<24-(t%4<<3);e[((t>>2)+2&~15)+14]=r>>29;e[((t>>2)+2&~15)+15]=r<<3};var f=function(e,t,r,n,i){var o=this,s,a=i%4,f=n%4,u=n-f;if(u>0){switch(a){case 0:e[i+3|0]=o.charCodeAt(r);case 1:e[i+2|0]=o.charCodeAt(r+1);case 2:e[i+1|0]=o.charCodeAt(r+2);case 3:e[i|0]=o.charCodeAt(r+3)}}for(s=a;s<u;s=s+4|0){t[i+s>>2]=o.charCodeAt(r+s)<<24|o.charCodeAt(r+s+1)<<16|o.charCodeAt(r+s+2)<<8|o.charCodeAt(r+s+3)}switch(f){case 3:e[i+u+1|0]=o.charCodeAt(r+u+2);case 2:e[i+u+2|0]=o.charCodeAt(r+u+1);case 1:e[i+u+3|0]=o.charCodeAt(r+u)}};var u=function(e,t,r,n,i){var o=this,s,a=i%4,f=n%4,u=n-f;if(u>0){switch(a){case 0:e[i+3|0]=o[r];case 1:e[i+2|0]=o[r+1];case 2:e[i+1|0]=o[r+2];case 3:e[i|0]=o[r+3]}}for(s=4-a;s<u;s=s+=4|0){t[i+s>>2]=o[r+s]<<24|o[r+s+1]<<16|o[r+s+2]<<8|o[r+s+3]}switch(f){case 3:e[i+u+1|0]=o[r+u+2];case 2:e[i+u+2|0]=o[r+u+1];case 1:e[i+u+3|0]=o[r+u]}};var c=function(e,t,r,n,o){var s=this,a,f=o%4,u=n%4,c=n-u;var l=new Uint8Array(i.readAsArrayBuffer(s.slice(r,r+n)));if(c>0){switch(f){case 0:e[o+3|0]=l[0];case 1:e[o+2|0]=l[1];case 2:e[o+1|0]=l[2];case 3:e[o|0]=l[3]}}for(a=4-f;a<c;a=a+=4|0){t[o+a>>2]=l[a]<<24|l[a+1]<<16|l[a+2]<<8|l[a+3]}switch(u){case 3:e[o+c+1|0]=l[c+2];case 2:e[o+c+2|0]=l[c+1];case 1:e[o+c+3|0]=l[c]}};var l=function(e){switch(r.getDataType(e)){case"string":return f.bind(e);case"array":return u.bind(e);case"buffer":return u.bind(e);case"arraybuffer":return u.bind(new Uint8Array(e));case"view":return u.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return c.bind(e)}};var d=function(e,t){switch(r.getDataType(e)){case"string":return e.slice(t);case"array":return e.slice(t);case"buffer":return e.slice(t);case"arraybuffer":return e.slice(t);case"view":return e.buffer.slice(t)}};var h=function(e){var t,r,n="0123456789abcdef",i=[],o=new Uint8Array(e);for(t=0;t<o.length;t++){r=o[t];i[t]=n.charAt(r>>4&15)+n.charAt(r>>0&15)}return i.join("")};var p=function(e){var t;if(e<=65536)return 65536;if(e<16777216){for(t=1;t<e;t=t<<1);}else{for(t=16777216;t<e;t+=16777216);}return t};var m=function(e){if(e%64>0){throw new Error("Chunk size must be a multiple of 128 bit")}t.maxChunkLen=e;t.padMaxChunkLen=o(e);t.heap=new ArrayBuffer(p(t.padMaxChunkLen+320+20));t.h32=new Int32Array(t.heap);t.h8=new Int8Array(t.heap);t.core=new n._core({Int32Array:Int32Array,DataView:DataView},{},t.heap);t.buffer=null};m(e||64*1024);var v=function(e,t){var r=new Int32Array(e,t+320,5);r[0]=1732584193;r[1]=-271733879;r[2]=-1732584194;r[3]=271733878;r[4]=-1009589776};var g=function(e,r){var n=o(e);var i=new Int32Array(t.heap,0,n>>2);s(i,e);a(i,e,r);return n};var y=function(e,r,n){l(e)(t.h8,t.h32,r,n,0)};var _=function(e,r,n,i,o){var s=n;if(o){s=g(n,i)}y(e,r,n);t.core.hash(s,t.padMaxChunkLen)};var b=function(e,t){var r=new Int32Array(e,t+320,5);var n=new Int32Array(5);var i=new DataView(n.buffer);i.setInt32(0,r[0],false);i.setInt32(4,r[1],false);i.setInt32(8,r[2],false);i.setInt32(12,r[3],false);i.setInt32(16,r[4],false);return n};var w=this.rawDigest=function(e){var r=e.byteLength||e.length||e.size||0;v(t.heap,t.padMaxChunkLen);var n=0,i=t.maxChunkLen,o;for(n=0;r>n+i;n+=i){_(e,n,i,r,false)}_(e,n,r-n,r,true);return b(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return h(w(e).buffer)}}n._core=function s(e,t,r){"use asm";var n=new e.Int32Array(r);function i(e,t){e=e|0;t=t|0;var r=0,i=0,o=0,s=0,a=0,f=0,u=0,c=0,l=0,d=0,h=0,p=0,m=0,v=0;o=n[t+320>>2]|0;a=n[t+324>>2]|0;u=n[t+328>>2]|0;l=n[t+332>>2]|0;h=n[t+336>>2]|0;for(r=0;(r|0)<(e|0);r=r+64|0){s=o;f=a;c=u;d=l;p=h;for(i=0;(i|0)<64;i=i+4|0){v=n[r+i>>2]|0;m=((o<<5|o>>>27)+(a&u|~a&l)|0)+((v+h|0)+1518500249|0)|0;h=l;l=u;u=a<<30|a>>>2;a=o;o=m;n[e+i>>2]=v}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){v=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;m=((o<<5|o>>>27)+(a&u|~a&l)|0)+((v+h|0)+1518500249|0)|0;h=l;l=u;u=a<<30|a>>>2;a=o;o=m;n[i>>2]=v}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){v=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;m=((o<<5|o>>>27)+(a^u^l)|0)+((v+h|0)+1859775393|0)|0;h=l;l=u;u=a<<30|a>>>2;a=o;o=m;n[i>>2]=v}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){v=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;m=((o<<5|o>>>27)+(a&u|a&l|u&l)|0)+((v+h|0)-1894007588|0)|0;h=l;l=u;u=a<<30|a>>>2;a=o;o=m;n[i>>2]=v}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){v=(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])<<1|(n[i-12>>2]^n[i-32>>2]^n[i-56>>2]^n[i-64>>2])>>>31;m=((o<<5|o>>>27)+(a^u^l)|0)+((v+h|0)-899497514|0)|0;h=l;l=u;u=a<<30|a>>>2;a=o;o=m;n[i>>2]=v}o=o+s|0;a=a+f|0;u=u+c|0;l=l+d|0;h=h+p|0}n[t+320>>2]=o;n[t+324>>2]=a;n[t+328>>2]=u;n[t+332>>2]=l;n[t+336>>2]=h}return{hash:i}};if(typeof t!=="undefined"){t.exports=n}else if(typeof window!=="undefined"){window.Rusha=n}if(typeof FileReaderSync!=="undefined"){var i=new FileReaderSync,o=new n(4*1024*1024);self.onmessage=function a(e){var t,r=e.data.data;try{t=o.digest(r);self.postMessage({id:e.data.id,hash:t})}catch(n){self.postMessage({id:e.data.id,error:n.name})}}}})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],195:[function(e,t,r){var n=1;var i=65535;var o=4;var s=function(){n=n+1&i};var a=setInterval(s,1e3/o|0);if(a.unref)a.unref();t.exports=function(e){var t=o*(e||5);var r=[0];var s=1;var a=n-1&i;return function(e){var f=n-a&i;if(f>t)f=t;a=n;while(f--){if(s===t)s=0;r[s]=r[s===0?t-1:s-1];s++}if(e)r[s-1]+=e;var u=r[s-1];var c=r.length<t?0:r[s===t?0:s];return r.length<o?u:(u-c)*o/r.length}}},{}],196:[function(e,t,r){var n=e("once");t.exports=function i(e,t,r){r=n(r);var i=[];e.on("data",function(e){i.push(e)}).on("end",function(){var e=t?new Blob(i,{type:t}):new Blob(i);var n=URL.createObjectURL(e);r(null,n)}).on("error",r)}},{once:198}],197:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],198:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,wrappy:197}],199:[function(e,t,r){(function(r){var n=e("once");t.exports=function i(e,t,o){o=n(o);var s=new r(t);var a=0;e.on("data",function(e){e.copy(s,a);a+=e.length}).on("end",function(){o(null,s)}).on("error",o)}}).call(this,e("buffer").Buffer)},{buffer:25,once:201}],200:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{dup:19}],201:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{dup:20,wrappy:200}],202:[function(e,t,r){(function(r,n){t.exports=d;var i=e("debug")("torrent-discovery");var o=e("bittorrent-dht/client");var s=e("events").EventEmitter;var a=e("xtend");var f=e("inherits");var u=e("run-parallel");var c=e("re-emitter");var l=e("bittorrent-tracker/client");f(d,s);function d(e){var t=this;if(!(t instanceof d))return new d(e);s.call(t);t.announce=e.announce||[];t.rtcConfig=e.rtcConfig;t.peerId=e.peerId;t.port=e.port||0;
+t.wrtc=e.wrtc;t.intervalMs=e.intervalMs||15*60*1e3;if(!t.peerId)throw new Error("peerId required");if(!r.browser&&!t.port)throw new Error("port required");t.infoHash=null;t.infoHashBuffer=null;t.torrent=null;t._dhtAnnouncing=false;t._dhtTimeout=false;t._internalDHT=false;if(e.tracker===false){t.tracker=false}else{t.tracker=true}if(e.dht===false){t.dht=false}else if(typeof e.dht==="object"){t.dht=e.dht}else{t.dht=n()}if(t.dht){c(t.dht,t,["error","warning"]);t.dht.on("peer",i)}function n(){if(typeof o!=="function")return false;t._internalDHT=true;var r=new o;r.listen(e.dhtPort);return r}function i(e,r){if(r.toString("hex")!==t.infoHash)return;t.emit("peer",e.host+":"+e.port)}}d.prototype.setTorrent=function(e){var t=this;if(!t.infoHash&&(typeof e==="string"||n.isBuffer(e))){t.infoHash=typeof e==="string"?e:e.toString("hex")}else if(!t.torrent&&e&&e.infoHash){t.torrent=e;t.infoHash=typeof e.infoHash==="string"?e.infoHash:e.infoHash.toString("hex")}else{return}t.infoHashBuffer=new n(t.infoHash,"hex");i("setTorrent %s",t.infoHash);if(t.tracker&&t.tracker!==true){t.tracker.torrentLength=e.length}else{t._createTracker()}t._dhtAnnounce()};d.prototype.updatePort=function(e){var t=this;if(e===t.port)return;t.port=e;t._dhtAnnounce();if(t.tracker&&t.tracker!==true){t.tracker.stop();t.tracker.destroy(function(){t._createTracker()})}};d.prototype.stop=function(e){var t=this;var r=[];clearTimeout(t._dhtTimeout);if(t.tracker&&t.tracker!==true){t.tracker.stop();r.push(function(e){t.tracker.destroy(e)})}if(t._internalDHT){r.push(function(e){t.dht.destroy(e)})}u(r,e)};d.prototype._createTracker=function(){var e=this;if(!e.tracker)return;var t=e.torrent?a({announce:[]},e.torrent):{infoHash:e.infoHash,announce:[]};if(e.announce)t.announce=t.announce.concat(e.announce);var r={rtcConfig:e.rtcConfig,wrtc:e.wrtc};e.tracker=new l(e.peerId,e.port,t,r);c(e.tracker,e,["peer","warning","error"]);e.tracker.setInterval(e.intervalMs);e.tracker.on("update",n);e.tracker.start();function n(t){e.emit("trackerAnnounce",t)}};d.prototype._dhtAnnounce=function(){var e=this;if(!e.port||!e.infoHash||!e.dht||e._dhtAnnouncing)return;e._dhtAnnouncing=true;e.dht.announce(e.infoHash,e.port,function(t){if(t)e.emit("warning",t);e._dhtAnnouncing=false;i("dht announce complete");e.emit("dhtAnnounce")});clearTimeout(e._dhtTimeout);e._dhtTimeout=setTimeout(function(){e._dhtAnnounce()},t());function t(){return e.intervalMs+Math.floor(Math.random()*e.intervalMs/5)}}}).call(this,e("_process"),e("buffer").Buffer)},{_process:34,"bittorrent-dht/client":24,"bittorrent-tracker/client":15,buffer:25,debug:107,events:29,inherits:115,"re-emitter":132,"run-parallel":184,xtend:210}],203:[function(e,t,r){(function(e){t.exports=n;var r=1<<14;function n(e){if(!(this instanceof n))return new n(e);this.length=e;this.missing=e;this.sources=null;this._chunks=Math.ceil(e/r);this._remainder=e%r||r;this._buffered=0;this._buffer=null;this._cancellations=null;this._reservations=0;this._flushed=false}n.BLOCK_LENGTH=r;n.prototype.chunkLength=function(e){return e===this._chunks-1?this._remainder:r};n.prototype.chunkOffset=function(e){return e*r};n.prototype.reserve=function(){if(!this.init())return-1;if(this._cancellations.length)return this._cancellations.pop();if(this._reservations<this._chunks)return this._reservations++;return-1};n.prototype.cancel=function(e){if(!this.init())return;this._cancellations.push(e)};n.prototype.get=function(e){if(!this.init())return null;return this._buffer[e]};n.prototype.set=function(e,t,r){if(!this.init())return false;if(!this._buffer[e]){this._buffered++;this._buffer[e]=t;this.missing-=t.length;if(this.sources.indexOf(r)===-1){this.sources.push(r)}}return this._buffered===this._chunks};n.prototype.flush=function(){if(!this._buffer||this._chunks!==this._buffered)return null;var t=e.concat(this._buffer,this.length);this._buffer=null;this._cancellations=null;this.sources=null;this._flushed=true;return t};n.prototype.init=function(){if(this._flushed)return false;if(this._buffer)return true;this._buffer=new Array(this._chunks);this._cancellations=[];this.sources=[];return true}}).call(this,e("buffer").Buffer)},{buffer:25}],204:[function(e,t,r){"use strict";function n(e,t){var r=1,n=e.length,i=e[0],o=e[0];for(var s=1;s<n;++s){o=i;i=e[s];if(t(i,o)){if(s===r){r++;continue}e[r++]=i}}e.length=r;return e}function i(e){var t=1,r=e.length,n=e[0],i=e[0];for(var o=1;o<r;++o,i=n){i=n;n=e[o];if(n!==i){if(o===t){t++;continue}e[t++]=n}}e.length=t;return e}function o(e,t,r){if(e.length===0){return e}if(t){if(!r){e.sort(t)}return n(e,t)}if(!r){e.sort()}return i(e)}t.exports=o},{}],205:[function(e,t,r){(function(r){var n=e("bencode");var i=e("bitfield");var o=e("events").EventEmitter;var s=e("inherits");var a=e("simple-sha1");var f=1e7;var u=1e3;var c=16*1024;t.exports=function(e){s(t,o);function t(t){o.call(this);this._wire=t;this._metadataComplete=false;this._metadataSize=null;this._remainingRejects=null;this._fetching=false;this._bitfield=new i(0,{grow:u});if(r.isBuffer(e)){this.setMetadata(e)}}t.prototype.name="ut_metadata";t.prototype.onHandshake=function(e,t,r){this._infoHash=e};t.prototype.onExtendedHandshake=function(e){if(!e.m||!e.m.ut_metadata){return this.emit("warning",new Error("Peer does not support ut_metadata"))}if(!e.metadata_size){return this.emit("warning",new Error("Peer does not have metadata"))}if(e.metadata_size>f){return this.emit("warning",new Error("Peer gave maliciously large metadata size"))}this._metadataSize=e.metadata_size;this._numPieces=Math.ceil(this._metadataSize/c);this._remainingRejects=this._numPieces*2;if(this._fetching){this._requestPieces()}};t.prototype.onMessage=function(e){var t,r;try{var i=e.toString();var o=i.indexOf("ee")+2;t=n.decode(i.substring(0,o));r=e.slice(o)}catch(s){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,r,t.total_size);break;case 2:this._onReject(t.piece);break}};t.prototype.fetch=function(){if(this._metadataComplete){return}this._fetching=true;if(this._metadataSize){this._requestPieces()}};t.prototype.cancel=function(){this._fetching=false};t.prototype.setMetadata=function(e){if(this._metadataComplete)return true;try{var t=n.decode(e).info;if(t){e=n.encode(t)}}catch(r){}if(this._infoHash&&this._infoHash!==a.sync(e)){return false}this.cancel();this.metadata=e;this._metadataComplete=true;this._metadataSize=this.metadata.length;this._wire.extendedHandshake.metadata_size=this._metadataSize;this.emit("metadata",n.encode({info:n.decode(this.metadata)}));return true};t.prototype._send=function(e,t){var i=n.encode(e);if(r.isBuffer(t)){i=r.concat([i,t])}this._wire.extended("ut_metadata",i)};t.prototype._request=function(e){this._send({msg_type:0,piece:e})};t.prototype._data=function(e,t,r){var n={msg_type:1,piece:e};if(typeof r==="number"){n.total_size=r}this._send(n,t)};t.prototype._reject=function(e){this._send({msg_type:2,piece:e})};t.prototype._onRequest=function(e){if(!this._metadataComplete){this._reject(e);return}var t=e*c;var r=t+c;if(r>this._metadataSize){r=this._metadataSize}var n=this.metadata.slice(t,r);this._data(e,n,this._metadataSize)};t.prototype._onData=function(e,t,r){if(t.length>c){return}t.copy(this.metadata,e*c);this._bitfield.set(e);this._checkDone()};t.prototype._onReject=function(e){if(this._remainingRejects>0&&this._fetching){this._request(e);this._remainingRejects-=1}else{this.emit("warning",new Error('Peer sent "reject" too much'))}};t.prototype._requestPieces=function(){this.metadata=new r(this._metadataSize);for(var e=0;e<this._numPieces;e++){this._request(e)}};t.prototype._checkDone=function(){var e=true;for(var t=0;t<this._numPieces;t++){if(!this._bitfield.get(t)){e=false;break}}if(!e)return;var r=this.setMetadata(this.metadata);if(!r){this._failedMetadata()}};t.prototype._failedMetadata=function(){this._bitfield=new i(0,{grow:u});this._remainingRejects-=this._numPieces;if(this._remainingRejects>0){this._requestPieces()}else{this.emit("warning",new Error("Peer sent invalid metadata"))}};return t}}).call(this,e("buffer").Buffer)},{bencode:206,bitfield:6,buffer:25,events:29,inherits:115,"simple-sha1":193}],206:[function(e,t,r){arguments[4][11][0].apply(r,arguments)},{"./lib/decode":207,"./lib/encode":209,dup:11}],207:[function(e,t,r){arguments[4][12][0].apply(r,arguments)},{"./dict":208,buffer:25,dup:12}],208:[function(e,t,r){arguments[4][13][0].apply(r,arguments)},{dup:13}],209:[function(e,t,r){arguments[4][14][0].apply(r,arguments)},{buffer:25,dup:14}],210:[function(e,t,r){t.exports=i;var n=Object.prototype.hasOwnProperty;function i(){var e={};for(var t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r){if(n.call(r,i)){e[i]=r[i]}}}return e}},{}],211:[function(e,t,r){t.exports=i;var n=Object.prototype.hasOwnProperty;function i(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r){if(n.call(r,i)){e[i]=r[i]}}}return e}},{}],212:[function(e,t,r){t.exports=function n(e,t,r){if(t===undefined){return function(t,r){return n(e,t,r)}}if(r===undefined)r="0";e-=t.toString().length;if(e>0)return new Array(e+(/\./.test(t)?2:1)).join(r)+t;return t+""}},{}],213:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.73.1",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/server.js":false,"bittorrent-dht/client":false,"fs-chunk-store":"memory-chunk-store","load-ip-set":false,os:false,"path-exists":false,ut_pex:false},bugs:{url:"https://github.com/feross/webtorrent/issues"},dependencies:{"addr-to-ip-port":"^1.0.1",bitfield:"^1.0.2","bittorrent-dht":"^6.0.1","bittorrent-swarm":"^6.0.0","chunk-store-stream":"^2.0.0",clivas:"^0.2.0",cpus:"^1.0.0","create-torrent":"^3.4.0",debug:"^2.1.0","end-of-stream":"^1.0.0",executable:"^3.0.0","fs-chunk-store":"^1.3.4",hat:"0.0.3","immediate-chunk-store":"^1.0.7",inherits:"^2.0.1",inquirer:"^0.11.0","load-ip-set":"^1.0.3","memory-chunk-store":"^1.2.0",mime:"^1.2.11",minimist:"^1.1.0",moment:"^2.8.3",multistream:"^2.0.2","network-address":"^1.0.0","parse-torrent":"^5.1.0","path-exists":"^2.1.0","pretty-bytes":"^3.0.0",pump:"^1.0.0","random-iterate":"^1.0.1","range-parser":"^1.0.2","re-emitter":"^1.0.0","readable-stream":"^2.0.5","render-media":"^2.0.0","run-parallel":"^1.0.0","run-parallel-limit":"^1.0.2","simple-peer":"^5.11.6","simple-sha1":"^2.0.0",speedometer:"^1.0.0","stream-to-blob-url":"^2.0.0","stream-with-known-length-to-buffer":"^1.0.0","torrent-discovery":"^5.1.0","torrent-piece":"^1.0.0",uniq:"^1.0.1",ut_metadata:"^3.0.1",ut_pex:"^1.0.1",winreg:"0.0.16",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^7.0.0",brfs:"^1.2.0",browserify:"^13.0.0","cross-spawn-async":"^2.0.0",finalhandler:"^0.4.0","run-series":"^1.0.2","serve-static":"^1.9.3","simple-get":"^1.0.0",standard:"^6.0.1",tape:"^4.0.0","uglify-js":"^2.4.15",zuul:"^3.0.0"},homepage:"https://webtorrent.io",keywords:["bittorrent","bittorrent client","download","mad science","streaming","torrent","webrtc","webrtc data","webtorrent"],license:"MIT",main:"index.js",optionalDependencies:{"airplay-js":"^0.2.3",chromecasts:"^1.5.3",nodebmc:"0.0.6"},repository:{type:"git",url:"git://github.com/feross/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | uglifyjs -m > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && node ./bin/test.js","test-browser":"zuul -- test/*.js test/browser/*.js","test-browser-local":"zuul --local -- test/*.js test/browser/*.js","test-node":"tape test/*.js test/node/*.js"}}},{}],214:[function(e,t,r){(function(r,n,i){t.exports=x;var o=e("create-torrent");var s=e("debug")("webtorrent");var a=e("bittorrent-dht/client");var f=e("events").EventEmitter;var u=e("xtend");var c=e("hat");var l=e("inherits");var d=e("load-ip-set");var h=e("run-parallel");var p=e("parse-torrent");var m=e("path");var v=e("simple-peer");var g=e("speedometer");var y=e("zero-fill");var _=e("./lib/torrent");t.exports.WEBRTC_SUPPORT=v.WEBRTC_SUPPORT;var b=e("./package.json").version;var w=b.match(/([0-9]+)/g).slice(0,2).map(y(2)).join("");var E="-WW"+w+"-";l(x,f);function x(e){var t=this;if(!(t instanceof x))return new x(e);f.call(t);if(!e)e={};if(!s.enabled)t.setMaxListeners(0);t.destroyed=false;t.torrentPort=e.torrentPort||0;t.tracker=e.tracker!==undefined?e.tracker:true;t._rtcConfig=e.rtcConfig;t._wrtc=e.wrtc||n.WRTC;t.torrents=[];t._downloadSpeed=g();t._uploadSpeed=g();t.maxConns=e.maxConns;t.peerId=typeof e.peerId==="string"?e.peerId:(e.peerId||new i(E+c(48))).toString("hex");t.peerIdBuffer=new i(t.peerId,"hex");t.nodeId=typeof e.nodeId==="string"?e.nodeId:e.nodeId&&e.nodeId.toString("hex")||c(160);t.nodeIdBuffer=new i(t.nodeId,"hex");if(e.dht!==false&&typeof a==="function"){t.dht=new a(u({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}s("new webtorrent (peerId %s, nodeId %s)",t.peerId,t.nodeId);if(typeof d==="function"){d(e.blocklist,{headers:{"user-agent":"WebTorrent/"+b+" (http://webtorrent.io)"}},function(e,r){if(e)return t.error("Failed to load blocklist: "+e.message);t.blocked=r;o()})}else r.nextTick(o);function o(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(x.prototype,"ratio",{get:function(){var e=this.torrents.reduce(function(e,t){return e+t.uploaded},0);var t=this.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return e/t}});Object.defineProperty(x.prototype,"downloadSpeed",{get:function(){return this._downloadSpeed()}});Object.defineProperty(x.prototype,"uploadSpeed",{get:function(){return this._uploadSpeed()}});x.prototype.get=function(e){var t=this;if(e instanceof _)return e;var r;try{r=p(e)}catch(n){}if(!r)return null;if(!r.infoHash)throw new Error("Invalid torrent identifier");for(var i=0,o=t.torrents.length;i<o;i++){var s=t.torrents[i];if(s.infoHash===r.infoHash)return s}return null};x.prototype.add=x.prototype.download=function(e,t,n){var i=this;if(i.destroyed)throw new Error("client is destroyed");if(typeof t==="function")return i.add(e,null,t);t=t?u(t):{};s("add");var o=i.get(e);function a(){if(typeof n==="function")n(o)}if(o){if(o.ready)r.nextTick(a);else o.on("ready",a)}else{t.client=i;o=new _(e,t);i.torrents.push(o);o.on("error",function(e){i.emit("error",e,o);i.remove(o)});o.on("listening",function(e){i.emit("listening",e,o)});o.on("ready",function(){a();i.emit("torrent",o)})}return o};x.prototype.seed=function(e,t,r){var n=this;if(n.destroyed)throw new Error("client is destroyed");if(typeof t==="function")return n.seed(e,null,t);t=t?u(t):{};s("seed");if(typeof e==="string")t.path=m.dirname(e);if(!t.createdBy)t.createdBy="WebTorrent/"+w;if(!n.tracker)t.announce=[];var i;var a=n.add(undefined,t,function(e){var t=[function(t){e.load(i,t)}];if(n.dht){t.push(function(t){e.on("dhtAnnounce",t)})}h(t,function(t){if(t)return n.emit("error",t);f();n.emit("seed",e)})});o.parseInput(e,t,function(r,s){if(r)return n.emit("error",r);i=s.map(function(e){return e.getStream});o(e,t,function(e,t){if(e)return n.emit("error",e);if(n.destroyed)return;var r=n.get(t);if(r){a.destroy();f();return}else{a._onTorrentId(t)}})});function f(){s("on seed");if(typeof r==="function")r(a)}return a};x.prototype.remove=function(e,t){var r=this;s("remove");var n=r.get(e);if(!n)throw new Error("No torrent with id "+e);r.torrents.splice(r.torrents.indexOf(n),1);n.destroy(t)};x.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}};x.prototype.destroy=function(e){var t=this;if(t.destroyed)throw new Error("client already destroyed");t.destroyed=true;s("destroy");var r=t.torrents.map(function(e){return function(r){t.remove(e,r)}});if(t.dht)r.push(function(e){t.dht.destroy(e)});h(r,e)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./lib/torrent":4,"./package.json":213,_process:34,"bittorrent-dht/client":24,buffer:25,"create-torrent":79,debug:107,events:29,hat:113,inherits:115,"load-ip-set":24,"parse-torrent":118,path:33,"run-parallel":184,"simple-peer":188,speedometer:195,xtend:210,"zero-fill":212}]},{},[214])(214)});