UNPKG

gear

Version:

Gear.js - Build System for Node.js and the Browser

14 lines 273 kB
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.Gear=e()}}(function(){var define,module,exports;return function e(t,r,n){function i(s,f){if(!r[s]){if(!t[s]){var o="function"==typeof require&&require;if(!f&&o)return o(s,!0);if(a)return a(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=r[s]={exports:{}};t[s][0].call(d.exports,function(e){var r=t[s][1][e];return i(r?r:e)},d,d.exports,e,t,r,n)}return r[s].exports}for(var a="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,r){(function(t){var n=r.Blob=function s(e,t){function r(e,t){Object.keys(t).forEach(function(r){e[r]=t[r]})}e="undefined"==typeof e?[]:Array.prototype.concat(e),t=t||{};var n=e.length?e.shift():"",i={},a=this;n instanceof s&&(r(i,n),n=n.result),e.forEach(function(e){e instanceof s?(r(i,e),n+=e.result):n+=e}),r(i,t),Object.keys(i).forEach(function(e){"result"!==e&&Object.defineProperty(a,e,{enumerable:!0,value:i[e]})}),Object.defineProperty(this,"result",{value:n})};n.prototype.toString=function(){return this.result};var i={server:function(t,r,a,s){var f=e("fs");s?i.serverSync(t,r,a):f.readFile(t,"bin"===r?void 0:r,function(e,r){e?a(e):a(null,new n(r,{name:t}))})},serverSync:function(t,r,i){var a,s=e("fs");try{a=s.readFileSync(t,"bin"===r?void 0:r),i(null,new n(a,{name:t}))}catch(f){i(f)}},client:function(e,t,r){e in localStorage?r(null,new n(localStorage[e],{name:e})):r("localStorage has no item "+e)}};n.readFile=n.prototype.readFile=t.browser?i.client:i.server;var a={server:function(t,r,i,a){function s(e,t){o.writeFile(e,t.result,"bin"===i?void 0:i,function(r){a(r,new n(t,{name:e}))})}var f,o=e("fs"),c=e("path"),d=o.exists||c.exists,u=e("mkdirp").mkdirp,h=e("crypto"),l=c.resolve(c.dirname(t));t.indexOf("{checksum}")>-1&&(f=h.createHash("md5"),f.update(r.result),t=t.replace("{checksum}",f.digest("hex"))),d(l,function(e){e?s(t,r):u(l,"0755",function(e){e?a(e):s(t,r)})})},client:function(e,t,r,n){localStorage[e]=t.result,n(null,new t.constructor(t,{name:e}))}};n.writeFile=n.prototype.writeFile=t.browser?a.client:a.server}).call(this,e("_process"))},{_process:163,crypto:21,fs:15,mkdirp:179,path:162}],2:[function(e,t){t.exports={Registry:e("./registry").Registry,Blob:e("./blob").Blob,Queue:e("./queue").Queue,Util:e("./util"),tasks:e("./tasks")}},{"./blob":1,"./queue":3,"./registry":4,"./tasks":7,"./util":13}],3:[function(e,t,r){function n(e,t){for(var r=[],n=0;n<Math.min(e.length,t.length);n++)r.push([e[n],t[n]]);return r}function i(e){return"undefined"==typeof e?[]:Array.prototype.concat(e)}function a(e){return function(t,r){e._queue[0]=function(e){e(null,t)},e.run(r)}}var s=e("async"),f=e("./registry").Registry,o=e("./blob").Blob,c=r.Queue=function(e){var t=this;e=e||{},this._logger=e.logger||console,this._registry="string"==typeof e.registry?new f({module:e.registry}):e.registry||new f,this._clear(),this._registry.tasks.forEach(function(e){t[e]=t.task.bind(t,e)})};c.prototype._clear=function(){this._queue=[function(e){e(null,[])}]},c.prototype._log=function(e){this._logger.log(e)},c.prototype._dispatch=function(e,t,r,f){function d(t,r){t&&(t={task:e,error:t}),f(t,r)}if(e instanceof c)return a(e)(r,f);var u=this._registry.task(e),h={2:"append",3:"map",4:"reduce"},l=u.type?u.type:h[u.length];switch(l){case"append":s.map(i(t),u.bind(this),function(e,t){d(e,r.concat(t))});break;case"prepend":s.map(i(t),u.bind(this),function(e,t){d(e,t.concat(r))});break;case"collect":u.call(this,t,r,d);break;case"slice":s.map(n(i(t),r),function(e,t){u.call(this,e[0],e[1],t)}.bind(this),d);break;case"each":s.forEach(r,u.bind(this,t),function(e){d(e,r)});break;case"map":s.map(r,u.bind(this,t),d);break;case"syncmap":s.mapSeries(r,u.bind(this,t),d);break;case"reduce":s.reduce(r,new o,u.bind(this,t),function(e,t){d(e,[t])});break;default:throw new Error('Task "'+e+'" has unknown type. Add a type property to the task function.')}},c.prototype.task=function(e,t){return this._queue.push(this._dispatch.bind(this,e,t)),this},c.prototype.series=function(e){return e instanceof c&&(e=[].slice.call(arguments)),this._queue=this._queue.concat(e.map(a)),this},c.prototype.run=function(e){var t=this;s.waterfall(this._queue,e||function(e){e&&t._log(e)})}},{"./blob":1,"./registry":4,async:14}],4:[function(e,t,r){(function(t,n){var i=e("fs"),a=e("path"),s=r.Registry=function(r){var i=this;this._tasks={},this.load(t.browser?{tasks:e("./tasks")}:{dirname:n+"/tasks"}),r&&this.load(r),Object.defineProperty(this,"tasks",{get:function(){return Object.keys(i._tasks)}})};s.prototype={load:function(e){e=e||{};var t=e.module,r=e.dirname,n=e.filename,i=e.tasks;if(t&&!this._loadModule(t))throw new Error("Module "+t+" doesn't exist");if(r&&!this._loadDir(r))throw new Error("Directory "+r+" doesn't exist");if(n&&!this._loadFile(n))throw new Error("File "+n+" doesn't exist");if(i&&!this._loadTasks(i))throw new Error("Failed to load tasks");return this},_loadModule:function(t){if(e)try{return this._loadTasks(e(t))}catch(r){}return this._loadDir(a.resolve("node_modules",t,"lib"))},_loadDir:function(e){if(!i.existsSync(e))return!1;var t=i.readdirSync(e),r=this;return t.forEach(function(t){var n=a.join(e,t);".js"===a.extname(n)&&r._loadFile(n)}),!0},_loadFile:function(t){return i.existsSync(t)?this._loadTasks(e(t)):!1},_loadTasks:function(e){var t;for(t in e)this._tasks[t]=e[t];return!0},task:function(e){if(!(e in this._tasks))throw new Error("Task "+e+" doesn't exist");return this._tasks[e]}}}).call(this,e("_process"),"/lib")},{"./tasks":7,_process:163,fs:15,path:162}],5:[function(e,t,r){r.concat=function(e,t,r,n){e=e||{},n(null,new r.constructor([t,e.callback?e.callback(r):r]))}},{}],6:[function(e,t,r){function n(){return function(e,t){t(null,new i(e))}}var i=e("../blob").Blob;r.append=r.load=n();var a=r.prepend=n();a.type="prepend";var s=r.test=function(e,t,r){e=e||{},r(e.callback?e.callback(t):null)};s.type="each";var f=r.get=function(e,t,r){r(null,t.slice(e,e+1))};f.type="collect";var o=r.log=function(e,t,r){this._log(e),r(null,t)};o.type="collect";var c=r.inspect=function(e,t,r){var n=this;t.forEach(function(e,t){var r={result:e.result};Object.keys(e).forEach(function(t){r[t]=e[t]}),n._log("blob "+(t+1)+": "+JSON.stringify(r,null," "))}),r(null,t)};c.type="collect",r.noop=function(e,t,r){r(null,t)}},{"../blob":1}],7:[function(e,t){function r(e){Object.keys(e).map(function(t){n[t]=e[t]})}var n={write:e("./write").write,tasks:e("./tasks").tasks,stamp:e("./stamp").stamp,replace:e("./replace").replace,concat:e("./concat").concat};r(e("./core")),r(e("./read")),t.exports=n},{"./concat":5,"./core":6,"./read":8,"./replace":9,"./stamp":10,"./tasks":11,"./write":12}],8:[function(e,t,r){function n(){return function(e,t){e="string"==typeof e?{name:e}:e;var r=e.encoding||"utf8";i.readFile(e.name,r,t,e.sync)}}var i=e("../blob").Blob;r.read=n();var a=r.readBefore=n();a.type="prepend"},{"../blob":1}],9:[function(e,t,r){r.replace=function(e,t,r){var n=t.result;Array.isArray(e)||(e=[e]),e.forEach(function(e){var t=e.replace||"",r=void 0!==e.flags?e.flags:"mg",i="string"==typeof e.regex?new RegExp(e.regex,r):e.regex;n=n.replace(i,t)}),r(null,new t.constructor(n,t))}},{}],10:[function(e,t,r){r.stamp=function(e,t,r){e=e||{},e.prefix=e.prefix||"",e.postfix=e.postfix||"";var n=e.callback?e.callback(t):t.result,i=e.prefix+n+e.postfix;r(null,new t.constructor(i,t))}},{}],11:[function(e,t,r){var n=e("async"),i=r.tasks=function(e,t,r){function i(e,r,n){return function(i,a){var s=n.length?[]:t;a=a||[],n.forEach(function(e){s=s.concat(a[e])}),d._dispatch(e,r,s,i)}}var a,s,f,o,c={},d=this;for(a in e)s=e[a].task,void 0===s?s=["noop"]:Array.isArray(s)||(s=[s]),f=e[a].requires,void 0===f?f=[]:Array.isArray(f)||(f=[f]),o=i(s[0],s[1],f),c[a]=f?f.concat(o):o;n.auto(c,function(e,t){return e?void r(e):void r(e,t&&t.join?t.join:[])})};i.type="collect"},{async:14}],12:[function(e,t,r){var n=r.write=function(e,t,r){e="string"==typeof e?{name:e}:e;var n=e.encoding||"utf8";t.writeFile(e.name,t,n,r)};n.type="slice"},{}],13:[function(e,t){(function(r){function n(e){return localStorage[e]}function i(e){return JSON.parse(f(e)+"")}function a(e){return JSON.parse(s(f(e)+""))}function s(e){var t,r,n,i,a=/"|(\/\*)|(\*\/)|(\/\/)|\n|\r/g,s=!1,f=!1,o=!1,c=[],d=0,u=0;for(a.lastIndex=0;t=a.exec(e);)n=RegExp.leftContext,i=RegExp.rightContext,f||o||(r=n.substring(u),s||(r=r.replace(/(\n|\r|\s)*/g,"")),c[d++]=r),u=a.lastIndex,'"'!=t[0]||f||o?"/*"!=t[0]||s||f||o?"*/"!=t[0]||s||!f||o?"//"!=t[0]||s||f||o?"\n"!=t[0]&&"\r"!=t[0]||s||f||!o?f||o||/\n|\r|\s/.test(t[0])||(c[d++]=t[0]):o=!1:o=!0:f=!1:f=!0:(r=n.match(/(\\)*$/),s&&r&&r[0].length%2!==0||(s=!s),u--,i=e.substring(u));return c[d++]=i,c.join("")}var f=r.browser?n:e("fs").readFileSync;t.exports={readJSON:i,readJSONC:a}}).call(this,e("_process"))},{_process:163,fs:15}],14:[function(e,t){(function(e){/*! * async * https://github.com/caolan/async * * Copyright 2010-2014 Caolan McMahon * Released under the MIT license */ !function(){function r(e){var t=!1;return function(){if(t)throw new Error("Callback was already called.");t=!0,e.apply(n,arguments)}}var n,i,a={};n=this,null!=n&&(i=n.async),a.noConflict=function(){return n.async=i,a};var s=Object.prototype.toString,f=Array.isArray||function(e){return"[object Array]"===s.call(e)},o=function(e,t){if(e.forEach)return e.forEach(t);for(var r=0;r<e.length;r+=1)t(e[r],r,e)},c=function(e,t){if(e.map)return e.map(t);var r=[];return o(e,function(e,n,i){r.push(t(e,n,i))}),r},d=function(e,t,r){return e.reduce?e.reduce(t,r):(o(e,function(e,n,i){r=t(r,e,n,i)}),r)},u=function(e){if(Object.keys)return Object.keys(e);var t=[];for(var r in e)e.hasOwnProperty(r)&&t.push(r);return t};"undefined"!=typeof e&&e.nextTick?(a.nextTick=e.nextTick,a.setImmediate="undefined"!=typeof setImmediate?function(e){setImmediate(e)}:a.nextTick):"function"==typeof setImmediate?(a.nextTick=function(e){setImmediate(e)},a.setImmediate=a.nextTick):(a.nextTick=function(e){setTimeout(e,0)},a.setImmediate=a.nextTick),a.each=function(e,t,n){function i(t){t?(n(t),n=function(){}):(a+=1,a>=e.length&&n())}if(n=n||function(){},!e.length)return n();var a=0;o(e,function(e){t(e,r(i))})},a.forEach=a.each,a.eachSeries=function(e,t,r){if(r=r||function(){},!e.length)return r();var n=0,i=function(){t(e[n],function(t){t?(r(t),r=function(){}):(n+=1,n>=e.length?r():i())})};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(e,t,r,n){var i=h(t);i.apply(null,[e,r,n])},a.forEachLimit=a.eachLimit;var h=function(e){return function(t,r,n){if(n=n||function(){},!t.length||0>=e)return n();var i=0,a=0,s=0;!function f(){if(i>=t.length)return n();for(;e>s&&a<t.length;)a+=1,s+=1,r(t[a-1],function(e){e?(n(e),n=function(){}):(i+=1,s-=1,i>=t.length?n():f())})}()}},l=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[a.each].concat(t))}},b=function(e,t){return function(){var r=Array.prototype.slice.call(arguments);return t.apply(null,[h(e)].concat(r))}},p=function(e){return function(){var t=Array.prototype.slice.call(arguments);return e.apply(null,[a.eachSeries].concat(t))}},g=function(e,t,r,n){if(t=c(t,function(e,t){return{index:t,value:e}}),n){var i=[];e(t,function(e,t){r(e.value,function(r,n){i[e.index]=n,t(r)})},function(e){n(e,i)})}else e(t,function(e,t){r(e.value,function(e){t(e)})})};a.map=l(g),a.mapSeries=p(g),a.mapLimit=function(e,t,r,n){return v(t)(e,r,n)};var v=function(e){return b(e,g)};a.reduce=function(e,t,r,n){a.eachSeries(e,function(e,n){r(t,e,function(e,r){t=r,n(e)})},function(e){n(e,t)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(e,t,r,n){var i=c(e,function(e){return e}).reverse();a.reduce(i,t,r,n)},a.foldr=a.reduceRight;var y=function(e,t,r,n){var i=[];t=c(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){r(e.value,function(r){r&&i.push(e),t()})},function(){n(c(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};a.filter=l(y),a.filterSeries=p(y),a.select=a.filter,a.selectSeries=a.filterSeries;var m=function(e,t,r,n){var i=[];t=c(t,function(e,t){return{index:t,value:e}}),e(t,function(e,t){r(e.value,function(r){r||i.push(e),t()})},function(){n(c(i.sort(function(e,t){return e.index-t.index}),function(e){return e.value}))})};a.reject=l(m),a.rejectSeries=p(m);var w=function(e,t,r,n){e(t,function(e,t){r(e,function(r){r?(n(e),n=function(){}):t()})},function(){n()})};a.detect=l(w),a.detectSeries=p(w),a.some=function(e,t,r){a.each(e,function(e,n){t(e,function(e){e&&(r(!0),r=function(){}),n()})},function(){r(!1)})},a.any=a.some,a.every=function(e,t,r){a.each(e,function(e,n){t(e,function(e){e||(r(!1),r=function(){}),n()})},function(){r(!0)})},a.all=a.every,a.sortBy=function(e,t,r){a.map(e,function(e,r){t(e,function(t,n){t?r(t):r(null,{value:e,criteria:n})})},function(e,t){if(e)return r(e);var n=function(e,t){var r=e.criteria,n=t.criteria;return n>r?-1:r>n?1:0};r(null,c(t.sort(n),function(e){return e.value}))})},a.auto=function(e,t){t=t||function(){};var r=u(e),n=r.length;if(!n)return t();var i={},s=[],c=function(e){s.unshift(e)},h=function(e){for(var t=0;t<s.length;t+=1)if(s[t]===e)return void s.splice(t,1)},l=function(){n--,o(s.slice(0),function(e){e()})};c(function(){if(!n){var e=t;t=function(){},e(null,i)}}),o(r,function(r){var n=f(e[r])?e[r]:[e[r]],s=function(e){var n=Array.prototype.slice.call(arguments,1);if(n.length<=1&&(n=n[0]),e){var s={};o(u(i),function(e){s[e]=i[e]}),s[r]=n,t(e,s),t=function(){}}else i[r]=n,a.setImmediate(l)},b=n.slice(0,Math.abs(n.length-1))||[],p=function(){return d(b,function(e,t){return e&&i.hasOwnProperty(t)},!0)&&!i.hasOwnProperty(r)};if(p())n[n.length-1](s,i);else{var g=function(){p()&&(h(g),n[n.length-1](s,i))};c(g)}})},a.retry=function(e,t,r){var n=5,i=[];"function"==typeof e&&(r=t,t=e,e=n),e=parseInt(e,10)||n;var s=function(n,s){for(var f=function(e,t){return function(r){e(function(e,n){r(!e||t,{err:e,result:n})},s)}};e;)i.push(f(t,!(e-=1)));a.series(i,function(e,t){t=t[t.length-1],(n||r)(t.err,t.result)})};return r?s():s},a.waterfall=function(e,t){if(t=t||function(){},!f(e)){var r=new Error("First argument to waterfall must be an array of functions");return t(r)}if(!e.length)return t();var n=function(e){return function(r){if(r)t.apply(null,arguments),t=function(){};else{var i=Array.prototype.slice.call(arguments,1),s=e.next();i.push(s?n(s):t),a.setImmediate(function(){e.apply(null,i)})}}};n(a.iterator(e))()};var _=function(e,t,r){if(r=r||function(){},f(t))e.map(t,function(e,t){e&&e(function(e){var r=Array.prototype.slice.call(arguments,1);r.length<=1&&(r=r[0]),t.call(null,e,r)})},r);else{var n={};e.each(u(t),function(e,r){t[e](function(t){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),n[e]=i,r(t)})},function(e){r(e,n)})}};a.parallel=function(e,t){_({map:a.map,each:a.each},e,t)},a.parallelLimit=function(e,t,r){_({map:v(t),each:h(t)},e,r)},a.series=function(e,t){if(t=t||function(){},f(e))a.mapSeries(e,function(e,t){e&&e(function(e){var r=Array.prototype.slice.call(arguments,1);r.length<=1&&(r=r[0]),t.call(null,e,r)})},t);else{var r={};a.eachSeries(u(e),function(t,n){e[t](function(e){var i=Array.prototype.slice.call(arguments,1);i.length<=1&&(i=i[0]),r[t]=i,n(e)})},function(e){t(e,r)})}},a.iterator=function(e){var t=function(r){var n=function(){return e.length&&e[r].apply(null,arguments),n.next()};return n.next=function(){return r<e.length-1?t(r+1):null},n};return t(0)},a.apply=function(e){var t=Array.prototype.slice.call(arguments,1);return function(){return e.apply(null,t.concat(Array.prototype.slice.call(arguments)))}};var S=function(e,t,r,n){var i=[];e(t,function(e,t){r(e,function(e,r){i=i.concat(r||[]),t(e)})},function(e){n(e,i)})};a.concat=l(S),a.concatSeries=p(S),a.whilst=function(e,t,r){e()?t(function(n){return n?r(n):void a.whilst(e,t,r)}):r()},a.doWhilst=function(e,t,r){e(function(n){if(n)return r(n);var i=Array.prototype.slice.call(arguments,1);t.apply(null,i)?a.doWhilst(e,t,r):r()})},a.until=function(e,t,r){e()?r():t(function(n){return n?r(n):void a.until(e,t,r)})},a.doUntil=function(e,t,r){e(function(n){if(n)return r(n);var i=Array.prototype.slice.call(arguments,1);t.apply(null,i)?r():a.doUntil(e,t,r)})},a.queue=function(e,t){function n(e,t,r,n){return e.started||(e.started=!0),f(t)||(t=[t]),0==t.length?a.setImmediate(function(){e.drain&&e.drain()}):void o(t,function(t){var i={data:t,callback:"function"==typeof n?n:null};r?e.tasks.unshift(i):e.tasks.push(i),e.saturated&&e.tasks.length===e.concurrency&&e.saturated(),a.setImmediate(e.process)})}void 0===t&&(t=1);var i=0,s={tasks:[],concurrency:t,saturated:null,empty:null,drain:null,started:!1,paused:!1,push:function(e,t){n(s,e,!1,t)},kill:function(){s.drain=null,s.tasks=[]},unshift:function(e,t){n(s,e,!0,t)},process:function(){if(!s.paused&&i<s.concurrency&&s.tasks.length){var t=s.tasks.shift();s.empty&&0===s.tasks.length&&s.empty(),i+=1;var n=function(){i-=1,t.callback&&t.callback.apply(t,arguments),s.drain&&s.tasks.length+i===0&&s.drain(),s.process()},a=r(n);e(t.data,a)}},length:function(){return s.tasks.length},running:function(){return i},idle:function(){return s.tasks.length+i===0},pause:function(){s.paused!==!0&&(s.paused=!0,s.process())},resume:function(){s.paused!==!1&&(s.paused=!1,s.process())}};return s},a.cargo=function(e,t){var r=!1,n=[],i={tasks:n,payload:t,saturated:null,empty:null,drain:null,drained:!0,push:function(e,r){f(e)||(e=[e]),o(e,function(e){n.push({data:e,callback:"function"==typeof r?r:null}),i.drained=!1,i.saturated&&n.length===t&&i.saturated()}),a.setImmediate(i.process)},process:function s(){if(!r){if(0===n.length)return i.drain&&!i.drained&&i.drain(),void(i.drained=!0);var a="number"==typeof t?n.splice(0,t):n.splice(0,n.length),f=c(a,function(e){return e.data});i.empty&&i.empty(),r=!0,e(f,function(){r=!1;var e=arguments;o(a,function(t){t.callback&&t.callback.apply(null,e)}),s()})}},length:function(){return n.length},running:function(){return r}};return i};var E=function(e){return function(t){var r=Array.prototype.slice.call(arguments,1);t.apply(null,r.concat([function(t){var r=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(t?console.error&&console.error(t):console[e]&&o(r,function(t){console[e](t)}))}]))}};a.log=E("log"),a.dir=E("dir"),a.memoize=function(e,t){var r={},n={};t=t||function(e){return e};var i=function(){var i=Array.prototype.slice.call(arguments),s=i.pop(),f=t.apply(null,i);f in r?a.nextTick(function(){s.apply(null,r[f])}):f in n?n[f].push(s):(n[f]=[s],e.apply(null,i.concat([function(){r[f]=arguments;var e=n[f];delete n[f];for(var t=0,i=e.length;i>t;t++)e[t].apply(null,arguments)}])))};return i.memo=r,i.unmemoized=e,i},a.unmemoize=function(e){return function(){return(e.unmemoized||e).apply(null,arguments)}},a.times=function(e,t,r){for(var n=[],i=0;e>i;i++)n.push(i);return a.map(n,t,r)},a.timesSeries=function(e,t,r){for(var n=[],i=0;e>i;i++)n.push(i);return a.mapSeries(n,t,r)},a.seq=function(){var e=arguments;return function(){var t=this,r=Array.prototype.slice.call(arguments),n=r.pop();a.reduce(e,r,function(e,r,n){r.apply(t,e.concat([function(){var e=arguments[0],t=Array.prototype.slice.call(arguments,1);n(e,t)}]))},function(e,r){n.apply(t,[e].concat(r))})}},a.compose=function(){return a.seq.apply(null,Array.prototype.reverse.call(arguments))};var k=function(e,t){var r=function(){var r=this,n=Array.prototype.slice.call(arguments),i=n.pop();return e(t,function(e,t){e.apply(r,n.concat([t]))},i)};if(arguments.length>2){var n=Array.prototype.slice.call(arguments,2);return r.apply(this,n)}return r};a.applyEach=l(k),a.applyEachSeries=p(k),a.forever=function(e,t){function r(n){if(n){if(t)return t(n);throw n}e(r)}r()},"undefined"!=typeof t&&t.exports?t.exports=a:"undefined"!=typeof define&&define.amd?define([],function(){return a}):n.async=a}()}).call(this,e("_process"))},{_process:163}],15:[function(){},{}],16:[function(e,t,r){arguments[4][15][0].apply(r,arguments)},{dup:15}],17:[function(e,t,r){function n(e,t,r){if(!(this instanceof n))return new n(e,t,r);var i,a=typeof e;if("number"===a)i=e>0?e>>>0:0;else if("string"===a)i=n.byteLength(e,t);else{if("object"!==a||null===e)throw new TypeError("must start with number, buffer, array or string");"Buffer"===e.type&&q(e.data)&&(e=e.data),i=+e.length>0?Math.floor(+e.length):0}if(i>D)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+D.toString(16)+" bytes");var s;n.TYPED_ARRAY_SUPPORT?s=n._augment(new Uint8Array(i)):(s=this,s.length=i,s._isBuffer=!0);var f;if(n.TYPED_ARRAY_SUPPORT&&"number"==typeof e.byteLength)s._set(e);else if(x(e))if(n.isBuffer(e))for(f=0;i>f;f++)s[f]=e.readUInt8(f);else for(f=0;i>f;f++)s[f]=(e[f]%256+256)%256;else if("string"===a)s.write(e,0,t);else if("number"===a&&!n.TYPED_ARRAY_SUPPORT&&!r)for(f=0;i>f;f++)s[f]=0;return i>0&&i<=n.poolSize&&(s.parent=U),s}function i(e,t,r){if(!(this instanceof i))return new i(e,t,r);var a=new n(e,t,r);return delete a.parent,a}function a(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var a=t.length;if(a%2!==0)throw new Error("Invalid hex string");n>a/2&&(n=a/2);for(var s=0;n>s;s++){var f=parseInt(t.substr(2*s,2),16);if(isNaN(f))throw new Error("Invalid hex string");e[r+s]=f}return s}function s(e,t,r,n){var i=C(B(t,e.length-r),e,r,n);return i}function f(e,t,r,n){var i=C(j(t),e,r,n);return i}function o(e,t,r,n){return f(e,t,r,n)}function c(e,t,r,n){var i=C(M(t),e,r,n);return i}function d(e,t,r,n){var i=C(R(t,e.length-r),e,r,n,2);return i}function u(e,t,r){return T.fromByteArray(0===t&&r===e.length?e:e.slice(t,r))}function h(e,t,r){var n="",i="";r=Math.min(e.length,r);for(var a=t;r>a;a++)e[a]<=127?(n+=P(i)+String.fromCharCode(e[a]),i=""):i+="%"+e[a].toString(16);return n+P(i)}function l(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(127&e[i]);return n}function b(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;r>i;i++)n+=String.fromCharCode(e[i]);return n}function p(e,t,r){var n=e.length;(!t||0>t)&&(t=0),(!r||0>r||r>n)&&(r=n);for(var i="",a=t;r>a;a++)i+=I(e[a]);return i}function g(e,t,r){for(var n=e.slice(t,r),i="",a=0;a<n.length;a+=2)i+=String.fromCharCode(n[a]+256*n[a+1]);return i}function v(e,t,r){if(e%1!==0||0>e)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function y(e,t,r,i,a,s){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");if(t>a||s>t)throw new RangeError("value is out of bounds");if(r+i>e.length)throw new RangeError("index out of range")}function m(e,t,r,n){0>t&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);a>i;i++)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function w(e,t,r,n){0>t&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);a>i;i++)e[r+i]=t>>>8*(n?i:3-i)&255}function _(e,t,r,n,i,a){if(t>i||a>t)throw new RangeError("value is out of bounds");if(r+n>e.length)throw new RangeError("index out of range");if(0>r)throw new RangeError("index out of range")}function S(e,t,r,n,i){return i||_(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),L.write(e,t,r,n,23,4),r+4}function E(e,t,r,n,i){return i||_(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),L.write(e,t,r,n,52,8),r+8}function k(e){if(e=A(e).replace(z,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function A(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function x(e){return q(e)||n.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function I(e){return 16>e?"0"+e.toString(16):e.toString(16)}function B(e,t){var r,n=e.length,i=null;t=t||1/0;for(var a=[],s=0;n>s;s++){if(r=e.charCodeAt(s),r>55295&&57344>r){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(56320>r){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&((t-=3)>-1&&a.push(239,191,189),i=null);if(128>r){if((t-=1)<0)break;a.push(r)}else if(2048>r){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(65536>r){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(2097152>r))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function j(e){for(var t=[],r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return t}function R(e,t){for(var r,n,i,a=[],s=0;s<e.length&&!((t-=2)<0);s++)r=e.charCodeAt(s),n=r>>8,i=r%256,a.push(i),a.push(n);return a}function M(e){return T.toByteArray(k(e))}function C(e,t,r,n,i){i&&(n-=n%i);for(var a=0;n>a&&!(a+r>=t.length||a>=e.length);a++)t[a+r]=e[a];return a}function P(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org> * @license MIT */ var T=e("base64-js"),L=e("ieee754"),q=e("is-array");r.Buffer=n,r.SlowBuffer=i,r.INSPECT_MAX_BYTES=50,n.poolSize=8192;var D=1073741823,U={};n.TYPED_ARRAY_SUPPORT=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray&&0===new Uint8Array(1).subarray(1,1).byteLength}catch(r){return!1}}(),n.isBuffer=function(e){return!(null==e||!e._isBuffer)},n.compare=function(e,t){if(!n.isBuffer(e)||!n.isBuffer(t))throw new TypeError("Arguments must be Buffers");for(var r=e.length,i=t.length,a=0,s=Math.min(r,i);s>a&&e[a]===t[a];a++);return a!==s&&(r=e[a],i=t[a]),i>r?-1:r>i?1:0},n.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},n.concat=function(e,t){if(!q(e))throw new TypeError("Usage: Buffer.concat(list[, length])");if(0===e.length)return new n(0);if(1===e.length)return e[0];var r;if(void 0===t)for(t=0,r=0;r<e.length;r++)t+=e[r].length;var i=new n(t),a=0;for(r=0;r<e.length;r++){var s=e[r];s.copy(i,a),a+=s.length}return i},n.byteLength=function(e,t){var r;switch(e+="",t||"utf8"){case"ascii":case"binary":case"raw":r=e.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":r=2*e.length;break;case"hex":r=e.length>>>1;break;case"utf8":case"utf-8":r=B(e).length;break;case"base64":r=M(e).length;break;default:r=e.length}return r},n.prototype.length=void 0,n.prototype.parent=void 0,n.prototype.toString=function(e,t,r){var n=!1;if(t>>>=0,r=void 0===r||1/0===r?this.length:r>>>0,e||(e="utf8"),0>t&&(t=0),r>this.length&&(r=this.length),t>=r)return"";for(;;)switch(e){case"hex":return p(this,t,r);case"utf8":case"utf-8":return h(this,t,r);case"ascii":return l(this,t,r);case"binary":return b(this,t,r);case"base64":return u(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return g(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}},n.prototype.equals=function(e){if(!n.isBuffer(e))throw new TypeError("Argument must be a Buffer");return 0===n.compare(this,e)},n.prototype.inspect=function(){var e="",t=r.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),"<Buffer "+e+">"},n.prototype.compare=function(e){if(!n.isBuffer(e))throw new TypeError("Argument must be a Buffer");return n.compare(this,e)},n.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},n.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},n.prototype.write=function(e,t,r,n){if(isFinite(t))isFinite(r)||(n=r,r=void 0);else{var i=n;n=t,t=r,r=i}if(t=Number(t)||0,0>r||0>t||t>this.length)throw new RangeError("attempt to write outside buffer bounds");var u=this.length-t;r?(r=Number(r),r>u&&(r=u)):r=u,n=String(n||"utf8").toLowerCase();var h;switch(n){case"hex":h=a(this,e,t,r);break;case"utf8":case"utf-8":h=s(this,e,t,r);break;case"ascii":h=f(this,e,t,r);break;case"binary":h=o(this,e,t,r);break;case"base64":h=c(this,e,t,r);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=d(this,e,t,r);break;default:throw new TypeError("Unknown encoding: "+n)}return h},n.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},n.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),e>t&&(t=e);var i;if(n.TYPED_ARRAY_SUPPORT)i=n._augment(this.subarray(e,t));else{var a=t-e;i=new n(a,void 0,!0);for(var s=0;a>s;s++)i[s]=this[s+e]}return i.length&&(i.parent=this.parent||this),i},n.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=this[e],i=1,a=0;++a<t&&(i*=256);)n+=this[e+a]*i;return n},n.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},n.prototype.readUInt8=function(e,t){return t||v(e,1,this.length),this[e]},n.prototype.readUInt16LE=function(e,t){return t||v(e,2,this.length),this[e]|this[e+1]<<8},n.prototype.readUInt16BE=function(e,t){return t||v(e,2,this.length),this[e]<<8|this[e+1]},n.prototype.readUInt32LE=function(e,t){return t||v(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},n.prototype.readUInt32BE=function(e,t){return t||v(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},n.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=this[e],i=1,a=0;++a<t&&(i*=256);)n+=this[e+a]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*t)),n},n.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=t,i=1,a=this[e+--n];n>0&&(i*=256);)a+=this[e+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*t)),a},n.prototype.readInt8=function(e,t){return t||v(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},n.prototype.readInt16LE=function(e,t){t||v(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt16BE=function(e,t){t||v(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},n.prototype.readInt32LE=function(e,t){return t||v(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},n.prototype.readInt32BE=function(e,t){return t||v(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},n.prototype.readFloatLE=function(e,t){return t||v(e,4,this.length),L.read(this,e,!0,23,4)},n.prototype.readFloatBE=function(e,t){return t||v(e,4,this.length),L.read(this,e,!1,23,4)},n.prototype.readDoubleLE=function(e,t){return t||v(e,8,this.length),L.read(this,e,!0,52,8)},n.prototype.readDoubleBE=function(e,t){return t||v(e,8,this.length),L.read(this,e,!1,52,8)},n.prototype.writeUIntLE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||y(this,e,t,r,Math.pow(2,8*r),0);var i=1,a=0;for(this[t]=255&e;++a<r&&(i*=256);)this[t+a]=e/i>>>0&255;return t+r},n.prototype.writeUIntBE=function(e,t,r,n){e=+e,t>>>=0,r>>>=0,n||y(this,e,t,r,Math.pow(2,8*r),0);var i=r-1,a=1;for(this[t+i]=255&e;--i>=0&&(a*=256);)this[t+i]=e/a>>>0&255;return t+r},n.prototype.writeUInt8=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,1,255,0),n.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e,t+1},n.prototype.writeUInt16LE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):m(this,e,t,!0),t+2},n.prototype.writeUInt16BE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,2,65535,0),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):m(this,e,t,!1),t+2},n.prototype.writeUInt32LE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e):w(this,e,t,!0),t+4},n.prototype.writeUInt32BE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,4,4294967295,0),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):w(this,e,t,!1),t+4},n.prototype.writeIntLE=function(e,t,r,n){e=+e,t>>>=0,n||y(this,e,t,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var i=0,a=1,s=0>e?1:0;for(this[t]=255&e;++i<r&&(a*=256);)this[t+i]=(e/a>>0)-s&255;return t+r},n.prototype.writeIntBE=function(e,t,r,n){e=+e,t>>>=0,n||y(this,e,t,r,Math.pow(2,8*r-1)-1,-Math.pow(2,8*r-1));var i=r-1,a=1,s=0>e?1:0;for(this[t+i]=255&e;--i>=0&&(a*=256);)this[t+i]=(e/a>>0)-s&255;return t+r},n.prototype.writeInt8=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,1,127,-128),n.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=e,t+1},n.prototype.writeInt16LE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8):m(this,e,t,!0),t+2},n.prototype.writeInt16BE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,2,32767,-32768),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e):m(this,e,t,!1),t+2},n.prototype.writeInt32LE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,4,2147483647,-2147483648),n.TYPED_ARRAY_SUPPORT?(this[t]=e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):w(this,e,t,!0),t+4},n.prototype.writeInt32BE=function(e,t,r){return e=+e,t>>>=0,r||y(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),n.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e):w(this,e,t,!1),t+4},n.prototype.writeFloatLE=function(e,t,r){return S(this,e,t,!0,r)},n.prototype.writeFloatBE=function(e,t,r){return S(this,e,t,!1,r)},n.prototype.writeDoubleLE=function(e,t,r){return E(this,e,t,!0,r)},n.prototype.writeDoubleBE=function(e,t,r){return E(this,e,t,!1,r)},n.prototype.copy=function(e,t,r,i){var a=this;if(r||(r=0),i||0===i||(i=this.length),t>=e.length&&(t=e.length),t||(t=0),i>0&&r>i&&(i=r),i===r)return 0;if(0===e.length||0===a.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>r||r>=a.length)throw new RangeError("sourceStart out of bounds");if(0>i)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),e.length-t<i-r&&(i=e.length-t+r);var s=i-r;if(1e3>s||!n.TYPED_ARRAY_SUPPORT)for(var f=0;s>f;f++)e[f+t]=this[f+r];else e._set(this.subarray(r,r+s),t);return s},n.prototype.fill=function(e,t,r){if(e||(e=0),t||(t=0),r||(r=this.length),t>r)throw new RangeError("end < start");if(r!==t&&0!==this.length){if(0>t||t>=this.length)throw new RangeError("start out of bounds");if(0>r||r>this.length)throw new RangeError("end out of bounds");var n;if("number"==typeof e)for(n=t;r>n;n++)this[n]=e;else{var i=B(e.toString()),a=i.length;for(n=t;r>n;n++)this[n]=i[n%a]}return this}},n.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(n.TYPED_ARRAY_SUPPORT)return new n(this).buffer;for(var e=new Uint8Array(this.length),t=0,r=e.length;r>t;t+=1)e[t]=this[t];return e.buffer}throw new TypeError("Buffer.toArrayBuffer not supported in this browser")};var O=n.prototype;n._augment=function(e){return e.constructor=n,e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=O.get,e.set=O.set,e.write=O.write,e.toString=O.toString,e.toLocaleString=O.toString,e.toJSON=O.toJSON,e.equals=O.equals,e.compare=O.compare,e.copy=O.copy,e.slice=O.slice,e.readUIntLE=O.readUIntLE,e.readUIntBE=O.readUIntBE,e.readUInt8=O.readUInt8,e.readUInt16LE=O.readUInt16LE,e.readUInt16BE=O.readUInt16BE,e.readUInt32LE=O.readUInt32LE,e.readUInt32BE=O.readUInt32BE,e.readIntLE=O.readIntLE,e.readIntBE=O.readIntBE,e.readInt8=O.readInt8,e.readInt16LE=O.readInt16LE,e.readInt16BE=O.readInt16BE,e.readInt32LE=O.readInt32LE,e.readInt32BE=O.readInt32BE,e.readFloatLE=O.readFloatLE,e.readFloatBE=O.readFloatBE,e.readDoubleLE=O.readDoubleLE,e.readDoubleBE=O.readDoubleBE,e.writeUInt8=O.writeUInt8,e.writeUIntLE=O.writeUIntLE,e.writeUIntBE=O.writeUIntBE,e.writeUInt16LE=O.writeUInt16LE,e.writeUInt16BE=O.writeUInt16BE,e.writeUInt32LE=O.writeUInt32LE,e.writeUInt32BE=O.writeUInt32BE,e.writeIntLE=O.writeIntLE,e.writeIntBE=O.writeIntBE,e.writeInt8=O.writeInt8,e.writeInt16LE=O.writeInt16LE,e.writeInt16BE=O.writeInt16BE,e.writeInt32LE=O.writeInt32LE,e.writeInt32BE=O.writeInt32BE,e.writeFloatLE=O.writeFloatLE,e.writeFloatBE=O.writeFloatBE,e.writeDoubleLE=O.writeDoubleLE,e.writeDoubleBE=O.writeDoubleBE,e.fill=O.fill,e.inspect=O.inspect,e.toArrayBuffer=O.toArrayBuffer,e};var z=/[^+\/0-9A-z\-]/g},{"base64-js":18,ieee754:19,"is-array":20}],18:[function(e,t,r){var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===s||t===u?62:t===f||t===h?63:o>t?-1:o+10>t?t-o+26+26:d+26>t?t-d:c+26>t?t-c+26:void 0}function r(e){function r(e){c[u++]=e}var n,i,s,f,o,c;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var d=e.length;o="="===e.charAt(d-2)?2:"="===e.charAt(d-1)?1:0,c=new a(3*e.length/4-o),s=o>0?e.length-4:e.length;var u=0;for(n=0,i=0;s>n;n+=4,i+=3)f=t(e.charAt(n))<<18|t(e.charAt(n+1))<<12|t(e.charAt(n+2))<<6|t(e.charAt(n+3)),r((16711680&f)>>16),r((65280&f)>>8),r(255&f);return 2===o?(f=t(e.charAt(n))<<2|t(e.charAt(n+1))>>4,r(255&f)):1===o&&(f=t(e.charAt(n))<<10|t(e.charAt(n+1))<<4|t(e.charAt(n+2))>>2,r(f>>8&255),r(255&f)),c}function i(e){function t(e){return n.charAt(e)}function r(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,a,s,f=e.length%3,o="";for(i=0,s=e.length-f;s>i;i+=3)a=(e[i]<<16)+(e[i+1]<<8)+e[i+2],o+=r(a);switch(f){case 1:a=e[e.length-1],o+=t(a>>2),o+=t(a<<4&63),o+="==";break;case 2:a=(e[e.length-2]<<8)+e[e.length-1],o+=t(a>>10),o+=t(a>>4&63),o+=t(a<<2&63),o+="="}return o}var a="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),f="/".charCodeAt(0),o="0".charCodeAt(0),c="a".charCodeAt(0),d="A".charCodeAt(0),u="-".charCodeAt(0),h="_".charCodeAt(0);e.toByteArray=r,e.fromByteArray=i}("undefined"==typeof r?this.base64js={}:r)},{}],19:[function(e,t,r){r.read=function(e,t,r,n,i){var a,s,f=8*i-n-1,o=(1<<f)-1,c=o>>1,d=-7,u=r?i-1:0,h=r?-1:1,l=e[t+u];for(u+=h,a=l&(1<<-d)-1,l>>=-d,d+=f;d>0;a=256*a+e[t+u],u+=h,d-=8);for(s=a&(1<<-d)-1,a>>=-d,d+=n;d>0;s=256*s+e[t+u],u+=h,d-=8);if(0===a)a=1-c;else{if(a===o)return s?0/0:1/0*(l?-1:1);s+=Math.pow(2,n),a-=c}return(l?-1:1)*s*Math.pow(2,a-n)},r.write=function(e,t,r,n,i,a){var s,f,o,c=8*a-i-1,d=(1<<c)-1,u=d>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:a-1,b=n?1:-1,p=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||1/0===t?(f=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(o=Math.pow(2,-s))<1&&(s--,o*=2),t+=s+u>=1?h/o:h*Math.pow(2,1-u),t*o>=2&&(s++,o/=2),s+u>=d?(f=0,s=d):s+u>=1?(f=(t*o-1)*Math.pow(2,i),s+=u):(f=t*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;e[r+l]=255&f,l+=b,f/=256,i-=8);for(s=s<<i|f,c+=i;c>0;e[r+l]=255&s,l+=b,s/=256,c-=8);e[r+l-b]|=128*p}},{}],20:[function(e,t){var r=Array.isArray,n=Object.prototype.toString;t.exports=r||function(e){return!!e&&"[object Array]"==n.call(e)}},{}],21:[function(e,t,r){"use strict";function n(){var e=[].slice.call(arguments).join(" ");throw new Error([e,"we accept pull requests","http://github.com/dominictarr/crypto-browserify"].join("\n"))}function i(e,t){for(var r in e)t(e[r],r)}r.randomBytes=r.rng=e("randombytes");var a=r.prng=e("./prng");r.createHash=r.Hash=e("create-hash"),r.createHmac=r.Hmac=e("create-hmac"),r.pseudoRandomBytes=function(e,t){if(!t||!t.call)return a(e);var r;try{r=a(e)}catch(n){return t(n)}t.call(this,void 0,r)};var s=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(Object.keys(e("browserify-sign/algos")));r.getHashes=function(){return s};var f=e("./pbkdf2")(r);r.pbkdf2=f.pbkdf2,r.pbkdf2Sync=f.pbkdf2Sync;var o=e("browserify-aes");["Cipher","createCipher","Cipheriv","createCipheriv","Decipher","createDecipher","Decipheriv","createDecipheriv","getCiphers","listCiphers"].forEach(function(e){r[e]=o[e]}),e("browserify-sign/inject")(t.exports,r),e("diffie-hellman/inject")(r,t.exports),e("create-ecdh/inject")(t.exports,r),e("public-encrypt/inject")(t.exports,r),i(["createCredentials"],function(e){r[e]=function(){n("sorry,",e,"is not implemented yet")}})},{"./pbkdf2":157,"./prng":158,"browserify-aes":25,"browserify-sign/algos":40,"browserify-sign/inject":41,"create-ecdh/inject":87,"create-hash":109,"create-hmac":120,"diffie-hellman/inject":123,"public-encrypt/inject":129,randombytes:156}],22:[function(e,t){(function(r){function n(e,t,n){r.isBuffer(e)||(e=new r(e,"binary")),t/=8,n=n||0;for(var a,s,f=0,o=0,c=new r(t),d=new r(n),u=0,h=[];;){if(u++>0&&h.push(a),h.push(e),a=i(r.concat(h)),h=[],s=0,t>0)for(;;){if(0===t)break;if(s===a.length)break;c[f++]=a[s],t--,s++}if(n>0&&s!==a.length)for(;;){if(0===n)break;if(s===a.length)break;d[o++]=a[s],n--,s++}if(0===t&&0===n)break}for(s=0;s<a.length;s++)a[s]=0;return{key:c,iv:d}}var i=e("create-hash/md5");t.exports=n}).call(this,e("buffer").Buffer)},{buffer:17,"create-hash/md5":111}],23:[function(e,t,r){(function(e){function t(e){var t,r;return t=e>f||0>e?(r=Math.abs(e)%f,0>e?f-r:r):e}function n(e){var t,r,n;for(t=r=0,n=e.length;n>=0?n>r:r>n;t=n>=0?++r:--r)e[t]=0;return!1}function i(){var e;this.SBOX=[],this.INV_SBOX=[],this.SUB_MIX=function(){var t,r;for(r=[],e=t=0;4>t;e=++t)r.push([]);return r}(),this.INV_SUB_MIX=function(){var t,r;for(r=[],e=t=0;4>t;e=++t)r.push([]);return r}(),this.init(),this.RCON=[0,1,2,4,8,16,32,64,128,27,54]}function a(e){for(var t=e.length/4,r=new Array(t),n=-1;++n<t;)r[n]=e.readUInt32BE(4*n);return r}function s(e){this._key=a(e),this._doReset()}var f=Math.pow(2,32);i.prototype.init=function(){var e,t,r,n,i,a,s,f,o,c;for(e=function(){var e,r;for(r=[],t=e=0;256>e;t=++e)r.push(128>t?t<<1:t<<1^283);return r}(),i=0,o=0,t=c=0;256>c;t=++c)r=o^o<<1^o<<2^o<<3^o<<4,r=r>>>8^255&r^99,this.SBOX[i]=r,this.INV_SBOX[r]=i,a=e[i],s=e[a],f=e[s],n=257*e[r]^16843008*r,this.SUB_MIX[0][i]=n<<24|n>>>8,this.SUB_MIX[1][i]=n<<16|n>>>16,this.SUB_MIX[2][i]=n<<8|n>>>24,this.SUB_MIX[3][i]=n,n=16843009*f^65537*s^257*a^16843008*i,this.INV_SUB_MIX[0][r]=n<<24|n>>>8,this.INV_SUB_MIX[1][r]=n<<16|n>>>16,this.INV_SUB_MIX[2][r]=n<<8|n>>>24,this.INV_SUB_MIX[3][r]=n,0===i?i=o=1:(i=a^e[e[e[f^a]]],o^=e[e[o]]);return!0};var o=new i;s.blockSize=16,s.prototype.blockSize=s.blockSize,s.keySize=32,s.prototype.keySize=s.keySize,s.prototype._doReset=function(){var e,t,r,n,i,a,s,f;for(r=this._key,t=r.length,this._nRounds=t+6,i=4*(this._nRounds+1),this._keySchedule=[],n=s=0;i>=0?i>s:s>i;n=i>=0?++s:--s)this._keySchedule[n]=t>n?r[n]:(a=this._keySchedule[n-1],n%t===0?(a=a<<8|a>>>24,a=o.SBOX[a>>>24]<<24|o.SBOX[a>>>16&255]<<16|o.SBOX[a>>>8&255]<<8|o.SBOX[255&a],a^=o.RCON[n/t|0]<<24):t>6&&n%t===4?a=o.SBOX[a>>>24]<<24|o.SBOX[a>>>16&255]<<16|o.SBOX[a>>>8&255]<<8|o.SBOX[255&a]:void 0,this._keySchedule[n-t]^a);for(this._invKeySchedule=[],e=f=0;i>=0?i>f:f>i;e=i>=0?++f:--f)n=i-e,a=this._keySchedule[n-(e%4?0:4)],this._invKeySchedule[e]=4>e||4>=n?a:o.INV_SUB_MIX[0][o.SBOX[a>>>24]]^o.INV_SUB_MIX[1][o.SBOX[a>>>16&255]]^o.INV_SUB_MIX[2][o.SBOX[a>>>8&255]]^o.INV_SUB_MIX[3][o.SBOX[255&a]];return!0},s.prototype.encryptBlock=function(t){t=a(new e(t));var r=this._doCryptBlock(t,this._keySchedule,o.SUB_MIX,o.SBOX),n=new e(16);return n.writeUInt32BE(r[0],0),n.writeUInt32BE(r[1],4),n.writeUInt32BE(r[2],8),n.writeUInt32BE(r[3],12),n},s.prototype.decryptBlock=function(t){t=a(new e(t));var r=[t[3],t[1]];t[1]=r[0],t[3]=r[1];var n=this._doCryptBlock(t,this._invKeySchedule,o.INV_SUB_MIX,o.INV_SBOX),i=new e(16);return i.writeUInt32BE(n[0],0),i.writeUInt32BE(n[3],4),i.writeUInt32BE(n[2],8),i.writeUInt32BE(n[1],12),i},s.prototype.scrub=function(){n(this._keySchedule),n(this._invKeySchedule),n(this._key)},s.prototype._doCryptBlock=function(e,r,n,i){var a,s,f,o,c,d,u,h,l,b,p,g;for(f=e[0]^r[0],o=e[1]^r[1],c=e[2]^r[2],d=e[3]^r[3],a=4,s=p=1,g=this._nRounds;g>=1?g>p:p>g;s=g>=1?++p:--p)u=n[0][f>>>24]^n[1][o>>>16&255]^n[2][c>>>8&255]^n[3][255&d]^r[a++],h=n[0][o>>>24]^n[1][c>>>16&255]^n[2][d>>>8&255]^n[3][255&f]^r[a++],l=n[0][c>>>24]^n[1][d>>>16&255]^n[2][f>>>8&255]^n[3][255&o]^r[a++],b=n[0][d>>>24]^n[1][f>>>16&255]^n[2][o>>>8&255]^n[3][255&c]^r[a++],f=u,o=h,c=l,d=b;return u=(i[f>>>24]<<24|i[o>>>16&255]<<16|i[c>>>8&255]<<8|i[255&d])^r[a++],h=(i[o>>>24]<<24|i[c>>>16&255]<<16|i[d>>>8&255]<<8|i[255&f])^r[a++],l=(i[c>>>24]<<24|i[d>>>16&255]<<16|i[f>>>8&255]<<8|i[255&o])^r[a++],b=(i[d>>>24]<<24|i[f>>>16&255]<<16|i[o>>>8&255]<<8|i[255&c])^r[a++],[t(u),t(h),t(l),t(b)]},r.AES=s}).call(this,e("buffer").Buffer)},{buffer:17}],24:[function(e,t){(function(r){function n(e,t,i,f){if(!(this instanceof n))return new n(e,t,i);s.call(this),this._finID=r.concat([i,new r([0,0,0,1])]),i=r.concat([i,new r([0,0,0,2])]),this._cipher=new a.AES(t),this._prev=new r(i.length),this._cache=new r(""),this._secCache=new r(""),this._decrypt=f,this._alen=0,this._len=0,i.copy(this._prev),this._mode=e;var c=new r(4);c.fill(0),this._ghash=new o(this._cipher.encryptBlock(c)),this._authTag=null,this._called=!1}function i(e,t){var r=0;e.length!==t.length&&r++;for(var n=Math.min(e.length,t.length),i=-1;++i<n;)r+=e[i]^t[i];return r}var a=e("./aes"),s=e("./cipherBase"),f=e("inherits"),o=e("./ghash"),c=e("./xor");f(n,s),t.exports=n,n.prototype._update=function(e){if(!this._called&&this._alen){var t=16-this._alen%16;16>t&&(t=new r(t),t.fill(0),this._ghash.update(t))}this._called=!0;var n=this._mode.encrypt(this,e);return this._ghash.update(this._decrypt?e:n),this._len+=e.length,n},n.prototype._final=function(){if(this._decrypt&&!this._authTag)throw new Error("Unsupported state or unable to authenticate data");var e=c(this._ghash["final"](8*this._alen,8*this._len),this._cipher.encryptBlock(this._finID));if(this._decrypt){if(i(e,this._authTag))throw new Error("Unsupported state or unable to authenticate data")}else this._authTag=e;this._cipher.scrub()},n.prototype.getAuthTag=function(){if(!this._decrypt&&r.isBuffer(this._authTag))return this._authTag;throw new Error("Attempting to get auth tag in unsupported state")},n.prototype.setAuthTag=function(e){if(!this._decrypt)throw new Error("Attempting to set auth tag in unsupported state");this._authTag=e},n.prototype.setAAD=function(e){if(this._called)throw new Error("Attempting to set AAD in unsupported state");this._ghash.update(e),this._alen+=e.length}}).call(this,e("buffer").Buffer)},{"./aes":23,"./cipherBase":26,"./ghash":29,"./xor":39,buffer:17,inherits:160}],25:[function(e,t,r){function n(){return Object.keys(s)}var i=e("./encrypter");r.createCipher=r.Cipher=i.createCipher,r.createCipheriv=r.Cipheriv=i.createCipheriv;var a=e("./decrypter");r.createDecipher=r.Decipher=a.createDecipher,r.createDecipheriv=r.Decipheriv=a.createDecipheriv;var s=e("./modes");r.listCiphers=r.getCiphers=n},{"./decrypter":27,"./encrypter":28,"./modes":30}],26:[function(e,t){(function(r){function n(){i.call(this)}var i=e("stream").Transform,a=e("inherits");t.exports=n,a(n,i),n.prototype.update=function(e,t,n){"string"==typeof e&&(e=new r(e,t));var i=this._update(e);return n&&(i=i.toString(n)),i},n.prototype._transform=function(e,t,r){this.push(this._update(e)),r()},n.prototype._flush=function(e){try{this.push(this._final())}catch(t){return e(t)}e()},n.prototype["final"]=function(e){var t=this._final()||new r("");return e&&(t=t.toString(e)),t}}).call(this,e("buffer").Buffer)},{buffer:17,inherits:160,stream:175}],27:[function(e,t,r){(function(t){function n(e,r,a){return this instanceof n?(c.call(this),this._cache=new i,this._last=void 0,this._cipher=new o.AES(r),this._prev=new t(a.length),a.copy(this._prev),this._mode=e,void(this._autopadding=!0)):new n(e,r,a)}function i(){return this instanceof i?void(this.cache=new t("")):new i}function a(e){for(var t=e[15],r=-1;++r<t;)if(e[r+(16-t)]!==t)throw new Error("unable to decrypt data");return 16!==t?e.slice(0,16-t):void 0}function s(e,r,i){var a=u[e.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof i&&(i=new t(i)),"string"==typeof r&&(r=new t(r)),r.length!==a.key/8)throw new TypeError("invalid key length "+r.length);if(i.length!==a.iv)throw new TypeError("invalid iv length "+i.length);return"stream"===a.type?new h(p[a.mode],r,i,!0):"auth"===a.type?new l(p[a.mode],r,i,!0):new n(p[a.mode],r,i)}function f(e,t){var r=u[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=b(t,r.key,r.iv);return s(e,n.key,n.iv)}var o=e("./aes"),c=e("./cipherBase"),d=e("inherits"),u=e("./modes"),h=e("./streamCipher"),l=e("./authCipher"),b=e("./EVP_BytesToKey");d(n,c),n.prototype._update=function(e){this._cache.add(e);for(var r,n,i=[];r=this._cache.get(this._autopadding);)n=this._mode.decrypt(this,r),i.push(n);return t.concat(i)},n.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return a(this._mode.decrypt(this,e));if(e)throw new Error("data not multiple of block length")},n.prototype.setAutoPadding=function(e){this._autopadding=!!e},i.prototype.add=function(e){this.cache=t.concat([this.cache,e])},i.prototype.get=function(e){var t;if(e){if(this.cache.length>16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},i.prototype.flush=function(){return this.cache.length?this.cache:void 0};var p={ECB:e("./modes/ecb"),CBC:e("./modes/cbc"),CFB:e("./modes/cfb"),CFB8:e("./modes/cfb8"),CFB1:e("./modes/cfb1"),OFB:e("./modes/ofb"),CTR:e("./modes/ctr"),GCM:e("./modes/ctr")};r.createDecipher=f,r.createDecipheriv=s}).call(this,e("buffer").Buffer)},{"./EVP_BytesToKey":22,"./aes":23,"./authCipher":24,"./cipherBase":26,"./modes":30,"./modes/cbc":31,"./modes/cfb":32,"./modes/cfb1":33,"./modes/cfb8":34,"./modes/ctr":35,"./modes/ecb":36,"./modes/ofb":37,"./streamCipher":38,buffer:17,inherits:160}],28:[function(e,t,r){(function(t){function n(e,r,a){return this instanceof n?(o.call(this),this._cache=new i,this._cipher=new f.AES(r),this._prev=new t(a.length),a.copy(this._prev),this._mode=e,void(this._autopadding=!0)):new n(e,r,a)}function i(){return this instanceof i?void(this.cache=new t("")):new i}function a(e,r,i){var a=d[e.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof i