diff --git a/bower.json b/bower.json index 424e1d0..39829f9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "filer", - "version": "0.0.27", + "version": "0.0.28", "main": "dist/filer.js", "devDependencies": { "mocha": "1.17.1", diff --git a/dist/filer.js b/dist/filer.js index db68285..a91af50 100644 --- a/dist/filer.js +++ b/dist/filer.js @@ -3,7 +3,7 @@ /*global setImmediate: false, setTimeout: false, console: false */ /** - * https://raw.github.com/caolan/async/master/lib/async.js Feb 18, 2014 + * async.js shim, based on https://raw.github.com/caolan/async/master/lib/async.js Feb 18, 2014 * Used under MIT - https://github.com/caolan/async/blob/master/LICENSE */ @@ -11,74 +11,7 @@ var async = {}; - // global on the server, window in the browser - var root, previous_async; - - root = this; - if (root != null) { - previous_async = root.async; - } - - async.noConflict = function () { - root.async = previous_async; - return async; - }; - - function only_once(fn) { - var called = false; - return function() { - if (called) throw new Error("Callback was already called."); - called = true; - fn.apply(root, arguments); - } - } - - //// cross-browser compatiblity functions //// - - var _each = function (arr, iterator) { - if (arr.forEach) { - return arr.forEach(iterator); - } - for (var i = 0; i < arr.length; i += 1) { - iterator(arr[i], i, arr); - } - }; - - var _map = function (arr, iterator) { - if (arr.map) { - return arr.map(iterator); - } - var results = []; - _each(arr, function (x, i, a) { - results.push(iterator(x, i, a)); - }); - return results; - }; - - var _reduce = function (arr, iterator, memo) { - if (arr.reduce) { - return arr.reduce(iterator, memo); - } - _each(arr, function (x, i, a) { - memo = iterator(memo, x, i, a); - }); - return memo; - }; - - var _keys = function (obj) { - if (Object.keys) { - return Object.keys(obj); - } - var keys = []; - for (var k in obj) { - if (obj.hasOwnProperty(k)) { - keys.push(k); - } - } - return keys; - }; - - //// exported async module functions //// + // async.js functions used in Filer //// nextTick implementation with browser-compatible fallback //// if (typeof process === 'undefined' || !(process.nextTick)) { @@ -109,29 +42,6 @@ } } - async.each = function (arr, iterator, callback) { - callback = callback || function () {}; - if (!arr.length) { - return callback(); - } - var completed = 0; - _each(arr, function (x) { - iterator(x, only_once(function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - if (completed >= arr.length) { - callback(null); - } - } - })); - }); - }; - async.forEach = async.each; - async.eachSeries = function (arr, iterator, callback) { callback = callback || function () {}; if (!arr.length) { @@ -147,7 +57,7 @@ else { completed += 1; if (completed >= arr.length) { - callback(null); + callback(); } else { iterate(); @@ -159,795 +69,6 @@ }; async.forEachSeries = async.eachSeries; - async.eachLimit = function (arr, limit, iterator, callback) { - var fn = _eachLimit(limit); - fn.apply(null, [arr, iterator, callback]); - }; - async.forEachLimit = async.eachLimit; - - var _eachLimit = function (limit) { - - return function (arr, iterator, callback) { - callback = callback || function () {}; - if (!arr.length || limit <= 0) { - return callback(); - } - var completed = 0; - var started = 0; - var running = 0; - - (function replenish () { - if (completed >= arr.length) { - return callback(); - } - - while (running < limit && started < arr.length) { - started += 1; - running += 1; - iterator(arr[started - 1], function (err) { - if (err) { - callback(err); - callback = function () {}; - } - else { - completed += 1; - running -= 1; - if (completed >= arr.length) { - callback(); - } - else { - replenish(); - } - } - }); - } - })(); - }; - }; - - - var doParallel = function (fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - return fn.apply(null, [async.each].concat(args)); - }; - }; - var doParallelLimit = function(limit, fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - return fn.apply(null, [_eachLimit(limit)].concat(args)); - }; - }; - var doSeries = function (fn) { - return function () { - var args = Array.prototype.slice.call(arguments); - return fn.apply(null, [async.eachSeries].concat(args)); - }; - }; - - - var _asyncMap = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (err, v) { - results[x.index] = v; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - }; - async.map = doParallel(_asyncMap); - async.mapSeries = doSeries(_asyncMap); - async.mapLimit = function (arr, limit, iterator, callback) { - return _mapLimit(limit)(arr, iterator, callback); - }; - - var _mapLimit = function(limit) { - return doParallelLimit(limit, _asyncMap); - }; - - // reduce only has a series version, as doing reduce in parallel won't - // work in many situations. - async.reduce = function (arr, memo, iterator, callback) { - async.eachSeries(arr, function (x, callback) { - iterator(memo, x, function (err, v) { - memo = v; - callback(err); - }); - }, function (err) { - callback(err, memo); - }); - }; - // inject alias - async.inject = async.reduce; - // foldl alias - async.foldl = async.reduce; - - async.reduceRight = function (arr, memo, iterator, callback) { - var reversed = _map(arr, function (x) { - return x; - }).reverse(); - async.reduce(reversed, memo, iterator, callback); - }; - // foldr alias - async.foldr = async.reduceRight; - - var _filter = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (v) { - if (v) { - results.push(x); - } - callback(); - }); - }, function (err) { - callback(_map(results.sort(function (a, b) { - return a.index - b.index; - }), function (x) { - return x.value; - })); - }); - }; - async.filter = doParallel(_filter); - async.filterSeries = doSeries(_filter); - // select alias - async.select = async.filter; - async.selectSeries = async.filterSeries; - - var _reject = function (eachfn, arr, iterator, callback) { - var results = []; - arr = _map(arr, function (x, i) { - return {index: i, value: x}; - }); - eachfn(arr, function (x, callback) { - iterator(x.value, function (v) { - if (!v) { - results.push(x); - } - callback(); - }); - }, function (err) { - callback(_map(results.sort(function (a, b) { - return a.index - b.index; - }), function (x) { - return x.value; - })); - }); - }; - async.reject = doParallel(_reject); - async.rejectSeries = doSeries(_reject); - - var _detect = function (eachfn, arr, iterator, main_callback) { - eachfn(arr, function (x, callback) { - iterator(x, function (result) { - if (result) { - main_callback(x); - main_callback = function () {}; - } - else { - callback(); - } - }); - }, function (err) { - main_callback(); - }); - }; - async.detect = doParallel(_detect); - async.detectSeries = doSeries(_detect); - - async.some = function (arr, iterator, main_callback) { - async.each(arr, function (x, callback) { - iterator(x, function (v) { - if (v) { - main_callback(true); - main_callback = function () {}; - } - callback(); - }); - }, function (err) { - main_callback(false); - }); - }; - // any alias - async.any = async.some; - - async.every = function (arr, iterator, main_callback) { - async.each(arr, function (x, callback) { - iterator(x, function (v) { - if (!v) { - main_callback(false); - main_callback = function () {}; - } - callback(); - }); - }, function (err) { - main_callback(true); - }); - }; - // all alias - async.all = async.every; - - async.sortBy = function (arr, iterator, callback) { - async.map(arr, function (x, callback) { - iterator(x, function (err, criteria) { - if (err) { - callback(err); - } - else { - callback(null, {value: x, criteria: criteria}); - } - }); - }, function (err, results) { - if (err) { - return callback(err); - } - else { - var fn = function (left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }; - callback(null, _map(results.sort(fn), function (x) { - return x.value; - })); - } - }); - }; - - async.auto = function (tasks, callback) { - callback = callback || function () {}; - var keys = _keys(tasks); - if (!keys.length) { - return callback(null); - } - - var results = {}; - - var listeners = []; - var addListener = function (fn) { - listeners.unshift(fn); - }; - var removeListener = function (fn) { - for (var i = 0; i < listeners.length; i += 1) { - if (listeners[i] === fn) { - listeners.splice(i, 1); - return; - } - } - }; - var taskComplete = function () { - _each(listeners.slice(0), function (fn) { - fn(); - }); - }; - - addListener(function () { - if (_keys(results).length === keys.length) { - callback(null, results); - callback = function () {}; - } - }); - - _each(keys, function (k) { - var task = (tasks[k] instanceof Function) ? [tasks[k]]: tasks[k]; - var taskCallback = function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - if (err) { - var safeResults = {}; - _each(_keys(results), function(rkey) { - safeResults[rkey] = results[rkey]; - }); - safeResults[k] = args; - callback(err, safeResults); - // stop subsequent errors hitting callback multiple times - callback = function () {}; - } - else { - results[k] = args; - async.setImmediate(taskComplete); - } - }; - var requires = task.slice(0, Math.abs(task.length - 1)) || []; - var ready = function () { - return _reduce(requires, function (a, x) { - return (a && results.hasOwnProperty(x)); - }, true) && !results.hasOwnProperty(k); - }; - if (ready()) { - task[task.length - 1](taskCallback, results); - } - else { - var listener = function () { - if (ready()) { - removeListener(listener); - task[task.length - 1](taskCallback, results); - } - }; - addListener(listener); - } - }); - }; - - async.waterfall = function (tasks, callback) { - callback = callback || function () {}; - if (tasks.constructor !== Array) { - var err = new Error('First argument to waterfall must be an array of functions'); - return callback(err); - } - if (!tasks.length) { - return callback(); - } - var wrapIterator = function (iterator) { - return function (err) { - if (err) { - callback.apply(null, arguments); - callback = function () {}; - } - else { - var args = Array.prototype.slice.call(arguments, 1); - var next = iterator.next(); - if (next) { - args.push(wrapIterator(next)); - } - else { - args.push(callback); - } - async.setImmediate(function () { - iterator.apply(null, args); - }); - } - }; - }; - wrapIterator(async.iterator(tasks))(); - }; - - var _parallel = function(eachfn, tasks, callback) { - callback = callback || function () {}; - if (tasks.constructor === Array) { - eachfn.map(tasks, function (fn, callback) { - if (fn) { - fn(function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - callback.call(null, err, args); - }); - } - }, callback); - } - else { - var results = {}; - eachfn.each(_keys(tasks), function (k, callback) { - tasks[k](function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - results[k] = args; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - } - }; - - async.parallel = function (tasks, callback) { - _parallel({ map: async.map, each: async.each }, tasks, callback); - }; - - async.parallelLimit = function(tasks, limit, callback) { - _parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback); - }; - - async.series = function (tasks, callback) { - callback = callback || function () {}; - if (tasks.constructor === Array) { - async.mapSeries(tasks, function (fn, callback) { - if (fn) { - fn(function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - callback.call(null, err, args); - }); - } - }, callback); - } - else { - var results = {}; - async.eachSeries(_keys(tasks), function (k, callback) { - tasks[k](function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (args.length <= 1) { - args = args[0]; - } - results[k] = args; - callback(err); - }); - }, function (err) { - callback(err, results); - }); - } - }; - - async.iterator = function (tasks) { - var makeCallback = function (index) { - var fn = function () { - if (tasks.length) { - tasks[index].apply(null, arguments); - } - return fn.next(); - }; - fn.next = function () { - return (index < tasks.length - 1) ? makeCallback(index + 1): null; - }; - return fn; - }; - return makeCallback(0); - }; - - async.apply = function (fn) { - var args = Array.prototype.slice.call(arguments, 1); - return function () { - return fn.apply( - null, args.concat(Array.prototype.slice.call(arguments)) - ); - }; - }; - - var _concat = function (eachfn, arr, fn, callback) { - var r = []; - eachfn(arr, function (x, cb) { - fn(x, function (err, y) { - r = r.concat(y || []); - cb(err); - }); - }, function (err) { - callback(err, r); - }); - }; - async.concat = doParallel(_concat); - async.concatSeries = doSeries(_concat); - - async.whilst = function (test, iterator, callback) { - if (test()) { - iterator(function (err) { - if (err) { - return callback(err); - } - async.whilst(test, iterator, callback); - }); - } - else { - callback(); - } - }; - - async.doWhilst = function (iterator, test, callback) { - iterator(function (err) { - if (err) { - return callback(err); - } - if (test()) { - async.doWhilst(iterator, test, callback); - } - else { - callback(); - } - }); - }; - - async.until = function (test, iterator, callback) { - if (!test()) { - iterator(function (err) { - if (err) { - return callback(err); - } - async.until(test, iterator, callback); - }); - } - else { - callback(); - } - }; - - async.doUntil = function (iterator, test, callback) { - iterator(function (err) { - if (err) { - return callback(err); - } - if (!test()) { - async.doUntil(iterator, test, callback); - } - else { - callback(); - } - }); - }; - - async.queue = function (worker, concurrency) { - if (concurrency === undefined) { - concurrency = 1; - } - function _insert(q, data, pos, callback) { - if(data.constructor !== Array) { - data = [data]; - } - _each(data, function(task) { - var item = { - data: task, - callback: typeof callback === 'function' ? callback : null - }; - - if (pos) { - q.tasks.unshift(item); - } else { - q.tasks.push(item); - } - - if (q.saturated && q.tasks.length === concurrency) { - q.saturated(); - } - async.setImmediate(q.process); - }); - } - - var workers = 0; - var q = { - tasks: [], - concurrency: concurrency, - saturated: null, - empty: null, - drain: null, - push: function (data, callback) { - _insert(q, data, false, callback); - }, - unshift: function (data, callback) { - _insert(q, data, true, callback); - }, - process: function () { - if (workers < q.concurrency && q.tasks.length) { - var task = q.tasks.shift(); - if (q.empty && q.tasks.length === 0) { - q.empty(); - } - workers += 1; - var next = function () { - workers -= 1; - if (task.callback) { - task.callback.apply(task, arguments); - } - if (q.drain && q.tasks.length + workers === 0) { - q.drain(); - } - q.process(); - }; - var cb = only_once(next); - worker(task.data, cb); - } - }, - length: function () { - return q.tasks.length; - }, - running: function () { - return workers; - } - }; - return q; - }; - - async.cargo = function (worker, payload) { - var working = false, - tasks = []; - - var cargo = { - tasks: tasks, - payload: payload, - saturated: null, - empty: null, - drain: null, - push: function (data, callback) { - if(data.constructor !== Array) { - data = [data]; - } - _each(data, function(task) { - tasks.push({ - data: task, - callback: typeof callback === 'function' ? callback : null - }); - if (cargo.saturated && tasks.length === payload) { - cargo.saturated(); - } - }); - async.setImmediate(cargo.process); - }, - process: function process() { - if (working) return; - if (tasks.length === 0) { - if(cargo.drain) cargo.drain(); - return; - } - - var ts = typeof payload === 'number' - ? tasks.splice(0, payload) - : tasks.splice(0); - - var ds = _map(ts, function (task) { - return task.data; - }); - - if(cargo.empty) cargo.empty(); - working = true; - worker(ds, function () { - working = false; - - var args = arguments; - _each(ts, function (data) { - if (data.callback) { - data.callback.apply(null, args); - } - }); - - process(); - }); - }, - length: function () { - return tasks.length; - }, - running: function () { - return working; - } - }; - return cargo; - }; - - var _console_fn = function (name) { - return function (fn) { - var args = Array.prototype.slice.call(arguments, 1); - fn.apply(null, args.concat([function (err) { - var args = Array.prototype.slice.call(arguments, 1); - if (typeof console !== 'undefined') { - if (err) { - if (console.error) { - console.error(err); - } - } - else if (console[name]) { - _each(args, function (x) { - console[name](x); - }); - } - } - }])); - }; - }; - async.log = _console_fn('log'); - async.dir = _console_fn('dir'); - /*async.info = _console_fn('info'); - async.warn = _console_fn('warn'); - async.error = _console_fn('error');*/ - - async.memoize = function (fn, hasher) { - var memo = {}; - var queues = {}; - hasher = hasher || function (x) { - return x; - }; - var memoized = function () { - var args = Array.prototype.slice.call(arguments); - var callback = args.pop(); - var key = hasher.apply(null, args); - if (key in memo) { - callback.apply(null, memo[key]); - } - else if (key in queues) { - queues[key].push(callback); - } - else { - queues[key] = [callback]; - fn.apply(null, args.concat([function () { - memo[key] = arguments; - var q = queues[key]; - delete queues[key]; - for (var i = 0, l = q.length; i < l; i++) { - q[i].apply(null, arguments); - } - }])); - } - }; - memoized.memo = memo; - memoized.unmemoized = fn; - return memoized; - }; - - async.unmemoize = function (fn) { - return function () { - return (fn.unmemoized || fn).apply(null, arguments); - }; - }; - - async.times = function (count, iterator, callback) { - var counter = []; - for (var i = 0; i < count; i++) { - counter.push(i); - } - return async.map(counter, iterator, callback); - }; - - async.timesSeries = function (count, iterator, callback) { - var counter = []; - for (var i = 0; i < count; i++) { - counter.push(i); - } - return async.mapSeries(counter, iterator, callback); - }; - - async.compose = function (/* functions... */) { - var fns = Array.prototype.reverse.call(arguments); - return function () { - var that = this; - var args = Array.prototype.slice.call(arguments); - var callback = args.pop(); - async.reduce(fns, args, function (newargs, fn, cb) { - fn.apply(that, newargs.concat([function () { - var err = arguments[0]; - var nextargs = Array.prototype.slice.call(arguments, 1); - cb(err, nextargs); - }])) - }, - function (err, results) { - callback.apply(that, [err].concat(results)); - }); - }; - }; - - var _applyEach = function (eachfn, fns /*args...*/) { - var go = function () { - var that = this; - var args = Array.prototype.slice.call(arguments); - var callback = args.pop(); - return eachfn(fns, function (fn, cb) { - fn.apply(that, args.concat([cb])); - }, - callback); - }; - if (arguments.length > 2) { - var args = Array.prototype.slice.call(arguments, 2); - return go.apply(this, args); - } - else { - return go; - } - }; - async.applyEach = doParallel(_applyEach); - async.applyEachSeries = doSeries(_applyEach); - - async.forever = function (fn, callback) { - function next(err) { - if (err) { - if (callback) { - return callback(err); - } - throw err; - } - fn(next); - } - next(); - }; - // AMD / RequireJS if (typeof define !== 'undefined' && define.amd) { define([], function () { @@ -966,7 +87,7 @@ }()); }).call(this,_dereq_("JkpR2F")) -},{"JkpR2F":10}],2:[function(_dereq_,module,exports){ +},{"JkpR2F":9}],2:[function(_dereq_,module,exports){ // Based on https://github.com/diy/intercom.js/blob/master/lib/events.js // Copyright 2012 DIY Co Apache License, Version 2.0 // http://www.apache.org/licenses/LICENSE-2.0 @@ -1361,7 +482,7 @@ Intercom.getInstance = (function() { module.exports = Intercom; }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../src/shared.js":27,"./eventemitter.js":2}],4:[function(_dereq_,module,exports){ +},{"../src/shared.js":26,"./eventemitter.js":2}],4:[function(_dereq_,module,exports){ // Cherry-picked bits of underscore.js, lodash.js /** @@ -1522,492 +643,6 @@ module.exports = nodash; })("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); },{}],6:[function(_dereq_,module,exports){ -(function (Buffer){ -// Browser Request -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -var XHR = XMLHttpRequest -if (!XHR) throw new Error('missing XMLHttpRequest') -request.log = { - 'trace': noop, 'debug': noop, 'info': noop, 'warn': noop, 'error': noop -} - -var DEFAULT_TIMEOUT = 3 * 60 * 1000 // 3 minutes - -// -// request -// - -function request(options, callback) { - // The entry-point to the API: prep the options object and pass the real work to run_xhr. - if(typeof callback !== 'function') - throw new Error('Bad callback given: ' + callback) - - if(!options) - throw new Error('No options given') - - var options_onResponse = options.onResponse; // Save this for later. - - if(typeof options === 'string') - options = {'uri':options}; - else - options = JSON.parse(JSON.stringify(options)); // Use a duplicate for mutating. - - options.onResponse = options_onResponse // And put it back. - - if (options.verbose) request.log = getLogger(); - - if(options.url) { - options.uri = options.url; - delete options.url; - } - - if(!options.uri && options.uri !== "") - throw new Error("options.uri is a required argument"); - - if(typeof options.uri != "string") - throw new Error("options.uri must be a string"); - - var unsupported_options = ['proxy', '_redirectsFollowed', 'maxRedirects', 'followRedirect'] - for (var i = 0; i < unsupported_options.length; i++) - if(options[ unsupported_options[i] ]) - throw new Error("options." + unsupported_options[i] + " is not supported") - - options.callback = callback - options.method = options.method || 'GET'; - options.headers = options.headers || {}; - options.body = options.body || null - options.timeout = options.timeout || request.DEFAULT_TIMEOUT - - if(options.headers.host) - throw new Error("Options.headers.host is not supported"); - - if(options.json) { - options.headers.accept = options.headers.accept || 'application/json' - if(options.method !== 'GET') - options.headers['content-type'] = 'application/json' - - if(typeof options.json !== 'boolean') - options.body = JSON.stringify(options.json) - else if(typeof options.body !== 'string') - options.body = JSON.stringify(options.body) - } - - //BEGIN QS Hack - var serialize = function(obj) { - var str = []; - for(var p in obj) - if (obj.hasOwnProperty(p)) { - str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); - } - return str.join("&"); - } - - if(options.qs){ - var qs = (typeof options.qs == 'string')? options.qs : serialize(options.qs); - if(options.uri.indexOf('?') !== -1){ //no get params - options.uri = options.uri+'&'+qs; - }else{ //existing get params - options.uri = options.uri+'?'+qs; - } - } - //END QS Hack - - //BEGIN FORM Hack - var multipart = function(obj) { - //todo: support file type (useful?) - var result = {}; - result.boundry = '-------------------------------'+Math.floor(Math.random()*1000000000); - var lines = []; - for(var p in obj){ - if (obj.hasOwnProperty(p)) { - lines.push( - '--'+result.boundry+"\n"+ - 'Content-Disposition: form-data; name="'+p+'"'+"\n"+ - "\n"+ - obj[p]+"\n" - ); - } - } - lines.push( '--'+result.boundry+'--' ); - result.body = lines.join(''); - result.length = result.body.length; - result.type = 'multipart/form-data; boundary='+result.boundry; - return result; - } - - if(options.form){ - if(typeof options.form == 'string') throw('form name unsupported'); - if(options.method === 'POST'){ - var encoding = (options.encoding || 'application/x-www-form-urlencoded').toLowerCase(); - options.headers['content-type'] = encoding; - switch(encoding){ - case 'application/x-www-form-urlencoded': - options.body = serialize(options.form).replace(/%20/g, "+"); - break; - case 'multipart/form-data': - var multi = multipart(options.form); - //options.headers['content-length'] = multi.length; - options.body = multi.body; - options.headers['content-type'] = multi.type; - break; - default : throw new Error('unsupported encoding:'+encoding); - } - } - } - //END FORM Hack - - // If onResponse is boolean true, call back immediately when the response is known, - // not when the full request is complete. - options.onResponse = options.onResponse || noop - if(options.onResponse === true) { - options.onResponse = callback - options.callback = noop - } - - // XXX Browsers do not like this. - //if(options.body) - // options.headers['content-length'] = options.body.length; - - // HTTP basic authentication - if(!options.headers.authorization && options.auth) - options.headers.authorization = 'Basic ' + b64_enc(options.auth.username + ':' + options.auth.password); - - return run_xhr(options) -} - -var req_seq = 0 -function run_xhr(options) { - var xhr = new XHR - , timed_out = false - , is_cors = is_crossDomain(options.uri) - , supports_cors = ('withCredentials' in xhr) - - req_seq += 1 - xhr.seq_id = req_seq - xhr.id = req_seq + ': ' + options.method + ' ' + options.uri - xhr._id = xhr.id // I know I will type "_id" from habit all the time. - - if(is_cors && !supports_cors) { - var cors_err = new Error('Browser does not support cross-origin request: ' + options.uri) - cors_err.cors = 'unsupported' - return options.callback(cors_err, xhr) - } - - xhr.timeoutTimer = setTimeout(too_late, options.timeout) - function too_late() { - timed_out = true - var er = new Error('ETIMEDOUT') - er.code = 'ETIMEDOUT' - er.duration = options.timeout - - request.log.error('Timeout', { 'id':xhr._id, 'milliseconds':options.timeout }) - return options.callback(er, xhr) - } - - // Some states can be skipped over, so remember what is still incomplete. - var did = {'response':false, 'loading':false, 'end':false} - - xhr.onreadystatechange = on_state_change - xhr.open(options.method, options.uri, true) // asynchronous - // Deal with requests for raw buffer response - if(options.encoding === null) { - xhr.responseType = 'arraybuffer'; - } - if(is_cors) - xhr.withCredentials = !! options.withCredentials - xhr.send(options.body) - return xhr - - function on_state_change(event) { - if(timed_out) - return request.log.debug('Ignoring timed out state change', {'state':xhr.readyState, 'id':xhr.id}) - - request.log.debug('State change', {'state':xhr.readyState, 'id':xhr.id, 'timed_out':timed_out}) - - if(xhr.readyState === XHR.OPENED) { - request.log.debug('Request started', {'id':xhr.id}) - for (var key in options.headers) - xhr.setRequestHeader(key, options.headers[key]) - } - - else if(xhr.readyState === XHR.HEADERS_RECEIVED) - on_response() - - else if(xhr.readyState === XHR.LOADING) { - on_response() - on_loading() - } - - else if(xhr.readyState === XHR.DONE) { - on_response() - on_loading() - on_end() - } - } - - function on_response() { - if(did.response) - return - - did.response = true - request.log.debug('Got response', {'id':xhr.id, 'status':xhr.status}) - clearTimeout(xhr.timeoutTimer) - xhr.statusCode = xhr.status // Node request compatibility - - // Detect failed CORS requests. - if(is_cors && xhr.statusCode == 0) { - var cors_err = new Error('CORS request rejected: ' + options.uri) - cors_err.cors = 'rejected' - - // Do not process this request further. - did.loading = true - did.end = true - - return options.callback(cors_err, xhr) - } - - options.onResponse(null, xhr) - } - - function on_loading() { - if(did.loading) - return - - did.loading = true - request.log.debug('Response body loading', {'id':xhr.id}) - // TODO: Maybe simulate "data" events by watching xhr.responseText - } - - function on_end() { - if(did.end) - return - - did.end = true - request.log.debug('Request done', {'id':xhr.id}) - - if(options.encoding === null) { - xhr.body = new Buffer(new Uint8Array(xhr.response)); - } else { - xhr.body = xhr.responseText - if(options.json) { - try { xhr.body = JSON.parse(xhr.responseText) } - catch (er) { return options.callback(er, xhr) } - } - } - - options.callback(null, xhr, xhr.body) - } - -} // request - -request.withCredentials = false; -request.DEFAULT_TIMEOUT = DEFAULT_TIMEOUT; - -// -// defaults -// - -request.defaults = function(options, requester) { - var def = function (method) { - var d = function (params, callback) { - if(typeof params === 'string') - params = {'uri': params}; - else { - params = JSON.parse(JSON.stringify(params)); - } - for (var i in options) { - if (params[i] === undefined) params[i] = options[i] - } - return method(params, callback) - } - return d - } - var de = def(request) - de.get = def(request.get) - de.post = def(request.post) - de.put = def(request.put) - de.head = def(request.head) - return de -} - -// -// HTTP method shortcuts -// - -var shortcuts = [ 'get', 'put', 'post', 'head' ]; -shortcuts.forEach(function(shortcut) { - var method = shortcut.toUpperCase(); - var func = shortcut.toLowerCase(); - - request[func] = function(opts) { - if(typeof opts === 'string') - opts = {'method':method, 'uri':opts}; - else { - opts = JSON.parse(JSON.stringify(opts)); - opts.method = method; - } - - var args = [opts].concat(Array.prototype.slice.apply(arguments, [1])); - return request.apply(this, args); - } -}) - -// -// CouchDB shortcut -// - -request.couch = function(options, callback) { - if(typeof options === 'string') - options = {'uri':options} - - // Just use the request API to do JSON. - options.json = true - if(options.body) - options.json = options.body - delete options.body - - callback = callback || noop - - var xhr = request(options, couch_handler) - return xhr - - function couch_handler(er, resp, body) { - if(er) - return callback(er, resp, body) - - if((resp.statusCode < 200 || resp.statusCode > 299) && body.error) { - // The body is a Couch JSON object indicating the error. - er = new Error('CouchDB error: ' + (body.error.reason || body.error.error)) - for (var key in body) - er[key] = body[key] - return callback(er, resp, body); - } - - return callback(er, resp, body); - } -} - -// -// Utility -// - -function noop() {} - -function getLogger() { - var logger = {} - , levels = ['trace', 'debug', 'info', 'warn', 'error'] - , level, i - - for(i = 0; i < levels.length; i++) { - level = levels[i] - - logger[level] = noop - if(typeof console !== 'undefined' && console && console[level]) - logger[level] = formatted(console, level) - } - - return logger -} - -function formatted(obj, method) { - return formatted_logger - - function formatted_logger(str, context) { - if(typeof context === 'object') - str += ' ' + JSON.stringify(context) - - return obj[method].call(obj, str) - } -} - -// Return whether a URL is a cross-domain request. -function is_crossDomain(url) { - var rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/ - - // jQuery #8138, IE may throw an exception when accessing - // a field from window.location if document.domain has been set - var ajaxLocation - try { ajaxLocation = location.href } - catch (e) { - // Use the href attribute of an A element since IE will modify it given document.location - ajaxLocation = document.createElement( "a" ); - ajaxLocation.href = ""; - ajaxLocation = ajaxLocation.href; - } - - var ajaxLocParts = rurl.exec(ajaxLocation.toLowerCase()) || [] - , parts = rurl.exec(url.toLowerCase() ) - - var result = !!( - parts && - ( parts[1] != ajaxLocParts[1] - || parts[2] != ajaxLocParts[2] - || (parts[3] || (parts[1] === "http:" ? 80 : 443)) != (ajaxLocParts[3] || (ajaxLocParts[1] === "http:" ? 80 : 443)) - ) - ) - - //console.debug('is_crossDomain('+url+') -> ' + result) - return result -} - -// MIT License from http://phpjs.org/functions/base64_encode:358 -function b64_enc (data) { - // Encodes string using MIME base64 algorithm - var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, enc="", tmp_arr = []; - - if (!data) { - return data; - } - - // assume utf8 data - // data = this.utf8_encode(data+''); - - do { // pack three octets into four hexets - o1 = data.charCodeAt(i++); - o2 = data.charCodeAt(i++); - o3 = data.charCodeAt(i++); - - bits = o1<<16 | o2<<8 | o3; - - h1 = bits>>18 & 0x3f; - h2 = bits>>12 & 0x3f; - h3 = bits>>6 & 0x3f; - h4 = bits & 0x3f; - - // use hexets to index into b64, and append result to encoded string - tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4); - } while (i < data.length); - - enc = tmp_arr.join(''); - - switch (data.length % 3) { - case 1: - enc = enc.slice(0, -2) + '=='; - break; - case 2: - enc = enc.slice(0, -1) + '='; - break; - } - - return enc; -} -module.exports = request; - -}).call(this,_dereq_("buffer").Buffer) -},{"buffer":7}],7:[function(_dereq_,module,exports){ /*! * The buffer module from node.js, for the browser. * @@ -3165,7 +1800,7 @@ function assert (test, message) { if (!test) throw new Error(message || 'Failed assertion') } -},{"base64-js":8,"ieee754":9}],8:[function(_dereq_,module,exports){ +},{"base64-js":7,"ieee754":8}],7:[function(_dereq_,module,exports){ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; ;(function (exports) { @@ -3287,7 +1922,7 @@ var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; exports.fromByteArray = uint8ToBase64 }(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) -},{}],9:[function(_dereq_,module,exports){ +},{}],8:[function(_dereq_,module,exports){ exports.read = function(buffer, offset, isLE, mLen, nBytes) { var e, m, eLen = nBytes * 8 - mLen - 1, @@ -3373,7 +2008,7 @@ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { buffer[offset + i - d] |= s * 128; }; -},{}],10:[function(_dereq_,module,exports){ +},{}],9:[function(_dereq_,module,exports){ // shim for using process in browser var process = module.exports = {}; @@ -3438,7 +2073,7 @@ process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; -},{}],11:[function(_dereq_,module,exports){ +},{}],10:[function(_dereq_,module,exports){ (function (Buffer){ function FilerBuffer (subject, encoding, nonZero) { @@ -3465,7 +2100,7 @@ Object.keys(Buffer).forEach(function (p) { module.exports = FilerBuffer; }).call(this,_dereq_("buffer").Buffer) -},{"buffer":7}],12:[function(_dereq_,module,exports){ +},{"buffer":6}],11:[function(_dereq_,module,exports){ var O_READ = 'READ'; var O_WRITE = 'WRITE'; var O_CREATE = 'CREATE'; @@ -3547,7 +2182,7 @@ module.exports = { } }; -},{}],13:[function(_dereq_,module,exports){ +},{}],12:[function(_dereq_,module,exports){ var MODE_FILE = _dereq_('./constants.js').MODE_FILE; module.exports = function DirectoryEntry(id, type) { @@ -3555,7 +2190,7 @@ module.exports = function DirectoryEntry(id, type) { this.type = type || MODE_FILE; }; -},{"./constants.js":12}],14:[function(_dereq_,module,exports){ +},{"./constants.js":11}],13:[function(_dereq_,module,exports){ (function (Buffer){ // Adapt encodings to work with Buffer or Uint8Array, they expect the latter function decode(buf) { @@ -3572,7 +2207,7 @@ module.exports = { }; }).call(this,_dereq_("buffer").Buffer) -},{"buffer":7}],15:[function(_dereq_,module,exports){ +},{"buffer":6}],14:[function(_dereq_,module,exports){ var errors = {}; [ /** @@ -3678,7 +2313,7 @@ var errors = {}; module.exports = errors; -},{}],16:[function(_dereq_,module,exports){ +},{}],15:[function(_dereq_,module,exports){ var _ = _dereq_('../../lib/nodash.js'); var Path = _dereq_('../path.js'); @@ -5758,7 +4393,7 @@ module.exports = { ftruncate: ftruncate }; -},{"../../lib/nodash.js":4,"../buffer.js":11,"../constants.js":12,"../directory-entry.js":13,"../encoding.js":14,"../errors.js":15,"../node.js":20,"../open-file-description.js":21,"../path.js":22,"../stats.js":31,"../super-node.js":32}],17:[function(_dereq_,module,exports){ +},{"../../lib/nodash.js":4,"../buffer.js":10,"../constants.js":11,"../directory-entry.js":12,"../encoding.js":13,"../errors.js":14,"../node.js":19,"../open-file-description.js":20,"../path.js":21,"../stats.js":29,"../super-node.js":30}],16:[function(_dereq_,module,exports){ var _ = _dereq_('../../lib/nodash.js'); var isNullPath = _dereq_('../path.js').isNull; @@ -6101,7 +4736,7 @@ FileSystem.prototype.Shell = function(options) { module.exports = FileSystem; -},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":12,"../errors.js":15,"../fs-watcher.js":18,"../path.js":22,"../providers/index.js":23,"../shared.js":27,"../shell/shell.js":30,"./implementation.js":16}],18:[function(_dereq_,module,exports){ +},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":11,"../errors.js":14,"../fs-watcher.js":17,"../path.js":21,"../providers/index.js":22,"../shared.js":26,"../shell/shell.js":28,"./implementation.js":15}],17:[function(_dereq_,module,exports){ var EventEmitter = _dereq_('../lib/eventemitter.js'); var Path = _dereq_('./path.js'); var Intercom = _dereq_('../lib/intercom.js'); @@ -6165,7 +4800,7 @@ FSWatcher.prototype.constructor = FSWatcher; module.exports = FSWatcher; -},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":22}],19:[function(_dereq_,module,exports){ +},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":21}],18:[function(_dereq_,module,exports){ module.exports = { FileSystem: _dereq_('./filesystem/interface.js'), Buffer: _dereq_('./buffer.js'), @@ -6173,7 +4808,7 @@ module.exports = { Errors: _dereq_('./errors.js') }; -},{"./buffer.js":11,"./errors.js":15,"./filesystem/interface.js":17,"./path.js":22}],20:[function(_dereq_,module,exports){ +},{"./buffer.js":10,"./errors.js":14,"./filesystem/interface.js":16,"./path.js":21}],19:[function(_dereq_,module,exports){ var MODE_FILE = _dereq_('./constants.js').MODE_FILE; function Node(options) { @@ -6228,7 +4863,7 @@ Node.create = function(options, callback) { module.exports = Node; -},{"./constants.js":12}],21:[function(_dereq_,module,exports){ +},{"./constants.js":11}],20:[function(_dereq_,module,exports){ module.exports = function OpenFileDescription(path, id, flags, position) { this.path = path; this.id = id; @@ -6236,7 +4871,7 @@ module.exports = function OpenFileDescription(path, id, flags, position) { this.position = position; }; -},{}],22:[function(_dereq_,module,exports){ +},{}],21:[function(_dereq_,module,exports){ // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -6462,7 +5097,7 @@ module.exports = { isNull: isNull }; -},{}],23:[function(_dereq_,module,exports){ +},{}],22:[function(_dereq_,module,exports){ var IndexedDB = _dereq_('./indexeddb.js'); var WebSQL = _dereq_('./websql.js'); var Memory = _dereq_('./memory.js'); @@ -6499,7 +5134,7 @@ module.exports = { }()) }; -},{"./indexeddb.js":24,"./memory.js":25,"./websql.js":26}],24:[function(_dereq_,module,exports){ +},{"./indexeddb.js":23,"./memory.js":24,"./websql.js":25}],23:[function(_dereq_,module,exports){ (function (global){ var FILE_SYSTEM_NAME = _dereq_('../constants.js').FILE_SYSTEM_NAME; var FILE_STORE_NAME = _dereq_('../constants.js').FILE_STORE_NAME; @@ -6645,7 +5280,7 @@ IndexedDB.prototype.getReadWriteContext = function() { module.exports = IndexedDB; }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../buffer.js":11,"../constants.js":12,"../errors.js":15}],25:[function(_dereq_,module,exports){ +},{"../buffer.js":10,"../constants.js":11,"../errors.js":14}],24:[function(_dereq_,module,exports){ var FILE_SYSTEM_NAME = _dereq_('../constants.js').FILE_SYSTEM_NAME; // NOTE: prefer setImmediate to nextTick for proper recursion yielding. // see https://github.com/js-platform/filer/pull/24 @@ -6737,7 +5372,7 @@ Memory.prototype.getReadWriteContext = function() { module.exports = Memory; -},{"../../lib/async.js":1,"../constants.js":12}],26:[function(_dereq_,module,exports){ +},{"../../lib/async.js":1,"../constants.js":11}],25:[function(_dereq_,module,exports){ (function (global){ var FILE_SYSTEM_NAME = _dereq_('../constants.js').FILE_SYSTEM_NAME; var FILE_STORE_NAME = _dereq_('../constants.js').FILE_STORE_NAME; @@ -6912,7 +5547,7 @@ WebSQL.prototype.getReadWriteContext = function() { module.exports = WebSQL; }).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"../buffer.js":11,"../constants.js":12,"../errors.js":15,"base64-arraybuffer":5}],27:[function(_dereq_,module,exports){ +},{"../buffer.js":10,"../constants.js":11,"../errors.js":14,"base64-arraybuffer":5}],26:[function(_dereq_,module,exports){ function guid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); @@ -6940,7 +5575,7 @@ module.exports = { nop: nop }; -},{}],28:[function(_dereq_,module,exports){ +},{}],27:[function(_dereq_,module,exports){ var defaults = _dereq_('../constants.js').ENVIRONMENT; module.exports = function Environment(env) { @@ -6957,36 +5592,11 @@ module.exports = function Environment(env) { }; }; -},{"../constants.js":12}],29:[function(_dereq_,module,exports){ -var request = _dereq_('request'); - -module.exports.download = function(uri, callback) { - request({ - url: uri, - method: 'GET', - encoding: null - }, function(err, msg, body) { - var statusCode; - var error; - - msg = msg || null; - statusCode = msg && msg.statusCode; - error = statusCode !== 200 ? { message: err || 'Not found!', code: statusCode } : null; - - if (error) { - callback(error, null); - return; - } - callback(null, body); - }); -}; - -},{"request":6}],30:[function(_dereq_,module,exports){ +},{"../constants.js":11}],28:[function(_dereq_,module,exports){ var Path = _dereq_('../path.js'); var Errors = _dereq_('../errors.js'); var Environment = _dereq_('./environment.js'); var async = _dereq_('../../lib/async.js'); -var Network = _dereq_('./network.js'); var Encoding = _dereq_('../encoding.js'); function Shell(fs, options) { @@ -7411,57 +6021,9 @@ Shell.prototype.mkdirp = function(path, callback) { _mkdirp(path, callback); }; -/** - * Downloads the file at `url` and saves it to the filesystem. - * The file is saved to a file named with the current date/time - * unless the `options.filename` is present, in which case that - * filename is used instead. The callback receives (error, path). - */ -Shell.prototype.wget = function(url, options, callback) { - var sh = this; - var fs = sh.fs; - if(typeof options === 'function') { - callback = options; - options = {}; - } - options = options || {}; - callback = callback || function(){}; - - if(!url) { - callback(new Errors.EINVAL('Missing url argument')); - return; - } - - // Grab whatever is after the last / (assuming there is one). Like the real - // wget, we leave query string or hash portions in tact. This assumes a - // properly encoded URL. - // i.e. instead of "/foo?bar/" we would expect "/foo?bar%2F" - var path = options.filename || url.split('/').pop(); - - path = Path.resolve(sh.pwd(), path); - - function onerror() { - callback(new Error('unable to get resource')); - } - - Network.download(url, function(err, data) { - if (err || !data) { - return onerror(); - } - - fs.writeFile(path, data, function(err) { - if(err) { - callback(err); - } else { - callback(null, path); - } - }); - }); -}; - module.exports = Shell; -},{"../../lib/async.js":1,"../encoding.js":14,"../errors.js":15,"../path.js":22,"./environment.js":28,"./network.js":29}],31:[function(_dereq_,module,exports){ +},{"../../lib/async.js":1,"../encoding.js":13,"../errors.js":14,"../path.js":21,"./environment.js":27}],29:[function(_dereq_,module,exports){ var Constants = _dereq_('./constants.js'); function Stats(fileNode, devName) { @@ -7498,7 +6060,7 @@ function() { module.exports = Stats; -},{"./constants.js":12}],32:[function(_dereq_,module,exports){ +},{"./constants.js":11}],30:[function(_dereq_,module,exports){ var Constants = _dereq_('./constants.js'); function SuperNode(options) { @@ -7526,6 +6088,6 @@ SuperNode.create = function(options, callback) { module.exports = SuperNode; -},{"./constants.js":12}]},{},[19]) -(19) +},{"./constants.js":11}]},{},[18]) +(18) }); \ No newline at end of file diff --git a/dist/filer.min.js b/dist/filer.min.js index 6de88fc..5180052 100644 --- a/dist/filer.min.js +++ b/dist/filer.min.js @@ -1,4 +1,4 @@ -/*! filer 0.0.27 2014-09-02 */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.Filer=t()}}(function(){var t;return function n(t,e,r){function i(a,u){if(!e[a]){if(!t[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var c=e[a]={exports:{}};t[a][0].call(c.exports,function(n){var e=t[a][1][n];return i(e?e:n)},c,c.exports,n,t,e,r)}return e[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(n,e){(function(n){(function(){function r(t){var n=!1;return function(){if(n)throw Error("Callback was already called.");n=!0,t.apply(i,arguments)}}var i,o,a={};i=this,null!=i&&(o=i.async),a.noConflict=function(){return i.async=o,a};var u=function(t,n){if(t.forEach)return t.forEach(n);for(var e=0;t.length>e;e+=1)n(t[e],e,t)},s=function(t,n){if(t.map)return t.map(n);var e=[];return u(t,function(t,r,i){e.push(n(t,r,i))}),e},c=function(t,n,e){return t.reduce?t.reduce(n,e):(u(t,function(t,r,i){e=n(e,t,r,i)}),e)},f=function(t){if(Object.keys)return Object.keys(t);var n=[];for(var e in t)t.hasOwnProperty(e)&&n.push(e);return n};void 0!==n&&n.nextTick?(a.nextTick=n.nextTick,a.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:a.nextTick):"function"==typeof setImmediate?(a.nextTick=function(t){setImmediate(t)},a.setImmediate=a.nextTick):(a.nextTick=function(t){setTimeout(t,0)},a.setImmediate=a.nextTick),a.each=function(t,n,e){if(e=e||function(){},!t.length)return e();var i=0;u(t,function(o){n(o,r(function(n){n?(e(n),e=function(){}):(i+=1,i>=t.length&&e(null))}))})},a.forEach=a.each,a.eachSeries=function(t,n,e){if(e=e||function(){},!t.length)return e();var r=0,i=function(){n(t[r],function(n){n?(e(n),e=function(){}):(r+=1,r>=t.length?e(null):i())})};i()},a.forEachSeries=a.eachSeries,a.eachLimit=function(t,n,e,r){var i=l(n);i.apply(null,[t,e,r])},a.forEachLimit=a.eachLimit;var l=function(t){return function(n,e,r){if(r=r||function(){},!n.length||0>=t)return r();var i=0,o=0,a=0;(function u(){if(i>=n.length)return r();for(;t>a&&n.length>o;)o+=1,a+=1,e(n[o-1],function(t){t?(r(t),r=function(){}):(i+=1,a-=1,i>=n.length?r():u())})})()}},d=function(t){return function(){var n=Array.prototype.slice.call(arguments);return t.apply(null,[a.each].concat(n))}},p=function(t,n){return function(){var e=Array.prototype.slice.call(arguments);return n.apply(null,[l(t)].concat(e))}},h=function(t){return function(){var n=Array.prototype.slice.call(arguments);return t.apply(null,[a.eachSeries].concat(n))}},g=function(t,n,e,r){var i=[];n=s(n,function(t,n){return{index:n,value:t}}),t(n,function(t,n){e(t.value,function(e,r){i[t.index]=r,n(e)})},function(t){r(t,i)})};a.map=d(g),a.mapSeries=h(g),a.mapLimit=function(t,n,e,r){return v(n)(t,e,r)};var v=function(t){return p(t,g)};a.reduce=function(t,n,e,r){a.eachSeries(t,function(t,r){e(n,t,function(t,e){n=e,r(t)})},function(t){r(t,n)})},a.inject=a.reduce,a.foldl=a.reduce,a.reduceRight=function(t,n,e,r){var i=s(t,function(t){return t}).reverse();a.reduce(i,n,e,r)},a.foldr=a.reduceRight;var m=function(t,n,e,r){var i=[];n=s(n,function(t,n){return{index:n,value:t}}),t(n,function(t,n){e(t.value,function(e){e&&i.push(t),n()})},function(){r(s(i.sort(function(t,n){return t.index-n.index}),function(t){return t.value}))})};a.filter=d(m),a.filterSeries=h(m),a.select=a.filter,a.selectSeries=a.filterSeries;var y=function(t,n,e,r){var i=[];n=s(n,function(t,n){return{index:n,value:t}}),t(n,function(t,n){e(t.value,function(e){e||i.push(t),n()})},function(){r(s(i.sort(function(t,n){return t.index-n.index}),function(t){return t.value}))})};a.reject=d(y),a.rejectSeries=h(y);var E=function(t,n,e,r){t(n,function(t,n){e(t,function(e){e?(r(t),r=function(){}):n()})},function(){r()})};a.detect=d(E),a.detectSeries=h(E),a.some=function(t,n,e){a.each(t,function(t,r){n(t,function(t){t&&(e(!0),e=function(){}),r()})},function(){e(!1)})},a.any=a.some,a.every=function(t,n,e){a.each(t,function(t,r){n(t,function(t){t||(e(!1),e=function(){}),r()})},function(){e(!0)})},a.all=a.every,a.sortBy=function(t,n,e){a.map(t,function(t,e){n(t,function(n,r){n?e(n):e(null,{value:t,criteria:r})})},function(t,n){if(t)return e(t);var r=function(t,n){var e=t.criteria,r=n.criteria;return r>e?-1:e>r?1:0};e(null,s(n.sort(r),function(t){return t.value}))})},a.auto=function(t,n){n=n||function(){};var e=f(t);if(!e.length)return n(null);var r={},i=[],o=function(t){i.unshift(t)},s=function(t){for(var n=0;i.length>n;n+=1)if(i[n]===t)return i.splice(n,1),void 0},l=function(){u(i.slice(0),function(t){t()})};o(function(){f(r).length===e.length&&(n(null,r),n=function(){})}),u(e,function(e){var i=t[e]instanceof Function?[t[e]]:t[e],d=function(t){var i=Array.prototype.slice.call(arguments,1);if(1>=i.length&&(i=i[0]),t){var o={};u(f(r),function(t){o[t]=r[t]}),o[e]=i,n(t,o),n=function(){}}else r[e]=i,a.setImmediate(l)},p=i.slice(0,Math.abs(i.length-1))||[],h=function(){return c(p,function(t,n){return t&&r.hasOwnProperty(n)},!0)&&!r.hasOwnProperty(e)};if(h())i[i.length-1](d,r);else{var g=function(){h()&&(s(g),i[i.length-1](d,r))};o(g)}})},a.waterfall=function(t,n){if(n=n||function(){},t.constructor!==Array){var e=Error("First argument to waterfall must be an array of functions");return n(e)}if(!t.length)return n();var r=function(t){return function(e){if(e)n.apply(null,arguments),n=function(){};else{var i=Array.prototype.slice.call(arguments,1),o=t.next();o?i.push(r(o)):i.push(n),a.setImmediate(function(){t.apply(null,i)})}}};r(a.iterator(t))()};var b=function(t,n,e){if(e=e||function(){},n.constructor===Array)t.map(n,function(t,n){t&&t(function(t){var e=Array.prototype.slice.call(arguments,1);1>=e.length&&(e=e[0]),n.call(null,t,e)})},e);else{var r={};t.each(f(n),function(t,e){n[t](function(n){var i=Array.prototype.slice.call(arguments,1);1>=i.length&&(i=i[0]),r[t]=i,e(n)})},function(t){e(t,r)})}};a.parallel=function(t,n){b({map:a.map,each:a.each},t,n)},a.parallelLimit=function(t,n,e){b({map:v(n),each:l(n)},t,e)},a.series=function(t,n){if(n=n||function(){},t.constructor===Array)a.mapSeries(t,function(t,n){t&&t(function(t){var e=Array.prototype.slice.call(arguments,1);1>=e.length&&(e=e[0]),n.call(null,t,e)})},n);else{var e={};a.eachSeries(f(t),function(n,r){t[n](function(t){var i=Array.prototype.slice.call(arguments,1);1>=i.length&&(i=i[0]),e[n]=i,r(t)})},function(t){n(t,e)})}},a.iterator=function(t){var n=function(e){var r=function(){return t.length&&t[e].apply(null,arguments),r.next()};return r.next=function(){return t.length-1>e?n(e+1):null},r};return n(0)},a.apply=function(t){var n=Array.prototype.slice.call(arguments,1);return function(){return t.apply(null,n.concat(Array.prototype.slice.call(arguments)))}};var w=function(t,n,e,r){var i=[];t(n,function(t,n){e(t,function(t,e){i=i.concat(e||[]),n(t)})},function(t){r(t,i)})};a.concat=d(w),a.concatSeries=h(w),a.whilst=function(t,n,e){t()?n(function(r){return r?e(r):(a.whilst(t,n,e),void 0)}):e()},a.doWhilst=function(t,n,e){t(function(r){return r?e(r):(n()?a.doWhilst(t,n,e):e(),void 0)})},a.until=function(t,n,e){t()?e():n(function(r){return r?e(r):(a.until(t,n,e),void 0)})},a.doUntil=function(t,n,e){t(function(r){return r?e(r):(n()?e():a.doUntil(t,n,e),void 0)})},a.queue=function(t,n){function e(t,e,r,i){e.constructor!==Array&&(e=[e]),u(e,function(e){var o={data:e,callback:"function"==typeof i?i:null};r?t.tasks.unshift(o):t.tasks.push(o),t.saturated&&t.tasks.length===n&&t.saturated(),a.setImmediate(t.process)})}void 0===n&&(n=1);var i=0,o={tasks:[],concurrency:n,saturated:null,empty:null,drain:null,push:function(t,n){e(o,t,!1,n)},unshift:function(t,n){e(o,t,!0,n)},process:function(){if(o.concurrency>i&&o.tasks.length){var n=o.tasks.shift();o.empty&&0===o.tasks.length&&o.empty(),i+=1;var e=function(){i-=1,n.callback&&n.callback.apply(n,arguments),o.drain&&0===o.tasks.length+i&&o.drain(),o.process()},a=r(e);t(n.data,a)}},length:function(){return o.tasks.length},running:function(){return i}};return o},a.cargo=function(t,n){var e=!1,r=[],i={tasks:r,payload:n,saturated:null,empty:null,drain:null,push:function(t,e){t.constructor!==Array&&(t=[t]),u(t,function(t){r.push({data:t,callback:"function"==typeof e?e:null}),i.saturated&&r.length===n&&i.saturated()}),a.setImmediate(i.process)},process:function o(){if(!e){if(0===r.length)return i.drain&&i.drain(),void 0;var a="number"==typeof n?r.splice(0,n):r.splice(0),c=s(a,function(t){return t.data});i.empty&&i.empty(),e=!0,t(c,function(){e=!1;var t=arguments;u(a,function(n){n.callback&&n.callback.apply(null,t)}),o()})}},length:function(){return r.length},running:function(){return e}};return i};var I=function(t){return function(n){var e=Array.prototype.slice.call(arguments,1);n.apply(null,e.concat([function(n){var e=Array.prototype.slice.call(arguments,1);"undefined"!=typeof console&&(n?console.error&&console.error(n):console[t]&&u(e,function(n){console[t](n)}))}]))}};a.log=I("log"),a.dir=I("dir"),a.memoize=function(t,n){var e={},r={};n=n||function(t){return t};var i=function(){var i=Array.prototype.slice.call(arguments),o=i.pop(),a=n.apply(null,i);a in e?o.apply(null,e[a]):a in r?r[a].push(o):(r[a]=[o],t.apply(null,i.concat([function(){e[a]=arguments;var t=r[a];delete r[a];for(var n=0,i=t.length;i>n;n++)t[n].apply(null,arguments)}])))};return i.memo=e,i.unmemoized=t,i},a.unmemoize=function(t){return function(){return(t.unmemoized||t).apply(null,arguments)}},a.times=function(t,n,e){for(var r=[],i=0;t>i;i++)r.push(i);return a.map(r,n,e)},a.timesSeries=function(t,n,e){for(var r=[],i=0;t>i;i++)r.push(i);return a.mapSeries(r,n,e)},a.compose=function(){var t=Array.prototype.reverse.call(arguments);return function(){var n=this,e=Array.prototype.slice.call(arguments),r=e.pop();a.reduce(t,e,function(t,e,r){e.apply(n,t.concat([function(){var t=arguments[0],n=Array.prototype.slice.call(arguments,1);r(t,n)}]))},function(t,e){r.apply(n,[t].concat(e))})}};var O=function(t,n){var e=function(){var e=this,r=Array.prototype.slice.call(arguments),i=r.pop();return t(n,function(t,n){t.apply(e,r.concat([n]))},i)};if(arguments.length>2){var r=Array.prototype.slice.call(arguments,2);return e.apply(this,r)}return e};a.applyEach=d(O),a.applyEachSeries=h(O),a.forever=function(t,n){function e(r){if(r){if(n)return n(r);throw r}t(e)}e()},t!==void 0&&t.amd?t([],function(){return a}):e!==void 0&&e.exports?e.exports=a:i.async=a})()}).call(this,n("JkpR2F"))},{JkpR2F:10}],2:[function(t,n){function e(t,n){for(var e=n.length-1;e>=0;e--)n[e]===t&&n.splice(e,1);return n}var r=function(){};r.createInterface=function(t){var n={};return n.on=function(n,e){this[t]===void 0&&(this[t]={}),this[t].hasOwnProperty(n)||(this[t][n]=[]),this[t][n].push(e)},n.off=function(n,r){void 0!==this[t]&&this[t].hasOwnProperty(n)&&e(r,this[t][n])},n.trigger=function(n){if(this[t]!==void 0&&this[t].hasOwnProperty(n))for(var e=Array.prototype.slice.call(arguments,1),r=0;this[t][n].length>r;r++)this[t][n][r].apply(this[t][n][r],e)},n.removeAllListeners=function(n){if(void 0!==this[t]){var e=this;e[t][n].forEach(function(t){e.off(n,t)})}},n};var i=r.createInterface("_handlers");r.prototype._on=i.on,r.prototype._off=i.off,r.prototype._trigger=i.trigger;var o=r.createInterface("handlers");r.prototype.on=function(){o.on.apply(this,arguments),Array.prototype.unshift.call(arguments,"on"),this._trigger.apply(this,arguments)},r.prototype.off=o.off,r.prototype.trigger=o.trigger,r.prototype.removeAllListeners=o.removeAllListeners,n.exports=r},{}],3:[function(t,n){(function(e){function r(t,n){var e=0;return function(){var r=Date.now();r-e>t&&(e=r,n.apply(this,arguments))}}function i(t,n){if(void 0!==t&&t||(t={}),"object"==typeof n)for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e]);return t}function o(){var t=this,n=Date.now();this.origin=u(),this.lastMessage=n,this.receivedIDs={},this.previousValues={};var r=function(){t._onStorageEvent.apply(t,arguments)};"undefined"!=typeof document&&(document.attachEvent?document.attachEvent("onstorage",r):e.addEventListener("storage",r,!1))}var a=t("./eventemitter.js"),u=t("../src/shared.js").guid,s=function(t){return t===void 0||t.localStorage===void 0?{getItem:function(){},setItem:function(){},removeItem:function(){}}:t.localStorage}(e);o.prototype._transaction=function(t){function n(){if(!a){var f=Date.now(),d=0|s.getItem(l);if(d&&r>f-d)return u||(o._on("storage",n),u=!0),c=setTimeout(n,i),void 0;a=!0,s.setItem(l,f),t(),e()}}function e(){u&&o._off("storage",n),c&&clearTimeout(c),s.removeItem(l)}var r=1e3,i=20,o=this,a=!1,u=!1,c=null;n()},o.prototype._cleanup_emit=r(100,function(){var t=this;t._transaction(function(){var t,n=Date.now(),e=n-d,r=0;try{t=JSON.parse(s.getItem(c)||"[]")}catch(i){t=[]}for(var o=t.length-1;o>=0;o--)e>t[o].timestamp&&(t.splice(o,1),r++);r>0&&s.setItem(c,JSON.stringify(t))})}),o.prototype._cleanup_once=r(100,function(){var t=this;t._transaction(function(){var n,e;Date.now();var r=0;try{e=JSON.parse(s.getItem(f)||"{}")}catch(i){e={}}for(n in e)t._once_expired(n,e)&&(delete e[n],r++);r>0&&s.setItem(f,JSON.stringify(e))})}),o.prototype._once_expired=function(t,n){if(!n)return!0;if(!n.hasOwnProperty(t))return!0;if("object"!=typeof n[t])return!0;var e=n[t].ttl||p,r=Date.now(),i=n[t].timestamp;return r-e>i},o.prototype._localStorageChanged=function(t,n){if(t&&t.key)return t.key===n;var e=s.getItem(n);return e===this.previousValues[n]?!1:(this.previousValues[n]=e,!0)},o.prototype._onStorageEvent=function(t){t=t||e.event;var n=this;this._localStorageChanged(t,c)&&this._transaction(function(){var t,e=Date.now(),r=s.getItem(c);try{t=JSON.parse(r||"[]")}catch(i){t=[]}for(var o=0;t.length>o;o++)if(t[o].origin!==n.origin&&!(t[o].timestampr;r++)if(n.call(e,t[r],r,t)===m)return}else{var o=o(t);for(r=0,i=o.length;i>r;r++)if(n.call(e,t[o[r]],o[r],t)===m)return}}function a(t,n,e){n||(n=i);var r=!1;return null==t?r:p&&t.some===p?t.some(n,e):(o(t,function(t,i,o){return r||(r=n.call(e,t,i,o))?m:void 0}),!!r)}function u(t,n){return null==t?!1:d&&t.indexOf===d?-1!=t.indexOf(n):a(t,function(t){return t===n})}function s(t){this.value=t}function c(t){return t&&"object"==typeof t&&!Array.isArray(t)&&g.call(t,"__wrapped__")?t:new s(t)}var f=Array.prototype,l=f.forEach,d=f.indexOf,p=f.some,h=Object.prototype,g=h.hasOwnProperty,v=Object.keys,m={},y=v||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var n=[];for(var r in t)e(t,r)&&n.push(r);return n};s.prototype.has=function(t){return e(this.value,t)},s.prototype.contains=function(t){return u(this.value,t)},s.prototype.size=function(){return r(this.value)},n.exports=c},{}],5:[function(t,n,e){(function(t){"use strict";e.encode=function(n){var e,r=new Uint8Array(n),i=r.length,o="";for(e=0;i>e;e+=3)o+=t[r[e]>>2],o+=t[(3&r[e])<<4|r[e+1]>>4],o+=t[(15&r[e+1])<<2|r[e+2]>>6],o+=t[63&r[e+2]];return 2===i%3?o=o.substring(0,o.length-1)+"=":1===i%3&&(o=o.substring(0,o.length-2)+"=="),o},e.decode=function(n){var e,r,i,o,a,u=.75*n.length,s=n.length,c=0;"="===n[n.length-1]&&(u--,"="===n[n.length-2]&&u--);var f=new ArrayBuffer(u),l=new Uint8Array(f);for(e=0;s>e;e+=4)r=t.indexOf(n[e]),i=t.indexOf(n[e+1]),o=t.indexOf(n[e+2]),a=t.indexOf(n[e+3]),l[c++]=r<<2|i>>4,l[c++]=(15&i)<<4|o>>2,l[c++]=(3&o)<<6|63&a;return f}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],6:[function(t,n){(function(t){function e(t,n){if("function"!=typeof n)throw Error("Bad callback given: "+n);if(!t)throw Error("No options given");var a=t.onResponse;if(t="string"==typeof t?{uri:t}:JSON.parse(JSON.stringify(t)),t.onResponse=a,t.verbose&&(e.log=o()),t.url&&(t.uri=t.url,delete t.url),!t.uri&&""!==t.uri)throw Error("options.uri is a required argument");if("string"!=typeof t.uri)throw Error("options.uri must be a string");for(var u=["proxy","_redirectsFollowed","maxRedirects","followRedirect"],c=0;u.length>c;c++)if(t[u[c]])throw Error("options."+u[c]+" is not supported");if(t.callback=n,t.method=t.method||"GET",t.headers=t.headers||{},t.body=t.body||null,t.timeout=t.timeout||e.DEFAULT_TIMEOUT,t.headers.host)throw Error("Options.headers.host is not supported");t.json&&(t.headers.accept=t.headers.accept||"application/json","GET"!==t.method&&(t.headers["content-type"]="application/json"),"boolean"!=typeof t.json?t.body=JSON.stringify(t.json):"string"!=typeof t.body&&(t.body=JSON.stringify(t.body)));var f=function(t){var n=[];for(var e in t)t.hasOwnProperty(e)&&n.push(encodeURIComponent(e)+"="+encodeURIComponent(t[e]));return n.join("&")};if(t.qs){var l="string"==typeof t.qs?t.qs:f(t.qs);t.uri=-1!==t.uri.indexOf("?")?t.uri+"&"+l:t.uri+"?"+l}var d=function(t){var n={};n.boundry="-------------------------------"+Math.floor(1e9*Math.random());var e=[];for(var r in t)t.hasOwnProperty(r)&&e.push("--"+n.boundry+"\n"+'Content-Disposition: form-data; name="'+r+'"'+"\n"+"\n"+t[r]+"\n");return e.push("--"+n.boundry+"--"),n.body=e.join(""),n.length=n.body.length,n.type="multipart/form-data; boundary="+n.boundry,n};if(t.form){if("string"==typeof t.form)throw"form name unsupported";if("POST"===t.method){var p=(t.encoding||"application/x-www-form-urlencoded").toLowerCase();switch(t.headers["content-type"]=p,p){case"application/x-www-form-urlencoded":t.body=f(t.form).replace(/%20/g,"+");break;case"multipart/form-data":var h=d(t.form);t.body=h.body,t.headers["content-type"]=h.type;break;default:throw Error("unsupported encoding:"+p)}}}return t.onResponse=t.onResponse||i,t.onResponse===!0&&(t.onResponse=n,t.callback=i),!t.headers.authorization&&t.auth&&(t.headers.authorization="Basic "+s(t.auth.username+":"+t.auth.password)),r(t)}function r(n){function r(){d=!0;var t=Error("ETIMEDOUT");return t.code="ETIMEDOUT",t.duration=n.timeout,e.log.error("Timeout",{id:f._id,milliseconds:n.timeout}),n.callback(t,f)}function i(){if(d)return e.log.debug("Ignoring timed out state change",{state:f.readyState,id:f.id});if(e.log.debug("State change",{state:f.readyState,id:f.id,timed_out:d}),f.readyState===c.OPENED){e.log.debug("Request started",{id:f.id});for(var t in n.headers)f.setRequestHeader(t,n.headers[t])}else f.readyState===c.HEADERS_RECEIVED?o():f.readyState===c.LOADING?(o(),a()):f.readyState===c.DONE&&(o(),a(),s())}function o(){if(!v.response){if(v.response=!0,e.log.debug("Got response",{id:f.id,status:f.status}),clearTimeout(f.timeoutTimer),f.statusCode=f.status,p&&0==f.statusCode){var t=Error("CORS request rejected: "+n.uri);return t.cors="rejected",v.loading=!0,v.end=!0,n.callback(t,f)}n.onResponse(null,f)}}function a(){v.loading||(v.loading=!0,e.log.debug("Response body loading",{id:f.id}))}function s(){if(!v.end){if(v.end=!0,e.log.debug("Request done",{id:f.id}),null===n.encoding)f.body=new t(new Uint8Array(f.response));else if(f.body=f.responseText,n.json)try{f.body=JSON.parse(f.responseText)}catch(r){return n.callback(r,f)}n.callback(null,f,f.body)}}var f=new c,d=!1,p=u(n.uri),h="withCredentials"in f;if(l+=1,f.seq_id=l,f.id=l+": "+n.method+" "+n.uri,f._id=f.id,p&&!h){var g=Error("Browser does not support cross-origin request: "+n.uri);return g.cors="unsupported",n.callback(g,f)}f.timeoutTimer=setTimeout(r,n.timeout);var v={response:!1,loading:!1,end:!1};return f.onreadystatechange=i,f.open(n.method,n.uri,!0),null===n.encoding&&(f.responseType="arraybuffer"),p&&(f.withCredentials=!!n.withCredentials),f.send(n.body),f}function i(){}function o(){var t,n,e={},r=["trace","debug","info","warn","error"];for(n=0;r.length>n;n++)t=r[n],e[t]=i,"undefined"!=typeof console&&console&&console[t]&&(e[t]=a(console,t));return e}function a(t,n){function e(e,r){return"object"==typeof r&&(e+=" "+JSON.stringify(r)),t[n].call(t,e)}return e}function u(t){var n,e=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/;try{n=location.href}catch(r){n=document.createElement("a"),n.href="",n=n.href}var i=e.exec(n.toLowerCase())||[],o=e.exec(t.toLowerCase()),a=!(!o||o[1]==i[1]&&o[2]==i[2]&&(o[3]||("http:"===o[1]?80:443))==(i[3]||("http:"===i[1]?80:443)));return a}function s(t){var n,e,r,i,o,a,u,s,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",f=0,l=0,d="",p=[];if(!t)return t;do n=t.charCodeAt(f++),e=t.charCodeAt(f++),r=t.charCodeAt(f++),s=n<<16|e<<8|r,i=63&s>>18,o=63&s>>12,a=63&s>>6,u=63&s,p[l++]=c.charAt(i)+c.charAt(o)+c.charAt(a)+c.charAt(u);while(t.length>f);switch(d=p.join(""),t.length%3){case 1:d=d.slice(0,-2)+"==";break;case 2:d=d.slice(0,-1)+"="}return d}var c=XMLHttpRequest;if(!c)throw Error("missing XMLHttpRequest");e.log={trace:i,debug:i,info:i,warn:i,error:i};var f=18e4,l=0;e.withCredentials=!1,e.DEFAULT_TIMEOUT=f,e.defaults=function(t){var n=function(n){var e=function(e,r){e="string"==typeof e?{uri:e}:JSON.parse(JSON.stringify(e));for(var i in t)void 0===e[i]&&(e[i]=t[i]);return n(e,r)};return e},r=n(e);return r.get=n(e.get),r.post=n(e.post),r.put=n(e.put),r.head=n(e.head),r};var d=["get","put","post","head"];d.forEach(function(t){var n=t.toUpperCase(),r=t.toLowerCase();e[r]=function(t){"string"==typeof t?t={method:n,uri:t}:(t=JSON.parse(JSON.stringify(t)),t.method=n);var r=[t].concat(Array.prototype.slice.apply(arguments,[1]));return e.apply(this,r)}}),e.couch=function(t,n){function r(t,e,r){if(t)return n(t,e,r);if((200>e.statusCode||e.statusCode>299)&&r.error){t=Error("CouchDB error: "+(r.error.reason||r.error.error));for(var i in r)t[i]=r[i];return n(t,e,r)}return n(t,e,r)}"string"==typeof t&&(t={uri:t}),t.json=!0,t.body&&(t.json=t.body),delete t.body,n=n||i;var o=e(t,r);return o},n.exports=e}).call(this,t("buffer").Buffer)},{buffer:7}],7:[function(t,n,e){function r(t,n,e){if(!(this instanceof r))return new r(t,n,e);var i=typeof t;"base64"===n&&"string"===i&&(t=x(t));var o;if("number"===i)o=R(t);else if("string"===i)o=r.byteLength(t,n);else{if("object"!==i)throw Error("First argument needs to be a number, array or string.");o=R(t.length)}var a;r._useTypedArrays?a=r._augment(new Uint8Array(o)):(a=this,a.length=o,a._isBuffer=!0);var u;if(r._useTypedArrays&&"number"==typeof t.byteLength)a._set(t);else if(L(t))if(r.isBuffer(t))for(u=0;o>u;u++)a[u]=t.readUInt8(u);else for(u=0;o>u;u++)a[u]=(t[u]%256+256)%256;else if("string"===i)a.write(t,0,n);else if("number"===i&&!r._useTypedArrays&&!e)for(u=0;o>u;u++)a[u]=0;return a}function i(t,n,e,r){e=Number(e)||0;var i=t.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;var o=n.length;z(0===o%2,"Invalid hex string"),r>o/2&&(r=o/2);for(var a=0;r>a;a++){var u=parseInt(n.substr(2*a,2),16);z(!isNaN(u),"Invalid hex string"),t[e+a]=u}return a}function o(t,n,e,r){var i=U(M(n),t,e,r);return i}function a(t,n,e,r){var i=U(k(n),t,e,r);return i}function u(t,n,e,r){return a(t,n,e,r)}function s(t,n,e,r){var i=U(F(n),t,e,r);return i}function c(t,n,e,r){var i=U(C(n),t,e,r);return i}function f(t,n,e){return 0===n&&e===t.length?X.fromByteArray(t):X.fromByteArray(t.slice(n,e))}function l(t,n,e){var r="",i="";e=Math.min(t.length,e);for(var o=n;e>o;o++)127>=t[o]?(r+=P(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+P(i)}function d(t,n,e){var r="";e=Math.min(t.length,e);for(var i=n;e>i;i++)r+=String.fromCharCode(t[i]);return r}function p(t,n,e){return d(t,n,e)}function h(t,n,e){var r=t.length;(!n||0>n)&&(n=0),(!e||0>e||e>r)&&(e=r);for(var i="",o=n;e>o;o++)i+=B(t[o]);return i}function g(t,n,e){for(var r=t.slice(n,e),i="",o=0;r.length>o;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function v(t,n,e,r){r||(z("boolean"==typeof e,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+1,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o;return e?(o=t[n],i>n+1&&(o|=t[n+1]<<8)):(o=t[n]<<8,i>n+1&&(o|=t[n+1])),o}}function m(t,n,e,r){r||(z("boolean"==typeof e,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+3,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o;return e?(i>n+2&&(o=t[n+2]<<16),i>n+1&&(o|=t[n+1]<<8),o|=t[n],i>n+3&&(o+=t[n+3]<<24>>>0)):(i>n+1&&(o=t[n+1]<<16),i>n+2&&(o|=t[n+2]<<8),i>n+3&&(o|=t[n+3]),o+=t[n]<<24>>>0),o}}function y(t,n,e,r){r||(z("boolean"==typeof e,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+1,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o=v(t,n,e,!0),a=32768&o;return a?-1*(65535-o+1):o}}function E(t,n,e,r){r||(z("boolean"==typeof e,"missing or invalid endian"),z(void 0!==n&&null!==n,"missing offset"),z(t.length>n+3,"Trying to read beyond buffer length"));var i=t.length;if(!(n>=i)){var o=m(t,n,e,!0),a=2147483648&o;return a?-1*(4294967295-o+1):o}}function b(t,n,e,r){return r||(z("boolean"==typeof e,"missing or invalid endian"),z(t.length>n+3,"Trying to read beyond buffer length")),W.read(t,n,e,23,4)}function w(t,n,e,r){return r||(z("boolean"==typeof e,"missing or invalid endian"),z(t.length>n+7,"Trying to read beyond buffer length")),W.read(t,n,e,52,8)}function I(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+1,"trying to write beyond buffer length"),V(n,65535));var o=t.length;if(!(e>=o)){for(var a=0,u=Math.min(o-e,2);u>a;a++)t[e+a]=(n&255<<8*(r?a:1-a))>>>8*(r?a:1-a);return e+2}}function O(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+3,"trying to write beyond buffer length"),V(n,4294967295));var o=t.length;if(!(e>=o)){for(var a=0,u=Math.min(o-e,4);u>a;a++)t[e+a]=255&n>>>8*(r?a:3-a);return e+4}}function A(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+1,"Trying to write beyond buffer length"),Y(n,32767,-32768));var o=t.length;if(!(e>=o))return n>=0?I(t,n,e,r,i):I(t,65535+n+1,e,r,i),e+2}function j(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+3,"Trying to write beyond buffer length"),Y(n,2147483647,-2147483648));var o=t.length;if(!(e>=o))return n>=0?O(t,n,e,r,i):O(t,4294967295+n+1,e,r,i),e+4}function T(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+3,"Trying to write beyond buffer length"),q(n,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;if(!(e>=o))return W.write(t,n,e,r,23,4),e+4}function S(t,n,e,r,i){i||(z(void 0!==n&&null!==n,"missing value"),z("boolean"==typeof r,"missing or invalid endian"),z(void 0!==e&&null!==e,"missing offset"),z(t.length>e+7,"Trying to write beyond buffer length"),q(n,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;if(!(e>=o))return W.write(t,n,e,r,52,8),e+8}function x(t){for(t=N(t).replace(H,"");0!==t.length%4;)t+="=";return t}function N(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function D(t,n,e){return"number"!=typeof t?e:(t=~~t,t>=n?n:t>=0?t:(t+=n,t>=0?t:0))}function R(t){return t=~~Math.ceil(+t),0>t?0:t}function _(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function L(t){return _(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function B(t){return 16>t?"0"+t.toString(16):t.toString(16)}function M(t){for(var n=[],e=0;t.length>e;e++){var r=t.charCodeAt(e);if(127>=r)n.push(r);else{var i=e;r>=55296&&57343>=r&&e++;for(var o=encodeURIComponent(t.slice(i,e+1)).substr(1).split("%"),a=0;o.length>a;a++)n.push(parseInt(o[a],16))}}return n}function k(t){for(var n=[],e=0;t.length>e;e++)n.push(255&t.charCodeAt(e));return n}function C(t){for(var n,e,r,i=[],o=0;t.length>o;o++)n=t.charCodeAt(o),e=n>>8,r=n%256,i.push(r),i.push(e);return i}function F(t){return X.toByteArray(t)}function U(t,n,e,r){for(var i=0;r>i&&!(i+e>=n.length||i>=t.length);i++)n[i+e]=t[i];return i}function P(t){try{return decodeURIComponent(t)}catch(n){return String.fromCharCode(65533)}}function V(t,n){z("number"==typeof t,"cannot write a non-number as a number"),z(t>=0,"specified a negative value for writing an unsigned value"),z(n>=t,"value is larger than maximum value for type"),z(Math.floor(t)===t,"value has a fractional component")}function Y(t,n,e){z("number"==typeof t,"cannot write a non-number as a number"),z(n>=t,"value larger than maximum allowed value"),z(t>=e,"value smaller than minimum allowed value"),z(Math.floor(t)===t,"value has a fractional component")}function q(t,n,e){z("number"==typeof t,"cannot write a non-number as a number"),z(n>=t,"value larger than maximum allowed value"),z(t>=e,"value smaller than minimum allowed value")}function z(t,n){if(!t)throw Error(n||"Failed assertion")}var X=t("base64-js"),W=t("ieee754");e.Buffer=r,e.SlowBuffer=r,e.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){try{var t=new ArrayBuffer(0),n=new Uint8Array(t);return n.foo=function(){return 42},42===n.foo()&&"function"==typeof n.subarray}catch(e){return!1}}(),r.isEncoding=function(t){switch((t+"").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}},r.isBuffer=function(t){return!(null===t||void 0===t||!t._isBuffer)},r.byteLength=function(t,n){var e;switch(t=""+t,n||"utf8"){case"hex":e=t.length/2;break;case"utf8":case"utf-8":e=M(t).length;break;case"ascii":case"binary":case"raw":e=t.length;break;case"base64":e=F(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":e=2*t.length;break;default:throw Error("Unknown encoding")}return e},r.concat=function(t,n){if(z(_(t),"Usage: Buffer.concat(list[, length])"),0===t.length)return new r(0);if(1===t.length)return t[0];var e;if(void 0===n)for(n=0,e=0;t.length>e;e++)n+=t[e].length;var i=new r(n),o=0;for(e=0;t.length>e;e++){var a=t[e];a.copy(i,o),o+=a.length}return i},r.compare=function(t,n){z(r.isBuffer(t)&&r.isBuffer(n),"Arguments must be Buffers");for(var e=t.length,i=n.length,o=0,a=Math.min(e,i);a>o&&t[o]===n[o];o++);return o!==a&&(e=t[o],i=n[o]),i>e?-1:e>i?1:0},r.prototype.write=function(t,n,e,r){if(isFinite(n))isFinite(e)||(r=e,e=void 0);else{var f=r;r=n,n=e,e=f}n=Number(n)||0;var l=this.length-n; -e?(e=Number(e),e>l&&(e=l)):e=l,r=((r||"utf8")+"").toLowerCase();var d;switch(r){case"hex":d=i(this,t,n,e);break;case"utf8":case"utf-8":d=o(this,t,n,e);break;case"ascii":d=a(this,t,n,e);break;case"binary":d=u(this,t,n,e);break;case"base64":d=s(this,t,n,e);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":d=c(this,t,n,e);break;default:throw Error("Unknown encoding")}return d},r.prototype.toString=function(t,n,e){var r=this;if(t=((t||"utf8")+"").toLowerCase(),n=Number(n)||0,e=void 0===e?r.length:Number(e),e===n)return"";var i;switch(t){case"hex":i=h(r,n,e);break;case"utf8":case"utf-8":i=l(r,n,e);break;case"ascii":i=d(r,n,e);break;case"binary":i=p(r,n,e);break;case"base64":i=f(r,n,e);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=g(r,n,e);break;default:throw Error("Unknown encoding")}return i},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.equals=function(t){return z(r.isBuffer(t),"Argument must be a Buffer"),0===r.compare(this,t)},r.prototype.compare=function(t){return z(r.isBuffer(t),"Argument must be a Buffer"),r.compare(this,t)},r.prototype.copy=function(t,n,e,i){var o=this;if(e||(e=0),i||0===i||(i=this.length),n||(n=0),i!==e&&0!==t.length&&0!==o.length){z(i>=e,"sourceEnd < sourceStart"),z(n>=0&&t.length>n,"targetStart out of bounds"),z(e>=0&&o.length>e,"sourceStart out of bounds"),z(i>=0&&o.length>=i,"sourceEnd out of bounds"),i>this.length&&(i=this.length),i-e>t.length-n&&(i=t.length-n+e);var a=i-e;if(100>a||!r._useTypedArrays)for(var u=0;a>u;u++)t[u+n]=this[u+e];else t._set(this.subarray(e,e+a),n)}},r.prototype.slice=function(t,n){var e=this.length;if(t=D(t,e,0),n=D(n,e,e),r._useTypedArrays)return r._augment(this.subarray(t,n));for(var i=n-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,n){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,n)},r.prototype.readUInt8=function(t,n){return n||(z(void 0!==t&&null!==t,"missing offset"),z(this.length>t,"Trying to read beyond buffer length")),t>=this.length?void 0:this[t]},r.prototype.readUInt16LE=function(t,n){return v(this,t,!0,n)},r.prototype.readUInt16BE=function(t,n){return v(this,t,!1,n)},r.prototype.readUInt32LE=function(t,n){return m(this,t,!0,n)},r.prototype.readUInt32BE=function(t,n){return m(this,t,!1,n)},r.prototype.readInt8=function(t,n){if(n||(z(void 0!==t&&null!==t,"missing offset"),z(this.length>t,"Trying to read beyond buffer length")),!(t>=this.length)){var e=128&this[t];return e?-1*(255-this[t]+1):this[t]}},r.prototype.readInt16LE=function(t,n){return y(this,t,!0,n)},r.prototype.readInt16BE=function(t,n){return y(this,t,!1,n)},r.prototype.readInt32LE=function(t,n){return E(this,t,!0,n)},r.prototype.readInt32BE=function(t,n){return E(this,t,!1,n)},r.prototype.readFloatLE=function(t,n){return b(this,t,!0,n)},r.prototype.readFloatBE=function(t,n){return b(this,t,!1,n)},r.prototype.readDoubleLE=function(t,n){return w(this,t,!0,n)},r.prototype.readDoubleBE=function(t,n){return w(this,t,!1,n)},r.prototype.writeUInt8=function(t,n,e){return e||(z(void 0!==t&&null!==t,"missing value"),z(void 0!==n&&null!==n,"missing offset"),z(this.length>n,"trying to write beyond buffer length"),V(t,255)),n>=this.length?void 0:(this[n]=t,n+1)},r.prototype.writeUInt16LE=function(t,n,e){return I(this,t,n,!0,e)},r.prototype.writeUInt16BE=function(t,n,e){return I(this,t,n,!1,e)},r.prototype.writeUInt32LE=function(t,n,e){return O(this,t,n,!0,e)},r.prototype.writeUInt32BE=function(t,n,e){return O(this,t,n,!1,e)},r.prototype.writeInt8=function(t,n,e){return e||(z(void 0!==t&&null!==t,"missing value"),z(void 0!==n&&null!==n,"missing offset"),z(this.length>n,"Trying to write beyond buffer length"),Y(t,127,-128)),n>=this.length?void 0:(t>=0?this.writeUInt8(t,n,e):this.writeUInt8(255+t+1,n,e),n+1)},r.prototype.writeInt16LE=function(t,n,e){return A(this,t,n,!0,e)},r.prototype.writeInt16BE=function(t,n,e){return A(this,t,n,!1,e)},r.prototype.writeInt32LE=function(t,n,e){return j(this,t,n,!0,e)},r.prototype.writeInt32BE=function(t,n,e){return j(this,t,n,!1,e)},r.prototype.writeFloatLE=function(t,n,e){return T(this,t,n,!0,e)},r.prototype.writeFloatBE=function(t,n,e){return T(this,t,n,!1,e)},r.prototype.writeDoubleLE=function(t,n,e){return S(this,t,n,!0,e)},r.prototype.writeDoubleBE=function(t,n,e){return S(this,t,n,!1,e)},r.prototype.fill=function(t,n,e){if(t||(t=0),n||(n=0),e||(e=this.length),z(e>=n,"end < start"),e!==n&&0!==this.length){z(n>=0&&this.length>n,"start out of bounds"),z(e>=0&&this.length>=e,"end out of bounds");var r;if("number"==typeof t)for(r=n;e>r;r++)this[r]=t;else{var i=M(""+t),o=i.length;for(r=n;e>r;r++)this[r]=i[r%o]}return this}},r.prototype.inspect=function(){for(var t=[],n=this.length,r=0;n>r;r++)if(t[r]=B(this[r]),r===e.INSPECT_MAX_BYTES){t[r+1]="...";break}return""},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(r._useTypedArrays)return new r(this).buffer;for(var t=new Uint8Array(this.length),n=0,e=t.length;e>n;n+=1)t[n]=this[n];return t.buffer}throw Error("Buffer.toArrayBuffer not supported in this browser")};var J=r.prototype;r._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=J.get,t.set=J.set,t.write=J.write,t.toString=J.toString,t.toLocaleString=J.toString,t.toJSON=J.toJSON,t.equals=J.equals,t.compare=J.compare,t.copy=J.copy,t.slice=J.slice,t.readUInt8=J.readUInt8,t.readUInt16LE=J.readUInt16LE,t.readUInt16BE=J.readUInt16BE,t.readUInt32LE=J.readUInt32LE,t.readUInt32BE=J.readUInt32BE,t.readInt8=J.readInt8,t.readInt16LE=J.readInt16LE,t.readInt16BE=J.readInt16BE,t.readInt32LE=J.readInt32LE,t.readInt32BE=J.readInt32BE,t.readFloatLE=J.readFloatLE,t.readFloatBE=J.readFloatBE,t.readDoubleLE=J.readDoubleLE,t.readDoubleBE=J.readDoubleBE,t.writeUInt8=J.writeUInt8,t.writeUInt16LE=J.writeUInt16LE,t.writeUInt16BE=J.writeUInt16BE,t.writeUInt32LE=J.writeUInt32LE,t.writeUInt32BE=J.writeUInt32BE,t.writeInt8=J.writeInt8,t.writeInt16LE=J.writeInt16LE,t.writeInt16BE=J.writeInt16BE,t.writeInt32LE=J.writeInt32LE,t.writeInt32BE=J.writeInt32BE,t.writeFloatLE=J.writeFloatLE,t.writeFloatBE=J.writeFloatBE,t.writeDoubleLE=J.writeDoubleLE,t.writeDoubleBE=J.writeDoubleBE,t.fill=J.fill,t.inspect=J.inspect,t.toArrayBuffer=J.toArrayBuffer,t};var H=/[^+\/0-9A-z]/g},{"base64-js":8,ieee754:9}],8:[function(t,n,e){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(t){"use strict";function n(t){var n=t.charCodeAt(0);return n===a?62:n===u?63:s>n?-1:s+10>n?n-s+26+26:f+26>n?n-f:c+26>n?n-c+26:void 0}function e(t){function e(t){c[l++]=t}var r,i,a,u,s,c;if(t.length%4>0)throw Error("Invalid string. Length must be a multiple of 4");var f=t.length;s="="===t.charAt(f-2)?2:"="===t.charAt(f-1)?1:0,c=new o(3*t.length/4-s),a=s>0?t.length-4:t.length;var l=0;for(r=0,i=0;a>r;r+=4,i+=3)u=n(t.charAt(r))<<18|n(t.charAt(r+1))<<12|n(t.charAt(r+2))<<6|n(t.charAt(r+3)),e((16711680&u)>>16),e((65280&u)>>8),e(255&u);return 2===s?(u=n(t.charAt(r))<<2|n(t.charAt(r+1))>>4,e(255&u)):1===s&&(u=n(t.charAt(r))<<10|n(t.charAt(r+1))<<4|n(t.charAt(r+2))>>2,e(255&u>>8),e(255&u)),c}function i(t){function n(t){return r.charAt(t)}function e(t){return n(63&t>>18)+n(63&t>>12)+n(63&t>>6)+n(63&t)}var i,o,a,u=t.length%3,s="";for(i=0,a=t.length-u;a>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],s+=e(o);switch(u){case 1:o=t[t.length-1],s+=n(o>>2),s+=n(63&o<<4),s+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],s+=n(o>>10),s+=n(63&o>>4),s+=n(63&o<<2),s+="="}return s}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),u="/".charCodeAt(0),s="0".charCodeAt(0),c="a".charCodeAt(0),f="A".charCodeAt(0);t.toByteArray=e,t.fromByteArray=i})(e===void 0?this.base64js={}:e)},{}],9:[function(t,n,e){e.read=function(t,n,e,r,i){var o,a,u=8*i-r-1,s=(1<>1,f=-7,l=e?i-1:0,d=e?-1:1,p=t[n+l];for(l+=d,o=p&(1<<-f)-1,p>>=-f,f+=u;f>0;o=256*o+t[n+l],l+=d,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=r;f>0;a=256*a+t[n+l],l+=d,f-=8);if(0===o)o=1-c;else{if(o===s)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=c}return(p?-1:1)*a*Math.pow(2,o-r)},e.write=function(t,n,e,r,i,o){var a,u,s,c=8*o-i-1,f=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,h=r?1:-1,g=0>n||0===n&&0>1/n?1:0;for(n=Math.abs(n),isNaN(n)||1/0===n?(u=isNaN(n)?1:0,a=f):(a=Math.floor(Math.log(n)/Math.LN2),1>n*(s=Math.pow(2,-a))&&(a--,s*=2),n+=a+l>=1?d/s:d*Math.pow(2,1-l),n*s>=2&&(a++,s/=2),a+l>=f?(u=0,a=f):a+l>=1?(u=(n*s-1)*Math.pow(2,i),a+=l):(u=n*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[e+p]=255&u,p+=h,u/=256,i-=8);for(a=a<0;t[e+p]=255&a,p+=h,a/=256,c-=8);t[e+p-h]|=128*g}},{}],10:[function(t,n){function e(){}var r=n.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,n="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(n){var e=[];return window.addEventListener("message",function(t){var n=t.source;if((n===window||null===n)&&"process-tick"===t.data&&(t.stopPropagation(),e.length>0)){var r=e.shift();r()}},!0),function(t){e.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=e,r.addListener=e,r.once=e,r.off=e,r.removeListener=e,r.removeAllListeners=e,r.emit=e,r.binding=function(){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw Error("process.chdir is not supported")}},{}],11:[function(t,n){(function(t){function e(n,e,r){return n instanceof ArrayBuffer&&(n=new Uint8Array(n)),new t(n,e,r)}e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Object.keys(t).forEach(function(n){t.hasOwnProperty(n)&&(e[n]=t[n])}),n.exports=e}).call(this,t("buffer").Buffer)},{buffer:7}],12:[function(t,n){var e="READ",r="WRITE",i="CREATE",o="EXCLUSIVE",a="TRUNCATE",u="APPEND",s="CREATE",c="REPLACE";n.exports={FILE_SYSTEM_NAME:"local",FILE_STORE_NAME:"files",IDB_RO:"readonly",IDB_RW:"readwrite",WSQL_VERSION:"1",WSQL_SIZE:5242880,WSQL_DESC:"FileSystem Storage",MODE_FILE:"FILE",MODE_DIRECTORY:"DIRECTORY",MODE_SYMBOLIC_LINK:"SYMLINK",MODE_META:"META",SYMLOOP_MAX:10,BINARY_MIME_TYPE:"application/octet-stream",JSON_MIME_TYPE:"application/json",ROOT_DIRECTORY_NAME:"/",FS_FORMAT:"FORMAT",FS_NOCTIME:"NOCTIME",FS_NOMTIME:"NOMTIME",FS_NODUPEIDCHECK:"FS_NODUPEIDCHECK",O_READ:e,O_WRITE:r,O_CREATE:i,O_EXCLUSIVE:o,O_TRUNCATE:a,O_APPEND:u,O_FLAGS:{r:[e],"r+":[e,r],w:[r,i,a],"w+":[r,e,i,a],wx:[r,i,o,a],"wx+":[r,e,i,o,a],a:[r,i,u],"a+":[r,e,i,u],ax:[r,i,o,u],"ax+":[r,e,i,o,u]},XATTR_CREATE:s,XATTR_REPLACE:c,FS_READY:"READY",FS_PENDING:"PENDING",FS_ERROR:"ERROR",SUPER_NODE_ID:"00000000-0000-0000-0000-000000000000",STDIN:0,STDOUT:1,STDERR:2,FIRST_DESCRIPTOR:3,ENVIRONMENT:{TMP:"/tmp",PATH:""}}},{}],13:[function(t,n){var e=t("./constants.js").MODE_FILE;n.exports=function(t,n){this.id=t,this.type=n||e}},{"./constants.js":12}],14:[function(t,n){(function(t){function e(t){return t.toString("utf8")}function r(n){return new t(n,"utf8")}n.exports={encode:r,decode:e}}).call(this,t("buffer").Buffer)},{buffer:7}],15:[function(t,n){var e={};["9:EBADF:bad file descriptor","10:EBUSY:resource busy or locked","18:EINVAL:invalid argument","27:ENOTDIR:not a directory","28:EISDIR:illegal operation on a directory","34:ENOENT:no such file or directory","47:EEXIST:file already exists","51:ELOOP:too many symbolic links encountered","53:ENOTEMPTY:directory not empty","55:EIO:i/o error","1000:ENOTMOUNTED:not mounted","1001:EFILESYSTEMERROR:missing super node, use 'FORMAT' flag to format filesystem.","1002:ENOATTR:attribute does not exist"].forEach(function(t){function n(t,n){Error.call(this),this.name=i,this.code=i,this.errno=r,this.message=t||o,n&&(this.path=n),this.stack=Error(this.message).stack}t=t.split(":");var r=+t[0],i=t[1],o=t[2];n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n.prototype.toString=function(){var t=this.path?", '"+this.path+"'":"";return this.name+": "+this.message+t},e[i]=e[r]=n}),n.exports=e},{}],16:[function(t,n){function e(t){return function(n,e){n?t(n):t(null,e)}}function r(t,n,e,r,i){function o(e){t.changes.push({event:"change",path:n}),i(e)}var a=t.flags;pn(a).contains(Cn)&&delete r.ctime,pn(a).contains(kn)&&delete r.mtime;var u=!1;r.ctime&&(e.ctime=r.ctime,e.atime=r.ctime,u=!0),r.atime&&(e.atime=r.atime,u=!0),r.mtime&&(e.mtime=r.mtime,u=!0),u?t.putObject(e.id,e,o):o()}function i(t,n,e,i){function a(e,r){e?i(e):r.mode!==In?i(new Un.ENOTDIR("a component of the path prefix is not a directory",n)):(l=r,o(t,n,u))}function u(e,r){!e&&r?i(new Un.EEXIST("path name already exists",n)):!e||e instanceof Un.ENOENT?t.getObject(l.data,s):i(e)}function s(n,r){n?i(n):(d=r,qn.create({guid:t.guid,mode:e},function(n,e){return n?(i(n),void 0):(p=e,p.nlinks+=1,t.putObject(p.id,p,f),void 0)}))}function c(n){if(n)i(n);else{var e=Date.now();r(t,g,p,{mtime:e,ctime:e},i)}}function f(n){n?i(n):(d[h]=new Pn(p.id,e),t.putObject(l.data,d,c))}if(e!==In&&e!==wn)return i(new Un.EINVAL("mode must be a directory or file",n));n=gn(n);var l,d,p,h=mn(n),g=vn(n);o(t,g,a)}function o(t,n,e){function r(n,r){n?e(n):r&&r.mode===An&&r.rnode?t.getObject(r.rnode,i):e(new Un.EFILESYSTEMERROR)}function i(t,n){t?e(t):n?e(null,n):e(new Un.ENOENT)}function a(r,i){r?e(r):i.mode===In&&i.data?t.getObject(i.data,u):e(new Un.ENOTDIR("a component of the path prefix is not a directory",n))}function u(r,i){if(r)e(r);else if(pn(i).has(f)){var o=i[f].id;t.getObject(o,s)}else e(new Un.ENOENT(null,n))}function s(t,r){t?e(t):r.mode==On?(d++,d>Sn?e(new Un.ELOOP(null,n)):c(r.data)):e(null,r)}function c(n){n=gn(n),l=vn(n),f=mn(n),jn==f?t.getObject(Tn,r):o(t,l,a)}if(n=gn(n),!n)return e(new Un.ENOENT("path is an empty string"));var f=mn(n),l=vn(n),d=0;jn==f?t.getObject(Tn,r):o(t,l,a)}function a(t,n,e,i,a,u){function s(o,s){function f(n){n?u(n):r(t,c,s,{ctime:Date.now()},u)}s?s.xattrs[e]:null,o?u(o):a===Bn&&s.xattrs.hasOwnProperty(e)?u(new Un.EEXIST("attribute already exists",n)):a!==Mn||s.xattrs.hasOwnProperty(e)?(s.xattrs[e]=i,t.putObject(s.id,s,f)):u(new Un.ENOATTR(null,n))}var c;"string"==typeof n?(c=n,o(t,n,s)):"object"==typeof n&&"string"==typeof n.id?(c=n.path,t.getObject(n.id,s)):u(new Un.EINVAL("path or file descriptor of wrong type",n))}function u(t,n){function e(e,i){!e&&i?n():!e||e instanceof Un.ENOENT?Yn.create({guid:t.guid},function(e,i){return e?(n(e),void 0):(o=i,t.putObject(o.id,o,r),void 0)}):n(e)}function r(e){e?n(e):qn.create({guid:t.guid,id:o.rnode,mode:In},function(e,r){return e?(n(e),void 0):(a=r,a.nlinks+=1,t.putObject(a.id,a,i),void 0)})}function i(e){e?n(e):(u={},t.putObject(a.data,u,n))}var o,a,u;t.getObject(Tn,e)}function s(t,n,e){function i(r,i){!r&&i?e(new Un.EEXIST(null,n)):!r||r instanceof Un.ENOENT?o(t,v,a):e(r)}function a(n,r){n?e(n):(p=r,t.getObject(p.data,u))}function u(n,r){n?e(n):(h=r,qn.create({guid:t.guid,mode:In},function(n,r){return n?(e(n),void 0):(l=r,l.nlinks+=1,t.putObject(l.id,l,s),void 0)}))}function s(n){n?e(n):(d={},t.putObject(l.data,d,f))}function c(n){if(n)e(n);else{var i=Date.now();r(t,v,p,{mtime:i,ctime:i},e)}}function f(n){n?e(n):(h[g]=new Pn(l.id,In),t.putObject(p.data,h,c))}n=gn(n);var l,d,p,h,g=mn(n),v=vn(n);o(t,n,i)}function c(t,n,e){function i(n,r){n?e(n):(g=r,t.getObject(g.data,a))}function a(r,i){r?e(r):jn==m?e(new Un.EBUSY(null,n)):pn(i).has(m)?(v=i,p=v[m].id,t.getObject(p,u)):e(new Un.ENOENT(null,n))}function u(r,i){r?e(r):i.mode!=In?e(new Un.ENOTDIR(null,n)):(p=i,t.getObject(p.data,s))}function s(t,r){t?e(t):(h=r,pn(h).size()>0?e(new Un.ENOTEMPTY(null,n)):f())}function c(n){if(n)e(n);else{var i=Date.now();r(t,y,g,{mtime:i,ctime:i},l)}}function f(){delete v[m],t.putObject(g.data,v,c)}function l(n){n?e(n):t.delete(p.id,d)}function d(n){n?e(n):t.delete(p.data,e)}n=gn(n);var p,h,g,v,m=mn(n),y=vn(n);o(t,y,i)}function f(t,n,e,i){function a(e,r){e?i(e):r.mode!==In?i(new Un.ENOENT(null,n)):(v=r,t.getObject(v.data,u))}function u(r,o){r?i(r):(m=o,pn(m).has(w)?pn(e).contains(Rn)?i(new Un.ENOENT("O_CREATE and O_EXCLUSIVE are set, and the named file exists",n)):(y=m[w],y.type==In&&pn(e).contains(Nn)?i(new Un.EISDIR("the named file is a directory and O_WRITE is set",n)):t.getObject(y.id,s)):pn(e).contains(Dn)?l():i(new Un.ENOENT("O_CREATE is not set and the named file does not exist",n)))}function s(t,e){if(t)i(t);else{var r=e;r.mode==On?(O++,O>Sn?i(new Un.ELOOP(null,n)):c(r.data)):f(void 0,r)}}function c(r){r=gn(r),I=vn(r),w=mn(r),jn==w&&(pn(e).contains(Nn)?i(new Un.EISDIR("the named file is a directory and O_WRITE is set",n)):o(t,n,f)),o(t,I,a)}function f(t,n){t?i(t):(E=n,i(null,E))}function l(){qn.create({guid:t.guid,mode:wn},function(n,e){return n?(i(n),void 0):(E=e,E.nlinks+=1,t.putObject(E.id,E,d),void 0)})}function d(n){n?i(n):(b=new Xn(0),b.fill(0),t.putBuffer(E.data,b,h))}function p(n){if(n)i(n);else{var e=Date.now();r(t,I,v,{mtime:e,ctime:e},g)}}function h(n){n?i(n):(m[w]=new Pn(E.id,wn),t.putObject(v.data,m,p))}function g(t){t?i(t):i(null,E)}n=gn(n);var v,m,y,E,b,w=mn(n),I=vn(n),O=0;jn==w?pn(e).contains(Nn)?i(new Un.EISDIR("the named file is a directory and O_WRITE is set",n)):o(t,n,f):o(t,I,a)}function l(t,n,e,i,o,a){function u(t){t?a(t):a(null,o)}function s(e){if(e)a(e);else{var i=Date.now();r(t,n.path,l,{mtime:i,ctime:i},u)}}function c(n){n?a(n):t.putObject(l.id,l,s)}function f(r,u){if(r)a(r);else{l=u;var s=new Xn(o);s.fill(0),e.copy(s,0,i,i+o),n.position=o,l.size=o,l.version+=1,t.putBuffer(l.data,s,c)}}var l;t.getObject(n.id,f)}function d(t,n,e,i,o,a,u){function s(t){t?u(t):u(null,o)}function c(e){if(e)u(e);else{var i=Date.now();r(t,n.path,p,{mtime:i,ctime:i},s)}}function f(n){n?u(n):t.putObject(p.id,p,c)}function l(r,s){if(r)u(r);else{if(h=s,!h)return u(new Un.EIO("Expected Buffer"));var c=void 0!==a&&null!==a?a:n.position,l=Math.max(h.length,c+o),d=new Xn(l);d.fill(0),h&&h.copy(d),e.copy(d,c,i,i+o),void 0===a&&(n.position+=o),p.size=l,p.version+=1,t.putBuffer(p.data,d,f)}}function d(n,e){n?u(n):(p=e,t.getBuffer(p.data,l))}var p,h;t.getObject(n.id,d)}function p(t,n,e,r,i,o,a){function u(t,u){if(t)a(t);else{if(f=u,!f)return a(new Un.EIO("Expected Buffer"));var s=void 0!==o&&null!==o?o:n.position;i=s+i>e.length?i-s:i,f.copy(e,r,s,s+i),void 0===o&&(n.position+=i),a(null,i)}}function s(n,e){n?a(n):(c=e,t.getBuffer(c.data,u))}var c,f;t.getObject(n.id,s)}function h(t,n,r){n=gn(n),mn(n),o(t,n,e(r))}function g(t,n,r){t.getObject(n.id,e(r))}function v(t,n,r){function i(n,e){n?r(n):(u=e,t.getObject(u.data,a))}function a(i,o){i?r(i):(s=o,pn(s).has(c)?t.getObject(s[c].id,e(r)):r(new Un.ENOENT("a component of the path does not name an existing file",n)))}n=gn(n);var u,s,c=mn(n),f=vn(n);jn==c?o(t,n,e(r)):o(t,f,i)}function m(t,n,e,i){function a(n){n?i(n):r(t,e,E,{ctime:Date.now()},i)}function u(n,e){n?i(n):(E=e,E.nlinks+=1,t.putObject(E.id,E,a))}function s(n){n?i(n):t.getObject(y[b].id,u)}function c(n,e){n?i(n):(y=e,pn(y).has(b)?i(new Un.EEXIST("newpath resolves to an existing file",b)):(y[b]=v[p],t.putObject(m.data,y,s)))}function f(n,e){n?i(n):(m=e,t.getObject(m.data,c))}function l(n,e){n?i(n):(v=e,pn(v).has(p)?o(t,w,f):i(new Un.ENOENT("a component of either path prefix does not exist",p)))}function d(n,e){n?i(n):(g=e,t.getObject(g.data,l))}n=gn(n);var p=mn(n),h=vn(n);e=gn(e);var g,v,m,y,E,b=mn(e),w=vn(e);o(t,h,d)}function y(t,n,e){function i(n){n?e(n):(delete l[p],t.putObject(f.data,l,function(){var n=Date.now();r(t,h,f,{mtime:n,ctime:n},e)}))}function a(n){n?e(n):t.delete(d.data,i)}function u(o,u){o?e(o):(d=u,d.nlinks-=1,1>d.nlinks?t.delete(d.id,a):t.putObject(d.id,d,function(){r(t,n,d,{ctime:Date.now()},i)}))}function s(n,r){n?e(n):(l=r,pn(l).has(p)?t.getObject(l[p].id,u):e(new Un.ENOENT("a component of the path does not name an existing file",p)))}function c(n,r){n?e(n):(f=r,t.getObject(f.data,s))}n=gn(n);var f,l,d,p=mn(n),h=vn(n);o(t,h,c)}function E(t,n,e){function r(t,n){if(t)e(t);else{u=n;var r=Object.keys(u);e(null,r)}}function i(i,o){i?e(i):o.mode!==In?e(new Un.ENOTDIR(null,n)):(a=o,t.getObject(a.data,r))}n=gn(n),mn(n);var a,u;o(t,n,i)}function b(t,n,e,i){function a(n,e){n?i(n):(l=e,t.getObject(l.data,u))}function u(t,n){t?i(t):(d=n,pn(d).has(h)?i(new Un.EEXIST(null,h)):s())}function s(){qn.create({guid:t.guid,mode:On},function(e,r){return e?(i(e),void 0):(p=r,p.nlinks+=1,p.size=n.length,p.data=n,t.putObject(p.id,p,f),void 0)})}function c(n){if(n)i(n);else{var e=Date.now();r(t,g,l,{mtime:e,ctime:e},i)}}function f(n){n?i(n):(d[h]=new Pn(p.id,On),t.putObject(l.data,d,c))}e=gn(e);var l,d,p,h=mn(e),g=vn(e);jn==h?i(new Un.EEXIST(null,h)):o(t,g,a)}function w(t,n,e){function r(n,r){n?e(n):(u=r,t.getObject(u.data,i))}function i(n,r){n?e(n):(s=r,pn(s).has(c)?t.getObject(s[c].id,a):e(new Un.ENOENT("a component of the path does not name an existing file",c)))}function a(t,r){t?e(t):r.mode!=On?e(new Un.EINVAL("path not a symbolic link",n)):e(null,r.data)}n=gn(n);var u,s,c=mn(n),f=vn(n);o(t,f,r)}function I(t,n,e,i){function a(e,r){e?i(e):r.mode==In?i(new Un.EISDIR(null,n)):(f=r,t.getBuffer(f.data,u))}function u(n,r){if(n)i(n);else{if(!r)return i(new Un.EIO("Expected Buffer"));var o=new Xn(e);o.fill(0),r&&r.copy(o),t.putBuffer(f.data,o,c)}}function s(e){if(e)i(e);else{var o=Date.now();r(t,n,f,{mtime:o,ctime:o},i)}}function c(n){n?i(n):(f.size=e,f.version+=1,t.putObject(f.id,f,s))}n=gn(n);var f;0>e?i(new Un.EINVAL("length cannot be negative")):o(t,n,a)}function O(t,n,e,i){function o(n,e){n?i(n):e.mode==In?i(new Un.EISDIR):(c=e,t.getBuffer(c.data,a))}function a(n,r){if(n)i(n);else{var o;if(!r)return i(new Un.EIO("Expected Buffer"));r?o=r.slice(0,e):(o=new Xn(e),o.fill(0)),t.putBuffer(c.data,o,s)}}function u(e){if(e)i(e);else{var o=Date.now();r(t,n.path,c,{mtime:o,ctime:o},i)}}function s(n){n?i(n):(c.size=e,c.version+=1,t.putObject(c.id,c,u))}var c;0>e?i(new Un.EINVAL("length cannot be negative")):t.getObject(n.id,o)}function A(t,n,e,i,a){function u(o,u){o?a(o):r(t,n,u,{atime:e,ctime:i,mtime:i},a)}n=gn(n),"number"!=typeof e||"number"!=typeof i?a(new Un.EINVAL("atime and mtime must be number",n)):0>e||0>i?a(new Un.EINVAL("atime and mtime must be positive integers",n)):o(t,n,u)}function j(t,n,e,i,o){function a(a,u){a?o(a):r(t,n.path,u,{atime:e,ctime:i,mtime:i},o)}"number"!=typeof e||"number"!=typeof i?o(new Un.EINVAL("atime and mtime must be a number")):0>e||0>i?o(new Un.EINVAL("atime and mtime must be positive integers")):t.getObject(n.id,a)}function T(t,n,e,r,i,o){n=gn(n),"string"!=typeof e?o(new Un.EINVAL("attribute name must be a string",n)):e?null!==i&&i!==Bn&&i!==Mn?o(new Un.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE",n)):a(t,n,e,r,i,o):o(new Un.EINVAL("attribute name cannot be an empty string",n))}function S(t,n,e,r,i,o){"string"!=typeof e?o(new Un.EINVAL("attribute name must be a string")):e?null!==i&&i!==Bn&&i!==Mn?o(new Un.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE")):a(t,n,e,r,i,o):o(new Un.EINVAL("attribute name cannot be an empty string"))}function x(t,n,e,r){function i(t,i){i?i.xattrs[e]:null,t?r(t):i.xattrs.hasOwnProperty(e)?r(null,i.xattrs[e]):r(new Un.ENOATTR(null,n))}n=gn(n),"string"!=typeof e?r(new Un.EINVAL("attribute name must be a string",n)):e?o(t,n,i):r(new Un.EINVAL("attribute name cannot be an empty string",n))}function N(t,n,e,r){function i(t,n){n?n.xattrs[e]:null,t?r(t):n.xattrs.hasOwnProperty(e)?r(null,n.xattrs[e]):r(new Un.ENOATTR)}"string"!=typeof e?r(new Un.EINVAL):e?t.getObject(n.id,i):r(new Un.EINVAL("attribute name cannot be an empty string"))}function D(t,n,e,i){function a(o,a){function u(e){e?i(e):r(t,n,a,{ctime:Date.now()},i)}var s=a?a.xattrs:null;o?i(o):s.hasOwnProperty(e)?(delete a.xattrs[e],t.putObject(a.id,a,u)):i(new Un.ENOATTR(null,n))}n=gn(n),"string"!=typeof e?i(new Un.EINVAL("attribute name must be a string",n)):e?o(t,n,a):i(new Un.EINVAL("attribute name cannot be an empty string",n))}function R(t,n,e,i){function o(o,a){function u(e){e?i(e):r(t,n.path,a,{ctime:Date.now()},i)}o?i(o):a.xattrs.hasOwnProperty(e)?(delete a.xattrs[e],t.putObject(a.id,a,u)):i(new Un.ENOATTR)}"string"!=typeof e?i(new Un.EINVAL("attribute name must be a string")):e?t.getObject(n.id,o):i(new Un.EINVAL("attribute name cannot be an empty string"))}function _(t){return pn(Ln).has(t)?Ln[t]:null}function L(t,n,e){return t?"function"==typeof t?t={encoding:n,flag:e}:"string"==typeof t&&(t={encoding:t,flag:e}):t={encoding:n,flag:e},t}function B(t,n){var e;return t?En(t)?e=new Un.EINVAL("Path must be a string without null bytes.",t):yn(t)||(e=new Un.EINVAL("Path must be absolute.",t)):e=new Un.EINVAL("Path must be a string",t),e?(n(e),!1):!0}function M(t,n,e,r,i,o){function a(n,i){if(n)o(n);else{var a;a=pn(r).contains(_n)?i.size:0;var u=new Vn(e,i.id,r,a),s=t.allocDescriptor(u);o(null,s)}}o=arguments[arguments.length-1],B(e,o)&&(r=_(r),r||o(new Un.EINVAL("flags is not valid"),e),f(n,e,r,a))}function k(t,n,e,r){pn(t.openFiles).has(e)?(t.releaseDescriptor(e),r(null)):r(new Un.EBADF)}function C(t,n,e,r,o){B(e,o)&&i(n,e,r,o)}function F(t,n,r,i,o){o=arguments[arguments.length-1],B(r,o)&&s(n,r,e(o))}function U(t,n,r,i){B(r,i)&&c(n,r,e(i))}function P(t,n,e,r){function i(n,e){if(n)r(n);else{var i=new zn(e,t.name);r(null,i)}}B(e,r)&&h(n,e,i)}function V(t,n,e,r){function i(n,e){if(n)r(n);else{var i=new zn(e,t.name);r(null,i)}}var o=t.openFiles[e];o?g(n,o,i):r(new Un.EBADF)}function Y(t,n,r,i,o){B(r,o)&&B(i,o)&&m(n,r,i,e(o))}function q(t,n,r,i){B(r,i)&&y(n,r,e(i))}function z(t,n,r,i,o,a,u,s){function c(t,n){s(t,n||0,i)}o=void 0===o?0:o,a=void 0===a?i.length-o:a,s=arguments[arguments.length-1];var f=t.openFiles[r];f?pn(f.flags).contains(xn)?p(n,f,i,o,a,u,e(c)):s(new Un.EBADF("descriptor does not permit reading")):s(new Un.EBADF)}function X(t,n,e,r,i){if(i=arguments[arguments.length-1],r=L(r,null,"r"),B(e,i)){var o=_(r.flag||"r");return o?(f(n,e,o,function(a,u){function s(){t.releaseDescriptor(f)}if(a)return i(a);var c=new Vn(e,u.id,o,0),f=t.allocDescriptor(c);g(n,c,function(o,a){if(o)return s(),i(o);var u=new zn(a,t.name);if(u.isDirectory())return s(),i(new Un.EISDIR("illegal operation on directory",e));var f=u.size,l=new Xn(f);l.fill(0),p(n,c,l,0,f,0,function(t){if(s(),t)return i(t);var n;n="utf8"===r.encoding?Fn.decode(l):l,i(null,n)})})}),void 0):i(new Un.EINVAL("flags is not valid",e))}}function W(t,n,r,i,o,a,u,s){s=arguments[arguments.length-1],o=void 0===o?0:o,a=void 0===a?i.length-o:a;var c=t.openFiles[r];c?pn(c.flags).contains(Nn)?a>i.length-o?s(new Un.EIO("intput buffer is too small")):d(n,c,i,o,a,u,e(s)):s(new Un.EBADF("descriptor does not permit writing")):s(new Un.EBADF)}function J(t,n,e,r,i,o){if(o=arguments[arguments.length-1],i=L(i,"utf8","w"),B(e,o)){var a=_(i.flag||"w");if(!a)return o(new Un.EINVAL("flags is not valid",e));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Fn.encode(r)),f(n,e,a,function(i,u){if(i)return o(i);var s=new Vn(e,u.id,a,0),c=t.allocDescriptor(s);l(n,s,r,0,r.length,function(n){return t.releaseDescriptor(c),n?o(n):(o(null),void 0)})})}}function H(t,n,e,r,i,o){if(o=arguments[arguments.length-1],i=L(i,"utf8","a"),B(e,o)){var a=_(i.flag||"a");if(!a)return o(new Un.EINVAL("flags is not valid",e));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Fn.encode(r)),f(n,e,a,function(i,u){if(i)return o(i);var s=new Vn(e,u.id,a,u.size),c=t.allocDescriptor(s);d(n,s,r,0,r.length,s.position,function(n){return t.releaseDescriptor(c),n?o(n):(o(null),void 0)})})}}function G(t,n,e,r){function i(t){r(t?!1:!0)}P(t,n,e,i)}function Q(t,n,r,i,o){B(r,o)&&x(n,r,i,e(o))}function K(t,n,r,i,o){var a=t.openFiles[r];a?N(n,a,i,e(o)):o(new Un.EBADF)}function Z(t,n,r,i,o,a,u){"function"==typeof a&&(u=a,a=null),B(r,u)&&T(n,r,i,o,a,e(u))}function $(t,n,r,i,o,a,u){"function"==typeof a&&(u=a,a=null);var s=t.openFiles[r];s?pn(s.flags).contains(Nn)?S(n,s,i,o,a,e(u)):u(new Un.EBADF("descriptor does not permit writing")):u(new Un.EBADF)}function tn(t,n,r,i,o){B(r,o)&&D(n,r,i,e(o))}function nn(t,n,r,i,o){var a=t.openFiles[r];a?pn(a.flags).contains(Nn)?R(n,a,i,e(o)):o(new Un.EBADF("descriptor does not permit writing")):o(new Un.EBADF)}function en(t,n,e,r,i,o){function a(t,n){t?o(t):0>n.size+r?o(new Un.EINVAL("resulting file offset would be negative")):(u.position=n.size+r,o(null,u.position))}var u=t.openFiles[e];u||o(new Un.EBADF),"SET"===i?0>r?o(new Un.EINVAL("resulting file offset would be negative")):(u.position=r,o(null,u.position)):"CUR"===i?0>u.position+r?o(new Un.EINVAL("resulting file offset would be negative")):(u.position+=r,o(null,u.position)):"END"===i?g(n,u,a):o(new Un.EINVAL("whence argument is not a proper value"))}function rn(t,n,r,i){B(r,i)&&E(n,r,e(i))}function on(t,n,r,i,o,a){if(B(r,a)){var u=Date.now();i=i?i:u,o=o?o:u,A(n,r,i,o,e(a))}}function an(t,n,r,i,o,a){var u=Date.now();i=i?i:u,o=o?o:u;var s=t.openFiles[r];s?pn(s.flags).contains(Nn)?j(n,s,i,o,e(a)):a(new Un.EBADF("descriptor does not permit writing")):a(new Un.EBADF)}function un(t,n,r,i,o){function a(t){t?o(t):y(n,r,e(o))}B(r,o)&&B(i,o)&&m(n,r,i,a)}function sn(t,n,r,i,o,a){a=arguments[arguments.length-1],B(r,a)&&B(i,a)&&b(n,r,i,e(a))}function cn(t,n,r,i){B(r,i)&&w(n,r,e(i))}function fn(t,n,e,r){function i(n,e){if(n)r(n);else{var i=new zn(e,t.name);r(null,i)}}B(e,r)&&v(n,e,i)}function ln(t,n,r,i,o){o=arguments[arguments.length-1],i=i||0,B(r,o)&&I(n,r,i,e(o))}function dn(t,n,r,i,o){o=arguments[arguments.length-1],i=i||0;var a=t.openFiles[r];a?pn(a.flags).contains(Nn)?O(n,a,i,e(o)):o(new Un.EBADF("descriptor does not permit writing")):o(new Un.EBADF)}var pn=t("../../lib/nodash.js"),hn=t("../path.js"),gn=hn.normalize,vn=hn.dirname,mn=hn.basename,yn=hn.isAbsolute,En=hn.isNull,bn=t("../constants.js"),wn=bn.MODE_FILE,In=bn.MODE_DIRECTORY,On=bn.MODE_SYMBOLIC_LINK,An=bn.MODE_META,jn=bn.ROOT_DIRECTORY_NAME,Tn=bn.SUPER_NODE_ID,Sn=bn.SYMLOOP_MAX,xn=bn.O_READ,Nn=bn.O_WRITE,Dn=bn.O_CREATE,Rn=bn.O_EXCLUSIVE;bn.O_TRUNCATE;var _n=bn.O_APPEND,Ln=bn.O_FLAGS,Bn=bn.XATTR_CREATE,Mn=bn.XATTR_REPLACE,kn=bn.FS_NOMTIME,Cn=bn.FS_NOCTIME,Fn=t("../encoding.js"),Un=t("../errors.js"),Pn=t("../directory-entry.js"),Vn=t("../open-file-description.js"),Yn=t("../super-node.js"),qn=t("../node.js"),zn=t("../stats.js"),Xn=t("../buffer.js");n.exports={ensureRootDirectory:u,open:M,close:k,mknod:C,mkdir:F,rmdir:U,unlink:q,stat:P,fstat:V,link:Y,read:z,readFile:X,write:W,writeFile:J,appendFile:H,exists:G,getxattr:Q,fgetxattr:K,setxattr:Z,fsetxattr:$,removexattr:tn,fremovexattr:nn,lseek:en,readdir:rn,utimes:on,futimes:an,rename:un,symlink:sn,readlink:cn,lstat:fn,truncate:ln,ftruncate:dn}},{"../../lib/nodash.js":4,"../buffer.js":11,"../constants.js":12,"../directory-entry.js":13,"../encoding.js":14,"../errors.js":15,"../node.js":20,"../open-file-description.js":21,"../path.js":22,"../stats.js":31,"../super-node.js":32}],17:[function(t,n){function e(t){return"function"==typeof t?t:function(t){if(t)throw t}}function r(t,n){function e(){_.forEach(function(t){t.call(this)}.bind(N)),_=null}function r(t){return function(n){function e(n){var r=j();t.getObject(r,function(t,i){return t?(n(t),void 0):(i?e(n):n(null,r),void 0)})}return i(g).contains(p)?(n(null,j()),void 0):(e(n),void 0)}}function u(t){if(t.length){var n=v.getInstance();t.forEach(function(t){n.emit(t.event,t.path)})}}t=t||{},n=n||a;var g=t.flags,j=t.guid?t.guid:E,T=t.provider||new h.Default(t.name||s),S=t.name||T.name,x=i(g).contains(c),N=this;N.readyState=l,N.name=S,N.error=null,N.stdin=b,N.stdout=w,N.stderr=I;var D={},R=O;Object.defineProperty(this,"openFiles",{get:function(){return D}}),this.allocDescriptor=function(t){var n=R++;return D[n]=t,n},this.releaseDescriptor=function(t){delete D[t]};var _=[];this.queueOrRun=function(t){var n;return f==N.readyState?t.call(N):d==N.readyState?n=new y.EFILESYSTEMERROR("unknown error"):_.push(t),n},this.watch=function(t,n,e){if(o(t))throw Error("Path must be a string without null bytes."); -"function"==typeof n&&(e=n,n={}),n=n||{},e=e||a;var r=new m;return r.start(t,!1,n.recursive),r.on("change",e),r},T.open(function(t){function i(t){function i(t){var n=T[t]();return n.flags=g,n.changes=[],n.guid=r(n),n.close=function(){var t=n.changes;u(t),t.length=0},n}N.provider={openReadWriteContext:function(){return i("getReadWriteContext")},openReadOnlyContext:function(){return i("getReadOnlyContext")}},N.readyState=t?d:f,e(),n(t,N)}if(t)return i(t);var o=T.getReadWriteContext();o.guid=r(o),x?o.clear(function(t){return t?i(t):(A.ensureRootDirectory(o,i),void 0)}):A.ensureRootDirectory(o,i)})}var i=t("../../lib/nodash.js"),o=t("../path.js").isNull,a=t("../shared.js").nop,u=t("../constants.js"),s=u.FILE_SYSTEM_NAME,c=u.FS_FORMAT,f=u.FS_READY,l=u.FS_PENDING,d=u.FS_ERROR,p=u.FS_NODUPEIDCHECK,h=t("../providers/index.js"),g=t("../shell/shell.js"),v=t("../../lib/intercom.js"),m=t("../fs-watcher.js"),y=t("../errors.js"),E=t("../shared.js").guid,b=u.STDIN,w=u.STDOUT,I=u.STDERR,O=u.FIRST_DESCRIPTOR,A=t("./implementation.js");r.providers=h,["open","close","mknod","mkdir","rmdir","stat","fstat","link","unlink","read","readFile","write","writeFile","appendFile","exists","lseek","readdir","rename","readlink","symlink","lstat","truncate","ftruncate","utimes","futimes","setxattr","getxattr","fsetxattr","fgetxattr","removexattr","fremovexattr"].forEach(function(t){r.prototype[t]=function(){var n=this,r=Array.prototype.slice.call(arguments,0),i=r.length-1,o="function"!=typeof r[i],a=e(r[i]),u=n.queueOrRun(function(){function e(){u.close(),a.apply(n,arguments)}var u=n.provider.openReadWriteContext();if(d===n.readyState){var s=new y.EFILESYSTEMERROR("filesystem unavailable, operation canceled");return a.call(n,s)}o?r.push(e):r[i]=e;var c=[n,u].concat(r);A[t].apply(null,c)});u&&a(u)}}),r.prototype.Shell=function(t){return new g(this,t)},n.exports=r},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":12,"../errors.js":15,"../fs-watcher.js":18,"../path.js":22,"../providers/index.js":23,"../shared.js":27,"../shell/shell.js":30,"./implementation.js":16}],18:[function(t,n){function e(){function t(t){(e===t||u&&0===t.indexOf(n))&&a.trigger("change","change",t)}r.call(this);var n,e,a=this,u=!1;a.start=function(r,a,s){if(!e){if(i.isNull(r))throw Error("Path must be a string without null bytes.");e=i.normalize(r),u=s===!0,u&&(n="/"===e?"/":e+"/");var c=o.getInstance();c.on("change",t)}},a.close=function(){var n=o.getInstance();n.off("change",t),a.removeAllListeners("change")}}var r=t("../lib/eventemitter.js"),i=t("./path.js"),o=t("../lib/intercom.js");e.prototype=new r,e.prototype.constructor=e,n.exports=e},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":22}],19:[function(t,n){n.exports={FileSystem:t("./filesystem/interface.js"),Buffer:t("./buffer.js"),Path:t("./path.js"),Errors:t("./errors.js")}},{"./buffer.js":11,"./errors.js":15,"./filesystem/interface.js":17,"./path.js":22}],20:[function(t,n){function e(t){var n=Date.now();this.id=t.id,this.mode=t.mode||i,this.size=t.size||0,this.atime=t.atime||n,this.ctime=t.ctime||n,this.mtime=t.mtime||n,this.flags=t.flags||[],this.xattrs=t.xattrs||{},this.nlinks=t.nlinks||0,this.version=t.version||0,this.blksize=void 0,this.nblocks=1,this.data=t.data}function r(t,n,e){t[n]?e(null):t.guid(function(r,i){t[n]=i,e(r)})}var i=t("./constants.js").MODE_FILE;e.create=function(t,n){r(t,"id",function(i){return i?(n(i),void 0):(r(t,"data",function(r){return r?(n(r),void 0):(n(null,new e(t)),void 0)}),void 0)})},n.exports=e},{"./constants.js":12}],21:[function(t,n){n.exports=function(t,n,e,r){this.path=t,this.id=n,this.flags=e,this.position=r}},{}],22:[function(t,n,e){function r(t,n){for(var e=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),e++):e&&(t.splice(r,1),e--)}if(n)for(;e--;e)t.unshift("..");return t}function i(){for(var t="",n=!1,e=arguments.length-1;e>=-1&&!n;e--){var i=e>=0?arguments[e]:"/";"string"==typeof i&&i&&(t=i+"/"+t,n="/"===i.charAt(0))}return t=r(t.split("/").filter(function(t){return!!t}),!n).join("/"),(n?"/":"")+t||"."}function o(t){var n="/"===t.charAt(0);return"/"===t.substr(-1),t=r(t.split("/").filter(function(t){return!!t}),!n).join("/"),t||n||(t="."),(n?"/":"")+t}function a(){var t=Array.prototype.slice.call(arguments,0);return o(t.filter(function(t){return t&&"string"==typeof t}).join("/"))}function u(t,n){function r(t){for(var n=0;t.length>n&&""===t[n];n++);for(var e=t.length-1;e>=0&&""===t[e];e--);return n>e?[]:t.slice(n,e-n+1)}t=e.resolve(t).substr(1),n=e.resolve(n).substr(1);for(var i=r(t.split("/")),o=r(n.split("/")),a=Math.min(i.length,o.length),u=a,s=0;a>s;s++)if(i[s]!==o[s]){u=s;break}for(var c=[],s=u;i.length>s;s++)c.push("..");return c=c.concat(o.slice(u)),c.join("/")}function s(t){var n=h(t),e=n[0],r=n[1];return e||r?(r&&(r=r.substr(0,r.length-1)),e+r):"."}function c(t,n){var e=h(t)[2];return n&&e.substr(-1*n.length)===n&&(e=e.substr(0,e.length-n.length)),""===e?"/":e}function f(t){return h(t)[3]}function l(t){return"/"===t.charAt(0)?!0:!1}function d(t){return-1!==(""+t).indexOf("\0")?!0:!1}var p=/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/,h=function(t){var n=p.exec(t);return[n[1]||"",n[2]||"",n[3]||"",n[4]||""]};n.exports={normalize:o,resolve:i,join:a,relative:u,sep:"/",delimiter:":",dirname:s,basename:c,extname:f,isAbsolute:l,isNull:d}},{}],23:[function(t,n){var e=t("./indexeddb.js"),r=t("./websql.js"),i=t("./memory.js");n.exports={IndexedDB:e,WebSQL:r,Memory:i,Default:e,Fallback:function(){function t(){throw"[Filer Error] Your browser doesn't support IndexedDB or WebSQL."}return e.isSupported()?e:r.isSupported()?r:(t.isSupported=function(){return!1},t)}()}},{"./indexeddb.js":24,"./memory.js":25,"./websql.js":26}],24:[function(t,n){(function(e){function r(t,n){var e=t.transaction(s,n);this.objectStore=e.objectStore(s)}function i(t,n,e){try{var r=t.get(n);r.onsuccess=function(t){var n=t.target.result;e(null,n)},r.onerror=function(t){e(t)}}catch(i){e(i)}}function o(t,n,e,r){try{var i=t.put(e,n);i.onsuccess=function(t){var n=t.target.result;r(null,n)},i.onerror=function(t){r(t)}}catch(o){r(o)}}function a(t){this.name=t||u,this.db=null}var u=t("../constants.js").FILE_SYSTEM_NAME,s=t("../constants.js").FILE_STORE_NAME,c=t("../constants.js").IDB_RW;t("../constants.js").IDB_RO;var f=t("../errors.js"),l=t("../buffer.js"),d=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB;r.prototype.clear=function(t){try{var n=this.objectStore.clear();n.onsuccess=function(){t()},n.onerror=function(n){t(n)}}catch(e){t(e)}},r.prototype.getObject=function(t,n){i(this.objectStore,t,n)},r.prototype.getBuffer=function(t,n){i(this.objectStore,t,function(t,e){return t?n(t):(n(null,new l(e)),void 0)})},r.prototype.putObject=function(t,n,e){o(this.objectStore,t,n,e)},r.prototype.putBuffer=function(t,n,e){o(this.objectStore,t,n.buffer,e)},r.prototype.delete=function(t,n){try{var e=this.objectStore.delete(t);e.onsuccess=function(t){var e=t.target.result;n(null,e)},e.onerror=function(t){n(t)}}catch(r){n(r)}},a.isSupported=function(){return!!d},a.prototype.open=function(t){var n=this;if(n.db)return t();var e=d.open(n.name);e.onupgradeneeded=function(t){var n=t.target.result;n.objectStoreNames.contains(s)&&n.deleteObjectStore(s),n.createObjectStore(s)},e.onsuccess=function(e){n.db=e.target.result,t()},e.onerror=function(){t(new f.EINVAL("IndexedDB cannot be accessed. If private browsing is enabled, disable it."))}},a.prototype.getReadOnlyContext=function(){return new r(this.db,c)},a.prototype.getReadWriteContext=function(){return new r(this.db,c)},n.exports=a}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../buffer.js":11,"../constants.js":12,"../errors.js":15}],25:[function(t,n){function e(t,n){this.readOnly=n,this.objectStore=t}function r(t){this.name=t||i}var i=t("../constants.js").FILE_SYSTEM_NAME,o=t("../../lib/async.js").setImmediate,a=function(){var t={};return function(n){return t.hasOwnProperty(n)||(t[n]={}),t[n]}}();e.prototype.clear=function(t){if(this.readOnly)return o(function(){t("[MemoryContext] Error: write operation on read only context")}),void 0;var n=this.objectStore;Object.keys(n).forEach(function(t){delete n[t]}),o(t)},e.prototype.getObject=e.prototype.getBuffer=function(t,n){var e=this;o(function(){n(null,e.objectStore[t])})},e.prototype.putObject=e.prototype.putBuffer=function(t,n,e){return this.readOnly?(o(function(){e("[MemoryContext] Error: write operation on read only context")}),void 0):(this.objectStore[t]=n,o(e),void 0)},e.prototype.delete=function(t,n){return this.readOnly?(o(function(){n("[MemoryContext] Error: write operation on read only context")}),void 0):(delete this.objectStore[t],o(n),void 0)},r.isSupported=function(){return!0},r.prototype.open=function(t){this.db=a(this.name),o(t)},r.prototype.getReadOnlyContext=function(){return new e(this.db,!0)},r.prototype.getReadWriteContext=function(){return new e(this.db,!1)},n.exports=r},{"../../lib/async.js":1,"../constants.js":12}],26:[function(t,n){(function(e){function r(t,n){var e=this;this.getTransaction=function(r){return e.transaction?(r(e.transaction),void 0):(t[n?"readTransaction":"transaction"](function(t){e.transaction=t,r(t)}),void 0)}}function i(t,n,e){function r(t,n){var r=0===n.rows.length?null:n.rows.item(0).data;e(null,r)}function i(t,n){e(n)}t(function(t){t.executeSql("SELECT data FROM "+s+" WHERE id = ? LIMIT 1;",[n],r,i)})}function o(t,n,e,r){function i(){r(null)}function o(t,n){r(n)}t(function(t){t.executeSql("INSERT OR REPLACE INTO "+s+" (id, data) VALUES (?, ?);",[n,e],i,o)})}function a(t){this.name=t||u,this.db=null}var u=t("../constants.js").FILE_SYSTEM_NAME,s=t("../constants.js").FILE_STORE_NAME,c=t("../constants.js").WSQL_VERSION,f=t("../constants.js").WSQL_SIZE,l=t("../constants.js").WSQL_DESC,d=t("../errors.js"),p=t("../buffer.js"),h=t("base64-arraybuffer");r.prototype.clear=function(t){function n(n,e){t(e)}function e(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+s+";",[],e,n)})},r.prototype.getObject=function(t,n){i(this.getTransaction,t,function(t,e){if(t)return n(t);try{e&&(e=JSON.parse(e))}catch(r){return n(r)}n(null,e)})},r.prototype.getBuffer=function(t,n){i(this.getTransaction,t,function(t,e){if(t)return n(t);if(e||""===e){var r=h.decode(e);e=new p(r)}n(null,e)})},r.prototype.putObject=function(t,n,e){var r=JSON.stringify(n);o(this.getTransaction,t,r,e)},r.prototype.putBuffer=function(t,n,e){var r=h.encode(n.buffer);o(this.getTransaction,t,r,e)},r.prototype.delete=function(t,n){function e(){n(null)}function r(t,e){n(e)}this.getTransaction(function(n){n.executeSql("DELETE FROM "+s+" WHERE id = ?;",[t],e,r)})},a.isSupported=function(){return!!e.openDatabase},a.prototype.open=function(t){function n(n,e){5===e.code&&t(new d.EINVAL("WebSQL cannot be accessed. If private browsing is enabled, disable it.")),t(e)}function r(){i.db=o,t()}var i=this;if(i.db)return t();var o=e.openDatabase(i.name,c,l,f);return o?(o.transaction(function(t){function e(t){t.executeSql("CREATE INDEX IF NOT EXISTS idx_"+s+"_id"+" on "+s+" (id);",[],r,n)}t.executeSql("CREATE TABLE IF NOT EXISTS "+s+" (id unique, data TEXT);",[],e,n)}),void 0):(t("[WebSQL] Unable to open database."),void 0)},a.prototype.getReadOnlyContext=function(){return new r(this.db,!0)},a.prototype.getReadWriteContext=function(){return new r(this.db,!1)},n.exports=a}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../buffer.js":11,"../constants.js":12,"../errors.js":15,"base64-arraybuffer":5}],27:[function(t,n){function e(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=0|16*Math.random(),e="x"==t?n:8|3&n;return e.toString(16)}).toUpperCase()}function r(){}function i(t){for(var n=[],e=t.length,r=0;e>r;r++)n[r]=t[r];return n}n.exports={guid:e,u8toArray:i,nop:r}},{}],28:[function(t,n){var e=t("../constants.js").ENVIRONMENT;n.exports=function(t){t=t||{},t.TMP=t.TMP||e.TMP,t.PATH=t.PATH||e.PATH,this.get=function(n){return t[n]},this.set=function(n,e){t[n]=e}}},{"../constants.js":12}],29:[function(t,n){var e=t("request");n.exports.download=function(t,n){e({url:t,method:"GET",encoding:null},function(t,e,r){var i,o;return e=e||null,i=e&&e.statusCode,(o=200!==i?{message:t||"Not found!",code:i}:null)?(n(o,null),void 0):(n(null,r),void 0)})}},{request:6}],30:[function(t,n){function e(t,n){n=n||{};var e=new o(n.env),a="/";Object.defineProperty(this,"fs",{get:function(){return t},enumerable:!0}),Object.defineProperty(this,"env",{get:function(){return e},enumerable:!0}),this.cd=function(n,e){n=r.resolve(a,n),t.stat(n,function(t,r){return t?(e(new i.ENOTDIR(null,n)),void 0):("DIRECTORY"===r.type?(a=n,e()):e(new i.ENOTDIR(null,n)),void 0)})},this.pwd=function(){return a}}var r=t("../path.js"),i=t("../errors.js"),o=t("./environment.js"),a=t("../../lib/async.js"),u=t("./network.js");t("../encoding.js"),e.prototype.exec=function(t,n,e){var i=this,o=i.fs;"function"==typeof n&&(e=n,n=[]),n=n||[],e=e||function(){},t=r.resolve(i.pwd(),t),o.readFile(t,"utf8",function(t,r){if(t)return e(t),void 0;try{var i=Function("fs","args","callback",r);i(o,n,e)}catch(a){e(a)}})},e.prototype.touch=function(t,n,e){function i(t){u.writeFile(t,"",e)}function o(t){var r=Date.now(),i=n.date||r,o=n.date||r;u.utimes(t,i,o,e)}var a=this,u=a.fs;"function"==typeof n&&(e=n,n={}),n=n||{},e=e||function(){},t=r.resolve(a.pwd(),t),u.stat(t,function(r){r?n.updateOnly===!0?e():i(t):o(t)})},e.prototype.cat=function(t,n){function e(t,n){var e=r.resolve(o.pwd(),t);u.readFile(e,"utf8",function(t,e){return t?(n(t),void 0):(s+=e+"\n",n(),void 0)})}var o=this,u=o.fs,s="";return n=n||function(){},t?(t="string"==typeof t?[t]:t,a.eachSeries(t,e,function(t){t?n(t):n(null,s.replace(/\n$/,""))}),void 0):(n(new i.EINVAL("Missing files argument")),void 0)},e.prototype.ls=function(t,n,e){function o(t,e){var i=r.resolve(u.pwd(),t),c=[];s.readdir(i,function(t,u){function f(t,e){t=r.join(i,t),s.stat(t,function(a,u){if(a)return e(a),void 0;var s={path:r.basename(t),links:u.nlinks,size:u.size,modified:u.mtime,type:u.type};n.recursive&&"DIRECTORY"===u.type?o(r.join(i,s.path),function(t,n){return t?(e(t),void 0):(s.contents=n,c.push(s),e(),void 0)}):(c.push(s),e())})}return t?(e(t),void 0):(a.eachSeries(u,f,function(t){e(t,c)}),void 0)})}var u=this,s=u.fs;return"function"==typeof n&&(e=n,n={}),n=n||{},e=e||function(){},t?(o(t,e),void 0):(e(new i.EINVAL("Missing dir argument")),void 0)},e.prototype.rm=function(t,n,e){function o(t,e){t=r.resolve(u.pwd(),t),s.stat(t,function(u,c){return u?(e(u),void 0):"FILE"===c.type?(s.unlink(t,e),void 0):(s.readdir(t,function(u,c){return u?(e(u),void 0):0===c.length?(s.rmdir(t,e),void 0):n.recursive?(c=c.map(function(n){return r.join(t,n)}),a.eachSeries(c,o,function(n){return n?(e(n),void 0):(s.rmdir(t,e),void 0)}),void 0):(e(new i.ENOTEMPTY(null,t)),void 0)}),void 0)})}var u=this,s=u.fs;return"function"==typeof n&&(e=n,n={}),n=n||{},e=e||function(){},t?(o(t,e),void 0):(e(new i.EINVAL("Missing path argument")),void 0)},e.prototype.tempDir=function(t){var n=this,e=n.fs,r=n.env.get("TMP");t=t||function(){},e.mkdir(r,function(){t(null,r)})},e.prototype.mkdirp=function(t,n){function e(t,n){a.stat(t,function(o,u){if(u){if(u.isDirectory())return n(),void 0;if(u.isFile())return n(new i.ENOTDIR(null,t)),void 0}else{if(o&&"ENOENT"!==o.code)return n(o),void 0;var s=r.dirname(t);"/"===s?a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(n(t),void 0):(n(),void 0)}):e(s,function(e){return e?n(e):(a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(n(t),void 0):(n(),void 0)}),void 0)})}})}var o=this,a=o.fs;return n=n||function(){},t?"/"===t?(n(),void 0):(e(t,n),void 0):(n(new i.EINVAL("Missing path argument")),void 0)},e.prototype.wget=function(t,n,e){function o(){e(Error("unable to get resource"))}var a=this,s=a.fs;if("function"==typeof n&&(e=n,n={}),n=n||{},e=e||function(){},!t)return e(new i.EINVAL("Missing url argument")),void 0;var c=n.filename||t.split("/").pop();c=r.resolve(a.pwd(),c),u.download(t,function(t,n){return t||!n?o():(s.writeFile(c,n,function(t){t?e(t):e(null,c)}),void 0)})},n.exports=e},{"../../lib/async.js":1,"../encoding.js":14,"../errors.js":15,"../path.js":22,"./environment.js":28,"./network.js":29}],31:[function(t,n){function e(t,n){this.node=t.id,this.dev=n,this.size=t.size,this.nlinks=t.nlinks,this.atime=t.atime,this.mtime=t.mtime,this.ctime=t.ctime,this.type=t.mode}var r=t("./constants.js");e.prototype.isFile=function(){return this.type===r.MODE_FILE},e.prototype.isDirectory=function(){return this.type===r.MODE_DIRECTORY},e.prototype.isSymbolicLink=function(){return this.type===r.MODE_SYMBOLIC_LINK},e.prototype.isSocket=e.prototype.isFIFO=e.prototype.isCharacterDevice=e.prototype.isBlockDevice=function(){return!1},n.exports=e},{"./constants.js":12}],32:[function(t,n){function e(t){var n=Date.now();this.id=r.SUPER_NODE_ID,this.mode=r.MODE_META,this.atime=t.atime||n,this.ctime=t.ctime||n,this.mtime=t.mtime||n,this.rnode=t.rnode}var r=t("./constants.js");e.create=function(t,n){t.guid(function(r,i){return r?(n(r),void 0):(t.rnode=t.rnode||i,n(null,new e(t)),void 0)})},n.exports=e},{"./constants.js":12}]},{},[19])(19)}); \ No newline at end of file +/*! filer 0.0.27 2014-09-09 */ +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Filer=t()}}(function(){var t;return function e(t,n,r){function i(a,u){if(!n[a]){if(!t[a]){var s="function"==typeof require&&require;if(!u&&s)return s(a,!0);if(o)return o(a,!0);throw Error("Cannot find module '"+a+"'")}var f=n[a]={exports:{}};t[a][0].call(f.exports,function(e){var n=t[a][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;r.length>a;a++)i(r[a]);return i}({1:[function(e,n){(function(e){(function(){var r={};void 0!==e&&e.nextTick?(r.nextTick=e.nextTick,r.setImmediate="undefined"!=typeof setImmediate?function(t){setImmediate(t)}:r.nextTick):"function"==typeof setImmediate?(r.nextTick=function(t){setImmediate(t)},r.setImmediate=r.nextTick):(r.nextTick=function(t){setTimeout(t,0)},r.setImmediate=r.nextTick),r.eachSeries=function(t,e,n){if(n=n||function(){},!t.length)return n();var r=0,i=function(){e(t[r],function(e){e?(n(e),n=function(){}):(r+=1,r>=t.length?n():i())})};i()},r.forEachSeries=r.eachSeries,t!==void 0&&t.amd?t([],function(){return r}):n!==void 0&&n.exports?n.exports=r:root.async=r})()}).call(this,e("JkpR2F"))},{JkpR2F:9}],2:[function(t,e){function n(t,e){for(var n=e.length-1;n>=0;n--)e[n]===t&&e.splice(n,1);return e}var r=function(){};r.createInterface=function(t){var e={};return e.on=function(e,n){this[t]===void 0&&(this[t]={}),this[t].hasOwnProperty(e)||(this[t][e]=[]),this[t][e].push(n)},e.off=function(e,r){void 0!==this[t]&&this[t].hasOwnProperty(e)&&n(r,this[t][e])},e.trigger=function(e){if(this[t]!==void 0&&this[t].hasOwnProperty(e))for(var n=Array.prototype.slice.call(arguments,1),r=0;this[t][e].length>r;r++)this[t][e][r].apply(this[t][e][r],n)},e.removeAllListeners=function(e){if(void 0!==this[t]){var n=this;n[t][e].forEach(function(t){n.off(e,t)})}},e};var i=r.createInterface("_handlers");r.prototype._on=i.on,r.prototype._off=i.off,r.prototype._trigger=i.trigger;var o=r.createInterface("handlers");r.prototype.on=function(){o.on.apply(this,arguments),Array.prototype.unshift.call(arguments,"on"),this._trigger.apply(this,arguments)},r.prototype.off=o.off,r.prototype.trigger=o.trigger,r.prototype.removeAllListeners=o.removeAllListeners,e.exports=r},{}],3:[function(t,e){(function(n){function r(t,e){var n=0;return function(){var r=Date.now();r-n>t&&(n=r,e.apply(this,arguments))}}function i(t,e){if(void 0!==t&&t||(t={}),"object"==typeof e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}function o(){var t=this,e=Date.now();this.origin=u(),this.lastMessage=e,this.receivedIDs={},this.previousValues={};var r=function(){t._onStorageEvent.apply(t,arguments)};"undefined"!=typeof document&&(document.attachEvent?document.attachEvent("onstorage",r):n.addEventListener("storage",r,!1))}var a=t("./eventemitter.js"),u=t("../src/shared.js").guid,s=function(t){return t===void 0||t.localStorage===void 0?{getItem:function(){},setItem:function(){},removeItem:function(){}}:t.localStorage}(n);o.prototype._transaction=function(t){function e(){if(!a){var c=Date.now(),d=0|s.getItem(l);if(d&&r>c-d)return u||(o._on("storage",e),u=!0),f=setTimeout(e,i),void 0;a=!0,s.setItem(l,c),t(),n()}}function n(){u&&o._off("storage",e),f&&clearTimeout(f),s.removeItem(l)}var r=1e3,i=20,o=this,a=!1,u=!1,f=null;e()},o.prototype._cleanup_emit=r(100,function(){var t=this;t._transaction(function(){var t,e=Date.now(),n=e-d,r=0;try{t=JSON.parse(s.getItem(f)||"[]")}catch(i){t=[]}for(var o=t.length-1;o>=0;o--)n>t[o].timestamp&&(t.splice(o,1),r++);r>0&&s.setItem(f,JSON.stringify(t))})}),o.prototype._cleanup_once=r(100,function(){var t=this;t._transaction(function(){var e,n;Date.now();var r=0;try{n=JSON.parse(s.getItem(c)||"{}")}catch(i){n={}}for(e in n)t._once_expired(e,n)&&(delete n[e],r++);r>0&&s.setItem(c,JSON.stringify(n))})}),o.prototype._once_expired=function(t,e){if(!e)return!0;if(!e.hasOwnProperty(t))return!0;if("object"!=typeof e[t])return!0;var n=e[t].ttl||p,r=Date.now(),i=e[t].timestamp;return r-n>i},o.prototype._localStorageChanged=function(t,e){if(t&&t.key)return t.key===e;var n=s.getItem(e);return n===this.previousValues[e]?!1:(this.previousValues[e]=n,!0)},o.prototype._onStorageEvent=function(t){t=t||n.event;var e=this;this._localStorageChanged(t,f)&&this._transaction(function(){var t,n=Date.now(),r=s.getItem(f);try{t=JSON.parse(r||"[]")}catch(i){t=[]}for(var o=0;t.length>o;o++)if(t[o].origin!==e.origin&&!(t[o].timestampr;r++)if(e.call(n,t[r],r,t)===m)return}else{var o=o(t);for(r=0,i=o.length;i>r;r++)if(e.call(n,t[o[r]],o[r],t)===m)return}}function a(t,e,n){e||(e=i);var r=!1;return null==t?r:p&&t.some===p?t.some(e,n):(o(t,function(t,i,o){return r||(r=e.call(n,t,i,o))?m:void 0}),!!r)}function u(t,e){return null==t?!1:d&&t.indexOf===d?-1!=t.indexOf(e):a(t,function(t){return t===e})}function s(t){this.value=t}function f(t){return t&&"object"==typeof t&&!Array.isArray(t)&&g.call(t,"__wrapped__")?t:new s(t)}var c=Array.prototype,l=c.forEach,d=c.indexOf,p=c.some,h=Object.prototype,g=h.hasOwnProperty,v=Object.keys,m={},E=v||function(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var r in t)n(t,r)&&e.push(r);return e};s.prototype.has=function(t){return n(this.value,t)},s.prototype.contains=function(t){return u(this.value,t)},s.prototype.size=function(){return r(this.value)},e.exports=f},{}],5:[function(t,e,n){(function(t){"use strict";n.encode=function(e){var n,r=new Uint8Array(e),i=r.length,o="";for(n=0;i>n;n+=3)o+=t[r[n]>>2],o+=t[(3&r[n])<<4|r[n+1]>>4],o+=t[(15&r[n+1])<<2|r[n+2]>>6],o+=t[63&r[n+2]];return 2===i%3?o=o.substring(0,o.length-1)+"=":1===i%3&&(o=o.substring(0,o.length-2)+"=="),o},n.decode=function(e){var n,r,i,o,a,u=.75*e.length,s=e.length,f=0;"="===e[e.length-1]&&(u--,"="===e[e.length-2]&&u--);var c=new ArrayBuffer(u),l=new Uint8Array(c);for(n=0;s>n;n+=4)r=t.indexOf(e[n]),i=t.indexOf(e[n+1]),o=t.indexOf(e[n+2]),a=t.indexOf(e[n+3]),l[f++]=r<<2|i>>4,l[f++]=(15&i)<<4|o>>2,l[f++]=(3&o)<<6|63&a;return c}})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},{}],6:[function(t,e,n){function r(t,e,n){if(!(this instanceof r))return new r(t,e,n);var i=typeof t;"base64"===e&&"string"===i&&(t=x(t));var o;if("number"===i)o=_(t);else if("string"===i)o=r.byteLength(t,e);else{if("object"!==i)throw Error("First argument needs to be a number, array or string.");o=_(t.length)}var a;r._useTypedArrays?a=r._augment(new Uint8Array(o)):(a=this,a.length=o,a._isBuffer=!0);var u;if(r._useTypedArrays&&"number"==typeof t.byteLength)a._set(t);else if(L(t))if(r.isBuffer(t))for(u=0;o>u;u++)a[u]=t.readUInt8(u);else for(u=0;o>u;u++)a[u]=(t[u]%256+256)%256;else if("string"===i)a.write(t,0,e);else if("number"===i&&!r._useTypedArrays&&!n)for(u=0;o>u;u++)a[u]=0;return a}function i(t,e,n,r){n=Number(n)||0;var i=t.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=e.length;W(0===o%2,"Invalid hex string"),r>o/2&&(r=o/2);for(var a=0;r>a;a++){var u=parseInt(e.substr(2*a,2),16);W(!isNaN(u),"Invalid hex string"),t[n+a]=u}return a}function o(t,e,n,r){var i=U(M(e),t,n,r);return i}function a(t,e,n,r){var i=U(F(e),t,n,r);return i}function u(t,e,n,r){return a(t,e,n,r)}function s(t,e,n,r){var i=U(k(e),t,n,r);return i}function f(t,e,n,r){var i=U(C(e),t,n,r);return i}function c(t,e,n){return 0===e&&n===t.length?z.fromByteArray(t):z.fromByteArray(t.slice(e,n))}function l(t,e,n){var r="",i="";n=Math.min(t.length,n);for(var o=e;n>o;o++)127>=t[o]?(r+=P(i)+String.fromCharCode(t[o]),i=""):i+="%"+t[o].toString(16);return r+P(i)}function d(t,e,n){var r="";n=Math.min(t.length,n);for(var i=e;n>i;i++)r+=String.fromCharCode(t[i]);return r}function p(t,e,n){return d(t,e,n)}function h(t,e,n){var r=t.length;(!e||0>e)&&(e=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=e;n>o;o++)i+=B(t[o]);return i}function g(t,e,n){for(var r=t.slice(e,n),i="",o=0;r.length>o;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function v(t,e,n,r){r||(W("boolean"==typeof n,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(t.length>e+1,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o;return n?(o=t[e],i>e+1&&(o|=t[e+1]<<8)):(o=t[e]<<8,i>e+1&&(o|=t[e+1])),o}}function m(t,e,n,r){r||(W("boolean"==typeof n,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(t.length>e+3,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o;return n?(i>e+2&&(o=t[e+2]<<16),i>e+1&&(o|=t[e+1]<<8),o|=t[e],i>e+3&&(o+=t[e+3]<<24>>>0)):(i>e+1&&(o=t[e+1]<<16),i>e+2&&(o|=t[e+2]<<8),i>e+3&&(o|=t[e+3]),o+=t[e]<<24>>>0),o}}function E(t,e,n,r){r||(W("boolean"==typeof n,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(t.length>e+1,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o=v(t,e,n,!0),a=32768&o;return a?-1*(65535-o+1):o}}function y(t,e,n,r){r||(W("boolean"==typeof n,"missing or invalid endian"),W(void 0!==e&&null!==e,"missing offset"),W(t.length>e+3,"Trying to read beyond buffer length"));var i=t.length;if(!(e>=i)){var o=m(t,e,n,!0),a=2147483648&o;return a?-1*(4294967295-o+1):o}}function w(t,e,n,r){return r||(W("boolean"==typeof n,"missing or invalid endian"),W(t.length>e+3,"Trying to read beyond buffer length")),q.read(t,e,n,23,4)}function b(t,e,n,r){return r||(W("boolean"==typeof n,"missing or invalid endian"),W(t.length>e+7,"Trying to read beyond buffer length")),q.read(t,e,n,52,8)}function I(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+1,"trying to write beyond buffer length"),V(e,65535));var o=t.length;if(!(n>=o)){for(var a=0,u=Math.min(o-n,2);u>a;a++)t[n+a]=(e&255<<8*(r?a:1-a))>>>8*(r?a:1-a);return n+2}}function O(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+3,"trying to write beyond buffer length"),V(e,4294967295));var o=t.length;if(!(n>=o)){for(var a=0,u=Math.min(o-n,4);u>a;a++)t[n+a]=255&e>>>8*(r?a:3-a);return n+4}}function j(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+1,"Trying to write beyond buffer length"),Y(e,32767,-32768));var o=t.length;if(!(n>=o))return e>=0?I(t,e,n,r,i):I(t,65535+e+1,n,r,i),n+2}function T(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+3,"Trying to write beyond buffer length"),Y(e,2147483647,-2147483648));var o=t.length;if(!(n>=o))return e>=0?O(t,e,n,r,i):O(t,4294967295+e+1,n,r,i),n+4}function A(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+3,"Trying to write beyond buffer length"),X(e,3.4028234663852886e38,-3.4028234663852886e38));var o=t.length;if(!(n>=o))return q.write(t,e,n,r,23,4),n+4}function S(t,e,n,r,i){i||(W(void 0!==e&&null!==e,"missing value"),W("boolean"==typeof r,"missing or invalid endian"),W(void 0!==n&&null!==n,"missing offset"),W(t.length>n+7,"Trying to write beyond buffer length"),X(e,1.7976931348623157e308,-1.7976931348623157e308));var o=t.length;if(!(n>=o))return q.write(t,e,n,r,52,8),n+8}function x(t){for(t=N(t).replace(Q,"");0!==t.length%4;)t+="=";return t}function N(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function D(t,e,n){return"number"!=typeof t?n:(t=~~t,t>=e?e:t>=0?t:(t+=e,t>=0?t:0))}function _(t){return t=~~Math.ceil(+t),0>t?0:t}function R(t){return(Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)})(t)}function L(t){return R(t)||r.isBuffer(t)||t&&"object"==typeof t&&"number"==typeof t.length}function B(t){return 16>t?"0"+t.toString(16):t.toString(16)}function M(t){for(var e=[],n=0;t.length>n;n++){var r=t.charCodeAt(n);if(127>=r)e.push(r);else{var i=n;r>=55296&&57343>=r&&n++;for(var o=encodeURIComponent(t.slice(i,n+1)).substr(1).split("%"),a=0;o.length>a;a++)e.push(parseInt(o[a],16))}}return e}function F(t){for(var e=[],n=0;t.length>n;n++)e.push(255&t.charCodeAt(n));return e}function C(t){for(var e,n,r,i=[],o=0;t.length>o;o++)e=t.charCodeAt(o),n=e>>8,r=e%256,i.push(r),i.push(n);return i}function k(t){return z.toByteArray(t)}function U(t,e,n,r){for(var i=0;r>i&&!(i+n>=e.length||i>=t.length);i++)e[i+n]=t[i];return i}function P(t){try{return decodeURIComponent(t)}catch(e){return String.fromCharCode(65533)}}function V(t,e){W("number"==typeof t,"cannot write a non-number as a number"),W(t>=0,"specified a negative value for writing an unsigned value"),W(e>=t,"value is larger than maximum value for type"),W(Math.floor(t)===t,"value has a fractional component")}function Y(t,e,n){W("number"==typeof t,"cannot write a non-number as a number"),W(e>=t,"value larger than maximum allowed value"),W(t>=n,"value smaller than minimum allowed value"),W(Math.floor(t)===t,"value has a fractional component")}function X(t,e,n){W("number"==typeof t,"cannot write a non-number as a number"),W(e>=t,"value larger than maximum allowed value"),W(t>=n,"value smaller than minimum allowed value")}function W(t,e){if(!t)throw Error(e||"Failed assertion")}var z=t("base64-js"),q=t("ieee754");n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){try{var t=new ArrayBuffer(0),e=new Uint8Array(t);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray}catch(n){return!1}}(),r.isEncoding=function(t){switch((t+"").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}},r.isBuffer=function(t){return!(null===t||void 0===t||!t._isBuffer)},r.byteLength=function(t,e){var n;switch(t=""+t,e||"utf8"){case"hex":n=t.length/2;break;case"utf8":case"utf-8":n=M(t).length;break;case"ascii":case"binary":case"raw":n=t.length;break;case"base64":n=k(t).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*t.length;break;default:throw Error("Unknown encoding")}return n},r.concat=function(t,e){if(W(R(t),"Usage: Buffer.concat(list[, length])"),0===t.length)return new r(0);if(1===t.length)return t[0];var n;if(void 0===e)for(e=0,n=0;t.length>n;n++)e+=t[n].length;var i=new r(e),o=0;for(n=0;t.length>n;n++){var a=t[n];a.copy(i,o),o+=a.length}return i},r.compare=function(t,e){W(r.isBuffer(t)&&r.isBuffer(e),"Arguments must be Buffers");for(var n=t.length,i=e.length,o=0,a=Math.min(n,i);a>o&&t[o]===e[o];o++);return o!==a&&(n=t[o],i=e[o]),i>n?-1:n>i?1:0},r.prototype.write=function(t,e,n,r){if(isFinite(e))isFinite(n)||(r=n,n=void 0);else{var c=r;r=e,e=n,n=c}e=Number(e)||0;var l=this.length-e;n?(n=Number(n),n>l&&(n=l)):n=l,r=((r||"utf8")+"").toLowerCase();var d;switch(r){case"hex":d=i(this,t,e,n);break;case"utf8":case"utf-8":d=o(this,t,e,n);break;case"ascii":d=a(this,t,e,n);break;case"binary":d=u(this,t,e,n);break;case"base64":d=s(this,t,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":d=f(this,t,e,n);break;default:throw Error("Unknown encoding")}return d},r.prototype.toString=function(t,e,n){var r=this;if(t=((t||"utf8")+"").toLowerCase(),e=Number(e)||0,n=void 0===n?r.length:Number(n),n===e)return"";var i;switch(t){case"hex":i=h(r,e,n);break;case"utf8":case"utf-8":i=l(r,e,n);break;case"ascii":i=d(r,e,n);break;case"binary":i=p(r,e,n);break;case"base64":i=c(r,e,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=g(r,e,n);break;default:throw Error("Unknown encoding")}return i},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.equals=function(t){return W(r.isBuffer(t),"Argument must be a Buffer"),0===r.compare(this,t)},r.prototype.compare=function(t){return W(r.isBuffer(t),"Argument must be a Buffer"),r.compare(this,t)},r.prototype.copy=function(t,e,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),e||(e=0),i!==n&&0!==t.length&&0!==o.length){W(i>=n,"sourceEnd < sourceStart"),W(e>=0&&t.length>e,"targetStart out of bounds"),W(n>=0&&o.length>n,"sourceStart out of bounds"),W(i>=0&&o.length>=i,"sourceEnd out of bounds"),i>this.length&&(i=this.length),i-n>t.length-e&&(i=t.length-e+n);var a=i-n;if(100>a||!r._useTypedArrays)for(var u=0;a>u;u++)t[u+e]=this[u+n];else t._set(this.subarray(n,n+a),e)}},r.prototype.slice=function(t,e){var n=this.length;if(t=D(t,n,0),e=D(e,n,n),r._useTypedArrays)return r._augment(this.subarray(t,e));for(var i=e-t,o=new r(i,void 0,!0),a=0;i>a;a++)o[a]=this[a+t];return o},r.prototype.get=function(t){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(t)},r.prototype.set=function(t,e){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(t,e)},r.prototype.readUInt8=function(t,e){return e||(W(void 0!==t&&null!==t,"missing offset"),W(this.length>t,"Trying to read beyond buffer length")),t>=this.length?void 0:this[t]},r.prototype.readUInt16LE=function(t,e){return v(this,t,!0,e)},r.prototype.readUInt16BE=function(t,e){return v(this,t,!1,e)},r.prototype.readUInt32LE=function(t,e){return m(this,t,!0,e)},r.prototype.readUInt32BE=function(t,e){return m(this,t,!1,e)},r.prototype.readInt8=function(t,e){if(e||(W(void 0!==t&&null!==t,"missing offset"),W(this.length>t,"Trying to read beyond buffer length")),!(t>=this.length)){var n=128&this[t];return n?-1*(255-this[t]+1):this[t]}},r.prototype.readInt16LE=function(t,e){return E(this,t,!0,e)},r.prototype.readInt16BE=function(t,e){return E(this,t,!1,e)},r.prototype.readInt32LE=function(t,e){return y(this,t,!0,e)},r.prototype.readInt32BE=function(t,e){return y(this,t,!1,e)},r.prototype.readFloatLE=function(t,e){return w(this,t,!0,e)},r.prototype.readFloatBE=function(t,e){return w(this,t,!1,e)},r.prototype.readDoubleLE=function(t,e){return b(this,t,!0,e)},r.prototype.readDoubleBE=function(t,e){return b(this,t,!1,e)},r.prototype.writeUInt8=function(t,e,n){return n||(W(void 0!==t&&null!==t,"missing value"),W(void 0!==e&&null!==e,"missing offset"),W(this.length>e,"trying to write beyond buffer length"),V(t,255)),e>=this.length?void 0:(this[e]=t,e+1)},r.prototype.writeUInt16LE=function(t,e,n){return I(this,t,e,!0,n)},r.prototype.writeUInt16BE=function(t,e,n){return I(this,t,e,!1,n)},r.prototype.writeUInt32LE=function(t,e,n){return O(this,t,e,!0,n)},r.prototype.writeUInt32BE=function(t,e,n){return O(this,t,e,!1,n)},r.prototype.writeInt8=function(t,e,n){return n||(W(void 0!==t&&null!==t,"missing value"),W(void 0!==e&&null!==e,"missing offset"),W(this.length>e,"Trying to write beyond buffer length"),Y(t,127,-128)),e>=this.length?void 0:(t>=0?this.writeUInt8(t,e,n):this.writeUInt8(255+t+1,e,n),e+1)},r.prototype.writeInt16LE=function(t,e,n){return j(this,t,e,!0,n)},r.prototype.writeInt16BE=function(t,e,n){return j(this,t,e,!1,n)},r.prototype.writeInt32LE=function(t,e,n){return T(this,t,e,!0,n)},r.prototype.writeInt32BE=function(t,e,n){return T(this,t,e,!1,n)},r.prototype.writeFloatLE=function(t,e,n){return A(this,t,e,!0,n)},r.prototype.writeFloatBE=function(t,e,n){return A(this,t,e,!1,n)},r.prototype.writeDoubleLE=function(t,e,n){return S(this,t,e,!0,n)},r.prototype.writeDoubleBE=function(t,e,n){return S(this,t,e,!1,n)},r.prototype.fill=function(t,e,n){if(t||(t=0),e||(e=0),n||(n=this.length),W(n>=e,"end < start"),n!==e&&0!==this.length){W(e>=0&&this.length>e,"start out of bounds"),W(n>=0&&this.length>=n,"end out of bounds");var r;if("number"==typeof t)for(r=e;n>r;r++)this[r]=t;else{var i=M(""+t),o=i.length;for(r=e;n>r;r++)this[r]=i[r%o]}return this}},r.prototype.inspect=function(){for(var t=[],e=this.length,r=0;e>r;r++)if(t[r]=B(this[r]),r===n.INSPECT_MAX_BYTES){t[r+1]="...";break}return""},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(r._useTypedArrays)return new r(this).buffer;for(var t=new Uint8Array(this.length),e=0,n=t.length;n>e;e+=1)t[e]=this[e];return t.buffer}throw Error("Buffer.toArrayBuffer not supported in this browser")};var J=r.prototype;r._augment=function(t){return t._isBuffer=!0,t._get=t.get,t._set=t.set,t.get=J.get,t.set=J.set,t.write=J.write,t.toString=J.toString,t.toLocaleString=J.toString,t.toJSON=J.toJSON,t.equals=J.equals,t.compare=J.compare,t.copy=J.copy,t.slice=J.slice,t.readUInt8=J.readUInt8,t.readUInt16LE=J.readUInt16LE,t.readUInt16BE=J.readUInt16BE,t.readUInt32LE=J.readUInt32LE,t.readUInt32BE=J.readUInt32BE,t.readInt8=J.readInt8,t.readInt16LE=J.readInt16LE,t.readInt16BE=J.readInt16BE,t.readInt32LE=J.readInt32LE,t.readInt32BE=J.readInt32BE,t.readFloatLE=J.readFloatLE,t.readFloatBE=J.readFloatBE,t.readDoubleLE=J.readDoubleLE,t.readDoubleBE=J.readDoubleBE,t.writeUInt8=J.writeUInt8,t.writeUInt16LE=J.writeUInt16LE,t.writeUInt16BE=J.writeUInt16BE,t.writeUInt32LE=J.writeUInt32LE,t.writeUInt32BE=J.writeUInt32BE,t.writeInt8=J.writeInt8,t.writeInt16LE=J.writeInt16LE,t.writeInt16BE=J.writeInt16BE,t.writeInt32LE=J.writeInt32LE,t.writeInt32BE=J.writeInt32BE,t.writeFloatLE=J.writeFloatLE,t.writeFloatBE=J.writeFloatBE,t.writeDoubleLE=J.writeDoubleLE,t.writeDoubleBE=J.writeDoubleBE,t.fill=J.fill,t.inspect=J.inspect,t.toArrayBuffer=J.toArrayBuffer,t};var Q=/[^+\/0-9A-z]/g},{"base64-js":7,ieee754:8}],7:[function(t,e,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(t){"use strict";function e(t){var e=t.charCodeAt(0);return e===a?62:e===u?63:s>e?-1:s+10>e?e-s+26+26:c+26>e?e-c:f+26>e?e-f+26:void 0}function n(t){function n(t){f[l++]=t}var r,i,a,u,s,f;if(t.length%4>0)throw Error("Invalid string. Length must be a multiple of 4");var c=t.length;s="="===t.charAt(c-2)?2:"="===t.charAt(c-1)?1:0,f=new o(3*t.length/4-s),a=s>0?t.length-4:t.length;var l=0;for(r=0,i=0;a>r;r+=4,i+=3)u=e(t.charAt(r))<<18|e(t.charAt(r+1))<<12|e(t.charAt(r+2))<<6|e(t.charAt(r+3)),n((16711680&u)>>16),n((65280&u)>>8),n(255&u);return 2===s?(u=e(t.charAt(r))<<2|e(t.charAt(r+1))>>4,n(255&u)):1===s&&(u=e(t.charAt(r))<<10|e(t.charAt(r+1))<<4|e(t.charAt(r+2))>>2,n(255&u>>8),n(255&u)),f}function i(t){function e(t){return r.charAt(t)}function n(t){return e(63&t>>18)+e(63&t>>12)+e(63&t>>6)+e(63&t)}var i,o,a,u=t.length%3,s="";for(i=0,a=t.length-u;a>i;i+=3)o=(t[i]<<16)+(t[i+1]<<8)+t[i+2],s+=n(o);switch(u){case 1:o=t[t.length-1],s+=e(o>>2),s+=e(63&o<<4),s+="==";break;case 2:o=(t[t.length-2]<<8)+t[t.length-1],s+=e(o>>10),s+=e(63&o>>4),s+=e(63&o<<2),s+="="}return s}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="+".charCodeAt(0),u="/".charCodeAt(0),s="0".charCodeAt(0),f="a".charCodeAt(0),c="A".charCodeAt(0);t.toByteArray=n,t.fromByteArray=i})(n===void 0?this.base64js={}:n)},{}],8:[function(t,e,n){n.read=function(t,e,n,r,i){var o,a,u=8*i-r-1,s=(1<>1,c=-7,l=n?i-1:0,d=n?-1:1,p=t[e+l];for(l+=d,o=p&(1<<-c)-1,p>>=-c,c+=u;c>0;o=256*o+t[e+l],l+=d,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+t[e+l],l+=d,c-=8);if(0===o)o=1-f;else{if(o===s)return a?0/0:1/0*(p?-1:1);a+=Math.pow(2,r),o-=f}return(p?-1:1)*a*Math.pow(2,o-r)},n.write=function(t,e,n,r,i,o){var a,u,s,f=8*o-i-1,c=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:o-1,h=r?1:-1,g=0>e||0===e&&0>1/e?1:0;for(e=Math.abs(e),isNaN(e)||1/0===e?(u=isNaN(e)?1:0,a=c):(a=Math.floor(Math.log(e)/Math.LN2),1>e*(s=Math.pow(2,-a))&&(a--,s*=2),e+=a+l>=1?d/s:d*Math.pow(2,1-l),e*s>=2&&(a++,s/=2),a+l>=c?(u=0,a=c):a+l>=1?(u=(e*s-1)*Math.pow(2,i),a+=l):(u=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[n+p]=255&u,p+=h,u/=256,i-=8);for(a=a<0;t[n+p]=255&a,p+=h,a/=256,f-=8);t[n+p-h]|=128*g}},{}],9:[function(t,e){function n(){}var r=e.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw Error("process.chdir is not supported")}},{}],10:[function(t,e){(function(t){function n(e,n,r){return e instanceof ArrayBuffer&&(e=new Uint8Array(e)),new t(e,n,r)}n.prototype=Object.create(t.prototype),n.prototype.constructor=n,Object.keys(t).forEach(function(e){t.hasOwnProperty(e)&&(n[e]=t[e])}),e.exports=n}).call(this,t("buffer").Buffer)},{buffer:6}],11:[function(t,e){var n="READ",r="WRITE",i="CREATE",o="EXCLUSIVE",a="TRUNCATE",u="APPEND",s="CREATE",f="REPLACE";e.exports={FILE_SYSTEM_NAME:"local",FILE_STORE_NAME:"files",IDB_RO:"readonly",IDB_RW:"readwrite",WSQL_VERSION:"1",WSQL_SIZE:5242880,WSQL_DESC:"FileSystem Storage",MODE_FILE:"FILE",MODE_DIRECTORY:"DIRECTORY",MODE_SYMBOLIC_LINK:"SYMLINK",MODE_META:"META",SYMLOOP_MAX:10,BINARY_MIME_TYPE:"application/octet-stream",JSON_MIME_TYPE:"application/json",ROOT_DIRECTORY_NAME:"/",FS_FORMAT:"FORMAT",FS_NOCTIME:"NOCTIME",FS_NOMTIME:"NOMTIME",FS_NODUPEIDCHECK:"FS_NODUPEIDCHECK",O_READ:n,O_WRITE:r,O_CREATE:i,O_EXCLUSIVE:o,O_TRUNCATE:a,O_APPEND:u,O_FLAGS:{r:[n],"r+":[n,r],w:[r,i,a],"w+":[r,n,i,a],wx:[r,i,o,a],"wx+":[r,n,i,o,a],a:[r,i,u],"a+":[r,n,i,u],ax:[r,i,o,u],"ax+":[r,n,i,o,u]},XATTR_CREATE:s,XATTR_REPLACE:f,FS_READY:"READY",FS_PENDING:"PENDING",FS_ERROR:"ERROR",SUPER_NODE_ID:"00000000-0000-0000-0000-000000000000",STDIN:0,STDOUT:1,STDERR:2,FIRST_DESCRIPTOR:3,ENVIRONMENT:{TMP:"/tmp",PATH:""}}},{}],12:[function(t,e){var n=t("./constants.js").MODE_FILE;e.exports=function(t,e){this.id=t,this.type=e||n}},{"./constants.js":11}],13:[function(t,e){(function(t){function n(t){return t.toString("utf8")}function r(e){return new t(e,"utf8")}e.exports={encode:r,decode:n}}).call(this,t("buffer").Buffer)},{buffer:6}],14:[function(t,e){var n={};["9:EBADF:bad file descriptor","10:EBUSY:resource busy or locked","18:EINVAL:invalid argument","27:ENOTDIR:not a directory","28:EISDIR:illegal operation on a directory","34:ENOENT:no such file or directory","47:EEXIST:file already exists","51:ELOOP:too many symbolic links encountered","53:ENOTEMPTY:directory not empty","55:EIO:i/o error","1000:ENOTMOUNTED:not mounted","1001:EFILESYSTEMERROR:missing super node, use 'FORMAT' flag to format filesystem.","1002:ENOATTR:attribute does not exist"].forEach(function(t){function e(t,e){Error.call(this),this.name=i,this.code=i,this.errno=r,this.message=t||o,e&&(this.path=e),this.stack=Error(this.message).stack}t=t.split(":");var r=+t[0],i=t[1],o=t[2];e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(){var t=this.path?", '"+this.path+"'":"";return this.name+": "+this.message+t},n[i]=n[r]=e}),e.exports=n},{}],15:[function(t,e){function n(t){return function(e,n){e?t(e):t(null,n)}}function r(t,e,n,r,i){function o(n){t.changes.push({event:"change",path:e}),i(n)}var a=t.flags;de(a).contains(Fe)&&delete r.ctime,de(a).contains(Me)&&delete r.mtime;var u=!1;r.ctime&&(n.ctime=r.ctime,n.atime=r.ctime,u=!0),r.atime&&(n.atime=r.atime,u=!0),r.mtime&&(n.mtime=r.mtime,u=!0),u?t.putObject(n.id,n,o):o()}function i(t,e,n,i){function a(n,r){n?i(n):r.mode!==be?i(new ke.ENOTDIR("a component of the path prefix is not a directory",e)):(l=r,o(t,e,u))}function u(n,r){!n&&r?i(new ke.EEXIST("path name already exists",e)):!n||n instanceof ke.ENOENT?t.getObject(l.data,s):i(n)}function s(e,r){e?i(e):(d=r,Ye.create({guid:t.guid,mode:n},function(e,n){return e?(i(e),void 0):(p=n,p.nlinks+=1,t.putObject(p.id,p,c),void 0)}))}function f(e){if(e)i(e);else{var n=Date.now();r(t,g,p,{mtime:n,ctime:n},i)}}function c(e){e?i(e):(d[h]=new Ue(p.id,n),t.putObject(l.data,d,f))}if(n!==be&&n!==we)return i(new ke.EINVAL("mode must be a directory or file",e));e=he(e);var l,d,p,h=ve(e),g=ge(e);o(t,g,a)}function o(t,e,n){function r(e,r){e?n(e):r&&r.mode===Oe&&r.rnode?t.getObject(r.rnode,i):n(new ke.EFILESYSTEMERROR)}function i(t,e){t?n(t):e?n(null,e):n(new ke.ENOENT)}function a(r,i){r?n(r):i.mode===be&&i.data?t.getObject(i.data,u):n(new ke.ENOTDIR("a component of the path prefix is not a directory",e))}function u(r,i){if(r)n(r);else if(de(i).has(c)){var o=i[c].id;t.getObject(o,s)}else n(new ke.ENOENT(null,e))}function s(t,r){t?n(t):r.mode==Ie?(d++,d>Ae?n(new ke.ELOOP(null,e)):f(r.data)):n(null,r)}function f(e){e=he(e),l=ge(e),c=ve(e),je==c?t.getObject(Te,r):o(t,l,a)}if(e=he(e),!e)return n(new ke.ENOENT("path is an empty string"));var c=ve(e),l=ge(e),d=0;je==c?t.getObject(Te,r):o(t,l,a)}function a(t,e,n,i,a,u){function s(o,s){function c(e){e?u(e):r(t,f,s,{ctime:Date.now()},u)}s?s.xattrs[n]:null,o?u(o):a===Le&&s.xattrs.hasOwnProperty(n)?u(new ke.EEXIST("attribute already exists",e)):a!==Be||s.xattrs.hasOwnProperty(n)?(s.xattrs[n]=i,t.putObject(s.id,s,c)):u(new ke.ENOATTR(null,e))}var f;"string"==typeof e?(f=e,o(t,e,s)):"object"==typeof e&&"string"==typeof e.id?(f=e.path,t.getObject(e.id,s)):u(new ke.EINVAL("path or file descriptor of wrong type",e))}function u(t,e){function n(n,i){!n&&i?e():!n||n instanceof ke.ENOENT?Ve.create({guid:t.guid},function(n,i){return n?(e(n),void 0):(o=i,t.putObject(o.id,o,r),void 0)}):e(n)}function r(n){n?e(n):Ye.create({guid:t.guid,id:o.rnode,mode:be},function(n,r){return n?(e(n),void 0):(a=r,a.nlinks+=1,t.putObject(a.id,a,i),void 0)})}function i(n){n?e(n):(u={},t.putObject(a.data,u,e))}var o,a,u;t.getObject(Te,n)}function s(t,e,n){function i(r,i){!r&&i?n(new ke.EEXIST(null,e)):!r||r instanceof ke.ENOENT?o(t,v,a):n(r)}function a(e,r){e?n(e):(p=r,t.getObject(p.data,u))}function u(e,r){e?n(e):(h=r,Ye.create({guid:t.guid,mode:be},function(e,r){return e?(n(e),void 0):(l=r,l.nlinks+=1,t.putObject(l.id,l,s),void 0)}))}function s(e){e?n(e):(d={},t.putObject(l.data,d,c))}function f(e){if(e)n(e);else{var i=Date.now();r(t,v,p,{mtime:i,ctime:i},n)}}function c(e){e?n(e):(h[g]=new Ue(l.id,be),t.putObject(p.data,h,f)) +}e=he(e);var l,d,p,h,g=ve(e),v=ge(e);o(t,e,i)}function f(t,e,n){function i(e,r){e?n(e):(g=r,t.getObject(g.data,a))}function a(r,i){r?n(r):je==m?n(new ke.EBUSY(null,e)):de(i).has(m)?(v=i,p=v[m].id,t.getObject(p,u)):n(new ke.ENOENT(null,e))}function u(r,i){r?n(r):i.mode!=be?n(new ke.ENOTDIR(null,e)):(p=i,t.getObject(p.data,s))}function s(t,r){t?n(t):(h=r,de(h).size()>0?n(new ke.ENOTEMPTY(null,e)):c())}function f(e){if(e)n(e);else{var i=Date.now();r(t,E,g,{mtime:i,ctime:i},l)}}function c(){delete v[m],t.putObject(g.data,v,f)}function l(e){e?n(e):t.delete(p.id,d)}function d(e){e?n(e):t.delete(p.data,n)}e=he(e);var p,h,g,v,m=ve(e),E=ge(e);o(t,E,i)}function c(t,e,n,i){function a(n,r){n?i(n):r.mode!==be?i(new ke.ENOENT(null,e)):(v=r,t.getObject(v.data,u))}function u(r,o){r?i(r):(m=o,de(m).has(b)?de(n).contains(De)?i(new ke.ENOENT("O_CREATE and O_EXCLUSIVE are set, and the named file exists",e)):(E=m[b],E.type==be&&de(n).contains(xe)?i(new ke.EISDIR("the named file is a directory and O_WRITE is set",e)):t.getObject(E.id,s)):de(n).contains(Ne)?l():i(new ke.ENOENT("O_CREATE is not set and the named file does not exist",e)))}function s(t,n){if(t)i(t);else{var r=n;r.mode==Ie?(O++,O>Ae?i(new ke.ELOOP(null,e)):f(r.data)):c(void 0,r)}}function f(r){r=he(r),I=ge(r),b=ve(r),je==b&&(de(n).contains(xe)?i(new ke.EISDIR("the named file is a directory and O_WRITE is set",e)):o(t,e,c)),o(t,I,a)}function c(t,e){t?i(t):(y=e,i(null,y))}function l(){Ye.create({guid:t.guid,mode:we},function(e,n){return e?(i(e),void 0):(y=n,y.nlinks+=1,t.putObject(y.id,y,d),void 0)})}function d(e){e?i(e):(w=new We(0),w.fill(0),t.putBuffer(y.data,w,h))}function p(e){if(e)i(e);else{var n=Date.now();r(t,I,v,{mtime:n,ctime:n},g)}}function h(e){e?i(e):(m[b]=new Ue(y.id,we),t.putObject(v.data,m,p))}function g(t){t?i(t):i(null,y)}e=he(e);var v,m,E,y,w,b=ve(e),I=ge(e),O=0;je==b?de(n).contains(xe)?i(new ke.EISDIR("the named file is a directory and O_WRITE is set",e)):o(t,e,c):o(t,I,a)}function l(t,e,n,i,o,a){function u(t){t?a(t):a(null,o)}function s(n){if(n)a(n);else{var i=Date.now();r(t,e.path,l,{mtime:i,ctime:i},u)}}function f(e){e?a(e):t.putObject(l.id,l,s)}function c(r,u){if(r)a(r);else{l=u;var s=new We(o);s.fill(0),n.copy(s,0,i,i+o),e.position=o,l.size=o,l.version+=1,t.putBuffer(l.data,s,f)}}var l;t.getObject(e.id,c)}function d(t,e,n,i,o,a,u){function s(t){t?u(t):u(null,o)}function f(n){if(n)u(n);else{var i=Date.now();r(t,e.path,p,{mtime:i,ctime:i},s)}}function c(e){e?u(e):t.putObject(p.id,p,f)}function l(r,s){if(r)u(r);else{if(h=s,!h)return u(new ke.EIO("Expected Buffer"));var f=void 0!==a&&null!==a?a:e.position,l=Math.max(h.length,f+o),d=new We(l);d.fill(0),h&&h.copy(d),n.copy(d,f,i,i+o),void 0===a&&(e.position+=o),p.size=l,p.version+=1,t.putBuffer(p.data,d,c)}}function d(e,n){e?u(e):(p=n,t.getBuffer(p.data,l))}var p,h;t.getObject(e.id,d)}function p(t,e,n,r,i,o,a){function u(t,u){if(t)a(t);else{if(c=u,!c)return a(new ke.EIO("Expected Buffer"));var s=void 0!==o&&null!==o?o:e.position;i=s+i>n.length?i-s:i,c.copy(n,r,s,s+i),void 0===o&&(e.position+=i),a(null,i)}}function s(e,n){e?a(e):(f=n,t.getBuffer(f.data,u))}var f,c;t.getObject(e.id,s)}function h(t,e,r){e=he(e),ve(e),o(t,e,n(r))}function g(t,e,r){t.getObject(e.id,n(r))}function v(t,e,r){function i(e,n){e?r(e):(u=n,t.getObject(u.data,a))}function a(i,o){i?r(i):(s=o,de(s).has(f)?t.getObject(s[f].id,n(r)):r(new ke.ENOENT("a component of the path does not name an existing file",e)))}e=he(e);var u,s,f=ve(e),c=ge(e);je==f?o(t,e,n(r)):o(t,c,i)}function m(t,e,n,i){function a(e){e?i(e):r(t,n,y,{ctime:Date.now()},i)}function u(e,n){e?i(e):(y=n,y.nlinks+=1,t.putObject(y.id,y,a))}function s(e){e?i(e):t.getObject(E[w].id,u)}function f(e,n){e?i(e):(E=n,de(E).has(w)?i(new ke.EEXIST("newpath resolves to an existing file",w)):(E[w]=v[p],t.putObject(m.data,E,s)))}function c(e,n){e?i(e):(m=n,t.getObject(m.data,f))}function l(e,n){e?i(e):(v=n,de(v).has(p)?o(t,b,c):i(new ke.ENOENT("a component of either path prefix does not exist",p)))}function d(e,n){e?i(e):(g=n,t.getObject(g.data,l))}e=he(e);var p=ve(e),h=ge(e);n=he(n);var g,v,m,E,y,w=ve(n),b=ge(n);o(t,h,d)}function E(t,e,n){function i(e){e?n(e):(delete l[p],t.putObject(c.data,l,function(){var e=Date.now();r(t,h,c,{mtime:e,ctime:e},n)}))}function a(e){e?n(e):t.delete(d.data,i)}function u(o,u){o?n(o):(d=u,d.nlinks-=1,1>d.nlinks?t.delete(d.id,a):t.putObject(d.id,d,function(){r(t,e,d,{ctime:Date.now()},i)}))}function s(e,r){e?n(e):(l=r,de(l).has(p)?t.getObject(l[p].id,u):n(new ke.ENOENT("a component of the path does not name an existing file",p)))}function f(e,r){e?n(e):(c=r,t.getObject(c.data,s))}e=he(e);var c,l,d,p=ve(e),h=ge(e);o(t,h,f)}function y(t,e,n){function r(t,e){if(t)n(t);else{u=e;var r=Object.keys(u);n(null,r)}}function i(i,o){i?n(i):o.mode!==be?n(new ke.ENOTDIR(null,e)):(a=o,t.getObject(a.data,r))}e=he(e),ve(e);var a,u;o(t,e,i)}function w(t,e,n,i){function a(e,n){e?i(e):(l=n,t.getObject(l.data,u))}function u(t,e){t?i(t):(d=e,de(d).has(h)?i(new ke.EEXIST(null,h)):s())}function s(){Ye.create({guid:t.guid,mode:Ie},function(n,r){return n?(i(n),void 0):(p=r,p.nlinks+=1,p.size=e.length,p.data=e,t.putObject(p.id,p,c),void 0)})}function f(e){if(e)i(e);else{var n=Date.now();r(t,g,l,{mtime:n,ctime:n},i)}}function c(e){e?i(e):(d[h]=new Ue(p.id,Ie),t.putObject(l.data,d,f))}n=he(n);var l,d,p,h=ve(n),g=ge(n);je==h?i(new ke.EEXIST(null,h)):o(t,g,a)}function b(t,e,n){function r(e,r){e?n(e):(u=r,t.getObject(u.data,i))}function i(e,r){e?n(e):(s=r,de(s).has(f)?t.getObject(s[f].id,a):n(new ke.ENOENT("a component of the path does not name an existing file",f)))}function a(t,r){t?n(t):r.mode!=Ie?n(new ke.EINVAL("path not a symbolic link",e)):n(null,r.data)}e=he(e);var u,s,f=ve(e),c=ge(e);o(t,c,r)}function I(t,e,n,i){function a(n,r){n?i(n):r.mode==be?i(new ke.EISDIR(null,e)):(c=r,t.getBuffer(c.data,u))}function u(e,r){if(e)i(e);else{if(!r)return i(new ke.EIO("Expected Buffer"));var o=new We(n);o.fill(0),r&&r.copy(o),t.putBuffer(c.data,o,f)}}function s(n){if(n)i(n);else{var o=Date.now();r(t,e,c,{mtime:o,ctime:o},i)}}function f(e){e?i(e):(c.size=n,c.version+=1,t.putObject(c.id,c,s))}e=he(e);var c;0>n?i(new ke.EINVAL("length cannot be negative")):o(t,e,a)}function O(t,e,n,i){function o(e,n){e?i(e):n.mode==be?i(new ke.EISDIR):(f=n,t.getBuffer(f.data,a))}function a(e,r){if(e)i(e);else{var o;if(!r)return i(new ke.EIO("Expected Buffer"));r?o=r.slice(0,n):(o=new We(n),o.fill(0)),t.putBuffer(f.data,o,s)}}function u(n){if(n)i(n);else{var o=Date.now();r(t,e.path,f,{mtime:o,ctime:o},i)}}function s(e){e?i(e):(f.size=n,f.version+=1,t.putObject(f.id,f,u))}var f;0>n?i(new ke.EINVAL("length cannot be negative")):t.getObject(e.id,o)}function j(t,e,n,i,a){function u(o,u){o?a(o):r(t,e,u,{atime:n,ctime:i,mtime:i},a)}e=he(e),"number"!=typeof n||"number"!=typeof i?a(new ke.EINVAL("atime and mtime must be number",e)):0>n||0>i?a(new ke.EINVAL("atime and mtime must be positive integers",e)):o(t,e,u)}function T(t,e,n,i,o){function a(a,u){a?o(a):r(t,e.path,u,{atime:n,ctime:i,mtime:i},o)}"number"!=typeof n||"number"!=typeof i?o(new ke.EINVAL("atime and mtime must be a number")):0>n||0>i?o(new ke.EINVAL("atime and mtime must be positive integers")):t.getObject(e.id,a)}function A(t,e,n,r,i,o){e=he(e),"string"!=typeof n?o(new ke.EINVAL("attribute name must be a string",e)):n?null!==i&&i!==Le&&i!==Be?o(new ke.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE",e)):a(t,e,n,r,i,o):o(new ke.EINVAL("attribute name cannot be an empty string",e))}function S(t,e,n,r,i,o){"string"!=typeof n?o(new ke.EINVAL("attribute name must be a string")):n?null!==i&&i!==Le&&i!==Be?o(new ke.EINVAL("invalid flag, must be null, XATTR_CREATE or XATTR_REPLACE")):a(t,e,n,r,i,o):o(new ke.EINVAL("attribute name cannot be an empty string"))}function x(t,e,n,r){function i(t,i){i?i.xattrs[n]:null,t?r(t):i.xattrs.hasOwnProperty(n)?r(null,i.xattrs[n]):r(new ke.ENOATTR(null,e))}e=he(e),"string"!=typeof n?r(new ke.EINVAL("attribute name must be a string",e)):n?o(t,e,i):r(new ke.EINVAL("attribute name cannot be an empty string",e))}function N(t,e,n,r){function i(t,e){e?e.xattrs[n]:null,t?r(t):e.xattrs.hasOwnProperty(n)?r(null,e.xattrs[n]):r(new ke.ENOATTR)}"string"!=typeof n?r(new ke.EINVAL):n?t.getObject(e.id,i):r(new ke.EINVAL("attribute name cannot be an empty string"))}function D(t,e,n,i){function a(o,a){function u(n){n?i(n):r(t,e,a,{ctime:Date.now()},i)}var s=a?a.xattrs:null;o?i(o):s.hasOwnProperty(n)?(delete a.xattrs[n],t.putObject(a.id,a,u)):i(new ke.ENOATTR(null,e))}e=he(e),"string"!=typeof n?i(new ke.EINVAL("attribute name must be a string",e)):n?o(t,e,a):i(new ke.EINVAL("attribute name cannot be an empty string",e))}function _(t,e,n,i){function o(o,a){function u(n){n?i(n):r(t,e.path,a,{ctime:Date.now()},i)}o?i(o):a.xattrs.hasOwnProperty(n)?(delete a.xattrs[n],t.putObject(a.id,a,u)):i(new ke.ENOATTR)}"string"!=typeof n?i(new ke.EINVAL("attribute name must be a string")):n?t.getObject(e.id,o):i(new ke.EINVAL("attribute name cannot be an empty string"))}function R(t){return de(Re).has(t)?Re[t]:null}function L(t,e,n){return t?"function"==typeof t?t={encoding:e,flag:n}:"string"==typeof t&&(t={encoding:t,flag:n}):t={encoding:e,flag:n},t}function B(t,e){var n;return t?Ee(t)?n=new ke.EINVAL("Path must be a string without null bytes.",t):me(t)||(n=new ke.EINVAL("Path must be absolute.",t)):n=new ke.EINVAL("Path must be a string",t),n?(e(n),!1):!0}function M(t,e,n,r,i,o){function a(e,i){if(e)o(e);else{var a;a=de(r).contains(_e)?i.size:0;var u=new Pe(n,i.id,r,a),s=t.allocDescriptor(u);o(null,s)}}o=arguments[arguments.length-1],B(n,o)&&(r=R(r),r||o(new ke.EINVAL("flags is not valid"),n),c(e,n,r,a))}function F(t,e,n,r){de(t.openFiles).has(n)?(t.releaseDescriptor(n),r(null)):r(new ke.EBADF)}function C(t,e,n,r,o){B(n,o)&&i(e,n,r,o)}function k(t,e,r,i,o){o=arguments[arguments.length-1],B(r,o)&&s(e,r,n(o))}function U(t,e,r,i){B(r,i)&&f(e,r,n(i))}function P(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Xe(n,t.name);r(null,i)}}B(n,r)&&h(e,n,i)}function V(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Xe(n,t.name);r(null,i)}}var o=t.openFiles[n];o?g(e,o,i):r(new ke.EBADF)}function Y(t,e,r,i,o){B(r,o)&&B(i,o)&&m(e,r,i,n(o))}function X(t,e,r,i){B(r,i)&&E(e,r,n(i))}function W(t,e,r,i,o,a,u,s){function f(t,e){s(t,e||0,i)}o=void 0===o?0:o,a=void 0===a?i.length-o:a,s=arguments[arguments.length-1];var c=t.openFiles[r];c?de(c.flags).contains(Se)?p(e,c,i,o,a,u,n(f)):s(new ke.EBADF("descriptor does not permit reading")):s(new ke.EBADF)}function z(t,e,n,r,i){if(i=arguments[arguments.length-1],r=L(r,null,"r"),B(n,i)){var o=R(r.flag||"r");return o?(c(e,n,o,function(a,u){function s(){t.releaseDescriptor(c)}if(a)return i(a);var f=new Pe(n,u.id,o,0),c=t.allocDescriptor(f);g(e,f,function(o,a){if(o)return s(),i(o);var u=new Xe(a,t.name);if(u.isDirectory())return s(),i(new ke.EISDIR("illegal operation on directory",n));var c=u.size,l=new We(c);l.fill(0),p(e,f,l,0,c,0,function(t){if(s(),t)return i(t);var e;e="utf8"===r.encoding?Ce.decode(l):l,i(null,e)})})}),void 0):i(new ke.EINVAL("flags is not valid",n))}}function q(t,e,r,i,o,a,u,s){s=arguments[arguments.length-1],o=void 0===o?0:o,a=void 0===a?i.length-o:a;var f=t.openFiles[r];f?de(f.flags).contains(xe)?a>i.length-o?s(new ke.EIO("intput buffer is too small")):d(e,f,i,o,a,u,n(s)):s(new ke.EBADF("descriptor does not permit writing")):s(new ke.EBADF)}function J(t,e,n,r,i,o){if(o=arguments[arguments.length-1],i=L(i,"utf8","w"),B(n,o)){var a=R(i.flag||"w");if(!a)return o(new ke.EINVAL("flags is not valid",n));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Ce.encode(r)),c(e,n,a,function(i,u){if(i)return o(i);var s=new Pe(n,u.id,a,0),f=t.allocDescriptor(s);l(e,s,r,0,r.length,function(e){return t.releaseDescriptor(f),e?o(e):(o(null),void 0)})})}}function Q(t,e,n,r,i,o){if(o=arguments[arguments.length-1],i=L(i,"utf8","a"),B(n,o)){var a=R(i.flag||"a");if(!a)return o(new ke.EINVAL("flags is not valid",n));r=r||"","number"==typeof r&&(r=""+r),"string"==typeof r&&"utf8"===i.encoding&&(r=Ce.encode(r)),c(e,n,a,function(i,u){if(i)return o(i);var s=new Pe(n,u.id,a,u.size),f=t.allocDescriptor(s);d(e,s,r,0,r.length,s.position,function(e){return t.releaseDescriptor(f),e?o(e):(o(null),void 0)})})}}function H(t,e,n,r){function i(t){r(t?!1:!0)}P(t,e,n,i)}function K(t,e,r,i,o){B(r,o)&&x(e,r,i,n(o))}function G(t,e,r,i,o){var a=t.openFiles[r];a?N(e,a,i,n(o)):o(new ke.EBADF)}function $(t,e,r,i,o,a,u){"function"==typeof a&&(u=a,a=null),B(r,u)&&A(e,r,i,o,a,n(u))}function Z(t,e,r,i,o,a,u){"function"==typeof a&&(u=a,a=null);var s=t.openFiles[r];s?de(s.flags).contains(xe)?S(e,s,i,o,a,n(u)):u(new ke.EBADF("descriptor does not permit writing")):u(new ke.EBADF)}function te(t,e,r,i,o){B(r,o)&&D(e,r,i,n(o))}function ee(t,e,r,i,o){var a=t.openFiles[r];a?de(a.flags).contains(xe)?_(e,a,i,n(o)):o(new ke.EBADF("descriptor does not permit writing")):o(new ke.EBADF)}function ne(t,e,n,r,i,o){function a(t,e){t?o(t):0>e.size+r?o(new ke.EINVAL("resulting file offset would be negative")):(u.position=e.size+r,o(null,u.position))}var u=t.openFiles[n];u||o(new ke.EBADF),"SET"===i?0>r?o(new ke.EINVAL("resulting file offset would be negative")):(u.position=r,o(null,u.position)):"CUR"===i?0>u.position+r?o(new ke.EINVAL("resulting file offset would be negative")):(u.position+=r,o(null,u.position)):"END"===i?g(e,u,a):o(new ke.EINVAL("whence argument is not a proper value"))}function re(t,e,r,i){B(r,i)&&y(e,r,n(i))}function ie(t,e,r,i,o,a){if(B(r,a)){var u=Date.now();i=i?i:u,o=o?o:u,j(e,r,i,o,n(a))}}function oe(t,e,r,i,o,a){var u=Date.now();i=i?i:u,o=o?o:u;var s=t.openFiles[r];s?de(s.flags).contains(xe)?T(e,s,i,o,n(a)):a(new ke.EBADF("descriptor does not permit writing")):a(new ke.EBADF)}function ae(t,e,r,i,o){function a(t){t?o(t):E(e,r,n(o))}B(r,o)&&B(i,o)&&m(e,r,i,a)}function ue(t,e,r,i,o,a){a=arguments[arguments.length-1],B(r,a)&&B(i,a)&&w(e,r,i,n(a))}function se(t,e,r,i){B(r,i)&&b(e,r,n(i))}function fe(t,e,n,r){function i(e,n){if(e)r(e);else{var i=new Xe(n,t.name);r(null,i)}}B(n,r)&&v(e,n,i)}function ce(t,e,r,i,o){o=arguments[arguments.length-1],i=i||0,B(r,o)&&I(e,r,i,n(o))}function le(t,e,r,i,o){o=arguments[arguments.length-1],i=i||0;var a=t.openFiles[r];a?de(a.flags).contains(xe)?O(e,a,i,n(o)):o(new ke.EBADF("descriptor does not permit writing")):o(new ke.EBADF)}var de=t("../../lib/nodash.js"),pe=t("../path.js"),he=pe.normalize,ge=pe.dirname,ve=pe.basename,me=pe.isAbsolute,Ee=pe.isNull,ye=t("../constants.js"),we=ye.MODE_FILE,be=ye.MODE_DIRECTORY,Ie=ye.MODE_SYMBOLIC_LINK,Oe=ye.MODE_META,je=ye.ROOT_DIRECTORY_NAME,Te=ye.SUPER_NODE_ID,Ae=ye.SYMLOOP_MAX,Se=ye.O_READ,xe=ye.O_WRITE,Ne=ye.O_CREATE,De=ye.O_EXCLUSIVE;ye.O_TRUNCATE;var _e=ye.O_APPEND,Re=ye.O_FLAGS,Le=ye.XATTR_CREATE,Be=ye.XATTR_REPLACE,Me=ye.FS_NOMTIME,Fe=ye.FS_NOCTIME,Ce=t("../encoding.js"),ke=t("../errors.js"),Ue=t("../directory-entry.js"),Pe=t("../open-file-description.js"),Ve=t("../super-node.js"),Ye=t("../node.js"),Xe=t("../stats.js"),We=t("../buffer.js");e.exports={ensureRootDirectory:u,open:M,close:F,mknod:C,mkdir:k,rmdir:U,unlink:X,stat:P,fstat:V,link:Y,read:W,readFile:z,write:q,writeFile:J,appendFile:Q,exists:H,getxattr:K,fgetxattr:G,setxattr:$,fsetxattr:Z,removexattr:te,fremovexattr:ee,lseek:ne,readdir:re,utimes:ie,futimes:oe,rename:ae,symlink:ue,readlink:se,lstat:fe,truncate:ce,ftruncate:le}},{"../../lib/nodash.js":4,"../buffer.js":10,"../constants.js":11,"../directory-entry.js":12,"../encoding.js":13,"../errors.js":14,"../node.js":19,"../open-file-description.js":20,"../path.js":21,"../stats.js":29,"../super-node.js":30}],16:[function(t,e){function n(t){return"function"==typeof t?t:function(t){if(t)throw t}}function r(t,e){function n(){R.forEach(function(t){t.call(this)}.bind(N)),R=null}function r(t){return function(e){function n(e){var r=T();t.getObject(r,function(t,i){return t?(e(t),void 0):(i?n(e):e(null,r),void 0)})}return i(g).contains(p)?(e(null,T()),void 0):(n(e),void 0)}}function u(t){if(t.length){var e=v.getInstance();t.forEach(function(t){e.emit(t.event,t.path)})}}t=t||{},e=e||a;var g=t.flags,T=t.guid?t.guid:y,A=t.provider||new h.Default(t.name||s),S=t.name||A.name,x=i(g).contains(f),N=this;N.readyState=l,N.name=S,N.error=null,N.stdin=w,N.stdout=b,N.stderr=I;var D={},_=O;Object.defineProperty(this,"openFiles",{get:function(){return D}}),this.allocDescriptor=function(t){var e=_++;return D[e]=t,e},this.releaseDescriptor=function(t){delete D[t]};var R=[];this.queueOrRun=function(t){var e;return c==N.readyState?t.call(N):d==N.readyState?e=new E.EFILESYSTEMERROR("unknown error"):R.push(t),e},this.watch=function(t,e,n){if(o(t))throw Error("Path must be a string without null bytes.");"function"==typeof e&&(n=e,e={}),e=e||{},n=n||a;var r=new m;return r.start(t,!1,e.recursive),r.on("change",n),r},A.open(function(t){function i(t){function i(t){var e=A[t]();return e.flags=g,e.changes=[],e.guid=r(e),e.close=function(){var t=e.changes;u(t),t.length=0},e}N.provider={openReadWriteContext:function(){return i("getReadWriteContext")},openReadOnlyContext:function(){return i("getReadOnlyContext")}},N.readyState=t?d:c,n(),e(t,N)}if(t)return i(t);var o=A.getReadWriteContext();o.guid=r(o),x?o.clear(function(t){return t?i(t):(j.ensureRootDirectory(o,i),void 0)}):j.ensureRootDirectory(o,i)})}var i=t("../../lib/nodash.js"),o=t("../path.js").isNull,a=t("../shared.js").nop,u=t("../constants.js"),s=u.FILE_SYSTEM_NAME,f=u.FS_FORMAT,c=u.FS_READY,l=u.FS_PENDING,d=u.FS_ERROR,p=u.FS_NODUPEIDCHECK,h=t("../providers/index.js"),g=t("../shell/shell.js"),v=t("../../lib/intercom.js"),m=t("../fs-watcher.js"),E=t("../errors.js"),y=t("../shared.js").guid,w=u.STDIN,b=u.STDOUT,I=u.STDERR,O=u.FIRST_DESCRIPTOR,j=t("./implementation.js");r.providers=h,["open","close","mknod","mkdir","rmdir","stat","fstat","link","unlink","read","readFile","write","writeFile","appendFile","exists","lseek","readdir","rename","readlink","symlink","lstat","truncate","ftruncate","utimes","futimes","setxattr","getxattr","fsetxattr","fgetxattr","removexattr","fremovexattr"].forEach(function(t){r.prototype[t]=function(){var e=this,r=Array.prototype.slice.call(arguments,0),i=r.length-1,o="function"!=typeof r[i],a=n(r[i]),u=e.queueOrRun(function(){function n(){u.close(),a.apply(e,arguments)}var u=e.provider.openReadWriteContext();if(d===e.readyState){var s=new E.EFILESYSTEMERROR("filesystem unavailable, operation canceled");return a.call(e,s)}o?r.push(n):r[i]=n;var f=[e,u].concat(r);j[t].apply(null,f)});u&&a(u)}}),r.prototype.Shell=function(t){return new g(this,t)},e.exports=r},{"../../lib/intercom.js":3,"../../lib/nodash.js":4,"../constants.js":11,"../errors.js":14,"../fs-watcher.js":17,"../path.js":21,"../providers/index.js":22,"../shared.js":26,"../shell/shell.js":28,"./implementation.js":15}],17:[function(t,e){function n(){function t(t){(n===t||u&&0===t.indexOf(e))&&a.trigger("change","change",t)}r.call(this);var e,n,a=this,u=!1;a.start=function(r,a,s){if(!n){if(i.isNull(r))throw Error("Path must be a string without null bytes.");n=i.normalize(r),u=s===!0,u&&(e="/"===n?"/":n+"/");var f=o.getInstance();f.on("change",t)}},a.close=function(){var e=o.getInstance();e.off("change",t),a.removeAllListeners("change")}}var r=t("../lib/eventemitter.js"),i=t("./path.js"),o=t("../lib/intercom.js");n.prototype=new r,n.prototype.constructor=n,e.exports=n},{"../lib/eventemitter.js":2,"../lib/intercom.js":3,"./path.js":21}],18:[function(t,e){e.exports={FileSystem:t("./filesystem/interface.js"),Buffer:t("./buffer.js"),Path:t("./path.js"),Errors:t("./errors.js")}},{"./buffer.js":10,"./errors.js":14,"./filesystem/interface.js":16,"./path.js":21}],19:[function(t,e){function n(t){var e=Date.now();this.id=t.id,this.mode=t.mode||i,this.size=t.size||0,this.atime=t.atime||e,this.ctime=t.ctime||e,this.mtime=t.mtime||e,this.flags=t.flags||[],this.xattrs=t.xattrs||{},this.nlinks=t.nlinks||0,this.version=t.version||0,this.blksize=void 0,this.nblocks=1,this.data=t.data}function r(t,e,n){t[e]?n(null):t.guid(function(r,i){t[e]=i,n(r)})}var i=t("./constants.js").MODE_FILE;n.create=function(t,e){r(t,"id",function(i){return i?(e(i),void 0):(r(t,"data",function(r){return r?(e(r),void 0):(e(null,new n(t)),void 0)}),void 0)})},e.exports=n},{"./constants.js":11}],20:[function(t,e){e.exports=function(t,e,n,r){this.path=t,this.id=e,this.flags=n,this.position=r}},{}],21:[function(t,e,n){function r(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}function i(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var i=n>=0?arguments[n]:"/";"string"==typeof i&&i&&(t=i+"/"+t,e="/"===i.charAt(0))}return t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),(e?"/":"")+t||"."}function o(t){var e="/"===t.charAt(0);return"/"===t.substr(-1),t=r(t.split("/").filter(function(t){return!!t}),!e).join("/"),t||e||(t="."),(e?"/":"")+t}function a(){var t=Array.prototype.slice.call(arguments,0);return o(t.filter(function(t){return t&&"string"==typeof t}).join("/"))}function u(t,e){function r(t){for(var e=0;t.length>e&&""===t[e];e++);for(var n=t.length-1;n>=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=n.resolve(t).substr(1),e=n.resolve(e).substr(1);for(var i=r(t.split("/")),o=r(e.split("/")),a=Math.min(i.length,o.length),u=a,s=0;a>s;s++)if(i[s]!==o[s]){u=s;break}for(var f=[],s=u;i.length>s;s++)f.push("..");return f=f.concat(o.slice(u)),f.join("/")}function s(t){var e=h(t),n=e[0],r=e[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."}function f(t,e){var n=h(t)[2];return e&&n.substr(-1*e.length)===e&&(n=n.substr(0,n.length-e.length)),""===n?"/":n}function c(t){return h(t)[3]}function l(t){return"/"===t.charAt(0)?!0:!1}function d(t){return-1!==(""+t).indexOf("\0")?!0:!1}var p=/^(\/?)([\s\S]+\/(?!$)|\/)?((?:\.{1,2}$|[\s\S]+?)?(\.[^.\/]*)?)$/,h=function(t){var e=p.exec(t);return[e[1]||"",e[2]||"",e[3]||"",e[4]||""]};e.exports={normalize:o,resolve:i,join:a,relative:u,sep:"/",delimiter:":",dirname:s,basename:f,extname:c,isAbsolute:l,isNull:d}},{}],22:[function(t,e){var n=t("./indexeddb.js"),r=t("./websql.js"),i=t("./memory.js");e.exports={IndexedDB:n,WebSQL:r,Memory:i,Default:n,Fallback:function(){function t(){throw"[Filer Error] Your browser doesn't support IndexedDB or WebSQL."}return n.isSupported()?n:r.isSupported()?r:(t.isSupported=function(){return!1},t)}()}},{"./indexeddb.js":23,"./memory.js":24,"./websql.js":25}],23:[function(t,e){(function(n){function r(t,e){var n=t.transaction(s,e);this.objectStore=n.objectStore(s)}function i(t,e,n){try{var r=t.get(e);r.onsuccess=function(t){var e=t.target.result;n(null,e)},r.onerror=function(t){n(t)}}catch(i){n(i)}}function o(t,e,n,r){try{var i=t.put(n,e);i.onsuccess=function(t){var e=t.target.result;r(null,e)},i.onerror=function(t){r(t)}}catch(o){r(o)}}function a(t){this.name=t||u,this.db=null}var u=t("../constants.js").FILE_SYSTEM_NAME,s=t("../constants.js").FILE_STORE_NAME,f=t("../constants.js").IDB_RW;t("../constants.js").IDB_RO;var c=t("../errors.js"),l=t("../buffer.js"),d=n.indexedDB||n.mozIndexedDB||n.webkitIndexedDB||n.msIndexedDB;r.prototype.clear=function(t){try{var e=this.objectStore.clear();e.onsuccess=function(){t()},e.onerror=function(e){t(e)}}catch(n){t(n)}},r.prototype.getObject=function(t,e){i(this.objectStore,t,e)},r.prototype.getBuffer=function(t,e){i(this.objectStore,t,function(t,n){return t?e(t):(e(null,new l(n)),void 0)})},r.prototype.putObject=function(t,e,n){o(this.objectStore,t,e,n)},r.prototype.putBuffer=function(t,e,n){o(this.objectStore,t,e.buffer,n)},r.prototype.delete=function(t,e){try{var n=this.objectStore.delete(t);n.onsuccess=function(t){var n=t.target.result;e(null,n)},n.onerror=function(t){e(t)}}catch(r){e(r)}},a.isSupported=function(){return!!d},a.prototype.open=function(t){var e=this;if(e.db)return t();var n=d.open(e.name);n.onupgradeneeded=function(t){var e=t.target.result;e.objectStoreNames.contains(s)&&e.deleteObjectStore(s),e.createObjectStore(s)},n.onsuccess=function(n){e.db=n.target.result,t()},n.onerror=function(){t(new c.EINVAL("IndexedDB cannot be accessed. If private browsing is enabled, disable it."))}},a.prototype.getReadOnlyContext=function(){return new r(this.db,f)},a.prototype.getReadWriteContext=function(){return new r(this.db,f)},e.exports=a}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../buffer.js":10,"../constants.js":11,"../errors.js":14}],24:[function(t,e){function n(t,e){this.readOnly=e,this.objectStore=t}function r(t){this.name=t||i}var i=t("../constants.js").FILE_SYSTEM_NAME,o=t("../../lib/async.js").setImmediate,a=function(){var t={};return function(e){return t.hasOwnProperty(e)||(t[e]={}),t[e]}}();n.prototype.clear=function(t){if(this.readOnly)return o(function(){t("[MemoryContext] Error: write operation on read only context")}),void 0;var e=this.objectStore;Object.keys(e).forEach(function(t){delete e[t]}),o(t)},n.prototype.getObject=n.prototype.getBuffer=function(t,e){var n=this;o(function(){e(null,n.objectStore[t])})},n.prototype.putObject=n.prototype.putBuffer=function(t,e,n){return this.readOnly?(o(function(){n("[MemoryContext] Error: write operation on read only context")}),void 0):(this.objectStore[t]=e,o(n),void 0)},n.prototype.delete=function(t,e){return this.readOnly?(o(function(){e("[MemoryContext] Error: write operation on read only context")}),void 0):(delete this.objectStore[t],o(e),void 0)},r.isSupported=function(){return!0},r.prototype.open=function(t){this.db=a(this.name),o(t)},r.prototype.getReadOnlyContext=function(){return new n(this.db,!0)},r.prototype.getReadWriteContext=function(){return new n(this.db,!1)},e.exports=r},{"../../lib/async.js":1,"../constants.js":11}],25:[function(t,e){(function(n){function r(t,e){var n=this;this.getTransaction=function(r){return n.transaction?(r(n.transaction),void 0):(t[e?"readTransaction":"transaction"](function(t){n.transaction=t,r(t)}),void 0)}}function i(t,e,n){function r(t,e){var r=0===e.rows.length?null:e.rows.item(0).data;n(null,r)}function i(t,e){n(e)}t(function(t){t.executeSql("SELECT data FROM "+s+" WHERE id = ? LIMIT 1;",[e],r,i)})}function o(t,e,n,r){function i(){r(null)}function o(t,e){r(e)}t(function(t){t.executeSql("INSERT OR REPLACE INTO "+s+" (id, data) VALUES (?, ?);",[e,n],i,o)})}function a(t){this.name=t||u,this.db=null}var u=t("../constants.js").FILE_SYSTEM_NAME,s=t("../constants.js").FILE_STORE_NAME,f=t("../constants.js").WSQL_VERSION,c=t("../constants.js").WSQL_SIZE,l=t("../constants.js").WSQL_DESC,d=t("../errors.js"),p=t("../buffer.js"),h=t("base64-arraybuffer");r.prototype.clear=function(t){function e(e,n){t(n)}function n(){t(null)}this.getTransaction(function(t){t.executeSql("DELETE FROM "+s+";",[],n,e)})},r.prototype.getObject=function(t,e){i(this.getTransaction,t,function(t,n){if(t)return e(t);try{n&&(n=JSON.parse(n))}catch(r){return e(r)}e(null,n)})},r.prototype.getBuffer=function(t,e){i(this.getTransaction,t,function(t,n){if(t)return e(t);if(n||""===n){var r=h.decode(n);n=new p(r)}e(null,n)})},r.prototype.putObject=function(t,e,n){var r=JSON.stringify(e);o(this.getTransaction,t,r,n)},r.prototype.putBuffer=function(t,e,n){var r=h.encode(e.buffer);o(this.getTransaction,t,r,n)},r.prototype.delete=function(t,e){function n(){e(null)}function r(t,n){e(n)}this.getTransaction(function(e){e.executeSql("DELETE FROM "+s+" WHERE id = ?;",[t],n,r)})},a.isSupported=function(){return!!n.openDatabase},a.prototype.open=function(t){function e(e,n){5===n.code&&t(new d.EINVAL("WebSQL cannot be accessed. If private browsing is enabled, disable it.")),t(n)}function r(){i.db=o,t()}var i=this;if(i.db)return t();var o=n.openDatabase(i.name,f,l,c);return o?(o.transaction(function(t){function n(t){t.executeSql("CREATE INDEX IF NOT EXISTS idx_"+s+"_id"+" on "+s+" (id);",[],r,e)}t.executeSql("CREATE TABLE IF NOT EXISTS "+s+" (id unique, data TEXT);",[],n,e)}),void 0):(t("[WebSQL] Unable to open database."),void 0)},a.prototype.getReadOnlyContext=function(){return new r(this.db,!0)},a.prototype.getReadWriteContext=function(){return new r(this.db,!1)},e.exports=a}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../buffer.js":10,"../constants.js":11,"../errors.js":14,"base64-arraybuffer":5}],26:[function(t,e){function n(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=0|16*Math.random(),n="x"==t?e:8|3&e;return n.toString(16)}).toUpperCase()}function r(){}function i(t){for(var e=[],n=t.length,r=0;n>r;r++)e[r]=t[r];return e}e.exports={guid:n,u8toArray:i,nop:r}},{}],27:[function(t,e){var n=t("../constants.js").ENVIRONMENT;e.exports=function(t){t=t||{},t.TMP=t.TMP||n.TMP,t.PATH=t.PATH||n.PATH,this.get=function(e){return t[e]},this.set=function(e,n){t[e]=n}}},{"../constants.js":11}],28:[function(t,e){function n(t,e){e=e||{};var n=new o(e.env),a="/";Object.defineProperty(this,"fs",{get:function(){return t},enumerable:!0}),Object.defineProperty(this,"env",{get:function(){return n},enumerable:!0}),this.cd=function(e,n){e=r.resolve(a,e),t.stat(e,function(t,r){return t?(n(new i.ENOTDIR(null,e)),void 0):("DIRECTORY"===r.type?(a=e,n()):n(new i.ENOTDIR(null,e)),void 0)})},this.pwd=function(){return a}}var r=t("../path.js"),i=t("../errors.js"),o=t("./environment.js"),a=t("../../lib/async.js");t("../encoding.js"),n.prototype.exec=function(t,e,n){var i=this,o=i.fs;"function"==typeof e&&(n=e,e=[]),e=e||[],n=n||function(){},t=r.resolve(i.pwd(),t),o.readFile(t,"utf8",function(t,r){if(t)return n(t),void 0;try{var i=Function("fs","args","callback",r);i(o,e,n)}catch(a){n(a)}})},n.prototype.touch=function(t,e,n){function i(t){u.writeFile(t,"",n)}function o(t){var r=Date.now(),i=e.date||r,o=e.date||r;u.utimes(t,i,o,n)}var a=this,u=a.fs;"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t=r.resolve(a.pwd(),t),u.stat(t,function(r){r?e.updateOnly===!0?n():i(t):o(t)})},n.prototype.cat=function(t,e){function n(t,e){var n=r.resolve(o.pwd(),t);u.readFile(n,"utf8",function(t,n){return t?(e(t),void 0):(s+=n+"\n",e(),void 0)})}var o=this,u=o.fs,s="";return e=e||function(){},t?(t="string"==typeof t?[t]:t,a.eachSeries(t,n,function(t){t?e(t):e(null,s.replace(/\n$/,""))}),void 0):(e(new i.EINVAL("Missing files argument")),void 0)},n.prototype.ls=function(t,e,n){function o(t,n){var i=r.resolve(u.pwd(),t),f=[];s.readdir(i,function(t,u){function c(t,n){t=r.join(i,t),s.stat(t,function(a,u){if(a)return n(a),void 0;var s={path:r.basename(t),links:u.nlinks,size:u.size,modified:u.mtime,type:u.type};e.recursive&&"DIRECTORY"===u.type?o(r.join(i,s.path),function(t,e){return t?(n(t),void 0):(s.contents=e,f.push(s),n(),void 0)}):(f.push(s),n())})}return t?(n(t),void 0):(a.eachSeries(u,c,function(t){n(t,f)}),void 0)})}var u=this,s=u.fs;return"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t?(o(t,n),void 0):(n(new i.EINVAL("Missing dir argument")),void 0)},n.prototype.rm=function(t,e,n){function o(t,n){t=r.resolve(u.pwd(),t),s.stat(t,function(u,f){return u?(n(u),void 0):"FILE"===f.type?(s.unlink(t,n),void 0):(s.readdir(t,function(u,f){return u?(n(u),void 0):0===f.length?(s.rmdir(t,n),void 0):e.recursive?(f=f.map(function(e){return r.join(t,e)}),a.eachSeries(f,o,function(e){return e?(n(e),void 0):(s.rmdir(t,n),void 0)}),void 0):(n(new i.ENOTEMPTY(null,t)),void 0)}),void 0)})}var u=this,s=u.fs;return"function"==typeof e&&(n=e,e={}),e=e||{},n=n||function(){},t?(o(t,n),void 0):(n(new i.EINVAL("Missing path argument")),void 0)},n.prototype.tempDir=function(t){var e=this,n=e.fs,r=e.env.get("TMP");t=t||function(){},n.mkdir(r,function(){t(null,r)})},n.prototype.mkdirp=function(t,e){function n(t,e){a.stat(t,function(o,u){if(u){if(u.isDirectory())return e(),void 0;if(u.isFile())return e(new i.ENOTDIR(null,t)),void 0}else{if(o&&"ENOENT"!==o.code)return e(o),void 0;var s=r.dirname(t);"/"===s?a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(e(t),void 0):(e(),void 0)}):n(s,function(n){return n?e(n):(a.mkdir(t,function(t){return t&&"EEXIST"!=t.code?(e(t),void 0):(e(),void 0)}),void 0)})}})}var o=this,a=o.fs;return e=e||function(){},t?"/"===t?(e(),void 0):(n(t,e),void 0):(e(new i.EINVAL("Missing path argument")),void 0) +},e.exports=n},{"../../lib/async.js":1,"../encoding.js":13,"../errors.js":14,"../path.js":21,"./environment.js":27}],29:[function(t,e){function n(t,e){this.node=t.id,this.dev=e,this.size=t.size,this.nlinks=t.nlinks,this.atime=t.atime,this.mtime=t.mtime,this.ctime=t.ctime,this.type=t.mode}var r=t("./constants.js");n.prototype.isFile=function(){return this.type===r.MODE_FILE},n.prototype.isDirectory=function(){return this.type===r.MODE_DIRECTORY},n.prototype.isSymbolicLink=function(){return this.type===r.MODE_SYMBOLIC_LINK},n.prototype.isSocket=n.prototype.isFIFO=n.prototype.isCharacterDevice=n.prototype.isBlockDevice=function(){return!1},e.exports=n},{"./constants.js":11}],30:[function(t,e){function n(t){var e=Date.now();this.id=r.SUPER_NODE_ID,this.mode=r.MODE_META,this.atime=t.atime||e,this.ctime=t.ctime||e,this.mtime=t.mtime||e,this.rnode=t.rnode}var r=t("./constants.js");n.create=function(t,e){t.guid(function(r,i){return r?(e(r),void 0):(t.rnode=t.rnode||i,e(null,new n(t)),void 0)})},e.exports=n},{"./constants.js":11}]},{},[18])(18)}); \ No newline at end of file diff --git a/package.json b/package.json index 0e9264d..118fb80 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "idb", "websql" ], - "version": "0.0.27", + "version": "0.0.28", "author": "Alan K (http://blog.modeswitch.org)", "homepage": "http://js-platform.github.io/filer", "bugs": "https://github.com/js-platform/filer/issues",