{"version":3,"file":"productDetail.bundle.js","sources":["webpack:///webpack/bootstrap","webpack:///./node_modules/base64-js/index.js","webpack:///./node_modules/buffer/index.js","webpack:///./node_modules/clone/clone.js","webpack:///./node_modules/ieee754/index.js","webpack:///./node_modules/isarray/index.js","webpack:///./node_modules/material-design-iconic-font/dist/css/material-design-iconic-font.css?7e35","webpack:///./node_modules/mithril-tsx-component/index.js","webpack:///./node_modules/mithril/api/mount-redraw.js","webpack:///./node_modules/mithril/api/router.js","webpack:///./node_modules/mithril/hyperscript.js","webpack:///./node_modules/mithril/index.js","webpack:///./node_modules/mithril/mount-redraw.js","webpack:///./node_modules/mithril/pathname/assign.js","webpack:///./node_modules/mithril/pathname/build.js","webpack:///./node_modules/mithril/pathname/compileTemplate.js","webpack:///./node_modules/mithril/pathname/parse.js","webpack:///./node_modules/mithril/promise/polyfill.js","webpack:///./node_modules/mithril/promise/promise.js","webpack:///./node_modules/mithril/querystring/build.js","webpack:///./node_modules/mithril/querystring/parse.js","webpack:///./node_modules/mithril/render.js","webpack:///./node_modules/mithril/render/fragment.js","webpack:///./node_modules/mithril/render/hyperscript.js","webpack:///./node_modules/mithril/render/hyperscriptVnode.js","webpack:///./node_modules/mithril/render/render.js","webpack:///./node_modules/mithril/render/trust.js","webpack:///./node_modules/mithril/render/vnode.js","webpack:///./node_modules/mithril/request.js","webpack:///./node_modules/mithril/request/request.js","webpack:///./node_modules/mithril/route.js","webpack:///./node_modules/oj-ajax/dist/index.js","webpack:///./node_modules/oj-component/dist/index.js","webpack:///./node_modules/oj-dom-utils/dist/index.js","webpack:///./node_modules/oj-draggable/dist/index.js","webpack:///./node_modules/oj-event/dist/index.js","webpack:///./node_modules/oj-eventaggregator/dist/index.js","webpack:///./node_modules/oj-form-validator/dist/index.js","webpack:///./node_modules/oj-mithril-packages/dist/BasicTooltip/index.js","webpack:///./node_modules/oj-mithril-packages/dist/Button/index.js","webpack:///./node_modules/oj-mithril-packages/dist/Carousel/index.js","webpack:///./node_modules/oj-mithril-packages/dist/Carousel/style.scss?1ff3","webpack:///./node_modules/oj-mithril-packages/dist/Dialog/index.js","webpack:///./node_modules/oj-mithril-packages/dist/FormGroup/index.js","webpack:///./node_modules/oj-mithril-packages/dist/FormGroup/style.scss?5480","webpack:///./node_modules/oj-mithril-packages/dist/Gallery/index.js","webpack:///./node_modules/oj-mithril-packages/dist/ImageZoom/index.js","webpack:///./node_modules/oj-mithril-packages/dist/ImageZoom/style.scss?d0ef","webpack:///./node_modules/oj-mithril-packages/dist/Label/index.js","webpack:///./node_modules/oj-mithril-packages/dist/Radio/index.js","webpack:///./node_modules/oj-mithril-packages/dist/Select/index.js","webpack:///./node_modules/oj-mithril-packages/dist/Select/style.scss?4e7e","webpack:///./node_modules/oj-mithril-packages/dist/Svg/index.js","webpack:///./node_modules/oj-mithril-packages/dist/Tabs/index.js","webpack:///./node_modules/oj-mithril-packages/dist/Tabs/style.scss?fd39","webpack:///./node_modules/oj-mithril-packages/dist/Zmdi/index.js","webpack:///./node_modules/oj-mithril-packages/dist/utils/types.js","webpack:///./node_modules/oj-mithril-utils/dist/index.js","webpack:///./node_modules/oj-promise-utils/dist/index.js","webpack:///./node_modules/oj-utils/dist/index.js","webpack:///./node_modules/process/browser.js","webpack:///./node_modules/setimmediate/setImmediate.js","webpack:///./node_modules/timers-browserify/main.js","webpack:///(webpack)/buildin/global.js","webpack:///./src/ts/components/ProductConfiguration/DeliveryOptions.tsx","webpack:///./src/ts/components/ProductConfiguration/Index.tsx","webpack:///./src/ts/components/ProductConfiguration/PackagingSelection.tsx","webpack:///./src/ts/components/ProductConfiguration/PriceOptions.tsx","webpack:///./src/ts/components/ProductConfiguration/ProductOptions.tsx","webpack:///./src/ts/components/ProductConfiguration/SelectedPackage.tsx","webpack:///./src/ts/components/ProductConfiguration/Utils.tsx","webpack:///./src/ts/components/UI/Button.tsx","webpack:///./src/ts/components/UI/Form.tsx","webpack:///./src/ts/components/UI/NotificationDialog.tsx","webpack:///./src/ts/components/UI/Price.tsx","webpack:///./src/ts/components/UI/ProductGallery.tsx","webpack:///./src/ts/components/UI/ProductSlider.tsx","webpack:///./src/ts/components/UI/Toast.tsx","webpack:///./src/ts/editor/editorGallery.tsx","webpack:///./src/ts/eventAggregator.ts","webpack:///./src/ts/pages/productDetail.tsx","webpack:///./src/ts/tagmanager.ts","webpack:///./src/ts/utils/index.ts","webpack:///./src/ts/validation.ts"],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/frontend/dist/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/ts/pages/productDetail.tsx\");\n","'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nvar base64 = require('base64-js')\nvar ieee754 = require('ieee754')\nvar isArray = require('isarray')\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Use Object implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * Due to various browser bugs, sometimes the Object implementation will be used even\n * when the browser supports typed arrays.\n *\n * Note:\n *\n * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,\n * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.\n *\n * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.\n *\n * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of\n * incorrect length in some situations.\n\n * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they\n * get the Object implementation, which is slower but behaves correctly.\n */\nBuffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined\n ? global.TYPED_ARRAY_SUPPORT\n : typedArraySupport()\n\n/*\n * Export kMaxLength after typed array support is determined.\n */\nexports.kMaxLength = kMaxLength()\n\nfunction typedArraySupport () {\n try {\n var arr = new Uint8Array(1)\n arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}\n return arr.foo() === 42 && // typed array instances can be augmented\n typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`\n arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`\n } catch (e) {\n return false\n }\n}\n\nfunction kMaxLength () {\n return Buffer.TYPED_ARRAY_SUPPORT\n ? 0x7fffffff\n : 0x3fffffff\n}\n\nfunction createBuffer (that, length) {\n if (kMaxLength() < length) {\n throw new RangeError('Invalid typed array length')\n }\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = new Uint8Array(length)\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n if (that === null) {\n that = new Buffer(length)\n }\n that.length = length\n }\n\n return that\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {\n return new Buffer(arg, encodingOrOffset, length)\n }\n\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new Error(\n 'If encoding is specified then the first argument must be a string'\n )\n }\n return allocUnsafe(this, arg)\n }\n return from(this, arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\n// TODO: Legacy, not needed anymore. Remove in next major version.\nBuffer._augment = function (arr) {\n arr.__proto__ = Buffer.prototype\n return arr\n}\n\nfunction from (that, value, encodingOrOffset, length) {\n if (typeof value === 'number') {\n throw new TypeError('\"value\" argument must not be a number')\n }\n\n if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {\n return fromArrayBuffer(that, value, encodingOrOffset, length)\n }\n\n if (typeof value === 'string') {\n return fromString(that, value, encodingOrOffset)\n }\n\n return fromObject(that, value)\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(null, value, encodingOrOffset, length)\n}\n\nif (Buffer.TYPED_ARRAY_SUPPORT) {\n Buffer.prototype.__proto__ = Uint8Array.prototype\n Buffer.__proto__ = Uint8Array\n if (typeof Symbol !== 'undefined' && Symbol.species &&\n Buffer[Symbol.species] === Buffer) {\n // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97\n Object.defineProperty(Buffer, Symbol.species, {\n value: null,\n configurable: true\n })\n }\n}\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be a number')\n } else if (size < 0) {\n throw new RangeError('\"size\" argument must not be negative')\n }\n}\n\nfunction alloc (that, size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(that, size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpretted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(that, size).fill(fill, encoding)\n : createBuffer(that, size).fill(fill)\n }\n return createBuffer(that, size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(null, size, fill, encoding)\n}\n\nfunction allocUnsafe (that, size) {\n assertSize(size)\n that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) {\n for (var i = 0; i < size; ++i) {\n that[i] = 0\n }\n }\n return that\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(null, size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(null, size)\n}\n\nfunction fromString (that, string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('\"encoding\" must be a valid string encoding')\n }\n\n var length = byteLength(string, encoding) | 0\n that = createBuffer(that, length)\n\n var actual = that.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n that = that.slice(0, actual)\n }\n\n return that\n}\n\nfunction fromArrayLike (that, array) {\n var length = array.length < 0 ? 0 : checked(array.length) | 0\n that = createBuffer(that, length)\n for (var i = 0; i < length; i += 1) {\n that[i] = array[i] & 255\n }\n return that\n}\n\nfunction fromArrayBuffer (that, array, byteOffset, length) {\n array.byteLength // this throws if `array` is not a valid ArrayBuffer\n\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\\'offset\\' is out of bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\\'length\\' is out of bounds')\n }\n\n if (byteOffset === undefined && length === undefined) {\n array = new Uint8Array(array)\n } else if (length === undefined) {\n array = new Uint8Array(array, byteOffset)\n } else {\n array = new Uint8Array(array, byteOffset, length)\n }\n\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n // Return an augmented `Uint8Array` instance, for best performance\n that = array\n that.__proto__ = Buffer.prototype\n } else {\n // Fallback: Return an object instance of the Buffer class\n that = fromArrayLike(that, array)\n }\n return that\n}\n\nfunction fromObject (that, obj) {\n if (Buffer.isBuffer(obj)) {\n var len = checked(obj.length) | 0\n that = createBuffer(that, len)\n\n if (that.length === 0) {\n return that\n }\n\n obj.copy(that, 0, 0, len)\n return that\n }\n\n if (obj) {\n if ((typeof ArrayBuffer !== 'undefined' &&\n obj.buffer instanceof ArrayBuffer) || 'length' in obj) {\n if (typeof obj.length !== 'number' || isnan(obj.length)) {\n return createBuffer(that, 0)\n }\n return fromArrayLike(that, obj)\n }\n\n if (obj.type === 'Buffer' && isArray(obj.data)) {\n return fromArrayLike(that, obj.data)\n }\n }\n\n throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')\n}\n\nfunction checked (length) {\n // Note: cannot use `length < kMaxLength()` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= kMaxLength()) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + kMaxLength().toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return !!(b != null && b._isBuffer)\n}\n\nBuffer.compare = function compare (a, b) {\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError('Arguments must be Buffers')\n }\n\n if (a === b) return 0\n\n var x = a.length\n var y = b.length\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n var i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n var buffer = Buffer.allocUnsafe(length)\n var pos = 0\n for (i = 0; i < list.length; ++i) {\n var buf = list[i]\n if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n buf.copy(buffer, pos)\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&\n (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n string = '' + string\n }\n\n var len = string.length\n if (len === 0) return 0\n\n // Use a for loop to avoid recursion\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n case undefined:\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) return utf8ToBytes(string).length // assume utf8\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n var loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coersion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect\n// Buffer instances.\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n var i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n var len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (var i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n var len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (var i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n var len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (var i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n var length = this.length | 0\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n var str = ''\n var max = exports.INSPECT_MAX_BYTES\n if (this.length > 0) {\n str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')\n if (this.length > max) str += ' ... '\n }\n return ''\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (!Buffer.isBuffer(target)) {\n throw new TypeError('Argument must be a Buffer')\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n var x = thisEnd - thisStart\n var y = end - start\n var len = Math.min(x, y)\n\n var thisCopy = this.slice(thisStart, thisEnd)\n var targetCopy = target.slice(start, end)\n\n for (var i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (isNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (Buffer.TYPED_ARRAY_SUPPORT &&\n typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n var indexSize = 1\n var arrLength = arr.length\n var valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n var i\n if (dir) {\n var foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n var found = true\n for (var j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n var remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n // must be an even number of digits\n var strLen = string.length\n if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n for (var i = 0; i < length; ++i) {\n var parsed = parseInt(string.substr(i * 2, 2), 16)\n if (isNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction latin1Write (buf, string, offset, length) {\n return asciiWrite(buf, string, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset | 0\n if (isFinite(length)) {\n length = length | 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n // legacy write(string, encoding, offset, length) - remove in v0.13\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n var remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n var loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n return asciiWrite(this, string, offset, length)\n\n case 'latin1':\n case 'binary':\n return latin1Write(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n var res = []\n\n var i = start\n while (i < end) {\n var firstByte = buf[i]\n var codePoint = null\n var bytesPerSequence = (firstByte > 0xEF) ? 4\n : (firstByte > 0xDF) ? 3\n : (firstByte > 0xBF) ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n var secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nvar MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n var len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n var res = ''\n var i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n var ret = ''\n end = Math.min(buf.length, end)\n\n for (var i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n var len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n var out = ''\n for (var i = start; i < end; ++i) {\n out += toHex(buf[i])\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n var bytes = buf.slice(start, end)\n var res = ''\n for (var i = 0; i < bytes.length; i += 2) {\n res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n var len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n var newBuf\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n newBuf = this.subarray(start, end)\n newBuf.__proto__ = Buffer.prototype\n } else {\n var sliceLen = end - start\n newBuf = new Buffer(sliceLen, undefined)\n for (var i = 0; i < sliceLen; ++i) {\n newBuf[i] = this[i + start]\n }\n }\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n var val = this[offset + --byteLength]\n var mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var val = this[offset]\n var mul = 1\n var i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n var i = byteLength\n var mul = 1\n var val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 2, this.length)\n var val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var mul = 1\n var i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n byteLength = byteLength | 0\n if (!noAssert) {\n var maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n var i = byteLength - 1\n var mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nfunction objectWriteUInt16 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {\n buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>\n (littleEndian ? i : 1 - i) * 8\n }\n}\n\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nfunction objectWriteUInt32 (buf, value, offset, littleEndian) {\n if (value < 0) value = 0xffffffff + value + 1\n for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {\n buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff\n }\n}\n\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = 0\n var mul = 1\n var sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) {\n var limit = Math.pow(2, 8 * byteLength - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n var i = byteLength - 1\n var mul = 1\n var sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n } else {\n objectWriteUInt16(this, value, offset, true)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n } else {\n objectWriteUInt16(this, value, offset, false)\n }\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n } else {\n objectWriteUInt32(this, value, offset, true)\n }\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset | 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n if (Buffer.TYPED_ARRAY_SUPPORT) {\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n } else {\n objectWriteUInt32(this, value, offset, false)\n }\n return offset + 4\n}\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n var len = end - start\n var i\n\n if (this === target && start < targetStart && targetStart < end) {\n // descending copy from end\n for (i = len - 1; i >= 0; --i) {\n target[i + targetStart] = this[i + start]\n }\n } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {\n // ascending copy from start\n for (i = 0; i < len; ++i) {\n target[i + targetStart] = this[i + start]\n }\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, start + len),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (val.length === 1) {\n var code = val.charCodeAt(0)\n if (code < 256) {\n val = code\n }\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n } else if (typeof val === 'number') {\n val = val & 255\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n var i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n var bytes = Buffer.isBuffer(val)\n ? val\n : utf8ToBytes(new Buffer(val, encoding).toString())\n var len = bytes.length\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// HELPER FUNCTIONS\n// ================\n\nvar INVALID_BASE64_RE = /[^+\\/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = stringtrim(str).replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction stringtrim (str) {\n if (str.trim) return str.trim()\n return str.replace(/^\\s+|\\s+$/g, '')\n}\n\nfunction toHex (n) {\n if (n < 16) return '0' + n.toString(16)\n return n.toString(16)\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n var codePoint\n var length = string.length\n var leadSurrogate = null\n var bytes = []\n\n for (var i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n var c, hi, lo\n var byteArray = []\n for (var i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n for (var i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\nfunction isnan (val) {\n return val !== val // eslint-disable-line no-self-compare\n}\n","var clone = (function() {\n'use strict';\n\nfunction _instanceof(obj, type) {\n return type != null && obj instanceof type;\n}\n\nvar nativeMap;\ntry {\n nativeMap = Map;\n} catch(_) {\n // maybe a reference error because no `Map`. Give it a dummy value that no\n // value will ever be an instanceof.\n nativeMap = function() {};\n}\n\nvar nativeSet;\ntry {\n nativeSet = Set;\n} catch(_) {\n nativeSet = function() {};\n}\n\nvar nativePromise;\ntry {\n nativePromise = Promise;\n} catch(_) {\n nativePromise = function() {};\n}\n\n/**\n * Clones (copies) an Object using deep copying.\n *\n * This function supports circular references by default, but if you are certain\n * there are no circular references in your object, you can save some CPU time\n * by calling clone(obj, false).\n *\n * Caution: if `circular` is false and `parent` contains circular references,\n * your program may enter an infinite loop and crash.\n *\n * @param `parent` - the object to be cloned\n * @param `circular` - set to true if the object to be cloned may contain\n * circular references. (optional - true by default)\n * @param `depth` - set to a number if the object is only to be cloned to\n * a particular depth. (optional - defaults to Infinity)\n * @param `prototype` - sets the prototype to be used when cloning an object.\n * (optional - defaults to parent prototype).\n * @param `includeNonEnumerable` - set to true if the non-enumerable properties\n * should be cloned as well. Non-enumerable properties on the prototype\n * chain will be ignored. (optional - false by default)\n*/\nfunction clone(parent, circular, depth, prototype, includeNonEnumerable) {\n if (typeof circular === 'object') {\n depth = circular.depth;\n prototype = circular.prototype;\n includeNonEnumerable = circular.includeNonEnumerable;\n circular = circular.circular;\n }\n // maintain two arrays for circular references, where corresponding parents\n // and children have the same index\n var allParents = [];\n var allChildren = [];\n\n var useBuffer = typeof Buffer != 'undefined';\n\n if (typeof circular == 'undefined')\n circular = true;\n\n if (typeof depth == 'undefined')\n depth = Infinity;\n\n // recurse this function so we don't reset allParents and allChildren\n function _clone(parent, depth) {\n // cloning null always returns null\n if (parent === null)\n return null;\n\n if (depth === 0)\n return parent;\n\n var child;\n var proto;\n if (typeof parent != 'object') {\n return parent;\n }\n\n if (_instanceof(parent, nativeMap)) {\n child = new nativeMap();\n } else if (_instanceof(parent, nativeSet)) {\n child = new nativeSet();\n } else if (_instanceof(parent, nativePromise)) {\n child = new nativePromise(function (resolve, reject) {\n parent.then(function(value) {\n resolve(_clone(value, depth - 1));\n }, function(err) {\n reject(_clone(err, depth - 1));\n });\n });\n } else if (clone.__isArray(parent)) {\n child = [];\n } else if (clone.__isRegExp(parent)) {\n child = new RegExp(parent.source, __getRegExpFlags(parent));\n if (parent.lastIndex) child.lastIndex = parent.lastIndex;\n } else if (clone.__isDate(parent)) {\n child = new Date(parent.getTime());\n } else if (useBuffer && Buffer.isBuffer(parent)) {\n if (Buffer.allocUnsafe) {\n // Node.js >= 4.5.0\n child = Buffer.allocUnsafe(parent.length);\n } else {\n // Older Node.js versions\n child = new Buffer(parent.length);\n }\n parent.copy(child);\n return child;\n } else if (_instanceof(parent, Error)) {\n child = Object.create(parent);\n } else {\n if (typeof prototype == 'undefined') {\n proto = Object.getPrototypeOf(parent);\n child = Object.create(proto);\n }\n else {\n child = Object.create(prototype);\n proto = prototype;\n }\n }\n\n if (circular) {\n var index = allParents.indexOf(parent);\n\n if (index != -1) {\n return allChildren[index];\n }\n allParents.push(parent);\n allChildren.push(child);\n }\n\n if (_instanceof(parent, nativeMap)) {\n parent.forEach(function(value, key) {\n var keyChild = _clone(key, depth - 1);\n var valueChild = _clone(value, depth - 1);\n child.set(keyChild, valueChild);\n });\n }\n if (_instanceof(parent, nativeSet)) {\n parent.forEach(function(value) {\n var entryChild = _clone(value, depth - 1);\n child.add(entryChild);\n });\n }\n\n for (var i in parent) {\n var attrs;\n if (proto) {\n attrs = Object.getOwnPropertyDescriptor(proto, i);\n }\n\n if (attrs && attrs.set == null) {\n continue;\n }\n child[i] = _clone(parent[i], depth - 1);\n }\n\n if (Object.getOwnPropertySymbols) {\n var symbols = Object.getOwnPropertySymbols(parent);\n for (var i = 0; i < symbols.length; i++) {\n // Don't need to worry about cloning a symbol because it is a primitive,\n // like a number or string.\n var symbol = symbols[i];\n var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);\n if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {\n continue;\n }\n child[symbol] = _clone(parent[symbol], depth - 1);\n if (!descriptor.enumerable) {\n Object.defineProperty(child, symbol, {\n enumerable: false\n });\n }\n }\n }\n\n if (includeNonEnumerable) {\n var allPropertyNames = Object.getOwnPropertyNames(parent);\n for (var i = 0; i < allPropertyNames.length; i++) {\n var propertyName = allPropertyNames[i];\n var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);\n if (descriptor && descriptor.enumerable) {\n continue;\n }\n child[propertyName] = _clone(parent[propertyName], depth - 1);\n Object.defineProperty(child, propertyName, {\n enumerable: false\n });\n }\n }\n\n return child;\n }\n\n return _clone(parent, depth);\n}\n\n/**\n * Simple flat clone using prototype, accepts only objects, usefull for property\n * override on FLAT configuration object (no nested props).\n *\n * USE WITH CAUTION! This may not behave as you wish if you do not know how this\n * works.\n */\nclone.clonePrototype = function clonePrototype(parent) {\n if (parent === null)\n return null;\n\n var c = function () {};\n c.prototype = parent;\n return new c();\n};\n\n// private utility functions\n\nfunction __objToStr(o) {\n return Object.prototype.toString.call(o);\n}\nclone.__objToStr = __objToStr;\n\nfunction __isDate(o) {\n return typeof o === 'object' && __objToStr(o) === '[object Date]';\n}\nclone.__isDate = __isDate;\n\nfunction __isArray(o) {\n return typeof o === 'object' && __objToStr(o) === '[object Array]';\n}\nclone.__isArray = __isArray;\n\nfunction __isRegExp(o) {\n return typeof o === 'object' && __objToStr(o) === '[object RegExp]';\n}\nclone.__isRegExp = __isRegExp;\n\nfunction __getRegExpFlags(re) {\n var flags = '';\n if (re.global) flags += 'g';\n if (re.ignoreCase) flags += 'i';\n if (re.multiline) flags += 'm';\n return flags;\n}\nclone.__getRegExpFlags = __getRegExpFlags;\n\nreturn clone;\n})();\n\nif (typeof module === 'object' && module.exports) {\n module.exports = clone;\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","var toString = {}.toString;\n\nmodule.exports = Array.isArray || function (arr) {\n return toString.call(arr) == '[object Array]';\n};\n","// extracted by mini-css-extract-plugin","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nvar MithrilTsxComponent = /** @class */ (function () {\n function MithrilTsxComponent() {\n }\n return MithrilTsxComponent;\n}());\nexports.MithrilTsxComponent = MithrilTsxComponent;\n","\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\nmodule.exports = function(render, schedule, console) {\n\tvar subscriptions = []\n\tvar rendering = false\n\tvar pending = false\n\n\tfunction sync() {\n\t\tif (rendering) throw new Error(\"Nested m.redraw.sync() call\")\n\t\trendering = true\n\t\tfor (var i = 0; i < subscriptions.length; i += 2) {\n\t\t\ttry { render(subscriptions[i], Vnode(subscriptions[i + 1]), redraw) }\n\t\t\tcatch (e) { console.error(e) }\n\t\t}\n\t\trendering = false\n\t}\n\n\tfunction redraw() {\n\t\tif (!pending) {\n\t\t\tpending = true\n\t\t\tschedule(function() {\n\t\t\t\tpending = false\n\t\t\t\tsync()\n\t\t\t})\n\t\t}\n\t}\n\n\tredraw.sync = sync\n\n\tfunction mount(root, component) {\n\t\tif (component != null && component.view == null && typeof component !== \"function\") {\n\t\t\tthrow new TypeError(\"m.mount(element, component) expects a component, not a vnode\")\n\t\t}\n\n\t\tvar index = subscriptions.indexOf(root)\n\t\tif (index >= 0) {\n\t\t\tsubscriptions.splice(index, 2)\n\t\t\trender(root, [], redraw)\n\t\t}\n\n\t\tif (component != null) {\n\t\t\tsubscriptions.push(root, component)\n\t\t\trender(root, Vnode(component), redraw)\n\t\t}\n\t}\n\n\treturn {mount: mount, redraw: redraw}\n}\n","\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\nvar m = require(\"../render/hyperscript\")\nvar Promise = require(\"../promise/promise\")\n\nvar buildPathname = require(\"../pathname/build\")\nvar parsePathname = require(\"../pathname/parse\")\nvar compileTemplate = require(\"../pathname/compileTemplate\")\nvar assign = require(\"../pathname/assign\")\n\nvar sentinel = {}\n\nmodule.exports = function($window, mountRedraw) {\n\tvar fireAsync\n\n\tfunction setPath(path, data, options) {\n\t\tpath = buildPathname(path, data)\n\t\tif (fireAsync != null) {\n\t\t\tfireAsync()\n\t\t\tvar state = options ? options.state : null\n\t\t\tvar title = options ? options.title : null\n\t\t\tif (options && options.replace) $window.history.replaceState(state, title, route.prefix + path)\n\t\t\telse $window.history.pushState(state, title, route.prefix + path)\n\t\t}\n\t\telse {\n\t\t\t$window.location.href = route.prefix + path\n\t\t}\n\t}\n\n\tvar currentResolver = sentinel, component, attrs, currentPath, lastUpdate\n\n\tvar SKIP = route.SKIP = {}\n\n\tfunction route(root, defaultRoute, routes) {\n\t\tif (root == null) throw new Error(\"Ensure the DOM element that was passed to `m.route` is not undefined\")\n\t\t// 0 = start\n\t\t// 1 = init\n\t\t// 2 = ready\n\t\tvar state = 0\n\n\t\tvar compiled = Object.keys(routes).map(function(route) {\n\t\t\tif (route[0] !== \"/\") throw new SyntaxError(\"Routes must start with a `/`\")\n\t\t\tif ((/:([^\\/\\.-]+)(\\.{3})?:/).test(route)) {\n\t\t\t\tthrow new SyntaxError(\"Route parameter names must be separated with either `/`, `.`, or `-`\")\n\t\t\t}\n\t\t\treturn {\n\t\t\t\troute: route,\n\t\t\t\tcomponent: routes[route],\n\t\t\t\tcheck: compileTemplate(route),\n\t\t\t}\n\t\t})\n\t\tvar callAsync = typeof setImmediate === \"function\" ? setImmediate : setTimeout\n\t\tvar p = Promise.resolve()\n\t\tvar scheduled = false\n\t\tvar onremove\n\n\t\tfireAsync = null\n\n\t\tif (defaultRoute != null) {\n\t\t\tvar defaultData = parsePathname(defaultRoute)\n\n\t\t\tif (!compiled.some(function (i) { return i.check(defaultData) })) {\n\t\t\t\tthrow new ReferenceError(\"Default route doesn't match any known routes\")\n\t\t\t}\n\t\t}\n\n\t\tfunction resolveRoute() {\n\t\t\tscheduled = false\n\t\t\t// Consider the pathname holistically. The prefix might even be invalid,\n\t\t\t// but that's not our problem.\n\t\t\tvar prefix = $window.location.hash\n\t\t\tif (route.prefix[0] !== \"#\") {\n\t\t\t\tprefix = $window.location.search + prefix\n\t\t\t\tif (route.prefix[0] !== \"?\") {\n\t\t\t\t\tprefix = $window.location.pathname + prefix\n\t\t\t\t\tif (prefix[0] !== \"/\") prefix = \"/\" + prefix\n\t\t\t\t}\n\t\t\t}\n\t\t\t// This seemingly useless `.concat()` speeds up the tests quite a bit,\n\t\t\t// since the representation is consistently a relatively poorly\n\t\t\t// optimized cons string.\n\t\t\tvar path = prefix.concat()\n\t\t\t\t.replace(/(?:%[a-f89][a-f0-9])+/gim, decodeURIComponent)\n\t\t\t\t.slice(route.prefix.length)\n\t\t\tvar data = parsePathname(path)\n\n\t\t\tassign(data.params, $window.history.state)\n\n\t\t\tfunction fail() {\n\t\t\t\tif (path === defaultRoute) throw new Error(\"Could not resolve default route \" + defaultRoute)\n\t\t\t\tsetPath(defaultRoute, null, {replace: true})\n\t\t\t}\n\n\t\t\tloop(0)\n\t\t\tfunction loop(i) {\n\t\t\t\t// 0 = init\n\t\t\t\t// 1 = scheduled\n\t\t\t\t// 2 = done\n\t\t\t\tfor (; i < compiled.length; i++) {\n\t\t\t\t\tif (compiled[i].check(data)) {\n\t\t\t\t\t\tvar payload = compiled[i].component\n\t\t\t\t\t\tvar matchedRoute = compiled[i].route\n\t\t\t\t\t\tvar localComp = payload\n\t\t\t\t\t\tvar update = lastUpdate = function(comp) {\n\t\t\t\t\t\t\tif (update !== lastUpdate) return\n\t\t\t\t\t\t\tif (comp === SKIP) return loop(i + 1)\n\t\t\t\t\t\t\tcomponent = comp != null && (typeof comp.view === \"function\" || typeof comp === \"function\")? comp : \"div\"\n\t\t\t\t\t\t\tattrs = data.params, currentPath = path, lastUpdate = null\n\t\t\t\t\t\t\tcurrentResolver = payload.render ? payload : null\n\t\t\t\t\t\t\tif (state === 2) mountRedraw.redraw()\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tstate = 2\n\t\t\t\t\t\t\t\tmountRedraw.redraw.sync()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// There's no understating how much I *wish* I could\n\t\t\t\t\t\t// use `async`/`await` here...\n\t\t\t\t\t\tif (payload.view || typeof payload === \"function\") {\n\t\t\t\t\t\t\tpayload = {}\n\t\t\t\t\t\t\tupdate(localComp)\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (payload.onmatch) {\n\t\t\t\t\t\t\tp.then(function () {\n\t\t\t\t\t\t\t\treturn payload.onmatch(data.params, path, matchedRoute)\n\t\t\t\t\t\t\t}).then(update, fail)\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse update(\"div\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfail()\n\t\t\t}\n\t\t}\n\n\t\t// Set it unconditionally so `m.route.set` and `m.route.Link` both work,\n\t\t// even if neither `pushState` nor `hashchange` are supported. It's\n\t\t// cleared if `hashchange` is used, since that makes it automatically\n\t\t// async.\n\t\tfireAsync = function() {\n\t\t\tif (!scheduled) {\n\t\t\t\tscheduled = true\n\t\t\t\tcallAsync(resolveRoute)\n\t\t\t}\n\t\t}\n\n\t\tif (typeof $window.history.pushState === \"function\") {\n\t\t\tonremove = function() {\n\t\t\t\t$window.removeEventListener(\"popstate\", fireAsync, false)\n\t\t\t}\n\t\t\t$window.addEventListener(\"popstate\", fireAsync, false)\n\t\t} else if (route.prefix[0] === \"#\") {\n\t\t\tfireAsync = null\n\t\t\tonremove = function() {\n\t\t\t\t$window.removeEventListener(\"hashchange\", resolveRoute, false)\n\t\t\t}\n\t\t\t$window.addEventListener(\"hashchange\", resolveRoute, false)\n\t\t}\n\n\t\treturn mountRedraw.mount(root, {\n\t\t\tonbeforeupdate: function() {\n\t\t\t\tstate = state ? 2 : 1\n\t\t\t\treturn !(!state || sentinel === currentResolver)\n\t\t\t},\n\t\t\toncreate: resolveRoute,\n\t\t\tonremove: onremove,\n\t\t\tview: function() {\n\t\t\t\tif (!state || sentinel === currentResolver) return\n\t\t\t\t// Wrap in a fragment to preserve existing key semantics\n\t\t\t\tvar vnode = [Vnode(component, attrs.key, attrs)]\n\t\t\t\tif (currentResolver) vnode = currentResolver.render(vnode[0])\n\t\t\t\treturn vnode\n\t\t\t},\n\t\t})\n\t}\n\troute.set = function(path, data, options) {\n\t\tif (lastUpdate != null) {\n\t\t\toptions = options || {}\n\t\t\toptions.replace = true\n\t\t}\n\t\tlastUpdate = null\n\t\tsetPath(path, data, options)\n\t}\n\troute.get = function() {return currentPath}\n\troute.prefix = \"#!\"\n\troute.Link = {\n\t\tview: function(vnode) {\n\t\t\tvar options = vnode.attrs.options\n\t\t\t// Remove these so they don't get overwritten\n\t\t\tvar attrs = {}, onclick, href\n\t\t\tassign(attrs, vnode.attrs)\n\t\t\t// The first two are internal, but the rest are magic attributes\n\t\t\t// that need censored to not screw up rendering.\n\t\t\tattrs.selector = attrs.options = attrs.key = attrs.oninit =\n\t\t\tattrs.oncreate = attrs.onbeforeupdate = attrs.onupdate =\n\t\t\tattrs.onbeforeremove = attrs.onremove = null\n\n\t\t\t// Do this now so we can get the most current `href` and `disabled`.\n\t\t\t// Those attributes may also be specified in the selector, and we\n\t\t\t// should honor that.\n\t\t\tvar child = m(vnode.attrs.selector || \"a\", attrs, vnode.children)\n\n\t\t\t// Let's provide a *right* way to disable a route link, rather than\n\t\t\t// letting people screw up accessibility on accident.\n\t\t\t//\n\t\t\t// The attribute is coerced so users don't get surprised over\n\t\t\t// `disabled: 0` resulting in a button that's somehow routable\n\t\t\t// despite being visibly disabled.\n\t\t\tif (child.attrs.disabled = Boolean(child.attrs.disabled)) {\n\t\t\t\tchild.attrs.href = null\n\t\t\t\tchild.attrs[\"aria-disabled\"] = \"true\"\n\t\t\t\t// If you *really* do want to do this on a disabled link, use\n\t\t\t\t// an `oncreate` hook to add it.\n\t\t\t\tchild.attrs.onclick = null\n\t\t\t} else {\n\t\t\t\tonclick = child.attrs.onclick\n\t\t\t\thref = child.attrs.href\n\t\t\t\tchild.attrs.href = route.prefix + href\n\t\t\t\tchild.attrs.onclick = function(e) {\n\t\t\t\t\tvar result\n\t\t\t\t\tif (typeof onclick === \"function\") {\n\t\t\t\t\t\tresult = onclick.call(e.currentTarget, e)\n\t\t\t\t\t} else if (onclick == null || typeof onclick !== \"object\") {\n\t\t\t\t\t\t// do nothing\n\t\t\t\t\t} else if (typeof onclick.handleEvent === \"function\") {\n\t\t\t\t\t\tonclick.handleEvent(e)\n\t\t\t\t\t}\n\n\t\t\t\t\t// Adapted from React Router's implementation:\n\t\t\t\t\t// https://github.com/ReactTraining/react-router/blob/520a0acd48ae1b066eb0b07d6d4d1790a1d02482/packages/react-router-dom/modules/Link.js\n\t\t\t\t\t//\n\t\t\t\t\t// Try to be flexible and intuitive in how we handle links.\n\t\t\t\t\t// Fun fact: links aren't as obvious to get right as you\n\t\t\t\t\t// would expect. There's a lot more valid ways to click a\n\t\t\t\t\t// link than this, and one might want to not simply click a\n\t\t\t\t\t// link, but right click or command-click it to copy the\n\t\t\t\t\t// link target, etc. Nope, this isn't just for blind people.\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Skip if `onclick` prevented default\n\t\t\t\t\t\tresult !== false && !e.defaultPrevented &&\n\t\t\t\t\t\t// Ignore everything but left clicks\n\t\t\t\t\t\t(e.button === 0 || e.which === 0 || e.which === 1) &&\n\t\t\t\t\t\t// Let the browser handle `target=_blank`, etc.\n\t\t\t\t\t\t(!e.currentTarget.target || e.currentTarget.target === \"_self\") &&\n\t\t\t\t\t\t// No modifier keys\n\t\t\t\t\t\t!e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey\n\t\t\t\t\t) {\n\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\te.redraw = false\n\t\t\t\t\t\troute.set(href, null, options)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn child\n\t\t},\n\t}\n\troute.param = function(key) {\n\t\treturn attrs && key != null ? attrs[key] : attrs\n\t}\n\n\treturn route\n}\n","\"use strict\"\n\nvar hyperscript = require(\"./render/hyperscript\")\n\nhyperscript.trust = require(\"./render/trust\")\nhyperscript.fragment = require(\"./render/fragment\")\n\nmodule.exports = hyperscript\n","\"use strict\"\n\nvar hyperscript = require(\"./hyperscript\")\nvar request = require(\"./request\")\nvar mountRedraw = require(\"./mount-redraw\")\n\nvar m = function m() { return hyperscript.apply(this, arguments) }\nm.m = hyperscript\nm.trust = hyperscript.trust\nm.fragment = hyperscript.fragment\nm.mount = mountRedraw.mount\nm.route = require(\"./route\")\nm.render = require(\"./render\")\nm.redraw = mountRedraw.redraw\nm.request = request.request\nm.jsonp = request.jsonp\nm.parseQueryString = require(\"./querystring/parse\")\nm.buildQueryString = require(\"./querystring/build\")\nm.parsePathname = require(\"./pathname/parse\")\nm.buildPathname = require(\"./pathname/build\")\nm.vnode = require(\"./render/vnode\")\nm.PromisePolyfill = require(\"./promise/polyfill\")\n\nmodule.exports = m\n","\"use strict\"\n\nvar render = require(\"./render\")\n\nmodule.exports = require(\"./api/mount-redraw\")(render, requestAnimationFrame, console)\n","\"use strict\"\n\nmodule.exports = Object.assign || function(target, source) {\n\tif(source) Object.keys(source).forEach(function(key) { target[key] = source[key] })\n}\n","\"use strict\"\n\nvar buildQueryString = require(\"../querystring/build\")\nvar assign = require(\"./assign\")\n\n// Returns `path` from `template` + `params`\nmodule.exports = function(template, params) {\n\tif ((/:([^\\/\\.-]+)(\\.{3})?:/).test(template)) {\n\t\tthrow new SyntaxError(\"Template parameter names *must* be separated\")\n\t}\n\tif (params == null) return template\n\tvar queryIndex = template.indexOf(\"?\")\n\tvar hashIndex = template.indexOf(\"#\")\n\tvar queryEnd = hashIndex < 0 ? template.length : hashIndex\n\tvar pathEnd = queryIndex < 0 ? queryEnd : queryIndex\n\tvar path = template.slice(0, pathEnd)\n\tvar query = {}\n\n\tassign(query, params)\n\n\tvar resolved = path.replace(/:([^\\/\\.-]+)(\\.{3})?/g, function(m, key, variadic) {\n\t\tdelete query[key]\n\t\t// If no such parameter exists, don't interpolate it.\n\t\tif (params[key] == null) return m\n\t\t// Escape normal parameters, but not variadic ones.\n\t\treturn variadic ? params[key] : encodeURIComponent(String(params[key]))\n\t})\n\n\t// In case the template substitution adds new query/hash parameters.\n\tvar newQueryIndex = resolved.indexOf(\"?\")\n\tvar newHashIndex = resolved.indexOf(\"#\")\n\tvar newQueryEnd = newHashIndex < 0 ? resolved.length : newHashIndex\n\tvar newPathEnd = newQueryIndex < 0 ? newQueryEnd : newQueryIndex\n\tvar result = resolved.slice(0, newPathEnd)\n\n\tif (queryIndex >= 0) result += template.slice(queryIndex, queryEnd)\n\tif (newQueryIndex >= 0) result += (queryIndex < 0 ? \"?\" : \"&\") + resolved.slice(newQueryIndex, newQueryEnd)\n\tvar querystring = buildQueryString(query)\n\tif (querystring) result += (queryIndex < 0 && newQueryIndex < 0 ? \"?\" : \"&\") + querystring\n\tif (hashIndex >= 0) result += template.slice(hashIndex)\n\tif (newHashIndex >= 0) result += (hashIndex < 0 ? \"\" : \"&\") + resolved.slice(newHashIndex)\n\treturn result\n}\n","\"use strict\"\n\nvar parsePathname = require(\"./parse\")\n\n// Compiles a template into a function that takes a resolved path (without query\n// strings) and returns an object containing the template parameters with their\n// parsed values. This expects the input of the compiled template to be the\n// output of `parsePathname`. Note that it does *not* remove query parameters\n// specified in the template.\nmodule.exports = function(template) {\n\tvar templateData = parsePathname(template)\n\tvar templateKeys = Object.keys(templateData.params)\n\tvar keys = []\n\tvar regexp = new RegExp(\"^\" + templateData.path.replace(\n\t\t// I escape literal text so people can use things like `:file.:ext` or\n\t\t// `:lang-:locale` in routes. This is all merged into one pass so I\n\t\t// don't also accidentally escape `-` and make it harder to detect it to\n\t\t// ban it from template parameters.\n\t\t/:([^\\/.-]+)(\\.{3}|\\.(?!\\.)|-)?|[\\\\^$*+.()|\\[\\]{}]/g,\n\t\tfunction(m, key, extra) {\n\t\t\tif (key == null) return \"\\\\\" + m\n\t\t\tkeys.push({k: key, r: extra === \"...\"})\n\t\t\tif (extra === \"...\") return \"(.*)\"\n\t\t\tif (extra === \".\") return \"([^/]+)\\\\.\"\n\t\t\treturn \"([^/]+)\" + (extra || \"\")\n\t\t}\n\t) + \"$\")\n\treturn function(data) {\n\t\t// First, check the params. Usually, there isn't any, and it's just\n\t\t// checking a static set.\n\t\tfor (var i = 0; i < templateKeys.length; i++) {\n\t\t\tif (templateData.params[templateKeys[i]] !== data.params[templateKeys[i]]) return false\n\t\t}\n\t\t// If no interpolations exist, let's skip all the ceremony\n\t\tif (!keys.length) return regexp.test(data.path)\n\t\tvar values = regexp.exec(data.path)\n\t\tif (values == null) return false\n\t\tfor (var i = 0; i < keys.length; i++) {\n\t\t\tdata.params[keys[i].k] = keys[i].r ? values[i + 1] : decodeURIComponent(values[i + 1])\n\t\t}\n\t\treturn true\n\t}\n}\n","\"use strict\"\n\nvar parseQueryString = require(\"../querystring/parse\")\n\n// Returns `{path, params}` from `url`\nmodule.exports = function(url) {\n\tvar queryIndex = url.indexOf(\"?\")\n\tvar hashIndex = url.indexOf(\"#\")\n\tvar queryEnd = hashIndex < 0 ? url.length : hashIndex\n\tvar pathEnd = queryIndex < 0 ? queryEnd : queryIndex\n\tvar path = url.slice(0, pathEnd).replace(/\\/{2,}/g, \"/\")\n\n\tif (!path) path = \"/\"\n\telse {\n\t\tif (path[0] !== \"/\") path = \"/\" + path\n\t\tif (path.length > 1 && path[path.length - 1] === \"/\") path = path.slice(0, -1)\n\t}\n\treturn {\n\t\tpath: path,\n\t\tparams: queryIndex < 0\n\t\t\t? {}\n\t\t\t: parseQueryString(url.slice(queryIndex + 1, queryEnd)),\n\t}\n}\n","\"use strict\"\n/** @constructor */\nvar PromisePolyfill = function(executor) {\n\tif (!(this instanceof PromisePolyfill)) throw new Error(\"Promise must be called with `new`\")\n\tif (typeof executor !== \"function\") throw new TypeError(\"executor must be a function\")\n\n\tvar self = this, resolvers = [], rejectors = [], resolveCurrent = handler(resolvers, true), rejectCurrent = handler(rejectors, false)\n\tvar instance = self._instance = {resolvers: resolvers, rejectors: rejectors}\n\tvar callAsync = typeof setImmediate === \"function\" ? setImmediate : setTimeout\n\tfunction handler(list, shouldAbsorb) {\n\t\treturn function execute(value) {\n\t\t\tvar then\n\t\t\ttry {\n\t\t\t\tif (shouldAbsorb && value != null && (typeof value === \"object\" || typeof value === \"function\") && typeof (then = value.then) === \"function\") {\n\t\t\t\t\tif (value === self) throw new TypeError(\"Promise can't be resolved w/ itself\")\n\t\t\t\t\texecuteOnce(then.bind(value))\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tcallAsync(function() {\n\t\t\t\t\t\tif (!shouldAbsorb && list.length === 0) console.error(\"Possible unhandled promise rejection:\", value)\n\t\t\t\t\t\tfor (var i = 0; i < list.length; i++) list[i](value)\n\t\t\t\t\t\tresolvers.length = 0, rejectors.length = 0\n\t\t\t\t\t\tinstance.state = shouldAbsorb\n\t\t\t\t\t\tinstance.retry = function() {execute(value)}\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (e) {\n\t\t\t\trejectCurrent(e)\n\t\t\t}\n\t\t}\n\t}\n\tfunction executeOnce(then) {\n\t\tvar runs = 0\n\t\tfunction run(fn) {\n\t\t\treturn function(value) {\n\t\t\t\tif (runs++ > 0) return\n\t\t\t\tfn(value)\n\t\t\t}\n\t\t}\n\t\tvar onerror = run(rejectCurrent)\n\t\ttry {then(run(resolveCurrent), onerror)} catch (e) {onerror(e)}\n\t}\n\n\texecuteOnce(executor)\n}\nPromisePolyfill.prototype.then = function(onFulfilled, onRejection) {\n\tvar self = this, instance = self._instance\n\tfunction handle(callback, list, next, state) {\n\t\tlist.push(function(value) {\n\t\t\tif (typeof callback !== \"function\") next(value)\n\t\t\telse try {resolveNext(callback(value))} catch (e) {if (rejectNext) rejectNext(e)}\n\t\t})\n\t\tif (typeof instance.retry === \"function\" && state === instance.state) instance.retry()\n\t}\n\tvar resolveNext, rejectNext\n\tvar promise = new PromisePolyfill(function(resolve, reject) {resolveNext = resolve, rejectNext = reject})\n\thandle(onFulfilled, instance.resolvers, resolveNext, true), handle(onRejection, instance.rejectors, rejectNext, false)\n\treturn promise\n}\nPromisePolyfill.prototype.catch = function(onRejection) {\n\treturn this.then(null, onRejection)\n}\nPromisePolyfill.prototype.finally = function(callback) {\n\treturn this.then(\n\t\tfunction(value) {\n\t\t\treturn PromisePolyfill.resolve(callback()).then(function() {\n\t\t\t\treturn value\n\t\t\t})\n\t\t},\n\t\tfunction(reason) {\n\t\t\treturn PromisePolyfill.resolve(callback()).then(function() {\n\t\t\t\treturn PromisePolyfill.reject(reason);\n\t\t\t})\n\t\t}\n\t)\n}\nPromisePolyfill.resolve = function(value) {\n\tif (value instanceof PromisePolyfill) return value\n\treturn new PromisePolyfill(function(resolve) {resolve(value)})\n}\nPromisePolyfill.reject = function(value) {\n\treturn new PromisePolyfill(function(resolve, reject) {reject(value)})\n}\nPromisePolyfill.all = function(list) {\n\treturn new PromisePolyfill(function(resolve, reject) {\n\t\tvar total = list.length, count = 0, values = []\n\t\tif (list.length === 0) resolve([])\n\t\telse for (var i = 0; i < list.length; i++) {\n\t\t\t(function(i) {\n\t\t\t\tfunction consume(value) {\n\t\t\t\t\tcount++\n\t\t\t\t\tvalues[i] = value\n\t\t\t\t\tif (count === total) resolve(values)\n\t\t\t\t}\n\t\t\t\tif (list[i] != null && (typeof list[i] === \"object\" || typeof list[i] === \"function\") && typeof list[i].then === \"function\") {\n\t\t\t\t\tlist[i].then(consume, reject)\n\t\t\t\t}\n\t\t\t\telse consume(list[i])\n\t\t\t})(i)\n\t\t}\n\t})\n}\nPromisePolyfill.race = function(list) {\n\treturn new PromisePolyfill(function(resolve, reject) {\n\t\tfor (var i = 0; i < list.length; i++) {\n\t\t\tlist[i].then(resolve, reject)\n\t\t}\n\t})\n}\n\nmodule.exports = PromisePolyfill\n","\"use strict\"\n\nvar PromisePolyfill = require(\"./polyfill\")\n\nif (typeof window !== \"undefined\") {\n\tif (typeof window.Promise === \"undefined\") {\n\t\twindow.Promise = PromisePolyfill\n\t} else if (!window.Promise.prototype.finally) {\n\t\twindow.Promise.prototype.finally = PromisePolyfill.prototype.finally\n\t}\n\tmodule.exports = window.Promise\n} else if (typeof global !== \"undefined\") {\n\tif (typeof global.Promise === \"undefined\") {\n\t\tglobal.Promise = PromisePolyfill\n\t} else if (!global.Promise.prototype.finally) {\n\t\tglobal.Promise.prototype.finally = PromisePolyfill.prototype.finally\n\t}\n\tmodule.exports = global.Promise\n} else {\n\tmodule.exports = PromisePolyfill\n}\n","\"use strict\"\n\nmodule.exports = function(object) {\n\tif (Object.prototype.toString.call(object) !== \"[object Object]\") return \"\"\n\n\tvar args = []\n\tfor (var key in object) {\n\t\tdestructure(key, object[key])\n\t}\n\n\treturn args.join(\"&\")\n\n\tfunction destructure(key, value) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (var i = 0; i < value.length; i++) {\n\t\t\t\tdestructure(key + \"[\" + i + \"]\", value[i])\n\t\t\t}\n\t\t}\n\t\telse if (Object.prototype.toString.call(value) === \"[object Object]\") {\n\t\t\tfor (var i in value) {\n\t\t\t\tdestructure(key + \"[\" + i + \"]\", value[i])\n\t\t\t}\n\t\t}\n\t\telse args.push(encodeURIComponent(key) + (value != null && value !== \"\" ? \"=\" + encodeURIComponent(value) : \"\"))\n\t}\n}\n","\"use strict\"\n\nmodule.exports = function(string) {\n\tif (string === \"\" || string == null) return {}\n\tif (string.charAt(0) === \"?\") string = string.slice(1)\n\n\tvar entries = string.split(\"&\"), counters = {}, data = {}\n\tfor (var i = 0; i < entries.length; i++) {\n\t\tvar entry = entries[i].split(\"=\")\n\t\tvar key = decodeURIComponent(entry[0])\n\t\tvar value = entry.length === 2 ? decodeURIComponent(entry[1]) : \"\"\n\n\t\tif (value === \"true\") value = true\n\t\telse if (value === \"false\") value = false\n\n\t\tvar levels = key.split(/\\]\\[?|\\[/)\n\t\tvar cursor = data\n\t\tif (key.indexOf(\"[\") > -1) levels.pop()\n\t\tfor (var j = 0; j < levels.length; j++) {\n\t\t\tvar level = levels[j], nextLevel = levels[j + 1]\n\t\t\tvar isNumber = nextLevel == \"\" || !isNaN(parseInt(nextLevel, 10))\n\t\t\tif (level === \"\") {\n\t\t\t\tvar key = levels.slice(0, j).join()\n\t\t\t\tif (counters[key] == null) {\n\t\t\t\t\tcounters[key] = Array.isArray(cursor) ? cursor.length : 0\n\t\t\t\t}\n\t\t\t\tlevel = counters[key]++\n\t\t\t}\n\t\t\t// Disallow direct prototype pollution\n\t\t\telse if (level === \"__proto__\") break\n\t\t\tif (j === levels.length - 1) cursor[level] = value\n\t\t\telse {\n\t\t\t\t// Read own properties exclusively to disallow indirect\n\t\t\t\t// prototype pollution\n\t\t\t\tvar desc = Object.getOwnPropertyDescriptor(cursor, level)\n\t\t\t\tif (desc != null) desc = desc.value\n\t\t\t\tif (desc == null) cursor[level] = desc = isNumber ? [] : {}\n\t\t\t\tcursor = desc\n\t\t\t}\n\t\t}\n\t}\n\treturn data\n}\n","\"use strict\"\n\nmodule.exports = require(\"./render/render\")(window)\n","\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\nvar hyperscriptVnode = require(\"./hyperscriptVnode\")\n\nmodule.exports = function() {\n\tvar vnode = hyperscriptVnode.apply(0, arguments)\n\n\tvnode.tag = \"[\"\n\tvnode.children = Vnode.normalizeChildren(vnode.children)\n\treturn vnode\n}\n","\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\nvar hyperscriptVnode = require(\"./hyperscriptVnode\")\n\nvar selectorParser = /(?:(^|#|\\.)([^#\\.\\[\\]]+))|(\\[(.+?)(?:\\s*=\\s*(\"|'|)((?:\\\\[\"'\\]]|.)*?)\\5)?\\])/g\nvar selectorCache = {}\nvar hasOwn = {}.hasOwnProperty\n\nfunction isEmpty(object) {\n\tfor (var key in object) if (hasOwn.call(object, key)) return false\n\treturn true\n}\n\nfunction compileSelector(selector) {\n\tvar match, tag = \"div\", classes = [], attrs = {}\n\twhile (match = selectorParser.exec(selector)) {\n\t\tvar type = match[1], value = match[2]\n\t\tif (type === \"\" && value !== \"\") tag = value\n\t\telse if (type === \"#\") attrs.id = value\n\t\telse if (type === \".\") classes.push(value)\n\t\telse if (match[3][0] === \"[\") {\n\t\t\tvar attrValue = match[6]\n\t\t\tif (attrValue) attrValue = attrValue.replace(/\\\\([\"'])/g, \"$1\").replace(/\\\\\\\\/g, \"\\\\\")\n\t\t\tif (match[4] === \"class\") classes.push(attrValue)\n\t\t\telse attrs[match[4]] = attrValue === \"\" ? attrValue : attrValue || true\n\t\t}\n\t}\n\tif (classes.length > 0) attrs.className = classes.join(\" \")\n\treturn selectorCache[selector] = {tag: tag, attrs: attrs}\n}\n\nfunction execSelector(state, vnode) {\n\tvar attrs = vnode.attrs\n\tvar children = Vnode.normalizeChildren(vnode.children)\n\tvar hasClass = hasOwn.call(attrs, \"class\")\n\tvar className = hasClass ? attrs.class : attrs.className\n\n\tvnode.tag = state.tag\n\tvnode.attrs = null\n\tvnode.children = undefined\n\n\tif (!isEmpty(state.attrs) && !isEmpty(attrs)) {\n\t\tvar newAttrs = {}\n\n\t\tfor (var key in attrs) {\n\t\t\tif (hasOwn.call(attrs, key)) newAttrs[key] = attrs[key]\n\t\t}\n\n\t\tattrs = newAttrs\n\t}\n\n\tfor (var key in state.attrs) {\n\t\tif (hasOwn.call(state.attrs, key) && key !== \"className\" && !hasOwn.call(attrs, key)){\n\t\t\tattrs[key] = state.attrs[key]\n\t\t}\n\t}\n\tif (className != null || state.attrs.className != null) attrs.className =\n\t\tclassName != null\n\t\t\t? state.attrs.className != null\n\t\t\t\t? String(state.attrs.className) + \" \" + String(className)\n\t\t\t\t: className\n\t\t\t: state.attrs.className != null\n\t\t\t\t? state.attrs.className\n\t\t\t\t: null\n\n\tif (hasClass) attrs.class = null\n\n\tfor (var key in attrs) {\n\t\tif (hasOwn.call(attrs, key) && key !== \"key\") {\n\t\t\tvnode.attrs = attrs\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (Array.isArray(children) && children.length === 1 && children[0] != null && children[0].tag === \"#\") {\n\t\tvnode.text = children[0].children\n\t} else {\n\t\tvnode.children = children\n\t}\n\n\treturn vnode\n}\n\nfunction hyperscript(selector) {\n\tif (selector == null || typeof selector !== \"string\" && typeof selector !== \"function\" && typeof selector.view !== \"function\") {\n\t\tthrow Error(\"The selector must be either a string or a component.\");\n\t}\n\n\tvar vnode = hyperscriptVnode.apply(1, arguments)\n\n\tif (typeof selector === \"string\") {\n\t\tvnode.children = Vnode.normalizeChildren(vnode.children)\n\t\tif (selector !== \"[\") return execSelector(selectorCache[selector] || compileSelector(selector), vnode)\n\t}\n\n\tvnode.tag = selector\n\treturn vnode\n}\n\nmodule.exports = hyperscript\n","\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\n// Call via `hyperscriptVnode.apply(startOffset, arguments)`\n//\n// The reason I do it this way, forwarding the arguments and passing the start\n// offset in `this`, is so I don't have to create a temporary array in a\n// performance-critical path.\n//\n// In native ES6, I'd instead add a final `...args` parameter to the\n// `hyperscript` and `fragment` factories and define this as\n// `hyperscriptVnode(...args)`, since modern engines do optimize that away. But\n// ES5 (what Mithril requires thanks to IE support) doesn't give me that luxury,\n// and engines aren't nearly intelligent enough to do either of these:\n//\n// 1. Elide the allocation for `[].slice.call(arguments, 1)` when it's passed to\n// another function only to be indexed.\n// 2. Elide an `arguments` allocation when it's passed to any function other\n// than `Function.prototype.apply` or `Reflect.apply`.\n//\n// In ES6, it'd probably look closer to this (I'd need to profile it, though):\n// module.exports = function(attrs, ...children) {\n// if (attrs == null || typeof attrs === \"object\" && attrs.tag == null && !Array.isArray(attrs)) {\n// if (children.length === 1 && Array.isArray(children[0])) children = children[0]\n// } else {\n// children = children.length === 0 && Array.isArray(attrs) ? attrs : [attrs, ...children]\n// attrs = undefined\n// }\n//\n// if (attrs == null) attrs = {}\n// return Vnode(\"\", attrs.key, attrs, children)\n// }\nmodule.exports = function() {\n\tvar attrs = arguments[this], start = this + 1, children\n\n\tif (attrs == null) {\n\t\tattrs = {}\n\t} else if (typeof attrs !== \"object\" || attrs.tag != null || Array.isArray(attrs)) {\n\t\tattrs = {}\n\t\tstart = this\n\t}\n\n\tif (arguments.length === start + 1) {\n\t\tchildren = arguments[start]\n\t\tif (!Array.isArray(children)) children = [children]\n\t} else {\n\t\tchildren = []\n\t\twhile (start < arguments.length) children.push(arguments[start++])\n\t}\n\n\treturn Vnode(\"\", attrs.key, attrs, children)\n}\n","\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\nmodule.exports = function($window) {\n\tvar $doc = $window && $window.document\n\tvar currentRedraw\n\n\tvar nameSpace = {\n\t\tsvg: \"http://www.w3.org/2000/svg\",\n\t\tmath: \"http://www.w3.org/1998/Math/MathML\"\n\t}\n\n\tfunction getNameSpace(vnode) {\n\t\treturn vnode.attrs && vnode.attrs.xmlns || nameSpace[vnode.tag]\n\t}\n\n\t//sanity check to discourage people from doing `vnode.state = ...`\n\tfunction checkState(vnode, original) {\n\t\tif (vnode.state !== original) throw new Error(\"`vnode.state` must not be modified\")\n\t}\n\n\t//Note: the hook is passed as the `this` argument to allow proxying the\n\t//arguments without requiring a full array allocation to do so. It also\n\t//takes advantage of the fact the current `vnode` is the first argument in\n\t//all lifecycle methods.\n\tfunction callHook(vnode) {\n\t\tvar original = vnode.state\n\t\ttry {\n\t\t\treturn this.apply(original, arguments)\n\t\t} finally {\n\t\t\tcheckState(vnode, original)\n\t\t}\n\t}\n\n\t// IE11 (at least) throws an UnspecifiedError when accessing document.activeElement when\n\t// inside an iframe. Catch and swallow this error, and heavy-handidly return null.\n\tfunction activeElement() {\n\t\ttry {\n\t\t\treturn $doc.activeElement\n\t\t} catch (e) {\n\t\t\treturn null\n\t\t}\n\t}\n\t//create\n\tfunction createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) {\n\t\tfor (var i = start; i < end; i++) {\n\t\t\tvar vnode = vnodes[i]\n\t\t\tif (vnode != null) {\n\t\t\t\tcreateNode(parent, vnode, hooks, ns, nextSibling)\n\t\t\t}\n\t\t}\n\t}\n\tfunction createNode(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar tag = vnode.tag\n\t\tif (typeof tag === \"string\") {\n\t\t\tvnode.state = {}\n\t\t\tif (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)\n\t\t\tswitch (tag) {\n\t\t\t\tcase \"#\": createText(parent, vnode, nextSibling); break\n\t\t\t\tcase \"<\": createHTML(parent, vnode, ns, nextSibling); break\n\t\t\t\tcase \"[\": createFragment(parent, vnode, hooks, ns, nextSibling); break\n\t\t\t\tdefault: createElement(parent, vnode, hooks, ns, nextSibling)\n\t\t\t}\n\t\t}\n\t\telse createComponent(parent, vnode, hooks, ns, nextSibling)\n\t}\n\tfunction createText(parent, vnode, nextSibling) {\n\t\tvnode.dom = $doc.createTextNode(vnode.children)\n\t\tinsertNode(parent, vnode.dom, nextSibling)\n\t}\n\tvar possibleParents = {caption: \"table\", thead: \"table\", tbody: \"table\", tfoot: \"table\", tr: \"tbody\", th: \"tr\", td: \"tr\", colgroup: \"table\", col: \"colgroup\"}\n\tfunction createHTML(parent, vnode, ns, nextSibling) {\n\t\tvar match = vnode.children.match(/^\\s*?<(\\w+)/im) || []\n\t\t// not using the proper parent makes the child element(s) vanish.\n\t\t// var div = document.createElement(\"div\")\n\t\t// div.innerHTML = \"ij\"\n\t\t// console.log(div.innerHTML)\n\t\t// --> \"ij\", no in sight.\n\t\tvar temp = $doc.createElement(possibleParents[match[1]] || \"div\")\n\t\tif (ns === \"http://www.w3.org/2000/svg\") {\n\t\t\ttemp.innerHTML = \"\" + vnode.children + \"\"\n\t\t\ttemp = temp.firstChild\n\t\t} else {\n\t\t\ttemp.innerHTML = vnode.children\n\t\t}\n\t\tvnode.dom = temp.firstChild\n\t\tvnode.domSize = temp.childNodes.length\n\t\t// Capture nodes to remove, so we don't confuse them.\n\t\tvnode.instance = []\n\t\tvar fragment = $doc.createDocumentFragment()\n\t\tvar child\n\t\twhile (child = temp.firstChild) {\n\t\t\tvnode.instance.push(child)\n\t\t\tfragment.appendChild(child)\n\t\t}\n\t\tinsertNode(parent, fragment, nextSibling)\n\t}\n\tfunction createFragment(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar fragment = $doc.createDocumentFragment()\n\t\tif (vnode.children != null) {\n\t\t\tvar children = vnode.children\n\t\t\tcreateNodes(fragment, children, 0, children.length, hooks, null, ns)\n\t\t}\n\t\tvnode.dom = fragment.firstChild\n\t\tvnode.domSize = fragment.childNodes.length\n\t\tinsertNode(parent, fragment, nextSibling)\n\t}\n\tfunction createElement(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar tag = vnode.tag\n\t\tvar attrs = vnode.attrs\n\t\tvar is = attrs && attrs.is\n\n\t\tns = getNameSpace(vnode) || ns\n\n\t\tvar element = ns ?\n\t\t\tis ? $doc.createElementNS(ns, tag, {is: is}) : $doc.createElementNS(ns, tag) :\n\t\t\tis ? $doc.createElement(tag, {is: is}) : $doc.createElement(tag)\n\t\tvnode.dom = element\n\n\t\tif (attrs != null) {\n\t\t\tsetAttrs(vnode, attrs, ns)\n\t\t}\n\n\t\tinsertNode(parent, element, nextSibling)\n\n\t\tif (!maybeSetContentEditable(vnode)) {\n\t\t\tif (vnode.text != null) {\n\t\t\t\tif (vnode.text !== \"\") element.textContent = vnode.text\n\t\t\t\telse vnode.children = [Vnode(\"#\", undefined, undefined, vnode.text, undefined, undefined)]\n\t\t\t}\n\t\t\tif (vnode.children != null) {\n\t\t\t\tvar children = vnode.children\n\t\t\t\tcreateNodes(element, children, 0, children.length, hooks, null, ns)\n\t\t\t\tif (vnode.tag === \"select\" && attrs != null) setLateSelectAttrs(vnode, attrs)\n\t\t\t}\n\t\t}\n\t}\n\tfunction initComponent(vnode, hooks) {\n\t\tvar sentinel\n\t\tif (typeof vnode.tag.view === \"function\") {\n\t\t\tvnode.state = Object.create(vnode.tag)\n\t\t\tsentinel = vnode.state.view\n\t\t\tif (sentinel.$$reentrantLock$$ != null) return\n\t\t\tsentinel.$$reentrantLock$$ = true\n\t\t} else {\n\t\t\tvnode.state = void 0\n\t\t\tsentinel = vnode.tag\n\t\t\tif (sentinel.$$reentrantLock$$ != null) return\n\t\t\tsentinel.$$reentrantLock$$ = true\n\t\t\tvnode.state = (vnode.tag.prototype != null && typeof vnode.tag.prototype.view === \"function\") ? new vnode.tag(vnode) : vnode.tag(vnode)\n\t\t}\n\t\tinitLifecycle(vnode.state, vnode, hooks)\n\t\tif (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)\n\t\tvnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode))\n\t\tif (vnode.instance === vnode) throw Error(\"A view cannot return the vnode it received as argument\")\n\t\tsentinel.$$reentrantLock$$ = null\n\t}\n\tfunction createComponent(parent, vnode, hooks, ns, nextSibling) {\n\t\tinitComponent(vnode, hooks)\n\t\tif (vnode.instance != null) {\n\t\t\tcreateNode(parent, vnode.instance, hooks, ns, nextSibling)\n\t\t\tvnode.dom = vnode.instance.dom\n\t\t\tvnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0\n\t\t}\n\t\telse {\n\t\t\tvnode.domSize = 0\n\t\t}\n\t}\n\n\t//update\n\t/**\n\t * @param {Element|Fragment} parent - the parent element\n\t * @param {Vnode[] | null} old - the list of vnodes of the last `render()` call for\n\t * this part of the tree\n\t * @param {Vnode[] | null} vnodes - as above, but for the current `render()` call.\n\t * @param {Function[]} hooks - an accumulator of post-render hooks (oncreate/onupdate)\n\t * @param {Element | null} nextSibling - the next DOM node if we're dealing with a\n\t * fragment that is not the last item in its\n\t * parent\n\t * @param {'svg' | 'math' | String | null} ns) - the current XML namespace, if any\n\t * @returns void\n\t */\n\t// This function diffs and patches lists of vnodes, both keyed and unkeyed.\n\t//\n\t// We will:\n\t//\n\t// 1. describe its general structure\n\t// 2. focus on the diff algorithm optimizations\n\t// 3. discuss DOM node operations.\n\n\t// ## Overview:\n\t//\n\t// The updateNodes() function:\n\t// - deals with trivial cases\n\t// - determines whether the lists are keyed or unkeyed based on the first non-null node\n\t// of each list.\n\t// - diffs them and patches the DOM if needed (that's the brunt of the code)\n\t// - manages the leftovers: after diffing, are there:\n\t// - old nodes left to remove?\n\t// \t - new nodes to insert?\n\t// \t deal with them!\n\t//\n\t// The lists are only iterated over once, with an exception for the nodes in `old` that\n\t// are visited in the fourth part of the diff and in the `removeNodes` loop.\n\n\t// ## Diffing\n\t//\n\t// Reading https://github.com/localvoid/ivi/blob/ddc09d06abaef45248e6133f7040d00d3c6be853/packages/ivi/src/vdom/implementation.ts#L617-L837\n\t// may be good for context on longest increasing subsequence-based logic for moving nodes.\n\t//\n\t// In order to diff keyed lists, one has to\n\t//\n\t// 1) match nodes in both lists, per key, and update them accordingly\n\t// 2) create the nodes present in the new list, but absent in the old one\n\t// 3) remove the nodes present in the old list, but absent in the new one\n\t// 4) figure out what nodes in 1) to move in order to minimize the DOM operations.\n\t//\n\t// To achieve 1) one can create a dictionary of keys => index (for the old list), then iterate\n\t// over the new list and for each new vnode, find the corresponding vnode in the old list using\n\t// the map.\n\t// 2) is achieved in the same step: if a new node has no corresponding entry in the map, it is new\n\t// and must be created.\n\t// For the removals, we actually remove the nodes that have been updated from the old list.\n\t// The nodes that remain in that list after 1) and 2) have been performed can be safely removed.\n\t// The fourth step is a bit more complex and relies on the longest increasing subsequence (LIS)\n\t// algorithm.\n\t//\n\t// the longest increasing subsequence is the list of nodes that can remain in place. Imagine going\n\t// from `1,2,3,4,5` to `4,5,1,2,3` where the numbers are not necessarily the keys, but the indices\n\t// corresponding to the keyed nodes in the old list (keyed nodes `e,d,c,b,a` => `b,a,e,d,c` would\n\t// match the above lists, for example).\n\t//\n\t// In there are two increasing subsequences: `4,5` and `1,2,3`, the latter being the longest. We\n\t// can update those nodes without moving them, and only call `insertNode` on `4` and `5`.\n\t//\n\t// @localvoid adapted the algo to also support node deletions and insertions (the `lis` is actually\n\t// the longest increasing subsequence *of old nodes still present in the new list*).\n\t//\n\t// It is a general algorithm that is fireproof in all circumstances, but it requires the allocation\n\t// and the construction of a `key => oldIndex` map, and three arrays (one with `newIndex => oldIndex`,\n\t// the `LIS` and a temporary one to create the LIS).\n\t//\n\t// So we cheat where we can: if the tails of the lists are identical, they are guaranteed to be part of\n\t// the LIS and can be updated without moving them.\n\t//\n\t// If two nodes are swapped, they are guaranteed not to be part of the LIS, and must be moved (with\n\t// the exception of the last node if the list is fully reversed).\n\t//\n\t// ## Finding the next sibling.\n\t//\n\t// `updateNode()` and `createNode()` expect a nextSibling parameter to perform DOM operations.\n\t// When the list is being traversed top-down, at any index, the DOM nodes up to the previous\n\t// vnode reflect the content of the new list, whereas the rest of the DOM nodes reflect the old\n\t// list. The next sibling must be looked for in the old list using `getNextSibling(... oldStart + 1 ...)`.\n\t//\n\t// In the other scenarios (swaps, upwards traversal, map-based diff),\n\t// the new vnodes list is traversed upwards. The DOM nodes at the bottom of the list reflect the\n\t// bottom part of the new vnodes list, and we can use the `v.dom` value of the previous node\n\t// as the next sibling (cached in the `nextSibling` variable).\n\n\n\t// ## DOM node moves\n\t//\n\t// In most scenarios `updateNode()` and `createNode()` perform the DOM operations. However,\n\t// this is not the case if the node moved (second and fourth part of the diff algo). We move\n\t// the old DOM nodes before updateNode runs because it enables us to use the cached `nextSibling`\n\t// variable rather than fetching it using `getNextSibling()`.\n\t//\n\t// The fourth part of the diff currently inserts nodes unconditionally, leading to issues\n\t// like #1791 and #1999. We need to be smarter about those situations where adjascent old\n\t// nodes remain together in the new list in a way that isn't covered by parts one and\n\t// three of the diff algo.\n\n\tfunction updateNodes(parent, old, vnodes, hooks, nextSibling, ns) {\n\t\tif (old === vnodes || old == null && vnodes == null) return\n\t\telse if (old == null || old.length === 0) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, ns)\n\t\telse if (vnodes == null || vnodes.length === 0) removeNodes(parent, old, 0, old.length)\n\t\telse {\n\t\t\tvar isOldKeyed = old[0] != null && old[0].key != null\n\t\t\tvar isKeyed = vnodes[0] != null && vnodes[0].key != null\n\t\t\tvar start = 0, oldStart = 0\n\t\t\tif (!isOldKeyed) while (oldStart < old.length && old[oldStart] == null) oldStart++\n\t\t\tif (!isKeyed) while (start < vnodes.length && vnodes[start] == null) start++\n\t\t\tif (isKeyed === null && isOldKeyed == null) return // both lists are full of nulls\n\t\t\tif (isOldKeyed !== isKeyed) {\n\t\t\t\tremoveNodes(parent, old, oldStart, old.length)\n\t\t\t\tcreateNodes(parent, vnodes, start, vnodes.length, hooks, nextSibling, ns)\n\t\t\t} else if (!isKeyed) {\n\t\t\t\t// Don't index past the end of either list (causes deopts).\n\t\t\t\tvar commonLength = old.length < vnodes.length ? old.length : vnodes.length\n\t\t\t\t// Rewind if necessary to the first non-null index on either side.\n\t\t\t\t// We could alternatively either explicitly create or remove nodes when `start !== oldStart`\n\t\t\t\t// but that would be optimizing for sparse lists which are more rare than dense ones.\n\t\t\t\tstart = start < oldStart ? start : oldStart\n\t\t\t\tfor (; start < commonLength; start++) {\n\t\t\t\t\to = old[start]\n\t\t\t\t\tv = vnodes[start]\n\t\t\t\t\tif (o === v || o == null && v == null) continue\n\t\t\t\t\telse if (o == null) createNode(parent, v, hooks, ns, getNextSibling(old, start + 1, nextSibling))\n\t\t\t\t\telse if (v == null) removeNode(parent, o)\n\t\t\t\t\telse updateNode(parent, o, v, hooks, getNextSibling(old, start + 1, nextSibling), ns)\n\t\t\t\t}\n\t\t\t\tif (old.length > commonLength) removeNodes(parent, old, start, old.length)\n\t\t\t\tif (vnodes.length > commonLength) createNodes(parent, vnodes, start, vnodes.length, hooks, nextSibling, ns)\n\t\t\t} else {\n\t\t\t\t// keyed diff\n\t\t\t\tvar oldEnd = old.length - 1, end = vnodes.length - 1, map, o, v, oe, ve, topSibling\n\n\t\t\t\t// bottom-up\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\toe = old[oldEnd]\n\t\t\t\t\tve = vnodes[end]\n\t\t\t\t\tif (oe.key !== ve.key) break\n\t\t\t\t\tif (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)\n\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\toldEnd--, end--\n\t\t\t\t}\n\t\t\t\t// top-down\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\to = old[oldStart]\n\t\t\t\t\tv = vnodes[start]\n\t\t\t\t\tif (o.key !== v.key) break\n\t\t\t\t\toldStart++, start++\n\t\t\t\t\tif (o !== v) updateNode(parent, o, v, hooks, getNextSibling(old, oldStart, nextSibling), ns)\n\t\t\t\t}\n\t\t\t\t// swaps and list reversals\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\tif (start === end) break\n\t\t\t\t\tif (o.key !== ve.key || oe.key !== v.key) break\n\t\t\t\t\ttopSibling = getNextSibling(old, oldStart, nextSibling)\n\t\t\t\t\tmoveNodes(parent, oe, topSibling)\n\t\t\t\t\tif (oe !== v) updateNode(parent, oe, v, hooks, topSibling, ns)\n\t\t\t\t\tif (++start <= --end) moveNodes(parent, o, nextSibling)\n\t\t\t\t\tif (o !== ve) updateNode(parent, o, ve, hooks, nextSibling, ns)\n\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\toldStart++; oldEnd--\n\t\t\t\t\toe = old[oldEnd]\n\t\t\t\t\tve = vnodes[end]\n\t\t\t\t\to = old[oldStart]\n\t\t\t\t\tv = vnodes[start]\n\t\t\t\t}\n\t\t\t\t// bottom up once again\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\tif (oe.key !== ve.key) break\n\t\t\t\t\tif (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)\n\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\toldEnd--, end--\n\t\t\t\t\toe = old[oldEnd]\n\t\t\t\t\tve = vnodes[end]\n\t\t\t\t}\n\t\t\t\tif (start > end) removeNodes(parent, old, oldStart, oldEnd + 1)\n\t\t\t\telse if (oldStart > oldEnd) createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)\n\t\t\t\telse {\n\t\t\t\t\t// inspired by ivi https://github.com/ivijs/ivi/ by Boris Kaul\n\t\t\t\t\tvar originalNextSibling = nextSibling, vnodesLength = end - start + 1, oldIndices = new Array(vnodesLength), li=0, i=0, pos = 2147483647, matched = 0, map, lisIndices\n\t\t\t\t\tfor (i = 0; i < vnodesLength; i++) oldIndices[i] = -1\n\t\t\t\t\tfor (i = end; i >= start; i--) {\n\t\t\t\t\t\tif (map == null) map = getKeyMap(old, oldStart, oldEnd + 1)\n\t\t\t\t\t\tve = vnodes[i]\n\t\t\t\t\t\tvar oldIndex = map[ve.key]\n\t\t\t\t\t\tif (oldIndex != null) {\n\t\t\t\t\t\t\tpos = (oldIndex < pos) ? oldIndex : -1 // becomes -1 if nodes were re-ordered\n\t\t\t\t\t\t\toldIndices[i-start] = oldIndex\n\t\t\t\t\t\t\toe = old[oldIndex]\n\t\t\t\t\t\t\told[oldIndex] = null\n\t\t\t\t\t\t\tif (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)\n\t\t\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\t\t\tmatched++\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tnextSibling = originalNextSibling\n\t\t\t\t\tif (matched !== oldEnd - oldStart + 1) removeNodes(parent, old, oldStart, oldEnd + 1)\n\t\t\t\t\tif (matched === 0) createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (pos === -1) {\n\t\t\t\t\t\t\t// the indices of the indices of the items that are part of the\n\t\t\t\t\t\t\t// longest increasing subsequence in the oldIndices list\n\t\t\t\t\t\t\tlisIndices = makeLisIndices(oldIndices)\n\t\t\t\t\t\t\tli = lisIndices.length - 1\n\t\t\t\t\t\t\tfor (i = end; i >= start; i--) {\n\t\t\t\t\t\t\t\tv = vnodes[i]\n\t\t\t\t\t\t\t\tif (oldIndices[i-start] === -1) createNode(parent, v, hooks, ns, nextSibling)\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (lisIndices[li] === i - start) li--\n\t\t\t\t\t\t\t\t\telse moveNodes(parent, v, nextSibling)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v.dom != null) nextSibling = vnodes[i].dom\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfor (i = end; i >= start; i--) {\n\t\t\t\t\t\t\t\tv = vnodes[i]\n\t\t\t\t\t\t\t\tif (oldIndices[i-start] === -1) createNode(parent, v, hooks, ns, nextSibling)\n\t\t\t\t\t\t\t\tif (v.dom != null) nextSibling = vnodes[i].dom\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction updateNode(parent, old, vnode, hooks, nextSibling, ns) {\n\t\tvar oldTag = old.tag, tag = vnode.tag\n\t\tif (oldTag === tag) {\n\t\t\tvnode.state = old.state\n\t\t\tvnode.events = old.events\n\t\t\tif (shouldNotUpdate(vnode, old)) return\n\t\t\tif (typeof oldTag === \"string\") {\n\t\t\t\tif (vnode.attrs != null) {\n\t\t\t\t\tupdateLifecycle(vnode.attrs, vnode, hooks)\n\t\t\t\t}\n\t\t\t\tswitch (oldTag) {\n\t\t\t\t\tcase \"#\": updateText(old, vnode); break\n\t\t\t\t\tcase \"<\": updateHTML(parent, old, vnode, ns, nextSibling); break\n\t\t\t\t\tcase \"[\": updateFragment(parent, old, vnode, hooks, nextSibling, ns); break\n\t\t\t\t\tdefault: updateElement(old, vnode, hooks, ns)\n\t\t\t\t}\n\t\t\t}\n\t\t\telse updateComponent(parent, old, vnode, hooks, nextSibling, ns)\n\t\t}\n\t\telse {\n\t\t\tremoveNode(parent, old)\n\t\t\tcreateNode(parent, vnode, hooks, ns, nextSibling)\n\t\t}\n\t}\n\tfunction updateText(old, vnode) {\n\t\tif (old.children.toString() !== vnode.children.toString()) {\n\t\t\told.dom.nodeValue = vnode.children\n\t\t}\n\t\tvnode.dom = old.dom\n\t}\n\tfunction updateHTML(parent, old, vnode, ns, nextSibling) {\n\t\tif (old.children !== vnode.children) {\n\t\t\tremoveHTML(parent, old)\n\t\t\tcreateHTML(parent, vnode, ns, nextSibling)\n\t\t}\n\t\telse {\n\t\t\tvnode.dom = old.dom\n\t\t\tvnode.domSize = old.domSize\n\t\t\tvnode.instance = old.instance\n\t\t}\n\t}\n\tfunction updateFragment(parent, old, vnode, hooks, nextSibling, ns) {\n\t\tupdateNodes(parent, old.children, vnode.children, hooks, nextSibling, ns)\n\t\tvar domSize = 0, children = vnode.children\n\t\tvnode.dom = null\n\t\tif (children != null) {\n\t\t\tfor (var i = 0; i < children.length; i++) {\n\t\t\t\tvar child = children[i]\n\t\t\t\tif (child != null && child.dom != null) {\n\t\t\t\t\tif (vnode.dom == null) vnode.dom = child.dom\n\t\t\t\t\tdomSize += child.domSize || 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (domSize !== 1) vnode.domSize = domSize\n\t\t}\n\t}\n\tfunction updateElement(old, vnode, hooks, ns) {\n\t\tvar element = vnode.dom = old.dom\n\t\tns = getNameSpace(vnode) || ns\n\n\t\tif (vnode.tag === \"textarea\") {\n\t\t\tif (vnode.attrs == null) vnode.attrs = {}\n\t\t\tif (vnode.text != null) {\n\t\t\t\tvnode.attrs.value = vnode.text //FIXME handle multiple children\n\t\t\t\tvnode.text = undefined\n\t\t\t}\n\t\t}\n\t\tupdateAttrs(vnode, old.attrs, vnode.attrs, ns)\n\t\tif (!maybeSetContentEditable(vnode)) {\n\t\t\tif (old.text != null && vnode.text != null && vnode.text !== \"\") {\n\t\t\t\tif (old.text.toString() !== vnode.text.toString()) old.dom.firstChild.nodeValue = vnode.text\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (old.text != null) old.children = [Vnode(\"#\", undefined, undefined, old.text, undefined, old.dom.firstChild)]\n\t\t\t\tif (vnode.text != null) vnode.children = [Vnode(\"#\", undefined, undefined, vnode.text, undefined, undefined)]\n\t\t\t\tupdateNodes(element, old.children, vnode.children, hooks, null, ns)\n\t\t\t}\n\t\t}\n\t}\n\tfunction updateComponent(parent, old, vnode, hooks, nextSibling, ns) {\n\t\tvnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode))\n\t\tif (vnode.instance === vnode) throw Error(\"A view cannot return the vnode it received as argument\")\n\t\tupdateLifecycle(vnode.state, vnode, hooks)\n\t\tif (vnode.attrs != null) updateLifecycle(vnode.attrs, vnode, hooks)\n\t\tif (vnode.instance != null) {\n\t\t\tif (old.instance == null) createNode(parent, vnode.instance, hooks, ns, nextSibling)\n\t\t\telse updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, ns)\n\t\t\tvnode.dom = vnode.instance.dom\n\t\t\tvnode.domSize = vnode.instance.domSize\n\t\t}\n\t\telse if (old.instance != null) {\n\t\t\tremoveNode(parent, old.instance)\n\t\t\tvnode.dom = undefined\n\t\t\tvnode.domSize = 0\n\t\t}\n\t\telse {\n\t\t\tvnode.dom = old.dom\n\t\t\tvnode.domSize = old.domSize\n\t\t}\n\t}\n\tfunction getKeyMap(vnodes, start, end) {\n\t\tvar map = Object.create(null)\n\t\tfor (; start < end; start++) {\n\t\t\tvar vnode = vnodes[start]\n\t\t\tif (vnode != null) {\n\t\t\t\tvar key = vnode.key\n\t\t\t\tif (key != null) map[key] = start\n\t\t\t}\n\t\t}\n\t\treturn map\n\t}\n\t// Lifted from ivi https://github.com/ivijs/ivi/\n\t// takes a list of unique numbers (-1 is special and can\n\t// occur multiple times) and returns an array with the indices\n\t// of the items that are part of the longest increasing\n\t// subsequece\n\tvar lisTemp = []\n\tfunction makeLisIndices(a) {\n\t\tvar result = [0]\n\t\tvar u = 0, v = 0, i = 0\n\t\tvar il = lisTemp.length = a.length\n\t\tfor (var i = 0; i < il; i++) lisTemp[i] = a[i]\n\t\tfor (var i = 0; i < il; ++i) {\n\t\t\tif (a[i] === -1) continue\n\t\t\tvar j = result[result.length - 1]\n\t\t\tif (a[j] < a[i]) {\n\t\t\t\tlisTemp[i] = j\n\t\t\t\tresult.push(i)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tu = 0\n\t\t\tv = result.length - 1\n\t\t\twhile (u < v) {\n\t\t\t\t// Fast integer average without overflow.\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tvar c = (u >>> 1) + (v >>> 1) + (u & v & 1)\n\t\t\t\tif (a[result[c]] < a[i]) {\n\t\t\t\t\tu = c + 1\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tv = c\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (a[i] < a[result[u]]) {\n\t\t\t\tif (u > 0) lisTemp[i] = result[u - 1]\n\t\t\t\tresult[u] = i\n\t\t\t}\n\t\t}\n\t\tu = result.length\n\t\tv = result[u - 1]\n\t\twhile (u-- > 0) {\n\t\t\tresult[u] = v\n\t\t\tv = lisTemp[v]\n\t\t}\n\t\tlisTemp.length = 0\n\t\treturn result\n\t}\n\n\tfunction getNextSibling(vnodes, i, nextSibling) {\n\t\tfor (; i < vnodes.length; i++) {\n\t\t\tif (vnodes[i] != null && vnodes[i].dom != null) return vnodes[i].dom\n\t\t}\n\t\treturn nextSibling\n\t}\n\n\t// This covers a really specific edge case:\n\t// - Parent node is keyed and contains child\n\t// - Child is removed, returns unresolved promise in `onbeforeremove`\n\t// - Parent node is moved in keyed diff\n\t// - Remaining children still need moved appropriately\n\t//\n\t// Ideally, I'd track removed nodes as well, but that introduces a lot more\n\t// complexity and I'm not exactly interested in doing that.\n\tfunction moveNodes(parent, vnode, nextSibling) {\n\t\tvar frag = $doc.createDocumentFragment()\n\t\tmoveChildToFrag(parent, frag, vnode)\n\t\tinsertNode(parent, frag, nextSibling)\n\t}\n\tfunction moveChildToFrag(parent, frag, vnode) {\n\t\t// Dodge the recursion overhead in a few of the most common cases.\n\t\twhile (vnode.dom != null && vnode.dom.parentNode === parent) {\n\t\t\tif (typeof vnode.tag !== \"string\") {\n\t\t\t\tvnode = vnode.instance\n\t\t\t\tif (vnode != null) continue\n\t\t\t} else if (vnode.tag === \"<\") {\n\t\t\t\tfor (var i = 0; i < vnode.instance.length; i++) {\n\t\t\t\t\tfrag.appendChild(vnode.instance[i])\n\t\t\t\t}\n\t\t\t} else if (vnode.tag !== \"[\") {\n\t\t\t\t// Don't recurse for text nodes *or* elements, just fragments\n\t\t\t\tfrag.appendChild(vnode.dom)\n\t\t\t} else if (vnode.children.length === 1) {\n\t\t\t\tvnode = vnode.children[0]\n\t\t\t\tif (vnode != null) continue\n\t\t\t} else {\n\t\t\t\tfor (var i = 0; i < vnode.children.length; i++) {\n\t\t\t\t\tvar child = vnode.children[i]\n\t\t\t\t\tif (child != null) moveChildToFrag(parent, frag, child)\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfunction insertNode(parent, dom, nextSibling) {\n\t\tif (nextSibling != null) parent.insertBefore(dom, nextSibling)\n\t\telse parent.appendChild(dom)\n\t}\n\n\tfunction maybeSetContentEditable(vnode) {\n\t\tif (vnode.attrs == null || (\n\t\t\tvnode.attrs.contenteditable == null && // attribute\n\t\t\tvnode.attrs.contentEditable == null // property\n\t\t)) return false\n\t\tvar children = vnode.children\n\t\tif (children != null && children.length === 1 && children[0].tag === \"<\") {\n\t\t\tvar content = children[0].children\n\t\t\tif (vnode.dom.innerHTML !== content) vnode.dom.innerHTML = content\n\t\t}\n\t\telse if (vnode.text != null || children != null && children.length !== 0) throw new Error(\"Child node of a contenteditable must be trusted\")\n\t\treturn true\n\t}\n\n\t//remove\n\tfunction removeNodes(parent, vnodes, start, end) {\n\t\tfor (var i = start; i < end; i++) {\n\t\t\tvar vnode = vnodes[i]\n\t\t\tif (vnode != null) removeNode(parent, vnode)\n\t\t}\n\t}\n\tfunction removeNode(parent, vnode) {\n\t\tvar mask = 0\n\t\tvar original = vnode.state\n\t\tvar stateResult, attrsResult\n\t\tif (typeof vnode.tag !== \"string\" && typeof vnode.state.onbeforeremove === \"function\") {\n\t\t\tvar result = callHook.call(vnode.state.onbeforeremove, vnode)\n\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\tmask = 1\n\t\t\t\tstateResult = result\n\t\t\t}\n\t\t}\n\t\tif (vnode.attrs && typeof vnode.attrs.onbeforeremove === \"function\") {\n\t\t\tvar result = callHook.call(vnode.attrs.onbeforeremove, vnode)\n\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tmask |= 2\n\t\t\t\tattrsResult = result\n\t\t\t}\n\t\t}\n\t\tcheckState(vnode, original)\n\n\t\t// If we can, try to fast-path it and avoid all the overhead of awaiting\n\t\tif (!mask) {\n\t\t\tonremove(vnode)\n\t\t\tremoveChild(parent, vnode)\n\t\t} else {\n\t\t\tif (stateResult != null) {\n\t\t\t\tvar next = function () {\n\t\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\t\tif (mask & 1) { mask &= 2; if (!mask) reallyRemove() }\n\t\t\t\t}\n\t\t\t\tstateResult.then(next, next)\n\t\t\t}\n\t\t\tif (attrsResult != null) {\n\t\t\t\tvar next = function () {\n\t\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\t\tif (mask & 2) { mask &= 1; if (!mask) reallyRemove() }\n\t\t\t\t}\n\t\t\t\tattrsResult.then(next, next)\n\t\t\t}\n\t\t}\n\n\t\tfunction reallyRemove() {\n\t\t\tcheckState(vnode, original)\n\t\t\tonremove(vnode)\n\t\t\tremoveChild(parent, vnode)\n\t\t}\n\t}\n\tfunction removeHTML(parent, vnode) {\n\t\tfor (var i = 0; i < vnode.instance.length; i++) {\n\t\t\tparent.removeChild(vnode.instance[i])\n\t\t}\n\t}\n\tfunction removeChild(parent, vnode) {\n\t\t// Dodge the recursion overhead in a few of the most common cases.\n\t\twhile (vnode.dom != null && vnode.dom.parentNode === parent) {\n\t\t\tif (typeof vnode.tag !== \"string\") {\n\t\t\t\tvnode = vnode.instance\n\t\t\t\tif (vnode != null) continue\n\t\t\t} else if (vnode.tag === \"<\") {\n\t\t\t\tremoveHTML(parent, vnode)\n\t\t\t} else {\n\t\t\t\tif (vnode.tag !== \"[\") {\n\t\t\t\t\tparent.removeChild(vnode.dom)\n\t\t\t\t\tif (!Array.isArray(vnode.children)) break\n\t\t\t\t}\n\t\t\t\tif (vnode.children.length === 1) {\n\t\t\t\t\tvnode = vnode.children[0]\n\t\t\t\t\tif (vnode != null) continue\n\t\t\t\t} else {\n\t\t\t\t\tfor (var i = 0; i < vnode.children.length; i++) {\n\t\t\t\t\t\tvar child = vnode.children[i]\n\t\t\t\t\t\tif (child != null) removeChild(parent, child)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tfunction onremove(vnode) {\n\t\tif (typeof vnode.tag !== \"string\" && typeof vnode.state.onremove === \"function\") callHook.call(vnode.state.onremove, vnode)\n\t\tif (vnode.attrs && typeof vnode.attrs.onremove === \"function\") callHook.call(vnode.attrs.onremove, vnode)\n\t\tif (typeof vnode.tag !== \"string\") {\n\t\t\tif (vnode.instance != null) onremove(vnode.instance)\n\t\t} else {\n\t\t\tvar children = vnode.children\n\t\t\tif (Array.isArray(children)) {\n\t\t\t\tfor (var i = 0; i < children.length; i++) {\n\t\t\t\t\tvar child = children[i]\n\t\t\t\t\tif (child != null) onremove(child)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//attrs\n\tfunction setAttrs(vnode, attrs, ns) {\n\t\tfor (var key in attrs) {\n\t\t\tsetAttr(vnode, key, null, attrs[key], ns)\n\t\t}\n\t}\n\tfunction setAttr(vnode, key, old, value, ns) {\n\t\tif (key === \"key\" || key === \"is\" || value == null || isLifecycleMethod(key) || (old === value && !isFormAttribute(vnode, key)) && typeof value !== \"object\") return\n\t\tif (key[0] === \"o\" && key[1] === \"n\") return updateEvent(vnode, key, value)\n\t\tif (key.slice(0, 6) === \"xlink:\") vnode.dom.setAttributeNS(\"http://www.w3.org/1999/xlink\", key.slice(6), value)\n\t\telse if (key === \"style\") updateStyle(vnode.dom, old, value)\n\t\telse if (hasPropertyKey(vnode, key, ns)) {\n\t\t\tif (key === \"value\") {\n\t\t\t\t// Only do the coercion if we're actually going to check the value.\n\t\t\t\t/* eslint-disable no-implicit-coercion */\n\t\t\t\t//setting input[value] to same value by typing on focused element moves cursor to end in Chrome\n\t\t\t\tif ((vnode.tag === \"input\" || vnode.tag === \"textarea\") && vnode.dom.value === \"\" + value && vnode.dom === activeElement()) return\n\t\t\t\t//setting select[value] to same value while having select open blinks select dropdown in Chrome\n\t\t\t\tif (vnode.tag === \"select\" && old !== null && vnode.dom.value === \"\" + value) return\n\t\t\t\t//setting option[value] to same value while having select open blinks select dropdown in Chrome\n\t\t\t\tif (vnode.tag === \"option\" && old !== null && vnode.dom.value === \"\" + value) return\n\t\t\t\t/* eslint-enable no-implicit-coercion */\n\t\t\t}\n\t\t\t// If you assign an input type that is not supported by IE 11 with an assignment expression, an error will occur.\n\t\t\tif (vnode.tag === \"input\" && key === \"type\") vnode.dom.setAttribute(key, value)\n\t\t\telse vnode.dom[key] = value\n\t\t} else {\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\tif (value) vnode.dom.setAttribute(key, \"\")\n\t\t\t\telse vnode.dom.removeAttribute(key)\n\t\t\t}\n\t\t\telse vnode.dom.setAttribute(key === \"className\" ? \"class\" : key, value)\n\t\t}\n\t}\n\tfunction removeAttr(vnode, key, old, ns) {\n\t\tif (key === \"key\" || key === \"is\" || old == null || isLifecycleMethod(key)) return\n\t\tif (key[0] === \"o\" && key[1] === \"n\" && !isLifecycleMethod(key)) updateEvent(vnode, key, undefined)\n\t\telse if (key === \"style\") updateStyle(vnode.dom, old, null)\n\t\telse if (\n\t\t\thasPropertyKey(vnode, key, ns)\n\t\t\t&& key !== \"className\"\n\t\t\t&& !(key === \"value\" && (\n\t\t\t\tvnode.tag === \"option\"\n\t\t\t\t|| vnode.tag === \"select\" && vnode.dom.selectedIndex === -1 && vnode.dom === activeElement()\n\t\t\t))\n\t\t\t&& !(vnode.tag === \"input\" && key === \"type\")\n\t\t) {\n\t\t\tvnode.dom[key] = null\n\t\t} else {\n\t\t\tvar nsLastIndex = key.indexOf(\":\")\n\t\t\tif (nsLastIndex !== -1) key = key.slice(nsLastIndex + 1)\n\t\t\tif (old !== false) vnode.dom.removeAttribute(key === \"className\" ? \"class\" : key)\n\t\t}\n\t}\n\tfunction setLateSelectAttrs(vnode, attrs) {\n\t\tif (\"value\" in attrs) {\n\t\t\tif(attrs.value === null) {\n\t\t\t\tif (vnode.dom.selectedIndex !== -1) vnode.dom.value = null\n\t\t\t} else {\n\t\t\t\tvar normalized = \"\" + attrs.value // eslint-disable-line no-implicit-coercion\n\t\t\t\tif (vnode.dom.value !== normalized || vnode.dom.selectedIndex === -1) {\n\t\t\t\t\tvnode.dom.value = normalized\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (\"selectedIndex\" in attrs) setAttr(vnode, \"selectedIndex\", null, attrs.selectedIndex, undefined)\n\t}\n\tfunction updateAttrs(vnode, old, attrs, ns) {\n\t\tif (attrs != null) {\n\t\t\tfor (var key in attrs) {\n\t\t\t\tsetAttr(vnode, key, old && old[key], attrs[key], ns)\n\t\t\t}\n\t\t}\n\t\tvar val\n\t\tif (old != null) {\n\t\t\tfor (var key in old) {\n\t\t\t\tif (((val = old[key]) != null) && (attrs == null || attrs[key] == null)) {\n\t\t\t\t\tremoveAttr(vnode, key, val, ns)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction isFormAttribute(vnode, attr) {\n\t\treturn attr === \"value\" || attr === \"checked\" || attr === \"selectedIndex\" || attr === \"selected\" && vnode.dom === activeElement() || vnode.tag === \"option\" && vnode.dom.parentNode === $doc.activeElement\n\t}\n\tfunction isLifecycleMethod(attr) {\n\t\treturn attr === \"oninit\" || attr === \"oncreate\" || attr === \"onupdate\" || attr === \"onremove\" || attr === \"onbeforeremove\" || attr === \"onbeforeupdate\"\n\t}\n\tfunction hasPropertyKey(vnode, key, ns) {\n\t\t// Filter out namespaced keys\n\t\treturn ns === undefined && (\n\t\t\t// If it's a custom element, just keep it.\n\t\t\tvnode.tag.indexOf(\"-\") > -1 || vnode.attrs != null && vnode.attrs.is ||\n\t\t\t// If it's a normal element, let's try to avoid a few browser bugs.\n\t\t\tkey !== \"href\" && key !== \"list\" && key !== \"form\" && key !== \"width\" && key !== \"height\"// && key !== \"type\"\n\t\t\t// Defer the property check until *after* we check everything.\n\t\t) && key in vnode.dom\n\t}\n\n\t//style\n\tvar uppercaseRegex = /[A-Z]/g\n\tfunction toLowerCase(capital) { return \"-\" + capital.toLowerCase() }\n\tfunction normalizeKey(key) {\n\t\treturn key[0] === \"-\" && key[1] === \"-\" ? key :\n\t\t\tkey === \"cssFloat\" ? \"float\" :\n\t\t\t\tkey.replace(uppercaseRegex, toLowerCase)\n\t}\n\tfunction updateStyle(element, old, style) {\n\t\tif (old === style) {\n\t\t\t// Styles are equivalent, do nothing.\n\t\t} else if (style == null) {\n\t\t\t// New style is missing, just clear it.\n\t\t\telement.style.cssText = \"\"\n\t\t} else if (typeof style !== \"object\") {\n\t\t\t// New style is a string, let engine deal with patching.\n\t\t\telement.style.cssText = style\n\t\t} else if (old == null || typeof old !== \"object\") {\n\t\t\t// `old` is missing or a string, `style` is an object.\n\t\t\telement.style.cssText = \"\"\n\t\t\t// Add new style properties\n\t\t\tfor (var key in style) {\n\t\t\t\tvar value = style[key]\n\t\t\t\tif (value != null) element.style.setProperty(normalizeKey(key), String(value))\n\t\t\t}\n\t\t} else {\n\t\t\t// Both old & new are (different) objects.\n\t\t\t// Update style properties that have changed\n\t\t\tfor (var key in style) {\n\t\t\t\tvar value = style[key]\n\t\t\t\tif (value != null && (value = String(value)) !== String(old[key])) {\n\t\t\t\t\telement.style.setProperty(normalizeKey(key), value)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Remove style properties that no longer exist\n\t\t\tfor (var key in old) {\n\t\t\t\tif (old[key] != null && style[key] == null) {\n\t\t\t\t\telement.style.removeProperty(normalizeKey(key))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Here's an explanation of how this works:\n\t// 1. The event names are always (by design) prefixed by `on`.\n\t// 2. The EventListener interface accepts either a function or an object\n\t// with a `handleEvent` method.\n\t// 3. The object does not inherit from `Object.prototype`, to avoid\n\t// any potential interference with that (e.g. setters).\n\t// 4. The event name is remapped to the handler before calling it.\n\t// 5. In function-based event handlers, `ev.target === this`. We replicate\n\t// that below.\n\t// 6. In function-based event handlers, `return false` prevents the default\n\t// action and stops event propagation. We replicate that below.\n\tfunction EventDict() {\n\t\t// Save this, so the current redraw is correctly tracked.\n\t\tthis._ = currentRedraw\n\t}\n\tEventDict.prototype = Object.create(null)\n\tEventDict.prototype.handleEvent = function (ev) {\n\t\tvar handler = this[\"on\" + ev.type]\n\t\tvar result\n\t\tif (typeof handler === \"function\") result = handler.call(ev.currentTarget, ev)\n\t\telse if (typeof handler.handleEvent === \"function\") handler.handleEvent(ev)\n\t\tif (this._ && ev.redraw !== false) (0, this._)()\n\t\tif (result === false) {\n\t\t\tev.preventDefault()\n\t\t\tev.stopPropagation()\n\t\t}\n\t}\n\n\t//event\n\tfunction updateEvent(vnode, key, value) {\n\t\tif (vnode.events != null) {\n\t\t\tif (vnode.events[key] === value) return\n\t\t\tif (value != null && (typeof value === \"function\" || typeof value === \"object\")) {\n\t\t\t\tif (vnode.events[key] == null) vnode.dom.addEventListener(key.slice(2), vnode.events, false)\n\t\t\t\tvnode.events[key] = value\n\t\t\t} else {\n\t\t\t\tif (vnode.events[key] != null) vnode.dom.removeEventListener(key.slice(2), vnode.events, false)\n\t\t\t\tvnode.events[key] = undefined\n\t\t\t}\n\t\t} else if (value != null && (typeof value === \"function\" || typeof value === \"object\")) {\n\t\t\tvnode.events = new EventDict()\n\t\t\tvnode.dom.addEventListener(key.slice(2), vnode.events, false)\n\t\t\tvnode.events[key] = value\n\t\t}\n\t}\n\n\t//lifecycle\n\tfunction initLifecycle(source, vnode, hooks) {\n\t\tif (typeof source.oninit === \"function\") callHook.call(source.oninit, vnode)\n\t\tif (typeof source.oncreate === \"function\") hooks.push(callHook.bind(source.oncreate, vnode))\n\t}\n\tfunction updateLifecycle(source, vnode, hooks) {\n\t\tif (typeof source.onupdate === \"function\") hooks.push(callHook.bind(source.onupdate, vnode))\n\t}\n\tfunction shouldNotUpdate(vnode, old) {\n\t\tdo {\n\t\t\tif (vnode.attrs != null && typeof vnode.attrs.onbeforeupdate === \"function\") {\n\t\t\t\tvar force = callHook.call(vnode.attrs.onbeforeupdate, vnode, old)\n\t\t\t\tif (force !== undefined && !force) break\n\t\t\t}\n\t\t\tif (typeof vnode.tag !== \"string\" && typeof vnode.state.onbeforeupdate === \"function\") {\n\t\t\t\tvar force = callHook.call(vnode.state.onbeforeupdate, vnode, old)\n\t\t\t\tif (force !== undefined && !force) break\n\t\t\t}\n\t\t\treturn false\n\t\t} while (false); // eslint-disable-line no-constant-condition\n\t\tvnode.dom = old.dom\n\t\tvnode.domSize = old.domSize\n\t\tvnode.instance = old.instance\n\t\t// One would think having the actual latest attributes would be ideal,\n\t\t// but it doesn't let us properly diff based on our current internal\n\t\t// representation. We have to save not only the old DOM info, but also\n\t\t// the attributes used to create it, as we diff *that*, not against the\n\t\t// DOM directly (with a few exceptions in `setAttr`). And, of course, we\n\t\t// need to save the children and text as they are conceptually not\n\t\t// unlike special \"attributes\" internally.\n\t\tvnode.attrs = old.attrs\n\t\tvnode.children = old.children\n\t\tvnode.text = old.text\n\t\treturn true\n\t}\n\n\treturn function(dom, vnodes, redraw) {\n\t\tif (!dom) throw new TypeError(\"Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.\")\n\t\tvar hooks = []\n\t\tvar active = activeElement()\n\t\tvar namespace = dom.namespaceURI\n\n\t\t// First time rendering into a node clears it out\n\t\tif (dom.vnodes == null) dom.textContent = \"\"\n\n\t\tvnodes = Vnode.normalizeChildren(Array.isArray(vnodes) ? vnodes : [vnodes])\n\t\tvar prevRedraw = currentRedraw\n\t\ttry {\n\t\t\tcurrentRedraw = typeof redraw === \"function\" ? redraw : undefined\n\t\t\tupdateNodes(dom, dom.vnodes, vnodes, hooks, null, namespace === \"http://www.w3.org/1999/xhtml\" ? undefined : namespace)\n\t\t} finally {\n\t\t\tcurrentRedraw = prevRedraw\n\t\t}\n\t\tdom.vnodes = vnodes\n\t\t// `document.activeElement` can return null: https://html.spec.whatwg.org/multipage/interaction.html#dom-document-activeelement\n\t\tif (active != null && activeElement() !== active && typeof active.focus === \"function\") active.focus()\n\t\tfor (var i = 0; i < hooks.length; i++) hooks[i]()\n\t}\n}\n","\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\nmodule.exports = function(html) {\n\tif (html == null) html = \"\"\n\treturn Vnode(\"<\", undefined, undefined, html, undefined, undefined)\n}\n","\"use strict\"\n\nfunction Vnode(tag, key, attrs, children, text, dom) {\n\treturn {tag: tag, key: key, attrs: attrs, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined}\n}\nVnode.normalize = function(node) {\n\tif (Array.isArray(node)) return Vnode(\"[\", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)\n\tif (node == null || typeof node === \"boolean\") return null\n\tif (typeof node === \"object\") return node\n\treturn Vnode(\"#\", undefined, undefined, String(node), undefined, undefined)\n}\nVnode.normalizeChildren = function(input) {\n\tvar children = []\n\tif (input.length) {\n\t\tvar isKeyed = input[0] != null && input[0].key != null\n\t\t// Note: this is a *very* perf-sensitive check.\n\t\t// Fun fact: merging the loop like this is somehow faster than splitting\n\t\t// it, noticeably so.\n\t\tfor (var i = 1; i < input.length; i++) {\n\t\t\tif ((input[i] != null && input[i].key != null) !== isKeyed) {\n\t\t\t\tthrow new TypeError(\"Vnodes must either always have keys or never have keys!\")\n\t\t\t}\n\t\t}\n\t\tfor (var i = 0; i < input.length; i++) {\n\t\t\tchildren[i] = Vnode.normalize(input[i])\n\t\t}\n\t}\n\treturn children\n}\n\nmodule.exports = Vnode\n","\"use strict\"\n\nvar PromisePolyfill = require(\"./promise/promise\")\nvar mountRedraw = require(\"./mount-redraw\")\n\nmodule.exports = require(\"./request/request\")(window, PromisePolyfill, mountRedraw.redraw)\n","\"use strict\"\n\nvar buildPathname = require(\"../pathname/build\")\n\nmodule.exports = function($window, Promise, oncompletion) {\n\tvar callbackCount = 0\n\n\tfunction PromiseProxy(executor) {\n\t\treturn new Promise(executor)\n\t}\n\n\t// In case the global Promise is some userland library's where they rely on\n\t// `foo instanceof this.constructor`, `this.constructor.resolve(value)`, or\n\t// similar. Let's *not* break them.\n\tPromiseProxy.prototype = Promise.prototype\n\tPromiseProxy.__proto__ = Promise // eslint-disable-line no-proto\n\n\tfunction makeRequest(factory) {\n\t\treturn function(url, args) {\n\t\t\tif (typeof url !== \"string\") { args = url; url = url.url }\n\t\t\telse if (args == null) args = {}\n\t\t\tvar promise = new Promise(function(resolve, reject) {\n\t\t\t\tfactory(buildPathname(url, args.params), args, function (data) {\n\t\t\t\t\tif (typeof args.type === \"function\") {\n\t\t\t\t\t\tif (Array.isArray(data)) {\n\t\t\t\t\t\t\tfor (var i = 0; i < data.length; i++) {\n\t\t\t\t\t\t\t\tdata[i] = new args.type(data[i])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse data = new args.type(data)\n\t\t\t\t\t}\n\t\t\t\t\tresolve(data)\n\t\t\t\t}, reject)\n\t\t\t})\n\t\t\tif (args.background === true) return promise\n\t\t\tvar count = 0\n\t\t\tfunction complete() {\n\t\t\t\tif (--count === 0 && typeof oncompletion === \"function\") oncompletion()\n\t\t\t}\n\n\t\t\treturn wrap(promise)\n\n\t\t\tfunction wrap(promise) {\n\t\t\t\tvar then = promise.then\n\t\t\t\t// Set the constructor, so engines know to not await or resolve\n\t\t\t\t// this as a native promise. At the time of writing, this is\n\t\t\t\t// only necessary for V8, but their behavior is the correct\n\t\t\t\t// behavior per spec. See this spec issue for more details:\n\t\t\t\t// https://github.com/tc39/ecma262/issues/1577. Also, see the\n\t\t\t\t// corresponding comment in `request/tests/test-request.js` for\n\t\t\t\t// a bit more background on the issue at hand.\n\t\t\t\tpromise.constructor = PromiseProxy\n\t\t\t\tpromise.then = function() {\n\t\t\t\t\tcount++\n\t\t\t\t\tvar next = then.apply(promise, arguments)\n\t\t\t\t\tnext.then(complete, function(e) {\n\t\t\t\t\t\tcomplete()\n\t\t\t\t\t\tif (count === 0) throw e\n\t\t\t\t\t})\n\t\t\t\t\treturn wrap(next)\n\t\t\t\t}\n\t\t\t\treturn promise\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction hasHeader(args, name) {\n\t\tfor (var key in args.headers) {\n\t\t\tif ({}.hasOwnProperty.call(args.headers, key) && name.test(key)) return true\n\t\t}\n\t\treturn false\n\t}\n\n\treturn {\n\t\trequest: makeRequest(function(url, args, resolve, reject) {\n\t\t\tvar method = args.method != null ? args.method.toUpperCase() : \"GET\"\n\t\t\tvar body = args.body\n\t\t\tvar assumeJSON = (args.serialize == null || args.serialize === JSON.serialize) && !(body instanceof $window.FormData)\n\t\t\tvar responseType = args.responseType || (typeof args.extract === \"function\" ? \"\" : \"json\")\n\n\t\t\tvar xhr = new $window.XMLHttpRequest(), aborted = false\n\t\t\tvar original = xhr, replacedAbort\n\t\t\tvar abort = xhr.abort\n\n\t\t\txhr.abort = function() {\n\t\t\t\taborted = true\n\t\t\t\tabort.call(this)\n\t\t\t}\n\n\t\t\txhr.open(method, url, args.async !== false, typeof args.user === \"string\" ? args.user : undefined, typeof args.password === \"string\" ? args.password : undefined)\n\n\t\t\tif (assumeJSON && body != null && !hasHeader(args, /^content-type$/i)) {\n\t\t\t\txhr.setRequestHeader(\"Content-Type\", \"application/json; charset=utf-8\")\n\t\t\t}\n\t\t\tif (typeof args.deserialize !== \"function\" && !hasHeader(args, /^accept$/i)) {\n\t\t\t\txhr.setRequestHeader(\"Accept\", \"application/json, text/*\")\n\t\t\t}\n\t\t\tif (args.withCredentials) xhr.withCredentials = args.withCredentials\n\t\t\tif (args.timeout) xhr.timeout = args.timeout\n\t\t\txhr.responseType = responseType\n\n\t\t\tfor (var key in args.headers) {\n\t\t\t\tif ({}.hasOwnProperty.call(args.headers, key)) {\n\t\t\t\t\txhr.setRequestHeader(key, args.headers[key])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\txhr.onreadystatechange = function(ev) {\n\t\t\t\t// Don't throw errors on xhr.abort().\n\t\t\t\tif (aborted) return\n\n\t\t\t\tif (ev.target.readyState === 4) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvar success = (ev.target.status >= 200 && ev.target.status < 300) || ev.target.status === 304 || (/^file:\\/\\//i).test(url)\n\t\t\t\t\t\t// When the response type isn't \"\" or \"text\",\n\t\t\t\t\t\t// `xhr.responseText` is the wrong thing to use.\n\t\t\t\t\t\t// Browsers do the right thing and throw here, and we\n\t\t\t\t\t\t// should honor that and do the right thing by\n\t\t\t\t\t\t// preferring `xhr.response` where possible/practical.\n\t\t\t\t\t\tvar response = ev.target.response, message\n\n\t\t\t\t\t\tif (responseType === \"json\") {\n\t\t\t\t\t\t\t// For IE and Edge, which don't implement\n\t\t\t\t\t\t\t// `responseType: \"json\"`.\n\t\t\t\t\t\t\tif (!ev.target.responseType && typeof args.extract !== \"function\") response = JSON.parse(ev.target.responseText)\n\t\t\t\t\t\t} else if (!responseType || responseType === \"text\") {\n\t\t\t\t\t\t\t// Only use this default if it's text. If a parsed\n\t\t\t\t\t\t\t// document is needed on old IE and friends (all\n\t\t\t\t\t\t\t// unsupported), the user should use a custom\n\t\t\t\t\t\t\t// `config` instead. They're already using this at\n\t\t\t\t\t\t\t// their own risk.\n\t\t\t\t\t\t\tif (response == null) response = ev.target.responseText\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (typeof args.extract === \"function\") {\n\t\t\t\t\t\t\tresponse = args.extract(ev.target, args)\n\t\t\t\t\t\t\tsuccess = true\n\t\t\t\t\t\t} else if (typeof args.deserialize === \"function\") {\n\t\t\t\t\t\t\tresponse = args.deserialize(response)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (success) resolve(response)\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\ttry { message = ev.target.responseText }\n\t\t\t\t\t\t\tcatch (e) { message = response }\n\t\t\t\t\t\t\tvar error = new Error(message)\n\t\t\t\t\t\t\terror.code = ev.target.status\n\t\t\t\t\t\t\terror.response = response\n\t\t\t\t\t\t\treject(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\treject(e)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof args.config === \"function\") {\n\t\t\t\txhr = args.config(xhr, args, url) || xhr\n\n\t\t\t\t// Propagate the `abort` to any replacement XHR as well.\n\t\t\t\tif (xhr !== original) {\n\t\t\t\t\treplacedAbort = xhr.abort\n\t\t\t\t\txhr.abort = function() {\n\t\t\t\t\t\taborted = true\n\t\t\t\t\t\treplacedAbort.call(this)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (body == null) xhr.send()\n\t\t\telse if (typeof args.serialize === \"function\") xhr.send(args.serialize(body))\n\t\t\telse if (body instanceof $window.FormData) xhr.send(body)\n\t\t\telse xhr.send(JSON.stringify(body))\n\t\t}),\n\t\tjsonp: makeRequest(function(url, args, resolve, reject) {\n\t\t\tvar callbackName = args.callbackName || \"_mithril_\" + Math.round(Math.random() * 1e16) + \"_\" + callbackCount++\n\t\t\tvar script = $window.document.createElement(\"script\")\n\t\t\t$window[callbackName] = function(data) {\n\t\t\t\tdelete $window[callbackName]\n\t\t\t\tscript.parentNode.removeChild(script)\n\t\t\t\tresolve(data)\n\t\t\t}\n\t\t\tscript.onerror = function() {\n\t\t\t\tdelete $window[callbackName]\n\t\t\t\tscript.parentNode.removeChild(script)\n\t\t\t\treject(new Error(\"JSONP request failed\"))\n\t\t\t}\n\t\t\tscript.src = url + (url.indexOf(\"?\") < 0 ? \"?\" : \"&\") +\n\t\t\t\tencodeURIComponent(args.callbackKey || \"callback\") + \"=\" +\n\t\t\t\tencodeURIComponent(callbackName)\n\t\t\t$window.document.documentElement.appendChild(script)\n\t\t}),\n\t}\n}\n","\"use strict\"\n\nvar mountRedraw = require(\"./mount-redraw\")\n\nmodule.exports = require(\"./api/router\")(window, mountRedraw)\n","\"use strict\";\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n};\r\nvar __generator = (this && this.__generator) || function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.poll = exports.postForm = exports.postJSON = exports.getJSON = exports.post = exports.get = exports.request = exports.requestRaw = void 0;\r\nvar requestRaw = function (method, url, options) {\r\n if (options === void 0) { options = {}; }\r\n return new Promise(function (res, rej) {\r\n var upProgress = 0;\r\n var downProgress = 0;\r\n var emitProgress = function () { return typeof options.progress === \"function\" && options.progress((upProgress + downProgress) * .5); };\r\n var xhr = new XMLHttpRequest();\r\n xhr.onload = function () {\r\n if (xhr.status >= 200 && xhr.status < 300)\r\n res(xhr);\r\n else\r\n rej(xhr);\r\n };\r\n if (typeof options.progress === \"function\") {\r\n if (xhr.upload)\r\n xhr.upload.onprogress = function (e) { upProgress = Math.ceil((e.loaded / e.total) * 100); emitProgress(); };\r\n xhr.onprogress = function (e) { downProgress = Math.ceil((e.loaded / e.total) * 100); emitProgress(); };\r\n }\r\n xhr.onerror = function () { return rej(xhr); };\r\n xhr.open(method, url, true);\r\n if (options.responseType)\r\n xhr.responseType = options.responseType;\r\n if (options.headers)\r\n Object.keys(options.headers).forEach(function (k) {\r\n return xhr.setRequestHeader(k, options.headers[k]);\r\n });\r\n xhr.send(options.data);\r\n });\r\n};\r\nexports.requestRaw = requestRaw;\r\nvar request = function (method, url, options) {\r\n if (options === void 0) { options = {}; }\r\n return (0, exports.requestRaw)(method, url, options)\r\n .then(function (xhr) { return xhr.response || xhr.responseText; });\r\n};\r\nexports.request = request;\r\nvar get = function (url, options) {\r\n if (options === void 0) { options = {}; }\r\n return (0, exports.request)(\"GET\", url, options);\r\n};\r\nexports.get = get;\r\nvar post = function (url, data, options) {\r\n if (options === void 0) { options = {}; }\r\n return (0, exports.request)(\"POST\", url, __assign(__assign({}, options), { data: data }));\r\n};\r\nexports.post = post;\r\nvar getJSON = function (url, options) {\r\n if (options === void 0) { options = {}; }\r\n return __awaiter(void 0, void 0, void 0, function () {\r\n var r;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, (0, exports.get)(url, __assign(__assign({}, options), { headers: __assign(__assign({}, (options.headers || {})), { \"Content-Type\": \"application/json;charset=UTF-8\" }) }))];\r\n case 1:\r\n r = _a.sent();\r\n try {\r\n return [2 /*return*/, JSON.parse(r)];\r\n }\r\n catch (err) {\r\n return [2 /*return*/, r];\r\n }\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n};\r\nexports.getJSON = getJSON;\r\nvar postJSON = function (url, data, options) {\r\n if (options === void 0) { options = {}; }\r\n return __awaiter(void 0, void 0, void 0, function () {\r\n var r;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, (0, exports.post)(url, JSON.stringify(data), __assign(__assign({}, options), { headers: __assign(__assign({}, (options.headers || {})), { \"Content-Type\": \"application/json;charset=UTF-8\" }) }))];\r\n case 1:\r\n r = _a.sent();\r\n try {\r\n return [2 /*return*/, JSON.parse(r)];\r\n }\r\n catch (err) {\r\n return [2 /*return*/, r];\r\n }\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n};\r\nexports.postJSON = postJSON;\r\nvar postForm = function (url, data, options) {\r\n if (options === void 0) { options = {}; }\r\n return (0, exports.post)(url, new FormData(data), options);\r\n};\r\nexports.postForm = postForm;\r\nvar poll = function (url, rate, check) {\r\n if (rate === void 0) { rate = 200; }\r\n return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {\r\n var done, res, err_1;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n done = false;\r\n _a.label = 1;\r\n case 1:\r\n if (!(done === false)) return [3 /*break*/, 7];\r\n return [4 /*yield*/, pause(rate)];\r\n case 2:\r\n _a.sent();\r\n _a.label = 3;\r\n case 3:\r\n _a.trys.push([3, 5, , 6]);\r\n return [4 /*yield*/, (0, exports.getJSON)(url)];\r\n case 4:\r\n res = _a.sent();\r\n done = check(res);\r\n return [3 /*break*/, 6];\r\n case 5:\r\n err_1 = _a.sent();\r\n reject(err_1);\r\n return [3 /*break*/, 6];\r\n case 6: return [3 /*break*/, 1];\r\n case 7:\r\n resolve(res);\r\n return [2 /*return*/];\r\n }\r\n });\r\n }); });\r\n};\r\nexports.poll = poll;\r\nvar pause = function (ms) {\r\n return new Promise(function (r) { return setTimeout(r, ms); });\r\n};\r\n","\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar oj_eventaggregator_1 = require(\"oj-eventaggregator\");\r\nvar Component = /** @class */ (function (_super) {\r\n __extends(Component, _super);\r\n function Component(name, root, options) {\r\n if (options === void 0) { options = {}; }\r\n var _this = _super.call(this) || this;\r\n _this.id = Component.id++;\r\n _this.name = name;\r\n Object.assign(_this, options);\r\n setTimeout(function () { return _this.remount(root); });\r\n return _this;\r\n }\r\n Component.getRoots = function (selector) {\r\n return Array.from(document.querySelectorAll(selector));\r\n };\r\n Component.prototype.remount = function (root) {\r\n if (!root) {\r\n if (!this.rootId)\r\n throw new Error(\"Cannot remount, no element for id \\\"\" + this.rootId + \"\\\" found\");\r\n var node = document.getElementById(this.rootId);\r\n if (!node)\r\n throw new Error(\"Cannot remount, no element for id \\\"\" + this.rootId + \"\\\" found\");\r\n this.remount(node);\r\n return this;\r\n }\r\n this.root = root;\r\n var dataVal = this.root.getAttribute(\"data-\" + this.name);\r\n this.root.setAttribute(\"data-\" + this.name, \"loaded\");\r\n this.rootId = this.root.id;\r\n this.initialize(dataVal);\r\n };\r\n Component.id = 0;\r\n return Component;\r\n}(oj_eventaggregator_1.EventAggregator));\r\nexports.default = Component;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.appendDivTo = exports.loadScript = exports.mounter = exports.getRootData = exports.jsonFromB64 = exports.jsonToB64 = exports.replaceElement = exports.getRootElements = exports.sanitizeHTML = exports.getOffsetY = exports.getOffsetX = exports.getEventProps = exports.childOf = exports.withinViewport = exports.getOffsetsOnPage = exports.getOuterWidth = exports.getOuterHeight = exports.getTransitionDuration = void 0;\r\nvar getTransitionDuration = function (element, deep) {\r\n if (deep === void 0) { deep = false; }\r\n var duration = Math.max.apply(Math, (window.getComputedStyle(element).transitionDuration || \"0\").split(\",\").map(function (x) { return parseFloat(x); }));\r\n var delay = Math.max.apply(Math, (window.getComputedStyle(element).transitionDelay || \"0\").split(\",\").map(function (x) { return parseFloat(x); }));\r\n var totalTime = (duration + delay) * 1000;\r\n if (deep)\r\n totalTime += Array.from(element.children || []).reduce(function (sum, x) { return sum += (0, exports.getTransitionDuration)(x, deep); }, 0);\r\n return totalTime;\r\n};\r\nexports.getTransitionDuration = getTransitionDuration;\r\nvar getOuterHeight = function (element) {\r\n var styles = getComputedStyle(element);\r\n return parseFloat(styles.height || \"0\")\r\n + parseFloat(styles.marginTop || \"0\")\r\n + parseFloat(styles.marginBottom || \"0\")\r\n + parseFloat(styles.paddingTop || \"0\")\r\n + parseFloat(styles.paddingBottom || \"0\");\r\n};\r\nexports.getOuterHeight = getOuterHeight;\r\nvar getOuterWidth = function (element) {\r\n var styles = getComputedStyle(element);\r\n return parseFloat(styles.width || \"0\")\r\n + parseFloat(styles.marginLeft || \"0\")\r\n + parseFloat(styles.marginRight || \"0\")\r\n + parseFloat(styles.paddingLeft || \"0\")\r\n + parseFloat(styles.paddingRight || \"0\");\r\n};\r\nexports.getOuterWidth = getOuterWidth;\r\nvar getOffsetsOnPage = function (element) {\r\n var _x = 0;\r\n var _y = 0;\r\n while (element && !isNaN(element.offsetLeft) && !isNaN(element.offsetTop)) {\r\n _x += element.offsetLeft - element.scrollLeft;\r\n _y += element.offsetTop - element.scrollTop;\r\n element = element.offsetParent;\r\n }\r\n return { top: _y, left: _x };\r\n};\r\nexports.getOffsetsOnPage = getOffsetsOnPage;\r\nvar withinViewport = function (element, completely) {\r\n if (completely === void 0) { completely = true; }\r\n var rect = element.getBoundingClientRect();\r\n var windowHeight = window.innerHeight || document.documentElement.clientHeight;\r\n var windowWidth = window.innerWidth || document.documentElement.clientWidth;\r\n var topVisible = rect.top > 0 && rect.top < windowHeight;\r\n var bottomVisible = rect.bottom < windowHeight && rect.bottom > 0;\r\n var leftVisible = rect.left > 0 && rect.left < windowWidth;\r\n var rightVisible = rect.right < windowWidth && rect.right > 0;\r\n return completely\r\n ? (topVisible && bottomVisible && leftVisible && rightVisible)\r\n : ((topVisible || bottomVisible) && (leftVisible || rightVisible));\r\n};\r\nexports.withinViewport = withinViewport;\r\nvar childOf = function (container, child) {\r\n var el = child;\r\n if (!el)\r\n return false;\r\n while (el !== container) {\r\n if (!el.parentNode)\r\n return false;\r\n el = el.parentNode;\r\n }\r\n return true;\r\n};\r\nexports.childOf = childOf;\r\nvar getEventProps = function (e) {\r\n if (e.targetTouches && e.targetTouches[0])\r\n return e.targetTouches[0];\r\n if (e.changedTouches && e.changedTouches[0])\r\n return e.changedTouches[0];\r\n return e;\r\n};\r\nexports.getEventProps = getEventProps;\r\nvar getOffsetX = function (e) {\r\n var x = 0;\r\n var elem = e.target;\r\n while (elem) {\r\n x += parseInt(elem.offsetLeft);\r\n elem = elem.offsetParent;\r\n }\r\n return (0, exports.getEventProps)(e).pageX - x;\r\n};\r\nexports.getOffsetX = getOffsetX;\r\nvar getOffsetY = function (e) {\r\n var y = 0;\r\n var elem = e.target;\r\n while (elem) {\r\n y += parseInt(elem.offsetTop);\r\n elem = elem.offsetParent;\r\n }\r\n return (0, exports.getEventProps)(e).pageY - y;\r\n};\r\nexports.getOffsetY = getOffsetY;\r\nvar sanitizeHTML = function (html) {\r\n var ta = document.createElement(\"textarea\");\r\n ta.innerHTML = html;\r\n return (ta.value || html)\r\n .replace(/NS\\d+:href/gi, 'xlink:href')\r\n .replace(/[\\u00A0-\\u9999\\&]/gm, function (i) { return \"&#\".concat(i.charCodeAt(0), \";\"); });\r\n};\r\nexports.sanitizeHTML = sanitizeHTML;\r\nvar getRootElements = function (selector, loaded) {\r\n var elements = Array.from(document.querySelectorAll(selector));\r\n if (!loaded)\r\n return elements;\r\n elements = elements.filter(function (x) { return !x.getAttribute(\"data-loaded\"); });\r\n elements.forEach(function (x) { return x.setAttribute(\"data-loaded\", \"=D\"); });\r\n return elements;\r\n};\r\nexports.getRootElements = getRootElements;\r\nvar replaceElement = function (n, o) {\r\n o.parentElement.replaceChild(n, o);\r\n return n;\r\n};\r\nexports.replaceElement = replaceElement;\r\nvar jsonToB64 = function (json) {\r\n return btoa(JSON.stringify(json));\r\n};\r\nexports.jsonToB64 = jsonToB64;\r\nvar jsonFromB64 = function (b64) {\r\n return JSON.parse(atob(b64));\r\n};\r\nexports.jsonFromB64 = jsonFromB64;\r\nvar getRootData = function (x) {\r\n var input = x.querySelector(\"input\");\r\n var data;\r\n try {\r\n data = input ? JSON.parse(input.value) : null;\r\n }\r\n catch (err) {\r\n data = null;\r\n }\r\n return data;\r\n};\r\nexports.getRootData = getRootData;\r\nvar mounter = function (selector, cb) {\r\n return (0, exports.getRootElements)(selector)\r\n .forEach(function (x) {\r\n return cb(x, (0, exports.getRootData)(x));\r\n });\r\n};\r\nexports.mounter = mounter;\r\nvar loadScript = function (url, target) {\r\n if (target === void 0) { target = document.body; }\r\n return new Promise(function (res, rej) {\r\n var tag = document.createElement(\"script\");\r\n tag.onload = function (e) { return res(e); };\r\n tag.onerror = function (e) { return rej(e); };\r\n tag.src = url;\r\n target.appendChild(tag);\r\n });\r\n};\r\nexports.loadScript = loadScript;\r\nvar appendDivTo = function (target) {\r\n if (target === void 0) { target = document.body; }\r\n var root = document.createElement(\"div\");\r\n target.appendChild(root);\r\n return root;\r\n};\r\nexports.appendDivTo = appendDivTo;\r\n","\"use strict\";\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nrequire(\"oj-event\");\r\nvar oj_utils_1 = require(\"oj-utils\");\r\nvar oj_dom_utils_1 = require(\"oj-dom-utils\");\r\nvar Draggable = /** @class */ (function () {\r\n function Draggable(options) {\r\n if (options === void 0) { options = {}; }\r\n this.id = Draggable.id();\r\n this.subs = {};\r\n Object.assign(this, { ratio: false, corners: true, area: 20 }, options);\r\n }\r\n Draggable.prototype.setOptions = function (options) {\r\n if (options === void 0) { options = {}; }\r\n Object.assign(this, options);\r\n };\r\n Draggable.prototype.start = function (e, options) {\r\n var _this = this;\r\n if (options === void 0) { options = {}; }\r\n Object.assign(this, { context: null }, options);\r\n e.redraw = false;\r\n if (this.dragging)\r\n return;\r\n if (options.preventDefault)\r\n e.preventDefault();\r\n this.offsetX = oj_dom_utils_1.getOffsetX(e);\r\n this.offsetY = oj_dom_utils_1.getOffsetY(e);\r\n var p = oj_dom_utils_1.getEventProps(e);\r\n this.startX = p.pageX;\r\n this.startY = p.pageY;\r\n this.side = this.side || this.getResizeSides(e.target);\r\n if (this.ratio)\r\n this.ratio = this.rect.width / this.rect.height;\r\n this.dragging = true;\r\n window.on(\"mousemove.draggable.\" + this.id, function (e) { return _this.drag(e, options); });\r\n window.on(\"mouseup.draggable.\" + this.id, function (e) { return _this.stop(e, options); });\r\n window.on(\"touchmove.draggable.\" + this.id, function (e) { return _this.drag(e, options); }, { passive: false });\r\n window.on(\"touchend.draggable.\" + this.id, function (e) { return _this.stop(e, options); }, { passive: false });\r\n this.emit(\"start\", { rect: this.rect, context: this.context });\r\n };\r\n Draggable.prototype.on = function (event, fn) {\r\n if (!this.subs[event])\r\n this.subs[event] = [];\r\n this.subs[event].push(fn);\r\n };\r\n Draggable.prototype.getResizeSides = function (target) {\r\n var sides = \"\";\r\n if (this.offsetX < this.area) {\r\n sides += \"left\";\r\n if (!this.corners)\r\n return sides;\r\n }\r\n else if (this.offsetX > target.clientWidth - this.area) {\r\n sides += \"right\";\r\n if (!this.corners)\r\n return sides;\r\n }\r\n if (this.offsetY < this.area) {\r\n sides += \"top\";\r\n if (!this.corners)\r\n return sides;\r\n }\r\n else if (this.offsetY > target.clientHeight - this.area) {\r\n sides += \"bottom\";\r\n if (!this.corners)\r\n return sides;\r\n }\r\n return sides;\r\n };\r\n Draggable.prototype.setCursor = function (e, cursor) {\r\n e.redraw = false;\r\n if (this.dragging)\r\n return;\r\n if (cursor) {\r\n e.target.style.cursor = cursor;\r\n return;\r\n }\r\n this.offsetX = e.offsetX;\r\n this.offsetY = e.offsetY;\r\n var sides = this.getResizeSides(e.target);\r\n e.target.style.cursor = \"move\";\r\n if (sides.indexOf(\"left\") !== -1 || sides.indexOf(\"right\") !== -1)\r\n e.target.style.cursor = \"ew-resize\";\r\n if (sides.indexOf(\"top\") !== -1 || sides.indexOf(\"bottom\") !== -1)\r\n e.target.style.cursor = \"ns-resize\";\r\n if (sides.indexOf(\"top\") !== -1 && sides.indexOf(\"left\") !== -1)\r\n e.target.style.cursor = \"nw-resize\";\r\n if (sides.indexOf(\"top\") !== -1 && sides.indexOf(\"right\") !== -1)\r\n e.target.style.cursor = \"ne-resize\";\r\n if (sides.indexOf(\"bottom\") !== -1 && sides.indexOf(\"left\") !== -1)\r\n e.target.style.cursor = \"sw-resize\";\r\n if (sides.indexOf(\"bottom\") !== -1 && sides.indexOf(\"right\") !== -1)\r\n e.target.style.cursor = \"se-resize\";\r\n };\r\n Draggable.prototype.drag = function (e, options) {\r\n if (options === void 0) { options = {}; }\r\n if (!this.dragging)\r\n return;\r\n if (options.preventDefault)\r\n e.preventDefault();\r\n var p = oj_dom_utils_1.getEventProps(e);\r\n if (this.side === \"\") {\r\n var diff = { x: p.pageX - this.startX, y: p.pageY - this.startY };\r\n this.emit(\"diff\", { diff: diff, context: this.context });\r\n var rect = this.rect === undefined ? undefined : {\r\n x: this.rect.x + diff.x,\r\n y: this.rect.y + diff.y,\r\n width: this.rect.width,\r\n height: this.rect.height,\r\n };\r\n if (rect && this.grid && this.container)\r\n Draggable.constrainToGrid(this.container, this.grid, rect);\r\n this.emit(\"drag\", { diff: diff, rect: rect, context: this.context });\r\n }\r\n else {\r\n var diff = { x: 0, y: 0, width: 0, height: 0 };\r\n var rect = this.rect === undefined ? undefined : __assign({}, this.rect);\r\n if (this.side.indexOf(\"left\") !== -1) {\r\n diff.x = p.pageX - this.startX;\r\n this.emit(\"diff\", { diff: diff, context: this.context });\r\n if (rect) {\r\n rect.x = this.rect.x + diff.x;\r\n rect.width = this.rect.width - diff.x;\r\n if (typeof this.ratio === \"number\") {\r\n rect.height = this.rect.height - (diff.x * this.ratio);\r\n }\r\n }\r\n }\r\n if (this.side.indexOf(\"right\") !== -1) {\r\n diff.width = p.pageX - this.startX;\r\n this.emit(\"diff\", { diff: diff, context: this.context });\r\n if (rect) {\r\n rect.width = this.rect.width + diff.width;\r\n if (typeof this.ratio === \"number\") {\r\n rect.height = this.rect.height + (diff.width * this.ratio);\r\n }\r\n }\r\n }\r\n if (this.side.indexOf(\"top\") !== -1) {\r\n diff.y = p.pageY - this.startY;\r\n this.emit(\"diff\", { diff: diff, context: this.context });\r\n if (rect) {\r\n rect.y = this.rect.y + diff.y;\r\n rect.height = this.rect.height - diff.y;\r\n if (typeof this.ratio === \"number\") {\r\n rect.width = this.rect.width - (diff.y * this.ratio);\r\n }\r\n }\r\n }\r\n if (this.side.indexOf(\"bottom\") !== -1) {\r\n diff.height = p.pageY - this.startY;\r\n this.emit(\"diff\", { diff: diff, context: this.context });\r\n if (rect) {\r\n rect.height = this.rect.height + diff.height;\r\n if (typeof this.ratio === \"number\") {\r\n rect.width = this.rect.width + (diff.height * this.ratio);\r\n }\r\n }\r\n }\r\n if (rect && this.grid && this.container)\r\n Draggable.constrainToGrid(this.container, this.grid, rect);\r\n this.emit(\"resize\", { diff: diff, rect: rect, context: this.context });\r\n }\r\n };\r\n Draggable.constrainToGrid = function (container, grid, rect) {\r\n var w = Math.floor(container.width / grid.width);\r\n var h = Math.floor(container.height / grid.height);\r\n var apply = function (s, x) {\r\n var rest = rect[s] % x;\r\n if (rest !== 0) {\r\n if (rest < x / 2)\r\n rect[s] = rect[s] - rest;\r\n else\r\n rect[s] = rect[s] + (x - rest);\r\n }\r\n };\r\n apply(\"left\", w);\r\n apply(\"width\", w);\r\n apply(\"top\", h);\r\n apply(\"height\", h);\r\n return rect;\r\n };\r\n Draggable.prototype.stop = function (e, options) {\r\n if (options === void 0) { options = {}; }\r\n if (!this.dragging)\r\n return;\r\n if (options.preventDefault)\r\n e.preventDefault();\r\n this.side = \"\";\r\n this.dragging = false;\r\n window.off(\"mousemove.draggable.\" + this.id);\r\n window.off(\"mouseup.draggable.\" + this.id);\r\n window.off(\"touchmove.draggable.\" + this.id);\r\n window.off(\"touchend.draggable.\" + this.id);\r\n var p = oj_dom_utils_1.getEventProps(e);\r\n this.emit(\"stop\", { rect: { left: p.pageX - this.startX, top: p.pageY - this.startY }, context: this.context });\r\n };\r\n Draggable.prototype.emit = function (event) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n if (this.subs[event])\r\n this.subs[event].forEach(function (e) { return e.apply(void 0, args); });\r\n };\r\n Draggable.id = oj_utils_1.increment();\r\n return Draggable;\r\n}());\r\nexports.default = Draggable;\r\n","\"use strict\";\r\nvar __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nvar getNamespace = function (arr) { return arr.slice(1).join(\".\") || arr[0]; };\r\nvar debounce = function (fn, threshold) {\r\n if (threshold === void 0) { threshold = 100; }\r\n var t;\r\n return (function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n clearTimeout(t);\r\n t = setTimeout(function () { return fn.apply(void 0, args); }, threshold);\r\n });\r\n};\r\nvar has = function (event) {\r\n var _this = this;\r\n if (Array.isArray(event))\r\n return !!event.find(function (x) { return _this.has(x); });\r\n var arr = event.split(\".\");\r\n var nsp = getNamespace(arr);\r\n var type = arr[0];\r\n return this.namespaces && this.namespaces[nsp] && typeof this.namespaces[nsp][type] === \"function\";\r\n};\r\nvar on = function (event, cb, opts) {\r\n var _this = this;\r\n if (!opts)\r\n opts === false;\r\n if (Array.isArray(event)) {\r\n cb = debounce(cb, 10);\r\n event.forEach(function (e) { return _this.on(e, cb, opts); });\r\n return this;\r\n }\r\n var arr = event.split(\".\");\r\n var nsp = getNamespace(arr);\r\n var type = arr[0];\r\n if (!this.namespaces)\r\n this.namespaces = {};\r\n if (!this.namespaces[nsp])\r\n this.namespaces[nsp] = {};\r\n if (this.namespaces[nsp][type])\r\n this.removeEventListener(type, this.namespaces[nsp][type]);\r\n this.namespaces[nsp][type] = function (e) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n if (opts && opts.preventDefault)\r\n e.preventDefault();\r\n if (opts && opts.stopPropagation)\r\n e.stopPropagation();\r\n return cb.apply(void 0, __spreadArray([e], args, false));\r\n };\r\n this.addEventListener(type, this.namespaces[nsp][type], opts);\r\n return this;\r\n};\r\nvar off = function (event) {\r\n var _this = this;\r\n if (Array.isArray(event)) {\r\n event.forEach(function (e) { return _this.off(e); });\r\n return this;\r\n }\r\n var arr = event.split(\".\");\r\n var nsp = getNamespace(arr);\r\n var type = arr[0];\r\n if (!this.namespaces || !this.namespaces[nsp] || !this.namespaces[nsp][type])\r\n return this;\r\n try {\r\n this.removeEventListener(type, this.namespaces[nsp][type]);\r\n delete this.namespaces[nsp][type];\r\n }\r\n catch (err) {\r\n console.error(err);\r\n }\r\n return this;\r\n};\r\nvar once = function (event, cb, opts) {\r\n var _this = this;\r\n on.call(this, event, function (e) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n off.call(_this, event);\r\n return cb.apply(void 0, __spreadArray([e], args, false));\r\n }, opts);\r\n return this;\r\n};\r\nwindow.has = document.has = Element.prototype.has = has;\r\nwindow.on = document.on = Element.prototype.on = on;\r\nwindow.once = document.once = Element.prototype.once = once;\r\nwindow.off = document.off = Element.prototype.off = off;\r\n","\"use strict\";\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.EventAggregator = void 0;\r\nvar EventAggregator = /** @class */ (function () {\r\n function EventAggregator() {\r\n this.events = {};\r\n this.paused = false;\r\n }\r\n EventAggregator.prototype.emit = function (event, data) {\r\n var _a, _b;\r\n if (this.paused)\r\n return this;\r\n (_a = this.events[event]) === null || _a === void 0 ? void 0 : _a.filter(function (x) { return !x.paused; }).forEach(function (x) { return x.fn(data, event); });\r\n (_b = this.events[\"*\"]) === null || _b === void 0 ? void 0 : _b.filter(function (x) { return !x.paused; }).forEach(function (x) { return x.fn(data, event); });\r\n return this;\r\n };\r\n EventAggregator.prototype.on = function (event, fn) {\r\n var _this = this;\r\n var _a;\r\n var _b;\r\n (_a = (_b = this.events)[event]) !== null && _a !== void 0 ? _a : (_b[event] = []);\r\n var sub = {\r\n fn: fn,\r\n off: function () { return _this.off(event, sub); },\r\n pause: function () { return sub.paused = true; },\r\n resume: function () { return sub.paused = false; },\r\n };\r\n this.events[event].push(sub);\r\n return sub;\r\n };\r\n EventAggregator.prototype.once = function (event, fn) {\r\n var sub = this.on(event, function (d, e) {\r\n sub.off();\r\n fn(d, e);\r\n });\r\n return sub;\r\n };\r\n EventAggregator.prototype.off = function (event, sub) {\r\n if (!this.events[event])\r\n return;\r\n var i = this.events[event].indexOf(sub);\r\n if (i === -1)\r\n return;\r\n this.events[event].splice(i, 1);\r\n return this;\r\n };\r\n EventAggregator.prototype.clear = function (event) {\r\n this.events[event].forEach(function (x) { return x.off(); });\r\n return this;\r\n };\r\n EventAggregator.prototype.emitMultiple = function (events, data) {\r\n var _this = this;\r\n events.forEach(function (event) { return _this.emit(event, data); });\r\n return this;\r\n };\r\n EventAggregator.prototype.onMultiple = function (events, fn) {\r\n var _this = this;\r\n return events.map(function (event) { return _this.on(event, function (d, e) { return fn(d, e); }); });\r\n };\r\n EventAggregator.prototype.onceMultiple = function (events, fn) {\r\n var _this = this;\r\n var subs = events.map(function (event) { return _this.once(event, function (d, e) {\r\n subs.forEach(function (x) { return x.off(); });\r\n fn(d, e);\r\n }); });\r\n return subs;\r\n };\r\n EventAggregator.prototype.clearMultiple = function (events) {\r\n var _this = this;\r\n events.forEach(function (event) { return _this.clear(event); });\r\n return this;\r\n };\r\n EventAggregator.prototype.pause = function () {\r\n this.paused = true;\r\n return this;\r\n };\r\n EventAggregator.prototype.resume = function () {\r\n this.paused = false;\r\n return this;\r\n };\r\n return EventAggregator;\r\n}());\r\nexports.EventAggregator = EventAggregator;\r\n","\"use strict\";\r\nvar __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n};\r\nvar __generator = (this && this.__generator) || function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nrequire(\"oj-event\");\r\nvar oj_component_1 = require(\"oj-component\");\r\nvar FormValidator = /** @class */ (function (_super) {\r\n __extends(FormValidator, _super);\r\n function FormValidator(root, options) {\r\n var _this = _super.call(this, \"form-validator\", root, options) || this;\r\n _this.inputs = [];\r\n FormValidator.validators.push(_this);\r\n return _this;\r\n }\r\n FormValidator.mount = function (options) {\r\n return oj_component_1.default.getRoots(\"form:not([data-form-validator=\\\"loaded\\\"])\").map(function (x) { return new FormValidator(x, options); });\r\n };\r\n FormValidator.prototype.unmount = function () {\r\n var _this = this;\r\n this.submitButton.off([\"click.form-validator.\" + this.id, \"touchend.form-validator.\" + this.id]);\r\n this.inputs.forEach(function (input) {\r\n input.element.off(\"change.form-validator.\" + _this.id);\r\n input.element.off(\"keyup.form-validator.\" + _this.id);\r\n });\r\n var i = FormValidator.validators.indexOf(this);\r\n if (i >= 0)\r\n FormValidator.validators.splice(i, 1);\r\n };\r\n FormValidator.prototype.validateForm = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var valid, errors, _i, _a, input, _b;\r\n return __generator(this, function (_c) {\r\n switch (_c.label) {\r\n case 0:\r\n valid = true;\r\n errors = [];\r\n _i = 0, _a = this.inputs;\r\n _c.label = 1;\r\n case 1:\r\n if (!(_i < _a.length)) return [3 /*break*/, 4];\r\n input = _a[_i];\r\n _b = input;\r\n return [4 /*yield*/, FormValidator.validate(input)];\r\n case 2:\r\n _b.valid = _c.sent();\r\n this.emit(\"change\", { form: this.root, valid: input.valid, button: this.submitButton, input: input });\r\n if (!input.valid) {\r\n valid = false;\r\n if (input.error)\r\n errors.push(input.error);\r\n }\r\n _c.label = 3;\r\n case 3:\r\n _i++;\r\n return [3 /*break*/, 1];\r\n case 4:\r\n this.emit(\"change\", { form: this.root, valid: valid, button: this.submitButton, inputs: this.inputs });\r\n return [2 /*return*/, valid];\r\n }\r\n });\r\n });\r\n };\r\n FormValidator.addRule = function (rule) {\r\n FormValidator.customRules.push(rule);\r\n return this;\r\n };\r\n FormValidator.validateElement = function (element) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var input, validator, _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n validator = FormValidator.validators.find(function (v) {\r\n var i = v.inputs.find(function (i) { return i.element === element; });\r\n if (i !== undefined) {\r\n input = i;\r\n return true;\r\n }\r\n });\r\n if (!input)\r\n input = { element: element, valid: true, error: null };\r\n _a = input;\r\n return [4 /*yield*/, FormValidator.validate(input)];\r\n case 1:\r\n _a.valid = _b.sent();\r\n if (validator)\r\n validator.emit(\"change\", { form: validator.root, input: input, valid: input.valid, button: validator.submitButton });\r\n return [2 /*return*/, input.valid];\r\n }\r\n });\r\n });\r\n };\r\n FormValidator.prototype.initialize = function () {\r\n var _this = this;\r\n this.handleInputElements();\r\n this.submitButton = this.root.querySelector('button[type=\"submit\"], .submit');\r\n if (this.submitButton) {\r\n this.submitButton.on([\"click.form-validator.\" + this.id, \"touchend.form-validator.\" + this.id], function (e) { return _this.validateForm(); }, { preventDefault: true, stopPropagation: true });\r\n }\r\n };\r\n FormValidator.validate = function (input) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var i, result, value, required, minLength, maxLength, email, phone, regex, equalToSelector, eq, value, required, requiredChecked, required;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n if (input.element.classList.contains(\"ignore\")) {\r\n return [2 /*return*/, true];\r\n }\r\n i = 0;\r\n _a.label = 1;\r\n case 1:\r\n if (!(i < FormValidator.customRules.length)) return [3 /*break*/, 4];\r\n return [4 /*yield*/, FormValidator.customRules[i](input.element)];\r\n case 2:\r\n result = _a.sent();\r\n if (result === undefined)\r\n return [3 /*break*/, 3];\r\n input.error = result.error;\r\n if (result.valid === false)\r\n return [2 /*return*/, false];\r\n _a.label = 3;\r\n case 3:\r\n i++;\r\n return [3 /*break*/, 1];\r\n case 4:\r\n if (input.element.type === \"text\" || input.element.type === \"textarea\" || input.element.type === \"password\" || input.element.type === \"email\" || input.element.type === \"url\") {\r\n value = input.element.value.trim();\r\n required = input.element.getAttribute(\"data-val-required\");\r\n if (value.length < 1 && required) {\r\n input.error = required;\r\n return [2 /*return*/, false];\r\n }\r\n minLength = input.element.getAttribute(\"data-val-minlength-min\");\r\n if (minLength && value.length > 0 && value.length < parseFloat(minLength)) {\r\n input.error = input.element.getAttribute(\"data-val-minlength\");\r\n return [2 /*return*/, false];\r\n }\r\n maxLength = input.element.getAttribute(\"data-val-maxlength-max\");\r\n if (maxLength && value.length > 0 && value.length > parseFloat(maxLength)) {\r\n input.error = input.element.getAttribute(\"data-val-maxlength\");\r\n return [2 /*return*/, false];\r\n }\r\n email = input.element.getAttribute(\"data-val-email\");\r\n if (email && !/(.+)@(.+){2,}\\.(.+){2,}/.test(value)) {\r\n input.error = input.element.getAttribute(\"data-val-email\");\r\n return [2 /*return*/, false];\r\n }\r\n phone = input.element.getAttribute(\"data-val-phone\");\r\n if (phone && !/^[+]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\\s\\./0-9]*$/.test(value)) {\r\n input.error = input.element.getAttribute(\"data-val-phone\");\r\n return [2 /*return*/, false];\r\n }\r\n regex = input.element.getAttribute(\"data-val-regex-pattern\") || input.element.getAttribute(\"data-regex\");\r\n if (regex && !RegExp(regex).test(value)) {\r\n input.error = input.element.getAttribute(\"data-val-regex\");\r\n return [2 /*return*/, false];\r\n }\r\n equalToSelector = input.element.getAttribute(\"data-val-equalto-other\");\r\n if (equalToSelector) {\r\n eq = document.querySelector(equalToSelector);\r\n if (!eq) {\r\n input.error = \"No element found for \" + equalToSelector;\r\n return [2 /*return*/, false];\r\n }\r\n if (input.element.value.length > 0 && input.element.value !== eq.value) {\r\n input.error = input.element.getAttribute(\"data-val-equalto\");\r\n return [2 /*return*/, false];\r\n }\r\n }\r\n }\r\n else if (input.element.type === \"checkbox\") {\r\n value = input.element.checked;\r\n required = input.element.getAttribute(\"data-val-required\");\r\n if (value === undefined && required) {\r\n input.error = required;\r\n return [2 /*return*/, false];\r\n }\r\n requiredChecked = input.element.getAttribute(\"data-val-checkrequired\");\r\n if (value !== true && requiredChecked) {\r\n input.error = requiredChecked;\r\n return [2 /*return*/, false];\r\n }\r\n }\r\n else if (input.element instanceof HTMLSelectElement) {\r\n required = input.element.getAttribute(\"data-val-required\");\r\n if (required && input.element.options[input.element.selectedIndex].disabled) {\r\n input.error = required;\r\n return [2 /*return*/, false];\r\n }\r\n }\r\n delete input.error;\r\n return [2 /*return*/, true];\r\n }\r\n });\r\n });\r\n };\r\n FormValidator.prototype.handleInputElements = function () {\r\n var _this = this;\r\n this.inputs = Array.from(this.root.querySelectorAll('input, textarea, select'))\r\n .filter(function (element) { return element instanceof HTMLSelectElement || (element.type !== \"hidden\" && element.hidden === false); })\r\n .map(function (element) {\r\n var input = { element: element };\r\n input.element.on(\"change.form-validator.\" + _this.id, function (e) {\r\n if (element instanceof HTMLSelectElement)\r\n _this.handleChanges(input);\r\n else\r\n _this.handleChanges(input).then(function (valid) {\r\n if (valid)\r\n input.element.off(\"keyup.form-validator.\" + _this.id);\r\n else\r\n input.element.on(\"keyup.form-validator.\" + _this.id, function (e) { return _this.handleChanges(input); });\r\n });\r\n });\r\n return input;\r\n });\r\n };\r\n FormValidator.prototype.handleChanges = function (input) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var _a;\r\n return __generator(this, function (_b) {\r\n switch (_b.label) {\r\n case 0:\r\n _a = input;\r\n return [4 /*yield*/, FormValidator.validate(input)];\r\n case 1:\r\n _a.valid = _b.sent();\r\n this.emit(\"change\", { form: this.root, input: input, valid: input.valid, button: this.submitButton });\r\n return [2 /*return*/, input.valid];\r\n }\r\n });\r\n });\r\n };\r\n FormValidator.validators = [];\r\n FormValidator.customRules = [];\r\n return FormValidator;\r\n}(oj_component_1.default));\r\nexports.default = FormValidator;\r\n","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString } from \"oj-utils\";\r\nvar Tooltip = (function (_super) {\r\n __extends(Tooltip, _super);\r\n function Tooltip() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n Tooltip.prototype.view = function (v) {\r\n return m(\"div\", { className: cleanString(\"tooltip-container\", v.attrs.className, \"tooltip-\" + (v.attrs.direction || \"default\")) },\r\n m(\"div\", null, v.children),\r\n m(\"span\", { className: \"tooltip\" },\r\n m(\"span\", null, v.attrs.text)));\r\n };\r\n return Tooltip;\r\n}(MithrilTsxComponent));\r\nexport { Tooltip };\r\n//# sourceMappingURL=index.js.map","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString } from \"oj-utils\";\r\nimport { Zmdi } from \"../Zmdi\";\r\nimport { Svg } from \"../Svg\";\r\nvar Button = (function (_super) {\r\n __extends(Button, _super);\r\n function Button() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n Button.prototype.view = function (v) {\r\n var _this = this;\r\n return m(\"button\", { type: v.attrs.submit ? \"submit\" : \"button\", title: v.attrs.title, className: cleanString(\"component-Button\", v.attrs.className), \"aria-label\": v.attrs.label, onmousedown: function (e) {\r\n if (e.button === 0) {\r\n _this.handleKeepDown(v, e);\r\n if (!_this.tapped(e))\r\n v.attrs.onclick(e);\r\n }\r\n else\r\n _this.unhandleKeepDown(v, e);\r\n }, onmouseup: function (e) {\r\n _this.unhandleKeepDown(v, e);\r\n }, ontouchstart: function (e) {\r\n _this.handleKeepDown(v, e);\r\n }, ontouchend: function (e) {\r\n _this.unhandleKeepDown(v, e);\r\n if (!_this.tapped(e))\r\n v.attrs.onclick(e);\r\n }, onmouseleave: function (e) {\r\n _this.unhandleKeepDown(v, e);\r\n }, oncontextmenu: function (e) {\r\n e.preventDefault();\r\n e.stopPropagation();\r\n return false;\r\n }, disabled: v.attrs.disabled },\r\n v.attrs.name ? m(\"span\", null, v.attrs.name) : v.children,\r\n m(Zmdi, { icon: v.attrs.zmdi }),\r\n m(Svg, { src: v.attrs.svg }));\r\n };\r\n Button.prototype.onbeforeupdate = function (v, o) {\r\n if (!o.attrs.disabled && v.attrs.disabled)\r\n this.unhandleKeepDown(v);\r\n };\r\n Button.prototype.handleKeepDown = function (v, e) {\r\n var _this = this;\r\n e.redraw = false;\r\n this.unhandleKeepDown(v, e);\r\n if (!v.attrs.bounce)\r\n return;\r\n this.timeout = setTimeout(function () {\r\n _this.isKeepDown = true;\r\n _this.interval = setInterval(function () {\r\n if (!v.dom || !document.body.contains(v.dom))\r\n return _this.unhandleKeepDown(v, e);\r\n v.attrs.onclick(e, true);\r\n m.redraw();\r\n }, 100);\r\n }, 500);\r\n };\r\n Button.prototype.unhandleKeepDown = function (v, e) {\r\n clearInterval(this.interval);\r\n clearTimeout(this.timeout);\r\n if (this.isKeepDown === true) {\r\n this.isKeepDown = false;\r\n v.attrs.onclick(e);\r\n }\r\n };\r\n Button.prototype.tapped = function (e) {\r\n var _this = this;\r\n if (this.isTapped) {\r\n e.redraw = false;\r\n return true;\r\n }\r\n this.isTapped = true;\r\n this.tappedTimer = setTimeout(function () { return _this.isTapped = false; }, 50);\r\n return false;\r\n };\r\n return Button;\r\n}(MithrilTsxComponent));\r\nexport { Button };\r\n//# sourceMappingURL=index.js.map","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString, exec } from \"oj-utils\";\r\nimport { getTransitionDuration } from \"oj-dom-utils\";\r\nimport \"./style.scss\";\r\nimport Draggable from \"oj-draggable\";\r\nimport { Button } from \"../Button\";\r\nimport \"oj-event\";\r\nvar Carousel = (function (_super) {\r\n __extends(Carousel, _super);\r\n function Carousel() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.index = 0;\r\n return _this;\r\n }\r\n Carousel.prototype.oninit = function (v) {\r\n var _this = this;\r\n v.children.forEach(function (x, i) { return x.key = i; });\r\n this.children = [v.children[0]];\r\n if (v.attrs.autoplay) {\r\n this.setAutoplay(v);\r\n }\r\n this.draggable = new Draggable();\r\n this.draggable.on(\"stop\", function (_a) {\r\n var rect = _a.rect;\r\n if (rect.left > 50) {\r\n _this.prev(v);\r\n m.redraw();\r\n }\r\n else if (rect.left < -50) {\r\n _this.next(v);\r\n m.redraw();\r\n }\r\n });\r\n };\r\n Carousel.prototype.onbeforeupdate = function (v) {\r\n v.children.forEach(function (x, i) { return x.key = i; });\r\n };\r\n Carousel.prototype.view = function (v) {\r\n var _this = this;\r\n return m(\"div\", { className: cleanString(\"component-Carousel carousel\", v.attrs.className), onclick: function (e) { return exec(onclick, e); }, onmouseenter: function (e) { return v.attrs.autoplay && _this.stopAutoplay(v); }, ontouchstart: function (e) { return v.attrs.autoplay && _this.stopAutoplay(v); }, onmouseleave: function (e) { return v.attrs.autoplay && _this.setAutoplay(v); } },\r\n m(\"div\", { className: \"carousel-container\", onmousedown: function (e) { return _this.draggable.start(e); }, ontouchstart: function (e) { return _this.draggable.start(e); } },\r\n m(\"div\", { className: \"carousel-rail\", style: { width: 100 * this.children.length + \"%\" }, oncreate: function (_a) {\r\n var dom = _a.dom;\r\n return _this.rail = dom;\r\n } }, this.children.map(function (x, i) {\r\n return m(\"div\", { key: x.key, className: cleanString(\"carousel-slide\"), style: { minWidth: 100 / _this.children.length + \"%\", height: v.attrs.height + \"px\" }, oncreate: function (cv) {\r\n setTimeout(function () { return cv.dom.classList.add(\"active\"); }, 35);\r\n } }, x);\r\n }))),\r\n v.attrs.arrows && m(\"div\", { className: \"carousel-nav\" },\r\n m(Button, { className: \"btn-square-default carousel-prev\", zmdi: \"chevron-left\", onclick: function (e) { return _this.prev(v); }, label: \"vorige\" }),\r\n m(Button, { className: \"btn-square-default carousel-next\", zmdi: \"chevron-right\", onclick: function (e) { return _this.next(v); }, label: \"volgende\" })),\r\n v.attrs.dots && m(\"div\", { className: \"carousel-controls\" }, v.children.map(function (x, i) { return m(Button, { className: cleanString(\"carousel-dot\", _this.index === i && \"active\"), onclick: function (e) { return _this.setIndex(v, i); }, label: \"slide-\" + i }); })));\r\n };\r\n Carousel.prototype.resetChildren = function (v) {\r\n var _this = this;\r\n clearTimeout(this.timer);\r\n this.timer = setTimeout(function () {\r\n _this.rail.style.transition = \"none\";\r\n _this.rail.style.transform = \"\";\r\n _this.children = [v.children[_this.index]];\r\n v.attrs.onchange(_this.index);\r\n m.redraw();\r\n }, getTransitionDuration(this.rail));\r\n };\r\n Carousel.prototype.transformTo = function (v, leftToRight, i) {\r\n var _this = this;\r\n this.children = leftToRight ? [v.children[this.index], v.children[i]] : [v.children[i], v.children[this.index]];\r\n m.redraw();\r\n this.rail.style.transition = \"none\";\r\n this.rail.style.transform = leftToRight ? \"\" : \"translateX(\" + -100 / this.children.length + \"%)\";\r\n clearTimeout(this.timer);\r\n this.timer = setTimeout(function () {\r\n _this.rail.style.transition = \"\";\r\n _this.rail.style.transform = leftToRight ? \"translateX(\" + -100 / _this.children.length + \"%)\" : \"\";\r\n _this.resetChildren(v);\r\n m.redraw();\r\n }, 35);\r\n };\r\n Carousel.prototype.setIndex = function (v, i) {\r\n if (this.index === i)\r\n return;\r\n var leftToRight = i > this.index;\r\n var min = 0;\r\n var max = v.children.length - 1;\r\n i = i < min ? max : i > max ? min : i;\r\n this.transformTo(v, leftToRight, i);\r\n this.index = i;\r\n };\r\n Carousel.prototype.next = function (v) {\r\n this.setIndex(v, this.index + 1);\r\n };\r\n Carousel.prototype.prev = function (v) {\r\n this.setIndex(v, this.index - 1);\r\n };\r\n Carousel.prototype.setAutoplay = function (v) {\r\n var _this = this;\r\n this.autoplay = setInterval(function () {\r\n _this.next(v);\r\n m.redraw();\r\n }, v.attrs.autoplay);\r\n };\r\n Carousel.prototype.stopAutoplay = function (v) {\r\n clearInterval(this.autoplay);\r\n };\r\n return Carousel;\r\n}(MithrilTsxComponent));\r\nexport { Carousel };\r\n//# sourceMappingURL=index.js.map","// extracted by mini-css-extract-plugin","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString, exec, increment } from \"oj-utils\";\r\nimport { getTransitionDuration } from \"oj-dom-utils\";\r\nimport { Button } from \"../Button\";\r\nimport { Zmdi } from \"../Zmdi\";\r\nimport \"oj-event\";\r\nvar inc = increment();\r\nexport var DialogSize;\r\n(function (DialogSize) {\r\n DialogSize[\"s\"] = \"small\";\r\n DialogSize[\"m\"] = \"medium\";\r\n DialogSize[\"l\"] = \"large\";\r\n DialogSize[\"a\"] = \"auto\";\r\n})(DialogSize || (DialogSize = {}));\r\nvar Dialog = (function (_super) {\r\n __extends(Dialog, _super);\r\n function Dialog() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.id = inc();\r\n return _this;\r\n }\r\n Dialog.prototype.oninit = function (v) {\r\n this.setOpen(v, v.attrs.open);\r\n };\r\n Dialog.prototype.setOpen = function (v, open) {\r\n var _this = this;\r\n if (open === void 0) { open = true; }\r\n if (open) {\r\n document.body.classList.add(\"modal-open\");\r\n exec(v.attrs.onopen);\r\n window.on(\"keydown.Dialog.\" + this.id, function (e) { return _this.handleKeydown(v, e); });\r\n setTimeout(function () { return (v.children[0].dom).focus(); }, 500);\r\n }\r\n else {\r\n document.body.classList.remove(\"modal-open\");\r\n exec(v.attrs.onclose);\r\n window.off(\"keydown.Dialog.\" + this.id);\r\n }\r\n };\r\n Dialog.prototype.handleKeydown = function (v, e) {\r\n if (e.which === 27) {\r\n e.preventDefault();\r\n this.setOpen(v, false);\r\n m.redraw();\r\n return false;\r\n }\r\n };\r\n Dialog.prototype.onbeforeupdate = function (v, o) {\r\n var _this = this;\r\n if (v.attrs.open !== o.attrs.open) {\r\n clearTimeout(this.timer);\r\n this.outro = !v.attrs.open;\r\n this.setOpen(v, v.attrs.open);\r\n if (this.outro)\r\n this.timer = setTimeout(function () {\r\n _this.outro = false;\r\n _this.setOpen(v, false);\r\n m.redraw();\r\n }, getTransitionDuration(this.dom));\r\n }\r\n };\r\n Dialog.prototype.onremove = function (v) {\r\n clearTimeout(this.timer);\r\n document.body.classList.remove(\"modal-open\");\r\n window.off(\"keydown.Dialog.\" + this.id);\r\n };\r\n Dialog.prototype.view = function (v) {\r\n var _this = this;\r\n return m(\"div\", { className: cleanString(\"component-Dialog modal-container\", \"modal\", v.attrs.open && \"active\", this.outro && \"de-active\", v.attrs.fullscreen && \"fullscreen\", v.attrs.className), oncreate: function (v) { return _this.dom = v.dom; }, onclick: function (e) {\r\n if (e.target === _this.dom) {\r\n exec(v.attrs.oncontainerclick, e);\r\n if (v.attrs.containerclose)\r\n _this.setOpen(v, false);\r\n }\r\n } },\r\n m(\"div\", { className: cleanString(\"dialog\", \"modal-window\", v.attrs.open && \"active\", this.outro && \"de-active\", v.attrs.size || DialogSize.m) },\r\n m(\"header\", { className: cleanString(\"modal-header\", !v.attrs.header && \"no-title\") },\r\n v.attrs.header && m(\"h2\", { class: \"h2\" }, v.attrs.header),\r\n m(Button, { onclick: function (e) { e.stopPropagation(); _this.setOpen(v, false); }, className: \"btn-close\" },\r\n m(Zmdi, { icon: v.attrs.zmdi || \"close\" }))),\r\n v.children));\r\n };\r\n return Dialog;\r\n}(MithrilTsxComponent));\r\nexport { Dialog };\r\nvar ConfirmDialog = (function (_super) {\r\n __extends(ConfirmDialog, _super);\r\n function ConfirmDialog() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n ConfirmDialog.prototype.view = function (v) {\r\n return m(Dialog, { header: v.attrs.header, size: v.attrs.size, className: cleanString(\"component-ConfirmDialog modal-container\", v.attrs.className), open: v.attrs.open, onopen: v.attrs.onopen, onclose: v.attrs.onclose, oncontainerclick: function (e) {\r\n exec(v.attrs.onclose, e);\r\n exec(v.attrs.oncancel, e);\r\n } },\r\n v.children,\r\n m(\"div\", { className: \"modal-footer\" },\r\n m(Button, { className: \"text-link\", onclick: function (e) {\r\n exec(v.attrs.onclose, e);\r\n exec(v.attrs.oncancel, e);\r\n } },\r\n m(\"span\", null, v.attrs.no || \"Cancel\")),\r\n m(Button, { disabled: v.attrs.disabled, className: \"btn-default\", onclick: function (e) {\r\n exec(v.attrs.onclose, e);\r\n exec(v.attrs.onconfirm, e);\r\n } },\r\n m(\"span\", null, v.attrs.yes || \"Confirm\"))));\r\n };\r\n return ConfirmDialog;\r\n}(MithrilTsxComponent));\r\nexport { ConfirmDialog };\r\n//# sourceMappingURL=index.js.map","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString, exec } from \"oj-utils\";\r\nimport \"./style.scss\";\r\nimport { FormLabel } from \"../Label\";\r\nimport { Svg } from \"../Svg\";\r\nimport { Zmdi } from \"../Zmdi\";\r\nvar FormGroup = (function (_super) {\r\n __extends(FormGroup, _super);\r\n function FormGroup() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n FormGroup.prototype.view = function (v) {\r\n return m(\"div\", { className: cleanString(\"component-FormGroup form-group\", v.attrs.className, v.attrs.error && \"is-invalid\"), onclick: function (e) { return exec(v.attrs.onclick, e); } },\r\n !v.attrs.nolabel &&\r\n m(FormLabel, { for: v.attrs.for, name: v.attrs.name, tooltip: v.attrs.tooltip, tooltipIcon: v.attrs.tooltipIcon, tooltipDirection: v.attrs.tooltipDirection }),\r\n m(\"div\", { className: cleanString(\"form-control\", v.attrs.group && \"group-\" + v.attrs.group) },\r\n v.children,\r\n m(Svg, { src: v.attrs.svg }),\r\n m(Zmdi, { icon: v.attrs.zmdi })),\r\n v.attrs.error && m(\"div\", { className: \"form-error\" },\r\n m(\"span\", { className: \"text\" }, v.attrs.error)));\r\n };\r\n return FormGroup;\r\n}(MithrilTsxComponent));\r\nexport { FormGroup };\r\n//# sourceMappingURL=index.js.map","// extracted by mini-css-extract-plugin","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString, exec } from \"oj-utils\";\r\nimport { updateIfChanged } from \"oj-mithril-utils\";\r\nimport { Position } from \"../utils/types\";\r\nimport { ImageZoom } from \"../ImageZoom\";\r\nimport { Zmdi } from \"../Zmdi\";\r\nexport var GalleryType;\r\n(function (GalleryType) {\r\n GalleryType[GalleryType[\"image\"] = 0] = \"image\";\r\n GalleryType[GalleryType[\"video\"] = 1] = \"video\";\r\n})(GalleryType || (GalleryType = {}));\r\nexport var GalleryGutter;\r\n(function (GalleryGutter) {\r\n GalleryGutter[GalleryGutter[\"small\"] = 5] = \"small\";\r\n GalleryGutter[GalleryGutter[\"medium\"] = 10] = \"medium\";\r\n GalleryGutter[GalleryGutter[\"large\"] = 15] = \"large\";\r\n})(GalleryGutter || (GalleryGutter = {}));\r\nexport var GalleryDimension;\r\n(function (GalleryDimension) {\r\n GalleryDimension[GalleryDimension[\"small\"] = 50] = \"small\";\r\n GalleryDimension[GalleryDimension[\"medium\"] = 80] = \"medium\";\r\n GalleryDimension[GalleryDimension[\"large\"] = 110] = \"large\";\r\n})(GalleryDimension || (GalleryDimension = {}));\r\nvar Gallery = (function (_super) {\r\n __extends(Gallery, _super);\r\n function Gallery() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.collapsed = false;\r\n return _this;\r\n }\r\n Gallery.prototype.oninit = function (v) {\r\n this.value = v.attrs.value || 0;\r\n };\r\n Gallery.prototype.onbeforeupdate = function (v, o) {\r\n updateIfChanged(\"value\", this, v, o);\r\n };\r\n Gallery.prototype.view = function (v) {\r\n var _this = this;\r\n var position = getPositionOrDefault(v);\r\n var _a = v.attrs, className = _a.className, onclick = _a.onclick, dimension = _a.dimension;\r\n var child = v.children[this.value].attrs;\r\n return m(\"div\", { className: cleanString(\"component-Gallery gallery\", position, className), onclick: function (e) { return exec(onclick, e); }, style: this.getGalleryStyle(v) },\r\n m(\"div\", { className: \"gallery-thumbs\" },\r\n m(\"div\", { className: cleanString(\"gallery-thumblist\", this.collapsed && \"collapsed\") }, v.children.map(function (thumb, index) {\r\n thumb.attrs.dimension = dimension;\r\n thumb.attrs.selected = index === _this.value;\r\n return m(\"div\", { onclick: function (e) { return _this.setSelected(v, index); }, className: cleanString(\"thumb\"), style: _this.getThumbStyle(v) }, thumb);\r\n }))),\r\n m(Preview, { ratio: v.attrs.previewRatio, type: child.type, src: child.src, alt: child.alt, zoomable: v.attrs.zoomable, zoomMax: v.attrs.zoomMax, zoom: v.attrs.zoom, onclick: function (e) { return exec(v.attrs.onpreviewclick, e); } }));\r\n };\r\n Gallery.prototype.setSelected = function (v, i) {\r\n this.value = i;\r\n exec(v.attrs.onchange, this.value);\r\n };\r\n Gallery.prototype.getHeight = function (v) {\r\n return v.attrs.visibleThumbs * (v.attrs.dimension + v.attrs.gutter || GalleryDimension.medium + GalleryGutter.medium);\r\n };\r\n Gallery.prototype.isHorizontal = function (v) {\r\n return v.attrs.position === Position.left || v.attrs.position === Position.right;\r\n };\r\n Gallery.prototype.getGalleryStyle = function (v) {\r\n if (this.isHorizontal(v))\r\n return {\r\n height: (this.getHeight(v) - (v.attrs.gutter * 2)) + \"px\"\r\n };\r\n };\r\n Gallery.prototype.getThumbStyle = function (v) {\r\n return {\r\n padding: this.isHorizontal(v) ? v.attrs.gutter + \"px 0px\" : \"0px \" + v.attrs.gutter + \"px\"\r\n };\r\n };\r\n return Gallery;\r\n}(MithrilTsxComponent));\r\nexport { Gallery };\r\nvar Thumb = (function (_super) {\r\n __extends(Thumb, _super);\r\n function Thumb() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n Thumb.prototype.view = function (v) {\r\n var type = getTypeOrDefault(v);\r\n var dimension = getDimensionOrDefault(v);\r\n var dimensionString = dimension + \"px\";\r\n return m(\"div\", { className: cleanString(\"component-Thumb\", type === GalleryType.video && \"video\", v.attrs.selected && \"active\", v.attrs.className), onclick: function (e) { return exec(v.attrs.onclick, e); }, style: { width: dimensionString, height: dimensionString } },\r\n m(\"img\", { width: dimension, height: dimension, loading: \"lazy\", src: v.attrs.thumb || v.attrs.src, alt: v.attrs.alt || \"\" }),\r\n type === GalleryType.video && m(Zmdi, { icon: \"play\" }));\r\n };\r\n return Thumb;\r\n}(MithrilTsxComponent));\r\nexport { Thumb };\r\nvar Preview = (function (_super) {\r\n __extends(Preview, _super);\r\n function Preview() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n Preview.prototype.view = function (v) {\r\n var type = getTypeOrDefault(v);\r\n var zoomable = getZoomableOrDefault(v);\r\n return m(\"div\", { className: cleanString(\"component-Preview\", type === GalleryType.video && \"video\", v.attrs.className, zoomable && \"zoomable\"), onclick: function (e) { return exec(v.attrs.onclick, e); } },\r\n type === GalleryType.image && (zoomable\r\n ? m(ImageZoom, { src: v.attrs.src, alt: v.attrs.alt, zoom: v.attrs.zoom, max: v.attrs.zoomMax })\r\n : m(\"img\", { width: v.attrs.ratio[0], height: v.attrs.ratio[1], loading: \"lazy\", src: v.attrs.src, alt: v.attrs.alt || \"\" })),\r\n type === GalleryType.video && m(Video, { src: v.attrs.src, mute: true, loop: true, navigation: true }));\r\n };\r\n return Preview;\r\n}(MithrilTsxComponent));\r\nvar Video = (function (_super) {\r\n __extends(Video, _super);\r\n function Video() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n Video.prototype.view = function (v) {\r\n var _this = this;\r\n return m(\"div\", { className: \"video-player\" },\r\n m(\"video\", { oncreate: function (_a) {\r\n var dom = _a.dom;\r\n _this.video = dom;\r\n setTimeout(function () { return m.redraw(); }, 100);\r\n }, width: \"720\", height: \"576\", muted: v.attrs.mute, controls: v.attrs.controls, loop: v.attrs.loop },\r\n m(\"source\", { src: v.attrs.src, type: \"video/mp4\" })),\r\n this.video && v.attrs.navigation && m(\"div\", { className: \"video-controls\" },\r\n m(\"button\", { type: \"button\", onclick: function () { return _this.togglePlay(); } }, this.video.paused ? m(Zmdi, { icon: \"play\" }) : m(Zmdi, { icon: \"pause\" })),\r\n m(\"button\", { type: \"button\", onclick: function () { return _this.toggleMute(); } }, this.video.muted ? m(Zmdi, { icon: \"volume-mute\" }) : m(Zmdi, { icon: \"volume-up\" }))));\r\n };\r\n Video.prototype.togglePlay = function () {\r\n this.video.paused ? this.video.play() : this.video.pause();\r\n };\r\n Video.prototype.toggleMute = function () {\r\n this.video.muted = !this.video.muted;\r\n };\r\n return Video;\r\n}(MithrilTsxComponent));\r\nexport { Video };\r\nvar getTypeOrDefault = function (v) { return v.attrs.type !== undefined ? v.attrs.type : GalleryType.image; };\r\nvar getDimensionOrDefault = function (v) { return v.attrs.dimension !== undefined ? v.attrs.dimension : GalleryDimension.medium; };\r\nvar getPositionOrDefault = function (v) { return v.attrs.position !== undefined ? v.attrs.position : Position.left; };\r\nvar getZoomableOrDefault = function (v) { return v.attrs.zoomable !== undefined ? v.attrs.zoomable : false; };\r\n//# sourceMappingURL=index.js.map","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString, debounce } from \"oj-utils\";\r\nimport { getEventProps, doubletap } from \"oj-dom-utils\";\r\nimport \"./style.scss\";\r\nimport Draggable from \"oj-draggable\";\r\nimport { Button } from \"../Button\";\r\nimport { Zmdi } from \"../Zmdi\";\r\nimport * as clone from \"clone\";\r\nimport \"oj-event\";\r\nvar ImageZoom = (function (_super) {\r\n __extends(ImageZoom, _super);\r\n function ImageZoom() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.offsets = { left: 0, top: 0 };\r\n _this.handleZoomToCursor = doubletap(function (e) { return _this.zoomToCursor(e); }, 400);\r\n return _this;\r\n }\r\n ImageZoom.prototype.oninit = function (v) {\r\n var _this = this;\r\n this.v = v;\r\n this.id = ImageZoom.nextId();\r\n this.zoom = v.attrs.zoom || ImageZoom.default.zoom;\r\n this.draggable = new Draggable();\r\n this.draggable.on(\"diff\", function (e) { return _this.setOffsets(v, e.diff, e.context.offsets); });\r\n };\r\n ImageZoom.prototype.view = function (v) {\r\n var _this = this;\r\n return m(\"div\", { className: cleanString(\"component-ImageZoom\", v.attrs.className, this.zooming && \"zooming\") },\r\n m(\"img\", { src: v.attrs.src, alt: v.attrs.alt, style: { transform: \"scale(\" + this.zoom + \") translate3d(\" + this.offsets.left + \"px, \" + this.offsets.top + \"px, 0)\", transformOrigin: \"center center\" }, ondragstart: function (e) { e.preventDefault(); e.redraw = false; return false; }, ontouchstart: function (e) { return _this.start(v, e); }, onmousedown: function (e) { return _this.start(v, e); }, onmouseup: this.handleZoomToCursor, ontouchend: this.handleZoomToCursor }),\r\n m(\"div\", null,\r\n m(Button, { bounce: true, onclick: function (e) { return _this.setZoomFactor(_this.zoom * 2); } },\r\n m(Zmdi, { icon: \"plus\" })),\r\n m(Button, { bounce: true, onclick: function (e) { return _this.setZoomFactor(_this.zoom * .5); } },\r\n m(Zmdi, { icon: \"minus\" }))));\r\n };\r\n ImageZoom.prototype.oncreate = function (v) {\r\n var _this = this;\r\n window.on(\"resize.ImageZoom.\" + this.id, debounce(function (e) {\r\n _this.keepImageWithilContainer();\r\n m.redraw();\r\n }));\r\n };\r\n ImageZoom.prototype.onremove = function (v) {\r\n window.off(\"resize.ImageZoom.\" + this.id);\r\n };\r\n ImageZoom.prototype.start = function (v, e) {\r\n this.draggable.start(e, { context: { offsets: clone(this.offsets) } });\r\n };\r\n ImageZoom.prototype.setZoomFactor = function (zoom) {\r\n var _this = this;\r\n var max = this.getMaxZoom();\r\n zoom = zoom > max ? max : zoom < 1 ? 1 : zoom;\r\n if (zoom === this.zoom)\r\n return;\r\n this.zoom = zoom;\r\n this.zooming = true;\r\n clearTimeout(this.zoomingTimer);\r\n this.zoomingTimer = setTimeout(function () {\r\n _this.zooming = false;\r\n m.redraw();\r\n }, 250);\r\n this.keepImageWithilContainer();\r\n };\r\n ImageZoom.prototype.getMaxZoom = function () {\r\n return Math.min(this.v.dom.children[0].naturalWidth / this.v.dom.offsetWidth, this.v.attrs.max || ImageZoom.default.max);\r\n };\r\n ImageZoom.prototype.zoomToCursor = function (e) {\r\n this.setZoomFactorToCursor(e, this.zoom > 1 ? 1 : Infinity);\r\n };\r\n ImageZoom.prototype.setZoomFactorToCursor = function (e, zoom) {\r\n var w = this.v.dom.offsetWidth;\r\n var h = this.v.dom.offsetHeight;\r\n var p = getEventProps(e);\r\n var cx = p.pageX - this.v.dom.offsetLeft;\r\n var cy = p.pageY - this.v.dom.offsetTop;\r\n this.offsets.left = -(cx - w / 2);\r\n this.offsets.top = -(cy - h / 2);\r\n this.setZoomFactor(zoom);\r\n };\r\n ImageZoom.prototype.setOffsets = function (v, diff, prev) {\r\n this.offsets.left = prev.left + (diff.left / this.zoom);\r\n this.offsets.top = prev.top + (diff.top / this.zoom);\r\n this.keepImageWithilContainer();\r\n m.redraw();\r\n };\r\n ImageZoom.prototype.keepImageWithilContainer = function () {\r\n var wc = this.v.dom.offsetWidth / 2;\r\n var hc = this.v.dom.offsetHeight / 2;\r\n var minl = wc - wc / this.zoom;\r\n var maxl = -minl;\r\n var mint = hc - hc / this.zoom;\r\n var maxt = -mint;\r\n this.offsets.left = this.offsets.left > minl ? minl : this.offsets.left < maxl ? maxl : this.offsets.left;\r\n this.offsets.top = this.offsets.top > mint ? mint : this.offsets.top < maxt ? maxt : this.offsets.top;\r\n };\r\n ImageZoom.id = 0;\r\n ImageZoom.nextId = function () { return ++ImageZoom.id; };\r\n ImageZoom.default = {\r\n max: 10,\r\n zoom: 1,\r\n };\r\n return ImageZoom;\r\n}(MithrilTsxComponent));\r\nexport { ImageZoom };\r\n//# sourceMappingURL=index.js.map","// extracted by mini-css-extract-plugin","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString } from \"oj-utils\";\r\nimport { Tooltip } from \"../BasicTooltip\";\r\nimport { Zmdi } from \"../Zmdi\";\r\nvar FormLabel = (function (_super) {\r\n __extends(FormLabel, _super);\r\n function FormLabel() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n FormLabel.prototype.view = function (v) {\r\n return m(\"label\", { for: v.attrs.for, className: cleanString(\"component-FormLabel form-label\", v.attrs.className) },\r\n v.attrs.name && m(\"span\", null, v.attrs.name),\r\n v.attrs.tooltip && m(Tooltip, { text: v.attrs.tooltip },\r\n m(Zmdi, { icon: v.attrs.tooltipIcon || \"help\" })),\r\n v.children);\r\n };\r\n return FormLabel;\r\n}(MithrilTsxComponent));\r\nexport { FormLabel };\r\n//# sourceMappingURL=index.js.map","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString, exec, UUID } from \"oj-utils\";\r\nimport { updateIfChanged } from \"oj-mithril-utils\";\r\nimport { FormGroup } from \"../FormGroup\";\r\nvar RadioList = (function (_super) {\r\n __extends(RadioList, _super);\r\n function RadioList() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n RadioList.prototype.oninit = function (v) {\r\n this.value = v.attrs.value;\r\n this.id = UUID();\r\n };\r\n RadioList.prototype.onbeforeupdate = function (v, o) {\r\n updateIfChanged(\"value\", this, v, o);\r\n };\r\n RadioList.prototype.view = function (v) {\r\n var _this = this;\r\n return m(FormGroup, { className: cleanString(\"component-RadioList\", v.attrs.className), group: v.attrs.group, name: v.attrs.name, tooltip: v.attrs.tooltip, tooltipIcon: v.attrs.tooltipIcon, tooltipDirection: v.attrs.tooltipDirection, error: v.attrs.error, zmdi: v.attrs.zmdi, svg: v.attrs.svg }, v.children.map(function (x, i) {\r\n return m(Radio, { group: _this.id, value: _this.value === i, onchange: function () { return _this.setIndex(v, i); } }, x);\r\n }));\r\n };\r\n RadioList.prototype.setIndex = function (v, i) {\r\n this.value = i;\r\n exec(v.attrs.onchange, this.value);\r\n };\r\n return RadioList;\r\n}(MithrilTsxComponent));\r\nexport { RadioList };\r\nvar Radio = (function (_super) {\r\n __extends(Radio, _super);\r\n function Radio() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n Radio.prototype.oninit = function (v) {\r\n this.value = v.attrs.value;\r\n };\r\n Radio.prototype.onbeforeupdate = function (v, o) {\r\n updateIfChanged(\"value\", this, v, o);\r\n };\r\n Radio.prototype.view = function (v) {\r\n var _this = this;\r\n return m(\"label\", { className: cleanString(\"component-Radio radio\", this.value && \"checked\", v.attrs.className) },\r\n m(\"input\", { className: cleanString(this.value && \"checked\"), name: v.attrs.group, type: \"radio\", checked: this.value, onclick: function (e) { return _this.handleChange(v, e); } }),\r\n m(\"span\", null, v.children));\r\n };\r\n Radio.prototype.handleChange = function (v, e) {\r\n if (this.value)\r\n return;\r\n this.value = !this.value;\r\n exec(v.attrs.onchange, this.value);\r\n };\r\n return Radio;\r\n}(MithrilTsxComponent));\r\nexport { Radio };\r\n//# sourceMappingURL=index.js.map","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString, exec } from \"oj-utils\";\r\nimport { childOf } from \"oj-dom-utils\";\r\nimport { updateIfChanged, cloneVNode, onbeforeremoveAll } from \"oj-mithril-utils\";\r\nimport \"./style.scss\";\r\nimport { Zmdi } from \"../Zmdi\";\r\nimport { Svg } from \"../Svg\";\r\nimport \"oj-event\";\r\nimport { FormGroup } from \"../FormGroup\";\r\nvar Select = (function (_super) {\r\n __extends(Select, _super);\r\n function Select() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n Select.getNextId = function () { return ++Select.id; };\r\n Select.prototype.oninit = function (v) {\r\n this.id = Select.getNextId();\r\n this.open = v.attrs.open;\r\n this.value = v.attrs.value || [];\r\n };\r\n Select.prototype.onbeforeupdate = function (v, o) {\r\n var changed = updateIfChanged(\"open\", this, v, o);\r\n if (changed)\r\n this.handleChange(v);\r\n updateIfChanged(\"value\", this, v, o);\r\n };\r\n Select.prototype.view = function (v) {\r\n var _this = this;\r\n var activeChildren = (v.children && v.attrs.value) ? v.children.filter(function (x, i) { return v.attrs.value.indexOf(i) !== -1; }) : [];\r\n return m(FormGroup, { className: cleanString(\"component-Select custom-select\", v.attrs.className, v.attrs.multiple && \"multiple\"), name: v.attrs.name, tooltip: v.attrs.tooltip, tooltipIcon: v.attrs.tooltipIcon, tooltipDirection: v.attrs.tooltipDirection, error: v.attrs.error, zmdi: v.attrs.zmdi, svg: v.attrs.svg },\r\n !v.attrs.noface && m(\"div\", { className: cleanString(\"face\", this.open && \"active\"), onclick: function (e) { return _this.setOpen(v, !_this.open); } },\r\n m(Zmdi, { icon: v.attrs.zmdi }),\r\n m(Svg, { src: v.attrs.svg }),\r\n activeChildren.length > 0 ? cloneVNode(activeChildren) : (v.attrs.placeholder || \"click to select\")),\r\n m(\"div\", { className: cleanString(\"options\", this.open && \"active\") }, this.open && v.children.map(function (x, i) {\r\n return x && m(\"div\", { onbeforeremove: onbeforeremoveAll, className: cleanString(\"option\", _this.value.indexOf(i) !== -1 && \"active\"), onclick: function (e) { return _this.setIndex(v, i); } }, x);\r\n })));\r\n };\r\n Select.prototype.setIndex = function (v, i) {\r\n var currentIndex = this.value.indexOf(i);\r\n if (currentIndex !== -1 && v.attrs.multiple)\r\n this.value.splice(currentIndex, 1);\r\n else {\r\n if (v.attrs.multiple)\r\n this.value.push(i);\r\n else {\r\n this.value = [i];\r\n this.open = false;\r\n }\r\n }\r\n exec(v.attrs.onchange, this.value);\r\n };\r\n Select.prototype.setOpen = function (v, open) {\r\n if (this.open === open)\r\n return;\r\n this.open = open;\r\n this.handleChange(v);\r\n };\r\n Select.prototype.handleChange = function (v) {\r\n if (this.open) {\r\n this.addOutsideClickListener(v);\r\n exec(v.attrs.onopen);\r\n }\r\n else {\r\n this.removeOutsideClickListener(v);\r\n exec(v.attrs.onclose);\r\n }\r\n };\r\n Select.prototype.addOutsideClickListener = function (v) {\r\n var _this = this;\r\n setTimeout(function () { return window.on(\"click.Select.\" + _this.id, function (e) {\r\n if (!childOf(v.dom, e.target)) {\r\n _this.open = false;\r\n _this.handleChange(v);\r\n m.redraw();\r\n }\r\n }); });\r\n };\r\n Select.prototype.removeOutsideClickListener = function (v) {\r\n window.off(\"click.Select.\" + this.id);\r\n };\r\n Select.prototype.onremove = function (v) {\r\n this.removeOutsideClickListener(v);\r\n };\r\n Select.id = 0;\r\n return Select;\r\n}(MithrilTsxComponent));\r\nexport { Select };\r\n//# sourceMappingURL=index.js.map","// extracted by mini-css-extract-plugin","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString } from \"oj-utils\";\r\nimport { get } from \"oj-ajax\";\r\nvar Svg = (function (_super) {\r\n __extends(Svg, _super);\r\n function Svg() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.svg = \"\";\r\n return _this;\r\n }\r\n Svg.prototype.view = function (v) {\r\n if (v.attrs.src === undefined)\r\n return;\r\n return m(\"i\", { className: cleanString(\"component-Svg\", v.attrs.className) }, m.trust(this.svg));\r\n };\r\n Svg.prototype.oninit = function (v) {\r\n var _this = this;\r\n if (v.attrs.src === undefined)\r\n return;\r\n get(v.attrs.src).then(function (x) {\r\n if (typeof x === \"string\") {\r\n _this.svg = x;\r\n m.redraw();\r\n }\r\n });\r\n };\r\n return Svg;\r\n}(MithrilTsxComponent));\r\nexport { Svg };\r\n//# sourceMappingURL=index.js.map","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString, exec } from \"oj-utils\";\r\nimport { flattenChildren, updateIfChanged } from \"oj-mithril-utils\";\r\nimport \"./style.scss\";\r\nvar Tab = (function (_super) {\r\n __extends(Tab, _super);\r\n function Tab() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.value = 0;\r\n return _this;\r\n }\r\n Tab.prototype.oninit = function (v) {\r\n this.value = v.attrs.value;\r\n };\r\n Tab.prototype.onbeforeupdate = function (v, o) {\r\n updateIfChanged(\"value\", this, v, o);\r\n };\r\n Tab.prototype.view = function (v) {\r\n var _this = this;\r\n var children = flattenChildren(v.children);\r\n var child = children[this.value];\r\n return m(\"div\", { className: cleanString(\"component-Tab tabs\", v.attrs.absolute && \"absolute\", v.attrs.className) },\r\n m(\"div\", { className: \"tabs-controls\" }, children.map(function (x, i) {\r\n return m(\"button\", { type: \"button\", className: cleanString(_this.value === i && \"active\"), onclick: function (e) { return _this.setIndex(v, i); } }, x.attrs.header);\r\n })),\r\n m(\"div\", { className: \"tabs-container\" }, child));\r\n };\r\n Tab.prototype.setIndex = function (v, i) {\r\n this.value = i;\r\n exec(v.attrs.onchange, this.value);\r\n };\r\n return Tab;\r\n}(MithrilTsxComponent));\r\nexport { Tab };\r\nvar TabItem = (function (_super) {\r\n __extends(TabItem, _super);\r\n function TabItem() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n TabItem.prototype.view = function (v) {\r\n return m(\"div\", { className: cleanString(\"component-TabItem tabs-pane active\", v.attrs.className) }, v.children);\r\n };\r\n return TabItem;\r\n}(MithrilTsxComponent));\r\nexport { TabItem };\r\n//# sourceMappingURL=index.js.map","// extracted by mini-css-extract-plugin","var __extends = (this && this.__extends) || (function () {\r\n var extendStatics = function (d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\nimport * as m from \"mithril\";\r\nimport { MithrilTsxComponent } from \"mithril-tsx-component\";\r\nimport { cleanString } from \"oj-utils\";\r\nimport \"material-design-iconic-font/dist/css/material-design-iconic-font.css\";\r\nvar Zmdi = (function (_super) {\r\n __extends(Zmdi, _super);\r\n function Zmdi() {\r\n return _super !== null && _super.apply(this, arguments) || this;\r\n }\r\n Zmdi.prototype.view = function (v) {\r\n if (v.attrs.icon === undefined)\r\n return;\r\n return m(\"i\", { className: cleanString(\"component-Zmdi\", \"zmdi zmdi-\" + v.attrs.icon, v.attrs.className) });\r\n };\r\n return Zmdi;\r\n}(MithrilTsxComponent));\r\nexport { Zmdi };\r\n//# sourceMappingURL=index.js.map","export var Align;\r\n(function (Align) {\r\n Align[\"horizontal\"] = \"horizontal\";\r\n Align[\"vertical\"] = \"vertical\";\r\n})(Align || (Align = {}));\r\nexport var ValueType;\r\n(function (ValueType) {\r\n ValueType[\"number\"] = \"number\";\r\n ValueType[\"text\"] = \"text\";\r\n})(ValueType || (ValueType = {}));\r\nexport var Position;\r\n(function (Position) {\r\n Position[\"left\"] = \"left\";\r\n Position[\"top\"] = \"top\";\r\n Position[\"right\"] = \"right\";\r\n Position[\"bottom\"] = \"bottom\";\r\n})(Position || (Position = {}));\r\n//# sourceMappingURL=types.js.map","var __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n};\r\nvar __generator = (this && this.__generator) || function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n};\r\nvar __read = (this && this.__read) || function (o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n};\r\nvar __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n};\r\nvar __values = (this && this.__values) || function(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n};\r\nimport \"oj-event\";\r\nimport m from \"mithril\";\r\nimport { cleanString } from \"oj-utils\";\r\nimport { getTransitionDuration } from \"oj-dom-utils\";\r\nimport { delegate, pause } from \"oj-promise-utils\";\r\nexport var getAttrValue = function (val) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n return typeof val === \"function\" ? val.apply(void 0, __spreadArray([], __read(args), false)) : val;\r\n};\r\nexport var keyOrIndex = function (x, i) { var _a, _b; return (_b = (_a = x === null || x === void 0 ? void 0 : x.attrs) === null || _a === void 0 ? void 0 : _a.key) !== null && _b !== void 0 ? _b : i; };\r\nexport var immediate = function (component, options) {\r\n if (options === void 0) { options = {}; }\r\n var d = delegate();\r\n var distroy = function () {\r\n var _a;\r\n setTimeout(function () {\r\n m.mount(root, null);\r\n try {\r\n document.body.removeChild(root);\r\n }\r\n catch (_a) {\r\n }\r\n }, (_a = options.distroyTimeout) !== null && _a !== void 0 ? _a : 1000);\r\n };\r\n var resolve = function (arg) {\r\n d.resolve(arg);\r\n distroy();\r\n };\r\n var reject = function (arg) {\r\n d.reject(arg);\r\n distroy();\r\n };\r\n var root;\r\n if (options.root)\r\n root = options.root;\r\n else {\r\n root = document.createElement(\"div\");\r\n document.body.appendChild(root);\r\n }\r\n m.mount(root, component);\r\n return {\r\n promise: d.promise,\r\n resolve: resolve,\r\n reject: reject,\r\n };\r\n};\r\nexport var flattenChildren = function (children) {\r\n var e_1, _a;\r\n var arr = [];\r\n try {\r\n for (var children_1 = __values(children), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) {\r\n var c = children_1_1.value;\r\n if (c == undefined)\r\n continue;\r\n else if (c.tag === \"[\")\r\n arr = arr.concat(c.children);\r\n else\r\n arr.push(c);\r\n }\r\n }\r\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\r\n finally {\r\n try {\r\n if (children_1_1 && !children_1_1.done && (_a = children_1.return)) _a.call(children_1);\r\n }\r\n finally { if (e_1) throw e_1.error; }\r\n }\r\n return arr;\r\n};\r\nexport var updateIfChanged = function (prop, self, v, o, m) {\r\n var a = typeof self[prop] === \"object\" && self[prop] !== null\r\n ? self[prop].toString()\r\n : self[prop];\r\n var b = typeof v.attrs[prop] === \"object\" && v.attrs[prop] !== null\r\n ? v.attrs[prop].toString()\r\n : v.attrs[prop];\r\n var c = typeof o.attrs[prop] === \"object\" && o.attrs[prop] !== null\r\n ? o.attrs[prop].toString()\r\n : o.attrs[prop];\r\n if (b !== undefined && a !== b && b !== c) {\r\n self[prop] = typeof m === \"function\"\r\n ? m(v.attrs[prop])\r\n : v.attrs[prop];\r\n return true;\r\n }\r\n return false;\r\n};\r\nexport var portal = function (element, target) {\r\n if (target === void 0) { target = document.body; }\r\n var parent = element.parentElement;\r\n var placeholder = document.createElement(\"div\");\r\n parent.replaceChild(placeholder, element);\r\n target.appendChild(element);\r\n return {\r\n reset: function () { return parent.replaceChild(element, placeholder); }\r\n };\r\n};\r\nexport var animateCreate = function (v, delay) {\r\n if (delay === void 0) { delay = 20; }\r\n return __awaiter(void 0, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4, pause(delay).promise];\r\n case 1:\r\n _a.sent();\r\n v.dom.classList.remove(\"animate-in\");\r\n v.state[\"__animate\"] = true;\r\n return [2];\r\n }\r\n });\r\n });\r\n};\r\nexport var animateRemove = function (v, delay) {\r\n if (delay === void 0) { delay = 0; }\r\n return __awaiter(void 0, void 0, void 0, function () {\r\n var transitionDelay;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4, pause(delay).promise];\r\n case 1:\r\n _a.sent();\r\n v.dom.classList.add(\"animate-out\");\r\n v.state[\"__animate\"] = false;\r\n transitionDelay = getTransitionDuration(v.dom);\r\n return [4, pause(transitionDelay).promise];\r\n case 2:\r\n _a.sent();\r\n return [2];\r\n }\r\n });\r\n });\r\n};\r\nexport var animateClassNames = function (v, animation) {\r\n return cleanString(animation, v.state[\"__animate\"] === undefined && \"animate-in\");\r\n};\r\nexport var parseQueryParams = function (prefix) {\r\n if (prefix === void 0) { prefix = \"?\"; }\r\n return m.parseQueryString(prefix === \"?\" ? location.search : location.hash.substring(1));\r\n};\r\nexport var replaceQueryParams = function (params, merge, prefix, replace) {\r\n if (merge === void 0) { merge = true; }\r\n if (prefix === void 0) { prefix = \"?\"; }\r\n if (replace === void 0) { replace = false; }\r\n var url = mergeQueryParams(params, merge, prefix);\r\n if (replace)\r\n history.replaceState(null, null, url);\r\n else\r\n history.pushState(null, null, url);\r\n};\r\nexport var mergeQueryParams = function (params, merge, prefix) {\r\n if (merge === void 0) { merge = true; }\r\n if (prefix === void 0) { prefix = \"?\"; }\r\n var obj = Object.entries(__assign(__assign({}, merge ? parseQueryParams(prefix) : {}), params))\r\n .reduce(function (s, _a) {\r\n var _b;\r\n var _c = __read(_a, 2), k = _c[0], v = _c[1];\r\n return v == undefined ? s : Object.assign(s, (_b = {}, _b[k] = v, _b));\r\n }, {});\r\n var str = m.buildQueryString(obj);\r\n var url = \"\";\r\n if (prefix === \"?\")\r\n url = \"\".concat(str ? \"?\".concat(str) : \"\").concat(location.hash);\r\n else\r\n url = \"\".concat(location.search).concat(str ? \"#\".concat(str) : \"\");\r\n return \"\".concat(location.origin).concat(location.pathname).concat(url);\r\n};\r\nexport var cloneVNode = function (vnode) {\r\n if (Array.isArray(vnode))\r\n return vnode.map(function (x) { return cloneVNode(x); });\r\n if (typeof vnode === \"object\" && vnode !== null) {\r\n var cvnode = Object.assign({}, vnode);\r\n if (cvnode.children)\r\n cvnode.children = cloneVNode(cvnode.children);\r\n return cvnode;\r\n }\r\n return vnode;\r\n};\r\n//# sourceMappingURL=index.js.map","\"use strict\";\r\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n};\r\nvar __generator = (this && this.__generator) || function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n};\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.rejectPending = exports.poll = exports.clamp = exports.mapRange = exports.throttle = exports.debounce = exports.singleton = exports.pauseIncrement = exports.pause = exports.delegate = void 0;\r\nvar delegate = function () {\r\n var resolve;\r\n var reject;\r\n var promise = new Promise(function (res, rej) {\r\n resolve = res;\r\n reject = rej;\r\n });\r\n return { promise: promise, resolve: resolve, reject: reject };\r\n};\r\nexports.delegate = delegate;\r\nvar pause = function (ms, autoStart) {\r\n if (autoStart === void 0) { autoStart = true; }\r\n var d = (0, exports.delegate)();\r\n var promise = d.promise;\r\n var timer;\r\n var reject = function () {\r\n clearTimeout(timer);\r\n d.reject(\"pause canceled\");\r\n };\r\n var start = function () {\r\n if (timer)\r\n throw new Error(\"timer already executed, autoStart param is true\");\r\n timer = setTimeout(d.resolve, ms);\r\n return { promise: promise, reject: reject };\r\n };\r\n if (autoStart)\r\n start();\r\n return { start: start, promise: promise, reject: reject };\r\n};\r\nexports.pause = pause;\r\nvar pauseIncrement = function (range, ms, limit) {\r\n if (limit === void 0) { limit = true; }\r\n var i = 0;\r\n return function (autoStart) {\r\n if (autoStart === void 0) { autoStart = true; }\r\n var s = (0, exports.mapRange)(i++, range, ms);\r\n if (limit)\r\n s = (0, exports.clamp)(s, ms[0], ms[1]);\r\n return (0, exports.pause)(s, autoStart);\r\n };\r\n};\r\nexports.pauseIncrement = pauseIncrement;\r\nvar singleton = function (fn, hashFn) {\r\n var cache = {};\r\n return function () {\r\n var _a;\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n var hash = (_a = hashFn === null || hashFn === void 0 ? void 0 : hashFn.apply(void 0, args)) !== null && _a !== void 0 ? _a : JSON.stringify(args);\r\n if (!cache[hash]) {\r\n cache[hash] = fn.apply(void 0, args);\r\n cache[hash].finally(function () { return delete cache[hash]; });\r\n }\r\n return cache[hash];\r\n };\r\n};\r\nexports.singleton = singleton;\r\nvar debounce = function (threshold, fn) {\r\n var t;\r\n var d;\r\n return function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n if (!d)\r\n d = (0, exports.delegate)();\r\n clearTimeout(t);\r\n t = setTimeout(function () {\r\n var p = fn.apply(void 0, args);\r\n p.then(function (x) { return d === null || d === void 0 ? void 0 : d.resolve(x); });\r\n p.catch(function (x) { return d === null || d === void 0 ? void 0 : d.reject(x); });\r\n p.finally(function () { return d = undefined; });\r\n }, threshold);\r\n return d.promise;\r\n };\r\n};\r\nexports.debounce = debounce;\r\nvar throttle = function (threshold, fn, hashFn) {\r\n var n;\r\n var p;\r\n var h;\r\n return function () {\r\n var _a;\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n var now = Date.now();\r\n var hn = (_a = hashFn === null || hashFn === void 0 ? void 0 : hashFn.apply(void 0, args)) !== null && _a !== void 0 ? _a : JSON.stringify(args);\r\n if (!n || now - n >= threshold || h !== hn) {\r\n n = now;\r\n h = hn;\r\n p = fn.apply(void 0, args);\r\n }\r\n return p;\r\n };\r\n};\r\nexports.throttle = throttle;\r\nvar mapRange = function (value, source, target) {\r\n return target[0] + (value - source[0]) * (target[1] - target[0]) / (source[1] - source[0]);\r\n};\r\nexports.mapRange = mapRange;\r\nvar clamp = function (value, min, max) {\r\n return Math.min(Math.max(value, min), max);\r\n};\r\nexports.clamp = clamp;\r\nvar poll = function (fn, test, threshold, max) { return __awaiter(void 0, void 0, void 0, function () {\r\n var now, i, pi, x, err_1;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n now = Date.now();\r\n i = 0;\r\n pi = (0, exports.pauseIncrement)([0, max], threshold);\r\n _a.label = 1;\r\n case 1:\r\n if (!(i++ < max)) return [3 /*break*/, 7];\r\n _a.label = 2;\r\n case 2:\r\n _a.trys.push([2, 4, , 5]);\r\n return [4 /*yield*/, fn()];\r\n case 3:\r\n x = _a.sent();\r\n if (test(x))\r\n return [2 /*return*/, x];\r\n return [3 /*break*/, 5];\r\n case 4:\r\n err_1 = _a.sent();\r\n console.error(err_1);\r\n return [3 /*break*/, 5];\r\n case 5: return [4 /*yield*/, pi().promise];\r\n case 6:\r\n _a.sent();\r\n return [3 /*break*/, 1];\r\n case 7: throw new Error(\"poll reached timeout (\".concat(Date.now() - now, \" ms)\"));\r\n }\r\n });\r\n}); };\r\nexports.poll = poll;\r\nvar rejectPending = function (rejector, hashFn) {\r\n var current;\r\n var currHash;\r\n return function () {\r\n var _a;\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n var hash = (_a = hashFn === null || hashFn === void 0 ? void 0 : hashFn.apply(void 0, args)) !== null && _a !== void 0 ? _a : JSON.stringify(args);\r\n if (currHash !== hash)\r\n current === null || current === void 0 ? void 0 : current.reject(\"Cancelled\");\r\n currHash = hash;\r\n var d = current = (0, exports.delegate)();\r\n d.promise.then(function () { return current = undefined; });\r\n var fn = rejector(function () { return d !== current; });\r\n fn.apply(void 0, args).then(d.resolve)\r\n .catch(d.reject);\r\n return d.promise;\r\n };\r\n};\r\nexports.rejectPending = rejectPending;\r\n","\"use strict\";\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n};\r\nvar __generator = (this && this.__generator) || function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n};\r\nvar _this = this;\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nexports.getDynamicObj = exports.getDynamicVal = exports.imageUrlToB64 = exports.fileToB64 = exports.base64toBlob = exports.getImageTypeFromB64 = exports.createImage = exports.isIE = exports.formatPrice = exports.formatSize = exports.clone = exports.removeIfExists = exports.createToggle = exports.chunk = exports.memoize = exports.throttle = exports.debounce = exports.exec = exports.diff = exports.increment = exports.repeatMap = exports.arrToObj = exports.objToArr = exports.groupArr = exports.groupObj = exports.mapObj = exports.reduceObj = exports.filterObj = exports.findObjKey = exports.generateHashFromString = exports.uniqueArray = exports.pipe = exports.getDpi = exports.pxToMm = exports.mmToPx = exports.UUID = exports.pause = exports.cleanString = exports.clamp = exports.mapRange = exports.randomList = exports.randomDec = exports.randomInt = void 0;\r\nvar randomInt = function (min, max) {\r\n if (min === void 0) { min = 0; }\r\n if (max === void 0) { max = 9999; }\r\n return Math.floor(Math.random() * (max - min)) + min;\r\n};\r\nexports.randomInt = randomInt;\r\nvar randomDec = function (min, max) {\r\n if (min === void 0) { min = 0; }\r\n if (max === void 0) { max = 9999; }\r\n return (Math.random() * (max - min) + min);\r\n};\r\nexports.randomDec = randomDec;\r\nvar randomList = function (list) {\r\n return list[(0, exports.randomInt)(0, list.length)];\r\n};\r\nexports.randomList = randomList;\r\nvar mapRange = function (value, source, target) {\r\n return target[0] + (value - source[0]) * (target[1] - target[0]) / (source[1] - source[0]);\r\n};\r\nexports.mapRange = mapRange;\r\nvar clamp = function (value, min, max) {\r\n return Math.min(Math.max(value, min), max);\r\n};\r\nexports.clamp = clamp;\r\nvar cleanString = function () {\r\n var x = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n x[_i] = arguments[_i];\r\n }\r\n return x\r\n .filter(function (x) { return typeof x === \"string\"; })\r\n .map(function (x) { return x.trim(); })\r\n .join(\" \");\r\n};\r\nexports.cleanString = cleanString;\r\nvar pause = function (ms) { return __awaiter(void 0, void 0, void 0, function () {\r\n return __generator(this, function (_a) {\r\n return [2 /*return*/, new Promise(function (resolve, reject) {\r\n var timeout = setTimeout(resolve, ms);\r\n return function () {\r\n clearTimeout(timeout);\r\n reject(\"pause canceled\");\r\n };\r\n })];\r\n });\r\n}); };\r\nexports.pause = pause;\r\nvar UUID = function () {\r\n var d = Date.now();\r\n if (window.performance && typeof window.performance.now === \"function\")\r\n d += performance.now();\r\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, function (c) {\r\n var r = (d + Math.random() * 16) % 16 | 0;\r\n d = Math.floor(d / 16);\r\n return (c === \"x\" ? r : (r & 0x3 | 0x8)).toString(16);\r\n });\r\n};\r\nexports.UUID = UUID;\r\nvar mmToPx = function (mm, dpi) {\r\n if (dpi === void 0) { dpi = 200; }\r\n return (mm * dpi) / 25.4;\r\n};\r\nexports.mmToPx = mmToPx;\r\nvar pxToMm = function (px, dpi) {\r\n if (dpi === void 0) { dpi = 200; }\r\n return (px / dpi) * 25.4;\r\n};\r\nexports.pxToMm = pxToMm;\r\nvar getDpi = function (px, mm) {\r\n return px / mm * 25.4;\r\n};\r\nexports.getDpi = getDpi;\r\nvar pipe = function (value) {\r\n return ({\r\n map: function (fn) { return (0, exports.pipe)(fn(value)); },\r\n value: value\r\n });\r\n};\r\nexports.pipe = pipe;\r\nvar uniqueArray = function (arr) {\r\n return Array.from(new Set(arr));\r\n};\r\nexports.uniqueArray = uniqueArray;\r\nvar generateHashFromString = function (str) {\r\n return str.split(\"\").reduce(function (s, x) { return (((s << 5) - s) + x.charCodeAt(0)) | 0; }, 0);\r\n};\r\nexports.generateHashFromString = generateHashFromString;\r\nvar findObjKey = function (obj, cb) {\r\n for (var k in obj)\r\n if (cb(obj[k], k, obj))\r\n return k;\r\n};\r\nexports.findObjKey = findObjKey;\r\nvar filterObj = function (obj, cb) {\r\n var result = {};\r\n for (var k in obj)\r\n if (cb(obj[k], k, obj))\r\n result[k] = obj[k];\r\n return result;\r\n};\r\nexports.filterObj = filterObj;\r\nvar reduceObj = function (obj, cb, result) {\r\n for (var k in obj)\r\n result = cb(result, obj[k], k, obj);\r\n return result;\r\n};\r\nexports.reduceObj = reduceObj;\r\nvar mapObj = function (obj, cb) {\r\n var result = {};\r\n for (var k in obj)\r\n result[k] = cb(obj[k], k, obj);\r\n return result;\r\n};\r\nexports.mapObj = mapObj;\r\nvar groupObj = function (obj, key, ref) {\r\n var _a;\r\n var _b;\r\n if (ref === void 0) { ref = \"$key\"; }\r\n var result = {};\r\n for (var k in obj) {\r\n var gr = obj[k][key];\r\n (_b = result[gr]) !== null && _b !== void 0 ? _b : (result[gr] = []);\r\n result[gr].push(__assign((_a = {}, _a[ref] = k, _a), obj[k]));\r\n }\r\n return result;\r\n};\r\nexports.groupObj = groupObj;\r\nvar groupArr = function (arr, key, ref) {\r\n var _a;\r\n var _b;\r\n if (ref === void 0) { ref = \"$key\"; }\r\n var result = {};\r\n for (var i = 0; i < arr.length; i++) {\r\n var gr = arr[i][key];\r\n (_b = result[gr]) !== null && _b !== void 0 ? _b : (result[gr] = []);\r\n result[gr].push(__assign((_a = {}, _a[ref] = i, _a), arr[i]));\r\n }\r\n return result;\r\n};\r\nexports.groupArr = groupArr;\r\nvar objToArr = function (obj, ref) {\r\n if (ref === void 0) { ref = \"$key\"; }\r\n return (0, exports.reduceObj)(obj, function (r, x, k) {\r\n var _a;\r\n return r.concat(__assign(__assign({}, x), (_a = {}, _a[ref] = k, _a)));\r\n }, []);\r\n};\r\nexports.objToArr = objToArr;\r\nvar arrToObj = function (arr, key) {\r\n if (key === void 0) { key = \"$key\"; }\r\n return arr.reduce(function (r, x) {\r\n var copy = __assign({}, x);\r\n delete copy[key];\r\n r[x[key]] = copy;\r\n return r;\r\n }, {});\r\n};\r\nexports.arrToObj = arrToObj;\r\nvar repeatMap = function (times, fn) {\r\n var _a;\r\n var result = [];\r\n for (var i = 0; i < times; i++)\r\n result[i] = (_a = fn === null || fn === void 0 ? void 0 : fn(i)) !== null && _a !== void 0 ? _a : i;\r\n return result;\r\n};\r\nexports.repeatMap = repeatMap;\r\nvar increment = function () {\r\n var i = 0;\r\n return function () {\r\n return i++;\r\n };\r\n};\r\nexports.increment = increment;\r\nvar diff = function (cb, reset) {\r\n if (reset === void 0) { reset = false; }\r\n var last = cb();\r\n return function () {\r\n var curr = cb();\r\n var d = curr - last;\r\n if (reset)\r\n last = curr;\r\n return d;\r\n };\r\n};\r\nexports.diff = diff;\r\nvar exec = function (fn) {\r\n var args = [];\r\n for (var _i = 1; _i < arguments.length; _i++) {\r\n args[_i - 1] = arguments[_i];\r\n }\r\n return typeof fn === \"function\"\r\n ? fn.apply(_this, args)\r\n : undefined;\r\n};\r\nexports.exec = exec;\r\nvar debounce = function (threshold, fn, head) {\r\n if (head === void 0) { head = false; }\r\n var t;\r\n var c;\r\n return (function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n if (t === undefined && head)\r\n c = fn.apply(void 0, args);\r\n clearTimeout(t);\r\n t = setTimeout(function () {\r\n c = fn.apply(void 0, args);\r\n }, threshold);\r\n return c;\r\n });\r\n};\r\nexports.debounce = debounce;\r\nvar throttle = function (threshold, fn, tail) {\r\n if (tail === void 0) { tail = false; }\r\n var t;\r\n var p;\r\n var c;\r\n return (function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n clearTimeout(t);\r\n var now = Date.now();\r\n if (!p || now - p >= threshold) {\r\n p = now;\r\n c = fn.apply(void 0, args);\r\n }\r\n else if (tail) {\r\n t = setTimeout(function () {\r\n c = fn.apply(void 0, args);\r\n }, threshold);\r\n }\r\n return c;\r\n });\r\n};\r\nexports.throttle = throttle;\r\nvar memoize = function (fn, hashFn) {\r\n var cache = {};\r\n return (function () {\r\n var _a, _b;\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n var hash = (_a = hashFn === null || hashFn === void 0 ? void 0 : hashFn.apply(void 0, args)) !== null && _a !== void 0 ? _a : JSON.stringify(args);\r\n if (cache[hash] === undefined)\r\n cache[hash] = (_b = fn.apply(void 0, args)) !== null && _b !== void 0 ? _b : null;\r\n return cache[hash];\r\n });\r\n};\r\nexports.memoize = memoize;\r\nvar chunk = function (n, arr) {\r\n var chunks = [];\r\n for (var i = 0; i < arr.length; i++) {\r\n var chunk_1 = Math.floor(i / n);\r\n if (!chunks[chunk_1])\r\n chunks[chunk_1] = [];\r\n chunks[chunk_1].push(arr[i]);\r\n }\r\n return chunks;\r\n};\r\nexports.chunk = chunk;\r\nvar createToggle = function () {\r\n var value = false;\r\n return {\r\n get: function () { return value; },\r\n on: function () { return value = true; },\r\n off: function () { return value = false; },\r\n toggle: function () { return value = !value; },\r\n };\r\n};\r\nexports.createToggle = createToggle;\r\nvar removeIfExists = function (arr, cb) {\r\n var i = arr.findIndex(cb);\r\n if (i !== -1)\r\n arr.splice(i, 1);\r\n return arr;\r\n};\r\nexports.removeIfExists = removeIfExists;\r\nvar clone = function (obj) {\r\n return JSON.parse(JSON.stringify(obj));\r\n};\r\nexports.clone = clone;\r\nvar formatSize = function (bytes) {\r\n var sizes = [\"Bytes\", \"KB\", \"MB\", \"GB\", \"TB\"];\r\n if (bytes == 0)\r\n return \"0 Byte\";\r\n var i = Math.floor(Math.floor(Math.log(bytes) / Math.log(1024)));\r\n var size = (bytes / Math.pow(1024, i));\r\n size = Math.round(size * 100) / 100;\r\n return size + sizes[i];\r\n};\r\nexports.formatSize = formatSize;\r\nvar formatPrice = function (price, decimal, format) {\r\n if (decimal === void 0) { decimal = true; }\r\n if (format === void 0) { format = {}; }\r\n var _a = \"\".concat(Math.round(price * 100) / 100).split(\".\"), n = _a[0], m = _a[1];\r\n var _b = Object.assign({ pre: \"€ \", dot: \",\", post: \"\" }, format), pre = _b.pre, dot = _b.dot, post = _b.post;\r\n var cents = \"\".concat(m !== null && m !== void 0 ? m : 0).padEnd(2, \"0\");\r\n return decimal ? \"\".concat(pre).concat(n).concat(dot).concat(cents).concat(post) : \"\".concat(pre).concat(Math.round(price)).concat(post);\r\n};\r\nexports.formatPrice = formatPrice;\r\nexports.isIE = (0, exports.memoize)(function () {\r\n return (/MSIE (\\d+\\.\\d+);/.test(navigator.userAgent) || navigator.userAgent.indexOf(\"Trident/\") > -1);\r\n}, function () { return navigator.userAgent; });\r\nvar createImage = function (src) {\r\n return new Promise(function (res, rej) {\r\n var img = new Image();\r\n img.crossOrigin = \"Anonymous\";\r\n img.onload = function () { return res(img); };\r\n img.onerror = function (err) { return rej(err); };\r\n img.src = src;\r\n });\r\n};\r\nexports.createImage = createImage;\r\nvar getImageTypeFromB64 = function (source) {\r\n var match = source.match(/(image\\/.*)?;/);\r\n return (match && match[1]) ? match[1] : \"image/png\";\r\n};\r\nexports.getImageTypeFromB64 = getImageTypeFromB64;\r\nvar base64toBlob = function (src) {\r\n var base64Data = src.replace(/^data:image\\/(.*?);base64,/, \"\");\r\n var contentType = (0, exports.getImageTypeFromB64)(src);\r\n var sliceSize = 1024;\r\n var byteCharacters = atob(base64Data);\r\n var bytesLength = byteCharacters.length;\r\n var slicesCount = Math.ceil(bytesLength / sliceSize);\r\n var byteArrays = new Array(slicesCount);\r\n for (var i = 0; i < slicesCount; ++i) {\r\n var begin = i * sliceSize;\r\n var end = Math.min(begin + sliceSize, bytesLength);\r\n var bytes = new Array(end - begin);\r\n for (var offset = begin, i_1 = 0; offset < end; ++i_1, ++offset)\r\n bytes[i_1] = byteCharacters[offset].charCodeAt(0);\r\n byteArrays[i] = new Uint8Array(bytes);\r\n }\r\n return new Blob(byteArrays, { type: contentType });\r\n};\r\nexports.base64toBlob = base64toBlob;\r\nvar fileToB64 = function (file) {\r\n return new Promise(function (res, rej) {\r\n var reader = new FileReader();\r\n reader.onload = function () { return res(reader.result); };\r\n reader.onerror = function (err) { return rej(err); };\r\n reader.readAsDataURL(file);\r\n });\r\n};\r\nexports.fileToB64 = fileToB64;\r\nvar imageUrlToB64 = function (url) {\r\n return fetch(url)\r\n .then(function (x) { return x.blob(); })\r\n .then(function (x) { return (0, exports.fileToB64)(x); });\r\n};\r\nexports.imageUrlToB64 = imageUrlToB64;\r\nvar getDynamicVal = function (x) {\r\n return typeof x === \"function\" ? x() : x;\r\n};\r\nexports.getDynamicVal = getDynamicVal;\r\nvar getDynamicObj = function (x) {\r\n return Object.fromEntries(Object.entries(x).map(function (_a) {\r\n var k = _a[0], v = _a[1];\r\n return [k, (0, exports.getDynamicVal)(v)];\r\n }));\r\n};\r\nexports.getDynamicObj = getDynamicObj;\r\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\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}\n\nprocess.nextTick = function (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\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};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","(function (global, undefined) {\n \"use strict\";\n\n if (global.setImmediate) {\n return;\n }\n\n var nextHandle = 1; // Spec says greater than zero\n var tasksByHandle = {};\n var currentlyRunningATask = false;\n var doc = global.document;\n var registerImmediate;\n\n function setImmediate(callback) {\n // Callback can either be a function or a string\n if (typeof callback !== \"function\") {\n callback = new Function(\"\" + callback);\n }\n // Copy function arguments\n var args = new Array(arguments.length - 1);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i + 1];\n }\n // Store and register the task\n var task = { callback: callback, args: args };\n tasksByHandle[nextHandle] = task;\n registerImmediate(nextHandle);\n return nextHandle++;\n }\n\n function clearImmediate(handle) {\n delete tasksByHandle[handle];\n }\n\n function run(task) {\n var callback = task.callback;\n var args = task.args;\n switch (args.length) {\n case 0:\n callback();\n break;\n case 1:\n callback(args[0]);\n break;\n case 2:\n callback(args[0], args[1]);\n break;\n case 3:\n callback(args[0], args[1], args[2]);\n break;\n default:\n callback.apply(undefined, args);\n break;\n }\n }\n\n function runIfPresent(handle) {\n // From the spec: \"Wait until any invocations of this algorithm started before this one have completed.\"\n // So if we're currently running a task, we'll need to delay this invocation.\n if (currentlyRunningATask) {\n // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a\n // \"too much recursion\" error.\n setTimeout(runIfPresent, 0, handle);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunningATask = true;\n try {\n run(task);\n } finally {\n clearImmediate(handle);\n currentlyRunningATask = false;\n }\n }\n }\n }\n\n function installNextTickImplementation() {\n registerImmediate = function(handle) {\n process.nextTick(function () { runIfPresent(handle); });\n };\n }\n\n function canUsePostMessage() {\n // The test against `importScripts` prevents this implementation from being installed inside a web worker,\n // where `global.postMessage` means something completely different and can't be used for this purpose.\n if (global.postMessage && !global.importScripts) {\n var postMessageIsAsynchronous = true;\n var oldOnMessage = global.onmessage;\n global.onmessage = function() {\n postMessageIsAsynchronous = false;\n };\n global.postMessage(\"\", \"*\");\n global.onmessage = oldOnMessage;\n return postMessageIsAsynchronous;\n }\n }\n\n function installPostMessageImplementation() {\n // Installs an event handler on `global` for the `message` event: see\n // * https://developer.mozilla.org/en/DOM/window.postMessage\n // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages\n\n var messagePrefix = \"setImmediate$\" + Math.random() + \"$\";\n var onGlobalMessage = function(event) {\n if (event.source === global &&\n typeof event.data === \"string\" &&\n event.data.indexOf(messagePrefix) === 0) {\n runIfPresent(+event.data.slice(messagePrefix.length));\n }\n };\n\n if (global.addEventListener) {\n global.addEventListener(\"message\", onGlobalMessage, false);\n } else {\n global.attachEvent(\"onmessage\", onGlobalMessage);\n }\n\n registerImmediate = function(handle) {\n global.postMessage(messagePrefix + handle, \"*\");\n };\n }\n\n function installMessageChannelImplementation() {\n var channel = new MessageChannel();\n channel.port1.onmessage = function(event) {\n var handle = event.data;\n runIfPresent(handle);\n };\n\n registerImmediate = function(handle) {\n channel.port2.postMessage(handle);\n };\n }\n\n function installReadyStateChangeImplementation() {\n var html = doc.documentElement;\n registerImmediate = function(handle) {\n // Create a