(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,V),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,V),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 s=r.from+r.offset,a=r.to,c={},l=0,p=t(s,a,c);lo));){if(d._request(e,o,!1))return;c[o]=!0,l+=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>G)return function(){return!0};var n=s(1,e.requests.length)*R.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;ap));){for(;d._request(e,p,d._critical[p]||n););if(e.requests.length=c)){var l=a(e,K);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=G||2*l>o||l>r||(a=c,r=l)}}if(!a)return!1;for(d=0;d=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 _=g.indexOf(null);-1===_&&(_=g.length),g[_]=e;var y=h.chunkOffset(m),b=u?h.chunkLengthRemaining(m):h.chunkLength(m);return e.request(t,y,b,function n(r,o){if(!l.destroyed){if(!l.ready)return l.once("ready",function(){n(r,o)});if(g[_]===e&&(g[_]=null),h!==l.pieces[t])return s();if(r)return l._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,y,b,e.remoteAddress+":"+e.remotePort,r.message),u?h.cancelRemaining(m):h.cancel(m),void s();if(l._debug("got piece %s (offset: %s length: %s) from %s",t,y,b,e.remoteAddress+":"+e.remotePort),!h.set(m,o,e))return s();var i=h.flush();O(i,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,i),l.wires.forEach(function(e){e.have(t)}),l._checkDone()&&!l.destroyed&&l.discovery.complete()}else l.pieces[t]=new R(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=C.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>=Y.length)return void e._debug("conn %s closed: will not re-add (max %s attempts)",t.addr,Y.length);var n=Y[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":128,"./file":2,"./peer":3,"./rarity-map":4,"./server":21,_process:69,"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-numeric-range":64,"parse-torrent":65,path:66,pump:70,"random-iterate":75,"run-parallel":90,"run-parallel-limit":89,"simple-get":94,"simple-sha1":96,speedometer:98,"torrent-discovery":111,"torrent-piece":112,uniq:115,ut_metadata:119,ut_pex:21,xtend:125,"xtend/mutable":126}],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":128,bitfield:13,"bittorrent-protocol":14,debug:35,inherits:44,"safe-buffer":92,"simple-get":94,"simple-sha1":96}],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>16,a[d++]=255&f>>8,a[d++]=255&f;return 2===s&&(f=p[e.charCodeAt(l)]<<2|p[e.charCodeAt(l+1)]>>4,a[d++]=255&f),1===s&&(f=p[e.charCodeAt(l)]<<10|p[e.charCodeAt(l+1)]<<4|p[e.charCodeAt(l+2)]>>2,a[d++]=255&f>>8,a[d++]=255&f),a}function a(e){return l[63&e>>18]+l[63&e>>12]+l[63&e>>6]+l[63&e]}function d(e,t,n){for(var r=[],o=t,s;oa?a:s+o));return 1===n?(c=e[t-1],r.push(l[c>>2]+l[63&c<<4]+"==")):2===n&&(c=(e[t-2]<<8)+e[t-1],r.push(l[c>>10]+l[63&c>>4]+l[63&c<<2]+"=")),r.join("")}n.byteLength=function(e){var t=r(e),n=t[0],o=t[1];return 3*(n+o)/4-o},n.toByteArray=s,n.fromByteArray=c;for(var l=[],p=[],u="undefined"==typeof Uint8Array?Array:Uint8Array,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=0,m=f.length;ha&&48<=a){r=10*r+(a-48);continue}if(s!==t||43!==a){if(s===t&&45===a){o=-1;continue}if(46===a)break;throw new Error("not a number: buffer["+s+"] = "+a)}}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,s=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]:d.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":86}],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(2147483647e)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=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647 .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 F(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 F(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 U(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 R(this,t,n);case"base64":return B(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===a?e[t]:e.readUInt16BE(t*a)}var a=1,d=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;a=2,d/=2,c/=2,n/=2}var l;if(o){var p=-1;for(l=n;ld&&(n=d-c),l=n;0<=l;l--){for(var u=!0,f=0;fo&&(r=o)):r=o;var s=t.length;r>s/2&&(r=s/2);for(var a=0,d;as&&(a=s):2===c?(l=e[o+1],128==(192&l)&&(f=(31&s)<<6|63&l,127f||57343f&&(a=f))):void 0}null===a?(a=65533,c=1):65535>>10),a=56320|1023&a),r.push(a),o+=c}return T(r)}function T(t){var n=t.length;if(n<=4096)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 N(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||N(e,t,n,4,34028234663852886e22,-34028234663852886e22),Q.write(e,t,n,r,23,4),n+4}function M(e,t,n,r,o){return t=+t,n>>>=0,o||N(e,t,n,8,17976931348623157e292,-17976931348623157e292),Q.write(e,t,n,r,52,8),n+8}function j(e){if(e=e.split("=")[0],e=e.trim().replace(J,""),2>e.length)return"";for(;0!=e.length%4;)e+="=";return e}function D(e){return 16>e?"0"+e.toString(16):e.toString(16)}function F(e,t){t=t||1/0;for(var n=e.length,r=null,o=[],s=0,a;sa){if(!r){if(56319a){-1<(t-=3)&&o.push(239,191,189),r=a;continue}a=(r-55296<<10|a-56320)+65536}else r&&-1<(t-=3)&&o.push(239,191,189);if(r=null,128>a){if(0>(t-=1))break;o.push(a)}else if(2048>a){if(0>(t-=2))break;o.push(192|a>>6,128|63&a)}else if(65536>a){if(0>(t-=3))break;o.push(224|a>>12,128|63&a>>6,128|63&a)}else if(1114112>a){if(0>(t-=4))break;o.push(240|a>>18,128|63&a>>12,128|63&a>>6,128|63&a)}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),s=o>>8,a=o%256,n.push(a),n.push(s);return n}function V(e){return Y.toByteArray(j(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;o.kMaxLength=2147483647,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,s=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 E(this,e,t,n);case"base64":return C(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return I(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0;}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};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,a=0;++a=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,s=1,a=this[e+--o];0=s&&(a-=n(2,8*t)),a},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 a=1,d=0;for(this[t]=255&e;++d>>=0,r>>>=0,!o){var s=n(2,8*r)-1;H(this,e,t,r,s,0)}var a=r-1,d=1;for(this[t+a]=255&e;0<=--a&&(d*=256);)this[t+a]=255&e/d;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 a=0,d=1,c=0;for(this[t]=255&e;++ae&&0===c&&0!==this[t+a-1]&&(c=1),this[t+a]=255&(e/d>>0)-c;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 a=r-1,d=1,c=0;for(this[t+a]=255&e;0<=--a&&(d*=256);)0>e&&0===c&&0!==this[t+a+1]&&(c=1),this[t+a]=255&(e/d>>0)-c;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 M(this,e,t,!0,n)},c.prototype.writeDoubleBE=function(e,t,n){return M(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)){a.warned=!0;var d=new Error("Possible EventEmitter memory leak detected. "+a.length+" \""+(t+"\" listeners added. Use emitter.setMaxListeners() to increase limit."));d.name="MaxListenersExceededWarning",d.emitter=e,d.type=t,d.count=a.length,"object"==typeof console&&console.warn&&console.warn("%s: %s",d.name,d.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,f;if(f=this._events,f)t=t&&null==f.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,a||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),s;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,a,d,c){if(i)return t.fill(s,a,d,c);if("number"==typeof s)return r(t,s,a,d);if("string"==typeof s){if("string"==typeof a?(c=a,a=0,d=t.length):"string"==typeof d&&(c=d,d=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,a,d);if(n(s))return r(t,s.charCodeAt(0),a,d);s=new e(s,c)}return e.isBuffer(s)?o(t,s,a,d):r(t,0,a,d)}}).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,a){if("number"==typeof t)throw new TypeError("\"value\" argument must not be a number");return n(t)?r(t,i,a):"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){function s(t){a.destroyed||(e.put(d,t),d+=1)}var a=this;if(!(a instanceof n))return new n(e,t,o);if(i.Writable.call(a,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");a._blockstream=new r(t,{zeroPadding:!1}),a._blockstream.on("data",s).on("error",function(e){a.destroy(e)});var d=0;a.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":86}],32:[function(e,n){n.exports=function(e,n,r){for(var o=1/0,s=0,a=n.length-1,d,c,l;s<=a&&(d=s+(a-s>>1),l=n[d]-e,0>l?s=d+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(a(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":86,"typedarray-to-buffer":113}],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,g=o?-1:1,d=t[r+h],_,y;for(h+=g,_=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,w=p?1:-1,d=0>a||0===a&&0>1/a?1:0,s,k,x;for(a=t(a),isNaN(a)||a===1/0?(k=isNaN(a)?1:0,s=g):(s=r(Math.log(a)/Math.LN2),1>a*(x=n(2,-s))&&(s--,x*=2),a+=1<=s+_?y/x:y*n(2,1-_),2<=a*x&&(s++,x/=2),s+_>=g?(k=0,s=g):1<=s+_?(k=(a*x-1)*n(2,u),s+=_):(k=a*n(2,_-1)*n(2,u),s=0));8<=u;o[l+b]=255&k,b+=w,k/=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 a;if(t.xt){var d=Array.isArray(t.xt)?t.xt:[t.xt];d.forEach(function(e){if(a=e.match(/^urn:btih:(.{40})/))t.infoHash=a[1].toLowerCase();else if(a=e.match(/^urn:btih:(.{32})/)){var n=r.decode(a[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<=a)&&(r=a)}var d=r-n;return 0>d&&(d=0),d}},{inherits:44,"readable-stream":86,"to-arraybuffer":110}],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||1/0,this.length!==1/0&&(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,a=t.length||o.length-s;r(n,null,o.slice(s,a+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:69}],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),d&&(c+="."+d)),{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;sa&&(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){d._encode(e,t,l),l+=d.encode.bytes})}else e[n]&&(d._encode(e[n],t,l),l+=d.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){d._encode(e,t,l),l+=d.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 d.encode.bytes=l-n,t},d.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),a=t+8;if(1===o){if(16>n-t)return 16;o=r.decode(e,a),a+=8}var d,c;return s.fullBoxes[i]&&(d=e.readUInt8(a),c=16777215&e.readUInt32BE(a),a+=4),{length:o,headersLen:a-t,contentLen:o-(a-t),type:i,version:d,flags:c}},d.decode=function(e,t,n){t=t||0,n=n||e.length;var r=d.readHeaders(e,t,n);if(!r||r.length>n-t)throw new Error("Data too short");return d.decodeWithoutHeaders(r,e,t+r.headersLen,t+r.length)},d.decodeWithoutHeaders=function(e,t,n,r){n=n||0,r=r||t.length;var o=e.type,a={};if(c[o]){a.otherBoxes=[];for(var l=c[o],p=n,u;8<=r-p;)if(u=d.decode(t,p,r),p+=u.length,0<=l.indexOf(u.type))a[u.type]=u;else if(0<=l.indexOf(u.type+"s")){var f=u.type+"s",h=a[f]=a[f]||[];h.push(u)}else a.otherBoxes.push(u)}else if(s[o]){var m=s[o].decode;a=m(t,n,r)}else a.buffer=i(t.slice(n,r));return a.length=e.length,a.contentLen=e.contentLen,a.type=e.type,a.version=e.version,a.flags=e.flags,a},d.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+=d.encodingLength(e)})}else if(e[t]){var o=e[t];o.type=t,n+=d.encodingLength(o)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){n+=d.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>a&&(n+=8),e.length=n,n}},{"./boxes":54,"buffer-alloc":27,"buffer-from":29,uint64be:114}],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"),a=e("next-event"),d=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.lengthn?[]: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}],68:[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,a,d;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(a=Array(s-1),d=0;de.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+=E(e),t}).join("")}function u(e){return 10>e-48?e-22:26>e-65?e-65:26>e-97?e-97:36}function f(e,t){return e+22+75*(26>e)-((0!=t)<<5)}function h(e,t,n){var r=0;for(e=n?S(e/700):e>>1,e+=S(e/t);455f&&(f=0),m=0;m=o&&a("invalid-input"),x=u(e.charCodeAt(g++)),(36<=x||x>S((2147483647-s)/y))&&a("overflow"),s+=x*y,v=b<=c?1:b>=c+26?26:b-c,xS(2147483647/E)&&a("overflow"),y*=E}l=r.length+1,c=h(s-_,l,0==_),S(s/l)>2147483647-d&&a("overflow"),d+=S(s/l),s%=l,r.splice(s++,0,d)}return p(r)}function g(e){var r=[],o,i,s,d,c,p,u,g,_,y,b,w,x,v,C;for(e=l(e),w=e.length,o=128,i=0,c=72,p=0;pb&&r.push(E(b));for(s=d=r.length,d&&r.push("-");s=o&&bS((2147483647-i)/x)&&a("overflow"),i+=(u-o)*x,o=u,p=0;p=c+26?26:_-c,g= 0x80 (not a basic code point)","invalid-input":"Invalid input"},S=r,E=e,C,I;if(C={version:"1.4.1",ucs2:{decode:l,encode:p},decode:m,encode:g,toASCII:function(e){return c(e,function(e){return k.test(e)?"xn--"+g(e):e})},toUnicode:function(e){return c(e,function(e){return w.test(e)?m(e.slice(4).toLowerCase()):e})}},"function"==typeof i&&"object"==typeof i.amd&&i.amd)i("punycode",function(){return C});else if(!(_&&y))s.punycode=C;else if(n.exports==_)y.exports=C;else for(I in C)C.hasOwnProperty(I)&&(_[I]=C[I])})(this)}).call(this,"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global)},{}],72:[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 a={};if("string"!=typeof e||0===e.length)return a;var d=/\+/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(d>e.length){r._position+=e.length,c=0===a?e:e.slice(a),o=i.stream.write(c)&&o;break}r._position+=d,c=0===a&&d===e.length?e:e.slice(a,d),o=i.stream.write(c)&&o,i.last&&i.stream.end(),e=e.slice(d),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":86}],78:[function(e,t){"use strict";function n(e){return this instanceof n?void(d.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 a=e("core-util-is");a.inherits=e("inherits");var d=e("./_stream_readable"),c=e("./_stream_writable");a.inherits(n,d);for(var l=s(c.prototype),p=0,u;p>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function m(e,t){return 0>=e||0===t.length&&t.ended?0:t.objectMode?1:e===e?(e>t.highWaterMark&&(t.highWaterMark=h(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0)):t.flowing&&t.length?t.buffer.head.data.length:t.length}function g(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,_(e)}}function _(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(W("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?U.nextTick(y,e):y(e))}function y(e){W("emit readable"),e.emit("readable"),E(e)}function b(e,t){t.readingMore||(t.readingMore=!0,U.nextTick(w,e,t))}function w(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=I(e,t.buffer,t.decoder),n}function I(e,t,n){var r;return es.length?s.length:e;if(i+=a===s.length?s:s.slice(0,e),e-=a,0===e){a===s.length?(++o,t.head=r.next?r.next:t.tail=null):(t.head=r,r.data=s.slice(a));break}++o}return t.length-=o,i}function L(e,t){var r=M.allocUnsafe(e),o=t.head,i=1;for(o.data.copy(r),e-=o.data.length;o=o.next;){var s=o.data,a=e>s.length?s.length:e;if(s.copy(r,r.length-e,0,a),e-=a,0===e){a===s.length?(++i,t.head=o.next?o.next:t.tail=null):(t.head=o,o.data=s.slice(a));break}++i}return t.length-=i,r}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 o=t.needReadable;W("need readable",o),(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":92,util:21}],84:[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":68}],85:[function(e,t){t.exports=e("events").EventEmitter},{events:24}],86:[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":78,"./lib/_stream_passthrough.js":79,"./lib/_stream_readable.js":80,"./lib/_stream_transform.js":81,"./lib/_stream_writable.js":82}],87:[function(e,t,n){function r(e,t,n,r){function i(){S.removeEventListener("loadstart",i),n.autoplay&&S.play()}function a(){S.removeEventListener("canplay",a),r(null,S)}function u(){o(e,function(e,n){return e?k(e):void(".pdf"===x?(S=t("object"),S.setAttribute("typemustmatch",!0),S.setAttribute("type","application/pdf"),S.setAttribute("data",n)):(S=t("iframe"),S.sandbox="allow-forms allow-scripts",S.src=n),r(null,S))})}function k(t){t.message="Error rendering file \""+e.name+"\": "+t.message,d(t.message),r(t)}var x=p.extname(e.name).toLowerCase(),v=0,S;0<=g.indexOf(x)?function(){function r(){d("Use `videostream` package for "+e.name),_(),S.addEventListener("error",u),S.addEventListener("loadstart",i),S.addEventListener("canplay",a),f(e,S)}function c(){d("Use MediaSource API for "+e.name),_(),S.addEventListener("error",g),S.addEventListener("loadstart",i),S.addEventListener("canplay",a);var t=new l(S),n=t.createWriteStream(s(e.name));e.createReadStream().pipe(n),v&&(S.currentTime=v)}function p(){d("Use Blob URL for "+e.name),_(),S.addEventListener("error",k),S.addEventListener("loadstart",i),S.addEventListener("canplay",a),o(e,function(e,t){return e?k(e):void(S.src=t,v&&(S.currentTime=v))})}function u(e){d("videostream error: fallback to MediaSource API: %o",e.message||e),S.removeEventListener("error",u),S.removeEventListener("canplay",a),c()}function g(t){return d("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>n.maxBlobLength?(d("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),k(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")"))):void(S.removeEventListener("error",g),S.removeEventListener("canplay",a),p())}function _(){S||(S=t(y),S.addEventListener("progress",function(){v=S.currentTime}))}var y=0<=m.indexOf(x)?"video":"audio";w?0<=h.indexOf(x)?r():c():p()}():0<=_.indexOf(x)?function(){S=t("audio"),o(e,function(e,t){return e?k(e):void(S.addEventListener("error",k),S.addEventListener("loadstart",i),S.addEventListener("canplay",a),S.src=t)})}():0<=y.indexOf(x)?function(){S=t("img"),o(e,function(t,n){return t?k(t):void(S.src=n,S.alt=e.name,r(null,S))})}():0<=b.indexOf(x)?u():function(){function t(){c(n)?(d("File extension \"%s\" appears ascii, so will render.",x),u()):(d("File extension \"%s\" appears non-ascii, will not render.",x),r(new Error("Unsupported file type \""+x+"\": Cannot append to DOM")))}d("Unknown file extension \"%s\" - will attempt to render into iframe",x);var n="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){n+=e}).on("end",t).on("error",r)}()}function o(e,t){var r=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 a(e){null==e.autoplay&&(e.autoplay=!1),null==e.muted&&(e.muted=!1),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=200000000)}n.render=function(e,t,n,o){"function"==typeof n&&(o=n,n={}),n||(n={}),o||(o=function(){}),i(e),a(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=d(e);return n.autoplay&&(r.autoplay=!0),n.muted&&(r.muted=!0),n.controls&&(r.controls=!0),t.appendChild(r),r}function d(e){var n=document.createElement(e);return t.appendChild(n),n}function c(e,t){e&&t&&t.remove(),o(e,t)}if("function"==typeof n&&(o=n,n={}),n||(n={}),o||(o=function(){}),i(e),a(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):d(e)},n,c)},n.mime=e("./lib/mime.json");var d=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="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":88,debug:35,"is-ascii":45,mediasource:52,path:66,"stream-to-blob-url":103,videostream:123}],88:[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"}},{}],89:[function(e,t){(function(e){t.exports=function(t,n,r){function o(t){function n(){r&&r(t,a),r=null}i?e.nextTick(n):n()}function s(e,n,r){if(a[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=void 0;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],a=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,d=a,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)+(a&c|~a&p))+(0|(0|g+f)+1518500249),f=p,p=c,c=a<<30|a>>>2,a=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)+(a&c|~a&p))+(0|(0|g+f)+1518500249),f=p,p=c,c=a<<30|a>>>2,a=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)+(a^c^p))+(0|(0|g+f)+1859775393),f=p,p=c,c=a<<30|a>>>2,a=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)+(a&c|a&p|c&p))+(0|(0|g+f)-1894007588),f=p,p=c,c=a<<30|a>>>2,a=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)+(a^c^p))+(0|(0|g+f)-899497514),f=p,p=c,c=a<<30|a>>>2,a=i,i=m,r[o>>2]=g;i=0|i+s,a=0|a+d,c=0|c+l,p=0|p+u,f=0|f+h}r[t+320>>2]=i,r[t+324>>2]=a,r[t+328>>2]=c,r[t+332>>2]=p,r[t+336>>2]=f}}}},function(e){var t=this,n=void 0;"undefined"!=typeof self&&"undefined"!=typeof self.FileReaderSync&&(n=new self.FileReaderSync);var r=function(e,t,n,r,o,s){var a=s%4,d=(o+a)%4,c=o-d,l;switch(a){case 0:t[s]=e.charCodeAt(r+3);case 1:t[0|s+1-(a<<1)]=e.charCodeAt(r+2);case 2:t[0|s+2-(a<<1)]=e.charCodeAt(r+1);case 3:t[0|s+3-(a<<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(d){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 a=s%4,d=(o+a)%4,c=o-d,l;switch(a){case 0:t[s]=e[r+3];case 1:t[0|s+1-(a<<1)]=e[r+2];case 2:t[0|s+2-(a<<1)]=e[r+1];case 3:t[0|s+3-(a<<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(d){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,a){var d=void 0,c=a%4,l=(s+c)%4,p=s-l,u=new Uint8Array(n.readAsArrayBuffer(e.slice(o,o+s)));switch(c){case 0:t[a]=u[3];case 1:t[0|a+1-(c<<1)]=u[2];case 2:t[0|a+2-(c<<1)]=u[1];case 3:t[0|a+3-(c<<1)]=u[0];}if(!(s>2]=u[d]<<24|u[d+1]<<16|u[d+2]<<8|u[d+3];switch(l){case 3:t[0|a+p+1]=u[p+2];case 2:t[0|a+p+2]=u[p+1];case 1:t[0|a+p+3]=u[p];}}};e.exports=function(e,n,s,a,d,c){if("string"==typeof e)return r(e,n,s,a,d,c);if(e instanceof Array)return o(e,n,s,a,d,c);if(t&&t.Buffer&&t.Buffer.isBuffer(e))return o(e,n,s,a,d,c);if(e instanceof ArrayBuffer)return o(new Uint8Array(e),n,s,a,d,c);if(e.buffer instanceof ArrayBuffer)return o(new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n,s,a,d,c);if(e instanceof Blob)return i(e,n,s,a,d,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,a=function(){function e(){r(this,e),this._rusha=new o,this._rusha.resetState()}return e.prototype.update=function(e){return this._rusha.append(e),this},e.prototype.digest=function e(t){var e=this._rusha.rawEnd().buffer;if(!t)return e;if("hex"===t)return s(e);throw new Error("unsupported digest encoding")},e}();e.exports=function(){return new a}}])})},{}],92:[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}],93:[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}],94:[function(e,t){(function(n){function r(e,t){if(e=Object.assign({maxRedirects:10},"string"==typeof e?{url:e}:e),t=d(t),e.url){const{hostname:t,port:n,protocol:r,auth:o,path:i}=l.parse(e.url);delete e.url,t||n||r||o?Object.assign(e,{hostname:t,port:n,protocol:r,auth:o,path:i}):e.path=i}const o={"accept-encoding":"gzip, deflate"};e.headers&&Object.keys(e.headers).forEach(t=>o[t.toLowerCase()]=e.headers[t]),e.headers=o;let u;e.body?u=e.json&&!p(e.body)?JSON.stringify(e.body):e.body:e.form&&(u="string"==typeof e.form?e.form:c.stringify(e.form),e.headers["content-type"]="application/x-www-form-urlencoded"),delete e.body,delete e.form,u&&(!e.method&&(e.method="POST"),!p(u)&&(e.headers["content-length"]=n.byteLength(u)),e.json&&(e.headers["content-type"]="application/json")),e.json&&(e.headers.accept="application/json"),e.method&&(e.method=e.method.toUpperCase());const f="https:"===e.protocol?a:s,h=f.request(e,n=>{if(300<=n.statusCode&&400>n.statusCode&&n.headers.location)return e.url=n.headers.location,delete e.headers.host,n.resume(),"POST"===e.method&&[301,302].includes(n.statusCode)&&(e.method="GET",delete e.headers["content-length"],delete e.headers["content-type"]),0==e.maxRedirects--?t(new Error("too many redirects")):r(e,t);const o="function"==typeof i&&"HEAD"!==e.method;t(null,o?i(n):n)});return h.on("timeout",()=>{h.abort(),t(new Error("Request timed out"))}),h.on("error",t),p(u)?u.on("error",t).pipe(h):h.end(u),h}t.exports=r;const o=e("simple-concat"),i=e("decompress-response"),s=e("http"),a=e("https"),d=e("once"),c=e("querystring"),l=e("url"),p=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;r.concat=(e,t)=>r(e,(n,r)=>n?t(n):void o(r,(n,o)=>{if(n)return t(n);if(e.json)try{o=JSON.parse(o.toString())}catch(e){return t(e,r,o)}t(null,r,o)})),["get","post","put","patch","head","delete"].forEach(e=>{r[e]=(t,n)=>("string"==typeof t&&(t={url:t}),r(Object.assign({method:e.toUpperCase()},t),n))})}).call(this,e("buffer").Buffer)},{buffer:23,"decompress-response":21,http:99,https:25,once:63,querystring:74,"simple-concat":93,url:117}],95:[function(e,t){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(t._id=c(4).toString("hex").slice(0,7),t._debug("new peer %o",e),e=Object.assign({allowHalfOpen:!1},e),l.Duplex.call(t,e),t.channelName=e.initiator?e.channelName||c(20).toString("hex"):null,t._isChromium="undefined"!=typeof window&&!!window.webkitRTCPeerConnection,t.initiator=e.initiator||!1,t.channelConfig=e.channelConfig||r.channelConfig,t.config=e.config||r.config,t.constraints=t._transformConstraints(e.constraints||r.constraints),t.offerConstraints=t._transformConstraints(e.offerConstraints||{}),t.answerConstraints=t._transformConstraints(e.answerConstraints||{}),t.sdpTransform=e.sdpTransform||function(e){return e},t.streams=e.streams||(e.stream?[e.stream]:[]),t.trickle=void 0===e.trickle||e.trickle,t.destroyed=!1,t.connected=!1,t.remoteAddress=void 0,t.remoteFamily=void 0,t.remotePort=void 0,t.localAddress=void 0,t.localPort=void 0,t._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:a(),!t._wrtc)if("undefined"==typeof window)throw o("No WebRTC support: Specify `opts.wrtc` option in this environment","ERR_WEBRTC_SUPPORT");else throw o("No WebRTC support: Not a supported browser","ERR_WEBRTC_SUPPORT");t._pcReady=!1,t._channelReady=!1,t._iceComplete=!1,t._channel=null,t._pendingCandidates=[],t._isNegotiating=!1,t._batchedNegotiation=!1,t._queuedNegotiation=!1,t._sendersAwaitingStable=[],t._senderMap=new WeakMap,t._remoteTracks=[],t._remoteStreams=[],t._chunk=null,t._cb=null,t._interval=null,t._pc=new t._wrtc.RTCPeerConnection(t.config,t.constraints),t._isReactNativeWebrtc="number"==typeof t._pc._peerConnectionId,t._pc.oniceconnectionstatechange=function(){t._onIceStateChange()},t._pc.onicegatheringstatechange=function(){t._onIceStateChange()},t._pc.onsignalingstatechange=function(){t._onSignalingStateChange()},t._pc.onicecandidate=function(e){t._onIceCandidate(e)},t.initiator?t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)}):t._pc.ondatachannel=function(e){t._setupData(e)},"addTrack"in t._pc&&(t.streams&&t.streams.forEach(function(e){t.addStream(e)}),t._pc.ontrack=function(e){t._onTrack(e)}),t.initiator&&t._needsNegotiation(),t._onFinishBound=function(){t._onFinish()},t.once("finish",t._onFinishBound)}function o(e,t){var n=new Error(e);return n.code=t,n}function i(){}t.exports=r;var s=e("debug")("simple-peer"),a=e("get-browser-rtc"),d=e("inherits"),c=e("randombytes"),l=e("readable-stream"),p=65536;d(r,l.Duplex),r.WEBRTC_SUPPORT=!!a(),r.config={iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:global.stun.twilio.com:3478?transport=udp"}]},r.constraints={},r.channelConfig={},Object.defineProperty(r.prototype,"bufferSize",{get:function(){var e=this;return e._channel&&e._channel.bufferedAmount||0}}),r.prototype.address=function(){var e=this;return{port:e.localPort,family:"IPv4",address:e.localAddress}},r.prototype.signal=function(e){var t=this;if(t.destroyed)throw o("cannot signal after peer is destroyed","ERR_SIGNALING");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}t._debug("signal()"),e.renegotiate&&(t._debug("got request to renegotiate"),t._needsNegotiation()),e.candidate&&(t._pc.remoteDescription&&t._pc.remoteDescription.type?t._addIceCandidate(e.candidate):t._pendingCandidates.push(e.candidate)),e.sdp&&t._pc.setRemoteDescription(new t._wrtc.RTCSessionDescription(e),function(){t.destroyed||(t._pendingCandidates.forEach(function(e){t._addIceCandidate(e)}),t._pendingCandidates=[],"offer"===t._pc.remoteDescription.type&&t._createAnswer())},function(e){t.destroy(o(e,"ERR_SET_REMOTE_DESCRIPTION"))}),e.sdp||e.candidate||e.renegotiate||t.destroy(o("signal() called with invalid signal data","ERR_SIGNALING"))},r.prototype._addIceCandidate=function(e){var t=this;try{t._pc.addIceCandidate(new t._wrtc.RTCIceCandidate(e),i,function(e){t.destroy(o(e,"ERR_ADD_ICE_CANDIDATE"))})}catch(e){t.destroy(o("error adding candidate: "+e.message,"ERR_ADD_ICE_CANDIDATE"))}},r.prototype.send=function(e){var t=this;t._channel.send(e)},r.prototype.addStream=function(e){var t=this;t._debug("addStream()"),e.getTracks().forEach(function(n){t.addTrack(n,e)})},r.prototype.addTrack=function(e,t){var n=this;n._debug("addTrack()");var r=n._pc.addTrack(e,t),o=n._senderMap.get(e)||new WeakMap;o.set(t,r),n._senderMap.set(e,o),n._needsNegotiation()},r.prototype.removeTrack=function(e,t){var n=this;n._debug("removeSender()");var r=n._senderMap.get(e),o=r?r.get(t):null;o||n.destroy(new Error("Cannot remove track that was never added."));try{n._pc.removeTrack(o)}catch(e){"NS_ERROR_UNEXPECTED"===e.name?n._sendersAwaitingStable.push(o):n.destroy(e)}},r.prototype.removeStream=function(e){var t=this;t._debug("removeSenders()"),e.getTracks().forEach(function(n){t.removeTrack(n,e)})},r.prototype._needsNegotiation=function(){var e=this;e._debug("_needsNegotiation");e._batchedNegotiation||(e._batchedNegotiation=!0,setTimeout(function(){e._batchedNegotiation=!1,e._debug("starting batched negotiation"),e.negotiate()},0))},r.prototype.negotiate=function(){var e=this;e.initiator?e._isNegotiating?(e._queuedNegotiation=!0,e._debug("already negotiating, queueing")):(e._debug("start negotiation"),e._createOffer()):(e._debug("requesting negotiation from initiator"),e.emit("signal",{renegotiate:!0})),e._isNegotiating=!0},r.prototype.destroy=function(e){var t=this;t._destroy(e,function(){})},r.prototype._destroy=function(e,t){var n=this;if(!n.destroyed){if(n._debug("destroy (error: %s)",e&&(e.message||e)),n.readable=n.writable=!1,n._readableState.ended||n.push(null),n._writableState.finished||n.end(),n.destroyed=!0,n.connected=!1,n._pcReady=!1,n._channelReady=!1,n._remoteTracks=null,n._remoteStreams=null,n._senderMap=null,clearInterval(n._interval),n._interval=null,n._chunk=null,n._cb=null,n._onFinishBound&&n.removeListener("finish",n._onFinishBound),n._onFinishBound=null,n._channel){try{n._channel.close()}catch(e){}n._channel.onmessage=null,n._channel.onopen=null,n._channel.onclose=null,n._channel.onerror=null}if(n._pc){try{n._pc.close()}catch(e){}n._pc.oniceconnectionstatechange=null,n._pc.onicegatheringstatechange=null,n._pc.onsignalingstatechange=null,n._pc.onicecandidate=null,"addTrack"in n._pc&&(n._pc.ontrack=null),n._pc.ondatachannel=null}n._pc=null,n._channel=null,e&&n.emit("error",e),n.emit("close"),t()}},r.prototype._setupData=function(e){var t=this;return e.channel?void(t._channel=e.channel,t._channel.binaryType="arraybuffer","number"==typeof t._channel.bufferedAmountLowThreshold&&(t._channel.bufferedAmountLowThreshold=p),t.channelName=t._channel.label,t._channel.onmessage=function(e){t._onChannelMessage(e)},t._channel.onbufferedamountlow=function(){t._onChannelBufferedAmountLow()},t._channel.onopen=function(){t._onChannelOpen()},t._channel.onclose=function(){t._onChannelClose()},t._channel.onerror=function(e){t.destroy(o(e,"ERR_DATA_CHANNEL"))}):t.destroy(o("Data channel event is missing `channel` property","ERR_DATA_CHANNEL"))},r.prototype._read=function(){},r.prototype._write=function(e,t,n){var r=this;if(r.destroyed)return n(o("cannot write after peer is destroyed","ERR_DATA_CHANNEL"));if(r.connected){try{r.send(e)}catch(e){return r.destroy(o(e,"ERR_DATA_CHANNEL"))}r._channel.bufferedAmount>p?(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._debug("createOffer success");e.destroyed||(e.trickle||e._iceComplete?n():e.once("_iceComplete",n))},function(t){e.destroy(o(t,"ERR_SET_LOCAL_DESCRIPTION"))}))},function(t){e.destroy(o(t,"ERR_CREATE_OFFER"))},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(o(t,"ERR_SET_LOCAL_DESCRIPTION"))}))},function(t){e.destroy(o(t,"ERR_CREATE_ANSWER"))},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)&&(e._pcReady=!0,e._maybeReady()),"failed"===t&&e.destroy(o("Ice connection failed.","ERR_ICE_CONNECTION_FAILURE")),"closed"===t&&e.destroy(new Error("Ice connection closed."))}},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)}):0p)&&e._onChannelBufferedAmountLow()},r.prototype._onSignalingStateChange=function(){var e=this;e.destroyed||("stable"===e._pc.signalingState&&(e._isNegotiating=!1,e._debug("flushing sender queue",e._sendersAwaitingStable),e._sendersAwaitingStable.forEach(function(t){e.removeTrack(t),e._queuedNegotiation=!0}),e._sendersAwaitingStable=[],e._queuedNegotiation&&(e._debug("flushing negotiation queue"),e._queuedNegotiation=!1,e._needsNegotiation()),e._debug("negotiate"),e.emit("negotiate")),e._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._onTrack=function(e){var t=this;t.destroyed||e.streams.forEach(function(n){t._debug("on track"),t.emit("track",e.track,n),t._remoteTracks.push({track:e.track,stream:n});t._remoteStreams.some(function(e){return e.id===n.id})||(t._remoteStreams.push(n),setTimeout(function(){t.emit("stream",n)},0))})},r.prototype._debug=function(){var e=this,t=[].slice.call(arguments);t[0]="["+e._id+"] "+t[0],s.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:76,"readable-stream":86}],96:[function(e,t){function n(e){return a.digest(e)}function r(e,t){return l?void("string"==typeof e&&(e=o(e)),l.digest({name:"sha-1"},e).then(function(e){t(i(new Uint8Array(e)))},function(){t(n(e))})):void setTimeout(t,0,n(e))}function o(e){for(var t=e.length,n=new Uint8Array(t),r=0;r>>4).toString(16)),n.push((15&o).toString(16));return n.join("")}var s=e("rusha"),a=new s,d="undefined"==typeof window?self:window,c=d.crypto||d.msCrypto||{},l=c.subtle||c.webkitSubtle;try{l.digest({name:"sha-1"},new Uint8Array).catch(function(){l=!1})}catch(e){l=!1}t.exports=r,t.exports.sync=n},{rusha:91}],97:[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=a(4).toString("hex").slice(0,7),t._debug("new websocket: %o",e),e=Object.assign({allowHalfOpen:!1},e),d.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"),a=e("randombytes"),d=e("readable-stream"),c=e("ws"),l="function"==typeof c?c:WebSocket,p=65536;s(r,d.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:69,debug:35,inherits:44,randombytes:76,"readable-stream":86,"safe-buffer":92,ws:21}],98:[function(e,t){var n=1,r=65535,o=4,i=function(){n=n+1&r},s=setInterval(i,0|1e3/o);s.unref&&s.unref(),t.exports=function(e){var t=o*(e||5),i=[0],s=1,a=n-1&r;return function(e){var d=n-a&r;for(d>t&&(d=t),a=n;d--;)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.lengtht._pos){var s=n.substr(t._pos);if("x-user-defined"===t._charset){for(var a=new o(s.length),c=0;ct._pos&&(t.push(new o(new Uint8Array(l.result.slice(t._pos)))),t._pos=l.result.byteLength)},l.onload=function(){t.push(null)},l.readAsArrayBuffer(n);}t._xhr.readyState===d.DONE&&"ms-stream"!==t._mode&&t.push(null)}}).call(this,e("_process"),"undefined"==typeof global?"undefined"==typeof self?"undefined"==typeof window?{}:window:self:global,e("buffer").Buffer)},{"./capability":100,_process:69,buffer:23,inherits:44,"readable-stream":86}],103:[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":104}],104:[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}],105:[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}],106:[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 a(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>s,s=(s+5)%8,a=a<>8-s,r++):(a=31&c>>8-(s+5),s=(s+5)%8,0===s&&r++),d[o]="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".charCodeAt(a),o++}for(r=o;r=n?(n=(n+5)%8,0==n?(d|=r,c[a]=d,a++,d=0):d|=255&r<<8-n):(n=(n+5)%8,d|=255&r>>>n,c[a]=d,a++,d=255&r<<8-n);else throw new Error("Invalid input - it is not base32 encoded string")}return c.slice(0,a)}}).call(this,e("buffer").Buffer)},{buffer:23}],109:[function(e,t,n){(function(t,r){function o(e,t){this._id=e,this._clearFn=t}var i=e("process/browser.js").nextTick,s=Function.prototype.apply,a=Array.prototype.slice,d={},c=0;n.setTimeout=function(){return new o(s.call(setTimeout,window,arguments),clearTimeout)},n.setInterval=function(){return new o(s.call(setInterval,window,arguments),clearInterval)},n.clearTimeout=n.clearInterval=function(e){e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(window,this._id)},n.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},n.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},n._unrefActive=n.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;0<=t&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},n.setImmediate="function"==typeof t?t:function(e){var t=c++,r=!(2>arguments.length)&&a.call(arguments,1);return d[t]=!0,i(function(){d[t]&&(r?e.apply(null,r):e.call(null),n.clearImmediate(t))}),t},n.clearImmediate="function"==typeof r?r:function(e){delete d[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":69,timers:109}],110:[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(!a.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),o=-1!==r&&rb.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),x=e.host||e.pathname&&"/"===e.pathname.charAt(0),S=x||s||n.host&&e.pathname,E=S,C=n.pathname&&n.pathname.split("/")||[],b=e.pathname&&e.pathname.split("/")||[],I=n.protocol&&!y[n.protocol];if(I&&(n.hostname="",n.port=null,n.host&&(""===C[0]?C[0]=n.host:C.unshift(n.host)),n.host="",e.protocol&&(e.hostname=null,e.port=null,e.host&&(""===b[0]?b[0]=e.host:b.unshift(e.host)),e.host=null),S=S&&(""===b[0]||""===C[0])),x)n.host=e.host||""===e.host?e.host:n.host,n.hostname=e.hostname||""===e.hostname?e.hostname:n.hostname,n.search=e.search,n.query=e.query,C=b;else if(b.length)C||(C=[]),C.pop(),C=C.concat(b),n.search=e.search,n.query=e.query;else if(!a.isNullOrUndefined(e.search)){if(I){n.hostname=n.host=C.shift();var B=!!(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))&&(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=c.stsz.entries.length)break;if(_++,b+=C,_>=E.samplesPerChunk){_=0,b=0,y++;var T=c.stsc.entries[w+1];T&&y+1>=T.firstChunk&&w++}k+=I,x.inc(),v&&v.inc(),L&&S++}d.mdia.mdhd.duration=0,d.tkhd.duration=0;var A=E.sampleDescriptionId,R={type:"moov",mvhd:e.mvhd,traks:[{tkhd:d.tkhd,mdia:{mdhd:d.mdia.mdhd,hdlr:d.mdia.hdlr,elng:d.mdia.elng,minf:{vmhd:d.mdia.minf.vmhd,smhd:d.mdia.minf.smhd,dinf:d.mdia.minf.dinf,stbl:{stsd:c.stsd,stts:a(),ctts:a(),stsc:a(),stsz:a(),stco:a(),stss:a()}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:d.tkhd.trackId,defaultSampleDescriptionIndex:A,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};t._tracks.push({trackId:d.tkhd.trackId,timeScale:d.mdia.mdhd.timeScale,samples:m,currSample:null,currTime:null,moov:R,mime:h})}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),P=t._tracks.map(function(e){var t=p.encode(e.moov);return{mime:e.mime,init:n.concat([U,t])}});t.emit("ready",P)},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 a=r.inStream.slice(e.ranges);a.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(),a=t._generateFragment(o,e);return a?void((-1===n||a.ranges[0].starta&&(a=-a-2);!o.samples[a].sync;)a--;return a};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,a=[],d=o,c;d=1*r.timeScale));d++){s+=c.size;var l=a.length-1;0>l||a[l].end!==c.offset?a.push({start:c.offset,end:c.offset+c.size}):a[l].end+=c.size}return r.currSample=d,{moof:n._generateMoof(e,o,d),ranges:a,length:s}},o.prototype._generateMoof=function(e,t,n){for(var r=this,o=r._tracks[e],i=[],s=t,a;se.length)throw new Error("pump requires two streams per minimum");var n=e.map(function(o,s){var i=s