PageSourceSearch

https://oplayer.vercel.app/_next/static/chunks/64682d3d.189b30b2c95c04af.js

js oplayer.vercel.app collected 2026-10-03 07:27:12 UTC 262,665 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[43],{2661:function(e,t,n){var r;r=function(){var e;return(function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){if(o)return o(s,!0);var u=Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){return i(t[s][1][e]||e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var o=void 0,s=0;s<r.length;s++)i(r[s]);return i})({1:[function(e,t,n){function r(e,t){s.Readable.call(this,t),this.destroyed=!1,this._torrent=e._torrent;var n=t&&t.start||0,r=t&&t.end&&t.end<e.length?t.end:e.length-1,i=e._torrent.pieceLength;this._startPiece=(n+e.offset)/i|0,this._endPiece=(r+e.offset)/i|0,this._piece=this._startPiece,this._offset=n+e.offset-this._startPiece*i,this._missing=r-n+1,this._reading=!1,this._notifying=!1,this._criticalLength=Math.min(1048576/i|0,2)}t.exports=r;var i=e("debug")("webtorrent:file-stream"),o=e("inherits"),s=e("readable-stream");o(r,s.Readable),r.prototype._read=function(){this._reading||(this._reading=!0,this._notify())},r.prototype._notify=function(){var e=this;if(e._reading&&0!==e._missing){if(!e._torrent.bitfield.get(e._piece))return e._torrent.critical(e._piece,e._piece+e._criticalLength);if(!e._notifying){e._notifying=!0;var t=e._piece;e._torrent.store.get(t,function(n,r){if(e._notifying=!1,!e.destroyed){if(n)return e._destroy(n);i("read %s (length %s) (err %s)",t,r.length,n&&n.message),e._offset&&(r=r.slice(e._offset),e._offset=0),e._missing<r.length&&(r=r.slice(0,e._missing)),e._missing-=r.length,i("pushing buffer of length %s",r.length),e._reading=!1,e.push(r),0===e._missing&&e.push(null)}}),e._piece+=1}}},r.prototype.destroy=function(e){this._destroy(null,e)},r.prototype._destroy=function(e,t){this.destroyed||(this.destroyed=!0,this._torrent.destroyed||this._torrent.deselect(this._startPiece,this._endPiece,!0),e&&this.emit("error",e),this.emit("close"),t&&t())}},{debug:30,inherits:41,"readable-stream":82}],2:[function(e,t,n){(function(n){function r(e,t){o.call(this),this._torrent=e,this._destroyed=!1,this.name=t.name,this.path=t.path,this.length=t.length,this.offset=t.offset,this.done=!1;var n=t.offset,r=n+t.length-1;this._startPiece=n/this._torrent.pieceLength|0,this._endPiece=r/this._torrent.pieceLength|0,0===this.length&&(this.done=!0,this.emit("done"))}t.exports=r;var i=e("end-of-stream"),o=e("events").EventEmitter,s=e("./file-stream"),a=e("inherits"),u=e("path"),c=e("render-media"),f=e("readable-stream"),h=e("stream-to-blob"),d=e("stream-to-blob-url"),l=e("stream-with-known-length-to-buffer");a(r,o),Object.defineProperty(r.prototype,"downloaded",{get:function(){if(!this._torrent.bitfield)return 0;for(var e=0,t=this._startPiece;t<=this._endPiece;++t)if(this._torrent.bitfield.get(t))e+=this._torrent.pieceLength;else{var n=this._torrent.pieces[t];e+=n.length-n.missing}return e}}),r.prototype.select=function(e){0!==this.length&&this._torrent.select(this._startPiece,this._endPiece,e)},r.prototype.deselect=function(){0!==this.length&&this._torrent.deselect(this._startPiece,this._endPiece,!1)},r.prototype.createReadStream=function(e){var t=this;if(0===this.length){var r=new f.PassThrough;return n.nextTick(function(){r.end()}),r}var o=new s(t,e);return t._torrent.select(o._startPiece,o._endPiece,!0,function(){o._notify()}),i(o,function(){t._destroyed||t._torrent.destroyed||t._torrent.deselect(o._startPiece,o._endPiece,!0)}),o},r.prototype.getBuffer=function(e){l(this.createReadStream(),this.length,e)},r.prototype.getBlob=function(e){if("undefined"==typeof window)throw Error("browser-only method");h(this.createReadStream(),this._getMimeType(),e)},r.prototype.getBlobURL=function(e){if("undefined"==typeof window)throw Error("browser-only method");d(this.createReadStream(),this._getMimeType(),e)},r.prototype.appendTo=function(e,t,n){if("undefined"==typeof window)throw Error("browser-only method");c.append(this,e,t,n)},r.prototype.renderTo=function(e,t,n){if("undefined"==typeof window)throw Error("browser-only method");c.render(this,e,t,n)},r.prototype._getMimeType=function(){return c.mime[u.extname(this.name).toLowerCase()]},r.prototype._destroy=function(){this._destroyed=!0,this._torrent=null}}).call(this,e("_process"))},{"./file-stream":1,_process:66,"end-of-stream":33,events:34,inherits:41,path:63,"readable-stream":82,"render-media":83,"stream-to-blob":100,"stream-to-blob-url":99,"stream-with-known-length-to-buffer":101}],3:[function(e,t,n){function r(e,t){this.id=e,this.type=t,s("new Peer %s",e),this.addr=null,this.conn=null,this.swarm=null,this.wire=null,this.connected=!1,this.destroyed=!1,this.timeout=null,this.retries=0,this.sentHandshake=!1}function i(){}var o=e("unordered-array-remove"),s=e("debug")("webtorrent:peer"),a=e("bittorrent-protocol"),u=e("./webconn");n.createWebRTCPeer=function(e,t){var n=new r(e.id,"webrtc");return n.conn=e,n.swarm=t,n.conn.connected?n.onConnect():(n.conn.once("connect",function(){n.onConnect()}),n.conn.once("error",function(e){n.destroy(e)}),n.startConnectTimeout()),n},n.createTCPIncomingPeer=function(e){var t=e.remoteAddress+":"+e.remotePort,n=new r(t,"tcpIncoming");return n.conn=e,n.addr=t,n.onConnect(),n},n.createTCPOutgoingPeer=function(e,t){var n=new r(e,"tcpOutgoing");return n.addr=e,n.swarm=t,n},n.createWebSeedPeer=function(e,t){var n=new r(e,"webSeed");return n.swarm=t,n.conn=new u(e,t),n.onConnect(),n},r.prototype.onConnect=function(){var e=this;
1if(!e.destroyed){e.connected=!0,s("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 n=e.wire=new a;n.type=e.type,n.once("end",function(){e.destroy()}),n.once("close",function(){e.destroy()}),n.once("finish",function(){e.destroy()}),n.once("error",function(t){e.destroy(t)}),n.once("handshake",function(t,n){e.onHandshake(t,n)}),e.startHandshakeTimeout(),t.pipe(n).pipe(t),e.swarm&&!e.sentHandshake&&e.handshake()}},r.prototype.onHandshake=function(e,t){if(this.swarm&&!this.destroyed){if(this.swarm.destroyed)return this.destroy(Error("swarm already destroyed"));if(e!==this.swarm.infoHash)return this.destroy(Error("unexpected handshake info hash for this swarm"));if(t===this.swarm.peerId)return this.destroy(Error("refusing to connect to ourselves"));s("Peer %s got handshake %s",this.id,e),clearTimeout(this.handshakeTimeout),this.retries=0;var n=this.addr;!n&&this.conn.remoteAddress&&(n=this.conn.remoteAddress+":"+this.conn.remotePort),this.swarm._onWire(this.wire,n),this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}},r.prototype.handshake=function(){var e={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,e),this.sentHandshake=!0},r.prototype.startConnectTimeout=function(){var e=this;clearTimeout(e.connectTimeout),e.connectTimeout=setTimeout(function(){e.destroy(Error("connect timeout"))},"webrtc"===e.type?25e3:5e3),e.connectTimeout.unref&&e.connectTimeout.unref()},r.prototype.startHandshakeTimeout=function(){var e=this;clearTimeout(e.handshakeTimeout),e.handshakeTimeout=setTimeout(function(){e.destroy(Error("handshake timeout"))},25e3),e.handshakeTimeout.unref&&e.handshakeTimeout.unref()},r.prototype.destroy=function(e){if(!this.destroyed){this.destroyed=!0,this.connected=!1,s("destroy %s (error: %s)",this.id,e&&(e.message||e)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);var t=this.swarm,n=this.conn,r=this.wire;this.swarm=null,this.conn=null,this.wire=null,t&&r&&o(t.wires,t.wires.indexOf(r)),n&&(n.on("error",i),n.destroy()),r&&r.destroy(),t&&t.removePeer(this.id)}}},{"./webconn":6,"bittorrent-protocol":14,debug:30,"unordered-array-remove":111}],4:[function(e,t,n){function r(e){var t=this;t._torrent=e,t._numPieces=e.pieces.length,t._pieces=[],t._onWire=function(e){t.recalculate(),t._initWire(e)},t._onWireHave=function(e){t._pieces[e]+=1},t._onWireBitfield=function(){t.recalculate()},t._torrent.wires.forEach(function(e){t._initWire(e)}),t._torrent.on("wire",t._onWire),t.recalculate()}function i(){return!0}t.exports=r,r.prototype.getRarestPiece=function(e){e||(e=i);for(var t=[],n=1/0,r=0;r<this._numPieces;++r)if(e(r)){var o=this._pieces[r];o===n?t.push(r):o<n&&(t=[r],n=o)}return t.length>0?t[Math.random()*t.length|0]:-1},r.prototype.destroy=function(){var e=this;e._torrent.removeListener("wire",e._onWire),e._torrent.wires.forEach(function(t){e._cleanupWireEvents(t)}),e._torrent=null,e._pieces=null,e._onWire=null,e._onWireHave=null,e._onWireBitfield=null},r.prototype._initWire=function(e){var t=this;e._onClose=function(){t._cleanupWireEvents(e);for(var n=0;n<this._numPieces;++n)t._pieces[n]-=e.peerPieces.get(n)},e.on("have",t._onWireHave),e.on("bitfield",t._onWireBitfield),e.once("close",e._onClose)},r.prototype.recalculate=function(){for(e=0;e<this._numPieces;++e)this._pieces[e]=0;var e,t=this._torrent.wires.length;for(e=0;e<t;++e)for(var n=this._torrent.wires[e],r=0;r<this._numPieces;++r)this._pieces[r]+=n.peerPieces.get(r)},r.prototype._cleanupWireEvents=function(e){e.removeListener("have",this._onWireHave),e.removeListener("bitfield",this._onWireBitfield),e._onClose&&e.removeListener("close",e._onClose),e._onClose=null}},{}],5:[function(e,t,r){(function(n,r){function i(e,t,n){l.call(this),this._debugId="unknown infohash",this.client=t,this.announce=n.announce,this.urlList=n.urlList,this.path=n.path,this._store=n.store||y,this._getAnnounceOpts=n.getAnnounceOpts,this.strategy=n.strategy||"sequential",this.maxWebConns=n.maxWebConns||4,this._rechokeNumSlots=!1===n.uploads||0===n.uploads?0:+n.uploads||10,this._rechokeOptimisticWire=null,this._rechokeOptimisticTime=0,this._rechokeIntervalId=null,this.ready=!1,this.destroyed=!1,this.paused=!1,this.done=!1,this.metadata=null,this.store=null,this.files=[],this.pieces=[],this._amInterested=!1,this._selections=[],this._critical=[],this.wires=[],this._queue=[],this._peers={},this._peersLength=0,this.received=0,this.uploaded=0,this._downloadSpeed=U(),this._uploadSpeed=U(),this._servers=[],this._xsRequests=[],this._fileModtimes=n.fileModtimes,null!==e&&this._onTorrentId(e),this._debug("new torrent")}function o(e,t){return 2+Math.ceil(t*e.downloadSpeed()/C.BLOCK_LENGTH)}function s(){}t.exports=i;var a,u=e("addr-to-ip-port"),c=e("bitfield"),f=e("chunk-store-stream/write"),h=e("debug")("webtorrent:torrent"),d=e("torrent-discovery"),l=e("events").EventEmitter,p=e("xtend"),m=e("xtend/mutable"),g=e("fs"),y=e("fs-chunk-store"),_=e("simple-get"),v=e("immediate-chunk-store"),b=e("inherits"),w=e("multistream"),E=e("net"),k=e("os"),x=e("run-parallel"),S=e("run-parallel-limit"),I=e("parse-torrent"),B=e("path"),C=e("torrent-piece"),A=e("pump"),T=e("random-iterate"),L=e("simple-sha1"),U=e("speedometer"),R=e("uniq"),O=e("ut_metadata"),P=e("ut_pex"),M=e("./file"),j=e("./peer"),H=e("./rarity-map"),N=e("./server"),q=3*C.BLOCK_LENGTH,D=[1e3,5e3,15e3],W="WebTorrent/"+e("../package.json").version+" (https://webtorrent.io)";try{a=B.join(g.statSync("/tmp")&&"/tmp","webtorrent")}catch(e){a=B.join("function"==typeof k.tmpdir?k.tmpdir():"/","webtorrent")}b(i,l),Object.defineProperty(i.prototype,"timeRemaining",{get:function(){return this.done?0:0===this.downloadSpeed?1/0:(this.length-this.downloaded)/this.downloadSpeed*1e3}}),Object.defineProperty(i.prototype,"downloaded",{get:function(){if(!this.bitfield)return 0;for(var e=0,t=0,n=this.pieces.length;t<n;++t)if(this.bitfield.get(t))e+=t===n-1?this.lastPieceLength:this.pieceLength;else{var r=this.pieces[t];e+=r.length-r.missing}return e}}),Object.defineProperty(i.prototype,"downloadSpeed",{get:function(){return this._downloadSpeed()}}),Object.defineProperty(i.prototype,"uploadSpeed",{get:function(){return this._uploadSpeed()}}),Object.defineProperty(i.prototype,"progress",{get:function(){return this.length?this.downloaded/this.length:0}}),Object.defineProperty(i.prototype,"ratio",{get:function(){return this.uploaded/(this.received||1)}}),Object.defineProperty(i.prototype,"numPeers",{get:function(){return this.wires.length}}),Object.defineProperty(i.prototype,"torrentFileBlobURL",{get:function(){if("undefined"==typeof window)throw Error("browser-only property");return this.torrentFile?URL.createObjectURL(new Blob([this.torrentFile],{type:"application/x-bittorrent"})):null}}),Object.defineProperty(i.prototype,"_numQueued",{get:function(){return this._queue.length+(this._peersLength-this._numConns)}}),Object.defineProperty(i.prototype,"_numConns",{get:function(){var e=0;for(var t in this._peers)this._peers[t].connected&&(e+=1);return e}}),Object.defineProperty(i.prototype,"swarm",{get:function(){return console.warn("WebTorrent: `torrent.swarm` is deprecated. Use `torrent` directly instead."),this}}),i.prototype._onTorrentId=function(e){var t,r=this;if(!r.destroyed){try{t=I(e)}catch(e){}t?(r.infoHash=t.infoHash,r._debugId=t.infoHash.toString("hex").substring(0,7),n.nextTick(function(){r.destroyed||r._onParsedTorrent(t)})):I.remote(e,function(e,t){if(!r.destroyed)return e?r._destroy(e):void r._onParsedTorrent(t)})}},i.prototype._onParsedTorrent=function(e){var t=this;
1if(!t.destroyed){if(t._processParsedTorrent(e),!t.infoHash)return t._destroy(Error("Malformed torrent data: No info hash"));t.path||(t.path=B.join(a,t.infoHash)),t._rechokeIntervalId=setInterval(function(){t._rechoke()},1e4),t._rechokeIntervalId.unref&&t._rechokeIntervalId.unref(),t.emit("_infoHash",t.infoHash),t.destroyed||(t.emit("infoHash",t.infoHash),t.destroyed||(t.client.listening?t._onListening():t.client.once("listening",function(){t._onListening()})))}},i.prototype._processParsedTorrent=function(e){this._debugId=e.infoHash.toString("hex").substring(0,7),this.announce&&(e.announce=e.announce.concat(this.announce)),this.client.tracker&&r.WEBTORRENT_ANNOUNCE&&!this.private&&(e.announce=e.announce.concat(r.WEBTORRENT_ANNOUNCE)),this.urlList&&(e.urlList=e.urlList.concat(this.urlList)),R(e.announce),R(e.urlList),m(this,e),this.magnetURI=I.toMagnetURI(e),this.torrentFile=I.toTorrentFile(e)},i.prototype._onListening=function(){var e=this;if(!e.discovery&&!e.destroyed){var t=e.client.tracker;t&&(t=p(e.client.tracker,{getAnnounceOpts:function(){var t={uploaded:e.uploaded,downloaded:e.downloaded,left:Math.max(e.length-e.downloaded,0)};return e.client.tracker.getAnnounceOpts&&m(t,e.client.tracker.getAnnounceOpts()),e._getAnnounceOpts&&m(t,e._getAnnounceOpts()),t}})),e.discovery=new d({infoHash:e.infoHash,announce:e.announce,peerId:e.client.peerId,dht:!e.private&&e.client.dht,tracker:t,port:e.client.torrentPort,userAgent:W}),e.discovery.on("error",function(t){e._destroy(t)}),e.discovery.on("peer",function(t){"string"==typeof t&&e.done||e.addPeer(t)}),e.discovery.on("trackerAnnounce",function(){e.emit("trackerAnnounce"),0===e.numPeers&&e.emit("noPeers","tracker")}),e.discovery.on("dhtAnnounce",function(){e.emit("dhtAnnounce"),0===e.numPeers&&e.emit("noPeers","dht")}),e.discovery.on("warning",function(t){e.emit("warning",t)}),e.info?e._onMetadata(e):e.xs&&e._getMetadataFromServer()}},i.prototype._getMetadataFromServer=function(){var e=this;x((Array.isArray(e.xs)?e.xs:[e.xs]).map(function(t){return function(n){(function(t,n){var r;if(0!==t.indexOf("http://")&&0!==t.indexOf("https://"))return e.emit("warning",Error("skipping non-http xs param: "+t)),n(null);try{r=_.concat({url:t,method:"GET",headers:{"user-agent":W}},function(r,i,o){var s;if(e.destroyed||e.metadata)return n(null);if(r)return e.emit("warning",Error("http error from xs param: "+t)),n(null);if(200!==i.statusCode)return e.emit("warning",Error("non-200 status code "+i.statusCode+" from xs param: "+t)),n(null);try{s=I(o)}catch(e){}return s?s.infoHash!==e.infoHash?(e.emit("warning",Error("got torrent file with incorrect info hash from xs param: "+t)),n(null)):(e._onMetadata(s),void n(null)):(e.emit("warning",Error("got invalid torrent file from xs param: "+t)),n(null))})}catch(r){return e.emit("warning",Error("skipping invalid url xs param: "+t)),n(null)}e._xsRequests.push(r)})(t,n)}}))},i.prototype._onMetadata=function(e){var t,n=this;if(!n.metadata&&!n.destroyed){if(n._debug("got metadata"),n._xsRequests.forEach(function(e){e.abort()}),n._xsRequests=[],e&&e.infoHash)t=e;else try{t=I(e)}catch(e){return n._destroy(e)}n._processParsedTorrent(t),n.metadata=n.torrentFile,n.client.enableWebSeeds&&n.urlList.forEach(function(e){n.addWebSeed(e)}),0!==n.pieces.length&&n.select(0,n.pieces.length-1,!1),n._rarityMap=new H(n),n.store=new v(new n._store(n.pieceLength,{torrent:{infoHash:n.infoHash},files:n.files.map(function(e){return{path:B.join(n.path,e.path),length:e.length,offset:e.offset}}),length:n.length})),n.files=n.files.map(function(e){return new M(n,e)}),n._hashes=n.pieces,n.pieces=n.pieces.map(function(e,t){return new C(t===n.pieces.length-1?n.lastPieceLength:n.pieceLength)}),n._reservations=n.pieces.map(function(){return[]}),n.bitfield=new c(n.pieces.length),n.wires.forEach(function(e){e.ut_metadata&&e.ut_metadata.setMetadata(n.metadata),n._onWireWithMetadata(e)}),n._debug("verifying existing torrent data"),n._fileModtimes&&n._store===y?n.getFileModtimes(function(e,t){if(e)return n._destroy(e);if(n.files.map(function(e,r){return t[r]===n._fileModtimes[r]}).every(function(e){return e})){for(var r=0;r<n.pieces.length;r++)n._markVerified(r);n._onStore()}else n._verifyPieces()}):n._verifyPieces(),n.emit("metadata")}},i.prototype.getFileModtimes=function(e){var t=this,n=[];S(t.files.map(function(e,r){return function(i){g.stat(B.join(t.path,e.path),function(e,t){if(e&&"ENOENT"!==e.code)return i(e);n[r]=t&&t.mtime.getTime(),i(null)})}}),2,function(r){t._debug("done getting file modtimes"),e(r,n)})},i.prototype._verifyPieces=function(){var e=this;S(e.pieces.map(function(t,r){return function(t){if(e.destroyed)return t(Error("torrent is destroyed"));e.store.get(r,function(i,o){return e.destroyed?t(Error("torrent is destroyed")):i?n.nextTick(t,null):void L(o,function(n){if(e.destroyed)return t(Error("torrent is destroyed"));if(n===e._hashes[r]){if(!e.pieces[r])return;e._debug("piece verified %s",r),e._markVerified(r)}else e._debug("piece invalid %s",r);t(null)})})}}),2,function(t){if(t)return e._destroy(t);e._debug("done verifying"),e._onStore()})},i.prototype._markVerified=function(e){this.pieces[e]=null,this._reservations[e]=null,this.bitfield.set(e,!0)},i.prototype._onStore=function(){this.destroyed||(this._debug("on store"),this.ready=!0,this.emit
1("ready"),this._checkDone(),this._updateSelections())},i.prototype.destroy=function(e){this._destroy(null,e)},i.prototype._destroy=function(e,t){var n=this;if(!n.destroyed){for(var r in n.destroyed=!0,n._debug("destroy"),n.client._remove(n),clearInterval(n._rechokeIntervalId),n._xsRequests.forEach(function(e){e.abort()}),n._rarityMap&&n._rarityMap.destroy(),n._peers)n.removePeer(r);n.files.forEach(function(e){e instanceof M&&e._destroy()});var i=n._servers.map(function(e){return function(t){e.destroy(t)}});n.discovery&&i.push(function(e){n.discovery.destroy(e)}),n.store&&i.push(function(e){n.store.close(e)}),x(i,t),e&&(0===n.listenerCount("error")?n.client.emit("error",e):n.emit("error",e)),n.emit("close"),n.client=null,n.files=[],n.discovery=null,n.store=null,n._rarityMap=null,n._peers=null,n._servers=null,n._xsRequests=null}},i.prototype.addPeer=function(e){if(this.destroyed)throw Error("torrent is destroyed");if(!this.infoHash)throw Error("addPeer() must not be called before the `infoHash` event");if(this.client.blocked){if("string"==typeof e){try{n=u(e)}catch(t){return this._debug("ignoring peer: invalid %s",e),this.emit("invalidPeer",e),!1}t=n[0]}else"string"==typeof e.remoteAddress&&(t=e.remoteAddress);if(t&&this.client.blocked.contains(t))return this._debug("ignoring peer: blocked %s",e),"string"!=typeof e&&e.destroy(),this.emit("blockedPeer",e),!1}var t,n,r=!!this._addPeer(e);return r?this.emit("peer",e):this.emit("invalidPeer",e),r},i.prototype._addPeer=function(e){if(this.destroyed)return"string"!=typeof e&&e.destroy(),null;if("string"==typeof e&&!this._validAddr(e))return this._debug("ignoring peer: invalid %s",e),null;var t,n=e&&e.id||e;return this._peers[n]?(this._debug("ignoring peer: duplicate (%s)",n),"string"!=typeof e&&e.destroy(),null):this.paused?(this._debug("ignoring peer: torrent is paused"),"string"!=typeof e&&e.destroy(),null):(this._debug("add peer %s",n),t="string"==typeof e?j.createTCPOutgoingPeer(e,this):j.createWebRTCPeer(e,this),this._peers[t.id]=t,this._peersLength+=1,"string"==typeof e&&(this._queue.push(t),this._drain()),t)},i.prototype.addWebSeed=function(e){if(this.destroyed)throw Error("torrent is destroyed");if(!/^https?:\/\/.+/.test(e))return this.emit("warning",Error("ignoring invalid web seed: "+e)),void this.emit("invalidPeer",e);if(this._peers[e])return this.emit("warning",Error("ignoring duplicate web seed: "+e)),void this.emit("invalidPeer",e);this._debug("add web seed %s",e);var t=j.createWebSeedPeer(e,this);this._peers[t.id]=t,this._peersLength+=1,this.emit("peer",e)},i.prototype._addIncomingPeer=function(e){return this.destroyed?e.destroy(Error("torrent is destroyed")):this.paused?e.destroy(Error("torrent is paused")):(this._debug("add incoming peer %s",e.id),this._peers[e.id]=e,void(this._peersLength+=1))},i.prototype.removePeer=function(e){var t=e&&e.id||e;(e=this._peers[t])&&(this._debug("removePeer %s",t),delete this._peers[t],this._peersLength-=1,e.destroy(),this._drain())},i.prototype.select=function(e,t,n,r){if(this.destroyed)throw Error("torrent is destroyed");if(e<0||t<e||this.pieces.length<=t)throw Error("invalid selection ",e,":",t);n=Number(n)||0,this._debug("select %s-%s (priority %s)",e,t,n),this._selections.push({from:e,to:t,offset:0,priority:n,notify:r||s}),this._selections.sort(function(e,t){return t.priority-e.priority}),this._updateSelections()},i.prototype.deselect=function(e,t,n){if(this.destroyed)throw Error("torrent is destroyed");n=Number(n)||0,this._debug("deselect %s-%s (priority %s)",e,t,n);for(var r=0;r<this._selections.length;++r){var i=this._selections[r];if(i.from===e&&i.to===t&&i.priority===n){this._selections.splice(r,1);break}}this._updateSelections()},i.prototype.critical=function(e,t){if(this.destroyed)throw Error("torrent is destroyed");this._debug("critical %s-%s",e,t);for(var n=e;n<=t;++n)this._critical[n]=!0;this._updateSelections()},i.prototype._onWire=function(e,t){var r=this;if(r._debug("got wire %s (%s)",e._debugId,t||"Unknown"),e.on("download",function(e){r.destroyed||(r.received+=e,r._downloadSpeed(e),r.client._downloadSpeed(e),r.emit("download",e),r.client.emit("download",e))}),e.on("upload",function(e){r.destroyed||(r.uploaded+=e,r._uploadSpeed(e),r.client._uploadSpeed(e),r.emit("upload",e),r.client.emit("upload",e))}),r.wires.push(e),t){var i=u(t);e.remoteAddress=i[0],e.remotePort=i[1]}r.client.dht&&r.client.dht.listening&&e.on("port",function(n){if(!r.destroyed&&!r.client.dht.destroyed){
1if(!e.remoteAddress)return r._debug("ignoring PORT from peer with no address");if(0===n||n>65536)return r._debug("ignoring invalid PORT from peer");r._debug("port: %s (from %s)",n,t),r.client.dht.addNode({host:e.remoteAddress,port:n})}}),e.on("timeout",function(){r._debug("wire timeout (%s)",t),e.destroy()}),e.setTimeout(3e4,!0),e.setKeepAlive(!0),e.use(O(r.metadata)),e.ut_metadata.on("warning",function(e){r._debug("ut_metadata warning: %s",e.message)}),r.metadata||(e.ut_metadata.on("metadata",function(e){r._debug("got metadata via ut_metadata"),r._onMetadata(e)}),e.ut_metadata.fetch()),"function"!=typeof P||r.private||(e.use(P()),e.ut_pex.on("peer",function(e){r.done||(r._debug("ut_pex: got peer: %s (from %s)",e,t),r.addPeer(e))}),e.ut_pex.on("dropped",function(e){var n=r._peers[e];n&&!n.connected&&(r._debug("ut_pex: dropped peer: %s (from %s)",e,t),r.removePeer(e))}),e.once("close",function(){e.ut_pex.reset()})),r.emit("wire",e,t),r.metadata&&n.nextTick(function(){r._onWireWithMetadata(e)})},i.prototype._onWireWithMetadata=function(e){function t(){i.destroyed||e.destroyed||(i._numQueued>2*(i._numConns-i.numPeers)&&e.amInterested?e.destroy():(o=setTimeout(t,5e3)).unref&&o.unref())}function n(){if(e.peerPieces.buffer.length===i.bitfield.buffer.length){for(r=0;r<i.pieces.length;++r)if(!e.peerPieces.get(r))return;e.isSeeder=!0,e.choke()}}var r,i=this,o=null;e.on("bitfield",function(){n(),i._update()}),e.on("have",function(){n(),i._update()}),e.once("interested",function(){e.unchoke()}),e.once("close",function(){clearTimeout(o)}),e.on("choke",function(){clearTimeout(o),(o=setTimeout(t,5e3)).unref&&o.unref()}),e.on("unchoke",function(){clearTimeout(o),i._update()}),e.on("request",function(t,n,r,o){if(r>131072)return e.destroy();i.pieces[t]||i.store.get(t,{offset:n,length:r},o)}),e.bitfield(i.bitfield),e.interested(),e.peerExtensions.dht&&i.client.dht&&i.client.dht.listening&&e.port(i.client.dht.address().port),"webSeed"!==e.type&&(o=setTimeout(t,5e3)).unref&&o.unref(),e.isSeeder=!1,n()},i.prototype._updateSelections=function(){var e=this;e.ready&&!e.destroyed&&(n.nextTick(function(){e._gcSelections()}),e._updateInterest(),e._update())},i.prototype._gcSelections=function(){for(var e=0;e<this._selections.length;++e){for(var t=this._selections[e],n=t.offset;this.bitfield.get(t.from+t.offset)&&t.from+t.offset<t.to;)t.offset+=1;n!==t.offset&&t.notify(),t.to===t.from+t.offset&&this.bitfield.get(t.from+t.offset)&&(this._selections.splice(e,1),e-=1,t.notify(),this._updateInterest())}this._selections.length||this.emit("idle")},i.prototype._updateInterest=function(){var e=this,t=e._amInterested;e._amInterested=!!e._selections.length,e.wires.forEach(function(t){e._amInterested?t.interested():t.uninterested()}),t!==e._amInterested&&(e._amInterested?e.emit("interested"):e.emit("uninterested"))},i.prototype._update=function(){if(!this.destroyed)for(var e,t=T(this.wires);e=t();)this._updateWire(e)},i.prototype._updateWire=function(e){function t(t,n,r,i){return function(o){return o>=t&&o<=n&&!(o in r)&&e.peerPieces.get(o)&&(!i||i(o))}}function n(e){for(var t=e,n=e;n<i._selections.length&&i._selections[n].priority;n++)t=n;var r=i._selections[e];i._selections[e]=i._selections[t],i._selections[t]=r}function r(r){if(e.requests.length>=a)return!0;for(var o=function(){var t=e.downloadSpeed()||1;if(t>q)return function(){return!0};var n=Math.max(1,e.requests.length)*C.BLOCK_LENGTH/t,r=10,o=0;return function(e){if(!r||i.bitfield.get(e))return!0;for(var s=i.pieces[e].missing;o<i.wires.length;o++){var a=i.wires[o],u=a.downloadSpeed();if(!(u<q)&&!(u<=t)&&a.peerPieces.get(e)&&!((s-=u*n)>0))return r--,!1}return!0}}(),s=0;s<i._selections.length;s++){var u,c=i._selections[s];if("rarest"===i.strategy)for(var f=c.from+c.offset,h=c.to,d=h-f+1,l={},p=0,m=t(f,h,l,o);p<d&&!((u=i._rarityMap.getRarestPiece(m))<0);){for(;i._request(e,u,i._critical[u]||r););if(!(e.requests.length<a))return c.priority&&n(s),!0;l[u]=!0,p++}else for(u=c.from+c.offset;u<=c.to;u++)if(e.peerPieces.get(u)&&o(u)){for(;i._request(e,u,i._critical[u]||r););if(!(e.requests.length<a))return c.priority&&n(s),!0}}return!1}var i=this;if(!e.peerChoking){if(!e.downloaded)return function(){if(!e.requests.length)for(var n=i._selections.length;n--;){var r,o=i._selections[n];if("rarest"===i.strategy)for(var s=o.from+o.offset,a=o.to,u=a-s+1,c={},f=0,h=t(s,a,c);f<u&&!((r=i._rarityMap.getRarestPiece(h))<0);){if(i._request(e,r,!1))return;c[r]=!0,f+=1}
1else for(r=o.to;r>=o.from+o.offset;--r)if(e.peerPieces.get(r)&&i._request(e,r,!1))return}}();var s=o(e,.5);if(!(e.requests.length>=s)){var a=o(e,1);r(!1)||r(!0)}}},i.prototype._rechoke=function(){var e=this;if(e.ready){e._rechokeOptimisticTime>0?e._rechokeOptimisticTime-=1:e._rechokeOptimisticWire=null;var t=[];e.wires.forEach(function(n){n.isSeeder||n===e._rechokeOptimisticWire||t.push({wire:n,downloadSpeed:n.downloadSpeed(),uploadSpeed:n.uploadSpeed(),salt:Math.random(),isChoked:!0})}),t.sort(function(e,t){return e.downloadSpeed!==t.downloadSpeed?t.downloadSpeed-e.downloadSpeed:e.uploadSpeed!==t.uploadSpeed?t.uploadSpeed-e.uploadSpeed:e.wire.amChoking!==t.wire.amChoking?e.wire.amChoking?1:-1:e.salt-t.salt});for(var n=0,r=0;r<t.length&&n<e._rechokeNumSlots;++r)t[r].isChoked=!1,t[r].wire.peerInterested&&(n+=1);if(!e._rechokeOptimisticWire&&r<t.length&&e._rechokeNumSlots){var i=t.slice(r).filter(function(e){return e.wire.peerInterested}),o=i[Math.random()*i.length|0];o&&(o.isChoked=!1,e._rechokeOptimisticWire=o.wire,e._rechokeOptimisticTime=2)}t.forEach(function(e){e.wire.amChoking!==e.isChoked&&(e.isChoked?e.wire.choke():e.wire.unchoke())})}},i.prototype._hotswap=function(e,t){var n=e.downloadSpeed();if(n<C.BLOCK_LENGTH||!this._reservations[t])return!1;var r=this._reservations[t];if(!r)return!1;var i,o,s=1/0;for(o=0;o<r.length;o++){var a=r[o];if(a&&a!==e){var u=a.downloadSpeed();u>=q||2*u>n||u>s||(i=a,s=u)}}if(!i)return!1;for(o=0;o<r.length;o++)r[o]===i&&(r[o]=null);for(o=0;o<i.requests.length;o++){var c=i.requests[o];c.piece===t&&this.pieces[t].cancel(c.offset/C.BLOCK_LENGTH|0)}return this.emit("hotswap",i,e,t),!0},i.prototype._request=function(e,t,r){function i(){n.nextTick(function(){a._update()})}var s,a=this,u=e.requests.length,c="webSeed"===e.type;if(a.bitfield.get(t)||u>=(c?Math.min((s=a.pieceLength,1+Math.ceil(1*e.downloadSpeed()/s)),a.maxWebConns):o(e,1)))return!1;var f=a.pieces[t],h=c?f.reserveRemaining():f.reserve();if(-1===h&&r&&a._hotswap(e,t)&&(h=c?f.reserveRemaining():f.reserve()),-1===h)return!1;var d=a._reservations[t];d||(d=a._reservations[t]=[]);var l=d.indexOf(null);-1===l&&(l=d.length),d[l]=e;var p=f.chunkOffset(h),m=c?f.chunkLengthRemaining(h):f.chunkLength(h);return e.request(t,p,m,function n(r,o){if(!a.destroyed){if(!a.ready)return a.once("ready",function(){n(r,o)});if(d[l]===e&&(d[l]=null),f!==a.pieces[t])return i();if(r)return a._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,p,m,e.remoteAddress+":"+e.remotePort,r.message),c?f.cancelRemaining(h):f.cancel(h),void i();if(a._debug("got piece %s (offset: %s length: %s) from %s",t,p,m,e.remoteAddress+":"+e.remotePort),!f.set(h,o,e))return i();var s=f.flush();L(s,function(e){if(!a.destroyed){if(e===a._hashes[t]){if(!a.pieces[t])return;a._debug("piece verified %s",t),a.pieces[t]=null,a._reservations[t]=null,a.bitfield.set(t,!0),a.store.put(t,s),a.wires.forEach(function(e){e.have(t)}),a._checkDone()&&!a.destroyed&&a.discovery.complete()}else a.pieces[t]=new C(f.length),a.emit("warning",Error("Piece "+t+" failed verification"));i()}})}}),!0},i.prototype._checkDone=function(){var e=this;if(!e.destroyed){e.files.forEach(function(t){if(!t.done){for(var n=t._startPiece;n<=t._endPiece;++n)if(!e.bitfield.get(n))return;t.done=!0,t.emit("done"),e._debug("file done: "+t.name)}});for(var t=!0,n=0;n<e._selections.length;n++){for(var r=e._selections[n],i=r.from;i<=r.to;i++)if(!e.bitfield.get(i)){t=!1;break}if(!t)break}return!e.done&&t&&(e.done=!0,e._debug("torrent done: "+e.infoHash),e.emit("done")),e._gcSelections(),t}},i.prototype.load=function(e,t){var n=this;if(n.destroyed)throw Error("torrent is destroyed");if(!n.ready)return n.once("ready",function(){n.load(e,t)});Array.isArray(e)||(e=[e]),t||(t=s),A(new w(e),new f(n.store,n.pieceLength),function(e){if(e)return t(e);n.pieces.forEach(function(e,t){n.pieces[t]=null,n._reservations[t]=null,n.bitfield.set(t,!0)}),n._checkDone(),t(null)})},i.prototype.createServer=function(e){if("function"!=typeof N)throw Error("node.js-only method");if(this.destroyed)throw Error("torrent is destroyed");var t=new N(this,e);return this._servers.push(t),t},i.prototype.pause=function(){this.destroyed||(this._debug("pause"),this.paused=!0)},i.prototype.resume=function(){this.destroyed||(this._debug("resume"),this.paused=!1,this._drain())},i.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this.client._debugId+"] ["+this._debugId+"] "+e[0],h.apply(null,e)},i.prototype._drain=function(){var e=this;if(this._debug("_drain numConns %s maxConns %s",e._numConns,e.client.maxConns),!("function"!=typeof E.connect||e.destroyed||e.paused||e._numConns>=e.client.maxConns)){this._debug("drain (%s queued, %s/%s peers)",e._numQueued,e.numPeers,e.client.maxConns);var t=e._queue.shift();if(t){this._debug("tcp connect attempt to %s",t.addr);var n=u(t.addr),r={host:n[0],port:n[1]},i=t.conn=E.connect(r);i.once("connect",function(){t.onConnect()}),i.once("error",function(e){t.destroy(e)}),t.startConnectTimeout(),i.on("close",function(){if(!e.destroyed){
1if(t.retries>=D.length)return void e._debug("conn %s closed: will not re-add (max %s attempts)",t.addr,D.length);var n=D[t.retries];e._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,n,t.retries+1);var r=setTimeout(function(){var n=e._addPeer(t.addr);n&&(n.retries=t.retries+1)},n);r.unref&&r.unref()}})}}},i.prototype._validAddr=function(e){try{t=u(e)}catch(e){return!1}var t,n=t[0],r=t[1];return r>0&&r<65535&&!("127.0.0.1"===n&&r===this.client.torrentPort)}}).call(this,e("_process"),void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../package.json":122,"./file":2,"./peer":3,"./rarity-map":4,"./server":21,_process:66,"addr-to-ip-port":7,bitfield:13,"chunk-store-stream/write":26,debug:30,events:34,fs:22,"fs-chunk-store":50,"immediate-chunk-store":40,inherits:41,multistream:58,net:21,os:21,"parse-torrent":62,path:63,pump:67,"random-iterate":72,"run-parallel":86,"run-parallel-limit":85,"simple-get":90,"simple-sha1":92,speedometer:94,"torrent-discovery":106,"torrent-piece":107,uniq:110,ut_metadata:114,ut_pex:21,xtend:119,"xtend/mutable":120}],6:[function(e,t,n){function r(e,t){f.call(this),this.url=e,this.webPeerId=c.sync(e),this._torrent=t,this._init()}t.exports=r;var i=e("bitfield"),o=e("safe-buffer").Buffer,s=e("debug")("webtorrent:webconn"),a=e("simple-get"),u=e("inherits"),c=e("simple-sha1"),f=e("bittorrent-protocol"),h=e("../package.json").version;u(r,f),r.prototype._init=function(){var e=this;e.setKeepAlive(!0),e.once("handshake",function(t,n){if(!e.destroyed){e.handshake(t,e.webPeerId);for(var r=e._torrent.pieces.length,o=new i(r),s=0;s<=r;s++)o.set(s,!0);e.bitfield(o)}}),e.once("interested",function(){s("interested"),e.unchoke()}),e.on("uninterested",function(){s("uninterested")}),e.on("choke",function(){s("choke")}),e.on("unchoke",function(){s("unchoke")}),e.on("bitfield",function(){s("bitfield")}),e.on("request",function(t,n,r,i){s("request pieceIndex=%d offset=%d length=%d",t,n,r),e.httpRequest(t,n,r,i)})},r.prototype.httpRequest=function(e,t,n,r){var i,u=this,c=e*u._torrent.pieceLength+t,f=c+n-1,d=u._torrent.files;if(d.length<=1)i=[{url:u.url,start:c,end:f}];else{var l=d.filter(function(e){return e.offset<=f&&e.offset+e.length>c});if(l.length<1)return r(Error("Could not find file corresponnding to web seed range request"));i=l.map(function(e){var t=e.offset+e.length-1;return{url:u.url+("/"===u.url[u.url.length-1]?"":"/")+e.path,fileOffsetInRange:Math.max(e.offset-c,0),start:Math.max(c-e.offset,0),end:Math.min(t,f-e.offset)}})}var p,m=0,g=!1;i.length>
11&&(p=o.alloc(n)),i.forEach(function(o){function u(e,t){if(e.statusCode<200||e.statusCode>=300)return g=!0,r(Error("Unexpected HTTP status code "+e.statusCode));s("Got data of length %d",t.length),1===i.length?r(null,t):(t.copy(p,o.fileOffsetInRange),++m===i.length&&r(null,p))}var c=o.url,f=o.start,d=o.end;s("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",c,e,t,n,f,d);var l={url:c,method:"GET",headers:{"user-agent":"WebTorrent/"+h+" (https://webtorrent.io)",range:"bytes="+f+"-"+d}};a.concat(l,function(e,t,n){if(!g)return e?"undefined"==typeof window||c.startsWith(window.location.origin+"/")?(g=!0,r(e)):a.head(c,function(t,n){if(!g){if(t)return g=!0,r(t);if(n.statusCode<200||n.statusCode>=300)return g=!0,r(Error("Unexpected HTTP status code "+n.statusCode));if(n.url===c)return g=!0,r(e);l.url=n.url,a.concat(l,function(e,t,n){if(!g)return e?(g=!0,r(e)):void u(t,n)})}}):void u(t,n)})})},r.prototype.destroy=function(){f.prototype.destroy.call(this),this._torrent=null}},{"../package.json":122,bitfield:13,"bittorrent-protocol":14,debug:30,inherits:41,"safe-buffer":88,"simple-get":90,"simple-sha1":92}],7:[function(e,t,n){var r=/^\[?([^\]]+)\]?:(\d+)$/,i={},o=0;t.exports=function(e){if(1e5===o&&t.exports.reset(),!i[e]){var n=r.exec(e);if(!n)throw Error("invalid addr: "+e);i[e]=[n[1],Number(n[2])],o+=1}return i[e]},t.exports.reset=function(){i={},o=0}},{}],8:[function(e,t,n){"use strict";function r(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}n.byteLength=function(e){return 3*e.length/4-r(e)},n.toByteArray=function(e){var t,n,i,a,u,c,f=e.length;c=new s(3*f/4-(u=r(e))),i=u>0?f-4:f;var h=0;for(t=0,n=0;t<i;t+=4,n+=3)a=o[e.charCodeAt(t)]<<18|o[e.charCodeAt(t+1)]<<12|o[e.charCodeAt(t+2)]<<6|o[e.charCodeAt(t+3)],c[h++]=a>>16&255,c[h++]=a>>8&255,c[h++]=255&a;return 2===u?(a=o[e.charCodeAt(t)]<<2|o[e.charCodeAt(t+1)]>>4,c[h++]=255&a):1===u&&(a=o[e.charCodeAt(t)]<<10|o[e.charCodeAt(t+1)]<<4|o[e.charCodeAt(t+2)]>>2,c[h++]=a>>8&255,c[h++]=255&a),c},n.fromByteArray=function(e){for(var t,n=e.length,r=n%3,o="",s=[],a=0,u=n-r;a<u;a+=16383)s.push(function(e,t,n){for(var r,o=[],s=t;s<n;s+=3)o.push(i[(r=(e[s]<<16)+(e[s+1]<<8)+e[s+2])>>18&63]+i[r>>12&63]+i[r>>6&63]+i[63&r]);return o.join("")}(e,a,a+16383>u?u:a+16383));return 1===r?o+=i[(t=e[n-1])>>2]+i[t<<4&63]+"==":2===r&&(o+=i[(t=(e[n-2]<<8)+e[n-1])>>10]+i[t>>4&63]+i[t<<2&63]+"="),s.push(o),s.join("")};for(var i=[],o=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,c=a.length;u<c;++u)i[u]=a[u],o[a.charCodeAt(u)]=u;o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},{}],9:[function(e,t,n){(function(e){function n(e,t,n){for(var r=0,i=1,o=t;o<n;o++){var s=e[o];if(s<58&&s>=48)r=10*r+(s-48);else if(o!==t||43!==s){if(o!==t||45!==s){if(46===s)break;throw Error("not a number: buffer["+o+"] = "+s)}i=-1}}return r*i}function r(t,n,i,o){return null==t||0===t.length?null:("number"!=typeof n&&null==o&&(o=n,n=void 0),"number"!=typeof i&&null==o&&(o=i,i=void 0),r.position=0,r.encoding=o||null,r.data=e.isBuffer(t)?t.slice(n,i):new e(t),r.bytes=r.data.length,r.next())}r.bytes=0,r.position=0,r.data=null,r.encoding=null,r.next=function(){switch(r.data[r.position]){case 100:return r.dictionary();case 108:return r.list();case 105:return r.integer();default:return r.buffer()}},r.find=function(e){for(var t=r.position,n=r.data.length,i=r.data;t<n;){if(i[t]===e)return t;t++}throw Error('Invalid data: Missing delimiter "'+String.fromCharCode(e)+'" [0x'+e.toString(16)+"]")},r.dictionary=function(){r.position++;for(var e={};101!==r.data[r.position];)e[r.buffer()]=r.next();return r.position++,e},r.list=function(){r.position++;for(var e=[];101!==r.data[r.position];)e.push(r.next());return r.position++,e},r.integer=function(){var e=r.find(101),t=n(r.data,r.position+1,e);return r.position+=e+1-r.position,t},r.buffer=function(){var e=r.find(58),t=n(r.data,r.position,e),i=++e+t;return r.position=i,r.encoding?r.data.toString(r.encoding,e,i):r.data.slice(e,i)},t.exports=r}).call(this,e("buffer").Buffer)},{buffer:24}],10:[function(e,t,n){(function(e){function n(t,r,i){var o=[],s=null;return n._encode(o,t),s=e.concat(o),n.bytes=s.length,e.isBuffer(r)?(s.copy(r,i),r):s}n.bytes=-1,n._floatConversionDetected=!1,n._encode=function(t,r){if(e.isBuffer(r))return t.push(new e(r.length+":")),void t.push(r);if(null!=r)switch(typeof r){case"string":n.buffer(t,r);break;case"number":n.number(t,r);break;case"object":r.constructor===Array?n.list(t,r):n.dict(t,r);break;case"boolean":n.number(t,r?1:0)}};var r=new e("e"),i=new e("d"),o=new e("l");n.buffer=function(t,n){t.push(new e(e.byteLength(n)+":"+n))}
1,n.number=function(t,r){var i=2147483648*(r/2147483648<<0)+(r%2147483648<<0);t.push(new e("i"+i+"e")),i===r||n._floatConversionDetected||(n._floatConversionDetected=!0,console.warn('WARNING: Possible data corruption detected with value "'+r+'":','Bencoding only defines support for integers, value was converted to "'+i+'"'),console.trace())},n.dict=function(e,t){e.push(i);for(var o,s=0,a=Object.keys(t).sort(),u=a.length;s<u;s++)null!=t[o=a[s]]&&(n.buffer(e,o),n._encode(e,t[o]));e.push(r)},n.list=function(e,t){var i=0,s=t.length;for(e.push(o);i<s;i++)null!=t[i]&&n._encode(e,t[i]);e.push(r)},t.exports=n}).call(this,e("buffer").Buffer)},{buffer:24}],11:[function(e,t,n){var r=t.exports;r.encode=e("./encode"),r.decode=e("./decode"),r.byteLength=r.encodingLength=function(e){return r.encode(e).length}},{"./decode":9,"./encode":10}],12:[function(e,t,n){t.exports=function(e,t,n,r,i){var o,s;if(void 0===r)r=0;else if((r|=0)<0||r>=e.length)throw RangeError("invalid lower bound");if(void 0===i)i=e.length-1;else if((i|=0)<r||i>=e.length)throw RangeError("invalid upper bound");for(;r<=i;)if((s=+n(e[o=r+(i-r>>1)],t,o,e))<0)r=o+1;else{if(!(s>0))return o;i=o-1}return~r}},{}],13:[function(e,t,n){(function(e){function n(e,t){if(!(this instanceof n))return new n(e,t);0==arguments.length&&(e=0),this.grow=t&&(isFinite(t.grow)&&r(t.grow)||t.grow)||0,"number"!=typeof e&&void 0!==e||(e=new i(r(e))).fill&&!e._isBuffer&&e.fill(0),this.buffer=e}function r(e){var t=e>>3;return e%8!=0&&t++,t}var i=void 0!==e?e:"undefined"!=typeof Int8Array?Int8Array:function(e){for(var t=Array(e),n=0;n<e;n++)t[n]=0};n.prototype.get=function(e){var t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)},n.prototype.set=function(e,t){var n=e>>3;t||1==arguments.length?(this.buffer.length<n+1&&this._grow(Math.max(n+1,Math.min(2*this.buffer.length,this.grow))),this.buffer[n]|=128>>e%8):n<this.buffer.length&&(this.buffer[n]&=~(128>>e%8))},n.prototype._grow=function(e){if(this.buffer.length<e&&e<=this.grow){var t=new i(e);if(t.fill&&t.fill(0),this.buffer.copy)this.buffer.copy(t,0);else for(var n=0;n<this.buffer.length;n++)t[n]=this.buffer[n];this.buffer=t}},void 0!==t&&(t.exports=n)}).call(this,e("buffer").Buffer)},{buffer:24}],14:[function(e,t,n){function r(e,t,n,r){this.piece=e,this.offset=t,this.length=n,this.callback=r}function i(){if(!(this instanceof i))return new i;m.Duplex.call(this),this._debugId=l(4).toString("hex"),this._debug("new wire"),this.peerId=null,this.peerIdBuffer=null,this.type=null,this.amChoking=!0,this.amInterested=!1,this.peerChoking=!0,this.peerInterested=!1,this.peerPieces=new u(0,{grow:g}),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=p(),this.downloadSpeed=p(),this._keepAliveInterval=null,this._timeout=null,this._timeoutMs=0,this.destroyed=!1,this._finished=!1,this._parserSize=0,this._parser=null,this._buffer=[],this._bufferSize=0,this.on("finish",this._onFinish),this._parseHandshake()}function o(e,t,n,r){for(var i=0;i<e.length;i++){var o=e[i];if(o.piece===t&&o.offset===n&&o.length===r)return s(e,i),o}return null}t.exports=i;var s=e("unordered-array-remove"),a=e("bencode"),u=e("bitfield"),c=e("safe-buffer").Buffer,f=e("debug")("bittorrent-protocol"),h=e("xtend"),d=e("inherits"),l=e("randombytes"),p=e("speedometer"),m=e("readable-stream"),g=4e5,y=c.from("\x13BitTorrent protocol"),_=c.from([0,0,0,0]),v=c.from([0,0,0,1,0]),b=c.from([0,0,0,1,1]),w=c.from([0,0,0,1,2]),E=c.from([0,0,0,1,3]),k=[0,0,0,0,0,0,0,0],x=[0,0,0,3,9,0,0];d(i,m.Duplex),i.prototype.setKeepAlive=function(e){var t=this;t._debug("setKeepAlive %s",e),clearInterval(t._keepAliveInterval),!1!==e&&(t._keepAliveInterval=setInterval(function(){t.keepAlive()},55e3))},i.prototype.setTimeout=function(e,t){this._debug("setTimeout ms=%d unref=%s",e,t),this._clearTimeout(),this._timeoutMs=e,this._timeoutUnref=!!t,this._updateTimeout()},i.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this._debug("destroy"),this.emit
1("close"),this.end())},i.prototype.end=function(){this._debug("end"),this._onUninterested(),this._onChoke(),m.Duplex.prototype.end.apply(this,arguments)},i.prototype.use=function(e){function t(){}var n=e.prototype.name;if(!n)throw Error('Extension class requires a "name" property on the prototype');this._debug("use extension.name=%s",n);var r=this._nextExt,i=new e(this);"function"!=typeof i.onHandshake&&(i.onHandshake=t),"function"!=typeof i.onExtendedHandshake&&(i.onExtendedHandshake=t),"function"!=typeof i.onMessage&&(i.onMessage=t),this.extendedMapping[r]=n,this._ext[n]=i,this[n]=i,this._nextExt+=1},i.prototype.keepAlive=function(){this._debug("keep-alive"),this._push(_)},i.prototype.handshake=function(e,t,n){if("string"==typeof e?r=c.from(e,"hex"):e=(r=e).toString("hex"),"string"==typeof t?i=c.from(t,"hex"):t=(i=t).toString("hex"),20!==r.length||20!==i.length)throw Error("infoHash and peerId MUST have length 20");this._debug("handshake i=%s p=%s exts=%o",e,t,n);var r,i,o=c.from(k);o[5]|=16,n&&n.dht&&(o[7]|=1),this._push(c.concat([y,o,r,i])),this._handshakeSent=!0,this.peerExtensions.extended&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()},i.prototype._sendExtendedHandshake=function(){var e=h(this.extendedHandshake);for(var t in e.m={},this.extendedMapping){var n=this.extendedMapping[t];e.m[n]=Number(t)}this.extended(0,a.encode(e)),this._extendedHandshakeSent=!0},i.prototype.choke=function(){if(!this.amChoking){for(this.amChoking=!0,this._debug("choke");this.peerRequests.length;)this.peerRequests.pop();this._push(v)}},i.prototype.unchoke=function(){this.amChoking&&(this.amChoking=!1,this._debug("unchoke"),this._push(b))},i.prototype.interested=function(){this.amInterested||(this.amInterested=!0,this._debug("interested"),this._push(w))},i.prototype.uninterested=function(){this.amInterested&&(this.amInterested=!1,this._debug("uninterested"),this._push(E))},i.prototype.have=function(e){this._debug("have %d",e),this._message(4,[e],null)},i.prototype.bitfield=function(e){this._debug("bitfield"),c.isBuffer(e)||(e=e.buffer),this._message(5,[],e)},i.prototype.request=function(e,t,n,i){return i||(i=function(){}),this._finished?i(Error("wire is closed")):this.peerChoking?i(Error("peer is choking")):(this._debug("request index=%d offset=%d length=%d",e,t,n),this.requests.push(new r(e,t,n,i)),this._updateTimeout(),void this._message(6,[e,t,n],null))},i.prototype.piece=function(e,t,n){this._debug("piece index=%d offset=%d",e,t),this.uploaded+=n.length,this.uploadSpeed(n.length),this.emit("upload",n.length),this._message(7,[e,t],n)},i.prototype.cancel=function(e,t,n){this._debug("cancel index=%d offset=%d length=%d",e,t,n),this._callback(o(this.requests,e,t,n),Error("request was cancelled"),null),this._message(8,[e,t,n],null)},i.prototype.port=function(e){this._debug("port %d",e);var t=c.from(x);t.writeUInt16BE(e,5),this._push(t)},i.prototype.extended=function(e,t){if(this._debug("extended ext=%s",e),"string"==typeof e&&this.peerExtendedMapping[e]&&(e=this.peerExtendedMapping[e]),"number"!=typeof e)throw Error("Unrecognized extension: "+e);var n=c.from([e]),r=c.isBuffer(t)?t:a.encode(t);this._message(20,[],c.concat([n,r]))},i.prototype._read=function(){},i.prototype._message=function(e,t,n){var r=n?n.length:0,i=c.allocUnsafe(5+4*t.length);i.writeUInt32BE(i.length+r-4,0),i[4]=e;for(var o=0;o<t.length;o++)i.writeUInt32BE(t[o],5+4*o);this._push(i),n&&this._push(n)},i.prototype._push=function(e){if(!this._finished)return this.push(e)},i.prototype._onKeepAlive=function(){this._debug("got keep-alive"),this.emit("keep-alive")},i.prototype._onHandshake=function(e,t,n){var r,i=e.toString("hex"),o=t.toString("hex");for(r in this._debug("got handshake i=%s p=%s exts=%o",i,o,n),this.peerId=o,this.peerIdBuffer=t,this.peerExtensions=n,this.emit("handshake",i,o,n),this._ext)this._ext[r].onHandshake(i,o,n);n.extended&&this._handshakeSent&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()},i.prototype._onChoke=function(){for(this.peerChoking=!0,this._debug("got choke"),this.emit("choke");this.requests.length;)this._callback(this.requests.pop(),Error("peer is choking"),null)},i.prototype._onUnchoke=function(){this.peerChoking=!1,this._debug("got unchoke"),this.emit
1("unchoke")},i.prototype._onInterested=function(){this.peerInterested=!0,this._debug("got interested"),this.emit("interested")},i.prototype._onUninterested=function(){this.peerInterested=!1,this._debug("got uninterested"),this.emit("uninterested")},i.prototype._onHave=function(e){this.peerPieces.get(e)||(this._debug("got have %d",e),this.peerPieces.set(e,!0),this.emit("have",e))},i.prototype._onBitField=function(e){this.peerPieces=new u(e),this._debug("got bitfield"),this.emit("bitfield",this.peerPieces)},i.prototype._onRequest=function(e,t,n){var i=this;if(!i.amChoking){i._debug("got request index=%d offset=%d length=%d",e,t,n);var s=function(r,s){if(a===o(i.peerRequests,e,t,n))return r?i._debug("error satisfying request index=%d offset=%d length=%d (%s)",e,t,n,r.message):void i.piece(e,t,s)},a=new r(e,t,n,s);i.peerRequests.push(a),i.emit("request",e,t,n,s)}},i.prototype._onPiece=function(e,t,n){this._debug("got piece index=%d offset=%d",e,t),this._callback(o(this.requests,e,t,n.length),null,n),this.downloaded+=n.length,this.downloadSpeed(n.length),this.emit("download",n.length),this.emit("piece",e,t,n)},i.prototype._onCancel=function(e,t,n){this._debug("got cancel index=%d offset=%d length=%d",e,t,n),o(this.peerRequests,e,t,n),this.emit("cancel",e,t,n)},i.prototype._onPort=function(e){this._debug("got port %d",e),this.emit("port",e)},i.prototype._onExtended=function(e,t){if(0===e){var n,r;try{n=a.decode(t)}catch(e){this._debug("ignoring invalid extended handshake: %s",e.message||e)}if(n){if(this.peerExtendedHandshake=n,"object"==typeof n.m)for(r in n.m)this.peerExtendedMapping[r]=Number(n.m[r].toString());for(r in this._ext)this.peerExtendedMapping[r]&&this._ext[r].onExtendedHandshake(this.peerExtendedHandshake);this._debug("got extended handshake"),this.emit("extended","handshake",this.peerExtendedHandshake)}}else this.extendedMapping[e]&&(e=this.extendedMapping[e],this._ext[e]&&this._ext[e].onMessage(t)),this._debug("got extended message ext=%s",e),this.emit("extended",e,t)}
1,i.prototype._onTimeout=function(){this._debug("request timed out"),this._callback(this.requests.shift(),Error("request has timed out"),null),this.emit("timeout")},i.prototype._write=function(e,t,n){for(this._bufferSize+=e.length,this._buffer.push(e);this._bufferSize>=this._parserSize;){var r=1===this._buffer.length?this._buffer[0]:c.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[r.slice(this._parserSize)]:[],this._parser(r.slice(0,this._parserSize))}n(null)},i.prototype._callback=function(e,t,n){e&&(this._clearTimeout(),this.peerChoking||this._finished||this._updateTimeout(),e.callback(t,n))},i.prototype._clearTimeout=function(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)},i.prototype._updateTimeout=function(){var e=this;e._timeoutMs&&e.requests.length&&!e._timeout&&(e._timeout=setTimeout(function(){e._onTimeout()},e._timeoutMs),e._timeoutUnref&&e._timeout.unref&&e._timeout.unref())},i.prototype._parse=function(e,t){this._parserSize=e,this._parser=t},i.prototype._onMessageLength=function(e){var t=e.readUInt32BE(0);t>0?this._parse(t,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))},i.prototype._onMessage=function(e){switch(this._parse(4,this._onMessageLength),e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this._debug("got unknown message"),this.emit("unknownmessage",e)}},i.prototype._parseHandshake=function(){var e=this;e._parse(1,function(t){var n=t.readUInt8(0);e._parse(n+48,function(t){var r=t.slice(0,n);if("BitTorrent protocol"!==r.toString())return e._debug("Error: wire not speaking BitTorrent protocol (%s)",r.toString()),void e.end();t=t.slice(n),e._onHandshake(t.slice(8,28),t.slice(28,48),{dht:!!(1&t[7]),extended:!!(16&t[5])}),e._parse(4,e._onMessageLength)})})},i.prototype._onFinish=function(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,function(){});this.peerRequests.length;)this.peerRequests.pop();for(;this.requests.length;)this._callback(this.requests.pop(),Error("wire was closed"),null)},i.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._debugId+"] "+e[0],f.apply(null,e)}},{bencode:11,bitfield:13,debug:30,inherits:41,randombytes:73,"readable-stream":82,"safe-buffer":88,speedometer:94,"unordered-array-remove":111,xtend:119}],15:[function(e,t,n){(function(n){function r(e){function t(e){n.nextTick(function(){a.emit("warning",e)})}var a=this;if(!(a instanceof r))return new r(e);if(s.call(a),e||(e={}),!e.peerId)throw Error("Option `peerId` is required");if(!e.infoHash)throw Error("Option `infoHash` is required");if(!e.announce)throw Error("Option `announce` is required");if(!n.browser&&!e.port)throw Error("Option `port` is required");a.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),a._peerIdBuffer=i.from(a.peerId,"hex"),a._peerIdBinary=a._peerIdBuffer.toString("binary"),a.infoHash="string"==typeof e.infoHash?e.infoHash:e.infoHash.toString("hex"),a._infoHashBuffer=i.from(a.infoHash,"hex"),a._infoHashBinary=a._infoHashBuffer.toString("binary"),o("new client %s",a.infoHash),a.destroyed=!1,a._port=e.port,a._getAnnounceOpts=e.getAnnounceOpts,a._rtcConfig=e.rtcConfig,a._userAgent=e.userAgent,a._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc;var u="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;u=d(u=u.map(function(e){return"/"===(e=e.toString())[e.length-1]&&(e=e.substring(0,e.length-1)),e}));var c=!1!==a._wrtc&&(!!a._wrtc||h.WEBRTC_SUPPORT);a._trackers=u.map(function(e){var n=l.parse(e).protocol;return"http:"!==n&&"https:"!==n||"function"!=typeof m?"udp:"===n&&"function"==typeof g?new g(a,e):("ws:"===n||"wss:"===n)&&c?"ws:"===n&&"undefined"!=typeof window&&"https:"===window.location.protocol?(t(Error("Unsupported tracker protocol: "+e)),null):new y(a,e):(t(Error("Unsupported tracker protocol: "+e)),null):new m(a,e)}
1).filter(Boolean)}t.exports=r;var i=e("safe-buffer").Buffer,o=e("debug")("bittorrent-tracker:client"),s=e("events").EventEmitter,a=e("xtend"),u=e("inherits"),c=e("once"),f=e("run-parallel"),h=e("simple-peer"),d=e("uniq"),l=e("url"),p=e("./lib/common"),m=e("./lib/client/http-tracker"),g=e("./lib/client/udp-tracker"),y=e("./lib/client/websocket-tracker");u(r,s),r.scrape=function(e,t){if(t=c(t),!e.infoHash)throw Error("Option `infoHash` is required");if(!e.announce)throw Error("Option `announce` is required");var n=new r(a(e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:i.from("01234567890123456789"),port:6881}));n.once("error",t),n.once("warning",t);var o=Array.isArray(e.infoHash)?e.infoHash.length:1,s={};return n.on("scrape",function(e){if(o-=1,s[e.infoHash]=e,0===o){n.destroy();var r=Object.keys(s);1===r.length?t(null,s[r[0]]):t(null,s)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(function(e){return i.from(e,"hex")}):i.from(e.infoHash,"hex"),n.scrape({infoHash:e.infoHash}),n},r.prototype.start=function(e){o("send `start`"),(e=this._defaultAnnounceOpts(e)).event="started",this._announce(e),this._trackers.forEach(function(e){e.setInterval()})},r.prototype.stop=function(e){o("send `stop`"),(e=this._defaultAnnounceOpts(e)).event="stopped",this._announce(e)},r.prototype.complete=function(e){o("send `complete`"),e||(e={}),(e=this._defaultAnnounceOpts(e)).event="completed",this._announce(e)},r.prototype.update=function(e){o("send `update`"),(e=this._defaultAnnounceOpts(e)).event&&delete e.event,this._announce(e)},r.prototype._announce=function(e){this._trackers.forEach(function(t){t.announce(e)})},r.prototype.scrape=function(e){o("send `scrape`"),e||(e={}),this._trackers.forEach(function(t){t.scrape(e)})},r.prototype.setInterval=function(e){o("setInterval %d",e),this._trackers.forEach(function(t){t.setInterval(e)})},r.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,o("destroy"),f(this._trackers.map(function(e){return function(t){e.destroy(t)}}),e),this._trackers=[],this._getAnnounceOpts=null)},r.prototype._defaultAnnounceOpts=function(e){return e||(e={}),null==e.numwant&&(e.numwant=p.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=a(e,this._getAnnounceOpts())),e}}).call(this,e("_process"))},{"./lib/client/http-tracker":21,"./lib/client/udp-tracker":21,"./lib/client/websocket-tracker":17,"./lib/common":18,_process:66,debug:30,events:34,inherits:41,once:60,"run-parallel":86,"safe-buffer":88,"simple-peer":91,uniq:110,url:112,xtend:119}],16:[function(e,t,n){function r(e,t){i.call(this),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}t.exports=r;var i=e("events").EventEmitter;e("inherits")(r,i),r.prototype.setInterval=function(e){var t=this;null==e&&(e=t.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(t.interval),e&&(t.interval=setInterval(function(){t.announce(t.client._defaultAnnounceOpts())},e),t.interval.unref&&t.interval.unref())}},{events:34,inherits:41}],17:[function(e,t,n){function r(e,t,n){d.call(this,e,t),o("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}function i(){}t.exports=r;var o=e("debug")("bittorrent-tracker:websocket-tracker"),s=e("xtend"),a=e("inherits"),u=e("simple-peer"),c=e("randombytes"),f=e("simple-websocket"),h=e("../common"),d=e("./tracker"),l={};a(r,d),r.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,r.prototype.announce=function(e){var t=this;if(!t.destroyed&&!t.reconnecting){if(!t.socket.connected)return void t.socket.once("connect",function(){t.announce(e)});var n=s(e,{action:"announce",info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary});if(t._trackerId&&(n.trackerid=t._trackerId),"stopped"===e.event||"completed"===e.event)t._send(n);else{var r=Math.min(e.numwant,10);t._generateOffers(r,function(e){n.numwant=r,n.offers=e,t._send(n)})}}},r.prototype.scrape=function(e){var t=this;if(!t.destroyed&&!t.reconnecting){if(!t.socket.connected)return void t.s
1ocket.once("connect",function(){t.scrape(e)});var n=Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map(function(e){return e.toString("binary")}):e.infoHash&&e.infoHash.toString("binary")||t.client._infoHashBinary;t._send({action:"scrape",info_hash:n})}},r.prototype.destroy=function(e){function t(){s&&(clearTimeout(s),s=null),o.removeListener("data",t),o.destroy(),o=null}if(e||(e=i),this.destroyed)return e(null);for(var n in this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer),this.peers){var r=this.peers[n];clearTimeout(r.trackerTimeout),r.destroy()}if(this.peers=null,this.socket&&(this.socket.removeListener("connect",this._onSocketConnectBound),this.socket.removeListener("data",this._onSocketDataBound),this.socket.removeListener("close",this._onSocketCloseBound),this.socket.removeListener("error",this._onSocketErrorBound),this.socket=null),this._onSocketConnectBound=null,this._onSocketErrorBound=null,this._onSocketDataBound=null,this._onSocketCloseBound=null,l[this.announceUrl]&&(l[this.announceUrl].consumers-=1),l[this.announceUrl].consumers>0)return e();var o=l[this.announceUrl];if(delete l[this.announceUrl],o.on("error",i),o.once("close",e),!this.expectingResponse)return t();var s=setTimeout(t,h.DESTROY_TIMEOUT);o.once("data",t)},r.prototype._openSocket=function(){var e=this;e.destroyed=!1,e.peers||(e.peers={}),e._onSocketConnectBound=function(){e._onSocketConnect()},e._onSocketErrorBound=function(t){e._onSocketError(t)},e._onSocketDataBound=function(t){e._onSocketData(t)},e._onSocketCloseBound=function(){e._onSocketClose()},e.socket=l[e.announceUrl],e.socket?l[e.announceUrl].consumers+=1:(e.socket=l[e.announceUrl]=new f(e.announceUrl),e.socket.consumers=1,e.socket.once("connect",e._onSocketConnectBound)),e.socket.on("data",e._onSocketDataBound),e.socket.once("close",e._onSocketCloseBound),e.socket.once("error",e._onSocketErrorBound)},r.prototype._onSocketConnect=function(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))},r.prototype._onSocketData=function(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void this.client.emit("warning",Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(Error("invalid action in WS response: "+e.action))}},r.prototype._onAnnounceResponse=function(e){var t=this;if(e.info_hash!==t.client._infoHashBinary)return void o("ignoring websocket data from %s for %s (looking for %s: reused socket)",t.announceUrl,h.binaryToHex(e.info_hash),t.client.infoHash);if(!e.peer_id||e.peer_id!==t.client._peerIdBinary){o("received %s from %s for %s",JSON.stringify(e),t.announceUrl,t.client.infoHash);var n,r=e["failure reason"];if(r)return t.client.emit("warning",Error(r));var i=e["warning message"];i&&t.client.emit("warning",Error(i));var s=e.interval||e["min interval"];s&&t.setInterval(1e3*s);var a=e["tracker id"];if(a&&(t._trackerId=a),null!=e.complete){var u=Object.assign({},e,{announce:t.announceUrl,infoHash:h.binaryToHex(e.info_hash)});t.client.emit("update",u)}if(e.offer&&e.peer_id&&(o("creating peer (from remote offer)"),(n=t._createPeer()).id=h.binaryToHex(e.peer_id),n.once("signal",function(n){var r={action:"announce",info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:n,offer_id:e.offer_id};t._trackerId&&(r.trackerid=t._trackerId),t._send(r)}),n.signal(e.offer),t.client.emit("peer",n)),e.answer&&e.peer_id){var c=h.binaryToHex(e.offer_id);(n=t.peers[c])?(n.id=h.binaryToHex(e.peer_id),n.signal(e.answer),t.client.emit("peer",n),clearTimeout(n.trackerTimeout),n.trackerTimeout=null,delete t.peers[c]):o("got unexpected answer: "+JSON.stringify(e.answer))}}},r.prototype._onScrapeResponse=function(e){var t=this,n=Object.keys(e=e.files||{});if(0===n.length)return void t.client.emit("warning",Error("invalid scrape response"));n.forEach(function(n){var r=Object.assign(e[n],{announce:t.announceUrl,infoHash:h.binaryToHex(n)});t.client.emit("scrape",r)})},r.prototype._onSocketClose=function(){this.destroyed||(this.destroy(),this._startReconnectTimer())},r.prototype._onSocketError=function(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())},r.prototype._startReconnectTimer=function(){var e=this,t=Math.floor(3e4*Math.random())+Math.min(15e3*Math.pow(2,e.retries),18e5);e.reconnecting=!0,clearTimeout(e.reconnectTimer),e.reconnectTimer=setTimeout(function(){e.retries++,e._openSocket()},t),e.reconnectTimer.unref&&e.reconnectTimer.unref(),o("reconnecting socket in %s ms",t)},r.prototype._send=function(e){if(!this.destroyed){this.expectingResponse=!0;var t=JSON.stringify(e);o("send %s",t),this.socket.send(t)}},r.prototype._generateOffers=function(e,t){function n(){i.length===e&&(o("generated %s offers",e),t(i))}var r=this,i=[];o("generating %s offers",e);for(var s=0;s<e;++s)!function(){var e=c(20).toString("hex");o("creating peer (from _generateOffers)");var t=r.peers[e]=r._createPeer({initiator:!0});t.once("signal",function(t){i.push({offer:t,offer_id:h.hexToBinary(e)}),n()}),t.trackerTimeout=setTimeout(function(){o("tracker timeout: destroying peer"),t.trackerTimeout=null,delete r.peers[e],t.destroy()},5e4),t.trackerTimeout.unref&&t.trackerTimeout.unref()}();n()},r.prototype._createPeer=function(e){function t(e){n.client.emit("warning",Error("Connection error: "+e.message)),r.destroy()}var n=this,r=new u(e=Object.assign({trickle:!1,config:n.client._rtcConfig,wrtc:n.client._wrtc},e));return r.once("error",t),r.once("connect",function e(){r.removeListener("error",t),r.removeListener("connect",e)}),r}},{"../common":18,"./tracker":16,debug:30,inherits:41,randombytes:73,"simple-peer":91,"simple-websocket":93,xtend:119}],18:[function(e,t,n){var r=e("safe-buffer").Buffer,i=e("xtend/mutable");n.DEFAULT_ANNOUNCE_PEERS=50,n.MAX_ANNOUNCE_PEERS=82,n.binaryToHex=function(e){return"string"!=typeof e&&(e=String(e)),r.from(e,"binary").toString("hex")},n.hexToBinary=function(e){return"string"!=typeof e&&(e=String(e)),r.from(e,"hex").toString("binary")},i(n,e("./common-node"))},{"./common-node":21,"safe-buffer":88,"xtend/mutable":120}],19:[function(e,t,n){(function(e){t.exports=function(t,n){if("undefined"==typeof Blob||!(t instanceof Blob))throw Error("first argument must be a Blob");if("function"!=typeof n)throw Error("second argument must be a function");var r=new FileReader;r.addEventListener("loadend",function t(i){r.removeEventListener("loadend",t,!1),i.error?n(i.error):n(null,new e(r.result))},!1),r.readAsArrayBuffer(t)}}).call(this,e("buffer").Buffer)},{buffer:24}],20:[function(e,t,n){(function(n){function r(e,t){if(!(this instanceof r))return new r(e,t);o.call(this),t||(t={}),"object"==typeof e&&(e=(t=e).size),this.size=e||512,t.nopad?this._zeroPadding=!1:this._zeroPadding=s(t.zeroPadding,!0),this._buffered=[],this._bufferedBytes=0}var i=e("inherits"),o=e("readable-stream").Transform,s=e("defined");t.exports=r,i(r,o),r.prototype._transform=function(e,t,r){for(this._bufferedBytes+=e.length,this._buffered.push(e);this._bufferedBytes>=this.size;){var i=n.concat(this._buffered);this._bufferedBytes-=this.size,this.push(i.slice(0,this.size)),this._buffered=[i.slice(this.size,i.length)]}r()},r.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new n(this.size-this._bufferedBytes);e.fill(0),this._buffered.push(e),this.push(n.concat(this._buffered)),this._buffered=null}else this._bufferedBytes&&(this.push(n.concat(this._buffered)),this._buffered=null);this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:24,defined:32,inherits:41,"readable-stream":82}],21:[function(e,t,n){},{}],22:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21}],23:[function(e,t,r){(function(t){"use strict";var n=e("buffer"),i=n.Buffer,o=n.SlowBuffer,s=n.kMaxLength||2147483647;r.alloc=function(e,t,n){if("function"==typeof i.alloc)return i.alloc(e,t,n);if("number"==typeof n)throw TypeError("encoding must not be number");if("number"!=typeof e)throw TypeError("size must be a number");if(e>s)throw RangeError("size is too large");var r=n,o=t;void 0===o&&(r=void 0,o=0);var a=new i(e);if("string"==typeof o)for(var u=new i(o,r),c=u.length,f=-1;++f<e;)a[f]=u[f%c];else a.fill(o);return a},r.allocUnsafe=function(e){if("function"==typeof i.allocUnsafe)return i.allocUnsafe(e);if("number"!=typeof e)throw TypeError("size must be a number");if(e>s)throw RangeError("size is too large");return new i(e)},r.from=function(e,n,r){if("function"==typeof i.from&&(!t.Uint8Array||Uint8Array.from!==i.from))return i.from(e,n,r);if("number"==typeof e)throw TypeError('"value" argument must not be a number');if("string"==typeof e)return new i(e,n);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var o=n;if(1==arguments.length)return new i(e);void 0===o&&(o=0);var s=r;if(void 0===s&&(s=e.byteLength-o),o>=e.byteLength)throw RangeError("'offset' is out of bounds");if(s>e.byteLength-o)throw RangeError("'length' is out of bounds");return new i(e.slice(o,o+s))}if(i.isBuffer(e)){var a=new i(e.length);return e.copy(a,0,0,e.length),a}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new i(e);if("Buffer"===e.type&&Array.isArray(e.data))return new i(e.data)}throw TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},r.allocUnsafeSlow=function(e){if("function"==typeof i.allocUnsafeSlow)return i.allocUnsafeSlow(e);if("number"!=typeof e)throw TypeError("size must be a number");if(e>=s)throw RangeError("size is too large");return new o(e)}}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{buffer:24}],24:[function(e,t,n){"use strict";function r(e){if(e>C)throw RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=i.prototype,t}function i(e,t,n){if("number"==typeof e){if("string"==typeof t)throw Error("If encoding is specified then the first argument must be a string");return a(e)}return o(e,t,n)}function o(e,t,n){if("number"==typeof e)throw TypeError('"value" argument must not be a number');return e instanceof ArrayBuffer?function(e,t,n){var r;if(t<0||e.byteLength<t)throw RangeError("'offset' is out of bounds");if(e.byteLength<t+(n||0))throw RangeError("'length' is out of bounds");return(r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n)).__proto__=i.prototype,r}(e,t,n):"string"==typeof e?function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!i.isEncoding(t))throw TypeError('"encoding" must be a valid string encoding');var n=0|f(e,t),o=r(n),s=o.write(e,t);return s!==n&&(o=o.slice(0,s)),o}(e,t):function(e){if(i.isBuffer(e)){var t,n=0|c(e.length),o=r(n);return 0===o.length||e.copy(o,0,0,n),o}if(e){if(S(e)||"length"in e){;return"number"!=typeof e.length||(t=e.length)!=t?r(0):u(e)}if("Buffer"===e.type&&Array.isArray(e.data))return u(e.data)}throw TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e)}function s(e){if("number"!=typeof e)throw TypeError('"size" argument must be a number');if(e<0)throw RangeError('"size" argument must not be negative')}function a(e){return s(e),r(e<0?0:0|c(e))}function u(e){for(var t=e.length<0?0:0|c(e.length),n=r(t),i=0;i<t;i+=1)n[i]=255&e[i];return n}function c(e){if(e>=C)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+C.toString(16)+" bytes");return 0|e}function f(e,t){if(i.isBuffer(e))return e.length;if(S(e)||e instanceof ArrayBuffer)return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return w(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return k(e).length;default:if(r)return w(e).length;t=(""+t).toLowerCase(),r=!0}}function h(e,t,n){var r,i,o=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===n||n>this.length)&&(n=this.length),n<=0)||(n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,n){var r,i=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>i)&&(n=i);for(var o="",s=t;s<n;++s)o+=(r=e[s])<16?"0"+r.toString(16):r.toString(16);return o}(this,t,n);case"utf8":case"utf-8":return m(this,t,n);case"ascii":return function(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}(this,t,n);case"latin1":case"binary":return function(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}(this,t,n);case"base64":return r=t,i=n,0===r&&i===this.length?I.fromByteArray(this):I.fromByteArray(this.slice(r,i));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}(this,t,n);default:if(o)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function d(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function l(e,t,n,r,o){var s;if(0===e.length)return -1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),(s=n=+n)!=s&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return -1;n=e.length-1}else if(n<0){if(!o)return -1;n=0}if("string"==typeof t&&(t=i.from(t,r)),i.isBuffer(t))return 0===t.length?-1:p(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):p(e,[t],n,r,o);throw TypeError("val must be string, number or Buffer")}function p(e,t,n,r,i){function o(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}var s,a=1,u=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return -1;a=2,u/=2,c/=2,n/=2}if(i){var f=-1;for(s=n;s<u;s++)if(o(e,s)===o(t,-1===f?0:s-f)){if(-1===f&&(f=s),s-f+1===c)return f*a}else -1!==f&&(s-=s-f),f=-1}else for(n+c>u&&(n=u-c),s=n;s>=0;s--){for(var h=!0,d=0;d<c;d++)if(o(e,s+d)!==o(t,d)){h=!1;break}if(h)return s}return -1}function m(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,u,c=e[i],f=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=n)switch(h){case 1:c<128&&(f=c);break;
1case 2:128==(192&(o=e[i+1]))&&(u=(31&c)<<6|63&o)>127&&(f=u);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(u=(15&c)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,h=1):f>65535&&(f-=65536,r.push(f>>>10&1023|55296),f=56320|1023&f),r.push(f),i+=h}return function(e){var t=e.length;if(t<=A)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=A));return n}(r)}function g(e,t,n){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>n)throw RangeError("Trying to access beyond buffer length")}function y(e,t,n,r,o,s){if(!i.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<s)throw RangeError('"value" argument is out of bounds');if(n+r>e.length)throw RangeError("Index out of range")}function _(e,t,n,r,i,o){if(n+r>e.length||n<0)throw RangeError("Index out of range")}function v(e,t,n,r,i){return t=+t,n>>>=0,i||_(e,t,n,4,34028234663852886e22,-34028234663852886e22),B.write(e,t,n,r,23,4),n+4}function b(e,t,n,r,i){return t=+t,n>>>=0,i||_(e,t,n,8,17976931348623157e292,-17976931348623157e292),B.write(e,t,n,r,52,8),n+8}function w(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319||s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function E(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function k(e){return I.toByteArray(function(e){if((e=e.trim().replace(T,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function x(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function S(e){return"function"==typeof ArrayBuffer.isView&&ArrayBuffer.isView(e)}var I=e("base64-js"),B=e("ieee754");n.Buffer=i,n.SlowBuffer=function(e){return+e!=e&&(e=0),i.alloc(+e)},n.INSPECT_MAX_BYTES=50;var C=2147483647;n.kMaxLength=C,i.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(e){return!1}}(),i.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),"undefined"!=typeof Symbol&&Symbol.species&&i[Symbol.species]===i&&Object.defineProperty(i,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),i.poolSize=8192,i.from=function(e,t,n){return o(e,t,n)},i.prototype.__proto__=Uint8Array.prototype,i.__proto__=Uint8Array,i.alloc=function(e,t,n){return s(e),e<=0?r(e):void 0!==t?"string"==typeof n?r(e).fill(t,n):r(e).fill(t):r(e)},i.allocUnsafe=function(e){return a(e)},i.allocUnsafeSlow=function(e){return a(e)},i.isBuffer=function(e){return null!=e&&!0===e._isBuffer},i.compare=function(e,t){if(!i.isBuffer(e)||!i.isBuffer(t))throw TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,s=Math.min(n,r);o<s;++o)if(e[o]!==t[o]){n=e[o],r=t[o];break}return n<r?-1:r<n?1:0},i.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},i.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return i.alloc(0);if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var n,r=i.allocUnsafe(t),o=0;for(n=0;n<e.length;++n){var s=e[n];if(!i.isBuffer(s))throw TypeError('"list" argument must be an Array of Buffers');s.copy(r,o),o+=s.length}return r},i.byteLength=f,i.prototype._isBuffer=!0,i.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)d(this,t,t+1);return this},i.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)d(this,t,t+3),d(this,t+1,t+2);return this},i.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)d(this,t,t+7),d(this,t+1,t+6),d(this,t+2,t+5),d(this,t+3,t+4);return this},i.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?m(this,0,e):h.apply(this,arguments)},i.prototype.equals=function(e){if(!i.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===i.compare(this,e)},i.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},i.prototype.compare=function(e,t,n,r,o){if(!i.isBuffer(e))throw TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),t<0||n>e.length||r<0||o>this.length)throw RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return -1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,o>>>=0,this===e)return 0;for(var s=o-r,a=n-t,u=Math.min(s,a),c=this.slice(r,o),f=e.slice(t,n),h=0;h<u;++h)if(c[h]!==f[h]){s=c[h],a=f[h];break}return s<a?-1:a<s?1:0},i.prototype.includes=function(e,t,n){return -1!==this.indexOf(e,t,n)},i.prototype.indexOf=function(e,t,n){return l(this,e,t,n,!0)},i.prototype.lastIndexOf=function(e,t,n){return l(this,e,t,n,!1)},i.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i,o,s,a,u,c,f,h,d,l,p,m,g=this.length-t;if((void 0===n||n>g)&&(n=g),e.length>0&&(n<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var y=!1;;)switch(r){case"hex":return function(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(a!=a)break;e[n+s]=a}return s}(this,e,t,n);case"utf8":case"utf-8":return u=t,c=n,x(w(e,this.length-u),this,u,c);case"ascii":return f=t,h=n,x(E(e),this,f,h);case"latin1":case"binary":;return i=this,o=e,s=t,a=n,x(E(o),i,s,a);case"base64":return d=t,l=n,x(k(e),this,d,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return p=t,m=n,x(function(e,t){for(var n,r,i=[],o=0;o<e.length&&!((t-=2)<0);++o)r=(n=e.charCodeAt(o))>>8,i.push(n%256),i.push(r);return i}(e,this.length-p),this,p,m);default:if(y)throw TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),y=!0}},i.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var A=4096;i.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e);var r=this.subarray(e,t);return r.__proto__=i.prototype,r},i.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||g(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},i.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||g(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},i.prototype.readUInt8=function(e,t){return e>>>=0,t||g(e,1,this.length),this[e]},i.prototype.readUInt16LE=function(e,t){return e>>>=0,t||g(e,2,this.length),this[e]|this[e+1]<<8},i.prototype.readUInt16BE=function(e,t){return e>>>=0,t||g(e,2,this.length),this[e]<<8|this[e+1]},i.prototype.readUInt32LE=function(e,t){return e>>>=0,t||g(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},i.prototype.readUInt32BE=function(e,t){return e>>>=0,t||g(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},i.prototype.readIntLE=function(e,t,n){e>>>=0,t>>>=0,n||g(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},i.prototype.readIntBE=function(e,t,n){e>>>=0,t>>>=0,n||g(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},i.prototype.readInt8=function(e,t){return e>>>=0,t||g(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},i.prototype.readInt16LE=function(e,t){e>>>=0,t||g(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt16BE=function(e,t){e>>>=0,t||g(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},i.prototype.readInt32LE=function(e,t){return e>>>=0,t||g(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},i.prototype.readInt32BE=function(e,t){return e>>>=0,t||g(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},i.prototype.readFloatLE=function(e,t){return e>>>=0,t||g(e,4,this.length),B.read(this,e,!0,23,4)},i.prototype.readFloatBE=function(e,t){return e>>>=0,t||g(e,4,this.length),B.read(this,e,!1,23,4)},i.prototype.readDoubleLE=function(e,t){return e>>>=0,t||g(e,8,this.length),B.read(this,e,!0,52,8)},i.prototype.readDoubleBE=function(e,t){return e>>>=0,t||g(e,8,this.length),B.read(this,e,!1,52,8)},i.prototype.writeUIntLE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||y(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},i.prototype.writeUIntBE=function(e,t,n,r){e=+e,t>>>=0,n>>>=0,r||y(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},i.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||y(this,e,t,1,255,0),this[t]=255&e,t+1},i.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||y(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||y(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||y(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},i.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||y(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},i.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);y(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},i.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t>>>=0,!r){var i=Math.pow(2,8*n-1);y(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},i.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||y(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},i.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||y(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},i.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||y(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},i.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||y(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},i.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||y(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},i.prototype.writeFloatLE=function(e,t,n){return v(this,e,t,!0,n)},i.prototype.writeFloatBE=function(e,t,n){return v(this,e,t,!1,n)},i.prototype.writeDoubleLE=function(e,t,n){return b(this,e,t,!0,n)},i.prototype.writeDoubleBE=function(e,t,n){return b(this,e,t,!1,n)},i.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw RangeError("sourceStart out of bounds");if(r<0)throw RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},i.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var o,s=e.charCodeAt(0);s<256&&(e=s)}if(void 0!==r&&"string"!=typeof r)throw TypeError("encoding must be a string");if("string"==typeof r&&!i.isEncoding(r))throw TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw RangeError("Out of range index");if(n<=t)return this;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var a=i.isBuffer(e)?e:new i(e,r),u=a.length;for(o=0;o<n-t;++o)this[o+t]=a[o%u]}return this};var T=/[^+\/0-9A-Za-z-_]/g},{"base64-js":8,ieee754:39}],25:[function(e,t,n){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:"Parti
1al Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",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 Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",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",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"}},{}],26:[function(e,t,n){function r(e,t,n){var o=this;if(!(o instanceof r))return new r(e,t,n);if(s.Writable.call(o,n),n||(n={}),!e||!e.put||!e.get)throw Error("First argument must be an abstract-chunk-store compliant store");if(!(t=Number(t)))throw Error("Second argument must be a chunk length");o._blockstream=new i(t,{zeroPadding:!1}),o._blockstream.on("data",function(t){o.destroyed||(e.put(a,t),a+=1)}).on("error",function(e){o.destroy(e)});var a=0;o.on("finish",function(){this._blockstream.end()})}t.exports=r;var i=e("block-stream2"),o=e("inherits"),s=e("readable-stream");o(r,s.Writable),r.prototype._write=function(e,t,n){this._blockstream.write(e,t,n)},r.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}},{"block-stream2":20,inherits:41,"readable-stream":82}],27:[function(e,t,n){var r=Math.abs;t.exports=function(e,t,n){for(var i,o,s,a=1/0,u=0,c=t.length-1;u<=c&&((s=t[i=u+(c-u>>1)]-e)<0?u=i+1:s>0&&(c=i-1),(s=r(s))<a&&(a=s,o=i),t[i]!==e););return n?o:t[o]}},{}],28:[function(e,t,n){(function(e){function t(e){return Object.prototype.toString.call(e)}n.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===t(e)},n.isBoolean=function(e){return"boolean"==typeof e},n.isNull=function(e){return null===e},n.isNullOrUndefined=function(e){return null==e},n.isNumber=function(e){return"number"==typeof e},n.isString=function(e){return"string"==typeof e},n.isSymbol=function(e){return"symbol"==typeof e},n.isUndefined=function(e){return void 0===e},n.isRegExp=function(e){return"[object RegExp]"===t(e)},n.isObject=function(e){return"object"==typeof e&&null!==e},n.isDate=function(e){return"[object Date]"===t(e)},n.isError=function(e){return"[object Error]"===t(e)||e instanceof Error},n.isFunction=function(e){return"function"==typeof e},n.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},n.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":43}],29:[function(e,t,r){(function(n,r,i){function o(e,t,r){function o(){k(e.map(function(e){return function(t){var n,r,o={};if(c(e))o.getStream=function(){return new g(e)},o.length=e.size;else if(i.isBuffer(e))o.getStream=function(){var t=new S.PassThrough;return t.end(e),t},o.length=e.length;else{if(!f(e)){if("string"==typeof e){if("function"!=typeof _.stat)throw Error("filesystem paths do not work in the browser");return void(n=e,r=d>1||l,function e(t,n,r){_.stat(t,function(i,o){if(i)return r(i);o.isDirectory()?_.readdir(t,function(i,o){if(i)return r(i);k(o.filter(a).filter(b.not).map(function(r){return function(i){e(p.join(t,r),n,i)}}),r)}):o.isFile()&&n(t,r)})}(n,s,function(e,i){if(e)return t(e);i=Array.isArray(i)?y(i):[i],n=p.normalize(n),r&&(n=n.slice(0,n.lastIndexOf(p.sep)+1)),n[n.length-1]!==
1p.sep&&(n+=p.sep),i.forEach(function(e){var t;e.getStream=(t=e.path,function(){return _.createReadStream(t)}),e.path=e.path.replace(n,"").split(p.sep)}),t(null,i)}))}throw Error("invalid input type")}o.getStream=function(){var t=new S.Transform;return t._transform=function(e,t,n){o.length+=e.length,this.push(e),n()},e.pipe(t),t},o.length=0}o.path=e.path,t(null,o)}}),function(e,t){if(e)return r(e);r(null,t=y(t),l)})}if(Array.isArray(e)&&0===e.length)throw Error("invalid input type");u=e,"undefined"!=typeof FileList&&u instanceof FileList&&(e=Array.prototype.slice.call(e)),Array.isArray(e)||(e=[e]),1!==(e=e.map(function(e){return c(e)&&"string"==typeof e.path&&"function"==typeof _.stat?e.path:e})).length||"string"==typeof e[0]||e[0].name||(e[0].name=t.name);var u,h=null;e.forEach(function(t,n){if("string"!=typeof t){var r=t.fullPath||t.name;r||(r="Unknown File "+(n+1),t.unknownName=!0),t.path=r.split("/"),t.path[0]||t.path.shift(),t.path.length<2?h=null:0===n&&e.length>1?h=t.path[0]:t.path[0]!==h&&(h=null)}}),e=e.filter(function(e){if("string"==typeof e)return!0;var t=e.path[e.path.length-1];return a(t)&&b.not(t)}),h&&e.forEach(function(e){var t=(i.isBuffer(e)||f(e))&&!e.path;"string"==typeof e||t||e.path.shift()}),!t.name&&h&&(t.name=h),t.name||e.some(function(e){return"string"==typeof e?(t.name=p.basename(e),!0):e.unknownName?void 0:(t.name=e.path[e.path.length-1],!0)}),t.name||(t.name="Unnamed Torrent "+Date.now());var d=e.reduce(function(e,t){return e+Number("string"==typeof t)},0),l=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof _.stat)throw Error("filesystem paths do not work in the browser");v(e[0],function(e,t){if(e)return r(e);l=t,o()})}else n.nextTick(function(){o()})}function s(e,t){t=E(t),_.stat(e,function(n,r){if(n)return t(n);var i={length:r.size,path:e};t(null,i)})}function a(e){return"."!==e[0]}function u(e,t){return e+t.length}function c(e){return"undefined"!=typeof Blob&&e instanceof Blob}function f(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}t.exports=function e(n,s,a){if("function"==typeof s)return e(n,null,s);o(n,s=s?m(s):{},function(e,n,o){var c,f,p,m;if(e)return a(e);s.singleFileTorrent=o,(f=(c=s).announceList)||("string"==typeof c.announce?f=[[c.announce]]:Array.isArray(c.announce)&&(f=c.announce.map(function(e){return[e]}))),f||(f=[]),r.WEBTORRENT_ANNOUNCE&&("string"==typeof r.WEBTORRENT_ANNOUNCE?f.push([[r.WEBTORRENT_ANNOUNCE]]):Array.isArray(r.WEBTORRENT_ANNOUNCE)&&(f=f.concat(r.WEBTORRENT_ANNOUNCE.map(function(e){return[e]})))),void 0===c.announce&&void 0===c.announceList&&(f=f.concat(t.exports.announce
1List)),"string"==typeof c.urlList&&(c.urlList=[c.urlList]),p={info:{name:c.name},"creation date":Math.ceil((Number(c.creationDate)||Date.now())/1e3),encoding:"UTF-8"},0!==f.length&&(p.announce=f[0][0],p["announce-list"]=f),void 0!==c.comment&&(p.comment=c.comment),void 0!==c.createdBy&&(p["created by"]=c.createdBy),void 0!==c.private&&(p.info.private=Number(c.private)),void 0!==c.sslCert&&(p.info["ssl-cert"]=c.sslCert),void 0!==c.urlList&&(p["url-list"]=c.urlList),m=c.pieceLength||l(n.reduce(u,0)),p.info["piece length"]=m,function(e,t,n){function r(e){f+=e.length;var t=p;x(e,function(e){c[t]=e,l-=1,u()}),l+=1,p+=1}function o(){m=!0,u()}function s(e){a(),n(e)}function a(){g.removeListener("error",s),y.removeListener("data",r),y.removeListener("end",o),y.removeListener("error",s)}function u(){m&&0===l&&(a(),n(null,i.from(c.join(""),"hex"),f))}n=E(n);var c=[],f=0,h=e.map(function(e){return e.getStream}),l=0,p=0,m=!1,g=new w(h),y=new d(t,{zeroPadding:!1});g.on("error",s),g.pipe(y).on("data",r).on("end",o).on("error",s)}(n,m,function(e,t,r){if(e)return a(e);p.info.pieces=t,n.forEach(function(e){delete e.getStream}),c.singleFileTorrent?p.info.length=r:p.info.files=n,a(null,h.encode(p))})})},t.exports.parseInput=function e(t,n,r){if("function"==typeof n)return e(t,null,n);o(t,n=n?m(n):{},r)}
1,t.exports.announceList=[["udp://tracker.leechers-paradise.org:6969"],["udp://tracker.coppersurfer.tk:6969"],["udp://tracker.opentrackr.org:1337"],["udp://explodie.org:6969"],["udp://tracker.empire-js.us:1337"],["wss://tracker.btorrent.xyz"],["wss://tracker.openwebtorrent.com"],["wss://tracker.fastcast.nz"]];var h=e("bencode"),d=e("block-stream2"),l=e("piece-length"),p=e("path"),m=e("xtend"),g=e("filestream/read"),y=e("flatten"),_=e("fs"),v=e("is-file"),b=e("junk"),w=e("multistream"),E=e("once"),k=e("run-parallel"),x=e("simple-sha1"),S=e("readable-stream")}).call(this,e("_process"),void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{_process:66,bencode:11,"block-stream2":20,buffer:24,"filestream/read":35,flatten:36,fs:22,"is-file":44,junk:47,multistream:58,once:60,path:63,"piece-length":64,"readable-stream":82,"run-parallel":86,"simple-sha1":92,xtend:119}],30:[function(e,t,n){(function(r){function i(){var e;try{e=n.storage.debug}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e}(n=t.exports=e("./debug")).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},n.formatArgs=function(e){var t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),t){var r="color: "+this.color;e.splice(1,0,r,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))}),e.splice(o,0,r)}},n.save=function(e){try{null==e?n.storage.removeItem("debug"):n.storage.debug=e}catch(e){}},n.load=i,n.useColors=function(){return!("undefined"==typeof window||!window||void 0===window.process||"renderer"!==window.process.type)||"undefined"!=typeof document&&document&&"WebkitAppearance"in document.documentElement.style||"undefined"!=typeof window&&window&&window.console&&(console.firebug||console.exception&&console.table)||"undefined"!=typeof navigator&&navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},n.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},n.enable(i())}).call(this,e("_process"))},{"./debug":31,_process:66}],31:[function(e,t,n){var r;function i(e){function t(){if(t.enabled){var e=+new Date,i=e-(r||e);t.diff=i,t.prev=r,t.curr=e,r=e;for(var o=Array(arguments.length),s=0;s<o.length;s++)o[s]=arguments[s];o[0]=n.coerce(o[0]),"string"!=typeof o[0]&&o.unshift("%O");var a=0;o[0]=o[0].replace(/%([a-zA-Z%])/g,function(e,r){if("%%"===e)return e;a++;var i=n.formatters[r];if("function"==typeof i){var s=o[a];e=i.call(t,s),o.splice(a,1),a--}return e}),n.formatArgs.call(t,o),(t.log||n.log||console.log.bind(console)).apply(t,o)}}return t.namespace=e,t.enabled=n.enabled(e),t.useColors=n.useColors(),t.color=function(e){var t,r=0;for(t in e)r=(r<<5)-r+e.charCodeAt(t)|0;return n.colors[Math.abs(r)%n.colors.length]}(e),"function"==typeof n.init&&n.init(t),t}(n=t.exports=i.debug=i.default=i).coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){n.enable("")},n.enable=function(e){n.save(e),n.names=[],n.skips=[];for(var t=(e||"").split(/[\s,]+/),r=t.length,i=0;i<r;i++)t[i]&&("-"===(e=t[i].replace(/\*/g,".*?"))[0]?n.skips.push(RegExp("^"+e.substr(1)+"$")):n.names.push(RegExp("^"+e+"$")))},n.enabled=function(e){var t,r;for(t=0,r=n.skips.length;t<r;t++)if(n.skips[t].test(e))return!1;for(t=0,r=n.names.length;t<r;t++)if(n.names[t].test(e))return!0;return!1},n.humanize=e("ms"),n.names=[],n.skips=[],n.formatters={}},{ms:57}],32:[function(e,t,n){t.exports=function(){for(var e=0;e<arguments.length;e++)if(void 0!==arguments[e])return arguments[e]}},{}],33:[function(e,t,n){var r=e("once"),i=function(){},o=function(e,t,n){if("function"==typeof t)return o(e,null,t);t||(t={}),n=r(n||i);var s=e._writableState,a=e._readableState,u=t.readable||!1!==t.readable&&e.readable,c=t.writable||!1!==t.writable&&e.writable,f=function(){e.writable||h()},h=function(){c=!1,u||n.call(e)},d=function(){u=!1,c||n.call(e)},l=function(t){n.call(e,t?Error("exited with error code: "+t):null)},p=function(){return(!u||a&&a.ended)&&(!c||s&&s.ended)?void 0:n.call(e,Error("premature close"))},m=function(){e.req.on("finish",h)};return e.setHeader&&"function"==typeof e.abort?(e.on("complete",h),e.on("abort",p),e.req?m():e.on("request",m)):c&&!s&&(e.on("end",f),e.on("close",f)),e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length&&e.on("exit",l),e.on("end",d),e.on("finish",h),!1!==t.error&&e.on("error",n),e.on("close",p),function(){e.removeListener("complete",h),e.removeListener("abort",p),e.removeListener("request",m),e.req&&e.req.removeListener("finish",h),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",h),e.removeListener("exit",l),e.removeListener("end",d),e.removeListener("error",n),e.removeListener("close",p)}};t.exports=o},{once:60}],34:[function(e,t,n){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function i(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}t.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,n,r,s,a,u;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var c=Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(void 0===(n=this._events[e]))return!1;if(i(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;
1default:s=Array.prototype.slice.call(arguments,1),n.apply(this,s)}else if(o(n))for(s=Array.prototype.slice.call(arguments,1),r=(u=n.slice()).length,a=0;a<r;a++)u[a].apply(this,s);return!0},r.prototype.addListener=function(e,t){var n;if(!i(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,i(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned&&(n=void 0===this._maxListeners?r.defaultMaxListeners:this._maxListeners)&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!i(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,s,a;if(!i(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(n=this._events[e]).length,r=-1,n===t||i(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(a=s;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0==arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0==arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i(n=this._events[e]))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?i(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(i(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],35:[function(e,t,n){function r(e,t){var n=this;if(!(this instanceof r))return new r(e,t);t=t||{},i.call(this,t),this._offset=0,this._ready=!1,this._file=e,this._size=e.size,this._chunkSize=t.chunkSize||Math.max(this._size/1e3,204800),this.reader=new FileReader,this._generateHeaderBlocks(e,t,function(e,t){if(e)return n.emit("error",e);Array.isArray(t)&&t.forEach(function(e){n.push(e)}),n._ready=!0,n.emit("_ready")})}var i=e("readable-stream").Readable,o=e("inherits"),s=e("typedarray-to-buffer");o(r,i),t.exports=r,r.prototype._generateHeaderBlocks=function(e,t,n){n(null,[])},r.prototype._read=function(){if(!this._ready)return void this.once("_ready",this._read.bind(this));var e=this,t=this.reader,n=this._offset,r=this._offset+this._chunkSize;if(r>this._size&&(r=this._size),n===this._size)return this.destroy(),void this.push(null);t.onload=function(){e._offset=r,e.push(s(t.result))},t.onerror=function(){e.emit("error",t.error)},t.readAsArrayBuffer(this._file.slice(n,r))},r.prototype.destroy=function(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},{inherits:41,"readable-stream":82,"typedarray-to-buffer":108}],36:[function(e,t,n){t.exports=function(e,t){return(t="number"==typeof t?t:1/0)?function e(n,r){return n.reduce(function(n,i){return Array.isArray(i)&&r<t?n.concat(e(i,r+1)):n.concat(i)},[])}(e,1):Array.isArray(e)?e.map(function(e){return e}):e}},{}],37:[function(e,t,n){t.exports=function(){if("undefined"==typeof window)return null;var e={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},{}],38:[function(e,t,n){function r(e){if("string"==typeof e&&(e=o.parse(e)),e.protocol||(e.protocol="https:"),"https:"!==e.protocol)throw Error('Protocol "'+e.protocol+'" not supported. Expected "https:"');return e}var i=e("http"),o=e("url"),s=t.exports;for(var a in i)i.hasOwnProperty(a)&&(s[a]=i[a]);s.request=function(e,t){return e=r(e),i.request.call(this,e,t)},s.get=function(e,t){return e=r(e),i.get.call(this,e,t)}},{http:95,url:112}],39:[function(e,t,n){n.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,c=u>>1,f=-7,h=n?i-1:0,d=n?-1:1,l=e[t+h];for(h+=d,o=l&(1<<-f)-1,l>>=-f,f+=a;f>0;o=256*o+e[t+h],h+=d,f-=8);for(s=o&(1<<-f)-1,o>>=-f,f+=r;f>0;s=256*s+e[t+h],h+=d,f-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(l?-1:1);s+=Math.pow(2,r),o-=c}return(l?-1:1)*s*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var s,a,u,c=8*o-i-1,f=(1<<c)-1,h=f>>1,d=23===i?5960464477539062e-23:0,l=r?0:o-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(isNaN(t=Math.abs(t))||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+h>=1?d/u:d*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=f?(a=0,s=f):s+h>=1?(a=(t*u-1)*Math.pow(2,i),s+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;e[n+l]=255&a,l+=p,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;e[n+l]=255&s,l+=p,s/=256,c-=8);e[n+l-p]|=128*m}},{}],40:[function(e,t,n){(function(e){function n(e){if(!(this instanceof n))return new n(e);
1if(this.store=e,this.chunkLength=e.chunkLength,!this.store||!this.store.get||!this.store.put)throw Error("First argument must be abstract-chunk-store compliant");this.mem=[]}t.exports=n,n.prototype.put=function(e,t,n){var r=this;r.mem[e]=t,r.store.put(e,t,function(t){r.mem[e]=null,n&&n(t)})},n.prototype.get=function(t,n,r){if("function"==typeof n)return this.get(t,null,n);var i,o=n&&n.offset||0,s=n&&n.length&&o+n.length,a=this.mem[t];if(a)return i=n?a.slice(o,s):a,void e.nextTick(function(){r&&r(null,i)});this.store.get(t,n,r)},n.prototype.close=function(e){this.store.close(e)},n.prototype.destroy=function(e){this.store.destroy(e)}}).call(this,e("_process"))},{_process:66}],41:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],42:[function(e,t,n){t.exports=function(e){for(var t=0,n=e.length;t<n;++t)if(e.charCodeAt(t)>127)return!1;return!0}},{}],43:[function(e,t,n){function r(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}t.exports=function(e){return null!=e&&(r(e)||"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&r(e.slice(0,0))||!!e._isBuffer)}},{}],44:[function(e,t,n){"use strict";function r(e){return i.existsSync(e)&&i.statSync(e).isFile()}var i=e("fs");t.exports=function(e,t){if(!t)return r(e);i.stat(e,function(e,n){return e?t(e):t(null,n.isFile())})},t.exports.sync=r},{fs:22}],45:[function(e,t,n){function r(e){return i(e)||o(e)}function i(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 a[s.call(e)]}t.exports=r,r.strict=i,r.loose=o;var s=Object.prototype.toString,a={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],46:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],47:[function(e,t,n){"use strict";n.re=/^npm-debug\.log$|^\..*\.swp$|^\.DS_Store$|^\.AppleDouble$|^\.LSOverride$|^Icon\r$|^\._.*|^\.Spotlight-V100$|\.Trashes|^__MACOSX$|~$|^Thumbs\.db$|^ehthumbs\.db$|^Desktop\.ini$/,n.is=function(e){return n.re.test(e)},n.not=n.isnt=function(e){return!n.is(e)}},{}],48:[function(e,t,n){(function(n){function r(e){var t,r={},o=e.split("magnet:?")[1];return(o&&o.length>=0?o.split("&"):[]).forEach(function(e){var t=e.split("=");if(2===t.length){var n=t[0],i=t[1];if("dn"===n&&(i=decodeURIComponent(i).replace(/\+/g," ")),"tr"!==n&&"xs"!==n&&"as"!==n&&"ws"!==n||(i=decodeURIComponent(i)),"kt"===n&&(i=decodeURIComponent(i).split("+")),"ix"===n&&(i=Number(i)),r[n]){if(Array.isArray(r[n]))r[n].push(i);else{var o=r[n];r[n]=[o,i]}}else r[n]=i}}),r.xt&&(Array.isArray(r.xt)?r.xt:[r.xt]).forEach(function(e){if(t=e.match(/^urn:btih:(.{40})/))r.infoHash=t[1].toLowerCase();else if(t=e.match(/^urn:btih:(.{32})/)){var o=i.decode(t[1]);r.infoHash=n.from(o,"binary").toString("hex")}}),r.infoHash&&(r.infoHashBuffer=n.from(r.infoHash,"hex")),r.dn&&(r.name=r.dn),r.kt&&(r.keywords=r.kt),"string"==typeof r.tr?r.announce=[r.tr]:Array.isArray(r.tr)?r.announce=r.tr:r.announce=[],r.urlList=[],("string"==typeof r.as||Array.isArray(r.as))&&(r.urlList=r.urlList.concat(r.as)),("string"==typeof r.ws||Array.isArray(r.ws))&&(r.urlList=r.urlList.concat(r.ws)),s(r.announce),s(r.urlList),r}t.exports=r,t.exports.decode=r,t.exports.encode=function(e){(e=o(e)).infoHashBuffer&&(e.xt="urn:btih:"+e.infoHashBuffer.toString("hex")),e.infoHash&&(e.xt="urn:btih:"+e.infoHash),e.name&&(e.dn=e.name),e.keywords&&(e.kt=e.keywords),e.announce&&(e.tr=e.announce),e.urlList&&(e.ws=e.urlList,delete e.as);var t="magnet:?";return Object.keys(e).filter(function(e){return 2===e.length}
1).forEach(function(n,r){(Array.isArray(e[n])?e[n]:[e[n]]).forEach(function(e,i){(r>0||i>0)&&("kt"!==n||0===i)&&(t+="&"),"dn"===n&&(e=encodeURIComponent(e).replace(/%20/g,"+")),"tr"!==n&&"xs"!==n&&"as"!==n&&"ws"!==n||(e=encodeURIComponent(e)),"kt"===n&&(e=encodeURIComponent(e)),t+="kt"===n&&i>0?"+"+e:n+"="+e})}),t};var i=e("thirty-two"),o=e("xtend"),s=e("uniq")}).call(this,e("buffer").Buffer)},{buffer:24,"thirty-two":103,uniq:110,xtend:119}],49:[function(e,t,n){function r(e,t){var n=this;if(!(n instanceof r))return new r(e,t);if(!u)throw Error("web browser lacks MediaSource support");t||(t={}),n._bufferDuration=t.bufferDuration||c,n._elem=e,n._mediaSource=new u,n._streams=[],n.detailedError=null,n._errorHandler=function(){n._elem.removeEventListener("error",n._errorHandler),n._streams.slice().forEach(function(e){e.destroy(n._elem.error)})},n._elem.addEventListener("error",n._errorHandler),n._elem.src=window.URL.createObjectURL(n._mediaSource)}function i(e,t){var n=this;if(s.Writable.call(n),n._wrapper=e,n._elem=e._elem,n._mediaSource=e._mediaSource,n._allStreams=e._streams,n._allStreams.push(n),n._bufferDuration=e._bufferDuration,n._sourceBuffer=null,n._openHandler=function(){n._onSourceOpen()},n._flowHandler=function(){n._flow()},"string"==typeof t)n._type=t,"open"===n._mediaSource.readyState?n._createSourceBuffer():n._mediaSource.addEventListener("sourceopen",n._openHandler);else if(null===t._sourceBuffer)t.destroy(),n._type=t._type,n._mediaSource.addEventListener("sourceopen",n._openHandler);else{if(!t._sourceBuffer)throw Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");t.destroy(),n._type=t._type,n._sourceBuffer=t._sourceBuffer,n._sourceBuffer.addEventListener("updateend",n._flowHandler)}n._elem.addEventListener("timeupdate",n._flowHandler),n.on("error",function(e){n._wrapper.error(e)}),n.on("finish",function(){if(!n.destroyed&&(n._finished=!0,n._allStreams.every(function(e){return e._finished})))try{n._mediaSource.endOfStream()}catch(e){}})}t.exports=r;var o=e("inherits"),s=e("readable-stream"),a=e("to-arraybuffer"),u="undefined"!=typeof window&&window.MediaSource,c=60;r.prototype.createWriteStream=function(e){return new i(this,e)},r.prototype.error=function(e){this.detailedError||(this.detailedError=e);try{this._mediaSource.endOfStream("decode")}catch(e){}},o(i,s.Writable),i.prototype._onSourceOpen=function(){this.destroyed||(this._mediaSource.removeEventListener("sourceopen",this._openHandler),this._createSourceBuffer())},i.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._allStreams.splice(this._allStreams.indexOf(this),1),this._mediaSource.removeEventListener("sourceopen",this._openHandler),this._elem.removeEventListener("timeupdate",this._flowHandler),this._sourceBuffer&&(this._sourceBuffer.removeEventListener("updateend",this._flowHandler),"open"===this._mediaSource.readyState&&this._sourceBuffer.abort()),e&&this.emit("error",e),this.emit("close"))},i.prototype._createSourceBuffer=function(){if(!this.destroyed){if(u.isTypeSupported(this._type)){if(this._sourceBuffer=this._mediaSource.addSourceBuffer(this._type),this._sourceBuffer.addEventListener("updateend",this._flowHandler),this._cb){var e=this._cb;this._cb=null,e()}}else this.destroy(Error("The provided type is not supported"))}},i.prototype._write=function(e,t,n){var r=this;if(!r.destroyed){if(!r._sourceBuffer)return void(r._cb=function(i){if(i)return n(i);r._write(e,t,n)});if(r._sourceBuffer.updating)return n(Error("Cannot append buffer while source buffer updating"));try{r._sourceBuffer.appendBuffer(a(e))}catch(e){return void r.destroy(e)}r._cb=n}},i.prototype._flow=function(){if(!this.destroyed&&this._sourceBuffer&&!this._sourceBuffer.updating&&!("open"===this._mediaSource.readyState&&this._getBufferDuration()>this._bufferDuration)&&this._cb){var e=this._cb;this._cb=null,e()}},i.prototype._getBufferDuration=function(){for(var e=this._sourceBuffer.buffered,t=this._elem.currentTime,n=-1,r=0;r<e.length;r++){var i=e.start(r),o=e.end(r)+0;if(i>t)break;(n>=0||t<=o)&&(n=o)}var s=n-t;return s<0&&(s=0),s}},{inherits:41,"readable-stream":82,"to-arraybuffer":105}],50:[function(e,t,n){(function(e){function n(e,t){if(!(this instanceof n))return new n(e,t);if(t||(t={}
1),this.chunkLength=Number(e),!this.chunkLength)throw Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=Number(t.length)||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}function r(t,n,r){e.nextTick(function(){t&&t(n,r)})}t.exports=n,n.prototype.put=function(e,t,n){if(this.closed)return r(n,Error("Storage is closed"));var i=e===this.lastChunkIndex;return i&&t.length!==this.lastChunkLength?r(n,Error("Last chunk length must be "+this.lastChunkLength)):i||t.length===this.chunkLength?(this.chunks[e]=t,void r(n,null)):r(n,Error("Chunk length must be "+this.chunkLength))},n.prototype.get=function(e,t,n){if("function"==typeof t)return this.get(e,null,t);if(this.closed)return r(n,Error("Storage is closed"));var i=this.chunks[e];if(!i)return r(n,Error("Chunk not found"));if(!t)return r(n,null,i);var o=t.offset||0,s=t.length||i.length-o;r(n,null,i.slice(o,s+o))},n.prototype.close=n.prototype.destroy=function(e){if(this.closed)return r(e,Error("Storage is closed"));this.closed=!0,this.chunks=null,r(e,null)}}).call(this,e("_process"))},{_process:66}],51:[function(e,t,n){(function(t){function r(e,t,n){for(var r=t;r<n;r++)e[r]=0}function i(e,t,n){t.writeUInt32BE(Math.floor((e.getTime()+d)/1e3),n)}function o(e,t,n){t.writeUInt16BE(Math.floor(e)%65536,n),t.writeUInt16BE(Math.floor(256*e*256)%65536,n+2)}function s(e,t,n){e||(e=[0,0,0,0,0,0,0,0,0]);for(var r=0;r<e.length;r++)o(e[r],t,n+4*r)}function a(e){for(var t=Array(e.length/4),n=0;n<t.length;n++)t[n]=c(e,4*n);return t}function u(e,t){return new Date(1e3*e.readUInt32BE(t)-d)}function c(e,t){return e.readUInt16BE(t)+e.readUInt16BE(t+2)/65536}var f=e("./index"),h=e("./descriptor"),d=20828448e5;n.fullBoxes={},["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"].forEach(function(e){n.fullBoxes[e]=!0}),n.ftyp={},n.ftyp.encode=function(e,r,i){r=r?r.slice(i):new t(n.ftyp.encodingLength(e));var o=e.compatibleBrands||[];r.write(e.brand,0,4,"ascii"),r.writeUInt32BE(e.brandVersion,4);for(var s=0;s<o.length;s++)r.write(o[s],8+4*s,4,"ascii");return n.ftyp.encode.bytes=8+4*o.length,r},n.ftyp.decode=function(e,t){e=e.slice(t);for(var n=e.toString("ascii",0,4),r=e.readUInt32BE(4),i=[],o=8;o<e.length;o+=4)i.push(e.toString("ascii",o,o+4));return{brand:n,brandVersion:r,compatibleBrands:i}},n.ftyp.encodingLength=function(e){return 8+4*(e.compatibleBrands||[]).length},n.mvhd={},n.mvhd.encode=function(e,a,u){var c,f;return a=a?a.slice(u):new t(96),i(e.ctime||new Date,a,0),i(e.mtime||new Date,a,4),a.writeUInt32BE(e.timeScale||0,8),a.writeUInt32BE(e.duration||0,12),o(e.preferredRate||0,a,16),c=e.preferredVolume||0,(f=a)[20]=Math.floor(c)%256,f[21]=Math.floor(256*c)%256,r(a,22,32),s(e.matrix,a,32),a.writeUInt32BE(e.previewTime||0,68),a.writeUInt32BE(e.previewDuration||0,72),a.writeUInt32BE(e.posterTime||0,76),a.writeUInt32BE(e.selectionTime||0,80),a.writeUInt32BE(e.selectionDuration||0,84),a.writeUInt32BE(e.currentTime||0,88),a.writeUInt32BE(e.nextTrackId||0,92),n.mvhd.encode.bytes=96,a},n.mvhd.decode=function(e,t){var n;return{ctime:u(e=e.slice(t),0),mtime:u(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),preferredRate:c(e,16),preferredVolume:(n=e)[20]+n[21]/256,matrix:a(e.slice(32,68)),previewTime:e.readUInt32BE(68),previewDuration:e.readUInt32BE(72),posterTime:e.readUInt32BE(76),selectionTime:e.readUInt32BE(80),selectionDuration:e.readUInt32BE(84),currentTime:e.readUInt32BE(88),nextTrackId:e.readUInt32BE(92)}},n.mvhd.encodingLength=function(e){return 96},n.tkhd={},n.tkhd.encode=function(e,o,a){return o=o?o.slice(a):new t(80),i(e.ctime||new Date,o,0),i(e.mtime||new Date,o,4),o.writeUInt32BE(e.trackId||0,8),r(o,12,16),o.writeUInt32BE(e.duration||0,16),r(o,20,28),o.writeUInt16BE(e.layer||0,28),o.writeUInt16BE(e.alternateGroup||0,30),o.writeUInt16BE(e.volume||0,32),s(e.matrix,o,36),o.writeUInt32BE(e.trackWidth||0,72),o.writeUInt32BE(e.trackHeight||0,76),n.tkhd.encode.bytes=80,o},n.tkhd.decode=function(e,t){return{ctime:u(e=e.slice(t),0),mtime:u(e,4),trackId:e.readUInt32BE(8),duration:e.readUInt32BE(16),layer:e.readUInt16BE(28),alternateGroup:e.readUInt16BE(30),volume:e.readUInt16BE(32),matrix:a(e.slice(36,72)),trackWidth:e.readUInt32BE(72),trackHeight:e.readUInt32BE(76)}},n.tkhd.encodingLength=function(e){return 80},n.mdhd={},n.mdhd.encode=function(e,r,o){return r=r?r.slice(o):new t(20),i(e.ctime||new Date,r,0),i(e.mtime||new Date,r,4),r.writeUInt32BE(e.timeScale||0,8),r.writeUInt32BE(e.duration||0,12),r.writeUInt16BE(e.language||0,16),r.writeUInt16BE(e.quality||0,18),n.mdhd.encode.bytes=20,r},n.mdhd.decode=function(e,t){return{ctime:u(e=e.slice(t),0),mtime:u(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),language:e.readUInt16BE(16),quality:e.readUInt16BE(18)}},n.mdhd.encodingLength=function(e){return 20},n.vmhd={},n.vmhd.encode=function(e,r,i){(r=r?r.slice(i):new t(8)).writeUInt16BE(e.graphicsMode||0,0);var o=e.opcolor||[0,0,0];return r.writeUInt16BE(o[0],2),r.writeUInt16BE(o[1],4),r.writeUInt16BE(o[2],6),n.vmhd.encode.bytes=8,r},n.vmhd.decode=function(e,t){return{graphicsMode:(e=e.slice(t)).readUInt16BE(0),opcolor:[e.readUInt16BE(2),e.readUInt16BE(4),e.readUInt16BE(6)]}},n.vmhd.encodingLength=function(e){return 8},n.smhd={},n.smhd.encode=function(e,i,o){return(i=i?i.slice(o):new t(4)).writeUInt16BE(e.balance||0,0),r(i,2,4),n.smhd.encode.bytes=4,i},n.smhd.decode=function(e,t){return{balance:(e=e.slice(t)).readUInt16BE(0)}},n.smhd.encodingLength=function(e){return 4},n.stsd={},n.stsd.encode=function(e,r,i){r=r?r.slice(i):new t(n.stsd.encodingLength(e));var o=e.entries||[];r.writeUInt32BE(o.length,0);for(var s=4,a=0;a<o.length;a++){var u=o[a];f.encode(u,r,s),s+=f.encode.bytes}return n.stsd.encode.bytes=s,r},n.stsd.decode=function(e,t,n){e=e.slice(t);for(var r=e.readUInt32BE(0),i=Array(r),o=4,s=0;s<r;s++){var a=f.decode(e,o,n);i[s]=a,o+=a.length}return{entries:i}},n.stsd.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var n=0;n<e.entries.length;n++)t+=f.encodingLength(e.entries[n]);return t},n.avc1=n.VisualSampleEntry={},n.VisualSampleEntry.encode=function(e,i,o){r(i=i?i.slice(o):new t(n.VisualSampleEntry.encodingLength(e)),0,6),i.writeUInt16BE(e.dataReferenceIndex||
10,6),r(i,8,24),i.writeUInt16BE(e.width||0,24),i.writeUInt16BE(e.height||0,26),i.writeUInt32BE(e.hResolution||4718592,28),i.writeUInt32BE(e.vResolution||4718592,32),r(i,36,40),i.writeUInt16BE(e.frameCount||1,40);var s=e.compressorName||"",a=Math.min(s.length,31);i.writeUInt8(a,42),i.write(s,43,a,"utf8"),i.writeUInt16BE(e.depth||24,74),i.writeInt16BE(-1,76);var u=78;(e.children||[]).forEach(function(e){f.encode(e,i,u),u+=f.encode.bytes}),n.VisualSampleEntry.encode.bytes=u},n.VisualSampleEntry.decode=function(e,t,n){e=e.slice(t);for(var r=n-t,i=Math.min(e.readUInt8(42),31),o={dataReferenceIndex:e.readUInt16BE(6),width:e.readUInt16BE(24),height:e.readUInt16BE(26),hResolution:e.readUInt32BE(28),vResolution:e.readUInt32BE(32),frameCount:e.readUInt16BE(40),compressorName:e.toString("utf8",43,43+i),depth:e.readUInt16BE(74),children:[]},s=78;r-s>=8;){var a=f.decode(e,s,r);o.children.push(a),o[a.type]=a,s+=a.length}return o},n.VisualSampleEntry.encodingLength=function(e){var t=78;return(e.children||[]).forEach(function(e){t+=f.encodingLength(e)}),t},n.avcC={},n.avcC.encode=function(e,r,i){r=r?r.slice(i):t(e.buffer.length),e.buffer.copy(r),n.avcC.encode.bytes=e.buffer.length},n.avcC.decode=function(e,n,r){return{mimeCodec:(e=e.slice(n,r)).toString("hex",1,4),buffer:new t(e)}},n.avcC.encodingLength=function(e){return e.buffer.length},n.mp4a=n.AudioSampleEntry={},n.AudioSampleEntry.encode=function(e,i,o){r(i=i?i.slice(o):new t(n.AudioSampleEntry.encodingLength(e)),0,6),i.writeUInt16BE(e.dataReferenceIndex||0,6),r(i,8,16),i.writeUInt16BE(e.channelCount||2,16),i.writeUInt16BE(e.sampleSize||16,18),r(i,20,24),i.writeUInt32BE(e.sampleRate||0,24);var s=28;(e.children||[]).forEach(function(e){f.encode(e,i,s),s+=f.encode.bytes}),n.AudioSampleEntry.encode.bytes=s},n.AudioSampleEntry.decode=function(e,t,n){e=e.slice(t,n);for(var r=n-t,i={dataReferenceIndex:e.readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},o=28;r-o>=8;){var s=f.decode(e,o,r);i.children.push(s),i[s.type]=s,o+=s.length}return i},n.AudioSampleEntry.encodingLength=function(e){var t=28;return(e.children||[]).forEach(function(e){t+=f.encodingLength(e)}),t},n.esds={},n.esds.encode=function(e,r,i){r=r?r.slice(i):t(e.buffer.length),e.buffer.copy(r,0),n.esds.encode.bytes=e.buffer.length},n.esds.decode=function(e,n,r){e=e.slice(n,r);var i=h.Descriptor.decode(e,0,e.length),o=("ESDescriptor"===i.tagName?i:{}).DecoderConfigDescriptor||{},s=o.oti||0,a=o.DecoderSpecificInfo,u=a?(248&a.buffer.readUInt8(0))>>3:0,c=null;return s&&(c=s.toString(16),u&&(c+="."+u)),{mimeCodec:c,buffer:new t(e.slice(0))}},n.esds.encodingLength=function(e){return e.buffer.length},n.stsz={},n.stsz.encode=function(e,r,i){var o=e.entries||[];(r=r?r.slice(i):t(n.stsz.encodingLength(e))).writeUInt32BE(0,0),r.writeUInt32BE(o.length,4);for(var s=0;s<o.length;s++)r.writeUInt32BE(o[s],4*s+8);return n.stsz.encode.bytes=8+4*o.length,r},n.stsz.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=e.readUInt32BE(4),i=Array(r),o=0;o<r;o++)i[o]=0===n?e.readUInt32BE(4*o+8):n;return{entries:i}},n.stsz.encodingLength=function(e){return 8+4*e.entries.length},n.stss=n.stco={},n.stco.encode=function(e,r,i){var o=e.entries||[];(r=r?r.slice(i):new t(n.stco.encodingLength(e))).writeUInt32BE(o.length,0);for(var s=0;s<o.length;s++)r.writeUInt32BE(o[s],4*s+4);return n.stco.encode.bytes=4+4*o.length,r},n.stco.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),i=0;i<n;i++)r[i]=e.readUInt32BE(4*i+4);return{entries:r}},n.stco.encodingLength=function(e){return 4+4*e.entries.length},n.stts={},n.stts.encode=function(e,r,i){var o=e.entries||[];(r=r?r.slice(i):new t(n.stts.encodingLength(e))).writeUInt32BE(o.length,0);for(var s=0;s<o.length;s++){var a=8*s+4;r.writeUInt32BE(o[s].count||0,a),r.writeUInt32BE(o[s].duration||0,a+4)}return n.stts.encode.bytes=4+8*e.entries.length,r},n.stts.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),i=0;i<n;i++){var o=8*i+4;r[i]={count:e.readUInt32BE(o),duration:e.readUInt32BE(o+4)}}return{entries:r}},n.stts.encodingLength=function(e){return 4+8*e.entries.length},n.ctts={},n.ctts.encode=function(e,r,i){var o=e.entries||[];(r=r?r.slice(i):new t(n.ctts.encodingLength(e))).writeUInt32BE(o.length,0);for(var s=0;s<o.length;s++){var a=8*s+4;r.writeUInt32BE(o[s].count||0,a),r.writeUInt32BE(o[s].compositionOffset||0,a+4)}return n.ctts.encode.bytes=4+8*o.length,r},n.ctts.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),i=0;i<n;i++){var o=8*i+4;r[i]={count:e.readUInt32BE(o),compositionOffset:e.readInt32BE(o+4)}}return{entries:r}},n.ctts.encodingLength=function(e){return 4+8*e.entries.length},n.stsc={},n.stsc.encode=function(e,r,i){var o=e.entries||[];(r=r?r.slice(i):new t(n.stsc.encodingLength(e))).writeUInt32BE(o.length,0);for(var s=0;s<o.length;s++){var a=12*s+4;r.writeUInt32BE(o[s].firstChunk||0,a),r.writeUInt32BE(o[s].samplesPerChunk||0,a+4),r.writeUInt32BE(o[s].sampleDescriptionId||0,a+8)}return n.stsc.encode.bytes=4+12*o.length,r},n.stsc.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),i=0;i<n;i++){var o=12*i+4;r[i]={firstChunk:e.readUInt32BE(o),samplesPerChunk:e.readUInt32BE(o+4),sampleDescriptionId:e.readUInt32BE(o+8)}}return{entries:r}},n.stsc.encodingLength=function(e){return 4+12*e.entries.length},n.dref={},n.dref.encode=function(e,r,i){r=r?r.slice(i):new t(n.dref.encodingLength(e));var o=e.entries||[];r.writeUInt32BE(o.length,0);for(var s=4,a=0;a<o.length;a++){var u=o[a],c=(u.buf?u.buf.length:0)+4+4;r.writeUInt32BE(c,s),s+=4,r.write(u.type,s,4,"ascii"),s+=4,u.buf&&(u.buf.copy(r,s),s+=u.buf.length)}return n.dref.encode.bytes=s,r},n.dref.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),i=4,o=0;o<n;o++){var s=e.readUInt32BE(i),a=e.toString("ascii",i+4,i+8),u=e.slice(i+8,i+s);i+=s,r[o]={type:a,buf:u}}return{entries:r}},n.dref.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var n=0;n<e.entries.length;n++){var r=e.entries[n].buf;t+=(r?r.length:0)+4+4}return t},n.elst={},n.elst.encode=function(e,r,i){var s=e.entries||[];(r=r?r.slice(i):new t(n.elst.encodingLength(e))).writeUInt32BE(s.length,0);for(var a=0;a<s.length;a++){var u=12*a+4;r.writeUInt32BE(s[a].trackDuration||0,u),r.writeUInt32BE(s[a].mediaTime||0,u+4),o(s[a].mediaRate||0,r,u+8)}return n.elst.encode.bytes=4+12*s.length,r},n.elst.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),i=0;i<n;i++){var o=12*i+4;r[i]={trackDuration:e.readUInt32BE(o),mediaTime:e.readInt32BE(o+4),mediaRate:c(e,o+8)}}return{entries:r}},n.elst.encodingLength=function(e){return 4+12*e.entries.length},n.hdlr={},n.hdlr.encode=function(e,r,i){r=r?r.slice(i):new t(n.hdlr.encodingLength(e));var o,s,a,u=21+(e.name||"").length;return r.fill(0,0,u),r.write(e.handlerType||"",4,4,"ascii"),o=e.name||"",s=r,(a=new t(o,"utf8")).copy(s,20),s[20+a.length]=0,n.hdlr.encode.bytes=u,r},n.hdlr.decode=function(e,t,n){return{handlerType:(e=e.slice(t)).toString("ascii",4,8),name:function(e,t,n){var r;for(r=0;r<n&&0!==e[20+r];r++);return e.toString("utf8",20,20+r)}(e,20,n)}},n.hdlr.encodingLength=function(e){return 21+(e.name||"").length},n.mehd={},n.mehd.encode=function(e,r,i){return(r=r?r.slice(i):new t(4)).writeUInt32BE(e.fragmentDuration||0,0),n.mehd.encode.bytes=4,r},n.mehd.decode=function(e,t){return{fragmentDuration:(e=e.slice(t)).readUInt32BE(0)}},n.mehd.encodingLength=function(e){return 4},n.trex={},n.trex.encode=function(e,r,i){return(r=r?r.slice(i):new t(20)).writeUInt32BE(e.trackId||0,0),r.writeUInt32BE(e.defaultSampleDescriptionIndex||0,4),r.writeUInt32BE(e.defaultSampleDuration||0,8),r.writeUInt32BE(e.defaultSampleSize||0,12),r.writeUInt32BE(e.defaultSampleFlags||0,16),n.trex.encode.bytes=20,r},n.trex.decode=function(e,t){return{trackId:(e=e.slice(t)).readUInt32BE(0),defaultSampleDescriptionIndex:e.readUInt32BE(4),defaultSampleDuration:e.readUInt32BE(8),defaultSampleSize:e.readUInt32BE(12),defaultSampleFlags:e.readUInt32BE(16)}},n.trex.encodingLength=function(e){return 20},n.mfhd={},n.mfhd.encode=function(e,r,i){return(r=r?r.slice(i):new t(4)).writeUInt32BE(e.sequenceNumber||0,0),n.mfhd.encode.bytes=4,r},n.mfhd.decode=function(e,t){return{sequenceNumber:e.readUint32BE(0)}},n.mfhd.encodingLength=function(e){return 4},n.tfhd={},n.tfhd.encode=function(e,r,i){return(r=r?r.slice(i):new t(4)).writeUInt32BE(e.trackId,0),n.tfhd.encode.bytes=4,r},n.tfhd.decode=function(e,t){},n.tfhd.encodingLength=function(e){return 4},n.tfdt={},n.tfdt.encode=function(e,r,i){return(r=r?r.slice(i):new t(4)).writeUInt32BE(e.baseMediaDecodeTime||0,0),n.tfdt.encode.bytes=4,r},n.tfdt.decode=function(e,t){},n.tfdt.encodingLength=function(e){return 4},n.trun={},n.trun.encode=function(e,r,i){(r=r?r.slice(i):new t(8+16*e.entries.length)).writeUInt32BE(e.entries.length,0),r.writeInt32BE(e.dataOffset,4);for(var o=8,s=0;s<e.entries.length;s++){var a=e.entries[s];r.writeUInt32BE(a.sampleDuration,o),o+=4,r.writeUInt32BE(a.sampleSize,o),o+=4,r.writeUInt32BE(a.sampleFlags,o),o+=4,r.writeUInt32BE(a.sampleCompositionTimeOffset,o),o+=4}n.trun.encode.bytes=o},n.trun.decode=function(e,t){},n.trun.encodingLength=function(e){return 8+16*e.entries.length},n.mdat={},n.mdat.encode=function(e,t,r){e.buffer?(e.buffer.copy(t,r),n.mdat.encode.bytes=e.buffer.length):n.mdat.encode.bytes=n.mdat.encodingLength(e)},n.mdat.decode=function(e,n,r){return{buffer:new t(e.slice(n,r))}},n.mdat.encodingLength=function(e){return e.buffer?e.buffer.length:e.contentLength}}).call(this,e("buffer").Buffer)},{"./descriptor":52,"./index":53,buffer:24}],52:[function(e,t,n){(function(e){var t={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};n.Descriptor={},n.Descriptor.decode=function(r,i,o){var s,a=r.readUInt8(i),u=i+1,c=0;do c=c<<7|127&(s=r.readUInt8(u++));while(128&s);var f,h=t[a];return(f=n[h]?n[h].decode(r,u,o):{buffer:new e(r.slice(u,u+c))}).tag=a,f.tagName=h,f.length=u-i+c,f.contentsLen=c,f},n.DescriptorArray={},n.DescriptorArray.decode=function(e,r,i){for(var o=r,s={};o+2<=i;){var a=n.Descriptor.decode(e,o,i);o+=a.length,s[t[a.tag]||"Descriptor"+a.tag]=a}return s},n.ESDescriptor={},n.ESDescriptor.decode=function(e,t,r){var i=e.readUInt8(t+2),o=t+3;return 128&i&&(o+=2),64&i&&(o+=e.readUInt8(o)+1),32&i&&(o+=2),n.DescriptorArray.decode(e,o,r)},n.DecoderConfigDescriptor={},n.DecoderConfigDescriptor.decode=function(e,t,r){var i=e.readUInt8(t),o=n.DescriptorArray.decode(e,t+13,r);return o.oti=i,o}}).call(this,e("buffer").Buffer)},{buffer:24}],53:[function(e,t,n){(function(t){var r=e("uint64be"),i=e("./boxes"),o=n.containers={moov:["mvhd","meta","traks","mvex"],trak:["tkhd","tref","trgr","edts","meta","mdia","udta"],edts:["elst"],mdia:["mdhd","hdlr","elng","minf"],minf:["vmhd","smhd","hmhd","sthd","nmhd","dinf","stbl"],dinf:["dref"],stbl:["stsd","stts","ctts","cslg","stsc","stsz","stz2","stco","co64","stss","stsh","padb","stdp","sdtp","sbgps","sgpds","subss","
1saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","trun","sbgps","sgpds","subss","saizs","saios","tfdt","meta"]};n.encode=function(e,r,i){return n.encodingLength(e),i=i||0,r=r||new t(e.length),n._encode(e,r,i)},n._encode=function(e,t,s){var a=e.type,u=e.length;u>4294967295&&(u=1),t.writeUInt32BE(u,s),t.write(e.type,s+4,4,"ascii");var c=s+8;if(1===u&&(r.encode(e.length,t,c),c+=8),i.fullBoxes[a]&&(t.writeUInt32BE(e.flags||0,c),t.writeUInt8(e.version||0,c),c+=4),o[a])o[a].forEach(function(r){if(5===r.length){var i=e[r]||[];r=r.substr(0,4),i.forEach(function(e){n._encode(e,t,c),c+=n.encode.bytes})}else e[r]&&(n._encode(e[r],t,c),c+=n.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){n._encode(e,t,c),c+=n.encode.bytes});else if(i[a]){var f=i[a].encode;f(e,t,c),c+=f.bytes}else{if(!e.buffer)throw Error("Either `type` must be set to a known type (not'"+a+"') or `buffer` must be set");e.buffer.copy(t,c),c+=e.buffer.length}return n.encode.bytes=c-s,t},n.readHeaders=function(e,t,n){if(t=t||0,(n=n||e.length)-t<8)return 8;var o,s,a=e.readUInt32BE(t),u=e.toString("ascii",t+4,t+8),c=t+8;if(1===a){if(n-t<16)return 16;a=r.decode(e,c),c+=8}return i.fullBoxes[u]&&(o=e.readUInt8(c),s=16777215&e.readUInt32BE(c),c+=4),{length:a,headersLen:c-t,contentLen:a-(c-t),type:u,version:o,flags:s}},n.decode=function(e,t,r){t=t||0,r=r||e.length;var i=n.readHeaders(e,t,r);if(!i||i.length>r-t)throw Error("Data too short");return n.decodeWithoutHeaders(i,e,t+i.headersLen,t+i.length)},n.decodeWithoutHeaders=function(e,r,s,a){s=s||0,a=a||r.length;var u=e.type,c={};if(o[u]){c.otherBoxes=[];for(var f=o[u],h=s;a-h>=8;){var d=n.decode(r,h,a);if(h+=d.length,f.indexOf(d.type)>=0)c[d.type]=d;else if(f.indexOf(d.type+"s")>=0){var l=d.type+"s";(c[l]=c[l]||[]).push(d)}else c.otherBoxes.push(d)}}else i[u]?c=(0,i[u].decode)(r,s,a):c.buffer=new t(r.slice(s,a));return c.length=e.length,c.contentLen=e.contentLen,c.type=e.type,c.version=e.version,c.flags=e.flags,c},n.encodingLength=function(e){var t=e.type,r=8;if(i.fullBoxes[t]&&(r+=4),o[t])o[t].forEach(function(t){if(5===t.length){var i=e[t]||[];t=t.substr(0,4),i.forEach(function(e){e.type=t,r+=n.encodingLength(e)})}else if(e[t]){var o=e[t];o.type=t,r+=n.encodingLength(o)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){r+=n.encodingLength(e)});else if(i[t])r+=i[t].encodingLength(e);else{if(!e.buffer)throw Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");r+=e.buffer.length}return r>4294967295&&(r+=8),e.length=r,r}}).call(this,e("buffer").Buffer)},{"./boxes":51,buffer:24,uint64be:109}],54:[function(e,t,n){(function(n){function r(){if(!(this instanceof r))return new r;o.Writable.call(this),this.destroyed=!1,this._pending=0,this._missing=0,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}function i(e){this._parent=e,this.destroyed=!1,o.PassThrough.call(this)}var o=e("readable-stream"),s=e("inherits"),a=e("next-event"),u=e("mp4-box-encoding"),c=new n(0);t.exports=r,s(r,o.Writable),r.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))},r.prototype._write=function(e,t,n){if(!this.destroyed){for(var r=!this._str||!this._str._writableState.needDrain;e.length&&!this.destroyed;){if(!this._missing)return this._writeBuffer=e,void(this._writeCb=n);var i=e.length<this._missing?e.length:this._missing;if(this._buf?e.copy(this._buf,this._buf.length-this._missing):this._str&&(r=this._str.write(i===e.length?e:e.slice(0,i))),this._missing-=i,!this._missing){var o=this._buf,s=this._cb,a=this._str;this._buf=this._cb=this._str=this._ondrain=null,r=!0,a&&a.end(),s&&s(o)}e=i===e.length?c:e.slice(i)}if(this._pending&&!this._missing)return this._writeBuffer=e,void(this._writeCb=n);r?n():this._ondrain(n)}},r.prototype._buffer=function(e,t){this._missing=e,this._buf=new n(e),this._cb=t},r.prototype._stream=function(e,t){var n=this;return this._missing=e,this._str=new i(this),this._ondrain=a(this._str,"drain"),this._pending++,this._str.on("end",function(){n._pending--,n._
1kick()}),this._cb=t,this._str},r.prototype._readBox=function(){var e=this;(function t(r,i){e._buffer(r,function(r){i=i?n.concat([i,r]):r;var o=u.readHeaders(i);"number"==typeof o?t(o-i.length,i):(e._pending++,e._headers=o,e.emit("box",o))})})(8)},r.prototype.stream=function(){if(!this._headers)throw Error("this function can only be called once after 'box' is emitted");var e=this._headers;return this._headers=null,this._stream(e.contentLen,null)},r.prototype.decode=function(e){var t=this;if(!t._headers)throw Error("this function can only be called once after 'box' is emitted");var n=t._headers;t._headers=null,t._buffer(n.contentLen,function(r){e(u.decodeWithoutHeaders(n,r)),t._pending--,t._kick()})},r.prototype.ignore=function(){var e=this;if(!e._headers)throw Error("this function can only be called once after 'box' is emitted");var t=e._headers;e._headers=null,this._missing=t.contentLen,this._cb=function(){e._pending--,e._kick()}},r.prototype._kick=function(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var e=this._writeCb,t=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(t,null,e)}},s(i,o.PassThrough),i.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}).call(this,e("buffer").Buffer)},{buffer:24,inherits:41,"mp4-box-encoding":53,"next-event":59,"readable-stream":82}],55:[function(e,t,n){(function(n,r){function i(){}function o(){if(!(this instanceof o))return new o;a.Readable.call(this),this.destroyed=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=function(){e._want&&(e._want=!1,e._read())},this._onend=function(){e._stream=null};var e=this}function s(e){this._parent=e,this.destroyed=!1,a.PassThrough.call(this)}var a=e("readable-stream"),u=e("inherits"),c=e("mp4-box-encoding");t.exports=o,u(o,a.Readable),o.prototype.mediaData=o.prototype.mdat=function(e,t){var n=new s(this);return this.box({type:"mdat",contentLength:e,encodeBufferLen:8,stream:n},t),n},o.prototype.box=function(e,t){var o;if(t||(t=i),this.destroyed)return t(Error("Encoder is destroyed"));if(e.encodeBufferLen&&(o=new r(e.encodeBufferLen)),e.stream)e.buffer=null,o=c.encode(e,o),this.push(o),this._stream=e.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",t),this._forward();else{if(o=c.encode(e,o),this.push(o))return n.nextTick(t);this._drain=t}},o.prototype.destroy=function(e){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var t=this._drain;this._drain=null,t(e)}e&&this.emit("error",e),this.emit("close")}},o.prototype.finalize=function(){this.push(null)},o.prototype._forward=function(){if(this._stream)for(;!this.destroyed;){var e=this._stream.read();if(!e)return void(this._want=!!this._stream);if(!this.push(e))return}},o.prototype._read=function(){if(!this._reading&&!this.destroyed){if(this._reading=!0,this._stream&&this._forward(),this._drain){var e=this._drain;this._drain=null,e()}this._reading=!1}},u(s,a.PassThrough),s.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}).call(this,e("_process"),e("buffer").Buffer)},{_process:66,buffer:24,inherits:41,"mp4-box-encoding":53,"readable-stream":82}],56:[function(e,t,n){n.decode=e("./decode"),n.encode=e("./encode")},{"./decode":54,"./encode":55}],57:[function(e,t,n){function r(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}t.exports=function(e,t){t=t||{};var n=typeof e;if("string"===n&&e.length>0)return function(e){if(!((e=String(e)).length>1e4)){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){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*n;case"days":case"day":case"d":return 864e5*n;case"hours":case"hour":case"hrs":case"hr":case"h":return 36e5*n;case"minutes":case"minute":case"mins":case"min":case"m":return 6e4*n;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*n;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);
1if("number"===n&&!1===isNaN(e))return t.long?r(e,864e5,"day")||r(e,36e5,"hour")||r(e,6e4,"minute")||r(e,1e3,"second")||e+" ms":e>=864e5?Math.round(e/864e5)+"d":e>=36e5?Math.round(e/36e5)+"h":e>=6e4?Math.round(e/6e4)+"m":e>=1e3?Math.round(e/1e3)+"s":e+"ms";throw Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],58:[function(e,t,n){function r(e,t){var n=this;if(!(n instanceof r))return new r(e,t);s.Readable.call(n,t),n.destroyed=!1,n._drained=!1,n._forwarding=!1,n._current=null,"function"==typeof e?n._queue=e:(n._queue=e.map(i),n._queue.forEach(function(e){"function"!=typeof e&&n._attachErrorListener(e)})),n._next()}function i(e){if(!e||"function"==typeof e||e._readableState)return e;var t=(new s.Readable).wrap(e);return e.destroy&&(t.destroy=e.destroy.bind(e)),t}t.exports=r;var o=e("inherits"),s=e("readable-stream");o(r,s.Readable),r.obj=function(e){return new r(e,{objectMode:!0,highWaterMark:16})},r.prototype._read=function(){this._drained=!0,this._forward()},r.prototype._forward=function(){if(!this._forwarding&&this._drained&&this._current){this._forwarding=!0;for(var e;null!==(e=this._current.read());)this._drained=this.push(e);this._forwarding=!1}},r.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),"function"!=typeof this._queue&&this._queue.forEach(function(e){e.destroy&&e.destroy()}),e&&this.emit("error",e),this.emit("close"))},r.prototype._next=function(){var e=this;if(e._current=null,"function"==typeof e._queue)e._queue(function(t,n){if(t)return e.destroy(t);n=i(n),e._attachErrorListener(n),e._gotNextStream(n)});else{var t=e._queue.shift();"function"==typeof t&&(t=i(t()),e._attachErrorListener(t)),e._gotNextStream(t)}},r.prototype._gotNextStream=function(e){function t(){r._forward()}function n(){e._readableState.ended||r.destroy()}var r=this;if(!e)return r.push(null),void r.destroy();r._current=e,r._forward(),e.on("readable",t),e.once("end",function i(){r._current=null,e.removeListener("readable",t),e.removeListener("end",i),e.removeListener("close",n),r._next()}),e.once("close",n)},r.prototype._attachErrorListener=function(e){var t=this;e&&e.once("error",function n(r){e.removeListener("error",n),t.destroy(r)})}},{inherits:41,"readable-stream":82}],59:[function(e,t,n){t.exports=function(e,t){var n=null;return e.on(t,function(e){if(n){var t=n;n=null,t(e)}}),function(e){n=e}}},{}],60:[function(e,t,n){function r(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function i(e){var t=function(){if(t.called)throw Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}var o=e("wrappy");t.exports=o(r),t.exports.strict=o(i),r.proto=r(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return r(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return i(this)},configurable:!0})})},{wrappy:118}],61:[function(e,t,n){(function(n){function r(e){n.isBuffer(e)&&(e=s.decode(e)),o(e.info,"info"),o(e.info["name.utf-8"]||e.info.name,"info.name"),o(e.info["piece length"],"info['piece length']"),o(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(function(e){o("number"==typeof e.length,"info.files[0].length"),o(e["path.utf-8"]||e.path,"info.files[0].path")}):o("number"==typeof e.info.length,"info.length");var t={};t.info=e.info,t.infoBuffer=s.encode(e.info),t.infoHash=u.sync(t.infoBuffer),t.infoHashBuffer=new n(t.infoHash,"hex"),t.name=(e.info["name.utf-8"]||e.info.name).toString(),void 0!==e.info.private&&(t.private=!!e.info.private),e["creation date"]&&(t.created=new Date(1e3*e["creation date"])),e["created by"]&&(t.createdBy=e["created by"].toString()),n.isBuffer(e.comment)&&(t.comment=e.comment.toString()),t.announce=[],e["announce-list"]&&e["announce-list"].length?e["announce-list"].forEach(function(e){e.forEach(function(e){t.announce.push(e.toString())})}):e.announce&&t.announce.push(e.announce.toString()),n.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()}),c(t.announce),c(t.urlList);var r=e.info.files||[e.info];t.files=r.map(function(e,n){var o=[].concat(t.name,e["path.utf-8"]||e.path||[]).map(function(e){return e.toString()});return{path:a.join.apply(null,[a.sep].concat(o)).slice(1),name:o[o.length-1],length:e.length,offset:r.slice(0,n).reduce(i,0)}}),t.length=r.reduce(i,0);var f=t.files[t.files.length-1];return t.pieceLength=e.info["piece length"],t.lastPieceLength=(f.offset+f.length)%t.pieceLength||t.pieceLength,t.pieces=function(e){for(var t=[],n=0;n<e.length;n+=20)t.push(e.slice(n,n+20).toString("hex"));return t}(e.info.pieces),t}function i(e,t){return e+t.length}function o(e,t){if(!e)throw Error("Torrent is missing required field: "+t)}t.exports=r,t.exports.decode=r,t.exports.encode=function(e){var t={info:e.info};return t["announce-list"]=(e.announce||[]).map(function(e){return t.announce||(t.announce=e),[e=new n(e,"utf8")]}),t["url-list"]=e.urlList||[],e.created&&(t["creation date"]=e.created.getTime()/1e3|0
1),e.createdBy&&(t["created by"]=e.createdBy),e.comment&&(t.comment=e.comment),s.encode(t)};var s=e("bencode"),a=e("path"),u=e("simple-sha1"),c=e("uniq")}).call(this,e("buffer").Buffer)},{bencode:11,buffer:24,path:63,"simple-sha1":92,uniq:110}],62:[function(e,t,n){(function(n,r){function i(e){if("string"==typeof e&&/^(stream-)?magnet:/.test(e))return u(e);if("string"==typeof e&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e)))return u("magnet:?xt=urn:btih:"+e);if(r.isBuffer(e)&&20===e.length)return u("magnet:?xt=urn:btih:"+e.toString("hex"));if(r.isBuffer(e))return c(e);if(e&&e.infoHash)return e.announce||(e.announce=[]),"string"==typeof e.announce&&(e.announce=[e.announce]),e.urlList||(e.urlList=[]),e;throw Error("Invalid torrent identifier")}t.exports=i,t.exports.remote=function(e,t){var r;function u(e){try{r=i(e)}catch(e){return t(e)}r&&r.infoHash?t(null,r):t(Error("Invalid torrent identifier"))}if("function"!=typeof t)throw Error("second argument must be a Function");try{r=i(e)}catch(e){}r&&r.infoHash?n.nextTick(function(){t(null,r)}):"undefined"!=typeof Blob&&e instanceof Blob?o(e,function(e,n){if(e)return t(Error("Error converting Blob: "+e.message));u(n)}):"function"==typeof a&&/^https?:/.test(e)?a.concat({url:e,timeout:3e4,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,n,r){if(e)return t(Error("Error downloading torrent: "+e.message));u(r)}):"function"==typeof s.readFile&&"string"==typeof e?s.readFile(e,function(e,n){if(e)return t(Error("Invalid torrent identifier"));u(n)}):n.nextTick(function(){t(Error("Invalid torrent identifier"))})};var o=e("blob-to-buffer"),s=e("fs"),a=e("simple-get"),u=e("magnet-uri"),c=e("parse-torrent-file");t.exports.toMagnetURI=u.encode,t.exports.toTorrentFile=c.encode,r.alloc(0)}).call(this,e("_process"),e("buffer").Buffer)},{_process:66,"blob-to-buffer":19,buffer:24,fs:22,"magnet-uri":48,"parse-torrent-file":61,"simple-get":90}],63:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1;r>=0;r--){var i=e[r];"."===i?e.splice(r,1):".."===i?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);return n}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,o=function(e){return i.exec(e).slice(1)};n.resolve=function(){for(var n="",i=!1,o=arguments.length-1;o>=-1&&!i;o--){var s=o>=0?arguments[o]:e.cwd();if("string"!=typeof s)throw TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,i="/"===s.charAt(0))}return n=t(r(n.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+n||"."},n.normalize=function(e){var i=n.isAbsolute(e),o="/"===s(e,-1);return(e=t(r(e.split("/"),function(e){return!!e}),!i).join("/"))||i||(e="."),e&&o&&(e+="/"),(i?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,function(e,t){if("string"!=typeof e)throw TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var i=r(e.split("/")),o=r(t.split("/")),s=Math.min(i.length,o.length),a=s,u=0;u<s;u++)if(i[u]!==o[u]){a=u;break}for(var c=[],u=a;u<i.length;u++)c.push("..");return(c=c.concat(o.slice(a))).join("/")}
1,n.sep="/",n.delimiter=":",n.dirname=function(e){var t=o(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},n.basename=function(e,t){var n=o(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){return o(e)[3]};var s=function(e,t,n){return e.substr(t,n)}}).call(this,e("_process"))},{_process:66}],64:[function(e,t,n){for(var r=e("closest-to"),i=13,o=[];i++<22;)o.push(Math.pow(2,i));t.exports=function(e){return r(e/1024,o)}},{"closest-to":27}],65:[function(e,t,n){(function(e){"use strict";e.version&&0!==e.version.indexOf("v0.")&&(0!==e.version.indexOf("v1.")||0===e.version.indexOf("v1.8."))?t.exports=e.nextTick:t.exports=function(t,n,r,i){if("function"!=typeof t)throw TypeError('"callback" argument must be a function');var o,s,a=arguments.length;switch(a){case 0:case 1:return e.nextTick(t);case 2:return e.nextTick(function(){t.call(null,n)});case 3:return e.nextTick(function(){t.call(null,n,r)});case 4:return e.nextTick(function(){t.call(null,n,r,i)});default:for(o=Array(a-1),s=0;s<o.length;)o[s++]=arguments[s];return e.nextTick(function(){t.apply(null,o)})}}}).call(this,e("_process"))},{_process:66}],66:[function(e,t,n){function r(){throw Error("setTimeout has not been defined")}function i(){throw Error("clearTimeout has not been defined")}function o(e){if(f===setTimeout)return setTimeout(e,0);if((f===r||!f)&&setTimeout)return f=setTimeout,setTimeout(e,0);try{return f(e,0)}catch(t){try{return f.call(null,e,0)}catch(t){return f.call(this,e,0)}}}function s(){m&&l&&(m=!1,l.length?p=l.concat(p):g=-1,p.length&&a())}function a(){if(!m){var e=o(s);m=!0;for(var t=p.length;t;){for(l=p,p=[];++g<t;)l&&l[g].run();g=-1,t=p.length}l=null,m=!1,function(e){if(h===clearTimeout)return clearTimeout(e);if((h===i||!h)&&clearTimeout)return h=clearTimeout,clearTimeout(e);try{h(e)}catch(t){try{return h.call(null,e)}catch(t){return h.call(this,e)}}}(e)}}function u(e,t){this.fun=e,this.array=t}function c(){}var f,h,d=t.exports={};!function(){try{f="function"==typeof setTimeout?setTimeout:r}catch(e){f=r}try{h="function"==typeof clearTimeout?clearTimeout:i}catch(e){h=i}}();var l,p=[],m=!1,g=-1;d.nextTick=function(e){var t=Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new u(e,t)),1!==p.length||m||o(a)},u.prototype.run=function(){this.fun.apply(null,this.array)},d.title="browser",d.browser=!0,d.env={},d.argv=[],d.version="",d.versions={},d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.binding=function(e){throw Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(e){throw Error("process.chdir is not supported")},d.umask=function(){return 0}},{}],67:[function(e,t,n){var r=e("once"),i=e("end-of-stream"),o=e("fs"),s=function(){},a=function(e){return"function"==typeof e},u=function(e,t,n,u){u=r(u);var c=!1;e.on("close",function(){c=!0}),i(e,{readable:t,writable:n},function(e){if(e)return u(e);c=!0,u()});var f=!1;return function(t){if(!c&&!f)return f=!0,o&&(e instanceof(o.ReadStream||s)||e instanceof(o.WriteStream||s))&&a(e.close)?e.close():e.setHeader&&a(e.abort)?e.abort():a(e.destroy)?e.destroy():void u(t||Error("stream was destroyed"))}},c=function(e){e()},f=function(e,t){return e.pipe(t)};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=a(e[e.length-1]||s)&&e.pop()||s;if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw Error("pump requires two streams per minimum");var n,r=e.map(function(i,o){var s=o<e.length-1;return u(i,s,o>0,function(e){n||(n=e),e&&r.forEach(c),s||(r.forEach(c),t(n))})});return e.reduce(f)}},{"end-of-stream":33,fs:21,once:60}],68:[function(t,r,i){(function(t){!function(n){function o(e){throw RangeError(L[e])}function s(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function a(e,t){var n=e.split("@"),r="";return n.length>1&&(r=n[0]+"@",e=n[1]),r+s((e=e.replace(T,".")).split("."),t).join(".")}function u(e){for(var t,n,r=[],i=0,o=e.length;i<o;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<o?56320==(64512&(n=e.charCodeAt(i++)))?r.push(((1023&t)<<10)+(1023&n)+65536):(r.push(t),i--):r.push(t);return r}function c(e){return s(e,function(e){var t="";return e>65535&&(e-=65536,t+=O(e>>>10&1023|55296),e=56320|1023&e),t+=O(e)}).join("")}function f(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function h(e,t,n){var r=0;for(e=n?R(e/x):e>>1,e+=R(e/t);e>U*E>>1;r+=b)e=R(e/U);return R(r+(U+1)*e/(e+k))}function d(e){var t,n,r,i,s,a,u,f,d,l,p,m=[],g=e.length,y=0,_=I,k=S;for((r=e.lastIndexOf(B))<0&&(r=0),i=0;i<r;++i)e.charCodeAt(i)>=128&&o("not-basic"),m.push(e.charCodeAt(i));for(s=r>0?r+1:0;s<g;){for(a=y,u=1,f=b;s>=g&&o("invalid-input"),((d=(t=e.charCodeAt(s++))-48<10?t-22:t-65<26?t-65:t-97<26?t-97:b)>=b||d>R((v-y)/u))&&o("overflow"),y+=d*u,!(d<(l=f<=k?w:f>=k+E?E:f-k));f+=b)u>R(v/(p=b-l))&&o("overflow"),u*=p;k=h(y-a,n=m.length+1,0==a),R(y/n)>v-_&&o("overflow"),_+=R(y/n),y%=n,m.splice(y++,0,_)}return c(m)}function l(e){var t,n,r,i,s,a,c,d,l,p,m,g,y,_,k,x=[];for(g=(e=u(e)).length,t=I,n=0,s=S,a=0;a<g;++a)(m=e[a])<128&&x.push(O(m));for(r=i=x.length,i&&x.push(B);r<g;){for(c=v,a=0;a<g;++a)(m=e[a])>=t&&m<c&&(c=m);for(c-t>R((v-n)/(y=r+1))&&o("overflow"),n+=(c-t)*y,t=c,a=0;a<g;++a)if((m=e[a])<t&&++n>v&&o("overflow"),m==t){for(d=n,l=b;!(d<(p=l<=s?w:l>=s+E?E:l-s));l+=b)k=d-p,_=b-p,x.push(O(f(p+k%_,0))),d=R(k/_);x.push(O(f(d,0))),s=h(n,y,r==i),n=0,++r}++n,++t}return x.join("")}
1var p="object"==typeof i&&i&&!i.nodeType&&i,m="object"==typeof r&&r&&!r.nodeType&&r,g="object"==typeof t&&t;g.global!==g&&g.window!==g&&g.self!==g||(n=g);var y,_,v=2147483647,b=36,w=1,E=26,k=38,x=700,S=72,I=128,B="-",C=/^xn--/,A=/[^\x20-\x7E]/,T=/[\x2E\u3002\uFF0E\uFF61]/g,L={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},U=35,R=Math.floor,O=String.fromCharCode;if(y={version:"1.4.1",ucs2:{decode:u,encode:c},decode:d,encode:l,toASCII:function(e){return a(e,function(e){return A.test(e)?"xn--"+l(e):e})},toUnicode:function(e){return a(e,function(e){return C.test(e)?d(e.slice(4).toLowerCase()):e})}},"function"==typeof e&&"object"==typeof e.amd&&e.amd)e("punycode",function(){return y});else if(p&&m){if(r.exports==p)m.exports=y;else for(_ in y)y.hasOwnProperty(_)&&(p[_]=y[_])}else n.punycode=y}(this)}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],69:[function(e,t,n){"use strict";t.exports=function(e,t,n,i){t=t||"&",n=n||"=";var o={};if("string"!=typeof e||0===e.length)return o;e=e.split(t);var s=1e3;i&&"number"==typeof i.maxKeys&&(s=i.maxKeys);var a=e.length;s>0&&a>s&&(a=s);for(var u=0;u<a;++u){var c,f,h,d,l=e[u].replace(/\+/g,"%20"),p=l.indexOf(n);p>=0?(c=l.substr(0,p),f=l.substr(p+1)):(c=l,f=""),h=decodeURIComponent(c),d=decodeURIComponent(f),Object.prototype.hasOwnProperty.call(o,h)?r(o[h])?o[h].push(d):o[h]=[o[h],d]:o[h]=d}return o};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],70:[function(e,t,n){"use strict";function r(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r<e.length;r++)n.push(t(e[r],r));return n}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,n,a){return t=t||"&",n=n||"=",null===e&&(e=void 0),"object"==typeof e?r(s(e),function(s){var a=encodeURIComponent(i(s))+n;return o(e[s])?r(e[s],function(e){return a+encodeURIComponent(i(e))}).join(t):a+encodeURIComponent(i(e[s]))}).join(t):a?encodeURIComponent(i(a))+n+encodeURIComponent(i(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],71:[function(e,t,n){"use strict";n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":69,"./encode":70}],72:[function(e,t,n){t.exports=function(e){var t=0;return function(){if(t===e.length)return null;var n=Math.random()*(e.length-t)|0,r=e[t+n],i=e[t];return e[t]=r,e[t+n]=i,t++,r}}},{}],73:[function(e,t,r){(function(e,n,r){"use strict";var i=n.crypto||n.msCrypto;i&&i.getRandomValues?t.exports=function(t,o){if(t>65536)throw Error("requested too many random bytes");var s=new n.Uint8Array(t);t>0&&i.getRandomValues(s);var a=new r(s.buffer);return"function"==typeof o?e.nextTick(function(){o(null,a)}):a}:t.exports=function(){throw Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}}).call(this,e("_process"),void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{_process:66,buffer:24}],74:[function(e,t,n){function r(e,t){if(!(this instanceof r))return new r(e);o.Writable.call(this,t),this.destroyed=!1,this._queue=[],this._position=e||0,this._cb=null,this._buffer=null,this._out=null}var i=e("inherits"),o=e("readable-stream");t.exports=r,i(r,o.Writable),r.prototype._write=function(e,t,n){for(var r=!0;;){if(this.destroyed)return;if(0===this._queue.length)return this._buffer=e,void(this._cb=n);this._buffer=null;var i,o=this._queue[0],s=Math.max(o.start-this._position,0),a=o.end-this._position;if(s>=e.length)return this._position+=e.length,n(null);if(a>e.length){this._position+=e.length,i=0===s?e:e.slice(s),r=o.stream.write(i)&&r;break}this._position+=a,i=0===s&&a===e.length?e:e.slice(s,a),r=o.stream.write(i)&&r,o.last&&o.stream.end(),e=e.slice(a),this._queue.shift()}r?n(null):o.stream.once("drain",n.bind(null,null))},r.prototype.slice=function(e){var t=this;if(t.destroyed)return null;e instanceof Array||(e=[e]);var n=new o.PassThrough;return e.forEach(function(r,i){t._queue.push({start:r.start,end:r.end,stream:n,last:i===e.length-1})}),t._buffer&&t._write(t._buffer,null,t._cb),n},r.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit
1("error",e))}},{inherits:41,"readable-stream":82}],75:[function(e,t,n){"use strict";function r(e){if(!(this instanceof r))return new r(e);c.call(this,e),f.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",i)}function i(){this.allowHalfOpen||this._writableState.ended||a(o,this)}function o(e){e.end()}var s=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=r;var a=e("process-nextick-args"),u=e("core-util-is");u.inherits=e("inherits");var c=e("./_stream_readable"),f=e("./_stream_writable");u.inherits(r,c);for(var h=s(f.prototype),d=0;d<h.length;d++){var l=h[d];r.prototype[l]||(r.prototype[l]=f.prototype[l])}},{"./_stream_readable":77,"./_stream_writable":79,"core-util-is":28,inherits:41,"process-nextick-args":65}],76:[function(e,t,n){"use strict";function r(e){if(!(this instanceof r))return new r(e);i.call(this,e)}t.exports=r;var i=e("./_stream_transform"),o=e("core-util-is");o.inherits=e("inherits"),o.inherits(r,i),r.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":78,"core-util-is":28,inherits:41}],77:[function(e,t,n){(function(n){"use strict";function r(t,n){y=y||e("./_stream_duplex"),t=t||{},this.objectMode=!!t.objectMode,n instanceof y&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var r=t.highWaterMark,i=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:i,this.highWaterMark=~~this.highWaterMark,this.buffer=new C,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(B||(B=e("string_decoder/").StringDecoder),this.decoder=new B(t.encoding),this.encoding=t.encoding)}function i(t){if(y=y||e("./_stream_duplex"),!(this instanceof i))return new i(t);this._readableState=new r(t,this),this.readable=!0,t&&"function"==typeof t.read&&(this._read=t.read),w.call(this)}function o(e,t,n,r,i){var o,s,u,f=(o=n,s=null,E.isBuffer(o)||"string"==typeof o||null==o||t.objectMode||(s=TypeError("Invalid non-string/buffer chunk")),s);if(f)e.emit("error",f);else if(null===n)t.reading=!1,function(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,a(e)}}(e,t);else if(t.objectMode||n&&n.length>0){if(t.ended&&!i){var h=Error("stream.push() after EOF");e.emit("error",h)}else if(t.endEmitted&&i){var d=Error("stream.unshift() after end event");e.emit("error",d)}else!t.decoder||i||r||(n=t.decoder.write(n),u=!t.objectMode&&0===n.length),i||(t.reading=!1),u||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&a(e))),t.readingMore||(t.readingMore=!0,_(c,e,t))}else i||(t.reading=!1);return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}function s(e,t){var n;return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=((n=e)>=T?n=T:(n--,n|=n>>>1,n|=n>>>2,n|=n>>>4,n|=n>>>8,n|=n>>>16,n++),n)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function a(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(I("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?_(u,e):u(e))}function u(e){I("emit readable"),e.emit("readable"),d(e)}function c(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(I("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function f(e){I("readable nexttick read 0"),e.read(0)}function h(e,t){t.reading||(I("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),d(e),t.flowing&&!t.reading&&e.read(0)}function d(e){var t=e._readableState;for(I("flow",t.flowing);t.flowing&&null!==e.read(););}function l(e,t){var n,r,i,o;return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):(r=t.buffer,i=t.decoder,e<r.head.data.length?(o=r.head.data.slice(0,e),r.head.data=r.head.data.slice(e)):o=e===r.head.data.length?r.shift():i?function(e,t){var n=t.head,r=1,i=n.data;for(e-=i.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(s===o.length?i+=o:i+=o.slice(0,e),0==(e-=s)){s===o.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(s));break}++r}return t.length-=r,i}(e,r):function(e,t){var n=k.allocUnsafe(e),r=t.head,i=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,s),0==(e-=s)){s===o.length?(++i,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(s));break}++i}return t.length-=i,n}(e,r),n=o),n)}function p(e){var t=e._readableState;if(t.length>0)throw Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,_(m,t,e))}function m(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function g(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return -1}t.exports=i;var y,_=e("process-nextick-args"),v=e("isarray");
1i.ReadableState=r;var b=(e("events").EventEmitter,function(e,t){return e.listeners(t).length}),w=e("./internal/streams/stream"),E=e("buffer").Buffer,k=e("buffer-shims"),x=e("core-util-is");x.inherits=e("inherits");var S=e("util"),I=void 0;I=S&&S.debuglog?S.debuglog("stream"):function(){};var B,C=e("./internal/streams/BufferList");x.inherits(i,w);var A=["error","close","destroy","pause","resume"];i.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding)!==n.encoding&&(e=k.from(e,t),t=""),o(this,n,e,t,!1)},i.prototype.unshift=function(e){return o(this,this._readableState,e,"",!0)},i.prototype.isPaused=function(){return!1===this._readableState.flowing},i.prototype.setEncoding=function(t){return B||(B=e("string_decoder/").StringDecoder),this._readableState.decoder=new B(t),this._readableState.encoding=t,this};var T=8388608;i.prototype.read=function(e){I("read",e),e=parseInt(e,10);var t,n=this._readableState,r=e;if(0!==e&&(n.emittedReadable=!1),0===e&&n.needReadable&&(n.length>=n.highWaterMark||n.ended))return I("read: emitReadable",n.length,n.ended),0===n.length&&n.ended?p(this):a(this),null;if(0===(e=s(e,n))&&n.ended)return 0===n.length&&p(this),null;var i=n.needReadable;return I("need readable",i),(0===n.length||n.length-e<n.highWaterMark)&&I("length less than watermark",i=!0),n.ended||n.reading?I("reading or ended",i=!1):i&&(I("do read"),n.reading=!0,n.sync=!0,0===n.length&&(n.needReadable=!0),this._read(n.highWaterMark),n.sync=!1,n.reading||(e=s(r,n))),null===(t=e>0?l(e,n):null)?(n.needReadable=!0,e=0):n.length-=e,0===n.length&&(n.ended||(n.needReadable=!0),r!==e&&n.ended&&p(this)),null!==t&&this.emit("data",t),t},i.prototype._read=function(e){this.emit("error",Error("_read() is not implemented"))},i.prototype.pipe=function(e,t){function r(e){I("onunpipe"),e===h&&o()}function i(){I("onend"),e.end()}function o(){I("cleanup"),e.removeListener("close",u),e.removeListener("finish",c),e.removeListener("drain",m),e.removeListener("error",a),e.removeListener("unpipe",r),h.removeListener("end",i),h.removeListener("end",o),h.removeListener("data",s),y=!0,l.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&m()}function s(t){I("ondata"),w=!1,!1!==e.write(t)||w||((1===l.pipesCount&&l.pipes===e||l.pipesCount>1&&-1!==g(l.pipes,e))&&!y&&(I("false write response, pause",h._readableState.awaitDrain),h._readableState.awaitDrain++,w=!0),h.pause())}function a(t){I("onerror",t),f(),e.removeListener("error",a),0===b(e,"error")&&e.emit("error",t)}function u(){e.removeListener("finish",c),f()}function c(){I("onfinish"),e.removeListener("close",u),f()}function f(){I("unpipe"),h.unpipe(e)}var h=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=e;break;case 1:l.pipes=[l.pipes,e];break;default:l.pipes.push(e)}l.pipesCount+=1,I("pipe count=%d opts=%j",l.pipesCount,t);var p=t&&!1===t.end||e===n.stdout||e===n.stderr?o:i;l.endEmitted?_(p):h.once("end",p),e.on("unpipe",r);var m=function(){var e=h._readableState;I("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&b(h,"data")&&(e.flowing=!0,d(h))};e.on("drain",m);var y=!1,w=!1;return h.on("data",s),function(e,t,n){if("function"==typeof e.prependListener)return e.prepe
1ndListener(t,n);e._events&&e._events[t]?v(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",a),e.once("close",u),e.once("finish",c),e.emit("pipe",h),l.flowing||(I("pipe resume"),h.resume()),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this)),this;if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i<r;i++)n[i].emit("unpipe",this);return this}var o=g(t.pipes,e);return -1===o||(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this)),this},i.prototype.on=function(e,t){var n=w.prototype.on.call(this,e,t);if("data"===e)!1!==this._readableState.flowing&&this.resume();else if("readable"===e){var r=this._readableState;r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.emittedReadable=!1,r.reading?r.length&&a(this):_(f,this))}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){var e=this._readableState;return e.flowing||(I("resume"),e.flowing=!0,e.resumeScheduled||(e.resumeScheduled=!0,_(h,this,e))),this},i.prototype.pause=function(){return I("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(I("pause"),this._readableState.flowing=!1,this.emit("pause")),this},i.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;for(var i in e.on("end",function(){if(I("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){I("wrapped data"),t.decoder&&(i=t.decoder.write(i)),(!t.objectMode||null!=i)&&(t.objectMode||i&&i.length)&&(r.push(i)||(n=!0,e.pause()))}),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o<A.length;o++)e.on(A[o],r.emit.bind(r,A[o]));return r._read=function(t){I("wrapped _read",t),n&&(n=!1,e.resume())},r},i._fromList=l}).call(this,e("_process"))},{"./_stream_duplex":75,"./internal/streams/BufferList":80,"./internal/streams/stream":81,_process:66,buffer:24,"buffer-shims":23,"core-util-is":28,events:34,inherits:41,isarray:46,"process-nextick-args":65,"string_decoder/":102,util:21}],78:[function(e,t,n){"use strict";function r(e){this.afterTransform=function(t,n){return function(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!=n&&e.push(n),i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&e._read(o.highWaterMark)}(e,t,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function i(e){if(!(this instanceof i))return new i(e);s.call(this,e),this._transformState=new r(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.once("prefinish",function(){"function"==typeof this._flush?this._flush(function(e,n){o(t,e,n)}):o(t)})}function o(e,t,n){if(t)return e.emit("error",t);null!=n&&e.push(n);var r=e._writableState,i=e._transformState;if(r.length)throw Error("Calling transform done when ws.length != 0");if(i.transforming)throw Error("Calling transform done when still transforming");return e.push(null)}t.exports=i;var s=e("./_stream_duplex"),a=e("core-util-is");a.inherits=e("inherits"),a.inherits(i,s),i.prototype.push=function(e,t){return this._transformState.needTransform=!1,s.prototype.push.call(this,e,t)},i.prototype._transform=function(e,t,n){throw Error("_transform() is not implemented")},i.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},i.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0}},{"./_stream_duplex":75,"core-util-is":28,inherits:41}],79:[function(e,t,n){(function(n){"use strict";function r(){}function i(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function o(t,n){m=m||e("./_stream_duplex"),t=t||{},this.objectMode=!!t.objectMode,n instanceof m&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var r=t.highWaterMark,i=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:i,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var o=!1===t.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){(function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(n.writing=!1,n.writecb=null,n.length-=n.writelen,n.writelen=0,t)--n.pendingcb,r?g(i,t):i(t),e._writableState.errorEmitted=!0,e.emit("error",t);else{var o=f(n);o||n.corked||n.bufferProcessing||!n.bufferedRequest||c(e,n),r?y(u,e,n,o,i):u(e,n,o,i)}})(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new l(this)}function s(t){if(m=m||e("./_stream_duplex"),!(p.call(s,this)||this instanceof m))return new s(t);this._writableState=new o(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev)),b.call(this)}function a(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function u(e,t,n,r){n||0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain")),t.pendingcb--,r(),d(e,t)}function c(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=Array(t.bufferedRequestCount),i=t.corkedRequestsFree;i.entry=n;for(var o=0;n;)r[o]=n,n=n.next,o+=1;a(e,t,!0,t.length,r,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new l(t)}else{for(;n;){var s=n.chunk,u=n.encoding,c=n.callback;if(a(e,t,!1,t.objectMode?1:s.length,s,u,c),n=n.next,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequestCount=0,t.bufferedRequest=n,t.bufferProcessing=!1}function f(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function h(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function d(e,t){var n=f(t);return n&&(0===t.pendingcb?(h(e,t),t.finished=!0,e.emit("finish")):h(e,t)),n}function l(e){var t=this;this.next=null,this.entry=null,this.finish=function(n){var r=t.entry;for(t.entry=null;r;){var i=r.callback;e.pendingcb--,i(n),r=r.next}e.corkedRequestsFree?e.corkedRequestsFree.next=t:e.corkedRequestsFree=t}}t.exports=s;var p,m,g=e("process-nextick-args"),y=!n.browser&&["v0.10","v0.9."].indexOf(n.version.slice(0,5))>-1?setImmediate:g;s.WritableState=o;var _=e("core-util-is");_.inherits=e("inherits");var v={deprecate:e("util-deprecate")}
1,b=e("./internal/streams/stream"),w=e("buffer").Buffer,E=e("buffer-shims");_.inherits(s,b),o.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(o.prototype,"buffer",{get:v.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(s,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||e&&e._writableState instanceof o}})):p=function(e){return e instanceof this},s.prototype.pipe=function(){this.emit("error",Error("Cannot pipe, not readable"))},s.prototype.write=function(e,t,n){var o,s,u,c,f,h=this._writableState,d=!1,l=w.isBuffer(e);return"function"==typeof t&&(n=t,t=null),l?t="buffer":t||(t=h.defaultEncoding),"function"!=typeof n&&(n=r),h.ended?(o=n,s=Error("write after end"),this.emit("error",s),g(o,s)):(l||(u=n,c=!0,f=!1,null===e?f=TypeError("May not write null values to stream"):"string"==typeof e||void 0===e||h.objectMode||(f=TypeError("Invalid non-string/buffer chunk")),f&&(this.emit
1("error",f),g(u,f),c=!1),c))&&(h.pendingcb++,d=function(e,t,n,r,o,s){n||(u=r,c=o,t.objectMode||!1===t.decodeStrings||"string"!=typeof u||(u=E.from(u,c)),r=u,w.isBuffer(r)&&(o="buffer"));var u,c,f=t.objectMode?1:r.length;t.length+=f;var h=t.length<t.highWaterMark;if(h||(t.needDrain=!0),t.writing||t.corked){var d=t.lastBufferedRequest;t.lastBufferedRequest=new i(r,o,s),d?d.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else a(e,t,!1,f,r,o,s);return h}(this,h,l,e,t,n)),d},s.prototype.cork=function(){this._writableState.corked++},s.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||c(this,e))},s.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},s.prototype._write=function(e,t,n){n(Error("_write() is not implemented"))},s.prototype._writev=null,s.prototype.end=function(e,t,n){var r,i=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||(r=n,i.ending=!0,d(this,i),r&&(i.finished?g(r):this.once("finish",r)),i.ended=!0,this.writable=!1)}}).call(this,e("_process"))},{"./_stream_duplex":75,"./internal/streams/stream":81,_process:66,buffer:24,"buffer-shims":23,"core-util-is":28,inherits:41,"process-nextick-args":65,"util-deprecate":115}],80:[function(e,t,n){"use strict";function r(){this.head=null,this.tail=null,this.length=0}var i=(e("buffer").Buffer,e("buffer-shims"));t.exports=r,r.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},r.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},r.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},r.prototype.clear=function(){this.head=this.tail=null,this.length=0},r.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},r.prototype.concat=function(e){if(0===this.length)return i.alloc(0);if(1===this.length)return this.head.data;for(var t=i.allocUnsafe(e>>>0),n=this.head,r=0;n;)n.data.copy(t,r),r+=n.data.length,n=n.next;return t}},{buffer:24,"buffer-shims":23}],81:[function(e,t,n){t.exports=e("events").EventEmitter},{events:34}],82:[function(e,t,n){(n=t.exports=e("./lib/_stream_readable.js")).Stream=n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":75,"./lib/_stream_passthrough.js":76,"./lib/_stream_readable.js":77,"./lib/_stream_transform.js":78,"./lib/_stream_writable.js":79}],83:[function(e,t,n){function r(e,t,n,r){function o(){E.removeEventListener("loadstart",o),n.autoplay&&E.play()}function s(){E.removeEventListener("canplay",s),r(null,E)}function h(){E=t("iframe"),i(e,function(e,t){if(e)return v(e);E.src=t,".pdf"!==k&&(E.sandbox="allow-forms allow-scripts"),r(null,E)})}function v(t){t.message='Error rendering file "'+e.name+'": '+t.message,a(t.message),r(t)}var w,E,k=f.extname(e.name).toLowerCase(),x=0;m.indexOf(k)>=0?function(){function r(){a("Use MediaSource API for "+e.name),m(),E.addEventListener("error",h),E.addEventListener("loadstart",o),E.addEventListener("canplay",s);var t,n=new c(E).createWriteStream((t=e.name,({".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4v":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".mkv":'video/webm; codecs="avc1.640029, mp4a.40.5"',".mp3":"audio/mpeg",".mp4":'video/mp4; codecs="avc1.640029, mp4a.40.5"',".webm":'video/webm; codecs="vorbis, vp8"'})[f.extname(t).toLowerCase()]));e.createReadStream().pipe(n),x&&(E.currentTime=x)}function u(){a("Use Blob URL for "+e.name),m(),E.addEventListener("error",v),E.addEventListener("loadstart",o),E.addEventListener("canplay",s),i(e,function(e,t){if(e)return v(e);E.src=t,x&&(E.currentTime=x)})}function h(t){if(a("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>n.maxBlobLength)return a("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),v(Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")"));E.removeEventListener("error",h),E.removeEventListener("canplay",s),u()}function m(){E||(E=t(g)).addEventListener("progress",function(){x=E.currentTime})}var g=p.indexOf(k)>=0?"video":"audio";b?l.indexOf(k)>=0?(a("Use `videostream` package for "+e.name),m(),E.addEventListener("error",function e(t){a("videostream error: fallback to MediaSource API: %o",t.message||t),E.removeEventListener("error",e),E.removeEventListener("canplay",s),r()}),E.addEventListener("loadstart",o),E.addEventListener("canplay",s),d(e,E)):r():u()}():g.indexOf(k)>=0?(E=t("audio"),i(e,function(e,t){if(e)return v(e);E.addEventListener("error",v),E.addEventListener("loadstart",o),E.addEventListener("canplay",s),E.src=t})):y.indexOf(k)>=0?(E=t("img"),i(e,function(t,n){if(t)return v(t);E.src=n,E.alt=e.name,r(null,E)}
1)):_.indexOf(k)>=0?h():(a('Unknown file extension "%s" - will attempt to render into iframe',k),w="",e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){w+=e}).on("end",function(){u(w)?(a('File extension "%s" appears ascii, so will render.',k),h()):(a('File extension "%s" appears non-ascii, will not render.',k),r(Error('Unsupported file type "'+k+'": Cannot append to DOM')))}).on("error",r))}function i(e,t){var r=f.extname(e.name).toLowerCase();h(e.createReadStream(),n.mime[r],t)}function o(e){if(null==e)throw Error("file cannot be null or undefined");if("string"!=typeof e.name)throw Error("missing or invalid file.name property");if("function"!=typeof e.createReadStream)throw Error("missing or invalid file.createReadStream property")}function s(e){null==e.autoplay&&(e.autoplay=!0),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=v)}n.render=function(e,t,n,i){"function"==typeof n&&(i=n,n={}),n||(n={}),i||(i=function(){}),o(e),s(n),"string"==typeof t&&(t=document.querySelector(t)),r(e,function(n){if(t.nodeName!==n.toUpperCase())throw Error('Cannot render "'+f.extname(e.name).toLowerCase()+'" inside a "'+t.nodeName.toLowerCase()+'" element, expected "'+n+'"');return t},n,i)},n.append=function(e,t,n,i){function a(e){var n=document.createElement(e);return t.appendChild(n),n}if("function"==typeof n&&(i=n,n={}),n||(n={}),i||(i=function(){}),o(e),s(n),"string"==typeof t&&(t=document.querySelector(t)),t&&("VIDEO"===t.nodeName||"AUDIO"===t.nodeName))throw Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");r(e,function(e){var r;return"video"===e||"audio"===e?(r=a(e),n.controls&&(r.controls=!0),n.autoplay&&(r.autoplay=!0),t.appendChild(r),r):a(e)},n,function(e,t){e&&t&&t.remove(),i(e,t)})},n.mime=e("./lib/mime.json");var a=e("debug")("render-media"),u=e("is-ascii"),c=e("mediasource"),f=e("path"),h=e("stream-to-blob-url"),d=e("videostream"),l=[".m4a",".m4v",".mp4"],p=[".m4v",".mkv",".mp4",".webm"],m=[].concat(p,[".m4a",".mp3"]),g=[".aac",".oga",".ogg",".wav"],y=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],_=[".css",".html",".js",".md",".pdf",".txt"],v=2e8,b="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":84,debug:30,"is-ascii":42,mediasource:49,path:63,"stream-to-blob-url":99,videostream:117}],84:[function(e,t,n){t.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/plain",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/mp4",".m4v":"video/mp4",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},{}],85:[function(e,t,n){(function(e){t.exports=function(t,n,r){function i(t){function n(){r&&r(t,s),r=null}h?e.nextTick(n):n()}function o(e,n,r){if(s[e]=r,n&&(f=!0),0==--u||n)i(n);else if(!f&&d<a){var h;c?(h=c[d],d+=1,t[h](function(e,t){o(h,e,t)})):(h=d,d+=1,t[h](function(e,t){o(h,e,t)}))}}if("number"!=typeof n)throw Error("second argument must be a Number");var s,a,u,c,f,h=!0;Array.isArray(t)?(s=[],u=a=t.length):(c=Object.keys(t),s={},u=a=c.length);var d=n;u?c?c.some(function(e,r){if(t[e](function(t,n){o(e,t,n)}),r===n-1)return!0}):t.some(function(e,t){if(e(function(e,n){o(t,e,n)}),t===n-1)return!0}):i(null),h=!1}}).call(this,e("_process"))},{_process:66}],86:[function(e,t,n){(function(e){t.exports=function(t,n){function r(t){function r(){n&&n(t,o),n=null}u?e.nextTick(r):r()}function i(e,t,n){o[e]=n,(0==--s||t)&&r(t)}var o,s,a,u=!0;Array.isArray(t)?(o=[],s=t.length):(a=Object.keys(t),o={},s=a.length),s?a?a.forEach(function(e){t[e](function(t,n){i(e,t,n)})}):t.forEach(function(e,t){e(function(e,n){i(t,e,n)})}):r(null),u=!1}}).call(this,e("_process"))},{_process:66}],87:[function(e,t,r){(function(e){!function(){function n(e){"use strict";for(var t={fill:0},o=function(e){for(e+=9;e%64>0;e+=1);return e},s=function(e,t){var n=new Uint8Array(e.buffer),r=t%4,i=t-r;switch(r){case 0:n[i+3]=0;case 1:n[i+2]=0;case 2:n[i+1]=0;case 3:n[i+0]=0}for(var o=1+(t>>2);o<e.length;o++)e[o]=0},a=function(e,t,n){e[t>>2]|=128<<24-(t%4<<3),e[14+(2+(t>>2)&-16)]=n/536870912|0,e[15+(2+(t>>2)&-16)]=n<<3},u=function(e,t,n,r,i){var o,s=i%4,a=(r+s)%4,u=r-a;switch(s){case 0:e[i]=this.charCodeAt(n+3);case 1:e[i+1-(s<<1)|0]=this.charCodeAt(n+2);case 2:e[i+2-(s<<1)|0]=this.charCodeAt(n+1);case 3:e[i+3-(s<<1)|0]=this.charCodeAt(n)}
1if(!(r<a+s)){for(o=4-s;o<u;o=o+4|0)t[i+o>>2]=this.charCodeAt(n+o)<<24|this.charCodeAt(n+o+1)<<16|this.charCodeAt(n+o+2)<<8|this.charCodeAt(n+o+3);switch(a){case 3:e[i+u+1|0]=this.charCodeAt(n+u+2);case 2:e[i+u+2|0]=this.charCodeAt(n+u+1);case 1:e[i+u+3|0]=this.charCodeAt(n+u)}}},c=function(e,t,n,r,i){var o,s=i%4,a=(r+s)%4,u=r-a;switch(s){case 0:e[i]=this[n+3];case 1:e[i+1-(s<<1)|0]=this[n+2];case 2:e[i+2-(s<<1)|0]=this[n+1];case 3:e[i+3-(s<<1)|0]=this[n]}if(!(r<a+s)){for(o=4-s;o<u;o=o+4|0)t[i+o>>2|0]=this[n+o]<<24|this[n+o+1]<<16|this[n+o+2]<<8|this[n+o+3];switch(a){case 3:e[i+u+1|0]=this[n+u+2];case 2:e[i+u+2|0]=this[n+u+1];case 1:e[i+u+3|0]=this[n+u]}}},f=function(e,t,n,r,o){var s,a=o%4,u=(r+a)%4,c=r-u,f=new Uint8Array(i.readAsArrayBuffer(this.slice(n,n+r)));switch(a){case 0:e[o]=f[3];case 1:e[o+1-(a<<1)|0]=f[2];case 2:e[o+2-(a<<1)|0]=f[1];case 3:e[o+3-(a<<1)|0]=f[0]}if(!(r<u+a)){for(s=4-a;s<c;s=s+4|0)t[o+s>>2|0]=f[s]<<24|f[s+1]<<16|f[s+2]<<8|f[s+3];switch(u){case 3:e[o+c+1|0]=f[c+2];case 2:e[o+c+2|0]=f[c+1];case 1:e[o+c+3|0]=f[c]}}},h=function(e){switch(r.getDataType(e)){case"string":return u.bind(e);case"array":case"buffer":return c.bind(e);case"arraybuffer":return c.bind(new Uint8Array(e));case"view":return c.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return f.bind(e)}},d=Array(256),l=0;l<256;l++)d[l]=(l<16?"0":"")+l.toString(16);var p=function(e){for(var t=new Uint8Array(e),n=Array(e.byteLength),r=0;r<n.length;r++)n[r]=d[t[r]];return n.join("")},m=function(e){var t;if(e<=65536)return 65536;if(e<16777216)for(t=1;t<e;t<<=1);else for(t=16777216;t<e;t+=16777216);return t};!function(e){if(e%64>0)throw Error("Chunk size must be a multiple of 128 bit");t.offset=0,t.maxChunkLen=e,t.padMaxChunkLen=o(e),t.heap=new ArrayBuffer(m(t.padMaxChunkLen+320+20)),t.h32=new Int32Array(t.heap),t.h8=new Int8Array(t.heap),t.core=new n._core({Int32Array:Int32Array,DataView:DataView},{},t.heap),t.buffer=null}(e||65536);var g=function(e,n){t.offset=0;var r=new Int32Array(e,n+320,5);r[0]=1732584193,r[1]=-271733879,r[2]=-1732584194,r[3]=271733878,r[4]=-1009589776},y=function(e,n){var r=o(e),i=new Int32Array(t.heap,0,r>>2);return s(i,e),a(i,e,n),r},_=function(e,n,r,i){h(e)(t.h8,t.h32,n,r,i||0)},v=function(e,n,r,i,o){var s=r;_(e,n,r),o&&(s=y(r,i)),t.core.hash(s,t.padMaxChunkLen)},b=function(e,t){var n=new Int32Array(e,t+320,5),r=new Int32Array(5),i=new DataView(r.buffer);return i.setInt32(0,n[0],!1),i.setInt32(4,n[1],!1),i.setInt32(8,n[2],!1),i.setInt32(12,n[3],!1),i.setInt32(16,n[4],!1),r},w=this.rawDigest=function(e){var n=e.byteLength||e.length||e.size||0;g(t.heap,t.padMaxChunkLen);var r=0,i=t.maxChunkLen;for(r=0;n>r+i;r+=i)v(e,r,i,n,!1);return v(e,r,n-r,n,!0),b(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return p(w(e).buffer)},this.resetState=function(){return g(t.heap,t.padMaxChunkLen),this},this.append=function(e){var n,r=0,i=e.byteLength||e.length||e.size||0,o=t.offset%t.maxChunkLen;for(t.offset+=i;r<i;)n=Math.min(i-r,t.maxChunkLen-o),_(e,r,n,o),o+=n,r+=n,o===t.maxChunkLen&&(t.core.hash(t.maxChunkLen,t.padMaxChunkLen),o=0);return this},this.getState=function(){var e;if(t.offset%t.maxChunkLen)e=t.heap.slice(0);else{var n=new Int32Array(t.heap,t.padMaxChunkLen+320,5);e=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}return{offset:t.offset,heap:e}},this.setState=function(e){return(t.offset=e.offset,20===e.heap.byteLength)?new Int32Array(t.heap,t.padMaxChunkLen+320,5).set(new Int32Array(e.heap)):t.h32.set(new Int32Array(e.heap)),this};var E=this.rawEnd=function(){var e=t.offset,n=y(e%t.maxChunkLen,e);t.core.hash(n,t.padMaxChunkLen);var r=b(t.heap,t.padMaxChunkLen);return g(t.heap,t.padMaxChunkLen),r};this.end=function(){return p(E().buffer)}}var r={getDataType:function(t){if("string"==typeof t)return"string";if(t instanceof Array)return"array";if(void 0!==e&&e.Buffer&&e.Buffer.isBuffer(t))return"buffer";if(t instanceof ArrayBuffer)return"arraybuffer";if(t.buffer instanceof ArrayBuffer)return"view";if(t instanceof Blob)return"blob";throw Error("Unsupported data type.")}};if(n._core=function(e,t,n){"use asm";var r=new e.Int32Array(n);function i(e,t){e=e|0;t=t|0;var n=0,i=0,o=0,s=0,a=0,u=0,c=0,f=0,h=0,d=0,l=0,p=0,m=0,g=0;o=r[t+320>>2]|0;a=r[t+324>>2]|0;c=r[t+328>>2]|0;h=r[t+332>>2]|0;l=r[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){s=o;u=a;f=c;d=h;p=l;for(i=0;(i|0)<64;i=i+4|0){g=r[n+i>>2]|0;m=((o<<5|o>>>27)+(a&c|~a&h)|0)+((g+l|0)+1518500249|0)|0;l=h;h=c;c=a<<30|a>>>2;a=o;o=m;r[e+i>>2]=g}for(i=e+64|0;(i|0)<(e+80|0);i=i+4|0){g=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;m=((o<<5|o>>>27)+(a&c|~a&h)|0)+((g+l|0)+1518500249|0)|0;l=h;h=c;c=a<<30|a>>>2;a=o;o=m;r[i>>2]=g}for(i=e+80|0;(i|0)<(e+160|0);i=i+4|0){g=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;m=((o<<5|o>>>27)+(a^c^h)|0)+((g+l|0)+1859775393|0)|0;l=h;h=c;c=a<<30|a>>>2;a=o;o=m;r[i>>2]=g}for(i=e+160|0;(i|0)<(e+240|0);i=i+4|0){g=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;m=((o<<5|o>>>27)+(a&c|a&h|c&h)|0)+((g+l|0)-1894007588|0)|0;l=h;h=c;c=a<<30|a>>>2;a=o;o=m;r[i>>2]=g}for(i=e+240|0;(i|0)<(e+320|0);i=i+4|0){g=(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])<<1|(r[i-12>>2]^r[i-32>>2]^r[i-56>>2]^r[i-64>>2])>>>31;m=((o<<5|o>>>27)+(a^c^h)|0)+((g+l|0)-899497514|0)|0;l=h;h=c;c=a<<30|a>>>2;a=o;o=m;r[i>>2]=g}o=o+s|0;a=a+u|0;c=c+f|0;h=h+d|0;l=l+p|0}r[t+320>>2]=o;r[t+324>>2]=a;r[t+328>>2]=c;r[t+332>>2]=h;r[t+336>>2]=l}return{hash:i}},void 0!==t?t.exports=n:"undefined"!=typeof window&&(window.Rusha=n),"undefined"!=typeof FileReaderSync){var i=new FileReaderSync,o=new n(4194304);self.onmessage=function(e){var t,n=e.data.data;try{t=o.digest(n),self.postMessage({id:e.data.id,hash:t})}catch(t){self.postMessage({id:e.data.id,error:t.name})}}}}()}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],88:[function(e,t,n){t.exports=e("buffer")},{buffer:24}],89:[function(e,t,n){(function(e){t.exports=function(t,n){var r=[];t.on("data",function(e){r.push(e)}),t.once("end",function(){n&&n(null,e.concat(r)),n=null}),t.once("error",function(e){n&&n(e),n=null})}}).call(this,e("buffer").Buffer)},{buffer:24}],90:[function(e,t,n){(function(n){function r(e,t){e="string"==typeof e?{url:e}:Object.assign({},e),t=a(t),e.url&&(i=e,(h=f.parse(i.url)).hostname&&(i.hostname=h.hostname),h.port&&(i.port=h.port),h.protocol&&(i.protocol=h.protocol),h.auth&&(i.auth=h.auth),i.path=h.path,delete i.url),null==e.headers&&(e.headers={}),null==e.maxRedirects&&(e.maxRedirects=10),e.form&&(d="string"==typeof e.form?e.form:u.stringify(e.form)),e.body&&(d=e.json?JSON.stringify(e.body):e.body),e.json&&(e.headers.accept="application/json"),e.json&&d&&(e.headers["content-type"]="application/json"),e.form&&(e.headers["content-type"]="application/x-www-form-urlencoded"),d&&(e.headers["content-length"]=n.byteLength(d)),delete e.body,delete e.form,d&&!e.method&&(e.method="POST"),e.method&&(e.method=e.method.toUpperCase()),Object.keys(e.headers).some(function(e){return"accept-encoding"===e.toLowerCase()})||(e.headers["accept-encoding"]="gzip, deflate");var i,h,d,l=("https:"===e.protocol?s:o).request(e,function(n){if(n.statusCode>=300&&n.statusCode<400&&"location"in n.headers)return e.url=n.headers.location,n.resume(),void(e.maxRedirects>0?(e.maxRedirects-=1,r(e,t)):t(Error("too many redirects")));var i="function"==typeof c&&"HEAD"!==e.method;t(null,i?c(n):n)});return l.on("timeout",function(){l.abort(),t(Error("Request timed out"))}),l.on("error",t),l.end(d),l}t.exports=r;var i=e("simple-concat"),o=e("http"),s=e("https"),a=e("once"),u=e("querystring"),c=e("unzip-response"),f=e("url");r.concat=function(e,t){return r(e,function(n,r){if(n)return t(n);
1i(r,function(n,i){if(n)return t(n);if(e.json)try{i=JSON.parse(i.toString())}catch(e){return t(e,r,i)}t(null,r,i)})})},["get","post","put","patch","head","delete"].forEach(function(e){r[e]=function(t,n){return"string"==typeof t&&(t={url:t}),t.method=e.toUpperCase(),r(t,n)}})}).call(this,e("buffer").Buffer)},{buffer:24,http:95,https:38,once:60,querystring:71,"simple-concat":89,"unzip-response":21,url:112}],91:[function(e,t,n){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(t._id=u(4).toString("hex").slice(0,7),t._debug("new peer %o",e),e=Object.assign({allowHalfOpen:!1},e),c.Duplex.call(t,e),t.channelName=e.initiator?e.channelName||u(20).toString("hex"):null,t._isChromium="undefined"!=typeof window&&!!window.webkitRTCPeerConnection,t.initiator=e.initiator||!1,t.channelConfig=e.channelConfig||r.channelConfig,t.config=e.config||r.config,t.constraints=t._transformConstraints(e.constraints||r.constraints),t.offerConstraints=t._transformConstraints(e.offerConstraints||{}),t.answerConstraints=t._transformConstraints(e.answerConstraints||{}),t.reconnectTimer=e.reconnectTimer||!1,t.sdpTransform=e.sdpTransform||function(e){return e},t.stream=e.stream||!1,t.trickle=void 0===e.trickle||e.trickle,t.destroyed=!1,t.connected=!1,t.remoteAddress=void 0,t.remoteFamily=void 0,t.remotePort=void 0,t.localAddress=void 0,t.localPort=void 0,t._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:s(),!t._wrtc)throw"undefined"==typeof window?Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):Error("No WebRTC support: Not a supported browser");if(t._pcReady=!1,t._channelReady=!1,t._iceComplete=!1,t._channel=null,t._pendingCandidates=[],t._previousStreams=[],t._chunk=null,t._cb=null,t._interval=null,t._reconnectTimeout=null,t._pc=new t._wrtc.RTCPeerConnection(t.config,t.constraints),t._isWrtc=Array.isArray(t._pc.RTCIceConnectionStates),t._isReactNativeWebrtc="number"==typeof t._pc._peerConnectionId,t._pc.oniceconnectionstatechange=function(){t._onIceStateChange()},t._pc.onicegatheringstatechange=function(){t._onIceStateChange()},t._pc.onsignalingstatechange=function(){t._onSignalingStateChange()},t._pc.onicecandidate=function(e){t._onIceCandidate(e)},t.initiator){var n=!1;t._pc.onnegotiationneeded=function(){n||t._createOffer(),n=!0},t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)})}else t._pc.ondatachannel=function(e){t._setupData(e)};"addTrack"in t._pc?(t.stream&&t.stream.getTracks().forEach(function(e){t._pc.addTrack(e,t.stream)}),t._pc.ontrack=function(e){t._onTrack(e)}):(t.stream&&t._pc.addStream(t.stream),t._pc.onaddstream=function(e){t._onAddStream(e)}),t.initiator&&t._isWrtc&&t._pc.onnegotiationneeded(),t._onFinishBound=function(){t._onFinish()},t.once("finish",t._onFinishBound)}function i(){}t.exports=r;var o=e("debug")("simple-peer"),s=e("get-browser-rtc"),a=e("inherits"),u=e("randombytes"),c=e("readable-stream");a(r,c.Duplex),r.WEBRTC_SUPPORT=!!s(),r.config={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:global.stun.twilio.com:3478?transport=udp"}]},r.constraints={},r.channelConfig={},Object.defineProperty(r.prototype,"bufferSize",{get:function(){return this._channel&&this._channel.bufferedAmount||0}}),r.prototype.address=function(){return{port:this.localPort,family:"IPv4",address:this.localAddress}},r.prototype.signal=function(e){var t=this;if(t.destroyed)throw Error("cannot signal after peer is destroyed");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}t._debug("signal()"),e.candidate&&(t._pc.remoteDescription?t._addIceCandidate(e.candidate):t._pendingCandidates.push(e.candidate)),e.sdp&&t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e),function(){t.destroyed||(t._pendingCandidates.forEach(function(e){t._addIceCandidate(e)}),t._pendingCandidates=[],"offer"===t._pc.remoteDescription.type&&t._createAnswer())},function(e){t._destroy(e)}),e.sdp||e.candidate||t._destroy(Error("signal() called with invalid signal data"))},r.prototype._addIceCandidate=function(e){var t=this;try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e),i,function(e){t._destroy(e)})}catch(e){t._destroy(Error("error adding candidate: "+e.message))}},r.prototype.send=function(e){this._isWrtc&&n.isBuffer(e)&&(e=new Uint8Array(e)),this._channel.send(e)},r.prototype.destroy=function(e){this._destroy(null,e)}
1,r.prototype._destroy=function(e,t){if(!this.destroyed){if(t&&this.once("close",t),this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.destroyed=!0,this.connected=!1,this._pcReady=!1,this._channelReady=!1,this._previousStreams=null,clearInterval(this._interval),clearTimeout(this._reconnectTimeout),this._interval=null,this._reconnectTimeout=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._pc){try{this._pc.close()}catch(e){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,"addTrack"in this._pc?this._pc.ontrack=null:this._pc.onaddstream=null,this._pc.onnegotiationneeded=null,this._pc.ondatachannel=null}if(this._channel){try{this._channel.close()}catch(e){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}this._pc=null,this._channel=null,e&&this.emit("error",e),this.emit("close")}},r.prototype._setupData=function(e){var t=this;if(!e.channel)return t._destroy(Error("Data channel event is missing `channel` property"));t._channel=e.channel,t._channel.binaryType="arraybuffer","number"==typeof t._channel.bufferedAmountLowThreshold&&(t._channel.bufferedAmountLowThreshold=65536),t.channelName=t._channel.label,t._channel.onmessage=function(e){t._onChannelMessage(e)},t._channel.onbufferedamountlow=function(){t._onChannelBufferedAmountLow()},t._channel.onopen=function(){t._onChannelOpen()},t._channel.onclose=function(){t._onChannelClose()},t._channel.onerror=function(e){t._destroy(e)}},r.prototype._read=function(){},r.prototype._write=function(e,t,n){if(this.destroyed)return n(Error("cannot write after peer is destroyed"));if(this.connected){try{this.send(e)}catch(e){return this._destroy(e)}this._channel.bufferedAmount>65536?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n},r.prototype._onFinish=function(){function e(){setTimeout(function(){t._destroy()},1e3)}var t=this;t.destroyed||(t.connected?e():t.once("connect",e))},r.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(function(t){function n(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))},function(t){e._destroy(t)}))},function(t){e._destroy(t)},e.offerConstraints)},r.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(function(t){function n(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))},function(t){e._destroy(t)}))},function(t){e._destroy(t)},e.answerConstraints)},r.prototype._onIceStateChange=function(){var e=this;if(!e.destroyed){var t=e._pc.iceConnectionState,n=e._pc.iceGatheringState;e._debug("iceStateChange (connection: %s) (gathering: %s)",t,n),e.emit("iceStateChange",t,n),"connected"!==t&&"completed"!==t||(clearTimeout(e._reconnectTimeout),e._pcReady=!0,e._maybeReady()),"disconnected"===t&&(e.reconnectTimer?(clearTimeout(e._reconnectTimeout),e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)):e._destroy()),"failed"===t&&e._destroy(Error("Ice connection failed.")),"closed"===t&&e._destroy()}},r.prototype.getStats=function(e){0===this._pc.getStats.length?this._pc.getStats().then(function(t){var n=[];t.forEach(function(e){n.push(e)}),e(null,n)},function(t){e(t)}):this._isReactNativeWebrtc?this._pc.getStats(null,function(t){var n=[];t.forEach(function(e){n.push(e)}),e(null,n)},function(t){e(t)}):this._pc.getStats.length>0?this._pc.getStats(function(t){var n=[];
1t.result().forEach(function(e){var t={};e.names().forEach(function(n){t[n]=e.stat(n)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,n.push(t)}),e(null,n)},function(t){e(t)}):e(null,[])},r.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady),!e.connected&&!e._connecting&&e._pcReady&&e._channelReady&&(e._connecting=!0,e.getStats(function(t,n){function r(t){var n=o[t.localCandidateId];n&&n.ip?(e.localAddress=n.ip,e.localPort=Number(n.port)):n&&n.ipAddress?(e.localAddress=n.ipAddress,e.localPort=Number(n.portNumber)):"string"==typeof t.googLocalAddress&&(n=t.googLocalAddress.split(":"),e.localAddress=n[0],e.localPort=Number(n[1]));var r=i[t.remoteCandidateId];r&&r.ip?(e.remoteAddress=r.ip,e.remotePort=Number(r.port)):r&&r.ipAddress?(e.remoteAddress=r.ipAddress,e.remotePort=Number(r.portNumber)):"string"==typeof t.googRemoteAddress&&(r=t.googRemoteAddress.split(":"),e.remoteAddress=r[0],e.remotePort=Number(r[1])),e.remoteFamily="IPv4",e._debug("connect local: %s:%s remote: %s:%s",e.localAddress,e.localPort,e.remoteAddress,e.remotePort)}if(!e.destroyed){t&&(n=[]),e._connecting=!1,e.connected=!0;var i={},o={},s={};if(n.forEach(function(e){"remotecandidate"!==e.type&&"remote-candidate"!==e.type||(i[e.id]=e),"localcandidate"!==e.type&&"local-candidate"!==e.type||(o[e.id]=e),"candidatepair"!==e.type&&"candidate-pair"!==e.type||(s[e.id]=e)}),n.forEach(function(e){"transport"===e.type&&r(s[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&r(e)}),e._chunk){try{e.send(e._chunk)}catch(t){return e._destroy(t)}e._chunk=null,e._debug('sent chunk from "write before connect"');var a=e._cb;e._cb=null,a(null)}"number"!=typeof e._channel.bufferedAmountLowThreshold&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}}))},r.prototype._onInterval=function(){this._cb&&this._channel&&!(this._channel.bufferedAmount>65536)&&this._onChannelBufferedAmountLow()},r.prototype._onSignalingStateChange=function(){this.destroyed||(this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))},r.prototype._onIceCandidate=function(e){this.destroyed||(e.candidate&&this.trickle?this.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):e.candidate||(this._iceComplete=!0,this.emit("_iceComplete")))},r.prototype._onChannelMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=n.from(t)),this.push(t)}},r.prototype._onChannelBufferedAmountLow=function(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},r.prototype._onChannelOpen=function(){this.connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())},r.prototype._onChannelClose=function(){this.destroyed||(this._debug("on channel close"),this._destroy())},r.prototype._onAddStream=function(e){this.destroyed||(this._debug("on add stream"),this.emit("stream",e.stream))},r.prototype._onTrack=function(e){if(!this.destroyed){this._debug("on track");var t=e.streams[0].id;-1===this._previousStreams.indexOf(t)&&(this._previousStreams.push(t),this.emit("stream",e.streams[0]))}},r.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],o.apply(null,e)},r.prototype._transformConstraints=function(e){if(0===Object.keys(e).length)return e;if((e.mandatory||e.optional)&&!this._isChromium){var t=Object.assign({},e.optional,e.mandatory);return void 0!==t.OfferToReceiveVideo&&(t.offerToReceiveVideo=t.OfferToReceiveVideo,delete t.OfferToReceiveVideo),void 0!==t.OfferToReceiveAudio&&(t.offerToReceiveAudio=t.OfferToReceiveAudio,delete t.OfferToReceiveAudio),t}return e.mandatory||e.optional||!this._isChromium?e:(void 0!==e.offerToReceiveVideo&&(e.OfferToReceiveVideo=e.offerToReceiveVideo,delete e.offerToReceiveVideo),void 0!==e.offerToReceiveAudio&&(e.OfferToReceiveAudio=e.offerToReceiveAudio,delete e.offerToReceiveAudio),{mandatory:e})}}).call(this,e("buffer").Buffer)},{buffer:24,debug:30,"get-browser-rtc":37,inherits:41,randombytes:73,"readable-stream":82}],92:[function(e,t,n){function r(e){return i.digest(e)}var i=new(e("rusha")),o="undefined"!=typeof window?window:self,s=o.crypto||o.msCrypto||{},a=s.subtle||s.webkitSubtle;try{a.digest({name:"sha-1"},new Uint8Array).catch(function(){a=!1})}catch(e){a=!1}t.exports=function(e,t){if(!a)return void setTimeout(t,0,r(e));"string"==typeof e&&(e=function(e){for(var t=e.length,n=new Uint8Array(t),r=0;r<t;r++)n[r]=e.charCodeAt(r);return n}(e)),a.digest({name:"sha-1"},e).then(function(e){t(function(e){for(var t=e.length,n=[],r=0;r<t;r++){var i=e[r];n.push((i>>>4).toString(16)),n.push((15&i).toString(16))}return n.join("")}(new Uint8Array(e)))},function(n){t(r(e))})},t.exports.sync=r},{rusha:87}],93:[function(e,t,n){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(e||(e={}),"string"==typeof e&&(e={url:e}),null==e.url&&null==e.socket)throw Error("Missing required `url` or `socket` option");
1if(null!=e.url&&null!=e.socket)throw Error("Must specify either `url` or `socket` option, not both");if(t._id=a(4).toString("hex").slice(0,7),t._debug("new websocket: %o",e),e=Object.assign({allowHalfOpen:!1},e),u.Duplex.call(t,e),t.connected=!1,t.destroyed=!1,t._chunk=null,t._cb=null,t._interval=null,e.socket)t.url=e.socket.url,t._ws=e.socket;else{t.url=e.url;try{t._ws="function"==typeof c?new f(e.url,e):new f(e.url)}catch(e){return void n.nextTick(function(){t._destroy(e)})}}t._ws.binaryType="arraybuffer",t._ws.onopen=function(){t._onOpen()},t._ws.onmessage=function(e){t._onMessage(e)},t._ws.onclose=function(){t._onClose()},t._ws.onerror=function(){t._destroy(Error("connection error to "+t.url))},t._onFinishBound=function(){t._onFinish()},t.once("finish",t._onFinishBound)}t.exports=r;var i=e("safe-buffer").Buffer,o=e("debug")("simple-websocket"),s=e("inherits"),a=e("randombytes"),u=e("readable-stream"),c=e("ws"),f="function"!=typeof c?WebSocket:c;s(r,u.Duplex),r.WEBSOCKET_SUPPORT=!!f,r.prototype.send=function(e){this._ws.send(e)},r.prototype.destroy=function(e){this._destroy(null,e)},r.prototype._destroy=function(e,t){if(!this.destroyed){if(t&&this.once("close",t),this._debug("destroy (error: %s)",e&&(e.message||e)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this.connected=!1,this.destroyed=!0,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._ws){var n=this._ws,r=function(){n.onclose=null};if(n.readyState===f.CLOSED)r();else try{n.onclose=r,n.close()}catch(e){r()}n.onopen=null,n.onmessage=null,n.onerror=null}this._ws=null,e&&this.emit("error",e),this.emit("close")}},r.prototype._read=function(){},r.prototype._write=function(e,t,n){if(this.destroyed)return n(Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(e)}catch(e){return this._destroy(e)}"function"!=typeof c&&this._ws.bufferedAmount>65536?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n},r.prototype._onFinish=function(){function e(){setTimeout(function(){t._destroy()},1e3)}var t=this;t.destroyed||(t.connected?e():t.once("connect",e))},r.prototype._onMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=i.from(t)),this.push(t)}},r.prototype._onOpen=function(){var e=this;if(!e.connected&&!e.destroyed){if(e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(t){return e._destroy(t)}e._chunk=null,e._debug('sent chunk from "write before connect"');var t=e._cb;e._cb=null,t(null)}"function"!=typeof c&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}},r.prototype._onInterval=function(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>65536)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},r.prototype._onClose=function(){this.destroyed||(this._debug("on close"),this._destroy())},r.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],o.apply(null,e)}}).call(this,e("_process"))},{_process:66,debug:30,inherits:41,randombytes:73,"readable-stream":82,"safe-buffer":88,ws:21}],94:[function(e,t,n){var r=1,i=setInterval(function(){r=r+1&65535},250);i.unref&&i.unref(),t.exports=function(e){var t=4*(e||5),n=[0],i=1,o=r-1&65535;return function(e){var s=r-o&65535;for(s>t&&(s=t),o=r;s--;)i===t&&(i=0),n[i]=n[0===i?t-1:i-1],i++;e&&(n[i-1]+=e);var a=n[i-1],u=n.length<t?0:n[i===t?0:i];return n.length<4?a:4*(a-u)/n.length}}},{}],95:[function(e,t,r){(function(t){var n=e("./lib/request"),i=e("xtend"),o=e("builtin-status-codes"),s=e("url");r.request=function(e,r){e="string"==typeof e?s.parse(e):i(e);var o=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||o,u=e.hostname||e.host,c=e.port,f=e.path||"/";u&&-1!==u.indexOf(":")&&(u="["+u+"]"),e.url=(u?a+"//"+u:"")+(c?":"+c:"")+f,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var h=new n(e);return r&&h.on("response",r),h},r.get=function(e,t){var n=r.request(e,t);return n.end(),n},r.Agent=function(){},r.Agent.defaultMaxSockets=4,r.STATUS_CODES=o,r.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/request":97,"builtin-status-codes":25,url:112,xtend:119}],96:[function(e,t,r){(function(e){function t(){if(void 0!==o)return o;if(e.XMLHttpRequest){o=new e.XMLHttpRequest;try{o.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(e){o=null}}else o=null;return o}function n(e){var n=t();if(!n)return!1;try{return n.responseType=e,n.responseType===e}catch(e){}return!1}function i(e){return"function"==typeof e}r.fetch=i(e.fetch)&&i(e.ReadableStream),r.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),r.blobConstructor=!0}catch(e){}var o,s=void 0!==e.ArrayBuffer,a=s&&i(e.ArrayBuffer.prototype.slice);r.arraybuffer=r.fetch||s&&n("arraybuffer"),r.msstream=!r.fetch&&a&&n("ms-stream"),r.mozchunkedarraybuffer=!r.fetch&&s&&n("moz-chunked-arraybuffer"),r.overrideMimeType=r.fetch||!!t()&&i(t().overrideMimeType),r.vbArray=i(e.VBArray),o=null}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],97:[function(e,t,r){(function(n,r,i){var o=e("./capability"),s=e("inherits"),a=e("./response"),u=e("readable-stream"),c=e("to-arraybuffer"),f=a.IncomingMessage,h=a.readyStates,d=t.exports=function(e){var t,n,r=this;u.Writable.call(r),r._opts=e,r._body=[],r._headers={},e.auth&&r.setHeader("Authorization","Basic "+new i(e.auth).toString("base64")),Object.keys(e.headers).forEac
1h(function(t){r.setHeader(t,e.headers[t])});var s,a=!0;if("disable-fetch"===e.mode||"timeout"in e)a=!1,s=!0;else if("prefer-streaming"===e.mode)s=!1;else if("allow-wrong-content-type"===e.mode)s=!o.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)throw Error("Invalid value for opts.mode");s=!0}r._mode=(t=s,n=a,o.fetch&&n?"fetch":o.mozchunkedarraybuffer?"moz-chunked-arraybuffer":o.msstream?"ms-stream":o.arraybuffer&&t?"arraybuffer":o.vbArray&&t?"text:vbarray":"text"),r.on("finish",function(){r._onFinish()})};s(d,u.Writable),d.prototype.setHeader=function(e,t){var n=e.toLowerCase();-1===l.indexOf(n)&&(this._headers[n]={name:e,value:t})},d.prototype.getHeader=function(e){return this._headers[e.toLowerCase()].value},d.prototype.removeHeader=function(e){delete this._headers[e.toLowerCase()]},d.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,s=e._headers,a=null;"GET"!==t.method&&"HEAD"!==t.method&&(a=o.blobConstructor?new r.Blob(e._body.map(function(e){return c(e)}),{type:(s["content-type"]||{}).value||""}):i.concat(e._body).toString());var u=[];if(Object.keys(s).forEach(function(e){var t=s[e].name,n=s[e].value;Array.isArray(n)?n.forEach(function(e){u.push([t,e])}):u.push([t,n])}),"fetch"===e._mode)r.fetch(e._opts.url,{method:e._opts.method,headers:u,body:a||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin"}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)});else{var f=e._xhr=new r.XMLHttpRequest;try{f.open(e._opts.method,e._opts.url,!0)}catch(t){return void n.nextTick(function(){e.emit("error",t)})}"responseType"in f&&(f.responseType=e._mode.split(":")[0]),"withCredentials"in f&&(f.withCredentials=!!t.withCredentials),"text"===e._mode&&"overrideMimeType"in f&&f.overrideMimeType("text/plain; charset=x-user-defined"),"timeout"in t&&(f.timeout=t.timeout,f.ontimeout=function(){e.emit("timeout")}),u.forEach(function(e){f.setRequestHeader(e[0],e[1])}),e._response=null,f.onreadystatechange=function(){switch(f.readyState){case h.LOADING:case h.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(f.onprogress=function(){e._onXHRProgress()}),f.onerror=function(){e._destroyed||e.emit("error",Error("XHR error"))};try{f.send(a)}catch(t){return void n.nextTick(function(){e.emit("error",t)})}}}},d.prototype._onXHRProgress=function(){(function(e){try{var t=e.status;return null!==t&&0!==t}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},d.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},d.prototype._write=function(e,t,n){this._body.push(e),n()},d.prototype.abort=d.prototype.destroy=function(){this._destroyed=!0,this._response&&(this._response._destroyed=!0),this._xhr&&this._xhr.abort()},d.prototype.end=function(e,t,n){"function"==typeof e&&(n=e,e=void 0),u.Writable.prototype.end.call(this,e,t,n)},d.prototype.flushHeaders=function(){},d.prototype.setTimeout=function(){},d.prototype.setNoDelay=function(){},d.prototype.setSocketKeepAlive=function(){};var l=["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"),void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":96,"./response":98,_process:66,buffer:24,inherits:41,"readable-stream":82,"to-arraybuffer":105}],98:[function(e,t,r){(function(t,n,i){var o=e("./capability"),s=e("inherits"),a=e("readable-stream"),u=r.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=r.IncomingMessage=function(e,n,r){var s=this;if(a.Readable.call(s),s._mode=r,s.headers={},s.rawHeaders=[],s.trailers={},s.rawTrailers=[],s.on("end",function(){t.nextTick(function(){s.emit("close")})}),"fetch"===r){s._fetchResponse=n,s.url=n.url,s.statusCode=n.status,s.statusMessage=n.statusText,n.headers.forEac
1h(function(e,t){s.headers[t.toLowerCase()]=e,s.rawHeaders.push(t,e)});var u=n.body.getReader();!function e(){u.read().then(function(t){if(!s._destroyed){if(t.done)return void s.push(null);s.push(new i(t.value)),e()}}).catch(function(e){s.emit("error",e)})}()}else if(s._xhr=e,s._pos=0,s.url=e.responseURL,s.statusCode=e.status,s.statusMessage=e.statusText,e.getAllResponseHeaders().split(/\r?\n/).forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var n=t[1].toLowerCase();"set-cookie"===n?(void 0===s.headers[n]&&(s.headers[n]=[]),s.headers[n].push(t[2])):void 0!==s.headers[n]?s.headers[n]+=", "+t[2]:s.headers[n]=t[2],s.rawHeaders.push(t[1],t[2])}}),s._charset="x-user-defined",!o.overrideMimeType){var c=s.rawHeaders["mime-type"];if(c){var f=c.match(/;\s*charset=([^;])(;|$)/);f&&(s._charset=f[1].toLowerCase())}s._charset||(s._charset="utf-8")}};s(c,a.Readable),c.prototype._read=function(){},c.prototype._onXHRProgress=function(){var e=this,t=e._xhr,r=null;switch(e._mode){case"text:vbarray":if(t.readyState!==u.DONE)break;try{r=new n.VBArray(t.responseBody).toArray()}catch(e){}if(null!==r){e.push(new i(r));break}case"text":try{r=t.responseText}catch(t){e._mode="text:vbarray";break}if(r.length>e._pos){var o=r.substr(e._pos);if("x-user-defined"===e._charset){for(var s=new i(o.length),a=0;a<o.length;a++)s[a]=255&o.charCodeAt(a);e.push(s)}else e.push(o,e._charset);e._pos=r.length}break;case"arraybuffer":if(t.readyState!==u.DONE||!t.response)break;r=t.response,e.push(new i(new Uint8Array(r)));break;case"moz-chunked-arraybuffer":if(r=t.response,t.readyState!==u.LOADING||!r)break;e.push(new i(new Uint8Array(r)));break;case"ms-stream":if(r=t.response,t.readyState!==u.LOADING)break;var c=new n.MSStreamReader;c.onprogress=function(){c.result.byteLength>e._pos&&(e.push(new i(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(r)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":96,_process:66,buffer:24,inherits:41,"readable-stream":82}],99:[function(e,t,n){var r=e("stream-to-blob");t.exports=function e(t,n,i){if("function"==typeof n)return e(t,null,n);r(t,n,function(e,t){if(e)return i(e);i(null,URL.createObjectURL(t))})}},{"stream-to-blob":100}],100:[function(e,t,n){var r=e("once");t.exports=function e(t,n,i){if("function"==typeof n)return e(t,null,n);i=r(i);var o=[];t.on("data",function(e){o.push(e)}).on("end",function(){var e=n?new Blob(o,{type:n}):new Blob(o);i(null,e)}).on("error",i)}},{once:60}],101:[function(e,t,n){(function(n){var r=e("once");t.exports=function(e,t,i){i=r(i);var o=new n(t),s=0;e.on("data",function(e){e.copy(o,s),s+=e.length}).on("end",function(){i(null,o)}).on("error",i)}}).call(this,e("buffer").Buffer)},{buffer:24,once:60}],102:[function(e,t,n){"use strict";function r(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(d.isEncoding===p||!p(e)))throw Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=s,this.end=a,t=4;break;case"utf8":this.fillLast=o,t=4;break;case"base64":this.text=u,this.end=c,t=3;break;default:return this.write=f,void(this.end=h)}this.lastNeed=0,this.lastTotal=0,this.lastChar=l.allocUnsafe(t)}function i(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:-1}function o(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�".repeat(n);if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�".repeat(n+1);if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�".repeat(n+2)}}(this,e,t);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function s(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function a(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function u(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function c(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}var d=e("buffer").Buffer,l=e("buffer-shims"),p=d.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};n.StringDecoder=r,r.prototype.write=function(e){var t,n;if(0===e.length)return"";if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""},r.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�".repeat(this.lastTotal-this.lastNeed):t},r.prototype.text=function(e,t){var n=function(e,t,n){var r=t.length-1;if(r<n)return 0;var o=i(t[r]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--r<n?0:(o=i(t[r]))>=0?(o>0&&(e.lastNeed=o-2),o):--r<n?0:(o=i(t[r]))>=0?(o>0&&(2===o?o=0:e.lastNeed=o-3),o):0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},r.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},{buffer:24,"buffer-shims":23}],103:[function(e,t,n){var r=e("./thirty-two");n.encode=r.encode,n.decode=r.decode},{"./thirty-two":104}],104:[function(e,t,n){(function(e){"use strict";var t=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];n.encode=function(t){e.isBuffer(t)||(t=new e(t));for(var n,r,i=0,o=0,s=0,a=0,u=new e(8*(r=Math.floor((n=t).length/5),n.length%5==0?r:r+1));i<t.length;){var c=t[i];s>3?(a=(a=c&255>>s)<<(s=(s+5)%8)|(i+1<t.length?t[i+1]:0)>>8-s,i++):(a=c>>8-(s+5)&31,0==(s=(s+5)%8)&&i++),u[o]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(a),o++}for(i=o;i<u.length;i++)u[i]=61;return u},n.decode=function(n){var r,i=0,o=0,s=0;e.isBuffer(n)||(n=new e(n));for(var a=new e(Math.ceil(5*n.length/8)),u=0;u<n.length&&61!==n[u];u++){var c=n[u]-48;if(!(c<t.length))throw Error("Invalid input - it is not base32 encoded string");o=t[c],i<=3?0==(i=(i+5)%8)?(r|=o,a[s]=r,s++,r=0):r|=255&o<<8-i:(r|=255&o>>>(i=(i+5)%8),a[s]=r,s++,r=255&o<<8-i)}return a.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:24}],105:[function(e,t,n){var r=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(r.isBuffer(e)){for(var t=new Uint8Array(e.length),n=e.length,i=0;i<n;i++)t[i]=e[i];return t.buffer}throw Error("Argument must be a Buffer")}},{buffer:24}],106:[function(e,t,n){(function(n){function r(e){function t(e,t){var n=new o(t);return n.on("warning",i._onWarning),n.on("error",i._onError),n.listen(e),i._internalDHT=!0,n}var i=this;if(!(i instanceof r))return new r(e);if(s.call(i),!e.peerId)throw Error("Option `peerId` is required");if(!e.infoHash)throw Error("Option `infoHash` is required");if(!n.browser&&!e.port)throw Error("Option `port` is required");i.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),i.infoHash="string"==typeof e.infoHash?e.infoHash:e.infoHash.toString("hex"),i._port=e.port,i._userAgent=e.userAgent,i.destroyed=!1,i._announce=e.announce||[],i._intervalMs=e.intervalMs||9e5,i._trackerOpts=null,i._dhtAnnouncing=!1,i._dhtTimeout=!1,i._internalDHT=!1,i._onWarning=function(e){i.emit("warning",e)},i._onError=function(e){i.emit("error",e)}
1,i._onDHTPeer=function(e,t){t.toString("hex")===i.infoHash&&i.emit("peer",e.host+":"+e.port,"dht")},i._onTrackerPeer=function(e){i.emit("peer",e,"tracker")},i._onTrackerAnnounce=function(){i.emit("trackerAnnounce")},!1===e.tracker?i.tracker=null:(e.tracker&&"object"==typeof e.tracker&&(i._trackerOpts=a(e.tracker)),i.tracker=i._createTracker()),!1===e.dht||"function"!=typeof o?i.dht=null:e.dht&&"function"==typeof e.dht.addNode?i.dht=e.dht:e.dht&&"object"==typeof e.dht?i.dht=t(e.dhtPort,e.dht):i.dht=t(e.dhtPort),i.dht&&(i.dht.on("peer",i._onDHTPeer),i._dhtAnnounce())}t.exports=r;var i=e("debug")("torrent-discovery"),o=e("bittorrent-dht/client"),s=e("events").EventEmitter,a=e("xtend"),u=e("inherits"),c=e("run-parallel"),f=e("bittorrent-tracker/client");u(r,s),r.prototype.updatePort=function(e){var t=this;e!==t._port&&(t._port=e,t.dht&&t._dhtAnnounce(),t.tracker&&(t.tracker.stop(),t.tracker.destroy(function(){t.tracker=t._createTracker()})))},r.prototype.complete=function(e){this.tracker&&this.tracker.complete(e)},r.prototype.destroy=function(e){var t=this;if(!t.destroyed){t.destroyed=!0,clearTimeout(t._dhtTimeout);var n=[];t.tracker&&(t.tracker.stop(),t.tracker.removeListener("warning",t._onWarning),t.tracker.removeListener("error",t._onError),t.tracker.removeListener("peer",t._onTrackerPeer),t.tracker.removeListener("update",t._onTrackerAnnounce),n.push(function(e){t.tracker.destroy(e)})),t.dht&&t.dht.removeListener("peer",t._onDHTPeer),t._internalDHT&&(t.dht.removeListener("warning",t._onWarning),t.dht.removeListener("error",t._onError),n.push(function(e){t.dht.destroy(e)})),c(n,e),t.dht=null,t.tracker=null,t._announce=null}},r.prototype._createTracker=function(){var e=new f(a(this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}));return e.on("warning",this._onWarning),e.on("error",this._onError),e.on("peer",this._onTrackerPeer),e.on("update",this._onTrackerAnnounce),e.setInterval(this._intervalMs),e.start(),e},r.prototype._dhtAnnounce=function(){var e=this;e._dhtAnnouncing||(i("dht announce"),e._dhtAnnouncing=!0,clearTimeout(e._dhtTimeout),e.dht.announce(e.infoHash,e._port,function(t){e._dhtAnnouncing=!1,i("dht announce complete"),t&&e.emit("warning",t),e.emit("dhtAnnounce"),e.destroyed||(e._dhtTimeout=setTimeout(function(){e._dhtAnnounce()},e._intervalMs+Math.floor(Math.random()*e._intervalMs/5)),e._dhtTimeout.unref&&e._dhtTimeout.unref())}))}}).call(this,e("_process"))},{_process:66,"bittorrent-dht/client":21,"bittorrent-tracker/client":15,debug:30,events:34,inherits:41,"run-parallel":86,xtend:119}],107:[function(e,t,n){(function(e){function n(e){if(!(this instanceof n))return new n(e);this.length=e,this.missing=e,this.sources=null,this._chunks=Math.ceil(e/r),this._remainder=e%r||r,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}t.exports=n;var r=16384;n.BLOCK_LENGTH=r,n.prototype.chunkLength=function(e){return e===this._chunks-1?this._remainder:r},n.prototype.chunkLengthRemaining=function(e){return this.length-e*r},n.prototype.chunkOffset=function(e){return e*r},n.prototype.reserve=function(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1},n.prototype.reserveRemaining=function(){if(!this.init())return -1;if(this._reservations<this._chunks){var e=this._reservations;return this._reservations=this._chunks,e}return -1},n.prototype.cancel=function(e){this.init()&&this._cancellations.push(e)},n.prototype.cancelRemaining=function(e){this.init()&&(this._reservations=e)},n.prototype.get=function(e){return this.init()?this._buffer[e]:null},n.prototype.set=function(e,t,n){if(!this.init())return!1;for(var i=t.length,o=Math.ceil(i/r),s=0;s<o;s++)if(!this._buffer[e+s]){var a=s*r,u=t.slice(a,a+r);this._buffered++,this._buffer[e+s]=u,this.missing-=u.length,-1===this.sources.indexOf(n)&&this.sources.push(n)}return this._buffered===this._chunks},n.prototype.flush=function(){if(!this._buffer||this._chunks!==this._buffered)return null;var t=e.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,t},n.prototype.init=function(){return!this._flushed&&(!!this._buffer||(this._buffer=Array(this._chunks),this._cancellations=[],this.sources=[],!0))}}).call(this,e("buffer").Buffer)},{buffer:24}],108:[function(e,t,n){(function(n){var r=e("is-typedarray").strict;t.exports=function(e){if(r(e)){var t=new n(e.buffer);
1return e.byteLength!==e.buffer.byteLength&&(t=t.slice(e.byteOffset,e.byteOffset+e.byteLength)),t}return new n(e)}}).call(this,e("buffer").Buffer)},{buffer:24,"is-typedarray":45}],109:[function(e,t,n){(function(e){n.encodingLength=function(){return 8},n.encode=function(t,n,r){n||(n=new e(8)),r||(r=0);var i=Math.floor(t/4294967295);return n.writeUInt32BE(i,r),n.writeUInt32BE(t-4294967295*i,r+4),n},n.decode=function(t,n){return n||(n=0),t||(t=new e(4)),n||(n=0),4294967295*t.readUInt32BE(n)+t.readUInt32BE(n+4)},n.encode.bytes=8,n.decode.bytes=8}).call(this,e("buffer").Buffer)},{buffer:24}],110:[function(e,t,n){"use strict";t.exports=function(e,t,n){return 0===e.length?e:t?(n||e.sort(t),function(e,t){for(var n=1,r=e.length,i=e[0],o=e[0],s=1;s<r;++s)if(o=i,t(i=e[s],o)){if(s===n){n++;continue}e[n++]=i}return e.length=n,e}(e,t)):(n||e.sort(),function(e){for(var t=1,n=e.length,r=e[0],i=e[0],o=1;o<n;++o,i=r)if(i=r,(r=e[o])!==i){if(o===t){t++;continue}e[t++]=r}return e.length=t,e}(e))}},{}],111:[function(e,t,n){t.exports=function(e,t){if(!(t>=e.length||t<0)){var n=e.pop();if(t<e.length){var r=e[t];return e[t]=n,r}return n}}},{}],112:[function(e,t,n){"use strict";function r(){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}function i(e,t,n){if(e&&s.isObject(e)&&e instanceof r)return e;var i=new r;return i.parse(e,t,n),i}var o=e("punycode"),s=e("./util");n.parse=i,n.resolve=function(e,t){return i(e,!1,!0).resolve(t)},n.resolveObject=function(e,t){return e?i(e,!1,!0).resolveObject(t):t},n.format=function(e){return s.isString(e)&&(e=i(e)),e instanceof r?e.format():r.prototype.format.call(e)},n.Url=r;var a=/^([a-z0-9.+-]+:)/i,u=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,f=["'"].concat(["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","	"])),h=["%","/","?",";","#"].concat(f),d=["/","?","#"],l={javascript:!0,"javascript:":!0},p={javascript:!0,"javascript:":!0},m={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},g=e("querystring");r.prototype.parse=function(e,t,n){if(!s.isString(e))throw TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),i=-1!==r&&r<e.indexOf("#")?"?":"#",u=e.split(i);u[0]=u[0].replace(/\\/g,"/");var y=e=u.join(i);if(y=y.trim(),!n&&1===e.split("#").length){var _=c.exec(y);if(_)return this.path=y,this.href=y,this.pathname=_[1],_[2]?(this.search=_[2],this.query=t?g.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var v=a.exec(y);if(v){var b=(v=v[0]).toLowerCase();this.protocol=b,y=y.substr(v.length)}if(n||v||y.match(/^\/\/[^@\/]+@[^@\/]+/)){var w="//"===y.substr(0,2);!w||v&&p[v]||(y=y.substr(2),this.slashes=!0)}if(!p[v]&&(w||v&&!m[v])){for(var E,k,x=-1,S=0;S<d.length;S++){var I=y.indexOf(d[S]);-1!==I&&(-1===x||I<x)&&(x=I)}-1!==(k=-1===x?y.lastIndexOf("@"):y.lastIndexOf("@",x))&&(E=y.slice(0,k),y=y.slice(k+1),this.auth=decodeURIComponent(E)),x=-1;for(var S=0;S<h.length;S++){var I=y.indexOf(h[S]);-1!==I&&(-1===x||I<x)&&(x=I)}-1===x&&(x=y.length),this.host=y.slice(0,x),y=y.slice(x),this.parseHost(),this.hostname=this.hostname||"";var B="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!B)for(var C=this.hostname.split(/\./),S=0,A=C.length;S<A;S++){var T=C[S];if(T&&!T.match(/^[+a-z0-9A-Z_-]{0,63}$/)){for(var L="",U=0,R=T.length;U<R;U++)T.charCodeAt(U)>127?L+="x":L+=T[U];if(!L.match(/^[+a-z0-9A-Z_-]{0,63}$/)){var O=C.slice(0,S),P=C.slice(S+1),M=T.match(/^([+a-z0-9A-Z_-]{0,63})(.*)$/);M&&(O.push(M[1]),P.unshift(M[2])),P.length&&(y="/"+P.join(".")+y),this.hostname=O.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),B||(this.hostname=o.toASCII(this.hostname));var j=this.port?":"+this.port:"",H=this.hostname||"";this.host=H+j,this.href+=this.host,B&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==y[0]&&(y="/"+y))}if(!l[b])for(var S=0,A=f.length;S<A;S++){var N=f[S];if(-1!==y.indexOf(N)){var q=encodeURIComponent(N);q===N&&(q=escape(N)),y=y.split(N).join(q)}}var D=y.indexOf("#");-1!==D&&(this.hash=y.substr(D),y=y.slice(0,D));var W=y.indexOf("?");if(-1!==W?(this.search=y.substr(W),this.query=y.substr(W+1),t&&(this.query=g.parse(this.query)),y=y.slice(0,W)):t&&(this.search="",this.query={}),y&&(this.pathname=y),m[b]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var j=this.pathname||"",z=this.search||"";this.path=j+z}return this.href=this.format(),this},r.prototype.format=function(){var e=this.auth||"";e&&(e=(e=encodeURIComponent(e)).replace(/%3A/i,":")+"@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",i=!1,o="";this.host?i=e+this.host:this.hostname&&(i=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&s.isObject(this.query)&&Object.keys(this.query).length&&(o=g.stringify(this.query));var a=this.search||o&&"?"+o||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||m[t])&&!1!==i?(i="//"+(i||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):i||(i=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),t+i+(n=n.replace(/[?#]/g,function(e){return encodeURIComponent(e)}))+(a=a.replace("#","%23"))+r},r.prototype.resolve=function(e){return this.resolveObject(i(e,!1,!0)).format()},r.prototype.resolveObject=function(e){if(s.isString(e)){var t=new r;t.parse(e,!1,!0),e=t}for(var n=new r,i=Object.keys(this),o=0;o<i.length;o++){var a=i[o];n[a]=this[a]}if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var u=Object.keys(e),c=0;c<u.length;c++){var f=u[c];"protocol"!==f&&(n[f]=e[f])}return m[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!m[e.protocol]){for(var h=Object.keys(e),d=0;d<h.length;d++){var l=h[d];n[l]=e[l]}return n.href=n.format(),n}if(n.protocol=e.protocol,e.host||p[e.protocol])n.pathname=e.pathname;else{for(var g=(e.pathname||"").split("/");g.length&&!(e.host=g.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==g[0]&&g.unshift(""),g.length<2&&g.unshift(""),n.pathname=g.join("/")}if(n.search=e.search,n.query=e.query,n.host=e.host||"",n.auth=e.auth,n.hostname=e.hostname||e.host,n.port=e.port,n.pathname||n.search){var y=n.pathname||"",_=n.search||"";n.path=y+_}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var v=n.pathname&&"/"===n.pathname.charAt(0),b=e.host||e.pathname&&"/"===e.pathname.charAt(0),w=b||v||n.host&&e.pathname,E=w,k=n.pathname&&n.pathname.split("/")||[],g=e.pathname&&e.pathname.split("/")||[],x=n.protocol&&!m[n.protocol];if(x&&(n.hostname="",n.port=null,n.host&&(""===k[0]?k[0]=n.host:k.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===g[0]?g[0]=e.host:g.unshift(e.host)),e.host=null),w=w&&(""===g[0]||""===k[0])),b)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,k=g;
1else if(g.length)k||(k=[]),k.pop(),k=k.concat(g),n.search=e.search,n.query=e.query;else if(!s.isNullOrUndefined(e.search)){if(x){n.hostname=n.host=k.shift();var S=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@");S&&(n.auth=S.shift(),n.host=n.hostname=S.shift())}return n.search=e.search,n.query=e.query,s.isNull(n.pathname)&&s.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!k.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var I=k.slice(-1)[0],B=(n.host||e.host||k.length>1)&&("."===I||".."===I)||""===I,C=0,A=k.length;A>=0;A--)"."===(I=k[A])?k.splice(A,1):".."===I?(k.splice(A,1),C++):C&&(k.splice(A,1),C--);if(!w&&!E)for(;C--;C)k.unshift("..");!w||""===k[0]||k[0]&&"/"===k[0].charAt(0)||k.unshift(""),B&&"/"!==k.join("/").substr(-1)&&k.push("");var T=""===k[0]||k[0]&&"/"===k[0].charAt(0);if(x){n.hostname=n.host=T?"":k.length?k.shift():"";var S=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@");S&&(n.auth=S.shift(),n.host=n.hostname=S.shift())}return(w=w||n.host&&k.length)&&!T&&k.unshift(""),k.length?n.pathname=k.join("/"):(n.pathname=null,n.path=null),s.isNull(n.pathname)&&s.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},r.prototype.parseHost=function(){var e=this.host,t=u.exec(e);t&&(":"!==(t=t[0])&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":113,punycode:68,querystring:71}],113:[function(e,t,n){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],114:[function(e,t,n){var r=e("bencode"),i=e("bitfield"),o=e("safe-buffer").Buffer,s=e("debug")("ut_metadata"),a=e("events").EventEmitter,u=e("inherits"),c=e("simple-sha1");t.exports=function(e){function t(t){a.call(this),this._wire=t,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._fetching=!1,this._bitfield=new i(0,{grow:1e3}),o.isBuffer(e)&&this.setMetadata(e)}return u(t,a),t.prototype.name="ut_metadata",t.prototype.onHandshake=function(e,t,n){this._infoHash=e},t.prototype.onExtendedHandshake=function(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||1e7<e.metadata_size||e.metadata_size<=0?this.emit("warning",Error("Peer gave invalid metadata size")):(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/16384),this._remainingRejects=2*this._numPieces,void(this._fetching&&this._requestPieces())):this.emit("warning",Error("Peer does not have metadata")):this.emit("warning",Error("Peer does not support ut_metadata"))},t.prototype.onMessage=function(e){var t,n;try{var i=e.toString(),o=i.indexOf("ee")+2;t=r.decode(i.substring(0,o)),n=e.slice(o)}catch(e){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece)}},t.prototype.fetch=function(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())},t.prototype.cancel=function(){this._fetching=!1},t.prototype.setMetadata=function(e){if(this._metadataComplete)return!0;s("set metadata");try{var t=r.decode(e).info;t&&(e=r.encode(t))}catch(e){}return(!this._infoHash||this._infoHash===c.sync(e))&&(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",r.encode({info:r.decode(this.metadata)})),!0)},t.prototype._send=function(e,t){var n=r.encode(e);o.isBuffer(t)&&(n=o.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,n){var r={msg_type:1,piece:e};"number"==typeof n&&(r.total_size=n),this._send(r,t)},t.prototype._reject=function(e){this._send({msg_type:2,piece:e})},t.prototype._onRequest=function(e){if(!this._metadataComplete)return void this._reject(e);var t=16384*e,n=t+16384;n>this._metadataSize&&(n=this._metadataSize);var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)},t.prototype._onData=function(e,t,n){t.length>16384||(t.copy(this.metadata,16384*e),this._bitfield.set(e),this._checkDone())},t.prototype._onReject=function(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit
1("warning",Error('Peer sent "reject" too much'))},t.prototype._requestPieces=function(){this.metadata=o.alloc(this._metadataSize);for(var e=0;e<this._numPieces;e++)this._request(e)},t.prototype._checkDone=function(){for(var e=!0,t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}e&&(this.setMetadata(this.metadata)||this._failedMetadata())},t.prototype._failedMetadata=function(){this._bitfield=new i(0,{grow:1e3}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit("warning",Error("Peer sent invalid metadata"))},t}},{bencode:11,bitfield:13,debug:30,events:34,inherits:41,"safe-buffer":88,"simple-sha1":92}],115:[function(e,t,r){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=function(e,t){if(n("noDeprecation"))return e;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw Error(t);n("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}}}).call(this,void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],116:[function(e,t,n){(function(n){function r(e){a.call(this),this._tracks=[],this._fragmentSequence=1,this._file=e,this._decoder=null,this._findMoov(0)}function i(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}function o(){return{version:0,flags:0,entries:[]}}var s=e("binary-search"),a=e("events").EventEmitter,u=e("inherits"),c=e("mp4-stream"),f=e("mp4-box-encoding"),h=e("range-slice-stream");t.exports=r,u(r,a),r.prototype._findMoov=function(e){var t=this;t._decoder&&t._decoder.destroy(),t._decoder=c.decode();var n=t._file.createReadStream({start:e});n.pipe(t._decoder),t._decoder.once("box",function(r){"moov"===r.type?t._decoder.decode(function(e){n.destroy();try{t._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,t.emit("error",e)}}):(n.destroy(),t._findMoov(e+r.length))})},i.prototype.inc=function(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]},r.prototype._processMoov=function(e){var t=e.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(var r=0;r<t.length;r++){var s,a,u=t[r],c=u.mdia.minf.stbl,h=c.stsd.entries[0],d=u.mdia.hdlr.handlerType;if("vide"===d&&"avc1"===h.type){if(this._hasVideo)continue;this._hasVideo=!0,s="avc1",h.avcC&&(s+="."+h.avcC.mimeCodec),a='video/mp4; codecs="'+s+'"'}else{if("soun"!==d||"mp4a"!==h.type||this._hasAudio)continue;this._hasAudio=!0,s="mp4a",h.esds&&h.esds.mimeCodec&&(s+="."+h.esds.mimeCodec),a='audio/mp4; codecs="'+s+'"'}var l=[],p=0,m=0,g=0,y=0,_=0,v=0,b=new i(c.stts.entries),w=null;c.ctts&&(w=new i(c.ctts.entries));for(var E=0;;){var k=c.stsc.entries[_],x=c.stsz.entries[p],S=b.value.duration,I=w?w.value.compositionOffset:0,B=!0;if(c.stss&&(B=c.stss.entries[E]===p+1),l.push({size:x,duration:S,dts:v,presentationOffset:I,sync:B,offset:y+c.stco.entries[g]}),++p>=c.stsz.entries.length)break;if(m++,y+=x,m>=k.samplesPerChunk){m=0,y=0,g++;var C=c.stsc.entries[_+1];C&&g+1>=C.firstChunk&&_++}v+=S,b.inc(),w&&w.inc(),B&&E++}u.mdia.mdhd.duration=0,u.tkhd.duration=0;var A=k.sampleDescriptionId,T={type:"moov",mvhd:e.mvhd,traks:[{tkhd:u.tkhd,mdia:{mdhd:u.mdia.mdhd,hdlr:u.mdia.hdlr,elng:u.mdia.elng,minf:{vmhd:u.mdia.minf.vmhd,smhd:u.mdia.minf.smhd,dinf:u.mdia.minf.dinf,stbl:{stsd:c.stsd,stts:o(),ctts:o(),stsc:o(),stsz:o(),stco:o(),stss:o()}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:u.tkhd.trackId,defaultSampleDescriptionIndex:A,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({trackId:u.tkhd.trackId,timeScale:u.mdia.mdhd.timeScale,samples:l,currSample:null,currTime:null,moov:T,mime:a})}if(0===this._tracks.length)return void this.emit("error",Error("no playable tracks"));e.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};var L=f.encode(this._ftyp),U=this._tracks.map(function(e){var t=f.encode(e.moov);return{mime:e.mime,init:n.concat([L,t])}});
1this.emit("ready",U)},r.prototype.seek=function(e){var t=this;if(!t._tracks)throw Error("Not ready yet; wait for 'ready' event");t._fileStream&&(t._fileStream.destroy(),t._fileStream=null);var n=-1;if(t._tracks.map(function(r,i){r.outStream&&r.outStream.destroy(),r.inStream&&(r.inStream.destroy(),r.inStream=null);var o=r.outStream=c.encode(),s=t._generateFragment(i,e);if(!s)return o.finalize();(-1===n||s.ranges[0].start<n)&&(n=s.ranges[0].start),function e(n){o.destroyed||o.box(n.moof,function(s){if(s)return t.emit("error",s);o.destroyed||r.inStream.slice(n.ranges).pipe(o.mediaData(n.length,function(n){if(n)return t.emit("error",n);if(!o.destroyed){var r=t._generateFragment(i);if(!r)return o.finalize();e(r)}}))})}(s)}),n>=0){var r=t._fileStream=t._file.createReadStream({start:n});t._tracks.forEach(function(e){e.inStream=new h(n,{highWaterMark:1e7}),r.pipe(e.inStream)})}return t._tracks.map(function(e){return e.outStream})},r.prototype._findSampleBefore=function(e,t){var n=this._tracks[e],r=Math.floor(n.timeScale*t),i=s(n.samples,r,function(e,t){return e.dts+e.presentationOffset-t});for(-1===i?i=0:i<0&&(i=-i-2);!n.samples[i].sync;)i--;return i},r.prototype._generateFragment=function(e,t){var n,r=this._tracks[e];if((n=void 0!==t?this._findSampleBefore(e,t):r.currSample)>=r.samples.length)return null;for(var i=r.samples[n].dts,o=0,s=[],a=n;a<r.samples.length;a++){var u=r.samples[a];if(u.sync&&u.dts-i>=1*r.timeScale)break;o+=u.size;var c=s.length-1;c<0||s[c].end!==u.offset?s.push({start:u.offset,end:u.offset+u.size}):s[c].end+=u.size}return r.currSample=a,{moof:this._generateMoof(e,n,a),ranges:s,length:o}},r.prototype._generateMoof=function(e,t,n){for(var r=this._tracks[e],i=[],o=t;o<n;o++){var s=r.samples[o];i.push({sampleDuration:s.duration,sampleSize:s.size,sampleFlags:s.sync?33554432:16842752,sampleCompositionTimeOffset:s.presentationOffset})}var a={type:"moof",mfhd:{sequenceNumber:this._fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:r.trackId},tfdt:{baseMediaDecodeTime:r.samples[t].dts},trun:{flags:3841,dataOffset:8,entries:i}}]};return a.trafs[0].trun.dataOffset+=f.encodingLength(a),a}}).call(this,e("buffer").Buffer)},{"binary-search":12,buffer:24,events:34,inherits:41,"mp4-box-encoding":53,"mp4-stream":56,"range-slice-stream":74}],117:[function(e,t,n){function r(e,t,n){var o=this;if(!(this instanceof r))return new r(e,t,n);n=n||{},o.detailedError=null,o._elem=t,o._elemWrapper=new i(t),o._waitingFired=!1,o._trackMeta=null,o._file=e,o._tracks=null,"none"!==o._elem.preload&&o._createMuxer(),o._onError=function(e){o.detailedError=o._elemWrapper.detailedError,o.destroy()},o._onWaiting=function(){o._waitingFired=!0,o._muxer?o._tracks&&o._pump():o._createMuxer()},o._elem.addEventListener("waiting",o._onWaiting),o._elem.addEventListener("error",o._onError)}var i=e("mediasource"),o=e("pump"),s=e("./mp4-remuxer");t.exports=r,r.prototype._createMuxer=function(){var e=this;e._muxer=new s(e._file),e._muxer.on("ready",function(t){e._tracks=t.map(function(t){var n=e._elemWrapper.createWriteStream(t.mime);n.on("error",function(t){e._elemWrapper.error(t)});var r={muxed:null,mediaSource:n,initFlushed:!1,onInitFlushed:null};return n.write(t.init,function(e){r.initFlushed=!0,r.onInitFlushed&&r.onInitFlushed(e)}),r}),(e._waitingFired||"auto"===e._elem.preload)&&e._pump()}),e._muxer.on("error",function(t){e._elemWrapper.error(t)})},r.prototype._pump=function(){var e=this,t=e._muxer.seek(e._elem.currentTime,!e._tracks);e._tracks.forEach(function(n,r){var i=function(){n.muxed&&(n.muxed.destroy(),n.mediaSource=e._elemWrapper.createWriteStream(n.mediaSource),n.mediaSource.on("error",function(t){e._elemWrapper.error(t)})),n.muxed=t[r],o(n.muxed,n.mediaSource)};n.initFlushed?i():n.onInitFlushed=function(t){if(t)return void e._elemWrapper.error(t);i()}})},r.prototype.destroy=function(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(function(e){e.muxed.destroy()}),this._elem.src="")}},{"./mp4-remuxer":116,mediasource:49,pump:67}],118:[function(e,t,n){t.exports=function e(t,n){function r(){for(var e=Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];var r=t.apply(this,e),i=e[e.length-1];
1return"function"==typeof r&&r!==i&&Object.keys(i).forEach(function(e){r[e]=i[e]}),r}if(t&&n)return e(t)(n);if("function"!=typeof t)throw TypeError("need wrapper function");return Object.keys(t).forEach(function(e){r[e]=t[e]}),r}},{}],119:[function(e,t,n){t.exports=function(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var i in n)r.call(n,i)&&(e[i]=n[i])}return e};var r=Object.prototype.hasOwnProperty},{}],120:[function(e,t,n){t.exports=function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)r.call(n,i)&&(e[i]=n[i])}return e};var r=Object.prototype.hasOwnProperty},{}],121:[function(e,t,n){t.exports=function e(t,n,r){return void 0===n?function(n,r){return e(t,n,r)}:(void 0===r&&(r="0"),(t-=n.toString().length)>0?Array(t+(/\./.test(n)?2:1)).join(r)+n:n+"")}},{}],122:[function(e,t,n){t.exports={version:"0.98.18"}},{}],123:[function(e,t,r){(function(n,r){function i(e){function t(){s.destroyed||(s.ready=!0,s.emit("ready"))}var s=this;if(!(s instanceof i))return new i(e);f.call(s),e||(e={}),"string"==typeof e.peerId?s.peerId=e.peerId:o.isBuffer(e.peerId)?s.peerId=e.peerId.toString("hex"):s.peerId=o.from(S+_(9).toString("base64")).toString("hex"),s.peerIdBuffer=o.from(s.peerId,"hex"),"string"==typeof e.nodeId?s.nodeId=e.nodeId:o.isBuffer(e.nodeId)?s.nodeId=e.nodeId.toString("hex"):s.nodeId=_(20).toString("hex"),s.nodeIdBuffer=o.from(s.nodeId,"hex"),s._debugId=s.peerId.toString("hex").substring(0,7),s.destroyed=!1,s.listening=!1,s.torrentPort=e.torrentPort||0,s.dhtPort=e.dhtPort||0,s.tracker=void 0!==e.tracker?e.tracker:{},s.torrents=[],s.maxConns=Number(e.maxConns)||55,s._debug("new webtorrent (peerId %s, nodeId %s, port %s)",s.peerId,s.nodeId,s.torrentPort),s.tracker&&("object"!=typeof s.tracker&&(s.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),s.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),s.tracker.wrtc=e.wrtc),r.WRTC&&!s.tracker.wrtc&&(s.tracker.wrtc=r.WRTC)),"function"==typeof w?s._tcpPool=new w(s):n.nextTick(function(){s._onListening()}),s._downloadSpeed=v(),s._uploadSpeed=v(),!1!==e.dht&&"function"==typeof c?(s.dht=new c(h({nodeId:s.nodeId},e.dht)),s.dht.once("error",function(e){s._destroy(e)}),s.dht.once("listening",function(){var e=s.dht.address();e&&(s.dhtPort=e.port)}),s.dht.setMaxListeners(0),s.dht.listen(s.dhtPort)):s.dht=!1,s.enableWebSeeds=!1!==e.webSeeds,"function"==typeof l&&null!=e.blocklist?l(e.blocklist,{headers:{"user-agent":"WebTorrent/"+k+" (https://webtorrent.io)"}},function(e,n){if(e)return s.error("Failed to load blocklist: "+e.message);s.blocked=n,t()}):n.nextTick(t)}t.exports=i;var o=e("safe-buffer").Buffer,s=e("simple-concat"),a=e("create-torrent"),u=e("debug")("webtorrent"),c=e("bittorrent-dht/client"),f=e("events").EventEmitter,h=e("xtend"),d=e("inherits"),l=e("load-ip-set"),p=e("run-parallel"),m=e("parse-torrent"),g=e("path"),y=e("simple-peer"),_=e("randombytes"),v=e("speedometer"),b=e("zero-fill"),w=e("./lib/tcp-pool"),E=e("./lib/torrent"),k=e("./package.json").version,x=k.match(/([0-9]+)/g).slice(0,2).map(function(e){return b(2,e)}).join(""),S="-WW"+x+"-";d(i,f),i.WEBRTC_SUPPORT=y.WEBRTC_SUPPORT,Object.defineProperty(i.prototype,"downloadSpeed",{get:function(){return this._downloadSpeed()}}),Object.defineProperty(i.prototype,"uploadSpeed",{get:function(){return this._uploadSpeed()}}),Object.defineProperty(i.prototype,"progress",{get:function(){var e=this.torrents.filter(function(e){return 1!==e.progress});return e.reduce(function(e,t){return e+t.downloaded},0)/(e.reduce(function(e,t){return e+(t.length||0)},0)||1)}}),Object.defineProperty(i.prototype,"ratio",{get:function(){return this.torrents.reduce(function(e,t){return e+t.uploaded},0)/(this.torrents.reduce(function(e,t){return e+t.received},0)||1)}}),i.prototype.get=function(e){var t,n,r,i=this.torrents.length;if(e instanceof E){for(n=0;n<i;n++)if((r=this.torrents[n])===e)return r}else{try{t=m(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw Error("Invalid torrent identifier");for(n=0;n<i;n++)if((r=this.torrents[n]).infoHash===t.infoHash)return r}return null},i.prototype.download=function(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)},i.prototype.add=function(e,t,n){function r(){if(!o.destroyed)for(var e=0,t=o.torrents.length;e<t;e++){var n=o.torrents[e];
1if(n.infoHash===s.infoHash&&n!==s)return void s._destroy(Error("Cannot add duplicate torrent "+s.infoHash))}}function i(){o.destroyed||("function"==typeof n&&n(s),o.emit("torrent",s))}var o=this;if(o.destroyed)throw Error("client is destroyed");if("function"==typeof t)return o.add(e,null,t);o._debug("add");var s=new E(e,o,t=t?h(t):{});return o.torrents.push(s),s.once("_infoHash",r),s.once("ready",i),s.once("close",function e(){s.removeListener("_infoHash",r),s.removeListener("ready",i),s.removeListener("close",e)}),s},i.prototype.seed=function(e,t,n){var r,i=this;if(i.destroyed)throw Error("client is destroyed");if("function"==typeof t)return i.seed(e,null,t);i._debug("seed"),t=t?h(t):{},"string"==typeof e&&(t.path=g.dirname(e)),t.createdBy||(t.createdBy="WebTorrent/"+x);var o,u=i.add(null,t,function(e){var t=[function(t){e.load(o,t)}];i.dht&&t.push(function(t){e.once("dhtAnnounce",t)}),p(t,function(t){if(!i.destroyed)return t?e._destroy(t):void(i._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),i.emit("seed",e))})});return r=e,"undefined"!=typeof FileList&&r instanceof FileList&&(e=Array.prototype.slice.call(e)),Array.isArray(e)||(e=[e]),p(e.map(function(e){return function(t){"object"==typeof e&&null!=e&&"function"==typeof e.pipe?s(e,t):t(null,e)}}),function(e,n){if(!i.destroyed)return e?u._destroy(e):void a.parseInput(n,t,function(e,r){if(!i.destroyed){if(e)return u._destroy(e);o=r.map(function(e){return e.getStream}),a(n,t,function(e,t){if(!i.destroyed){if(e)return u._destroy(e);var n=i.get(t);n?u._destroy(Error("Cannot add duplicate torrent "+n.infoHash)):u._onTorrentId(t)}})}})}),u},i.prototype.remove=function(e,t){if(this._debug("remove"),!this.get(e))throw Error("No torrent with id "+e);this._remove(e,t)},i.prototype._remove=function(e,t){var n=this.get(e);n&&(this.torrents.splice(this.torrents.indexOf(n),1),n.destroy(t))},i.prototype.address=function(){return this.listening?this._tcpPool?this._tcpPool.server.address():{address:"0.0.0.0",family:"IPv4",port:0}:null},i.prototype.destroy=function(e){if(this.destroyed)throw Error("client already destroyed");this._destroy(null,e)},i.prototype._destroy=function(e,t){var n=this;n._debug("client destroy"),n.destroyed=!0;var r=n.torrents.map(function(e){return function(t){e.destroy(t)}});n._tcpPool&&r.push(function(e){n._tcpPool.destroy(e)}),n.dht&&r.push(function(e){n.dht.destroy(e)}),p(r,t),e&&n.emit("error",e),n.torrents=[],n._tcpPool=null,n.dht=null},i.prototype._onListening=function(){if(this._debug("listening"),this.listening=!0,this._tcpPool){var e=this._tcpPool.server.address();e&&(this.torrentPort=e.port)}
1this.emit("listening")},i.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._debugId+"] "+e[0],u.apply(null,e)}}).call(this,e("_process"),void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/tcp-pool":21,"./lib/torrent":5,"./package.json":122,_process:66,"bittorrent-dht/client":21,"create-torrent":29,debug:30,events:34,inherits:41,"load-ip-set":21,"parse-torrent":62,path:63,randombytes:73,"run-parallel":86,"safe-buffer":88,"simple-concat":89,"simple-peer":91,speedometer:94,xtend:119,"zero-fill":121}]},{},[123])(123)},e.exports=r()}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.