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

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeross Aboukhadijeh <feross@feross.org>2016-03-17 00:00:50 +0300
committerFeross Aboukhadijeh <feross@feross.org>2016-03-17 00:00:50 +0300
commit4ec81a03f9a856c4b40a9354519a5a95e8dc56de (patch)
tree336ad4fcec527f8b17a37fae4443e98a0f38b324 /webtorrent.min.js
parent4746da9591c6000ba7196ec13d88f92f5c078ef4 (diff)
build
Diffstat (limited to 'webtorrent.min.js')
-rw-r--r--webtorrent.min.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/webtorrent.min.js b/webtorrent.min.js
index dff5350..2d4548f 100644
--- a/webtorrent.min.js
+++ b/webtorrent.min.js
@@ -5,4 +5,4 @@ Object.keys(e.headers).forEach(function(n){t.setHeader(n,e.headers[n])});var n;i
return(!f||u&&u.ended)&&(!d||c&&c.ended)?void 0:n(new Error("premature close"))},y=function(){e.req.on("finish",l)};return i(e)?(e.on("complete",l),e.on("abort",g),e.req?y():e.on("request",y)):d&&!c&&(e.on("end",h),e.on("close",h)),s(e)&&e.on("exit",m),e.on("end",p),e.on("finish",l),t.error!==!1&&e.on("error",n),e.on("close",g),function(){e.removeListener("complete",l),e.removeListener("abort",g),e.removeListener("request",y),e.req&&e.req.removeListener("finish",l),e.removeListener("end",h),e.removeListener("close",h),e.removeListener("finish",l),e.removeListener("exit",m),e.removeListener("end",p),e.removeListener("error",n),e.removeListener("close",g)}};t.exports=a},{once:73}],72:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{dup:20}],73:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21,wrappy:72}],74:[function(e,t,n){var r=t.exports=function(e,t){if(t||(t=16),void 0===e&&(e=128),0>=e)return"0";for(var n=Math.log(Math.pow(2,e))/Math.log(t),o=2;n===1/0;o*=2)n=Math.log(Math.pow(2,e/o))/Math.log(t)*o;for(var i=n-Math.floor(n),s="",o=0;o<Math.floor(n);o++){var a=Math.floor(Math.random()*t).toString(t);s=a+s}if(i){var c=Math.pow(t,i),a=Math.floor(Math.random()*c).toString(t);s=a+s}var u=parseInt(s,t);return u!==1/0&&u>=Math.pow(2,e)?r(e,t):s};r.rack=function(e,t,n){var o=function(o){var s=0;do{if(s++>10){if(!n)throw new Error("too many ID collisions, use more bits");e+=n}var a=r(e,t)}while(Object.hasOwnProperty.call(i,a));return i[a]=o,a},i=o.hats={};return o.get=function(e){return o.hats[e]},o.set=function(e,t){return o.hats[e]=t,o},o.bits=e||128,o.base=t||16,o}},{}],75:[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:33}],76:[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}},{}],77:[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:33}],78:[function(e,t,n){function r(e,t){return this instanceof r?(s.Readable.call(this,t),this.destroyed=!1,this._drained=!1,this._forwarding=!1,this._current=null,this._queue="function"==typeof e?e:e.map(o),void this._next()):new r(e,t)}function o(e){if(!e||"function"==typeof e||e._readableState)return e;var t=(new s.Readable).wrap(e);return e.destroy&&(t.destroy=e.destroy.bind(e)),t}t.exports=r;var i=e("inherits"),s=e("readable-stream");i(r,s.Readable),r.obj=function(e){return new r(e,{objectMode:!0,highWaterMark:16})},r.prototype._read=function(){this._drained=!0,this._forward()},r.prototype._forward=function(){if(!this._forwarding&&this._drained&&this._current){this._forwarding=!0;for(var e;null!==(e=this._current.read());)this._drained=this.push(e);this._forwarding=!1}},r.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._current&&this._current.destroy&&this._current.destroy(),"function"!=typeof this._queue&&this._queue.forEach(function(e){e.destroy&&e.destroy()}),e&&this.emit("error",e),this.emit("close"))},r.prototype._next=function(){var e=this;if(e._current=null,"function"==typeof e._queue)e._queue(function(t,n){return t?e.destroy(t):void e._gotNextStream(o(n))});else{var t=e._queue.shift();"function"==typeof t&&(t=o(t())),e._gotNextStream(t)}},r.prototype._gotNextStream=function(e){function t(){i._forward()}function n(){e._readableState.ended||i.destroy()}function r(){i._current=null,e.removeListener("readable",t),e.removeListener("end",r),e.removeListener("error",o),e.removeListener("close",n),i._next()}function o(e){i.destroy(e)}var i=this;return e?(i._current=e,i._forward(),e.on("readable",t),e.on("end",r),e.on("error",o),void e.on("close",n)):(i.push(null),void i.destroy())}},{inherits:76,"readable-stream":106}],79:[function(e,t,n){(function(n,r){function o(e){if("string"==typeof e&&/magnet:/.test(e))return f(e);if("string"==typeof e&&(/^[a-f0-9]{40}$/i.test(e)||/^[a-z2-7]{32}$/i.test(e)))return f("magnet:?xt=urn:btih:"+e);if(n.isBuffer(e)&&20===e.length)return f("magnet:?xt=urn:btih:"+e.toString("hex"));if(n.isBuffer(e))return d(e);if(e&&e.infoHash)return e.announce||(e.announce=[]),"string"==typeof e.announce&&(e.announce=[e.announce]),e.urlList||(e.urlList=[]),e;throw new Error("Invalid torrent identifier")}function i(e,t){function n(e){try{i=o(e)}catch(n){return t(n)}i&&i.infoHash?t(null,i):t(new Error("Invalid torrent identifier"))}var i;if("function"!=typeof t)throw new Error("second argument must be a Function");try{i=o(e)}catch(f){}i&&i.infoHash?r.nextTick(function(){t(null,i)}):s(e)?a(e,function(e,r){return e?t(new Error("Error converting Blob: "+e.message)):void n(r)}):"function"==typeof u&&/^https?:/.test(e)?u.concat({url:e,headers:{"user-agent":"WebTorrent (http://webtorrent.io)"}},function(e,r,o){return e?t(new Error("Error downloading torrent: "+e.message)):void n(o)}):"function"==typeof c.readFile&&"string"==typeof e?c.readFile(e,function(e,r){return e?t(new Error("Invalid torrent identifier")):void n(r)}):r.nextTick(function(){t(new Error("Invalid torrent identifier"))})}function s(e){return"undefined"!=typeof Blob&&e instanceof Blob}t.exports=o,t.exports.remote=i;var a=e("blob-to-buffer"),c=e("fs"),u=e("simple-get"),f=e("magnet-uri"),d=e("parse-torrent-file");t.exports.toMagnetURI=f.encode,t.exports.toTorrentFile=d.encode}).call(this,{isBuffer:e("../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js")},e("_process"))},{"../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js":31,_process:33,"blob-to-buffer":80,fs:23,"magnet-uri":81,"parse-torrent-file":84,"simple-get":128}],80:[function(e,t,n){(function(e){t.exports=function(t,n){function r(t){o.removeEventListener("loadend",r,!1),t.error?n(t.error):n(null,new e(o.result))}if("undefined"==typeof Blob||!(t instanceof Blob))throw new Error("first argument must be a Blob");if("function"!=typeof n)throw new Error("second argument must be a function");var o=new FileReader;o.addEventListener("loadend",r,!1),o.readAsArrayBuffer(t)}}).call(this,e("buffer").Buffer)},{buffer:25}],81:[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 c=Array.isArray(t.xt)?t.xt:[t.xt];c.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:25,"thirty-two":82,uniq:146,xtend:152}],82:[function(e,t,n){var r=e("./thirty-two");n.encode=r.encode,n.decode=r.decode},{"./thirty-two":83}],83:[function(e,t,n){(function(e){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,c=new e(8*t(n));o<n.length;){var u=n[o];s>3?(a=u&255>>s,s=(s+5)%8,a=a<<s|(o+1<n.length?n[o+1]:0)>>8-s,o++):(a=u>>8-(s+5)&31,s=(s+5)%8,0==s&&o++),c[i]=r.charCodeAt(a),i++}for(o=i;o<c.length;o++)c[o]=61;return c},n.decode=function(t){var n,r=0,i=0,s=0;e.isBuffer(t)||(t=new e(t));for(var a=new e(Math.ceil(5*t.length/8)),c=0;c<t.length&&61!=t[c];c++){var u=t[c]-48;if(!(u<o.length))throw new Error("Invalid input - it is not base32 encoded string");i=o[u],3>=r?(r=(r+5)%8,0==r?(n|=i,a[s]=n,s++,n=0):n|=255&i<<8-r):(r=(r+5)%8,n|=255&i>>>r,a[s]=n,s++,n=255&i<<8-r)}return a.slice(0,s)}}).call(this,e("buffer").Buffer)},{buffer:25}],84:[function(e,t,n){(function(n){function r(e){n.isBuffer(e)&&(e=c.decode(e)),a(e.info,"info"),a(e.info["name.utf-8"]||e.info.name,"info.name"),a(e.info["piece length"],"info['piece length']"),a(e.info.pieces,"info.pieces"),e.info.files?e.info.files.forEach(function(e){a("number"==typeof e.length,"info.files[0].length"),a(e["path.utf-8"]||e.path,"info.files[0].path")}):a("number"==typeof e.info.length,"info.length");var t={};t.info=e.info,t.infoBuffer=c.encode(e.info),t.infoHash=f.sync(t.infoBuffer),t.infoHashBuffer=new n(t.infoHash,"hex"),t.name=(e.info["name.utf-8"]||e.info.name).toString(),void 0!==e.info["private"]&&(t["private"]=!!e.info["private"]),e["creation date"]&&(t.created=new Date(1e3*e["creation date"])),e["created by"]&&(t.createdBy=e["created by"].toString()),n.isBuffer(e.comment)&&(t.comment=e.comment.toString()),t.announce=[],e["announce-list"]&&e["announce-list"].length?e["announce-list"].forEach(function(e){e.forEach(function(e){t.announce.push(e.toString())})}):e.announce&&t.announce.push(e.announce.toString()),n.isBuffer(e["url-list"])&&(e["url-list"]=e["url-list"].length>0?[e["url-list"]]:[]),t.urlList=(e["url-list"]||[]).map(function(e){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:u.join.apply(null,[u.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]}),e.created&&(t["creation date"]=e.created.getTime()/1e3|0),e.urlList&&(t["url-list"]=e.urlList),c.encode(t)}function i(e,t){return e+t.length}function s(e){for(var t=[],n=0;n<e.length;n+=20)t.push(e.slice(n,n+20).toString("hex"));return t}function a(e,t){if(!e)throw new Error("Torrent is missing required field: "+t)}t.exports=r,t.exports.decode=r,t.exports.encode=o;var c=e("bencode"),u=e("path"),f=e("simple-sha1"),d=e("uniq")}).call(this,e("buffer").Buffer)},{bencode:85,buffer:25,path:32,"simple-sha1":135,uniq:146}],85:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./lib/decode":86,"./lib/encode":88,dup:12}],86:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./dict":87,buffer:25,dup:13}],87:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],88:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{buffer:25,dup:15}],89:[function(e,t,n){var r=e("once"),o=e("end-of-stream"),i=e("fs"),s=function(){},a=function(e){return"function"==typeof e},c=function(e){return(e instanceof(i.ReadStream||s)||e instanceof(i.WriteStream||s))&&a(e.close)},u=function(e){return e.setHeader&&a(e.abort)},f=function(e,t,n,i){i=r(i);var s=!1;e.on("close",function(){s=!0}),o(e,{readable:t,writable:n},function(e){return e?i(e):(s=!0,void i())});var f=!1;return function(t){return s||f?void 0:(f=!0,c(e)?e.close():u(e)?e.abort():a(e.destroy)?e.destroy():void i(t||new Error("stream was destroyed")))}},d=function(e){e()},h=function(e,t){return e.pipe(t)},l=function(){var e=Array.prototype.slice.call(arguments),t=a(e[e.length-1]||s)&&e.pop()||s;if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new Error("pump requires two streams per minimum");var n,r=e.map(function(o,i){var s=i<e.length-1,a=i>0;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":71,fs:23,once:91}],90:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{dup:20}],91:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21,wrappy:90}],92:[function(e,t,n){var r=function(e){var t=0;return function(){if(t===e.length)return null;var n=e.length-t,r=Math.random()*n|0,o=e[t+r],i=e[t];return e[t]=o,e[t+r]=i,t++,o}};t.exports=r},{}],93:[function(e,t,n){function r(e,t,n){Array.isArray(n)||(n=[n]);var r=[];return n.forEach(function(n){var o=function(){var e=[].slice.call(arguments);e.unshift(n),t.emit.apply(t,e)};r.push(o),e.on(n,o)}),function(){n.forEach(function(t,n){e.removeListener(t,r[n])})}}function o(e,t){var n=new i;return r(e,n,t),n}t.exports=r,t.exports.filter=o;var i=e("events").EventEmitter},{events:29}],94:[function(e,t,n){t.exports=e("./lib/_stream_duplex.js")},{"./lib/_stream_duplex.js":95}],95:[function(e,t,n){"use strict";function r(e){return this instanceof r?(u.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"),c=e("core-util-is");c.inherits=e("inherits");var u=e("./_stream_readable"),f=e("./_stream_writable");c.inherits(r,u);for(var d=s(f.prototype),h=0;h<d.length;h++){var l=d[h];r.prototype[l]||(r.prototype[l]=f.prototype[l])}},{"./_stream_readable":97,"./_stream_writable":99,"core-util-is":100,inherits:76,"process-nextick-args":102}],96:[function(e,t,n){"use strict";function r(e){return this instanceof r?void o.call(this,e):new r(e)}t.exports=r;var o=e("./_stream_transform"),i=e("core-util-is");i.inherits=e("inherits"),i.inherits(r,o),r.prototype._transform=function(e,t,n){n(null,e)}},{"./_stream_transform":98,"core-util-is":100,inherits:76}],97:[function(e,t,n){(function(n){"use strict";function r(t,n){P=P||e("./_stream_duplex"),t=t||{},this.objectMode=!!t.objectMode,n instanceof P&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var r=t.highWaterMark,o=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:o,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(U||(U=e("string_decoder/").StringDecoder),this.decoder=new U(t.encoding),this.encoding=t.encoding)}function o(t){return P=P||e("./_stream_duplex"),this instanceof o?(this._readableState=new r(t,this),this.readable=!0,t&&"function"==typeof t.read&&(this._read=t.read),void A.call(this)):new o(t)}function i(e,t,n,r,o){var i=u(t,n);if(i)e.emit("error",i);else if(null===n)t.reading=!1,f(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!o){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&o){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else!t.decoder||o||r||(n=t.decoder.write(n)),o||(t.reading=!1),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&&d(e)),l(e,t);else o||(t.reading=!1);return s(t)}function s(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function a(e){return e>=O?e=O:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function c(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:null===e||isNaN(e)?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function u(e,t){var n=null;return B.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk")),n}function f(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,d(e)}}function d(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(T("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?S(h,e):h(e))}function h(e){T("emit readable"),e.emit("readable"),v(e)}function l(e,t){t.readingMore||(t.readingMore=!0,S(p,e,t))}function p(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(T("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function m(e){return function(){var t=e._readableState;T("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&C(e,"data")&&(t.flowing=!0,v(e))}}function g(e){T("readable nexttick read 0"),e.read(0)}function y(e,t){t.resumeScheduled||(t.resumeScheduled=!0,S(_,e,t))}function _(e,t){t.reading||(T("resume read 0"),e.read(0)),t.resumeScheduled=!1,e.emit("resume"),v(e),t.flowing&&!t.reading&&e.read(0)}function v(e){var t=e._readableState;if(T("flow",t.flowing),t.flowing)do var n=e.read();while(null!==n&&t.flowing)}function b(e,t){var n,r=t.buffer,o=t.length,i=!!t.decoder,s=!!t.objectMode;if(0===r.length)return null;if(0===o)n=null;else if(s)n=r.shift();else if(!e||e>=o)n=i?r.join(""):1===r.length?r[0]:B.concat(r,o),r.length=0;else if(e<r[0].length){var a=r[0];n=a.slice(0,e),r[0]=a.slice(e)}else if(e===r[0].length)n=r.shift();else{n=i?"":new B(e);for(var c=0,u=0,f=r.length;f>u&&e>c;u++){var a=r[0],d=Math.min(e-c,a.length);i?n+=a.slice(0,d):a.copy(n,c,0,d),d<a.length?r[0]=a.slice(d):r.shift(),c+=d}}return n}function w(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");t.endEmitted||(t.ended=!0,S(E,t,e))}function E(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function k(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function x(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}t.exports=o;var S=e("process-nextick-args"),I=e("isarray"),B=e("buffer").Buffer;o.ReadableState=r;var A,C=(e("events"),function(e,t){return e.listeners(t).length});!function(){try{A=e("stream")}catch(t){}finally{A||(A=e("events").EventEmitter)}}();var B=e("buffer").Buffer,L=e("core-util-is");L.inherits=e("inherits");var T,R=e("util");T=R&&R.debuglog?R.debuglog("stream"):function(){};var U;L.inherits(o,A);var P,P;o.prototype.push=function(e,t){var n=this._readableState;return n.objectMode||"string"!=typeof e||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new B(e,t),t="")),i(this,n,e,t,!1)},o.prototype.unshift=function(e){var t=this._readableState;return i(this,t,e,"",!0)},o.prototype.isPaused=function(){return this._readableState.flowing===!1},o.prototype.setEncoding=function(t){return U||(U=e("string_decoder/").StringDecoder),this._readableState.decoder=new U(t),this._readableState.encoding=t,this};var O=8388608;o.prototype.read=function(e){T("read",e);var t=this._readableState,n=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return T("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?w(this):d(this),null;if(e=c(e,t),0===e&&t.ended)return 0===t.length&&w(this),null;var r=t.needReadable;T("need readable",r),(0===t.length||t.length-e<t.highWaterMark)&&(r=!0,T("length less than watermark",r)),(t.ended||t.reading)&&(r=!1,T("reading or ended",r)),r&&(T("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1),r&&!t.reading&&(e=c(n,t));var o;return o=e>0?b(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&&0===t.length&&w(this),null!==o&&this.emit("data",o),o},o.prototype._read=function(e){this.emit("error",new Error("not implemented"))},o.prototype.pipe=function(e,t){function r(e){T("onunpipe"),e===d&&i()}function o(){T("onend"),e.end()}function i(){T("cleanup"),e.removeListener("close",c),e.removeListener("finish",u),e.removeListener("drain",g),e.removeListener("error",a),e.removeListener("unpipe",r),d.removeListener("end",o),d.removeListener("end",i),d.removeListener("data",s),y=!0,!h.awaitDrain||e._writableState&&!e._writableState.needDrain||g()}function s(t){T("ondata");var n=e.write(t);!1===n&&(1!==h.pipesCount||h.pipes[0]!==e||1!==d.listenerCount("data")||y||(T("false write response, pause",d._readableState.awaitDrain),d._readableState.awaitDrain++),d.pause())}function a(t){T("onerror",t),f(),e.removeListener("error",a),0===C(e,"error")&&e.emit("error",t)}function c(){e.removeListener("finish",u),f()}function u(){T("onfinish"),e.removeListener("close",c),f()}function f(){T("unpipe"),d.unpipe(e)}var d=this,h=this._readableState;switch(h.pipesCount){case 0:h.pipes=e;break;case 1:h.pipes=[h.pipes,e];break;default:h.pipes.push(e)}h.pipesCount+=1,T("pipe count=%d opts=%j",h.pipesCount,t);var l=(!t||t.end!==!1)&&e!==n.stdout&&e!==n.stderr,p=l?o:i;h.endEmitted?S(p):d.once("end",p),e.on("unpipe",r);var g=m(d);e.on("drain",g);var y=!1;return d.on("data",s),e._events&&e._events.error?I(e._events.error)?e._events.error.unshift(a):e._events.error=[a,e._events.error]:e.on("error",a),e.once("close",c),e.once("finish",u),e.emit("pipe",d),h.flowing||(T("pipe resume"),d.resume()),e},o.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;r>o;o++)n[o].emit("unpipe",this);return this}var o=x(t.pipes,e);return-1===o?this:(t.pipes.splice(o,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},o.prototype.on=function(e,t){var n=A.prototype.on.call(this,e,t);if("data"===e&&!1!==this._readableState.flowing&&this.resume(),"readable"===e&&this.readable){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&d(this,r):S(g,this))}return n},o.prototype.addListener=o.prototype.on,o.prototype.resume=function(){var e=this._readableState;return e.flowing||(T("resume"),e.flowing=!0,y(this,e)),this},o.prototype.pause=function(){return T("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(T("pause"),this._readableState.flowing=!1,this.emit("pause")),this},o.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(T("wrapped end"),t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(o){if(T("wrapped data"),t.decoder&&(o=t.decoder.write(o)),(!t.objectMode||null!==o&&void 0!==o)&&(t.objectMode||o&&o.length)){var i=r.push(o);i||(n=!0,e.pause())}});for(var o in e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));var i=["error","close","destroy","pause","resume"];return k(i,function(t){e.on(t,r.emit.bind(r,t))}),r._read=function(t){T("wrapped _read",t),n&&(n=!1,e.resume())},r},o._fromList=b}).call(this,e("_process"))},{"./_stream_duplex":95,_process:33,buffer:25,"core-util-is":100,events:29,inherits:76,isarray:101,"process-nextick-args":102,"string_decoder/":103,util:24}],98:[function(e,t,n){"use strict";function r(e){this.afterTransform=function(t,n){return o(e,t,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function o(e,t,n){var r=e._transformState;r.transforming=!1;var o=r.writecb;if(!o)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!==n&&void 0!==n&&e.push(n),o&&o(t);var i=e._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&e._read(i.highWaterMark)}function i(e){if(!(this instanceof i))return new i(e);a.call(this,e),this._transformState=new r(this);var t=this;this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.once("prefinish",function(){"function"==typeof this._flush?this._flush(function(e){s(t,e)}):s(t)})}function s(e,t){if(t)return e.emit("error",t);var n=e._writableState,r=e._transformState;if(n.length)throw new Error("calling transform done when ws.length != 0");if(r.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}t.exports=i;var a=e("./_stream_duplex"),c=e("core-util-is");c.inherits=e("inherits"),c.inherits(i,a),i.prototype.push=function(e,t){return this._transformState.needTransform=!1,a.prototype.push.call(this,e,t)},i.prototype._transform=function(e,t,n){throw new Error("not implemented")},i.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var o=this._readableState;(r.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}},i.prototype._read=function(e){var t=this._transformState;null!==t.writechunk&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0}},{"./_stream_duplex":95,"core-util-is":100,inherits:76}],99:[function(e,t,n){"use strict";function r(){}function o(e,t,n){this.chunk=e,this.encoding=t,this.callback=n,this.next=null}function i(t,n){B=B||e("./_stream_duplex"),t=t||{},this.objectMode=!!t.objectMode,n instanceof B&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var r=t.highWaterMark,o=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:o,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=t.decodeStrings===!1;this.decodeStrings=!i,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){p(n,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1}function s(t){return B=B||e("./_stream_duplex"),this instanceof s||this instanceof B?(this._writableState=new i(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev)),void S.call(this)):new s(t)}function a(e,t){var n=new Error("write after end");e.emit("error",n),E(t,n)}function c(e,t,n,r){var o=!0;if(!k.isBuffer(n)&&"string"!=typeof n&&null!==n&&void 0!==n&&!t.objectMode){var i=new TypeError("Invalid non-string/buffer chunk");e.emit("error",i),E(r,i),o=!1}return o}function u(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new k(t,n)),t}function f(e,t,n,r,i){n=u(t,n,r),k.isBuffer(n)&&(r="buffer");var s=t.objectMode?1:n.length;t.length+=s;var a=t.length<t.highWaterMark;if(a||(t.needDrain=!0),t.writing||t.corked){var c=t.lastBufferedRequest;t.lastBufferedRequest=new o(n,r,i),c?c.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest}else d(e,t,!1,s,n,r,i);return a}function d(e,t,n,r,o,i,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,n?e._writev(o,t.onwrite):e._write(o,i,t.onwrite),t.sync=!1}function h(e,t,n,r,o){--t.pendingcb,n?E(o,r):o(r),e._writableState.errorEmitted=!0,e.emit("error",r)}function l(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function p(e,t){var n=e._writableState,r=n.sync,o=n.writecb;if(l(n),t)h(e,n,r,t,o);else{var i=_(n);i||n.corked||n.bufferProcessing||!n.bufferedRequest||y(e,n),r?E(m,e,n,i,o):m(e,n,i,o)}}function m(e,t,n,r){n||g(e,t),t.pendingcb--,r(),b(e,t)}function g(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function y(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){for(var r=[],o=[];n;)o.push(n.callback),r.push(n),n=n.next;t.pendingcb++,t.lastBufferedRequest=null,d(e,t,!0,t.length,r,"",function(e){for(var n=0;n<o.length;n++)t.pendingcb--,o[n](e)})}else{for(;n;){var i=n.chunk,s=n.encoding,a=n.callback,c=t.objectMode?1:i.length;if(d(e,t,!1,c,i,s,a),n=n.next,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function v(e,t){t.prefinished||(t.prefinished=!0,e.emit("prefinish"))}function b(e,t){var n=_(t);return n&&(0===t.pendingcb?(v(e,t),t.finished=!0,e.emit("finish")):v(e,t)),n}function w(e,t,n){t.ending=!0,b(e,t),n&&(t.finished?E(n):e.once("finish",n)),t.ended=!0}t.exports=s;var E=e("process-nextick-args"),k=e("buffer").Buffer;s.WritableState=i;var x=e("core-util-is");x.inherits=e("inherits");var S,I={deprecate:e("util-deprecate")};!function(){try{S=e("stream")}catch(t){}finally{S||(S=e("events").EventEmitter)}}();var k=e("buffer").Buffer;x.inherits(s,S);var B;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 B;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),k.isBuffer(e)?t="buffer":t||(t=o.defaultEncoding),"function"!=typeof n&&(n=r),o.ended?a(this,n):c(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);this._writableState.defaultEncoding=e},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)}},{"./_stream_duplex":95,buffer:25,"core-util-is":100,events:29,inherits:76,"process-nextick-args":102,"util-deprecate":104}],100:[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 c(e){return"symbol"==typeof e}function u(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=c,n.isUndefined=u,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("../../../../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js")})},{"../../../../browserify/node_modules/insert-module-globals/node_modules/is-buffer/index.js":31}],101:[function(e,t,n){t.exports=Array.isArray||function(e){return"[object Array]"==Object.prototype.toString.call(e)}},{}],102:[function(e,t,n){(function(e){"use strict";function n(t){for(var n=new Array(arguments.length-1),r=0;r<n.length;)n[r++]=arguments[r];e.nextTick(function(){t.apply(null,n)})}!e.version||0===e.version.indexOf("v0.")||0===e.version.indexOf("v1.")&&0!==e.version.indexOf("v1.8.")?t.exports=n:t.exports=e.nextTick}).call(this,e("_process"))},{_process:33}],103:[function(e,t,n){function r(e){if(e&&!c(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,c=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}},u=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};u.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<this.charLength)return"";e=e.slice(n,e.length),t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var r=t.charCodeAt(t.length-1);if(!(r>=55296&&56319>=r)){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&&56319>=r){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},u.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(2>=t&&n>>4==14){this.charLength=3;break}if(3>=t&&n>>3==30){this.charLength=4;break}}this.charReceived=t},u.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:25}],104:[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(n){return!1}var r=e.localStorage[t];return null==r?!1:"true"===String(r).toLowerCase()}t.exports=n}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],105:[function(e,t,n){t.exports=e("./lib/_stream_passthrough.js")},{"./lib/_stream_passthrough.js":96}],106:[function(e,t,n){var r=function(){try{return e("stream")}catch(t){}}();n=t.exports=e("./lib/_stream_readable.js"),n.Stream=r||n,n.Readable=n,n.Writable=e("./lib/_stream_writable.js"),n.Duplex=e("./lib/_stream_duplex.js"),n.Transform=e("./lib/_stream_transform.js"),n.PassThrough=e("./lib/_stream_passthrough.js")},{"./lib/_stream_duplex.js":95,"./lib/_stream_passthrough.js":96,"./lib/_stream_readable.js":97,"./lib/_stream_transform.js":98,"./lib/_stream_writable.js":99}],107:[function(e,t,n){t.exports=e("./lib/_stream_transform.js")},{"./lib/_stream_transform.js":98}],108:[function(e,t,n){t.exports=e("./lib/_stream_writable.js")},{"./lib/_stream_writable.js":99}],109:[function(e,t,n){function r(e,t,n){a(e),"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)}function o(e,t,n){function r(e){var n=o(e);return n.controls=!0,n.autoplay=!0,n.play(),t.appendChild(n),n}function o(e){var n=document.createElement(e);return t.appendChild(n),n}if(n||(n=function(){}),a(e),"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,function(e){return"video"===e||"audio"===e?r(e):o(e)},function(e,t){e&&t&&t.remove(),n(e,t)})}function i(e,t,n){function r(){function n(){f("Use `videostream` package for "+e.name),d(),x.addEventListener("error",a),x.addEventListener("playing",o),m(e,x)}function r(){f("Use MediaSource API for "+e.name),d(),x.addEventListener("error",u),x.addEventListener("playing",o);var t=new h(x),n=t.createWriteStream(c(e.name));e.createReadStream().pipe(n),I&&(x.currentTime=I)}function i(){f("Use Blob URL for "+e.name),d(),x.addEventListener("error",_),x.addEventListener("playing",o),s(e,function(e,t){return e?_(e):(x.src=t,void(I&&(x.currentTime=I)))})}function a(e){f("videostream error: fallback to MediaSource API: %o",e.message||e),x.removeEventListener("error",a),x.removeEventListener("playing",o),r()}function u(e){f("MediaSource API error: fallback to Blob URL: %o",e.message||e),x.removeEventListener("error",u),x.removeEventListener("playing",o),i()}function d(){x||(x=t(l),x.addEventListener("progress",function(){I=x.currentTime}))}var l=y.indexOf(S)>=0?"video":"audio";k?g.indexOf(S)>=0?n():r():i()}function o(){x.removeEventListener("playing",o),n(null,x)}function i(){x=t("audio"),s(e,function(e,t){return e?_(e):(x.addEventListener("error",_),x.addEventListener("playing",o),void(x.src=t))})}function a(){x=t("img"),s(e,function(t,r){return t?_(t):(x.src=r,x.alt=e.name,void n(null,x))})}function u(){x=t("iframe"),s(e,function(e,t){return e?_(e):(x.src=t,".pdf"!==S&&(x.sandbox="allow-forms allow-scripts"),void n(null,x))})}function p(){function t(){d(r)?(f('File extension "%s" appears ascii, so will render.',S),u()):(f('File extension "%s" appears non-ascii, will not render.',S),n(new Error('Unsupported file type "'+S+'": Cannot append to DOM')))}f('Unknown file extension "%s" - will attempt to render into iframe',S);var r="";e.createReadStream({start:0,end:1e3}).setEncoding("utf8").on("data",function(e){r+=e}).on("end",t).on("error",n)}function _(t){t.message='Error rendering file "'+e.name+'": '+t.message,f(t.message),n(t)}n||(n=function(){});var x,S=l.extname(e.name).toLowerCase(),I=0;v.indexOf(S)>=0?r():b.indexOf(S)>=0?i():w.indexOf(S)>=0?a():E.indexOf(S)>=0?u():p()}function s(e,t){var n=l.extname(e.name).toLowerCase();p(e.createReadStream(),u[n],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 c(e){var t=l.extname(e).toLowerCase();return{".m4a":'audio/mp4; codecs="mp4a.40.5"',".m4v":'video/mp4; 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]}n.render=r,n.append=o;var u=n.mime=e("./lib/mime.json"),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=[".mp4",".m4v",".m4a"],y=[".mp4",".m4v",".webm"],_=[".m4a",".mp3"],v=y.concat(_),b=[".wav",".aac",".ogg",".oga"],w=[".jpg",".jpeg",".png",".gif",".bmp"],E=[".css",".html",".js",".md",".pdf",".txt"],k="undefined"!=typeof window&&window.MediaSource},{"./lib/mime.json":110,debug:68,"is-ascii":111,mediasource:112,path:32,"stream-to-blob-url":138,videostream:125}],110:[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"}},{}],111:[function(e,t,n){var r=127;t.exports=function(e){for(var t=0,n=e.length;n>t;++t)if(e.charCodeAt(t)>r)return!1;return!0}},{}],112:[function(e,t,n){function r(e,t){var n=this;if(!(n instanceof r))return new r(e,t);if(!c)throw new Error("web browser lacks MediaSource support");t||(t={}),n._bufferDuration=t.bufferDuration||u,n._elem=e,n._mediaSource=new c,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=n._onSourceOpen.bind(n),n._flowHandler=n._flow.bind(n),"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",n._wrapper.error.bind(n._wrapper)),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"),c="undefined"!=typeof window&&window.MediaSource,u=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(c.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(o){return void r.destroy(o)}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;o<t.length;o++){var i=t.start(o),s=t.end(o)+f;if(i>n)break;(r>=0||s>=n)&&(r=s)}var a=r-n;return 0>a&&(a=0),a}},{inherits:76,"readable-stream":106,"to-arraybuffer":113}],113:[function(e,t,n){arguments[4][44][0].apply(n,arguments)},{buffer:25,dup:44}],114:[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,c=e("inherits"),u=e("mp4-stream"),f=e("mp4-box-encoding"),d=e("range-slice-stream");t.exports=r,c(r,a),r.prototype._findMoov=function(e){var t=this;t._decoder&&t._decoder.destroy(),t._decoder=u.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(r){r.message="Cannot parse mp4 file: "+r.message,t.emit("error",r)}}):(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<r.length;s++){var a,c,u=r[s],d=u.mdia.minf.stbl,h=d.stsd.entries[0],l=u.mdia.hdlr.handlerType;if("vide"===l&&"avc1"===h.type){if(t._hasVideo)continue;t._hasVideo=!0,a="avc1",h.avcC&&(a+="."+h.avcC.mimeCodec),c='video/mp4; codecs="'+a+'"'}else{if("soun"!==l||"mp4a"!==h.type)continue;if(t._hasAudio)continue;t._hasAudio=!0,a="mp4a",h.esds&&h.esds.mimeCodec&&(a+="."+h.esds.mimeCodec),c='audio/mp4; codecs="'+a+'"'}var p=[],m=0,g=0,y=0,_=0,v=0,b=0,w=new o(d.stts.entries),E=null;d.ctts&&(E=new o(d.ctts.entries));for(var k=0;;){var x=d.stsc.entries[v],S=d.stsz.entries[m],I=w.value.duration,B=E?E.value.compositionOffset:0,A=!0;if(d.stss&&(A=d.stss.entries[k]===m+1),p.push({size:S,duration:I,dts:b,presentationOffset:B,sync:A,offset:_+d.stco.entries[y]}),m++,m>=d.stsz.entries.length)break;if(g++,_+=S,g>=x.samplesPerChunk){g=0,_=0,y++;var C=d.stsc.entries[v+1];C&&y+1>=C.firstChunk&&v++}b+=I,w.inc(),E&&E.inc(),A&&k++}u.mdia.mdhd.duration=0,u.tkhd.duration=0;var L=x.sampleDescriptionId,T={type:"moov",mvhd:e.mvhd,traks:[{tkhd:u.tkhd,mdia:{mdhd:u.mdia.mdhd,hdlr:u.mdia.hdlr,elng:u.mdia.elng,minf:{vmhd:u.mdia.minf.vmhd,smhd:u.mdia.minf.smhd,dinf:u.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:u.tkhd.trackId,defaultSampleDescriptionIndex:L,defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0}]}};t._tracks.push({trackId:u.tkhd.trackId,timeScale:u.mdia.mdhd.timeScale,samples:p,currSample:null,currTime:null,moov:T,mime:c})}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=u.encode(),a=t._generateFragment(o,e);return a?((-1===n||a.ranges[0].start<n)&&(n=a.ranges[0].start),void i(a)):s.finalize()}),n>=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(-1===i?i=0:0>i&&(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=[],c=n;c<o.samples.length;c++){var u=o.samples[c];if(u.sync&&u.dts-i>=o.timeScale*h)break;s+=u.size;var f=a.length-1;0>f||a[f].end!==u.offset?a.push({start:u.offset,end:u.offset+u.size}):a[f].end+=u.size}return o.currSample=c,{moof:r._generateMoof(e,n,c),ranges:a,length:s}},r.prototype._generateMoof=function(e,t,n){for(var r=this,o=r._tracks[e],i=[],s=t;n>s;s++){var a=o.samples[s];i.push({sampleDuration:a.duration,sampleSize:a.size,sampleFlags:a.sync?33554432:16842752,sampleCompositionTimeOffset:a.presentationOffset})}var c={type:"moof",mfhd:{sequenceNumber:r._fragmentSequence++},trafs:[{tfhd:{flags:131072,trackId:o.trackId},tfdt:{baseMediaDecodeTime:o.samples[t].dts},trun:{flags:3841,dataOffset:8,entries:i}}]};return c.trafs[0].trun.dataOffset+=f.encodingLength(c),c}}).call(this,e("buffer").Buffer)},{"binary-search":115,buffer:25,events:29,inherits:76,"mp4-box-encoding":118,"mp4-stream":122,"range-slice-stream":124}],115:[function(e,t,n){t.exports=function(e,t,n,r,o){var i,s;if(void 0===r)r=0;else if(r=0|r,0>r||r>=e.length)throw new RangeError("invalid lower bound");if(void 0===o)o=e.length-1;else if(o=0|o,r>o||o>=e.length)throw new RangeError("invalid upper bound");for(;o>=r;)if(i=r+(o-r>>1),s=+n(e[i],t),0>s)r=i+1;else{if(!(s>0))return i;o=i-1}return~r}},{}],116:[function(e,t,n){(function(t){function r(e,t,n){for(var r=t;n>r;r++)e[r]=0}function o(e,t,n){t.writeUInt32BE(Math.floor((e.getTime()+g)/1e3),n)}function i(e,t,n){t.writeUInt16BE(Math.floor(e)%65536,n),t.writeUInt16BE(Math.floor(256*e*256)%65536,n+2)}function s(e,t,n){t[n]=Math.floor(e)%256,t[n+1]=Math.floor(256*e)%256}function a(e,t,n){e||(e=[0,0,0,0,0,0,0,0,0]);for(var r=0;r<e.length;r++)i(e[r],t,n+4*r)}function c(e,n,r){var o=new t(e,"utf8");o.copy(n,r),n[r+o.length]=0}function u(e){for(var t=new Array(e.length/4),n=0;n<t.length;n++)t[n]=d(e,4*n);return t}function f(e,t){return new Date(1e3*e.readUInt32BE(t)-g)}function d(e,t){return e.readUInt16BE(t)+e.readUInt16BE(t+2)/65536}function h(e,t){return e[t]+e[t+1]/256}function l(e,t,n){var r;for(r=0;n>r&&0!==e[t+r];r++);return e.toString("utf8",t,t+r)}var p=e("./index"),m=e("./descriptor"),g=20828448e5;n.fullBoxes={};var y=["mvhd","tkhd","mdhd","vmhd","smhd","stsd","esds","stsz","stco","stss","stts","ctts","stsc","dref","elst","hdlr","mehd","trex","mfhd","tfhd","tfdt","trun"];y.forEach(function(e){n.fullBoxes[e]=!0}),n.ftyp={},n.ftyp.encode=function(e,r,o){r=r?r.slice(o):new t(n.ftyp.encodingLength(e));var i=e.compatibleBrands||[];r.write(e.brand,0,4,"ascii"),r.writeUInt32BE(e.brandVersion,4);for(var s=0;s<i.length;s++)r.write(i[s],8+4*s,4,"ascii");return n.ftyp.encode.bytes=8+4*i.length,r},n.ftyp.decode=function(e,t){e=e.slice(t);for(var n=e.toString("ascii",0,4),r=e.readUInt32BE(4),o=[],i=8;i<e.length;i+=4)o.push(e.toString("ascii",i,i+4));return{brand:n,brandVersion:r,compatibleBrands:o}},n.ftyp.encodingLength=function(e){return 8+4*(e.compatibleBrands||[]).length},n.mvhd={},n.mvhd.encode=function(e,c,u){return c=c?c.slice(u):new t(96),o(e.ctime||new Date,c,0),o(e.mtime||new Date,c,4),c.writeUInt32BE(e.timeScale||0,8),c.writeUInt32BE(e.duration||0,12),i(e.preferredRate||0,c,16),s(e.preferredVolume||0,c,20),r(c,22,32),a(e.matrix,c,32),c.writeUInt32BE(e.previewTime||0,68),c.writeUInt32BE(e.previewDuration||0,72),c.writeUInt32BE(e.posterTime||0,76),c.writeUInt32BE(e.selectionTime||0,80),c.writeUInt32BE(e.selectionDuration||0,84),c.writeUInt32BE(e.currentTime||0,88),c.writeUInt32BE(e.nextTrackId||0,92),n.mvhd.encode.bytes=96,c},n.mvhd.decode=function(e,t){return e=e.slice(t),{ctime:f(e,0),mtime:f(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),preferredRate:d(e,16),preferredVolume:h(e,20),matrix:u(e.slice(32,68)),previewTime:e.readUInt32BE(68),previewDuration:e.readUInt32BE(72),posterTime:e.readUInt32BE(76),selectionTime:e.readUInt32BE(80),selectionDuration:e.readUInt32BE(84),currentTime:e.readUInt32BE(88),nextTrackId:e.readUInt32BE(92)}},n.mvhd.encodingLength=function(e){return 96},n.tkhd={},n.tkhd.encode=function(e,i,s){return i=i?i.slice(s):new t(80),o(e.ctime||new Date,i,0),o(e.mtime||new Date,i,4),i.writeUInt32BE(e.trackId||0,8),r(i,12,16),i.writeUInt32BE(e.duration||0,16),r(i,20,28),i.writeUInt16BE(e.layer||0,28),i.writeUInt16BE(e.alternateGroup||0,30),i.writeUInt16BE(e.volume||0,32),a(e.matrix,i,36),i.writeUInt32BE(e.trackWidth||0,72),i.writeUInt32BE(e.trackHeight||0,76),n.tkhd.encode.bytes=80,i},n.tkhd.decode=function(e,t){return e=e.slice(t),{ctime:f(e,0),mtime:f(e,4),trackId:e.readUInt32BE(8),duration:e.readUInt32BE(16),layer:e.readUInt16BE(28),alternateGroup:e.readUInt16BE(30),volume:e.readUInt16BE(32),matrix:u(e.slice(36,72)),trackWidth:e.readUInt32BE(72),trackHeight:e.readUInt32BE(76)}},n.tkhd.encodingLength=function(e){return 80},n.mdhd={},n.mdhd.encode=function(e,r,i){return r=r?r.slice(i):new t(20),o(e.ctime||new Date,r,0),o(e.mtime||new Date,r,4),r.writeUInt32BE(e.timeScale||0,8),r.writeUInt32BE(e.duration||0,12),r.writeUInt16BE(e.language||0,16),r.writeUInt16BE(e.quality||0,18),n.mdhd.encode.bytes=20,r},n.mdhd.decode=function(e,t){return e=e.slice(t),{ctime:f(e,0),mtime:f(e,4),timeScale:e.readUInt32BE(8),duration:e.readUInt32BE(12),language:e.readUInt16BE(16),quality:e.readUInt16BE(18)}},n.mdhd.encodingLength=function(e){return 20},n.vmhd={},n.vmhd.encode=function(e,r,o){r=r?r.slice(o):new t(8),r.writeUInt16BE(e.graphicsMode||0,0);var i=e.opcolor||[0,0,0];return r.writeUInt16BE(i[0],2),r.writeUInt16BE(i[1],4),r.writeUInt16BE(i[2],6),n.vmhd.encode.bytes=8,r},n.vmhd.decode=function(e,t){return e=e.slice(t),{graphicsMode:e.readUInt16BE(0),opcolor:[e.readUInt16BE(2),e.readUInt16BE(4),e.readUInt16BE(6)]}},n.vmhd.encodingLength=function(e){return 8},n.smhd={},n.smhd.encode=function(e,o,i){return o=o?o.slice(i):new t(4),o.writeUInt16BE(e.balance||0,0),r(o,2,4),n.smhd.encode.bytes=4,o},n.smhd.decode=function(e,t){return e=e.slice(t),{balance:e.readUInt16BE(0)}},n.smhd.encodingLength=function(e){return 4},n.stsd={},n.stsd.encode=function(e,r,o){r=r?r.slice(o):new t(n.stsd.encodingLength(e));var i=e.entries||[];r.writeUInt32BE(i.length,0);for(var s=4,a=0;a<i.length;a++){var c=i[a];p.encode(c,r,s),s+=p.encode.bytes}return n.stsd.encode.bytes=s,r},n.stsd.decode=function(e,t,n){e=e.slice(t);for(var r=e.readUInt32BE(0),o=new Array(r),i=4,s=0;r>s;s++){var a=p.decode(e,i,n);o[s]=a,i+=a.length}return{entries:o}},n.stsd.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var n=0;n<e.entries.length;n++)t+=p.encodingLength(e.entries[n]);return t},n.avc1=n.VisualSampleEntry={},n.VisualSampleEntry.encode=function(e,o,i){o=o?o.slice(i):new t(n.VisualSampleEntry.encodingLength(e)),r(o,0,6),o.writeUInt16BE(e.dataReferenceIndex||0,6),r(o,8,24),o.writeUInt16BE(e.width||0,24),o.writeUInt16BE(e.height||0,26),o.writeUInt32BE(e.hResolution||4718592,28),o.writeUInt32BE(e.vResolution||4718592,32),r(o,36,40),o.writeUInt16BE(e.frameCount||1,40);var s=e.compressorName||"",a=Math.min(s.length,31);o.writeUInt8(a,42),o.write(s,43,a,"utf8"),o.writeUInt16BE(e.depth||24,74),o.writeInt16BE(-1,76);var c=78,u=e.children||[];u.forEach(function(e){p.encode(e,o,c),c+=p.encode.bytes}),n.VisualSampleEntry.encode.bytes=c},n.VisualSampleEntry.decode=function(e,t,n){e=e.slice(t);for(var r=n-t,o=Math.min(e.readUInt8(42),31),i={dataReferenceIndex:e.readUInt16BE(6),width:e.readUInt16BE(24),height:e.readUInt16BE(26),hResolution:e.readUInt32BE(28),vResolution:e.readUInt32BE(32),frameCount:e.readUInt16BE(40),compressorName:e.toString("utf8",43,43+o),depth:e.readUInt16BE(74),children:[]},s=78;r-s>=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,c=s.DecoderSpecificInfo||{},u=c?(248&c.buffer.readUInt8(0))>>3:0,f=null;return a&&(f=a.toString(16),u&&(f+="."+u)),{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;s<i.length;s++)r.writeUInt32BE(i[s],4*s+8);return n.stsz.encode.bytes=8+4*i.length,r},n.stsz.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=e.readUInt32BE(4),o=new Array(r),i=0;r>i;i++)0===n?o[i]=e.readUInt32BE(4*i+8):o[i]=n;return{entries:o}},n.stsz.encodingLength=function(e){return 8+4*e.entries.length},n.stss=n.stco={},n.stco.encode=function(e,r,o){var i=e.entries||[];r=r?r.slice(o):new t(n.stco.encodingLength(e)),r.writeUInt32BE(i.length,0);for(var s=0;s<i.length;s++)r.writeUInt32BE(i[s],4*s+4);return n.stco.encode.bytes=4+4*i.length,r},n.stco.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=new Array(n),o=0;n>o;o++)r[o]=e.readUInt32BE(4*o+4);return{entries:r}},n.stco.encodingLength=function(e){return 4+4*e.entries.length},n.stts={},n.stts.encode=function(e,r,o){var i=e.entries||[];r=r?r.slice(o):new t(n.stts.encodingLength(e)),r.writeUInt32BE(i.length,0);for(var s=0;s<i.length;s++){var a=8*s+4;r.writeUInt32BE(i[s].count||0,a),r.writeUInt32BE(i[s].duration||0,a+4)}return n.stts.encode.bytes=4+8*e.entries.length,
r},n.stts.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=new Array(n),o=0;n>o;o++){var i=8*o+4;r[o]={count:e.readUInt32BE(i),duration:e.readUInt32BE(i+4)}}return{entries:r}},n.stts.encodingLength=function(e){return 4+8*e.entries.length},n.ctts={},n.ctts.encode=function(e,r,o){var i=e.entries||[];r=r?r.slice(o):new t(n.ctts.encodingLength(e)),r.writeUInt32BE(i.length,0);for(var s=0;s<i.length;s++){var a=8*s+4;r.writeUInt32BE(i[s].count||0,a),r.writeUInt32BE(i[s].compositionOffset||0,a+4)}return n.ctts.encode.bytes=4+8*i.length,r},n.ctts.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=new Array(n),o=0;n>o;o++){var i=8*o+4;r[o]={count:e.readUInt32BE(i),compositionOffset:e.readInt32BE(i+4)}}return{entries:r}},n.ctts.encodingLength=function(e){return 4+8*e.entries.length},n.stsc={},n.stsc.encode=function(e,r,o){var i=e.entries||[];r=r?r.slice(o):new t(n.stsc.encodingLength(e)),r.writeUInt32BE(i.length,0);for(var s=0;s<i.length;s++){var a=12*s+4;r.writeUInt32BE(i[s].firstChunk||0,a),r.writeUInt32BE(i[s].samplesPerChunk||0,a+4),r.writeUInt32BE(i[s].sampleDescriptionId||0,a+8)}return n.stsc.encode.bytes=4+12*i.length,r},n.stsc.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=new Array(n),o=0;n>o;o++){var i=12*o+4;r[o]={firstChunk:e.readUInt32BE(i),samplesPerChunk:e.readUInt32BE(i+4),sampleDescriptionId:e.readUInt32BE(i+8)}}return{entries:r}},n.stsc.encodingLength=function(e){return 4+12*e.entries.length},n.dref={},n.dref.encode=function(e,r,o){r=r?r.slice(o):new t(n.dref.encodingLength(e));var i=e.entries||[];r.writeUInt32BE(i.length,0);for(var s=4,a=0;a<i.length;a++){var c=i[a],u=(c.buf?c.buf.length:0)+4+4;r.writeUInt32BE(u,s),s+=4,r.write(c.type,s,4,"ascii"),s+=4,c.buf&&(c.buf.copy(r,s),s+=c.buf.length)}return n.dref.encode.bytes=s,r},n.dref.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=new Array(n),o=4,i=0;n>i;i++){var s=e.readUInt32BE(o),a=e.toString("ascii",o+4,o+8),c=e.slice(o+8,o+s);o+=s,r[i]={type:a,buf:c}}return{entries:r}},n.dref.encodingLength=function(e){var t=4;if(!e.entries)return t;for(var n=0;n<e.entries.length;n++){var r=e.entries[n].buf;t+=(r?r.length:0)+4+4}return t},n.elst={},n.elst.encode=function(e,r,o){var s=e.entries||[];r=r?r.slice(o):new t(n.elst.encodingLength(e)),r.writeUInt32BE(s.length,0);for(var a=0;a<s.length;a++){var c=12*a+4;r.writeUInt32BE(s[a].trackDuration||0,c),r.writeUInt32BE(s[a].mediaTime||0,c+4),i(s[a].mediaRate||0,r,c+8)}return n.elst.encode.bytes=4+12*s.length,r},n.elst.decode=function(e,t){e=e.slice(t);for(var n=e.readUInt32BE(0),r=new Array(n),o=0;n>o;o++){var i=12*o+4;r[o]={trackDuration:e.readUInt32BE(i),mediaTime:e.readInt32BE(i+4),mediaRate:d(e,i+8)}}return{entries:r}},n.elst.encodingLength=function(e){return 4+12*e.entries.length},n.hdlr={},n.hdlr.encode=function(e,r,o){r=r?r.slice(o):new t(n.hdlr.encodingLength(e));var i=21+(e.name||"").length;return r.fill(0,0,i),r.write(e.handlerType||"",4,4,"ascii"),c(e.name||"",r,20),n.hdlr.encode.bytes=i,r},n.hdlr.decode=function(e,t,n){return e=e.slice(t),{handlerType:e.toString("ascii",4,8),name:l(e,20,n)}},n.hdlr.encodingLength=function(e){return 21+(e.name||"").length},n.mehd={},n.mehd.encode=function(e,r,o){return r=r?r.slice(o):new t(4),r.writeUInt32BE(e.fragmentDuration||0,0),n.mehd.encode.bytes=4,r},n.mehd.decode=function(e,t){return e=e.slice(t),{fragmentDuration:e.readUInt32BE(0)}},n.mehd.encodingLength=function(e){return 4},n.trex={},n.trex.encode=function(e,r,o){return r=r?r.slice(o):new t(20),r.writeUInt32BE(e.trackId||0,0),r.writeUInt32BE(e.defaultSampleDescriptionIndex||0,4),r.writeUInt32BE(e.defaultSampleDuration||0,8),r.writeUInt32BE(e.defaultSampleSize||0,12),r.writeUInt32BE(e.defaultSampleFlags||0,16),n.trex.encode.bytes=20,r},n.trex.decode=function(e,t){return e=e.slice(t),{trackId:e.readUInt32BE(0),defaultSampleDescriptionIndex:e.readUInt32BE(4),defaultSampleDuration:e.readUInt32BE(8),defaultSampleSize:e.readUInt32BE(12),defaultSampleFlags:e.readUInt32BE(16)}},n.trex.encodingLength=function(e){return 20},n.mfhd={},n.mfhd.encode=function(e,r,o){return r=r?r.slice(o):new t(4),r.writeUInt32BE(e.sequenceNumber||0,0),n.mfhd.encode.bytes=4,r},n.mfhd.decode=function(e,t){return{sequenceNumber:e.readUint32BE(0)}},n.mfhd.encodingLength=function(e){return 4},n.tfhd={},n.tfhd.encode=function(e,r,o){return r=r?r.slice(o):new t(4),r.writeUInt32BE(e.trackId,0),n.tfhd.encode.bytes=4,r},n.tfhd.decode=function(e,t){},n.tfhd.encodingLength=function(e){return 4},n.tfdt={},n.tfdt.encode=function(e,r,o){return r=r?r.slice(o):new t(4),r.writeUInt32BE(e.baseMediaDecodeTime||0,0),n.tfdt.encode.bytes=4,r},n.tfdt.decode=function(e,t){},n.tfdt.encodingLength=function(e){return 4},n.trun={},n.trun.encode=function(e,r,o){r=r?r.slice(o):new t(8+16*e.entries.length),r.writeUInt32BE(e.entries.length,0),r.writeInt32BE(e.dataOffset,4);for(var i=8,s=0;s<e.entries.length;s++){var a=e.entries[s];r.writeUInt32BE(a.sampleDuration,i),i+=4,r.writeUInt32BE(a.sampleSize,i),i+=4,r.writeUInt32BE(a.sampleFlags,i),i+=4,r.writeUInt32BE(a.sampleCompositionTimeOffset,i),i+=4}n.trun.encode.bytes=i},n.trun.decode=function(e,t){},n.trun.encodingLength=function(e){return 8+16*e.entries.length},n.mdat={},n.mdat.encode=function(e,t,r){e.buffer?(e.buffer.copy(t,r),n.mdat.encode.bytes=e.buffer.length):n.mdat.encode.bytes=n.mdat.encodingLength(e)},n.mdat.decode=function(e,n,r){return{buffer:new t(e.slice(n,r))}},n.mdat.encodingLength=function(e){return e.buffer?e.buffer.length:e.contentLength}}).call(this,e("buffer").Buffer)},{"./descriptor":117,"./index":118,buffer:25}],117:[function(e,t,n){(function(e){var t={3:"ESDescriptor",4:"DecoderConfigDescriptor",5:"DecoderSpecificInfo",6:"SLConfigDescriptor"};n.Descriptor={},n.Descriptor.decode=function(r,o,i){var s,a=r.readUInt8(o),c=o+1,u=0;do s=r.readUInt8(c++),u=u<<7|127&s;while(128&s);var f,d=t[a];return f=n[d]?n[d].decode(r,c,i):{buffer:new e(r.slice(c,c+u))},f.tag=a,f.tagName=d,f.length=c-o+u,f.contentsLen=u,f},n.DescriptorArray={},n.DescriptorArray.decode=function(e,r,o){for(var i=r,s={};o>=i+2;){var a=n.Descriptor.decode(e,i,o);i+=a.length;var c=t[a.tag]||"Descriptor"+a.tag;s[c]=a}return s},n.ESDescriptor={},n.ESDescriptor.decode=function(e,t,r){var o=e.readUInt8(t+2),i=t+3;if(128&o&&(i+=2),64&o){var s=e.readUInt8(i);i+=s+1}return 32&o&&(i+=2),n.DescriptorArray.decode(e,i,r)},n.DecoderConfigDescriptor={},n.DecoderConfigDescriptor.decode=function(e,t,r){var o=e.readUInt8(t),i=n.DescriptorArray.decode(e,t+13,r);return i.oti=o,i}}).call(this,e("buffer").Buffer)},{buffer:25}],118:[function(e,t,n){(function(t){var r=e("uint64be"),o=e("./boxes"),i=4294967295,s=n,a=n.containers={moov:["mvhd","meta","traks","mvex"],trak:["tkhd","tref","trgr","edts","meta","mdia","udta"],edts:["elst"],mdia:["mdhd","hdlr","elng","minf"],minf:["vmhd","smhd","hmhd","sthd","nmhd","dinf","stbl"],dinf:["dref"],stbl:["stsd","stts","ctts","cslg","stsc","stsz","stz2","stco","co64","stss","stsh","padb","stdp","sdtp","sbgps","sgpds","subss","saizs","saios"],mvex:["mehd","trexs","leva"],moof:["mfhd","meta","trafs"],traf:["tfhd","trun","sbgps","sgpds","subss","saizs","saios","tfdt","meta"]};s.encode=function(e,n,r){return s.encodingLength(e),r=r||0,n=n||new t(e.length),s._encode(e,n,r)},s._encode=function(e,t,n){var c=e.type,u=e.length;u>i&&(u=1),t.writeUInt32BE(u,n),t.write(e.type,n+4,4,"ascii");var f=n+8;if(1===u&&(r.encode(e.length,t,f),f+=8),o.fullBoxes[c]&&(t.writeUInt32BE(e.flags||0,f),t.writeUInt8(e.version||0,f),f+=4),a[c]){var d=a[c];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[c]){var h=o[c].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'"+c+"') 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,8>n-t)return 8;var i=e.readUInt32BE(t),s=e.toString("ascii",t+4,t+8),a=t+8;if(1===i){if(16>n-t)return 16;i=r.decode(e,a),a+=8}var c,u;return o.fullBoxes[s]&&(c=e.readUInt8(a),u=16777215&e.readUInt32BE(a),a+=4),{length:i,headersLen:a-t,contentLen:i-(a-t),type:s,version:c,flags:u}},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 c=e.type,u={};if(a[c]){u.otherBoxes=[];for(var f=a[c],d=r;i-d>=8;){var h=s.decode(n,d,i);if(d+=h.length,f.indexOf(h.type)>=0)u[h.type]=h;else if(f.indexOf(h.type+"s")>=0){var l=h.type+"s",p=u[l]=u[l]||[];p.push(h)}else u.otherBoxes.push(h)}}else if(o[c]){var m=o[c].decode;u=m(n,r,i)}else u.buffer=new t(n.slice(r,i));return u.length=e.length,u.contentLen=e.contentLen,u.type=e.type,u.version=e.version,u.flags=e.flags,u},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":116,buffer:25,uint64be:119}],119:[function(e,t,n){(function(e){var t=4294967295;n.encodingLength=function(){return 8},n.encode=function(n,r,o){r||(r=new e(8)),o||(o=0);var i=Math.floor(n/t),s=n-i*t;return r.writeUInt32BE(i,o),r.writeUInt32BE(s,o+4),r},n.decode=function(n,r){r||(r=0),n||(n=new e(4)),r||(r=0);var o=n.readUInt32BE(r),i=n.readUInt32BE(r+4);return o*t+i},n.encode.bytes=8,n.decode.bytes=8}).call(this,e("buffer").Buffer)},{buffer:25}],120:[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"),c=e("mp4-box-encoding"),u=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.length<this._missing?e.length:this._missing;if(this._buf?e.copy(this._buf,this._buf.length-this._missing):this._str&&(r=this._str.write(o===e.length?e:e.slice(0,o))),this._missing-=o,!this._missing){var i=this._buf,s=this._cb,a=this._str;this._buf=this._cb=this._str=this._ondrain=null,r=!0,a&&a.end(),s&&s(i)}e=o===e.length?u:e.slice(o)}return this._pending&&!this._missing?(this._writeBuffer=e,void(this._writeCb=n)):void(r?n():this._ondrain(n))}},r.prototype._buffer=function(e,t){this._missing=e,this._buf=new n(e),this._cb=t},r.prototype._stream=function(e,t){var n=this;return this._missing=e,this._str=new o(this),this._ondrain=a(this._str,"drain"),this._pending++,this._str.on("end",function(){n._pending--,n._kick()}),this._cb=t,this._str},r.prototype._readBox=function(){function e(r,o){t._buffer(r,function(r){o=o?n.concat(o,r):r;var i=c.readHeaders(o);"number"==typeof i?e(i-o.length,o):(t._pending++,t._headers=i,t.emit("box",i))})}var t=this;e(8)},r.prototype.stream=function(){var e=this;if(!e._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=e._headers;return e._headers=null,e._stream(t.contentLen,null)},r.prototype.decode=function(e){var t=this;if(!t._headers)throw new Error("this function can only be called once after 'box' is emitted");var n=t._headers;t._headers=null,t._buffer(n.contentLen,function(r){var o=c.decodeWithoutHeaders(n,r);e(o),t._pending--,t._kick()})},r.prototype.ignore=function(){var e=this;if(!e._headers)throw new Error("this function can only be called once after 'box' is emitted");var t=e._headers;e._headers=null,this._missing=t.contentLen,this._cb=function(){e._pending--,e._kick()}},r.prototype._kick=function(){if(!this._pending&&(this._buf||this._str||this._readBox(),this._writeBuffer)){var e=this._writeCb,t=this._writeBuffer;this._writeBuffer=null,this._writeCb=null,this._write(t,null,e)}},s(o,i.PassThrough),o.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}).call(this,e("buffer").Buffer)},{buffer:25,inherits:76,"mp4-box-encoding":118,"next-event":123,"readable-stream":106}],121:[function(e,t,n){(function(n,r){function o(){}function i(){function e(){n._want&&(n._want=!1,n._read())}function t(){n._stream=null}if(!(this instanceof i))return new i;a.Readable.call(this),this.destroyed=!1,this._reading=!1,this._stream=null,this._drain=null,this._want=!1,this._onreadable=e,this._onend=t;var n=this}function s(e){this._parent=e,this.destroyed=!1,a.PassThrough.call(this)}var a=e("readable-stream"),c=e("inherits"),u=e("mp4-box-encoding");t.exports=i,c(i,a.Readable),i.prototype.mediaData=i.prototype.mdat=function(e,t){var n=new s(this);return this.box({type:"mdat",contentLength:e,encodeBufferLen:8,stream:n},t),n},i.prototype.box=function(e,t){if(t||(t=o),this.destroyed)return t(new Error("Encoder is destroyed"));var i;if(e.encodeBufferLen&&(i=new r(e.encodeBufferLen)),e.stream)e.buffer=null,i=u.encode(e,i),this.push(i),this._stream=e.stream,this._stream.on("readable",this._onreadable),this._stream.on("end",this._onend),this._stream.on("end",t),this._forward();else{i=u.encode(e,i);var s=this.push(i);if(s)return n.nextTick(t);this._drain=t}},i.prototype.destroy=function(e){if(!this.destroyed){if(this.destroyed=!0,this._stream&&this._stream.destroy&&this._stream.destroy(),this._stream=null,this._drain){var t=this._drain;this._drain=null,t(e)}e&&this.emit("error",e),this.emit("close")}},i.prototype.finalize=function(){this.push(null)},i.prototype._forward=function(){if(this._stream)for(;!this.destroyed;){var e=this._stream.read();if(!e)return void(this._want=!!this._stream);if(!this.push(e))return}},i.prototype._read=function(){if(!this._reading&&!this.destroyed){if(this._reading=!0,this._stream&&this._forward(),this._drain){var e=this._drain;this._drain=null,e()}this._reading=!1}},c(s,a.PassThrough),s.prototype.destroy=function(e){this.destroyed||(this.destroyed=!0,this._parent.destroy(e),e&&this.emit("error",e),this.emit("close"))}}).call(this,e("_process"),e("buffer").Buffer)},{_process:33,buffer:25,inherits:76,"mp4-box-encoding":118,"readable-stream":106}],122:[function(e,t,n){n.decode=e("./decode"),n.encode=e("./encode")},{"./decode":120,"./encode":121}],123:[function(e,t,n){function r(e,t){var n=null;return e.on(t,function(e){if(n){var t=n;n=null,t(e)}}),function(e){n=e}}t.exports=r},{}],124:[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 c;if(a>e.length){r._position+=e.length,c=0===s?e:e.slice(s),o=i.stream.write(c)&&o;break}r._position+=a,c=0===s&&a===e.length?e:e.slice(s,a),o=i.stream.write(c)&&o,i.last&&i.stream.end(),e=e.slice(a),r._queue.shift()}o?n(null):i.stream.once("drain",n.bind(null,null))},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:76,"readable-stream":106}],125:[function(e,t,n){function r(e,t,n){var i=this;return this instanceof r?(n=n||{},i._elem=t,i._elemWrapper=new o(t),i._waitingFired=!1,i._trackMeta=null,i._file=e,i._tracks=null,"none"!==i._elem.preload&&i._createMuxer(),i._onError=function(e){i.destroy()},i._onWaiting=function(){i._waitingFired=!0,i._muxer?i._tracks&&i._pump():i._createMuxer()},i._elem.addEventListener("waiting",i._onWaiting),void i._elem.addEventListener("error",i._onError)):new r(e,t,n)}var o=e("mediasource"),i=e("pump"),s=e("./mp4-remuxer");t.exports=r,r.prototype._createMuxer=function(){var e=this;e._muxer=new s(e._file),e._muxer.on("ready",function(t){e._tracks=t.map(function(t){var n=e._elemWrapper.createWriteStream(t.mime);return n.on("error",function(t){e._elemWrapper.error(t)}),n.write(t.init),{muxed:null,mediaSource:n}}),(e._waitingFired||"auto"===e._elem.preload)&&e._pump()}),e._muxer.on("error",function(t){e._elemWrapper.error(t)})},r.prototype._pump=function(){var e=this,t=e._muxer.seek(e._elem.currentTime,!e._tracks);e._tracks.forEach(function(n,r){n.muxed&&(n.muxed.destroy(),n.mediaSource=e._elemWrapper.createWriteStream(n.mediaSource),n.mediaSource.on("error",function(t){e._elemWrapper.error(t)})),n.muxed=t[r],i(n.muxed,n.mediaSource)})},r.prototype.destroy=function(){var e=this;e.destroyed||(e.destroyed=!0,e._elem.removeEventListener("waiting",e._onWaiting),e._elem.removeEventListener("error",e._onError),e._tracks&&e._tracks.forEach(function(e){e.muxed.destroy()}),e._elem.src="")}},{"./mp4-remuxer":114,mediasource:112,pump:89}],126:[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===--c||n)o(n);else if(!f&&a>h){var d;u?(d=u[h],h+=1,t[d](i.bind(void 0,d))):(d=h,h+=1,t[d](i.bind(void 0,d)))}}if("number"!=typeof n)throw new Error("second argument must be a Number");var s,a,c,u,f,d=!0;Array.isArray(t)?(s=[],c=a=t.length):(u=Object.keys(t),s={},c=a=u.length);var h=n;c?u?u.some(function(e,r){return t[e](i.bind(void 0,e)),r===n-1?!0:void 0}):t.some(function(e,t){return e(i.bind(void 0,t)),t===n-1?!0:void 0}):o(null),d=!1}}).call(this,e("_process"))},{_process:33}],127:[function(e,t,n){(function(e){t.exports=function(t,n){function r(t){function r(){n&&n(t,i),n=null}c?e.nextTick(r):r()}function o(e,t,n){i[e]=n,(0===--s||t)&&r(t)}var i,s,a,c=!0;Array.isArray(t)?(i=[],s=t.length):(a=Object.keys(t),i={},s=a.length),s?a?a.forEach(function(e){t[e](o.bind(void 0,e))}):t.forEach(function(e,t){e(o.bind(void 0,t))}):r(null),c=!1}}).call(this,e("_process"))},{_process:33}],128:[function(e,t,n){(function(n){function r(e,t){e="string"==typeof e?{url:e}:i(e),t=c(t),e.url&&o(e),null==e.headers&&(e.headers={}),null==e.maxRedirects&&(e.maxRedirects=10);var n=e.body;e.body=void 0,n&&!e.method&&(e.method="POST");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){return n.statusCode>=300&&n.statusCode<400&&"location"in n.headers?(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")))):void t(null,"function"==typeof u?u(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),e.path=t.path,delete e.url}t.exports=r;var i=e("xtend"),s=e("http"),a=e("https"),c=e("once"),u=e("unzip-response"),f=e("url");t.exports.concat=function(e,t){return r(e,function(e,r){if(e)return t(e);var o=[];r.on("data",function(e){o.push(e)}),r.on("end",function(){t(null,r,n.concat(o))})})},["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:25,http:39,https:30,once:130,"unzip-response":24,url:45,xtend:152}],129:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{dup:20}],130:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21,wrappy:129}],131:[function(e,t,n){(function(n){function r(e){var t=this;if(!(t instanceof r))return new r(e);if(t._debug("new peer %o",e),e||(e={}),e.allowHalfOpen=!1,null==e.highWaterMark&&(e.highWaterMark=1048576),f.Duplex.call(t,e),t.initiator=e.initiator||!1,t.channelConfig=e.channelConfig||r.channelConfig,t.channelName=e.initiator?e.channelName||a(160):null,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:!0,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||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");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=t._onIceConnectionStateChange.bind(t),t._pc.onsignalingstatechange=t._onSignalingStateChange.bind(t),t._pc.onicecandidate=t._onIceCandidate.bind(t),t.stream&&t._pc.addStream(t.stream),t._pc.onaddstream=t._onAddStream.bind(t),t.initiator?(t._setupData({channel:t._pc.createDataChannel(t.channelName,t.channelConfig)}),t._pc.onnegotiationneeded=u(t._createOffer.bind(t)),"undefined"!=typeof window&&window.webkitRTCPeerConnection||t._pc.onnegotiationneeded()):t._pc.ondatachannel=t._setupData.bind(t),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("hat"),c=e("inherits"),u=e("once"),f=e("readable-stream");c(r,f.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,n._onError.bind(n))}catch(t){n._destroy(new Error("error adding candidate: "+t.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(r){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=[])},n._onError.bind(n)),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}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=t._onChannelMessage.bind(t),t._channel.onopen=t._onChannelOpen.bind(t),t._channel.onclose=t._onChannelClose.bind(t)},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(o){return r._onError(o)}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,e._onError.bind(e));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)}},e._onError.bind(e),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,e._onError.bind(e));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)}},e._onError.bind(e),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)},t._onError.bind(t)):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(i){return e._onError(i)}e._chunk=null,e._debug('sent chunk from "write before connect"');var s=e._cb;e._cb=null,s(null)}e._interval=setInterval(function(){if(e._cb&&e._channel&&!(e._channel.bufferedAmount>e._maxBufferedAmount)){e._debug("ending backpressure: bufferedAmount %d",e._channel.bufferedAmount);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._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:25,debug:68,"get-browser-rtc":132,hat:74,inherits:76,once:134,"readable-stream":106}],132:[function(e,t,n){t.exports=function(){if("undefined"==typeof window)return null;var e={RTCPeerConnection:window.RTCPeerConnection||window.mozRTCPeerConnection||window.webkitRTCPeerConnection,RTCSessionDescription:window.RTCSessionDescription||window.mozRTCSessionDescription||window.webkitRTCSessionDescription,RTCIceCandidate:window.RTCIceCandidate||window.mozRTCIceCandidate||window.webkitRTCIceCandidate};return e.RTCPeerConnection?e:null}},{}],133:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{dup:20}],134:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21,wrappy:133}],135:[function(e,t,n){function r(e,t){return u?("string"==typeof e&&(e=o(e)),void u.digest({name:"sha-1"},e).then(function(e){t(i(new Uint8Array(e)))},function(n){t(f(e))})):void setTimeout(t,0,f(e))}function o(e){for(var t=e.length,n=new Uint8Array(t),r=0;t>r;r++)n[r]=e.charCodeAt(r);return n}function i(e){for(var t=e.length,n=[],r=0;t>r;r++){var o=e[r];n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")}var s=e("rusha"),a=new s,c=window.crypto||window.msCrypto||{},u=c.subtle||c.webkitSubtle,f=a.digest.bind(a);try{u.digest({name:"sha-1"},new Uint8Array)["catch"](function(){u=!1})}catch(d){u=!1}t.exports=r,t.exports.sync=f},{rusha:136}],136:[function(e,t,n){(function(e){!function(){function n(e){"use strict";var t={fill:0},i=function(e){for(e+=9;e%64>0;e+=1);return e},s=function(e,t){for(var n=t>>2;n<e.length;n++)e[n]=0},a=function(e,t,n){e[t>>2]|=128<<24-(t%4<<3),e[((t>>2)+2&-16)+14]=n>>29,e[((t>>2)+2&-16)+15]=n<<3},c=function(e,t,n,r,o){var i,s=this,a=o%4,c=r%4,u=r-c;if(u>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;u>i;i=i+4|0)t[o+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(c){case 3:e[o+u+1|0]=s.charCodeAt(n+u+2);case 2:e[o+u+2|0]=s.charCodeAt(n+u+1);case 1:e[o+u+3|0]=s.charCodeAt(n+u)}},u=function(e,t,n,r,o){var i,s=this,a=o%4,c=r%4,u=r-c;if(u>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;u>i;i=i+=4)t[o+i>>2]=s[n+i]<<24|s[n+i+1]<<16|s[n+i+2]<<8|s[n+i+3];switch(c){case 3:e[o+u+1|0]=s[n+u+2];case 2:e[o+u+2|0]=s[n+u+1];case 1:e[o+u+3|0]=s[n+u]}},f=function(e,t,n,r,i){var s,a=this,c=i%4,u=r%4,f=r-u,d=new Uint8Array(o.readAsArrayBuffer(a.slice(n,n+r)));if(f>0)switch(c){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-c;f>s;s=s+=4)t[i+s>>2]=d[s]<<24|d[s+1]<<16|d[s+2]<<8|d[s+3];switch(u){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 c.bind(e);case"array":return u.bind(e);case"buffer":return u.bind(e);case"arraybuffer":return u.bind(new Uint8Array(e));case"view":return u.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return f.bind(e)}},h=function(e){var t,n,r="0123456789abcdef",o=[],i=new Uint8Array(e);for(t=0;t<i.length;t++)n=i[t],o[t]=r.charAt(n>>4&15)+r.charAt(n>>0&15);return o.join("")},l=function(e){var t;if(65536>=e)return 65536;if(16777216>e)for(t=1;e>t;t<<=1);else for(t=16777216;e>t;t+=16777216);return t},p=function(e){if(e%64>0)throw new Error("Chunk size must be a multiple of 128 bit");t.maxChunkLen=e,t.padMaxChunkLen=i(e),t.heap=new ArrayBuffer(l(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};p(e||65536);var m=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},g=function(e,n){var r=i(e),o=new Int32Array(t.heap,0,r>>2);return s(o,e),a(o,e,n),r},y=function(e,n,r){d(e)(t.h8,t.h32,n,r,0)},_=function(e,n,r,o,i){var s=r;i&&(s=g(r,o)),y(e,n,r),t.core.hash(s,t.padMaxChunkLen)},v=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},b=this.rawDigest=function(e){var n=e.byteLength||e.length||e.size||0;m(t.heap,t.padMaxChunkLen);var r=0,o=t.maxChunkLen;for(r=0;n>r+o;r+=o)_(e,r,o,n,!1);return _(e,r,n-r,n,!0),v(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return h(b(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 s(e,t,n){"use asm";var r=new e.Int32Array(n);function o(e,t){e=e|0;t=t|0;var n=0,o=0,i=0,s=0,a=0,c=0,u=0,f=0,d=0,h=0,l=0,p=0,m=0,g=0;i=r[t+320>>2]|0;a=r[t+324>>2]|0;u=r[t+328>>2]|0;d=r[t+332>>2]|0;l=r[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){s=i;c=a;f=u;h=d;p=l;for(o=0;(o|0)<64;o=o+4|0){g=r[n+o>>2]|0;m=((i<<5|i>>>27)+(a&u|~a&d)|0)+((g+l|0)+1518500249|0)|0;l=d;d=u;u=a<<30|a>>>2;a=i;i=m;r[e+o>>2]=g}for(o=e+64|0;(o|0)<(e+80|0);o=o+4|0){g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31;m=((i<<5|i>>>27)+(a&u|~a&d)|0)+((g+l|0)+1518500249|0)|0;l=d;d=u;u=a<<30|a>>>2;a=i;i=m;r[o>>2]=g}for(o=e+80|0;(o|0)<(e+160|0);o=o+4|0){g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31;m=((i<<5|i>>>27)+(a^u^d)|0)+((g+l|0)+1859775393|0)|0;l=d;d=u;u=a<<30|a>>>2;a=i;i=m;r[o>>2]=g}for(o=e+160|0;(o|0)<(e+240|0);o=o+4|0){g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31;m=((i<<5|i>>>27)+(a&u|a&d|u&d)|0)+((g+l|0)-1894007588|0)|0;l=d;d=u;u=a<<30|a>>>2;a=i;i=m;r[o>>2]=g}for(o=e+240|0;(o|0)<(e+320|0);o=o+4|0){g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31;m=((i<<5|i>>>27)+(a^u^d)|0)+((g+l|0)-899497514|0)|0;l=d;d=u;u=a<<30|a>>>2;a=i;i=m;r[o>>2]=g}i=i+s|0;a=a+c|0;u=u+f|0;d=d+h|0;l=l+p|0}r[t+320>>2]=i;r[t+324>>2]=a;r[t+328>>2]=u;r[t+332>>2]=d;r[t+336>>2]=l}return{hash:o}},"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(r){self.postMessage({id:e.data.id,error:r.name})}}}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],137:[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 c=r-a&o;for(c>t&&(c=t),a=r;c--;)s===t&&(s=0),n[s]=n[0===s?t-1:s-1],s++;e&&(n[s-1]+=e);var u=n[s-1],f=n.length<t?0:n[s===t?0:s];return n.length<i?u:(u-f)*i/n.length}}},{}],138:[function(e,t,n){var r=e("once");t.exports=function(e,t,n){n=r(n);var o=[];e.on("data",function(e){o.push(e)}).on("end",function(){var e=t?new Blob(o,{type:t}):new Blob(o),r=URL.createObjectURL(e);n(null,r)}).on("error",n)}},{once:140}],139:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{dup:20}],140:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21,wrappy:139}],141:[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:25,once:143}],142:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{dup:20}],143:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21,wrappy:142}],144:[function(e,t,n){(function(n,r){function o(e){function t(e,t){i._internalDHT=!0;var n=new s(t);return d(n,i,["warning","error"]),n.listen(e),n}function r(e,t){t.toString("hex")===i.infoHash&&i.emit("peer",e.host+":"+e.port)}var i=this;if(!(i instanceof o))return new o(e);if(a.call(i),i.peerId=e.peerId,i.port=e.port||0,!i.peerId)throw new Error("peerId required");if(!n.browser&&!i.port)throw new Error("port required");i.announce=e.announce||[],i._intervalMs=e.intervalMs||9e5,i.destroyed=!1,i.infoHash=null,i.infoHashBuffer=null,i.torrent=null,i._dhtAnnouncing=!1,i._dhtTimeout=!1,i._internalDHT=!1,e.tracker===!1?i.tracker=!1:(i.tracker=!0,i._trackerOpts=e.tracker||{}),e.dht===!1||"function"!=typeof s?i.dht=!1:e.dht&&"function"==typeof e.dht.announce&&"function"==typeof e.dht.addNode?i.dht=e.dht:"object"==typeof e.dht?i.dht=t(e.dhtPort,e.dht):i.dht=t(e.dhtPort),i.dht&&i.dht.on("peer",r)}t.exports=o;var i=e("debug")("torrent-discovery"),s=e("bittorrent-dht/client"),a=e("events").EventEmitter,c=e("xtend"),u=e("inherits"),f=e("run-parallel"),d=e("re-emitter"),h=e("bittorrent-tracker/client");u(o,a),o.prototype.setTorrent=function(e){var t=this;if(t.infoHash||"string"!=typeof e&&!r.isBuffer(e)){if(t.torrent||!e||!e.infoHash)return;t.torrent=e,t.infoHash="string"==typeof e.infoHash?e.infoHash:e.infoHash.toString("hex")}else t.infoHash="string"==typeof e?e:e.toString("hex");t.infoHashBuffer=new r(t.infoHash,"hex"),i("setTorrent %s",t.infoHash),t.tracker&&t.tracker!==!0?t.tracker.torrentLength=e.length:t._createTracker(),t._dhtAnnounce()},o.prototype.updatePort=function(e){var t=this;e!==t.port&&(t.port=e,t._dhtAnnounce(),t.tracker&&t.tracker!==!0&&(t.tracker.stop(),t.tracker.destroy(function(){t._createTracker()})))},o.prototype.stop=function(e){var t=this;t.destroyed=!0,clearTimeout(t._dhtTimeout);var n=[];t.tracker&&t.tracker!==!0&&(t.tracker.stop(),n.push(function(e){t.tracker.destroy(e)})),t._internalDHT&&n.push(function(e){t.dht.destroy(e)}),f(n,e)},o.prototype._createTracker=function(){function e(e){t.emit("trackerAnnounce",e)}var t=this;if(t.tracker){var n=t.torrent?c({announce:[]},t.torrent):{infoHash:t.infoHash,announce:[]};t.announce&&(n.announce=n.announce.concat(t.announce)),t.tracker=new h(t.peerId,t.port,n,t._trackerOpts),d(t.tracker,t,["peer","warning","error"]),t.tracker.setInterval(t._intervalMs),t.tracker.on("update",e),t.tracker.start()}},o.prototype._dhtAnnounce=function(){function e(){return t._intervalMs+Math.floor(Math.random()*t._intervalMs/5)}var t=this;t.port&&t.infoHash&&t.dht&&!t._dhtAnnouncing&&(i("dht announce"),t._dhtAnnouncing=!0,clearTimeout(t._dhtTimeout),t.dht.announce(t.infoHash,t.port,function(n){t._dhtAnnouncing=!1,i("dht announce complete"),n&&t.emit("warning",n),t.emit("dhtAnnounce"),t.destroyed||(t._dhtTimeout=setTimeout(function(){t._dhtAnnounce()},e()))}))}}).call(this,e("_process"),e("buffer").Buffer)},{_process:33,"bittorrent-dht/client":24,"bittorrent-tracker/client":16,buffer:25,debug:68,events:29,inherits:76,"re-emitter":93,"run-parallel":127,xtend:152}],145:[function(e,t,n){(function(e){function n(e){return this instanceof n?(this.length=e,this.missing=e,this.sources=null,this._chunks=Math.ceil(e/r),this._remainder=e%r||r,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,void(this._flushed=!1)):new n(e)}t.exports=n;var r=16384;n.BLOCK_LENGTH=r,n.prototype.chunkLength=function(e){return e===this._chunks-1?this._remainder:r},n.prototype.chunkLengthRemaining=function(e){return this.length-e*r},n.prototype.chunkOffset=function(e){return e*r},n.prototype.reserve=function(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1},n.prototype.reserveRemaining=function(){if(!this.init())return-1;if(this._reservations<this._chunks){var e=this._reservations;return this._reservations=this._chunks,e}return-1},n.prototype.cancel=function(e){this.init()&&this._cancellations.push(e)},n.prototype.cancelRemaining=function(e){this.init()&&(this._reservations=e)},n.prototype.get=function(e){return this.init()?this._buffer[e]:null},n.prototype.set=function(e,t,n){if(!this.init())return!1;for(var o=t.length,i=Math.ceil(o/r),s=0;i>s;s++)if(!this._buffer[e+s]){var a=s*r,c=t.slice(a,a+r);this._buffered++,this._buffer[e+s]=c,this.missing-=c.length,-1===this.sources.indexOf(n)&&this.sources.push(n)}return this._buffered===this._chunks},n.prototype.flush=function(){if(!this._buffer||this._chunks!==this._buffered)return null;var t=e.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,t},n.prototype.init=function(){return this._flushed?!1:this._buffer?!0:(this._buffer=new Array(this._chunks),this._cancellations=[],this.sources=[],!0)}}).call(this,e("buffer").Buffer)},{buffer:25}],146:[function(e,t,n){"use strict";function r(e,t){for(var n=1,r=e.length,o=e[0],i=e[0],s=1;r>s;++s)if(i=o,o=e[s],t(o,i)){if(s===n){n++;continue}e[n++]=o}return e.length=n,e}function o(e){for(var t=1,n=e.length,r=e[0],o=e[0],i=1;n>i;++i,o=r)if(o=r,r=e[i],r!==o){if(i===t){t++;continue}e[t++]=r}return e.length=t,e}function i(e,t,n){return 0===e.length?e:t?(n||e.sort(t),r(e,t)):(n||e.sort(),o(e))}t.exports=i},{}],147:[function(e,t,n){(function(n){var r=e("bencode"),o=e("bitfield"),i=e("debug")("ut_metadata"),s=e("events").EventEmitter,a=e("inherits"),c=e("simple-sha1"),u=1e7,f=1e3,d=16384;t.exports=function(e){function t(t){s.call(this),this._wire=t,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._fetching=!1,this._bitfield=new o(0,{grow:f}),n.isBuffer(e)&&this.setMetadata(e)}return a(t,s),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?e.metadata_size>u?this.emit("warning",new Error("Peer gave maliciously large metadata size")):(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/d),this._remainingRejects=2*this._numPieces,void(this._fetching&&this._requestPieces())):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))},t.prototype.onMessage=function(e){var t,n;try{var o=e.toString(),i=o.indexOf("ee")+2;t=r.decode(o.substring(0,i)),n=e.slice(i)}catch(s){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece)}},t.prototype.fetch=function(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())},t.prototype.cancel=function(){this._fetching=!1},t.prototype.setMetadata=function(e){if(this._metadataComplete)return!0;i("set metadata");try{var t=r.decode(e).info;t&&(e=r.encode(t))}catch(n){}return this._infoHash&&this._infoHash!==c.sync(e)?!1:(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",r.encode({info:r.decode(this.metadata)})),!0)},t.prototype._send=function(e,t){var o=r.encode(e);n.isBuffer(t)&&(o=n.concat([o,t])),this._wire.extended("ut_metadata",o)},t.prototype._request=function(e){this._send({msg_type:0,piece:e})},t.prototype._data=function(e,t,n){var r={msg_type:1,piece:e};"number"==typeof n&&(r.total_size=n),this._send(r,t)},t.prototype._reject=function(e){this._send({msg_type:2,piece:e})},t.prototype._onRequest=function(e){if(!this._metadataComplete)return void this._reject(e);var t=e*d,n=t+d;n>this._metadataSize&&(n=this._metadataSize);var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)},t.prototype._onData=function(e,t,n){t.length>d||(t.copy(this.metadata,e*d),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=new n(this._metadataSize);for(var e=0;e<this._numPieces;e++)this._request(e)},t.prototype._checkDone=function(){for(var e=!0,t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}if(e){var n=this.setMetadata(this.metadata);n||this._failedMetadata()}},t.prototype._failedMetadata=function(){this._bitfield=new o(0,{grow:f}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))},t}}).call(this,e("buffer").Buffer)},{bencode:148,bitfield:7,buffer:25,debug:68,events:29,inherits:76,"simple-sha1":135}],148:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./lib/decode":149,"./lib/encode":151,dup:12}],149:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./dict":150,buffer:25,dup:13}],150:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],151:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{buffer:25,dup:15}],152:[function(e,t,n){function r(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var r in n)o.call(n,r)&&(e[r]=n[r])}return e}t.exports=r;var o=Object.prototype.hasOwnProperty},{}],153:[function(e,t,n){function r(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)o.call(n,r)&&(e[r]=n[r])}return e}t.exports=r;var o=Object.prototype.hasOwnProperty},{}],154:[function(e,t,n){t.exports=function r(e,t,n){return void 0===t?function(t,n){return r(e,t,n)}:(void 0===n&&(n="0"),e-=t.toString().length,e>0?new Array(e+(/\./.test(t)?2:1)).join(n)+t:t+"")}},{}],155:[function(e,t,n){t.exports={version:"0.85.2"}},{}],156:[function(e,t,n){(function(n,r,o){function i(e){function t(){s.destroyed||(s.ready=!0,s.emit("ready"))}var s=this;return s instanceof i?(f.call(s),e||(e={}),c.enabled||s.setMaxListeners(0),s.destroyed=!1,s.torrentPort=e.torrentPort||0,s.tracker=void 0!==e.tracker?e.tracker:!0,s._rtcConfig=e.rtcConfig,s._wrtc=e.wrtc||r.WRTC,s.torrents=[],s._downloadSpeed=v(),s._uploadSpeed=v(),s.maxConns=e.maxConns,s.peerId="string"==typeof e.peerId?e.peerId:(e.peerId||new o(S+h(48))).toString("hex"),s.peerIdBuffer=new o(s.peerId,"hex"),s.nodeId="string"==typeof e.nodeId?e.nodeId:e.nodeId&&e.nodeId.toString("hex")||h(160),s.nodeIdBuffer=new o(s.nodeId,"hex"),e.dht!==!1&&"function"==typeof u?(s.dht=new u(d({nodeId:s.nodeId},e.dht)),s.dht.once("error",function(e){s.emit("error",e),s.destroy()}),s.dht.listen(e.dhtPort)):s.dht=!1,c("new webtorrent (peerId %s, nodeId %s)",s.peerId,s.nodeId),void("function"==typeof p?p(e.blocklist,{headers:{"user-agent":"WebTorrent/"+k+" (http://webtorrent.io)"}},function(e,n){return e?s.error("Failed to load blocklist: "+e.message):(s.blocked=n,void t())}):n.nextTick(t))):new i(e)}function s(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}t.exports=i;var a=e("create-torrent"),c=e("debug")("webtorrent"),u=e("bittorrent-dht/client"),f=e("events").EventEmitter,d=e("xtend"),h=e("hat"),l=e("inherits"),p=e("load-ip-set"),m=e("run-parallel"),g=e("parse-torrent"),y=e("path"),_=e("simple-peer"),v=e("speedometer"),b=e("zero-fill"),w=e("./lib/concat-stream"),E=e("./lib/torrent");t.exports.WEBRTC_SUPPORT=_.WEBRTC_SUPPORT;var k=e("./package.json").version,x=k.match(/([0-9]+)/g).slice(0,2).map(b(2)).join(""),S="-WW"+x+"-";l(i,f),Object.defineProperty(i.prototype,"downloadSpeed",{get:function(){return this._downloadSpeed()}}),Object.defineProperty(i.prototype,"uploadSpeed",{get:function(){return this._uploadSpeed()}}),Object.defineProperty(i.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(i.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.downloaded},0)||1;return e/t}}),i.prototype.get=function(e){var t=this;if(e instanceof E)return e;var n;try{n=g(e)}catch(r){}if(!n)return null;if(!n.infoHash)throw new Error("Invalid torrent identifier");for(var o=0,i=t.torrents.length;i>o;o++){var s=t.torrents[o];if(s.infoHash===n.infoHash)return s}return null},i.prototype.add=i.prototype.download=function(e,t,r){function o(){c("on torrent"),"function"==typeof r&&r(s),i.emit("torrent",s)}var i=this;if(i.destroyed)throw new Error("client is destroyed");if("function"==typeof t)return i.add(e,null,t);c("add"),t=t?d(t):{};var s=i.get(e);return s?s.ready?n.nextTick(o):s.once("ready",o):(s=new E(e,i,t),i.torrents.push(s),s.once("error",function(e){i.emit("error",e,s),i.remove(s)}),s.once("listening",function(e){i.emit("listening",e,s)}),s.once("ready",o)),s},i.prototype.seed=function(e,t,n){function r(e){var t=[function(t){e.load(u,t)}];i.dht&&t.push(function(t){e.once("dhtAnnounce",t)}),m(t,function(t){return i.destroyed?void 0:t?i.emit("error",t,e):void o(e)})}function o(e){c("on seed"),"function"==typeof n&&n(e),i.emit("seed",e)}var i=this;if(i.destroyed)throw new Error("client is destroyed");if("function"==typeof t)return i.seed(e,null,t);c("seed"),t=t?d(t):{},"string"==typeof e&&(t.path=y.dirname(e)),t.createdBy||(t.createdBy="WebTorrent/"+x),i.tracker||(t.announce=[]);var u,f=i.add(null,t,r);return Array.isArray(e)||(e=[e]),m(e.map(function(e){return function(t){s(e)?w(e,t):t(null,e)}}),function(e,n){return e?i.emit("error",e,f):void(i.destroyed||a.parseInput(n,t,function(e,r){return e?i.emit("error",e,f):void(i.destroyed||(u=r.map(function(e){return e.getStream}),a(n,t,function(e,t){if(e)return i.emit("error",e,f);if(!i.destroyed){var n=i.get(t);n?(f.destroy(),o(n)):f._onTorrentId(t)}})))}))}),f},i.prototype.remove=function(e,t){var n=this;c("remove");var r=n.get(e);if(!r)throw new Error("No torrent with id "+e);n.torrents.splice(n.torrents.indexOf(r),1),r.destroy(t)},i.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}},i.prototype.destroy=function(e){var t=this;if(t.destroyed)throw new Error("client already destroyed");t.destroyed=!0,c("destroy");var n=t.torrents.map(function(e){return function(n){t.remove(e,n)}});t.dht&&n.push(function(e){t.dht.destroy(e)}),m(n,e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./lib/concat-stream":1,"./lib/torrent":5,"./package.json":155,_process:33,"bittorrent-dht/client":24,buffer:25,"create-torrent":51,debug:68,events:29,hat:74,inherits:76,"load-ip-set":24,"parse-torrent":79,path:32,"run-parallel":127,"simple-peer":131,speedometer:137,xtend:152,"zero-fill":154}]},{},[156])(156)});
+switch(c){case 3:e[o+u+1|0]=s.charCodeAt(n+u+2);case 2:e[o+u+2|0]=s.charCodeAt(n+u+1);case 1:e[o+u+3|0]=s.charCodeAt(n+u)}},u=function(e,t,n,r,o){var i,s=this,a=o%4,c=r%4,u=r-c;if(u>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;u>i;i=i+=4)t[o+i>>2]=s[n+i]<<24|s[n+i+1]<<16|s[n+i+2]<<8|s[n+i+3];switch(c){case 3:e[o+u+1|0]=s[n+u+2];case 2:e[o+u+2|0]=s[n+u+1];case 1:e[o+u+3|0]=s[n+u]}},f=function(e,t,n,r,i){var s,a=this,c=i%4,u=r%4,f=r-u,d=new Uint8Array(o.readAsArrayBuffer(a.slice(n,n+r)));if(f>0)switch(c){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-c;f>s;s=s+=4)t[i+s>>2]=d[s]<<24|d[s+1]<<16|d[s+2]<<8|d[s+3];switch(u){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 c.bind(e);case"array":return u.bind(e);case"buffer":return u.bind(e);case"arraybuffer":return u.bind(new Uint8Array(e));case"view":return u.bind(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));case"blob":return f.bind(e)}},h=function(e){var t,n,r="0123456789abcdef",o=[],i=new Uint8Array(e);for(t=0;t<i.length;t++)n=i[t],o[t]=r.charAt(n>>4&15)+r.charAt(n>>0&15);return o.join("")},l=function(e){var t;if(65536>=e)return 65536;if(16777216>e)for(t=1;e>t;t<<=1);else for(t=16777216;e>t;t+=16777216);return t},p=function(e){if(e%64>0)throw new Error("Chunk size must be a multiple of 128 bit");t.maxChunkLen=e,t.padMaxChunkLen=i(e),t.heap=new ArrayBuffer(l(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};p(e||65536);var m=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},g=function(e,n){var r=i(e),o=new Int32Array(t.heap,0,r>>2);return s(o,e),a(o,e,n),r},y=function(e,n,r){d(e)(t.h8,t.h32,n,r,0)},_=function(e,n,r,o,i){var s=r;i&&(s=g(r,o)),y(e,n,r),t.core.hash(s,t.padMaxChunkLen)},v=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},b=this.rawDigest=function(e){var n=e.byteLength||e.length||e.size||0;m(t.heap,t.padMaxChunkLen);var r=0,o=t.maxChunkLen;for(r=0;n>r+o;r+=o)_(e,r,o,n,!1);return _(e,r,n-r,n,!0),v(t.heap,t.padMaxChunkLen)};this.digest=this.digestFromString=this.digestFromBuffer=this.digestFromArrayBuffer=function(e){return h(b(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 s(e,t,n){"use asm";var r=new e.Int32Array(n);function o(e,t){e=e|0;t=t|0;var n=0,o=0,i=0,s=0,a=0,c=0,u=0,f=0,d=0,h=0,l=0,p=0,m=0,g=0;i=r[t+320>>2]|0;a=r[t+324>>2]|0;u=r[t+328>>2]|0;d=r[t+332>>2]|0;l=r[t+336>>2]|0;for(n=0;(n|0)<(e|0);n=n+64|0){s=i;c=a;f=u;h=d;p=l;for(o=0;(o|0)<64;o=o+4|0){g=r[n+o>>2]|0;m=((i<<5|i>>>27)+(a&u|~a&d)|0)+((g+l|0)+1518500249|0)|0;l=d;d=u;u=a<<30|a>>>2;a=i;i=m;r[e+o>>2]=g}for(o=e+64|0;(o|0)<(e+80|0);o=o+4|0){g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31;m=((i<<5|i>>>27)+(a&u|~a&d)|0)+((g+l|0)+1518500249|0)|0;l=d;d=u;u=a<<30|a>>>2;a=i;i=m;r[o>>2]=g}for(o=e+80|0;(o|0)<(e+160|0);o=o+4|0){g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31;m=((i<<5|i>>>27)+(a^u^d)|0)+((g+l|0)+1859775393|0)|0;l=d;d=u;u=a<<30|a>>>2;a=i;i=m;r[o>>2]=g}for(o=e+160|0;(o|0)<(e+240|0);o=o+4|0){g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31;m=((i<<5|i>>>27)+(a&u|a&d|u&d)|0)+((g+l|0)-1894007588|0)|0;l=d;d=u;u=a<<30|a>>>2;a=i;i=m;r[o>>2]=g}for(o=e+240|0;(o|0)<(e+320|0);o=o+4|0){g=(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])<<1|(r[o-12>>2]^r[o-32>>2]^r[o-56>>2]^r[o-64>>2])>>>31;m=((i<<5|i>>>27)+(a^u^d)|0)+((g+l|0)-899497514|0)|0;l=d;d=u;u=a<<30|a>>>2;a=i;i=m;r[o>>2]=g}i=i+s|0;a=a+c|0;u=u+f|0;d=d+h|0;l=l+p|0}r[t+320>>2]=i;r[t+324>>2]=a;r[t+328>>2]=u;r[t+332>>2]=d;r[t+336>>2]=l}return{hash:o}},"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(r){self.postMessage({id:e.data.id,error:r.name})}}}}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],137:[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 c=r-a&o;for(c>t&&(c=t),a=r;c--;)s===t&&(s=0),n[s]=n[0===s?t-1:s-1],s++;e&&(n[s-1]+=e);var u=n[s-1],f=n.length<t?0:n[s===t?0:s];return n.length<i?u:(u-f)*i/n.length}}},{}],138:[function(e,t,n){var r=e("once");t.exports=function(e,t,n){n=r(n);var o=[];e.on("data",function(e){o.push(e)}).on("end",function(){var e=t?new Blob(o,{type:t}):new Blob(o),r=URL.createObjectURL(e);n(null,r)}).on("error",n)}},{once:140}],139:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{dup:20}],140:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21,wrappy:139}],141:[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:25,once:143}],142:[function(e,t,n){arguments[4][20][0].apply(n,arguments)},{dup:20}],143:[function(e,t,n){arguments[4][21][0].apply(n,arguments)},{dup:21,wrappy:142}],144:[function(e,t,n){(function(n,r){function o(e){function t(e,t){i._internalDHT=!0;var n=new s(t);return d(n,i,["warning","error"]),n.listen(e),n}function r(e,t){t.toString("hex")===i.infoHash&&i.emit("peer",e.host+":"+e.port)}var i=this;if(!(i instanceof o))return new o(e);if(a.call(i),i.peerId=e.peerId,i.port=e.port||0,!i.peerId)throw new Error("peerId required");if(!n.browser&&!i.port)throw new Error("port required");i.announce=e.announce||[],i._intervalMs=e.intervalMs||9e5,i.destroyed=!1,i.infoHash=null,i.infoHashBuffer=null,i.torrent=null,i._dhtAnnouncing=!1,i._dhtTimeout=!1,i._internalDHT=!1,e.tracker===!1?i.tracker=!1:(i.tracker=!0,i._trackerOpts=e.tracker||{}),e.dht===!1||"function"!=typeof s?i.dht=!1:e.dht&&"function"==typeof e.dht.announce&&"function"==typeof e.dht.addNode?i.dht=e.dht:"object"==typeof e.dht?i.dht=t(e.dhtPort,e.dht):i.dht=t(e.dhtPort),i.dht&&i.dht.on("peer",r)}t.exports=o;var i=e("debug")("torrent-discovery"),s=e("bittorrent-dht/client"),a=e("events").EventEmitter,c=e("xtend"),u=e("inherits"),f=e("run-parallel"),d=e("re-emitter"),h=e("bittorrent-tracker/client");u(o,a),o.prototype.setTorrent=function(e){var t=this;if(t.infoHash||"string"!=typeof e&&!r.isBuffer(e)){if(t.torrent||!e||!e.infoHash)return;t.torrent=e,t.infoHash="string"==typeof e.infoHash?e.infoHash:e.infoHash.toString("hex")}else t.infoHash="string"==typeof e?e:e.toString("hex");t.infoHashBuffer=new r(t.infoHash,"hex"),i("setTorrent %s",t.infoHash),t.tracker&&t.tracker!==!0?t.tracker.torrentLength=e.length:t._createTracker(),t._dhtAnnounce()},o.prototype.updatePort=function(e){var t=this;e!==t.port&&(t.port=e,t._dhtAnnounce(),t.tracker&&t.tracker!==!0&&(t.tracker.stop(),t.tracker.destroy(function(){t._createTracker()})))},o.prototype.stop=function(e){var t=this;t.destroyed=!0,clearTimeout(t._dhtTimeout);var n=[];t.tracker&&t.tracker!==!0&&(t.tracker.stop(),n.push(function(e){t.tracker.destroy(e)})),t._internalDHT&&n.push(function(e){t.dht.destroy(e)}),f(n,e)},o.prototype._createTracker=function(){function e(e){t.emit("trackerAnnounce",e)}var t=this;if(t.tracker){var n=t.torrent?c({announce:[]},t.torrent):{infoHash:t.infoHash,announce:[]};t.announce&&(n.announce=n.announce.concat(t.announce)),t.tracker=new h(t.peerId,t.port,n,t._trackerOpts),d(t.tracker,t,["peer","warning","error"]),t.tracker.setInterval(t._intervalMs),t.tracker.on("update",e),t.tracker.start()}},o.prototype._dhtAnnounce=function(){function e(){return t._intervalMs+Math.floor(Math.random()*t._intervalMs/5)}var t=this;t.port&&t.infoHash&&t.dht&&!t._dhtAnnouncing&&(i("dht announce"),t._dhtAnnouncing=!0,clearTimeout(t._dhtTimeout),t.dht.announce(t.infoHash,t.port,function(n){t._dhtAnnouncing=!1,i("dht announce complete"),n&&t.emit("warning",n),t.emit("dhtAnnounce"),t.destroyed||(t._dhtTimeout=setTimeout(function(){t._dhtAnnounce()},e()))}))}}).call(this,e("_process"),e("buffer").Buffer)},{_process:33,"bittorrent-dht/client":24,"bittorrent-tracker/client":16,buffer:25,debug:68,events:29,inherits:76,"re-emitter":93,"run-parallel":127,xtend:152}],145:[function(e,t,n){(function(e){function n(e){return this instanceof n?(this.length=e,this.missing=e,this.sources=null,this._chunks=Math.ceil(e/r),this._remainder=e%r||r,this._buffered=0,this._buffer=null,this._cancellations=null,this._reservations=0,void(this._flushed=!1)):new n(e)}t.exports=n;var r=16384;n.BLOCK_LENGTH=r,n.prototype.chunkLength=function(e){return e===this._chunks-1?this._remainder:r},n.prototype.chunkLengthRemaining=function(e){return this.length-e*r},n.prototype.chunkOffset=function(e){return e*r},n.prototype.reserve=function(){return this.init()?this._cancellations.length?this._cancellations.pop():this._reservations<this._chunks?this._reservations++:-1:-1},n.prototype.reserveRemaining=function(){if(!this.init())return-1;if(this._reservations<this._chunks){var e=this._reservations;return this._reservations=this._chunks,e}return-1},n.prototype.cancel=function(e){this.init()&&this._cancellations.push(e)},n.prototype.cancelRemaining=function(e){this.init()&&(this._reservations=e)},n.prototype.get=function(e){return this.init()?this._buffer[e]:null},n.prototype.set=function(e,t,n){if(!this.init())return!1;for(var o=t.length,i=Math.ceil(o/r),s=0;i>s;s++)if(!this._buffer[e+s]){var a=s*r,c=t.slice(a,a+r);this._buffered++,this._buffer[e+s]=c,this.missing-=c.length,-1===this.sources.indexOf(n)&&this.sources.push(n)}return this._buffered===this._chunks},n.prototype.flush=function(){if(!this._buffer||this._chunks!==this._buffered)return null;var t=e.concat(this._buffer,this.length);return this._buffer=null,this._cancellations=null,this.sources=null,this._flushed=!0,t},n.prototype.init=function(){return this._flushed?!1:this._buffer?!0:(this._buffer=new Array(this._chunks),this._cancellations=[],this.sources=[],!0)}}).call(this,e("buffer").Buffer)},{buffer:25}],146:[function(e,t,n){"use strict";function r(e,t){for(var n=1,r=e.length,o=e[0],i=e[0],s=1;r>s;++s)if(i=o,o=e[s],t(o,i)){if(s===n){n++;continue}e[n++]=o}return e.length=n,e}function o(e){for(var t=1,n=e.length,r=e[0],o=e[0],i=1;n>i;++i,o=r)if(o=r,r=e[i],r!==o){if(i===t){t++;continue}e[t++]=r}return e.length=t,e}function i(e,t,n){return 0===e.length?e:t?(n||e.sort(t),r(e,t)):(n||e.sort(),o(e))}t.exports=i},{}],147:[function(e,t,n){(function(n){var r=e("bencode"),o=e("bitfield"),i=e("debug")("ut_metadata"),s=e("events").EventEmitter,a=e("inherits"),c=e("simple-sha1"),u=1e7,f=1e3,d=16384;t.exports=function(e){function t(t){s.call(this),this._wire=t,this._metadataComplete=!1,this._metadataSize=null,this._remainingRejects=null,this._fetching=!1,this._bitfield=new o(0,{grow:f}),n.isBuffer(e)&&this.setMetadata(e)}return a(t,s),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?e.metadata_size>u?this.emit("warning",new Error("Peer gave maliciously large metadata size")):(this._metadataSize=e.metadata_size,this._numPieces=Math.ceil(this._metadataSize/d),this._remainingRejects=2*this._numPieces,void(this._fetching&&this._requestPieces())):this.emit("warning",new Error("Peer does not have metadata")):this.emit("warning",new Error("Peer does not support ut_metadata"))},t.prototype.onMessage=function(e){var t,n;try{var o=e.toString(),i=o.indexOf("ee")+2;t=r.decode(o.substring(0,i)),n=e.slice(i)}catch(s){return}switch(t.msg_type){case 0:this._onRequest(t.piece);break;case 1:this._onData(t.piece,n,t.total_size);break;case 2:this._onReject(t.piece)}},t.prototype.fetch=function(){this._metadataComplete||(this._fetching=!0,this._metadataSize&&this._requestPieces())},t.prototype.cancel=function(){this._fetching=!1},t.prototype.setMetadata=function(e){if(this._metadataComplete)return!0;i("set metadata");try{var t=r.decode(e).info;t&&(e=r.encode(t))}catch(n){}return this._infoHash&&this._infoHash!==c.sync(e)?!1:(this.cancel(),this.metadata=e,this._metadataComplete=!0,this._metadataSize=this.metadata.length,this._wire.extendedHandshake.metadata_size=this._metadataSize,this.emit("metadata",r.encode({info:r.decode(this.metadata)})),!0)},t.prototype._send=function(e,t){var o=r.encode(e);n.isBuffer(t)&&(o=n.concat([o,t])),this._wire.extended("ut_metadata",o)},t.prototype._request=function(e){this._send({msg_type:0,piece:e})},t.prototype._data=function(e,t,n){var r={msg_type:1,piece:e};"number"==typeof n&&(r.total_size=n),this._send(r,t)},t.prototype._reject=function(e){this._send({msg_type:2,piece:e})},t.prototype._onRequest=function(e){if(!this._metadataComplete)return void this._reject(e);var t=e*d,n=t+d;n>this._metadataSize&&(n=this._metadataSize);var r=this.metadata.slice(t,n);this._data(e,r,this._metadataSize)},t.prototype._onData=function(e,t,n){t.length>d||(t.copy(this.metadata,e*d),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=new n(this._metadataSize);for(var e=0;e<this._numPieces;e++)this._request(e)},t.prototype._checkDone=function(){for(var e=!0,t=0;t<this._numPieces;t++)if(!this._bitfield.get(t)){e=!1;break}if(e){var n=this.setMetadata(this.metadata);n||this._failedMetadata()}},t.prototype._failedMetadata=function(){this._bitfield=new o(0,{grow:f}),this._remainingRejects-=this._numPieces,this._remainingRejects>0?this._requestPieces():this.emit("warning",new Error("Peer sent invalid metadata"))},t}}).call(this,e("buffer").Buffer)},{bencode:148,bitfield:7,buffer:25,debug:68,events:29,inherits:76,"simple-sha1":135}],148:[function(e,t,n){arguments[4][12][0].apply(n,arguments)},{"./lib/decode":149,"./lib/encode":151,dup:12}],149:[function(e,t,n){arguments[4][13][0].apply(n,arguments)},{"./dict":150,buffer:25,dup:13}],150:[function(e,t,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],151:[function(e,t,n){arguments[4][15][0].apply(n,arguments)},{buffer:25,dup:15}],152:[function(e,t,n){function r(){for(var e={},t=0;t<arguments.length;t++){var n=arguments[t];for(var r in n)o.call(n,r)&&(e[r]=n[r])}return e}t.exports=r;var o=Object.prototype.hasOwnProperty},{}],153:[function(e,t,n){function r(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)o.call(n,r)&&(e[r]=n[r])}return e}t.exports=r;var o=Object.prototype.hasOwnProperty},{}],154:[function(e,t,n){t.exports=function r(e,t,n){return void 0===t?function(t,n){return r(e,t,n)}:(void 0===n&&(n="0"),e-=t.toString().length,e>0?new Array(e+(/\./.test(t)?2:1)).join(n)+t:t+"")}},{}],155:[function(e,t,n){t.exports={version:"0.85.3"}},{}],156:[function(e,t,n){(function(n,r,o){function i(e){function t(){s.destroyed||(s.ready=!0,s.emit("ready"))}var s=this;return s instanceof i?(f.call(s),e||(e={}),c.enabled||s.setMaxListeners(0),s.destroyed=!1,s.torrentPort=e.torrentPort||0,s.tracker=void 0!==e.tracker?e.tracker:!0,s._rtcConfig=e.rtcConfig,s._wrtc=e.wrtc||r.WRTC,s.torrents=[],s._downloadSpeed=v(),s._uploadSpeed=v(),s.maxConns=e.maxConns,s.peerId="string"==typeof e.peerId?e.peerId:(e.peerId||new o(S+h(48))).toString("hex"),s.peerIdBuffer=new o(s.peerId,"hex"),s.nodeId="string"==typeof e.nodeId?e.nodeId:e.nodeId&&e.nodeId.toString("hex")||h(160),s.nodeIdBuffer=new o(s.nodeId,"hex"),e.dht!==!1&&"function"==typeof u?(s.dht=new u(d({nodeId:s.nodeId},e.dht)),s.dht.once("error",function(e){s.emit("error",e),s.destroy()}),s.dht.listen(e.dhtPort)):s.dht=!1,c("new webtorrent (peerId %s, nodeId %s)",s.peerId,s.nodeId),void("function"==typeof p?p(e.blocklist,{headers:{"user-agent":"WebTorrent/"+k+" (http://webtorrent.io)"}},function(e,n){return e?s.error("Failed to load blocklist: "+e.message):(s.blocked=n,void t())}):n.nextTick(t))):new i(e)}function s(e){return"object"==typeof e&&null!=e&&"function"==typeof e.pipe}t.exports=i;var a=e("create-torrent"),c=e("debug")("webtorrent"),u=e("bittorrent-dht/client"),f=e("events").EventEmitter,d=e("xtend"),h=e("hat"),l=e("inherits"),p=e("load-ip-set"),m=e("run-parallel"),g=e("parse-torrent"),y=e("path"),_=e("simple-peer"),v=e("speedometer"),b=e("zero-fill"),w=e("./lib/concat-stream"),E=e("./lib/torrent");t.exports.WEBRTC_SUPPORT=_.WEBRTC_SUPPORT;var k=e("./package.json").version,x=k.match(/([0-9]+)/g).slice(0,2).map(b(2)).join(""),S="-WW"+x+"-";l(i,f),Object.defineProperty(i.prototype,"downloadSpeed",{get:function(){return this._downloadSpeed()}}),Object.defineProperty(i.prototype,"uploadSpeed",{get:function(){return this._uploadSpeed()}}),Object.defineProperty(i.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(i.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.downloaded},0)||1;return e/t}}),i.prototype.get=function(e){var t=this;if(e instanceof E)return e;var n;try{n=g(e)}catch(r){}if(!n)return null;if(!n.infoHash)throw new Error("Invalid torrent identifier");for(var o=0,i=t.torrents.length;i>o;o++){var s=t.torrents[o];if(s.infoHash===n.infoHash)return s}return null},i.prototype.add=i.prototype.download=function(e,t,r){function o(){c("on torrent"),"function"==typeof r&&r(s),i.emit("torrent",s)}var i=this;if(i.destroyed)throw new Error("client is destroyed");if("function"==typeof t)return i.add(e,null,t);c("add"),t=t?d(t):{};var s=i.get(e);return s?s.ready?n.nextTick(o):s.once("ready",o):(s=new E(e,i,t),i.torrents.push(s),s.once("error",function(e){i.emit("error",e,s),i.remove(s)}),s.once("listening",function(e){i.emit("listening",e,s)}),s.once("ready",o)),s},i.prototype.seed=function(e,t,n){function r(e){var t=[function(t){e.load(u,t)}];i.dht&&t.push(function(t){e.once("dhtAnnounce",t)}),m(t,function(t){return i.destroyed?void 0:t?i.emit("error",t,e):void o(e)})}function o(e){c("on seed"),"function"==typeof n&&n(e),i.emit("seed",e)}var i=this;if(i.destroyed)throw new Error("client is destroyed");if("function"==typeof t)return i.seed(e,null,t);c("seed"),t=t?d(t):{},"string"==typeof e&&(t.path=y.dirname(e)),t.createdBy||(t.createdBy="WebTorrent/"+x),i.tracker||(t.announce=[]);var u,f=i.add(null,t,r);return Array.isArray(e)||(e=[e]),m(e.map(function(e){return function(t){s(e)?w(e,t):t(null,e)}}),function(e,n){return e?i.emit("error",e,f):void(i.destroyed||a.parseInput(n,t,function(e,r){return e?i.emit("error",e,f):void(i.destroyed||(u=r.map(function(e){return e.getStream}),a(n,t,function(e,t){if(e)return i.emit("error",e,f);if(!i.destroyed){var n=i.get(t);n?(f.destroy(),o(n)):f._onTorrentId(t)}})))}))}),f},i.prototype.remove=function(e,t){var n=this;c("remove");var r=n.get(e);if(!r)throw new Error("No torrent with id "+e);n.torrents.splice(n.torrents.indexOf(r),1),r.destroy(t)},i.prototype.address=function(){var e=this;return{address:"0.0.0.0",family:"IPv4",port:e.torrentPort}},i.prototype.destroy=function(e){var t=this;if(t.destroyed)throw new Error("client already destroyed");t.destroyed=!0,c("destroy");var n=t.torrents.map(function(e){return function(n){t.remove(e,n)}});t.dht&&n.push(function(e){t.dht.destroy(e)}),m(n,e)}}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"./lib/concat-stream":1,"./lib/torrent":5,"./package.json":155,_process:33,"bittorrent-dht/client":24,buffer:25,"create-torrent":51,debug:68,events:29,hat:74,inherits:76,"load-ip-set":24,"parse-torrent":79,path:32,"run-parallel":127,"simple-peer":131,speedometer:137,xtend:152,"zero-fill":154}]},{},[156])(156)});