{ "version": 3, "sources": ["../../build/_snowpack/pkg/pixl-canvas-plus/browser.js", "../../build/_snowpack/pkg/common/_polyfill-node:buffer-57df7f7d.js", "../../build/_snowpack/pkg/common/_commonjsHelpers-a3307dcf.js", "../../build/_snowpack/pkg/fabric.js", "../../build/_snowpack/pkg/@sindresorhus/slugify.js", "../../build/src/util/canvas-plus.js", "../../build/src/util/fabric.js", "../../build/src/util/download.js", "../../build/src/index.js"], "sourcesContent": ["import { c as commonjsGlobal, g as getDefaultExportFromNamespaceIfNotNamed, a as createCommonjsModule } from '../common/_commonjsHelpers-a3307dcf.js';\nimport { B as Buffer, g as global } from '../common/_polyfill-node:buffer-57df7f7d.js';\n\n/* SNOWPACK PROCESS POLYFILL (based on https://github.com/calvinmetcalf/node-process-es6) */\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\nvar cachedSetTimeout = defaultSetTimout;\nvar cachedClearTimeout = defaultClearTimeout;\nvar globalContext;\nif (typeof window !== 'undefined') {\n globalContext = window;\n} else if (typeof self !== 'undefined') {\n globalContext = self;\n} else {\n globalContext = {};\n}\nif (typeof globalContext.setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n}\nif (typeof globalContext.clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n}\n\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\nfunction nextTick(fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n}\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nvar title = 'browser';\nvar platform = 'browser';\nvar browser = true;\nvar argv = [];\nvar version = ''; // empty string to avoid regexp issues\nvar versions = {};\nvar release = {};\nvar config = {};\n\nfunction noop() {}\n\nvar on = noop;\nvar addListener = noop;\nvar once = noop;\nvar off = noop;\nvar removeListener = noop;\nvar removeAllListeners = noop;\nvar emit = noop;\n\nfunction binding(name) {\n throw new Error('process.binding is not supported');\n}\n\nfunction cwd () { return '/' }\nfunction chdir (dir) {\n throw new Error('process.chdir is not supported');\n}function umask() { return 0; }\n\n// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js\nvar performance = globalContext.performance || {};\nvar performanceNow =\n performance.now ||\n performance.mozNow ||\n performance.msNow ||\n performance.oNow ||\n performance.webkitNow ||\n function(){ return (new Date()).getTime() };\n\n// generate timestamp or delta\n// see http://nodejs.org/api/process.html#process_process_hrtime\nfunction hrtime(previousTimestamp){\n var clocktime = performanceNow.call(performance)*1e-3;\n var seconds = Math.floor(clocktime);\n var nanoseconds = Math.floor((clocktime%1)*1e9);\n if (previousTimestamp) {\n seconds = seconds - previousTimestamp[0];\n nanoseconds = nanoseconds - previousTimestamp[1];\n if (nanoseconds<0) {\n seconds--;\n nanoseconds += 1e9;\n }\n }\n return [seconds,nanoseconds]\n}\n\nvar startTime = new Date();\nfunction uptime() {\n var currentTime = new Date();\n var dif = currentTime - startTime;\n return dif / 1000;\n}\n\nvar process = {\n nextTick: nextTick,\n title: title,\n browser: browser,\n env: {\"NODE_ENV\":\"production\"},\n argv: argv,\n version: version,\n versions: versions,\n on: on,\n addListener: addListener,\n once: once,\n off: off,\n removeListener: removeListener,\n removeAllListeners: removeAllListeners,\n emit: emit,\n binding: binding,\n cwd: cwd,\n chdir: chdir,\n umask: umask,\n hrtime: hrtime,\n platform: platform,\n release: release,\n config: config,\n uptime: uptime\n};\n\nvar browserProcessHrtime = process.hrtime || hrtime$1;\n\n// polyfil for window.performance.now\nvar performance$1 = commonjsGlobal.performance || {};\nvar performanceNow$1 =\n performance$1.now ||\n performance$1.mozNow ||\n performance$1.msNow ||\n performance$1.oNow ||\n performance$1.webkitNow ||\n function(){ return (new Date()).getTime() };\n\n// generate timestamp or delta\n// see http://nodejs.org/api/process.html#process_process_hrtime\nfunction hrtime$1(previousTimestamp){\n var clocktime = performanceNow$1.call(performance$1)*1e-3;\n var seconds = Math.floor(clocktime);\n var nanoseconds = Math.floor((clocktime%1)*1e9);\n if (previousTimestamp) {\n seconds = seconds - previousTimestamp[0];\n nanoseconds = nanoseconds - previousTimestamp[1];\n if (nanoseconds<0) {\n seconds--;\n nanoseconds += 1e9;\n }\n }\n return [seconds,nanoseconds]\n}\n\nvar inherits;\nif (typeof Object.create === 'function'){\n inherits = function inherits(ctor, superCtor) {\n // implementation from standard node.js 'util' module\n ctor.super_ = superCtor;\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n };\n} else {\n inherits = function inherits(ctor, superCtor) {\n ctor.super_ = superCtor;\n var TempCtor = function () {};\n TempCtor.prototype = superCtor.prototype;\n ctor.prototype = new TempCtor();\n ctor.prototype.constructor = ctor;\n };\n}\nvar inherits$1 = inherits;\n\nvar formatRegExp = /%[sdj%]/g;\nfunction format(f) {\n if (!isString(f)) {\n var objects = [];\n for (var i = 0; i < arguments.length; i++) {\n objects.push(inspect(arguments[i]));\n }\n return objects.join(' ');\n }\n\n var i = 1;\n var args = arguments;\n var len = args.length;\n var str = String(f).replace(formatRegExp, function(x) {\n if (x === '%%') return '%';\n if (i >= len) return x;\n switch (x) {\n case '%s': return String(args[i++]);\n case '%d': return Number(args[i++]);\n case '%j':\n try {\n return JSON.stringify(args[i++]);\n } catch (_) {\n return '[Circular]';\n }\n default:\n return x;\n }\n });\n for (var x = args[i]; i < len; x = args[++i]) {\n if (isNull(x) || !isObject(x)) {\n str += ' ' + x;\n } else {\n str += ' ' + inspect(x);\n }\n }\n return str;\n}\n\n// Mark that a method should not be used.\n// Returns a modified function which warns once by default.\n// If --no-deprecation is set, then it is a no-op.\nfunction deprecate(fn, msg) {\n // Allow for deprecating things in the process of starting up.\n if (isUndefined(global.process)) {\n return function() {\n return deprecate(fn, msg).apply(this, arguments);\n };\n }\n\n if (process.noDeprecation === true) {\n return fn;\n }\n\n var warned = false;\n function deprecated() {\n if (!warned) {\n if (process.throwDeprecation) {\n throw new Error(msg);\n } else if (process.traceDeprecation) {\n console.trace(msg);\n } else {\n console.error(msg);\n }\n warned = true;\n }\n return fn.apply(this, arguments);\n }\n\n return deprecated;\n}\n\nvar debugs = {};\nvar debugEnviron;\nfunction debuglog(set) {\n if (isUndefined(debugEnviron))\n debugEnviron = process.env.NODE_DEBUG || '';\n set = set.toUpperCase();\n if (!debugs[set]) {\n if (new RegExp('\\\\b' + set + '\\\\b', 'i').test(debugEnviron)) {\n var pid = 0;\n debugs[set] = function() {\n var msg = format.apply(null, arguments);\n console.error('%s %d: %s', set, pid, msg);\n };\n } else {\n debugs[set] = function() {};\n }\n }\n return debugs[set];\n}\n\n/**\n * Echos the value of a value. Trys to print the value out\n * in the best way possible given the different types.\n *\n * @param {Object} obj The object to print out.\n * @param {Object} opts Optional options object that alters the output.\n */\n/* legacy: obj, showHidden, depth, colors*/\nfunction inspect(obj, opts) {\n // default options\n var ctx = {\n seen: [],\n stylize: stylizeNoColor\n };\n // legacy...\n if (arguments.length >= 3) ctx.depth = arguments[2];\n if (arguments.length >= 4) ctx.colors = arguments[3];\n if (isBoolean(opts)) {\n // legacy...\n ctx.showHidden = opts;\n } else if (opts) {\n // got an \"options\" object\n _extend(ctx, opts);\n }\n // set default options\n if (isUndefined(ctx.showHidden)) ctx.showHidden = false;\n if (isUndefined(ctx.depth)) ctx.depth = 2;\n if (isUndefined(ctx.colors)) ctx.colors = false;\n if (isUndefined(ctx.customInspect)) ctx.customInspect = true;\n if (ctx.colors) ctx.stylize = stylizeWithColor;\n return formatValue(ctx, obj, ctx.depth);\n}\n\n// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\ninspect.colors = {\n 'bold' : [1, 22],\n 'italic' : [3, 23],\n 'underline' : [4, 24],\n 'inverse' : [7, 27],\n 'white' : [37, 39],\n 'grey' : [90, 39],\n 'black' : [30, 39],\n 'blue' : [34, 39],\n 'cyan' : [36, 39],\n 'green' : [32, 39],\n 'magenta' : [35, 39],\n 'red' : [31, 39],\n 'yellow' : [33, 39]\n};\n\n// Don't use 'blue' not visible on cmd.exe\ninspect.styles = {\n 'special': 'cyan',\n 'number': 'yellow',\n 'boolean': 'yellow',\n 'undefined': 'grey',\n 'null': 'bold',\n 'string': 'green',\n 'date': 'magenta',\n // \"name\": intentionally not styling\n 'regexp': 'red'\n};\n\n\nfunction stylizeWithColor(str, styleType) {\n var style = inspect.styles[styleType];\n\n if (style) {\n return '\\u001b[' + inspect.colors[style][0] + 'm' + str +\n '\\u001b[' + inspect.colors[style][1] + 'm';\n } else {\n return str;\n }\n}\n\n\nfunction stylizeNoColor(str, styleType) {\n return str;\n}\n\n\nfunction arrayToHash(array) {\n var hash = {};\n\n array.forEach(function(val, idx) {\n hash[val] = true;\n });\n\n return hash;\n}\n\n\nfunction formatValue(ctx, value, recurseTimes) {\n // Provide a hook for user-specified inspect functions.\n // Check that value is an object with an inspect function on it\n if (ctx.customInspect &&\n value &&\n isFunction(value.inspect) &&\n // Filter out the util module, it's inspect function is special\n value.inspect !== inspect &&\n // Also filter out any prototype objects using the circular check.\n !(value.constructor && value.constructor.prototype === value)) {\n var ret = value.inspect(recurseTimes, ctx);\n if (!isString(ret)) {\n ret = formatValue(ctx, ret, recurseTimes);\n }\n return ret;\n }\n\n // Primitive types cannot have properties\n var primitive = formatPrimitive(ctx, value);\n if (primitive) {\n return primitive;\n }\n\n // Look up the keys of the object.\n var keys = Object.keys(value);\n var visibleKeys = arrayToHash(keys);\n\n if (ctx.showHidden) {\n keys = Object.getOwnPropertyNames(value);\n }\n\n // IE doesn't make error fields non-enumerable\n // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx\n if (isError(value)\n && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) {\n return formatError(value);\n }\n\n // Some type of object without properties can be shortcutted.\n if (keys.length === 0) {\n if (isFunction(value)) {\n var name = value.name ? ': ' + value.name : '';\n return ctx.stylize('[Function' + name + ']', 'special');\n }\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n }\n if (isDate(value)) {\n return ctx.stylize(Date.prototype.toString.call(value), 'date');\n }\n if (isError(value)) {\n return formatError(value);\n }\n }\n\n var base = '', array = false, braces = ['{', '}'];\n\n // Make Array say that they are Array\n if (isArray(value)) {\n array = true;\n braces = ['[', ']'];\n }\n\n // Make functions say that they are functions\n if (isFunction(value)) {\n var n = value.name ? ': ' + value.name : '';\n base = ' [Function' + n + ']';\n }\n\n // Make RegExps say that they are RegExps\n if (isRegExp(value)) {\n base = ' ' + RegExp.prototype.toString.call(value);\n }\n\n // Make dates with properties first say the date\n if (isDate(value)) {\n base = ' ' + Date.prototype.toUTCString.call(value);\n }\n\n // Make error with message first say the error\n if (isError(value)) {\n base = ' ' + formatError(value);\n }\n\n if (keys.length === 0 && (!array || value.length == 0)) {\n return braces[0] + base + braces[1];\n }\n\n if (recurseTimes < 0) {\n if (isRegExp(value)) {\n return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');\n } else {\n return ctx.stylize('[Object]', 'special');\n }\n }\n\n ctx.seen.push(value);\n\n var output;\n if (array) {\n output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);\n } else {\n output = keys.map(function(key) {\n return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);\n });\n }\n\n ctx.seen.pop();\n\n return reduceToSingleString(output, base, braces);\n}\n\n\nfunction formatPrimitive(ctx, value) {\n if (isUndefined(value))\n return ctx.stylize('undefined', 'undefined');\n if (isString(value)) {\n var simple = '\\'' + JSON.stringify(value).replace(/^\"|\"$/g, '')\n .replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"') + '\\'';\n return ctx.stylize(simple, 'string');\n }\n if (isNumber(value))\n return ctx.stylize('' + value, 'number');\n if (isBoolean(value))\n return ctx.stylize('' + value, 'boolean');\n // For some reason typeof null is \"object\", so special case here.\n if (isNull(value))\n return ctx.stylize('null', 'null');\n}\n\n\nfunction formatError(value) {\n return '[' + Error.prototype.toString.call(value) + ']';\n}\n\n\nfunction formatArray(ctx, value, recurseTimes, visibleKeys, keys) {\n var output = [];\n for (var i = 0, l = value.length; i < l; ++i) {\n if (hasOwnProperty(value, String(i))) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n String(i), true));\n } else {\n output.push('');\n }\n }\n keys.forEach(function(key) {\n if (!key.match(/^\\d+$/)) {\n output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,\n key, true));\n }\n });\n return output;\n}\n\n\nfunction formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {\n var name, str, desc;\n desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };\n if (desc.get) {\n if (desc.set) {\n str = ctx.stylize('[Getter/Setter]', 'special');\n } else {\n str = ctx.stylize('[Getter]', 'special');\n }\n } else {\n if (desc.set) {\n str = ctx.stylize('[Setter]', 'special');\n }\n }\n if (!hasOwnProperty(visibleKeys, key)) {\n name = '[' + key + ']';\n }\n if (!str) {\n if (ctx.seen.indexOf(desc.value) < 0) {\n if (isNull(recurseTimes)) {\n str = formatValue(ctx, desc.value, null);\n } else {\n str = formatValue(ctx, desc.value, recurseTimes - 1);\n }\n if (str.indexOf('\\n') > -1) {\n if (array) {\n str = str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n').substr(2);\n } else {\n str = '\\n' + str.split('\\n').map(function(line) {\n return ' ' + line;\n }).join('\\n');\n }\n }\n } else {\n str = ctx.stylize('[Circular]', 'special');\n }\n }\n if (isUndefined(name)) {\n if (array && key.match(/^\\d+$/)) {\n return str;\n }\n name = JSON.stringify('' + key);\n if (name.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/)) {\n name = name.substr(1, name.length - 2);\n name = ctx.stylize(name, 'name');\n } else {\n name = name.replace(/'/g, \"\\\\'\")\n .replace(/\\\\\"/g, '\"')\n .replace(/(^\"|\"$)/g, \"'\");\n name = ctx.stylize(name, 'string');\n }\n }\n\n return name + ': ' + str;\n}\n\n\nfunction reduceToSingleString(output, base, braces) {\n var length = output.reduce(function(prev, cur) {\n if (cur.indexOf('\\n') >= 0) ;\n return prev + cur.replace(/\\u001b\\[\\d\\d?m/g, '').length + 1;\n }, 0);\n\n if (length > 60) {\n return braces[0] +\n (base === '' ? '' : base + '\\n ') +\n ' ' +\n output.join(',\\n ') +\n ' ' +\n braces[1];\n }\n\n return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];\n}\n\n\n// NOTE: These type checking functions intentionally don't use `instanceof`\n// because it is fragile and can be easily faked with `Object.create()`.\nfunction isArray(ar) {\n return Array.isArray(ar);\n}\n\nfunction isBoolean(arg) {\n return typeof arg === 'boolean';\n}\n\nfunction isNull(arg) {\n return arg === null;\n}\n\nfunction isNullOrUndefined(arg) {\n return arg == null;\n}\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\n\nfunction isString(arg) {\n return typeof arg === 'string';\n}\n\nfunction isSymbol(arg) {\n return typeof arg === 'symbol';\n}\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\n\nfunction isRegExp(re) {\n return isObject(re) && objectToString(re) === '[object RegExp]';\n}\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\n\nfunction isDate(d) {\n return isObject(d) && objectToString(d) === '[object Date]';\n}\n\nfunction isError(e) {\n return isObject(e) &&\n (objectToString(e) === '[object Error]' || e instanceof Error);\n}\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\n\nfunction isPrimitive(arg) {\n return arg === null ||\n typeof arg === 'boolean' ||\n typeof arg === 'number' ||\n typeof arg === 'string' ||\n typeof arg === 'symbol' || // ES6 symbol\n typeof arg === 'undefined';\n}\n\nfunction isBuffer(maybeBuf) {\n return Buffer.isBuffer(maybeBuf);\n}\n\nfunction objectToString(o) {\n return Object.prototype.toString.call(o);\n}\n\n\nfunction pad(n) {\n return n < 10 ? '0' + n.toString(10) : n.toString(10);\n}\n\n\nvar months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',\n 'Oct', 'Nov', 'Dec'];\n\n// 26 Feb 16:19:34\nfunction timestamp() {\n var d = new Date();\n var time = [pad(d.getHours()),\n pad(d.getMinutes()),\n pad(d.getSeconds())].join(':');\n return [d.getDate(), months[d.getMonth()], time].join(' ');\n}\n\n\n// log is just a thin wrapper to console.log that prepends a timestamp\nfunction log() {\n console.log('%s - %s', timestamp(), format.apply(null, arguments));\n}\n\nfunction _extend(origin, add) {\n // Don't do anything if add isn't an object\n if (!add || !isObject(add)) return origin;\n\n var keys = Object.keys(add);\n var i = keys.length;\n while (i--) {\n origin[keys[i]] = add[keys[i]];\n }\n return origin;\n}\nfunction hasOwnProperty(obj, prop) {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nvar _polyfillNode_util = {\n inherits: inherits$1,\n _extend: _extend,\n log: log,\n isBuffer: isBuffer,\n isPrimitive: isPrimitive,\n isFunction: isFunction,\n isError: isError,\n isDate: isDate,\n isObject: isObject,\n isRegExp: isRegExp,\n isUndefined: isUndefined,\n isSymbol: isSymbol,\n isString: isString,\n isNumber: isNumber,\n isNullOrUndefined: isNullOrUndefined,\n isNull: isNull,\n isBoolean: isBoolean,\n isArray: isArray,\n inspect: inspect,\n deprecate: deprecate,\n format: format,\n debuglog: debuglog\n};\n\nvar _polyfillNode_util$1 = /*#__PURE__*/Object.freeze({\n __proto__: null,\n format: format,\n deprecate: deprecate,\n debuglog: debuglog,\n inspect: inspect,\n isArray: isArray,\n isBoolean: isBoolean,\n isNull: isNull,\n isNullOrUndefined: isNullOrUndefined,\n isNumber: isNumber,\n isString: isString,\n isSymbol: isSymbol,\n isUndefined: isUndefined,\n isRegExp: isRegExp,\n isObject: isObject,\n isDate: isDate,\n isError: isError,\n isFunction: isFunction,\n isPrimitive: isPrimitive,\n isBuffer: isBuffer,\n log: log,\n inherits: inherits$1,\n _extend: _extend,\n 'default': _polyfillNode_util\n});\n\nvar domain;\n\n// This constructor is used to store event handlers. Instantiating this is\n// faster than explicitly calling `Object.create(null)` to get a \"clean\" empty\n// object (tested with v8 v4.9).\nfunction EventHandlers() {}\nEventHandlers.prototype = Object.create(null);\n\nfunction EventEmitter() {\n EventEmitter.init.call(this);\n}\n\n// nodejs oddity\n// require('events') === require('events').EventEmitter\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.usingDomains = false;\n\nEventEmitter.prototype.domain = undefined;\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nEventEmitter.defaultMaxListeners = 10;\n\nEventEmitter.init = function() {\n this.domain = null;\n if (EventEmitter.usingDomains) {\n // if there is an active domain, then attach to it.\n if (domain.active ) ;\n }\n\n if (!this._events || this._events === Object.getPrototypeOf(this)._events) {\n this._events = new EventHandlers();\n this._eventsCount = 0;\n }\n\n this._maxListeners = this._maxListeners || undefined;\n};\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n if (typeof n !== 'number' || n < 0 || isNaN(n))\n throw new TypeError('\"n\" argument must be a positive number');\n this._maxListeners = n;\n return this;\n};\n\nfunction $getMaxListeners(that) {\n if (that._maxListeners === undefined)\n return EventEmitter.defaultMaxListeners;\n return that._maxListeners;\n}\n\nEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n return $getMaxListeners(this);\n};\n\n// These standalone emit* functions are used to optimize calling of event\n// handlers for fast cases because emit() itself often has a variable number of\n// arguments and can be deoptimized because of that. These functions always have\n// the same number of arguments and thus do not get deoptimized, so the code\n// inside them can execute faster.\nfunction emitNone(handler, isFn, self) {\n if (isFn)\n handler.call(self);\n else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n listeners[i].call(self);\n }\n}\nfunction emitOne(handler, isFn, self, arg1) {\n if (isFn)\n handler.call(self, arg1);\n else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n listeners[i].call(self, arg1);\n }\n}\nfunction emitTwo(handler, isFn, self, arg1, arg2) {\n if (isFn)\n handler.call(self, arg1, arg2);\n else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n listeners[i].call(self, arg1, arg2);\n }\n}\nfunction emitThree(handler, isFn, self, arg1, arg2, arg3) {\n if (isFn)\n handler.call(self, arg1, arg2, arg3);\n else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n listeners[i].call(self, arg1, arg2, arg3);\n }\n}\n\nfunction emitMany(handler, isFn, self, args) {\n if (isFn)\n handler.apply(self, args);\n else {\n var len = handler.length;\n var listeners = arrayClone(handler, len);\n for (var i = 0; i < len; ++i)\n listeners[i].apply(self, args);\n }\n}\n\nEventEmitter.prototype.emit = function emit(type) {\n var er, handler, len, args, i, events, domain;\n var doError = (type === 'error');\n\n events = this._events;\n if (events)\n doError = (doError && events.error == null);\n else if (!doError)\n return false;\n\n domain = this.domain;\n\n // If there is no 'error' event listener then throw.\n if (doError) {\n er = arguments[1];\n if (domain) {\n if (!er)\n er = new Error('Uncaught, unspecified \"error\" event');\n er.domainEmitter = this;\n er.domain = domain;\n er.domainThrown = false;\n domain.emit('error', er);\n } else if (er instanceof Error) {\n throw er; // Unhandled 'error' event\n } else {\n // At least give some kind of context to the user\n var err = new Error('Uncaught, unspecified \"error\" event. (' + er + ')');\n err.context = er;\n throw err;\n }\n return false;\n }\n\n handler = events[type];\n\n if (!handler)\n return false;\n\n var isFn = typeof handler === 'function';\n len = arguments.length;\n switch (len) {\n // fast cases\n case 1:\n emitNone(handler, isFn, this);\n break;\n case 2:\n emitOne(handler, isFn, this, arguments[1]);\n break;\n case 3:\n emitTwo(handler, isFn, this, arguments[1], arguments[2]);\n break;\n case 4:\n emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);\n break;\n // slower\n default:\n args = new Array(len - 1);\n for (i = 1; i < len; i++)\n args[i - 1] = arguments[i];\n emitMany(handler, isFn, this, args);\n }\n\n return true;\n};\n\nfunction _addListener(target, type, listener, prepend) {\n var m;\n var events;\n var existing;\n\n if (typeof listener !== 'function')\n throw new TypeError('\"listener\" argument must be a function');\n\n events = target._events;\n if (!events) {\n events = target._events = new EventHandlers();\n target._eventsCount = 0;\n } else {\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (events.newListener) {\n target.emit('newListener', type,\n listener.listener ? listener.listener : listener);\n\n // Re-assign `events` because a newListener handler could have caused the\n // this._events to be assigned to a new object\n events = target._events;\n }\n existing = events[type];\n }\n\n if (!existing) {\n // Optimize the case of one listener. Don't need the extra array object.\n existing = events[type] = listener;\n ++target._eventsCount;\n } else {\n if (typeof existing === 'function') {\n // Adding the second element, need to change to array.\n existing = events[type] = prepend ? [listener, existing] :\n [existing, listener];\n } else {\n // If we've already got an array, just append.\n if (prepend) {\n existing.unshift(listener);\n } else {\n existing.push(listener);\n }\n }\n\n // Check for listener leak\n if (!existing.warned) {\n m = $getMaxListeners(target);\n if (m && m > 0 && existing.length > m) {\n existing.warned = true;\n var w = new Error('Possible EventEmitter memory leak detected. ' +\n existing.length + ' ' + type + ' listeners added. ' +\n 'Use emitter.setMaxListeners() to increase limit');\n w.name = 'MaxListenersExceededWarning';\n w.emitter = target;\n w.type = type;\n w.count = existing.length;\n emitWarning(w);\n }\n }\n }\n\n return target;\n}\nfunction emitWarning(e) {\n typeof console.warn === 'function' ? console.warn(e) : console.log(e);\n}\nEventEmitter.prototype.addListener = function addListener(type, listener) {\n return _addListener(this, type, listener, false);\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.prependListener =\n function prependListener(type, listener) {\n return _addListener(this, type, listener, true);\n };\n\nfunction _onceWrap(target, type, listener) {\n var fired = false;\n function g() {\n target.removeListener(type, g);\n if (!fired) {\n fired = true;\n listener.apply(target, arguments);\n }\n }\n g.listener = listener;\n return g;\n}\n\nEventEmitter.prototype.once = function once(type, listener) {\n if (typeof listener !== 'function')\n throw new TypeError('\"listener\" argument must be a function');\n this.on(type, _onceWrap(this, type, listener));\n return this;\n};\n\nEventEmitter.prototype.prependOnceListener =\n function prependOnceListener(type, listener) {\n if (typeof listener !== 'function')\n throw new TypeError('\"listener\" argument must be a function');\n this.prependListener(type, _onceWrap(this, type, listener));\n return this;\n };\n\n// emits a 'removeListener' event iff the listener was removed\nEventEmitter.prototype.removeListener =\n function removeListener(type, listener) {\n var list, events, position, i, originalListener;\n\n if (typeof listener !== 'function')\n throw new TypeError('\"listener\" argument must be a function');\n\n events = this._events;\n if (!events)\n return this;\n\n list = events[type];\n if (!list)\n return this;\n\n if (list === listener || (list.listener && list.listener === listener)) {\n if (--this._eventsCount === 0)\n this._events = new EventHandlers();\n else {\n delete events[type];\n if (events.removeListener)\n this.emit('removeListener', type, list.listener || listener);\n }\n } else if (typeof list !== 'function') {\n position = -1;\n\n for (i = list.length; i-- > 0;) {\n if (list[i] === listener ||\n (list[i].listener && list[i].listener === listener)) {\n originalListener = list[i].listener;\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (list.length === 1) {\n list[0] = undefined;\n if (--this._eventsCount === 0) {\n this._events = new EventHandlers();\n return this;\n } else {\n delete events[type];\n }\n } else {\n spliceOne(list, position);\n }\n\n if (events.removeListener)\n this.emit('removeListener', type, originalListener || listener);\n }\n\n return this;\n };\n \n// Alias for removeListener added in NodeJS 10.0\n// https://nodejs.org/api/events.html#events_emitter_off_eventname_listener\nEventEmitter.prototype.off = function(type, listener){\n return this.removeListener(type, listener);\n};\n\nEventEmitter.prototype.removeAllListeners =\n function removeAllListeners(type) {\n var listeners, events;\n\n events = this._events;\n if (!events)\n return this;\n\n // not listening for removeListener, no need to emit\n if (!events.removeListener) {\n if (arguments.length === 0) {\n this._events = new EventHandlers();\n this._eventsCount = 0;\n } else if (events[type]) {\n if (--this._eventsCount === 0)\n this._events = new EventHandlers();\n else\n delete events[type];\n }\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n var keys = Object.keys(events);\n for (var i = 0, key; i < keys.length; ++i) {\n key = keys[i];\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = new EventHandlers();\n this._eventsCount = 0;\n return this;\n }\n\n listeners = events[type];\n\n if (typeof listeners === 'function') {\n this.removeListener(type, listeners);\n } else if (listeners) {\n // LIFO order\n do {\n this.removeListener(type, listeners[listeners.length - 1]);\n } while (listeners[0]);\n }\n\n return this;\n };\n\nEventEmitter.prototype.listeners = function listeners(type) {\n var evlistener;\n var ret;\n var events = this._events;\n\n if (!events)\n ret = [];\n else {\n evlistener = events[type];\n if (!evlistener)\n ret = [];\n else if (typeof evlistener === 'function')\n ret = [evlistener.listener || evlistener];\n else\n ret = unwrapListeners(evlistener);\n }\n\n return ret;\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n if (typeof emitter.listenerCount === 'function') {\n return emitter.listenerCount(type);\n } else {\n return listenerCount.call(emitter, type);\n }\n};\n\nEventEmitter.prototype.listenerCount = listenerCount;\nfunction listenerCount(type) {\n var events = this._events;\n\n if (events) {\n var evlistener = events[type];\n\n if (typeof evlistener === 'function') {\n return 1;\n } else if (evlistener) {\n return evlistener.length;\n }\n }\n\n return 0;\n}\n\nEventEmitter.prototype.eventNames = function eventNames() {\n return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];\n};\n\n// About 1.5x faster than the two-arg version of Array#splice().\nfunction spliceOne(list, index) {\n for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)\n list[i] = list[k];\n list.pop();\n}\n\nfunction arrayClone(arr, i) {\n var copy = new Array(i);\n while (i--)\n copy[i] = arr[i];\n return copy;\n}\n\nfunction unwrapListeners(arr) {\n var ret = new Array(arr.length);\n for (var i = 0; i < ret.length; ++i) {\n ret[i] = arr[i].listener || arr[i];\n }\n return ret;\n}\n\nvar _polyfillNode_events = /*#__PURE__*/Object.freeze({\n __proto__: null,\n 'default': EventEmitter,\n EventEmitter: EventEmitter\n});\n\nvar util = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(_polyfillNode_util$1);\n\nvar events = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(_polyfillNode_events);\n\n// Simple OOP Tools for Node.JS\n// Copyright (c) 2014 Joseph Huckaby\n// Released under the MIT License\n\n\n\n\nvar create = function create(members) {\n\t// create new class using php-style syntax (sort of)\n\tif (!members) members = {};\n\t\n\t// setup constructor\n\tvar constructor = null;\n\t\n\t// inherit from parent class\n\tif (members.__parent) {\n\t\tif (members.__construct) {\n\t\t\t// explicit constructor passed in\n\t\t\tconstructor = members.__construct;\n\t\t}\n\t\telse {\n\t\t\t// inherit parent's constructor\n\t\t\tvar parent = members.__parent;\n\t\t\tconstructor = function() {\n\t\t\t\tvar args = Array.prototype.slice.call(arguments);\n\t\t\t\tparent.apply( this, args );\n\t\t\t};\n\t\t}\n\t\t\n\t\t// inherit rest of parent members\n\t\tutil.inherits(constructor, members.__parent);\n\t\tdelete members.__parent;\n\t}\n\telse {\n\t\t// create new base class\n\t\tconstructor = members.__construct || function() {};\n\t}\n\tdelete members.__construct;\n\t\n\t// handle static variables\n\tif (members.__static) {\n\t\tfor (var key in members.__static) {\n\t\t\tconstructor[key] = members.__static[key];\n\t\t}\n\t\tdelete members.__static;\n\t}\n\t\n\t// all classes are event emitters unless explicitly disabled\n\tif (members.__events !== false) {\n\t\tif (!members.__mixins) members.__mixins = [];\n\t\tif (members.__mixins.indexOf(events.EventEmitter) == -1) {\n\t\t\tmembers.__mixins.push( events.EventEmitter );\n\t\t}\n\t}\n\tdelete members.__events;\n\t\n\t// handle mixins\n\tif (members.__mixins) {\n\t\tfor (var idx = 0, len = members.__mixins.length; idx < len; idx++) {\n\t\t\tvar class_obj = members.__mixins[idx];\n\t\t\t\n\t\t\tfor (var key in class_obj.prototype) {\n\t\t\t\tif (!key.match(/^__/) && (typeof(constructor.prototype[key]) == 'undefined')) {\n\t\t\t\t\tconstructor.prototype[key] = class_obj.prototype[key];\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar static_members = class_obj.__static;\n\t\t\tif (static_members) {\n\t\t\t\tfor (var key in static_members) {\n\t\t\t\t\tif (typeof(constructor[key]) == 'undefined') constructor[key] = static_members[key];\n\t\t\t\t}\n\t\t\t}\n\t\t} // foreach mixin\n\t\tdelete members.__mixins;\n\t} // mixins\n\t\n\t// handle promisify (node 8+)\n\tif (members.__promisify && util.promisify) {\n\t\tif (Array.isArray(members.__promisify)) {\n\t\t\t// promisify some\n\t\t\tmembers.__promisify.forEach( function(key) {\n\t\t\t\tif (typeof(members[key]) == 'function') {\n\t\t\t\t\tmembers[key] = util.promisify( members[key] );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t\telse {\n\t\t\t// promisify all\n\t\t\tfor (var key in members) {\n\t\t\t\tif (!key.match(/^__/) && (typeof(members[key]) == 'function')) {\n\t\t\t\t\tmembers[key] = util.promisify( members[key] );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tdelete members.__promisify;\n\t}\n\t\n\t// fill prototype members\n\tfor (var key in members) {\n\t\tconstructor.prototype[key] = members[key];\n\t}\n\t\n\t// return completed class definition\n\treturn constructor;\n};\n\nvar _class = {\n\tcreate: create\n};\n\n// High Resolution Performance Tracker for Node.JS\n// Copyright (c) 2014 Joseph Huckaby\n// Released under the MIT License\n\n\n\nvar perf = _class.create({\n\t\n\tperf: null,\n\tcounters: null,\n\tscale: 1000, // milliseconds\n\tprecision: 1000, // 3 digits\n\ttotalKey: 'total', // where to store the total\n\tminMax: false, // track min/avg/max per metric\n\t\n\t__events: false,\n\t\n\t__construct: function() {\n\t\t// class constructor\n\t\tthis.reset();\n\t},\n\t\n\treset: function() {\n\t\t// reset everything\n\t\tthis.perf = {};\n\t\tthis.counters = {};\n\t},\n\t\n\tsetScale: function(scale) { \n\t\t// set scale for time measurements\n\t\t// 1000000000 == nanoseconds\n\t\t// 1000000 == microseconds\n\t\t// 1000 == milliseconds\n\t\t// 1 == seconds\n\t\tthis.scale = scale; \n\t},\n\t\n\tsetPrecision: function(precision) {\n\t\t// set precision for measurements\n\t\t// 1 == integers only\n\t\t// 10 == 1 digit after the decimal\n\t\t// 100 == 2 digits after the decimal\n\t\t// 1000 == 3 digits after the decimal\n\t\tthis.precision = precision; \n\t},\n\t\n\tcalcElapsed: function(start) {\n\t\t// calculate elapsed time using process.hrtime() (nanoseconds)\n\t\t// then convert to our scale and precision\n\t\tvar diff = process.hrtime( start );\n\t\tvar nano = diff[0] * 1e9 + diff[1];\n\t\t\n\t\t// apply scale transform\n\t\tvar value = nano / (1000000000 / this.scale);\n\t\t\n\t\treturn value;\n\t},\n\t\n\tbegin: function(id) {\n\t\t// begin tracking metric\n\t\t// ID defaults to 't' for total\n\t\tif (!id) id = this.totalKey;\n\t\tvar now = process.hrtime();\n\t\t\n\t\t// only allow 't' begin to be called once per object (unless it is reset)\n\t\tif ((id == this.totalKey) && this.perf[id]) return;\n\t\t\n\t\t// set start time\n\t\tif (!this.perf[id]) this.perf[id] = { elapsed: 0 };\n\t\tthis.perf[id].start = now;\n\t\tif (this.perf[id].end) delete this.perf[id].end;\n\t\t\n\t\treturn new PerfMetric(this, id, now);\n\t},\n\t\n\tend: function(id, start) {\n\t\t// mark end of metric\n\t\t// ID defaults to 't' for total\n\t\tif (!id) id = this.totalKey;\n\t\tvar now = process.hrtime();\n\t\t\n\t\tif (!this.perf[id] && !start) return;\n\t\tif (!this.perf[id]) this.perf[id] = { elapsed: 0 };\n\t\tvar obj = this.perf[id];\n\t\t\n\t\tif (start) obj.start = start;\n\t\tobj.end = now;\n\t\tif (!obj.start) obj.start = obj.end;\n\t\t\n\t\tvar elapsed = Array.isArray(obj.start) ? \n\t\t\tthis.calcElapsed( obj.start ) : 0;\n\t\t\n\t\tif (id == this.totalKey) {\n\t\t\t// end of all tracking\n\t\t\t// set elapsed instead of incrementing, to prevent bugs with calling end() twice.\n\t\t\tobj.elapsed = elapsed;\n\t\t}\n\t\telse {\n\t\t\t// stopped tracking single metric\n\t\t\t// increment elapsed to allow for multiple trackings on same metric\n\t\t\tobj.elapsed += elapsed;\n\t\t}\n\t\t\n\t\tif (this.minMax) {\n\t\t\tif (!obj.count || (elapsed < obj.min)) obj.min = elapsed;\n\t\t\tif (!obj.count || (elapsed > obj.max)) obj.max = elapsed;\n\t\t\tif (!obj.count) obj.count = 0;\n\t\t\tobj.count++;\n\t\t}\n\t\t\n\t\treturn this.formatValue(elapsed);\n\t},\n\t\n\tcount: function(id, amount) {\n\t\t// increment (or decrement) simple counter, unrelated to time measurement\n\t\tif (typeof(amount) == 'undefined') amount = 1;\n\t\tif (!(id in this.counters)) this.counters[id] = amount;\n\t\telse this.counters[id] += amount;\n\t},\n\t\n\tmetrics: function() {\n\t\t// get all perf metrics and counters in simple object format\n\t\tvar out = {};\n\t\t\n\t\t// make sure total metric is ended\n\t\tthis.end();\n\t\t\n\t\t// generate object containing only elapsed times of each\n\t\tfor (var id in this.perf) {\n\t\t\tif (this.perf[id].end) {\n\t\t\t\tout[id] = this.elapsed(id, true);\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn {\n\t\t\tscale: this.scale,\n\t\t\tperf: out,\n\t\t\tcounters: this.counters\n\t\t};\n\t},\n\t\n\tjson: function() {\n\t\t// return a JSON string with perf metrics and counters separated out\n\t\treturn JSON.stringify( this.metrics() );\n\t},\n\t\n\tsummarize: function(prefix) {\n\t\t// Summarize performance metrics in query string format\n\t\tvar pairs = [];\n\t\tvar metrics = this.metrics();\n\t\tif (!prefix) prefix = '';\n\t\t\n\t\t// start with scale\n\t\tpairs.push( 'scale=' + this.scale );\n\t\t\n\t\t// make sure total is always right after scale\n\t\tpairs.push( 'total=' + metrics.perf.total );\n\t\tdelete metrics.perf.total;\n\t\t\n\t\t// build summary string of other metrics\n\t\tfor (var id in metrics.perf) {\n\t\t\tpairs.push( prefix + id + '=' + metrics.perf[id] );\n\t\t}\n\t\t\n\t\t// add counters if applicable, prefix each with c_\n\t\tfor (var id in metrics.counters) {\n\t\t\tvar disp_id = id.match(/^c_/) ? id : ('c_'+id);\n\t\t\tpairs.push( disp_id + '=' + metrics.counters[id] );\n\t\t}\n\t\t\n\t\treturn pairs.join('&');\n\t},\n\t\n\telapsed: function(id, display_format) {\n\t\t// get elapsed seconds from given metric\n\t\tif (!this.perf[id]) return 0;\n\t\tif (!this.perf[id].elapsed) return 0;\n\t\t\n\t\tif (display_format) {\n\t\t\treturn this.formatValue( this.perf[id].elapsed );\n\t\t}\n\t\telse return this.perf[id].elapsed;\n\t},\n\t\n\tget: function() {\n\t\t// Get raw perf object\n\t\treturn this.perf;\n\t},\n\t\n\tgetCounters: function() {\n\t\t// Get raw counters object\n\t\treturn this.counters;\n\t},\n\t\n\tformatValue: function(value) {\n\t\t// format value according to our precision\n\t\treturn Math.floor(value * this.precision) / this.precision;\n\t},\n\t\n\tgetMinMaxMetrics: function() {\n\t\t// get min/max/avg/count/total for each named metric (omits total)\n\t\t// special 'minMax' mode must be enabled\n\t\tif (!this.minMax) return {};\n\t\tvar metrics = {};\n\t\t\n\t\tfor (var id in this.perf) {\n\t\t\tvar obj = this.perf[id];\n\t\t\tif (obj.end && (id != this.totalKey)) {\n\t\t\t\tif (!obj.elapsed) obj.elapsed = 0;\n\t\t\t\tmetrics[id] = {\n\t\t\t\t\tmin: this.formatValue( obj.min || 0 ),\n\t\t\t\t\tmax: this.formatValue( obj.max || 0 ),\n\t\t\t\t\ttotal: this.formatValue( obj.elapsed ),\n\t\t\t\t\tcount: obj.count || 0,\n\t\t\t\t\tavg: this.formatValue( obj.elapsed / (obj.count || 1) )\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\t\n\t\treturn metrics;\n\t},\n\t\n\timport: function(perf, prefix) {\n\t\t// import perf metrics from another object (and adjust scale to match)\n\t\t// can be a pixl-perf instance, or an object from calling metrics()\n\t\tif (!prefix) prefix = '';\n\t\t\n\t\tif (perf.perf) {\n\t\t\tfor (var key in perf.perf) {\n\t\t\t\tif (key != this.totalKey) {\n\t\t\t\t\tvar pkey = prefix + key;\n\t\t\t\t\tif (!this.perf[pkey]) this.perf[pkey] = {};\n\t\t\t\t\tif (!this.perf[pkey].end) this.perf[pkey].end = 1;\n\t\t\t\t\tif (!this.perf[pkey].elapsed) this.perf[pkey].elapsed = 0;\n\t\t\t\t\tvar elapsed = (typeof(perf.perf[key]) == 'number') ? perf.perf[key] : perf.perf[key].elapsed;\n\t\t\t\t\tthis.perf[pkey].elapsed += (elapsed / (perf.scale / this.scale)) || 0;\n\t\t\t\t\t\n\t\t\t\t\tif (this.minMax && perf.minMax) {\n\t\t\t\t\t\t// both source and dest have minMax, so import entire min/max/count\n\t\t\t\t\t\tvar adj_min = perf.perf[key].min / (perf.scale / this.scale);\n\t\t\t\t\t\tif (!this.perf[pkey].count || (adj_min < this.perf[pkey].min)) this.perf[pkey].min = adj_min;\n\t\t\t\t\t\t\n\t\t\t\t\t\tvar adj_max = perf.perf[key].max / (perf.scale / this.scale);\n\t\t\t\t\t\tif (!this.perf[pkey].count || (adj_max > this.perf[pkey].max)) this.perf[pkey].max = adj_max;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (!this.perf[pkey].count) this.perf[pkey].count = 0;\n\t\t\t\t\t\tthis.perf[pkey].count += perf.perf[key].count || 0;\n\t\t\t\t\t} // minMax\n\t\t\t\t\telse if (this.minMax) {\n\t\t\t\t\t\t// source has no minMax, but dest does, so just import their elapsed as one measurement\n\t\t\t\t\t\tvar adj_elapsed = (elapsed / (perf.scale / this.scale)) || 0;\n\t\t\t\t\t\tif (!this.perf[pkey].count || (adj_elapsed < this.perf[pkey].min)) this.perf[pkey].min = adj_elapsed;\n\t\t\t\t\t\tif (!this.perf[pkey].count || (adj_elapsed > this.perf[pkey].max)) this.perf[pkey].max = adj_elapsed;\n\t\t\t\t\t\tif (!this.perf[pkey].count) this.perf[pkey].count = 0;\n\t\t\t\t\t\tthis.perf[pkey].count++;\n\t\t\t\t\t}\n\t\t\t\t} // not totalKey\n\t\t\t} // foreach perf\n\t\t} // perf.perf\n\t\t\n\t\tif (perf.counters) {\n\t\t\tfor (var key in perf.counters) {\n\t\t\t\tvar pkey = prefix + key;\n\t\t\t\tthis.count( pkey, perf.counters[key] );\n\t\t\t}\n\t\t}\n\t}\n\t\n});\n\n// A PerfMetric promise is returned from each call to begin(),\n// so the user can track multiple simultaneous metrics with the same key.\n\nvar PerfMetric = _class.create({\n\t\n\t__events: false,\n\t\n\tperf: null,\n\tid: '',\n\tstart: 0,\n\t\n\t__construct: function(perf, id, start) {\n\t\t// class constructor\n\t\tthis.perf = perf;\n\t\tthis.id = id;\n\t\tthis.start = start;\n\t},\n\t\n\tend: function() {\n\t\t// end tracking\n\t\treturn this.perf.end(this.id, this.start);\n\t}\n\t\n});\n\n// canvas-plus - Image Transformation Engine\n// Canvas Create Mixin - Browser Version\n// Copyright (c) 2017 Joseph Huckaby\n// Released under the MIT License\n\n\n\nvar create$1 = _class.create({\n\t\n\tcreate: function(opts, callback) {\n\t\t// create new canvas, with optional background color\n\t\t// opts: { width, height, background }\n\t\tthis.clearLastError();\n\t\tif (!this.get('origWidth')) this.perf.begin('create');\n\t\t\n\t\topts = this.copyHash( opts || {} );\n\t\topts = this.applySettings(opts);\n\t\t\n\t\tvar width = opts.width;\n\t\tvar height = opts.height;\n\t\tvar background = opts.background;\n\t\t\n\t\tthis.set('width', width);\n\t\tthis.set('height', height);\n\t\t\n\t\tthis.logDebug(5, \"Creating new canvas: \" + width + 'x' + height, { background: background || '(transparent)' });\n\t\t\n\t\t// sanity check\n\t\tif (!width || isNaN(parseInt(width)) || !height || isNaN(parseInt(height))) {\n\t\t\treturn this.doError('create', \"Invalid image dimensions: \" + width + 'x' + height, callback);\n\t\t}\n\t\t\n\t\t// check max area\n\t\tif (this.get('maxArea')) {\n\t\t\tvar area = width * height;\n\t\t\tif (area > this.get('maxArea')) {\n\t\t\t\treturn this.doError('create', \"Image dimensions are too large: \" + width + 'x' + height, callback);\n\t\t\t}\n\t\t}\n\t\t\n\t\t// create canvas\n\t\tthis.canvas = document.createElement('canvas');\n\t\tthis.canvas.width = width;\n\t\tthis.canvas.height = height;\n\t\tthis.context = this.canvas.getContext('2d');\n\t\t\n\t\t// apply settings\n\t\tfor (var key in this.canvasSettingsKeys) {\n\t\t\tthis.context[key] = this.settings[key];\n\t\t}\n\t\t\n\t\t// fill background if desired\n\t\tif (background) {\n\t\t\tthis.context.save();\n\t\t\tthis.context.globalCompositeOperation = 'copy';\n\t\t\tthis.context.fillStyle = background;\n\t\t\tthis.context.fillRect( 0, 0, width, height );\n\t\t\tthis.context.restore();\n\t\t}\n\t\t\n\t\tthis.set('mode', 'rgba');\n\t\t\n\t\tif (!this.get('origWidth')) {\n\t\t\tthis.perf.end('create');\n\t\t\tthis.set('origWidth', this.get('width'));\n\t\t\tthis.set('origHeight', this.get('height'));\n\t\t}\n\t\t\n\t\tthis.logDebug(5, \"Canvas created successfully\");\n\t\tif (callback) callback();\n\t\t\n\t\t// for chaining\n\t\treturn this;\n\t}\n\t\t\n});\n\n// canvas-plus - Image Transformation Engine\n// Canvas Font Mixin - Browser Version\n// Copyright (c) 2017 Joseph Huckaby\n// Released under the MIT License\n\n\nvar fonts_loaded = {};\n\nvar font = _class.create({\n\t\n\tgetFontID: function(family) {\n\t\t// family is font ID for browser\n\t\treturn family;\n\t},\n\t\n\tloadFont: function(family, url, callback) {\n\t\t// load CSS font family in browser, callback is optional\n\t\tvar self = this;\n\t\t\n\t\tif (family in fonts_loaded) {\n\t\t\tif (callback) callback();\n\t\t\treturn;\n\t\t}\n\t\tfonts_loaded[family] = 1;\n\t\t\n\t\t// sniff format from URL\n\t\tif (url.match(/\\.(\\w+)(\\?|$)/)) {\n\t\t\tvar fmt = RegExp.$1;\n\t\t\tif (fmt.match(/ttf/i)) fmt = 'truetype';\n\t\t\telse if (fmt.match(/otf/i)) fmt = 'opentype';\n\t\t\t\n\t\t\tvar pf = this.perf.begin('font');\n\t\t\t\n\t\t\tvar sty = document.createElement('style');\n\t\t\tsty.type = 'text/css';\n\t\t\tsty.innerHTML = \"@font-face { font-family:'\" + family + \"'; src:url('\" + url + \"') format('\" + fmt + \"'); }\\n\";\n\t\t\t(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(sty);\n\t\t\t\n\t\t\tonFontReady(family, function() {\n\t\t\t\tpf.end();\n\t\t\t\tself.logDebug(5, \"Font loaded successfully: \" + family + \": \" + url);\n\t\t\t\tif (callback) callback();\n\t\t\t}, \n\t\t\t{\n\t\t\t\ttimeoutAfter: 5000,\n\t\t\t\tonTimeout: function() {\n\t\t\t\t\tpf.end();\n\t\t\t\t\treturn self.doError( 'font', \"Failed to load font after 5 seconds: \" + family, callback );\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tself.doError( 'font', \"Cannot determine font format from URL: \" + url, callback );\n\t\t}\n\t}\n\t\n});\n\n// onFontReady (MIT License)\n// https://github.com/dwighthouse/onfontready/blob/master/LICENSE\nfunction onFontReady(e,t,i,n,o){i=i||0,i.timeoutAfter&&setTimeout(function(){n&&(document.body.removeChild(n),n=0,i.onTimeout&&i.onTimeout());},i.timeoutAfter),o=function(){n&&n.firstChild.clientWidth==n.lastChild.clientWidth&&(document.body.removeChild(n),n=0,t());},o(document.body.appendChild(n=document.createElement(\"div\")).innerHTML='