!function(e){if("object"==typeofexports&&"undefined"!=typeofmodule)module.exports=e();elseif("function"==typeofdefine&&define.amd)define([],e);else{vart;t="undefined"!=typeofwindow?window:"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:this,t.CacheP2P=e()}}(function(){vare;returnfunctiont(e,n,r){functiono(s,a){if(!n[s]){if(!e[s]){varu="function"==typeofrequire&&require;if(!a&&u)returnu(s,!0);if(i)returni(s,!0);varc=newError("Cannot find module '"+s+"'");throwc.code="MODULE_NOT_FOUND",c}varf=n[s]={exports:{}};e[s][0].call(f.exports,function(t){varn=e[s][1][t];returno(n?n:t)},f,f.exports,t,e,n,r)}returnn[s].exports}for(vari="function"==typeofrequire&&require,s=0;s<r.length;s++)o(r[s]);returno}({1:[function(){},{}],2:[function(e,t,n){"use strict";functionr(e){vart=e.length;if(t%4>0)thrownewError("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}functiono(e){return3*e.length/4-r(e)}functioni(e){vart,n,o,i,s,a,u=e.length;s=r(e),a=newd(3*u/4-s),o=s>0?u-4:u;varc=0;for(t=0,n=0;o>t;t+=4,n+=3)i=f[e.charCodeAt(t)]<<18|f[e.charCodeAt(t+1)]<<12|f[e.charCodeAt(t+2)]<<6|f[e.charCodeAt(t+3)],a[c++]=i>>16&255,a[c++]=i>>8&255,a[c++]=255&i;return2===s?(i=f[e.charCodeAt(t)]<<2|f[e.charCodeAt(t+1)]>>4,a[c++]=255&i):1===s&&(i=f[e.charCodeAt(t)]<<10|f[e.charCodeAt(t+1)]<<4|f[e.charCodeAt(t+2)]>>2,a[c++]=i>>8&255,a[c++]=255&i),a}functions(e){returnc[e>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}functiona(e,t,n){for(varr,o=[],i=t;n>i;i+=3)r=(e[i]<<16)+(e[i+1]<<8)+e[i+2],o.push(s(r));returno.join("")}functionu(e){for(vart,n=e.length,r=n%3,o="",i=[],s=16383,u=0,f=n-r;f>u;u+=s)i.push(a(e,u,u+s>f?f:u+s));return1===r?(t=e[n-1],o+=c[t>>2],o+=c[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=c[t>>10],o+=c[t>>4&63],o+=c[t<<2&63],o+="="),i.push(o),i.join("")}n.byteLength=o,n.toByteArray=i,n.fromByteArray=u;for(varc=[],f=[],d="undefined"!=typeofUint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,p=h.length;p>l;++l)c[l]=h[l],f[h.charCodeAt(l)]=l;f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63},{}],3:[function(e,t,n){arguments[4][1][0].apply(n,arguments)},{dup:1}],4:[function(e,t,n){(function(t){"use strict";varr=e("buffer"),o=r.Buffer,i=r.SlowBuffer,s=r.kMaxLength||2147483647;n.alloc=function(e,t,n){if("function"==typeofo.alloc)returno.alloc(e,t,n);if("number"==typeofn)thrownewTypeError("encoding must not be number");if("number"!=typeofe)thrownewTypeError("size must be a number");if(e>s)thrownewRangeError("size is too large");varr=n,i=t;void0===i&&(r=void0,i=0);vara=newo(e);if("string"==typeofi)for(varu=newo(i,r),c=u.length,f=-1;++f<e;)a[f]=u[f%c];elsea.fill(i);returna},n.allocUnsafe=function(e){if("function"==typeofo.allocUnsafe)returno.allocUnsafe(e);if("number"!=typeofe)thrownewTypeError("size must be a number");if(e>s)thrownewRangeError("size is too large");returnnewo(e)},n.from=function(e,n,r){if("function"==typeofo.from&&(!t.Uint8Array||Uint8Array.from!==o.from))returno.from(e,n,r);if("number"==typeofe)thrownewTypeError('"value" argument must not be a number');if("string"==typeofe)returnnewo(e,n);if("undefined"!=typeofArrayBuffer&&einstanceofArrayBuffer){vari=n;if(1===arguments.length)returnnewo(e);"undefined"==typeofi&&(i=0);vars=r;if("undefined"==typeofs&&(s=e.byteLength-i),i>=e.byteLength)thrownewRangeError("'offset' is out of bounds");if(s>e.byteLength-i)thrownewRangeError("'length' is out of bounds");returnnewo(e.slice(i,i+s))}if(o.isBuffer(e)){vara=newo(e.length);returne.copy(a,0,0,e.length),a}if(e){if(Array.isArray(e)||"undefined"!=typeofArrayBuffer&&e.bufferinstanceofArrayBuffer||"length"ine)returnnewo(e);if("Buffer"===e.type&&Array.isArray(e.data))returnnewo(e.data)}thrownewTypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},n.allocUnsafeSlow=function(e){if("function"==typeofo.allocUnsafeSlow)returno.allocUnsafeSlow(e);if("number"!=typeofe)thrownewTypeError("size must be a number");if
}t.exports=function(e){returnnull!=e&&(n(e)||r(e)||!!e._isBuffer)}},{}],13:[function(e,t){varn={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],14:[function(e,t,n){(function(e){functiont(e,t){for(varn=0,r=e.length-1;r>=0;r--){varo=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("..");returne}functionr(e,t){if(e.filter)returne.filter(t);for(varn=[],r=0;r<e.length;r++)t(e[r],r,e)&&n.push(e[r]);returnn}varo=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i=function(e){returno.exec(e).slice(1)};n.resolve=function(){for(varn="",o=!1,i=arguments.length-1;i>=-1&&!o;i--){vars=i>=0?arguments[i]:e.cwd();if("string"!=typeofs)thrownewTypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,o="/"===s.charAt(0))}returnn=t(r(n.split("/"),function(e){return!!e}),!o).join("/"),(o?"/":"")+n||"."},n.normalize=function(e){varo=n.isAbsolute(e),i="/"===s(e,-1);returne=t(r(e.split("/"),function(e){return!!e}),!o).join("/"),e||o||(e="."),e&&i&&(e+="/"),(o?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){vare=Array.prototype.slice.call(arguments,0);returnn.normalize(r(e,function(e){if("string"!=typeofe)thrownewTypeError("Arguments to path.join must be strings");returne}).join("/"))},n.relative=function(e,t){functionr(e){for(vart=0;t<e.length&&""===e[t];t++);for(varn=e.length-1;n>=0&&""===e[n];n--);returnt>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(varo=r(e.split("/")),i=r(t.split("/")),s=Math.min(o.length,i.length),a=s,u=0;s>u;u++)if(o[u]!==i[u]){a=u;break}for(varc=[],u=a;u<o.length;u++)c.push("..");returnc=c.concat(i.slice(a)),c.join("/")},n.sep="/",n.delimiter=":",n.dirname=function(e){vart=i(e),n=t[0],r=t[1];returnn||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},n.basename=function(e,t){varn=i(e)[2];returnt&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},n.extname=function(e){returni(e)[3]};vars="b"==="ab".substr(-1)?function(e,t,n){returne.substr(t,n)}:function(e,t,n){return0>t&&(t=e.length+t),e.substr(t,n)}}).call(this,e("_process"))},{_process:16}],15:[function(e,t){(function(e){"use strict";functionn(t,n,r,o){if("function"!=typeoft)thrownewTypeError('"callback" argument must be a function');vari,s,a=arguments.length;switch(a){case0:case1:returne.nextTick(t);case2:returne.nextTick(function(){t.call(null,n)});case3:returne.nextTick(function(){t.call(null,n,r)});case4:returne.nextTick(function(){t.call(null,n,r,o)});default:for(i=newArray(a-1),s=0;s<i.length;)i[s++]=arguments[s];returne.nextTick(function(){t.apply(null,i)})}}t.exports=!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?n:e.nextTick}).call(this,e("_process"))},{_process:16}],16:[function(e,t){functionn(){thrownewError("setTimeout has not been defined")}functionr(){thrownewError("clearTimeout has not been defined")}functiono(e){if(f===setTimeout)returnsetTimeout(e,0);if((f===n||!f)&&setTimeout)returnf=setTimeout,setTimeout(e,0);try{returnf(e,0)}catch(t){try{returnf.call(null,e,0)}catch(t){returnf.call(this,e,0)}}}functioni(e){if(d===clearTimeout)returnclearTimeout(e);if((d===r||!d)&&clearTimeout)returnd=clearTimeout,clearTimeout(e);try{returnd(e)}catch(t){try{returnd.call(null,e)}catch(t){returnd.call(this,e)}}}functions(){m&&l&&(m=!1,l.length?p=l.concat(p):g=-1,p.length&&a())}functiona(){if(!m){vare=o(s);m=!0;for(vart=p.length;t;){for(l=p,p=[];++g<t;)l&&l[g].run();g=-1,t=p.length}l=null,m=!1,i(e)}}functionu(e,t){this.fun=e,this.array=t}functionc(){}varf,d,h=t.exports={};!function(){try{f="function"==typeofsetTimeout?setTimeout:n}catch(e){f=n}try{d="function"==typeofclearTimeout?clearTimeout:r}catch(e){d=r}}();varl,p=[],m=!1,g=-1;h.nextTick=function(e){vart=newArray(arguments.length-1);if(arguments.length>1)for(varn=1;n<arguments.length;n++)t[n-1]=arguments[n];p.push(newu(e,t)),1!==p.length||m||o(a)},u.prototype.run=function(){this.fun.appl
Object.keys(e.headers).forEach(function(n){t.setHeader(n,e.headers[n])});varn,r=!0;if("disable-fetch"===e.mode)r=!1,n=!0;elseif("prefer-streaming"===e.mode)n=!1;elseif("allow-wrong-content-type"===e.mode)n=!a.overrideMimeType;else{if(e.mode&&"default"!==e.mode&&"prefer-fast"!==e.mode)thrownewError("Invalid value for opts.mode");n=!0}t._mode=i(n,r),t.on("finish",function(){t._onFinish()})};u(p,f.Writable),p.prototype.setHeader=function(e,t){varn=this,r=e.toLowerCase();-1===m.indexOf(r)&&(n._headers[r]={name:e,value:t})},p.prototype.getHeader=function(e){vart=this;returnt._headers[e.toLowerCase()].value},p.prototype.removeHeader=function(e){vart=this;deletet._headers[e.toLowerCase()]},p.prototype._onFinish=function(){vare=this;if(!e._destroyed){vart,i=e._opts,s=e._headers;if(("POST"===i.method||"PUT"===i.method||"PATCH"===i.method)&&(t=a.blobConstructor?newr.Blob(e._body.map(function(e){returnd(e)}),{type:(s["content-type"]||{}).value||""}):o.concat(e._body).toString()),"fetch"===e._mode){varu=Object.keys(s).map(function(e){return[s[e].name,s[e].value]});r.fetch(e._opts.url,{method:e._opts.method,headers:u,body:t,mode:"cors",credentials:i.withCredentials?"include":"same-origin"}).then(function(t){e._fetchResponse=t,e._connect()},function(t){e.emit("error",t)})}else{varc=e._xhr=newr.XMLHttpRequest;try{c.open(e._opts.method,e._opts.url,!0)}catch(f){returnvoidn.nextTick(function(){e.emit("error",f)})}"responseType"inc&&(c.responseType=e._mode.split(":")[0]),"withCredentials"inc&&(c.withCredentials=!!i.withCredentials),"text"===e._mode&&"overrideMimeType"inc&&c.overrideMimeType("text/plain; charset=x-user-defined"),Object.keys(s).forEach(function(e){c.setRequestHeader(s[e].name,s[e].value)}),e._response=null,c.onreadystatechange=function(){switch(c.readyState){casel.LOADING:casel.DONE:e._onXHRProgress()}},"moz-chunked-arraybuffer"===e._mode&&(c.onprogress=function(){e._onXHRProgress()}),c.onerror=function(){e._destroyed||e.emit("error",newError("XHR error"))};try{c.send(t)}catch(f){returnvoidn.nextTick(function(){e.emit("error",f)})}}}},p.prototype._onXHRProgress=function(){vare=this;s(e._xhr)&&!e._destroyed&&(e._response||e._connect(),e._response._onXHRProgress())},p.prototype._connect=function(){vare=this;e._destroyed||(e._response=newh(e._xhr,e._fetchResponse,e._mode),e.emit("response",e._response))},p.prototype._write=function(e,t,n){varr=this;r._body.push(e),n()},p.prototype.abort=p.prototype.destroy=function(){vare=this;e._destroyed=!0,e._response&&(e._response._destroyed=!0),e._xhr&&e._xhr.abort()},p.prototype.end=function(e,t,n){varr=this;"function"==typeofe&&(n=e,e=void0),f.Writable.prototype.end.call(r,e,t,n)},p.prototype.flushHeaders=function(){},p.prototype.setTimeout=function(){},p.prototype.setNoDelay=function(){},p.prototype.setSocketKeepAlive=function(){};varm=["accept-charset","accept-encoding","access-control-request-headers","access-control-request-method","connection","content-length","cookie","cookie2","date","dnt","expect","host","keep-alive","origin","referer","te","trailer","transfer-encoding","upgrade","user-agent","via"]}).call(this,e("_process"),"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:"undefined"!=typeofwindow?window:{},e("buffer").Buffer)},{"./capability":29,"./response":31,_process:16,buffer:5,inherits:11,"readable-stream":27,"to-arraybuffer":33}],31:[function(e,t,n){(function(t,r,o){vari=e("./capability"),s=e("inherits"),a=e("readable-stream"),u=n.readyStates={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c=n.IncomingMessage=function(e,n,r){functions(){h.read().then(function(e){if(!u._destroyed){if(e.done)returnvoidu.push(null);u.push(newo(e.value)),s()}})}varu=this;if(a.Readable.call(u),u._mode=r,u.headers={},u.rawHeaders=[],u.trailers={},u.rawTrailers=[],u.on("end",function(){t.nextTick(function(){u.emit("close")})}),"fetch"===r){u._fetchResponse=n,u.url=n.url,u.statusCode=n.status,u.statusMessage=n.statusText;for(varc,f,d=n.headers[Symbol.iterator]();c=(f=d.next()).value,!f.done;)u.headers[c[0].toLowerCase()]=c[1],u.r
voide.end()):(t=t.slice(n),e._onHandshake(t.slice(8,28),t.slice(28,48),{dht:!!(1&t[7]),extended:!!(16&t[5])}),voide._parse(4,e._onMessageLength))})})},r.prototype._onFinish=function(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,function(){}),this.peerRequests=[];this.requests.length;)this._callback(this.requests.shift(),newError("wire was closed"),null)},r.prototype._debug=function(){vare=[].slice.call(arguments);e[0]="["+this._debugId+"] "+e[0],u.apply(null,e)}},{bencode:41,bitfield:43,debug:56,inherits:65,randombytes:90,"readable-stream":98,"safe-buffer":104,speedometer:110,xtend:137}],45:[function(e,t){(function(n){functionr(e){functiont(e){n.nextTick(function(){a.emit("warning",e)})}vara=this;if(!(ainstanceofr))returnnewr(e);if(s.call(a),e||(e={}),!e.peerId)thrownewError("Option `peerId` is required");if(!e.infoHash)thrownewError("Option `infoHash` is required");if(!e.announce)thrownewError("Option `announce` is required");if(!n.browser&&!e.port)thrownewError("Option `port` is required");a.peerId="string"==typeofe.peerId?e.peerId:e.peerId.toString("hex"),a._peerIdBuffer=o.from(a.peerId,"hex"),a._peerIdBinary=a._peerIdBuffer.toString("binary"),a.infoHash="string"==typeofe.infoHash?e.infoHash:e.infoHash.toString("hex"),a._infoHashBuffer=o.from(a.infoHash,"hex"),a._infoHashBinary=a._infoHashBuffer.toString("binary"),a._port=e.port,a.destroyed=!1,a._rtcConfig=e.rtcConfig,a._getAnnounceOpts=e.getAnnounceOpts,a._wrtc=e.wrtc,"function"==typeofa._wrtc&&(a._wrtc=a._wrtc()),i("new client %s",a.infoHash);varu=a._wrtc!==!1&&(!!a._wrtc||d.WEBRTC_SUPPORT),c="string"==typeofe.announce?[e.announce]:null==e.announce?[]:e.announce;c=c.map(function(e){returne=e.toString(),"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),e}),c=h(c),a._trackers=c.map(function(e){varn=l.parse(e).protocol;return"http:"!==n&&"https:"!==n||"function"!=typeofm?"udp:"===n&&"function"==typeofg?newg(a,e):"ws:"!==n&&"wss:"!==n||!u?(t(newError("Unsupported tracker protocol: "+e)),null):"ws:"===n&&"undefined"!=typeofwindow&&"https:"===window.location.protocol?(t(newError("Unsupported tracker protocol: "+e)),null):newy(a,e):newm(a,e)}).filter(Boolean)}t.exports=r;varo=e("safe-buffer").Buffer,i=e("debug")("bittorrent-tracker"),s=e("events").EventEmitter,a=e("xtend"),u=e("inherits"),c=e("once"),f=e("run-parallel"),d=e("simple-peer"),h=e("uniq"),l=e("url"),p=e("./lib/common"),m=e("./lib/client/http-tracker"),g=e("./lib/client/udp-tracker"),y=e("./lib/client/websocket-tracker");u(r,s),r.scrape=function(e,t){if(t=c(t),!e.infoHash)thrownewError("Option `infoHash` is required");if(!e.announce)thrownewError("Option `announce` is required");varn=a(e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:o.from("01234567890123456789"),port:6881}),i=newr(n);i.once("error",t),i.once("warning",t);vars=Array.isArray(e.infoHash)?e.infoHash.length:1,u={};returni.on("scrape",function(e){if(s-=1,u[e.infoHash]=e,0===s){i.destroy();varn=Object.keys(u);1===n.length?t(null,u[n[0]]):t(null,u)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(function(e){returno.from(e,"hex")}):o.from(e.infoHash,"hex"),i.scrape({infoHash:e.infoHash}),i},r.prototype.start=function(e){vart=this;i("send `start`"),e=t._defaultAnnounceOpts(e),e.event="started",t._announce(e),t._trackers.forEach(function(e){e.setInterval()})},r.prototype.stop=function(e){vart=this;i("send `stop`"),e=t._defaultAnnounceOpts(e),e.event="stopped",t._announce(e)},r.prototype.complete=function(e){vart=this;i("send `complete`"),e||(e={}),e=t._defaultAnnounceOpts(e),e.event="completed",t._announce(e)},r.prototype.update=function(e){vart=this;i("send `update`"),e=t._defaultAnnounceOpts(e),e.event&&deletee.event,t._announce(e)},r.prototype._announce=function(e){vart=this;t._trackers.forEach(function(t){t.announce(e)})},r.prototype.scrape=function(e){vart=this;i("send `scrape`"),e||(e={}),t._trackers.forEach(function(t){t.scrape(e)})},r.prototype.setInterval=function(e){vart=this;i("setIn
t.exports.encode=o;vari=e("thirty-two"),s=e("xtend"),a=e("uniq")}).call(this,e("buffer").Buffer)},{buffer:5,"thirty-two":115,uniq:122,xtend:137}],72:[function(e,t){functionn(e,t){varr=this;if(!(rinstanceofn))returnnewn(e,t);if(!a)thrownewError("web browser lacks MediaSource support");t||(t={}),r._bufferDuration=t.bufferDuration||u,r._elem=e,r._mediaSource=newa,r._streams=[],r.detailedError=null,r._errorHandler=function(){r._elem.removeEventListener("error",r._errorHandler);vare=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)}functionr(e,t){varn=this;if(i.Writable.call(n),n._wrapper=e,n._elem=e._elem,n._mediaSource=e._mediaSource,n._allStreams=e._streams,n._allStreams.push(n),n._bufferDuration=e._bufferDuration,n._sourceBuffer=null,n._openHandler=function(){n._onSourceOpen()},n._flowHandler=function(){n._flow()},"string"==typeoft)n._type=t,"open"===n._mediaSource.readyState?n._createSourceBuffer():n._mediaSource.addEventListener("sourceopen",n._openHandler);elseif(null===t._sourceBuffer)t.destroy(),n._type=t._type,n._mediaSource.addEventListener("sourceopen",n._openHandler);else{if(!t._sourceBuffer)thrownewError("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");t.destroy(),n._type=t._type,n._sourceBuffer=t._sourceBuffer,n._sourceBuffer.addEventListener("updateend",n._flowHandler)}n._elem.addEventListener("timeupdate",n._flowHandler),n.on("error",function(e){n._wrapper.error(e)}),n.on("finish",function(){if(!n.destroyed&&(n._finished=!0,n._allStreams.every(function(e){returne._finished})))try{n._mediaSource.endOfStream()}catch(e){}})}t.exports=n;varo=e("inherits"),i=e("readable-stream"),s=e("to-arraybuffer"),a="undefined"!=typeofwindow&&window.MediaSource,u=60;n.prototype.createWriteStream=function(e){vart=this;returnnewr(t,e)},n.prototype.error=function(e){vart=this;t.detailedError||(t.detailedError=e);try{t._mediaSource.endOfStream("decode")}catch(e){}},o(r,i.Writable),r.prototype._onSourceOpen=function(){vare=this;e.destroyed||(e._mediaSource.removeEventListener("sourceopen",e._openHandler),e._createSourceBuffer())},r.prototype.destroy=function(e){vart=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),"open"===t._mediaSource.readyState&&t._sourceBuffer.abort()),e&&t.emit("error",e),t.emit("close"))},r.prototype._createSourceBuffer=function(){vare=this;if(!e.destroyed)if(a.isTypeSupported(e._type)){if(e._sourceBuffer=e._mediaSource.addSourceBuffer(e._type),e._sourceBuffer.addEventListener("updateend",e._flowHandler),e._cb){vart=e._cb;e._cb=null,t()}}elsee.destroy(newError("The provided type is not supported"))},r.prototype._write=function(e,t,n){varr=this;if(!r.destroyed){if(!r._sourceBuffer)returnvoid(r._cb=function(o){returno?n(o):voidr._write(e,t,n)});if(r._sourceBuffer.updating)returnn(newError("Cannot append buffer while source buffer updating"));try{r._sourceBuffer.appendBuffer(s(e))}catch(o){returnvoidr.destroy(o)}r._cb=n}},r.prototype._flow=function(){vare=this;if(!e.destroyed&&e._sourceBuffer&&!e._sourceBuffer.updating&&!("open"===e._mediaSource.readyState&&e._getBufferDuration()>e._bufferDuration)&&e._cb){vart=e._cb;e._cb=null,t()}};varc=0;r.prototype._getBufferDuration=function(){for(vare=this,t=e._sourceBuffer.buffered,n=e._elem.currentTime,r=-1,o=0;o<t.length;o++){vari=t.start(o),s=t.end(o)+c;if(i>n)break;(r>=0||s>=n)&&(r=s)}vara=r-n;return0>a&&(a=0),a}},{inherits:65,"readable-stream":98,"to-arraybuffer":117}],73:[function(e,t){(function(e){functionn(e,t){if(!(thisinstanceofn))returnnewn(e,t);if(t||(t={}),this.chunkLength=Number(e),!this.chunkLength)thrownewError("First argument must be a chunk length");this.chunks=[],this.closed
o._forward(),e.on("readable",t),e.once("end",r),voide.once("close",n)):(o.push(null),voido.destroy())},n.prototype._attachErrorListener=function(e){functiont(r){e.removeListener("error",t),n.destroy(r)}varn=this;e&&e.once("error",t)}},{inherits:65,"readable-stream":98}],82:[function(e,t){functionn(e,t){varn=null;returne.on(t,function(e){if(n){vart=n;n=null,t(e)}}),function(e){n=e}}t.exports=n},{}],83:[function(e,t){functionn(e){vart=function(){returnt.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};returnt.called=!1,t}functionr(e){vart=function(){if(t.called)thrownewError(t.onceError);returnt.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";returnt.onceError=n+" shouldn't be called more than once",t.called=!1,t}varo=e("wrappy");t.exports=o(n),t.exports.strict=o(r),n.proto=n(function(){Object.defineProperty(Function.prototype,"once",{value:function(){returnn(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){returnr(this)},configurable:!0})})},{wrappy:136}],84:[function(e,t){(function(n){functionr(e){n.isBuffer(e)&&(e=u.decode(e)),a(e.info,"info"),a(e.info["name.utf-8"]||e.info.name,"info.name"),a(e.info["piece length"],"info['piece length']"),a(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(function(e){a("number"==typeofe.length,"info.files[0].length"),a(e["path.utf-8"]||e.path,"info.files[0].path")}):a("number"==typeofe.info.length,"info.length");vart={};t.info=e.info,t.infoBuffer=u.encode(e.info),t.infoHash=f.sync(t.infoBuffer),t.infoHashBuffer=newn(t.infoHash,"hex"),t.name=(e.info["name.utf-8"]||e.info.name).toString(),void0!==e.info["private"]&&(t["private"]=!!e.info["private"]),e["creation date"]&&(t.created=newDate(1e3*e["creation date"])),e["created by"]&&(t.createdBy=e["created by"].toString()),n.isBuffer(e.comment)&&(t.comment=e.comment.toString()),t.announce=[],e["announce-list"]&&e["announce-list"].length?e["announce-list"].forEach(function(e){e.forEach(function(e){t.announce.push(e.toString())})}):e.announce&&t.announce.push(e.announce.toString()),n.isBuffer(e["url-list"])&&(e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]),t.urlList=(e["url-list"]||[]).map(function(e){returne.toString()}),d(t.announce),d(t.urlList);varr=e.info.files||[e.info];t.files=r.map(function(e,n){varo=[].concat(t.name,e["path.utf-8"]||e.path||[]).map(function(e){returne.toString()});return{path:c.join.apply(null,[c.sep].concat(o)).slice(1),name:o[o.length-1],length:e.length,offset:r.slice(0,n).reduce(i,0)}}),t.length=r.reduce(i,0);varo=t.files[t.files.length-1];returnt.pieceLength=e.info["piece length"],t.lastPieceLength=(o.offset+o.length)%t.pieceLength||t.pieceLength,t.pieces=s(e.info.pieces),t}functiono(e){vart={info:e.info};returnt["announce-list"]=(e.announce||[]).map(function(e){returnt.announce||(t.announce=e),e=newn(e,"utf8"),[e]}),t["url-list"]=e.urlList||[],e.created&&(t["creation date"]=e.created.getTime()/1e3|0),e.createdBy&&(t["created by"]=e.createdBy),e.comment&&(t.comment=e.comment),u.encode(t)}functioni(e,t){returne+t.length}functions(e){for(vart=[],n=0;n<e.length;n+=20)t.push(e.slice(n,n+20).toString("hex"));returnt}functiona(e,t){if(!e)thrownewError("Torrent is missing required field: "+t)}t.exports=r,t.exports.decode=r,t.exports.encode=o;varu=e("bencode"),c=e("path"),f=e("simple-sha1"),d=e("uniq")}).call(this,e("buffer").Buffer)},{bencode:41,buffer:5,path:14,"simple-sha1":108,uniq:122}],85:[function(e,t){(function(n,r){functiono(e){if("string"==typeofe&&/^(stream-)?magnet:/.test(e))returnf(e);if("string"==typeofe&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e)))returnf("magnet:?xt=urn:btih:"+e);if(r.isBuffer(e)&&20===e.length)returnf("magnet:?xt=urn:btih:"+e.toString("hex"));if(r.isBuffer(e))returnd(e);if(e&&e.infoHash)returne.announce||(e.announce=[]),"string"==typeofe.announce&&(e.announce=[e.announce]),e.urlList||(e.urlList=[]),e;thrownewError("Invalid torrent identifier")}functioni(e,t){functionr(e){try{i=o(e)}catch(n){returnt
},e.reconnectTimer)):e._destroy()),"failed"===n&&e._destroy(),"closed"===n&&e._destroy()}},r.prototype.getStats=function(e){vart=this;t._pc.getStats?"undefined"!=typeofwindow&&window.mozRTCPeerConnection?t._pc.getStats(null,function(t){varn=[];t.forEach(function(e){n.push(e)}),e(n)},function(e){t._onError(e)}):t._pc.getStats(function(t){varn=[];t.result().forEach(function(e){vart={};e.names().forEach(function(n){t[n]=e.stat(n)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,n.push(t)}),e(n)}):e([])},r.prototype._maybeReady=function(){vare=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady),!e.connected&&!e._connecting&&e._pcReady&&e._channelReady&&(e._connecting=!0,e.getStats(function(t){functionn(t){varn=o[t.localCandidateId],i=r[t.remoteCandidateId];n?(e.localAddress=n.ipAddress,e.localPort=Number(n.portNumber)):"string"==typeoft.googLocalAddress&&(n=t.googLocalAddress.split(":"),e.localAddress=n[0],e.localPort=Number(n[1])),e._debug("connect local: %s:%s",e.localAddress,e.localPort),i?(e.remoteAddress=i.ipAddress,e.remotePort=Number(i.portNumber),e.remoteFamily="IPv4"):"string"==typeoft.googRemoteAddress&&(i=t.googRemoteAddress.split(":"),e.remoteAddress=i[0],e.remotePort=Number(i[1]),e.remoteFamily="IPv4"),e._debug("connect remote: %s:%s",e.remoteAddress,e.remotePort)}e._connecting=!1,e.connected=!0;varr={},o={};if(t.forEach(function(e){"remotecandidate"===e.type&&(r[e.id]=e),"localcandidate"===e.type&&(o[e.id]=e)}),t.forEach(function(e){vart="googCandidatePair"===e.type&&"true"===e.googActiveConnection||"candidatepair"===e.type&&e.selected;t&&n(e)}),e._chunk){try{e.send(e._chunk)}catch(i){returne._onError(i)}e._chunk=null,e._debug('sent chunk from "write before connect"');vars=e._cb;e._cb=null,s(null)}e._interval=setInterval(function(){if(e._cb&&e._channel&&!(e._channel.bufferedAmount>e._maxBufferedAmount)){e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);vart=e._cb;e._cb=null,t(null)}},150),e._interval.unref&&e._interval.unref(),e._debug("connect"),e.emit("connect")}))},r.prototype._onSignalingStateChange=function(){vare=this;e.destroyed||(e._debug("signalingStateChange %s",e._pc.signalingState),e.emit("signalingStateChange",e._pc.signalingState))},r.prototype._onIceCandidate=function(e){vart=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=!0,t.emit("_iceComplete")))},r.prototype._onChannelMessage=function(e){vart=this;if(!t.destroyed){varr=e.data;t._debug("read: %d bytes",r.byteLength||r.length),rinstanceofArrayBuffer&&(r=newn(r)),t.push(r)}},r.prototype._onChannelOpen=function(){vare=this;e.connected||e.destroyed||(e._debug("on channel open"),e._channelReady=!0,e._maybeReady())},r.prototype._onChannelClose=function(){vare=this;e.destroyed||(e._debug("on channel close"),e._destroy())},r.prototype._onAddStream=function(e){vart=this;t.destroyed||(t._debug("on add stream"),t.emit("stream",e.stream))},r.prototype._onTrack=function(e){vart=this;t.destroyed||(t._debug("on track"),t.emit("stream",e.streams[0]))},r.prototype._onError=function(e){vart=this;t.destroyed||(t._debug("error %s",e.message||e),t._destroy(e))},r.prototype._debug=function(){vare=this,t=[].slice.call(arguments),n=e.channelName&&e.channelName.substring(0,7);t[0]="["+n+"] "+t[0],i.apply(null,t)}}).call(this,e("buffer").Buffer)},{buffer:5,debug:56,"get-browser-rtc":63,inherits:65,randombytes:90,"readable-stream":98}],108:[function(e,t){functionn(e){returna.digest(e)}functionr(e,t){returnc?("string"==typeofe&&(e=o(e)),voidc.digest({name:"sha-1"},e).then(function(e){t(i(newUint8Array(e)))},function(){t(n(e))})):voidsetTimeout(t,0,n(e))}functiono(e){for(vart=e.length,n=newUint8Array(t),r=0;t>r;r++)n[r]=e.charCodeAt(r);returnn}functioni(e){for(vart=e.length,n=[],r=0;t>r;r++){varo=e[r];n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}returnn.join("")}vars=e("rusha"),a=news,u=window.crypto||window.msCrypto
if(!a.destroyed){if(e)returnh._destroy(e);varr=a.get(n);r?h._destroy(newError("Cannot add duplicate torrent "+r.infoHash)):h._onTorrentId(n,t.forced_id)}})}})}),h},o.prototype.remove=function(e,t){f("remove");varn=this.get(e);if(!n)thrownewError("No torrent with id "+e);this._remove(e,t)},o.prototype._remove=function(e,t){varn=this.get(e);n&&(this.torrents.splice(this.torrents.indexOf(n),1),n.destroy(t))},o.prototype.address=function(){returnthis.listening?this._tcpPool?this._tcpPool.server.address():{address:"0.0.0.0",family:"IPv4",port:0}:null},o.prototype.destroy=function(e){if(this.destroyed)thrownewError("client already destroyed");this._destroy(null,e)},o.prototype._destroy=function(e,t){varn=this;f("client destroy"),n.destroyed=!0;varr=n.torrents.map(function(e){returnfunction(t){e.destroy(t)}});n._tcpPool&&r.push(function(e){n._tcpPool.destroy(e)}),n.dht&&r.push(function(e){n.dht.destroy(e)}),g(r,t),e&&n.emit("error",e),n.torrents=[],n._tcpPool=null,n.dht=null},o.prototype._onListening=function(){if(this.listening=!0,this._tcpPool){vare=this._tcpPool.server.address();e&&(this.torrentPort=e.port)}this.emit("listening")}}).call(this,e("_process"),"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:"undefined"!=typeofwindow?window:{})},{"./lib/tcp-pool":3,"./lib/torrent":133,"./package.json":135,_process:16,"bittorrent-dht/client":3,"create-torrent":55,debug:56,events:8,inherits:65,"load-ip-set":3,"parse-torrent":85,path:14,randombytes:90,"run-parallel":102,"safe-buffer":104,"simple-concat":105,"simple-peer":107,speedometer:110,xtend:137,"zero-fill":139}],129:[function(e,t){functionn(e,t){i.Readable.call(this,t),this.destroyed=!1,this._torrent=e._torrent;varn=t&&t.start||0,r=t&&t.end&&t.end<e.length?t.end:e.length-1,o=e._torrent.pieceLength;this._startPiece=(n+e.offset)/o|0,this._endPiece=(r+e.offset)/o|0,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=Math.min(1048576/o|0,2)}t.exports=n;varr=e("debug")("webtorrent:file-stream"),o=e("inherits"),i=e("readable-stream");o(n,i.Readable),n.prototype._read=function(){this._reading||(this._reading=!0,this._notify())},n.prototype._notify=function(){vare=this;if(e._reading&&0!==e._missing){if(!e._torrent.bitfield.get(e._piece))returne._torrent.critical(e._piece,e._piece+e._criticalLength);if(!e._notifying){e._notifying=!0;vart=e._piece;e._torrent.store.get(t,function(n,o){if(e._notifying=!1,!e.destroyed){if(n)returne._destroy(n);r("read %s (length %s) (err %s)",t,o.length,n&&n.message),e._offset&&(o=o.slice(e._offset),e._offset=0),e._missing<o.length&&(o=o.slice(0,e._missing)),e._missing-=o.length,r("pushing buffer of length %s",o.length),e._reading=!1,e.push(o),0===e._missing&&e.push(null)}}),e._piece+=1}}},n.prototype.destroy=function(e){this._destroy(null,e)},n.prototype._destroy=function(e,t){this.destroyed||(this.destroyed=!0,this._torrent.destroyed||this._torrent.deselect(this._startPiece,this._endPiece,!0),e&&this.emit("error",e),this.emit("close"),t&&t())}},{debug:56,inherits:65,"readable-stream":98}],130:[function(e,t){(function(n){functionr(e,t){i.call(this),this._torrent=e,this._destroyed=!1,this.name=t.name,this.path=t.path,this.length=t.length,this.offset=t.offset,this.done=!1;varn=t.offset,r=n+t.length-1;this._startPiece=n/this._torrent.pieceLength|0,this._endPiece=r/this._torrent.pieceLength|0,0===this.length&&(this.done=!0,this.emit("done"))}t.exports=r;varo=e("end-of-stream"),i=e("events").EventEmitter,s=e("./file-stream"),a=e("inherits"),u=e("path"),c=e("render-media"),f=e("readable-stream"),d=e("stream-to-blob"),h=e("stream-to-blob-url"),l=e("stream-with-known-length-to-buffer");a(r,i),r.prototype.select=function(e){0!==this.length&&this._torrent.select(this._startPiece,this._endPiece,e)},r.prototype.deselect=function(){0!==this.length&&this._torrent.deselect(this._startPiece,this._endPiece,!1)},r.prototype.createReadStream=function(e){vart=this;if(0===this.length){varr=newf.PassThrough;returnn.nextTick(function(){r
n.bitfield.set(t,!0)}),n._checkDone(),voidt(null))})},o.prototype.createServer=function(e){if("function"!=typeofN)thrownewError("node.js-only method");if(this.destroyed)thrownewError("torrent is destroyed");vart=newN(this,e);returnthis._servers.push(t),t},o.prototype.pause=function(){this.destroyed||(this._debug("pause"),this.paused=!0)},o.prototype.resume=function(){this.destroyed||(this._debug("resume"),this.paused=!1,this._drain())},o.prototype._debug=function(){vare=[].slice.call(arguments);e[0]="["+this._debugId+"] "+e[0],l.apply(null,e)},o.prototype._drain=function(){vare=this;if(this._debug("_drain numConns %s maxConns %s",e._numConns,e.client.maxConns),!("function"!=typeofx.connect||e.destroyed||e.paused||e._numConns>=e.client.maxConns)){this._debug("drain (%s queued, %s/%s peers)",e._numQueued,e.numPeers,e.client.maxConns);vart=e._queue.shift();if(t){this._debug("tcp connect attempt to %s",t.addr);varn=f(t.addr),r={host:n[0],port:n[1]},o=t.conn=x.connect(r);o.once("connect",function(){t.onConnect()}),o.once("error",function(e){t.destroy(e)}),t.startConnectTimeout(),o.on("close",function(){if(!e.destroyed){if(t.retries>=J.length)returnvoide._debug("conn %s closed: will not re-add (max %s attempts)",t.addr,J.length);varn=J[t.retries];e._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,n,t.retries+1);varr=setTimeout(function(){varn=e._addPeer(t.addr);n&&(n.retries=t.retries+1)},n);r.unref&&r.unref()}})}}},o.prototype._validAddr=function(e){vart;try{t=f(e)}catch(n){return!1}varr=t[0],o=t[1];returno>0&&65535>o&&!("127.0.0.1"===r&&o===this.client.torrentPort)}}).call(this,e("_process"),"undefined"!=typeofglobal?global:"undefined"!=typeofself?self:"undefined"!=typeofwindow?window:{})},{"../package.json":135,"./file":130,"./peer":131,"./rarity-map":132,"./server":3,_process:16,"addr-to-ip-port":38,bitfield:43,"chunk-store-stream/write":52,debug:56,events:8,fs:1,"fs-chunk-store":73,"immediate-chunk-store":64,inherits:65,multistream:81,net:3,os:3,"parse-torrent":85,path:14,pump:88,"random-iterate":89,"run-parallel":102,"run-parallel-limit":101,"simple-get":106,"simple-sha1":108,speedometer:110,"torrent-discovery":118,"torrent-piece":119,uniq:122,ut_metadata:124,ut_pex:3,xtend:137,"xtend/mutable":138}],134:[function(e,t){functionn(e,t){c.call(this),this.url=e,this.webPeerId=u.sync(e),this._torrent=t,this._init()}t.exports=n;varr=e("bitfield"),o=e("safe-buffer").Buffer,i=e("debug")("webtorrent:webconn"),s=e("simple-get"),a=e("inherits"),u=e("simple-sha1"),c=e("bittorrent-protocol"),f=e("../package.json").version;a(n,c),n.prototype._init=function(){vare=this;e.setKeepAlive(!0),e.once("handshake",function(t){if(!e.destroyed){e.handshake(t,e.webPeerId);for(varn=e._torrent.pieces.length,o=newr(n),i=0;n>=i;i++)o.set(i,!0);e.bitfield(o)}}),e.once("interested",function(){i("interested"),e.unchoke()}),e.on("uninterested",function(){i("uninterested")}),e.on("choke",function(){i("choke")}),e.on("unchoke",function(){i("unchoke")}),e.on("bitfield",function(){i("bitfield")}),e.on("request",function(t,n,r,o){i("request pieceIndex=%d offset=%d length=%d",t,n,r),e.httpRequest(t,n,r,o)})},n.prototype.httpRequest=function(e,t,n,r){vara,u=this,c=e*u._torrent.pieceLength,d=c+t,h=d+n-1,l=u._torrent.files;if(l.length<=1)a=[{url:u.url,start:d,end:h}];else{varp=l.filter(function(e){returne.offset<=h&&e.offset+e.length>d});if(p.length<1)returnr(newError("Could not find file corresponnding to web seed range request"));a=p.map(function(e){vart=e.offset+e.length-1,n=u.url+("/"===u.url[u.url.length-1]?"":"/")+e.path;return{url:n,fileOffsetInRange:Math.max(e.offset-d,0),start:Math.max(d-e.offset,0),end:Math.min(t,h-e.offset)}})}varm,g=0,y=!1;a.length>1&&(m=o.alloc(n)),a.forEach(function(o){functionu(e,t){returne.statusCode<200||e.statusCode>=300?(y=!0,r(newError("Unexpected HTTP status code "+e.statusCode))):(i("Got data of length %d",t.length),void(1===a.length?r(null,t):(t.copy(m,o.fileOffsetInRange),++g===a.length&&r(null,m))))}varc=o.url,d=o.start,h=o.end;i("Requestingurl=%spieceInd