(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,e=String.fromCharCode,o=Math.ceil,s=Math.max,d=Math.min,i;return function(){function s(d,e,n){function t(o,i){if(!e[o]){if(!d[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:{}};d[o][0].call(a.exports,function(e){var r=d[o][1][e];return t(r||e)},a,a.exports,s,d,e,n)}return e[o].exports}for(var r="function"==typeof require&&require,o=0;oe||t2*(r._numConns-r.numPeers)&&e.amInterested?e.destroy():(o=setTimeout(t,z),o.unref&&o.unref()))}function n(){if(e.peerPieces.buffer.length===r.bitfield.buffer.length){for(s=0;s131072?e.destroy():void(r.pieces[t]||r.store.get(t,{offset:n,length:o},i))}),e.bitfield(r.bitfield),e.interested(),e.peerExtensions.dht&&r.client.dht&&r.client.dht.listening&&e.port(r.client.dht.address().port),"webSeed"!==e.type&&(o=setTimeout(t,z),o.unref&&o.unref()),e.isSeeder=!1,n()},i.prototype._updateSelections=function(){var e=this;!e.ready||e.destroyed||(n.nextTick(function(){e._gcSelections()}),e._updateInterest(),e._update())},i.prototype._gcSelections=function(){for(var e=this,t=0;t=t&&s<=n&&!(s in r)&&e.peerPieces.get(s)&&(!o||o(s))}}function n(){if(!e.requests.length)for(var n=d._selections.length;n--;){var r=d._selections[n],o;if("rarest"===d.strategy)for(var i=r.from+r.offset,s=r.to,a={},c=0,l=t(i,s,a);co));){if(d._request(e,o,!1))return;a[o]=!0,c+=1}else for(o=r.to;o>=r.from+r.offset;--o)if(e.peerPieces.get(o)&&d._request(e,o,!1))return}}function r(){var t=e.downloadSpeed()||1;if(t>V)return function(){return!0};var n=s(1,e.requests.length)*U.BLOCK_LENGTH/t,r=10,o=0;return function(e){if(!r||d.bitfield.get(e))return!0;for(var i=d.pieces[e].missing;o=l)return!0;for(var s=r(),a=0;ac));){for(;d._request(e,c,d._critical[c]||n););if(e.requests.length=c)){var l=a(e,G);i(!1)||i(!0)}}},i.prototype._rechoke=function(){function e(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}var t=this;if(t.ready){0=V||2*l>o||l>d||(a=i,d=l)}}if(!a)return!1;for(c=0;c=f)return!1;var h=l.pieces[t],m=u?h.reserveRemaining():h.reserve();if(-1===m&&o&&l._hotswap(e,t)&&(m=u?h.reserveRemaining():h.reserve()),-1===m)return!1;var g=l._reservations[t];g||(g=l._reservations[t]=[]);var r=g.indexOf(null);-1===r&&(r=g.length),g[r]=e;var i=h.chunkOffset(m),_=u?h.chunkLengthRemaining(m):h.chunkLength(m);return e.request(t,i,_,function n(o,d){if(!l.destroyed){if(!l.ready)return l.once("ready",function(){n(o,d)});if(g[r]===e&&(g[r]=null),h!==l.pieces[t])return s();if(o)return l._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,i,_,e.remoteAddress+":"+e.remotePort,o.message),u?h.cancelRemaining(m):h.cancel(m),void s();if(l._debug("got piece %s (offset: %s length: %s) from %s",t,i,_,e.remoteAddress+":"+e.remotePort),!h.set(m,d,e))return s();var a=h.flush();O(a,function(e){if(!l.destroyed){if(e===l._hashes[t]){if(!l.pieces[t])return;l._debug("piece verified %s",t),l.pieces[t]=null,l._reservations[t]=null,l.bitfield.set(t,!0),l.store.put(t,a),l.wires.forEach(function(e){e.have(t)}),l._checkDone()&&!l.destroyed&&l.discovery.complete()}else l.pieces[t]=new U(h.length),l.emit("warning",new Error("Piece "+t+" failed verification"));s()}})}}),!0},i.prototype._checkDone=function(){var e=this;if(!e.destroyed){e.files.forEach(function(t){if(!t.done){for(var n=t._startPiece;n<=t._endPiece;++n)if(!e.bitfield.get(n))return;t.done=!0,t.emit("done"),e._debug("file done: "+t.name)}});for(var t=!0,n=0,r;n=e.client.maxConns)){this._debug("drain (%s queued, %s/%s peers)",e._numQueued,e.numPeers,e.client.maxConns);var t=e._queue.shift();if(t){this._debug("tcp connect attempt to %s",t.addr);var n=u(t.addr),r={host:n[0],port:n[1]},o=t.conn=E.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>=X.length)return void e._debug("conn %s closed: will not re-add (max %s attempts)",t.addr,X.length);var n=X[t.retries];e._debug("conn %s closed: will re-add to queue in %sms (attempt %s)",t.addr,n,t.retries+1);var r=setTimeout(function(){var n=e._addPeer(t.addr);n&&(n.retries=t.retries+1)},n);r.unref&&r.unref()}})}}},i.prototype._validAddr=function(e){var t;try{t=u(e)}catch(t){return!1}var n=t[0],r=t[1];return 0r&&("127.0.0.1"!==n||r!==this.client.torrentPort)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{"../package.json":126,"./file":2,"./peer":3,"./rarity-map":4,"./server":21,_process:68,"addr-to-ip-port":7,bitfield:13,"chunk-store-stream/write":31,debug:35,events:24,fs:22,"fs-chunk-store":53,"immediate-chunk-store":43,inherits:44,multistream:61,net:21,os:21,"parse-torrent":64,path:65,pump:69,"random-iterate":74,"run-parallel":89,"run-parallel-limit":88,"simple-get":93,"simple-sha1":95,speedometer:97,"torrent-discovery":109,"torrent-piece":110,uniq:113,ut_metadata:117,ut_pex:21,xtend:123,"xtend/mutable":124}],6:[function(e,t){function n(e,t){p.call(this),this.url=e,this.webPeerId=l.sync(e),this._torrent=t,this._init()}t.exports=n;var r=e("bitfield"),o=e("safe-buffer").Buffer,i=e("debug")("webtorrent:webconn"),a=e("simple-get"),c=e("inherits"),l=e("simple-sha1"),p=e("bittorrent-protocol"),u=e("../package.json").version;c(n,p),n.prototype._init=function(){var e=this;e.setKeepAlive(!0),e.once("handshake",function(t){if(!e.destroyed){e.handshake(t,e.webPeerId);for(var n=e._torrent.pieces.length,o=new r(n),s=0;s<=n;s++)o.set(s,!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){var c=this,l=e*c._torrent.pieceLength,p=l+t,f=p+n-1,h=c._torrent.files,m;if(1>=h.length)m=[{url:c.url,start:p,end:f}];else{var g=h.filter(function(e){return e.offset<=f&&e.offset+e.length>p});if(1>g.length)return r(new Error("Could not find file corresponnding to web seed range request"));m=g.map(function(e){var t=e.offset+e.length-1,n=c.url+("/"===c.url[c.url.length-1]?"":"/")+e.path;return{url:n,fileOffsetInRange:s(e.offset-p,0),start:s(p-e.offset,0),end:d(t,f-e.offset)}})}var _=0,y=!1,b;1e.statusCode||300<=e.statusCode?(y=!0,r(new Error("Unexpected HTTP status code "+e.statusCode))):void(i("Got data of length %d",t.length),1===m.length?r(null,t):(t.copy(b,o.fileOffsetInRange),++_===m.length&&r(null,b)))}var d=o.url,c=o.start,l=o.end;i("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",d,e,t,n,c,l);var p={url:d,method:"GET",headers:{"user-agent":"WebTorrent/"+u+" (https://webtorrent.io)",range:"bytes="+c+"-"+l}};a.concat(p,function(e,t,n){return y?void 0:e?"undefined"==typeof window||d.startsWith(window.location.origin+"/")?(y=!0,r(e)):a.head(d,function(t,n){return y?void 0:t?(y=!0,r(t)):200>n.statusCode||300<=n.statusCode?(y=!0,r(new Error("Unexpected HTTP status code "+n.statusCode))):n.url===d?(y=!0,r(e)):void(p.url=n.url,a.concat(p,function(e,t,n){return y?void 0:e?(y=!0,r(e)):void s(t,n)}))}):void s(t,n)})})},n.prototype.destroy=function(){p.prototype.destroy.call(this),this._torrent=null}},{"../package.json":126,bitfield:13,"bittorrent-protocol":14,debug:35,inherits:44,"safe-buffer":91,"simple-get":93,"simple-sha1":95}],7:[function(e,t){var n=/^\[?([^\]]+)\]?:(\d+)$/,r={},o=0;t.exports=function(e){if(1e5==o&&t.exports.reset(),!r[e]){var i=n.exec(e);if(!i)throw new Error("invalid addr: "+e);r[e]=[i[1],+i[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>18]+a[63&e>>12]+a[63&e>>6]+a[63&e]}function d(e,t,n){for(var r=[],o=t,i;o>16,d[a++]=255&i>>8,d[a++]=255&i;return 2===s&&(i=c[e.charCodeAt(u)]<<2|c[e.charCodeAt(u+1)]>>4,d[a++]=255&i),1===s&&(i=c[e.charCodeAt(u)]<<10|c[e.charCodeAt(u+1)]<<4|c[e.charCodeAt(u+2)]>>2,d[a++]=255&i>>8,d[a++]=255&i),d},n.fromByteArray=function(e){for(var t=e.length,n=t%3,r=[],o=16383,s=0,i=t-n,c;si?i:s+o));return 1==n?(c=e[t-1],r.push(a[c>>2]+a[63&c<<4]+"==")):2==n&&(c=(e[t-2]<<8)+e[t-1],r.push(a[c>>10]+a[63&c>>4]+a[63&c<<2]+"=")),r.join("")};for(var a=[],c=[],l="undefined"==typeof Uint8Array?Array:Uint8Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=0,i=p.length;ui&&48<=i){r=10*r+(i-48);continue}if(s!==t||43!==i){if(s===t&&45===i){o=-1;continue}if(46===i)break;throw new Error("not a number: buffer["+s+"] = "+i)}}return r*o}function o(e,n,r,i){return null==e||0===e.length?null:("number"!=typeof n&&null==i&&(i=n,n=void 0),"number"!=typeof r&&null==i&&(i=r,r=void 0),o.position=0,o.encoding=i||null,o.data=t.isBuffer(e)?e.slice(n,r):new t(e),o.bytes=o.data.length,o.next())}const i=101;o.bytes=0,o.position=0,o.data=null,o.encoding=null,o.next=function(){switch(o.data[o.position]){case 100:return o.dictionary();case 108:return o.list();case 105:return o.integer();default:return o.buffer();}},o.find=function(t){for(var n=o.position,r=o.data.length,i=o.data;nr||r>=e.length)throw new RangeError("invalid lower bound");if(void 0===o)o=e.length-1;else if(o|=0,o=e.length)throw new RangeError("invalid upper bound");for(;r<=o;)if(i=r+(o-r>>1),s=+n(e[i],t,i,e),0>s)r=i+1;else if(0>3;return 0!=e%8&&t++,t}var o="undefined"==typeof e?Uint8Array:e;n.prototype.get=function(e){var t=e>>3;return t>e%8)},n.prototype.set=function(e,t){var n=e>>3;t||1===arguments.length?(this.buffer.length>e%8):n>e%8))},n.prototype._grow=function(e){if(this.buffer.length=this._parserSize;){var r=1===this._buffer.length?this._buffer[0]:a.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[r.slice(this._parserSize)]:[],this._parser(r.slice(0,this._parserSize))}n(null)},r.prototype._callback=function(e,t,n){e&&(this._clearTimeout(),!this.peerChoking&&!this._finished&&this._updateTimeout(),e.callback(t,n))},r.prototype._clearTimeout=function(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)},r.prototype._updateTimeout=function(){var e=this;e._timeoutMs&&e.requests.length&&!e._timeout&&(e._timeout=setTimeout(function(){e._onTimeout()},e._timeoutMs),e._timeoutUnref&&e._timeout.unref&&e._timeout.unref())},r.prototype._parse=function(e,t){this._parserSize=e,this._parser=t},r.prototype._onMessageLength=function(e){var t=e.readUInt32BE(0);0=this.size;){var o=n.concat(this._buffered);this._bufferedBytes-=this.size,this.push(o.slice(0,this.size)),this._buffered=[o.slice(this.size,o.length)]}r()},r.prototype._flush=function(){if(this._bufferedBytes&&this._zeroPadding){var e=new n(this.size-this._bufferedBytes);e.fill(0),this._buffered.push(e),this.push(n.concat(this._buffered)),this._buffered=null}else this._bufferedBytes&&(this.push(n.concat(this._buffered)),this._buffered=null);this.push(null)}}).call(this,e("buffer").Buffer)},{buffer:23,defined:37,inherits:44,"readable-stream":85}],21:[function(){},{}],22:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21}],23:[function(t,r,o){"use strict";function s(e){if(e>J)throw new RangeError("Invalid typed array length");var t=new Uint8Array(e);return t.__proto__=c.prototype,t}function c(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return p(e)}return i(e,t,n)}function i(e,t,n){if("number"==typeof e)throw new TypeError("\"value\" argument must not be a number");return K(e)||e&&K(e.buffer)?h(e,t,n):"string"==typeof e?u(e,t):m(e)}function a(e){if("number"!=typeof e)throw new TypeError("\"size\" argument must be of type number");else if(0>e)throw new RangeError("\"size\" argument must not be negative")}function l(e,t,n){return a(e),0>=e?s(e):void 0===t?s(e):"string"==typeof n?s(e).fill(t,n):s(e).fill(t)}function p(e){return a(e),s(0>e?0:0|g(e))}function u(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|_(e,t),r=s(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function f(e){for(var t=0>e.length?0:0|g(e.length),n=s(t),r=0;rt||e.byteLength=J)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+J.toString(16)+" bytes");return 0|e}function _(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||K(e))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return D(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return V(e).length;default:if(r)return D(e).length;t=(""+t).toLowerCase(),r=!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 R(this,t,n);case"utf8":case"utf-8":return L(this,t,n);case"ascii":return A(this,t,n);case"latin1":case"binary":return U(this,t,n);case"base64":return I(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0;}}function b(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function w(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):2147483647n&&(n=-2147483648),n=+n,X(n)&&(n=o?0:e.length-1),0>n&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(0>n)if(o)n=0;else return-1;if("string"==typeof t&&(t=c.from(t,r)),c.isBuffer(t))return 0===t.length?-1:k(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):k(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function k(e,t,n,r,o){function s(e,t){return 1==d?e[t]:e.readUInt16BE(t*d)}var d=1,a=e.length,c=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,a/=2,c/=2,n/=2}var l;if(o){var i=-1;for(l=n;la&&(n=a-c),l=n;0<=l;l--){for(var p=!0,u=0;uo&&(r=o)):r=o;var s=t.length;r>s/2&&(r=s/2);for(var d=0,i;di&&(s=i):2==a?(c=e[o+1],128==(192&c)&&(u=(31&i)<<6|63&c,127u||57343u&&(s=u))):void 0}null===s?(s=65533,a=1):65535>>10),s=56320|1023&s),r.push(s),o+=a}return T(r)}function T(t){var n=t.length;if(n<=$)return e.apply(String,t);for(var r="",o=0;ot)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var o="",s=t;se)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function H(e,t,n,r,o,i){if(!c.isBuffer(e))throw new TypeError("\"buffer\" argument must be a Buffer instance");if(t>o||te.length)throw new RangeError("Index out of range")}function M(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 q(e,t,n,r,o){return t=+t,n>>>=0,o||M(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(e,t,n,r,23,4),n+4}function j(e,t,n,r,o){return t=+t,n>>>=0,o||M(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(e,t,n,r,52,8),n+8}function N(e){if(e=e.split("=")[0],e=e.trim().replace(Z,""),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 D(e,t){t=t||Infinity;for(var n=e.length,r=null,o=[],s=0,i;si){if(!r){if(56319i){-1<(t-=3)&&o.push(239,191,189),r=i;continue}i=(r-55296<<10|i-56320)+65536}else r&&-1<(t-=3)&&o.push(239,191,189);if(r=null,128>i){if(0>(t-=1))break;o.push(i)}else if(2048>i){if(0>(t-=2))break;o.push(192|i>>6,128|63&i)}else if(65536>i){if(0>(t-=3))break;o.push(224|i>>12,128|63&i>>6,128|63&i)}else if(1114112>i){if(0>(t-=4))break;o.push(240|i>>18,128|63&i>>12,128|63&i>>6,128|63&i)}else throw new Error("Invalid code point")}return o}function W(e){for(var t=[],n=0;n(t-=2));++r)o=e.charCodeAt(r),i=o>>8,s=o%256,n.push(s),n.push(i);return n}function V(e){return Y.toByteArray(N(e))}function G(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function K(e){return e instanceof ArrayBuffer||null!=e&&null!=e.constructor&&"ArrayBuffer"===e.constructor.name&&"number"==typeof e.byteLength}function X(e){return e!==e}var Y=t("base64-js"),Q=t("ieee754");o.Buffer=c,o.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},o.INSPECT_MAX_BYTES=50;var J=2147483647;o.kMaxLength=J,c.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}}(),c.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(c.prototype,"parent",{get:function(){return this instanceof c?this.buffer:void 0}}),Object.defineProperty(c.prototype,"offset",{get:function(){return this instanceof c?this.byteOffset:void 0}}),"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),c.poolSize=8192,c.from=function(e,t,n){return i(e,t,n)},c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,c.alloc=function(e,t,n){return l(e,t,n)},c.allocUnsafe=function(e){return p(e)},c.allocUnsafeSlow=function(e){return p(e)},c.isBuffer=function(e){return null!=e&&!0===e._isBuffer},c.compare=function(e,t){if(!c.isBuffer(e)||!c.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,o=0,i=d(n,r);ot&&(e+=" ... ")),""},c.prototype.compare=function(e,t,n,r,o){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),0>t||n>e.length||0>r||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,o>>>=0,this===e)return 0;for(var s=o-r,a=n-t,l=d(s,a),p=this.slice(r,o),u=e.slice(t,n),f=0;f>>=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),0n||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 x(this,e,t,n);case"utf8":case"utf-8":return v(this,e,t,n);case"ascii":return S(this,e,t,n);case"latin1":case"binary":return C(this,e,t,n);case"base64":return E(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0;}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;c.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),t>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e],o=1,s=0;++s>>=0,t>>>=0,n||O(e,t,this.length);for(var r=this[e+--t],o=1;0>>=0,t||O(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||O(e,2,this.length),this[e]<<8|this[e+1]},c.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]},c.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])},c.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var o=this[e],s=1,d=0;++d=s&&(o-=n(2,8*t)),o},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||O(e,t,this.length);for(var o=t,i=1,s=this[e+--o];0=i&&(s-=n(2,8*t)),s},c.prototype.readInt8=function(e,t){return e>>>=0,t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.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},c.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},c.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},c.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]},c.prototype.readFloatLE=function(e,t){return e>>>=0,t||O(e,4,this.length),Q.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||O(e,4,this.length),Q.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||O(e,8,this.length),Q.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||O(e,8,this.length),Q.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,o){if(e=+e,t>>>=0,r>>>=0,!o){var s=n(2,8*r)-1;H(this,e,t,r,s,0)}var d=1,a=0;for(this[t]=255&e;++a>>=0,r>>>=0,!o){var s=n(2,8*r)-1;H(this,e,t,r,s,0)}var d=r-1,i=1;for(this[t+d]=255&e;0<=--d&&(i*=256);)this[t+d]=255&e/i;return t+r},c.prototype.writeUInt8=function(e,t,n){return e=+e,t>>>=0,n||H(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,n){return e=+e,t>>>=0,n||H(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUInt16BE=function(e,t,n){return e=+e,t>>>=0,n||H(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUInt32LE=function(e,t,n){return e=+e,t>>>=0,n||H(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},c.prototype.writeUInt32BE=function(e,t,n){return e=+e,t>>>=0,n||H(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},c.prototype.writeIntLE=function(e,t,r,o){if(e=+e,t>>>=0,!o){var s=n(2,8*r-1);H(this,e,t,r,s-1,-s)}var d=0,i=1,a=0;for(this[t]=255&e;++de&&0==a&&0!==this[t+d-1]&&(a=1),this[t+d]=255&(e/i>>0)-a;return t+r},c.prototype.writeIntBE=function(e,t,r,o){if(e=+e,t>>>=0,!o){var s=n(2,8*r-1);H(this,e,t,r,s-1,-s)}var d=r-1,i=1,a=0;for(this[t+d]=255&e;0<=--d&&(i*=256);)0>e&&0==a&&0!==this[t+d+1]&&(a=1),this[t+d]=255&(e/i>>0)-a;return t+r},c.prototype.writeInt8=function(e,t,n){return e=+e,t>>>=0,n||H(this,e,t,1,127,-128),0>e&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,n){return e=+e,t>>>=0,n||H(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,n){return e=+e,t>>>=0,n||H(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,n){return e=+e,t>>>=0,n||H(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},c.prototype.writeInt32BE=function(e,t,n){return e=+e,t>>>=0,n||H(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},c.prototype.writeFloatLE=function(e,t,n){return q(this,e,t,!0,n)},c.prototype.writeFloatBE=function(e,t,n){return q(this,e,t,!1,n)},c.prototype.writeDoubleLE=function(e,t,n){return j(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return j(this,e,t,!1,n)},c.prototype.copy=function(e,t,n,r){if(!c.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),0t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-to||"latin1"===r)&&(e=o)}}else"number"==typeof e&&(e&=255);if(0>t||this.length>>=0,n=n===void 0?this.length:n>>>0,e||(e=0);var s;if("number"==typeof e)for(s=t;si)){d.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+d.length+" \""+(t+"\" listeners added. Use emitter.setMaxListeners() to increase limit."));a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=d.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",a.name,a.message)}return e}function p(){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;te||e!==e)throw new TypeError("\"defaultMaxListeners\" must be a positive number");w=e}}):n.defaultMaxListeners=w,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,p,u,i;if(i=this._events,i)t=t&&null==i.error;else if(!t)return!1;if(t){if(1o)return this;0===o?n.shift():h(n,o),1===n.length&&(r[e]=n[0]),r.removeListener&&this.emit("removeListener",e,i||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=_(null),this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=_(null):delete n[e]),this;if(0===arguments.length){var o=y(n),i;for(r=0;rt)throw new RangeError("\"size\" argument must not be negative");return e.allocUnsafe?e.allocUnsafe(t):new e(t)}}).call(this,e("buffer").Buffer)},{buffer:23}],27:[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 s=o(e);return 0===e?s:void 0===t?r(s,0):("string"!=typeof i&&(i=void 0),r(s,t,i))}}).call(this,e("buffer").Buffer)},{buffer:23,"buffer-alloc-unsafe":26,"buffer-fill":28}],28:[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,s,d,a,c){if(i)return t.fill(s,d,a,c);if("number"==typeof s)return r(t,s,d,a);if("string"==typeof s){if("string"==typeof d?(c=d,d=0,a=t.length):"string"==typeof a&&(c=a,a=t.length),void 0!==c&&"string"!=typeof c)throw new TypeError("encoding must be a string");if("latin1"===c&&(c="binary"),"string"==typeof c&&!e.isEncoding(c))throw new TypeError("Unknown encoding: "+c);if(""===s)return r(t,0,d,a);if(n(s))return r(t,s.charCodeAt(0),d,a);s=new e(s,c)}return e.isBuffer(s)?o(t,s,d,a):r(t,0,d,a)}}).call(this,e("buffer").Buffer)},{buffer:23}],29:[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 s?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 s?e.from(t,n):new e(t,n)}var i=Object.prototype.toString,s="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):s?e.from(t):new e(t)}}).call(this,e("buffer").Buffer)},{buffer:23}],30:[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"}},{}],31:[function(e,t){function n(e,t,o){var s=this;if(!(s instanceof n))return new n(e,t,o);if(i.Writable.call(s,o),o||(o={}),!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");s._blockstream=new r(t,{zeroPadding:!1}),s._blockstream.on("data",function(t){s.destroyed||(e.put(d,t),d+=1)}).on("error",function(e){s.destroy(e)});var d=0;s.on("finish",function(){this._blockstream.end()})}t.exports=n;var r=e("block-stream2"),o=e("inherits"),i=e("readable-stream");o(n,i.Writable),n.prototype._write=function(e,t,n){this._blockstream.write(e,t,n)},n.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,e&&this.emit("error",e),this.emit("close"))}},{"block-stream2":20,inherits:44,"readable-stream":85}],32:[function(e,n){n.exports=function(e,n,r){for(var o=Infinity,s=0,d=n.length-1,a,i,c;s<=d&&(a=s+(d-s>>1),c=n[a]-e,0>c?s=a+1:0t.path.length?s=null:0===n&&1this._size&&(r=this._size),n===this._size?(this.destroy(),void this.push(null)):void(t.onload=function(){e._offset=r,e.push(d(t.result))},t.onerror=function(){e.emit("error",t.error)},t.readAsArrayBuffer(this._file.slice(n,r)))},n.prototype.destroy=function(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(t){}}this.reader=null}},{inherits:44,"readable-stream":85,"typedarray-to-buffer":111}],40:[function(e,t){t.exports=function(e,t){function n(e,r){return e.reduce(function(e,o){return Array.isArray(o)&&r>1,f=-7,h=o?c-1:0,i=o?-1:1,d=t[r+h],s,e;for(h+=i,s=d&(1<<-f)-1,d>>=-f,f+=l;0>=-f,f+=a;0>1,y=23===u?5.960464477539063e-8-6.617444900424222e-24:0,b=p?0:f-1,i=p?1:-1,d=0>a||0===a&&0>1/a?1:0,s,w,m;for(a=t(a),isNaN(a)||a===Infinity?(w=isNaN(a)?1:0,s=g):(s=r(Math.log(a)/Math.LN2),1>a*(m=n(2,-s))&&(s--,m*=2),a+=1<=s+_?y/m:y*n(2,1-_),2<=a*m&&(s++,m/=2),s+_>=g?(w=0,s=g):1<=s+_?(w=(a*m-1)*n(2,u),s+=_):(w=a*n(2,_-1)*n(2,u),s=0));8<=u;o[l+b]=255&w,b+=i,w/=256,u-=8);for(s=s<127)return!1;return!0}},{}],46:[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))}t.exports=function(e){return null!=e&&(n(e)||r(e)||!!e._isBuffer)}},{}],47:[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}],48:[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 s[i.call(e)]}t.exports=n,n.strict=r,n.loose=o;var i=Object.prototype.toString,s={"[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}},{}],49:[function(e,t){var n={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},{}],50:[function(e,t,n){"use strict";n.regex=n.re=/^npm-debug\.log$|^\..*\.swp$|^\.DS_Store$|^\.AppleDouble$|^\.LSOverride$|^Icon\r$|^\._.*|^\.Spotlight-V100(?:$|\/)|\.Trashes|^__MACOSX$|~$|^Thumbs\.db$|^ehthumbs\.db$|^Desktop\.ini$|^@eaDir$/,n.is=(e)=>n.re.test(e),n.not=(e)=>!n.is(e)},{}],51:[function(e,t){function n(e){var t={},n=e.split("magnet:?")[1],i=n&&0<=n.length?n.split("&"):[];i.forEach(function(e){var n=e.split("=");if(2===n.length){var r=n[0],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{var i=t[r];t[r]=[i,o]}}});var d;if(t.xt){var a=Array.isArray(t.xt)?t.xt:[t.xt];a.forEach(function(e){if(d=e.match(/^urn:btih:(.{40})/))t.infoHash=d[1].toLowerCase();else if(d=e.match(/^urn:btih:(.{32})/)){var n=r.decode(d[1]);t.infoHash=o.from(n,"binary").toString("hex")}})}return t.infoHash&&(t.infoHashBuffer=o.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)),s(t.announce),s(t.urlList),t}t.exports=n,t.exports.decode=n,t.exports.encode=function(e){e=i(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);var t="magnet:?";return Object.keys(e).filter(function(e){return 2===e.length}).forEach(function(n,r){var o=Array.isArray(e[n])?e[n]:[e[n]];o.forEach(function(e,o){(0e._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;on)break;else(0<=r||n<=s)&&(r=s)}var d=r-n;return 0>d&&(d=0),d}},{inherits:44,"readable-stream":85,"to-arraybuffer":108}],53:[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||Infinity,this.length!==Infinity&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=o(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 s=t.offset||0,d=t.length||o.length-s;r(n,null,o.slice(s,d+s))},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:68}],54:[function(e,t,n){function o(e,t,n){for(var r=t;r>3:0,c=null;return s&&(c=s.toString(16),a&&(c+="."+a)),{mimeCodec:c,buffer:b(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):y(n.stsz.encodingLength(e)),t.writeUInt32BE(0,0),t.writeUInt32BE(o.length,4);for(var s=0;sd&&(i=1),t.writeUInt32BE(i,n),t.write(e.type,n+4,4,"ascii");var l=n+8;if(1===i&&(r.encode(e.length,t,l),l+=8),s.fullBoxes[o]&&(t.writeUInt32BE(e.flags||0,l),t.writeUInt8(e.version||0,l),l+=4),c[o]){var p=c[o];p.forEach(function(n){if(5===n.length){var r=e[n]||[];n=n.substr(0,4),r.forEach(function(e){a._encode(e,t,l),l+=a.encode.bytes})}else e[n]&&(a._encode(e[n],t,l),l+=a.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){a._encode(e,t,l),l+=a.encode.bytes})}else if(s[o]){var u=s[o].encode;u(e,t,l),l+=u.bytes}else if(e.buffer){var f=e.buffer;f.copy(t,l),l+=e.buffer.length}else throw new Error("Either `type` must be set to a known type (not'"+o+"') or `buffer` must be set");return a.encode.bytes=l-n,t},a.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 a,c;return s.fullBoxes[i]&&(a=e.readUInt8(d),c=16777215&e.readUInt32BE(d),d+=4),{length:o,headersLen:d-t,contentLen:o-(d-t),type:i,version:a,flags:c}},a.decode=function(e,t,n){t=t||0,n=n||e.length;var r=a.readHeaders(e,t,n);if(!r||r.length>n-t)throw new Error("Data too short");return a.decodeWithoutHeaders(r,e,t+r.headersLen,t+r.length)},a.decodeWithoutHeaders=function(e,t,n,r){n=n||0,r=r||t.length;var o=e.type,d={};if(c[o]){d.otherBoxes=[];for(var l=c[o],p=n,u;8<=r-p;)if(u=a.decode(t,p,r),p+=u.length,0<=l.indexOf(u.type))d[u.type]=u;else if(0<=l.indexOf(u.type+"s")){var f=u.type+"s",h=d[f]=d[f]||[];h.push(u)}else d.otherBoxes.push(u)}else if(s[o]){var m=s[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},a.encodingLength=function(e){var t=e.type,n=8;if(s.fullBoxes[t]&&(n+=4),c[t]){var r=c[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+=a.encodingLength(e)})}else if(e[t]){var o=e[t];o.type=t,n+=a.encodingLength(o)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){n+=a.encodingLength(e)})}else if(s[t])n+=s[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":54,"buffer-alloc":27,"buffer-from":29,uint64be:112}],57:[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._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"),s=e("inherits"),d=e("next-event"),a=e("mp4-box-encoding"),c=e("buffer-alloc"),l=c(0);t.exports=r,s(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)return this._writeBuffer=e,void(this._writeCb=n);var o=e.length=u?t(e/u)+"d":e>=p?t(e/p)+"h":e>=s?t(e/s)+"m":e>=l?t(e/l)+"s":e+"ms"}function a(e){return c(e,u,"day")||c(e,p,"hour")||c(e,s,"minute")||c(e,l,"second")||e+" ms"}function c(e,t,n){return en?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var o=r(e.split("/")),s=r(t.split("/")),a=d(o.length,s.length),c=a,l=0;li++;)s.push(n(2,i));t.exports=function(e){return r(e/o,s)}},{"closest-to":32}],67:[function(e,t){(function(e){"use strict";t.exports=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 s=arguments.length,d,a;switch(s){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(s-1),a=0;ae.length)throw new Error("pump requires two streams per minimum");var n=e.map(function(o,s){var i=s=o&&n>>10),e=56320|1023&e),t+=O(e),t}).join("")}function u(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:v}function f(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function h(e,t,n){var r=0;for(e=n?P(e/E):e>>1,e+=P(e/t);e>R*C>>1;r+=v)e=P(e/R);return P(r+(R+1)*e/(e+w))}function m(e){var r=[],o=e.length,s=0,i=I,n=B,a,c,l,f,m,g,_,y,b,t;for(c=e.lastIndexOf(L),0>c&&(c=0),l=0;l=o&&d("invalid-input"),y=u(e.charCodeAt(f++)),(y>=v||y>P((x-s)/g))&&d("overflow"),s+=y*g,b=_<=n?S:_>=n+C?C:_-n,yP(x/t)&&d("overflow"),g*=t}a=r.length+1,n=h(s-m,a,0==m),P(s/a)>x-i&&d("overflow"),i+=P(s/a),s%=a,r.splice(s++,0,i)}return p(r)}function g(e){var r=[],o,n,i,s,a,c,p,u,m,g,t,_,y,b,w;for(e=l(e),_=e.length,o=I,n=0,a=B,c=0;c<_;++c)t=e[c],128>t&&r.push(O(t));for(i=s=r.length,s&&r.push(L);i<_;){for(p=x,c=0;c<_;++c)t=e[c],t>=o&&tP((x-n)/y)&&d("overflow"),n+=(p-o)*y,o=p,c=0;c<_;++c)if(t=e[c],tx&&d("overflow"),t==o){for(u=n,m=v;;m+=v){if(g=m<=a?S:m>=a+C?C:m-a,u= 0x80 (not a basic code point)","invalid-input":"Invalid input"},R=v-S,P=r,O=e,H,M;if(H={version:"1.4.1",ucs2:{decode:l,encode:p},decode:m,encode:g,toASCII:function(e){return c(e,function(e){return T.test(e)?"xn--"+g(e):e})},toUnicode:function(e){return c(e,function(e){return k.test(e)?m(e.slice(4).toLowerCase()):e})}},"function"==typeof i&&"object"==typeof i.amd&&i.amd)i("punycode",function(){return H});else if(!(_&&y))s.punycode=H;else if(n.exports==_)y.exports=H;else for(M in H)H.hasOwnProperty(M)&&(_[M]=H[M])})(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],71:[function(e,t){"use strict";function n(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,o,s){t=t||"&",o=o||"=";var d={};if("string"!=typeof e||0===e.length)return d;var a=/\+/g;e=e.split(t);var c=1e3;s&&"number"==typeof s.maxKeys&&(c=s.maxKeys);var l=e.length;0c&&(l=c);for(var p=0;p=e.length)return r._position+=e.length,n(null);var c;if(a>e.length){r._position+=e.length,c=0===d?e:e.slice(d),o=i.stream.write(c)&&o;break}r._position+=a,c=0===d&&a===e.length?e:e.slice(d,a),o=i.stream.write(c)&&o,i.last&&i.stream.end(),e=e.slice(a),r._queue.shift()}o?n(null):i.stream.once("drain",n.bind(null,null))},n.prototype.slice=function(e){var t=this;if(t.destroyed)return null;e instanceof Array||(e=[e]);var n=new o.PassThrough;return e.forEach(function(r,o){t._queue.push({start:r.start,end:r.end,stream:n,last:o===e.length-1})}),t._buffer&&t._write(t._buffer,null,t._cb),n},n.prototype.destroy=function(e){var t=this;t.destroyed||(t.destroyed=!0,e&&t.emit("error",e))}},{inherits:44,"readable-stream":85}],77:[function(e,t){"use strict";function n(e){return this instanceof n?void(a.call(this,e),c.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"),s=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 a=e("./_stream_readable"),c=e("./_stream_writable");d.inherits(n,a);for(var l=s(c.prototype),p=0,u;p=X?e=X:(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?R.nextTick(y,e):y(e))}function y(e){W("emit readable"),e.emit("readable"),C(e)}function b(e,t){t.readingMore||(t.readingMore=!0,R.nextTick(w,e,t))}function w(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=B(e,t.buffer,t.decoder),r}function B(e,t,n){var r;return ei.length?i.length:e;if(o+=s===i.length?i:i.slice(0,e),e-=s,0===e){s===i.length?(++r,t.head=n.next?n.next:t.tail=null):(t.head=n,n.data=i.slice(s));break}++r}return t.length-=r,o}function L(e,t){var n=j.allocUnsafe(e),r=t.head,o=1;for(r.data.copy(n),e-=r.data.length;r=r.next;){var i=r.data,s=e>i.length?i.length:e;if(i.copy(n,n.length-e,0,s),e-=s,0===e){s===i.length?(++o,t.head=r.next?r.next:t.tail=null):(t.head=r,r.data=i.slice(s));break}++o}return t.length-=o,n}function T(e){var t=e._readableState;if(0=t.highWaterMark||t.ended))return W("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?T(this):_(this),null;if(e=m(e,t),0===e&&t.ended)return 0===t.length&&T(this),null;var r=t.needReadable;W("need readable",r),(0===t.length||t.length-e>>0),n=this.head,s=0;n;)r(n.data,t,s),s+=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":91,util:21}],83:[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,s=this._writableState&&this._writableState.destroyed;return i||s?(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":67}],84:[function(e,t){t.exports=e("events").EventEmitter},{events:24}],85:[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":77,"./lib/_stream_passthrough.js":78,"./lib/_stream_readable.js":79,"./lib/_stream_transform.js":80,"./lib/_stream_writable.js":81}],86:[function(e,t,n){function r(e,t,n,r){function i(){S.removeEventListener("loadstart",i),n.autoplay&&S.play()}function d(){S.removeEventListener("canplay",d),r(null,S)}function u(){S=t("iframe"),o(e,function(e,t){return e?w(e):void(S.src=t,".pdf"!==x&&(S.sandbox="allow-forms allow-scripts"),r(null,S))})}function w(t){t.message="Error rendering file \""+e.name+"\": "+t.message,a(t.message),r(t)}var x=p.extname(e.name).toLowerCase(),v=0,S;0<=g.indexOf(x)?function(){function r(){a("Use MediaSource API for "+e.name),g(),S.addEventListener("error",u),S.addEventListener("loadstart",i),S.addEventListener("canplay",d);var t=new l(S),n=t.createWriteStream(s(e.name));e.createReadStream().pipe(n),v&&(S.currentTime=v)}function c(){a("Use Blob URL for "+e.name),g(),S.addEventListener("error",w),S.addEventListener("loadstart",i),S.addEventListener("canplay",d),o(e,function(e,t){return e?w(e):void(S.src=t,v&&(S.currentTime=v))})}function p(e){a("videostream error: fallback to MediaSource API: %o",e.message||e),S.removeEventListener("error",p),S.removeEventListener("canplay",d),r()}function u(t){return a("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>n.maxBlobLength?(a("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),w(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")"))):void(S.removeEventListener("error",u),S.removeEventListener("canplay",d),c())}function g(){S||(S=t(_),S.addEventListener("progress",function(){v=S.currentTime}))}var _=0<=m.indexOf(x)?"video":"audio";k?0<=h.indexOf(x)?function(){a("Use `videostream` package for "+e.name),g(),S.addEventListener("error",p),S.addEventListener("loadstart",i),S.addEventListener("canplay",d),f(e,S)}():r():c()}():0<=_.indexOf(x)?function(){S=t("audio"),o(e,function(e,t){return e?w(e):void(S.addEventListener("error",w),S.addEventListener("loadstart",i),S.addEventListener("canplay",d),S.src=t)})}():0<=y.indexOf(x)?function(){S=t("img"),o(e,function(t,n){return t?w(t):void(S.src=n,S.alt=e.name,r(null,S))})}():0<=b.indexOf(x)?u():function(){a("Unknown file extension \"%s\" - will attempt to render into iframe",x);var t="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){t+=e}).on("end",function(){c(t)?(a("File extension \"%s\" appears ascii, so will render.",x),u()):(a("File extension \"%s\" appears non-ascii, will not render.",x),r(new Error("Unsupported file type \""+x+"\": Cannot append to DOM")))}).on("error",r)}()}function o(e,t){var r=p.extname(e.name).toLowerCase();u(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 s(e){var t=p.extname(e).toLowerCase();return{".m4a":"audio/mp4; codecs=\"mp4a.40.5\"",".m4v":"video/mp4; codecs=\"avc1.640029, mp4a.40.5\"",".mkv":"video/webm; codecs=\"avc1.640029, mp4a.40.5\"",".mp3":"audio/mpeg",".mp4":"video/mp4; codecs=\"avc1.640029, mp4a.40.5\"",".webm":"video/webm; codecs=\"vorbis, vp8\""}[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=w)}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=p.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 s(e){var r=a(e);return n.autoplay&&(r.autoplay=!0),n.muted&&(r.muted=!0),n.controls&&(r.controls=!0),t.appendChild(r),r}function a(e){var n=document.createElement(e);return t.appendChild(n),n}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?s(e):a(e)},n,function(e,t){e&&t&&t.remove(),o(e,t)})},n.mime=e("./lib/mime.json");var a=e("debug")("render-media"),c=e("is-ascii"),l=e("mediasource"),p=e("path"),u=e("stream-to-blob-url"),f=e("videostream"),h=[".m4a",".m4v",".mp4"],m=[".m4v",".mkv",".mp4",".webm"],g=[].concat(m,[".m4a",".mp3"]),_=[".aac",".oga",".ogg",".wav",".flac"],y=[".bmp",".gif",".jpeg",".jpg",".png",".svg"],b=[".css",".html",".js",".md",".pdf",".txt"],w=200000000,k="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":87,debug:35,"is-ascii":45,mediasource:52,path:65,"stream-to-blob-url":102,videostream:121}],87:[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/mp4",".m4v":"video/mp4",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},{}],88:[function(e,t){(function(e){t.exports=function(t,n,r){function o(t){function n(){r&&r(t,d),r=null}i?e.nextTick(n):n()}function s(e,n,r){if(d[e]=r,n&&(p=!0),0==--c||n)o(n);else if(!p&&u>2)+1;s>2]|=128<<24-(t%4<<3),e[(-16&(t>>2)+2)+14]=0|n/536870912,e[(-16&(t>>2)+2)+15]=n<<3},f=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>2);return p(r,e),u(r,e,t),n},e.prototype._write=function(e,t,n,r){c(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),f(this._heap,this._padMaxChunkLen)},e.prototype.digest=function(e){return s(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;for(this._offset+=n;tn;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=e)return 65536;if(16777216>e)for(t=1;t>2],d=0|r[t+324>>2],c=0|r[t+328>>2],p=0|r[t+332>>2],f=0|r[t+336>>2],n=0;(0|n)<(0|e);n=0|n+64){for(s=i,a=d,l=c,u=p,h=f,o=0;64>(0|o);o=0|o+4)g=0|r[n+o>>2],m=0|(0|(i<<5|i>>>27)+(d&c|~d&p))+(0|(0|g+f)+1518500249),f=p,p=c,c=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&c|~d&p))+(0|(0|g+f)+1518500249),f=p,p=c,c=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^c^p))+(0|(0|g+f)+1859775393),f=p,p=c,c=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&c|d&p|c&p))+(0|(0|g+f)-1894007588),f=p,p=c,c=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^c^p))+(0|(0|g+f)-899497514),f=p,p=c,c=d<<30|d>>>2,d=i,i=m,r[o>>2]=g;i=0|i+s,d=0|d+a,c=0|c+l,p=0|p+u,f=0|f+h}r[t+320>>2]=i,r[t+324>>2]=d,r[t+328>>2]=c,r[t+332>>2]=p,r[t+336>>2]=f}}}},function(e){var t=this,n;"undefined"!=typeof self&&"undefined"!=typeof self.FileReaderSync&&(n=new self.FileReaderSync);var r=function(e,t,n,r,o,s){var d=s%4,a=(o+d)%4,c=o-a,l;switch(d){case 0:t[s]=e.charCodeAt(r+3);case 1:t[0|s+1-(d<<1)]=e.charCodeAt(r+2);case 2:t[0|s+2-(d<<1)]=e.charCodeAt(r+1);case 3:t[0|s+3-(d<<1)]=e.charCodeAt(r);}if(!(o>2]=e.charCodeAt(r+l)<<24|e.charCodeAt(r+l+1)<<16|e.charCodeAt(r+l+2)<<8|e.charCodeAt(r+l+3);switch(a){case 3:t[0|s+c+1]=e.charCodeAt(r+c+2);case 2:t[0|s+c+2]=e.charCodeAt(r+c+1);case 1:t[0|s+c+3]=e.charCodeAt(r+c);}}},o=function(e,t,n,r,o,s){var d=s%4,a=(o+d)%4,c=o-a,l;switch(d){case 0:t[s]=e[r+3];case 1:t[0|s+1-(d<<1)]=e[r+2];case 2:t[0|s+2-(d<<1)]=e[r+1];case 3:t[0|s+3-(d<<1)]=e[r];}if(!(o>2]=e[r+l]<<24|e[r+l+1]<<16|e[r+l+2]<<8|e[r+l+3];switch(a){case 3:t[0|s+c+1]=e[r+c+2];case 2:t[0|s+c+2]=e[r+c+1];case 1:t[0|s+c+3]=e[r+c];}}},i=function(e,t,r,o,s,d){var a=d%4,c=(s+a)%4,l=s-c,p=new Uint8Array(n.readAsArrayBuffer(e.slice(o,o+s))),u;switch(a){case 0:t[d]=p[3];case 1:t[0|d+1-(a<<1)]=p[2];case 2:t[0|d+2-(a<<1)]=p[1];case 3:t[0|d+3-(a<<1)]=p[0];}if(!(s>2]=p[u]<<24|p[u+1]<<16|p[u+2]<<8|p[u+3];switch(c){case 3:t[0|d+l+1]=p[l+2];case 2:t[0|d+l+2]=p[l+1];case 1:t[0|d+l+3]=p[l];}}};e.exports=function(e,n,s,d,a,c){if("string"==typeof e)return r(e,n,s,d,a,c);if(e instanceof Array)return o(e,n,s,d,a,c);if(t&&t.Buffer&&t.Buffer.isBuffer(e))return o(e,n,s,d,a,c);if(e instanceof ArrayBuffer)return o(new Uint8Array(e),n,s,d,a,c);if(e.buffer instanceof ArrayBuffer)return o(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n,s,d,a,c);if(e instanceof Blob)return i(e,n,s,d,a,c);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),s=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){var t=this._rusha.rawEnd().buffer;if(!e)return t;if("hex"===e)return s(t);throw new Error("unsupported digest encoding")},e}();e.exports=function(){return new d}}])})},{}],91:[function(e,t,n){function r(e,t){for(var n in e)t[n]=e[n]}function o(e,t,n){return s(e,t,n)}var i=e("buffer"),s=i.Buffer;s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?t.exports=i:(r(i,n),n.Buffer=o),r(s,o),o.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return s(e,t,n)},o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=s(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 s(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i.SlowBuffer(e)}},{buffer:23}],92:[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:23}],93:[function(e,t){(function(n){function r(e,t){e="string"==typeof e?{url:e}:Object.assign({},e),e.headers=Object.assign({},e.headers),t=c(t),e.url&&o(e),null==e.maxRedirects&&(e.maxRedirects=10);var s;e.form&&(s="string"==typeof e.form?e.form:l.stringify(e.form)),e.body&&(s=e.json&&!i(e.body)?JSON.stringify(e.body):e.body),e.json&&(e.headers.accept="application/json"),e.json&&s&&(e.headers["content-type"]="application/json"),e.form&&(e.headers["content-type"]="application/x-www-form-urlencoded"),s&&!i(s)&&(e.headers["content-length"]=n.byteLength(s)),delete e.body,delete e.form,s&&!e.method&&(e.method="POST"),e.method&&(e.method=e.method.toUpperCase());var u=Object.keys(e.headers).some(function(e){return"accept-encoding"===e.toLowerCase()});u||(e.headers["accept-encoding"]="gzip, deflate");var f="https:"===e.protocol?a:d,h=f.request(e,function(n){if(300<=n.statusCode&&400>n.statusCode&&"location"in n.headers)return e.url=n.headers.location,n.resume(),void(0l?(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._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(function(t){function n(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))},function(t){e.destroy(t)}))},function(t){e.destroy(t)},e.offerConstraints)},r.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(function(t){function n(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})}e.destroyed||(t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,function(){e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))},function(t){e.destroy(t)}))},function(t){e.destroy(t)},e.answerConstraints)},r.prototype._onIceStateChange=function(){var e=this;if(!e.destroyed){var t=e._pc.iceConnectionState,n=e._pc.iceGatheringState;e._debug("iceStateChange (connection: %s) (gathering: %s)",t,n),e.emit("iceStateChange",t,n),("connected"===t||"completed"===t)&&(clearTimeout(e._reconnectTimeout),e._pcReady=!0,e._maybeReady()),"disconnected"===t&&(e.reconnectTimer?(clearTimeout(e._reconnectTimeout),e._reconnectTimeout=setTimeout(function(){e.destroy()},e.reconnectTimer)):e.destroy()),"failed"===t&&e.destroy(new Error("Ice connection failed.")),"closed"===t&&e.destroy()}},r.prototype.getStats=function(e){var t=this;0===t._pc.getStats.length?t._pc.getStats().then(function(t){var n=[];t.forEach(function(e){n.push(e)}),e(null,n)},function(t){e(t)}):t._isReactNativeWebrtc?t._pc.getStats(null,function(t){var n=[];t.forEach(function(e){n.push(e)}),e(null,n)},function(t){e(t)}):0l)&&e._onChannelBufferedAmountLow()},r.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||(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=!0,t.emit("_iceComplete")))},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._onAddStream=function(e){var t=this;t.destroyed||(t._debug("on add stream"),t.emit("stream",e.stream))},r.prototype._onTrack=function(e){var t=this;if(!t.destroyed){t._debug("on track");var n=e.streams[0].id;-1!==t._previousStreams.indexOf(n)||(t._previousStreams.push(n),t.emit("stream",e.streams[0]))}},r.prototype._debug=function(){var e=this,t=[].slice.call(arguments);t[0]="["+e._id+"] "+t[0],i.apply(null,t)},r.prototype._transformConstraints=function(e){var t=this;if(0===Object.keys(e).length)return e;if((e.mandatory||e.optional)&&!t._isChromium){var n=Object.assign({},e.optional,e.mandatory);return void 0!==n.OfferToReceiveVideo&&(n.offerToReceiveVideo=n.OfferToReceiveVideo,delete n.OfferToReceiveVideo),void 0!==n.OfferToReceiveAudio&&(n.offerToReceiveAudio=n.OfferToReceiveAudio,delete n.OfferToReceiveAudio),n}return e.mandatory||e.optional||!t._isChromium?e:(void 0!==e.offerToReceiveVideo&&(e.OfferToReceiveVideo=e.offerToReceiveVideo,delete e.offerToReceiveVideo),void 0!==e.offerToReceiveAudio&&(e.OfferToReceiveAudio=e.offerToReceiveAudio,delete e.offerToReceiveAudio),{mandatory:e})}}).call(this,e("buffer").Buffer)},{buffer:23,debug:35,"get-browser-rtc":41,inherits:44,randombytes:75,"readable-stream":85}],95:[function(e,t){function n(e){return s.digest(e)}function r(e){for(var t=e.length,n=new Uint8Array(t),r=0;r>>4).toString(16)),n.push((15&o).toString(16));return n.join("")}var i=e("rusha"),s=new i,d="undefined"==typeof window?self:window,a=d.crypto||d.msCrypto||{},c=a.subtle||a.webkitSubtle;try{c.digest({name:"sha-1"},new Uint8Array).catch(function(){c=!1})}catch(e){c=!1}t.exports=function(e,t){return c?void("string"==typeof e&&(e=r(e)),c.digest({name:"sha-1"},e).then(function(e){t(o(new Uint8Array(e)))},function(){t(n(e))})):void setTimeout(t,0,n(e))},t.exports.sync=n},{rusha:90}],96:[function(e,t){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(e||(e={}),"string"==typeof e&&(e={url:e}),null==e.url&&null==e.socket)throw 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(t._id=d(4).toString("hex").slice(0,7),t._debug("new websocket: %o",e),e=Object.assign({allowHalfOpen:!1},e),a.Duplex.call(t,e),t.connected=!1,t.destroyed=!1,t._chunk=null,t._cb=null,t._interval=null,e.socket)t.url=e.socket.url,t._ws=e.socket;else{t.url=e.url;try{t._ws="function"==typeof c?new l(e.url,e):new l(e.url)}catch(e){return void n.nextTick(function(){t.destroy(e)})}}t._ws.binaryType="arraybuffer",t._ws.onopen=function(){t._onOpen()},t._ws.onmessage=function(e){t._onMessage(e)},t._ws.onclose=function(){t._onClose()},t._ws.onerror=function(){t.destroy(new Error("connection error to "+t.url))},t._onFinishBound=function(){t._onFinish()},t.once("finish",t._onFinishBound)}t.exports=r;var o=e("safe-buffer").Buffer,i=e("debug")("simple-websocket"),s=e("inherits"),d=e("randombytes"),a=e("readable-stream"),c=e("ws"),l="function"==typeof c?c:WebSocket,p=65536;s(r,a.Duplex),r.WEBSOCKET_SUPPORT=!!l,r.prototype.send=function(e){this._ws.send(e)},r.prototype.destroy=function(e){this._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.connected=!1,n.destroyed=!0,clearInterval(n._interval),n._interval=null,n._chunk=null,n._cb=null,n._onFinishBound&&n.removeListener("finish",n._onFinishBound),n._onFinishBound=null,n._ws){var r=n._ws,o=function(){r.onclose=null};if(r.readyState===l.CLOSED)o();else try{r.onclose=o,r.close()}catch(e){o()}r.onopen=null,r.onmessage=null,r.onerror=function(){}}if(n._ws=null,e){if("undefined"!=typeof DOMException&&e instanceof DOMException){var i=e.code;e=new Error(e.message),e.code=i}n.emit("error",e)}n.emit("close"),t()}},r.prototype._read=function(){},r.prototype._write=function(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 c&&this._ws.bufferedAmount>p?(this._debug("start backpressure: bufferedAmount %d",this._ws.bufferedAmount),this._cb=n):n(null)}else this._debug("write before connect"),this._chunk=e,this._cb=n},r.prototype._onFinish=function(){function e(){setTimeout(function(){t.destroy()},1e3)}var t=this;t.destroyed||(t.connected?e():t.once("connect",e))},r.prototype._onMessage=function(e){if(!this.destroyed){var t=e.data;t instanceof ArrayBuffer&&(t=o.from(t)),this.push(t)}},r.prototype._onOpen=function(){var e=this;if(!(e.connected||e.destroyed)){if(e.connected=!0,e._chunk){try{e.send(e._chunk)}catch(t){return e.destroy(t)}e._chunk=null,e._debug("sent chunk from \"write before connect\"");var t=e._cb;e._cb=null,t(null)}"function"!=typeof c&&(e._interval=setInterval(function(){e._onInterval()},150),e._interval.unref&&e._interval.unref()),e._debug("connect"),e.emit("connect")}},r.prototype._onInterval=function(){if(this._cb&&this._ws&&!(this._ws.bufferedAmount>p)){this._debug("ending backpressure: bufferedAmount %d",this._ws.bufferedAmount);var e=this._cb;this._cb=null,e(null)}},r.prototype._onClose=function(){this.destroyed||(this._debug("on close"),this.destroy())},r.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._id+"] "+e[0],i.apply(null,e)}}).call(this,e("_process"))},{_process:68,debug:35,inherits:44,randombytes:75,"readable-stream":85,"safe-buffer":91,ws:21}],97:[function(e,t){var n=1,r=65535,o=4,i=setInterval(function(){n=n+1&r},0|1e3/o);i.unref&&i.unref(),t.exports=function(e){var t=o*(e||5),i=[0],s=1,d=n-1&r;return function(e){var a=n-d&r;for(a>t&&(a=t),d=n;a--;)s==t&&(s=0),i[s]=i[0==s?t-1:s-1],s++;e&&(i[s-1]+=e);var c=i[s-1],l=i.lengthe._pos){var s=n.substr(e._pos);if("x-user-defined"===e._charset){for(var d=new o(s.length),c=0;ce._pos&&(e.push(new o(new Uint8Array(i.result.slice(e._pos)))),e._pos=i.result.byteLength)},i.onload=function(){e.push(null)},i.readAsArrayBuffer(n);}e._xhr.readyState===a.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("buffer").Buffer)},{"./capability":99,_process:68,buffer:23,inherits:44,"readable-stream":85}],102:[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":103}],103:[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:63}],104:[function(e,t){(function(n){var r=e("once");t.exports=function(e,t,o){o=r(o);var i=n.alloc(t),s=0;e.on("data",function(e){e.copy(i,s),s+=e.length}).on("end",function(){o(null,i)}).on("error",o)}}).call(this,e("buffer").Buffer)},{buffer:23,once:63}],105:[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=l,this.end=p,t=4;break;case"utf8":this.fillLast=c,t=4;break;case"base64":this.text=u,this.end=f,t=3;break;default:return this.write=h,void(this.end=m);}this.lastNeed=0,this.lastTotal=0,this.lastChar=g.allocUnsafe(t)}function s(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=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 p(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function u(e,t){var 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 f(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>i,i=(i+5)%8,s=s<>8-i,r++):(s=31&a>>8-(i+5),i=(i+5)%8,0==i&&r++),d[o]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(s),o++}for(r=o;r=n?(n=(n+5)%8,0==n?(a|=r,c[d]=a,d++,a=0):a|=255&r<<8-n):(n=(n+5)%8,a|=255&r>>>n,c[d]=a,d++,a=255&r<<8-n);else throw new Error("Invalid input - it is not base32 encoded string")}return c.slice(0,d)}}).call(this,e("buffer").Buffer)},{buffer:23}],108:[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=e.length||0>t)){var n=e.pop();if(t","\"","`"," ","\r","\n","\t"]),p=["'"].concat(l),u=["%","/","?",";","#"].concat(p),f=["/","?","#"],h=/^[+a-z0-9A-Z_-]{0,63}$/,m=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,g={javascript:!0,"javascript:":!0},_={javascript:!0,"javascript:":!0},y={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},b=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&&r255?"":this.hostname.toLowerCase(),U||(this.hostname=s.toASCII(this.hostname));var N=this.port?":"+this.port:"",F=this.hostname||"";this.host=F+N,this.href+=this.host,U&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==v[0]&&(v="/"+v))}if(!g[E])for(var L=0,P=p.length,D;Lb.length&&b.unshift(""),n.pathname=b.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 w=n.pathname||"",p=n.search||"";n.path=w+p}return n.slashes=n.slashes||e.slashes,n.href=n.format(),n}var s=n.pathname&&"/"===n.pathname.charAt(0),k=e.host||e.pathname&&"/"===e.pathname.charAt(0),x=k||s||n.host&&e.pathname,v=x,S=n.pathname&&n.pathname.split("/")||[],b=e.pathname&&e.pathname.split("/")||[],C=n.protocol&&!y[n.protocol];if(C&&(n.hostname="",n.port=null,n.host&&(""===S[0]?S[0]=n.host:S.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===b[0]?b[0]=e.host:b.unshift(e.host)),e.host=null),x=x&&(""===b[0]||""===S[0])),k)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,S=b;else if(b.length)S||(S=[]),S.pop(),S=S.concat(b),n.search=e.search,n.query=e.query;else if(!d.isNullOrUndefined(e.search)){if(C){n.hostname=n.host=S.shift();var E=n.host&&0=e.metadata_size?this.emit("warning",new Error("Peer gave invalid metadata size")):void(this._metadataSize=e.metadata_size,this._numPieces=o(this._metadataSize/p),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"))},t.prototype.onMessage=function(e){var t,r;try{var o=e.toString(),i=o.indexOf("ee")+2;t=n.decode(o.substring(0,i)),r=e.slice(i)}catch(e){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,r,t.total_size);break;case 2:this._onReject(t.piece);}},t.prototype.fetch=function(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())},t.prototype.cancel=function(){this._fetching=!1},t.prototype.setMetadata=function(e){if(this._metadataComplete)return!0;s("set metadata");try{var t=n.decode(e).info;t&&(e=n.encode(t))}catch(e){}return this._infoHash&&this._infoHash!==c.sync(e)?!1:(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",n.encode({info:n.decode(this.metadata)})),!0)},t.prototype._send=function(e,t){var r=n.encode(e);i.isBuffer(t)&&(r=i.concat([r,t])),this._wire.extended("ut_metadata",r)},t.prototype._request=function(e){this._send({msg_type:0,piece:e})},t.prototype._data=function(e,t,n){var r={msg_type:1,piece:e};"number"==typeof n&&(r.total_size=n),this._send(r,t)},t.prototype._reject=function(e){this._send({msg_type:2,piece:e})},t.prototype._onRequest=function(e){if(!this._metadataComplete)return void this._reject(e);var t=e*p,n=t+p;n>this._metadataSize&&(n=this._metadataSize);var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)},t.prototype._onData=function(e,t){t.length>p||(t.copy(this.metadata,e*p),this._bitfield.set(e),this._checkDone())},t.prototype._onReject=function(e){0=e._entries[e._index][e._countName]&&(e._index++,e._offset=0),e.value=e._entries[e._index]},o.prototype._processMoov=function(e){var t=this,r=e.traks;t._tracks=[],t._hasVideo=!1,t._hasAudio=!1;for(var o=0;o=a.stsz.entries.length)break;if(g++,y+=C,g>=S.samplesPerChunk){g=0,y=0,_++;var L=a.stsc.entries[b+1];L&&_+1>=L.firstChunk&&b++}w+=E,k.inc(),x&&x.inc(),I&&v++}i.mdia.mdhd.duration=0,i.tkhd.duration=0;var T=S.sampleDescriptionId,A={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:d(),ctts:d(),stsc:d(),stsz:d(),stco:d(),stss:d()}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:i.tkhd.trackId,defaultSampleDescriptionIndex:T,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};t._tracks.push({trackId:i.tkhd.trackId,timeScale:i.mdia.mdhd.timeScale,samples:h,currSample:null,currTime:null,moov:A,mime:f})}if(0===t._tracks.length)return void t.emit("error",new Error("no playable tracks"));e.mvhd.duration=0,t._ftyp={type:"ftyp",brand:"iso5",brandVersion:0,compatibleBrands:["iso5"]};var U=p.encode(t._ftyp),R=t._tracks.map(function(e){var t=p.encode(e.moov);return{mime:e.mime,init:n.concat([U,t])}});t.emit("ready",R)},o.prototype.seek=function(e){var t=this;if(!t._tracks)throw new Error("Not ready yet; wait for 'ready' event");t._fileStream&&(t._fileStream.destroy(),t._fileStream=null);var n=-1;if(t._tracks.map(function(r,o){function i(e){s.destroyed||s.box(e.moof,function(n){if(n)return t.emit("error",n);if(!s.destroyed){var d=r.inStream.slice(e.ranges);d.pipe(s.mediaData(e.length,function(e){if(e)return t.emit("error",e);if(!s.destroyed){var n=t._generateFragment(o);return n?void i(n):s.finalize()}}))}})}r.outStream&&r.outStream.destroy(),r.inStream&&(r.inStream.destroy(),r.inStream=null);var s=r.outStream=l.encode(),d=t._generateFragment(o,e);return d?void((-1==n||d.ranges[0].startd&&(d=-d-2);!o.samples[d].sync;)d--;return d};o.prototype._generateFragment=function(e,t){var n=this,r=n._tracks[e],o;if(o=void 0===t?r.currSample:n._findSampleBefore(e,t),o>=r.samples.length)return null;for(var i=r.samples[o].dts,s=0,d=[],a=o,c;a=r.timeScale*1));a++){s+=c.size;var l=d.length-1;0>l||d[l].end!==c.offset?d.push({start:c.offset,end:c.offset+c.size}):d[l].end+=c.size}return r.currSample=a,{moof:n._generateMoof(e,o,a),ranges:d,length:s}},o.prototype._generateMoof=function(e,t,n){for(var r=this,o=r._tracks[e],i=[],s=t,d;se.length)throw new Error("pump requires two streams per minimum");var n=e.map(function(o,s){var i=s