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

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2015-08-23 22:35:09 +0300
committerFeross Aboukhadijeh <feross@feross.org>2015-08-23 22:35:09 +0300
commitf1d966c24739d982128e247e48cc41f2a82ee30a (patch)
tree7cbb8ac6f7a85b9e5e19b6e95aa4154fe7fba92a /webtorrent.min.js
parent69d63ba1eff48932b190f1373514940906d0538a (diff)
build
Diffstat (limited to 'webtorrent.min.js')
-rw-r--r--webtorrent.min.js22
1 files changed, 11 insertions, 11 deletions
diff --git a/webtorrent.min.js b/webtorrent.min.js
index 5a18b46..93e71c0 100644
--- a/webtorrent.min.js
+++ b/webtorrent.min.js
@@ -1,11 +1,11 @@
-(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,o){if(!t[s]){if(!e[s]){var f=typeof require=="function"&&require;if(!o&&f)return f(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=t[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,n,e,t,r)}return t[s].exports}var a=typeof require=="function"&&require;for(var s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,r){(function(r){var i=e("debug")("webtorrent:append-to");var n=e("./media-stream");var a=e("path");var s=e("videostream");var o=[".mp4",".m4v",".m4a"];var f=[".mp4",".m4v",".webm"];var u=[".m4a",".mp3"];var l=f.concat(u);var c=[".wav",".aac",".ogg",".oga"];var p=[".jpg",".jpeg",".png",".gif",".bmp"];var d=[".css",".html",".js",".md",".pdf",".txt"];var h=typeof window!=="undefined"&&window.MediaSource;t.exports=function g(e,t,r){if(!r)r=m;var u;var g=a.extname(e.name).toLowerCase();var y=0;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.")}if(l.indexOf(g)>=0)_();else if(c.indexOf(g)>=0)w();else if(p.indexOf(g)>=0)x();else if(d.indexOf(g)>=0)k();else v(r,new Error('Unsupported file type "'+g+'": Cannot append to DOM'));function _(){if(!h){return v(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 a=f.indexOf(g)>=0?"video":"audio";if(o.indexOf(g)>=0)l();else c();function l(){i("Use `videostream` package for "+e.name);_();u.addEventListener("error",d);u.addEventListener("playing",b);s(e,u)}function c(){i("Use MediaSource API for "+e.name);_();u.addEventListener("error",m);u.addEventListener("playing",b);e.createReadStream().pipe(new n(u,{extname:g}));if(y)u.currentTime=y}function p(){i("Use Blob URL for "+e.name);_();u.addEventListener("error",S);u.addEventListener("playing",b);e.getBlobURL(function(e,t){if(e)return S(e);u.src=t;if(y)u.currentTime=y})}function d(e){i("videostream error: fallback to MediaSource API: %o",e.message||e);u.removeEventListener("error",d);u.removeEventListener("playing",b);c()}function m(e){i("MediaSource API error: fallback to Blob URL: %o",e.message||e);u.removeEventListener("error",m);u.removeEventListener("playing",b);p()}function _(e){if(!u){u=document.createElement(a);u.controls=true;u.autoplay=true;u.play();u.addEventListener("progress",function(){y=u.currentTime});t.appendChild(u)}}}function b(){u.removeEventListener("playing",b);r(null,u)}function w(){u=document.createElement("audio");u.controls=true;u.autoplay=true;t.appendChild(u);e.getBlobURL(function(e,t){if(e)return S(e);u.addEventListener("error",S);u.addEventListener("playing",b);u.src=t;u.play()})}function x(){e.getBlobURL(function(i,n){if(i)return S(i);u=document.createElement("img");u.src=n;u.alt=e.name;t.appendChild(u);r(null)})}function k(){e.getBlobURL(function(e,i){if(e)return S(e);u=document.createElement("iframe");u.src=i;if(g!==".pdf")u.sandbox="allow-forms allow-scripts";t.appendChild(u);r(null)})}function S(t){if(u)u.remove();t.message='Error appending file "'+e.name+'" to DOM: '+t.message;i(t.message);if(r)r(t)}};function m(){}function v(e,t,i){r.nextTick(function(){if(e)e(t,i)})}}).call(this,e("_process"))},{"./media-stream":4,_process:49,debug:121,path:48,videostream:180}],2:[function(e,t,r){t.exports=s;var i=e("debug")("webtorrent:file-stream");var n=e("inherits");var a=e("stream");n(s,a.Readable);function s(e,t){a.Readable.call(this,t);this.destroyed=false;this._torrent=e._torrent;var r=t&&t.start||0;var i=t&&t.end||e.length-1;var n=e._torrent.pieceLength;this._startPiece=(r+e.offset)/n|0;this._endPiece=(i+e.offset)/n|0;this._piece=this._startPiece;this._offset=r+e.offset-this._startPiece*n;this._missing=i-r+1;this._reading=false;this._notifying=false;this._criticalLength=Math.min(1024*1024/n|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,n){e._notifying=false;if(e.destroyed)return;if(r)return e.destroy(r);i("read %s (length %s) (err %s)",t,n.length,r&&r.message);if(e._offset){n=n.slice(e._offset);e._offset=0}if(e._missing<n.length){n=n.slice(0,e._missing)}e._missing-=n.length;i("pushing buffer of length %s",n.length);e._reading=false;e.push(n);if(e._missing===0)e.push(null)});e._piece+=1};s.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;this._torrent.deselect(this._startPiece,this._endPiece,true)}},{debug:121,inherits:129,stream:67}],3:[function(e,t,r){(function(r,i){t.exports=p;var n=e("./append-to");var a=e("end-of-stream");var s=e("events").EventEmitter;var o=e("./file-stream");var f=e("inherits");var u=e("./mime.json");var l=e("path");var c=e("stream");f(p,s);function p(e,t){s.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 i=r+t.length-1;this._startPiece=r/this._torrent.pieceLength|0;this._endPiece=i/this._torrent.pieceLength|0;if(this.length===0){this.done=true;this.emit("done")}}p.prototype.select=function(){if(this.length===0)return;this._torrent.select(this._startPiece,this._endPiece,false)};p.prototype.deselect=function(){if(this.length===0)return;this._torrent.deselect(this._startPiece,this._endPiece,false)};p.prototype.createReadStream=function(e){var t=this;if(this.length===0){var i=new c.PassThrough;r.nextTick(function(){i.end()});return i}var n=new o(t,e);t._torrent.select(n._startPiece,n._endPiece,true,function(){n._notify()});a(n,function(){t._torrent.deselect(n._startPiece,n._endPiece,true)});return n};p.prototype.getBuffer=function(e){var t=new i(this.length);var r=0;this.createReadStream().on("data",function(e){e.copy(t,r);r+=e.length}).on("end",function(){e(null,t)}).on("error",e)};p.prototype.getBlobURL=function(e){var t=this;if(typeof window==="undefined")throw new Error("browser-only method");t.getBuffer(function(r,i){if(r)return e(r);var n=l.extname(t.name).toLowerCase();var a=u[n];var s=new window.Blob([i],a&&{type:a});var o=window.URL.createObjectURL(s);e(null,o)})};p.prototype.appendTo=function(e,t){if(typeof window==="undefined")throw new Error("browser-only method");if(typeof e==="string")e=document.querySelector(e);n(this,e,t)}}).call(this,e("_process"),e("buffer").Buffer)},{"./append-to":1,"./file-stream":2,"./mime.json":5,_process:49,buffer:40,"end-of-stream":124,events:44,inherits:129,path:48,stream:67}],4:[function(e,t,r){t.exports=o;var i=e("debug")("webtorrent:media-source-stream");var n=e("inherits");var a=e("stream");var s=typeof window!=="undefined"&&window.MediaSource;n(o,a.Writable);function o(e,t){var r=this;if(!(r instanceof o))return new o(e,t);a.Writable.call(r,t);if(!s)throw new Error("web browser lacks MediaSource support");if(!t)t={};i("new MediaSourceStream %s %s",e,JSON.stringify(t));r._elem=e;r._mediaSource=new s;r._sourceBuffer=null;r._cb=null;r._type=t.type||f(t.extname);if(!r._type)throw new Error("missing `opts.type` or `opts.extname` options");r._elem.src=window.URL.createObjectURL(r._mediaSource);r._mediaSource.addEventListener("sourceopen",function(){if(s.isTypeSupported(r._type)){r._sourceBuffer=r._mediaSource.addSourceBuffer(r._type);r._sourceBuffer.addEventListener("updateend",r._flow.bind(r));r._flow()}else{r._mediaSource.endOfStream("decode")}});r.on("finish",function(){i("finish");r._mediaSource.endOfStream()});window.vs=r}o.prototype._write=function(e,t,r){var n=this;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"))}n._sourceBuffer.appendBuffer(e);i("appendBuffer %s",e.length);n._cb=r};o.prototype._flow=function(){var e=this;i("flow");if(e._cb){e._cb(null)}};function f(e){if(!e)return null;if(e[0]!==".")e="."+e;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"'}[e]}},{debug:121,inherits:129,stream:67}],5:[function(e,t,r){t.exports={".aac":"audio/aac",".css":"text/css",".html":"text/html",".js":"application/javascript",".m4a":"audio/mp4",".md":"text/x-markdown",".mp3":"audio/mpeg",".mp4":"video/mp4",".oga":"audio/ogg",".ogg":"audio/ogg",".pdf":"application/pdf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm"}},{}],6:[function(e,t,r){t.exports=i;function i(e,t){var r=this;r.pieces=[];r.swarm=e;r.numPieces=t;function i(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(i);r.swarm.on("wire",function(e){r.recalculate();i(e)});r.recalculate()}i.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)}})};i.prototype.getRarestPiece=function(e){var t=this;var r=[];var i=Infinity;e=e||function(){return true};for(var n=0;n<t.numPieces;++n){if(!e(n))continue;var a=t.pieces[n];if(a===i){r.push(n)}else if(a<i){r=[n];i=a}}if(r.length>0){return r[Math.random()*r.length|0]}else{return-1}}},{}],7:[function(e,t,r){t.exports=u;var i=e("debug")("webtorrent:server");var n=e("http");var a=e("mime");var s=e("pump");var o=e("range-parser");var f=e("url");function u(e,t){var r=n.createServer(t);var u=[];r.on("connection",function(e){e.setTimeout(36e6);u.push(e);e.on("close",function(){var t=u.indexOf(e);if(t>=0)u.splice(t,1)})});r.destroy=function(e){u.forEach(function(e){e.destroy()});r.close(e)};r.on("request",function(t,r){i("onRequest");if(t.method==="OPTIONS"&&t.headers["access-control-request-headers"]){r.setHeader("Access-Control-Allow-Methods","POST, GET, OPTIONS");r.setHeader("Access-Control-Allow-Headers",t.headers["access-control-request-headers"]);r.setHeader("Access-Control-Max-Age","1728000");return r.end()}if(t.headers.origin){r.setHeader("Access-Control-Allow-Origin",t.headers.origin)}var n=f.parse(t.url).pathname;if(n==="/favicon.ico")return r.end();if(e.ready)u();else e.once("ready",u);function u(){if(n==="/"){r.setHeader("Content-Type","text/html");var f=e.files.map(function(e,t){return'<li><a href="/'+t+'">'+e.name+"</a></li>"}).join("<br>");return r.end("<h1>WebTorrent</h1><ol>"+f+"</ol>")}var u=Number(n.slice(1));if(Number.isNaN(u)||u>=e.files.length){r.statusCode=404;return r.end("404 Not Found")}var l=e.files[u];r.setHeader("Accept-Ranges","bytes");r.setHeader("Content-Type",a.lookup(l.name));r.statusCode=200;r.setHeader("transferMode.dlna.org","Streaming");r.setHeader("contentFeatures.dlna.org","DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000");var c;if(t.headers.range){r.statusCode=206;c=o(l.length,t.headers.range)[0];i("range %s",JSON.stringify(c));r.setHeader("Content-Range","bytes "+c.start+"-"+c.end+"/"+l.length);r.setHeader("Content-Length",c.end-c.start+1)}else{r.setHeader("Content-Length",l.length)}if(t.method==="HEAD")r.end();s(l.createReadStream(c),r)}});return r}},{debug:121,http:68,mime:131,pump:148,"range-parser":152,url:78}],8:[function(e,t,r){(function(r,i){t.exports=H;var n=e("addr-to-ip-port");var a=e("bitfield");var s=e("chunk-store-stream/write");var o=e("create-torrent");var f=e("debug")("webtorrent:torrent");var u=e("torrent-discovery");var l=e("events").EventEmitter;var c=e("xtend/mutable");var p=e("fs-chunk-store");var d=e("immediate-chunk-store");var h=e("inherits");var m=e("multistream");var v=e("os");var g=e("run-parallel");var y=e("parse-torrent");var _=e("path");var b=e("path-exists");var w=e("torrent-piece");var x=e("pump");var k=e("random-iterate");var S=e("re-emitter");var E=e("simple-sha1");var A=e("bittorrent-swarm");var U=e("uniq");var I=e("ut_metadata");var T=e("ut_pex");var L=e("./file");var B=e("./rarity-map");var C=e("./server");var R=128*1024;var P=3e4;var O=5e3;var z=3*w.BLOCK_LENGTH;var F=.5;var M=1;var j=1e4;var D=2;var N=_.join(b.sync("/tmp")?"/tmp":v.tmpDir(),"webtorrent");h(H,l);function H(e,t){var r=this;l.call(r);if(!f.enabled)r.setMaxListeners(0);f("new torrent");r.client=t.client;r.announce=t.announce;r.urlList=t.urlList;r._path=t.path;r._store=t.store||p;r.strategy=t.strategy||"sequential";r._rechokeNumSlots=t.uploads===false||t.uploads===0?0:+t.uploads||10;r._rechokeOptimisticWire=null;r._rechokeOptimisticTime=0;r._rechokeIntervalId=null;r.ready=false;r.destroyed=false;r.metadata=null;r.store=null;r.numBlockedPeers=0;r.files=null;r.done=false;r._amInterested=false;r._selections=[];r._critical=[];r._servers=[];if(e)r._onTorrentId(e)}Object.defineProperty(H.prototype,"timeRemaining",{get:function(){if(this.swarm.downloadSpeed()===0)return Infinity;else return(this.length-this.downloaded)/this.swarm.downloadSpeed()*1e3}});Object.defineProperty(H.prototype,"downloaded",{get:function(){return this.swarm?this.swarm.downloaded:0}});Object.defineProperty(H.prototype,"uploaded",{get:function(){return this.swarm?this.swarm.uploaded:0}});Object.defineProperty(H.prototype,"progress",{get:function(){return this.length?this.downloaded/this.length:0}});Object.defineProperty(H.prototype,"ratio",{get:function(){return this.uploaded/(this.downloaded||1)}});Object.defineProperty(H.prototype,"numPeers",{get:function(){return this.swarm?this.swarm.numPeers:0}});Object.defineProperty(H.prototype,"torrentFileURL",{get:function(){if(typeof window==="undefined")throw new Error("browser-only property");if(!this.torrentFile)return null;return window.URL.createObjectURL(new window.Blob([this.torrentFile],{type:"application/x-bittorrent"}))}});H.prototype.downloadSpeed=function(){return this.swarm?this.swarm.downloadSpeed():0};H.prototype.uploadSpeed=function(){return this.swarm?this.swarm.uploadSpeed():0};H.prototype._onTorrentId=function(e){var t=this;if(t.destroyed)return;y.remote(e,function(e,r){if(t.destroyed)return;if(e)return t._onError(e);t._onParsedTorrent(r)})};H.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=_.join(N,t.infoHash);t.swarm=new A(t.infoHash,t.client.peerId,{handshake:{dht:!!t.client.dht}});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));r.nextTick(function(){if(t.destroyed)return;t.emit("infoHash",t.infoHash)})};H.prototype._processParsedTorrent=function(e){if(this.announce){e.announce=e.announce.concat(this.announce)}if(i.WEBTORRENT_ANNOUNCE){e.announce=e.announce.concat(i.WEBTORRENT_ANNOUNCE)}if(e.announce.length===0){e.announce=o.announceList.map(function(e){return e[0]})}if(this.urlList){e.urlList=e.urlList.concat(this.urlList)}U(e.announce);c(this,e);this.magnetURI=y.toMagnetURI(e);this.torrentFile=y.toTorrentFile(e)};H.prototype._onSwarmListening=function(){var e=this;if(e.destroyed)return;if(e.swarm.server)e.client.torrentPort=e.swarm.address().port;e.discovery=new u({announce:e.announce,dht:e.client.dht,tracker:e.client.tracker,peerId:e.client.peerId,port:e.client.torrentPort,rtcConfig:e.client._rtcConfig,wrtc:e.client._wrtc});e.discovery.on("error",e._onError.bind(e));e.discovery.setTorrent(e.infoHash);e.discovery.on("peer",e.addPeer.bind(e));S(e.discovery,e,["trackerAnnounce","dhtAnnounce","warning"]);if(e.info)e._onMetadata(e);e.emit("listening",e.client.torrentPort)};H.prototype._onMetadata=function(e){var t=this;if(t.metadata||t.destroyed)return;f("got metadata");var i;if(e&&e.infoHash){i=e}else{try{i=y(e)}catch(n){return t._onError(n)}}t._processParsedTorrent(i);t.metadata=t.torrentFile;t.discovery.setTorrent(t);if(t.urlList)t.urlList.forEach(t.addWebSeed.bind(t));t.rarityMap=new B(t.swarm,t.pieces.length);t.store=new d(new t._store(t.pieceLength,{files:t.files.map(function(e){return{path:_.join(t._path,e.path),length:e.length,offset:e.offset}}),length:t.length}));t.files=t.files.map(function(e){return new L(t,e)});t._hashes=t.pieces;t.pieces=t.pieces.map(function(e,r){var i=r===t.pieces.length-1?t.lastPieceLength:t.pieceLength;return new w(i)});t._reservations=t.pieces.map(function(){return[]});t.bitfield=new a(t.pieces.length);t.swarm.wires.forEach(function(e){if(e.ut_metadata)e.ut_metadata.setMetadata(t.metadata);t._onWireWithMetadata(e)});r.nextTick(function(){t.emit("metadata");t._onStore()})};H.prototype._onStore=function(){var e=this;if(e.destroyed)return;f("on store");e.select(0,e.pieces.length-1,false);e._rechokeIntervalId=setInterval(e._rechoke.bind(e),j);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();e.ready=true;e.emit("ready")};H.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;f("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)});g(r,e)};H.prototype.addPeer=function(e){var t=this;function r(){t.swarm.addPeer(e);t.emit("peer",e)}if(typeof e==="string"&&t.client.blocked&&t.client.blocked.contains(n(e)[0])){t.numBlockedPeers+=1;t.emit("blockedPeer",e);return false}else{if(t.swarm)r();else t.once("listening",r);return true}};H.prototype.addWebSeed=function(e){var t=this;t.swarm.addWebSeed(e,t)};H.prototype.select=function(e,t,r,i){var n=this;if(e>t||e<0||t>=n.pieces.length){throw new Error("invalid selection ",e,":",t)}r=Number(r)||0;f("select %s-%s (priority %s)",e,t,r);n._selections.push({from:e,to:t,offset:0,priority:r,notify:i||W});n._selections.sort(function(e,t){return t.priority-e.priority});n._updateSelections()};H.prototype.deselect=function(e,t,r){var i=this;r=Number(r)||0;f("deselect %s-%s (priority %s)",e,t,r);for(var n=0;n<i._selections.length;++n){var a=i._selections[n];if(a.from===e&&a.to===t&&a.priority===r){i._selections.splice(n--,1);break}}i._updateSelections()};H.prototype.critical=function(e,t){var r=this;f("critical %s-%s",e,t);for(var i=e;i<=t;++i){r._critical[i]=true}r._updateSelections()};H.prototype._onWire=function(e,t){var r=this;f("got wire (%s)",t||"Unknown");if(t){var i=n(t);e.remoteAddress=i[0];e.remotePort=i[1]}if(e.peerExtensions.dht&&r.client.dht&&r.client.dht.listening){e.on("port",function(t){if(!e.remoteAddress){f("ignoring port from peer with no address");return}f("port: %s (from %s)",t,e.remoteAddress+":"+e.remotePort);r.client.dht.addNode(e.remoteAddress+":"+t)});e.port(r.client.dht.address().port)}e.on("timeout",function(){f("wire timeout (%s)",t);e.destroy()});e.setTimeout(P,true);e.setKeepAlive(true);e.use(I(r.metadata));if(!r.metadata){e.ut_metadata.on("metadata",function(e){f("got metadata via ut_metadata");r._onMetadata(e)});e.ut_metadata.fetch()}if(typeof T==="function"){e.use(T());e.ut_pex.on("peer",function(e){f("ut_pex: got peer: %s (from %s)",e,t);r.addPeer(e)});e.ut_pex.on("dropped",function(e){var i=r.swarm._peers[e];if(i&&!i.connected){f("ut_pex: dropped peer: %s (from %s)",e,t);r.swarm.removePeer(e)}})}r.emit("wire",e,t);if(r.metadata){r._onWireWithMetadata(e)}};H.prototype._onWireWithMetadata=function(e){var t=this;var r=null;function i(){if(t.destroyed||e.destroyed)return;if(t.swarm.numQueued>2*(t.swarm.numConns-t.swarm.numPeers)&&e.amInterested){e.destroy()}else{r=setTimeout(i,O);if(r.unref)r.unref()}}var n=0;function a(){if(e.peerPieces.length!==t.pieces.length)return;for(;n<t.pieces.length;++n){if(!e.peerPieces.get(n))return}e.isSeeder=true;e.choke()}e.on("bitfield",function(){a();t._update()});e.on("have",function(){a();t._update()});e.once("interested",function(){e.unchoke()});e.on("close",function(){clearTimeout(r)});e.on("choke",function(){clearTimeout(r);r=setTimeout(i,O);if(r.unref)r.unref()});e.on("unchoke",function(){clearTimeout(r);t._update()});e.on("request",function(r,i,n,a){if(n>R){return e.destroy()}if(t.pieces[r])return;t.store.get(r,{offset:i,length:n},a)});e.bitfield(t.bitfield);e.interested();r=setTimeout(i,O);if(r.unref)r.unref();e.isSeeder=false;a()};H.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()};H.prototype._gcSelections=function(){var e=this;for(var t=0;t<e._selections.length;t++){var r=e._selections[t];var i=r.offset;while(e.bitfield.get(r.from+r.offset)&&r.from+r.offset<r.to){r.offset++}if(i!==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")};H.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")};H.prototype._update=function(){var e=this;if(e.destroyed)return;var t=k(e.swarm.wires);var r;while(r=t()){e._updateWire(r)}};H.prototype._updateWire=function(e){var t=this;if(e.peerChoking)return;if(!e.downloaded)return a();var r=q(e,F);if(e.requests.length>=r)return;var i=q(e,M);f(false)||f(true);function n(t,r,i,n){return function(a){return a>=t&&a<=r&&!(a in i)&&e.peerPieces.get(a)&&(!n||n(a))}}function a(){if(e.requests.length)return;for(var r=t._selections.length;r--;){var i=t._selections[r];var a;if(t.strategy==="rarest"){var s=i.from+i.offset;var o=i.to;var f=o-s+1;var u={};var l=0;var c=n(s,o,u);while(l<f){a=t.rarityMap.getRarestPiece(c);if(a<0)break;if(t._request(e,a,false))return;u[a]=true;l+=1}}else{for(a=i.to;a>=i.from+i.offset;--a){if(!e.peerPieces.get(a))continue;if(t._request(e,a,false))return}}}}function s(){var r=e.downloadSpeed()||1;if(r>z)return function(){return true};var i=Math.max(1,e.requests.length)*w.BLOCK_LENGTH/r;var n=10;var a=0;return function(e){if(!n||t.bitfield.get(e))return true;var s=t.pieces[e].missing;for(;a<t.swarm.wires.length;a++){var o=t.swarm.wires[a];var f=o.downloadSpeed();if(f<z)continue;if(f<=r)continue;if(!o.peerPieces.get(e))continue;if((s-=f*i)>0)continue;n--;return false}return true}}function o(e){var r=e;for(var i=e;i<t._selections.length&&t._selections[i].priority;i++){r=i}var n=t._selections[e];t._selections[e]=t._selections[r];t._selections[r]=n}function f(r){if(e.requests.length>=i)return true;var a=s();for(var f=0;f<t._selections.length;f++){var u=t._selections[f];var l;if(t.strategy==="rarest"){var c=u.from+u.offset;var p=u.to;var d=p-c+1;var h={};var m=0;var v=n(c,p,h,a);while(m<d){l=t.rarityMap.getRarestPiece(v);if(l<0)break;while(t._request(e,l,t._critical[l]||r)){}if(e.requests.length<i){h[l]=true;m++;continue}if(u.priority)o(f);return true}}else{for(l=u.from+u.offset;l<=u.to;l++){if(!e.peerPieces.get(l)||!a(l))continue;while(t._request(e,l,t._critical[l]||r)){}if(e.requests.length<i)continue;if(u.priority)o(f);return true}}}return false}};H.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 i=0;for(;i<t.length&&r<e._rechokeNumSlots;++i){t[i].isChoked=false;if(t[i].wire.peerInterested)r+=1}if(!e._rechokeOptimisticWire&&i<t.length&&e._rechokeNumSlots){var n=t.slice(i).filter(function(e){return e.wire.peerInterested});var a=n[G(n.length)];if(a){a.isChoked=false;e._rechokeOptimisticWire=a.wire;e._rechokeOptimisticTime=D}}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}};H.prototype._hotswap=function(e,t){var r=this;var i=e.downloadSpeed();if(i<w.BLOCK_LENGTH)return false;if(!r._reservations[t])return false;var n=r._reservations[t];if(!n){return false}var a=Infinity;var s;var o;for(o=0;o<n.length;o++){var f=n[o];if(!f||f===e)continue;var u=f.downloadSpeed();if(u>=z)continue;if(2*u>i||u>a)continue;s=f;a=u}if(!s)return false;for(o=0;o<n.length;o++){if(n[o]===s)n[o]=null}for(o=0;o<s.requests.length;o++){var l=s.requests[o];if(l.piece!==t)continue;r.pieces[t].cancel(l.offset/w.BLOCK_SIZE|0)}r.emit("hotswap",s,e,t);return true};H.prototype._request=function(e,t,i){var n=this;var a=e.requests.length;if(n.bitfield.get(t))return false;var s=q(e,M);if(a>=s)return false;var o=n.pieces[t];var u=o.reserve();if(u===-1&&i&&n._hotswap(e,t)){u=o.reserve()}if(u===-1)return false;var l=n._reservations[t];if(!l)l=n._reservations[t]=[];var c=l.indexOf(null);if(c===-1)c=l.length;l[c]=e;var p=o.chunkOffset(u);var d=o.chunkLength(u);e.request(t,p,d,function m(r,i){if(!n.ready)return n.once("ready",function(){m(r,i)});if(l[c]===e)l[c]=null;if(o!==n.pieces[t])return h();if(r){f("error getting piece %s (offset: %s length: %s) from %s: %s",t,p,d,e.remoteAddress+":"+e.remotePort,r.message);o.cancel(u);h();return}f("got piece %s (offset: %s length: %s) from %s",t,p,d,e.remoteAddress+":"+e.remotePort);if(!o.set(u,i,e))return h();var a=o.flush();E(a,function(e){if(e===n._hashes[t]){if(!n.pieces[t])return;f("piece verified %s",t);n.pieces[t]=null;n._reservations[t]=null;n.bitfield.set(t,true);n.store.put(t,a);n.swarm.wires.forEach(function(e){e.have(t)});n._onPiece()}else{n.pieces[t]=new w(o.length);n.emit("warning",new Error("Piece "+t+" failed verification"))}h()})});function h(){r.nextTick(function(){n._update()})}return true};H.prototype._onPiece=function(){var e=this;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");f("file done: "+t.name)});if(e.files.every(function(e){return e.done})){e.done=true;e.emit("done");f("torrent done: "+e.infoHash);if(e.discovery.tracker)e.discovery.tracker.complete()}e._gcSelections()};H.prototype.load=function(e,t){var r=this;if(!Array.isArray(e))e=[e];if(!t)t=W;var i=new m(e);var n=new s(r.store,r.pieceLength);x(i,n,function(e){if(e)return t(e);r.pieces.forEach(function(e,t){r.pieces[t]=null;r.bitfield.set(t,true)});r._onPiece();t(null)})};H.prototype.createServer=function(e){var t=this;if(typeof C==="function"){var r=new C(t,e);t._servers.push(r);return r}};H.prototype._onError=function(e){var t=this;f("torrent error: %s",e.message||e);t.emit("error",e);t.destroy()};function q(e,t){return Math.ceil(2+t*e.downloadSpeed()/w.BLOCK_LENGTH)}function G(e){return Math.random()*e|0}function W(){}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./file":3,"./rarity-map":6,"./server":7,_process:49,"addr-to-ip-port":9,bitfield:10,"bittorrent-swarm":11,"chunk-store-stream/write":90,"create-torrent":91,debug:121,events:44,"fs-chunk-store":130,"immediate-chunk-store":128,inherits:129,multistream:133,os:47,"parse-torrent":134,path:48,"path-exists":147,pump:148,"random-iterate":151,"re-emitter":153,"run-parallel":154,"simple-sha1":163,"torrent-discovery":166,"torrent-piece":167,uniq:168,ut_metadata:169,ut_pex:39,"xtend/mutable":182}],9:[function(e,t,r){var i=/^\[?([^\]]+)\]?:(\d+)$/;var n={};var a=0;t.exports=function s(e){if(a===1e5)n={};if(!n[e]){var t=i.exec(e);if(!t)throw new Error("invalid addr: "+e);n[e]=[t[1],Number(t[2])];a+=1}return n[e]};t.exports.reset=function o(){n={}}},{}],10:[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 i(e,t){if(!(this instanceof i)){return new i(e,t)}if(arguments.length===0){e=0}this.grow=t&&(isFinite(t.grow)&&n(t.grow)||t.grow)||0;if(typeof e==="number"||e===undefined){e=new r(n(e));if(e.fill&&!e._isBuffer)e.fill(0)}this.buffer=e}function n(e){var t=e>>3;if(e%8!==0)t++;return t}i.prototype.get=function(e){var t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)};i.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)}};i.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 i=0;i<this.buffer.length;i++){t[i]=this.buffer[i]}}this.buffer=t}};if(typeof t!=="undefined")t.exports=i}).call(this,e("buffer").Buffer)},{buffer:40}],11:[function(e,t,r){(function(r,i){t.exports=m;var n=e("addr-to-ip-port");var a=e("debug")("bittorrent-swarm");var s=e("dezalgo");var o=e("events").EventEmitter;var f=e("inherits");var u=e("net");var l=e("./lib/peer");var c=e("speedometer");var p=e("./lib/tcp-pool");var d=55;var h=[1e3,5e3,15e3];f(m,o);function m(e,t,r){var n=this;if(!(n instanceof m))return new m(e,t,r);o.call(n);n.infoHash=typeof e==="string"?new i(e,"hex"):e;n.infoHashHex=n.infoHash.toString("hex");n.peerId=typeof t==="string"?new i(t,"hex"):t;n.peerIdHex=n.peerId.toString("hex");if(!r)r={};a("new swarm (i %s p %s)",n.infoHashHex,n.peerIdHex);n.handshakeOpts=r.handshake;n.maxConns=r.maxConns!==undefined?r.maxConns:d;n.destroyed=false;n.listening=false;n.paused=false;n.server=null;n.wires=[];n._queue=[];n._peers={};n._peersLength=0;n._port=0;n.downloaded=0;n.uploaded=0;n.downloadSpeed=c();n.uploadSpeed=c()}Object.defineProperty(m.prototype,"ratio",{get:function(){var e=this;return e.uploaded/e.downloaded||0}});Object.defineProperty(m.prototype,"numQueued",{get:function(){var e=this;return e._queue.length+(e._peersLength-e.numConns)}});Object.defineProperty(m.prototype,"numConns",{get:function(){var e=this;var t=0;for(var r in e._peers){var i=e._peers[r];if(i&&i.connected)t+=1}return t}});Object.defineProperty(m.prototype,"numPeers",{get:function(){var e=this;return e.wires.length}});m.prototype.addPeer=function(e){var t=this;t._addPeer(e)};m.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)){a("ignoring invalid peer %s (from swarm.addPeer)",e);return null}var r=e&&e.id||e;if(t._peers[r])return;a("addPeer %s",r);var i;if(typeof e==="string"){i=l.createOutgoingTCPPeer(e,t)}else{if(t.paused){e.destroy(new Error("swarm paused"));return null}i=l.createWebRTCPeer(e,t)}t._peers[i.id]=i;t._peersLength+=1;if(typeof e==="string"){t._queue.push(i);t._drain()}return i};m.prototype.addWebSeed=function(e,t){var r=this;if(r.destroyed)return;if(!/^https?:\/\/.+/.test(e)){
-a("ignoring invalid web seed %s (from swarm.addWebSeed)",e);return}if(r._peers[e])return;a("addWebSeed %s",e);var i=l.createWebPeer(e,t,r);r._peers[i.id]=i;r._peersLength+=1};m.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)"))}a("_addIncomingPeer %s",e.id);t._peers[e.id]=e;t._peersLength+=1};m.prototype.removePeer=function(e){var t=this;var r=t._peers[e];if(!r)return;a("removePeer %s",e);t._peers[e]=null;t._peersLength-=1;r.destroy();t._drain()};m.prototype.pause=function(){var e=this;if(e.destroyed)return;a("pause");e.paused=true};m.prototype.resume=function(){var e=this;if(e.destroyed)return;a("resume");e.paused=false;e._drain()};m.prototype.listen=function(e,t,i){var n=this;if(typeof t==="function"){i=t;t=undefined}if(i)i=s(i);if(n.listening)throw new Error("swarm already listening");if(r.browser&&i){i()}else{n._port=e||p.getDefaultListenPort(n.infoHashHex);n._hostname=t;if(i)n.once("listening",i);a("listen %s",e);var o=p.addSwarm(n);n.server=o.server}};m.prototype._onListening=function(e){var t=this;t._port=e;t.listening=true;t.emit("listening")};m.prototype.address=function(){var e=this;return e.server.address()};m.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);a("destroy");for(var r in t._peers){t.removePeer(r)}p.removeSwarm(t,function(){t.emit("close")})};m.prototype._drain=function(){var e=this;a("_drain numConns %s maxConns %s",e.numConns,e.maxConns);if(typeof u.connect!=="function"||e.destroyed||e.paused||e.numConns>=e.maxConns){return}a("drain (%s queued, %s/%s peers)",e.numQueued,e.numPeers,e.maxConns);var t=e._queue.shift();if(!t)return;a("tcp connect attempt to %s",t.addr);var r=n(t.addr);var i={host:r[0],port:r[1]};if(e._hostname)i.localAddress=e._hostname;var s=t.conn=u.connect(i);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){a("conn %s closed: will not re-add (max %s attempts)",t.addr,h.length);return}var r=h[t.retries];a("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,r,t.retries+1);var i=setTimeout(function n(){var r=e._addPeer(t.addr);if(r)r.retries=t.retries+1},r);if(i.unref)i.unref()})};m.prototype._onError=function(e){var t=this;t.emit("error",e);t.destroy()};m.prototype._validAddr=function(e){var t=this;var r=n(e);var i=r[0];var a=r[1];return a>0&&a<65535&&!(i==="127.0.0.1"&&a===t._port)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/peer":12,"./lib/tcp-pool":13,_process:49,"addr-to-ip-port":39,buffer:40,debug:121,dezalgo:20,events:44,inherits:129,net:39,speedometer:165}],12:[function(e,t,r){var i=e("debug")("bittorrent-swarm:peer");var n=e("./webconn");var a=e("bittorrent-protocol");var s=25e3;var o=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 i=new f(e);i.swarm=r;i.conn=new n(e,t);i.onConnect();return i};function f(e){var t=this;t.id=e;i("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;i("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 a;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;var n=e.toString("hex");var a=t.toString("hex");if(r.swarm.destroyed)return r.destroy(new Error("swarm already destroyed"));if(n!==r.swarm.infoHashHex){return r.destroy(new Error("unexpected handshake info hash for this swarm"))}if(a===r.swarm.peerIdHex){return r.destroy(new Error("refusing to handshake with self"))}i("Peer %s got handshake %s",r.id,n);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 s=r.addr;if(!s&&r.conn.remoteAddress){s=r.conn.remoteAddress+":"+r.conn.remotePort}r.swarm.emit("wire",r.wire,s)};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"))},o);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;i("destroy %s (error: %s)",t.id,e&&(e.message||e));clearTimeout(t.connectTimeout);clearTimeout(t.handshakeTimeout);var r=t.swarm;var n=t.conn;var a=t.wire;t.conn=null;t.swarm=null;t.wire=null;if(r&&a){var s=r.wires.indexOf(a);if(s>=0)r.wires.splice(s,1)}if(n)n.destroy();if(a)a.destroy();if(r)r.removePeer(t.id)}},{"./webconn":14,"bittorrent-protocol":15,debug:121}],13:[function(e,t,r){(function(r){t.exports=f;var i=e("debug")("bittorrent-swarm:tcp-pool");var n=e("dezalgo");var a=e("net");var s=e("./peer");var o={};function f(e,t){var r=this;r.port=e;r.listening=false;r.swarms={};i("new TCPPool (port: %s, hostname: %s)",e,t);r.pendingConns=[];r.server=a.createServer();r.server.on("connection",function(e){r._onConnection(e)});r.server.on("error",function(e){r._onError(e)});r.server.on("listening",function(){r._onListening()});r.server.listen(r.port,t)}f.addSwarm=function(e){var t=o[e._port];if(!t)t=o[e._port]=new f(e._port,e._hostname);t.addSwarm(e);return t};f.removeSwarm=function(e,t){var i=o[e._port];if(!i)return t();i.removeSwarm(e);var n=0;for(var a in i.swarms){var s=i.swarms[a];if(s)n+=1}if(n===0)i.destroy(t);else r.nextTick(t)};f.getDefaultListenPort=function(e){for(var t in o){var r=o[t];if(r&&!r.swarms[e])return r.port}return 0};f.prototype.addSwarm=function(e){var t=this;if(t.swarms[e.infoHashHex]){r.nextTick(function(){e._onError(new Error("There is already a swarm with info hash "+e.infoHashHex+" "+"listening on port "+e._port))});return}t.swarms[e.infoHashHex]=e;if(t.listening){r.nextTick(function(){e._onListening(t.port)})}i("add swarm %s to tcp pool %s",e.infoHashHex,t.port)};f.prototype.removeSwarm=function(e){var t=this;i("remove swarm %s from tcp pool %s",e.infoHashHex,t.port);t.swarms[e.infoHashHex]=null};f.prototype.destroy=function(e){var t=this;if(e)e=n(e);i("destroy tcp pool %s",t.port);t.listening=false;t.pendingConns.forEach(function(e){e.destroy()});o[t.port]=null;try{t.server.close(e)}catch(r){if(e)e(null)}};f.prototype._onListening=function(){var e=this;var t=e.server.address()||{port:0};var r=t.port;i("tcp pool listening on %s",r);if(r!==e.port){o[e.port]=null;e.port=r;o[e.port]=e}e.listening=true;for(var n in e.swarms){var a=e.swarms[n];if(a)a._onListening(e.port)}};f.prototype._onConnection=function(e){var t=this;t.pendingConns.push(e);e.once("close",r);function r(){t.pendingConns.splice(t.pendingConns.indexOf(e))}var i=s.createIncomingTCPPeer(e);i.wire.once("handshake",function(n,a){var s=n.toString("hex");r();e.removeListener("close",r);var o=t.swarms[s];if(o){i.swarm=o;o._addIncomingPeer(i);i.onHandshake(n,a)}else{var f=new Error("Unexpected info hash "+s+" from incoming peer "+i.id+": destroying peer");i.destroy(f)}})};f.prototype._onError=function(e){var t=this;t.destroy();for(var r in t.swarms){var i=t.swarms[r];if(i){t.removeSwarm(i);i._onError(e)}}}}).call(this,e("_process"))},{"./peer":12,_process:49,debug:121,dezalgo:20,net:39}],14:[function(e,t,r){(function(r){t.exports=f;var i=e("bitfield");var n=e("debug")("bittorrent-swarm:webconn");var a=e("simple-get");var s=e("inherits");var o=e("bittorrent-protocol");s(f,o);function f(e,t){var a=this;o.call(this);a.url=e;a.parsedTorrent=t;a.setKeepAlive(true);a.on("handshake",function(t,n){a.handshake(t,new r(20).fill(e));var s=a.parsedTorrent.pieces.length;var o=new i(s);for(var f=0;f<=s;f++){o.set(f,true)}a.bitfield(o)});a.on("choke",function(){n("choke")});a.on("unchoke",function(){n("unchoke")});a.once("interested",function(){n("interested");a.unchoke()});a.on("uninterested",function(){n("uninterested")});a.on("bitfield",function(){n("bitfield")});a.on("request",function(e,t,r,i){n("request pieceIndex=%d offset=%d length=%d",e,t,r);a.httpRequest(e,t,r,i)})}f.prototype.httpRequest=function(e,t,r,i){var s=this;var o=e*s.parsedTorrent.pieceLength;var f=o+t;var u=f+r-1;n("Requesting pieceIndex=%d offset=%d length=%d start=%d end=%d",e,t,r,f,u);var l={url:s.url,method:"GET",headers:{"user-agent":"WebTorrent (http://webtorrent.io)",range:"bytes="+f+"-"+u}};a.concat(l,function(e,t,r){if(e)return i(e);if(r.statusCode<200||r.statusCode>=300){return i(new Error("Unexpected HTTP status code "+r.statusCode))}n("Got data of length %d",t.length);i(null,t)})}}).call(this,e("buffer").Buffer)},{bitfield:10,"bittorrent-protocol":15,buffer:40,debug:121,inherits:129,"simple-get":159}],15:[function(e,t,r){(function(r){t.exports=w;var i=e("bencode");var n=e("bitfield");var a=e("debug")("bittorrent-protocol");var s=e("xtend");var o=e("hat");var f=e("inherits");var u=e("speedometer");var l=e("stream");var c=4e5;var p=new r("BitTorrent protocol");var d=new r([0,0,0,0]);var h=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,i){this.piece=e;this.offset=t;this.length=r;this.callback=i}f(w,l.Duplex);function w(){if(!(this instanceof w))return new w;l.Duplex.call(this);this._debugId=o(32);this._debug("new wire");this.amChoking=true;this.amInterested=false;this.peerChoking=true;this.peerInterested=false;this.peerPieces=new n(0,{grow:c});this.peerExtensions={};this.requests=[];this.peerRequests=[];this.extendedMapping={};this.peerExtendedMapping={};this.extendedHandshake={};this.peerExtendedHandshake={};this._ext={};this._nextExt=1;this.uploaded=0;this.downloaded=0;this.uploadSpeed=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();l.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 i=new e(this);function n(){}if(typeof i.onHandshake!=="function"){i.onHandshake=n}if(typeof i.onExtendedHandshake!=="function"){i.onExtendedHandshake=n}if(typeof i.onMessage!=="function"){i.onMessage=n}this.extendedMapping[r]=t;this._ext[t]=i;this[t]=i;this._nextExt+=1};w.prototype.keepAlive=function(){this._debug("keep-alive");this._push(d)};w.prototype.handshake=function(e,t,i){if(typeof e==="string")e=new r(e,"hex");if(typeof t==="string")t=new r(t,"hex");if(e.length!==20||t.length!==20){throw new Error("infoHash and peerId MUST have length 20")}this._debug("handshake i=%s p=%s exts=%o",e.toString("hex"),t.toString("hex"),i);var n=new r(y);n[5]|=16;if(i&&i.dht)n[7]|=1;this._push(r.concat([p,n,e,t]));this._handshakeSent=true;if(this.peerExtensions.extended){this._sendExtendedHandshake()}};w.prototype._sendExtendedHandshake=function(){var e=s(this.extendedHandshake);e.m={};for(var t in this.extendedMapping){var r=this.extendedMapping[t];e.m[r]=Number(t)}this.extended(0,i.encode(e))};w.prototype.choke=function(){if(this.amChoking)return;this.amChoking=true;this._debug("choke");this.peerRequests.splice(0,this.peerRequests.length);this._push(h)};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,i){if(!i)i=function(){};if(this._finished)return i(new Error("wire is closed"));if(this.peerChoking)return i(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,i));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(x(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 n=new r([e]);var a=r.isBuffer(t)?t:i.encode(t);this._message(20,[],r.concat([n,a]))}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){this._debug("got handshake i=%s p=%s exts=%o",e.toString("hex"),t.toString("hex"),r);this.peerId=t;this.peerExtensions=r;this.emit("handshake",e,t,r);var i;for(i in this._ext){this._ext[i].onHandshake(e,t,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 n(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 i=function(i,a){if(n!==x(this.peerRequests,e,t,r))return;if(i)return;this.piece(e,t,a)}.bind(this);var n=new b(e,t,r,i);this.peerRequests.push(n);this.emit("request",e,t,r,i)};w.prototype._onPiece=function(e,t,r){this._debug("got piece index=%d offset=%d",e,t);this._callback(x(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);x(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=i.decode(t)}catch(n){this._debug("ignoring invalid extended handshake: %s",n.message||n)}if(!r)return;this.peerExtendedHandshake=r;var a;if(typeof r.m==="object"){for(a in r.m){this.peerExtendedMapping[a]=Number(r.m[a].toString())}}for(a in this._ext){if(this.peerExtendedMapping[a]){this._ext[a].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,i){this._bufferSize+=e.length;this._buffer.push(e);while(this._bufferSize>=this._parserSize){var n=this._buffer.length===1?this._buffer[0]:r.concat(this._buffer);this._bufferSize-=this._parserSize;this._buffer=this._bufferSize?[n.slice(this._parserSize)]:[];this._parser(n.slice(0,this._parserSize))}i(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,i){var n=i?i.length:0;var a=new r(5+4*t.length);a.writeUInt32BE(a.length+n-4,0);a[4]=e;for(var s=0;s<t.length;s++){a.writeUInt32BE(t[s],5+4*s)}this._push(a);if(i)this._push(i)};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];a.apply(null,e)};function x(e,t,r,i){for(var n=0;n<e.length;n++){var a=e[n];if(a.piece!==t||a.offset!==r||a.length!==i)continue;if(n===0)e.shift();else e.splice(n,1);return a}return null}}).call(this,e("buffer").Buffer)},{bencode:16,bitfield:10,buffer:40,debug:121,hat:127,inherits:129,speedometer:165,stream:67,xtend:181}],16:[function(e,t,r){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":17,"./lib/encode":19}],17:[function(e,t,r){(function(r){var i=e("./dict");function n(e,t){n.position=0;n.encoding=t||null;n.data=!r.isBuffer(e)?new r(e):e;return n.next()}n.position=0;n.data=null;n.encoding=null;n.next=function(){switch(n.data[n.position]){case 100:return n.dictionary();break;case 108:return n.list();break;case 105:return n.integer();break;default:return n.bytes();break}};n.find=function(e){var t=n.position;var r=n.data.length;var i=n.data;while(t<r){if(i[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")};n.dictionary=function(){n.position++;var e=new i;while(n.data[n.position]!==101){e.binarySet(n.bytes(),n.next())}n.position++;return e};n.list=function(){n.position++;var e=[];while(n.data[n.position]!==101){e.push(n.next())}n.position++;return e};n.integer=function(){var e=n.find(101);var t=n.data.toString("ascii",n.position+1,e);n.position+=e+1-n.position;return parseInt(t,10)};n.bytes=function(){var e=n.find(58);var t=parseInt(n.data.toString("ascii",n.position,e),10);var r=++e+t;n.position=r;return n.encoding?n.data.toString(n.encoding,e,r):n.data.slice(e,r)};t.exports=n}).call(this,e("buffer").Buffer)},{"./dict":18,buffer:40}],18:[function(e,t,r){var i=t.exports=function n(){Object.defineProperty(this,"_keys",{enumerable:false,value:[]})};i.prototype.binaryKeys=function a(){return this._keys.slice()};i.prototype.binarySet=function s(e,t){this._keys.push(e);this[e]=t}},{}],19:[function(e,t,r){(function(e){function r(t){var i=[];r._encode(i,t);return e.concat(i)}r._floatConversionDetected=false;r._encode=function(t,i){if(e.isBuffer(i)){t.push(new e(i.length+":"));t.push(i);return}switch(typeof i){case"string":r.bytes(t,i);break;case"number":r.number(t,i);break;case"object":i.constructor===Array?r.list(t,i):r.dict(t,i);break}};var i=new e("e"),n=new e("d"),a=new e("l");r.bytes=function(t,r){t.push(new e(e.byteLength(r)+":"+r))};r.number=function(t,i){var n=2147483648;var a=i/n<<0;var s=i%n<<0;var o=a*n+s;t.push(new e("i"+o+"e"));if(o!==i&&!r._floatConversionDetected){r._floatConversionDetected=true;console.warn('WARNING: Possible data corruption detected with value "'+i+'":','Bencoding only defines support for integers, value was converted to "'+o+'"');console.trace()}};r.dict=function(e,t){e.push(n);var a=0;var s;var o=Object.keys(t).sort();var f=o.length;for(;a<f;a++){s=o[a];r.bytes(e,s);r._encode(e,t[s])}e.push(i)};r.list=function(e,t){var n=0,s=1;var o=t.length;e.push(a);for(;n<o;n++){r._encode(e,t[n])}e.push(i)};t.exports=r}).call(this,e("buffer").Buffer)},{buffer:40}],20:[function(e,t,r){var i=e("wrappy");t.exports=i(a);var n=e("asap");function a(e){var t=true;n(function(){t=false});return function r(){var r=arguments;var i=this;if(t)n(function(){e.apply(i,r)});else e.apply(i,r)}}},{asap:21,wrappy:23}],21:[function(e,t,r){"use strict";var i=e("./raw");var n=[];var a=[];var s=i.makeRequestCallFromTimer(o);function o(){if(a.length){throw a.shift()}}t.exports=f;function f(e){var t;if(n.length){t=n.pop()}else{t=new u}t.task=e;i(t)}function u(){this.task=null}u.prototype.call=function(){try{this.task.call()}catch(e){if(f.onerror){f.onerror(e)}else{a.push(e);s()}}finally{this.task=null;n[n.length]=this}}},{"./raw":22}],22:[function(e,t,r){(function(e){"use strict";t.exports=r;function r(e){if(!i.length){a();n=true}i[i.length]=e}var i=[];var n=false;var a;var s=0;var o=1024;function f(){while(s<i.length){var e=s;s=s+1;i[e].call();if(s>o){for(var t=0,r=i.length-s;t<r;t++){i[t]=i[t+s]}i.length-=s;s=0}}i.length=0;s=0;n=false}var u=e.MutationObserver||e.WebKitMutationObserver;if(typeof u==="function"){a=l(f)}else{a=c(f)}r.requestFlush=a;function l(e){var t=1;var r=new u(e);var i=document.createTextNode("");r.observe(i,{characterData:true});return function n(){t=-t;i.data=t}}function c(e){return function t(){var t=setTimeout(i,0);var r=setInterval(i,50);function i(){clearTimeout(t);clearInterval(r);e()}}}r.makeRequestCallFromTimer=c}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],23:[function(e,t,r){t.exports=i;function i(e,t){if(e&&t)return i(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 i=e.apply(this,t);var n=t[t.length-1];if(typeof i==="function"&&i!==n){Object.keys(n).forEach(function(e){i[e]=n[e]})}return i}}},{}],24:[function(e,t,r){(function(r,i){t.exports=m;var n=e("events").EventEmitter;var a=e("debug")("bittorrent-tracker");var s=e("inherits");var o=e("once");var f=e("run-parallel");var u=e("uniq");var l=e("url");var c=e("./lib/common");var p=e("./lib/client/http-tracker");var d=e("./lib/client/udp-tracker");var h=e("./lib/client/websocket-tracker");s(m,n);function m(e,t,s,o){var f=this;if(!(f instanceof m))return new m(e,t,s,o);n.call(f);if(!o)o={};f._peerId=i.isBuffer(e)?e:new i(e,"hex");f._peerIdHex=f._peerId.toString("hex");f._peerIdBinary=f._peerId.toString("binary");f._infoHash=i.isBuffer(s.infoHash)?s.infoHash:new i(s.infoHash,"hex");f._infoHashHex=f._infoHash.toString("hex");f._infoHashBinary=f._infoHash.toString("binary");f.torrentLength=s.length;f.destroyed=false;f._port=t;f._rtcConfig=o.rtcConfig;f._wrtc=o.wrtc;a("new client %s",f._infoHashHex);var c=!!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=l.parse(e).protocol;if((t==="http:"||t==="https:")&&typeof p==="function"){return new p(f,e)}else if(t==="udp:"&&typeof d==="function"){return new d(f,e)}else if((t==="ws:"||t==="wss:")&&c){return new h(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=o(r);var n=new i("01234567890123456789");var a=6881;var s={infoHash:Array.isArray(t)?t[0]:t,announce:[e]};var f=new m(n,a,s);f.once("error",r);var u=Array.isArray(t)?t.length:1;var l={};f.on("scrape",function(e){u-=1;l[e.infoHash]=e;if(u===0){f.destroy();var t=Object.keys(l);if(t.length===1){r(null,l[t[0]])}else{r(null,l)}}});t=Array.isArray(t)?t.map(function(e){return new i(e,"hex")}):new i(t,"hex");f.scrape({infoHash:t})};m.prototype.start=function(e){var t=this;a("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;a("send `stop`");e=t._defaultAnnounceOpts(e);e.event="stopped";t._announce(e)};m.prototype.complete=function(e){var t=this;a("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;a("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;a("send `scrape`");if(!e)e={};t._trackers.forEach(function(t){t.scrape(e)})};m.prototype.setInterval=function(e){var t=this;a("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;a("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=c.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":39,"./lib/client/udp-tracker":39,"./lib/client/websocket-tracker":26,"./lib/common":28,_process:49,buffer:40,debug:121,events:44,inherits:129,once:30,"run-parallel":154,uniq:168,url:78}],25:[function(e,t,r){t.exports=a;var i=e("events").EventEmitter;var n=e("inherits");n(a,i);function a(e,t){var r=this;i.call(r);r.client=e;r.announceUrl=t;r.interval=null;r.destroyed=false}a.prototype.setInterval=function(e){var t=this;if(t.interval)return;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)}}},{events:44,inherits:129}],26:[function(e,t,r){t.exports=d;var i=e("debug")("bittorrent-tracker:websocket-tracker");var n=e("hat");var a=e("inherits");var s=e("simple-peer");var o=e("simple-websocket");var f=e("../common");var u=e("./tracker");var l={};var c=30*1e3;var p=5*1e3;a(d,u);function d(e,t,r){var n=this;u.call(n,e,t);i("new websocket tracker %s",t);n.peers={};n.socket=null;n.reconnecting=false;n._openSocket()}d.prototype.DEFAULT_ANNOUNCE_INTERVAL=30*1e3;d.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(i){var n={numwant:r,uploaded:e.uploaded||0,downloaded:e.downloaded,event:e.event,info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,offers:i};if(t._trackerId)n.trackerid=t._trackerId;t._send(n)})};d.prototype.scrape=function(e){var t=this;if(t.destroyed||t.reconnecting)return;t._onSocketError(new Error("scrape not supported "+t.announceUrl))};d.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;clearInterval(t.interval);l[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",h);try{t.socket.destroy(e)}catch(r){if(e)e()}t.socket=null};d.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=l[e.announceUrl];if(!e.socket){e.socket=l[e.announceUrl]=new o(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)};d.prototype._onSocketConnect=function(){var e=this;if(e.destroyed)return;if(e.reconnecting){e.reconnecting=false;e.announce(e.client._defaultAnnounceOpts())}};d.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){i("ignoring websocket data from %s for %s (looking for %s: reused socket)",t.announceUrl,f.binaryToHex(e.info_hash),t.client._infoHashHex);return}if(e.peer_id&&e.peer_id===t.client._peerIdBinary){return}i("received %s from %s for %s",JSON.stringify(e),t.announceUrl,t.client._infoHashHex);var r=e["failure reason"];if(r)return t.client.emit("warning",new Error(r));var n=e["warning message"];if(n)t.client.emit("warning",new Error(n));var a=e.interval||e["min interval"];if(a)t.setInterval(a*1e3);var o=e["tracker id"];if(o){t._trackerId=o}if(e.complete){t.client.emit("update",{announce:t.announceUrl,complete:e.complete,incomplete:e.incomplete})}var u;if(e.offer&&e.peer_id){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 i={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)i.trackerid=t._trackerId;t._send(i)});u.signal(e.offer);t.client.emit("peer",u)}if(e.answer&&e.peer_id){u=t.peers[f.binaryToHex(e.offer_id)];if(u){u.id=f.binaryToHex(e.peer_id);u.signal(e.answer);t.client.emit("peer",u)}else{i("got unexpected answer: "+JSON.stringify(e.answer))}}};d.prototype._onSocketClose=function(){var e=this;if(e.destroyed)return;e.destroy();e._startReconnectTimer()};d.prototype._onSocketError=function(e){var t=this;if(t.destroyed)return;t.destroy();t.client.emit("warning",e);t._startReconnectTimer()};d.prototype._startReconnectTimer=function(){var e=this;var t=Math.floor(Math.random()*c)+p;e.reconnecting=true;var r=setTimeout(function(){e._openSocket()},t);if(r.unref)r.unref();i("reconnecting socket in %s ms",t)};d.prototype._send=function(e){var t=this;if(t.destroyed)return;var r=JSON.stringify(e);i("send %s",r);t.socket.send(r)};d.prototype._generateOffers=function(e,t){var r=this;var a=[];i("generating %s offers",e);for(var o=0;o<e;++o){u()}function u(){var e=n(160);var t=r.peers[e]=new s({initiator:true,trickle:false,config:r.client._rtcConfig,wrtc:r.client._wrtc});t.once("signal",function(t){a.push({offer:t,offer_id:f.hexToBinary(e)});l()})}function l(){if(a.length===e){i("generated %s offers",e);t(a)}}};function h(){}},{"../common":28,"./tracker":25,debug:121,hat:127,inherits:129,"simple-peer":31,"simple-websocket":35}],27:[function(e,t,r){(function(t){var i=e("querystring");r.IPV4_RE=/^[\d\.]+$/;r.IPV6_RE=/^[\da-fA-F:]+$/;r.CONNECTION_ID=t.concat([n(1047),n(655366528)]);r.ACTIONS={CONNECT:0,ANNOUNCE:1,SCRAPE:2,ERROR:3};r.EVENTS={update:0,completed:1,started:2,stopped:3};r.EVENT_IDS={0:"update",1:"completed",2:"started",3:"stopped"};r.EVENT_NAMES={update:"update",completed:"complete",started:"start",stopped:"stop"};function n(e){var r=new t(4);r.writeUInt32BE(e,0);return r}r.toUInt32=n;r.querystringParse=function(e){var t=i.unescape;i.unescape=unescape;var r=i.parse(e);i.unescape=t;return r};r.querystringStringify=function(e){var t=i.escape;i.escape=escape;var r=i.stringify(e);r=r.replace(/[\@\*\/\+]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});i.escape=t;return r}}).call(this,e("buffer").Buffer)},{buffer:40,querystring:53}],28:[function(e,t,r){(function(t){var i=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 n=e("./common-node");i(r,n)}).call(this,e("buffer").Buffer)},{"./common-node":27,buffer:40,"xtend/mutable":182}],29:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],30:[function(e,t,r){var i=e("wrappy");t.exports=i(n);n.proto=n(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:true})});function n(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:29}],31:[function(e,t,r){(function(r){t.exports=c;var i=e("debug")("simple-peer");var n=e("get-browser-rtc");var a=e("hat");var s=e("inherits");var o=e("is-typedarray");var f=e("once");var u=e("stream");var l=e("typedarray-to-buffer");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.channelName||a(160);if(!e.initiator)t.channelName=null;t.config=e.config||c.config;t.constraints=e.constraints||c.constraints;t.reconnectTimer=e.reconnectTimer||0;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._wrtc=e.wrtc||n();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=!!n();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 i(e){try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e),p,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(i);t._pendingCandidates=[]},t._onError.bind(t))}if(e.candidate){if(t._pc.remoteDescription)i(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(!o.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)&&!o.strict(e)){e=new Uint8Array(e)}var i=e.length||e.byteLength||e.size;t._channel.send(e);t._debug("write: %d bytes",i)};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 i=this;if(i.destroyed)return r(new Error("cannot write after peer is destroyed"));if(i.connected){try{i.send(e)}catch(n){return i._onError(n)}if(i._channel.bufferedAmount>i._maxBufferedAmount){i._debug("start backpressure: bufferedAmount %d",i._channel.bufferedAmount);i._cb=r}else{r(null)}}else{i._debug("write before connect");i._chunk=e;i._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,p,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,p,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==="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(typeof window!=="undefined"&&!!window.mozRTCPeerConnection){e._pc.getStats(null,function(e){var r=[];e.forEach(function(e){r.push(e)});t(r)},e._onError.bind(e))}else{e._pc.getStats(function(e){var r=[];e.result().forEach(function(e){var t={};e.names().forEach(function(r){t[r]=e.stat(r)});t.id=e.id;t.type=e.type;t.timestamp=e.timestamp;r.push(t)});t(r)})}function t(t){t.forEach(function(t){if(t.type==="remotecandidate"){e.remoteAddress=t.ipAddress;e.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 i=e._cb;e._cb=null;i(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 r=e.data;t._debug("read: %d bytes",r.byteLength||r.length);if(r instanceof ArrayBuffer){r=l(new Uint8Array(r));t.push(r)}else{try{r=JSON.parse(r)}catch(i){}t.emit("data",r)}};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];i.apply(null,t)};function p(){}}).call(this,e("buffer").Buffer)},{buffer:40,debug:121,"get-browser-rtc":32,hat:127,inherits:129,"is-typedarray":33,once:30,stream:67,"typedarray-to-buffer":34}],32:[function(e,t,r){t.exports=function i(){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}},{}],33:[function(e,t,r){t.exports=a;a.strict=s;a.loose=o;var i=Object.prototype.toString;var n={"[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 a(e){return s(e)||o(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 o(e){return n[i.call(e)]}},{}],34:[function(e,t,r){(function(r){var i=e("is-typedarray").strict;t.exports=function(e){var t=r.TYPED_ARRAY_SUPPORT?r._augment:function(e){return new r(e)};if(e instanceof Uint8Array){return t(e)}else if(e instanceof ArrayBuffer){return t(new Uint8Array(e))}else if(i(e)){return t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}else{return new r(e)}}}).call(this,e("buffer").Buffer)},{buffer:40,"is-typedarray":33}],35:[function(e,t,r){(function(r){t.exports=l;var i=e("debug")("simple-websocket");var n=e("inherits");var a=e("is-typedarray");var s=e("stream");var o=e("typedarray-to-buffer");var f=e("ws");var u=typeof window!=="undefined"?window.WebSocket:f;n(l,s.Duplex);function l(e,t){var r=this;if(!(r instanceof l))return new l(e,t);if(!t)t={};i("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 u(r.url);r._ws.binaryType="arraybuffer";r._ws.onopen=r._onOpen.bind(r);r._ws.onmessage=r._onMessage.bind(r);r._ws.onclose=r._onClose.bind(r);r._ws.onerror=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)})}})}l.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)}var n=e.length||e.byteLength||e.size;t._ws.send(e);i("write: %d bytes",n)};l.prototype.destroy=function(e){var t=this;t._destroy(null,e)};l.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);i("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 n=r._ws;var a=function(){n.onclose=null;r.emit("close")};if(n.readyState===u.CLOSED){a()}else{try{n.onclose=a;n.close()}catch(e){a()}}n.onopen=null;n.onmessage=null;n.onerror=null}r._ws=null;if(e)r.emit("error",e)};l.prototype._read=function(){};l.prototype._write=function(e,t,r){var n=this;if(n.destroyed)return r(new Error("cannot write after socket is destroyed"));if(n.connected){try{n.send(e)}catch(a){return n._onError(a)}if(typeof f!=="function"&&n._ws.bufferedAmount>n._maxBufferedAmount){i("start backpressure: bufferedAmount %d",n._ws.bufferedAmount);n._cb=r}else{r(null)}}else{i("write before connect");n._chunk=e;n._cb=r}};l.prototype._onMessage=function(e){var t=this;if(t.destroyed)return;var n=e.data;i("read: %d bytes",n.byteLength||n.length);if(n instanceof ArrayBuffer){n=o(new Uint8Array(n));t.push(n)}else if(r.isBuffer(n)){t.push(n)}else{try{n=JSON.parse(n)}catch(a){}t.emit("data",n)}};l.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;i('sent chunk from "write before connect"');var r=e._cb;e._cb=null;r(null)}if(typeof f!=="function"){e._interval=setInterval(function(){if(!e._cb||!e._ws||e._ws.bufferedAmount>e._maxBufferedAmount){return}i("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref()}i("connect");e.emit("connect")};l.prototype._onClose=function(){var e=this;if(e.destroyed)return;i("on close");e._destroy()};l.prototype._onError=function(e){var t=this;if(t.destroyed)return;i("error: %s",e.message||e);t._destroy(e)}}).call(this,e("buffer").Buffer)},{buffer:40,debug:121,inherits:129,"is-typedarray":36,stream:67,"typedarray-to-buffer":37,ws:39}],36:[function(e,t,r){arguments[4][33][0].apply(r,arguments)},{dup:33}],37:[function(e,t,r){arguments[4][34][0].apply(r,arguments)},{buffer:40,dup:34,"is-typedarray":36}],38:[function(e,t,r){},{}],39:[function(e,t,r){arguments[4][38][0].apply(r,arguments)},{dup:38}],40:[function(e,t,r){var i=e("base64-js");var n=e("ieee754");var a=e("is-array");r.Buffer=f;r.SlowBuffer=b;r.INSPECT_MAX_BYTES=50;f.poolSize=8192;var s={};f.TYPED_ARRAY_SUPPORT=function(){function e(){}try{var t=new Uint8Array(1);t.foo=function(){return 42};t.constructor=e;return t.foo()===42&&t.constructor===e&&typeof t.subarray==="function"&&t.subarray(1,1).byteLength===0}catch(r){return false}}();function o(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(e){if(!(this instanceof f)){if(arguments.length>1)return new f(e,arguments[1]);return new f(e)}this.length=0;this.parent=undefined;if(typeof e==="number"){return u(this,e)}if(typeof e==="string"){return l(this,e,arguments.length>1?arguments[1]:"utf8")}return c(this,e)}function u(e,t){e=y(e,t<0?0:_(t)|0);if(!f.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 i=w(t,r)|0;e=y(e,i);e.write(t,r);return e}function c(e,t){if(f.isBuffer(t))return p(e,t);if(a(t))return d(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 h(e,t)}if(t instanceof ArrayBuffer){return m(e,t)}}if(t.length)return v(e,t);return g(e,t)}function p(e,t){var r=_(t.length)|0;e=y(e,r);t.copy(e,0,0,r);return e}function d(e,t){var r=_(t.length)|0;e=y(e,r);for(var i=0;i<r;i+=1){e[i]=t[i]&255}return e}function h(e,t){var r=_(t.length)|0;e=y(e,r);for(var i=0;i<r;i+=1){e[i]=t[i]&255}return e}function m(e,t){if(f.TYPED_ARRAY_SUPPORT){t.byteLength;e=f._augment(new Uint8Array(t))}else{e=h(e,new Uint8Array(t))}return e}function v(e,t){var r=_(t.length)|0;e=y(e,r);for(var i=0;i<r;i+=1){e[i]=t[i]&255}return e}function g(e,t){var r;var i=0;if(t.type==="Buffer"&&a(t.data)){r=t.data;i=_(r.length)|0}e=y(e,i);for(var n=0;n<i;n+=1){e[n]=r[n]&255}return e}function y(e,t){if(f.TYPED_ARRAY_SUPPORT){e=f._augment(new Uint8Array(t))}else{e.length=t;e._isBuffer=true}var r=t!==0&&t<=f.poolSize>>>1;if(r)e.parent=s;return e}function _(e){if(e>=o()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+o().toString(16)+" bytes")}return e|0}function b(e,t){if(!(this instanceof b))return new b(e,t);var r=new f(e,t);delete r.parent;return r}f.isBuffer=function ee(e){return!!(e!=null&&e._isBuffer)};f.compare=function te(e,t){if(!f.isBuffer(e)||!f.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var r=e.length;var i=t.length;var n=0;var a=Math.min(r,i);while(n<a){if(e[n]!==t[n])break;++n}if(n!==a){r=e[n];i=t[n]}if(r<i)return-1;if(i<r)return 1;return 0};f.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}};f.concat=function ie(e,t){if(!a(e))throw new TypeError("list argument must be an Array of Buffers.");if(e.length===0){return new f(0)}var r;if(t===undefined){t=0;for(r=0;r<e.length;r++){t+=e[r].length}}var i=new f(t);var n=0;for(r=0;r<e.length;r++){var s=e[r];s.copy(i,n);n+=s.length}return i};function w(e,t){if(typeof e!=="string")e=""+e;var r=e.length;if(r===0)return 0;var i=false;for(;;){switch(t){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return J(e).length;default:if(i)return $(e).length;t=(""+t).toLowerCase();i=true}}}f.byteLength=w;f.prototype.length=undefined;f.prototype.parent=undefined;function x(e,t,r){var i=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 R(this,t,r);case"binary":return P(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();i=true}}}f.prototype.toString=function ne(){var e=this.length|0;if(e===0)return"";if(arguments.length===0)return L(this,0,e);return x.apply(this,arguments)};f.prototype.equals=function ae(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return f.compare(this,e)===0};f.prototype.inspect=function 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+">"};f.prototype.compare=function oe(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return 0;return f.compare(this,e)};f.prototype.indexOf=function 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(f.isBuffer(e)){return r(this,e,t)}if(typeof e==="number"){if(f.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,e,t)}return r(this,[e],t)}function r(e,t,r){var i=-1;for(var n=0;r+n<e.length;n++){if(e[r+n]===t[i===-1?0:n-i]){if(i===-1)i=n;if(n-i+1===t.length)return r+i}else{i=-1}}return-1}throw new TypeError("val must be string, number or Buffer")};f.prototype.get=function ue(e){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(e)};f.prototype.set=function le(e,t){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(e,t)};function k(e,t,r,i){r=Number(r)||0;var n=e.length-r;if(!i){i=n}else{i=Number(i);if(i>n){i=n}}var a=t.length;if(a%2!==0)throw new Error("Invalid hex string");if(i>a/2){i=a/2}for(var s=0;s<i;s++){var o=parseInt(t.substr(s*2,2),16);if(isNaN(o))throw new Error("Invalid hex string");e[r+s]=o}return s}function S(e,t,r,i){return Q($(t,e.length-r),e,r,i)}function E(e,t,r,i){return Q(Z(t),e,r,i)}function A(e,t,r,i){return E(e,t,r,i)}function U(e,t,r,i){return Q(J(t),e,r,i)}function I(e,t,r,i){return Q(X(t,e.length-r),e,r,i)}f.prototype.write=function ce(e,t,r,i){if(t===undefined){i="utf8";r=this.length;t=0}else if(r===undefined&&typeof t==="string"){i=t;r=this.length;t=0}else if(isFinite(t)){t=t|0;if(isFinite(r)){r=r|0;if(i===undefined)i="utf8"}else{i=r;r=undefined}}else{var n=i;i=t;t=r|0;r=n}var a=this.length-t;if(r===undefined||r>a)r=a;if(e.length>0&&(r<0||t<0)||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!i)i="utf8";var s=false;for(;;){switch(i){case"hex":return k(this,e,t,r);case"utf8":case"utf-8":return S(this,e,t,r);case"ascii":return E(this,e,t,r);case"binary":return A(this,e,t,r);case"base64":return U(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();s=true}}};f.prototype.toJSON=function pe(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(e,t,r){if(t===0&&r===e.length){return i.fromByteArray(e)}else{return i.fromByteArray(e.slice(t,r))}}function L(e,t,r){r=Math.min(e.length,r);var i=[];var n=t;while(n<r){var a=e[n];var s=null;var o=a>239?4:a>223?3:a>191?2:1;if(n+o<=r){var f,u,l,c;switch(o){case 1:if(a<128){s=a}break;case 2:f=e[n+1];if((f&192)===128){c=(a&31)<<6|f&63;if(c>127){s=c}}break;case 3:f=e[n+1];u=e[n+2];if((f&192)===128&&(u&192)===128){c=(a&15)<<12|(f&63)<<6|u&63;if(c>2047&&(c<55296||c>57343)){s=c}}break;case 4:f=e[n+1];u=e[n+2];l=e[n+3];if((f&192)===128&&(u&192)===128&&(l&192)===128){c=(a&15)<<18|(f&63)<<12|(u&63)<<6|l&63;if(c>65535&&c<1114112){s=c}}}}if(s===null){s=65533;o=1}else if(s>65535){s-=65536;i.push(s>>>10&1023|55296);s=56320|s&1023}i.push(s);n+=o}return C(i)}var B=4096;function C(e){var t=e.length;if(t<=B){return String.fromCharCode.apply(String,e)}var r="";var i=0;while(i<t){r+=String.fromCharCode.apply(String,e.slice(i,i+=B))}return r}function R(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;n++){i+=String.fromCharCode(e[n]&127)}return i}function P(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;n++){i+=String.fromCharCode(e[n])}return i}function O(e,t,r){var i=e.length;if(!t||t<0)t=0;if(!r||r<0||r>i)r=i;var n="";for(var a=t;a<r;a++){n+=K(e[a])}return n}function z(e,t,r){var i=e.slice(t,r);var n="";for(var a=0;a<i.length;a+=2){n+=String.fromCharCode(i[a]+i[a+1]*256)}return n}f.prototype.slice=function de(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 i;if(f.TYPED_ARRAY_SUPPORT){i=f._augment(this.subarray(e,t))}else{var n=t-e;i=new f(n,undefined);for(var a=0;a<n;a++){i[a]=this[a+e]}}if(i.length)i.parent=this.parent||this;return i};function F(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUIntLE=function he(e,t,r){e=e|0;t=t|0;if(!r)F(e,t,this.length);var i=this[e];var n=1;var a=0;while(++a<t&&(n*=256)){i+=this[e+a]*n}return i};f.prototype.readUIntBE=function me(e,t,r){e=e|0;t=t|0;if(!r){F(e,t,this.length)}var i=this[e+--t];var n=1;while(t>0&&(n*=256)){i+=this[e+--t]*n}return i};f.prototype.readUInt8=function ve(e,t){if(!t)F(e,1,this.length);return this[e]};f.prototype.readUInt16LE=function ge(e,t){if(!t)F(e,2,this.length);return this[e]|this[e+1]<<8};f.prototype.readUInt16BE=function ye(e,t){if(!t)F(e,2,this.length);return this[e]<<8|this[e+1]};f.prototype.readUInt32LE=function _e(e,t){if(!t)F(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUInt32BE=function be(e,t){if(!t)F(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function we(e,t,r){e=e|0;t=t|0;if(!r)F(e,t,this.length);var i=this[e];var n=1;var a=0;while(++a<t&&(n*=256)){i+=this[e+a]*n}n*=128;if(i>=n)i-=Math.pow(2,8*t);return i};f.prototype.readIntBE=function xe(e,t,r){e=e|0;t=t|0;if(!r)F(e,t,this.length);var i=t;var n=1;var a=this[e+--i];while(i>0&&(n*=256)){a+=this[e+--i]*n}n*=128;if(a>=n)a-=Math.pow(2,8*t);return a};f.prototype.readInt8=function ke(e,t){if(!t)F(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};f.prototype.readInt16LE=function Se(e,t){if(!t)F(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};f.prototype.readInt16BE=function Ee(e,t){if(!t)F(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};f.prototype.readInt32LE=function Ae(e,t){if(!t)F(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function Ue(e,t){if(!t)F(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function Ie(e,t){if(!t)F(e,4,this.length);return n.read(this,e,true,23,4)};f.prototype.readFloatBE=function Te(e,t){if(!t)F(e,4,this.length);return n.read(this,e,false,23,4)};f.prototype.readDoubleLE=function Le(e,t){if(!t)F(e,8,this.length);return n.read(this,e,true,52,8)};f.prototype.readDoubleBE=function Be(e,t){if(!t)F(e,8,this.length);return n.read(this,e,false,52,8)};function M(e,t,r,i,n,a){if(!f.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>n||t<a)throw new RangeError("value is out of bounds");if(r+i>e.length)throw new RangeError("index out of range")}f.prototype.writeUIntLE=function Ce(e,t,r,i){e=+e;t=t|0;r=r|0;if(!i)M(this,e,t,r,Math.pow(2,8*r),0);var n=1;var a=0;this[t]=e&255;while(++a<r&&(n*=256)){this[t+a]=e/n&255}return t+r};f.prototype.writeUIntBE=function Re(e,t,r,i){e=+e;t=t|0;r=r|0;if(!i)M(this,e,t,r,Math.pow(2,8*r),0);var n=r-1;var a=1;this[t+n]=e&255;while(--n>=0&&(a*=256)){this[t+n]=e/a&255}return t+r};f.prototype.writeUInt8=function Pe(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,1,255,0);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function j(e,t,r,i){if(t<0)t=65535+t+1;for(var n=0,a=Math.min(e.length-r,2);n<a;n++){e[r+n]=(t&255<<8*(i?n:1-n))>>>(i?n:1-n)*8}}f.prototype.writeUInt16LE=function Oe(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeUInt16BE=function ze(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};function D(e,t,r,i){if(t<0)t=4294967295+t+1;for(var n=0,a=Math.min(e.length-r,4);n<a;n++){e[r+n]=t>>>(i?n:3-n)*8&255}}f.prototype.writeUInt32LE=function Fe(e,t,r){
-e=+e;t=t|0;if(!r)M(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e}else{D(this,e,t,true)}return t+4};f.prototype.writeUInt32BE=function Me(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{D(this,e,t,false)}return t+4};f.prototype.writeIntLE=function je(e,t,r,i){e=+e;t=t|0;if(!i){var n=Math.pow(2,8*r-1);M(this,e,t,r,n-1,-n)}var a=0;var s=1;var o=e<0?1:0;this[t]=e&255;while(++a<r&&(s*=256)){this[t+a]=(e/s>>0)-o&255}return t+r};f.prototype.writeIntBE=function De(e,t,r,i){e=+e;t=t|0;if(!i){var n=Math.pow(2,8*r-1);M(this,e,t,r,n-1,-n)}var a=r-1;var s=1;var o=e<0?1:0;this[t+a]=e&255;while(--a>=0&&(s*=256)){this[t+a]=(e/s>>0)-o&255}return t+r};f.prototype.writeInt8=function Ne(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,1,127,-128);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e;return t+1};f.prototype.writeInt16LE=function He(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeInt16BE=function qe(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};f.prototype.writeInt32LE=function Ge(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,4,2147483647,-2147483648);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{D(this,e,t,true)}return t+4};f.prototype.writeInt32BE=function We(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{D(this,e,t,false)}return t+4};function N(e,t,r,i,n,a){if(t>n||t<a)throw new RangeError("value is out of bounds");if(r+i>e.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function H(e,t,r,i,a){if(!a){N(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}n.write(e,t,r,i,23,4);return r+4}f.prototype.writeFloatLE=function Ve(e,t,r){return H(this,e,t,true,r)};f.prototype.writeFloatBE=function Ye(e,t,r){return H(this,e,t,false,r)};function q(e,t,r,i,a){if(!a){N(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}n.write(e,t,r,i,52,8);return r+8}f.prototype.writeDoubleLE=function Ke(e,t,r){return q(this,e,t,true,r)};f.prototype.writeDoubleBE=function $e(e,t,r){return q(this,e,t,false,r)};f.prototype.copy=function Ze(e,t,r,i){if(!r)r=0;if(!i&&i!==0)i=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(i>0&&i<r)i=r;if(i===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(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(e.length-t<i-r){i=e.length-t+r}var n=i-r;var a;if(this===e&&r<t&&t<i){for(a=n-1;a>=0;a--){e[a+t]=this[a+r]}}else if(n<1e3||!f.TYPED_ARRAY_SUPPORT){for(a=0;a<n;a++){e[a+t]=this[a+r]}}else{e._set(this.subarray(r,r+n),t)}return n};f.prototype.fill=function Xe(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 i;if(typeof e==="number"){for(i=t;i<r;i++){this[i]=e}}else{var n=$(e.toString());var a=n.length;for(i=t;i<r;i++){this[i]=n[i%a]}}return this};f.prototype.toArrayBuffer=function Je(){if(typeof Uint8Array!=="undefined"){if(f.TYPED_ARRAY_SUPPORT){return new f(this).buffer}else{var e=new Uint8Array(this.length);for(var t=0,r=e.length;t<r;t+=1){e[t]=this[t]}return e.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var G=f.prototype;f._augment=function Qe(e){e.constructor=f;e._isBuffer=true;e._set=e.set;e.get=G.get;e.set=G.set;e.write=G.write;e.toString=G.toString;e.toLocaleString=G.toString;e.toJSON=G.toJSON;e.equals=G.equals;e.compare=G.compare;e.indexOf=G.indexOf;e.copy=G.copy;e.slice=G.slice;e.readUIntLE=G.readUIntLE;e.readUIntBE=G.readUIntBE;e.readUInt8=G.readUInt8;e.readUInt16LE=G.readUInt16LE;e.readUInt16BE=G.readUInt16BE;e.readUInt32LE=G.readUInt32LE;e.readUInt32BE=G.readUInt32BE;e.readIntLE=G.readIntLE;e.readIntBE=G.readIntBE;e.readInt8=G.readInt8;e.readInt16LE=G.readInt16LE;e.readInt16BE=G.readInt16BE;e.readInt32LE=G.readInt32LE;e.readInt32BE=G.readInt32BE;e.readFloatLE=G.readFloatLE;e.readFloatBE=G.readFloatBE;e.readDoubleLE=G.readDoubleLE;e.readDoubleBE=G.readDoubleBE;e.writeUInt8=G.writeUInt8;e.writeUIntLE=G.writeUIntLE;e.writeUIntBE=G.writeUIntBE;e.writeUInt16LE=G.writeUInt16LE;e.writeUInt16BE=G.writeUInt16BE;e.writeUInt32LE=G.writeUInt32LE;e.writeUInt32BE=G.writeUInt32BE;e.writeIntLE=G.writeIntLE;e.writeIntBE=G.writeIntBE;e.writeInt8=G.writeInt8;e.writeInt16LE=G.writeInt16LE;e.writeInt16BE=G.writeInt16BE;e.writeInt32LE=G.writeInt32LE;e.writeInt32BE=G.writeInt32BE;e.writeFloatLE=G.writeFloatLE;e.writeFloatBE=G.writeFloatBE;e.writeDoubleLE=G.writeDoubleLE;e.writeDoubleBE=G.writeDoubleBE;e.fill=G.fill;e.inspect=G.inspect;e.toArrayBuffer=G.toArrayBuffer;return e};var W=/[^+\/0-9A-Za-z-_]/g;function V(e){e=Y(e).replace(W,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function Y(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function K(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function $(e,t){t=t||Infinity;var r;var i=e.length;var n=null;var a=[];for(var s=0;s<i;s++){r=e.charCodeAt(s);if(r>55295&&r<57344){if(!n){if(r>56319){if((t-=3)>-1)a.push(239,191,189);continue}else if(s+1===i){if((t-=3)>-1)a.push(239,191,189);continue}n=r;continue}if(r<56320){if((t-=3)>-1)a.push(239,191,189);n=r;continue}r=n-55296<<10|r-56320|65536}else if(n){if((t-=3)>-1)a.push(239,191,189)}n=null;if(r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return a}function Z(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,i,n;var a=[];for(var s=0;s<e.length;s++){if((t-=2)<0)break;r=e.charCodeAt(s);i=r>>8;n=r%256;a.push(n);a.push(i)}return a}function J(e){return i.toByteArray(V(e))}function Q(e,t,r,i){for(var n=0;n<i;n++){if(n+r>=t.length||n>=e.length)break;t[n+r]=e[n]}return n}},{"base64-js":41,ieee754:42,"is-array":43}],41:[function(e,t,r){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){"use strict";var t=typeof Uint8Array!=="undefined"?Uint8Array:Array;var r="+".charCodeAt(0);var n="/".charCodeAt(0);var a="0".charCodeAt(0);var s="a".charCodeAt(0);var o="A".charCodeAt(0);var f="-".charCodeAt(0);var u="_".charCodeAt(0);function l(e){var t=e.charCodeAt(0);if(t===r||t===f)return 62;if(t===n||t===u)return 63;if(t<a)return-1;if(t<a+10)return t-a+26+26;if(t<o+26)return t-o;if(t<s+26)return t-s+26}function c(e){var r,i,n,a,s,o;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;o=new t(e.length*3/4-s);n=s>0?e.length-4:e.length;var u=0;function c(e){o[u++]=e}for(r=0,i=0;r<n;r+=4,i+=3){a=l(e.charAt(r))<<18|l(e.charAt(r+1))<<12|l(e.charAt(r+2))<<6|l(e.charAt(r+3));c((a&16711680)>>16);c((a&65280)>>8);c(a&255)}if(s===2){a=l(e.charAt(r))<<2|l(e.charAt(r+1))>>4;c(a&255)}else if(s===1){a=l(e.charAt(r))<<10|l(e.charAt(r+1))<<4|l(e.charAt(r+2))>>2;c(a>>8&255);c(a&255)}return o}function p(e){var t,r=e.length%3,n="",a,s;function o(e){return i.charAt(e)}function f(e){return o(e>>18&63)+o(e>>12&63)+o(e>>6&63)+o(e&63)}for(t=0,s=e.length-r;t<s;t+=3){a=(e[t]<<16)+(e[t+1]<<8)+e[t+2];n+=f(a)}switch(r){case 1:a=e[e.length-1];n+=o(a>>2);n+=o(a<<4&63);n+="==";break;case 2:a=(e[e.length-2]<<8)+e[e.length-1];n+=o(a>>10);n+=o(a>>4&63);n+=o(a<<2&63);n+="=";break}return n}e.toByteArray=c;e.fromByteArray=p})(typeof r==="undefined"?this.base64js={}:r)},{}],42:[function(e,t,r){r.read=function(e,t,r,i,n){var a,s;var o=n*8-i-1;var f=(1<<o)-1;var u=f>>1;var l=-7;var c=r?n-1:0;var p=r?-1:1;var d=e[t+c];c+=p;a=d&(1<<-l)-1;d>>=-l;l+=o;for(;l>0;a=a*256+e[t+c],c+=p,l-=8){}s=a&(1<<-l)-1;a>>=-l;l+=i;for(;l>0;s=s*256+e[t+c],c+=p,l-=8){}if(a===0){a=1-u}else if(a===f){return s?NaN:(d?-1:1)*Infinity}else{s=s+Math.pow(2,i);a=a-u}return(d?-1:1)*s*Math.pow(2,a-i)};r.write=function(e,t,r,i,n,a){var s,o,f;var u=a*8-n-1;var l=(1<<u)-1;var c=l>>1;var p=n===23?Math.pow(2,-24)-Math.pow(2,-77):0;var d=i?0:a-1;var h=i?1:-1;var m=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){o=isNaN(t)?1:0;s=l}else{s=Math.floor(Math.log(t)/Math.LN2);if(t*(f=Math.pow(2,-s))<1){s--;f*=2}if(s+c>=1){t+=p/f}else{t+=p*Math.pow(2,1-c)}if(t*f>=2){s++;f/=2}if(s+c>=l){o=0;s=l}else if(s+c>=1){o=(t*f-1)*Math.pow(2,n);s=s+c}else{o=t*Math.pow(2,c-1)*Math.pow(2,n);s=0}}for(;n>=8;e[r+d]=o&255,d+=h,o/=256,n-=8){}s=s<<n|o;u+=n;for(;u>0;e[r+d]=s&255,d+=h,s/=256,u-=8){}e[r+d-h]|=m*128}},{}],43:[function(e,t,r){var i=Array.isArray;var n=Object.prototype.toString;t.exports=i||function(e){return!!e&&"[object Array]"==n.call(e)}},{}],44:[function(e,t,r){function i(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=i;i.EventEmitter=i;i.prototype._events=undefined;i.prototype._maxListeners=undefined;i.defaultMaxListeners=10;i.prototype.setMaxListeners=function(e){if(!a(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};i.prototype.emit=function(e){var t,r,i,a,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(o(r))return false;if(n(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:i=arguments.length;a=new Array(i-1);for(f=1;f<i;f++)a[f-1]=arguments[f];r.apply(this,a)}}else if(s(r)){i=arguments.length;a=new Array(i-1);for(f=1;f<i;f++)a[f-1]=arguments[f];u=r.slice();i=u.length;for(f=0;f<i;f++)u[f].apply(this,a)}return true};i.prototype.addListener=function(e,t){var r;if(!n(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,n(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(s(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(s(this._events[e])&&!this._events[e].warned){var r;if(!o(this._maxListeners)){r=this._maxListeners}else{r=i.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};i.prototype.on=i.prototype.addListener;i.prototype.once=function(e,t){if(!n(t))throw TypeError("listener must be a function");var r=false;function i(){this.removeListener(e,i);if(!r){r=true;t.apply(this,arguments)}}i.listener=t;this.on(e,i);return this};i.prototype.removeListener=function(e,t){var r,i,a,o;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];a=r.length;i=-1;if(r===t||n(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(s(r)){for(o=a;o-->0;){if(r[o]===t||r[o].listener&&r[o].listener===t){i=o;break}}if(i<0)return this;if(r.length===1){r.length=0;delete this._events[e]}else{r.splice(i,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};i.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(n(r)){this.removeListener(e,r)}else{while(r.length)this.removeListener(e,r[r.length-1])}delete this._events[e];return this};i.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(n(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};i.listenerCount=function(e,t){var r;if(!e._events||!e._events[t])r=0;else if(n(e._events[t]))r=1;else r=e._events[t].length;return r};function n(e){return typeof e==="function"}function a(e){return typeof e==="number"}function s(e){return typeof e==="object"&&e!==null}function o(e){return e===void 0}},{}],45:[function(e,t,r){var i=e("http");var n=t.exports;for(var a in i){if(i.hasOwnProperty(a))n[a]=i[a]}n.request=function(e,t){if(!e)e={};e.scheme="https";return i.request.call(this,e,t)}},{http:68}],46:[function(e,t,r){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],47:[function(e,t,r){r.endianness=function(){return"LE"};r.hostname=function(){if(typeof location!=="undefined"){return location.hostname}else return""};r.loadavg=function(){return[]};r.uptime=function(){return 0};r.freemem=function(){return Number.MAX_VALUE};r.totalmem=function(){return Number.MAX_VALUE};r.cpus=function(){return[]};r.type=function(){return"Browser"};r.release=function(){if(typeof navigator!=="undefined"){return navigator.appVersion}return""};r.networkInterfaces=r.getNetworkInterfaces=function(){return{}};r.arch=function(){return"javascript"};r.platform=function(){return"browser"};r.tmpdir=r.tmpDir=function(){return"/tmp"};r.EOL="\n"},{}],48:[function(e,t,r){(function(e){function t(e,t){var r=0;for(var i=e.length-1;i>=0;i--){var n=e[i];if(n==="."){e.splice(i,1)}else if(n===".."){e.splice(i,1);r++}else if(r){e.splice(i,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var n=function(e){return i.exec(e).slice(1)};r.resolve=function(){var r="",i=false;for(var n=arguments.length-1;n>=-1&&!i;n--){var s=n>=0?arguments[n]:e.cwd();if(typeof s!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!s){continue}r=s+"/"+r;i=s.charAt(0)==="/"}r=t(a(r.split("/"),function(e){return!!e}),!i).join("/");return(i?"/":"")+r||"."};r.normalize=function(e){var i=r.isAbsolute(e),n=s(e,-1)==="/";e=t(a(e.split("/"),function(e){return!!e}),!i).join("/");if(!e&&!i){e="."}if(e&&n){e+="/"}return(i?"/":"")+e};r.isAbsolute=function(e){return e.charAt(0)==="/"};r.join=function(){var e=Array.prototype.slice.call(arguments,0);return r.normalize(a(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 i(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 n=i(e.split("/"));var a=i(t.split("/"));var s=Math.min(n.length,a.length);var o=s;for(var f=0;f<s;f++){if(n[f]!==a[f]){o=f;break}}var u=[];for(var f=o;f<n.length;f++){u.push("..")}u=u.concat(a.slice(o));return u.join("/")};r.sep="/";r.delimiter=":";r.dirname=function(e){var t=n(e),r=t[0],i=t[1];if(!r&&!i){return"."}if(i){i=i.substr(0,i.length-1)}return r+i};r.basename=function(e,t){var r=n(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 n(e)[3]};function a(e,t){if(e.filter)return e.filter(t);var r=[];for(var i=0;i<e.length;i++){if(t(e[i],i,e))r.push(e[i])}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:49}],49:[function(e,t,r){var i=t.exports={};var n=[];var a=false;var s;var o=-1;function f(){a=false;if(s.length){n=s.concat(n)}else{o=-1}if(n.length){u()}}function u(){if(a){return}var e=setTimeout(f);a=true;var t=n.length;while(t){s=n;n=[];while(++o<t){s[o].run()}o=-1;t=n.length}s=null;a=false;clearTimeout(e)}i.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]}}n.push(new l(e,t));if(n.length===1&&!a){setTimeout(u,0)}};function l(e,t){this.fun=e;this.array=t}l.prototype.run=function(){this.fun.apply(null,this.array)};i.title="browser";i.browser=true;i.env={};i.argv=[];i.version="";i.versions={};function c(){}i.on=c;i.addListener=c;i.once=c;i.off=c;i.removeListener=c;i.removeAllListeners=c;i.emit=c;i.binding=function(e){throw new Error("process.binding is not supported")};i.cwd=function(){return"/"};i.chdir=function(e){throw new Error("process.chdir is not supported")};i.umask=function(){return 0}},{}],50:[function(t,r,i){(function(t){(function(n){var a=typeof i=="object"&&i&&!i.nodeType&&i;var s=typeof r=="object"&&r&&!r.nodeType&&r;var o=typeof t=="object"&&t;if(o.global===o||o.window===o||o.self===o){n=o}var f,u=2147483647,l=36,c=1,p=26,d=38,h=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"},x=l-c,k=Math.floor,S=String.fromCharCode,E;function A(e){throw RangeError(w[e])}function U(e,t){var r=e.length;var i=[];while(r--){i[r]=t(e[r])}return i}function I(e,t){var r=e.split("@");var i="";if(r.length>1){i=r[0]+"@";e=r[1]}e=e.replace(b,".");var n=e.split(".");var a=U(n,t).join(".");return i+a}function T(e){var t=[],r=0,i=e.length,n,a;while(r<i){n=e.charCodeAt(r++);if(n>=55296&&n<=56319&&r<i){a=e.charCodeAt(r++);if((a&64512)==56320){t.push(((n&1023)<<10)+(a&1023)+65536)}else{t.push(n);r--}}else{t.push(n)}}return t}function L(e){return U(e,function(e){var t="";if(e>65535){e-=65536;t+=S(e>>>10&1023|55296);e=56320|e&1023}t+=S(e);return t}).join("")}function B(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return l}function C(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function R(e,t,r){var i=0;e=r?k(e/h):e>>1;e+=k(e/t);for(;e>x*p>>1;i+=l){e=k(e/x)}return k(i+(x+1)*e/(e+d))}function P(e){var t=[],r=e.length,i,n=0,a=v,s=m,o,f,d,h,y,_,b,w,x;o=e.lastIndexOf(g);if(o<0){o=0}for(f=0;f<o;++f){if(e.charCodeAt(f)>=128){A("not-basic")}t.push(e.charCodeAt(f))}for(d=o>0?o+1:0;d<r;){for(h=n,y=1,_=l;;_+=l){if(d>=r){A("invalid-input")}b=B(e.charCodeAt(d++));if(b>=l||b>k((u-n)/y)){A("overflow")}n+=b*y;w=_<=s?c:_>=s+p?p:_-s;if(b<w){break}x=l-w;if(y>k(u/x)){A("overflow")}y*=x}i=t.length+1;s=R(n-h,i,h==0);if(k(n/i)>u-a){A("overflow")}a+=k(n/i);n%=i;t.splice(n++,0,a)}return L(t)}function O(e){var t,r,i,n,a,s,o,f,d,h,y,_=[],b,w,x,E;e=T(e);b=e.length;t=v;r=0;a=m;for(s=0;s<b;++s){y=e[s];if(y<128){_.push(S(y))}}i=n=_.length;if(n){_.push(g)}while(i<b){for(o=u,s=0;s<b;++s){y=e[s];if(y>=t&&y<o){o=y}}w=i+1;if(o-t>k((u-r)/w)){A("overflow")}r+=(o-t)*w;t=o;for(s=0;s<b;++s){y=e[s];if(y<t&&++r>u){A("overflow")}if(y==t){for(f=r,d=l;;d+=l){h=d<=a?c:d>=a+p?p:d-a;if(f<h){break}E=f-h;x=l-h;_.push(S(C(h+E%x,0)));f=k(E/x)}_.push(S(C(f,0)));a=R(r,w,i==n);r=0;++i}}++r;++t}return _.join("")}function z(e){return I(e,function(e){return y.test(e)?P(e.slice(4).toLowerCase()):e})}function F(e){return I(e,function(e){return _.test(e)?"xn--"+O(e):e})}f={version:"1.3.2",ucs2:{decode:T,encode:L},decode:P,encode:O,toASCII:F,toUnicode:z};if(typeof e=="function"&&typeof e.amd=="object"&&e.amd){e("punycode",function(){return f})}else if(a&&s){if(r.exports==a){s.exports=f}else{for(E in f){f.hasOwnProperty(E)&&(a[E]=f[E])}}}else{n.punycode=f}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],51:[function(e,t,r){"use strict";function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,a){t=t||"&";r=r||"=";var s={};if(typeof e!=="string"||e.length===0){return s}var o=/\+/g;e=e.split(t);var f=1e3;if(a&&typeof a.maxKeys==="number"){f=a.maxKeys}var u=e.length;if(f>0&&u>f){u=f}for(var l=0;l<u;++l){var c=e[l].replace(o,"%20"),p=c.indexOf(r),d,h,m,v;if(p>=0){d=c.substr(0,p);h=c.substr(p+1)}else{d=c;h=""}m=decodeURIComponent(d);v=decodeURIComponent(h);if(!i(s,m)){s[m]=v}else if(n(s[m])){s[m].push(v)}else{s[m]=[s[m],v]}}return s};var n=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],52:[function(e,t,r){"use strict";var i=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,o){t=t||"&";r=r||"=";if(e===null){e=undefined}if(typeof e==="object"){return a(s(e),function(s){var o=encodeURIComponent(i(s))+r;if(n(e[s])){return a(e[s],function(e){return o+encodeURIComponent(i(e))}).join(t)}else{return o+encodeURIComponent(i(e[s]))}}).join(t)}if(!o)return"";return encodeURIComponent(i(o))+r+encodeURIComponent(i(e))};var n=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};function a(e,t){if(e.map)return e.map(t);var r=[];for(var i=0;i<e.length;i++){r.push(t(e[i],i))}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}},{}],53:[function(e,t,r){"use strict";r.decode=r.parse=e("./decode");r.encode=r.stringify=e("./encode")},{"./decode":51,"./encode":52}],54:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":55}],55:[function(e,t,r){"use strict";var i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=c;var n=e("process-nextick-args");var a=e("core-util-is");a.inherits=e("inherits");var s=e("./_stream_readable");var o=e("./_stream_writable");a.inherits(c,s);var f=i(o.prototype);for(var u=0;u<f.length;u++){var l=f[u];if(!c.prototype[l])c.prototype[l]=o.prototype[l]}function c(e){if(!(this instanceof c))return new c(e);s.call(this,e);o.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",p)}function p(){if(this.allowHalfOpen||this._writableState.ended)return;n(d,this)}function d(e){e.end()}function h(e,t){for(var r=0,i=e.length;r<i;r++){t(e[r],r)}}},{"./_stream_readable":57,"./_stream_writable":59,"core-util-is":60,inherits:129,"process-nextick-args":61}],56:[function(e,t,r){"use strict";t.exports=a;var i=e("./_stream_transform");var n=e("core-util-is");n.inherits=e("inherits");n.inherits(a,i);function a(e){if(!(this instanceof a))return new a(e);i.call(this,e)}a.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":58,"core-util-is":60,inherits:129}],57:[function(e,t,r){(function(r){"use strict";t.exports=p;var i=e("process-nextick-args");var n=e("isarray");var a=e("buffer").Buffer;p.ReadableState=c;var s=e("events").EventEmitter;if(!s.listenerCount)s.listenerCount=function(e,t){return e.listeners(t).length};var o;(function(){try{o=e("st"+"ream")}catch(t){}finally{if(!o)o=e("events").EventEmitter}})();var a=e("buffer").Buffer;var f=e("core-util-is");f.inherits=e("inherits");var u=e("util");if(u&&u.debuglog){u=u.debuglog("stream")}else{u=function(){}}var l;f.inherits(p,o);function c(t,r){var i=e("./_stream_duplex");t=t||{};this.objectMode=!!t.objectMode;if(r instanceof i)this.objectMode=this.objectMode||!!t.readableObjectMode;var n=t.highWaterMark;var a=this.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:a;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(!l)l=e("string_decoder/").StringDecoder;this.decoder=new l(t.encoding);this.encoding=t.encoding}}function p(t){var r=e("./_stream_duplex");if(!(this instanceof p))return new p(t);this._readableState=new c(t,this);this.readable=true;if(t&&typeof t.read==="function")this._read=t.read;o.call(this)}p.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 a(e,t);t=""}}return d(this,r,e,t,false)};p.prototype.unshift=function(e){var t=this._readableState;return d(this,t,e,"",true)};p.prototype.isPaused=function(){return this._readableState.flowing===false};function d(e,t,r,i,n){var a=y(t,r);if(a){e.emit("error",a)}else if(r===null){t.reading=false;_(e,t)}else if(t.objectMode||r&&r.length>0){if(t.ended&&!n){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&n){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{if(t.decoder&&!n&&!i)r=t.decoder.write(r);if(!n)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(n)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)b(e)}x(e,t)}}else if(!n){t.reading=false}return h(t)}function h(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}p.prototype.setEncoding=function(t){if(!l)l=e("string_decoder/").StringDecoder;this._readableState.decoder=new l(t);this._readableState.encoding=t;return this};var m=8388608;function v(e){if(e>=m){e=m}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function g(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=v(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else{return t.length}}return e}p.prototype.read=function(e){u("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)){u("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)L(this);else b(this);return null}e=g(e,t);if(e===0&&t.ended){if(t.length===0)L(this);return null}var i=t.needReadable;u("need readable",i);if(t.length===0||t.length-e<t.highWaterMark){i=true;u("length less than watermark",i)}if(t.ended||t.reading){i=false;u("reading or ended",i)}if(i){u("do read");t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(i&&!t.reading)e=g(r,t);var n;if(e>0)n=T(e,t);else n=null;if(n===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)L(this);if(n!==null)this.emit("data",n);return n};function y(e,t){var r=null;if(!a.isBuffer(t)&&typeof t!=="string"&&t!==null&&t!==undefined&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function _(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;b(e)}function b(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){u("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)i(w,e);else w(e)}}function w(e){u("emit readable");e.emit("readable");I(e)}function x(e,t){if(!t.readingMore){t.readingMore=true;i(k,e,t)}}function k(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){u("maybeReadMore read 0");e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}p.prototype._read=function(e){this.emit("error",new Error("not implemented"))};p.prototype.pipe=function(e,t){var a=this;var o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e);break}o.pipesCount+=1;u("pipe count=%d opts=%j",o.pipesCount,t);var f=(!t||t.end!==false)&&e!==r.stdout&&e!==r.stderr;var l=f?p:h;if(o.endEmitted)i(l);else a.once("end",l);e.on("unpipe",c);function c(e){u("onunpipe");if(e===a){h()}}function p(){u("onend");e.end()}var d=S(a);e.on("drain",d);function h(){u("cleanup");e.removeListener("close",g);e.removeListener("finish",y);e.removeListener("drain",d);e.removeListener("error",v);e.removeListener("unpipe",c);a.removeListener("end",p);a.removeListener("end",h);a.removeListener("data",m);if(o.awaitDrain&&(!e._writableState||e._writableState.needDrain))d()}a.on("data",m);function m(t){u("ondata");var r=e.write(t);if(false===r){u("false write response, pause",a._readableState.awaitDrain);a._readableState.awaitDrain++;a.pause()}}function v(t){u("onerror",t);_();e.removeListener("error",v);if(s.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",v);else if(n(e._events.error))e._events.error.unshift(v);else e._events.error=[v,e._events.error];function g(){e.removeListener("finish",y);_()}e.once("close",g);function y(){u("onfinish");e.removeListener("close",g);_()}e.once("finish",y);function _(){u("unpipe");a.unpipe(e)}e.emit("pipe",a);if(!o.flowing){u("pipe resume");a.resume()}return e};function S(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&s.listenerCount(e,"data")){t.flowing=true;I(e)}}}p.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 i=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var n=0;n<i;n++)r[n].emit("unpipe",this);return this}var n=R(t.pipes,e);if(n===-1)return this;t.pipes.splice(n,1);t.pipesCount-=1;if(t.pipesCount===1)t.pipes=t.pipes[0];e.emit("unpipe",this);return this};p.prototype.on=function(e,t){var r=o.prototype.on.call(this,e,t);if(e==="data"&&false!==this._readableState.flowing){this.resume()}if(e==="readable"&&this.readable){var n=this._readableState;if(!n.readableListening){n.readableListening=true;n.emittedReadable=false;n.needReadable=true;if(!n.reading){i(E,this)}else if(n.length){b(this,n)}}}return r};p.prototype.addListener=p.prototype.on;function E(e){u("readable nexttick read 0");e.read(0)}p.prototype.resume=function(){var e=this._readableState;if(!e.flowing){u("resume");e.flowing=true;A(this,e)}return this};function A(e,t){if(!t.resumeScheduled){t.resumeScheduled=true;i(U,e,t)}}function U(e,t){if(!t.reading){u("resume read 0");e.read(0)}t.resumeScheduled=false;e.emit("resume");I(e);if(t.flowing&&!t.reading)e.read(0)}p.prototype.pause=function(){u("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){u("pause");this._readableState.flowing=false;this.emit("pause")}return this};function I(e){var t=e._readableState;u("flow",t.flowing);if(t.flowing){do{var r=e.read()}while(null!==r&&t.flowing)}}p.prototype.wrap=function(e){var t=this._readableState;var r=false;var i=this;e.on("end",function(){u("wrapped end");if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)i.push(e)}i.push(null)});e.on("data",function(n){u("wrapped data");if(t.decoder)n=t.decoder.write(n);if(t.objectMode&&(n===null||n===undefined))return;else if(!t.objectMode&&(!n||!n.length))return;var a=i.push(n);if(!a){r=true;e.pause()}});for(var n in e){if(this[n]===undefined&&typeof e[n]==="function"){this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n)}}var a=["error","close","destroy","pause","resume"];C(a,function(t){e.on(t,i.emit.bind(i,t))});
-i._read=function(t){u("wrapped _read",t);if(r){r=false;e.resume()}};return i};p._fromList=T;function T(e,t){var r=t.buffer;var i=t.length;var n=!!t.decoder;var s=!!t.objectMode;var o;if(r.length===0)return null;if(i===0)o=null;else if(s)o=r.shift();else if(!e||e>=i){if(n)o=r.join("");else o=a.concat(r,i);r.length=0}else{if(e<r[0].length){var f=r[0];o=f.slice(0,e);r[0]=f.slice(e)}else if(e===r[0].length){o=r.shift()}else{if(n)o="";else o=new a(e);var u=0;for(var l=0,c=r.length;l<c&&u<e;l++){var f=r[0];var p=Math.min(e-u,f.length);if(n)o+=f.slice(0,p);else f.copy(o,u,0,p);if(p<f.length)r[0]=f.slice(p);else r.shift();u+=p}}}return o}function L(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;i(B,t,e)}}function B(e,t){if(!e.endEmitted&&e.length===0){e.endEmitted=true;t.readable=false;t.emit("end")}}function C(e,t){for(var r=0,i=e.length;r<i;r++){t(e[r],r)}}function R(e,t){for(var r=0,i=e.length;r<i;r++){if(e[r]===t)return r}return-1}}).call(this,e("_process"))},{"./_stream_duplex":55,_process:49,buffer:40,"core-util-is":60,events:44,inherits:129,isarray:46,"process-nextick-args":61,"string_decoder/":77,util:39}],58:[function(e,t,r){"use strict";t.exports=o;var i=e("./_stream_duplex");var n=e("core-util-is");n.inherits=e("inherits");n.inherits(o,i);function a(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 i=e._transformState;i.transforming=false;var n=i.writecb;if(!n)return e.emit("error",new Error("no writecb in Transform class"));i.writechunk=null;i.writecb=null;if(r!==null&&r!==undefined)e.push(r);if(n)n(t);var a=e._readableState;a.reading=false;if(a.needReadable||a.length<a.highWaterMark){e._read(a.highWaterMark)}}function o(e){if(!(this instanceof o))return new o(e);i.call(this,e);this._transformState=new a(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)})}o.prototype.push=function(e,t){this._transformState.needTransform=false;return i.prototype.push.call(this,e,t)};o.prototype._transform=function(e,t,r){throw new Error("not implemented")};o.prototype._write=function(e,t,r){var i=this._transformState;i.writecb=r;i.writechunk=e;i.writeencoding=t;if(!i.transforming){var n=this._readableState;if(i.needTransform||n.needReadable||n.length<n.highWaterMark)this._read(n.highWaterMark)}};o.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 i=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(i.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":55,"core-util-is":60,inherits:129}],59:[function(e,t,r){"use strict";t.exports=l;var i=e("process-nextick-args");var n=e("buffer").Buffer;l.WritableState=u;var a=e("core-util-is");a.inherits=e("inherits");var s;(function(){try{s=e("st"+"ream")}catch(t){}finally{if(!s)s=e("events").EventEmitter}})();var n=e("buffer").Buffer;a.inherits(l,s);function o(){}function f(e,t,r){this.chunk=e;this.encoding=t;this.callback=r;this.next=null}function u(t,r){var i=e("./_stream_duplex");t=t||{};this.objectMode=!!t.objectMode;if(r instanceof i)this.objectMode=this.objectMode||!!t.writableObjectMode;var n=t.highWaterMark;var a=this.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:a;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var s=t.decodeStrings===false;this.decodeStrings=!s;this.defaultEncoding=t.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){y(r,e)};this.writecb=null;this.writelen=0;this.bufferedRequest=null;this.lastBufferedRequest=null;this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}u.prototype.getBuffer=function A(){var e=this.bufferedRequest;var t=[];while(e){t.push(e);e=e.next}return t};(function(){try{Object.defineProperty(u.prototype,"buffer",{get:e("util-deprecate")(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use "+"_writableState.getBuffer() instead.")})}catch(t){}})();function l(t){var r=e("./_stream_duplex");if(!(this instanceof l)&&!(this instanceof r))return new l(t);this._writableState=new u(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}s.call(this)}l.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function c(e,t){var r=new Error("write after end");e.emit("error",r);i(t,r)}function p(e,t,r,a){var s=true;if(!n.isBuffer(r)&&typeof r!=="string"&&r!==null&&r!==undefined&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o);i(a,o);s=false}return s}l.prototype.write=function(e,t,r){var i=this._writableState;var a=false;if(typeof t==="function"){r=t;t=null}if(n.isBuffer(e))t="buffer";else if(!t)t=i.defaultEncoding;if(typeof r!=="function")r=o;if(i.ended)c(this,r);else if(p(this,i,e,r)){i.pendingcb++;a=h(this,i,e,t,r)}return a};l.prototype.cork=function(){var e=this._writableState;e.corked++};l.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest)w(this,e)}};l.prototype.setDefaultEncoding=function U(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 d(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&typeof t==="string"){t=new n(t,r)}return t}function h(e,t,r,i,a){r=d(t,r,i);if(n.isBuffer(r))i="buffer";var s=t.objectMode?1:r.length;t.length+=s;var o=t.length<t.highWaterMark;if(!o)t.needDrain=true;if(t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest=new f(r,i,a);if(u){u.next=t.lastBufferedRequest}else{t.bufferedRequest=t.lastBufferedRequest}}else{m(e,t,false,s,r,i,a)}return o}function m(e,t,r,i,n,a,s){t.writelen=i;t.writecb=s;t.writing=true;t.sync=true;if(r)e._writev(n,t.onwrite);else e._write(n,a,t.onwrite);t.sync=false}function v(e,t,r,n,a){--t.pendingcb;if(r)i(a,n);else a(n);e._writableState.errorEmitted=true;e.emit("error",n)}function g(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function y(e,t){var r=e._writableState;var n=r.sync;var a=r.writecb;g(r);if(t)v(e,r,n,t,a);else{var s=x(r);if(!s&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest){w(e,r)}if(n){i(_,e,r,s,a)}else{_(e,r,s,a)}}}function _(e,t,r,i){if(!r)b(e,t);t.pendingcb--;i();S(e,t)}function b(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function w(e,t){t.bufferProcessing=true;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=[];var n=[];while(r){n.push(r.callback);i.push(r);r=r.next}t.pendingcb++;t.lastBufferedRequest=null;m(e,t,true,t.length,i,"",function(e){for(var r=0;r<n.length;r++){t.pendingcb--;n[r](e)}})}else{while(r){var a=r.chunk;var s=r.encoding;var o=r.callback;var f=t.objectMode?1:a.length;m(e,t,false,f,a,s,o);r=r.next;if(t.writing){break}}if(r===null)t.lastBufferedRequest=null}t.bufferedRequest=r;t.bufferProcessing=false}l.prototype._write=function(e,t,r){r(new Error("not implemented"))};l.prototype._writev=null;l.prototype.end=function(e,t,r){var i=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(i.corked){i.corked=1;this.uncork()}if(!i.ending&&!i.finished)E(this,i,r)};function x(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function k(e,t){if(!t.prefinished){t.prefinished=true;e.emit("prefinish")}}function S(e,t){var r=x(t);if(r){if(t.pendingcb===0){k(e,t);t.finished=true;e.emit("finish")}else{k(e,t)}}return r}function E(e,t,r){t.ending=true;S(e,t);if(r){if(t.finished)i(r);else e.once("finish",r)}t.ended=true}},{"./_stream_duplex":55,buffer:40,"core-util-is":60,events:44,inherits:129,"process-nextick-args":61,"util-deprecate":62}],60:[function(e,t,r){(function(e){function t(e){return Array.isArray(e)}r.isArray=t;function i(e){return typeof e==="boolean"}r.isBoolean=i;function n(e){return e===null}r.isNull=n;function a(e){return e==null}r.isNullOrUndefined=a;function s(e){return typeof e==="number"}r.isNumber=s;function o(e){return typeof e==="string"}r.isString=o;function f(e){return typeof e==="symbol"}r.isSymbol=f;function u(e){return e===void 0}r.isUndefined=u;function l(e){return c(e)&&g(e)==="[object RegExp]"}r.isRegExp=l;function c(e){return typeof e==="object"&&e!==null}r.isObject=c;function p(e){return c(e)&&g(e)==="[object Date]"}r.isDate=p;function d(e){return c(e)&&(g(e)==="[object Error]"||e instanceof Error)}r.isError=d;function h(e){return typeof e==="function"}r.isFunction=h;function m(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=m;function v(t){return e.isBuffer(t)}r.isBuffer=v;function g(e){return Object.prototype.toString.call(e)}}).call(this,e("buffer").Buffer)},{buffer:40}],61:[function(e,t,r){(function(e){"use strict";t.exports=r;function r(t){var r=new Array(arguments.length-1);var i=0;while(i<arguments.length){r[i++]=arguments[i]}e.nextTick(function n(){t.apply(null,r)})}}).call(this,e("_process"))},{_process:49}],62:[function(e,t,r){(function(e){t.exports=r;function r(e,t){if(i("noDeprecation")){return e}var r=false;function n(){if(!r){if(i("throwDeprecation")){throw new Error(t)}else if(i("traceDeprecation")){console.trace(t)}else{console.warn(t)}r=true}return e.apply(this,arguments)}return n}function i(t){if(!e.localStorage)return false;var r=e.localStorage[t];if(null==r)return false;return String(r).toLowerCase()==="true"}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],63:[function(e,t,r){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":56}],64:[function(e,t,r){var i=function(){try{return e("st"+"ream")}catch(t){}}();r=t.exports=e("./lib/_stream_readable.js");r.Stream=i||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":55,"./lib/_stream_passthrough.js":56,"./lib/_stream_readable.js":57,"./lib/_stream_transform.js":58,"./lib/_stream_writable.js":59}],65:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":58}],66:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":59}],67:[function(e,t,r){t.exports=a;var i=e("events").EventEmitter;var n=e("inherits");n(a,i);a.Readable=e("readable-stream/readable.js");a.Writable=e("readable-stream/writable.js");a.Duplex=e("readable-stream/duplex.js");a.Transform=e("readable-stream/transform.js");a.PassThrough=e("readable-stream/passthrough.js");a.Stream=a;function a(){i.call(this)}a.prototype.pipe=function(e,t){var r=this;function n(t){if(e.writable){if(false===e.write(t)&&r.pause){r.pause()}}}r.on("data",n);function a(){if(r.readable&&r.resume){r.resume()}}e.on("drain",a);if(!e._isStdio&&(!t||t.end!==false)){r.on("end",o);r.on("close",f)}var s=false;function o(){if(s)return;s=true;e.end()}function f(){if(s)return;s=true;if(typeof e.destroy==="function")e.destroy()}function u(e){l();if(i.listenerCount(this,"error")===0){throw e}}r.on("error",u);e.on("error",u);function l(){r.removeListener("data",n);e.removeListener("drain",a);r.removeListener("end",o);r.removeListener("close",f);r.removeListener("error",u);e.removeListener("error",u);r.removeListener("end",l);r.removeListener("close",l);e.removeListener("close",l)}r.on("end",l);r.on("close",l);e.on("close",l);e.emit("pipe",r);return e}},{events:44,inherits:129,"readable-stream/duplex.js":54,"readable-stream/passthrough.js":63,"readable-stream/readable.js":64,"readable-stream/transform.js":65,"readable-stream/writable.js":66}],68:[function(e,t,r){var i=e("./lib/request");var n=e("xtend");var a=e("builtin-status-codes");var s=e("url");var o=r;o.request=function(e,t){if(typeof e==="string")e=s.parse(e);else e=n(e);var r=e.host?e.host.split(":")[0]:null;var a=e.host?parseInt(e.host.split(":")[1],10):null;e.method=e.method||"GET";e.headers=e.headers||{};e.path=e.path||"/";e.protocol=e.protocol||window.location.protocol;var o=e.hostname||r?e.protocol==="https:"?443:80:window.location.port;e.hostname=e.hostname||r||window.location.hostname;e.port=e.port||a||o;var f=new i(e);if(t)f.on("response",t);return f};o.get=function f(e,t){var r=o.request(e,t);r.end();return r};o.Agent=function(){};o.Agent.defaultMaxSockets=4;o.STATUS_CODES=a;o.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"]},{"./lib/request":70,"builtin-status-codes":72,url:78,xtend:181}],69:[function(e,t,r){r.fetch=f(window.fetch)&&f(window.ReadableByteStream);r.blobConstructor=false;try{new Blob([new ArrayBuffer(1)]);r.blobConstructor=true}catch(i){}var n=new window.XMLHttpRequest;n.open("GET","/");function a(e){try{n.responseType=e;return n.responseType===e}catch(t){}return false}var s=typeof window.ArrayBuffer!=="undefined";var o=s&&f(window.ArrayBuffer.prototype.slice);r.arraybuffer=s&&a("arraybuffer");r.msstream=!r.fetch&&o&&a("ms-stream");r.mozchunkedarraybuffer=!r.fetch&&s&&a("moz-chunked-arraybuffer");r.overrideMimeType=f(n.overrideMimeType);r.vbArray=f(window.VBArray);function f(e){return typeof e==="function"}n=null},{}],70:[function(e,t,r){(function(r,i){var n=e("./capability");var a=e("foreach");var s=e("indexof");var o=e("inherits");var f=e("object-keys");var u=e("./response");var l=e("stream");var c=u.IncomingMessage;var p=u.readyStates;function d(e){if(n.fetch){return"fetch"}else if(n.mozchunkedarraybuffer){return"moz-chunked-arraybuffer"}else if(n.msstream){return"ms-stream"}else if(n.arraybuffer&&e){return"arraybuffer"}else if(n.vbArray&&e){return"text:vbarray"}else{return"text"}}var h=t.exports=function(e){var t=this;l.Writable.call(t);t._opts=e;t._url=e.protocol+"//"+e.hostname+":"+e.port+e.path;t._body=[];t._headers={};if(e.auth)t.setHeader("Authorization","Basic "+new i(e.auth).toString("base64"));a(f(e.headers),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=!n.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()})};o(h,l.Writable);h.prototype.setHeader=function(e,t){var r=this;var i=e.toLowerCase();if(s(v,i)!==-1)return;r._headers[i]={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 o;if(t.method==="POST"||t.method==="PUT"){if(n.blobConstructor){o=new window.Blob(e._body.map(function(e){return e.toArrayBuffer()}),{type:(s["content-type"]||{}).value||""})}else{o=i.concat(e._body).toString()}}if(e._mode==="fetch"){var u=f(s).map(function(e){return[s[e].name,s[e].value]});window.fetch(e._url,{method:e._opts.method,headers:u,body:o,mode:"cors",credentials:t.withCredentials?"include":"same-origin"}).then(function(t){e._fetchResponse=t;e._connect()}).then(undefined,function(t){e.emit("error",t)})}else{var l=e._xhr=new window.XMLHttpRequest;try{l.open(e._opts.method,e._url,true)}catch(c){r.nextTick(function(){e.emit("error",c)});return}if("responseType"in l)l.responseType=e._mode.split(":")[0];if("withCredentials"in l)l.withCredentials=!!t.withCredentials;if(e._mode==="text"&&"overrideMimeType"in l)l.overrideMimeType("text/plain; charset=x-user-defined");a(f(s),function(e){l.setRequestHeader(s[e].name,s[e].value)});e._response=null;l.onreadystatechange=function(){switch(l.readyState){case p.LOADING:case p.DONE:e._onXHRProgress();break}};if(e._mode==="moz-chunked-arraybuffer"){l.onprogress=function(){e._onXHRProgress()}}l.onerror=function(){if(e._destroyed)return;e.emit("error",new Error("XHR error"))};try{l.send(o)}catch(c){r.nextTick(function(){e.emit("error",c)});return}}};function m(e){try{return e.status!==null}catch(t){return false}}h.prototype._onXHRProgress=function(){var e=this;if(!m(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 i=this;i._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 i=this;if(typeof e==="function"){r=e;e=undefined}l.Writable.prototype.end.call(i,e,t,r)};h.prototype.flushHeaders=function(){};h.prototype.setTimeout=function(){};h.prototype.setNoDelay=function(){};h.prototype.setSocketKeepAlive=function(){};var v=["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"),e("buffer").Buffer)},{"./capability":69,"./response":71,_process:49,buffer:40,foreach:73,indexof:74,inherits:129,"object-keys":75,stream:67}],71:[function(e,t,r){(function(t,i){var n=e("./capability");var a=e("foreach");var s=e("inherits");var o=e("stream");var f=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4};var u=r.IncomingMessage=function(e,r,s){var f=this;o.Readable.call(f);f._mode=s;f.headers={};f.rawHeaders=[];f.trailers={};f.rawTrailers=[];f.on("end",function(){t.nextTick(function(){f.emit("close")})});if(s==="fetch"){f._fetchResponse=r;f.statusCode=r.status;f.statusMessage=r.statusText;for(var u,l,c=r.headers[Symbol.iterator]();u=(l=c.next()).value,!l.done;){f.headers[u[0].toLowerCase()]=u[1];f.rawHeaders.push(u[0],u[1])}var p=r.body.getReader();function d(){p.read().then(function(e){if(f._destroyed)return;if(e.done){f.push(null);return}f.push(new i(e.value));d()})}d()}else{f._xhr=e;f._pos=0;f.statusCode=e.status;f.statusMessage=e.statusText;var h=e.getAllResponseHeaders().split(/\r?\n/);a(h,function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();if(f.headers[r]!==undefined)f.headers[r]+=", "+t[2];else f.headers[r]=t[2];f.rawHeaders.push(t[1],t[2])}});f._charset="x-user-defined";if(!n.overrideMimeType){var m=f.rawHeaders["mime-type"];if(m){var v=m.match(/;\s*charset=([^;])(;|$)/);if(v){f._charset=v[1].toLowerCase()}}if(!f._charset)f._charset="utf-8"}}};s(u,o.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 window.VBArray(t.responseBody).toArray()}catch(n){}if(r!==null){e.push(new i(r));break}case"text":try{r=t.responseText}catch(n){e._mode="text:vbarray";break}if(r.length>e._pos){var a=r.substr(e._pos);if(e._charset==="x-user-defined"){var s=new i(a.length);for(var o=0;o<a.length;o++)s[o]=a.charCodeAt(o)&255;e.push(s)}else{e.push(a,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 u=new window.MSStreamReader;u.onprogress=function(){if(u.result.byteLength>e._pos){e.push(new i(new Uint8Array(u.result.slice(e._pos))));e._pos=u.result.byteLength}};u.onload=function(){e.push(null)};u.readAsArrayBuffer(r);break}if(e._xhr.readyState===f.DONE&&e._mode!=="ms-stream"){e.push(null)}}}).call(this,e("_process"),e("buffer").Buffer)},{"./capability":69,_process:49,buffer:40,foreach:73,inherits:129,stream:67}],72:[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"}},{}],73:[function(e,t,r){var i=Object.prototype.hasOwnProperty;var n=Object.prototype.toString;t.exports=function a(e,t,r){if(n.call(t)!=="[object Function]"){throw new TypeError("iterator must be a function")}var a=e.length;if(a===+a){for(var s=0;s<a;s++){t.call(r,e[s],s,e)}}else{for(var o in e){if(i.call(e,o)){t.call(r,e[o],o,e)}}}}},{}],74:[function(e,t,r){var i=[].indexOf;t.exports=function(e,t){if(i)return e.indexOf(t);for(var r=0;r<e.length;++r){if(e[r]===t)return r}return-1}},{}],75:[function(e,t,r){"use strict";var i=Object.prototype.hasOwnProperty;var n=Object.prototype.toString;var a=Array.prototype.slice;var s=e("./isArguments");var o=!{toString:null}.propertyIsEnumerable("toString");var f=function(){}.propertyIsEnumerable("prototype");var u=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"];var l=function c(e){var t=e!==null&&typeof e==="object";var r=n.call(e)==="[object Function]";var a=s(e);var l=t&&n.call(e)==="[object String]";var c=[];if(!t&&!r&&!a){throw new TypeError("Object.keys called on a non-object")}var p=f&&r;if(l&&e.length>0&&!i.call(e,0)){for(var d=0;d<e.length;++d){c.push(String(d))}}if(a&&e.length>0){for(var h=0;h<e.length;++h){c.push(String(h))}}else{for(var m in e){if(!(p&&m==="prototype")&&i.call(e,m)){c.push(String(m))}}}if(o){var v=e.constructor;var g=v&&v.prototype===e;for(var y=0;y<u.length;++y){if(!(g&&u[y]==="constructor")&&i.call(e,u[y])){c.push(u[y])}}}return c};l.shim=function p(){if(!Object.keys){Object.keys=l}else{var e=function(){return(Object.keys(arguments)||"").length===2}(1,2);if(!e){var t=Object.keys;Object.keys=function r(e){if(s(e)){return t(a.call(e))}else{return t(e)}}}}return Object.keys||l};t.exports=l},{"./isArguments":76}],76:[function(e,t,r){"use strict";var i=Object.prototype.toString;t.exports=function n(e){var t=i.call(e);var r=t==="[object Arguments]";if(!r){r=t!=="[object Array]"&&e!==null&&typeof e==="object"&&typeof e.length==="number"&&e.length>=0&&i.call(e.callee)==="[object Function]"}return r}},{}],77:[function(e,t,r){var i=e("buffer").Buffer;var n=i.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 a(e){if(e&&!n(e)){throw new Error("Unknown encoding: "+e)}}var s=r.StringDecoder=function(e){this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,"");a(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=o;return}this.charBuffer=new i(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 i=t.charCodeAt(t.length-1);if(i>=55296&&i<=56319){this.charLength+=this.surrogateSize;t="";continue}this.charReceived=this.charLength=0;if(e.length===0){return t}break}this.detectIncompleteChar(e);var n=e.length;if(this.charLength){e.copy(this.charBuffer,0,e.length-this.charReceived,n);n-=this.charReceived}t+=e.toString(this.encoding,0,n);var n=t.length-1;var i=t.charCodeAt(n);if(i>=55296&&i<=56319){var a=this.surrogateSize;this.charLength+=a;this.charReceived+=a;this.charBuffer.copy(this.charBuffer,a,0,a);e.copy(this.charBuffer,0,0,a);return t.substring(0,n)}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 i=this.charBuffer;var n=this.encoding;t+=i.slice(0,r).toString(n)}return t};function o(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:40}],78:[function(e,t,r){var i=e("punycode");r.parse=_;r.resolve=w;r.resolveObject=x;r.format=b;r.Url=n;function n(){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 a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,o=["<",">",'"',"`"," ","\r","\n"," "],f=["{","}","|","\\","^","`"].concat(o),u=["'"].concat(f),l=["%","/","?",";","#"].concat(u),c=["/","?","#"],p=255,d=/^[a-z0-9A-Z_-]{0,63}$/,h=/^([a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:true,"javascript:":true},v={javascript:true,"javascript:":true},g={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},y=e("querystring");function _(e,t,r){if(e&&S(e)&&e instanceof n)return e;var i=new n;i.parse(e,t,r);return i}n.prototype.parse=function(e,t,r){if(!k(e)){throw new TypeError("Parameter 'url' must be a string, not "+typeof e)}var n=e;n=n.trim();var s=a.exec(n);if(s){s=s[0];var o=s.toLowerCase();this.protocol=o;n=n.substr(s.length)}if(r||s||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var f=n.substr(0,2)==="//";if(f&&!(s&&v[s])){n=n.substr(2);this.slashes=true}}if(!v[s]&&(f||s&&!g[s])){var _=-1;for(var b=0;b<c.length;b++){var w=n.indexOf(c[b]);if(w!==-1&&(_===-1||w<_))_=w}var x,S;if(_===-1){S=n.lastIndexOf("@")}else{S=n.lastIndexOf("@",_)}if(S!==-1){x=n.slice(0,S);n=n.slice(S+1);this.auth=decodeURIComponent(x)}_=-1;for(var b=0;b<l.length;b++){var w=n.indexOf(l[b]);if(w!==-1&&(_===-1||w<_))_=w}if(_===-1)_=n.length;this.host=n.slice(0,_);n=n.slice(_);this.parseHost();this.hostname=this.hostname||"";var E=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!E){var A=this.hostname.split(/\./);for(var b=0,U=A.length;b<U;b++){var I=A[b];if(!I)continue;if(!I.match(d)){var T="";for(var L=0,B=I.length;L<B;L++){if(I.charCodeAt(L)>127){T+="x"}else{T+=I[L]}}if(!T.match(d)){var C=A.slice(0,b);var R=A.slice(b+1);var P=I.match(h);if(P){C.push(P[1]);R.unshift(P[2])}if(R.length){n="/"+R.join(".")+n}this.hostname=C.join(".");break}}}}if(this.hostname.length>p){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!E){var O=this.hostname.split(".");var z=[];for(var b=0;b<O.length;++b){var F=O[b];z.push(F.match(/[^A-Za-z0-9_-]/)?"xn--"+i.encode(F):F)}this.hostname=z.join(".")}var M=this.port?":"+this.port:"";var j=this.hostname||"";this.host=j+M;this.href+=this.host;if(E){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(n[0]!=="/"){n="/"+n}}}if(!m[o]){for(var b=0,U=u.length;b<U;b++){var D=u[b];var N=encodeURIComponent(D);if(N===D){N=escape(D)}n=n.split(D).join(N)}}var H=n.indexOf("#");if(H!==-1){this.hash=n.substr(H);n=n.slice(0,H)}var q=n.indexOf("?");if(q!==-1){this.search=n.substr(q);this.query=n.substr(q+1);if(t){this.query=y.parse(this.query)}n=n.slice(0,q)}else if(t){this.search="";this.query={}}if(n)this.pathname=n;if(g[o]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var M=this.pathname||"";var F=this.search||"";this.path=M+F}this.href=this.format();return this};function b(e){if(k(e))e=_(e);if(!(e instanceof n))return n.prototype.format.call(e);return e.format()}n.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||"",i=this.hash||"",n=false,a="";if(this.host){n=e+this.host}else if(this.hostname){n=e+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]");if(this.port){n+=":"+this.port}}if(this.query&&S(this.query)&&Object.keys(this.query).length){a=y.stringify(this.query)}var s=this.search||a&&"?"+a||"";if(t&&t.substr(-1)!==":")t+=":";if(this.slashes||(!t||g[t])&&n!==false){n="//"+(n||"");if(r&&r.charAt(0)!=="/")r="/"+r}else if(!n){n=""}if(i&&i.charAt(0)!=="#")i="#"+i;if(s&&s.charAt(0)!=="?")s="?"+s;r=r.replace(/[?#]/g,function(e){return encodeURIComponent(e)});s=s.replace("#","%23");return t+n+r+s+i};function w(e,t){return _(e,false,true).resolve(t)}n.prototype.resolve=function(e){return this.resolveObject(_(e,false,true)).format()};function x(e,t){if(!e)return t;return _(e,false,true).resolveObject(t)}n.prototype.resolveObject=function(e){if(k(e)){var t=new n;t.parse(e,false,true);e=t}var r=new n;Object.keys(this).forEach(function(e){r[e]=this[e]},this);r.hash=e.hash;if(e.href===""){r.href=r.format();return r}if(e.slashes&&!e.protocol){Object.keys(e).forEach(function(t){if(t!=="protocol")r[t]=e[t]});if(g[r.protocol]&&r.hostname&&!r.pathname){r.path=r.pathname="/"}r.href=r.format();return r}if(e.protocol&&e.protocol!==r.protocol){if(!g[e.protocol]){Object.keys(e).forEach(function(t){r[t]=e[t]});r.href=r.format();return r}r.protocol=e.protocol;if(!e.host&&!v[e.protocol]){var i=(e.pathname||"").split("/");while(i.length&&!(e.host=i.shift()));if(!e.host)e.host="";if(!e.hostname)e.hostname="";if(i[0]!=="")i.unshift("");if(i.length<2)i.unshift("");r.pathname=i.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 a=r.pathname||"";var s=r.search||"";r.path=a+s}r.slashes=r.slashes||e.slashes;r.href=r.format();
-return r}var o=r.pathname&&r.pathname.charAt(0)==="/",f=e.host||e.pathname&&e.pathname.charAt(0)==="/",u=f||o||r.host&&e.pathname,l=u,c=r.pathname&&r.pathname.split("/")||[],i=e.pathname&&e.pathname.split("/")||[],p=r.protocol&&!g[r.protocol];if(p){r.hostname="";r.port=null;if(r.host){if(c[0]==="")c[0]=r.host;else c.unshift(r.host)}r.host="";if(e.protocol){e.hostname=null;e.port=null;if(e.host){if(i[0]==="")i[0]=e.host;else i.unshift(e.host)}e.host=null}u=u&&(i[0]===""||c[0]==="")}if(f){r.host=e.host||e.host===""?e.host:r.host;r.hostname=e.hostname||e.hostname===""?e.hostname:r.hostname;r.search=e.search;r.query=e.query;c=i}else if(i.length){if(!c)c=[];c.pop();c=c.concat(i);r.search=e.search;r.query=e.query}else if(!A(e.search)){if(p){r.hostname=r.host=c.shift();var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}r.search=e.search;r.query=e.query;if(!E(r.pathname)||!E(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.href=r.format();return r}if(!c.length){r.pathname=null;if(r.search){r.path="/"+r.search}else{r.path=null}r.href=r.format();return r}var h=c.slice(-1)[0];var m=(r.host||e.host)&&(h==="."||h==="..")||h==="";var y=0;for(var _=c.length;_>=0;_--){h=c[_];if(h=="."){c.splice(_,1)}else if(h===".."){c.splice(_,1);y++}else if(y){c.splice(_,1);y--}}if(!u&&!l){for(;y--;y){c.unshift("..")}}if(u&&c[0]!==""&&(!c[0]||c[0].charAt(0)!=="/")){c.unshift("")}if(m&&c.join("/").substr(-1)!=="/"){c.push("")}var b=c[0]===""||c[0]&&c[0].charAt(0)==="/";if(p){r.hostname=r.host=b?"":c.length?c.shift():"";var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}u=u||r.host&&c.length;if(u&&!b){c.unshift("")}if(!c.length){r.pathname=null;r.path=null}else{r.pathname=c.join("/")}if(!E(r.pathname)||!E(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};n.prototype.parseHost=function(){var e=this.host;var t=s.exec(e);if(t){t=t[0];if(t!==":"){this.port=t.substr(1)}e=e.substr(0,e.length-t.length)}if(e)this.hostname=e};function k(e){return typeof e==="string"}function S(e){return typeof e==="object"&&e!==null}function E(e){return e===null}function A(e){return e==null}},{punycode:50,querystring:53}],79:[function(e,t,r){(function(r){var i=e("inherits");var n=e("readable-stream").Transform;var a=e("defined");t.exports=s;i(s,n);function s(e,t){if(!(this instanceof s))return new s(e,t);n.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=a(t.zeroPadding,true);this._buffered=[];this._bufferedBytes=0}s.prototype._transform=function(e,t,i){this._bufferedBytes+=e.length;this._buffered.push(e);while(this._bufferedBytes>=this.size){var n=r.concat(this._buffered);this._bufferedBytes-=this.size;this.push(n.slice(0,this.size));this._buffered=[n.slice(this.size,n.length)]}i()};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:40,defined:80,inherits:129,"readable-stream":89}],80:[function(e,t,r){t.exports=function(){for(var e=0;e<arguments.length;e++){if(arguments[e]!==undefined)return arguments[e]}}},{}],81:[function(e,t,r){(function(r){t.exports=o;var i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};var n=e("core-util-is");n.inherits=e("inherits");var a=e("./_stream_readable");var s=e("./_stream_writable");n.inherits(o,a);u(i(s.prototype),function(e){if(!o.prototype[e])o.prototype[e]=s.prototype[e]});function o(e){if(!(this instanceof o))return new o(e);a.call(this,e);s.call(this,e);if(e&&e.readable===false)this.readable=false;if(e&&e.writable===false)this.writable=false;this.allowHalfOpen=true;if(e&&e.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",f)}function f(){if(this.allowHalfOpen||this._writableState.ended)return;r.nextTick(this.end.bind(this))}function u(e,t){for(var r=0,i=e.length;r<i;r++){t(e[r],r)}}}).call(this,e("_process"))},{"./_stream_readable":83,"./_stream_writable":85,_process:49,"core-util-is":86,inherits:129}],82:[function(e,t,r){t.exports=a;var i=e("./_stream_transform");var n=e("core-util-is");n.inherits=e("inherits");n.inherits(a,i);function a(e){if(!(this instanceof a))return new a(e);i.call(this,e)}a.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":84,"core-util-is":86,inherits:129}],83:[function(e,t,r){(function(r){t.exports=c;var i=e("isarray");var n=e("buffer").Buffer;c.ReadableState=l;var a=e("events").EventEmitter;if(!a.listenerCount)a.listenerCount=function(e,t){return e.listeners(t).length};var s=e("stream");var o=e("core-util-is");o.inherits=e("inherits");var f;var u=e("util");if(u&&u.debuglog){u=u.debuglog("stream")}else{u=function(){}}o.inherits(c,s);function l(t,r){var i=e("./_stream_duplex");t=t||{};var n=t.highWaterMark;var a=t.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:a;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=null;this.ended=false;this.endEmitted=false;this.reading=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!t.objectMode;if(r instanceof i)this.objectMode=this.objectMode||!!t.readableObjectMode;this.defaultEncoding=t.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(t.encoding){if(!f)f=e("string_decoder/").StringDecoder;this.decoder=new f(t.encoding);this.encoding=t.encoding}}function c(t){var r=e("./_stream_duplex");if(!(this instanceof c))return new c(t);this._readableState=new l(t,this);this.readable=true;s.call(this)}c.prototype.push=function(e,t){var r=this._readableState;if(o.isString(e)&&!r.objectMode){t=t||r.defaultEncoding;if(t!==r.encoding){e=new n(e,t);t=""}}return p(this,r,e,t,false)};c.prototype.unshift=function(e){var t=this._readableState;return p(this,t,e,"",true)};function p(e,t,r,i,n){var a=g(t,r);if(a){e.emit("error",a)}else if(o.isNullOrUndefined(r)){t.reading=false;if(!t.ended)y(e,t)}else if(t.objectMode||r&&r.length>0){if(t.ended&&!n){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&n){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{if(t.decoder&&!n&&!i)r=t.decoder.write(r);if(!n)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(n)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)_(e)}w(e,t)}}else if(!n){t.reading=false}return d(t)}function d(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}c.prototype.setEncoding=function(t){if(!f)f=e("string_decoder/").StringDecoder;this._readableState.decoder=new f(t);this._readableState.encoding=t;return this};var h=8388608;function m(e){if(e>=h){e=h}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function v(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(isNaN(e)||o.isNull(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=m(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}c.prototype.read=function(e){u("read",e);var t=this._readableState;var r=e;if(!o.isNumber(e)||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){u("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)I(this);else _(this);return null}e=v(e,t);if(e===0&&t.ended){if(t.length===0)I(this);return null}var i=t.needReadable;u("need readable",i);if(t.length===0||t.length-e<t.highWaterMark){i=true;u("length less than watermark",i)}if(t.ended||t.reading){i=false;u("reading or ended",i)}if(i){u("do read");t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(i&&!t.reading)e=v(r,t);var n;if(e>0)n=U(e,t);else n=null;if(o.isNull(n)){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)I(this);if(!o.isNull(n))this.emit("data",n);return n};function g(e,t){var r=null;if(!o.isBuffer(t)&&!o.isString(t)&&!o.isNullOrUndefined(t)&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function y(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;_(e)}function _(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){u("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)r.nextTick(function(){b(e)});else b(e)}}function b(e){u("emit readable");e.emit("readable");A(e)}function w(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){x(e,t)})}}function x(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){u("maybeReadMore read 0");e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}c.prototype._read=function(e){this.emit("error",new Error("not implemented"))};c.prototype.pipe=function(e,t){var n=this;var s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e);break}s.pipesCount+=1;u("pipe count=%d opts=%j",s.pipesCount,t);var o=(!t||t.end!==false)&&e!==r.stdout&&e!==r.stderr;var f=o?c:d;if(s.endEmitted)r.nextTick(f);else n.once("end",f);e.on("unpipe",l);function l(e){u("onunpipe");if(e===n){d()}}function c(){u("onend");e.end()}var p=k(n);e.on("drain",p);function d(){u("cleanup");e.removeListener("close",v);e.removeListener("finish",g);e.removeListener("drain",p);e.removeListener("error",m);e.removeListener("unpipe",l);n.removeListener("end",c);n.removeListener("end",d);n.removeListener("data",h);if(s.awaitDrain&&(!e._writableState||e._writableState.needDrain))p()}n.on("data",h);function h(t){u("ondata");var r=e.write(t);if(false===r){u("false write response, pause",n._readableState.awaitDrain);n._readableState.awaitDrain++;n.pause()}}function m(t){u("onerror",t);y();e.removeListener("error",m);if(a.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",m);else if(i(e._events.error))e._events.error.unshift(m);else e._events.error=[m,e._events.error];function v(){e.removeListener("finish",g);y()}e.once("close",v);function g(){u("onfinish");e.removeListener("close",v);y()}e.once("finish",g);function y(){u("unpipe");n.unpipe(e)}e.emit("pipe",n);if(!s.flowing){u("pipe resume");n.resume()}return e};function k(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&a.listenerCount(e,"data")){t.flowing=true;A(e)}}}c.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 i=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var n=0;n<i;n++)r[n].emit("unpipe",this);return this}var n=L(t.pipes,e);if(n===-1)return this;t.pipes.splice(n,1);t.pipesCount-=1;if(t.pipesCount===1)t.pipes=t.pipes[0];e.emit("unpipe",this);return this};c.prototype.on=function(e,t){var i=s.prototype.on.call(this,e,t);if(e==="data"&&false!==this._readableState.flowing){this.resume()}if(e==="readable"&&this.readable){var n=this._readableState;if(!n.readableListening){n.readableListening=true;n.emittedReadable=false;n.needReadable=true;if(!n.reading){var a=this;r.nextTick(function(){u("readable nexttick read 0");a.read(0)})}else if(n.length){_(this,n)}}}return i};c.prototype.addListener=c.prototype.on;c.prototype.resume=function(){var e=this._readableState;if(!e.flowing){u("resume");e.flowing=true;if(!e.reading){u("resume read 0");this.read(0)}S(this,e)}return this};function S(e,t){if(!t.resumeScheduled){t.resumeScheduled=true;r.nextTick(function(){E(e,t)})}}function E(e,t){t.resumeScheduled=false;e.emit("resume");A(e);if(t.flowing&&!t.reading)e.read(0)}c.prototype.pause=function(){u("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){u("pause");this._readableState.flowing=false;this.emit("pause")}return this};function A(e){var t=e._readableState;u("flow",t.flowing);if(t.flowing){do{var r=e.read()}while(null!==r&&t.flowing)}}c.prototype.wrap=function(e){var t=this._readableState;var r=false;var i=this;e.on("end",function(){u("wrapped end");if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)i.push(e)}i.push(null)});e.on("data",function(n){u("wrapped data");if(t.decoder)n=t.decoder.write(n);if(!n||!t.objectMode&&!n.length)return;var a=i.push(n);if(!a){r=true;e.pause()}});for(var n in e){if(o.isFunction(e[n])&&o.isUndefined(this[n])){this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n)}}var a=["error","close","destroy","pause","resume"];T(a,function(t){e.on(t,i.emit.bind(i,t))});i._read=function(t){u("wrapped _read",t);if(r){r=false;e.resume()}};return i};c._fromList=U;function U(e,t){var r=t.buffer;var i=t.length;var a=!!t.decoder;var s=!!t.objectMode;var o;if(r.length===0)return null;if(i===0)o=null;else if(s)o=r.shift();else if(!e||e>=i){if(a)o=r.join("");else o=n.concat(r,i);r.length=0}else{if(e<r[0].length){var f=r[0];o=f.slice(0,e);r[0]=f.slice(e)}else if(e===r[0].length){o=r.shift()}else{if(a)o="";else o=new n(e);var u=0;for(var l=0,c=r.length;l<c&&u<e;l++){var f=r[0];var p=Math.min(e-u,f.length);if(a)o+=f.slice(0,p);else f.copy(o,u,0,p);if(p<f.length)r[0]=f.slice(p);else r.shift();u+=p}}}return o}function I(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function T(e,t){for(var r=0,i=e.length;r<i;r++){t(e[r],r)}}function L(e,t){for(var r=0,i=e.length;r<i;r++){if(e[r]===t)return r}return-1}}).call(this,e("_process"))},{"./_stream_duplex":81,_process:49,buffer:40,"core-util-is":86,events:44,inherits:129,isarray:87,stream:67,"string_decoder/":88,util:39}],84:[function(e,t,r){t.exports=o;var i=e("./_stream_duplex");var n=e("core-util-is");n.inherits=e("inherits");n.inherits(o,i);function a(e,t){this.afterTransform=function(e,r){return s(t,e,r)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function s(e,t,r){var i=e._transformState;i.transforming=false;var a=i.writecb;if(!a)return e.emit("error",new Error("no writecb in Transform class"));i.writechunk=null;i.writecb=null;if(!n.isNullOrUndefined(r))e.push(r);if(a)a(t);var s=e._readableState;s.reading=false;if(s.needReadable||s.length<s.highWaterMark){e._read(s.highWaterMark)}}function o(e){if(!(this instanceof o))return new o(e);i.call(this,e);this._transformState=new a(e,this);var t=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("prefinish",function(){if(n.isFunction(this._flush))this._flush(function(e){f(t,e)});else f(t)})}o.prototype.push=function(e,t){this._transformState.needTransform=false;return i.prototype.push.call(this,e,t)};o.prototype._transform=function(e,t,r){throw new Error("not implemented")};o.prototype._write=function(e,t,r){var i=this._transformState;i.writecb=r;i.writechunk=e;i.writeencoding=t;if(!i.transforming){var n=this._readableState;if(i.needTransform||n.needReadable||n.length<n.highWaterMark)this._read(n.highWaterMark)}};o.prototype._read=function(e){var t=this._transformState;if(!n.isNull(t.writechunk)&&t.writecb&&!t.transforming){t.transforming=true;this._transform(t.writechunk,t.writeencoding,t.afterTransform)}else{t.needTransform=true}};function f(e,t){if(t)return e.emit("error",t);var r=e._writableState;var i=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(i.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":81,"core-util-is":86,inherits:129}],85:[function(e,t,r){(function(r){t.exports=f;var i=e("buffer").Buffer;f.WritableState=o;var n=e("core-util-is");n.inherits=e("inherits");var a=e("stream");n.inherits(f,a);function s(e,t,r){this.chunk=e;this.encoding=t;this.callback=r}function o(t,r){var i=e("./_stream_duplex");t=t||{};var n=t.highWaterMark;var a=t.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:a;this.objectMode=!!t.objectMode;if(r instanceof i)this.objectMode=this.objectMode||!!t.writableObjectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var s=t.decodeStrings===false;this.decodeStrings=!s;this.defaultEncoding=t.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){v(r,e)};this.writecb=null;this.writelen=0;this.buffer=[];this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}function f(t){var r=e("./_stream_duplex");if(!(this instanceof f)&&!(this instanceof r))return new f(t);this._writableState=new o(t,this);this.writable=true;a.call(this)}f.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function u(e,t,i){var n=new Error("write after end");e.emit("error",n);r.nextTick(function(){i(n)})}function l(e,t,i,a){var s=true;if(!n.isBuffer(i)&&!n.isString(i)&&!n.isNullOrUndefined(i)&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o);r.nextTick(function(){a(o)});s=false}return s}f.prototype.write=function(e,t,r){var i=this._writableState;var a=false;if(n.isFunction(t)){r=t;t=null}if(n.isBuffer(e))t="buffer";else if(!t)t=i.defaultEncoding;if(!n.isFunction(r))r=function(){};if(i.ended)u(this,i,r);else if(l(this,i,e,r)){i.pendingcb++;a=p(this,i,e,t,r)}return a};f.prototype.cork=function(){var e=this._writableState;e.corked++};f.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.buffer.length)_(this,e)}};function c(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&n.isString(t)){t=new i(t,r)}return t}function p(e,t,r,i,a){r=c(t,r,i);if(n.isBuffer(r))i="buffer";var o=t.objectMode?1:r.length;t.length+=o;var f=t.length<t.highWaterMark;if(!f)t.needDrain=true;if(t.writing||t.corked)t.buffer.push(new s(r,i,a));else d(e,t,false,o,r,i,a);return f}function d(e,t,r,i,n,a,s){t.writelen=i;t.writecb=s;t.writing=true;t.sync=true;if(r)e._writev(n,t.onwrite);else e._write(n,a,t.onwrite);t.sync=false}function h(e,t,i,n,a){if(i)r.nextTick(function(){t.pendingcb--;a(n)});else{t.pendingcb--;a(n)}e._writableState.errorEmitted=true;e.emit("error",n)}function m(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function v(e,t){var i=e._writableState;var n=i.sync;var a=i.writecb;m(i);if(t)h(e,i,n,t,a);else{var s=b(e,i);if(!s&&!i.corked&&!i.bufferProcessing&&i.buffer.length){_(e,i)}if(n){r.nextTick(function(){g(e,i,s,a)})}else{g(e,i,s,a)}}}function g(e,t,r,i){if(!r)y(e,t);t.pendingcb--;i();x(e,t)}function y(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function _(e,t){t.bufferProcessing=true;if(e._writev&&t.buffer.length>1){var r=[];for(var i=0;i<t.buffer.length;i++)r.push(t.buffer[i].callback);t.pendingcb++;d(e,t,true,t.length,t.buffer,"",function(e){for(var i=0;i<r.length;i++){t.pendingcb--;r[i](e)}});t.buffer=[]}else{for(var i=0;i<t.buffer.length;i++){var n=t.buffer[i];var a=n.chunk;var s=n.encoding;var o=n.callback;var f=t.objectMode?1:a.length;d(e,t,false,f,a,s,o);if(t.writing){i++;break}}if(i<t.buffer.length)t.buffer=t.buffer.slice(i);else t.buffer.length=0}t.bufferProcessing=false}f.prototype._write=function(e,t,r){r(new Error("not implemented"))};f.prototype._writev=null;f.prototype.end=function(e,t,r){var i=this._writableState;if(n.isFunction(e)){r=e;e=null;t=null}else if(n.isFunction(t)){r=t;t=null}if(!n.isNullOrUndefined(e))this.write(e,t);if(i.corked){i.corked=1;this.uncork()}if(!i.ending&&!i.finished)k(this,i,r)};function b(e,t){return t.ending&&t.length===0&&!t.finished&&!t.writing}function w(e,t){if(!t.prefinished){t.prefinished=true;e.emit("prefinish")}}function x(e,t){var r=b(e,t);if(r){if(t.pendingcb===0){w(e,t);t.finished=true;e.emit("finish")}else w(e,t)}return r}function k(e,t,i){t.ending=true;x(e,t);if(i){if(t.finished)r.nextTick(i);else e.once("finish",i)}t.ended=true}}).call(this,e("_process"))},{"./_stream_duplex":81,_process:49,buffer:40,"core-util-is":86,inherits:129,stream:67}],86:[function(e,t,r){arguments[4][60][0].apply(r,arguments)},{buffer:40,dup:60}],87:[function(e,t,r){arguments[4][46][0].apply(r,arguments)},{dup:46}],88:[function(e,t,r){arguments[4][77][0].apply(r,arguments)},{buffer:40,dup:77}],89:[function(e,t,r){r=t.exports=e("./lib/_stream_readable.js");r.Stream=e("stream");r.Readable=r;r.Writable=e("./lib/_stream_writable.js");r.Duplex=e("./lib/_stream_duplex.js");r.Transform=e("./lib/_stream_transform.js");r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":81,"./lib/_stream_passthrough.js":82,"./lib/_stream_readable.js":83,"./lib/_stream_transform.js":84,"./lib/_stream_writable.js":85,stream:67}],90:[function(e,t,r){t.exports=s;var i=e("block-stream2");var n=e("inherits");var a=e("stream");n(s,a.Writable);function s(e,t,r){var n=this;if(!(n instanceof s)){return new s(e,t,r)}a.Writable.call(n,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");n._blockstream=new i(t,{zeroPadding:false});n._blockstream.on("data",f).on("error",function(e){n.destroy(e)});var o=0;function f(t){if(n.destroyed)return;e.put(o,t);o+=1}n.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":79,inherits:129,stream:67}],91:[function(e,t,r){(function(r,i){t.exports=_;t.exports.announceList=[["udp://tracker.publicbt.com:80"],["udp://tracker.openbittorrent.com:80"],["udp://open.demonii.com:1337"],["udp://tracker.webtorrent.io:80"],["wss://tracker.webtorrent.io"]];t.exports.parseInput=b;var n=e("bencode");var a=e("block-stream2");var s=e("piece-length");var o=e("path");var f=e("dezalgo");var u=e("filestream/read");var l=e("flatten");var c=e("fs");var p=e("is-file");var d=e("junk");var h=e("multistream");var m=e("once");var v=e("run-parallel");var g=e("simple-sha1");var y=e("stream");function _(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};b(e,t,function(e,i,n){if(e)return r(e);t.singleFileTorrent=n;A(i,t,r)})}function b(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};r=f(r);if(Array.isArray(e)&&e.length===0)throw new Error("invalid input type");if(T(e))e=Array.prototype.slice.call(e);if(!Array.isArray(e))e=[e];if(!t.name)t.name=e[0]&&e[0].name;if(!t.name)t.name=typeof e[0]==="string"&&o.basename(e[0]);if(t.name===undefined){throw new Error("missing option 'name' and unable to infer it from input[0].name")}if(e.length===1&&!e[0].name)e[0].name=t.name;var n=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"){p(e[0],function(e,t){if(e)return r(e);a=t;s()})}else{s()}function s(){v(e.map(function(e){return function(r){var s={};if(I(e)){s.getStream=B(e);s.length=e.size}else if(i.isBuffer(e)){s.getStream=C(e);s.length=e.length}else if(L(e)){if(!t.pieceLength){throw new Error("must specify `pieceLength` option if input is Stream")}s.getStream=P(e,s);s.length=0}else if(typeof e==="string"){if(typeof c.readdir!=="function"){throw new Error("filesystem paths do not work in the browser")}var f=n>1||a;w(e,f,r);return}else{throw new Error("invalid input type")}if(!e.name)throw new Error("missing requied `name` property on input");s.path=e.name.split(o.sep);r(null,s)}}),function(e,t){if(e)return r(e);t=l(t);r(null,t,a)})}}function w(e,t,r){k(e,x,function(i,n){if(i)return r(i);if(Array.isArray(n))n=l(n);else n=[n];e=o.normalize(e);if(t){e=e.slice(0,e.lastIndexOf(o.sep)+1)}if(e[e.length-1]!==o.sep)e+=o.sep;n.forEach(function(t){t.getStream=R(t.path);t.path=t.path.replace(e,"").split(o.sep)});r(null,n)})}function x(e,t){t=m(t);c.stat(e,function(r,i){if(r)return t(r);var n={length:i.size,path:e};t(null,n)})}function k(e,t,r){c.readdir(e,function(i,n){if(i&&i.code==="ENOTDIR"){t(e,r)}else if(i){r(i)}else{v(n.filter(S).filter(d.not).map(function(r){return function(i){k(o.join(e,r),t,i)}}),r)}})}function S(e){return e[0]!=="."}function E(e,t,r){r=m(r);var n=[];var s=0;var o=e.map(function(e){return e.getStream});var f=0;var u=0;var l=false;var c=new h(o);var p=new a(t,{zeroPadding:false});c.on("error",y);c.pipe(p).on("data",d).on("end",v).on("error",y);function d(e){s+=e.length;var t=u;g(e,function(e){n[t]=e;f-=1;b()});f+=1;u+=1}function v(){l=true;b()}function y(e){_();r(e)}function _(){c.removeListener("error",y);p.removeListener("data",d);p.removeListener("end",v);p.removeListener("error",y)}function b(){if(l&&f===0){_();r(null,new i(n.join(""),"hex"),s)}}}function A(e,i,a){var o=i.announceList;if(!o){if(typeof i.announce==="string")o=[[i.announce]];else if(Array.isArray(i.announce)){o=i.announce.map(function(e){return[e]})}}if(!o)o=[];if(r.WEBTORRENT_ANNOUNCE){if(typeof r.WEBTORRENT_ANNOUNCE==="string"){o.push([[r.WEBTORRENT_ANNOUNCE]])}else if(Array.isArray(r.WEBTORRENT_ANNOUNCE)){o=o.concat(r.WEBTORRENT_ANNOUNCE.map(function(e){return[e]}))}}if(o.length===0){o=o.concat(t.exports.announceList)}if(typeof i.urlList==="string")i.urlList=[i.urlList];var f={info:{name:i.name},announce:o[0][0],"announce-list":o,"creation date":Number(i.creationDate)||Date.now(),encoding:"UTF-8"};if(i.comment!==undefined)f.comment=i.comment;if(i.createdBy!==undefined)f["created by"]=i.createdBy;if(i.private!==undefined)f.info.private=Number(i.private);if(i.sslCert!==undefined)f.info["ssl-cert"]=i.sslCert;if(i.urlList!==undefined)f["url-list"]=i.urlList;var u=i.pieceLength||s(e.reduce(U,0));f.info["piece length"]=u;E(e,u,function(t,r,s){if(t)return a(t);f.info.pieces=r;e.forEach(function(e){delete e.getStream});if(i.singleFileTorrent){f.info.length=s}else{f.info.files=e}a(null,n.encode(f))})}function U(e,t){return e+t.length}function I(e){return typeof Blob!=="undefined"&&e instanceof Blob}function T(e){return typeof FileList==="function"&&e instanceof FileList}function L(e){return typeof e==="object"&&typeof e.pipe==="function"}function B(e){return function(){return new u(e)}}function C(e){return function(){var t=new y.PassThrough;t.end(e);return t}}function R(e){return function(){return c.createReadStream(e)}}function P(e,t){return function(){var r=new y.Transform;r._transform=function(e,r,i){t.length+=e.length;this.push(e);i()};e.pipe(r);return r}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{bencode:92,"block-stream2":96,buffer:40,dezalgo:107,"filestream/read":113,flatten:114,fs:38,"is-file":115,junk:116,multistream:133,once:118,path:48,"piece-length":119,"run-parallel":154,"simple-sha1":163,stream:67}],92:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./lib/decode":93,"./lib/encode":95,dup:16}],93:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{"./dict":94,buffer:40,dup:17}],94:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],95:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{buffer:40,dup:19}],96:[function(e,t,r){arguments[4][79][0].apply(r,arguments)},{buffer:40,defined:97,dup:79,inherits:129,"readable-stream":106}],97:[function(e,t,r){arguments[4][80][0].apply(r,arguments)},{dup:80}],98:[function(e,t,r){arguments[4][81][0].apply(r,arguments)},{"./_stream_readable":100,"./_stream_writable":102,_process:49,"core-util-is":103,dup:81,inherits:129}],99:[function(e,t,r){arguments[4][82][0].apply(r,arguments)},{"./_stream_transform":101,"core-util-is":103,dup:82,inherits:129}],100:[function(e,t,r){arguments[4][83][0].apply(r,arguments)},{"./_stream_duplex":98,_process:49,buffer:40,"core-util-is":103,dup:83,events:44,inherits:129,isarray:104,stream:67,"string_decoder/":105,util:39}],101:[function(e,t,r){arguments[4][84][0].apply(r,arguments)},{"./_stream_duplex":98,"core-util-is":103,dup:84,inherits:129}],102:[function(e,t,r){arguments[4][85][0].apply(r,arguments)},{"./_stream_duplex":98,_process:49,buffer:40,"core-util-is":103,dup:85,inherits:129,stream:67}],103:[function(e,t,r){arguments[4][60][0].apply(r,arguments)},{buffer:40,dup:60}],104:[function(e,t,r){arguments[4][46][0].apply(r,arguments)},{dup:46}],105:[function(e,t,r){arguments[4][77][0].apply(r,arguments)},{buffer:40,dup:77}],106:[function(e,t,r){arguments[4][89][0].apply(r,arguments)},{"./lib/_stream_duplex.js":98,"./lib/_stream_passthrough.js":99,"./lib/_stream_readable.js":100,"./lib/_stream_transform.js":101,"./lib/_stream_writable.js":102,dup:89,stream:67}],107:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{asap:108,dup:20,wrappy:110}],108:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{"./raw":109,dup:21}],109:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],110:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],111:[function(e,t,r){arguments[4][34][0].apply(r,arguments)},{buffer:40,dup:34,"is-typedarray":112}],112:[function(e,t,r){arguments[4][33][0].apply(r,arguments)},{dup:33}],113:[function(e,t,r){var i=e("stream").Readable;var n=e("inherits");var a=/^.*\.(\w+)$/;var s=e("typedarray-to-buffer");function o(e,t){var r=this;if(!(this instanceof o)){return new o(e,t)}t=t||{};i.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")})}n(o,i);t.exports=o;o.prototype._generateHeaderBlocks=function(e,t,r){r(null,[])};o.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 i=this._offset+this._chunkSize;if(i>this._size)i=this._size;if(r===this._size){this.destroy();this.push(null);return}t.onload=function(){e._offset=i;e.push(s(t.result))};t.onerror=function(){e.emit("error",t.error)};t.readAsArrayBuffer(this._file.slice(r,i))};o.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:129,stream:67,"typedarray-to-buffer":111}],114:[function(e,t,r){t.exports=function i(e,t){t=typeof t=="number"?t:Infinity;return r(e,1);function r(e,i){return e.reduce(function(e,n){if(Array.isArray(n)&&i<t){return e.concat(r(n,i+1))}else{return e.concat(n)}},[])}}},{}],115:[function(e,t,r){"use strict";var i=e("fs");t.exports=function a(e,t){if(!t)return n(e);i.stat(e,function(e,r){if(e)return t(e);return t(null,r.isFile())})};t.exports.sync=n;function n(e){return i.existsSync(e)&&i.statSync(e).isFile()}},{fs:38}],116:[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)}},{}],117:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],118:[function(e,t,r){
-arguments[4][30][0].apply(r,arguments)},{dup:30,wrappy:117}],119:[function(e,t,r){var i=e("closest-to");var n=[];for(var a=14;a<=22;a++){n.push(Math.pow(2,a))}t.exports=function(e){return i(e/Math.pow(2,10),n)}},{"closest-to":120}],120:[function(e,t,r){t.exports=function(e,t){var r=Infinity;var i=0;var n=null;t.sort(function(e,t){return e-t});for(var a=0,s=t.length;a<s;a++){i=Math.abs(e-t[a]);if(i>=r){break}r=i;n=t[a]}return n}},{}],121:[function(e,t,r){r=t.exports=e("./debug");r.log=a;r.formatArgs=n;r.save=s;r.load=o;r.useColors=i;r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:f();r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function i(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}r.formatters.j=function(e){return JSON.stringify(e)};function n(){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 i="color: "+this.color;e=[e[0],i,"color: inherit"].concat(Array.prototype.slice.call(e,1));var n=0;var a=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;n++;if("%c"===e){a=n}});e.splice(a,0,i);return e}function a(){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 o(){var e;try{e=r.storage.debug}catch(t){}return e}r.enable(o());function f(){try{return window.localStorage}catch(e){}}},{"./debug":122}],122:[function(e,t,r){r=t.exports=s;r.coerce=l;r.disable=f;r.enable=o;r.enabled=u;r.humanize=e("ms");r.names=[];r.skips=[];r.formatters={};var i=0;var n;function a(){return r.colors[i++%r.colors.length]}function s(e){function t(){}t.enabled=false;function i(){var e=i;var t=+new Date;var s=t-(n||t);e.diff=s;e.prev=n;e.curr=t;n=t;if(null==e.useColors)e.useColors=r.useColors();if(null==e.color&&e.useColors)e.color=a();var o=Array.prototype.slice.call(arguments);o[0]=r.coerce(o[0]);if("string"!==typeof o[0]){o=["%o"].concat(o)}var f=0;o[0]=o[0].replace(/%([a-z%])/g,function(t,i){if(t==="%%")return t;f++;var n=r.formatters[i];if("function"===typeof n){var a=o[f];t=n.call(e,a);o.splice(f,1);f--}return t});if("function"===typeof r.formatArgs){o=r.formatArgs.apply(e,o)}var u=i.log||r.log||console.log.bind(console);u.apply(e,o)}i.enabled=true;var s=r.enabled(e)?i:t;s.namespace=e;return s}function o(e){r.save(e);var t=(e||"").split(/[\s,]+/);var i=t.length;for(var n=0;n<i;n++){if(!t[n])continue;e=t[n].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,i;for(t=0,i=r.skips.length;t<i;t++){if(r.skips[t].test(e)){return false}}for(t=0,i=r.names.length;t<i;t++){if(r.names[t].test(e)){return true}}return false}function l(e){if(e instanceof Error)return e.stack||e.message;return e}},{ms:123}],123:[function(e,t,r){var i=1e3;var n=i*60;var a=n*60;var s=a*24;var o=s*365.25;t.exports=function(e,t){t=t||{};if("string"==typeof e)return f(e);return t.long?l(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*o;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*a;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*i;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>=a)return Math.round(e/a)+"h";if(e>=n)return Math.round(e/n)+"m";if(e>=i)return Math.round(e/i)+"s";return e+"ms"}function l(e){return c(e,s,"day")||c(e,a,"hour")||c(e,n,"minute")||c(e,i,"second")||e+" ms"}function c(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"}},{}],124:[function(e,t,r){var i=e("once");var n=function(){};var a=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 o=function(e,t,r){if(typeof t==="function")return o(e,null,t);if(!t)t={};r=i(r||n);var f=e._writableState;var u=e._readableState;var l=t.readable||t.readable!==false&&e.readable;var c=t.writable||t.writable!==false&&e.writable;var p=function(){if(!e.writable)d()};var d=function(){c=false;if(!l)r()};var h=function(){l=false;if(!c)r()};var m=function(e){r(e?new Error("exited with error code: "+e):null)};var v=function(){if(l&&!(u&&u.ended))return r(new Error("premature close"));if(c&&!(f&&f.ended))return r(new Error("premature close"))};var g=function(){e.req.on("finish",d)};if(a(e)){e.on("complete",d);e.on("abort",v);if(e.req)g();else e.on("request",g)}else if(c&&!f){e.on("end",p);e.on("close",p)}if(s(e))e.on("exit",m);e.on("end",h);e.on("finish",d);if(t.error!==false)e.on("error",r);e.on("close",v);return function(){e.removeListener("complete",d);e.removeListener("abort",v);e.removeListener("request",g);if(e.req)e.req.removeListener("finish",d);e.removeListener("end",p);e.removeListener("close",p);e.removeListener("finish",d);e.removeListener("exit",m);e.removeListener("end",h);e.removeListener("error",r);e.removeListener("close",v)}};t.exports=o},{once:126}],125:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],126:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30,wrappy:125}],127:[function(e,t,r){var i=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 n=2;r===Infinity;n*=2){r=Math.log(Math.pow(2,e/n))/Math.log(t)*n}var a=r-Math.floor(r);var s="";for(var n=0;n<Math.floor(r);n++){var o=Math.floor(Math.random()*t).toString(t);s=o+s}if(a){var f=Math.pow(t,a);var o=Math.floor(Math.random()*f).toString(t);s=o+s}var u=parseInt(s,t);if(u!==Infinity&&u>=Math.pow(2,e)){return i(e,t)}else return s};i.rack=function(e,t,r){var n=function(n){var s=0;do{if(s++>10){if(r)e+=r;else throw new Error("too many ID collisions, use more bits")}var o=i(e,t)}while(Object.hasOwnProperty.call(a,o));a[o]=n;return o};var a=n.hats={};n.get=function(e){return n.hats[e]};n.set=function(e,t){n.hats[e]=t;return n};n.bits=e||128;n.base=t||16;return n}},{}],128:[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 i=this;i.mem[e]=t;i.store.put(e,t,function(t){i.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 n=t&&t.offset||0;var a=t&&t.length&&n+t.length;var s=this.mem[e];if(s)return i(r,null,t?s.slice(n,a):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 i(t,r,i){e.nextTick(function(){if(t)t(r,i)})}}).call(this,e("_process"))},{_process:49}],129:[function(e,t,r){if(typeof Object.create==="function"){t.exports=function i(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{t.exports=function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}}},{}],130:[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 i(r,new Error("Storage is closed"));var n=e===this.lastChunkIndex;if(n&&t.length!==this.lastChunkLength){return i(r,new Error("Last chunk length must be "+this.lastChunkLength))}if(!n&&t.length!==this.chunkLength){return i(r,new Error("Chunk length must be "+this.chunkLength))}this.chunks[e]=t;i(r,null)};r.prototype.get=function(e,t,r){if(typeof t==="function")return this.get(e,null,t);if(this.closed)return i(r,new Error("Storage is closed"));var n=this.chunks[e];if(!n)return i(r,new Error("Chunk not found"));if(!t)return i(r,null,n);var a=t.offset||0;var s=t.length||n.length-a;i(r,null,n.slice(a,s+a))};r.prototype.close=r.prototype.destroy=function(e){if(this.closed)return i(e,new Error("Storage is closed"));this.closed=true;this.chunks=null;i(e,null)};function i(t,r,i){e.nextTick(function(){if(t)t(r,i)})}}).call(this,e("_process"))},{_process:49}],131:[function(e,t,r){(function(r){var i=e("path");var n=e("fs");function a(){this.types=Object.create(null);this.extensions=Object.create(null)}a.prototype.define=function(e){for(var t in e){var i=e[t];for(var n=0;n<i.length;n++){if(r.env.DEBUG_MIME&&this.types[i]){console.warn(this._loading.replace(/.*\//,""),'changes "'+i[n]+'" extension type from '+this.types[i]+" to "+t)}this.types[i[n]]=t}if(!this.extensions[t]){this.extensions[t]=i[0]}}};a.prototype.load=function(e){this._loading=e;var t={},r=n.readFileSync(e,"ascii"),i=r.split(/[\r\n]+/);i.forEach(function(e){var r=e.replace(/\s*#.*|^\s*|\s*$/g,"").split(/\s+/);t[r.shift()]=r});this.define(t);this._loading=null};a.prototype.lookup=function(e,t){var r=e.replace(/.*[\.\/\\]/,"").toLowerCase();return this.types[r]||t||this.default_type};a.prototype.extension=function(e){var t=e.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();return this.extensions[t]};var s=new a;s.define(e("./types.json"));s.default_type=s.lookup("bin");s.Mime=a;s.charsets={lookup:function(e,t){return/^text\//.test(e)?"UTF-8":t}};t.exports=s}).call(this,e("_process"))},{"./types.json":132,_process:49,fs:38,path:48}],132:[function(e,t,r){t.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mdp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/font-woff":["woff"],"application/font-woff2":["woff2"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],
-"application/x-latex":["latex"],"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl","xsd"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a","m4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"font/opentype":["otf"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee"],"text/css":["css"],"text/csv":["csv"],"text/hjson":["hjson"],"text/html":["html","htm"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/vtt":["vtt"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["markdown","md","mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}},{}],133:[function(e,t,r){t.exports=a;var i=e("inherits");var n=e("stream");i(a,n.Readable);function a(e,t){if(!(this instanceof a))return new a(e,t);n.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()}a.obj=function(e){return new a(e,{objectMode:true,highWaterMark:16})};a.prototype._read=function(){this._drained=true;this._forward()};a.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};a.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")};a.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)}};a.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",n);e.on("error",a);e.on("close",i);function r(){t._forward()}function i(){if(!e._readableState.ended){t.destroy()}}function n(){t._current=null;e.removeListener("readable",r);e.removeListener("end",n);e.removeListener("error",a);e.removeListener("close",i);t._next()}function a(e){t.destroy(e)}};function s(e){if(!e||typeof e==="function"||e._readableState)return e;var t=(new n.Readable).wrap(e);if(e.destroy){t.destroy=e.destroy.bind(e)}return t}},{inherits:129,stream:67}],134:[function(e,t,r){(function(r){t.exports=f;t.exports.remote=u;var i=e("dezalgo");var n=e("fs");var a=e("simple-get");var s=e("magnet-uri");var o=e("parse-torrent-file");t.exports.toMagnetURI=s.encode;t.exports.toTorrentFile=o.encode;function f(e){var t=e&&e.length;if(typeof e==="string"&&/magnet:/.test(e)){return s(e)}else if(typeof e==="string"&&(t===40||t===32)){return s("magnet:?xt=urn:btih:"+e)}else if(r.isBuffer(e)&&t===20){return s("magnet:?xt=urn:btih:"+e.toString("hex"))}else if(r.isBuffer(e)){return o(e)}else if(e&&e.infoHash){if(!e.announce)e.announce=[];if(typeof e.announce==="string"){e.announce=[e.announce]}return e}else{throw new Error("Invalid torrent identifier")}}function u(e,t){var r;if(typeof t!=="function")throw new Error("second argument must be a Function");t=i(t);try{r=f(e)}catch(s){}if(r&&r.infoHash){t(null,r)}else if(typeof a==="function"&&/^https?:/.test(e)){a.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,r){if(e){e=new Error("Error downloading torrent: "+e.message);return t(e)}o(r)})}else if(typeof n.readFile==="function"&&typeof e==="string"){n.readFile(e,function(e,r){if(e)return t(new Error("Invalid torrent identifier"));o(r)})}else{t(new Error("Invalid torrent identifier"))}function o(e){try{r=f(e)}catch(i){return t(i)}if(r&&r.infoHash)t(null,r);else t(new Error("Invalid torrent identifier"))}}}).call(this,e("buffer").Buffer)},{buffer:40,dezalgo:135,fs:38,"magnet-uri":139,"parse-torrent-file":142,"simple-get":159}],135:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{asap:136,dup:20,wrappy:138}],136:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{"./raw":137,dup:21}],137:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],138:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],139:[function(e,t,r){(function(r){t.exports=s;t.exports.decode=s;t.exports.encode=o;var i=e("thirty-two");var n=e("xtend");var a=e("uniq");function s(e){var t={};var n=e.split("magnet:?")[1];var s=n&&n.length>=0?n.split("&"):[];s.forEach(function(e){var r=e.split("=");if(r.length!==2)return;var i=r[0];var n=r[1];if(i==="dn")n=decodeURIComponent(n).replace(/\+/g," ");if(i==="tr"||i==="xs"||i==="as"||i==="ws"){n=decodeURIComponent(n)}if(i==="kt")n=decodeURIComponent(n).split("+");if(t[i]){if(Array.isArray(t[i])){t[i].push(n)}else{var a=t[i];t[i]=[a,n]}}else{t[i]=n}});var o;if(t.xt){var f=Array.isArray(t.xt)?t.xt:[t.xt];f.forEach(function(e){if(o=e.match(/^urn:btih:(.{40})/)){t.infoHash=new r(o[1],"hex").toString("hex")}else if(o=e.match(/^urn:btih:(.{32})/)){var n=i.decode(o[1]);t.infoHash=new r(n,"binary").toString("hex")}})}if(t.dn)t.name=t.dn;if(t.kt)t.keywords=t.kt;if(typeof t.tr==="string")t.announce=[t.tr];else if(Array.isArray(t.tr))t.announce=t.tr;else t.announce=[];a(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)}return t}function o(e){e=n(e);if(e.infoHash)e.xt="urn:btih:"+e.infoHash;if(e.name)e.dn=e.name;if(e.keywords)e.kt=e.keywords;if(e.announce)e.tr=e.announce;if(e.urlList){e.ws=e.urlList;delete e.as}var t="magnet:?";Object.keys(e).filter(function(e){return e.length===2}).forEach(function(r,i){var n=Array.isArray(e[r])?e[r]:[e[r]];n.forEach(function(e,n){if((i>0||n>0)&&(r!=="kt"||n===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"&&n>0)t+="+"+e;else t+=r+"="+e})});return t}}).call(this,e("buffer").Buffer)},{buffer:40,"thirty-two":140,uniq:168,xtend:181}],140:[function(e,t,r){var i=e("./thirty-two");r.encode=i.encode;r.decode=i.decode},{"./thirty-two":141}],141:[function(e,t,r){(function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";var i=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];function n(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}r.encode=function(r){var i=0;var a=0;var s=0;var o=0;var f=new e(n(r)*8);if(!e.isBuffer(r)){r=new e(r)}while(i<r.length){var u=r[i];if(s>3){o=u&255>>s;s=(s+5)%8;o=o<<s|(i+1<r.length?r[i+1]:0)>>8-s;i++}else{o=u>>8-(s+5)&31;s=(s+5)%8;if(s==0)i++}f[a]=t.charCodeAt(o);a++}for(i=a;i<f.length;i++)f[i]=61;return f};r.decode=function(t){var r=0;var n=0;var a;var s=0;if(!e.isBuffer(t)){t=new e(t)}var o=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<i.length){n=i[u];if(r<=3){r=(r+5)%8;if(r==0){a|=n;o[s]=a;s++;a=0}else{a|=255&n<<8-r}}else{r=(r+5)%8;a|=255&n>>>r;o[s]=a;s++;a=255&n<<8-r}}else{throw new Error("Invalid input - it is not base32 encoded string")}}return o.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:40}],142:[function(e,t,r){(function(r){t.exports=o;t.exports.decode=o;t.exports.encode=f;var i=e("bencode");var n=e("path");var a=e("simple-sha1");var s=e("uniq");function o(e){if(r.isBuffer(e)){e=i.decode(e)}c(e.info,"info");c(e.info["name.utf-8"]||e.info.name,"info.name");c(e.info["piece length"],"info['piece length']");c(e.info.pieces,"info.pieces");if(e.info.files){e.info.files.forEach(function(e){c(typeof e.length==="number","info.files[0].length");c(e["path.utf-8"]||e.path,"info.files[0].path")})}else{c(typeof e.info.length==="number","info.length")}var t={};t.info=e.info;t.infoBuffer=i.encode(e.info);t.infoHash=a.sync(t.infoBuffer);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())}s(t.announce);if(r.isBuffer(e["url-list"])){e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]}t.urlList=(e["url-list"]||[]).map(function(e){return e.toString()});var o=e.info.files||[e.info];t.files=o.map(function(e,r){var i=[].concat(t.name,e["path.utf-8"]||e.path||[]).map(function(e){return e.toString()});return{path:n.join.apply(null,[n.sep].concat(i)).slice(1),name:i[i.length-1],length:e.length,offset:o.slice(0,r).reduce(u,0)}});t.length=o.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=l(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 i.encode(t)}function u(e,t){return e+t.length}function l(e){var t=[];for(var r=0;r<e.length;r+=20){t.push(e.slice(r,r+20).toString("hex"))}return t}function c(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}}).call(this,e("buffer").Buffer)},{bencode:143,buffer:40,path:48,"simple-sha1":163,uniq:168}],143:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./lib/decode":144,"./lib/encode":146,dup:16}],144:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{"./dict":145,buffer:40,dup:17}],145:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],146:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{buffer:40,dup:19}],147:[function(e,t,r){"use strict";var i=e("fs");t.exports=function(e,t){var r=typeof i.access==="function"?i.access:i.stat;r(e,function(e){t(null,!e)})};t.exports.sync=function(e){var t=typeof i.accessSync==="function"?i.accessSync:i.statSync;try{t(e);return true}catch(r){return false}}},{fs:38}],148:[function(e,t,r){var i=e("once");var n=e("end-of-stream");var a=e("fs");var s=function(){};var o=function(e){return typeof e==="function"};var f=function(e){return(e instanceof(a.ReadStream||s)||e instanceof(a.WriteStream||s))&&o(e.close)};var u=function(e){return e.setHeader&&o(e.abort)};var l=function(e,t,r,a){a=i(a);var s=false;e.on("close",function(){s=true});n(e,{readable:t,writable:r},function(e){if(e)return a(e);s=true;a()});var l=false;return function(t){if(s)return;if(l)return;l=true;if(f(e))return e.close();if(u(e))return e.abort();if(o(e.destroy))return e.destroy();a(t||new Error("stream was destroyed"))}};var c=function(e){e()};var p=function(e,t){return e.pipe(t)};var d=function(){var e=Array.prototype.slice.call(arguments);var t=o(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 i=e.map(function(n,a){var s=a<e.length-1;var o=a>0;return l(n,s,o,function(e){if(!r)r=e;if(e)i.forEach(c);if(s)return;i.forEach(c);t(r)})});return e.reduce(p)};t.exports=d},{"end-of-stream":124,fs:38,once:150}],149:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],150:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30,wrappy:149}],151:[function(e,t,r){var i=function(e){var t=0;return function(){if(t===e.length)return null;var r=e.length-t;var i=Math.random()*r|0;var n=e[t+i];var a=e[t];e[t]=n;e[t+i]=a;t++;return n}};t.exports=i},{}],152:[function(e,t,r){t.exports=function(e,t){var r=true;var i=t.indexOf("=");if(-1==i)return-2;var n=t.slice(i+1).split(",").map(function(t){var t=t.split("-"),i=parseInt(t[0],10),n=parseInt(t[1],10);if(isNaN(i)){i=e-n;n=e-1}else if(isNaN(n)){n=e-1}if(n>e-1)n=e-1;if(isNaN(i)||isNaN(n)||i>n||i<0)r=false;return{start:i,end:n}});n.type=t.slice(0,i);return r?n:-1}},{}],153:[function(e,t,r){t.exports=n;t.exports.filter=a;var i=e("events").EventEmitter;function n(e,t,r){if(!Array.isArray(r))r=[r];var i=[];r.forEach(function(r){var n=function(){var e=[].slice.call(arguments);e.unshift(r);t.emit.apply(t,e)};i.push(n);e.on(r,n)});return function n(){r.forEach(function(t,r){e.removeListener(t,i[r])})}}function a(e,t){var r=new i;n(e,r,t);return r}},{events:44}],154:[function(e,t,r){var i=e("dezalgo");t.exports=function(e,t){if(t)t=i(t);var r,n,a;if(Array.isArray(e)){r=[];n=e.length}else{a=Object.keys(e);r={};n=a.length}function s(e,i,a){r[e]=a;if(--n===0||i){if(t)t(i,r);t=null}}if(!n){if(t)t(null,r);t=null}else if(a){a.forEach(function(t){e[t](s.bind(undefined,t))})}else{e.forEach(function(e,t){e(s.bind(undefined,t))})}}},{dezalgo:155}],155:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{asap:156,dup:20,wrappy:158}],156:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{"./raw":157,dup:21}],157:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],158:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],159:[function(e,t,r){(function(r){t.exports=u;var i=e("http");var n=e("https");var a=e("once");var s=e("url");var o=e("unzip-response");var f=e("object-assign");function u(e,t){e=typeof e==="string"?{url:e}:f({},e);t=a(t);if(e.url)l(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 s=Object.keys(e.headers).some(function(e){return e.toLowerCase()==="accept-encoding"});if(!s)e.headers["accept-encoding"]="gzip, deflate";var c=e.protocol==="https:"?n:i;var p=c.request(e,function(r){if(r.statusCode>=300&&r.statusCode<400&&"location"in r.headers){e.url=r.headers.location;l(e);r.resume();e.maxRedirects-=1;if(e.maxRedirects>0)u(e,t);else t(new Error("too many redirects"));return}t(null,typeof o==="function"?o(r):r)});p.on("error",t);p.end(r);return p}t.exports.concat=function(e,t){return u(e,function(e,i){if(e)return t(e);var n=[];i.on("data",function(e){n.push(e)});i.on("end",function(){t(null,r.concat(n),i)})})};["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 l(e){var t=s.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:40,http:68,https:45,"object-assign":160,once:162,"unzip-response":39,url:78}],160:[function(e,t,r){"use strict";var i=Object.prototype.propertyIsEnumerable;function n(e){if(e==null){throw new TypeError("Object.assign cannot be called with null or undefined")}return Object(e)}function a(e){var t=Object.getOwnPropertyNames(e);if(Object.getOwnPropertySymbols){t=t.concat(Object.getOwnPropertySymbols(e))}return t.filter(function(t){return i.call(e,t)})}t.exports=Object.assign||function(e,t){var r;var i;var s=n(e);for(var o=1;o<arguments.length;o++){r=arguments[o];i=a(Object(r));for(var f=0;f<i.length;f++){s[i[f]]=r[i[f]]}}return s}},{}],161:[function(e,t,r){arguments[4][23][0].apply(r,arguments)},{dup:23}],162:[function(e,t,r){arguments[4][30][0].apply(r,arguments)},{dup:30,wrappy:161}],163:[function(e,t,r){var i=e("rusha");var n=new i;var a=window.crypto||window.msCrypto||{};var s=a.subtle||a.webkitSubtle;var o=n.digest.bind(n);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,o(e));return}if(typeof e==="string"){e=l(e)}s.digest({name:"sha-1"},e).then(function r(e){t(c(new Uint8Array(e)))},function i(r){t(o(e))})}function l(e){var t=e.length;var r=new Uint8Array(t);for(var i=0;i<t;i++){r[i]=e.charCodeAt(i)}return r}function c(e){var t=e.length;var r=[];for(var i=0;i<t;i++){var n=e[i];r.push((n>>>4).toString(16));r.push((n&15).toString(16))}return r.join("")}t.exports=u;t.exports.sync=o},{rusha:164}],164:[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 i(e){"use strict";var t={fill:0};var a=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 o=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,i,n){var a=this,s,o=n%4,f=i%4,u=i-f;if(u>0){switch(o){case 0:e[n+3|0]=a.charCodeAt(r);case 1:e[n+2|0]=a.charCodeAt(r+1);case 2:e[n+1|0]=a.charCodeAt(r+2);case 3:e[n|0]=a.charCodeAt(r+3)}}for(s=o;s<u;s=s+4|0){t[n+s>>2]=a.charCodeAt(r+s)<<24|a.charCodeAt(r+s+1)<<16|a.charCodeAt(r+s+2)<<8|a.charCodeAt(r+s+3)}switch(f){case 3:e[n+u+1|0]=a.charCodeAt(r+u+2);case 2:e[n+u+2|0]=a.charCodeAt(r+u+1);case 1:e[n+u+3|0]=a.charCodeAt(r+u)}};var u=function(e,t,r,i,n){var a=this,s,o=n%4,f=i%4,u=i-f;if(u>0){switch(o){case 0:e[n+3|0]=a[r];case 1:e[n+2|0]=a[r+1];case 2:e[n+1|0]=a[r+2];case 3:e[n|0]=a[r+3]}}for(s=4-o;s<u;s=s+=4|0){t[n+s>>2]=a[r+s]<<24|a[r+s+1]<<16|a[r+s+2]<<8|a[r+s+3]}switch(f){case 3:e[n+u+1|0]=a[r+u+2];case 2:e[n+u+2|0]=a[r+u+1];case 1:e[n+u+3|0]=a[r+u]}};var l=function(e,t,r,i,a){var s=this,o,f=a%4,u=i%4,l=i-u;var c=new Uint8Array(n.readAsArrayBuffer(s.slice(r,r+i)));if(l>0){switch(f){case 0:e[a+3|0]=c[0];case 1:e[a+2|0]=c[1];case 2:e[a+1|0]=c[2];case 3:e[a|0]=c[3]}}for(o=4-f;o<l;o=o+=4|0){t[a+o>>2]=c[o]<<24|c[o+1]<<16|c[o+2]<<8|c[o+3]}switch(u){case 3:e[a+l+1|0]=c[l+2];case 2:e[a+l+2|0]=c[l+1];case 1:e[a+l+3|0]=c[l]}};var c=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 l.bind(e)}};var p=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 d=function(e){var t,r,i="0123456789abcdef",n=[],a=new Uint8Array(e);for(t=0;t<a.length;t++){r=a[t];n[t]=i.charAt(r>>4&15)+i.charAt(r>>0&15)}return n.join("")};var h=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=a(e);t.heap=new ArrayBuffer(h(t.padMaxChunkLen+320+20));t.h32=new Int32Array(t.heap);t.h8=new Int8Array(t.heap);t.core=new i._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 i=a(e);var n=new Int32Array(t.heap,0,i>>2);s(n,e);o(n,e,r);return i};var y=function(e,r,i){c(e)(t.h8,t.h32,r,i,0)};var _=function(e,r,i,n,a){var s=i;if(a){s=g(i,n)}y(e,r,i);t.core.hash(s,t.padMaxChunkLen)};var b=function(e,t){var r=new Int32Array(e,t+320,5);var i=new Int32Array(5);var n=new DataView(i.buffer);n.setInt32(0,r[0],false);n.setInt32(4,r[1],false);n.setInt32(8,r[2],false);n.setInt32(12,r[3],false);n.setInt32(16,r[4],false);return i};var w=this.rawDigest=function(e){var r=e.byteLength||e.length||e.size||0;v(t.heap,t.padMaxChunkLen);var i=0,n=t.maxChunkLen,a;for(i=0;r>i+n;i+=n){_(e,i,n,r,false)}_(e,i,r-i,r,true);return b(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return d(w(e).buffer)}}i._core=function s(e,t,r){"use asm";var i=new e.Int32Array(r);function n(e,t){e=e|0;t=t|0;var r=0,n=0,a=0,s=0,o=0,f=0,u=0,l=0,c=0,p=0,d=0,h=0,m=0,v=0;a=i[t+320>>2]|0;o=i[t+324>>2]|0;u=i[t+328>>2]|0;c=i[t+332>>2]|0;d=i[t+336>>2]|0;for(r=0;(r|0)<(e|0);r=r+64|0){s=a;f=o;l=u;p=c;h=d;for(n=0;(n|0)<64;n=n+4|0){v=i[r+n>>2]|0;m=((a<<5|a>>>27)+(o&u|~o&c)|0)+((v+d|0)+1518500249|0)|0;d=c;c=u;u=o<<30|o>>>2;o=a;a=m;i[e+n>>2]=v}for(n=e+64|0;(n|0)<(e+80|0);n=n+4|0){v=(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])<<1|(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])>>>31;m=((a<<5|a>>>27)+(o&u|~o&c)|0)+((v+d|0)+1518500249|0)|0;d=c;c=u;u=o<<30|o>>>2;o=a;a=m;i[n>>2]=v}for(n=e+80|0;(n|0)<(e+160|0);n=n+4|0){v=(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])<<1|(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])>>>31;m=((a<<5|a>>>27)+(o^u^c)|0)+((v+d|0)+1859775393|0)|0;d=c;c=u;u=o<<30|o>>>2;o=a;a=m;i[n>>2]=v}for(n=e+160|0;(n|0)<(e+240|0);n=n+4|0){v=(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])<<1|(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])>>>31;m=((a<<5|a>>>27)+(o&u|o&c|u&c)|0)+((v+d|0)-1894007588|0)|0;d=c;c=u;u=o<<30|o>>>2;o=a;a=m;i[n>>2]=v}for(n=e+240|0;(n|0)<(e+320|0);n=n+4|0){v=(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])<<1|(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])>>>31;m=((a<<5|a>>>27)+(o^u^c)|0)+((v+d|0)-899497514|0)|0;d=c;c=u;u=o<<30|o>>>2;o=a;a=m;i[n>>2]=v}a=a+s|0;o=o+f|0;u=u+l|0;c=c+p|0;d=d+h|0}i[t+320>>2]=a;i[t+324>>2]=o;i[t+328>>2]=u;i[t+332>>2]=c;i[t+336>>2]=d}return{hash:n}};if(typeof t!=="undefined"){t.exports=i}else if(typeof window!=="undefined"){window.Rusha=i}if(typeof FileReaderSync!=="undefined"){var n=new FileReaderSync,a=new i(4*1024*1024);self.onmessage=function o(e){var t,r=e.data.data;try{t=a.digest(r);self.postMessage({id:e.data.id,hash:t})}catch(i){self.postMessage({id:e.data.id,error:i.name})}}}})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],165:[function(e,t,r){var i=1;var n=65535;var a=4;var s=function(){i=i+1&n};var o=setInterval(s,1e3/a|0);if(o.unref)o.unref();t.exports=function(e){var t=a*(e||5);var r=[0];var s=1;var o=i-1&n;return function(e){var f=i-o&n;if(f>t)f=t;o=i;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 l=r.length<t?0:r[s===t?0:s];return r.length<a?u:(u-l)*a/r.length}}},{}],166:[function(e,t,r){(function(r,i){t.exports=p;var n=e("debug")("torrent-discovery");var a=e("bittorrent-dht/client");var s=e("events").EventEmitter;var o=e("xtend/mutable");var f=e("inherits");var u=e("run-parallel");var l=e("re-emitter");var c=e("bittorrent-tracker/client");f(p,s);function p(e){var t=this;if(!(t instanceof p))return new p(e);s.call(t);o(t,{announce:[],dht:typeof a==="function",rtcConfig:null,peerId:null,port:0,tracker:true,wrtc:null},e);t.infoHash=null;t.infoHashHex=null;t.torrent=null;t._externalDHT=typeof t.dht==="object";t._performedDHTLookup=false;if(!t.peerId)throw new Error("peerId required");if(!r.browser&&!t.port)throw new Error("port required");if(t.dht)t._createDHT(t.dhtPort)}p.prototype.setTorrent=function(e){var t=this;if(!t.infoHash&&i.isBuffer(e)||typeof e==="string"){t.infoHash=typeof e==="string"?new i(e,"hex"):e}else if(!t.torrent&&e&&e.infoHash){t.torrent=e;t.infoHash=typeof e.infoHash==="string"?new i(e.infoHash,"hex"):e.infoHash}else{return}t.infoHashHex=t.infoHash.toString("hex");n("setTorrent %s",t.infoHashHex);if(t.tracker&&t.tracker!==true){t.tracker.torrentLength=e.length}else{t._createTracker()}if(t.dht){if(t.dht.ready)t._dhtLookupAndAnnounce();else t.dht.on("ready",t._dhtLookupAndAnnounce.bind(t))}};p.prototype.updatePort=function(e){var t=this;if(e===t.port)return;t.port=e;if(t.dht&&t.infoHash){t._performedDHTLookup=false;t._dhtLookupAndAnnounce()}if(t.tracker&&t.tracker!==true){t.tracker.stop();t.tracker.destroy(function(){t._createTracker()})}};p.prototype.stop=function(e){var t=this;var r=[];if(t.tracker&&t.tracker!==true){t.tracker.stop();r.push(function(e){t.tracker.destroy(e)})}if(!t._externalDHT&&t.dht&&t.dht!==true){r.push(function(e){t.dht.destroy(e)})}u(r,e)};p.prototype._createDHT=function(e){var t=this;if(!t._externalDHT)t.dht=new a;l(t.dht,t,["error","warning"]);t.dht.on("peer",function(e,r){if(r===t.infoHashHex)t.emit("peer",e)});if(!t._externalDHT)t.dht.listen(e)};p.prototype._createTracker=function(){var e=this;if(!e.tracker)return;var t=e.torrent?o({},e.torrent):{infoHash:e.infoHashHex,announce:[]};if(e.announce)t.announce=t.announce.concat(e.announce);
-var r={rtcConfig:e.rtcConfig,wrtc:e.wrtc};e.tracker=new c(e.peerId,e.port,t,r);l(e.tracker,e,["peer","warning","error"]);e.tracker.on("update",function(t){e.emit("trackerAnnounce",t)});e.tracker.start()};p.prototype._dhtLookupAndAnnounce=function(){var e=this;if(e._performedDHTLookup)return;e._performedDHTLookup=true;n("dht lookup");e.dht.lookup(e.infoHash,function(t){if(t||!e.port)return;n("dht announce");e.dht.announce(e.infoHash,e.port,function(){n("dht announce complete");e.emit("dhtAnnounce")})})}}).call(this,e("_process"),e("buffer").Buffer)},{_process:49,"bittorrent-dht/client":39,"bittorrent-tracker/client":24,buffer:40,debug:121,events:44,inherits:129,"re-emitter":153,"run-parallel":154,"xtend/mutable":182}],167:[function(e,t,r){(function(e){t.exports=i;var r=1<<14;function i(e){if(!(this instanceof i))return new i(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}i.BLOCK_LENGTH=r;i.prototype.chunkLength=function(e){return e===this._chunks-1?this._remainder:r};i.prototype.chunkOffset=function(e){return e*r};i.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};i.prototype.cancel=function(e){if(!this.init())return;this._cancellations.push(e)};i.prototype.get=function(e){if(!this.init())return null;return this._buffer[e]};i.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};i.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};i.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:40}],168:[function(e,t,r){"use strict";function i(e,t){var r=1,i=e.length,n=e[0],a=e[0];for(var s=1;s<i;++s){a=n;n=e[s];if(t(n,a)){if(s===r){r++;continue}e[r++]=n}}e.length=r;return e}function n(e){var t=1,r=e.length,i=e[0],n=e[0];for(var a=1;a<r;++a,n=i){n=i;i=e[a];if(i!==n){if(a===t){t++;continue}e[t++]=i}}e.length=t;return e}function a(e,t,r){if(e.length===0){return e}if(t){if(!r){e.sort(t)}return i(e,t)}if(!r){e.sort()}return n(e)}t.exports=a},{}],169:[function(e,t,r){(function(r){var i=e("bencode");var n=e("bitfield");var a=e("events").EventEmitter;var s=e("inherits");var o=e("simple-sha1");var f=1e7;var u=1e3;var l=16*1024;t.exports=function(e){s(t,a);function t(t){a.call(this);this._wire=t;this._metadataComplete=false;this._metadataSize=null;this._remainingRejects=null;this._fetching=false;this._bitfield=new n(0,{grow:u});if(r.isBuffer(e)){this.setMetadata(e)}}t.prototype.name="ut_metadata";t.prototype.onHandshake=function(e,t,r){this._infoHash=e;this._infoHashHex=e.toString("hex")};t.prototype.onExtendedHandshake=function(e){if(!e.m||!e.m.ut_metadata){return this.emit("warning",new Error("Peer does not support ut_metadata"))}if(!e.metadata_size){return this.emit("warning",new Error("Peer does not have metadata"))}if(e.metadata_size>f){return this.emit("warning",new Error("Peer gave maliciously large metadata size"))}this._metadataSize=e.metadata_size;this._numPieces=Math.ceil(this._metadataSize/l);this._remainingRejects=this._numPieces*2;if(this._fetching){this._requestPieces()}};t.prototype.onMessage=function(e){var t,r;try{var n=e.toString();var a=n.indexOf("ee")+2;t=i.decode(n.substring(0,a));r=e.slice(a)}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=i.decode(e).info;if(t){e=i.encode(t)}}catch(r){}if(this._infoHashHex&&this._infoHashHex!==o.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",i.encode({info:i.decode(this.metadata)}));return true};t.prototype._send=function(e,t){var n=i.encode(e);if(r.isBuffer(t)){n=r.concat([n,t])}this._wire.extended("ut_metadata",n)};t.prototype._request=function(e){this._send({msg_type:0,piece:e})};t.prototype._data=function(e,t,r){var i={msg_type:1,piece:e};if(typeof r==="number"){i.total_size=r}this._send(i,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*l;var r=t+l;if(r>this._metadataSize){r=this._metadataSize}var i=this.metadata.slice(t,r);this._data(e,i,this._metadataSize)};t.prototype._onData=function(e,t,r){if(t.length>l){return}t.copy(this.metadata,e*l);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 n(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:170,bitfield:10,buffer:40,events:44,inherits:129,"simple-sha1":163}],170:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./lib/decode":171,"./lib/encode":173,dup:16}],171:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{"./dict":172,buffer:40,dup:17}],172:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{dup:18}],173:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{buffer:40,dup:19}],174:[function(e,t,r){var i=function(e,t,r){this._byteOffset=t||0;if(e instanceof ArrayBuffer){this.buffer=e}else if(typeof e=="object"){this.dataView=e;if(t){this._byteOffset+=t}}else{this.buffer=new ArrayBuffer(e||0)}this.position=0;this.endianness=r==null?i.LITTLE_ENDIAN:r};t.exports=i;i.prototype={};i.prototype.save=function(e){var t=new Blob([this.buffer]);var r=window.webkitURL||window.URL;if(r&&r.createObjectURL){var i=r.createObjectURL(t);var n=document.createElement("a");n.setAttribute("href",i);n.setAttribute("download",e);n.click();r.revokeObjectURL(i)}else{throw"DataStream.save: Can't create object URL."}};i.BIG_ENDIAN=false;i.LITTLE_ENDIAN=true;i.prototype._dynamicSize=true;Object.defineProperty(i.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(e){if(!e){this._trimAlloc()}this._dynamicSize=e}});i.prototype._byteLength=0;Object.defineProperty(i.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}});Object.defineProperty(i.prototype,"buffer",{get:function(){this._trimAlloc();return this._buffer},set:function(e){this._buffer=e;this._dataView=new DataView(this._buffer,this._byteOffset);this._byteLength=this._buffer.byteLength}});Object.defineProperty(i.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(e){this._byteOffset=e;this._dataView=new DataView(this._buffer,this._byteOffset);this._byteLength=this._buffer.byteLength}});Object.defineProperty(i.prototype,"dataView",{get:function(){return this._dataView},set:function(e){this._byteOffset=e.byteOffset;this._buffer=e.buffer;this._dataView=new DataView(this._buffer,this._byteOffset);this._byteLength=this._byteOffset+e.byteLength}});i.prototype._realloc=function(e){if(!this._dynamicSize){return}var t=this._byteOffset+this.position+e;var r=this._buffer.byteLength;if(t<=r){if(t>this._byteLength){this._byteLength=t}return}if(r<1){r=1}while(t>r){r*=2}var i=new ArrayBuffer(r);var n=new Uint8Array(this._buffer);var a=new Uint8Array(i,0,n.length);a.set(n);this.buffer=i;this._byteLength=t};i.prototype._trimAlloc=function(){if(this._byteLength==this._buffer.byteLength){return}var e=new ArrayBuffer(this._byteLength);var t=new Uint8Array(e);var r=new Uint8Array(this._buffer,0,t.length);t.set(r);this.buffer=e};i.prototype.shift=function(e){var t=new ArrayBuffer(this._byteLength-e);var r=new Uint8Array(t);var i=new Uint8Array(this._buffer,e,r.length);r.set(i);this.buffer=t;this.position-=e};i.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t};i.prototype.isEof=function(){return this.position>=this._byteLength};i.prototype.mapInt32Array=function(e,t){this._realloc(e*4);var r=new Int32Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*4;return r};i.prototype.mapInt16Array=function(e,t){this._realloc(e*2);var r=new Int16Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*2;return r};i.prototype.mapInt8Array=function(e){this._realloc(e*1);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);this.position+=e*1;return t};i.prototype.mapUint32Array=function(e,t){this._realloc(e*4);var r=new Uint32Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*4;return r};i.prototype.mapUint16Array=function(e,t){this._realloc(e*2);var r=new Uint16Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*2;return r};i.prototype.mapUint8Array=function(e){this._realloc(e*1);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);this.position+=e*1;return t};i.prototype.mapFloat64Array=function(e,t){this._realloc(e*8);var r=new Float64Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*8;return r};i.prototype.mapFloat32Array=function(e,t){this._realloc(e*4);var r=new Float32Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*4;return r};i.prototype.readInt32Array=function(e,t){e=e==null?this.byteLength-this.position/4:e;var r=new Int32Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readInt16Array=function(e,t){e=e==null?this.byteLength-this.position/2:e;var r=new Int16Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readInt8Array=function(e){e=e==null?this.byteLength-this.position:e;var t=new Int8Array(e);i.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT);this.position+=t.byteLength;return t};i.prototype.readUint32Array=function(e,t){e=e==null?this.byteLength-this.position/4:e;var r=new Uint32Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readUint16Array=function(e,t){e=e==null?this.byteLength-this.position/2:e;var r=new Uint16Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readUint8Array=function(e){e=e==null?this.byteLength-this.position:e;var t=new Uint8Array(e);i.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT);this.position+=t.byteLength;return t};i.prototype.readFloat64Array=function(e,t){e=e==null?this.byteLength-this.position/8:e;var r=new Float64Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readFloat32Array=function(e,t){e=e==null?this.byteLength-this.position/4:e;var r=new Float32Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.writeInt32Array=function(e,t){this._realloc(e.length*4);if(e instanceof Int32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapInt32Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeInt32(e[r],t)}}};i.prototype.writeInt16Array=function(e,t){this._realloc(e.length*2);if(e instanceof Int16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapInt16Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeInt16(e[r],t)}}};i.prototype.writeInt8Array=function(e){this._realloc(e.length*1);if(e instanceof Int8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapInt8Array(e.length)}else{for(var t=0;t<e.length;t++){this.writeInt8(e[t])}}};i.prototype.writeUint32Array=function(e,t){this._realloc(e.length*4);if(e instanceof Uint32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapUint32Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeUint32(e[r],t)}}};i.prototype.writeUint16Array=function(e,t){this._realloc(e.length*2);if(e instanceof Uint16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapUint16Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeUint16(e[r],t)}}};i.prototype.writeUint8Array=function(e){this._realloc(e.length*1);if(e instanceof Uint8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapUint8Array(e.length)}else{for(var t=0;t<e.length;t++){this.writeUint8(e[t])}}};i.prototype.writeFloat64Array=function(e,t){this._realloc(e.length*8);if(e instanceof Float64Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapFloat64Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeFloat64(e[r],t)}}};i.prototype.writeFloat32Array=function(e,t){this._realloc(e.length*4);if(e instanceof Float32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapFloat32Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeFloat32(e[r],t)}}};i.prototype.readInt32=function(e){var t=this._dataView.getInt32(this.position,e==null?this.endianness:e);this.position+=4;return t};i.prototype.readInt16=function(e){var t=this._dataView.getInt16(this.position,e==null?this.endianness:e);this.position+=2;return t};i.prototype.readInt8=function(){var e=this._dataView.getInt8(this.position);this.position+=1;return e};i.prototype.readUint32=function(e){var t=this._dataView.getUint32(this.position,e==null?this.endianness:e);this.position+=4;return t};i.prototype.readUint16=function(e){var t=this._dataView.getUint16(this.position,e==null?this.endianness:e);this.position+=2;return t};i.prototype.readUint8=function(){var e=this._dataView.getUint8(this.position);this.position+=1;return e};i.prototype.readFloat32=function(e){var t=this._dataView.getFloat32(this.position,e==null?this.endianness:e);this.position+=4;return t};i.prototype.readFloat64=function(e){var t=this._dataView.getFloat64(this.position,e==null?this.endianness:e);this.position+=8;return t};i.prototype.writeInt32=function(e,t){this._realloc(4);this._dataView.setInt32(this.position,e,t==null?this.endianness:t);this.position+=4};i.prototype.writeInt16=function(e,t){this._realloc(2);this._dataView.setInt16(this.position,e,t==null?this.endianness:t);this.position+=2};i.prototype.writeInt8=function(e){this._realloc(1);this._dataView.setInt8(this.position,e);this.position+=1};i.prototype.writeUint32=function(e,t){this._realloc(4);this._dataView.setUint32(this.position,e,t==null?this.endianness:t);this.position+=4};i.prototype.writeUint16=function(e,t){this._realloc(2);this._dataView.setUint16(this.position,e,t==null?this.endianness:t);this.position+=2};i.prototype.writeUint8=function(e){this._realloc(1);this._dataView.setUint8(this.position,e);this.position+=1};i.prototype.writeFloat32=function(e,t){this._realloc(4);this._dataView.setFloat32(this.position,e,t==null?this.endianness:t);this.position+=4};i.prototype.writeFloat64=function(e,t){this._realloc(8);this._dataView.setFloat64(this.position,e,t==null?this.endianness:t);this.position+=8};i.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0;i.memcpy=function(e,t,r,i,n){var a=new Uint8Array(e,t,n);var s=new Uint8Array(r,i,n);a.set(s)};i.arrayToNative=function(e,t){if(t==this.endianness){return e}else{return this.flipArrayEndianness(e)}};i.nativeToEndian=function(e,t){if(this.endianness==t){return e}else{return this.flipArrayEndianness(e)}};i.flipArrayEndianness=function(e){var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);for(var r=0;r<e.byteLength;r+=e.BYTES_PER_ELEMENT){for(var i=r+e.BYTES_PER_ELEMENT-1,n=r;i>n;i--,n++){var a=t[n];t[n]=t[i];t[i]=a}}return e};i.prototype.failurePosition=0;i.prototype.readStruct=function(e){var t={},r,i,n;var a=this.position;for(var s=0;s<e.length;s+=2){r=e[s+1];i=this.readType(r,t);if(i==null){if(this.failurePosition===0){this.failurePosition=this.position}this.position=a;return null}t[e[s]]=i}return t};i.prototype.readUCS2String=function(e,t){return String.fromCharCode.apply(null,this.readUint16Array(e,t))};i.prototype.writeUCS2String=function(e,t,r){if(r==null){r=e.length}for(var i=0;i<e.length&&i<r;i++){this.writeUint16(e.charCodeAt(i),t)}for(;i<r;i++){this.writeUint16(0)}};i.prototype.readString=function(e,t){if(t==null||t=="ASCII"){return String.fromCharCode.apply(null,this.mapUint8Array(e==null?this.byteLength-this.position:e))}else{return new TextDecoder(t).decode(this.mapUint8Array(e))}};i.prototype.writeString=function(e,t,r){var i=0;if(t==null||t=="ASCII"){if(r!=null){var n=Math.min(e.length,r);for(i=0;i<n;i++){this.writeUint8(e.charCodeAt(i))}for(;i<r;i++){this.writeUint8(0)}}else{for(i=0;i<e.length;i++){this.writeUint8(e.charCodeAt(i))}}}else{this.writeUint8Array(new TextEncoder(t).encode(e.substring(0,r)))}};i.prototype.readCString=function(e){var t=this.byteLength-this.position;var r=new Uint8Array(this._buffer,this._byteOffset+this.position);var i=t;if(e!=null){i=Math.min(e,t)}for(var n=0;n<i&&r[n]!==0;n++);var a=String.fromCharCode.apply(null,this.mapUint8Array(n));if(e!=null){this.position+=i-n}else if(n!=t){this.position+=1}return a};i.prototype.writeCString=function(e,t){var r=0;if(t!=null){var i=Math.min(e.length,t);for(r=0;r<i;r++){this.writeUint8(e.charCodeAt(r))}for(;r<t;r++){this.writeUint8(0)}}else{for(r=0;r<e.length;r++){this.writeUint8(e.charCodeAt(r))}this.writeUint8(0)}};i.prototype.readType=function(e,t){if(typeof e=="function"){return e(this,t)}else if(typeof e=="object"&&!(e instanceof Array)){return e.get(this,t)}else if(e instanceof Array&&e.length!=3){return this.readStruct(e,t)}var r=null;var n=null;var a="ASCII";var s=this.position;var o;var f;var u;if(typeof e=="string"&&/:/.test(e)){o=e.split(":");e=o[0];n=parseInt(o[1])}if(typeof e=="string"&&/,/.test(e)){o=e.split(",");e=o[0];a=parseInt(o[1])}switch(e){case"uint8":r=this.readUint8();break;case"int8":r=this.readInt8();break;case"uint16":r=this.readUint16(this.endianness);break;case"int16":r=this.readInt16(this.endianness);break;case"uint32":r=this.readUint32(this.endianness);break;case"int32":r=this.readInt32(this.endianness);break;case"float32":r=this.readFloat32(this.endianness);break;case"float64":r=this.readFloat64(this.endianness);break;case"uint16be":r=this.readUint16(i.BIG_ENDIAN);break;case"int16be":r=this.readInt16(i.BIG_ENDIAN);break;case"uint32be":r=this.readUint32(i.BIG_ENDIAN);break;case"int32be":r=this.readInt32(i.BIG_ENDIAN);break;case"float32be":r=this.readFloat32(i.BIG_ENDIAN);break;case"float64be":r=this.readFloat64(i.BIG_ENDIAN);break;case"uint16le":r=this.readUint16(i.LITTLE_ENDIAN);break;case"int16le":r=this.readInt16(i.LITTLE_ENDIAN);break;case"uint32le":r=this.readUint32(i.LITTLE_ENDIAN);break;case"int32le":r=this.readInt32(i.LITTLE_ENDIAN);break;case"float32le":r=this.readFloat32(i.LITTLE_ENDIAN);break;case"float64le":r=this.readFloat64(i.LITTLE_ENDIAN);break;case"cstring":r=this.readCString(n);break;case"string":r=this.readString(n,a);break;case"u16string":r=this.readUCS2String(n,this.endianness);break;case"u16stringle":r=this.readUCS2String(n,i.LITTLE_ENDIAN);break;case"u16stringbe":r=this.readUCS2String(n,i.BIG_ENDIAN);break;default:if(e.length==3){var l=e[1];var c=e[2];var p=0;if(typeof c=="function"){p=c(t,this,e)}else if(typeof c=="string"&&t[c]!=null){p=parseInt(t[c])}else{p=parseInt(c)}if(typeof l=="string"){var d=l.replace(/(le|be)$/,"");var h=null;if(/le$/.test(l)){h=i.LITTLE_ENDIAN}else if(/be$/.test(l)){h=i.BIG_ENDIAN}if(c=="*"){p=null}switch(d){case"uint8":r=this.readUint8Array(p);break;case"uint16":r=this.readUint16Array(p,h);break;case"uint32":r=this.readUint32Array(p,h);break;case"int8":r=this.readInt8Array(p);break;case"int16":r=this.readInt16Array(p,h);break;case"int32":r=this.readInt32Array(p,h);break;case"float32":r=this.readFloat32Array(p,h);break;case"float64":r=this.readFloat64Array(p,h);break;case"cstring":case"utf16string":case"string":if(p==null){r=[];while(!this.isEof()){u=this.readType(l,t);if(u==null)break;r.push(u)}}else{r=new Array(p);for(f=0;f<p;f++){r[f]=this.readType(l,t)}}break}}else{if(c=="*"){r=[];var m=this.buffer;while(true){var v=this.position;try{var g=this.readType(l,t);if(g==null){this.position=v;break}r.push(g)}catch(y){this.position=v;break}}}else{r=new Array(p);for(f=0;f<p;f++){u=this.readType(l,t);if(u==null)return null;r[f]=u}}}break}}if(n!=null){this.position=s+n}return r};i.prototype.writeStruct=function(e,t){for(var r=0;r<e.length;r+=2){var i=e[r+1];this.writeType(i,t[e[r]],t)}};i.prototype.writeType=function(e,t,r){var n;if(typeof e=="function"){return e(this,t)}else if(typeof e=="object"&&!(e instanceof Array)){return e.set(this,t,r)}var a=null;var s="ASCII";var o=this.position;if(typeof e=="string"&&/:/.test(e)){n=e.split(":");e=n[0];a=parseInt(n[1])}if(typeof e=="string"&&/,/.test(e)){n=e.split(",");e=n[0];s=parseInt(n[1])}switch(e){case"uint8":this.writeUint8(t);break;case"int8":this.writeInt8(t);break;case"uint16":this.writeUint16(t,this.endianness);break;case"int16":this.writeInt16(t,this.endianness);break;case"uint32":this.writeUint32(t,this.endianness);break;case"int32":this.writeInt32(t,this.endianness);break;case"float32":this.writeFloat32(t,this.endianness);break;case"float64":this.writeFloat64(t,this.endianness);break;case"uint16be":this.writeUint16(t,i.BIG_ENDIAN);break;case"int16be":this.writeInt16(t,i.BIG_ENDIAN);break;case"uint32be":this.writeUint32(t,i.BIG_ENDIAN);break;case"int32be":this.writeInt32(t,i.BIG_ENDIAN);break;case"float32be":this.writeFloat32(t,i.BIG_ENDIAN);break;case"float64be":this.writeFloat64(t,i.BIG_ENDIAN);break;case"uint16le":this.writeUint16(t,i.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(t,i.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(t,i.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(t,i.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(t,i.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(t,i.LITTLE_ENDIAN);break;case"cstring":this.writeCString(t,a);break;case"string":this.writeString(t,s,a);break;case"u16string":this.writeUCS2String(t,this.endianness,a);break;case"u16stringle":this.writeUCS2String(t,i.LITTLE_ENDIAN,a);break;case"u16stringbe":this.writeUCS2String(t,i.BIG_ENDIAN,a);break;default:if(e.length==3){var f=e[1];for(var u=0;u<t.length;u++){this.writeType(f,t[u])}break}else{this.writeStruct(e,t);break}}if(a!=null){this.position=o;this._realloc(a);this.position=o+a}};var n=Math.pow(2,32);r.MAX_SIZE=n;i.prototype.readUint64=function(){return this.readUint32()*n+this.readUint32()};i.prototype.writeUint64=function(e){var t=Math.floor(e/n);this.writeUint32(t);this.writeUint32(e&4294967295)};i.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()};i.prototype.writeUint24=function(e){this.writeUint8((e&16711680)>>16);this.writeUint8((e&65280)>>8);this.writeUint8(e&255)};i.prototype.adjustUint32=function(e,t){var r=this.position;this.seek(e);this.writeUint32(t);this.seek(r)}},{}],175:[function(e,t,r){var n=e("./DataStream");var a=e("./descriptor");var s=e("./log");var o={ERR_NOT_ENOUGH_DATA:0,OK:1,boxCodes:["mdat","avcC","hvcC","ftyp","payl","vmhd","smhd","hmhd","dref","elst"],fullBoxCodes:["mvhd","tkhd","mdhd","hdlr","smhd","hmhd","nhmd","url ","urn ","ctts","cslg","stco","co64","stsc","stss","stsz","stz2","stts","stsh","mehd","trex","mfhd","tfhd","trun","tfdt","esds","subs","txtC"],containerBoxCodes:[["moov",["trak"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl"],["mvex",["trex"]],["moof",["traf"]],["traf",["trun"]],["vttc"],["tref"]],sampleEntryCodes:[{prefix:"Visual",types:["mp4v","avc1","avc2","avc3","avc4","avcp","drac","encv","mjp2","mvc1","mvc2","resv","s263","svc1","vc-1","hvc1","hev1"]},{prefix:"Audio",types:["mp4a","ac-3","alac","dra1","dtsc","dtse",,"dtsh","dtsl","ec-3","enca","g719","g726","m4ae","mlpa","raw ","samr","sawb","sawp","sevc","sqcp","ssmv","twos"]},{prefix:"Hint",types:["fdp ","m2ts","pm2t","prtp","rm2t","rrtp","rsrp","rtp ","sm2t","srtp"]},{prefix:"Metadata",types:["metx","mett","urim"]},{prefix:"Subtitle",types:["stpp","wvtt","sbtt","tx3g","stxt"]}],trackReferenceTypes:["scal"],initialize:function(){var e,t;var r;o.FullBox.prototype=new o.Box;o.ContainerBox.prototype=new o.Box;o.stsdBox.prototype=new o.FullBox;o.SampleEntry.prototype=new o.FullBox;o.TrackReferenceTypeBox.prototype=new o.Box;r=o.boxCodes.length;for(e=0;e<r;e++){o[o.boxCodes[e]+"Box"]=function(e){return function(t){o.Box.call(this,o.boxCodes[e],t)}}(e);o[o.boxCodes[e]+"Box"].prototype=new o.Box}r=o.fullBoxCodes.length;for(e=0;e<r;e++){o[o.fullBoxCodes[e]+"Box"]=function(e){return function(t){o.FullBox.call(this,o.fullBoxCodes[e],t)}}(e);o[o.fullBoxCodes[e]+"Box"].prototype=new o.FullBox}r=o.containerBoxCodes.length;for(e=0;e<r;e++){o[o.containerBoxCodes[e][0]+"Box"]=function(e,t){return function(r){o.ContainerBox.call(this,o.containerBoxCodes[e][0],r);if(t){this.subBoxNames=t;var i=t.length;for(var n=0;n<i;n++){this[t[n]+"s"]=[]}}}}(e,o.containerBoxCodes[e][1]);o[o.containerBoxCodes[e][0]+"Box"].prototype=new o.ContainerBox}r=o.sampleEntryCodes.length;for(t=0;t<r;t++){var i=o.sampleEntryCodes[t].prefix;var n=o.sampleEntryCodes[t].types;var a=n.length;o[i+"SampleEntry"]=function(e,t){o.SampleEntry.call(this,e,t)};o[i+"SampleEntry"].prototype=new o.SampleEntry;for(e=0;e<a;e++){o[n[e]+"Box"]=function(e,t){return function(r){o[o.sampleEntryCodes[e].prefix+"SampleEntry"].call(this,o.sampleEntryCodes[e].types[t],r)}}(t,e);o[n[e]+"Box"].prototype=new o[i+"SampleEntry"]}}r=o.trackReferenceTypes.length;for(e=0;e<r;e++){o[o.trackReferenceTypes[e]+"Box"]=function(e){return function(t){o.TrackReferenceTypeBox.call(this,o.trackReferenceTypes[e],t)}}(e);o[o.trackReferenceTypes[e]+"Box"].prototype=new o.Box}},Box:function(e,t){this.type=e;this.size=t},FullBox:function(e,t){o.Box.call(this,e,t);this.flags=0;this.version=0},ContainerBox:function(e,t){o.Box.call(this,e,t);this.boxes=[]},SampleEntry:function(e,t){o.Box.call(this,e,t);this.boxes=[]},TrackReferenceTypeBox:function(e,t){o.Box.call(this,e,t);this.track_ids=[]},stsdBox:function(e){o.FullBox.call(this,"stsd",e);this.entries=[]},parseOneBox:function(e,t){var r;var i=e.position;var n=0;if(e.byteLength-e.position<8){s.d("BoxParser","Not enough data in stream to parse the type and size of the box");return{code:o.ERR_NOT_ENOUGH_DATA}}var a=e.readUint32();var f=e.readString(4);s.d("BoxParser","Found box of type "+f+" and size "+a+" at position "+i+" in the current buffer ("+(e.buffer.fileStart+i)+" in the file)");n=8;if(a==1){if(e.byteLength-e.position<8){e.seek(i);s.w("BoxParser",'Not enough data in stream to parse the extended size of the "'+f+'" box');return{code:o.ERR_NOT_ENOUGH_DATA}}a=e.readUint64();n+=8}else if(a===0){throw"Unlimited box size not supported"}if(i+a>e.byteLength){e.seek(i);s.w("BoxParser",'Not enough data in stream to parse the entire "'+f+'" box');return{code:o.ERR_NOT_ENOUGH_DATA,type:f,size:a,hdr_size:n}}if(o[f+"Box"]){r=new o[f+"Box"](a-n)}else{if(t){r=new o.SampleEntry(f,a-n)}else{r=new o.Box(f,a-n)}}r.hdr_size=n;r.start=i;r.fileStart=i+e.buffer.fileStart;r.parse(e);e.seek(i+a);return{code:o.OK,box:r,size:a}}};t.exports=o;o.initialize();o.Box.prototype.parse=function(e){if(this.type!="mdat"){this.data=e.readUint8Array(this.size)}else{e.seek(this.start+this.size+this.hdr_size)}};o.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8();this.flags=e.readUint24();this.size-=4};o.ContainerBox.prototype.parse=function(e){var t;var r;var i;i=e.position;while(e.position<i+this.size){t=o.parseOneBox(e);r=t.box;this.boxes.push(r);if(this.subBoxNames&&this.subBoxNames.indexOf(r.type)!=-1){this[this.subBoxNames+"s"].push(r)}else{this[r.type]=r}}};o.SampleEntry.prototype.isVideo=function(){return false};o.SampleEntry.prototype.isAudio=function(){return false};o.SampleEntry.prototype.isSubtitle=function(){return false};o.SampleEntry.prototype.isMetadata=function(){return false};o.SampleEntry.prototype.isHint=function(){return false};o.SampleEntry.prototype.getCodec=function(){return this.type};o.SampleEntry.prototype.getWidth=function(){return""};o.SampleEntry.prototype.getHeight=function(){return""};o.SampleEntry.prototype.getChannelCount=function(){return""};o.SampleEntry.prototype.getSampleRate=function(){return""};o.SampleEntry.prototype.getSampleSize=function(){return""};o.SampleEntry.prototype.parseHeader=function(e){this.start=e.position;e.readUint8Array(6);this.data_reference_index=e.readUint16()};o.SampleEntry.prototype.parse=function(e){this.parseHeader(e);e.seek(this.start+this.size)};o.SampleEntry.prototype.parseFooter=function(e){var t;var r;while(e.position<this.start+this.size){t=o.parseOneBox(e,false);r=t.box;this.boxes.push(r);this[r.type]=r}};o.VisualSampleEntry.prototype.parse=function(e){this.parseHeader(e);e.readUint16();e.readUint16();e.readUint32Array(3);this.width=e.readUint16();this.height=e.readUint16();this.horizresolution=e.readUint32();this.vertresolution=e.readUint32();e.readUint32();this.frame_count=e.readUint16();this.compressorname=e.readString(32);this.depth=e.readUint16();e.readUint16();this.parseFooter(e)};o.VisualSampleEntry.prototype.isVideo=function(){return true};o.VisualSampleEntry.prototype.getWidth=function(){return this.width};o.VisualSampleEntry.prototype.getHeight=function(){return this.height};o.AudioSampleEntry.prototype.parse=function(e){this.parseHeader(e);e.readUint32Array(2);this.channel_count=e.readUint16();this.samplesize=e.readUint16();e.readUint16();e.readUint16();this.samplerate=e.readUint32()/(1<<16);this.parseFooter(e)};o.AudioSampleEntry.prototype.isAudio=function(){
-return true};o.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_count};o.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate};o.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize};o.SubtitleSampleEntry.prototype.parse=function(e){this.parseHeader(e);this.parseFooter(e)};o.SubtitleSampleEntry.prototype.isSubtitle=function(){return true};o.MetadataSampleEntry.prototype.parse=function(e){this.parseHeader(e);this.parseFooter(e)};o.MetadataSampleEntry.prototype.isMetadata=function(){return true};o.TrackReferenceTypeBox.prototype.parse=function(e){this.track_ids=e.readUint8Array(this.size)};o.metxBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.namespace=e.readCString();this.schema_location=e.readCString();this.parseFooter(e)};o.mettBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.mime_format=e.readCString();this.parseFooter(e)};o.sbttBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.mime_format=e.readCString();this.parseFooter(e)};o.stxtBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.mime_format=e.readCString();this.parseFooter(e)};o.stppBox.prototype.parse=function(e){this.parseHeader(e);this.namespace=e.readCString();this.schema_location=e.readCString();this.auxiliary_mime_types=e.readCString();this.parseFooter(e)};o.tx3gBox.prototype.parse=function(e){this.parseHeader(e);this.displayFlags=e.readUint32();this.horizontal_justification=e.readInt8();this.vertical_justification=e.readInt8();this.bg_color_rgba=e.readUint8Array(4);this.box_record=e.readInt16Array(4);this.style_record=e.readUint8Array(12);this.parseFooter(e)};o.ftypBox.prototype.parse=function(e){this.major_brand=e.readString(4);this.minor_version=e.readUint32();this.size-=8;this.compatible_brands=[];var t=0;while(this.size>=4){this.compatible_brands[t]=e.readString(4);this.size-=4;t++}};o.mvhdBox.prototype.parse=function(e){this.flags=0;this.parseFullHeader(e);if(this.version==1){this.creation_time=e.readUint64();this.modification_time=e.readUint64();this.timescale=e.readUint32();this.duration=e.readUint64()}else{this.creation_time=e.readUint32();this.modification_time=e.readUint32();this.timescale=e.readUint32();this.duration=e.readUint32()}this.rate=e.readUint32();this.volume=e.readUint16()>>8;e.readUint16();e.readUint32Array(2);this.matrix=e.readUint32Array(9);e.readUint32Array(6);this.next_track_id=e.readUint32()};o.TKHD_FLAG_ENABLED=1;o.TKHD_FLAG_IN_MOVIE=2;o.TKHD_FLAG_IN_PREVIEW=4;o.tkhdBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.creation_time=e.readUint64();this.modification_time=e.readUint64();this.track_id=e.readUint32();e.readUint32();this.duration=e.readUint64()}else{this.creation_time=e.readUint32();this.modification_time=e.readUint32();this.track_id=e.readUint32();e.readUint32();this.duration=e.readUint32()}e.readUint32Array(2);this.layer=e.readInt16();this.alternate_group=e.readInt16();this.volume=e.readInt16()>>8;e.readUint16();this.matrix=e.readInt32Array(9);this.width=e.readUint32();this.height=e.readUint32()};o.mdhdBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.creation_time=e.readUint64();this.modification_time=e.readUint64();this.timescale=e.readUint32();this.duration=e.readUint64()}else{this.creation_time=e.readUint32();this.modification_time=e.readUint32();this.timescale=e.readUint32();this.duration=e.readUint32()}this.language=e.readUint16();var t=[];t[0]=this.language>>10&31;t[1]=this.language>>5&31;t[2]=this.language&31;this.languageString=String.fromCharCode(t[0]+96,t[1]+96,t[2]+96);e.readUint16()};o.hdlrBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version===0){e.readUint32();this.handler=e.readString(4);e.readUint32Array(3);this.name=e.readCString()}else{this.data=e.readUint8Array(size)}};o.stsdBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);r=e.readUint32();for(i=1;i<=r;i++){t=o.parseOneBox(e,true);this.entries.push(t.box)}};o.avcCBox.prototype.parse=function(e){var t;var r;var i;this.configurationVersion=e.readUint8();this.AVCProfileIndication=e.readUint8();this.profile_compatibility=e.readUint8();this.AVCLevelIndication=e.readUint8();this.lengthSizeMinusOne=e.readUint8()&3;r=e.readUint8()&31;this.size-=6;this.SPS=new Array(r);for(t=0;t<r;t++){i=e.readUint16();this.SPS[t]=e.readUint8Array(i);this.size-=2+i}r=e.readUint8();this.size--;this.PPS=new Array(r);for(t=0;t<r;t++){i=e.readUint16();this.PPS[t]=e.readUint8Array(i);this.size-=2+i}if(this.size>0){this.ext=e.readUint8Array(this.size)}};o.hvcCBox.prototype.parse=function(e){var t;var r;var i;var n;this.configurationVersion=e.readUint8();n=e.readUint8();this.general_profile_space=n>>6;this.general_tier_flag=(n&32)>>5;this.general_profile_idc=n&31;this.general_profile_compatibility=e.readUint32();this.general_constraint_indicator=e.readUint8Array(6);this.general_level_idc=e.readUint8();this.min_spatial_segmentation_idc=e.readUint16()&4095;this.parallelismType=e.readUint8()&3;this.chromaFormat=e.readUint8()&3;this.bitDepthLumaMinus8=e.readUint8()&7;this.bitDepthChromaMinus8=e.readUint8()&7;this.avgFrameRate=e.readUint16();n=e.readUint8();this.constantFrameRate=n>>6;this.numTemporalLayers=(n&13)>>3;this.temporalIdNested=(n&4)>>2;this.lengthSizeMinusOne=n&3;this.nalu_arrays=[];numOfArrays=e.readUint8();for(t=0;t<numOfArrays;t++){var a=[];this.nalu_arrays.push(a);n=e.readUint8();a.completeness=(n&128)>>7;a.nalu_type=n&63;numNalus=e.readUint16();for(j=0;j<numNalus;j++){var s={};a.push(s);i=e.readUint16();s.data=e.readUint8Array(i)}}};function f(e,t){var r=Number(e).toString(16);t=typeof t==="undefined"||t===null?t=2:t;while(r.length<t){r="0"+r}return r}o.avc1Box.prototype.getCodec=function(){var e=o.SampleEntry.prototype.getCodec.call(this);if(this.avcC){return e+"."+f(this.avcC.AVCProfileIndication)+""+f(this.avcC.profile_compatibility)+""+f(this.avcC.AVCLevelIndication)}else{return e}};o.hvc1Box.prototype.getCodec=function(){var e;var t=o.SampleEntry.prototype.getCodec.call(this);if(this.hvcC){t+=".";switch(this.hvcC.general_profile_space){case 0:t+="";break;case 1:t+="A";break;case 2:t+="B";break;case 3:t+="C";break}t+=this.hvcC.general_profile_idc;t+=".";var r=this.hvcC.general_profile_compatibility;var i=0;for(e=0;e<32;e++){i|=r&1;if(e==31)break;i<<=1;r>>=1}t+=f(i,0);t+=".";if(this.hvcC.general_tier_flag===0){t+="L"}else{t+="H"}t+=this.hvcC.general_level_idc;var n=false;var a="";for(e=5;e>=0;e--){if(this.hvcC.general_constraint_indicator[e]||n){a="."+f(this.hvcC.general_constraint_indicator[e],0)+a;n=true}}t+=a}return t};o.mp4aBox.prototype.getCodec=function(){var e=o.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var t=this.esds.esd.getOTI();var r=this.esds.esd.getAudioConfig();return e+"."+f(t)+(r?"."+r:"")}else{return e}};o.esdsBox.prototype.parse=function(e){this.parseFullHeader(e);this.data=e.readUint8Array(this.size);this.size=0;var t=new a;this.esd=t.parseOneDescriptor(new n(this.data.buffer,0,n.BIG_ENDIAN))};o.txtCBox.prototype.parse=function(e){this.parseFullHeader(e);this.config=e.readCString()};o.cttsBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.sample_counts=[];this.sample_offsets=[];if(this.version===0){for(r=0;r<t;r++){this.sample_counts.push(e.readUint32());this.sample_offsets.push(e.readInt32())}}else if(this.version==1){for(r=0;r<t;r++){this.sample_counts.push(e.readUint32());this.sample_offsets.push(e.readInt32())}}else{this.data=e.readUint8Array(this.size-4)}};o.cttsBox.prototype.unpack=function(e){var t,r,i;i=0;for(t=0;t<this.sample_counts.length;t++){for(r=0;r<this.sample_counts[t];r++){e[i].pts=e[i].dts+this.sample_offsets[t];i++}}};o.cslgBox.prototype.parse=function(e){var t;this.parseFullHeader(e);if(this.version===0){this.compositionToDTSShift=e.readInt32();this.leastDecodeToDisplayDelta=e.readInt32();this.greatestDecodeToDisplayDelta=e.readInt32();this.compositionStartTime=e.readInt32();this.compositionEndTime=e.readInt32()}else{this.data=e.readUint8Array(this.size-4)}};o.sttsBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.sample_counts=[];this.sample_deltas=[];if(this.version===0){for(r=0;r<t;r++){this.sample_counts.push(e.readUint32());this.sample_deltas.push(e.readUint32())}}else{this.data=e.readUint8Array(this.size-4)}};o.sttsBox.prototype.unpack=function(e){var t,r,i;i=0;for(t=0;t<this.sample_counts.length;t++){for(r=0;r<this.sample_counts[t];r++){if(i===0){e[i].dts=0}else{e[i].dts=e[i-1].dts+this.sample_deltas[t]}i++}}};o.stssBox.prototype.parse=function(e){var t;this.parseFullHeader(e);t=e.readUint32();if(this.version===0){this.sample_numbers=e.readUint32Array(t)}else{this.data=e.readUint8Array(this.size-4)}};o.stshBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.shadowed_sample_numbers=[];this.sync_sample_numbers=[];if(this.version===0){for(r=0;r<t;r++){this.shadowed_sample_numbers.push(e.readUint32());this.sync_sample_numbers.push(e.readUint32())}}else{this.data=e.readUint8Array(this.size-4)}};o.stcoBox.prototype.parse=function(e){var t;this.parseFullHeader(e);t=e.readUint32();if(this.version===0){this.chunk_offsets=e.readUint32Array(t)}else{this.data=e.readUint8Array(this.size-4)}};o.stcoBox.prototype.unpack=function(e){var t;for(t=0;t<this.chunk_offsets.length;t++){e[t].offset=this.chunk_offsets[t]}};o.co64Box.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.chunk_offsets=[];if(this.version===0){for(r=0;r<t;r++){this.chunk_offsets.push(e.readUint64())}}else{this.data=e.readUint8Array(this.size-4)}};o.stscBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.first_chunk=[];this.samples_per_chunk=[];this.sample_description_index=[];if(this.version===0){for(r=0;r<t;r++){this.first_chunk.push(e.readUint32());this.samples_per_chunk.push(e.readUint32());this.sample_description_index.push(e.readUint32())}}else{this.data=e.readUint8Array(this.size-4)}};o.stscBox.prototype.unpack=function(e){var t,r,i,n,a;n=0;a=0;for(t=0;t<this.first_chunk.length;t++){for(r=0;r<(t+1<this.first_chunk.length?this.first_chunk[t+1]:Infinity);r++){a++;for(i=0;i<this.samples_per_chunk[t];i++){if(e[n]){e[n].description_index=this.sample_description_index[t];e[n].chunk_index=a}else{return}n++}}}};o.stszBox.prototype.parse=function(e){var t;var r;var i;this.parseFullHeader(e);this.sample_sizes=[];if(this.version===0){r=e.readUint32();i=e.readUint32();if(r===0){this.sample_sizes=e.readUint32Array(i)}else{this.sample_sizes=[];for(t=0;t<i;t++){this.sample_sizes[t]=r}}}else{this.data=e.readUint8Array(this.size)}};o.stszBox.prototype.unpack=function(e){var t;for(t=0;t<this.sample_sizes.length;t++){e[t].size=this.sample_sizes[t]}};o.mehdBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.fragment_duration=e.readUint64()}else{this.fragment_duration=e.readUint32()}};o.trexBox.prototype.parse=function(e){this.parseFullHeader(e);this.track_id=e.readUint32();this.default_sample_description_index=e.readUint32();this.default_sample_duration=e.readUint32();this.default_sample_size=e.readUint32();this.default_sample_flags=e.readUint32()};o.mfhdBox.prototype.parse=function(e){this.parseFullHeader(e);this.sequence_number=e.readUint32()};o.TFHD_FLAG_BASE_DATA_OFFSET=1;o.TFHD_FLAG_SAMPLE_DESC=2;o.TFHD_FLAG_SAMPLE_DUR=8;o.TFHD_FLAG_SAMPLE_SIZE=16;o.TFHD_FLAG_SAMPLE_FLAGS=32;o.TFHD_FLAG_DUR_EMPTY=65536;o.TFHD_FLAG_DEFAULT_BASE_IS_MOOF=131072;o.tfhdBox.prototype.parse=function(e){var t=0;this.parseFullHeader(e);this.track_id=e.readUint32();if(this.size>t&&this.flags&o.TFHD_FLAG_BASE_DATA_OFFSET){this.base_data_offset=e.readUint64();t+=8}else{this.base_data_offset=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_DESC){this.default_sample_description_index=e.readUint32();t+=4}else{this.default_sample_description_index=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_DUR){this.default_sample_duration=e.readUint32();t+=4}else{this.default_sample_duration=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_SIZE){this.default_sample_size=e.readUint32();t+=4}else{this.default_sample_size=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_FLAGS){this.default_sample_flags=e.readUint32();t+=4}else{this.default_sample_flags=0}};o.TRUN_FLAGS_DATA_OFFSET=1;o.TRUN_FLAGS_FIRST_FLAG=4;o.TRUN_FLAGS_DURATION=256;o.TRUN_FLAGS_SIZE=512;o.TRUN_FLAGS_FLAGS=1024;o.TRUN_FLAGS_CTS_OFFSET=2048;o.trunBox.prototype.parse=function(e){var t=0;this.parseFullHeader(e);this.sample_count=e.readUint32();t+=4;if(this.size>t&&this.flags&o.TRUN_FLAGS_DATA_OFFSET){this.data_offset=e.readInt32();t+=4}else{this.data_offset=0}if(this.size>t&&this.flags&o.TRUN_FLAGS_FIRST_FLAG){this.first_sample_flags=e.readUint32();t+=4}else{this.first_sample_flags=0}this.sample_duration=[];this.sample_size=[];this.sample_flags=[];this.sample_composition_time_offset=[];if(this.size>t){for(var r=0;r<this.sample_count;r++){if(this.flags&o.TRUN_FLAGS_DURATION){this.sample_duration[r]=e.readUint32()}if(this.flags&o.TRUN_FLAGS_SIZE){this.sample_size[r]=e.readUint32()}if(this.flags&o.TRUN_FLAGS_FLAGS){this.sample_flags[r]=e.readUint32()}if(this.flags&o.TRUN_FLAGS_CTS_OFFSET){if(this.version===0){this.sample_composition_time_offset[r]=e.readUint32()}else{this.sample_composition_time_offset[r]=e.readInt32()}}}}};o.tfdtBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.baseMediaDecodeTime=e.readUint64()}else{this.baseMediaDecodeTime=e.readUint32()}};o.paylBox.prototype.parse=function(e){this.text=e.readString(this.size)};o.subsBox.prototype.parse=function(e){var t,r;var i;var n;this.parseFullHeader(e);i=e.readUint32();this.samples=[];for(t=0;t<i;t++){var a={};this.samples[t]=a;a.sample_delta=e.readUint32();a.subsamples=[];n=e.readUint16();if(n>0){for(r=0;r<n;r++){var s={};a.subsamples.push(s);if(this.version==1){s.size=e.readUint32()}else{s.size=e.readUint16()}s.priority=e.readUint8();s.discardable=e.readUint8();s.reserved=e.readUint32()}}}};o.Box.prototype.writeHeader=function(e,t){this.size+=8;if(this.size>n.MAX_SIZE){this.size+=8}s.d("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+e.position+(t||""));if(this.size>n.MAX_SIZE){e.writeUint32(1)}else{this.sizePosition=e.position;e.writeUint32(this.size)}e.writeString(this.type,null,4);if(this.size>n.MAX_SIZE){e.writeUint64(this.size)}};o.FullBox.prototype.writeHeader=function(e){this.size+=4;o.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags);e.writeUint8(this.version);e.writeUint24(this.flags)};o.Box.prototype.write=function(e){if(this.type==="mdat"){if(this.data){this.size=this.data.length;this.writeHeader(e);e.writeUint8Array(this.data)}}else{this.size=this.data.length;this.writeHeader(e);e.writeUint8Array(this.data)}};o.ContainerBox.prototype.write=function(e){this.size=0;this.writeHeader(e);for(var t=0;t<this.boxes.length;t++){if(this.boxes[t]){this.boxes[t].write(e);this.size+=this.boxes[t].size}}s.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size);e.adjustUint32(this.sizePosition,this.size)};o.TrackReferenceTypeBox.prototype.write=function(e){this.size=this.track_ids.length*4;this.writeHeader(e);e.writeUint32Array(this.track_ids)};o.ftypBox.prototype.write=function(e){this.size=8+4*this.compatible_brands.length;this.writeHeader(e);e.writeString(this.major_brand,null,4);e.writeUint32(this.minor_version);for(var t=0;t<this.compatible_brands.length;t++){e.writeString(this.compatible_brands[t],null,4)}};o.mvhdBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=23*4+2*2;this.writeHeader(e);e.writeUint32(this.creation_time);e.writeUint32(this.modification_time);e.writeUint32(this.timescale);e.writeUint32(this.duration);e.writeUint32(this.rate);e.writeUint16(this.volume<<8);e.writeUint16(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32Array(this.matrix);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(this.next_track_id)};o.tkhdBox.prototype.write=function(e){this.version=0;this.size=4*18+2*4;this.writeHeader(e);e.writeUint32(this.creation_time);e.writeUint32(this.modification_time);e.writeUint32(this.track_id);e.writeUint32(0);e.writeUint32(this.duration);e.writeUint32(0);e.writeUint32(0);e.writeInt16(this.layer);e.writeInt16(this.alternate_group);e.writeInt16(this.volume<<8);e.writeUint16(0);e.writeInt32Array(this.matrix);e.writeUint32(this.width);e.writeUint32(this.height)};o.mdhdBox.prototype.write=function(e){this.size=4*4+2*2;this.flags=0;this.version=0;this.writeHeader(e);e.writeUint32(this.creation_time);e.writeUint32(this.modification_time);e.writeUint32(this.timescale);e.writeUint32(this.duration);e.writeUint16(this.language);e.writeUint16(0)};o.hdlrBox.prototype.write=function(e){this.size=5*4+this.name.length+1;this.version=0;this.flags=0;this.writeHeader(e);e.writeUint32(0);e.writeString(this.handler,null,4);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeCString(this.name)};o.stsdBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=0;this.writeHeader(e);e.writeUint32(this.entries.length);this.size+=4;for(t=0;t<this.entries.length;t++){this.entries[t].write(e);this.size+=this.entries[t].size}s.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size);e.adjustUint32(this.sizePosition,this.size)};o.SampleEntry.prototype.writeHeader=function(e){this.size=8;o.Box.prototype.writeHeader.call(this,e);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint16(this.data_reference_index)};o.SampleEntry.prototype.writeFooter=function(e){for(var t=0;t<this.boxes.length;t++){this.boxes[t].write(e);this.size+=this.boxes[t].size}s.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size);e.adjustUint32(this.sizePosition,this.size)};o.SampleEntry.prototype.write=function(e){this.writeHeader(e);this.writeFooter(e)};o.VisualSampleEntry.prototype.write=function(e){this.writeHeader(e);this.size+=2*7+6*4+32;e.writeUint16(0);e.writeUint16(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint16(this.width-this.width%2);e.writeUint16(this.height-this.height%2);e.writeUint32(this.horizresolution);e.writeUint32(this.vertresolution);e.writeUint32(0);e.writeUint16(this.frame_count);e.writeString(this.compressorname,null,32);e.writeUint16(this.depth);e.writeInt16(-1);this.writeFooter(e)};o.AudioSampleEntry.prototype.write=function(e){this.writeHeader(e);this.size+=2*4+3*4;e.writeUint32(0);e.writeUint32(0);e.writeUint16(this.channel_count);e.writeUint16(this.samplesize);e.writeUint16(0);e.writeUint16(0);e.writeUint32(this.samplerate<<16);this.writeFooter(e)};o.avcCBox.prototype.write=function(e){var t;this.size=7;for(t=0;t<this.SPS.length;t++){this.size+=2+this.SPS[t].length}for(t=0;t<this.PPS.length;t++){this.size+=2+this.PPS[t].length}if(this.ext){this.size+=this.ext.length}this.writeHeader(e);e.writeUint8(this.configurationVersion);e.writeUint8(this.AVCProfileIndication);e.writeUint8(this.profile_compatibility);e.writeUint8(this.AVCLevelIndication);e.writeUint8(this.lengthSizeMinusOne+(63<<2));e.writeUint8(this.SPS.length+(7<<5));for(t=0;t<this.SPS.length;t++){e.writeUint16(this.SPS[t].length);e.writeUint8Array(this.SPS[t])}e.writeUint8(this.PPS.length);for(t=0;t<this.PPS.length;t++){e.writeUint16(this.PPS[t].length);e.writeUint8Array(this.PPS[t])}if(this.ext){e.writeUint8Array(this.ext)}};o.cttsBox.prototype.write=function(e){var t;this.version=1;this.flags=0;this.size=4+8*this.sample_counts.length;this.writeHeader(e);e.writeUint32(this.sample_counts.length);for(t=0;t<this.sample_counts.length;t++){e.writeUint32(this.sample_counts[t]);e.writeInt32(this.sample_offsets[t])}};o.cslgBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4*5;this.writeHeader(e);e.writeInt32(this.compositionToDTSShift);e.writeInt32(this.leastDecodeToDisplayDelta);e.writeInt32(this.greatestDecodeToDisplayDelta);e.writeInt32(this.compositionStartTime);e.writeInt32(this.compositionEndTime)};o.sttsBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+8*this.sample_counts.length;this.writeHeader(e);e.writeUint32(this.sample_counts.length);for(t=0;t<this.sample_counts.length;t++){e.writeUint32(this.sample_counts[t]);e.writeUint32(this.sample_deltas[t])}};o.stssBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4+4*this.sample_numbers.length;this.writeHeader(e);e.writeUint32(this.sample_numbers.length);e.writeUint32Array(this.sample_numbers)};o.stshBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+8*this.shadowed_sample_numbers.length;this.writeHeader(e);e.writeUint32(this.shadowed_sample_numbers.length);for(t=0;t<this.shadowed_sample_numbers.length;t++){e.writeUint32(this.shadowed_sample_numbers[t]);e.writeUint32(this.sync_sample_numbers[t])}};o.stcoBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4+4*this.chunk_offsets.length;this.writeHeader(e);e.writeUint32(this.chunk_offsets.length);e.writeUint32Array(this.chunk_offsets)};o.co64Box.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+8*this.chunk_offsets.length;this.writeHeader(e);e.writeUint32(this.chunk_offsets.length);for(t=0;t<this.chunk_offsets.length;t++){e.writeUint64(this.chunk_offsets[t])}};o.stscBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+12*this.first_chunk.length;this.writeHeader(e);e.writeUint32(this.first_chunk.length);for(t=0;t<this.first_chunk.length;t++){e.writeUint32(this.first_chunk[t]);e.writeUint32(this.samples_per_chunk[t]);e.writeUint32(this.sample_description_index[t])}};o.stszBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=8+12*this.sample_sizes.length;this.writeHeader(e);e.writeUint32(0);e.writeUint32(this.sample_sizes.length);e.writeUint32Array(this.sample_sizes)};o.mehdBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4;this.writeHeader(e);e.writeUint32(this.fragment_duration)};o.trexBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4*5;this.writeHeader(e);e.writeUint32(this.track_id);e.writeUint32(this.default_sample_description_index);e.writeUint32(this.default_sample_duration);e.writeUint32(this.default_sample_size);e.writeUint32(this.default_sample_flags)};o.mfhdBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4;this.writeHeader(e);e.writeUint32(this.sequence_number)};o.tfhdBox.prototype.write=function(e){this.version=0;this.size=4;if(this.flags&o.TFHD_FLAG_BASE_OFFSET){this.size+=8}if(this.flags&o.TFHD_FLAG_SAMPLE_DESC){this.size+=4}if(this.flags&o.TFHD_FLAG_SAMPLE_DUR){this.size+=4}if(this.flags&o.TFHD_FLAG_SAMPLE_SIZE){this.size+=4}if(this.flags&o.TFHD_FLAG_SAMPLE_FLAGS){this.size+=4}this.writeHeader(e);e.writeUint32(this.track_id);if(this.flags&o.TFHD_FLAG_BASE_OFFSET){e.writeUint64(this.base_data_offset)}if(this.flags&o.TFHD_FLAG_SAMPLE_DESC){e.writeUint32(this.default_sample_description_index)}if(this.flags&o.TFHD_FLAG_SAMPLE_DUR){e.writeUint32(this.default_sample_duration)}if(this.flags&o.TFHD_FLAG_SAMPLE_SIZE){e.writeUint32(this.default_sample_size)}if(this.flags&o.TFHD_FLAG_SAMPLE_FLAGS){e.writeUint32(this.default_sample_flags)}};o.trunBox.prototype.write=function(e){this.version=0;this.size=4;if(this.flags&o.TRUN_FLAGS_DATA_OFFSET){this.size+=4}if(this.flags&o.TRUN_FLAGS_FIRST_FLAG){this.size+=4}if(this.flags&o.TRUN_FLAGS_DURATION){this.size+=4*this.sample_duration.length}if(this.flags&o.TRUN_FLAGS_SIZE){this.size+=4*this.sample_size.length}if(this.flags&o.TRUN_FLAGS_FLAGS){this.size+=4*this.sample_flags.length}if(this.flags&o.TRUN_FLAGS_CTS_OFFSET){this.size+=4*this.sample_composition_time_offset.length}this.writeHeader(e);e.writeUint32(this.sample_count);if(this.flags&o.TRUN_FLAGS_DATA_OFFSET){this.data_offset_position=e.position;e.writeInt32(this.data_offset)}if(this.flags&o.TRUN_FLAGS_FIRST_FLAG){e.writeUint32(this.first_sample_flags)}for(var t=0;t<this.sample_count;t++){if(this.flags&o.TRUN_FLAGS_DURATION){e.writeUint32(this.sample_duration[t])}if(this.flags&o.TRUN_FLAGS_SIZE){e.writeUint32(this.sample_size[t])}if(this.flags&o.TRUN_FLAGS_FLAGS){e.writeUint32(this.sample_flags[t])}if(this.flags&o.TRUN_FLAGS_CTS_OFFSET){if(this.version===0){e.writeUint32(this.sample_composition_time_offset[t])}else{e.writeInt32(this.sample_composition_time_offset[t])}}}};o.tfdtBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4;this.writeHeader(e);if(this.version==1){e.writeUint64(this.baseMediaDecodeTime)}else{e.writeUint32(this.baseMediaDecodeTime)}}},{"./DataStream":174,"./descriptor":176,"./log":178}],176:[function(e,t,r){var i=e("./log");var n=function(){var e=3;var t=4;var r=5;var n=6;var a=[];a[e]="ES_Descriptor";a[t]="DecoderConfigDescriptor";a[r]="DecoderSpecificInfo";a[n]="SLConfigDescriptor";var s=this;var o={};this.parseOneDescriptor=function(e){var t=0;var r=0;var n;var s;var f;n=e.readUint8();t++;f=e.readUint8();t++;while(f&128){r=(f&127)<<7;f=e.readUint8();t++}r+=f&127;i.d("MPEG4DescriptorParser","Found "+(a[n]|"Descriptor "+n)+", size "+r+" at position "+e.position);if(a[n]){s=new o[a[n]](r)}else{s=new o.Descriptor(r)}s.parse(e);return s};o.Descriptor=function(e,t){this.tag=e;this.size=t;this.descs=[]};o.Descriptor.prototype.parse=function(e){this.data=e.readUint8Array(this.size)};o.Descriptor.prototype.findDescriptor=function(e){for(var t=0;t<this.descs.length;t++){if(this.descs[t].tag==e){return this.descs[t]}}return null};o.Descriptor.prototype.parseRemainingDescriptors=function(e){var t=e.position;while(e.position<t+this.size){var r=s.parseOneDescriptor(e);this.descs.push(r)}};o.ES_Descriptor=function(t){o.Descriptor.call(this,e,t)};o.ES_Descriptor.prototype=new o.Descriptor;o.ES_Descriptor.prototype.parse=function(e){this.ES_ID=e.readUint16();this.flags=e.readUint8();this.size-=3;if(this.flags&128){this.dependsOn_ES_ID=e.readUint16();this.size-=2}else{this.dependsOn_ES_ID=0}if(this.flags&64){var t=e.readUint8();this.URL=e.readString(t);this.size-=t+1}else{this.URL=null}if(this.flags&32){this.OCR_ES_ID=e.readUint16();this.size-=2}else{this.OCR_ES_ID=0}this.parseRemainingDescriptors(e)};o.ES_Descriptor.prototype.getOTI=function(e){var r=this.findDescriptor(t);if(r){return r.oti}else{return 0}};o.ES_Descriptor.prototype.getAudioConfig=function(e){var i=this.findDescriptor(t);if(!i)return null;var n=i.findDescriptor(r);if(n&&n.data){return(n.data[0]&248)>>3}else{return null}};o.DecoderConfigDescriptor=function(e){o.Descriptor.call(this,t,e)};o.DecoderConfigDescriptor.prototype=new o.Descriptor;o.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8();this.streamType=e.readUint8();this.bufferSize=e.readUint24();this.maxBitrate=e.readUint32();this.avgBitrate=e.readUint32();this.size-=13;this.parseRemainingDescriptors(e)};o.DecoderSpecificInfo=function(e){o.Descriptor.call(this,r,e)};o.DecoderSpecificInfo.prototype=new o.Descriptor;o.SLConfigDescriptor=function(e){o.Descriptor.call(this,n,e)};o.SLConfigDescriptor.prototype=new o.Descriptor;return this};t.exports=n},{"./log":178}],177:[function(e,t,r){var i=e("./box");var n=e("./DataStream");var a=e("./log");var s=function(e){this.stream=e;this.boxes=[];this.mdats=[];this.moofs=[];this.isProgressive=false;this.lastMoofIndex=0;this.lastBoxStartPosition=0;this.parsingMdat=null;this.moovStartFound=false;this.samplesDataSize=0;this.nextParsePosition=0};t.exports=s;s.prototype.mergeNextBuffer=function(){var e;if(this.stream.bufferIndex+1<this.stream.nextBuffers.length){e=this.stream.nextBuffers[this.stream.bufferIndex+1];if(e.fileStart===this.stream.buffer.fileStart+this.stream.buffer.byteLength){var t=this.stream.buffer.byteLength;var r=this.stream.buffer.usedBytes;var i=this.stream.buffer.fileStart;this.stream.nextBuffers[this.stream.bufferIndex]=ArrayBuffer.concat(this.stream.buffer,e);this.stream.buffer=this.stream.nextBuffers[this.stream.bufferIndex];this.stream.nextBuffers.splice(this.stream.bufferIndex+1,1);this.stream.buffer.usedBytes=r;this.stream.buffer.fileStart=i;a.d("ISOFile","Concatenating buffer for box parsing (length: "+t+"->"+this.stream.buffer.byteLength+")");return true}else{return false}}else{return false}};s.prototype.parse=function(){var e;var t;var r;a.d("ISOFile","Starting parsing with buffer #"+this.stream.bufferIndex+" (fileStart: "+this.stream.buffer.fileStart+" - Length: "+this.stream.buffer.byteLength+") from position "+this.lastBoxStartPosition+" ("+(this.stream.buffer.fileStart+this.lastBoxStartPosition)+" in the file)");this.stream.seek(this.lastBoxStartPosition);while(true){if(this.parsingMdat!==null){r=this.parsingMdat;e=this.reposition(false,r.fileStart+r.hdr_size+r.size);if(e){a.d("ISOFile","Found 'mdat' end in buffer #"+this.stream.bufferIndex);this.parsingMdat=null;continue}else{this.nextParsePosition=this.findEndContiguousBuf(this.stream.bufferIndex);return}}else{this.lastBoxStartPosition=this.stream.position;t=i.parseOneBox(this.stream);if(t.code===i.ERR_NOT_ENOUGH_DATA){if(t.type==="mdat"){r=new i[t.type+"Box"](t.size-t.hdr_size);this.parsingMdat=r;this.mdats.push(r);r.fileStart=this.stream.buffer.fileStart+this.stream.position;r.hdr_size=t.hdr_size;this.stream.buffer.usedBytes+=t.hdr_size;e=this.reposition(false,r.fileStart+r.hdr_size+r.size);if(e){this.parsingMdat=null;continue}else{if(!this.moovStartFound){this.nextParsePosition=r.fileStart+r.size+r.hdr_size}else{this.nextParsePosition=this.findEndContiguousBuf(this.stream.bufferIndex)}return}}else{if(t.type==="moov"){this.moovStartFound=true;if(this.mdats.length===0){this.isProgressive=true}}else if(t.type==="free"){e=this.reposition(false,this.stream.buffer.fileStart+this.stream.position+t.size);if(e){continue}else{this.nextParsePosition=this.stream.buffer.fileStart+this.stream.position+t.size;return}}merged=this.mergeNextBuffer();if(merged){this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength;continue}else{if(!t.type){this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength}else{if(this.moovStartFound){this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength}else{this.nextParsePosition=this.stream.buffer.fileStart+this.stream.position+t.size}}return}}}else{r=t.box;this.boxes.push(r);switch(r.type){case"mdat":this.mdats.push(r);r.fileStart=this.stream.buffer.fileStart+r.start;break;case"moof":this.moofs.push(r);break;case"moov":this.moovStartFound=true;if(this.mdats.length===0){this.isProgressive=true}default:if(this[r.type]!==undefined){a.w("ISOFile","Duplicate Box of type: "+r.type+", overriding previous occurrence")}this[r.type]=r;break}if(r.type==="mdat"){this.stream.buffer.usedBytes+=r.hdr_size}else{this.stream.buffer.usedBytes+=t.size}}}}};s.prototype.reposition=function(e,t){var r;r=this.findPosition(e,t);if(r!==-1){this.stream.buffer=this.stream.nextBuffers[r];this.stream.bufferIndex=r;this.stream.position=t-this.stream.buffer.fileStart;a.d("ISOFile","Repositioning parser at buffer position: "+this.stream.position);return true}else{return false}};s.prototype.findPosition=function(e,t){var r;var i=null;var n=-1;if(e===true){r=0}else{r=this.stream.bufferIndex}while(r<this.stream.nextBuffers.length){i=this.stream.nextBuffers[r];if(i.fileStart<=t){n=r}else{break}r++}if(n!==-1){i=this.stream.nextBuffers[n];if(i.fileStart+i.byteLength>=t){a.d("ISOFile","Found position in existing buffer #"+n);return n}else{return-1}}else{return-1}};s.prototype.findEndContiguousBuf=function(e){var t;var r;var i;r=this.stream.nextBuffers[e];if(this.stream.nextBuffers.length>e+1){for(t=e+1;t<this.stream.nextBuffers.length;t++){i=this.stream.nextBuffers[t];if(i.fileStart===r.fileStart+r.byteLength){r=i}else{break}}}return r.fileStart+r.byteLength;
-};s.prototype.write=function(e){for(var t=0;t<this.boxes.length;t++){this.boxes[t].write(e)}};s.prototype.writeInitializationSegment=function(e){var t;var r;var n;var s;var o;a.d("ISOFile","Generating initialization segment");this.ftyp.write(e);if(this.moov.mvex){this.initial_duration=this.moov.mvex.mehd.fragment_duration;r=-1;for(t=0;t<this.moov.boxes.length;t++){o=this.moov.boxes[t];if(o===this.moov.mvex){r=t}}if(r>-1){this.moov.boxes.splice(r,1)}this.moov.mvex=null}this.moov.mvex=new i.mvexBox;this.moov.boxes.push(this.moov.mvex);this.moov.mvex.mehd=new i.mehdBox;this.moov.mvex.boxes.push(this.moov.mvex.mehd);this.moov.mvex.mehd.fragment_duration=this.initial_duration;for(t=0;t<this.moov.traks.length;t++){if(this.moov.traks[t].ignore)continue;s=new i.trexBox;this.moov.mvex.boxes.push(s);s.track_id=this.moov.traks[t].tkhd.track_id;s.default_sample_description_index=1;s.default_sample_duration=this.moov.traks[t].samples.length>0?this.moov.traks[t].samples[0].duration:0;s.default_sample_size=0;s.default_sample_flags=1<<16}this.moov.write(e)};s.prototype.resetTables=function(){var e;var t,r,i,n,a,s,o,f;this.initial_duration=this.moov.mvhd.duration;this.moov.mvhd.duration=0;for(e=0;e<this.moov.traks.length;e++){t=this.moov.traks[e];t.tkhd.duration=0;t.mdia.mdhd.duration=0;r=t.mdia.minf.stbl.stco||t.mdia.minf.stbl.co64;r.chunk_offsets=[];i=t.mdia.minf.stbl.stsc;i.first_chunk=[];i.samples_per_chunk=[];i.sample_description_index=[];n=t.mdia.minf.stbl.stsz;n.sample_sizes=[];a=t.mdia.minf.stbl.stts;a.sample_counts=[];a.sample_deltas=[];s=t.mdia.minf.stbl.ctts;if(s){s.sample_counts=[];s.sample_offsets=[]}o=t.mdia.minf.stbl.stss;if(o){o.sample_numbers=new Uint32Array(0)}f=t.mdia.minf.stbl.sdtp;var u=t.mdia.minf.stbl.boxes.indexOf(f);if(u!=-1)t.mdia.minf.stbl.boxes[u]=null}};s.prototype.buildSampleLists=function(){var e,t,r;var i,n,a,s,o,f,u,l,c;var p,d,h,m,v;var g,y,_,b,w,x;this.originalMvex=this.moov.mvex;for(e=0;e<this.moov.traks.length;e++){i=this.moov.traks[e];i.samples=[];n=i.mdia.minf.stbl.stco||i.mdia.minf.stbl.co64;a=i.mdia.minf.stbl.stsc;s=i.mdia.minf.stbl.stsz;o=i.mdia.minf.stbl.stts;f=i.mdia.minf.stbl.ctts;u=i.mdia.minf.stbl.stss;l=i.mdia.minf.stbl.stsd;c=i.mdia.minf.stbl.subs;g=-1;y=-1;_=-1;b=-1;w=0;subs_entry_index=0;last_subs_sample_index=0;for(t=0;t<s.sample_sizes.length;t++){var k={};k.number=t;k.track_id=i.tkhd.track_id;k.timescale=i.mdia.mdhd.timescale;i.samples[t]=k;k.size=s.sample_sizes[t];if(t===0){d=1;p=0;k.chunk_index=d;k.chunk_run_index=p;v=a.samples_per_chunk[p];m=0;if(p+1<a.first_chunk.length){h=a.first_chunk[p+1]-1}else{h=Infinity}}else{if(t<v){k.chunk_index=d;k.chunk_run_index=p}else{d++;k.chunk_index=d;m=0;if(d<=h){}else{p++;if(p+1<a.first_chunk.length){h=a.first_chunk[p+1]-1}else{h=Infinity}}k.chunk_run_index=p;v+=a.samples_per_chunk[p]}}k.description=l.entries[a.sample_description_index[k.chunk_run_index]-1];k.offset=n.chunk_offsets[k.chunk_index-1]+m;m+=k.size;if(t>g){y++;if(g<0){g=0}g+=o.sample_counts[y]}if(t>0){i.samples[t-1].duration=o.sample_deltas[y];k.dts=i.samples[t-1].dts+i.samples[t-1].duration}else{k.dts=0}if(f){if(t>_){b++;_+=f.sample_counts[b]}k.cts=i.samples[t].dts+f.sample_offsets[b]}else{k.cts=k.dts}if(u){if(t==u.sample_numbers[w]-1){k.is_rap=true;w++}else{k.is_rap=false}}else{k.is_rap=true}if(c){if(c.samples[subs_entry_index].sample_delta+last_subs_sample_index==t){k.subsamples=c.samples[subs_entry_index].subsamples;last_subs_sample_index+=c.samples[subs_entry_index].sample_delta}}}if(t>0)i.samples[t-1].duration=i.mdia.mdhd.duration-i.samples[t-1].dts}};s.prototype.updateSampleLists=function(){var e,t,r;var n,a,s,o;var f;var u,l,c,p,d;var h;while(this.lastMoofIndex<this.moofs.length){u=this.moofs[this.lastMoofIndex];this.lastMoofIndex++;if(u.type=="moof"){l=u;for(e=0;e<l.trafs.length;e++){c=l.trafs[e];p=this.getTrackById(c.tfhd.track_id);d=this.getTrexById(c.tfhd.track_id);if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_DESC){n=c.tfhd.default_sample_description_index}else{n=d.default_sample_description_index}if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_DUR){a=c.tfhd.default_sample_duration}else{a=d.default_sample_duration}if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_SIZE){s=c.tfhd.default_sample_size}else{s=d.default_sample_size}if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_FLAGS){o=c.tfhd.default_sample_flags}else{o=d.default_sample_flags}for(t=0;t<c.truns.length;t++){var m=c.truns[t];for(r=0;r<m.sample_count;r++){h={};c.first_sample_index=p.samples.length;p.samples.push(h);h.track_id=p.tkhd.track_id;h.timescale=p.mdia.mdhd.timescale;h.description=p.mdia.minf.stbl.stsd.entries[n-1];h.size=s;if(m.flags&i.TRUN_FLAGS_SIZE){h.size=m.sample_size[r]}h.duration=a;if(m.flags&i.TRUN_FLAGS_DURATION){h.duration=m.sample_duration[r]}if(p.first_traf_merged||r>0){h.dts=p.samples[p.samples.length-2].dts+p.samples[p.samples.length-2].duration}else{if(c.tfdt){h.dts=c.tfdt.baseMediaDecodeTime}else{h.dts=0}p.first_traf_merged=true}h.cts=h.dts;if(m.flags&i.TRUN_FLAGS_CTS_OFFSET){h.cts=h.dts+m.sample_composition_time_offset[r]}sample_flags=o;if(m.flags&i.TRUN_FLAGS_FLAGS){sample_flags=m.sample_flags[r]}else if(r===0&&m.flags&i.TRUN_FLAGS_FIRST_FLAG){sample_flags=m.first_sample_flags}h.is_rap=sample_flags>>16&1?false:true;var v=c.tfhd.flags&i.TFHD_FLAG_BASE_DATA_OFFSET?true:false;var g=c.tfhd.flags&i.TFHD_FLAG_DEFAULT_BASE_IS_MOOF?true:false;var y=m.flags&i.TRUN_FLAGS_DATA_OFFSET?true:false;var _=0;if(!v){if(!g){if(t===0){_=l.fileStart}else{_=f}}else{_=l.fileStart}}else{_=c.tfhd.base_data_offset}if(t===0&&r===0){if(y){h.offset=_+m.data_offset}else{h.offset=_}}else{h.offset=f}f=h.offset+h.size}}if(c.subs){var b=c.first_sample_index;for(t=0;t<c.subs.samples.length;t++){b+=c.subs.samples[t].sample_delta;h=p.samples[b-1];h.subsamples=c.subs.samples[t].subsamples}}}}}};s.prototype.getCodecs=function(){var e;var t="";for(e=0;e<this.moov.traks.length;e++){var r=this.moov.traks[e];if(e>0){t+=","}t+=r.mdia.minf.stbl.stsd.entries[0].getCodec()}return t};s.prototype.getTrexById=function(e){var t;if(!this.originalMvex)return null;for(t=0;t<this.originalMvex.trexs.length;t++){var r=this.originalMvex.trexs[t];if(r.track_id==e)return r}return null};s.prototype.getTrackById=function(e){for(var t=0;t<this.moov.traks.length;t++){var r=this.moov.traks[t];if(r.tkhd.track_id==e)return r}return null};s.prototype.getSample=function(e,t){var r;var i;var s=e.samples[t];if(!this.moov){return null}if(!s.data){s.data=new Uint8Array(s.size);s.alreadyRead=0;this.samplesDataSize+=s.size;a.d("ISOFile","Allocating sample #"+t+" on track #"+e.tkhd.track_id+" of size "+s.size+" (total: "+this.samplesDataSize+")")}else if(s.alreadyRead==s.size){return s}for(i=0;i<this.stream.nextBuffers.length;i++){r=this.stream.nextBuffers[i];if(s.offset+s.alreadyRead>=r.fileStart&&s.offset+s.alreadyRead<r.fileStart+r.byteLength){var o=r.byteLength-(s.offset+s.alreadyRead-r.fileStart);if(s.size-s.alreadyRead<=o){a.d("ISOFile","Getting sample #"+t+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-r.fileStart)+" size: "+(s.size-s.alreadyRead)+")");n.memcpy(s.data.buffer,s.alreadyRead,r,s.offset+s.alreadyRead-r.fileStart,s.size-s.alreadyRead);s.alreadyRead=s.size;r.usedBytes+=s.size-s.alreadyRead;if(r.usedBytes===r.byteLength){this.stream.nextBuffers.splice(i,1);i--}return s}else{a.d("ISOFile","Getting sample data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-r.fileStart)+" size: "+o+")");n.memcpy(s.data.buffer,s.alreadyRead,r,s.offset+s.alreadyRead-r.fileStart,o);s.alreadyRead+=o;r.usedBytes+=o;if(r.usedBytes===r.byteLength){this.stream.nextBuffers.splice(i,1);i--}}}}return null};s.prototype.releaseSample=function(e,t){var r=e.samples[t];r.data=null;this.samplesDataSize-=r.size;return r.size}},{"./DataStream":174,"./box":175,"./log":178}],178:[function(e,t,r){var i=function(){var e=new Date;var t=4;var r=3;var n=2;var a=1;var s=t;var o={setLogLevel:function(e){if(e==this.d)s=a;else if(e==this.i)s=n;else if(e==this.w)s=r;else if(e==this.e)s=t;else s=t},d:function(t,r){if(a>=s){console.debug("["+i.getDurationString(new Date-e,1e3)+"]","["+t+"]",r)}},i:function(t,r){if(n>=s){console.info("["+i.getDurationString(new Date-e,1e3)+"]","["+t+"]",r)}},w:function(t,n){if(r>=s){console.warn("["+i.getDurationString(new Date-e,1e3)+"]","["+t+"]",n)}},e:function(r,n){if(t>=s){console.error("["+i.getDurationString(new Date-e,1e3)+"]","["+r+"]",n)}}};return o}();t.exports=i;i.getDurationString=function(e,t){function r(e,t){var r=""+e;var i=r.split(".");while(i[0].length<t){i[0]="0"+i[0]}return i.join(".")}var i=t||1;var n=e/i;var a=Math.floor(n/3600);n-=a*3600;var s=Math.floor(n/60);n-=s*60;var o=n*1e3;n=Math.floor(n);o-=n*1e3;o=Math.floor(o);return""+a+":"+r(s,2)+":"+r(n,2)+"."+r(o,3)};i.printRanges=function(e){var t=e.length;if(t>0){var r="";for(var n=0;n<t;n++){if(n>0)r+=",";r+="["+i.getDurationString(e.start(n))+","+i.getDurationString(e.end(n))+"]"}return r}else{return"(empty)"}}},{}],179:[function(e,t,r){var n=e("./box");var a=e("./DataStream");var s=e("./isofile");var o=e("./log");var f=function(){this.inputStream=null;this.nextBuffers=[];this.inputIsoFile=null;this.onMoovStart=null;this.moovStartSent=false;this.onReady=null;this.readySent=false;this.onSegment=null;this.onSamples=null;this.onError=null;this.sampleListBuilt=false;this.fragmentedTracks=[];this.extractedTracks=[];this.isFragmentationStarted=false;this.nextMoofNumber=0};t.exports=f;f.prototype.setSegmentOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.fragmentedTracks.push(n);n.id=e;n.user=t;n.trak=i;i.nextSample=0;n.segmentStream=null;n.nb_samples=1e3;n.rapAlignement=true;if(r){if(r.nbSamples)n.nb_samples=r.nbSamples;if(r.rapAlignement)n.rapAlignement=r.rapAlignement}}};f.prototype.unsetSegmentOptions=function(e){var t=-1;for(var r=0;r<this.fragmentedTracks.length;r++){var i=this.fragmentedTracks[r];if(i.id==e){t=r}}if(t>-1){this.fragmentedTracks.splice(t,1)}};f.prototype.setExtractionOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.extractedTracks.push(n);n.id=e;n.user=t;n.trak=i;i.nextSample=0;n.nb_samples=1e3;n.samples=[];if(r){if(r.nbSamples)n.nb_samples=r.nbSamples}}};f.prototype.unsetExtractionOptions=function(e){var t=-1;for(var r=0;r<this.extractedTracks.length;r++){var i=this.extractedTracks[r];if(i.id==e){t=r}}if(t>-1){this.extractedTracks.splice(t,1)}};f.prototype.createSingleSampleMoof=function(e){var t=new n.moofBox;var r=new n.mfhdBox;r.sequence_number=this.nextMoofNumber;this.nextMoofNumber++;t.boxes.push(r);var i=new n.trafBox;t.boxes.push(i);var a=new n.tfhdBox;i.boxes.push(a);a.track_id=e.track_id;a.flags=n.TFHD_FLAG_DEFAULT_BASE_IS_MOOF;var s=new n.tfdtBox;i.boxes.push(s);s.baseMediaDecodeTime=e.dts;var o=new n.trunBox;i.boxes.push(o);t.trun=o;o.flags=n.TRUN_FLAGS_DATA_OFFSET|n.TRUN_FLAGS_DURATION|n.TRUN_FLAGS_SIZE|n.TRUN_FLAGS_FLAGS|n.TRUN_FLAGS_CTS_OFFSET;o.data_offset=0;o.first_sample_flags=0;o.sample_count=1;o.sample_duration=[];o.sample_duration[0]=e.duration;o.sample_size=[];o.sample_size[0]=e.size;o.sample_flags=[];o.sample_flags[0]=0;o.sample_composition_time_offset=[];o.sample_composition_time_offset[0]=e.cts-e.dts;return t};f.prototype.createFragment=function(e,t,r,i){var s=this.inputIsoFile.getTrackById(t);var f=this.inputIsoFile.getSample(s,r);if(f==null){if(this.nextSeekPosition){this.nextSeekPosition=Math.min(s.samples[r].offset,this.nextSeekPosition)}else{this.nextSeekPosition=s.samples[r].offset}return null}var u=i||new a;u.endianness=a.BIG_ENDIAN;var l=this.createSingleSampleMoof(f);l.write(u);l.trun.data_offset=l.size+8;o.d("BoxWriter","Adjusting data_offset with new value "+l.trun.data_offset);u.adjustUint32(l.trun.data_offset_position,l.trun.data_offset);var c=new n.mdatBox;c.data=f.data;c.write(u);return u};ArrayBuffer.concat=function(e,t){o.d("ArrayBuffer","Trying to create a new buffer of size: "+(e.byteLength+t.byteLength));var r=new Uint8Array(e.byteLength+t.byteLength);r.set(new Uint8Array(e),0);r.set(new Uint8Array(t),e.byteLength);return r.buffer};f.prototype.reduceBuffer=function(e,t,r){var i;i=new Uint8Array(r);i.set(new Uint8Array(e,t,r));i.buffer.fileStart=e.fileStart+t;i.buffer.usedBytes=0;return i.buffer};f.prototype.insertBuffer=function(e){var t=true;for(var r=0;r<this.nextBuffers.length;r++){var i=this.nextBuffers[r];if(e.fileStart<=i.fileStart){if(e.fileStart===i.fileStart){if(e.byteLength>i.byteLength){this.nextBuffers.splice(r,1);r--;continue}else{o.w("MP4Box","Buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+") already appended, ignoring")}}else{if(e.fileStart+e.byteLength<=i.fileStart){}else{e=this.reduceBuffer(e,0,i.fileStart-e.fileStart)}o.d("MP4Box","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")");this.nextBuffers.splice(r,0,e);if(r===0&&this.inputStream!==null){this.inputStream.buffer=e}}t=false;break}else if(e.fileStart<i.fileStart+i.byteLength){var n=i.fileStart+i.byteLength-e.fileStart;var a=e.byteLength-n;if(a>0){e=this.reduceBuffer(e,n,a)}else{t=false;break}}}if(t){o.d("MP4Box","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")");this.nextBuffers.push(e);if(r===0&&this.inputStream!==null){this.inputStream.buffer=e}}};f.prototype.processSamples=function(){var e;var t;if(this.isFragmentationStarted&&this.onSegment!==null){for(e=0;e<this.fragmentedTracks.length;e++){var r=this.fragmentedTracks[e];t=r.trak;while(t.nextSample<t.samples.length){o.d("MP4Box","Creating media fragment on track #"+r.id+" for sample "+t.nextSample);var i=this.createFragment(this.inputIsoFile,r.id,t.nextSample,r.segmentStream);if(i){r.segmentStream=i;t.nextSample++}else{break}if(t.nextSample%r.nb_samples===0||t.nextSample>=t.samples.length){o.i("MP4Box","Sending fragmented data on track #"+r.id+" for samples ["+(t.nextSample-r.nb_samples)+","+(t.nextSample-1)+"]");if(this.onSegment){this.onSegment(r.id,r.user,r.segmentStream.buffer,t.nextSample)}r.segmentStream=null;if(r!==this.fragmentedTracks[e]){break}}}}}if(this.onSamples!==null){for(e=0;e<this.extractedTracks.length;e++){var n=this.extractedTracks[e];t=n.trak;while(t.nextSample<t.samples.length){o.d("MP4Box","Exporting on track #"+n.id+" sample #"+t.nextSample);var a=this.inputIsoFile.getSample(t,t.nextSample);if(a){t.nextSample++;n.samples.push(a)}else{return}if(t.nextSample%n.nb_samples===0||t.nextSample>=t.samples.length){o.d("MP4Box","Sending samples on track #"+n.id+" for sample "+t.nextSample);if(this.onSamples){this.onSamples(n.id,n.user,n.samples)}n.samples=[];if(n!==this.extractedTracks[e]){break}}}}}};f.prototype.appendBuffer=function(e){var t;var r;if(e===null||e===undefined){throw"Buffer must be defined and non empty"}if(e.fileStart===undefined){throw"Buffer must have a fileStart property"}if(e.byteLength===0){o.w("MP4Box","Ignoring empty buffer (fileStart: "+e.fileStart+")");return}e.usedBytes=0;this.insertBuffer(e);if(!this.inputStream){if(this.nextBuffers.length>0){r=this.nextBuffers[0];if(r.fileStart===0){this.inputStream=new a(r,0,a.BIG_ENDIAN);this.inputStream.nextBuffers=this.nextBuffers;this.inputStream.bufferIndex=0}else{o.w("MP4Box","The first buffer should have a fileStart of 0");return}}else{o.w("MP4Box","No buffer to start parsing from");return}}if(!this.inputIsoFile){this.inputIsoFile=new s(this.inputStream)}this.inputIsoFile.parse();if(this.inputIsoFile.moovStartFound&&!this.moovStartSent){this.moovStartSent=true;if(this.onMoovStart)this.onMoovStart()}if(this.inputIsoFile.moov){if(!this.sampleListBuilt){this.inputIsoFile.buildSampleLists();this.sampleListBuilt=true}this.inputIsoFile.updateSampleLists();if(this.onReady&&!this.readySent){var i=this.getInfo();this.readySent=true;this.onReady(i)}this.processSamples();if(this.nextSeekPosition){t=this.nextSeekPosition;this.nextSeekPosition=undefined}else{t=this.inputIsoFile.nextParsePosition}var n=this.inputIsoFile.findPosition(true,t);if(n!==-1){t=this.inputIsoFile.findEndContiguousBuf(n)}o.i("MP4Box","Next buffer to fetch should have a fileStart position of "+t);return t}else{if(this.inputIsoFile!==null){return this.inputIsoFile.nextParsePosition}else{return 0}}};f.prototype.getInfo=function(){var e={};var t;var r;var n;var a=new Date(4,0,1,0,0,0,0).getTime();e.duration=this.inputIsoFile.moov.mvhd.duration;e.timescale=this.inputIsoFile.moov.mvhd.timescale;e.isFragmented=this.inputIsoFile.moov.mvex!=null;if(e.isFragmented&&this.inputIsoFile.moov.mvex.mehd){e.fragment_duration=this.inputIsoFile.moov.mvex.mehd.fragment_duration}else{e.fragment_duration=0}e.isProgressive=this.inputIsoFile.isProgressive;e.hasIOD=this.inputIsoFile.moov.iods!=null;e.brands=[];e.brands.push(this.inputIsoFile.ftyp.major_brand);e.brands=e.brands.concat(this.inputIsoFile.ftyp.compatible_brands);e.created=new Date(a+this.inputIsoFile.moov.mvhd.creation_time*1e3);e.modified=new Date(a+this.inputIsoFile.moov.mvhd.modification_time*1e3);e.tracks=[];e.audioTracks=[];e.videoTracks=[];e.subtitleTracks=[];e.metadataTracks=[];e.hintTracks=[];e.otherTracks=[];for(i=0;i<this.inputIsoFile.moov.traks.length;i++){t=this.inputIsoFile.moov.traks[i];n=t.mdia.minf.stbl.stsd.entries[0];r={};e.tracks.push(r);r.id=t.tkhd.track_id;r.references=[];if(t.tref){for(j=0;j<t.tref.boxes.length;j++){ref={};r.references.push(ref);ref.type=t.tref.boxes[j].type;ref.track_ids=t.tref.boxes[j].track_ids}}r.created=new Date(a+t.tkhd.creation_time*1e3);r.modified=new Date(a+t.tkhd.modification_time*1e3);r.movie_duration=t.tkhd.duration;r.layer=t.tkhd.layer;r.alternate_group=t.tkhd.alternate_group;r.volume=t.tkhd.volume;r.matrix=t.tkhd.matrix;r.track_width=t.tkhd.width/(1<<16);r.track_height=t.tkhd.height/(1<<16);r.timescale=t.mdia.mdhd.timescale;r.duration=t.mdia.mdhd.duration;r.codec=n.getCodec();r.language=t.mdia.mdhd.languageString;r.nb_samples=t.samples.length;r.size=0;for(j=0;j<r.nb_samples;j++){r.size+=t.samples[j].size}r.bitrate=r.size*8*r.timescale/r.duration;if(n.isAudio()){e.audioTracks.push(r);r.audio={};r.audio.sample_rate=n.getSampleRate();r.audio.channel_count=n.getChannelCount();r.audio.sample_size=n.getSampleSize()}else if(n.isVideo()){e.videoTracks.push(r);r.video={};r.video.width=n.getWidth();r.video.height=n.getHeight()}else if(n.isSubtitle()){e.subtitleTracks.push(r)}else if(n.isHint()){e.hintTracks.push(r)}else if(n.isMetadata()){e.metadataTracks.push(r)}else{e.otherTracks.push(r)}}return e};f.prototype.getInitializationSegment=function(){var e=new a;e.endianness=a.BIG_ENDIAN;this.inputIsoFile.writeInitializationSegment(e);return e.buffer};f.prototype.writeFile=function(){var e=new a;e.endianness=a.BIG_ENDIAN;this.inputIsoFile.write(e);return e.buffer};f.prototype.initializeSegmentation=function(){var e;var t;var r;var i;var n;if(this.onSegment===null){o.w("MP4Box","No segmentation callback set!")}if(!this.isFragmentationStarted){this.isFragmentationStarted=true;this.nextMoofNumber=0;this.inputIsoFile.resetTables()}i=[];for(e=0;e<this.fragmentedTracks.length;e++){for(t=0;t<this.inputIsoFile.moov.boxes.length;t++){r=this.inputIsoFile.moov.boxes[t];if(r&&r.type==="trak"){this.inputIsoFile.moov.boxes[t].ignore=true;this.inputIsoFile.moov.boxes[t]=null}}n=this.inputIsoFile.getTrackById(this.fragmentedTracks[e].id);delete n.ignore;for(t=0;t<this.inputIsoFile.moov.boxes.length;t++){r=this.inputIsoFile.moov.boxes[t];if(r==null){this.inputIsoFile.moov.boxes[t]=n;break}}seg={};seg.id=n.tkhd.track_id;seg.user=this.fragmentedTracks[e].user;seg.buffer=this.getInitializationSegment();i.push(seg)}return i};f.prototype.releaseUsedSamples=function(e,t){var r=0;var i=this.inputIsoFile.getTrackById(e);if(!i.lastValidSample)i.lastValidSample=0;for(var n=i.lastValidSample;n<t;n++){r+=this.inputIsoFile.releaseSample(i,n)}o.d("MP4Box","Track #"+e+" released samples up to "+t+" (total size: "+r+", remaining: "+this.inputIsoFile.samplesDataSize+")");i.lastValidSample=t};f.prototype.flush=function(){o.i("MP4Box","Flushing remaining samples");this.inputIsoFile.updateSampleLists();this.processSamples()};f.prototype.seekTrack=function(e,t,r){var i;var n;var a=Infinity;var s=0;var f=Infinity;var u=0;var l=0;var c;for(i=0;i<r.samples.length;i++){n=r.samples[i];if(i===0){f=n.offset;l=0;c=n.timescale}else if(n.cts>e*n.timescale){f=r.samples[i-1].offset;l=i-1;break}if(t&&n.is_rap){a=n.offset;s=n.cts;u=i}}if(t){r.nextSample=u;o.i("MP4Box","Seeking to RAP sample #"+r.nextSample+" on track "+r.tkhd.track_id+", time "+o.getDurationString(s,c)+" and offset: "+a);return{offset:a,time:s/c}}else{r.nextSample=l;o.i("MP4Box","Seeking to non-RAP sample #"+r.nextSample+" on track "+r.tkhd.track_id+", time "+o.getDurationString(e)+" and offset: "+a);return{offset:f,time:e}}};f.prototype.seek=function(e,t){var r=this.inputIsoFile.moov;var i;var n;var a;var s={offset:Infinity,time:Infinity};if(!this.inputIsoFile.moov){throw"Cannot seek: moov not received!"}else{for(a=0;a<r.traks.length;a++){i=r.traks[a];n=this.seekTrack(e,t,i);if(n.offset<s.offset){s.offset=n.offset}if(n.time<s.time){s.time=n.time}}if(s.offset===Infinity){s={offset:this.inputIsoFile.nextParsePosition,time:0}}else{var f=this.inputIsoFile.findPosition(true,s.offset);if(f!==-1){s.offset=this.inputIsoFile.findEndContiguousBuf(f)}}o.i("MP4Box","Seeking at time "+o.getDurationString(s.time,1)+" needs a buffer with a fileStart position of "+s.offset);return s}}},{"./DataStream":174,"./box":175,"./isofile":177,"./log":178}],180:[function(e,t,r){var i=e("debug")("videostream");var n=e("mp4box");var a=.01;var s=60;t.exports=function(e,t,r){r=r||{};var f=r.debugTrack||-1;var u=[];function l(){t.addEventListener("waiting",x);t.addEventListener("timeupdate",E)}l();var c=false;function p(e){c=true;t.removeEventListener("waiting",x);t.removeEventListener("timeupdate",E);if(h.readyState==="open")h.endOfStream(e)}function d(e){var r=e.buffer.buffered;var n=t.currentTime;var o=-1;for(var f=0;f<r.length;f++){var u=r.start(f);var l=r.end(f)+a;if(u>n){break}else if(o>=0||n<=l){o=l}}var c=o-n;if(c<0)c=0;i("Buffer length: %f",c);return c<=s}var h=new MediaSource;h.addEventListener("sourceopen",function(){w(0)});t.src=window.URL.createObjectURL(h);var m=new n;m.onError=function(e){i("MP4Box error: %s",e.message);if(b){b()}if(h.readyState==="open"){p("decode")}};var v=false;var g={};m.onReady=function(e){i("MP4 info: %o",e);e.tracks.forEach(function(e){var t;if(e.video){t="video/mp4"}else if(e.audio){t="audio/mp4"}else{return}t+='; codecs="'+e.codec+'"';if(MediaSource.isTypeSupported(t)){var r=h.addSourceBuffer(t);var i={buffer:r,arrayBuffers:[],meta:e,ended:false};r.addEventListener("updateend",A.bind(null,i));m.setSegmentOptions(e.id,null,{nbSamples:e.video?1:100});g[e.id]=i}});if(Object.keys(g).length===0){p("decode");return}var t=m.initializeSegmentation();t.forEach(function(e){S(g[e.id],e.buffer);if(e.id===f){o("init-track-"+f+".mp4",[e.buffer]);u.push(e.buffer)}});v=true};m.onSegment=function(e,t,r,i){var n=g[e];S(n,r,i===n.meta.nb_samples);if(e===f&&u){u.push(r);if(i>1e3){o("track-"+f+".mp4",u);u=null}}};var y;var _=null;var b=null;function w(t){if(t===e.length){m.flush();return}if(_&&t===y){var r=_;setTimeout(function(){if(_===r)_.resume()});return}if(_){_.destroy();b()}y=t;var n={start:y,end:e.length-1};_=e.createReadStream(n);function a(e){_.pause();var t=e.toArrayBuffer();t.fileStart=y;y+=t.byteLength;var r;try{r=m.appendBuffer(t)}catch(n){i("MP4Box threw exception: %s",n.message);if(h.readyState==="open"){p("decode")}_.destroy();b();return}w(r)}_.on("data",a);function s(){b();w(y)}_.on("end",s);function o(e){i("Stream error: %s",e.message);if(h.readyState==="open"){p("network")}}_.on("error",o);b=function(){_.removeListener("data",a);_.removeListener("end",s);_.removeListener("error",o);_=null;b=null}}function x(){if(v){k(t.currentTime)}}function k(e){if(c)l();var t=m.seek(e,true);i("Seeking to time: %d",e);i("Seeked file offset: %d",t.offset);w(t.offset)}function S(e,t,r){e.arrayBuffers.push({buffer:t,ended:r||false});A(e)}function E(){Object.keys(g).forEach(function(e){var t=g[e];if(t.blocked){A(t)}})}function A(e){if(e.buffer.updating)return;e.blocked=!d(e);if(e.blocked)return;if(e.arrayBuffers.length===0)return;var t=e.arrayBuffers.shift();var r=false;try{e.buffer.appendBuffer(t.buffer);e.ended=t.ended;r=true}catch(n){i("SourceBuffer error: %s",n.message);p("decode");return}if(r){U()}}function U(){if(h.readyState!=="open"){return}var e=Object.keys(g).every(function(e){var t=g[e];return t.ended&&!t.buffer.updating});if(e){p()}}};function o(e,t){var r=new Blob(t);var i=URL.createObjectURL(r);var n=document.createElement("a");n.setAttribute("href",i);n.setAttribute("download",e);n.click()}},{debug:121,mp4box:179}],181:[function(e,t,r){t.exports=i;function i(){var e={};for(var t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r){if(r.hasOwnProperty(i)){e[i]=r[i]}}}return e}},{}],182:[function(e,t,r){t.exports=i;function i(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r){if(r.hasOwnProperty(i)){e[i]=r[i]}}}return e}},{}],183:[function(e,t,r){t.exports=function i(e,t,r){if(t===undefined){return function(t,r){return i(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+""}},{}],184:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.58.0",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/server":false,"bittorrent-dht/client":false,"fs-chunk-store":"memory-chunk-store","load-ip-set":false,ut_pex:false},bugs:{url:"https://github.com/feross/webtorrent/issues"},dependencies:{"addr-to-ip-port":"^1.0.1",bitfield:"^1.0.2","bittorrent-dht":"^3.0.0","bittorrent-swarm":"^5.0.0","chunk-store-stream":"^2.0.0",clivas:"^0.2.0","create-torrent":"^3.4.0",debug:"^2.1.0","end-of-stream":"^1.0.0",executable:"^1.1.0","fs-chunk-store":"^1.3.4",hat:"0.0.3","immediate-chunk-store":"^1.0.7",inherits:"^2.0.1",inquirer:"^0.9.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":"^1.0.0","pretty-bytes":"^2.0.1",pump:"^1.0.0","random-iterate":"^1.0.1","range-parser":"^1.0.2","re-emitter":"^1.0.0","run-parallel":"^1.0.0","simple-sha1":"^2.0.0",speedometer:"^0.1.2",thunky:"^0.1.0","torrent-discovery":"^3.0.0","torrent-piece":"^1.0.0",uniq:"^1.0.1",ut_metadata:"^2.1.0",ut_pex:"^1.0.1",videostream:"^1.1.4","windows-no-runnable":"0.0.6",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^6.0.0",brfs:"^1.2.0",browserify:"^11.0.0",finalhandler:"^0.4.0","run-auto":"^1.0.0","serve-static":"^1.9.3","simple-get":"^1.0.0",standard:"^5.1.0",tape:"^4.0.0","uglify-js":"^2.4.15",zelda:"^2.0.0",zuul:"^3.0.0"},homepage:"http://webtorrent.io",keywords:["torrent","bittorrent","bittorrent client","streaming","download","webrtc","webrtc data","webtorrent","mad science"],license:"MIT",main:"index.js",optionalDependencies:{"airplay-js":"^0.2.3","chromecast-js":"^0.1.4",nodebmc:"0.0.5"},repository:{type:"git",url:"git://github.com/feross/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | uglifyjs -m > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && node ./bin/test.js","test-browser":"zuul -- test/basic.js","test-browser-local":"zuul --local -- test/basic.js","test-node":"tape test/*.js"}}},{}],185:[function(e,t,r){(function(r,i,n){t.exports=w;var a=e("create-torrent");var s=e("debug")("webtorrent");var o=e("bittorrent-dht/client");var f=e("events").EventEmitter;var u=e("xtend");var l=e("hat");var c=e("inherits");var p=e("load-ip-set");var d=e("run-parallel");var h=e("parse-torrent");var m=e("speedometer");var v=e("zero-fill");var g=e("path");var y=e("./lib/torrent");c(w,f);var _=e("./package.json").version;var b=_.match(/([0-9]+)/g).slice(0,2).map(v(2)).join("");function w(e){var t=this;if(!(t instanceof w))return new w(e);if(!e)e={};f.call(t);if(!s.enabled)t.setMaxListeners(0);t.destroyed=false;t.torrentPort=e.torrentPort||0;t.tracker=e.tracker!==undefined?e.tracker:true;t._rtcConfig=e.rtcConfig;t._wrtc=e.wrtc||i.WRTC;t.torrents=[];t.downloadSpeed=m();t.uploadSpeed=m();t.peerId=e.peerId===undefined?new n("-WW"+b+"-"+l(48),"utf8"):typeof e.peerId==="string"?new n(e.peerId,"hex"):e.peerId;t.peerIdHex=t.peerId.toString("hex");t.nodeId=e.nodeId===undefined?new n(l(160),"hex"):typeof e.nodeId==="string"?new n(e.nodeId,"hex"):e.nodeId;t.nodeIdHex=t.nodeId.toString("hex");if(e.dht!==false&&typeof o==="function"){t.dht=new o(u({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}s("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof p==="function"){p(e.blocklist,{headers:{"user-agent":"WebTorrent/"+_+" (http://webtorrent.io)"}},function(e,r){if(e)return t.error("Failed to load blocklist: "+e.message);t.blocked=r;a()})}else r.nextTick(a);function a(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(w.prototype,"ratio",{get:function(){var e=this;var t=e.torrents.reduce(function(e,t){return e+t.uploaded},0);var r=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/r}});w.prototype.get=function(e){var t=this;if(e instanceof y)return e;var r;try{r=h(e)}catch(i){}if(!r)return null;if(!r.infoHash)throw new Error("Invalid torrent identifier");for(var n=0,a=t.torrents.length;n<a;n++){var s=t.torrents[n];if(s.infoHash===r.infoHash)return s}return null};w.prototype.add=w.prototype.download=function(e,t,i){var n=this;if(n.destroyed)throw new Error("client is destroyed");if(typeof t==="function")return n.add(e,null,t);s("add");if(!t)t={};t.client=n;var a=n.get(e);function o(){s("on torrent %s",a.infoHash);if(typeof i==="function")i(a)}if(a){if(a.ready)r.nextTick(o);else a.on("ready",o)}else{a=new y(e,t);n.torrents.push(a);a.on("error",function(e){n.emit("error",e,a);n.remove(a)});a.on("listening",function(e){n.emit("listening",e,a)});a.on("ready",function(){o();n.emit("torrent",a)})}return a};w.prototype.seed=function(e,t,r){var i=this;if(i.destroyed)throw new Error("client is destroyed");if(typeof t==="function")return i.seed(e,null,t);s("seed");if(!t)t={};if(typeof e==="string")t.path=g.dirname(e);if(!t.createdBy)t.createdBy="WebTorrent/"+_;var n;var o=i.add(undefined,t,function(e){var t=[function(t){e.load(n,t)}];if(i.dht){t.push(function(t){e.on("dhtAnnounce",t)})}d(t,function(t){if(t)return i.emit("error",t);f();i.emit("seed",e)})});a.parseInput(e,t,function(r,s){if(r)return i.emit("error",r);n=s.map(function(e){return e.getStream});a(e,t,function(e,t){if(e)return i.emit("error",e);if(i.destroyed)return;var r=i.get(t);if(r){o.destroy();f();return}else{o._onTorrentId(t)}})});function f(){s("on seed");if(typeof r==="function")r(o)}return o};w.prototype.remove=function(e,t){var r=this;s("remove");var i=r.get(e);if(!i)throw new Error("No torrent with id "+e);r.torrents.splice(r.torrents.indexOf(i),1);i.destroy(t)};w.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}};w.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)});d(r,e)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./lib/torrent":8,"./package.json":184,_process:49,"bittorrent-dht/client":39,buffer:40,"create-torrent":91,debug:121,events:44,hat:127,inherits:129,"load-ip-set":39,"parse-torrent":134,path:48,"run-parallel":154,speedometer:165,xtend:181,"zero-fill":183}]},{},[185])(185)});
+(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,o){if(!t[s]){if(!e[s]){var f=typeof require=="function"&&require;if(!o&&f)return f(s,!0);if(a)return a(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=t[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,n,e,t,r)}return t[s].exports}var a=typeof require=="function"&&require;for(var s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t,r){(function(r){var i=e("debug")("webtorrent:append-to");var n=e("mediasource");var a=e("path");var s=e("videostream");var o=[".mp4",".m4v",".m4a"];var f=[".mp4",".m4v",".webm"];var u=[".m4a",".mp3"];var l=f.concat(u);var c=[".wav",".aac",".ogg",".oga"];var p=[".jpg",".jpeg",".png",".gif",".bmp"];var d=[".css",".html",".js",".md",".pdf",".txt"];var h=typeof window!=="undefined"&&window.MediaSource;t.exports=function g(e,t,r){if(!r)r=m;var u;var g=a.extname(e.name).toLowerCase();var y=0;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.")}if(l.indexOf(g)>=0)_();else if(c.indexOf(g)>=0)w();else if(p.indexOf(g)>=0)x();else if(d.indexOf(g)>=0)k();else v(r,new Error('Unsupported file type "'+g+'": Cannot append to DOM'));function _(){if(!h){return v(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 a=f.indexOf(g)>=0?"video":"audio";if(o.indexOf(g)>=0)l();else c();function l(){i("Use `videostream` package for "+e.name);_();u.addEventListener("error",d);u.addEventListener("playing",b);s(e,u)}function c(){i("Use MediaSource API for "+e.name);_();u.addEventListener("error",m);u.addEventListener("playing",b);e.createReadStream().pipe(new n(u,{extname:g}));if(y)u.currentTime=y}function p(){i("Use Blob URL for "+e.name);_();u.addEventListener("error",S);u.addEventListener("playing",b);e.getBlobURL(function(e,t){if(e)return S(e);u.src=t;if(y)u.currentTime=y})}function d(e){i("videostream error: fallback to MediaSource API: %o",e.message||e);u.removeEventListener("error",d);u.removeEventListener("playing",b);c()}function m(e){i("MediaSource API error: fallback to Blob URL: %o",e.message||e);u.removeEventListener("error",m);u.removeEventListener("playing",b);p()}function _(e){if(!u){u=document.createElement(a);u.controls=true;u.autoplay=true;u.play();u.addEventListener("progress",function(){y=u.currentTime});t.appendChild(u)}}}function b(){u.removeEventListener("playing",b);r(null,u)}function w(){u=document.createElement("audio");u.controls=true;u.autoplay=true;t.appendChild(u);e.getBlobURL(function(e,t){if(e)return S(e);u.addEventListener("error",S);u.addEventListener("playing",b);u.src=t;u.play()})}function x(){e.getBlobURL(function(i,n){if(i)return S(i);u=document.createElement("img");u.src=n;u.alt=e.name;t.appendChild(u);r(null)})}function k(){e.getBlobURL(function(e,i){if(e)return S(e);u=document.createElement("iframe");u.src=i;if(g!==".pdf")u.sandbox="allow-forms allow-scripts";t.appendChild(u);r(null)})}function S(t){if(u)u.remove();t.message='Error appending file "'+e.name+'" to DOM: '+t.message;i(t.message);if(r)r(t)}};function m(){}function v(e,t,i){r.nextTick(function(){if(e)e(t,i)})}}).call(this,e("_process"))},{_process:48,debug:120,mediasource:129,path:47,videostream:180}],2:[function(e,t,r){t.exports=s;var i=e("debug")("webtorrent:file-stream");var n=e("inherits");var a=e("stream");n(s,a.Readable);function s(e,t){a.Readable.call(this,t);this.destroyed=false;this._torrent=e._torrent;var r=t&&t.start||0;var i=t&&t.end||e.length-1;var n=e._torrent.pieceLength;this._startPiece=(r+e.offset)/n|0;this._endPiece=(i+e.offset)/n|0;this._piece=this._startPiece;this._offset=r+e.offset-this._startPiece*n;this._missing=i-r+1;this._reading=false;this._notifying=false;this._criticalLength=Math.min(1024*1024/n|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,n){e._notifying=false;if(e.destroyed)return;if(r)return e.destroy(r);i("read %s (length %s) (err %s)",t,n.length,r&&r.message);if(e._offset){n=n.slice(e._offset);e._offset=0}if(e._missing<n.length){n=n.slice(0,e._missing)}e._missing-=n.length;i("pushing buffer of length %s",n.length);e._reading=false;e.push(n);if(e._missing===0)e.push(null)});e._piece+=1};s.prototype.destroy=function(){if(this.destroyed)return;this.destroyed=true;this._torrent.deselect(this._startPiece,this._endPiece,true)}},{debug:120,inherits:128,stream:66}],3:[function(e,t,r){(function(r,i){t.exports=p;var n=e("./append-to");var a=e("end-of-stream");var s=e("events").EventEmitter;var o=e("./file-stream");var f=e("inherits");var u=e("./mime.json");var l=e("path");var c=e("stream");f(p,s);function p(e,t){s.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 i=r+t.length-1;this._startPiece=r/this._torrent.pieceLength|0;this._endPiece=i/this._torrent.pieceLength|0;if(this.length===0){this.done=true;this.emit("done")}}p.prototype.select=function(){if(this.length===0)return;this._torrent.select(this._startPiece,this._endPiece,false)};p.prototype.deselect=function(){if(this.length===0)return;this._torrent.deselect(this._startPiece,this._endPiece,false)};p.prototype.createReadStream=function(e){var t=this;if(this.length===0){var i=new c.PassThrough;r.nextTick(function(){i.end()});return i}var n=new o(t,e);t._torrent.select(n._startPiece,n._endPiece,true,function(){n._notify()});a(n,function(){t._torrent.deselect(n._startPiece,n._endPiece,true)});return n};p.prototype.getBuffer=function(e){var t=new i(this.length);var r=0;this.createReadStream().on("data",function(e){e.copy(t,r);r+=e.length}).on("end",function(){e(null,t)}).on("error",e)};p.prototype.getBlobURL=function(e){var t=this;if(typeof window==="undefined")throw new Error("browser-only method");t.getBuffer(function(r,i){if(r)return e(r);var n=l.extname(t.name).toLowerCase();var a=u[n];var s=new window.Blob([i],a&&{type:a});var o=window.URL.createObjectURL(s);e(null,o)})};p.prototype.appendTo=function(e,t){if(typeof window==="undefined")throw new Error("browser-only method");if(typeof e==="string")e=document.querySelector(e);n(this,e,t)}}).call(this,e("_process"),e("buffer").Buffer)},{"./append-to":1,"./file-stream":2,"./mime.json":4,_process:48,buffer:39,"end-of-stream":123,events:43,inherits:128,path:47,stream:66}],4:[function(e,t,r){t.exports={".aac":"audio/aac",".css":"text/css",".html":"text/html",".js":"application/javascript",".m4a":"audio/mp4",".md":"text/x-markdown",".mp3":"audio/mpeg",".mp4":"video/mp4",".oga":"audio/ogg",".ogg":"audio/ogg",".pdf":"application/pdf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm"}},{}],5:[function(e,t,r){t.exports=i;function i(e,t){var r=this;r.pieces=[];r.swarm=e;r.numPieces=t;function i(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(i);r.swarm.on("wire",function(e){r.recalculate();i(e)});r.recalculate()}i.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)}})};i.prototype.getRarestPiece=function(e){var t=this;var r=[];var i=Infinity;e=e||function(){return true};for(var n=0;n<t.numPieces;++n){if(!e(n))continue;var a=t.pieces[n];if(a===i){r.push(n)}else if(a<i){r=[n];i=a}}if(r.length>0){return r[Math.random()*r.length|0]}else{return-1}}},{}],6:[function(e,t,r){t.exports=u;var i=e("debug")("webtorrent:server");var n=e("http");var a=e("mime");var s=e("pump");var o=e("range-parser");var f=e("url");function u(e,t){var r=n.createServer(t);var u=[];r.on("connection",function(e){e.setTimeout(36e6);u.push(e);e.on("close",function(){var t=u.indexOf(e);if(t>=0)u.splice(t,1)})});r.destroy=function(e){u.forEach(function(e){e.destroy()});r.close(e)};r.on("request",function(t,r){i("onRequest");if(t.method==="OPTIONS"&&t.headers["access-control-request-headers"]){r.setHeader("Access-Control-Allow-Methods","POST, GET, OPTIONS");r.setHeader("Access-Control-Allow-Headers",t.headers["access-control-request-headers"]);r.setHeader("Access-Control-Max-Age","1728000");return r.end()}if(t.headers.origin){r.setHeader("Access-Control-Allow-Origin",t.headers.origin)}var n=f.parse(t.url).pathname;if(n==="/favicon.ico")return r.end();if(e.ready)u();else e.once("ready",u);function u(){if(n==="/"){r.setHeader("Content-Type","text/html");var f=e.files.map(function(e,t){return'<li><a href="/'+t+'">'+e.name+"</a></li>"}).join("<br>");return r.end("<h1>WebTorrent</h1><ol>"+f+"</ol>")}var u=Number(n.slice(1));if(Number.isNaN(u)||u>=e.files.length){r.statusCode=404;return r.end("404 Not Found")}var l=e.files[u];r.setHeader("Accept-Ranges","bytes");r.setHeader("Content-Type",a.lookup(l.name));r.statusCode=200;r.setHeader("transferMode.dlna.org","Streaming");r.setHeader("contentFeatures.dlna.org","DLNA.ORG_OP=01;DLNA.ORG_CI=0;DLNA.ORG_FLAGS=01700000000000000000000000000000");var c;if(t.headers.range){r.statusCode=206;c=o(l.length,t.headers.range)[0];i("range %s",JSON.stringify(c));r.setHeader("Content-Range","bytes "+c.start+"-"+c.end+"/"+l.length);r.setHeader("Content-Length",c.end-c.start+1)}else{r.setHeader("Content-Length",l.length)}if(t.method==="HEAD")r.end();s(l.createReadStream(c),r)}});return r}},{debug:120,http:67,mime:131,pump:148,"range-parser":152,url:77}],7:[function(e,t,r){(function(r,i){t.exports=H;var n=e("addr-to-ip-port");var a=e("bitfield");var s=e("chunk-store-stream/write");var o=e("create-torrent");var f=e("debug")("webtorrent:torrent");var u=e("torrent-discovery");var l=e("events").EventEmitter;var c=e("xtend/mutable");var p=e("fs-chunk-store");var d=e("immediate-chunk-store");var h=e("inherits");var m=e("multistream");var v=e("os");var g=e("run-parallel");var y=e("parse-torrent");var _=e("path");var b=e("path-exists");var w=e("torrent-piece");var x=e("pump");var k=e("random-iterate");var S=e("re-emitter");var E=e("simple-sha1");var A=e("bittorrent-swarm");var U=e("uniq");var I=e("ut_metadata");var T=e("ut_pex");var L=e("./file");var B=e("./rarity-map");var C=e("./server");var R=128*1024;var P=3e4;var O=5e3;var z=3*w.BLOCK_LENGTH;var F=.5;var M=1;var j=1e4;var D=2;var N=_.join(b.sync("/tmp")?"/tmp":v.tmpDir(),"webtorrent");h(H,l);function H(e,t){var r=this;l.call(r);if(!f.enabled)r.setMaxListeners(0);f("new torrent");r.client=t.client;r.announce=t.announce;r.urlList=t.urlList;r._path=t.path;r._store=t.store||p;r.strategy=t.strategy||"sequential";r._rechokeNumSlots=t.uploads===false||t.uploads===0?0:+t.uploads||10;r._rechokeOptimisticWire=null;r._rechokeOptimisticTime=0;r._rechokeIntervalId=null;r.ready=false;r.destroyed=false;r.metadata=null;r.store=null;r.numBlockedPeers=0;r.files=null;r.done=false;r._amInterested=false;r._selections=[];r._critical=[];r._servers=[];if(e)r._onTorrentId(e)}Object.defineProperty(H.prototype,"timeRemaining",{get:function(){if(this.swarm.downloadSpeed()===0)return Infinity;else return(this.length-this.downloaded)/this.swarm.downloadSpeed()*1e3}});Object.defineProperty(H.prototype,"downloaded",{get:function(){return this.swarm?this.swarm.downloaded:0}});Object.defineProperty(H.prototype,"uploaded",{get:function(){return this.swarm?this.swarm.uploaded:0}});Object.defineProperty(H.prototype,"progress",{get:function(){var e=0;for(var t=0,r=this.pieces.length;t<r;t++){if(this.bitfield.get(t)){e+=t!==r-1?this.pieceLength:this.lastPieceLength}else{var i=this.pieces[t];e+=i.length-i.missing}}return this.length?e/this.length:0}});Object.defineProperty(H.prototype,"ratio",{get:function(){return this.uploaded/(this.downloaded||1)}});Object.defineProperty(H.prototype,"numPeers",{get:function(){return this.swarm?this.swarm.numPeers:0}});Object.defineProperty(H.prototype,"torrentFileURL",{get:function(){if(typeof window==="undefined")throw new Error("browser-only property");if(!this.torrentFile)return null;return window.URL.createObjectURL(new window.Blob([this.torrentFile],{type:"application/x-bittorrent"}))}});H.prototype.downloadSpeed=function(){return this.swarm?this.swarm.downloadSpeed():0};H.prototype.uploadSpeed=function(){return this.swarm?this.swarm.uploadSpeed():0};H.prototype._onTorrentId=function(e){var t=this;if(t.destroyed)return;y.remote(e,function(e,r){if(t.destroyed)return;if(e)return t._onError(e);t._onParsedTorrent(r)})};H.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=_.join(N,t.infoHash);t.swarm=new A(t.infoHash,t.client.peerId,{handshake:{dht:!!t.client.dht}});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));r.nextTick(function(){if(t.destroyed)return;t.emit("infoHash",t.infoHash)})};H.prototype._processParsedTorrent=function(e){if(this.announce){e.announce=e.announce.concat(this.announce)}if(i.WEBTORRENT_ANNOUNCE){e.announce=e.announce.concat(i.WEBTORRENT_ANNOUNCE)}if(e.announce.length===0){e.announce=o.announceList.map(function(e){return e[0]})}if(this.urlList){e.urlList=e.urlList.concat(this.urlList)}U(e.announce);c(this,e);this.magnetURI=y.toMagnetURI(e);this.torrentFile=y.toTorrentFile(e)};H.prototype._onSwarmListening=function(){var e=this;if(e.destroyed)return;if(e.swarm.server)e.client.torrentPort=e.swarm.address().port;e.discovery=new u({announce:e.announce,dht:e.client.dht,tracker:e.client.tracker,peerId:e.client.peerId,port:e.client.torrentPort,rtcConfig:e.client._rtcConfig,wrtc:e.client._wrtc});e.discovery.on("error",e._onError.bind(e));e.discovery.setTorrent(e.infoHash);e.discovery.on("peer",e.addPeer.bind(e));S(e.discovery,e,["trackerAnnounce","dhtAnnounce","warning"]);if(e.info)e._onMetadata(e);e.emit("listening",e.client.torrentPort)};H.prototype._onMetadata=function(e){var t=this;if(t.metadata||t.destroyed)return;f("got metadata");var i;if(e&&e.infoHash){i=e}else{try{i=y(e)}catch(n){return t._onError(n)}}t._processParsedTorrent(i);t.metadata=t.torrentFile;t.discovery.setTorrent(t);if(t.urlList)t.urlList.forEach(t.addWebSeed.bind(t));t.rarityMap=new B(t.swarm,t.pieces.length);t.store=new d(new t._store(t.pieceLength,{files:t.files.map(function(e){return{path:_.join(t._path,e.path),length:e.length,offset:e.offset}}),length:t.length}));t.files=t.files.map(function(e){return new L(t,e)});t._hashes=t.pieces;t.pieces=t.pieces.map(function(e,r){var i=r===t.pieces.length-1?t.lastPieceLength:t.pieceLength;return new w(i)});t._reservations=t.pieces.map(function(){return[]});t.bitfield=new a(t.pieces.length);t.swarm.wires.forEach(function(e){if(e.ut_metadata)e.ut_metadata.setMetadata(t.metadata);t._onWireWithMetadata(e)});r.nextTick(function(){t.emit("metadata");t._onStore()})};H.prototype._onStore=function(){var e=this;if(e.destroyed)return;f("on store");e.select(0,e.pieces.length-1,false);e._rechokeIntervalId=setInterval(e._rechoke.bind(e),j);if(e._rechokeIntervalId.unref)e._rechokeIntervalId.unref();e.ready=true;e.emit("ready")};H.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;f("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)});g(r,e)};H.prototype.addPeer=function(e){var t=this;function r(){t.swarm.addPeer(e);t.emit("peer",e)}if(typeof e==="string"&&t.client.blocked&&t.client.blocked.contains(n(e)[0])){t.numBlockedPeers+=1;t.emit("blockedPeer",e);return false}else{if(t.swarm)r();else t.once("listening",r);return true}};H.prototype.addWebSeed=function(e){var t=this;t.swarm.addWebSeed(e,t)};H.prototype.select=function(e,t,r,i){var n=this;if(e>t||e<0||t>=n.pieces.length){throw new Error("invalid selection ",e,":",t)}r=Number(r)||0;f("select %s-%s (priority %s)",e,t,r);n._selections.push({from:e,to:t,offset:0,priority:r,notify:i||W});n._selections.sort(function(e,t){return t.priority-e.priority});n._updateSelections()};H.prototype.deselect=function(e,t,r){var i=this;r=Number(r)||0;f("deselect %s-%s (priority %s)",e,t,r);for(var n=0;n<i._selections.length;++n){var a=i._selections[n];if(a.from===e&&a.to===t&&a.priority===r){i._selections.splice(n--,1);break}}i._updateSelections()};H.prototype.critical=function(e,t){var r=this;f("critical %s-%s",e,t);for(var i=e;i<=t;++i){r._critical[i]=true}r._updateSelections()};H.prototype._onWire=function(e,t){var r=this;f("got wire (%s)",t||"Unknown");if(t){var i=n(t);e.remoteAddress=i[0];e.remotePort=i[1]}if(e.peerExtensions.dht&&r.client.dht&&r.client.dht.listening){e.on("port",function(t){if(!e.remoteAddress){f("ignoring port from peer with no address");return}f("port: %s (from %s)",t,e.remoteAddress+":"+e.remotePort);r.client.dht.addNode(e.remoteAddress+":"+t)});e.port(r.client.dht.address().port)}e.on("timeout",function(){f("wire timeout (%s)",t);e.destroy()});e.setTimeout(P,true);e.setKeepAlive(true);e.use(I(r.metadata));if(!r.metadata){e.ut_metadata.on("metadata",function(e){f("got metadata via ut_metadata");r._onMetadata(e)});e.ut_metadata.fetch()}if(typeof T==="function"){e.use(T());e.ut_pex.on("peer",function(e){f("ut_pex: got peer: %s (from %s)",e,t);r.addPeer(e)});e.ut_pex.on("dropped",function(e){var i=r.swarm._peers[e];if(i&&!i.connected){f("ut_pex: dropped peer: %s (from %s)",e,t);r.swarm.removePeer(e)}})}r.emit("wire",e,t);if(r.metadata){r._onWireWithMetadata(e)}};H.prototype._onWireWithMetadata=function(e){var t=this;var r=null;function i(){if(t.destroyed||e.destroyed)return;if(t.swarm.numQueued>2*(t.swarm.numConns-t.swarm.numPeers)&&e.amInterested){e.destroy()}else{r=setTimeout(i,O);if(r.unref)r.unref()}}var n=0;function a(){if(e.peerPieces.length!==t.pieces.length)return;for(;n<t.pieces.length;++n){if(!e.peerPieces.get(n))return}e.isSeeder=true;e.choke()}e.on("bitfield",function(){a();t._update()});e.on("have",function(){a();t._update()});e.once("interested",function(){e.unchoke()});e.on("close",function(){clearTimeout(r)});e.on("choke",function(){clearTimeout(r);r=setTimeout(i,O);if(r.unref)r.unref()});e.on("unchoke",function(){clearTimeout(r);t._update()});e.on("request",function(r,i,n,a){if(n>R){return e.destroy()}if(t.pieces[r])return;t.store.get(r,{offset:i,length:n},a)});e.bitfield(t.bitfield);e.interested();r=setTimeout(i,O);if(r.unref)r.unref();e.isSeeder=false;a()};H.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()};H.prototype._gcSelections=function(){var e=this;for(var t=0;t<e._selections.length;t++){var r=e._selections[t];var i=r.offset;while(e.bitfield.get(r.from+r.offset)&&r.from+r.offset<r.to){r.offset++}if(i!==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")};H.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")};H.prototype._update=function(){var e=this;if(e.destroyed)return;var t=k(e.swarm.wires);var r;while(r=t()){e._updateWire(r)}};H.prototype._updateWire=function(e){var t=this;if(e.peerChoking)return;if(!e.downloaded)return a();var r=q(e,F);if(e.requests.length>=r)return;var i=q(e,M);f(false)||f(true);function n(t,r,i,n){return function(a){return a>=t&&a<=r&&!(a in i)&&e.peerPieces.get(a)&&(!n||n(a))}}function a(){if(e.requests.length)return;for(var r=t._selections.length;r--;){var i=t._selections[r];var a;if(t.strategy==="rarest"){var s=i.from+i.offset;var o=i.to;var f=o-s+1;var u={};var l=0;var c=n(s,o,u);while(l<f){a=t.rarityMap.getRarestPiece(c);if(a<0)break;if(t._request(e,a,false))return;u[a]=true;l+=1}}else{for(a=i.to;a>=i.from+i.offset;--a){if(!e.peerPieces.get(a))continue;if(t._request(e,a,false))return}}}}function s(){var r=e.downloadSpeed()||1;if(r>z)return function(){return true};var i=Math.max(1,e.requests.length)*w.BLOCK_LENGTH/r;var n=10;var a=0;return function(e){if(!n||t.bitfield.get(e))return true;var s=t.pieces[e].missing;for(;a<t.swarm.wires.length;a++){var o=t.swarm.wires[a];var f=o.downloadSpeed();if(f<z)continue;if(f<=r)continue;if(!o.peerPieces.get(e))continue;if((s-=f*i)>0)continue;n--;return false}return true}}function o(e){var r=e;for(var i=e;i<t._selections.length&&t._selections[i].priority;i++){r=i}var n=t._selections[e];t._selections[e]=t._selections[r];t._selections[r]=n}function f(r){if(e.requests.length>=i)return true;var a=s();for(var f=0;f<t._selections.length;f++){var u=t._selections[f];var l;if(t.strategy==="rarest"){var c=u.from+u.offset;var p=u.to;var d=p-c+1;var h={};var m=0;var v=n(c,p,h,a);while(m<d){l=t.rarityMap.getRarestPiece(v);if(l<0)break;while(t._request(e,l,t._critical[l]||r)){}if(e.requests.length<i){h[l]=true;m++;continue}if(u.priority)o(f);return true}}else{for(l=u.from+u.offset;l<=u.to;l++){if(!e.peerPieces.get(l)||!a(l))continue;while(t._request(e,l,t._critical[l]||r)){}if(e.requests.length<i)continue;if(u.priority)o(f);return true}}}return false}};H.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 i=0;for(;i<t.length&&r<e._rechokeNumSlots;++i){t[i].isChoked=false;if(t[i].wire.peerInterested)r+=1}if(!e._rechokeOptimisticWire&&i<t.length&&e._rechokeNumSlots){var n=t.slice(i).filter(function(e){return e.wire.peerInterested});var a=n[G(n.length)];if(a){a.isChoked=false;e._rechokeOptimisticWire=a.wire;e._rechokeOptimisticTime=D}}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}};H.prototype._hotswap=function(e,t){var r=this;var i=e.downloadSpeed();if(i<w.BLOCK_LENGTH)return false;if(!r._reservations[t])return false;var n=r._reservations[t];if(!n){return false}var a=Infinity;var s;var o;for(o=0;o<n.length;o++){var f=n[o];if(!f||f===e)continue;var u=f.downloadSpeed();if(u>=z)continue;if(2*u>i||u>a)continue;s=f;a=u}if(!s)return false;for(o=0;o<n.length;o++){if(n[o]===s)n[o]=null}for(o=0;o<s.requests.length;o++){var l=s.requests[o];if(l.piece!==t)continue;r.pieces[t].cancel(l.offset/w.BLOCK_SIZE|0)}r.emit("hotswap",s,e,t);return true};H.prototype._request=function(e,t,i){var n=this;var a=e.requests.length;if(n.bitfield.get(t))return false;var s=q(e,M);if(a>=s)return false;var o=n.pieces[t];var u=o.reserve();if(u===-1&&i&&n._hotswap(e,t)){u=o.reserve()}if(u===-1)return false;var l=n._reservations[t];if(!l)l=n._reservations[t]=[];var c=l.indexOf(null);if(c===-1)c=l.length;l[c]=e;var p=o.chunkOffset(u);var d=o.chunkLength(u);e.request(t,p,d,function m(r,i){if(!n.ready)return n.once("ready",function(){m(r,i)});if(l[c]===e)l[c]=null;if(o!==n.pieces[t])return h();if(r){f("error getting piece %s (offset: %s length: %s) from %s: %s",t,p,d,e.remoteAddress+":"+e.remotePort,r.message);o.cancel(u);h();return}f("got piece %s (offset: %s length: %s) from %s",t,p,d,e.remoteAddress+":"+e.remotePort);if(!o.set(u,i,e))return h();var a=o.flush();E(a,function(e){if(e===n._hashes[t]){if(!n.pieces[t])return;f("piece verified %s",t);n.pieces[t]=null;n._reservations[t]=null;n.bitfield.set(t,true);n.store.put(t,a);n.swarm.wires.forEach(function(e){e.have(t)});n._onPiece()}else{n.pieces[t]=new w(o.length);n.emit("warning",new Error("Piece "+t+" failed verification"))}h()})});function h(){r.nextTick(function(){n._update()})}return true};H.prototype._onPiece=function(){var e=this;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");f("file done: "+t.name)});if(e.files.every(function(e){return e.done})){e.done=true;e.emit("done");f("torrent done: "+e.infoHash);if(e.discovery.tracker)e.discovery.tracker.complete()}e._gcSelections()};H.prototype.load=function(e,t){var r=this;if(!Array.isArray(e))e=[e];if(!t)t=W;var i=new m(e);var n=new s(r.store,r.pieceLength);x(i,n,function(e){if(e)return t(e);r.pieces.forEach(function(e,t){r.pieces[t]=null;r.bitfield.set(t,true)});r._onPiece();t(null)})};H.prototype.createServer=function(e){var t=this;if(typeof C==="function"){var r=new C(t,e);t._servers.push(r);return r}};H.prototype._onError=function(e){var t=this;f("torrent error: %s",e.message||e);t.emit("error",e);t.destroy()};function q(e,t){return Math.ceil(2+t*e.downloadSpeed()/w.BLOCK_LENGTH)}function G(e){return Math.random()*e|0}function W(){}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./file":3,"./rarity-map":5,"./server":6,_process:48,"addr-to-ip-port":8,bitfield:9,"bittorrent-swarm":10,"chunk-store-stream/write":89,"create-torrent":90,debug:120,events:43,"fs-chunk-store":130,"immediate-chunk-store":127,inherits:128,multistream:133,os:46,"parse-torrent":134,path:47,"path-exists":147,pump:148,"random-iterate":151,"re-emitter":153,"run-parallel":154,"simple-sha1":163,"torrent-discovery":166,"torrent-piece":167,uniq:168,ut_metadata:169,ut_pex:38,"xtend/mutable":182}],8:[function(e,t,r){var i=/^\[?([^\]]+)\]?:(\d+)$/;var n={};var a=0;t.exports=function s(e){if(a===1e5)n={};if(!n[e]){var t=i.exec(e);if(!t)throw new Error("invalid addr: "+e);n[e]=[t[1],Number(t[2])];a+=1}return n[e]};t.exports.reset=function o(){n={}}},{}],9:[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 i(e,t){if(!(this instanceof i)){return new i(e,t)}if(arguments.length===0){e=0}this.grow=t&&(isFinite(t.grow)&&n(t.grow)||t.grow)||0;if(typeof e==="number"||e===undefined){e=new r(n(e));if(e.fill&&!e._isBuffer)e.fill(0)}this.buffer=e}function n(e){var t=e>>3;if(e%8!==0)t++;return t}i.prototype.get=function(e){var t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)};i.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)}};i.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 i=0;i<this.buffer.length;i++){t[i]=this.buffer[i]}}this.buffer=t}};if(typeof t!=="undefined")t.exports=i}).call(this,e("buffer").Buffer)},{buffer:39}],10:[function(e,t,r){(function(r,i){t.exports=m;var n=e("addr-to-ip-port");var a=e("debug")("bittorrent-swarm");var s=e("dezalgo");var o=e("events").EventEmitter;var f=e("inherits");var u=e("net");var l=e("./lib/peer");var c=e("speedometer");var p=e("./lib/tcp-pool");var d=55;var h=[1e3,5e3,15e3];f(m,o);function m(e,t,r){var n=this;if(!(n instanceof m))return new m(e,t,r);o.call(n);n.infoHash=typeof e==="string"?new i(e,"hex"):e;n.infoHashHex=n.infoHash.toString("hex");n.peerId=typeof t==="string"?new i(t,"hex"):t;n.peerIdHex=n.peerId.toString("hex");if(!r)r={};a("new swarm (i %s p %s)",n.infoHashHex,n.peerIdHex);n.handshakeOpts=r.handshake;n.maxConns=r.maxConns!==undefined?r.maxConns:d;n.destroyed=false;n.listening=false;n.paused=false;n.server=null;n.wires=[];n._queue=[];n._peers={};n._peersLength=0;n._port=0;n.downloaded=0;n.uploaded=0;n.downloadSpeed=c();n.uploadSpeed=c()}Object.defineProperty(m.prototype,"ratio",{get:function(){var e=this;return e.uploaded/e.downloaded||0}});Object.defineProperty(m.prototype,"numQueued",{get:function(){var e=this;return e._queue.length+(e._peersLength-e.numConns)}});Object.defineProperty(m.prototype,"numConns",{get:function(){var e=this;var t=0;for(var r in e._peers){var i=e._peers[r];if(i&&i.connected)t+=1}return t}});Object.defineProperty(m.prototype,"numPeers",{get:function(){var e=this;return e.wires.length}});m.prototype.addPeer=function(e){var t=this;t._addPeer(e)};m.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)){a("ignoring invalid peer %s (from swarm.addPeer)",e);return null}var r=e&&e.id||e;if(t._peers[r])return;a("addPeer %s",r);var i;if(typeof e==="string"){i=l.createOutgoingTCPPeer(e,t)}else{if(t.paused){e.destroy(new Error("swarm paused"));return null}i=l.createWebRTCPeer(e,t)}t._peers[i.id]=i;t._peersLength+=1;if(typeof e==="string"){t._queue.push(i);t._drain()}return i};m.prototype.addWebSeed=function(e,t){var r=this;if(r.destroyed)return;if(!/^https?:\/\/.+/.test(e)){a("ignoring invalid web seed %s (from swarm.addWebSeed)",e);return}if(r._peers[e])return;a("addWebSeed %s",e);var i=l.createWebPeer(e,t,r);r._peers[i.id]=i;r._peersLength+=1};m.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)"))}a("_addIncomingPeer %s",e.id);t._peers[e.id]=e;t._peersLength+=1};m.prototype.removePeer=function(e){var t=this;var r=t._peers[e];if(!r)return;a("removePeer %s",e);t._peers[e]=null;t._peersLength-=1;r.destroy();t._drain()};m.prototype.pause=function(){var e=this;if(e.destroyed)return;a("pause");e.paused=true};m.prototype.resume=function(){var e=this;if(e.destroyed)return;a("resume");e.paused=false;e._drain()};m.prototype.listen=function(e,t,i){var n=this;if(typeof t==="function"){i=t;t=undefined}if(i)i=s(i);if(n.listening)throw new Error("swarm already listening");if(r.browser&&i){i()}else{n._port=e||p.getDefaultListenPort(n.infoHashHex);n._hostname=t;if(i)n.once("listening",i);a("listen %s",e);var o=p.addSwarm(n);n.server=o.server}};m.prototype._onListening=function(e){var t=this;t._port=e;t.listening=true;t.emit("listening")};m.prototype.address=function(){var e=this;return e.server.address()};m.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);
+a("destroy");for(var r in t._peers){t.removePeer(r)}p.removeSwarm(t,function(){t.emit("close")})};m.prototype._drain=function(){var e=this;a("_drain numConns %s maxConns %s",e.numConns,e.maxConns);if(typeof u.connect!=="function"||e.destroyed||e.paused||e.numConns>=e.maxConns){return}a("drain (%s queued, %s/%s peers)",e.numQueued,e.numPeers,e.maxConns);var t=e._queue.shift();if(!t)return;a("tcp connect attempt to %s",t.addr);var r=n(t.addr);var i={host:r[0],port:r[1]};if(e._hostname)i.localAddress=e._hostname;var s=t.conn=u.connect(i);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){a("conn %s closed: will not re-add (max %s attempts)",t.addr,h.length);return}var r=h[t.retries];a("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,r,t.retries+1);var i=setTimeout(function n(){var r=e._addPeer(t.addr);if(r)r.retries=t.retries+1},r);if(i.unref)i.unref()})};m.prototype._onError=function(e){var t=this;t.emit("error",e);t.destroy()};m.prototype._validAddr=function(e){var t=this;var r=n(e);var i=r[0];var a=r[1];return a>0&&a<65535&&!(i==="127.0.0.1"&&a===t._port)}}).call(this,e("_process"),e("buffer").Buffer)},{"./lib/peer":11,"./lib/tcp-pool":12,_process:48,"addr-to-ip-port":38,buffer:39,debug:120,dezalgo:19,events:43,inherits:128,net:38,speedometer:165}],11:[function(e,t,r){var i=e("debug")("bittorrent-swarm:peer");var n=e("./webconn");var a=e("bittorrent-protocol");var s=25e3;var o=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 i=new f(e);i.swarm=r;i.conn=new n(e,t);i.onConnect();return i};function f(e){var t=this;t.id=e;i("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;i("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 a;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;var n=e.toString("hex");var a=t.toString("hex");if(r.swarm.destroyed)return r.destroy(new Error("swarm already destroyed"));if(n!==r.swarm.infoHashHex){return r.destroy(new Error("unexpected handshake info hash for this swarm"))}if(a===r.swarm.peerIdHex){return r.destroy(new Error("refusing to handshake with self"))}i("Peer %s got handshake %s",r.id,n);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 s=r.addr;if(!s&&r.conn.remoteAddress){s=r.conn.remoteAddress+":"+r.conn.remotePort}r.swarm.emit("wire",r.wire,s)};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"))},o);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;i("destroy %s (error: %s)",t.id,e&&(e.message||e));clearTimeout(t.connectTimeout);clearTimeout(t.handshakeTimeout);var r=t.swarm;var n=t.conn;var a=t.wire;t.conn=null;t.swarm=null;t.wire=null;if(r&&a){var s=r.wires.indexOf(a);if(s>=0)r.wires.splice(s,1)}if(n)n.destroy();if(a)a.destroy();if(r)r.removePeer(t.id)}},{"./webconn":13,"bittorrent-protocol":14,debug:120}],12:[function(e,t,r){(function(r){t.exports=f;var i=e("debug")("bittorrent-swarm:tcp-pool");var n=e("dezalgo");var a=e("net");var s=e("./peer");var o={};function f(e,t){var r=this;r.port=e;r.listening=false;r.swarms={};i("new TCPPool (port: %s, hostname: %s)",e,t);r.pendingConns=[];r.server=a.createServer();r.server.on("connection",function(e){r._onConnection(e)});r.server.on("error",function(e){r._onError(e)});r.server.on("listening",function(){r._onListening()});r.server.listen(r.port,t)}f.addSwarm=function(e){var t=o[e._port];if(!t)t=o[e._port]=new f(e._port,e._hostname);t.addSwarm(e);return t};f.removeSwarm=function(e,t){var i=o[e._port];if(!i)return t();i.removeSwarm(e);var n=0;for(var a in i.swarms){var s=i.swarms[a];if(s)n+=1}if(n===0)i.destroy(t);else r.nextTick(t)};f.getDefaultListenPort=function(e){for(var t in o){var r=o[t];if(r&&!r.swarms[e])return r.port}return 0};f.prototype.addSwarm=function(e){var t=this;if(t.swarms[e.infoHashHex]){r.nextTick(function(){e._onError(new Error("There is already a swarm with info hash "+e.infoHashHex+" "+"listening on port "+e._port))});return}t.swarms[e.infoHashHex]=e;if(t.listening){r.nextTick(function(){e._onListening(t.port)})}i("add swarm %s to tcp pool %s",e.infoHashHex,t.port)};f.prototype.removeSwarm=function(e){var t=this;i("remove swarm %s from tcp pool %s",e.infoHashHex,t.port);t.swarms[e.infoHashHex]=null};f.prototype.destroy=function(e){var t=this;if(e)e=n(e);i("destroy tcp pool %s",t.port);t.listening=false;t.pendingConns.forEach(function(e){e.destroy()});o[t.port]=null;try{t.server.close(e)}catch(r){if(e)e(null)}};f.prototype._onListening=function(){var e=this;var t=e.server.address()||{port:0};var r=t.port;i("tcp pool listening on %s",r);if(r!==e.port){o[e.port]=null;e.port=r;o[e.port]=e}e.listening=true;for(var n in e.swarms){var a=e.swarms[n];if(a)a._onListening(e.port)}};f.prototype._onConnection=function(e){var t=this;t.pendingConns.push(e);e.once("close",r);function r(){t.pendingConns.splice(t.pendingConns.indexOf(e))}var i=s.createIncomingTCPPeer(e);i.wire.once("handshake",function(n,a){var s=n.toString("hex");r();e.removeListener("close",r);var o=t.swarms[s];if(o){i.swarm=o;o._addIncomingPeer(i);i.onHandshake(n,a)}else{var f=new Error("Unexpected info hash "+s+" from incoming peer "+i.id+": destroying peer");i.destroy(f)}})};f.prototype._onError=function(e){var t=this;t.destroy();for(var r in t.swarms){var i=t.swarms[r];if(i){t.removeSwarm(i);i._onError(e)}}}}).call(this,e("_process"))},{"./peer":11,_process:48,debug:120,dezalgo:19,net:38}],13:[function(e,t,r){(function(r){t.exports=f;var i=e("bitfield");var n=e("debug")("bittorrent-swarm:webconn");var a=e("simple-get");var s=e("inherits");var o=e("bittorrent-protocol");s(f,o);function f(e,t){var a=this;o.call(this);a.url=e;a.parsedTorrent=t;a.setKeepAlive(true);a.on("handshake",function(t,n){a.handshake(t,new r(20).fill(e));var s=a.parsedTorrent.pieces.length;var o=new i(s);for(var f=0;f<=s;f++){o.set(f,true)}a.bitfield(o)});a.on("choke",function(){n("choke")});a.on("unchoke",function(){n("unchoke")});a.once("interested",function(){n("interested");a.unchoke()});a.on("uninterested",function(){n("uninterested")});a.on("bitfield",function(){n("bitfield")});a.on("request",function(e,t,r,i){n("request pieceIndex=%d offset=%d length=%d",e,t,r);a.httpRequest(e,t,r,i)})}f.prototype.httpRequest=function(e,t,r,i){var s=this;var o=e*s.parsedTorrent.pieceLength;var f=o+t;var u=f+r-1;n("Requesting pieceIndex=%d offset=%d length=%d start=%d end=%d",e,t,r,f,u);var l={url:s.url,method:"GET",headers:{"user-agent":"WebTorrent (http://webtorrent.io)",range:"bytes="+f+"-"+u}};a.concat(l,function(e,t,r){if(e)return i(e);if(r.statusCode<200||r.statusCode>=300){return i(new Error("Unexpected HTTP status code "+r.statusCode))}n("Got data of length %d",t.length);i(null,t)})}}).call(this,e("buffer").Buffer)},{bitfield:9,"bittorrent-protocol":14,buffer:39,debug:120,inherits:128,"simple-get":159}],14:[function(e,t,r){(function(r){t.exports=w;var i=e("bencode");var n=e("bitfield");var a=e("debug")("bittorrent-protocol");var s=e("xtend");var o=e("hat");var f=e("inherits");var u=e("speedometer");var l=e("stream");var c=4e5;var p=new r("BitTorrent protocol");var d=new r([0,0,0,0]);var h=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,i){this.piece=e;this.offset=t;this.length=r;this.callback=i}f(w,l.Duplex);function w(){if(!(this instanceof w))return new w;l.Duplex.call(this);this._debugId=o(32);this._debug("new wire");this.amChoking=true;this.amInterested=false;this.peerChoking=true;this.peerInterested=false;this.peerPieces=new n(0,{grow:c});this.peerExtensions={};this.requests=[];this.peerRequests=[];this.extendedMapping={};this.peerExtendedMapping={};this.extendedHandshake={};this.peerExtendedHandshake={};this._ext={};this._nextExt=1;this.uploaded=0;this.downloaded=0;this.uploadSpeed=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();l.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 i=new e(this);function n(){}if(typeof i.onHandshake!=="function"){i.onHandshake=n}if(typeof i.onExtendedHandshake!=="function"){i.onExtendedHandshake=n}if(typeof i.onMessage!=="function"){i.onMessage=n}this.extendedMapping[r]=t;this._ext[t]=i;this[t]=i;this._nextExt+=1};w.prototype.keepAlive=function(){this._debug("keep-alive");this._push(d)};w.prototype.handshake=function(e,t,i){if(typeof e==="string")e=new r(e,"hex");if(typeof t==="string")t=new r(t,"hex");if(e.length!==20||t.length!==20){throw new Error("infoHash and peerId MUST have length 20")}this._debug("handshake i=%s p=%s exts=%o",e.toString("hex"),t.toString("hex"),i);var n=new r(y);n[5]|=16;if(i&&i.dht)n[7]|=1;this._push(r.concat([p,n,e,t]));this._handshakeSent=true;if(this.peerExtensions.extended){this._sendExtendedHandshake()}};w.prototype._sendExtendedHandshake=function(){var e=s(this.extendedHandshake);e.m={};for(var t in this.extendedMapping){var r=this.extendedMapping[t];e.m[r]=Number(t)}this.extended(0,i.encode(e))};w.prototype.choke=function(){if(this.amChoking)return;this.amChoking=true;this._debug("choke");this.peerRequests.splice(0,this.peerRequests.length);this._push(h)};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,i){if(!i)i=function(){};if(this._finished)return i(new Error("wire is closed"));if(this.peerChoking)return i(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,i));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(x(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 n=new r([e]);var a=r.isBuffer(t)?t:i.encode(t);this._message(20,[],r.concat([n,a]))}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){this._debug("got handshake i=%s p=%s exts=%o",e.toString("hex"),t.toString("hex"),r);this.peerId=t;this.peerExtensions=r;this.emit("handshake",e,t,r);var i;for(i in this._ext){this._ext[i].onHandshake(e,t,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 n(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 i=function(i,a){if(n!==x(this.peerRequests,e,t,r))return;if(i)return;this.piece(e,t,a)}.bind(this);var n=new b(e,t,r,i);this.peerRequests.push(n);this.emit("request",e,t,r,i)};w.prototype._onPiece=function(e,t,r){this._debug("got piece index=%d offset=%d",e,t);this._callback(x(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);x(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=i.decode(t)}catch(n){this._debug("ignoring invalid extended handshake: %s",n.message||n)}if(!r)return;this.peerExtendedHandshake=r;var a;if(typeof r.m==="object"){for(a in r.m){this.peerExtendedMapping[a]=Number(r.m[a].toString())}}for(a in this._ext){if(this.peerExtendedMapping[a]){this._ext[a].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,i){this._bufferSize+=e.length;this._buffer.push(e);while(this._bufferSize>=this._parserSize){var n=this._buffer.length===1?this._buffer[0]:r.concat(this._buffer);this._bufferSize-=this._parserSize;this._buffer=this._bufferSize?[n.slice(this._parserSize)]:[];this._parser(n.slice(0,this._parserSize))}i(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,i){var n=i?i.length:0;var a=new r(5+4*t.length);a.writeUInt32BE(a.length+n-4,0);a[4]=e;for(var s=0;s<t.length;s++){a.writeUInt32BE(t[s],5+4*s)}this._push(a);if(i)this._push(i)};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];a.apply(null,e)};function x(e,t,r,i){for(var n=0;n<e.length;n++){var a=e[n];if(a.piece!==t||a.offset!==r||a.length!==i)continue;if(n===0)e.shift();else e.splice(n,1);return a}return null}}).call(this,e("buffer").Buffer)},{bencode:15,bitfield:9,buffer:39,debug:120,hat:126,inherits:128,speedometer:165,stream:66,xtend:181}],15:[function(e,t,r){t.exports={encode:e("./lib/encode"),decode:e("./lib/decode")}},{"./lib/decode":16,"./lib/encode":18}],16:[function(e,t,r){(function(r){var i=e("./dict");function n(e,t){n.position=0;n.encoding=t||null;n.data=!r.isBuffer(e)?new r(e):e;return n.next()}n.position=0;n.data=null;n.encoding=null;n.next=function(){switch(n.data[n.position]){case 100:return n.dictionary();break;case 108:return n.list();break;case 105:return n.integer();break;default:return n.bytes();break}};n.find=function(e){var t=n.position;var r=n.data.length;var i=n.data;while(t<r){if(i[t]===e)return t;t++}throw new Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")};n.dictionary=function(){n.position++;var e=new i;while(n.data[n.position]!==101){e.binarySet(n.bytes(),n.next())}n.position++;return e};n.list=function(){n.position++;var e=[];while(n.data[n.position]!==101){e.push(n.next())}n.position++;return e};n.integer=function(){var e=n.find(101);var t=n.data.toString("ascii",n.position+1,e);n.position+=e+1-n.position;return parseInt(t,10)};n.bytes=function(){var e=n.find(58);var t=parseInt(n.data.toString("ascii",n.position,e),10);var r=++e+t;n.position=r;return n.encoding?n.data.toString(n.encoding,e,r):n.data.slice(e,r)};t.exports=n}).call(this,e("buffer").Buffer)},{"./dict":17,buffer:39}],17:[function(e,t,r){var i=t.exports=function n(){Object.defineProperty(this,"_keys",{enumerable:false,value:[]})};i.prototype.binaryKeys=function a(){return this._keys.slice()};i.prototype.binarySet=function s(e,t){this._keys.push(e);this[e]=t}},{}],18:[function(e,t,r){(function(e){function r(t){var i=[];r._encode(i,t);return e.concat(i)}r._floatConversionDetected=false;r._encode=function(t,i){if(e.isBuffer(i)){t.push(new e(i.length+":"));t.push(i);return}switch(typeof i){case"string":r.bytes(t,i);break;case"number":r.number(t,i);break;case"object":i.constructor===Array?r.list(t,i):r.dict(t,i);break}};var i=new e("e"),n=new e("d"),a=new e("l");r.bytes=function(t,r){t.push(new e(e.byteLength(r)+":"+r))};r.number=function(t,i){var n=2147483648;var a=i/n<<0;var s=i%n<<0;var o=a*n+s;t.push(new e("i"+o+"e"));if(o!==i&&!r._floatConversionDetected){r._floatConversionDetected=true;console.warn('WARNING: Possible data corruption detected with value "'+i+'":','Bencoding only defines support for integers, value was converted to "'+o+'"');console.trace()}};r.dict=function(e,t){e.push(n);var a=0;var s;var o=Object.keys(t).sort();var f=o.length;for(;a<f;a++){s=o[a];r.bytes(e,s);r._encode(e,t[s])}e.push(i)};r.list=function(e,t){var n=0,s=1;var o=t.length;e.push(a);for(;n<o;n++){r._encode(e,t[n])}e.push(i)};t.exports=r}).call(this,e("buffer").Buffer)},{buffer:39}],19:[function(e,t,r){var i=e("wrappy");t.exports=i(a);var n=e("asap");function a(e){var t=true;n(function(){t=false});return function r(){var r=arguments;var i=this;if(t)n(function(){e.apply(i,r)});else e.apply(i,r)}}},{asap:20,wrappy:22}],20:[function(e,t,r){"use strict";var i=e("./raw");var n=[];var a=[];var s=i.makeRequestCallFromTimer(o);function o(){if(a.length){throw a.shift()}}t.exports=f;function f(e){var t;if(n.length){t=n.pop()}else{t=new u}t.task=e;i(t)}function u(){this.task=null}u.prototype.call=function(){try{this.task.call()}catch(e){if(f.onerror){f.onerror(e)}else{a.push(e);s()}}finally{this.task=null;n[n.length]=this}}},{"./raw":21}],21:[function(e,t,r){(function(e){"use strict";t.exports=r;function r(e){if(!i.length){a();n=true}i[i.length]=e}var i=[];var n=false;var a;var s=0;var o=1024;function f(){while(s<i.length){var e=s;s=s+1;i[e].call();if(s>o){for(var t=0,r=i.length-s;t<r;t++){i[t]=i[t+s]}i.length-=s;s=0}}i.length=0;s=0;n=false}var u=e.MutationObserver||e.WebKitMutationObserver;if(typeof u==="function"){a=l(f)}else{a=c(f)}r.requestFlush=a;function l(e){var t=1;var r=new u(e);var i=document.createTextNode("");r.observe(i,{characterData:true});return function n(){t=-t;i.data=t}}function c(e){return function t(){var t=setTimeout(i,0);var r=setInterval(i,50);function i(){clearTimeout(t);clearInterval(r);e()}}}r.makeRequestCallFromTimer=c}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],22:[function(e,t,r){t.exports=i;function i(e,t){if(e&&t)return i(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 i=e.apply(this,t);var n=t[t.length-1];if(typeof i==="function"&&i!==n){Object.keys(n).forEach(function(e){i[e]=n[e]})}return i}}},{}],23:[function(e,t,r){(function(r,i){t.exports=m;var n=e("events").EventEmitter;var a=e("debug")("bittorrent-tracker");var s=e("inherits");var o=e("once");var f=e("run-parallel");var u=e("uniq");var l=e("url");var c=e("./lib/common");var p=e("./lib/client/http-tracker");var d=e("./lib/client/udp-tracker");var h=e("./lib/client/websocket-tracker");s(m,n);function m(e,t,s,o){var f=this;if(!(f instanceof m))return new m(e,t,s,o);n.call(f);if(!o)o={};f._peerId=i.isBuffer(e)?e:new i(e,"hex");f._peerIdHex=f._peerId.toString("hex");f._peerIdBinary=f._peerId.toString("binary");f._infoHash=i.isBuffer(s.infoHash)?s.infoHash:new i(s.infoHash,"hex");f._infoHashHex=f._infoHash.toString("hex");f._infoHashBinary=f._infoHash.toString("binary");f.torrentLength=s.length;f.destroyed=false;f._port=t;f._rtcConfig=o.rtcConfig;f._wrtc=o.wrtc;a("new client %s",f._infoHashHex);var c=!!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=l.parse(e).protocol;if((t==="http:"||t==="https:")&&typeof p==="function"){return new p(f,e)}else if(t==="udp:"&&typeof d==="function"){return new d(f,e)}else if((t==="ws:"||t==="wss:")&&c){return new h(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=o(r);var n=new i("01234567890123456789");var a=6881;var s={infoHash:Array.isArray(t)?t[0]:t,announce:[e]};var f=new m(n,a,s);f.once("error",r);var u=Array.isArray(t)?t.length:1;var l={};f.on("scrape",function(e){u-=1;l[e.infoHash]=e;if(u===0){f.destroy();var t=Object.keys(l);if(t.length===1){r(null,l[t[0]])}else{r(null,l)}}});t=Array.isArray(t)?t.map(function(e){return new i(e,"hex")}):new i(t,"hex");f.scrape({infoHash:t})};m.prototype.start=function(e){var t=this;a("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;a("send `stop`");e=t._defaultAnnounceOpts(e);e.event="stopped";t._announce(e)};m.prototype.complete=function(e){var t=this;a("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;a("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;a("send `scrape`");if(!e)e={};t._trackers.forEach(function(t){t.scrape(e)})};m.prototype.setInterval=function(e){var t=this;a("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;a("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=c.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":38,"./lib/client/udp-tracker":38,"./lib/client/websocket-tracker":25,"./lib/common":27,_process:48,buffer:39,debug:120,events:43,inherits:128,once:29,"run-parallel":154,uniq:168,url:77}],24:[function(e,t,r){t.exports=a;var i=e("events").EventEmitter;var n=e("inherits");n(a,i);function a(e,t){var r=this;i.call(r);r.client=e;r.announceUrl=t;r.interval=null;r.destroyed=false}a.prototype.setInterval=function(e){var t=this;if(t.interval)return;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)}}},{events:43,inherits:128}],25:[function(e,t,r){t.exports=d;var i=e("debug")("bittorrent-tracker:websocket-tracker");var n=e("hat");var a=e("inherits");var s=e("simple-peer");var o=e("simple-websocket");var f=e("../common");var u=e("./tracker");var l={};var c=30*1e3;var p=5*1e3;a(d,u);function d(e,t,r){var n=this;u.call(n,e,t);i("new websocket tracker %s",t);n.peers={};n.socket=null;n.reconnecting=false;n._openSocket()}d.prototype.DEFAULT_ANNOUNCE_INTERVAL=30*1e3;d.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(i){var n={numwant:r,uploaded:e.uploaded||0,downloaded:e.downloaded,event:e.event,info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,offers:i};if(t._trackerId)n.trackerid=t._trackerId;t._send(n)})};d.prototype.scrape=function(e){var t=this;if(t.destroyed||t.reconnecting)return;t._onSocketError(new Error("scrape not supported "+t.announceUrl))};d.prototype.destroy=function(e){var t=this;if(t.destroyed)return;t.destroyed=true;clearInterval(t.interval);l[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",h);try{t.socket.destroy(e)}catch(r){if(e)e()}t.socket=null};d.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=l[e.announceUrl];if(!e.socket){e.socket=l[e.announceUrl]=new o(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)};d.prototype._onSocketConnect=function(){var e=this;if(e.destroyed)return;if(e.reconnecting){e.reconnecting=false;e.announce(e.client._defaultAnnounceOpts())}};d.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){i("ignoring websocket data from %s for %s (looking for %s: reused socket)",t.announceUrl,f.binaryToHex(e.info_hash),t.client._infoHashHex);return}if(e.peer_id&&e.peer_id===t.client._peerIdBinary){return}i("received %s from %s for %s",JSON.stringify(e),t.announceUrl,t.client._infoHashHex);var r=e["failure reason"];if(r)return t.client.emit("warning",new Error(r));var n=e["warning message"];if(n)t.client.emit("warning",new Error(n));var a=e.interval||e["min interval"];if(a)t.setInterval(a*1e3);var o=e["tracker id"];if(o){t._trackerId=o}if(e.complete){t.client.emit("update",{announce:t.announceUrl,complete:e.complete,incomplete:e.incomplete})}var u;if(e.offer&&e.peer_id){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 i={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)i.trackerid=t._trackerId;t._send(i)});u.signal(e.offer);t.client.emit("peer",u)}if(e.answer&&e.peer_id){u=t.peers[f.binaryToHex(e.offer_id)];if(u){u.id=f.binaryToHex(e.peer_id);u.signal(e.answer);t.client.emit("peer",u)}else{i("got unexpected answer: "+JSON.stringify(e.answer))}}};d.prototype._onSocketClose=function(){var e=this;if(e.destroyed)return;e.destroy();e._startReconnectTimer()};d.prototype._onSocketError=function(e){var t=this;if(t.destroyed)return;t.destroy();t.client.emit("warning",e);t._startReconnectTimer()};d.prototype._startReconnectTimer=function(){var e=this;var t=Math.floor(Math.random()*c)+p;e.reconnecting=true;var r=setTimeout(function(){e._openSocket()},t);if(r.unref)r.unref();i("reconnecting socket in %s ms",t)};d.prototype._send=function(e){var t=this;if(t.destroyed)return;var r=JSON.stringify(e);i("send %s",r);t.socket.send(r)};d.prototype._generateOffers=function(e,t){var r=this;var a=[];i("generating %s offers",e);for(var o=0;o<e;++o){u()}function u(){var e=n(160);var t=r.peers[e]=new s({initiator:true,trickle:false,config:r.client._rtcConfig,wrtc:r.client._wrtc});t.once("signal",function(t){a.push({offer:t,offer_id:f.hexToBinary(e)});l()})}function l(){if(a.length===e){i("generated %s offers",e);t(a)}}};function h(){}},{"../common":27,"./tracker":24,debug:120,hat:126,inherits:128,"simple-peer":30,"simple-websocket":34}],26:[function(e,t,r){(function(t){var i=e("querystring");r.IPV4_RE=/^[\d\.]+$/;r.IPV6_RE=/^[\da-fA-F:]+$/;r.CONNECTION_ID=t.concat([n(1047),n(655366528)]);r.ACTIONS={CONNECT:0,ANNOUNCE:1,SCRAPE:2,ERROR:3};r.EVENTS={update:0,completed:1,started:2,stopped:3};r.EVENT_IDS={0:"update",1:"completed",2:"started",3:"stopped"};r.EVENT_NAMES={update:"update",completed:"complete",started:"start",stopped:"stop"};function n(e){var r=new t(4);r.writeUInt32BE(e,0);return r}r.toUInt32=n;r.querystringParse=function(e){var t=i.unescape;i.unescape=unescape;var r=i.parse(e);i.unescape=t;return r};r.querystringStringify=function(e){var t=i.escape;i.escape=escape;var r=i.stringify(e);r=r.replace(/[\@\*\/\+]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()});i.escape=t;return r}}).call(this,e("buffer").Buffer)},{buffer:39,querystring:52}],27:[function(e,t,r){(function(t){var i=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 n=e("./common-node");i(r,n)}).call(this,e("buffer").Buffer)},{"./common-node":26,buffer:39,"xtend/mutable":182}],28:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],29:[function(e,t,r){var i=e("wrappy");t.exports=i(n);n.proto=n(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:true})});function n(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:28}],30:[function(e,t,r){(function(r){t.exports=c;var i=e("debug")("simple-peer");var n=e("get-browser-rtc");var a=e("hat");var s=e("inherits");var o=e("is-typedarray");var f=e("once");var u=e("stream");var l=e("typedarray-to-buffer");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.channelName||a(160);if(!e.initiator)t.channelName=null;t.config=e.config||c.config;t.constraints=e.constraints||c.constraints;t.reconnectTimer=e.reconnectTimer||0;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._wrtc=e.wrtc||n();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=!!n();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 i(e){try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e),p,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(i);t._pendingCandidates=[]},t._onError.bind(t))}if(e.candidate){if(t._pc.remoteDescription)i(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(!o.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)&&!o.strict(e)){e=new Uint8Array(e)}var i=e.length||e.byteLength||e.size;t._channel.send(e);t._debug("write: %d bytes",i)};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 i=this;if(i.destroyed)return r(new Error("cannot write after peer is destroyed"));if(i.connected){try{i.send(e)}catch(n){return i._onError(n)}if(i._channel.bufferedAmount>i._maxBufferedAmount){i._debug("start backpressure: bufferedAmount %d",i._channel.bufferedAmount);i._cb=r}else{r(null)}}else{i._debug("write before connect");i._chunk=e;i._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,p,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,p,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==="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(typeof window!=="undefined"&&!!window.mozRTCPeerConnection){e._pc.getStats(null,function(e){var r=[];e.forEach(function(e){r.push(e)});t(r)},e._onError.bind(e))}else{e._pc.getStats(function(e){var r=[];e.result().forEach(function(e){var t={};e.names().forEach(function(r){t[r]=e.stat(r)});t.id=e.id;t.type=e.type;t.timestamp=e.timestamp;r.push(t)});t(r)})}function t(t){t.forEach(function(t){if(t.type==="remotecandidate"){e.remoteAddress=t.ipAddress;e.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 i=e._cb;e._cb=null;i(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 r=e.data;t._debug("read: %d bytes",r.byteLength||r.length);if(r instanceof ArrayBuffer){r=l(new Uint8Array(r));t.push(r)}else{try{r=JSON.parse(r)}catch(i){}t.emit("data",r)}};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];i.apply(null,t)};function p(){}}).call(this,e("buffer").Buffer)},{buffer:39,debug:120,"get-browser-rtc":31,hat:126,inherits:128,"is-typedarray":32,once:29,stream:66,"typedarray-to-buffer":33}],31:[function(e,t,r){t.exports=function i(){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}},{}],32:[function(e,t,r){t.exports=a;a.strict=s;a.loose=o;var i=Object.prototype.toString;var n={"[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 a(e){return s(e)||o(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 o(e){return n[i.call(e)]}},{}],33:[function(e,t,r){(function(r){var i=e("is-typedarray").strict;t.exports=function(e){var t=r.TYPED_ARRAY_SUPPORT?r._augment:function(e){return new r(e)};if(e instanceof Uint8Array){return t(e)}else if(e instanceof ArrayBuffer){return t(new Uint8Array(e))}else if(i(e)){return t(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}else{return new r(e)}}}).call(this,e("buffer").Buffer)},{buffer:39,"is-typedarray":32}],34:[function(e,t,r){(function(r){t.exports=l;var i=e("debug")("simple-websocket");var n=e("inherits");var a=e("is-typedarray");var s=e("stream");var o=e("typedarray-to-buffer");var f=e("ws");var u=typeof window!=="undefined"?window.WebSocket:f;n(l,s.Duplex);function l(e,t){var r=this;if(!(r instanceof l))return new l(e,t);if(!t)t={};i("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 u(r.url);r._ws.binaryType="arraybuffer";r._ws.onopen=r._onOpen.bind(r);r._ws.onmessage=r._onMessage.bind(r);r._ws.onclose=r._onClose.bind(r);r._ws.onerror=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)})}})}l.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)}var n=e.length||e.byteLength||e.size;t._ws.send(e);i("write: %d bytes",n)};l.prototype.destroy=function(e){var t=this;t._destroy(null,e)};l.prototype._destroy=function(e,t){var r=this;if(r.destroyed)return;if(t)r.once("close",t);i("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 n=r._ws;var a=function(){n.onclose=null;r.emit("close")};if(n.readyState===u.CLOSED){a()}else{try{n.onclose=a;n.close()}catch(e){a()}}n.onopen=null;n.onmessage=null;n.onerror=null}r._ws=null;if(e)r.emit("error",e)};l.prototype._read=function(){};l.prototype._write=function(e,t,r){var n=this;if(n.destroyed)return r(new Error("cannot write after socket is destroyed"));if(n.connected){try{n.send(e)}catch(a){return n._onError(a)}if(typeof f!=="function"&&n._ws.bufferedAmount>n._maxBufferedAmount){i("start backpressure: bufferedAmount %d",n._ws.bufferedAmount);n._cb=r}else{r(null)}}else{i("write before connect");n._chunk=e;n._cb=r}};l.prototype._onMessage=function(e){var t=this;if(t.destroyed)return;var n=e.data;i("read: %d bytes",n.byteLength||n.length);if(n instanceof ArrayBuffer){n=o(new Uint8Array(n));t.push(n)}else if(r.isBuffer(n)){t.push(n)}else{try{n=JSON.parse(n)}catch(a){}t.emit("data",n)}};l.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;i('sent chunk from "write before connect"');var r=e._cb;e._cb=null;r(null)}if(typeof f!=="function"){e._interval=setInterval(function(){if(!e._cb||!e._ws||e._ws.bufferedAmount>e._maxBufferedAmount){return}i("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null;t(null)},150);if(e._interval.unref)e._interval.unref()}i("connect");e.emit("connect")};l.prototype._onClose=function(){var e=this;if(e.destroyed)return;i("on close");e._destroy()};l.prototype._onError=function(e){var t=this;if(t.destroyed)return;i("error: %s",e.message||e);t._destroy(e)}}).call(this,e("buffer").Buffer)},{buffer:39,debug:120,inherits:128,"is-typedarray":35,stream:66,"typedarray-to-buffer":36,ws:38}],35:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],36:[function(e,t,r){arguments[4][33][0].apply(r,arguments)},{buffer:39,dup:33,"is-typedarray":35}],37:[function(e,t,r){},{}],38:[function(e,t,r){arguments[4][37][0].apply(r,arguments)},{dup:37}],39:[function(e,t,r){var i=e("base64-js");var n=e("ieee754");var a=e("is-array");r.Buffer=f;r.SlowBuffer=b;r.INSPECT_MAX_BYTES=50;f.poolSize=8192;var s={};f.TYPED_ARRAY_SUPPORT=function(){function e(){}try{var t=new Uint8Array(1);t.foo=function(){return 42};t.constructor=e;return t.foo()===42&&t.constructor===e&&typeof t.subarray==="function"&&t.subarray(1,1).byteLength===0}catch(r){return false}}();function o(){return f.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(e){if(!(this instanceof f)){if(arguments.length>1)return new f(e,arguments[1]);return new f(e)}this.length=0;this.parent=undefined;if(typeof e==="number"){return u(this,e)}if(typeof e==="string"){return l(this,e,arguments.length>1?arguments[1]:"utf8")}return c(this,e)}function u(e,t){e=y(e,t<0?0:_(t)|0);if(!f.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 i=w(t,r)|0;e=y(e,i);e.write(t,r);return e}function c(e,t){if(f.isBuffer(t))return p(e,t);if(a(t))return d(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 h(e,t)}if(t instanceof ArrayBuffer){return m(e,t)}}if(t.length)return v(e,t);return g(e,t)}function p(e,t){var r=_(t.length)|0;e=y(e,r);t.copy(e,0,0,r);return e}function d(e,t){var r=_(t.length)|0;e=y(e,r);for(var i=0;i<r;i+=1){e[i]=t[i]&255}return e}function h(e,t){var r=_(t.length)|0;e=y(e,r);for(var i=0;i<r;i+=1){e[i]=t[i]&255}return e}function m(e,t){if(f.TYPED_ARRAY_SUPPORT){t.byteLength;e=f._augment(new Uint8Array(t))}else{e=h(e,new Uint8Array(t))}return e}function v(e,t){var r=_(t.length)|0;e=y(e,r);for(var i=0;i<r;i+=1){e[i]=t[i]&255}return e}function g(e,t){var r;var i=0;if(t.type==="Buffer"&&a(t.data)){r=t.data;i=_(r.length)|0}e=y(e,i);for(var n=0;n<i;n+=1){e[n]=r[n]&255}return e}function y(e,t){if(f.TYPED_ARRAY_SUPPORT){e=f._augment(new Uint8Array(t))}else{e.length=t;e._isBuffer=true}var r=t!==0&&t<=f.poolSize>>>1;if(r)e.parent=s;return e}function _(e){if(e>=o()){throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+o().toString(16)+" bytes")}return e|0}function b(e,t){if(!(this instanceof b))return new b(e,t);var r=new f(e,t);delete r.parent;return r}f.isBuffer=function ee(e){return!!(e!=null&&e._isBuffer)};f.compare=function te(e,t){if(!f.isBuffer(e)||!f.isBuffer(t)){throw new TypeError("Arguments must be Buffers")}if(e===t)return 0;var r=e.length;var i=t.length;var n=0;var a=Math.min(r,i);while(n<a){if(e[n]!==t[n])break;++n}if(n!==a){r=e[n];i=t[n]}if(r<i)return-1;if(i<r)return 1;return 0};f.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}};f.concat=function ie(e,t){if(!a(e))throw new TypeError("list argument must be an Array of Buffers.");if(e.length===0){return new f(0)}var r;if(t===undefined){t=0;for(r=0;r<e.length;r++){t+=e[r].length}}var i=new f(t);var n=0;for(r=0;r<e.length;r++){var s=e[r];s.copy(i,n);n+=s.length}return i};function w(e,t){if(typeof e!=="string")e=""+e;var r=e.length;if(r===0)return 0;var i=false;for(;;){switch(t){case"ascii":case"binary":case"raw":case"raws":return r;case"utf8":case"utf-8":return $(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return J(e).length;default:if(i)return $(e).length;t=(""+t).toLowerCase();i=true}}}f.byteLength=w;f.prototype.length=undefined;f.prototype.parent=undefined;function x(e,t,r){var i=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 R(this,t,r);case"binary":return P(this,t,r);case"base64":return T(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return z(this,t,r);default:if(i)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase();i=true}}}f.prototype.toString=function ne(){var e=this.length|0;if(e===0)return"";if(arguments.length===0)return L(this,0,e);return x.apply(this,arguments)};f.prototype.equals=function ae(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return true;return f.compare(this,e)===0};f.prototype.inspect=function 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+">"};f.prototype.compare=function oe(e){if(!f.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(this===e)return 0;return f.compare(this,e)};f.prototype.indexOf=function 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(f.isBuffer(e)){return r(this,e,t)}if(typeof e==="number"){if(f.TYPED_ARRAY_SUPPORT&&Uint8Array.prototype.indexOf==="function"){return Uint8Array.prototype.indexOf.call(this,e,t)}return r(this,[e],t)}function r(e,t,r){var i=-1;for(var n=0;r+n<e.length;n++){if(e[r+n]===t[i===-1?0:n-i]){if(i===-1)i=n;if(n-i+1===t.length)return r+i}else{i=-1}}return-1}throw new TypeError("val must be string, number or Buffer")};f.prototype.get=function ue(e){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(e)};f.prototype.set=function le(e,t){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(e,t)};function k(e,t,r,i){r=Number(r)||0;var n=e.length-r;if(!i){i=n}else{i=Number(i);if(i>n){i=n}}var a=t.length;if(a%2!==0)throw new Error("Invalid hex string");if(i>a/2){i=a/2}for(var s=0;s<i;s++){var o=parseInt(t.substr(s*2,2),16);if(isNaN(o))throw new Error("Invalid hex string");e[r+s]=o}return s}function S(e,t,r,i){return Q($(t,e.length-r),e,r,i)}function E(e,t,r,i){return Q(Z(t),e,r,i)}function A(e,t,r,i){return E(e,t,r,i)}function U(e,t,r,i){return Q(J(t),e,r,i)}function I(e,t,r,i){return Q(X(t,e.length-r),e,r,i)}f.prototype.write=function ce(e,t,r,i){if(t===undefined){i="utf8";r=this.length;t=0}else if(r===undefined&&typeof t==="string"){i=t;r=this.length;t=0}else if(isFinite(t)){t=t|0;if(isFinite(r)){r=r|0;if(i===undefined)i="utf8"}else{i=r;r=undefined}}else{var n=i;i=t;t=r|0;r=n}var a=this.length-t;if(r===undefined||r>a)r=a;if(e.length>0&&(r<0||t<0)||t>this.length){throw new RangeError("attempt to write outside buffer bounds")}if(!i)i="utf8";var s=false;for(;;){switch(i){case"hex":return k(this,e,t,r);case"utf8":case"utf-8":return S(this,e,t,r);case"ascii":return E(this,e,t,r);case"binary":return A(this,e,t,r);case"base64":return U(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase();s=true}}};f.prototype.toJSON=function pe(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function T(e,t,r){if(t===0&&r===e.length){return i.fromByteArray(e)}else{return i.fromByteArray(e.slice(t,r))}}function L(e,t,r){r=Math.min(e.length,r);var i=[];var n=t;while(n<r){var a=e[n];var s=null;var o=a>239?4:a>223?3:a>191?2:1;if(n+o<=r){var f,u,l,c;switch(o){case 1:if(a<128){s=a}break;case 2:f=e[n+1];if((f&192)===128){c=(a&31)<<6|f&63;if(c>127){s=c}}break;case 3:f=e[n+1];u=e[n+2];if((f&192)===128&&(u&192)===128){c=(a&15)<<12|(f&63)<<6|u&63;if(c>2047&&(c<55296||c>57343)){s=c}}break;case 4:f=e[n+1];u=e[n+2];l=e[n+3];if((f&192)===128&&(u&192)===128&&(l&192)===128){c=(a&15)<<18|(f&63)<<12|(u&63)<<6|l&63;if(c>65535&&c<1114112){s=c}}}}if(s===null){s=65533;o=1}else if(s>65535){s-=65536;i.push(s>>>10&1023|55296);s=56320|s&1023}i.push(s);n+=o}return C(i)}var B=4096;function C(e){var t=e.length;if(t<=B){return String.fromCharCode.apply(String,e)}var r="";var i=0;while(i<t){r+=String.fromCharCode.apply(String,e.slice(i,i+=B))}return r}function R(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;n++){i+=String.fromCharCode(e[n]&127)}return i}function P(e,t,r){var i="";r=Math.min(e.length,r);for(var n=t;n<r;n++){i+=String.fromCharCode(e[n])}return i}function O(e,t,r){var i=e.length;if(!t||t<0)t=0;if(!r||r<0||r>i)r=i;var n="";for(var a=t;a<r;a++){n+=K(e[a])}return n}function z(e,t,r){var i=e.slice(t,r);var n="";for(var a=0;a<i.length;a+=2){n+=String.fromCharCode(i[a]+i[a+1]*256)}return n}f.prototype.slice=function de(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 i;if(f.TYPED_ARRAY_SUPPORT){i=f._augment(this.subarray(e,t))}else{var n=t-e;i=new f(n,undefined);for(var a=0;a<n;a++){i[a]=this[a+e]}}if(i.length)i.parent=this.parent||this;return i};function F(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}f.prototype.readUIntLE=function he(e,t,r){e=e|0;t=t|0;if(!r)F(e,t,this.length);var i=this[e];var n=1;var a=0;while(++a<t&&(n*=256)){i+=this[e+a]*n}return i};f.prototype.readUIntBE=function me(e,t,r){e=e|0;t=t|0;if(!r){F(e,t,this.length)}var i=this[e+--t];var n=1;while(t>0&&(n*=256)){i+=this[e+--t]*n}return i};f.prototype.readUInt8=function ve(e,t){if(!t)F(e,1,this.length);return this[e]};f.prototype.readUInt16LE=function ge(e,t){if(!t)F(e,2,this.length);return this[e]|this[e+1]<<8};f.prototype.readUInt16BE=function ye(e,t){if(!t)F(e,2,this.length);return this[e]<<8|this[e+1]};f.prototype.readUInt32LE=function _e(e,t){if(!t)F(e,4,this.length);return(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};f.prototype.readUInt32BE=function be(e,t){if(!t)F(e,4,this.length);return this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};f.prototype.readIntLE=function we(e,t,r){e=e|0;t=t|0;if(!r)F(e,t,this.length);var i=this[e];var n=1;var a=0;while(++a<t&&(n*=256)){i+=this[e+a]*n}n*=128;if(i>=n)i-=Math.pow(2,8*t);return i};f.prototype.readIntBE=function xe(e,t,r){e=e|0;t=t|0;if(!r)F(e,t,this.length);var i=t;var n=1;var a=this[e+--i];while(i>0&&(n*=256)){a+=this[e+--i]*n}n*=128;if(a>=n)a-=Math.pow(2,8*t);return a};f.prototype.readInt8=function ke(e,t){if(!t)F(e,1,this.length);if(!(this[e]&128))return this[e];return(255-this[e]+1)*-1};f.prototype.readInt16LE=function Se(e,t){if(!t)F(e,2,this.length);var r=this[e]|this[e+1]<<8;return r&32768?r|4294901760:r};f.prototype.readInt16BE=function Ee(e,t){if(!t)F(e,2,this.length);var r=this[e+1]|this[e]<<8;return r&32768?r|4294901760:r};f.prototype.readInt32LE=function Ae(e,t){if(!t)F(e,4,this.length);return this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};f.prototype.readInt32BE=function Ue(e,t){if(!t)F(e,4,this.length);return this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};f.prototype.readFloatLE=function Ie(e,t){if(!t)F(e,4,this.length);return n.read(this,e,true,23,4)};f.prototype.readFloatBE=function Te(e,t){if(!t)F(e,4,this.length);return n.read(this,e,false,23,4)};f.prototype.readDoubleLE=function Le(e,t){if(!t)F(e,8,this.length);return n.read(this,e,true,52,8)};f.prototype.readDoubleBE=function Be(e,t){if(!t)F(e,8,this.length);return n.read(this,e,false,52,8)};function M(e,t,r,i,n,a){if(!f.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>n||t<a)throw new RangeError("value is out of bounds");if(r+i>e.length)throw new RangeError("index out of range")}f.prototype.writeUIntLE=function Ce(e,t,r,i){e=+e;t=t|0;r=r|0;if(!i)M(this,e,t,r,Math.pow(2,8*r),0);var n=1;var a=0;this[t]=e&255;while(++a<r&&(n*=256)){this[t+a]=e/n&255}return t+r};f.prototype.writeUIntBE=function Re(e,t,r,i){e=+e;t=t|0;r=r|0;if(!i)M(this,e,t,r,Math.pow(2,8*r),0);var n=r-1;var a=1;this[t+n]=e&255;while(--n>=0&&(a*=256)){this[t+n]=e/a&255}return t+r};f.prototype.writeUInt8=function Pe(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,1,255,0);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);this[t]=e;return t+1};function j(e,t,r,i){if(t<0)t=65535+t+1;for(var n=0,a=Math.min(e.length-r,2);n<a;n++){e[r+n]=(t&255<<8*(i?n:1-n))>>>(i?n:1-n)*8}}f.prototype.writeUInt16LE=function Oe(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeUInt16BE=function ze(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,2,65535,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};function D(e,t,r,i){if(t<0)t=4294967295+t+1;for(var n=0,a=Math.min(e.length-r,4);n<a;n++){e[r+n]=t>>>(i?n:3-n)*8&255}}f.prototype.writeUInt32LE=function Fe(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t+3]=e>>>24;this[t+2]=e>>>16;this[t+1]=e>>>8;this[t]=e}else{D(this,e,t,true)}return t+4};f.prototype.writeUInt32BE=function Me(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,4,4294967295,0);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{D(this,e,t,false)}return t+4};f.prototype.writeIntLE=function je(e,t,r,i){e=+e;t=t|0;if(!i){var n=Math.pow(2,8*r-1);M(this,e,t,r,n-1,-n)}var a=0;var s=1;var o=e<0?1:0;this[t]=e&255;while(++a<r&&(s*=256)){this[t+a]=(e/s>>0)-o&255}return t+r};f.prototype.writeIntBE=function De(e,t,r,i){e=+e;t=t|0;if(!i){var n=Math.pow(2,8*r-1);M(this,e,t,r,n-1,-n)}var a=r-1;var s=1;var o=e<0?1:0;this[t+a]=e&255;while(--a>=0&&(s*=256)){this[t+a]=(e/s>>0)-o&255}return t+r};f.prototype.writeInt8=function Ne(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,1,127,-128);if(!f.TYPED_ARRAY_SUPPORT)e=Math.floor(e);if(e<0)e=255+e+1;this[t]=e;return t+1};f.prototype.writeInt16LE=function He(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e;this[t+1]=e>>>8}else{j(this,e,t,true)}return t+2};f.prototype.writeInt16BE=function qe(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,2,32767,-32768);if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>8;this[t+1]=e}else{j(this,e,t,false)}return t+2};f.prototype.writeInt32LE=function Ge(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,4,2147483647,-2147483648);if(f.TYPED_ARRAY_SUPPORT){
+this[t]=e;this[t+1]=e>>>8;this[t+2]=e>>>16;this[t+3]=e>>>24}else{D(this,e,t,true)}return t+4};f.prototype.writeInt32BE=function We(e,t,r){e=+e;t=t|0;if(!r)M(this,e,t,4,2147483647,-2147483648);if(e<0)e=4294967295+e+1;if(f.TYPED_ARRAY_SUPPORT){this[t]=e>>>24;this[t+1]=e>>>16;this[t+2]=e>>>8;this[t+3]=e}else{D(this,e,t,false)}return t+4};function N(e,t,r,i,n,a){if(t>n||t<a)throw new RangeError("value is out of bounds");if(r+i>e.length)throw new RangeError("index out of range");if(r<0)throw new RangeError("index out of range")}function H(e,t,r,i,a){if(!a){N(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38)}n.write(e,t,r,i,23,4);return r+4}f.prototype.writeFloatLE=function Ve(e,t,r){return H(this,e,t,true,r)};f.prototype.writeFloatBE=function Ye(e,t,r){return H(this,e,t,false,r)};function q(e,t,r,i,a){if(!a){N(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308)}n.write(e,t,r,i,52,8);return r+8}f.prototype.writeDoubleLE=function Ke(e,t,r){return q(this,e,t,true,r)};f.prototype.writeDoubleBE=function $e(e,t,r){return q(this,e,t,false,r)};f.prototype.copy=function Ze(e,t,r,i){if(!r)r=0;if(!i&&i!==0)i=this.length;if(t>=e.length)t=e.length;if(!t)t=0;if(i>0&&i<r)i=r;if(i===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(i<0)throw new RangeError("sourceEnd out of bounds");if(i>this.length)i=this.length;if(e.length-t<i-r){i=e.length-t+r}var n=i-r;var a;if(this===e&&r<t&&t<i){for(a=n-1;a>=0;a--){e[a+t]=this[a+r]}}else if(n<1e3||!f.TYPED_ARRAY_SUPPORT){for(a=0;a<n;a++){e[a+t]=this[a+r]}}else{e._set(this.subarray(r,r+n),t)}return n};f.prototype.fill=function Xe(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 i;if(typeof e==="number"){for(i=t;i<r;i++){this[i]=e}}else{var n=$(e.toString());var a=n.length;for(i=t;i<r;i++){this[i]=n[i%a]}}return this};f.prototype.toArrayBuffer=function Je(){if(typeof Uint8Array!=="undefined"){if(f.TYPED_ARRAY_SUPPORT){return new f(this).buffer}else{var e=new Uint8Array(this.length);for(var t=0,r=e.length;t<r;t+=1){e[t]=this[t]}return e.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var G=f.prototype;f._augment=function Qe(e){e.constructor=f;e._isBuffer=true;e._set=e.set;e.get=G.get;e.set=G.set;e.write=G.write;e.toString=G.toString;e.toLocaleString=G.toString;e.toJSON=G.toJSON;e.equals=G.equals;e.compare=G.compare;e.indexOf=G.indexOf;e.copy=G.copy;e.slice=G.slice;e.readUIntLE=G.readUIntLE;e.readUIntBE=G.readUIntBE;e.readUInt8=G.readUInt8;e.readUInt16LE=G.readUInt16LE;e.readUInt16BE=G.readUInt16BE;e.readUInt32LE=G.readUInt32LE;e.readUInt32BE=G.readUInt32BE;e.readIntLE=G.readIntLE;e.readIntBE=G.readIntBE;e.readInt8=G.readInt8;e.readInt16LE=G.readInt16LE;e.readInt16BE=G.readInt16BE;e.readInt32LE=G.readInt32LE;e.readInt32BE=G.readInt32BE;e.readFloatLE=G.readFloatLE;e.readFloatBE=G.readFloatBE;e.readDoubleLE=G.readDoubleLE;e.readDoubleBE=G.readDoubleBE;e.writeUInt8=G.writeUInt8;e.writeUIntLE=G.writeUIntLE;e.writeUIntBE=G.writeUIntBE;e.writeUInt16LE=G.writeUInt16LE;e.writeUInt16BE=G.writeUInt16BE;e.writeUInt32LE=G.writeUInt32LE;e.writeUInt32BE=G.writeUInt32BE;e.writeIntLE=G.writeIntLE;e.writeIntBE=G.writeIntBE;e.writeInt8=G.writeInt8;e.writeInt16LE=G.writeInt16LE;e.writeInt16BE=G.writeInt16BE;e.writeInt32LE=G.writeInt32LE;e.writeInt32BE=G.writeInt32BE;e.writeFloatLE=G.writeFloatLE;e.writeFloatBE=G.writeFloatBE;e.writeDoubleLE=G.writeDoubleLE;e.writeDoubleBE=G.writeDoubleBE;e.fill=G.fill;e.inspect=G.inspect;e.toArrayBuffer=G.toArrayBuffer;return e};var W=/[^+\/0-9A-Za-z-_]/g;function V(e){e=Y(e).replace(W,"");if(e.length<2)return"";while(e.length%4!==0){e=e+"="}return e}function Y(e){if(e.trim)return e.trim();return e.replace(/^\s+|\s+$/g,"")}function K(e){if(e<16)return"0"+e.toString(16);return e.toString(16)}function $(e,t){t=t||Infinity;var r;var i=e.length;var n=null;var a=[];for(var s=0;s<i;s++){r=e.charCodeAt(s);if(r>55295&&r<57344){if(!n){if(r>56319){if((t-=3)>-1)a.push(239,191,189);continue}else if(s+1===i){if((t-=3)>-1)a.push(239,191,189);continue}n=r;continue}if(r<56320){if((t-=3)>-1)a.push(239,191,189);n=r;continue}r=n-55296<<10|r-56320|65536}else if(n){if((t-=3)>-1)a.push(239,191,189)}n=null;if(r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else{throw new Error("Invalid code point")}}return a}function Z(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,i,n;var a=[];for(var s=0;s<e.length;s++){if((t-=2)<0)break;r=e.charCodeAt(s);i=r>>8;n=r%256;a.push(n);a.push(i)}return a}function J(e){return i.toByteArray(V(e))}function Q(e,t,r,i){for(var n=0;n<i;n++){if(n+r>=t.length||n>=e.length)break;t[n+r]=e[n]}return n}},{"base64-js":40,ieee754:41,"is-array":42}],40:[function(e,t,r){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(e){"use strict";var t=typeof Uint8Array!=="undefined"?Uint8Array:Array;var r="+".charCodeAt(0);var n="/".charCodeAt(0);var a="0".charCodeAt(0);var s="a".charCodeAt(0);var o="A".charCodeAt(0);var f="-".charCodeAt(0);var u="_".charCodeAt(0);function l(e){var t=e.charCodeAt(0);if(t===r||t===f)return 62;if(t===n||t===u)return 63;if(t<a)return-1;if(t<a+10)return t-a+26+26;if(t<o+26)return t-o;if(t<s+26)return t-s+26}function c(e){var r,i,n,a,s,o;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;o=new t(e.length*3/4-s);n=s>0?e.length-4:e.length;var u=0;function c(e){o[u++]=e}for(r=0,i=0;r<n;r+=4,i+=3){a=l(e.charAt(r))<<18|l(e.charAt(r+1))<<12|l(e.charAt(r+2))<<6|l(e.charAt(r+3));c((a&16711680)>>16);c((a&65280)>>8);c(a&255)}if(s===2){a=l(e.charAt(r))<<2|l(e.charAt(r+1))>>4;c(a&255)}else if(s===1){a=l(e.charAt(r))<<10|l(e.charAt(r+1))<<4|l(e.charAt(r+2))>>2;c(a>>8&255);c(a&255)}return o}function p(e){var t,r=e.length%3,n="",a,s;function o(e){return i.charAt(e)}function f(e){return o(e>>18&63)+o(e>>12&63)+o(e>>6&63)+o(e&63)}for(t=0,s=e.length-r;t<s;t+=3){a=(e[t]<<16)+(e[t+1]<<8)+e[t+2];n+=f(a)}switch(r){case 1:a=e[e.length-1];n+=o(a>>2);n+=o(a<<4&63);n+="==";break;case 2:a=(e[e.length-2]<<8)+e[e.length-1];n+=o(a>>10);n+=o(a>>4&63);n+=o(a<<2&63);n+="=";break}return n}e.toByteArray=c;e.fromByteArray=p})(typeof r==="undefined"?this.base64js={}:r)},{}],41:[function(e,t,r){r.read=function(e,t,r,i,n){var a,s;var o=n*8-i-1;var f=(1<<o)-1;var u=f>>1;var l=-7;var c=r?n-1:0;var p=r?-1:1;var d=e[t+c];c+=p;a=d&(1<<-l)-1;d>>=-l;l+=o;for(;l>0;a=a*256+e[t+c],c+=p,l-=8){}s=a&(1<<-l)-1;a>>=-l;l+=i;for(;l>0;s=s*256+e[t+c],c+=p,l-=8){}if(a===0){a=1-u}else if(a===f){return s?NaN:(d?-1:1)*Infinity}else{s=s+Math.pow(2,i);a=a-u}return(d?-1:1)*s*Math.pow(2,a-i)};r.write=function(e,t,r,i,n,a){var s,o,f;var u=a*8-n-1;var l=(1<<u)-1;var c=l>>1;var p=n===23?Math.pow(2,-24)-Math.pow(2,-77):0;var d=i?0:a-1;var h=i?1:-1;var m=t<0||t===0&&1/t<0?1:0;t=Math.abs(t);if(isNaN(t)||t===Infinity){o=isNaN(t)?1:0;s=l}else{s=Math.floor(Math.log(t)/Math.LN2);if(t*(f=Math.pow(2,-s))<1){s--;f*=2}if(s+c>=1){t+=p/f}else{t+=p*Math.pow(2,1-c)}if(t*f>=2){s++;f/=2}if(s+c>=l){o=0;s=l}else if(s+c>=1){o=(t*f-1)*Math.pow(2,n);s=s+c}else{o=t*Math.pow(2,c-1)*Math.pow(2,n);s=0}}for(;n>=8;e[r+d]=o&255,d+=h,o/=256,n-=8){}s=s<<n|o;u+=n;for(;u>0;e[r+d]=s&255,d+=h,s/=256,u-=8){}e[r+d-h]|=m*128}},{}],42:[function(e,t,r){var i=Array.isArray;var n=Object.prototype.toString;t.exports=i||function(e){return!!e&&"[object Array]"==n.call(e)}},{}],43:[function(e,t,r){function i(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=i;i.EventEmitter=i;i.prototype._events=undefined;i.prototype._maxListeners=undefined;i.defaultMaxListeners=10;i.prototype.setMaxListeners=function(e){if(!a(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};i.prototype.emit=function(e){var t,r,i,a,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(o(r))return false;if(n(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:i=arguments.length;a=new Array(i-1);for(f=1;f<i;f++)a[f-1]=arguments[f];r.apply(this,a)}}else if(s(r)){i=arguments.length;a=new Array(i-1);for(f=1;f<i;f++)a[f-1]=arguments[f];u=r.slice();i=u.length;for(f=0;f<i;f++)u[f].apply(this,a)}return true};i.prototype.addListener=function(e,t){var r;if(!n(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,n(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(s(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(s(this._events[e])&&!this._events[e].warned){var r;if(!o(this._maxListeners)){r=this._maxListeners}else{r=i.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};i.prototype.on=i.prototype.addListener;i.prototype.once=function(e,t){if(!n(t))throw TypeError("listener must be a function");var r=false;function i(){this.removeListener(e,i);if(!r){r=true;t.apply(this,arguments)}}i.listener=t;this.on(e,i);return this};i.prototype.removeListener=function(e,t){var r,i,a,o;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;r=this._events[e];a=r.length;i=-1;if(r===t||n(r.listener)&&r.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(s(r)){for(o=a;o-->0;){if(r[o]===t||r[o].listener&&r[o].listener===t){i=o;break}}if(i<0)return this;if(r.length===1){r.length=0;delete this._events[e]}else{r.splice(i,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};i.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(n(r)){this.removeListener(e,r)}else{while(r.length)this.removeListener(e,r[r.length-1])}delete this._events[e];return this};i.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(n(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};i.listenerCount=function(e,t){var r;if(!e._events||!e._events[t])r=0;else if(n(e._events[t]))r=1;else r=e._events[t].length;return r};function n(e){return typeof e==="function"}function a(e){return typeof e==="number"}function s(e){return typeof e==="object"&&e!==null}function o(e){return e===void 0}},{}],44:[function(e,t,r){var i=e("http");var n=t.exports;for(var a in i){if(i.hasOwnProperty(a))n[a]=i[a]}n.request=function(e,t){if(!e)e={};e.scheme="https";return i.request.call(this,e,t)}},{http:67}],45:[function(e,t,r){t.exports=Array.isArray||function(e){return Object.prototype.toString.call(e)=="[object Array]"}},{}],46:[function(e,t,r){r.endianness=function(){return"LE"};r.hostname=function(){if(typeof location!=="undefined"){return location.hostname}else return""};r.loadavg=function(){return[]};r.uptime=function(){return 0};r.freemem=function(){return Number.MAX_VALUE};r.totalmem=function(){return Number.MAX_VALUE};r.cpus=function(){return[]};r.type=function(){return"Browser"};r.release=function(){if(typeof navigator!=="undefined"){return navigator.appVersion}return""};r.networkInterfaces=r.getNetworkInterfaces=function(){return{}};r.arch=function(){return"javascript"};r.platform=function(){return"browser"};r.tmpdir=r.tmpDir=function(){return"/tmp"};r.EOL="\n"},{}],47:[function(e,t,r){(function(e){function t(e,t){var r=0;for(var i=e.length-1;i>=0;i--){var n=e[i];if(n==="."){e.splice(i,1)}else if(n===".."){e.splice(i,1);r++}else if(r){e.splice(i,1);r--}}if(t){for(;r--;r){e.unshift("..")}}return e}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;var n=function(e){return i.exec(e).slice(1)};r.resolve=function(){var r="",i=false;for(var n=arguments.length-1;n>=-1&&!i;n--){var s=n>=0?arguments[n]:e.cwd();if(typeof s!=="string"){throw new TypeError("Arguments to path.resolve must be strings")}else if(!s){continue}r=s+"/"+r;i=s.charAt(0)==="/"}r=t(a(r.split("/"),function(e){return!!e}),!i).join("/");return(i?"/":"")+r||"."};r.normalize=function(e){var i=r.isAbsolute(e),n=s(e,-1)==="/";e=t(a(e.split("/"),function(e){return!!e}),!i).join("/");if(!e&&!i){e="."}if(e&&n){e+="/"}return(i?"/":"")+e};r.isAbsolute=function(e){return e.charAt(0)==="/"};r.join=function(){var e=Array.prototype.slice.call(arguments,0);return r.normalize(a(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 i(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 n=i(e.split("/"));var a=i(t.split("/"));var s=Math.min(n.length,a.length);var o=s;for(var f=0;f<s;f++){if(n[f]!==a[f]){o=f;break}}var u=[];for(var f=o;f<n.length;f++){u.push("..")}u=u.concat(a.slice(o));return u.join("/")};r.sep="/";r.delimiter=":";r.dirname=function(e){var t=n(e),r=t[0],i=t[1];if(!r&&!i){return"."}if(i){i=i.substr(0,i.length-1)}return r+i};r.basename=function(e,t){var r=n(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 n(e)[3]};function a(e,t){if(e.filter)return e.filter(t);var r=[];for(var i=0;i<e.length;i++){if(t(e[i],i,e))r.push(e[i])}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:48}],48:[function(e,t,r){var i=t.exports={};var n=[];var a=false;var s;var o=-1;function f(){a=false;if(s.length){n=s.concat(n)}else{o=-1}if(n.length){u()}}function u(){if(a){return}var e=setTimeout(f);a=true;var t=n.length;while(t){s=n;n=[];while(++o<t){s[o].run()}o=-1;t=n.length}s=null;a=false;clearTimeout(e)}i.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]}}n.push(new l(e,t));if(n.length===1&&!a){setTimeout(u,0)}};function l(e,t){this.fun=e;this.array=t}l.prototype.run=function(){this.fun.apply(null,this.array)};i.title="browser";i.browser=true;i.env={};i.argv=[];i.version="";i.versions={};function c(){}i.on=c;i.addListener=c;i.once=c;i.off=c;i.removeListener=c;i.removeAllListeners=c;i.emit=c;i.binding=function(e){throw new Error("process.binding is not supported")};i.cwd=function(){return"/"};i.chdir=function(e){throw new Error("process.chdir is not supported")};i.umask=function(){return 0}},{}],49:[function(t,r,i){(function(t){(function(n){var a=typeof i=="object"&&i&&!i.nodeType&&i;var s=typeof r=="object"&&r&&!r.nodeType&&r;var o=typeof t=="object"&&t;if(o.global===o||o.window===o||o.self===o){n=o}var f,u=2147483647,l=36,c=1,p=26,d=38,h=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"},x=l-c,k=Math.floor,S=String.fromCharCode,E;function A(e){throw RangeError(w[e])}function U(e,t){var r=e.length;var i=[];while(r--){i[r]=t(e[r])}return i}function I(e,t){var r=e.split("@");var i="";if(r.length>1){i=r[0]+"@";e=r[1]}e=e.replace(b,".");var n=e.split(".");var a=U(n,t).join(".");return i+a}function T(e){var t=[],r=0,i=e.length,n,a;while(r<i){n=e.charCodeAt(r++);if(n>=55296&&n<=56319&&r<i){a=e.charCodeAt(r++);if((a&64512)==56320){t.push(((n&1023)<<10)+(a&1023)+65536)}else{t.push(n);r--}}else{t.push(n)}}return t}function L(e){return U(e,function(e){var t="";if(e>65535){e-=65536;t+=S(e>>>10&1023|55296);e=56320|e&1023}t+=S(e);return t}).join("")}function B(e){if(e-48<10){return e-22}if(e-65<26){return e-65}if(e-97<26){return e-97}return l}function C(e,t){return e+22+75*(e<26)-((t!=0)<<5)}function R(e,t,r){var i=0;e=r?k(e/h):e>>1;e+=k(e/t);for(;e>x*p>>1;i+=l){e=k(e/x)}return k(i+(x+1)*e/(e+d))}function P(e){var t=[],r=e.length,i,n=0,a=v,s=m,o,f,d,h,y,_,b,w,x;o=e.lastIndexOf(g);if(o<0){o=0}for(f=0;f<o;++f){if(e.charCodeAt(f)>=128){A("not-basic")}t.push(e.charCodeAt(f))}for(d=o>0?o+1:0;d<r;){for(h=n,y=1,_=l;;_+=l){if(d>=r){A("invalid-input")}b=B(e.charCodeAt(d++));if(b>=l||b>k((u-n)/y)){A("overflow")}n+=b*y;w=_<=s?c:_>=s+p?p:_-s;if(b<w){break}x=l-w;if(y>k(u/x)){A("overflow")}y*=x}i=t.length+1;s=R(n-h,i,h==0);if(k(n/i)>u-a){A("overflow")}a+=k(n/i);n%=i;t.splice(n++,0,a)}return L(t)}function O(e){var t,r,i,n,a,s,o,f,d,h,y,_=[],b,w,x,E;e=T(e);b=e.length;t=v;r=0;a=m;for(s=0;s<b;++s){y=e[s];if(y<128){_.push(S(y))}}i=n=_.length;if(n){_.push(g)}while(i<b){for(o=u,s=0;s<b;++s){y=e[s];if(y>=t&&y<o){o=y}}w=i+1;if(o-t>k((u-r)/w)){A("overflow")}r+=(o-t)*w;t=o;for(s=0;s<b;++s){y=e[s];if(y<t&&++r>u){A("overflow")}if(y==t){for(f=r,d=l;;d+=l){h=d<=a?c:d>=a+p?p:d-a;if(f<h){break}E=f-h;x=l-h;_.push(S(C(h+E%x,0)));f=k(E/x)}_.push(S(C(f,0)));a=R(r,w,i==n);r=0;++i}}++r;++t}return _.join("")}function z(e){return I(e,function(e){return y.test(e)?P(e.slice(4).toLowerCase()):e})}function F(e){return I(e,function(e){return _.test(e)?"xn--"+O(e):e})}f={version:"1.3.2",ucs2:{decode:T,encode:L},decode:P,encode:O,toASCII:F,toUnicode:z};if(typeof e=="function"&&typeof e.amd=="object"&&e.amd){e("punycode",function(){return f})}else if(a&&s){if(r.exports==a){s.exports=f}else{for(E in f){f.hasOwnProperty(E)&&(a[E]=f[E])}}}else{n.punycode=f}})(this)}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],50:[function(e,t,r){"use strict";function i(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,r,a){t=t||"&";r=r||"=";var s={};if(typeof e!=="string"||e.length===0){return s}var o=/\+/g;e=e.split(t);var f=1e3;if(a&&typeof a.maxKeys==="number"){f=a.maxKeys}var u=e.length;if(f>0&&u>f){u=f}for(var l=0;l<u;++l){var c=e[l].replace(o,"%20"),p=c.indexOf(r),d,h,m,v;if(p>=0){d=c.substr(0,p);h=c.substr(p+1)}else{d=c;h=""}m=decodeURIComponent(d);v=decodeURIComponent(h);if(!i(s,m)){s[m]=v}else if(n(s[m])){s[m].push(v)}else{s[m]=[s[m],v]}}return s};var n=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"}},{}],51:[function(e,t,r){"use strict";var i=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,o){t=t||"&";r=r||"=";if(e===null){e=undefined}if(typeof e==="object"){return a(s(e),function(s){var o=encodeURIComponent(i(s))+r;if(n(e[s])){return a(e[s],function(e){return o+encodeURIComponent(i(e))}).join(t)}else{return o+encodeURIComponent(i(e[s]))}}).join(t)}if(!o)return"";return encodeURIComponent(i(o))+r+encodeURIComponent(i(e))};var n=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"};function a(e,t){if(e.map)return e.map(t);var r=[];for(var i=0;i<e.length;i++){r.push(t(e[i],i))}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}},{}],52:[function(e,t,r){"use strict";r.decode=r.parse=e("./decode");r.encode=r.stringify=e("./encode")},{"./decode":50,"./encode":51}],53:[function(e,t,r){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":54}],54:[function(e,t,r){"use strict";var i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};t.exports=c;var n=e("process-nextick-args");var a=e("core-util-is");a.inherits=e("inherits");var s=e("./_stream_readable");var o=e("./_stream_writable");a.inherits(c,s);var f=i(o.prototype);for(var u=0;u<f.length;u++){var l=f[u];if(!c.prototype[l])c.prototype[l]=o.prototype[l]}function c(e){if(!(this instanceof c))return new c(e);s.call(this,e);o.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",p)}function p(){if(this.allowHalfOpen||this._writableState.ended)return;n(d,this)}function d(e){e.end()}function h(e,t){for(var r=0,i=e.length;r<i;r++){t(e[r],r)}}},{"./_stream_readable":56,"./_stream_writable":58,"core-util-is":59,inherits:128,"process-nextick-args":60}],55:[function(e,t,r){"use strict";t.exports=a;var i=e("./_stream_transform");var n=e("core-util-is");n.inherits=e("inherits");n.inherits(a,i);function a(e){if(!(this instanceof a))return new a(e);i.call(this,e)}a.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":57,"core-util-is":59,inherits:128}],56:[function(e,t,r){(function(r){"use strict";t.exports=p;var i=e("process-nextick-args");var n=e("isarray");var a=e("buffer").Buffer;p.ReadableState=c;var s=e("events").EventEmitter;if(!s.listenerCount)s.listenerCount=function(e,t){return e.listeners(t).length};var o;(function(){try{o=e("st"+"ream")}catch(t){}finally{if(!o)o=e("events").EventEmitter}})();var a=e("buffer").Buffer;var f=e("core-util-is");f.inherits=e("inherits");var u=e("util");if(u&&u.debuglog){u=u.debuglog("stream")}else{u=function(){}}var l;f.inherits(p,o);function c(t,r){var i=e("./_stream_duplex");t=t||{};this.objectMode=!!t.objectMode;if(r instanceof i)this.objectMode=this.objectMode||!!t.readableObjectMode;var n=t.highWaterMark;var a=this.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:a;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(!l)l=e("string_decoder/").StringDecoder;this.decoder=new l(t.encoding);this.encoding=t.encoding}}function p(t){var r=e("./_stream_duplex");if(!(this instanceof p))return new p(t);this._readableState=new c(t,this);this.readable=true;if(t&&typeof t.read==="function")this._read=t.read;o.call(this)}p.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 a(e,t);t=""}}return d(this,r,e,t,false)};p.prototype.unshift=function(e){var t=this._readableState;return d(this,t,e,"",true)};p.prototype.isPaused=function(){return this._readableState.flowing===false};function d(e,t,r,i,n){var a=y(t,r);if(a){e.emit("error",a)}else if(r===null){t.reading=false;_(e,t)}else if(t.objectMode||r&&r.length>0){if(t.ended&&!n){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&n){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{if(t.decoder&&!n&&!i)r=t.decoder.write(r);if(!n)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(n)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)b(e)}x(e,t)}}else if(!n){t.reading=false}return h(t)}function h(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}p.prototype.setEncoding=function(t){if(!l)l=e("string_decoder/").StringDecoder;this._readableState.decoder=new l(t);this._readableState.encoding=t;return this};var m=8388608;function v(e){if(e>=m){e=m}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function g(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=v(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else{return t.length}}return e}p.prototype.read=function(e){u("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)){u("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)L(this);else b(this);return null}e=g(e,t);if(e===0&&t.ended){if(t.length===0)L(this);return null}var i=t.needReadable;u("need readable",i);if(t.length===0||t.length-e<t.highWaterMark){i=true;u("length less than watermark",i)}if(t.ended||t.reading){i=false;u("reading or ended",i)}if(i){u("do read");t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(i&&!t.reading)e=g(r,t);var n;if(e>0)n=T(e,t);else n=null;if(n===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)L(this);if(n!==null)this.emit("data",n);return n};function y(e,t){var r=null;if(!a.isBuffer(t)&&typeof t!=="string"&&t!==null&&t!==undefined&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function _(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;b(e)}function b(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){u("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)i(w,e);else w(e)}}function w(e){u("emit readable");e.emit("readable");I(e)}function x(e,t){if(!t.readingMore){t.readingMore=true;i(k,e,t)}}function k(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){u("maybeReadMore read 0");e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}p.prototype._read=function(e){this.emit("error",new Error("not implemented"))};p.prototype.pipe=function(e,t){var a=this;var o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e);break}o.pipesCount+=1;u("pipe count=%d opts=%j",o.pipesCount,t);var f=(!t||t.end!==false)&&e!==r.stdout&&e!==r.stderr;var l=f?p:h;if(o.endEmitted)i(l);else a.once("end",l);e.on("unpipe",c);function c(e){u("onunpipe");if(e===a){h()}}function p(){u("onend");e.end()}var d=S(a);e.on("drain",d);function h(){u("cleanup");e.removeListener("close",g);e.removeListener("finish",y);e.removeListener("drain",d);e.removeListener("error",v);e.removeListener("unpipe",c);a.removeListener("end",p);a.removeListener("end",h);a.removeListener("data",m);if(o.awaitDrain&&(!e._writableState||e._writableState.needDrain))d()}a.on("data",m);function m(t){u("ondata");var r=e.write(t);if(false===r){u("false write response, pause",a._readableState.awaitDrain);a._readableState.awaitDrain++;a.pause()}}function v(t){u("onerror",t);_();e.removeListener("error",v);if(s.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",v);else if(n(e._events.error))e._events.error.unshift(v);else e._events.error=[v,e._events.error];function g(){e.removeListener("finish",y);_()}e.once("close",g);function y(){u("onfinish");e.removeListener("close",g);_()}e.once("finish",y);function _(){u("unpipe");a.unpipe(e)}e.emit("pipe",a);if(!o.flowing){u("pipe resume");a.resume()}return e};function S(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&s.listenerCount(e,"data")){t.flowing=true;I(e)}}}p.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 i=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var n=0;n<i;n++)r[n].emit("unpipe",this);return this}var n=R(t.pipes,e);if(n===-1)return this;t.pipes.splice(n,1);t.pipesCount-=1;if(t.pipesCount===1)t.pipes=t.pipes[0];e.emit("unpipe",this);return this};p.prototype.on=function(e,t){var r=o.prototype.on.call(this,e,t);if(e==="data"&&false!==this._readableState.flowing){this.resume()}if(e==="readable"&&this.readable){var n=this._readableState;if(!n.readableListening){n.readableListening=true;n.emittedReadable=false;n.needReadable=true;if(!n.reading){i(E,this)}else if(n.length){b(this,n)}}}return r};p.prototype.addListener=p.prototype.on;function E(e){u("readable nexttick read 0");e.read(0)}p.prototype.resume=function(){var e=this._readableState;if(!e.flowing){u("resume");e.flowing=true;A(this,e)}return this};function A(e,t){if(!t.resumeScheduled){t.resumeScheduled=true;i(U,e,t)}}function U(e,t){if(!t.reading){u("resume read 0");e.read(0)}t.resumeScheduled=false;e.emit("resume");I(e);if(t.flowing&&!t.reading)e.read(0)}p.prototype.pause=function(){u("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){u("pause");this._readableState.flowing=false;this.emit("pause")}return this};function I(e){var t=e._readableState;u("flow",t.flowing);if(t.flowing){do{var r=e.read()}while(null!==r&&t.flowing)}}p.prototype.wrap=function(e){var t=this._readableState;var r=false;var i=this;e.on("end",function(){u("wrapped end");if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)i.push(e)}i.push(null)});e.on("data",function(n){u("wrapped data");if(t.decoder)n=t.decoder.write(n);if(t.objectMode&&(n===null||n===undefined))return;else if(!t.objectMode&&(!n||!n.length))return;var a=i.push(n);if(!a){r=true;e.pause()}});for(var n in e){if(this[n]===undefined&&typeof e[n]==="function"){this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n)}}var a=["error","close","destroy","pause","resume"];C(a,function(t){e.on(t,i.emit.bind(i,t))});i._read=function(t){u("wrapped _read",t);if(r){r=false;e.resume()}};return i};p._fromList=T;function T(e,t){var r=t.buffer;var i=t.length;var n=!!t.decoder;var s=!!t.objectMode;var o;if(r.length===0)return null;if(i===0)o=null;else if(s)o=r.shift();else if(!e||e>=i){if(n)o=r.join("");else o=a.concat(r,i);r.length=0}else{if(e<r[0].length){var f=r[0];o=f.slice(0,e);r[0]=f.slice(e)}else if(e===r[0].length){o=r.shift()}else{if(n)o="";else o=new a(e);var u=0;for(var l=0,c=r.length;l<c&&u<e;l++){var f=r[0];var p=Math.min(e-u,f.length);if(n)o+=f.slice(0,p);else f.copy(o,u,0,p);if(p<f.length)r[0]=f.slice(p);else r.shift();u+=p}}}return o}function L(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;i(B,t,e)}}function B(e,t){if(!e.endEmitted&&e.length===0){e.endEmitted=true;t.readable=false;t.emit("end")}}function C(e,t){for(var r=0,i=e.length;r<i;r++){t(e[r],r)}}function R(e,t){for(var r=0,i=e.length;r<i;r++){if(e[r]===t)return r}return-1}}).call(this,e("_process"))},{"./_stream_duplex":54,_process:48,buffer:39,"core-util-is":59,events:43,inherits:128,isarray:45,"process-nextick-args":60,"string_decoder/":76,util:38}],57:[function(e,t,r){"use strict";t.exports=o;var i=e("./_stream_duplex");var n=e("core-util-is");n.inherits=e("inherits");n.inherits(o,i);function a(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 i=e._transformState;i.transforming=false;var n=i.writecb;if(!n)return e.emit("error",new Error("no writecb in Transform class"));i.writechunk=null;i.writecb=null;if(r!==null&&r!==undefined)e.push(r);if(n)n(t);var a=e._readableState;a.reading=false;if(a.needReadable||a.length<a.highWaterMark){e._read(a.highWaterMark)}}function o(e){if(!(this instanceof o))return new o(e);i.call(this,e);this._transformState=new a(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)})}o.prototype.push=function(e,t){this._transformState.needTransform=false;return i.prototype.push.call(this,e,t)};o.prototype._transform=function(e,t,r){throw new Error("not implemented")};o.prototype._write=function(e,t,r){var i=this._transformState;i.writecb=r;i.writechunk=e;i.writeencoding=t;if(!i.transforming){var n=this._readableState;if(i.needTransform||n.needReadable||n.length<n.highWaterMark)this._read(n.highWaterMark)}};o.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 i=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(i.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":54,"core-util-is":59,inherits:128}],58:[function(e,t,r){"use strict";t.exports=l;var i=e("process-nextick-args");var n=e("buffer").Buffer;l.WritableState=u;var a=e("core-util-is");a.inherits=e("inherits");var s;(function(){try{s=e("st"+"ream")}catch(t){}finally{if(!s)s=e("events").EventEmitter}})();var n=e("buffer").Buffer;a.inherits(l,s);function o(){}function f(e,t,r){this.chunk=e;this.encoding=t;this.callback=r;this.next=null}function u(t,r){var i=e("./_stream_duplex");t=t||{};this.objectMode=!!t.objectMode;if(r instanceof i)this.objectMode=this.objectMode||!!t.writableObjectMode;var n=t.highWaterMark;var a=this.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:a;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var s=t.decodeStrings===false;this.decodeStrings=!s;this.defaultEncoding=t.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){y(r,e)};this.writecb=null;this.writelen=0;this.bufferedRequest=null;this.lastBufferedRequest=null;this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}u.prototype.getBuffer=function A(){var e=this.bufferedRequest;var t=[];while(e){t.push(e);e=e.next}return t};(function(){try{Object.defineProperty(u.prototype,"buffer",{get:e("util-deprecate")(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use "+"_writableState.getBuffer() instead.")})}catch(t){}})();function l(t){var r=e("./_stream_duplex");if(!(this instanceof l)&&!(this instanceof r))return new l(t);this._writableState=new u(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}s.call(this)}l.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function c(e,t){var r=new Error("write after end");e.emit("error",r);i(t,r)}function p(e,t,r,a){var s=true;if(!n.isBuffer(r)&&typeof r!=="string"&&r!==null&&r!==undefined&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o);i(a,o);s=false}return s}l.prototype.write=function(e,t,r){var i=this._writableState;var a=false;if(typeof t==="function"){r=t;t=null}if(n.isBuffer(e))t="buffer";else if(!t)t=i.defaultEncoding;if(typeof r!=="function")r=o;if(i.ended)c(this,r);else if(p(this,i,e,r)){i.pendingcb++;a=h(this,i,e,t,r)}return a};l.prototype.cork=function(){var e=this._writableState;e.corked++};l.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest)w(this,e)}};l.prototype.setDefaultEncoding=function U(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 d(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&typeof t==="string"){t=new n(t,r)}return t}function h(e,t,r,i,a){r=d(t,r,i);if(n.isBuffer(r))i="buffer";var s=t.objectMode?1:r.length;t.length+=s;var o=t.length<t.highWaterMark;if(!o)t.needDrain=true;if(t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest=new f(r,i,a);if(u){u.next=t.lastBufferedRequest}else{t.bufferedRequest=t.lastBufferedRequest}}else{m(e,t,false,s,r,i,a)}return o}function m(e,t,r,i,n,a,s){t.writelen=i;t.writecb=s;t.writing=true;t.sync=true;if(r)e._writev(n,t.onwrite);else e._write(n,a,t.onwrite);t.sync=false}function v(e,t,r,n,a){--t.pendingcb;if(r)i(a,n);else a(n);e._writableState.errorEmitted=true;e.emit("error",n)}function g(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function y(e,t){var r=e._writableState;var n=r.sync;var a=r.writecb;g(r);if(t)v(e,r,n,t,a);else{var s=x(r);if(!s&&!r.corked&&!r.bufferProcessing&&r.bufferedRequest){w(e,r)}if(n){i(_,e,r,s,a)}else{_(e,r,s,a)}}}function _(e,t,r,i){if(!r)b(e,t);t.pendingcb--;i();S(e,t)}function b(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function w(e,t){t.bufferProcessing=true;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=[];var n=[];while(r){n.push(r.callback);i.push(r);r=r.next}t.pendingcb++;t.lastBufferedRequest=null;m(e,t,true,t.length,i,"",function(e){for(var r=0;r<n.length;r++){t.pendingcb--;n[r](e)}})}else{while(r){var a=r.chunk;var s=r.encoding;var o=r.callback;var f=t.objectMode?1:a.length;m(e,t,false,f,a,s,o);r=r.next;if(t.writing){break}}if(r===null)t.lastBufferedRequest=null}t.bufferedRequest=r;t.bufferProcessing=false}l.prototype._write=function(e,t,r){r(new Error("not implemented"))};l.prototype._writev=null;l.prototype.end=function(e,t,r){var i=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(i.corked){i.corked=1;this.uncork()}if(!i.ending&&!i.finished)E(this,i,r)};function x(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function k(e,t){if(!t.prefinished){t.prefinished=true;e.emit("prefinish")}}function S(e,t){var r=x(t);if(r){if(t.pendingcb===0){k(e,t);t.finished=true;e.emit("finish")}else{k(e,t)}}return r}function E(e,t,r){t.ending=true;S(e,t);if(r){if(t.finished)i(r);else e.once("finish",r)}t.ended=true}},{"./_stream_duplex":54,buffer:39,"core-util-is":59,events:43,inherits:128,"process-nextick-args":60,"util-deprecate":61}],59:[function(e,t,r){(function(e){function t(e){return Array.isArray(e)}r.isArray=t;function i(e){return typeof e==="boolean"}r.isBoolean=i;function n(e){return e===null}r.isNull=n;function a(e){return e==null}r.isNullOrUndefined=a;function s(e){return typeof e==="number"}r.isNumber=s;function o(e){return typeof e==="string"}r.isString=o;function f(e){return typeof e==="symbol"}r.isSymbol=f;function u(e){return e===void 0}r.isUndefined=u;function l(e){return c(e)&&g(e)==="[object RegExp]"}r.isRegExp=l;function c(e){return typeof e==="object"&&e!==null}r.isObject=c;function p(e){return c(e)&&g(e)==="[object Date]"}r.isDate=p;function d(e){return c(e)&&(g(e)==="[object Error]"||e instanceof Error)}r.isError=d;function h(e){return typeof e==="function"}r.isFunction=h;function m(e){return e===null||typeof e==="boolean"||typeof e==="number"||typeof e==="string"||typeof e==="symbol"||typeof e==="undefined"}r.isPrimitive=m;function v(t){return e.isBuffer(t)}r.isBuffer=v;function g(e){return Object.prototype.toString.call(e)}}).call(this,e("buffer").Buffer)},{buffer:39}],60:[function(e,t,r){(function(e){"use strict";t.exports=r;function r(t){var r=new Array(arguments.length-1);var i=0;while(i<arguments.length){r[i++]=arguments[i]}e.nextTick(function n(){t.apply(null,r)})}}).call(this,e("_process"))},{_process:48}],61:[function(e,t,r){(function(e){t.exports=r;function r(e,t){if(i("noDeprecation")){return e}var r=false;function n(){if(!r){if(i("throwDeprecation")){throw new Error(t)}else if(i("traceDeprecation")){console.trace(t)}else{console.warn(t)}r=true}return e.apply(this,arguments)}return n}function i(t){if(!e.localStorage)return false;var r=e.localStorage[t];if(null==r)return false;return String(r).toLowerCase()==="true"}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],62:[function(e,t,r){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":55}],63:[function(e,t,r){var i=function(){try{return e("st"+"ream")}catch(t){}}();r=t.exports=e("./lib/_stream_readable.js");r.Stream=i||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":54,"./lib/_stream_passthrough.js":55,"./lib/_stream_readable.js":56,"./lib/_stream_transform.js":57,"./lib/_stream_writable.js":58}],64:[function(e,t,r){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":57}],65:[function(e,t,r){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":58}],66:[function(e,t,r){t.exports=a;var i=e("events").EventEmitter;var n=e("inherits");n(a,i);a.Readable=e("readable-stream/readable.js");a.Writable=e("readable-stream/writable.js");a.Duplex=e("readable-stream/duplex.js");a.Transform=e("readable-stream/transform.js");a.PassThrough=e("readable-stream/passthrough.js");a.Stream=a;function a(){i.call(this)}a.prototype.pipe=function(e,t){var r=this;function n(t){if(e.writable){if(false===e.write(t)&&r.pause){r.pause()}}}r.on("data",n);function a(){if(r.readable&&r.resume){r.resume()}}e.on("drain",a);if(!e._isStdio&&(!t||t.end!==false)){r.on("end",o);r.on("close",f)}var s=false;function o(){if(s)return;s=true;e.end()}function f(){if(s)return;s=true;if(typeof e.destroy==="function")e.destroy()}function u(e){l();if(i.listenerCount(this,"error")===0){throw e}}r.on("error",u);e.on("error",u);function l(){r.removeListener("data",n);e.removeListener("drain",a);r.removeListener("end",o);r.removeListener("close",f);r.removeListener("error",u);e.removeListener("error",u);r.removeListener("end",l);r.removeListener("close",l);e.removeListener("close",l)}r.on("end",l);r.on("close",l);e.on("close",l);e.emit("pipe",r);return e}},{events:43,inherits:128,"readable-stream/duplex.js":53,"readable-stream/passthrough.js":62,"readable-stream/readable.js":63,"readable-stream/transform.js":64,"readable-stream/writable.js":65}],67:[function(e,t,r){var i=e("./lib/request");var n=e("xtend");var a=e("builtin-status-codes");var s=e("url");var o=r;o.request=function(e,t){if(typeof e==="string")e=s.parse(e);else e=n(e);var r=e.host?e.host.split(":")[0]:null;var a=e.host?parseInt(e.host.split(":")[1],10):null;e.method=e.method||"GET";e.headers=e.headers||{};e.path=e.path||"/";e.protocol=e.protocol||window.location.protocol;var o=e.hostname||r?e.protocol==="https:"?443:80:window.location.port;e.hostname=e.hostname||r||window.location.hostname;e.port=e.port||a||o;var f=new i(e);if(t)f.on("response",t);return f};o.get=function f(e,t){var r=o.request(e,t);r.end();return r};o.Agent=function(){};o.Agent.defaultMaxSockets=4;o.STATUS_CODES=a;o.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"]},{"./lib/request":69,"builtin-status-codes":71,url:77,xtend:181}],68:[function(e,t,r){r.fetch=f(window.fetch)&&f(window.ReadableByteStream);r.blobConstructor=false;try{new Blob([new ArrayBuffer(1)]);r.blobConstructor=true}catch(i){}var n=new window.XMLHttpRequest;n.open("GET","/");function a(e){try{n.responseType=e;return n.responseType===e}catch(t){}return false}var s=typeof window.ArrayBuffer!=="undefined";var o=s&&f(window.ArrayBuffer.prototype.slice);r.arraybuffer=s&&a("arraybuffer");r.msstream=!r.fetch&&o&&a("ms-stream");r.mozchunkedarraybuffer=!r.fetch&&s&&a("moz-chunked-arraybuffer");r.overrideMimeType=f(n.overrideMimeType);r.vbArray=f(window.VBArray);function f(e){return typeof e==="function"}n=null},{}],69:[function(e,t,r){(function(r,i){var n=e("./capability");var a=e("foreach");var s=e("indexof");var o=e("inherits");var f=e("object-keys");var u=e("./response");var l=e("stream");var c=u.IncomingMessage;var p=u.readyStates;function d(e){if(n.fetch){return"fetch"}else if(n.mozchunkedarraybuffer){return"moz-chunked-arraybuffer"}else if(n.msstream){return"ms-stream"}else if(n.arraybuffer&&e){return"arraybuffer"}else if(n.vbArray&&e){return"text:vbarray"}else{return"text"}}var h=t.exports=function(e){var t=this;l.Writable.call(t);t._opts=e;t._url=e.protocol+"//"+e.hostname+":"+e.port+e.path;t._body=[];t._headers={};if(e.auth)t.setHeader("Authorization","Basic "+new i(e.auth).toString("base64"));a(f(e.headers),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=!n.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()})};o(h,l.Writable);h.prototype.setHeader=function(e,t){var r=this;var i=e.toLowerCase();if(s(v,i)!==-1)return;r._headers[i]={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 o;if(t.method==="POST"||t.method==="PUT"){if(n.blobConstructor){o=new window.Blob(e._body.map(function(e){return e.toArrayBuffer()}),{type:(s["content-type"]||{}).value||""})}else{o=i.concat(e._body).toString()}}if(e._mode==="fetch"){var u=f(s).map(function(e){return[s[e].name,s[e].value]});window.fetch(e._url,{method:e._opts.method,headers:u,body:o,mode:"cors",credentials:t.withCredentials?"include":"same-origin"}).then(function(t){e._fetchResponse=t;e._connect()}).then(undefined,function(t){e.emit("error",t)})}else{var l=e._xhr=new window.XMLHttpRequest;try{l.open(e._opts.method,e._url,true)}catch(c){r.nextTick(function(){e.emit("error",c)});return}if("responseType"in l)l.responseType=e._mode.split(":")[0];if("withCredentials"in l)l.withCredentials=!!t.withCredentials;if(e._mode==="text"&&"overrideMimeType"in l)l.overrideMimeType("text/plain; charset=x-user-defined");a(f(s),function(e){l.setRequestHeader(s[e].name,s[e].value)});e._response=null;l.onreadystatechange=function(){switch(l.readyState){case p.LOADING:case p.DONE:e._onXHRProgress();break}};if(e._mode==="moz-chunked-arraybuffer"){l.onprogress=function(){e._onXHRProgress()}}l.onerror=function(){if(e._destroyed)return;e.emit("error",new Error("XHR error"))};try{l.send(o)}catch(c){r.nextTick(function(){e.emit("error",c)});return}}};function m(e){try{return e.status!==null}catch(t){return false}}h.prototype._onXHRProgress=function(){var e=this;if(!m(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 i=this;i._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 i=this;if(typeof e==="function"){r=e;e=undefined}l.Writable.prototype.end.call(i,e,t,r)};h.prototype.flushHeaders=function(){};h.prototype.setTimeout=function(){};h.prototype.setNoDelay=function(){};h.prototype.setSocketKeepAlive=function(){};var v=["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"),e("buffer").Buffer)},{"./capability":68,"./response":70,_process:48,buffer:39,foreach:72,indexof:73,inherits:128,"object-keys":74,stream:66}],70:[function(e,t,r){(function(t,i){var n=e("./capability");var a=e("foreach");var s=e("inherits");var o=e("stream");var f=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4};var u=r.IncomingMessage=function(e,r,s){var f=this;o.Readable.call(f);f._mode=s;f.headers={};f.rawHeaders=[];f.trailers={};f.rawTrailers=[];f.on("end",function(){t.nextTick(function(){f.emit("close")})});if(s==="fetch"){f._fetchResponse=r;f.statusCode=r.status;f.statusMessage=r.statusText;for(var u,l,c=r.headers[Symbol.iterator]();u=(l=c.next()).value,!l.done;){f.headers[u[0].toLowerCase()]=u[1];f.rawHeaders.push(u[0],u[1])}var p=r.body.getReader();function d(){p.read().then(function(e){if(f._destroyed)return;if(e.done){f.push(null);return}f.push(new i(e.value));d()})}d()}else{f._xhr=e;f._pos=0;f.statusCode=e.status;f.statusMessage=e.statusText;var h=e.getAllResponseHeaders().split(/\r?\n/);a(h,function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var r=t[1].toLowerCase();if(f.headers[r]!==undefined)f.headers[r]+=", "+t[2];else f.headers[r]=t[2];f.rawHeaders.push(t[1],t[2])}});f._charset="x-user-defined";if(!n.overrideMimeType){var m=f.rawHeaders["mime-type"];if(m){var v=m.match(/;\s*charset=([^;])(;|$)/);if(v){f._charset=v[1].toLowerCase()}}if(!f._charset)f._charset="utf-8"}}};s(u,o.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 window.VBArray(t.responseBody).toArray()}catch(n){}if(r!==null){e.push(new i(r));break}case"text":try{r=t.responseText}catch(n){e._mode="text:vbarray";break}if(r.length>e._pos){var a=r.substr(e._pos);if(e._charset==="x-user-defined"){var s=new i(a.length);for(var o=0;o<a.length;o++)s[o]=a.charCodeAt(o)&255;e.push(s)}else{e.push(a,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 u=new window.MSStreamReader;u.onprogress=function(){if(u.result.byteLength>e._pos){e.push(new i(new Uint8Array(u.result.slice(e._pos))));e._pos=u.result.byteLength}};u.onload=function(){e.push(null)};u.readAsArrayBuffer(r);break}if(e._xhr.readyState===f.DONE&&e._mode!=="ms-stream"){e.push(null)}}}).call(this,e("_process"),e("buffer").Buffer)},{"./capability":68,_process:48,buffer:39,foreach:72,inherits:128,stream:66}],71:[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"}},{}],72:[function(e,t,r){var i=Object.prototype.hasOwnProperty;var n=Object.prototype.toString;t.exports=function a(e,t,r){if(n.call(t)!=="[object Function]"){throw new TypeError("iterator must be a function")}var a=e.length;if(a===+a){for(var s=0;s<a;s++){t.call(r,e[s],s,e)}}else{for(var o in e){if(i.call(e,o)){t.call(r,e[o],o,e)}}}}},{}],73:[function(e,t,r){var i=[].indexOf;t.exports=function(e,t){if(i)return e.indexOf(t);for(var r=0;r<e.length;++r){if(e[r]===t)return r}return-1}},{}],74:[function(e,t,r){"use strict";var i=Object.prototype.hasOwnProperty;var n=Object.prototype.toString;var a=Array.prototype.slice;var s=e("./isArguments");var o=!{toString:null}.propertyIsEnumerable("toString");var f=function(){}.propertyIsEnumerable("prototype");var u=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"];var l=function c(e){var t=e!==null&&typeof e==="object";var r=n.call(e)==="[object Function]";var a=s(e);var l=t&&n.call(e)==="[object String]";var c=[];if(!t&&!r&&!a){throw new TypeError("Object.keys called on a non-object")}var p=f&&r;if(l&&e.length>0&&!i.call(e,0)){for(var d=0;d<e.length;++d){c.push(String(d))}}if(a&&e.length>0){for(var h=0;h<e.length;++h){c.push(String(h))}}else{for(var m in e){if(!(p&&m==="prototype")&&i.call(e,m)){c.push(String(m))}}}if(o){var v=e.constructor;var g=v&&v.prototype===e;for(var y=0;y<u.length;++y){if(!(g&&u[y]==="constructor")&&i.call(e,u[y])){c.push(u[y])}}}return c};l.shim=function p(){if(!Object.keys){Object.keys=l}else{var e=function(){return(Object.keys(arguments)||"").length===2}(1,2);if(!e){var t=Object.keys;Object.keys=function r(e){if(s(e)){return t(a.call(e))}else{return t(e)}}}}return Object.keys||l};t.exports=l},{"./isArguments":75}],75:[function(e,t,r){"use strict";var i=Object.prototype.toString;t.exports=function n(e){var t=i.call(e);var r=t==="[object Arguments]";if(!r){r=t!=="[object Array]"&&e!==null&&typeof e==="object"&&typeof e.length==="number"&&e.length>=0&&i.call(e.callee)==="[object Function]"}return r}},{}],76:[function(e,t,r){var i=e("buffer").Buffer;var n=i.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 a(e){if(e&&!n(e)){throw new Error("Unknown encoding: "+e)}}var s=r.StringDecoder=function(e){this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,"");a(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=o;return}this.charBuffer=new i(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 i=t.charCodeAt(t.length-1);if(i>=55296&&i<=56319){this.charLength+=this.surrogateSize;t="";continue}this.charReceived=this.charLength=0;if(e.length===0){return t}break}this.detectIncompleteChar(e);var n=e.length;if(this.charLength){e.copy(this.charBuffer,0,e.length-this.charReceived,n);n-=this.charReceived}t+=e.toString(this.encoding,0,n);var n=t.length-1;var i=t.charCodeAt(n);if(i>=55296&&i<=56319){var a=this.surrogateSize;this.charLength+=a;this.charReceived+=a;this.charBuffer.copy(this.charBuffer,a,0,a);e.copy(this.charBuffer,0,0,a);return t.substring(0,n)}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 i=this.charBuffer;var n=this.encoding;t+=i.slice(0,r).toString(n)}return t};function o(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:39}],77:[function(e,t,r){var i=e("punycode");r.parse=_;r.resolve=w;r.resolveObject=x;r.format=b;r.Url=n;function n(){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 a=/^([a-z0-9.+-]+:)/i,s=/:[0-9]*$/,o=["<",">",'"',"`"," ","\r","\n"," "],f=["{","}","|","\\","^","`"].concat(o),u=["'"].concat(f),l=["%","/","?",";","#"].concat(u),c=["/","?","#"],p=255,d=/^[a-z0-9A-Z_-]{0,63}$/,h=/^([a-z0-9A-Z_-]{0,63})(.*)$/,m={javascript:true,"javascript:":true},v={javascript:true,"javascript:":true},g={http:true,https:true,ftp:true,gopher:true,file:true,"http:":true,"https:":true,"ftp:":true,"gopher:":true,"file:":true},y=e("querystring");function _(e,t,r){if(e&&S(e)&&e instanceof n)return e;var i=new n;i.parse(e,t,r);return i}n.prototype.parse=function(e,t,r){if(!k(e)){throw new TypeError("Parameter 'url' must be a string, not "+typeof e)}var n=e;n=n.trim();var s=a.exec(n);if(s){s=s[0];var o=s.toLowerCase();this.protocol=o;n=n.substr(s.length)}if(r||s||n.match(/^\/\/[^@\/]+@[^@\/]+/)){var f=n.substr(0,2)==="//";if(f&&!(s&&v[s])){n=n.substr(2);this.slashes=true}}if(!v[s]&&(f||s&&!g[s])){var _=-1;for(var b=0;b<c.length;b++){var w=n.indexOf(c[b]);if(w!==-1&&(_===-1||w<_))_=w}var x,S;if(_===-1){S=n.lastIndexOf("@")}else{S=n.lastIndexOf("@",_)}if(S!==-1){x=n.slice(0,S);n=n.slice(S+1);this.auth=decodeURIComponent(x)}_=-1;for(var b=0;b<l.length;b++){var w=n.indexOf(l[b]);if(w!==-1&&(_===-1||w<_))_=w}if(_===-1)_=n.length;this.host=n.slice(0,_);n=n.slice(_);this.parseHost();this.hostname=this.hostname||"";var E=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!E){var A=this.hostname.split(/\./);for(var b=0,U=A.length;b<U;b++){var I=A[b];if(!I)continue;if(!I.match(d)){var T="";for(var L=0,B=I.length;L<B;L++){if(I.charCodeAt(L)>127){T+="x"}else{T+=I[L]}}if(!T.match(d)){var C=A.slice(0,b);var R=A.slice(b+1);var P=I.match(h);if(P){C.push(P[1]);R.unshift(P[2])}if(R.length){n="/"+R.join(".")+n}this.hostname=C.join(".");break}}}}if(this.hostname.length>p){this.hostname=""}else{this.hostname=this.hostname.toLowerCase()}if(!E){var O=this.hostname.split(".");var z=[];for(var b=0;b<O.length;++b){var F=O[b];z.push(F.match(/[^A-Za-z0-9_-]/)?"xn--"+i.encode(F):F)}this.hostname=z.join(".")}var M=this.port?":"+this.port:"";var j=this.hostname||"";this.host=j+M;this.href+=this.host;if(E){this.hostname=this.hostname.substr(1,this.hostname.length-2);if(n[0]!=="/"){n="/"+n}}}if(!m[o]){for(var b=0,U=u.length;b<U;b++){var D=u[b];var N=encodeURIComponent(D);if(N===D){N=escape(D)}n=n.split(D).join(N)}}var H=n.indexOf("#");if(H!==-1){this.hash=n.substr(H);n=n.slice(0,H)}var q=n.indexOf("?");if(q!==-1){this.search=n.substr(q);this.query=n.substr(q+1);if(t){this.query=y.parse(this.query)}n=n.slice(0,q)}else if(t){this.search="";this.query={}}if(n)this.pathname=n;if(g[o]&&this.hostname&&!this.pathname){this.pathname="/"}if(this.pathname||this.search){var M=this.pathname||"";var F=this.search||"";this.path=M+F}this.href=this.format();return this};function b(e){if(k(e))e=_(e);if(!(e instanceof n))return n.prototype.format.call(e);return e.format()}n.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||"",i=this.hash||"",n=false,a="";if(this.host){n=e+this.host}else if(this.hostname){n=e+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]");if(this.port){n+=":"+this.port}}if(this.query&&S(this.query)&&Object.keys(this.query).length){a=y.stringify(this.query)}var s=this.search||a&&"?"+a||"";if(t&&t.substr(-1)!==":")t+=":";if(this.slashes||(!t||g[t])&&n!==false){n="//"+(n||"");if(r&&r.charAt(0)!=="/")r="/"+r}else if(!n){n=""}if(i&&i.charAt(0)!=="#")i="#"+i;if(s&&s.charAt(0)!=="?")s="?"+s;r=r.replace(/[?#]/g,function(e){return encodeURIComponent(e)});s=s.replace("#","%23");return t+n+r+s+i};function w(e,t){return _(e,false,true).resolve(t)}n.prototype.resolve=function(e){return this.resolveObject(_(e,false,true)).format()};function x(e,t){if(!e)return t;return _(e,false,true).resolveObject(t)}n.prototype.resolveObject=function(e){if(k(e)){var t=new n;t.parse(e,false,true);e=t}var r=new n;Object.keys(this).forEach(function(e){r[e]=this[e]},this);r.hash=e.hash;if(e.href===""){r.href=r.format();return r}if(e.slashes&&!e.protocol){Object.keys(e).forEach(function(t){if(t!=="protocol")r[t]=e[t]});if(g[r.protocol]&&r.hostname&&!r.pathname){r.path=r.pathname="/"}r.href=r.format();return r}if(e.protocol&&e.protocol!==r.protocol){if(!g[e.protocol]){Object.keys(e).forEach(function(t){r[t]=e[t]});r.href=r.format();return r}r.protocol=e.protocol;if(!e.host&&!v[e.protocol]){var i=(e.pathname||"").split("/");while(i.length&&!(e.host=i.shift()));if(!e.host)e.host="";if(!e.hostname)e.hostname="";if(i[0]!=="")i.unshift("");if(i.length<2)i.unshift("");r.pathname=i.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 a=r.pathname||"";var s=r.search||"";r.path=a+s}r.slashes=r.slashes||e.slashes;r.href=r.format();return r}var o=r.pathname&&r.pathname.charAt(0)==="/",f=e.host||e.pathname&&e.pathname.charAt(0)==="/",u=f||o||r.host&&e.pathname,l=u,c=r.pathname&&r.pathname.split("/")||[],i=e.pathname&&e.pathname.split("/")||[],p=r.protocol&&!g[r.protocol];if(p){r.hostname="";r.port=null;if(r.host){if(c[0]==="")c[0]=r.host;else c.unshift(r.host)}r.host="";if(e.protocol){e.hostname=null;e.port=null;if(e.host){if(i[0]==="")i[0]=e.host;else i.unshift(e.host)}e.host=null}u=u&&(i[0]===""||c[0]==="")}if(f){r.host=e.host||e.host===""?e.host:r.host;r.hostname=e.hostname||e.hostname===""?e.hostname:r.hostname;r.search=e.search;r.query=e.query;c=i}else if(i.length){if(!c)c=[];c.pop();c=c.concat(i);r.search=e.search;r.query=e.query}else if(!A(e.search)){if(p){r.hostname=r.host=c.shift();var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}r.search=e.search;r.query=e.query;if(!E(r.pathname)||!E(r.search)){r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")}r.href=r.format();return r}if(!c.length){r.pathname=null;if(r.search){r.path="/"+r.search}else{r.path=null}r.href=r.format();return r}var h=c.slice(-1)[0];var m=(r.host||e.host)&&(h==="."||h==="..")||h==="";var y=0;for(var _=c.length;_>=0;_--){h=c[_];if(h=="."){c.splice(_,1)}else if(h===".."){c.splice(_,1);y++}else if(y){c.splice(_,1);y--}}if(!u&&!l){for(;y--;y){c.unshift("..")}}if(u&&c[0]!==""&&(!c[0]||c[0].charAt(0)!=="/")){c.unshift("");
+}if(m&&c.join("/").substr(-1)!=="/"){c.push("")}var b=c[0]===""||c[0]&&c[0].charAt(0)==="/";if(p){r.hostname=r.host=b?"":c.length?c.shift():"";var d=r.host&&r.host.indexOf("@")>0?r.host.split("@"):false;if(d){r.auth=d.shift();r.host=r.hostname=d.shift()}}u=u||r.host&&c.length;if(u&&!b){c.unshift("")}if(!c.length){r.pathname=null;r.path=null}else{r.pathname=c.join("/")}if(!E(r.pathname)||!E(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};n.prototype.parseHost=function(){var e=this.host;var t=s.exec(e);if(t){t=t[0];if(t!==":"){this.port=t.substr(1)}e=e.substr(0,e.length-t.length)}if(e)this.hostname=e};function k(e){return typeof e==="string"}function S(e){return typeof e==="object"&&e!==null}function E(e){return e===null}function A(e){return e==null}},{punycode:49,querystring:52}],78:[function(e,t,r){(function(r){var i=e("inherits");var n=e("readable-stream").Transform;var a=e("defined");t.exports=s;i(s,n);function s(e,t){if(!(this instanceof s))return new s(e,t);n.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=a(t.zeroPadding,true);this._buffered=[];this._bufferedBytes=0}s.prototype._transform=function(e,t,i){this._bufferedBytes+=e.length;this._buffered.push(e);while(this._bufferedBytes>=this.size){var n=r.concat(this._buffered);this._bufferedBytes-=this.size;this.push(n.slice(0,this.size));this._buffered=[n.slice(this.size,n.length)]}i()};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:39,defined:79,inherits:128,"readable-stream":88}],79:[function(e,t,r){t.exports=function(){for(var e=0;e<arguments.length;e++){if(arguments[e]!==undefined)return arguments[e]}}},{}],80:[function(e,t,r){(function(r){t.exports=o;var i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};var n=e("core-util-is");n.inherits=e("inherits");var a=e("./_stream_readable");var s=e("./_stream_writable");n.inherits(o,a);u(i(s.prototype),function(e){if(!o.prototype[e])o.prototype[e]=s.prototype[e]});function o(e){if(!(this instanceof o))return new o(e);a.call(this,e);s.call(this,e);if(e&&e.readable===false)this.readable=false;if(e&&e.writable===false)this.writable=false;this.allowHalfOpen=true;if(e&&e.allowHalfOpen===false)this.allowHalfOpen=false;this.once("end",f)}function f(){if(this.allowHalfOpen||this._writableState.ended)return;r.nextTick(this.end.bind(this))}function u(e,t){for(var r=0,i=e.length;r<i;r++){t(e[r],r)}}}).call(this,e("_process"))},{"./_stream_readable":82,"./_stream_writable":84,_process:48,"core-util-is":85,inherits:128}],81:[function(e,t,r){t.exports=a;var i=e("./_stream_transform");var n=e("core-util-is");n.inherits=e("inherits");n.inherits(a,i);function a(e){if(!(this instanceof a))return new a(e);i.call(this,e)}a.prototype._transform=function(e,t,r){r(null,e)}},{"./_stream_transform":83,"core-util-is":85,inherits:128}],82:[function(e,t,r){(function(r){t.exports=c;var i=e("isarray");var n=e("buffer").Buffer;c.ReadableState=l;var a=e("events").EventEmitter;if(!a.listenerCount)a.listenerCount=function(e,t){return e.listeners(t).length};var s=e("stream");var o=e("core-util-is");o.inherits=e("inherits");var f;var u=e("util");if(u&&u.debuglog){u=u.debuglog("stream")}else{u=function(){}}o.inherits(c,s);function l(t,r){var i=e("./_stream_duplex");t=t||{};var n=t.highWaterMark;var a=t.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:a;this.highWaterMark=~~this.highWaterMark;this.buffer=[];this.length=0;this.pipes=null;this.pipesCount=0;this.flowing=null;this.ended=false;this.endEmitted=false;this.reading=false;this.sync=true;this.needReadable=false;this.emittedReadable=false;this.readableListening=false;this.objectMode=!!t.objectMode;if(r instanceof i)this.objectMode=this.objectMode||!!t.readableObjectMode;this.defaultEncoding=t.defaultEncoding||"utf8";this.ranOut=false;this.awaitDrain=0;this.readingMore=false;this.decoder=null;this.encoding=null;if(t.encoding){if(!f)f=e("string_decoder/").StringDecoder;this.decoder=new f(t.encoding);this.encoding=t.encoding}}function c(t){var r=e("./_stream_duplex");if(!(this instanceof c))return new c(t);this._readableState=new l(t,this);this.readable=true;s.call(this)}c.prototype.push=function(e,t){var r=this._readableState;if(o.isString(e)&&!r.objectMode){t=t||r.defaultEncoding;if(t!==r.encoding){e=new n(e,t);t=""}}return p(this,r,e,t,false)};c.prototype.unshift=function(e){var t=this._readableState;return p(this,t,e,"",true)};function p(e,t,r,i,n){var a=g(t,r);if(a){e.emit("error",a)}else if(o.isNullOrUndefined(r)){t.reading=false;if(!t.ended)y(e,t)}else if(t.objectMode||r&&r.length>0){if(t.ended&&!n){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&n){var s=new Error("stream.unshift() after end event");e.emit("error",s)}else{if(t.decoder&&!n&&!i)r=t.decoder.write(r);if(!n)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(n)t.buffer.unshift(r);else t.buffer.push(r);if(t.needReadable)_(e)}w(e,t)}}else if(!n){t.reading=false}return d(t)}function d(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}c.prototype.setEncoding=function(t){if(!f)f=e("string_decoder/").StringDecoder;this._readableState.decoder=new f(t);this._readableState.encoding=t;return this};var h=8388608;function m(e){if(e>=h){e=h}else{e--;for(var t=1;t<32;t<<=1)e|=e>>t;e++}return e}function v(e,t){if(t.length===0&&t.ended)return 0;if(t.objectMode)return e===0?0:1;if(isNaN(e)||o.isNull(e)){if(t.flowing&&t.buffer.length)return t.buffer[0].length;else return t.length}if(e<=0)return 0;if(e>t.highWaterMark)t.highWaterMark=m(e);if(e>t.length){if(!t.ended){t.needReadable=true;return 0}else return t.length}return e}c.prototype.read=function(e){u("read",e);var t=this._readableState;var r=e;if(!o.isNumber(e)||e>0)t.emittedReadable=false;if(e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended)){u("read: emitReadable",t.length,t.ended);if(t.length===0&&t.ended)I(this);else _(this);return null}e=v(e,t);if(e===0&&t.ended){if(t.length===0)I(this);return null}var i=t.needReadable;u("need readable",i);if(t.length===0||t.length-e<t.highWaterMark){i=true;u("length less than watermark",i)}if(t.ended||t.reading){i=false;u("reading or ended",i)}if(i){u("do read");t.reading=true;t.sync=true;if(t.length===0)t.needReadable=true;this._read(t.highWaterMark);t.sync=false}if(i&&!t.reading)e=v(r,t);var n;if(e>0)n=U(e,t);else n=null;if(o.isNull(n)){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)I(this);if(!o.isNull(n))this.emit("data",n);return n};function g(e,t){var r=null;if(!o.isBuffer(t)&&!o.isString(t)&&!o.isNullOrUndefined(t)&&!e.objectMode){r=new TypeError("Invalid non-string/buffer chunk")}return r}function y(e,t){if(t.decoder&&!t.ended){var r=t.decoder.end();if(r&&r.length){t.buffer.push(r);t.length+=t.objectMode?1:r.length}}t.ended=true;_(e)}function _(e){var t=e._readableState;t.needReadable=false;if(!t.emittedReadable){u("emitReadable",t.flowing);t.emittedReadable=true;if(t.sync)r.nextTick(function(){b(e)});else b(e)}}function b(e){u("emit readable");e.emit("readable");A(e)}function w(e,t){if(!t.readingMore){t.readingMore=true;r.nextTick(function(){x(e,t)})}}function x(e,t){var r=t.length;while(!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark){u("maybeReadMore read 0");e.read(0);if(r===t.length)break;else r=t.length}t.readingMore=false}c.prototype._read=function(e){this.emit("error",new Error("not implemented"))};c.prototype.pipe=function(e,t){var n=this;var s=this._readableState;switch(s.pipesCount){case 0:s.pipes=e;break;case 1:s.pipes=[s.pipes,e];break;default:s.pipes.push(e);break}s.pipesCount+=1;u("pipe count=%d opts=%j",s.pipesCount,t);var o=(!t||t.end!==false)&&e!==r.stdout&&e!==r.stderr;var f=o?c:d;if(s.endEmitted)r.nextTick(f);else n.once("end",f);e.on("unpipe",l);function l(e){u("onunpipe");if(e===n){d()}}function c(){u("onend");e.end()}var p=k(n);e.on("drain",p);function d(){u("cleanup");e.removeListener("close",v);e.removeListener("finish",g);e.removeListener("drain",p);e.removeListener("error",m);e.removeListener("unpipe",l);n.removeListener("end",c);n.removeListener("end",d);n.removeListener("data",h);if(s.awaitDrain&&(!e._writableState||e._writableState.needDrain))p()}n.on("data",h);function h(t){u("ondata");var r=e.write(t);if(false===r){u("false write response, pause",n._readableState.awaitDrain);n._readableState.awaitDrain++;n.pause()}}function m(t){u("onerror",t);y();e.removeListener("error",m);if(a.listenerCount(e,"error")===0)e.emit("error",t)}if(!e._events||!e._events.error)e.on("error",m);else if(i(e._events.error))e._events.error.unshift(m);else e._events.error=[m,e._events.error];function v(){e.removeListener("finish",g);y()}e.once("close",v);function g(){u("onfinish");e.removeListener("close",v);y()}e.once("finish",g);function y(){u("unpipe");n.unpipe(e)}e.emit("pipe",n);if(!s.flowing){u("pipe resume");n.resume()}return e};function k(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain);if(t.awaitDrain)t.awaitDrain--;if(t.awaitDrain===0&&a.listenerCount(e,"data")){t.flowing=true;A(e)}}}c.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 i=t.pipesCount;t.pipes=null;t.pipesCount=0;t.flowing=false;for(var n=0;n<i;n++)r[n].emit("unpipe",this);return this}var n=L(t.pipes,e);if(n===-1)return this;t.pipes.splice(n,1);t.pipesCount-=1;if(t.pipesCount===1)t.pipes=t.pipes[0];e.emit("unpipe",this);return this};c.prototype.on=function(e,t){var i=s.prototype.on.call(this,e,t);if(e==="data"&&false!==this._readableState.flowing){this.resume()}if(e==="readable"&&this.readable){var n=this._readableState;if(!n.readableListening){n.readableListening=true;n.emittedReadable=false;n.needReadable=true;if(!n.reading){var a=this;r.nextTick(function(){u("readable nexttick read 0");a.read(0)})}else if(n.length){_(this,n)}}}return i};c.prototype.addListener=c.prototype.on;c.prototype.resume=function(){var e=this._readableState;if(!e.flowing){u("resume");e.flowing=true;if(!e.reading){u("resume read 0");this.read(0)}S(this,e)}return this};function S(e,t){if(!t.resumeScheduled){t.resumeScheduled=true;r.nextTick(function(){E(e,t)})}}function E(e,t){t.resumeScheduled=false;e.emit("resume");A(e);if(t.flowing&&!t.reading)e.read(0)}c.prototype.pause=function(){u("call pause flowing=%j",this._readableState.flowing);if(false!==this._readableState.flowing){u("pause");this._readableState.flowing=false;this.emit("pause")}return this};function A(e){var t=e._readableState;u("flow",t.flowing);if(t.flowing){do{var r=e.read()}while(null!==r&&t.flowing)}}c.prototype.wrap=function(e){var t=this._readableState;var r=false;var i=this;e.on("end",function(){u("wrapped end");if(t.decoder&&!t.ended){var e=t.decoder.end();if(e&&e.length)i.push(e)}i.push(null)});e.on("data",function(n){u("wrapped data");if(t.decoder)n=t.decoder.write(n);if(!n||!t.objectMode&&!n.length)return;var a=i.push(n);if(!a){r=true;e.pause()}});for(var n in e){if(o.isFunction(e[n])&&o.isUndefined(this[n])){this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n)}}var a=["error","close","destroy","pause","resume"];T(a,function(t){e.on(t,i.emit.bind(i,t))});i._read=function(t){u("wrapped _read",t);if(r){r=false;e.resume()}};return i};c._fromList=U;function U(e,t){var r=t.buffer;var i=t.length;var a=!!t.decoder;var s=!!t.objectMode;var o;if(r.length===0)return null;if(i===0)o=null;else if(s)o=r.shift();else if(!e||e>=i){if(a)o=r.join("");else o=n.concat(r,i);r.length=0}else{if(e<r[0].length){var f=r[0];o=f.slice(0,e);r[0]=f.slice(e)}else if(e===r[0].length){o=r.shift()}else{if(a)o="";else o=new n(e);var u=0;for(var l=0,c=r.length;l<c&&u<e;l++){var f=r[0];var p=Math.min(e-u,f.length);if(a)o+=f.slice(0,p);else f.copy(o,u,0,p);if(p<f.length)r[0]=f.slice(p);else r.shift();u+=p}}}return o}function I(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");if(!t.endEmitted){t.ended=true;r.nextTick(function(){if(!t.endEmitted&&t.length===0){t.endEmitted=true;e.readable=false;e.emit("end")}})}}function T(e,t){for(var r=0,i=e.length;r<i;r++){t(e[r],r)}}function L(e,t){for(var r=0,i=e.length;r<i;r++){if(e[r]===t)return r}return-1}}).call(this,e("_process"))},{"./_stream_duplex":80,_process:48,buffer:39,"core-util-is":85,events:43,inherits:128,isarray:86,stream:66,"string_decoder/":87,util:38}],83:[function(e,t,r){t.exports=o;var i=e("./_stream_duplex");var n=e("core-util-is");n.inherits=e("inherits");n.inherits(o,i);function a(e,t){this.afterTransform=function(e,r){return s(t,e,r)};this.needTransform=false;this.transforming=false;this.writecb=null;this.writechunk=null}function s(e,t,r){var i=e._transformState;i.transforming=false;var a=i.writecb;if(!a)return e.emit("error",new Error("no writecb in Transform class"));i.writechunk=null;i.writecb=null;if(!n.isNullOrUndefined(r))e.push(r);if(a)a(t);var s=e._readableState;s.reading=false;if(s.needReadable||s.length<s.highWaterMark){e._read(s.highWaterMark)}}function o(e){if(!(this instanceof o))return new o(e);i.call(this,e);this._transformState=new a(e,this);var t=this;this._readableState.needReadable=true;this._readableState.sync=false;this.once("prefinish",function(){if(n.isFunction(this._flush))this._flush(function(e){f(t,e)});else f(t)})}o.prototype.push=function(e,t){this._transformState.needTransform=false;return i.prototype.push.call(this,e,t)};o.prototype._transform=function(e,t,r){throw new Error("not implemented")};o.prototype._write=function(e,t,r){var i=this._transformState;i.writecb=r;i.writechunk=e;i.writeencoding=t;if(!i.transforming){var n=this._readableState;if(i.needTransform||n.needReadable||n.length<n.highWaterMark)this._read(n.highWaterMark)}};o.prototype._read=function(e){var t=this._transformState;if(!n.isNull(t.writechunk)&&t.writecb&&!t.transforming){t.transforming=true;this._transform(t.writechunk,t.writeencoding,t.afterTransform)}else{t.needTransform=true}};function f(e,t){if(t)return e.emit("error",t);var r=e._writableState;var i=e._transformState;if(r.length)throw new Error("calling transform done when ws.length != 0");if(i.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}},{"./_stream_duplex":80,"core-util-is":85,inherits:128}],84:[function(e,t,r){(function(r){t.exports=f;var i=e("buffer").Buffer;f.WritableState=o;var n=e("core-util-is");n.inherits=e("inherits");var a=e("stream");n.inherits(f,a);function s(e,t,r){this.chunk=e;this.encoding=t;this.callback=r}function o(t,r){var i=e("./_stream_duplex");t=t||{};var n=t.highWaterMark;var a=t.objectMode?16:16*1024;this.highWaterMark=n||n===0?n:a;this.objectMode=!!t.objectMode;if(r instanceof i)this.objectMode=this.objectMode||!!t.writableObjectMode;this.highWaterMark=~~this.highWaterMark;this.needDrain=false;this.ending=false;this.ended=false;this.finished=false;var s=t.decodeStrings===false;this.decodeStrings=!s;this.defaultEncoding=t.defaultEncoding||"utf8";this.length=0;this.writing=false;this.corked=0;this.sync=true;this.bufferProcessing=false;this.onwrite=function(e){v(r,e)};this.writecb=null;this.writelen=0;this.buffer=[];this.pendingcb=0;this.prefinished=false;this.errorEmitted=false}function f(t){var r=e("./_stream_duplex");if(!(this instanceof f)&&!(this instanceof r))return new f(t);this._writableState=new o(t,this);this.writable=true;a.call(this)}f.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))};function u(e,t,i){var n=new Error("write after end");e.emit("error",n);r.nextTick(function(){i(n)})}function l(e,t,i,a){var s=true;if(!n.isBuffer(i)&&!n.isString(i)&&!n.isNullOrUndefined(i)&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o);r.nextTick(function(){a(o)});s=false}return s}f.prototype.write=function(e,t,r){var i=this._writableState;var a=false;if(n.isFunction(t)){r=t;t=null}if(n.isBuffer(e))t="buffer";else if(!t)t=i.defaultEncoding;if(!n.isFunction(r))r=function(){};if(i.ended)u(this,i,r);else if(l(this,i,e,r)){i.pendingcb++;a=p(this,i,e,t,r)}return a};f.prototype.cork=function(){var e=this._writableState;e.corked++};f.prototype.uncork=function(){var e=this._writableState;if(e.corked){e.corked--;if(!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.buffer.length)_(this,e)}};function c(e,t,r){if(!e.objectMode&&e.decodeStrings!==false&&n.isString(t)){t=new i(t,r)}return t}function p(e,t,r,i,a){r=c(t,r,i);if(n.isBuffer(r))i="buffer";var o=t.objectMode?1:r.length;t.length+=o;var f=t.length<t.highWaterMark;if(!f)t.needDrain=true;if(t.writing||t.corked)t.buffer.push(new s(r,i,a));else d(e,t,false,o,r,i,a);return f}function d(e,t,r,i,n,a,s){t.writelen=i;t.writecb=s;t.writing=true;t.sync=true;if(r)e._writev(n,t.onwrite);else e._write(n,a,t.onwrite);t.sync=false}function h(e,t,i,n,a){if(i)r.nextTick(function(){t.pendingcb--;a(n)});else{t.pendingcb--;a(n)}e._writableState.errorEmitted=true;e.emit("error",n)}function m(e){e.writing=false;e.writecb=null;e.length-=e.writelen;e.writelen=0}function v(e,t){var i=e._writableState;var n=i.sync;var a=i.writecb;m(i);if(t)h(e,i,n,t,a);else{var s=b(e,i);if(!s&&!i.corked&&!i.bufferProcessing&&i.buffer.length){_(e,i)}if(n){r.nextTick(function(){g(e,i,s,a)})}else{g(e,i,s,a)}}}function g(e,t,r,i){if(!r)y(e,t);t.pendingcb--;i();x(e,t)}function y(e,t){if(t.length===0&&t.needDrain){t.needDrain=false;e.emit("drain")}}function _(e,t){t.bufferProcessing=true;if(e._writev&&t.buffer.length>1){var r=[];for(var i=0;i<t.buffer.length;i++)r.push(t.buffer[i].callback);t.pendingcb++;d(e,t,true,t.length,t.buffer,"",function(e){for(var i=0;i<r.length;i++){t.pendingcb--;r[i](e)}});t.buffer=[]}else{for(var i=0;i<t.buffer.length;i++){var n=t.buffer[i];var a=n.chunk;var s=n.encoding;var o=n.callback;var f=t.objectMode?1:a.length;d(e,t,false,f,a,s,o);if(t.writing){i++;break}}if(i<t.buffer.length)t.buffer=t.buffer.slice(i);else t.buffer.length=0}t.bufferProcessing=false}f.prototype._write=function(e,t,r){r(new Error("not implemented"))};f.prototype._writev=null;f.prototype.end=function(e,t,r){var i=this._writableState;if(n.isFunction(e)){r=e;e=null;t=null}else if(n.isFunction(t)){r=t;t=null}if(!n.isNullOrUndefined(e))this.write(e,t);if(i.corked){i.corked=1;this.uncork()}if(!i.ending&&!i.finished)k(this,i,r)};function b(e,t){return t.ending&&t.length===0&&!t.finished&&!t.writing}function w(e,t){if(!t.prefinished){t.prefinished=true;e.emit("prefinish")}}function x(e,t){var r=b(e,t);if(r){if(t.pendingcb===0){w(e,t);t.finished=true;e.emit("finish")}else w(e,t)}return r}function k(e,t,i){t.ending=true;x(e,t);if(i){if(t.finished)r.nextTick(i);else e.once("finish",i)}t.ended=true}}).call(this,e("_process"))},{"./_stream_duplex":80,_process:48,buffer:39,"core-util-is":85,inherits:128,stream:66}],85:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{buffer:39,dup:59}],86:[function(e,t,r){arguments[4][45][0].apply(r,arguments)},{dup:45}],87:[function(e,t,r){arguments[4][76][0].apply(r,arguments)},{buffer:39,dup:76}],88:[function(e,t,r){r=t.exports=e("./lib/_stream_readable.js");r.Stream=e("stream");r.Readable=r;r.Writable=e("./lib/_stream_writable.js");r.Duplex=e("./lib/_stream_duplex.js");r.Transform=e("./lib/_stream_transform.js");r.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":80,"./lib/_stream_passthrough.js":81,"./lib/_stream_readable.js":82,"./lib/_stream_transform.js":83,"./lib/_stream_writable.js":84,stream:66}],89:[function(e,t,r){t.exports=s;var i=e("block-stream2");var n=e("inherits");var a=e("stream");n(s,a.Writable);function s(e,t,r){var n=this;if(!(n instanceof s)){return new s(e,t,r)}a.Writable.call(n,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");n._blockstream=new i(t,{zeroPadding:false});n._blockstream.on("data",f).on("error",function(e){n.destroy(e)});var o=0;function f(t){if(n.destroyed)return;e.put(o,t);o+=1}n.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":78,inherits:128,stream:66}],90:[function(e,t,r){(function(r,i){t.exports=_;t.exports.announceList=[["udp://tracker.publicbt.com:80"],["udp://tracker.openbittorrent.com:80"],["udp://open.demonii.com:1337"],["udp://tracker.webtorrent.io:80"],["wss://tracker.webtorrent.io"]];t.exports.parseInput=b;var n=e("bencode");var a=e("block-stream2");var s=e("piece-length");var o=e("path");var f=e("dezalgo");var u=e("filestream/read");var l=e("flatten");var c=e("fs");var p=e("is-file");var d=e("junk");var h=e("multistream");var m=e("once");var v=e("run-parallel");var g=e("simple-sha1");var y=e("stream");function _(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};b(e,t,function(e,i,n){if(e)return r(e);t.singleFileTorrent=n;A(i,t,r)})}function b(e,t,r){if(typeof t==="function"){r=t;t={}}if(!t)t={};r=f(r);if(Array.isArray(e)&&e.length===0)throw new Error("invalid input type");if(T(e))e=Array.prototype.slice.call(e);if(!Array.isArray(e))e=[e];if(!t.name)t.name=e[0]&&e[0].name;if(!t.name)t.name=typeof e[0]==="string"&&o.basename(e[0]);if(t.name===undefined){throw new Error("missing option 'name' and unable to infer it from input[0].name")}if(e.length===1&&!e[0].name)e[0].name=t.name;var n=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"){p(e[0],function(e,t){if(e)return r(e);a=t;s()})}else{s()}function s(){v(e.map(function(e){return function(r){var s={};if(I(e)){s.getStream=B(e);s.length=e.size}else if(i.isBuffer(e)){s.getStream=C(e);s.length=e.length}else if(L(e)){if(!t.pieceLength){throw new Error("must specify `pieceLength` option if input is Stream")}s.getStream=P(e,s);s.length=0}else if(typeof e==="string"){if(typeof c.readdir!=="function"){throw new Error("filesystem paths do not work in the browser")}var f=n>1||a;w(e,f,r);return}else{throw new Error("invalid input type")}if(!e.name)throw new Error("missing requied `name` property on input");s.path=e.name.split(o.sep);r(null,s)}}),function(e,t){if(e)return r(e);t=l(t);r(null,t,a)})}}function w(e,t,r){k(e,x,function(i,n){if(i)return r(i);if(Array.isArray(n))n=l(n);else n=[n];e=o.normalize(e);if(t){e=e.slice(0,e.lastIndexOf(o.sep)+1)}if(e[e.length-1]!==o.sep)e+=o.sep;n.forEach(function(t){t.getStream=R(t.path);t.path=t.path.replace(e,"").split(o.sep)});r(null,n)})}function x(e,t){t=m(t);c.stat(e,function(r,i){if(r)return t(r);var n={length:i.size,path:e};t(null,n)})}function k(e,t,r){c.readdir(e,function(i,n){if(i&&i.code==="ENOTDIR"){t(e,r)}else if(i){r(i)}else{v(n.filter(S).filter(d.not).map(function(r){return function(i){k(o.join(e,r),t,i)}}),r)}})}function S(e){return e[0]!=="."}function E(e,t,r){r=m(r);var n=[];var s=0;var o=e.map(function(e){return e.getStream});var f=0;var u=0;var l=false;var c=new h(o);var p=new a(t,{zeroPadding:false});c.on("error",y);c.pipe(p).on("data",d).on("end",v).on("error",y);function d(e){s+=e.length;var t=u;g(e,function(e){n[t]=e;f-=1;b()});f+=1;u+=1}function v(){l=true;b()}function y(e){_();r(e)}function _(){c.removeListener("error",y);p.removeListener("data",d);p.removeListener("end",v);p.removeListener("error",y)}function b(){if(l&&f===0){_();r(null,new i(n.join(""),"hex"),s)}}}function A(e,i,a){var o=i.announceList;if(!o){if(typeof i.announce==="string")o=[[i.announce]];else if(Array.isArray(i.announce)){o=i.announce.map(function(e){return[e]})}}if(!o)o=[];if(r.WEBTORRENT_ANNOUNCE){if(typeof r.WEBTORRENT_ANNOUNCE==="string"){o.push([[r.WEBTORRENT_ANNOUNCE]])}else if(Array.isArray(r.WEBTORRENT_ANNOUNCE)){o=o.concat(r.WEBTORRENT_ANNOUNCE.map(function(e){return[e]}))}}if(o.length===0){o=o.concat(t.exports.announceList)}if(typeof i.urlList==="string")i.urlList=[i.urlList];var f={info:{name:i.name},announce:o[0][0],"announce-list":o,"creation date":Number(i.creationDate)||Date.now(),encoding:"UTF-8"};if(i.comment!==undefined)f.comment=i.comment;if(i.createdBy!==undefined)f["created by"]=i.createdBy;if(i.private!==undefined)f.info.private=Number(i.private);if(i.sslCert!==undefined)f.info["ssl-cert"]=i.sslCert;if(i.urlList!==undefined)f["url-list"]=i.urlList;var u=i.pieceLength||s(e.reduce(U,0));f.info["piece length"]=u;E(e,u,function(t,r,s){if(t)return a(t);f.info.pieces=r;e.forEach(function(e){delete e.getStream});if(i.singleFileTorrent){f.info.length=s}else{f.info.files=e}a(null,n.encode(f))})}function U(e,t){return e+t.length}function I(e){return typeof Blob!=="undefined"&&e instanceof Blob}function T(e){return typeof FileList==="function"&&e instanceof FileList}function L(e){return typeof e==="object"&&typeof e.pipe==="function"}function B(e){return function(){return new u(e)}}function C(e){return function(){var t=new y.PassThrough;t.end(e);return t}}function R(e){return function(){return c.createReadStream(e)}}function P(e,t){return function(){var r=new y.Transform;r._transform=function(e,r,i){t.length+=e.length;this.push(e);i()};e.pipe(r);return r}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{bencode:91,"block-stream2":95,buffer:39,dezalgo:106,"filestream/read":112,flatten:113,fs:37,"is-file":114,junk:115,multistream:133,once:117,path:47,"piece-length":118,"run-parallel":154,"simple-sha1":163,stream:66}],91:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{"./lib/decode":92,"./lib/encode":94,dup:15}],92:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./dict":93,buffer:39,dup:16}],93:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{dup:17}],94:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{buffer:39,dup:18}],95:[function(e,t,r){arguments[4][78][0].apply(r,arguments)},{buffer:39,defined:96,dup:78,inherits:128,"readable-stream":105}],96:[function(e,t,r){arguments[4][79][0].apply(r,arguments)},{dup:79}],97:[function(e,t,r){arguments[4][80][0].apply(r,arguments)},{"./_stream_readable":99,"./_stream_writable":101,_process:48,"core-util-is":102,dup:80,inherits:128}],98:[function(e,t,r){arguments[4][81][0].apply(r,arguments)},{"./_stream_transform":100,"core-util-is":102,dup:81,inherits:128}],99:[function(e,t,r){arguments[4][82][0].apply(r,arguments)},{"./_stream_duplex":97,_process:48,buffer:39,"core-util-is":102,dup:82,events:43,inherits:128,isarray:103,stream:66,"string_decoder/":104,util:38}],100:[function(e,t,r){arguments[4][83][0].apply(r,arguments)},{"./_stream_duplex":97,"core-util-is":102,dup:83,inherits:128}],101:[function(e,t,r){arguments[4][84][0].apply(r,arguments)},{"./_stream_duplex":97,_process:48,buffer:39,"core-util-is":102,dup:84,inherits:128,stream:66}],102:[function(e,t,r){arguments[4][59][0].apply(r,arguments)},{buffer:39,dup:59}],103:[function(e,t,r){arguments[4][45][0].apply(r,arguments)},{dup:45}],104:[function(e,t,r){arguments[4][76][0].apply(r,arguments)},{buffer:39,dup:76}],105:[function(e,t,r){arguments[4][88][0].apply(r,arguments)},{"./lib/_stream_duplex.js":97,"./lib/_stream_passthrough.js":98,"./lib/_stream_readable.js":99,"./lib/_stream_transform.js":100,"./lib/_stream_writable.js":101,dup:88,stream:66}],106:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{asap:107,dup:19,wrappy:109}],107:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{"./raw":108,dup:20}],108:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],109:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],110:[function(e,t,r){arguments[4][33][0].apply(r,arguments)},{buffer:39,dup:33,"is-typedarray":111}],111:[function(e,t,r){arguments[4][32][0].apply(r,arguments)},{dup:32}],112:[function(e,t,r){var i=e("stream").Readable;var n=e("inherits");var a=/^.*\.(\w+)$/;var s=e("typedarray-to-buffer");function o(e,t){var r=this;if(!(this instanceof o)){return new o(e,t)}t=t||{};i.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")})}n(o,i);t.exports=o;o.prototype._generateHeaderBlocks=function(e,t,r){r(null,[])};o.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 i=this._offset+this._chunkSize;if(i>this._size)i=this._size;if(r===this._size){this.destroy();this.push(null);return}t.onload=function(){e._offset=i;e.push(s(t.result))};t.onerror=function(){e.emit("error",t.error)};t.readAsArrayBuffer(this._file.slice(r,i))};o.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:128,stream:66,"typedarray-to-buffer":110}],113:[function(e,t,r){t.exports=function i(e,t){t=typeof t=="number"?t:Infinity;return r(e,1);function r(e,i){return e.reduce(function(e,n){if(Array.isArray(n)&&i<t){return e.concat(r(n,i+1))}else{return e.concat(n)}},[])}}},{}],114:[function(e,t,r){"use strict";var i=e("fs");t.exports=function a(e,t){if(!t)return n(e);i.stat(e,function(e,r){if(e)return t(e);return t(null,r.isFile())})};t.exports.sync=n;function n(e){return i.existsSync(e)&&i.statSync(e).isFile()}},{fs:37}],115:[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)}},{}],116:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],117:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29,wrappy:116}],118:[function(e,t,r){var i=e("closest-to");var n=[];for(var a=14;a<=22;a++){n.push(Math.pow(2,a))}t.exports=function(e){return i(e/Math.pow(2,10),n)}},{"closest-to":119}],119:[function(e,t,r){t.exports=function(e,t){var r=Infinity;var i=0;var n=null;t.sort(function(e,t){return e-t});for(var a=0,s=t.length;a<s;a++){i=Math.abs(e-t[a]);if(i>=r){break}r=i;n=t[a]}return n}},{}],120:[function(e,t,r){r=t.exports=e("./debug");r.log=a;r.formatArgs=n;r.save=s;r.load=o;r.useColors=i;r.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:f();r.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"];function i(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}r.formatters.j=function(e){return JSON.stringify(e)};function n(){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 i="color: "+this.color;e=[e[0],i,"color: inherit"].concat(Array.prototype.slice.call(e,1));var n=0;var a=0;e[0].replace(/%[a-z%]/g,function(e){if("%%"===e)return;n++;if("%c"===e){a=n}});e.splice(a,0,i);return e}function a(){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 o(){var e;try{e=r.storage.debug}catch(t){}return e}r.enable(o());function f(){try{return window.localStorage}catch(e){}}},{"./debug":121}],121:[function(e,t,r){r=t.exports=s;r.coerce=l;r.disable=f;r.enable=o;r.enabled=u;r.humanize=e("ms");r.names=[];r.skips=[];r.formatters={};var i=0;var n;function a(){return r.colors[i++%r.colors.length]}function s(e){function t(){}t.enabled=false;function i(){var e=i;var t=+new Date;var s=t-(n||t);e.diff=s;e.prev=n;e.curr=t;n=t;if(null==e.useColors)e.useColors=r.useColors();if(null==e.color&&e.useColors)e.color=a();var o=Array.prototype.slice.call(arguments);o[0]=r.coerce(o[0]);if("string"!==typeof o[0]){o=["%o"].concat(o)}var f=0;o[0]=o[0].replace(/%([a-z%])/g,function(t,i){if(t==="%%")return t;f++;var n=r.formatters[i];if("function"===typeof n){var a=o[f];t=n.call(e,a);o.splice(f,1);f--}return t});if("function"===typeof r.formatArgs){o=r.formatArgs.apply(e,o)}var u=i.log||r.log||console.log.bind(console);u.apply(e,o)}i.enabled=true;var s=r.enabled(e)?i:t;s.namespace=e;return s}function o(e){r.save(e);var t=(e||"").split(/[\s,]+/);var i=t.length;for(var n=0;n<i;n++){if(!t[n])continue;e=t[n].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,i;for(t=0,i=r.skips.length;t<i;t++){if(r.skips[t].test(e)){return false}}for(t=0,i=r.names.length;t<i;t++){if(r.names[t].test(e)){return true}}return false}function l(e){if(e instanceof Error)return e.stack||e.message;return e}},{ms:122}],122:[function(e,t,r){var i=1e3;var n=i*60;var a=n*60;var s=a*24;var o=s*365.25;t.exports=function(e,t){t=t||{};if("string"==typeof e)return f(e);return t.long?l(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*o;case"days":case"day":case"d":return r*s;case"hours":case"hour":case"hrs":case"hr":case"h":return r*a;case"minutes":case"minute":case"mins":case"min":case"m":return r*n;case"seconds":case"second":case"secs":case"sec":case"s":return r*i;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>=a)return Math.round(e/a)+"h";if(e>=n)return Math.round(e/n)+"m";if(e>=i)return Math.round(e/i)+"s";return e+"ms"}function l(e){return c(e,s,"day")||c(e,a,"hour")||c(e,n,"minute")||c(e,i,"second")||e+" ms"}function c(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"}},{}],123:[function(e,t,r){var i=e("once");var n=function(){};var a=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 o=function(e,t,r){if(typeof t==="function")return o(e,null,t);if(!t)t={};r=i(r||n);var f=e._writableState;var u=e._readableState;var l=t.readable||t.readable!==false&&e.readable;var c=t.writable||t.writable!==false&&e.writable;var p=function(){if(!e.writable)d()};var d=function(){c=false;if(!l)r()};var h=function(){l=false;if(!c)r()};var m=function(e){r(e?new Error("exited with error code: "+e):null)};var v=function(){if(l&&!(u&&u.ended))return r(new Error("premature close"));if(c&&!(f&&f.ended))return r(new Error("premature close"))};var g=function(){e.req.on("finish",d)};if(a(e)){e.on("complete",d);e.on("abort",v);if(e.req)g();else e.on("request",g)}else if(c&&!f){e.on("end",p);e.on("close",p)}if(s(e))e.on("exit",m);e.on("end",h);e.on("finish",d);if(t.error!==false)e.on("error",r);e.on("close",v);return function(){e.removeListener("complete",d);e.removeListener("abort",v);e.removeListener("request",g);if(e.req)e.req.removeListener("finish",d);e.removeListener("end",p);e.removeListener("close",p);e.removeListener("finish",d);e.removeListener("exit",m);e.removeListener("end",h);e.removeListener("error",r);e.removeListener("close",v)}};t.exports=o},{once:125}],124:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],125:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29,wrappy:124}],126:[function(e,t,r){var i=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 n=2;r===Infinity;n*=2){r=Math.log(Math.pow(2,e/n))/Math.log(t)*n}var a=r-Math.floor(r);var s="";for(var n=0;n<Math.floor(r);n++){var o=Math.floor(Math.random()*t).toString(t);s=o+s}if(a){var f=Math.pow(t,a);var o=Math.floor(Math.random()*f).toString(t);s=o+s}var u=parseInt(s,t);if(u!==Infinity&&u>=Math.pow(2,e)){return i(e,t)}else return s};i.rack=function(e,t,r){var n=function(n){var s=0;do{if(s++>10){if(r)e+=r;else throw new Error("too many ID collisions, use more bits")}var o=i(e,t)}while(Object.hasOwnProperty.call(a,o));a[o]=n;return o};var a=n.hats={};n.get=function(e){return n.hats[e]};n.set=function(e,t){n.hats[e]=t;return n};n.bits=e||128;n.base=t||16;return n}},{}],127:[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 i=this;i.mem[e]=t;i.store.put(e,t,function(t){i.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 n=t&&t.offset||0;var a=t&&t.length&&n+t.length;var s=this.mem[e];if(s)return i(r,null,t?s.slice(n,a):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 i(t,r,i){e.nextTick(function(){if(t)t(r,i)})}}).call(this,e("_process"))},{_process:48}],128:[function(e,t,r){if(typeof Object.create==="function"){t.exports=function i(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}}else{t.exports=function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype;e.prototype=new r;e.prototype.constructor=e}}},{}],129:[function(e,t,r){t.exports=s;var i=e("inherits");var n=e("stream");var a=typeof window!=="undefined"&&window.MediaSource;i(s,n.Writable);function s(e,t){var r=this;if(!(r instanceof s))return new s(e,t);n.Writable.call(r,t);if(!a)throw new Error("web browser lacks MediaSource support");if(!t)t={};r._elem=e;r._mediaSource=new a;r._sourceBuffer=null;r._cb=null;r._type=t.type||o(t.extname);if(!r._type)throw new Error("missing `opts.type` or `opts.extname` options");r._elem.src=window.URL.createObjectURL(r._mediaSource);r._mediaSource.addEventListener("sourceopen",function(){if(a.isTypeSupported(r._type)){r._sourceBuffer=r._mediaSource.addSourceBuffer(r._type);r._sourceBuffer.addEventListener("updateend",r._flow.bind(r));r._flow()}else{r._mediaSource.endOfStream("decode")}});r.on("finish",function(){r._mediaSource.endOfStream()})}s.prototype._write=function(e,t,r){var i=this;if(!i._sourceBuffer){i._cb=function(n){if(n)return r(n);i._write(e,t,r)};return}if(i._sourceBuffer.updating){return r(new Error("Cannot append buffer while source buffer updating"))}i._sourceBuffer.appendBuffer(e);i._cb=r};s.prototype._flow=function(){var e=this;if(e._cb){e._cb(null)}};function o(e){if(!e)return null;if(e[0]!==".")e="."+e;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"'}[e]}},{inherits:128,stream:66}],130:[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 i(r,new Error("Storage is closed"));var n=e===this.lastChunkIndex;if(n&&t.length!==this.lastChunkLength){return i(r,new Error("Last chunk length must be "+this.lastChunkLength))}if(!n&&t.length!==this.chunkLength){return i(r,new Error("Chunk length must be "+this.chunkLength))}this.chunks[e]=t;i(r,null)};r.prototype.get=function(e,t,r){if(typeof t==="function")return this.get(e,null,t);if(this.closed)return i(r,new Error("Storage is closed"));var n=this.chunks[e];if(!n)return i(r,new Error("Chunk not found"));if(!t)return i(r,null,n);var a=t.offset||0;var s=t.length||n.length-a;i(r,null,n.slice(a,s+a))};r.prototype.close=r.prototype.destroy=function(e){if(this.closed)return i(e,new Error("Storage is closed"));this.closed=true;this.chunks=null;i(e,null)};function i(t,r,i){e.nextTick(function(){if(t)t(r,i)})}}).call(this,e("_process"))},{_process:48}],131:[function(e,t,r){(function(r){var i=e("path");var n=e("fs");function a(){this.types=Object.create(null);this.extensions=Object.create(null)}a.prototype.define=function(e){for(var t in e){var i=e[t];for(var n=0;n<i.length;n++){if(r.env.DEBUG_MIME&&this.types[i]){console.warn(this._loading.replace(/.*\//,""),'changes "'+i[n]+'" extension type from '+this.types[i]+" to "+t)}this.types[i[n]]=t}if(!this.extensions[t]){this.extensions[t]=i[0]}}};a.prototype.load=function(e){this._loading=e;var t={},r=n.readFileSync(e,"ascii"),i=r.split(/[\r\n]+/);i.forEach(function(e){var r=e.replace(/\s*#.*|^\s*|\s*$/g,"").split(/\s+/);t[r.shift()]=r});this.define(t);this._loading=null};a.prototype.lookup=function(e,t){var r=e.replace(/.*[\.\/\\]/,"").toLowerCase();return this.types[r]||t||this.default_type};a.prototype.extension=function(e){var t=e.match(/^\s*([^;\s]*)(?:;|\s|$)/)[1].toLowerCase();return this.extensions[t]};var s=new a;s.define(e("./types.json"));s.default_type=s.lookup("bin");s.Mime=a;s.charsets={lookup:function(e,t){return/^text\//.test(e)?"UTF-8":t}};t.exports=s}).call(this,e("_process"))},{"./types.json":132,_process:48,fs:37,path:47}],132:[function(e,t,r){t.exports={"application/andrew-inset":["ez"],"application/applixware":["aw"],"application/atom+xml":["atom"],"application/atomcat+xml":["atomcat"],"application/atomsvc+xml":["atomsvc"],"application/ccxml+xml":["ccxml"],"application/cdmi-capability":["cdmia"],"application/cdmi-container":["cdmic"],"application/cdmi-domain":["cdmid"],"application/cdmi-object":["cdmio"],"application/cdmi-queue":["cdmiq"],"application/cu-seeme":["cu"],"application/dash+xml":["mdp"],"application/davmount+xml":["davmount"],"application/docbook+xml":["dbk"],"application/dssc+der":["dssc"],"application/dssc+xml":["xdssc"],"application/ecmascript":["ecma"],"application/emma+xml":["emma"],"application/epub+zip":["epub"],"application/exi":["exi"],"application/font-tdpfr":["pfr"],"application/font-woff":["woff"],"application/font-woff2":["woff2"],"application/gml+xml":["gml"],"application/gpx+xml":["gpx"],"application/gxf":["gxf"],"application/hyperstudio":["stk"],"application/inkml+xml":["ink","inkml"],"application/ipfix":["ipfix"],"application/java-archive":["jar"],"application/java-serialized-object":["ser"],"application/java-vm":["class"],"application/javascript":["js"],"application/json":["json","map"],"application/json5":["json5"],"application/jsonml+json":["jsonml"],"application/lost+xml":["lostxml"],"application/mac-binhex40":["hqx"],"application/mac-compactpro":["cpt"],"application/mads+xml":["mads"],"application/marc":["mrc"],"application/marcxml+xml":["mrcx"],"application/mathematica":["ma","nb","mb"],"application/mathml+xml":["mathml"],"application/mbox":["mbox"],"application/mediaservercontrol+xml":["mscml"],"application/metalink+xml":["metalink"],"application/metalink4+xml":["meta4"],"application/mets+xml":["mets"],"application/mods+xml":["mods"],"application/mp21":["m21","mp21"],"application/mp4":["mp4s","m4p"],"application/msword":["doc","dot"],"application/mxf":["mxf"],"application/octet-stream":["bin","dms","lrf","mar","so","dist","distz","pkg","bpk","dump","elc","deploy","buffer"],"application/oda":["oda"],"application/oebps-package+xml":["opf"],"application/ogg":["ogx"],"application/omdoc+xml":["omdoc"],"application/onenote":["onetoc","onetoc2","onetmp","onepkg"],"application/oxps":["oxps"],"application/patch-ops-error+xml":["xer"],"application/pdf":["pdf"],"application/pgp-encrypted":["pgp"],"application/pgp-signature":["asc","sig"],"application/pics-rules":["prf"],"application/pkcs10":["p10"],"application/pkcs7-mime":["p7m","p7c"],"application/pkcs7-signature":["p7s"],"application/pkcs8":["p8"],"application/pkix-attr-cert":["ac"],"application/pkix-cert":["cer"],"application/pkix-crl":["crl"],"application/pkix-pkipath":["pkipath"],"application/pkixcmp":["pki"],"application/pls+xml":["pls"],"application/postscript":["ai","eps","ps"],"application/prs.cww":["cww"],"application/pskc+xml":["pskcxml"],"application/rdf+xml":["rdf"],"application/reginfo+xml":["rif"],"application/relax-ng-compact-syntax":["rnc"],"application/resource-lists+xml":["rl"],"application/resource-lists-diff+xml":["rld"],"application/rls-services+xml":["rs"],"application/rpki-ghostbusters":["gbr"],"application/rpki-manifest":["mft"],"application/rpki-roa":["roa"],"application/rsd+xml":["rsd"],"application/rss+xml":["rss"],"application/rtf":["rtf"],"application/sbml+xml":["sbml"],"application/scvp-cv-request":["scq"],"application/scvp-cv-response":["scs"],"application/scvp-vp-request":["spq"],"application/scvp-vp-response":["spp"],"application/sdp":["sdp"],"application/set-payment-initiation":["setpay"],"application/set-registration-initiation":["setreg"],"application/shf+xml":["shf"],"application/smil+xml":["smi","smil"],"application/sparql-query":["rq"],"application/sparql-results+xml":["srx"],"application/srgs":["gram"],"application/srgs+xml":["grxml"],"application/sru+xml":["sru"],"application/ssdl+xml":["ssdl"],"application/ssml+xml":["ssml"],"application/tei+xml":["tei","teicorpus"],"application/thraud+xml":["tfi"],"application/timestamped-data":["tsd"],"application/vnd.3gpp.pic-bw-large":["plb"],"application/vnd.3gpp.pic-bw-small":["psb"],"application/vnd.3gpp.pic-bw-var":["pvb"],"application/vnd.3gpp2.tcap":["tcap"],"application/vnd.3m.post-it-notes":["pwn"],"application/vnd.accpac.simply.aso":["aso"],"application/vnd.accpac.simply.imp":["imp"],"application/vnd.acucobol":["acu"],"application/vnd.acucorp":["atc","acutc"],"application/vnd.adobe.air-application-installer-package+zip":["air"],"application/vnd.adobe.formscentral.fcdt":["fcdt"],"application/vnd.adobe.fxp":["fxp","fxpl"],"application/vnd.adobe.xdp+xml":["xdp"],"application/vnd.adobe.xfdf":["xfdf"],"application/vnd.ahead.space":["ahead"],"application/vnd.airzip.filesecure.azf":["azf"],"application/vnd.airzip.filesecure.azs":["azs"],"application/vnd.amazon.ebook":["azw"],"application/vnd.americandynamics.acc":["acc"],"application/vnd.amiga.ami":["ami"],"application/vnd.android.package-archive":["apk"],"application/vnd.anser-web-certificate-issue-initiation":["cii"],"application/vnd.anser-web-funds-transfer-initiation":["fti"],"application/vnd.antix.game-component":["atx"],"application/vnd.apple.installer+xml":["mpkg"],"application/vnd.apple.mpegurl":["m3u8"],"application/vnd.aristanetworks.swi":["swi"],"application/vnd.astraea-software.iota":["iota"],"application/vnd.audiograph":["aep"],"application/vnd.blueice.multipass":["mpm"],"application/vnd.bmi":["bmi"],"application/vnd.businessobjects":["rep"],"application/vnd.chemdraw+xml":["cdxml"],"application/vnd.chipnuts.karaoke-mmd":["mmd"],"application/vnd.cinderella":["cdy"],"application/vnd.claymore":["cla"],"application/vnd.cloanto.rp9":["rp9"],"application/vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"application/vnd.cluetrust.cartomobile-config":["c11amc"],"application/vnd.cluetrust.cartomobile-config-pkg":["c11amz"],"application/vnd.commonspace":["csp"],"application/vnd.contact.cmsg":["cdbcmsg"],"application/vnd.cosmocaller":["cmc"],"application/vnd.crick.clicker":["clkx"],"application/vnd.crick.clicker.keyboard":["clkk"],"application/vnd.crick.clicker.palette":["clkp"],"application/vnd.crick.clicker.template":["clkt"],"application/vnd.crick.clicker.wordbank":["clkw"],"application/vnd.criticaltools.wbs+xml":["wbs"],"application/vnd.ctc-posml":["pml"],"application/vnd.cups-ppd":["ppd"],"application/vnd.curl.car":["car"],"application/vnd.curl.pcurl":["pcurl"],"application/vnd.dart":["dart"],"application/vnd.data-vision.rdz":["rdz"],"application/vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"application/vnd.dece.ttml+xml":["uvt","uvvt"],"application/vnd.dece.unspecified":["uvx","uvvx"],"application/vnd.dece.zip":["uvz","uvvz"],"application/vnd.denovo.fcselayout-link":["fe_launch"],"application/vnd.dna":["dna"],"application/vnd.dolby.mlp":["mlp"],"application/vnd.dpgraph":["dpg"],"application/vnd.dreamfactory":["dfac"],"application/vnd.ds-keypoint":["kpxx"],"application/vnd.dvb.ait":["ait"],"application/vnd.dvb.service":["svc"],"application/vnd.dynageo":["geo"],"application/vnd.ecowin.chart":["mag"],"application/vnd.enliven":["nml"],"application/vnd.epson.esf":["esf"],"application/vnd.epson.msf":["msf"],"application/vnd.epson.quickanime":["qam"],"application/vnd.epson.salt":["slt"],"application/vnd.epson.ssf":["ssf"],"application/vnd.eszigno3+xml":["es3","et3"],"application/vnd.ezpix-album":["ez2"],"application/vnd.ezpix-package":["ez3"],"application/vnd.fdf":["fdf"],"application/vnd.fdsn.mseed":["mseed"],"application/vnd.fdsn.seed":["seed","dataless"],"application/vnd.flographit":["gph"],"application/vnd.fluxtime.clip":["ftc"],"application/vnd.framemaker":["fm","frame","maker","book"],"application/vnd.frogans.fnc":["fnc"],"application/vnd.frogans.ltf":["ltf"],"application/vnd.fsc.weblaunch":["fsc"],"application/vnd.fujitsu.oasys":["oas"],"application/vnd.fujitsu.oasys2":["oa2"],"application/vnd.fujitsu.oasys3":["oa3"],"application/vnd.fujitsu.oasysgp":["fg5"],"application/vnd.fujitsu.oasysprs":["bh2"],"application/vnd.fujixerox.ddd":["ddd"],"application/vnd.fujixerox.docuworks":["xdw"],"application/vnd.fujixerox.docuworks.binder":["xbd"],"application/vnd.fuzzysheet":["fzs"],"application/vnd.genomatix.tuxedo":["txd"],"application/vnd.geogebra.file":["ggb"],"application/vnd.geogebra.tool":["ggt"],"application/vnd.geometry-explorer":["gex","gre"],"application/vnd.geonext":["gxt"],"application/vnd.geoplan":["g2w"],"application/vnd.geospace":["g3w"],"application/vnd.gmx":["gmx"],"application/vnd.google-earth.kml+xml":["kml"],"application/vnd.google-earth.kmz":["kmz"],"application/vnd.grafeq":["gqf","gqs"],"application/vnd.groove-account":["gac"],"application/vnd.groove-help":["ghf"],"application/vnd.groove-identity-message":["gim"],"application/vnd.groove-injector":["grv"],"application/vnd.groove-tool-message":["gtm"],"application/vnd.groove-tool-template":["tpl"],"application/vnd.groove-vcard":["vcg"],"application/vnd.hal+xml":["hal"],"application/vnd.handheld-entertainment+xml":["zmm"],"application/vnd.hbci":["hbci"],"application/vnd.hhe.lesson-player":["les"],"application/vnd.hp-hpgl":["hpgl"],"application/vnd.hp-hpid":["hpid"],"application/vnd.hp-hps":["hps"],"application/vnd.hp-jlyt":["jlt"],"application/vnd.hp-pcl":["pcl"],"application/vnd.hp-pclxl":["pclxl"],"application/vnd.ibm.minipay":["mpy"],"application/vnd.ibm.modcap":["afp","listafp","list3820"],"application/vnd.ibm.rights-management":["irm"],"application/vnd.ibm.secure-container":["sc"],"application/vnd.iccprofile":["icc","icm"],"application/vnd.igloader":["igl"],"application/vnd.immervision-ivp":["ivp"],"application/vnd.immervision-ivu":["ivu"],"application/vnd.insors.igm":["igm"],"application/vnd.intercon.formnet":["xpw","xpx"],"application/vnd.intergeo":["i2g"],"application/vnd.intu.qbo":["qbo"],"application/vnd.intu.qfx":["qfx"],"application/vnd.ipunplugged.rcprofile":["rcprofile"],"application/vnd.irepository.package+xml":["irp"],"application/vnd.is-xpr":["xpr"],"application/vnd.isac.fcs":["fcs"],"application/vnd.jam":["jam"],"application/vnd.jcp.javame.midlet-rms":["rms"],"application/vnd.jisp":["jisp"],"application/vnd.joost.joda-archive":["joda"],"application/vnd.kahootz":["ktz","ktr"],"application/vnd.kde.karbon":["karbon"],"application/vnd.kde.kchart":["chrt"],"application/vnd.kde.kformula":["kfo"],"application/vnd.kde.kivio":["flw"],"application/vnd.kde.kontour":["kon"],"application/vnd.kde.kpresenter":["kpr","kpt"],"application/vnd.kde.kspread":["ksp"],"application/vnd.kde.kword":["kwd","kwt"],"application/vnd.kenameaapp":["htke"],"application/vnd.kidspiration":["kia"],"application/vnd.kinar":["kne","knp"],"application/vnd.koan":["skp","skd","skt","skm"],"application/vnd.kodak-descriptor":["sse"],"application/vnd.las.las+xml":["lasxml"],"application/vnd.llamagraphics.life-balance.desktop":["lbd"],"application/vnd.llamagraphics.life-balance.exchange+xml":["lbe"],"application/vnd.lotus-1-2-3":["123"],"application/vnd.lotus-approach":["apr"],"application/vnd.lotus-freelance":["pre"],"application/vnd.lotus-notes":["nsf"],"application/vnd.lotus-organizer":["org"],"application/vnd.lotus-screencam":["scm"],"application/vnd.lotus-wordpro":["lwp"],"application/vnd.macports.portpkg":["portpkg"],"application/vnd.mcd":["mcd"],"application/vnd.medcalcdata":["mc1"],"application/vnd.mediastation.cdkey":["cdkey"],"application/vnd.mfer":["mwf"],"application/vnd.mfmp":["mfm"],"application/vnd.micrografx.flo":["flo"],"application/vnd.micrografx.igx":["igx"],"application/vnd.mif":["mif"],"application/vnd.mobius.daf":["daf"],"application/vnd.mobius.dis":["dis"],"application/vnd.mobius.mbk":["mbk"],"application/vnd.mobius.mqy":["mqy"],"application/vnd.mobius.msl":["msl"],"application/vnd.mobius.plc":["plc"],"application/vnd.mobius.txf":["txf"],"application/vnd.mophun.application":["mpn"],"application/vnd.mophun.certificate":["mpc"],"application/vnd.mozilla.xul+xml":["xul"],"application/vnd.ms-artgalry":["cil"],"application/vnd.ms-cab-compressed":["cab"],"application/vnd.ms-excel":["xls","xlm","xla","xlc","xlt","xlw"],"application/vnd.ms-excel.addin.macroenabled.12":["xlam"],"application/vnd.ms-excel.sheet.binary.macroenabled.12":["xlsb"],"application/vnd.ms-excel.sheet.macroenabled.12":["xlsm"],"application/vnd.ms-excel.template.macroenabled.12":["xltm"],"application/vnd.ms-fontobject":["eot"],"application/vnd.ms-htmlhelp":["chm"],"application/vnd.ms-ims":["ims"],"application/vnd.ms-lrm":["lrm"],"application/vnd.ms-officetheme":["thmx"],"application/vnd.ms-pki.seccat":["cat"],"application/vnd.ms-pki.stl":["stl"],"application/vnd.ms-powerpoint":["ppt","pps","pot"],"application/vnd.ms-powerpoint.addin.macroenabled.12":["ppam"],"application/vnd.ms-powerpoint.presentation.macroenabled.12":["pptm"],"application/vnd.ms-powerpoint.slide.macroenabled.12":["sldm"],"application/vnd.ms-powerpoint.slideshow.macroenabled.12":["ppsm"],"application/vnd.ms-powerpoint.template.macroenabled.12":["potm"],"application/vnd.ms-project":["mpp","mpt"],"application/vnd.ms-word.document.macroenabled.12":["docm"],"application/vnd.ms-word.template.macroenabled.12":["dotm"],"application/vnd.ms-works":["wps","wks","wcm","wdb"],"application/vnd.ms-wpl":["wpl"],"application/vnd.ms-xpsdocument":["xps"],"application/vnd.mseq":["mseq"],"application/vnd.musician":["mus"],"application/vnd.muvee.style":["msty"],"application/vnd.mynfc":["taglet"],"application/vnd.neurolanguage.nlu":["nlu"],"application/vnd.nitf":["ntf","nitf"],"application/vnd.noblenet-directory":["nnd"],"application/vnd.noblenet-sealer":["nns"],"application/vnd.noblenet-web":["nnw"],"application/vnd.nokia.n-gage.data":["ngdat"],"application/vnd.nokia.radio-preset":["rpst"],"application/vnd.nokia.radio-presets":["rpss"],"application/vnd.novadigm.edm":["edm"],"application/vnd.novadigm.edx":["edx"],"application/vnd.novadigm.ext":["ext"],"application/vnd.oasis.opendocument.chart":["odc"],"application/vnd.oasis.opendocument.chart-template":["otc"],"application/vnd.oasis.opendocument.database":["odb"],"application/vnd.oasis.opendocument.formula":["odf"],"application/vnd.oasis.opendocument.formula-template":["odft"],"application/vnd.oasis.opendocument.graphics":["odg"],"application/vnd.oasis.opendocument.graphics-template":["otg"],"application/vnd.oasis.opendocument.image":["odi"],"application/vnd.oasis.opendocument.image-template":["oti"],"application/vnd.oasis.opendocument.presentation":["odp"],"application/vnd.oasis.opendocument.presentation-template":["otp"],"application/vnd.oasis.opendocument.spreadsheet":["ods"],"application/vnd.oasis.opendocument.spreadsheet-template":["ots"],"application/vnd.oasis.opendocument.text":["odt"],"application/vnd.oasis.opendocument.text-master":["odm"],"application/vnd.oasis.opendocument.text-template":["ott"],"application/vnd.oasis.opendocument.text-web":["oth"],"application/vnd.olpc-sugar":["xo"],"application/vnd.oma.dd2+xml":["dd2"],"application/vnd.openofficeorg.extension":["oxt"],"application/vnd.openxmlformats-officedocument.presentationml.presentation":["pptx"],"application/vnd.openxmlformats-officedocument.presentationml.slide":["sldx"],"application/vnd.openxmlformats-officedocument.presentationml.slideshow":["ppsx"],"application/vnd.openxmlformats-officedocument.presentationml.template":["potx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":["xlsx"],"application/vnd.openxmlformats-officedocument.spreadsheetml.template":["xltx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":["docx"],"application/vnd.openxmlformats-officedocument.wordprocessingml.template":["dotx"],"application/vnd.osgeo.mapguide.package":["mgp"],"application/vnd.osgi.dp":["dp"],"application/vnd.osgi.subsystem":["esa"],"application/vnd.palm":["pdb","pqa","oprc"],"application/vnd.pawaafile":["paw"],"application/vnd.pg.format":["str"],"application/vnd.pg.osasli":["ei6"],"application/vnd.picsel":["efif"],"application/vnd.pmi.widget":["wg"],"application/vnd.pocketlearn":["plf"],"application/vnd.powerbuilder6":["pbd"],"application/vnd.previewsystems.box":["box"],"application/vnd.proteus.magazine":["mgz"],"application/vnd.publishare-delta-tree":["qps"],"application/vnd.pvi.ptid1":["ptid"],"application/vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"application/vnd.realvnc.bed":["bed"],"application/vnd.recordare.musicxml":["mxl"],"application/vnd.recordare.musicxml+xml":["musicxml"],"application/vnd.rig.cryptonote":["cryptonote"],"application/vnd.rim.cod":["cod"],"application/vnd.rn-realmedia":["rm"],"application/vnd.rn-realmedia-vbr":["rmvb"],"application/vnd.route66.link66+xml":["link66"],"application/vnd.sailingtracker.track":["st"],"application/vnd.seemail":["see"],"application/vnd.sema":["sema"],"application/vnd.semd":["semd"],"application/vnd.semf":["semf"],"application/vnd.shana.informed.formdata":["ifm"],"application/vnd.shana.informed.formtemplate":["itp"],"application/vnd.shana.informed.interchange":["iif"],"application/vnd.shana.informed.package":["ipk"],"application/vnd.simtech-mindmapper":["twd","twds"],"application/vnd.smaf":["mmf"],"application/vnd.smart.teacher":["teacher"],"application/vnd.solent.sdkm+xml":["sdkm","sdkd"],"application/vnd.spotfire.dxp":["dxp"],"application/vnd.spotfire.sfs":["sfs"],"application/vnd.stardivision.calc":["sdc"],"application/vnd.stardivision.draw":["sda"],"application/vnd.stardivision.impress":["sdd"],"application/vnd.stardivision.math":["smf"],"application/vnd.stardivision.writer":["sdw","vor"],"application/vnd.stardivision.writer-global":["sgl"],"application/vnd.stepmania.package":["smzip"],"application/vnd.stepmania.stepchart":["sm"],"application/vnd.sun.xml.calc":["sxc"],"application/vnd.sun.xml.calc.template":["stc"],"application/vnd.sun.xml.draw":["sxd"],"application/vnd.sun.xml.draw.template":["std"],"application/vnd.sun.xml.impress":["sxi"],"application/vnd.sun.xml.impress.template":["sti"],"application/vnd.sun.xml.math":["sxm"],"application/vnd.sun.xml.writer":["sxw"],"application/vnd.sun.xml.writer.global":["sxg"],"application/vnd.sun.xml.writer.template":["stw"],"application/vnd.sus-calendar":["sus","susp"],"application/vnd.svd":["svd"],"application/vnd.symbian.install":["sis","sisx"],"application/vnd.syncml+xml":["xsm"],"application/vnd.syncml.dm+wbxml":["bdm"],"application/vnd.syncml.dm+xml":["xdm"],"application/vnd.tao.intent-module-archive":["tao"],"application/vnd.tcpdump.pcap":["pcap","cap","dmp"],"application/vnd.tmobile-livetv":["tmo"],"application/vnd.trid.tpt":["tpt"],"application/vnd.triscape.mxs":["mxs"],"application/vnd.trueapp":["tra"],"application/vnd.ufdl":["ufd","ufdl"],"application/vnd.uiq.theme":["utz"],"application/vnd.umajin":["umj"],"application/vnd.unity":["unityweb"],"application/vnd.uoml+xml":["uoml"],"application/vnd.vcx":["vcx"],"application/vnd.visio":["vsd","vst","vss","vsw"],"application/vnd.visionary":["vis"],"application/vnd.vsf":["vsf"],"application/vnd.wap.wbxml":["wbxml"],"application/vnd.wap.wmlc":["wmlc"],"application/vnd.wap.wmlscriptc":["wmlsc"],"application/vnd.webturbo":["wtb"],"application/vnd.wolfram.player":["nbp"],"application/vnd.wordperfect":["wpd"],"application/vnd.wqd":["wqd"],"application/vnd.wt.stf":["stf"],"application/vnd.xara":["xar"],"application/vnd.xfdl":["xfdl"],"application/vnd.yamaha.hv-dic":["hvd"],"application/vnd.yamaha.hv-script":["hvs"],"application/vnd.yamaha.hv-voice":["hvp"],"application/vnd.yamaha.openscoreformat":["osf"],"application/vnd.yamaha.openscoreformat.osfpvg+xml":["osfpvg"],"application/vnd.yamaha.smaf-audio":["saf"],"application/vnd.yamaha.smaf-phrase":["spf"],"application/vnd.yellowriver-custom-menu":["cmp"],"application/vnd.zul":["zir","zirz"],"application/vnd.zzazz.deck+xml":["zaz"],"application/voicexml+xml":["vxml"],"application/widget":["wgt"],"application/winhlp":["hlp"],"application/wsdl+xml":["wsdl"],"application/wspolicy+xml":["wspolicy"],"application/x-7z-compressed":["7z"],"application/x-abiword":["abw"],"application/x-ace-compressed":["ace"],"application/x-apple-diskimage":["dmg"],"application/x-authorware-bin":["aab","x32","u32","vox"],"application/x-authorware-map":["aam"],"application/x-authorware-seg":["aas"],"application/x-bcpio":["bcpio"],"application/x-bittorrent":["torrent"],"application/x-blorb":["blb","blorb"],"application/x-bzip":["bz"],"application/x-bzip2":["bz2","boz"],"application/x-cbr":["cbr","cba","cbt","cbz","cb7"],"application/x-cdlink":["vcd"],"application/x-cfs-compressed":["cfs"],"application/x-chat":["chat"],"application/x-chess-pgn":["pgn"],"application/x-chrome-extension":["crx"],"application/x-conference":["nsc"],"application/x-cpio":["cpio"],"application/x-csh":["csh"],"application/x-debian-package":["deb","udeb"],"application/x-dgc-compressed":["dgc"],"application/x-director":["dir","dcr","dxr","cst","cct","cxt","w3d","fgd","swa"],"application/x-doom":["wad"],"application/x-dtbncx+xml":["ncx"],"application/x-dtbook+xml":["dtb"],"application/x-dtbresource+xml":["res"],"application/x-dvi":["dvi"],"application/x-envoy":["evy"],"application/x-eva":["eva"],"application/x-font-bdf":["bdf"],"application/x-font-ghostscript":["gsf"],"application/x-font-linux-psf":["psf"],"application/x-font-otf":["otf"],"application/x-font-pcf":["pcf"],"application/x-font-snf":["snf"],"application/x-font-ttf":["ttf","ttc"],"application/x-font-type1":["pfa","pfb","pfm","afm"],"application/x-freearc":["arc"],"application/x-futuresplash":["spl"],"application/x-gca-compressed":["gca"],"application/x-glulx":["ulx"],"application/x-gnumeric":["gnumeric"],"application/x-gramps-xml":["gramps"],"application/x-gtar":["gtar"],"application/x-hdf":["hdf"],"application/x-install-instructions":["install"],"application/x-iso9660-image":["iso"],"application/x-java-jnlp-file":["jnlp"],"application/x-latex":["latex"],
+"application/x-lua-bytecode":["luac"],"application/x-lzh-compressed":["lzh","lha"],"application/x-mie":["mie"],"application/x-mobipocket-ebook":["prc","mobi"],"application/x-ms-application":["application"],"application/x-ms-shortcut":["lnk"],"application/x-ms-wmd":["wmd"],"application/x-ms-wmz":["wmz"],"application/x-ms-xbap":["xbap"],"application/x-msaccess":["mdb"],"application/x-msbinder":["obd"],"application/x-mscardfile":["crd"],"application/x-msclip":["clp"],"application/x-msdownload":["exe","dll","com","bat","msi"],"application/x-msmediaview":["mvb","m13","m14"],"application/x-msmetafile":["wmf","wmz","emf","emz"],"application/x-msmoney":["mny"],"application/x-mspublisher":["pub"],"application/x-msschedule":["scd"],"application/x-msterminal":["trm"],"application/x-mswrite":["wri"],"application/x-netcdf":["nc","cdf"],"application/x-nzb":["nzb"],"application/x-pkcs12":["p12","pfx"],"application/x-pkcs7-certificates":["p7b","spc"],"application/x-pkcs7-certreqresp":["p7r"],"application/x-rar-compressed":["rar"],"application/x-research-info-systems":["ris"],"application/x-sh":["sh"],"application/x-shar":["shar"],"application/x-shockwave-flash":["swf"],"application/x-silverlight-app":["xap"],"application/x-sql":["sql"],"application/x-stuffit":["sit"],"application/x-stuffitx":["sitx"],"application/x-subrip":["srt"],"application/x-sv4cpio":["sv4cpio"],"application/x-sv4crc":["sv4crc"],"application/x-t3vm-image":["t3"],"application/x-tads":["gam"],"application/x-tar":["tar"],"application/x-tcl":["tcl"],"application/x-tex":["tex"],"application/x-tex-tfm":["tfm"],"application/x-texinfo":["texinfo","texi"],"application/x-tgif":["obj"],"application/x-ustar":["ustar"],"application/x-wais-source":["src"],"application/x-web-app-manifest+json":["webapp"],"application/x-x509-ca-cert":["der","crt"],"application/x-xfig":["fig"],"application/x-xliff+xml":["xlf"],"application/x-xpinstall":["xpi"],"application/x-xz":["xz"],"application/x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"application/xaml+xml":["xaml"],"application/xcap-diff+xml":["xdf"],"application/xenc+xml":["xenc"],"application/xhtml+xml":["xhtml","xht"],"application/xml":["xml","xsl","xsd"],"application/xml-dtd":["dtd"],"application/xop+xml":["xop"],"application/xproc+xml":["xpl"],"application/xslt+xml":["xslt"],"application/xspf+xml":["xspf"],"application/xv+xml":["mxml","xhvml","xvml","xvm"],"application/yang":["yang"],"application/yin+xml":["yin"],"application/zip":["zip"],"audio/adpcm":["adp"],"audio/basic":["au","snd"],"audio/midi":["mid","midi","kar","rmi"],"audio/mp4":["mp4a","m4a"],"audio/mpeg":["mpga","mp2","mp2a","mp3","m2a","m3a"],"audio/ogg":["oga","ogg","spx"],"audio/s3m":["s3m"],"audio/silk":["sil"],"audio/vnd.dece.audio":["uva","uvva"],"audio/vnd.digital-winds":["eol"],"audio/vnd.dra":["dra"],"audio/vnd.dts":["dts"],"audio/vnd.dts.hd":["dtshd"],"audio/vnd.lucent.voice":["lvp"],"audio/vnd.ms-playready.media.pya":["pya"],"audio/vnd.nuera.ecelp4800":["ecelp4800"],"audio/vnd.nuera.ecelp7470":["ecelp7470"],"audio/vnd.nuera.ecelp9600":["ecelp9600"],"audio/vnd.rip":["rip"],"audio/webm":["weba"],"audio/x-aac":["aac"],"audio/x-aiff":["aif","aiff","aifc"],"audio/x-caf":["caf"],"audio/x-flac":["flac"],"audio/x-matroska":["mka"],"audio/x-mpegurl":["m3u"],"audio/x-ms-wax":["wax"],"audio/x-ms-wma":["wma"],"audio/x-pn-realaudio":["ram","ra"],"audio/x-pn-realaudio-plugin":["rmp"],"audio/x-wav":["wav"],"audio/xm":["xm"],"chemical/x-cdx":["cdx"],"chemical/x-cif":["cif"],"chemical/x-cmdf":["cmdf"],"chemical/x-cml":["cml"],"chemical/x-csml":["csml"],"chemical/x-xyz":["xyz"],"font/opentype":["otf"],"image/bmp":["bmp"],"image/cgm":["cgm"],"image/g3fax":["g3"],"image/gif":["gif"],"image/ief":["ief"],"image/jpeg":["jpeg","jpg","jpe"],"image/ktx":["ktx"],"image/png":["png"],"image/prs.btif":["btif"],"image/sgi":["sgi"],"image/svg+xml":["svg","svgz"],"image/tiff":["tiff","tif"],"image/vnd.adobe.photoshop":["psd"],"image/vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"image/vnd.djvu":["djvu","djv"],"image/vnd.dvb.subtitle":["sub"],"image/vnd.dwg":["dwg"],"image/vnd.dxf":["dxf"],"image/vnd.fastbidsheet":["fbs"],"image/vnd.fpx":["fpx"],"image/vnd.fst":["fst"],"image/vnd.fujixerox.edmics-mmr":["mmr"],"image/vnd.fujixerox.edmics-rlc":["rlc"],"image/vnd.ms-modi":["mdi"],"image/vnd.ms-photo":["wdp"],"image/vnd.net-fpx":["npx"],"image/vnd.wap.wbmp":["wbmp"],"image/vnd.xiff":["xif"],"image/webp":["webp"],"image/x-3ds":["3ds"],"image/x-cmu-raster":["ras"],"image/x-cmx":["cmx"],"image/x-freehand":["fh","fhc","fh4","fh5","fh7"],"image/x-icon":["ico"],"image/x-mrsid-image":["sid"],"image/x-pcx":["pcx"],"image/x-pict":["pic","pct"],"image/x-portable-anymap":["pnm"],"image/x-portable-bitmap":["pbm"],"image/x-portable-graymap":["pgm"],"image/x-portable-pixmap":["ppm"],"image/x-rgb":["rgb"],"image/x-tga":["tga"],"image/x-xbitmap":["xbm"],"image/x-xpixmap":["xpm"],"image/x-xwindowdump":["xwd"],"message/rfc822":["eml","mime"],"model/iges":["igs","iges"],"model/mesh":["msh","mesh","silo"],"model/vnd.collada+xml":["dae"],"model/vnd.dwf":["dwf"],"model/vnd.gdl":["gdl"],"model/vnd.gtw":["gtw"],"model/vnd.mts":["mts"],"model/vnd.vtu":["vtu"],"model/vrml":["wrl","vrml"],"model/x3d+binary":["x3db","x3dbz"],"model/x3d+vrml":["x3dv","x3dvz"],"model/x3d+xml":["x3d","x3dz"],"text/cache-manifest":["appcache","manifest"],"text/calendar":["ics","ifb"],"text/coffeescript":["coffee"],"text/css":["css"],"text/csv":["csv"],"text/hjson":["hjson"],"text/html":["html","htm"],"text/jade":["jade"],"text/jsx":["jsx"],"text/less":["less"],"text/n3":["n3"],"text/plain":["txt","text","conf","def","list","log","in","ini"],"text/prs.lines.tag":["dsc"],"text/richtext":["rtx"],"text/sgml":["sgml","sgm"],"text/stylus":["stylus","styl"],"text/tab-separated-values":["tsv"],"text/troff":["t","tr","roff","man","me","ms"],"text/turtle":["ttl"],"text/uri-list":["uri","uris","urls"],"text/vcard":["vcard"],"text/vnd.curl":["curl"],"text/vnd.curl.dcurl":["dcurl"],"text/vnd.curl.mcurl":["mcurl"],"text/vnd.curl.scurl":["scurl"],"text/vnd.dvb.subtitle":["sub"],"text/vnd.fly":["fly"],"text/vnd.fmi.flexstor":["flx"],"text/vnd.graphviz":["gv"],"text/vnd.in3d.3dml":["3dml"],"text/vnd.in3d.spot":["spot"],"text/vnd.sun.j2me.app-descriptor":["jad"],"text/vnd.wap.wml":["wml"],"text/vnd.wap.wmlscript":["wmls"],"text/vtt":["vtt"],"text/x-asm":["s","asm"],"text/x-c":["c","cc","cxx","cpp","h","hh","dic"],"text/x-component":["htc"],"text/x-fortran":["f","for","f77","f90"],"text/x-handlebars-template":["hbs"],"text/x-java-source":["java"],"text/x-lua":["lua"],"text/x-markdown":["markdown","md","mkd"],"text/x-nfo":["nfo"],"text/x-opml":["opml"],"text/x-pascal":["p","pas"],"text/x-sass":["sass"],"text/x-scss":["scss"],"text/x-setext":["etx"],"text/x-sfv":["sfv"],"text/x-uuencode":["uu"],"text/x-vcalendar":["vcs"],"text/x-vcard":["vcf"],"text/yaml":["yaml","yml"],"video/3gpp":["3gp"],"video/3gpp2":["3g2"],"video/h261":["h261"],"video/h263":["h263"],"video/h264":["h264"],"video/jpeg":["jpgv"],"video/jpm":["jpm","jpgm"],"video/mj2":["mj2","mjp2"],"video/mp2t":["ts"],"video/mp4":["mp4","mp4v","mpg4"],"video/mpeg":["mpeg","mpg","mpe","m1v","m2v"],"video/ogg":["ogv"],"video/quicktime":["qt","mov"],"video/vnd.dece.hd":["uvh","uvvh"],"video/vnd.dece.mobile":["uvm","uvvm"],"video/vnd.dece.pd":["uvp","uvvp"],"video/vnd.dece.sd":["uvs","uvvs"],"video/vnd.dece.video":["uvv","uvvv"],"video/vnd.dvb.file":["dvb"],"video/vnd.fvt":["fvt"],"video/vnd.mpegurl":["mxu","m4u"],"video/vnd.ms-playready.media.pyv":["pyv"],"video/vnd.uvvu.mp4":["uvu","uvvu"],"video/vnd.vivo":["viv"],"video/webm":["webm"],"video/x-f4v":["f4v"],"video/x-fli":["fli"],"video/x-flv":["flv"],"video/x-m4v":["m4v"],"video/x-matroska":["mkv","mk3d","mks"],"video/x-mng":["mng"],"video/x-ms-asf":["asf","asx"],"video/x-ms-vob":["vob"],"video/x-ms-wm":["wm"],"video/x-ms-wmv":["wmv"],"video/x-ms-wmx":["wmx"],"video/x-ms-wvx":["wvx"],"video/x-msvideo":["avi"],"video/x-sgi-movie":["movie"],"video/x-smv":["smv"],"x-conference/x-cooltalk":["ice"]}},{}],133:[function(e,t,r){t.exports=a;var i=e("inherits");var n=e("stream");i(a,n.Readable);function a(e,t){if(!(this instanceof a))return new a(e,t);n.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()}a.obj=function(e){return new a(e,{objectMode:true,highWaterMark:16})};a.prototype._read=function(){this._drained=true;this._forward()};a.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};a.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")};a.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)}};a.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",n);e.on("error",a);e.on("close",i);function r(){t._forward()}function i(){if(!e._readableState.ended){t.destroy()}}function n(){t._current=null;e.removeListener("readable",r);e.removeListener("end",n);e.removeListener("error",a);e.removeListener("close",i);t._next()}function a(e){t.destroy(e)}};function s(e){if(!e||typeof e==="function"||e._readableState)return e;var t=(new n.Readable).wrap(e);if(e.destroy){t.destroy=e.destroy.bind(e)}return t}},{inherits:128,stream:66}],134:[function(e,t,r){(function(r){t.exports=f;t.exports.remote=u;var i=e("dezalgo");var n=e("fs");var a=e("simple-get");var s=e("magnet-uri");var o=e("parse-torrent-file");t.exports.toMagnetURI=s.encode;t.exports.toTorrentFile=o.encode;function f(e){var t=e&&e.length;if(typeof e==="string"&&/magnet:/.test(e)){return s(e)}else if(typeof e==="string"&&(t===40||t===32)){return s("magnet:?xt=urn:btih:"+e)}else if(r.isBuffer(e)&&t===20){return s("magnet:?xt=urn:btih:"+e.toString("hex"))}else if(r.isBuffer(e)){return o(e)}else if(e&&e.infoHash){if(!e.announce)e.announce=[];if(typeof e.announce==="string"){e.announce=[e.announce]}return e}else{throw new Error("Invalid torrent identifier")}}function u(e,t){var r;if(typeof t!=="function")throw new Error("second argument must be a Function");t=i(t);try{r=f(e)}catch(s){}if(r&&r.infoHash){t(null,r)}else if(typeof a==="function"&&/^https?:/.test(e)){a.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,r){if(e){e=new Error("Error downloading torrent: "+e.message);return t(e)}o(r)})}else if(typeof n.readFile==="function"&&typeof e==="string"){n.readFile(e,function(e,r){if(e)return t(new Error("Invalid torrent identifier"));o(r)})}else{t(new Error("Invalid torrent identifier"))}function o(e){try{r=f(e)}catch(i){return t(i)}if(r&&r.infoHash)t(null,r);else t(new Error("Invalid torrent identifier"))}}}).call(this,e("buffer").Buffer)},{buffer:39,dezalgo:135,fs:37,"magnet-uri":139,"parse-torrent-file":142,"simple-get":159}],135:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{asap:136,dup:19,wrappy:138}],136:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{"./raw":137,dup:20}],137:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],138:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],139:[function(e,t,r){(function(r){t.exports=s;t.exports.decode=s;t.exports.encode=o;var i=e("thirty-two");var n=e("xtend");var a=e("uniq");function s(e){var t={};var n=e.split("magnet:?")[1];var s=n&&n.length>=0?n.split("&"):[];s.forEach(function(e){var r=e.split("=");if(r.length!==2)return;var i=r[0];var n=r[1];if(i==="dn")n=decodeURIComponent(n).replace(/\+/g," ");if(i==="tr"||i==="xs"||i==="as"||i==="ws"){n=decodeURIComponent(n)}if(i==="kt")n=decodeURIComponent(n).split("+");if(t[i]){if(Array.isArray(t[i])){t[i].push(n)}else{var a=t[i];t[i]=[a,n]}}else{t[i]=n}});var o;if(t.xt){var f=Array.isArray(t.xt)?t.xt:[t.xt];f.forEach(function(e){if(o=e.match(/^urn:btih:(.{40})/)){t.infoHash=new r(o[1],"hex").toString("hex")}else if(o=e.match(/^urn:btih:(.{32})/)){var n=i.decode(o[1]);t.infoHash=new r(n,"binary").toString("hex")}})}if(t.dn)t.name=t.dn;if(t.kt)t.keywords=t.kt;if(typeof t.tr==="string")t.announce=[t.tr];else if(Array.isArray(t.tr))t.announce=t.tr;else t.announce=[];a(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)}return t}function o(e){e=n(e);if(e.infoHash)e.xt="urn:btih:"+e.infoHash;if(e.name)e.dn=e.name;if(e.keywords)e.kt=e.keywords;if(e.announce)e.tr=e.announce;if(e.urlList){e.ws=e.urlList;delete e.as}var t="magnet:?";Object.keys(e).filter(function(e){return e.length===2}).forEach(function(r,i){var n=Array.isArray(e[r])?e[r]:[e[r]];n.forEach(function(e,n){if((i>0||n>0)&&(r!=="kt"||n===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"&&n>0)t+="+"+e;else t+=r+"="+e})});return t}}).call(this,e("buffer").Buffer)},{buffer:39,"thirty-two":140,uniq:168,xtend:181}],140:[function(e,t,r){var i=e("./thirty-two");r.encode=i.encode;r.decode=i.decode},{"./thirty-two":141}],141:[function(e,t,r){(function(e){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";var i=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];function n(e){var t=Math.floor(e.length/5);return e.length%5==0?t:t+1}r.encode=function(r){var i=0;var a=0;var s=0;var o=0;var f=new e(n(r)*8);if(!e.isBuffer(r)){r=new e(r)}while(i<r.length){var u=r[i];if(s>3){o=u&255>>s;s=(s+5)%8;o=o<<s|(i+1<r.length?r[i+1]:0)>>8-s;i++}else{o=u>>8-(s+5)&31;s=(s+5)%8;if(s==0)i++}f[a]=t.charCodeAt(o);a++}for(i=a;i<f.length;i++)f[i]=61;return f};r.decode=function(t){var r=0;var n=0;var a;var s=0;if(!e.isBuffer(t)){t=new e(t)}var o=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<i.length){n=i[u];if(r<=3){r=(r+5)%8;if(r==0){a|=n;o[s]=a;s++;a=0}else{a|=255&n<<8-r}}else{r=(r+5)%8;a|=255&n>>>r;o[s]=a;s++;a=255&n<<8-r}}else{throw new Error("Invalid input - it is not base32 encoded string")}}return o.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:39}],142:[function(e,t,r){(function(r){t.exports=o;t.exports.decode=o;t.exports.encode=f;var i=e("bencode");var n=e("path");var a=e("simple-sha1");var s=e("uniq");function o(e){if(r.isBuffer(e)){e=i.decode(e)}c(e.info,"info");c(e.info["name.utf-8"]||e.info.name,"info.name");c(e.info["piece length"],"info['piece length']");c(e.info.pieces,"info.pieces");if(e.info.files){e.info.files.forEach(function(e){c(typeof e.length==="number","info.files[0].length");c(e["path.utf-8"]||e.path,"info.files[0].path")})}else{c(typeof e.info.length==="number","info.length")}var t={};t.info=e.info;t.infoBuffer=i.encode(e.info);t.infoHash=a.sync(t.infoBuffer);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())}s(t.announce);if(r.isBuffer(e["url-list"])){e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]}t.urlList=(e["url-list"]||[]).map(function(e){return e.toString()});var o=e.info.files||[e.info];t.files=o.map(function(e,r){var i=[].concat(t.name,e["path.utf-8"]||e.path||[]).map(function(e){return e.toString()});return{path:n.join.apply(null,[n.sep].concat(i)).slice(1),name:i[i.length-1],length:e.length,offset:o.slice(0,r).reduce(u,0)}});t.length=o.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=l(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 i.encode(t)}function u(e,t){return e+t.length}function l(e){var t=[];for(var r=0;r<e.length;r+=20){t.push(e.slice(r,r+20).toString("hex"))}return t}function c(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}}).call(this,e("buffer").Buffer)},{bencode:143,buffer:39,path:47,"simple-sha1":163,uniq:168}],143:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{"./lib/decode":144,"./lib/encode":146,dup:15}],144:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./dict":145,buffer:39,dup:16}],145:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{dup:17}],146:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{buffer:39,dup:18}],147:[function(e,t,r){"use strict";var i=e("fs");t.exports=function(e,t){var r=typeof i.access==="function"?i.access:i.stat;r(e,function(e){t(null,!e)})};t.exports.sync=function(e){var t=typeof i.accessSync==="function"?i.accessSync:i.statSync;try{t(e);return true}catch(r){return false}}},{fs:37}],148:[function(e,t,r){var i=e("once");var n=e("end-of-stream");var a=e("fs");var s=function(){};var o=function(e){return typeof e==="function"};var f=function(e){return(e instanceof(a.ReadStream||s)||e instanceof(a.WriteStream||s))&&o(e.close)};var u=function(e){return e.setHeader&&o(e.abort)};var l=function(e,t,r,a){a=i(a);var s=false;e.on("close",function(){s=true});n(e,{readable:t,writable:r},function(e){if(e)return a(e);s=true;a()});var l=false;return function(t){if(s)return;if(l)return;l=true;if(f(e))return e.close();if(u(e))return e.abort();if(o(e.destroy))return e.destroy();a(t||new Error("stream was destroyed"))}};var c=function(e){e()};var p=function(e,t){return e.pipe(t)};var d=function(){var e=Array.prototype.slice.call(arguments);var t=o(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 i=e.map(function(n,a){var s=a<e.length-1;var o=a>0;return l(n,s,o,function(e){if(!r)r=e;if(e)i.forEach(c);if(s)return;i.forEach(c);t(r)})});return e.reduce(p)};t.exports=d},{"end-of-stream":123,fs:37,once:150}],149:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],150:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29,wrappy:149}],151:[function(e,t,r){var i=function(e){var t=0;return function(){if(t===e.length)return null;var r=e.length-t;var i=Math.random()*r|0;var n=e[t+i];var a=e[t];e[t]=n;e[t+i]=a;t++;return n}};t.exports=i},{}],152:[function(e,t,r){t.exports=function(e,t){var r=true;var i=t.indexOf("=");if(-1==i)return-2;var n=t.slice(i+1).split(",").map(function(t){var t=t.split("-"),i=parseInt(t[0],10),n=parseInt(t[1],10);if(isNaN(i)){i=e-n;n=e-1}else if(isNaN(n)){n=e-1}if(n>e-1)n=e-1;if(isNaN(i)||isNaN(n)||i>n||i<0)r=false;return{start:i,end:n}});n.type=t.slice(0,i);return r?n:-1}},{}],153:[function(e,t,r){t.exports=n;t.exports.filter=a;var i=e("events").EventEmitter;function n(e,t,r){if(!Array.isArray(r))r=[r];var i=[];r.forEach(function(r){var n=function(){var e=[].slice.call(arguments);e.unshift(r);t.emit.apply(t,e)};i.push(n);e.on(r,n)});return function n(){r.forEach(function(t,r){e.removeListener(t,i[r])})}}function a(e,t){var r=new i;n(e,r,t);return r}},{events:43}],154:[function(e,t,r){var i=e("dezalgo");t.exports=function(e,t){if(t)t=i(t);var r,n,a;if(Array.isArray(e)){r=[];n=e.length}else{a=Object.keys(e);r={};n=a.length}function s(e,i,a){r[e]=a;if(--n===0||i){if(t)t(i,r);t=null}}if(!n){if(t)t(null,r);t=null}else if(a){a.forEach(function(t){e[t](s.bind(undefined,t))})}else{e.forEach(function(e,t){e(s.bind(undefined,t))})}}},{dezalgo:155}],155:[function(e,t,r){arguments[4][19][0].apply(r,arguments)},{asap:156,dup:19,wrappy:158}],156:[function(e,t,r){arguments[4][20][0].apply(r,arguments)},{"./raw":157,dup:20}],157:[function(e,t,r){arguments[4][21][0].apply(r,arguments)},{dup:21}],158:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],159:[function(e,t,r){(function(r){t.exports=u;var i=e("http");var n=e("https");var a=e("once");var s=e("url");var o=e("unzip-response");var f=e("object-assign");function u(e,t){e=typeof e==="string"?{url:e}:f({},e);t=a(t);if(e.url)l(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 s=Object.keys(e.headers).some(function(e){return e.toLowerCase()==="accept-encoding"});if(!s)e.headers["accept-encoding"]="gzip, deflate";var c=e.protocol==="https:"?n:i;var p=c.request(e,function(r){if(r.statusCode>=300&&r.statusCode<400&&"location"in r.headers){e.url=r.headers.location;l(e);r.resume();e.maxRedirects-=1;if(e.maxRedirects>0)u(e,t);else t(new Error("too many redirects"));return}t(null,typeof o==="function"?o(r):r)});p.on("error",t);p.end(r);return p}t.exports.concat=function(e,t){return u(e,function(e,i){if(e)return t(e);var n=[];i.on("data",function(e){n.push(e)});i.on("end",function(){t(null,r.concat(n),i)})})};["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 l(e){var t=s.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:39,http:67,https:44,"object-assign":160,once:162,"unzip-response":38,url:77}],160:[function(e,t,r){"use strict";var i=Object.prototype.propertyIsEnumerable;function n(e){if(e==null){throw new TypeError("Object.assign cannot be called with null or undefined")}return Object(e)}function a(e){var t=Object.getOwnPropertyNames(e);if(Object.getOwnPropertySymbols){t=t.concat(Object.getOwnPropertySymbols(e))}return t.filter(function(t){return i.call(e,t)})}t.exports=Object.assign||function(e,t){var r;var i;var s=n(e);for(var o=1;o<arguments.length;o++){r=arguments[o];i=a(Object(r));for(var f=0;f<i.length;f++){s[i[f]]=r[i[f]]}}return s}},{}],161:[function(e,t,r){arguments[4][22][0].apply(r,arguments)},{dup:22}],162:[function(e,t,r){arguments[4][29][0].apply(r,arguments)},{dup:29,wrappy:161}],163:[function(e,t,r){var i=e("rusha");var n=new i;var a=window.crypto||window.msCrypto||{};var s=a.subtle||a.webkitSubtle;var o=n.digest.bind(n);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,o(e));return}if(typeof e==="string"){e=l(e)}s.digest({name:"sha-1"},e).then(function r(e){t(c(new Uint8Array(e)))},function i(r){t(o(e))})}function l(e){var t=e.length;var r=new Uint8Array(t);for(var i=0;i<t;i++){r[i]=e.charCodeAt(i)}return r}function c(e){var t=e.length;var r=[];for(var i=0;i<t;i++){var n=e[i];r.push((n>>>4).toString(16));r.push((n&15).toString(16))}return r.join("")}t.exports=u;t.exports.sync=o},{rusha:164}],164:[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 i(e){"use strict";var t={fill:0};var a=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 o=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,i,n){var a=this,s,o=n%4,f=i%4,u=i-f;if(u>0){switch(o){case 0:e[n+3|0]=a.charCodeAt(r);case 1:e[n+2|0]=a.charCodeAt(r+1);case 2:e[n+1|0]=a.charCodeAt(r+2);case 3:e[n|0]=a.charCodeAt(r+3)}}for(s=o;s<u;s=s+4|0){t[n+s>>2]=a.charCodeAt(r+s)<<24|a.charCodeAt(r+s+1)<<16|a.charCodeAt(r+s+2)<<8|a.charCodeAt(r+s+3)}switch(f){case 3:e[n+u+1|0]=a.charCodeAt(r+u+2);case 2:e[n+u+2|0]=a.charCodeAt(r+u+1);case 1:e[n+u+3|0]=a.charCodeAt(r+u)}};var u=function(e,t,r,i,n){var a=this,s,o=n%4,f=i%4,u=i-f;if(u>0){switch(o){case 0:e[n+3|0]=a[r];case 1:e[n+2|0]=a[r+1];case 2:e[n+1|0]=a[r+2];case 3:e[n|0]=a[r+3]}}for(s=4-o;s<u;s=s+=4|0){t[n+s>>2]=a[r+s]<<24|a[r+s+1]<<16|a[r+s+2]<<8|a[r+s+3]}switch(f){case 3:e[n+u+1|0]=a[r+u+2];case 2:e[n+u+2|0]=a[r+u+1];case 1:e[n+u+3|0]=a[r+u]}};var l=function(e,t,r,i,a){var s=this,o,f=a%4,u=i%4,l=i-u;var c=new Uint8Array(n.readAsArrayBuffer(s.slice(r,r+i)));if(l>0){switch(f){case 0:e[a+3|0]=c[0];case 1:e[a+2|0]=c[1];case 2:e[a+1|0]=c[2];case 3:e[a|0]=c[3]}}for(o=4-f;o<l;o=o+=4|0){t[a+o>>2]=c[o]<<24|c[o+1]<<16|c[o+2]<<8|c[o+3]}switch(u){case 3:e[a+l+1|0]=c[l+2];case 2:e[a+l+2|0]=c[l+1];case 1:e[a+l+3|0]=c[l]}};var c=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 l.bind(e)}};var p=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 d=function(e){var t,r,i="0123456789abcdef",n=[],a=new Uint8Array(e);for(t=0;t<a.length;t++){r=a[t];n[t]=i.charAt(r>>4&15)+i.charAt(r>>0&15)}return n.join("")};var h=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=a(e);t.heap=new ArrayBuffer(h(t.padMaxChunkLen+320+20));t.h32=new Int32Array(t.heap);t.h8=new Int8Array(t.heap);t.core=new i._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 i=a(e);var n=new Int32Array(t.heap,0,i>>2);s(n,e);o(n,e,r);return i};var y=function(e,r,i){c(e)(t.h8,t.h32,r,i,0)};var _=function(e,r,i,n,a){var s=i;if(a){s=g(i,n)}y(e,r,i);t.core.hash(s,t.padMaxChunkLen)};var b=function(e,t){var r=new Int32Array(e,t+320,5);var i=new Int32Array(5);var n=new DataView(i.buffer);n.setInt32(0,r[0],false);n.setInt32(4,r[1],false);n.setInt32(8,r[2],false);n.setInt32(12,r[3],false);n.setInt32(16,r[4],false);return i};var w=this.rawDigest=function(e){var r=e.byteLength||e.length||e.size||0;v(t.heap,t.padMaxChunkLen);var i=0,n=t.maxChunkLen,a;for(i=0;r>i+n;i+=n){_(e,i,n,r,false)}_(e,i,r-i,r,true);return b(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return d(w(e).buffer)}}i._core=function s(e,t,r){"use asm";var i=new e.Int32Array(r);function n(e,t){e=e|0;t=t|0;var r=0,n=0,a=0,s=0,o=0,f=0,u=0,l=0,c=0,p=0,d=0,h=0,m=0,v=0;a=i[t+320>>2]|0;o=i[t+324>>2]|0;u=i[t+328>>2]|0;c=i[t+332>>2]|0;d=i[t+336>>2]|0;for(r=0;(r|0)<(e|0);r=r+64|0){s=a;f=o;l=u;p=c;h=d;for(n=0;(n|0)<64;n=n+4|0){v=i[r+n>>2]|0;m=((a<<5|a>>>27)+(o&u|~o&c)|0)+((v+d|0)+1518500249|0)|0;d=c;c=u;u=o<<30|o>>>2;o=a;a=m;i[e+n>>2]=v}for(n=e+64|0;(n|0)<(e+80|0);n=n+4|0){v=(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])<<1|(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])>>>31;m=((a<<5|a>>>27)+(o&u|~o&c)|0)+((v+d|0)+1518500249|0)|0;d=c;c=u;u=o<<30|o>>>2;o=a;a=m;i[n>>2]=v}for(n=e+80|0;(n|0)<(e+160|0);n=n+4|0){v=(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])<<1|(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])>>>31;m=((a<<5|a>>>27)+(o^u^c)|0)+((v+d|0)+1859775393|0)|0;d=c;c=u;u=o<<30|o>>>2;o=a;a=m;i[n>>2]=v}for(n=e+160|0;(n|0)<(e+240|0);n=n+4|0){v=(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])<<1|(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])>>>31;m=((a<<5|a>>>27)+(o&u|o&c|u&c)|0)+((v+d|0)-1894007588|0)|0;d=c;c=u;u=o<<30|o>>>2;o=a;a=m;i[n>>2]=v}for(n=e+240|0;(n|0)<(e+320|0);n=n+4|0){v=(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])<<1|(i[n-12>>2]^i[n-32>>2]^i[n-56>>2]^i[n-64>>2])>>>31;m=((a<<5|a>>>27)+(o^u^c)|0)+((v+d|0)-899497514|0)|0;d=c;c=u;u=o<<30|o>>>2;o=a;a=m;i[n>>2]=v}a=a+s|0;o=o+f|0;u=u+l|0;c=c+p|0;d=d+h|0}i[t+320>>2]=a;i[t+324>>2]=o;i[t+328>>2]=u;i[t+332>>2]=c;i[t+336>>2]=d}return{hash:n}};if(typeof t!=="undefined"){t.exports=i}else if(typeof window!=="undefined"){window.Rusha=i}if(typeof FileReaderSync!=="undefined"){var n=new FileReaderSync,a=new i(4*1024*1024);self.onmessage=function o(e){var t,r=e.data.data;try{t=a.digest(r);self.postMessage({id:e.data.id,hash:t})}catch(i){self.postMessage({id:e.data.id,error:i.name})}}}})()}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],165:[function(e,t,r){var i=1;var n=65535;var a=4;var s=function(){i=i+1&n};var o=setInterval(s,1e3/a|0);if(o.unref)o.unref();t.exports=function(e){var t=a*(e||5);var r=[0];var s=1;var o=i-1&n;return function(e){var f=i-o&n;if(f>t)f=t;o=i;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 l=r.length<t?0:r[s===t?0:s];return r.length<a?u:(u-l)*a/r.length}}},{}],166:[function(e,t,r){(function(r,i){t.exports=p;var n=e("debug")("torrent-discovery");var a=e("bittorrent-dht/client");var s=e("events").EventEmitter;var o=e("xtend/mutable");var f=e("inherits");var u=e("run-parallel");var l=e("re-emitter");var c=e("bittorrent-tracker/client");f(p,s);function p(e){var t=this;if(!(t instanceof p))return new p(e);s.call(t);o(t,{announce:[],dht:typeof a==="function",rtcConfig:null,peerId:null,port:0,tracker:true,wrtc:null},e);t.infoHash=null;t.infoHashHex=null;t.torrent=null;t._externalDHT=typeof t.dht==="object";t._performedDHTLookup=false;if(!t.peerId)throw new Error("peerId required");if(!r.browser&&!t.port)throw new Error("port required");if(t.dht)t._createDHT(t.dhtPort)}p.prototype.setTorrent=function(e){var t=this;if(!t.infoHash&&i.isBuffer(e)||typeof e==="string"){t.infoHash=typeof e==="string"?new i(e,"hex"):e}else if(!t.torrent&&e&&e.infoHash){t.torrent=e;t.infoHash=typeof e.infoHash==="string"?new i(e.infoHash,"hex"):e.infoHash}else{return}t.infoHashHex=t.infoHash.toString("hex");n("setTorrent %s",t.infoHashHex);if(t.tracker&&t.tracker!==true){t.tracker.torrentLength=e.length}else{t._createTracker()}if(t.dht){if(t.dht.ready)t._dhtLookupAndAnnounce();else t.dht.on("ready",t._dhtLookupAndAnnounce.bind(t))}};p.prototype.updatePort=function(e){var t=this;if(e===t.port)return;t.port=e;if(t.dht&&t.infoHash){t._performedDHTLookup=false;t._dhtLookupAndAnnounce()}if(t.tracker&&t.tracker!==true){t.tracker.stop();t.tracker.destroy(function(){t._createTracker()})}};p.prototype.stop=function(e){var t=this;var r=[];if(t.tracker&&t.tracker!==true){t.tracker.stop();r.push(function(e){t.tracker.destroy(e)})}if(!t._externalDHT&&t.dht&&t.dht!==true){r.push(function(e){t.dht.destroy(e)})}u(r,e)};p.prototype._createDHT=function(e){var t=this;if(!t._externalDHT)t.dht=new a;l(t.dht,t,["error","warning"]);t.dht.on("peer",function(e,r){if(r===t.infoHashHex)t.emit("peer",e)});if(!t._externalDHT)t.dht.listen(e)};p.prototype._createTracker=function(){var e=this;if(!e.tracker)return;var t=e.torrent?o({},e.torrent):{infoHash:e.infoHashHex,announce:[]};if(e.announce)t.announce=t.announce.concat(e.announce);var r={rtcConfig:e.rtcConfig,
+wrtc:e.wrtc};e.tracker=new c(e.peerId,e.port,t,r);l(e.tracker,e,["peer","warning","error"]);e.tracker.on("update",function(t){e.emit("trackerAnnounce",t)});e.tracker.start()};p.prototype._dhtLookupAndAnnounce=function(){var e=this;if(e._performedDHTLookup)return;e._performedDHTLookup=true;n("dht lookup");e.dht.lookup(e.infoHash,function(t){if(t||!e.port)return;n("dht announce");e.dht.announce(e.infoHash,e.port,function(){n("dht announce complete");e.emit("dhtAnnounce")})})}}).call(this,e("_process"),e("buffer").Buffer)},{_process:48,"bittorrent-dht/client":38,"bittorrent-tracker/client":23,buffer:39,debug:120,events:43,inherits:128,"re-emitter":153,"run-parallel":154,"xtend/mutable":182}],167:[function(e,t,r){(function(e){t.exports=i;var r=1<<14;function i(e){if(!(this instanceof i))return new i(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}i.BLOCK_LENGTH=r;i.prototype.chunkLength=function(e){return e===this._chunks-1?this._remainder:r};i.prototype.chunkOffset=function(e){return e*r};i.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};i.prototype.cancel=function(e){if(!this.init())return;this._cancellations.push(e)};i.prototype.get=function(e){if(!this.init())return null;return this._buffer[e]};i.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};i.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};i.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:39}],168:[function(e,t,r){"use strict";function i(e,t){var r=1,i=e.length,n=e[0],a=e[0];for(var s=1;s<i;++s){a=n;n=e[s];if(t(n,a)){if(s===r){r++;continue}e[r++]=n}}e.length=r;return e}function n(e){var t=1,r=e.length,i=e[0],n=e[0];for(var a=1;a<r;++a,n=i){n=i;i=e[a];if(i!==n){if(a===t){t++;continue}e[t++]=i}}e.length=t;return e}function a(e,t,r){if(e.length===0){return e}if(t){if(!r){e.sort(t)}return i(e,t)}if(!r){e.sort()}return n(e)}t.exports=a},{}],169:[function(e,t,r){(function(r){var i=e("bencode");var n=e("bitfield");var a=e("events").EventEmitter;var s=e("inherits");var o=e("simple-sha1");var f=1e7;var u=1e3;var l=16*1024;t.exports=function(e){s(t,a);function t(t){a.call(this);this._wire=t;this._metadataComplete=false;this._metadataSize=null;this._remainingRejects=null;this._fetching=false;this._bitfield=new n(0,{grow:u});if(r.isBuffer(e)){this.setMetadata(e)}}t.prototype.name="ut_metadata";t.prototype.onHandshake=function(e,t,r){this._infoHash=e;this._infoHashHex=e.toString("hex")};t.prototype.onExtendedHandshake=function(e){if(!e.m||!e.m.ut_metadata){return this.emit("warning",new Error("Peer does not support ut_metadata"))}if(!e.metadata_size){return this.emit("warning",new Error("Peer does not have metadata"))}if(e.metadata_size>f){return this.emit("warning",new Error("Peer gave maliciously large metadata size"))}this._metadataSize=e.metadata_size;this._numPieces=Math.ceil(this._metadataSize/l);this._remainingRejects=this._numPieces*2;if(this._fetching){this._requestPieces()}};t.prototype.onMessage=function(e){var t,r;try{var n=e.toString();var a=n.indexOf("ee")+2;t=i.decode(n.substring(0,a));r=e.slice(a)}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=i.decode(e).info;if(t){e=i.encode(t)}}catch(r){}if(this._infoHashHex&&this._infoHashHex!==o.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",i.encode({info:i.decode(this.metadata)}));return true};t.prototype._send=function(e,t){var n=i.encode(e);if(r.isBuffer(t)){n=r.concat([n,t])}this._wire.extended("ut_metadata",n)};t.prototype._request=function(e){this._send({msg_type:0,piece:e})};t.prototype._data=function(e,t,r){var i={msg_type:1,piece:e};if(typeof r==="number"){i.total_size=r}this._send(i,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*l;var r=t+l;if(r>this._metadataSize){r=this._metadataSize}var i=this.metadata.slice(t,r);this._data(e,i,this._metadataSize)};t.prototype._onData=function(e,t,r){if(t.length>l){return}t.copy(this.metadata,e*l);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 n(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:170,bitfield:9,buffer:39,events:43,inherits:128,"simple-sha1":163}],170:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{"./lib/decode":171,"./lib/encode":173,dup:15}],171:[function(e,t,r){arguments[4][16][0].apply(r,arguments)},{"./dict":172,buffer:39,dup:16}],172:[function(e,t,r){arguments[4][17][0].apply(r,arguments)},{dup:17}],173:[function(e,t,r){arguments[4][18][0].apply(r,arguments)},{buffer:39,dup:18}],174:[function(e,t,r){var i=function(e,t,r){this._byteOffset=t||0;if(e instanceof ArrayBuffer){this.buffer=e}else if(typeof e=="object"){this.dataView=e;if(t){this._byteOffset+=t}}else{this.buffer=new ArrayBuffer(e||0)}this.position=0;this.endianness=r==null?i.LITTLE_ENDIAN:r};t.exports=i;i.prototype={};i.prototype.save=function(e){var t=new Blob([this.buffer]);var r=window.webkitURL||window.URL;if(r&&r.createObjectURL){var i=r.createObjectURL(t);var n=document.createElement("a");n.setAttribute("href",i);n.setAttribute("download",e);n.click();r.revokeObjectURL(i)}else{throw"DataStream.save: Can't create object URL."}};i.BIG_ENDIAN=false;i.LITTLE_ENDIAN=true;i.prototype._dynamicSize=true;Object.defineProperty(i.prototype,"dynamicSize",{get:function(){return this._dynamicSize},set:function(e){if(!e){this._trimAlloc()}this._dynamicSize=e}});i.prototype._byteLength=0;Object.defineProperty(i.prototype,"byteLength",{get:function(){return this._byteLength-this._byteOffset}});Object.defineProperty(i.prototype,"buffer",{get:function(){this._trimAlloc();return this._buffer},set:function(e){this._buffer=e;this._dataView=new DataView(this._buffer,this._byteOffset);this._byteLength=this._buffer.byteLength}});Object.defineProperty(i.prototype,"byteOffset",{get:function(){return this._byteOffset},set:function(e){this._byteOffset=e;this._dataView=new DataView(this._buffer,this._byteOffset);this._byteLength=this._buffer.byteLength}});Object.defineProperty(i.prototype,"dataView",{get:function(){return this._dataView},set:function(e){this._byteOffset=e.byteOffset;this._buffer=e.buffer;this._dataView=new DataView(this._buffer,this._byteOffset);this._byteLength=this._byteOffset+e.byteLength}});i.prototype._realloc=function(e){if(!this._dynamicSize){return}var t=this._byteOffset+this.position+e;var r=this._buffer.byteLength;if(t<=r){if(t>this._byteLength){this._byteLength=t}return}if(r<1){r=1}while(t>r){r*=2}var i=new ArrayBuffer(r);var n=new Uint8Array(this._buffer);var a=new Uint8Array(i,0,n.length);a.set(n);this.buffer=i;this._byteLength=t};i.prototype._trimAlloc=function(){if(this._byteLength==this._buffer.byteLength){return}var e=new ArrayBuffer(this._byteLength);var t=new Uint8Array(e);var r=new Uint8Array(this._buffer,0,t.length);t.set(r);this.buffer=e};i.prototype.shift=function(e){var t=new ArrayBuffer(this._byteLength-e);var r=new Uint8Array(t);var i=new Uint8Array(this._buffer,e,r.length);r.set(i);this.buffer=t;this.position-=e};i.prototype.seek=function(e){var t=Math.max(0,Math.min(this.byteLength,e));this.position=isNaN(t)||!isFinite(t)?0:t};i.prototype.isEof=function(){return this.position>=this._byteLength};i.prototype.mapInt32Array=function(e,t){this._realloc(e*4);var r=new Int32Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*4;return r};i.prototype.mapInt16Array=function(e,t){this._realloc(e*2);var r=new Int16Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*2;return r};i.prototype.mapInt8Array=function(e){this._realloc(e*1);var t=new Int8Array(this._buffer,this.byteOffset+this.position,e);this.position+=e*1;return t};i.prototype.mapUint32Array=function(e,t){this._realloc(e*4);var r=new Uint32Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*4;return r};i.prototype.mapUint16Array=function(e,t){this._realloc(e*2);var r=new Uint16Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*2;return r};i.prototype.mapUint8Array=function(e){this._realloc(e*1);var t=new Uint8Array(this._buffer,this.byteOffset+this.position,e);this.position+=e*1;return t};i.prototype.mapFloat64Array=function(e,t){this._realloc(e*8);var r=new Float64Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*8;return r};i.prototype.mapFloat32Array=function(e,t){this._realloc(e*4);var r=new Float32Array(this._buffer,this.byteOffset+this.position,e);i.arrayToNative(r,t==null?this.endianness:t);this.position+=e*4;return r};i.prototype.readInt32Array=function(e,t){e=e==null?this.byteLength-this.position/4:e;var r=new Int32Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readInt16Array=function(e,t){e=e==null?this.byteLength-this.position/2:e;var r=new Int16Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readInt8Array=function(e){e=e==null?this.byteLength-this.position:e;var t=new Int8Array(e);i.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT);this.position+=t.byteLength;return t};i.prototype.readUint32Array=function(e,t){e=e==null?this.byteLength-this.position/4:e;var r=new Uint32Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readUint16Array=function(e,t){e=e==null?this.byteLength-this.position/2:e;var r=new Uint16Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readUint8Array=function(e){e=e==null?this.byteLength-this.position:e;var t=new Uint8Array(e);i.memcpy(t.buffer,0,this.buffer,this.byteOffset+this.position,e*t.BYTES_PER_ELEMENT);this.position+=t.byteLength;return t};i.prototype.readFloat64Array=function(e,t){e=e==null?this.byteLength-this.position/8:e;var r=new Float64Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.readFloat32Array=function(e,t){e=e==null?this.byteLength-this.position/4:e;var r=new Float32Array(e);i.memcpy(r.buffer,0,this.buffer,this.byteOffset+this.position,e*r.BYTES_PER_ELEMENT);i.arrayToNative(r,t==null?this.endianness:t);this.position+=r.byteLength;return r};i.prototype.writeInt32Array=function(e,t){this._realloc(e.length*4);if(e instanceof Int32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapInt32Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeInt32(e[r],t)}}};i.prototype.writeInt16Array=function(e,t){this._realloc(e.length*2);if(e instanceof Int16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapInt16Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeInt16(e[r],t)}}};i.prototype.writeInt8Array=function(e){this._realloc(e.length*1);if(e instanceof Int8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapInt8Array(e.length)}else{for(var t=0;t<e.length;t++){this.writeInt8(e[t])}}};i.prototype.writeUint32Array=function(e,t){this._realloc(e.length*4);if(e instanceof Uint32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapUint32Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeUint32(e[r],t)}}};i.prototype.writeUint16Array=function(e,t){this._realloc(e.length*2);if(e instanceof Uint16Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapUint16Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeUint16(e[r],t)}}};i.prototype.writeUint8Array=function(e){this._realloc(e.length*1);if(e instanceof Uint8Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapUint8Array(e.length)}else{for(var t=0;t<e.length;t++){this.writeUint8(e[t])}}};i.prototype.writeFloat64Array=function(e,t){this._realloc(e.length*8);if(e instanceof Float64Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapFloat64Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeFloat64(e[r],t)}}};i.prototype.writeFloat32Array=function(e,t){this._realloc(e.length*4);if(e instanceof Float32Array&&this.byteOffset+this.position%e.BYTES_PER_ELEMENT===0){i.memcpy(this._buffer,this.byteOffset+this.position,e.buffer,0,e.byteLength);this.mapFloat32Array(e.length,t)}else{for(var r=0;r<e.length;r++){this.writeFloat32(e[r],t)}}};i.prototype.readInt32=function(e){var t=this._dataView.getInt32(this.position,e==null?this.endianness:e);this.position+=4;return t};i.prototype.readInt16=function(e){var t=this._dataView.getInt16(this.position,e==null?this.endianness:e);this.position+=2;return t};i.prototype.readInt8=function(){var e=this._dataView.getInt8(this.position);this.position+=1;return e};i.prototype.readUint32=function(e){var t=this._dataView.getUint32(this.position,e==null?this.endianness:e);this.position+=4;return t};i.prototype.readUint16=function(e){var t=this._dataView.getUint16(this.position,e==null?this.endianness:e);this.position+=2;return t};i.prototype.readUint8=function(){var e=this._dataView.getUint8(this.position);this.position+=1;return e};i.prototype.readFloat32=function(e){var t=this._dataView.getFloat32(this.position,e==null?this.endianness:e);this.position+=4;return t};i.prototype.readFloat64=function(e){var t=this._dataView.getFloat64(this.position,e==null?this.endianness:e);this.position+=8;return t};i.prototype.writeInt32=function(e,t){this._realloc(4);this._dataView.setInt32(this.position,e,t==null?this.endianness:t);this.position+=4};i.prototype.writeInt16=function(e,t){this._realloc(2);this._dataView.setInt16(this.position,e,t==null?this.endianness:t);this.position+=2};i.prototype.writeInt8=function(e){this._realloc(1);this._dataView.setInt8(this.position,e);this.position+=1};i.prototype.writeUint32=function(e,t){this._realloc(4);this._dataView.setUint32(this.position,e,t==null?this.endianness:t);this.position+=4};i.prototype.writeUint16=function(e,t){this._realloc(2);this._dataView.setUint16(this.position,e,t==null?this.endianness:t);this.position+=2};i.prototype.writeUint8=function(e){this._realloc(1);this._dataView.setUint8(this.position,e);this.position+=1};i.prototype.writeFloat32=function(e,t){this._realloc(4);this._dataView.setFloat32(this.position,e,t==null?this.endianness:t);this.position+=4};i.prototype.writeFloat64=function(e,t){this._realloc(8);this._dataView.setFloat64(this.position,e,t==null?this.endianness:t);this.position+=8};i.endianness=new Int8Array(new Int16Array([1]).buffer)[0]>0;i.memcpy=function(e,t,r,i,n){var a=new Uint8Array(e,t,n);var s=new Uint8Array(r,i,n);a.set(s)};i.arrayToNative=function(e,t){if(t==this.endianness){return e}else{return this.flipArrayEndianness(e)}};i.nativeToEndian=function(e,t){if(this.endianness==t){return e}else{return this.flipArrayEndianness(e)}};i.flipArrayEndianness=function(e){var t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);for(var r=0;r<e.byteLength;r+=e.BYTES_PER_ELEMENT){for(var i=r+e.BYTES_PER_ELEMENT-1,n=r;i>n;i--,n++){var a=t[n];t[n]=t[i];t[i]=a}}return e};i.prototype.failurePosition=0;i.prototype.readStruct=function(e){var t={},r,i,n;var a=this.position;for(var s=0;s<e.length;s+=2){r=e[s+1];i=this.readType(r,t);if(i==null){if(this.failurePosition===0){this.failurePosition=this.position}this.position=a;return null}t[e[s]]=i}return t};i.prototype.readUCS2String=function(e,t){return String.fromCharCode.apply(null,this.readUint16Array(e,t))};i.prototype.writeUCS2String=function(e,t,r){if(r==null){r=e.length}for(var i=0;i<e.length&&i<r;i++){this.writeUint16(e.charCodeAt(i),t)}for(;i<r;i++){this.writeUint16(0)}};i.prototype.readString=function(e,t){if(t==null||t=="ASCII"){return String.fromCharCode.apply(null,this.mapUint8Array(e==null?this.byteLength-this.position:e))}else{return new TextDecoder(t).decode(this.mapUint8Array(e))}};i.prototype.writeString=function(e,t,r){var i=0;if(t==null||t=="ASCII"){if(r!=null){var n=Math.min(e.length,r);for(i=0;i<n;i++){this.writeUint8(e.charCodeAt(i))}for(;i<r;i++){this.writeUint8(0)}}else{for(i=0;i<e.length;i++){this.writeUint8(e.charCodeAt(i))}}}else{this.writeUint8Array(new TextEncoder(t).encode(e.substring(0,r)))}};i.prototype.readCString=function(e){var t=this.byteLength-this.position;var r=new Uint8Array(this._buffer,this._byteOffset+this.position);var i=t;if(e!=null){i=Math.min(e,t)}for(var n=0;n<i&&r[n]!==0;n++);var a=String.fromCharCode.apply(null,this.mapUint8Array(n));if(e!=null){this.position+=i-n}else if(n!=t){this.position+=1}return a};i.prototype.writeCString=function(e,t){var r=0;if(t!=null){var i=Math.min(e.length,t);for(r=0;r<i;r++){this.writeUint8(e.charCodeAt(r))}for(;r<t;r++){this.writeUint8(0)}}else{for(r=0;r<e.length;r++){this.writeUint8(e.charCodeAt(r))}this.writeUint8(0)}};i.prototype.readType=function(e,t){if(typeof e=="function"){return e(this,t)}else if(typeof e=="object"&&!(e instanceof Array)){return e.get(this,t)}else if(e instanceof Array&&e.length!=3){return this.readStruct(e,t)}var r=null;var n=null;var a="ASCII";var s=this.position;var o;var f;var u;if(typeof e=="string"&&/:/.test(e)){o=e.split(":");e=o[0];n=parseInt(o[1])}if(typeof e=="string"&&/,/.test(e)){o=e.split(",");e=o[0];a=parseInt(o[1])}switch(e){case"uint8":r=this.readUint8();break;case"int8":r=this.readInt8();break;case"uint16":r=this.readUint16(this.endianness);break;case"int16":r=this.readInt16(this.endianness);break;case"uint32":r=this.readUint32(this.endianness);break;case"int32":r=this.readInt32(this.endianness);break;case"float32":r=this.readFloat32(this.endianness);break;case"float64":r=this.readFloat64(this.endianness);break;case"uint16be":r=this.readUint16(i.BIG_ENDIAN);break;case"int16be":r=this.readInt16(i.BIG_ENDIAN);break;case"uint32be":r=this.readUint32(i.BIG_ENDIAN);break;case"int32be":r=this.readInt32(i.BIG_ENDIAN);break;case"float32be":r=this.readFloat32(i.BIG_ENDIAN);break;case"float64be":r=this.readFloat64(i.BIG_ENDIAN);break;case"uint16le":r=this.readUint16(i.LITTLE_ENDIAN);break;case"int16le":r=this.readInt16(i.LITTLE_ENDIAN);break;case"uint32le":r=this.readUint32(i.LITTLE_ENDIAN);break;case"int32le":r=this.readInt32(i.LITTLE_ENDIAN);break;case"float32le":r=this.readFloat32(i.LITTLE_ENDIAN);break;case"float64le":r=this.readFloat64(i.LITTLE_ENDIAN);break;case"cstring":r=this.readCString(n);break;case"string":r=this.readString(n,a);break;case"u16string":r=this.readUCS2String(n,this.endianness);break;case"u16stringle":r=this.readUCS2String(n,i.LITTLE_ENDIAN);break;case"u16stringbe":r=this.readUCS2String(n,i.BIG_ENDIAN);break;default:if(e.length==3){var l=e[1];var c=e[2];var p=0;if(typeof c=="function"){p=c(t,this,e)}else if(typeof c=="string"&&t[c]!=null){p=parseInt(t[c])}else{p=parseInt(c)}if(typeof l=="string"){var d=l.replace(/(le|be)$/,"");var h=null;if(/le$/.test(l)){h=i.LITTLE_ENDIAN}else if(/be$/.test(l)){h=i.BIG_ENDIAN}if(c=="*"){p=null}switch(d){case"uint8":r=this.readUint8Array(p);break;case"uint16":r=this.readUint16Array(p,h);break;case"uint32":r=this.readUint32Array(p,h);break;case"int8":r=this.readInt8Array(p);break;case"int16":r=this.readInt16Array(p,h);break;case"int32":r=this.readInt32Array(p,h);break;case"float32":r=this.readFloat32Array(p,h);break;case"float64":r=this.readFloat64Array(p,h);break;case"cstring":case"utf16string":case"string":if(p==null){r=[];while(!this.isEof()){u=this.readType(l,t);if(u==null)break;r.push(u)}}else{r=new Array(p);for(f=0;f<p;f++){r[f]=this.readType(l,t)}}break}}else{if(c=="*"){r=[];var m=this.buffer;while(true){var v=this.position;try{var g=this.readType(l,t);if(g==null){this.position=v;break}r.push(g)}catch(y){this.position=v;break}}}else{r=new Array(p);for(f=0;f<p;f++){u=this.readType(l,t);if(u==null)return null;r[f]=u}}}break}}if(n!=null){this.position=s+n}return r};i.prototype.writeStruct=function(e,t){for(var r=0;r<e.length;r+=2){var i=e[r+1];this.writeType(i,t[e[r]],t)}};i.prototype.writeType=function(e,t,r){var n;if(typeof e=="function"){return e(this,t)}else if(typeof e=="object"&&!(e instanceof Array)){return e.set(this,t,r)}var a=null;var s="ASCII";var o=this.position;if(typeof e=="string"&&/:/.test(e)){n=e.split(":");e=n[0];a=parseInt(n[1])}if(typeof e=="string"&&/,/.test(e)){n=e.split(",");e=n[0];s=parseInt(n[1])}switch(e){case"uint8":this.writeUint8(t);break;case"int8":this.writeInt8(t);break;case"uint16":this.writeUint16(t,this.endianness);break;case"int16":this.writeInt16(t,this.endianness);break;case"uint32":this.writeUint32(t,this.endianness);break;case"int32":this.writeInt32(t,this.endianness);break;case"float32":this.writeFloat32(t,this.endianness);break;case"float64":this.writeFloat64(t,this.endianness);break;case"uint16be":this.writeUint16(t,i.BIG_ENDIAN);break;case"int16be":this.writeInt16(t,i.BIG_ENDIAN);break;case"uint32be":this.writeUint32(t,i.BIG_ENDIAN);break;case"int32be":this.writeInt32(t,i.BIG_ENDIAN);break;case"float32be":this.writeFloat32(t,i.BIG_ENDIAN);break;case"float64be":this.writeFloat64(t,i.BIG_ENDIAN);break;case"uint16le":this.writeUint16(t,i.LITTLE_ENDIAN);break;case"int16le":this.writeInt16(t,i.LITTLE_ENDIAN);break;case"uint32le":this.writeUint32(t,i.LITTLE_ENDIAN);break;case"int32le":this.writeInt32(t,i.LITTLE_ENDIAN);break;case"float32le":this.writeFloat32(t,i.LITTLE_ENDIAN);break;case"float64le":this.writeFloat64(t,i.LITTLE_ENDIAN);break;case"cstring":this.writeCString(t,a);break;case"string":this.writeString(t,s,a);break;case"u16string":this.writeUCS2String(t,this.endianness,a);break;case"u16stringle":this.writeUCS2String(t,i.LITTLE_ENDIAN,a);break;case"u16stringbe":this.writeUCS2String(t,i.BIG_ENDIAN,a);break;default:if(e.length==3){var f=e[1];for(var u=0;u<t.length;u++){this.writeType(f,t[u])}break}else{this.writeStruct(e,t);break}}if(a!=null){this.position=o;this._realloc(a);this.position=o+a}};var n=Math.pow(2,32);r.MAX_SIZE=n;i.prototype.readUint64=function(){return this.readUint32()*n+this.readUint32()};i.prototype.writeUint64=function(e){var t=Math.floor(e/n);this.writeUint32(t);this.writeUint32(e&4294967295)};i.prototype.readUint24=function(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()};i.prototype.writeUint24=function(e){this.writeUint8((e&16711680)>>16);this.writeUint8((e&65280)>>8);this.writeUint8(e&255)};i.prototype.adjustUint32=function(e,t){var r=this.position;this.seek(e);this.writeUint32(t);this.seek(r)}},{}],175:[function(e,t,r){var n=e("./DataStream");var a=e("./descriptor");var s=e("./log");var o={ERR_NOT_ENOUGH_DATA:0,OK:1,boxCodes:["mdat","avcC","hvcC","ftyp","payl","vmhd","smhd","hmhd","dref","elst"],fullBoxCodes:["mvhd","tkhd","mdhd","hdlr","smhd","hmhd","nhmd","url ","urn ","ctts","cslg","stco","co64","stsc","stss","stsz","stz2","stts","stsh","mehd","trex","mfhd","tfhd","trun","tfdt","esds","subs","txtC"],containerBoxCodes:[["moov",["trak"]],["trak"],["edts"],["mdia"],["minf"],["dinf"],["stbl"],["mvex",["trex"]],["moof",["traf"]],["traf",["trun"]],["vttc"],["tref"]],sampleEntryCodes:[{prefix:"Visual",types:["mp4v","avc1","avc2","avc3","avc4","avcp","drac","encv","mjp2","mvc1","mvc2","resv","s263","svc1","vc-1","hvc1","hev1"]},{prefix:"Audio",types:["mp4a","ac-3","alac","dra1","dtsc","dtse",,"dtsh","dtsl","ec-3","enca","g719","g726","m4ae","mlpa","raw ","samr","sawb","sawp","sevc","sqcp","ssmv","twos"]},{prefix:"Hint",types:["fdp ","m2ts","pm2t","prtp","rm2t","rrtp","rsrp","rtp ","sm2t","srtp"]},{prefix:"Metadata",types:["metx","mett","urim"]},{prefix:"Subtitle",types:["stpp","wvtt","sbtt","tx3g","stxt"]}],trackReferenceTypes:["scal"],initialize:function(){var e,t;var r;o.FullBox.prototype=new o.Box;o.ContainerBox.prototype=new o.Box;o.stsdBox.prototype=new o.FullBox;o.SampleEntry.prototype=new o.FullBox;o.TrackReferenceTypeBox.prototype=new o.Box;r=o.boxCodes.length;for(e=0;e<r;e++){o[o.boxCodes[e]+"Box"]=function(e){return function(t){o.Box.call(this,o.boxCodes[e],t)}}(e);o[o.boxCodes[e]+"Box"].prototype=new o.Box}r=o.fullBoxCodes.length;for(e=0;e<r;e++){o[o.fullBoxCodes[e]+"Box"]=function(e){return function(t){o.FullBox.call(this,o.fullBoxCodes[e],t)}}(e);o[o.fullBoxCodes[e]+"Box"].prototype=new o.FullBox}r=o.containerBoxCodes.length;for(e=0;e<r;e++){o[o.containerBoxCodes[e][0]+"Box"]=function(e,t){return function(r){o.ContainerBox.call(this,o.containerBoxCodes[e][0],r);if(t){this.subBoxNames=t;var i=t.length;for(var n=0;n<i;n++){this[t[n]+"s"]=[]}}}}(e,o.containerBoxCodes[e][1]);o[o.containerBoxCodes[e][0]+"Box"].prototype=new o.ContainerBox}r=o.sampleEntryCodes.length;for(t=0;t<r;t++){var i=o.sampleEntryCodes[t].prefix;var n=o.sampleEntryCodes[t].types;var a=n.length;o[i+"SampleEntry"]=function(e,t){o.SampleEntry.call(this,e,t)};o[i+"SampleEntry"].prototype=new o.SampleEntry;for(e=0;e<a;e++){o[n[e]+"Box"]=function(e,t){return function(r){o[o.sampleEntryCodes[e].prefix+"SampleEntry"].call(this,o.sampleEntryCodes[e].types[t],r)}}(t,e);o[n[e]+"Box"].prototype=new o[i+"SampleEntry"]}}r=o.trackReferenceTypes.length;for(e=0;e<r;e++){o[o.trackReferenceTypes[e]+"Box"]=function(e){return function(t){o.TrackReferenceTypeBox.call(this,o.trackReferenceTypes[e],t)}}(e);o[o.trackReferenceTypes[e]+"Box"].prototype=new o.Box}},Box:function(e,t){this.type=e;this.size=t},FullBox:function(e,t){o.Box.call(this,e,t);this.flags=0;this.version=0},ContainerBox:function(e,t){o.Box.call(this,e,t);this.boxes=[]},SampleEntry:function(e,t){o.Box.call(this,e,t);this.boxes=[]},TrackReferenceTypeBox:function(e,t){o.Box.call(this,e,t);this.track_ids=[]},stsdBox:function(e){o.FullBox.call(this,"stsd",e);this.entries=[]},parseOneBox:function(e,t){var r;var i=e.position;var n=0;if(e.byteLength-e.position<8){s.d("BoxParser","Not enough data in stream to parse the type and size of the box");return{code:o.ERR_NOT_ENOUGH_DATA}}var a=e.readUint32();var f=e.readString(4);s.d("BoxParser","Found box of type "+f+" and size "+a+" at position "+i+" in the current buffer ("+(e.buffer.fileStart+i)+" in the file)");n=8;if(a==1){if(e.byteLength-e.position<8){e.seek(i);s.w("BoxParser",'Not enough data in stream to parse the extended size of the "'+f+'" box');return{code:o.ERR_NOT_ENOUGH_DATA}}a=e.readUint64();n+=8}else if(a===0){throw"Unlimited box size not supported"}if(i+a>e.byteLength){e.seek(i);s.w("BoxParser",'Not enough data in stream to parse the entire "'+f+'" box');return{code:o.ERR_NOT_ENOUGH_DATA,type:f,size:a,hdr_size:n}}if(o[f+"Box"]){r=new o[f+"Box"](a-n)}else{if(t){r=new o.SampleEntry(f,a-n)}else{r=new o.Box(f,a-n)}}r.hdr_size=n;r.start=i;r.fileStart=i+e.buffer.fileStart;r.parse(e);e.seek(i+a);return{code:o.OK,box:r,size:a}}};t.exports=o;o.initialize();o.Box.prototype.parse=function(e){if(this.type!="mdat"){this.data=e.readUint8Array(this.size)}else{e.seek(this.start+this.size+this.hdr_size)}};o.FullBox.prototype.parseFullHeader=function(e){this.version=e.readUint8();this.flags=e.readUint24();this.size-=4};o.ContainerBox.prototype.parse=function(e){var t;var r;var i;i=e.position;while(e.position<i+this.size){t=o.parseOneBox(e);r=t.box;this.boxes.push(r);if(this.subBoxNames&&this.subBoxNames.indexOf(r.type)!=-1){this[this.subBoxNames+"s"].push(r)}else{this[r.type]=r}}};o.SampleEntry.prototype.isVideo=function(){return false};o.SampleEntry.prototype.isAudio=function(){return false};o.SampleEntry.prototype.isSubtitle=function(){return false};o.SampleEntry.prototype.isMetadata=function(){return false};o.SampleEntry.prototype.isHint=function(){return false};o.SampleEntry.prototype.getCodec=function(){return this.type};o.SampleEntry.prototype.getWidth=function(){return""};o.SampleEntry.prototype.getHeight=function(){return""};o.SampleEntry.prototype.getChannelCount=function(){return""};o.SampleEntry.prototype.getSampleRate=function(){return""};o.SampleEntry.prototype.getSampleSize=function(){return""};o.SampleEntry.prototype.parseHeader=function(e){this.start=e.position;e.readUint8Array(6);this.data_reference_index=e.readUint16()};o.SampleEntry.prototype.parse=function(e){this.parseHeader(e);e.seek(this.start+this.size)};o.SampleEntry.prototype.parseFooter=function(e){var t;var r;while(e.position<this.start+this.size){t=o.parseOneBox(e,false);r=t.box;this.boxes.push(r);this[r.type]=r}};o.VisualSampleEntry.prototype.parse=function(e){this.parseHeader(e);e.readUint16();e.readUint16();e.readUint32Array(3);this.width=e.readUint16();this.height=e.readUint16();this.horizresolution=e.readUint32();this.vertresolution=e.readUint32();e.readUint32();this.frame_count=e.readUint16();this.compressorname=e.readString(32);this.depth=e.readUint16();e.readUint16();this.parseFooter(e)};o.VisualSampleEntry.prototype.isVideo=function(){return true};o.VisualSampleEntry.prototype.getWidth=function(){return this.width};o.VisualSampleEntry.prototype.getHeight=function(){return this.height};o.AudioSampleEntry.prototype.parse=function(e){this.parseHeader(e);e.readUint32Array(2);this.channel_count=e.readUint16();this.samplesize=e.readUint16();e.readUint16();e.readUint16();this.samplerate=e.readUint32()/(1<<16);this.parseFooter(e)};o.AudioSampleEntry.prototype.isAudio=function(){return true;
+};o.AudioSampleEntry.prototype.getChannelCount=function(){return this.channel_count};o.AudioSampleEntry.prototype.getSampleRate=function(){return this.samplerate};o.AudioSampleEntry.prototype.getSampleSize=function(){return this.samplesize};o.SubtitleSampleEntry.prototype.parse=function(e){this.parseHeader(e);this.parseFooter(e)};o.SubtitleSampleEntry.prototype.isSubtitle=function(){return true};o.MetadataSampleEntry.prototype.parse=function(e){this.parseHeader(e);this.parseFooter(e)};o.MetadataSampleEntry.prototype.isMetadata=function(){return true};o.TrackReferenceTypeBox.prototype.parse=function(e){this.track_ids=e.readUint8Array(this.size)};o.metxBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.namespace=e.readCString();this.schema_location=e.readCString();this.parseFooter(e)};o.mettBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.mime_format=e.readCString();this.parseFooter(e)};o.sbttBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.mime_format=e.readCString();this.parseFooter(e)};o.stxtBox.prototype.parse=function(e){this.parseHeader(e);this.content_encoding=e.readCString();this.mime_format=e.readCString();this.parseFooter(e)};o.stppBox.prototype.parse=function(e){this.parseHeader(e);this.namespace=e.readCString();this.schema_location=e.readCString();this.auxiliary_mime_types=e.readCString();this.parseFooter(e)};o.tx3gBox.prototype.parse=function(e){this.parseHeader(e);this.displayFlags=e.readUint32();this.horizontal_justification=e.readInt8();this.vertical_justification=e.readInt8();this.bg_color_rgba=e.readUint8Array(4);this.box_record=e.readInt16Array(4);this.style_record=e.readUint8Array(12);this.parseFooter(e)};o.ftypBox.prototype.parse=function(e){this.major_brand=e.readString(4);this.minor_version=e.readUint32();this.size-=8;this.compatible_brands=[];var t=0;while(this.size>=4){this.compatible_brands[t]=e.readString(4);this.size-=4;t++}};o.mvhdBox.prototype.parse=function(e){this.flags=0;this.parseFullHeader(e);if(this.version==1){this.creation_time=e.readUint64();this.modification_time=e.readUint64();this.timescale=e.readUint32();this.duration=e.readUint64()}else{this.creation_time=e.readUint32();this.modification_time=e.readUint32();this.timescale=e.readUint32();this.duration=e.readUint32()}this.rate=e.readUint32();this.volume=e.readUint16()>>8;e.readUint16();e.readUint32Array(2);this.matrix=e.readUint32Array(9);e.readUint32Array(6);this.next_track_id=e.readUint32()};o.TKHD_FLAG_ENABLED=1;o.TKHD_FLAG_IN_MOVIE=2;o.TKHD_FLAG_IN_PREVIEW=4;o.tkhdBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.creation_time=e.readUint64();this.modification_time=e.readUint64();this.track_id=e.readUint32();e.readUint32();this.duration=e.readUint64()}else{this.creation_time=e.readUint32();this.modification_time=e.readUint32();this.track_id=e.readUint32();e.readUint32();this.duration=e.readUint32()}e.readUint32Array(2);this.layer=e.readInt16();this.alternate_group=e.readInt16();this.volume=e.readInt16()>>8;e.readUint16();this.matrix=e.readInt32Array(9);this.width=e.readUint32();this.height=e.readUint32()};o.mdhdBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.creation_time=e.readUint64();this.modification_time=e.readUint64();this.timescale=e.readUint32();this.duration=e.readUint64()}else{this.creation_time=e.readUint32();this.modification_time=e.readUint32();this.timescale=e.readUint32();this.duration=e.readUint32()}this.language=e.readUint16();var t=[];t[0]=this.language>>10&31;t[1]=this.language>>5&31;t[2]=this.language&31;this.languageString=String.fromCharCode(t[0]+96,t[1]+96,t[2]+96);e.readUint16()};o.hdlrBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version===0){e.readUint32();this.handler=e.readString(4);e.readUint32Array(3);this.name=e.readCString()}else{this.data=e.readUint8Array(size)}};o.stsdBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);r=e.readUint32();for(i=1;i<=r;i++){t=o.parseOneBox(e,true);this.entries.push(t.box)}};o.avcCBox.prototype.parse=function(e){var t;var r;var i;this.configurationVersion=e.readUint8();this.AVCProfileIndication=e.readUint8();this.profile_compatibility=e.readUint8();this.AVCLevelIndication=e.readUint8();this.lengthSizeMinusOne=e.readUint8()&3;r=e.readUint8()&31;this.size-=6;this.SPS=new Array(r);for(t=0;t<r;t++){i=e.readUint16();this.SPS[t]=e.readUint8Array(i);this.size-=2+i}r=e.readUint8();this.size--;this.PPS=new Array(r);for(t=0;t<r;t++){i=e.readUint16();this.PPS[t]=e.readUint8Array(i);this.size-=2+i}if(this.size>0){this.ext=e.readUint8Array(this.size)}};o.hvcCBox.prototype.parse=function(e){var t;var r;var i;var n;this.configurationVersion=e.readUint8();n=e.readUint8();this.general_profile_space=n>>6;this.general_tier_flag=(n&32)>>5;this.general_profile_idc=n&31;this.general_profile_compatibility=e.readUint32();this.general_constraint_indicator=e.readUint8Array(6);this.general_level_idc=e.readUint8();this.min_spatial_segmentation_idc=e.readUint16()&4095;this.parallelismType=e.readUint8()&3;this.chromaFormat=e.readUint8()&3;this.bitDepthLumaMinus8=e.readUint8()&7;this.bitDepthChromaMinus8=e.readUint8()&7;this.avgFrameRate=e.readUint16();n=e.readUint8();this.constantFrameRate=n>>6;this.numTemporalLayers=(n&13)>>3;this.temporalIdNested=(n&4)>>2;this.lengthSizeMinusOne=n&3;this.nalu_arrays=[];numOfArrays=e.readUint8();for(t=0;t<numOfArrays;t++){var a=[];this.nalu_arrays.push(a);n=e.readUint8();a.completeness=(n&128)>>7;a.nalu_type=n&63;numNalus=e.readUint16();for(j=0;j<numNalus;j++){var s={};a.push(s);i=e.readUint16();s.data=e.readUint8Array(i)}}};function f(e,t){var r=Number(e).toString(16);t=typeof t==="undefined"||t===null?t=2:t;while(r.length<t){r="0"+r}return r}o.avc1Box.prototype.getCodec=function(){var e=o.SampleEntry.prototype.getCodec.call(this);if(this.avcC){return e+"."+f(this.avcC.AVCProfileIndication)+""+f(this.avcC.profile_compatibility)+""+f(this.avcC.AVCLevelIndication)}else{return e}};o.hvc1Box.prototype.getCodec=function(){var e;var t=o.SampleEntry.prototype.getCodec.call(this);if(this.hvcC){t+=".";switch(this.hvcC.general_profile_space){case 0:t+="";break;case 1:t+="A";break;case 2:t+="B";break;case 3:t+="C";break}t+=this.hvcC.general_profile_idc;t+=".";var r=this.hvcC.general_profile_compatibility;var i=0;for(e=0;e<32;e++){i|=r&1;if(e==31)break;i<<=1;r>>=1}t+=f(i,0);t+=".";if(this.hvcC.general_tier_flag===0){t+="L"}else{t+="H"}t+=this.hvcC.general_level_idc;var n=false;var a="";for(e=5;e>=0;e--){if(this.hvcC.general_constraint_indicator[e]||n){a="."+f(this.hvcC.general_constraint_indicator[e],0)+a;n=true}}t+=a}return t};o.mp4aBox.prototype.getCodec=function(){var e=o.SampleEntry.prototype.getCodec.call(this);if(this.esds&&this.esds.esd){var t=this.esds.esd.getOTI();var r=this.esds.esd.getAudioConfig();return e+"."+f(t)+(r?"."+r:"")}else{return e}};o.esdsBox.prototype.parse=function(e){this.parseFullHeader(e);this.data=e.readUint8Array(this.size);this.size=0;var t=new a;this.esd=t.parseOneDescriptor(new n(this.data.buffer,0,n.BIG_ENDIAN))};o.txtCBox.prototype.parse=function(e){this.parseFullHeader(e);this.config=e.readCString()};o.cttsBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.sample_counts=[];this.sample_offsets=[];if(this.version===0){for(r=0;r<t;r++){this.sample_counts.push(e.readUint32());this.sample_offsets.push(e.readInt32())}}else if(this.version==1){for(r=0;r<t;r++){this.sample_counts.push(e.readUint32());this.sample_offsets.push(e.readInt32())}}else{this.data=e.readUint8Array(this.size-4)}};o.cttsBox.prototype.unpack=function(e){var t,r,i;i=0;for(t=0;t<this.sample_counts.length;t++){for(r=0;r<this.sample_counts[t];r++){e[i].pts=e[i].dts+this.sample_offsets[t];i++}}};o.cslgBox.prototype.parse=function(e){var t;this.parseFullHeader(e);if(this.version===0){this.compositionToDTSShift=e.readInt32();this.leastDecodeToDisplayDelta=e.readInt32();this.greatestDecodeToDisplayDelta=e.readInt32();this.compositionStartTime=e.readInt32();this.compositionEndTime=e.readInt32()}else{this.data=e.readUint8Array(this.size-4)}};o.sttsBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.sample_counts=[];this.sample_deltas=[];if(this.version===0){for(r=0;r<t;r++){this.sample_counts.push(e.readUint32());this.sample_deltas.push(e.readUint32())}}else{this.data=e.readUint8Array(this.size-4)}};o.sttsBox.prototype.unpack=function(e){var t,r,i;i=0;for(t=0;t<this.sample_counts.length;t++){for(r=0;r<this.sample_counts[t];r++){if(i===0){e[i].dts=0}else{e[i].dts=e[i-1].dts+this.sample_deltas[t]}i++}}};o.stssBox.prototype.parse=function(e){var t;this.parseFullHeader(e);t=e.readUint32();if(this.version===0){this.sample_numbers=e.readUint32Array(t)}else{this.data=e.readUint8Array(this.size-4)}};o.stshBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.shadowed_sample_numbers=[];this.sync_sample_numbers=[];if(this.version===0){for(r=0;r<t;r++){this.shadowed_sample_numbers.push(e.readUint32());this.sync_sample_numbers.push(e.readUint32())}}else{this.data=e.readUint8Array(this.size-4)}};o.stcoBox.prototype.parse=function(e){var t;this.parseFullHeader(e);t=e.readUint32();if(this.version===0){this.chunk_offsets=e.readUint32Array(t)}else{this.data=e.readUint8Array(this.size-4)}};o.stcoBox.prototype.unpack=function(e){var t;for(t=0;t<this.chunk_offsets.length;t++){e[t].offset=this.chunk_offsets[t]}};o.co64Box.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.chunk_offsets=[];if(this.version===0){for(r=0;r<t;r++){this.chunk_offsets.push(e.readUint64())}}else{this.data=e.readUint8Array(this.size-4)}};o.stscBox.prototype.parse=function(e){var t;var r;this.parseFullHeader(e);t=e.readUint32();this.first_chunk=[];this.samples_per_chunk=[];this.sample_description_index=[];if(this.version===0){for(r=0;r<t;r++){this.first_chunk.push(e.readUint32());this.samples_per_chunk.push(e.readUint32());this.sample_description_index.push(e.readUint32())}}else{this.data=e.readUint8Array(this.size-4)}};o.stscBox.prototype.unpack=function(e){var t,r,i,n,a;n=0;a=0;for(t=0;t<this.first_chunk.length;t++){for(r=0;r<(t+1<this.first_chunk.length?this.first_chunk[t+1]:Infinity);r++){a++;for(i=0;i<this.samples_per_chunk[t];i++){if(e[n]){e[n].description_index=this.sample_description_index[t];e[n].chunk_index=a}else{return}n++}}}};o.stszBox.prototype.parse=function(e){var t;var r;var i;this.parseFullHeader(e);this.sample_sizes=[];if(this.version===0){r=e.readUint32();i=e.readUint32();if(r===0){this.sample_sizes=e.readUint32Array(i)}else{this.sample_sizes=[];for(t=0;t<i;t++){this.sample_sizes[t]=r}}}else{this.data=e.readUint8Array(this.size)}};o.stszBox.prototype.unpack=function(e){var t;for(t=0;t<this.sample_sizes.length;t++){e[t].size=this.sample_sizes[t]}};o.mehdBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.fragment_duration=e.readUint64()}else{this.fragment_duration=e.readUint32()}};o.trexBox.prototype.parse=function(e){this.parseFullHeader(e);this.track_id=e.readUint32();this.default_sample_description_index=e.readUint32();this.default_sample_duration=e.readUint32();this.default_sample_size=e.readUint32();this.default_sample_flags=e.readUint32()};o.mfhdBox.prototype.parse=function(e){this.parseFullHeader(e);this.sequence_number=e.readUint32()};o.TFHD_FLAG_BASE_DATA_OFFSET=1;o.TFHD_FLAG_SAMPLE_DESC=2;o.TFHD_FLAG_SAMPLE_DUR=8;o.TFHD_FLAG_SAMPLE_SIZE=16;o.TFHD_FLAG_SAMPLE_FLAGS=32;o.TFHD_FLAG_DUR_EMPTY=65536;o.TFHD_FLAG_DEFAULT_BASE_IS_MOOF=131072;o.tfhdBox.prototype.parse=function(e){var t=0;this.parseFullHeader(e);this.track_id=e.readUint32();if(this.size>t&&this.flags&o.TFHD_FLAG_BASE_DATA_OFFSET){this.base_data_offset=e.readUint64();t+=8}else{this.base_data_offset=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_DESC){this.default_sample_description_index=e.readUint32();t+=4}else{this.default_sample_description_index=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_DUR){this.default_sample_duration=e.readUint32();t+=4}else{this.default_sample_duration=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_SIZE){this.default_sample_size=e.readUint32();t+=4}else{this.default_sample_size=0}if(this.size>t&&this.flags&o.TFHD_FLAG_SAMPLE_FLAGS){this.default_sample_flags=e.readUint32();t+=4}else{this.default_sample_flags=0}};o.TRUN_FLAGS_DATA_OFFSET=1;o.TRUN_FLAGS_FIRST_FLAG=4;o.TRUN_FLAGS_DURATION=256;o.TRUN_FLAGS_SIZE=512;o.TRUN_FLAGS_FLAGS=1024;o.TRUN_FLAGS_CTS_OFFSET=2048;o.trunBox.prototype.parse=function(e){var t=0;this.parseFullHeader(e);this.sample_count=e.readUint32();t+=4;if(this.size>t&&this.flags&o.TRUN_FLAGS_DATA_OFFSET){this.data_offset=e.readInt32();t+=4}else{this.data_offset=0}if(this.size>t&&this.flags&o.TRUN_FLAGS_FIRST_FLAG){this.first_sample_flags=e.readUint32();t+=4}else{this.first_sample_flags=0}this.sample_duration=[];this.sample_size=[];this.sample_flags=[];this.sample_composition_time_offset=[];if(this.size>t){for(var r=0;r<this.sample_count;r++){if(this.flags&o.TRUN_FLAGS_DURATION){this.sample_duration[r]=e.readUint32()}if(this.flags&o.TRUN_FLAGS_SIZE){this.sample_size[r]=e.readUint32()}if(this.flags&o.TRUN_FLAGS_FLAGS){this.sample_flags[r]=e.readUint32()}if(this.flags&o.TRUN_FLAGS_CTS_OFFSET){if(this.version===0){this.sample_composition_time_offset[r]=e.readUint32()}else{this.sample_composition_time_offset[r]=e.readInt32()}}}}};o.tfdtBox.prototype.parse=function(e){this.parseFullHeader(e);if(this.version==1){this.baseMediaDecodeTime=e.readUint64()}else{this.baseMediaDecodeTime=e.readUint32()}};o.paylBox.prototype.parse=function(e){this.text=e.readString(this.size)};o.subsBox.prototype.parse=function(e){var t,r;var i;var n;this.parseFullHeader(e);i=e.readUint32();this.samples=[];for(t=0;t<i;t++){var a={};this.samples[t]=a;a.sample_delta=e.readUint32();a.subsamples=[];n=e.readUint16();if(n>0){for(r=0;r<n;r++){var s={};a.subsamples.push(s);if(this.version==1){s.size=e.readUint32()}else{s.size=e.readUint16()}s.priority=e.readUint8();s.discardable=e.readUint8();s.reserved=e.readUint32()}}}};o.Box.prototype.writeHeader=function(e,t){this.size+=8;if(this.size>n.MAX_SIZE){this.size+=8}s.d("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+e.position+(t||""));if(this.size>n.MAX_SIZE){e.writeUint32(1)}else{this.sizePosition=e.position;e.writeUint32(this.size)}e.writeString(this.type,null,4);if(this.size>n.MAX_SIZE){e.writeUint64(this.size)}};o.FullBox.prototype.writeHeader=function(e){this.size+=4;o.Box.prototype.writeHeader.call(this,e," v="+this.version+" f="+this.flags);e.writeUint8(this.version);e.writeUint24(this.flags)};o.Box.prototype.write=function(e){if(this.type==="mdat"){if(this.data){this.size=this.data.length;this.writeHeader(e);e.writeUint8Array(this.data)}}else{this.size=this.data.length;this.writeHeader(e);e.writeUint8Array(this.data)}};o.ContainerBox.prototype.write=function(e){this.size=0;this.writeHeader(e);for(var t=0;t<this.boxes.length;t++){if(this.boxes[t]){this.boxes[t].write(e);this.size+=this.boxes[t].size}}s.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size);e.adjustUint32(this.sizePosition,this.size)};o.TrackReferenceTypeBox.prototype.write=function(e){this.size=this.track_ids.length*4;this.writeHeader(e);e.writeUint32Array(this.track_ids)};o.ftypBox.prototype.write=function(e){this.size=8+4*this.compatible_brands.length;this.writeHeader(e);e.writeString(this.major_brand,null,4);e.writeUint32(this.minor_version);for(var t=0;t<this.compatible_brands.length;t++){e.writeString(this.compatible_brands[t],null,4)}};o.mvhdBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=23*4+2*2;this.writeHeader(e);e.writeUint32(this.creation_time);e.writeUint32(this.modification_time);e.writeUint32(this.timescale);e.writeUint32(this.duration);e.writeUint32(this.rate);e.writeUint16(this.volume<<8);e.writeUint16(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32Array(this.matrix);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(this.next_track_id)};o.tkhdBox.prototype.write=function(e){this.version=0;this.size=4*18+2*4;this.writeHeader(e);e.writeUint32(this.creation_time);e.writeUint32(this.modification_time);e.writeUint32(this.track_id);e.writeUint32(0);e.writeUint32(this.duration);e.writeUint32(0);e.writeUint32(0);e.writeInt16(this.layer);e.writeInt16(this.alternate_group);e.writeInt16(this.volume<<8);e.writeUint16(0);e.writeInt32Array(this.matrix);e.writeUint32(this.width);e.writeUint32(this.height)};o.mdhdBox.prototype.write=function(e){this.size=4*4+2*2;this.flags=0;this.version=0;this.writeHeader(e);e.writeUint32(this.creation_time);e.writeUint32(this.modification_time);e.writeUint32(this.timescale);e.writeUint32(this.duration);e.writeUint16(this.language);e.writeUint16(0)};o.hdlrBox.prototype.write=function(e){this.size=5*4+this.name.length+1;this.version=0;this.flags=0;this.writeHeader(e);e.writeUint32(0);e.writeString(this.handler,null,4);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeCString(this.name)};o.stsdBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=0;this.writeHeader(e);e.writeUint32(this.entries.length);this.size+=4;for(t=0;t<this.entries.length;t++){this.entries[t].write(e);this.size+=this.entries[t].size}s.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size);e.adjustUint32(this.sizePosition,this.size)};o.SampleEntry.prototype.writeHeader=function(e){this.size=8;o.Box.prototype.writeHeader.call(this,e);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint8(0);e.writeUint16(this.data_reference_index)};o.SampleEntry.prototype.writeFooter=function(e){for(var t=0;t<this.boxes.length;t++){this.boxes[t].write(e);this.size+=this.boxes[t].size}s.d("BoxWriter","Adjusting box "+this.type+" with new size "+this.size);e.adjustUint32(this.sizePosition,this.size)};o.SampleEntry.prototype.write=function(e){this.writeHeader(e);this.writeFooter(e)};o.VisualSampleEntry.prototype.write=function(e){this.writeHeader(e);this.size+=2*7+6*4+32;e.writeUint16(0);e.writeUint16(0);e.writeUint32(0);e.writeUint32(0);e.writeUint32(0);e.writeUint16(this.width-this.width%2);e.writeUint16(this.height-this.height%2);e.writeUint32(this.horizresolution);e.writeUint32(this.vertresolution);e.writeUint32(0);e.writeUint16(this.frame_count);e.writeString(this.compressorname,null,32);e.writeUint16(this.depth);e.writeInt16(-1);this.writeFooter(e)};o.AudioSampleEntry.prototype.write=function(e){this.writeHeader(e);this.size+=2*4+3*4;e.writeUint32(0);e.writeUint32(0);e.writeUint16(this.channel_count);e.writeUint16(this.samplesize);e.writeUint16(0);e.writeUint16(0);e.writeUint32(this.samplerate<<16);this.writeFooter(e)};o.avcCBox.prototype.write=function(e){var t;this.size=7;for(t=0;t<this.SPS.length;t++){this.size+=2+this.SPS[t].length}for(t=0;t<this.PPS.length;t++){this.size+=2+this.PPS[t].length}if(this.ext){this.size+=this.ext.length}this.writeHeader(e);e.writeUint8(this.configurationVersion);e.writeUint8(this.AVCProfileIndication);e.writeUint8(this.profile_compatibility);e.writeUint8(this.AVCLevelIndication);e.writeUint8(this.lengthSizeMinusOne+(63<<2));e.writeUint8(this.SPS.length+(7<<5));for(t=0;t<this.SPS.length;t++){e.writeUint16(this.SPS[t].length);e.writeUint8Array(this.SPS[t])}e.writeUint8(this.PPS.length);for(t=0;t<this.PPS.length;t++){e.writeUint16(this.PPS[t].length);e.writeUint8Array(this.PPS[t])}if(this.ext){e.writeUint8Array(this.ext)}};o.cttsBox.prototype.write=function(e){var t;this.version=1;this.flags=0;this.size=4+8*this.sample_counts.length;this.writeHeader(e);e.writeUint32(this.sample_counts.length);for(t=0;t<this.sample_counts.length;t++){e.writeUint32(this.sample_counts[t]);e.writeInt32(this.sample_offsets[t])}};o.cslgBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4*5;this.writeHeader(e);e.writeInt32(this.compositionToDTSShift);e.writeInt32(this.leastDecodeToDisplayDelta);e.writeInt32(this.greatestDecodeToDisplayDelta);e.writeInt32(this.compositionStartTime);e.writeInt32(this.compositionEndTime)};o.sttsBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+8*this.sample_counts.length;this.writeHeader(e);e.writeUint32(this.sample_counts.length);for(t=0;t<this.sample_counts.length;t++){e.writeUint32(this.sample_counts[t]);e.writeUint32(this.sample_deltas[t])}};o.stssBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4+4*this.sample_numbers.length;this.writeHeader(e);e.writeUint32(this.sample_numbers.length);e.writeUint32Array(this.sample_numbers)};o.stshBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+8*this.shadowed_sample_numbers.length;this.writeHeader(e);e.writeUint32(this.shadowed_sample_numbers.length);for(t=0;t<this.shadowed_sample_numbers.length;t++){e.writeUint32(this.shadowed_sample_numbers[t]);e.writeUint32(this.sync_sample_numbers[t])}};o.stcoBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4+4*this.chunk_offsets.length;this.writeHeader(e);e.writeUint32(this.chunk_offsets.length);e.writeUint32Array(this.chunk_offsets)};o.co64Box.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+8*this.chunk_offsets.length;this.writeHeader(e);e.writeUint32(this.chunk_offsets.length);for(t=0;t<this.chunk_offsets.length;t++){e.writeUint64(this.chunk_offsets[t])}};o.stscBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=4+12*this.first_chunk.length;this.writeHeader(e);e.writeUint32(this.first_chunk.length);for(t=0;t<this.first_chunk.length;t++){e.writeUint32(this.first_chunk[t]);e.writeUint32(this.samples_per_chunk[t]);e.writeUint32(this.sample_description_index[t])}};o.stszBox.prototype.write=function(e){var t;this.version=0;this.flags=0;this.size=8+12*this.sample_sizes.length;this.writeHeader(e);e.writeUint32(0);e.writeUint32(this.sample_sizes.length);e.writeUint32Array(this.sample_sizes)};o.mehdBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4;this.writeHeader(e);e.writeUint32(this.fragment_duration)};o.trexBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4*5;this.writeHeader(e);e.writeUint32(this.track_id);e.writeUint32(this.default_sample_description_index);e.writeUint32(this.default_sample_duration);e.writeUint32(this.default_sample_size);e.writeUint32(this.default_sample_flags)};o.mfhdBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4;this.writeHeader(e);e.writeUint32(this.sequence_number)};o.tfhdBox.prototype.write=function(e){this.version=0;this.size=4;if(this.flags&o.TFHD_FLAG_BASE_OFFSET){this.size+=8}if(this.flags&o.TFHD_FLAG_SAMPLE_DESC){this.size+=4}if(this.flags&o.TFHD_FLAG_SAMPLE_DUR){this.size+=4}if(this.flags&o.TFHD_FLAG_SAMPLE_SIZE){this.size+=4}if(this.flags&o.TFHD_FLAG_SAMPLE_FLAGS){this.size+=4}this.writeHeader(e);e.writeUint32(this.track_id);if(this.flags&o.TFHD_FLAG_BASE_OFFSET){e.writeUint64(this.base_data_offset)}if(this.flags&o.TFHD_FLAG_SAMPLE_DESC){e.writeUint32(this.default_sample_description_index)}if(this.flags&o.TFHD_FLAG_SAMPLE_DUR){e.writeUint32(this.default_sample_duration)}if(this.flags&o.TFHD_FLAG_SAMPLE_SIZE){e.writeUint32(this.default_sample_size)}if(this.flags&o.TFHD_FLAG_SAMPLE_FLAGS){e.writeUint32(this.default_sample_flags)}};o.trunBox.prototype.write=function(e){this.version=0;this.size=4;if(this.flags&o.TRUN_FLAGS_DATA_OFFSET){this.size+=4}if(this.flags&o.TRUN_FLAGS_FIRST_FLAG){this.size+=4}if(this.flags&o.TRUN_FLAGS_DURATION){this.size+=4*this.sample_duration.length}if(this.flags&o.TRUN_FLAGS_SIZE){this.size+=4*this.sample_size.length}if(this.flags&o.TRUN_FLAGS_FLAGS){this.size+=4*this.sample_flags.length}if(this.flags&o.TRUN_FLAGS_CTS_OFFSET){this.size+=4*this.sample_composition_time_offset.length}this.writeHeader(e);e.writeUint32(this.sample_count);if(this.flags&o.TRUN_FLAGS_DATA_OFFSET){this.data_offset_position=e.position;e.writeInt32(this.data_offset)}if(this.flags&o.TRUN_FLAGS_FIRST_FLAG){e.writeUint32(this.first_sample_flags)}for(var t=0;t<this.sample_count;t++){if(this.flags&o.TRUN_FLAGS_DURATION){e.writeUint32(this.sample_duration[t])}if(this.flags&o.TRUN_FLAGS_SIZE){e.writeUint32(this.sample_size[t])}if(this.flags&o.TRUN_FLAGS_FLAGS){e.writeUint32(this.sample_flags[t])}if(this.flags&o.TRUN_FLAGS_CTS_OFFSET){if(this.version===0){e.writeUint32(this.sample_composition_time_offset[t])}else{e.writeInt32(this.sample_composition_time_offset[t])}}}};o.tfdtBox.prototype.write=function(e){this.version=0;this.flags=0;this.size=4;this.writeHeader(e);if(this.version==1){e.writeUint64(this.baseMediaDecodeTime)}else{e.writeUint32(this.baseMediaDecodeTime)}}},{"./DataStream":174,"./descriptor":176,"./log":178}],176:[function(e,t,r){var i=e("./log");var n=function(){var e=3;var t=4;var r=5;var n=6;var a=[];a[e]="ES_Descriptor";a[t]="DecoderConfigDescriptor";a[r]="DecoderSpecificInfo";a[n]="SLConfigDescriptor";var s=this;var o={};this.parseOneDescriptor=function(e){var t=0;var r=0;var n;var s;var f;n=e.readUint8();t++;f=e.readUint8();t++;while(f&128){r=(f&127)<<7;f=e.readUint8();t++}r+=f&127;i.d("MPEG4DescriptorParser","Found "+(a[n]|"Descriptor "+n)+", size "+r+" at position "+e.position);if(a[n]){s=new o[a[n]](r)}else{s=new o.Descriptor(r)}s.parse(e);return s};o.Descriptor=function(e,t){this.tag=e;this.size=t;this.descs=[]};o.Descriptor.prototype.parse=function(e){this.data=e.readUint8Array(this.size)};o.Descriptor.prototype.findDescriptor=function(e){for(var t=0;t<this.descs.length;t++){if(this.descs[t].tag==e){return this.descs[t]}}return null};o.Descriptor.prototype.parseRemainingDescriptors=function(e){var t=e.position;while(e.position<t+this.size){var r=s.parseOneDescriptor(e);this.descs.push(r)}};o.ES_Descriptor=function(t){o.Descriptor.call(this,e,t)};o.ES_Descriptor.prototype=new o.Descriptor;o.ES_Descriptor.prototype.parse=function(e){this.ES_ID=e.readUint16();this.flags=e.readUint8();this.size-=3;if(this.flags&128){this.dependsOn_ES_ID=e.readUint16();this.size-=2}else{this.dependsOn_ES_ID=0}if(this.flags&64){var t=e.readUint8();this.URL=e.readString(t);this.size-=t+1}else{this.URL=null}if(this.flags&32){this.OCR_ES_ID=e.readUint16();this.size-=2}else{this.OCR_ES_ID=0}this.parseRemainingDescriptors(e)};o.ES_Descriptor.prototype.getOTI=function(e){var r=this.findDescriptor(t);if(r){return r.oti}else{return 0}};o.ES_Descriptor.prototype.getAudioConfig=function(e){var i=this.findDescriptor(t);if(!i)return null;var n=i.findDescriptor(r);if(n&&n.data){return(n.data[0]&248)>>3}else{return null}};o.DecoderConfigDescriptor=function(e){o.Descriptor.call(this,t,e)};o.DecoderConfigDescriptor.prototype=new o.Descriptor;o.DecoderConfigDescriptor.prototype.parse=function(e){this.oti=e.readUint8();this.streamType=e.readUint8();this.bufferSize=e.readUint24();this.maxBitrate=e.readUint32();this.avgBitrate=e.readUint32();this.size-=13;this.parseRemainingDescriptors(e)};o.DecoderSpecificInfo=function(e){o.Descriptor.call(this,r,e)};o.DecoderSpecificInfo.prototype=new o.Descriptor;o.SLConfigDescriptor=function(e){o.Descriptor.call(this,n,e)};o.SLConfigDescriptor.prototype=new o.Descriptor;return this};t.exports=n},{"./log":178}],177:[function(e,t,r){var i=e("./box");var n=e("./DataStream");var a=e("./log");var s=function(e){this.stream=e;this.boxes=[];this.mdats=[];this.moofs=[];this.isProgressive=false;this.lastMoofIndex=0;this.lastBoxStartPosition=0;this.parsingMdat=null;this.moovStartFound=false;this.samplesDataSize=0;this.nextParsePosition=0};t.exports=s;s.prototype.mergeNextBuffer=function(){var e;if(this.stream.bufferIndex+1<this.stream.nextBuffers.length){e=this.stream.nextBuffers[this.stream.bufferIndex+1];if(e.fileStart===this.stream.buffer.fileStart+this.stream.buffer.byteLength){var t=this.stream.buffer.byteLength;var r=this.stream.buffer.usedBytes;var i=this.stream.buffer.fileStart;this.stream.nextBuffers[this.stream.bufferIndex]=ArrayBuffer.concat(this.stream.buffer,e);this.stream.buffer=this.stream.nextBuffers[this.stream.bufferIndex];this.stream.nextBuffers.splice(this.stream.bufferIndex+1,1);this.stream.buffer.usedBytes=r;this.stream.buffer.fileStart=i;a.d("ISOFile","Concatenating buffer for box parsing (length: "+t+"->"+this.stream.buffer.byteLength+")");return true}else{return false}}else{return false}};s.prototype.parse=function(){var e;var t;var r;a.d("ISOFile","Starting parsing with buffer #"+this.stream.bufferIndex+" (fileStart: "+this.stream.buffer.fileStart+" - Length: "+this.stream.buffer.byteLength+") from position "+this.lastBoxStartPosition+" ("+(this.stream.buffer.fileStart+this.lastBoxStartPosition)+" in the file)");this.stream.seek(this.lastBoxStartPosition);while(true){if(this.parsingMdat!==null){r=this.parsingMdat;e=this.reposition(false,r.fileStart+r.hdr_size+r.size);if(e){a.d("ISOFile","Found 'mdat' end in buffer #"+this.stream.bufferIndex);this.parsingMdat=null;continue}else{this.nextParsePosition=this.findEndContiguousBuf(this.stream.bufferIndex);return}}else{this.lastBoxStartPosition=this.stream.position;t=i.parseOneBox(this.stream);if(t.code===i.ERR_NOT_ENOUGH_DATA){if(t.type==="mdat"){r=new i[t.type+"Box"](t.size-t.hdr_size);this.parsingMdat=r;this.mdats.push(r);r.fileStart=this.stream.buffer.fileStart+this.stream.position;r.hdr_size=t.hdr_size;this.stream.buffer.usedBytes+=t.hdr_size;e=this.reposition(false,r.fileStart+r.hdr_size+r.size);if(e){this.parsingMdat=null;continue}else{if(!this.moovStartFound){this.nextParsePosition=r.fileStart+r.size+r.hdr_size}else{this.nextParsePosition=this.findEndContiguousBuf(this.stream.bufferIndex)}return}}else{if(t.type==="moov"){this.moovStartFound=true;if(this.mdats.length===0){this.isProgressive=true}}else if(t.type==="free"){e=this.reposition(false,this.stream.buffer.fileStart+this.stream.position+t.size);if(e){continue}else{this.nextParsePosition=this.stream.buffer.fileStart+this.stream.position+t.size;return}}merged=this.mergeNextBuffer();if(merged){this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength;continue}else{if(!t.type){this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength}else{if(this.moovStartFound){this.nextParsePosition=this.stream.buffer.fileStart+this.stream.buffer.byteLength}else{this.nextParsePosition=this.stream.buffer.fileStart+this.stream.position+t.size}}return}}}else{r=t.box;this.boxes.push(r);switch(r.type){case"mdat":this.mdats.push(r);r.fileStart=this.stream.buffer.fileStart+r.start;break;case"moof":this.moofs.push(r);break;case"moov":this.moovStartFound=true;if(this.mdats.length===0){this.isProgressive=true}default:if(this[r.type]!==undefined){a.w("ISOFile","Duplicate Box of type: "+r.type+", overriding previous occurrence")}this[r.type]=r;break}if(r.type==="mdat"){this.stream.buffer.usedBytes+=r.hdr_size}else{this.stream.buffer.usedBytes+=t.size}}}}};s.prototype.reposition=function(e,t){var r;r=this.findPosition(e,t);if(r!==-1){this.stream.buffer=this.stream.nextBuffers[r];this.stream.bufferIndex=r;this.stream.position=t-this.stream.buffer.fileStart;a.d("ISOFile","Repositioning parser at buffer position: "+this.stream.position);return true}else{return false}};s.prototype.findPosition=function(e,t){var r;var i=null;var n=-1;if(e===true){r=0}else{r=this.stream.bufferIndex}while(r<this.stream.nextBuffers.length){i=this.stream.nextBuffers[r];if(i.fileStart<=t){n=r}else{break}r++}if(n!==-1){i=this.stream.nextBuffers[n];if(i.fileStart+i.byteLength>=t){a.d("ISOFile","Found position in existing buffer #"+n);return n}else{return-1}}else{return-1}};s.prototype.findEndContiguousBuf=function(e){var t;var r;var i;r=this.stream.nextBuffers[e];if(this.stream.nextBuffers.length>e+1){for(t=e+1;t<this.stream.nextBuffers.length;t++){i=this.stream.nextBuffers[t];if(i.fileStart===r.fileStart+r.byteLength){r=i}else{break}}}return r.fileStart+r.byteLength;
+};s.prototype.write=function(e){for(var t=0;t<this.boxes.length;t++){this.boxes[t].write(e)}};s.prototype.writeInitializationSegment=function(e){var t;var r;var n;var s;var o;a.d("ISOFile","Generating initialization segment");this.ftyp.write(e);if(this.moov.mvex){this.initial_duration=this.moov.mvex.mehd.fragment_duration;r=-1;for(t=0;t<this.moov.boxes.length;t++){o=this.moov.boxes[t];if(o===this.moov.mvex){r=t}}if(r>-1){this.moov.boxes.splice(r,1)}this.moov.mvex=null}this.moov.mvex=new i.mvexBox;this.moov.boxes.push(this.moov.mvex);this.moov.mvex.mehd=new i.mehdBox;this.moov.mvex.boxes.push(this.moov.mvex.mehd);this.moov.mvex.mehd.fragment_duration=this.initial_duration;for(t=0;t<this.moov.traks.length;t++){if(this.moov.traks[t].ignore)continue;s=new i.trexBox;this.moov.mvex.boxes.push(s);s.track_id=this.moov.traks[t].tkhd.track_id;s.default_sample_description_index=1;s.default_sample_duration=this.moov.traks[t].samples.length>0?this.moov.traks[t].samples[0].duration:0;s.default_sample_size=0;s.default_sample_flags=1<<16}this.moov.write(e)};s.prototype.resetTables=function(){var e;var t,r,i,n,a,s,o,f;this.initial_duration=this.moov.mvhd.duration;this.moov.mvhd.duration=0;for(e=0;e<this.moov.traks.length;e++){t=this.moov.traks[e];t.tkhd.duration=0;t.mdia.mdhd.duration=0;r=t.mdia.minf.stbl.stco||t.mdia.minf.stbl.co64;r.chunk_offsets=[];i=t.mdia.minf.stbl.stsc;i.first_chunk=[];i.samples_per_chunk=[];i.sample_description_index=[];n=t.mdia.minf.stbl.stsz;n.sample_sizes=[];a=t.mdia.minf.stbl.stts;a.sample_counts=[];a.sample_deltas=[];s=t.mdia.minf.stbl.ctts;if(s){s.sample_counts=[];s.sample_offsets=[]}o=t.mdia.minf.stbl.stss;if(o){o.sample_numbers=new Uint32Array(0)}f=t.mdia.minf.stbl.sdtp;var u=t.mdia.minf.stbl.boxes.indexOf(f);if(u!=-1)t.mdia.minf.stbl.boxes[u]=null}};s.prototype.buildSampleLists=function(){var e,t,r;var i,n,a,s,o,f,u,l,c;var p,d,h,m,v;var g,y,_,b,w,x;this.originalMvex=this.moov.mvex;for(e=0;e<this.moov.traks.length;e++){i=this.moov.traks[e];i.samples=[];n=i.mdia.minf.stbl.stco||i.mdia.minf.stbl.co64;a=i.mdia.minf.stbl.stsc;s=i.mdia.minf.stbl.stsz;o=i.mdia.minf.stbl.stts;f=i.mdia.minf.stbl.ctts;u=i.mdia.minf.stbl.stss;l=i.mdia.minf.stbl.stsd;c=i.mdia.minf.stbl.subs;g=-1;y=-1;_=-1;b=-1;w=0;subs_entry_index=0;last_subs_sample_index=0;for(t=0;t<s.sample_sizes.length;t++){var k={};k.number=t;k.track_id=i.tkhd.track_id;k.timescale=i.mdia.mdhd.timescale;i.samples[t]=k;k.size=s.sample_sizes[t];if(t===0){d=1;p=0;k.chunk_index=d;k.chunk_run_index=p;v=a.samples_per_chunk[p];m=0;if(p+1<a.first_chunk.length){h=a.first_chunk[p+1]-1}else{h=Infinity}}else{if(t<v){k.chunk_index=d;k.chunk_run_index=p}else{d++;k.chunk_index=d;m=0;if(d<=h){}else{p++;if(p+1<a.first_chunk.length){h=a.first_chunk[p+1]-1}else{h=Infinity}}k.chunk_run_index=p;v+=a.samples_per_chunk[p]}}k.description=l.entries[a.sample_description_index[k.chunk_run_index]-1];k.offset=n.chunk_offsets[k.chunk_index-1]+m;m+=k.size;if(t>g){y++;if(g<0){g=0}g+=o.sample_counts[y]}if(t>0){i.samples[t-1].duration=o.sample_deltas[y];k.dts=i.samples[t-1].dts+i.samples[t-1].duration}else{k.dts=0}if(f){if(t>_){b++;_+=f.sample_counts[b]}k.cts=i.samples[t].dts+f.sample_offsets[b]}else{k.cts=k.dts}if(u){if(t==u.sample_numbers[w]-1){k.is_rap=true;w++}else{k.is_rap=false}}else{k.is_rap=true}if(c){if(c.samples[subs_entry_index].sample_delta+last_subs_sample_index==t){k.subsamples=c.samples[subs_entry_index].subsamples;last_subs_sample_index+=c.samples[subs_entry_index].sample_delta}}}if(t>0)i.samples[t-1].duration=i.mdia.mdhd.duration-i.samples[t-1].dts}};s.prototype.updateSampleLists=function(){var e,t,r;var n,a,s,o;var f;var u,l,c,p,d;var h;while(this.lastMoofIndex<this.moofs.length){u=this.moofs[this.lastMoofIndex];this.lastMoofIndex++;if(u.type=="moof"){l=u;for(e=0;e<l.trafs.length;e++){c=l.trafs[e];p=this.getTrackById(c.tfhd.track_id);d=this.getTrexById(c.tfhd.track_id);if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_DESC){n=c.tfhd.default_sample_description_index}else{n=d.default_sample_description_index}if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_DUR){a=c.tfhd.default_sample_duration}else{a=d.default_sample_duration}if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_SIZE){s=c.tfhd.default_sample_size}else{s=d.default_sample_size}if(c.tfhd.flags&i.TFHD_FLAG_SAMPLE_FLAGS){o=c.tfhd.default_sample_flags}else{o=d.default_sample_flags}for(t=0;t<c.truns.length;t++){var m=c.truns[t];for(r=0;r<m.sample_count;r++){h={};c.first_sample_index=p.samples.length;p.samples.push(h);h.track_id=p.tkhd.track_id;h.timescale=p.mdia.mdhd.timescale;h.description=p.mdia.minf.stbl.stsd.entries[n-1];h.size=s;if(m.flags&i.TRUN_FLAGS_SIZE){h.size=m.sample_size[r]}h.duration=a;if(m.flags&i.TRUN_FLAGS_DURATION){h.duration=m.sample_duration[r]}if(p.first_traf_merged||r>0){h.dts=p.samples[p.samples.length-2].dts+p.samples[p.samples.length-2].duration}else{if(c.tfdt){h.dts=c.tfdt.baseMediaDecodeTime}else{h.dts=0}p.first_traf_merged=true}h.cts=h.dts;if(m.flags&i.TRUN_FLAGS_CTS_OFFSET){h.cts=h.dts+m.sample_composition_time_offset[r]}sample_flags=o;if(m.flags&i.TRUN_FLAGS_FLAGS){sample_flags=m.sample_flags[r]}else if(r===0&&m.flags&i.TRUN_FLAGS_FIRST_FLAG){sample_flags=m.first_sample_flags}h.is_rap=sample_flags>>16&1?false:true;var v=c.tfhd.flags&i.TFHD_FLAG_BASE_DATA_OFFSET?true:false;var g=c.tfhd.flags&i.TFHD_FLAG_DEFAULT_BASE_IS_MOOF?true:false;var y=m.flags&i.TRUN_FLAGS_DATA_OFFSET?true:false;var _=0;if(!v){if(!g){if(t===0){_=l.fileStart}else{_=f}}else{_=l.fileStart}}else{_=c.tfhd.base_data_offset}if(t===0&&r===0){if(y){h.offset=_+m.data_offset}else{h.offset=_}}else{h.offset=f}f=h.offset+h.size}}if(c.subs){var b=c.first_sample_index;for(t=0;t<c.subs.samples.length;t++){b+=c.subs.samples[t].sample_delta;h=p.samples[b-1];h.subsamples=c.subs.samples[t].subsamples}}}}}};s.prototype.getCodecs=function(){var e;var t="";for(e=0;e<this.moov.traks.length;e++){var r=this.moov.traks[e];if(e>0){t+=","}t+=r.mdia.minf.stbl.stsd.entries[0].getCodec()}return t};s.prototype.getTrexById=function(e){var t;if(!this.originalMvex)return null;for(t=0;t<this.originalMvex.trexs.length;t++){var r=this.originalMvex.trexs[t];if(r.track_id==e)return r}return null};s.prototype.getTrackById=function(e){for(var t=0;t<this.moov.traks.length;t++){var r=this.moov.traks[t];if(r.tkhd.track_id==e)return r}return null};s.prototype.getSample=function(e,t){var r;var i;var s=e.samples[t];if(!this.moov){return null}if(!s.data){s.data=new Uint8Array(s.size);s.alreadyRead=0;this.samplesDataSize+=s.size;a.d("ISOFile","Allocating sample #"+t+" on track #"+e.tkhd.track_id+" of size "+s.size+" (total: "+this.samplesDataSize+")")}else if(s.alreadyRead==s.size){return s}for(i=0;i<this.stream.nextBuffers.length;i++){r=this.stream.nextBuffers[i];if(s.offset+s.alreadyRead>=r.fileStart&&s.offset+s.alreadyRead<r.fileStart+r.byteLength){var o=r.byteLength-(s.offset+s.alreadyRead-r.fileStart);if(s.size-s.alreadyRead<=o){a.d("ISOFile","Getting sample #"+t+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-r.fileStart)+" size: "+(s.size-s.alreadyRead)+")");n.memcpy(s.data.buffer,s.alreadyRead,r,s.offset+s.alreadyRead-r.fileStart,s.size-s.alreadyRead);s.alreadyRead=s.size;r.usedBytes+=s.size-s.alreadyRead;if(r.usedBytes===r.byteLength){this.stream.nextBuffers.splice(i,1);i--}return s}else{a.d("ISOFile","Getting sample data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-r.fileStart)+" size: "+o+")");n.memcpy(s.data.buffer,s.alreadyRead,r,s.offset+s.alreadyRead-r.fileStart,o);s.alreadyRead+=o;r.usedBytes+=o;if(r.usedBytes===r.byteLength){this.stream.nextBuffers.splice(i,1);i--}}}}return null};s.prototype.releaseSample=function(e,t){var r=e.samples[t];r.data=null;this.samplesDataSize-=r.size;return r.size}},{"./DataStream":174,"./box":175,"./log":178}],178:[function(e,t,r){var i=function(){var e=new Date;var t=4;var r=3;var n=2;var a=1;var s=t;var o={setLogLevel:function(e){if(e==this.d)s=a;else if(e==this.i)s=n;else if(e==this.w)s=r;else if(e==this.e)s=t;else s=t},d:function(t,r){if(a>=s){console.debug("["+i.getDurationString(new Date-e,1e3)+"]","["+t+"]",r)}},i:function(t,r){if(n>=s){console.info("["+i.getDurationString(new Date-e,1e3)+"]","["+t+"]",r)}},w:function(t,n){if(r>=s){console.warn("["+i.getDurationString(new Date-e,1e3)+"]","["+t+"]",n)}},e:function(r,n){if(t>=s){console.error("["+i.getDurationString(new Date-e,1e3)+"]","["+r+"]",n)}}};return o}();t.exports=i;i.getDurationString=function(e,t){function r(e,t){var r=""+e;var i=r.split(".");while(i[0].length<t){i[0]="0"+i[0]}return i.join(".")}var i=t||1;var n=e/i;var a=Math.floor(n/3600);n-=a*3600;var s=Math.floor(n/60);n-=s*60;var o=n*1e3;n=Math.floor(n);o-=n*1e3;o=Math.floor(o);return""+a+":"+r(s,2)+":"+r(n,2)+"."+r(o,3)};i.printRanges=function(e){var t=e.length;if(t>0){var r="";for(var n=0;n<t;n++){if(n>0)r+=",";r+="["+i.getDurationString(e.start(n))+","+i.getDurationString(e.end(n))+"]"}return r}else{return"(empty)"}}},{}],179:[function(e,t,r){var n=e("./box");var a=e("./DataStream");var s=e("./isofile");var o=e("./log");var f=function(){this.inputStream=null;this.nextBuffers=[];this.inputIsoFile=null;this.onMoovStart=null;this.moovStartSent=false;this.onReady=null;this.readySent=false;this.onSegment=null;this.onSamples=null;this.onError=null;this.sampleListBuilt=false;this.fragmentedTracks=[];this.extractedTracks=[];this.isFragmentationStarted=false;this.nextMoofNumber=0};t.exports=f;f.prototype.setSegmentOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.fragmentedTracks.push(n);n.id=e;n.user=t;n.trak=i;i.nextSample=0;n.segmentStream=null;n.nb_samples=1e3;n.rapAlignement=true;if(r){if(r.nbSamples)n.nb_samples=r.nbSamples;if(r.rapAlignement)n.rapAlignement=r.rapAlignement}}};f.prototype.unsetSegmentOptions=function(e){var t=-1;for(var r=0;r<this.fragmentedTracks.length;r++){var i=this.fragmentedTracks[r];if(i.id==e){t=r}}if(t>-1){this.fragmentedTracks.splice(t,1)}};f.prototype.setExtractionOptions=function(e,t,r){var i=this.inputIsoFile.getTrackById(e);if(i){var n={};this.extractedTracks.push(n);n.id=e;n.user=t;n.trak=i;i.nextSample=0;n.nb_samples=1e3;n.samples=[];if(r){if(r.nbSamples)n.nb_samples=r.nbSamples}}};f.prototype.unsetExtractionOptions=function(e){var t=-1;for(var r=0;r<this.extractedTracks.length;r++){var i=this.extractedTracks[r];if(i.id==e){t=r}}if(t>-1){this.extractedTracks.splice(t,1)}};f.prototype.createSingleSampleMoof=function(e){var t=new n.moofBox;var r=new n.mfhdBox;r.sequence_number=this.nextMoofNumber;this.nextMoofNumber++;t.boxes.push(r);var i=new n.trafBox;t.boxes.push(i);var a=new n.tfhdBox;i.boxes.push(a);a.track_id=e.track_id;a.flags=n.TFHD_FLAG_DEFAULT_BASE_IS_MOOF;var s=new n.tfdtBox;i.boxes.push(s);s.baseMediaDecodeTime=e.dts;var o=new n.trunBox;i.boxes.push(o);t.trun=o;o.flags=n.TRUN_FLAGS_DATA_OFFSET|n.TRUN_FLAGS_DURATION|n.TRUN_FLAGS_SIZE|n.TRUN_FLAGS_FLAGS|n.TRUN_FLAGS_CTS_OFFSET;o.data_offset=0;o.first_sample_flags=0;o.sample_count=1;o.sample_duration=[];o.sample_duration[0]=e.duration;o.sample_size=[];o.sample_size[0]=e.size;o.sample_flags=[];o.sample_flags[0]=0;o.sample_composition_time_offset=[];o.sample_composition_time_offset[0]=e.cts-e.dts;return t};f.prototype.createFragment=function(e,t,r,i){var s=this.inputIsoFile.getTrackById(t);var f=this.inputIsoFile.getSample(s,r);if(f==null){if(this.nextSeekPosition){this.nextSeekPosition=Math.min(s.samples[r].offset,this.nextSeekPosition)}else{this.nextSeekPosition=s.samples[r].offset}return null}var u=i||new a;u.endianness=a.BIG_ENDIAN;var l=this.createSingleSampleMoof(f);l.write(u);l.trun.data_offset=l.size+8;o.d("BoxWriter","Adjusting data_offset with new value "+l.trun.data_offset);u.adjustUint32(l.trun.data_offset_position,l.trun.data_offset);var c=new n.mdatBox;c.data=f.data;c.write(u);return u};ArrayBuffer.concat=function(e,t){o.d("ArrayBuffer","Trying to create a new buffer of size: "+(e.byteLength+t.byteLength));var r=new Uint8Array(e.byteLength+t.byteLength);r.set(new Uint8Array(e),0);r.set(new Uint8Array(t),e.byteLength);return r.buffer};f.prototype.reduceBuffer=function(e,t,r){var i;i=new Uint8Array(r);i.set(new Uint8Array(e,t,r));i.buffer.fileStart=e.fileStart+t;i.buffer.usedBytes=0;return i.buffer};f.prototype.insertBuffer=function(e){var t=true;for(var r=0;r<this.nextBuffers.length;r++){var i=this.nextBuffers[r];if(e.fileStart<=i.fileStart){if(e.fileStart===i.fileStart){if(e.byteLength>i.byteLength){this.nextBuffers.splice(r,1);r--;continue}else{o.w("MP4Box","Buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+") already appended, ignoring")}}else{if(e.fileStart+e.byteLength<=i.fileStart){}else{e=this.reduceBuffer(e,0,i.fileStart-e.fileStart)}o.d("MP4Box","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")");this.nextBuffers.splice(r,0,e);if(r===0&&this.inputStream!==null){this.inputStream.buffer=e}}t=false;break}else if(e.fileStart<i.fileStart+i.byteLength){var n=i.fileStart+i.byteLength-e.fileStart;var a=e.byteLength-n;if(a>0){e=this.reduceBuffer(e,n,a)}else{t=false;break}}}if(t){o.d("MP4Box","Appending new buffer (fileStart: "+e.fileStart+" - Length: "+e.byteLength+")");this.nextBuffers.push(e);if(r===0&&this.inputStream!==null){this.inputStream.buffer=e}}};f.prototype.processSamples=function(){var e;var t;if(this.isFragmentationStarted&&this.onSegment!==null){for(e=0;e<this.fragmentedTracks.length;e++){var r=this.fragmentedTracks[e];t=r.trak;while(t.nextSample<t.samples.length){o.d("MP4Box","Creating media fragment on track #"+r.id+" for sample "+t.nextSample);var i=this.createFragment(this.inputIsoFile,r.id,t.nextSample,r.segmentStream);if(i){r.segmentStream=i;t.nextSample++}else{break}if(t.nextSample%r.nb_samples===0||t.nextSample>=t.samples.length){o.i("MP4Box","Sending fragmented data on track #"+r.id+" for samples ["+(t.nextSample-r.nb_samples)+","+(t.nextSample-1)+"]");if(this.onSegment){this.onSegment(r.id,r.user,r.segmentStream.buffer,t.nextSample)}r.segmentStream=null;if(r!==this.fragmentedTracks[e]){break}}}}}if(this.onSamples!==null){for(e=0;e<this.extractedTracks.length;e++){var n=this.extractedTracks[e];t=n.trak;while(t.nextSample<t.samples.length){o.d("MP4Box","Exporting on track #"+n.id+" sample #"+t.nextSample);var a=this.inputIsoFile.getSample(t,t.nextSample);if(a){t.nextSample++;n.samples.push(a)}else{return}if(t.nextSample%n.nb_samples===0||t.nextSample>=t.samples.length){o.d("MP4Box","Sending samples on track #"+n.id+" for sample "+t.nextSample);if(this.onSamples){this.onSamples(n.id,n.user,n.samples)}n.samples=[];if(n!==this.extractedTracks[e]){break}}}}}};f.prototype.appendBuffer=function(e){var t;var r;if(e===null||e===undefined){throw"Buffer must be defined and non empty"}if(e.fileStart===undefined){throw"Buffer must have a fileStart property"}if(e.byteLength===0){o.w("MP4Box","Ignoring empty buffer (fileStart: "+e.fileStart+")");return}e.usedBytes=0;this.insertBuffer(e);if(!this.inputStream){if(this.nextBuffers.length>0){r=this.nextBuffers[0];if(r.fileStart===0){this.inputStream=new a(r,0,a.BIG_ENDIAN);this.inputStream.nextBuffers=this.nextBuffers;this.inputStream.bufferIndex=0}else{o.w("MP4Box","The first buffer should have a fileStart of 0");return}}else{o.w("MP4Box","No buffer to start parsing from");return}}if(!this.inputIsoFile){this.inputIsoFile=new s(this.inputStream)}this.inputIsoFile.parse();if(this.inputIsoFile.moovStartFound&&!this.moovStartSent){this.moovStartSent=true;if(this.onMoovStart)this.onMoovStart()}if(this.inputIsoFile.moov){if(!this.sampleListBuilt){this.inputIsoFile.buildSampleLists();this.sampleListBuilt=true}this.inputIsoFile.updateSampleLists();if(this.onReady&&!this.readySent){var i=this.getInfo();this.readySent=true;this.onReady(i)}this.processSamples();if(this.nextSeekPosition){t=this.nextSeekPosition;this.nextSeekPosition=undefined}else{t=this.inputIsoFile.nextParsePosition}var n=this.inputIsoFile.findPosition(true,t);if(n!==-1){t=this.inputIsoFile.findEndContiguousBuf(n)}o.i("MP4Box","Next buffer to fetch should have a fileStart position of "+t);return t}else{if(this.inputIsoFile!==null){return this.inputIsoFile.nextParsePosition}else{return 0}}};f.prototype.getInfo=function(){var e={};var t;var r;var n;var a=new Date(4,0,1,0,0,0,0).getTime();e.duration=this.inputIsoFile.moov.mvhd.duration;e.timescale=this.inputIsoFile.moov.mvhd.timescale;e.isFragmented=this.inputIsoFile.moov.mvex!=null;if(e.isFragmented&&this.inputIsoFile.moov.mvex.mehd){e.fragment_duration=this.inputIsoFile.moov.mvex.mehd.fragment_duration}else{e.fragment_duration=0}e.isProgressive=this.inputIsoFile.isProgressive;e.hasIOD=this.inputIsoFile.moov.iods!=null;e.brands=[];e.brands.push(this.inputIsoFile.ftyp.major_brand);e.brands=e.brands.concat(this.inputIsoFile.ftyp.compatible_brands);e.created=new Date(a+this.inputIsoFile.moov.mvhd.creation_time*1e3);e.modified=new Date(a+this.inputIsoFile.moov.mvhd.modification_time*1e3);e.tracks=[];e.audioTracks=[];e.videoTracks=[];e.subtitleTracks=[];e.metadataTracks=[];e.hintTracks=[];e.otherTracks=[];for(i=0;i<this.inputIsoFile.moov.traks.length;i++){t=this.inputIsoFile.moov.traks[i];n=t.mdia.minf.stbl.stsd.entries[0];r={};e.tracks.push(r);r.id=t.tkhd.track_id;r.references=[];if(t.tref){for(j=0;j<t.tref.boxes.length;j++){ref={};r.references.push(ref);ref.type=t.tref.boxes[j].type;ref.track_ids=t.tref.boxes[j].track_ids}}r.created=new Date(a+t.tkhd.creation_time*1e3);r.modified=new Date(a+t.tkhd.modification_time*1e3);r.movie_duration=t.tkhd.duration;r.layer=t.tkhd.layer;r.alternate_group=t.tkhd.alternate_group;r.volume=t.tkhd.volume;r.matrix=t.tkhd.matrix;r.track_width=t.tkhd.width/(1<<16);r.track_height=t.tkhd.height/(1<<16);r.timescale=t.mdia.mdhd.timescale;r.duration=t.mdia.mdhd.duration;r.codec=n.getCodec();r.language=t.mdia.mdhd.languageString;r.nb_samples=t.samples.length;r.size=0;for(j=0;j<r.nb_samples;j++){r.size+=t.samples[j].size}r.bitrate=r.size*8*r.timescale/r.duration;if(n.isAudio()){e.audioTracks.push(r);r.audio={};r.audio.sample_rate=n.getSampleRate();r.audio.channel_count=n.getChannelCount();r.audio.sample_size=n.getSampleSize()}else if(n.isVideo()){e.videoTracks.push(r);r.video={};r.video.width=n.getWidth();r.video.height=n.getHeight()}else if(n.isSubtitle()){e.subtitleTracks.push(r)}else if(n.isHint()){e.hintTracks.push(r)}else if(n.isMetadata()){e.metadataTracks.push(r)}else{e.otherTracks.push(r)}}return e};f.prototype.getInitializationSegment=function(){var e=new a;e.endianness=a.BIG_ENDIAN;this.inputIsoFile.writeInitializationSegment(e);return e.buffer};f.prototype.writeFile=function(){var e=new a;e.endianness=a.BIG_ENDIAN;this.inputIsoFile.write(e);return e.buffer};f.prototype.initializeSegmentation=function(){var e;var t;var r;var i;var n;if(this.onSegment===null){o.w("MP4Box","No segmentation callback set!")}if(!this.isFragmentationStarted){this.isFragmentationStarted=true;this.nextMoofNumber=0;this.inputIsoFile.resetTables()}i=[];for(e=0;e<this.fragmentedTracks.length;e++){for(t=0;t<this.inputIsoFile.moov.boxes.length;t++){r=this.inputIsoFile.moov.boxes[t];if(r&&r.type==="trak"){this.inputIsoFile.moov.boxes[t].ignore=true;this.inputIsoFile.moov.boxes[t]=null}}n=this.inputIsoFile.getTrackById(this.fragmentedTracks[e].id);delete n.ignore;for(t=0;t<this.inputIsoFile.moov.boxes.length;t++){r=this.inputIsoFile.moov.boxes[t];if(r==null){this.inputIsoFile.moov.boxes[t]=n;break}}seg={};seg.id=n.tkhd.track_id;seg.user=this.fragmentedTracks[e].user;seg.buffer=this.getInitializationSegment();i.push(seg)}return i};f.prototype.releaseUsedSamples=function(e,t){var r=0;var i=this.inputIsoFile.getTrackById(e);if(!i.lastValidSample)i.lastValidSample=0;for(var n=i.lastValidSample;n<t;n++){r+=this.inputIsoFile.releaseSample(i,n)}o.d("MP4Box","Track #"+e+" released samples up to "+t+" (total size: "+r+", remaining: "+this.inputIsoFile.samplesDataSize+")");i.lastValidSample=t};f.prototype.flush=function(){o.i("MP4Box","Flushing remaining samples");this.inputIsoFile.updateSampleLists();this.processSamples()};f.prototype.seekTrack=function(e,t,r){var i;var n;var a=Infinity;var s=0;var f=Infinity;var u=0;var l=0;var c;for(i=0;i<r.samples.length;i++){n=r.samples[i];if(i===0){f=n.offset;l=0;c=n.timescale}else if(n.cts>e*n.timescale){f=r.samples[i-1].offset;l=i-1;break}if(t&&n.is_rap){a=n.offset;s=n.cts;u=i}}if(t){r.nextSample=u;o.i("MP4Box","Seeking to RAP sample #"+r.nextSample+" on track "+r.tkhd.track_id+", time "+o.getDurationString(s,c)+" and offset: "+a);return{offset:a,time:s/c}}else{r.nextSample=l;o.i("MP4Box","Seeking to non-RAP sample #"+r.nextSample+" on track "+r.tkhd.track_id+", time "+o.getDurationString(e)+" and offset: "+a);return{offset:f,time:e}}};f.prototype.seek=function(e,t){var r=this.inputIsoFile.moov;var i;var n;var a;var s={offset:Infinity,time:Infinity};if(!this.inputIsoFile.moov){throw"Cannot seek: moov not received!"}else{for(a=0;a<r.traks.length;a++){i=r.traks[a];n=this.seekTrack(e,t,i);if(n.offset<s.offset){s.offset=n.offset}if(n.time<s.time){s.time=n.time}}if(s.offset===Infinity){s={offset:this.inputIsoFile.nextParsePosition,time:0}}else{var f=this.inputIsoFile.findPosition(true,s.offset);if(f!==-1){s.offset=this.inputIsoFile.findEndContiguousBuf(f)}}o.i("MP4Box","Seeking at time "+o.getDurationString(s.time,1)+" needs a buffer with a fileStart position of "+s.offset);return s}}},{"./DataStream":174,"./box":175,"./isofile":177,"./log":178}],180:[function(e,t,r){var i=e("debug")("videostream");var n=e("mp4box");var a=.01;var s=60;t.exports=function(e,t,r){r=r||{};var f=r.debugTrack||-1;var u=[];function l(){t.addEventListener("waiting",x);t.addEventListener("timeupdate",E)}l();var c=false;function p(e){c=true;t.removeEventListener("waiting",x);t.removeEventListener("timeupdate",E);if(h.readyState==="open")h.endOfStream(e)}function d(e){var r=e.buffer.buffered;var n=t.currentTime;var o=-1;for(var f=0;f<r.length;f++){var u=r.start(f);var l=r.end(f)+a;if(u>n){break}else if(o>=0||n<=l){o=l}}var c=o-n;if(c<0)c=0;i("Buffer length: %f",c);return c<=s}var h=new MediaSource;h.addEventListener("sourceopen",function(){w(0)});t.src=window.URL.createObjectURL(h);var m=new n;m.onError=function(e){i("MP4Box error: %s",e.message);if(b){b()}if(h.readyState==="open"){p("decode")}};var v=false;var g={};m.onReady=function(e){i("MP4 info: %o",e);e.tracks.forEach(function(e){var t;if(e.video){t="video/mp4"}else if(e.audio){t="audio/mp4"}else{return}t+='; codecs="'+e.codec+'"';if(MediaSource.isTypeSupported(t)){var r=h.addSourceBuffer(t);var i={buffer:r,arrayBuffers:[],meta:e,ended:false};r.addEventListener("updateend",A.bind(null,i));m.setSegmentOptions(e.id,null,{nbSamples:e.video?1:100});g[e.id]=i}});if(Object.keys(g).length===0){p("decode");return}var t=m.initializeSegmentation();t.forEach(function(e){S(g[e.id],e.buffer);if(e.id===f){o("init-track-"+f+".mp4",[e.buffer]);u.push(e.buffer)}});v=true};m.onSegment=function(e,t,r,i){var n=g[e];S(n,r,i===n.meta.nb_samples);if(e===f&&u){u.push(r);if(i>1e3){o("track-"+f+".mp4",u);u=null}}};var y;var _=null;var b=null;function w(t){if(t===e.length){m.flush();return}if(_&&t===y){var r=_;setTimeout(function(){if(_===r)_.resume()});return}if(_){_.destroy();b()}y=t;var n={start:y,end:e.length-1};_=e.createReadStream(n);function a(e){_.pause();var t=e.toArrayBuffer();t.fileStart=y;y+=t.byteLength;var r;try{r=m.appendBuffer(t)}catch(n){i("MP4Box threw exception: %s",n.message);if(h.readyState==="open"){p("decode")}_.destroy();b();return}w(r)}_.on("data",a);function s(){b();w(y)}_.on("end",s);function o(e){i("Stream error: %s",e.message);if(h.readyState==="open"){p("network")}}_.on("error",o);b=function(){_.removeListener("data",a);_.removeListener("end",s);_.removeListener("error",o);_=null;b=null}}function x(){if(v){k(t.currentTime)}}function k(e){if(c)l();var t=m.seek(e,true);i("Seeking to time: %d",e);i("Seeked file offset: %d",t.offset);w(t.offset)}function S(e,t,r){e.arrayBuffers.push({buffer:t,ended:r||false});A(e)}function E(){Object.keys(g).forEach(function(e){var t=g[e];if(t.blocked){A(t)}})}function A(e){if(e.buffer.updating)return;e.blocked=!d(e);if(e.blocked)return;if(e.arrayBuffers.length===0)return;var t=e.arrayBuffers.shift();var r=false;try{e.buffer.appendBuffer(t.buffer);e.ended=t.ended;r=true}catch(n){i("SourceBuffer error: %s",n.message);p("decode");return}if(r){U()}}function U(){if(h.readyState!=="open"){return}var e=Object.keys(g).every(function(e){var t=g[e];return t.ended&&!t.buffer.updating});if(e){p()}}};function o(e,t){var r=new Blob(t);var i=URL.createObjectURL(r);var n=document.createElement("a");n.setAttribute("href",i);n.setAttribute("download",e);n.click()}},{debug:120,mp4box:179}],181:[function(e,t,r){t.exports=i;function i(){var e={};for(var t=0;t<arguments.length;t++){var r=arguments[t];for(var i in r){if(r.hasOwnProperty(i)){e[i]=r[i]}}}return e}},{}],182:[function(e,t,r){t.exports=i;function i(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var i in r){if(r.hasOwnProperty(i)){e[i]=r[i]}}}return e}},{}],183:[function(e,t,r){t.exports=function i(e,t,r){if(t===undefined){return function(t,r){return i(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+""}},{}],184:[function(e,t,r){t.exports={name:"webtorrent",description:"Streaming torrent client",version:"0.59.0",author:{name:"Feross Aboukhadijeh",email:"feross@feross.org",url:"http://feross.org/"},bin:{webtorrent:"./bin/cmd.js"},browser:{"./lib/server":false,"bittorrent-dht/client":false,"fs-chunk-store":"memory-chunk-store","load-ip-set":false,ut_pex:false},bugs:{url:"https://github.com/feross/webtorrent/issues"},dependencies:{"addr-to-ip-port":"^1.0.1",bitfield:"^1.0.2","bittorrent-dht":"^3.0.0","bittorrent-swarm":"^5.0.0","chunk-store-stream":"^2.0.0",clivas:"^0.2.0","create-torrent":"^3.4.0",debug:"^2.1.0","end-of-stream":"^1.0.0",executable:"^1.1.0","fs-chunk-store":"^1.3.4",hat:"0.0.3","immediate-chunk-store":"^1.0.7",inherits:"^2.0.1",inquirer:"^0.9.0","load-ip-set":"^1.0.3",mediasource:"^1.0.0","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":"^1.0.0","pretty-bytes":"^2.0.1",pump:"^1.0.0","random-iterate":"^1.0.1","range-parser":"^1.0.2","re-emitter":"^1.0.0","run-parallel":"^1.0.0","simple-sha1":"^2.0.0",speedometer:"^0.1.2",thunky:"^0.1.0","torrent-discovery":"^3.0.0","torrent-piece":"^1.0.0",uniq:"^1.0.1",ut_metadata:"^2.1.0",ut_pex:"^1.0.1",videostream:"^1.1.4","windows-no-runnable":"0.0.6",xtend:"^4.0.0","zero-fill":"^2.2.0"},devDependencies:{"bittorrent-tracker":"^6.0.0",brfs:"^1.2.0",browserify:"^11.0.0",finalhandler:"^0.4.0","run-auto":"^1.0.0","serve-static":"^1.9.3","simple-get":"^1.0.0",standard:"^5.1.0",tape:"^4.0.0","uglify-js":"^2.4.15",zelda:"^2.0.0",zuul:"^3.0.0"},homepage:"http://webtorrent.io",keywords:["torrent","bittorrent","bittorrent client","streaming","download","webrtc","webrtc data","webtorrent","mad science"],license:"MIT",main:"index.js",optionalDependencies:{"airplay-js":"^0.2.3","chromecast-js":"^0.1.4",nodebmc:"0.0.5"},repository:{type:"git",url:"git://github.com/feross/webtorrent.git"},scripts:{build:"browserify -s WebTorrent -e ./ | uglifyjs -m > webtorrent.min.js","build-debug":"browserify -s WebTorrent -e ./ > webtorrent.debug.js",size:"npm run build && cat webtorrent.min.js | gzip | wc -c",test:"standard && node ./bin/test.js","test-browser":"zuul -- test/basic.js","test-browser-local":"zuul --local -- test/basic.js","test-node":"tape test/*.js"}}},{}],185:[function(e,t,r){(function(r,i,n){t.exports=w;var a=e("create-torrent");var s=e("debug")("webtorrent");var o=e("bittorrent-dht/client");var f=e("events").EventEmitter;var u=e("xtend");var l=e("hat");var c=e("inherits");var p=e("load-ip-set");var d=e("run-parallel");var h=e("parse-torrent");var m=e("speedometer");var v=e("zero-fill");var g=e("path");var y=e("./lib/torrent");c(w,f);var _=e("./package.json").version;var b=_.match(/([0-9]+)/g).slice(0,2).map(v(2)).join("");function w(e){var t=this;if(!(t instanceof w))return new w(e);if(!e)e={};f.call(t);if(!s.enabled)t.setMaxListeners(0);t.destroyed=false;t.torrentPort=e.torrentPort||0;t.tracker=e.tracker!==undefined?e.tracker:true;t._rtcConfig=e.rtcConfig;t._wrtc=e.wrtc||i.WRTC;t.torrents=[];t.downloadSpeed=m();t.uploadSpeed=m();t.peerId=e.peerId===undefined?new n("-WW"+b+"-"+l(48),"utf8"):typeof e.peerId==="string"?new n(e.peerId,"hex"):e.peerId;t.peerIdHex=t.peerId.toString("hex");t.nodeId=e.nodeId===undefined?new n(l(160),"hex"):typeof e.nodeId==="string"?new n(e.nodeId,"hex"):e.nodeId;t.nodeIdHex=t.nodeId.toString("hex");if(e.dht!==false&&typeof o==="function"){t.dht=new o(u({nodeId:t.nodeId},e.dht));t.dht.listen(e.dhtPort)}s("new webtorrent (peerId %s, nodeId %s)",t.peerIdHex,t.nodeIdHex);if(typeof p==="function"){p(e.blocklist,{headers:{"user-agent":"WebTorrent/"+_+" (http://webtorrent.io)"}},function(e,r){if(e)return t.error("Failed to load blocklist: "+e.message);t.blocked=r;a()})}else r.nextTick(a);function a(){if(t.destroyed)return;t.ready=true;t.emit("ready")}}Object.defineProperty(w.prototype,"ratio",{get:function(){var e=this;var t=e.torrents.reduce(function(e,t){return e+t.uploaded},0);var r=e.torrents.reduce(function(e,t){return e+t.downloaded},0)||1;return t/r}});w.prototype.get=function(e){var t=this;if(e instanceof y)return e;var r;try{r=h(e)}catch(i){}if(!r)return null;if(!r.infoHash)throw new Error("Invalid torrent identifier");for(var n=0,a=t.torrents.length;n<a;n++){var s=t.torrents[n];if(s.infoHash===r.infoHash)return s}return null};w.prototype.add=w.prototype.download=function(e,t,i){var n=this;if(n.destroyed)throw new Error("client is destroyed");if(typeof t==="function")return n.add(e,null,t);s("add");if(!t)t={};t.client=n;var a=n.get(e);function o(){s("on torrent %s",a.infoHash);if(typeof i==="function")i(a)}if(a){if(a.ready)r.nextTick(o);else a.on("ready",o)}else{a=new y(e,t);n.torrents.push(a);a.on("error",function(e){n.emit("error",e,a);n.remove(a)});a.on("listening",function(e){n.emit("listening",e,a)});a.on("ready",function(){o();n.emit("torrent",a)})}return a};w.prototype.seed=function(e,t,r){var i=this;if(i.destroyed)throw new Error("client is destroyed");if(typeof t==="function")return i.seed(e,null,t);s("seed");if(!t)t={};if(typeof e==="string")t.path=g.dirname(e);if(!t.createdBy)t.createdBy="WebTorrent/"+_;var n;var o=i.add(undefined,t,function(e){var t=[function(t){e.load(n,t)}];if(i.dht){t.push(function(t){e.on("dhtAnnounce",t)})}d(t,function(t){if(t)return i.emit("error",t);f();i.emit("seed",e)})});a.parseInput(e,t,function(r,s){if(r)return i.emit("error",r);n=s.map(function(e){return e.getStream});a(e,t,function(e,t){if(e)return i.emit("error",e);if(i.destroyed)return;var r=i.get(t);if(r){o.destroy();f();return}else{o._onTorrentId(t)}})});function f(){s("on seed");if(typeof r==="function")r(o)}return o};w.prototype.remove=function(e,t){var r=this;s("remove");var i=r.get(e);if(!i)throw new Error("No torrent with id "+e);r.torrents.splice(r.torrents.indexOf(i),1);i.destroy(t)};w.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}};w.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)});d(r,e)}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},e("buffer").Buffer)},{"./lib/torrent":7,"./package.json":184,_process:48,"bittorrent-dht/client":38,buffer:39,"create-torrent":90,debug:120,events:43,hat:126,inherits:128,"load-ip-set":38,"parse-torrent":134,path:47,"run-parallel":154,speedometer:165,xtend:181,"zero-fill":183}]},{},[185])(185)});