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

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2019-08-07 05:24:39 +0300
committerFeross Aboukhadijeh <feross@feross.org>2019-08-07 05:24:39 +0300
commited2809159585d2611dff24a48f25748baf78e8fb (patch)
tree84d39b048beb19484c5a737604a4ee4f4716846d
parent9a21ed492db9c75745b958b76a04352b715a883b (diff)
build
-rw-r--r--webtorrent.min.js12
1 files changed, 1 insertions, 11 deletions
diff --git a/webtorrent.min.js b/webtorrent.min.js
index 9346d6b..1607068 100644
--- a/webtorrent.min.js
+++ b/webtorrent.min.js
@@ -1,11 +1 @@
-(function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,t.WebTorrent=e()}})(function(){var t=Math.abs,n=Math.pow,r=Math.floor,o=String.fromCharCode,a=Math.ceil,d=Math.max,s=Math.min,l;return function(){function d(s,e,n){function t(o,i){if(!e[o]){if(!s[o]){var l="function"==typeof require&&require;if(!i&&l)return l(o,!0);if(r)return r(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var a=e[o]={exports:{}};s[o][0].call(a.exports,function(e){var r=s[o][1][e];return t(r||e)},a,a.exports,d,s,e,n)}return e[o].exports}for(var r="function"==typeof require&&require,o=0;o<n.length;o++)t(n[o]);return t}return d}()({1:[function(e,t){const n=e("debug")("webtorrent:file-stream"),r=e("readable-stream");class o extends r.Readable{constructor(e,t){super(t),this.destroyed=!1,this._torrent=e._torrent;const n=t&&t.start||0,r=t&&t.end&&t.end<e.length?t.end:e.length-1,o=e._torrent.pieceLength;this._startPiece=0|(n+e.offset)/o,this._endPiece=0|(r+e.offset)/o,this._piece=this._startPiece,this._offset=n+e.offset-this._startPiece*o,this._missing=r-n+1,this._reading=!1,this._notifying=!1,this._criticalLength=s(0|1048576/o,2)}_read(){this._reading||(this._reading=!0,this._notify())}_notify(){if(!this._reading||0===this._missing)return;if(!this._torrent.bitfield.get(this._piece))return this._torrent.critical(this._piece,this._piece+this._criticalLength);if(this._notifying)return;if(this._notifying=!0,this._torrent.destroyed)return this._destroy(new Error("Torrent removed"));const e=this._piece;this._torrent.store.get(e,(t,r)=>(this._notifying=!1,this.destroyed?void 0:t?this._destroy(t):void(n("read %s (length %s) (err %s)",e,r.length,t&&t.message),this._offset&&(r=r.slice(this._offset),this._offset=0),this._missing<r.length&&(r=r.slice(0,this._missing)),this._missing-=r.length,n("pushing buffer of length %s",r.length),this._reading=!1,this.push(r),0===this._missing&&this.push(null)))),this._piece+=1}destroy(e){this._destroy(null,e)}_destroy(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())}}t.exports=o},{debug:33,"readable-stream":90}],2:[function(e,t){(function(n){const{EventEmitter:r}=e("events"),{PassThrough:o}=e("readable-stream"),i=e("end-of-stream"),a=e("path"),l=e("render-media"),c=e("stream-to-blob"),u=e("stream-to-blob-url"),f=e("stream-with-known-length-to-buffer"),p=e("./file-stream");class h extends r{constructor(e,t){super(),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;const n=t.offset,r=n+t.length-1;this._startPiece=0|n/this._torrent.pieceLength,this._endPiece=0|r/this._torrent.pieceLength,0===this.length&&(this.done=!0,this.emit("done"))}get downloaded(){if(!this._torrent.bitfield)return 0;const{pieces:e,bitfield:t,pieceLength:n}=this._torrent,{_startPiece:r,_endPiece:o}=this,i=e[r];let a=t.get(r)?n-this.offset%n:d(i.length-i.missing-this.offset,0);for(let i=r+1;i<=o;++i)if(t.get(i))a+=n;else{const t=e[i];a+=t.length-t.missing}return s(a,this.length)}get progress(){return this.length?this.downloaded/this.length:0}select(e){0===this.length||this._torrent.select(this._startPiece,this._endPiece,e)}deselect(){0===this.length||this._torrent.deselect(this._startPiece,this._endPiece,!1)}createReadStream(e){if(0===this.length){const e=new o;return n.nextTick(()=>{e.end()}),e}const t=new p(this,e);return this._torrent.select(t._startPiece,t._endPiece,!0,()=>{t._notify()}),i(t,()=>{this._destroyed||!this._torrent.destroyed&&this._torrent.deselect(t._startPiece,t._endPiece,!0)}),t}getBuffer(e){f(this.createReadStream(),this.length,e)}getBlob(e){if("undefined"==typeof window)throw new Error("browser-only method");c(this.createReadStream(),this._getMimeType()).then(t=>e(null,t),e)}getBlobURL(e){if("undefined"==typeof window)throw new Error("browser-only method");u(this.createReadStream(),this._getMimeType(),e)}appendTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");l.append(this,e,t,n)}renderTo(e,t,n){if("undefined"==typeof window)throw new Error("browser-only method");l.render(this,e,t,n)}_getMimeType(){return l.mime[a.extname(this.name).toLowerCase()]}_destroy(){this._destroyed=!0,this._torrent=null}}t.exports=h}).call(this,e("_process"))},{"./file-stream":1,_process:67,"end-of-stream":35,events:36,path:64,"readable-stream":90,"render-media":91,"stream-to-blob":120,"stream-to-blob-url":118,"stream-with-known-length-to-buffer":121}],3:[function(e,t,n){const r=e("unordered-array-remove"),o=e("debug")("webtorrent:peer"),i=e("bittorrent-protocol"),a=e("./webconn");n.createWebRTCPeer=(e,t)=>{const n=new d(e.id,"webrtc");return n.conn=e,n.swarm=t,n.conn.connected?n.onConnect():(n.conn.once("connect",()=>{n.onConnect()}),n.conn.once("error",e=>{n.destroy(e)}),n.startConnectTimeout()),n},n.createTCPIncomingPeer=e=>{const t=`${e.remoteAddress}:${e.remotePort}`,n=new d(t,"tcpIncoming");return n.conn=e,n.addr=t,n.onConnect(),n},n.createTCPOutgoingPeer=(e,t)=>{const n=new d(e,"tcpOutgoing");return n.addr=e,n.swarm=t,n},n.createWebSeedPeer=(e,t)=>{const n=new d(e,"webSeed");return n.swarm=t,n.conn=new a(e,t),n.onConnect(),n};class d{constructor(e,t){this.id=e,this.type=t,o("new %s Peer %s",t,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}onConnect(){if(!this.destroyed){this.connected=!0,o("Peer %s connected",this.id),clearTimeout(this.connectTimeout);const e=this.conn;e.once("end",()=>{this.destroy()}),e.once("close",()=>{this.destroy()}),e.once("finish",()=>{this.destroy()}),e.once("error",e=>{this.destroy(e)});const t=this.wire=new i;t.type=this.type,t.once("end",()=>{this.destroy()}),t.once("close",()=>{this.destroy()}),t.once("finish",()=>{this.destroy()}),t.once("error",e=>{this.destroy(e)}),t.once("handshake",(e,t)=>{this.onHandshake(e,t)}),this.startHandshakeTimeout(),e.pipe(t).pipe(e),this.swarm&&!this.sentHandshake&&this.handshake()}}onHandshake(e,t){if(!this.swarm)return;if(this.destroyed)return;if(this.swarm.destroyed)return this.destroy(new Error("swarm already destroyed"));if(e!==this.swarm.infoHash)return this.destroy(new Error("unexpected handshake info hash for this swarm"));if(t===this.swarm.peerId)return this.destroy(new Error("refusing to connect to ourselves"));o("Peer %s got handshake %s",this.id,e),clearTimeout(this.handshakeTimeout),this.retries=0;let n=this.addr;!n&&this.conn.remoteAddress&&this.conn.remotePort&&(n=`${this.conn.remoteAddress}:${this.conn.remotePort}`),this.swarm._onWire(this.wire,n);this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}handshake(){const e={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,e),this.sentHandshake=!0}startConnectTimeout(){clearTimeout(this.connectTimeout),this.connectTimeout=setTimeout(()=>{this.destroy(new Error("connect timeout"))},"webrtc"===this.type?25e3:5e3),this.connectTimeout.unref&&this.connectTimeout.unref()}startHandshakeTimeout(){clearTimeout(this.handshakeTimeout),this.handshakeTimeout=setTimeout(()=>{this.destroy(new Error("handshake timeout"))},25e3),this.handshakeTimeout.unref&&this.handshakeTimeout.unref()}destroy(e){if(this.destroyed)return;this.destroyed=!0,this.connected=!1,o("destroy %s (error: %s)",this.id,e&&(e.message||e)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);const t=this.swarm,n=this.conn,i=this.wire;this.swarm=null,this.conn=null,this.wire=null,t&&i&&r(t.wires,t.wires.indexOf(i)),n&&(n.on("error",()=>{}),n.destroy()),i&&i.destroy(),t&&t.removePeer(this.id)}}},{"./webconn":6,"bittorrent-protocol":14,debug:33,"unordered-array-remove":133}],4:[function(e,t){t.exports=class{constructor(e){this._torrent=e,this._numPieces=e.pieces.length,this._pieces=Array(this._numPieces),this._onWire=e=>{this.recalculate(),this._initWire(e)},this._onWireHave=e=>{this._pieces[e]+=1},this._onWireBitfield=()=>{this.recalculate()},this._torrent.wires.forEach(e=>{this._initWire(e)}),this._torrent.on("wire",this._onWire),this.recalculate()}getRarestPiece(e){let t=[],n=1/0;for(let r=0;r<this._numPieces;++r){if(e&&!e(r))continue;const o=this._pieces[r];o===n?t.push(r):o<n&&(t=[r],n=o)}return t.length?t[0|Math.random()*t.length]:-1}destroy(){this._torrent.removeListener("wire",this._onWire),this._torrent.wires.forEach(e=>{this._cleanupWireEvents(e)}),this._torrent=null,this._pieces=null,this._onWire=null,this._onWireHave=null,this._onWireBitfield=null}_initWire(e){e._onClose=()=>{this._cleanupWireEvents(e);for(let t=0;t<this._numPieces;++t)this._pieces[t]-=e.peerPieces.get(t)},e.on("have",this._onWireHave),e.on("bitfield",this._onWireBitfield),e.once("close",e._onClose)}recalculate(){this._pieces.fill(0);for(const e of this._torrent.wires)for(let t=0;t<this._numPieces;++t)this._pieces[t]+=e.peerPieces.get(t)}_cleanupWireEvents(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){(function(n,r){function o(e,t){return 2+a(t*e.downloadSpeed()/I.BLOCK_LENGTH)}function l(e,t,n){return 1+a(t*e.downloadSpeed()/n)}function c(e){return 0|Math.random()*e}function u(){}const f=e("addr-to-ip-port"),p=e("bitfield"),h=e("chunk-store-stream/write"),m=e("debug")("webtorrent:torrent"),g=e("torrent-discovery"),_=e("events").EventEmitter,b=e("fs"),i=e("fs-chunk-store"),y=e("simple-get"),w=e("immediate-chunk-store"),k=e("multistream"),x=e("net"),S=e("os"),E=e("run-parallel"),v=e("run-parallel-limit"),C=e("parse-torrent"),L=e("path"),I=e("torrent-piece"),T=e("pump"),R=e("random-iterate"),B=e("simple-sha1"),A=e("speedometer"),U=e("uniq"),P=e("ut_metadata"),M=e("ut_pex"),O=e("parse-numeric-range"),N=e("./file"),q=e("./peer"),H=e("./rarity-map"),j=e("./server"),D=5e3,F=3*I.BLOCK_LENGTH,W=1,z=n.browser?1/0:2,V=[1e3,5e3,15e3],G=e("../package.json").version,K=`WebTorrent/${G} (https://webtorrent.io)`;let Y;try{Y=L.join(b.statSync("/tmp")&&"/tmp","webtorrent")}catch(e){Y=L.join("function"==typeof S.tmpdir?S.tmpdir():"/","webtorrent")}class X extends _{constructor(e,t,n){super(),this._debugId="unknown infohash",this.client=t,this.announce=n.announce,this.urlList=n.urlList,this.path=n.path,this.skipVerify=!!n.skipVerify,this._store=n.store||i,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=A(),this._uploadSpeed=A(),this._servers=[],this._xsRequests=[],this._fileModtimes=n.fileModtimes,null!==e&&this._onTorrentId(e),this._debug("new torrent")}get timeRemaining(){return this.done?0:0===this.downloadSpeed?1/0:1e3*((this.length-this.downloaded)/this.downloadSpeed)}get downloaded(){if(!this.bitfield)return 0;let e=0;for(let t=0,n=this.pieces.length;t<n;++t)if(this.bitfield.get(t))e+=t==n-1?this.lastPieceLength:this.pieceLength;else{const n=this.pieces[t];e+=n.length-n.missing}return e}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){return this.length?this.downloaded/this.length:0}get ratio(){return this.uploaded/(this.received||1)}get numPeers(){return this.wires.length}get torrentFileBlobURL(){if("undefined"==typeof window)throw new Error("browser-only property");return this.torrentFile?URL.createObjectURL(new Blob([this.torrentFile],{type:"application/x-bittorrent"})):null}get _numQueued(){return this._queue.length+(this._peersLength-this._numConns)}get _numConns(){let e=0;for(const t in this._peers)this._peers[t].connected&&(e+=1);return e}get swarm(){return console.warn("WebTorrent: `torrent.swarm` is deprecated. Use `torrent` directly instead."),this}_onTorrentId(e){if(this.destroyed)return;let t;try{t=C(e)}catch(e){}t?(this.infoHash=t.infoHash,this._debugId=t.infoHash.toString("hex").substring(0,7),n.nextTick(()=>{this.destroyed||this._onParsedTorrent(t)})):C.remote(e,(e,t)=>this.destroyed?void 0:e?this._destroy(e):void this._onParsedTorrent(t))}_onParsedTorrent(e){if(!this.destroyed){if(this._processParsedTorrent(e),!this.infoHash)return this._destroy(new Error("Malformed torrent data: No info hash"));(this.path||(this.path=L.join(Y,this.infoHash)),this._rechokeIntervalId=setInterval(()=>{this._rechoke()},1e4),this._rechokeIntervalId.unref&&this._rechokeIntervalId.unref(),this.emit("_infoHash",this.infoHash),!this.destroyed)&&(this.emit("infoHash",this.infoHash),this.destroyed||(this.client.listening?this._onListening():this.client.once("listening",()=>{this._onListening()})))}}_processParsedTorrent(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)),U(e.announce),U(e.urlList),Object.assign(this,e),this.magnetURI=C.toMagnetURI(e),this.torrentFile=C.toTorrentFile(e)}_onListening(){if(this.discovery||this.destroyed)return;let e=this.client.tracker;e&&(e=Object.assign({},this.client.tracker,{getAnnounceOpts:()=>{const e={uploaded:this.uploaded,downloaded:this.downloaded,left:d(this.length-this.downloaded,0)};return this.client.tracker.getAnnounceOpts&&Object.assign(e,this.client.tracker.getAnnounceOpts()),this._getAnnounceOpts&&Object.assign(e,this._getAnnounceOpts()),e}})),this.discovery=new g({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:e,port:this.client.torrentPort,userAgent:K}),this.discovery.on("error",e=>{this._destroy(e)}),this.discovery.on("peer",e=>{"string"==typeof e&&this.done||this.addPeer(e)}),this.discovery.on("trackerAnnounce",()=>{this.emit("trackerAnnounce"),0===this.numPeers&&this.emit("noPeers","tracker")}),this.discovery.on("dhtAnnounce",()=>{this.emit("dhtAnnounce"),0===this.numPeers&&this.emit("noPeers","dht")}),this.discovery.on("warning",e=>{this.emit("warning",e)}),this.info?this._onMetadata(this):this.xs&&this._getMetadataFromServer()}_getMetadataFromServer(){function e(e,n){function r(r,o,i){if(t.destroyed)return n(null);if(t.metadata)return n(null);if(r)return t.emit("warning",new Error(`http error from xs param: ${e}`)),n(null);if(200!==o.statusCode)return t.emit("warning",new Error(`non-200 status code ${o.statusCode} from xs param: ${e}`)),n(null);let a;try{a=C(i)}catch(e){}return a?a.infoHash===t.infoHash?void(t._onMetadata(a),n(null)):(t.emit("warning",new Error(`got torrent file with incorrect info hash from xs param: ${e}`)),n(null)):(t.emit("warning",new Error(`got invalid torrent file from xs param: ${e}`)),n(null))}if(0!==e.indexOf("http://")&&0!==e.indexOf("https://"))return t.emit("warning",new Error(`skipping non-http xs param: ${e}`)),n(null);let o;try{o=y.concat({url:e,method:"GET",headers:{"user-agent":K}},r)}catch(r){return t.emit("warning",new Error(`skipping invalid url xs param: ${e}`)),n(null)}t._xsRequests.push(o)}const t=this,n=Array.isArray(this.xs)?this.xs:[this.xs],r=n.map(t=>n=>{e(t,n)});E(r)}_onMetadata(e){if(this.metadata||this.destroyed)return;this._debug("got metadata"),this._xsRequests.forEach(e=>{e.abort()}),this._xsRequests=[];let t;if(e&&e.infoHash)t=e;else try{t=C(e)}catch(e){return this._destroy(e)}if(this._processParsedTorrent(t),this.metadata=this.torrentFile,this.client.enableWebSeeds&&this.urlList.forEach(e=>{this.addWebSeed(e)}),this._rarityMap=new H(this),this.store=new w(new this._store(this.pieceLength,{torrent:{infoHash:this.infoHash},files:this.files.map(e=>({path:L.join(this.path,e.path),length:e.length,offset:e.offset})),length:this.length,name:this.infoHash})),this.files=this.files.map(e=>new N(this,e)),this.so){const e=O.parse(this.so);this.files.forEach((t,n)=>{e.includes(n)&&this.files[n].select(!0)})}else 0!==this.pieces.length&&this.select(0,this.pieces.length-1,!1);if(this._hashes=this.pieces,this.pieces=this.pieces.map((e,t)=>{const n=t===this.pieces.length-1?this.lastPieceLength:this.pieceLength;return new I(n)}),this._reservations=this.pieces.map(()=>[]),this.bitfield=new p(this.pieces.length),this.wires.forEach(e=>{e.ut_metadata&&e.ut_metadata.setMetadata(this.metadata),this._onWireWithMetadata(e)}),this.skipVerify)this._markAllVerified(),this._onStore();else{const e=e=>e?this._destroy(e):void(this._debug("done verifying"),this._onStore());this._debug("verifying existing torrent data"),this._fileModtimes&&this._store===i?this.getFileModtimes((t,n)=>{if(t)return this._destroy(t);const r=this.files.map((e,t)=>n[t]===this._fileModtimes[t]).every(e=>e);r?(this._markAllVerified(),this._onStore()):this._verifyPieces(e)}):this._verifyPieces(e)}this.emit("metadata")}getFileModtimes(e){const t=[];v(this.files.map((e,n)=>r=>{b.stat(L.join(this.path,e.path),(e,o)=>e&&"ENOENT"!==e.code?r(e):void(t[n]=o&&o.mtime.getTime(),r(null)))}),z,n=>{this._debug("done getting file modtimes"),e(n,t)})}_verifyPieces(e){v(this.pieces.map((e,t)=>e=>this.destroyed?e(new Error("torrent is destroyed")):void this.store.get(t,(r,o)=>this.destroyed?e(new Error("torrent is destroyed")):r?n.nextTick(e,null):void B(o,n=>{if(this.destroyed)return e(new Error("torrent is destroyed"));if(n===this._hashes[t]){if(!this.pieces[t])return;this._debug("piece verified %s",t),this._markVerified(t)}else this._debug("piece invalid %s",t);e(null)}))),z,e)}rescanFiles(e){if(this.destroyed)throw new Error("torrent is destroyed");e||(e=u),this._verifyPieces(t=>t?(this._destroy(t),e(t)):void(this._checkDone(),e(null)))}_markAllVerified(){for(let e=0;e<this.pieces.length;e++)this._markVerified(e)}_markVerified(e){this.pieces[e]=null,this._reservations[e]=null,this.bitfield.set(e,!0)}_onStore(){this.destroyed||(this._debug("on store"),this.ready=!0,this.emit("ready"),this._checkDone(),this._updateSelections())}destroy(e){this._destroy(null,e)}_destroy(e,t){if(!this.destroyed){for(const e in this.destroyed=!0,this._debug("destroy"),this.client._remove(this),clearInterval(this._rechokeIntervalId),this._xsRequests.forEach(e=>{e.abort()}),this._rarityMap&&this._rarityMap.destroy(),this._peers)this.removePeer(e);this.files.forEach(e=>{e instanceof N&&e._destroy()});const n=this._servers.map(e=>t=>{e.destroy(t)});this.discovery&&n.push(e=>{this.discovery.destroy(e)}),this.store&&n.push(e=>{this.store.close(e)}),E(n,t),e&&(0===this.listenerCount("error")?this.client.emit("error",e):this.emit("error",e)),this.emit("close"),this.client=null,this.files=[],this.discovery=null,this.store=null,this._rarityMap=null,this._peers=null,this._servers=null,this._xsRequests=null}}addPeer(t){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.infoHash)throw new Error("addPeer() must not be called before the `infoHash` event");if(this.client.blocked){let e;if("string"==typeof t){let n;try{n=f(t)}catch(n){return this._debug("ignoring peer: invalid %s",t),this.emit("invalidPeer",t),!1}e=n[0]}else"string"==typeof t.remoteAddress&&(e=t.remoteAddress);if(e&&this.client.blocked.contains(e))return this._debug("ignoring peer: blocked %s",t),"string"!=typeof t&&t.destroy(),this.emit("blockedPeer",t),!1}const n=!!this._addPeer(t);return n?this.emit("peer",t):this.emit("invalidPeer",t),n}_addPeer(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;const t=e&&e.id||e;if(this._peers[t])return this._debug("ignoring peer: duplicate (%s)",t),"string"!=typeof e&&e.destroy(),null;if(this.paused)return this._debug("ignoring peer: torrent is paused"),"string"!=typeof e&&e.destroy(),null;this._debug("add peer %s",t);let n;return n="string"==typeof e?q.createTCPOutgoingPeer(e,this):q.createWebRTCPeer(e,this),this._peers[n.id]=n,this._peersLength+=1,"string"==typeof e&&(this._queue.push(n),this._drain()),n}addWebSeed(e){if(this.destroyed)throw new Error("torrent is destroyed");if(!/^https?:\/\/.+/.test(e))return this.emit("warning",new Error(`ignoring invalid web seed: ${e}`)),void this.emit("invalidPeer",e);if(this._peers[e])return this.emit("warning",new Error(`ignoring duplicate web seed: ${e}`)),void this.emit("invalidPeer",e);this._debug("add web seed %s",e);const t=q.createWebSeedPeer(e,this);this._peers[t.id]=t,this._peersLength+=1,this.emit("peer",e)}_addIncomingPeer(e){return this.destroyed?e.destroy(new Error("torrent is destroyed")):this.paused?e.destroy(new Error("torrent is paused")):void(this._debug("add incoming peer %s",e.id),this._peers[e.id]=e,this._peersLength+=1)}removePeer(e){const t=e&&e.id||e;e=this._peers[t];e&&(this._debug("removePeer %s",t),delete this._peers[t],this._peersLength-=1,e.destroy(),this._drain())}select(e,t,n,r){if(this.destroyed)throw new Error("torrent is destroyed");if(0>e||t<e||this.pieces.length<=t)throw new Error(`invalid selection ${e} : ${t}`);n=+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||u}),this._selections.sort((e,t)=>t.priority-e.priority),this._updateSelections()}deselect(e,t,n){if(this.destroyed)throw new Error("torrent is destroyed");n=+n||0,this._debug("deselect %s-%s (priority %s)",e,t,n);for(let r=0;r<this._selections.length;++r){const o=this._selections[r];if(o.from===e&&o.to===t&&o.priority===n){this._selections.splice(r,1);break}}this._updateSelections()}critical(e,t){if(this.destroyed)throw new Error("torrent is destroyed");this._debug("critical %s-%s",e,t);for(let n=e;n<=t;++n)this._critical[n]=!0;this._updateSelections()}_onWire(e,t){if(this._debug("got wire %s (%s)",e._debugId,t||"Unknown"),e.on("download",e=>{this.destroyed||(this.received+=e,this._downloadSpeed(e),this.client._downloadSpeed(e),this.emit("download",e),this.client.emit("download",e))}),e.on("upload",e=>{this.destroyed||(this.uploaded+=e,this._uploadSpeed(e),this.client._uploadSpeed(e),this.emit("upload",e),this.client.emit("upload",e))}),this.wires.push(e),t){const n=f(t);e.remoteAddress=n[0],e.remotePort=n[1]}this.client.dht&&this.client.dht.listening&&e.on("port",n=>this.destroyed||this.client.dht.destroyed?void 0:e.remoteAddress?0===n||65536<n?this._debug("ignoring invalid PORT from peer"):void(this._debug("port: %s (from %s)",n,t),this.client.dht.addNode({host:e.remoteAddress,port:n})):this._debug("ignoring PORT from peer with no address")),e.on("timeout",()=>{this._debug("wire timeout (%s)",t),e.destroy()}),e.setTimeout(3e4,!0),e.setKeepAlive(!0),e.use(P(this.metadata)),e.ut_metadata.on("warning",e=>{this._debug("ut_metadata warning: %s",e.message)}),this.metadata||(e.ut_metadata.on("metadata",e=>{this._debug("got metadata via ut_metadata"),this._onMetadata(e)}),e.ut_metadata.fetch()),"function"!=typeof M||this.private||(e.use(M()),e.ut_pex.on("peer",e=>{this.done||(this._debug("ut_pex: got peer: %s (from %s)",e,t),this.addPeer(e))}),e.ut_pex.on("dropped",e=>{const n=this._peers[e];n&&!n.connected&&(this._debug("ut_pex: dropped peer: %s (from %s)",e,t),this.removePeer(e))}),e.once("close",()=>{e.ut_pex.reset()})),this.emit("wire",e,t),this.metadata&&n.nextTick(()=>{this._onWireWithMetadata(e)})}_onWireWithMetadata(e){let t=null;const n=()=>{this.destroyed||e.destroyed||(this._numQueued>2*(this._numConns-this.numPeers)&&e.amInterested?e.destroy():(t=setTimeout(n,D),t.unref&&t.unref()))};let r;const o=()=>{if(e.peerPieces.buffer.length===this.bitfield.buffer.length){for(r=0;r<this.pieces.length;++r)if(!e.peerPieces.get(r))return;e.isSeeder=!0,e.choke()}};e.on("bitfield",()=>{o(),this._update()}),e.on("have",()=>{o(),this._update()}),e.once("interested",()=>{e.unchoke()}),e.once("close",()=>{clearTimeout(t)}),e.on("choke",()=>{clearTimeout(t),t=setTimeout(n,D),t.unref&&t.unref()}),e.on("unchoke",()=>{clearTimeout(t),this._update()}),e.on("request",(t,n,r,o)=>r>131072?e.destroy():void(this.pieces[t]||this.store.get(t,{offset:n,length:r},o))),e.bitfield(this.bitfield),e.uninterested(),e.peerExtensions.dht&&this.client.dht&&this.client.dht.listening&&e.port(this.client.dht.address().port),"webSeed"!==e.type&&(t=setTimeout(n,D),t.unref&&t.unref()),e.isSeeder=!1,o()}_updateSelections(){!this.ready||this.destroyed||(n.nextTick(()=>{this._gcSelections()}),this._updateInterest(),this._update())}_gcSelections(){for(let e=0;e<this._selections.length;++e){const t=this._selections[e],n=t.offset;for(;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")}_updateInterest(){const e=this._amInterested;this._amInterested=!!this._selections.length,this.wires.forEach(e=>{let t=!1;for(let n=0;n<this.pieces.length;++n)if(this.pieces[n]&&e.peerPieces.get(n)){t=!0;break}t?e.interested():e.uninterested()});e===this._amInterested||(this._amInterested?this.emit("interested"):this.emit("uninterested"))}_update(){if(!this.destroyed){const e=R(this.wires);for(let t;t=e();)this._updateWireWrapper(t)}}_updateWireWrapper(e){const t=this;"undefined"!=typeof window&&"function"==typeof window.requestIdleCallback?window.requestIdleCallback(function(){t._updateWire(e)}):t._updateWire(e)}_updateWire(e){function t(t,n,r,o){return a=>a>=t&&a<=n&&!(a in r)&&e.peerPieces.get(a)&&(!o||o(a))}function n(){const t=e.downloadSpeed()||1;if(t>F)return()=>!0;const n=d(1,e.requests.length)*I.BLOCK_LENGTH/t;let r=10,o=0;return e=>{if(!r||a.bitfield.get(e))return!0;for(let i=a.pieces[e].missing;o<a.wires.length;o++){const d=a.wires[o],s=d.downloadSpeed();if(!(s<F)&&!(s<=t)&&d.peerPieces.get(e)&&!(0<(i-=s*n)))return r--,!1}return!0}}function r(e){let t=e;for(let n=e;n<a._selections.length&&a._selections[n].priority;n++)t=n;const n=a._selections[e];a._selections[e]=a._selections[t],a._selections[t]=n}function i(o){if(e.requests.length>=l)return!0;const d=n();for(let n=0;n<a._selections.length;n++){const i=a._selections[n];let s;if("rarest"===a.strategy){const c=i.from+i.offset,u=i.to,f={};let p=0;for(const h=t(c,u,f,d);p<u-c+1&&(s=a._rarityMap.getRarestPiece(h),!(0>s));){for(;a._request(e,s,a._critical[s]||o););if(e.requests.length<l){f[s]=!0,p++;continue}return i.priority&&r(n),!0}}else for(s=i.from+i.offset;s<=i.to;s++)if(e.peerPieces.get(s)&&d(s)){for(;a._request(e,s,a._critical[s]||o););if(!(e.requests.length<l))return i.priority&&r(n),!0}}return!1}const a=this;if(e.peerChoking)return;if(!e.downloaded)return function(){if(!e.requests.length)for(let n=a._selections.length;n--;){const r=a._selections[n];let o;if("rarest"===a.strategy){const n=r.from+r.offset,i=r.to,d={};let s=0;for(const r=t(n,i,d);s<i-n+1&&(o=a._rarityMap.getRarestPiece(r),!(0>o));){if(a._request(e,o,!1))return;d[o]=!0,s+=1}}else for(o=r.to;o>=r.from+r.offset;--o)if(e.peerPieces.get(o)&&a._request(e,o,!1))return}}();const s=o(e,.5);if(e.requests.length>=s)return;const l=o(e,W);i(!1)||i(!0)}_rechoke(){if(!this.ready)return;0<this._rechokeOptimisticTime?this._rechokeOptimisticTime-=1:this._rechokeOptimisticWire=null;const e=[];this.wires.forEach(t=>{t.isSeeder||t===this._rechokeOptimisticWire||e.push({wire:t,downloadSpeed:t.downloadSpeed(),uploadSpeed:t.uploadSpeed(),salt:Math.random(),isChoked:!0})}),e.sort(function(e,t){return e.downloadSpeed===t.downloadSpeed?e.uploadSpeed===t.uploadSpeed?e.wire.amChoking===t.wire.amChoking?e.salt-t.salt:e.wire.amChoking?1:-1:t.uploadSpeed-e.uploadSpeed:t.downloadSpeed-e.downloadSpeed});let t=0,n=0;for(;n<e.length&&t<this._rechokeNumSlots;++n)e[n].isChoked=!1,e[n].wire.peerInterested&&(t+=1);if(!this._rechokeOptimisticWire&&n<e.length&&this._rechokeNumSlots){const t=e.slice(n).filter(e=>e.wire.peerInterested),r=t[c(t.length)];r&&(r.isChoked=!1,this._rechokeOptimisticWire=r.wire,this._rechokeOptimisticTime=2)}e.forEach(e=>{e.wire.amChoking!==e.isChoked&&(e.isChoked?e.wire.choke():e.wire.unchoke())})}_hotswap(e,t){const n=e.downloadSpeed();if(n<I.BLOCK_LENGTH)return!1;if(!this._reservations[t])return!1;const o=this._reservations[t];if(!o)return!1;let r=1/0,a,d;for(d=0;d<o.length;d++){const t=o[d];if(!t||t===e)continue;const i=t.downloadSpeed();i>=F||2*i>n||i>r||(a=t,r=i)}if(!a)return!1;for(d=0;d<o.length;d++)o[d]===a&&(o[d]=null);for(d=0;d<a.requests.length;d++){const e=a.requests[d];e.piece===t&&this.pieces[t].cancel(0|e.offset/I.BLOCK_LENGTH)}return this.emit("hotswap",a,e,t),!0}_request(e,t,a){function d(){n.nextTick(()=>{c._update()})}const c=this,u=e.requests.length,f="webSeed"===e.type;if(c.bitfield.get(t))return!1;const p=f?s(l(e,W,c.pieceLength),c.maxWebConns):o(e,W);if(u>=p)return!1;const h=c.pieces[t];let m=f?h.reserveRemaining():h.reserve();if(-1===m&&a&&c._hotswap(e,t)&&(m=f?h.reserveRemaining():h.reserve()),-1===m)return!1;let g=c._reservations[t];g||(g=c._reservations[t]=[]);let _=g.indexOf(null);-1===_&&(_=g.length),g[_]=e;const b=h.chunkOffset(m),y=f?h.chunkLengthRemaining(m):h.chunkLength(m);return e.request(t,b,y,function n(r,o){if(c.destroyed)return;if(!c.ready)return c.once("ready",()=>{n(r,o)});if(g[_]===e&&(g[_]=null),h!==c.pieces[t])return d();if(r)return c._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,b,y,`${e.remoteAddress}:${e.remotePort}`,r.message),f?h.cancelRemaining(m):h.cancel(m),void d();if(c._debug("got piece %s (offset: %s length: %s) from %s",t,b,y,`${e.remoteAddress}:${e.remotePort}`),!h.set(m,o,e))return d();const i=h.flush();B(i,e=>{if(!c.destroyed){if(e===c._hashes[t]){if(!c.pieces[t])return;c._debug("piece verified %s",t),c.pieces[t]=null,c._reservations[t]=null,c.bitfield.set(t,!0),c.store.put(t,i),c.wires.forEach(e=>{e.have(t)}),c._checkDone()&&!c.destroyed&&c.discovery.complete()}else c.pieces[t]=new I(h.length),c.emit("warning",new Error(`Piece ${t} failed verification`));d()}})}),!0}_checkDone(){if(this.destroyed)return;this.files.forEach(e=>{if(!e.done){for(let t=e._startPiece;t<=e._endPiece;++t)if(!this.bitfield.get(t))return;e.done=!0,e.emit("done"),this._debug(`file done: ${e.name}`)}});let e=!0;for(let t=0;t<this._selections.length;t++){const n=this._selections[t];for(let t=n.from;t<=n.to;t++)if(!this.bitfield.get(t)){e=!1;break}if(!e)break}return!this.done&&e&&(this.done=!0,this._debug(`torrent done: ${this.infoHash}`),this.emit("done")),this._gcSelections(),e}load(e,t){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.ready)return this.once("ready",()=>{this.load(e,t)});Array.isArray(e)||(e=[e]),t||(t=u);const n=new k(e),r=new h(this.store,this.pieceLength);T(n,r,e=>e?t(e):void(this._markAllVerified(),this._checkDone(),t(null)))}createServer(e){if("function"!=typeof j)throw new Error("node.js-only method");if(this.destroyed)throw new Error("torrent is destroyed");const t=new j(this,e);return this._servers.push(t),t}pause(){this.destroyed||(this._debug("pause"),this.paused=!0)}resume(){this.destroyed||(this._debug("resume"),this.paused=!1,this._drain())}_debug(){const e=[].slice.call(arguments);e[0]=`[${this.client._debugId}] [${this._debugId}] ${e[0]}`,m(...e)}_drain(){if(this._debug("_drain numConns %s maxConns %s",this._numConns,this.client.maxConns),"function"!=typeof x.connect||this.destroyed||this.paused||this._numConns>=this.client.maxConns)return;this._debug("drain (%s queued, %s/%s peers)",this._numQueued,this.numPeers,this.client.maxConns);const e=this._queue.shift();if(!e)return;this._debug("tcp connect attempt to %s",e.addr);const t=f(e.addr),n={host:t[0],port:t[1]},r=e.conn=x.connect(n);r.once("connect",()=>{e.onConnect()}),r.once("error",t=>{e.destroy(t)}),e.startConnectTimeout(),r.on("close",()=>{if(!this.destroyed){if(e.retries>=V.length)return void this._debug("conn %s closed: will not re-add (max %s attempts)",e.addr,V.length);const t=V[e.retries];this._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",e.addr,t,e.retries+1);const n=setTimeout(()=>{const t=this._addPeer(e.addr);t&&(t.retries=e.retries+1)},t);n.unref&&n.unref()}})}_validAddr(e){let t;try{t=f(e)}catch(t){return!1}const n=t[0],r=t[1];return 0<r&&65535>r&&("127.0.0.1"!==n||r!==this.client.torrentPort)}}t.exports=X}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"../package.json":142,"./file":2,"./peer":3,"./rarity-map":4,"./server":21,_process:67,"addr-to-ip-port":7,bitfield:13,"chunk-store-stream/write":29,debug:33,events:36,fs:22,"fs-chunk-store":51,"immediate-chunk-store":41,multistream:59,net:21,os:21,"parse-numeric-range":62,"parse-torrent":63,path:64,pump:68,"random-iterate":73,"run-parallel":94,"run-parallel-limit":93,"simple-get":98,"simple-sha1":100,speedometer:102,"torrent-discovery":128,"torrent-piece":129,uniq:132,ut_metadata:136,ut_pex:21}],6:[function(e,t){const n=e("bitfield"),r=e("safe-buffer").Buffer,o=e("debug")("webtorrent:webconn"),i=e("simple-get"),a=e("simple-sha1"),l=e("bittorrent-protocol"),c=e("../package.json").version;t.exports=class extends l{constructor(e,t){super(),this.url=e,this.webPeerId=a.sync(e),this._torrent=t,this._init()}_init(){this.setKeepAlive(!0),this.once("handshake",e=>{if(this.destroyed)return;this.handshake(e,this.webPeerId);const t=this._torrent.pieces.length,r=new n(t);for(let n=0;n<=t;n++)r.set(n,!0);this.bitfield(r)}),this.once("interested",()=>{o("interested"),this.unchoke()}),this.on("uninterested",()=>{o("uninterested")}),this.on("choke",()=>{o("choke")}),this.on("unchoke",()=>{o("unchoke")}),this.on("bitfield",()=>{o("bitfield")}),this.on("request",(e,t,n,r)=>{o("request pieceIndex=%d offset=%d length=%d",e,t,n),this.httpRequest(e,t,n,r)})}httpRequest(e,t,n,a){const l=e*this._torrent.pieceLength,u=l+t,f=u+n-1,p=this._torrent.files;let h;if(1>=p.length)h=[{url:this.url,start:u,end:f}];else{const e=p.filter(e=>e.offset<=f&&e.offset+e.length>u);if(1>e.length)return a(new Error("Could not find file corresponnding to web seed range request"));h=e.map(e=>{const t=e.offset+e.length-1,n=this.url+("/"===this.url[this.url.length-1]?"":"/")+e.path;return{url:n,fileOffsetInRange:d(e.offset-u,0),start:d(u-e.offset,0),end:s(t,f-e.offset)}})}let m=0,g=!1,_;1<h.length&&(_=r.alloc(n)),h.forEach(r=>{function d(e,t){return 200>e.statusCode||300<=e.statusCode?(g=!0,a(new Error(`Unexpected HTTP status code ${e.statusCode}`))):void(o("Got data of length %d",t.length),1===h.length?a(null,t):(t.copy(_,r.fileOffsetInRange),++m===h.length&&a(null,_)))}const s=r.url,l=r.start,u=r.end;o("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",s,e,t,n,l,u);const f={url:s,method:"GET",headers:{"user-agent":`WebTorrent/${c} (https://webtorrent.io)`,range:`bytes=${l}-${u}`}};i.concat(f,(e,t,n)=>g?void 0:e?"undefined"==typeof window||s.startsWith(`${window.location.origin}/`)?(g=!0,a(e)):i.head(s,(t,n)=>g?void 0:t?(g=!0,a(t)):200>n.statusCode||300<=n.statusCode?(g=!0,a(new Error(`Unexpected HTTP status code ${n.statusCode}`))):n.url===s?(g=!0,a(e)):void(f.url=n.url,i.concat(f,(e,t,n)=>g?void 0:e?(g=!0,a(e)):void d(t,n)))):void d(t,n))})}destroy(){super.destroy(),this._torrent=null}}},{"../package.json":142,bitfield:13,"bittorrent-protocol":14,debug:33,"safe-buffer":96,"simple-get":98,"simple-sha1":100}],7:[function(e,t){const n=/^\[?([^\]]+)\]?:(\d+)$/;let r={},o=0;t.exports=function(e){if(1e5===o&&t.exports.reset(),!r[e]){const t=n.exec(e);if(!t)throw new Error(`invalid addr: ${e}`);r[e]=[t[1],+t[2]],o+=1}return r[e]},t.exports.reset=function(){r={},o=0}},{}],8:[function(e,t,n){'use strict';function r(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");-1===n&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function o(e,t,n){return 3*(t+n)/4-n}function a(e){for(var t=r(e),n=t[0],a=t[1],d=new f(o(e,n,a)),s=0,l=0<a?n-4:n,c=0,p;c<l;c+=4)p=u[e.charCodeAt(c)]<<18|u[e.charCodeAt(c+1)]<<12|u[e.charCodeAt(c+2)]<<6|u[e.charCodeAt(c+3)],d[s++]=255&p>>16,d[s++]=255&p>>8,d[s++]=255&p;return 2===a&&(p=u[e.charCodeAt(c)]<<2|u[e.charCodeAt(c+1)]>>4,d[s++]=255&p),1===a&&(p=u[e.charCodeAt(c)]<<10|u[e.charCodeAt(c+1)]<<4|u[e.charCodeAt(c+2)]>>2,d[s++]=255&p>>8,d[s++]=255&p),d}function d(e){return c[63&e>>18]+c[63&e>>12]+c[63&e>>6]+c[63&e]}function s(e,t,n){for(var r=[],o=t,a;o<n;o+=3)a=(16711680&e[o]<<16)+(65280&e[o+1]<<8)+(255&e[o+2]),r.push(d(a));return r.join("")}function l(e){for(var t=e.length,n=t%3,r=[],o=16383,a=0,d=t-n,l;a<d;a+=o)r.push(s(e,a,a+o>d?d:a+o));return 1===n?(l=e[t-1],r.push(c[l>>2]+c[63&l<<4]+"==")):2===n&&(l=(e[t-2]<<8)+e[t-1],r.push(c[l>>10]+c[63&l>>4]+c[63&l<<2]+"=")),r.join("")}n.byteLength=function(e){var t=r(e),n=t[0],o=t[1];return 3*(n+o)/4-o},n.toByteArray=a,n.fromByteArray=l;for(var c=[],u=[],f="undefined"==typeof Uint8Array?Array:Uint8Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,m=p.length;h<m;++h)c[h]=p[h],u[p.charCodeAt(h)]=h;u[45]=62,u[95]=63},{}],9:[function(e,t){function n(e,t,n){for(var r=0,o=1,a=t,d;a<n;a++){if(d=e[a],58>d&&48<=d){r=10*r+(d-48);continue}if(a!==t||43!==d){if(a===t&&45===d){o=-1;continue}if(46===d)break;throw new Error("not a number: buffer["+a+"] = "+d)}}return r*o}function r(e,t,n,o){return null==e||0===e.length?null:("number"!=typeof t&&null==o&&(o=t,t=void 0),"number"!=typeof n&&null==o&&(o=n,n=void 0),r.position=0,r.encoding=o||null,r.data=i.isBuffer(e)?e.slice(t,n):i.from(e),r.bytes=r.data.length,r.next())}var i=e("safe-buffer").Buffer;const a=101;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,a=r.data;t<n;){if(a[t]===e)return t;t++}throw new Error("Invalid data: Missing delimiter \""+o(e)+"\" [0x"+e.toString(16)+"]")},r.dictionary=function(){r.position++;for(var e={};r.data[r.position]!==a;)e[r.buffer()]=r.next();return r.position++,e},r.list=function(){r.position++;for(var e=[];r.data[r.position]!==a;)e.push(r.next());return r.position++,e},r.integer=function(){var e=r.find(a),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),o=++e+t;return r.position=o,r.encoding?r.data.toString(r.encoding,e,o):r.data.slice(e,o)},t.exports=r},{"safe-buffer":96}],10:[function(e,t){function n(e,t,o){var i=[],a=null;return n._encode(i,e),a=r.concat(i),n.bytes=a.length,r.isBuffer(t)?(a.copy(t,o),t):a}var r=e("safe-buffer").Buffer;n.bytes=-1,n._floatConversionDetected=!1,n.getType=function(e){return r.isBuffer(e)?"buffer":Array.isArray(e)?"array":ArrayBuffer.isView(e)?"arraybufferview":e instanceof Number?"number":e instanceof Boolean?"boolean":e instanceof ArrayBuffer?"arraybuffer":typeof e},n._encode=function(e,t){if(null!=t)switch(n.getType(t)){case"buffer":n.buffer(e,t);break;case"object":n.dict(e,t);break;case"array":n.list(e,t);break;case"string":n.string(e,t);break;case"number":n.number(e,t);break;case"boolean":n.number(e,t);break;case"arraybufferview":n.buffer(e,r.from(t.buffer,t.byteOffset,t.byteLength));break;case"arraybuffer":n.buffer(e,r.from(t));}};var o=r.from("e"),i=r.from("d"),a=r.from("l");n.buffer=function(e,t){e.push(r.from(t.length+":"),t)},n.string=function(e,t){e.push(r.from(r.byteLength(t)+":"+t))},n.number=function(e,t){var o=(t/2147483648<<0)*2147483648+(t%2147483648<<0);e.push(r.from("i"+o+"e")),o===t||n._floatConversionDetected||(n._floatConversionDetected=!0,console.warn("WARNING: Possible data corruption detected with value \""+t+"\":","Bencoding only defines support for integers, value was converted to \""+o+"\""),console.trace())},n.dict=function(e,t){e.push(i);for(var r=0,a=Object.keys(t).sort(),d=a.length,s;r<d;r++)s=a[r],null==t[s]||(n.string(e,s),n._encode(e,t[s]));e.push(o)},n.list=function(e,t){var r=0,d=t.length;for(e.push(a);r<d;r++)null!=t[r]&&n._encode(e,t[r]);e.push(o)},t.exports=n},{"safe-buffer":96}],11:[function(e,t){var n=t.exports;n.encode=e("./encode"),n.decode=e("./decode"),n.byteLength=n.encodingLength=function(e){return n.encode(e).length}},{"./decode":9,"./encode":10}],12:[function(e,t){t.exports=function(e,t,n,r,o){var i,a;if(void 0===r)r=0;else if(r|=0,0>r||r>=e.length)throw new RangeError("invalid lower bound");if(void 0===o)o=e.length-1;else if(o|=0,o<r||o>=e.length)throw new RangeError("invalid upper bound");for(;r<=o;)if(i=r+(o-r>>1),a=+n(e[i],t,i,e),0>a)r=i+1;else if(0<a)o=i-1;else return i;return~r}},{}],13:[function(e,t){function n(e){let t=e>>3;return 0!=e%8&&t++,t}"undefined"!=typeof t&&(t.exports=class{constructor(e=0,t){const r=null!=t&&t.grow;this.grow=r&&isFinite(r)&&n(r)||r||0,this.buffer="number"==typeof e?new Uint8Array(n(e)):e}get(e){const t=e>>3;return t<this.buffer.length&&!!(this.buffer[t]&128>>e%8)}set(e,t=!0){const n=e>>3;if(t){if(this.buffer.length<n+1){const e=d(n+1,s(2*this.buffer.length,this.grow));if(e<=this.grow){const t=new Uint8Array(e);t.set(this.buffer),this.buffer=t}}this.buffer[n]|=128>>e%8}else n<this.buffer.length&&(this.buffer[n]&=~(128>>e%8))}})},{}],14:[function(e,t){(function(n){const r=e("unordered-array-remove"),o=e("bencode"),i=e("bitfield"),a=e("debug")("bittorrent-protocol"),d=e("randombytes"),s=e("speedometer"),l=e("readable-stream"),c=n.from("\x13BitTorrent protocol"),u=n.from([0,0,0,0]),f=n.from([0,0,0,1,0]),p=n.from([0,0,0,1,1]),h=n.from([0,0,0,1,2]),m=n.from([0,0,0,1,3]),g=[0,0,0,0,0,0,0,0],_=[0,0,0,3,9,0,0];class b{constructor(e,t,n,r){this.piece=e,this.offset=t,this.length=n,this.callback=r}}class y extends l.Duplex{constructor(){super(),this._debugId=d(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 i(0,{grow:4e5}),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=s(),this.downloadSpeed=s(),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()}setKeepAlive(e){this._debug("setKeepAlive %s",e),clearInterval(this._keepAliveInterval);!1===e||(this._keepAliveInterval=setInterval(()=>{this.keepAlive()},55e3))}setTimeout(e,t){this._debug("setTimeout ms=%d unref=%s",e,t),this._clearTimeout(),this._timeoutMs=e,this._timeoutUnref=!!t,this._updateTimeout()}destroy(){this.destroyed||(this.destroyed=!0,this._debug("destroy"),this.emit("close"),this.end())}end(...e){this._debug("end"),this._onUninterested(),this._onChoke(),super.end(...e)}use(e){function t(){}const n=e.prototype.name;if(!n)throw new Error("Extension class requires a \"name\" property on the prototype");this._debug("use extension.name=%s",n);const r=this._nextExt,o=new e(this);"function"!=typeof o.onHandshake&&(o.onHandshake=t),"function"!=typeof o.onExtendedHandshake&&(o.onExtendedHandshake=t),"function"!=typeof o.onMessage&&(o.onMessage=t),this.extendedMapping[r]=n,this._ext[n]=o,this[n]=o,this._nextExt+=1}keepAlive(){this._debug("keep-alive"),this._push(u)}handshake(e,t,r){let o,i;if("string"==typeof e?(e=e.toLowerCase(),o=n.from(e,"hex")):(o=e,e=o.toString("hex")),"string"==typeof t?i=n.from(t,"hex"):(i=t,t=i.toString("hex")),20!==o.length||20!==i.length)throw new Error("infoHash and peerId MUST have length 20");this._debug("handshake i=%s p=%s exts=%o",e,t,r);const a=n.from(g);a[5]|=16,r&&r.dht&&(a[7]|=1),this._push(n.concat([c,a,o,i])),this._handshakeSent=!0,this.peerExtensions.extended&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_sendExtendedHandshake(){const e=Object.assign({},this.extendedHandshake);for(const t in e.m={},this.extendedMapping){const n=this.extendedMapping[t];e.m[n]=+t}this.extended(0,o.encode(e)),this._extendedHandshakeSent=!0}choke(){if(!this.amChoking){for(this.amChoking=!0,this._debug("choke");this.peerRequests.length;)this.peerRequests.pop();this._push(f)}}unchoke(){this.amChoking&&(this.amChoking=!1,this._debug("unchoke"),this._push(p))}interested(){this.amInterested||(this.amInterested=!0,this._debug("interested"),this._push(h))}uninterested(){this.amInterested&&(this.amInterested=!1,this._debug("uninterested"),this._push(m))}have(e){this._debug("have %d",e),this._message(4,[e],null)}bitfield(e){this._debug("bitfield"),n.isBuffer(e)||(e=e.buffer),this._message(5,[],e)}request(e,t,n,r){return r||(r=()=>{}),this._finished?r(new Error("wire is closed")):this.peerChoking?r(new Error("peer is choking")):void(this._debug("request index=%d offset=%d length=%d",e,t,n),this.requests.push(new b(e,t,n,r)),this._updateTimeout(),this._message(6,[e,t,n],null))}piece(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)}cancel(e,t,n){this._debug("cancel index=%d offset=%d length=%d",e,t,n),this._callback(this._pull(this.requests,e,t,n),new Error("request was cancelled"),null),this._message(8,[e,t,n],null)}port(e){this._debug("port %d",e);const t=n.from(_);t.writeUInt16BE(e,5),this._push(t)}extended(e,t){if(this._debug("extended ext=%s",e),"string"==typeof e&&this.peerExtendedMapping[e]&&(e=this.peerExtendedMapping[e]),"number"==typeof e){const r=n.from([e]),i=n.isBuffer(t)?t:o.encode(t);this._message(20,[],n.concat([r,i]))}else throw new Error(`Unrecognized extension: ${e}`)}_read(){}_message(e,t,r){const o=r?r.length:0,a=n.allocUnsafe(5+4*t.length);a.writeUInt32BE(a.length+o-4,0),a[4]=e;for(let n=0;n<t.length;n++)a.writeUInt32BE(t[n],5+4*n);this._push(a),r&&this._push(r)}_push(e){return this._finished?void 0:this.push(e)}_onKeepAlive(){this._debug("got keep-alive"),this.emit("keep-alive")}_onHandshake(e,t,n){const r=e.toString("hex"),o=t.toString("hex");this._debug("got handshake i=%s p=%s exts=%o",r,o,n),this.peerId=o,this.peerIdBuffer=t,this.peerExtensions=n,this.emit("handshake",r,o,n);for(var i in this._ext)this._ext[i].onHandshake(r,o,n);n.extended&&this._handshakeSent&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_onChoke(){for(this.peerChoking=!0,this._debug("got choke"),this.emit("choke");this.requests.length;)this._callback(this.requests.pop(),new Error("peer is choking"),null)}_onUnchoke(){this.peerChoking=!1,this._debug("got unchoke"),this.emit("unchoke")}_onInterested(){this.peerInterested=!0,this._debug("got interested"),this.emit("interested")}_onUninterested(){this.peerInterested=!1,this._debug("got uninterested"),this.emit("uninterested")}_onHave(e){this.peerPieces.get(e)||(this._debug("got have %d",e),this.peerPieces.set(e,!0),this.emit("have",e))}_onBitField(e){this.peerPieces=new i(e),this._debug("got bitfield"),this.emit("bitfield",this.peerPieces)}_onRequest(e,t,n){if(!this.amChoking){this._debug("got request index=%d offset=%d length=%d",e,t,n);const o=(o,i)=>r===this._pull(this.peerRequests,e,t,n)?o?this._debug("error satisfying request index=%d offset=%d length=%d (%s)",e,t,n,o.message):void this.piece(e,t,i):void 0;var r=new b(e,t,n,o);this.peerRequests.push(r),this.emit("request",e,t,n,o)}}_onPiece(e,t,n){this._debug("got piece index=%d offset=%d",e,t),this._callback(this._pull(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)}_onCancel(e,t,n){this._debug("got cancel index=%d offset=%d length=%d",e,t,n),this._pull(this.peerRequests,e,t,n),this.emit("cancel",e,t,n)}_onPort(e){this._debug("got port %d",e),this.emit("port",e)}_onExtended(e,t){if(0===e){let e;try{e=o.decode(t)}catch(e){this._debug("ignoring invalid extended handshake: %s",e.message||e)}if(!e)return;this.peerExtendedHandshake=e;if("object"==typeof e.m)for(var n in e.m)this.peerExtendedMapping[n]=+e.m[n].toString();for(n in this._ext)this.peerExtendedMapping[n]&&this._ext[n].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)}_onTimeout(){this._debug("request timed out"),this._callback(this.requests.shift(),new Error("request has timed out"),null),this.emit("timeout")}_write(e,t,r){for(this._bufferSize+=e.length,this._buffer.push(e);this._bufferSize>=this._parserSize;){const e=1===this._buffer.length?this._buffer[0]:n.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[e.slice(this._parserSize)]:[],this._parser(e.slice(0,this._parserSize))}r(null)}_callback(e,t,n){e&&(this._clearTimeout(),!this.peerChoking&&!this._finished&&this._updateTimeout(),e.callback(t,n))}_clearTimeout(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)}_updateTimeout(){this._timeoutMs&&this.requests.length&&!this._timeout&&(this._timeout=setTimeout(()=>this._onTimeout(),this._timeoutMs),this._timeoutUnref&&this._timeout.unref&&this._timeout.unref())}_parse(e,t){this._parserSize=e,this._parser=t}_onMessageLength(e){const t=e.readUInt32BE(0);0<t?this._parse(t,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))}_onMessage(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);}}_parseHandshake(){this._parse(1,e=>{const t=e.readUInt8(0);this._parse(t+48,e=>{const n=e.slice(0,t);return"BitTorrent protocol"===n.toString()?void(e=e.slice(t),this._onHandshake(e.slice(8,28),e.slice(28,48),{dht:!!(1&e[7]),extended:!!(16&e[5])}),this._parse(4,this._onMessageLength)):(this._debug("Error: wire not speaking BitTorrent protocol (%s)",n.toString()),void this.end())})})}_onFinish(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,()=>{});this.peerRequests.length;)this.peerRequests.pop();for(;this.requests.length;)this._callback(this.requests.pop(),new Error("wire was closed"),null)}_debug(...e){e[0]=`[${this._debugId}] ${e[0]}`,a(...e)}_pull(e,t,n,o){for(let a=0;a<e.length;a++){const i=e[a];if(i.piece===t&&i.offset===n&&i.length===o)return r(e,a),i}return null}}t.exports=y}).call(this,e("buffer").Buffer)},{bencode:11,bitfield:13,buffer:27,debug:33,randombytes:74,"readable-stream":90,speedometer:102,"unordered-array-remove":133}],15:[function(e,t){(function(n){const{Buffer:r}=e("safe-buffer"),o=e("debug")("bittorrent-tracker:client"),i=e("events"),a=e("once"),d=e("run-parallel"),s=e("simple-peer"),l=e("uniq"),c=e("url").URL,u=e("./lib/common"),f=e("./lib/client/http-tracker"),p=e("./lib/client/udp-tracker"),h=e("./lib/client/websocket-tracker");class m extends i{constructor(e={}){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this._peerIdBuffer=r.from(this.peerId,"hex"),this._peerIdBinary=this._peerIdBuffer.toString("binary"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._infoHashBuffer=r.from(this.infoHash,"hex"),this._infoHashBinary=this._infoHashBuffer.toString("binary"),o("new client %s",this.infoHash),this.destroyed=!1,this._port=e.port,this._getAnnounceOpts=e.getAnnounceOpts,this._rtcConfig=e.rtcConfig,this._userAgent=e.userAgent,this._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc;let t="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;t=t.map(e=>(e=e.toString(),"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),e)),t=l(t);const i=!1!==this._wrtc&&(!!this._wrtc||s.WEBRTC_SUPPORT),a=e=>{n.nextTick(()=>{this.emit("warning",e)})};this._trackers=t.map(e=>{let t;try{t=new c(e)}catch(t){return a(new Error(`Invalid tracker URL: ${e}`)),null}const n=t.port;if(0>n||65535<n)return a(new Error(`Invalid tracker port: ${e}`)),null;const r=t.protocol;return("http:"===r||"https:"===r)&&"function"==typeof f?new f(this,e):"udp:"===r&&"function"==typeof p?new p(this,e):("ws:"===r||"wss:"===r)&&i?"ws:"===r&&"undefined"!=typeof window&&"https:"===window.location.protocol?(a(new Error(`Unsupported tracker protocol: ${e}`)),null):new h(this,e):(a(new Error(`Unsupported tracker protocol: ${e}`)),null)}).filter(Boolean)}start(e){o("send `start`"),e=this._defaultAnnounceOpts(e),e.event="started",this._announce(e),this._trackers.forEach(e=>{e.setInterval()})}stop(e){o("send `stop`"),e=this._defaultAnnounceOpts(e),e.event="stopped",this._announce(e)}complete(e){o("send `complete`"),e||(e={}),e=this._defaultAnnounceOpts(e),e.event="completed",this._announce(e)}update(e){o("send `update`"),e=this._defaultAnnounceOpts(e),e.event&&delete e.event,this._announce(e)}_announce(e){this._trackers.forEach(t=>{t.announce(e)})}scrape(e){o("send `scrape`"),e||(e={}),this._trackers.forEach(t=>{t.scrape(e)})}setInterval(e){o("setInterval %d",e),this._trackers.forEach(t=>{t.setInterval(e)})}destroy(e){if(!this.destroyed){this.destroyed=!0,o("destroy");const t=this._trackers.map(e=>t=>{e.destroy(t)});d(t,e),this._trackers=[],this._getAnnounceOpts=null}}_defaultAnnounceOpts(e={}){return null==e.numwant&&(e.numwant=u.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),this._getAnnounceOpts&&(e=Object.assign({},e,this._getAnnounceOpts())),e}}m.scrape=(e,t)=>{if(t=a(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");const n=Object.assign({},e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:r.from("01234567890123456789"),port:6881}),o=new m(n);o.once("error",t),o.once("warning",t);let i=Array.isArray(e.infoHash)?e.infoHash.length:1;const d={};return o.on("scrape",e=>{if(i-=1,d[e.infoHash]=e,0===i){o.destroy();const e=Object.keys(d);1===e.length?t(null,d[e[0]]):t(null,d)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(e=>r.from(e,"hex")):r.from(e.infoHash,"hex"),o.scrape({infoHash:e.infoHash}),o},t.exports=m}).call(this,e("_process"))},{"./lib/client/http-tracker":21,"./lib/client/udp-tracker":21,"./lib/client/websocket-tracker":17,"./lib/common":18,_process:67,debug:33,events:36,once:61,"run-parallel":94,"safe-buffer":96,"simple-peer":99,uniq:132,url:134}],16:[function(e,t){const n=e("events");t.exports=class extends n{constructor(e,t){super(),this.client=e,this.announceUrl=t,this.interval=null,this.destroyed=!1}setInterval(e){null==e&&(e=this.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(this.interval),e&&(this.interval=setInterval(()=>{this.announce(this.client._defaultAnnounceOpts())},e),this.interval.unref&&this.interval.unref())}}},{events:36}],17:[function(e,t){function o(){}const i=e("debug")("bittorrent-tracker:websocket-tracker"),a=e("simple-peer"),d=e("randombytes"),l=e("simple-websocket"),c=e("../common"),u=e("./tracker"),f={};class p extends u{constructor(e,t,n){super(e,t),i("new websocket tracker %s",t),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}announce(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.announce(e)});const t=Object.assign({},e,{action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary});if(this._trackerId&&(t.trackerid=this._trackerId),"stopped"===e.event||"completed"===e.event)this._send(t);else{const n=s(e.numwant,10);this._generateOffers(n,e=>{t.numwant=n,t.offers=e,this._send(t)})}}scrape(e){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.scrape(e)});const t=Array.isArray(e.infoHash)&&0<e.infoHash.length?e.infoHash.map(e=>e.toString("binary")):e.infoHash&&e.infoHash.toString("binary")||this.client._infoHashBinary;this._send({action:"scrape",info_hash:t})}destroy(e=o){function t(){r&&(clearTimeout(r),r=null),n.removeListener("data",t),n.destroy(),n=null}if(this.destroyed)return e(null);for(const t in this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer),this.peers){const e=this.peers[t];clearTimeout(e.trackerTimeout),e.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,f[this.announceUrl]&&(f[this.announceUrl].consumers-=1),0<f[this.announceUrl].consumers)return e();let n=f[this.announceUrl];if(delete f[this.announceUrl],n.on("error",o),n.once("close",e),!this.expectingResponse)return t();var r=setTimeout(t,c.DESTROY_TIMEOUT);n.once("data",t)}_openSocket(){this.destroyed=!1,this.peers||(this.peers={}),this._onSocketConnectBound=()=>{this._onSocketConnect()},this._onSocketErrorBound=e=>{this._onSocketError(e)},this._onSocketDataBound=e=>{this._onSocketData(e)},this._onSocketCloseBound=()=>{this._onSocketClose()},this.socket=f[this.announceUrl],this.socket?f[this.announceUrl].consumers+=1:(this.socket=f[this.announceUrl]=new l(this.announceUrl),this.socket.consumers=1,this.socket.once("connect",this._onSocketConnectBound)),this.socket.on("data",this._onSocketDataBound),this.socket.once("close",this._onSocketCloseBound),this.socket.once("error",this._onSocketErrorBound)}_onSocketConnect(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))}_onSocketData(e){if(!this.destroyed){this.expectingResponse=!1;try{e=JSON.parse(e)}catch(e){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?this._onAnnounceResponse(e):"scrape"===e.action?this._onScrapeResponse(e):this._onSocketError(new Error(`invalid action in WS response: ${e.action}`))}}_onAnnounceResponse(e){if(e.info_hash!==this.client._infoHashBinary)return void i("ignoring websocket data from %s for %s (looking for %s: reused socket)",this.announceUrl,c.binaryToHex(e.info_hash),this.client.infoHash);if(e.peer_id&&e.peer_id===this.client._peerIdBinary)return;i("received %s from %s for %s",JSON.stringify(e),this.announceUrl,this.client.infoHash);const t=e["failure reason"];if(t)return this.client.emit("warning",new Error(t));const n=e["warning message"];n&&this.client.emit("warning",new Error(n));const r=e.interval||e["min interval"];r&&this.setInterval(1e3*r);const o=e["tracker id"];if(o&&(this._trackerId=o),null!=e.complete){const t=Object.assign({},e,{announce:this.announceUrl,infoHash:c.binaryToHex(e.info_hash)});this.client.emit("update",t)}let a;if(e.offer&&e.peer_id&&(i("creating peer (from remote offer)"),a=this._createPeer(),a.id=c.binaryToHex(e.peer_id),a.once("signal",t=>{const n={action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,to_peer_id:e.peer_id,answer:t,offer_id:e.offer_id};this._trackerId&&(n.trackerid=this._trackerId),this._send(n)}),a.signal(e.offer),this.client.emit("peer",a)),e.answer&&e.peer_id){const t=c.binaryToHex(e.offer_id);a=this.peers[t],a?(a.id=c.binaryToHex(e.peer_id),a.signal(e.answer),this.client.emit("peer",a),clearTimeout(a.trackerTimeout),a.trackerTimeout=null,delete this.peers[t]):i(`got unexpected answer: ${JSON.stringify(e.answer)}`)}}_onScrapeResponse(e){e=e.files||{};const t=Object.keys(e);return 0===t.length?void this.client.emit("warning",new Error("invalid scrape response")):void t.forEach(t=>{const n=Object.assign(e[t],{announce:this.announceUrl,infoHash:c.binaryToHex(t)});this.client.emit("scrape",n)})}_onSocketClose(){this.destroyed||(this.destroy(),this._startReconnectTimer())}_onSocketError(e){this.destroyed||(this.destroy(),this.client.emit("warning",e),this._startReconnectTimer())}_startReconnectTimer(){const e=r(Math.random()*120000)+s(n(2,this.retries)*10000,1800000);this.reconnecting=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.retries++,this._openSocket()},e),this.reconnectTimer.unref&&this.reconnectTimer.unref(),i("reconnecting socket in %s ms",e)}_send(e){if(!this.destroyed){this.expectingResponse=!0;const t=JSON.stringify(e);i("send %s",t),this.socket.send(t)}}_generateOffers(e,t){function n(){const e=d(20).toString("hex");i("creating peer (from _generateOffers)");const t=o.peers[e]=o._createPeer({initiator:!0});t.once("signal",t=>{a.push({offer:t,offer_id:c.hexToBinary(e)}),r()}),t.trackerTimeout=setTimeout(()=>{i("tracker timeout: destroying peer"),t.trackerTimeout=null,delete o.peers[e],t.destroy()},50000),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function r(){a.length===e&&(i("generated %s offers",e),t(a))}const o=this,a=[];i("generating %s offers",e);for(let r=0;r<e;++r)n();r()}_createPeer(e){function t(e){r.client.emit("warning",new Error(`Connection error: ${e.message}`)),o.destroy()}function n(){o.removeListener("error",t),o.removeListener("connect",n)}const r=this;e=Object.assign({trickle:!1,config:r.client._rtcConfig,wrtc:r.client._wrtc},e);const o=new a(e);return o.once("error",t),o.once("connect",n),o}}p.prototype.DEFAULT_ANNOUNCE_INTERVAL=30000,p._socketPool=f,t.exports=p},{"../common":18,"./tracker":16,debug:33,randombytes:74,"simple-peer":99,"simple-websocket":101}],18:[function(e,t,n){var r=e("safe-buffer").Buffer;n.DEFAULT_ANNOUNCE_PEERS=50,n.MAX_ANNOUNCE_PEERS=82,n.binaryToHex=function(e){return"string"!=typeof e&&(e+=""),r.from(e,"binary").toString("hex")},n.hexToBinary=function(e){return"string"!=typeof e&&(e+=""),r.from(e,"hex").toString("binary")};var o=e("./common-node");Object.assign(n,o)},{"./common-node":21,"safe-buffer":96}],19:[function(e,t){(function(n){t.exports=function(e,t){function r(i){o.removeEventListener("loadend",r,!1),i.error?t(i.error):t(null,n.from(o.result))}if("undefined"==typeof Blob||!(e instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof t)throw new Error("second argument must be a function");var o=new FileReader;o.addEventListener("loadend",r,!1),o.readAsArrayBuffer(e)}}).call(this,e("buffer").Buffer)},{buffer:27}],20:[function(e,t){(function(n){const{Transform:r}=e("readable-stream");t.exports=class extends r{constructor(e,t={}){super(t),"object"==typeof e&&(t=e,e=t.size),this.size=e||512;const{nopad:n,zeroPadding:r=!0}=t;this._zeroPadding=!n&&!!r,this._buffered=[],this._bufferedBytes=0}_transform(e,t,r){for(this._bufferedBytes+=e.length,this._buffered.push(e);this._bufferedBytes>=this.size;){const e=n.concat(this._buffered);this._bufferedBytes-=this.size,this.push(e.slice(0,this.size)),this._buffered=[e.slice(this.size,e.length)]}r()}_flush(){if(this._bufferedBytes&&this._zeroPadding){const e=n.alloc(this.size-this._bufferedBytes);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:27,"readable-stream":90}],21:[function(){},{}],22:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21}],23:[function(e,t){(function(e){t.exports=function(t){if("number"!=typeof t)throw new TypeError("\"size\" argument must be a number");if(0>t)throw new RangeError("\"size\" argument must not be negative");return e.allocUnsafe?e.allocUnsafe(t):new e(t)}}).call(this,e("buffer").Buffer)},{buffer:27}],24:[function(e,t){(function(n){var r=e("buffer-fill"),o=e("buffer-alloc-unsafe");t.exports=function(e,t,i){if("number"!=typeof e)throw new TypeError("\"size\" argument must be a number");if(0>e)throw new RangeError("\"size\" argument must not be negative");if(n.alloc)return n.alloc(e,t,i);var a=o(e);return 0===e?a:void 0===t?r(a,0):("string"!=typeof i&&(i=void 0),r(a,t,i))}}).call(this,e("buffer").Buffer)},{buffer:27,"buffer-alloc-unsafe":23,"buffer-fill":25}],25:[function(e,t){(function(e){function n(e){return 1===e.length&&256>e.charCodeAt(0)}function r(e,t,n,r){if(0>n||r>e.length)throw new RangeError("Out of range index");return n>>>=0,r=void 0===r?e.length:r>>>0,r>n&&e.fill(t,n,r),e}function o(e,t,n,r){if(0>n||r>e.length)throw new RangeError("Out of range index");if(r<=n)return e;n>>>=0,r=void 0===r?e.length:r>>>0;for(var o=n,i=t.length;o<=r-i;)t.copy(e,o),o+=i;return o!==r&&t.copy(e,o,0,r-o),e}var i=function(){try{if(!e.isEncoding("latin1"))return!1;var t=e.alloc?e.alloc(4):new e(4);return t.fill("ab","ucs2"),"61006200"===t.toString("hex")}catch(e){return!1}}();t.exports=function(t,a,d,s,l){if(i)return t.fill(a,d,s,l);if("number"==typeof a)return r(t,a,d,s);if("string"==typeof a){if("string"==typeof d?(l=d,d=0,s=t.length):"string"==typeof s&&(l=s,s=t.length),void 0!==l&&"string"!=typeof l)throw new TypeError("encoding must be a string");if("latin1"===l&&(l="binary"),"string"==typeof l&&!e.isEncoding(l))throw new TypeError("Unknown encoding: "+l);if(""===a)return r(t,0,d,s);if(n(a))return r(t,a.charCodeAt(0),d,s);a=new e(a,l)}return e.isBuffer(a)?o(t,a,d,s):r(t,0,d,s)}}).call(this,e("buffer").Buffer)},{buffer:27}],26:[function(e,t){(function(e){function n(e){return"ArrayBuffer"===i.call(e).slice(8,-1)}function r(t,n,r){n>>>=0;var o=t.byteLength-n;if(0>o)throw new RangeError("'offset' is out of bounds");if(void 0===r)r=o;else if(r>>>=0,r>o)throw new RangeError("'length' is out of bounds");return a?e.from(t.slice(n,n+r)):new e(new Uint8Array(t.slice(n,n+r)))}function o(t,n){if(("string"!=typeof n||""===n)&&(n="utf8"),!e.isEncoding(n))throw new TypeError("\"encoding\" must be a valid string encoding");return a?e.from(t,n):new e(t,n)}var i=Object.prototype.toString,a="function"==typeof e.alloc&&"function"==typeof e.allocUnsafe&&"function"==typeof e.from;t.exports=function(t,i,d){if("number"==typeof t)throw new TypeError("\"value\" argument must not be a number");return n(t)?r(t,i,d):"string"==typeof t?o(t,i):a?e.from(t):new e(t)}}).call(this,e("buffer").Buffer)},{buffer:27}],27:[function(e,t,r){(function(t){/*!
- * The buffer module from node.js, for the browser.
- *
- * @author Feross Aboukhadijeh <https://feross.org>
- * @license MIT
- */'use strict';function a(e){if(2147483647<e)throw new RangeError("The value \""+e+"\" is invalid for option \"size\"");var n=new Uint8Array(e);return n.__proto__=t.prototype,n}function t(e,n,r){if("number"==typeof e){if("string"==typeof n)throw new TypeError("The \"string\" argument must be of type string. Received type number");return u(e)}return d(e,n,r)}function d(e,n,r){if("string"==typeof e)return f(e,n);if(ArrayBuffer.isView(e))return p(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Y(e,ArrayBuffer)||e&&Y(e.buffer,ArrayBuffer))return h(e,n,r);if("number"==typeof e)throw new TypeError("The \"value\" argument must not be of type number. Received type number");var o=e.valueOf&&e.valueOf();if(null!=o&&o!==e)return t.from(o,n,r);var i=m(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return t.from(e[Symbol.toPrimitive]("string"),n,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function l(e){if("number"!=typeof e)throw new TypeError("\"size\" argument must be of type number");else if(0>e)throw new RangeError("The value \""+e+"\" is invalid for option \"size\"")}function c(e,t,n){return l(e),0>=e?a(e):void 0===t?a(e):"string"==typeof n?a(e).fill(t,n):a(e).fill(t)}function u(e){return l(e),a(0>e?0:0|g(e))}function f(e,n){if(("string"!=typeof n||""===n)&&(n="utf8"),!t.isEncoding(n))throw new TypeError("Unknown encoding: "+n);var r=0|b(e,n),o=a(r),i=o.write(e,n);return i!==r&&(o=o.slice(0,i)),o}function p(e){for(var t=0>e.length?0:0|g(e.length),n=a(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function h(e,n,r){if(0>n||e.byteLength<n)throw new RangeError("\"offset\" is outside of buffer bounds");if(e.byteLength<n+(r||0))throw new RangeError("\"length\" is outside of buffer bounds");var o;return o=void 0===n&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,n):new Uint8Array(e,n,r),o.__proto__=t.prototype,o}function m(e){if(t.isBuffer(e)){var n=0|g(e.length),r=a(n);return 0===r.length?r:(e.copy(r,0,0,n),r)}return void 0===e.length?"Buffer"===e.type&&Array.isArray(e.data)?p(e.data):void 0:"number"!=typeof e.length||X(e.length)?a(0):p(e)}function g(e){if(e>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647 .toString(16)+" bytes");return 0|e}function _(e){return+e!=e&&(e=0),t.alloc(+e)}function b(e,n){if(t.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Y(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type "+typeof e);var r=e.length,o=2<arguments.length&&!0===arguments[2];if(!o&&0===r)return 0;for(var i=!1;;)switch(n){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return W(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return G(e).length;default:if(i)return o?-1:W(e).length;n=(""+n).toLowerCase(),i=!0;}}function y(e,t,n){var r=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),0>=n)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,n);case"utf8":case"utf-8":return R(this,t,n);case"ascii":return A(this,t,n);case"latin1":case"binary":return U(this,t,n);case"base64":return T(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return M(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0;}}function w(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function k(e,n,r,o,i){if(0===e.length)return-1;if("string"==typeof r?(o=r,r=0):2147483647<r?r=2147483647:-2147483648>r&&(r=-2147483648),r=+r,X(r)&&(r=i?0:e.length-1),0>r&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(0>r)if(i)r=0;else return-1;if("string"==typeof n&&(n=t.from(n,o)),t.isBuffer(n))return 0===n.length?-1:x(e,n,r,o,i);if("number"==typeof n)return n&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,n,r):Uint8Array.prototype.lastIndexOf.call(e,n,r):x(e,[n],r,o,i);throw new TypeError("val must be string, number or Buffer")}function x(e,t,n,r,o){function a(e,t){return 1===d?e[t]:e.readUInt16BE(t*d)}var d=1,s=e.length,l=t.length;if(void 0!==r&&(r=(r+"").toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(2>e.length||2>t.length)return-1;d=2,s/=2,l/=2,n/=2}var c;if(o){var u=-1;for(c=n;c<s;c++)if(a(e,c)!==a(t,-1===u?0:c-u))-1!==u&&(c-=c-u),u=-1;else if(-1===u&&(u=c),c-u+1===l)return u*d}else for(n+l>s&&(n=s-l),c=n;0<=c;c--){for(var f=!0,p=0;p<l;p++)if(a(e,c+p)!==a(t,p)){f=!1;break}if(f)return c}return-1}function S(e,t,n,r){n=+n||0;var o=e.length-n;r?(r=+r,r>o&&(r=o)):r=o;var a=t.length;r>a/2&&(r=a/2);for(var d=0,s;d<r;++d){if(s=parseInt(t.substr(2*d,2),16),X(s))return d;e[n+d]=s}return d}function E(e,t,n,r){return K(W(t,e.length-n),e,n,r)}function v(e,t,n,r){return K(z(t),e,n,r)}function C(e,t,n,r){return v(e,t,n,r)}function L(e,t,n,r){return K(G(t),e,n,r)}function I(e,t,n,r){return K(V(t,e.length-n),e,n,r)}function T(e,t,n){return 0===t&&n===e.length?$.fromByteArray(e):$.fromByteArray(e.slice(t,n))}function R(e,t,n){n=s(e.length,n);for(var r=[],o=t;o<n;){var a=e[o],d=null,l=239<a?4:223<a?3:191<a?2:1;if(o+l<=n){var c,u,f,p;1===l?128>a&&(d=a):2===l?(c=e[o+1],128==(192&c)&&(p=(31&a)<<6|63&c,127<p&&(d=p))):3===l?(c=e[o+1],u=e[o+2],128==(192&c)&&128==(192&u)&&(p=(15&a)<<12|(63&c)<<6|63&u,2047<p&&(55296>p||57343<p)&&(d=p))):4===l?(c=e[o+1],u=e[o+2],f=e[o+3],128==(192&c)&&128==(192&u)&&128==(192&f)&&(p=(15&a)<<18|(63&c)<<12|(63&u)<<6|63&f,65535<p&&1114112>p&&(d=p))):void 0}null===d?(d=65533,l=1):65535<d&&(d-=65536,r.push(55296|1023&d>>>10),d=56320|1023&d),r.push(d),o+=l}return B(r)}function B(e){var t=e.length;if(t<=4096)return o.apply(String,e);for(var n="",r=0;r<t;)n+=o.apply(String,e.slice(r,r+=4096));return n}function A(e,t,n){var r="";n=s(e.length,n);for(var a=t;a<n;++a)r+=o(127&e[a]);return r}function U(e,t,n){var r="";n=s(e.length,n);for(var a=t;a<n;++a)r+=o(e[a]);return r}function P(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var o="",a=t;a<n;++a)o+=F(e[a]);return o}function M(e,t,n){for(var r=e.slice(t,n),a="",d=0;d<r.length;d+=2)a+=o(r[d]+256*r[d+1]);return a}function O(e,t,n){if(0!=e%1||0>e)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function N(e,n,r,o,i,a){if(!t.isBuffer(e))throw new TypeError("\"buffer\" argument must be a Buffer instance");if(n>i||n<a)throw new RangeError("\"value\" argument is out of bounds");if(r+o>e.length)throw new RangeError("Index out of range")}function q(e,t,n,r){if(n+r>e.length)throw new RangeError("Index out of range");if(0>n)throw new RangeError("Index out of range")}function H(e,t,n,r,o){return t=+t,n>>>=0,o||q(e,t,n,4,34028234663852886e22,-34028234663852886e22),Q.write(e,t,n,r,23,4),n+4}function j(e,t,n,r,o){return t=+t,n>>>=0,o||q(e,t,n,8,17976931348623157e292,-17976931348623157e292),Q.write(e,t,n,r,52,8),n+8}function D(e){if(e=e.split("=")[0],e=e.trim().replace(J,""),2>e.length)return"";for(;0!=e.length%4;)e+="=";return e}function F(e){return 16>e?"0"+e.toString(16):e.toString(16)}function W(e,t){t=t||1/0;for(var n=e.length,r=null,o=[],a=0,d;a<n;++a){if(d=e.charCodeAt(a),55295<d&&57344>d){if(!r){if(56319<d){-1<(t-=3)&&o.push(239,191,189);continue}else if(a+1===n){-1<(t-=3)&&o.push(239,191,189);continue}r=d;continue}if(56320>d){-1<(t-=3)&&o.push(239,191,189),r=d;continue}d=(r-55296<<10|d-56320)+65536}else r&&-1<(t-=3)&&o.push(239,191,189);if(r=null,128>d){if(0>(t-=1))break;o.push(d)}else if(2048>d){if(0>(t-=2))break;o.push(192|d>>6,128|63&d)}else if(65536>d){if(0>(t-=3))break;o.push(224|d>>12,128|63&d>>6,128|63&d)}else if(1114112>d){if(0>(t-=4))break;o.push(240|d>>18,128|63&d>>12,128|63&d>>6,128|63&d)}else throw new Error("Invalid code point")}return o}function z(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function V(e,t){for(var n=[],r=0,o,a,d;r<e.length&&!(0>(t-=2));++r)o=e.charCodeAt(r),a=o>>8,d=o%256,n.push(d),n.push(a);return n}function G(e){return $.toByteArray(D(e))}function K(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function Y(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function X(e){return e!==e}var $=e("base64-js"),Q=e("ieee754");r.Buffer=t,r.SlowBuffer=_,r.INSPECT_MAX_BYTES=50;r.kMaxLength=2147483647,t.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(t){return!1}}(),t.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."),Object.defineProperty(t.prototype,"parent",{enumerable:!0,get:function(){return t.isBuffer(this)?this.buffer:void 0}}),Object.defineProperty(t.prototype,"offset",{enumerable:!0,get:function(){return t.isBuffer(this)?this.byteOffset:void 0}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&t[Symbol.species]===t&&Object.defineProperty(t,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),t.poolSize=8192,t.from=function(e,t,n){return d(e,t,n)},t.prototype.__proto__=Uint8Array.prototype,t.__proto__=Uint8Array,t.alloc=function(e,t,n){return c(e,t,n)},t.allocUnsafe=function(e){return u(e)},t.allocUnsafeSlow=function(e){return u(e)},t.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==t.prototype},t.compare=function(e,n){if(Y(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),Y(n,Uint8Array)&&(n=t.from(n,n.offset,n.byteLength)),!t.isBuffer(e)||!t.isBuffer(n))throw new TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array");if(e===n)return 0;for(var r=e.length,o=n.length,d=0,l=s(r,o);d<l;++d)if(e[d]!==n[d]){r=e[d],o=n[d];break}return r<o?-1:o<r?1:0},t.isEncoding=function(e){switch((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;}},t.concat=function(e,n){if(!Array.isArray(e))throw new TypeError("\"list\" argument must be an Array of Buffers");if(0===e.length)return t.alloc(0);var r;if(n===void 0)for(n=0,r=0;r<e.length;++r)n+=e[r].length;var o=t.allocUnsafe(n),a=0;for(r=0;r<e.length;++r){var d=e[r];if(Y(d,Uint8Array)&&(d=t.from(d)),!t.isBuffer(d))throw new TypeError("\"list\" argument must be an Array of Buffers");d.copy(o,a),a+=d.length}return o},t.byteLength=b,t.prototype._isBuffer=!0,t.prototype.swap16=function(){var e=this.length;if(0!=e%2)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)w(this,t,t+1);return this},t.prototype.swap32=function(){var e=this.length;if(0!=e%4)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)w(this,t,t+3),w(this,t+1,t+2);return this},t.prototype.swap64=function(){var e=this.length;if(0!=e%8)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)w(this,t,t+7),w(this,t+1,t+6),w(this,t+2,t+5),w(this,t+3,t+4);return this},t.prototype.toString=function(){var e=this.length;return 0===e?"":0===arguments.length?R(this,0,e):y.apply(this,arguments)},t.prototype.toLocaleString=t.prototype.toString,t.prototype.equals=function(e){if(!t.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===t.compare(this,e)},t.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return e=this.toString("hex",0,t).replace(/(.{2})/g,"$1 ").trim(),this.length>t&&(e+=" ... "),"<Buffer "+e+">"},t.prototype.compare=function(e,n,r,o,a){if(Y(e,Uint8Array)&&(e=t.from(e,e.offset,e.byteLength)),!t.isBuffer(e))throw new TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type "+typeof e);if(void 0===n&&(n=0),void 0===r&&(r=e?e.length:0),void 0===o&&(o=0),void 0===a&&(a=this.length),0>n||r>e.length||0>o||a>this.length)throw new RangeError("out of range index");if(o>=a&&n>=r)return 0;if(o>=a)return-1;if(n>=r)return 1;if(n>>>=0,r>>>=0,o>>>=0,a>>>=0,this===e)return 0;for(var d=a-o,l=r-n,c=s(d,l),u=this.slice(o,a),f=e.slice(n,r),p=0;p<c;++p)if(u[p]!==f[p]){d=u[p],l=f[p];break}return d<l?-1:l<d?1:0},t.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},t.prototype.indexOf=function(e,t,n){return k(this,e,t,n,!0)},t.prototype.lastIndexOf=function(e,t,n){return k(this,e,t,n,!1)},t.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))t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-t;if((void 0===n||n>o)&&(n=o),0<e.length&&(0>n||0>t)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return S(this,e,t,n);case"utf8":case"utf-8":return E(this,e,t,n);case"ascii":return v(this,e,t,n);case"latin1":case"binary":return C(this,e,t,n);case"base64":return L(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0;}},t.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};t.prototype.slice=function(e,n){var r=this.length;e=~~e,n=void 0===n?r:~~n,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>n?(n+=r,0>n&&(n=0)):n>r&&(n=r),n<e&&(n=e);var o=this.subarray(e,n);return o.__proto__=t.prototype,o},t.prototype.readUIntLE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e],o=1,a=0;++a<t&&(o*=256);)r+=this[e+a]*o;return r},t.prototype.readUIntBE=function(e,t,n){e>>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e+--t],o=1;0<t&&(o*=256);)r+=this[e+--t]*o;return r},t.prototype.readUInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),this[e]},t.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},t.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},t.prototype.readUInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},t.prototype.readUInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},t.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var o=this[e],a=1,d=0;++d<t&&(a*=256);)o+=this[e+d]*a;return a*=128,o>=a&&(o-=n(2,8*t)),o},t.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var o=t,a=1,d=this[e+--o];0<o&&(a*=256);)d+=this[e+--o]*a;return a*=128,d>=a&&(d-=n(2,8*t)),d},t.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},t.prototype.readInt16LE=function(e,t){e>>>=0,t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt16BE=function(e,t){e>>>=0,t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},t.prototype.readInt32LE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},t.prototype.readInt32BE=function(e,t){return e>>>=0,t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},t.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),Q.read(this,e,!0,23,4)},t.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),Q.read(this,e,!1,23,4)},t.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),Q.read(this,e,!0,52,8)},t.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),Q.read(this,e,!1,52,8)},t.prototype.writeUIntLE=function(e,t,r,o){if(e=+e,t>>>=0,r>>>=0,!o){var a=n(2,8*r)-1;N(this,e,t,r,a,0)}var d=1,s=0;for(this[t]=255&e;++s<r&&(d*=256);)this[t+s]=255&e/d;return t+r},t.prototype.writeUIntBE=function(e,t,r,o){if(e=+e,t>>>=0,r>>>=0,!o){var a=n(2,8*r)-1;N(this,e,t,r,a,0)}var d=r-1,s=1;for(this[t+d]=255&e;0<=--d&&(s*=256);)this[t+d]=255&e/s;return t+r},t.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,1,255,0),this[t]=255&e,t+1},t.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||N(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},t.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||N(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},t.prototype.writeIntLE=function(e,t,r,o){if(e=+e,t>>>=0,!o){var a=n(2,8*r-1);N(this,e,t,r,a-1,-a)}var d=0,s=1,l=0;for(this[t]=255&e;++d<r&&(s*=256);)0>e&&0===l&&0!==this[t+d-1]&&(l=1),this[t+d]=255&(e/s>>0)-l;return t+r},t.prototype.writeIntBE=function(e,t,r,o){if(e=+e,t>>>=0,!o){var a=n(2,8*r-1);N(this,e,t,r,a-1,-a)}var d=r-1,s=1,l=0;for(this[t+d]=255&e;0<=--d&&(s*=256);)0>e&&0===l&&0!==this[t+d+1]&&(l=1),this[t+d]=255&(e/s>>0)-l;return t+r},t.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,1,127,-128),0>e&&(e=255+e+1),this[t]=255&e,t+1},t.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},t.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},t.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||N(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},t.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||N(this,e,t,4,2147483647,-2147483648),0>e&&(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},t.prototype.writeFloatLE=function(e,t,n){return H(this,e,t,!0,n)},t.prototype.writeFloatBE=function(e,t,n){return H(this,e,t,!1,n)},t.prototype.writeDoubleLE=function(e,t,n){return j(this,e,t,!0,n)},t.prototype.writeDoubleBE=function(e,t,n){return j(this,e,t,!1,n)},t.prototype.copy=function(e,n,r,o){if(!t.isBuffer(e))throw new TypeError("argument should be a Buffer");if(r||(r=0),o||0===o||(o=this.length),n>=e.length&&(n=e.length),n||(n=0),0<o&&o<r&&(o=r),o===r)return 0;if(0===e.length||0===this.length)return 0;if(0>n)throw new RangeError("targetStart out of bounds");if(0>r||r>=this.length)throw new RangeError("Index out of range");if(0>o)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-n<o-r&&(o=e.length-n+r);var a=o-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(n,r,o);else if(this===e&&r<n&&n<o)for(var d=a-1;0<=d;--d)e[d+n]=this[d+r];else Uint8Array.prototype.set.call(e,this.subarray(r,o),n);return a},t.prototype.fill=function(e,n,r,o){if("string"==typeof e){if("string"==typeof n?(o=n,n=0,r=this.length):"string"==typeof r&&(o=r,r=this.length),void 0!==o&&"string"!=typeof o)throw new TypeError("encoding must be a string");if("string"==typeof o&&!t.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(1===e.length){var a=e.charCodeAt(0);("utf8"===o&&128>a||"latin1"===o)&&(e=a)}}else"number"==typeof e&&(e&=255);if(0>n||this.length<n||this.length<r)throw new RangeError("Out of range index");if(r<=n)return this;n>>>=0,r=r===void 0?this.length:r>>>0,e||(e=0);var d;if("number"==typeof e)for(d=n;d<r;++d)this[d]=e;else{var s=t.isBuffer(e)?e:t.from(e,o),l=s.length;if(0===l)throw new TypeError("The value \""+e+"\" is invalid for argument \"value\"");for(d=0;d<r-n;++d)this[d+n]=s[d%l]}return this};var J=/[^+/0-9A-Za-z-_]/g}).call(this,e("buffer").Buffer)},{"base64-js":8,buffer:27,ieee754:40}],28:[function(e,t){t.exports={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",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"}},{}],29:[function(e,t){const n=e("block-stream2"),r=e("readable-stream");class o extends r.Writable{constructor(e,t,r={}){if(super(r),!e||!e.put||!e.get)throw new Error("First argument must be an abstract-chunk-store compliant store");if(t=+t,!t)throw new Error("Second argument must be a chunk length");this._blockstream=new n(t,{zeroPadding:!1}),this._outstandingPuts=0;let o=0;const i=t=>{this.destroyed||(this._outstandingPuts+=1,e.put(o,t,()=>{this._outstandingPuts-=1,0===this._outstandingPuts&&"function"==typeof this._finalCb&&(this._finalCb(null),this._finalCb=null)}),o+=1)};this._blockstream.on("data",i).on("error",e=>{this.destroy(e)})}_write(e,t,n){this._blockstream.write(e,t,n)}_final(e){this._blockstream.end(),this._blockstream.once("end",()=>{0===this._outstandingPuts?e(null):this._finalCb=e})}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}}t.exports=o},{"block-stream2":20,"readable-stream":90}],30:[function(e,n){n.exports=function(e,n,r){for(var o=1/0,a=0,d=n.length-1,s,l,c;a<=d&&(s=a+(d-a>>1),c=n[s]-e,0>c?a=s+1:0<c?d=s-1:void 0,c=t(c),c<o&&(o=c,l=s),n[s]!==e););return r?l:n[l]}},{}],31:[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(n){return"[object Error]"===t(n)||n 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||"undefined"==typeof e},n.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":44}],32:[function(e,t){(function(n,r,o){function i(e){return e.reduce((e,t)=>Array.isArray(t)?e.concat(i(t)):e.concat(t),[])}function d(e,t,r){function a(){A(e.map(e=>t=>{const n={};if(m(e))n.getStream=b(e),n.length=e.size;else if(o.isBuffer(e))n.getStream=y(e),n.length=e.length;else if(_(e))n.getStream=k(e,n),n.length=0;else{if("string"==typeof e){if("function"!=typeof L.stat)throw new Error("filesystem paths do not work in the browser");const n=1<l||c;return void s(e,n,t)}throw new Error("invalid input type")}n.path=e.path,t(null,n)}),(e,t)=>e?r(e):void(t=i(t),r(null,t,c)))}if(g(e)&&(e=Array.from(e)),Array.isArray(e)||(e=[e]),0===e.length)throw new Error("invalid input type");e.forEach(e=>{if(null==e)throw new Error(`invalid input type: ${e}`)}),e=e.map(e=>m(e)&&"string"==typeof e.path&&"function"==typeof L.stat?e.path:e),1!==e.length||"string"==typeof e[0]||e[0].name||(e[0].name=t.name);let d=null;e.forEach((t,n)=>{if("string"==typeof t)return;let r=t.fullPath||t.name;r||(r=`Unknown File ${n+1}`,t.unknownName=!0),t.path=r.split("/"),t.path[0]||t.path.shift(),2>t.path.length?d=null:0===n&&1<e.length?d=t.path[0]:t.path[0]!==d&&(d=null)}),e=e.filter(e=>{if("string"==typeof e)return!0;const t=e.path[e.path.length-1];return u(t)&&T.not(t)}),d&&e.forEach(e=>{const t=(o.isBuffer(e)||_(e))&&!e.path;"string"==typeof e||t||e.path.shift()}),!t.name&&d&&(t.name=d),t.name||e.some(e=>"string"==typeof e?(t.name=v.basename(e),!0):e.unknownName?void 0:(t.name=e.path[e.path.length-1],!0)),t.name||(t.name=`Unnamed Torrent ${Date.now()}`);const l=e.reduce((e,t)=>e+ +("string"==typeof t),0);let c=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof L.stat)throw new Error("filesystem paths do not work in the browser");I(e[0],(e,t)=>e?r(e):void(c=t,a()))}else n.nextTick(()=>{a()})}function s(e,t,n){c(e,l,(r,o)=>r?n(r):void(o=Array.isArray(o)?i(o):[o],e=v.normalize(e),t&&(e=e.slice(0,e.lastIndexOf(v.sep)+1)),e[e.length-1]!==v.sep&&(e+=v.sep),o.forEach(t=>{t.getStream=w(t.path),t.path=t.path.replace(e,"").split(v.sep)}),n(null,o)))}function l(e,t){t=B(t),L.stat(e,(n,r)=>{if(n)return t(n);const o={length:r.size,path:e};t(null,o)})}function c(e,t,n){L.stat(e,(r,o)=>r?n(r):void(o.isDirectory()?L.readdir(e,(r,o)=>r?n(r):void A(o.filter(u).filter(T.not).map(n=>r=>{c(v.join(e,n),t,r)}),n)):o.isFile()&&t(e,n)))}function u(e){return"."!==e[0]}function f(e,t,n){function r(e){c+=e.length;const t=p;U(e,e=>{l[t]=e,f-=1,s()}),f+=1,p+=1}function i(){h=!0,s()}function a(e){d(),n(e)}function d(){m.removeListener("error",a),g.removeListener("data",r),g.removeListener("end",i),g.removeListener("error",a)}function s(){h&&0==f&&(d(),n(null,o.from(l.join(""),"hex"),c))}n=B(n);const l=[];let c=0;const u=e.map(e=>e.getStream);let f=0,p=0,h=!1;const m=new R(u),g=new S(t,{zeroPadding:!1});m.on("error",a),m.pipe(g).on("data",r).on("end",i).on("error",a)}function p(e,n,o){let i=n.announceList;i||("string"==typeof n.announce?i=[[n.announce]]:Array.isArray(n.announce)&&(i=n.announce.map(e=>[e]))),i||(i=[]),r.WEBTORRENT_ANNOUNCE&&("string"==typeof r.WEBTORRENT_ANNOUNCE?i.push([[r.WEBTORRENT_ANNOUNCE]]):Array.isArray(r.WEBTORRENT_ANNOUNCE)&&(i=i.concat(r.WEBTORRENT_ANNOUNCE.map(e=>[e])))),n.announce===void 0&&n.announceList===void 0&&(i=i.concat(t.exports.announceList)),"string"==typeof n.urlList&&(n.urlList=[n.urlList]);const d={info:{name:n.name},"creation date":a((+n.creationDate||Date.now())/1e3),encoding:"UTF-8"};0!==i.length&&(d.announce=i[0][0],d["announce-list"]=i),n.comment!==void 0&&(d.comment=n.comment),n.createdBy!==void 0&&(d["created by"]=n.createdBy),n.private!==void 0&&(d.info.private=+n.private),n.sslCert!==void 0&&(d.info["ssl-cert"]=n.sslCert),n.urlList!==void 0&&(d["url-list"]=n.urlList);const s=n.pieceLength||E(e.reduce(h,0));d.info["piece length"]=s,f(e,s,(t,r,i)=>t?o(t):void(d.info.pieces=r,e.forEach(e=>{delete e.getStream}),n.singleFileTorrent?d.info.length=i:d.info.files=e,o(null,x.encode(d))))}function h(e,t){return e+t.length}function m(e){return"undefined"!=typeof Blob&&e instanceof Blob}function g(e){return"undefined"!=typeof FileList&&e instanceof FileList}function _(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function b(e){return()=>new C(e)}function y(e){return()=>{const t=new P.PassThrough;return t.end(e),t}}function w(e){return()=>L.createReadStream(e)}function k(e,t){return()=>{const n=new P.Transform;return n._transform=function(e,n,r){t.length+=e.length,this.push(e),r()},e.pipe(n),n}}const x=e("bencode"),S=e("block-stream2"),E=e("piece-length"),v=e("path"),C=e("filestream/read"),L=e("fs"),I=e("is-file"),T=e("junk"),R=e("multistream"),B=e("once"),A=e("run-parallel"),U=e("simple-sha1"),P=e("readable-stream");t.exports=function(e,t,n){"function"==typeof t&&([t,n]=[n,t]),t=t?Object.assign({},t):{},d(e,t,(e,r,o)=>e?n(e):void(t.singleFileTorrent=o,p(r,t,n)))},t.exports.parseInput=function(e,t,n){"function"==typeof t&&([t,n]=[n,t]),t=t?Object.assign({},t):{},d(e,t,n)},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"]]}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("buffer").Buffer)},{_process:67,bencode:11,"block-stream2":20,buffer:27,"filestream/read":37,fs:22,"is-file":45,junk:48,multistream:59,once:61,path:64,"piece-length":65,"readable-stream":90,"run-parallel":94,"simple-sha1":100}],33:[function(e,t,n){(function(o){function i(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof o&&"env"in o&&(e=o.env.DEBUG),e}n.log=function(...e){return"object"==typeof console&&console.log&&console.log(...e)},n.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"===e||(r++,"%c"===e&&(o=r))}),e.splice(o,0,n)},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=i,n.useColors=function(){return!!("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))||!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage=function(){try{return localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=e("./common")(n);const{formatters:a}=t.exports;a.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,e("_process"))},{"./common":34,_process:67}],34:[function(e,n){n.exports=function(n){function r(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return o.colors[t(n)%o.colors.length]}function o(e){function t(...e){if(!t.enabled)return;const r=t,i=+new Date,a=i-(n||i);r.diff=a,r.prev=n,r.curr=i,n=i,e[0]=o.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let d=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,n)=>{if("%%"===t)return t;d++;const i=o.formatters[n];if("function"==typeof i){const n=e[d];t=i.call(r,n),e.splice(d,1),d--}return t}),o.formatArgs.call(r,e);const s=r.log||o.log;s.apply(r,e)}let n;return t.namespace=e,t.enabled=o.enabled(e),t.useColors=o.useColors(),t.color=r(e),t.destroy=i,t.extend=a,"function"==typeof o.init&&o.init(t),o.instances.push(t),t}function i(){const e=o.instances.indexOf(this);return-1!==e&&(o.instances.splice(e,1),!0)}function a(e,t){const n=o(this.namespace+("undefined"==typeof t?":":t)+e);return n.log=this.log,n}function d(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return o.debug=o,o.default=o,o.coerce=function(e){return e instanceof Error?e.stack||e.message:e},o.disable=function(){const e=[...o.names.map(d),...o.skips.map(d).map(e=>"-"+e)].join(",");return o.enable(""),e},o.enable=function(e){o.save(e),o.names=[],o.skips=[];let t;const n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length;for(t=0;t<r;t++)n[t]&&(e=n[t].replace(/\*/g,".*?"),"-"===e[0]?o.skips.push(new RegExp("^"+e.substr(1)+"$")):o.names.push(new RegExp("^"+e+"$")));for(t=0;t<o.instances.length;t++){const e=o.instances[t];e.enabled=o.enabled(e.namespace)}},o.enabled=function(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=o.skips.length;t<n;t++)if(o.skips[t].test(e))return!1;for(t=0,n=o.names.length;t<n;t++)if(o.names[t].test(e))return!0;return!1},o.humanize=e("ms"),Object.keys(n).forEach(e=>{o[e]=n[e]}),o.instances=[],o.names=[],o.skips=[],o.formatters={},o.selectColor=r,o.enable(o.load()),o}},{ms:58}],35:[function(e,t){var n=e("once"),r=function(){},o=function(e){return e.setHeader&&"function"==typeof e.abort},i=function(e){return e.stdio&&Array.isArray(e.stdio)&&3===e.stdio.length},a=function(e,t,d){if("function"==typeof t)return a(e,null,t);t||(t={}),d=n(d||r);var s=e._writableState,l=e._readableState,c=t.readable||!1!==t.readable&&e.readable,u=t.writable||!1!==t.writable&&e.writable,f=function(){e.writable||p()},p=function(){u=!1,c||d.call(e)},h=function(){c=!1,u||d.call(e)},m=function(t){d.call(e,t?new Error("exited with error code: "+t):null)},g=function(t){d.call(e,t)},_=function(){return c&&!(l&&l.ended)?d.call(e,new Error("premature close")):u&&!(s&&s.ended)?d.call(e,new Error("premature close")):void 0},b=function(){e.req.on("finish",p)};return o(e)?(e.on("complete",p),e.on("abort",_),e.req?b():e.on("request",b)):u&&!s&&(e.on("end",f),e.on("close",f)),i(e)&&e.on("exit",m),e.on("end",h),e.on("finish",p),!1!==t.error&&e.on("error",g),e.on("close",_),function(){e.removeListener("complete",p),e.removeListener("abort",_),e.removeListener("request",b),e.req&&e.req.removeListener("finish",p),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",p),e.removeListener("exit",m),e.removeListener("end",h),e.removeListener("error",g),e.removeListener("close",_)}};t.exports=a},{once:61}],36:[function(e,t){function n(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=y(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function r(e){return void 0===e._maxListeners?n.defaultMaxListeners:e._maxListeners}function a(e,t,n){if(t)e.call(n);else for(var r=e.length,o=_(e,r),a=0;a<r;++a)o[a].call(n)}function d(e,t,n,r){if(t)e.call(n,r);else for(var o=e.length,a=_(e,o),d=0;d<o;++d)a[d].call(n,r)}function s(e,t,n,r,o){if(t)e.call(n,r,o);else for(var a=e.length,d=_(e,a),s=0;s<a;++s)d[s].call(n,r,o)}function l(e,t,n,r,o,a){if(t)e.call(n,r,o,a);else for(var d=e.length,s=_(e,d),l=0;l<d;++l)s[l].call(n,r,o,a)}function c(e,t,n,r){if(t)e.apply(n,r);else for(var o=e.length,a=_(e,o),d=0;d<o;++d)a[d].apply(n,r)}function u(e,t,n,o){var i,a,d;if("function"!=typeof n)throw new TypeError("\"listener\" argument must be a function");if(a=e._events,a?(a.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),a=e._events),d=a[t]):(a=e._events=y(null),e._eventsCount=0),!d)d=a[t]=n,++e._eventsCount;else if("function"==typeof d?d=a[t]=o?[n,d]:[d,n]:o?d.unshift(n):d.push(n),!d.warned&&(i=r(e),i&&0<i&&d.length>i)){d.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+d.length+" \""+(t+"\" listeners added. Use emitter.setMaxListeners() to increase limit."));s.name="MaxListenersExceededWarning",s.emitter=e,s.type=t,s.count=d.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",s.name,s.message)}return e}function f(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var e=Array(arguments.length),t=0;t<e.length;++t)e[t]=arguments[t];this.listener.apply(this.target,e);}}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=k.call(f,r);return o.listener=n,r.wrapFn=o,o}function h(e,t,n){var r=e._events;if(!r)return[];var o=r[t];return o?"function"==typeof o?n?[o.listener||o]:[o]:n?b(o):_(o,o.length):[]}function m(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function g(e,t){for(var r=t,o=r+1,a=e.length;o<a;r+=1,o+=1)e[r]=e[o];e.pop()}function _(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function b(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}var y=Object.create||function(e){var t=function(){};return t.prototype=e,new t},w=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return n},k=Function.prototype.bind||function(e){var t=this;return function(){return t.apply(e,arguments)}};t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0;var x=10,S;try{var E={};Object.defineProperty&&Object.defineProperty(E,"x",{value:0}),S=0===E.x}catch(e){S=!1}S?Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return x},set:function(e){if("number"!=typeof e||0>e||e!==e)throw new TypeError("\"defaultMaxListeners\" must be a positive number");x=e}}):n.defaultMaxListeners=x,n.prototype.setMaxListeners=function(e){if("number"!=typeof e||0>e||isNaN(e))throw new TypeError("\"n\" argument must be a positive number");return this._maxListeners=e,this},n.prototype.getMaxListeners=function(){return r(this)},n.prototype.emit=function(e){var t="error"===e,n,r,o,u,f,p;if(p=this._events,p)t=t&&null==p.error;else if(!t)return!1;if(t){if(1<arguments.length&&(n=arguments[1]),n instanceof Error)throw n;else{var h=new Error("Unhandled \"error\" event. ("+n+")");throw h.context=n,h}return!1}if(r=p[e],!r)return!1;var m="function"==typeof r;switch(o=arguments.length,o){case 1:a(r,m,this);break;case 2:d(r,m,this,arguments[1]);break;case 3:s(r,m,this,arguments[1],arguments[2]);break;case 4:l(r,m,this,arguments[1],arguments[2],arguments[3]);break;default:for(u=Array(o-1),f=1;f<o;f++)u[f-1]=arguments[f];c(r,m,this,u);}return!0},n.prototype.addListener=function(e,t){return u(this,e,t,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(e,t){return u(this,e,t,!0)},n.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError("\"listener\" argument must be a function");return this.on(e,p(this,e,t)),this},n.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError("\"listener\" argument must be a function");return this.prependListener(e,p(this,e,t)),this},n.prototype.removeListener=function(e,t){var n,r,o,a,d;if("function"!=typeof t)throw new TypeError("\"listener\" argument must be a function");if(r=this._events,!r)return this;if(n=r[e],!n)return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=y(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,a=n.length-1;0<=a;a--)if(n[a]===t||n[a].listener===t){d=n[a].listener,o=a;break}if(0>o)return this;0===o?n.shift():g(n,o),1===n.length&&(r[e]=n[0]),r.removeListener&&this.emit("removeListener",e,d||t)}return this},n.prototype.removeAllListeners=function(e){var t,n,r;if(n=this._events,!n)return this;if(!n.removeListener)return 0===arguments.length?(this._events=y(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=y(null):delete n[e]),this;if(0===arguments.length){var o=w(n),a;for(r=0;r<o.length;++r)a=o[r],"removeListener"===a||this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=y(null),this._eventsCount=0,this}if(t=n[e],"function"==typeof t)this.removeListener(e,t);else if(t)for(r=t.length-1;0<=r;r--)this.removeListener(e,t[r]);return this},n.prototype.listeners=function(e){return h(this,e,!0)},n.prototype.rawListeners=function(e){return h(this,e,!1)},n.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):m.call(e,t)},n.prototype.listenerCount=m,n.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}],37:[function(e,t){const{Readable:n}=e("readable-stream"),r=e("typedarray-to-buffer");t.exports=class extends n{constructor(e,t={}){super(t),this._offset=0,this._ready=!1,this._file=e,this._size=e.size,this._chunkSize=t.chunkSize||d(this._size/1e3,204800);const n=new FileReader;n.onload=()=>{this.push(r(n.result))},n.onerror=()=>{this.emit("error",n.error)},this.reader=n,this._generateHeaderBlocks(e,t,(e,t)=>e?this.emit("error",e):void(Array.isArray(t)&&t.forEach(e=>this.push(e)),this._ready=!0,this.emit("_ready")))}_generateHeaderBlocks(e,t,n){n(null,[])}_read(){if(!this._ready)return void this.once("_ready",this._read.bind(this));const e=this._offset;let t=this._offset+this._chunkSize;return t>this._size&&(t=this._size),e===this._size?(this.destroy(),void this.push(null)):void(this.reader.readAsArrayBuffer(this._file.slice(e,t)),this._offset=t)}destroy(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(t){}}this.reader=null}}},{"readable-stream":90,"typedarray-to-buffer":130}],38:[function(e,t){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}},{}],39:[function(e,t){function n(e){if("string"==typeof e&&(e=o.parse(e)),e.protocol||(e.protocol="https:"),"https:"!==e.protocol)throw new Error("Protocol \""+e.protocol+"\" not supported. Expected \"https:\"");return e}var r=e("http"),o=e("url"),i=t.exports;for(var a in r)r.hasOwnProperty(a)&&(i[a]=r[a]);i.request=function(e,t){return e=n(e),r.request.call(this,e,t)},i.get=function(e,t){return e=n(e),r.get.call(this,e,t)}},{http:103,url:134}],40:[function(e,o,i){i.read=function(t,r,o,a,l){var c=8*l-a-1,u=(1<<c)-1,f=u>>1,p=-7,h=o?l-1:0,g=o?-1:1,d=t[r+h],_,b;for(h+=g,_=d&(1<<-p)-1,d>>=-p,p+=c;0<p;_=256*_+t[r+h],h+=g,p-=8);for(b=_&(1<<-p)-1,_>>=-p,p+=a;0<p;b=256*b+t[r+h],h+=g,p-=8);if(0===_)_=1-f;else{if(_===u)return b?NaN:(d?-1:1)*(1/0);b+=n(2,a),_-=f}return(d?-1:1)*b*n(2,_-a)},i.write=function(o,a,l,u,f,p){var h=Math.LN2,g=Math.log,_=8*p-f-1,b=(1<<_)-1,y=b>>1,w=23===f?n(2,-24)-n(2,-77):0,k=u?0:p-1,x=u?1:-1,d=0>a||0===a&&0>1/a?1:0,s,S,E;for(a=t(a),isNaN(a)||a===1/0?(S=isNaN(a)?1:0,s=b):(s=r(g(a)/h),1>a*(E=n(2,-s))&&(s--,E*=2),a+=1<=s+y?w/E:w*n(2,1-y),2<=a*E&&(s++,E/=2),s+y>=b?(S=0,s=b):1<=s+y?(S=(a*E-1)*n(2,f),s+=y):(S=a*n(2,y-1)*n(2,f),s=0));8<=f;o[l+k]=255&S,k+=x,S/=256,f-=8);for(s=s<<f|S,_+=f;0<_;o[l+k]=255&s,k+=x,s/=256,_-=8);o[l+k-x]|=128*d}},{}],41:[function(e,t){(function(e){function n(t,n,r){e.nextTick(()=>{t&&t(n,r)})}t.exports=class{constructor(e){if(this.store=e,this.chunkLength=e.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.mem=[]}put(e,t,n){this.mem[e]=t,this.store.put(e,t,t=>{this.mem[e]=null,n&&n(t)})}get(e,t,r){if("function"==typeof t)return this.get(e,null,t);const o=t&&t.offset||0,i=t&&t.length&&o+t.length,a=this.mem[e];return a?n(r,null,t?a.slice(o,i):a):void this.store.get(e,t,r)}close(e){this.store.close(e)}destroy(e){this.store.destroy(e)}}}).call(this,e("_process"))},{_process:67}],42:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},{}],43:[function(e,t){t.exports=function(e){for(var t=0,n=e.length;t<n;++t)if(e.charCodeAt(t)>127)return!1;return!0}},{}],44:[function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function r(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}/*!
- * Determine if an object is a Buffer
- *
- * @author Feross Aboukhadijeh <https://feross.org>
- * @license MIT
- */t.exports=function(e){return null!=e&&(n(e)||r(e)||!!e._isBuffer)}},{}],45:[function(e,t){'use strict';function n(e){return r.existsSync(e)&&r.statSync(e).isFile()}var r=e("fs");t.exports=function(e,t){return t?void r.stat(e,function(e,n){return e?t(e):t(null,n.isFile())}):n(e)},t.exports.sync=n},{fs:22}],46:[function(e,t){function n(e){return r(e)||o(e)}function r(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[i.call(e)]}t.exports=n,n.strict=r,n.loose=o;var i=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}},{}],47:[function(e,t){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],48:[function(e,t,n){'use strict';n.re=()=>{throw new Error("`junk.re` was renamed to `junk.regex`")},n.regex=new RegExp(["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^Desktop\\.ini$","@eaDir$"].join("|")),n.is=e=>n.regex.test(e),n.not=e=>!n.is(e),n.default=t.exports},{}],49:[function(e,t){(function(n){function r(e){const t={},r=e.split("magnet:?")[1],a=r&&0<=r.length?r.split("&"):[];a.forEach(e=>{const n=e.split("=");if(2!==n.length)return;const r=n[0];let o=n[1];if("dn"===r&&(o=decodeURIComponent(o).replace(/\+/g," ")),("tr"===r||"xs"===r||"as"===r||"ws"===r)&&(o=decodeURIComponent(o)),"kt"===r&&(o=decodeURIComponent(o).split("+")),"ix"===r&&(o=+o),!t[r])t[r]=o;else if(Array.isArray(t[r]))t[r].push(o);else{const e=t[r];t[r]=[e,o]}});let d;if(t.xt){const e=Array.isArray(t.xt)?t.xt:[t.xt];e.forEach(e=>{if(d=e.match(/^urn:btih:(.{40})/))t.infoHash=d[1].toLowerCase();else if(d=e.match(/^urn:btih:(.{32})/)){const e=o.decode(d[1]);t.infoHash=n.from(e,"binary").toString("hex")}})}return t.infoHash&&(t.infoHashBuffer=n.from(t.infoHash,"hex")),t.dn&&(t.name=t.dn),t.kt&&(t.keywords=t.kt),t.announce="string"==typeof t.tr?[t.tr]:Array.isArray(t.tr)?t.tr:[],t.urlList=[],("string"==typeof t.as||Array.isArray(t.as))&&(t.urlList=t.urlList.concat(t.as)),("string"==typeof t.ws||Array.isArray(t.ws))&&(t.urlList=t.urlList.concat(t.ws)),i(t.announce),i(t.urlList),t}t.exports=r,t.exports.decode=r,t.exports.encode=function(e){e=Object.assign({},e),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);let t="magnet:?";return Object.keys(e).filter(e=>2===e.length).forEach((n,r)=>{const o=Array.isArray(e[n])?e[n]:[e[n]];o.forEach((e,o)=>{(0<r||0<o)&&("kt"!==n||0===o)&&(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&&0<o?`+${e}`:`${n}=${e}`})}),t};const o=e("thirty-two"),i=e("uniq")}).call(this,e("buffer").Buffer)},{buffer:27,"thirty-two":124,uniq:132}],50:[function(e,t){function n(e,t){var r=this;if(!(r instanceof n))return new n(e,t);if(!s)throw new Error("web browser lacks MediaSource support");t||(t={}),r._debug=t.debug,r._bufferDuration=t.bufferDuration||60,r._elem=e,r._mediaSource=new s,r._streams=[],r.detailedError=null,r._errorHandler=function(){r._elem.removeEventListener("error",r._errorHandler);var e=r._streams.slice();e.forEach(function(e){e.destroy(r._elem.error)})},r._elem.addEventListener("error",r._errorHandler),r._elem.src=window.URL.createObjectURL(r._mediaSource)}function r(e,t){var n=this;if(a.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._debugBuffers=[],n._openHandler=function(){n._onSourceOpen()},n._flowHandler=function(){n._flow()},n._errorHandler=function(e){n.destroyed||n.emit("error",e)},"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)t.destroy(),n._type=t._type,n._sourceBuffer=t._sourceBuffer,n._debugBuffers=t._debugBuffers,n._sourceBuffer.addEventListener("updateend",n._flowHandler),n._sourceBuffer.addEventListener("error",n._errorHandler);else throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");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}))){n._wrapper._dumpDebugData();try{n._mediaSource.endOfStream()}catch(e){}}})}function o(e,t){var n=document.createElement("a");n.href=window.URL.createObjectURL(new window.Blob(e)),n.download=t,n.click()}t.exports=n;var i=e("inherits"),a=e("readable-stream"),d=e("to-arraybuffer"),s="undefined"!=typeof window&&window.MediaSource;n.prototype.createWriteStream=function(e){var t=this;return new r(t,e)},n.prototype.error=function(e){var t=this;t.detailedError||(t.detailedError=e),t._dumpDebugData();try{t._mediaSource.endOfStream("decode")}catch(e){}try{window.URL.revokeObjectURL(t._elem.src)}catch(e){}},n.prototype._dumpDebugData=function(){var e=this;e._debug&&(e._debug=!1,e._streams.forEach(function(e,t){o(e._debugBuffers,"mediasource-stream-"+t)}))},i(r,a.Writable),r.prototype._onSourceOpen=function(){var e=this;e.destroyed||(e._mediaSource.removeEventListener("sourceopen",e._openHandler),e._createSourceBuffer())},r.prototype.destroy=function(e){var t=this;t.destroyed||(t.destroyed=!0,t._allStreams.splice(t._allStreams.indexOf(t),1),t._mediaSource.removeEventListener("sourceopen",t._openHandler),t._elem.removeEventListener("timeupdate",t._flowHandler),t._sourceBuffer&&(t._sourceBuffer.removeEventListener("updateend",t._flowHandler),t._sourceBuffer.removeEventListener("error",t._errorHandler),"open"===t._mediaSource.readyState&&t._sourceBuffer.abort()),e&&t.emit("error",e),t.emit("close"))},r.prototype._createSourceBuffer=function(){var e=this;if(!e.destroyed)if(!s.isTypeSupported(e._type))e.destroy(new Error("The provided type is not supported"));else if(e._sourceBuffer=e._mediaSource.addSourceBuffer(e._type),e._sourceBuffer.addEventListener("updateend",e._flowHandler),e._sourceBuffer.addEventListener("error",e._errorHandler),e._cb){var t=e._cb;e._cb=null,t()}},r.prototype._write=function(e,t,n){var r=this;if(!r.destroyed){if(!r._sourceBuffer)return void(r._cb=function(o){return o?n(o):void r._write(e,t,n)});if(r._sourceBuffer.updating)return n(new Error("Cannot append buffer while source buffer updating"));var o=d(e);r._wrapper._debug&&r._debugBuffers.push(o);try{r._sourceBuffer.appendBuffer(o)}catch(e){return void r.destroy(e)}r._cb=n}},r.prototype._flow=function(){var e=this;if(!(e.destroyed||!e._sourceBuffer||e._sourceBuffer.updating)&&!("open"===e._mediaSource.readyState&&e._getBufferDuration()>e._bufferDuration)&&e._cb){var t=e._cb;e._cb=null,t()}};r.prototype._getBufferDuration=function(){for(var e=this,t=e._sourceBuffer.buffered,n=e._elem.currentTime,r=-1,o=0;o<t.length;o++){var a=t.start(o),d=t.end(o)+0;if(a>n)break;else(0<=r||n<=d)&&(r=d)}var s=r-n;return 0>s&&(s=0),s}},{inherits:42,"readable-stream":90,"to-arraybuffer":127}],51:[function(e,t){(function(e){function n(e,t){if(!(this instanceof n))return new n(e,t);if(t||(t={}),this.chunkLength=+e,!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=+t.length||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=a(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,new Error("Storage is closed"));var o=e===this.lastChunkIndex;return o&&t.length!==this.lastChunkLength?r(n,new Error("Last chunk length must be "+this.lastChunkLength)):o||t.length===this.chunkLength?void(this.chunks[e]=t,r(n,null)):r(n,new 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,new Error("Storage is closed"));var o=this.chunks[e];if(!o){var i=new Error("Chunk not found");return i.notFound=!0,r(n,i)}if(!t)return r(n,null,o);var a=t.offset||0,d=t.length||o.length-a;r(n,null,o.slice(a,d+a))},n.prototype.close=n.prototype.destroy=function(e){return this.closed?r(e,new Error("Storage is closed")):void(this.closed=!0,this.chunks=null,r(e,null))}}).call(this,e("_process"))},{_process:67}],52:[function(e,t,n){function o(e,t,n){for(var r=t;r<n;r++)e[r]=0}function i(e,t,n){t.writeUInt32BE(r((e.getTime()+2082844800000)/1e3),n)}function a(e,t,n){t.writeUIntBE(r((e.getTime()+2082844800000)/1e3),n,6)}function d(e,t,n){t.writeUInt16BE(r(e)%65536,n),t.writeUInt16BE(r(256*(256*e))%65536,n+2)}function l(e,t,n){t[n]=r(e)%256,t[n+1]=r(256*e)%256}function c(e,t,n){e||(e=[0,0,0,0,0,0,0,0,0]);for(var r=0;r<e.length;r++)d(e[r],t,n+4*r)}function u(e,t,n){var r=k(e,"utf8");r.copy(t,n),t[n+r.length]=0}function f(e){for(var t=Array(e.length/4),n=0;n<t.length;n++)t[n]=m(e,4*n);return t}function p(e,t){return new Date(1e3*e.readUIntBE(t,6)-2082844800000)}function h(e,t){return new Date(1e3*e.readUInt32BE(t)-2082844800000)}function m(e,t){return e.readUInt16BE(t)+e.readUInt16BE(t+2)/65536}function g(e,t){return e[t]+e[t+1]/256}function _(e,t,n){var r;for(r=0;r<n&&!(0===e[t+r]);r++);return e.toString("utf8",t,t+r)}var b=e("./index"),y=e("./descriptor"),w=e("buffer-alloc"),k=e("buffer-from"),x=e("uint64be");n.fullBoxes={};["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","co64","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,t,r){t=t?t.slice(r):w(n.ftyp.encodingLength(e));var o=e.compatibleBrands||[];t.write(e.brand,0,4,"ascii"),t.writeUInt32BE(e.brandVersion,4);for(var a=0;a<o.length;a++)t.write(o[a],8+4*a,4,"ascii");return n.ftyp.encode.bytes=8+4*o.length,t},n.ftyp.decode=function(e,t){e=e.slice(t);for(var n=e.toString("ascii",0,4),r=e.readUInt32BE(4),o=[],a=8;a<e.length;a+=4)o.push(e.toString("ascii",a,a+4));return{brand:n,brandVersion:r,compatibleBrands:o}},n.ftyp.encodingLength=function(e){return 8+4*(e.compatibleBrands||[]).length},n.mvhd={},n.mvhd.encode=function(e,t,r){return t=t?t.slice(r):w(96),i(e.ctime||new Date,t,0),i(e.mtime||new Date,t,4),t.writeUInt32BE(e.timeScale||0,8),t.writeUInt32BE(e.duration||0,12),d(e.preferredRate||0,t,16),l(e.preferredVolume||0,t,20),o(t,22,32),c(e.matrix,t,32),t.writeUInt32BE(e.previewTime||0,68),t.writeUInt32BE(e.previewDuration||0,72),t.writeUInt32BE(e.posterTime||0,76),t.writeUInt32BE(e.selectionTime||0,80),t.writeUInt32BE(e.selectionDuration||0,84),t.writeUInt32BE(e.currentTime||0,88),t.writeUInt32BE(e.nextTrackId||0,92),n.mvhd.encode.bytes=96,t},n.mvhd.decode=function(e,t){return e=e.slice(t),{ctime:h(e,0),mtime:h(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),preferredRate:m(e,16),preferredVolume:g(e,20),matrix:f(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(){return 96},n.tkhd={},n.tkhd.encode=function(e,t,r){return t=t?t.slice(r):w(80),i(e.ctime||new Date,t,0),i(e.mtime||new Date,t,4),t.writeUInt32BE(e.trackId||0,8),o(t,12,16),t.writeUInt32BE(e.duration||0,16),o(t,20,28),t.writeUInt16BE(e.layer||0,28),t.writeUInt16BE(e.alternateGroup||0,30),t.writeUInt16BE(e.volume||0,32),c(e.matrix,t,36),t.writeUInt32BE(e.trackWidth||0,72),t.writeUInt32BE(e.trackHeight||0,76),n.tkhd.encode.bytes=80,t},n.tkhd.decode=function(e,t){return e=e.slice(t),{ctime:h(e,0),mtime:h(e,4),trackId:e.readUInt32BE(8),duration:e.readUInt32BE(16),layer:e.readUInt16BE(28),alternateGroup:e.readUInt16BE(30),volume:e.readUInt16BE(32),matrix:f(e.slice(36,72)),trackWidth:e.readUInt32BE(72),trackHeight:e.readUInt32BE(76)}},n.tkhd.encodingLength=function(){return 80},n.mdhd={},n.mdhd.encode=function(e,t,r){return 1===e.version?(t=t?t.slice(r):w(32),a(e.ctime||new Date,t,0),a(e.mtime||new Date,t,8),t.writeUInt32BE(e.timeScale||0,16),t.writeUIntBE(e.duration||0,20,6),t.writeUInt16BE(e.language||0,28),t.writeUInt16BE(e.quality||0,30),n.mdhd.encode.bytes=32,t):(t=t?t.slice(r):w(20),i(e.ctime||new Date,t,0),i(e.mtime||new Date,t,4),t.writeUInt32BE(e.timeScale||0,8),t.writeUInt32BE(e.duration||0,12),t.writeUInt16BE(e.language||0,16),t.writeUInt16BE(e.quality||0,18),n.mdhd.encode.bytes=20,t)},n.mdhd.decode=function(e,t,n){e=e.slice(t);return 20!=n-t?{ctime:p(e,0),mtime:p(e,8),timeScale:e.readUInt32BE(16),duration:e.readUIntBE(20,6),language:e.readUInt16BE(28),quality:e.readUInt16BE(30)}:{ctime:h(e,0),mtime:h(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),language:e.readUInt16BE(16),quality:e.readUInt16BE(18)}},n.mdhd.encodingLength=function(e){return 1===e.version?32:20},n.vmhd={},n.vmhd.encode=function(e,t,r){t=t?t.slice(r):w(8),t.writeUInt16BE(e.graphicsMode||0,0);var o=e.opcolor||[0,0,0];return t.writeUInt16BE(o[0],2),t.writeUInt16BE(o[1],4),t.writeUInt16BE(o[2],6),n.vmhd.encode.bytes=8,t},n.vmhd.decode=function(e,t){return e=e.slice(t),{graphicsMode:e.readUInt16BE(0),opcolor:[e.readUInt16BE(2),e.readUInt16BE(4),e.readUInt16BE(6)]}},n.vmhd.encodingLength=function(){return 8},n.smhd={},n.smhd.encode=function(e,t,r){return t=t?t.slice(r):w(4),t.writeUInt16BE(e.balance||0,0),o(t,2,4),n.smhd.encode.bytes=4,t},n.smhd.decode=function(e,t){return e=e.slice(t),{balance:e.readUInt16BE(0)}},n.smhd.encodingLength=function(){return 4},n.stsd={},n.stsd.encode=function(e,t,r){t=t?t.slice(r):w(n.stsd.encodingLength(e));var o=e.entries||[];t.writeUInt32BE(o.length,0);for(var a=4,d=0,s;d<o.length;d++)s=o[d],b.encode(s,t,a),a+=b.encode.bytes;return n.stsd.encode.bytes=a,t},n.stsd.decode=function(e,t,n){e=e.slice(t);for(var r=e.readUInt32BE(0),o=Array(r),a=4,d=0,s;d<r;d++)s=b.decode(e,a,n),o[d]=s,a+=s.length;return{entries:o}},n.stsd.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var n=0;n<e.entries.length;n++)t+=b.encodingLength(e.entries[n]);return t},n.avc1=n.VisualSampleEntry={},n.VisualSampleEntry.encode=function(e,t,r){t=t?t.slice(r):w(n.VisualSampleEntry.encodingLength(e)),o(t,0,6),t.writeUInt16BE(e.dataReferenceIndex||0,6),o(t,8,24),t.writeUInt16BE(e.width||0,24),t.writeUInt16BE(e.height||0,26),t.writeUInt32BE(e.hResolution||4718592,28),t.writeUInt32BE(e.vResolution||4718592,32),o(t,36,40),t.writeUInt16BE(e.frameCount||1,40);var i=e.compressorName||"",a=s(i.length,31);t.writeUInt8(a,42),t.write(i,43,a,"utf8"),t.writeUInt16BE(e.depth||24,74),t.writeInt16BE(-1,76);var d=78,l=e.children||[];l.forEach(function(e){b.encode(e,t,d),d+=b.encode.bytes}),n.VisualSampleEntry.encode.bytes=d},n.VisualSampleEntry.decode=function(e,t,n){e=e.slice(t);for(var r=n-t,o=s(e.readUInt8(42),31),i={dataReferenceIndex:e.readUInt16BE(6),width:e.readUInt16BE(24),height:e.readUInt16BE(26),hResolution:e.readUInt32BE(28),vResolution:e.readUInt32BE(32),frameCount:e.readUInt16BE(40),compressorName:e.toString("utf8",43,43+o),depth:e.readUInt16BE(74),children:[]},a=78;8<=r-a;){var d=b.decode(e,a,r);i.children.push(d),i[d.type]=d,a+=d.length}return i},n.VisualSampleEntry.encodingLength=function(e){var t=78,n=e.children||[];return n.forEach(function(e){t+=b.encodingLength(e)}),t},n.avcC={},n.avcC.encode=function(e,t,r){t=t?t.slice(r):w(e.buffer.length),e.buffer.copy(t),n.avcC.encode.bytes=e.buffer.length},n.avcC.decode=function(e,t,n){return e=e.slice(t,n),{mimeCodec:e.toString("hex",1,4),buffer:k(e)}},n.avcC.encodingLength=function(e){return e.buffer.length},n.mp4a=n.AudioSampleEntry={},n.AudioSampleEntry.encode=function(e,t,r){t=t?t.slice(r):w(n.AudioSampleEntry.encodingLength(e)),o(t,0,6),t.writeUInt16BE(e.dataReferenceIndex||0,6),o(t,8,16),t.writeUInt16BE(e.channelCount||2,16),t.writeUInt16BE(e.sampleSize||16,18),o(t,20,24),t.writeUInt32BE(e.sampleRate||0,24);var i=28,a=e.children||[];a.forEach(function(e){b.encode(e,t,i),i+=b.encode.bytes}),n.AudioSampleEntry.encode.bytes=i},n.AudioSampleEntry.decode=function(e,t,n){e=e.slice(t,n);for(var r=n-t,o={dataReferenceIndex:e.readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},i=28;8<=r-i;){var a=b.decode(e,i,r);o.children.push(a),o[a.type]=a,i+=a.length}return o},n.AudioSampleEntry.encodingLength=function(e){var t=28,n=e.children||[];return n.forEach(function(e){t+=b.encodingLength(e)}),t},n.esds={},n.esds.encode=function(e,t,r){t=t?t.slice(r):w(e.buffer.length),e.buffer.copy(t,0),n.esds.encode.bytes=e.buffer.length},n.esds.decode=function(e,t,n){e=e.slice(t,n);var r=y.Descriptor.decode(e,0,e.length),o="ESDescriptor"===r.tagName?r:{},i=o.DecoderConfigDescriptor||{},a=i.oti||0,d=i.DecoderSpecificInfo,s=d?(248&d.buffer.readUInt8(0))>>3:0,l=null;return a&&(l=a.toString(16),s&&(l+="."+s)),{mimeCodec:l,buffer:k(e.slice(0))}},n.esds.encodingLength=function(e){return e.buffer.length},n.stsz={},n.stsz.encode=function(e,t,r){var o=e.entries||[];t=t?t.slice(r):w(n.stsz.encodingLength(e)),t.writeUInt32BE(0,0),t.writeUInt32BE(o.length,4);for(var a=0;a<o.length;a++)t.writeUInt32BE(o[a],4*a+8);return n.stsz.encode.bytes=8+4*o.length,t},n.stsz.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=e.readUInt32BE(4),o=Array(r),a=0;a<r;a++)o[a]=0===n?e.readUInt32BE(4*a+8):n;return{entries:o}},n.stsz.encodingLength=function(e){return 8+4*e.entries.length},n.stss=n.stco={},n.stco.encode=function(e,t,r){var o=e.entries||[];t=t?t.slice(r):w(n.stco.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0;a<o.length;a++)t.writeUInt32BE(o[a],4*a+4);return n.stco.encode.bytes=4+4*o.length,t},n.stco.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0;o<n;o++)r[o]=e.readUInt32BE(4*o+4);return{entries:r}},n.stco.encodingLength=function(e){return 4+4*e.entries.length},n.co64={},n.co64.encode=function(e,t,r){var o=e.entries||[];t=t?t.slice(r):w(n.co64.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0;a<o.length;a++)x.encode(o[a],t,8*a+4);return n.co64.encode.bytes=4+8*o.length,t},n.co64.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0;o<n;o++)r[o]=x.decode(e,8*o+4);return{entries:r}},n.co64.encodingLength=function(e){return 4+8*e.entries.length},n.stts={},n.stts.encode=function(e,t,r){var o=e.entries||[];t=t?t.slice(r):w(n.stts.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0,d;a<o.length;a++)d=8*a+4,t.writeUInt32BE(o[a].count||0,d),t.writeUInt32BE(o[a].duration||0,d+4);return n.stts.encode.bytes=4+8*e.entries.length,t},n.stts.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0,a;o<n;o++)a=8*o+4,r[o]={count:e.readUInt32BE(a),duration:e.readUInt32BE(a+4)};return{entries:r}},n.stts.encodingLength=function(e){return 4+8*e.entries.length},n.ctts={},n.ctts.encode=function(e,t,r){var o=e.entries||[];t=t?t.slice(r):w(n.ctts.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0,d;a<o.length;a++)d=8*a+4,t.writeUInt32BE(o[a].count||0,d),t.writeUInt32BE(o[a].compositionOffset||0,d+4);return n.ctts.encode.bytes=4+8*o.length,t},n.ctts.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0,a;o<n;o++)a=8*o+4,r[o]={count:e.readUInt32BE(a),compositionOffset:e.readInt32BE(a+4)};return{entries:r}},n.ctts.encodingLength=function(e){return 4+8*e.entries.length},n.stsc={},n.stsc.encode=function(e,t,r){var o=e.entries||[];t=t?t.slice(r):w(n.stsc.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0,d;a<o.length;a++)d=12*a+4,t.writeUInt32BE(o[a].firstChunk||0,d),t.writeUInt32BE(o[a].samplesPerChunk||0,d+4),t.writeUInt32BE(o[a].sampleDescriptionId||0,d+8);return n.stsc.encode.bytes=4+12*o.length,t},n.stsc.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0,a;o<n;o++)a=12*o+4,r[o]={firstChunk:e.readUInt32BE(a),samplesPerChunk:e.readUInt32BE(a+4),sampleDescriptionId:e.readUInt32BE(a+8)};return{entries:r}},n.stsc.encodingLength=function(e){return 4+12*e.entries.length},n.dref={},n.dref.encode=function(e,t,r){t=t?t.slice(r):w(n.dref.encodingLength(e));var o=e.entries||[];t.writeUInt32BE(o.length,0);for(var a=4,d=0;d<o.length;d++){var s=o[d],l=(s.buf?s.buf.length:0)+4+4;t.writeUInt32BE(l,a),a+=4,t.write(s.type,a,4,"ascii"),a+=4,s.buf&&(s.buf.copy(t,a),a+=s.buf.length)}return n.dref.encode.bytes=a,t},n.dref.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=4,a=0;a<n;a++){var d=e.readUInt32BE(o),s=e.toString("ascii",o+4,o+8),l=e.slice(o+8,o+d);o+=d,r[a]={type:s,buf:l}}return{entries:r}},n.dref.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var n=0,r;n<e.entries.length;n++)r=e.entries[n].buf,t+=(r?r.length:0)+4+4;return t},n.elst={},n.elst.encode=function(e,t,r){var o=e.entries||[];t=t?t.slice(r):w(n.elst.encodingLength(e)),t.writeUInt32BE(o.length,0);for(var a=0,s;a<o.length;a++)s=12*a+4,t.writeUInt32BE(o[a].trackDuration||0,s),t.writeUInt32BE(o[a].mediaTime||0,s+4),d(o[a].mediaRate||0,t,s+8);return n.elst.encode.bytes=4+12*o.length,t},n.elst.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=Array(n),o=0,a;o<n;o++)a=12*o+4,r[o]={trackDuration:e.readUInt32BE(a),mediaTime:e.readInt32BE(a+4),mediaRate:m(e,a+8)};return{entries:r}},n.elst.encodingLength=function(e){return 4+12*e.entries.length},n.hdlr={},n.hdlr.encode=function(e,t,r){t=t?t.slice(r):w(n.hdlr.encodingLength(e));var o=21+(e.name||"").length;return t.fill(0,0,o),t.write(e.handlerType||"",4,4,"ascii"),u(e.name||"",t,20),n.hdlr.encode.bytes=o,t},n.hdlr.decode=function(e,t,n){return e=e.slice(t),{handlerType:e.toString("ascii",4,8),name:_(e,20,n)}},n.hdlr.encodingLength=function(e){return 21+(e.name||"").length},n.mehd={},n.mehd.encode=function(e,t,r){return t=t?t.slice(r):w(4),t.writeUInt32BE(e.fragmentDuration||0,0),n.mehd.encode.bytes=4,t},n.mehd.decode=function(e,t){return e=e.slice(t),{fragmentDuration:e.readUInt32BE(0)}},n.mehd.encodingLength=function(){return 4},n.trex={},n.trex.encode=function(e,t,r){return t=t?t.slice(r):w(20),t.writeUInt32BE(e.trackId||0,0),t.writeUInt32BE(e.defaultSampleDescriptionIndex||0,4),t.writeUInt32BE(e.defaultSampleDuration||0,8),t.writeUInt32BE(e.defaultSampleSize||0,12),t.writeUInt32BE(e.defaultSampleFlags||0,16),n.trex.encode.bytes=20,t},n.trex.decode=function(e,t){return e=e.slice(t),{trackId:e.readUInt32BE(0),defaultSampleDescriptionIndex:e.readUInt32BE(4),defaultSampleDuration:e.readUInt32BE(8),defaultSampleSize:e.readUInt32BE(12),defaultSampleFlags:e.readUInt32BE(16)}},n.trex.encodingLength=function(){return 20},n.mfhd={},n.mfhd.encode=function(e,t,r){return t=t?t.slice(r):w(4),t.writeUInt32BE(e.sequenceNumber||0,0),n.mfhd.encode.bytes=4,t},n.mfhd.decode=function(e){return{sequenceNumber:e.readUInt32BE(0)}},n.mfhd.encodingLength=function(){return 4},n.tfhd={},n.tfhd.encode=function(e,t,r){return t=t?t.slice(r):w(4),t.writeUInt32BE(e.trackId,0),n.tfhd.encode.bytes=4,t},n.tfhd.decode=function(){},n.tfhd.encodingLength=function(){return 4},n.tfdt={},n.tfdt.encode=function(e,t,r){return t=t?t.slice(r):w(4),t.writeUInt32BE(e.baseMediaDecodeTime||0,0),n.tfdt.encode.bytes=4,t},n.tfdt.decode=function(){},n.tfdt.encodingLength=function(){return 4},n.trun={},n.trun.encode=function(e,t,r){t=t?t.slice(r):w(8+16*e.entries.length),t.writeUInt32BE(e.entries.length,0),t.writeInt32BE(e.dataOffset,4);for(var o=8,a=0,d;a<e.entries.length;a++)d=e.entries[a],t.writeUInt32BE(d.sampleDuration,o),o+=4,t.writeUInt32BE(d.sampleSize,o),o+=4,t.writeUInt32BE(d.sampleFlags,o),o+=4,0===(e.version||0)?t.writeUInt32BE(d.sampleCompositionTimeOffset,o):t.writeInt32BE(d.sampleCompositionTimeOffset,o),o+=4;n.trun.encode.bytes=o},n.trun.decode=function(){},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,t,n){return{buffer:k(e.slice(t,n))}},n.mdat.encodingLength=function(e){return e.buffer?e.buffer.length:e.contentLength}},{"./descriptor":53,"./index":54,"buffer-alloc":24,"buffer-from":26,uint64be:131}],53:[function(e,t,n){var r=e("buffer-from"),o={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};n.Descriptor={},n.Descriptor.decode=function(e,t,i){var a=e.readUInt8(t),d=t+1,s=0,l;do l=e.readUInt8(d++),s=s<<7|127&l;while(128&l);var c=o[a],u;return u=n[c]?n[c].decode(e,d,i):{buffer:r(e.slice(d,d+s))},u.tag=a,u.tagName=c,u.length=d-t+s,u.contentsLen=s,u},n.DescriptorArray={},n.DescriptorArray.decode=function(e,t,r){for(var i=t,a={};i+2<=r;){var d=n.Descriptor.decode(e,i,r);i+=d.length;var s=o[d.tag]||"Descriptor"+d.tag;a[s]=d}return a},n.ESDescriptor={},n.ESDescriptor.decode=function(e,t,r){var o=e.readUInt8(t+2),i=t+3;if(128&o&&(i+=2),64&o){var a=e.readUInt8(i);i+=a+1}return 32&o&&(i+=2),n.DescriptorArray.decode(e,i,r)},n.DecoderConfigDescriptor={},n.DecoderConfigDescriptor.decode=function(e,t,r){var o=e.readUInt8(t),i=n.DescriptorArray.decode(e,t+13,r);return i.oti=o,i}},{"buffer-from":26}],54:[function(e,t,n){var r=e("uint64be"),o=e("buffer-alloc"),i=e("buffer-from"),a=e("./boxes"),d=4294967295,s=n,l=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","saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","tfdt","trun","sbgps","sgpds","subss","saizs","saios","meta"]};s.encode=function(e,t,n){return s.encodingLength(e),n=n||0,t=t||o(e.length),s._encode(e,t,n)},s._encode=function(e,t,n){var o=e.type,i=e.length;i>d&&(i=1),t.writeUInt32BE(i,n),t.write(e.type,n+4,4,"ascii");var c=n+8;if(1===i&&(r.encode(e.length,t,c),c+=8),a.fullBoxes[o]&&(t.writeUInt32BE(e.flags||0,c),t.writeUInt8(e.version||0,c),c+=4),l[o]){var u=l[o];u.forEach(function(n){if(5===n.length){var r=e[n]||[];n=n.substr(0,4),r.forEach(function(e){s._encode(e,t,c),c+=s.encode.bytes})}else e[n]&&(s._encode(e[n],t,c),c+=s.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){s._encode(e,t,c),c+=s.encode.bytes})}else if(a[o]){var f=a[o].encode;f(e,t,c),c+=f.bytes}else if(e.buffer){var p=e.buffer;p.copy(t,c),c+=e.buffer.length}else throw new Error("Either `type` must be set to a known type (not'"+o+"') or `buffer` must be set");return s.encode.bytes=c-n,t},s.readHeaders=function(e,t,n){if(t=t||0,n=n||e.length,8>n-t)return 8;var o=e.readUInt32BE(t),i=e.toString("ascii",t+4,t+8),d=t+8;if(1===o){if(16>n-t)return 16;o=r.decode(e,d),d+=8}var s,l;return a.fullBoxes[i]&&(s=e.readUInt8(d),l=16777215&e.readUInt32BE(d),d+=4),{length:o,headersLen:d-t,contentLen:o-(d-t),type:i,version:s,flags:l}},s.decode=function(e,t,n){t=t||0,n=n||e.length;var r=s.readHeaders(e,t,n);if(!r||r.length>n-t)throw new Error("Data too short");return s.decodeWithoutHeaders(r,e,t+r.headersLen,t+r.length)},s.decodeWithoutHeaders=function(e,t,n,r){n=n||0,r=r||t.length;var o=e.type,d={};if(l[o]){d.otherBoxes=[];for(var c=l[o],u=n,f;8<=r-u;)if(f=s.decode(t,u,r),u+=f.length,0<=c.indexOf(f.type))d[f.type]=f;else if(0<=c.indexOf(f.type+"s")){var p=f.type+"s",h=d[p]=d[p]||[];h.push(f)}else d.otherBoxes.push(f)}else if(a[o]){var m=a[o].decode;d=m(t,n,r)}else d.buffer=i(t.slice(n,r));return d.length=e.length,d.contentLen=e.contentLen,d.type=e.type,d.version=e.version,d.flags=e.flags,d},s.encodingLength=function(e){var t=e.type,n=8;if(a.fullBoxes[t]&&(n+=4),l[t]){var r=l[t];r.forEach(function(t){if(5===t.length){var r=e[t]||[];t=t.substr(0,4),r.forEach(function(e){e.type=t,n+=s.encodingLength(e)})}else if(e[t]){var o=e[t];o.type=t,n+=s.encodingLength(o)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){n+=s.encodingLength(e)})}else if(a[t])n+=a[t].encodingLength(e);else if(e.buffer)n+=e.buffer.length;else throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");return n>d&&(n+=8),e.length=n,n}},{"./boxes":52,"buffer-alloc":24,"buffer-from":26,uint64be:131}],55:[function(e,t){(function(n){function r(){return this instanceof r?void(i.Writable.call(this),this.destroyed=!1,this._pending=0,this._missing=0,this._ignoreEmpty=!1,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()):new r}function o(e){this._parent=e,this.destroyed=!1,i.PassThrough.call(this)}var i=e("readable-stream"),a=e("inherits"),d=e("next-event"),s=e("mp4-box-encoding"),l=e("buffer-alloc"),c=l(0);t.exports=r,a(r,i.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&&!this._ignoreEmpty)return this._writeBuffer=e,void(this._writeCb=n);var o=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(o===e.length?e:e.slice(0,o))),this._missing-=o,!this._missing){var i=this._buf,a=this._cb,d=this._str;this._buf=this._cb=this._str=this._ondrain=null,r=!0,this._ignoreEmpty=!1,d&&d.end(),a&&a(i)}e=o===e.length?c:e.slice(o)}return this._pending&&!this._missing?(this._writeBuffer=e,void(this._writeCb=n)):void(r?n():this._ondrain(n))}},r.prototype._buffer=function(e,t){this._missing=e,this._buf=l(e),this._cb=t},r.prototype._stream=function(e,t){var n=this;return this._missing=e,this._str=new o(this),this._ondrain=d(this._str,"drain"),this._pending++,this._str.on("end",function(){n._pending--,n._kick()}),this._cb=t,this._str},r.prototype._readBox=function(){function e(r,o){t._buffer(r,function(r){o=o?n.concat([o,r]):r;var i=s.readHeaders(o);"number"==typeof i?e(i-o.length,o):(t._pending++,t._headers=i,t.emit("box",i))})}var t=this;e(8)},r.prototype.stream=function(){var e=this;if(!e._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=e._headers;return e._headers=null,e._stream(t.contentLen,null)},r.prototype.decode=function(e){var t=this;if(!t._headers)throw new Error("this function can only be called once after 'box' is emitted");var n=t._headers;t._headers=null,t._buffer(n.contentLen,function(r){var o=s.decodeWithoutHeaders(n,r);e(o),t._pending--,t._kick()})},r.prototype.ignore=function(){var e=this;if(!e._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=e._headers;e._headers=null,this._missing=t.contentLen,0===this._missing&&(this._ignoreEmpty=!0),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)}},a(o,i.PassThrough),o.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:27,"buffer-alloc":24,inherits:42,"mp4-box-encoding":54,"next-event":60,"readable-stream":90}],56:[function(e,t){(function(n){function r(){}function o(){if(!(this instanceof o))return new o;a.Readable.call(this),this.destroyed=!1,this._finalized=!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 i(e){this._parent=e,this.destroyed=!1,a.PassThrough.call(this)}var a=e("readable-stream"),d=e("inherits"),s=e("mp4-box-encoding"),l=e("buffer-alloc");t.exports=o,d(o,a.Readable),o.prototype.mediaData=o.prototype.mdat=function(e,t){var n=new i(this);return this.box({type:"mdat",contentLength:e,encodeBufferLen:8,stream:n},t),n},o.prototype.box=function(e,t){if(t||(t=r),this.destroyed)return t(new Error("Encoder is destroyed"));var o;if(e.encodeBufferLen&&(o=l(e.encodeBufferLen)),e.stream)e.buffer=null,o=s.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{o=s.encode(e,o);var i=this.push(o);if(i)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._finalized=!0,this._stream||this._drain||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,this._finalized&&this.push(null)}},d(i,a.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("_process"))},{_process:67,"buffer-alloc":24,inherits:42,"mp4-box-encoding":54,"readable-stream":90}],57:[function(e,t,n){n.decode=e("./decode"),n.encode=e("./encode")},{"./decode":55,"./encode":56}],58:[function(e,n){var s=Math.round;function r(e){if(e+="",!(100<e.length)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();return"years"===n||"year"===n||"yrs"===n||"yr"===n||"y"===n?31557600000*r:"weeks"===n||"week"===n||"w"===n?604800000*r:"days"===n||"day"===n||"d"===n?86400000*r:"hours"===n||"hour"===n||"hrs"===n||"hr"===n||"h"===n?3600000*r:"minutes"===n||"minute"===n||"mins"===n||"min"===n||"m"===n?60000*r:"seconds"===n||"second"===n||"secs"===n||"sec"===n||"s"===n?1000*r:"milliseconds"===n||"millisecond"===n||"msecs"===n||"msec"===n||"ms"===n?r:void 0}}}function o(e){var n=t(e);return 86400000<=n?s(e/86400000)+"d":3600000<=n?s(e/3600000)+"h":60000<=n?s(e/60000)+"m":1000<=n?s(e/1000)+"s":e+"ms"}function i(e){var n=t(e);return 86400000<=n?a(e,n,86400000,"day"):3600000<=n?a(e,n,3600000,"hour"):60000<=n?a(e,n,60000,"minute"):1000<=n?a(e,n,1000,"second"):e+" ms"}function a(e,t,r,n){return s(e/r)+" "+n+(t>=1.5*r?"s":"")}var l=24*(60*60000);n.exports=function(e,t){t=t||{};var n=typeof e;if("string"==n&&0<e.length)return r(e);if("number"==n&&isFinite(e))return t.long?i(e):o(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],59:[function(e,t){function n(e,t){var i=this;return i instanceof n?void(d.Readable.call(i,t),i.destroyed=!1,i._drained=!1,i._forwarding=!1,i._current=null,i._toStreams2=t&&t.objectMode?r:o,"function"==typeof e?i._queue=e:(i._queue=e.map(i._toStreams2),i._queue.forEach(function(e){"function"!=typeof e&&i._attachErrorListener(e)})),i._next()):new n(e,t)}function r(e){return i(e,{objectMode:!0,highWaterMark:16})}function o(e){return i(e)}function i(e,t){if(!e||"function"==typeof e||e._readableState)return e;var n=new d.Readable(t).wrap(e);return e.destroy&&(n.destroy=e.destroy.bind(e)),n}t.exports=n;var a=e("inherits"),d=e("readable-stream");a(n,d.Readable),n.obj=function(e){return new n(e,{objectMode:!0,highWaterMark:16})},n.prototype._read=function(){this._drained=!0,this._forward()},n.prototype._forward=function(){if(!this._forwarding&&this._drained&&this._current){this._forwarding=!0;for(var e;null!==(e=this._current.read())&&this._drained;)this._drained=this.push(e);this._forwarding=!1}},n.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),"function"!=typeof this._queue&&this._queue.forEach(function(e){e.destroy&&e.destroy()}),e&&this.emit("error",e),this.emit("close"))},n.prototype._next=function(){var e=this;if(e._current=null,"function"==typeof e._queue)e._queue(function(t,n){return t?e.destroy(t):void(n=e._toStreams2(n),e._attachErrorListener(n),e._gotNextStream(n))});else{var t=e._queue.shift();"function"==typeof t&&(t=e._toStreams2(t()),e._attachErrorListener(t)),e._gotNextStream(t)}},n.prototype._gotNextStream=function(e){function t(){o._forward()}function n(){e._readableState.ended||o.destroy()}function r(){o._current=null,e.removeListener("readable",t),e.removeListener("end",r),e.removeListener("close",n),o._next()}var o=this;return e?void(o._current=e,o._forward(),e.on("readable",t),e.once("end",r),e.once("close",n)):(o.push(null),void o.destroy())},n.prototype._attachErrorListener=function(e){function t(r){e.removeListener("error",t),n.destroy(r)}var n=this;e&&e.once("error",t)}},{inherits:42,"readable-stream":90}],60:[function(e,t){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}}},{}],61:[function(e,t){function n(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function r(e){var t=function(){if(t.called)throw new 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(n),t.exports.strict=o(r),n.proto=n(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return n(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return r(this)},configurable:!0})})},{wrappy:140}],62:[function(e,t){function n(e){if(/^-?\d+$/.test(e))return parseInt(e,10);var t;if(t=e.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)){var n=t[1],r=t[2],o=t[3];if(n&&o){n=parseInt(n),o=parseInt(o);var a=[],d=n<o?1:-1;("-"==r||".."==r||"\u2025"==r)&&(o+=d);for(var s=n;s!=o;s+=d)a.push(s);return a}}return[]}t.exports.parse=function(e){var t=e.split(","),r=t.map(function(e){return n(e)});return 0===r.length?[]:1===r.length?Array.isArray(r[0])?r[0]:r:r.reduce(function(e,t){return Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),e.concat(t)})}},{}],63:[function(e,t){(function(n,r){function o(e){if("string"==typeof e&&/^(stream-)?magnet:/.test(e))return h(e);if("string"==typeof e&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e)))return h(`magnet:?xt=urn:btih:${e}`);if(r.isBuffer(e)&&20===e.length)return h(`magnet:?xt=urn:btih:${e.toString("hex")}`);if(r.isBuffer(e))return i(e);if(e&&e.infoHash)return e.infoHash=e.infoHash.toLowerCase(),e.announce||(e.announce=[]),"string"==typeof e.announce&&(e.announce=[e.announce]),e.urlList||(e.urlList=[]),e;throw new Error("Invalid torrent identifier")}function i(e){r.isBuffer(e)&&(e=c.decode(e)),l(e.info,"info"),l(e.info["name.utf-8"]||e.info.name,"info.name"),l(e.info["piece length"],"info['piece length']"),l(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(e=>{l("number"==typeof e.length,"info.files[0].length"),l(e["path.utf-8"]||e.path,"info.files[0].path")}):l("number"==typeof e.info.length,"info.length");const t={info:e.info,infoBuffer:c.encode(e.info),name:(e.info["name.utf-8"]||e.info.name).toString(),announce:[]};t.infoHash=g.sync(t.infoBuffer),t.infoHashBuffer=r.from(t.infoHash,"hex"),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()),r.isBuffer(e.comment)&&(t.comment=e.comment.toString()),Array.isArray(e["announce-list"])&&0<e["announce-list"].length?e["announce-list"].forEach(e=>{e.forEach(e=>{t.announce.push(e.toString())})}):e.announce&&t.announce.push(e.announce.toString()),r.isBuffer(e["url-list"])&&(e["url-list"]=0<e["url-list"].length?[e["url-list"]]:[]),t.urlList=(e["url-list"]||[]).map(e=>e.toString()),_(t.announce),_(t.urlList);const n=e.info.files||[e.info];t.files=n.map((e,r)=>{const o=[].concat(t.name,e["path.utf-8"]||e.path||[]).map(e=>e.toString());return{path:m.join.apply(null,[m.sep].concat(o)).slice(1),name:o[o.length-1],length:e.length,offset:n.slice(0,r).reduce(d,0)}}),t.length=n.reduce(d,0);const o=t.files[t.files.length-1];return t.pieceLength=e.info["piece length"],t.lastPieceLength=(o.offset+o.length)%t.pieceLength||t.pieceLength,t.pieces=s(e.info.pieces),t}function a(e){return"undefined"!=typeof Blob&&e instanceof Blob}function d(e,t){return e+t.length}function s(e){const t=[];for(let n=0;n<e.length;n+=20)t.push(e.slice(n,n+20).toString("hex"));return t}function l(e,t){if(!e)throw new Error(`Torrent is missing required field: ${t}`)}const c=e("bencode"),u=e("blob-to-buffer"),f=e("fs"),p=e("simple-get"),h=e("magnet-uri"),m=e("path"),g=e("simple-sha1"),_=e("uniq");t.exports=o,t.exports.remote=function(e,t){function r(e){try{i=o(e)}catch(e){return t(e)}i&&i.infoHash?t(null,i):t(new Error("Invalid torrent identifier"))}let i;if("function"!=typeof t)throw new Error("second argument must be a Function");try{i=o(e)}catch(e){}i&&i.infoHash?n.nextTick(()=>{t(null,i)}):a(e)?u(e,(e,n)=>e?t(new Error(`Error converting Blob: ${e.message}`)):void r(n)):"function"==typeof p&&/^https?:/.test(e)?p.concat({url:e,timeout:30000,headers:{"user-agent":"WebTorrent (https://webtorrent.io)"}},(e,n,o)=>e?t(new Error(`Error downloading torrent: ${e.message}`)):void r(o)):"function"==typeof f.readFile&&"string"==typeof e?f.readFile(e,(e,n)=>e?t(new Error("Invalid torrent identifier")):void r(n)):n.nextTick(()=>{t(new Error("Invalid torrent identifier"))})},t.exports.toMagnetURI=h.encode,t.exports.toTorrentFile=function(e){const t={info:e.info};return t["announce-list"]=(e.announce||[]).map(e=>(t.announce||(t.announce=e),e=r.from(e,"utf8"),[e])),t["url-list"]=e.urlList||[],void 0!==e.private&&(t["private"]=+e.private),e.created&&(t["creation date"]=0|e.created.getTime()/1e3),e.createdBy&&(t["created by"]=e.createdBy),e.comment&&(t.comment=e.comment),c.encode(t)};(()=>{r.alloc(0)})()}).call(this,e("_process"),e("buffer").Buffer)},{_process:67,bencode:11,"blob-to-buffer":19,buffer:27,fs:22,"magnet-uri":49,path:64,"simple-get":98,"simple-sha1":100,uniq:132}],64:[function(e,t,n){(function(e){function t(e,t){for(var n=0,r=e.length-1,o;0<=r;r--)o=e[r],"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--);if(t)for(;n--;n)e.unshift("..");return e}function r(e){"string"!=typeof e&&(e+="");var t=0,n=-1,r=!0,o;for(o=e.length-1;0<=o;--o)if(!(47===e.charCodeAt(o)))-1===n&&(r=!1,n=o+1);else if(!r){t=o+1;break}return-1===n?"":e.slice(t,n)}function o(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}n.resolve=function(){for(var n="",r=!1,a=arguments.length-1,d;-1<=a&&!r;a--){if(d=0<=a?arguments[a]:e.cwd(),"string"!=typeof d)throw new TypeError("Arguments to path.resolve must be strings");else if(!d)continue;n=d+"/"+n,r="/"===d.charAt(0)}return n=t(o(n.split("/"),function(e){return!!e}),!r).join("/"),(r?"/":"")+n||"."},n.normalize=function(e){var r=n.isAbsolute(e),a="/"===i(e,-1);return e=t(o(e.split("/"),function(e){return!!e}),!r).join("/"),e||r||(e="."),e&&a&&(e+="/"),(r?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(o(e,function(e){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;0<=n&&""===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 o=r(e.split("/")),a=r(t.split("/")),d=s(o.length,a.length),l=d,c=0;c<d;c++)if(o[c]!==a[c]){l=c;break}for(var u=[],c=l;c<o.length;c++)u.push("..");return u=u.concat(a.slice(l)),u.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){if("string"!=typeof e&&(e+=""),0===e.length)return".";for(var t=e.charCodeAt(0),n=47===t,r=-1,o=!0,a=e.length-1;1<=a;--a)if(t=e.charCodeAt(a),47!==t)o=!1;else if(!o){r=a;break}return-1===r?n?"/":".":n&&1===r?"/":e.slice(0,r)},n.basename=function(e,t){var n=r(e);return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){"string"!=typeof e&&(e+="");for(var t=-1,n=0,r=-1,o=!0,a=0,d=e.length-1,s;0<=d;--d){if(s=e.charCodeAt(d),47===s){if(!o){n=d+1;break}continue}-1===r&&(o=!1,r=d+1),46===s?-1===t?t=d:1!==a&&(a=1):-1!==t&&(a=-1)}return-1===t||-1===r||0===a||1===a&&t===r-1&&t===n+1?"":e.slice(t,r)};var i=function(e,t,n){return e.substr(t,n)}}).call(this,e("_process"))},{_process:67}],65:[function(e,t){for(var r=e("closest-to"),o=n(2,10),i=13,a=[];22>i++;)a.push(n(2,i));t.exports=function(e){return r(e/o,a)}},{"closest-to":30}],66:[function(e,t){(function(e){'use strict';t.exports="undefined"!=typeof e&&e.version&&0!==e.version.indexOf("v0.")&&(0!==e.version.indexOf("v1.")||0===e.version.indexOf("v1.8."))?e:{nextTick:function(t,n,r,o){if("function"!=typeof t)throw new TypeError("\"callback\" argument must be a function");var a=arguments.length,d,s;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,o)});default:for(d=Array(a-1),s=0;s<d.length;)d[s++]=arguments[s];return e.nextTick(function(){t.apply(null,d)});}}}}).call(this,e("_process"))},{_process:67}],67:[function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(t){if(u===setTimeout)return setTimeout(t,0);if((u===n||!u)&&setTimeout)return u=setTimeout,setTimeout(t,0);try{return u(t,0)}catch(n){try{return u.call(null,t,0)}catch(n){return u.call(this,t,0)}}}function i(t){if(f===clearTimeout)return clearTimeout(t);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(t);try{return f(t)}catch(n){try{return f.call(null,t)}catch(n){return f.call(this,t)}}}function a(){h&&g&&(h=!1,g.length?p=g.concat(p):m=-1,p.length&&d())}function d(){if(!h){var e=o(a);h=!0;for(var t=p.length;t;){for(g=p,p=[];++m<t;)g&&g[m].run();m=-1,t=p.length}g=null,h=!1,i(e)}}function s(e,t){this.fun=e,this.array=t}function l(){}var c=t.exports={},u,f;(function(){try{u="function"==typeof setTimeout?setTimeout:n}catch(t){u=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(t){f=r}})();var p=[],h=!1,m=-1,g;c.nextTick=function(e){var t=Array(arguments.length-1);if(1<arguments.length)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(new s(e,t)),1!==p.length||h||o(d)},s.prototype.run=function(){this.fun.apply(null,this.array)},c.title="browser",c.browser=!0,c.env={},c.argv=[],c.version="",c.versions={},c.on=l,c.addListener=l,c.once=l,c.off=l,c.removeListener=l,c.removeAllListeners=l,c.emit=l,c.prependListener=l,c.prependOnceListener=l,c.listeners=function(){return[]},c.binding=function(){throw new Error("process.binding is not supported")},c.cwd=function(){return"/"},c.chdir=function(){throw new Error("process.chdir is not supported")},c.umask=function(){return 0}},{}],68:[function(e,t){(function(n){var r=e("once"),o=e("end-of-stream"),i=e("fs"),a=function(){},d=/^v?\.0/.test(n.version),s=function(e){return"function"==typeof e},l=function(e){return!!d&&!!i&&(e instanceof(i.ReadStream||a)||e instanceof(i.WriteStream||a))&&s(e.close)},c=function(e){return e.setHeader&&s(e.abort)},u=function(e,t,n,i){i=r(i);var d=!1;e.on("close",function(){d=!0}),o(e,{readable:t,writable:n},function(e){return e?i(e):void(d=!0,i())});var u=!1;return function(t){if(!d)return u?void 0:(u=!0,l(e)?e.close(a):c(e)?e.abort():s(e.destroy)?e.destroy():void i(t||new Error("stream was destroyed")))}},f=function(e){e()},p=function(e,t){return e.pipe(t)};t.exports=function(){var e=Array.prototype.slice.call(arguments),t=s(e[e.length-1]||a)&&e.pop()||a;if(Array.isArray(e[0])&&(e=e[0]),2>e.length)throw new Error("pump requires two streams per minimum");var n=e.map(function(o,a){var i=a<e.length-1;return u(o,i,0<a,function(e){r||(r=e),e&&n.forEach(f),i||(n.forEach(f),t(r))})}),r;return e.reduce(p)}}).call(this,e("_process"))},{_process:67,"end-of-stream":35,fs:21,once:61}],69:[function(e,t,n){(function(e){/*! https://mths.be/punycode v1.4.1 by @mathias */(function(i){function a(e){throw new RangeError(S[e])}function d(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function s(e,t){var n=e.split("@"),r="";1<n.length&&(r=n[0]+"@",e=n[1]),e=e.replace(x,".");var o=e.split("."),i=d(o,t).join(".");return r+i}function c(e){for(var t=[],n=0,r=e.length,o,i;n<r;)o=e.charCodeAt(n++),55296<=o&&56319>=o&&n<r?(i=e.charCodeAt(n++),56320==(64512&i)?t.push(((1023&o)<<10)+(1023&i)+65536):(t.push(o),n--)):t.push(o);return t}function u(e){return d(e,function(e){var t="";return 65535<e&&(e-=65536,t+=v(55296|1023&e>>>10),e=56320|1023&e),t+=v(e),t}).join("")}function f(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:36}function p(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function h(e,t,n){var r=0;for(e=n?E(e/700):e>>1,e+=E(e/t);455<e;r+=36)e=E(e/35);return E(r+36*e/(e+38))}function m(e){var r=[],o=e.length,d=0,s=128,l=72,c,p,m,g,_,b,y,x,S,v;for(p=e.lastIndexOf("-"),0>p&&(p=0),m=0;m<p;++m)128<=e.charCodeAt(m)&&a("not-basic"),r.push(e.charCodeAt(m));for(g=0<p?p+1:0;g<o;){for(_=d,b=1,y=36;;y+=36){if(g>=o&&a("invalid-input"),x=f(e.charCodeAt(g++)),(36<=x||x>E((2147483647-d)/b))&&a("overflow"),d+=x*b,S=y<=l?1:y>=l+26?26:y-l,x<S)break;v=36-S,b>E(2147483647/v)&&a("overflow"),b*=v}c=r.length+1,l=h(d-_,c,0==_),E(d/c)>2147483647-s&&a("overflow"),s+=E(d/c),d%=c,r.splice(d++,0,s)}return u(r)}function g(e){var r=[],o,i,d,s,l,u,f,g,_,b,y,w,x,S,C;for(e=c(e),w=e.length,o=128,i=0,l=72,u=0;u<w;++u)y=e[u],128>y&&r.push(v(y));for(d=s=r.length,s&&r.push("-");d<w;){for(f=2147483647,u=0;u<w;++u)y=e[u],y>=o&&y<f&&(f=y);for(x=d+1,f-o>E((2147483647-i)/x)&&a("overflow"),i+=(f-o)*x,o=f,u=0;u<w;++u)if(y=e[u],y<o&&2147483647<++i&&a("overflow"),y==o){for(g=i,_=36;;_+=36){if(b=_<=l?1:_>=l+26?26:_-l,g<b)break;C=g-b,S=36-b,r.push(v(p(b+C%S,0))),g=E(C/S)}r.push(v(p(g,0))),l=h(i,x,d==s),i=0,++d}++i,++o}return r.join("")}var _="object"==typeof n&&n&&!n.nodeType&&n,b="object"==typeof t&&t&&!t.nodeType&&t,y="object"==typeof e&&e;(y.global===y||y.window===y||y.self===y)&&(i=y);var w=/^xn--/,k=/[^\x20-\x7E]/,x=/[\x2E\u3002\uFF0E\uFF61]/g,S={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},E=r,v=o,C,L;if(C={version:"1.4.1",ucs2:{decode:c,encode:u},decode:m,encode:g,toASCII:function(e){return s(e,function(e){return k.test(e)?"xn--"+g(e):e})},toUnicode:function(e){return s(e,function(e){return w.test(e)?m(e.slice(4).toLowerCase()):e})}},"function"==typeof l&&"object"==typeof l.amd&&l.amd)l("punycode",function(){return C});else if(!(_&&b))i.punycode=C;else if(t.exports==_)b.exports=C;else for(L in C)C.hasOwnProperty(L)&&(_[L]=C[L])})(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],70:[function(e,t){'use strict';function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,o,a){t=t||"&",o=o||"=";var d={};if("string"!=typeof e||0===e.length)return d;var s=/\+/g;e=e.split(t);var l=1e3;a&&"number"==typeof a.maxKeys&&(l=a.maxKeys);var c=e.length;0<l&&c>l&&(c=l);for(var u=0;u<c;++u){var f=e[u].replace(s,"%20"),p=f.indexOf(o),h,m,g,_;0<=p?(h=f.substr(0,p),m=f.substr(p+1)):(h=f,m=""),g=decodeURIComponent(h),_=decodeURIComponent(m),n(d,g)?r(d[g])?d[g].push(_):d[g]=[d[g],_]:d[g]=_}return d};var r=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],71:[function(e,t){'use strict';function n(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 r=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,a,d){return t=t||"&",a=a||"=",null===e&&(e=void 0),"object"==typeof e?n(i(e),function(i){var d=encodeURIComponent(r(i))+a;return o(e[i])?n(e[i],function(e){return d+encodeURIComponent(r(e))}).join(t):d+encodeURIComponent(r(e[i]))}).join(t):d?encodeURIComponent(r(d))+a+encodeURIComponent(r(e)):""};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},i=Object.keys||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t}},{}],72:[function(e,t,n){'use strict';n.decode=n.parse=e("./decode"),n.encode=n.stringify=e("./encode")},{"./decode":70,"./encode":71}],73:[function(e,t){t.exports=function(e){var t=0;return function(){if(t===e.length)return null;var n=e.length-t,r=0|Math.random()*n,o=e[t+r],i=e[t];return e[t]=o,e[t+r]=i,t++,o}}},{}],74:[function(e,t){(function(n,r){'use strict';var o=e("safe-buffer").Buffer,i=r.crypto||r.msCrypto;t.exports=i&&i.getRandomValues?function(e,t){if(e>4294967295)throw new RangeError("requested too many random bytes");var r=o.allocUnsafe(e);if(0<e)if(65536<e)for(var a=0;a<e;a+=65536)i.getRandomValues(r.slice(a,a+65536));else i.getRandomValues(r);return"function"==typeof t?n.nextTick(function(){t(null,r)}):r}:function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{_process:67,"safe-buffer":96}],75:[function(e,t){const{Writable:n,PassThrough:r}=e("readable-stream");t.exports=class extends n{constructor(e,t={}){super(t),this.destroyed=!1,this._queue=[],this._position=e||0,this._cb=null,this._buffer=null,this._out=null}_write(e,t,n){let r=!0;for(;;){if(this.destroyed)return;if(0===this._queue.length)return this._buffer=e,void(this._cb=n);this._buffer=null;var o=this._queue[0];const t=d(o.start-this._position,0),i=o.end-this._position;if(t>=e.length)return this._position+=e.length,n(null);let a;if(i>e.length){this._position+=e.length,a=0===t?e:e.slice(t),r=o.stream.write(a)&&r;break}this._position+=i,a=0===t&&i===e.length?e:e.slice(t,i),r=o.stream.write(a)&&r,o.last&&o.stream.end(),e=e.slice(i),this._queue.shift()}r?n(null):o.stream.once("drain",n.bind(null,null))}slice(e){if(this.destroyed)return null;Array.isArray(e)||(e=[e]);const t=new r;return e.forEach((n,r)=>{this._queue.push({start:n.start,end:n.end,stream:t,last:r===e.length-1})}),this._buffer&&this._write(this._buffer,null,this._cb),t}destroy(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e))}}},{"readable-stream":90}],76:[function(e,t){'use strict';function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function r(e,t,r){function o(e,n,r){return"string"==typeof t?t:t(e,n,r)}r||(r=Error);var i=function(e){function t(t,n,r){return e.call(this,o(t,n,r))||this}return n(t,e),t}(r);i.prototype.name=r.name,i.prototype.code=e,s[e]=i}function o(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map(function(e){return e+""}),2<n?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(e+"")}function i(e,t,n){return e.substr(!n||0>n?0:+n,t.length)===t}function a(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-t.length,n)===t}function d(e,t,n){return"number"!=typeof n&&(n=0),!(n+t.length>e.length)&&-1!==e.indexOf(t,n)}var s={};r("ERR_INVALID_OPT_VALUE",function(e,t){return"The value \""+t+"\" is invalid for option \""+e+"\""},TypeError),r("ERR_INVALID_ARG_TYPE",function(e,t,n){var r;"string"==typeof t&&i(t,"not ")?(r="must not be",t=t.replace(/^not /,"")):r="must be";var s;if(a(e," argument"))s="The ".concat(e," ").concat(r," ").concat(o(t,"type"));else{var l=d(e,".")?"property":"argument";s="The \"".concat(e,"\" ").concat(l," ").concat(r," ").concat(o(t,"type"))}return s+=". Received type ".concat(typeof n),s},TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"}),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"}),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.codes=s},{}],77:[function(e,t){(function(e){'use strict';var n=new Set;t.exports.emitExperimentalWarning=e.emitWarning?function(t){if(!n.has(t)){n.add(t),e.emitWarning(t+" is an experimental feature. This feature could change at any time","ExperimentalWarning")}}:function(){}}).call(this,e("_process"))},{_process:67}],78:[function(e,t){(function(n){'use strict';function r(e){return this instanceof r?void(d.call(this,e),s.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",o)))):new r(e)}function o(){this._writableState.ended||n.nextTick(i,this)}function i(e){e.end()}var a=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=r;var d=e("./_stream_readable"),s=e("./_stream_writable");e("inherits")(r,d);for(var l=a(s.prototype),c=0,u;c<l.length;c++)u=l[c],r.prototype[u]||(r.prototype[u]=s.prototype[u]);Object.defineProperty(r.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(r.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(r.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(r.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0===this._readableState||void 0===this._writableState||(this._readableState.destroyed=e,this._writableState.destroyed=e)}})}).call(this,e("_process"))},{"./_stream_readable":80,"./_stream_writable":82,_process:67,inherits:42}],79:[function(e,t){'use strict';function n(e){return this instanceof n?void r.call(this,e):new n(e)}t.exports=n;var r=e("./_stream_transform");e("inherits")(n,r),n.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":81,inherits:42}],80:[function(e,t){(function(n,r){'use strict';function o(e){return U.from(e)}function i(e){return U.isBuffer(e)||e instanceof P}function a(e,t,n){return"function"==typeof e.prependListener?e.prependListener(t,n):void(e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n))}function d(t,n,r){T=T||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof T),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=j(this,t,"readableHighWaterMark",r),this.buffer=new N,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.paused=!0,this.emitClose=!1!==t.emitClose,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(!Y&&(Y=e("string_decoder/").StringDecoder),this.decoder=new Y(t.encoding),this.encoding=t.encoding)}function s(t){if(T=T||e("./_stream_duplex"),!(this instanceof s))return new s(t);var n=this instanceof T;this._readableState=new d(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),A.call(this)}function l(e,t,n,r,i){O("readableAddChunk",t);var a=e._readableState;if(null===t)a.reading=!1,h(e,a);else{var d;if(i||(d=u(a,t)),d)e.emit("error",d);else if(!(a.objectMode||t&&0<t.length))r||(a.reading=!1,_(e,a));else if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===U.prototype||(t=o(t)),r)a.endEmitted?e.emit("error",new V):c(e,a,t,!0);else if(a.ended)e.emit("error",new W);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?c(e,a,t,!1):_(e,a)):c(e,a,t,!1)}}return!a.ended&&(a.length<a.highWaterMark||0===a.length)}function c(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&m(e)),_(e,t)}function u(e,t){var n;return i(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new F("chunk",["string","Buffer","Uint8Array"],t)),n}function f(e){return 8388608<=e?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function p(e,t){return 0>=e||0===t.length&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=f(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}function h(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,t.sync?m(e):(t.needReadable=!1,!t.emittedReadable&&(t.emittedReadable=!0,g(e)))}}function m(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(O("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(g,e))}function g(e){var t=e._readableState;O("emitReadable_",t.destroyed,t.length,t.ended),!t.destroyed&&(t.length||t.ended)&&e.emit("readable"),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,E(e)}function _(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(b,e,t))}function b(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var n=t.length;if(O("maybeReadMore read 0"),e.read(0),n===t.length)break}t.readingMore=!1}function y(e){return function(){var t=e._readableState;O("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&B(e,"data")&&(t.flowing=!0,E(e))}}function w(e){var t=e._readableState;t.readableListening=0<e.listenerCount("readable"),t.resumeScheduled&&!t.paused?t.flowing=!0:0<e.listenerCount("data")&&e.resume()}function k(e){O("readable nexttick read 0"),e.read(0)}function x(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(S,e,t))}function S(e,t){O("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),E(e),t.flowing&&!t.reading&&e.read(0)}function E(e){var t=e._readableState;for(O("flow",t.flowing);t.flowing&&null!==e.read(););}function v(e,t){if(0===t.length)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n}function C(e){var t=e._readableState;O("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(L,t,e))}function L(e,t){O("endReadableNT",e.endEmitted,e.length),e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function I(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}t.exports=s;var T;s.ReadableState=d;var R=e("events").EventEmitter,B=function(e,t){return e.listeners(t).length},A=e("./internal/streams/stream"),U=e("buffer").Buffer,P=r.Uint8Array||function(){},M=e("util"),O;O=M&&M.debuglog?M.debuglog("stream"):function(){};var N=e("./internal/streams/buffer_list"),q=e("./internal/streams/destroy"),H=e("./internal/streams/state"),j=H.getHighWaterMark,D=e("../errors").codes,F=D.ERR_INVALID_ARG_TYPE,W=D.ERR_STREAM_PUSH_AFTER_EOF,z=D.ERR_METHOD_NOT_IMPLEMENTED,V=D.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,G=e("../experimentalWarning"),K=G.emitExperimentalWarning,Y,X;e("inherits")(s,A);var $=["error","close","destroy","pause","resume"];Object.defineProperty(s.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),s.prototype.destroy=q.destroy,s.prototype._undestroy=q.undestroy,s.prototype._destroy=function(e,t){t(e)},s.prototype.push=function(e,t){var n=this._readableState,r;return n.objectMode?r=!0:"string"==typeof e&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=U.from(e,t),t=""),r=!0),l(this,e,t,!1,r)},s.prototype.unshift=function(e){return l(this,e,null,!0,!1)},s.prototype.isPaused=function(){return!1===this._readableState.flowing},s.prototype.setEncoding=function(t){return Y||(Y=e("string_decoder/").StringDecoder),this._readableState.decoder=new Y(t),this._readableState.encoding=this._readableState.decoder.encoding,this};s.prototype.read=function(e){O("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0===t.highWaterMark?0<t.length:t.length>=t.highWaterMark)||t.ended))return O("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?C(this):m(this),null;if(e=p(e,t),0===e&&t.ended)return 0===t.length&&C(this),null;var o=t.needReadable;O("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&(o=!0,O("length less than watermark",o)),t.ended||t.reading?(o=!1,O("reading or ended",o)):o&&(O("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,!t.reading&&(e=p(r,t)));var i;return i=0<e?v(e,t):null,null===i?(t.needReadable=!0,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(!t.ended&&(t.needReadable=!0),r!==e&&t.ended&&C(this)),null!==i&&this.emit("data",i),i},s.prototype._read=function(){this.emit("error",new z("_read()"))},s.prototype.pipe=function(e,t){function r(e,t){O("onunpipe"),e===f&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,i())}function o(){O("onend"),e.end()}function i(){O("cleanup"),e.removeListener("close",l),e.removeListener("finish",c),e.removeListener("drain",g),e.removeListener("error",s),e.removeListener("unpipe",r),f.removeListener("end",o),f.removeListener("end",u),f.removeListener("data",d),_=!0,p.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&g()}function d(t){O("ondata");var n=e.write(t);O("dest.write",n),!1===n&&((1===p.pipesCount&&p.pipes===e||1<p.pipesCount&&-1!==I(p.pipes,e))&&!_&&(O("false write response, pause",p.awaitDrain),p.awaitDrain++),f.pause())}function s(t){O("onerror",t),u(),e.removeListener("error",s),0===B(e,"error")&&e.emit("error",t)}function l(){e.removeListener("finish",c),u()}function c(){O("onfinish"),e.removeListener("close",l),u()}function u(){O("unpipe"),f.unpipe(e)}var f=this,p=this._readableState;switch(p.pipesCount){case 0:p.pipes=e;break;case 1:p.pipes=[p.pipes,e];break;default:p.pipes.push(e);}p.pipesCount+=1,O("pipe count=%d opts=%j",p.pipesCount,t);var h=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr,m=h?o:u;p.endEmitted?n.nextTick(m):f.once("end",m),e.on("unpipe",r);var g=y(f);e.on("drain",g);var _=!1;return f.on("data",d),a(e,"error",s),e.once("close",l),e.once("finish",c),e.emit("pipe",f),p.flowing||(O("pipe resume"),f.resume()),e},s.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<o;a++)r[a].emit("unpipe",this,{hasUnpiped:!1});return this}var d=I(t.pipes,e);return-1===d?this:(t.pipes.splice(d,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},s.prototype.on=function(e,t){var r=A.prototype.on.call(this,e,t),o=this._readableState;return"data"===e?(o.readableListening=0<this.listenerCount("readable"),!1!==o.flowing&&this.resume()):"readable"==e&&!o.endEmitted&&!o.readableListening&&(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,O("on readable",o.length,o.reading),o.length?m(this):!o.reading&&n.nextTick(k,this)),r},s.prototype.addListener=s.prototype.on,s.prototype.removeListener=function(e,t){var r=A.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(w,this),r},s.prototype.removeAllListeners=function(e){var t=A.prototype.removeAllListeners.apply(this,arguments);return("readable"===e||void 0===e)&&n.nextTick(w,this),t},s.prototype.resume=function(){var e=this._readableState;return e.flowing||(O("resume"),e.flowing=!e.readableListening,x(this,e)),e.paused=!1,this},s.prototype.pause=function(){return O("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(O("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},s.prototype.wrap=function(e){var t=this,r=this._readableState,o=!1;for(var a in e.on("end",function(){if(O("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(n){if((O("wrapped data"),r.decoder&&(n=r.decoder.write(n)),!(r.objectMode&&(null===n||void 0===n)))&&(r.objectMode||n&&n.length)){var i=t.push(n);i||(o=!0,e.pause())}}),e)void 0===this[a]&&"function"==typeof e[a]&&(this[a]=function(t){return function(){return e[t].apply(e,arguments)}}(a));for(var i=0;i<$.length;i++)e.on($[i],this.emit.bind(this,$[i]));return this._read=function(t){O("wrapped _read",t),o&&(o=!1,e.resume())},this},"function"==typeof Symbol&&(s.prototype[Symbol.asyncIterator]=function(){return K("Readable[Symbol.asyncIterator]"),void 0===X&&(X=e("./internal/streams/async_iterator")),X(this)}),Object.defineProperty(s.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(s.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(s.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),s._fromList=v,Object.defineProperty(s.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}})}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"../errors":76,"../experimentalWarning":77,"./_stream_duplex":78,"./internal/streams/async_iterator":83,"./internal/streams/buffer_list":84,"./internal/streams/destroy":85,"./internal/streams/state":88,"./internal/streams/stream":89,_process:67,buffer:27,events:36,inherits:42,"string_decoder/":122,util:21}],81:[function(e,t){'use strict';function n(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new s);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function r(e){return this instanceof r?void(u.call(this,e),this._transformState={afterTransform:n.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},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.on("prefinish",o)):new r(e)}function o(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?i(this,null,null):this._flush(function(t,n){i(e,t,n)})}function i(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new c;if(e._transformState.transforming)throw new l;return e.push(null)}t.exports=r;var a=e("../errors").codes,d=a.ERR_METHOD_NOT_IMPLEMENTED,s=a.ERR_MULTIPLE_CALLBACK,l=a.ERR_TRANSFORM_ALREADY_TRANSFORMING,c=a.ERR_TRANSFORM_WITH_LENGTH_0,u=e("./_stream_duplex");e("inherits")(r,u),r.prototype.push=function(e,t){return this._transformState.needTransform=!1,u.prototype.push.call(this,e,t)},r.prototype._transform=function(e,t,n){n(new d("_transform()"))},r.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},r.prototype._read=function(){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},r.prototype._destroy=function(e,t){u.prototype._destroy.call(this,e,function(e){t(e)})}},{"../errors":76,"./_stream_duplex":78,inherits:42}],82:[function(e,t){(function(n,r){'use strict';function o(e){var t=this;this.next=null,this.entry=null,this.finish=function(){C(t,e)}}function i(e){return R.from(e)}function a(e){return R.isBuffer(e)||e instanceof B}function d(){}function s(t,n,r){L=L||e("./_stream_duplex"),t=t||{},"boolean"!=typeof r&&(r=n instanceof L),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=P(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=!1===t.decodeStrings;this.decodeStrings=!i,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){_(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function l(t){L=L||e("./_stream_duplex");var n=this instanceof L;return n||z.call(l,this)?void(this._writableState=new s(t,this,n),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),T.call(this)):new l(t)}function c(e,t){var r=new F;e.emit("error",r),n.nextTick(t,r)}function u(e,t,r,o){var i;return null===r?i=new D:"string"!=typeof r&&!t.objectMode&&(i=new O("chunk",["string","Buffer"],r)),!i||(e.emit("error",i),n.nextTick(o,i),!1)}function f(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=R.from(t,n)),t}function p(e,t,n,r,o,i){if(!n){var a=f(t,r,o);r!==a&&(n=!0,o="buffer",r=a)}var d=t.objectMode?1:r.length;t.length+=d;var s=t.length<t.highWaterMark;if(s||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else h(e,t,!1,d,r,o,i);return s}function h(e,t,n,r,o,i,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new j("write")):n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function m(e,t,r,o,i){--t.pendingcb,r?(n.nextTick(i,o),n.nextTick(E,e,t),e._writableState.errorEmitted=!0,e.emit("error",o)):(i(o),e._writableState.errorEmitted=!0,e.emit("error",o),E(e,t))}function g(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function _(e,t){var r=e._writableState,o=r.sync,i=r.writecb;if("function"!=typeof i)throw new q;if(g(r),t)m(e,r,o,t,i);else{var a=k(r)||e.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),o?n.nextTick(b,e,r,a,i):b(e,r,a,i)}}function b(e,t,n,r){n||y(e,t),t.pendingcb--,r(),E(e,t)}function y(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function w(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,i=Array(r),a=t.corkedRequestsFree;a.entry=n;for(var d=0,s=!0;n;)i[d]=n,n.isBuf||(s=!1),n=n.next,d+=1;i.allBuffers=s,h(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,c=n.encoding,u=n.callback,f=t.objectMode?1:l.length;if(h(e,t,!1,f,l,c,u),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function k(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),E(e,t)})}function S(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,n.nextTick(x,e,t)))}function E(e,t){var n=k(t);return n&&(S(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}function v(e,t,r){t.ending=!0,E(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r)),t.ended=!0,e.writable=!1}function C(e,t,n){var r=e.entry;for(e.entry=null;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree.next=e}t.exports=l;var L;l.WritableState=s;var I={deprecate:e("util-deprecate")},T=e("./internal/streams/stream"),R=e("buffer").Buffer,B=r.Uint8Array||function(){},A=e("./internal/streams/destroy"),U=e("./internal/streams/state"),P=U.getHighWaterMark,M=e("../errors").codes,O=M.ERR_INVALID_ARG_TYPE,N=M.ERR_METHOD_NOT_IMPLEMENTED,q=M.ERR_MULTIPLE_CALLBACK,H=M.ERR_STREAM_CANNOT_PIPE,j=M.ERR_STREAM_DESTROYED,D=M.ERR_STREAM_NULL_VALUES,F=M.ERR_STREAM_WRITE_AFTER_END,W=M.ERR_UNKNOWN_ENCODING;e("inherits")(l,T),s.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(s.prototype,"buffer",{get:I.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}();var z;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(z=Function.prototype[Symbol.hasInstance],Object.defineProperty(l,Symbol.hasInstance,{value:function(e){return!!z.call(this,e)||!(this!==l)&&e&&e._writableState instanceof s}})):z=function(e){return e instanceof this},l.prototype.pipe=function(){this.emit("error",new H)},l.prototype.write=function(e,t,n){var r=this._writableState,o=!1,s=!r.objectMode&&a(e);return s&&!R.isBuffer(e)&&(e=i(e)),"function"==typeof t&&(n=t,t=null),s?t="buffer":!t&&(t=r.defaultEncoding),"function"!=typeof n&&(n=d),r.ending?c(this,n):(s||u(this,r,e,n))&&(r.pendingcb++,o=p(this,r,s,e,t,n)),o},l.prototype.cork=function(){this._writableState.corked++},l.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&w(this,e))},l.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())))throw new W(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),l.prototype._write=function(e,t,n){n(new N("_write()"))},l.prototype._writev=null,l.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!==e&&void 0!==e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||v(this,r,n),this},Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),l.prototype.destroy=A.destroy,l.prototype._undestroy=A.undestroy,l.prototype._destroy=function(e,t){t(e)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"../errors":76,"./_stream_duplex":78,"./internal/streams/destroy":85,"./internal/streams/state":88,"./internal/streams/stream":89,_process:67,buffer:27,inherits:42,"util-deprecate":137}],83:[function(e,t){(function(n){'use strict';function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){return{value:e,done:t}}function i(e){var t=e[l];if(null!==t){var n=e[m].read();null!==n&&(e[p]=null,e[l]=null,e[c]=null,t(o(n,!1)))}}function a(e){n.nextTick(i,e)}function d(e,t){return function(n,r){e.then(function(){return t[f]?void n(o(void 0,!0)):void t[h](n,r)},r)}}var s=e("./end-of-stream"),l=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),f=Symbol("ended"),p=Symbol("lastPromise"),h=Symbol("handlePromise"),m=Symbol("stream"),g=Object.getPrototypeOf(function(){}),_=Object.setPrototypeOf((b={get stream(){return this[m]},next:function(){var e=this,t=this[u];if(null!==t)return Promise.reject(t);if(this[f])return Promise.resolve(o(void 0,!0));if(this[m].destroyed)return new Promise(function(t,r){n.nextTick(function(){e[u]?r(e[u]):t(o(void 0,!0))})});var r=this[p],i;if(r)i=new Promise(d(r,this));else{var a=this[m].read();if(null!==a)return Promise.resolve(o(a,!1));i=new Promise(this[h])}return this[p]=i,i}},r(b,Symbol.asyncIterator,function(){return this}),r(b,"return",function(){var e=this;return new Promise(function(t,n){e[m].destroy(null,function(e){return e?void n(e):void t(o(void 0,!0))})})}),b),g),b;t.exports=function(e){var t=Object.create(_,(n={},r(n,m,{value:e,writable:!0}),r(n,l,{value:null,writable:!0}),r(n,c,{value:null,writable:!0}),r(n,u,{value:null,writable:!0}),r(n,f,{value:e._readableState.endEmitted,writable:!0}),r(n,h,{value:function(e,n){var r=t[m].read();r?(t[p]=null,t[l]=null,t[c]=null,e(o(r,!1))):(t[l]=e,t[c]=n)},writable:!0}),n)),n;return t[p]=null,s(e,function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var n=t[c];return null!==n&&(t[p]=null,t[l]=null,t[c]=null,n(e)),void(t[u]=e)}var r=t[l];null!==r&&(t[p]=null,t[l]=null,t[c]=null,r(o(void 0,!0))),t[f]=!0}),e.on("readable",a.bind(null,t)),t}}).call(this,e("_process"))},{"./end-of-stream":86,_process:67}],84:[function(e,t){'use strict';function n(e){for(var t=1;t<arguments.length;t++){var n=null==arguments[t]?{}:arguments[t],o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){r(e,t,n[t])})}return e}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t,n){a.prototype.copy.call(e,t,n)}var i=e("buffer"),a=i.Buffer,d=e("util"),s=d.inspect,l=s&&s.custom||"inspect";t.exports=function(){function e(){this.head=null,this.tail=null,this.length=0}var t=e.prototype;return t.push=function(e){var t={data:e,next:null};0<this.length?this.tail.next=t:this.head=t,this.tail=t,++this.length},t.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},t.shift=function(){if(0!==this.length){var e=this.head.data;return this.head=1===this.length?this.tail=null:this.head.next,--this.length,e}},t.clear=function(){this.head=this.tail=null,this.length=0},t.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},t.concat=function(e){if(0===this.length)return a.alloc(0);for(var t=a.allocUnsafe(e>>>0),n=this.head,r=0;n;)o(n.data,t,r),r+=n.data.length,n=n.next;return t},t.consume=function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):e===this.head.data.length?n=this.shift():n=t?this._getString(e):this._getBuffer(e),n},t.first=function(){return this.head.data},t._getString=function(e){var t=this.head,r=1,o=t.data;for(e-=o.length;t=t.next;){var i=t.data,a=e>i.length?i.length:e;if(o+=a===i.length?i:i.slice(0,e),e-=a,0===e){a===i.length?(++r,this.head=t.next?t.next:this.tail=null):(this.head=t,t.data=i.slice(a));break}++r}return this.length-=r,o},t._getBuffer=function(e){var t=a.allocUnsafe(e),r=this.head,o=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,d=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,d),e-=d,0===e){d===i.length?(++o,this.head=r.next?r.next:this.tail=null):(this.head=r,r.data=i.slice(d));break}++o}return this.length-=o,t},t[l]=function(e,t){return s(this,n({},t,{depth:0,customInspect:!1}))},e}()},{buffer:27,util:21}],85:[function(e,t){(function(e){'use strict';function n(e,t){o(e,t),r(e)}function r(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function o(e,t){e.emit("error",t)}t.exports={destroy:function(t,i){var a=this,d=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return d||s?(i?i(t):t&&(!this._writableState||!this._writableState.errorEmitted)&&e.nextTick(o,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!i&&t?(e.nextTick(n,a,t),a._writableState&&(a._writableState.errorEmitted=!0)):i?(e.nextTick(r,a),i(t)):e.nextTick(r,a)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}}).call(this,e("_process"))},{_process:67}],86:[function(e,t){'use strict';function n(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=Array(n),o=0;o<n;o++)r[o]=arguments[o];e.apply(this,r)}}}function r(){}function o(e){return e.setHeader&&"function"==typeof e.abort}function i(e,t,d){if("function"==typeof t)return i(e,null,t);t||(t={}),d=n(d||r);var s=t.readable||!1!==t.readable&&e.readable,l=t.writable||!1!==t.writable&&e.writable,c=function(){e.writable||f()},u=e._writableState&&e._writableState.finished,f=function(){l=!1,u=!0,s||d.call(e)},p=e._readableState&&e._readableState.endEmitted,h=function(){s=!1,p=!0,l||d.call(e)},m=function(t){d.call(e,t)},g=function(){var t;return s&&!p?(e._readableState&&e._readableState.ended||(t=new a),d.call(e,t)):l&&!u?(e._writableState&&e._writableState.ended||(t=new a),d.call(e,t)):void 0},_=function(){e.req.on("finish",f)};return o(e)?(e.on("complete",f),e.on("abort",g),e.req?_():e.on("request",_)):l&&!e._writableState&&(e.on("end",c),e.on("close",c)),e.on("end",h),e.on("finish",f),!1!==t.error&&e.on("error",m),e.on("close",g),function(){e.removeListener("complete",f),e.removeListener("abort",g),e.removeListener("request",_),e.req&&e.req.removeListener("finish",f),e.removeListener("end",c),e.removeListener("close",c),e.removeListener("finish",f),e.removeListener("end",h),e.removeListener("error",m),e.removeListener("close",g)}}var a=e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;t.exports=i},{"../../../errors":76}],87:[function(e,t){'use strict';function n(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}function r(e){if(e)throw e}function o(e){return e.setHeader&&"function"==typeof e.abort}function a(t,r,i,a){a=n(a);var d=!1;t.on("close",function(){d=!0}),p===void 0&&(p=e("./end-of-stream")),p(t,{readable:r,writable:i},function(e){return e?a(e):void(d=!0,a())});var s=!1;return function(e){if(!d)return s?void 0:(s=!0,o(t)?t.abort():"function"==typeof t.destroy?t.destroy():void a(e||new f("pipe")))}}function d(e){e()}function s(e,t){return e.pipe(t)}function l(e){return e.length?"function"==typeof e[e.length-1]?e.pop():r:r}var c=e("../../../errors").codes,u=c.ERR_MISSING_ARGS,f=c.ERR_STREAM_DESTROYED,p;t.exports=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=l(t);if(Array.isArray(t[0])&&(t=t[0]),2>t.length)throw new u("streams");var o=t.map(function(e,n){var s=n<t.length-1;return a(e,s,0<n,function(e){i||(i=e),e&&o.forEach(d),s||(o.forEach(d),r(i))})}),i;return t.reduce(s)}},{"../../../errors":76,"./end-of-stream":86}],88:[function(e,t){'use strict';function n(e,t,n){return null==e.highWaterMark?t?e[n]:null:e.highWaterMark}var o=e("../../../errors").codes.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(e,t,i,a){var d=n(t,a,i);if(null!=d){if(!(isFinite(d)&&r(d)===d)||0>d){var s=a?i:"highWaterMark";throw new o(s,d)}return r(d)}return e.objectMode?16:16384}}},{"../../../errors":76}],89:[function(e,t){t.exports=e("events").EventEmitter},{events:36}],90:[function(e,t,n){n=t.exports=e("./lib/_stream_readable.js"),n.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"),n.finished=e("./lib/internal/streams/end-of-stream.js"),n.pipeline=e("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":78,"./lib/_stream_passthrough.js":79,"./lib/_stream_readable.js":80,"./lib/_stream_transform.js":81,"./lib/_stream_writable.js":82,"./lib/internal/streams/end-of-stream.js":86,"./lib/internal/streams/pipeline.js":87}],91:[function(e,t,n){function r(e,t,n,r){function i(){return!("number"==typeof e.length&&e.length>n.maxBlobLength)||(s("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),E(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")")),!1)}function d(n){i()&&(L=t(n),o(e,function(e,t){return e?E(e):void(L.addEventListener("error",E),L.addEventListener("loadstart",f),L.addEventListener("canplay",x),L.src=t)}))}function f(){L.removeEventListener("loadstart",f),n.autoplay&&L.play()}function x(){L.removeEventListener("canplay",x),r(null,L)}function S(){o(e,function(e,n){return e?E(e):void(".pdf"===v?(L=t("object"),L.setAttribute("typemustmatch",!0),L.setAttribute("type","application/pdf"),L.setAttribute("data",n)):(L=t("iframe"),L.sandbox="allow-forms allow-scripts",L.src=n),r(null,L))})}function E(t){t.message="Error rendering file \""+e.name+"\": "+t.message,s(t.message),r(t)}var v=u.extname(e.name).toLowerCase(),C=0,L;0<=g.indexOf(v)?function(){function n(){s("Use `videostream` package for "+e.name),g(),L.addEventListener("error",l),L.addEventListener("loadstart",f),L.addEventListener("canplay",x),p(e,L)}function r(){s("Use MediaSource API for "+e.name),g(),L.addEventListener("error",u),L.addEventListener("loadstart",f),L.addEventListener("canplay",x);var t=new c(L),n=t.createWriteStream(a(e.name));e.createReadStream().pipe(n),C&&(L.currentTime=C)}function d(){s("Use Blob URL for "+e.name),g(),L.addEventListener("error",E),L.addEventListener("loadstart",f),L.addEventListener("canplay",x),o(e,function(e,t){return e?E(e):void(L.src=t,C&&(L.currentTime=C))})}function l(e){s("videostream error: fallback to MediaSource API: %o",e.message||e),L.removeEventListener("error",l),L.removeEventListener("canplay",x),r()}function u(e){s("MediaSource API error: fallback to Blob URL: %o",e.message||e);i()&&(L.removeEventListener("error",u),L.removeEventListener("canplay",x),d())}function g(){L||(L=t(_),L.addEventListener("progress",function(){C=L.currentTime}))}var _=0<=m.indexOf(v)?"video":"audio";k?0<=h.indexOf(v)?n():r():d()}():0<=_.indexOf(v)?d("video"):0<=b.indexOf(v)?d("audio"):0<=y.indexOf(v)?function(){L=t("img"),o(e,function(t,n){return t?E(t):void(L.src=n,L.alt=e.name,r(null,L))})}():0<=w.indexOf(v)?S():function(){function t(){l(n)?(s("File extension \"%s\" appears ascii, so will render.",v),S()):(s("File extension \"%s\" appears non-ascii, will not render.",v),r(new Error("Unsupported file type \""+v+"\": Cannot append to DOM")))}s("Unknown file extension \"%s\" - will attempt to render into iframe",v);var n="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){n+=e}).on("end",t).on("error",r)}()}function o(e,t){var r=u.extname(e.name).toLowerCase();f(e.createReadStream(),n.mime[r],t)}function i(e){if(null==e)throw new Error("file cannot be null or undefined");if("string"!=typeof e.name)throw new Error("missing or invalid file.name property");if("function"!=typeof e.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function a(e){var t=u.extname(e).toLowerCase();return{".m4a":"audio/mp4; codecs=\"mp4a.40.5\"",".m4b":"audio/mp4; codecs=\"mp4a.40.5\"",".m4p":"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\""}[t]}function d(e){null==e.autoplay&&(e.autoplay=!1),null==e.muted&&(e.muted=!1),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=200000000)}n.render=function(e,t,n,o){"function"==typeof n&&(o=n,n={}),n||(n={}),o||(o=function(){}),i(e),d(n),"string"==typeof t&&(t=document.querySelector(t)),r(e,function(n){if(t.nodeName!==n.toUpperCase()){var r=u.extname(e.name).toLowerCase();throw new Error("Cannot render \""+r+"\" inside a \""+t.nodeName.toLowerCase()+"\" element, expected \""+n+"\"")}return t},n,o)},n.append=function(e,t,n,o){function a(e){var r=s(e);return n.autoplay&&(r.autoplay=!0),n.muted&&(r.muted=!0),n.controls&&(r.controls=!0),t.appendChild(r),r}function s(e){var n=document.createElement(e);return t.appendChild(n),n}function l(e,t){e&&t&&t.remove(),o(e,t)}if("function"==typeof n&&(o=n,n={}),n||(n={}),o||(o=function(){}),i(e),d(n),"string"==typeof t&&(t=document.querySelector(t)),t&&("VIDEO"===t.nodeName||"AUDIO"===t.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");r(e,function(e){return"video"===e||"audio"===e?a(e):s(e)},n,l)},n.mime=e("./lib/mime.json");var s=e("debug")("render-media"),l=e("is-ascii"),c=e("mediasource"),u=e("path"),f=e("stream-to-blob-url"),p=e("videostream"),h=[".m4a",".m4b",".m4p",".m4v",".mp4"],m=[".m4v",".mkv",".mp4",".webm"],g=[].concat(m,[".m4a",".m4b",".m4p",".mp3"]),_=[".mov",".ogv"],b=[".aac",".oga",".ogg",".wav",".flac"],y=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],w=[".css",".html",".js",".md",".pdf",".txt"],k="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":92,debug:33,"is-ascii":43,mediasource:50,path:64,"stream-to-blob-url":118,videostream:139}],92:[function(e,t){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/x-m4a",".m4b":"audio/mp4",".m4p":"audio/mp4",".m4v":"video/x-m4v",".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"}},{}],93:[function(e,t){(function(e){t.exports=function(t,n,r){function o(t){function n(){r&&r(t,s),r=null}d?e.nextTick(n):n()}function a(e,n,r){if(s[e]=r,n&&(f=!0),0==--c||n)o(n);else if(!f&&p<l){var i;u?(i=u[p],p+=1,t[i](function(e,t){a(i,e,t)})):(i=p,p+=1,t[i](function(e,t){a(i,e,t)}))}}if("number"!=typeof n)throw new Error("second argument must be a Number");var d=!0,s,l,c,u,f;Array.isArray(t)?(s=[],c=l=t.length):(u=Object.keys(t),s={},c=l=u.length);var p=n;c?u?u.some(function(e,r){if(t[e](function(t,n){a(e,t,n)}),r===n-1)return!0}):t.some(function(e,t){if(e(function(e,n){a(t,e,n)}),t===n-1)return!0}):o(null),d=!1}}).call(this,e("_process"))},{_process:67}],94:[function(e,t){(function(e){t.exports=function(t,n){function r(t){function r(){n&&n(t,a),n=null}i?e.nextTick(r):r()}function o(e,t,n){a[e]=n,(0==--d||t)&&r(t)}var i=!0,a,d,s;Array.isArray(t)?(a=[],d=t.length):(s=Object.keys(t),a={},d=s.length),d?s?s.forEach(function(e){t[e](function(t,n){o(e,t,n)})}):t.forEach(function(e,t){e(function(e,n){o(t,e,n)})}):r(null),i=!1}}).call(this,e("_process"))},{_process:67}],95:[function(e,t,n){(function(e,r){"object"==typeof n&&"object"==typeof t?t.exports=r():"function"==typeof l&&l.amd?l([],r):"object"==typeof n?n.Rusha=r():e.Rusha=r()})("undefined"==typeof self?this:self,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=n(5),i=n(1),a=i.toHex,d=i.ceilHeapSize,l=n(6),c=function(e){for(e+=9;0<e%64;e+=1);return e},u=function(e,t){var n=new Uint8Array(e.buffer),r=t%4,o=t-r;switch(r){case 0:n[o+3]=0;case 1:n[o+2]=0;case 2:n[o+1]=0;case 3:n[o+0]=0;}for(var a=(t>>2)+1;a<e.length;a++)e[a]=0},f=function(e,t,n){e[t>>2]|=128<<24-(t%4<<3),e[(-16&(t>>2)+2)+14]=0|n/536870912,e[(-16&(t>>2)+2)+15]=n<<3},p=function(e,t){var n=new Int32Array(e,t+320,5),r=new Int32Array(5),o=new DataView(r.buffer);return o.setInt32(0,n[0],!1),o.setInt32(4,n[1],!1),o.setInt32(8,n[2],!1),o.setInt32(12,n[3],!1),o.setInt32(16,n[4],!1),r},h=function(){function e(t){if(r(this,e),t=t||65536,0<t%64)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=t,this._padMaxChunkLen=c(t),this._heap=new ArrayBuffer(d(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new o({Int32Array:Int32Array},{},this._heap)}return e.prototype._initState=function(e,t){this._offset=0;var n=new Int32Array(e,t+320,5);n[0]=1732584193,n[1]=-271733879,n[2]=-1732584194,n[3]=271733878,n[4]=-1009589776},e.prototype._padChunk=function(e,t){var n=c(e),r=new Int32Array(this._heap,0,n>>2);return u(r,e),f(r,e,t),n},e.prototype._write=function(e,t,n,r){l(e,this._h8,this._h32,t,n,r||0)},e.prototype._coreCall=function(e,t,n,r,o){var i=n;this._write(e,t,n),o&&(i=this._padChunk(n,r)),this._core.hash(i,this._padMaxChunkLen)},e.prototype.rawDigest=function(e){var t=e.byteLength||e.length||e.size||0;this._initState(this._heap,this._padMaxChunkLen);var n=0,r=this._maxChunkLen;for(n=0;t>n+r;n+=r)this._coreCall(e,n,r,t,!1);return this._coreCall(e,n,t-n,t,!0),p(this._heap,this._padMaxChunkLen)},e.prototype.digest=function(e){return a(this.rawDigest(e).buffer)},e.prototype.digestFromString=function(e){return this.digest(e)},e.prototype.digestFromBuffer=function(e){return this.digest(e)},e.prototype.digestFromArrayBuffer=function(e){return this.digest(e)},e.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},e.prototype.append=function(e){var t=0,n=e.byteLength||e.length||e.size||0,r=this._offset%this._maxChunkLen,o=void 0;for(this._offset+=n;t<n;)o=s(n-t,this._maxChunkLen-r),this._write(e,t,o,r),r+=o,t+=o,r===this._maxChunkLen&&(this._core.hash(this._maxChunkLen,this._padMaxChunkLen),r=0);return this},e.prototype.getState=function(){var e=this._offset%this._maxChunkLen,t=void 0;if(!e){var n=new Int32Array(this._heap,this._padMaxChunkLen+320,5);t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else t=this._heap.slice(0);return{offset:this._offset,heap:t}},e.prototype.setState=function(e){if(this._offset=e.offset,20===e.heap.byteLength){var t=new Int32Array(this._heap,this._padMaxChunkLen+320,5);t.set(new Int32Array(e.heap))}else this._h32.set(new Int32Array(e.heap));return this},e.prototype.rawEnd=function(){var e=this._offset,t=e%this._maxChunkLen,n=this._padChunk(t,e);this._core.hash(n,this._padMaxChunkLen);var r=p(this._heap,this._padMaxChunkLen);return this._initState(this._heap,this._padMaxChunkLen),r},e.prototype.end=function(){return a(this.rawEnd().buffer)},e}();e.exports=h,e.exports._core=o},function(e){for(var t=Array(256),n=0;256>n;n++)t[n]=(16>n?"0":"")+n.toString(16);e.exports.toHex=function(e){for(var n=new Uint8Array(e),r=Array(e.byteLength),o=0;o<r.length;o++)r[o]=t[n[o]];return r.join("")},e.exports.ceilHeapSize=function(e){var t=0;if(65536>=e)return 65536;if(16777216>e)for(t=1;t<e;t<<=1);else for(t=16777216;t<e;t+=16777216);return t},e.exports.isDedicatedWorkerScope=function(e){var t="WorkerGlobalScope"in e&&e instanceof e.WorkerGlobalScope,n="SharedWorkerGlobalScope"in e&&e instanceof e.SharedWorkerGlobalScope,r="ServiceWorkerGlobalScope"in e&&e instanceof e.ServiceWorkerGlobalScope;return t&&!n&&!r}},function(e,t,n){e.exports=function(){var e=n(0),t=function(e,t,n){try{return n(null,e.digest(t))}catch(t){return n(t)}},r=function(e,t,n,o,i){var a=new self.FileReader;a.onloadend=function(){if(a.error)return i(a.error);var d=a.result;t+=a.result.byteLength;try{e.append(d)}catch(t){return void i(t)}t<o.size?r(e,t,n,o,i):i(null,e.end())},a.readAsArrayBuffer(o.slice(t,t+n))},o=!0;return self.onmessage=function(n){if(o){var i=n.data.data,a=n.data.file,d=n.data.id;if("undefined"!=typeof d&&(a||i)){var s=n.data.blockSize||4194304,l=new e(s);l.resetState();var c=function(e,t){e?self.postMessage({id:d,error:e.name}):self.postMessage({id:d,hash:t})};i&&t(l,i,c),a&&r(l,0,s,a,c)}}},function(){o=!1}}},function(e,t,n){var r=n(4),o=n(0),i=n(7),a=n(2),d=n(1),s=d.isDedicatedWorkerScope,l="undefined"!=typeof self&&s(self);o.disableWorkerBehaviour=l?a():function(){},o.createWorker=function(){var e=r(2),t=e.terminate;return e.terminate=function(){URL.revokeObjectURL(e.objectURL),t.call(e)},e},o.createHash=i,e.exports=o},function(e,t,n){function r(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},t.n=function(e){var n=e&&e.__esModule?function(){return e["default"]}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t.oe=function(e){throw console.error(e),e};var r=t(t.s=ENTRY_MODULE);return r.default||r}function o(e){return(e+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function i(e,t,r){var i={};i[r]=[];var a=t.toString(),d=a.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!d)return i;for(var s=d[1],l=new RegExp("(\\\\n|\\W)"+o(s)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g"),c;c=l.exec(a);)"dll-reference"!==c[3]&&i[r].push(c[3]);for(l=new RegExp("\\("+o(s)+"\\(\"(dll-reference\\s([\\.|\\-|\\+|\\w|/|@]+))\"\\)\\)\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");c=l.exec(a);)e[c[2]]||(i[r].push(c[1]),e[c[2]]=n(c[1]).m),i[c[2]]=i[c[2]]||[],i[c[2]].push(c[4]);return i}function a(e){var t=Object.keys(e);return t.reduce(function(t,n){return t||0<e[n].length},!1)}function d(e,t){for(var n={main:[t]},r={main:[]},o={main:{}};a(n);)for(var d=Object.keys(n),s=0;s<d.length;s++){var l=d[s],c=n[l],u=c.pop();if(o[l]=o[l]||{},!o[l][u]&&e[l][u]){o[l][u]=!0,r[l]=r[l]||[],r[l].push(u);for(var f=i(e,e[l][u],l),p=Object.keys(f),h=0;h<p.length;h++)n[p[h]]=n[p[h]]||[],n[p[h]]=n[p[h]].concat(f[p[h]])}}return r}e.exports=function(e,t){t=t||{};var o={main:n.m},i=t.all?{main:Object.keys(o)}:d(o,e),a="";Object.keys(i).filter(function(e){return"main"!==e}).forEach(function(e){for(var t=0;i[e][t];)t++;i[e].push(t),o[e][t]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+e+" = ("+r.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+i[e].map(function(t){return""+JSON.stringify(t)+": "+o[e][t].toString()}).join(",")+"});\n"}),a=a+"("+r.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+i.main.map(function(e){return""+JSON.stringify(e)+": "+o.main[e].toString()}).join(",")+"})(self);";var s=new window.Blob([a],{type:"text/javascript"});if(t.bare)return s;var l=window.URL||window.webkitURL||window.mozURL||window.msURL,c=l.createObjectURL(s),u=new window.Worker(c);return u.objectURL=c,u}},function(e){e.exports=function(e,t,n){'use asm';var r=new e.Int32Array(n);return{hash:function(e,t){e|=0,t|=0;var n=0,o=0,i=0,a=0,d=0,s=0,l=0,c=0,u=0,f=0,p=0,h=0,m=0,g=0;for(i=0|r[t+320>>2],d=0|r[t+324>>2],l=0|r[t+328>>2],u=0|r[t+332>>2],p=0|r[t+336>>2],n=0;(0|n)<(0|e);n=0|n+64){for(a=i,s=d,c=l,f=u,h=p,o=0;64>(0|o);o=0|o+4)g=0|r[n+o>>2],m=0|(0|(i<<5|i>>>27)+(d&l|~d&u))+(0|(0|g+p)+1518500249),p=u,u=l,l=d<<30|d>>>2,d=i,i=m,r[e+o>>2]=g;for(o=0|e+64;(0|o)<(0|e+80);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(i<<5|i>>>27)+(d&l|~d&u))+(0|(0|g+p)+1518500249),p=u,u=l,l=d<<30|d>>>2,d=i,i=m,r[o>>2]=g;for(o=0|e+80;(0|o)<(0|e+160);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(i<<5|i>>>27)+(d^l^u))+(0|(0|g+p)+1859775393),p=u,u=l,l=d<<30|d>>>2,d=i,i=m,r[o>>2]=g;for(o=0|e+160;(0|o)<(0|e+240);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(i<<5|i>>>27)+(d&l|d&u|l&u))+(0|(0|g+p)-1894007588),p=u,u=l,l=d<<30|d>>>2,d=i,i=m,r[o>>2]=g;for(o=0|e+240;(0|o)<(0|e+320);o=0|o+4)g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31,m=0|(0|(i<<5|i>>>27)+(d^l^u))+(0|(0|g+p)-899497514),p=u,u=l,l=d<<30|d>>>2,d=i,i=m,r[o>>2]=g;i=0|i+a,d=0|d+s,l=0|l+c,u=0|u+f,p=0|p+h}r[t+320>>2]=i,r[t+324>>2]=d,r[t+328>>2]=l,r[t+332>>2]=u,r[t+336>>2]=p}}}},function(e){var t=this,n=void 0;"undefined"!=typeof self&&"undefined"!=typeof self.FileReaderSync&&(n=new self.FileReaderSync);var r=function(e,t,n,r,o,a){var d=a%4,s=(o+d)%4,l=o-s,c;switch(d){case 0:t[a]=e.charCodeAt(r+3);case 1:t[0|a+1-(d<<1)]=e.charCodeAt(r+2);case 2:t[0|a+2-(d<<1)]=e.charCodeAt(r+1);case 3:t[0|a+3-(d<<1)]=e.charCodeAt(r);}if(!(o<s+(4-d))){for(c=4-d;c<l;c=0|c+4)n[a+c>>2]=e.charCodeAt(r+c)<<24|e.charCodeAt(r+c+1)<<16|e.charCodeAt(r+c+2)<<8|e.charCodeAt(r+c+3);switch(s){case 3:t[0|a+l+1]=e.charCodeAt(r+l+2);case 2:t[0|a+l+2]=e.charCodeAt(r+l+1);case 1:t[0|a+l+3]=e.charCodeAt(r+l);}}},o=function(e,t,n,r,o,a){var d=a%4,s=(o+d)%4,l=o-s,c;switch(d){case 0:t[a]=e[r+3];case 1:t[0|a+1-(d<<1)]=e[r+2];case 2:t[0|a+2-(d<<1)]=e[r+1];case 3:t[0|a+3-(d<<1)]=e[r];}if(!(o<s+(4-d))){for(c=4-d;c<l;c=0|c+4)n[0|a+c>>2]=e[r+c]<<24|e[r+c+1]<<16|e[r+c+2]<<8|e[r+c+3];switch(s){case 3:t[0|a+l+1]=e[r+l+2];case 2:t[0|a+l+2]=e[r+l+1];case 1:t[0|a+l+3]=e[r+l];}}},i=function(e,t,r,o,a,d){var s=void 0,l=d%4,c=(a+l)%4,u=a-c,f=new Uint8Array(n.readAsArrayBuffer(e.slice(o,o+a)));switch(l){case 0:t[d]=f[3];case 1:t[0|d+1-(l<<1)]=f[2];case 2:t[0|d+2-(l<<1)]=f[1];case 3:t[0|d+3-(l<<1)]=f[0];}if(!(a<c+(4-l))){for(s=4-l;s<u;s=0|s+4)r[0|d+s>>2]=f[s]<<24|f[s+1]<<16|f[s+2]<<8|f[s+3];switch(c){case 3:t[0|d+u+1]=f[u+2];case 2:t[0|d+u+2]=f[u+1];case 1:t[0|d+u+3]=f[u];}}};e.exports=function(e,n,a,d,s,l){if("string"==typeof e)return r(e,n,a,d,s,l);if(e instanceof Array)return o(e,n,a,d,s,l);if(t&&t.Buffer&&t.Buffer.isBuffer(e))return o(e,n,a,d,s,l);if(e instanceof ArrayBuffer)return o(new Uint8Array(e),n,a,d,s,l);if(e.buffer instanceof ArrayBuffer)return o(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n,a,d,s,l);if(e instanceof Blob)return i(e,n,a,d,s,l);throw new Error("Unsupported data type.")}},function(e,t,n){function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=n(0),i=n(1),a=i.toHex,d=function(){function e(){r(this,e),this._rusha=new o,this._rusha.resetState()}return e.prototype.update=function(e){return this._rusha.append(e),this},e.prototype.digest=function e(t){var e=this._rusha.rawEnd().buffer;if(!t)return e;if("hex"===t)return a(e);throw new Error("unsupported digest encoding")},e}();e.exports=function(){return new d}}])})},{}],96:[function(e,t,n){function r(e,t){for(var n in e)t[n]=e[n]}function o(e,t,n){return a(e,t,n)}var i=e("buffer"),a=i.Buffer;a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?t.exports=i:(r(i,n),n.Buffer=o),o.prototype=Object.create(a.prototype),r(a,o),o.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return a(e,t,n)},o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=a(e);return void 0===t?r.fill(0):"string"==typeof n?r.fill(t,n):r.fill(t),r},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return a(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},{buffer:27}],97:[function(e,t){(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:27}],98:[function(e,t){(function(n){function r(e,t){if(e=Object.assign({maxRedirects:10},"string"==typeof e?{url:e}:e),t=s(t),e.url){const{hostname:t,port:n,protocol:r,auth:o,path:i}=c.parse(e.url);delete e.url,t||n||r||o?Object.assign(e,{hostname:t,port:n,protocol:r,auth:o,path:i}):e.path=i}const o={"accept-encoding":"gzip, deflate"};e.headers&&Object.keys(e.headers).forEach(t=>o[t.toLowerCase()]=e.headers[t]),e.headers=o;let f;e.body?f=e.json&&!u(e.body)?JSON.stringify(e.body):e.body:e.form&&(f="string"==typeof e.form?e.form:l.stringify(e.form),e.headers["content-type"]="application/x-www-form-urlencoded"),f&&(!e.method&&(e.method="POST"),!u(f)&&(e.headers["content-length"]=n.byteLength(f)),e.json&&!e.form&&(e.headers["content-type"]="application/json")),delete e.body,delete e.form,e.json&&(e.headers.accept="application/json"),e.method&&(e.method=e.method.toUpperCase());const p="https:"===e.protocol?d:a,h=p.request(e,n=>{if(300<=n.statusCode&&400>n.statusCode&&n.headers.location)return e.url=n.headers.location,delete e.headers.host,n.resume(),"POST"===e.method&&[301,302].includes(n.statusCode)&&(e.method="GET",delete e.headers["content-length"],delete e.headers["content-type"]),0==e.maxRedirects--?t(new Error("too many redirects")):r(e,t);const o="function"==typeof i&&"HEAD"!==e.method;t(null,o?i(n):n)});return h.on("timeout",()=>{h.abort(),t(new Error("Request timed out"))}),h.on("error",t),u(f)?f.on("error",t).pipe(h):h.end(f),h}t.exports=r;const o=e("simple-concat"),i=e("decompress-response"),a=e("http"),d=e("https"),s=e("once"),l=e("querystring"),c=e("url"),u=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;r.concat=(e,t)=>r(e,(n,r)=>n?t(n):void o(r,(n,o)=>{if(n)return t(n);if(e.json)try{o=JSON.parse(o.toString())}catch(e){return t(e,r,o)}t(null,r,o)})),["get","post","put","patch","head","delete"].forEach(e=>{r[e]=(t,n)=>("string"==typeof t&&(t={url:t}),r(Object.assign({method:e.toUpperCase()},t),n))})}).call(this,e("buffer").Buffer)},{buffer:27,"decompress-response":21,http:103,https:39,once:61,querystring:72,"simple-concat":97,url:134}],99:[function(e,t){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(t._id=c(4).toString("hex").slice(0,7),t._debug("new peer %o",e),e=Object.assign({allowHalfOpen:!1},e),u.Duplex.call(t,e),t.channelName=e.initiator?e.channelName||c(20).toString("hex"):null,t.initiator=e.initiator||!1,t.channelConfig=e.channelConfig||r.channelConfig,t.config=Object.assign({},r.config,e.config),t.offerOptions=e.offerOptions||{},t.answerOptions=e.answerOptions||{},t.sdpTransform=e.sdpTransform||function(e){return e},t.streams=e.streams||(e.stream?[e.stream]:[]),t.trickle=void 0===e.trickle||e.trickle,t.allowHalfTrickle=void 0!==e.allowHalfTrickle&&e.allowHalfTrickle,t.iceCompleteTimeout=e.iceCompleteTimeout||5000,t.destroyed=!1,t._connected=!1,t.remoteAddress=void 0,t.remoteFamily=void 0,t.remotePort=void 0,t.localAddress=void 0,t.localFamily=void 0,t.localPort=void 0,t._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:s(),!t._wrtc)if("undefined"==typeof window)throw i("No WebRTC support: Specify `opts.wrtc` option in this environment","ERR_WEBRTC_SUPPORT");else throw i("No WebRTC support: Not a supported browser","ERR_WEBRTC_SUPPORT");t._pcReady=!1,t._channelReady=!1,t._iceComplete=!1,t._iceCompleteTimer=null,t._channel=null,t._pendingCandidates=[],t._isNegotiating=!t.initiator,t._batchedNegotiation=!1,t._queuedNegotiation=!1,t._sendersAwaitingStable=[],t._senderMap=new Map,t._firstStable=!0,t._closingInterval=null,t._remoteTracks=[],t._remoteStreams=[],t._chunk=null,t._cb=null,t._interval=null;try{t._pc=new t._wrtc.RTCPeerConnection(t.config)}catch(e){return void setTimeout(()=>t.destroy(e),0)}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?t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)}):t._pc.ondatachannel=function(e){t._setupData(e)},t.streams&&t.streams.forEach(function(e){t.addStream(e)}),t._pc.ontrack=function(e){t._onTrack(e)},t.initiator&&t._needsNegotiation(),t._onFinishBound=function(){t._onFinish()},t.once("finish",t._onFinishBound)}function o(e){return e.replace(/a=ice-options:trickle\s\n/g,"")}function i(e,t){var n=new Error(e);return n.code=t,n}function a(e){console.warn(e)}t.exports=r;var d=e("debug")("simple-peer"),s=e("get-browser-rtc"),l=e("inherits"),c=e("randombytes"),u=e("readable-stream"),f=65536;l(r,u.Duplex),r.WEBRTC_SUPPORT=!!s(),r.config={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:global.stun.twilio.com:3478?transport=udp"}],sdpSemantics:"unified-plan"},r.channelConfig={},Object.defineProperty(r.prototype,"bufferSize",{get:function(){var e=this;return e._channel&&e._channel.bufferedAmount||0}}),Object.defineProperty(r.prototype,"connected",{get:function(){var e=this;return e._connected&&"open"===e._channel.readyState}}),r.prototype.address=function(){var e=this;return{port:e.localPort,family:e.localFamily,address:e.localAddress}},r.prototype.signal=function(e){var t=this;if(t.destroyed)throw i("cannot signal after peer is destroyed","ERR_SIGNALING");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}t._debug("signal()"),e.renegotiate&&t.initiator&&(t._debug("got request to renegotiate"),t._needsNegotiation()),e.transceiverRequest&&t.initiator&&(t._debug("got request for transceiver"),t.addTransceiver(e.transceiverRequest.kind,e.transceiverRequest.init)),e.candidate&&(t._pc.localDescription&&t._pc.localDescription.type&&t._pc.remoteDescription&&t._pc.remoteDescription.type?t._addIceCandidate(e.candidate):t._pendingCandidates.push(e.candidate)),e.sdp&&t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e)).then(function(){t.destroyed||(t._pendingCandidates.forEach(function(e){t._addIceCandidate(e)}),t._pendingCandidates=[],"offer"===t._pc.remoteDescription.type&&t._createAnswer())}).catch(function(e){t.destroy(i(e,"ERR_SET_REMOTE_DESCRIPTION"))}),e.sdp||e.candidate||e.renegotiate||e.transceiverRequest||t.destroy(i("signal() called with invalid signal data","ERR_SIGNALING"))},r.prototype._addIceCandidate=function(e){var t=this,n=new t._wrtc.RTCIceCandidate(e);t._pc.addIceCandidate(n).catch(function(e){!n.address||n.address.endsWith(".local")?a("Ignoring unsupported ICE candidate."):t.destroy(i(e,"ERR_ADD_ICE_CANDIDATE"))})},r.prototype.send=function(e){var t=this;t._channel.send(e)},r.prototype.addTransceiver=function(e,t){var n=this;if(n._debug("addTransceiver()"),n.initiator)try{n._pc.addTransceiver(e,t),n._needsNegotiation()}catch(e){n.destroy(e)}else n.emit("signal",{transceiverRequest:{kind:e,init:t}})},r.prototype.addStream=function(e){var t=this;t._debug("addStream()"),e.getTracks().forEach(function(n){t.addTrack(n,e)})},r.prototype.addTrack=function(e,t){var n=this;n._debug("addTrack()");var r=n._senderMap.get(e)||new Map,o=r.get(t);o?o.removed?n.destroy(i("Track has been removed. You should enable/disable tracks that you want to re-add.","ERR_SENDER_REMOVED")):n.destroy(i("Track has already been added to that stream.","ERR_SENDER_ALREADY_ADDED")):(o=n._pc.addTrack(e,t),r.set(t,o),n._senderMap.set(e,r),n._needsNegotiation())},r.prototype.replaceTrack=function(e,t,n){var r=this;r._debug("replaceTrack()");var o=r._senderMap.get(e),a=o?o.get(n):null;a||r.destroy(i("Cannot replace track that was never added.","ERR_TRACK_NOT_ADDED")),t&&r._senderMap.set(t,o),null==a.replaceTrack?r.destroy(i("replaceTrack is not supported in this browser","ERR_UNSUPPORTED_REPLACETRACK")):a.replaceTrack(t)},r.prototype.removeTrack=function(e,t){var n=this;n._debug("removeSender()");var r=n._senderMap.get(e),o=r?r.get(t):null;o||n.destroy(i("Cannot remove track that was never added.","ERR_TRACK_NOT_ADDED"));try{o.removed=!0,n._pc.removeTrack(o)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?n._sendersAwaitingStable.push(o):n.destroy(e)}n._needsNegotiation()},r.prototype.removeStream=function(e){var t=this;t._debug("removeSenders()"),e.getTracks().forEach(function(n){t.removeTrack(n,e)})},r.prototype._needsNegotiation=function(){var e=this;e._debug("_needsNegotiation");e._batchedNegotiation||(e._batchedNegotiation=!0,setTimeout(function(){e._batchedNegotiation=!1,e._debug("starting batched negotiation"),e.negotiate()},0))},r.prototype.negotiate=function(){var e=this;e.initiator?e._isNegotiating?(e._queuedNegotiation=!0,e._debug("already negotiating, queueing")):(e._debug("start negotiation"),setTimeout(()=>{e._createOffer()},0)):!e._isNegotiating&&(e._debug("requesting negotiation from initiator"),e.emit("signal",{renegotiate:!0})),e._isNegotiating=!0},r.prototype.destroy=function(e){var t=this;t._destroy(e,function(){})},r.prototype._destroy=function(e,t){var n=this;if(!n.destroyed){if(n._debug("destroy (error: %s)",e&&(e.message||e)),n.readable=n.writable=!1,n._readableState.ended||n.push(null),n._writableState.finished||n.end(),n.destroyed=!0,n._connected=!1,n._pcReady=!1,n._channelReady=!1,n._remoteTracks=null,n._remoteStreams=null,n._senderMap=null,clearInterval(n._closingInterval),n._closingInterval=null,clearInterval(n._interval),n._interval=null,n._chunk=null,n._cb=null,n._onFinishBound&&n.removeListener("finish",n._onFinishBound),n._onFinishBound=null,n._channel){try{n._channel.close()}catch(e){}n._channel.onmessage=null,n._channel.onopen=null,n._channel.onclose=null,n._channel.onerror=null}if(n._pc){try{n._pc.close()}catch(e){}n._pc.oniceconnectionstatechange=null,n._pc.onicegatheringstatechange=null,n._pc.onsignalingstatechange=null,n._pc.onicecandidate=null,n._pc.ontrack=null,n._pc.ondatachannel=null}n._pc=null,n._channel=null,e&&n.emit("error",e),n.emit("close"),t()}},r.prototype._setupData=function(e){var t=this;if(!e.channel)return t.destroy(i("Data channel event is missing `channel` property","ERR_DATA_CHANNEL"));t._channel=e.channel,t._channel.binaryType="arraybuffer","number"==typeof t._channel.bufferedAmountLowThreshold&&(t._channel.bufferedAmountLowThreshold=f),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(i(e,"ERR_DATA_CHANNEL"))};var n=!1;t._closingInterval=setInterval(function(){t._channel&&"closing"===t._channel.readyState?(n&&t._onChannelClose(),n=!0):n=!1},5000)},r.prototype._read=function(){},r.prototype._write=function(e,t,n){var r=this;if(r.destroyed)return n(i("cannot write after peer is destroyed","ERR_DATA_CHANNEL"));if(r._connected){try{r.send(e)}catch(e){return r.destroy(i(e,"ERR_DATA_CHANNEL"))}r._channel.bufferedAmount>f?(r._debug("start backpressure: bufferedAmount %d",r._channel.bufferedAmount),r._cb=n):n(null)}else r._debug("write before connect"),r._chunk=e,r._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._startIceCompleteTimeout=function(){var e=this;e.destroyed||e._iceCompleteTimer||(e._debug("started iceComplete timeout"),e._iceCompleteTimer=setTimeout(function(){e._iceComplete||(e._iceComplete=!0,e._debug("iceComplete timeout completed"),e.emit("iceTimeout"),e.emit("_iceComplete"))},e.iceCompleteTimeout))},r.prototype._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(e.offerOptions).then(function(t){function n(){if(!e.destroyed){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}}e.destroyed||(!e.trickle&&!e.allowHalfTrickle&&(t.sdp=o(t.sdp)),t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t).then(function(){e._debug("createOffer success");e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))}).catch(function(t){e.destroy(i(t,"ERR_SET_LOCAL_DESCRIPTION"))}))}).catch(function(t){e.destroy(i(t,"ERR_CREATE_OFFER"))})},r.prototype._requestMissingTransceivers=function(){var e=this;e._pc.getTransceivers&&e._pc.getTransceivers().forEach(t=>{t.mid||!t.sender.track||t.requested||(t.requested=!0,e.addTransceiver(t.sender.track.kind))})},r.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(e.answerOptions).then(function(t){function n(){if(!e.destroyed){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp}),e.initiator||e._requestMissingTransceivers()}}e.destroyed||(!e.trickle&&!e.allowHalfTrickle&&(t.sdp=o(t.sdp)),t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t).then(function(){e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))}).catch(function(t){e.destroy(i(t,"ERR_SET_LOCAL_DESCRIPTION"))}))}).catch(function(t){e.destroy(i(t,"ERR_CREATE_ANSWER"))})},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)&&(e._pcReady=!0,e._maybeReady()),"failed"===t&&e.destroy(i("Ice connection failed.","ERR_ICE_CONNECTION_FAILURE")),"closed"===t&&e.destroy(i("Ice connection closed.","ERR_ICE_CONNECTION_CLOSED"))}},r.prototype.getStats=function(e){function t(e){return"[object Array]"===Object.prototype.toString.call(e.values)&&e.values.forEach(function(t){Object.assign(e,t)}),e}var n=this;0===n._pc.getStats.length?n._pc.getStats().then(function(n){var r=[];n.forEach(function(e){r.push(t(e))}),e(null,r)},function(t){e(t)}):n._isReactNativeWebrtc?n._pc.getStats(null,function(n){var r=[];n.forEach(function(e){r.push(t(e))}),e(null,r)},function(t){e(t)}):0<n._pc.getStats.length?n._pc.getStats(function(r){if(!n.destroyed){var o=[];r.result().forEach(function(e){var n={};e.names().forEach(function(t){n[t]=e.stat(t)}),n.id=e.id,n.type=e.type,n.timestamp=e.timestamp,o.push(t(n))}),e(null,o)}},function(t){e(t)}):e(null,[])},r.prototype._maybeReady=function(){function e(){t.destroyed||t.getStats(function(n,r){function o(e){l=!0;var n=d[e.localCandidateId];n&&(n.ip||n.address)?(t.localAddress=n.ip||n.address,t.localPort=+n.port):n&&n.ipAddress?(t.localAddress=n.ipAddress,t.localPort=+n.portNumber):"string"==typeof e.googLocalAddress&&(n=e.googLocalAddress.split(":"),t.localAddress=n[0],t.localPort=+n[1]),t.localAddress&&(t.localFamily=t.localAddress.includes(":")?"IPv6":"IPv4");var r=a[e.remoteCandidateId];r&&(r.ip||r.address)?(t.remoteAddress=r.ip||r.address,t.remotePort=+r.port):r&&r.ipAddress?(t.remoteAddress=r.ipAddress,t.remotePort=+r.portNumber):"string"==typeof e.googRemoteAddress&&(r=e.googRemoteAddress.split(":"),t.remoteAddress=r[0],t.remotePort=+r[1]),t.remoteAddress&&(t.remoteFamily=t.remoteAddress.includes(":")?"IPv6":"IPv4"),t._debug("connect local: %s:%s remote: %s:%s",t.localAddress,t.localPort,t.remoteAddress,t.remotePort)}if(!t.destroyed){n&&(r=[]);var a={},d={},s={},l=!1;if(r.forEach(function(e){("remotecandidate"===e.type||"remote-candidate"===e.type)&&(a[e.id]=e),("localcandidate"===e.type||"local-candidate"===e.type)&&(d[e.id]=e),("candidatepair"===e.type||"candidate-pair"===e.type)&&(s[e.id]=e)}),r.forEach(function(e){"transport"===e.type&&e.selectedCandidatePairId&&o(s[e.selectedCandidatePairId]),("googCandidatePair"===e.type&&"true"===e.googActiveConnection||("candidatepair"===e.type||"candidate-pair"===e.type)&&e.selected)&&o(e)}),!l&&(!Object.keys(s).length||Object.keys(d).length))return void setTimeout(e,100);if(t._connecting=!1,t._connected=!0,t._chunk){try{t.send(t._chunk)}catch(e){return t.destroy(i(e,"ERR_DATA_CHANNEL"))}t._chunk=null,t._debug("sent chunk from \"write before connect\"");var c=t._cb;t._cb=null,c(null)}"number"!=typeof t._channel.bufferedAmountLowThreshold&&(t._interval=setInterval(function(){t._onInterval()},150),t._interval.unref&&t._interval.unref()),t._debug("connect"),t.emit("connect")}})}var t=this;t._debug("maybeReady pc %s channel %s",t._pcReady,t._channelReady);t._connected||t._connecting||!t._pcReady||!t._channelReady||(t._connecting=!0,e())},r.prototype._onInterval=function(){var e=this;e._cb&&e._channel&&!(e._channel.bufferedAmount>f)&&e._onChannelBufferedAmountLow()},r.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||("stable"===e._pc.signalingState&&!e._firstStable&&(e._isNegotiating=!1,e._debug("flushing sender queue",e._sendersAwaitingStable),e._sendersAwaitingStable.forEach(function(t){e._pc.removeTrack(t),e._queuedNegotiation=!0}),e._sendersAwaitingStable=[],e._queuedNegotiation&&(e._debug("flushing negotiation queue"),e._queuedNegotiation=!1,e._needsNegotiation()),e._debug("negotiate"),e.emit("negotiate")),e._firstStable=!1,e._debug("signalingStateChange %s",e._pc.signalingState),e.emit("signalingStateChange",e._pc.signalingState))},r.prototype._onIceCandidate=function(e){var t=this;t.destroyed||(e.candidate&&t.trickle?t.emit("signal",{candidate:{candidate:e.candidate.candidate,sdpMLineIndex:e.candidate.sdpMLineIndex,sdpMid:e.candidate.sdpMid}}):!e.candidate&&!t._iceComplete&&(t._iceComplete=!0,t.emit("_iceComplete")),e.candidate&&t._startIceCompleteTimeout())},r.prototype._onChannelMessage=function(e){var t=this;if(!t.destroyed){var r=e.data;r instanceof ArrayBuffer&&(r=n.from(r)),t.push(r)}},r.prototype._onChannelBufferedAmountLow=function(){var e=this;if(!e.destroyed&&e._cb){e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);var t=e._cb;e._cb=null,t(null)}},r.prototype._onChannelOpen=function(){var e=this;e._connected||e.destroyed||(e._debug("on channel open"),e._channelReady=!0,e._maybeReady())},r.prototype._onChannelClose=function(){var e=this;e.destroyed||(e._debug("on channel close"),e.destroy())},r.prototype._onTrack=function(e){var t=this;t.destroyed||e.streams.forEach(function(n){t._debug("on track"),t.emit("track",e.track,n),t._remoteTracks.push({track:e.track,stream:n});t._remoteStreams.some(function(e){return e.id===n.id})||(t._remoteStreams.push(n),setTimeout(function(){t.emit("stream",n)},0))})},r.prototype._debug=function(){var e=this,t=[].slice.call(arguments);t[0]="["+e._id+"] "+t[0],d.apply(null,t)}}).call(this,e("buffer").Buffer)},{buffer:27,debug:33,"get-browser-rtc":38,inherits:42,randombytes:74,"readable-stream":90}],100:[function(e,t){function n(e){return d.digest(e)}function r(e,t){return c?void("string"==typeof e&&(e=o(e)),c.digest({name:"sha-1"},e).then(function(e){t(i(new Uint8Array(e)))},function(){t(n(e))})):void setTimeout(t,0,n(e))}function o(e){for(var t=e.length,n=new Uint8Array(t),r=0;r<t;r++)n[r]=e.charCodeAt(r);return n}function i(e){for(var t=e.length,n=[],r=0,o;r<t;r++)o=e[r],n.push((o>>>4).toString(16)),n.push((15&o).toString(16));return n.join("")}var a=e("rusha"),d=new a,s="undefined"==typeof window?self:window,l=s.crypto||s.msCrypto||{},c=l.subtle||l.webkitSubtle;try{c.digest({name:"sha-1"},new Uint8Array).catch(function(){c=!1})}catch(e){c=!1}t.exports=r,t.exports.sync=n},{rusha:95}],101:[function(e,t){(function(n,r){const o=e("debug")("simple-websocket"),i=e("randombytes"),a=e("readable-stream"),d=e("ws"),s="function"==typeof d?d:WebSocket,l=65536;class c extends a.Duplex{constructor(e={}){if("string"==typeof e&&(e={url:e}),e=Object.assign({allowHalfOpen:!1},e),super(e),null==e.url&&null==e.socket)throw new Error("Missing required `url` or `socket` option");if(null!=e.url&&null!=e.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(this._id=i(4).toString("hex").slice(0,7),this._debug("new websocket: %o",e),this.connected=!1,this.destroyed=!1,this._chunk=null,this._cb=null,this._interval=null,e.socket)this.url=e.socket.url,this._ws=e.socket;else{this.url=e.url;try{this._ws="function"==typeof d?new s(e.url,e):new s(e.url)}catch(e){return void n.nextTick(()=>this.destroy(e))}}this._ws.binaryType="arraybuffer",this._ws.onopen=()=>{this._onOpen()},this._ws.onmessage=e=>{this._onMessage(e)},this._ws.onclose=()=>{this._onClose()},this._ws.onerror=()=>{this.destroy(new Error("connection error to "+this.url))},this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}send(e){this._ws.send(e)}destroy(e){this._destroy(e,()=>{})}_destroy(e,t){if(!this.destroyed){if(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){const e=this._ws,t=()=>{e.onclose=null};if(e.readyState===s.CLOSED)t();else try{e.onclose=t,e.close()}catch(e){t()}e.onopen=null,e.onmessage=null,e.onerror=()=>{}}if(this._ws=null,e){if("undefined"!=typeof DOMException&&e instanceof DOMException){const t=e.code;e=new Error(e.message),e.code=t}this.emit("error",e)}this.emit("close"),t()}}_read(){}_write(e,t,n){if(this.destroyed)return n(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(e)}catch(e){return this.destroy(e)}"function"!=typeof d&&this._ws.bufferedAmount>l?(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}_onFinish(){if(!this.destroyed){const e=()=>{setTimeout(()=>this.destroy(),1e3)};this.connected?e():this.once("connect",e)}}_onMessage(e){if(this.destroyed)return;let t=e.data;t instanceof ArrayBuffer&&(t=r.from(t)),this.push(t)}_onOpen(){if(!(this.connected||this.destroyed)){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(e){return this.destroy(e)}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const e=this._cb;this._cb=null,e(null)}"function"!=typeof d&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")}}_onInterval(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>l)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);const e=this._cb;this._cb=null,e(null)}}_onClose(){this.destroyed||(this._debug("on close"),this.destroy())}_debug(){const e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],o.apply(null,e)}}c.WEBSOCKET_SUPPORT=!!s,t.exports=c}).call(this,e("_process"),e("buffer").Buffer)},{_process:67,buffer:27,debug:33,randombytes:74,"readable-stream":90,ws:21}],102:[function(e,t){var n=1,r=65535,o=4,i=function(){n=n+1&r},a;t.exports=function(e){a||(a=setInterval(i,0|1e3/o),a.unref&&a.unref());var t=o*(e||5),d=[0],s=1,l=n-1&r;return function(e){var i=n-l&r;for(i>t&&(i=t),l=n;i--;)s===t&&(s=0),d[s]=d[0===s?t-1:s-1],s++;e&&(d[s-1]+=e);var a=d[s-1],c=d.length<t?0:d[s===t?0:s];return d.length<o?a:(a-c)*o/d.length}}},{}],103:[function(e,t,n){(function(t){var r=e("./lib/request"),o=e("./lib/response"),i=e("xtend"),a=e("builtin-status-codes"),d=e("url"),s=n;s.request=function(e,n){e="string"==typeof e?d.parse(e):i(e);var o=-1===t.location.protocol.search(/^https?:$/)?"http:":"",a=e.protocol||o,s=e.hostname||e.host,l=e.port,c=e.path||"/";s&&-1!==s.indexOf(":")&&(s="["+s+"]"),e.url=(s?a+"//"+s:"")+(l?":"+l:"")+c,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var u=new r(e);return n&&u.on("response",n),u},s.get=function(e,t){var n=s.request(e,t);return n.end(),n},s.ClientRequest=r,s.IncomingMessage=o.IncomingMessage,s.Agent=function(){},s.Agent.defaultMaxSockets=4,s.globalAgent=new s.Agent,s.STATUS_CODES=a,s.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,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./lib/request":105,"./lib/response":106,"builtin-status-codes":28,url:134,xtend:141}],104:[function(e,t,n){(function(e){function t(){if(d!==void 0)return d;if(e.XMLHttpRequest){d=new e.XMLHttpRequest;try{d.open("GET",e.XDomainRequest?"/":"https://example.com")}catch(t){d=null}}else d=null;return d}function r(e){var n=t();if(!n)return!1;try{return n.responseType=e,n.responseType===e}catch(t){}return!1}function o(e){return"function"==typeof e}n.fetch=o(e.fetch)&&o(e.ReadableStream),n.writableStream=o(e.WritableStream),n.abortController=o(e.AbortController),n.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),n.blobConstructor=!0}catch(t){}var i="undefined"!=typeof e.ArrayBuffer,a=i&&o(e.ArrayBuffer.prototype.slice),d;n.arraybuffer=n.fetch||i&&r("arraybuffer"),n.msstream=!n.fetch&&a&&r("ms-stream"),n.mozchunkedarraybuffer=!n.fetch&&i&&r("moz-chunked-arraybuffer"),n.overrideMimeType=n.fetch||!!t()&&o(t().overrideMimeType),n.vbArray=o(e.VBArray),d=null}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],105:[function(e,t){(function(n,r,o){function i(e,t){return d.fetch&&t?"fetch":d.mozchunkedarraybuffer?"moz-chunked-arraybuffer":d.msstream?"ms-stream":d.arraybuffer&&e?"arraybuffer":d.vbArray&&e?"text:vbarray":"text"}function a(e){try{var t=e.status;return null!==t&&0!==t}catch(t){return!1}}var d=e("./capability"),s=e("inherits"),l=e("./response"),c=e("readable-stream"),u=e("to-arraybuffer"),f=l.IncomingMessage,p=l.readyStates,h=t.exports=function(e){var t=this;c.Writable.call(t),t._opts=e,t._body=[],t._headers={},e.auth&&t.setHeader("Authorization","Basic "+new o(e.auth).toString("base64")),Object.keys(e.headers).forEach(function(n){t.setHeader(n,e.headers[n])});var n=!0,r;if("disable-fetch"===e.mode||"requestTimeout"in e&&!d.abortController)n=!1,r=!0;else if("prefer-streaming"===e.mode)r=!1;else if("allow-wrong-content-type"===e.mode)r=!d.overrideMimeType;else if(!e.mode||"default"===e.mode||"prefer-fast"===e.mode)r=!0;else throw new Error("Invalid value for opts.mode");t._mode=i(r,n),t._fetchTimer=null,t.on("finish",function(){t._onFinish()})};s(h,c.Writable),h.prototype.setHeader=function(e,t){var n=this,r=e.toLowerCase();-1!==m.indexOf(r)||(n._headers[r]={name:e,value:t})},h.prototype.getHeader=function(e){var t=this._headers[e.toLowerCase()];return t?t.value:null},h.prototype.removeHeader=function(e){var t=this;delete t._headers[e.toLowerCase()]},h.prototype._onFinish=function(){var e=this;if(!e._destroyed){var t=e._opts,i=e._headers,a=null;"GET"!==t.method&&"HEAD"!==t.method&&(d.arraybuffer?a=u(o.concat(e._body)):d.blobConstructor?a=new r.Blob(e._body.map(function(e){return u(e)}),{type:(i["content-type"]||{}).value||""}):a=o.concat(e._body).toString());var s=[];if(Object.keys(i).forEach(function(e){var t=i[e].name,n=i[e].value;Array.isArray(n)?n.forEach(function(e){s.push([t,e])}):s.push([t,n])}),"fetch"===e._mode){var l=null;if(d.abortController){var c=new AbortController;l=c.signal,e._fetchAbortController=c,"requestTimeout"in t&&0!==t.requestTimeout&&(e._fetchTimer=r.setTimeout(function(){e.emit("requestTimeout"),e._fetchAbortController&&e._fetchAbortController.abort()},t.requestTimeout))}r.fetch(e._opts.url,{method:e._opts.method,headers:s,body:a||void 0,mode:"cors",credentials:t.withCredentials?"include":"same-origin",signal:l}).then(function(t){e._fetchResponse=t,e._connect()},function(t){r.clearTimeout(e._fetchTimer),e._destroyed||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"),"requestTimeout"in t&&(f.timeout=t.requestTimeout,f.ontimeout=function(){e.emit("requestTimeout")}),s.forEach(function(e){f.setRequestHeader(e[0],e[1])}),e._response=null,f.onreadystatechange=function(){switch(f.readyState){case p.LOADING:case p.DONE:e._onXHRProgress();}},"moz-chunked-arraybuffer"===e._mode&&(f.onprogress=function(){e._onXHRProgress()}),f.onerror=function(){e._destroyed||e.emit("error",new Error("XHR error"))};try{f.send(a)}catch(t){return void n.nextTick(function(){e.emit("error",t)})}}}},h.prototype._onXHRProgress=function(){var e=this;!a(e._xhr)||e._destroyed||(!e._response&&e._connect(),e._response._onXHRProgress())},h.prototype._connect=function(){var e=this;e._destroyed||(e._response=new f(e._xhr,e._fetchResponse,e._mode,e._fetchTimer),e._response.on("error",function(t){e.emit("error",t)}),e.emit("response",e._response))},h.prototype._write=function(e,t,n){var r=this;r._body.push(e),n()},h.prototype.abort=h.prototype.destroy=function(){var e=this;e._destroyed=!0,r.clearTimeout(e._fetchTimer),e._response&&(e._response._destroyed=!0),e._xhr?e._xhr.abort():e._fetchAbortController&&e._fetchAbortController.abort()},h.prototype.end=function(e,t,n){var r=this;"function"==typeof e&&(n=e,e=void 0),c.Writable.prototype.end.call(r,e,t,n)},h.prototype.flushHeaders=function(){},h.prototype.setTimeout=function(){},h.prototype.setNoDelay=function(){},h.prototype.setSocketKeepAlive=function(){};var m=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","via"]}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("buffer").Buffer)},{"./capability":104,"./response":106,_process:67,buffer:27,inherits:42,"readable-stream":115,"to-arraybuffer":127}],106:[function(e,t,n){(function(t,r,o){var i=e("./capability"),a=e("inherits"),d=e("readable-stream"),s=n.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},l=n.IncomingMessage=function(e,n,a,s){var l=this;if(d.Readable.call(l),l._mode=a,l.headers={},l.rawHeaders=[],l.trailers={},l.rawTrailers=[],l.on("end",function(){t.nextTick(function(){l.emit("close")})}),"fetch"===a){function e(){u.read().then(function(t){return l._destroyed?void 0:t.done?(r.clearTimeout(s),void l.push(null)):void(l.push(new o(t.value)),e())}).catch(function(e){r.clearTimeout(s),l._destroyed||l.emit("error",e)})}if(l._fetchResponse=n,l.url=n.url,l.statusCode=n.status,l.statusMessage=n.statusText,n.headers.forEach(function(e,t){l.headers[t.toLowerCase()]=e,l.rawHeaders.push(t,e)}),i.writableStream){var c=new WritableStream({write:function(e){return new Promise(function(t,n){l._destroyed?n():l.push(new o(e))?t():l._resumeFetch=t})},close:function(){r.clearTimeout(s),l._destroyed||l.push(null)},abort:function(e){l._destroyed||l.emit("error",e)}});try{return void n.body.pipeTo(c).catch(function(e){r.clearTimeout(s),l._destroyed||l.emit("error",e)})}catch(t){}}var u=n.body.getReader();e()}else{l._xhr=e,l._pos=0,l.url=e.responseURL,l.statusCode=e.status,l.statusMessage=e.statusText;var f=e.getAllResponseHeaders().split(/\r?\n/);if(f.forEach(function(e){var t=e.match(/^([^:]+):\s*(.*)/);if(t){var n=t[1].toLowerCase();"set-cookie"===n?(void 0===l.headers[n]&&(l.headers[n]=[]),l.headers[n].push(t[2])):void 0===l.headers[n]?l.headers[n]=t[2]:l.headers[n]+=", "+t[2],l.rawHeaders.push(t[1],t[2])}}),l._charset="x-user-defined",!i.overrideMimeType){var p=l.rawHeaders["mime-type"];if(p){var h=p.match(/;\s*charset=([^;])(;|$)/);h&&(l._charset=h[1].toLowerCase())}l._charset||(l._charset="utf-8")}}};a(l,d.Readable),l.prototype._read=function(){var e=this,t=e._resumeFetch;t&&(e._resumeFetch=null,t())},l.prototype._onXHRProgress=function(){var t=this,n=t._xhr,a=null;switch(t._mode){case"text:vbarray":if(n.readyState!==s.DONE)break;try{a=new r.VBArray(n.responseBody).toArray()}catch(t){}if(null!==a){t.push(new o(a));break}case"text":try{a=n.responseText}catch(n){t._mode="text:vbarray";break}if(a.length>t._pos){var d=a.substr(t._pos);if("x-user-defined"===t._charset){for(var l=new o(d.length),c=0;c<d.length;c++)l[c]=255&d.charCodeAt(c);t.push(l)}else t.push(d,t._charset);t._pos=a.length}break;case"arraybuffer":if(n.readyState!==s.DONE||!n.response)break;a=n.response,t.push(new o(new Uint8Array(a)));break;case"moz-chunked-arraybuffer":if(a=n.response,n.readyState!==s.LOADING||!a)break;t.push(new o(new Uint8Array(a)));break;case"ms-stream":if(a=n.response,n.readyState!==s.LOADING)break;var e=new r.MSStreamReader;e.onprogress=function(){e.result.byteLength>t._pos&&(t.push(new o(new Uint8Array(e.result.slice(t._pos)))),t._pos=e.result.byteLength)},e.onload=function(){t.push(null)},e.readAsArrayBuffer(a);}t._xhr.readyState===s.DONE&&"ms-stream"!==t._mode&&t.push(null)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("buffer").Buffer)},{"./capability":104,_process:67,buffer:27,inherits:42,"readable-stream":115}],107:[function(e,t){'use strict';function n(e){return this instanceof n?void(s.call(this,e),l.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",r)):new n(e)}function r(){this.allowHalfOpen||this._writableState.ended||i.nextTick(o,this)}function o(e){e.end()}var i=e("process-nextick-args"),a=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=n;var d=e("core-util-is");d.inherits=e("inherits");var s=e("./_stream_readable"),l=e("./_stream_writable");d.inherits(n,s);for(var c=a(l.prototype),u=0,f;u<c.length;u++)f=c[u],n.prototype[f]||(n.prototype[f]=l.prototype[f]);Object.defineProperty(n.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(n.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0===this._readableState||void 0===this._writableState||(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),n.prototype._destroy=function(e,t){this.push(null),this.end(),i.nextTick(t,e)}},{"./_stream_readable":109,"./_stream_writable":111,"core-util-is":31,inherits:42,"process-nextick-args":66}],108:[function(e,t){'use strict';function n(e){return this instanceof n?void r.call(this,e):new n(e)}t.exports=n;var r=e("./_stream_transform"),o=e("core-util-is");o.inherits=e("inherits"),o.inherits(n,r),n.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":110,"core-util-is":31,inherits:42}],109:[function(e,t){(function(n,o){'use strict';function i(e){return H.from(e)}function a(e){return H.isBuffer(e)||e instanceof j}function d(e,t,n){return"function"==typeof e.prependListener?e.prependListener(t,n):void(e._events&&e._events[t]?P(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n))}function s(t,n){M=M||e("./_stream_duplex"),t=t||{};var o=n instanceof M;this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var i=t.highWaterMark,a=t.readableHighWaterMark,d=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:o&&(a||0===a)?a:d,this.highWaterMark=r(this.highWaterMark),this.buffer=new z,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.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(!G&&(G=e("string_decoder/").StringDecoder),this.decoder=new G(t.encoding),this.encoding=t.encoding)}function l(t){return M=M||e("./_stream_duplex"),this instanceof l?void(this._readableState=new s(t,this),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),q.call(this)):new l(t)}function c(e,t,n,r,o){var a=e._readableState;if(null===t)a.reading=!1,g(e,a);else{var d;o||(d=f(a,t)),d?e.emit("error",d):a.objectMode||t&&0<t.length?("string"!=typeof t&&!a.objectMode&&Object.getPrototypeOf(t)!==H.prototype&&(t=i(t)),r?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):u(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!n?(t=a.decoder.write(t),a.objectMode||0!==t.length?u(e,a,t,!1):y(e,a)):u(e,a,t,!1))):!r&&(a.reading=!1)}return p(a)}function u(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&_(e)),y(e,t)}function f(e,t){var n;return a(t)||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function p(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function h(e){return 8388608<=e?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function m(e,t){return 0>=e||0===t.length&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=h(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}function g(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,_(e)}}function _(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(W("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?U.nextTick(b,e):b(e))}function b(e){W("emit readable"),e.emit("readable"),v(e)}function y(e,t){t.readingMore||(t.readingMore=!0,U.nextTick(w,e,t))}function w(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(W("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function k(e){return function(){var t=e._readableState;W("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&N(e,"data")&&(t.flowing=!0,v(e))}}function x(e){W("readable nexttick read 0"),e.read(0)}function S(e,t){t.resumeScheduled||(t.resumeScheduled=!0,U.nextTick(E,e,t))}function E(e,t){t.reading||(W("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),v(e),t.flowing&&!t.reading&&e.read(0)}function v(e){var t=e._readableState;for(W("flow",t.flowing);t.flowing&&null!==e.read(););}function C(e,t){if(0===t.length)return null;var n;return 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()):n=L(e,t.buffer,t.decoder),n}function L(e,t,n){var r;return e<t.head.data.length?(r=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?r=t.shift():r=n?I(e,t):T(e,t),r}function I(e,t){var r=t.head,o=1,i=r.data;for(e-=i.length;r=r.next;){var a=r.data,d=e>a.length?a.length:e;if(i+=d===a.length?a:a.slice(0,e),e-=d,0===e){d===a.length?(++o,t.head=r.next?r.next:t.tail=null):(t.head=r,r.data=a.slice(d));break}++o}return t.length-=o,i}function T(e,t){var r=H.allocUnsafe(e),o=t.head,i=1;for(o.data.copy(r),e-=o.data.length;o=o.next;){var a=o.data,d=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,d),e-=d,0===e){d===a.length?(++i,t.head=o.next?o.next:t.tail=null):(t.head=o,o.data=a.slice(d));break}++i}return t.length-=i,r}function R(e){var t=e._readableState;if(0<t.length)throw new Error("\"endReadable()\" called on non-empty stream");t.endEmitted||(t.ended=!0,U.nextTick(B,t,e))}function B(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function A(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}var U=e("process-nextick-args");t.exports=l;var P=e("isarray"),M;l.ReadableState=s;var O=e("events").EventEmitter,N=function(e,t){return e.listeners(t).length},q=e("./internal/streams/stream"),H=e("safe-buffer").Buffer,j=o.Uint8Array||function(){},D=e("core-util-is");D.inherits=e("inherits");var F=e("util"),W=void 0;W=F&&F.debuglog?F.debuglog("stream"):function(){};var z=e("./internal/streams/BufferList"),V=e("./internal/streams/destroy"),G;D.inherits(l,q);var K=["error","close","destroy","pause","resume"];Object.defineProperty(l.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),l.prototype.destroy=V.destroy,l.prototype._undestroy=V.undestroy,l.prototype._destroy=function(e,t){this.push(null),t(e)},l.prototype.push=function(e,t){var n=this._readableState,r;return n.objectMode?r=!0:"string"==typeof e&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=H.from(e,t),t=""),r=!0),c(this,e,t,!1,r)},l.prototype.unshift=function(e){return c(this,e,null,!0,!1)},l.prototype.isPaused=function(){return!1===this._readableState.flowing},l.prototype.setEncoding=function(t){return G||(G=e("string_decoder/").StringDecoder),this._readableState.decoder=new G(t),this._readableState.encoding=t,this};l.prototype.read=function(e){W("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return W("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?R(this):_(this),null;if(e=m(e,t),0===e&&t.ended)return 0===t.length&&R(this),null;var o=t.needReadable;W("need readable",o),(0===t.length||t.length-e<t.highWaterMark)&&(o=!0,W("length less than watermark",o)),t.ended||t.reading?(o=!1,W("reading or ended",o)):o&&(W("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,!t.reading&&(e=m(r,t)));var i;return i=0<e?C(e,t):null,null===i?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(!t.ended&&(t.needReadable=!0),r!==e&&t.ended&&R(this)),null!==i&&this.emit("data",i),i},l.prototype._read=function(){this.emit("error",new Error("_read() is not implemented"))},l.prototype.pipe=function(e,t){function r(e,t){W("onunpipe"),e===f&&t&&!1===t.hasUnpiped&&(t.hasUnpiped=!0,i())}function o(){W("onend"),e.end()}function i(){W("cleanup"),e.removeListener("close",l),e.removeListener("finish",c),e.removeListener("drain",g),e.removeListener("error",s),e.removeListener("unpipe",r),f.removeListener("end",o),f.removeListener("end",u),f.removeListener("data",a),_=!0,p.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&g()}function a(t){W("ondata"),b=!1;var n=e.write(t);!1!==n||b||((1===p.pipesCount&&p.pipes===e||1<p.pipesCount&&-1!==A(p.pipes,e))&&!_&&(W("false write response, pause",f._readableState.awaitDrain),f._readableState.awaitDrain++,b=!0),f.pause())}function s(t){W("onerror",t),u(),e.removeListener("error",s),0===N(e,"error")&&e.emit("error",t)}function l(){e.removeListener("finish",c),u()}function c(){W("onfinish"),e.removeListener("close",l),u()}function u(){W("unpipe"),f.unpipe(e)}var f=this,p=this._readableState;switch(p.pipesCount){case 0:p.pipes=e;break;case 1:p.pipes=[p.pipes,e];break;default:p.pipes.push(e);}p.pipesCount+=1,W("pipe count=%d opts=%j",p.pipesCount,t);var h=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr,m=h?o:u;p.endEmitted?U.nextTick(m):f.once("end",m),e.on("unpipe",r);var g=k(f);e.on("drain",g);var _=!1,b=!1;return f.on("data",a),d(e,"error",s),e.once("close",l),e.once("finish",c),e.emit("pipe",f),p.flowing||(W("pipe resume"),f.resume()),e},l.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a<o;a++)r[a].emit("unpipe",this,n);return this}var d=A(t.pipes,e);return-1===d?this:(t.pipes.splice(d,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)},l.prototype.on=function(e,t){var n=q.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&&_(this):U.nextTick(x,this))}return n},l.prototype.addListener=l.prototype.on,l.prototype.resume=function(){var e=this._readableState;return e.flowing||(W("resume"),e.flowing=!0,S(this,e)),this},l.prototype.pause=function(){return W("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(W("pause"),this._readableState.flowing=!1,this.emit("pause")),this},l.prototype.wrap=function(e){var t=this,r=this._readableState,o=!1;for(var a in e.on("end",function(){if(W("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)}),e.on("data",function(n){if((W("wrapped data"),r.decoder&&(n=r.decoder.write(n)),!(r.objectMode&&(null===n||void 0===n)))&&(r.objectMode||n&&n.length)){var i=t.push(n);i||(o=!0,e.pause())}}),e)void 0===this[a]&&"function"==typeof e[a]&&(this[a]=function(t){return function(){return e[t].apply(e,arguments)}}(a));for(var i=0;i<K.length;i++)e.on(K[i],this.emit.bind(this,K[i]));return this._read=function(t){W("wrapped _read",t),o&&(o=!1,e.resume())},this},Object.defineProperty(l.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),l._fromList=C}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./_stream_duplex":107,"./internal/streams/BufferList":112,"./internal/streams/destroy":113,"./internal/streams/stream":114,_process:67,"core-util-is":31,events:36,inherits:42,isarray:47,"process-nextick-args":66,"safe-buffer":116,"string_decoder/":117,util:21}],110:[function(e,t){'use strict';function n(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function r(e){return this instanceof r?void(a.call(this,e),this._transformState={afterTransform:n.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},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.on("prefinish",o)):new r(e)}function o(){var e=this;"function"==typeof this._flush?this._flush(function(t,n){i(e,t,n)}):i(this,null,null)}function i(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}t.exports=r;var a=e("./_stream_duplex"),d=e("core-util-is");d.inherits=e("inherits"),d.inherits(r,a),r.prototype.push=function(e,t){return this._transformState.needTransform=!1,a.prototype.push.call(this,e,t)},r.prototype._transform=function(){throw new Error("_transform() is not implemented")},r.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},r.prototype._read=function(){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},r.prototype._destroy=function(e,t){var n=this;a.prototype._destroy.call(this,e,function(e){t(e),n.emit("close")})}},{"./_stream_duplex":107,"core-util-is":31,inherits:42}],111:[function(e,t){(function(n,o,i){'use strict';function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){I(t,e)}}function d(e){return M.from(e)}function s(e){return M.isBuffer(e)||e instanceof O}function l(){}function c(t,n){B=B||e("./_stream_duplex"),t=t||{};var o=n instanceof B;this.objectMode=!!t.objectMode,o&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var i=t.highWaterMark,d=t.writableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:o&&(d||0===d)?d:s,this.highWaterMark=r(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===t.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){y(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 a(this)}function u(t){return B=B||e("./_stream_duplex"),q.call(u,this)||this instanceof B?void(this._writableState=new c(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),P.call(this)):new u(t)}function f(e,t){var n=new Error("write after end");e.emit("error",n),T.nextTick(t,n)}function p(e,t,n,r){var o=!0,i=!1;return null===n?i=new TypeError("May not write null values to stream"):"string"!=typeof n&&void 0!==n&&!t.objectMode&&(i=new TypeError("Invalid non-string/buffer chunk")),i&&(e.emit("error",i),T.nextTick(r,i),o=!1),o}function h(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=M.from(t,n)),t}function m(e,t,n,r,o,i){if(!n){var a=h(t,r,o);r!==a&&(n=!0,o="buffer",r=a)}var d=t.objectMode?1:r.length;t.length+=d;var s=t.length<t.highWaterMark;if(s||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:o,isBuf:n,callback:i,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else g(e,t,!1,d,r,o,i);return s}function g(e,t,n,r,o,i,a){t.writelen=r,t.writecb=a,t.writing=!0,t.sync=!0,n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function _(e,t,n,r,o){--t.pendingcb,n?(T.nextTick(o,r),T.nextTick(C,e,t),e._writableState.errorEmitted=!0,e.emit("error",r)):(o(r),e._writableState.errorEmitted=!0,e.emit("error",r),C(e,t))}function b(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function y(e,t){var n=e._writableState,r=n.sync,o=n.writecb;if(b(n),t)_(e,n,r,t,o);else{var i=S(n);i||n.corked||n.bufferProcessing||!n.bufferedRequest||x(e,n),r?R(w,e,n,i,o):w(e,n,i,o)}}function w(e,t,n,r){n||k(e,t),t.pendingcb--,r(),C(e,t)}function k(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function x(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,o=Array(r),i=t.corkedRequestsFree;i.entry=n;for(var d=0,s=!0;n;)o[d]=n,n.isBuf||(s=!1),n=n.next,d+=1;o.allBuffers=s,g(e,t,!0,t.length,o,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,c=n.encoding,u=n.callback,f=t.objectMode?1:l.length;if(g(e,t,!1,f,l,c,u),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function S(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function E(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),C(e,t)})}function v(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,T.nextTick(E,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function C(e,t){var n=S(t);return n&&(v(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}function L(e,t,n){t.ending=!0,C(e,t),n&&(t.finished?T.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}function I(e,t,n){var r=e.entry;for(e.entry=null;r;){var o=r.callback;t.pendingcb--,o(n),r=r.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}var T=e("process-nextick-args");t.exports=u;var R=!n.browser&&-1<["v0.10","v0.9."].indexOf(n.version.slice(0,5))?i:T.nextTick,B;u.WritableState=c;var A=e("core-util-is");A.inherits=e("inherits");var U={deprecate:e("util-deprecate")},P=e("./internal/streams/stream"),M=e("safe-buffer").Buffer,O=o.Uint8Array||function(){},N=e("./internal/streams/destroy");A.inherits(u,P),c.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(c.prototype,"buffer",{get:U.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}();var q;"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(q=Function.prototype[Symbol.hasInstance],Object.defineProperty(u,Symbol.hasInstance,{value:function(e){return!!q.call(this,e)||!(this!==u)&&e&&e._writableState instanceof c}})):q=function(e){return e instanceof this},u.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},u.prototype.write=function(e,t,n){var r=this._writableState,o=!1,i=!r.objectMode&&s(e);return i&&!M.isBuffer(e)&&(e=d(e)),"function"==typeof t&&(n=t,t=null),i?t="buffer":!t&&(t=r.defaultEncoding),"function"!=typeof n&&(n=l),r.ended?f(this,n):(i||p(this,r,e,n))&&(r.pendingcb++,o=m(this,r,i,e,t,n)),o},u.prototype.cork=function(){var e=this._writableState;e.corked++},u.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.finished&&!e.bufferProcessing&&e.bufferedRequest&&x(this,e))},u.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(u.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),u.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},u.prototype._writev=null,u.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!==e&&e!==void 0&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||L(this,r,n)},Object.defineProperty(u.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),u.prototype.destroy=N.destroy,u.prototype._undestroy=N.undestroy,u.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("timers").setImmediate)},{"./_stream_duplex":107,"./internal/streams/destroy":113,"./internal/streams/stream":114,_process:67,"core-util-is":31,inherits:42,"process-nextick-args":66,"safe-buffer":116,timers:126,"util-deprecate":137}],112:[function(e,t){'use strict';function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t,n){e.copy(t,n)}var o=e("safe-buffer").Buffer,i=e("util");t.exports=function(){function e(){n(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};0<this.length?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return this.head=1===this.length?this.tail=null:this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.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},e.prototype.concat=function(e){if(0===this.length)return o.alloc(0);if(1===this.length)return this.head.data;for(var t=o.allocUnsafe(e>>>0),n=this.head,a=0;n;)r(n.data,t,a),a+=n.data.length,n=n.next;return t},e}(),i&&i.inspect&&i.inspect.custom&&(t.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},{"safe-buffer":116,util:21}],113:[function(e,t){'use strict';function n(e,t){e.emit("error",t)}var r=e("process-nextick-args");t.exports={destroy:function(e,t){var o=this,i=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return i||a?(t?t(e):e&&(!this._writableState||!this._writableState.errorEmitted)&&r.nextTick(n,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(r.nextTick(n,o,e),o._writableState&&(o._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},{"process-nextick-args":66}],114:[function(e,t,n){arguments[4][89][0].apply(n,arguments)},{dup:89,events:36}],115:[function(e,t,n){n=t.exports=e("./lib/_stream_readable.js"),n.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":107,"./lib/_stream_passthrough.js":108,"./lib/_stream_readable.js":109,"./lib/_stream_transform.js":110,"./lib/_stream_writable.js":111}],116:[function(e,t,n){function r(e,t){for(var n in e)t[n]=e[n]}function o(e,t,n){return a(e,t,n)}var i=e("buffer"),a=i.Buffer;a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?t.exports=i:(r(i,n),n.Buffer=o),r(a,o),o.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return a(e,t,n)},o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=a(e);return void 0===t?r.fill(0):"string"==typeof n?r.fill(t,n):r.fill(t),r},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return a(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},{buffer:27}],117:[function(e,t,n){'use strict';function r(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;}}function o(e){var t=r(e);if("string"!=typeof t&&(g.isEncoding===_||!_(e)))throw new Error("Unknown encoding: "+e);return t||e}function i(e){this.encoding=o(e);var t;switch(this.encoding){case"utf16le":this.text=c,this.end=u,t=4;break;case"utf8":this.fillLast=l,t=4;break;case"base64":this.text=f,this.end=p,t=3;break;default:return this.write=h,void(this.end=m);}this.lastNeed=0,this.lastTotal=0,this.lastChar=g.allocUnsafe(t)}function a(e){if(127>=e)return 0;return 6==e>>5?2:14==e>>4?3:30==e>>3?4:2==e>>6?-1:-2}function d(e,t,n){var r=t.length-1;if(r<n)return 0;var o=a(t[r]);return 0<=o?(0<o&&(e.lastNeed=o-1),o):--r<n||-2===o?0:(o=a(t[r]),0<=o)?(0<o&&(e.lastNeed=o-2),o):--r<n||-2===o?0:(o=a(t[r]),0<=o?(0<o&&(2===o?o=0:e.lastNeed=o-3),o):0)}function s(e,t){if(128!=(192&t[0]))return e.lastNeed=0,"\uFFFD";if(1<e.lastNeed&&1<t.length){if(128!=(192&t[1]))return e.lastNeed=1,"\uFFFD";if(2<e.lastNeed&&2<t.length&&128!=(192&t[2]))return e.lastNeed=2,"\uFFFD"}}function l(e){var t=this.lastTotal-this.lastNeed,n=s(this,e,t);return void 0===n?this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length):n}function c(e,t){if(0==(e.length-t)%2){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(55296<=r&&56319>=r)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 u(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 f(e,t){var r=(e.length-t)%3;return 0==r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1==r?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-r))}function p(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function m(e){return e&&e.length?this.write(e):""}var g=e("safe-buffer").Buffer,_=g.isEncoding||function(e){switch(e=""+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=i,i.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(t=this.fillLast(e),void 0===t)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||""},i.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t},i.prototype.text=function(e,t){var n=d(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)},i.prototype.fillLast=function(e){return this.lastNeed<=e.length?(e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length)}},{"safe-buffer":116}],118:[function(e,t){var n=e("stream-to-blob");t.exports=function e(t,r,o){return"function"==typeof r?e(t,null,r):void n(t,r,function(e,t){if(e)return o(e);var n=URL.createObjectURL(t);o(null,n)})}},{"stream-to-blob":119}],119:[function(e,t){var n=e("once");t.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);o=n(o);var i=[];t.on("data",function(e){i.push(e)}).on("end",function(){var e=r?new Blob(i,{type:r}):new Blob(i);o(null,e)}).on("error",o)}},{once:61}],120:[function(e,t){t.exports=function(e,t){if(null!=t&&"string"!=typeof t)throw new Error("Invalid mimetype, expected string.");return new Promise((n,r)=>{const o=[];e.on("data",e=>o.push(e)).once("end",()=>{const e=null==t?new Blob(o):new Blob(o,{type:t});n(e)}).once("error",r)})}},{}],121:[function(e,t){(function(n){var r=e("once");t.exports=function(e,t,o){o=r(o);var i=n.alloc(t),a=0;e.on("data",function(e){e.copy(i,a),a+=e.length}).on("end",function(){o(null,i)}).on("error",o)}}).call(this,e("buffer").Buffer)},{buffer:27,once:61}],122:[function(e,t,n){arguments[4][117][0].apply(n,arguments)},{dup:117,"safe-buffer":123}],123:[function(e,t,n){arguments[4][116][0].apply(n,arguments)},{buffer:27,dup:116}],124:[function(e,t,n){var r=e("./thirty-two");n.encode=r.encode,n.decode=r.decode},{"./thirty-two":125}],125:[function(e,t,n){(function(e){'use strict';function t(e){var t=r(e.length/5);return 0==e.length%5?t:t+1}var o=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];n.encode=function(n){e.isBuffer(n)||(n=new e(n));for(var r=0,o=0,a=0,d=0,s=new e(8*t(n));r<n.length;){var l=n[r];3<a?(d=l&255>>a,a=(a+5)%8,d=d<<a|(r+1<n.length?n[r+1]:0)>>8-a,r++):(d=31&l>>8-(a+5),a=(a+5)%8,0===a&&r++),s[o]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(d),o++}for(r=o;r<s.length;r++)s[r]=61;return s},n.decode=function(t){var n=0,r=0,d=0,s;e.isBuffer(t)||(t=new e(t));for(var l=new e(a(5*t.length/8)),c=0;c<t.length&&!(61===t[c]);c++){var u=t[c]-48;if(u<o.length)r=o[u],3>=n?(n=(n+5)%8,0==n?(s|=r,l[d]=s,d++,s=0):s|=255&r<<8-n):(n=(n+5)%8,s|=255&r>>>n,l[d]=s,d++,s=255&r<<8-n);else throw new Error("Invalid input - it is not base32 encoded string")}return l.slice(0,d)}}).call(this,e("buffer").Buffer)},{buffer:27}],126:[function(e,t,n){(function(t,r){function o(e,t){this._id=e,this._clearFn=t}var i=e("process/browser.js").nextTick,a=Function.prototype.apply,d=Array.prototype.slice,s={},l=0;n.setTimeout=function(){return new o(a.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new o(a.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;0<=t&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n.setImmediate="function"==typeof t?t:function(e){var t=l++,r=!(2>arguments.length)&&d.call(arguments,1);return s[t]=!0,i(function(){s[t]&&(r?e.apply(null,r):e.call(null),n.clearImmediate(t))}),t},n.clearImmediate="function"==typeof r?r:function(e){delete s[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":67,timers:126}],127:[function(e,t){var n=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(n.isBuffer(e)){for(var t=new Uint8Array(e.length),r=e.length,o=0;o<r;o++)t[o]=e[o];return t.buffer}throw new Error("Argument must be a Buffer")}},{buffer:27}],128:[function(e,t){(function(n){const o=e("debug")("torrent-discovery"),i=e("bittorrent-dht/client"),a=e("events").EventEmitter,d=e("run-parallel"),s=e("bittorrent-tracker/client");t.exports=class extends a{constructor(e){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._port=e.port,this._userAgent=e.userAgent,this.destroyed=!1,this._announce=e.announce||[],this._intervalMs=e.intervalMs||900000,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=e=>{this.emit("warning",e)},this._onError=e=>{this.emit("error",e)},this._onDHTPeer=(e,t)=>{t.toString("hex")!==this.infoHash||this.emit("peer",`${e.host}:${e.port}`,"dht")},this._onTrackerPeer=e=>{this.emit("peer",e,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")};const t=(e,t)=>{const n=new i(t);return n.on("warning",this._onWarning),n.on("error",this._onError),n.listen(e),this._internalDHT=!0,n};!1===e.tracker?this.tracker=null:e.tracker&&"object"==typeof e.tracker?(this._trackerOpts=Object.assign({},e.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),this.dht=!1===e.dht||"function"!=typeof i?null:e.dht&&"function"==typeof e.dht.addNode?e.dht:e.dht&&"object"==typeof e.dht?t(e.dhtPort,e.dht):t(e.dhtPort),this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce())}updatePort(e){e===this._port||(this._port=e,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(e){this.tracker&&this.tracker.complete(e)}destroy(e){if(!this.destroyed){this.destroyed=!0,clearTimeout(this._dhtTimeout);const t=[];this.tracker&&(this.tracker.stop(),this.tracker.removeListener("warning",this._onWarning),this.tracker.removeListener("error",this._onError),this.tracker.removeListener("peer",this._onTrackerPeer),this.tracker.removeListener("update",this._onTrackerAnnounce),t.push(e=>{this.tracker.destroy(e)})),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),t.push(e=>{this.dht.destroy(e)})),d(t,e),this.dht=null,this.tracker=null,this._announce=null}}_createTracker(){const e=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),t=new s(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.on("peer",this._onTrackerPeer),t.on("update",this._onTrackerAnnounce),t.setInterval(this._intervalMs),t.start(),t}_dhtAnnounce(){this._dhtAnnouncing||(o("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,e=>{this._dhtAnnouncing=!1,o("dht announce complete"),e&&this.emit("warning",e),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout(()=>{this._dhtAnnounce()},this._intervalMs+r(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())}))}}}).call(this,e("_process"))},{_process:67,"bittorrent-dht/client":21,"bittorrent-tracker/client":15,debug:33,events:36,"run-parallel":94}],129:[function(e,t){(function(e){const n=16384;class r{constructor(e){this.length=e,this.missing=e,this.sources=null,this._chunks=a(e/n),this._remainder=e%n||n,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(e){return e===this._chunks-1?this._remainder:n}chunkLengthRemaining(e){return this.length-e*n}chunkOffset(e){return e*n}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1}reserveRemaining(){if(!this.init())return-1;if(this._reservations<this._chunks){const e=this._reservations;return this._reservations=this._chunks,e}return-1}cancel(e){this.init()&&this._cancellations.push(e)}cancelRemaining(e){this.init()&&(this._reservations=e)}get(e){return this.init()?this._buffer[e]:null}set(e,t,r){if(!this.init())return!1;const o=t.length,i=a(o/n);for(let o=0;o<i;o++)if(!this._buffer[e+o]){const i=o*n,a=t.slice(i,i+n);this._buffered++,this._buffer[e+o]=a,this.missing-=a.length,this.sources.includes(r)||this.sources.push(r)}return this._buffered===this._chunks}flush(){if(!this._buffer||this._chunks!==this._buffered)return null;const t=e.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,t}init(){return!this._flushed&&(!!this._buffer||(this._buffer=Array(this._chunks),this._cancellations=[],this.sources=[],!0))}}Object.defineProperty(r,"BLOCK_LENGTH",{value:16384}),t.exports=r}).call(this,e("buffer").Buffer)},{buffer:27}],130:[function(e,t){(function(n){var r=e("is-typedarray").strict;t.exports=function(e){if(r(e)){var t=n.from(e.buffer);return e.byteLength!==e.buffer.byteLength&&(t=t.slice(e.byteOffset,e.byteOffset+e.byteLength)),t}return n.from(e)}}).call(this,e("buffer").Buffer)},{buffer:27,"is-typedarray":46}],131:[function(e,t,o){var i=e("buffer-alloc"),a=n(2,32);o.encodingLength=function(){return 8},o.encode=function(e,t,n){t||(t=i(8)),n||(n=0);var o=r(e/a);return t.writeUInt32BE(o,n),t.writeUInt32BE(e-o*a,n+4),t},o.decode=function(e,t){t||(t=0);var n=e.readUInt32BE(t),r=e.readUInt32BE(t+4);return n*a+r},o.encode.bytes=8,o.decode.bytes=8},{"buffer-alloc":24}],132:[function(e,t){"use strict";function n(e,t){for(var n=1,r=e.length,o=e[0],d=e[0],s=1;s<r;++s)if(d=o,o=e[s],t(o,d)){if(s===n){n++;continue}e[n++]=o}return e.length=n,e}function r(e){for(var t=1,n=e.length,r=e[0],o=e[0],d=1;d<n;++d,o=r)if(o=r,r=e[d],r!==o){if(d===t){t++;continue}e[t++]=r}return e.length=t,e}t.exports=function(e,t,o){return 0===e.length?e:t?(o||e.sort(t),n(e,t)):(o||e.sort(),r(e))}},{}],133:[function(e,t){t.exports=function(e,t){if(!(t>=e.length||0>t)){var n=e.pop();if(t<e.length){var r=e[t];return e[t]=n,r}return n}}},{}],134:[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 o(e,t,n){if(e&&d.isObject(e)&&e instanceof r)return e;var o=new r;return o.parse(e,t,n),o}var a=e("punycode"),d=e("./util");n.parse=o,n.resolve=function(e,t){return o(e,!1,!0).resolve(t)},n.resolveObject=function(e,t){return e?o(e,!1,!0).resolveObject(t):t},n.format=function(e){return d.isString(e)&&(e=o(e)),e instanceof r?e.format():r.prototype.format.call(e)},n.Url=r;var c=/^([a-z0-9.+-]+:)/i,u=/:[0-9]*$/,f=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,p=["{","}","|","\\","^","`"].concat(["<",">","\"","`"," ","\r","\n","\t"]),h=["'"].concat(p),m=["%","/","?",";","#"].concat(h),g=["/","?","#"],_=/^[+a-z0-9A-Z_-]{0,63}$/,b=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},w={javascript:!0,"javascript:":!0},x={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},S=e("querystring");r.prototype.parse=function(e,t,n){if(!d.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),o=-1!==r&&r<e.indexOf("#")?"?":"#",u=e.split(o),E=/\\/g;u[0]=u[0].replace(E,"/"),e=u.join(o);var v=e;if(v=v.trim(),!n&&1===e.split("#").length){var C=f.exec(v);if(C)return this.path=v,this.href=v,this.pathname=C[1],C[2]?(this.search=C[2],this.query=t?S.parse(this.search.substr(1)):this.search.substr(1)):t&&(this.search="",this.query={}),this}var L=c.exec(v);if(L){L=L[0];var I=L.toLowerCase();this.protocol=I,v=v.substr(L.length)}if(n||L||v.match(/^\/\/[^@\/]+@[^@\/]+/)){var T="//"===v.substr(0,2);T&&!(L&&w[L])&&(v=v.substr(2),this.slashes=!0)}if(!w[L]&&(T||L&&!x[L])){for(var R=-1,B=0,A;B<g.length;B++)A=v.indexOf(g[B]),-1!==A&&(-1===R||A<R)&&(R=A);var U,P;P=-1===R?v.lastIndexOf("@"):v.lastIndexOf("@",R),-1!==P&&(U=v.slice(0,P),v=v.slice(P+1),this.auth=decodeURIComponent(U)),R=-1;for(var B=0,A;B<m.length;B++)A=v.indexOf(m[B]),-1!==A&&(-1===R||A<R)&&(R=A);-1===R&&(R=v.length),this.host=v.slice(0,R),v=v.slice(R),this.parseHost(),this.hostname=this.hostname||"";var M="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!M)for(var O=this.hostname.split(/\./),B=0,N=O.length,q;B<N;B++)if(q=O[B],q&&!q.match(_)){for(var H="",D=0,F=q.length;D<F;D++)H+=127<q.charCodeAt(D)?"x":q[D];if(!H.match(_)){var k=O.slice(0,B),W=O.slice(B+1),z=q.match(b);z&&(k.push(z[1]),W.unshift(z[2])),W.length&&(v="/"+W.join(".")+v),this.hostname=k.join(".");break}}this.hostname=255<this.hostname.length?"":this.hostname.toLowerCase(),M||(this.hostname=a.toASCII(this.hostname));var V=this.port?":"+this.port:"",G=this.hostname||"";this.host=G+V,this.href+=this.host,M&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!y[I])for(var B=0,N=h.length,K;B<N;B++)if(K=h[B],-1!==v.indexOf(K)){var Y=encodeURIComponent(K);Y===K&&(Y=escape(K)),v=v.split(K).join(Y)}var X=v.indexOf("#");-1!==X&&(this.hash=v.substr(X),v=v.slice(0,X));var $=v.indexOf("?");if(-1===$?t&&(this.search="",this.query={}):(this.search=v.substr($),this.query=v.substr($+1),t&&(this.query=S.parse(this.query)),v=v.slice(0,$)),v&&(this.pathname=v),x[I]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var V=this.pathname||"",Q=this.search||"";this.path=V+Q}return this.href=this.format(),this},r.prototype.format=function(){var e=this.auth||"";e&&(e=encodeURIComponent(e),e=e.replace(/%3A/i,":"),e+="@");var t=this.protocol||"",n=this.pathname||"",r=this.hash||"",o=!1,i="";this.host?o=e+this.host:this.hostname&&(o=e+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(o+=":"+this.port)),this.query&&d.isObject(this.query)&&Object.keys(this.query).length&&(i=S.stringify(this.query));var a=this.search||i&&"?"+i||"";return t&&":"!==t.substr(-1)&&(t+=":"),this.slashes||(!t||x[t])&&!1!=o?(o="//"+(o||""),n&&"/"!==n.charAt(0)&&(n="/"+n)):!o&&(o=""),r&&"#"!==r.charAt(0)&&(r="#"+r),a&&"?"!==a.charAt(0)&&(a="?"+a),n=n.replace(/[?#]/g,function(e){return encodeURIComponent(e)}),a=a.replace("#","%23"),t+o+n+a+r},r.prototype.resolve=function(e){return this.resolveObject(o(e,!1,!0)).format()},r.prototype.resolveObject=function(e){if(d.isString(e)){var t=new r;t.parse(e,!1,!0),e=t}for(var n=new r,o=Object.keys(this),a=0,l;a<o.length;a++)l=o[a],n[l]=this[l];if(n.hash=e.hash,""===e.href)return n.href=n.format(),n;if(e.slashes&&!e.protocol){for(var c=Object.keys(e),u=0,f;u<c.length;u++)f=c[u],"protocol"!==f&&(n[f]=e[f]);return x[n.protocol]&&n.hostname&&!n.pathname&&(n.path=n.pathname="/"),n.href=n.format(),n}if(e.protocol&&e.protocol!==n.protocol){if(!x[e.protocol]){for(var h=Object.keys(e),m=0,g;m<h.length;m++)g=h[m],n[g]=e[g];return n.href=n.format(),n}if(n.protocol=e.protocol,!e.host&&!w[e.protocol]){for(var _=(e.pathname||"").split("/");_.length&&!(e.host=_.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==_[0]&&_.unshift(""),2>_.length&&_.unshift(""),n.pathname=_.join("/")}else n.pathname=e.pathname;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 b=n.pathname||"",p=n.search||"";n.path=b+p}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var s=n.pathname&&"/"===n.pathname.charAt(0),y=e.host||e.pathname&&"/"===e.pathname.charAt(0),S=y||s||n.host&&e.pathname,E=S,C=n.pathname&&n.pathname.split("/")||[],_=e.pathname&&e.pathname.split("/")||[],L=n.protocol&&!x[n.protocol];if(L&&(n.hostname="",n.port=null,n.host&&(""===C[0]?C[0]=n.host:C.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===_[0]?_[0]=e.host:_.unshift(e.host)),e.host=null),S=S&&(""===_[0]||""===C[0])),y)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,C=_;else if(_.length)C||(C=[]),C.pop(),C=C.concat(_),n.search=e.search,n.query=e.query;else if(!d.isNullOrUndefined(e.search)){if(L){n.hostname=n.host=C.shift();var I=!!(n.host&&0<n.host.indexOf("@"))&&n.host.split("@");I&&(n.auth=I.shift(),n.host=n.hostname=I.shift())}return n.search=e.search,n.query=e.query,d.isNull(n.pathname)&&d.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!C.length)return n.pathname=null,n.path=n.search?"/"+n.search:null,n.href=n.format(),n;for(var T=C.slice(-1)[0],R=(n.host||e.host||1<C.length)&&("."===T||".."===T)||""===T,B=0,A=C.length;0<=A;A--)T=C[A],"."===T?C.splice(A,1):".."===T?(C.splice(A,1),B++):B&&(C.splice(A,1),B--);if(!S&&!E)for(;B--;B)C.unshift("..");S&&""!==C[0]&&(!C[0]||"/"!==C[0].charAt(0))&&C.unshift(""),R&&"/"!==C.join("/").substr(-1)&&C.push("");var U=""===C[0]||C[0]&&"/"===C[0].charAt(0);if(L){n.hostname=n.host=U?"":C.length?C.shift():"";var I=!!(n.host&&0<n.host.indexOf("@"))&&n.host.split("@");I&&(n.auth=I.shift(),n.host=n.hostname=I.shift())}return S=S||n.host&&C.length,S&&!U&&C.unshift(""),C.length?n.pathname=C.join("/"):(n.pathname=null,n.path=null),d.isNull(n.pathname)&&d.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],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":135,punycode:69,querystring:72}],135:[function(e,t){'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}}},{}],136:[function(e,t){(function(n){const{EventEmitter:r}=e("events"),o=e("bencode"),i=e("bitfield"),d=e("debug")("ut_metadata"),s=e("simple-sha1"),l=1E3,c=16384;t.exports=e=>{class t extends r{constructor(t){super(),this._wire=t,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new i(0,{grow:l}),n.isBuffer(e)&&this.setMetadata(e)}onHandshake(e,t,n){this._infoHash=e}onExtendedHandshake(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||1E7<e.metadata_size||0>=e.metadata_size?this.emit("warning",new Error("Peer gave invalid metadata size")):void(this._metadataSize=e.metadata_size,this._numPieces=a(this._metadataSize/c),this._remainingRejects=2*this._numPieces,this._fetching&&this._requestPieces()):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(e){let t,n;try{const r=e.toString(),i=r.indexOf("ee")+2;t=o.decode(r.substring(0,i)),n=e.slice(i)}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);}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(e){if(this._metadataComplete)return!0;d("set metadata");try{const t=o.decode(e).info;t&&(e=o.encode(t))}catch(e){}return!(this._infoHash&&this._infoHash!==s.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",o.encode({info:o.decode(this.metadata)})),!0)}_send(e,t){let r=o.encode(e);n.isBuffer(t)&&(r=n.concat([r,t])),this._wire.extended("ut_metadata",r)}_request(e){this._send({msg_type:0,piece:e})}_data(e,t,n){const r={msg_type:1,piece:e};"number"==typeof n&&(r.total_size=n),this._send(r,t)}_reject(e){this._send({msg_type:2,piece:e})}_onRequest(e){if(!this._metadataComplete)return void this._reject(e);const t=e*c;let n=t+c;n>this._metadataSize&&(n=this._metadataSize);const r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)}_onData(e,t,n){t.length>c||(t.copy(this.metadata,e*c),this._bitfield.set(e),this._checkDone())}_onReject(e){0<this._remainingRejects&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error("Peer sent \"reject\" too much"))}_requestPieces(){this.metadata=n.alloc(this._metadataSize);for(let e=0;e<this._numPieces;e++)this._request(e)}_checkDone(){let e=!0;for(let t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}if(e){const e=this.setMetadata(this.metadata);e||this._failedMetadata()}}_failedMetadata(){this._bitfield=new i(0,{grow:l}),this._remainingRejects-=this._numPieces,0<this._remainingRejects?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return t.prototype.name="ut_metadata",t}}).call(this,e("buffer").Buffer)},{bencode:11,bitfield:13,buffer:27,debug:33,events:36,"simple-sha1":100}],137:[function(e,t){(function(e){function n(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===(n+"").toLowerCase()}t.exports=function(e,t){function r(){if(!o){if(n("throwDeprecation"))throw new Error(t);else n("traceDeprecation")?console.trace(t):console.warn(t);o=!0}return e.apply(this,arguments)}if(n("noDeprecation"))return e;var o=!1;return r}}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],138:[function(e,t){(function(n){function o(){return{version:0,flags:0,entries:[]}}const i=e("binary-search"),a=e("events"),d=e("mp4-stream"),s=e("mp4-box-encoding"),l=e("range-slice-stream");class c{constructor(e,t){this._entries=e,this._countName=t||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}t.exports=class extends a{constructor(e){super(),this._tracks=[],this._file=e,this._decoder=null,this._findMoov(0)}_findMoov(e){this._decoder&&this._decoder.destroy();let t=0;this._decoder=d.decode();const n=this._file.createReadStream({start:e});n.pipe(this._decoder);const r=o=>{"moov"===o.type?(this._decoder.removeListener("box",r),this._decoder.decode(e=>{n.destroy();try{this._processMoov(e)}catch(e){e.message=`Cannot parse mp4 file: ${e.message}`,this.emit("error",e)}})):o.length<4096?(t+=o.length,this._decoder.ignore()):(this._decoder.removeListener("box",r),t+=o.length,n.destroy(),this._decoder.destroy(),this._findMoov(e+t))};this._decoder.on("box",r)}_processMoov(e){const t=e.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(let n=0;n<t.length;n++){const i=t[n],a=i.mdia.minf.stbl,d=a.stsd.entries[0],s=i.mdia.hdlr.handlerType;let l,u;if("vide"===s&&"avc1"===d.type){if(this._hasVideo)continue;this._hasVideo=!0,l="avc1",d.avcC&&(l+=`.${d.avcC.mimeCodec}`),u=`video/mp4; codecs="${l}"`}else if("soun"===s&&"mp4a"===d.type){if(this._hasAudio)continue;this._hasAudio=!0,l="mp4a",d.esds&&d.esds.mimeCodec&&(l+=`.${d.esds.mimeCodec}`),u=`audio/mp4; codecs="${l}"`}else continue;const f=[];let p=0,h=0,m=0,g=0,_=0,b=0;const y=new c(a.stts.entries);let w=null;a.ctts&&(w=new c(a.ctts.entries));for(let e=0;;){var r=a.stsc.entries[_];const t=a.stsz.entries[p],n=y.value.duration,o=w?w.value.compositionOffset:0;let i=!0;a.stss&&(i=a.stss.entries[e]===p+1);const d=a.stco||a.co64;if(f.push({size:t,duration:n,dts:b,presentationOffset:o,sync:i,offset:g+d.entries[m]}),p++,p>=a.stsz.entries.length)break;if(h++,g+=t,h>=r.samplesPerChunk){h=0,g=0,m++;const e=a.stsc.entries[_+1];e&&m+1>=e.firstChunk&&_++}b+=n,y.inc(),w&&w.inc(),i&&e++}i.mdia.mdhd.duration=0,i.tkhd.duration=0;const k=r.sampleDescriptionId,x={type:"moov",mvhd:e.mvhd,traks:[{tkhd:i.tkhd,mdia:{mdhd:i.mdia.mdhd,hdlr:i.mdia.hdlr,elng:i.mdia.elng,minf:{vmhd:i.mdia.minf.vmhd,smhd:i.mdia.minf.smhd,dinf:i.mdia.minf.dinf,stbl:{stsd:a.stsd,stts:o(),ctts:o(),stsc:o(),stsz:o(),stco:o(),stss:o()}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:i.tkhd.trackId,defaultSampleDescriptionIndex:k,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({fragmentSequence:1,trackId:i.tkhd.trackId,timeScale:i.mdia.mdhd.timeScale,samples:f,currSample:null,currTime:null,moov:x,mime:u})}if(0===this._tracks.length)return void this.emit("error",new Error("no playable tracks"));e.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};const i=s.encode(this._ftyp),a=this._tracks.map(e=>{const t=s.encode(e.moov);return{mime:e.mime,init:n.concat([i,t])}});this.emit("ready",a)}seek(e){if(!this._tracks)throw new Error("Not ready yet; wait for 'ready' event");this._fileStream&&(this._fileStream.destroy(),this._fileStream=null);let t=-1;if(this._tracks.map((n,r)=>{n.outStream&&n.outStream.destroy(),n.inStream&&(n.inStream.destroy(),n.inStream=null);const o=n.outStream=d.encode(),i=this._generateFragment(r,e);if(!i)return o.finalize();(-1===t||i.ranges[0].start<t)&&(t=i.ranges[0].start);const a=e=>{o.destroyed||o.box(e.moof,t=>{if(t)return this.emit("error",t);if(!o.destroyed){const t=n.inStream.slice(e.ranges);t.pipe(o.mediaData(e.length,e=>{if(e)return this.emit("error",e);if(!o.destroyed){const e=this._generateFragment(r);return e?void a(e):o.finalize()}}))}})};a(i)}),0<=t){const e=this._fileStream=this._file.createReadStream({start:t});this._tracks.forEach(n=>{n.inStream=new l(t,{highWaterMark:1e7}),e.pipe(n.inStream)})}return this._tracks.map(e=>e.outStream)}_findSampleBefore(e,t){const n=this._tracks[e],o=r(n.timeScale*t);let a=i(n.samples,o,(e,n)=>{const t=e.dts+e.presentationOffset;return t-n});for(-1===a?a=0:0>a&&(a=-a-2);!n.samples[a].sync;)a--;return a}_generateFragment(e,t){const n=this._tracks[e];let r;if(r=void 0===t?n.currSample:this._findSampleBefore(e,t),r>=n.samples.length)return null;const o=n.samples[r].dts;let i=0;const a=[];for(var d=r;d<n.samples.length;d++){const e=n.samples[d];if(e.sync&&e.dts-o>=n.timeScale*1)break;i+=e.size;const t=a.length-1;0>t||a[t].end!==e.offset?a.push({start:e.offset,end:e.offset+e.size}):a[t].end+=e.size}return n.currSample=d,{moof:this._generateMoof(e,r,d),ranges:a,length:i}}_generateMoof(e,t,n){const r=this._tracks[e],o=[];let i=0;for(let a=t;a<n;a++){const e=r.samples[a];0>e.presentationOffset&&(i=1),o.push({sampleDuration:e.duration,sampleSize:e.size,sampleFlags:e.sync?33554432:16842752,sampleCompositionTimeOffset:e.presentationOffset})}const a={type:"moof",mfhd:{sequenceNumber:r.fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:r.trackId},tfdt:{baseMediaDecodeTime:r.samples[t].dts},trun:{flags:3841,dataOffset:8,entries:o,version:i}}]};return a.trafs[0].trun.dataOffset+=s.encodingLength(a),a}}}).call(this,e("buffer").Buffer)},{"binary-search":12,buffer:27,events:36,"mp4-box-encoding":54,"mp4-stream":57,"range-slice-stream":75}],139:[function(e,t){function n(e,t,o={}){return this instanceof n?void(this.detailedError=null,this._elem=t,this._elemWrapper=new r(t),this._waitingFired=!1,this._trackMeta=null,this._file=e,this._tracks=null,"none"!==this._elem.preload&&this._createMuxer(),this._onError=()=>{this.detailedError=this._elemWrapper.detailedError,this.destroy()},this._onWaiting=()=>{this._waitingFired=!0,this._muxer?this._tracks&&this._pump():this._createMuxer()},t.autoplay&&(t.preload="auto"),t.addEventListener("waiting",this._onWaiting),t.addEventListener("error",this._onError)):(console.warn("don't invoked VideoStream without 'new'"),new n(e,t,o))}const r=e("mediasource"),o=e("pump"),i=e("./mp4-remuxer");n.prototype={_createMuxer(){this._muxer=new i(this._file),this._muxer.on("ready",e=>{this._tracks=e.map(e=>{const t=this._elemWrapper.createWriteStream(e.mime);t.on("error",e=>{this._elemWrapper.error(e)});const n={muxed:null,mediaSource:t,initFlushed:!1,onInitFlushed:null};return t.write(e.init,e=>{n.initFlushed=!0,n.onInitFlushed&&n.onInitFlushed(e)}),n}),(this._waitingFired||"auto"===this._elem.preload)&&this._pump()}),this._muxer.on("error",e=>{this._elemWrapper.error(e)})},_pump(){const e=this._muxer.seek(this._elem.currentTime,!this._tracks);this._tracks.forEach((t,n)=>{const r=()=>{t.muxed&&(t.muxed.destroy(),t.mediaSource=this._elemWrapper.createWriteStream(t.mediaSource),t.mediaSource.on("error",e=>{this._elemWrapper.error(e)})),t.muxed=e[n],o(t.muxed,t.mediaSource)};t.initFlushed?r():t.onInitFlushed=e=>e?void this._elemWrapper.error(e):void r()})},destroy(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(e=>{e.muxed&&e.muxed.destroy()}),this._elem.src="")}},t.exports=n},{"./mp4-remuxer":138,mediasource:50,pump:68}],140:[function(e,t){function n(e,t){function r(){for(var t=Array(arguments.length),n=0;n<t.length;n++)t[n]=arguments[n];var r=e.apply(this,t),o=t[t.length-1];return"function"==typeof r&&r!==o&&Object.keys(o).forEach(function(e){r[e]=o[e]}),r}if(e&&t)return n(e)(t);if("function"!=typeof e)throw new TypeError("need wrapper function");return Object.keys(e).forEach(function(t){r[t]=e[t]}),r}t.exports=n},{}],141:[function(e,t){t.exports=function(){for(var e={},t=0,r;t<arguments.length;t++)for(var o in r=arguments[t],r)n.call(r,o)&&(e[o]=r[o]);return e};var n=Object.prototype.hasOwnProperty},{}],142:[function(e,t){t.exports={version:"0.106.0"}},{}],143:[function(e,t){(function(n,r){function o(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function i(e){return"undefined"!=typeof FileList&&e instanceof FileList}const{Buffer:a}=e("safe-buffer"),{EventEmitter:d}=e("events"),s=e("simple-concat"),l=e("create-torrent"),c=e("debug")("webtorrent"),u=e("bittorrent-dht/client"),f=e("load-ip-set"),p=e("run-parallel"),h=e("parse-torrent"),m=e("path"),g=e("simple-peer"),_=e("randombytes"),b=e("speedometer"),y=e("./lib/tcp-pool"),w=e("./lib/torrent"),k=e("./package.json").version,x=k.replace(/\d*./g,e=>`0${e%100}`.slice(-2)).slice(0,4);class S extends d{constructor(e={}){super(),this.peerId="string"==typeof e.peerId?e.peerId:a.isBuffer(e.peerId)?e.peerId.toString("hex"):a.from(`-WW${x}-`+_(9).toString("base64")).toString("hex"),this.peerIdBuffer=a.from(this.peerId,"hex"),this.nodeId="string"==typeof e.nodeId?e.nodeId:a.isBuffer(e.nodeId)?e.nodeId.toString("hex"):_(20).toString("hex"),this.nodeIdBuffer=a.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=e.torrentPort||0,this.dhtPort=e.dhtPort||0,this.tracker=e.tracker===void 0?{}:e.tracker,this.torrents=[],this.maxConns=+e.maxConns||55,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=e.wrtc),r.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=r.WRTC)),"function"==typeof y?this._tcpPool=new y(this):n.nextTick(()=>{this._onListening()}),this._downloadSpeed=b(),this._uploadSpeed=b(),!1!==e.dht&&"function"==typeof u?(this.dht=new u(Object.assign({},{nodeId:this.nodeId},e.dht)),this.dht.once("error",e=>{this._destroy(e)}),this.dht.once("listening",()=>{const e=this.dht.address();e&&(this.dhtPort=e.port)}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==e.webSeeds;const t=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};"function"==typeof f&&null!=e.blocklist?f(e.blocklist,{headers:{"user-agent":`WebTorrent/${k} (https://webtorrent.io)`}},(e,n)=>e?this.error(`Failed to load blocklist: ${e.message}`):void(this.blocked=n,t())):n.nextTick(t)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const e=this.torrents.filter(e=>1!==e.progress),t=e.reduce((e,t)=>e+t.downloaded,0),n=e.reduce((e,t)=>e+(t.length||0),0)||1;return t/n}get ratio(){const e=this.torrents.reduce((e,t)=>e+t.uploaded,0),t=this.torrents.reduce((e,t)=>e+t.received,0)||1;return e/t}get(e){if(!(e instanceof w)){let t;try{t=h(e)}catch(e){}if(!t)return null;if(!t.infoHash)throw new Error("Invalid torrent identifier");for(const e of this.torrents)if(e.infoHash===t.infoHash)return e}else if(this.torrents.includes(e))return e;return null}download(e,t,n){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(e,t,n)}add(e,t={},n){function r(){a.removeListener("_infoHash",o),a.removeListener("ready",i),a.removeListener("close",r)}if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]);const o=()=>{if(!this.destroyed)for(const e of this.torrents)if(e.infoHash===a.infoHash&&e!==a)return void a._destroy(new Error(`Cannot add duplicate torrent ${a.infoHash}`))},i=()=>{this.destroyed||("function"==typeof n&&n(a),this.emit("torrent",a))};this._debug("add"),t=t?Object.assign({},t):{};const a=new w(e,this,t);return this.torrents.push(a),a.once("_infoHash",o),a.once("ready",i),a.once("close",r),a}seed(e,t,n){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof t&&([t,n]=[{},t]),this._debug("seed"),t=t?Object.assign({},t):{},t.skipVerify=!0;const r="string"==typeof e;r&&(t.path=m.dirname(e)),t.createdBy||(t.createdBy=`WebTorrent/${x}`);const a=e=>{this._debug("on seed"),"function"==typeof n&&n(e),e.emit("seed"),this.emit("seed",e)},d=this.add(null,t,e=>{const t=[t=>r?t():void e.load(c,t)];this.dht&&t.push(t=>{e.once("dhtAnnounce",t)}),p(t,t=>this.destroyed?void 0:t?e._destroy(t):void a(e))});let c;return i(e)?e=Array.from(e):!Array.isArray(e)&&(e=[e]),p(e.map(e=>t=>{o(e)?s(e,t):t(null,e)}),(e,n)=>this.destroyed?void 0:e?d._destroy(e):void l.parseInput(n,t,(e,r)=>this.destroyed?void 0:e?d._destroy(e):void(c=r.map(e=>e.getStream),l(n,t,(e,t)=>{if(!this.destroyed){if(e)return d._destroy(e);const n=this.get(t);n?d._destroy(new Error(`Cannot add duplicate torrent ${n.infoHash}`)):d._onTorrentId(t)}})))),d}remove(e,t){this._debug("remove");const n=this.get(e);if(!n)throw new Error(`No torrent with id ${e}`);this._remove(e,t)}_remove(e,t){const n=this.get(e);n&&(this.torrents.splice(this.torrents.indexOf(n),1),n.destroy(t))}address(){return this.listening?this._tcpPool?this._tcpPool.server.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}destroy(e){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,e)}_destroy(e,t){this._debug("client destroy"),this.destroyed=!0;const n=this.torrents.map(e=>t=>{e.destroy(t)});this._tcpPool&&n.push(e=>{this._tcpPool.destroy(e)}),this.dht&&n.push(e=>{this.dht.destroy(e)}),p(n,t),e&&this.emit("error",e),this.torrents=[],this._tcpPool=null,this.dht=null}_onListening(){if(this._debug("listening"),this.listening=!0,this._tcpPool){const e=this._tcpPool.server.address();e&&(this.torrentPort=e.port)}this.emit("listening")}_debug(){const e=[].slice.call(arguments);e[0]=`[${this._debugId}] ${e[0]}`,c(...e)}}S.WEBRTC_SUPPORT=g.WEBRTC_SUPPORT,S.VERSION=k,t.exports=S}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"./lib/tcp-pool":21,"./lib/torrent":5,"./package.json":142,_process:67,"bittorrent-dht/client":21,"create-torrent":32,debug:33,events:36,"load-ip-set":21,"parse-torrent":63,path:64,randombytes:74,"run-parallel":94,"safe-buffer":96,"simple-concat":97,"simple-peer":99,speedometer:102}]},{},[143])(143)}); \ No newline at end of file
+!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window).WebTorrent=t()}(function(){var eo=Math.ceil,to=Math.max,no=Math.pow,ro=String.fromCharCode,oo=Math.abs,ao=Math.min,io=Math.floor;function tt(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=c(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}function v(t){return void 0===t._maxListeners?tt.defaultMaxListeners:t._maxListeners}function C(d,e,t,n){var r,l,u;if("function"!=typeof t)throw new TypeError("\"listener\" argument must be a function");if((l=d._events)?(l.newListener&&(d.emit("newListener",e,t.listener?t.listener:t),l=d._events),u=l[e]):(l=d._events=c(null),d._eventsCount=0),!u)u=l[e]=t,++d._eventsCount;else if("function"==typeof u?u=l[e]=n?[t,u]:[u,t]:n?u.unshift(t):u.push(t),!u.warned&&(r=v(d))&&0<r&&u.length>r){u.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+u.length+" \""+(e+"\" listeners added. Use emitter.setMaxListeners() to increase limit."));f.name="MaxListenersExceededWarning",f.emitter=d,f.type=e,f.count=u.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",f.name,f.message)}return d}function x(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var n=Array(arguments.length),e=0;e<n.length;++e)n[e]=arguments[e];this.listener.apply(this.target,n);}}function T(o,e,t){var n={fired:!1,wrapFn:void 0,target:o,type:e,listener:t},r=s.call(x,n);return r.listener=t,n.wrapFn=r,r}function A(o,e,t){var n=o._events;if(!n)return[];var r=n[e];return r?"function"==typeof r?t?[r.listener||r]:[r]:t?function(r){for(var e=Array(r.length),t=0;t<e.length;++t)e[t]=r[t].listener||r[t];return e}(r):R(r,r.length):[]}function I(r){var e=this._events;if(e){var t=e[r];if("function"==typeof t)return 1;if(t)return t.length}return 0}function R(o,e){for(var t=Array(e),n=0;n<e;++n)t[n]=o[n];return t}function B(r){var e=r.length;if(0<e%4)throw new Error("Invalid string. Length must be a multiple of 4");var t=r.indexOf("=");return-1===t&&(t=e),[t,t===e?0:4-t%4]}function D(d,e,t){for(var n,a,l=[],s=e;s<t;s+=3)n=(16711680&d[s]<<16)+(65280&d[s+1]<<8)+(255&d[s+2]),l.push(w[63&(a=n)>>18]+w[63&a>>12]+w[63&a>>6]+w[63&a]);return l.join("")}function H(r,e){for(var t in r)e[t]=r[t]}function V(r,e,t){return z(r,e,t)}function G(o,e,t){var n=[],r=null;return G._encode(n,o),r=mo.concat(n),G.bytes=r.length,mo.isBuffer(e)?(r.copy(e,t),e):r}function J(d,e,t){for(var n,a=0,l=1,c=e;c<t;c++)if(n=d[c],58>n&&48<=n)a=10*a+(n-48);else if(c!==e||43!==n){if(c!==e||45!==n){if(46===n)break;throw new Error("not a number: buffer["+c+"] = "+n)}l=-1}return a*l}function ne(o,e,d,a){return null==o||0===o.length?null:("number"!=typeof e&&null==a&&(a=e,e=void 0),"number"!=typeof d&&null==a&&(a=d,d=void 0),ne.position=0,ne.encoding=a||null,ne.data=_o.isBuffer(o)?o.slice(e,d):_o.from(o),ne.bytes=ne.data.length,ne.next())}function re(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function he(){throw new Error("setTimeout has not been defined")}function _e(){throw new Error("clearTimeout has not been defined")}function ye(n){if(se===setTimeout)return setTimeout(n,0);if((se===he||!se)&&setTimeout)return se=setTimeout,setTimeout(n,0);try{return se(n,0)}catch(e){try{return se.call(null,n,0)}catch(e){return se.call(this,n,0)}}}function be(){ko&&me&&(ko=!1,me.length?So=me.concat(So):Eo=-1,So.length&&Se())}function Se(){if(!ko){var n=ye(be);ko=!0;for(var e=So.length;e;){for(me=So,So=[];++Eo<e;)me&&me[Eo].run();Eo=-1,e=So.length}me=null,ko=!1,function(n){if(bo===clearTimeout)return clearTimeout(n);if((bo===_e||!bo)&&clearTimeout)return bo=clearTimeout,clearTimeout(n);try{bo(n)}catch(e){try{return bo.call(null,n)}catch(e){return bo.call(this,n)}}}(n)}}function Ce(n,e){this.fun=n,this.array=e}function xe(){}function Te(o,d,e){e||(e=Error);var t=function(t){function e(e,n,r){return t.call(this,function(t,e,n){return"string"==typeof d?d:d(t,e,n)}(e,n,r))||this}var o,a;return a=t,(o=e).prototype=Object.create(a.prototype),o.prototype.constructor=o,o.__proto__=a,e}(e);t.prototype.name=e.name,t.prototype.code=o,Ie[o]=t}function Be(r,o){if(Array.isArray(r)){var t=r.length;return r=r.map(function(t){return t+""}),2<t?"one of ".concat(o," ").concat(r.slice(0,t-1).join(", "),", or ")+r[t-1]:2===t?"one of ".concat(o," ").concat(r[0]," or ").concat(r[1]):"of ".concat(o," ").concat(r[0])}return"of ".concat(o," ").concat(r+"")}function Le(r,e){for(var t in r)e[t]=r[t]}function qe(r,e,t){return De(r,e,t)}function Fe(o,e){var t=this._transformState;t.transforming=!1;var n=t.writecb;if(null===n)return this.emit("error",new $e);t.writechunk=null,t.writecb=null,null!=e&&this.push(e),n(o);var r=this._readableState;r.reading=!1,(r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}function Je(t){return this instanceof Je?void(Ke.call(this,t),this._transformState={afterTransform:Fe.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",Xe)):new Je(t)}function Xe(){var r=this;"function"!=typeof this._flush||this._readableState.destroyed?Ze(this,null,null):this._flush(function(e,t){Ze(r,e,t)})}function Ze(r,e,t){if(e)return r.emit("error",e);if(null!=t&&r.push(t),r._writableState.length)throw new Ge;if(r._transformState.transforming)throw new Ve;return r.push(null)}function Qe(t){return this instanceof Qe?void He.call(this,t):new Qe(t)}function nt(t){if(t)throw t}function ot(t){t()}function at(n,e){return n.pipe(e)}function ht(t){return bt(t)||wt(t)}function bt(t){return t instanceof Int8Array||t instanceof Int16Array||t instanceof Int32Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Uint16Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array}function wt(t){return _t[Uo.call(t)]}function vt(t){return St.existsSync(t)&&St.statSync(t).isFile()}function Tt(r,e){var t=this;return t instanceof Tt?void(st.Readable.call(t,e),t.destroyed=!1,t._drained=!1,t._forwarding=!1,t._current=null,t._toStreams2=e&&e.objectMode?It:Bt,"function"==typeof r?t._queue=r:(t._queue=r.map(t._toStreams2),t._queue.forEach(function(n){"function"!=typeof n&&t._attachErrorListener(n)})),t._next()):new Tt(r,e)}function It(t){return Lt(t,{objectMode:!0,highWaterMark:16})}function Bt(t){return Lt(t)}function Lt(r,e){if(!r||"function"==typeof r||r._readableState)return r;var t=new st.Readable(e).wrap(r);return r.destroy&&(t.destroy=r.destroy.bind(r)),t}function Rt(n){var e=function(){return e.called?e.value:(e.called=!0,e.value=n.apply(this,arguments))};return e.called=!1,e}function Ut(r){var e=function(){if(e.called)throw new Error(e.onceError);return e.called=!0,e.value=r.apply(this,arguments)},t=r.name||"Function wrapped with `once`";return e.onceError=t+" shouldn't be called more than once",e.called=!1,e}function Pt(t){return Fo.digest(t)}function Nt(r,e){for(var t in r)e[t]=r[t]}function Gt(r,e,t){return rn(r,e,t)}function on(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function an(n,e){n.emit("error",e)}function ln(o,e){var t=this._transformState;t.transforming=!1;var n=t.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));t.writechunk=null,t.writecb=null,null!=e&&this.push(e),n(o);var r=this._readableState;r.reading=!1,(r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}function hn(t){return this instanceof hn?void(pn.call(this,t),this._transformState={afterTransform:ln.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",mn)):new hn(t)}function mn(){var r=this;"function"==typeof this._flush?this._flush(function(e,t){_n(r,e,t)}):_n(this,null,null)}function _n(r,e,t){if(e)return r.emit("error",e);if(null!=t&&r.push(t),r._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(r._transformState.transforming)throw new Error("Calling transform done when still transforming");return r.push(null)}function bn(t){return this instanceof bn?void fn.call(this,t):new bn(t)}function yn(n,e){return Object.prototype.hasOwnProperty.call(n,e)}function wn(o,e){if(o.map)return o.map(e);for(var t=[],n=0;n<o.length;n++)t.push(e(o[n],n));return t}function vn(){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 Bn(o,e,t){if(o&&Qo.isObject(o)&&o instanceof vn)return o;var n=new vn;return n.parse(o,e,t),n}function Mn(t){if("string"==typeof t&&(t=Nn.parse(t)),t.protocol||(t.protocol="https:"),"https:"!==t.protocol)throw new Error("Protocol \""+t.protocol+"\" not supported. Expected \"https:\"");return t}function Dn(n){let e=n>>3;return 0!=n%8&&e++,e}function Zn(){}function rr(t){return Lr(t,{objectMode:!0,highWaterMark:16})}function Er(t){return Lr(t)}function Lr(r,e){if(!r||"function"==typeof r||r._readableState)return r;var t=new st.Readable(e).wrap(r);return r.destroy&&(t.destroy=r.destroy.bind(r)),t}function Br(r,e){var o=this;if(!(o instanceof Br))return new Br(r,e);if(!wd)throw new Error("web browser lacks MediaSource support");e||(e={}),o._debug=e.debug,o._bufferDuration=e.bufferDuration||60,o._elem=r,o._mediaSource=new wd,o._streams=[],o.detailedError=null,o._errorHandler=function(){o._elem.removeEventListener("error",o._errorHandler),o._streams.slice().forEach(function(t){t.destroy(o._elem.error)})},o._elem.addEventListener("error",o._errorHandler),o._elem.src=window.URL.createObjectURL(o._mediaSource)}function Rr(r,e){var t=this;if(st.Writable.call(t),t._wrapper=r,t._elem=r._elem,t._mediaSource=r._mediaSource,t._allStreams=r._streams,t._allStreams.push(t),t._bufferDuration=r._bufferDuration,t._sourceBuffer=null,t._debugBuffers=[],t._openHandler=function(){t._onSourceOpen()},t._flowHandler=function(){t._flow()},t._errorHandler=function(n){t.destroyed||t.emit("error",n)},"string"==typeof e)t._type=e,"open"===t._mediaSource.readyState?t._createSourceBuffer():t._mediaSource.addEventListener("sourceopen",t._openHandler);else if(null===e._sourceBuffer)e.destroy(),t._type=e._type,t._mediaSource.addEventListener("sourceopen",t._openHandler);else{if(!e._sourceBuffer)throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");e.destroy(),t._type=e._type,t._sourceBuffer=e._sourceBuffer,t._debugBuffers=e._debugBuffers,t._sourceBuffer.addEventListener("updateend",t._flowHandler),t._sourceBuffer.addEventListener("error",t._errorHandler)}t._elem.addEventListener("timeupdate",t._flowHandler),t.on("error",function(n){t._wrapper.error(n)}),t.on("finish",function(){if(!t.destroyed&&(t._finished=!0,t._allStreams.every(function(t){return t._finished}))){t._wrapper._dumpDebugData();try{t._mediaSource.endOfStream()}catch(e){}}})}function Ur(r,e,t={}){return this instanceof Ur?void(this.detailedError=null,this._elem=e,this._elemWrapper=new Qr(e),this._waitingFired=!1,this._trackMeta=null,this._file=r,this._tracks=null,"none"!==this._elem.preload&&this._createMuxer(),this._onError=()=>{this.detailedError=this._elemWrapper.detailedError,this.destroy()},this._onWaiting=()=>{this._waitingFired=!0,this._muxer?this._tracks&&this._pump():this._createMuxer()},e.autoplay&&(e.preload="auto"),e.addEventListener("waiting",this._onWaiting),e.addEventListener("error",this._onError)):(console.warn("don't invoked VideoStream without 'new'"),new Ur(r,e,t))}function Mr(p,f,e,g){function t(){return!("number"==typeof p.length&&p.length>e.maxBlobLength&&(Nd("File length too large for Blob URL approach: %d (max: %d)",p.length,e.maxBlobLength),d(new Error("File length too large for Blob URL approach: "+p.length+" (max: "+e.maxBlobLength+")")),1))}function n(e){t()&&(l=f(e),qr(p,function(n,e){return n?d(n):void(l.addEventListener("error",d),l.addEventListener("loadstart",a),l.addEventListener("canplay",c),l.src=e)}))}function a(){l.removeEventListener("loadstart",a),e.autoplay&&l.play()}function c(){l.removeEventListener("canplay",c),g(null,l)}function r(){qr(p,function(t,e){return t?d(t):void(".pdf"===u?((l=f("object")).setAttribute("typemustmatch",!0),l.setAttribute("type","application/pdf"),l.setAttribute("data",e)):((l=f("iframe")).sandbox="allow-forms allow-scripts",l.src=e),g(null,l))})}function d(e){e.message="Error rendering file \""+p.name+"\": "+e.message,Nd(e.message),g(e)}var l,u=pt.extname(p.name).toLowerCase(),s=0;0<=qd.indexOf(u)?function(){function o(){Nd("Use MediaSource API for "+p.name),e(),l.addEventListener("error",i),l.addEventListener("loadstart",a),l.addEventListener("canplay",c);var r,o=new Qr(l).createWriteStream((r=p.name,{".m4a":"audio/mp4; codecs=\"mp4a.40.5\"",".m4b":"audio/mp4; codecs=\"mp4a.40.5\"",".m4p":"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\""}[pt.extname(r).toLowerCase()]));p.createReadStream().pipe(o),s&&(l.currentTime=s)}function r(){Nd("Use Blob URL for "+p.name),e(),l.addEventListener("error",d),l.addEventListener("loadstart",a),l.addEventListener("canplay",c),qr(p,function(n,e){return n?d(n):void(l.src=e,s&&(l.currentTime=s))})}function i(n){Nd("MediaSource API error: fallback to Blob URL: %o",n.message||n),t()&&(l.removeEventListener("error",i),l.removeEventListener("canplay",c),r())}function e(){l||(l=f(h)).addEventListener("progress",function(){s=l.currentTime})}var h=0<=Dd.indexOf(u)?"video":"audio";Vd?0<=Hd.indexOf(u)?(Nd("Use `videostream` package for "+p.name),e(),l.addEventListener("error",function n(e){Nd("videostream error: fallback to MediaSource API: %o",e.message||e),l.removeEventListener("error",n),l.removeEventListener("canplay",c),o()}),l.addEventListener("loadstart",a),l.addEventListener("canplay",c),Md(p,l)):o():r()}():0<=Fd.indexOf(u)?n("video"):0<=Wd.indexOf(u)?n("audio"):0<=jd.indexOf(u)?(l=f("img"),qr(p,function(e,t){return e?d(e):void(l.src=t,l.alt=p.name,g(null,l))})):0<=zd.indexOf(u)?r():function(){Nd("Unknown file extension \"%s\" - will attempt to render into iframe",u);var n="";p.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(t){n+=t}).on("end",function(){Zr(n)?(Nd("File extension \"%s\" appears ascii, so will render.",u),r()):(Nd("File extension \"%s\" appears non-ascii, will not render.",u),g(new Error("Unsupported file type \""+u+"\": Cannot append to DOM")))}).on("error",g)}()}function qr(r,e){var t=pt.extname(r.name).toLowerCase();Sd(r.createReadStream(),Od.mime[t],e)}function Fr(t){if(null==t)throw new Error("file cannot be null or undefined");if("string"!=typeof t.name)throw new Error("missing or invalid file.name property");if("function"!=typeof t.createReadStream)throw new Error("missing or invalid file.createReadStream property")}function Wr(t){null==t.autoplay&&(t.autoplay=!1),null==t.muted&&(t.muted=!1),null==t.controls&&(t.controls=!0),null==t.maxBlobLength&&(t.maxBlobLength=200000000)}var so=function(r){var e;return function(t){return e||r(e={exports:{},parent:t},e.exports),e.exports}},lo=so(function(n,o){(function(p){var g=co({}),m=o,r={moov:["mvhd","meta","traks","mvex"],trak:["tkhd","tref","trgr","edts","meta","mdia","udta"],edts:["elst"],mdia:["mdhd","hdlr","elng","minf"],minf:["vmhd","smhd","hmhd","sthd","nmhd","dinf","stbl"],dinf:["dref"],stbl:["stsd","stts","ctts","cslg","stsc","stsz","stz2","stco","co64","stss","stsh","padb","stdp","sdtp","sbgps","sgpds","subss","saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","tfdt","trun","sbgps","sgpds","subss","saizs","saios","meta"]};m.encode=function(e,t,o){return m.encodingLength(e),o=o||0,t=t||p.alloc(e.length),m._encode(e,t,o)},m._encode=function(d,i,e){var t=d.type,n=d.length;4294967295<n&&(n=1),i.writeUInt32BE(n,e),i.write(d.type,e+4,4,"ascii");var o=e+8;if(1===n&&(Cd.encode(d.length,i,o),o+=8),g.fullBoxes[t]&&(i.writeUInt32BE(d.flags||0,o),i.writeUInt8(d.version||0,o),o+=4),r[t])r[t].forEach(function(e){if(5===e.length){var t=d[e]||[];e=e.substr(0,4),t.forEach(function(t){m._encode(t,i,o),o+=m.encode.bytes})}else d[e]&&(m._encode(d[e],i,o),o+=m.encode.bytes)}),d.otherBoxes&&d.otherBoxes.forEach(function(t){m._encode(t,i,o),o+=m.encode.bytes});else if(g[t]){var s=g[t].encode;s(d,i,o),o+=s.bytes}else{if(!d.buffer)throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");d.buffer.copy(i,o),o+=d.buffer.length}return m.encode.bytes=o-e,i},m.readHeaders=function(r,e,d){if(e=e||0,8>(d=d||r.length)-e)return 8;var l,c,u=r.readUInt32BE(e),f=r.toString("ascii",e+4,e+8),a=e+8;if(1===u){if(16>d-e)return 16;u=Cd.decode(r,a),a+=8}return g.fullBoxes[f]&&(l=r.readUInt8(a),c=16777215&r.readUInt32BE(a),a+=4),{length:u,headersLen:a-e,contentLen:u-(a-e),type:f,version:l,flags:c}},m.decode=function(o,e,d){e=e||0,d=d||o.length;var a=m.readHeaders(o,e,d);if(!a||a.length>d-e)throw new Error("Data too short");return m.decodeWithoutHeaders(a,o,e+a.headersLen,e+a.length)},m.decodeWithoutHeaders=function(e,t,n,i){n=n||0,i=i||t.length;var s=e.type,h={};if(r[s]){h.otherBoxes=[];for(var _,b=r[s],u=n;8<=i-u;)if(_=m.decode(t,u,i),u+=_.length,0<=b.indexOf(_.type))h[_.type]=_;else if(0<=b.indexOf(_.type+"s")){var y=_.type+"s";(h[y]=h[y]||[]).push(_)}else h.otherBoxes.push(_)}else g[s]?h=(0,g[s].decode)(t,n,i):h.buffer=p.from(t.slice(n,i));return h.length=e.length,h.contentLen=e.contentLen,h.type=e.type,h.version=e.version,h.flags=e.flags,h},m.encodingLength=function(o){var e=o.type,d=8;if(g.fullBoxes[e]&&(d+=4),r[e])r[e].forEach(function(n){if(5===n.length){var e=o[n]||[];n=n.substr(0,4),e.forEach(function(t){t.type=n,d+=m.encodingLength(t)})}else if(o[n]){var r=o[n];r.type=n,d+=m.encodingLength(r)}}),o.otherBoxes&&o.otherBoxes.forEach(function(t){d+=m.encodingLength(t)});else if(g[e])d+=g[e].encodingLength(o);else{if(!o.buffer)throw new Error("Either `type` must be set to a known type (not'"+e+"') or `buffer` must be set");d+=o.buffer.length}return 4294967295<d&&(d+=8),o.length=d,d}}).call(this,p({}).Buffer)}),co=so(function(t,m){(function(_){function e(o,e,t){for(var n=e;n<t;n++)o[n]=0}function n(r,e,t){e.writeUInt32BE(io((r.getTime()+2082844800000)/1e3),t)}function o(r,e,t){e.writeUIntBE(io((r.getTime()+2082844800000)/1e3),t,6)}function b(r,e,t){e.writeUInt16BE(io(r)%65536,t),e.writeUInt16BE(io(256*(256*r))%65536,t+2)}function a(o,d,t){o||(o=[0,0,0,0,0,0,0,0,0]);for(var n=0;n<o.length;n++)b(o[n],d,t+4*n)}function i(r){for(var e=Array(r.length/4),t=0;t<e.length;t++)e[t]=l(r,4*t);return e}function s(n,e){return new Date(1e3*n.readUIntBE(e,6)-2082844800000)}function d(n,e){return new Date(1e3*n.readUInt32BE(e)-2082844800000)}function l(n,e){return n.readUInt16BE(e)+n.readUInt16BE(e+2)/65536}function c(n,e){return n[e]+n[e+1]/256}function u(o,e,t){var n;for(n=0;n<t&&0!==o[e+n];n++);return o.toString("utf8",e,e+n)}var f=lo({});m.fullBoxes={},["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","co64","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"].forEach(function(t){m.fullBoxes[t]=!0}),m.ftyp={},m.ftyp.encode=function(e,t,n){t=t?t.slice(n):_.alloc(m.ftyp.encodingLength(e));var d=e.compatibleBrands||[];t.write(e.brand,0,4,"ascii"),t.writeUInt32BE(e.brandVersion,4);for(var a=0;a<d.length;a++)t.write(d[a],8+4*a,4,"ascii");return m.ftyp.encode.bytes=8+4*d.length,t},m.ftyp.decode=function(o,d){for(var t=(o=o.slice(d)).toString("ascii",0,4),n=o.readUInt32BE(4),r=[],a=8;a<o.length;a+=4)r.push(o.toString("ascii",a,a+4));return{brand:t,brandVersion:n,compatibleBrands:r}},m.ftyp.encodingLength=function(t){return 8+4*(t.compatibleBrands||[]).length},m.mvhd={},m.mvhd.encode=function(o,t,d){return t=t?t.slice(d):_.alloc(96),n(o.ctime||new Date,t,0),n(o.mtime||new Date,t,4),t.writeUInt32BE(o.timeScale||0,8),t.writeUInt32BE(o.duration||0,12),b(o.preferredRate||0,t,16),function(n,e){e[20]=io(n)%256,e[21]=io(256*n)%256}(o.preferredVolume||0,t),e(t,22,32),a(o.matrix,t,32),t.writeUInt32BE(o.previewTime||0,68),t.writeUInt32BE(o.previewDuration||0,72),t.writeUInt32BE(o.posterTime||0,76),t.writeUInt32BE(o.selectionTime||0,80),t.writeUInt32BE(o.selectionDuration||0,84),t.writeUInt32BE(o.currentTime||0,88),t.writeUInt32BE(o.nextTrackId||0,92),m.mvhd.encode.bytes=96,t},m.mvhd.decode=function(n,r){return{ctime:d(n=n.slice(r),0),mtime:d(n,4),timeScale:n.readUInt32BE(8),duration:n.readUInt32BE(12),preferredRate:l(n,16),preferredVolume:c(n,20),matrix:i(n.slice(32,68)),previewTime:n.readUInt32BE(68),previewDuration:n.readUInt32BE(72),posterTime:n.readUInt32BE(76),selectionTime:n.readUInt32BE(80),selectionDuration:n.readUInt32BE(84),currentTime:n.readUInt32BE(88),nextTrackId:n.readUInt32BE(92)}},m.mvhd.encodingLength=function(){return 96},m.tkhd={},m.tkhd.encode=function(o,t,d){return t=t?t.slice(d):_.alloc(80),n(o.ctime||new Date,t,0),n(o.mtime||new Date,t,4),t.writeUInt32BE(o.trackId||0,8),e(t,12,16),t.writeUInt32BE(o.duration||0,16),e(t,20,28),t.writeUInt16BE(o.layer||0,28),t.writeUInt16BE(o.alternateGroup||0,30),t.writeUInt16BE(o.volume||0,32),a(o.matrix,t,36),t.writeUInt32BE(o.trackWidth||0,72),t.writeUInt32BE(o.trackHeight||0,76),m.tkhd.encode.bytes=80,t},m.tkhd.decode=function(n,r){return{ctime:d(n=n.slice(r),0),mtime:d(n,4),trackId:n.readUInt32BE(8),duration:n.readUInt32BE(16),layer:n.readUInt16BE(28),alternateGroup:n.readUInt16BE(30),volume:n.readUInt16BE(32),matrix:i(n.slice(36,72)),trackWidth:n.readUInt32BE(72),trackHeight:n.readUInt32BE(76)}},m.tkhd.encodingLength=function(){return 80},m.mdhd={},m.mdhd.encode=function(e,t,d){return 1===e.version?(t=t?t.slice(d):_.alloc(32),o(e.ctime||new Date,t,0),o(e.mtime||new Date,t,8),t.writeUInt32BE(e.timeScale||0,16),t.writeUIntBE(e.duration||0,20,6),t.writeUInt16BE(e.language||0,28),t.writeUInt16BE(e.quality||0,30),m.mdhd.encode.bytes=32,t):(t=t?t.slice(d):_.alloc(20),n(e.ctime||new Date,t,0),n(e.mtime||new Date,t,4),t.writeUInt32BE(e.timeScale||0,8),t.writeUInt32BE(e.duration||0,12),t.writeUInt16BE(e.language||0,16),t.writeUInt16BE(e.quality||0,18),m.mdhd.encode.bytes=20,t)},m.mdhd.decode=function(r,o,t){return r=r.slice(o),20==t-o?{ctime:d(r,0),mtime:d(r,4),timeScale:r.readUInt32BE(8),duration:r.readUInt32BE(12),language:r.readUInt16BE(16),quality:r.readUInt16BE(18)}:{ctime:s(r,0),mtime:s(r,8),timeScale:r.readUInt32BE(16),duration:r.readUIntBE(20,6),language:r.readUInt16BE(28),quality:r.readUInt16BE(30)}},m.mdhd.encodingLength=function(t){return 1===t.version?32:20},m.vmhd={},m.vmhd.encode=function(e,t,n){(t=t?t.slice(n):_.alloc(8)).writeUInt16BE(e.graphicsMode||0,0);var o=e.opcolor||[0,0,0];return t.writeUInt16BE(o[0],2),t.writeUInt16BE(o[1],4),t.writeUInt16BE(o[2],6),m.vmhd.encode.bytes=8,t},m.vmhd.decode=function(n,r){return{graphicsMode:(n=n.slice(r)).readUInt16BE(0),opcolor:[n.readUInt16BE(2),n.readUInt16BE(4),n.readUInt16BE(6)]}},m.vmhd.encodingLength=function(){return 8},m.smhd={},m.smhd.encode=function(n,t,o){return(t=t?t.slice(o):_.alloc(4)).writeUInt16BE(n.balance||0,0),e(t,2,4),m.smhd.encode.bytes=4,t},m.smhd.decode=function(n,r){return{balance:(n=n.slice(r)).readUInt16BE(0)}},m.smhd.encodingLength=function(){return 4},m.stsd={},m.stsd.encode=function(e,t,n){t=t?t.slice(n):_.alloc(m.stsd.encodingLength(e));var r=e.entries||[];t.writeUInt32BE(r.length,0);for(var o,d=4,s=0;s<r.length;s++)o=r[s],f.encode(o,t,d),d+=f.encode.bytes;return m.stsd.encode.bytes=d,t},m.stsd.decode=function(r,d,t){for(var n,l=(r=r.slice(d)).readUInt32BE(0),i=Array(l),s=4,c=0;c<l;c++)n=f.decode(r,s,t),i[c]=n,s+=n.length;return{entries:i}},m.stsd.encodingLength=function(r){var e=4;if(!r.entries)return e;for(var o=0;o<r.entries.length;o++)e+=f.encodingLength(r.entries[o]);return e},m.avc1=m.VisualSampleEntry={},m.VisualSampleEntry.encode=function(n,t,r){e(t=t?t.slice(r):_.alloc(m.VisualSampleEntry.encodingLength(n)),0,6),t.writeUInt16BE(n.dataReferenceIndex||0,6),e(t,8,24),t.writeUInt16BE(n.width||0,24),t.writeUInt16BE(n.height||0,26),t.writeUInt32BE(n.hResolution||4718592,28),t.writeUInt32BE(n.vResolution||4718592,32),e(t,36,40),t.writeUInt16BE(n.frameCount||1,40);var o=n.compressorName||"",d=ao(o.length,31);t.writeUInt8(d,42),t.write(o,43,d,"utf8"),t.writeUInt16BE(n.depth||24,74),t.writeInt16BE(-1,76);var a=78;(n.children||[]).forEach(function(n){f.encode(n,t,a),a+=f.encode.bytes}),m.VisualSampleEntry.encode.bytes=a},m.VisualSampleEntry.decode=function(r,d,t){r=r.slice(d);for(var n,l=t-d,i=ao(r.readUInt8(42),31),s={dataReferenceIndex:r.readUInt16BE(6),width:r.readUInt16BE(24),height:r.readUInt16BE(26),hResolution:r.readUInt32BE(28),vResolution:r.readUInt32BE(32),frameCount:r.readUInt16BE(40),compressorName:r.toString("utf8",43,43+i),depth:r.readUInt16BE(74),children:[]},o=78;8<=l-o;)n=f.decode(r,o,l),s.children.push(n),s[n.type]=n,o+=n.length;return s},m.VisualSampleEntry.encodingLength=function(n){var r=78;return(n.children||[]).forEach(function(t){r+=f.encodingLength(t)}),r},m.avcC={},m.avcC.encode=function(e,t,n){t=t?t.slice(n):_.alloc(e.buffer.length),e.buffer.copy(t),m.avcC.encode.bytes=e.buffer.length},m.avcC.decode=function(e,o,n){return{mimeCodec:(e=e.slice(o,n)).toString("hex",1,4),buffer:_.from(e)}},m.avcC.encodingLength=function(t){return t.buffer.length},m.mp4a=m.AudioSampleEntry={},m.AudioSampleEntry.encode=function(n,t,r){e(t=t?t.slice(r):_.alloc(m.AudioSampleEntry.encodingLength(n)),0,6),t.writeUInt16BE(n.dataReferenceIndex||0,6),e(t,8,16),t.writeUInt16BE(n.channelCount||2,16),t.writeUInt16BE(n.sampleSize||16,18),e(t,20,24),t.writeUInt32BE(n.sampleRate||0,24);var o=28;(n.children||[]).forEach(function(n){f.encode(n,t,o),o+=f.encode.bytes}),m.AudioSampleEntry.encode.bytes=o},m.AudioSampleEntry.decode=function(r,d,t){for(var n,l=t-d,i={dataReferenceIndex:(r=r.slice(d,t)).readUInt16BE(6),channelCount:r.readUInt16BE(16),sampleSize:r.readUInt16BE(18),sampleRate:r.readUInt32BE(24),children:[]},s=28;8<=l-s;)n=f.decode(r,s,l),i.children.push(n),i[n.type]=n,s+=n.length;return i},m.AudioSampleEntry.encodingLength=function(n){var r=28;return(n.children||[]).forEach(function(t){r+=f.encodingLength(t)}),r},m.esds={},m.esds.encode=function(e,t,n){t=t?t.slice(n):_.alloc(e.buffer.length),e.buffer.copy(t,0),m.esds.encode.bytes=e.buffer.length},m.esds.decode=function(e,d,n){e=e.slice(d,n);var r=Ld.Descriptor.decode(e,0,e.length),i=("ESDescriptor"===r.tagName?r:{}).DecoderConfigDescriptor||{},s=i.oti||0,o=i.DecoderSpecificInfo,a=o?(248&o.buffer.readUInt8(0))>>3:0,l=null;return s&&(l=s.toString(16),a&&(l+="."+a)),{mimeCodec:l,buffer:_.from(e.slice(0))}},m.esds.encodingLength=function(t){return t.buffer.length},m.stsz={},m.stsz.encode=function(e,t,n){var d=e.entries||[];(t=t?t.slice(n):_.alloc(m.stsz.encodingLength(e))).writeUInt32BE(0,0),t.writeUInt32BE(d.length,4);for(var a=0;a<d.length;a++)t.writeUInt32BE(d[a],4*a+8);return m.stsz.encode.bytes=8+4*d.length,t},m.stsz.decode=function(o,d){for(var t=(o=o.slice(d)).readUInt32BE(0),n=o.readUInt32BE(4),r=Array(n),a=0;a<n;a++)r[a]=0===t?o.readUInt32BE(4*a+8):t;return{entries:r}},m.stsz.encodingLength=function(t){return 8+4*t.entries.length},m.stss=m.stco={},m.stco.encode=function(e,t,n){var d=e.entries||[];(t=t?t.slice(n):_.alloc(m.stco.encodingLength(e))).writeUInt32BE(d.length,0);for(var a=0;a<d.length;a++)t.writeUInt32BE(d[a],4*a+4);return m.stco.encode.bytes=4+4*d.length,t},m.stco.decode=function(o,d){for(var t=(o=o.slice(d)).readUInt32BE(0),n=Array(t),r=0;r<t;r++)n[r]=o.readUInt32BE(4*r+4);return{entries:n}},m.stco.encodingLength=function(t){return 4+4*t.entries.length},m.co64={},m.co64.encode=function(e,t,n){var d=e.entries||[];(t=t?t.slice(n):_.alloc(m.co64.encodingLength(e))).writeUInt32BE(d.length,0);for(var a=0;a<d.length;a++)Cd.encode(d[a],t,8*a+4);return m.co64.encode.bytes=4+8*d.length,t},m.co64.decode=function(o,d){for(var t=(o=o.slice(d)).readUInt32BE(0),n=Array(t),r=0;r<t;r++)n[r]=Cd.decode(o,8*r+4);return{entries:n}},m.co64.encodingLength=function(t){return 4+8*t.entries.length},m.stts={},m.stts.encode=function(e,t,n){var d=e.entries||[];(t=t?t.slice(n):_.alloc(m.stts.encodingLength(e))).writeUInt32BE(d.length,0);for(var i,s=0;s<d.length;s++)i=8*s+4,t.writeUInt32BE(d[s].count||0,i),t.writeUInt32BE(d[s].duration||0,i+4);return m.stts.encode.bytes=4+8*e.entries.length,t},m.stts.decode=function(o,d){for(var t,a=(o=o.slice(d)).readUInt32BE(0),n=Array(a),r=0;r<a;r++)t=8*r+4,n[r]={count:o.readUInt32BE(t),duration:o.readUInt32BE(t+4)};return{entries:n}},m.stts.encodingLength=function(t){return 4+8*t.entries.length},m.ctts={},m.ctts.encode=function(e,t,n){var d=e.entries||[];(t=t?t.slice(n):_.alloc(m.ctts.encodingLength(e))).writeUInt32BE(d.length,0);for(var i,s=0;s<d.length;s++)i=8*s+4,t.writeUInt32BE(d[s].count||0,i),t.writeUInt32BE(d[s].compositionOffset||0,i+4);return m.ctts.encode.bytes=4+8*d.length,t},m.ctts.decode=function(o,d){for(var t,a=(o=o.slice(d)).readUInt32BE(0),n=Array(a),r=0;r<a;r++)t=8*r+4,n[r]={count:o.readUInt32BE(t),compositionOffset:o.readInt32BE(t+4)};return{entries:n}},m.ctts.encodingLength=function(t){return 4+8*t.entries.length},m.stsc={},m.stsc.encode=function(e,t,n){var d=e.entries||[];(t=t?t.slice(n):_.alloc(m.stsc.encodingLength(e))).writeUInt32BE(d.length,0);for(var i,s=0;s<d.length;s++)i=12*s+4,t.writeUInt32BE(d[s].firstChunk||0,i),t.writeUInt32BE(d[s].samplesPerChunk||0,i+4),t.writeUInt32BE(d[s].sampleDescriptionId||0,i+8);return m.stsc.encode.bytes=4+12*d.length,t},m.stsc.decode=function(o,d){for(var t,a=(o=o.slice(d)).readUInt32BE(0),n=Array(a),r=0;r<a;r++)t=12*r+4,n[r]={firstChunk:o.readUInt32BE(t),samplesPerChunk:o.readUInt32BE(t+4),sampleDescriptionId:o.readUInt32BE(t+8)};return{entries:n}},m.stsc.encodingLength=function(t){return 4+12*t.entries.length},m.dref={},m.dref.encode=function(e,t,n){t=t?t.slice(n):_.alloc(m.dref.encodingLength(e));var d=e.entries||[];t.writeUInt32BE(d.length,0);for(var i=4,s=0;s<d.length;s++){var l=d[s],u=(l.buf?l.buf.length:0)+4+4;t.writeUInt32BE(u,i),i+=4,t.write(l.type,i,4,"ascii"),i+=4,l.buf&&(l.buf.copy(t,i),i+=l.buf.length)}return m.dref.encode.bytes=i,t},m.dref.decode=function(d,l){for(var t=(d=d.slice(l)).readUInt32BE(0),n=Array(t),r=4,c=0;c<t;c++){var u=d.readUInt32BE(r),o=d.toString("ascii",r+4,r+8),a=d.slice(r+8,r+u);r+=u,n[c]={type:o,buf:a}}return{entries:n}},m.dref.encodingLength=function(o){var e=4;if(!o.entries)return e;for(var d,a=0;a<o.entries.length;a++)d=o.entries[a].buf,e+=(d?d.length:0)+4+4;return e},m.elst={},m.elst.encode=function(e,t,n){var d=e.entries||[];(t=t?t.slice(n):_.alloc(m.elst.encodingLength(e))).writeUInt32BE(d.length,0);for(var i,s=0;s<d.length;s++)i=12*s+4,t.writeUInt32BE(d[s].trackDuration||0,i),t.writeUInt32BE(d[s].mediaTime||0,i+4),b(d[s].mediaRate||0,t,i+8);return m.elst.encode.bytes=4+12*d.length,t},m.elst.decode=function(o,d){for(var t,a=(o=o.slice(d)).readUInt32BE(0),n=Array(a),r=0;r<a;r++)t=12*r+4,n[r]={trackDuration:o.readUInt32BE(t),mediaTime:o.readInt32BE(t+4),mediaRate:l(o,t+8)};return{entries:n}},m.elst.encodingLength=function(t){return 4+12*t.entries.length},m.hdlr={},m.hdlr.encode=function(e,t,n){t=t?t.slice(n):_.alloc(m.hdlr.encodingLength(e));var o=21+(e.name||"").length;return t.fill(0,0,o),t.write(e.handlerType||"",4,4,"ascii"),function(e,t){var n=_.from(e,"utf8");n.copy(t,20),t[20+n.length]=0}(e.name||"",t),m.hdlr.encode.bytes=o,t},m.hdlr.decode=function(r,o,t){return{handlerType:(r=r.slice(o)).toString("ascii",4,8),name:u(r,20,t)}},m.hdlr.encodingLength=function(t){return 21+(t.name||"").length},m.mehd={},m.mehd.encode=function(e,t,n){return(t=t?t.slice(n):_.alloc(4)).writeUInt32BE(e.fragmentDuration||0,0),m.mehd.encode.bytes=4,t},m.mehd.decode=function(n,r){return{fragmentDuration:(n=n.slice(r)).readUInt32BE(0)}},m.mehd.encodingLength=function(){return 4},m.trex={},m.trex.encode=function(e,t,n){return(t=t?t.slice(n):_.alloc(20)).writeUInt32BE(e.trackId||0,0),t.writeUInt32BE(e.defaultSampleDescriptionIndex||0,4),t.writeUInt32BE(e.defaultSampleDuration||0,8),t.writeUInt32BE(e.defaultSampleSize||0,12),t.writeUInt32BE(e.defaultSampleFlags||0,16),m.trex.encode.bytes=20,t},m.trex.decode=function(n,r){return{trackId:(n=n.slice(r)).readUInt32BE(0),defaultSampleDescriptionIndex:n.readUInt32BE(4),defaultSampleDuration:n.readUInt32BE(8),defaultSampleSize:n.readUInt32BE(12),defaultSampleFlags:n.readUInt32BE(16)}},m.trex.encodingLength=function(){return 20},m.mfhd={},m.mfhd.encode=function(e,t,n){return(t=t?t.slice(n):_.alloc(4)).writeUInt32BE(e.sequenceNumber||0,0),m.mfhd.encode.bytes=4,t},m.mfhd.decode=function(t){return{sequenceNumber:t.readUInt32BE(0)}},m.mfhd.encodingLength=function(){return 4},m.tfhd={},m.tfhd.encode=function(e,t,n){return(t=t?t.slice(n):_.alloc(4)).writeUInt32BE(e.trackId,0),m.tfhd.encode.bytes=4,t},m.tfhd.decode=function(){},m.tfhd.encodingLength=function(){return 4},m.tfdt={},m.tfdt.encode=function(e,t,n){return(t=t?t.slice(n):_.alloc(4)).writeUInt32BE(e.baseMediaDecodeTime||0,0),m.tfdt.encode.bytes=4,t},m.tfdt.decode=function(){},m.tfdt.encodingLength=function(){return 4},m.trun={},m.trun.encode=function(e,t,n){(t=t?t.slice(n):_.alloc(8+16*e.entries.length)).writeUInt32BE(e.entries.length,0),t.writeInt32BE(e.dataOffset,4);for(var d,i=8,l=0;l<e.entries.length;l++)d=e.entries[l],t.writeUInt32BE(d.sampleDuration,i),i+=4,t.writeUInt32BE(d.sampleSize,i),i+=4,t.writeUInt32BE(d.sampleFlags,i),i+=4,0===(e.version||0)?t.writeUInt32BE(d.sampleCompositionTimeOffset,i):t.writeInt32BE(d.sampleCompositionTimeOffset,i),i+=4;m.trun.encode.bytes=i},m.trun.decode=function(){},m.trun.encodingLength=function(t){return 8+16*t.entries.length},m.mdat={},m.mdat.encode=function(n,e,t){n.buffer?(n.buffer.copy(e,t),m.mdat.encode.bytes=n.buffer.length):m.mdat.encode.bytes=m.mdat.encodingLength(n)},m.mdat.decode=function(e,t,n){return{buffer:_.from(e.slice(t,n))}},m.mdat.encodingLength=function(t){return t.buffer?t.buffer.length:t.contentLength}}).call(this,p({}).Buffer)}),t=so(function(i){(function(_,e){"use strict";function t(r,d){r=r||{};var t=d instanceof(L=L||fo({}));this.objectMode=!!r.objectMode,t&&(this.objectMode=this.objectMode||!!r.readableObjectMode);var n=r.highWaterMark,o=r.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:t&&(o||0===o)?o:a,this.highWaterMark=io(this.highWaterMark),this.buffer=new cn,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.destroyed=!1,this.defaultEncoding=r.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,r.encoding&&(I||(I=uo({}).StringDecoder),this.decoder=new I(r.encoding),this.encoding=r.encoding)}function n(r){return(L=L||fo({}),!(this instanceof n))?new n(r):void(this._readableState=new t(r,this),this.readable=!0,r&&("function"==typeof r.read&&(this._read=r.read),"function"==typeof r.destroy&&(this._destroy=r.destroy)),en.call(this))}function s(d,e,a,n,r){var i,c=d._readableState;return null===e?(c.reading=!1,function(r,e){if(!e.ended){if(e.decoder){var t=e.decoder.end();t&&t.length&&(e.buffer.push(t),e.length+=e.objectMode?1:t.length)}e.ended=!0,p(r)}}(d,c)):(r||(i=function(d,e){var t,a;return a=e,B.isBuffer(a)||a instanceof o||"string"==typeof e||void 0===e||d.objectMode||(t=new TypeError("Invalid non-string/buffer chunk")),t}(c,e)),i?d.emit("error",i):c.objectMode||e&&0<e.length?("string"==typeof e||c.objectMode||Object.getPrototypeOf(e)===B.prototype||(e=function(t){return B.from(t)}(e)),n?c.endEmitted?d.emit("error",new Error("stream.unshift() after end event")):l(d,c,e,!0):c.ended?d.emit("error",new Error("stream.push() after EOF")):(c.reading=!1,c.decoder&&!a?(e=c.decoder.write(e),c.objectMode||0!==e.length?l(d,c,e,!1):b(d,c)):l(d,c,e,!1))):n||(c.reading=!1)),function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(c)}function l(o,e,t,n){e.flowing&&0===e.length&&!e.sync?(o.emit("data",t),o.read(0)):(e.length+=e.objectMode?1:t.length,n?e.buffer.unshift(t):e.buffer.push(t),e.needReadable&&p(o)),b(o,e)}function f(n,e){return 0>=n||0===e.length&&e.ended?0:e.objectMode?1:n==n?(n>e.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(n)),n<=e.length?n:e.ended?e.length:(e.needReadable=!0,0)):e.flowing&&e.length?e.buffer.head.data.length:e.length}function p(n){var e=n._readableState;e.needReadable=!1,e.emittedReadable||(R("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?Xt.nextTick(g,n):g(n))}function g(t){R("emit readable"),t.emit("readable"),S(t)}function b(n,e){e.readingMore||(e.readingMore=!0,Xt.nextTick(y,n,e))}function y(r,e){for(var t=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(R("maybeReadMore read 0"),r.read(0),t!==e.length);)t=e.length;e.readingMore=!1}function w(t){R("readable nexttick read 0"),t.read(0)}function k(n,e){e.reading||(R("resume read 0"),n.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,n.emit("resume"),S(n),e.flowing&&!e.reading&&n.read(0)}function S(n){var e=n._readableState;for(R("flow",e.flowing);e.flowing&&null!==n.read(););}function E(r,e){return 0===e.length?null:(e.objectMode?t=e.buffer.shift():!r||r>=e.length?(t=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):t=function(o,e,t){var n;return o<e.head.data.length?(n=e.head.data.slice(0,o),e.head.data=e.head.data.slice(o)):n=o===e.head.data.length?e.shift():t?function(d,a){var t=a.head,l=1,c=t.data;for(d-=c.length;t=t.next;){var u=t.data,s=d>u.length?u.length:d;if(c+=s===u.length?u:u.slice(0,d),0==(d-=s)){s===u.length?(++l,a.head=t.next?t.next:a.tail=null):(a.head=t,t.data=u.slice(s));break}++l}return a.length-=l,c}(o,e):function(d,a){var t=B.allocUnsafe(d),n=a.head,l=1;for(n.data.copy(t),d-=n.data.length;n=n.next;){var c=n.data,s=d>c.length?c.length:d;if(c.copy(t,t.length-d,0,s),0==(d-=s)){s===c.length?(++l,a.head=n.next?n.next:a.tail=null):(a.head=n,n.data=c.slice(s));break}++l}return a.length-=l,t}(o,e),n}(r,e.buffer,e.decoder),t);var t}function v(n){var e=n._readableState;if(0<e.length)throw new Error("\"endReadable()\" called on non-empty stream");e.endEmitted||(e.ended=!0,Xt.nextTick(C,e,n))}function C(n,e){n.endEmitted||0!==n.length||(n.endEmitted=!0,e.readable=!1,e.emit("end"))}function x(o,e){for(var t=0,d=o.length;t<d;t++)if(o[t]===e)return t;return-1}var L;i.exports=n,n.ReadableState=t,m.EventEmitter;var T=function(n,e){return n.listeners(e).length},B=tn.Buffer,o=e.Uint8Array||function(){};sn.inherits=Me;var I,R;R=oe&&oe.debuglog?oe.debuglog("stream"):function(){},sn.inherits(n,en);var a=["error","close","destroy","pause","resume"];Object.defineProperty(n.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),n.prototype.destroy=dn.destroy,n.prototype._undestroy=dn.undestroy,n.prototype._destroy=function(n,e){this.push(null),e(n)},n.prototype.push=function(o,d){var a,i=this._readableState;return i.objectMode?a=!0:"string"==typeof o&&((d=d||i.defaultEncoding)!==i.encoding&&(o=B.from(o,d),d=""),a=!0),s(this,o,d,!1,a)},n.prototype.unshift=function(t){return s(this,t,null,!0,!1)},n.prototype.isPaused=function(){return!1===this._readableState.flowing},n.prototype.setEncoding=function(t){return I||(I=uo({}).StringDecoder),this._readableState.decoder=new I(t),this._readableState.encoding=t,this};n.prototype.read=function(o){R("read",o),o=parseInt(o,10);var d=this._readableState,t=o;if(0!==o&&(d.emittedReadable=!1),0===o&&d.needReadable&&(d.length>=d.highWaterMark||d.ended))return R("read: emitReadable",d.length,d.ended),0===d.length&&d.ended?v(this):p(this),null;if(0===(o=f(o,d))&&d.ended)return 0===d.length&&v(this),null;var n,a=d.needReadable;return R("need readable",a),(0===d.length||d.length-o<d.highWaterMark)&&R("length less than watermark",a=!0),d.ended||d.reading?R("reading or ended",a=!1):a&&(R("do read"),d.reading=!0,d.sync=!0,0===d.length&&(d.needReadable=!0),this._read(d.highWaterMark),d.sync=!1,d.reading||(o=f(t,d))),null===(n=0<o?E(o,d):null)?(d.needReadable=!0,o=0):d.length-=o,0===d.length&&(d.ended||(d.needReadable=!0),t!==o&&d.ended&&v(this)),null!==n&&this.emit("data",n),n},n.prototype._read=function(){this.emit("error",new Error("_read() is not implemented"))},n.prototype.pipe=function(o,e){function u(){R("onend"),o.end()}function a(e){R("ondata"),n=!1,!1!==o.write(e)||n||((1===r.pipesCount&&r.pipes===o||1<r.pipesCount&&-1!==x(r.pipes,o))&&!h&&(R("false write response, pause",m._readableState.awaitDrain),m._readableState.awaitDrain++,n=!0),m.pause())}function l(e){R("onerror",e),g(),o.removeListener("error",l),0===T(o,"error")&&o.emit("error",e)}function f(){o.removeListener("finish",p),g()}function p(){R("onfinish"),o.removeListener("close",f),g()}function g(){R("unpipe"),m.unpipe(o)}var m=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=o;break;case 1:r.pipes=[r.pipes,o];break;default:r.pipes.push(o);}r.pipesCount+=1,R("pipe count=%d opts=%j",r.pipesCount,e);var t=e&&!1===e.end||o===_.stdout||o===_.stderr?g:u;r.endEmitted?Xt.nextTick(t):m.once("end",t),o.on("unpipe",function e(t,n){R("onunpipe"),t===m&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,R("cleanup"),o.removeListener("close",f),o.removeListener("finish",p),o.removeListener("drain",i),o.removeListener("error",l),o.removeListener("unpipe",e),m.removeListener("end",u),m.removeListener("end",g),m.removeListener("data",a),h=!0,!r.awaitDrain||o._writableState&&!o._writableState.needDrain||i())});var i=function(n){return function(){var e=n._readableState;R("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&T(n,"data")&&(e.flowing=!0,S(n))}}(m);o.on("drain",i);var h=!1,n=!1;return m.on("data",a),function(r,e,t){return"function"==typeof r.prependListener?r.prependListener("error",t):void(r._events&&r._events.error?Qt(r._events.error)?r._events.error.unshift(t):r._events.error=[t,r._events.error]:r.on("error",t))}(o,0,l),o.once("close",f),o.once("finish",p),o.emit("pipe",m),r.flowing||(R("pipe resume"),m.resume()),o},n.prototype.unpipe=function(d){var a=this._readableState,t={hasUnpiped:!1};if(0===a.pipesCount)return this;if(1===a.pipesCount)return d&&d!==a.pipes?this:(d||(d=a.pipes),a.pipes=null,a.pipesCount=0,a.flowing=!1,d&&d.emit("unpipe",this,t),this);if(!d){var n=a.pipes,r=a.pipesCount;a.pipes=null,a.pipesCount=0,a.flowing=!1;for(var i=0;i<r;i++)n[i].emit("unpipe",this,t);return this}var l=x(a.pipes,d);return-1===l?this:(a.pipes.splice(l,1),a.pipesCount-=1,1===a.pipesCount&&(a.pipes=a.pipes[0]),d.emit("unpipe",this,t),this)},n.prototype.on=function(o,e){var t=en.prototype.on.call(this,o,e);if("data"===o)!1!==this._readableState.flowing&&this.resume();else if("readable"===o){var n=this._readableState;n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&p(this):Xt.nextTick(w,this))}return t},n.prototype.addListener=n.prototype.on,n.prototype.resume=function(){var t=this._readableState;return t.flowing||(R("resume"),t.flowing=!0,function(n,e){e.resumeScheduled||(e.resumeScheduled=!0,Xt.nextTick(k,n,e))}(this,t)),this},n.prototype.pause=function(){return R("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(R("pause"),this._readableState.flowing=!1,this.emit("pause")),this},n.prototype.wrap=function(o){var d=this,t=this._readableState,e=!1;for(var n in o.on("end",function(){if(R("wrapped end"),t.decoder&&!t.ended){var n=t.decoder.end();n&&n.length&&d.push(n)}d.push(null)}),o.on("data",function(n){R("wrapped data"),t.decoder&&(n=t.decoder.write(n)),t.objectMode&&null==n||(t.objectMode||n&&n.length)&&(d.push(n)||(e=!0,o.pause()))}),o)void 0===this[n]&&"function"==typeof o[n]&&(this[n]=function(e){return function(){return o[e].apply(o,arguments)}}(n));for(var i=0;i<a.length;i++)o.on(a[i],this.emit.bind(this,a[i]));return this._read=function(n){R("wrapped _read",n),e&&(e=!1,o.resume())},this},Object.defineProperty(n.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),n._fromList=E}).call(this,pe,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)}),uo=so(function(f,e){"use strict";function t(r){var e;switch(this.encoding=function(r){var e=function(n){if(!n)return"utf8";for(var r;;)switch(n){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 n;default:if(r)return;n=(""+n).toLowerCase(),r=!0;}}(r);if("string"!=typeof e&&(l.isEncoding===n||!n(r)))throw new Error("Unknown encoding: "+r);return e||r}(r),this.encoding){case"utf16le":this.text=o,this.end=a,e=4;break;case"utf8":this.fillLast=i,e=4;break;case"base64":this.text=s,this.end=c,e=3;break;default:return this.write=u,void(this.end=d);}this.lastNeed=0,this.lastTotal=0,this.lastChar=l.allocUnsafe(e)}function p(t){return 127>=t?0:6==t>>5?2:14==t>>4?3:30==t>>3?4:2==t>>6?-1:-2}function i(r){var e=this.lastTotal-this.lastNeed,t=function(n,e){if(128!=(192&e[0]))return n.lastNeed=0,"\uFFFD";if(1<n.lastNeed&&1<e.length){if(128!=(192&e[1]))return n.lastNeed=1,"\uFFFD";if(2<n.lastNeed&&2<e.length&&128!=(192&e[2]))return n.lastNeed=2,"\uFFFD"}}(this,r);return void 0===t?this.lastNeed<=r.length?(r.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(r.copy(this.lastChar,e,0,r.length),void(this.lastNeed-=r.length)):t}function o(o,e){if(0==(o.length-e)%2){var t=o.toString("utf16le",e);if(t){var n=t.charCodeAt(t.length-1);if(55296<=n&&56319>=n)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=o[o.length-2],this.lastChar[1]=o[o.length-1],t.slice(0,-1)}return t}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=o[o.length-1],o.toString("utf16le",e,o.length-1)}function a(r){var e=r&&r.length?this.write(r):"";if(this.lastNeed){var t=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,t)}return e}function s(r,e){var t=(r.length-e)%3;return 0==t?r.toString("base64",e):(this.lastNeed=3-t,this.lastTotal=3,1==t?this.lastChar[0]=r[r.length-1]:(this.lastChar[0]=r[r.length-2],this.lastChar[1]=r[r.length-1]),r.toString("base64",e,r.length-t))}function c(n){var e=n&&n.length?this.write(n):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function u(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}var l=tn.Buffer,n=l.isEncoding||function(t){switch((t=""+t)&&t.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;}};e.StringDecoder=t,t.prototype.write=function(r){if(0===r.length)return"";var e,o;if(this.lastNeed){if(void 0===(e=this.fillLast(r)))return"";o=this.lastNeed,this.lastNeed=0}else o=0;return o<r.length?e?e+this.text(r,o):this.text(r,o):e||""},t.prototype.end=function(n){var e=n&&n.length?this.write(n):"";return this.lastNeed?e+"\uFFFD":e},t.prototype.text=function(o,e){var t=function(o,e,t){var n=e.length-1;if(n<t)return 0;var d=p(e[n]);return 0<=d?(0<d&&(o.lastNeed=d-1),d):--n<t||-2===d?0:0<=(d=p(e[n]))?(0<d&&(o.lastNeed=d-2),d):--n<t||-2===d?0:0<=(d=p(e[n]))?(0<d&&(2===d?d=0:o.lastNeed=d-3),d):0}(this,o,e);if(!this.lastNeed)return o.toString("utf8",e);this.lastTotal=t;var n=o.length-(t-this.lastNeed);return o.copy(this.lastChar,0,n),o.toString("utf8",e,n)},t.prototype.fillLast=function(t){return this.lastNeed<=t.length?(t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length)}}),fo=so(function(o){"use strict";function f(t){return this instanceof f?void(n.call(this,t),i.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",u)):new f(t)}function u(){this.allowHalfOpen||this._writableState.ended||Xt.nextTick(e,this)}function e(t){t.end()}var d=Object.keys||function(r){var e=[];for(var t in r)e.push(t);return e};o.exports=f,sn.inherits=Me;var n=t({}),i=r({});sn.inherits(f,n);for(var s,l=d(i.prototype),a=0;a<l.length;a++)s=l[a],f.prototype[s]||(f.prototype[s]=i.prototype[s]);Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"destroyed",{get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}),f.prototype._destroy=function(n,e){this.push(null),this.end(),Xt.nextTick(e,n)}}),r=so(function(s){(function(e,t,n){"use strict";function S(n){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(n,e){var t=n.entry;for(n.entry=null;t;){var o=t.callback;e.pendingcb--,o(void 0),t=t.next}e.corkedRequestsFree?e.corkedRequestsFree.next=n:e.corkedRequestsFree=n}(e,n)}}function k(){}function r(o,d){b=b||fo({}),o=o||{};var t=d instanceof b;this.objectMode=!!o.objectMode,t&&(this.objectMode=this.objectMode||!!o.writableObjectMode);var n=o.highWaterMark,r=o.writableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=n||0===n?n:t&&(r||0===r)?r:a,this.highWaterMark=io(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var i=!1===o.decodeStrings;this.decodeStrings=!i,this.defaultEncoding=o.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(o,e){var t=o._writableState,n=t.sync,r=t.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(t),e)!function(o,e,t,n,r){--e.pendingcb,t?(Xt.nextTick(r,n),Xt.nextTick(_,o,e),o._writableState.errorEmitted=!0,o.emit("error",n)):(r(n),o._writableState.errorEmitted=!0,o.emit("error",n),_(o,e))}(o,t,n,e,r);else{var d=g(t);d||t.corked||t.bufferProcessing||!t.bufferedRequest||p(o,t),n?y(f,o,t,d,r):f(o,t,d,r)}}(d,t)},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 S(this)}function i(t){return(b=b||fo({}),!(a.call(i,this)||this instanceof b))?new i(t):void(this._writableState=new r(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),en.call(this))}function l(d,e,t,n,r,a,i){e.writelen=n,e.writecb=i,e.writing=!0,e.sync=!0,t?d._writev(r,e.onwrite):d._write(r,a,e.onwrite),e.sync=!1}function f(o,e,t,n){t||function(n,e){0===e.length&&e.needDrain&&(e.needDrain=!1,n.emit("drain"))}(o,e),e.pendingcb--,n(),_(o,e)}function p(i,e){e.bufferProcessing=!0;var t=e.bufferedRequest;if(i._writev&&t&&t.next){var f=e.bufferedRequestCount,r=Array(f),s=e.corkedRequestsFree;s.entry=t;for(var o=0,p=!0;t;)r[o]=t,t.isBuf||(p=!1),t=t.next,o+=1;r.allBuffers=p,l(i,e,!0,e.length,r,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new S(e),e.bufferedRequestCount=0}else{for(;t;){var g=t.chunk,c=t.encoding,u=t.callback;if(l(i,e,!1,e.objectMode?1:g.length,g,c,u),t=t.next,e.bufferedRequestCount--,e.writing)break}null===t&&(e.lastBufferedRequest=null)}e.bufferedRequest=t,e.bufferProcessing=!1}function g(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function m(r,e){r._final(function(t){e.pendingcb--,t&&r.emit("error",t),e.prefinished=!0,r.emit("prefinish"),_(r,e)})}function _(r,e){var t=g(e);return t&&(function(n,e){e.prefinished||e.finalCalled||("function"==typeof n._final?(e.pendingcb++,e.finalCalled=!0,Xt.nextTick(m,n,e)):(e.prefinished=!0,n.emit("prefinish")))}(r,e),0===e.pendingcb&&(e.finished=!0,r.emit("finish"))),t}s.exports=i;var b,y=!e.browser&&-1<["v0.10","v0.9."].indexOf(e.version.slice(0,5))?n:Xt.nextTick;i.WritableState=r,sn.inherits=Me;var a,w={deprecate:xo},c=tn.Buffer,u=t.Uint8Array||function(){};sn.inherits(i,en),r.prototype.getBuffer=function(){for(var n=this.bufferedRequest,r=[];n;)r.push(n),n=n.next;return r},function(){try{Object.defineProperty(r.prototype,"buffer",{get:w.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(i,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===i&&t&&t._writableState instanceof r}})):a=function(t){return t instanceof this},i.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},i.prototype.write=function(d,a,f){var p,h=this._writableState,i=!1,g=!h.objectMode&&(p=d,c.isBuffer(p)||p instanceof u);return g&&!c.isBuffer(d)&&(d=function(t){return c.from(t)}(d)),"function"==typeof a&&(f=a,a=null),g?a="buffer":a||(a=h.defaultEncoding),"function"!=typeof f&&(f=k),h.ended?function(r,e){var t=new Error("write after end");r.emit("error",t),Xt.nextTick(e,t)}(this,f):(g||function(o,e,t,n){var r=!0,d=!1;return null===t?d=new TypeError("May not write null values to stream"):"string"==typeof t||void 0===t||e.objectMode||(d=new TypeError("Invalid non-string/buffer chunk")),d&&(o.emit("error",d),Xt.nextTick(n,d),r=!1),r}(this,h,d,f))&&(h.pendingcb++,i=function(d,e,t,u,f,p){if(!t){var s=function(r,e,o){return r.objectMode||!1===r.decodeStrings||"string"!=typeof e||(e=c.from(e,o)),e}(e,u,f);u!==s&&(t=!0,f="buffer",u=s)}var o=e.objectMode?1:u.length;e.length+=o;var a=e.length<e.highWaterMark;if(a||(e.needDrain=!0),e.writing||e.corked){var h=e.lastBufferedRequest;e.lastBufferedRequest={chunk:u,encoding:f,isBuf:t,callback:p,next:null},h?h.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else l(d,e,!1,o,u,f,p);return a}(this,h,g,d,a,f)),i},i.prototype.cork=function(){this._writableState.corked++},i.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.finished||t.bufferProcessing||!t.bufferedRequest||p(this,t))},i.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(i.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),i.prototype._write=function(r,e,t){t(new Error("_write() is not implemented"))},i.prototype._writev=null,i.prototype.end=function(o,d,a){var i=this._writableState;"function"==typeof o?(a=o,o=null,d=null):"function"==typeof d&&(a=d,d=null),null!=o&&this.write(o,d),i.corked&&(i.corked=1,this.uncork()),i.ending||i.finished||function(r,e,t){e.ending=!0,_(r,e),t&&(e.finished?Xt.nextTick(t):r.once("finish",t)),e.ended=!0,r.writable=!1}(this,i,a)},Object.defineProperty(i.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),i.prototype.destroy=dn.destroy,i.prototype._undestroy=dn.undestroy,i.prototype._destroy=function(n,e){this.end(),e(n)}}).call(this,pe,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,o({}).setImmediate)}),o=so(function(n,d){(function(t,e){function n(n,e){this._id=n,this._clearFn=e}var l=pe.nextTick,r=(Function.prototype.apply,Array.prototype.slice),i={},s=0;n.prototype.unref=n.prototype.ref=function(){},n.prototype.close=function(){this._clearFn.call(window,this._id)},d.setImmediate="function"==typeof t?t:function(t){var e=s++,n=!(2>arguments.length)&&r.call(arguments,1);return i[e]=!0,l(function(){i[e]&&(n?t.apply(null,n):t.call(null),d.clearImmediate(e))}),e},d.clearImmediate="function"==typeof e?e:function(t){delete i[t]}}).call(this,o({}).setImmediate,o({}).clearImmediate)}),a=so(function(t){var o=Math.round;function n(d,e,t,n){return o(d/t)+" "+n+(e>=1.5*t?"s":"")}t.exports=function(r,e){e=e||{};var d,i,s=typeof r;if("string"==s&&0<r.length)return function(n){if(!(100<(n=n+"").length)){var r=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(n);if(r){var t=parseFloat(r[1]);switch((r[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*t;case"weeks":case"week":case"w":return 6048e5*t;case"days":case"day":case"d":return t*86400000;case"hours":case"hour":case"hrs":case"hr":case"h":return t*3600000;case"minutes":case"minute":case"mins":case"min":case"m":return t*60000;case"seconds":case"second":case"secs":case"sec":case"s":return t*1000;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:}}}}(r);if("number"==s&&isFinite(r))return e.long?(d=r,86400000<=(i=oo(d))?n(d,i,86400000,"day"):3600000<=i?n(d,i,3600000,"hour"):60000<=i?n(d,i,60000,"minute"):1000<=i?n(d,i,1000,"second"):d+" ms"):function(n){var e=oo(n);return 86400000<=e?o(n/86400000)+"d":3600000<=e?o(n/3600000)+"h":60000<=e?o(n/60000)+"m":1000<=e?o(n/1000)+"s":n+"ms"}(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))}}),e=so(function(t){t.exports=function(n,e,t){for(var r,d,l,u=1/0,f=0,p=e.length-1;f<=p&&(0>(l=e[r=f+(p-f>>1)]-n)?f=r+1:0<l&&(p=r-1),(l=oo(l))<u&&(u=l,d=r),e[r]!==n););return t?d:e[d]}}),po=so(function(f){(function(_,e){"use strict";function n(r,o,t){H=H||l({}),r=r||{},"boolean"!=typeof t&&(t=o instanceof H),this.objectMode=!!r.objectMode,t&&(this.objectMode=this.objectMode||!!r.readableObjectMode),this.highWaterMark=W(this,r,"readableHighWaterMark",t),this.buffer=new fe,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.paused=!0,this.emitClose=!1!==r.emitClose,this.destroyed=!1,this.defaultEncoding=r.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,r.encoding&&(a||(a=d({}).StringDecoder),this.decoder=new a(r.encoding),this.encoding=r.encoding)}function k(r){if(H=H||l({}),!(this instanceof k))return new k(r);var e=this instanceof H;this._readableState=new n(r,this,e),this.readable=!0,r&&("function"==typeof r.read&&(this._read=r.read),"function"==typeof r.destroy&&(this._destroy=r.destroy)),yo.call(this)}function S(d,e,a,n,r){D("readableAddChunk",e);var i,s=d._readableState;if(null===e)s.reading=!1,function(r,e){if(!e.ended){if(e.decoder){var t=e.decoder.end();t&&t.length&&(e.buffer.push(t),e.length+=e.objectMode?1:t.length)}e.ended=!0,e.sync?T(r):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(r)))}}(d,s);else if(r||(i=function(d,e){var t,a;return a=e,F.isBuffer(a)||a instanceof o||"string"==typeof e||void 0===e||d.objectMode||(t=new j("chunk",["string","Buffer","Uint8Array"],e)),t}(s,e)),i)d.emit("error",i);else if(!(s.objectMode||e&&0<e.length))n||(s.reading=!1,R(d,s));else if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===F.prototype||(e=function(t){return F.from(t)}(e)),n)s.endEmitted?d.emit("error",new b):C(d,s,e,!0);else if(s.ended)d.emit("error",new g);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!a?(e=s.decoder.write(e),s.objectMode||0!==e.length?C(d,s,e,!1):R(d,s)):C(d,s,e,!1)}return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function C(o,e,t,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,o.emit("data",t)):(e.length+=e.objectMode?1:t.length,n?e.buffer.unshift(t):e.buffer.push(t),e.needReadable&&T(o)),R(o,e)}function x(n,e){return 0>=n||0===e.length&&e.ended?0:e.objectMode?1:n==n?(n>e.highWaterMark&&(e.highWaterMark=function(t){return t>=8388608?t=8388608:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(n)),n<=e.length?n:e.ended?e.length:(e.needReadable=!0,0)):e.flowing&&e.length?e.buffer.head.data.length:e.length}function T(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(D("emitReadable",e.flowing),e.emittedReadable=!0,_.nextTick(I,t))}function I(n){var e=n._readableState;D("emitReadable_",e.destroyed,e.length,e.ended),!e.destroyed&&(e.length||e.ended)&&n.emit("readable"),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,U(n)}function R(r,e){e.readingMore||(e.readingMore=!0,_.nextTick(t,r,e))}function t(r,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var t=e.length;if(D("maybeReadMore read 0"),r.read(0),t===e.length)break}e.readingMore=!1}function L(n){var e=n._readableState;e.readableListening=0<n.listenerCount("readable"),e.resumeScheduled&&!e.paused?e.flowing=!0:0<n.listenerCount("data")&&n.resume()}function B(t){D("readable nexttick read 0"),t.read(0)}function A(n,e){D("resume",e.reading),e.reading||n.read(0),e.resumeScheduled=!1,n.emit("resume"),U(n),e.flowing&&!e.reading&&n.read(0)}function U(n){var e=n._readableState;for(D("flow",e.flowing);e.flowing&&null!==n.read(););}function P(r,e){return 0===e.length?null:(e.objectMode?t=e.buffer.shift():!r||r>=e.length?(t=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):t=e.buffer.consume(r,e.decoder),t);var t}function M(t){var e=t._readableState;D("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,_.nextTick(O,e,t))}function O(n,e){D("endReadableNT",n.endEmitted,n.length),n.endEmitted||0!==n.length||(n.endEmitted=!0,e.readable=!1,e.emit("end"))}function N(o,e){for(var t=0,d=o.length;t<d;t++)if(o[t]===e)return t;return-1}var H;f.exports=k,k.ReadableState=n,m.EventEmitter;var D,q=function(n,e){return n.listeners(e).length},F=p({}).Buffer,o=e.Uint8Array||function(){};D=oe&&oe.debuglog?oe.debuglog("stream"):function(){};var a,s,W=Ue.getHighWaterMark,u=Co.codes,j=u.ERR_INVALID_ARG_TYPE,g=u.ERR_STREAM_PUSH_AFTER_EOF,y=u.ERR_METHOD_NOT_IMPLEMENTED,b=u.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,w=Oe.emitExperimentalWarning;Me(k,yo);var v=["error","close","destroy","pause","resume"];Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),k.prototype.destroy=vo.destroy,k.prototype._undestroy=vo.undestroy,k.prototype._destroy=function(n,e){e(n)},k.prototype.push=function(o,d){var a,i=this._readableState;return i.objectMode?a=!0:"string"==typeof o&&((d=d||i.defaultEncoding)!==i.encoding&&(o=F.from(o,d),d=""),a=!0),S(this,o,d,!1,a)},k.prototype.unshift=function(t){return S(this,t,null,!0,!1)},k.prototype.isPaused=function(){return!1===this._readableState.flowing},k.prototype.setEncoding=function(t){return a||(a=d({}).StringDecoder),this._readableState.decoder=new a(t),this._readableState.encoding=this._readableState.decoder.encoding,this};k.prototype.read=function(o){D("read",o),o=parseInt(o,10);var d=this._readableState,t=o;if(0!==o&&(d.emittedReadable=!1),0===o&&d.needReadable&&((0===d.highWaterMark?0<d.length:d.length>=d.highWaterMark)||d.ended))return D("read: emitReadable",d.length,d.ended),0===d.length&&d.ended?M(this):T(this),null;if(0===(o=x(o,d))&&d.ended)return 0===d.length&&M(this),null;var n,a=d.needReadable;return D("need readable",a),(0===d.length||d.length-o<d.highWaterMark)&&D("length less than watermark",a=!0),d.ended||d.reading?D("reading or ended",a=!1):a&&(D("do read"),d.reading=!0,d.sync=!0,0===d.length&&(d.needReadable=!0),this._read(d.highWaterMark),d.sync=!1,d.reading||(o=x(t,d))),null===(n=0<o?P(o,d):null)?(d.needReadable=!0,o=0):(d.length-=o,d.awaitDrain=0),0===d.length&&(d.ended||(d.needReadable=!0),t!==o&&d.ended&&M(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(){this.emit("error",new y("_read()"))},k.prototype.pipe=function(i,e){function m(){D("onend"),i.end()}function h(e){D("ondata");var t=i.write(e);D("dest.write",t),!1===t&&((1===r.pipesCount&&r.pipes===i||1<r.pipesCount&&-1!==N(r.pipes,i))&&!a&&(D("false write response, pause",r.awaitDrain),r.awaitDrain++),g.pause())}function d(e){D("onerror",e),p(),i.removeListener("error",d),0===q(i,"error")&&i.emit("error",e)}function l(){i.removeListener("finish",f),p()}function f(){D("onfinish"),i.removeListener("close",l),p()}function p(){D("unpipe"),g.unpipe(i)}var g=this,r=this._readableState;switch(r.pipesCount){case 0:r.pipes=i;break;case 1:r.pipes=[r.pipes,i];break;default:r.pipes.push(i);}r.pipesCount+=1,D("pipe count=%d opts=%j",r.pipesCount,e);var t=e&&!1===e.end||i===_.stdout||i===_.stderr?p:m;r.endEmitted?_.nextTick(t):g.once("end",t),i.on("unpipe",function e(t,n){D("onunpipe"),t===g&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,D("cleanup"),i.removeListener("close",l),i.removeListener("finish",f),i.removeListener("drain",o),i.removeListener("error",d),i.removeListener("unpipe",e),g.removeListener("end",m),g.removeListener("end",p),g.removeListener("data",h),a=!0,!r.awaitDrain||i._writableState&&!i._writableState.needDrain||o())});var o=function(n){return function(){var e=n._readableState;D("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&q(n,"data")&&(e.flowing=!0,U(n))}}(g);i.on("drain",o);var a=!1;return g.on("data",h),function(r,e,t){return"function"==typeof r.prependListener?r.prependListener("error",t):void(r._events&&r._events.error?Array.isArray(r._events.error)?r._events.error.unshift(t):r._events.error=[t,r._events.error]:r.on("error",t))}(i,0,d),i.once("close",l),i.once("finish",f),i.emit("pipe",g),r.flowing||(D("pipe resume"),g.resume()),i},k.prototype.unpipe=function(d){var a=this._readableState,t={hasUnpiped:!1};if(0===a.pipesCount)return this;if(1===a.pipesCount)return d&&d!==a.pipes?this:(d||(d=a.pipes),a.pipes=null,a.pipesCount=0,a.flowing=!1,d&&d.emit("unpipe",this,t),this);if(!d){var n=a.pipes,r=a.pipesCount;a.pipes=null,a.pipesCount=0,a.flowing=!1;for(var i=0;i<r;i++)n[i].emit("unpipe",this,{hasUnpiped:!1});return this}var l=N(a.pipes,d);return-1===l?this:(a.pipes.splice(l,1),a.pipesCount-=1,1===a.pipesCount&&(a.pipes=a.pipes[0]),d.emit("unpipe",this,t),this)},k.prototype.on=function(t,e){var n=yo.prototype.on.call(this,t,e),r=this._readableState;return"data"===t?(r.readableListening=0<this.listenerCount("readable"),!1!==r.flowing&&this.resume()):"readable"==t&&(r.endEmitted||r.readableListening||(r.readableListening=r.needReadable=!0,r.flowing=!1,r.emittedReadable=!1,D("on readable",r.length,r.reading),r.length?T(this):r.reading||_.nextTick(B,this))),n},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var n=yo.prototype.removeListener.call(this,t,e);return"readable"===t&&_.nextTick(L,this),n},k.prototype.removeAllListeners=function(t){var e=yo.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||_.nextTick(L,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(D("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,_.nextTick(A,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return D("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(D("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(d){var a=this,t=this._readableState,e=!1;for(var n in d.on("end",function(){if(D("wrapped end"),t.decoder&&!t.ended){var n=t.decoder.end();n&&n.length&&a.push(n)}a.push(null)}),d.on("data",function(n){D("wrapped data"),t.decoder&&(n=t.decoder.write(n)),t.objectMode&&null==n||(t.objectMode||n&&n.length)&&(a.push(n)||(e=!0,d.pause()))}),d)void 0===this[n]&&"function"==typeof d[n]&&(this[n]=function(e){return function(){return d[e].apply(d,arguments)}}(n));for(var i=0;i<v.length;i++)d.on(v[i],this.emit.bind(this,v[i]));return this._read=function(n){D("wrapped _read",n),e&&(e=!1,d.resume())},this},"function"==typeof Symbol&&(k.prototype[Symbol.asyncIterator]=function(){return w("Readable[Symbol.asyncIterator]"),void 0===s&&(s=i({})),s(this)}),Object.defineProperty(k.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(k.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(k.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),k._fromList=P,Object.defineProperty(k.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}})}).call(this,pe,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)}),i=so(function(l){(function(_){"use strict";function t(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function b(n,e){return{value:n,done:e}}function r(r){var e=r[i];if(null!==e){var t=r[u].read();null!==t&&(r[p]=null,r[i]=null,r[s]=null,e(b(t,!1)))}}var e,f=ho({}),i=Symbol("lastResolve"),s=Symbol("lastReject"),o=Symbol("error"),a=Symbol("ended"),p=Symbol("lastPromise"),c=Symbol("handlePromise"),u=Symbol("stream"),d=Object.getPrototypeOf(function(){}),h=Object.setPrototypeOf((t(e={get stream(){return this[u]},next:function(){var t=this,e=this[o];if(null!==e)return Promise.reject(e);if(this[a])return Promise.resolve(b(void 0,!0));if(this[u].destroyed)return new Promise(function(e,n){_.nextTick(function(){t[o]?n(t[o]):e(b(void 0,!0))})});var n,d=this[p];if(d)n=new Promise(function(o,e){return function(t,n){o.then(function(){e[a]?t(b(void 0,!0)):e[c](t,n)},n)}}(d,this));else{var i=this[u].read();if(null!==i)return Promise.resolve(b(i,!1));n=new Promise(this[c])}return this[p]=n,n}},Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var r=this;return new Promise(function(o,t){r[u].destroy(null,function(n){n?t(n):o(b(void 0,!0))})})}),e),d);l.exports=function(d){var e,g=Object.create(h,(t(e={},u,{value:d,writable:!0}),t(e,i,{value:null,writable:!0}),t(e,s,{value:null,writable:!0}),t(e,o,{value:null,writable:!0}),t(e,a,{value:d._readableState.endEmitted,writable:!0}),t(e,c,{value:function(r,e){var t=g[u].read();t?(g[p]=null,g[i]=null,g[s]=null,r(b(t,!1))):(g[i]=r,g[s]=e)},writable:!0}),e));return g[p]=null,f(d,function(r){if(r&&"ERR_STREAM_PREMATURE_CLOSE"!==r.code){var e=g[s];return null!==e&&(g[p]=null,g[i]=null,g[s]=null,e(r)),void(g[o]=r)}var t=g[i];null!==t&&(g[p]=null,g[i]=null,g[s]=null,t(b(void 0,!0))),g[a]=!0}),d.on("readable",function(t){_.nextTick(r,t)}.bind(null,g)),g}}).call(this,pe)}),ho=so(function(t){"use strict";function m(){}var r=Co.codes.ERR_STREAM_PREMATURE_CLOSE;t.exports=function n(_,e,t){if("function"==typeof e)return n(_,null,e);e||(e={}),t=function(o){var e=!1;return function(){if(!e){e=!0;for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];o.apply(this,n)}}}(t||m);var b=e.readable||!1!==e.readable&&_.readable,y=e.writable||!1!==e.writable&&_.writable,w=function(){_.writable||S()},h=_._writableState&&_._writableState.finished,S=function(){y=!1,h=!0,b||t.call(_)},u=_._readableState&&_._readableState.endEmitted,k=function(){b=!1,u=!0,y||t.call(_)},l=function(n){t.call(_,n)},f=function(){var n;return b&&!u?(_._readableState&&_._readableState.ended||(n=new r),t.call(_,n)):y&&!h?(_._writableState&&_._writableState.ended||(n=new r),t.call(_,n)):void 0},p=function(){_.req.on("finish",S)};return function(t){return t.setHeader&&"function"==typeof t.abort}(_)?(_.on("complete",S),_.on("abort",f),_.req?p():_.on("request",p)):y&&!_._writableState&&(_.on("end",w),_.on("close",w)),_.on("end",k),_.on("finish",S),!1!==e.error&&_.on("error",l),_.on("close",f),function(){_.removeListener("complete",S),_.removeListener("abort",f),_.removeListener("request",p),_.req&&_.req.removeListener("finish",S),_.removeListener("end",w),_.removeListener("close",w),_.removeListener("finish",S),_.removeListener("end",k),_.removeListener("error",l),_.removeListener("close",f)}}}),d=so(function(f,e){"use strict";function t(r){var e;switch(this.encoding=function(r){var e=function(n){if(!n)return"utf8";for(var r;;)switch(n){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 n;default:if(r)return;n=(""+n).toLowerCase(),r=!0;}}(r);if("string"!=typeof e&&(l.isEncoding===n||!n(r)))throw new Error("Unknown encoding: "+r);return e||r}(r),this.encoding){case"utf16le":this.text=o,this.end=a,e=4;break;case"utf8":this.fillLast=i,e=4;break;case"base64":this.text=s,this.end=c,e=3;break;default:return this.write=u,void(this.end=d);}this.lastNeed=0,this.lastTotal=0,this.lastChar=l.allocUnsafe(e)}function p(t){return 127>=t?0:6==t>>5?2:14==t>>4?3:30==t>>3?4:2==t>>6?-1:-2}function i(r){var e=this.lastTotal-this.lastNeed,t=function(n,e){if(128!=(192&e[0]))return n.lastNeed=0,"\uFFFD";if(1<n.lastNeed&&1<e.length){if(128!=(192&e[1]))return n.lastNeed=1,"\uFFFD";if(2<n.lastNeed&&2<e.length&&128!=(192&e[2]))return n.lastNeed=2,"\uFFFD"}}(this,r);return void 0===t?this.lastNeed<=r.length?(r.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(r.copy(this.lastChar,e,0,r.length),void(this.lastNeed-=r.length)):t}function o(o,e){if(0==(o.length-e)%2){var t=o.toString("utf16le",e);if(t){var n=t.charCodeAt(t.length-1);if(55296<=n&&56319>=n)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=o[o.length-2],this.lastChar[1]=o[o.length-1],t.slice(0,-1)}return t}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=o[o.length-1],o.toString("utf16le",e,o.length-1)}function a(r){var e=r&&r.length?this.write(r):"";if(this.lastNeed){var t=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,t)}return e}function s(r,e){var t=(r.length-e)%3;return 0==t?r.toString("base64",e):(this.lastNeed=3-t,this.lastTotal=3,1==t?this.lastChar[0]=r[r.length-1]:(this.lastChar[0]=r[r.length-2],this.lastChar[1]=r[r.length-1]),r.toString("base64",e,r.length-t))}function c(n){var e=n&&n.length?this.write(n):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function u(t){return t.toString(this.encoding)}function d(t){return t&&t.length?this.write(t):""}var l=Lo.Buffer,n=l.isEncoding||function(t){switch((t=""+t)&&t.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;}};e.StringDecoder=t,t.prototype.write=function(r){if(0===r.length)return"";var e,o;if(this.lastNeed){if(void 0===(e=this.fillLast(r)))return"";o=this.lastNeed,this.lastNeed=0}else o=0;return o<r.length?e?e+this.text(r,o):this.text(r,o):e||""},t.prototype.end=function(n){var e=n&&n.length?this.write(n):"";return this.lastNeed?e+"\uFFFD":e},t.prototype.text=function(o,e){var t=function(o,e,t){var n=e.length-1;if(n<t)return 0;var d=p(e[n]);return 0<=d?(0<d&&(o.lastNeed=d-1),d):--n<t||-2===d?0:0<=(d=p(e[n]))?(0<d&&(o.lastNeed=d-2),d):--n<t||-2===d?0:0<=(d=p(e[n]))?(0<d&&(2===d?d=0:o.lastNeed=d-3),d):0}(this,o,e);if(!this.lastNeed)return o.toString("utf8",e);this.lastTotal=t;var n=o.length-(t-this.lastNeed);return o.copy(this.lastChar,0,n),o.toString("utf8",e,n)},t.prototype.fillLast=function(t){return this.lastNeed<=t.length?(t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):void(t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length)}}),l=so(function(l){(function(e){"use strict";function t(o){return this instanceof t?void(n.call(this,o),r.call(this,o),this.allowHalfOpen=!0,o&&(!1===o.readable&&(this.readable=!1),!1===o.writable&&(this.writable=!1),!1===o.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",f)))):new t(o)}function f(){this._writableState.ended||e.nextTick(c,this)}function c(t){t.end()}var d=Object.keys||function(r){var e=[];for(var t in r)e.push(t);return e};l.exports=t;var n=po({}),r=u({});Me(t,n);for(var i,p=d(r.prototype),s=0;s<p.length;s++)i=p[s],t.prototype[i]||(t.prototype[i]=r.prototype[i]);Object.defineProperty(t.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(t.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(t.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(t.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})}).call(this,pe)}),u=so(function(m){(function(L,e){"use strict";function B(n){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(n,e){var t=n.entry;for(n.entry=null;t;){var o=t.callback;e.pendingcb--,o(void 0),t=t.next}e.corkedRequestsFree.next=n}(e,n)}}function t(){}function n(t,r,n){T=T||l({}),t=t||{},"boolean"!=typeof n&&(n=r instanceof T),this.objectMode=!!t.objectMode,n&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",n),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var d=!1===t.decodeStrings;this.decodeStrings=!d,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var n=t._writableState,r=n.sync,d=n.writecb;if("function"!=typeof d)throw new u;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(n),e)!function(t,e,n,r,o){--e.pendingcb,n?(L.nextTick(o,r),L.nextTick(x,t,e),t._writableState.errorEmitted=!0,t.emit("error",r)):(o(r),t._writableState.errorEmitted=!0,t.emit("error",r),x(t,e))}(t,n,r,e,d);else{var a=v(n)||t.destroyed;a||n.corked||n.bufferProcessing||!n.bufferedRequest||E(t,n),r?L.nextTick(S,t,n,a,d):S(t,n,a,d)}}(r,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.bufferedRequestCount=0,this.corkedRequestsFree=new B(this)}function r(o){var e=this instanceof(T=T||l({}));return e||I.call(r,this)?void(this._writableState=new n(o,this,e),this.writable=!0,o&&("function"==typeof o.write&&(this._write=o.write),"function"==typeof o.writev&&(this._writev=o.writev),"function"==typeof o.destroy&&(this._destroy=o.destroy),"function"==typeof o.final&&(this._final=o.final)),yo.call(this)):new r(o)}function k(d,e,t,n,r,a,i){e.writelen=n,e.writecb=i,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new g("write")):t?d._writev(r,e.onwrite):d._write(r,a,e.onwrite),e.sync=!1}function S(o,e,t,n){t||function(n,e){0===e.length&&e.needDrain&&(e.needDrain=!1,n.emit("drain"))}(o,e),e.pendingcb--,n(),x(o,e)}function E(r,e){e.bufferProcessing=!0;var t=e.bufferedRequest;if(r._writev&&t&&t.next){var l=e.bufferedRequestCount,i=Array(l),s=e.corkedRequestsFree;s.entry=t;for(var o=0,f=!0;t;)i[o]=t,t.isBuf||(f=!1),t=t.next,o+=1;i.allBuffers=f,k(r,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new B(e),e.bufferedRequestCount=0}else{for(;t;){var p=t.chunk,c=t.encoding,u=t.callback;if(k(r,e,!1,e.objectMode?1:p.length,p,c,u),t=t.next,e.bufferedRequestCount--,e.writing)break}null===t&&(e.lastBufferedRequest=null)}e.bufferedRequest=t,e.bufferProcessing=!1}function v(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function C(r,e){r._final(function(t){e.pendingcb--,t&&r.emit("error",t),e.prefinished=!0,r.emit("prefinish"),x(r,e)})}function x(t,e){var n=v(e);return n&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,L.nextTick(C,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"))),n}var T;m.exports=r,r.WritableState=n;var I,R={deprecate:xo},A=p({}).Buffer,a=e.Uint8Array||function(){},h=Ue.getHighWaterMark,o=Co.codes,c=o.ERR_INVALID_ARG_TYPE,d=o.ERR_METHOD_NOT_IMPLEMENTED,u=o.ERR_MULTIPLE_CALLBACK,f=o.ERR_STREAM_CANNOT_PIPE,g=o.ERR_STREAM_DESTROYED,_=o.ERR_STREAM_NULL_VALUES,y=o.ERR_STREAM_WRITE_AFTER_END,b=o.ERR_UNKNOWN_ENCODING;Me(r,yo),n.prototype.getBuffer=function(){for(var n=this.bufferedRequest,r=[];n;)r.push(n),n=n.next;return r},function(){try{Object.defineProperty(n.prototype,"buffer",{get:R.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(I=Function.prototype[Symbol.hasInstance],Object.defineProperty(r,Symbol.hasInstance,{value:function(t){return!!I.call(this,t)||this===r&&t&&t._writableState instanceof n}})):I=function(t){return t instanceof this},r.prototype.pipe=function(){this.emit("error",new f)},r.prototype.write=function(d,l,u){var f,p=this._writableState,s=!1,h=!p.objectMode&&(f=d,A.isBuffer(f)||f instanceof a);return h&&!A.isBuffer(d)&&(d=function(t){return A.from(t)}(d)),"function"==typeof l&&(u=l,l=null),h?l="buffer":l||(l=p.defaultEncoding),"function"!=typeof u&&(u=t),p.ending?function(t,e){var n=new y;t.emit("error",n),L.nextTick(e,n)}(this,u):(h||function(t,e,n,r){var o;return null===n?o=new _:"string"==typeof n||e.objectMode||(o=new c("chunk",["string","Buffer"],n)),!o||(t.emit("error",o),L.nextTick(r,o),!1)}(this,p,d,u))&&(p.pendingcb++,s=function(d,e,t,a,l,f){if(!t){var s=function(r,e,o){return r.objectMode||!1===r.decodeStrings||"string"!=typeof e||(e=A.from(e,o)),e}(e,a,l);a!==s&&(t=!0,l="buffer",a=s)}var o=e.objectMode?1:a.length;e.length+=o;var p=e.length<e.highWaterMark;if(p||(e.needDrain=!0),e.writing||e.corked){var c=e.lastBufferedRequest;e.lastBufferedRequest={chunk:a,encoding:l,isBuf:t,callback:f,next:null},c?c.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else k(d,e,!1,o,a,l,f);return p}(this,p,h,d,l,u)),s},r.prototype.cork=function(){this._writableState.corked++},r.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||E(this,t))},r.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())))throw new b(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(r.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(r.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),r.prototype._write=function(r,e,t){t(new d("_write()"))},r.prototype._writev=null,r.prototype.end=function(t,o,d){var a=this._writableState;return"function"==typeof t?(d=t,t=null,o=null):"function"==typeof o&&(d=o,o=null),null!=t&&this.write(t,o),a.corked&&(a.corked=1,this.uncork()),a.ending||function(t,e,n){e.ending=!0,x(t,e),n&&(e.finished?L.nextTick(n):t.once("finish",n)),e.ended=!0,t.writable=!1}(this,a,d),this},Object.defineProperty(r.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(r.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),r.prototype.destroy=vo.destroy,r.prototype._undestroy=vo.undestroy,r.prototype._destroy=function(n,e){e(n)}}).call(this,pe,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)}),p=so(function(n,L){(function(H){"use strict";function D(e){if(e>N)throw new RangeError("The value \""+e+"\" is invalid for option \"size\"");var t=new Uint8Array(e);return t.__proto__=H.prototype,t}function H(o,e,t){if("number"==typeof o){if("string"==typeof e)throw new TypeError("The \"string\" argument must be of type string. Received type number");return s(o)}return r(o,e,t)}function r(e,t,n){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!H.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var r=0|a(e,t),d=D(r),i=d.write(e,t);return i!==r&&(d=d.slice(0,i)),d}(e,t);if(ArrayBuffer.isView(e))return q(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(M(e,ArrayBuffer)||e&&M(e.buffer,ArrayBuffer))return function(e,t,n){if(0>t||e.byteLength<t)throw new RangeError("\"offset\" is outside of buffer bounds");if(e.byteLength<t+(n||0))throw new RangeError("\"length\" is outside of buffer bounds");var r;return(r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n)).__proto__=H.prototype,r}(e,t,n);if("number"==typeof e)throw new TypeError("The \"value\" argument must not be of type number. Received type number");var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return H.from(r,t,n);var d=function(e){if(H.isBuffer(e)){var t=0|o(e.length),n=D(t);return 0===n.length?n:(e.copy(n,0,0,t),n)}return void 0===e.length?"Buffer"===e.type&&Array.isArray(e.data)?q(e.data):void 0:"number"!=typeof e.length||P(e.length)?D(0):q(e)}(e);if(d)return d;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return H.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function i(t){if("number"!=typeof t)throw new TypeError("\"size\" argument must be of type number");if(0>t)throw new RangeError("The value \""+t+"\" is invalid for option \"size\"")}function s(t){return i(t),D(0>t?0:0|o(t))}function q(r){for(var e=0>r.length?0:0|o(r.length),t=D(e),n=0;n<e;n+=1)t[n]=255&r[n];return t}function o(t){if(t>=N)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+N.toString(16)+" bytes");return 0|t}function a(e,t){if(H.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||M(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type "+typeof e);var o=e.length,r=2<arguments.length&&!0===arguments[2];if(!r&&0===o)return 0;for(var d=!1;;)switch(t){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return R(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*o;case"hex":return o>>>1;case"base64":return U(e).length;default:if(d)return r?-1:R(e).length;t=(""+t).toLowerCase(),d=!0;}}function c(o,e,t){var n=o[e];o[e]=o[t],o[t]=n}function u(e,t,o,a,l){if(0===e.length)return-1;if("string"==typeof o?(a=o,o=0):2147483647<o?o=2147483647:-2147483648>o&&(o=-2147483648),P(o=+o)&&(o=l?0:e.length-1),0>o&&(o=e.length+o),o>=e.length){if(l)return-1;o=e.length-1}else if(0>o){if(!l)return-1;o=0}if("string"==typeof t&&(t=H.from(t,a)),H.isBuffer(t))return 0===t.length?-1:d(e,t,o,a,l);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?l?Uint8Array.prototype.indexOf.call(e,t,o):Uint8Array.prototype.lastIndexOf.call(e,t,o):d(e,[t],o,a,l);throw new TypeError("val must be string, number or Buffer")}function d(f,e,t,p,g){function i(n,e){return 1===m?n[e]:n.readUInt16BE(e*m)}var c,m=1,_=f.length,b=e.length;if(void 0!==p&&("ucs2"===(p=(p+"").toLowerCase())||"ucs-2"===p||"utf16le"===p||"utf-16le"===p)){if(2>f.length||2>e.length)return-1;m=2,_/=2,b/=2,t/=2}if(g){var y=-1;for(c=t;c<_;c++)if(i(f,c)!==i(e,-1===y?0:c-y))-1!==y&&(c-=c-y),y=-1;else if(-1===y&&(y=c),c-y+1===b)return y*m}else for(t+b>_&&(t=_-b),c=t;0<=c;c--){for(var w=!0,S=0;S<b;S++)if(i(f,c+S)!==i(e,S)){w=!1;break}if(w)return c}return-1}function l(d,e,t,l){t=+t||0;var c=d.length-t;l?(l=+l)>c&&(l=c):l=c;var i=e.length;l>i/2&&(l=i/2);for(var s,u=0;u<l;++u){if(s=parseInt(e.substr(2*u,2),16),P(s))return u;d[t+u]=s}return u}function f(o,e,t,n){return F(R(e,o.length-t),o,t,n)}function p(o,e,t,n){return F(function(r){for(var e=[],t=0;t<r.length;++t)e.push(255&r.charCodeAt(t));return e}(e),o,t,n)}function h(o,e,t,n){return p(o,e,t,n)}function g(o,e,t,n){return F(U(e),o,t,n)}function m(o,e,t,n){return F(function(d,e){for(var a,l,c,u=[],s=0;s<d.length&&!(0>(e-=2));++s)l=(a=d.charCodeAt(s))>>8,c=a%256,u.push(c),u.push(l);return u}(e,o.length-t),o,t,n)}function _(r,e,t){return 0===e&&t===r.length?y.fromByteArray(r):y.fromByteArray(r.slice(e,t))}function b(l,e,t){t=ao(l.length,t);for(var f=[],r=e;r<t;){var p,g,m,_,b=l[r],c=null,y=239<b?4:223<b?3:191<b?2:1;r+y<=t&&(1==y?128>b&&(c=b):2==y?128==(192&(p=l[r+1]))&&127<(_=(31&b)<<6|63&p)&&(c=_):3==y?(p=l[r+1],g=l[r+2],128==(192&p)&&128==(192&g)&&2047<(_=(15&b)<<12|(63&p)<<6|63&g)&&(55296>_||57343<_)&&(c=_)):4==y?(p=l[r+1],g=l[r+2],m=l[r+3],128==(192&p)&&128==(192&g)&&128==(192&m)&&65535<(_=(15&b)<<18|(63&p)<<12|(63&g)<<6|63&m)&&1114112>_&&(c=_)):void 0);null===c?(c=65533,y=1):65535<c&&(c-=65536,f.push(55296|1023&c>>>10),c=56320|1023&c),f.push(c),r+=y}return function(o){var e=o.length;if(e<=W)return ro.apply(String,o);for(var t="",d=0;d<e;)t+=ro.apply(String,o.slice(d,d+=W));return t}(f)}function w(o,e,t){var d="";t=ao(o.length,t);for(var a=e;a<t;++a)d+=ro(127&o[a]);return d}function E(o,e,t){var d="";t=ao(o.length,t);for(var a=e;a<t;++a)d+=ro(o[a]);return d}function k(d,e,a){var l,c=d.length;(!e||0>e)&&(e=0),(!a||0>a||a>c)&&(a=c);for(var i="",u=e;u<a;++u)i+=16>(l=d[u])?"0"+l.toString(16):l.toString(16);return i}function S(o,e,t){for(var n=o.slice(e,t),r="",d=0;d<n.length;d+=2)r+=ro(n[d]+256*n[d+1]);return r}function C(r,e,t){if(0!=r%1||0>r)throw new RangeError("offset is not uint");if(r+e>t)throw new RangeError("Trying to access beyond buffer length")}function x(e,t,n,r,d,a){if(!H.isBuffer(e))throw new TypeError("\"buffer\" argument must be a Buffer instance");if(t>d||t<a)throw new RangeError("\"value\" argument is out of bounds");if(n+r>e.length)throw new RangeError("Index out of range")}function T(o,e,t,n){if(t+n>o.length)throw new RangeError("Index out of range");if(0>t)throw new RangeError("Index out of range")}function A(o,e,d,a,r){return e=+e,d>>>=0,r||T(o,0,d,4),O.write(o,e,d,a,23,4),d+4}function I(o,e,d,a,r){return e=+e,d>>>=0,r||T(o,0,d,8),O.write(o,e,d,a,52,8),d+8}function R(d,e){var a;e=e||1/0;for(var l=d.length,r=null,c=[],s=0;s<l;++s){if(55295<(a=d.charCodeAt(s))&&57344>a){if(!r){if(56319<a){-1<(e-=3)&&c.push(239,191,189);continue}if(s+1===l){-1<(e-=3)&&c.push(239,191,189);continue}r=a;continue}if(56320>a){-1<(e-=3)&&c.push(239,191,189),r=a;continue}a=65536+(r-55296<<10|a-56320)}else r&&-1<(e-=3)&&c.push(239,191,189);if(r=null,128>a){if(0>(e-=1))break;c.push(a)}else if(2048>a){if(0>(e-=2))break;c.push(192|a>>6,128|63&a)}else if(65536>a){if(0>(e-=3))break;c.push(224|a>>12,128|63&a>>6,128|63&a)}else{if(!(1114112>a))throw new Error("Invalid code point");if(0>(e-=4))break;c.push(240|a>>18,128|63&a>>12,128|63&a>>6,128|63&a)}}return c}function U(n){return y.toByteArray(function(n){if(2>(n=(n=n.split("=")[0]).trim().replace(t,"")).length)return"";for(;0!=n.length%4;)n+="=";return n}(n))}function F(o,e,t,n){for(var r=0;r<n&&!(r+t>=e.length||r>=o.length);++r)e[r+t]=o[r];return r}function M(n,e){return n instanceof e||null!=n&&null!=n.constructor&&null!=n.constructor.name&&n.constructor.name===e.name}function P(t){return t!=t}L.Buffer=H,L.SlowBuffer=function(e){return+e!=e&&(e=0),H.alloc(+e)},L.INSPECT_MAX_BYTES=50;var N=2147483647;L.kMaxLength=N,H.TYPED_ARRAY_SUPPORT=function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()}catch(e){return!1}}(),H.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."),Object.defineProperty(H.prototype,"parent",{enumerable:!0,get:function(){if(H.isBuffer(this))return this.buffer}}),Object.defineProperty(H.prototype,"offset",{enumerable:!0,get:function(){if(H.isBuffer(this))return this.byteOffset}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&H[Symbol.species]===H&&Object.defineProperty(H,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),H.poolSize=8192,H.from=function(o,e,t){return r(o,e,t)},H.prototype.__proto__=Uint8Array.prototype,H.__proto__=Uint8Array,H.alloc=function(r,e,t){return function(r,e,t){return i(r),0>=r?D(r):void 0===e?D(r):"string"==typeof t?D(r).fill(e,t):D(r).fill(e)}(r,e,t)},H.allocUnsafe=function(t){return s(t)},H.allocUnsafeSlow=function(t){return s(t)},H.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==H.prototype},H.compare=function(e,d){if(M(e,Uint8Array)&&(e=H.from(e,e.offset,e.byteLength)),M(d,Uint8Array)&&(d=H.from(d,d.offset,d.byteLength)),!H.isBuffer(e)||!H.isBuffer(d))throw new TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array");if(e===d)return 0;for(var a=e.length,l=d.length,c=0,u=ao(a,l);c<u;++c)if(e[c]!==d[c]){a=e[c],l=d[c];break}return a<l?-1:l<a?1:0},H.isEncoding=function(t){switch((t+"").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;}},H.concat=function(e,t){if(!Array.isArray(e))throw new TypeError("\"list\" argument must be an Array of Buffers");if(0===e.length)return H.alloc(0);var d;if(void 0===t)for(t=0,d=0;d<e.length;++d)t+=e[d].length;var a=H.allocUnsafe(t),i=0;for(d=0;d<e.length;++d){var l=e[d];if(M(l,Uint8Array)&&(l=H.from(l)),!H.isBuffer(l))throw new TypeError("\"list\" argument must be an Array of Buffers");l.copy(a,i),i+=l.length}return a},H.byteLength=a,H.prototype._isBuffer=!0,H.prototype.swap16=function(){var n=this.length;if(0!=n%2)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<n;e+=2)c(this,e,e+1);return this},H.prototype.swap32=function(){var n=this.length;if(0!=n%4)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<n;e+=4)c(this,e,e+3),c(this,e+1,e+2);return this},H.prototype.swap64=function(){var n=this.length;if(0!=n%8)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<n;e+=8)c(this,e,e+7),c(this,e+1,e+6),c(this,e+2,e+5),c(this,e+3,e+4);return this},H.prototype.toString=function(){var t=this.length;return 0===t?"":0===arguments.length?b(this,0,t):function(o,d,a){var i=!1;if((void 0===d||0>d)&&(d=0),d>this.length)return"";if((void 0===a||a>this.length)&&(a=this.length),0>=a)return"";if((a>>>=0)<=(d>>>=0))return"";for(o||(o="utf8");;)switch(o){case"hex":return k(this,d,a);case"utf8":case"utf-8":return b(this,d,a);case"ascii":return w(this,d,a);case"latin1":case"binary":return E(this,d,a);case"base64":return _(this,d,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,d,a);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),i=!0;}}.apply(this,arguments)},H.prototype.toLocaleString=H.prototype.toString,H.prototype.equals=function(e){if(!H.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===H.compare(this,e)},H.prototype.inspect=function(){var t="",r=L.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},H.prototype.compare=function(e,l,f,p,g){if(M(e,Uint8Array)&&(e=H.from(e,e.offset,e.byteLength)),!H.isBuffer(e))throw new TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type "+typeof e);if(void 0===l&&(l=0),void 0===f&&(f=e?e.length:0),void 0===p&&(p=0),void 0===g&&(g=this.length),0>l||f>e.length||0>p||g>this.length)throw new RangeError("out of range index");if(p>=g&&l>=f)return 0;if(p>=g)return-1;if(l>=f)return 1;if(this===e)return 0;for(var m=(g>>>=0)-(p>>>=0),_=(f>>>=0)-(l>>>=0),b=ao(m,_),h=this.slice(p,g),c=e.slice(l,f),u=0;u<b;++u)if(h[u]!==c[u]){m=h[u],_=c[u];break}return m<_?-1:_<m?1:0},H.prototype.includes=function(r,e,t){return-1!==this.indexOf(r,e,t)},H.prototype.indexOf=function(r,e,t){return u(this,r,e,t,!0)},H.prototype.lastIndexOf=function(r,e,t){return u(this,r,e,t,!1)},H.prototype.write=function(o,e,d,a){if(void 0===e)a="utf8",d=this.length,e=0;else if(void 0===d&&"string"==typeof e)a=e,d=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(d)?(d>>>=0,void 0===a&&(a="utf8")):(a=d,d=void 0)}var c=this.length-e;if((void 0===d||d>c)&&(d=c),0<o.length&&(0>d||0>e)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");a||(a="utf8");for(var i=!1;;)switch(a){case"hex":return l(this,o,e,d);case"utf8":case"utf-8":return f(this,o,e,d);case"ascii":return p(this,o,e,d);case"latin1":case"binary":return h(this,o,e,d);case"base64":return g(this,o,e,d);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return m(this,o,e,d);default:if(i)throw new TypeError("Unknown encoding: "+a);a=(""+a).toLowerCase(),i=!0;}},H.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var W=4096;H.prototype.slice=function(e,o){var d=this.length;0>(e=~~e)?0>(e+=d)&&(e=0):e>d&&(e=d),0>(o=void 0===o?d:~~o)?0>(o+=d)&&(o=0):o>d&&(o=d),o<e&&(o=e);var r=this.subarray(e,o);return r.__proto__=H.prototype,r},H.prototype.readUIntLE=function(o,d,a){o>>>=0,d>>>=0,a||C(o,d,this.length);for(var n=this[o],l=1,c=0;++c<d&&(l*=256);)n+=this[o+c]*l;return n},H.prototype.readUIntBE=function(o,d,a){o>>>=0,d>>>=0,a||C(o,d,this.length);for(var n=this[o+--d],s=1;0<d&&(s*=256);)n+=this[o+--d]*s;return n},H.prototype.readUInt8=function(n,r){return n>>>=0,r||C(n,1,this.length),this[n]},H.prototype.readUInt16LE=function(n,r){return n>>>=0,r||C(n,2,this.length),this[n]|this[n+1]<<8},H.prototype.readUInt16BE=function(n,r){return n>>>=0,r||C(n,2,this.length),this[n]<<8|this[n+1]},H.prototype.readUInt32LE=function(n,r){return n>>>=0,r||C(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+16777216*this[n+3]},H.prototype.readUInt32BE=function(n,r){return n>>>=0,r||C(n,4,this.length),16777216*this[n]+(this[n+1]<<16|this[n+2]<<8|this[n+3])},H.prototype.readIntLE=function(o,d,a){o>>>=0,d>>>=0,a||C(o,d,this.length);for(var n=this[o],l=1,c=0;++c<d&&(l*=256);)n+=this[o+c]*l;return n>=(l*=128)&&(n-=no(2,8*d)),n},H.prototype.readIntBE=function(o,d,a){o>>>=0,d>>>=0,a||C(o,d,this.length);for(var n=d,l=1,c=this[o+--n];0<n&&(l*=256);)c+=this[o+--n]*l;return c>=(l*=128)&&(c-=no(2,8*d)),c},H.prototype.readInt8=function(n,r){return n>>>=0,r||C(n,1,this.length),128&this[n]?-1*(255-this[n]+1):this[n]},H.prototype.readInt16LE=function(r,o){r>>>=0,o||C(r,2,this.length);var t=this[r]|this[r+1]<<8;return 32768&t?4294901760|t:t},H.prototype.readInt16BE=function(r,o){r>>>=0,o||C(r,2,this.length);var t=this[r+1]|this[r]<<8;return 32768&t?4294901760|t:t},H.prototype.readInt32LE=function(n,r){return n>>>=0,r||C(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},H.prototype.readInt32BE=function(n,r){return n>>>=0,r||C(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},H.prototype.readFloatLE=function(n,r){return n>>>=0,r||C(n,4,this.length),O.read(this,n,!0,23,4)},H.prototype.readFloatBE=function(n,r){return n>>>=0,r||C(n,4,this.length),O.read(this,n,!1,23,4)},H.prototype.readDoubleLE=function(n,r){return n>>>=0,r||C(n,8,this.length),O.read(this,n,!0,52,8)},H.prototype.readDoubleBE=function(n,r){return n>>>=0,r||C(n,8,this.length),O.read(this,n,!1,52,8)},H.prototype.writeUIntLE=function(o,d,a,l){o=+o,d>>>=0,a>>>=0,l||x(this,o,d,a,no(2,8*a)-1,0);var r=1,c=0;for(this[d]=255&o;++c<a&&(r*=256);)this[d+c]=255&o/r;return d+a},H.prototype.writeUIntBE=function(o,d,a,l){o=+o,d>>>=0,a>>>=0,l||x(this,o,d,a,no(2,8*a)-1,0);var r=a-1,c=1;for(this[d+r]=255&o;0<=--r&&(c*=256);)this[d+r]=255&o/c;return d+a},H.prototype.writeUInt8=function(r,o,d){return r=+r,o>>>=0,d||x(this,r,o,1,255,0),this[o]=255&r,o+1},H.prototype.writeUInt16LE=function(r,o,d){return r=+r,o>>>=0,d||x(this,r,o,2,65535,0),this[o]=255&r,this[o+1]=r>>>8,o+2},H.prototype.writeUInt16BE=function(r,o,d){return r=+r,o>>>=0,d||x(this,r,o,2,65535,0),this[o]=r>>>8,this[o+1]=255&r,o+2},H.prototype.writeUInt32LE=function(r,o,d){return r=+r,o>>>=0,d||x(this,r,o,4,4294967295,0),this[o+3]=r>>>24,this[o+2]=r>>>16,this[o+1]=r>>>8,this[o]=255&r,o+4},H.prototype.writeUInt32BE=function(r,o,d){return r=+r,o>>>=0,d||x(this,r,o,4,4294967295,0),this[o]=r>>>24,this[o+1]=r>>>16,this[o+2]=r>>>8,this[o+3]=255&r,o+4},H.prototype.writeIntLE=function(d,l,c,n){if(d=+d,l>>>=0,!n){var r=no(2,8*c-1);x(this,d,l,c,r-1,-r)}var i=0,u=1,f=0;for(this[l]=255&d;++i<c&&(u*=256);)0>d&&0==f&&0!==this[l+i-1]&&(f=1),this[l+i]=255&(d/u>>0)-f;return l+c},H.prototype.writeIntBE=function(d,l,c,n){if(d=+d,l>>>=0,!n){var r=no(2,8*c-1);x(this,d,l,c,r-1,-r)}var i=c-1,u=1,f=0;for(this[l+i]=255&d;0<=--i&&(u*=256);)0>d&&0==f&&0!==this[l+i+1]&&(f=1),this[l+i]=255&(d/u>>0)-f;return l+c},H.prototype.writeInt8=function(r,o,d){return r=+r,o>>>=0,d||x(this,r,o,1,127,-128),0>r&&(r=255+r+1),this[o]=255&r,o+1},H.prototype.writeInt16LE=function(r,o,d){return r=+r,o>>>=0,d||x(this,r,o,2,32767,-32768),this[o]=255&r,this[o+1]=r>>>8,o+2},H.prototype.writeInt16BE=function(r,o,d){return r=+r,o>>>=0,d||x(this,r,o,2,32767,-32768),this[o]=r>>>8,this[o+1]=255&r,o+2},H.prototype.writeInt32LE=function(r,o,d){return r=+r,o>>>=0,d||x(this,r,o,4,2147483647,-2147483648),this[o]=255&r,this[o+1]=r>>>8,this[o+2]=r>>>16,this[o+3]=r>>>24,o+4},H.prototype.writeInt32BE=function(r,o,d){return r=+r,o>>>=0,d||x(this,r,o,4,2147483647,-2147483648),0>r&&(r=4294967295+r+1),this[o]=r>>>24,this[o+1]=r>>>16,this[o+2]=r>>>8,this[o+3]=255&r,o+4},H.prototype.writeFloatLE=function(r,e,t){return A(this,r,e,!0,t)},H.prototype.writeFloatBE=function(r,e,t){return A(this,r,e,!1,t)},H.prototype.writeDoubleLE=function(r,e,t){return I(this,r,e,!0,t)},H.prototype.writeDoubleBE=function(r,e,t){return I(this,r,e,!1,t)},H.prototype.copy=function(e,t,d,a){if(!H.isBuffer(e))throw new TypeError("argument should be a Buffer");if(d||(d=0),a||0===a||(a=this.length),t>=e.length&&(t=e.length),t||(t=0),0<a&&a<d&&(a=d),a===d)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>d||d>=this.length)throw new RangeError("Index out of range");if(0>a)throw new RangeError("sourceEnd out of bounds");a>this.length&&(a=this.length),e.length-t<a-d&&(a=e.length-t+d);var l=a-d;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,d,a);else if(this===e&&d<t&&t<a)for(var s=l-1;0<=s;--s)e[s+t]=this[s+d];else Uint8Array.prototype.set.call(e,this.subarray(d,a),t);return l},H.prototype.fill=function(e,d,l,c){if("string"==typeof e){if("string"==typeof d?(c=d,d=0,l=this.length):"string"==typeof l&&(c=l,l=this.length),void 0!==c&&"string"!=typeof c)throw new TypeError("encoding must be a string");if("string"==typeof c&&!H.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(1===e.length){var u=e.charCodeAt(0);("utf8"===c&&128>u||"latin1"===c)&&(e=u)}}else"number"==typeof e&&(e&=255);if(0>d||this.length<d||this.length<l)throw new RangeError("Out of range index");if(l<=d)return this;var s;if(d>>>=0,l=void 0===l?this.length:l>>>0,e||(e=0),"number"==typeof e)for(s=d;s<l;++s)this[s]=e;else{var f=H.isBuffer(e)?e:H.from(e,c),a=f.length;if(0===a)throw new TypeError("The value \""+e+"\" is invalid for argument \"value\"");for(s=0;s<l-d;++s)this[s+d]=f[s%a]}return this};var t=/[^+\/0-9A-Za-z-_]/g}).call(this,p({}).Buffer)}),m={},c=Object.create||function(n){var e=function(){};return e.prototype=n,new e},f=Object.keys||function(r){var e=[];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.push(t);return t},s=Function.prototype.bind||function(n){var e=this;return function(){return e.apply(n,arguments)}};m=tt,tt.EventEmitter=tt,tt.prototype._events=void 0,tt.prototype._maxListeners=void 0;var h,g=10;try{var b={};Object.defineProperty&&Object.defineProperty(b,"x",{value:0}),h=0===b.x}catch(e){h=!1}h?Object.defineProperty(tt,"defaultMaxListeners",{enumerable:!0,get:function(){return g},set:function(t){if("number"!=typeof t||0>t||t!=t)throw new TypeError("\"defaultMaxListeners\" must be a positive number");g=t}}):tt.defaultMaxListeners=g,tt.prototype.setMaxListeners=function(t){if("number"!=typeof t||0>t||isNaN(t))throw new TypeError("\"n\" argument must be a positive number");return this._maxListeners=t,this},tt.prototype.getMaxListeners=function(){return v(this)},tt.prototype.emit=function(d){var e,l,u,f,p,g,m="error"===d;if(g=this._events)m=m&&null==g.error;else if(!m)return!1;if(m){if(1<arguments.length&&(e=arguments[1]),e instanceof Error)throw e;var _=new Error("Unhandled \"error\" event. ("+e+")");throw _.context=e,_}if(!(l=g[d]))return!1;var h="function"==typeof l;switch(u=arguments.length){case 1:!function(o,e,t){if(e)o.call(t);else for(var n=o.length,r=R(o,n),d=0;d<n;++d)r[d].call(t)}(l,h,this);break;case 2:!function(d,e,t,n){if(e)d.call(t,n);else for(var r=d.length,a=R(d,r),i=0;i<r;++i)a[i].call(t,n)}(l,h,this,arguments[1]);break;case 3:!function(d,e,t,n,r){if(e)d.call(t,n,r);else for(var i=d.length,s=R(d,i),o=0;o<i;++o)s[o].call(t,n,r)}(l,h,this,arguments[1],arguments[2]);break;case 4:!function(d,e,t,n,r,i){if(e)d.call(t,n,r,i);else for(var s=d.length,o=R(d,s),a=0;a<s;++a)o[a].call(t,n,r,i)}(l,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(f=Array(u-1),p=1;p<u;p++)f[p-1]=arguments[p];!function(d,e,t,n){if(e)d.apply(t,n);else for(var r=d.length,a=R(d,r),i=0;i<r;++i)a[i].apply(t,n)}(l,h,this,f);}return!0},tt.prototype.addListener=function(n,e){return C(this,n,e,!1)},tt.prototype.on=tt.prototype.addListener,tt.prototype.prependListener=function(n,e){return C(this,n,e,!0)},tt.prototype.once=function(n,e){if("function"!=typeof e)throw new TypeError("\"listener\" argument must be a function");return this.on(n,T(this,n,e)),this},tt.prototype.prependOnceListener=function(n,e){if("function"!=typeof e)throw new TypeError("\"listener\" argument must be a function");return this.prependListener(n,T(this,n,e)),this},tt.prototype.removeListener=function(d,e){var t,a,l,u,f;if("function"!=typeof e)throw new TypeError("\"listener\" argument must be a function");if(!(a=this._events))return this;if(!(t=a[d]))return this;if(t===e||t.listener===e)0==--this._eventsCount?this._events=c(null):(delete a[d],a.removeListener&&this.emit("removeListener",d,t.listener||e));else if("function"!=typeof t){for(l=-1,u=t.length-1;0<=u;u--)if(t[u]===e||t[u].listener===e){f=t[u].listener,l=u;break}if(0>l)return this;0===l?t.shift():function(t){for(var e=l,o=e+1,d=t.length;o<d;e+=1,o+=1)t[e]=t[o];t.pop()}(t),1===t.length&&(a[d]=t[0]),a.removeListener&&this.emit("removeListener",d,f||e)}return this},tt.prototype.removeAllListeners=function(o){var e,d,a;if(!(d=this._events))return this;if(!d.removeListener)return 0===arguments.length?(this._events=c(null),this._eventsCount=0):d[o]&&(0==--this._eventsCount?this._events=c(null):delete d[o]),this;if(0===arguments.length){var l,u=f(d);for(a=0;a<u.length;++a)"removeListener"!==(l=u[a])&&this.removeAllListeners(l);return this.removeAllListeners("removeListener"),this._events=c(null),this._eventsCount=0,this}if("function"==typeof(e=d[o]))this.removeListener(o,e);else if(e)for(a=e.length-1;0<=a;a--)this.removeListener(o,e[a]);return this},tt.prototype.listeners=function(t){return A(this,t,!0)},tt.prototype.rawListeners=function(t){return A(this,t,!1)},tt.listenerCount=function(n,e){return"function"==typeof n.listenerCount?n.listenerCount(e):I.call(n,e)},tt.prototype.listenerCount=I,tt.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]};for(var y={toByteArray:function(d){var e,l,c=B(d),r=c[0],i=c[1],s=new L(function(r,e,t){return 3*(e+t)/4-t}(0,r,i)),o=0,u=0<i?r-4:r;for(l=0;l<u;l+=4)e=S[d.charCodeAt(l)]<<18|S[d.charCodeAt(l+1)]<<12|S[d.charCodeAt(l+2)]<<6|S[d.charCodeAt(l+3)],s[o++]=255&e>>16,s[o++]=255&e>>8,s[o++]=255&e;return 2===i&&(e=S[d.charCodeAt(l)]<<2|S[d.charCodeAt(l+1)]>>4,s[o++]=255&e),1===i&&(e=S[d.charCodeAt(l)]<<10|S[d.charCodeAt(l+1)]<<4|S[d.charCodeAt(l+2)]>>2,s[o++]=255&e>>8,s[o++]=255&e),s},fromByteArray:function(d){for(var e,a=d.length,n=a%3,r=[],i=0,l=a-n;i<l;i+=16383)r.push(D(d,i,i+16383>l?l:i+16383));return 1==n?(e=d[a-1],r.push(w[e>>2]+w[63&e<<4]+"==")):2==n&&(e=(d[a-2]<<8)+d[a-1],r.push(w[e>>10]+w[63&e>>4]+w[63&e<<2]+"=")),r.join("")}},w=[],S=[],L="undefined"==typeof Uint8Array?Array:Uint8Array,U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",P=0,M=U.length;P<M;++P)w[P]=U[P],S[U.charCodeAt(P)]=P;S[45]=62,S[95]=63;var O={read:function(p,e,t,n,r){var i,g,m=8*r-n-1,a=(1<<m)-1,h=a>>1,c=-7,_=t?r-1:0,b=t?-1:1,l=p[e+_];for(_+=b,i=l&(1<<-c)-1,l>>=-c,c+=m;0<c;i=256*i+p[e+_],_+=b,c-=8);for(g=i&(1<<-c)-1,i>>=-c,c+=n;0<c;g=256*g+p[e+_],_+=b,c-=8);if(0===i)i=1-h;else{if(i===a)return g?NaN:1/0*(l?-1:1);g+=no(2,n),i-=h}return(l?-1:1)*g*no(2,i-n)},write:function(m,e,_,n,r,b){var s,y,w,S=8*b-r-1,k=(1<<S)-1,u=k>>1,d=23===r?no(2,-24)-no(2,-77):0,l=n?0:b-1,E=n?1:-1,p=0>e||0===e&&0>1/e?1:0;for(e=oo(e),isNaN(e)||e===1/0?(y=isNaN(e)?1:0,s=k):(s=io(Math.log(e)/Math.LN2),1>e*(w=no(2,-s))&&(s--,w*=2),2<=(e+=1<=s+u?d/w:d*no(2,1-u))*w&&(s++,w/=2),s+u>=k?(y=0,s=k):1<=s+u?(y=(e*w-1)*no(2,r),s+=u):(y=e*no(2,u-1)*no(2,r),s=0));8<=r;m[_+l]=255&y,l+=E,y/=256,r-=8);for(s=s<<r|y,S+=r;0<S;m[_+l]=255&s,l+=E,s/=256,S-=8);m[_+l-E]|=128*p}},q={};(function(t){q=function(e,o){var d=[];e.on("data",function(t){d.push(t)}),e.once("end",function(){o&&o(null,t.concat(d)),o=null}),e.once("error",function(t){o&&o(t),o=null})}}).call(this,p({}).Buffer);var j={},go=p({}),z=go.Buffer;z.from&&z.alloc&&z.allocUnsafe&&z.allocUnsafeSlow?j=go:(H(go,j),j.Buffer=V),V.prototype=Object.create(z.prototype),H(z,V),V.from=function(r,e,t){if("number"==typeof r)throw new TypeError("Argument must not be a number");return z(r,e,t)},V.alloc=function(o,e,t){if("number"!=typeof o)throw new TypeError("Argument must be a number");var n=z(o);return void 0===e?n.fill(0):"string"==typeof t?n.fill(e,t):n.fill(e),n},V.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return z(t)},V.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return go.SlowBuffer(t)};var $,mo=j.Buffer;G.bytes=-1,G._floatConversionDetected=!1,G.getType=function(t){return mo.isBuffer(t)?"buffer":Array.isArray(t)?"array":ArrayBuffer.isView(t)?"arraybufferview":t instanceof Number?"number":t instanceof Boolean?"boolean":t instanceof ArrayBuffer?"arraybuffer":typeof t},G._encode=function(n,e){if(null!=e)switch(G.getType(e)){case"buffer":G.buffer(n,e);break;case"object":G.dict(n,e);break;case"array":G.list(n,e);break;case"string":G.string(n,e);break;case"number":case"boolean":G.number(n,e);break;case"arraybufferview":G.buffer(n,mo.from(e.buffer,e.byteOffset,e.byteLength));break;case"arraybuffer":G.buffer(n,mo.from(e));}};var Y=mo.from("e"),X=mo.from("d"),Z=mo.from("l");G.buffer=function(n,e){n.push(mo.from(e.length+":"),e)},G.string=function(n,e){n.push(mo.from(mo.byteLength(e)+":"+e))},G.number=function(r,e){var t=2147483648*(e/2147483648<<0)+(e%2147483648<<0);r.push(mo.from("i"+t+"e")),t===e||G._floatConversionDetected||(G._floatConversionDetected=!0,console.warn("WARNING: Possible data corruption detected with value \""+e+"\":","Bencoding only defines support for integers, value was converted to \""+t+"\""),console.trace())},G.dict=function(o,e){o.push(X);for(var t,d=0,a=Object.keys(e).sort(),i=a.length;d<i;d++)null!=e[t=a[d]]&&(G.string(o,t),G._encode(o,e[t]));o.push(Y)},G.list=function(o,e){var t=0,d=e.length;for(o.push(Z);t<d;t++)null!=e[t]&&G._encode(o,e[t]);o.push(Y)},$=G;var Q,_o=j.Buffer;ne.bytes=0,ne.position=0,ne.data=null,ne.encoding=null,ne.next=function(){switch(ne.data[ne.position]){case 100:return ne.dictionary();case 108:return ne.list();case 105:return ne.integer();default:return ne.buffer();}},ne.find=function(o){for(var e=ne.position,d=ne.data.length,n=ne.data;e<d;){if(n[e]===o)return e;e++}throw new Error("Invalid data: Missing delimiter \""+ro(o)+"\" [0x"+o.toString(16)+"]")},ne.dictionary=function(){ne.position++;for(var t={};101!==ne.data[ne.position];)t[ne.buffer()]=ne.next();return ne.position++,t},ne.list=function(){ne.position++;for(var t=[];101!==ne.data[ne.position];)t.push(ne.next());return ne.position++,t},ne.integer=function(){var n=ne.find(101),e=J(ne.data,ne.position+1,n);return ne.position+=n+1-ne.position,e},ne.buffer=function(){var r=ne.find(58),o=J(ne.data,ne.position,r),t=++r+o;return ne.position=t,ne.encoding?ne.data.toString(ne.encoding,r,t):ne.data.slice(r,t)},Q=ne;var te={},ie=te;ie.encode=$,ie.decode=Q,ie.byteLength=ie.encodingLength=function(t){return ie.encode(t).length};var se,bo,yo=m.EventEmitter,oe={},ae=p({}).Buffer,de=oe.inspect,le=de&&de.custom||"inspect",fe=function(){function n(){this.head=null,this.tail=null,this.length=0}var e=n.prototype;return e.push=function(n){var e={data:n,next:null};0<this.length?this.tail.next=e:this.head=e,this.tail=e,++this.length},e.unshift=function(n){var e={data:n,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},e.shift=function(){if(0!==this.length){var t=this.head.data;return this.head=1===this.length?this.tail=null:this.head.next,--this.length,t}},e.clear=function(){this.head=this.tail=null,this.length=0},e.join=function(r){if(0===this.length)return"";for(var e=this.head,o=""+e.data;e=e.next;)o+=r+e.data;return o},e.concat=function(d){if(0===this.length)return ae.alloc(0);for(var e,a,l,c=ae.allocUnsafe(d>>>0),i=this.head,u=0;i;)e=i.data,a=c,l=u,ae.prototype.copy.call(e,a,l),u+=i.data.length,i=i.next;return c},e.consume=function(r,e){var t;return r<this.head.data.length?(t=this.head.data.slice(0,r),this.head.data=this.head.data.slice(r)):t=r===this.head.data.length?this.shift():e?this._getString(r):this._getBuffer(r),t},e.first=function(){return this.head.data},e._getString=function(o){var d=this.head,a=1,l=d.data;for(o-=l.length;d=d.next;){var c=d.data,i=o>c.length?c.length:o;if(l+=i===c.length?c:c.slice(0,o),0==(o-=i)){i===c.length?(++a,this.head=d.next?d.next:this.tail=null):(this.head=d,d.data=c.slice(i));break}++a}return this.length-=a,l},e._getBuffer=function(o){var d=ae.allocUnsafe(o),t=this.head,a=1;for(t.data.copy(d),o-=t.data.length;t=t.next;){var l=t.data,i=o>l.length?l.length:o;if(l.copy(d,d.length-o,0,i),0==(o-=i)){i===l.length?(++a,this.head=t.next?t.next:this.tail=null):(this.head=t,t.data=l.slice(i));break}++a}return this.length-=a,d},e[le]=function(n,e){return de(this,function(o){for(var e=1;e<arguments.length;e++){var d=null==arguments[e]?{}:arguments[e],n=Object.keys(d);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(d).filter(function(t){return Object.getOwnPropertyDescriptor(d,t).enumerable}))),n.forEach(function(e){re(o,e,d[e])})}return o}({},e,{depth:0,customInspect:!1}))},n}(),pe={},wo=pe={};!function(){try{se="function"==typeof setTimeout?setTimeout:he}catch(t){se=he}try{bo="function"==typeof clearTimeout?clearTimeout:_e}catch(t){bo=_e}}();var me,So=[],ko=!1,Eo=-1;wo.nextTick=function(r){var e=Array(arguments.length-1);if(1<arguments.length)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];So.push(new Ce(r,e)),1!==So.length||ko||ye(Se)},Ce.prototype.run=function(){this.fun.apply(null,this.array)},wo.title="browser",wo.browser=!0,wo.env={},wo.argv=[],wo.version="",wo.versions={},wo.on=xe,wo.addListener=xe,wo.once=xe,wo.off=xe,wo.removeListener=xe,wo.removeAllListeners=xe,wo.emit=xe,wo.prependListener=xe,wo.prependOnceListener=xe,wo.listeners=function(){return[]},wo.binding=function(){throw new Error("process.binding is not supported")},wo.cwd=function(){return"/"},wo.chdir=function(){throw new Error("process.chdir is not supported")},wo.umask=function(){return 0};var vo={};(function(d){"use strict";function e(r,e){n(r,e),a(r)}function a(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function n(n,e){n.emit("error",e)}vo={destroy:function(t,i){var s=this,r=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return r||o?(i?i(t):!t||this._writableState&&this._writableState.errorEmitted||d.nextTick(n,this,t),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,function(t){!i&&t?(d.nextTick(e,s,t),s._writableState&&(s._writableState.errorEmitted=!0)):i?(d.nextTick(a,s),i(t)):d.nextTick(a,s)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}}).call(this,pe);var Co={},Ie={};Te("ERR_INVALID_OPT_VALUE",function(n,e){return"The value \""+e+"\" is invalid for option \""+n+"\""},TypeError),Te("ERR_INVALID_ARG_TYPE",function(d,e,l){var n,c,u,f;if("string"==typeof e&&("not ","not "===e.substr(0,4))?(n="must not be",e=e.replace(/^not /,"")):n="must be",u=d,(void 0===f||f>u.length)&&(f=u.length)," argument"===u.substring(f-9,f))c="The ".concat(d," ").concat(n," ").concat(Be(e,"type"));else{var p=function(r,e,t){return"number"!=typeof t&&(t=0),!(t+1>r.length)&&-1!==r.indexOf(".",t)}(d)?"property":"argument";c="The \"".concat(d,"\" ").concat(p," ").concat(n," ").concat(Be(e,"type"))}return c+". Received type ".concat(typeof l)},TypeError),Te("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Te("ERR_METHOD_NOT_IMPLEMENTED",function(t){return"The "+t+" method is not implemented"}),Te("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Te("ERR_STREAM_DESTROYED",function(t){return"Cannot call "+t+" after a stream was destroyed"}),Te("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Te("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Te("ERR_STREAM_WRITE_AFTER_END","write after end"),Te("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Te("ERR_UNKNOWN_ENCODING",function(t){return"Unknown encoding: "+t},TypeError),Te("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Co.codes=Ie;var Re=Co.codes.ERR_INVALID_OPT_VALUE,Ue={getHighWaterMark:function(o,e,t,n){var r=function(r,e,t){return null==r.highWaterMark?e?r[t]:null:r.highWaterMark}(e,n,t);if(null!=r){if(!isFinite(r)||io(r)!==r||0>r)throw new Re(n?t:"highWaterMark",r);return io(r)}return o.objectMode?16:16384}},Oe={};(function(r){"use strict";var e=new Set;Oe.emitExperimentalWarning=r.emitWarning?function(t){if(!e.has(t)){e.add(t),r.emitWarning(t+" is an experimental feature. This feature could change at any time","ExperimentalWarning")}}:function(){}}).call(this,pe);var Me={};Me="function"==typeof Object.create?function(n,e){e&&(n.super_=e,n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:function(r,e){if(e){r.super_=e;var t=function(){};t.prototype=e.prototype,r.prototype=new t,r.prototype.constructor=r}};var xo={};(function(r){function o(e){try{if(!r.localStorage)return!1}catch(e){return!1}var t=r.localStorage[e];return null!=t&&"true"===(t+"").toLowerCase()}xo=function(t,e){if(o("noDeprecation"))return t;var n=!1;return function(){if(!n){if(o("throwDeprecation"))throw new Error(e);o("traceDeprecation")?console.trace(e):console.warn(e),n=!0}return t.apply(this,arguments)}}}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global);var Lo={},To=p({}),De=To.Buffer;De.from&&De.alloc&&De.allocUnsafe&&De.allocUnsafeSlow?Lo=To:(Le(To,Lo),Lo.Buffer=qe),Le(De,qe),qe.from=function(r,e,t){if("number"==typeof r)throw new TypeError("Argument must not be a number");return De(r,e,t)},qe.alloc=function(o,e,t){if("number"!=typeof o)throw new TypeError("Argument must be a number");var n=De(o);return void 0===e?n.fill(0):"string"==typeof t?n.fill(e,t):n.fill(e),n},qe.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return De(t)},qe.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return To.SlowBuffer(t)};var He=Je,We=Co.codes,ze=We.ERR_METHOD_NOT_IMPLEMENTED,$e=We.ERR_MULTIPLE_CALLBACK,Ve=We.ERR_TRANSFORM_ALREADY_TRANSFORMING,Ge=We.ERR_TRANSFORM_WITH_LENGTH_0,Ke=l({});Me(Je,Ke),Je.prototype.push=function(n,e){return this._transformState.needTransform=!1,Ke.prototype.push.call(this,n,e)},Je.prototype._transform=function(r,e,t){t(new ze("_transform()"))},Je.prototype._write=function(o,e,t){var n=this._transformState;if(n.writecb=t,n.writechunk=o,n.writeencoding=e,!n.transforming){var r=this._readableState;(n.needTransform||r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}},Je.prototype._read=function(){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},Je.prototype._destroy=function(n,r){Ke.prototype._destroy.call(this,n,function(t){r(t)})};var Ye;Me(Qe,He),Qe.prototype._transform=function(r,e,t){t(null,r)};var Bo=Co.codes,rt=Bo.ERR_MISSING_ARGS,it=Bo.ERR_STREAM_DESTROYED,st={};(st=st=po({})).Stream=st,st.Readable=st,st.Writable=u({}),st.Duplex=l({}),st.Transform=He,st.PassThrough=Qe,st.finished=ho({}),st.pipeline=function(){for(var o=arguments.length,d=Array(o),e=0;e<o;e++)d[e]=arguments[e];var a,l=function(t){return t.length?"function"==typeof t[t.length-1]?t.pop():nt:nt}(d);if(Array.isArray(d[0])&&(d=d[0]),2>d.length)throw new rt("streams");var i=d.map(function(t,e){var n=e<d.length-1;return function(o,e,t,n){n=function(n){var e=!1;return function(){e||(e=!0,n.apply(void 0,arguments))}}(n);var d=!1;o.on("close",function(){d=!0}),void 0===Ye&&(Ye=ho({})),Ye(o,{readable:e,writable:t},function(t){return t?n(t):void(d=!0,n())});var a=!1;return function(e){if(!d&&!a)return a=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(o)?o.abort():"function"==typeof o.destroy?o.destroy():void n(e||new it("pipe"))}}(t,n,0<e,function(t){a||(a=t),t&&i.forEach(ot),n||(i.forEach(ot),l(a))})});return d.reduce(at)};var Io={};(function(n){const{Transform:e}=st;Io=class extends e{constructor(o,d={}){super(d),"object"==typeof o&&(o=(d=o).size),this.size=o||512;const{nopad:a,zeroPadding:n=!0}=d;this._zeroPadding=!a&&!!n,this._buffered=[],this._bufferedBytes=0}_transform(e,t,o){for(this._bufferedBytes+=e.length,this._buffered.push(e);this._bufferedBytes>=this.size;){const e=n.concat(this._buffered);this._bufferedBytes-=this.size,this.push(e.slice(0,this.size)),this._buffered=[e.slice(this.size,e.length)]}o()}_flush(){if(this._bufferedBytes&&this._zeroPadding){const e=n.alloc(this.size-this._bufferedBytes);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,p({}).Buffer);for(var Ro=e({}),dt=no(2,10),lt=13,Ao=[];22>lt++;)Ao.push(no(2,lt));var pt={};(function(){function o(o,e){for(var t,d=0,a=o.length-1;0<=a;a--)t=o[a],"."===t?o.splice(a,1):".."===t?(o.splice(a,1),d++):d&&(o.splice(a,1),d--);if(e)for(;d--;d)o.unshift("..");return o}function t(o,e){if(o.filter)return o.filter(e);for(var t=[],n=0;n<o.length;n++)e(o[n],n,o)&&t.push(o[n]);return t}pt.normalize=function(r){var d=pt.isAbsolute(r),a="/"===n(r,-1);return(r=o(t(r.split("/"),function(t){return!!t}),!d).join("/"))||d||(r="."),r&&a&&(r+="/"),(d?"/":"")+r},pt.isAbsolute=function(t){return"/"===t.charAt(0)},pt.join=function(){var n=Array.prototype.slice.call(arguments,0);return pt.normalize(t(n,function(t){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},pt.sep="/",pt.dirname=function(o){if("string"!=typeof o&&(o+=""),0===o.length)return".";for(var d=o.charCodeAt(0),a=47===d,n=-1,l=!0,c=o.length-1;1<=c;--c)if(!(47===(d=o.charCodeAt(c))))l=!1;else if(!l){n=c;break}return-1==n?a?"/":".":a&&1==n?"/":o.slice(0,n)},pt.basename=function(r,e){var t=function(o){"string"!=typeof o&&(o+="");var d,a=0,s=-1,l=!0;for(d=o.length-1;0<=d;--d)if(!(47===o.charCodeAt(d)))-1===s&&(l=!1,s=d+1);else if(!l){a=d+1;break}return-1===s?"":o.slice(a,s)}(r);return e&&t.substr(-1*e.length)===e&&(t=t.substr(0,t.length-e.length)),t},pt.extname=function(d){"string"!=typeof d&&(d+="");for(var l,c=-1,u=0,f=-1,p=!0,h=0,g=d.length-1;0<=g;--g)if(l=d.charCodeAt(g),47!==l)-1==f&&(p=!1,f=g+1),46===l?-1==c?c=g:1!=h&&(h=1):-1!=c&&(h=-1);else if(!p){u=g+1;break}return-1==c||-1==f||0==h||1==h&&c==f-1&&c==u+1?"":d.slice(c,f)};var n=function(r,e,t){return r.substr(e,t)}}).call(this,pe);var gt;gt=ht,ht.strict=bt,ht.loose=wt;var Uo=Object.prototype.toString,_t={"[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},yt={};(function(o){var e=gt.strict;yt=function(t){if(e(t)){var n=o.from(t.buffer);return t.byteLength!==t.buffer.byteLength&&(n=n.slice(t.byteOffset,t.byteOffset+t.byteLength)),n}return o.from(t)}}).call(this,p({}).Buffer);const{Readable:Po}=st;var kt=class extends Po{constructor(r,e={}){super(e),this._offset=0,this._ready=!1,this._file=r,this._size=r.size,this._chunkSize=e.chunkSize||to(this._size/1e3,204800);const t=new FileReader;t.onload=()=>{this.push(yt(t.result))},t.onerror=()=>{this.emit("error",t.error)},this.reader=t,this._generateHeaderBlocks(r,e,(n,e)=>n?this.emit("error",n):void(Array.isArray(e)&&e.forEach(t=>this.push(t)),this._ready=!0,this.emit("_ready")))}_generateHeaderBlocks(r,e,t){t(null,[])}_read(){if(!this._ready)return void this.once("_ready",this._read.bind(this));const n=this._offset;let e=this._offset+this._chunkSize;return(e>this._size&&(e=this._size),n===this._size)?(this.destroy(),void this.push(null)):void(this.reader.readAsArrayBuffer(this._file.slice(n,e)),this._offset=e)}destroy(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(t){}}this.reader=null}},St={},Ct={};(Ct=function(n,r){return r?void St.stat(n,function(t,e){return t?r(t):r(null,e.isFile())}):vt(n)}).sync=vt;var Mo={};Mo.regex=new RegExp("^npm-debug\\.log$|^\\..*\\.swp$|^\\.DS_Store$|^\\.AppleDouble$|^\\.LSOverride$|^Icon\\r$|^\\._.*|^\\.Spotlight-V100(?:$|\\/)|\\.Trashes|^__MACOSX$|~$|^Thumbs\\.db$|^ehthumbs\\.db$|^Desktop\\.ini$|@eaDir$"),Mo.is=t=>Mo.regex.test(t),Mo.not=t=>!Mo.is(t);Me(Tt,st.Readable),Tt.obj=function(t){return new Tt(t,{objectMode:!0,highWaterMark:16})},Tt.prototype._read=function(){this._drained=!0,this._forward()},Tt.prototype._forward=function(){if(!this._forwarding&&this._drained&&this._current){var t;for(this._forwarding=!0;null!==(t=this._current.read())&&this._drained;)this._drained=this.push(t);this._forwarding=!1}},Tt.prototype.destroy=function(t){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),"function"!=typeof this._queue&&this._queue.forEach(function(t){t.destroy&&t.destroy()}),t&&this.emit("error",t),this.emit("close"))},Tt.prototype._next=function(){var r=this;if(r._current=null,"function"==typeof r._queue)r._queue(function(e,t){return e?r.destroy(e):void(t=r._toStreams2(t),r._attachErrorListener(t),r._gotNextStream(t))});else{var e=r._queue.shift();"function"==typeof e&&(e=r._toStreams2(e()),r._attachErrorListener(e)),r._gotNextStream(e)}},Tt.prototype._gotNextStream=function(o){function e(){r._forward()}function n(){o._readableState.ended||r.destroy()}var r=this;return o?void(r._current=o,r._forward(),o.on("readable",e),o.once("end",function t(){r._current=null,o.removeListener("readable",e),o.removeListener("end",t),o.removeListener("close",n),r._next()}),o.once("close",n)):(r.push(null),void r.destroy())},Tt.prototype._attachErrorListener=function(o){var e=this;o&&o.once("error",function t(n){o.removeListener("error",t),e.destroy(n)})};var At=function o(d,e){function t(){for(var t=Array(arguments.length),e=0;e<t.length;e++)t[e]=arguments[e];var o=d.apply(this,t),r=t[t.length-1];return"function"==typeof o&&o!==r&&Object.keys(r).forEach(function(t){o[t]=r[t]}),o}if(d&&e)return o(d)(e);if("function"!=typeof d)throw new TypeError("need wrapper function");return Object.keys(d).forEach(function(n){t[n]=d[n]}),t},Ot={};(Ot=At(Rt)).strict=At(Ut),Rt.proto=Rt(function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Rt(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Ut(this)},configurable:!0})});var Oo={};(function(d){Oo=function(l,e){function c(n){function t(){e&&e(n,u),e=null}p?d.nextTick(t):t()}function a(r,e,t){u[r]=t,(0==--f||e)&&c(e)}var u,f,t,p=!0;Array.isArray(l)?(u=[],f=l.length):(t=Object.keys(l),u={},f=t.length),f?t?t.forEach(function(r){l[r](function(e,t){a(r,e,t)})}):l.forEach(function(n,r){n(function(t,e){a(r,t,e)})}):c(null),p=!1}}).call(this,pe);var No,Ho,Do={exports:{}};No="undefined"==typeof self?this:self,Ho=function(){return function(o){function d(t){if(e[t])return e[t].exports;var n=e[t]={i:t,l:!1,exports:{}};return o[t].call(n.exports,n,n.exports,d),n.l=!0,n.exports}var e={};return d.m=o,d.c=e,d.d=function(n,e,t){d.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:t})},d.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return d.d(e,"a",e),e},d.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},d.p="",d(d.s=3)}([function(d,e,t){var n=t(5),r=t(1),i=r.toHex,s=r.ceilHeapSize,o=t(6),a=function(t){for(t+=9;0<t%64;t+=1);return t},l=function(o,e){var t=new Int32Array(o,e+320,5),n=new Int32Array(5),r=new DataView(n.buffer);return r.setInt32(0,t[0],!1),r.setInt32(4,t[1],!1),r.setInt32(8,t[2],!1),r.setInt32(12,t[3],!1),r.setInt32(16,t[4],!1),n},c=function(){function r(e){if(function(e){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this),0<(e=e||65536)%64)throw new Error("Chunk size must be a multiple of 128 bit");this._offset=0,this._maxChunkLen=e,this._padMaxChunkLen=a(e),this._heap=new ArrayBuffer(s(this._padMaxChunkLen+320+20)),this._h32=new Int32Array(this._heap),this._h8=new Int8Array(this._heap),this._core=new n({Int32Array:Int32Array},{},this._heap)}return r.prototype._initState=function(r,e){this._offset=0;var t=new Int32Array(r,e+320,5);t[0]=1732584193,t[1]=-271733879,t[2]=-1732584194,t[3]=271733878,t[4]=-1009589776},r.prototype._padChunk=function(o,e){var t=a(o),n=new Int32Array(this._heap,0,t>>2);return function(o,e){var t=new Uint8Array(o.buffer),n=e%4,r=e-n;switch(n){case 0:t[r+3]=0;case 1:t[r+2]=0;case 2:t[r+1]=0;case 3:t[r+0]=0;}for(var d=1+(e>>2);d<o.length;d++)o[d]=0}(n,o),function(r,e,t){r[e>>2]|=128<<24-(e%4<<3),r[14+(-16&2+(e>>2))]=0|t/536870912,r[15+(-16&2+(e>>2))]=t<<3}(n,o,e),t},r.prototype._write=function(d,e,t,n){o(d,this._h8,this._h32,e,t,n||0)},r.prototype._coreCall=function(o,e,t,n,r){var d=t;this._write(o,e,t),r&&(d=this._padChunk(t,n)),this._core.hash(d,this._padMaxChunkLen)},r.prototype.rawDigest=function(o){var e=o.byteLength||o.length||o.size||0;this._initState(this._heap,this._padMaxChunkLen);var t=0,d=this._maxChunkLen;for(t=0;e>t+d;t+=d)this._coreCall(o,t,d,e,!1);return this._coreCall(o,t,e-t,e,!0),l(this._heap,this._padMaxChunkLen)},r.prototype.digest=function(t){return i(this.rawDigest(t).buffer)},r.prototype.digestFromString=function(t){return this.digest(t)},r.prototype.digestFromBuffer=function(t){return this.digest(t)},r.prototype.digestFromArrayBuffer=function(t){return this.digest(t)},r.prototype.resetState=function(){return this._initState(this._heap,this._padMaxChunkLen),this},r.prototype.append=function(o){var e,d=0,a=o.byteLength||o.length||o.size||0,n=this._offset%this._maxChunkLen;for(this._offset+=a;d<a;)e=ao(a-d,this._maxChunkLen-n),this._write(o,d,e,n),d+=e,(n+=e)===this._maxChunkLen&&(this._core.hash(this._maxChunkLen,this._padMaxChunkLen),n=0);return this},r.prototype.getState=function(){var n;if(this._offset%this._maxChunkLen)n=this._heap.slice(0);else{var r=new Int32Array(this._heap,this._padMaxChunkLen+320,5);n=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength)}return{offset:this._offset,heap:n}},r.prototype.setState=function(t){return this._offset=t.offset,20===t.heap.byteLength?new Int32Array(this._heap,this._padMaxChunkLen+320,5).set(new Int32Array(t.heap)):this._h32.set(new Int32Array(t.heap)),this},r.prototype.rawEnd=function(){var o=this._offset,e=o%this._maxChunkLen,t=this._padChunk(e,o);this._core.hash(t,this._padMaxChunkLen);var n=l(this._heap,this._padMaxChunkLen);return this._initState(this._heap,this._padMaxChunkLen),n},r.prototype.end=function(){return i(this.rawEnd().buffer)},r}();d.exports=c,d.exports._core=n},function(t){for(var o=Array(256),e=0;256>e;e++)o[e]=(16>e?"0":"")+e.toString(16);t.exports.toHex=function(n){for(var e=new Uint8Array(n),t=Array(n.byteLength),r=0;r<t.length;r++)t[r]=o[e[r]];return t.join("")},t.exports.ceilHeapSize=function(n){var e=0;if(65536>=n)return 65536;if(16777216>n)for(e=1;e<n;e<<=1);else for(e=16777216;e<n;e+=16777216);return e},t.exports.isDedicatedWorkerScope=function(o){var e="WorkerGlobalScope"in o&&o instanceof o.WorkerGlobalScope,t="SharedWorkerGlobalScope"in o&&o instanceof o.SharedWorkerGlobalScope,n="ServiceWorkerGlobalScope"in o&&o instanceof o.ServiceWorkerGlobalScope;return e&&!t&&!n}},function(r,e,o){r.exports=function(){var d=o(0),l=function(t,e,d,r,i){var s=new self.FileReader;s.onloadend=function(){if(s.error)return i(s.error);var n=s.result;e+=s.result.byteLength;try{t.append(n)}catch(e){return void i(e)}e<r.size?l(t,e,d,r,i):i(null,t.end())},s.readAsArrayBuffer(r.slice(e,e+d))},e=!0;return self.onmessage=function(t){if(e){var n=t.data.data,r=t.data.file,i=t.data.id;if(void 0!==i&&(r||n)){var o=t.data.blockSize||4194304,a=new d(o);a.resetState();var s=function(n,e){n?self.postMessage({id:i,error:n.name}):self.postMessage({id:i,hash:e})};n&&function(r,e,t){try{t(null,r.digest(e))}catch(e){return t(e)}}(a,n,s),r&&l(a,0,o,r,s)}}},function(){e=!1}}},function(d,e,t){var n=t(4),r=t(0),i=t(7),s=t(2),o=t(1).isDedicatedWorkerScope,a="undefined"!=typeof self&&o(self);r.disableWorkerBehaviour=a?s():function(){},r.createWorker=function(){var r=n(2),e=r.terminate;return r.terminate=function(){URL.revokeObjectURL(r.objectURL),e.call(r)},r},r.createHash=i,d.exports=r},function(d,e,f){function n(o){function d(t){if(e[t])return e[t].exports;var n=e[t]={i:t,l:!1,exports:{}};return o[t].call(n.exports,n,n.exports,d),n.l=!0,n.exports}var e={};d.m=o,d.c=e,d.i=function(t){return t},d.d=function(n,e,t){d.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:t})},d.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},d.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return d.d(e,"a",e),e},d.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},d.p="/",d.oe=function(t){throw console.error(t),t};var t=d(d.s=ENTRY_MODULE);return t.default||t}function t(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function r(n,e,o){var r={};r[o]=[];var a=e.toString(),i=a.match(/^function\s?\(\w+,\s*\w+,\s*(\w+)\)/);if(!i)return r;for(var s,c=i[1],d=new RegExp("(\\\\n|\\W)"+t(c)+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");s=d.exec(a);)"dll-reference"!==s[3]&&r[o].push(s[3]);for(d=new RegExp("\\("+t(c)+"\\(\"(dll-reference\\s("+"[\\.|\\-|\\+|\\w|/|@]+"+"))\"\\)\\)"+"\\((/\\*.*?\\*/)?s?.*?([\\.|\\-|\\+|\\w|/|@]+).*?\\)","g");s=d.exec(a);)n[s[2]]||(r[o].push(s[1]),n[s[2]]=f(s[1]).m),r[s[2]]=r[s[2]]||[],r[s[2]].push(s[4]);return r}function a(r){return Object.keys(r).reduce(function(e,t){return e||0<r[t].length},!1)}d.exports=function(l,e){e=e||{};var p={main:f.m},i=e.all?{main:Object.keys(p)}:function(p,e){for(var t={main:[e]},n={main:[]},h={main:{}};a(t);)for(var i=Object.keys(t),s=0;s<i.length;s++){var g=i[s],c=t[g].pop();if(h[g]=h[g]||{},!h[g][c]&&p[g][c]){h[g][c]=!0,n[g]=n[g]||[],n[g].push(c);for(var u=r(p,p[g][c],g),d=Object.keys(u),l=0;l<d.length;l++)t[d[l]]=t[d[l]]||[],t[d[l]]=t[d[l]].concat(u[d[l]])}}return n}(p,l),s="";Object.keys(i).filter(function(t){return"main"!==t}).forEach(function(r){for(var e=0;i[r][e];)e++;i[r].push(e),p[r][e]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",s=s+"var "+r+" = ("+n.toString().replace("ENTRY_MODULE",JSON.stringify(e))+")({"+i[r].map(function(e){return JSON.stringify(e)+": "+p[r][e].toString()}).join(",")+"});\n"}),s=s+"("+n.toString().replace("ENTRY_MODULE",JSON.stringify(l))+")({"+i.main.map(function(t){return JSON.stringify(t)+": "+p.main[t].toString()}).join(",")+"})(self);";var h=new window.Blob([s],{type:"text/javascript"});if(e.bare)return h;var c=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(h),u=new window.Worker(c);return u.objectURL=c,u}},function(t){t.exports=function(o,e,t){"use asm";function n(r,b){r|=0,b|=0;var y=0,w=0,S=0,k=0,E=0,v=0,C=0,x=0,L=0,T=0,B=0,I=0,R=0,A=0;for(S=0|_[b+320>>2],E=0|_[b+324>>2],C=0|_[b+328>>2],L=0|_[b+332>>2],B=0|_[b+336>>2],y=0;(0|y)<(0|r);y=0|y+64){for(k=S,v=E,x=C,T=L,I=B,w=0;64>(0|w);w=0|w+4)A=0|_[y+w>>2],R=0|(0|(S<<5|S>>>27)+(E&C|~E&L))+(0|(0|A+B)+1518500249),B=L,L=C,C=E<<30|E>>>2,E=S,S=R,_[r+w>>2]=A;for(w=0|r+64;(0|w)<(0|r+80);w=0|w+4)A=(_[w-12>>2]^_[w-32>>2]^_[w-56>>2]^_[w-64>>2])<<1|(_[w-12>>2]^_[w-32>>2]^_[w-56>>2]^_[w-64>>2])>>>31,R=0|(0|(S<<5|S>>>27)+(E&C|~E&L))+(0|(0|A+B)+1518500249),B=L,L=C,C=E<<30|E>>>2,E=S,S=R,_[w>>2]=A;for(w=0|r+80;(0|w)<(0|r+160);w=0|w+4)A=(_[w-12>>2]^_[w-32>>2]^_[w-56>>2]^_[w-64>>2])<<1|(_[w-12>>2]^_[w-32>>2]^_[w-56>>2]^_[w-64>>2])>>>31,R=0|(0|(S<<5|S>>>27)+(E^C^L))+(0|(0|A+B)+1859775393),B=L,L=C,C=E<<30|E>>>2,E=S,S=R,_[w>>2]=A;for(w=0|r+160;(0|w)<(0|r+240);w=0|w+4)A=(_[w-12>>2]^_[w-32>>2]^_[w-56>>2]^_[w-64>>2])<<1|(_[w-12>>2]^_[w-32>>2]^_[w-56>>2]^_[w-64>>2])>>>31,R=0|(0|(S<<5|S>>>27)+(E&C|E&L|C&L))+(0|(0|A+B)-1894007588),B=L,L=C,C=E<<30|E>>>2,E=S,S=R,_[w>>2]=A;for(w=0|r+240;(0|w)<(0|r+320);w=0|w+4)A=(_[w-12>>2]^_[w-32>>2]^_[w-56>>2]^_[w-64>>2])<<1|(_[w-12>>2]^_[w-32>>2]^_[w-56>>2]^_[w-64>>2])>>>31,R=0|(0|(S<<5|S>>>27)+(E^C^L))+(0|(0|A+B)-899497514),B=L,L=C,C=E<<30|E>>>2,E=S,S=R,_[w>>2]=A;S=0|S+k,E=0|E+v,C=0|C+x,L=0|L+T,B=0|B+I}_[b+320>>2]=S,_[b+324>>2]=E,_[b+328>>2]=C,_[b+332>>2]=L,_[b+336>>2]=B}var _=new o.Int32Array(t);return{hash:n}}},function(t){var l,d=this;"undefined"!=typeof self&&void 0!==self.FileReaderSync&&(l=new self.FileReaderSync);var n=function(d,e,t,n,r,i){var s,l=i%4,a=(r+l)%4,u=r-a;switch(l){case 0:e[i]=d[n+3];case 1:e[0|i+1-(l<<1)]=d[n+2];case 2:e[0|i+2-(l<<1)]=d[n+1];case 3:e[0|i+3-(l<<1)]=d[n];}if(!(r<a+(4-l))){for(s=4-l;s<u;s=0|s+4)t[0|i+s>>2]=d[n+s]<<24|d[n+s+1]<<16|d[n+s+2]<<8|d[n+s+3];switch(a){case 3:e[0|i+u+1]=d[n+u+2];case 2:e[0|i+u+2]=d[n+u+1];case 1:e[0|i+u+3]=d[n+u];}}};t.exports=function(r,e,t,i,o,a){if("string"==typeof r)return function(d,e,t,n,r,i){var s,l=i%4,a=(r+l)%4,u=r-a;switch(l){case 0:e[i]=d.charCodeAt(n+3);case 1:e[0|i+1-(l<<1)]=d.charCodeAt(n+2);case 2:e[0|i+2-(l<<1)]=d.charCodeAt(n+1);case 3:e[0|i+3-(l<<1)]=d.charCodeAt(n);}if(!(r<a+(4-l))){for(s=4-l;s<u;s=0|s+4)t[i+s>>2]=d.charCodeAt(n+s)<<24|d.charCodeAt(n+s+1)<<16|d.charCodeAt(n+s+2)<<8|d.charCodeAt(n+s+3);switch(a){case 3:e[0|i+u+1]=d.charCodeAt(n+u+2);case 2:e[0|i+u+2]=d.charCodeAt(n+u+1);case 1:e[0|i+u+3]=d.charCodeAt(n+u);}}}(r,e,t,i,o,a);if(r instanceof Array)return n(r,e,t,i,o,a);if(d&&d.Buffer&&d.Buffer.isBuffer(r))return n(r,e,t,i,o,a);if(r instanceof ArrayBuffer)return n(new Uint8Array(r),e,t,i,o,a);if(r.buffer instanceof ArrayBuffer)return n(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),e,t,i,o,a);if(r instanceof Blob)return function(r,e,t,n,i,s){var o,f=s%4,p=(i+f)%4,c=i-p,u=new Uint8Array(l.readAsArrayBuffer(r.slice(n,n+i)));switch(f){case 0:e[s]=u[3];case 1:e[0|s+1-(f<<1)]=u[2];case 2:e[0|s+2-(f<<1)]=u[1];case 3:e[0|s+3-(f<<1)]=u[0];}if(!(i<p+(4-f))){for(o=4-f;o<c;o=0|o+4)t[0|s+o>>2]=u[o]<<24|u[o+1]<<16|u[o+2]<<8|u[o+3];switch(p){case 3:e[0|s+c+1]=u[c+2];case 2:e[0|s+c+2]=u[c+1];case 1:e[0|s+c+3]=u[c];}}}(r,e,t,i,o,a);throw new Error("Unsupported data type.")}},function(o,e,t){var n=t(0),r=t(1).toHex,d=function(){function o(){!function(e){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this),this._rusha=new n,this._rusha.resetState()}return o.prototype.update=function(t){return this._rusha.append(t),this},o.prototype.digest=function(n){var e=this._rusha.rawEnd().buffer;if(!n)return e;if("hex"===n)return r(e);throw new Error("unsupported digest encoding")},o}();o.exports=function(){return new d}}])},"object"==typeof Do.exports?Do.exports=Ho():"object"==typeof Do.exports?Do.exports.Rusha=Ho():No.Rusha=Ho(),Do=Do.exports;var qo={},Fo=new Do,Wt="undefined"==typeof window?self:window,zt=Wt.crypto||Wt.msCrypto||{},$t=zt.subtle||zt.webkitSubtle;try{$t.digest({name:"sha-1"},new Uint8Array).catch(function(){$t=!1})}catch(e){$t=!1}(qo=function(n,r){$t?("string"==typeof n&&(n=function(o){for(var e=o.length,t=new Uint8Array(e),n=0;n<e;n++)t[n]=o.charCodeAt(n);return t}(n)),$t.digest({name:"sha-1"},n).then(function(t){r(function(o){for(var e,d=o.length,t=[],n=0;n<d;n++)e=o[n],t.push((e>>>4).toString(16)),t.push((15&e).toString(16));return t.join("")}(new Uint8Array(t)))},function(){r(Pt(n))})):setTimeout(r,0,Pt(n))}).sync=Pt;var Wo={};(function(p,d,u){function f(t){return t.reduce((n,e)=>Array.isArray(e)?n.concat(f(e)):n.concat(e),[])}function l(s,c,i){function a(){Oo(s.map(a=>e=>{const t={};if(n(a))t.getStream=function(t){return()=>new kt(t)}(a),t.length=a.size;else if(u.isBuffer(a))t.getStream=function(n){return()=>{const e=new st.PassThrough;return e.end(n),e}}(a),t.length=a.length;else{if(!o(a)){if("string"==typeof a){if("function"!=typeof St.stat)throw new Error("filesystem paths do not work in the browser");return void function(o,d,t){!function o(e,t,n){St.stat(e,(r,d)=>r?n(r):void(d.isDirectory()?St.readdir(e,(r,d)=>r?n(r):void Oo(d.filter(g).filter(Mo.not).map(n=>r=>{o(pt.join(e,n),t,r)}),n)):d.isFile()&&t(e,n)))}(o,r,(e,n)=>e?t(e):void(n=Array.isArray(n)?f(n):[n],o=pt.normalize(o),d&&(o=o.slice(0,o.lastIndexOf(pt.sep)+1)),o[o.length-1]!==pt.sep&&(o+=pt.sep),n.forEach(e=>{e.getStream=function(t){return()=>St.createReadStream(t)}(e.path),e.path=e.path.replace(o,"").split(pt.sep)}),t(null,n)))}(a,1<m||d,e)}throw new Error("invalid input type")}t.getStream=function(r,o){return()=>{const e=new st.Transform;return e._transform=function(t,e,n){o.length+=t.length,this.push(t),n()},r.pipe(e),e}}(a,t),t.length=0}t.path=a.path,e(null,t)}),(n,e)=>n?i(n):void(e=f(e),i(null,e,d)))}if("undefined"!=typeof FileList&&s instanceof FileList&&(s=Array.from(s)),Array.isArray(s)||(s=[s]),0===s.length)throw new Error("invalid input type");s.forEach(t=>{if(null==t)throw new Error(`invalid input type: ${t}`)}),1!==(s=s.map(t=>n(t)&&"string"==typeof t.path&&"function"==typeof St.stat?t.path:t)).length||"string"==typeof s[0]||s[0].name||(s[0].name=c.name);let h=null;s.forEach((t,e)=>{if("string"==typeof t)return;let n=t.fullPath||t.name;n||(n=`Unknown File ${e+1}`,t.unknownName=!0),t.path=n.split("/"),t.path[0]||t.path.shift(),2>t.path.length?h=null:0===e&&1<s.length?h=t.path[0]:t.path[0]!==h&&(h=null)}),s=s.filter(n=>{if("string"==typeof n)return!0;const e=n.path[n.path.length-1];return g(e)&&Mo.not(e)}),h&&s.forEach(n=>{const e=(u.isBuffer(n)||o(n))&&!n.path;"string"==typeof n||e||n.path.shift()}),!c.name&&h&&(c.name=h),c.name||s.some(t=>"string"==typeof t?(c.name=pt.basename(t),!0):t.unknownName?void 0:(c.name=t.path[t.path.length-1],!0)),c.name||(c.name=`Unnamed Torrent ${Date.now()}`);const m=s.reduce((n,e)=>n+ +("string"==typeof e),0);let d=1===s.length;if(1===s.length&&"string"==typeof s[0]){if("function"!=typeof St.stat)throw new Error("filesystem paths do not work in the browser");Ct(s[0],(n,e)=>n?i(n):void(d=e,a()))}else p.nextTick(()=>{a()})}function r(o,e){e=Ot(e),St.stat(o,(t,n)=>{if(t)return e(t);const r={length:n.size,path:o};e(null,r)})}function g(t){return"."!==t[0]}function t(n,e){return n+e.length}function n(t){return"undefined"!=typeof Blob&&t instanceof Blob}function o(t){return"object"==typeof t&&null!=t&&"function"==typeof t.pipe}(Wo=function(n,a,c){"function"==typeof a&&([a,c]=[c,a]),l(n,a=a?Object.assign({},a):{},(n,e,r)=>n?c(n):void(a.singleFileTorrent=r,function(a,e,r){let n=e.announceList;n||("string"==typeof e.announce?n=[[e.announce]]:Array.isArray(e.announce)&&(n=e.announce.map(t=>[t]))),n||(n=[]),d.WEBTORRENT_ANNOUNCE&&("string"==typeof d.WEBTORRENT_ANNOUNCE?n.push([[d.WEBTORRENT_ANNOUNCE]]):Array.isArray(d.WEBTORRENT_ANNOUNCE)&&(n=n.concat(d.WEBTORRENT_ANNOUNCE.map(t=>[t])))),void 0===e.announce&&void 0===e.announceList&&(n=n.concat(Wo.announceList)),"string"==typeof e.urlList&&(e.urlList=[e.urlList]);const i={info:{name:e.name},"creation date":eo((+e.creationDate||Date.now())/1e3),encoding:"UTF-8"};0!==n.length&&(i.announce=n[0][0],i["announce-list"]=n),void 0!==e.comment&&(i.comment=e.comment),void 0!==e.createdBy&&(i["created by"]=e.createdBy),void 0!==e.private&&(i.info.private=+e.private),void 0!==e.sslCert&&(i.info["ssl-cert"]=e.sslCert),void 0!==e.urlList&&(i["url-list"]=e.urlList);const o=e.pieceLength||(l=a.reduce(t,0),Ro(l/dt,Ao));var l;i.info["piece length"]=o,function(n,e,t){function _(n){i+=n.length;const r=y;qo(n,t=>{m[r]=t,o-=1,g()}),o+=1,y+=1}function l(){w=!0,g()}function f(n){p(),t(n)}function p(){S.removeListener("error",f),k.removeListener("data",_),k.removeListener("end",l),k.removeListener("error",f)}function g(){w&&0==o&&(p(),t(null,u.from(m.join(""),"hex"),i))}t=Ot(t);const m=[];let i=0;const b=n.map(t=>t.getStream);let o=0,y=0,w=!1;const S=new Tt(b),k=new Io(e,{zeroPadding:!1});S.on("error",f),S.pipe(k).on("data",_).on("end",l).on("error",f)}(a,o,(o,t,n)=>o?r(o):void(i.info.pieces=t,a.forEach(t=>{delete t.getStream}),e.singleFileTorrent?i.info.length=n:i.info.files=a,r(null,te.encode(i))))}(e,a,c)))}).parseInput=function(r,e,o){"function"==typeof e&&([e,o]=[o,e]),l(r,e=e?Object.assign({},e):{},o)},Wo.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"]]}).call(this,pe,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,p({}).Buffer);var jo={};(function(n){jo.log=function(...t){return"object"==typeof console&&console.log&&console.log(...t)},jo.formatArgs=function(o){if(o[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+o[0]+(this.useColors?"%c ":" ")+"+"+jo.humanize(this.diff),!this.useColors)return;const e="color: "+this.color;o.splice(1,0,e,"color: inherit");let t=0,d=0;o[0].replace(/%[a-zA-Z%]/g,n=>{"%%"!==n&&(t++,"%c"===n&&(d=t))}),o.splice(d,0,e)},jo.save=function(t){try{t?jo.storage.setItem("debug",t):jo.storage.removeItem("debug")}catch(e){}},jo.load=function(){let e;try{e=jo.storage.getItem("debug")}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e},jo.useColors=function(){return"undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},jo.storage=function(){try{return localStorage}catch(t){}}(),jo.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],jo=function(o){function d(r){let e=0;for(let t=0;t<r.length;t++)e=(e<<5)-e+r.charCodeAt(t),e|=0;return l.colors[oo(e)%l.colors.length]}function l(r){function c(...d){if(!c.enabled)return;const e=c,t=+new Date,n=t-(o||t);e.diff=n,e.prev=o,e.curr=t,o=t,d[0]=l.coerce(d[0]),"string"!=typeof d[0]&&d.unshift("%O");let u=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(t,n)=>{if("%%"===t)return t;u++;const o=l.formatters[n];if("function"==typeof o){const r=d[u];t=o.call(e,r),d.splice(u,1),u--}return t}),l.formatArgs.call(e,d),(e.log||l.log).apply(e,d)}let o;return c.namespace=r,c.enabled=l.enabled(r),c.useColors=l.useColors(),c.color=d(r),c.destroy=t,c.extend=n,"function"==typeof l.init&&l.init(c),l.instances.push(c),c}function t(){const t=l.instances.indexOf(this);return-1!==t&&(l.instances.splice(t,1),!0)}function n(n,e){const t=l(this.namespace+(void 0===e?":":e)+n);return t.log=this.log,t}function r(t){return t.toString().substring(2,t.toString().length-2).replace(/\.\*\?$/,"*")}return l.debug=l,l.default=l,l.coerce=function(t){return t instanceof Error?t.stack||t.message:t},l.disable=function(){const t=[...l.names.map(r),...l.skips.map(r).map(t=>"-"+t)].join(",");return l.enable(""),t},l.enable=function(n){let o;l.save(n),l.names=[],l.skips=[];const d=("string"==typeof n?n:"").split(/[\s,]+/),r=d.length;for(o=0;o<r;o++)d[o]&&("-"===(n=d[o].replace(/\*/g,".*?"))[0]?l.skips.push(new RegExp("^"+n.substr(1)+"$")):l.names.push(new RegExp("^"+n+"$")));for(o=0;o<l.instances.length;o++){const t=l.instances[o];t.enabled=l.enabled(t.namespace)}},l.enabled=function(n){if("*"===n[n.length-1])return!0;let e,o;for(e=0,o=l.skips.length;e<o;e++)if(l.skips[e].test(n))return!1;for(e=0,o=l.names.length;e<o;e++)if(l.names[e].test(n))return!0;return!1},l.humanize=a({}),Object.keys(o).forEach(e=>{l[e]=o[e]}),l.instances=[],l.names=[],l.skips=[],l.formatters={},l.selectColor=d,l.enable(l.load()),l}(jo);const{formatters:e}=jo;e.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,pe);var zo={};(function(o){zo=function(e,d){if("undefined"==typeof Blob||!(e instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof d)throw new Error("second argument must be a function");var n=new FileReader;n.addEventListener("loadend",function e(t){n.removeEventListener("loadend",e,!1),t.error?d(t.error):d(null,o.from(n.result))},!1),n.readAsArrayBuffer(e)}}).call(this,p({}).Buffer);var Vo={};(function(d){function a(){if(void 0!==r)return r;if(d.XMLHttpRequest){r=new d.XMLHttpRequest;try{r.open("GET",d.XDomainRequest?"/":"https://example.com")}catch(e){r=null}}else r=null;return r}function e(n){var e=a();if(!e)return!1;try{return e.responseType=n,e.responseType===n}catch(e){}return!1}function n(t){return"function"==typeof t}Vo.fetch=n(d.fetch)&&n(d.ReadableStream),Vo.writableStream=n(d.WritableStream),Vo.abortController=n(d.AbortController),Vo.blobConstructor=!1;try{new Blob([new ArrayBuffer(1)]),Vo.blobConstructor=!0}catch(e){}var r,o=void 0!==d.ArrayBuffer,i=o&&n(d.ArrayBuffer.prototype.slice);Vo.arraybuffer=Vo.fetch||o&&e("arraybuffer"),Vo.msstream=!Vo.fetch&&i&&e("ms-stream"),Vo.mozchunkedarraybuffer=!Vo.fetch&&o&&e("moz-chunked-arraybuffer"),Vo.overrideMimeType=Vo.fetch||!!a()&&n(a().overrideMimeType),Vo.vbArray=n(d.VBArray),r=null}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global);var Xt={};(function(d){"use strict";Xt=void 0!==d&&d.version&&0!==d.version.indexOf("v0.")&&(0!==d.version.indexOf("v1.")||0===d.version.indexOf("v1.8."))?d:{nextTick:function(e,t,n,r){if("function"!=typeof e)throw new TypeError("\"callback\" argument must be a function");var i,l,c=arguments.length;switch(c){case 0:case 1:return d.nextTick(e);case 2:return d.nextTick(function(){e.call(null,t)});case 3:return d.nextTick(function(){e.call(null,t,n)});case 4:return d.nextTick(function(){e.call(null,t,n,r)});default:for(i=Array(c-1),l=0;l<i.length;)i[l++]=arguments[l];return d.nextTick(function(){e.apply(null,i)});}}}}).call(this,pe);var Go={}.toString,Qt=Array.isArray||function(t){return"[object Array]"==Go.call(t)},en=m.EventEmitter,tn={},Ko=p({}),rn=Ko.Buffer;rn.from&&rn.alloc&&rn.allocUnsafe&&rn.allocUnsafeSlow?tn=Ko:(Nt(Ko,tn),tn.Buffer=Gt),Nt(rn,Gt),Gt.from=function(r,e,t){if("number"==typeof r)throw new TypeError("Argument must not be a number");return rn(r,e,t)},Gt.alloc=function(o,e,t){if("number"!=typeof o)throw new TypeError("Argument must be a number");var n=rn(o);return void 0===e?n.fill(0):"string"==typeof t?n.fill(e,t):n.fill(e),n},Gt.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return rn(t)},Gt.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return Ko.SlowBuffer(t)};var sn={};(function(n){function r(t){return Object.prototype.toString.call(t)}sn.isArray=function(t){return Array.isArray?Array.isArray(t):"[object Array]"===r(t)},sn.isBoolean=function(t){return"boolean"==typeof t},sn.isNull=function(t){return null===t},sn.isNullOrUndefined=function(t){return null==t},sn.isNumber=function(t){return"number"==typeof t},sn.isString=function(t){return"string"==typeof t},sn.isSymbol=function(t){return"symbol"==typeof t},sn.isUndefined=function(t){return void 0===t},sn.isRegExp=function(t){return"[object RegExp]"===r(t)},sn.isObject=function(t){return"object"==typeof t&&null!==t},sn.isDate=function(t){return"[object Date]"===r(t)},sn.isError=function(t){return"[object Error]"===r(t)||t instanceof Error},sn.isFunction=function(t){return"function"==typeof t},sn.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},sn.isBuffer=n.isBuffer}).call(this,{isBuffer:function(t){return null!=t&&(on(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&on(t.slice(0,0))}(t)||!!t._isBuffer)}});var cn={},Yo=tn.Buffer;cn=function(){function n(){!function(e){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this),this.head=null,this.tail=null,this.length=0}return n.prototype.push=function(n){var e={data:n,next:null};0<this.length?this.tail.next=e:this.head=e,this.tail=e,++this.length},n.prototype.unshift=function(n){var e={data:n,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},n.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return this.head=1===this.length?this.tail=null:this.head.next,--this.length,t}},n.prototype.clear=function(){this.head=this.tail=null,this.length=0},n.prototype.join=function(r){if(0===this.length)return"";for(var e=this.head,o=""+e.data;e=e.next;)o+=r+e.data;return o},n.prototype.concat=function(o){if(0===this.length)return Yo.alloc(0);if(1===this.length)return this.head.data;for(var e,d,a=Yo.allocUnsafe(o>>>0),r=this.head,l=0;r;)e=a,d=l,r.data.copy(e,d),l+=r.data.length,r=r.next;return a},n}(),oe.inspect&&oe.inspect.custom&&(cn.prototype[oe.inspect.custom]=function(){var t=oe.inspect({length:this.length});return this.constructor.name+" "+t});var dn={destroy:function(o,d){var t=this,e=this._readableState&&this._readableState.destroyed,n=this._writableState&&this._writableState.destroyed;return e||n?(d?d(o):!o||this._writableState&&this._writableState.errorEmitted||Xt.nextTick(an,this,o),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(o||null,function(n){!d&&n?(Xt.nextTick(an,t,n),t._writableState&&(t._writableState.errorEmitted=!0)):d&&d(n)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}},fn=hn,pn=fo({});sn.inherits=Me,sn.inherits(hn,pn),hn.prototype.push=function(n,e){return this._transformState.needTransform=!1,pn.prototype.push.call(this,n,e)},hn.prototype._transform=function(){throw new Error("_transform() is not implemented")},hn.prototype._write=function(o,e,t){var n=this._transformState;if(n.writecb=t,n.writechunk=o,n.writeencoding=e,!n.transforming){var r=this._readableState;(n.needTransform||r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}},hn.prototype._read=function(){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},hn.prototype._destroy=function(r,o){var t=this;pn.prototype._destroy.call(this,r,function(n){o(n),t.emit("close")})};sn.inherits=Me,sn.inherits(bn,fn),bn.prototype._transform=function(r,e,t){t(null,r)};var gn={};(gn=gn=t({})).Stream=gn,gn.Readable=gn,gn.Writable=r({}),gn.Duplex=fo({}),gn.Transform=fn,gn.PassThrough=bn;var $o={};(function(o,d,l){var t=$o.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},e=$o.IncomingMessage=function(e,t,n,i){var s=this;if(gn.Readable.call(s),s._mode=n,s.headers={},s.rawHeaders=[],s.trailers={},s.rawTrailers=[],s.on("end",function(){o.nextTick(function(){s.emit("close")})}),"fetch"===n){if(s._fetchResponse=t,s.url=t.url,s.statusCode=t.status,s.statusMessage=t.statusText,t.headers.forEach(function(n,e){s.headers[e.toLowerCase()]=n,s.rawHeaders.push(e,n)}),Vo.writableStream){var r=new WritableStream({write:function(n){return new Promise(function(e,t){s._destroyed?t():s.push(new l(n))?e():s._resumeFetch=e})},close:function(){d.clearTimeout(i),s._destroyed||s.push(null)},abort:function(t){s._destroyed||s.emit("error",t)}});try{return void t.body.pipeTo(r).catch(function(t){d.clearTimeout(i),s._destroyed||s.emit("error",t)})}catch(e){}}var a=t.body.getReader();!function t(){a.read().then(function(e){if(!s._destroyed){if(e.done)return d.clearTimeout(i),void s.push(null);s.push(new l(e.value)),t()}}).catch(function(t){d.clearTimeout(i),s._destroyed||s.emit("error",t)})}()}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(r){var e=r.match(/^([^:]+):\s*(.*)/);if(e){var t=e[1].toLowerCase();"set-cookie"===t?(void 0===s.headers[t]&&(s.headers[t]=[]),s.headers[t].push(e[2])):void 0===s.headers[t]?s.headers[t]=e[2]:s.headers[t]+=", "+e[2],s.rawHeaders.push(e[1],e[2])}}),s._charset="x-user-defined",!Vo.overrideMimeType){var c=s.rawHeaders["mime-type"];if(c){var u=c.match(/;\s*charset=([^;])(;|$)/);u&&(s._charset=u[1].toLowerCase())}s._charset||(s._charset="utf-8")}};Me(e,gn.Readable),e.prototype._read=function(){var t=this._resumeFetch;t&&(this._resumeFetch=null,t())},e.prototype._onXHRProgress=function(){var n=this,e=n._xhr,r=null;switch(n._mode){case"text:vbarray":if(e.readyState!==t.DONE)break;try{r=new d.VBArray(e.responseBody).toArray()}catch(e){}if(null!==r){n.push(new l(r));break}case"text":try{r=e.responseText}catch(e){n._mode="text:vbarray";break}if(r.length>n._pos){var i=r.substr(n._pos);if("x-user-defined"===n._charset){for(var o=new l(i.length),a=0;a<i.length;a++)o[a]=255&i.charCodeAt(a);n.push(o)}else n.push(i,n._charset);n._pos=r.length}break;case"arraybuffer":if(e.readyState!==t.DONE||!e.response)break;r=e.response,n.push(new l(new Uint8Array(r)));break;case"moz-chunked-arraybuffer":if(r=e.response,e.readyState!==t.LOADING||!r)break;n.push(new l(new Uint8Array(r)));break;case"ms-stream":if(r=e.response,e.readyState!==t.LOADING)break;var u=new d.MSStreamReader;u.onprogress=function(){u.result.byteLength>n._pos&&(n.push(new l(new Uint8Array(u.result.slice(n._pos)))),n._pos=u.result.byteLength)},u.onload=function(){n.push(null)},u.readAsArrayBuffer(r);}n._xhr.readyState===t.DONE&&"ms-stream"!==n._mode&&n.push(null)}}).call(this,pe,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,p({}).Buffer);var kn=p({}).Buffer,Sn=function(o){if(o instanceof Uint8Array){if(0===o.byteOffset&&o.byteLength===o.buffer.byteLength)return o.buffer;if("function"==typeof o.buffer.slice)return o.buffer.slice(o.byteOffset,o.byteOffset+o.byteLength)}if(kn.isBuffer(o)){for(var e=new Uint8Array(o.length),t=o.length,n=0;n<t;n++)e[n]=o[n];return e.buffer}throw new Error("Argument must be a Buffer")},Cn={};(function(d,l,f){var t=$o.IncomingMessage,e=$o.readyStates,n=Cn=function(n){var e,o=this;gn.Writable.call(o),o._opts=n,o._body=[],o._headers={},n.auth&&o.setHeader("Authorization","Basic "+new f(n.auth).toString("base64")),Object.keys(n.headers).forEach(function(e){o.setHeader(e,n.headers[e])});var r=!0;if("disable-fetch"===n.mode||"requestTimeout"in n&&!Vo.abortController)r=!1,e=!0;else if("prefer-streaming"===n.mode)e=!1;else if("allow-wrong-content-type"===n.mode)e=!Vo.overrideMimeType;else{if(n.mode&&"default"!==n.mode&&"prefer-fast"!==n.mode)throw new Error("Invalid value for opts.mode");e=!0}o._mode=function(n,e){return Vo.fetch&&e?"fetch":Vo.mozchunkedarraybuffer?"moz-chunked-arraybuffer":Vo.msstream?"ms-stream":Vo.arraybuffer&&n?"arraybuffer":Vo.vbArray&&n?"text:vbarray":"text"}(e,r),o._fetchTimer=null,o.on("finish",function(){o._onFinish()})};Me(n,gn.Writable),n.prototype.setHeader=function(o,e){var t=o.toLowerCase();-1===r.indexOf(t)&&(this._headers[t]={name:o,value:e})},n.prototype.getHeader=function(n){var e=this._headers[n.toLowerCase()];return e?e.value:null},n.prototype.removeHeader=function(t){delete this._headers[t.toLowerCase()]},n.prototype._onFinish=function(){var t=this;if(!t._destroyed){var n=t._opts,r=t._headers,o=null;"GET"!==n.method&&"HEAD"!==n.method&&(o=Vo.arraybuffer?Sn(f.concat(t._body)):Vo.blobConstructor?new l.Blob(t._body.map(function(t){return Sn(t)}),{type:(r["content-type"]||{}).value||""}):f.concat(t._body).toString());var i=[];if(Object.keys(r).forEach(function(o){var d=r[o].name,e=r[o].value;Array.isArray(e)?e.forEach(function(t){i.push([d,t])}):i.push([d,e])}),"fetch"===t._mode){var s=null;if(Vo.abortController){var p=new AbortController;s=p.signal,t._fetchAbortController=p,"requestTimeout"in n&&0!==n.requestTimeout&&(t._fetchTimer=l.setTimeout(function(){t.emit("requestTimeout"),t._fetchAbortController&&t._fetchAbortController.abort()},n.requestTimeout))}l.fetch(t._opts.url,{method:t._opts.method,headers:i,body:o||void 0,mode:"cors",credentials:n.withCredentials?"include":"same-origin",signal:s}).then(function(n){t._fetchResponse=n,t._connect()},function(n){l.clearTimeout(t._fetchTimer),t._destroyed||t.emit("error",n)})}else{var u=t._xhr=new l.XMLHttpRequest;try{u.open(t._opts.method,t._opts.url,!0)}catch(e){return void d.nextTick(function(){t.emit("error",e)})}"responseType"in u&&(u.responseType=t._mode.split(":")[0]),"withCredentials"in u&&(u.withCredentials=!!n.withCredentials),"text"===t._mode&&"overrideMimeType"in u&&u.overrideMimeType("text/plain; charset=x-user-defined"),"requestTimeout"in n&&(u.timeout=n.requestTimeout,u.ontimeout=function(){t.emit("requestTimeout")}),i.forEach(function(t){u.setRequestHeader(t[0],t[1])}),t._response=null,u.onreadystatechange=function(){switch(u.readyState){case e.LOADING:case e.DONE:t._onXHRProgress();}},"moz-chunked-arraybuffer"===t._mode&&(u.onprogress=function(){t._onXHRProgress()}),u.onerror=function(){t._destroyed||t.emit("error",new Error("XHR error"))};try{u.send(o)}catch(e){return void d.nextTick(function(){t.emit("error",e)})}}}},n.prototype._onXHRProgress=function(){(function(n){try{var e=n.status;return null!==e&&0!==e}catch(e){return!1}})(this._xhr)&&!this._destroyed&&(this._response||this._connect(),this._response._onXHRProgress())},n.prototype._connect=function(){var n=this;n._destroyed||(n._response=new t(n._xhr,n._fetchResponse,n._mode,n._fetchTimer),n._response.on("error",function(e){n.emit("error",e)}),n.emit("response",n._response))},n.prototype._write=function(r,e,t){this._body.push(r),t()},n.prototype.abort=n.prototype.destroy=function(){this._destroyed=!0,l.clearTimeout(this._fetchTimer),this._response&&(this._response._destroyed=!0),this._xhr?this._xhr.abort():this._fetchAbortController&&this._fetchAbortController.abort()},n.prototype.end=function(r,o,t){"function"==typeof r&&(t=r,r=void 0),gn.Writable.prototype.end.call(this,r,o,t)},n.prototype.flushHeaders=function(){},n.prototype.setTimeout=function(){},n.prototype.setNoDelay=function(){},n.prototype.setSocketKeepAlive=function(){};var r=["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","via"]}).call(this,pe,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,p({}).Buffer);var Xo=Object.prototype.hasOwnProperty,Tn={100:"Continue",101:"Switching Protocols",102:"Processing",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",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"},An={exports:{}};(function(d){!function(e){function a(t){throw new RangeError(y[t])}function l(o,e){for(var t=o.length,d=[];t--;)d[t]=e(o[t]);return d}function c(o,d){var t=o.split("@"),n="";return 1<t.length&&(n=t[0]+"@",o=t[1]),n+l((o=o.replace(_,".")).split("."),d).join(".")}function u(o){for(var e,d,a=[],r=0,l=o.length;r<l;)55296<=(e=o.charCodeAt(r++))&&56319>=e&&r<l?56320==(64512&(d=o.charCodeAt(r++)))?a.push(((1023&e)<<10)+(1023&d)+65536):(a.push(e),r--):a.push(e);return a}function f(t){return l(t,function(n){var r="";return 65535<n&&(r+=v(55296|1023&(n-=65536)>>>10),n=56320|1023&n),r+v(n)}).join("")}function p(n,e){return n+22+75*(26>n)-((0!=e)<<5)}function h(o,d,t){var n=0;for(o=t?x(o/700):o>>1,o+=x(o/d);o>455;n+=36)o=x(o/35);return x(n+36*o/(o+38))}function g(c){var e,u,p,g,k,v,L,T,B,I,R,A=[],b=c.length,w=0,U=128,P=72;for(0>(u=c.lastIndexOf("-"))&&(u=0),p=0;p<u;++p)128<=c.charCodeAt(p)&&a("not-basic"),A.push(c.charCodeAt(p));for(g=0<u?u+1:0;g<b;){for(k=w,v=1,L=36;g>=b&&a("invalid-input"),((T=10>(R=c.charCodeAt(g++))-48?R-22:26>R-65?R-65:26>R-97?R-97:36)>=36||T>x((2147483647-w)/v))&&a("overflow"),w+=T*v,!(T<(B=L<=P?1:L>=P+26?26:L-P));L+=36)v>x(2147483647/(I=36-B))&&a("overflow"),v*=I;P=h(w-k,e=A.length+1,0==k),x(w/e)>2147483647-U&&a("overflow"),U+=x(w/e),w%=e,A.splice(w++,0,U)}return f(A)}function w(c){var f,g,k,E,L,B,I,R,A,U,P,M,O,N,H,D=[];for(M=(c=u(c)).length,f=128,g=0,L=72,B=0;B<M;++B)128>(P=c[B])&&D.push(v(P));for(k=E=D.length,E&&D.push("-");k<M;){for(I=2147483647,B=0;B<M;++B)(P=c[B])>=f&&P<I&&(I=P);for(I-f>x((2147483647-g)/(O=k+1))&&a("overflow"),g+=(I-f)*O,f=I,B=0;B<M;++B)if((P=c[B])<f&&++g>2147483647&&a("overflow"),P==f){for(R=g,A=36;!(R<(U=A<=L?1:A>=L+26?26:A-L));A+=36)H=R-U,N=36-U,D.push(v(p(U+H%N,0))),R=x(H/N);D.push(v(p(R,0))),L=h(g,O,k==E),g=0,++k}++g,++f}return D.join("")}var S="object"==typeof An.exports&&An.exports&&!An.exports.nodeType&&An.exports,n=An&&!An.nodeType&&An,r="object"==typeof d&&d;r.global!==r&&r.window!==r&&r.self!==r||(e=r);var i,k,C=/^xn--/,m=/[^\x20-\x7E]/,_=/[\x2E\u3002\uFF0E\uFF61]/g,y={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},x=io,v=ro;if(!(i={version:"1.4.1",ucs2:{decode:u,encode:f},decode:g,encode:w,toASCII:function(t){return c(t,function(t){return m.test(t)?"xn--"+w(t):t})},toUnicode:function(t){return c(t,function(t){return C.test(t)?g(t.slice(4).toLowerCase()):t})}},S&&n))e.punycode=i;else if(An.exports==S)n.exports=i;else for(k in i)i.hasOwnProperty(k)&&(S[k]=i[k])}(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global),An=An.exports;var Qo={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}},Rn=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Ln=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return"";}},Un=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},On=Object.keys||function(r){var e=[];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.push(t);return e},Pn={parse:function(g,m,_,b){m=m||"&",_=_||"=";var r={};if("string"!=typeof g||0===g.length)return r;var i=/\+/g;g=g.split(m);var s=1e3;b&&"number"==typeof b.maxKeys&&(s=b.maxKeys);var y=g.length;0<s&&y>s&&(y=s);for(var w=0;w<y;++w){var S,k,E,v,C=g[w].replace(i,"%20"),f=C.indexOf(_);0<=f?(S=C.substr(0,f),k=C.substr(f+1)):(S=C,k=""),E=decodeURIComponent(S),v=decodeURIComponent(k),yn(r,E)?Rn(r[E])?r[E].push(v):r[E]=[r[E],v]:r[E]=v}return r},stringify:function(o,d,a,i){return d=d||"&",a=a||"=",null===o&&(o=void 0),"object"==typeof o?wn(On(o),function(e){var t=encodeURIComponent(Ln(e))+a;return Un(o[e])?wn(o[e],function(n){return t+encodeURIComponent(Ln(n))}).join(d):t+encodeURIComponent(Ln(o[e]))}).join(d):i?encodeURIComponent(Ln(i))+a+encodeURIComponent(Ln(o)):""}},Nn={};Nn.parse=Bn;var jn=/^([a-z0-9.+-]+:)/i,Hn=/:[0-9]*$/,qn=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,Fn=["{","}","|","\\","^","`"].concat(["<",">","\"","`"," ","\r","\n","\t"]),Wn=["'"].concat(Fn),zn=["%","/","?",";","#"].concat(Wn),$n=["/","?","#"],Vn=/^[+a-z0-9A-Z_-]{0,63}$/,Gn=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Kn={javascript:!0,"javascript:":!0},Yn={javascript:!0,"javascript:":!0},Jn={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};vn.prototype.parse=function(U,P,t){if(!Qo.isString(U))throw new TypeError("Parameter 'url' must be a string, not "+typeof U);var n=U.indexOf("?"),r=-1!==n&&n<U.indexOf("#")?"?":"#",i=U.split(r);i[0]=i[0].replace(/\\/g,"/");var s=U=i.join(r);if(s=s.trim(),!t&&1===U.split("#").length){var M=qn.exec(s);if(M)return this.path=s,this.href=s,this.pathname=M[1],M[2]?(this.search=M[2],this.query=P?Pn.parse(this.search.substr(1)):this.search.substr(1)):P&&(this.search="",this.query={}),this}var a=jn.exec(s);if(a){var O=(a=a[0]).toLowerCase();this.protocol=O,s=s.substr(a.length)}if(t||a||s.match(/^\/\/[^@\/]+@[^@\/]+/)){var c="//"===s.substr(0,2);!c||a&&Yn[a]||(s=s.substr(2),this.slashes=!0)}if(!Yn[a]&&(c||a&&!Jn[a])){for(var u,N,H=-1,D=0;D<$n.length;D++)-1!==(q=s.indexOf($n[D]))&&(-1===H||q<H)&&(H=q);for(-1!==(N=-1===H?s.lastIndexOf("@"):s.lastIndexOf("@",H))&&(u=s.slice(0,N),s=s.slice(N+1),this.auth=decodeURIComponent(u)),H=-1,D=0;D<zn.length;D++){var q;-1!==(q=s.indexOf(zn[D]))&&(-1===H||q<H)&&(H=q)}-1===H&&(H=s.length),this.host=s.slice(0,H),s=s.slice(H),this.parseHost(),this.hostname=this.hostname||"";var F="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!F)for(var m,W=this.hostname.split(/\./),_=(D=0,W.length);D<_;D++)if(m=W[D],m&&!m.match(Vn)){for(var j="",z=0,V=m.length;z<V;z++)j+=127<m.charCodeAt(z)?"x":m[z];if(!j.match(Vn)){var E=W.slice(0,D),k=W.slice(D+1),S=m.match(Gn);S&&(E.push(S[1]),k.unshift(S[2])),k.length&&(s="/"+k.join(".")+s),this.hostname=E.join(".");break}}this.hostname=255<this.hostname.length?"":this.hostname.toLowerCase(),F||(this.hostname=An.toASCII(this.hostname));var C=this.port?":"+this.port:"",G=this.hostname||"";this.host=G+C,this.href+=this.host,F&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==s[0]&&(s="/"+s))}if(!Kn[O])for(D=0,_=Wn.length;D<_;D++){var T=Wn[D];if(-1!==s.indexOf(T)){var A=encodeURIComponent(T);A===T&&(A=escape(T)),s=s.split(T).join(A)}}var K=s.indexOf("#");-1!==K&&(this.hash=s.substr(K),s=s.slice(0,K));var R=s.indexOf("?");if(-1===R?P&&(this.search="",this.query={}):(this.search=s.substr(R),this.query=s.substr(R+1),P&&(this.query=Pn.parse(this.query)),s=s.slice(0,R)),s&&(this.pathname=s),Jn[O]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){C=this.pathname||"";var B=this.search||"";this.path=C+B}return this.href=this.format(),this},vn.prototype.format=function(){var d=this.auth||"";d&&(d=(d=encodeURIComponent(d)).replace(/%3A/i,":"),d+="@");var a=this.protocol||"",l=this.pathname||"",c=this.hash||"",u=!1,f="";this.host?u=d+this.host:this.hostname&&(u=d+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(u+=":"+this.port)),this.query&&Qo.isObject(this.query)&&Object.keys(this.query).length&&(f=Pn.stringify(this.query));var p=this.search||f&&"?"+f||"";return a&&":"!==a.substr(-1)&&(a+=":"),this.slashes||(!a||Jn[a])&&!1!==u?(u="//"+(u||""),l&&"/"!==l.charAt(0)&&(l="/"+l)):u||(u=""),c&&"#"!==c.charAt(0)&&(c="#"+c),p&&"?"!==p.charAt(0)&&(p="?"+p),a+u+(l=l.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(p=p.replace("#","%23"))+c},vn.prototype.resolve=function(t){return this.resolveObject(Bn(t,!1,!0)).format()},vn.prototype.resolveObject=function(L){if(Qo.isString(L)){var T=new vn;T.parse(L,!1,!0),L=T}for(var t,B=new vn,n=Object.keys(this),r=0;r<n.length;r++)t=n[r],B[t]=this[t];if(B.hash=L.hash,""===L.href)return B.href=B.format(),B;if(L.slashes&&!L.protocol){for(var I,R=Object.keys(L),o=0;o<R.length;o++)I=R[o],"protocol"!==I&&(B[I]=L[I]);return Jn[B.protocol]&&B.hostname&&!B.pathname&&(B.path=B.pathname="/"),B.href=B.format(),B}if(L.protocol&&L.protocol!==B.protocol){if(!Jn[L.protocol]){for(var A,U=Object.keys(L),c=0;c<U.length;c++)A=U[c],B[A]=L[A];return B.href=B.format(),B}if(B.protocol=L.protocol,L.host||Yn[L.protocol])B.pathname=L.pathname;else{for(var P=(L.pathname||"").split("/");P.length&&!(L.host=P.shift()););L.host||(L.host=""),L.hostname||(L.hostname=""),""!==P[0]&&P.unshift(""),2>P.length&&P.unshift(""),B.pathname=P.join("/")}if(B.search=L.search,B.query=L.query,B.host=L.host||"",B.auth=L.auth,B.hostname=L.hostname||L.host,B.port=L.port,B.pathname||B.search){var M=B.pathname||"",f=B.search||"";B.path=M+f}return B.slashes=B.slashes||L.slashes,B.href=B.format(),B}var p=B.pathname&&"/"===B.pathname.charAt(0),g=L.host||L.pathname&&"/"===L.pathname.charAt(0),m=g||p||B.host&&L.pathname,O=m,y=B.pathname&&B.pathname.split("/")||[],N=(P=L.pathname&&L.pathname.split("/")||[],B.protocol&&!Jn[B.protocol]);if(N&&(B.hostname="",B.port=null,B.host&&(""===y[0]?y[0]=B.host:y.unshift(B.host)),B.host="",L.protocol&&(L.hostname=null,L.port=null,L.host&&(""===P[0]?P[0]=L.host:P.unshift(L.host)),L.host=null),m=m&&(""===P[0]||""===y[0])),g)B.host=L.host||""===L.host?L.host:B.host,B.hostname=L.hostname||""===L.hostname?L.hostname:B.hostname,B.search=L.search,B.query=L.query,y=P;else if(P.length)y||(y=[]),y.pop(),y=y.concat(P),B.search=L.search,B.query=L.query;else if(!Qo.isNullOrUndefined(L.search))return N&&(B.hostname=B.host=y.shift(),(q=!!(B.host&&0<B.host.indexOf("@"))&&B.host.split("@"))&&(B.auth=q.shift(),B.host=B.hostname=q.shift())),B.search=L.search,B.query=L.query,Qo.isNull(B.pathname)&&Qo.isNull(B.search)||(B.path=(B.pathname?B.pathname:"")+(B.search?B.search:"")),B.href=B.format(),B;if(!y.length)return B.pathname=null,B.path=B.search?"/"+B.search:null,B.href=B.format(),B;for(var w=y.slice(-1)[0],H=(B.host||L.host||1<y.length)&&("."===w||".."===w)||""===w,E=0,D=y.length;0<=D;D--)"."===(w=y[D])?y.splice(D,1):".."===w?(y.splice(D,1),E++):E&&(y.splice(D,1),E--);if(!m&&!O)for(;E--;E)y.unshift("..");!m||""===y[0]||y[0]&&"/"===y[0].charAt(0)||y.unshift(""),H&&"/"!==y.join("/").substr(-1)&&y.push("");var q,F=""===y[0]||y[0]&&"/"===y[0].charAt(0);return N&&(B.hostname=B.host=F?"":y.length?y.shift():"",(q=!!(B.host&&0<B.host.indexOf("@"))&&B.host.split("@"))&&(B.auth=q.shift(),B.host=B.hostname=q.shift())),(m=m||B.host&&y.length)&&!F&&y.unshift(""),y.length?B.pathname=y.join("/"):(B.pathname=null,B.path=null),Qo.isNull(B.pathname)&&Qo.isNull(B.search)||(B.path=(B.pathname?B.pathname:"")+(B.search?B.search:"")),B.auth=L.auth||B.auth,B.slashes=B.slashes||L.slashes,B.href=B.format(),B},vn.prototype.parseHost=function(){var n=this.host,r=Hn.exec(n);r&&(":"!==(r=r[0])&&(this.port=r.substr(1)),n=n.substr(0,n.length-r.length)),n&&(this.hostname=n)};var Xn={};(function(d){var o=Xn;o.request=function(e,l){e="string"==typeof e?Nn.parse(e):function(){for(var o,d={},e=0;e<arguments.length;e++)for(var a in o=arguments[e],o)Xo.call(o,a)&&(d[a]=o[a]);return d}(e);var n=-1===d.location.protocol.search(/^https?:$/)?"http:":"",r=e.protocol||n,i=e.hostname||e.host,c=e.port,o=e.path||"/";i&&-1!==i.indexOf(":")&&(i="["+i+"]"),e.url=(i?r+"//"+i:"")+(c?":"+c:"")+o,e.method=(e.method||"GET").toUpperCase(),e.headers=e.headers||{};var a=new Cn(e);return l&&a.on("response",l),a},o.get=function(t,e){var n=o.request(t,e);return n.end(),n},o.ClientRequest=Cn,o.IncomingMessage=$o.IncomingMessage,o.Agent=function(){},o.Agent.defaultMaxSockets=4,o.globalAgent=new o.Agent,o.STATUS_CODES=Tn,o.METHODS=["CHECKOUT","CONNECT","COPY","DELETE","GET","HEAD","LOCK","M-SEARCH","MERGE","MKACTIVITY","MKCOL","MOVE","NOTIFY","OPTIONS","PATCH","POST","PROPFIND","PROPPATCH","PURGE","PUT","REPORT","SEARCH","SUBSCRIBE","TRACE","UNLOCK","UNSUBSCRIBE"]}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global);var Qn={},er=Qn;for(var tr in Xn)Xn.hasOwnProperty(tr)&&(er[tr]=Xn[tr]);er.request=function(n,r){return n=Mn(n),Xn.request.call(this,n,r)},er.get=function(n,r){return n=Mn(n),Xn.get.call(this,n,r)};var nr={};(function(d){function o(l,t){if(l=Object.assign({maxRedirects:10},"string"==typeof l?{url:l}:l),t=Ot(t),l.url){const{hostname:r,port:e,protocol:t,auth:n,path:o}=Nn.parse(l.url);delete l.url,r||e||t||n?Object.assign(l,{hostname:r,port:e,protocol:t,auth:n,path:o}):l.path=o}const n={"accept-encoding":"gzip, deflate"};let s;l.headers&&Object.keys(l.headers).forEach(t=>n[t.toLowerCase()]=l.headers[t]),l.headers=n,l.body?s=l.json&&!e(l.body)?JSON.stringify(l.body):l.body:l.form&&(s="string"==typeof l.form?l.form:Pn.stringify(l.form),l.headers["content-type"]="application/x-www-form-urlencoded"),s&&(l.method||(l.method="POST"),e(s)||(l.headers["content-length"]=d.byteLength(s)),l.json&&!l.form&&(l.headers["content-type"]="application/json")),delete l.body,delete l.form,l.json&&(l.headers.accept="application/json"),l.method&&(l.method=l.method.toUpperCase());const c=("https:"===l.protocol?Qn:Xn).request(l,n=>{if(300<=n.statusCode&&400>n.statusCode&&n.headers.location)return l.url=n.headers.location,delete l.headers.host,n.resume(),"POST"===l.method&&[301,302].includes(n.statusCode)&&(l.method="GET",delete l.headers["content-length"],delete l.headers["content-type"]),0==l.maxRedirects--?t(new Error("too many redirects")):o(l,t);t(null,n)});return c.on("timeout",()=>{c.abort(),t(new Error("Request timed out"))}),c.on("error",t),e(s)?s.on("error",t).pipe(c):c.end(s),c}nr=o;const e=t=>null!==t&&"object"==typeof t&&"function"==typeof t.pipe;o.concat=(d,e)=>o(d,(t,o)=>t?e(t):void q(o,(t,r)=>{if(t)return e(t);if(d.json)try{r=JSON.parse(r.toString())}catch(t){return e(t,o,r)}e(null,o,r)})),["get","post","put","patch","head","delete"].forEach(n=>{o[n]=(e,t)=>("string"==typeof e&&(e={url:e}),o(Object.assign({method:n.toUpperCase()},e),t))})}).call(this,p({}).Buffer);var Jo={};(function(d){"use strict";var e=[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];Jo.decode=function(t){var l,u=0,f=0,p=0;d.isBuffer(t)||(t=new d(t));for(var g,m=new d(eo(5*t.length/8)),a=0;a<t.length&&61!==t[a];a++){if(g=t[a]-48,!(g<e.length))throw new Error("Invalid input - it is not base32 encoded string");f=e[g],3>=u?0==(u=(u+5)%8)?(l|=f,m[p]=l,p++,l=0):l|=255&f<<8-u:(l|=255&f>>>(u=(u+5)%8),m[p]=l,p++,l=255&f<<8-u)}return m.slice(0,p)}}).call(this,p({}).Buffer);var sr={};Jo.encode,sr.decode=Jo.decode;var or=function(r,e,t){return 0===r.length?r:e?(t||r.sort(e),function(d,e){for(var t=1,a=d.length,r=d[0],l=d[0],c=1;c<a;++c)if(l=r,e(r=d[c],l)){if(c==t){t++;continue}d[t++]=r}return d.length=t,d}(r,e)):(t||r.sort(),function(o){for(var e=1,d=o.length,n=o[0],a=o[0],l=1;l<d;++l,a=n)if(a=n,(n=o[l])!==a){if(l==e){e++;continue}o[e++]=n}return o.length=e,o}(r))},ar={};(function(o){function e(e){const d={},t=e.split("magnet:?")[1];let n;return(t&&0<=t.length?t.split("&"):[]).forEach(n=>{const e=n.split("=");if(2!==e.length)return;const t=e[0];let r=e[1];if(!("dn"===t&&(r=decodeURIComponent(r).replace(/\+/g," ")),"tr"!==t&&"xs"!==t&&"as"!==t&&"ws"!==t||(r=decodeURIComponent(r)),"kt"===t&&(r=decodeURIComponent(r).split("+")),"ix"===t&&(r=+r),d[t]))d[t]=r;else if(Array.isArray(d[t]))d[t].push(r);else{const n=d[t];d[t]=[n,r]}}),d.xt&&(Array.isArray(d.xt)?d.xt:[d.xt]).forEach(e=>{if(n=e.match(/^urn:btih:(.{40})/))d.infoHash=n[1].toLowerCase();else if(n=e.match(/^urn:btih:(.{32})/)){const e=sr.decode(n[1]);d.infoHash=o.from(e,"binary").toString("hex")}}),d.infoHash&&(d.infoHashBuffer=o.from(d.infoHash,"hex")),d.dn&&(d.name=d.dn),d.kt&&(d.keywords=d.kt),d.announce="string"==typeof d.tr?[d.tr]:Array.isArray(d.tr)?d.tr:[],d.urlList=[],("string"==typeof d.as||Array.isArray(d.as))&&(d.urlList=d.urlList.concat(d.as)),("string"==typeof d.ws||Array.isArray(d.ws))&&(d.urlList=d.urlList.concat(d.ws)),or(d.announce),or(d.urlList),d}(ar=e).decode=e,ar.encode=function(o){(o=Object.assign({},o)).infoHashBuffer&&(o.xt=`urn:btih:${o.infoHashBuffer.toString("hex")}`),o.infoHash&&(o.xt=`urn:btih:${o.infoHash}`),o.name&&(o.dn=o.name),o.keywords&&(o.kt=o.keywords),o.announce&&(o.tr=o.announce),o.urlList&&(o.ws=o.urlList,delete o.as);let d="magnet:?";return Object.keys(o).filter(t=>2===t.length).forEach((t,n)=>{(Array.isArray(o[t])?o[t]:[o[t]]).forEach((r,o)=>{(0<n||0<o)&&("kt"!==t||0===o)&&(d+="&"),"dn"===t&&(r=encodeURIComponent(r).replace(/%20/g,"+")),"tr"!==t&&"xs"!==t&&"as"!==t&&"ws"!==t||(r=encodeURIComponent(r)),"kt"===t&&(r=encodeURIComponent(r)),d+="kt"===t&&0<o?`+${r}`:`${t}=${r}`})}),d}}).call(this,p({}).Buffer);var Zo={};(function(o,d){function a(n){if("string"==typeof n&&/^(stream-)?magnet:/.test(n))return ar(n);if("string"==typeof n&&(/^[a-f0-9]{40}$/i.test(n)||/^[a-z2-7]{32}$/i.test(n)))return ar(`magnet:?xt=urn:btih:${n}`);if(d.isBuffer(n)&&20===n.length)return ar(`magnet:?xt=urn:btih:${n.toString("hex")}`);if(d.isBuffer(n))return function(r){d.isBuffer(r)&&(r=te.decode(r)),t(r.info,"info"),t(r.info["name.utf-8"]||r.info.name,"info.name"),t(r.info["piece length"],"info['piece length']"),t(r.info.pieces,"info.pieces"),r.info.files?r.info.files.forEach(n=>{t("number"==typeof n.length,"info.files[0].length"),t(n["path.utf-8"]||n.path,"info.files[0].path")}):t("number"==typeof r.info.length,"info.length");const a={info:r.info,infoBuffer:te.encode(r.info),name:(r.info["name.utf-8"]||r.info.name).toString(),announce:[]};a.infoHash=qo.sync(a.infoBuffer),a.infoHashBuffer=d.from(a.infoHash,"hex"),void 0!==r.info.private&&(a.private=!!r.info.private),r["creation date"]&&(a.created=new Date(1e3*r["creation date"])),r["created by"]&&(a.createdBy=r["created by"].toString()),d.isBuffer(r.comment)&&(a.comment=r.comment.toString()),Array.isArray(r["announce-list"])&&0<r["announce-list"].length?r["announce-list"].forEach(t=>{t.forEach(t=>{a.announce.push(t.toString())})}):r.announce&&a.announce.push(r.announce.toString()),d.isBuffer(r["url-list"])&&(r["url-list"]=0<r["url-list"].length?[r["url-list"]]:[]),a.urlList=(r["url-list"]||[]).map(t=>t.toString()),or(a.announce),or(a.urlList);const n=r.info.files||[r.info];a.files=n.map((r,e)=>{const t=[].concat(a.name,r["path.utf-8"]||r.path||[]).map(t=>t.toString());return{path:pt.join.apply(null,[pt.sep].concat(t)).slice(1),name:t[t.length-1],length:r.length,offset:n.slice(0,e).reduce(l,0)}}),a.length=n.reduce(l,0);const i=a.files[a.files.length-1];return a.pieceLength=r.info["piece length"],a.lastPieceLength=(i.offset+i.length)%a.pieceLength||a.pieceLength,a.pieces=function(r){const e=[];for(let t=0;t<r.length;t+=20)e.push(r.slice(t,t+20).toString("hex"));return e}(r.info.pieces),a}(n);if(n&&n.infoHash)return n.infoHash=n.infoHash.toLowerCase(),n.announce||(n.announce=[]),"string"==typeof n.announce&&(n.announce=[n.announce]),n.urlList||(n.urlList=[]),n;throw new Error("Invalid torrent identifier")}function l(n,e){return n+e.length}function t(n,e){if(!n)throw new Error(`Torrent is missing required field: ${e}`)}(Zo=a).remote=function(e,d){function r(n){try{t=a(n)}catch(e){return d(e)}t&&t.infoHash?d(null,t):d(new Error("Invalid torrent identifier"))}let t;if("function"!=typeof d)throw new Error("second argument must be a Function");try{t=a(e)}catch(e){}t&&t.infoHash?o.nextTick(()=>{d(null,t)}):"undefined"!=typeof Blob&&e instanceof Blob?zo(e,(n,e)=>n?d(new Error(`Error converting Blob: ${n.message}`)):void r(e)):"function"==typeof nr&&/^https?:/.test(e)?nr.concat({url:e,timeout:3e4,headers:{"user-agent":"WebTorrent (https://webtorrent.io)"}},(o,e,t)=>o?d(new Error(`Error downloading torrent: ${o.message}`)):void r(t)):"function"==typeof St.readFile&&"string"==typeof e?St.readFile(e,(n,e)=>n?d(new Error("Invalid torrent identifier")):void r(e)):o.nextTick(()=>{d(new Error("Invalid torrent identifier"))})},Zo.toMagnetURI=ar.encode,Zo.toTorrentFile=function(t){const r={info:t.info};return r["announce-list"]=(t.announce||[]).map(t=>(r.announce||(r.announce=t),[t=d.from(t,"utf8")])),r["url-list"]=t.urlList||[],void 0!==t.private&&(r.private=+t.private),t.created&&(r["creation date"]=0|t.created.getTime()/1e3),t.createdBy&&(r["created by"]=t.createdBy),t.comment&&(r.comment=t.comment),te.encode(r)},d.alloc(0)}).call(this,pe,p({}).Buffer);var ed=function(){if("undefined"==typeof window)return null;var t={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return t.RTCPeerConnection?t:null},ur={};(function(d,e){"use strict";var a=j.Buffer,n=e.crypto||e.msCrypto;ur=n&&n.getRandomValues?function(e,t){if(4294967295<e)throw new RangeError("requested too many random bytes");var r=a.allocUnsafe(e);if(0<e)if(65536<e)for(var i=0;i<e;i+=65536)n.getRandomValues(r.slice(i,i+65536));else n.getRandomValues(r);return"function"==typeof t?d.nextTick(function(){t(null,r)}):r}:function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}}).call(this,pe,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global);var td={};(function(o){function n(r){var o=this;if(!(o instanceof n))return new n(r);if(o._id=ur(4).toString("hex").slice(0,7),o._debug("new peer %o",r),r=Object.assign({allowHalfOpen:!1},r),st.Duplex.call(o,r),o.channelName=r.initiator?r.channelName||ur(20).toString("hex"):null,o.initiator=r.initiator||!1,o.channelConfig=r.channelConfig||n.channelConfig,o.config=Object.assign({},n.config,r.config),o.offerOptions=r.offerOptions||{},o.answerOptions=r.answerOptions||{},o.sdpTransform=r.sdpTransform||function(t){return t},o.streams=r.streams||(r.stream?[r.stream]:[]),o.trickle=void 0===r.trickle||r.trickle,o.allowHalfTrickle=void 0!==r.allowHalfTrickle&&r.allowHalfTrickle,o.iceCompleteTimeout=r.iceCompleteTimeout||5000,o.destroyed=!1,o._connected=!1,o.remoteAddress=void 0,o.remoteFamily=void 0,o.remotePort=void 0,o.localAddress=void 0,o.localFamily=void 0,o.localPort=void 0,o._wrtc=r.wrtc&&"object"==typeof r.wrtc?r.wrtc:ed(),!o._wrtc)throw"undefined"==typeof window?d("No WebRTC support: Specify `opts.wrtc` option in this environment","ERR_WEBRTC_SUPPORT"):d("No WebRTC support: Not a supported browser","ERR_WEBRTC_SUPPORT");o._pcReady=!1,o._channelReady=!1,o._iceComplete=!1,o._iceCompleteTimer=null,o._channel=null,o._pendingCandidates=[],o._isNegotiating=!o.initiator,o._batchedNegotiation=!1,o._queuedNegotiation=!1,o._sendersAwaitingStable=[],o._senderMap=new Map,o._firstStable=!0,o._closingInterval=null,o._remoteTracks=[],o._remoteStreams=[],o._chunk=null,o._cb=null,o._interval=null;try{o._pc=new o._wrtc.RTCPeerConnection(o.config)}catch(e){return void setTimeout(()=>o.destroy(e),0)}o._isReactNativeWebrtc="number"==typeof o._pc._peerConnectionId,o._pc.oniceconnectionstatechange=function(){o._onIceStateChange()},o._pc.onicegatheringstatechange=function(){o._onIceStateChange()},o._pc.onsignalingstatechange=function(){o._onSignalingStateChange()},o._pc.onicecandidate=function(t){o._onIceCandidate(t)},o.initiator?o._setupData({channel:o._pc.createDataChannel(o.channelName,o.channelConfig)}):o._pc.ondatachannel=function(t){o._setupData(t)},o.streams&&o.streams.forEach(function(t){o.addStream(t)}),o._pc.ontrack=function(t){o._onTrack(t)},o.initiator&&o._needsNegotiation(),o._onFinishBound=function(){o._onFinish()},o.once("finish",o._onFinishBound)}function r(t){return t.replace(/a=ice-options:trickle\s\n/g,"")}function d(r,e){var t=new Error(r);return t.code=e,t}td=n;var a=jo("simple-peer");Me(n,st.Duplex),n.WEBRTC_SUPPORT=!!ed(),n.config={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:global.stun.twilio.com:3478?transport=udp"}],sdpSemantics:"unified-plan"},n.channelConfig={},Object.defineProperty(n.prototype,"bufferSize",{get:function(){return this._channel&&this._channel.bufferedAmount||0}}),Object.defineProperty(n.prototype,"connected",{get:function(){return this._connected&&"open"===this._channel.readyState}}),n.prototype.address=function(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}},n.prototype.signal=function(n){var r=this;if(r.destroyed)throw d("cannot signal after peer is destroyed","ERR_SIGNALING");if("string"==typeof n)try{n=JSON.parse(n)}catch(e){n={}}r._debug("signal()"),n.renegotiate&&r.initiator&&(r._debug("got request to renegotiate"),r._needsNegotiation()),n.transceiverRequest&&r.initiator&&(r._debug("got request for transceiver"),r.addTransceiver(n.transceiverRequest.kind,n.transceiverRequest.init)),n.candidate&&(r._pc.localDescription&&r._pc.localDescription.type&&r._pc.remoteDescription&&r._pc.remoteDescription.type?r._addIceCandidate(n.candidate):r._pendingCandidates.push(n.candidate)),n.sdp&&r._pc.setRemoteDescription(new r._wrtc.RTCSessionDescription(n)).then(function(){r.destroyed||(r._pendingCandidates.forEach(function(t){r._addIceCandidate(t)}),r._pendingCandidates=[],"offer"===r._pc.remoteDescription.type&&r._createAnswer())}).catch(function(t){r.destroy(d(t,"ERR_SET_REMOTE_DESCRIPTION"))}),n.sdp||n.candidate||n.renegotiate||n.transceiverRequest||r.destroy(d("signal() called with invalid signal data","ERR_SIGNALING"))},n.prototype._addIceCandidate=function(r){var o=this,t=new o._wrtc.RTCIceCandidate(r);o._pc.addIceCandidate(t).catch(function(n){!t.address||t.address.endsWith(".local")?("Ignoring unsupported ICE candidate.",console.warn("Ignoring unsupported ICE candidate.")):o.destroy(d(n,"ERR_ADD_ICE_CANDIDATE"))})},n.prototype.send=function(t){this._channel.send(t)},n.prototype.addTransceiver=function(n,e){if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(n,e),this._needsNegotiation()}catch(e){this.destroy(e)}else this.emit("signal",{transceiverRequest:{kind:n,init:e}})},n.prototype.addStream=function(r){var e=this;e._debug("addStream()"),r.getTracks().forEach(function(t){e.addTrack(t,r)})},n.prototype.addTrack=function(o,e){this._debug("addTrack()");var t=this._senderMap.get(o)||new Map,n=t.get(e);n?n.removed?this.destroy(d("Track has been removed. You should enable/disable tracks that you want to re-add.","ERR_SENDER_REMOVED")):this.destroy(d("Track has already been added to that stream.","ERR_SENDER_ALREADY_ADDED")):(n=this._pc.addTrack(o,e),t.set(e,n),this._senderMap.set(o,t),this._needsNegotiation())},n.prototype.replaceTrack=function(o,e,t){this._debug("replaceTrack()");var n=this._senderMap.get(o),r=n?n.get(t):null;r||this.destroy(d("Cannot replace track that was never added.","ERR_TRACK_NOT_ADDED")),e&&this._senderMap.set(e,n),null==r.replaceTrack?this.destroy(d("replaceTrack is not supported in this browser","ERR_UNSUPPORTED_REPLACETRACK")):r.replaceTrack(e)},n.prototype.removeTrack=function(o,e){this._debug("removeSender()");var t=this._senderMap.get(o),n=t?t.get(e):null;n||this.destroy(d("Cannot remove track that was never added.","ERR_TRACK_NOT_ADDED"));try{n.removed=!0,this._pc.removeTrack(n)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?this._sendersAwaitingStable.push(n):this.destroy(e)}this._needsNegotiation()},n.prototype.removeStream=function(r){var e=this;e._debug("removeSenders()"),r.getTracks().forEach(function(t){e.removeTrack(t,r)})},n.prototype._needsNegotiation=function(){var t=this;t._debug("_needsNegotiation"),t._batchedNegotiation||(t._batchedNegotiation=!0,setTimeout(function(){t._batchedNegotiation=!1,t._debug("starting batched negotiation"),t.negotiate()},0))},n.prototype.negotiate=function(){var t=this;t.initiator?t._isNegotiating?(t._queuedNegotiation=!0,t._debug("already negotiating, queueing")):(t._debug("start negotiation"),setTimeout(()=>{t._createOffer()},0)):t._isNegotiating||(t._debug("requesting negotiation from initiator"),t.emit("signal",{renegotiate:!0})),t._isNegotiating=!0},n.prototype.destroy=function(t){this._destroy(t,function(){})},n.prototype._destroy=function(n,e){if(!this.destroyed){if(this._debug("destroy (error: %s)",n&&(n.message||n)),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._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch(t){}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch(t){}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,n&&this.emit("error",n),this.emit("close"),e()}},n.prototype._setupData=function(r){var o=this;if(!r.channel)return o.destroy(d("Data channel event is missing `channel` property","ERR_DATA_CHANNEL"));o._channel=r.channel,o._channel.binaryType="arraybuffer","number"==typeof o._channel.bufferedAmountLowThreshold&&(o._channel.bufferedAmountLowThreshold=65536),o.channelName=o._channel.label,o._channel.onmessage=function(t){o._onChannelMessage(t)},o._channel.onbufferedamountlow=function(){o._onChannelBufferedAmountLow()},o._channel.onopen=function(){o._onChannelOpen()},o._channel.onclose=function(){o._onChannelClose()},o._channel.onerror=function(t){o.destroy(d(t,"ERR_DATA_CHANNEL"))};var e=!1;o._closingInterval=setInterval(function(){o._channel&&"closing"===o._channel.readyState?(e&&o._onChannelClose(),e=!0):e=!1},5e3)},n.prototype._read=function(){},n.prototype._write=function(r,e,t){if(this.destroyed)return t(d("cannot write after peer is destroyed","ERR_DATA_CHANNEL"));if(this._connected){try{this.send(r)}catch(e){return this.destroy(d(e,"ERR_DATA_CHANNEL"))}65536<this._channel.bufferedAmount?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=t):t(null)}else this._debug("write before connect"),this._chunk=r,this._cb=t},n.prototype._onFinish=function(){function n(){setTimeout(function(){t.destroy()},1e3)}var t=this;t.destroyed||(t._connected?n():t.once("connect",n))},n.prototype._startIceCompleteTimeout=function(){var t=this;t.destroyed||t._iceCompleteTimer||(t._debug("started iceComplete timeout"),t._iceCompleteTimer=setTimeout(function(){t._iceComplete||(t._iceComplete=!0,t._debug("iceComplete timeout completed"),t.emit("iceTimeout"),t.emit("_iceComplete"))},t.iceCompleteTimeout))},n.prototype._createOffer=function(){var o=this;o.destroyed||o._pc.createOffer(o.offerOptions).then(function(e){function t(){if(!o.destroyed){var t=o._pc.localDescription||e;o._debug("signal"),o.emit("signal",{type:t.type,sdp:t.sdp})}}o.destroyed||(o.trickle||o.allowHalfTrickle||(e.sdp=r(e.sdp)),e.sdp=o.sdpTransform(e.sdp),o._pc.setLocalDescription(e).then(function(){o._debug("createOffer success"),o.destroyed||(o.trickle||o._iceComplete?t():o.once("_iceComplete",t))}).catch(function(e){o.destroy(d(e,"ERR_SET_LOCAL_DESCRIPTION"))}))}).catch(function(e){o.destroy(d(e,"ERR_CREATE_OFFER"))})},n.prototype._requestMissingTransceivers=function(){var n=this;n._pc.getTransceivers&&n._pc.getTransceivers().forEach(e=>{e.mid||!e.sender.track||e.requested||(e.requested=!0,n.addTransceiver(e.sender.track.kind))})},n.prototype._createAnswer=function(){var o=this;o.destroyed||o._pc.createAnswer(o.answerOptions).then(function(e){function t(){if(!o.destroyed){var t=o._pc.localDescription||e;o._debug("signal"),o.emit("signal",{type:t.type,sdp:t.sdp}),o.initiator||o._requestMissingTransceivers()}}o.destroyed||(o.trickle||o.allowHalfTrickle||(e.sdp=r(e.sdp)),e.sdp=o.sdpTransform(e.sdp),o._pc.setLocalDescription(e).then(function(){o.destroyed||(o.trickle||o._iceComplete?t():o.once("_iceComplete",t))}).catch(function(e){o.destroy(d(e,"ERR_SET_LOCAL_DESCRIPTION"))}))}).catch(function(e){o.destroy(d(e,"ERR_CREATE_ANSWER"))})},n.prototype._onIceStateChange=function(){if(!this.destroyed){var n=this._pc.iceConnectionState,e=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",n,e),this.emit("iceStateChange",n,e),"connected"!==n&&"completed"!==n||(this._pcReady=!0,this._maybeReady()),"failed"===n&&this.destroy(d("Ice connection failed.","ERR_ICE_CONNECTION_FAILURE")),"closed"===n&&this.destroy(d("Ice connection closed.","ERR_ICE_CONNECTION_CLOSED"))}},n.prototype.getStats=function(o){function d(n){return"[object Array]"===Object.prototype.toString.call(n.values)&&n.values.forEach(function(e){Object.assign(n,e)}),n}var e=this;0===e._pc.getStats.length?e._pc.getStats().then(function(e){var t=[];e.forEach(function(n){t.push(d(n))}),o(null,t)},function(e){o(e)}):e._isReactNativeWebrtc?e._pc.getStats(null,function(e){var t=[];e.forEach(function(n){t.push(d(n))}),o(null,t)},function(e){o(e)}):0<e._pc.getStats.length?e._pc.getStats(function(t){if(!e.destroyed){var n=[];t.result().forEach(function(r){var e={};r.names().forEach(function(t){e[t]=r.stat(t)}),e.id=r.id,e.type=r.type,e.timestamp=r.timestamp,n.push(d(e))}),o(null,n)}},function(e){o(e)}):o(null,[])},n.prototype._maybeReady=function(){var s=this;s._debug("maybeReady pc %s channel %s",s._pcReady,s._channelReady),!s._connected&&!s._connecting&&s._pcReady&&s._channelReady&&(s._connecting=!0,function e(){s.destroyed||s.getStats(function(t,n){function l(e){a=!0;var t=i[e.localCandidateId];t&&(t.ip||t.address)?(s.localAddress=t.ip||t.address,s.localPort=+t.port):t&&t.ipAddress?(s.localAddress=t.ipAddress,s.localPort=+t.portNumber):"string"==typeof e.googLocalAddress&&(t=e.googLocalAddress.split(":"),s.localAddress=t[0],s.localPort=+t[1]),s.localAddress&&(s.localFamily=s.localAddress.includes(":")?"IPv6":"IPv4");var o=u[e.remoteCandidateId];o&&(o.ip||o.address)?(s.remoteAddress=o.ip||o.address,s.remotePort=+o.port):o&&o.ipAddress?(s.remoteAddress=o.ipAddress,s.remotePort=+o.portNumber):"string"==typeof e.googRemoteAddress&&(o=e.googRemoteAddress.split(":"),s.remoteAddress=o[0],s.remotePort=+o[1]),s.remoteAddress&&(s.remoteFamily=s.remoteAddress.includes(":")?"IPv6":"IPv4"),s._debug("connect local: %s:%s remote: %s:%s",s.localAddress,s.localPort,s.remoteAddress,s.remotePort)}if(!s.destroyed){t&&(n=[]);var u={},i={},o={},a=!1;if(n.forEach(function(t){"remotecandidate"!==t.type&&"remote-candidate"!==t.type||(u[t.id]=t),"localcandidate"!==t.type&&"local-candidate"!==t.type||(i[t.id]=t),"candidatepair"!==t.type&&"candidate-pair"!==t.type||(o[t.id]=t)}),n.forEach(function(t){"transport"===t.type&&t.selectedCandidatePairId&&l(o[t.selectedCandidatePairId]),("googCandidatePair"===t.type&&"true"===t.googActiveConnection||("candidatepair"===t.type||"candidate-pair"===t.type)&&t.selected)&&l(t)}),a||Object.keys(o).length&&!Object.keys(i).length){if(s._connecting=!1,s._connected=!0,s._chunk){try{s.send(s._chunk)}catch(e){return s.destroy(d(e,"ERR_DATA_CHANNEL"))}s._chunk=null,s._debug("sent chunk from \"write before connect\"");var f=s._cb;s._cb=null,f(null)}"number"!=typeof s._channel.bufferedAmountLowThreshold&&(s._interval=setInterval(function(){s._onInterval()},150),s._interval.unref&&s._interval.unref()),s._debug("connect"),s.emit("connect")}else setTimeout(e,100)}})}())},n.prototype._onInterval=function(){this._cb&&this._channel&&!(65536<this._channel.bufferedAmount)&&this._onChannelBufferedAmountLow()},n.prototype._onSignalingStateChange=function(){var n=this;n.destroyed||("stable"!==n._pc.signalingState||n._firstStable||(n._isNegotiating=!1,n._debug("flushing sender queue",n._sendersAwaitingStable),n._sendersAwaitingStable.forEach(function(e){n._pc.removeTrack(e),n._queuedNegotiation=!0}),n._sendersAwaitingStable=[],n._queuedNegotiation&&(n._debug("flushing negotiation queue"),n._queuedNegotiation=!1,n._needsNegotiation()),n._debug("negotiate"),n.emit("negotiate")),n._firstStable=!1,n._debug("signalingStateChange %s",n._pc.signalingState),n.emit("signalingStateChange",n._pc.signalingState))},n.prototype._onIceCandidate=function(t){this.destroyed||(t.candidate&&this.trickle?this.emit("signal",{candidate:{candidate:t.candidate.candidate,sdpMLineIndex:t.candidate.sdpMLineIndex,sdpMid:t.candidate.sdpMid}}):t.candidate||this._iceComplete||(this._iceComplete=!0,this.emit("_iceComplete")),t.candidate&&this._startIceCompleteTimeout())},n.prototype._onChannelMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=o.from(t)),this.push(t)}},n.prototype._onChannelBufferedAmountLow=function(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);var t=this._cb;this._cb=null,t(null)}},n.prototype._onChannelOpen=function(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())},n.prototype._onChannelClose=function(){this.destroyed||(this._debug("on channel close"),this.destroy())},n.prototype._onTrack=function(r){var e=this;e.destroyed||r.streams.forEach(function(t){e._debug("on track"),e.emit("track",r.track,t),e._remoteTracks.push({track:r.track,stream:t}),e._remoteStreams.some(function(n){return n.id===t.id})||(e._remoteStreams.push(t),setTimeout(function(){e.emit("stream",t)},0))})},n.prototype._debug=function(){var t=[].slice.call(arguments);t[0]="["+this._id+"] "+t[0],a.apply(null,t)}}).call(this,p({}).Buffer);var nd,rd=1,od=function(){rd=65535&rd+1},gr=function(o){nd||(nd=setInterval(od,250)).unref&&nd.unref();var d=4*(o||5),t=[0],n=1,l=65535&rd-1;return function(r){var e=65535&rd-l;for(e>d&&(e=d),l=rd;e--;)n==d&&(n=0),t[n]=t[0==n?d-1:n-1],n++;r&&(t[n-1]+=r);var i=t[n-1],o=t.length<d?0:t[n==d?0:n];return 4>t.length?i:4*(i-o)/t.length}},mr={};const dd=/^\[?([^\]]+)\]?:(\d+)$/;let yr={},ad=0;(mr=function(n){if(1e5==ad&&mr.reset(),!yr[n]){const e=dd.exec(n);if(!e)throw new Error(`invalid addr: ${n}`);yr[n]=[e[1],+e[2]],ad+=1}return yr[n]}).reset=function(){yr={},ad=0};var id={exports:{}};id.exports=class{constructor(r=0,e){const t=null!=e&&e.grow;this.grow=t&&isFinite(t)&&Dn(t)||t||0,this.buffer="number"==typeof r?new Uint8Array(Dn(r)):r}get(n){const e=n>>3;return e<this.buffer.length&&!!(this.buffer[e]&128>>n%8)}set(r,e=!0){const t=r>>3;if(e){if(this.buffer.length<t+1){const n=to(t+1,ao(2*this.buffer.length,this.grow));if(n<=this.grow){const e=new Uint8Array(n);e.set(this.buffer),this.buffer=e}}this.buffer[t]|=128>>r%8}else t<this.buffer.length&&(this.buffer[t]&=~(128>>r%8))}},id=id.exports;var sd=class extends st.Writable{constructor(o,e,d={}){if(super(d),!o||!o.put||!o.get)throw new Error("First argument must be an abstract-chunk-store compliant store");if(!(e=+e))throw new Error("Second argument must be a chunk length");this._blockstream=new Io(e,{zeroPadding:!1}),this._outstandingPuts=0;let n=0;this._blockstream.on("data",e=>{this.destroyed||(this._outstandingPuts+=1,o.put(n,e,()=>{this._outstandingPuts-=1,0===this._outstandingPuts&&"function"==typeof this._finalCb&&(this._finalCb(null),this._finalCb=null)}),n+=1)}).on("error",t=>{this.destroy(t)})}_write(r,e,t){this._blockstream.write(r,e,t)}_final(t){this._blockstream.end(),this._blockstream.once("end",()=>{0===this._outstandingPuts?t(null):this._finalCb=t})}destroy(t){this.destroyed||(this.destroyed=!0,t&&this.emit("error",t),this.emit("close"))}},kr={};(function(n){kr.DEFAULT_ANNOUNCE_PEERS=50,kr.binaryToHex=function(e){return"string"!=typeof e&&(e=e+""),n.from(e,"binary").toString("hex")},kr.hexToBinary=function(e){return"string"!=typeof e&&(e=e+""),n.from(e,"hex").toString("binary")},Object.assign(kr,oe)}).call(this,p({}).Buffer);var Sr={};(function(o,d){const t=jo("simple-websocket"),e=WebSocket,r=65536;class n extends st.Duplex{constructor(n={}){if("string"==typeof n&&(n={url:n}),super(n=Object.assign({allowHalfOpen:!1},n)),null==n.url&&null==n.socket)throw new Error("Missing required `url` or `socket` option");if(null!=n.url&&null!=n.socket)throw new Error("Must specify either `url` or `socket` option, not both");if(this._id=ur(4).toString("hex").slice(0,7),this._debug("new websocket: %o",n),this.connected=!1,this.destroyed=!1,this._chunk=null,this._cb=null,this._interval=null,n.socket)this.url=n.socket.url,this._ws=n.socket;else{this.url=n.url;try{this._ws=new e(n.url)}catch(e){return void o.nextTick(()=>this.destroy(e))}}this._ws.binaryType="arraybuffer",this._ws.onopen=()=>{this._onOpen()},this._ws.onmessage=t=>{this._onMessage(t)},this._ws.onclose=()=>{this._onClose()},this._ws.onerror=()=>{this.destroy(new Error("connection error to "+this.url))},this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}send(t){this._ws.send(t)}destroy(t){this._destroy(t,()=>{})}_destroy(n,r){if(!this.destroyed){if(this._debug("destroy (error: %s)",n&&(n.message||n)),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){const r=this._ws,t=()=>{r.onclose=null};if(r.readyState===e.CLOSED)t();else try{r.onclose=t,r.close()}catch(n){t()}r.onopen=null,r.onmessage=null,r.onerror=()=>{}}if(this._ws=null,n){if("undefined"!=typeof DOMException&&n instanceof DOMException){const e=n.code;(n=new Error(n.message)).code=e}this.emit("error",n)}this.emit("close"),r()}}_read(){}_write(o,e,t){if(this.destroyed)return t(new Error("cannot write after socket is destroyed"));if(this.connected){try{this.send(o)}catch(e){return this.destroy(e)}this._ws.bufferedAmount>r?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=t):t(null)}else this._debug("write before connect"),this._chunk=o,this._cb=t}_onFinish(){if(!this.destroyed){const t=()=>{setTimeout(()=>this.destroy(),1e3)};this.connected?t():this.once("connect",t)}}_onMessage(t){if(this.destroyed)return;let e=t.data;e instanceof ArrayBuffer&&(e=d.from(e)),this.push(e)}_onOpen(){if(!this.connected&&!this.destroyed){if(this.connected=!0,this._chunk){try{this.send(this._chunk)}catch(e){return this.destroy(e)}this._chunk=null,this._debug("sent chunk from \"write before connect\"");const t=this._cb;this._cb=null,t(null)}this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref(),this._debug("connect"),this.emit("connect")}}_onInterval(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>r)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);const t=this._cb;this._cb=null,t(null)}}_onClose(){this.destroyed||(this._debug("on close"),this.destroy())}_debug(){const n=[].slice.call(arguments);n[0]="["+this._id+"] "+n[0],t.apply(null,n)}}n.WEBSOCKET_SUPPORT=!!e,Sr=n}).call(this,pe,p({}).Buffer);var ld=class extends m{constructor(n,e){super(),this.client=n,this.announceUrl=e,this.interval=null,this.destroyed=!1}setInterval(t){null==t&&(t=this.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(this.interval),t&&(this.interval=setInterval(()=>{this.announce(this.client._defaultAnnounceOpts())},t),this.interval.unref&&this.interval.unref())}},xr={};const cd=jo("bittorrent-tracker:websocket-tracker"),Ar={};class Ir extends ld{constructor(r,e,t){super(r,e),cd("new websocket tracker %s",e),this.peers={},this.socket=null,this.reconnecting=!1,this.retries=0,this.reconnectTimer=null,this.expectingResponse=!1,this._openSocket()}announce(r){if(this.destroyed||this.reconnecting)return;if(!this.socket.connected)return void this.socket.once("connect",()=>{this.announce(r)});const o=Object.assign({},r,{action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary});if(this._trackerId&&(o.trackerid=this._trackerId),"stopped"===r.event||"completed"===r.event)this._send(o);else{const t=ao(r.numwant,10);this._generateOffers(t,n=>{o.numwant=t,o.offers=n,this._send(o)})}}scrape(n){if(!(this.destroyed||this.reconnecting)){if(!this.socket.connected)return void this.socket.once("connect",()=>{this.scrape(n)});const e={action:"scrape",info_hash:Array.isArray(n.infoHash)&&0<n.infoHash.length?n.infoHash.map(t=>t.toString("binary")):n.infoHash&&n.infoHash.toString("binary")||this.client._infoHashBinary};this._send(e)}}destroy(o=Zn){function e(){d&&(clearTimeout(d),d=null),r.removeListener("data",e),r.destroy(),r=null}if(this.destroyed)return o(null);for(const t in this.destroyed=!0,clearInterval(this.interval),clearTimeout(this.reconnectTimer),this.peers){const n=this.peers[t];clearTimeout(n.trackerTimeout),n.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,Ar[this.announceUrl]&&(Ar[this.announceUrl].consumers-=1),0<Ar[this.announceUrl].consumers)return o();let r=Ar[this.announceUrl];if(delete Ar[this.announceUrl],r.on("error",Zn),r.once("close",o),!this.expectingResponse)return e();var d=setTimeout(e,kr.DESTROY_TIMEOUT);r.once("data",e)}_openSocket(){this.destroyed=!1,this.peers||(this.peers={}),this._onSocketConnectBound=()=>{this._onSocketConnect()},this._onSocketErrorBound=t=>{this._onSocketError(t)},this._onSocketDataBound=t=>{this._onSocketData(t)},this._onSocketCloseBound=()=>{this._onSocketClose()},this.socket=Ar[this.announceUrl],this.socket?Ar[this.announceUrl].consumers+=1:(this.socket=Ar[this.announceUrl]=new Sr(this.announceUrl),this.socket.consumers=1,this.socket.once("connect",this._onSocketConnectBound)),this.socket.on("data",this._onSocketDataBound),this.socket.once("close",this._onSocketCloseBound),this.socket.once("error",this._onSocketErrorBound)}_onSocketConnect(){this.destroyed||this.reconnecting&&(this.reconnecting=!1,this.retries=0,this.announce(this.client._defaultAnnounceOpts()))}_onSocketData(t){if(!this.destroyed){this.expectingResponse=!1;try{t=JSON.parse(t)}catch(e){return void this.client.emit("warning",new Error("Invalid tracker response"))}"announce"===t.action?this._onAnnounceResponse(t):"scrape"===t.action?this._onScrapeResponse(t):this._onSocketError(new Error(`invalid action in WS response: ${t.action}`))}}_onAnnounceResponse(o){if(o.info_hash!==this.client._infoHashBinary)return void cd("ignoring websocket data from %s for %s (looking for %s: reused socket)",this.announceUrl,kr.binaryToHex(o.info_hash),this.client.infoHash);if(o.peer_id&&o.peer_id===this.client._peerIdBinary)return;cd("received %s from %s for %s",JSON.stringify(o),this.announceUrl,this.client.infoHash);const e=o["failure reason"];if(e)return this.client.emit("warning",new Error(e));const t=o["warning message"];t&&this.client.emit("warning",new Error(t));const n=o.interval||o["min interval"];n&&this.setInterval(1e3*n);const r=o["tracker id"];if(r&&(this._trackerId=r),null!=o.complete){const e=Object.assign({},o,{announce:this.announceUrl,infoHash:kr.binaryToHex(o.info_hash)});this.client.emit("update",e)}let d;if(o.offer&&o.peer_id&&(cd("creating peer (from remote offer)"),(d=this._createPeer()).id=kr.binaryToHex(o.peer_id),d.once("signal",e=>{const t={action:"announce",info_hash:this.client._infoHashBinary,peer_id:this.client._peerIdBinary,to_peer_id:o.peer_id,answer:e,offer_id:o.offer_id};this._trackerId&&(t.trackerid=this._trackerId),this._send(t)}),d.signal(o.offer),this.client.emit("peer",d)),o.answer&&o.peer_id){const e=kr.binaryToHex(o.offer_id);(d=this.peers[e])?(d.id=kr.binaryToHex(o.peer_id),d.signal(o.answer),this.client.emit("peer",d),clearTimeout(d.trackerTimeout),d.trackerTimeout=null,delete this.peers[e]):cd(`got unexpected answer: ${JSON.stringify(o.answer)}`)}}_onScrapeResponse(r){r=r.files||{};const n=Object.keys(r);0===n.length?this.client.emit("warning",new Error("invalid scrape response")):n.forEach(e=>{const t=Object.assign(r[e],{announce:this.announceUrl,infoHash:kr.binaryToHex(e)});this.client.emit("scrape",t)})}_onSocketClose(){this.destroyed||(this.destroy(),this._startReconnectTimer())}_onSocketError(t){this.destroyed||(this.destroy(),this.client.emit("warning",t),this._startReconnectTimer())}_startReconnectTimer(){const t=io(Math.random()*12e4)+ao(no(2,this.retries)*1e4,18e5);this.reconnecting=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.retries++,this._openSocket()},t),this.reconnectTimer.unref&&this.reconnectTimer.unref(),cd("reconnecting socket in %s ms",t)}_send(n){if(!this.destroyed){this.expectingResponse=!0;const e=JSON.stringify(n);cd("send %s",e),this.socket.send(e)}}_generateOffers(d,e){function t(){const r=ur(20).toString("hex");cd("creating peer (from _generateOffers)");const e=a.peers[r]=a._createPeer({initiator:!0});e.once("signal",e=>{n.push({offer:e,offer_id:kr.hexToBinary(r)}),o()}),e.trackerTimeout=setTimeout(()=>{cd("tracker timeout: destroying peer"),e.trackerTimeout=null,delete a.peers[r],e.destroy()},5e4),e.trackerTimeout.unref&&e.trackerTimeout.unref()}function o(){n.length===d&&(cd("generated %s offers",d),e(n))}const a=this,n=[];cd("generating %s offers",d);for(let n=0;n<d;++n)t();o()}_createPeer(o){function d(n){r.client.emit("warning",new Error(`Connection error: ${n.message}`)),t.destroy()}const r=this;o=Object.assign({trickle:!1,config:r.client._rtcConfig,wrtc:r.client._wrtc},o);const t=new td(o);return t.once("error",d),t.once("connect",function n(){t.removeListener("error",d),t.removeListener("connect",n)}),t}}Ir.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,Ir._socketPool=Ar,xr=Ir;var Or={};(function(d,l){const a=jo("bittorrent-tracker:client");class t extends m{constructor(e={}){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");if(!d.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this._peerIdBuffer=l.from(this.peerId,"hex"),this._peerIdBinary=this._peerIdBuffer.toString("binary"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._infoHashBuffer=l.from(this.infoHash,"hex"),this._infoHashBinary=this._infoHashBuffer.toString("binary"),a("new client %s",this.infoHash),this.destroyed=!1,this._port=e.port,this._getAnnounceOpts=e.getAnnounceOpts,this._rtcConfig=e.rtcConfig,this._userAgent=e.userAgent,this._wrtc="function"==typeof e.wrtc?e.wrtc():e.wrtc;let t="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;t=t.map(t=>("/"===(t=t.toString())[t.length-1]&&(t=t.substring(0,t.length-1)),t)),t=or(t);const c=!1!==this._wrtc&&(!!this._wrtc||td.WEBRTC_SUPPORT),s=e=>{d.nextTick(()=>{this.emit("warning",e)})};this._trackers=t.map(o=>{let e;try{e=new URL(o)}catch(e){return s(new Error(`Invalid tracker URL: ${o}`)),null}const d=e.port;if(0>d||65535<d)return s(new Error(`Invalid tracker port: ${o}`)),null;const n=e.protocol;return"http:"!==n&&"https:"!==n||!0?"udp:"===n&&!1?new oe(this,o):("ws:"===n||"wss:"===n)&&c?"ws:"===n&&"undefined"!=typeof window&&"https:"===window.location.protocol?(s(new Error(`Unsupported tracker protocol: ${o}`)),null):new xr(this,o):(s(new Error(`Unsupported tracker protocol: ${o}`)),null):new oe(this,o)}).filter(Boolean)}start(t){a("send `start`"),(t=this._defaultAnnounceOpts(t)).event="started",this._announce(t),this._trackers.forEach(t=>{t.setInterval()})}stop(t){a("send `stop`"),(t=this._defaultAnnounceOpts(t)).event="stopped",this._announce(t)}complete(t){a("send `complete`"),t||(t={}),(t=this._defaultAnnounceOpts(t)).event="completed",this._announce(t)}update(t){a("send `update`"),(t=this._defaultAnnounceOpts(t)).event&&delete t.event,this._announce(t)}_announce(n){this._trackers.forEach(e=>{e.announce(n)})}scrape(n){a("send `scrape`"),n||(n={}),this._trackers.forEach(e=>{e.scrape(n)})}setInterval(n){a("setInterval %d",n),this._trackers.forEach(e=>{e.setInterval(n)})}destroy(n){if(!this.destroyed){this.destroyed=!0,a("destroy");const e=this._trackers.map(n=>e=>{n.destroy(e)});Oo(e,n),this._trackers=[],this._getAnnounceOpts=null}}_defaultAnnounceOpts(t={}){return null==t.numwant&&(t.numwant=kr.DEFAULT_ANNOUNCE_PEERS),null==t.uploaded&&(t.uploaded=0),null==t.downloaded&&(t.downloaded=0),this._getAnnounceOpts&&(t=Object.assign({},t,this._getAnnounceOpts())),t}}t.scrape=(r,d)=>{if(d=Ot(d),!r.infoHash)throw new Error("Option `infoHash` is required");if(!r.announce)throw new Error("Option `announce` is required");const e=Object.assign({},r,{infoHash:Array.isArray(r.infoHash)?r.infoHash[0]:r.infoHash,peerId:l.from("01234567890123456789"),port:6881}),i=new t(e);i.once("error",d),i.once("warning",d);let s=Array.isArray(r.infoHash)?r.infoHash.length:1;const c={};return i.on("scrape",t=>{if(s-=1,c[t.infoHash]=t,0===s){i.destroy();const t=Object.keys(c);1===t.length?d(null,c[t[0]]):d(null,c)}}),r.infoHash=Array.isArray(r.infoHash)?r.infoHash.map(t=>l.from(t,"hex")):l.from(r.infoHash,"hex"),i.scrape({infoHash:r.infoHash}),i},Or=t}).call(this,pe,p({}).Buffer);var ud={};(function(r){const o=jo("torrent-discovery"),e=m.EventEmitter;ud=class extends e{constructor(e){if(super(),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!r.browser&&!e.port)throw new Error("Option `port` is required");this.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),this.infoHash="string"==typeof e.infoHash?e.infoHash.toLowerCase():e.infoHash.toString("hex"),this._port=e.port,this._userAgent=e.userAgent,this.destroyed=!1,this._announce=e.announce||[],this._intervalMs=e.intervalMs||9e5,this._trackerOpts=null,this._dhtAnnouncing=!1,this._dhtTimeout=!1,this._internalDHT=!1,this._onWarning=t=>{this.emit("warning",t)},this._onError=t=>{this.emit("error",t)},this._onDHTPeer=(n,e)=>{e.toString("hex")===this.infoHash&&this.emit("peer",`${n.host}:${n.port}`,"dht")},this._onTrackerPeer=t=>{this.emit("peer",t,"tracker")},this._onTrackerAnnounce=()=>{this.emit("trackerAnnounce")};const t=(r,e)=>{const t=new oe(e);return t.on("warning",this._onWarning),t.on("error",this._onError),t.listen(r),this._internalDHT=!0,t};!1===e.tracker?this.tracker=null:e.tracker&&"object"==typeof e.tracker?(this._trackerOpts=Object.assign({},e.tracker),this.tracker=this._createTracker()):this.tracker=this._createTracker(),this.dht=!1!==e.dht&&0?e.dht&&"function"==typeof e.dht.addNode?e.dht:e.dht&&"object"==typeof e.dht?t(e.dhtPort,e.dht):t(e.dhtPort):null,this.dht&&(this.dht.on("peer",this._onDHTPeer),this._dhtAnnounce())}updatePort(t){t!==this._port&&(this._port=t,this.dht&&this._dhtAnnounce(),this.tracker&&(this.tracker.stop(),this.tracker.destroy(()=>{this.tracker=this._createTracker()})))}complete(t){this.tracker&&this.tracker.complete(t)}destroy(n){if(!this.destroyed){this.destroyed=!0,clearTimeout(this._dhtTimeout);const e=[];this.tracker&&(this.tracker.stop(),this.tracker.removeListener("warning",this._onWarning),this.tracker.removeListener("error",this._onError),this.tracker.removeListener("peer",this._onTrackerPeer),this.tracker.removeListener("update",this._onTrackerAnnounce),e.push(t=>{this.tracker.destroy(t)})),this.dht&&this.dht.removeListener("peer",this._onDHTPeer),this._internalDHT&&(this.dht.removeListener("warning",this._onWarning),this.dht.removeListener("error",this._onError),e.push(t=>{this.dht.destroy(t)})),Oo(e,n),this.dht=null,this.tracker=null,this._announce=null}}_createTracker(){const n=Object.assign({},this._trackerOpts,{infoHash:this.infoHash,announce:this._announce,peerId:this.peerId,port:this._port,userAgent:this._userAgent}),e=new Or(n);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}_dhtAnnounce(){this._dhtAnnouncing||(o("dht announce"),this._dhtAnnouncing=!0,clearTimeout(this._dhtTimeout),this.dht.announce(this.infoHash,this._port,t=>{this._dhtAnnouncing=!1,o("dht announce complete"),t&&this.emit("warning",t),this.emit("dhtAnnounce"),this.destroyed||(this._dhtTimeout=setTimeout(()=>{this._dhtAnnounce()},this._intervalMs+io(Math.random()*this._intervalMs/5)),this._dhtTimeout.unref&&this._dhtTimeout.unref())}))}}}).call(this,pe);var fd={};(function(o){function r(t,e){if(!(this instanceof r))return new r(t,e);if(e||(e={}),this.chunkLength=+t,!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=+e.length||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=eo(this.length/this.chunkLength)-1)}function d(e,t,n){o.nextTick(function(){e&&e(t,n)})}fd=r,r.prototype.put=function(n,e,t){if(this.closed)return d(t,new Error("Storage is closed"));var r=n===this.lastChunkIndex;return r&&e.length!==this.lastChunkLength?d(t,new Error("Last chunk length must be "+this.lastChunkLength)):r||e.length===this.chunkLength?(this.chunks[n]=e,void d(t,null)):d(t,new Error("Chunk length must be "+this.chunkLength))},r.prototype.get=function(n,e,t){if("function"==typeof e)return this.get(n,null,e);if(this.closed)return d(t,new Error("Storage is closed"));var r=this.chunks[n];if(!r){var i=new Error("Chunk not found");return i.notFound=!0,d(t,i)}if(!e)return d(t,null,r);var s=e.offset||0,o=e.length||r.length-s;d(t,null,r.slice(s,o+s))},r.prototype.close=r.prototype.destroy=function(t){return this.closed?d(t,new Error("Storage is closed")):void(this.closed=!0,this.chunks=null,d(t,null))}}).call(this,pe);var pd={};(function(o){pd=class{constructor(t){if(this.store=t,this.chunkLength=t.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.mem=[]}put(r,e,o){this.mem[r]=e,this.store.put(r,e,e=>{this.mem[r]=null,o&&o(e)})}get(e,t,n){if("function"==typeof t)return this.get(e,null,t);const r=t&&t.offset||0,d=t&&t.length&&r+t.length,a=this.mem[e];return a?function(e,t,n){o.nextTick(()=>{e&&e(null,n)})}(n,0,t?a.slice(r,d):a):void this.store.get(e,t,n)}close(t){this.store.close(t)}destroy(t){this.store.destroy(t)}}}).call(this,pe);var hd={};class gd extends st.Readable{constructor(n,e){super(e),this.destroyed=!1,this._drained=!1,this._forwarding=!1,this._current=null,this._toStreams2=e&&e.objectMode?rr:Er,"function"==typeof n?this._queue=n:(this._queue=n.map(this._toStreams2),this._queue.forEach(t=>{"function"!=typeof t&&this._attachErrorListener(t)})),this._next()}_read(){this._drained=!0,this._forward()}_forward(){if(!this._forwarding&&this._drained&&this._current){var t;for(this._forwarding=!0;null!==(t=this._current.read())&&this._drained;)this._drained=this.push(t);this._forwarding=!1}}destroy(t){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),"function"!=typeof this._queue&&this._queue.forEach(t=>{t.destroy&&t.destroy()}),t&&this.emit("error",t),this.emit("close"))}_next(){if(this._current=null,"function"==typeof this._queue)this._queue((n,e)=>n?this.destroy(n):void(e=this._toStreams2(e),this._attachErrorListener(e),this._gotNextStream(e)));else{var t=this._queue.shift();"function"==typeof t&&(t=this._toStreams2(t()),this._attachErrorListener(t)),this._gotNextStream(t)}}_gotNextStream(o){if(!o)return this.push(null),void this.destroy();this._current=o,this._forward();const e=()=>{this._forward()},t=()=>{o._readableState.ended||this.destroy()},n=()=>{this._current=null,o.removeListener("readable",e),o.removeListener("end",n),o.removeListener("close",t),this._next()};o.on("readable",e),o.once("end",n),o.once("close",t)}_attachErrorListener(r){if(!r)return;const e=t=>{r.removeListener("error",e),this.destroy(t)};r.once("error",e)}}gd.obj=t=>new gd(t,{objectMode:!0,highWaterMark:16}),hd=gd;var zr={};(function(o){zr=function(f,p,e){function t(r){function t(){e&&e(r,d),e=null}b?o.nextTick(t):t()}function u(o,e,a){if(d[o]=a,e&&(_=!0),0==--m||e)t(e);else if(!_&&y<g){var r;n?(r=n[y],y+=1,f[r](function(n,e){u(r,n,e)})):(r=y,y+=1,f[r](function(n,e){u(r,n,e)}))}}if("number"!=typeof p)throw new Error("second argument must be a Number");var d,g,m,n,_,b=!0;Array.isArray(f)?(d=[],m=g=f.length):(n=Object.keys(f),d={},m=g=n.length);var y=p;m?n?n.some(function(o,e){if(f[o](function(e,t){u(o,e,t)}),e===p-1)return!0}):f.some(function(n,r){if(n(function(t,e){u(r,t,e)}),r===p-1)return!0}):t(null),b=!1}}).call(this,pe);var md={};(function(r){const d=16384;class e{constructor(t){this.length=t,this.missing=t,this.sources=null,this._chunks=eo(t/d),this._remainder=t%d||d,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,this._flushed=!1}chunkLength(t){return t===this._chunks-1?this._remainder:d}chunkLengthRemaining(t){return this.length-t*d}chunkOffset(t){return t*d}reserve(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1}reserveRemaining(){if(!this.init())return-1;if(this._reservations<this._chunks){const t=this._reservations;return this._reservations=this._chunks,t}return-1}cancel(t){this.init()&&this._cancellations.push(t)}cancelRemaining(t){this.init()&&(this._reservations=t)}get(t){return this.init()?this._buffer[t]:null}set(t,e,n){if(!this.init())return!1;const r=e.length,a=eo(r/d);for(let r=0;r<a;r++)if(!this._buffer[t+r]){const o=r*d,a=e.slice(o,o+d);this._buffered++,this._buffer[t+r]=a,this.missing-=a.length,this.sources.includes(n)||this.sources.push(n)}return this._buffered===this._chunks}flush(){if(!this._buffer||this._chunks!==this._buffered)return null;const e=r.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,e}init(){return!(this._flushed||!this._buffer&&(this._buffer=Array(this._chunks),this._cancellations=[],this.sources=[],0))}}Object.defineProperty(e,"BLOCK_LENGTH",{value:16384}),md=e}).call(this,p({}).Buffer);var _d=function(){},Gr=function(p,e,g){if("function"==typeof e)return Gr(p,null,e);e||(e={}),g=Ot(g||_d);var m=p._writableState,r=p._readableState,i=e.readable||!1!==e.readable&&p.readable,_=e.writable||!1!==e.writable&&p.writable,b=function(){p.writable||a()},a=function(){_=!1,i||g.call(p)},h=function(){i=!1,_||g.call(p)},c=function(e){g.call(p,e?new Error("exited with error code: "+e):null)},u=function(e){g.call(p,e)},d=function(){return(!i||r&&r.ended)&&(!_||m&&m.ended)?void 0:g.call(p,new Error("premature close"))},l=function(){p.req.on("finish",a)};return function(t){return t.setHeader&&"function"==typeof t.abort}(p)?(p.on("complete",a),p.on("abort",d),p.req?l():p.on("request",l)):_&&!m&&(p.on("end",b),p.on("close",b)),function(t){return t.stdio&&Array.isArray(t.stdio)&&3===t.stdio.length}(p)&&p.on("exit",c),p.on("end",h),p.on("finish",a),!1!==e.error&&p.on("error",u),p.on("close",d),function(){p.removeListener("complete",a),p.removeListener("abort",d),p.removeListener("request",l),p.req&&p.req.removeListener("finish",a),p.removeListener("end",b),p.removeListener("close",b),p.removeListener("finish",a),p.removeListener("exit",c),p.removeListener("end",h),p.removeListener("error",u),p.removeListener("close",d)}},Kr=Gr,Yr={};(function(o){var d=function(){},t=/^v?\.0/.test(o.version),n=function(t){return"function"==typeof t},r=function(t){t()},i=function(n,e){return n.pipe(e)};Yr=function(){var s,l=Array.prototype.slice.call(arguments),c=n(l[l.length-1]||d)&&l.pop()||d;if(Array.isArray(l[0])&&(l=l[0]),2>l.length)throw new Error("pump requires two streams per minimum");var a=l.map(function(e,o){var i=o<l.length-1;return function(r,e,i,s){s=Ot(s);var l=!1;r.on("close",function(){l=!0}),Kr(r,{readable:e,writable:i},function(t){return t?s(t):void(l=!0,s())});var c=!1;return function(e){if(!l&&!c)return c=!0,function(r){return!!t&&!0&&(r instanceof(oe.ReadStream||d)||r instanceof(oe.WriteStream||d))&&n(r.close)}(r)?r.close(d):function(t){return t.setHeader&&n(t.abort)}(r)?r.abort():n(r.destroy)?r.destroy():void s(e||new Error("stream was destroyed"))}}(e,i,0<o,function(e){s||(s=e),e&&a.forEach(r),i||(a.forEach(r),c(s))})});return l.reduce(i)}}).call(this,pe);var bd={};(function(d){const{EventEmitter:e}=m,t=jo("ut_metadata"),n=1e3,o=16384;bd=r=>{class i extends e{constructor(e){super(),this._wire=e,this._fetching=!1,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._bitfield=new id(0,{grow:n}),d.isBuffer(r)&&this.setMetadata(r)}onHandshake(r,e,t){this._infoHash=r}onExtendedHandshake(t){return t.m&&t.m.ut_metadata?t.metadata_size?"number"!=typeof t.metadata_size||1e7<t.metadata_size||0>=t.metadata_size?this.emit("warning",new Error("Peer gave invalid metadata size")):(this._metadataSize=t.metadata_size,this._numPieces=eo(this._metadataSize/o),this._remainingRejects=2*this._numPieces,void(this._fetching&&this._requestPieces())):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))}onMessage(o){let e,d;try{const t=o.toString(),n=t.indexOf("ee")+2;e=te.decode(t.substring(0,n)),d=o.slice(n)}catch(e){return}switch(e.msg_type){case 0:this._onRequest(e.piece);break;case 1:this._onData(e.piece,d,e.total_size);break;case 2:this._onReject(e.piece);}}fetch(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())}cancel(){this._fetching=!1}setMetadata(n){if(this._metadataComplete)return!0;t("set metadata");try{const e=te.decode(n).info;e&&(n=te.encode(e))}catch(e){}return!(this._infoHash&&this._infoHash!==qo.sync(n)||(this.cancel(),this.metadata=n,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",te.encode({info:te.decode(this.metadata)})),0))}_send(e,t){let n=te.encode(e);d.isBuffer(t)&&(n=d.concat([n,t])),this._wire.extended("ut_metadata",n)}_request(t){this._send({msg_type:0,piece:t})}_data(o,e,t){const n={msg_type:1,piece:o};"number"==typeof t&&(n.total_size=t),this._send(n,e)}_reject(t){this._send({msg_type:2,piece:t})}_onRequest(d){if(!this._metadataComplete)return void this._reject(d);const e=d*o;let t=e+o;t>this._metadataSize&&(t=this._metadataSize);const a=this.metadata.slice(e,t);this._data(d,a,this._metadataSize)}_onData(r,e,t){e.length>o||(e.copy(this.metadata,r*o),this._bitfield.set(r),this._checkDone())}_onReject(t){0<this._remainingRejects&&this._fetching?(this._request(t),this._remainingRejects-=1):this.emit("warning",new Error("Peer sent \"reject\" too much"))}_requestPieces(){this.metadata=d.alloc(this._metadataSize);for(let t=0;t<this._numPieces;t++)this._request(t)}_checkDone(){let t=!0;for(let e=0;e<this._numPieces;e++)if(!this._bitfield.get(e)){t=!1;break}t&&(this.setMetadata(this.metadata)||this._failedMetadata())}_failedMetadata(){this._bitfield=new id(0,{grow:n}),this._remainingRejects-=this._numPieces,0<this._remainingRejects?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))}}return i.prototype.name="ut_metadata",i}}).call(this,p({}).Buffer);var yd={parse:function(n){var e=n.split(",").map(function(t){return function(d){if(/^-?\d+$/.test(d))return parseInt(d,10);var e;if(e=d.match(/^(-?\d+)(-|\.\.\.?|\u2025|\u2026|\u22EF)(-?\d+)$/)){var l=e[1],c=e[2],r=e[3];if(l&&r){var u=[],s=(l=parseInt(l))<(r=parseInt(r))?1:-1;"-"!=c&&".."!=c&&"\u2025"!=c||(r+=s);for(var o=l;o!=r;o+=s)u.push(o);return u}}return[]}(t)});return 0===e.length?[]:1===e.length?Array.isArray(e[0])?e[0]:e:e.reduce(function(n,r){return Array.isArray(n)||(n=[n]),Array.isArray(r)||(r=[r]),n.concat(r)})}},Zr=function(r){for(var e=0,o=r.length;e<o;++e)if(127<r.charCodeAt(e))return!1;return!0},Qr=Br,wd="undefined"!=typeof window&&window.MediaSource;Br.prototype.createWriteStream=function(t){return new Rr(this,t)},Br.prototype.error=function(t){this.detailedError||(this.detailedError=t),this._dumpDebugData();try{this._mediaSource.endOfStream("decode")}catch(t){}try{window.URL.revokeObjectURL(this._elem.src)}catch(t){}},Br.prototype._dumpDebugData=function(){this._debug&&(this._debug=!1,this._streams.forEach(function(o,e){var t,d,a;t=o._debugBuffers,d="mediasource-stream-"+e,(a=document.createElement("a")).href=window.URL.createObjectURL(new window.Blob(t)),a.download=d,a.click()}))},Me(Rr,st.Writable),Rr.prototype._onSourceOpen=function(){this.destroyed||(this._mediaSource.removeEventListener("sourceopen",this._openHandler),this._createSourceBuffer())},Rr.prototype.destroy=function(t){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),this._sourceBuffer.removeEventListener("error",this._errorHandler),"open"===this._mediaSource.readyState&&this._sourceBuffer.abort()),t&&this.emit("error",t),this.emit("close"))},Rr.prototype._createSourceBuffer=function(){if(!this.destroyed)if(!wd.isTypeSupported(this._type))this.destroy(new Error("The provided type is not supported"));else if(this._sourceBuffer=this._mediaSource.addSourceBuffer(this._type),this._sourceBuffer.addEventListener("updateend",this._flowHandler),this._sourceBuffer.addEventListener("error",this._errorHandler),this._cb){var t=this._cb;this._cb=null,t()}},Rr.prototype._write=function(o,e,t){var n=this;if(!n.destroyed)if(n._sourceBuffer){if(n._sourceBuffer.updating)return t(new Error("Cannot append buffer while source buffer updating"));var r=Sn(o);n._wrapper._debug&&n._debugBuffers.push(r);try{n._sourceBuffer.appendBuffer(r)}catch(e){return void n.destroy(e)}n._cb=t}else n._cb=function(r){return r?t(r):void n._write(o,e,t)}},Rr.prototype._flow=function(){if(!this.destroyed&&this._sourceBuffer&&!this._sourceBuffer.updating&&!("open"===this._mediaSource.readyState&&this._getBufferDuration()>this._bufferDuration)&&this._cb){var t=this._cb;this._cb=null,t()}},Rr.prototype._getBufferDuration=function(){for(var d=this._sourceBuffer.buffered,e=this._elem.currentTime,t=-1,a=0;a<d.length;a++){var l=d.start(a),i=d.end(a)+0;if(l>e)break;(0<=t||e<=i)&&(t=i)}var s=t-e;return 0>s&&(s=0),s};var Sd=function o(e,t,d){return"function"==typeof t?o(e,null,t):void!function o(e,t,n){if("function"==typeof t)return o(e,null,t);n=Ot(n);var d=[];e.on("data",function(t){d.push(t)}).on("end",function(){var r=t?new Blob(d,{type:t}):new Blob(d);n(null,r)}).on("error",n)}(e,t,function(r,e){if(r)return d(r);var t=URL.createObjectURL(e);d(null,t)})},kd={};(function(d){function e(o,e,t,d){if(0>t||d>o.length)throw new RangeError("Out of range index");return t>>>=0,(d=void 0===d?o.length:d>>>0)>t&&o.fill(e,t,d),o}var n=function(){try{if(!d.isEncoding("latin1"))return!1;var e=d.alloc?d.alloc(4):new d(4);return e.fill("ab","ucs2"),"61006200"===e.toString("hex")}catch(e){return!1}}();kd=function(t,r,l,c,u){if(n)return t.fill(r,l,c,u);if("number"==typeof r)return e(t,r,l,c);if("string"==typeof r){if("string"==typeof l?(u=l,l=0,c=t.length):"string"==typeof c&&(u=c,c=t.length),void 0!==u&&"string"!=typeof u)throw new TypeError("encoding must be a string");if("latin1"===u&&(u="binary"),"string"==typeof u&&!d.isEncoding(u))throw new TypeError("Unknown encoding: "+u);if(""===r)return e(t,0,l,c);if(function(t){return 1===t.length&&256>t.charCodeAt(0)}(r))return e(t,r.charCodeAt(0),l,c);r=new d(r,u)}return d.isBuffer(r)?function(o,e,t,d){if(0>t||d>o.length)throw new RangeError("Out of range index");if(d<=t)return o;t>>>=0,d=void 0===d?o.length:d>>>0;for(var a=t,l=e.length;a<=d-l;)e.copy(o,a),a+=l;return a!==d&&e.copy(o,a,0,d-a),o}(t,r,l,c):e(t,0,l,c)}}).call(this,p({}).Buffer);var Ed={};(function(n){Ed=function(e){if("number"!=typeof e)throw new TypeError("\"size\" argument must be a number");if(0>e)throw new RangeError("\"size\" argument must not be negative");return n.allocUnsafe?n.allocUnsafe(e):new n(e)}}).call(this,p({}).Buffer);var vd={};(function(o){vd=function(e,t,n){if("number"!=typeof e)throw new TypeError("\"size\" argument must be a number");if(0>e)throw new RangeError("\"size\" argument must not be negative");if(o.alloc)return o.alloc(e,t,n);var d=Ed(e);return 0===e?d:void 0===t?kd(d,0):("string"!=typeof n&&(n=void 0),kd(d,t,n))}}).call(this,p({}).Buffer);var Cd={},xd=no(2,32);Cd.encode=function(o,e,d){e||(e=vd(8)),d||(d=0);var a=io(o/4294967296);return e.writeUInt32BE(a,d),e.writeUInt32BE(o-a*4294967296,d+4),e},Cd.decode=function(o,e){e||(e=0);var d=o.readUInt32BE(e),n=o.readUInt32BE(e+4);return d*4294967296+n},Cd.encode.bytes=8,Cd.decode.bytes=8;var Ld={};(function(d){var l={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};Ld.Descriptor={},Ld.Descriptor.decode=function(e,t,n){var r,i,f=e.readUInt8(t),a=t+1,p=0;do p=p<<7|127&(r=e.readUInt8(a++));while(128&r);var g=l[f];return(i=Ld[g]?Ld[g].decode(e,a,n):{buffer:d.from(e.slice(a,a+p))}).tag=f,i.tagName=g,i.length=a-t+p,i.contentsLen=p,i},Ld.DescriptorArray={},Ld.DescriptorArray.decode=function(t,e,n){for(var r,d=e,a={};d+2<=n;)r=Ld.Descriptor.decode(t,d,n),d+=r.length,a[l[r.tag]||"Descriptor"+r.tag]=r;return a},Ld.ESDescriptor={},Ld.ESDescriptor.decode=function(o,e,t){var n=o.readUInt8(e+2),r=e+3;return 128&n&&(r+=2),64&n&&(r+=o.readUInt8(r)+1),32&n&&(r+=2),Ld.DescriptorArray.decode(o,r,t)},Ld.DecoderConfigDescriptor={},Ld.DecoderConfigDescriptor.decode=function(o,e,t){var n=o.readUInt8(e),r=Ld.DescriptorArray.decode(o,e+13,t);return r.oti=n,r}}).call(this,p({}).Buffer);var Td={};(function(o){var d=lo({}),t=o.alloc(0);class a extends st.PassThrough{constructor(t){super(),this._parent=t,this.destroyed=!1}destroy(t){this.destroyed||(this.destroyed=!0,this._parent.destroy(t),t&&this.emit("error",t),this.emit("close"))}}Td=class extends st.Writable{constructor(t){super(t),this.destroyed=!1,this._pending=0,this._missing=0,this._ignoreEmpty=!1,this._buf=null,this._str=null,this._cb=null,this._ondrain=null,this._writeBuffer=null,this._writeCb=null,this._ondrain=null,this._kick()}destroy(t){this.destroyed||(this.destroyed=!0,t&&this.emit("error",t),this.emit("close"))}_write(r,d,l){if(!this.destroyed){for(var n=!this._str||!this._str._writableState.needDrain;r.length&&!this.destroyed;){if(!this._missing&&!this._ignoreEmpty)return this._writeBuffer=r,void(this._writeCb=l);var c=r.length<this._missing?r.length:this._missing;if(this._buf?r.copy(this._buf,this._buf.length-this._missing):this._str&&(n=this._str.write(c===r.length?r:r.slice(0,c))),this._missing-=c,!this._missing){var s=this._buf,o=this._cb,a=this._str;this._buf=this._cb=this._str=this._ondrain=null,n=!0,this._ignoreEmpty=!1,a&&a.end(),o&&o(s)}r=c===r.length?t:r.slice(c)}if(this._pending&&!this._missing)return this._writeBuffer=r,void(this._writeCb=l);n?l():this._ondrain(l)}}_buffer(e,t){this._missing=e,this._buf=o.alloc(e),this._cb=t}_stream(o,e){return this._missing=o,this._str=new a(this),this._ondrain=(t=this._str,d="drain",i=null,t.on(d,function(n){if(i){var e=i;i=null,e(n)}}),function(t){i=t}),this._pending++,this._str.on("end",()=>{this._pending--,this._kick()}),this._cb=e,this._str;var t,d,i}_readBox(){const e=(t,n)=>{this._buffer(t,t=>{n=n?o.concat([n,t]):t;var r=d.readHeaders(n);"number"==typeof r?e(r-n.length,n):(this._pending++,this._headers=r,this.emit("box",r))})};e(8)}stream(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=this._headers;return this._headers=null,this._stream(t.contentLen,null)}decode(n){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var e=this._headers;this._headers=null,this._buffer(e.contentLen,t=>{var r=d.decodeWithoutHeaders(e,t);n(r),this._pending--,this._kick()})}ignore(){if(!this._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=this._headers;this._headers=null,this._missing=t.contentLen,0===this._missing&&(this._ignoreEmpty=!0),this._cb=()=>{this._pending--,this._kick()}}_kick(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var n=this._writeCb,e=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(e,null,n)}}}}).call(this,p({}).Buffer);var Bd={};(function(d,e){function n(){}var a=lo({});class r extends st.PassThrough{constructor(t){super(),this._parent=t,this.destroyed=!1}destroy(t){this.destroyed||(this.destroyed=!0,this._parent.destroy(t),t&&this.emit("error",t),this.emit("close"))}}Bd=class extends st.Readable{constructor(t){super(t),this.destroyed=!1,this._finalized=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=()=>{this._want&&(this._want=!1,this._read())},this._onend=()=>{this._stream=null}}mdat(n,e){this.mediaData(n,e)}mediaData(o,e){var t=new r(this);return this.box({type:"mdat",contentLength:o,encodeBufferLen:8,stream:t},e),t}box(r,t){if(t||(t=n),this.destroyed)return t(new Error("Encoder is destroyed"));var i;if(r.encodeBufferLen&&(i=e.alloc(r.encodeBufferLen)),r.stream)r.buffer=null,i=a.encode(r,i),this.push(i),this._stream=r.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",t),this._forward();else{if(i=a.encode(r,i),this.push(i))return d.nextTick(t);this._drain=t}}destroy(n){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var e=this._drain;this._drain=null,e(n)}n&&this.emit("error",n),this.emit("close")}}finalize(){this._finalized=!0,this._stream||this._drain||this.push(null)}_forward(){if(this._stream)for(;!this.destroyed;){var t=this._stream.read();if(!t)return void(this._want=!!this._stream);if(!this.push(t))return}}_read(){if(!this._reading&&!this.destroyed){if(this._reading=!0,this._stream&&this._forward(),this._drain){var t=this._drain;this._drain=null,t()}this._reading=!1,this._finalized&&this.push(null)}}}}).call(this,pe,p({}).Buffer);var Id={decode:t=>new Td(t),encode:t=>new Bd(t)};const{Writable:Rd,PassThrough:Ad}=st;var Ud=class extends Rd{constructor(n,e={}){super(e),this.destroyed=!1,this._queue=[],this._position=n||0,this._cb=null,this._buffer=null,this._out=null}_write(d,o,a){let n=!0;for(;;){if(this.destroyed)return;if(0===this._queue.length)return this._buffer=d,void(this._cb=a);this._buffer=null;var l=this._queue[0];const e=to(l.start-this._position,0),t=l.end-this._position;if(e>=d.length)return this._position+=d.length,a(null);let r;if(t>d.length){this._position+=d.length,r=0===e?d:d.slice(e),n=l.stream.write(r)&&n;break}this._position+=t,r=0===e&&t===d.length?d:d.slice(e,t),n=l.stream.write(r)&&n,l.last&&l.stream.end(),d=d.slice(t),this._queue.shift()}n?a(null):l.stream.once("drain",a.bind(null,null))}slice(o){if(this.destroyed)return null;Array.isArray(o)||(o=[o]);const d=new Ad;return o.forEach((e,t)=>{this._queue.push({start:e.start,end:e.end,stream:d,last:t===o.length-1})}),this._buffer&&this._write(this._buffer,null,this._cb),d}destroy(t){this.destroyed||(this.destroyed=!0,t&&this.emit("error",t))}},Pd={};(function(d){const l=lo({});class w{constructor(n,e){this._entries=n,this._countName=e||"count",this._index=0,this._offset=0,this.value=this._entries[0]}inc(){this._offset++,this._offset>=this._entries[this._index][this._countName]&&(this._index++,this._offset=0),this.value=this._entries[this._index]}}Pd=class extends m{constructor(t){super(),this._tracks=[],this._file=t,this._decoder=null,this._findMoov(0)}_findMoov(o){this._decoder&&this._decoder.destroy();let e=0;this._decoder=Id.decode();const d=this._file.createReadStream({start:o});d.pipe(this._decoder);const n=t=>{"moov"===t.type?(this._decoder.removeListener("box",n),this._decoder.decode(t=>{d.destroy();try{this._processMoov(t)}catch(e){e.message=`Cannot parse mp4 file: ${e.message}`,this.emit("error",e)}})):4096>t.length?(e+=t.length,this._decoder.ignore()):(this._decoder.removeListener("box",n),e+=t.length,d.destroy(),this._decoder.destroy(),this._findMoov(o+e))};this._decoder.on("box",n)}_processMoov(r){const t=r.traks;this._tracks=[],this._hasVideo=!1,this._hasAudio=!1;for(let i=0;i<t.length;i++){const e=t[i],s=e.mdia.minf.stbl,n=s.stsd.entries[0],o=e.mdia.hdlr.handlerType;let a,c;if("vide"===o&&"avc1"===n.type){if(this._hasVideo)continue;this._hasVideo=!0,a="avc1",n.avcC&&(a+=`.${n.avcC.mimeCodec}`),c=`video/mp4; codecs="${a}"`}else{if("soun"!==o||"mp4a"!==n.type)continue;if(this._hasAudio)continue;this._hasAudio=!0,a="mp4a",n.esds&&n.esds.mimeCodec&&(a+=`.${n.esds.mimeCodec}`),c=`audio/mp4; codecs="${a}"`}const u=[];let d=0,l=0,f=0,p=0,h=0,g=0;const m=new w(s.stts.entries);let _=null;s.ctts&&(_=new w(s.ctts.entries));for(let o=0;;){var S=s.stsc.entries[h];const a=s.stsz.entries[d],e=m.value.duration,t=_?_.value.compositionOffset:0;let n=!0;s.stss&&(n=s.stss.entries[o]===d+1);const r=s.stco||s.co64;if(u.push({size:a,duration:e,dts:g,presentationOffset:t,sync:n,offset:p+r.entries[f]}),++d>=s.stsz.entries.length)break;if(p+=a,++l>=S.samplesPerChunk){l=0,p=0,f++;const t=s.stsc.entries[h+1];t&&f+1>=t.firstChunk&&h++}g+=e,m.inc(),_&&_.inc(),n&&o++}e.mdia.mdhd.duration=0,e.tkhd.duration=0;const b=S.sampleDescriptionId,y={type:"moov",mvhd:r.mvhd,traks:[{tkhd:e.tkhd,mdia:{mdhd:e.mdia.mdhd,hdlr:e.mdia.hdlr,elng:e.mdia.elng,minf:{vmhd:e.mdia.minf.vmhd,smhd:e.mdia.minf.smhd,dinf:e.mdia.minf.dinf,stbl:{stsd:s.stsd,stts:{version:0,flags:0,entries:[]},ctts:{version:0,flags:0,entries:[]},stsc:{version:0,flags:0,entries:[]},stsz:{version:0,flags:0,entries:[]},stco:{version:0,flags:0,entries:[]},stss:{version:0,flags:0,entries:[]}}}}}],mvex:{mehd:{fragmentDuration:r.mvhd.duration},trexs:[{trackId:e.tkhd.trackId,defaultSampleDescriptionIndex:b,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};this._tracks.push({fragmentSequence:1,trackId:e.tkhd.trackId,timeScale:e.mdia.mdhd.timeScale,samples:u,currSample:null,currTime:null,moov:y,mime:c})}if(0===this._tracks.length)return void this.emit("error",new Error("no playable tracks"));r.mvhd.duration=0,this._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};const e=l.encode(this._ftyp),n=this._tracks.map(n=>{const t=l.encode(n.moov);return{mime:n.mime,init:d.concat([e,t])}});this.emit("ready",n)}seek(d){if(!this._tracks)throw new Error("Not ready yet; wait for 'ready' event");this._fileStream&&(this._fileStream.destroy(),this._fileStream=null);let a=-1;if(this._tracks.map((l,e)=>{l.outStream&&l.outStream.destroy(),l.inStream&&(l.inStream.destroy(),l.inStream=null);const n=l.outStream=Id.encode(),t=this._generateFragment(e,d);if(!t)return n.finalize();(-1===a||t.ranges[0].start<a)&&(a=t.ranges[0].start);const r=o=>{n.destroyed||n.box(o.moof,d=>d?this.emit("error",d):void(n.destroyed||l.inStream.slice(o.ranges).pipe(n.mediaData(o.length,t=>{if(t)return this.emit("error",t);if(!n.destroyed){const o=this._generateFragment(e);return o?void r(o):n.finalize()}}))))};r(t)}),0<=a){const t=this._fileStream=this._file.createReadStream({start:a});this._tracks.forEach(e=>{e.inStream=new Ud(a,{highWaterMark:1e7}),t.pipe(e.inStream)})}return this._tracks.map(t=>t.outStream)}_findSampleBefore(o,e){const t=this._tracks[o],n=io(t.timeScale*e);let r=function(d,e,t,n,a){var l,c;if(void 0===n)n=0;else if(0>(n|=0)||n>=d.length)throw new RangeError("invalid lower bound");if(void 0===a)a=d.length-1;else if((a|=0)<n||a>=d.length)throw new RangeError("invalid upper bound");for(;n<=a;)if(0>(c=+t(d[l=n+(a-n>>>1)],e,l,d)))n=l+1;else{if(!(0<c))return l;a=l-1}return~n}(t.samples,n,(n,e)=>n.dts+n.presentationOffset-e);for(-1===r?r=0:0>r&&(r=-r-2);!t.samples[r].sync;)r--;return r}_generateFragment(d,e){const l=this._tracks[d];let t;if((t=void 0===e?l.currSample:this._findSampleBefore(d,e))>=l.samples.length)return null;const n=l.samples[t].dts;let i=0;const c=[];for(var o=t;o<l.samples.length;o++){const r=l.samples[o];if(r.sync&&r.dts-n>=1*l.timeScale)break;i+=r.size;const e=c.length-1;0>e||c[e].end!==r.offset?c.push({start:r.offset,end:r.offset+r.size}):c[e].end+=r.size}return l.currSample=o,{moof:this._generateMoof(d,t,o),ranges:c,length:i}}_generateMoof(n,e,t){const r=this._tracks[n],d=[];let i=0;for(let o=e;o<t;o++){const t=r.samples[o];0>t.presentationOffset&&(i=1),d.push({sampleDuration:t.duration,sampleSize:t.size,sampleFlags:t.sync?33554432:16842752,sampleCompositionTimeOffset:t.presentationOffset})}const s={type:"moof",mfhd:{sequenceNumber:r.fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:r.trackId},tfdt:{baseMediaDecodeTime:r.samples[e].dts},trun:{flags:3841,dataOffset:8,entries:d,version:i}}]};return s.trafs[0].trun.dataOffset+=l.encodingLength(s),s}}}).call(this,p({}).Buffer);var Md={};Ur.prototype={_createMuxer(){this._muxer=new Pd(this._file),this._muxer.on("ready",t=>{this._tracks=t.map(r=>{const e=this._elemWrapper.createWriteStream(r.mime);e.on("error",t=>{this._elemWrapper.error(t)});const t={muxed:null,mediaSource:e,initFlushed:!1,onInitFlushed:null};return e.write(r.init,n=>{t.initFlushed=!0,t.onInitFlushed&&t.onInitFlushed(n)}),t}),(this._waitingFired||"auto"===this._elem.preload)&&this._pump()}),this._muxer.on("error",t=>{this._elemWrapper.error(t)})},_pump(){const r=this._muxer.seek(this._elem.currentTime,!this._tracks);this._tracks.forEach((e,t)=>{const n=()=>{e.muxed&&(e.muxed.destroy(),e.mediaSource=this._elemWrapper.createWriteStream(e.mediaSource),e.mediaSource.on("error",t=>{this._elemWrapper.error(t)})),e.muxed=r[t],Yr(e.muxed,e.mediaSource)};e.initFlushed?n():e.onInitFlushed=t=>{t?this._elemWrapper.error(t):n()}})},destroy(){this.destroyed||(this.destroyed=!0,this._elem.removeEventListener("waiting",this._onWaiting),this._elem.removeEventListener("error",this._onError),this._tracks&&this._tracks.forEach(t=>{t.muxed&&t.muxed.destroy()}),this._elem.src="")}},Md=Ur;var Od={render:function(o,e,d,a){"function"==typeof d&&(a=d,d={}),d||(d={}),a||(a=function(){}),Fr(o),Wr(d),"string"==typeof e&&(e=document.querySelector(e)),Mr(o,function(t){if(e.nodeName!==t.toUpperCase()){var n=pt.extname(o.name).toLowerCase();throw new Error("Cannot render \""+n+"\" inside a \""+e.nodeName.toLowerCase()+"\" element, expected \""+t+"\"")}return e},d,a)},append:function(o,d,a,s){function l(t){var e=document.createElement(t);return d.appendChild(e),e}if("function"==typeof a&&(s=a,a={}),a||(a={}),s||(s=function(){}),Fr(o),Wr(a),"string"==typeof d&&(d=document.querySelector(d)),d&&("VIDEO"===d.nodeName||"AUDIO"===d.nodeName))throw new Error("Invalid video/audio node argument. Argument must be root element that video/audio tag will be appended to.");Mr(o,function(t){return"video"===t||"audio"===t?function(t){var e=l(t);return a.autoplay&&(e.autoplay=!0),a.muted&&(e.muted=!0),a.controls&&(e.controls=!0),d.appendChild(e),e}(t):l(t)},a,function(n,e){n&&e&&e.remove(),s(n,e)})},mime:{".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/x-m4a",".m4b":"audio/mp4",".m4p":"audio/mp4",".m4v":"video/x-m4v",".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"}},Nd=jo("render-media"),Hd=[".m4a",".m4b",".m4p",".m4v",".mp4"],Dd=[".m4v",".mkv",".mp4",".webm"],qd=[].concat(Dd,[".m4a",".m4b",".m4p",".mp3"]),Fd=[".mov",".ogv"],Wd=[".aac",".oga",".ogg",".wav",".flac"],jd=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],zd=[".css",".html",".js",".md",".pdf",".txt"],Vd="undefined"!=typeof window&&window.MediaSource,Gd={};(function(o){Gd=function(e,t,n){n=Ot(n);var d=o.alloc(t),a=0;e.on("data",function(t){t.copy(d,a),a+=t.length}).on("end",function(){n(null,d)}).on("error",n)}}).call(this,p({}).Buffer);const Kd=jo("webtorrent:file-stream");var Yd=class extends st.Readable{constructor(o,e){super(e),this.destroyed=!1,this._torrent=o._torrent;const t=e&&e.start||0,n=e&&e.end&&e.end<o.length?e.end:o.length-1,r=o._torrent.pieceLength;this._startPiece=0|(t+o.offset)/r,this._endPiece=0|(n+o.offset)/r,this._piece=this._startPiece,this._offset=t+o.offset-this._startPiece*r,this._missing=n-t+1,this._reading=!1,this._notifying=!1,this._criticalLength=ao(0|1048576/r,2)}_read(){this._reading||(this._reading=!0,this._notify())}_notify(){if(!this._reading||0===this._missing)return;if(!this._torrent.bitfield.get(this._piece))return this._torrent.critical(this._piece,this._piece+this._criticalLength);if(this._notifying)return;if(this._notifying=!0,this._torrent.destroyed)return this._destroy(new Error("Torrent removed"));const r=this._piece;this._torrent.store.get(r,(e,t)=>{if(this._notifying=!1,!this.destroyed){if(e)return this._destroy(e);Kd("read %s (length %s) (err %s)",r,t.length,e&&e.message),this._offset&&(t=t.slice(this._offset),this._offset=0),this._missing<t.length&&(t=t.slice(0,this._missing)),this._missing-=t.length,Kd("pushing buffer of length %s",t.length),this._reading=!1,this.push(t),0===this._missing&&this.push(null)}}),this._piece+=1}destroy(t){this._destroy(null,t)}_destroy(n,e){this.destroyed||(this.destroyed=!0,this._torrent.destroyed||this._torrent.deselect(this._startPiece,this._endPiece,!0),n&&this.emit("error",n),this.emit("close"),e&&e())}},$d={};(function(r){const{EventEmitter:e}=m,{PassThrough:o}=st;$d=class extends e{constructor(o,e){super(),this._torrent=o,this._destroyed=!1,this.name=e.name,this.path=e.path,this.length=e.length,this.offset=e.offset,this.done=!1;const t=e.offset,n=t+e.length-1;this._startPiece=0|t/this._torrent.pieceLength,this._endPiece=0|n/this._torrent.pieceLength,0===this.length&&(this.done=!0,this.emit("done"))}get downloaded(){if(!this._torrent.bitfield)return 0;const{pieces:d,bitfield:e,pieceLength:t}=this._torrent,{_startPiece:n,_endPiece:r}=this,a=d[n];let i=e.get(n)?t-this.offset%t:to(a.length-a.missing-this.offset,0);for(let o=n+1;o<=r;++o)if(e.get(o))i+=t;else{const e=d[o];i+=e.length-e.missing}return ao(i,this.length)}get progress(){return this.length?this.downloaded/this.length:0}select(t){0!==this.length&&this._torrent.select(this._startPiece,this._endPiece,t)}deselect(){0!==this.length&&this._torrent.deselect(this._startPiece,this._endPiece,!1)}createReadStream(e){if(0===this.length){const e=new o;return r.nextTick(()=>{e.end()}),e}const t=new Yd(this,e);return this._torrent.select(t._startPiece,t._endPiece,!0,()=>{t._notify()}),Kr(t,()=>{this._destroyed||this._torrent.destroyed||this._torrent.deselect(t._startPiece,t._endPiece,!0)}),t}getBuffer(t){Gd(this.createReadStream(),this.length,t)}getBlob(n){if("undefined"==typeof window)throw new Error("browser-only method");(function(o,r){if(null!=r&&"string"!=typeof r)throw new Error("Invalid mimetype, expected string.");return new Promise((t,e)=>{const n=[];o.on("data",t=>n.push(t)).once("end",()=>{const o=null==r?new Blob(n):new Blob(n,{type:r});t(o)}).once("error",e)})})(this.createReadStream(),this._getMimeType()).then(e=>n(null,e),n)}getBlobURL(t){if("undefined"==typeof window)throw new Error("browser-only method");Sd(this.createReadStream(),this._getMimeType(),t)}appendTo(r,e,t){if("undefined"==typeof window)throw new Error("browser-only method");Od.append(this,r,e,t)}renderTo(r,e,t){if("undefined"==typeof window)throw new Error("browser-only method");Od.render(this,r,e,t)}_getMimeType(){return Od.mime[pt.extname(this.name).toLowerCase()]}_destroy(){this._destroyed=!0,this._torrent=null}}}).call(this,pe);var Xd=function(o,e){if(!(e>=o.length||0>e)){var t=o.pop();if(e<o.length){var n=o[e];return o[e]=t,n}return t}},Qd={};(function(d){const l=jo("bittorrent-protocol"),e=d.from("\x13BitTorrent protocol"),t=d.from([0,0,0,0]),n=d.from([0,0,0,1,0]),r=d.from([0,0,0,1,1]),i=d.from([0,0,0,1,2]),o=d.from([0,0,0,1,3]),f=[0,0,0,0,0,0,0,0],a=[0,0,0,3,9,0,0];class s{constructor(o,e,t,n){this.piece=o,this.offset=e,this.length=t,this.callback=n}}Qd=class extends st.Duplex{constructor(){super(),this._debugId=ur(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 id(0,{grow:4e5}),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=gr(),this.downloadSpeed=gr(),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()}setKeepAlive(t){this._debug("setKeepAlive %s",t),clearInterval(this._keepAliveInterval),!1!==t&&(this._keepAliveInterval=setInterval(()=>{this.keepAlive()},55e3))}setTimeout(n,e){this._debug("setTimeout ms=%d unref=%s",n,e),this._clearTimeout(),this._timeoutMs=n,this._timeoutUnref=!!e,this._updateTimeout()}destroy(){this.destroyed||(this.destroyed=!0,this._debug("destroy"),this.emit("close"),this.end())}end(...t){this._debug("end"),this._onUninterested(),this._onChoke(),super.end(...t)}use(o){function e(){}const d=o.prototype.name;if(!d)throw new Error("Extension class requires a \"name\" property on the prototype");this._debug("use extension.name=%s",d);const t=this._nextExt,n=new o(this);"function"!=typeof n.onHandshake&&(n.onHandshake=e),"function"!=typeof n.onExtendedHandshake&&(n.onExtendedHandshake=e),"function"!=typeof n.onMessage&&(n.onMessage=e),this.extendedMapping[t]=d,this._ext[d]=n,this[d]=n,this._nextExt+=1}keepAlive(){this._debug("keep-alive"),this._push(t)}handshake(n,l,c){let i,u;if("string"==typeof n?(n=n.toLowerCase(),i=d.from(n,"hex")):n=(i=n).toString("hex"),"string"==typeof l?u=d.from(l,"hex"):l=(u=l).toString("hex"),20!==i.length||20!==u.length)throw new Error("infoHash and peerId MUST have length 20");this._debug("handshake i=%s p=%s exts=%o",n,l,c);const p=d.from(f);p[5]|=16,c&&c.dht&&(p[7]|=1),this._push(d.concat([e,p,i,u])),this._handshakeSent=!0,this.peerExtensions.extended&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_sendExtendedHandshake(){const r=Object.assign({},this.extendedHandshake);for(const e in r.m={},this.extendedMapping){const t=this.extendedMapping[e];r.m[t]=+e}this.extended(0,te.encode(r)),this._extendedHandshakeSent=!0}choke(){if(!this.amChoking){for(this.amChoking=!0,this._debug("choke");this.peerRequests.length;)this.peerRequests.pop();this._push(n)}}unchoke(){this.amChoking&&(this.amChoking=!1,this._debug("unchoke"),this._push(r))}interested(){this.amInterested||(this.amInterested=!0,this._debug("interested"),this._push(i))}uninterested(){this.amInterested&&(this.amInterested=!1,this._debug("uninterested"),this._push(o))}have(t){this._debug("have %d",t),this._message(4,[t],null)}bitfield(e){this._debug("bitfield"),d.isBuffer(e)||(e=e.buffer),this._message(5,[],e)}request(o,e,t,n){return n||(n=()=>{}),this._finished?n(new Error("wire is closed")):this.peerChoking?n(new Error("peer is choking")):(this._debug("request index=%d offset=%d length=%d",o,e,t),this.requests.push(new s(o,e,t,n)),this._updateTimeout(),void this._message(6,[o,e,t],null))}piece(r,e,t){this._debug("piece index=%d offset=%d",r,e),this.uploaded+=t.length,this.uploadSpeed(t.length),this.emit("upload",t.length),this._message(7,[r,e],t)}cancel(r,e,t){this._debug("cancel index=%d offset=%d length=%d",r,e,t),this._callback(this._pull(this.requests,r,e,t),new Error("request was cancelled"),null),this._message(8,[r,e,t],null)}port(e){this._debug("port %d",e);const t=d.from(a);t.writeUInt16BE(e,5),this._push(t)}extended(e,o){if(this._debug("extended ext=%s",e),"string"==typeof e&&this.peerExtendedMapping[e]&&(e=this.peerExtendedMapping[e]),"number"!=typeof e)throw new Error(`Unrecognized extension: ${e}`);{const t=d.from([e]),n=d.isBuffer(o)?o:te.encode(o);this._message(20,[],d.concat([t,n]))}}_read(){}_message(e,t,n){const r=n?n.length:0,o=d.allocUnsafe(5+4*t.length);o.writeUInt32BE(o.length+r-4,0),o[4]=e;for(let r=0;r<t.length;r++)o.writeUInt32BE(t[r],5+4*r);this._push(o),n&&this._push(n)}_push(t){if(!this._finished)return this.push(t)}_onKeepAlive(){this._debug("got keep-alive"),this.emit("keep-alive")}_onHandshake(o,e,t){const n=o.toString("hex"),r=e.toString("hex");for(var d in this._debug("got handshake i=%s p=%s exts=%o",n,r,t),this.peerId=r,this.peerIdBuffer=e,this.peerExtensions=t,this.emit("handshake",n,r,t),this._ext)this._ext[d].onHandshake(n,r,t);t.extended&&this._handshakeSent&&!this._extendedHandshakeSent&&this._sendExtendedHandshake()}_onChoke(){for(this.peerChoking=!0,this._debug("got choke"),this.emit("choke");this.requests.length;)this._callback(this.requests.pop(),new Error("peer is choking"),null)}_onUnchoke(){this.peerChoking=!1,this._debug("got unchoke"),this.emit("unchoke")}_onInterested(){this.peerInterested=!0,this._debug("got interested"),this.emit("interested")}_onUninterested(){this.peerInterested=!1,this._debug("got uninterested"),this.emit("uninterested")}_onHave(t){this.peerPieces.get(t)||(this._debug("got have %d",t),this.peerPieces.set(t,!0),this.emit("have",t))}_onBitField(t){this.peerPieces=new id(t),this._debug("got bitfield"),this.emit("bitfield",this.peerPieces)}_onRequest(o,e,t){if(!this.amChoking){this._debug("got request index=%d offset=%d length=%d",o,e,t);const d=(d,r)=>{if(n===this._pull(this.peerRequests,o,e,t))return d?this._debug("error satisfying request index=%d offset=%d length=%d (%s)",o,e,t,d.message):void this.piece(o,e,r)};var n=new s(o,e,t,d);this.peerRequests.push(n),this.emit("request",o,e,t,d)}}_onPiece(r,e,t){this._debug("got piece index=%d offset=%d",r,e),this._callback(this._pull(this.requests,r,e,t.length),null,t),this.downloaded+=t.length,this.downloadSpeed(t.length),this.emit("download",t.length),this.emit("piece",r,e,t)}_onCancel(r,e,t){this._debug("got cancel index=%d offset=%d length=%d",r,e,t),this._pull(this.peerRequests,r,e,t),this.emit("cancel",r,e,t)}_onPort(t){this._debug("got port %d",t),this.emit("port",t)}_onExtended(n,r){if(0===n){let t,e;try{t=te.decode(r)}catch(e){this._debug("ignoring invalid extended handshake: %s",e.message||e)}if(!t)return;if(this.peerExtendedHandshake=t,"object"==typeof t.m)for(e in t.m)this.peerExtendedMapping[e]=+t.m[e].toString();for(e in this._ext)this.peerExtendedMapping[e]&&this._ext[e].onExtendedHandshake(this.peerExtendedHandshake);this._debug("got extended handshake"),this.emit("extended","handshake",this.peerExtendedHandshake)}else this.extendedMapping[n]&&(n=this.extendedMapping[n],this._ext[n]&&this._ext[n].onMessage(r)),this._debug("got extended message ext=%s",n),this.emit("extended",n,r)}_onTimeout(){this._debug("request timed out"),this._callback(this.requests.shift(),new Error("request has timed out"),null),this.emit("timeout")}_write(e,t,n){for(this._bufferSize+=e.length,this._buffer.push(e);this._bufferSize>=this._parserSize;){const e=1===this._buffer.length?this._buffer[0]:d.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[e.slice(this._parserSize)]:[],this._parser(e.slice(0,this._parserSize))}n(null)}_callback(r,e,t){r&&(this._clearTimeout(),this.peerChoking||this._finished||this._updateTimeout(),r.callback(e,t))}_clearTimeout(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)}_updateTimeout(){this._timeoutMs&&this.requests.length&&!this._timeout&&(this._timeout=setTimeout(()=>this._onTimeout(),this._timeoutMs),this._timeoutUnref&&this._timeout.unref&&this._timeout.unref())}_parse(n,e){this._parserSize=n,this._parser=e}_onMessageLength(n){const e=n.readUInt32BE(0);0<e?this._parse(e,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))}_onMessage(t){switch(this._parse(4,this._onMessageLength),t[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(t.readUInt32BE(1));case 5:return this._onBitField(t.slice(1));case 6:return this._onRequest(t.readUInt32BE(1),t.readUInt32BE(5),t.readUInt32BE(9));case 7:return this._onPiece(t.readUInt32BE(1),t.readUInt32BE(5),t.slice(9));case 8:return this._onCancel(t.readUInt32BE(1),t.readUInt32BE(5),t.readUInt32BE(9));case 9:return this._onPort(t.readUInt16BE(1));case 20:return this._onExtended(t.readUInt8(1),t.slice(2));default:return this._debug("got unknown message"),this.emit("unknownmessage",t);}}_parseHandshake(){this._parse(1,n=>{const r=n.readUInt8(0);this._parse(r+48,t=>{const o=t.slice(0,r);return"BitTorrent protocol"===o.toString()?void(t=t.slice(r),this._onHandshake(t.slice(8,28),t.slice(28,48),{dht:!!(1&t[7]),extended:!!(16&t[5])}),this._parse(4,this._onMessageLength)):(this._debug("Error: wire not speaking BitTorrent protocol (%s)",o.toString()),void this.end())})})}_onFinish(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,()=>{});this.peerRequests.length;)this.peerRequests.pop();for(;this.requests.length;)this._callback(this.requests.pop(),new Error("wire was closed"),null)}_debug(...t){t[0]=`[${this._debugId}] ${t[0]}`,l(...t)}_pull(o,e,t,n){for(let r=0;r<o.length;r++){const d=o[r];if(d.piece===e&&d.offset===t&&d.length===n)return Xd(o,r),d}return null}}}).call(this,p({}).Buffer);var Jd={};(function(n){const m=jo("webtorrent:webconn");Jd=class extends Qd{constructor(n,e){super(),this.url=n,this.webPeerId=qo.sync(n),this._torrent=e,this._init()}_init(){this.setKeepAlive(!0),this.once("handshake",t=>{if(!this.destroyed){this.handshake(t,this.webPeerId);const e=this._torrent.pieces.length,n=new id(e);for(let t=0;t<=e;t++)n.set(t,!0);this.bitfield(n)}}),this.once("interested",()=>{m("interested"),this.unchoke()}),this.on("uninterested",()=>{m("uninterested")}),this.on("choke",()=>{m("choke")}),this.on("unchoke",()=>{m("unchoke")}),this.on("bitfield",()=>{m("bitfield")}),this.on("request",(t,e,n,r)=>{m("request pieceIndex=%d offset=%d length=%d",t,e,n),this.httpRequest(t,e,n,r)})}httpRequest(t,r,i,s){const o=t*this._torrent.pieceLength+r,a=o+i-1,p=this._torrent.files;let c;if(1>=p.length)c=[{url:this.url,start:o,end:a}];else{const t=p.filter(t=>t.offset<=a&&t.offset+t.length>o);if(1>t.length)return s(new Error("Could not find file corresponnding to web seed range request"));c=t.map(n=>{const e=n.offset+n.length-1;return{url:this.url+("/"===this.url[this.url.length-1]?"":"/")+n.path,fileOffsetInRange:to(n.offset-o,0),start:to(o-n.offset,0),end:ao(e,a-n.offset)}})}let h,g=0,_=!1;1<c.length&&(h=n.alloc(i)),c.forEach(o=>{function d(e,t){return 200>e.statusCode||300<=e.statusCode?(_=!0,s(new Error(`Unexpected HTTP status code ${e.statusCode}`))):void(m("Got data of length %d",t.length),1===c.length?s(null,t):(t.copy(h,o.fileOffsetInRange),++g===c.length&&s(null,h)))}const l=o.url,e=o.start,n=o.end;m("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",l,t,r,i,e,n);const a={url:l,method:"GET",headers:{"user-agent":`WebTorrent/${"0.107.0"} (https://webtorrent.io)`,range:`bytes=${e}-${n}`}};nr.concat(a,(r,e,t)=>{if(!_)return r?"undefined"==typeof window||l.startsWith(`${window.location.origin}/`)?(_=!0,s(r)):nr.head(l,(e,t)=>{if(!_){if(e)return _=!0,s(e);if(200>t.statusCode||300<=t.statusCode)return _=!0,s(new Error(`Unexpected HTTP status code ${t.statusCode}`));if(t.url===l)return _=!0,s(r);a.url=t.url,nr.concat(a,(r,e,t)=>{if(!_)return r?(_=!0,s(r)):void d(e,t)})}}):void d(e,t)})})}destroy(){super.destroy(),this._torrent=null}}}).call(this,p({}).Buffer);var Zd={};const ea=jo("webtorrent:peer");Zd.createWebRTCPeer=(r,e)=>{const t=new ta(r.id,"webrtc");return t.conn=r,t.swarm=e,t.conn.connected?t.onConnect():(t.conn.once("connect",()=>{t.onConnect()}),t.conn.once("error",n=>{t.destroy(n)}),t.startConnectTimeout()),t},Zd.createTCPOutgoingPeer=(r,e)=>{const t=new ta(r,"tcpOutgoing");return t.addr=r,t.swarm=e,t},Zd.createWebSeedPeer=(r,e)=>{const t=new ta(r,"webSeed");return t.swarm=e,t.conn=new Jd(r,e),t.onConnect(),t};class ta{constructor(n,e){this.id=n,this.type=e,ea("new %s Peer %s",e,n),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}onConnect(){if(!this.destroyed){this.connected=!0,ea("Peer %s connected",this.id),clearTimeout(this.connectTimeout);const n=this.conn;n.once("end",()=>{this.destroy()}),n.once("close",()=>{this.destroy()}),n.once("finish",()=>{this.destroy()}),n.once("error",t=>{this.destroy(t)});const e=this.wire=new Qd;e.type=this.type,e.once("end",()=>{this.destroy()}),e.once("close",()=>{this.destroy()}),e.once("finish",()=>{this.destroy()}),e.once("error",t=>{this.destroy(t)}),e.once("handshake",(n,e)=>{this.onHandshake(n,e)}),this.startHandshakeTimeout(),n.pipe(e).pipe(n),this.swarm&&!this.sentHandshake&&this.handshake()}}onHandshake(r,e){if(!this.swarm)return;if(this.destroyed)return;if(this.swarm.destroyed)return this.destroy(new Error("swarm already destroyed"));if(r!==this.swarm.infoHash)return this.destroy(new Error("unexpected handshake info hash for this swarm"));if(e===this.swarm.peerId)return this.destroy(new Error("refusing to connect to ourselves"));ea("Peer %s got handshake %s",this.id,r),clearTimeout(this.handshakeTimeout),this.retries=0;let t=this.addr;!t&&this.conn.remoteAddress&&this.conn.remotePort&&(t=`${this.conn.remoteAddress}:${this.conn.remotePort}`),this.swarm._onWire(this.wire,t),this.swarm&&!this.swarm.destroyed&&(this.sentHandshake||this.handshake())}handshake(){const t={dht:!this.swarm.private&&!!this.swarm.client.dht};this.wire.handshake(this.swarm.infoHash,this.swarm.client.peerId,t),this.sentHandshake=!0}startConnectTimeout(){clearTimeout(this.connectTimeout),this.connectTimeout=setTimeout(()=>{this.destroy(new Error("connect timeout"))},"webrtc"===this.type?25e3:5e3),this.connectTimeout.unref&&this.connectTimeout.unref()}startHandshakeTimeout(){clearTimeout(this.handshakeTimeout),this.handshakeTimeout=setTimeout(()=>{this.destroy(new Error("handshake timeout"))},25e3),this.handshakeTimeout.unref&&this.handshakeTimeout.unref()}destroy(o){if(!this.destroyed){this.destroyed=!0,this.connected=!1,ea("destroy %s (error: %s)",this.id,o&&(o.message||o)),clearTimeout(this.connectTimeout),clearTimeout(this.handshakeTimeout);const e=this.swarm,t=this.conn,n=this.wire;this.swarm=null,this.conn=null,this.wire=null,e&&n&&Xd(e.wires,e.wires.indexOf(n)),t&&(t.on("error",()=>{}),t.destroy()),n&&n.destroy(),e&&e.removePeer(this.id)}}}var na={};(function(d,a){function g(n,e){return 2+eo(e*n.downloadSpeed()/md.BLOCK_LENGTH)}function l(){}const t=jo("webtorrent:torrent"),e=m.EventEmitter,u=3*md.BLOCK_LENGTH,n=d.browser?1/0:2,r=[1e3,5e3,15e3];let o;try{o=pt.join(St.statSync("/tmp")&&"/tmp","webtorrent")}catch(e){o=pt.join("function"==typeof oe.tmpdir?oe.tmpdir():"/","webtorrent")}na=class extends e{constructor(r,e,t){super(),this._debugId="unknown infohash",this.client=e,this.announce=t.announce,this.urlList=t.urlList,this.path=t.path,this.skipVerify=!!t.skipVerify,this._store=t.store||fd,this._getAnnounceOpts=t.getAnnounceOpts,this.strategy=t.strategy||"sequential",this.maxWebConns=t.maxWebConns||4,this._rechokeNumSlots=!1===t.uploads||0===t.uploads?0:+t.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=gr(),this._uploadSpeed=gr(),this._servers=[],this._xsRequests=[],this._fileModtimes=t.fileModtimes,null!==r&&this._onTorrentId(r),this._debug("new torrent")}get timeRemaining(){return this.done?0:0===this.downloadSpeed?1/0:1e3*((this.length-this.downloaded)/this.downloadSpeed)}get downloaded(){if(!this.bitfield)return 0;let r=0;for(let e=0,t=this.pieces.length;e<t;++e)if(this.bitfield.get(e))r+=e==t-1?this.lastPieceLength:this.pieceLength;else{const t=this.pieces[e];r+=t.length-t.missing}return r}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){return this.length?this.downloaded/this.length:0}get ratio(){return this.uploaded/(this.received||1)}get numPeers(){return this.wires.length}get torrentFileBlobURL(){if("undefined"==typeof window)throw new Error("browser-only property");return this.torrentFile?URL.createObjectURL(new Blob([this.torrentFile],{type:"application/x-bittorrent"})):null}get _numQueued(){return this._queue.length+(this._peersLength-this._numConns)}get _numConns(){let n=0;for(const e in this._peers)this._peers[e].connected&&(n+=1);return n}get swarm(){return console.warn("WebTorrent: `torrent.swarm` is deprecated. Use `torrent` directly instead."),this}_onTorrentId(e){if(this.destroyed)return;let t;try{t=Zo(e)}catch(e){}t?(this.infoHash=t.infoHash,this._debugId=t.infoHash.toString("hex").substring(0,7),d.nextTick(()=>{this.destroyed||this._onParsedTorrent(t)})):Zo.remote(e,(n,e)=>{if(!this.destroyed)return n?this._destroy(n):void this._onParsedTorrent(e)})}_onParsedTorrent(t){if(!this.destroyed){if(this._processParsedTorrent(t),!this.infoHash)return this._destroy(new Error("Malformed torrent data: No info hash"));this.path||(this.path=pt.join(o,this.infoHash)),this._rechokeIntervalId=setInterval(()=>{this._rechoke()},1e4),this._rechokeIntervalId.unref&&this._rechokeIntervalId.unref(),this.emit("_infoHash",this.infoHash),this.destroyed||(this.emit("infoHash",this.infoHash),this.destroyed||(this.client.listening?this._onListening():this.client.once("listening",()=>{this._onListening()})))}}_processParsedTorrent(t){this._debugId=t.infoHash.toString("hex").substring(0,7),this.announce&&(t.announce=t.announce.concat(this.announce)),this.client.tracker&&a.WEBTORRENT_ANNOUNCE&&!this.private&&(t.announce=t.announce.concat(a.WEBTORRENT_ANNOUNCE)),this.urlList&&(t.urlList=t.urlList.concat(this.urlList)),or(t.announce),or(t.urlList),Object.assign(this,t),this.magnetURI=Zo.toMagnetURI(t),this.torrentFile=Zo.toTorrentFile(t)}_onListening(){if(this.discovery||this.destroyed)return;let t=this.client.tracker;t&&(t=Object.assign({},this.client.tracker,{getAnnounceOpts:()=>{const t={uploaded:this.uploaded,downloaded:this.downloaded,left:to(this.length-this.downloaded,0)};return this.client.tracker.getAnnounceOpts&&Object.assign(t,this.client.tracker.getAnnounceOpts()),this._getAnnounceOpts&&Object.assign(t,this._getAnnounceOpts()),t}})),this.discovery=new ud({infoHash:this.infoHash,announce:this.announce,peerId:this.client.peerId,dht:!this.private&&this.client.dht,tracker:t,port:this.client.torrentPort,userAgent:`WebTorrent/${"0.107.0"} (https://webtorrent.io)`}),this.discovery.on("error",t=>{this._destroy(t)}),this.discovery.on("peer",t=>{"string"==typeof t&&this.done||this.addPeer(t)}),this.discovery.on("trackerAnnounce",()=>{this.emit("trackerAnnounce"),0===this.numPeers&&this.emit("noPeers","tracker")}),this.discovery.on("dhtAnnounce",()=>{this.emit("dhtAnnounce"),0===this.numPeers&&this.emit("noPeers","dht")}),this.discovery.on("warning",t=>{this.emit("warning",t)}),this.info?this._onMetadata(this):this.xs&&this._getMetadataFromServer()}_getMetadataFromServer(){const d=this,e=(Array.isArray(this.xs)?this.xs:[this.xs]).map(e=>t=>{!function(e,t){if(0!==e.indexOf("http://")&&0!==e.indexOf("https://"))return d.emit("warning",new Error(`skipping non-http xs param: ${e}`)),t(null);let n;try{n=nr.concat({url:e,method:"GET",headers:{"user-agent":"WebTorrent/0.107.0 (https://webtorrent.io)"}},function(n,r,a){if(d.destroyed)return t(null);if(d.metadata)return t(null);if(n)return d.emit("warning",new Error(`http error from xs param: ${e}`)),t(null);if(200!==r.statusCode)return d.emit("warning",new Error(`non-200 status code ${r.statusCode} from xs param: ${e}`)),t(null);let i;try{i=Zo(a)}catch(e){}return i?i.infoHash===d.infoHash?(d._onMetadata(i),void t(null)):(d.emit("warning",new Error(`got torrent file with incorrect info hash from xs param: ${e}`)),t(null)):(d.emit("warning",new Error(`got invalid torrent file from xs param: ${e}`)),t(null))})}catch(n){return d.emit("warning",new Error(`skipping invalid url xs param: ${e}`)),t(null)}d._xsRequests.push(n)}(e,t)});Oo(e)}_onMetadata(n){if(this.metadata||this.destroyed)return;let e;if(this._debug("got metadata"),this._xsRequests.forEach(t=>{t.abort()}),this._xsRequests=[],n&&n.infoHash)e=n;else try{e=Zo(n)}catch(e){return this._destroy(e)}if(this._processParsedTorrent(e),this.metadata=this.torrentFile,this.client.enableWebSeeds&&this.urlList.forEach(t=>{this.addWebSeed(t)}),this._rarityMap=new class{constructor(t){this._torrent=t,this._numPieces=t.pieces.length,this._pieces=Array(this._numPieces),this._onWire=t=>{this.recalculate(),this._initWire(t)},this._onWireHave=t=>{this._pieces[t]+=1},this._onWireBitfield=()=>{this.recalculate()},this._torrent.wires.forEach(t=>{this._initWire(t)}),this._torrent.on("wire",this._onWire),this.recalculate()}getRarestPiece(o){let e=[],d=1/0;for(let t=0;t<this._numPieces;++t){if(o&&!o(t))continue;const n=this._pieces[t];n===d?e.push(t):n<d&&(e=[t],d=n)}return e.length?e[0|Math.random()*e.length]:-1}destroy(){this._torrent.removeListener("wire",this._onWire),this._torrent.wires.forEach(t=>{this._cleanupWireEvents(t)}),this._torrent=null,this._pieces=null,this._onWire=null,this._onWireHave=null,this._onWireBitfield=null}_initWire(n){n._onClose=()=>{this._cleanupWireEvents(n);for(let e=0;e<this._numPieces;++e)this._pieces[e]-=n.peerPieces.get(e)},n.on("have",this._onWireHave),n.on("bitfield",this._onWireBitfield),n.once("close",n._onClose)}recalculate(){this._pieces.fill(0);for(const n of this._torrent.wires)for(let e=0;e<this._numPieces;++e)this._pieces[e]+=n.peerPieces.get(e)}_cleanupWireEvents(t){t.removeListener("have",this._onWireHave),t.removeListener("bitfield",this._onWireBitfield),t._onClose&&t.removeListener("close",t._onClose),t._onClose=null}}(this),this.store=new pd(new this._store(this.pieceLength,{torrent:{infoHash:this.infoHash},files:this.files.map(t=>({path:pt.join(this.path,t.path),length:t.length,offset:t.offset})),length:this.length,name:this.infoHash})),this.files=this.files.map(t=>new $d(this,t)),this.so){const r=yd.parse(this.so);this.files.forEach((e,t)=>{r.includes(t)&&this.files[t].select(!0)})}else 0!==this.pieces.length&&this.select(0,this.pieces.length-1,!1);if(this._hashes=this.pieces,this.pieces=this.pieces.map((r,e)=>{const t=e===this.pieces.length-1?this.lastPieceLength:this.pieceLength;return new md(t)}),this._reservations=this.pieces.map(()=>[]),this.bitfield=new id(this.pieces.length),this.wires.forEach(t=>{t.ut_metadata&&t.ut_metadata.setMetadata(this.metadata),this._onWireWithMetadata(t)}),this.skipVerify)this._markAllVerified(),this._onStore();else{const r=t=>t?this._destroy(t):void(this._debug("done verifying"),this._onStore());this._debug("verifying existing torrent data"),this._fileModtimes&&this._store===fd?this.getFileModtimes((e,o)=>e?this._destroy(e):void(this.files.map((n,e)=>o[e]===this._fileModtimes[e]).every(t=>t)?(this._markAllVerified(),this._onStore()):this._verifyPieces(r))):this._verifyPieces(r)}this.emit("metadata")}getFileModtimes(r){const o=[];zr(this.files.map((t,d)=>n=>{St.stat(pt.join(this.path,t.path),(t,e)=>t&&"ENOENT"!==t.code?n(t):void(o[d]=e&&e.mtime.getTime(),n(null)))}),n,e=>{this._debug("done getting file modtimes"),r(e,o)})}_verifyPieces(e){zr(this.pieces.map((e,r)=>n=>this.destroyed?n(new Error("torrent is destroyed")):void this.store.get(r,(e,t)=>this.destroyed?n(new Error("torrent is destroyed")):e?d.nextTick(n,null):void qo(t,t=>{if(this.destroyed)return n(new Error("torrent is destroyed"));if(t===this._hashes[r]){if(!this.pieces[r])return;this._debug("piece verified %s",r),this._markVerified(r)}else this._debug("piece invalid %s",r);n(null)}))),n,e)}rescanFiles(n){if(this.destroyed)throw new Error("torrent is destroyed");n||(n=l),this._verifyPieces(e=>e?(this._destroy(e),n(e)):void(this._checkDone(),n(null)))}_markAllVerified(){for(let t=0;t<this.pieces.length;t++)this._markVerified(t)}_markVerified(t){this.pieces[t]=null,this._reservations[t]=null,this.bitfield.set(t,!0)}_onStore(){this.destroyed||(this._debug("on store"),this.ready=!0,this.emit("ready"),this._checkDone(),this._updateSelections())}destroy(t){this._destroy(null,t)}_destroy(r,e){if(!this.destroyed){for(const e in this.destroyed=!0,this._debug("destroy"),this.client._remove(this),clearInterval(this._rechokeIntervalId),this._xsRequests.forEach(t=>{t.abort()}),this._rarityMap&&this._rarityMap.destroy(),this._peers)this.removePeer(e);this.files.forEach(t=>{t instanceof $d&&t._destroy()});const t=this._servers.map(n=>e=>{n.destroy(e)});this.discovery&&t.push(t=>{this.discovery.destroy(t)}),this.store&&t.push(t=>{this.store.close(t)}),Oo(t,e),r&&(0===this.listenerCount("error")?this.client.emit("error",r):this.emit("error",r)),this.emit("close"),this.client=null,this.files=[],this.discovery=null,this.store=null,this._rarityMap=null,this._peers=null,this._servers=null,this._xsRequests=null}}addPeer(r){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.infoHash)throw new Error("addPeer() must not be called before the `infoHash` event");if(this.client.blocked){let e;if("string"==typeof r){let t;try{t=mr(r)}catch(e){return this._debug("ignoring peer: invalid %s",r),this.emit("invalidPeer",r),!1}e=t[0]}else"string"==typeof r.remoteAddress&&(e=r.remoteAddress);if(e&&this.client.blocked.contains(e))return this._debug("ignoring peer: blocked %s",r),"string"!=typeof r&&r.destroy(),this.emit("blockedPeer",r),!1}const e=!!this._addPeer(r);return e?this.emit("peer",r):this.emit("invalidPeer",r),e}_addPeer(r){if(this.destroyed)return"string"!=typeof r&&r.destroy(),null;if("string"==typeof r&&!this._validAddr(r))return this._debug("ignoring peer: invalid %s",r),null;const e=r&&r.id||r;if(this._peers[e])return this._debug("ignoring peer: duplicate (%s)",e),"string"!=typeof r&&r.destroy(),null;if(this.paused)return this._debug("ignoring peer: torrent is paused"),"string"!=typeof r&&r.destroy(),null;let t;return this._debug("add peer %s",e),t="string"==typeof r?Zd.createTCPOutgoingPeer(r,this):Zd.createWebRTCPeer(r,this),this._peers[t.id]=t,this._peersLength+=1,"string"==typeof r&&(this._queue.push(t),this._drain()),t}addWebSeed(n){if(this.destroyed)throw new Error("torrent is destroyed");if(!/^https?:\/\/.+/.test(n))return this.emit("warning",new Error(`ignoring invalid web seed: ${n}`)),void this.emit("invalidPeer",n);if(this._peers[n])return this.emit("warning",new Error(`ignoring duplicate web seed: ${n}`)),void this.emit("invalidPeer",n);this._debug("add web seed %s",n);const e=Zd.createWebSeedPeer(n,this);this._peers[e.id]=e,this._peersLength+=1,this.emit("peer",n)}_addIncomingPeer(t){return this.destroyed?t.destroy(new Error("torrent is destroyed")):this.paused?t.destroy(new Error("torrent is paused")):(this._debug("add incoming peer %s",t.id),this._peers[t.id]=t,void(this._peersLength+=1))}removePeer(n){const r=n&&n.id||n;(n=this._peers[r])&&(this._debug("removePeer %s",r),delete this._peers[r],this._peersLength-=1,n.destroy(),this._drain())}select(o,e,t,d){if(this.destroyed)throw new Error("torrent is destroyed");if(0>o||e<o||this.pieces.length<=e)throw new Error(`invalid selection ${o} : ${e}`);t=+t||0,this._debug("select %s-%s (priority %s)",o,e,t),this._selections.push({from:o,to:e,offset:0,priority:t,notify:d||l}),this._selections.sort((n,e)=>e.priority-n.priority),this._updateSelections()}deselect(o,e,t){if(this.destroyed)throw new Error("torrent is destroyed");t=+t||0,this._debug("deselect %s-%s (priority %s)",o,e,t);for(let n=0;n<this._selections.length;++n){const r=this._selections[n];if(r.from===o&&r.to===e&&r.priority===t){this._selections.splice(n,1);break}}this._updateSelections()}critical(r,e){if(this.destroyed)throw new Error("torrent is destroyed");this._debug("critical %s-%s",r,e);for(let t=r;t<=e;++t)this._critical[t]=!0;this._updateSelections()}_onWire(r,t){if(this._debug("got wire %s (%s)",r._debugId,t||"Unknown"),r.on("download",t=>{this.destroyed||(this.received+=t,this._downloadSpeed(t),this.client._downloadSpeed(t),this.emit("download",t),this.client.emit("download",t))}),r.on("upload",t=>{this.destroyed||(this.uploaded+=t,this._uploadSpeed(t),this.client._uploadSpeed(t),this.emit("upload",t),this.client.emit("upload",t))}),this.wires.push(r),t){const n=mr(t);r.remoteAddress=n[0],r.remotePort=n[1]}this.client.dht&&this.client.dht.listening&&r.on("port",n=>{if(!this.destroyed&&!this.client.dht.destroyed){if(!r.remoteAddress)return this._debug("ignoring PORT from peer with no address");if(0===n||65536<n)return this._debug("ignoring invalid PORT from peer");this._debug("port: %s (from %s)",n,t),this.client.dht.addNode({host:r.remoteAddress,port:n})}}),r.on("timeout",()=>{this._debug("wire timeout (%s)",t),r.destroy()}),r.setTimeout(3e4,!0),r.setKeepAlive(!0),r.use(bd(this.metadata)),r.ut_metadata.on("warning",t=>{this._debug("ut_metadata warning: %s",t.message)}),this.metadata||(r.ut_metadata.on("metadata",t=>{this._debug("got metadata via ut_metadata"),this._onMetadata(t)}),r.ut_metadata.fetch()),!0,this.emit("wire",r,t),this.metadata&&d.nextTick(()=>{this._onWireWithMetadata(r)})}_onWireWithMetadata(o){let e=null;const d=()=>{this.destroyed||o.destroyed||(this._numQueued>2*(this._numConns-this.numPeers)&&o.amInterested?o.destroy():(e=setTimeout(d,5e3)).unref&&e.unref())};let n;const a=()=>{if(o.peerPieces.buffer.length===this.bitfield.buffer.length){for(n=0;n<this.pieces.length;++n)if(!o.peerPieces.get(n))return;o.isSeeder=!0,o.choke()}};o.on("bitfield",()=>{a(),this._update()}),o.on("have",()=>{a(),this._update()}),o.once("interested",()=>{o.unchoke()}),o.once("close",()=>{clearTimeout(e)}),o.on("choke",()=>{clearTimeout(e),(e=setTimeout(d,5e3)).unref&&e.unref()}),o.on("unchoke",()=>{clearTimeout(e),this._update()}),o.on("request",(e,t,n,r)=>131072<n?o.destroy():void(this.pieces[e]||this.store.get(e,{offset:t,length:n},r))),o.bitfield(this.bitfield),o.uninterested(),o.peerExtensions.dht&&this.client.dht&&this.client.dht.listening&&o.port(this.client.dht.address().port),"webSeed"!==o.type&&(e=setTimeout(d,5e3)).unref&&e.unref(),o.isSeeder=!1,a()}_updateSelections(){this.ready&&!this.destroyed&&(d.nextTick(()=>{this._gcSelections()}),this._updateInterest(),this._update())}_gcSelections(){for(let r=0;r<this._selections.length;++r){const e=this._selections[r],t=e.offset;for(;this.bitfield.get(e.from+e.offset)&&e.from+e.offset<e.to;)e.offset+=1;t!==e.offset&&e.notify(),e.to===e.from+e.offset&&this.bitfield.get(e.from+e.offset)&&(this._selections.splice(r,1),r-=1,e.notify(),this._updateInterest())}this._selections.length||this.emit("idle")}_updateInterest(){const t=this._amInterested;this._amInterested=!!this._selections.length,this.wires.forEach(r=>{let e=!1;for(let t=0;t<this.pieces.length;++t)if(this.pieces[t]&&r.peerPieces.get(t)){e=!0;break}e?r.interested():r.uninterested()}),t!==this._amInterested&&(this._amInterested?this.emit("interested"):this.emit("uninterested"))}_update(){if(!this.destroyed){const t=(o=this.wires,d=0,function(){if(d===o.length)return null;var t=o.length-d,e=0|Math.random()*t,n=o[d+e],r=o[d];return o[d]=n,o[d+e]=r,d++,n});var o,d;for(let e;e=t();)this._updateWireWrapper(e)}}_updateWireWrapper(n){const e=this;"undefined"!=typeof window&&"function"==typeof window.requestIdleCallback?window.requestIdleCallback(function(){e._updateWire(n)}):e._updateWire(n)}_updateWire(d){function e(e,t,n,r){return o=>o>=e&&o<=t&&!(o in n)&&d.peerPieces.get(o)&&(!r||r(o))}function s(t){let e=t;for(let n=t;n<l._selections.length&&l._selections[n].priority;n++)e=n;const o=l._selections[t];l._selections[t]=l._selections[e],l._selections[e]=o}function o(t){if(d.requests.length>=m)return!0;const n=function(){const t=d.downloadSpeed()||1;if(t>u)return()=>!0;const n=to(1,d.requests.length)*md.BLOCK_LENGTH/t;let r=10,i=0;return o=>{if(!r||l.bitfield.get(o))return!0;for(let e=l.pieces[o].missing;i<l.wires.length;i++){const d=l.wires[i],a=d.downloadSpeed();if(!(a<u)&&!(a<=t)&&d.peerPieces.get(o)&&!(0<(e-=a*n)))return r--,!1}return!0}}();for(let r=0;r<l._selections.length;r++){const o=l._selections[r];let a;if("rarest"===l.strategy){const i=o.from+o.offset,c=o.to,u={};let f=0;for(const p=e(i,c,u,n);f<c-i+1&&!(0>(a=l._rarityMap.getRarestPiece(p)));){for(;l._request(d,a,l._critical[a]||t););if(!(d.requests.length<m))return o.priority&&s(r),!0;u[a]=!0,f++}}else for(a=o.from+o.offset;a<=o.to;a++)if(d.peerPieces.get(a)&&n(a)){for(;l._request(d,a,l._critical[a]||t););if(!(d.requests.length<m))return o.priority&&s(r),!0}}return!1}const l=this;if(d.peerChoking)return;if(!d.downloaded)return function(){if(!d.requests.length)for(let t=l._selections.length;t--;){const a=l._selections[t];let r;if("rarest"===l.strategy){const t=a.from+a.offset,n=a.to,o={};let i=0;for(const a=e(t,n,o);i<n-t+1&&!(0>(r=l._rarityMap.getRarestPiece(a)));){if(l._request(d,r,!1))return;o[r]=!0,i+=1}}else for(r=a.to;r>=a.from+a.offset;--r)if(d.peerPieces.get(r)&&l._request(d,r,!1))return}}();const t=g(d,.5);if(d.requests.length>=t)return;const m=g(d,1);o(!1)||o(!0)}_rechoke(){if(!this.ready)return;0<this._rechokeOptimisticTime?this._rechokeOptimisticTime-=1:this._rechokeOptimisticWire=null;const o=[];this.wires.forEach(e=>{e.isSeeder||e===this._rechokeOptimisticWire||o.push({wire:e,downloadSpeed:e.downloadSpeed(),uploadSpeed:e.uploadSpeed(),salt:Math.random(),isChoked:!0})}),o.sort(function(n,e){return n.downloadSpeed===e.downloadSpeed?n.uploadSpeed===e.uploadSpeed?n.wire.amChoking===e.wire.amChoking?n.salt-e.salt:n.wire.amChoking?1:-1:e.uploadSpeed-n.uploadSpeed:e.downloadSpeed-n.downloadSpeed});let e=0,d=0;for(;d<o.length&&e<this._rechokeNumSlots;++d)o[d].isChoked=!1,o[d].wire.peerInterested&&(e+=1);if(!this._rechokeOptimisticWire&&d<o.length&&this._rechokeNumSlots){const e=o.slice(d).filter(t=>t.wire.peerInterested),t=e[(a=e.length,0|Math.random()*a)];t&&(t.isChoked=!1,this._rechokeOptimisticWire=t.wire,this._rechokeOptimisticTime=2)}var a;o.forEach(t=>{t.wire.amChoking!==t.isChoked&&(t.isChoked?t.wire.choke():t.wire.unchoke())})}_hotswap(d,i){const e=d.downloadSpeed();if(e<md.BLOCK_LENGTH)return!1;if(!this._reservations[i])return!1;const n=this._reservations[i];if(!n)return!1;let r,l,c=1/0;for(l=0;l<n.length;l++){const o=n[l];if(!o||o===d)continue;const t=o.downloadSpeed();t>=u||2*t>e||t>c||(r=o,c=t)}if(!r)return!1;for(l=0;l<n.length;l++)n[l]===r&&(n[l]=null);for(l=0;l<r.requests.length;l++){const t=r.requests[l];t.piece===i&&this.pieces[i].cancel(0|t.offset/md.BLOCK_LENGTH)}return this.emit("hotswap",r,d,i),!0}_request(m,t,e){function n(){d.nextTick(()=>{p._update()})}const p=this,r=m.requests.length,i="webSeed"===m.type;if(p.bitfield.get(t))return!1;if(r>=(i?ao(function(r,e,t){return 1+eo(1*r.downloadSpeed()/t)}(m,0,p.pieceLength),p.maxWebConns):g(m,1)))return!1;const o=p.pieces[t];let a=i?o.reserveRemaining():o.reserve();if(-1===a&&e&&p._hotswap(m,t)&&(a=i?o.reserveRemaining():o.reserve()),-1===a)return!1;let _=p._reservations[t];_||(_=p._reservations[t]=[]);let b=_.indexOf(null);-1===b&&(b=_.length),_[b]=m;const y=o.chunkOffset(a),l=i?o.chunkLengthRemaining(a):o.chunkLength(a);return m.request(t,y,l,function d(e,r){if(p.destroyed)return;if(!p.ready)return p.once("ready",()=>{d(e,r)});if(_[b]===m&&(_[b]=null),o!==p.pieces[t])return n();if(e)return p._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,y,l,`${m.remoteAddress}:${m.remotePort}`,e.message),i?o.cancelRemaining(a):o.cancel(a),void n();if(p._debug("got piece %s (offset: %s length: %s) from %s",t,y,l,`${m.remoteAddress}:${m.remotePort}`),!o.set(a,r,m))return n();const s=o.flush();qo(s,r=>{if(!p.destroyed){if(r===p._hashes[t]){if(!p.pieces[t])return;p._debug("piece verified %s",t),p.pieces[t]=null,p._reservations[t]=null,p.bitfield.set(t,!0),p.store.put(t,s),p.wires.forEach(n=>{n.have(t)}),p._checkDone()&&!p.destroyed&&p.discovery.complete()}else p.pieces[t]=new md(o.length),p.emit("warning",new Error(`Piece ${t} failed verification`));n()}})}),!0}_checkDone(){if(this.destroyed)return;this.files.forEach(n=>{if(!n.done){for(let e=n._startPiece;e<=n._endPiece;++e)if(!this.bitfield.get(e))return;n.done=!0,n.emit("done"),this._debug(`file done: ${n.name}`)}});let r=!0;for(let e=0;e<this._selections.length;e++){const o=this._selections[e];for(let e=o.from;e<=o.to;e++)if(!this.bitfield.get(e)){r=!1;break}if(!r)break}return!this.done&&r&&(this.done=!0,this._debug(`torrent done: ${this.infoHash}`),this.emit("done")),this._gcSelections(),r}load(o,d){if(this.destroyed)throw new Error("torrent is destroyed");if(!this.ready)return this.once("ready",()=>{this.load(o,d)});Array.isArray(o)||(o=[o]),d||(d=l);const a=new hd(o),n=new sd(this.store,this.pieceLength);Yr(a,n,t=>t?d(t):void(this._markAllVerified(),this._checkDone(),d(null)))}createServer(t){throw new Error("node.js-only method")}pause(){this.destroyed||(this._debug("pause"),this.paused=!0)}resume(){this.destroyed||(this._debug("resume"),this.paused=!1,this._drain())}_debug(){const n=[].slice.call(arguments);n[0]=`[${this.client._debugId}] [${this._debugId}] ${n[0]}`,t(...n)}_drain(){if(this._debug("_drain numConns %s maxConns %s",this._numConns,this.client.maxConns),"function"!=typeof oe.connect||this.destroyed||this.paused||this._numConns>=this.client.maxConns)return;this._debug("drain (%s queued, %s/%s peers)",this._numQueued,this.numPeers,this.client.maxConns);const o=this._queue.shift();if(o){this._debug("tcp connect attempt to %s",o.addr);const e=mr(o.addr),t={host:e[0],port:e[1]},n=o.conn=oe.connect(t);n.once("connect",()=>{o.onConnect()}),n.once("error",e=>{o.destroy(e)}),o.startConnectTimeout(),n.on("close",()=>{if(!this.destroyed){if(o.retries>=r.length)return void this._debug("conn %s closed: will not re-add (max %s attempts)",o.addr,r.length);const e=r[o.retries];this._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",o.addr,e,o.retries+1);const t=setTimeout(()=>{const e=this._addPeer(o.addr);e&&(e.retries=o.retries+1)},e);t.unref&&t.unref()}})}}_validAddr(o){let e;try{e=mr(o)}catch(e){return!1}const d=e[0],n=e[1];return 0<n&&65535>n&&("127.0.0.1"!==d||n!==this.client.torrentPort)}}}).call(this,pe,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global);var ra={};return function(d,e,t){const{EventEmitter:n}=m,r=jo("webtorrent"),l="0.107.0".replace(/\d*./g,t=>`0${t%100}`.slice(-2)).slice(0,4);class o extends n{constructor(n={}){super(),this.peerId="string"==typeof n.peerId?n.peerId:t.isBuffer(n.peerId)?n.peerId.toString("hex"):t.from(`-WW${l}-`+ur(9).toString("base64")).toString("hex"),this.peerIdBuffer=t.from(this.peerId,"hex"),this.nodeId="string"==typeof n.nodeId?n.nodeId:t.isBuffer(n.nodeId)?n.nodeId.toString("hex"):ur(20).toString("hex"),this.nodeIdBuffer=t.from(this.nodeId,"hex"),this._debugId=this.peerId.toString("hex").substring(0,7),this.destroyed=!1,this.listening=!1,this.torrentPort=n.torrentPort||0,this.dhtPort=n.dhtPort||0,this.tracker=void 0===n.tracker?{}:n.tracker,this.torrents=[],this.maxConns=+n.maxConns||55,this._debug("new webtorrent (peerId %s, nodeId %s, port %s)",this.peerId,this.nodeId,this.torrentPort),this.tracker&&("object"!=typeof this.tracker&&(this.tracker={}),n.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),this.tracker.rtcConfig=n.rtcConfig),n.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),this.tracker.wrtc=n.wrtc),e.WRTC&&!this.tracker.wrtc&&(this.tracker.wrtc=e.WRTC)),d.nextTick(()=>{this._onListening()}),this._downloadSpeed=gr(),this._uploadSpeed=gr(),!1!==n.dht&&!1?(this.dht=new oe(Object.assign({},{nodeId:this.nodeId},n.dht)),this.dht.once("error",t=>{this._destroy(t)}),this.dht.once("listening",()=>{const t=this.dht.address();t&&(this.dhtPort=t.port)}),this.dht.setMaxListeners(0),this.dht.listen(this.dhtPort)):this.dht=!1,this.enableWebSeeds=!1!==n.webSeeds;const r=()=>{this.destroyed||(this.ready=!0,this.emit("ready"))};d.nextTick(r)}get downloadSpeed(){return this._downloadSpeed()}get uploadSpeed(){return this._uploadSpeed()}get progress(){const t=this.torrents.filter(t=>1!==t.progress);return t.reduce((n,e)=>n+e.downloaded,0)/(t.reduce((n,e)=>n+(e.length||0),0)||1)}get ratio(){return this.torrents.reduce((n,e)=>n+e.uploaded,0)/(this.torrents.reduce((n,e)=>n+e.received,0)||1)}get(t){if(!(t instanceof na)){let n;try{n=Zo(t)}catch(e){}if(!n)return null;if(!n.infoHash)throw new Error("Invalid torrent identifier");for(const t of this.torrents)if(t.infoHash===n.infoHash)return t}else if(this.torrents.includes(t))return t;return null}download(r,e,t){return console.warn("WebTorrent: client.download() is deprecated. Use client.add() instead"),this.add(r,e,t)}add(o,e={},d){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof e&&([e,d]=[{},e]);const a=()=>{if(!this.destroyed)for(const t of this.torrents)if(t.infoHash===i.infoHash&&t!==i)return void i._destroy(new Error(`Cannot add duplicate torrent ${i.infoHash}`))},r=()=>{this.destroyed||("function"==typeof d&&d(i),this.emit("torrent",i))};this._debug("add"),e=e?Object.assign({},e):{};const i=new na(o,this,e);return this.torrents.push(i),i.once("_infoHash",a),i.once("ready",r),i.once("close",function t(){i.removeListener("_infoHash",a),i.removeListener("ready",r),i.removeListener("close",t)}),i}seed(o,d,c){if(this.destroyed)throw new Error("client is destroyed");"function"==typeof d&&([d,c]=[{},d]),this._debug("seed"),(d=d?Object.assign({},d):{}).skipVerify=!0;const u="string"==typeof o;u&&(d.path=pt.dirname(o)),d.createdBy||(d.createdBy=`WebTorrent/${l}`);const r=t=>{this._debug("on seed"),"function"==typeof c&&c(t),t.emit("seed"),this.emit("seed",t)},i=this.add(null,d,n=>{const e=[e=>u?e():void n.load(s,e)];this.dht&&e.push(e=>{n.once("dhtAnnounce",e)}),Oo(e,e=>{if(!this.destroyed)return e?n._destroy(e):void r(n)})});let s;return"undefined"!=typeof FileList&&o instanceof FileList?o=Array.from(o):Array.isArray(o)||(o=[o]),Oo(o.map(n=>e=>{(function(){return"object"==typeof n&&null!=n&&"function"==typeof n.pipe})()?q(n,e):e(null,n)}),(t,o)=>{if(!this.destroyed)return t?i._destroy(t):void Wo.parseInput(o,d,(t,e)=>{if(!this.destroyed){if(t)return i._destroy(t);s=e.map(t=>t.getStream),Wo(o,d,(r,e)=>{if(!this.destroyed){if(r)return i._destroy(r);const t=this.get(e);t?i._destroy(new Error(`Cannot add duplicate torrent ${t.infoHash}`)):i._onTorrentId(e)}})}})}),i}remove(n,e){if(this._debug("remove"),!this.get(n))throw new Error(`No torrent with id ${n}`);this._remove(n,e)}_remove(r,e){const t=this.get(r);t&&(this.torrents.splice(this.torrents.indexOf(t),1),t.destroy(e))}address(){return this.listening?this._tcpPool?this._tcpPool.server.address():{address:"0.0.0.0",family:"IPv4",port:0}:null}destroy(t){if(this.destroyed)throw new Error("client already destroyed");this._destroy(null,t)}_destroy(r,e){this._debug("client destroy"),this.destroyed=!0;const t=this.torrents.map(n=>e=>{n.destroy(e)});this._tcpPool&&t.push(t=>{this._tcpPool.destroy(t)}),this.dht&&t.push(t=>{this.dht.destroy(t)}),Oo(t,e),r&&this.emit("error",r),this.torrents=[],this._tcpPool=null,this.dht=null}_onListening(){if(this._debug("listening"),this.listening=!0,this._tcpPool){const t=this._tcpPool.server.address();t&&(this.torrentPort=t.port)}this.emit("listening")}_debug(){const t=[].slice.call(arguments);t[0]=`[${this._debugId}] ${t[0]}`,r(...t)}}o.WEBRTC_SUPPORT=td.WEBRTC_SUPPORT,o.VERSION="0.107.0",ra=o}.call(this,pe,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,p({}).Buffer),ra}); \ No newline at end of file