From 402fd532e8f3bfecab400c5f257de03c0a09faea Mon Sep 17 00:00:00 2001 From: DC Date: Tue, 1 Nov 2016 17:37:08 -0700 Subject: [PATCH 01/48] webtorrent integration demo --- app/extensions.js | 8 ++- app/extensions/brave/ext/webtorrent.min.js | 9 +++ app/extensions/brave/js/webtorrent.js | 19 ++++++ app/extensions/brave/webtorrent.html | 20 +++++++ js/components/frame.js | 8 ++- js/lib/appUrlUtil.js | 28 +++++++-- js/lib/urlutil.js | 2 +- js/stores/windowStore.js | 10 ++-- js/webtorrent/entry.js | 68 ++++++++++++++++++++++ package.json | 3 +- webpack.config.js | 20 ++++++- 11 files changed, 178 insertions(+), 17 deletions(-) create mode 100644 app/extensions/brave/ext/webtorrent.min.js create mode 100644 app/extensions/brave/js/webtorrent.js create mode 100644 app/extensions/brave/webtorrent.html create mode 100644 js/webtorrent/entry.js diff --git a/app/extensions.js b/app/extensions.js index 080f342967a..373d573d6e2 100644 --- a/app/extensions.js +++ b/app/extensions.js @@ -125,7 +125,7 @@ let generateBraveManifest = () => { 'form-action': '\'none\'', 'referrer': 'no-referrer', 'style-src': '\'self\' \'unsafe-inline\'', - 'img-src': '* data:', + 'img-src': '* data: blob:', 'frame-src': '\'self\' https://buy.coinbase.com' } @@ -137,6 +137,12 @@ let generateBraveManifest = () => { cspDirectives['style-src'] = '\'self\' \'unsafe-inline\' http://' + devServer } + // TODO: + // * Move WebTorrent to its own renderer process, similar to the way it's done in + // WebTorrent Desktop + // * Remove this CSP exception: + cspDirectives['connect-src'] = '*' + var csp = '' for (var directive in cspDirectives) { csp += directive + ' ' + cspDirectives[directive] + '; ' diff --git a/app/extensions/brave/ext/webtorrent.min.js b/app/extensions/brave/ext/webtorrent.min.js new file mode 100644 index 00000000000..13fd7c9e813 --- /dev/null +++ b/app/extensions/brave/ext/webtorrent.min.js @@ -0,0 +1,9 @@ +!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?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.WebTorrent=e()}}(function(){var e;return function e(t,n,r){function o(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(i)return i(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return o(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var i="function"==typeof require&&require,s=0;s0?t[Math.random()*t.length|0]:-1},r.prototype.destroy=function(){var e=this;e._torrent.removeListener("wire",e._onWire),e._torrent.wires.forEach(function(t){e._cleanupWireEvents(t)}),e._torrent=null,e._pieces=null,e._onWire=null,e._onWireHave=null,e._onWireBitfield=null},r.prototype._initWire=function(e){var t=this;e._onClose=function(){t._cleanupWireEvents(e);for(var n=0;n65536)return r._debug("ignoring invalid PORT from peer");r._debug("port: %s (from %s)",n,t),r.client.dht.addNode({host:e.remoteAddress,port:n})}}),e.on("timeout",function(){r._debug("wire timeout (%s)",t),e.destroy()}),e.setTimeout(z,!0),e.setKeepAlive(!0),e.use(M(r.metadata)),e.ut_metadata.on("warning",function(e){r._debug("ut_metadata warning: %s",e.message)}),r.metadata||(e.ut_metadata.on("metadata",function(e){r._debug("got metadata via ut_metadata"),r._onMetadata(e)}),e.ut_metadata.fetch()),"function"!=typeof j||r.private||(e.use(j()),e.ut_pex.on("peer",function(e){r.done||(r._debug("ut_pex: got peer: %s (from %s)",e,t),r.addPeer(e))}),e.ut_pex.on("dropped",function(e){var n=r._peers[e];n&&!n.connected&&(r._debug("ut_pex: dropped peer: %s (from %s)",e,t),r.removePeer(e))}),e.once("close",function(){e.ut_pex.reset()})),r.emit("wire",e,t),r.metadata&&n.nextTick(function(){r._onWireWithMetadata(e)})},o.prototype._onWireWithMetadata=function(e){function t(){r.destroyed||e.destroyed||(r._numQueued>2*(r._numConns-r.numPeers)&&e.amInterested?e.destroy():(o=setTimeout(t,F),o.unref&&o.unref()))}function n(){if(e.peerPieces.length===r.pieces.length){for(;iW?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),o=setTimeout(t,F),o.unref&&o.unref(),e.isSeeder=!1,n()},o.prototype._updateSelections=function(){var e=this;e.ready&&!e.destroyed&&(n.nextTick(function(){e._gcSelections()}),e._updateInterest(),e._update())},o.prototype._gcSelections=function(){for(var e=this,t=0;t=t&&i<=n&&!(i in r)&&e.peerPieces.get(i)&&(!o||o(i))}}function n(){if(!e.requests.length)for(var n=a._selections.length;n--;){var r,o=a._selections[n];if("rarest"===a.strategy)for(var i=o.from+o.offset,s=o.to,u=s-i+1,c={},f=0,d=t(i,s,c);f=o.from+o.offset;--r)if(e.peerPieces.get(r)&&a._request(e,r,!1))return}}function r(){var t=e.downloadSpeed()||1;if(t>Y)return function(){return!0};var n=Math.max(1,e.requests.length)*C.BLOCK_LENGTH/t,r=10,o=0;return function(e){if(!r||a.bitfield.get(e))return!0;for(var i=a.pieces[e].missing;o0))return r--,!1}return!0}}function o(e){for(var t=e,n=e;n=c)return!0;for(var i=r(),s=0;s=u)){var c=i(e,G);s(!1)||s(!0)}}},o.prototype._rechoke=function(){function e(e,t){return e.downloadSpeed!==t.downloadSpeed?t.downloadSpeed-e.downloadSpeed:e.uploadSpeed!==t.uploadSpeed?t.uploadSpeed-e.uploadSpeed:e.wire.amChoking!==t.wire.amChoking?e.wire.amChoking?1:-1:e.salt-t.salt}var t=this;if(t.ready){t._rechokeOptimisticTime>0?t._rechokeOptimisticTime-=1:t._rechokeOptimisticWire=null;var n=[];t.wires.forEach(function(e){e.isSeeder||e===t._rechokeOptimisticWire||n.push({wire:e,downloadSpeed:e.downloadSpeed(),uploadSpeed:e.uploadSpeed(),salt:Math.random(),isChoked:!0})}),n.sort(e);for(var r=0,o=0;o=Y||2*c>r||c>a||(i=u,a=c)}}if(!i)return!1;for(s=0;s=f)return!1;var d=a.pieces[t],h=c?d.reserveRemaining():d.reserve();if(h===-1&&r&&a._hotswap(e,t)&&(h=c?d.reserveRemaining():d.reserve()),h===-1)return!1;var l=a._reservations[t];l||(l=a._reservations[t]=[]);var p=l.indexOf(null);p===-1&&(p=l.length),l[p]=e;var m=d.chunkOffset(h),g=c?d.chunkLengthRemaining(h):d.chunkLength(h);return e.request(t,m,g,function n(r,i){if(!a.ready)return a.once("ready",function(){n(r,i)});if(l[p]===e&&(l[p]=null),d!==a.pieces[t])return o();if(r)return a._debug("error getting piece %s (offset: %s length: %s) from %s: %s",t,m,g,e.remoteAddress+":"+e.remotePort,r.message),c?d.cancelRemaining(h):d.cancel(h),void o();if(a._debug("got piece %s (offset: %s length: %s) from %s",t,m,g,e.remoteAddress+":"+e.remotePort),!d.set(h,i,e))return o();var s=d.flush();U(s,function(e){if(e===a._hashes[t]){if(!a.pieces[t])return;a._debug("piece verified %s",t),a.pieces[t]=null,a._reservations[t]=null,a.bitfield.set(t,!0),a.store.put(t,s),a.wires.forEach(function(e){e.have(t)}),a._checkDone()}else a.pieces[t]=new C(d.length),a.emit("warning",new Error("Piece "+t+" failed verification"));o()})}),!0},o.prototype._checkDone=function(){var e=this;if(!e.destroyed){e.files.forEach(function(t){if(!t.done){for(var n=t._startPiece;n<=t._endPiece;++n)if(!e.bitfield.get(n))return;t.done=!0,t.emit("done"),e._debug("file done: "+t.name)}});for(var t=!0,n=0;n=e.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=f(t.addr),r={host:n[0],port:n[1]},o=t.conn=x.connect(r);o.once("connect",function(){t.onConnect()}),o.once("error",function(e){t.destroy(e)}),t.startConnectTimeout(),o.on("close",function(){if(!e.destroyed){if(t.retries>=J.length)return void e._debug("conn %s closed: will not re-add (max %s attempts)",t.addr,J.length);var n=J[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()}})}}},o.prototype._validAddr=function(e){var t;try{t=f(e)}catch(e){return!1}var n=t[0],r=t[1];return r>0&&r<65535&&!("127.0.0.1"===n&&r===this.client.torrentPort)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../package.json":122,"./file":2,"./peer":3,"./rarity-map":4,"./server":21,_process:67,"addr-to-ip-port":7,bitfield:13,"chunk-store-stream/write":26,debug:30,events:35,fs:22,"fs-chunk-store":51,"immediate-chunk-store":41,inherits:42,multistream:59,net:21,os:21,"parse-torrent":63,path:64,pump:68,"random-iterate":73,"run-parallel":86,"run-parallel-limit":85,"simple-get":90,"simple-sha1":92,speedometer:94,"torrent-discovery":106,"torrent-piece":107,uniq:110,ut_metadata:114,ut_pex:21,xtend:119,"xtend/mutable":120}],6:[function(e,t,n){function r(e,t){f.call(this),this.url=e,this.webPeerId=c.sync(e),this._torrent=t,this._init()}t.exports=r;var o=e("bitfield"),i=e("safe-buffer").Buffer,s=e("debug")("webtorrent:webconn"),a=e("simple-get"),u=e("inherits"),c=e("simple-sha1"),f=e("bittorrent-protocol"),d=e("../package.json").version;u(r,f),r.prototype._init=function(){var e=this;e.setKeepAlive(!0),e.once("handshake",function(t,n){if(!e.destroyed){e.handshake(t,e.webPeerId);for(var r=e._torrent.pieces.length,i=new o(r),s=0;s<=r;s++)i.set(s,!0);e.bitfield(i)}}),e.once("interested",function(){s("interested"),e.unchoke()}),e.on("uninterested",function(){s("uninterested")}),e.on("choke",function(){s("choke")}),e.on("unchoke",function(){s("unchoke")}),e.on("bitfield",function(){s("bitfield")}),e.on("request",function(t,n,r,o){s("request pieceIndex=%d offset=%d length=%d",t,n,r),e.httpRequest(t,n,r,o)})},r.prototype.httpRequest=function(e,t,n,r){var o,u=this,c=e*u._torrent.pieceLength,f=c+t,h=f+n-1,l=u._torrent.files;if(l.length<=1)o=[{url:u.url,start:f,end:h}];else{var p=l.filter(function(e){return e.offset<=h&&e.offset+e.length>f});if(p.length<1)return r(new Error("Could not find file corresponnding to web seed range request"));o=p.map(function(e){var t=e.offset+e.length-1,n=u.url+("/"===u.url[u.url.length-1]?"":"/")+e.path;return{url:n,fileOffsetInRange:Math.max(e.offset-f,0),start:Math.max(f-e.offset,0),end:Math.min(t,h-e.offset)}})}var m,g=0,y=!1;o.length>1&&(m=i.alloc(n)),o.forEach(function(i){var u=i.url,c=i.start,f=i.end;s("Requesting url=%s pieceIndex=%d offset=%d length=%d start=%d end=%d",u,e,t,n,c,f);var h={url:u,method:"GET",headers:{"user-agent":"WebTorrent/"+d+" (https://webtorrent.io)",range:"bytes="+c+"-"+f}};a.concat(h,function(e,t,n){if(!y){if(e)return y=!0,r(e);if(t.statusCode<200||t.statusCode>=300)return y=!0,r(new Error("Unexpected HTTP status code "+t.statusCode));s("Got data of length %d",n.length),1===o.length?r(null,n):(n.copy(m,i.fileOffsetInRange),++g===o.length&&r(null,m))}})})},r.prototype.destroy=function(){f.prototype.destroy.call(this),this._torrent=null}},{"../package.json":122,bitfield:13,"bittorrent-protocol":14,debug:30,inherits:42,"safe-buffer":88,"simple-get":90,"simple-sha1":92}],7:[function(e,t,n){var r=/^\[?([^\]]+)\]?:(\d+)$/,o={},i=0;t.exports=function(e){if(1e5===i&&t.exports.reset(),!o[e]){var n=r.exec(e);if(!n)throw new Error("invalid addr: "+e);o[e]=[n[1],Number(n[2])],i+=1}return o[e]},t.exports.reset=function(){o={},i=0}},{}],8:[function(e,t,n){"use strict";function r(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function o(e){return 3*e.length/4-r(e)}function i(e){var t,n,o,i,s,a,u=e.length;s=r(e),a=new d(3*u/4-s),o=s>0?u-4:u;var c=0;for(t=0,n=0;t>16&255,a[c++]=i>>8&255,a[c++]=255&i;return 2===s?(i=f[e.charCodeAt(t)]<<2|f[e.charCodeAt(t+1)]>>4,a[c++]=255&i):1===s&&(i=f[e.charCodeAt(t)]<<10|f[e.charCodeAt(t+1)]<<4|f[e.charCodeAt(t+2)]>>2,a[c++]=i>>8&255,a[c++]=255&i),a}function s(e){return c[e>>18&63]+c[e>>12&63]+c[e>>6&63]+c[63&e]}function a(e,t,n){for(var r,o=[],i=t;if?f:u+s));return 1===r?(t=e[n-1],o+=c[t>>2],o+=c[t<<4&63],o+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],o+=c[t>>10],o+=c[t>>4&63],o+=c[t<<2&63],o+="="),i.push(o),i.join("")}n.byteLength=o,n.toByteArray=i,n.fromByteArray=u;for(var c=[],f=[],d="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,p=h.length;l=e.length)throw new RangeError("invalid lower bound");if(void 0===o)o=e.length-1;else if(o=0|o,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),s<0)r=i+1;else{if(!(s>0))return i;o=i-1}return~r}},{}],13:[function(e,t,n){(function(e){function n(e,t){return this instanceof n?(0===arguments.length&&(e=0),this.grow=t&&(isFinite(t.grow)&&r(t.grow)||t.grow)||0,"number"!=typeof e&&void 0!==e||(e=new o(r(e)),e.fill&&!e._isBuffer&&e.fill(0)),void(this.buffer=e)):new n(e,t)}function r(e){var t=e>>3;return e%8!==0&&t++,t}var o="undefined"!=typeof e?e:"undefined"!=typeof Int8Array?Int8Array:function(e){for(var t=new Array(e),n=0;n>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]:u.concat(this._buffer);this._bufferSize-=this._parserSize,this._buffer=this._bufferSize?[r.slice(this._parserSize)]:[],this._parser(r.slice(0,this._parserSize))}n(null)},o.prototype._callback=function(e,t,n){e&&(this._clearTimeout(),this.peerChoking||this._finished||this._updateTimeout(),e.callback(t,n))},o.prototype._clearTimeout=function(){this._timeout&&(clearTimeout(this._timeout),this._timeout=null)},o.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())},o.prototype._parse=function(e,t){this._parserSize=e,this._parser=t},o.prototype._onMessageLength=function(e){var t=e.readUInt32BE(0);t>0?this._parse(t,this._onMessage):(this._onKeepAlive(),this._parse(4,this._onMessageLength))},o.prototype._onMessage=function(e){switch(this._parse(4,this._onMessageLength),e[0]){case 0:return this._onChoke();case 1:return this._onUnchoke();case 2:return this._onInterested();case 3:return this._onUninterested();case 4:return this._onHave(e.readUInt32BE(1));case 5:return this._onBitField(e.slice(1));case 6:return this._onRequest(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 7:return this._onPiece(e.readUInt32BE(1),e.readUInt32BE(5),e.slice(9));case 8:return this._onCancel(e.readUInt32BE(1),e.readUInt32BE(5),e.readUInt32BE(9));case 9:return this._onPort(e.readUInt16BE(1));case 20:return this._onExtended(e.readUInt8(1),e.slice(2));default:return this._debug("got unknown message"),this.emit("unknownmessage",e)}},o.prototype._parseHandshake=function(){var e=this;e._parse(1,function(t){var n=t.readUInt8(0);e._parse(n+48,function(t){var r=t.slice(0,n);return"BitTorrent protocol"!==r.toString()?(e._debug("Error: wire not speaking BitTorrent protocol (%s)",r.toString()),void e.end()):(t=t.slice(n),e._onHandshake(t.slice(8,28),t.slice(28,48),{dht:!!(1&t[7]),extended:!!(16&t[5])}),void e._parse(4,e._onMessageLength))})})},o.prototype._onFinish=function(){for(this._finished=!0,this.push(null);this.read(););for(clearInterval(this._keepAliveInterval),this._parse(Number.MAX_VALUE,function(){}),this.peerRequests=[];this.requests.length;)this._callback(this.requests.shift(),new Error("wire was closed"),null)},o.prototype._debug=function(){var e=[].slice.call(arguments);e[0]="["+this._debugId+"] "+e[0],c.apply(null,e)}},{bencode:11,bitfield:13,debug:30,inherits:42,randombytes:74,"readable-stream":82,"safe-buffer":88,speedometer:94,xtend:119}],15:[function(e,t,n){(function(n){function r(e){function t(e){n.nextTick(function(){a.emit("warning",e)})}var a=this;if(!(a instanceof r))return new r(e);if(s.call(a),e||(e={}),!e.peerId)throw new Error("Option `peerId` is required");if(!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");if(!n.browser&&!e.port)throw new Error("Option `port` is required");a.peerId="string"==typeof e.peerId?e.peerId:e.peerId.toString("hex"),a._peerIdBuffer=o.from(a.peerId,"hex"),a._peerIdBinary=a._peerIdBuffer.toString("binary"),a.infoHash="string"==typeof e.infoHash?e.infoHash:e.infoHash.toString("hex"),a._infoHashBuffer=o.from(a.infoHash,"hex"),a._infoHashBinary=a._infoHashBuffer.toString("binary"),a._port=e.port,a.destroyed=!1,a._rtcConfig=e.rtcConfig,a._wrtc=e.wrtc,a._getAnnounceOpts=e.getAnnounceOpts,i("new client %s",a.infoHash);var u=a._wrtc!==!1&&(!!a._wrtc||d.WEBRTC_SUPPORT),c="string"==typeof e.announce?[e.announce]:null==e.announce?[]:e.announce;c=c.map(function(e){return e=e.toString(),"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),e}),c=h(c),a._trackers=c.map(function(e){var n=l.parse(e).protocol;return"http:"!==n&&"https:"!==n||"function"!=typeof m?"udp:"===n&&"function"==typeof g?new g(a,e):"ws:"!==n&&"wss:"!==n||!u?(t(new Error("Unsupported tracker protocol: "+e)),null):"ws:"===n&&"undefined"!=typeof window&&"https:"===window.location.protocol?(t(new Error("Unsupported tracker protocol: "+e)),null):new y(a,e):new m(a,e)}).filter(Boolean)}t.exports=r;var o=e("safe-buffer").Buffer,i=e("debug")("bittorrent-tracker"),s=e("events").EventEmitter,a=e("xtend"),u=e("inherits"),c=e("once"),f=e("run-parallel"),d=e("simple-peer"),h=e("uniq"),l=e("url"),p=e("./lib/common"),m=e("./lib/client/http-tracker"),g=e("./lib/client/udp-tracker"),y=e("./lib/client/websocket-tracker");u(r,s),r.scrape=function(e,t){if(t=c(t),!e.infoHash)throw new Error("Option `infoHash` is required");if(!e.announce)throw new Error("Option `announce` is required");var n=a(e,{infoHash:Array.isArray(e.infoHash)?e.infoHash[0]:e.infoHash,peerId:o.from("01234567890123456789"),port:6881}),i=new r(n);i.once("error",t),i.once("warning",t);var s=Array.isArray(e.infoHash)?e.infoHash.length:1,u={};return i.on("scrape",function(e){if(s-=1,u[e.infoHash]=e,0===s){i.destroy();var n=Object.keys(u);1===n.length?t(null,u[n[0]]):t(null,u)}}),e.infoHash=Array.isArray(e.infoHash)?e.infoHash.map(function(e){return o.from(e,"hex")}):o.from(e.infoHash,"hex"),i.scrape({infoHash:e.infoHash}),i},r.prototype.start=function(e){var t=this;i("send `start`"),e=t._defaultAnnounceOpts(e),e.event="started",t._announce(e),t._trackers.forEach(function(e){e.setInterval()})},r.prototype.stop=function(e){var t=this;i("send `stop`"),e=t._defaultAnnounceOpts(e),e.event="stopped",t._announce(e)},r.prototype.complete=function(e){var t=this;i("send `complete`"),e||(e={}),e=t._defaultAnnounceOpts(e),e.event="completed",t._announce(e)},r.prototype.update=function(e){var t=this;i("send `update`"),e=t._defaultAnnounceOpts(e),e.event&&delete e.event,t._announce(e)},r.prototype._announce=function(e){var t=this;t._trackers.forEach(function(t){t.announce(e)})},r.prototype.scrape=function(e){var t=this;i("send `scrape`"),e||(e={}),t._trackers.forEach(function(t){t.scrape(e)})},r.prototype.setInterval=function(e){var t=this;i("setInterval %d",e),t._trackers.forEach(function(t){t.setInterval(e)})},r.prototype.destroy=function(e){var t=this;if(!t.destroyed){t.destroyed=!0,i("destroy");var n=t._trackers.map(function(e){return function(t){e.destroy(t)}});f(n,e),t._trackers=[],t._getAnnounceOpts=null}},r.prototype._defaultAnnounceOpts=function(e){var t=this;return e||(e={}),null==e.numwant&&(e.numwant=p.DEFAULT_ANNOUNCE_PEERS),null==e.uploaded&&(e.uploaded=0),null==e.downloaded&&(e.downloaded=0),t._getAnnounceOpts&&(e=a(e,t._getAnnounceOpts())),e}}).call(this,e("_process"))},{"./lib/client/http-tracker":21,"./lib/client/udp-tracker":21,"./lib/client/websocket-tracker":17,"./lib/common":18,_process:67,debug:30,events:35,inherits:42,once:61,"run-parallel":86,"safe-buffer":88,"simple-peer":91,uniq:110,url:112,xtend:119}],16:[function(e,t,n){function r(e,t){var n=this;o.call(n),n.client=e,n.announceUrl=t,n.interval=null,n.destroyed=!1}t.exports=r;var o=e("events").EventEmitter,i=e("inherits");i(r,o),r.prototype.setInterval=function(e){var t=this;null==e&&(e=t.DEFAULT_ANNOUNCE_INTERVAL),clearInterval(t.interval),e&&(t.interval=setInterval(function(){t.announce(t.client._defaultAnnounceOpts())},e),t.interval.unref&&t.interval.unref())}},{events:35,inherits:42}],17:[function(e,t,n){function r(e,t,n){var r=this;h.call(r,e,t),i("new websocket tracker %s",t),r.peers={},r.socket=null,r.reconnecting=!1,r.retries=0,r.reconnectTimer=null,r._openSocket()}function o(){}t.exports=r;var i=e("debug")("bittorrent-tracker:websocket-tracker"),s=e("xtend"),a=e("inherits"),u=e("simple-peer"),c=e("randombytes"),f=e("simple-websocket"),d=e("../common"),h=e("./tracker"),l={},p=15e3,m=18e5,g=3e4,y=5e4;a(r,h),r.prototype.DEFAULT_ANNOUNCE_INTERVAL=3e4,r.prototype.announce=function(e){var t=this;if(!t.destroyed&&!t.reconnecting){if(!t.socket.connected)return void t.socket.once("connect",function(){t.announce(e)});var n=s(e,{action:"announce",info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary});if(t._trackerId&&(n.trackerid=t._trackerId),"stopped"===e.event)t._send(n);else{var r=Math.min(e.numwant,10);t._generateOffers(r,function(e){n.numwant=r,n.offers=e,t._send(n)})}}},r.prototype.scrape=function(e){var t=this;if(!t.destroyed&&!t.reconnecting){if(!t.socket.connected)return void t.socket.once("connect",function(){t.scrape(e)});var n=Array.isArray(e.infoHash)&&e.infoHash.length>0?e.infoHash.map(function(e){return e.toString("binary")}):e.infoHash&&e.infoHash.toString("binary")||t.client._infoHashBinary,r={action:"scrape",info_hash:n};t._send(r)}},r.prototype.destroy=function(e){var t=this;if(e||(e=o),t.destroyed)return e(null);t.destroyed=!0,clearInterval(t.interval),clearTimeout(t.reconnectTimer),t.socket&&(t.socket.removeListener("connect",t._onSocketConnectBound),t.socket.removeListener("data",t._onSocketDataBound),t.socket.removeListener("close",t._onSocketCloseBound),t.socket.removeListener("error",t._onSocketErrorBound)),t._onSocketConnectBound=null,t._onSocketErrorBound=null,t._onSocketDataBound=null,t._onSocketCloseBound=null;for(var n in t.peers){var r=t.peers[n];clearTimeout(r.trackerTimeout),r.destroy()}if(t.peers=null,l[t.announceUrl]&&(l[t.announceUrl].consumers-=1),0===l[t.announceUrl].consumers){delete l[t.announceUrl];try{t.socket.on("error",o),t.socket.destroy(e)}catch(t){e(null)}}else e(null);t.socket=null},r.prototype._openSocket=function(){var e=this;e.destroyed=!1,e.peers||(e.peers={}),e._onSocketConnectBound=function(){e._onSocketConnect()},e._onSocketErrorBound=function(t){e._onSocketError(t)},e._onSocketDataBound=function(t){e._onSocketData(t)},e._onSocketCloseBound=function(){e._onSocketClose()},e.socket=l[e.announceUrl],e.socket?l[e.announceUrl].consumers+=1:(e.socket=l[e.announceUrl]=new f(e.announceUrl),e.socket.consumers=1,e.socket.on("connect",e._onSocketConnectBound)),e.socket.on("data",e._onSocketDataBound),e.socket.on("close",e._onSocketCloseBound),e.socket.on("error",e._onSocketErrorBound)},r.prototype._onSocketConnect=function(){var e=this;e.destroyed||e.reconnecting&&(e.reconnecting=!1,e.retries=0,e.announce(e.client._defaultAnnounceOpts()))},r.prototype._onSocketData=function(e){var t=this;if(!t.destroyed){try{e=JSON.parse(e)}catch(e){return void t.client.emit("warning",new Error("Invalid tracker response"))}"announce"===e.action?t._onAnnounceResponse(e):"scrape"===e.action?t._onScrapeResponse(e):t._onSocketError(new Error("invalid action in WS response: "+e.action))}},r.prototype._onAnnounceResponse=function(e){var t=this;if(e.info_hash!==t.client._infoHashBinary)return void i("ignoring websocket data from %s for %s (looking for %s: reused socket)",t.announceUrl,d.binaryToHex(e.info_hash),t.client.infoHash);if(!e.peer_id||e.peer_id!==t.client._peerIdBinary){i("received %s from %s for %s",JSON.stringify(e),t.announceUrl,t.client.infoHash);var n=e["failure reason"];if(n)return t.client.emit("warning",new Error(n));var r=e["warning message"];r&&t.client.emit("warning",new Error(r));var o=e.interval||e["min interval"];o&&t.setInterval(1e3*o);var s=e["tracker id"];s&&(t._trackerId=s),null!=e.complete&&t.client.emit("update",{announce:t.announceUrl,complete:e.complete,incomplete:e.incomplete});var a;if(e.offer&&e.peer_id&&(i("creating peer (from remote offer)"),a=new u({trickle:!1,config:t.client._rtcConfig,wrtc:t.client._wrtc}),a.id=d.binaryToHex(e.peer_id),a.once("signal",function(n){var r={action:"announce",info_hash:t.client._infoHashBinary,peer_id:t.client._peerIdBinary,to_peer_id:e.peer_id,answer:n,offer_id:e.offer_id};t._trackerId&&(r.trackerid=t._trackerId),t._send(r)}),a.signal(e.offer),t.client.emit("peer",a)),e.answer&&e.peer_id){var c=d.binaryToHex(e.offer_id);a=t.peers[c],a?(a.id=d.binaryToHex(e.peer_id),a.signal(e.answer),t.client.emit("peer",a),clearTimeout(a.trackerTimeout),a.trackerTimeout=null,delete t.peers[c]):i("got unexpected answer: "+JSON.stringify(e.answer))}}},r.prototype._onScrapeResponse=function(e){var t=this;e=e.files||{};var n=Object.keys(e);return 0===n.length?void t.client.emit("warning",new Error("invalid scrape response")):void n.forEach(function(n){var r=e[n];t.client.emit("scrape",{announce:t.announceUrl,infoHash:d.binaryToHex(n),complete:r.complete,incomplete:r.incomplete,downloaded:r.downloaded})})},r.prototype._onSocketClose=function(){var e=this;e.destroyed||(e.destroy(),e._startReconnectTimer())},r.prototype._onSocketError=function(e){var t=this;t.destroyed||(t.destroy(),t.client.emit("warning",e),t._startReconnectTimer())},r.prototype._startReconnectTimer=function(){var e=this,t=Math.floor(Math.random()*g)+Math.min(Math.pow(2,e.retries)*p,m);e.reconnecting=!0,clearTimeout(e.reconnectTimer),e.reconnectTimer=setTimeout(function(){e.retries++,e._openSocket()},t),e.reconnectTimer.unref&&e.reconnectTimer.unref(),i("reconnecting socket in %s ms",t)},r.prototype._send=function(e){var t=this;if(!t.destroyed){var n=JSON.stringify(e);i("send %s",n),t.socket.send(n)}},r.prototype._generateOffers=function(e,t){function n(){var e=c(20).toString("hex");i("creating peer (from _generateOffers)");var t=o.peers[e]=new u({initiator:!0,trickle:!1,config:o.client._rtcConfig,wrtc:o.client._wrtc});t.once("signal",function(t){s.push({offer:t,offer_id:d.hexToBinary(e)}),r()}),t.trackerTimeout=setTimeout(function(){i("tracker timeout: destroying peer"),t.trackerTimeout=null,delete o.peers[e],t.destroy()},y),t.trackerTimeout.unref&&t.trackerTimeout.unref()}function r(){s.length===e&&(i("generated %s offers",e),t(s))}var o=this,s=[];i("generating %s offers",e);for(var a=0;a=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:24,defined:32,inherits:42,"readable-stream":82}],21:[function(e,t,n){},{}],22:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21}],23:[function(e,t,n){(function(t){"use strict";var r=e("buffer"),o=r.Buffer,i=r.SlowBuffer,s=r.kMaxLength||2147483647;n.alloc=function(e,t,n){if("function"==typeof o.alloc)return o.alloc(e,t,n);if("number"==typeof n)throw new TypeError("encoding must not be number");if("number"!=typeof e)throw new TypeError("size must be a number");if(e>s)throw new RangeError("size is too large");var r=n,i=t;void 0===i&&(r=void 0,i=0);var a=new o(e);if("string"==typeof i)for(var u=new o(i,r),c=u.length,f=-1;++fs)throw new RangeError("size is too large");return new o(e)},n.from=function(e,n,r){if("function"==typeof o.from&&(!t.Uint8Array||Uint8Array.from!==o.from))return o.from(e,n,r);if("number"==typeof e)throw new TypeError('"value" argument must not be a number');if("string"==typeof e)return new o(e,n);if("undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer){var i=n;if(1===arguments.length)return new o(e);"undefined"==typeof i&&(i=0);var s=r;if("undefined"==typeof s&&(s=e.byteLength-i),i>=e.byteLength)throw new RangeError("'offset' is out of bounds");if(s>e.byteLength-i)throw new RangeError("'length' is out of bounds");return new o(e.slice(i,i+s))}if(o.isBuffer(e)){var a=new o(e.length);return e.copy(a,0,0,e.length),a}if(e){if(Array.isArray(e)||"undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return new o(e);if("Buffer"===e.type&&Array.isArray(e.data))return new o(e.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")},n.allocUnsafeSlow=function(e){if("function"==typeof o.allocUnsafeSlow)return o.allocUnsafeSlow(e);if("number"!=typeof e)throw new TypeError("size must be a number");if(e>=s)throw new RangeError("size is too large");return new i(e)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{buffer:24}],24:[function(e,t,n){(function(t){"use strict";function r(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}function o(){return s.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function i(e,t){if(o()=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function g(e){return+e!=e&&(e=0),s.alloc(+e)}function y(e,t){if(s.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(e).length;default:if(r)return Y(e).length;t=(""+t).toLowerCase(),r=!0}}function _(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)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 T(this,t,n);case"ascii":return L(this,t,n);case"latin1":case"binary":return R(this,t,n);case"base64":return A(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 v(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function b(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=o?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(n<0){if(!o)return-1;n=0}if("string"==typeof t&&(t=s.from(t,r)),s.isBuffer(t))return 0===t.length?-1:w(e,t,n,r,o);if("number"==typeof t)return t=255&t,s.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):w(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function w(e,t,n,r,o){function i(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}var s=1,a=e.length,u=t.length;if(void 0!==r&&(r=String(r).toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}var c;if(o){var f=-1;for(c=n;ca&&(n=a-u),c=n;c>=0;c--){for(var d=!0,h=0;ho&&(r=o)):r=o;var i=t.length;if(i%2!==0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s239?4:i>223?3:i>191?2:1;if(o+a<=n){var u,c,f,d;switch(a){case 1:i<128&&(s=i);break;case 2:u=e[o+1],128===(192&u)&&(d=(31&i)<<6|63&u,d>127&&(s=d));break;case 3:u=e[o+1],c=e[o+2],128===(192&u)&&128===(192&c)&&(d=(15&i)<<12|(63&u)<<6|63&c,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:u=e[o+1],c=e[o+2],f=e[o+3],128===(192&u)&&128===(192&c)&&128===(192&f)&&(d=(15&i)<<18|(63&u)<<12|(63&c)<<6|63&f,d>65535&&d<1114112&&(s=d))}}null===s?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|1023&s),r.push(s),o+=a}return C(r)}function C(e){var t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);for(var n="",r=0;rr)&&(n=r);for(var o="",i=t;in)throw new RangeError("Trying to access beyond buffer length")}function M(e,t,n,r,o,i){if(!s.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 j(e,t,n,r){t<0&&(t=65535+t+1);for(var o=0,i=Math.min(e.length-n,2);o>>8*(r?o:1-o)}function H(e,t,n,r){t<0&&(t=4294967295+t+1);for(var o=0,i=Math.min(e.length-n,4);o>>8*(r?o:3-o)&255}function D(e,t,n,r,o,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function q(e,t,n,r,o){return o||D(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),Q.write(e,t,n,r,23,4),n+4}function N(e,t,n,r,o){return o||D(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),Q.write(e,t,n,r,52,8),n+8}function W(e){if(e=z(e).replace(te,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function z(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function F(e){return e<16?"0"+e.toString(16):e.toString(16)}function Y(e,t){t=t||1/0;for(var n,r=e.length,o=null,i=[],s=0;s55295&&n<57344){if(!o){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}o=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),o=n;continue}n=(o-55296<<10|n-56320)+65536}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function V(e){for(var t=[],n=0;n>8,o=n%256,i.push(o),i.push(r);return i}function $(e){return J.toByteArray(W(e))}function K(e,t,n,r){for(var o=0;o=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function X(e){return e!==e}var J=e("base64-js"),Q=e("ieee754"),Z=e("isarray");n.Buffer=s,n.SlowBuffer=g,n.INSPECT_MAX_BYTES=50,s.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:r(),n.kMaxLength=o(),s.poolSize=8192,s._augment=function(e){return e.__proto__=s.prototype,e},s.from=function(e,t,n){return a(null,e,t,n)},s.TYPED_ARRAY_SUPPORT&&(s.prototype.__proto__=Uint8Array.prototype,s.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&s[Symbol.species]===s&&Object.defineProperty(s,Symbol.species,{value:null,configurable:!0})),s.alloc=function(e,t,n){return c(null,e,t,n)},s.allocUnsafe=function(e){return f(null,e)},s.allocUnsafeSlow=function(e){return f(null,e)},s.isBuffer=function(e){return!(null==e||!e._isBuffer)},s.compare=function(e,t){if(!s.isBuffer(e)||!s.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=Math.min(n,r);o0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},s.prototype.compare=function(e,t,n,r,o){if(!s.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),t<0||n>e.length||r<0||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 i=o-r,a=n-t,u=Math.min(i,a),c=this.slice(r,o),f=e.slice(t,n),d=0;do)&&(n=o),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return k(this,e,t,n);case"ascii":return x(this,e,t,n);case"latin1":case"binary":return S(this,e,t,n);case"base64":return B(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}},s.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ee=4096;s.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),t0&&(o*=256);)r+=this[e+--t]*o;return r},s.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},s.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},s.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},s.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},s.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},s.prototype.readIntLE=function(e,t,n){e=0|e,t=0|t,n||O(e,t,this.length);for(var r=this[e],o=1,i=0;++i=o&&(r-=Math.pow(2,8*t)),r},s.prototype.readIntBE=function(e,t,n){e=0|e,t=0|t,n||O(e,t,this.length);for(var r=t,o=1,i=this[e+--r];r>0&&(o*=256);)i+=this[e+--r]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*t)),i},s.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},s.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},s.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},s.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},s.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),Q.read(this,e,!0,23,4)},s.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),Q.read(this,e,!1,23,4)},s.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),Q.read(this,e,!0,52,8)},s.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),Q.read(this,e,!1,52,8)},s.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t=0|t,n=0|n,!r){var o=Math.pow(2,8*n)-1;M(this,e,t,n,o,0)}var i=1,s=0;for(this[t]=255&e;++s=0&&(s*=256);)this[t+i]=e/s&255;return t+n},s.prototype.writeUInt8=function(e,t,n){return e=+e,t=0|t,n||M(this,e,t,1,255,0),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},s.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=0|t,n||M(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):j(this,e,t,!0),t+2},s.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=0|t,n||M(this,e,t,2,65535,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):j(this,e,t,!1),t+2},s.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=0|t,n||M(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):H(this,e,t,!0),t+4},s.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=0|t,n||M(this,e,t,4,4294967295,0),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):H(this,e,t,!1),t+4},s.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t=0|t,!r){var o=Math.pow(2,8*n-1);M(this,e,t,n,o-1,-o)}var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+n},s.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t=0|t,!r){var o=Math.pow(2,8*n-1);M(this,e,t,n,o-1,-o)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},s.prototype.writeInt8=function(e,t,n){return e=+e,t=0|t,n||M(this,e,t,1,127,-128),s.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},s.prototype.writeInt16LE=function(e,t,n){return e=+e,t=0|t,n||M(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):j(this,e,t,!0),t+2},s.prototype.writeInt16BE=function(e,t,n){return e=+e,t=0|t,n||M(this,e,t,2,32767,-32768),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):j(this,e,t,!1),t+2},s.prototype.writeInt32LE=function(e,t,n){return e=+e,t=0|t,n||M(this,e,t,4,2147483647,-2147483648),s.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):H(this,e,t,!0),t+4},s.prototype.writeInt32BE=function(e,t,n){return e=+e,t=0|t,n||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),s.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):H(this,e,t,!1),t+4},s.prototype.writeFloatLE=function(e,t,n){return q(this,e,t,!0,n)},s.prototype.writeFloatBE=function(e,t,n){return q(this,e,t,!1,n)},s.prototype.writeDoubleLE=function(e,t,n){return N(this,e,t,!0,n)},s.prototype.writeDoubleBE=function(e,t,n){return N(this,e,t,!1,n)},s.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--o)e[o+t]=this[o+n];else if(i<1e3||!s.TYPED_ARRAY_SUPPORT)for(o=0;o>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var i;if("number"==typeof e)for(i=t;i=n));i++)n=r,o=t[i];return o}},{}],28:[function(e,t,n){(function(e){function t(e){return Array.isArray?Array.isArray(e):"[object Array]"===g(e)}function r(e){return"boolean"==typeof e}function o(e){return null===e}function i(e){return null==e}function s(e){return"number"==typeof e}function a(e){return"string"==typeof e}function u(e){return"symbol"==typeof e}function c(e){return void 0===e}function f(e){return"[object RegExp]"===g(e)}function d(e){return"object"==typeof e&&null!==e}function h(e){return"[object Date]"===g(e)}function l(e){return"[object Error]"===g(e)||e instanceof Error}function p(e){return"function"==typeof e}function m(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function g(e){return Object.prototype.toString.call(e)}n.isArray=t,n.isBoolean=r,n.isNull=o,n.isNullOrUndefined=i,n.isNumber=s,n.isString=a,n.isSymbol=u,n.isUndefined=c,n.isRegExp=f,n.isObject=d,n.isDate=h,n.isError=l,n.isFunction=p,n.isPrimitive=m,n.isBuffer=e.isBuffer}).call(this,{isBuffer:e("../../is-buffer/index.js")})},{"../../is-buffer/index.js":44}],29:[function(e,t,n){(function(n,r,o){function i(e,t,n){return"function"==typeof t?i(e,null,t):(t=t?B(t):{},void a(e,t,function(e,r,o){return e?n(e):(t.singleFileTorrent=o,void l(r,t,n))}))}function s(e,t,n){return"function"==typeof t?s(e,null,t):(t=t?B(t):{},void a(e,t,n))}function a(e,t,r){function i(){P(e.map(function(e){return function(t){var n={};if(m(e))n.getStream=_(e),n.length=e.size;else if(o.isBuffer(e))n.getStream=v(e),n.length=e.length;else{if(!y(e)){if("string"==typeof e){if("function"!=typeof T.stat)throw new Error("filesystem paths do not work in the browser");var r=a>1||c;return void u(e,r,t)}throw new Error("invalid input type")}n.getStream=w(e,n),n.length=0}n.path=e.path,t(null,n)}}),function(e,t){return e?r(e):(t=A(t),void r(null,t,c))})}if(Array.isArray(e)&&0===e.length)throw new Error("invalid input type");g(e)&&(e=Array.prototype.slice.call(e)),Array.isArray(e)||(e=[e]),e=e.map(function(e){return m(e)&&"string"==typeof e.path&&"function"==typeof T.stat?e.path:e}),1!==e.length||"string"==typeof e[0]||e[0].name||(e[0].name=t.name);var s=null;e.forEach(function(t,n){if("string"!=typeof t){var r=t.fullPath||t.name;r||(r="Unknown File "+(n+1),t.unknownName=!0),t.path=r.split("/"),t.path[0]||t.path.shift(),t.path.length<2?s=null:0===n&&e.length>1?s=t.path[0]:t.path[0]!==s&&(s=null)}}),e=e.filter(function(e){if("string"==typeof e)return!0;var t=e.path[e.path.length-1];return d(t)&&L.not(t)}),s&&e.forEach(function(e){var t=(o.isBuffer(e)||y(e))&&!e.path;"string"==typeof e||t||e.path.shift()}),!t.name&&s&&(t.name=s),t.name||e.some(function(e){return"string"==typeof e?(t.name=S.basename(e),!0):e.unknownName?void 0:(t.name=e.path[e.path.length-1],!0)}),t.name||(t.name="Unnamed Torrent "+Date.now());var a=e.reduce(function(e,t){return e+Number("string"==typeof t)},0),c=1===e.length;if(1===e.length&&"string"==typeof e[0]){if("function"!=typeof T.stat)throw new Error("filesystem paths do not work in the browser");C(e[0],function(e,t){return e?r(e):(c=t,void i())})}else n.nextTick(function(){i()})}function u(e,t,n){f(e,c,function(r,o){return r?n(r):(o=Array.isArray(o)?A(o):[o],e=S.normalize(e),t&&(e=e.slice(0,e.lastIndexOf(S.sep)+1)),e[e.length-1]!==S.sep&&(e+=S.sep),o.forEach(function(t){t.getStream=b(t.path),t.path=t.path.replace(e,"").split(S.sep)}),void n(null,o))})}function c(e,t){t=U(t),T.stat(e,function(n,r){if(n)return t(n);var o={length:r.size,path:e};t(null,o)})}function f(e,t,n){T.readdir(e,function(r,o){r&&"ENOTDIR"===r.code?t(e,n):r?n(r):P(o.filter(d).filter(L.not).map(function(n){return function(r){f(S.join(e,n),t,r)}}),n)})}function d(e){return"."!==e[0]}function h(e,t,n){function r(e){f+=e.length;var t=l;O(e,function(e){c[t]=e,h-=1,u()}),h+=1,l+=1}function i(){p=!0,u()}function s(e){a(),n(e)}function a(){m.removeListener("error",s),g.removeListener("data",r),g.removeListener("end",i),g.removeListener("error",s)}function u(){p&&0===h&&(a(),n(null,new o(c.join(""),"hex"),f))}n=U(n);var c=[],f=0,d=e.map(function(e){return e.getStream}),h=0,l=0,p=!1,m=new R(d),g=new k(t,{zeroPadding:!1});m.on("error",s),m.pipe(g).on("data",r).on("end",i).on("error",s)}function l(e,n,o){var i=n.announceList;i||("string"==typeof n.announce?i=[[n.announce]]:Array.isArray(n.announce)&&(i=n.announce.map(function(e){return[e]}))),i||(i=[]),r.WEBTORRENT_ANNOUNCE&&("string"==typeof r.WEBTORRENT_ANNOUNCE?i.push([[r.WEBTORRENT_ANNOUNCE]]):Array.isArray(r.WEBTORRENT_ANNOUNCE)&&(i=i.concat(r.WEBTORRENT_ANNOUNCE.map(function(e){return[e]})))),void 0===n.announce&&void 0===n.announceList&&(i=i.concat(t.exports.announceList)),"string"==typeof n.urlList&&(n.urlList=[n.urlList]);var s={info:{name:n.name},"creation date":Math.ceil((Number(n.creationDate)||Date.now())/1e3),encoding:"UTF-8"};0!==i.length&&(s.announce=i[0][0],s["announce-list"]=i),void 0!==n.comment&&(s.comment=n.comment),void 0!==n.createdBy&&(s["created by"]=n.createdBy),void 0!==n.private&&(s.info.private=Number(n.private)),void 0!==n.sslCert&&(s.info["ssl-cert"]=n.sslCert),void 0!==n.urlList&&(s["url-list"]=n.urlList);var a=n.pieceLength||x(e.reduce(p,0));s.info["piece length"]=a,h(e,a,function(t,r,i){return t?o(t):(s.info.pieces=r,e.forEach(function(e){delete e.getStream}),n.singleFileTorrent?s.info.length=i:s.info.files=e,void o(null,E.encode(s)))})}function p(e,t){return e+t.length}function m(e){return"undefined"!=typeof Blob&&e instanceof Blob}function g(e){return"undefined"!=typeof FileList&&e instanceof FileList}function y(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function _(e){return function(){return new I(e)}}function v(e){return function(){var t=new M.PassThrough;return t.end(e),t}}function b(e){return function(){return T.createReadStream(e)}}function w(e,t){return function(){var n=new M.Transform;return n._transform=function(e,n,r){t.length+=e.length,this.push(e),r()},e.pipe(n),n}}t.exports=i,t.exports.parseInput=s,t.exports.announceList=[["udp://tracker.openbittorrent.com:80"],["udp://tracker.internetwarriors.net:1337"],["udp://tracker.leechers-paradise.org:6969"],["udp://tracker.coppersurfer.tk:6969"],["udp://exodus.desync.com:6969"],["wss://tracker.btorrent.xyz"],["wss://tracker.openwebtorrent.com"],["wss://tracker.fastcast.nz"]]; +var E=e("bencode"),k=e("block-stream2"),x=e("piece-length"),S=e("path"),B=e("xtend"),I=e("filestream/read"),A=e("flatten"),T=e("fs"),C=e("is-file"),L=e("junk"),R=e("multistream"),U=e("once"),P=e("run-parallel"),O=e("simple-sha1"),M=e("readable-stream")}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{_process:67,bencode:11,"block-stream2":20,buffer:24,"filestream/read":36,flatten:37,fs:22,"is-file":45,junk:48,multistream:59,once:61,path:64,"piece-length":65,"readable-stream":82,"run-parallel":86,"simple-sha1":92,xtend:119}],30:[function(e,t,n){function r(){return"WebkitAppearance"in document.documentElement.style||window.console&&(console.firebug||console.exception&&console.table)||navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31}function o(){var e=arguments,t=this.useColors;if(e[0]=(t?"%c":"")+this.namespace+(t?" %c":" ")+e[0]+(t?"%c ":" ")+"+"+n.humanize(this.diff),!t)return e;var r="color: "+this.color;e=[e[0],r,"color: inherit"].concat(Array.prototype.slice.call(e,1));var o=0,i=0;return e[0].replace(/%[a-z%]/g,function(e){"%%"!==e&&(o++,"%c"===e&&(i=o))}),e.splice(i,0,r),e}function i(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function s(e){try{null==e?n.storage.removeItem("debug"):n.storage.debug=e}catch(e){}}function a(){var e;try{e=n.storage.debug}catch(e){}return e}function u(){try{return window.localStorage}catch(e){}}n=t.exports=e("./debug"),n.log=i,n.formatArgs=o,n.save=s,n.load=a,n.useColors=r,n.storage="undefined"!=typeof chrome&&"undefined"!=typeof chrome.storage?chrome.storage.local:u(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(e){return JSON.stringify(e)},n.enable(a())},{"./debug":31}],31:[function(e,t,n){function r(){return n.colors[f++%n.colors.length]}function o(e){function t(){}function o(){var e=o,t=+new Date,i=t-(c||t);e.diff=i,e.prev=c,e.curr=t,c=t,null==e.useColors&&(e.useColors=n.useColors()),null==e.color&&e.useColors&&(e.color=r());var s=Array.prototype.slice.call(arguments);s[0]=n.coerce(s[0]),"string"!=typeof s[0]&&(s=["%o"].concat(s));var a=0;s[0]=s[0].replace(/%([a-z%])/g,function(t,r){if("%%"===t)return t;a++;var o=n.formatters[r];if("function"==typeof o){var i=s[a];t=o.call(e,i),s.splice(a,1),a--}return t}),"function"==typeof n.formatArgs&&(s=n.formatArgs.apply(e,s));var u=o.log||n.log||console.log.bind(console);u.apply(e,s)}t.enabled=!1,o.enabled=!0;var i=n.enabled(e)?o:t;return i.namespace=e,i}function i(e){n.save(e);for(var t=(e||"").split(/[\s,]+/),r=t.length,o=0;o0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function n(){this.removeListener(e,n),r||(r=!0,t.apply(this,arguments))}if(!o(t))throw TypeError("listener must be a function");var r=!1;return n.listener=t,this.on(e,n),this},r.prototype.removeListener=function(e,t){var n,r,i,a;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],i=n.length,r=-1,n===t||o(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(s(n)){for(a=i;a-- >0;)if(n[a]===t||n[a].listener&&n[a].listener===t){r=a;break}if(r<0)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(r,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],o(n))this.removeListener(e,n);else if(n)for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(o(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},{}],36:[function(e,t,n){function r(e,t){var n=this;return this instanceof r?(t=t||{},o.call(this,t),this._offset=0,this._ready=!1,this._file=e,this._size=e.size,this._chunkSize=t.chunkSize||Math.max(this._size/1e3,204800),this.reader=new FileReader,void this._generateHeaderBlocks(e,t,function(e,t){return e?n.emit("error",e):(Array.isArray(t)&&t.forEach(function(e){n.push(e)}),n._ready=!0,void n.emit("_ready"))})):new r(e,t)}var o=e("readable-stream").Readable,i=e("inherits"),s=e("typedarray-to-buffer");i(r,o),t.exports=r,r.prototype._generateHeaderBlocks=function(e,t,n){n(null,[])},r.prototype._read=function(){if(!this._ready)return void this.once("_ready",this._read.bind(this));var e=this,t=this.reader,n=this._offset,r=this._offset+this._chunkSize;return r>this._size&&(r=this._size),n===this._size?(this.destroy(),void this.push(null)):(t.onload=function(){e._offset=r,e.push(s(t.result))},t.onerror=function(){e.emit("error",t.error)},void t.readAsArrayBuffer(this._file.slice(n,r)))},r.prototype.destroy=function(){if(this._file=null,this.reader){this.reader.onload=null,this.reader.onerror=null;try{this.reader.abort()}catch(e){}}this.reader=null}},{inherits:42,"readable-stream":82,"typedarray-to-buffer":108}],37:[function(e,t,n){t.exports=function(e,t){function n(e,r){return e.reduce(function(e,o){return Array.isArray(o)&&r>1,f=-7,d=n?o-1:0,h=n?-1:1,l=e[t+d];for(d+=h,i=l&(1<<-f)-1,l>>=-f,f+=a;f>0;i=256*i+e[t+d],d+=h,f-=8);for(s=i&(1<<-f)-1,i>>=-f,f+=r;f>0;s=256*s+e[t+d],d+=h,f-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:(l?-1:1)*(1/0);s+=Math.pow(2,r),i-=c}return(l?-1:1)*s*Math.pow(2,i-r)},n.write=function(e,t,n,r,o,i){var s,a,u,c=8*i-o-1,f=(1<>1,h=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=r?0:i-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=f):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+d>=1?h/u:h*Math.pow(2,1-d),t*u>=2&&(s++,u/=2),s+d>=f?(a=0,s=f):s+d>=1?(a=(t*u-1)*Math.pow(2,o),s+=d):(a=t*Math.pow(2,d-1)*Math.pow(2,o),s=0));o>=8;e[n+l]=255&a,l+=p,a/=256,o-=8);for(s=s<0;e[n+l]=255&s,l+=p,s/=256,c-=8);e[n+l-p]|=128*m}},{}],41:[function(e,t,n){(function(e){function n(e){if(!(this instanceof n))return new n(e);if(this.store=e,this.chunkLength=e.chunkLength,!this.store||!this.store.get||!this.store.put)throw new Error("First argument must be abstract-chunk-store compliant");this.mem=[]}function r(t,n,r){e.nextTick(function(){t&&t(n,r)})}t.exports=n,n.prototype.put=function(e,t,n){var r=this;r.mem[e]=t,r.store.put(e,t,function(t){r.mem[e]=null,n&&n(t)})},n.prototype.get=function(e,t,n){if("function"==typeof t)return this.get(e,null,t);var o=t&&t.offset||0,i=t&&t.length&&o+t.length,s=this.mem[e];return s?r(n,null,t?s.slice(o,i):s):void this.store.get(e,t,n)},n.prototype.close=function(e){this.store.close(e)},n.prototype.destroy=function(e){this.store.destroy(e)}}).call(this,e("_process"))},{_process:67}],42:[function(e,t,n){"function"==typeof Object.create?t.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:t.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],43:[function(e,t,n){var r=127;t.exports=function(e){for(var t=0,n=e.length;tr)return!1;return!0}},{}],44:[function(e,t,n){function r(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function o(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&r(e.slice(0,0))}t.exports=function(e){return null!=e&&(r(e)||o(e)||!!e._isBuffer)}},{}],45:[function(e,t,n){"use strict";function r(e){return o.existsSync(e)&&o.statSync(e).isFile()}var o=e("fs");t.exports=function(e,t){return t?void o.stat(e,function(e,n){return e?t(e):t(null,n.isFile())}):r(e)},t.exports.sync=r},{fs:22}],46:[function(e,t,n){function r(e){return o(e)||i(e)}function o(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 i(e){return a[s.call(e)]}t.exports=r,r.strict=o,r.loose=i;var s=Object.prototype.toString,a={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0}},{}],47:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],48:[function(e,t,n){"use strict";n.re=/^npm-debug\.log$|^\..*\.swp$|^\.DS_Store$|^\.AppleDouble$|^\.LSOverride$|^Icon\r$|^\._.*|^\.Spotlight-V100$|\.Trashes|^__MACOSX$|~$|^Thumbs\.db$|^ehthumbs\.db$|^Desktop\.ini$/,n.is=function(e){return n.re.test(e)},n.not=n.isnt=function(e){return!n.is(e)}},{}],49:[function(e,t,n){(function(n){function r(e){var t={},r=e.split("magnet:?")[1],o=r&&r.length>=0?r.split("&"):[];o.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("+")),t[r])if(Array.isArray(t[r]))t[r].push(o);else{var i=t[r];t[r]=[i,o]}else t[r]=o}});var s;if(t.xt){var u=Array.isArray(t.xt)?t.xt:[t.xt];u.forEach(function(e){if(s=e.match(/^urn:btih:(.{40})/))t.infoHash=s[1].toLowerCase();else if(s=e.match(/^urn:btih:(.{32})/)){var r=i.decode(s[1]);t.infoHash=new n(r,"binary").toString("hex")}})}return t.infoHash&&(t.infoHashBuffer=new n(t.infoHash,"hex")),t.dn&&(t.name=t.dn),t.kt&&(t.keywords=t.kt),"string"==typeof t.tr?t.announce=[t.tr]:Array.isArray(t.tr)?t.announce=t.tr:t.announce=[],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)),a(t.announce),a(t.urlList),t}function o(e){e=s(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){!(r>0||o>0)||"kt"===n&&0!==o||(t+="&"),"dn"===n&&(e=encodeURIComponent(e).replace(/%20/g,"+")),"tr"!==n&&"xs"!==n&&"as"!==n&&"ws"!==n||(e=encodeURIComponent(e)),"kt"===n&&(e=encodeURIComponent(e)),t+="kt"===n&&o>0?"+"+e:n+"="+e})}),t}t.exports=r,t.exports.decode=r,t.exports.encode=o;var i=e("thirty-two"),s=e("xtend"),a=e("uniq")}).call(this,e("buffer").Buffer)},{buffer:24,"thirty-two":103,uniq:110,xtend:119}],50:[function(e,t,n){function r(e,t){var n=this;if(!(n instanceof r))return new r(e,t);if(!u)throw new Error("web browser lacks MediaSource support");t||(t={}),n._bufferDuration=t.bufferDuration||c,n._elem=e,n._mediaSource=new u,n._streams=[],n.detailedError=null,n._errorHandler=function(){n._elem.removeEventListener("error",n._errorHandler);var e=n._streams.slice();e.forEach(function(e){e.destroy(n._elem.error)})},n._elem.addEventListener("error",n._errorHandler),n._elem.src=window.URL.createObjectURL(n._mediaSource)}function o(e,t){var n=this;if(s.Writable.call(n),n._wrapper=e,n._elem=e._elem,n._mediaSource=e._mediaSource,n._allStreams=e._streams,n._allStreams.push(n),n._bufferDuration=e._bufferDuration,n._sourceBuffer=null,n._openHandler=function(){n._onSourceOpen()},n._flowHandler=function(){n._flow()},"string"==typeof t)n._type=t,"open"===n._mediaSource.readyState?n._createSourceBuffer():n._mediaSource.addEventListener("sourceopen",n._openHandler);else if(null===t._sourceBuffer)t.destroy(),n._type=t._type,n._mediaSource.addEventListener("sourceopen",n._openHandler);else{if(!t._sourceBuffer)throw new Error("The argument to MediaElementWrapper.createWriteStream must be a string or a previous stream returned from that function");t.destroy(),n._type=t._type,n._sourceBuffer=t._sourceBuffer,n._sourceBuffer.addEventListener("updateend",n._flowHandler)}n._elem.addEventListener("timeupdate",n._flowHandler),n.on("error",function(e){n._wrapper.error(e)}),n.on("finish",function(){if(!n.destroyed&&(n._finished=!0,n._allStreams.every(function(e){return e._finished})))try{n._mediaSource.endOfStream()}catch(e){}})}t.exports=r;var i=e("inherits"),s=e("readable-stream"),a=e("to-arraybuffer"),u="undefined"!=typeof window&&window.MediaSource,c=60;r.prototype.createWriteStream=function(e){var t=this;return new o(t,e)},r.prototype.error=function(e){var t=this;t.detailedError||(t.detailedError=e);try{t._mediaSource.endOfStream("decode")}catch(e){}},i(o,s.Writable),o.prototype._onSourceOpen=function(){var e=this;e.destroyed||(e._mediaSource.removeEventListener("sourceopen",e._openHandler),e._createSourceBuffer())},o.prototype.destroy=function(e){var t=this;t.destroyed||(t.destroyed=!0,t._allStreams.splice(t._allStreams.indexOf(t),1),t._mediaSource.removeEventListener("sourceopen",t._openHandler),t._elem.removeEventListener("timeupdate",t._flowHandler),t._sourceBuffer&&(t._sourceBuffer.removeEventListener("updateend",t._flowHandler),"open"===t._mediaSource.readyState&&t._sourceBuffer.abort()),e&&t.emit("error",e),t.emit("close"))},o.prototype._createSourceBuffer=function(){var e=this;if(!e.destroyed)if(u.isTypeSupported(e._type)){if(e._sourceBuffer=e._mediaSource.addSourceBuffer(e._type),e._sourceBuffer.addEventListener("updateend",e._flowHandler),e._cb){var t=e._cb;e._cb=null,t()}}else e.destroy(new Error("The provided type is not supported"))},o.prototype._write=function(e,t,n){var r=this;if(!r.destroyed){if(!r._sourceBuffer)return void(r._cb=function(o){return o?n(o):void r._write(e,t,n)});if(r._sourceBuffer.updating)return n(new Error("Cannot append buffer while source buffer updating"));try{r._sourceBuffer.appendBuffer(a(e))}catch(e){return void r.destroy(e)}r._cb=n}},o.prototype._flow=function(){var e=this;if(!e.destroyed&&e._sourceBuffer&&!e._sourceBuffer.updating&&!("open"===e._mediaSource.readyState&&e._getBufferDuration()>e._bufferDuration)&&e._cb){var t=e._cb;e._cb=null,t()}};var f=0;o.prototype._getBufferDuration=function(){for(var e=this,t=e._sourceBuffer.buffered,n=e._elem.currentTime,r=-1,o=0;on)break;(r>=0||n<=s)&&(r=s)}var a=r-n;return a<0&&(a=0),a}},{inherits:42,"readable-stream":82,"to-arraybuffer":105}],51:[function(e,t,n){(function(e){function n(e,t){if(!(this instanceof n))return new n(e,t);if(t||(t={}),this.chunkLength=Number(e),!this.chunkLength)throw new Error("First argument must be a chunk length");this.chunks=[],this.closed=!1,this.length=Number(t.length)||1/0,this.length!==1/0&&(this.lastChunkLength=this.length%this.chunkLength||this.chunkLength,this.lastChunkIndex=Math.ceil(this.length/this.chunkLength)-1)}function r(t,n,r){e.nextTick(function(){t&&t(n,r)})}t.exports=n,n.prototype.put=function(e,t,n){if(this.closed)return r(n,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?(this.chunks[e]=t,void 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)return r(n,new Error("Chunk not found"));if(!t)return r(n,null,o);var i=t.offset||0,s=t.length||o.length-i;r(n,null,o.slice(i,s+i))},n.prototype.close=n.prototype.destroy=function(e){return this.closed?r(e,new Error("Storage is closed")):(this.closed=!0,this.chunks=null,void r(e,null))}}).call(this,e("_process"))},{_process:67}],52:[function(e,t,n){(function(t){function r(e,t,n){for(var r=t;r=8;){var a=p.decode(e,s,r);i.children.push(a),i[a.type]=a,s+=a.length}return i},n.VisualSampleEntry.encodingLength=function(e){var t=78,n=e.children||[];return n.forEach(function(e){t+=p.encodingLength(e)}),t},n.avcC={},n.avcC.encode=function(e,r,o){r=r?r.slice(o):t(e.buffer.length),e.buffer.copy(r),n.avcC.encode.bytes=e.buffer.length},n.avcC.decode=function(e,n,r){return e=e.slice(n,r),{mimeCodec:e.toString("hex",1,4),buffer:new t(e)}},n.avcC.encodingLength=function(e){return e.buffer.length},n.mp4a=n.AudioSampleEntry={},n.AudioSampleEntry.encode=function(e,o,i){o=o?o.slice(i):new t(n.AudioSampleEntry.encodingLength(e)),r(o,0,6),o.writeUInt16BE(e.dataReferenceIndex||0,6),r(o,8,16),o.writeUInt16BE(e.channelCount||2,16),o.writeUInt16BE(e.sampleSize||16,18),r(o,20,24),o.writeUInt32BE(e.sampleRate||0,24);var s=28,a=e.children||[];a.forEach(function(e){p.encode(e,o,s),s+=p.encode.bytes}),n.AudioSampleEntry.encode.bytes=s},n.AudioSampleEntry.decode=function(e,t,n){e=e.slice(t,n);for(var r=n-t,o={dataReferenceIndex:e.readUInt16BE(6),channelCount:e.readUInt16BE(16),sampleSize:e.readUInt16BE(18),sampleRate:e.readUInt32BE(24),children:[]},i=28;r-i>=8;){var s=p.decode(e,i,r);o.children.push(s),o[s.type]=s,i+=s.length}return o},n.AudioSampleEntry.encodingLength=function(e){var t=28,n=e.children||[];return n.forEach(function(e){t+=p.encodingLength(e)}),t},n.esds={},n.esds.encode=function(e,r,o){r=r?r.slice(o):t(e.buffer.length),e.buffer.copy(r,0),n.esds.encode.bytes=e.buffer.length},n.esds.decode=function(e,n,r){e=e.slice(n,r);var o=m.Descriptor.decode(e,0,e.length),i="ESDescriptor"===o.tagName?o:{},s=i.DecoderConfigDescriptor||{},a=s.oti||0,u=s.DecoderSpecificInfo,c=u?(248&u.buffer.readUInt8(0))>>3:0,f=null;return a&&(f=a.toString(16),c&&(f+="."+c)),{mimeCodec:f,buffer:new t(e.slice(0))}},n.esds.encodingLength=function(e){return e.buffer.length},n.stsz={},n.stsz.encode=function(e,r,o){var i=e.entries||[];r=r?r.slice(o):t(n.stsz.encodingLength(e)),r.writeUInt32BE(0,0),r.writeUInt32BE(i.length,4);for(var s=0;si&&(c=1),t.writeUInt32BE(c,n),t.write(e.type,n+4,4,"ascii");var f=n+8;if(1===c&&(r.encode(e.length,t,f),f+=8),o.fullBoxes[u]&&(t.writeUInt32BE(e.flags||0,f),t.writeUInt8(e.version||0,f),f+=4),a[u]){var d=a[u];d.forEach(function(n){if(5===n.length){var r=e[n]||[];n=n.substr(0,4),r.forEach(function(e){s._encode(e,t,f),f+=s.encode.bytes})}else e[n]&&(s._encode(e[n],t,f),f+=s.encode.bytes)}),e.otherBoxes&&e.otherBoxes.forEach(function(e){s._encode(e,t,f),f+=s.encode.bytes})}else if(o[u]){var h=o[u].encode;h(e,t,f),f+=h.bytes}else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+u+"') or `buffer` must be set");var l=e.buffer;l.copy(t,f),f+=e.buffer.length}return s.encode.bytes=f-n,t},s.readHeaders=function(e,t,n){if(t=t||0,n=n||e.length,n-t<8)return 8;var i=e.readUInt32BE(t),s=e.toString("ascii",t+4,t+8),a=t+8;if(1===i){if(n-t<16)return 16;i=r.decode(e,a),a+=8}var u,c;return o.fullBoxes[s]&&(u=e.readUInt8(a),c=16777215&e.readUInt32BE(a),a+=4),{length:i,headersLen:a-t,contentLen:i-(a-t),type:s,version:u,flags:c}},s.decode=function(e,t,n){t=t||0,n=n||e.length;var r=s.readHeaders(e,t,n);if(!r||r.length>n-t)throw new Error("Data too short");return s.decodeWithoutHeaders(r,e,t+r.headersLen,t+r.length)},s.decodeWithoutHeaders=function(e,n,r,i){r=r||0,i=i||n.length;var u=e.type,c={};if(a[u]){c.otherBoxes=[];for(var f=a[u],d=r;i-d>=8;){var h=s.decode(n,d,i);if(d+=h.length,f.indexOf(h.type)>=0)c[h.type]=h;else if(f.indexOf(h.type+"s")>=0){var l=h.type+"s",p=c[l]=c[l]||[];p.push(h)}else c.otherBoxes.push(h)}}else if(o[u]){var m=o[u].decode;c=m(n,r,i)}else c.buffer=new t(n.slice(r,i));return c.length=e.length,c.contentLen=e.contentLen,c.type=e.type,c.version=e.version,c.flags=e.flags,c},s.encodingLength=function(e){var t=e.type,n=8;if(o.fullBoxes[t]&&(n+=4),a[t]){var r=a[t];r.forEach(function(t){if(5===t.length){var r=e[t]||[];t=t.substr(0,4),r.forEach(function(e){e.type=t,n+=s.encodingLength(e)})}else if(e[t]){var o=e[t];o.type=t,n+=s.encodingLength(o)}}),e.otherBoxes&&e.otherBoxes.forEach(function(e){n+=s.encodingLength(e)})}else if(o[t])n+=o[t].encodingLength(e);else{if(!e.buffer)throw new Error("Either `type` must be set to a known type (not'"+t+"') or `buffer` must be set");n+=e.buffer.length}return n>i&&(n+=8),e.length=n,n}}).call(this,e("buffer").Buffer)},{"./boxes":52,buffer:24,uint64be:109}],55:[function(e,t,n){(function(n){function r(){return this instanceof r?(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,void 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"),u=e("mp4-box-encoding"),c=new n(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.length1e4)){var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*d;case"days":case"day":case"d":return n*f;case"hours":case"hour":case"hrs":case"hr":case"h":return n*c;case"minutes":case"minute":case"mins":case"min":case"m":return n*u;case"seconds":case"second":case"secs":case"sec":case"s":return n*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n}}}}function o(e){return e>=f?Math.round(e/f)+"d":e>=c?Math.round(e/c)+"h":e>=u?Math.round(e/u)+"m":e>=a?Math.round(e/a)+"s":e+"ms"}function i(e){return s(e,f,"day")||s(e,c,"hour")||s(e,u,"minute")||s(e,a,"second")||e+" ms"}function s(e,t,n){if(!(e0?[e["url-list"]]:[]),t.urlList=(e["url-list"]||[]).map(function(e){return e.toString()}),d(t.announce),d(t.urlList);var r=e.info.files||[e.info];t.files=r.map(function(e,n){var o=[].concat(t.name,e["path.utf-8"]||e.path||[]).map(function(e){return e.toString()});return{path:c.join.apply(null,[c.sep].concat(o)).slice(1),name:o[o.length-1],length:e.length,offset:r.slice(0,n).reduce(i,0)}}),t.length=r.reduce(i,0);var o=t.files[t.files.length-1];return t.pieceLength=e.info["piece length"],t.lastPieceLength=(o.offset+o.length)%t.pieceLength||t.pieceLength,t.pieces=s(e.info.pieces),t}function o(e){var t={info:e.info};return t["announce-list"]=(e.announce||[]).map(function(e){return t.announce||(t.announce=e),e=new n(e,"utf8"),[e]}),t["url-list"]=e.urlList||[],e.created&&(t["creation date"]=e.created.getTime()/1e3|0),e.createdBy&&(t["created by"]=e.createdBy),e.comment&&(t.comment=e.comment),u.encode(t)}function i(e,t){return e+t.length}function s(e){for(var t=[],n=0;n=0;r--){var o=e[r];"."===o?e.splice(r,1):".."===o?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r=-1&&!o;i--){var s=i>=0?arguments[i]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(n=s+"/"+n,o="/"===s.charAt(0))}return n=t(r(n.split("/"),function(e){return!!e}),!o).join("/"),(o?"/":"")+n||"."},n.normalize=function(e){var o=n.isAbsolute(e),i="/"===s(e,-1);return e=t(r(e.split("/"),function(e){return!!e}),!o).join("/"),e||o||(e="."),e&&i&&(e+="/"),(o?"/":"")+e},n.isAbsolute=function(e){return"/"===e.charAt(0)},n.join=function(){var e=Array.prototype.slice.call(arguments,0);return n.normalize(r(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},n.relative=function(e,t){function r(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=n.resolve(e).substr(1),t=n.resolve(t).substr(1);for(var o=r(e.split("/")),i=r(t.split("/")),s=Math.min(o.length,i.length),a=s,u=0;u1)for(var n=1;n0;return f(o,s,a,function(e){n||(n=e),e&&r.forEach(d),s||(r.forEach(d),t(n))})});return e.reduce(h)};t.exports=l},{"end-of-stream":33,fs:22,once:61}],69:[function(t,n,r){(function(t){!function(o){function i(e){throw new RangeError(P[e])}function s(e,t){for(var n=e.length,r=[];n--;)r[n]=t(e[n]);return r}function a(e,t){var n=e.split("@"),r="";n.length>1&&(r=n[0]+"@",e=n[1]),e=e.replace(U,".");var o=e.split("."),i=s(o,t).join(".");return r+i}function u(e){for(var t,n,r=[],o=0,i=e.length;o=55296&&t<=56319&&o65535&&(e-=65536,t+=j(e>>>10&1023|55296),e=56320|1023&e),t+=j(e)}).join("")}function f(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:k}function d(e,t){return e+22+75*(e<26)-((0!=t)<<5)}function h(e,t,n){var r=0;for(e=n?M(e/I):e>>1,e+=M(e/t);e>O*S>>1;r+=k)e=M(e/O);return M(r+(O+1)*e/(e+B))}function l(e){var t,n,r,o,s,a,u,d,l,p,m=[],g=e.length,y=0,_=T,v=A;for(n=e.lastIndexOf(C),n<0&&(n=0),r=0;r=128&&i("not-basic"),m.push(e.charCodeAt(r));for(o=n>0?n+1:0;o=g&&i("invalid-input"),d=f(e.charCodeAt(o++)),(d>=k||d>M((E-y)/a))&&i("overflow"),y+=d*a,l=u<=v?x:u>=v+S?S:u-v,!(dM(E/p)&&i("overflow"),a*=p;t=m.length+1,v=h(y-s,t,0==s),M(y/t)>E-_&&i("overflow"),_+=M(y/t),y%=t,m.splice(y++,0,_)}return c(m)}function p(e){var t,n,r,o,s,a,c,f,l,p,m,g,y,_,v,b=[];for(e=u(e),g=e.length,t=T,n=0,s=A,a=0;a=t&&mM((E-n)/y)&&i("overflow"),n+=(c-t)*y,t=c,a=0;aE&&i("overflow"),m==t){for(f=n,l=k;p=l<=s?x:l>=s+S?S:l-s,!(f= 0x80 (not a basic code point)","invalid-input":"Invalid input"},O=k-x,M=Math.floor,j=String.fromCharCode;if(b={version:"1.4.1",ucs2:{decode:u,encode:c},decode:l,encode:p,toASCII:g,toUnicode:m},"function"==typeof e&&"object"==typeof e.amd&&e.amd)e("punycode",function(){return b});else if(y&&_)if(n.exports==y)_.exports=b;else for(w in b)b.hasOwnProperty(w)&&(y[w]=b[w]);else o.punycode=b}(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],70:[function(e,t,n){"use strict";function r(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.exports=function(e,t,n,i){t=t||"&",n=n||"=";var s={};if("string"!=typeof e||0===e.length)return s;var a=/\+/g;e=e.split(t);var u=1e3;i&&"number"==typeof i.maxKeys&&(u=i.maxKeys);var c=e.length;u>0&&c>u&&(c=u);for(var f=0;f=0?(d=m.substr(0,g),h=m.substr(g+1)):(d=m,h=""),l=decodeURIComponent(d),p=decodeURIComponent(h),r(s,l)?o(s[l])?s[l].push(p):s[l]=[s[l],p]:s[l]=p}return s};var o=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{}],71:[function(e,t,n){"use strict";function r(e,t){if(e.map)return e.map(t);for(var n=[],r=0;r65536)throw new Error("requested too many random bytes");var i=new n.Uint8Array(t);t>0&&s.getRandomValues(i);var a=new r(i.buffer);return"function"==typeof o?e.nextTick(function(){o(null,a)}):a}var s=n.crypto||n.msCrypto;s&&s.getRandomValues?t.exports=i:t.exports=o}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer); +},{_process:67,buffer:24}],75:[function(e,t,n){function r(e){var t=this;return t instanceof r?(i.Writable.call(t),t.destroyed=!1,t._queue=[],t._position=e||0,t._cb=null,t._buffer=null,void(t._out=null)):new r(e)}var o=e("inherits"),i=e("readable-stream");t.exports=r,o(r,i.Writable),r.prototype._write=function(e,t,n){for(var r=this,o=!0;;){if(r.destroyed)return;if(0===r._queue.length)return r._buffer=e,void(r._cb=n);r._buffer=null;var i=r._queue[0],s=Math.max(i.start-r._position,0),a=i.end-r._position;if(s>=e.length)return r._position+=e.length,n(null);var u;if(a>e.length){r._position+=e.length,u=0===s?e:e.slice(s),o=i.stream.write(u)&&o;break}r._position+=a,u=0===s&&a===e.length?e:e.slice(s,a),o=i.stream.write(u)&&o,i.last&&i.stream.end(),e=e.slice(a),r._queue.shift()}o?n(null):i.stream.once("drain",n.bind(null,null))},r.prototype.slice=function(e){var t=this;if(t.destroyed)return null;e instanceof Array||(e=[e]);var n=new i.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},r.prototype.destroy=function(e){var t=this;t.destroyed||(t.destroyed=!0,e&&t.emit("error",e))}},{inherits:42,"readable-stream":82}],76:[function(e,t,n){"use strict";function r(e){return this instanceof r?(c.call(this,e),f.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",o)):new r(e)}function o(){this.allowHalfOpen||this._writableState.ended||a(i,this)}function i(e){e.end()}var s=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};t.exports=r;var a=e("process-nextick-args"),u=e("core-util-is");u.inherits=e("inherits");var c=e("./_stream_readable"),f=e("./_stream_writable");u.inherits(r,c);for(var d=s(f.prototype),h=0;h0)if(t.ended&&!o){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&o){var u=new Error("stream.unshift() after end event");e.emit("error",u)}else{var c;!t.decoder||o||r||(n=t.decoder.write(n),c=!t.objectMode&&0===n.length),o||(t.reading=!1),c||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,o?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&h(e))),p(e,t)}else o||(t.reading=!1);return a(t)}function a(e){return!e.ended&&(e.needReadable||e.length=N?e=N:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function c(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=u(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function f(e,t){var n=null;return U.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function d(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,h(e)}}function h(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(j("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?T(l,e):l(e))}function l(e){j("emit readable"),e.emit("readable"),b(e)}function p(e,t){t.readingMore||(t.readingMore=!0,T(m,e,t))}function m(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=E(e,t.buffer,t.decoder),n}function E(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,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=i.slice(s));break}++r}return t.length-=r,o}function x(e,t){var n=P.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,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(s));break}++o}return t.length-=o,n}function S(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,T(B,t,e))}function B(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function I(e,t){for(var n=0,r=e.length;n=t.highWaterMark||t.ended))return j("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?S(this):h(this),null;if(e=c(e,t),0===e&&t.ended)return 0===t.length&&S(this),null;var r=t.needReadable;j("need readable",r),(0===t.length||t.length-e0?w(e,t):null,null===o?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&S(this)),null!==o&&this.emit("data",o),o},i.prototype._read=function(e){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,t){function o(e){j("onunpipe"),e===h&&s()}function i(){j("onend"),e.end()}function s(){j("cleanup"),e.removeListener("close",c),e.removeListener("finish",f),e.removeListener("drain",y),e.removeListener("error",u),e.removeListener("unpipe",o),h.removeListener("end",i),h.removeListener("end",s),h.removeListener("data",a),_=!0,!l.awaitDrain||e._writableState&&!e._writableState.needDrain||y()}function a(t){j("ondata"),v=!1;var n=e.write(t);!1!==n||v||((1===l.pipesCount&&l.pipes===e||l.pipesCount>1&&A(l.pipes,e)!==-1)&&!_&&(j("false write response, pause",h._readableState.awaitDrain),h._readableState.awaitDrain++,v=!0),h.pause())}function u(t){j("onerror",t),d(),e.removeListener("error",u),0===R(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",f),d()}function f(){j("onfinish"),e.removeListener("close",c),d()}function d(){j("unpipe"),h.unpipe(e)}var h=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=e;break;case 1:l.pipes=[l.pipes,e];break;default:l.pipes.push(e)}l.pipesCount+=1,j("pipe count=%d opts=%j",l.pipesCount,t);var p=(!t||t.end!==!1)&&e!==n.stdout&&e!==n.stderr,m=p?i:s;l.endEmitted?T(m):h.once("end",m),e.on("unpipe",o);var y=g(h);e.on("drain",y);var _=!1,v=!1;return h.on("data",a),r(e,"error",u),e.once("close",c),e.once("finish",f),e.emit("pipe",h),l.flowing||(j("pipe resume"),h.resume()),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o-1?setImmediate:k;s.WritableState=i;var S=e("core-util-is");S.inherits=e("inherits");var B,I={deprecate:e("util-deprecate")};!function(){try{B=e("stream")}catch(e){}finally{B||(B=e("events").EventEmitter)}}();var A=e("buffer").Buffer,T=e("buffer-shims");S.inherits(s,B);var C;i.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(i.prototype,"buffer",{get:I.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")})}catch(e){}}();var C;s.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},s.prototype.write=function(e,t,n){var o=this._writableState,i=!1;return"function"==typeof t&&(n=t,t=null),A.isBuffer(e)?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof n&&(n=r),o.ended?a(this,n):u(this,o,e,n)&&(o.pendingcb++,i=f(this,o,e,t,n)),i},s.prototype.cork=function(){var e=this._writableState;e.corked++},s.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.finished||e.bufferProcessing||!e.bufferedRequest||y(this,e))},s.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},s.prototype._write=function(e,t,n){n(new Error("not implemented"))},s.prototype._writev=null,s.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!==e&&void 0!==e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||r.finished||w(this,r,n)}}).call(this,e("_process"))},{"./_stream_duplex":76,_process:67,buffer:24,"buffer-shims":23,"core-util-is":28,events:35,inherits:42,"process-nextick-args":66,"util-deprecate":115}],81:[function(e,t,n){"use strict";function r(){this.head=null,this.tail=null,this.length=0}var o=(e("buffer").Buffer,e("buffer-shims"));t.exports=r,r.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},r.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},r.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},r.prototype.clear=function(){this.head=this.tail=null,this.length=0},r.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},r.prototype.concat=function(e){if(0===this.length)return o.alloc(0);if(1===this.length)return this.head.data;for(var t=o.allocUnsafe(e>>>0),n=this.head,r=0;n;)n.data.copy(t,r),r+=n.data.length,n=n.next;return t}},{buffer:24,"buffer-shims":23}],82:[function(e,t,n){(function(r){var o=function(){try{return e("stream")}catch(e){}}();n=t.exports=e("./lib/_stream_readable.js"),n.Stream=o||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"),!r.browser&&"disable"===r.env.READABLE_STREAM&&o&&(t.exports=o)}).call(this,e("_process"))},{"./lib/_stream_duplex.js":76,"./lib/_stream_passthrough.js":77,"./lib/_stream_readable.js":78,"./lib/_stream_transform.js":79,"./lib/_stream_writable.js":80,_process:67}],83:[function(e,t,n){function r(e,t,n,r){"function"==typeof n&&(r=n,n={}),n||(n={}),r||(r=function(){}),a(e),c(n),"string"==typeof t&&(t=document.querySelector(t)),i(e,function(n){if(t.nodeName!==n.toUpperCase()){var r=l.extname(e.name).toLowerCase();throw new Error('Cannot render "'+r+'" inside a "'+t.nodeName.toLowerCase()+'" element, expected "'+n+'"')}return t},n,r)}function o(e,t,n,r){function o(e){return"video"===e||"audio"===e?s(e):u(e)}function s(e){var r=u(e);return n.controls&&(r.controls=!0),n.autoplay&&(r.autoplay=!0),t.appendChild(r),r}function u(e){var n=document.createElement(e);return t.appendChild(n),n}function f(e,t){e&&t&&t.remove(),r(e,t)}if("function"==typeof n&&(r=n,n={}),n||(n={}),r||(r=function(){}),a(e),c(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.");i(e,o,n,f)}function i(e,t,n,r){function o(){function r(){f("Use `videostream` package for "+e.name),p(),B.addEventListener("error",d),B.addEventListener("loadstart",a),B.addEventListener("canplay",c),m(e,B)}function o(){f("Use MediaSource API for "+e.name),p(),B.addEventListener("error",l),B.addEventListener("loadstart",a),B.addEventListener("canplay",c);var t=new h(B),n=t.createWriteStream(u(e.name));e.createReadStream().pipe(n),A&&(B.currentTime=A)}function i(){f("Use Blob URL for "+e.name),p(),B.addEventListener("error",S),B.addEventListener("loadstart",a),B.addEventListener("canplay",c),s(e,function(e,t){return e?S(e):(B.src=t,void(A&&(B.currentTime=A)))})}function d(e){f("videostream error: fallback to MediaSource API: %o",e.message||e),B.removeEventListener("error",d),B.removeEventListener("canplay",c),o()}function l(t){return f("MediaSource API error: fallback to Blob URL: %o",t.message||t),"number"==typeof e.length&&e.length>n.maxBlobLength?(f("File length too large for Blob URL approach: %d (max: %d)",e.length,n.maxBlobLength),S(new Error("File length too large for Blob URL approach: "+e.length+" (max: "+n.maxBlobLength+")"))):(B.removeEventListener("error",l),B.removeEventListener("canplay",c),void i())}function p(){B||(B=t(_),B.addEventListener("progress",function(){A=B.currentTime}))}var _=y.indexOf(I)>=0?"video":"audio";x?g.indexOf(I)>=0?r():o():i()}function i(){B=t("audio"),s(e,function(e,t){return e?S(e):(B.addEventListener("error",S),B.addEventListener("loadstart",a),B.addEventListener("canplay",c),void(B.src=t))})}function a(){B.removeEventListener("loadstart",a),n.autoplay&&B.play()}function c(){B.removeEventListener("canplay",c),r(null,B)}function p(){B=t("img"),s(e,function(t,n){return t?S(t):(B.src=n,B.alt=e.name,void r(null,B))})}function _(){B=t("iframe"),s(e,function(e,t){return e?S(e):(B.src=t,".pdf"!==I&&(B.sandbox="allow-forms allow-scripts"),void r(null,B))})}function k(){function t(){d(n)?(f('File extension "%s" appears ascii, so will render.',I),_()):(f('File extension "%s" appears non-ascii, will not render.',I),r(new Error('Unsupported file type "'+I+'": Cannot append to DOM')))}f('Unknown file extension "%s" - will attempt to render into iframe',I);var n="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){n+=e}).on("end",t).on("error",r)}function S(t){t.message='Error rendering file "'+e.name+'": '+t.message,f(t.message),r(t)}var B,I=l.extname(e.name).toLowerCase(),A=0;v.indexOf(I)>=0?o():b.indexOf(I)>=0?i():w.indexOf(I)>=0?p():E.indexOf(I)>=0?_():k()}function s(e,t){var r=l.extname(e.name).toLowerCase();p(e.createReadStream(),n.mime[r],t)}function a(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 u(e){var t=l.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 c(e){null==e.autoplay&&(e.autoplay=!0),null==e.controls&&(e.controls=!0),null==e.maxBlobLength&&(e.maxBlobLength=k)}n.render=r,n.append=o,n.mime=e("./lib/mime.json");var f=e("debug")("render-media"),d=e("is-ascii"),h=e("mediasource"),l=e("path"),p=e("stream-to-blob-url"),m=e("videostream"),g=[".m4a",".m4v",".mp4"],y=[".m4v",".mkv",".mp4",".webm"],_=[".m4a",".mp3"],v=[].concat(y,_),b=[".aac",".oga",".ogg",".wav"],w=[".bmp",".gif",".jpeg",".jpg",".png"],E=[".css",".html",".js",".md",".pdf",".txt"],k=2e8,x="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":84,debug:30,"is-ascii":43,mediasource:50,path:64,"stream-to-blob-url":99,videostream:117}],84:[function(e,t,n){t.exports={".3gp":"video/3gpp",".aac":"audio/aac",".aif":"audio/x-aiff",".aiff":"audio/x-aiff",".atom":"application/atom+xml",".avi":"video/x-msvideo",".bmp":"image/bmp",".bz2":"application/x-bzip2",".conf":"text/plain",".css":"text/css",".csv":"text/csv",".diff":"text/x-diff",".doc":"application/msword",".flv":"video/x-flv",".gif":"image/gif",".gz":"application/x-gzip",".htm":"text/html",".html":"text/html",".ico":"image/vnd.microsoft.icon",".ics":"text/calendar",".iso":"application/octet-stream",".jar":"application/java-archive",".jpeg":"image/jpeg",".jpg":"image/jpeg",".js":"application/javascript",".json":"application/json",".less":"text/css",".log":"text/plain",".m3u":"audio/x-mpegurl",".m4a":"audio/mp4",".m4v":"video/mp4",".manifest":"text/cache-manifest",".markdown":"text/x-markdown",".mathml":"application/mathml+xml",".md":"text/x-markdown",".mid":"audio/midi",".midi":"audio/midi",".mov":"video/quicktime",".mp3":"audio/mpeg",".mp4":"video/mp4",".mp4v":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".odp":"application/vnd.oasis.opendocument.presentation",".ods":"application/vnd.oasis.opendocument.spreadsheet",".odt":"application/vnd.oasis.opendocument.text",".oga":"audio/ogg",".ogg":"application/ogg",".pdf":"application/pdf",".png":"image/png",".pps":"application/vnd.ms-powerpoint",".ppt":"application/vnd.ms-powerpoint",".ps":"application/postscript",".psd":"image/vnd.adobe.photoshop",".qt":"video/quicktime",".rar":"application/x-rar-compressed",".rdf":"application/rdf+xml",".rss":"application/rss+xml",".rtf":"application/rtf",".svg":"image/svg+xml",".svgz":"image/svg+xml",".swf":"application/x-shockwave-flash",".tar":"application/x-tar",".tbz":"application/x-bzip-compressed-tar",".text":"text/plain",".tif":"image/tiff",".tiff":"image/tiff",".torrent":"application/x-bittorrent",".ttf":"application/x-font-ttf",".txt":"text/plain",".wav":"audio/wav",".webm":"video/webm",".wma":"audio/x-ms-wma",".wmv":"video/x-ms-wmv",".xls":"application/vnd.ms-excel",".xml":"application/xml",".yaml":"text/yaml",".yml":"text/yaml",".zip":"application/zip"}},{}],85:[function(e,t,n){(function(e){t.exports=function(t,n,r){function o(t){function n(){r&&r(t,s),r=null}d?e.nextTick(n):n()}function i(e,n,r){if(s[e]=r,n&&(f=!0),0===--u||n)o(n);else if(!f&&h0;e+=1);return e},s=function(e,t){for(var n=t>>2;n>2]|=128<<24-(t%4<<3),e[((t>>2)+2&-16)+14]=n/(1<<29)|0,e[((t>>2)+2&-16)+15]=n<<3},u=function(e,t,n,r,o){var i,s=this,a=o%4,u=r%4,c=r-u;if(c>0)switch(a){case 0:e[o+3|0]=s.charCodeAt(n);case 1:e[o+2|0]=s.charCodeAt(n+1);case 2:e[o+1|0]=s.charCodeAt(n+2);case 3:e[0|o]=s.charCodeAt(n+3)}for(i=a;i>2]=s.charCodeAt(n+i)<<24|s.charCodeAt(n+i+1)<<16|s.charCodeAt(n+i+2)<<8|s.charCodeAt(n+i+3);switch(u){case 3:e[o+c+1|0]=s.charCodeAt(n+c+2);case 2:e[o+c+2|0]=s.charCodeAt(n+c+1);case 1:e[o+c+3|0]=s.charCodeAt(n+c)}},c=function(e,t,n,r,o){var i,s=this,a=o%4,u=r%4,c=r-u;if(c>0)switch(a){case 0:e[o+3|0]=s[n];case 1:e[o+2|0]=s[n+1];case 2:e[o+1|0]=s[n+2];case 3:e[0|o]=s[n+3]}for(i=4-a;i>2]=s[n+i]<<24|s[n+i+1]<<16|s[n+i+2]<<8|s[n+i+3];switch(u){case 3:e[o+c+1|0]=s[n+c+2];case 2:e[o+c+2|0]=s[n+c+1];case 1:e[o+c+3|0]=s[n+c]}},f=function(e,t,n,r,i){var s,a=this,u=i%4,c=r%4,f=r-c,d=new Uint8Array(o.readAsArrayBuffer(a.slice(n,n+r)));if(f>0)switch(u){case 0:e[i+3|0]=d[0];case 1:e[i+2|0]=d[1];case 2:e[i+1|0]=d[2];case 3:e[0|i]=d[3]}for(s=4-u;s>2]=d[s]<<24|d[s+1]<<16|d[s+2]<<8|d[s+3];switch(c){case 3:e[i+f+1|0]=d[f+2];case 2:e[i+f+2|0]=d[f+1];case 1:e[i+f+3|0]=d[f]}},d=function(e){switch(r.getDataType(e)){case"string":return u.bind(e);case"array":return c.bind(e);case"buffer":return c.bind(e);case"arraybuffer":return c.bind(new Uint8Array(e));case"view":return c.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return f.bind(e)}},h=new Array(256),l=0;l<256;l++)h[l]=(l<16?"0":"")+l.toString(16);var p=function(e){for(var t=new Uint8Array(e),n=new Array(e.byteLength),r=0;r0)throw new Error("Chunk size must be a multiple of 128 bit");t.maxChunkLen=e,t.padMaxChunkLen=i(e),t.heap=new ArrayBuffer(m(t.padMaxChunkLen+320+20)),t.h32=new Int32Array(t.heap),t.h8=new Int8Array(t.heap),t.core=new n._core({Int32Array:Int32Array,DataView:DataView},{},t.heap),t.buffer=null};g(e||65536);var y=function(e,t){var n=new Int32Array(e,t+320,5);n[0]=1732584193,n[1]=-271733879,n[2]=-1732584194,n[3]=271733878,n[4]=-1009589776},_=function(e,n){var r=i(e),o=new Int32Array(t.heap,0,r>>2);return s(o,e),a(o,e,n),r},v=function(e,n,r){d(e)(t.h8,t.h32,n,r,0)},b=function(e,n,r,o,i){var s=r;i&&(s=_(r,o)),v(e,n,r),t.core.hash(s,t.padMaxChunkLen)},w=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},E=this.rawDigest=function(e){var n=e.byteLength||e.length||e.size||0;y(t.heap,t.padMaxChunkLen);var r=0,o=t.maxChunkLen;for(r=0;n>r+o;r+=o)b(e,r,o,n,!1);return b(e,r,n-r,n,!0),w(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return p(E(e).buffer)}}var r={getDataType:function(t){if("string"==typeof t)return"string";if(t instanceof Array)return"array";if("undefined"!=typeof e&&e.Buffer&&e.Buffer.isBuffer(t))return"buffer";if(t instanceof ArrayBuffer)return"arraybuffer";if(t.buffer instanceof ArrayBuffer)return"view";if(t instanceof Blob)return"blob";throw new Error("Unsupported data type.")}};if(n._core=function e(t,n,r){"use asm";var o=new t.Int32Array(r);function i(e,t){e=e|0;t=t|0;var n=0,r=0,i=0,s=0,a=0,u=0,c=0,f=0,d=0,h=0,l=0,p=0,m=0,g=0;i=o[t+320>>2]|0;a=o[t+324>>2]|0;c=o[t+328>>2]|0;d=o[t+332>>2]|0;l=o[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){s=i;u=a;f=c;h=d;p=l;for(r=0;(r|0)<64;r=r+4|0){g=o[n+r>>2]|0;m=((i<<5|i>>>27)+(a&c|~a&d)|0)+((g+l|0)+1518500249|0)|0;l=d;d=c;c=a<<30|a>>>2;a=i;i=m;o[e+r>>2]=g}for(r=e+64|0;(r|0)<(e+80|0);r=r+4|0){g=(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])<<1|(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])>>>31;m=((i<<5|i>>>27)+(a&c|~a&d)|0)+((g+l|0)+1518500249|0)|0;l=d;d=c;c=a<<30|a>>>2;a=i;i=m;o[r>>2]=g}for(r=e+80|0;(r|0)<(e+160|0);r=r+4|0){g=(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])<<1|(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])>>>31;m=((i<<5|i>>>27)+(a^c^d)|0)+((g+l|0)+1859775393|0)|0;l=d;d=c;c=a<<30|a>>>2;a=i;i=m;o[r>>2]=g}for(r=e+160|0;(r|0)<(e+240|0);r=r+4|0){g=(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])<<1|(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])>>>31;m=((i<<5|i>>>27)+(a&c|a&d|c&d)|0)+((g+l|0)-1894007588|0)|0;l=d;d=c;c=a<<30|a>>>2;a=i;i=m;o[r>>2]=g}for(r=e+240|0;(r|0)<(e+320|0);r=r+4|0){g=(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])<<1|(o[r-12>>2]^o[r-32>>2]^o[r-56>>2]^o[r-64>>2])>>>31;m=((i<<5|i>>>27)+(a^c^d)|0)+((g+l|0)-899497514|0)|0;l=d;d=c;c=a<<30|a>>>2;a=i;i=m;o[r>>2]=g}i=i+s|0;a=a+u|0;c=c+f|0;d=d+h|0;l=l+p|0}o[t+320>>2]=i;o[t+324>>2]=a;o[t+328>>2]=c;o[t+332>>2]=d;o[t+336>>2]=l}return{hash:i}},"undefined"!=typeof t?t.exports=n:"undefined"!=typeof window&&(window.Rusha=n),"undefined"!=typeof FileReaderSync){var o=new FileReaderSync,i=new n(4194304);self.onmessage=function(e){var t,n=e.data.data;try{t=i.digest(n),self.postMessage({id:e.data.id,hash:t})}catch(t){self.postMessage({id:e.data.id,error:t.name})}}}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],88:[function(e,t,n){t.exports=e("buffer")},{buffer:24}],89:[function(e,t,n){(function(e){t.exports=function(t,n){var r=[];t.on("data",function(e){r.push(e)}),t.once("end",function(){n&&n(null,e.concat(r)),n=null}),t.once("error",function(e){n&&n(e),n=null})}}).call(this,e("buffer").Buffer)},{buffer:24}],90:[function(e,t,n){(function(n){function r(e,t){e="string"==typeof e?{url:e}:i(e),t=u(t),e.url&&o(e),null==e.headers&&(e.headers={}),null==e.maxRedirects&&(e.maxRedirects=10);var n=e.json?JSON.stringify(e.body):e.body;e.body=void 0,n&&!e.method&&(e.method="POST"),e.method&&(e.method=e.method.toUpperCase()),e.json&&(e.headers.accept="application/json"),e.json&&n&&(e.headers["content-type"]="application/json");var f=Object.keys(e.headers).some(function(e){return"accept-encoding"===e.toLowerCase()});f||(e.headers["accept-encoding"]="gzip, deflate");var d="https:"===e.protocol?a:s,h=d.request(e,function(n){if(n.statusCode>=300&&n.statusCode<400&&"location"in n.headers)return e.url=n.headers.location,o(e),n.resume(),e.maxRedirects-=1,void(e.maxRedirects>0?r(e,t):t(new Error("too many redirects")));var i="function"==typeof c&&"HEAD"!==e.method;t(null,i?c(n):n)});return h.on("error",t),h.end(n),h}function o(e){var t=f.parse(e.url);t.hostname&&(e.hostname=t.hostname),t.port&&(e.port=t.port),t.protocol&&(e.protocol=t.protocol),t.auth&&(e.auth=t.auth),e.path=t.path,delete e.url}t.exports=r;var i=e("xtend"),s=e("http"),a=e("https"),u=e("once"),c=e("unzip-response"),f=e("url");t.exports.concat=function(e,t){return r(e,function(r,o){if(r)return t(r);var i=[];o.on("data",function(e){i.push(e)}),o.on("end",function(){var r=n.concat(i);if(e.json)try{r=JSON.parse(r.toString())}catch(e){return t(e,o,r)}t(null,o,r)})})},["get","post","put","patch","head","delete"].forEach(function(e){t.exports[e]=function(t,n){return"string"==typeof t&&(t={url:t}),t.method=e.toUpperCase(),r(t,n)}})}).call(this,e("buffer").Buffer)},{buffer:24,http:95,https:39,once:61,"unzip-response":21,url:112,xtend:119}],91:[function(e,t,n){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(t.channelName=e.initiator?e.channelName||u(20).toString("hex"):null,t._debug("new peer %o",e),e||(e={}),e.allowHalfOpen=!1,null==e.highWaterMark&&(e.highWaterMark=1048576),c.Duplex.call(t,e),t.initiator=e.initiator||!1,t.channelConfig=e.channelConfig||r.channelConfig,t.config=e.config||r.config,t.constraints=e.constraints||r.constraints,t.offerConstraints=e.offerConstraints||{},t.answerConstraints=e.answerConstraints||{},t.reconnectTimer=e.reconnectTimer||!1,t.sdpTransform=e.sdpTransform||function(e){return e},t.stream=e.stream||!1,t.trickle=void 0===e.trickle||e.trickle,t.destroyed=!1,t.connected=!1,t.remoteAddress=void 0,t.remoteFamily=void 0,t.remotePort=void 0,t.localAddress=void 0,t.localPort=void 0,t._isWrtc=!!e.wrtc,t._wrtc=e.wrtc&&"object"==typeof e.wrtc?e.wrtc:s(),!t._wrtc)throw"undefined"==typeof window?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser");if(t._maxBufferedAmount=e.highWaterMark,t._pcReady=!1,t._channelReady=!1,t._iceComplete=!1,t._channel=null,t._pendingCandidates=[],t._chunk=null,t._cb=null,t._interval=null,t._reconnectTimeout=null,t._pc=new t._wrtc.RTCPeerConnection(t.config,t.constraints),t._pc.oniceconnectionstatechange=function(){t._onIceConnectionStateChange()},t._pc.onsignalingstatechange=function(){t._onSignalingStateChange()},t._pc.onicecandidate=function(e){t._onIceCandidate(e)},t.stream&&t._pc.addStream(t.stream),"ontrack"in t._pc?t._pc.ontrack=function(e){t._onTrack(e)}:t._pc.onaddstream=function(e){t._onAddStream(e)},t.initiator){t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)});var n=!1;t._pc.onnegotiationneeded=function(){n||t._createOffer(),n=!0},"undefined"!=typeof window&&window.webkitRTCPeerConnection||t._pc.onnegotiationneeded()}else t._pc.ondatachannel=function(e){t._setupData(e)};t.on("finish",function(){t.connected?setTimeout(function(){t._destroy()},100):t.once("connect",function(){setTimeout(function(){t._destroy()},100)})})}function o(){}t.exports=r;var i=e("debug")("simple-peer"),s=e("get-browser-rtc"),a=e("inherits"),u=e("randombytes"),c=e("readable-stream");a(r,c.Duplex),r.WEBRTC_SUPPORT=!!s(),r.config={iceServers:[{url:"stun:23.21.150.121",urls:"stun:23.21.150.121"}]},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){function t(e){try{n._pc.addIceCandidate(new n._wrtc.RTCIceCandidate(e),o,function(e){n._onError(e)})}catch(e){n._destroy(new Error("error adding candidate: "+e.message))}}var n=this;if(n.destroyed)throw new Error("cannot signal after peer is destroyed");if("string"==typeof e)try{e=JSON.parse(e)}catch(t){e={}}n._debug("signal()"),e.sdp&&n._pc.setRemoteDescription(new n._wrtc.RTCSessionDescription(e),function(){n.destroyed||("offer"===n._pc.remoteDescription.type&&n._createAnswer(),n._pendingCandidates.forEach(t),n._pendingCandidates=[])},function(e){n._onError(e)}),e.candidate&&(n._pc.remoteDescription?t(e.candidate):n._pendingCandidates.push(e.candidate)),e.sdp||e.candidate||n._destroy(new Error("signal() called with invalid signal data"))},r.prototype.send=function(e){var t=this;n.isBuffer(e)&&t._isWrtc&&(e=new Uint8Array(e));var r=e.length||e.byteLength||e.size;t._channel.send(e),t._debug("write: %d bytes",r)},r.prototype.destroy=function(e){var t=this;t._destroy(null,e)},r.prototype._destroy=function(e,t){var n=this;if(!n.destroyed){if(t&&n.once("close",t),n._debug("destroy (error: %s)",e&&e.message),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._chunk=null,n._cb=null,clearInterval(n._interval),clearTimeout(n._reconnectTimeout),n._pc){try{n._pc.close()}catch(e){}n._pc.oniceconnectionstatechange=null,n._pc.onsignalingstatechange=null,n._pc.onicecandidate=null,"ontrack"in n._pc?n._pc.ontrack=null:n._pc.onaddstream=null,n._pc.onnegotiationneeded=null,n._pc.ondatachannel=null}if(n._channel){try{n._channel.close()}catch(e){}n._channel.onmessage=null,n._channel.onopen=null,n._channel.onclose=null}n._pc=null,n._channel=null,e&&n.emit("error",e),n.emit("close")}},r.prototype._setupData=function(e){var t=this;t._channel=e.channel,t.channelName=t._channel.label,t._channel.binaryType="arraybuffer",t._channel.onmessage=function(e){t._onChannelMessage(e)},t._channel.onopen=function(){t._onChannelOpen()},t._channel.onclose=function(){t._onChannelClose()}},r.prototype._read=function(){},r.prototype._write=function(e,t,n){var r=this;if(r.destroyed)return n(new Error("cannot write after peer is destroyed"));if(r.connected){try{r.send(e)}catch(e){return r._onError(e)}r._channel.bufferedAmount>r._maxBufferedAmount?(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._createOffer=function(){var e=this;e.destroyed||e._pc.createOffer(function(t){if(!e.destroyed){t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,o,function(t){e._onError(t)});var n=function(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})};e.trickle||e._iceComplete?n():e.once("_iceComplete",n)}},function(t){e._onError(t)},e.offerConstraints)},r.prototype._createAnswer=function(){var e=this;e.destroyed||e._pc.createAnswer(function(t){if(!e.destroyed){t.sdp=e.sdpTransform(t.sdp),e._pc.setLocalDescription(t,o,function(t){e._onError(t)});var n=function(){var n=e._pc.localDescription||t;e._debug("signal"),e.emit("signal",{type:n.type,sdp:n.sdp})};e.trickle||e._iceComplete?n():e.once("_iceComplete",n)}},function(t){e._onError(t)},e.answerConstraints)},r.prototype._onIceConnectionStateChange=function(){var e=this;if(!e.destroyed){var t=e._pc.iceGatheringState,n=e._pc.iceConnectionState;e._debug("iceConnectionStateChange %s %s",t,n),e.emit("iceConnectionStateChange",t,n),"connected"!==n&&"completed"!==n||(clearTimeout(e._reconnectTimeout),e._pcReady=!0,e._maybeReady()),"disconnected"===n&&(e.reconnectTimer?(clearTimeout(e._reconnectTimeout),e._reconnectTimeout=setTimeout(function(){e._destroy()},e.reconnectTimer)):e._destroy()),"failed"===n&&e._destroy(),"closed"===n&&e._destroy()}},r.prototype.getStats=function(e){var t=this;t._pc.getStats?"undefined"!=typeof window&&window.mozRTCPeerConnection?t._pc.getStats(null,function(t){var n=[];t.forEach(function(e){n.push(e)}),e(n)},function(e){t._onError(e)}):t._pc.getStats(function(t){var n=[];t.result().forEach(function(e){var t={};e.names().forEach(function(n){t[n]=e.stat(n)}),t.id=e.id,t.type=e.type,t.timestamp=e.timestamp,n.push(t)}),e(n)}):e([])},r.prototype._maybeReady=function(){var e=this;e._debug("maybeReady pc %s channel %s",e._pcReady,e._channelReady),!e.connected&&!e._connecting&&e._pcReady&&e._channelReady&&(e._connecting=!0,e.getStats(function(t){function n(t){var n=o[t.localCandidateId],i=r[t.remoteCandidateId];n?(e.localAddress=n.ipAddress,e.localPort=Number(n.portNumber)):"string"==typeof t.googLocalAddress&&(n=t.googLocalAddress.split(":"),e.localAddress=n[0],e.localPort=Number(n[1])),e._debug("connect local: %s:%s",e.localAddress,e.localPort),i?(e.remoteAddress=i.ipAddress,e.remotePort=Number(i.portNumber),e.remoteFamily="IPv4"):"string"==typeof t.googRemoteAddress&&(i=t.googRemoteAddress.split(":"),e.remoteAddress=i[0],e.remotePort=Number(i[1]),e.remoteFamily="IPv4"),e._debug("connect remote: %s:%s",e.remoteAddress,e.remotePort)}e._connecting=!1,e.connected=!0;var r={},o={};if(t.forEach(function(e){"remotecandidate"===e.type&&(r[e.id]=e),"localcandidate"===e.type&&(o[e.id]=e)}),t.forEach(function(e){var t="googCandidatePair"===e.type&&"true"===e.googActiveConnection||"candidatepair"===e.type&&e.selected;t&&n(e)}),e._chunk){try{e.send(e._chunk)}catch(t){return e._onError(t)}e._chunk=null,e._debug('sent chunk from "write before connect"');var i=e._cb;e._cb=null,i(null)}e._interval=setInterval(function(){if(e._cb&&e._channel&&!(e._channel.bufferedAmount>e._maxBufferedAmount)){e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);var t=e._cb;e._cb=null,t(null)}},150),e._interval.unref&&e._interval.unref(),e._debug("connect"),e.emit("connect")}))},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;t._debug("read: %d bytes",r.byteLength||r.length),r instanceof ArrayBuffer&&(r=new n(r)),t.push(r)}},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;t.destroyed||(t._debug("on track"),t.emit("stream",e.streams[0]))},r.prototype._onError=function(e){var t=this;t.destroyed||(t._debug("error %s",e.message||e),t._destroy(e))},r.prototype._debug=function(){var e=this,t=[].slice.call(arguments),n=e.channelName&&e.channelName.substring(0,7);t[0]="["+n+"] "+t[0],i.apply(null,t)}}).call(this,e("buffer").Buffer)},{buffer:24,debug:30,"get-browser-rtc":38,inherits:42,randombytes:74,"readable-stream":82}],92:[function(e,t,n){function r(e){return u.digest(e)}function o(e,t){return f?("string"==typeof e&&(e=i(e)),void f.digest({name:"sha-1"},e).then(function(e){t(s(new Uint8Array(e)))},function(n){t(r(e))})):void setTimeout(t,0,r(e))}function i(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 a=e("rusha"),u=new a,c=window.crypto||window.msCrypto||{},f=c.subtle||c.webkitSubtle;try{f.digest({name:"sha-1"},new Uint8Array).catch(function(){f=!1})}catch(e){f=!1}t.exports=o,t.exports.sync=r},{rusha:87}],93:[function(e,t,n){(function(n,r){function o(e,t){var r=this;if(!(r instanceof o))return new o(e,t);t||(t={}),i("new websocket: %s %o",e,t),t.allowHalfOpen=!1,null==t.highWaterMark&&(t.highWaterMark=1048576),a.Duplex.call(r,t),r.url=e,r.connected=!1,r.destroyed=!1,r._maxBufferedAmount=t.highWaterMark,r._chunk=null,r._cb=null,r._interval=null;try{"undefined"==typeof WebSocket?r._ws=new c(r.url,t):r._ws=new c(r.url)}catch(e){return void n.nextTick(function(){r._onError(e)})}r._ws.binaryType="arraybuffer",r._ws.onopen=function(){r._onOpen()},r._ws.onmessage=function(e){r._onMessage(e)},r._ws.onclose=function(){r._onClose()},r._ws.onerror=function(){r._onError(new Error("connection error to "+r.url))},r.on("finish",function(){r.connected?setTimeout(function(){r._destroy()},100):r.once("connect",function(){setTimeout(function(){r._destroy()},100)})})}t.exports=o;var i=e("debug")("simple-websocket"),s=e("inherits"),a=e("readable-stream"),u=e("ws"),c="undefined"!=typeof WebSocket?WebSocket:u;s(o,a.Duplex),o.WEBSOCKET_SUPPORT=!!c,o.prototype.send=function(e){var t=this,n=e.length||e.byteLength||e.size;t._ws.send(e),i("write: %d bytes",n)},o.prototype.destroy=function(e){var t=this;t._destroy(null,e)},o.prototype._destroy=function(e,t){var n=this;if(!n.destroyed){if(t&&n.once("close",t),i("destroy (error: %s)",e&&e.message),this.readable=this.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._ws){var r=n._ws,o=function(){r.onclose=null,n.emit("close")};if(r.readyState===c.CLOSED)o();else try{r.onclose=o,r.close()}catch(e){o()}r.onopen=null,r.onmessage=null,r.onerror=null}n._ws=null,e&&n.emit("error",e)}},o.prototype._read=function(){},o.prototype._write=function(e,t,n){var r=this;if(r.destroyed)return n(new Error("cannot write after socket is destroyed"));if(r.connected){try{r.send(e)}catch(e){return r._onError(e)}"function"!=typeof u&&r._ws.bufferedAmount>r._maxBufferedAmount?(i("start backpressure: bufferedAmount %d",r._ws.bufferedAmount),r._cb=n):n(null)}else i("write before connect"),r._chunk=e,r._cb=n},o.prototype._onMessage=function(e){var t=this;if(!t.destroyed){var n=e.data;i("read: %d bytes",n.byteLength||n.length),n instanceof ArrayBuffer&&(n=new r(n)),t.push(n)}},o.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._onError(t)}e._chunk=null,i('sent chunk from "write before connect"');var t=e._cb;e._cb=null,t(null)}"function"!=typeof u&&(e._interval=setInterval(function(){if(e._cb&&e._ws&&!(e._ws.bufferedAmount>e._maxBufferedAmount)){i("ending backpressure: bufferedAmount %d",e._ws.bufferedAmount);var t=e._cb;e._cb=null,t(null)}},150),e._interval.unref&&e._interval.unref()),i("connect"),e.emit("connect")}},o.prototype._onClose=function(){var e=this;e.destroyed||(i("on close"),e._destroy())},o.prototype._onError=function(e){var t=this;t.destroyed||(i("error: %s",e.message||e),t._destroy(e))}}).call(this,e("_process"),e("buffer").Buffer)},{_process:67,buffer:24,debug:30,inherits:42,"readable-stream":82,ws:21}],94:[function(e,t,n){var r=1,o=65535,i=4,s=function(){r=r+1&o},a=setInterval(s,1e3/i|0);a.unref&&a.unref(),t.exports=function(e){var t=i*(e||5),n=[0],s=1,a=r-1&o;return function(e){var u=r-a&o;for(u>t&&(u=t),a=r;u--;)s===t&&(s=0),n[s]=n[0===s?t-1:s-1],s++;e&&(n[s-1]+=e);var c=n[s-1],f=n.lengthe._pos){var i=n.substr(e._pos);if("x-user-defined"===e._charset){for(var s=new o(i.length),a=0;ae._pos&&(e.push(new o(new Uint8Array(c.result.slice(e._pos)))),e._pos=c.result.byteLength)},c.onload=function(){e.push(null)},c.readAsArrayBuffer(n)}e._xhr.readyState===u.DONE&&"ms-stream"!==e._mode&&e.push(null)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./capability":96,_process:67,buffer:24,inherits:42,"readable-stream":82}],99:[function(e,t,n){var r=e("stream-to-blob");t.exports=function e(t,n,o){return"function"==typeof n?e(t,null,n):void r(t,n,function(e,t){if(e)return o(e);var n=URL.createObjectURL(t);o(null,n)})}},{"stream-to-blob":100}],100:[function(e,t,n){var r=e("once");t.exports=function e(t,n,o){if("function"==typeof n)return e(t,null,n);o=r(o);var i=[];t.on("data",function(e){i.push(e)}).on("end",function(){var e=n?new Blob(i,{type:n}):new Blob(i);o(null,e)}).on("error",o)}},{once:61}],101:[function(e,t,n){(function(n){var r=e("once");t.exports=function(e,t,o){o=r(o);var i=new n(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:24,once:61}],102:[function(e,t,n){function r(e){if(e&&!u(e))throw new Error("Unknown encoding: "+e)}function o(e){return e.toString(this.encoding)}function i(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function s(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}var a=e("buffer").Buffer,u=a.isEncoding||function(e){switch(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}},c=n.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),r(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=i;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=o)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};c.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived=55296&&r<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var o=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,o),o-=this.charReceived),t+=e.toString(this.encoding,0,o);var o=t.length-1,r=t.charCodeAt(o);if(r>=55296&&r<=56319){var i=this.surrogateSize;return this.charLength+=i,this.charReceived+=i,this.charBuffer.copy(this.charBuffer,i,0,i),e.copy(this.charBuffer,0,0,i),t.substring(0,o)}return t},c.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},c.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,o=this.encoding;t+=r.slice(0,n).toString(o)}return t}},{buffer:24}],103:[function(e,t,n){var r=e("./thirty-two");n.encode=r.encode,n.decode=r.decode},{"./thirty-two":104}],104:[function(e,t,n){(function(e){"use strict";function t(e){var t=Math.floor(e.length/5);return e.length%5===0?t:t+1}var r="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",o=[255,255,26,27,28,29,30,31,255,255,255,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255];n.encode=function(n){e.isBuffer(n)||(n=new e(n));for(var o=0,i=0,s=0,a=0,u=new e(8*t(n));o3?(a=c&255>>s,s=(s+5)%8,a=a<>8-s,o++):(a=c>>8-(s+5)&31,s=(s+5)%8,0===s&&o++),u[i]=r.charCodeAt(a),i++}for(o=i;o>>r,a[s]=n,s++,n=255&i<<8-r)}return a.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:24}],105:[function(e,t,n){var r=e("buffer").Buffer;t.exports=function(e){if(e instanceof Uint8Array){if(0===e.byteOffset&&e.byteLength===e.buffer.byteLength)return e.buffer;if("function"==typeof e.buffer.slice)return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}if(r.isBuffer(e)){for(var t=new Uint8Array(e.length),n=e.length,o=0;o=e.length||t<0)){var n=e.pop();if(t",'"',"`"," ","\r","\n","\t"],p=["{","}","|","\\","^","`"].concat(l),m=["'"].concat(p),g=["%","/","?",";","#"].concat(m),y=["/","?","#"],_=255,v=/^[+a-z0-9A-Z_-]{0,63}$/,b=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,w={javascript:!0,"javascript:":!0},E={javascript:!0,"javascript:":!0},k={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},x=e("querystring");r.prototype.parse=function(e,t,n){if(!c.isString(e))throw new TypeError("Parameter 'url' must be a string, not "+typeof e);var r=e.indexOf("?"),o=r!==-1&&r127?"x":P[M];if(!O.match(v)){var H=R.slice(0,I),D=R.slice(I+1),q=P.match(b);q&&(H.push(q[1]),D.unshift(q[2])),D.length&&(a="/"+D.join(".")+a),this.hostname=H.join(".");break}}}this.hostname.length>_?this.hostname="":this.hostname=this.hostname.toLowerCase(),L||(this.hostname=u.toASCII(this.hostname));var N=this.port?":"+this.port:"",W=this.hostname||"";this.host=W+N,this.href+=this.host,L&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==a[0]&&(a="/"+a))}if(!w[p])for(var I=0,U=m.length;I0)&&n.host.split("@");S&&(n.auth=S.shift(),n.host=n.hostname=S.shift())}return n.search=e.search,n.query=e.query,c.isNull(n.pathname)&&c.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n}if(!w.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var B=w.slice(-1)[0],I=(n.host||e.host||w.length>1)&&("."===B||".."===B)||""===B,A=0,T=w.length;T>=0;T--)B=w[T],"."===B?w.splice(T,1):".."===B?(w.splice(T,1),A++):A&&(w.splice(T,1),A--);if(!v&&!b)for(;A--;A)w.unshift("..");!v||""===w[0]||w[0]&&"/"===w[0].charAt(0)||w.unshift(""),I&&"/"!==w.join("/").substr(-1)&&w.push("");var C=""===w[0]||w[0]&&"/"===w[0].charAt(0);if(x){n.hostname=n.host=C?"":w.length?w.shift():"";var S=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@");S&&(n.auth=S.shift(),n.host=n.hostname=S.shift())}return v=v||n.host&&w.length,v&&!C&&w.unshift(""),w.length?n.pathname=w.join("/"):(n.pathname=null,n.path=null),c.isNull(n.pathname)&&c.isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},r.prototype.parseHost=function(){var e=this.host,t=d.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)}},{"./util":113,punycode:69,querystring:72}],113:[function(e,t,n){"use strict";t.exports={isString:function(e){return"string"==typeof e},isObject:function(e){return"object"==typeof e&&null!==e},isNull:function(e){return null===e},isNullOrUndefined:function(e){return null==e}}},{}],114:[function(e,t,n){var r=e("bencode"),o=e("bitfield"),i=e("safe-buffer").Buffer,s=e("debug")("ut_metadata"),a=e("events").EventEmitter,u=e("inherits"),c=e("simple-sha1"),f=1e7,d=1e3,h=16384;t.exports=function(e){function t(t){a.call(this),this._wire=t,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._fetching=!1,this._bitfield=new o(0,{grow:d}),i.isBuffer(e)&&this.setMetadata(e)}return u(t,a),t.prototype.name="ut_metadata",t.prototype.onHandshake=function(e,t,n){this._infoHash=e},t.prototype.onExtendedHandshake=function(e){return e.m&&e.m.ut_metadata?e.metadata_size?"number"!=typeof e.metadata_size||fthis._metadataSize&&(n=this._metadataSize);var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)},t.prototype._onData=function(e,t,n){t.length>h||(t.copy(this.metadata,e*h),this._bitfield.set(e),this._checkDone())},t.prototype._onReject=function(e){this._remainingRejects>0&&this._fetching?(this._request(e),this._remainingRejects-=1):this.emit("warning",new Error('Peer sent "reject" too much'))},t.prototype._requestPieces=function(){this.metadata=i.alloc(this._metadataSize);for(var e=0;e0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))},t}},{bencode:11,bitfield:13,debug:30,events:35,inherits:42,"safe-buffer":88,"simple-sha1":92}],115:[function(e,t,n){(function(e){function n(e,t){function n(){if(!o){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),o=!0}return e.apply(this,arguments)}if(r("noDeprecation"))return e;var o=!1;return n}function r(t){try{if(!e.localStorage)return!1}catch(e){return!1}var n=e.localStorage[t];return null!=n&&"true"===String(n).toLowerCase()}t.exports=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],116:[function(e,t,n){(function(n){function r(e){var t=this;a.call(t),t._tracks=[],t._fragmentSequence=1,t._file=e,t._decoder=null,t._findMoov(0)}function o(e,t){var n=this;n._entries=e,n._countName=t||"count",n._index=0,n._offset=0,n.value=n._entries[0]}function i(){return{version:0,flags:0,entries:[]}}var s=e("binary-search"),a=e("events").EventEmitter,u=e("inherits"),c=e("mp4-stream"),f=e("mp4-box-encoding"),d=e("range-slice-stream");t.exports=r,u(r,a),r.prototype._findMoov=function(e){var t=this;t._decoder&&t._decoder.destroy(),t._decoder=c.decode();var n=t._file.createReadStream({start:e});n.pipe(t._decoder),t._decoder.once("box",function(r){"moov"===r.type?t._decoder.decode(function(e){n.destroy();try{t._processMoov(e)}catch(e){e.message="Cannot parse mp4 file: "+e.message,t.emit("error",e)}}):(n.destroy(),t._findMoov(e+r.length))})},o.prototype.inc=function(){var e=this;e._offset++,e._offset>=e._entries[e._index][e._countName]&&(e._index++,e._offset=0),e.value=e._entries[e._index]},r.prototype._processMoov=function(e){var t=this,r=e.traks;t._tracks=[],t._hasVideo=!1,t._hasAudio=!1;for(var s=0;s=d.stsz.entries.length)break;if(g++,_+=S,g>=x.samplesPerChunk){g=0,_=0,y++;var T=d.stsc.entries[v+1];T&&y+1>=T.firstChunk&&v++}b+=B,w.inc(),E&&E.inc(),A&&k++}c.mdia.mdhd.duration=0,c.tkhd.duration=0;var C=x.sampleDescriptionId,L={type:"moov",mvhd:e.mvhd,traks:[{tkhd:c.tkhd,mdia:{mdhd:c.mdia.mdhd,hdlr:c.mdia.hdlr,elng:c.mdia.elng,minf:{vmhd:c.mdia.minf.vmhd,smhd:c.mdia.minf.smhd,dinf:c.mdia.minf.dinf,stbl:{stsd:d.stsd,stts:i(),ctts:i(),stsc:i(),stsz:i(),stco:i(),stss:i()}}}}],mvex:{mehd:{fragmentDuration:e.mvhd.duration},trexs:[{trackId:c.tkhd.trackId,defaultSampleDescriptionIndex:C,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};t._tracks.push({trackId:c.tkhd.trackId,timeScale:c.mdia.mdhd.timeScale,samples:p,currSample:null,currTime:null,moov:L,mime:u})}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 R=f.encode(t._ftyp),U=t._tracks.map(function(e){var t=f.encode(e.moov);return{mime:e.mime,init:n.concat([R,t])}});t.emit("ready",U)},r.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=c.encode(),a=t._generateFragment(o,e);return a?((n===-1||a.ranges[0].start=0){var r=t._fileStream=t._file.createReadStream({start:n});t._tracks.forEach(function(e){e.inStream=new d(n),r.pipe(e.inStream)})}return t._tracks.map(function(e){return e.outStream})},r.prototype._findSampleBefore=function(e,t){var n=this,r=n._tracks[e],o=Math.floor(r.timeScale*t),i=s(r.samples,o,function(e,t){var n=e.dts+e.presentationOffset;return n-t});for(i===-1?i=0:i<0&&(i=-i-2);!r.samples[i].sync;)i--;return i};var h=1;r.prototype._generateFragment=function(e,t){var n,r=this,o=r._tracks[e];if(n=void 0!==t?r._findSampleBefore(e,t):o.currSample,n>=o.samples.length)return null;for(var i=o.samples[n].dts,s=0,a=[],u=n;u=o.timeScale*h)break;s+=c.size;var f=a.length-1;f<0||a[f].end!==c.offset?a.push({start:c.offset,end:c.offset+c.size}):a[f].end+=c.size}return o.currSample=u,{moof:r._generateMoof(e,n,u),ranges:a,length:s}},r.prototype._generateMoof=function(e,t,n){for(var r=this,o=r._tracks[e],i=[],s=t;s0?new Array(t+(/\./.test(n)?2:1)).join(r)+n:n+"")}},{}],122:[function(e,t,n){t.exports={version:"0.97.2"}},{}],123:[function(e,t,n){(function(n,r){function o(e){function t(){i.destroyed||(i.ready=!0,i.emit("ready"))}var i=this;return i instanceof o?(h.call(i),e||(e={}),"string"==typeof e.peerId?i.peerId=e.peerId:a.isBuffer(e.peerId)?i.peerId=e.peerId.toString("hex"):i.peerId=a.from(I+b(6).toString("hex")).toString("hex"),i.peerIdBuffer=a.from(i.peerId,"hex"),"string"==typeof e.nodeId?i.nodeId=e.nodeId:a.isBuffer(e.nodeId)?i.nodeId=e.nodeId.toString("hex"):i.nodeId=b(20).toString("hex"),i.nodeIdBuffer=a.from(i.nodeId,"hex"),i.destroyed=!1,i.listening=!1,i.torrentPort=e.torrentPort||0,i.dhtPort=e.dhtPort||0,i.tracker=void 0!==e.tracker?e.tracker:{},i.torrents=[],i.maxConns=Number(e.maxConns)||55,f("new webtorrent (peerId %s, nodeId %s, port %s)",i.peerId,i.nodeId,i.torrentPort),i.tracker&&("object"!=typeof i.tracker&&(i.tracker={}),e.rtcConfig&&(console.warn("WebTorrent: opts.rtcConfig is deprecated. Use opts.tracker.rtcConfig instead"),i.tracker.rtcConfig=e.rtcConfig),e.wrtc&&(console.warn("WebTorrent: opts.wrtc is deprecated. Use opts.tracker.wrtc instead"),i.tracker.wrtc=e.wrtc),r.WRTC&&!i.tracker.wrtc&&(i.tracker.wrtc=r.WRTC)),"function"==typeof k?i._tcpPool=new k(i):n.nextTick(function(){i._onListening()}),i._downloadSpeed=w(),i._uploadSpeed=w(),e.dht!==!1&&"function"==typeof d?(i.dht=new d(l({nodeId:i.nodeId},e.dht)),i.dht.once("error",function(e){i._destroy(e)}),i.dht.once("listening",function(){var e=i.dht.address();e&&(i.dhtPort=e.port)}),i.dht.setMaxListeners(0),i.dht.listen(i.dhtPort)):i.dht=!1,i.enableWebSeeds=e.webSeeds!==!1,void("function"==typeof m&&null!=e.blocklist?m(e.blocklist,{headers:{"user-agent":"WebTorrent/"+S+" (https://webtorrent.io)"}},function(e,n){return e?i.error("Failed to load blocklist: "+e.message):(i.blocked=n,void t())}):n.nextTick(t))):new o(e)}function i(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}function s(e){return"undefined"!=typeof FileList&&e instanceof FileList}t.exports=o;var a=e("safe-buffer").Buffer,u=e("simple-concat"),c=e("create-torrent"),f=e("debug")("webtorrent"),d=e("bittorrent-dht/client"),h=e("events").EventEmitter,l=e("xtend"),p=e("inherits"),m=e("load-ip-set"),g=e("run-parallel"),y=e("parse-torrent"),_=e("path"),v=e("simple-peer"),b=e("randombytes"),w=e("speedometer"),E=e("zero-fill"),k=e("./lib/tcp-pool"),x=e("./lib/torrent"),S=e("./package.json").version,B=S.match(/([0-9]+)/g).slice(0,2).map(function(e){return E(2,e)}).join(""),I="-WW"+B+"-";p(o,h),o.WEBRTC_SUPPORT=v.WEBRTC_SUPPORT,Object.defineProperty(o.prototype,"downloadSpeed",{get:function(){return this._downloadSpeed()}}),Object.defineProperty(o.prototype,"uploadSpeed",{get:function(){return this._uploadSpeed()}}),Object.defineProperty(o.prototype,"progress",{get:function(){var e=this.torrents.filter(function(e){return 1!==e.progress}),t=e.reduce(function(e,t){return e+t.downloaded},0),n=e.reduce(function(e,t){return e+(t.length||0)},0)||1;return t/n}}),Object.defineProperty(o.prototype,"ratio",{get:function(){var e=this.torrents.reduce(function(e,t){return e+t.uploaded},0),t=this.torrents.reduce(function(e,t){return e+t.received},0)||1;return e/t}}),o.prototype.get=function(e){var t,n,r=this,o=r.torrents.length;if(e instanceof x){for(t=0;t { + document.l10n.requestLanguages([detail.langCode]) + document.getElementsByName('availableLanguages')[0].content = detail.languageCodes.join(', ') + }) + + window.addEventListener('load', function () { + var po = document.createElement('script') + po.async = true + po.src = webtorrentEntryPage + var s = document.getElementsByTagName('script')[0] + s.parentNode.insertBefore(po, s) + chrome.ipc.send('request-language') + }) +})() diff --git a/app/extensions/brave/webtorrent.html b/app/extensions/brave/webtorrent.html new file mode 100644 index 00000000000..dab72c265e2 --- /dev/null +++ b/app/extensions/brave/webtorrent.html @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + +
+ + diff --git a/js/components/frame.js b/js/components/frame.js index 4c83e67737f..8248bf61240 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -23,7 +23,7 @@ const debounce = require('../lib/debounce') const getSetting = require('../settings').getSetting const config = require('../constants/config') const settings = require('../constants/settings') -const {aboutUrls, isSourceAboutUrl, isTargetAboutUrl, getTargetAboutUrl, getBaseUrl, isIntermediateAboutPage} = require('../lib/appUrlUtil') +const {aboutUrls, isSourceMagnetUrl, getTargetMagnetUrl, isSourceAboutUrl, isTargetAboutUrl, getTargetAboutUrl, getBaseUrl, isIntermediateAboutPage} = require('../lib/appUrlUtil') const {isFrameError} = require('../../app/common/lib/httpUtil') const locale = require('../l10n') const appConfig = require('../constants/appConfig') @@ -317,7 +317,11 @@ class Frame extends ImmutableComponent { } if (!guestInstanceId || newSrc !== 'about:blank') { - this.webview.setAttribute('src', isSourceAboutUrl(newSrc) ? getTargetAboutUrl(newSrc) : newSrc) + let webviewSrc + if (isSourceAboutUrl(newSrc)) webviewSrc = getTargetAboutUrl(newSrc) + else if (isSourceMagnetUrl(newSrc)) webviewSrc = getTargetMagnetUrl(newSrc) + else webviewSrc = newSrc + this.webview.setAttribute('src', webviewSrc) } if (webviewAdded) { diff --git a/js/lib/appUrlUtil.js b/js/lib/appUrlUtil.js index b2979535c3c..86fa5211973 100644 --- a/js/lib/appUrlUtil.js +++ b/js/lib/appUrlUtil.js @@ -116,14 +116,32 @@ module.exports.isSourceAboutUrl = function (input) { return !!module.exports.getTargetAboutUrl(getBaseUrl(input)) } -/** - * Determines if the passed in string is the target of a source about: URL - * Example: isTargetAboutUrl('http://localhost:8000/about-blank/index.html') -> true - */ module.exports.isTargetAboutUrl = function (input) { return !!module.exports.getSourceAboutUrl(getBaseUrl(input)) } +// TODO: document + +module.exports.getTargetMagnetUrl = function (input) { + if (!input.startsWith('magnet:?')) return null + const url = module.exports.getAppUrl('webtorrent.html') + return url + '#' + input +} + +module.exports.getSourceMagnetUrl = function (input) { + const url = module.exports.getAppUrl('webtorrent.html') + if (!input.startsWith(url)) return null + return input.substring(input.indexOf('#') + 1) +} + +module.exports.isSourceMagnetUrl = function (input) { + return !!module.exports.getTargetMagnetUrl(input) +} + +module.exports.isTargetMagnetUrl = function (input) { + return !!module.exports.getSourceMagnetUrl(input) +} + /** * Determines whether a string is a valid URL. Based on node-urlutil.js. * @param {string} input @@ -148,7 +166,7 @@ function getHash (input) { return (typeof input === 'string') ? input.split('#')[1] : '' } -module.exports.navigatableTypes = ['http:', 'https:', 'about:', 'chrome:', 'chrome-extension:', 'file:', 'view-source:', 'ftp:'] +module.exports.navigatableTypes = ['http:', 'https:', 'about:', 'chrome:', 'chrome-extension:', 'file:', 'view-source:', 'ftp:', 'magnet:'] /** * Determine the URL to use when creating a new tab diff --git a/js/lib/urlutil.js b/js/lib/urlutil.js index 961667d5027..8b5d2d7ac59 100644 --- a/js/lib/urlutil.js +++ b/js/lib/urlutil.js @@ -109,7 +109,7 @@ const UrlUtil = { // for cases, pure string const case3Reg = /[\?\.\/\s:]/ // for cases, data:uri, view-source:uri and about - const case4Reg = /^data:|view-source:|mailto:|about:|chrome-extension:.*/ + const case4Reg = /^data:|view-source:|mailto:|about:|chrome-extension:|magnet:.*/ let str = input.trim() let scheme = this.getScheme(str) diff --git a/js/stores/windowStore.js b/js/stores/windowStore.js index dcc4662908a..0470b3bca3c 100644 --- a/js/stores/windowStore.js +++ b/js/stores/windowStore.js @@ -18,7 +18,7 @@ const urlParse = require('url').parse const currentWindow = require('../../app/renderer/currentWindow') const {tabFromFrame} = require('../state/frameStateUtil') const {l10nErrorText} = require('../../app/common/lib/httpUtil') -const {aboutUrls, getSourceAboutUrl, isIntermediateAboutPage, navigatableTypes, newFrameUrl} = require('../lib/appUrlUtil') +const {aboutUrls, getSourceAboutUrl, isIntermediateAboutPage, getSourceMagnetUrl, navigatableTypes, newFrameUrl} = require('../lib/appUrlUtil') const Serializer = require('../dispatcher/serializer') let windowState = Immutable.fromJS({ @@ -280,8 +280,8 @@ const doAction = (action) => { audioPlaybackActive: false }) } else { - // If the user is changing back to the original src and they already navigated away then we need to - // explicitly set a new location via webview.loadURL. + // If the user is changing back to the original src and they already navigated away then we need to + // explicitly set a new location via webview.loadURL. let activeShortcut if (frame.get('location') !== action.location && frame.get('src') === action.location && @@ -307,7 +307,9 @@ const doAction = (action) => { windowState = windowState.setIn(activeFrameStatePath().concat(['navbar', 'urlbar', 'suggestions', 'shouldRender']), false) // For about: URLs, make sure we store the URL as about:something // and not what we map to. - action.location = getSourceAboutUrl(action.location) || action.location + action.location = getSourceAboutUrl(action.location) || + getSourceMagnetUrl(action.location) || + action.location if (UrlUtil.isURL(action.location)) { action.location = UrlUtil.getUrlFromInput(action.location) diff --git a/js/webtorrent/entry.js b/js/webtorrent/entry.js new file mode 100644 index 00000000000..cebf4b38444 --- /dev/null +++ b/js/webtorrent/entry.js @@ -0,0 +1,68 @@ +const ReactDOM = require('react-dom') +var WebTorrent = window.WebTorrent // require('webtorrent') + +var state = { + torrentId: window.location.hash.substring(1), + progress: 0, + files: [], + errorMessage: '' +} + +// Start downloading the torrent +var client = new WebTorrent() +window.client = client +state.torrent = client.add(state.torrentId) +client.on('error', onError) + +// Show download progress +setInterval(update, 1000) + +function update () { + var torrent = state.torrent + + var status + if (!torrent.infoHash) { + status = 'Loading torrent information...' + } else if (torrent.progress < 1) { + status = 'Downloading ' + (torrent.name || '...') + } else { + status = 'Done!' + } + + var elem = ( +
+

{status}

+

Progress: {(torrent.progress * 100).toFixed(1)}%

+

Files

+
    + {torrent.files.map((file, i) => { + var isSelected = i === state.selectedFileIndex + return ( +
  • + {file.name} +
  • + ) + })} +
+
+
{state.errorMessage}
+
+ ) + ReactDOM.render(elem, document.querySelector('#appContainer')) +} + +function onClickFile (e) { + if (state.selectedFileIndex === e.target.dataset.ix) return + state.selectedFileIndex = e.target.dataset.ix + + update() + + var fileContainer = document.querySelector('#fileContainer') + fileContainer.innerHTML = '' + var file = state.torrent.files[state.selectedFileIndex] + file.appendTo(fileContainer) +} + +function onError (err) { + state.errorMessage = err.message +} diff --git a/package.json b/package.json index 66b42388c8e..93c7c7da147 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,8 @@ "tldjs": "1.6.2", "tracking-protection": "1.1.x", "underscore": "1.8.3", - "url-loader": "^0.5.7" + "url-loader": "^0.5.7", + "webtorrent": "^0.97.2" }, "devDependencies": { "asar": "^0.11.0", diff --git a/webpack.config.js b/webpack.config.js index c00bbbdaffa..bee66653762 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -117,17 +117,31 @@ var aboutPages = { } } +var webtorrentPage = { + name: 'webtorrent', + target: 'web', + entry: ['./js/webtorrent/entry.js'], + output: { + path: path.resolve(__dirname, 'app', 'extensions', 'brave', 'gen'), + filename: 'webtorrentPage.entry.js', + publicPath: './gen/' + } +} + module.exports = { development: [ merge(app, development()), - merge(aboutPages, development()) + merge(aboutPages, development()), + merge(webtorrentPage, development()) ], production: [ merge(app, production()), - merge(aboutPages, production()) + merge(aboutPages, production()), + merge(webtorrentPage, production()) ], test: [ merge(app, production()), - merge(aboutPages, production()) + merge(aboutPages, production()), + merge(webtorrentPage, production()) ] }[env] From 4d00744723961b500ec873dc427bffd2bf56b9ba Mon Sep 17 00:00:00 2001 From: DC Date: Tue, 1 Nov 2016 19:58:11 -0700 Subject: [PATCH 02/48] magnet link demo styling --- js/webtorrent/entry.js | 23 +++++++++++++++++------ less/webtorrent.less | 22 ++++++++++++++++++++++ 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 less/webtorrent.less diff --git a/js/webtorrent/entry.js b/js/webtorrent/entry.js index cebf4b38444..81a30f8443b 100644 --- a/js/webtorrent/entry.js +++ b/js/webtorrent/entry.js @@ -8,12 +8,18 @@ var state = { errorMessage: '' } +require('../../less/webtorrent.less') + // Start downloading the torrent var client = new WebTorrent() window.client = client state.torrent = client.add(state.torrentId) client.on('error', onError) +// Show a friendly window title +updateTitle() +state.torrent.on('metadata', updateTitle) + // Show download progress setInterval(update, 1000) @@ -34,26 +40,31 @@ function update () {

{status}

Progress: {(torrent.progress * 100).toFixed(1)}%

Files

-
    +
      {torrent.files.map((file, i) => { - var isSelected = i === state.selectedFileIndex + var className = i === state.selectedFileIndex ? 'selected' : '' return ( -
    • +
    • {file.name}
    • ) })}
    -
    {state.errorMessage}
    +
    {state.errorMessage}
    ) ReactDOM.render(elem, document.querySelector('#appContainer')) } +function updateTitle () { + document.title = state.torrent.name || 'Downloading torrent...' +} + function onClickFile (e) { - if (state.selectedFileIndex === e.target.dataset.ix) return - state.selectedFileIndex = e.target.dataset.ix + var clickedIndex = Number(e.target.dataset.ix) + if (state.selectedFileIndex === clickedIndex) return + state.selectedFileIndex = clickedIndex update() diff --git a/less/webtorrent.less b/less/webtorrent.less new file mode 100644 index 00000000000..d56c512a3df --- /dev/null +++ b/less/webtorrent.less @@ -0,0 +1,22 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +@import "./variables.less"; + +.files { + padding: 0; + list-style: none; +} + +.files li { + cursor: pointer; +} + +.files .selected { + color: @highlightBlue; +} + +.error { + color: @errorTextColor; +} From 2795001c4ac01e983ce52e4fc4b828b868ef4011 Mon Sep 17 00:00:00 2001 From: DC Date: Wed, 2 Nov 2016 15:44:07 -0700 Subject: [PATCH 03/48] appUrlUtil jsdoc --- js/lib/appUrlUtil.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/js/lib/appUrlUtil.js b/js/lib/appUrlUtil.js index 86fa5211973..05e36a07954 100644 --- a/js/lib/appUrlUtil.js +++ b/js/lib/appUrlUtil.js @@ -116,28 +116,48 @@ module.exports.isSourceAboutUrl = function (input) { return !!module.exports.getTargetAboutUrl(getBaseUrl(input)) } +/** + * Determines if the passed in string is the target of a source about: URL + * Example: isTargetAboutUrl('http://localhost:8000/about-blank/index.html') -> true + */ module.exports.isTargetAboutUrl = function (input) { return !!module.exports.getSourceAboutUrl(getBaseUrl(input)) } -// TODO: document - +/** + * Gets a local URL that renders the given magnet:// URL + * Returns null if the input is not a magnet URL + * Example: getTargetMagnetUrl('magnet:?x=y') -> 'chrome-extension://<...>.html#magnet:?x=y' + */ module.exports.getTargetMagnetUrl = function (input) { if (!input.startsWith('magnet:?')) return null const url = module.exports.getAppUrl('webtorrent.html') return url + '#' + input } +/** + * Gets the magnet:// URL for a given local URL. + * Returns null if the input is not the local URL for a magnet link. + * Example: getSourceMagnetUrl('chrome-extension://<...>.html#magnet:?x=y') -> 'magnet:?x=y' + */ module.exports.getSourceMagnetUrl = function (input) { const url = module.exports.getAppUrl('webtorrent.html') if (!input.startsWith(url)) return null return input.substring(input.indexOf('#') + 1) } +/** + * Checks if the input looks like a magnet: URL + * Example: getSourceMagnetUrl('magnet:?x=y') -> true + */ module.exports.isSourceMagnetUrl = function (input) { return !!module.exports.getTargetMagnetUrl(input) } +/* + * Checks if the input looks like the local URL for a magnet link. + * Example: getSourceMagnetUrl('chrome-extension://<...>.html#magnet:?x=y') -> true + */ module.exports.isTargetMagnetUrl = function (input) { return !!module.exports.getSourceMagnetUrl(input) } From 0c29397216ccc337f54becd67f554679f231b826 Mon Sep 17 00:00:00 2001 From: DC Date: Wed, 2 Nov 2016 16:25:08 -0700 Subject: [PATCH 04/48] follow magnet links --- js/components/frame.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/js/components/frame.js b/js/components/frame.js index 8248bf61240..2fdfbd67483 100644 --- a/js/components/frame.js +++ b/js/components/frame.js @@ -912,7 +912,17 @@ class Frame extends ImmutableComponent { } const loadStart = (e) => { + // We have two kinds of special URLs: magnet links and about pages + // When the user clicks on a magnet link, navigate to the corresponding local URL + // (The address bar will still show the magnet URL. See appUrlUtil.getSourceMagnetUrl.) + if (isSourceMagnetUrl(e.url)) { + var targetURL = getTargetMagnetUrl(e.url) + // Return right away. loadStart will be called again with targetURL + return windowActions.loadUrl(this.frame, targetURL) + } + const parsedUrl = urlParse(e.url) + // Instead of telling person to install Flash, ask them if they want to // run Flash if it's installed. if (e.isMainFrame && !e.isErrorPage && !e.isFrameSrcDoc) { @@ -940,6 +950,7 @@ class Frame extends ImmutableComponent { this.webview.executeJavaScript('Navigator.prototype.__defineGetter__("doNotTrack", () => {return 1});') } } + const loadEnd = (savePage) => { windowActions.onWebviewLoadEnd( this.frame, @@ -970,6 +981,7 @@ class Frame extends ImmutableComponent { interceptFlash(false, undefined, hack.redirectURL) } } + const loadFail = (e, provisionLoadFailure = false) => { if (isFrameError(e.errorCode)) { // temporary workaround for https://github.com/brave/browser-laptop/issues/1817 @@ -1027,7 +1039,6 @@ class Frame extends ImmutableComponent { this.webview.addEventListener('load-start', (e) => { loadStart(e) }) - this.webview.addEventListener('did-navigate', (e) => { if (this.props.findbarShown) { this.props.onFindHide() From e5d76bf6a3d2394ae82848073a6ab5107d51f8df Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 3 Nov 2016 16:04:17 -0700 Subject: [PATCH 05/48] Address code review feedback --- app/extensions/brave/js/webtorrent.js | 2 -- js/lib/appUrlUtil.js | 18 +++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/app/extensions/brave/js/webtorrent.js b/app/extensions/brave/js/webtorrent.js index 2ba4c2cee4a..01a16dc2479 100644 --- a/app/extensions/brave/js/webtorrent.js +++ b/app/extensions/brave/js/webtorrent.js @@ -1,6 +1,4 @@ (function () { - var queryString = window.location.search - let webtorrentEntryPage = 'gen/webtorrentPage.entry.js' chrome.ipc.on('language', (e, detail) => { diff --git a/js/lib/appUrlUtil.js b/js/lib/appUrlUtil.js index 05e36a07954..9c2275b0c90 100644 --- a/js/lib/appUrlUtil.js +++ b/js/lib/appUrlUtil.js @@ -125,25 +125,25 @@ module.exports.isTargetAboutUrl = function (input) { } /** - * Gets a local URL that renders the given magnet:// URL + * Obtains the target URL associated with a magnet: source URL * Returns null if the input is not a magnet URL - * Example: getTargetMagnetUrl('magnet:?x=y') -> 'chrome-extension://<...>.html#magnet:?x=y' + * Example: getTargetMagnetUrl('magnet:...') -> 'chrome-extension://<...>.html#magnet:...' */ module.exports.getTargetMagnetUrl = function (input) { - if (!input.startsWith('magnet:?')) return null + if (!input.startsWith('magnet:')) return null const url = module.exports.getAppUrl('webtorrent.html') - return url + '#' + input + return [url, input].join('#') } /** - * Gets the magnet:// URL for a given local URL. + * Obtains the source magnet: URL associated with a target URL * Returns null if the input is not the local URL for a magnet link. - * Example: getSourceMagnetUrl('chrome-extension://<...>.html#magnet:?x=y') -> 'magnet:?x=y' + * Example: getSourceMagnetUrl('chrome-extension://<...>.html#magnet:...') -> 'magnet:...' */ module.exports.getSourceMagnetUrl = function (input) { - const url = module.exports.getAppUrl('webtorrent.html') - if (!input.startsWith(url)) return null - return input.substring(input.indexOf('#') + 1) + if (getBaseUrl(input) !== module.exports.getAppUrl('webtorrent.html')) return null + const url = getHash(input) + return url } /** From 5eebaecf9405a6660c77fb863c967604be734702 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 3 Nov 2016 16:19:29 -0700 Subject: [PATCH 06/48] Force add WebTorrent community trackers --- js/webtorrent/entry.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/js/webtorrent/entry.js b/js/webtorrent/entry.js index 81a30f8443b..d09b90546cc 100644 --- a/js/webtorrent/entry.js +++ b/js/webtorrent/entry.js @@ -1,5 +1,21 @@ const ReactDOM = require('react-dom') -var WebTorrent = window.WebTorrent // require('webtorrent') + +/** + * TODO: Once WebTorrent is running in it's own process, replace the window + * globals with require() calls. Delete ext/webtorrent.min.js. + */ +const WebTorrent = window.WebTorrent // require('webtorrent') + +/** + * TODO: Replace hard-coded list of community trackers with latest list from + * create-torrent package, similar to how WebTorrent Desktop does it here: + * https://github.com/feross/webtorrent-desktop/blob/4bb2056bc9c1a421815b97d03ffed512575dfde0/src/renderer/webtorrent.js#L29-L31 + */ +window.WEBTORRENT_ANNOUNCE = [ + 'wss://tracker.btorrent.xyz', + 'wss://tracker.openwebtorrent.com', + 'wss://tracker.fastcast.nz' +] var state = { torrentId: window.location.hash.substring(1), @@ -11,8 +27,7 @@ var state = { require('../../less/webtorrent.less') // Start downloading the torrent -var client = new WebTorrent() -window.client = client +var client = window.client = new WebTorrent() state.torrent = client.add(state.torrentId) client.on('error', onError) From 8f3f6a3573b95220410266b603c0def0acb6918c Mon Sep 17 00:00:00 2001 From: DC Date: Thu, 3 Nov 2016 19:52:28 -0700 Subject: [PATCH 07/48] link to individual files in a torrent --- js/webtorrent/entry.js | 152 +++++++++++++++++++++++++++++------------ less/webtorrent.less | 27 ++++++++ 2 files changed, 136 insertions(+), 43 deletions(-) diff --git a/js/webtorrent/entry.js b/js/webtorrent/entry.js index d09b90546cc..af9c7ced37e 100644 --- a/js/webtorrent/entry.js +++ b/js/webtorrent/entry.js @@ -1,4 +1,6 @@ const ReactDOM = require('react-dom') +const magnetURI = require('magnet-uri') +const Button = require('../components/button') /** * TODO: Once WebTorrent is running in it's own process, replace the window @@ -19,76 +21,140 @@ window.WEBTORRENT_ANNOUNCE = [ var state = { torrentId: window.location.hash.substring(1), + torrent: null, progress: 0, files: [], - errorMessage: '' + dn: '', + errorMessage: '', + isFileLoaded: false } require('../../less/webtorrent.less') // Start downloading the torrent var client = window.client = new WebTorrent() -state.torrent = client.add(state.torrentId) client.on('error', onError) -// Show a friendly window title -updateTitle() -state.torrent.on('metadata', updateTitle) - // Show download progress -setInterval(update, 1000) +setInterval(render, 1000) +render() + +function start () { + state.torrent = client.add(state.torrentId) +} -function update () { +function render () { var torrent = state.torrent + var id = state.torrentId + + // TODO: right now, we only support magnet links as the torrentId + // Eventually, we need to support .torrent files as well, prob using parse-torrent + if (!state.magnetInfo && id.startsWith('magnet:?')) { + state.magnetInfo = magnetURI(id) + } + var magnetName = state.magnetInfo && state.magnetInfo.dn + + var title + if (!torrent) { + title = magnetName || 'New torrent' + } else if (!torrent.name) { + title = magnetName || 'Loading torrent information...' + } else { + title = torrent.name + } + document.title = title var status - if (!torrent.infoHash) { - status = 'Loading torrent information...' + if (!state.torrent) { + status = ( + + ) } else if (torrent.progress < 1) { - status = 'Downloading ' + (torrent.name || '...') + status = ( + Downloading: {(torrent.progress * 100).toFixed(1)}% + ) } else { - status = 'Done!' + status = ( + Complete: 100% + ) + } + status = ( + + {status} + + ) + + var content + if (!state.torrent) { + content = ( +
    + Warning: + please ensure that you have legal rights to download and share this content before + clicking Start. +
    + ) + } else if (state.magnetInfo && state.magnetInfo.ix != null) { + content = ( +
    +
    +
    + ) + + var ix = Number(state.magnetInfo.ix) + if (torrent && torrent.files && torrent.files[ix] && !state.isFileLoaded) { + var file = state.torrent.files[ix] + file.appendTo(document.querySelector('#fileContainer')) + state.isFileLoaded = true + } + } else { + var fileElems = torrent.files.map((file, i) => { + return ( +
  • + + {fileElems} +
+ ) + } + + content = ( +
+

Files

+ {fileList} +
+ ) } var elem = (
-

{status}

-

Progress: {(torrent.progress * 100).toFixed(1)}%

-

Files

-
    - {torrent.files.map((file, i) => { - var className = i === state.selectedFileIndex ? 'selected' : '' - return ( -
  • - {file.name} -
  • - ) - })} -
-
+

{title}

+
+ {status} + + + Copy magnet link + + + + Save torrent file + +
+ {content}
{state.errorMessage}
) ReactDOM.render(elem, document.querySelector('#appContainer')) } -function updateTitle () { - document.title = state.torrent.name || 'Downloading torrent...' -} - -function onClickFile (e) { - var clickedIndex = Number(e.target.dataset.ix) - if (state.selectedFileIndex === clickedIndex) return - state.selectedFileIndex = clickedIndex - - update() - - var fileContainer = document.querySelector('#fileContainer') - fileContainer.innerHTML = '' - var file = state.torrent.files[state.selectedFileIndex] - file.appendTo(fileContainer) -} - function onError (err) { state.errorMessage = err.message } diff --git a/less/webtorrent.less b/less/webtorrent.less index d56c512a3df..9e4a2584c01 100644 --- a/less/webtorrent.less +++ b/less/webtorrent.less @@ -3,6 +3,8 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ @import "./variables.less"; +@import "./button.less"; +@import "../node_modules/font-awesome/css/font-awesome.css"; .files { padding: 0; @@ -20,3 +22,28 @@ .error { color: @errorTextColor; } + +.status-bar { + margin-bottom: 20px; +} + +.status { + display: inline-block; + width: 160px; + font-size: 1.17em; + font-weight: bold; +} + +.button:not(:last-child) { + display: inline-block; + padding-right: 20px; +} + +.fa { + display: inline-block; + width: 20px; +} + +.content { + margin-top: 20px; +} From 0683deec49d739de1268fce69d88591b1bd41553 Mon Sep 17 00:00:00 2001 From: DC Date: Tue, 8 Nov 2016 17:01:18 -0800 Subject: [PATCH 08/48] make normalizeURL handle magnet links --- js/state/siteUtil.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/js/state/siteUtil.js b/js/state/siteUtil.js index 8410f13a266..b85aaaad1ae 100644 --- a/js/state/siteUtil.js +++ b/js/state/siteUtil.js @@ -354,14 +354,7 @@ module.exports.updateSiteFavicon = function (sites, location, favicon) { if (UrlUtil.isNotURL(site.get('location'))) { return false } - - let siteLocation - try { siteLocation = normalizeUrl(site.get('location')) } catch (e) { siteLocation = site.get('location') } - - let inputLocation - try { inputLocation = normalizeUrl(location) } catch (e) { inputLocation = location } - - if (siteLocation === inputLocation) { + if (normURL(site.get('location')) === normURL(location)) { matchingIndices.push(index) return true } @@ -378,6 +371,19 @@ module.exports.updateSiteFavicon = function (sites, location, favicon) { return updatedSites } +/** + * Normalizes a URL for comparison, with special handling for magnet links + */ +function normURL (url) { + const lowerURL = url.toLowerCase() + if (lowerURL.startsWith('magnet:?')) return lowerURL + try { + return normalizeUrl(url) + } catch (e) { + return url + } +} + /** * Converts a siteDetail to frameOpts format * @param {Object} siteDetail - A site detail as per app state From fea269ee4a84285006c8983ddbf0329acfe4aa84 Mon Sep 17 00:00:00 2001 From: DC Date: Mon, 7 Nov 2016 13:44:14 -0800 Subject: [PATCH 09/48] move webtorrent to its own extension previously, torrent support was implemented in the brave extension --- .gitignore | 1 + app/browser/tabs.js | 4 +- app/extensions.js | 97 +++++++++++++----- app/extensions/torrent/ext/immutable.min.js | 36 +++++++ app/extensions/torrent/ext/l20n.min.js | 3 + app/extensions/torrent/ext/polyfill.min.js | 2 + .../{brave => torrent}/ext/webtorrent.min.js | 0 app/extensions/torrent/img/favicon.ico | Bin 0 -> 68589 bytes app/extensions/torrent/img/webtorrent-128.png | Bin 0 -> 5762 bytes app/extensions/torrent/img/webtorrent-16.png | Bin 0 -> 1295 bytes app/extensions/torrent/img/webtorrent-48.png | Bin 0 -> 1876 bytes app/extensions/torrent/img/webtorrent.png | Bin 0 -> 21521 bytes .../{brave => torrent}/js/webtorrent.js | 0 .../torrent/locales/en-US/app.properties | 2 + .../{brave => torrent}/webtorrent.html | 0 app/filtering.js | 3 +- js/constants/config.js | 1 + js/lib/appUrlUtil.js | 66 +++++++----- js/stores/appStore.js | 6 +- webpack.config.js | 2 +- 20 files changed, 166 insertions(+), 57 deletions(-) create mode 100644 app/extensions/torrent/ext/immutable.min.js create mode 100644 app/extensions/torrent/ext/l20n.min.js create mode 100644 app/extensions/torrent/ext/polyfill.min.js rename app/extensions/{brave => torrent}/ext/webtorrent.min.js (100%) create mode 100644 app/extensions/torrent/img/favicon.ico create mode 100644 app/extensions/torrent/img/webtorrent-128.png create mode 100644 app/extensions/torrent/img/webtorrent-16.png create mode 100644 app/extensions/torrent/img/webtorrent-48.png create mode 100644 app/extensions/torrent/img/webtorrent.png rename app/extensions/{brave => torrent}/js/webtorrent.js (100%) create mode 100644 app/extensions/torrent/locales/en-US/app.properties rename app/extensions/{brave => torrent}/webtorrent.html (100%) diff --git a/.gitignore b/.gitignore index 3e080cc8a01..d54b7e8faa0 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ win64-dist Brave.tar.bz2 app/extensions/brave/gen +app/extensions/torrent/gen *.pfx buildConfig.js diff --git a/app/browser/tabs.js b/app/browser/tabs.js index 93f680469ed..065cf1abcc6 100644 --- a/app/browser/tabs.js +++ b/app/browser/tabs.js @@ -1,6 +1,6 @@ const {app, BrowserWindow, session, webContents} = require('electron') const extensions = process.atomBinding('extension') -const { getIndexHTML } = require('../../js/lib/appUrlUtil') +const { getBraveExtIndexHTML } = require('../../js/lib/appUrlUtil') let currentWebContents = {} let activeTab = null @@ -13,7 +13,7 @@ const tabs = { init: () => { app.on('web-contents-created', function (event, tab) { // TODO(bridiver) - also exclude extension action windows?? - if (extensions.isBackgroundPage(tab) || tab.getURL() === getIndexHTML()) { + if (extensions.isBackgroundPage(tab) || tab.getURL() === getBraveExtIndexHTML()) { return } let tabId = tab.getId() diff --git a/app/extensions.js b/app/extensions.js index 373d573d6e2..b0f3abdf9a4 100644 --- a/app/extensions.js +++ b/app/extensions.js @@ -4,7 +4,7 @@ const extensionActions = require('./common/actions/extensionActions') const config = require('../js/constants/config') const appConfig = require('../js/constants/appConfig') const {fileUrl} = require('../js/lib/appUrlUtil') -const {getAppUrl, getExtensionsPath, getIndexHTML} = require('../js/lib/appUrlUtil') +const {getExtensionsPath, getBraveExtUrl, getBraveExtIndexHTML} = require('../js/lib/appUrlUtil') const {getSetting} = require('../js/settings') const settings = require('../js/constants/settings') const extensionStates = require('../js/constants/extensionStates') @@ -15,7 +15,21 @@ const appActions = require('../js/actions/appActions') const fs = require('fs') const path = require('path') +// Takes Content Security Policy flags, for example { 'default-src': '*' } +// Returns a CSP string, for example 'default-src: *;' +let concatCSP = (cspDirectives) => { + let csp = '' + for (let directive in cspDirectives) { + csp += directive + ' ' + cspDirectives[directive] + '; ' + } + return csp.trim() +} + +// Returns the Chromium extension manifest for the braveExtension +// The braveExtension handles about: pages, ad blocking, and a few other things let generateBraveManifest = () => { + const indexHTML = getBraveExtIndexHTML() + let baseManifest = { name: 'brave', manifest_version: 2, @@ -32,7 +46,7 @@ let generateBraveManifest = () => { 'http://*/*', 'https://*/*', 'file://*', 'data:*', 'about:srcdoc' ], exclude_globs: [ - getIndexHTML() + indexHTML ], match_about_blank: true, js: [ @@ -55,7 +69,7 @@ let generateBraveManifest = () => { 'http://*/*', 'https://*/*', 'file://*', 'data:*', 'about:srcdoc' ], exclude_globs: [ - getIndexHTML() + indexHTML ], js: [ 'content/scripts/adInsertion.js', @@ -70,13 +84,13 @@ let generateBraveManifest = () => { matches: [''], include_globs: [ 'http://*/*', 'https://*/*', 'file://*', 'data:*', 'about:srcdoc', - getIndexHTML(), - getAppUrl('about-*.html'), - getAppUrl('about-*.html') + '#*' + indexHTML, + getBraveExtUrl('about-*.html'), + getBraveExtUrl('about-*.html') + '#*' ], exclude_globs: [ - getAppUrl('about-blank.html'), - getAppUrl('about-blank.html') + '#*' + getBraveExtUrl('about-blank.html'), + getBraveExtUrl('about-blank.html') + '#*' ], js: [ 'content/scripts/spellCheck.js', @@ -93,13 +107,13 @@ let generateBraveManifest = () => { '' ], include_globs: [ - getIndexHTML(), - getAppUrl('about-*.html'), - getAppUrl('about-*.html') + '#*' + indexHTML, + getBraveExtUrl('about-*.html'), + getBraveExtUrl('about-*.html') + '#*' ], exclude_globs: [ - getAppUrl('about-blank.html'), - getAppUrl('about-blank.html') + '#*' + getBraveExtUrl('about-blank.html'), + getBraveExtUrl('about-blank.html') + '#*' ] } ], @@ -125,7 +139,7 @@ let generateBraveManifest = () => { 'form-action': '\'none\'', 'referrer': 'no-referrer', 'style-src': '\'self\' \'unsafe-inline\'', - 'img-src': '* data: blob:', + 'img-src': '* data:', 'frame-src': '\'self\' https://buy.coinbase.com' } @@ -137,19 +151,52 @@ let generateBraveManifest = () => { cspDirectives['style-src'] = '\'self\' \'unsafe-inline\' http://' + devServer } + baseManifest.content_security_policy = concatCSP(cspDirectives) + + return baseManifest +} + +// Returns the Chromium extension manifest for the torrentExtension +// The torrentExtension handles magnet: URLs +// Analagous to the PDFJS extension, it shows a special UI for that type of resource +let generateTorrentManifest = () => { + let cspDirectives = { + 'default-src': '\'self\'', + 'form-action': '\'none\'', + 'referrer': 'no-referrer', + 'style-src': '\'self\' \'unsafe-inline\'', + 'img-src': '* data: blob:' + } + // TODO: - // * Move WebTorrent to its own renderer process, similar to the way it's done in - // WebTorrent Desktop + // * Move WebTorrent to its own process, similar to the way it's done in WebTorrent Desktop // * Remove this CSP exception: cspDirectives['connect-src'] = '*' - var csp = '' - for (var directive in cspDirectives) { - csp += directive + ' ' + cspDirectives[directive] + '; ' + return { + name: 'Torrent Viewer', + manifest_version: 2, + version: '1.0', + content_security_policy: concatCSP(cspDirectives), + content_scripts: [], + permissions: [ + 'externally_connectable.all_urls', 'tabs', '' + ], + externally_connectable: { + matches: [ + '' + ] + }, + icons: { + 128: 'img/webtorrent-128.png', + 48: 'img/webtorrent-48.png', + 16: 'img/webtorrent-16.png' + }, + web_accessible_resources: [ + 'img/favicon.ico' + ], + incognito: 'split' } - baseManifest.content_security_policy = csp.trim() - - return baseManifest } const extensionInfo = { @@ -252,7 +299,7 @@ module.exports.init = () => { let loadExtension = (extensionId, extensionPath, manifest = {}, manifestLocation = 'unpacked') => { if (!extensionInfo.isLoaded(extensionId) && !extensionInfo.isLoading(extensionId)) { extensionInfo.setState(extensionId, extensionStates.LOADING) - if (extensionId === config.braveExtensionId) { + if (extensionId === config.braveExtensionId || extensionId === config.torrentExtensionId) { session.defaultSession.extensions.load(extensionPath, manifest, manifestLocation) return } @@ -295,9 +342,11 @@ module.exports.init = () => { } } - // Manually install only the braveExtension + // Manually install the braveExtension and torrentExtension extensionInfo.setState(config.braveExtensionId, extensionStates.REGISTERED) loadExtension(config.braveExtensionId, getExtensionsPath('brave'), generateBraveManifest(), 'component') + extensionInfo.setState(config.torrentExtensionId, extensionStates.REGISTERED) + loadExtension(config.torrentExtensionId, getExtensionsPath('torrent'), generateTorrentManifest(), 'component') let registerComponents = () => { if (getSetting(settings.PDFJS_ENABLED)) { diff --git a/app/extensions/torrent/ext/immutable.min.js b/app/extensions/torrent/ext/immutable.min.js new file mode 100644 index 00000000000..0993436ec00 --- /dev/null +++ b/app/extensions/torrent/ext/immutable.min.js @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2014-2015, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Immutable=e()}(this,function(){"use strict";function t(t,e){e&&(t.prototype=Object.create(e.prototype)),t.prototype.constructor=t}function e(t){return o(t)?t:O(t)}function r(t){return u(t)?t:x(t)}function n(t){return s(t)?t:k(t)}function i(t){return o(t)&&!a(t)?t:A(t)}function o(t){return!(!t||!t[ar])}function u(t){return!(!t||!t[hr])}function s(t){return!(!t||!t[fr])}function a(t){return u(t)||s(t)}function h(t){return!(!t||!t[cr])}function f(t){return t.value=!1,t}function c(t){t&&(t.value=!0)}function _(){}function p(t,e){e=e||0;for(var r=Math.max(0,t.length-e),n=Array(r),i=0;r>i;i++)n[i]=t[i+e];return n}function v(t){return void 0===t.size&&(t.size=t.__iterate(y)),t.size}function l(t,e){if("number"!=typeof e){var r=e>>>0;if(""+r!==e||4294967295===r)return NaN;e=r}return 0>e?v(t)+e:e}function y(){return!0}function d(t,e,r){return(0===t||void 0!==r&&-r>=t)&&(void 0===e||void 0!==r&&e>=r)}function m(t,e){return w(t,e,0)}function g(t,e){return w(t,e,e)}function w(t,e,r){return void 0===t?r:0>t?Math.max(0,e+t):void 0===e?t:Math.min(e,t)}function S(t){this.next=t}function z(t,e,r,n){var i=0===t?e:1===t?r:[e,r];return n?n.value=i:n={value:i,done:!1},n}function I(){return{value:void 0,done:!0}}function b(t){return!!M(t)}function q(t){return t&&"function"==typeof t.next}function D(t){var e=M(t);return e&&e.call(t)}function M(t){var e=t&&(zr&&t[zr]||t[Ir]);return"function"==typeof e?e:void 0}function E(t){return t&&"number"==typeof t.length}function O(t){return null===t||void 0===t?T():o(t)?t.toSeq():C(t)}function x(t){return null===t||void 0===t?T().toKeyedSeq():o(t)?u(t)?t.toSeq():t.fromEntrySeq():W(t)}function k(t){return null===t||void 0===t?T():o(t)?u(t)?t.entrySeq():t.toIndexedSeq():B(t)}function A(t){return(null===t||void 0===t?T():o(t)?u(t)?t.entrySeq():t:B(t)).toSetSeq()}function j(t){this._array=t,this.size=t.length}function K(t){var e=Object.keys(t);this._object=t,this._keys=e, +this.size=e.length}function R(t){this._iterable=t,this.size=t.length||t.size}function U(t){this._iterator=t,this._iteratorCache=[]}function L(t){return!(!t||!t[qr])}function T(){return Dr||(Dr=new j([]))}function W(t){var e=Array.isArray(t)?new j(t).fromEntrySeq():q(t)?new U(t).fromEntrySeq():b(t)?new R(t).fromEntrySeq():"object"==typeof t?new K(t):void 0;if(!e)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+t);return e}function B(t){var e=J(t);if(!e)throw new TypeError("Expected Array or iterable object of values: "+t);return e}function C(t){var e=J(t)||"object"==typeof t&&new K(t);if(!e)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+t);return e}function J(t){return E(t)?new j(t):q(t)?new U(t):b(t)?new R(t):void 0}function N(t,e,r,n){var i=t._cache;if(i){for(var o=i.length-1,u=0;o>=u;u++){var s=i[r?o-u:u];if(e(s[1],n?s[0]:u,t)===!1)return u+1}return u}return t.__iterateUncached(e,r)}function P(t,e,r,n){var i=t._cache;if(i){var o=i.length-1,u=0;return new S(function(){var t=i[r?o-u:u];return u++>o?I():z(e,n?t[0]:u-1,t[1])})}return t.__iteratorUncached(e,r)}function H(t,e){return e?V(e,t,"",{"":t}):Y(t)}function V(t,e,r,n){return Array.isArray(e)?t.call(n,r,k(e).map(function(r,n){return V(t,r,n,e)})):Q(e)?t.call(n,r,x(e).map(function(r,n){return V(t,r,n,e)})):e}function Y(t){return Array.isArray(t)?k(t).map(Y).toList():Q(t)?x(t).map(Y).toMap():t}function Q(t){return t&&(t.constructor===Object||void 0===t.constructor)}function X(t,e){if(t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1;if("function"==typeof t.valueOf&&"function"==typeof e.valueOf){if(t=t.valueOf(),e=e.valueOf(),t===e||t!==t&&e!==e)return!0;if(!t||!e)return!1}return"function"==typeof t.equals&&"function"==typeof e.equals&&t.equals(e)?!0:!1}function F(t,e){if(t===e)return!0;if(!o(e)||void 0!==t.size&&void 0!==e.size&&t.size!==e.size||void 0!==t.__hash&&void 0!==e.__hash&&t.__hash!==e.__hash||u(t)!==u(e)||s(t)!==s(e)||h(t)!==h(e))return!1;if(0===t.size&&0===e.size)return!0; +var r=!a(t);if(h(t)){var n=t.entries();return e.every(function(t,e){var i=n.next().value;return i&&X(i[1],t)&&(r||X(i[0],e))})&&n.next().done}var i=!1;if(void 0===t.size)if(void 0===e.size)"function"==typeof t.cacheResult&&t.cacheResult();else{i=!0;var f=t;t=e,e=f}var c=!0,_=e.__iterate(function(e,n){return(r?t.has(e):i?X(e,t.get(n,yr)):X(t.get(n,yr),e))?void 0:(c=!1,!1)});return c&&t.size===_}function G(t,e){if(!(this instanceof G))return new G(t,e);if(this._value=t,this.size=void 0===e?1/0:Math.max(0,e),0===this.size){if(Mr)return Mr;Mr=this}}function Z(t,e){if(!t)throw Error(e)}function $(t,e,r){if(!(this instanceof $))return new $(t,e,r);if(Z(0!==r,"Cannot step a Range by 0"),t=t||0,void 0===e&&(e=1/0),r=void 0===r?1:Math.abs(r),t>e&&(r=-r),this._start=t,this._end=e,this._step=r,this.size=Math.max(0,Math.ceil((e-t)/r-1)+1),0===this.size){if(Er)return Er;Er=this}}function tt(){throw TypeError("Abstract")}function et(){}function rt(){}function nt(){}function it(t){return t>>>1&1073741824|3221225471&t}function ot(t){if(t===!1||null===t||void 0===t)return 0;if("function"==typeof t.valueOf&&(t=t.valueOf(),t===!1||null===t||void 0===t))return 0;if(t===!0)return 1;var e=typeof t;if("number"===e){var r=0|t;for(r!==t&&(r^=4294967295*t);t>4294967295;)t/=4294967295,r^=t;return it(r)}if("string"===e)return t.length>Ur?ut(t):st(t);if("function"==typeof t.hashCode)return t.hashCode();if("object"===e)return at(t);if("function"==typeof t.toString)return st(""+t);throw Error("Value type "+e+" cannot be hashed.")}function ut(t){var e=Wr[t];return void 0===e&&(e=st(t),Tr===Lr&&(Tr=0,Wr={}),Tr++,Wr[t]=e),e}function st(t){for(var e=0,r=0;t.length>r;r++)e=31*e+t.charCodeAt(r)|0;return it(e)}function at(t){var e;if(jr&&(e=Or.get(t),void 0!==e))return e;if(e=t[Rr],void 0!==e)return e;if(!Ar){if(e=t.propertyIsEnumerable&&t.propertyIsEnumerable[Rr],void 0!==e)return e;if(e=ht(t),void 0!==e)return e}if(e=++Kr,1073741824&Kr&&(Kr=0),jr)Or.set(t,e);else{if(void 0!==kr&&kr(t)===!1)throw Error("Non-extensible objects are not allowed as keys."); +if(Ar)Object.defineProperty(t,Rr,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(void 0!==t.propertyIsEnumerable&&t.propertyIsEnumerable===t.constructor.prototype.propertyIsEnumerable)t.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},t.propertyIsEnumerable[Rr]=e;else{if(void 0===t.nodeType)throw Error("Unable to set a non-enumerable property on object.");t[Rr]=e}}return e}function ht(t){if(t&&t.nodeType>0)switch(t.nodeType){case 1:return t.uniqueID;case 9:return t.documentElement&&t.documentElement.uniqueID}}function ft(t){Z(t!==1/0,"Cannot perform this action with an infinite size.")}function ct(t){return null===t||void 0===t?zt():_t(t)&&!h(t)?t:zt().withMutations(function(e){var n=r(t);ft(n.size),n.forEach(function(t,r){return e.set(r,t)})})}function _t(t){return!(!t||!t[Br])}function pt(t,e){this.ownerID=t,this.entries=e}function vt(t,e,r){this.ownerID=t,this.bitmap=e,this.nodes=r}function lt(t,e,r){this.ownerID=t,this.count=e,this.nodes=r}function yt(t,e,r){this.ownerID=t,this.keyHash=e,this.entries=r}function dt(t,e,r){this.ownerID=t,this.keyHash=e,this.entry=r}function mt(t,e,r){this._type=e,this._reverse=r,this._stack=t._root&&wt(t._root)}function gt(t,e){return z(t,e[0],e[1])}function wt(t,e){return{node:t,index:0,__prev:e}}function St(t,e,r,n){var i=Object.create(Cr);return i.size=t,i._root=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function zt(){return Jr||(Jr=St(0))}function It(t,e,r){var n,i;if(t._root){var o=f(dr),u=f(mr);if(n=bt(t._root,t.__ownerID,0,void 0,e,r,o,u),!u.value)return t;i=t.size+(o.value?r===yr?-1:1:0)}else{if(r===yr)return t;i=1,n=new pt(t.__ownerID,[[e,r]])}return t.__ownerID?(t.size=i,t._root=n,t.__hash=void 0,t.__altered=!0,t):n?St(i,n):zt()}function bt(t,e,r,n,i,o,u,s){return t?t.update(e,r,n,i,o,u,s):o===yr?t:(c(s),c(u),new dt(e,n,[i,o]))}function qt(t){return t.constructor===dt||t.constructor===yt}function Dt(t,e,r,n,i){if(t.keyHash===n)return new yt(e,n,[t.entry,i]);var o,u=(0===r?t.keyHash:t.keyHash>>>r)&lr,s=(0===r?n:n>>>r)&lr,a=u===s?[Dt(t,e,r+pr,n,i)]:(o=new dt(e,n,i), +s>u?[t,o]:[o,t]);return new vt(e,1<o;o++){var u=e[o];i=i.update(t,0,void 0,u[0],u[1])}return i}function Et(t,e,r,n){for(var i=0,o=0,u=Array(r),s=0,a=1,h=e.length;h>s;s++,a<<=1){var f=e[s];void 0!==f&&s!==n&&(i|=a,u[o++]=f)}return new vt(t,i,u)}function Ot(t,e,r,n,i){for(var o=0,u=Array(vr),s=0;0!==r;s++,r>>>=1)u[s]=1&r?e[o++]:void 0;return u[n]=i,new lt(t,o+1,u)}function xt(t,e,n){for(var i=[],u=0;n.length>u;u++){var s=n[u],a=r(s);o(s)||(a=a.map(function(t){return H(t)})),i.push(a)}return jt(t,e,i)}function kt(t,e,r){return t&&t.mergeDeep&&o(e)?t.mergeDeep(e):X(t,e)?t:e}function At(t){return function(e,r,n){if(e&&e.mergeDeepWith&&o(r))return e.mergeDeepWith(t,r);var i=t(e,r,n);return X(e,i)?e:i}}function jt(t,e,r){return r=r.filter(function(t){return 0!==t.size}),0===r.length?t:0!==t.size||t.__ownerID||1!==r.length?t.withMutations(function(t){for(var n=e?function(r,n){t.update(n,yr,function(t){return t===yr?r:e(t,r,n)})}:function(e,r){t.set(r,e)},i=0;r.length>i;i++)r[i].forEach(n)}):t.constructor(r[0])}function Kt(t,e,r,n){var i=t===yr,o=e.next();if(o.done){var u=i?r:t,s=n(u);return s===u?t:s}Z(i||t&&t.set,"invalid keyPath");var a=o.value,h=i?yr:t.get(a,yr),f=Kt(h,e,r,n);return f===h?t:f===yr?t.remove(a):(i?zt():t).set(a,f)}function Rt(t){return t-=t>>1&1431655765,t=(858993459&t)+(t>>2&858993459),t=t+(t>>4)&252645135,t+=t>>8,t+=t>>16,127&t}function Ut(t,e,r,n){var i=n?t:p(t);return i[e]=r,i}function Lt(t,e,r,n){var i=t.length+1;if(n&&e+1===i)return t[e]=r,t;for(var o=Array(i),u=0,s=0;i>s;s++)s===e?(o[s]=r,u=-1):o[s]=t[s+u];return o}function Tt(t,e,r){var n=t.length-1;if(r&&e===n)return t.pop(),t;for(var i=Array(n),o=0,u=0;n>u;u++)u===e&&(o=1),i[u]=t[u+o];return i}function Wt(t){var e=Pt();if(null===t||void 0===t)return e;if(Bt(t))return t;var r=n(t),i=r.size;return 0===i?e:(ft(i),i>0&&vr>i?Nt(0,i,pr,null,new Ct(r.toArray())):e.withMutations(function(t){t.setSize(i),r.forEach(function(e,r){return t.set(r,e)})}))}function Bt(t){ +return!(!t||!t[Vr])}function Ct(t,e){this.array=t,this.ownerID=e}function Jt(t,e){function r(t,e,r){return 0===e?n(t,r):i(t,e,r)}function n(t,r){var n=r===s?a&&a.array:t&&t.array,i=r>o?0:o-r,h=u-r;return h>vr&&(h=vr),function(){if(i===h)return Xr;var t=e?--h:i++;return n&&n[t]}}function i(t,n,i){var s,a=t&&t.array,h=i>o?0:o-i>>n,f=(u-i>>n)+1;return f>vr&&(f=vr),function(){for(;;){if(s){var t=s();if(t!==Xr)return t;s=null}if(h===f)return Xr;var o=e?--f:h++;s=r(a&&a[o],n-pr,i+(o<=t.size||0>e)return t.withMutations(function(t){0>e?Xt(t,e).set(0,r):Xt(t,0,e+1).set(e,r)});e+=t._origin;var n=t._tail,i=t._root,o=f(mr);return e>=Gt(t._capacity)?n=Vt(n,t.__ownerID,0,e,r,o):i=Vt(i,t.__ownerID,t._level,e,r,o),o.value?t.__ownerID?(t._root=i,t._tail=n,t.__hash=void 0,t.__altered=!0,t):Nt(t._origin,t._capacity,t._level,i,n):t}function Vt(t,e,r,n,i,o){var u=n>>>r&lr,s=t&&t.array.length>u;if(!s&&void 0===i)return t;var a;if(r>0){var h=t&&t.array[u],f=Vt(h,e,r-pr,n,i,o);return f===h?t:(a=Yt(t,e),a.array[u]=f,a)}return s&&t.array[u]===i?t:(c(o),a=Yt(t,e),void 0===i&&u===a.array.length-1?a.array.pop():a.array[u]=i,a)}function Yt(t,e){return e&&t&&e===t.ownerID?t:new Ct(t?t.array.slice():[],e)}function Qt(t,e){if(e>=Gt(t._capacity))return t._tail;if(1<e){for(var r=t._root,n=t._level;r&&n>0;)r=r.array[e>>>n&lr],n-=pr;return r}}function Xt(t,e,r){void 0!==e&&(e=0|e),void 0!==r&&(r=0|r);var n=t.__ownerID||new _,i=t._origin,o=t._capacity,u=i+e,s=void 0===r?o:0>r?o+r:i+r;if(u===i&&s===o)return t;if(u>=s)return t.clear();for(var a=t._level,h=t._root,f=0;0>u+f;)h=new Ct(h&&h.array.length?[void 0,h]:[],n),a+=pr,f+=1<=1<p?Qt(t,s-1):p>c?new Ct([],n):v;if(v&&p>c&&o>u&&v.array.length){h=Yt(h,n);for(var y=h,d=a;d>pr;d-=pr){var m=c>>>d&lr;y=y.array[m]=Yt(y.array[m],n)}y.array[c>>>pr&lr]=v}if(o>s&&(l=l&&l.removeAfter(n,0,s)),u>=p)u-=p,s-=p,a=pr,h=null,l=l&&l.removeBefore(n,0,u);else if(u>i||c>p){for(f=0;h;){var g=u>>>a&lr;if(g!==p>>>a&lr)break;g&&(f+=(1<i&&(h=h.removeBefore(n,a,u-f)),h&&c>p&&(h=h.removeAfter(n,a,p-f)),f&&(u-=f,s-=f)}return t.__ownerID?(t.size=s-u,t._origin=u,t._capacity=s,t._level=a,t._root=h,t._tail=l,t.__hash=void 0,t.__altered=!0,t):Nt(u,s,a,h,l)}function Ft(t,e,r){for(var i=[],u=0,s=0;r.length>s;s++){var a=r[s],h=n(a);h.size>u&&(u=h.size),o(a)||(h=h.map(function(t){return H(t)})),i.push(h)}return u>t.size&&(t=t.setSize(u)),jt(t,e,i)}function Gt(t){return vr>t?0:t-1>>>pr<=vr&&u.size>=2*o.size?(i=u.filter(function(t,e){return void 0!==t&&s!==e}),n=i.toKeyedSeq().map(function(t){return t[0]}).flip().toMap(),t.__ownerID&&(n.__ownerID=i.__ownerID=t.__ownerID)):(n=o.remove(e),i=s===u.size-1?u.pop():u.set(s,void 0))}else if(a){if(r===u.get(s)[1])return t;n=o,i=u.set(s,[e,r])}else n=o.set(e,u.size),i=u.set(u.size,[e,r]);return t.__ownerID?(t.size=n.size,t._map=n,t._list=i,t.__hash=void 0,t):te(n,i)}function ne(t,e){this._iter=t,this._useKeys=e,this.size=t.size}function ie(t){this._iter=t,this.size=t.size}function oe(t){this._iter=t,this.size=t.size}function ue(t){this._iter=t,this.size=t.size}function se(t){var e=Ee(t);return e._iter=t,e.size=t.size,e.flip=function(){return t},e.reverse=function(){var e=t.reverse.apply(this); +return e.flip=function(){return t.reverse()},e},e.has=function(e){return t.includes(e)},e.includes=function(e){return t.has(e)},e.cacheResult=Oe,e.__iterateUncached=function(e,r){var n=this;return t.__iterate(function(t,r){return e(r,t,n)!==!1},r)},e.__iteratorUncached=function(e,r){if(e===Sr){var n=t.__iterator(e,r);return new S(function(){var t=n.next();if(!t.done){var e=t.value[0];t.value[0]=t.value[1],t.value[1]=e}return t})}return t.__iterator(e===wr?gr:wr,r)},e}function ae(t,e,r){var n=Ee(t);return n.size=t.size,n.has=function(e){return t.has(e)},n.get=function(n,i){var o=t.get(n,yr);return o===yr?i:e.call(r,o,n,t)},n.__iterateUncached=function(n,i){var o=this;return t.__iterate(function(t,i,u){return n(e.call(r,t,i,u),i,o)!==!1},i)},n.__iteratorUncached=function(n,i){var o=t.__iterator(Sr,i);return new S(function(){var i=o.next();if(i.done)return i;var u=i.value,s=u[0];return z(n,s,e.call(r,u[1],s,t),i)})},n}function he(t,e){var r=Ee(t);return r._iter=t,r.size=t.size,r.reverse=function(){return t},t.flip&&(r.flip=function(){var e=se(t);return e.reverse=function(){return t.flip()},e}),r.get=function(r,n){return t.get(e?r:-1-r,n)},r.has=function(r){return t.has(e?r:-1-r)},r.includes=function(e){return t.includes(e)},r.cacheResult=Oe,r.__iterate=function(e,r){var n=this;return t.__iterate(function(t,r){return e(t,r,n)},!r)},r.__iterator=function(e,r){return t.__iterator(e,!r)},r}function fe(t,e,r,n){var i=Ee(t);return n&&(i.has=function(n){var i=t.get(n,yr);return i!==yr&&!!e.call(r,i,n,t)},i.get=function(n,i){var o=t.get(n,yr);return o!==yr&&e.call(r,o,n,t)?o:i}),i.__iterateUncached=function(i,o){var u=this,s=0;return t.__iterate(function(t,o,a){return e.call(r,t,o,a)?(s++,i(t,n?o:s-1,u)):void 0},o),s},i.__iteratorUncached=function(i,o){var u=t.__iterator(Sr,o),s=0;return new S(function(){for(;;){var o=u.next();if(o.done)return o;var a=o.value,h=a[0],f=a[1];if(e.call(r,f,h,t))return z(i,n?h:s++,f,o)}})},i}function ce(t,e,r){var n=ct().asMutable();return t.__iterate(function(i,o){n.update(e.call(r,i,o,t),0,function(t){ +return t+1})}),n.asImmutable()}function _e(t,e,r){var n=u(t),i=(h(t)?Zt():ct()).asMutable();t.__iterate(function(o,u){i.update(e.call(r,o,u,t),function(t){return t=t||[],t.push(n?[u,o]:o),t})});var o=Me(t);return i.map(function(e){return be(t,o(e))})}function pe(t,e,r,n){var i=t.size;if(void 0!==e&&(e=0|e),void 0!==r&&(r=0|r),d(e,r,i))return t;var o=m(e,i),u=g(r,i);if(o!==o||u!==u)return pe(t.toSeq().cacheResult(),e,r,n);var s,a=u-o;a===a&&(s=0>a?0:a);var h=Ee(t);return h.size=0===s?s:t.size&&s||void 0,!n&&L(t)&&s>=0&&(h.get=function(e,r){return e=l(this,e),e>=0&&s>e?t.get(e+o,r):r}),h.__iterateUncached=function(e,r){var i=this;if(0===s)return 0;if(r)return this.cacheResult().__iterate(e,r);var u=0,a=!0,h=0;return t.__iterate(function(t,r){return a&&(a=u++s)return I();var t=i.next();return n||e===wr?t:e===gr?z(e,a-1,void 0,t):z(e,a-1,t.value[1],t)})},h}function ve(t,e,r){var n=Ee(t);return n.__iterateUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterate(n,i);var u=0;return t.__iterate(function(t,i,s){return e.call(r,t,i,s)&&++u&&n(t,i,o)}),u},n.__iteratorUncached=function(n,i){var o=this;if(i)return this.cacheResult().__iterator(n,i);var u=t.__iterator(Sr,i),s=!0;return new S(function(){if(!s)return I();var t=u.next();if(t.done)return t;var i=t.value,a=i[0],h=i[1];return e.call(r,h,a,o)?n===Sr?t:z(n,a,h,t):(s=!1,I())})},n}function le(t,e,r,n){var i=Ee(t);return i.__iterateUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterate(i,o);var s=!0,a=0;return t.__iterate(function(t,o,h){return s&&(s=e.call(r,t,o,h))?void 0:(a++,i(t,n?o:a-1,u))}),a},i.__iteratorUncached=function(i,o){var u=this;if(o)return this.cacheResult().__iterator(i,o);var s=t.__iterator(Sr,o),a=!0,h=0;return new S(function(){var t,o,f;do{if(t=s.next(),t.done)return n||i===wr?t:i===gr?z(i,h++,void 0,t):z(i,h++,t.value[1],t); +var c=t.value;o=c[0],f=c[1],a&&(a=e.call(r,f,o,u))}while(a);return i===Sr?t:z(i,o,f,t)})},i}function ye(t,e){var n=u(t),i=[t].concat(e).map(function(t){return o(t)?n&&(t=r(t)):t=n?W(t):B(Array.isArray(t)?t:[t]),t}).filter(function(t){return 0!==t.size});if(0===i.length)return t;if(1===i.length){var a=i[0];if(a===t||n&&u(a)||s(t)&&s(a))return a}var h=new j(i);return n?h=h.toKeyedSeq():s(t)||(h=h.toSetSeq()),h=h.flatten(!0),h.size=i.reduce(function(t,e){if(void 0!==t){var r=e.size;if(void 0!==r)return t+r}},0),h}function de(t,e,r){var n=Ee(t);return n.__iterateUncached=function(n,i){function u(t,h){var f=this;t.__iterate(function(t,i){return(!e||e>h)&&o(t)?u(t,h+1):n(t,r?i:s++,f)===!1&&(a=!0),!a},i)}var s=0,a=!1;return u(t,0),s},n.__iteratorUncached=function(n,i){var u=t.__iterator(n,i),s=[],a=0;return new S(function(){for(;u;){var t=u.next();if(t.done===!1){var h=t.value;if(n===Sr&&(h=h[1]),e&&!(e>s.length)||!o(h))return r?t:z(n,a++,h,t);s.push(u),u=h.__iterator(n,i)}else u=s.pop()}return I()})},n}function me(t,e,r){var n=Me(t);return t.toSeq().map(function(i,o){return n(e.call(r,i,o,t))}).flatten(!0)}function ge(t,e){var r=Ee(t);return r.size=t.size&&2*t.size-1,r.__iterateUncached=function(r,n){var i=this,o=0;return t.__iterate(function(t,n){return(!o||r(e,o++,i)!==!1)&&r(t,o++,i)!==!1},n),o},r.__iteratorUncached=function(r,n){var i,o=t.__iterator(wr,n),u=0;return new S(function(){return(!i||u%2)&&(i=o.next(),i.done)?i:u%2?z(r,u++,e):z(r,u++,i.value,i)})},r}function we(t,e,r){e||(e=xe);var n=u(t),i=0,o=t.toSeq().map(function(e,n){return[n,e,i++,r?r(e,n,t):e]}).toArray();return o.sort(function(t,r){return e(t[3],r[3])||t[2]-r[2]}).forEach(n?function(t,e){o[e].length=2}:function(t,e){o[e]=t[1]}),n?x(o):s(t)?k(o):A(o)}function Se(t,e,r){if(e||(e=xe),r){var n=t.toSeq().map(function(e,n){return[e,r(e,n,t)]}).reduce(function(t,r){return ze(e,t[1],r[1])?r:t});return n&&n[0]}return t.reduce(function(t,r){return ze(e,t,r)?r:t})}function ze(t,e,r){var n=t(r,e);return 0===n&&r!==e&&(void 0===r||null===r||r!==r)||n>0}function Ie(t,r,n){ +var i=Ee(t);return i.size=new j(n).map(function(t){return t.size}).min(),i.__iterate=function(t,e){for(var r,n=this.__iterator(wr,e),i=0;!(r=n.next()).done&&t(r.value,i++,this)!==!1;);return i},i.__iteratorUncached=function(t,i){var o=n.map(function(t){return t=e(t),D(i?t.reverse():t)}),u=0,s=!1;return new S(function(){var e;return s||(e=o.map(function(t){return t.next()}),s=e.some(function(t){return t.done})),s?I():z(t,u++,r.apply(null,e.map(function(t){return t.value})))})},i}function be(t,e){return L(t)?e:t.constructor(e)}function qe(t){if(t!==Object(t))throw new TypeError("Expected [K, V] tuple: "+t)}function De(t){return ft(t.size),v(t)}function Me(t){return u(t)?r:s(t)?n:i}function Ee(t){return Object.create((u(t)?x:s(t)?k:A).prototype)}function Oe(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):O.prototype.cacheResult.call(this)}function xe(t,e){return t>e?1:e>t?-1:0}function ke(t){var r=D(t);if(!r){if(!E(t))throw new TypeError("Expected iterable or array-like: "+t);r=D(e(t))}return r}function Ae(t,e){var r,n=function(o){if(o instanceof n)return o;if(!(this instanceof n))return new n(o);if(!r){r=!0;var u=Object.keys(t);Re(i,u),i.size=u.length,i._name=e,i._keys=u,i._defaultValues=t}this._map=ct(o)},i=n.prototype=Object.create(Gr);return i.constructor=n,n}function je(t,e,r){var n=Object.create(Object.getPrototypeOf(t));return n._map=e,n.__ownerID=r,n}function Ke(t){return t._name||t.constructor.name||"Record"}function Re(t,e){try{e.forEach(Ue.bind(void 0,t))}catch(r){}}function Ue(t,e){Object.defineProperty(t,e,{get:function(){return this.get(e)},set:function(t){Z(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}function Le(t){return null===t||void 0===t?Ce():Te(t)&&!h(t)?t:Ce().withMutations(function(e){var r=i(t);ft(r.size),r.forEach(function(t){return e.add(t)})})}function Te(t){return!(!t||!t[Zr])}function We(t,e){return t.__ownerID?(t.size=e.size,t._map=e,t):e===t._map?t:0===e.size?t.__empty():t.__make(e)}function Be(t,e){var r=Object.create($r); +return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function Ce(){return tn||(tn=Be(zt()))}function Je(t){return null===t||void 0===t?He():Ne(t)?t:He().withMutations(function(e){var r=i(t);ft(r.size),r.forEach(function(t){return e.add(t)})})}function Ne(t){return Te(t)&&h(t)}function Pe(t,e){var r=Object.create(en);return r.size=t?t.size:0,r._map=t,r.__ownerID=e,r}function He(){return rn||(rn=Pe(ee()))}function Ve(t){return null===t||void 0===t?Xe():Ye(t)?t:Xe().unshiftAll(t)}function Ye(t){return!(!t||!t[nn])}function Qe(t,e,r,n){var i=Object.create(on);return i.size=t,i._head=e,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function Xe(){return un||(un=Qe(0))}function Fe(t,e){var r=function(r){t.prototype[r]=e[r]};return Object.keys(e).forEach(r),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(r),t}function Ge(t,e){return e}function Ze(t,e){return[e,t]}function $e(t){return function(){return!t.apply(this,arguments)}}function tr(t){return function(){return-t.apply(this,arguments)}}function er(t){return"string"==typeof t?JSON.stringify(t):t}function rr(){return p(arguments)}function nr(t,e){return e>t?1:t>e?-1:0}function ir(t){if(t.size===1/0)return 0;var e=h(t),r=u(t),n=e?1:0,i=t.__iterate(r?e?function(t,e){n=31*n+ur(ot(t),ot(e))|0}:function(t,e){n=n+ur(ot(t),ot(e))|0}:e?function(t){n=31*n+ot(t)|0}:function(t){n=n+ot(t)|0});return or(i,n)}function or(t,e){return e=xr(e,3432918353),e=xr(e<<15|e>>>-15,461845907),e=xr(e<<13|e>>>-13,5),e=(e+3864292196|0)^t,e=xr(e^e>>>16,2246822507),e=xr(e^e>>>13,3266489909),e=it(e^e>>>16)}function ur(t,e){return t^e+2654435769+(t<<6)+(t>>2)|0}var sr=Array.prototype.slice;t(r,e),t(n,e),t(i,e),e.isIterable=o,e.isKeyed=u,e.isIndexed=s,e.isAssociative=a,e.isOrdered=h,e.Keyed=r,e.Indexed=n,e.Set=i;var ar="@@__IMMUTABLE_ITERABLE__@@",hr="@@__IMMUTABLE_KEYED__@@",fr="@@__IMMUTABLE_INDEXED__@@",cr="@@__IMMUTABLE_ORDERED__@@",_r="delete",pr=5,vr=1<=i;i++)if(t(r[e?n-i:i],i,this)===!1)return i+1;return i},j.prototype.__iterator=function(t,e){var r=this._array,n=r.length-1,i=0;return new S(function(){return i>n?I():z(t,i,r[e?n-i++:i++])})},t(K,x),K.prototype.get=function(t,e){return void 0===e||this.has(t)?this._object[t]:e},K.prototype.has=function(t){return this._object.hasOwnProperty(t)},K.prototype.__iterate=function(t,e){for(var r=this._object,n=this._keys,i=n.length-1,o=0;i>=o;o++){var u=n[e?i-o:o];if(t(r[u],u,this)===!1)return o+1}return o},K.prototype.__iterator=function(t,e){var r=this._object,n=this._keys,i=n.length-1,o=0;return new S(function(){var u=n[e?i-o:o];return o++>i?I():z(t,u,r[u])})},K.prototype[cr]=!0,t(R,k),R.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e); +var r=this._iterable,n=D(r),i=0;if(q(n))for(var o;!(o=n.next()).done&&t(o.value,i++,this)!==!1;);return i},R.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=this._iterable,n=D(r);if(!q(n))return new S(I);var i=0;return new S(function(){var e=n.next();return e.done?e:z(t,i++,e.value)})},t(U,k),U.prototype.__iterateUncached=function(t,e){if(e)return this.cacheResult().__iterate(t,e);for(var r=this._iterator,n=this._iteratorCache,i=0;n.length>i;)if(t(n[i],i++,this)===!1)return i;for(var o;!(o=r.next()).done;){var u=o.value;if(n[i]=u,t(u,i++,this)===!1)break}return i},U.prototype.__iteratorUncached=function(t,e){if(e)return this.cacheResult().__iterator(t,e);var r=this._iterator,n=this._iteratorCache,i=0;return new S(function(){if(i>=n.length){var e=r.next();if(e.done)return e;n[i]=e.value}return z(t,i,n[i++])})};var Dr;t(G,k),G.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},G.prototype.get=function(t,e){return this.has(t)?this._value:e},G.prototype.includes=function(t){return X(this._value,t)},G.prototype.slice=function(t,e){var r=this.size;return d(t,e,r)?this:new G(this._value,g(e,r)-m(t,r))},G.prototype.reverse=function(){return this},G.prototype.indexOf=function(t){return X(this._value,t)?0:-1},G.prototype.lastIndexOf=function(t){return X(this._value,t)?this.size:-1},G.prototype.__iterate=function(t,e){for(var r=0;this.size>r;r++)if(t(this._value,r,this)===!1)return r+1;return r},G.prototype.__iterator=function(t,e){var r=this,n=0;return new S(function(){return r.size>n?z(t,n++,r._value):I()})},G.prototype.equals=function(t){return t instanceof G?X(this._value,t._value):F(t)};var Mr;t($,k),$.prototype.toString=function(){return 0===this.size?"Range []":"Range [ "+this._start+"..."+this._end+(this._step>1?" by "+this._step:"")+" ]"},$.prototype.get=function(t,e){return this.has(t)?this._start+l(this,t)*this._step:e},$.prototype.includes=function(t){var e=(t-this._start)/this._step;return e>=0&&this.size>e&&e===Math.floor(e); +},$.prototype.slice=function(t,e){return d(t,e,this.size)?this:(t=m(t,this.size),e=g(e,this.size),t>=e?new $(0,0):new $(this.get(t,this._end),this.get(e,this._end),this._step))},$.prototype.indexOf=function(t){var e=t-this._start;if(e%this._step===0){var r=e/this._step;if(r>=0&&this.size>r)return r}return-1},$.prototype.lastIndexOf=function(t){return this.indexOf(t)},$.prototype.__iterate=function(t,e){for(var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,o=0;r>=o;o++){if(t(i,o,this)===!1)return o+1;i+=e?-n:n}return o},$.prototype.__iterator=function(t,e){var r=this.size-1,n=this._step,i=e?this._start+r*n:this._start,o=0;return new S(function(){var u=i;return i+=e?-n:n,o>r?I():z(t,o++,u)})},$.prototype.equals=function(t){return t instanceof $?this._start===t._start&&this._end===t._end&&this._step===t._step:F(this,t)};var Er;t(tt,e),t(et,tt),t(rt,tt),t(nt,tt),tt.Keyed=et,tt.Indexed=rt,tt.Set=nt;var Or,xr="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(t,e){t=0|t,e=0|e;var r=65535&t,n=65535&e;return r*n+((t>>>16)*n+r*(e>>>16)<<16>>>0)|0},kr=Object.isExtensible,Ar=function(){try{return Object.defineProperty({},"@",{}),!0}catch(t){return!1}}(),jr="function"==typeof WeakMap;jr&&(Or=new WeakMap);var Kr=0,Rr="__immutablehash__";"function"==typeof Symbol&&(Rr=Symbol(Rr));var Ur=16,Lr=255,Tr=0,Wr={};t(ct,et),ct.prototype.toString=function(){return this.__toString("Map {","}")},ct.prototype.get=function(t,e){return this._root?this._root.get(0,void 0,t,e):e},ct.prototype.set=function(t,e){return It(this,t,e)},ct.prototype.setIn=function(t,e){return this.updateIn(t,yr,function(){return e})},ct.prototype.remove=function(t){return It(this,t,yr)},ct.prototype.deleteIn=function(t){return this.updateIn(t,function(){return yr})},ct.prototype.update=function(t,e,r){return 1===arguments.length?t(this):this.updateIn([t],e,r)},ct.prototype.updateIn=function(t,e,r){r||(r=e,e=void 0);var n=Kt(this,ke(t),e,r);return n===yr?void 0:n},ct.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0, +this._root=null,this.__hash=void 0,this.__altered=!0,this):zt()},ct.prototype.merge=function(){return xt(this,void 0,arguments)},ct.prototype.mergeWith=function(t){var e=sr.call(arguments,1);return xt(this,t,e)},ct.prototype.mergeIn=function(t){var e=sr.call(arguments,1);return this.updateIn(t,zt(),function(t){return"function"==typeof t.merge?t.merge.apply(t,e):e[e.length-1]})},ct.prototype.mergeDeep=function(){return xt(this,kt,arguments)},ct.prototype.mergeDeepWith=function(t){var e=sr.call(arguments,1);return xt(this,At(t),e)},ct.prototype.mergeDeepIn=function(t){var e=sr.call(arguments,1);return this.updateIn(t,zt(),function(t){return"function"==typeof t.mergeDeep?t.mergeDeep.apply(t,e):e[e.length-1]})},ct.prototype.sort=function(t){return Zt(we(this,t))},ct.prototype.sortBy=function(t,e){return Zt(we(this,e,t))},ct.prototype.withMutations=function(t){var e=this.asMutable();return t(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this},ct.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new _)},ct.prototype.asImmutable=function(){return this.__ensureOwner()},ct.prototype.wasAltered=function(){return this.__altered},ct.prototype.__iterator=function(t,e){return new mt(this,t,e)},ct.prototype.__iterate=function(t,e){var r=this,n=0;return this._root&&this._root.iterate(function(e){return n++,t(e[1],e[0],r)},e),n},ct.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?St(this.size,this._root,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},ct.isMap=_t;var Br="@@__IMMUTABLE_MAP__@@",Cr=ct.prototype;Cr[Br]=!0,Cr[_r]=Cr.remove,Cr.removeIn=Cr.deleteIn,pt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},pt.prototype.update=function(t,e,r,n,i,o,u){for(var s=i===yr,a=this.entries,h=0,f=a.length;f>h&&!X(n,a[h][0]);h++);var _=f>h;if(_?a[h][1]===i:s)return this;if(c(u),(s||!_)&&c(o),!s||1!==a.length){if(!_&&!s&&a.length>=Nr)return Mt(t,a,n,i);var v=t&&t===this.ownerID,l=v?a:p(a);return _?s?h===f-1?l.pop():l[h]=l.pop():l[h]=[n,i]:l.push([n,i]), +v?(this.entries=l,this):new pt(t,l)}},vt.prototype.get=function(t,e,r,n){void 0===e&&(e=ot(r));var i=1<<((0===t?e:e>>>t)&lr),o=this.bitmap;return 0===(o&i)?n:this.nodes[Rt(o&i-1)].get(t+pr,e,r,n)},vt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ot(n));var s=(0===e?r:r>>>e)&lr,a=1<=Pr)return Ot(t,_,h,s,v);if(f&&!v&&2===_.length&&qt(_[1^c]))return _[1^c];if(f&&v&&1===_.length&&qt(v))return v;var l=t&&t===this.ownerID,y=f?v?h:h^a:h|a,d=f?v?Ut(_,c,v,l):Tt(_,c,l):Lt(_,c,v,l);return l?(this.bitmap=y,this.nodes=d,this):new vt(t,y,d)},lt.prototype.get=function(t,e,r,n){void 0===e&&(e=ot(r));var i=(0===t?e:e>>>t)&lr,o=this.nodes[i];return o?o.get(t+pr,e,r,n):n},lt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ot(n));var s=(0===e?r:r>>>e)&lr,a=i===yr,h=this.nodes,f=h[s];if(a&&!f)return this;var c=bt(f,t,e+pr,r,n,i,o,u);if(c===f)return this;var _=this.count;if(f){if(!c&&(_--,Hr>_))return Et(t,h,_,s)}else _++;var p=t&&t===this.ownerID,v=Ut(h,s,c,p);return p?(this.count=_,this.nodes=v,this):new lt(t,_,v)},yt.prototype.get=function(t,e,r,n){for(var i=this.entries,o=0,u=i.length;u>o;o++)if(X(r,i[o][0]))return i[o][1];return n},yt.prototype.update=function(t,e,r,n,i,o,u){void 0===r&&(r=ot(n));var s=i===yr;if(r!==this.keyHash)return s?this:(c(u),c(o),Dt(this,t,e,r,[n,i]));for(var a=this.entries,h=0,f=a.length;f>h&&!X(n,a[h][0]);h++);var _=f>h;if(_?a[h][1]===i:s)return this;if(c(u),(s||!_)&&c(o),s&&2===f)return new dt(t,this.keyHash,a[1^h]);var v=t&&t===this.ownerID,l=v?a:p(a);return _?s?h===f-1?l.pop():l[h]=l.pop():l[h]=[n,i]:l.push([n,i]),v?(this.entries=l,this):new yt(t,this.keyHash,l)},dt.prototype.get=function(t,e,r,n){return X(r,this.entry[0])?this.entry[1]:n},dt.prototype.update=function(t,e,r,n,i,o,u){var s=i===yr,a=X(n,this.entry[0]);return(a?i===this.entry[1]:s)?this:(c(u),s?void c(o):a?t&&t===this.ownerID?(this.entry[1]=i,this):new dt(t,this.keyHash,[n,i]):(c(o), +Dt(this,t,e,ot(n),[n,i])))},pt.prototype.iterate=yt.prototype.iterate=function(t,e){for(var r=this.entries,n=0,i=r.length-1;i>=n;n++)if(t(r[e?i-n:n])===!1)return!1},vt.prototype.iterate=lt.prototype.iterate=function(t,e){for(var r=this.nodes,n=0,i=r.length-1;i>=n;n++){var o=r[e?i-n:n];if(o&&o.iterate(t,e)===!1)return!1}},dt.prototype.iterate=function(t,e){return t(this.entry)},t(mt,S),mt.prototype.next=function(){for(var t=this._type,e=this._stack;e;){var r,n=e.node,i=e.index++;if(n.entry){if(0===i)return gt(t,n.entry)}else if(n.entries){if(r=n.entries.length-1,r>=i)return gt(t,n.entries[this._reverse?r-i:i])}else if(r=n.nodes.length-1,r>=i){var o=n.nodes[this._reverse?r-i:i];if(o){if(o.entry)return gt(t,o.entry);e=this._stack=wt(o,e)}continue}e=this._stack=this._stack.__prev}return I()};var Jr,Nr=vr/4,Pr=vr/2,Hr=vr/4;t(Wt,rt),Wt.of=function(){return this(arguments)},Wt.prototype.toString=function(){return this.__toString("List [","]")},Wt.prototype.get=function(t,e){if(t=l(this,t),t>=0&&this.size>t){t+=this._origin;var r=Qt(this,t);return r&&r.array[t&lr]}return e},Wt.prototype.set=function(t,e){return Ht(this,t,e)},Wt.prototype.remove=function(t){return this.has(t)?0===t?this.shift():t===this.size-1?this.pop():this.splice(t,1):this},Wt.prototype.insert=function(t,e){return this.splice(t,0,e)},Wt.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=pr,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):Pt()},Wt.prototype.push=function(){var t=arguments,e=this.size;return this.withMutations(function(r){Xt(r,0,e+t.length);for(var n=0;t.length>n;n++)r.set(e+n,t[n])})},Wt.prototype.pop=function(){return Xt(this,0,-1)},Wt.prototype.unshift=function(){var t=arguments;return this.withMutations(function(e){Xt(e,-t.length);for(var r=0;t.length>r;r++)e.set(r,t[r])})},Wt.prototype.shift=function(){return Xt(this,1)},Wt.prototype.merge=function(){return Ft(this,void 0,arguments)},Wt.prototype.mergeWith=function(t){var e=sr.call(arguments,1); +return Ft(this,t,e)},Wt.prototype.mergeDeep=function(){return Ft(this,kt,arguments)},Wt.prototype.mergeDeepWith=function(t){var e=sr.call(arguments,1);return Ft(this,At(t),e)},Wt.prototype.setSize=function(t){return Xt(this,0,t)},Wt.prototype.slice=function(t,e){var r=this.size;return d(t,e,r)?this:Xt(this,m(t,r),g(e,r))},Wt.prototype.__iterator=function(t,e){var r=0,n=Jt(this,e);return new S(function(){var e=n();return e===Xr?I():z(t,r++,e)})},Wt.prototype.__iterate=function(t,e){for(var r,n=0,i=Jt(this,e);(r=i())!==Xr&&t(r,n++,this)!==!1;);return n},Wt.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Nt(this._origin,this._capacity,this._level,this._root,this._tail,t,this.__hash):(this.__ownerID=t,this)},Wt.isList=Bt;var Vr="@@__IMMUTABLE_LIST__@@",Yr=Wt.prototype;Yr[Vr]=!0,Yr[_r]=Yr.remove,Yr.setIn=Cr.setIn,Yr.deleteIn=Yr.removeIn=Cr.removeIn,Yr.update=Cr.update,Yr.updateIn=Cr.updateIn,Yr.mergeIn=Cr.mergeIn,Yr.mergeDeepIn=Cr.mergeDeepIn,Yr.withMutations=Cr.withMutations,Yr.asMutable=Cr.asMutable,Yr.asImmutable=Cr.asImmutable,Yr.wasAltered=Cr.wasAltered,Ct.prototype.removeBefore=function(t,e,r){if(r===e?1<>>e&lr;if(n>=this.array.length)return new Ct([],t);var i,o=0===n;if(e>0){var u=this.array[n];if(i=u&&u.removeBefore(t,e-pr,r),i===u&&o)return this}if(o&&!i)return this;var s=Yt(this,t);if(!o)for(var a=0;n>a;a++)s.array[a]=void 0;return i&&(s.array[n]=i),s},Ct.prototype.removeAfter=function(t,e,r){if(r===(e?1<>>e&lr;if(n>=this.array.length)return this;var i;if(e>0){var o=this.array[n];if(i=o&&o.removeAfter(t,e-pr,r),i===o&&n===this.array.length-1)return this}var u=Yt(this,t);return u.array.splice(n+1),i&&(u.array[n]=i),u};var Qr,Xr={};t(Zt,ct),Zt.of=function(){return this(arguments)},Zt.prototype.toString=function(){return this.__toString("OrderedMap {","}")},Zt.prototype.get=function(t,e){var r=this._map.get(t);return void 0!==r?this._list.get(r)[1]:e},Zt.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0, +this._map.clear(),this._list.clear(),this):ee()},Zt.prototype.set=function(t,e){return re(this,t,e)},Zt.prototype.remove=function(t){return re(this,t,yr)},Zt.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},Zt.prototype.__iterate=function(t,e){var r=this;return this._list.__iterate(function(e){return e&&t(e[1],e[0],r)},e)},Zt.prototype.__iterator=function(t,e){return this._list.fromEntrySeq().__iterator(t,e)},Zt.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t),r=this._list.__ensureOwner(t);return t?te(e,r,t,this.__hash):(this.__ownerID=t,this._map=e,this._list=r,this)},Zt.isOrderedMap=$t,Zt.prototype[cr]=!0,Zt.prototype[_r]=Zt.prototype.remove;var Fr;t(ne,x),ne.prototype.get=function(t,e){return this._iter.get(t,e)},ne.prototype.has=function(t){return this._iter.has(t)},ne.prototype.valueSeq=function(){return this._iter.valueSeq()},ne.prototype.reverse=function(){var t=this,e=he(this,!0);return this._useKeys||(e.valueSeq=function(){return t._iter.toSeq().reverse()}),e},ne.prototype.map=function(t,e){var r=this,n=ae(this,t,e);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(t,e)}),n},ne.prototype.__iterate=function(t,e){var r,n=this;return this._iter.__iterate(this._useKeys?function(e,r){return t(e,r,n)}:(r=e?De(this):0,function(i){return t(i,e?--r:r++,n)}),e)},ne.prototype.__iterator=function(t,e){if(this._useKeys)return this._iter.__iterator(t,e);var r=this._iter.__iterator(wr,e),n=e?De(this):0;return new S(function(){var i=r.next();return i.done?i:z(t,e?--n:n++,i.value,i)})},ne.prototype[cr]=!0,t(ie,k),ie.prototype.includes=function(t){return this._iter.includes(t)},ie.prototype.__iterate=function(t,e){var r=this,n=0;return this._iter.__iterate(function(e){return t(e,n++,r)},e)},ie.prototype.__iterator=function(t,e){var r=this._iter.__iterator(wr,e),n=0;return new S(function(){var e=r.next();return e.done?e:z(t,n++,e.value,e)})},t(oe,A),oe.prototype.has=function(t){return this._iter.includes(t)},oe.prototype.__iterate=function(t,e){ +var r=this;return this._iter.__iterate(function(e){return t(e,e,r)},e)},oe.prototype.__iterator=function(t,e){var r=this._iter.__iterator(wr,e);return new S(function(){var e=r.next();return e.done?e:z(t,e.value,e.value,e)})},t(ue,x),ue.prototype.entrySeq=function(){return this._iter.toSeq()},ue.prototype.__iterate=function(t,e){var r=this;return this._iter.__iterate(function(e){if(e){qe(e);var n=o(e);return t(n?e.get(1):e[1],n?e.get(0):e[0],r)}},e)},ue.prototype.__iterator=function(t,e){var r=this._iter.__iterator(wr,e);return new S(function(){for(;;){var e=r.next();if(e.done)return e;var n=e.value;if(n){qe(n);var i=o(n);return z(t,i?n.get(0):n[0],i?n.get(1):n[1],e)}}})},ie.prototype.cacheResult=ne.prototype.cacheResult=oe.prototype.cacheResult=ue.prototype.cacheResult=Oe,t(Ae,et),Ae.prototype.toString=function(){return this.__toString(Ke(this)+" {","}")},Ae.prototype.has=function(t){return this._defaultValues.hasOwnProperty(t)},Ae.prototype.get=function(t,e){if(!this.has(t))return e;var r=this._defaultValues[t];return this._map?this._map.get(t,r):r},Ae.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var t=this.constructor;return t._empty||(t._empty=je(this,zt()))},Ae.prototype.set=function(t,e){if(!this.has(t))throw Error('Cannot set unknown key "'+t+'" on '+Ke(this));var r=this._map&&this._map.set(t,e);return this.__ownerID||r===this._map?this:je(this,r)},Ae.prototype.remove=function(t){if(!this.has(t))return this;var e=this._map&&this._map.remove(t);return this.__ownerID||e===this._map?this:je(this,e)},Ae.prototype.wasAltered=function(){return this._map.wasAltered()},Ae.prototype.__iterator=function(t,e){var n=this;return r(this._defaultValues).map(function(t,e){return n.get(e)}).__iterator(t,e)},Ae.prototype.__iterate=function(t,e){var n=this;return r(this._defaultValues).map(function(t,e){return n.get(e)}).__iterate(t,e)},Ae.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map&&this._map.__ensureOwner(t);return t?je(this,e,t):(this.__ownerID=t, +this._map=e,this)};var Gr=Ae.prototype;Gr[_r]=Gr.remove,Gr.deleteIn=Gr.removeIn=Cr.removeIn,Gr.merge=Cr.merge,Gr.mergeWith=Cr.mergeWith,Gr.mergeIn=Cr.mergeIn,Gr.mergeDeep=Cr.mergeDeep,Gr.mergeDeepWith=Cr.mergeDeepWith,Gr.mergeDeepIn=Cr.mergeDeepIn,Gr.setIn=Cr.setIn,Gr.update=Cr.update,Gr.updateIn=Cr.updateIn,Gr.withMutations=Cr.withMutations,Gr.asMutable=Cr.asMutable,Gr.asImmutable=Cr.asImmutable,t(Le,nt),Le.of=function(){return this(arguments)},Le.fromKeys=function(t){return this(r(t).keySeq())},Le.prototype.toString=function(){return this.__toString("Set {","}")},Le.prototype.has=function(t){return this._map.has(t)},Le.prototype.add=function(t){return We(this,this._map.set(t,!0))},Le.prototype.remove=function(t){return We(this,this._map.remove(t))},Le.prototype.clear=function(){return We(this,this._map.clear())},Le.prototype.union=function(){var t=sr.call(arguments,0);return t=t.filter(function(t){return 0!==t.size}),0===t.length?this:0!==this.size||this.__ownerID||1!==t.length?this.withMutations(function(e){for(var r=0;t.length>r;r++)i(t[r]).forEach(function(t){return e.add(t)})}):this.constructor(t[0])},Le.prototype.intersect=function(){var t=sr.call(arguments,0);if(0===t.length)return this;t=t.map(function(t){return i(t)});var e=this;return this.withMutations(function(r){e.forEach(function(e){t.every(function(t){return t.includes(e)})||r.remove(e)})})},Le.prototype.subtract=function(){var t=sr.call(arguments,0);if(0===t.length)return this;t=t.map(function(t){return i(t)});var e=this;return this.withMutations(function(r){e.forEach(function(e){t.some(function(t){return t.includes(e)})&&r.remove(e)})})},Le.prototype.merge=function(){return this.union.apply(this,arguments)},Le.prototype.mergeWith=function(t){var e=sr.call(arguments,1);return this.union.apply(this,e)},Le.prototype.sort=function(t){return Je(we(this,t))},Le.prototype.sortBy=function(t,e){return Je(we(this,e,t))},Le.prototype.wasAltered=function(){return this._map.wasAltered()},Le.prototype.__iterate=function(t,e){var r=this;return this._map.__iterate(function(e,n){ +return t(n,n,r)},e)},Le.prototype.__iterator=function(t,e){return this._map.map(function(t,e){return e}).__iterator(t,e)},Le.prototype.__ensureOwner=function(t){if(t===this.__ownerID)return this;var e=this._map.__ensureOwner(t);return t?this.__make(e,t):(this.__ownerID=t,this._map=e,this)},Le.isSet=Te;var Zr="@@__IMMUTABLE_SET__@@",$r=Le.prototype;$r[Zr]=!0,$r[_r]=$r.remove,$r.mergeDeep=$r.merge,$r.mergeDeepWith=$r.mergeWith,$r.withMutations=Cr.withMutations,$r.asMutable=Cr.asMutable,$r.asImmutable=Cr.asImmutable,$r.__empty=Ce,$r.__make=Be;var tn;t(Je,Le),Je.of=function(){return this(arguments)},Je.fromKeys=function(t){return this(r(t).keySeq())},Je.prototype.toString=function(){return this.__toString("OrderedSet {","}")},Je.isOrderedSet=Ne;var en=Je.prototype;en[cr]=!0,en.__empty=He,en.__make=Pe;var rn;t(Ve,rt),Ve.of=function(){return this(arguments)},Ve.prototype.toString=function(){return this.__toString("Stack [","]")},Ve.prototype.get=function(t,e){var r=this._head;for(t=l(this,t);r&&t--;)r=r.next;return r?r.value:e},Ve.prototype.peek=function(){return this._head&&this._head.value},Ve.prototype.push=function(){if(0===arguments.length)return this;for(var t=this.size+arguments.length,e=this._head,r=arguments.length-1;r>=0;r--)e={value:arguments[r],next:e};return this.__ownerID?(this.size=t,this._head=e,this.__hash=void 0,this.__altered=!0,this):Qe(t,e)},Ve.prototype.pushAll=function(t){if(t=n(t),0===t.size)return this;ft(t.size);var e=this.size,r=this._head;return t.reverse().forEach(function(t){e++,r={value:t,next:r}}),this.__ownerID?(this.size=e,this._head=r,this.__hash=void 0,this.__altered=!0,this):Qe(e,r)},Ve.prototype.pop=function(){return this.slice(1)},Ve.prototype.unshift=function(){return this.push.apply(this,arguments)},Ve.prototype.unshiftAll=function(t){return this.pushAll(t)},Ve.prototype.shift=function(){return this.pop.apply(this,arguments)},Ve.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Xe()},Ve.prototype.slice=function(t,e){ +if(d(t,e,this.size))return this;var r=m(t,this.size),n=g(e,this.size);if(n!==this.size)return rt.prototype.slice.call(this,t,e);for(var i=this.size-r,o=this._head;r--;)o=o.next;return this.__ownerID?(this.size=i,this._head=o,this.__hash=void 0,this.__altered=!0,this):Qe(i,o)},Ve.prototype.__ensureOwner=function(t){return t===this.__ownerID?this:t?Qe(this.size,this._head,t,this.__hash):(this.__ownerID=t,this.__altered=!1,this)},Ve.prototype.__iterate=function(t,e){if(e)return this.reverse().__iterate(t);for(var r=0,n=this._head;n&&t(n.value,r++,this)!==!1;)n=n.next;return r},Ve.prototype.__iterator=function(t,e){if(e)return this.reverse().__iterator(t);var r=0,n=this._head;return new S(function(){if(n){var e=n.value;return n=n.next,z(t,r++,e)}return I()})},Ve.isStack=Ye;var nn="@@__IMMUTABLE_STACK__@@",on=Ve.prototype;on[nn]=!0,on.withMutations=Cr.withMutations,on.asMutable=Cr.asMutable,on.asImmutable=Cr.asImmutable,on.wasAltered=Cr.wasAltered;var un;e.Iterator=S,Fe(e,{toArray:function(){ft(this.size);var t=Array(this.size||0);return this.valueSeq().__iterate(function(e,r){t[r]=e}),t},toIndexedSeq:function(){return new ie(this)},toJS:function(){return this.toSeq().map(function(t){return t&&"function"==typeof t.toJS?t.toJS():t}).__toJS()},toJSON:function(){return this.toSeq().map(function(t){return t&&"function"==typeof t.toJSON?t.toJSON():t}).__toJS()},toKeyedSeq:function(){return new ne(this,!0)},toMap:function(){return ct(this.toKeyedSeq())},toObject:function(){ft(this.size);var t={};return this.__iterate(function(e,r){t[r]=e}),t},toOrderedMap:function(){return Zt(this.toKeyedSeq())},toOrderedSet:function(){return Je(u(this)?this.valueSeq():this)},toSet:function(){return Le(u(this)?this.valueSeq():this)},toSetSeq:function(){return new oe(this)},toSeq:function(){return s(this)?this.toIndexedSeq():u(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Ve(u(this)?this.valueSeq():this)},toList:function(){return Wt(u(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(t,e){ +return 0===this.size?t+e:t+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+e},concat:function(){var t=sr.call(arguments,0);return be(this,ye(this,t))},includes:function(t){return this.some(function(e){return X(e,t)})},entries:function(){return this.__iterator(Sr)},every:function(t,e){ft(this.size);var r=!0;return this.__iterate(function(n,i,o){return t.call(e,n,i,o)?void 0:(r=!1,!1)}),r},filter:function(t,e){return be(this,fe(this,t,e,!0))},find:function(t,e,r){var n=this.findEntry(t,e);return n?n[1]:r},findEntry:function(t,e){var r;return this.__iterate(function(n,i,o){return t.call(e,n,i,o)?(r=[i,n],!1):void 0}),r},findLastEntry:function(t,e){return this.toSeq().reverse().findEntry(t,e)},forEach:function(t,e){return ft(this.size),this.__iterate(e?t.bind(e):t)},join:function(t){ft(this.size),t=void 0!==t?""+t:",";var e="",r=!0;return this.__iterate(function(n){r?r=!1:e+=t,e+=null!==n&&void 0!==n?""+n:""}),e},keys:function(){return this.__iterator(gr)},map:function(t,e){return be(this,ae(this,t,e))},reduce:function(t,e,r){ft(this.size);var n,i;return arguments.length<2?i=!0:n=e,this.__iterate(function(e,o,u){i?(i=!1,n=e):n=t.call(r,n,e,o,u)}),n},reduceRight:function(t,e,r){var n=this.toKeyedSeq().reverse();return n.reduce.apply(n,arguments)},reverse:function(){return be(this,he(this,!0))},slice:function(t,e){return be(this,pe(this,t,e,!0))},some:function(t,e){return!this.every($e(t),e)},sort:function(t){return be(this,we(this,t))},values:function(){return this.__iterator(wr)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return void 0!==this.size?0===this.size:!this.some(function(){return!0})},count:function(t,e){return v(t?this.toSeq().filter(t,e):this)},countBy:function(t,e){return ce(this,t,e)},equals:function(t){return F(this,t)},entrySeq:function(){var t=this;if(t._cache)return new j(t._cache);var e=t.toSeq().map(Ze).toIndexedSeq();return e.fromEntrySeq=function(){return t.toSeq()},e},filterNot:function(t,e){return this.filter($e(t),e)},findLast:function(t,e,r){return this.toKeyedSeq().reverse().find(t,e,r); +},first:function(){return this.find(y)},flatMap:function(t,e){return be(this,me(this,t,e))},flatten:function(t){return be(this,de(this,t,!0))},fromEntrySeq:function(){return new ue(this)},get:function(t,e){return this.find(function(e,r){return X(r,t)},void 0,e)},getIn:function(t,e){for(var r,n=this,i=ke(t);!(r=i.next()).done;){var o=r.value;if(n=n&&n.get?n.get(o,yr):yr,n===yr)return e}return n},groupBy:function(t,e){return _e(this,t,e)},has:function(t){return this.get(t,yr)!==yr},hasIn:function(t){return this.getIn(t,yr)!==yr},isSubset:function(t){return t="function"==typeof t.includes?t:e(t),this.every(function(e){return t.includes(e)})},isSuperset:function(t){return t="function"==typeof t.isSubset?t:e(t),t.isSubset(this)},keySeq:function(){return this.toSeq().map(Ge).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},max:function(t){return Se(this,t)},maxBy:function(t,e){return Se(this,e,t)},min:function(t){return Se(this,t?tr(t):nr)},minBy:function(t,e){return Se(this,e?tr(e):nr,t)},rest:function(){return this.slice(1)},skip:function(t){return this.slice(Math.max(0,t))},skipLast:function(t){return be(this,this.toSeq().reverse().skip(t).reverse())},skipWhile:function(t,e){return be(this,le(this,t,e,!0))},skipUntil:function(t,e){return this.skipWhile($e(t),e)},sortBy:function(t,e){return be(this,we(this,e,t))},take:function(t){return this.slice(0,Math.max(0,t))},takeLast:function(t){return be(this,this.toSeq().reverse().take(t).reverse())},takeWhile:function(t,e){return be(this,ve(this,t,e))},takeUntil:function(t,e){return this.takeWhile($e(t),e)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=ir(this))}});var sn=e.prototype;sn[ar]=!0,sn[br]=sn.values,sn.__toJS=sn.toArray,sn.__toStringMapper=er,sn.inspect=sn.toSource=function(){return""+this},sn.chain=sn.flatMap,sn.contains=sn.includes,function(){try{Object.defineProperty(sn,"length",{get:function(){if(!e.noLengthWarning){var t;try{throw Error()}catch(r){t=r.stack}if(-1===t.indexOf("_wrapObject"))return console&&console.warn&&console.warn("iterable.length has been deprecated, use iterable.size or iterable.count(). This warning will become a silent error in a future version. "+t), +this.size}}})}catch(t){}}(),Fe(r,{flip:function(){return be(this,se(this))},findKey:function(t,e){var r=this.findEntry(t,e);return r&&r[0]},findLastKey:function(t,e){return this.toSeq().reverse().findKey(t,e)},keyOf:function(t){return this.findKey(function(e){return X(e,t)})},lastKeyOf:function(t){return this.findLastKey(function(e){return X(e,t)})},mapEntries:function(t,e){var r=this,n=0;return be(this,this.toSeq().map(function(i,o){return t.call(e,[o,i],n++,r)}).fromEntrySeq())},mapKeys:function(t,e){var r=this;return be(this,this.toSeq().flip().map(function(n,i){return t.call(e,n,i,r)}).flip())}});var an=r.prototype;an[hr]=!0,an[br]=sn.entries,an.__toJS=sn.toObject,an.__toStringMapper=function(t,e){return JSON.stringify(e)+": "+er(t)},Fe(n,{toKeyedSeq:function(){return new ne(this,!1)},filter:function(t,e){return be(this,fe(this,t,e,!1))},findIndex:function(t,e){var r=this.findEntry(t,e);return r?r[0]:-1},indexOf:function(t){var e=this.toKeyedSeq().keyOf(t);return void 0===e?-1:e},lastIndexOf:function(t){var e=this.toKeyedSeq().reverse().keyOf(t);return void 0===e?-1:e},reverse:function(){return be(this,he(this,!1))},slice:function(t,e){return be(this,pe(this,t,e,!1))},splice:function(t,e){var r=arguments.length;if(e=Math.max(0|e,0),0===r||2===r&&!e)return this;t=m(t,0>t?this.count():this.size);var n=this.slice(0,t);return be(this,1===r?n:n.concat(p(arguments,2),this.slice(t+e)))},findLastIndex:function(t,e){var r=this.toKeyedSeq().findLastKey(t,e);return void 0===r?-1:r},first:function(){return this.get(0)},flatten:function(t){return be(this,de(this,t,!1))},get:function(t,e){return t=l(this,t),0>t||this.size===1/0||void 0!==this.size&&t>this.size?e:this.find(function(e,r){return r===t},void 0,e)},has:function(t){return t=l(this,t),t>=0&&(void 0!==this.size?this.size===1/0||this.size>t:-1!==this.indexOf(t))},interpose:function(t){return be(this,ge(this,t))},interleave:function(){var t=[this].concat(p(arguments)),e=Ie(this.toSeq(),k.of,t),r=e.flatten(!0);return e.size&&(r.size=e.size*t.length),be(this,r)},last:function(){ +return this.get(-1)},skipWhile:function(t,e){return be(this,le(this,t,e,!1))},zip:function(){var t=[this].concat(p(arguments));return be(this,Ie(this,rr,t))},zipWith:function(t){var e=p(arguments);return e[0]=this,be(this,Ie(this,t,e))}}),n.prototype[fr]=!0,n.prototype[cr]=!0,Fe(i,{get:function(t,e){return this.has(t)?t:e},includes:function(t){return this.has(t)},keySeq:function(){return this.valueSeq()}}),i.prototype.has=sn.includes,Fe(x,r.prototype),Fe(k,n.prototype),Fe(A,i.prototype),Fe(et,r.prototype),Fe(rt,n.prototype),Fe(nt,i.prototype);var hn={Iterable:e,Seq:O,Collection:tt,Map:ct,OrderedMap:Zt,List:Wt,Stack:Ve,Set:Le,OrderedSet:Je,Record:Ae,Range:$,Repeat:G,is:X,fromJS:H};return hn}); diff --git a/app/extensions/torrent/ext/l20n.min.js b/app/extensions/torrent/ext/l20n.min.js new file mode 100644 index 00000000000..0c16a3f1cd0 --- /dev/null +++ b/app/extensions/torrent/ext/l20n.min.js @@ -0,0 +1,3 @@ +// https://github.com/l20n/l20n.js/releases/tag/v3.5.0 +"use strict";function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}!function(){function a(a,b,c){this.name="L10nError",this.message=a,this.id=b,this.lang=c}function b(b,c){return new Promise(function(d,e){var f=new XMLHttpRequest;f.overrideMimeType&&f.overrideMimeType(b),f.open("GET",c,!0),"application/json"===b&&(f.responseType="json"),f.addEventListener("load",function(b){b.target.status===ga||0===b.target.status?d(b.target.response):e(new a("Not found: "+c))}),f.addEventListener("error",e),f.addEventListener("timeout",e);try{f.send(null)}catch(g){if("NS_ERROR_FILE_NOT_FOUND"!==g.name)throw g;e(new a("Not found: "+c))}})}function c(a,b){var c=b.code,d=b.src,e=b.ver,f=a.replace("{locale}",c),g=a.endsWith(".json")?"json":"text";return ha[d](c,e,f,g)}function d(a){for(var b=this,c=arguments.length,d=Array(c>1?c-1:0),e=1;c>e;e++)d[e-1]=arguments[e];var f=d.shift();a["*"]&&a["*"].slice().forEach(function(a){return a.apply(b,d)}),a[f]&&a[f].slice().forEach(function(a){return a.apply(b,d)})}function e(a,b,c){b in a||(a[b]=[]),a[b].push(c)}function f(a,b,c){var d=a[b],e=d.indexOf(c);-1!==e&&d.splice(e,1)}function g(a,b){Array.from(this.ctxs.keys()).forEach(function(c){return c.emit(a,b)})}function h(b,c,d,e){if("string"==typeof e)return[{},e];if(na.has(e))throw new a("Cyclic reference detected");na.add(e);var f=void 0;try{f=m({},b,c,d,e.value,e.index)}finally{na.delete(e)}return f}function i(b,c,d,e){if(ja.indexOf(e)>-1)return[{},b._getMacro(c,e)];if(d&&d.hasOwnProperty(e)){if("string"==typeof d[e]||"number"==typeof d[e]&&!isNaN(d[e]))return[{},d[e]];throw new a("Arg must be a string or a number: "+e)}if("__proto__"===e)throw new a("Illegal id: "+e);var f=b._getEntity(c,e);if(f)return h(b,c,d,f);throw new a("Unknown reference: "+e)}function j(b,c,d,e,f){var g=void 0,h=void 0;try{var j=i(c,d,e,f);g=j[0],h=j[1]}catch(k){return[{error:k},la+"{{ "+f+" }}"+ma]}if("number"==typeof h){var l=c._getNumberFormatter(d);return[g,l.format(h)]}if("string"==typeof h){if(h.length>=ka)throw new a("Too many characters in placeable ("+h.length+", max allowed is "+ka+")");return[g,la+h+ma]}return[{},la+"{{ "+f+" }}"+ma]}function k(a,b,c,d,e){return e.reduce(function(e,f){var g=e[0],h=e[1];if("string"==typeof f)return[g,h+f];var i=j(a,b,c,d,f.name),k=i[1];return[g,h+k]},[a,""])}function l(a,b,c,d,e){var f=void 0;f="call"===e[0].type&&"prop"===e[0].expr.type&&"cldr"===e[0].expr.expr.name?"plural":e[0].name;var g=i(a,b,c,f)[1];if("function"!=typeof g)return g;var h=e[0].args?i(a,b,c,e[0].args[0].name)[1]:void 0;if("plural"===f){if(0===h&&"zero"in d)return"zero";if(1===h&&"one"in d)return"one";if(2===h&&"two"in d)return"two"}return g(h)}function m(b,c,d,e,f,g){if(!f)return[b,f];if("string"==typeof f||"boolean"==typeof f||"number"==typeof f)return[b,f];if(Array.isArray(f))return k(b,c,d,e,f);if(g){var h=l(c,d,e,f,g);if(h in f)return m(b,c,d,e,f[h])}var i=f.__default||"other";if(i in f)return m(b,c,d,e,f[i]);throw new a("Unresolvable value")}function n(a,b){return-1!==b.indexOf(a)}function o(a,b,c){return typeof a==typeof b&&a>=b&&c>=a}function p(a){var b=oa[a.replace(/-.*$/,"")];return b in pa?pa[b]:function(){return"other"}}function q(b,c,d){var e=this,f=new Set;return b.forEach(function(a,b){if(!d||void 0===d[b]){var g=Array.isArray(a)?a[0]:a;f.add(g),d[b]=c===e._formatValue?g:{value:g,attrs:null}}}),this.emit("notfounderror",new a('"'+Array.from(f).join(", ")+'" not found in any language',f)),d}function r(a,b){if("string"==typeof a)return b(a);var c=Object.create(null);if(a.value&&(c.value=s(a.value,b)),a.index&&(c.index=a.index),a.attrs){c.attrs=Object.create(null);for(var d in a.attrs)c.attrs[d]=r(a.attrs[d],b)}return c}function s(a,b){if("string"==typeof a)return b(a);if(a.type)return a;for(var c=Array.isArray(a)?[]:Object.create(null),d=Object.keys(a),e=0,f=void 0;f=d[e];e++)c[f]=s(a[f],b);return c}function t(a,b){var c=null;return function(){if(c)return c;var d=/[a-zA-Z]/g,e=/[aeiouAEIOU]/g,f=/[^\W0-9_]+/g,g=/(%[EO]?\w|\{\s*.+?\s*\}|&[#\w]+;|<\s*.+?\s*>)/,h={"fr-x-psaccent":"ȦƁƇḒḖƑƓĦĪĴĶĿḾȠǾƤɊŘŞŦŬṼẆẊẎẐ[\\]^_`ȧƀƈḓḗƒɠħīĵķŀḿƞǿƥɋřşŧŭṽẇẋẏẑ","ar-x-psbidi":"∀ԐↃpƎɟפHIſӼ˥WNOԀÒᴚS⊥∩ɅMXʎZ[\\]ᵥ_,ɐqɔpǝɟƃɥıɾʞʅɯuodbɹsʇnʌʍxʎz"},i={"fr-x-psaccent":function(a){return a.replace(e,function(a){return a+a.toLowerCase()})},"ar-x-psbidi":function(a){return a.replace(f,function(a){return"‮"+a+"‬"})}},j=65,k=function(a,b){return b.replace(d,function(b){return a.charAt(b.charCodeAt(0)-j)})},l=function(b){return k(h[a],i[a](b))},m=function(a,b){if(!b)return b;var c=b.split(g),d=c.map(function(b){return g.test(b)?b:a(b)});return d.join("")};return c={name:l(b),process:function(a){return m(l,a)}}}}function u(a,b){return b.lang=a,b}function v(a,b,c){for(var d=void 0,e=0;eb[d]))return"extra"}return d in wa&&!(d in b)?"pseudo":"app"}function A(){return"loading"!==document.readyState?Promise.resolve():new Promise(function(a){document.addEventListener("readystatechange",function b(){document.removeEventListener("readystatechange",b),a()})})}function B(a){var b=a.split("-")[0];return["ar","he","fa","ps","ur"].indexOf(b)>=0?"rtl":"ltr"}function C(a){return Array.prototype.map.call(a.querySelectorAll('link[rel="localization"]'),function(a){return a.getAttribute("href")})}function D(a){for(var b=Object.create(null),c=null,d=null,e=Array.from(a.querySelectorAll('meta[name="availableLanguages"],meta[name="defaultLanguage"],meta[name="appVersion"]')),f=e,g=Array.isArray(f),h=0,f=g?f:f[Symbol.iterator]();;){var i;if(g){if(h>=f.length)break;i=f[h++]}else{if(h=f.next(),h.done)break;i=h.value}var j=i,k=j.getAttribute("name"),l=j.getAttribute("content").trim();switch(k){case"availableLanguages":b=E(b,l);break;case"defaultLanguage":var m=F(l),n=m[0],o=m[1];c=n,n in b||(b[n]=o);break;case"appVersion":d=l}}return{defaultLang:c,availableLangs:b,appVersion:d}}function E(a,b){return b.split(",").reduce(function(a,b){var c=F(b),d=c[0],e=c[1];return a[d]=e,a},a)}function F(a){var b=a.trim().split(":"),c=b[0],d=b[1];return[c,parseInt(d)]}function G(a,b){var c=b.value;if("string"==typeof c)if(za.test(c)){var d=a.ownerDocument.createElement("template");d.innerHTML=c,H(a,d.content)}else a.textContent=c;for(var e in b.attrs){var f=M(e);J({name:f},a)&&a.setAttribute(f,b.attrs[e])}}function H(a,b){for(var c=b.ownerDocument.createDocumentFragment(),d=void 0,e=void 0,f=void 0;f=b.childNodes[0];)if(b.removeChild(f),f.nodeType!==f.TEXT_NODE){var g=L(f),h=K(a,f,g);if(h)H(h,f),c.appendChild(h);else if(I(f)){var i=f.ownerDocument.createElement(f.nodeName);H(i,f),c.appendChild(i)}else c.appendChild(b.ownerDocument.createTextNode(f.textContent))}else c.appendChild(f);if(a.textContent="",a.appendChild(c),b.attributes)for(d=0,e;e=b.attributes[d];d++)J(e,a)&&a.setAttribute(e.name,e.value)}function I(a){return-1!==Aa.elements.indexOf(a.tagName.toLowerCase())}function J(a,b){var c=a.name.toLowerCase(),d=b.tagName.toLowerCase();if(-1!==Aa.attributes.global.indexOf(c))return!0;if(!Aa.attributes[d])return!1;if(-1!==Aa.attributes[d].indexOf(c))return!0;if("input"===d&&"value"===c){var e=b.type.toLowerCase();if("submit"===e||"button"===e||"reset"===e)return!0}return!1}function K(a,b,c){for(var d=0,e=0,f=void 0;f=a.children[e];e++)if(f.nodeType===f.ELEMENT_NODE&&f.tagName===b.tagName){if(d===c)return f;d++}return null}function L(a){for(var b=0,c=void 0;c=a.previousElementSibling;)c.tagName===a.tagName&&b++;return b}function M(a){return"ariaValueText"===a?"aria-valuetext":a.replace(/[A-Z]/g,function(a){return"-"+a.toLowerCase()}).replace(/^-/,"")}function N(a,b,c){a.setAttribute("data-l10n-id",b),c&&a.setAttribute("data-l10n-args",JSON.stringify(c))}function O(a){return{id:a.getAttribute("data-l10n-id"),args:JSON.parse(a.getAttribute("data-l10n-args"))}}function P(a){var b=Array.from(a.querySelectorAll("[data-l10n-id]"));return"function"==typeof a.hasAttribute&&a.hasAttribute("data-l10n-id")&&b.push(a),b}function Q(a,b){for(var c=new Set,d=b,e=Array.isArray(d),f=0,d=e?d:d[Symbol.iterator]();;){var g;if(e){if(f>=d.length)break;g=d[f++]}else{if(f=d.next(),f.done)break;g=f.value}var h=g;switch(h.type){case"attributes":c.add(h.target);break;case"childList":for(var i=h.addedNodes,j=Array.isArray(i),k=0,i=j?i:i[Symbol.iterator]();;){var l;if(j){if(k>=i.length)break;l=i[k++]}else{if(k=i.next(),k.done)break;l=k.value}var m=l;m.nodeType===m.ELEMENT_NODE&&(m.childElementCount?P(m).forEach(c.add.bind(c)):m.hasAttribute("data-l10n-id")&&c.add(m))}}}0!==c.size&&T(a,Array.from(c))}function R(a,b){return T(a,P(b))}function S(a,b){var c=b.map(function(a){var b=a.getAttribute("data-l10n-id"),c=a.getAttribute("data-l10n-args");return c?[b,JSON.parse(c.replace(Ba,function(a){return Ca[a]}))]:b});return a.formatEntities.apply(a,c)}function T(a,b){return S(a,b).then(function(c){return U(a,b,c)})}function U(a,b,c){Y(a,null,!0);for(var d=0;dd;d++)b[d]=arguments[d];return e.apply(void 0,[c].concat(b))},this.emit=function(){for(var a=arguments.length,b=Array(a),e=0;a>e;e++)b[e]=arguments[e];return d.apply(void 0,[c].concat(b))}}return a.prototype.method=function(a){for(var b,c=arguments.length,d=Array(c>1?c-1:0),e=1;c>e;e++)d[e-1]=arguments[e];return(b=this.remote)[a].apply(b,d)},a}(),ja=["plural"],ka=2500,la="⁨",ma="⁩",na=new WeakSet,oa={af:3,ak:4,am:4,ar:1,asa:3,az:0,be:11,bem:3,bez:3,bg:3,bh:4,bm:0,bn:3,bo:0,br:20,brx:3,bs:11,ca:3,cgg:3,chr:3,cs:12,cy:17,da:3,de:3,dv:3,dz:0,ee:3,el:3,en:3,eo:3,es:3,et:3,eu:3,fa:0,ff:5,fi:3,fil:4,fo:3,fr:5,fur:3,fy:3,ga:8,gd:24,gl:3,gsw:3,gu:3,guw:4,gv:23,ha:3,haw:3,he:2,hi:4,hr:11,hu:0,id:0,ig:0,ii:0,is:3,it:3,iu:7,ja:0,jmc:3,jv:0,ka:0,kab:5,kaj:3,kcg:3,kde:0,kea:0,kk:3,kl:3,km:0,kn:0,ko:0,ksb:3,ksh:21,ku:3,kw:7,lag:18,lb:3,lg:3,ln:4,lo:0,lt:10,lv:6,mas:3,mg:4,mk:16,ml:3,mn:3,mo:9,mr:3,ms:0,mt:15,my:0,nah:3,naq:7,nb:3,nd:3,ne:3,nl:3,nn:3,no:3,nr:3,nso:4,ny:3,nyn:3,om:3,or:3,pa:3,pap:3,pl:13,ps:3,pt:3,rm:3,ro:9,rof:3,ru:11,rwk:3,sah:0,saq:3,se:7,seh:3,ses:0,sg:0,sh:11,shi:19,sk:12,sl:14,sma:7,smi:7,smj:7,smn:7,sms:7,sn:3,so:3,sq:3,sr:11,ss:3,ssy:3,st:3,sv:3,sw:3,syr:3,ta:3,te:3,teo:3,th:0,ti:4,tig:3,tk:3,tl:4,tn:3,to:0,tr:0,ts:3,tzm:22,uk:11,ur:3,ve:3,vi:0,vun:3,wa:4,wae:3,wo:0,xh:3,xog:3,yo:0,zh:0,zu:3},pa={0:function(){return"other"},1:function(a){return o(a%100,3,10)?"few":0===a?"zero":o(a%100,11,99)?"many":2===a?"two":1===a?"one":"other"},2:function(a){return 0!==a&&a%10===0?"many":2===a?"two":1===a?"one":"other"},3:function(a){return 1===a?"one":"other"},4:function(a){return o(a,0,1)?"one":"other"},5:function(a){return o(a,0,2)&&2!==a?"one":"other"},6:function(a){return 0===a?"zero":a%10===1&&a%100!==11?"one":"other"},7:function(a){return 2===a?"two":1===a?"one":"other"},8:function(a){return o(a,3,6)?"few":o(a,7,10)?"many":2===a?"two":1===a?"one":"other"},9:function(a){return 0===a||1!==a&&o(a%100,1,19)?"few":1===a?"one":"other"},10:function(a){return o(a%10,2,9)&&!o(a%100,11,19)?"few":a%10!==1||o(a%100,11,19)?"other":"one"},11:function(a){return o(a%10,2,4)&&!o(a%100,12,14)?"few":a%10===0||o(a%10,5,9)||o(a%100,11,14)?"many":a%10===1&&a%100!==11?"one":"other"},12:function(a){return o(a,2,4)?"few":1===a?"one":"other"},13:function(a){return o(a%10,2,4)&&!o(a%100,12,14)?"few":1!==a&&o(a%10,0,1)||o(a%10,5,9)||o(a%100,12,14)?"many":1===a?"one":"other"},14:function(a){return o(a%100,3,4)?"few":a%100===2?"two":a%100===1?"one":"other"},15:function(a){return 0===a||o(a%100,2,10)?"few":o(a%100,11,19)?"many":1===a?"one":"other"},16:function(a){return a%10===1&&11!==a?"one":"other"},17:function(a){return 3===a?"few":0===a?"zero":6===a?"many":2===a?"two":1===a?"one":"other"},18:function(a){return 0===a?"zero":o(a,0,2)&&0!==a&&2!==a?"one":"other"},19:function(a){return o(a,2,10)?"few":o(a,0,1)?"one":"other"},20:function(a){return!o(a%10,3,4)&&a%10!==9||o(a%100,10,19)||o(a%100,70,79)||o(a%100,90,99)?a%1e6===0&&0!==a?"many":a%10!==2||n(a%100,[12,72,92])?a%10!==1||n(a%100,[11,71,91])?"other":"one":"two":"few"},21:function(a){return 0===a?"zero":1===a?"one":"other"},22:function(a){return o(a,0,1)||o(a,11,99)?"one":"other"},23:function(a){return o(a%10,1,2)||a%20===0?"one":"other"},24:function(a){return o(a,3,10)||o(a,13,19)?"few":n(a,[2,12])?"two":n(a,[1,11])?"one":"other"}},qa="undefined"!=typeof Intl?Intl:{NumberFormat:function(){return{format:function(a){return a}}}},ra=function(){function b(a,c,d){var e=this;_classCallCheck(this,b),this.langs=c,this.resIds=d,this.env=a,this.emit=function(b,c){return a.emit(b,c,e)}}return b.prototype._formatTuple=function(a,b,c,d,e){try{return h(this,a,b,c)}catch(f){return f.id=e?d+"::"+e:d,f.lang=a,this.emit("resolveerror",f),[{error:f},f.id]}},b.prototype._formatEntity=function(a,b,c,d){var e=this._formatTuple(a,b,c,d),f=e[1],g={value:f,attrs:null};if(c.attrs){g.attrs=Object.create(null);for(var h in c.attrs){var i=this._formatTuple(a,b,c.attrs[h],d,h),j=i[1];g.attrs[h]=j}}return g},b.prototype._formatValue=function(a,b,c,d){return this._formatTuple(a,b,c,d)[1]},b.prototype.fetch=function(){var a=this,b=arguments.length<=0||void 0===arguments[0]?this.langs:arguments[0];return 0===b.length?Promise.resolve(b):Promise.all(this.resIds.map(function(c){return a.env._getResource(b[0],c)})).then(function(){return b})},b.prototype._resolve=function(b,c,d,e){var f=this,g=b[0];if(!g)return q.call(this,c,d,e);var h=!1,i=c.map(function(b,c){if(e&&void 0!==e[c])return e[c];var i=Array.isArray(b)?b:[b,void 0],j=i[0],k=i[1],l=f._getEntity(g,j);return l?d.call(f,g,k,l,j):(f.emit("notfounderror",new a('"'+j+'" not found in '+g.code,j,g)),void(h=!0))});return h?this.fetch(b.slice(1)).then(function(a){return f._resolve(a,c,d,i)}):i},b.prototype.formatEntities=function(){for(var a=this,b=arguments.length,c=Array(b),d=0;b>d;d++)c[d]=arguments[d];return this.fetch().then(function(b){return a._resolve(b,c,a._formatEntity)})},b.prototype.formatValues=function(){for(var a=this,b=arguments.length,c=Array(b),d=0;b>d;d++)c[d]=arguments[d];return this.fetch().then(function(b){return a._resolve(b,c,a._formatValue)})},b.prototype._getEntity=function(b,c){for(var d=this.env.resCache,e=0,f=void 0;f=this.resIds[e];e++){var g=d.get(f+b.code+b.src);if(!(g instanceof a)&&c in g)return g[c]}return void 0},b.prototype._getNumberFormatter=function(a){if(this.env.numberFormatters||(this.env.numberFormatters=new Map),!this.env.numberFormatters.has(a)){var b=qa.NumberFormat(a);return this.env.numberFormatters.set(a,b),b}return this.env.numberFormatters.get(a)},b.prototype._getMacro=function(a,b){switch(b){case"plural":return p(a.code);default:return void 0}},b}(),sa=100,ta={patterns:null,entryIds:null,emit:null,init:function(){this.patterns={comment:/^\s*#|^\s*$/,entity:/^([^=\s]+)\s*=\s*(.*)$/,multiline:/[^\\]\\$/,index:/\{\[\s*(\w+)(?:\(([^\)]*)\))?\s*\]\}/i,unicode:/\\u([0-9a-fA-F]{1,4})/g,entries:/[^\r\n]+/g,controlChars:/\\([\\\n\r\t\b\f\{\}\"\'])/g,placeables:/\{\{\s*([^\s]*?)\s*\}\}/}},parse:function(a,b){this.patterns||this.init(),this.emit=a;var c={},d=b.match(this.patterns.entries);if(!d)return c;for(var e=0;e2)throw this.error('Error in ID: "'+d+'". Nested attributes are not supported.');var h=void 0;if(g.length>1){if(d=g[0],h=g[1],"$"===h[0])throw this.error('Attribute can\'t start with "$"')}else h=null;this.setEntityValue(d,h,e,this.unescapeString(b),c)},setEntityValue:function(a,b,c,d,e){var f=d.indexOf("{{")>-1?this.parseString(d):d,g="string"==typeof f,h=e,i="string"==typeof e[a];if(e[a]||!b&&!c&&g||(e[a]=Object.create(null),i=!1),b){if(i){var j=e[a];e[a]=Object.create(null),e[a].value=j}e[a].attrs||(e[a].attrs=Object.create(null)),e[a].attrs||g||(e[a].attrs[b]=Object.create(null)),h=e[a].attrs,a=b}if(c){if(i=!1,"string"==typeof h[a]){var j=h[a];h[a]=Object.create(null),h[a].index=this.parseIndex(j),h[a].value=Object.create(null)}h=h[a].value,a=c,g=!0}if(g){if(a in h)throw this.error("Duplicated id: "+a);h[a]=f}else h[a]||(h[a]=Object.create(null)),h[a].value=f},parseString:function(a){var b=a.split(this.patterns.placeables),c=[],d=b.length,e=(d-1)/2;if(e>=sa)throw this.error("Too many placeables ("+e+", max allowed is "+sa+")");for(var f=0;f"===c)throw this.error('Expected ">"');f=this.getAttributes()}else{var g=this.getRequiredWS();if(">"!==this._source[this._index]){if(!g)throw this.error('Expected ">"');f=this.getAttributes()}}if(++this._index,a in this.entries)throw this.error('Duplicate entry ID "'+a,"duplicateerror");f||b||"string"!=typeof e?this.entries[a]={value:e,attrs:f,index:b}:this.entries[a]=e},getValue:function(){var a=arguments.length<=0||void 0===arguments[0]?this._source[this._index]:arguments[0],b=arguments.length<=1||void 0===arguments[1]?!1:arguments[1],c=arguments.length<=2||void 0===arguments[2]?!0:arguments[2];switch(a){case"'":case'"':return this.getString(a,1);case"{":return this.getHash(b)}if(c)throw this.error("Unknown value type");return void 0},getWS:function(){for(var a=this._source.charCodeAt(this._index);32===a||10===a||9===a||13===a;)a=this._source.charCodeAt(++this._index)},getRequiredWS:function(){for(var a=this._index,b=this._source.charCodeAt(a);32===b||10===b||9===b||13===b;)b=this._source.charCodeAt(++this._index);return this._index!==a},getIdentifier:function(){var a=this._index,b=this._source.charCodeAt(this._index);if(!(b>=97&&122>=b||b>=65&&90>=b||95===b))throw this.error("Identifier has to start with [a-zA-Z_]");for(b=this._source.charCodeAt(++this._index);b>=97&&122>=b||b>=65&&90>=b||b>=48&&57>=b||95===b;)b=this._source.charCodeAt(++this._index);return this._source.slice(a,this._index)},getUnicodeChar:function(){for(var a=0;4>a;a++){var b=this._source.charCodeAt(++this._index);if(!(b>96&&103>b||b>64&&71>b||b>47&&58>b))throw this.error("Illegal unicode escape sequence")}return this._index++,String.fromCharCode(parseInt(this._source.slice(this._index-4,this._index),16))},stringRe:/"|'|{{|\\/g,getString:function(a,b){var c=[],d=0;this._index+=b;for(var e=this._index,f=e,g="";;){this.stringRe.lastIndex=this._index;var h=this.stringRe.exec(this._source);if(!h)throw this.error("Unclosed string literal");if('"'===h[0]||"'"===h[0]){if(h[0]!==a){this._index+=b;continue}this._index=h.index+b;break}if("{{"!==h[0]){if("\\"===h[0]){this._index=h.index+1;var i=this._source[this._index];if("u"===i)g+=this._source.slice(f,h.index)+this.getUnicodeChar();else if(i===a||"\\"===i)g+=this._source.slice(f,h.index)+i,this._index++;else{if(!this._source.startsWith("{{",this._index))throw this.error("Illegal escape sequence");g+=this._source.slice(f,h.index)+"{{",this._index+=2}f=this._index}}else{if(d>ua-1)throw this.error("Too many placeables, maximum allowed is "+ua);d++,(h.index>f||g.length>0)&&(c.push(g+this._source.slice(f,h.index)),g=""),this._index=h.index+2,this.getWS(),c.push(this.getExpression()),this.getWS(),this._index+=2,f=this._index}}return 0===c.length?g+this._source.slice(f,this._index-b):((this._index-b>f||g.length>0)&&c.push(g+this._source.slice(f,this._index-b)),c)},getAttributes:function(){for(var a=Object.create(null);;){this.getAttribute(a);var b=this.getRequiredWS(),c=this._source.charAt(this._index);if(">"===c)break;if(!b)throw this.error('Expected ">"')}return a},getAttribute:function(a){var b=this.getIdentifier(),c=void 0;if("["===this._source[this._index]&&(++this._index,this.getWS(),c=this.getItemList(this.getExpression,"]")),this.getWS(),":"!==this._source[this._index])throw this.error('Expected ":"');++this._index,this.getWS();var d=void 0!==c,e=this.getValue(void 0,d);if(b in a)throw this.error('Duplicate attribute "'+b,"duplicateerror");c||"string"!=typeof e?a[b]={value:e,index:c}:a[b]=e},getHash:function(a){var b=Object.create(null);++this._index,this.getWS();for(var c=void 0;;){var d=this.getHashItem(),e=d[0],f=d[1],g=d[2];if(b[e]=f,g){if(c)throw this.error("Default item redefinition forbidden");c=e}this.getWS();var h=","===this._source[this._index];if(h&&(++this._index,this.getWS()),"}"===this._source[this._index]){++this._index;break}if(!h)throw this.error('Expected "}"')}if(c)b.__default=c;else if(!a)throw this.error("Unresolvable Hash Value");return b},getHashItem:function(){var a=!1;"*"===this._source[this._index]&&(++this._index,a=!0);var b=this.getIdentifier();if(this.getWS(),":"!==this._source[this._index])throw this.error('Expected ":"');return++this._index,this.getWS(),[b,this.getValue(),a]},getComment:function(){this._index+=2;var a=this._index,b=this._source.indexOf("*/",a);if(-1===b)throw this.error("Comment without a closing tag");this._index=b+2},getExpression:function(){for(var a=this.getPrimaryExpression();;){var b=this._source[this._index];if("."===b||"["===b)++this._index,a=this.getPropertyExpression(a,"["===b);else{if("("!==b)break;++this._index,a=this.getCallExpression(a)}}return a},getPropertyExpression:function(a,b){var c=void 0;if(b){if(this.getWS(),c=this.getExpression(),this.getWS(),"]"!==this._source[this._index])throw this.error('Expected "]"');++this._index}else c=this.getIdentifier();return{type:"prop",expr:a,prop:c,cmpt:b}},getCallExpression:function(a){return this.getWS(),{type:"call",expr:a,args:this.getItemList(this.getExpression,")")}},getPrimaryExpression:function(){var a=this._source[this._index];switch(a){case"$":return++this._index,{type:"var",name:this.getIdentifier()};case"@":return++this._index,{type:"glob",name:this.getIdentifier()};default:return{type:"id",name:this.getIdentifier()}}},getItemList:function(a,b){var c=[],d=!1;for(this.getWS(),this._source[this._index]===b&&(++this._index,d=!0);!d;){c.push(a.call(this)),this.getWS();var e=this._source.charAt(this._index);switch(e){case",":++this._index,this.getWS();break;case b:++this._index,d=!0;break;default:throw this.error('Expected "," or "'+b+'"')}}return c},getJunkEntry:function(){var a=this._index,b=this._source.indexOf("<",a),c=this._source.indexOf("/*",a);-1===b&&(b=this._length),-1===c&&(c=this._length);var d=Math.min(b,c);this._index=d},error:function(b){var c=arguments.length<=1||void 0===arguments[1]?"parsererror":arguments[1],d=this._index,e=this._source.lastIndexOf("<",d-1),f=this._source.lastIndexOf(">",d-1);e=f>e?f+1:e;var g=this._source.slice(e,d+10),h=b+" at pos "+d+": `"+g+"`",i=new a(h);return this.emit&&this.emit(c,i),i}},wa=Object.defineProperties(Object.create(null),{"fr-x-psaccent":{enumerable:!0,get:t("fr-x-psaccent","Runtime Accented")},"ar-x-psbidi":{enumerable:!0,get:t("ar-x-psbidi","Runtime Bidi")}}),xa=function(){function a(b){_classCallCheck(this,a),this.fetchResource=b,this.resCache=new Map,this.resRefs=new Map,this.numberFormatters=null,this.parsers={properties:ta,l20n:va};var c={};this.emit=d.bind(this,c),this.addEventListener=e.bind(this,c),this.removeEventListener=f.bind(this,c)}return a.prototype.createContext=function(a,b){var c=this,d=new ra(this,a,b);return b.forEach(function(a){var b=c.resRefs.get(a)||0;c.resRefs.set(a,b+1)}),d},a.prototype.destroyContext=function(a){var b=this;a.resIds.forEach(function(a){var c=b.resRefs.get(a)||0;return c>1?b.resRefs.set(a,c-1):(b.resRefs.delete(a),void b.resCache.forEach(function(c,d){return d.startsWith(a)?b.resCache.delete(d):null}))})},a.prototype._parse=function(a,b,c){var d=this,e=this.parsers[a];if(!e)return c;var f=function(a,c){return d.emit(a,u(b,c))};return e.parse(f,c)},a.prototype._create=function(a,b){if("pseudo"!==a.src)return b;var c=Object.create(null);for(var d in b)c[d]=r(b[d],wa[a.code].process);return c},a.prototype._getResource=function(a,b){var c=this,d=this.resCache,e=b+a.code+a.src;if(d.has(e))return d.get(e);var f=b.substr(b.lastIndexOf(".")+1),g=function(b){var g=c._parse(f,a,b);d.set(e,c._create(a,g))},h=function(b){b.lang=a,c.emit("fetcherror",b),d.set(e,b)},i="pseudo"===a.src?{code:"en-US",src:"app",ver:a.ver}:a,j=this.fetchResource(b,i).then(g,h);return d.set(e,j),j},a}(),ya=function(){function a(b,c){_classCallCheck(this,a),this.broadcast=c,this.env=new xa(b),this.ctxs=new Map}return a.prototype.registerView=function(a,b,c,d,e){var f=w(c,d,[],e),g=f.langs;return this.ctxs.set(a,this.env.createContext(g,b)),g},a.prototype.unregisterView=function(a){return this.ctxs.delete(a),!0},a.prototype.formatEntities=function(a,b){var c;return(c=this.ctxs.get(a)).formatEntities.apply(c,b)},a.prototype.formatValues=function(a,b){var c;return(c=this.ctxs.get(a)).formatValues.apply(c,b)},a.prototype.changeLanguages=function(a,b,c,d){var e=this.ctxs.get(a),f=e.langs,g=w(b,c,f,d);return this.ctxs.set(a,this.env.createContext(g.langs,e.resIds)),g},a.prototype.requestLanguages=function(a){this.broadcast("languageschangerequest",a)},a.prototype.getName=function(a){return wa[a].name},a.prototype.processString=function(a,b){return wa[a].process(b)},a}();"function"!=typeof NodeList||NodeList.prototype[Symbol.iterator]||(NodeList.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator]),void 0===navigator.languages&&(navigator.languages=[navigator.language]);var za=/<|&#?\w+;/,Aa={elements:["a","em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","ruby","rt","rp","bdi","bdo","span","br","wbr"],attributes:{global:["title","aria-label","aria-valuetext","aria-moz-hint"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]}},Ba=/[&<>]/g,Ca={"&":"&","<":"<",">":">"},Da={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:["data-l10n-id","data-l10n-args"]},Ea=new WeakMap,Fa=new WeakMap,Ga=function(){function a(b,c){var d=this;_classCallCheck(this,a),this.pseudo={"fr-x-psaccent":$(this,"fr-x-psaccent"),"ar-x-psbidi":$(this,"ar-x-psbidi")};var e=A().then(function(){return _(d,b)});this._interactive=e.then(function(){return b}),this.ready=e.then(function(a){return ca(d,a)}),V(this),Fa.set(this,{doc:c,ready:!1}),b.on("languageschangerequest",function(a){return d.requestLanguages(a)})}return a.prototype.requestLanguages=function(a,b){var c=this,d=b?function(b){return b.method("requestLanguages",a)}:function(b){return aa(c,b,a)};return this._interactive.then(d)},a.prototype.handleEvent=function(){return this.requestLanguages(navigator.languages)},a.prototype.formatEntities=function(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return this._interactive.then(function(a){return a.method("formatEntities",a.id,b)})},a.prototype.formatValue=function(a,b){return this._interactive.then(function(c){return c.method("formatValues",c.id,[[a,b]])}).then(function(a){return a[0]})},a.prototype.formatValues=function(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return this._interactive.then(function(a){return a.method("formatValues",a.id,b)})},a.prototype.translateFragment=function(a){return R(this,a)},a.prototype.observeRoot=function(a){X(this,a)},a.prototype.disconnectRoot=function(a){Y(this,a)},a}();Ga.prototype.setAttributes=N,Ga.prototype.getAttributes=O;var Ha=new ya(c,g),Ia=new ia(Ha);document.l10n=new Ga(Ia,document),window.addEventListener("languagechange",document.l10n),document.addEventListener("additionallanguageschange",document.l10n); +}(); diff --git a/app/extensions/torrent/ext/polyfill.min.js b/app/extensions/torrent/ext/polyfill.min.js new file mode 100644 index 00000000000..c7af30af6ee --- /dev/null +++ b/app/extensions/torrent/ext/polyfill.min.js @@ -0,0 +1,2 @@ +!function e(t,n,r){function s(i,u){if(!n[i]){if(!t[i]){var c="function"==typeof require&&require;if(!u&&c)return c(i,!0);if(o)return o(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var f=n[i]={exports:{}};t[i][0].call(f.exports,function(n){var e=t[i][1][n];return s(e?e:n)},f,f.exports,e,t,n,r)}return n[i].exports}for(var o="function"==typeof require&&require,i=0;i2?s[2]:void 0,l=Math.min((void 0===f?u:o(f,u))-a,u-c),h=1;for(c>a&&a+l>c&&(h=-1,a+=l-1,c+=l-1);l-- >0;)a in e?e[c]=e[a]:delete e[c],c+=h,a+=h;return e}},{77:77,80:80,81:81}],7:[function(t,n,e){"use strict";var r=t(81),o=t(77),i=t(80);n.exports=[].fill||function fill(t){for(var n=r(this,!0),e=i(n.length),u=arguments,c=u.length,a=o(c>1?u[1]:void 0,e),s=c>2?u[2]:void 0,f=void 0===s?e:o(s,e);f>a;)n[a++]=t;return n}},{77:77,80:80,81:81}],8:[function(t,n,e){var r=t(79),o=t(80),i=t(77);n.exports=function(t){return function(n,e,u){var c,a=r(n),s=o(a.length),f=i(u,s);if(t&&e!=e){for(;s>f;)if(c=a[f++],c!=c)return!0}else for(;s>f;f++)if((t||f in a)&&a[f]===e)return t||f;return!t&&-1}}},{77:77,79:79,80:80}],9:[function(t,n,e){var r=t(18),o=t(35),i=t(81),u=t(80),c=t(10);n.exports=function(t){var n=1==t,e=2==t,a=3==t,s=4==t,f=6==t,l=5==t||f;return function(h,p,v){for(var g,y,d=i(h),m=o(d),x=r(p,v,3),S=u(m.length),b=0,w=n?c(h,S):e?c(h,0):void 0;S>b;b++)if((l||b in m)&&(g=m[b],y=x(g,b,d),t))if(n)w[b]=y;else if(y)switch(t){case 3:return!0;case 5:return g;case 6:return b;case 2:w.push(g)}else if(s)return!1;return f?-1:a||s?s:w}}},{10:10,18:18,35:35,80:80,81:81}],10:[function(t,n,e){var r=t(39),o=t(37),i=t(84)("species");n.exports=function(t,n){var e;return o(t)&&(e=t.constructor,"function"!=typeof e||e!==Array&&!o(e.prototype)||(e=void 0),r(e)&&(e=e[i],null===e&&(e=void 0))),new(void 0===e?Array:e)(n)}},{37:37,39:39,84:84}],11:[function(t,n,e){var r=t(12),o=t(84)("toStringTag"),i="Arguments"==r(function(){return arguments}());n.exports=function(t){var n,e,u;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(e=(n=Object(t))[o])?e:i?r(n):"Object"==(u=r(n))&&"function"==typeof n.callee?"Arguments":u}},{12:12,84:84}],12:[function(t,n,e){var r={}.toString;n.exports=function(t){return r.call(t).slice(8,-1)}},{}],13:[function(t,n,e){"use strict";var r=t(47),o=t(32),i=t(54),u=t(18),c=t(70),a=t(20),s=t(28),f=t(43),l=t(45),h=t(83)("id"),p=t(31),v=t(39),g=t(66),y=t(21),d=Object.isExtensible||v,m=y?"_s":"size",x=0,S=function(t,n){if(!v(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!p(t,h)){if(!d(t))return"F";if(!n)return"E";o(t,h,++x)}return"O"+t[h]},b=function(t,n){var e,r=S(n);if("F"!==r)return t._i[r];for(e=t._f;e;e=e.n)if(e.k==n)return e};n.exports={getConstructor:function(t,n,e,o){var f=t(function(t,i){c(t,f,n),t._i=r.create(null),t._f=void 0,t._l=void 0,t[m]=0,void 0!=i&&s(i,e,t[o],t)});return i(f.prototype,{clear:function clear(){for(var t=this,n=t._i,e=t._f;e;e=e.n)e.r=!0,e.p&&(e.p=e.p.n=void 0),delete n[e.i];t._f=t._l=void 0,t[m]=0},"delete":function(t){var n=this,e=b(n,t);if(e){var r=e.n,o=e.p;delete n._i[e.i],e.r=!0,o&&(o.n=r),r&&(r.p=o),n._f==e&&(n._f=r),n._l==e&&(n._l=o),n[m]--}return!!e},forEach:function forEach(t){for(var n,e=u(t,arguments.length>1?arguments[1]:void 0,3);n=n?n.n:this._f;)for(e(n.v,n.k,this);n&&n.r;)n=n.p},has:function has(t){return!!b(this,t)}}),y&&r.setDesc(f.prototype,"size",{get:function(){return a(this[m])}}),f},def:function(t,n,e){var r,o,i=b(t,n);return i?i.v=e:(t._l=i={i:o=S(n,!0),k:n,v:e,p:r=t._l,n:void 0,r:!1},t._f||(t._f=i),r&&(r.n=i),t[m]++,"F"!==o&&(t._i[o]=i)),t},getEntry:b,setStrong:function(t,n,e){f(t,n,function(t,n){this._t=t,this._k=n,this._l=void 0},function(){for(var t=this,n=t._k,e=t._l;e&&e.r;)e=e.p;return t._t&&(t._l=e=e?e.n:t._t._f)?"keys"==n?l(0,e.k):"values"==n?l(0,e.v):l(0,[e.k,e.v]):(t._t=void 0,l(1))},e?"entries":"values",!e,!0),g(n)}}},{18:18,20:20,21:21,28:28,31:31,32:32,39:39,43:43,45:45,47:47,54:54,66:66,70:70,83:83}],14:[function(t,n,e){var r=t(28),o=t(11);n.exports=function(t){return function toJSON(){if(o(this)!=t)throw TypeError(t+"#toJSON isn't generic");var n=[];return r(this,!1,n.push,n),n}}},{11:11,28:28}],15:[function(t,n,e){"use strict";var r=t(32),o=t(54),i=t(5),u=t(70),c=t(28),a=t(9),s=t(83)("weak"),f=t(39),l=t(31),h=Object.isExtensible||f,p=a(5),v=a(6),g=0,y=function(t){return t._l||(t._l=new d)},d=function(){this.a=[]},m=function(t,n){return p(t.a,function(t){return t[0]===n})};d.prototype={get:function(t){var n=m(this,t);return n?n[1]:void 0},has:function(t){return!!m(this,t)},set:function(t,n){var e=m(this,t);e?e[1]=n:this.a.push([t,n])},"delete":function(t){var n=v(this.a,function(n){return n[0]===t});return~n&&this.a.splice(n,1),!!~n}},n.exports={getConstructor:function(t,n,e,r){var i=t(function(t,o){u(t,i,n),t._i=g++,t._l=void 0,void 0!=o&&c(o,e,t[r],t)});return o(i.prototype,{"delete":function(t){return f(t)?h(t)?l(t,s)&&l(t[s],this._i)&&delete t[s][this._i]:y(this)["delete"](t):!1},has:function has(t){return f(t)?h(t)?l(t,s)&&l(t[s],this._i):y(this).has(t):!1}}),i},def:function(t,n,e){return h(i(n))?(l(n,s)||r(n,s,{}),n[s][t._i]=e):y(t).set(n,e),t},frozenStore:y,WEAK:s}},{28:28,31:31,32:32,39:39,5:5,54:54,70:70,83:83,9:9}],16:[function(t,n,e){"use strict";var r=t(30),o=t(19),i=t(62),u=t(54),c=t(28),a=t(70),s=t(39),f=t(25),l=t(44),h=t(67);n.exports=function(t,n,e,p,v,g){var y=r[t],d=y,m=v?"set":"add",x=d&&d.prototype,S={},b=function(t){var n=x[t];i(x,t,"delete"==t?function(t){return g&&!s(t)?!1:n.call(this,0===t?0:t)}:"has"==t?function has(t){return g&&!s(t)?!1:n.call(this,0===t?0:t)}:"get"==t?function get(t){return g&&!s(t)?void 0:n.call(this,0===t?0:t)}:"add"==t?function add(t){return n.call(this,0===t?0:t),this}:function set(t,e){return n.call(this,0===t?0:t,e),this})};if("function"==typeof d&&(g||x.forEach&&!f(function(){(new d).entries().next()}))){var w,E=new d,O=E[m](g?{}:-0,1)!=E,P=f(function(){E.has(1)}),_=l(function(t){new d(t)});_||(d=n(function(n,e){a(n,d,t);var r=new y;return void 0!=e&&c(e,v,r[m],r),r}),d.prototype=x,x.constructor=d),g||E.forEach(function(t,n){w=1/n===-(1/0)}),(P||w)&&(b("delete"),b("has"),v&&b("get")),(w||O)&&b(m),g&&x.clear&&delete x.clear}else d=p.getConstructor(n,t,v,m),u(d.prototype,e);return h(d,t),S[t]=d,o(o.G+o.W+o.F*(d!=y),S),g||p.setStrong(d,t,v),d}},{19:19,25:25,28:28,30:30,39:39,44:44,54:54,62:62,67:67,70:70}],17:[function(t,n,e){var r=n.exports={version:"1.2.5"};"number"==typeof __e&&(__e=r)},{}],18:[function(t,n,e){var r=t(3);n.exports=function(t,n,e){if(r(t),void 0===n)return t;switch(e){case 1:return function(e){return t.call(n,e)};case 2:return function(e,r){return t.call(n,e,r)};case 3:return function(e,r,o){return t.call(n,e,r,o)}}return function(){return t.apply(n,arguments)}}},{3:3}],19:[function(t,n,e){var r=t(30),o=t(17),i=t(32),u=t(62),c="prototype",a=function(t,n){return function(){return t.apply(n,arguments)}},s=function(t,n,e){var f,l,h,p,v=t&s.G,g=t&s.P,y=v?r:t&s.S?r[n]||(r[n]={}):(r[n]||{})[c],d=v?o:o[n]||(o[n]={});v&&(e=n);for(f in e)l=!(t&s.F)&&y&&f in y,h=(l?y:e)[f],p=t&s.B&&l?a(h,r):g&&"function"==typeof h?a(Function.call,h):h,y&&!l&&u(y,f,h),d[f]!=h&&i(d,f,p),g&&((d[c]||(d[c]={}))[f]=h)};r.core=o,s.F=1,s.G=2,s.S=4,s.P=8,s.B=16,s.W=32,n.exports=s},{17:17,30:30,32:32,62:62}],20:[function(t,n,e){n.exports=function(t){if(void 0==t)throw TypeError("Can't call method on "+t);return t}},{}],21:[function(t,n,e){n.exports=!t(25)(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},{25:25}],22:[function(t,n,e){var r=t(39),o=t(30).document,i=r(o)&&r(o.createElement);n.exports=function(t){return i?o.createElement(t):{}}},{30:30,39:39}],23:[function(t,n,e){var r=t(47);n.exports=function(t){var n=r.getKeys(t),e=r.getSymbols;if(e)for(var o,i=e(t),u=r.isEnum,c=0;i.length>c;)u.call(t,o=i[c++])&&n.push(o);return n}},{47:47}],24:[function(t,n,e){var r=t(84)("match");n.exports=function(t){var n=/./;try{"/./"[t](n)}catch(e){try{return n[r]=!1,!"/./"[t](n)}catch(o){}}return!0}},{84:84}],25:[function(t,n,e){n.exports=function(t){try{return!!t()}catch(n){return!0}}},{}],26:[function(t,n,e){"use strict";var r=t(32),o=t(62),i=t(25),u=t(20),c=t(84);n.exports=function(t,n,e){var a=c(t),s=""[t];i(function(){var n={};return n[a]=function(){return 7},7!=""[t](n)})&&(o(String.prototype,t,e(u,a,s)),r(RegExp.prototype,a,2==n?function(t,n){return s.call(t,this,n)}:function(t){return s.call(t,this)}))}},{20:20,25:25,32:32,62:62,84:84}],27:[function(t,n,e){"use strict";var r=t(5);n.exports=function(){var t=r(this),n="";return t.global&&(n+="g"),t.ignoreCase&&(n+="i"),t.multiline&&(n+="m"),t.unicode&&(n+="u"),t.sticky&&(n+="y"),n}},{5:5}],28:[function(t,n,e){var r=t(18),o=t(41),i=t(36),u=t(5),c=t(80),a=t(85);n.exports=function(t,n,e,s){var f,l,h,p=a(t),v=r(e,s,n?2:1),g=0;if("function"!=typeof p)throw TypeError(t+" is not iterable!");if(i(p))for(f=c(t.length);f>g;g++)n?v(u(l=t[g])[0],l[1]):v(t[g]);else for(h=p.call(t);!(l=h.next()).done;)o(h,v,l.value,n)}},{18:18,36:36,41:41,5:5,80:80,85:85}],29:[function(t,n,e){var r={}.toString,o=t(79),i=t(47).getNames,u="object"==typeof window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],c=function(t){try{return i(t)}catch(n){return u.slice()}};n.exports.get=function getOwnPropertyNames(t){return u&&"[object Window]"==r.call(t)?c(t):i(o(t))}},{47:47,79:79}],30:[function(t,n,e){var r=n.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},{}],31:[function(t,n,e){var r={}.hasOwnProperty;n.exports=function(t,n){return r.call(t,n)}},{}],32:[function(t,n,e){var r=t(47),o=t(61);n.exports=t(21)?function(t,n,e){return r.setDesc(t,n,o(1,e))}:function(t,n,e){return t[n]=e,t}},{21:21,47:47,61:61}],33:[function(t,n,e){n.exports=t(30).document&&document.documentElement},{30:30}],34:[function(t,n,e){n.exports=function(t,n,e){var r=void 0===e;switch(n.length){case 0:return r?t():t.call(e);case 1:return r?t(n[0]):t.call(e,n[0]);case 2:return r?t(n[0],n[1]):t.call(e,n[0],n[1]);case 3:return r?t(n[0],n[1],n[2]):t.call(e,n[0],n[1],n[2]);case 4:return r?t(n[0],n[1],n[2],n[3]):t.call(e,n[0],n[1],n[2],n[3])}return t.apply(e,n)}},{}],35:[function(t,n,e){var r=t(12);n.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},{12:12}],36:[function(t,n,e){var r=t(46),o=t(84)("iterator"),i=Array.prototype;n.exports=function(t){return(r.Array||i[o])===t}},{46:46,84:84}],37:[function(t,n,e){var r=t(12);n.exports=Array.isArray||function(t){return"Array"==r(t)}},{12:12}],38:[function(t,n,e){var r=t(39),o=Math.floor;n.exports=function isInteger(t){return!r(t)&&isFinite(t)&&o(t)===t}},{39:39}],39:[function(t,n,e){n.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},{}],40:[function(t,n,e){var r=t(39),o=t(12),i=t(84)("match");n.exports=function(t){var n;return r(t)&&(void 0!==(n=t[i])?!!n:"RegExp"==o(t))}},{12:12,39:39,84:84}],41:[function(t,n,e){var r=t(5);n.exports=function(t,n,e,o){try{return o?n(r(e)[0],e[1]):n(e)}catch(i){var u=t["return"];throw void 0!==u&&r(u.call(t)),i}}},{5:5}],42:[function(t,n,e){"use strict";var r=t(47),o=t(61),i=t(67),u={};t(32)(u,t(84)("iterator"),function(){return this}),n.exports=function(t,n,e){t.prototype=r.create(u,{next:o(1,e)}),i(t,n+" Iterator")}},{32:32,47:47,61:61,67:67,84:84}],43:[function(t,n,e){"use strict";var r=t(49),o=t(19),i=t(62),u=t(32),c=t(31),a=t(84)("iterator"),s=t(46),f=t(42),l=t(67),h=t(47).getProto,p=!([].keys&&"next"in[].keys()),v="@@iterator",g="keys",y="values",d=function(){return this};n.exports=function(t,n,e,m,x,S,b){f(e,n,m);var w,E,O=function(t){if(!p&&t in _)return _[t];switch(t){case g:return function keys(){return new e(this,t)};case y:return function values(){return new e(this,t)}}return function entries(){return new e(this,t)}},P=n+" Iterator",_=t.prototype,M=_[a]||_[v]||x&&_[x],F=M||O(x);if(M){var A=h(F.call(new t));l(A,P,!0),!r&&c(_,v)&&u(A,a,d)}if(r&&!b||!p&&a in _||u(_,a,F),s[n]=F,s[P]=d,x)if(w={values:x==y?F:O(y),keys:S?F:O(g),entries:x!=y?F:O("entries")},b)for(E in w)E in _||i(_,E,w[E]);else o(o.P+o.F*p,n,w);return w}},{19:19,31:31,32:32,42:42,46:46,47:47,49:49,62:62,67:67,84:84}],44:[function(t,n,e){var r=t(84)("iterator"),o=!1;try{var i=[7][r]();i["return"]=function(){o=!0},Array.from(i,function(){throw 2})}catch(u){}n.exports=function(t,n){if(!n&&!o)return!1;var e=!1;try{var i=[7],u=i[r]();u.next=function(){e=!0},i[r]=function(){return u},t(i)}catch(c){}return e}},{84:84}],45:[function(t,n,e){n.exports=function(t,n){return{value:n,done:!!t}}},{}],46:[function(t,n,e){n.exports={}},{}],47:[function(t,n,e){var r=Object;n.exports={create:r.create,getProto:r.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:r.getOwnPropertyDescriptor,setDesc:r.defineProperty,setDescs:r.defineProperties,getKeys:r.keys,getNames:r.getOwnPropertyNames,getSymbols:r.getOwnPropertySymbols,each:[].forEach}},{}],48:[function(t,n,e){var r=t(47),o=t(79);n.exports=function(t,n){for(var e,i=o(t),u=r.getKeys(i),c=u.length,a=0;c>a;)if(i[e=u[a++]]===n)return e}},{47:47,79:79}],49:[function(t,n,e){n.exports=!1},{}],50:[function(t,n,e){n.exports=Math.expm1||function expm1(t){return 0==(t=+t)?t:t>-1e-6&&1e-6>t?t+t*t/2:Math.exp(t)-1}},{}],51:[function(t,n,e){n.exports=Math.log1p||function log1p(t){return(t=+t)>-1e-8&&1e-8>t?t-t*t/2:Math.log(1+t)}},{}],52:[function(t,n,e){n.exports=Math.sign||function sign(t){return 0==(t=+t)||t!=t?t:0>t?-1:1}},{}],53:[function(t,n,e){var r,o,i,u=t(30),c=t(76).set,a=u.MutationObserver||u.WebKitMutationObserver,s=u.process,f="process"==t(12)(s),l=function(){var t,n;for(f&&(t=s.domain)&&(s.domain=null,t.exit());r;)n=r.domain,n&&n.enter(),r.fn.call(),n&&n.exit(),r=r.next;o=void 0,t&&t.enter()};if(f)i=function(){s.nextTick(l)};else if(a){var h=1,p=document.createTextNode("");new a(l).observe(p,{characterData:!0}),i=function(){p.data=h=-h}}else i=function(){c.call(u,l)};n.exports=function asap(t){var n={fn:t,next:void 0,domain:f&&s.domain};o&&(o.next=n),r||(r=n,i()),o=n}},{12:12,30:30,76:76}],54:[function(t,n,e){var r=t(62);n.exports=function(t,n){for(var e in n)r(t,e,n[e]);return t}},{62:62}],55:[function(t,n,e){var r=t(47),o=t(81),i=t(35);n.exports=t(25)(function(){var t=Object.assign,n={},e={},r=Symbol(),o="abcdefghijklmnopqrst";return n[r]=7,o.split("").forEach(function(t){e[t]=t}),7!=t({},n)[r]||Object.keys(t({},e)).join("")!=o})?function assign(t,n){for(var e=o(t),u=arguments,c=u.length,a=1,s=r.getKeys,f=r.getSymbols,l=r.isEnum;c>a;)for(var h,p=i(u[a++]),v=f?s(p).concat(f(p)):s(p),g=v.length,y=0;g>y;)l.call(p,h=v[y++])&&(e[h]=p[h]);return e}:Object.assign},{25:25,35:35,47:47,81:81}],56:[function(t,n,e){var r=(t(19),t(17)),o=t(25);n.exports=function(n,e){var i=t(19),u=(r.Object||{})[n]||Object[n],c={};c[n]=e(u),i(i.S+i.F*o(function(){u(1)}),"Object",c)}},{17:17,19:19,25:25}],57:[function(t,n,e){var r=t(47),o=t(79),i=r.isEnum;n.exports=function(t){return function(n){for(var e,u=o(n),c=r.getKeys(u),a=c.length,s=0,f=[];a>s;)i.call(u,e=c[s++])&&f.push(t?[e,u[e]]:u[e]);return f}}},{47:47,79:79}],58:[function(t,n,e){var r=t(47),o=t(5),i=t(30).Reflect;n.exports=i&&i.ownKeys||function ownKeys(t){var n=r.getNames(o(t)),e=r.getSymbols;return e?n.concat(e(t)):n}},{30:30,47:47,5:5}],59:[function(t,n,e){"use strict";var r=t(60),o=t(34),i=t(3);n.exports=function(){for(var t=i(this),n=arguments.length,e=Array(n),u=0,c=r._,a=!1;n>u;)(e[u]=arguments[u++])===c&&(a=!0);return function(){var r,i=this,u=arguments,s=u.length,f=0,l=0;if(!a&&!s)return o(t,e,i);if(r=e.slice(),a)for(;n>f;f++)r[f]===c&&(r[f]=u[l++]);for(;s>l;)r.push(u[l++]);return o(t,r,i)}}},{3:3,34:34,60:60}],60:[function(t,n,e){n.exports=t(30)},{30:30}],61:[function(t,n,e){n.exports=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}}},{}],62:[function(t,n,e){var r=t(30),o=t(32),i=t(83)("src"),u="toString",c=Function[u],a=(""+c).split(u);t(17).inspectSource=function(t){return c.call(t)},(n.exports=function(t,n,e,u){"function"==typeof e&&(e.hasOwnProperty(i)||o(e,i,t[n]?""+t[n]:a.join(String(n))),e.hasOwnProperty("name")||o(e,"name",n)),t===r?t[n]=e:(u||delete t[n],o(t,n,e))})(Function.prototype,u,function toString(){return"function"==typeof this&&this[i]||c.call(this)})},{17:17,30:30,32:32,83:83}],63:[function(t,n,e){n.exports=function(t,n){var e=n===Object(n)?function(t){return n[t]}:n;return function(n){return String(n).replace(t,e)}}},{}],64:[function(t,n,e){n.exports=Object.is||function is(t,n){return t===n?0!==t||1/t===1/n:t!=t&&n!=n}},{}],65:[function(t,n,e){var r=t(47).getDesc,o=t(39),i=t(5),u=function(t,n){if(i(t),!o(n)&&null!==n)throw TypeError(n+": can't set as prototype!")};n.exports={set:Object.setPrototypeOf||("__proto__"in{}?function(n,e,o){try{o=t(18)(Function.call,r(Object.prototype,"__proto__").set,2),o(n,[]),e=!(n instanceof Array)}catch(i){e=!0}return function setPrototypeOf(t,n){return u(t,n),e?t.__proto__=n:o(t,n),t}}({},!1):void 0),check:u}},{18:18,39:39,47:47,5:5}],66:[function(t,n,e){"use strict";var r=t(30),o=t(47),i=t(21),u=t(84)("species");n.exports=function(t){var n=r[t];i&&n&&!n[u]&&o.setDesc(n,u,{configurable:!0,get:function(){return this}})}},{21:21,30:30,47:47,84:84}],67:[function(t,n,e){var r=t(47).setDesc,o=t(31),i=t(84)("toStringTag");n.exports=function(t,n,e){t&&!o(t=e?t:t.prototype,i)&&r(t,i,{configurable:!0,value:n})}},{31:31,47:47,84:84}],68:[function(t,n,e){var r=t(30),o="__core-js_shared__",i=r[o]||(r[o]={});n.exports=function(t){return i[t]||(i[t]={})}},{30:30}],69:[function(t,n,e){var r=t(5),o=t(3),i=t(84)("species");n.exports=function(t,n){var e,u=r(t).constructor;return void 0===u||void 0==(e=r(u)[i])?n:o(e)}},{3:3,5:5,84:84}],70:[function(t,n,e){n.exports=function(t,n,e){if(!(t instanceof n))throw TypeError(e+": use the 'new' operator!");return t}},{}],71:[function(t,n,e){var r=t(78),o=t(20);n.exports=function(t){return function(n,e){var i,u,c=String(o(n)),a=r(e),s=c.length;return 0>a||a>=s?t?"":void 0:(i=c.charCodeAt(a),55296>i||i>56319||a+1===s||(u=c.charCodeAt(a+1))<56320||u>57343?t?c.charAt(a):i:t?c.slice(a,a+2):(i-55296<<10)+(u-56320)+65536)}}},{20:20,78:78}],72:[function(t,n,e){var r=t(40),o=t(20);n.exports=function(t,n,e){if(r(n))throw TypeError("String#"+e+" doesn't accept regex!");return String(o(t))}},{20:20,40:40}],73:[function(t,n,e){var r=t(80),o=t(74),i=t(20);n.exports=function(t,n,e,u){var c=String(i(t)),a=c.length,s=void 0===e?" ":String(e),f=r(n);if(a>=f)return c;""==s&&(s=" ");var l=f-a,h=o.call(s,Math.ceil(l/s.length));return h.length>l&&(h=h.slice(0,l)),u?h+c:c+h}},{20:20,74:74,80:80}],74:[function(t,n,e){"use strict";var r=t(78),o=t(20);n.exports=function repeat(t){var n=String(o(this)),e="",i=r(t);if(0>i||i==1/0)throw RangeError("Count can't be negative");for(;i>0;(i>>>=1)&&(n+=n))1&i&&(e+=n);return e}},{20:20,78:78}],75:[function(t,n,e){var r=t(19),o=t(20),i=t(25),u=" \n\x0B\f\r   ᠎              \u2028\u2029\ufeff",c="["+u+"]",a="​…",s=RegExp("^"+c+c+"*"),f=RegExp(c+c+"*$"),l=function(t,n){var e={};e[t]=n(h),r(r.P+r.F*i(function(){return!!u[t]()||a[t]()!=a}),"String",e)},h=l.trim=function(t,n){return t=String(o(t)),1&n&&(t=t.replace(s,"")),2&n&&(t=t.replace(f,"")),t};n.exports=l},{19:19,20:20,25:25}],76:[function(t,n,e){"use strict";var r,o,i,u=t(18),c=t(34),a=t(33),s=t(22),f=t(30),l=f.process,h=f.setImmediate,p=f.clearImmediate,v=f.MessageChannel,g=0,y={},d="onreadystatechange",m=function(){var t=+this;if(y.hasOwnProperty(t)){var n=y[t];delete y[t],n()}},x=function(t){m.call(t.data)};h&&p||(h=function setImmediate(t){for(var n=[],e=1;arguments.length>e;)n.push(arguments[e++]);return y[++g]=function(){c("function"==typeof t?t:Function(t),n)},r(g),g},p=function clearImmediate(t){delete y[t]},"process"==t(12)(l)?r=function(t){l.nextTick(u(m,t,1))}:v?(o=new v,i=o.port2,o.port1.onmessage=x,r=u(i.postMessage,i,1)):f.addEventListener&&"function"==typeof postMessage&&!f.importScripts?(r=function(t){f.postMessage(t+"","*")},f.addEventListener("message",x,!1)):r=d in s("script")?function(t){a.appendChild(s("script"))[d]=function(){a.removeChild(this),m.call(t)}}:function(t){setTimeout(u(m,t,1),0)}),n.exports={set:h,clear:p}},{12:12,18:18,22:22,30:30,33:33,34:34}],77:[function(t,n,e){var r=t(78),o=Math.max,i=Math.min;n.exports=function(t,n){return t=r(t),0>t?o(t+n,0):i(t,n)}},{78:78}],78:[function(t,n,e){var r=Math.ceil,o=Math.floor;n.exports=function(t){return isNaN(t=+t)?0:(t>0?o:r)(t)}},{}],79:[function(t,n,e){var r=t(35),o=t(20);n.exports=function(t){return r(o(t))}},{20:20,35:35}],80:[function(t,n,e){var r=t(78),o=Math.min;n.exports=function(t){return t>0?o(r(t),9007199254740991):0}},{78:78}],81:[function(t,n,e){var r=t(20);n.exports=function(t){return Object(r(t))}},{20:20}],82:[function(t,n,e){var r=t(39);n.exports=function(t,n){if(!r(t))return t;var e,o;if(n&&"function"==typeof(e=t.toString)&&!r(o=e.call(t)))return o;if("function"==typeof(e=t.valueOf)&&!r(o=e.call(t)))return o;if(!n&&"function"==typeof(e=t.toString)&&!r(o=e.call(t)))return o;throw TypeError("Can't convert object to primitive value")}},{39:39}],83:[function(t,n,e){var r=0,o=Math.random();n.exports=function(t){return"Symbol(".concat(void 0===t?"":t,")_",(++r+o).toString(36))}},{}],84:[function(t,n,e){var r=t(68)("wks"),o=t(83),i=t(30).Symbol;n.exports=function(t){return r[t]||(r[t]=i&&i[t]||(i||o)("Symbol."+t))}},{30:30,68:68,83:83}],85:[function(t,n,e){var r=t(11),o=t(84)("iterator"),i=t(46);n.exports=t(17).getIteratorMethod=function(t){return void 0!=t?t[o]||t["@@iterator"]||i[r(t)]:void 0}},{11:11,17:17,46:46,84:84}],86:[function(t,n,e){"use strict";var r,o=t(47),i=t(21),u=t(61),c=t(33),a=t(22),s=t(31),f=t(12),l=t(19),h=t(34),p=t(9),v=t(83)("__proto__"),g=t(39),y=t(5),d=t(3),m=t(81),x=t(79),S=t(78),b=t(77),w=t(80),E=t(35),O=t(25),P=Object.prototype,_=[],M=_.slice,F=_.join,A=o.setDesc,j=o.getDesc,N=o.setDescs,I=t(8)(!1),k={};i||(r=!O(function(){return 7!=A(a("div"),"a",{get:function(){return 7}}).a}),o.setDesc=function(t,n,e){if(r)try{return A(t,n,e)}catch(o){}if("get"in e||"set"in e)throw TypeError("Accessors not supported!");return"value"in e&&(y(t)[n]=e.value),t},o.getDesc=function(t,n){if(r)try{return j(t,n)}catch(e){}return s(t,n)?u(!P.propertyIsEnumerable.call(t,n),t[n]):void 0},o.setDescs=N=function(t,n){y(t);for(var e,r=o.getKeys(n),i=r.length,u=0;i>u;)o.setDesc(t,e=r[u++],n[e]);return t}),l(l.S+l.F*!i,"Object",{getOwnPropertyDescriptor:o.getDesc,defineProperty:o.setDesc,defineProperties:N});var D="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),T=D.concat("length","prototype"),L=D.length,R=function(){var t,n=a("iframe"),e=L,r=">";for(n.style.display="none",c.appendChild(n),n.src="javascript:",t=n.contentWindow.document,t.open(),t.write(" diff --git a/js/webtorrent/entry.js b/js/webtorrent/entry.js index 6364e75518c..b76a9528344 100644 --- a/js/webtorrent/entry.js +++ b/js/webtorrent/entry.js @@ -68,7 +68,7 @@ class TorrentViewer extends React.Component { client.on('error', this.onError) ipc.on(messages.TORRENT_MESSAGE, function (e, msg) { - client.recieve(msg) + client.receive(msg) }) function send (msg) { @@ -83,9 +83,7 @@ class TorrentViewer extends React.Component { state.torrent.createServer() } - // Render immediately, then periodically to show download progress update() - setInterval(update, 1000) } saveTorrentFile () { @@ -152,3 +150,7 @@ class TorrentViewer extends React.Component { ) } } + +// Render immediately, then periodically to show download progress +update() +setInterval(update, 1000) From 76e80778c8605aab1a2e9296196c88f2911104df Mon Sep 17 00:00:00 2001 From: DC Date: Fri, 11 Nov 2016 17:26:50 -0800 Subject: [PATCH 20/48] Torrent Viewer UI bugfixes ImmutableComponent -> React.Component Fix NaNs remaining bug --- js/webtorrent/components/torrentFileList.js | 7 +++---- js/webtorrent/components/torrentStats.js | 8 +++++--- js/webtorrent/entry.js | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/js/webtorrent/components/torrentFileList.js b/js/webtorrent/components/torrentFileList.js index 149c71b7f24..8bafc51466c 100644 --- a/js/webtorrent/components/torrentFileList.js +++ b/js/webtorrent/components/torrentFileList.js @@ -1,16 +1,15 @@ const prettierBytes = require('prettier-bytes') - -const ImmutableComponent = require('../../components/immutableComponent') +const React = require('react') const SortableTable = require('../../components/sortableTable') -class TorrentFileList extends ImmutableComponent { +class TorrentFileList extends React.Component { constructor () { super() this.onClick = this.onClick.bind(this) } onClick (file) { - window.location = this.props.torrentID + '&ix=' + file.offset + window.location = this.props.torrentID + '&ix=' + this.props.files.indexOf(file) } render () { diff --git a/js/webtorrent/components/torrentStats.js b/js/webtorrent/components/torrentStats.js index 922adaa28ca..d78edd38c20 100644 --- a/js/webtorrent/components/torrentStats.js +++ b/js/webtorrent/components/torrentStats.js @@ -1,8 +1,7 @@ const prettierBytes = require('prettier-bytes') +const React = require('react') -const ImmutableComponent = require('../../components/immutableComponent') - -class TorrentStats extends ImmutableComponent { +class TorrentStats extends React.Component { render () { const torrent = this.props.torrent const errorMessage = this.props.errorMessage @@ -51,6 +50,9 @@ class TorrentStats extends ImmutableComponent { } function renderEta () { + if (torrent.timeRemaining === Infinity) return // Zero download speed + if (torrent.downloaded === torrent.length) return // Already done + const rawEta = torrent.timeRemaining / 1000 const hours = Math.floor(rawEta / 3600) % 24 const minutes = Math.floor(rawEta / 60) % 60 diff --git a/js/webtorrent/entry.js b/js/webtorrent/entry.js index b76a9528344..e6217439e28 100644 --- a/js/webtorrent/entry.js +++ b/js/webtorrent/entry.js @@ -112,8 +112,8 @@ class TorrentViewer extends React.Component { let fileContent if (state.torrent && ix) { - fileContent = state.server != null - ?