diff --git a/index.js b/index.js index feead34..ae44c7f 100644 --- a/index.js +++ b/index.js @@ -10434,6 +10434,8 @@ function colorNamesDataList() { * @property {string} [datalist] * @property {number} [min] * @property {number} [max] + * @property {boolean} [notRequired] + * @property {string[]} [addedFields] */ /** @@ -10714,14 +10716,14 @@ class Select extends Prop { return this.labeled( html`
\n
\n Gender: \n
\n \n \n \n
form = {{user | json}}
\n
master = {{master | json}}
\n \n \n \n // Module: copyExample\n angular.\n module('copyExample', []).\n controller('ExampleController', ['$scope', function($scope) {\n $scope.master = {};\n\n $scope.reset = function() {\n // Example with 1 argument\n $scope.user = angular.copy($scope.master);\n };\n\n $scope.update = function(user) {\n // Example with 2 arguments\n angular.copy(user, $scope.master);\n };\n\n $scope.reset();\n }]);\n \n \n */\nfunction copy(source, destination) {\n\tvar stackSource = [];\n\tvar stackDest = [];\n\n\tif (destination) {\n\t\tif (isTypedArray(destination) || isArrayBuffer(destination)) {\n\t\t\tthrow ngMinErr(\n\t\t\t\t\"cpta\",\n\t\t\t\t\"Can't copy! TypedArray destination cannot be mutated.\"\n\t\t\t);\n\t\t}\n\t\tif (source === destination) {\n\t\t\tthrow ngMinErr(\n\t\t\t\t\"cpi\",\n\t\t\t\t\"Can't copy! Source and destination are identical.\"\n\t\t\t);\n\t\t}\n\n\t\t// Empty the destination object\n\t\tif (isArray(destination)) {\n\t\t\tdestination.length = 0;\n\t\t} else {\n\t\t\tforEach(destination, function (value, key) {\n\t\t\t\tif (key !== \"$$hashKey\") {\n\t\t\t\t\tdelete destination[key];\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\tstackSource.push(source);\n\t\tstackDest.push(destination);\n\t\treturn copyRecurse(source, destination);\n\t}\n\n\treturn copyElement(source);\n\n\tfunction copyRecurse(source, destination) {\n\t\tvar h = destination.$$hashKey;\n\t\tvar key;\n\t\tif (isArray(source)) {\n\t\t\tfor (var i = 0, ii = source.length; i < ii; i++) {\n\t\t\t\tdestination.push(copyElement(source[i]));\n\t\t\t}\n\t\t} else if (isBlankObject(source)) {\n\t\t\t// createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty\n\t\t\t// eslint-disable-next-line guard-for-in\n\t\t\tfor (key in source) {\n\t\t\t\tdestination[key] = copyElement(source[key]);\n\t\t\t}\n\t\t} else if (source && typeof source.hasOwnProperty === \"function\") {\n\t\t\t// Slow path, which must rely on hasOwnProperty\n\t\t\tfor (key in source) {\n\t\t\t\tif (source.hasOwnProperty(key)) {\n\t\t\t\t\tdestination[key] = copyElement(source[key]);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Slowest path --- hasOwnProperty can't be called as a method\n\t\t\tfor (key in source) {\n\t\t\t\tif (hasOwnProperty.call(source, key)) {\n\t\t\t\t\tdestination[key] = copyElement(source[key]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tsetHashKey(destination, h);\n\t\treturn destination;\n\t}\n\n\tfunction copyElement(source) {\n\t\t// Simple values\n\t\tif (!isObject(source)) {\n\t\t\treturn source;\n\t\t}\n\n\t\t// Already copied values\n\t\tvar index = stackSource.indexOf(source);\n\t\tif (index !== -1) {\n\t\t\treturn stackDest[index];\n\t\t}\n\n\t\tif (isWindow(source) || isScope(source)) {\n\t\t\tthrow ngMinErr(\n\t\t\t\t\"cpws\",\n\t\t\t\t\"Can't copy! Making copies of Window or Scope instances is not supported.\"\n\t\t\t);\n\t\t}\n\n\t\tvar needsRecurse = false;\n\t\tvar destination = copyType(source);\n\n\t\tif (destination === undefined) {\n\t\t\tdestination = isArray(source)\n\t\t\t\t? []\n\t\t\t\t: Object.create(getPrototypeOf(source));\n\t\t\tneedsRecurse = true;\n\t\t}\n\n\t\tstackSource.push(source);\n\t\tstackDest.push(destination);\n\n\t\treturn needsRecurse ? copyRecurse(source, destination) : destination;\n\t}\n\n\tfunction copyType(source) {\n\t\tswitch (toString.call(source)) {\n\t\t\tcase \"[object Int8Array]\":\n\t\t\tcase \"[object Int16Array]\":\n\t\t\tcase \"[object Int32Array]\":\n\t\t\tcase \"[object Float32Array]\":\n\t\t\tcase \"[object Float64Array]\":\n\t\t\tcase \"[object Uint8Array]\":\n\t\t\tcase \"[object Uint8ClampedArray]\":\n\t\t\tcase \"[object Uint16Array]\":\n\t\t\tcase \"[object Uint32Array]\":\n\t\t\t\treturn new source.constructor(\n\t\t\t\t\tcopyElement(source.buffer),\n\t\t\t\t\tsource.byteOffset,\n\t\t\t\t\tsource.length\n\t\t\t\t);\n\n\t\t\tcase \"[object ArrayBuffer]\":\n\t\t\t\t// Support: IE10\n\t\t\t\tif (!source.slice) {\n\t\t\t\t\t// If we're in this case we know the environment supports ArrayBuffer\n\t\t\t\t\t/* eslint-disable no-undef */\n\t\t\t\t\tvar copied = new ArrayBuffer(source.byteLength);\n\t\t\t\t\tnew Uint8Array(copied).set(new Uint8Array(source));\n\t\t\t\t\t/* eslint-enable */\n\t\t\t\t\treturn copied;\n\t\t\t\t}\n\t\t\t\treturn source.slice(0);\n\n\t\t\tcase \"[object Boolean]\":\n\t\t\tcase \"[object Number]\":\n\t\t\tcase \"[object String]\":\n\t\t\tcase \"[object Date]\":\n\t\t\t\treturn new source.constructor(source.valueOf());\n\n\t\t\tcase \"[object RegExp]\":\n\t\t\t\tvar re = new RegExp(\n\t\t\t\t\tsource.source,\n\t\t\t\t\tsource.toString().match(/[^\\/]*$/)[0]\n\t\t\t\t);\n\t\t\t\tre.lastIndex = source.lastIndex;\n\t\t\t\treturn re;\n\n\t\t\tcase \"[object Blob]\":\n\t\t\t\treturn new source.constructor([source], { type: source.type });\n\t\t}\n\n\t\tif (isFunction(source.cloneNode)) {\n\t\t\treturn source.cloneNode(true);\n\t\t}\n\t}\n}\n\n/**\n * @ngdoc function\n * @name angular.equals\n * @module ng\n * @kind function\n *\n * @description\n * Determines if two objects or two values are equivalent. Supports value types, regular\n * expressions, arrays and objects.\n *\n * Two objects or values are considered equivalent if at least one of the following is true:\n *\n * * Both objects or values pass `===` comparison.\n * * Both objects or values are of the same type and all of their properties are equal by\n * comparing them with `angular.equals`.\n * * Both values are NaN. (In JavaScript, NaN == NaN => false. But we consider two NaN as equal)\n * * Both values represent the same regular expression (In JavaScript,\n * /abc/ == /abc/ => false. But we consider two regular expressions as equal when their textual\n * representation matches).\n *\n * During a property comparison, properties of `function` type and properties with names\n * that begin with `$` are ignored.\n *\n * Scope and DOMWindow objects are being compared only by identify (`===`).\n *\n * @param {*} o1 Object or value to compare.\n * @param {*} o2 Object or value to compare.\n * @returns {boolean} True if arguments are equal.\n *\n * @example\n \n \n
\n
\n

User 1

\n Name: \n Age: \n\n

User 2

\n Name: \n Age: \n\n
\n
\n \n
\n User 1:
{{user1 | json}}
\n User 2:
{{user2 | json}}
\n Equal:
{{result}}
\n
\n
\n
\n \n angular.module('equalsExample', []).controller('ExampleController', ['$scope', function($scope) {\n $scope.user1 = {};\n $scope.user2 = {};\n $scope.compare = function() {\n $scope.result = angular.equals($scope.user1, $scope.user2);\n };\n }]);\n \n
\n */\nfunction equals(o1, o2) {\n\tif (o1 === o2) return true;\n\tif (o1 === null || o2 === null) return false;\n\t// eslint-disable-next-line no-self-compare\n\tif (o1 !== o1 && o2 !== o2) return true; // NaN === NaN\n\tvar t1 = typeof o1,\n\t\tt2 = typeof o2,\n\t\tlength,\n\t\tkey,\n\t\tkeySet;\n\tif (t1 === t2 && t1 === \"object\") {\n\t\tif (isArray(o1)) {\n\t\t\tif (!isArray(o2)) return false;\n\t\t\tif ((length = o1.length) === o2.length) {\n\t\t\t\tfor (key = 0; key < length; key++) {\n\t\t\t\t\tif (!equals(o1[key], o2[key])) return false;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (isDate(o1)) {\n\t\t\tif (!isDate(o2)) return false;\n\t\t\treturn equals(o1.getTime(), o2.getTime());\n\t\t} else if (isRegExp(o1)) {\n\t\t\tif (!isRegExp(o2)) return false;\n\t\t\treturn o1.toString() === o2.toString();\n\t\t} else {\n\t\t\tif (\n\t\t\t\tisScope(o1) ||\n\t\t\t\tisScope(o2) ||\n\t\t\t\tisWindow(o1) ||\n\t\t\t\tisWindow(o2) ||\n\t\t\t\tisArray(o2) ||\n\t\t\t\tisDate(o2) ||\n\t\t\t\tisRegExp(o2)\n\t\t\t)\n\t\t\t\treturn false;\n\t\t\tkeySet = createMap();\n\t\t\tfor (key in o1) {\n\t\t\t\tif (key.charAt(0) === \"$\" || isFunction(o1[key])) continue;\n\t\t\t\tif (!equals(o1[key], o2[key])) return false;\n\t\t\t\tkeySet[key] = true;\n\t\t\t}\n\t\t\tfor (key in o2) {\n\t\t\t\tif (\n\t\t\t\t\t!(key in keySet) &&\n\t\t\t\t\tkey.charAt(0) !== \"$\" &&\n\t\t\t\t\tisDefined(o2[key]) &&\n\t\t\t\t\t!isFunction(o2[key])\n\t\t\t\t)\n\t\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nvar csp = function () {\n\tif (!isDefined(csp.rules)) {\n\t\tvar ngCspElement =\n\t\t\twindow.document.querySelector(\"[ng-csp]\") ||\n\t\t\twindow.document.querySelector(\"[data-ng-csp]\");\n\n\t\tif (ngCspElement) {\n\t\t\tvar ngCspAttribute =\n\t\t\t\tngCspElement.getAttribute(\"ng-csp\") ||\n\t\t\t\tngCspElement.getAttribute(\"data-ng-csp\");\n\t\t\tcsp.rules = {\n\t\t\t\tnoUnsafeEval:\n\t\t\t\t\t!ngCspAttribute || ngCspAttribute.indexOf(\"no-unsafe-eval\") !== -1,\n\t\t\t\tnoInlineStyle:\n\t\t\t\t\t!ngCspAttribute || ngCspAttribute.indexOf(\"no-inline-style\") !== -1,\n\t\t\t};\n\t\t} else {\n\t\t\tcsp.rules = {\n\t\t\t\tnoUnsafeEval: noUnsafeEval(),\n\t\t\t\tnoInlineStyle: false,\n\t\t\t};\n\t\t}\n\t}\n\n\treturn csp.rules;\n\n\tfunction noUnsafeEval() {\n\t\ttry {\n\t\t\t// eslint-disable-next-line no-new, no-new-func\n\t\t\tnew Function(\"\");\n\t\t\treturn false;\n\t\t} catch (e) {\n\t\t\treturn true;\n\t\t}\n\t}\n};\n\n/**\n * @ngdoc directive\n * @module ng\n * @name ngJq\n *\n * @element ANY\n * @param {string=} ngJq the name of the library available under `window`\n * to be used for angular.element\n * @description\n * Use this directive to force the angular.element library. This should be\n * used to force either jqLite by leaving ng-jq blank or setting the name of\n * the jquery variable under window (eg. jQuery).\n *\n * Since angular looks for this directive when it is loaded (doesn't wait for the\n * DOMContentLoaded event), it must be placed on an element that comes before the script\n * which loads angular. Also, only the first instance of `ng-jq` will be used and all\n * others ignored.\n *\n * @example\n * This example shows how to force jqLite using the `ngJq` directive to the `html` tag.\n ```html\n \n \n ...\n ...\n \n ```\n * @example\n * This example shows how to use a jQuery based library of a different name.\n * The library name must be available at the top most 'window'.\n ```html\n \n \n ...\n ...\n \n ```\n */\nvar jq = function () {\n\tif (isDefined(jq.name_)) return jq.name_;\n\tvar el;\n\tvar i,\n\t\tii = ngAttrPrefixes.length,\n\t\tprefix,\n\t\tname;\n\tfor (i = 0; i < ii; ++i) {\n\t\tprefix = ngAttrPrefixes[i];\n\t\tel = window.document.querySelector(\n\t\t\t\"[\" + prefix.replace(\":\", \"\\\\:\") + \"jq]\"\n\t\t);\n\t\tif (el) {\n\t\t\tname = el.getAttribute(prefix + \"jq\");\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn (jq.name_ = name);\n};\n\nfunction concat(array1, array2, index) {\n\treturn array1.concat(slice.call(array2, index));\n}\n\nfunction sliceArgs(args, startIndex) {\n\treturn slice.call(args, startIndex || 0);\n}\n\n/**\n * @ngdoc function\n * @name angular.bind\n * @module ng\n * @kind function\n *\n * @description\n * Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for\n * `fn`). You can supply optional `args` that are prebound to the function. This feature is also\n * known as [partial application](http://en.wikipedia.org/wiki/Partial_application), as\n * distinguished from [function currying](http://en.wikipedia.org/wiki/Currying#Contrast_with_partial_function_application).\n *\n * @param {Object} self Context which `fn` should be evaluated in.\n * @param {function()} fn Function to be bound.\n * @param {...*} args Optional arguments to be prebound to the `fn` function call.\n * @returns {function()} Function that wraps the `fn` with all the specified bindings.\n */\n// eslint-disable-next-line consistent-this\nfunction bind(self, fn) {\n\tvar curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : [];\n\tif (isFunction(fn) && !(fn instanceof RegExp)) {\n\t\treturn curryArgs.length\n\t\t\t? function () {\n\t\t\t\t\treturn arguments.length\n\t\t\t\t\t\t? fn.apply(self, concat(curryArgs, arguments, 0))\n\t\t\t\t\t\t: fn.apply(self, curryArgs);\n\t\t\t\t}\n\t\t\t: function () {\n\t\t\t\t\treturn arguments.length ? fn.apply(self, arguments) : fn.call(self);\n\t\t\t\t};\n\t} else {\n\t\t// In IE, native methods are not functions so they cannot be bound (note: they don't need to be).\n\t\treturn fn;\n\t}\n}\n\nfunction toJsonReplacer(key, value) {\n\tvar val = value;\n\n\tif (\n\t\ttypeof key === \"string\" &&\n\t\tkey.charAt(0) === \"$\" &&\n\t\tkey.charAt(1) === \"$\"\n\t) {\n\t\tval = undefined;\n\t} else if (isWindow(value)) {\n\t\tval = \"$WINDOW\";\n\t} else if (value && window.document === value) {\n\t\tval = \"$DOCUMENT\";\n\t} else if (isScope(value)) {\n\t\tval = \"$SCOPE\";\n\t}\n\n\treturn val;\n}\n\n/**\n * @ngdoc function\n * @name angular.toJson\n * @module ng\n * @kind function\n *\n * @description\n * Serializes input into a JSON-formatted string. Properties with leading $$ characters will be\n * stripped since angular uses this notation internally.\n *\n * @param {Object|Array|Date|string|number|boolean} obj Input to be serialized into JSON.\n * @param {boolean|number} [pretty=2] If set to true, the JSON output will contain newlines and whitespace.\n * If set to an integer, the JSON output will contain that many spaces per indentation.\n * @returns {string|undefined} JSON-ified string representing `obj`.\n * @knownIssue\n *\n * The Safari browser throws a `RangeError` instead of returning `null` when it tries to stringify a `Date`\n * object with an invalid date value. The only reliable way to prevent this is to monkeypatch the\n * `Date.prototype.toJSON` method as follows:\n *\n * ```\n * var _DatetoJSON = Date.prototype.toJSON;\n * Date.prototype.toJSON = function() {\n * try {\n * return _DatetoJSON.call(this);\n * } catch(e) {\n * if (e instanceof RangeError) {\n * return null;\n * }\n * throw e;\n * }\n * };\n * ```\n *\n * See https://github.com/angular/angular.js/pull/14221 for more information.\n */\nfunction toJson(obj, pretty) {\n\tif (isUndefined(obj)) return undefined;\n\tif (!isNumber(pretty)) {\n\t\tpretty = pretty ? 2 : null;\n\t}\n\treturn JSON.stringify(obj, toJsonReplacer, pretty);\n}\n\n/**\n * @ngdoc function\n * @name angular.fromJson\n * @module ng\n * @kind function\n *\n * @description\n * Deserializes a JSON string.\n *\n * @param {string} json JSON string to deserialize.\n * @returns {Object|Array|string|number} Deserialized JSON string.\n */\nfunction fromJson(json) {\n\treturn isString(json) ? JSON.parse(json) : json;\n}\n\nvar ALL_COLONS = /:/g;\nfunction timezoneToOffset(timezone, fallback) {\n\t// IE/Edge do not \"understand\" colon (`:`) in timezone\n\ttimezone = timezone.replace(ALL_COLONS, \"\");\n\tvar requestedTimezoneOffset =\n\t\tDate.parse(\"Jan 01, 1970 00:00:00 \" + timezone) / 60000;\n\treturn isNumberNaN(requestedTimezoneOffset)\n\t\t? fallback\n\t\t: requestedTimezoneOffset;\n}\n\nfunction addDateMinutes(date, minutes) {\n\tdate = new Date(date.getTime());\n\tdate.setMinutes(date.getMinutes() + minutes);\n\treturn date;\n}\n\nfunction convertTimezoneToLocal(date, timezone, reverse) {\n\treverse = reverse ? -1 : 1;\n\tvar dateTimezoneOffset = date.getTimezoneOffset();\n\tvar timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);\n\treturn addDateMinutes(date, reverse * (timezoneOffset - dateTimezoneOffset));\n}\n\n/**\n * @returns {string} Returns the string representation of the element.\n */\nfunction startingTag(element) {\n\telement = jqLite(element).clone();\n\ttry {\n\t\t// turns out IE does not let you set .html() on elements which\n\t\t// are not allowed to have children. So we just ignore it.\n\t\telement.empty();\n\t} catch (e) {\n\t\t/* empty */\n\t}\n\tvar elemHtml = jqLite(\"
\").append(element).html();\n\ttry {\n\t\treturn element[0].nodeType === NODE_TYPE_TEXT\n\t\t\t? lowercase(elemHtml)\n\t\t\t: elemHtml\n\t\t\t\t\t.match(/^(<[^>]+>)/)[1]\n\t\t\t\t\t.replace(/^<([\\w\\-]+)/, function (match, nodeName) {\n\t\t\t\t\t\treturn \"<\" + lowercase(nodeName);\n\t\t\t\t\t});\n\t} catch (e) {\n\t\treturn lowercase(elemHtml);\n\t}\n}\n\n/////////////////////////////////////////////////\n\n/**\n * Tries to decode the URI component without throwing an exception.\n *\n * @private\n * @param str value potential URI component to check.\n * @returns {boolean} True if `value` can be decoded\n * with the decodeURIComponent function.\n */\nfunction tryDecodeURIComponent(value) {\n\ttry {\n\t\treturn decodeURIComponent(value);\n\t} catch (e) {\n\t\t// Ignore any invalid uri component.\n\t}\n}\n\n/**\n * Parses an escaped url query string into key-value pairs.\n * @returns {Object.}\n */\nfunction parseKeyValue(/**string*/ keyValue) {\n\tvar obj = {};\n\tforEach((keyValue || \"\").split(\"&\"), function (keyValue) {\n\t\tvar splitPoint, key, val;\n\t\tif (keyValue) {\n\t\t\tkey = keyValue = keyValue.replace(/\\+/g, \"%20\");\n\t\t\tsplitPoint = keyValue.indexOf(\"=\");\n\t\t\tif (splitPoint !== -1) {\n\t\t\t\tkey = keyValue.substring(0, splitPoint);\n\t\t\t\tval = keyValue.substring(splitPoint + 1);\n\t\t\t}\n\t\t\tkey = tryDecodeURIComponent(key);\n\t\t\tif (isDefined(key)) {\n\t\t\t\tval = isDefined(val) ? tryDecodeURIComponent(val) : true;\n\t\t\t\tif (!hasOwnProperty.call(obj, key)) {\n\t\t\t\t\tobj[key] = val;\n\t\t\t\t} else if (isArray(obj[key])) {\n\t\t\t\t\tobj[key].push(val);\n\t\t\t\t} else {\n\t\t\t\t\tobj[key] = [obj[key], val];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\treturn obj;\n}\n\nfunction toKeyValue(obj) {\n\tvar parts = [];\n\tforEach(obj, function (value, key) {\n\t\tif (isArray(value)) {\n\t\t\tforEach(value, function (arrayValue) {\n\t\t\t\tparts.push(\n\t\t\t\t\tencodeUriQuery(key, true) +\n\t\t\t\t\t\t(arrayValue === true ? \"\" : \"=\" + encodeUriQuery(arrayValue, true))\n\t\t\t\t);\n\t\t\t});\n\t\t} else {\n\t\t\tparts.push(\n\t\t\t\tencodeUriQuery(key, true) +\n\t\t\t\t\t(value === true ? \"\" : \"=\" + encodeUriQuery(value, true))\n\t\t\t);\n\t\t}\n\t});\n\treturn parts.length ? parts.join(\"&\") : \"\";\n}\n\n/**\n * We need our custom method because encodeURIComponent is too aggressive and doesn't follow\n * http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path\n * segments:\n * segment = *pchar\n * pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"\n * pct-encoded = \"%\" HEXDIG HEXDIG\n * unreserved = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n * sub-delims = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\"\n * / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n */\nfunction encodeUriSegment(val) {\n\treturn encodeUriQuery(val, true)\n\t\t.replace(/%26/gi, \"&\")\n\t\t.replace(/%3D/gi, \"=\")\n\t\t.replace(/%2B/gi, \"+\");\n}\n\n/**\n * This method is intended for encoding *key* or *value* parts of query component. We need a custom\n * method because encodeURIComponent is too aggressive and encodes stuff that doesn't have to be\n * encoded per http://tools.ietf.org/html/rfc3986:\n * query = *( pchar / \"/\" / \"?\" )\n * pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"\n * unreserved = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n * pct-encoded = \"%\" HEXDIG HEXDIG\n * sub-delims = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\"\n * / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n */\nfunction encodeUriQuery(val, pctEncodeSpaces) {\n\treturn encodeURIComponent(val)\n\t\t.replace(/%40/gi, \"@\")\n\t\t.replace(/%3A/gi, \":\")\n\t\t.replace(/%24/g, \"$\")\n\t\t.replace(/%2C/gi, \",\")\n\t\t.replace(/%3B/gi, \";\")\n\t\t.replace(/%20/g, pctEncodeSpaces ? \"%20\" : \"+\");\n}\n\nfunction getNgAttribute(element, ngAttr) {\n\tvar attr,\n\t\ti,\n\t\tii = ngAttrPrefixes.length;\n\tfor (i = 0; i < ii; ++i) {\n\t\tattr = ngAttrPrefixes[i] + ngAttr;\n\t\tif (isString((attr = element.getAttribute(attr)))) {\n\t\t\treturn attr;\n\t\t}\n\t}\n\treturn null;\n}\n\nfunction allowAutoBootstrap(document) {\n\tif (!document.currentScript) {\n\t\treturn true;\n\t}\n\tvar src = document.currentScript.getAttribute(\"src\");\n\tvar link = document.createElement(\"a\");\n\tlink.href = src;\n\tvar scriptProtocol = link.protocol;\n\tvar docLoadProtocol = document.location.protocol;\n\tif (\n\t\t(scriptProtocol === \"resource:\" ||\n\t\t\tscriptProtocol === \"chrome-extension:\") &&\n\t\tdocLoadProtocol !== scriptProtocol\n\t) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n// Cached as it has to run during loading so that document.currentScript is available.\nvar isAutoBootstrapAllowed = allowAutoBootstrap(window.document);\n\n/**\n * @ngdoc directive\n * @name ngApp\n * @module ng\n *\n * @element ANY\n * @param {angular.Module} ngApp an optional application\n * {@link angular.module module} name to load.\n * @param {boolean=} ngStrictDi if this attribute is present on the app element, the injector will be\n * created in \"strict-di\" mode. This means that the application will fail to invoke functions which\n * do not use explicit function annotation (and are thus unsuitable for minification), as described\n * in {@link guide/di the Dependency Injection guide}, and useful debugging info will assist in\n * tracking down the root of these bugs.\n *\n * @description\n *\n * Use this directive to **auto-bootstrap** an AngularJS application. The `ngApp` directive\n * designates the **root element** of the application and is typically placed near the root element\n * of the page - e.g. on the `` or `` tags.\n *\n * There are a few things to keep in mind when using `ngApp`:\n * - only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp`\n * found in the document will be used to define the root element to auto-bootstrap as an\n * application. To run multiple applications in an HTML document you must manually bootstrap them using\n * {@link angular.bootstrap} instead.\n * - AngularJS applications cannot be nested within each other.\n * - Do not use a directive that uses {@link ng.$compile#transclusion transclusion} on the same element as `ngApp`.\n * This includes directives such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and\n * {@link ngRoute.ngView `ngView`}.\n * Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},\n * causing animations to stop working and making the injector inaccessible from outside the app.\n *\n * You can specify an **AngularJS module** to be used as the root module for the application. This\n * module will be loaded into the {@link auto.$injector} when the application is bootstrapped. It\n * should contain the application code needed or have dependencies on other modules that will\n * contain the code. See {@link angular.module} for more information.\n *\n * In the example below if the `ngApp` directive were not placed on the `html` element then the\n * document would not be compiled, the `AppController` would not be instantiated and the `{{ a+b }}`\n * would not be resolved to `3`.\n *\n * `ngApp` is the easiest, and most common way to bootstrap an application.\n *\n \n \n
\n I can add: {{a}} + {{b}} = {{ a+b }}\n
\n
\n \n angular.module('ngAppDemo', []).controller('ngAppDemoController', function($scope) {\n $scope.a = 1;\n $scope.b = 2;\n });\n \n
\n *\n * Using `ngStrictDi`, you would see something like this:\n *\n \n \n
\n
\n I can add: {{a}} + {{b}} = {{ a+b }}\n\n

This renders because the controller does not fail to\n instantiate, by using explicit annotation style (see\n script.js for details)\n

\n
\n\n
\n Name:
\n Hello, {{name}}!\n\n

This renders because the controller does not fail to\n instantiate, by using explicit annotation style\n (see script.js for details)\n

\n
\n\n
\n I can add: {{a}} + {{b}} = {{ a+b }}\n\n

The controller could not be instantiated, due to relying\n on automatic function annotations (which are disabled in\n strict mode). As such, the content of this section is not\n interpolated, and there should be an error in your web console.\n

\n
\n
\n
\n \n angular.module('ngAppStrictDemo', [])\n // BadController will fail to instantiate, due to relying on automatic function annotation,\n // rather than an explicit annotation\n .controller('BadController', function($scope) {\n $scope.a = 1;\n $scope.b = 2;\n })\n // Unlike BadController, GoodController1 and GoodController2 will not fail to be instantiated,\n // due to using explicit annotations using the array style and $inject property, respectively.\n .controller('GoodController1', ['$scope', function($scope) {\n $scope.a = 1;\n $scope.b = 2;\n }])\n .controller('GoodController2', GoodController2);\n function GoodController2($scope) {\n $scope.name = 'World';\n }\n GoodController2.$inject = ['$scope'];\n \n \n div[ng-controller] {\n margin-bottom: 1em;\n -webkit-border-radius: 4px;\n border-radius: 4px;\n border: 1px solid;\n padding: .5em;\n }\n div[ng-controller^=Good] {\n border-color: #d6e9c6;\n background-color: #dff0d8;\n color: #3c763d;\n }\n div[ng-controller^=Bad] {\n border-color: #ebccd1;\n background-color: #f2dede;\n color: #a94442;\n margin-bottom: 0;\n }\n \n
\n */\n\n/**\n * @ngdoc function\n * @name angular.bootstrap\n * @module ng\n * @description\n * Use this function to manually start up angular application.\n *\n * For more information, see the {@link guide/bootstrap Bootstrap guide}.\n *\n * Angular will detect if it has been loaded into the browser more than once and only allow the\n * first loaded script to be bootstrapped and will report a warning to the browser console for\n * each of the subsequent scripts. This prevents strange results in applications, where otherwise\n * multiple instances of Angular try to work on the DOM.\n *\n *
\n * **Note:** Protractor based end-to-end tests cannot use this function to bootstrap manually.\n * They must use {@link ng.directive:ngApp ngApp}.\n *
\n *\n *
\n * **Note:** Do not bootstrap the app on an element with a directive that uses {@link ng.$compile#transclusion transclusion},\n * such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and {@link ngRoute.ngView `ngView`}.\n * Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},\n * causing animations to stop working and making the injector inaccessible from outside the app.\n *
\n *\n * ```html\n * \n * \n * \n *
\n * {{greeting}}\n *
\n *\n * \n * \n * \n * \n * ```\n *\n * @param {DOMElement} element DOM element which is the root of angular application.\n * @param {Array=} modules an array of modules to load into the application.\n * Each item in the array should be the name of a predefined module or a (DI annotated)\n * function that will be invoked by the injector as a `config` block.\n * See: {@link angular.module modules}\n * @param {Object=} config an object for defining configuration options for the application. The\n * following keys are supported:\n *\n * * `strictDi` - disable automatic function annotation for the application. This is meant to\n * assist in finding bugs which break minified code. Defaults to `false`.\n *\n * @returns {auto.$injector} Returns the newly created injector for this app.\n */\nfunction bootstrap(element, modules, config) {\n\tif (!isObject(config)) config = {};\n\tvar defaultConfig = {\n\t\tstrictDi: false,\n\t};\n\tconfig = extend(defaultConfig, config);\n\tvar doBootstrap = function () {\n\t\telement = jqLite(element);\n\n\t\tif (element.injector()) {\n\t\t\tvar tag =\n\t\t\t\telement[0] === window.document ? \"document\" : startingTag(element);\n\t\t\t// Encode angle brackets to prevent input from being sanitized to empty string #8683.\n\t\t\tthrow ngMinErr(\n\t\t\t\t\"btstrpd\",\n\t\t\t\t\"App already bootstrapped with this element '{0}'\",\n\t\t\t\ttag.replace(//, \">\")\n\t\t\t);\n\t\t}\n\n\t\tmodules = modules || [];\n\t\tmodules.unshift([\n\t\t\t\"$provide\",\n\t\t\tfunction ($provide) {\n\t\t\t\t$provide.value(\"$rootElement\", element);\n\t\t\t},\n\t\t]);\n\n\t\tif (config.debugInfoEnabled) {\n\t\t\t// Pushing so that this overrides `debugInfoEnabled` setting defined in user's `modules`.\n\t\t\tmodules.push([\n\t\t\t\t\"$compileProvider\",\n\t\t\t\tfunction ($compileProvider) {\n\t\t\t\t\t$compileProvider.debugInfoEnabled(true);\n\t\t\t\t},\n\t\t\t]);\n\t\t}\n\n\t\tmodules.unshift(\"ng\");\n\t};\n\n\tvar NG_ENABLE_DEBUG_INFO = /^NG_ENABLE_DEBUG_INFO!/;\n\tvar NG_DEFER_BOOTSTRAP = /^NG_DEFER_BOOTSTRAP!/;\n\n\tif (window && NG_ENABLE_DEBUG_INFO.test(window.name)) {\n\t\tconfig.debugInfoEnabled = true;\n\t\twindow.name = window.name.replace(NG_ENABLE_DEBUG_INFO, \"\");\n\t}\n\n\tif (window && !NG_DEFER_BOOTSTRAP.test(window.name)) {\n\t\treturn doBootstrap();\n\t}\n\n\twindow.name = window.name.replace(NG_DEFER_BOOTSTRAP, \"\");\n\tangular.resumeBootstrap = function (extraModules) {\n\t\tforEach(extraModules, function (module) {\n\t\t\tmodules.push(module);\n\t\t});\n\t\treturn doBootstrap();\n\t};\n\n\tif (isFunction(angular.resumeDeferredBootstrap)) {\n\t\tangular.resumeDeferredBootstrap();\n\t}\n}\n\n/**\n * @ngdoc function\n * @name angular.reloadWithDebugInfo\n * @module ng\n * @description\n * Use this function to reload the current application with debug information turned on.\n * This takes precedence over a call to `$compileProvider.debugInfoEnabled(false)`.\n *\n * See {@link ng.$compileProvider#debugInfoEnabled} for more.\n */\nfunction reloadWithDebugInfo() {\n\twindow.name = \"NG_ENABLE_DEBUG_INFO!\" + window.name;\n\twindow.location.reload();\n}\n\n/**\n * @name angular.getTestability\n * @module ng\n * @description\n * Get the testability service for the instance of Angular on the given\n * element.\n * @param {DOMElement} element DOM element which is the root of angular application.\n */\nfunction getTestability(rootElement) {\n\tvar injector = angular.element(rootElement).injector();\n\tif (!injector) {\n\t\tthrow ngMinErr(\n\t\t\t\"test\",\n\t\t\t\"no injector found for element argument to getTestability\"\n\t\t);\n\t}\n\treturn injector.get(\"$$testability\");\n}\n\nvar SNAKE_CASE_REGEXP = /[A-Z]/g;\nfunction snake_case(name, separator) {\n\tseparator = separator || \"_\";\n\treturn name.replace(SNAKE_CASE_REGEXP, function (letter, pos) {\n\t\treturn (pos ? separator : \"\") + letter.toLowerCase();\n\t});\n}\n\nvar bindJQueryFired = false;\nfunction bindJQuery() {\n\tvar originalCleanData;\n\n\tif (bindJQueryFired) {\n\t\treturn;\n\t}\n\n\t// bind to jQuery if present;\n\tvar jqName = jq();\n\tjQuery = isUndefined(jqName)\n\t\t? window.jQuery // use jQuery (if present)\n\t\t: !jqName\n\t\t\t? undefined // use jqLite\n\t\t\t: window[jqName]; // use jQuery specified by `ngJq`\n\n\t// Use jQuery if it exists with proper functionality, otherwise default to us.\n\t// Angular 1.2+ requires jQuery 1.7+ for on()/off() support.\n\t// Angular 1.3+ technically requires at least jQuery 2.1+ but it may work with older\n\t// versions. It will not work for sure with jQuery <1.7, though.\n\tif (jQuery && jQuery.fn.on) {\n\t\tjqLite = jQuery;\n\t\textend(jQuery.fn, {\n\t\t\tscope: JQLitePrototype.scope,\n\t\t\tisolateScope: JQLitePrototype.isolateScope,\n\t\t\tcontroller: JQLitePrototype.controller,\n\t\t\tinjector: JQLitePrototype.injector,\n\t\t\tinheritedData: JQLitePrototype.inheritedData,\n\t\t});\n\n\t\t// All nodes removed from the DOM via various jQuery APIs like .remove()\n\t\t// are passed through jQuery.cleanData. Monkey-patch this method to fire\n\t\t// the $destroy event on all removed nodes.\n\t\toriginalCleanData = jQuery.cleanData;\n\t\tjQuery.cleanData = function (elems) {\n\t\t\tvar events;\n\t\t\tfor (var i = 0, elem; (elem = elems[i]) != null; i++) {\n\t\t\t\tevents = jQuery._data(elem, \"events\");\n\t\t\t\tif (events && events.$destroy) {\n\t\t\t\t\tjQuery(elem).triggerHandler(\"$destroy\");\n\t\t\t\t}\n\t\t\t}\n\t\t\toriginalCleanData(elems);\n\t\t};\n\t} else {\n\t\tjqLite = JQLite;\n\t}\n\n\tangular.element = jqLite;\n\n\t// Prevent double-proxying.\n\tbindJQueryFired = true;\n}\n\n/**\n * throw error if the argument is falsy.\n */\nfunction assertArg(arg, name, reason) {\n\tif (!arg) {\n\t\tthrow ngMinErr(\n\t\t\t\"areq\",\n\t\t\t\"Argument '{0}' is {1}\",\n\t\t\tname || \"?\",\n\t\t\treason || \"required\"\n\t\t);\n\t}\n\treturn arg;\n}\n\nfunction assertArgFn(arg, name, acceptArrayAnnotation) {\n\tif (acceptArrayAnnotation && isArray(arg)) {\n\t\targ = arg[arg.length - 1];\n\t}\n\n\tassertArg(\n\t\tisFunction(arg),\n\t\tname,\n\t\t\"not a function, got \" +\n\t\t\t(arg && typeof arg === \"object\"\n\t\t\t\t? arg.constructor.name || \"Object\"\n\t\t\t\t: typeof arg)\n\t);\n\treturn arg;\n}\n\n/**\n * throw error if the name given is hasOwnProperty\n * @param {String} name the name to test\n * @param {String} context the context in which the name is used, such as module or directive\n */\nfunction assertNotHasOwnProperty(name, context) {\n\tif (name === \"hasOwnProperty\") {\n\t\tthrow ngMinErr(\n\t\t\t\"badname\",\n\t\t\t\"hasOwnProperty is not a valid {0} name\",\n\t\t\tcontext\n\t\t);\n\t}\n}\n\n/**\n * Return the value accessible from the object by path. Any undefined traversals are ignored\n * @param {Object} obj starting object\n * @param {String} path path to traverse\n * @param {boolean} [bindFnToScope=true]\n * @returns {Object} value as accessible by path\n */\n//TODO(misko): this function needs to be removed\nfunction getter(obj, path, bindFnToScope) {\n\tif (!path) return obj;\n\tvar keys = path.split(\".\");\n\tvar key;\n\tvar lastInstance = obj;\n\tvar len = keys.length;\n\n\tfor (var i = 0; i < len; i++) {\n\t\tkey = keys[i];\n\t\tif (obj) {\n\t\t\tobj = (lastInstance = obj)[key];\n\t\t}\n\t}\n\tif (!bindFnToScope && isFunction(obj)) {\n\t\treturn bind(lastInstance, obj);\n\t}\n\treturn obj;\n}\n\n/**\n * Return the DOM siblings between the first and last node in the given array.\n * @param {Array} array like object\n * @returns {Array} the inputted object or a jqLite collection containing the nodes\n */\nfunction getBlockNodes(nodes) {\n\t// TODO(perf): update `nodes` instead of creating a new object?\n\tvar node = nodes[0];\n\tvar endNode = nodes[nodes.length - 1];\n\tvar blockNodes;\n\n\tfor (var i = 1; node !== endNode && (node = node.nextSibling); i++) {\n\t\tif (blockNodes || nodes[i] !== node) {\n\t\t\tif (!blockNodes) {\n\t\t\t\tblockNodes = jqLite(slice.call(nodes, 0, i));\n\t\t\t}\n\t\t\tblockNodes.push(node);\n\t\t}\n\t}\n\n\treturn blockNodes || nodes;\n}\n\n/**\n * Creates a new object without a prototype. This object is useful for lookup without having to\n * guard against prototypically inherited properties via hasOwnProperty.\n *\n * Related micro-benchmarks:\n * - http://jsperf.com/object-create2\n * - http://jsperf.com/proto-map-lookup/2\n * - http://jsperf.com/for-in-vs-object-keys2\n *\n * @returns {Object}\n */\nfunction createMap() {\n\treturn Object.create(null);\n}\n\nfunction stringify(value) {\n\tif (value == null) {\n\t\t// null || undefined\n\t\treturn \"\";\n\t}\n\tswitch (typeof value) {\n\t\tcase \"string\":\n\t\t\tbreak;\n\t\tcase \"number\":\n\t\t\tvalue = \"\" + value;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (hasCustomToString(value) && !isArray(value) && !isDate(value)) {\n\t\t\t\tvalue = value.toString();\n\t\t\t} else {\n\t\t\t\tvalue = toJson(value);\n\t\t\t}\n\t}\n\n\treturn value;\n}\n\n/* global toDebugString: true */\n\nfunction serializeObject(obj) {\n\tvar seen = [];\n\n\treturn JSON.stringify(obj, function (key, val) {\n\t\tval = toJsonReplacer(key, val);\n\t\tif (isObject(val)) {\n\t\t\tif (seen.indexOf(val) >= 0) return \"...\";\n\n\t\t\tseen.push(val);\n\t\t}\n\t\treturn val;\n\t});\n}\n\nfunction toDebugString(obj) {\n\tif (typeof obj === \"function\") {\n\t\treturn obj.toString().replace(/ \\{[\\s\\S]*$/, \"\");\n\t} else if (isUndefined(obj)) {\n\t\treturn \"undefined\";\n\t} else if (typeof obj !== \"string\") {\n\t\treturn serializeObject(obj);\n\t}\n\treturn obj;\n}\n\n/**\n * @description\n *\n * This object provides a utility for producing rich Error messages within\n * Angular. It can be called as follows:\n *\n * var exampleMinErr = minErr('example');\n * throw exampleMinErr('one', 'This {0} is {1}', foo, bar);\n *\n * The above creates an instance of minErr in the example namespace. The\n * resulting error will have a namespaced error code of example.one. The\n * resulting error will replace {0} with the value of foo, and {1} with the\n * value of bar. The object is not restricted in the number of arguments it can\n * take.\n *\n * If fewer arguments are specified than necessary for interpolation, the extra\n * interpolation markers will be preserved in the final string.\n *\n * Since data will be parsed statically during a build step, some restrictions\n * are applied with respect to how minErr instances are created and called.\n * Instances should have names of the form namespaceMinErr for a minErr created\n * using minErr('namespace') . Error codes, namespaces and template strings\n * should all be static strings, not variables or general expressions.\n *\n * @param {string} module The namespace to use for the new minErr instance.\n * @param {function} ErrorConstructor Custom error constructor to be instantiated when returning\n * error from returned function, for cases when a particular type of error is useful.\n * @returns {function(code:string, template:string, ...templateArgs): Error} minErr instance\n */\n\nfunction minErr(module, ErrorConstructor) {\n\tErrorConstructor = ErrorConstructor || Error;\n\treturn function () {\n\t\tvar SKIP_INDEXES = 2;\n\n\t\tvar templateArgs = arguments,\n\t\t\tcode = templateArgs[0],\n\t\t\tmessage = \"[\" + (module ? module + \":\" : \"\") + code + \"] \",\n\t\t\ttemplate = templateArgs[1],\n\t\t\tparamPrefix,\n\t\t\ti;\n\n\t\tmessage += template.replace(/\\{\\d+\\}/g, function (match) {\n\t\t\tvar index = +match.slice(1, -1),\n\t\t\t\tshiftedIndex = index + SKIP_INDEXES;\n\n\t\t\tif (shiftedIndex < templateArgs.length) {\n\t\t\t\treturn toDebugString(templateArgs[shiftedIndex]);\n\t\t\t}\n\n\t\t\treturn match;\n\t\t});\n\n\t\tmessage +=\n\t\t\t'\\nhttp://errors.angularjs.org/\"NG_VERSION_FULL\"/' +\n\t\t\t(module ? module + \"/\" : \"\") +\n\t\t\tcode;\n\n\t\tfor (\n\t\t\ti = SKIP_INDEXES, paramPrefix = \"?\";\n\t\t\ti < templateArgs.length;\n\t\t\ti++, paramPrefix = \"&\"\n\t\t) {\n\t\t\tmessage +=\n\t\t\t\tparamPrefix +\n\t\t\t\t\"p\" +\n\t\t\t\t(i - SKIP_INDEXES) +\n\t\t\t\t\"=\" +\n\t\t\t\tencodeURIComponent(toDebugString(templateArgs[i]));\n\t\t}\n\n\t\treturn new ErrorConstructor(message);\n\t};\n}\n\n/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n * Any commits to this file should be reviewed with security in mind. *\n * Changes to this file can potentially create security vulnerabilities. *\n * An approval from 2 Core members with history of modifying *\n * this file is required. *\n * *\n * Does the change somehow allow for arbitrary javascript to be executed? *\n * Or allows for someone to change the prototype of built-in objects? *\n * Or gives undesired access to variables likes document or window? *\n * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */\n\nvar $parseMinErr = minErr(\"$parse\");\n\nvar objectValueOf = {}.constructor.prototype.valueOf;\n\n// Sandboxing Angular Expressions\n// ------------------------------\n// Angular expressions are no longer sandboxed. So it is now even easier to access arbitrary JS code by\n// various means such as obtaining a reference to native JS functions like the Function constructor.\n//\n// As an example, consider the following Angular expression:\n//\n// {}.toString.constructor('alert(\"evil JS code\")')\n//\n// It is important to realize that if you create an expression from a string that contains user provided\n// content then it is possible that your application contains a security vulnerability to an XSS style attack.\n//\n// See https://docs.angularjs.org/guide/security\n\nfunction getStringValue(name) {\n\t// Property names must be strings. This means that non-string objects cannot be used\n\t// as keys in an object. Any non-string object, including a number, is typecasted\n\t// into a string via the toString method.\n\t// -- MDN, https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Property_accessors#Property_names\n\t//\n\t// So, to ensure that we are checking the same `name` that JavaScript would use, we cast it\n\t// to a string. It's not always possible. If `name` is an object and its `toString` method is\n\t// 'broken' (doesn't return a string, isn't a function, etc.), an error will be thrown:\n\t//\n\t// TypeError: Cannot convert object to primitive value\n\t//\n\t// For performance reasons, we don't catch this error here and allow it to propagate up the call\n\t// stack. Note that you'll get the same error in JavaScript if you try to access a property using\n\t// such a 'broken' object as a key.\n\treturn name + \"\";\n}\n\nvar OPERATORS = createMap();\nforEach(\n\t\"+ - * / % === !== == != < > <= >= && || ! = |\".split(\" \"),\n\tfunction (operator) {\n\t\tOPERATORS[operator] = true;\n\t}\n);\nvar ESCAPE = {\n\tn: \"\\n\",\n\tf: \"\\f\",\n\tr: \"\\r\",\n\tt: \"\\t\",\n\tv: \"\\v\",\n\t\"'\": \"'\",\n\t'\"': '\"',\n};\n\n/////////////////////////////////////////\n\n/**\n * @constructor\n */\nvar Lexer = function Lexer(options) {\n\tthis.options = options;\n};\n\nLexer.prototype = {\n\tconstructor: Lexer,\n\n\tlex: function (text) {\n\t\tthis.text = text;\n\t\tthis.index = 0;\n\t\tthis.tokens = [];\n\n\t\twhile (this.index < this.text.length) {\n\t\t\tvar ch = this.text.charAt(this.index);\n\t\t\tif (ch === '\"' || ch === \"'\") {\n\t\t\t\tthis.readString(ch);\n\t\t\t} else if (\n\t\t\t\tthis.isNumber(ch) ||\n\t\t\t\t(ch === \".\" && this.isNumber(this.peek()))\n\t\t\t) {\n\t\t\t\tthis.readNumber();\n\t\t\t} else if (this.isIdentifierStart(this.peekMultichar())) {\n\t\t\t\tthis.readIdent();\n\t\t\t} else if (this.is(ch, \"(){}[].,;:?\")) {\n\t\t\t\tthis.tokens.push({ index: this.index, text: ch });\n\t\t\t\tthis.index++;\n\t\t\t} else if (this.isWhitespace(ch)) {\n\t\t\t\tthis.index++;\n\t\t\t} else {\n\t\t\t\tvar ch2 = ch + this.peek();\n\t\t\t\tvar ch3 = ch2 + this.peek(2);\n\t\t\t\tvar op1 = OPERATORS[ch];\n\t\t\t\tvar op2 = OPERATORS[ch2];\n\t\t\t\tvar op3 = OPERATORS[ch3];\n\t\t\t\tif (op1 || op2 || op3) {\n\t\t\t\t\tvar token = op3 ? ch3 : op2 ? ch2 : ch;\n\t\t\t\t\tthis.tokens.push({ index: this.index, text: token, operator: true });\n\t\t\t\t\tthis.index += token.length;\n\t\t\t\t} else {\n\t\t\t\t\tthis.throwError(\n\t\t\t\t\t\t\"Unexpected next character \",\n\t\t\t\t\t\tthis.index,\n\t\t\t\t\t\tthis.index + 1\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn this.tokens;\n\t},\n\n\tis: function (ch, chars) {\n\t\treturn chars.indexOf(ch) !== -1;\n\t},\n\n\tpeek: function (i) {\n\t\tvar num = i || 1;\n\t\treturn this.index + num < this.text.length\n\t\t\t? this.text.charAt(this.index + num)\n\t\t\t: false;\n\t},\n\n\tisNumber: function (ch) {\n\t\treturn \"0\" <= ch && ch <= \"9\" && typeof ch === \"string\";\n\t},\n\n\tisWhitespace: function (ch) {\n\t\t// IE treats non-breaking space as \\u00A0\n\t\treturn (\n\t\t\tch === \" \" ||\n\t\t\tch === \"\\r\" ||\n\t\t\tch === \"\\t\" ||\n\t\t\tch === \"\\n\" ||\n\t\t\tch === \"\\v\" ||\n\t\t\tch === \"\\u00A0\"\n\t\t);\n\t},\n\n\tisIdentifierStart: function (ch) {\n\t\treturn this.options.isIdentifierStart\n\t\t\t? this.options.isIdentifierStart(ch, this.codePointAt(ch))\n\t\t\t: this.isValidIdentifierStart(ch);\n\t},\n\n\tisValidIdentifierStart: function (ch) {\n\t\treturn (\n\t\t\t(\"a\" <= ch && ch <= \"z\") ||\n\t\t\t(\"A\" <= ch && ch <= \"Z\") ||\n\t\t\t\"_\" === ch ||\n\t\t\tch === \"$\"\n\t\t);\n\t},\n\n\tisIdentifierContinue: function (ch) {\n\t\treturn this.options.isIdentifierContinue\n\t\t\t? this.options.isIdentifierContinue(ch, this.codePointAt(ch))\n\t\t\t: this.isValidIdentifierContinue(ch);\n\t},\n\n\tisValidIdentifierContinue: function (ch, cp) {\n\t\treturn this.isValidIdentifierStart(ch, cp) || this.isNumber(ch);\n\t},\n\n\tcodePointAt: function (ch) {\n\t\tif (ch.length === 1) return ch.charCodeAt(0);\n\t\t// eslint-disable-next-line no-bitwise\n\t\treturn (ch.charCodeAt(0) << 10) + ch.charCodeAt(1) - 0x35fdc00;\n\t},\n\n\tpeekMultichar: function () {\n\t\tvar ch = this.text.charAt(this.index);\n\t\tvar peek = this.peek();\n\t\tif (!peek) {\n\t\t\treturn ch;\n\t\t}\n\t\tvar cp1 = ch.charCodeAt(0);\n\t\tvar cp2 = peek.charCodeAt(0);\n\t\tif (cp1 >= 0xd800 && cp1 <= 0xdbff && cp2 >= 0xdc00 && cp2 <= 0xdfff) {\n\t\t\treturn ch + peek;\n\t\t}\n\t\treturn ch;\n\t},\n\n\tisExpOperator: function (ch) {\n\t\treturn ch === \"-\" || ch === \"+\" || this.isNumber(ch);\n\t},\n\n\tthrowError: function (error, start, end) {\n\t\tend = end || this.index;\n\t\tvar colStr = isDefined(start)\n\t\t\t? \"s \" +\n\t\t\t\tstart +\n\t\t\t\t\"-\" +\n\t\t\t\tthis.index +\n\t\t\t\t\" [\" +\n\t\t\t\tthis.text.substring(start, end) +\n\t\t\t\t\"]\"\n\t\t\t: \" \" + end;\n\t\tthrow $parseMinErr(\n\t\t\t\"lexerr\",\n\t\t\t\"Lexer Error: {0} at column{1} in expression [{2}].\",\n\t\t\terror,\n\t\t\tcolStr,\n\t\t\tthis.text\n\t\t);\n\t},\n\n\treadNumber: function () {\n\t\tvar number = \"\";\n\t\tvar start = this.index;\n\t\twhile (this.index < this.text.length) {\n\t\t\tvar ch = lowercase(this.text.charAt(this.index));\n\t\t\tif (ch === \".\" || this.isNumber(ch)) {\n\t\t\t\tnumber += ch;\n\t\t\t} else {\n\t\t\t\tvar peekCh = this.peek();\n\t\t\t\tif (ch === \"e\" && this.isExpOperator(peekCh)) {\n\t\t\t\t\tnumber += ch;\n\t\t\t\t} else if (\n\t\t\t\t\tthis.isExpOperator(ch) &&\n\t\t\t\t\tpeekCh &&\n\t\t\t\t\tthis.isNumber(peekCh) &&\n\t\t\t\t\tnumber.charAt(number.length - 1) === \"e\"\n\t\t\t\t) {\n\t\t\t\t\tnumber += ch;\n\t\t\t\t} else if (\n\t\t\t\t\tthis.isExpOperator(ch) &&\n\t\t\t\t\t(!peekCh || !this.isNumber(peekCh)) &&\n\t\t\t\t\tnumber.charAt(number.length - 1) === \"e\"\n\t\t\t\t) {\n\t\t\t\t\tthis.throwError(\"Invalid exponent\");\n\t\t\t\t} else {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.index++;\n\t\t}\n\t\tthis.tokens.push({\n\t\t\tindex: start,\n\t\t\ttext: number,\n\t\t\tconstant: true,\n\t\t\tvalue: Number(number),\n\t\t});\n\t},\n\n\treadIdent: function () {\n\t\tvar start = this.index;\n\t\tthis.index += this.peekMultichar().length;\n\t\twhile (this.index < this.text.length) {\n\t\t\tvar ch = this.peekMultichar();\n\t\t\tif (!this.isIdentifierContinue(ch)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tthis.index += ch.length;\n\t\t}\n\t\tthis.tokens.push({\n\t\t\tindex: start,\n\t\t\ttext: this.text.slice(start, this.index),\n\t\t\tidentifier: true,\n\t\t});\n\t},\n\n\treadString: function (quote) {\n\t\tvar start = this.index;\n\t\tthis.index++;\n\t\tvar string = \"\";\n\t\tvar rawString = quote;\n\t\tvar escape = false;\n\t\twhile (this.index < this.text.length) {\n\t\t\tvar ch = this.text.charAt(this.index);\n\t\t\trawString += ch;\n\t\t\tif (escape) {\n\t\t\t\tif (ch === \"u\") {\n\t\t\t\t\tvar hex = this.text.substring(this.index + 1, this.index + 5);\n\t\t\t\t\tif (!hex.match(/[\\da-f]{4}/i)) {\n\t\t\t\t\t\tthis.throwError(\"Invalid unicode escape [\\\\u\" + hex + \"]\");\n\t\t\t\t\t}\n\t\t\t\t\tthis.index += 4;\n\t\t\t\t\tstring += String.fromCharCode(parseInt(hex, 16));\n\t\t\t\t} else {\n\t\t\t\t\tvar rep = ESCAPE[ch];\n\t\t\t\t\tstring = string + (rep || ch);\n\t\t\t\t}\n\t\t\t\tescape = false;\n\t\t\t} else if (ch === \"\\\\\") {\n\t\t\t\tescape = true;\n\t\t\t} else if (ch === quote) {\n\t\t\t\tthis.index++;\n\t\t\t\tthis.tokens.push({\n\t\t\t\t\tindex: start,\n\t\t\t\t\ttext: rawString,\n\t\t\t\t\tconstant: true,\n\t\t\t\t\tvalue: string,\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\tstring += ch;\n\t\t\t}\n\t\t\tthis.index++;\n\t\t}\n\t\tthis.throwError(\"Unterminated quote\", start);\n\t},\n};\n\nvar AST = function AST(lexer, options) {\n\tthis.lexer = lexer;\n\tthis.options = options;\n};\n\nAST.Program = \"Program\";\nAST.ExpressionStatement = \"ExpressionStatement\";\nAST.AssignmentExpression = \"AssignmentExpression\";\nAST.ConditionalExpression = \"ConditionalExpression\";\nAST.LogicalExpression = \"LogicalExpression\";\nAST.BinaryExpression = \"BinaryExpression\";\nAST.UnaryExpression = \"UnaryExpression\";\nAST.CallExpression = \"CallExpression\";\nAST.MemberExpression = \"MemberExpression\";\nAST.Identifier = \"Identifier\";\nAST.Literal = \"Literal\";\nAST.ArrayExpression = \"ArrayExpression\";\nAST.Property = \"Property\";\nAST.ObjectExpression = \"ObjectExpression\";\nAST.ThisExpression = \"ThisExpression\";\nAST.LocalsExpression = \"LocalsExpression\";\n\n// Internal use only\nAST.NGValueParameter = \"NGValueParameter\";\n\nAST.prototype = {\n\tast: function (text) {\n\t\tthis.text = text;\n\t\tthis.tokens = this.lexer.lex(text);\n\n\t\tvar value = this.program();\n\n\t\tif (this.tokens.length !== 0) {\n\t\t\tthis.throwError(\"is an unexpected token\", this.tokens[0]);\n\t\t}\n\n\t\treturn value;\n\t},\n\n\tprogram: function () {\n\t\tvar body = [];\n\t\twhile (true) {\n\t\t\tif (this.tokens.length > 0 && !this.peek(\"}\", \")\", \";\", \"]\"))\n\t\t\t\tbody.push(this.expressionStatement());\n\t\t\tif (!this.expect(\";\")) {\n\t\t\t\treturn { type: AST.Program, body: body };\n\t\t\t}\n\t\t}\n\t},\n\n\texpressionStatement: function () {\n\t\treturn { type: AST.ExpressionStatement, expression: this.filterChain() };\n\t},\n\n\tfilterChain: function () {\n\t\tvar left = this.expression();\n\t\twhile (this.expect(\"|\")) {\n\t\t\tleft = this.filter(left);\n\t\t}\n\t\treturn left;\n\t},\n\n\texpression: function () {\n\t\treturn this.assignment();\n\t},\n\n\tassignment: function () {\n\t\tvar result = this.ternary();\n\t\tif (this.expect(\"=\")) {\n\t\t\tif (!isAssignable(result)) {\n\t\t\t\tthrow $parseMinErr(\"lval\", \"Trying to assign a value to a non l-value\");\n\t\t\t}\n\n\t\t\tresult = {\n\t\t\t\ttype: AST.AssignmentExpression,\n\t\t\t\tleft: result,\n\t\t\t\tright: this.assignment(),\n\t\t\t\toperator: \"=\",\n\t\t\t};\n\t\t}\n\t\treturn result;\n\t},\n\n\tternary: function () {\n\t\tvar test = this.logicalOR();\n\t\tvar alternate;\n\t\tvar consequent;\n\t\tif (this.expect(\"?\")) {\n\t\t\talternate = this.expression();\n\t\t\tif (this.consume(\":\")) {\n\t\t\t\tconsequent = this.expression();\n\t\t\t\treturn {\n\t\t\t\t\ttype: AST.ConditionalExpression,\n\t\t\t\t\ttest: test,\n\t\t\t\t\talternate: alternate,\n\t\t\t\t\tconsequent: consequent,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn test;\n\t},\n\n\tlogicalOR: function () {\n\t\tvar left = this.logicalAND();\n\t\twhile (this.expect(\"||\")) {\n\t\t\tleft = {\n\t\t\t\ttype: AST.LogicalExpression,\n\t\t\t\toperator: \"||\",\n\t\t\t\tleft: left,\n\t\t\t\tright: this.logicalAND(),\n\t\t\t};\n\t\t}\n\t\treturn left;\n\t},\n\n\tlogicalAND: function () {\n\t\tvar left = this.equality();\n\t\twhile (this.expect(\"&&\")) {\n\t\t\tleft = {\n\t\t\t\ttype: AST.LogicalExpression,\n\t\t\t\toperator: \"&&\",\n\t\t\t\tleft: left,\n\t\t\t\tright: this.equality(),\n\t\t\t};\n\t\t}\n\t\treturn left;\n\t},\n\n\tequality: function () {\n\t\tvar left = this.relational();\n\t\tvar token;\n\t\twhile ((token = this.expect(\"==\", \"!=\", \"===\", \"!==\"))) {\n\t\t\tleft = {\n\t\t\t\ttype: AST.BinaryExpression,\n\t\t\t\toperator: token.text,\n\t\t\t\tleft: left,\n\t\t\t\tright: this.relational(),\n\t\t\t};\n\t\t}\n\t\treturn left;\n\t},\n\n\trelational: function () {\n\t\tvar left = this.additive();\n\t\tvar token;\n\t\twhile ((token = this.expect(\"<\", \">\", \"<=\", \">=\"))) {\n\t\t\tleft = {\n\t\t\t\ttype: AST.BinaryExpression,\n\t\t\t\toperator: token.text,\n\t\t\t\tleft: left,\n\t\t\t\tright: this.additive(),\n\t\t\t};\n\t\t}\n\t\treturn left;\n\t},\n\n\tadditive: function () {\n\t\tvar left = this.multiplicative();\n\t\tvar token;\n\t\twhile ((token = this.expect(\"+\", \"-\"))) {\n\t\t\tleft = {\n\t\t\t\ttype: AST.BinaryExpression,\n\t\t\t\toperator: token.text,\n\t\t\t\tleft: left,\n\t\t\t\tright: this.multiplicative(),\n\t\t\t};\n\t\t}\n\t\treturn left;\n\t},\n\n\tmultiplicative: function () {\n\t\tvar left = this.unary();\n\t\tvar token;\n\t\twhile ((token = this.expect(\"*\", \"/\", \"%\"))) {\n\t\t\tleft = {\n\t\t\t\ttype: AST.BinaryExpression,\n\t\t\t\toperator: token.text,\n\t\t\t\tleft: left,\n\t\t\t\tright: this.unary(),\n\t\t\t};\n\t\t}\n\t\treturn left;\n\t},\n\n\tunary: function () {\n\t\tvar token;\n\t\tif ((token = this.expect(\"+\", \"-\", \"!\"))) {\n\t\t\treturn {\n\t\t\t\ttype: AST.UnaryExpression,\n\t\t\t\toperator: token.text,\n\t\t\t\tprefix: true,\n\t\t\t\targument: this.unary(),\n\t\t\t};\n\t\t} else {\n\t\t\treturn this.primary();\n\t\t}\n\t},\n\n\tprimary: function () {\n\t\tvar primary;\n\t\tif (this.expect(\"(\")) {\n\t\t\tprimary = this.filterChain();\n\t\t\tthis.consume(\")\");\n\t\t} else if (this.expect(\"[\")) {\n\t\t\tprimary = this.arrayDeclaration();\n\t\t} else if (this.expect(\"{\")) {\n\t\t\tprimary = this.object();\n\t\t} else if (this.selfReferential.hasOwnProperty(this.peek().text)) {\n\t\t\tprimary = copy(this.selfReferential[this.consume().text]);\n\t\t} else if (this.options.literals.hasOwnProperty(this.peek().text)) {\n\t\t\tprimary = {\n\t\t\t\ttype: AST.Literal,\n\t\t\t\tvalue: this.options.literals[this.consume().text],\n\t\t\t};\n\t\t} else if (this.peek().identifier) {\n\t\t\tprimary = this.identifier();\n\t\t} else if (this.peek().constant) {\n\t\t\tprimary = this.constant();\n\t\t} else {\n\t\t\tthis.throwError(\"not a primary expression\", this.peek());\n\t\t}\n\n\t\tvar next;\n\t\twhile ((next = this.expect(\"(\", \"[\", \".\"))) {\n\t\t\tif (next.text === \"(\") {\n\t\t\t\tprimary = {\n\t\t\t\t\ttype: AST.CallExpression,\n\t\t\t\t\tcallee: primary,\n\t\t\t\t\targuments: this.parseArguments(),\n\t\t\t\t};\n\t\t\t\tthis.consume(\")\");\n\t\t\t} else if (next.text === \"[\") {\n\t\t\t\tprimary = {\n\t\t\t\t\ttype: AST.MemberExpression,\n\t\t\t\t\tobject: primary,\n\t\t\t\t\tproperty: this.expression(),\n\t\t\t\t\tcomputed: true,\n\t\t\t\t};\n\t\t\t\tthis.consume(\"]\");\n\t\t\t} else if (next.text === \".\") {\n\t\t\t\tprimary = {\n\t\t\t\t\ttype: AST.MemberExpression,\n\t\t\t\t\tobject: primary,\n\t\t\t\t\tproperty: this.identifier(),\n\t\t\t\t\tcomputed: false,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tthis.throwError(\"IMPOSSIBLE\");\n\t\t\t}\n\t\t}\n\t\treturn primary;\n\t},\n\n\tfilter: function (baseExpression) {\n\t\tvar args = [baseExpression];\n\t\tvar result = {\n\t\t\ttype: AST.CallExpression,\n\t\t\tcallee: this.identifier(),\n\t\t\targuments: args,\n\t\t\tfilter: true,\n\t\t};\n\n\t\twhile (this.expect(\":\")) {\n\t\t\targs.push(this.expression());\n\t\t}\n\n\t\treturn result;\n\t},\n\n\tparseArguments: function () {\n\t\tvar args = [];\n\t\tif (this.peekToken().text !== \")\") {\n\t\t\tdo {\n\t\t\t\targs.push(this.filterChain());\n\t\t\t} while (this.expect(\",\"));\n\t\t}\n\t\treturn args;\n\t},\n\n\tidentifier: function () {\n\t\tvar token = this.consume();\n\t\tif (!token.identifier) {\n\t\t\tthis.throwError(\"is not a valid identifier\", token);\n\t\t}\n\t\treturn { type: AST.Identifier, name: token.text };\n\t},\n\n\tconstant: function () {\n\t\t// TODO check that it is a constant\n\t\treturn { type: AST.Literal, value: this.consume().value };\n\t},\n\n\tarrayDeclaration: function () {\n\t\tvar elements = [];\n\t\tif (this.peekToken().text !== \"]\") {\n\t\t\tdo {\n\t\t\t\tif (this.peek(\"]\")) {\n\t\t\t\t\t// Support trailing commas per ES5.1.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telements.push(this.expression());\n\t\t\t} while (this.expect(\",\"));\n\t\t}\n\t\tthis.consume(\"]\");\n\n\t\treturn { type: AST.ArrayExpression, elements: elements };\n\t},\n\n\tobject: function () {\n\t\tvar properties = [],\n\t\t\tproperty;\n\t\tif (this.peekToken().text !== \"}\") {\n\t\t\tdo {\n\t\t\t\tif (this.peek(\"}\")) {\n\t\t\t\t\t// Support trailing commas per ES5.1.\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tproperty = { type: AST.Property, kind: \"init\" };\n\t\t\t\tif (this.peek().constant) {\n\t\t\t\t\tproperty.key = this.constant();\n\t\t\t\t\tproperty.computed = false;\n\t\t\t\t\tthis.consume(\":\");\n\t\t\t\t\tproperty.value = this.expression();\n\t\t\t\t} else if (this.peek().identifier) {\n\t\t\t\t\tproperty.key = this.identifier();\n\t\t\t\t\tproperty.computed = false;\n\t\t\t\t\tif (this.peek(\":\")) {\n\t\t\t\t\t\tthis.consume(\":\");\n\t\t\t\t\t\tproperty.value = this.expression();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tproperty.value = property.key;\n\t\t\t\t\t}\n\t\t\t\t} else if (this.peek(\"[\")) {\n\t\t\t\t\tthis.consume(\"[\");\n\t\t\t\t\tproperty.key = this.expression();\n\t\t\t\t\tthis.consume(\"]\");\n\t\t\t\t\tproperty.computed = true;\n\t\t\t\t\tthis.consume(\":\");\n\t\t\t\t\tproperty.value = this.expression();\n\t\t\t\t} else {\n\t\t\t\t\tthis.throwError(\"invalid key\", this.peek());\n\t\t\t\t}\n\t\t\t\tproperties.push(property);\n\t\t\t} while (this.expect(\",\"));\n\t\t}\n\t\tthis.consume(\"}\");\n\n\t\treturn { type: AST.ObjectExpression, properties: properties };\n\t},\n\n\tthrowError: function (msg, token) {\n\t\tthrow $parseMinErr(\n\t\t\t\"syntax\",\n\t\t\t\"Syntax Error: Token '{0}' {1} at column {2} of the expression [{3}] starting at [{4}].\",\n\t\t\ttoken.text,\n\t\t\tmsg,\n\t\t\ttoken.index + 1,\n\t\t\tthis.text,\n\t\t\tthis.text.substring(token.index)\n\t\t);\n\t},\n\n\tconsume: function (e1) {\n\t\tif (this.tokens.length === 0) {\n\t\t\tthrow $parseMinErr(\n\t\t\t\t\"ueoe\",\n\t\t\t\t\"Unexpected end of expression: {0}\",\n\t\t\t\tthis.text\n\t\t\t);\n\t\t}\n\n\t\tvar token = this.expect(e1);\n\t\tif (!token) {\n\t\t\tthis.throwError(\"is unexpected, expecting [\" + e1 + \"]\", this.peek());\n\t\t}\n\t\treturn token;\n\t},\n\n\tpeekToken: function () {\n\t\tif (this.tokens.length === 0) {\n\t\t\tthrow $parseMinErr(\n\t\t\t\t\"ueoe\",\n\t\t\t\t\"Unexpected end of expression: {0}\",\n\t\t\t\tthis.text\n\t\t\t);\n\t\t}\n\t\treturn this.tokens[0];\n\t},\n\n\tpeek: function (e1, e2, e3, e4) {\n\t\treturn this.peekAhead(0, e1, e2, e3, e4);\n\t},\n\n\tpeekAhead: function (i, e1, e2, e3, e4) {\n\t\tif (this.tokens.length > i) {\n\t\t\tvar token = this.tokens[i];\n\t\t\tvar t = token.text;\n\t\t\tif (\n\t\t\t\tt === e1 ||\n\t\t\t\tt === e2 ||\n\t\t\t\tt === e3 ||\n\t\t\t\tt === e4 ||\n\t\t\t\t(!e1 && !e2 && !e3 && !e4)\n\t\t\t) {\n\t\t\t\treturn token;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t},\n\n\texpect: function (e1, e2, e3, e4) {\n\t\tvar token = this.peek(e1, e2, e3, e4);\n\t\tif (token) {\n\t\t\tthis.tokens.shift();\n\t\t\treturn token;\n\t\t}\n\t\treturn false;\n\t},\n\n\tselfReferential: {\n\t\tthis: { type: AST.ThisExpression },\n\t\t$locals: { type: AST.LocalsExpression },\n\t},\n};\n\nfunction ifDefined(v, d) {\n\treturn typeof v !== \"undefined\" ? v : d;\n}\n\nfunction plusFn(l, r) {\n\tif (typeof l === \"undefined\") return r;\n\tif (typeof r === \"undefined\") return l;\n\treturn l + r;\n}\n\nfunction isStateless($filter, filterName) {\n\tvar fn = $filter(filterName);\n\tif (!fn) {\n\t\tthrow new Error(\"Filter '\" + filterName + \"' is not defined\");\n\t}\n\treturn !fn.$stateful;\n}\n\nfunction findConstantAndWatchExpressions(ast, $filter) {\n\tvar allConstants;\n\tvar argsToWatch;\n\tvar isStatelessFilter;\n\tswitch (ast.type) {\n\t\tcase AST.Program:\n\t\t\tallConstants = true;\n\t\t\tforEach(ast.body, function (expr) {\n\t\t\t\tfindConstantAndWatchExpressions(expr.expression, $filter);\n\t\t\t\tallConstants = allConstants && expr.expression.constant;\n\t\t\t});\n\t\t\tast.constant = allConstants;\n\t\t\tbreak;\n\t\tcase AST.Literal:\n\t\t\tast.constant = true;\n\t\t\tast.toWatch = [];\n\t\t\tbreak;\n\t\tcase AST.UnaryExpression:\n\t\t\tfindConstantAndWatchExpressions(ast.argument, $filter);\n\t\t\tast.constant = ast.argument.constant;\n\t\t\tast.toWatch = ast.argument.toWatch;\n\t\t\tbreak;\n\t\tcase AST.BinaryExpression:\n\t\t\tfindConstantAndWatchExpressions(ast.left, $filter);\n\t\t\tfindConstantAndWatchExpressions(ast.right, $filter);\n\t\t\tast.constant = ast.left.constant && ast.right.constant;\n\t\t\tast.toWatch = ast.left.toWatch.concat(ast.right.toWatch);\n\t\t\tbreak;\n\t\tcase AST.LogicalExpression:\n\t\t\tfindConstantAndWatchExpressions(ast.left, $filter);\n\t\t\tfindConstantAndWatchExpressions(ast.right, $filter);\n\t\t\tast.constant = ast.left.constant && ast.right.constant;\n\t\t\tast.toWatch = ast.constant ? [] : [ast];\n\t\t\tbreak;\n\t\tcase AST.ConditionalExpression:\n\t\t\tfindConstantAndWatchExpressions(ast.test, $filter);\n\t\t\tfindConstantAndWatchExpressions(ast.alternate, $filter);\n\t\t\tfindConstantAndWatchExpressions(ast.consequent, $filter);\n\t\t\tast.constant =\n\t\t\t\tast.test.constant && ast.alternate.constant && ast.consequent.constant;\n\t\t\tast.toWatch = ast.constant ? [] : [ast];\n\t\t\tbreak;\n\t\tcase AST.Identifier:\n\t\t\tast.constant = false;\n\t\t\tast.toWatch = [ast];\n\t\t\tbreak;\n\t\tcase AST.MemberExpression:\n\t\t\tfindConstantAndWatchExpressions(ast.object, $filter);\n\t\t\tif (ast.computed) {\n\t\t\t\tfindConstantAndWatchExpressions(ast.property, $filter);\n\t\t\t}\n\t\t\tast.constant =\n\t\t\t\tast.object.constant && (!ast.computed || ast.property.constant);\n\t\t\tast.toWatch = [ast];\n\t\t\tbreak;\n\t\tcase AST.CallExpression:\n\t\t\tisStatelessFilter = ast.filter\n\t\t\t\t? isStateless($filter, ast.callee.name)\n\t\t\t\t: false;\n\t\t\tallConstants = isStatelessFilter;\n\t\t\targsToWatch = [];\n\t\t\tforEach(ast.arguments, function (expr) {\n\t\t\t\tfindConstantAndWatchExpressions(expr, $filter);\n\t\t\t\tallConstants = allConstants && expr.constant;\n\t\t\t\tif (!expr.constant) {\n\t\t\t\t\targsToWatch.push.apply(argsToWatch, expr.toWatch);\n\t\t\t\t}\n\t\t\t});\n\t\t\tast.constant = allConstants;\n\t\t\tast.toWatch = isStatelessFilter ? argsToWatch : [ast];\n\t\t\tbreak;\n\t\tcase AST.AssignmentExpression:\n\t\t\tfindConstantAndWatchExpressions(ast.left, $filter);\n\t\t\tfindConstantAndWatchExpressions(ast.right, $filter);\n\t\t\tast.constant = ast.left.constant && ast.right.constant;\n\t\t\tast.toWatch = [ast];\n\t\t\tbreak;\n\t\tcase AST.ArrayExpression:\n\t\t\tallConstants = true;\n\t\t\targsToWatch = [];\n\t\t\tforEach(ast.elements, function (expr) {\n\t\t\t\tfindConstantAndWatchExpressions(expr, $filter);\n\t\t\t\tallConstants = allConstants && expr.constant;\n\t\t\t\tif (!expr.constant) {\n\t\t\t\t\targsToWatch.push.apply(argsToWatch, expr.toWatch);\n\t\t\t\t}\n\t\t\t});\n\t\t\tast.constant = allConstants;\n\t\t\tast.toWatch = argsToWatch;\n\t\t\tbreak;\n\t\tcase AST.ObjectExpression:\n\t\t\tallConstants = true;\n\t\t\targsToWatch = [];\n\t\t\tforEach(ast.properties, function (property) {\n\t\t\t\tfindConstantAndWatchExpressions(property.value, $filter);\n\t\t\t\tallConstants =\n\t\t\t\t\tallConstants && property.value.constant && !property.computed;\n\t\t\t\tif (!property.value.constant) {\n\t\t\t\t\targsToWatch.push.apply(argsToWatch, property.value.toWatch);\n\t\t\t\t}\n\t\t\t});\n\t\t\tast.constant = allConstants;\n\t\t\tast.toWatch = argsToWatch;\n\t\t\tbreak;\n\t\tcase AST.ThisExpression:\n\t\t\tast.constant = false;\n\t\t\tast.toWatch = [];\n\t\t\tbreak;\n\t\tcase AST.LocalsExpression:\n\t\t\tast.constant = false;\n\t\t\tast.toWatch = [];\n\t\t\tbreak;\n\t}\n}\n\nfunction getInputs(body) {\n\tif (body.length !== 1) return;\n\tvar lastExpression = body[0].expression;\n\tvar candidate = lastExpression.toWatch;\n\tif (candidate.length !== 1) return candidate;\n\treturn candidate[0] !== lastExpression ? candidate : undefined;\n}\n\nfunction isAssignable(ast) {\n\treturn ast.type === AST.Identifier || ast.type === AST.MemberExpression;\n}\n\nfunction assignableAST(ast) {\n\tif (ast.body.length === 1 && isAssignable(ast.body[0].expression)) {\n\t\treturn {\n\t\t\ttype: AST.AssignmentExpression,\n\t\t\tleft: ast.body[0].expression,\n\t\t\tright: { type: AST.NGValueParameter },\n\t\t\toperator: \"=\",\n\t\t};\n\t}\n}\n\nfunction isLiteral(ast) {\n\treturn (\n\t\tast.body.length === 0 ||\n\t\t(ast.body.length === 1 &&\n\t\t\t(ast.body[0].expression.type === AST.Literal ||\n\t\t\t\tast.body[0].expression.type === AST.ArrayExpression ||\n\t\t\t\tast.body[0].expression.type === AST.ObjectExpression))\n\t);\n}\n\nfunction isConstant(ast) {\n\treturn ast.constant;\n}\n\nfunction ASTCompiler(astBuilder, $filter) {\n\tthis.astBuilder = astBuilder;\n\tthis.$filter = $filter;\n}\n\nASTCompiler.prototype = {\n\tcompile: function (expression) {\n\t\tvar self = this;\n\t\tvar ast = this.astBuilder.ast(expression);\n\t\tthis.state = {\n\t\t\tnextId: 0,\n\t\t\tfilters: {},\n\t\t\tfn: { vars: [], body: [], own: {} },\n\t\t\tassign: { vars: [], body: [], own: {} },\n\t\t\tinputs: [],\n\t\t};\n\t\tfindConstantAndWatchExpressions(ast, self.$filter);\n\t\tvar extra = \"\";\n\t\tvar assignable;\n\t\tthis.stage = \"assign\";\n\t\tif ((assignable = assignableAST(ast))) {\n\t\t\tthis.state.computing = \"assign\";\n\t\t\tvar result = this.nextId();\n\t\t\tthis.recurse(assignable, result);\n\t\t\tthis.return_(result);\n\t\t\textra = \"fn.assign=\" + this.generateFunction(\"assign\", \"s,v,l\");\n\t\t}\n\t\tvar toWatch = getInputs(ast.body);\n\t\tself.stage = \"inputs\";\n\t\tforEach(toWatch, function (watch, key) {\n\t\t\tvar fnKey = \"fn\" + key;\n\t\t\tself.state[fnKey] = { vars: [], body: [], own: {} };\n\t\t\tself.state.computing = fnKey;\n\t\t\tvar intoId = self.nextId();\n\t\t\tself.recurse(watch, intoId);\n\t\t\tself.return_(intoId);\n\t\t\tself.state.inputs.push(fnKey);\n\t\t\twatch.watchId = key;\n\t\t});\n\t\tthis.state.computing = \"fn\";\n\t\tthis.stage = \"main\";\n\t\tthis.recurse(ast);\n\t\tvar fnString =\n\t\t\t// The build and minification steps remove the string \"use strict\" from the code, but this is done using a regex.\n\t\t\t// This is a workaround for this until we do a better job at only removing the prefix only when we should.\n\t\t\t'\"' +\n\t\t\tthis.USE +\n\t\t\t\" \" +\n\t\t\tthis.STRICT +\n\t\t\t'\";\\n' +\n\t\t\tthis.filterPrefix() +\n\t\t\t\"var fn=\" +\n\t\t\tthis.generateFunction(\"fn\", \"s,l,a,i\") +\n\t\t\textra +\n\t\t\tthis.watchFns() +\n\t\t\t\"return fn;\";\n\t\t// eslint-disable-next-line no-new-func\n\t\tvar fn = new Function(\n\t\t\t\"$filter\",\n\t\t\t\"getStringValue\",\n\t\t\t\"ifDefined\",\n\t\t\t\"plus\",\n\t\t\tfnString\n\t\t)(this.$filter, getStringValue, ifDefined, plusFn);\n\n\t\tthis.state = this.stage = undefined;\n\t\tfn.ast = ast;\n\t\tfn.literal = isLiteral(ast);\n\t\tfn.constant = isConstant(ast);\n\t\treturn fn;\n\t},\n\n\tUSE: \"use\",\n\n\tSTRICT: \"strict\",\n\n\twatchFns: function () {\n\t\tvar result = [];\n\t\tvar fns = this.state.inputs;\n\t\tvar self = this;\n\t\tforEach(fns, function (name) {\n\t\t\tresult.push(\"var \" + name + \"=\" + self.generateFunction(name, \"s\"));\n\t\t});\n\t\tif (fns.length) {\n\t\t\tresult.push(\"fn.inputs=[\" + fns.join(\",\") + \"];\");\n\t\t}\n\t\treturn result.join(\"\");\n\t},\n\n\tgenerateFunction: function (name, params) {\n\t\treturn (\n\t\t\t\"function(\" +\n\t\t\tparams +\n\t\t\t\"){\" +\n\t\t\tthis.varsPrefix(name) +\n\t\t\tthis.body(name) +\n\t\t\t\"};\"\n\t\t);\n\t},\n\n\tfilterPrefix: function () {\n\t\tvar parts = [];\n\t\tvar self = this;\n\t\tforEach(this.state.filters, function (id, filter) {\n\t\t\tparts.push(id + \"=$filter(\" + self.escape(filter) + \")\");\n\t\t});\n\t\tif (parts.length) return \"var \" + parts.join(\",\") + \";\";\n\t\treturn \"\";\n\t},\n\n\tvarsPrefix: function (section) {\n\t\treturn this.state[section].vars.length\n\t\t\t? \"var \" + this.state[section].vars.join(\",\") + \";\"\n\t\t\t: \"\";\n\t},\n\n\tbody: function (section) {\n\t\treturn this.state[section].body.join(\"\");\n\t},\n\n\trecurse: function (\n\t\tast,\n\t\tintoId,\n\t\tnameId,\n\t\trecursionFn,\n\t\tcreate,\n\t\tskipWatchIdCheck\n\t) {\n\t\tvar left,\n\t\t\tright,\n\t\t\tself = this,\n\t\t\targs,\n\t\t\texpression,\n\t\t\tcomputed;\n\t\trecursionFn = recursionFn || noop;\n\t\tif (!skipWatchIdCheck && isDefined(ast.watchId)) {\n\t\t\tintoId = intoId || this.nextId();\n\t\t\tthis.if_(\n\t\t\t\t\"i\",\n\t\t\t\tthis.lazyAssign(intoId, this.unsafeComputedMember(\"i\", ast.watchId)),\n\t\t\t\tthis.lazyRecurse(ast, intoId, nameId, recursionFn, create, true)\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tswitch (ast.type) {\n\t\t\tcase AST.Program:\n\t\t\t\tforEach(ast.body, function (expression, pos) {\n\t\t\t\t\tself.recurse(\n\t\t\t\t\t\texpression.expression,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tfunction (expr) {\n\t\t\t\t\t\t\tright = expr;\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tif (pos !== ast.body.length - 1) {\n\t\t\t\t\t\tself.current().body.push(right, \";\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tself.return_(right);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase AST.Literal:\n\t\t\t\texpression = this.escape(ast.value);\n\t\t\t\tthis.assign(intoId, expression);\n\t\t\t\trecursionFn(intoId || expression);\n\t\t\t\tbreak;\n\t\t\tcase AST.UnaryExpression:\n\t\t\t\tthis.recurse(ast.argument, undefined, undefined, function (expr) {\n\t\t\t\t\tright = expr;\n\t\t\t\t});\n\t\t\t\texpression = ast.operator + \"(\" + this.ifDefined(right, 0) + \")\";\n\t\t\t\tthis.assign(intoId, expression);\n\t\t\t\trecursionFn(expression);\n\t\t\t\tbreak;\n\t\t\tcase AST.BinaryExpression:\n\t\t\t\tthis.recurse(ast.left, undefined, undefined, function (expr) {\n\t\t\t\t\tleft = expr;\n\t\t\t\t});\n\t\t\t\tthis.recurse(ast.right, undefined, undefined, function (expr) {\n\t\t\t\t\tright = expr;\n\t\t\t\t});\n\t\t\t\tif (ast.operator === \"+\") {\n\t\t\t\t\texpression = this.plus(left, right);\n\t\t\t\t} else if (ast.operator === \"-\") {\n\t\t\t\t\texpression =\n\t\t\t\t\t\tthis.ifDefined(left, 0) + ast.operator + this.ifDefined(right, 0);\n\t\t\t\t} else {\n\t\t\t\t\texpression = \"(\" + left + \")\" + ast.operator + \"(\" + right + \")\";\n\t\t\t\t}\n\t\t\t\tthis.assign(intoId, expression);\n\t\t\t\trecursionFn(expression);\n\t\t\t\tbreak;\n\t\t\tcase AST.LogicalExpression:\n\t\t\t\tintoId = intoId || this.nextId();\n\t\t\t\tself.recurse(ast.left, intoId);\n\t\t\t\tself.if_(\n\t\t\t\t\tast.operator === \"&&\" ? intoId : self.not(intoId),\n\t\t\t\t\tself.lazyRecurse(ast.right, intoId)\n\t\t\t\t);\n\t\t\t\trecursionFn(intoId);\n\t\t\t\tbreak;\n\t\t\tcase AST.ConditionalExpression:\n\t\t\t\tintoId = intoId || this.nextId();\n\t\t\t\tself.recurse(ast.test, intoId);\n\t\t\t\tself.if_(\n\t\t\t\t\tintoId,\n\t\t\t\t\tself.lazyRecurse(ast.alternate, intoId),\n\t\t\t\t\tself.lazyRecurse(ast.consequent, intoId)\n\t\t\t\t);\n\t\t\t\trecursionFn(intoId);\n\t\t\t\tbreak;\n\t\t\tcase AST.Identifier:\n\t\t\t\tintoId = intoId || this.nextId();\n\t\t\t\tvar inAssignment = self.current().inAssignment;\n\t\t\t\tif (nameId) {\n\t\t\t\t\tif (inAssignment) {\n\t\t\t\t\t\tnameId.context = this.assign(this.nextId(), \"s\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnameId.context =\n\t\t\t\t\t\t\tself.stage === \"inputs\"\n\t\t\t\t\t\t\t\t? \"s\"\n\t\t\t\t\t\t\t\t: this.assign(\n\t\t\t\t\t\t\t\t\t\tthis.nextId(),\n\t\t\t\t\t\t\t\t\t\tthis.getHasOwnProperty(\"l\", ast.name) + \"?l:s\"\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tnameId.computed = false;\n\t\t\t\t\tnameId.name = ast.name;\n\t\t\t\t}\n\t\t\t\tself.if_(\n\t\t\t\t\tself.stage === \"inputs\" ||\n\t\t\t\t\t\tself.not(self.getHasOwnProperty(\"l\", ast.name)),\n\t\t\t\t\tfunction () {\n\t\t\t\t\t\tself.if_(\n\t\t\t\t\t\t\tself.stage === \"inputs\" ||\n\t\t\t\t\t\t\t\tself.and_(\n\t\t\t\t\t\t\t\t\t\"s\",\n\t\t\t\t\t\t\t\t\tself.or_(\n\t\t\t\t\t\t\t\t\t\tself.isNull(self.nonComputedMember(\"s\", ast.name)),\n\t\t\t\t\t\t\t\t\t\tself.hasOwnProperty_(\"s\", ast.name)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfunction () {\n\t\t\t\t\t\t\t\tif (create && create !== 1) {\n\t\t\t\t\t\t\t\t\tself.if_(\n\t\t\t\t\t\t\t\t\t\tself.isNull(self.nonComputedMember(\"s\", ast.name)),\n\t\t\t\t\t\t\t\t\t\tself.lazyAssign(self.nonComputedMember(\"s\", ast.name), \"{}\")\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tself.assign(intoId, self.nonComputedMember(\"s\", ast.name));\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\tintoId &&\n\t\t\t\t\t\tself.lazyAssign(intoId, self.nonComputedMember(\"l\", ast.name))\n\t\t\t\t);\n\t\t\t\trecursionFn(intoId);\n\t\t\t\tbreak;\n\t\t\tcase AST.MemberExpression:\n\t\t\t\tleft = (nameId && (nameId.context = this.nextId())) || this.nextId();\n\t\t\t\tintoId = intoId || this.nextId();\n\t\t\t\tself.recurse(\n\t\t\t\t\tast.object,\n\t\t\t\t\tleft,\n\t\t\t\t\tundefined,\n\t\t\t\t\tfunction () {\n\t\t\t\t\t\tvar member = null;\n\t\t\t\t\t\tvar inAssignment = self.current().inAssignment;\n\t\t\t\t\t\tif (ast.computed) {\n\t\t\t\t\t\t\tright = self.nextId();\n\t\t\t\t\t\t\tif (inAssignment || self.state.computing === \"assign\") {\n\t\t\t\t\t\t\t\tmember = self.unsafeComputedMember(left, right);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmember = self.computedMember(left, right);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (inAssignment || self.state.computing === \"assign\") {\n\t\t\t\t\t\t\t\tmember = self.unsafeNonComputedMember(left, ast.property.name);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tmember = self.nonComputedMember(left, ast.property.name);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tright = ast.property.name;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (ast.computed) {\n\t\t\t\t\t\t\tif (ast.property.type === AST.Literal) {\n\t\t\t\t\t\t\t\tself.recurse(ast.property, right);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tself.if_(\n\t\t\t\t\t\t\tself.and_(\n\t\t\t\t\t\t\t\tself.notNull(left),\n\t\t\t\t\t\t\t\tself.or_(\n\t\t\t\t\t\t\t\t\tself.isNull(member),\n\t\t\t\t\t\t\t\t\tself.hasOwnProperty_(left, right, ast.computed)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfunction () {\n\t\t\t\t\t\t\t\tif (ast.computed) {\n\t\t\t\t\t\t\t\t\tif (ast.property.type !== AST.Literal) {\n\t\t\t\t\t\t\t\t\t\tself.recurse(ast.property, right);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif (create && create !== 1) {\n\t\t\t\t\t\t\t\t\t\tself.if_(self.not(member), self.lazyAssign(member, \"{}\"));\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tself.assign(intoId, member);\n\t\t\t\t\t\t\t\t\tif (nameId) {\n\t\t\t\t\t\t\t\t\t\tnameId.computed = true;\n\t\t\t\t\t\t\t\t\t\tnameId.name = right;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tif (create && create !== 1) {\n\t\t\t\t\t\t\t\t\t\tself.if_(\n\t\t\t\t\t\t\t\t\t\t\tself.isNull(member),\n\t\t\t\t\t\t\t\t\t\t\tself.lazyAssign(member, \"{}\")\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tself.assign(intoId, member);\n\t\t\t\t\t\t\t\t\tif (nameId) {\n\t\t\t\t\t\t\t\t\t\tnameId.computed = false;\n\t\t\t\t\t\t\t\t\t\tnameId.name = ast.property.name;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfunction () {\n\t\t\t\t\t\t\t\tself.assign(intoId, \"undefined\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t\trecursionFn(intoId);\n\t\t\t\t\t},\n\t\t\t\t\t!!create\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase AST.CallExpression:\n\t\t\t\tintoId = intoId || this.nextId();\n\t\t\t\tif (ast.filter) {\n\t\t\t\t\tright = self.filter(ast.callee.name);\n\t\t\t\t\targs = [];\n\t\t\t\t\tforEach(ast.arguments, function (expr) {\n\t\t\t\t\t\tvar argument = self.nextId();\n\t\t\t\t\t\tself.recurse(expr, argument);\n\t\t\t\t\t\targs.push(argument);\n\t\t\t\t\t});\n\t\t\t\t\texpression = right + \".call(\" + right + \",\" + args.join(\",\") + \")\";\n\t\t\t\t\tself.assign(intoId, expression);\n\t\t\t\t\trecursionFn(intoId);\n\t\t\t\t} else {\n\t\t\t\t\tright = self.nextId();\n\t\t\t\t\tleft = {};\n\t\t\t\t\targs = [];\n\t\t\t\t\tself.recurse(ast.callee, right, left, function () {\n\t\t\t\t\t\tself.if_(\n\t\t\t\t\t\t\tself.notNull(right),\n\t\t\t\t\t\t\tfunction () {\n\t\t\t\t\t\t\t\tforEach(ast.arguments, function (expr) {\n\t\t\t\t\t\t\t\t\tself.recurse(\n\t\t\t\t\t\t\t\t\t\texpr,\n\t\t\t\t\t\t\t\t\t\tast.constant ? undefined : self.nextId(),\n\t\t\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\t\tfunction (argument) {\n\t\t\t\t\t\t\t\t\t\t\targs.push(argument);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tif (left.name) {\n\t\t\t\t\t\t\t\t\tvar x = self.member(left.context, left.name, left.computed);\n\t\t\t\t\t\t\t\t\texpression =\n\t\t\t\t\t\t\t\t\t\t\"(\" +\n\t\t\t\t\t\t\t\t\t\tx +\n\t\t\t\t\t\t\t\t\t\t\" === null ? null : \" +\n\t\t\t\t\t\t\t\t\t\tself.unsafeMember(left.context, left.name, left.computed) +\n\t\t\t\t\t\t\t\t\t\t\".call(\" +\n\t\t\t\t\t\t\t\t\t\t[left.context].concat(args).join(\",\") +\n\t\t\t\t\t\t\t\t\t\t\"))\";\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\texpression = right + \"(\" + args.join(\",\") + \")\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tself.assign(intoId, expression);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tfunction () {\n\t\t\t\t\t\t\t\tself.assign(intoId, \"undefined\");\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t\trecursionFn(intoId);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase AST.AssignmentExpression:\n\t\t\t\tright = this.nextId();\n\t\t\t\tleft = {};\n\t\t\t\tself.current().inAssignment = true;\n\t\t\t\tthis.recurse(\n\t\t\t\t\tast.left,\n\t\t\t\t\tundefined,\n\t\t\t\t\tleft,\n\t\t\t\t\tfunction () {\n\t\t\t\t\t\tself.if_(\n\t\t\t\t\t\t\tself.and_(\n\t\t\t\t\t\t\t\tself.notNull(left.context),\n\t\t\t\t\t\t\t\tself.or_(\n\t\t\t\t\t\t\t\t\tself.hasOwnProperty_(left.context, left.name),\n\t\t\t\t\t\t\t\t\tself.isNull(\n\t\t\t\t\t\t\t\t\t\tself.member(left.context, left.name, left.computed)\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfunction () {\n\t\t\t\t\t\t\t\tself.recurse(ast.right, right);\n\t\t\t\t\t\t\t\texpression =\n\t\t\t\t\t\t\t\t\tself.member(left.context, left.name, left.computed) +\n\t\t\t\t\t\t\t\t\tast.operator +\n\t\t\t\t\t\t\t\t\tright;\n\t\t\t\t\t\t\t\tself.assign(intoId, expression);\n\t\t\t\t\t\t\t\trecursionFn(intoId || expression);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t\tself.current().inAssignment = false;\n\t\t\t\t\t\tself.recurse(ast.right, right);\n\t\t\t\t\t\tself.current().inAssignment = true;\n\t\t\t\t\t},\n\t\t\t\t\t1\n\t\t\t\t);\n\t\t\t\tself.current().inAssignment = false;\n\t\t\t\tbreak;\n\t\t\tcase AST.ArrayExpression:\n\t\t\t\targs = [];\n\t\t\t\tforEach(ast.elements, function (expr) {\n\t\t\t\t\tself.recurse(\n\t\t\t\t\t\texpr,\n\t\t\t\t\t\tast.constant ? undefined : self.nextId(),\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tfunction (argument) {\n\t\t\t\t\t\t\targs.push(argument);\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\texpression = \"[\" + args.join(\",\") + \"]\";\n\t\t\t\tthis.assign(intoId, expression);\n\t\t\t\trecursionFn(intoId || expression);\n\t\t\t\tbreak;\n\t\t\tcase AST.ObjectExpression:\n\t\t\t\targs = [];\n\t\t\t\tcomputed = false;\n\t\t\t\tforEach(ast.properties, function (property) {\n\t\t\t\t\tif (property.computed) {\n\t\t\t\t\t\tcomputed = true;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tif (computed) {\n\t\t\t\t\tintoId = intoId || this.nextId();\n\t\t\t\t\tthis.assign(intoId, \"{}\");\n\t\t\t\t\tforEach(ast.properties, function (property) {\n\t\t\t\t\t\tif (property.computed) {\n\t\t\t\t\t\t\tleft = self.nextId();\n\t\t\t\t\t\t\tself.recurse(property.key, left);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tleft =\n\t\t\t\t\t\t\t\tproperty.key.type === AST.Identifier\n\t\t\t\t\t\t\t\t\t? property.key.name\n\t\t\t\t\t\t\t\t\t: \"\" + property.key.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tright = self.nextId();\n\t\t\t\t\t\tself.recurse(property.value, right);\n\t\t\t\t\t\tself.assign(\n\t\t\t\t\t\t\tself.unsafeMember(intoId, left, property.computed),\n\t\t\t\t\t\t\tright\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tforEach(ast.properties, function (property) {\n\t\t\t\t\t\tself.recurse(\n\t\t\t\t\t\t\tproperty.value,\n\t\t\t\t\t\t\tast.constant ? undefined : self.nextId(),\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\tfunction (expr) {\n\t\t\t\t\t\t\t\targs.push(\n\t\t\t\t\t\t\t\t\tself.escape(\n\t\t\t\t\t\t\t\t\t\tproperty.key.type === AST.Identifier\n\t\t\t\t\t\t\t\t\t\t\t? property.key.name\n\t\t\t\t\t\t\t\t\t\t\t: \"\" + property.key.value\n\t\t\t\t\t\t\t\t\t) +\n\t\t\t\t\t\t\t\t\t\t\":\" +\n\t\t\t\t\t\t\t\t\t\texpr\n\t\t\t\t\t\t\t\t);\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\texpression = \"{\" + args.join(\",\") + \"}\";\n\t\t\t\t\tthis.assign(intoId, expression);\n\t\t\t\t}\n\t\t\t\trecursionFn(intoId || expression);\n\t\t\t\tbreak;\n\t\t\tcase AST.ThisExpression:\n\t\t\t\tthis.assign(intoId, \"s\");\n\t\t\t\trecursionFn(intoId || \"s\");\n\t\t\t\tbreak;\n\t\t\tcase AST.LocalsExpression:\n\t\t\t\tthis.assign(intoId, \"l\");\n\t\t\t\trecursionFn(intoId || \"l\");\n\t\t\t\tbreak;\n\t\t\tcase AST.NGValueParameter:\n\t\t\t\tthis.assign(intoId, \"v\");\n\t\t\t\trecursionFn(intoId || \"v\");\n\t\t\t\tbreak;\n\t\t}\n\t},\n\n\tgetHasOwnProperty: function (element, property) {\n\t\tvar key = element + \".\" + property;\n\t\tvar own = this.current().own;\n\t\tif (!own.hasOwnProperty(key)) {\n\t\t\town[key] = this.nextId(\n\t\t\t\tfalse,\n\t\t\t\telement + \"&&(\" + this.escape(property) + \" in \" + element + \")\"\n\t\t\t);\n\t\t}\n\t\treturn own[key];\n\t},\n\n\tassign: function (id, value) {\n\t\tif (!id) return;\n\t\tthis.current().body.push(id, \"=\", value, \";\");\n\t\treturn id;\n\t},\n\n\tfilter: function (filterName) {\n\t\tif (!this.state.filters.hasOwnProperty(filterName)) {\n\t\t\tthis.state.filters[filterName] = this.nextId(true);\n\t\t}\n\t\treturn this.state.filters[filterName];\n\t},\n\n\tifDefined: function (id, defaultValue) {\n\t\treturn \"ifDefined(\" + id + \",\" + this.escape(defaultValue) + \")\";\n\t},\n\n\tplus: function (left, right) {\n\t\treturn \"plus(\" + left + \",\" + right + \")\";\n\t},\n\n\treturn_: function (id) {\n\t\tthis.current().body.push(\"return \", id, \";\");\n\t},\n\n\tif_: function (test, alternate, consequent) {\n\t\tif (test === true) {\n\t\t\talternate();\n\t\t} else {\n\t\t\tvar body = this.current().body;\n\t\t\tbody.push(\"if(\", test, \"){\");\n\t\t\talternate();\n\t\t\tbody.push(\"}\");\n\t\t\tif (consequent) {\n\t\t\t\tbody.push(\"else{\");\n\t\t\t\tconsequent();\n\t\t\t\tbody.push(\"}\");\n\t\t\t}\n\t\t}\n\t},\n\tor_: function (expr1, expr2) {\n\t\treturn \"(\" + expr1 + \") || (\" + expr2 + \")\";\n\t},\n\thasOwnProperty_: function (obj, prop, computed) {\n\t\tif (computed) {\n\t\t\treturn \"(Object.prototype.hasOwnProperty.call(\" + obj + \",\" + prop + \"))\";\n\t\t} else {\n\t\t\treturn (\n\t\t\t\t\"(Object.prototype.hasOwnProperty.call(\" + obj + \",'\" + prop + \"'))\"\n\t\t\t);\n\t\t}\n\t},\n\tand_: function (expr1, expr2) {\n\t\treturn \"(\" + expr1 + \") && (\" + expr2 + \")\";\n\t},\n\tnot: function (expression) {\n\t\treturn \"!(\" + expression + \")\";\n\t},\n\n\tisNull: function (expression) {\n\t\treturn expression + \"==null\";\n\t},\n\n\tnotNull: function (expression) {\n\t\treturn expression + \"!=null\";\n\t},\n\n\tnonComputedMember: function (left, right) {\n\t\tvar SAFE_IDENTIFIER = /^[$_a-zA-Z][$_a-zA-Z0-9]*$/;\n\t\tvar UNSAFE_CHARACTERS = /[^$_a-zA-Z0-9]/g;\n\t\tvar expr = \"\";\n\t\tif (SAFE_IDENTIFIER.test(right)) {\n\t\t\texpr = left + \".\" + right;\n\t\t} else {\n\t\t\tright = right.replace(UNSAFE_CHARACTERS, this.stringEscapeFn);\n\t\t\texpr = left + '[\"' + right + '\"]';\n\t\t}\n\n\t\treturn expr;\n\t},\n\n\tunsafeComputedMember: function (left, right) {\n\t\treturn left + \"[\" + right + \"]\";\n\t},\n\tunsafeNonComputedMember: function (left, right) {\n\t\treturn this.nonComputedMember(left, right);\n\t},\n\n\tcomputedMember: function (left, right) {\n\t\tif (this.state.computing === \"assign\") {\n\t\t\treturn this.unsafeComputedMember(left, right);\n\t\t}\n\t\t// return left + \"[\" + right + \"]\";\n\t\treturn (\n\t\t\t\"(\" +\n\t\t\tleft +\n\t\t\t\".hasOwnProperty(\" +\n\t\t\tright +\n\t\t\t\") ? \" +\n\t\t\tleft +\n\t\t\t\"[\" +\n\t\t\tright +\n\t\t\t\"] : null)\"\n\t\t);\n\t},\n\n\tunsafeMember: function (left, right, computed) {\n\t\tif (computed) return this.unsafeComputedMember(left, right);\n\t\treturn this.unsafeNonComputedMember(left, right);\n\t},\n\n\tmember: function (left, right, computed) {\n\t\tif (computed) return this.computedMember(left, right);\n\t\treturn this.nonComputedMember(left, right);\n\t},\n\n\tgetStringValue: function (item) {\n\t\tthis.assign(item, \"getStringValue(\" + item + \")\");\n\t},\n\n\tlazyRecurse: function (\n\t\tast,\n\t\tintoId,\n\t\tnameId,\n\t\trecursionFn,\n\t\tcreate,\n\t\tskipWatchIdCheck\n\t) {\n\t\tvar self = this;\n\t\treturn function () {\n\t\t\tself.recurse(ast, intoId, nameId, recursionFn, create, skipWatchIdCheck);\n\t\t};\n\t},\n\n\tlazyAssign: function (id, value) {\n\t\tvar self = this;\n\t\treturn function () {\n\t\t\tself.assign(id, value);\n\t\t};\n\t},\n\n\tstringEscapeRegex: /[^ a-zA-Z0-9]/g,\n\n\tstringEscapeFn: function (c) {\n\t\treturn \"\\\\u\" + (\"0000\" + c.charCodeAt(0).toString(16)).slice(-4);\n\t},\n\n\tescape: function (value) {\n\t\tif (isString(value))\n\t\t\treturn (\n\t\t\t\t\"'\" + value.replace(this.stringEscapeRegex, this.stringEscapeFn) + \"'\"\n\t\t\t);\n\t\tif (isNumber(value)) return value.toString();\n\t\tif (value === true) return \"true\";\n\t\tif (value === false) return \"false\";\n\t\tif (value === null) return \"null\";\n\t\tif (typeof value === \"undefined\") return \"undefined\";\n\n\t\tthrow $parseMinErr(\"esc\", \"IMPOSSIBLE\");\n\t},\n\n\tnextId: function (skip, init) {\n\t\tvar id = \"v\" + this.state.nextId++;\n\t\tif (!skip) {\n\t\t\tthis.current().vars.push(id + (init ? \"=\" + init : \"\"));\n\t\t}\n\t\treturn id;\n\t},\n\n\tcurrent: function () {\n\t\treturn this.state[this.state.computing];\n\t},\n};\n\nfunction ASTInterpreter(astBuilder, $filter) {\n\tthis.astBuilder = astBuilder;\n\tthis.$filter = $filter;\n}\n\nASTInterpreter.prototype = {\n\tcompile: function (expression) {\n\t\tvar self = this;\n\t\tvar ast = this.astBuilder.ast(expression);\n\t\tfindConstantAndWatchExpressions(ast, self.$filter);\n\t\tvar assignable;\n\t\tvar assign;\n\t\tif ((assignable = assignableAST(ast))) {\n\t\t\tassign = this.recurse(assignable);\n\t\t}\n\t\tvar toWatch = getInputs(ast.body);\n\t\tvar inputs;\n\t\tif (toWatch) {\n\t\t\tinputs = [];\n\t\t\tforEach(toWatch, function (watch, key) {\n\t\t\t\tvar input = self.recurse(watch);\n\t\t\t\twatch.input = input;\n\t\t\t\tinputs.push(input);\n\t\t\t\twatch.watchId = key;\n\t\t\t});\n\t\t}\n\t\tvar expressions = [];\n\t\tforEach(ast.body, function (expression) {\n\t\t\texpressions.push(self.recurse(expression.expression));\n\t\t});\n\t\tvar fn =\n\t\t\tast.body.length === 0\n\t\t\t\t? noop\n\t\t\t\t: ast.body.length === 1\n\t\t\t\t\t? expressions[0]\n\t\t\t\t\t: function (scope, locals) {\n\t\t\t\t\t\t\tvar lastValue;\n\t\t\t\t\t\t\tforEach(expressions, function (exp) {\n\t\t\t\t\t\t\t\tlastValue = exp(scope, locals);\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treturn lastValue;\n\t\t\t\t\t\t};\n\n\t\tif (assign) {\n\t\t\tfn.assign = function (scope, value, locals) {\n\t\t\t\treturn assign(scope, locals, value);\n\t\t\t};\n\t\t}\n\t\tif (inputs) {\n\t\t\tfn.inputs = inputs;\n\t\t}\n\t\tfn.ast = ast;\n\t\tfn.literal = isLiteral(ast);\n\t\tfn.constant = isConstant(ast);\n\t\treturn fn;\n\t},\n\n\trecurse: function (ast, context, create) {\n\t\tvar left,\n\t\t\tright,\n\t\t\tself = this,\n\t\t\targs;\n\t\tif (ast.input) {\n\t\t\treturn this.inputs(ast.input, ast.watchId);\n\t\t}\n\t\tswitch (ast.type) {\n\t\t\tcase AST.Literal:\n\t\t\t\treturn this.value(ast.value, context);\n\t\t\tcase AST.UnaryExpression:\n\t\t\t\tright = this.recurse(ast.argument);\n\t\t\t\treturn this[\"unary\" + ast.operator](right, context);\n\t\t\tcase AST.BinaryExpression:\n\t\t\t\tleft = this.recurse(ast.left);\n\t\t\t\tright = this.recurse(ast.right);\n\t\t\t\treturn this[\"binary\" + ast.operator](left, right, context);\n\t\t\tcase AST.LogicalExpression:\n\t\t\t\tleft = this.recurse(ast.left);\n\t\t\t\tright = this.recurse(ast.right);\n\t\t\t\treturn this[\"binary\" + ast.operator](left, right, context);\n\t\t\tcase AST.ConditionalExpression:\n\t\t\t\treturn this[\"ternary?:\"](\n\t\t\t\t\tthis.recurse(ast.test),\n\t\t\t\t\tthis.recurse(ast.alternate),\n\t\t\t\t\tthis.recurse(ast.consequent),\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\tcase AST.Identifier:\n\t\t\t\treturn self.identifier(ast.name, context, create);\n\t\t\tcase AST.MemberExpression:\n\t\t\t\tleft = this.recurse(ast.object, false, !!create);\n\t\t\t\tif (!ast.computed) {\n\t\t\t\t\tright = ast.property.name;\n\t\t\t\t}\n\t\t\t\tif (ast.computed) right = this.recurse(ast.property);\n\n\t\t\t\treturn ast.computed\n\t\t\t\t\t? this.computedMember(left, right, context, create)\n\t\t\t\t\t: this.nonComputedMember(left, right, context, create);\n\t\t\tcase AST.CallExpression:\n\t\t\t\targs = [];\n\t\t\t\tforEach(ast.arguments, function (expr) {\n\t\t\t\t\targs.push(self.recurse(expr));\n\t\t\t\t});\n\t\t\t\tif (ast.filter) right = this.$filter(ast.callee.name);\n\t\t\t\tif (!ast.filter) right = this.recurse(ast.callee, true);\n\t\t\t\treturn ast.filter\n\t\t\t\t\t? function (scope, locals, assign, inputs) {\n\t\t\t\t\t\t\tvar values = [];\n\t\t\t\t\t\t\tfor (var i = 0; i < args.length; ++i) {\n\t\t\t\t\t\t\t\tvalues.push(args[i](scope, locals, assign, inputs));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvar value = right.apply(undefined, values, inputs);\n\t\t\t\t\t\t\treturn context\n\t\t\t\t\t\t\t\t? { context: undefined, name: undefined, value: value }\n\t\t\t\t\t\t\t\t: value;\n\t\t\t\t\t\t}\n\t\t\t\t\t: function (scope, locals, assign, inputs) {\n\t\t\t\t\t\t\tvar rhs = right(scope, locals, assign, inputs);\n\t\t\t\t\t\t\tvar value;\n\t\t\t\t\t\t\tif (rhs.value != null) {\n\t\t\t\t\t\t\t\tvar values = [];\n\t\t\t\t\t\t\t\tfor (var i = 0; i < args.length; ++i) {\n\t\t\t\t\t\t\t\t\tvalues.push(args[i](scope, locals, assign, inputs));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tvalue = rhs.value.apply(rhs.context, values);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn context ? { value: value } : value;\n\t\t\t\t\t\t};\n\t\t\tcase AST.AssignmentExpression:\n\t\t\t\tleft = this.recurse(ast.left, true, 1);\n\t\t\t\tright = this.recurse(ast.right);\n\t\t\t\treturn function (scope, locals, assign, inputs) {\n\t\t\t\t\tvar lhs = left(scope, false, assign, inputs);\n\t\t\t\t\tvar rhs = right(scope, locals, assign, inputs);\n\t\t\t\t\tlhs.context[lhs.name] = rhs;\n\t\t\t\t\treturn context ? { value: rhs } : rhs;\n\t\t\t\t};\n\t\t\tcase AST.ArrayExpression:\n\t\t\t\targs = [];\n\t\t\t\tforEach(ast.elements, function (expr) {\n\t\t\t\t\targs.push(self.recurse(expr));\n\t\t\t\t});\n\t\t\t\treturn function (scope, locals, assign, inputs) {\n\t\t\t\t\tvar value = [];\n\t\t\t\t\tfor (var i = 0; i < args.length; ++i) {\n\t\t\t\t\t\tvalue.push(args[i](scope, locals, assign, inputs));\n\t\t\t\t\t}\n\t\t\t\t\treturn context ? { value: value } : value;\n\t\t\t\t};\n\t\t\tcase AST.ObjectExpression:\n\t\t\t\targs = [];\n\t\t\t\tforEach(ast.properties, function (property) {\n\t\t\t\t\tif (property.computed) {\n\t\t\t\t\t\targs.push({\n\t\t\t\t\t\t\tkey: self.recurse(property.key),\n\t\t\t\t\t\t\tcomputed: true,\n\t\t\t\t\t\t\tvalue: self.recurse(property.value),\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\targs.push({\n\t\t\t\t\t\t\tkey:\n\t\t\t\t\t\t\t\tproperty.key.type === AST.Identifier\n\t\t\t\t\t\t\t\t\t? property.key.name\n\t\t\t\t\t\t\t\t\t: \"\" + property.key.value,\n\t\t\t\t\t\t\tcomputed: false,\n\t\t\t\t\t\t\tvalue: self.recurse(property.value),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn function (scope, locals, assign, inputs) {\n\t\t\t\t\tvar value = {};\n\t\t\t\t\tfor (var i = 0; i < args.length; ++i) {\n\t\t\t\t\t\tif (args[i].computed) {\n\t\t\t\t\t\t\tvalue[args[i].key(scope, locals, assign, inputs)] = args[i].value(\n\t\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\t\tlocals,\n\t\t\t\t\t\t\t\tassign,\n\t\t\t\t\t\t\t\tinputs\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tvalue[args[i].key] = args[i].value(scope, locals, assign, inputs);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn context ? { value: value } : value;\n\t\t\t\t};\n\t\t\tcase AST.ThisExpression:\n\t\t\t\treturn function (scope) {\n\t\t\t\t\treturn context ? { value: scope } : scope;\n\t\t\t\t};\n\t\t\tcase AST.LocalsExpression:\n\t\t\t\treturn function (scope, locals) {\n\t\t\t\t\treturn context ? { value: locals } : locals;\n\t\t\t\t};\n\t\t\tcase AST.NGValueParameter:\n\t\t\t\treturn function (scope, locals, assign) {\n\t\t\t\t\treturn context ? { value: assign } : assign;\n\t\t\t\t};\n\t\t}\n\t},\n\n\t\"unary+\": function (argument, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg = argument(scope, locals, assign, inputs);\n\t\t\tif (isDefined(arg)) {\n\t\t\t\targ = +arg;\n\t\t\t} else {\n\t\t\t\targ = 0;\n\t\t\t}\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"unary-\": function (argument, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg = argument(scope, locals, assign, inputs);\n\t\t\tif (isDefined(arg)) {\n\t\t\t\targ = -arg;\n\t\t\t} else {\n\t\t\t\targ = -0;\n\t\t\t}\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"unary!\": function (argument, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg = !argument(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary+\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar lhs = left(scope, locals, assign, inputs);\n\t\t\tvar rhs = right(scope, locals, assign, inputs);\n\t\t\tvar arg = plusFn(lhs, rhs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary-\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar lhs = left(scope, locals, assign, inputs);\n\t\t\tvar rhs = right(scope, locals, assign, inputs);\n\t\t\tvar arg = (isDefined(lhs) ? lhs : 0) - (isDefined(rhs) ? rhs : 0);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary*\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) *\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary/\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) /\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary%\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) %\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary===\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) ===\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary!==\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) !==\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary==\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\t// eslint-disable-next-line eqeqeq\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) ==\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary!=\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\t// eslint-disable-next-line eqeqeq\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) !=\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary<\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) <\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary>\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) >\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary<=\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) <=\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary>=\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) >=\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary&&\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) &&\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"binary||\": function (left, right, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg =\n\t\t\t\tleft(scope, locals, assign, inputs) ||\n\t\t\t\tright(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\t\"ternary?:\": function (test, alternate, consequent, context) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar arg = test(scope, locals, assign, inputs)\n\t\t\t\t? alternate(scope, locals, assign, inputs)\n\t\t\t\t: consequent(scope, locals, assign, inputs);\n\t\t\treturn context ? { value: arg } : arg;\n\t\t};\n\t},\n\tvalue: function (value, context) {\n\t\treturn function () {\n\t\t\treturn context\n\t\t\t\t? { context: undefined, name: undefined, value: value }\n\t\t\t\t: value;\n\t\t};\n\t},\n\tidentifier: function (name, context, create) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar base = locals && name in locals ? locals : scope;\n\t\t\tif (create && create !== 1 && base && base[name] == null) {\n\t\t\t\tbase[name] = {};\n\t\t\t}\n\t\t\tvar value = base ? base[name] : undefined;\n\t\t\tif (context) {\n\t\t\t\treturn { context: base, name: name, value: value };\n\t\t\t} else {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t};\n\t},\n\tcomputedMember: function (left, right, context, create) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar lhs = left(scope, locals, assign, inputs);\n\t\t\tvar rhs;\n\t\t\tvar value;\n\t\t\tif (lhs != null) {\n\t\t\t\trhs = right(scope, locals, assign, inputs);\n\t\t\t\trhs = getStringValue(rhs);\n\t\t\t\tif (create && create !== 1) {\n\t\t\t\t\tif (lhs && !lhs[rhs]) {\n\t\t\t\t\t\tlhs[rhs] = {};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(lhs, rhs)) {\n\t\t\t\t\tvalue = lhs[rhs];\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (context) {\n\t\t\t\treturn { context: lhs, name: rhs, value: value };\n\t\t\t} else {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t};\n\t},\n\tnonComputedMember: function (left, right, context, create) {\n\t\treturn function (scope, locals, assign, inputs) {\n\t\t\tvar lhs = left(scope, locals, assign, inputs);\n\t\t\tif (create && create !== 1) {\n\t\t\t\tif (lhs && lhs[right] == null) {\n\t\t\t\t\tlhs[right] = {};\n\t\t\t\t}\n\t\t\t}\n\t\t\tvar value = undefined;\n\t\t\tif (lhs != null && Object.prototype.hasOwnProperty.call(lhs, right)) {\n\t\t\t\tvalue = lhs[right];\n\t\t\t}\n\n\t\t\tif (context) {\n\t\t\t\treturn { context: lhs, name: right, value: value };\n\t\t\t} else {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t};\n\t},\n\tinputs: function (input, watchId) {\n\t\treturn function (scope, value, locals, inputs) {\n\t\t\tif (inputs) return inputs[watchId];\n\t\t\treturn input(scope, value, locals);\n\t\t};\n\t},\n};\n\n/**\n * @constructor\n */\nvar Parser = function Parser(lexer, $filter, options) {\n\tthis.lexer = lexer;\n\tthis.$filter = $filter;\n\tthis.options = options;\n\tthis.ast = new AST(lexer, options);\n\tthis.astCompiler = options.csp\n\t\t? new ASTInterpreter(this.ast, $filter)\n\t\t: new ASTCompiler(this.ast, $filter);\n};\n\nParser.prototype = {\n\tconstructor: Parser,\n\n\tparse: function (text) {\n\t\treturn this.astCompiler.compile(text);\n\t},\n};\n\nfunction getValueOf(value) {\n\treturn isFunction(value.valueOf)\n\t\t? value.valueOf()\n\t\t: objectValueOf.call(value);\n}\n\n///////////////////////////////////\n\n/**\n * @ngdoc service\n * @name $parse\n * @kind function\n *\n * @description\n *\n * Converts Angular {@link guide/expression expression} into a function.\n *\n * ```js\n * var getter = $parse('user.name');\n * var setter = getter.assign;\n * var context = {user:{name:'angular'}};\n * var locals = {user:{name:'local'}};\n *\n * expect(getter(context)).toEqual('angular');\n * setter(context, 'newValue');\n * expect(context.user.name).toEqual('newValue');\n * expect(getter(context, locals)).toEqual('local');\n * ```\n *\n *\n * @param {string} expression String expression to compile.\n * @returns {function(context, locals)} a function which represents the compiled expression:\n *\n * * `context` – `{object}` – an object against which any expressions embedded in the strings\n * are evaluated against (typically a scope object).\n * * `locals` – `{object=}` – local variables context object, useful for overriding values in\n * `context`.\n *\n * The returned function also has the following properties:\n * * `literal` – `{boolean}` – whether the expression's top-level node is a JavaScript\n * literal.\n * * `constant` – `{boolean}` – whether the expression is made entirely of JavaScript\n * constant literals.\n * * `assign` – `{?function(context, value)}` – if the expression is assignable, this will be\n * set to a function to change its value on the given context.\n *\n */\n\n/**\n * @ngdoc provider\n * @name $parseProvider\n * @this\n *\n * @description\n * `$parseProvider` can be used for configuring the default behavior of the {@link ng.$parse $parse}\n * service.\n */\nfunction $ParseProvider() {\n\tvar cache = createMap();\n\tvar literals = {\n\t\ttrue: true,\n\t\tfalse: false,\n\t\tnull: null,\n\t\tundefined: undefined,\n\t};\n\tvar identStart, identContinue;\n\n\t/**\n\t * @ngdoc method\n\t * @name $parseProvider#addLiteral\n\t * @description\n\t *\n\t * Configure $parse service to add literal values that will be present as literal at expressions.\n\t *\n\t * @param {string} literalName Token for the literal value. The literal name value must be a valid literal name.\n\t * @param {*} literalValue Value for this literal. All literal values must be primitives or `undefined`.\n\t *\n\t **/\n\tthis.addLiteral = function (literalName, literalValue) {\n\t\tliterals[literalName] = literalValue;\n\t};\n\n\t/**\n\t * @ngdoc method\n\t * @name $parseProvider#setIdentifierFns\n\t *\n\t * @description\n\t *\n\t * Allows defining the set of characters that are allowed in Angular expressions. The function\n\t * `identifierStart` will get called to know if a given character is a valid character to be the\n\t * first character for an identifier. The function `identifierContinue` will get called to know if\n\t * a given character is a valid character to be a follow-up identifier character. The functions\n\t * `identifierStart` and `identifierContinue` will receive as arguments the single character to be\n\t * identifier and the character code point. These arguments will be `string` and `numeric`. Keep in\n\t * mind that the `string` parameter can be two characters long depending on the character\n\t * representation. It is expected for the function to return `true` or `false`, whether that\n\t * character is allowed or not.\n\t *\n\t * Since this function will be called extensively, keep the implementation of these functions fast,\n\t * as the performance of these functions have a direct impact on the expressions parsing speed.\n\t *\n\t * @param {function=} identifierStart The function that will decide whether the given character is\n\t * a valid identifier start character.\n\t * @param {function=} identifierContinue The function that will decide whether the given character is\n\t * a valid identifier continue character.\n\t */\n\tthis.setIdentifierFns = function (identifierStart, identifierContinue) {\n\t\tidentStart = identifierStart;\n\t\tidentContinue = identifierContinue;\n\t\treturn this;\n\t};\n\n\tthis.$get = [\n\t\t\"$filter\",\n\t\tfunction ($filter) {\n\t\t\tvar noUnsafeEval = csp().noUnsafeEval;\n\t\t\tvar $parseOptions = {\n\t\t\t\tcsp: noUnsafeEval,\n\t\t\t\tliterals: copy(literals),\n\t\t\t\tisIdentifierStart: isFunction(identStart) && identStart,\n\t\t\t\tisIdentifierContinue: isFunction(identContinue) && identContinue,\n\t\t\t};\n\t\t\treturn $parse;\n\n\t\t\tfunction $parse(exp, interceptorFn) {\n\t\t\t\tvar parsedExpression, oneTime, cacheKey;\n\n\t\t\t\tswitch (typeof exp) {\n\t\t\t\t\tcase \"string\":\n\t\t\t\t\t\texp = exp.trim();\n\t\t\t\t\t\tcacheKey = exp;\n\n\t\t\t\t\t\tparsedExpression = cache[cacheKey];\n\n\t\t\t\t\t\tif (!parsedExpression) {\n\t\t\t\t\t\t\tif (exp.charAt(0) === \":\" && exp.charAt(1) === \":\") {\n\t\t\t\t\t\t\t\toneTime = true;\n\t\t\t\t\t\t\t\texp = exp.substring(2);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvar lexer = new Lexer($parseOptions);\n\t\t\t\t\t\t\tvar parser = new Parser(lexer, $filter, $parseOptions);\n\t\t\t\t\t\t\tparsedExpression = parser.parse(exp);\n\t\t\t\t\t\t\tif (parsedExpression.constant) {\n\t\t\t\t\t\t\t\tparsedExpression.$$watchDelegate = constantWatchDelegate;\n\t\t\t\t\t\t\t} else if (oneTime) {\n\t\t\t\t\t\t\t\tparsedExpression.$$watchDelegate = parsedExpression.literal\n\t\t\t\t\t\t\t\t\t? oneTimeLiteralWatchDelegate\n\t\t\t\t\t\t\t\t\t: oneTimeWatchDelegate;\n\t\t\t\t\t\t\t} else if (parsedExpression.inputs) {\n\t\t\t\t\t\t\t\tparsedExpression.$$watchDelegate = inputsWatchDelegate;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcache[cacheKey] = parsedExpression;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn addInterceptor(parsedExpression, interceptorFn);\n\n\t\t\t\t\tcase \"function\":\n\t\t\t\t\t\treturn addInterceptor(exp, interceptorFn);\n\n\t\t\t\t\tdefault:\n\t\t\t\t\t\treturn addInterceptor(noop, interceptorFn);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction expressionInputDirtyCheck(newValue, oldValueOfValue) {\n\t\t\t\tif (newValue == null || oldValueOfValue == null) {\n\t\t\t\t\t// null/undefined\n\t\t\t\t\treturn newValue === oldValueOfValue;\n\t\t\t\t}\n\n\t\t\t\tif (typeof newValue === \"object\") {\n\t\t\t\t\t// attempt to convert the value to a primitive type\n\t\t\t\t\t// TODO(docs): add a note to docs that by implementing valueOf even objects and arrays can\n\t\t\t\t\t// be cheaply dirty-checked\n\t\t\t\t\tnewValue = getValueOf(newValue);\n\n\t\t\t\t\tif (typeof newValue === \"object\") {\n\t\t\t\t\t\t// objects/arrays are not supported - deep-watching them would be too expensive\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\t// fall-through to the primitive equality check\n\t\t\t\t}\n\n\t\t\t\t//Primitive or NaN\n\t\t\t\t// eslint-disable-next-line no-self-compare\n\t\t\t\treturn (\n\t\t\t\t\tnewValue === oldValueOfValue ||\n\t\t\t\t\t(newValue !== newValue && oldValueOfValue !== oldValueOfValue)\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfunction inputsWatchDelegate(\n\t\t\t\tscope,\n\t\t\t\tlistener,\n\t\t\t\tobjectEquality,\n\t\t\t\tparsedExpression,\n\t\t\t\tprettyPrintExpression\n\t\t\t) {\n\t\t\t\tvar inputExpressions = parsedExpression.inputs;\n\t\t\t\tvar lastResult;\n\n\t\t\t\tif (inputExpressions.length === 1) {\n\t\t\t\t\tvar oldInputValueOf = expressionInputDirtyCheck; // init to something unique so that equals check fails\n\t\t\t\t\tinputExpressions = inputExpressions[0];\n\t\t\t\t\treturn scope.$watch(\n\t\t\t\t\t\tfunction expressionInputWatch(scope) {\n\t\t\t\t\t\t\tvar newInputValue = inputExpressions(scope);\n\t\t\t\t\t\t\tif (!expressionInputDirtyCheck(newInputValue, oldInputValueOf)) {\n\t\t\t\t\t\t\t\tlastResult = parsedExpression(scope, undefined, undefined, [\n\t\t\t\t\t\t\t\t\tnewInputValue,\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\toldInputValueOf = newInputValue && getValueOf(newInputValue);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn lastResult;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tlistener,\n\t\t\t\t\t\tobjectEquality,\n\t\t\t\t\t\tprettyPrintExpression\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tvar oldInputValueOfValues = [];\n\t\t\t\tvar oldInputValues = [];\n\t\t\t\tfor (var i = 0, ii = inputExpressions.length; i < ii; i++) {\n\t\t\t\t\toldInputValueOfValues[i] = expressionInputDirtyCheck; // init to something unique so that equals check fails\n\t\t\t\t\toldInputValues[i] = null;\n\t\t\t\t}\n\n\t\t\t\treturn scope.$watch(\n\t\t\t\t\tfunction expressionInputsWatch(scope) {\n\t\t\t\t\t\tvar changed = false;\n\n\t\t\t\t\t\tfor (var i = 0, ii = inputExpressions.length; i < ii; i++) {\n\t\t\t\t\t\t\tvar newInputValue = inputExpressions[i](scope);\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tchanged ||\n\t\t\t\t\t\t\t\t(changed = !expressionInputDirtyCheck(\n\t\t\t\t\t\t\t\t\tnewInputValue,\n\t\t\t\t\t\t\t\t\toldInputValueOfValues[i]\n\t\t\t\t\t\t\t\t))\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\toldInputValues[i] = newInputValue;\n\t\t\t\t\t\t\t\toldInputValueOfValues[i] =\n\t\t\t\t\t\t\t\t\tnewInputValue && getValueOf(newInputValue);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (changed) {\n\t\t\t\t\t\t\tlastResult = parsedExpression(\n\t\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\toldInputValues\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn lastResult;\n\t\t\t\t\t},\n\t\t\t\t\tlistener,\n\t\t\t\t\tobjectEquality,\n\t\t\t\t\tprettyPrintExpression\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tfunction oneTimeWatchDelegate(\n\t\t\t\tscope,\n\t\t\t\tlistener,\n\t\t\t\tobjectEquality,\n\t\t\t\tparsedExpression,\n\t\t\t\tprettyPrintExpression\n\t\t\t) {\n\t\t\t\tvar unwatch, lastValue;\n\t\t\t\tif (parsedExpression.inputs) {\n\t\t\t\t\tunwatch = inputsWatchDelegate(\n\t\t\t\t\t\tscope,\n\t\t\t\t\t\toneTimeListener,\n\t\t\t\t\t\tobjectEquality,\n\t\t\t\t\t\tparsedExpression,\n\t\t\t\t\t\tprettyPrintExpression\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tunwatch = scope.$watch(oneTimeWatch, oneTimeListener, objectEquality);\n\t\t\t\t}\n\t\t\t\treturn unwatch;\n\n\t\t\t\tfunction oneTimeWatch(scope) {\n\t\t\t\t\treturn parsedExpression(scope);\n\t\t\t\t}\n\t\t\t\tfunction oneTimeListener(value, old, scope) {\n\t\t\t\t\tlastValue = value;\n\t\t\t\t\tif (isFunction(listener)) {\n\t\t\t\t\t\tlistener(value, old, scope);\n\t\t\t\t\t}\n\t\t\t\t\tif (isDefined(value)) {\n\t\t\t\t\t\tscope.$$postDigest(function () {\n\t\t\t\t\t\t\tif (isDefined(lastValue)) {\n\t\t\t\t\t\t\t\tunwatch();\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\n\t\t\tfunction oneTimeLiteralWatchDelegate(\n\t\t\t\tscope,\n\t\t\t\tlistener,\n\t\t\t\tobjectEquality,\n\t\t\t\tparsedExpression\n\t\t\t) {\n\t\t\t\tvar unwatch, lastValue;\n\t\t\t\tunwatch = scope.$watch(\n\t\t\t\t\tfunction oneTimeWatch(scope) {\n\t\t\t\t\t\treturn parsedExpression(scope);\n\t\t\t\t\t},\n\t\t\t\t\tfunction oneTimeListener(value, old, scope) {\n\t\t\t\t\t\tlastValue = value;\n\t\t\t\t\t\tif (isFunction(listener)) {\n\t\t\t\t\t\t\tlistener(value, old, scope);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (isAllDefined(value)) {\n\t\t\t\t\t\t\tscope.$$postDigest(function () {\n\t\t\t\t\t\t\t\tif (isAllDefined(lastValue)) unwatch();\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\tobjectEquality\n\t\t\t\t);\n\n\t\t\t\treturn unwatch;\n\n\t\t\t\tfunction isAllDefined(value) {\n\t\t\t\t\tvar allDefined = true;\n\t\t\t\t\tforEach(value, function (val) {\n\t\t\t\t\t\tif (!isDefined(val)) allDefined = false;\n\t\t\t\t\t});\n\t\t\t\t\treturn allDefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction constantWatchDelegate(\n\t\t\t\tscope,\n\t\t\t\tlistener,\n\t\t\t\tobjectEquality,\n\t\t\t\tparsedExpression\n\t\t\t) {\n\t\t\t\tvar unwatch = scope.$watch(\n\t\t\t\t\tfunction constantWatch(scope) {\n\t\t\t\t\t\tunwatch();\n\t\t\t\t\t\treturn parsedExpression(scope);\n\t\t\t\t\t},\n\t\t\t\t\tlistener,\n\t\t\t\t\tobjectEquality\n\t\t\t\t);\n\t\t\t\treturn unwatch;\n\t\t\t}\n\n\t\t\tfunction addInterceptor(parsedExpression, interceptorFn) {\n\t\t\t\tif (!interceptorFn) return parsedExpression;\n\t\t\t\tvar watchDelegate = parsedExpression.$$watchDelegate;\n\t\t\t\tvar useInputs = false;\n\n\t\t\t\tvar regularWatch =\n\t\t\t\t\twatchDelegate !== oneTimeLiteralWatchDelegate &&\n\t\t\t\t\twatchDelegate !== oneTimeWatchDelegate;\n\n\t\t\t\tvar fn = regularWatch\n\t\t\t\t\t? function regularInterceptedExpression(\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\tlocals,\n\t\t\t\t\t\t\tassign,\n\t\t\t\t\t\t\tinputs\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tvar value =\n\t\t\t\t\t\t\t\tuseInputs && inputs\n\t\t\t\t\t\t\t\t\t? inputs[0]\n\t\t\t\t\t\t\t\t\t: parsedExpression(scope, locals, assign, inputs);\n\t\t\t\t\t\t\treturn interceptorFn(value, scope, locals);\n\t\t\t\t\t\t}\n\t\t\t\t\t: function oneTimeInterceptedExpression(\n\t\t\t\t\t\t\tscope,\n\t\t\t\t\t\t\tlocals,\n\t\t\t\t\t\t\tassign,\n\t\t\t\t\t\t\tinputs\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tvar value = parsedExpression(scope, locals, assign, inputs);\n\t\t\t\t\t\t\tvar result = interceptorFn(value, scope, locals);\n\t\t\t\t\t\t\t// we only return the interceptor's result if the\n\t\t\t\t\t\t\t// initial value is defined (for bind-once)\n\t\t\t\t\t\t\treturn isDefined(value) ? result : value;\n\t\t\t\t\t\t};\n\n\t\t\t\t// Propagate $$watchDelegates other then inputsWatchDelegate\n\t\t\t\tuseInputs = !parsedExpression.inputs;\n\t\t\t\tif (\n\t\t\t\t\tparsedExpression.$$watchDelegate &&\n\t\t\t\t\tparsedExpression.$$watchDelegate !== inputsWatchDelegate\n\t\t\t\t) {\n\t\t\t\t\tfn.$$watchDelegate = parsedExpression.$$watchDelegate;\n\t\t\t\t\tfn.inputs = parsedExpression.inputs;\n\t\t\t\t} else if (!interceptorFn.$stateful) {\n\t\t\t\t\t// If there is an interceptor, but no watchDelegate then treat the interceptor like\n\t\t\t\t\t// we treat filters - it is assumed to be a pure function unless flagged with $stateful\n\t\t\t\t\tfn.$$watchDelegate = inputsWatchDelegate;\n\t\t\t\t\tfn.inputs = parsedExpression.inputs\n\t\t\t\t\t\t? parsedExpression.inputs\n\t\t\t\t\t\t: [parsedExpression];\n\t\t\t\t}\n\n\t\t\t\treturn fn;\n\t\t\t}\n\t\t},\n\t];\n}\n\nexports.Lexer = Lexer;\nexports.Parser = Parser;\n","\"use strict\";\n\nvar parse = require(\"./parse.js\");\n\nvar filters = {};\nvar Lexer = parse.Lexer;\nvar Parser = parse.Parser;\n\n/**\n * Compiles src and returns a function that executes src on a target object.\n * To speed up further calls the compiled function is cached under compile.cache[src] if options.filters is not present.\n *\n * @param {string} src\n * @param {object | undefined} options\n * @returns {function}\n */\nfunction compile(src, options) {\n\toptions = options || {};\n\tvar localFilters = options.filters || filters;\n\tvar cache = options.filters ? options.cache || {} : compile.cache;\n\tvar lexerOptions = options;\n\n\tvar cached;\n\n\tif (typeof src !== \"string\") {\n\t\tthrow new TypeError(\n\t\t\t\"src must be a string, instead saw '\" + typeof src + \"'\"\n\t\t);\n\t}\n\tvar parserOptions = {\n\t\tcsp: options.csp != null ? options.csp : false, // noUnsafeEval,\n\t\tliterals:\n\t\t\toptions.literals != null\n\t\t\t\t? options.literals\n\t\t\t\t: {\n\t\t\t\t\t\t// defined at: function $ParseProvider() {\n\t\t\t\t\t\ttrue: true,\n\t\t\t\t\t\tfalse: false,\n\t\t\t\t\t\tnull: null,\n\t\t\t\t\t\t/*eslint no-undefined: 0*/\n\t\t\t\t\t\tundefined: undefined,\n\t\t\t\t\t\t/* eslint: no-undefined: 1 */\n\t\t\t\t\t},\n\t};\n\n\tvar lexer = new Lexer(lexerOptions);\n\tvar parser = new Parser(\n\t\tlexer,\n\t\tfunction getFilter(name) {\n\t\t\treturn localFilters[name];\n\t\t},\n\t\tparserOptions\n\t);\n\n\tif (!cache) {\n\t\treturn parser.parse(src);\n\t}\n\n\tcached = cache[src];\n\tif (!cached) {\n\t\tcached = cache[src] = parser.parse(src);\n\t}\n\n\treturn cached;\n}\n\n/**\n * A cache containing all compiled functions. The src is used as key.\n * Set this on false to disable the cache.\n *\n * @type {object}\n */\ncompile.cache = Object.create(null);\n\nexports.Lexer = Lexer;\nexports.Parser = Parser;\nexports.compile = compile;\nexports.filters = filters;\n","/**\n * Values I want to reference from anywhere\n * @typedef {Object} GlobalsObject\n * @property {State} state\n * @property {import(\"./data\").Data} data\n * @property {import(\"./components/actions\").Actions} actions\n * @property {import('./components/layout').Layout} layout\n * @property {import('./components/access/pattern').PatternList} patterns\n * @property {import('./components/access/cues').CueList} cues\n * @property {import('./components/access/method').MethodChooser} method\n * @property {import('./components/monitor').Monitor} monitor\n * @property {import('./components/designer').Designer} designer\n * @property {import('./components/errors').Messages} error\n * @property {function():Promise} restart\n */\n\n/** @type {GlobalsObject} */\n// @ts-ignore Object missing properties\nconst Globals = {}; // values are supplied in start.js\n\nexport default Globals;\n","const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);\n\nlet idbProxyableTypes;\nlet cursorAdvanceMethods;\n// This is a function to prevent it throwing up in node environments.\nfunction getIdbProxyableTypes() {\n return (idbProxyableTypes ||\n (idbProxyableTypes = [\n IDBDatabase,\n IDBObjectStore,\n IDBIndex,\n IDBCursor,\n IDBTransaction,\n ]));\n}\n// This is a function to prevent it throwing up in node environments.\nfunction getCursorAdvanceMethods() {\n return (cursorAdvanceMethods ||\n (cursorAdvanceMethods = [\n IDBCursor.prototype.advance,\n IDBCursor.prototype.continue,\n IDBCursor.prototype.continuePrimaryKey,\n ]));\n}\nconst transactionDoneMap = new WeakMap();\nconst transformCache = new WeakMap();\nconst reverseTransformCache = new WeakMap();\nfunction promisifyRequest(request) {\n const promise = new Promise((resolve, reject) => {\n const unlisten = () => {\n request.removeEventListener('success', success);\n request.removeEventListener('error', error);\n };\n const success = () => {\n resolve(wrap(request.result));\n unlisten();\n };\n const error = () => {\n reject(request.error);\n unlisten();\n };\n request.addEventListener('success', success);\n request.addEventListener('error', error);\n });\n // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This\n // is because we create many promises from a single IDBRequest.\n reverseTransformCache.set(promise, request);\n return promise;\n}\nfunction cacheDonePromiseForTransaction(tx) {\n // Early bail if we've already created a done promise for this transaction.\n if (transactionDoneMap.has(tx))\n return;\n const done = new Promise((resolve, reject) => {\n const unlisten = () => {\n tx.removeEventListener('complete', complete);\n tx.removeEventListener('error', error);\n tx.removeEventListener('abort', error);\n };\n const complete = () => {\n resolve();\n unlisten();\n };\n const error = () => {\n reject(tx.error || new DOMException('AbortError', 'AbortError'));\n unlisten();\n };\n tx.addEventListener('complete', complete);\n tx.addEventListener('error', error);\n tx.addEventListener('abort', error);\n });\n // Cache it for later retrieval.\n transactionDoneMap.set(tx, done);\n}\nlet idbProxyTraps = {\n get(target, prop, receiver) {\n if (target instanceof IDBTransaction) {\n // Special handling for transaction.done.\n if (prop === 'done')\n return transactionDoneMap.get(target);\n // Make tx.store return the only store in the transaction, or undefined if there are many.\n if (prop === 'store') {\n return receiver.objectStoreNames[1]\n ? undefined\n : receiver.objectStore(receiver.objectStoreNames[0]);\n }\n }\n // Else transform whatever we get back.\n return wrap(target[prop]);\n },\n set(target, prop, value) {\n target[prop] = value;\n return true;\n },\n has(target, prop) {\n if (target instanceof IDBTransaction &&\n (prop === 'done' || prop === 'store')) {\n return true;\n }\n return prop in target;\n },\n};\nfunction replaceTraps(callback) {\n idbProxyTraps = callback(idbProxyTraps);\n}\nfunction wrapFunction(func) {\n // Due to expected object equality (which is enforced by the caching in `wrap`), we\n // only create one new func per func.\n // Cursor methods are special, as the behaviour is a little more different to standard IDB. In\n // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the\n // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense\n // with real promises, so each advance methods returns a new promise for the cursor object, or\n // undefined if the end of the cursor has been reached.\n if (getCursorAdvanceMethods().includes(func)) {\n return function (...args) {\n // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use\n // the original object.\n func.apply(unwrap(this), args);\n return wrap(this.request);\n };\n }\n return function (...args) {\n // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use\n // the original object.\n return wrap(func.apply(unwrap(this), args));\n };\n}\nfunction transformCachableValue(value) {\n if (typeof value === 'function')\n return wrapFunction(value);\n // This doesn't return, it just creates a 'done' promise for the transaction,\n // which is later returned for transaction.done (see idbObjectHandler).\n if (value instanceof IDBTransaction)\n cacheDonePromiseForTransaction(value);\n if (instanceOfAny(value, getIdbProxyableTypes()))\n return new Proxy(value, idbProxyTraps);\n // Return the same value back if we're not going to transform it.\n return value;\n}\nfunction wrap(value) {\n // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because\n // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.\n if (value instanceof IDBRequest)\n return promisifyRequest(value);\n // If we've already transformed this value before, reuse the transformed value.\n // This is faster, but it also provides object equality.\n if (transformCache.has(value))\n return transformCache.get(value);\n const newValue = transformCachableValue(value);\n // Not all types are transformed.\n // These may be primitive types, so they can't be WeakMap keys.\n if (newValue !== value) {\n transformCache.set(value, newValue);\n reverseTransformCache.set(newValue, value);\n }\n return newValue;\n}\nconst unwrap = (value) => reverseTransformCache.get(value);\n\n/**\n * Open a database.\n *\n * @param name Name of the database.\n * @param version Schema version.\n * @param callbacks Additional callbacks.\n */\nfunction openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {\n const request = indexedDB.open(name, version);\n const openPromise = wrap(request);\n if (upgrade) {\n request.addEventListener('upgradeneeded', (event) => {\n upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);\n });\n }\n if (blocked) {\n request.addEventListener('blocked', (event) => blocked(\n // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405\n event.oldVersion, event.newVersion, event));\n }\n openPromise\n .then((db) => {\n if (terminated)\n db.addEventListener('close', () => terminated());\n if (blocking) {\n db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));\n }\n })\n .catch(() => { });\n return openPromise;\n}\n/**\n * Delete a database.\n *\n * @param name Name of the database.\n */\nfunction deleteDB(name, { blocked } = {}) {\n const request = indexedDB.deleteDatabase(name);\n if (blocked) {\n request.addEventListener('blocked', (event) => blocked(\n // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405\n event.oldVersion, event));\n }\n return wrap(request).then(() => undefined);\n}\n\nconst readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];\nconst writeMethods = ['put', 'add', 'delete', 'clear'];\nconst cachedMethods = new Map();\nfunction getMethod(target, prop) {\n if (!(target instanceof IDBDatabase &&\n !(prop in target) &&\n typeof prop === 'string')) {\n return;\n }\n if (cachedMethods.get(prop))\n return cachedMethods.get(prop);\n const targetFuncName = prop.replace(/FromIndex$/, '');\n const useIndex = prop !== targetFuncName;\n const isWrite = writeMethods.includes(targetFuncName);\n if (\n // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.\n !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||\n !(isWrite || readMethods.includes(targetFuncName))) {\n return;\n }\n const method = async function (storeName, ...args) {\n // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(\n const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');\n let target = tx.store;\n if (useIndex)\n target = target.index(args.shift());\n // Must reject if op rejects.\n // If it's a write operation, must reject if tx.done rejects.\n // Must reject with op rejection first.\n // Must resolve with op value.\n // Must handle both promises (no unhandled rejections)\n return (await Promise.all([\n target[targetFuncName](...args),\n isWrite && tx.done,\n ]))[0];\n };\n cachedMethods.set(prop, method);\n return method;\n}\nreplaceTraps((oldTraps) => ({\n ...oldTraps,\n get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),\n has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),\n}));\n\nconst advanceMethodProps = ['continue', 'continuePrimaryKey', 'advance'];\nconst methodMap = {};\nconst advanceResults = new WeakMap();\nconst ittrProxiedCursorToOriginalProxy = new WeakMap();\nconst cursorIteratorTraps = {\n get(target, prop) {\n if (!advanceMethodProps.includes(prop))\n return target[prop];\n let cachedFunc = methodMap[prop];\n if (!cachedFunc) {\n cachedFunc = methodMap[prop] = function (...args) {\n advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args));\n };\n }\n return cachedFunc;\n },\n};\nasync function* iterate(...args) {\n // tslint:disable-next-line:no-this-assignment\n let cursor = this;\n if (!(cursor instanceof IDBCursor)) {\n cursor = await cursor.openCursor(...args);\n }\n if (!cursor)\n return;\n cursor = cursor;\n const proxiedCursor = new Proxy(cursor, cursorIteratorTraps);\n ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor);\n // Map this double-proxy back to the original, so other cursor methods work.\n reverseTransformCache.set(proxiedCursor, unwrap(cursor));\n while (cursor) {\n yield proxiedCursor;\n // If one of the advancing methods was not called, call continue().\n cursor = await (advanceResults.get(proxiedCursor) || cursor.continue());\n advanceResults.delete(proxiedCursor);\n }\n}\nfunction isIteratorProp(target, prop) {\n return ((prop === Symbol.asyncIterator &&\n instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor])) ||\n (prop === 'iterate' && instanceOfAny(target, [IDBIndex, IDBObjectStore])));\n}\nreplaceTraps((oldTraps) => ({\n ...oldTraps,\n get(target, prop, receiver) {\n if (isIteratorProp(target, prop))\n return iterate;\n return oldTraps.get(target, prop, receiver);\n },\n has(target, prop) {\n return isIteratorProp(target, prop) || oldTraps.has(target, prop);\n },\n}));\n\nexport { deleteDB, openDB, unwrap, wrap };\n","// DEFLATE is a complex format; to read this code, you should probably check the RFC first:\n// https://tools.ietf.org/html/rfc1951\n// You may also wish to take a look at the guide I made about this program:\n// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad\n// Some of the following code is similar to that of UZIP.js:\n// https://github.com/photopea/UZIP.js\n// However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.\n// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint\n// is better for memory in most engines (I *think*).\nvar ch2 = {};\nvar wk = (function (c, id, msg, transfer, cb) {\n var w = new Worker(ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([\n c + ';addEventListener(\"error\",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'\n ], { type: 'text/javascript' }))));\n w.onmessage = function (e) {\n var d = e.data, ed = d.$e$;\n if (ed) {\n var err = new Error(ed[0]);\n err['code'] = ed[1];\n err.stack = ed[2];\n cb(err, null);\n }\n else\n cb(null, d);\n };\n w.postMessage(msg, transfer);\n return w;\n});\n\n// aliases for shorter compressed code (most minifers don't do this)\nvar u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;\n// fixed length extra bits\nvar fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]);\n// fixed distance extra bits\nvar fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]);\n// code length index map\nvar clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n// get base, reverse index map from extra bits\nvar freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new i32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return { b: b, r: r };\n};\nvar _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;\n// we can ignore the fact that the other numbers are wrong; they never happen anyway\nfl[28] = 258, revfl[258] = 28;\nvar _b = freb(fdeb, 0), fd = _b.b, revfd = _b.r;\n// map of value to reverse (assuming 16 bits)\nvar rev = new u16(32768);\nfor (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1;\n}\n// create huffman tree from u8 \"map\": index -> code length for code index\n// mb (max bits) must be at most 15\n// TODO: optimize/split up?\nvar hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i) {\n if (cd[i])\n ++l[cd[i] - 1];\n }\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 1; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i) {\n if (cd[i]) {\n co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]);\n }\n }\n }\n return co;\n});\n// fixed length tree\nvar flt = new u8(288);\nfor (var i = 0; i < 144; ++i)\n flt[i] = 8;\nfor (var i = 144; i < 256; ++i)\n flt[i] = 9;\nfor (var i = 256; i < 280; ++i)\n flt[i] = 7;\nfor (var i = 280; i < 288; ++i)\n flt[i] = 8;\n// fixed distance tree\nvar fdt = new u8(32);\nfor (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n// fixed length map\nvar flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n// fixed distance map\nvar fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n// find max of array\nvar max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n};\n// read d, starting at bit p and mask with m\nvar bits = function (d, p, m) {\n var o = (p / 8) | 0;\n return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;\n};\n// read d, starting at bit p continuing for at least 16 bits\nvar bits16 = function (d, p) {\n var o = (p / 8) | 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));\n};\n// get end of byte\nvar shft = function (p) { return ((p + 7) / 8) | 0; };\n// typed array slice - allows garbage collector to free original reference,\n// while being more compatible than .slice\nvar slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n return new u8(v.subarray(s, e));\n};\n/**\n * Codes for errors generated within this library\n */\nexport var FlateErrorCode = {\n UnexpectedEOF: 0,\n InvalidBlockType: 1,\n InvalidLengthLiteral: 2,\n InvalidDistance: 3,\n StreamFinished: 4,\n NoStreamHandler: 5,\n InvalidHeader: 6,\n NoCallback: 7,\n InvalidUTF8: 8,\n ExtraFieldTooLong: 9,\n InvalidDate: 10,\n FilenameTooLong: 11,\n StreamFinishing: 12,\n InvalidZipData: 13,\n UnknownCompressionMethod: 14\n};\n// error codes\nvar ec = [\n 'unexpected EOF',\n 'invalid block type',\n 'invalid length/literal',\n 'invalid distance',\n 'stream finished',\n 'no stream handler',\n ,\n 'no callback',\n 'invalid UTF-8 data',\n 'extra field too long',\n 'date not in range 1980-2099',\n 'filename too long',\n 'stream finishing',\n 'invalid zip data'\n // determined by unknown compression method\n];\n;\nvar err = function (ind, msg, nt) {\n var e = new Error(msg || ec[ind]);\n e.code = ind;\n if (Error.captureStackTrace)\n Error.captureStackTrace(e, err);\n if (!nt)\n throw e;\n return e;\n};\n// expands raw DEFLATE data\nvar inflt = function (dat, st, buf, dict) {\n // source length dict length\n var sl = dat.length, dl = dict ? dict.length : 0;\n if (!sl || st.f && !st.l)\n return buf || new u8(0);\n var noBuf = !buf;\n // have to estimate size\n var resize = noBuf || st.i != 2;\n // no state\n var noSt = st.i;\n // Assumes roughly 33% compression ratio average\n if (noBuf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n err(0);\n break;\n }\n // ensure size\n if (resize)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8, st.f = final;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n err(1);\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17\n if (resize)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var lpos = pos;\n for (;; lpos = pos) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >> 4;\n pos += c & 15;\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n if (!c)\n err(2);\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lpos = pos, lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;\n if (!d)\n err(3);\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & (1 << b) - 1, pos += b;\n }\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n if (resize)\n cbuf(bt + 131072);\n var end = bt + add;\n if (bt < dt) {\n var shift = dl - dt, dend = Math.min(dt, end);\n if (shift + bt < 0)\n err(3);\n for (; bt < dend; ++bt)\n buf[bt] = dict[shift + bt];\n }\n for (; bt < end; ++bt)\n buf[bt] = buf[bt - dt];\n }\n }\n st.l = lm, st.p = lpos, st.b = bt, st.f = final;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n // don't reallocate for streams or user buffers\n return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);\n};\n// starting at p, write the minimum number of bits that can hold v to d\nvar wbits = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) | 0;\n d[o] |= v;\n d[o + 1] |= v >> 8;\n};\n// starting at p, write the minimum number of bits (>8) that can hold v to d\nvar wbits16 = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) | 0;\n d[o] |= v;\n d[o + 1] |= v >> 8;\n d[o + 2] |= v >> 16;\n};\n// creates code lengths from a frequency table\nvar hTree = function (d, mb) {\n // Need extra info to make a tree\n var t = [];\n for (var i = 0; i < d.length; ++i) {\n if (d[i])\n t.push({ s: i, f: d[i] });\n }\n var s = t.length;\n var t2 = t.slice();\n if (!s)\n return { t: et, l: 0 };\n if (s == 1) {\n var v = new u8(t[0].s + 1);\n v[t[0].s] = 1;\n return { t: v, l: 1 };\n }\n t.sort(function (a, b) { return a.f - b.f; });\n // after i2 reaches last ind, will be stopped\n // freq must be greater than largest possible number of symbols\n t.push({ s: -1, f: 25001 });\n var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;\n t[0] = { s: -1, f: l.f + r.f, l: l, r: r };\n // efficient algorithm from UZIP.js\n // i0 is lookbehind, i2 is lookahead - after processing two low-freq\n // symbols that combined have high freq, will start processing i2 (high-freq,\n // non-composite) symbols instead\n // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/\n while (i1 != s - 1) {\n l = t[t[i0].f < t[i2].f ? i0++ : i2++];\n r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];\n t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r };\n }\n var maxSym = t2[0].s;\n for (var i = 1; i < s; ++i) {\n if (t2[i].s > maxSym)\n maxSym = t2[i].s;\n }\n // code lengths\n var tr = new u16(maxSym + 1);\n // max bits in tree\n var mbt = ln(t[i1 - 1], tr, 0);\n if (mbt > mb) {\n // more algorithms from UZIP.js\n // TODO: find out how this code works (debt)\n // ind debt\n var i = 0, dt = 0;\n // left cost\n var lft = mbt - mb, cst = 1 << lft;\n t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; });\n for (; i < s; ++i) {\n var i2_1 = t2[i].s;\n if (tr[i2_1] > mb) {\n dt += cst - (1 << (mbt - tr[i2_1]));\n tr[i2_1] = mb;\n }\n else\n break;\n }\n dt >>= lft;\n while (dt > 0) {\n var i2_2 = t2[i].s;\n if (tr[i2_2] < mb)\n dt -= 1 << (mb - tr[i2_2]++ - 1);\n else\n ++i;\n }\n for (; i >= 0 && dt; --i) {\n var i2_3 = t2[i].s;\n if (tr[i2_3] == mb) {\n --tr[i2_3];\n ++dt;\n }\n }\n mbt = mb;\n }\n return { t: new u8(tr), l: mbt };\n};\n// get the max length and assign length codes\nvar ln = function (n, l, d) {\n return n.s == -1\n ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1))\n : (l[n.s] = d);\n};\n// length codes generation\nvar lc = function (c) {\n var s = c.length;\n // Note that the semicolon was intentional\n while (s && !c[--s])\n ;\n var cl = new u16(++s);\n // ind num streak\n var cli = 0, cln = c[0], cls = 1;\n var w = function (v) { cl[cli++] = v; };\n for (var i = 1; i <= s; ++i) {\n if (c[i] == cln && i != s)\n ++cls;\n else {\n if (!cln && cls > 2) {\n for (; cls > 138; cls -= 138)\n w(32754);\n if (cls > 2) {\n w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305);\n cls = 0;\n }\n }\n else if (cls > 3) {\n w(cln), --cls;\n for (; cls > 6; cls -= 6)\n w(8304);\n if (cls > 2)\n w(((cls - 3) << 5) | 8208), cls = 0;\n }\n while (cls--)\n w(cln);\n cls = 1;\n cln = c[i];\n }\n }\n return { c: cl.subarray(0, cli), n: s };\n};\n// calculate the length of output from tree, code lengths\nvar clen = function (cf, cl) {\n var l = 0;\n for (var i = 0; i < cl.length; ++i)\n l += cf[i] * cl[i];\n return l;\n};\n// writes a fixed block\n// returns the new bit pos\nvar wfblk = function (out, pos, dat) {\n // no need to write 00 as type: TypedArray defaults to 0\n var s = dat.length;\n var o = shft(pos + 2);\n out[o] = s & 255;\n out[o + 1] = s >> 8;\n out[o + 2] = out[o] ^ 255;\n out[o + 3] = out[o + 1] ^ 255;\n for (var i = 0; i < s; ++i)\n out[o + i + 4] = dat[i];\n return (o + 4 + s) * 8;\n};\n// writes a block\nvar wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) {\n wbits(out, p++, final);\n ++lf[256];\n var _a = hTree(lf, 15), dlt = _a.t, mlb = _a.l;\n var _b = hTree(df, 15), ddt = _b.t, mdb = _b.l;\n var _c = lc(dlt), lclt = _c.c, nlc = _c.n;\n var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;\n var lcfreq = new u16(19);\n for (var i = 0; i < lclt.length; ++i)\n ++lcfreq[lclt[i] & 31];\n for (var i = 0; i < lcdt.length; ++i)\n ++lcfreq[lcdt[i] & 31];\n var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;\n var nlcc = 19;\n for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)\n ;\n var flen = (bl + 5) << 3;\n var ftlen = clen(lf, flt) + clen(df, fdt) + eb;\n var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];\n if (bs >= 0 && flen <= ftlen && flen <= dtlen)\n return wfblk(out, p, dat.subarray(bs, bs + bl));\n var lm, ll, dm, dl;\n wbits(out, p, 1 + (dtlen < ftlen)), p += 2;\n if (dtlen < ftlen) {\n lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;\n var llm = hMap(lct, mlcb, 0);\n wbits(out, p, nlc - 257);\n wbits(out, p + 5, ndc - 1);\n wbits(out, p + 10, nlcc - 4);\n p += 14;\n for (var i = 0; i < nlcc; ++i)\n wbits(out, p + 3 * i, lct[clim[i]]);\n p += 3 * nlcc;\n var lcts = [lclt, lcdt];\n for (var it = 0; it < 2; ++it) {\n var clct = lcts[it];\n for (var i = 0; i < clct.length; ++i) {\n var len = clct[i] & 31;\n wbits(out, p, llm[len]), p += lct[len];\n if (len > 15)\n wbits(out, p, (clct[i] >> 5) & 127), p += clct[i] >> 12;\n }\n }\n }\n else {\n lm = flm, ll = flt, dm = fdm, dl = fdt;\n }\n for (var i = 0; i < li; ++i) {\n var sym = syms[i];\n if (sym > 255) {\n var len = (sym >> 18) & 31;\n wbits16(out, p, lm[len + 257]), p += ll[len + 257];\n if (len > 7)\n wbits(out, p, (sym >> 23) & 31), p += fleb[len];\n var dst = sym & 31;\n wbits16(out, p, dm[dst]), p += dl[dst];\n if (dst > 3)\n wbits16(out, p, (sym >> 5) & 8191), p += fdeb[dst];\n }\n else {\n wbits16(out, p, lm[sym]), p += ll[sym];\n }\n }\n wbits16(out, p, lm[256]);\n return p + ll[256];\n};\n// deflate options (nice << 13) | chain\nvar deo = /*#__PURE__*/ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);\n// empty\nvar et = /*#__PURE__*/ new u8(0);\n// compresses data into a raw DEFLATE buffer\nvar dflt = function (dat, lvl, plvl, pre, post, st) {\n var s = st.z || dat.length;\n var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7000)) + post);\n // writing to this writes to the output buffer\n var w = o.subarray(pre, o.length - post);\n var lst = st.l;\n var pos = (st.r || 0) & 7;\n if (lvl) {\n if (pos)\n w[0] = st.r >> 3;\n var opt = deo[lvl - 1];\n var n = opt >> 13, c = opt & 8191;\n var msk_1 = (1 << plvl) - 1;\n // prev 2-byte val map curr 2-byte val map\n var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);\n var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;\n var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; };\n // 24576 is an arbitrary number of maximum symbols per block\n // 424 buffer for last block\n var syms = new i32(25000);\n // length/literal freq distance freq\n var lf = new u16(288), df = new u16(32);\n // l/lcnt exbits index l/lind waitdx blkpos\n var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;\n for (; i + 2 < s; ++i) {\n // hash value\n var hv = hsh(i);\n // index mod 32768 previous index mod\n var imod = i & 32767, pimod = head[hv];\n prev[imod] = pimod;\n head[hv] = imod;\n // We always should modify head and prev, but only add symbols if\n // this data is not yet processed (\"wait\" for wait index)\n if (wi <= i) {\n // bytes remaining\n var rem = s - i;\n if ((lc_1 > 7000 || li > 24576) && (rem > 423 || !lst)) {\n pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);\n li = lc_1 = eb = 0, bs = i;\n for (var j = 0; j < 286; ++j)\n lf[j] = 0;\n for (var j = 0; j < 30; ++j)\n df[j] = 0;\n }\n // len dist chain\n var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;\n if (rem > 2 && hv == hsh(i - dif)) {\n var maxn = Math.min(n, rem) - 1;\n var maxd = Math.min(32767, i);\n // max possible length\n // not capped at dif because decompressors implement \"rolling\" index population\n var ml = Math.min(258, rem);\n while (dif <= maxd && --ch_1 && imod != pimod) {\n if (dat[i + l] == dat[i + l - dif]) {\n var nl = 0;\n for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)\n ;\n if (nl > l) {\n l = nl, d = dif;\n // break out early when we reach \"nice\" (we are satisfied enough)\n if (nl > maxn)\n break;\n // now, find the rarest 2-byte sequence within this\n // length of literals and search for that instead.\n // Much faster than just using the start\n var mmd = Math.min(dif, nl - 2);\n var md = 0;\n for (var j = 0; j < mmd; ++j) {\n var ti = i - dif + j & 32767;\n var pti = prev[ti];\n var cd = ti - pti & 32767;\n if (cd > md)\n md = cd, pimod = ti;\n }\n }\n }\n // check the previous match\n imod = pimod, pimod = prev[imod];\n dif += imod - pimod & 32767;\n }\n }\n // d will be nonzero only when a match was found\n if (d) {\n // store both dist and len data in one int32\n // Make sure this is recognized as a len/dist with 28th bit (2^28)\n syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d];\n var lin = revfl[l] & 31, din = revfd[d] & 31;\n eb += fleb[lin] + fdeb[din];\n ++lf[257 + lin];\n ++df[din];\n wi = i + l;\n ++lc_1;\n }\n else {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n }\n }\n for (i = Math.max(i, wi); i < s; ++i) {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);\n if (!lst) {\n st.r = (pos & 7) | w[(pos / 8) | 0] << 3;\n // shft(pos) now 1 less if pos & 7 != 0\n pos -= 7;\n st.h = head, st.p = prev, st.i = i, st.w = wi;\n }\n }\n else {\n for (var i = st.w || 0; i < s + lst; i += 65535) {\n // end\n var e = i + 65535;\n if (e >= s) {\n // write final block\n w[(pos / 8) | 0] = lst;\n e = s;\n }\n pos = wfblk(w, pos + 1, dat.subarray(i, e));\n }\n st.i = s;\n }\n return slc(o, 0, pre + shft(pos) + post);\n};\n// CRC32 table\nvar crct = /*#__PURE__*/ (function () {\n var t = new Int32Array(256);\n for (var i = 0; i < 256; ++i) {\n var c = i, k = 9;\n while (--k)\n c = ((c & 1) && -306674912) ^ (c >>> 1);\n t[i] = c;\n }\n return t;\n})();\n// CRC32\nvar crc = function () {\n var c = -1;\n return {\n p: function (d) {\n // closures have awful performance\n var cr = c;\n for (var i = 0; i < d.length; ++i)\n cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8);\n c = cr;\n },\n d: function () { return ~c; }\n };\n};\n// Adler32\nvar adler = function () {\n var a = 1, b = 0;\n return {\n p: function (d) {\n // closures have awful performance\n var n = a, m = b;\n var l = d.length | 0;\n for (var i = 0; i != l;) {\n var e = Math.min(i + 2655, l);\n for (; i < e; ++i)\n m += n += d[i];\n n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);\n }\n a = n, b = m;\n },\n d: function () {\n a %= 65521, b %= 65521;\n return (a & 255) << 24 | (a & 0xFF00) << 8 | (b & 255) << 8 | (b >> 8);\n }\n };\n};\n;\n// deflate with opts\nvar dopt = function (dat, opt, pre, post, st) {\n if (!st) {\n st = { l: 1 };\n if (opt.dictionary) {\n var dict = opt.dictionary.subarray(-32768);\n var newDat = new u8(dict.length + dat.length);\n newDat.set(dict);\n newDat.set(dat, dict.length);\n dat = newDat;\n st.w = dict.length;\n }\n }\n return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? (st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20) : (12 + opt.mem), pre, post, st);\n};\n// Walmart object spread\nvar mrg = function (a, b) {\n var o = {};\n for (var k in a)\n o[k] = a[k];\n for (var k in b)\n o[k] = b[k];\n return o;\n};\n// worker clone\n// This is possibly the craziest part of the entire codebase, despite how simple it may seem.\n// The only parameter to this function is a closure that returns an array of variables outside of the function scope.\n// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.\n// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).\n// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.\n// This took me three weeks to figure out how to do.\nvar wcln = function (fn, fnStr, td) {\n var dt = fn();\n var st = fn.toString();\n var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/\\s+/g, '').split(',');\n for (var i = 0; i < dt.length; ++i) {\n var v = dt[i], k = ks[i];\n if (typeof v == 'function') {\n fnStr += ';' + k + '=';\n var st_1 = v.toString();\n if (v.prototype) {\n // for global objects\n if (st_1.indexOf('[native code]') != -1) {\n var spInd = st_1.indexOf(' ', 8) + 1;\n fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));\n }\n else {\n fnStr += st_1;\n for (var t in v.prototype)\n fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();\n }\n }\n else\n fnStr += st_1;\n }\n else\n td[k] = v;\n }\n return fnStr;\n};\nvar ch = [];\n// clone bufs\nvar cbfs = function (v) {\n var tl = [];\n for (var k in v) {\n if (v[k].buffer) {\n tl.push((v[k] = new v[k].constructor(v[k])).buffer);\n }\n }\n return tl;\n};\n// use a worker to execute code\nvar wrkr = function (fns, init, id, cb) {\n if (!ch[id]) {\n var fnStr = '', td_1 = {}, m = fns.length - 1;\n for (var i = 0; i < m; ++i)\n fnStr = wcln(fns[i], fnStr, td_1);\n ch[id] = { c: wcln(fns[m], fnStr, td_1), e: td_1 };\n }\n var td = mrg({}, ch[id].e);\n return wk(ch[id].c + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);\n};\n// base async inflate fn\nvar bInflt = function () { return [u8, u16, i32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, ec, hMap, max, bits, bits16, shft, slc, err, inflt, inflateSync, pbf, gopt]; };\nvar bDflt = function () { return [u8, u16, i32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };\n// gzip extra\nvar gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };\n// gunzip extra\nvar guze = function () { return [gzs, gzl]; };\n// zlib extra\nvar zle = function () { return [zlh, wbytes, adler]; };\n// unzlib extra\nvar zule = function () { return [zls]; };\n// post buf\nvar pbf = function (msg) { return postMessage(msg, [msg.buffer]); };\n// get opts\nvar gopt = function (o) { return o && {\n out: o.size && new u8(o.size),\n dictionary: o.dictionary\n}; };\n// async helper\nvar cbify = function (dat, opts, fns, init, id, cb) {\n var w = wrkr(fns, init, id, function (err, dat) {\n w.terminate();\n cb(err, dat);\n });\n w.postMessage([dat, opts], opts.consume ? [dat.buffer] : []);\n return function () { w.terminate(); };\n};\n// auto stream\nvar astrm = function (strm) {\n strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };\n return function (ev) {\n if (ev.data.length) {\n strm.push(ev.data[0], ev.data[1]);\n postMessage([ev.data[0].length]);\n }\n else\n strm.flush();\n };\n};\n// async stream attach\nvar astrmify = function (fns, strm, opts, init, id, flush, ext) {\n var t;\n var w = wrkr(fns, init, id, function (err, dat) {\n if (err)\n w.terminate(), strm.ondata.call(strm, err);\n else if (!Array.isArray(dat))\n ext(dat);\n else if (dat.length == 1) {\n strm.queuedSize -= dat[0];\n if (strm.ondrain)\n strm.ondrain(dat[0]);\n }\n else {\n if (dat[1])\n w.terminate();\n strm.ondata.call(strm, err, dat[0], dat[1]);\n }\n });\n w.postMessage(opts);\n strm.queuedSize = 0;\n strm.push = function (d, f) {\n if (!strm.ondata)\n err(5);\n if (t)\n strm.ondata(err(4, 0, 1), null, !!f);\n strm.queuedSize += d.length;\n w.postMessage([d, t = f], [d.buffer]);\n };\n strm.terminate = function () { w.terminate(); };\n if (flush) {\n strm.flush = function () { w.postMessage([]); };\n }\n};\n// read 2 bytes\nvar b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };\n// read 4 bytes\nvar b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; };\nvar b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); };\n// write bytes\nvar wbytes = function (d, b, v) {\n for (; v; ++b)\n d[b] = v, v >>>= 8;\n};\n// gzip header\nvar gzh = function (c, o) {\n var fn = o.filename;\n c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix\n if (o.mtime != 0)\n wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));\n if (fn) {\n c[3] = 8;\n for (var i = 0; i <= fn.length; ++i)\n c[i + 10] = fn.charCodeAt(i);\n }\n};\n// gzip footer: -8 to -4 = CRC, -4 to -0 is length\n// gzip start\nvar gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n err(6, 'invalid gzip data');\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += (d[10] | d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n};\n// gzip length\nvar gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;\n};\n// gzip header length\nvar gzhl = function (o) { return 10 + (o.filename ? o.filename.length + 1 : 0); };\n// zlib header\nvar zlh = function (c, o) {\n var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;\n c[0] = 120, c[1] = (fl << 6) | (o.dictionary && 32);\n c[1] |= 31 - ((c[0] << 8) | c[1]) % 31;\n if (o.dictionary) {\n var h = adler();\n h.p(o.dictionary);\n wbytes(c, 2, h.d());\n }\n};\n// zlib start\nvar zls = function (d, dict) {\n if ((d[0] & 15) != 8 || (d[0] >> 4) > 7 || ((d[0] << 8 | d[1]) % 31))\n err(6, 'invalid zlib data');\n if ((d[1] >> 5 & 1) == +!dict)\n err(6, 'invalid zlib data: ' + (d[1] & 32 ? 'need' : 'unexpected') + ' dictionary');\n return (d[1] >> 3 & 4) + 2;\n};\nfunction StrmOpt(opts, cb) {\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n return opts;\n}\n/**\n * Streaming DEFLATE compression\n */\nvar Deflate = /*#__PURE__*/ (function () {\n function Deflate(opts, cb) {\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n this.o = opts || {};\n this.s = { l: 0, i: 32768, w: 32768, z: 32768 };\n // Buffer length must always be 0 mod 32768 for index calculations to be correct when modifying head and prev\n // 98304 = 32768 (lookback) + 65536 (common chunk size)\n this.b = new u8(98304);\n if (this.o.dictionary) {\n var dict = this.o.dictionary.subarray(-32768);\n this.b.set(dict, 32768 - dict.length);\n this.s.i = 32768 - dict.length;\n }\n }\n Deflate.prototype.p = function (c, f) {\n this.ondata(dopt(c, this.o, 0, 0, this.s), f);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Deflate.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (this.s.l)\n err(4);\n var endLen = chunk.length + this.s.z;\n if (endLen > this.b.length) {\n if (endLen > 2 * this.b.length - 32768) {\n var newBuf = new u8(endLen & -32768);\n newBuf.set(this.b.subarray(0, this.s.z));\n this.b = newBuf;\n }\n var split = this.b.length - this.s.z;\n this.b.set(chunk.subarray(0, split), this.s.z);\n this.s.z = this.b.length;\n this.p(this.b, false);\n this.b.set(this.b.subarray(-32768));\n this.b.set(chunk.subarray(split), 32768);\n this.s.z = chunk.length - split + 32768;\n this.s.i = 32766, this.s.w = 32768;\n }\n else {\n this.b.set(chunk, this.s.z);\n this.s.z += chunk.length;\n }\n this.s.l = final & 1;\n if (this.s.z > this.s.w + 8191 || final) {\n this.p(this.b, final || false);\n this.s.w = this.s.i, this.s.i -= 2;\n }\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * deflated output for small inputs.\n */\n Deflate.prototype.flush = function () {\n if (!this.ondata)\n err(5);\n if (this.s.l)\n err(4);\n this.p(this.b, false);\n this.s.w = this.s.i, this.s.i -= 2;\n };\n return Deflate;\n}());\nexport { Deflate };\n/**\n * Asynchronous streaming DEFLATE compression\n */\nvar AsyncDeflate = /*#__PURE__*/ (function () {\n function AsyncDeflate(opts, cb) {\n astrmify([\n bDflt,\n function () { return [astrm, Deflate]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Deflate(ev.data);\n onmessage = astrm(strm);\n }, 6, 1);\n }\n return AsyncDeflate;\n}());\nexport { AsyncDeflate };\nexport function deflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);\n}\n/**\n * Compresses data with DEFLATE without any wrapper\n * @param data The data to compress\n * @param opts The compression options\n * @returns The deflated version of the data\n */\nexport function deflateSync(data, opts) {\n return dopt(data, opts || {}, 0, 0);\n}\n/**\n * Streaming DEFLATE decompression\n */\nvar Inflate = /*#__PURE__*/ (function () {\n function Inflate(opts, cb) {\n // no StrmOpt here to avoid adding to workerizer\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n var dict = opts && opts.dictionary && opts.dictionary.subarray(-32768);\n this.s = { i: 0, b: dict ? dict.length : 0 };\n this.o = new u8(32768);\n this.p = new u8(0);\n if (dict)\n this.o.set(dict);\n }\n Inflate.prototype.e = function (c) {\n if (!this.ondata)\n err(5);\n if (this.d)\n err(4);\n if (!this.p.length)\n this.p = c;\n else if (c.length) {\n var n = new u8(this.p.length + c.length);\n n.set(this.p), n.set(c, this.p.length), this.p = n;\n }\n };\n Inflate.prototype.c = function (final) {\n this.s.i = +(this.d = final || false);\n var bts = this.s.b;\n var dt = inflt(this.p, this.s, this.o);\n this.ondata(slc(dt, bts, this.s.b), this.d);\n this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;\n this.p = slc(this.p, (this.s.p / 8) | 0), this.s.p &= 7;\n };\n /**\n * Pushes a chunk to be inflated\n * @param chunk The chunk to push\n * @param final Whether this is the final chunk\n */\n Inflate.prototype.push = function (chunk, final) {\n this.e(chunk), this.c(final);\n };\n return Inflate;\n}());\nexport { Inflate };\n/**\n * Asynchronous streaming DEFLATE decompression\n */\nvar AsyncInflate = /*#__PURE__*/ (function () {\n function AsyncInflate(opts, cb) {\n astrmify([\n bInflt,\n function () { return [astrm, Inflate]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Inflate(ev.data);\n onmessage = astrm(strm);\n }, 7, 0);\n }\n return AsyncInflate;\n}());\nexport { AsyncInflate };\nexport function inflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt\n ], function (ev) { return pbf(inflateSync(ev.data[0], gopt(ev.data[1]))); }, 1, cb);\n}\n/**\n * Expands DEFLATE data with no wrapper\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\nexport function inflateSync(data, opts) {\n return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);\n}\n// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.\n/**\n * Streaming GZIP compression\n */\nvar Gzip = /*#__PURE__*/ (function () {\n function Gzip(opts, cb) {\n this.c = crc();\n this.l = 0;\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gzip.prototype.push = function (chunk, final) {\n this.c.p(chunk);\n this.l += chunk.length;\n Deflate.prototype.push.call(this, chunk, final);\n };\n Gzip.prototype.p = function (c, f) {\n var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, this.s);\n if (this.v)\n gzh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);\n this.ondata(raw, f);\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * GZIPped output for small inputs.\n */\n Gzip.prototype.flush = function () {\n Deflate.prototype.flush.call(this);\n };\n return Gzip;\n}());\nexport { Gzip };\n/**\n * Asynchronous streaming GZIP compression\n */\nvar AsyncGzip = /*#__PURE__*/ (function () {\n function AsyncGzip(opts, cb) {\n astrmify([\n bDflt,\n gze,\n function () { return [astrm, Deflate, Gzip]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Gzip(ev.data);\n onmessage = astrm(strm);\n }, 8, 1);\n }\n return AsyncGzip;\n}());\nexport { AsyncGzip };\nexport function gzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n gze,\n function () { return [gzipSync]; }\n ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);\n}\n/**\n * Compresses data with GZIP\n * @param data The data to compress\n * @param opts The compression options\n * @returns The gzipped version of the data\n */\nexport function gzipSync(data, opts) {\n if (!opts)\n opts = {};\n var c = crc(), l = data.length;\n c.p(data);\n var d = dopt(data, opts, gzhl(opts), 8), s = d.length;\n return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;\n}\n/**\n * Streaming single or multi-member GZIP decompression\n */\nvar Gunzip = /*#__PURE__*/ (function () {\n function Gunzip(opts, cb) {\n this.v = 1;\n this.r = 0;\n Inflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GUNZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gunzip.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n this.r += chunk.length;\n if (this.v) {\n var p = this.p.subarray(this.v - 1);\n var s = p.length > 3 ? gzs(p) : 4;\n if (s > p.length) {\n if (!final)\n return;\n }\n else if (this.v > 1 && this.onmember) {\n this.onmember(this.r - p.length);\n }\n this.p = p.subarray(s), this.v = 0;\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n // process concatenated GZIP\n if (this.s.f && !this.s.l && !final) {\n this.v = shft(this.s.p) + 9;\n this.s = { i: 0 };\n this.o = new u8(0);\n this.push(new u8(0), final);\n }\n };\n return Gunzip;\n}());\nexport { Gunzip };\n/**\n * Asynchronous streaming single or multi-member GZIP decompression\n */\nvar AsyncGunzip = /*#__PURE__*/ (function () {\n function AsyncGunzip(opts, cb) {\n var _this = this;\n astrmify([\n bInflt,\n guze,\n function () { return [astrm, Inflate, Gunzip]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Gunzip(ev.data);\n strm.onmember = function (offset) { return postMessage(offset); };\n onmessage = astrm(strm);\n }, 9, 0, function (offset) { return _this.onmember && _this.onmember(offset); });\n }\n return AsyncGunzip;\n}());\nexport { AsyncGunzip };\nexport function gunzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt,\n guze,\n function () { return [gunzipSync]; }\n ], function (ev) { return pbf(gunzipSync(ev.data[0], ev.data[1])); }, 3, cb);\n}\n/**\n * Expands GZIP data\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\nexport function gunzipSync(data, opts) {\n var st = gzs(data);\n if (st + 8 > data.length)\n err(6, 'invalid gzip data');\n return inflt(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary);\n}\n/**\n * Streaming Zlib compression\n */\nvar Zlib = /*#__PURE__*/ (function () {\n function Zlib(opts, cb) {\n this.c = adler();\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be zlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Zlib.prototype.push = function (chunk, final) {\n this.c.p(chunk);\n Deflate.prototype.push.call(this, chunk, final);\n };\n Zlib.prototype.p = function (c, f) {\n var raw = dopt(c, this.o, this.v && (this.o.dictionary ? 6 : 2), f && 4, this.s);\n if (this.v)\n zlh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 4, this.c.d());\n this.ondata(raw, f);\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * zlibbed output for small inputs.\n */\n Zlib.prototype.flush = function () {\n Deflate.prototype.flush.call(this);\n };\n return Zlib;\n}());\nexport { Zlib };\n/**\n * Asynchronous streaming Zlib compression\n */\nvar AsyncZlib = /*#__PURE__*/ (function () {\n function AsyncZlib(opts, cb) {\n astrmify([\n bDflt,\n zle,\n function () { return [astrm, Deflate, Zlib]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Zlib(ev.data);\n onmessage = astrm(strm);\n }, 10, 1);\n }\n return AsyncZlib;\n}());\nexport { AsyncZlib };\nexport function zlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n zle,\n function () { return [zlibSync]; }\n ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);\n}\n/**\n * Compress data with Zlib\n * @param data The data to compress\n * @param opts The compression options\n * @returns The zlib-compressed version of the data\n */\nexport function zlibSync(data, opts) {\n if (!opts)\n opts = {};\n var a = adler();\n a.p(data);\n var d = dopt(data, opts, opts.dictionary ? 6 : 2, 4);\n return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;\n}\n/**\n * Streaming Zlib decompression\n */\nvar Unzlib = /*#__PURE__*/ (function () {\n function Unzlib(opts, cb) {\n Inflate.call(this, opts, cb);\n this.v = opts && opts.dictionary ? 2 : 1;\n }\n /**\n * Pushes a chunk to be unzlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzlib.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n if (this.p.length < 6 && !final)\n return;\n this.p = this.p.subarray(zls(this.p, this.v - 1)), this.v = 0;\n }\n if (final) {\n if (this.p.length < 4)\n err(6, 'invalid zlib data');\n this.p = this.p.subarray(0, -4);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Unzlib;\n}());\nexport { Unzlib };\n/**\n * Asynchronous streaming Zlib decompression\n */\nvar AsyncUnzlib = /*#__PURE__*/ (function () {\n function AsyncUnzlib(opts, cb) {\n astrmify([\n bInflt,\n zule,\n function () { return [astrm, Inflate, Unzlib]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Unzlib(ev.data);\n onmessage = astrm(strm);\n }, 11, 0);\n }\n return AsyncUnzlib;\n}());\nexport { AsyncUnzlib };\nexport function unzlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt,\n zule,\n function () { return [unzlibSync]; }\n ], function (ev) { return pbf(unzlibSync(ev.data[0], gopt(ev.data[1]))); }, 5, cb);\n}\n/**\n * Expands Zlib data\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\nexport function unzlibSync(data, opts) {\n return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary);\n}\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzip as compress, AsyncGzip as AsyncCompress };\nexport { gzipSync as compressSync, Gzip as Compress };\n/**\n * Streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar Decompress = /*#__PURE__*/ (function () {\n function Decompress(opts, cb) {\n this.o = StrmOpt.call(this, opts, cb) || {};\n this.G = Gunzip;\n this.I = Inflate;\n this.Z = Unzlib;\n }\n // init substream\n // overriden by AsyncDecompress\n Decompress.prototype.i = function () {\n var _this = this;\n this.s.ondata = function (dat, final) {\n _this.ondata(dat, final);\n };\n };\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Decompress.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (!this.s) {\n if (this.p && this.p.length) {\n var n = new u8(this.p.length + chunk.length);\n n.set(this.p), n.set(chunk, this.p.length);\n }\n else\n this.p = chunk;\n if (this.p.length > 2) {\n this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)\n ? new this.G(this.o)\n : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))\n ? new this.I(this.o)\n : new this.Z(this.o);\n this.i();\n this.s.push(this.p, final);\n this.p = null;\n }\n }\n else\n this.s.push(chunk, final);\n };\n return Decompress;\n}());\nexport { Decompress };\n/**\n * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar AsyncDecompress = /*#__PURE__*/ (function () {\n function AsyncDecompress(opts, cb) {\n Decompress.call(this, opts, cb);\n this.queuedSize = 0;\n this.G = AsyncGunzip;\n this.I = AsyncInflate;\n this.Z = AsyncUnzlib;\n }\n AsyncDecompress.prototype.i = function () {\n var _this = this;\n this.s.ondata = function (err, dat, final) {\n _this.ondata(err, dat, final);\n };\n this.s.ondrain = function (size) {\n _this.queuedSize -= size;\n if (_this.ondrain)\n _this.ondrain(size);\n };\n };\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncDecompress.prototype.push = function (chunk, final) {\n this.queuedSize += chunk.length;\n Decompress.prototype.push.call(this, chunk, final);\n };\n return AsyncDecompress;\n}());\nexport { AsyncDecompress };\nexport function decompress(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzip(data, opts, cb)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflate(data, opts, cb)\n : unzlib(data, opts, cb);\n}\n/**\n * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\nexport function decompressSync(data, opts) {\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzipSync(data, opts)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflateSync(data, opts)\n : unzlibSync(data, opts);\n}\n// flatten a directory structure\nvar fltn = function (d, p, t, o) {\n for (var k in d) {\n var val = d[k], n = p + k, op = o;\n if (Array.isArray(val))\n op = mrg(o, val[1]), val = val[0];\n if (val instanceof u8)\n t[n] = [val, op];\n else {\n t[n += '/'] = [new u8(0), op];\n fltn(val, n, t, o);\n }\n }\n};\n// text encoder\nvar te = typeof TextEncoder != 'undefined' && /*#__PURE__*/ new TextEncoder();\n// text decoder\nvar td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();\n// text decoder stream\nvar tds = 0;\ntry {\n td.decode(et, { stream: true });\n tds = 1;\n}\ncatch (e) { }\n// decode UTF8\nvar dutf8 = function (d) {\n for (var r = '', i = 0;;) {\n var c = d[i++];\n var eb = (c > 127) + (c > 223) + (c > 239);\n if (i + eb > d.length)\n return { s: r, r: slc(d, i - 1) };\n if (!eb)\n r += String.fromCharCode(c);\n else if (eb == 3) {\n c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536,\n r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));\n }\n else if (eb & 1)\n r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63));\n else\n r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63));\n }\n};\n/**\n * Streaming UTF-8 decoding\n */\nvar DecodeUTF8 = /*#__PURE__*/ (function () {\n /**\n * Creates a UTF-8 decoding stream\n * @param cb The callback to call whenever data is decoded\n */\n function DecodeUTF8(cb) {\n this.ondata = cb;\n if (tds)\n this.t = new TextDecoder();\n else\n this.p = et;\n }\n /**\n * Pushes a chunk to be decoded from UTF-8 binary\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n DecodeUTF8.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n final = !!final;\n if (this.t) {\n this.ondata(this.t.decode(chunk, { stream: true }), final);\n if (final) {\n if (this.t.decode().length)\n err(8);\n this.t = null;\n }\n return;\n }\n if (!this.p)\n err(4);\n var dat = new u8(this.p.length + chunk.length);\n dat.set(this.p);\n dat.set(chunk, this.p.length);\n var _a = dutf8(dat), s = _a.s, r = _a.r;\n if (final) {\n if (r.length)\n err(8);\n this.p = null;\n }\n else\n this.p = r;\n this.ondata(s, final);\n };\n return DecodeUTF8;\n}());\nexport { DecodeUTF8 };\n/**\n * Streaming UTF-8 encoding\n */\nvar EncodeUTF8 = /*#__PURE__*/ (function () {\n /**\n * Creates a UTF-8 decoding stream\n * @param cb The callback to call whenever data is encoded\n */\n function EncodeUTF8(cb) {\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be encoded to UTF-8\n * @param chunk The string data to push\n * @param final Whether this is the last chunk\n */\n EncodeUTF8.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (this.d)\n err(4);\n this.ondata(strToU8(chunk), this.d = final || false);\n };\n return EncodeUTF8;\n}());\nexport { EncodeUTF8 };\n/**\n * Converts a string into a Uint8Array for use with compression/decompression methods\n * @param str The string to encode\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless decoding a binary string.\n * @returns The string encoded in UTF-8/Latin-1 binary\n */\nexport function strToU8(str, latin1) {\n if (latin1) {\n var ar_1 = new u8(str.length);\n for (var i = 0; i < str.length; ++i)\n ar_1[i] = str.charCodeAt(i);\n return ar_1;\n }\n if (te)\n return te.encode(str);\n var l = str.length;\n var ar = new u8(str.length + (str.length >> 1));\n var ai = 0;\n var w = function (v) { ar[ai++] = v; };\n for (var i = 0; i < l; ++i) {\n if (ai + 5 > ar.length) {\n var n = new u8(ai + 8 + ((l - i) << 1));\n n.set(ar);\n ar = n;\n }\n var c = str.charCodeAt(i);\n if (c < 128 || latin1)\n w(c);\n else if (c < 2048)\n w(192 | (c >> 6)), w(128 | (c & 63));\n else if (c > 55295 && c < 57344)\n c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023),\n w(240 | (c >> 18)), w(128 | ((c >> 12) & 63)), w(128 | ((c >> 6) & 63)), w(128 | (c & 63));\n else\n w(224 | (c >> 12)), w(128 | ((c >> 6) & 63)), w(128 | (c & 63));\n }\n return slc(ar, 0, ai);\n}\n/**\n * Converts a Uint8Array to a string\n * @param dat The data to decode to string\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless encoding to binary string.\n * @returns The original UTF-8/Latin-1 string\n */\nexport function strFromU8(dat, latin1) {\n if (latin1) {\n var r = '';\n for (var i = 0; i < dat.length; i += 16384)\n r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));\n return r;\n }\n else if (td) {\n return td.decode(dat);\n }\n else {\n var _a = dutf8(dat), s = _a.s, r = _a.r;\n if (r.length)\n err(8);\n return s;\n }\n}\n;\n// deflate bit flag\nvar dbf = function (l) { return l == 1 ? 3 : l < 6 ? 2 : l == 9 ? 1 : 0; };\n// skip local zip header\nvar slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };\n// read zip header\nvar zh = function (d, b, z) {\n var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);\n var _a = z && bs == 4294967295 ? z64e(d, es) : [bs, b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];\n return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];\n};\n// read zip64 extra field\nvar z64e = function (d, b) {\n for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))\n ;\n return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];\n};\n// extra field length\nvar exfl = function (ex) {\n var le = 0;\n if (ex) {\n for (var k in ex) {\n var l = ex[k].length;\n if (l > 65535)\n err(9);\n le += l + 4;\n }\n }\n return le;\n};\n// write zip header\nvar wzh = function (d, b, f, fn, u, c, ce, co) {\n var fl = fn.length, ex = f.extra, col = co && co.length;\n var exl = exfl(ex);\n wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;\n if (ce != null)\n d[b++] = 20, d[b++] = f.os;\n d[b] = 20, b += 2; // spec compliance? what's that?\n d[b++] = (f.flag << 1) | (c < 0 && 8), d[b++] = u && 8;\n d[b++] = f.compression & 255, d[b++] = f.compression >> 8;\n var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;\n if (y < 0 || y > 119)\n err(10);\n wbytes(d, b, (y << 25) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >> 1)), b += 4;\n if (c != -1) {\n wbytes(d, b, f.crc);\n wbytes(d, b + 4, c < 0 ? -c - 2 : c);\n wbytes(d, b + 8, f.size);\n }\n wbytes(d, b + 12, fl);\n wbytes(d, b + 14, exl), b += 16;\n if (ce != null) {\n wbytes(d, b, col);\n wbytes(d, b + 6, f.attrs);\n wbytes(d, b + 10, ce), b += 14;\n }\n d.set(fn, b);\n b += fl;\n if (exl) {\n for (var k in ex) {\n var exf = ex[k], l = exf.length;\n wbytes(d, b, +k);\n wbytes(d, b + 2, l);\n d.set(exf, b + 4), b += 4 + l;\n }\n }\n if (col)\n d.set(co, b), b += col;\n return b;\n};\n// write zip footer (end of central directory)\nvar wzf = function (o, b, c, d, e) {\n wbytes(o, b, 0x6054B50); // skip disk\n wbytes(o, b + 8, c);\n wbytes(o, b + 10, c);\n wbytes(o, b + 12, d);\n wbytes(o, b + 16, e);\n};\n/**\n * A pass-through stream to keep data uncompressed in a ZIP archive.\n */\nvar ZipPassThrough = /*#__PURE__*/ (function () {\n /**\n * Creates a pass-through stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n */\n function ZipPassThrough(filename) {\n this.filename = filename;\n this.c = crc();\n this.size = 0;\n this.compression = 0;\n }\n /**\n * Processes a chunk and pushes to the output stream. You can override this\n * method in a subclass for custom behavior, but by default this passes\n * the data through. You must call this.ondata(err, chunk, final) at some\n * point in this method.\n * @param chunk The chunk to process\n * @param final Whether this is the last chunk\n */\n ZipPassThrough.prototype.process = function (chunk, final) {\n this.ondata(null, chunk, final);\n };\n /**\n * Pushes a chunk to be added. If you are subclassing this with a custom\n * compression algorithm, note that you must push data from the source\n * file only, pre-compression.\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n ZipPassThrough.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n this.c.p(chunk);\n this.size += chunk.length;\n if (final)\n this.crc = this.c.d();\n this.process(chunk, final || false);\n };\n return ZipPassThrough;\n}());\nexport { ZipPassThrough };\n// I don't extend because TypeScript extension adds 1kB of runtime bloat\n/**\n * Streaming DEFLATE compression for ZIP archives. Prefer using AsyncZipDeflate\n * for better performance\n */\nvar ZipDeflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n * @param opts The compression options\n */\n function ZipDeflate(filename, opts) {\n var _this = this;\n if (!opts)\n opts = {};\n ZipPassThrough.call(this, filename);\n this.d = new Deflate(opts, function (dat, final) {\n _this.ondata(null, dat, final);\n });\n this.compression = 8;\n this.flag = dbf(opts.level);\n }\n ZipDeflate.prototype.process = function (chunk, final) {\n try {\n this.d.push(chunk, final);\n }\n catch (e) {\n this.ondata(e, null, final);\n }\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n ZipDeflate.prototype.push = function (chunk, final) {\n ZipPassThrough.prototype.push.call(this, chunk, final);\n };\n return ZipDeflate;\n}());\nexport { ZipDeflate };\n/**\n * Asynchronous streaming DEFLATE compression for ZIP archives\n */\nvar AsyncZipDeflate = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous DEFLATE stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n * @param opts The compression options\n */\n function AsyncZipDeflate(filename, opts) {\n var _this = this;\n if (!opts)\n opts = {};\n ZipPassThrough.call(this, filename);\n this.d = new AsyncDeflate(opts, function (err, dat, final) {\n _this.ondata(err, dat, final);\n });\n this.compression = 8;\n this.flag = dbf(opts.level);\n this.terminate = this.d.terminate;\n }\n AsyncZipDeflate.prototype.process = function (chunk, final) {\n this.d.push(chunk, final);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncZipDeflate.prototype.push = function (chunk, final) {\n ZipPassThrough.prototype.push.call(this, chunk, final);\n };\n return AsyncZipDeflate;\n}());\nexport { AsyncZipDeflate };\n// TODO: Better tree shaking\n/**\n * A zippable archive to which files can incrementally be added\n */\nvar Zip = /*#__PURE__*/ (function () {\n /**\n * Creates an empty ZIP archive to which files can be added\n * @param cb The callback to call whenever data for the generated ZIP archive\n * is available\n */\n function Zip(cb) {\n this.ondata = cb;\n this.u = [];\n this.d = 1;\n }\n /**\n * Adds a file to the ZIP archive\n * @param file The file stream to add\n */\n Zip.prototype.add = function (file) {\n var _this = this;\n if (!this.ondata)\n err(5);\n // finishing or finished\n if (this.d & 2)\n this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, false);\n else {\n var f = strToU8(file.filename), fl_1 = f.length;\n var com = file.comment, o = com && strToU8(com);\n var u = fl_1 != file.filename.length || (o && (com.length != o.length));\n var hl_1 = fl_1 + exfl(file.extra) + 30;\n if (fl_1 > 65535)\n this.ondata(err(11, 0, 1), null, false);\n var header = new u8(hl_1);\n wzh(header, 0, file, f, u, -1);\n var chks_1 = [header];\n var pAll_1 = function () {\n for (var _i = 0, chks_2 = chks_1; _i < chks_2.length; _i++) {\n var chk = chks_2[_i];\n _this.ondata(null, chk, false);\n }\n chks_1 = [];\n };\n var tr_1 = this.d;\n this.d = 0;\n var ind_1 = this.u.length;\n var uf_1 = mrg(file, {\n f: f,\n u: u,\n o: o,\n t: function () {\n if (file.terminate)\n file.terminate();\n },\n r: function () {\n pAll_1();\n if (tr_1) {\n var nxt = _this.u[ind_1 + 1];\n if (nxt)\n nxt.r();\n else\n _this.d = 1;\n }\n tr_1 = 1;\n }\n });\n var cl_1 = 0;\n file.ondata = function (err, dat, final) {\n if (err) {\n _this.ondata(err, dat, final);\n _this.terminate();\n }\n else {\n cl_1 += dat.length;\n chks_1.push(dat);\n if (final) {\n var dd = new u8(16);\n wbytes(dd, 0, 0x8074B50);\n wbytes(dd, 4, file.crc);\n wbytes(dd, 8, cl_1);\n wbytes(dd, 12, file.size);\n chks_1.push(dd);\n uf_1.c = cl_1, uf_1.b = hl_1 + cl_1 + 16, uf_1.crc = file.crc, uf_1.size = file.size;\n if (tr_1)\n uf_1.r();\n tr_1 = 1;\n }\n else if (tr_1)\n pAll_1();\n }\n };\n this.u.push(uf_1);\n }\n };\n /**\n * Ends the process of adding files and prepares to emit the final chunks.\n * This *must* be called after adding all desired files for the resulting\n * ZIP file to work properly.\n */\n Zip.prototype.end = function () {\n var _this = this;\n if (this.d & 2) {\n this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, true);\n return;\n }\n if (this.d)\n this.e();\n else\n this.u.push({\n r: function () {\n if (!(_this.d & 1))\n return;\n _this.u.splice(-1, 1);\n _this.e();\n },\n t: function () { }\n });\n this.d = 3;\n };\n Zip.prototype.e = function () {\n var bt = 0, l = 0, tl = 0;\n for (var _i = 0, _a = this.u; _i < _a.length; _i++) {\n var f = _a[_i];\n tl += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0);\n }\n var out = new u8(tl + 22);\n for (var _b = 0, _c = this.u; _b < _c.length; _b++) {\n var f = _c[_b];\n wzh(out, bt, f, f.f, f.u, -f.c - 2, l, f.o);\n bt += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0), l += f.b;\n }\n wzf(out, bt, this.u.length, tl, l);\n this.ondata(null, out, true);\n this.d = 2;\n };\n /**\n * A method to terminate any internal workers used by the stream. Subsequent\n * calls to add() will fail.\n */\n Zip.prototype.terminate = function () {\n for (var _i = 0, _a = this.u; _i < _a.length; _i++) {\n var f = _a[_i];\n f.t();\n }\n this.d = 2;\n };\n return Zip;\n}());\nexport { Zip };\nexport function zip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n var r = {};\n fltn(data, '', r, opts);\n var k = Object.keys(r);\n var lft = k.length, o = 0, tot = 0;\n var slft = lft, files = new Array(lft);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var cbd = function (a, b) {\n mt(function () { cb(a, b); });\n };\n mt(function () { cbd = cb; });\n var cbf = function () {\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n tot = 0;\n for (var i = 0; i < slft; ++i) {\n var f = files[i];\n try {\n var l = f.c.length;\n wzh(out, tot, f, f.f, f.u, l);\n var badd = 30 + f.f.length + exfl(f.extra);\n var loc = tot + badd;\n out.set(f.c, loc);\n wzh(out, o, f, f.f, f.u, l, tot, f.m), o += 16 + badd + (f.m ? f.m.length : 0), tot = loc + l;\n }\n catch (e) {\n return cbd(e, null);\n }\n }\n wzf(out, o, files.length, cdl, oe);\n cbd(null, out);\n };\n if (!lft)\n cbf();\n var _loop_1 = function (i) {\n var fn = k[i];\n var _a = r[fn], file = _a[0], p = _a[1];\n var c = crc(), size = file.length;\n c.p(file);\n var f = strToU8(fn), s = f.length;\n var com = p.comment, m = com && strToU8(com), ms = m && m.length;\n var exl = exfl(p.extra);\n var compression = p.level == 0 ? 0 : 8;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cbd(e, null);\n }\n else {\n var l = d.length;\n files[i] = mrg(p, {\n size: size,\n crc: c.d(),\n c: d,\n f: f,\n m: m,\n u: s != fn.length || (m && (com.length != ms)),\n compression: compression\n });\n o += 30 + s + exl + l;\n tot += 76 + 2 * (s + exl) + (ms || 0) + l;\n if (!--lft)\n cbf();\n }\n };\n if (s > 65535)\n cbl(err(11, 0, 1), null);\n if (!compression)\n cbl(null, file);\n else if (size < 160000) {\n try {\n cbl(null, deflateSync(file, p));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(deflate(file, p, cbl));\n };\n // Cannot use lft because it can decrease\n for (var i = 0; i < slft; ++i) {\n _loop_1(i);\n }\n return tAll;\n}\n/**\n * Synchronously creates a ZIP file. Prefer using `zip` for better performance\n * with more than one file.\n * @param data The directory structure for the ZIP archive\n * @param opts The main options, merged with per-file options\n * @returns The generated ZIP archive\n */\nexport function zipSync(data, opts) {\n if (!opts)\n opts = {};\n var r = {};\n var files = [];\n fltn(data, '', r, opts);\n var o = 0;\n var tot = 0;\n for (var fn in r) {\n var _a = r[fn], file = _a[0], p = _a[1];\n var compression = p.level == 0 ? 0 : 8;\n var f = strToU8(fn), s = f.length;\n var com = p.comment, m = com && strToU8(com), ms = m && m.length;\n var exl = exfl(p.extra);\n if (s > 65535)\n err(11);\n var d = compression ? deflateSync(file, p) : file, l = d.length;\n var c = crc();\n c.p(file);\n files.push(mrg(p, {\n size: file.length,\n crc: c.d(),\n c: d,\n f: f,\n m: m,\n u: s != fn.length || (m && (com.length != ms)),\n o: o,\n compression: compression\n }));\n o += 30 + s + exl + l;\n tot += 76 + 2 * (s + exl) + (ms || 0) + l;\n }\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n for (var i = 0; i < files.length; ++i) {\n var f = files[i];\n wzh(out, f.o, f, f.f, f.u, f.c.length);\n var badd = 30 + f.f.length + exfl(f.extra);\n out.set(f.c, f.o + badd);\n wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);\n }\n wzf(out, o, files.length, cdl, oe);\n return out;\n}\n/**\n * Streaming pass-through decompression for ZIP archives\n */\nvar UnzipPassThrough = /*#__PURE__*/ (function () {\n function UnzipPassThrough() {\n }\n UnzipPassThrough.prototype.push = function (data, final) {\n this.ondata(null, data, final);\n };\n UnzipPassThrough.compression = 0;\n return UnzipPassThrough;\n}());\nexport { UnzipPassThrough };\n/**\n * Streaming DEFLATE decompression for ZIP archives. Prefer AsyncZipInflate for\n * better performance.\n */\nvar UnzipInflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE decompression that can be used in ZIP archives\n */\n function UnzipInflate() {\n var _this = this;\n this.i = new Inflate(function (dat, final) {\n _this.ondata(null, dat, final);\n });\n }\n UnzipInflate.prototype.push = function (data, final) {\n try {\n this.i.push(data, final);\n }\n catch (e) {\n this.ondata(e, null, final);\n }\n };\n UnzipInflate.compression = 8;\n return UnzipInflate;\n}());\nexport { UnzipInflate };\n/**\n * Asynchronous streaming DEFLATE decompression for ZIP archives\n */\nvar AsyncUnzipInflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE decompression that can be used in ZIP archives\n */\n function AsyncUnzipInflate(_, sz) {\n var _this = this;\n if (sz < 320000) {\n this.i = new Inflate(function (dat, final) {\n _this.ondata(null, dat, final);\n });\n }\n else {\n this.i = new AsyncInflate(function (err, dat, final) {\n _this.ondata(err, dat, final);\n });\n this.terminate = this.i.terminate;\n }\n }\n AsyncUnzipInflate.prototype.push = function (data, final) {\n if (this.i.terminate)\n data = slc(data, 0);\n this.i.push(data, final);\n };\n AsyncUnzipInflate.compression = 8;\n return AsyncUnzipInflate;\n}());\nexport { AsyncUnzipInflate };\n/**\n * A ZIP archive decompression stream that emits files as they are discovered\n */\nvar Unzip = /*#__PURE__*/ (function () {\n /**\n * Creates a ZIP decompression stream\n * @param cb The callback to call whenever a file in the ZIP archive is found\n */\n function Unzip(cb) {\n this.onfile = cb;\n this.k = [];\n this.o = {\n 0: UnzipPassThrough\n };\n this.p = et;\n }\n /**\n * Pushes a chunk to be unzipped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzip.prototype.push = function (chunk, final) {\n var _this = this;\n if (!this.onfile)\n err(5);\n if (!this.p)\n err(4);\n if (this.c > 0) {\n var len = Math.min(this.c, chunk.length);\n var toAdd = chunk.subarray(0, len);\n this.c -= len;\n if (this.d)\n this.d.push(toAdd, !this.c);\n else\n this.k[0].push(toAdd);\n chunk = chunk.subarray(len);\n if (chunk.length)\n return this.push(chunk, final);\n }\n else {\n var f = 0, i = 0, is = void 0, buf = void 0;\n if (!this.p.length)\n buf = chunk;\n else if (!chunk.length)\n buf = this.p;\n else {\n buf = new u8(this.p.length + chunk.length);\n buf.set(this.p), buf.set(chunk, this.p.length);\n }\n var l = buf.length, oc = this.c, add = oc && this.d;\n var _loop_2 = function () {\n var _a;\n var sig = b4(buf, i);\n if (sig == 0x4034B50) {\n f = 1, is = i;\n this_1.d = null;\n this_1.c = 0;\n var bf = b2(buf, i + 6), cmp_1 = b2(buf, i + 8), u = bf & 2048, dd = bf & 8, fnl = b2(buf, i + 26), es = b2(buf, i + 28);\n if (l > i + 30 + fnl + es) {\n var chks_3 = [];\n this_1.k.unshift(chks_3);\n f = 2;\n var sc_1 = b4(buf, i + 18), su_1 = b4(buf, i + 22);\n var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);\n if (sc_1 == 4294967295) {\n _a = dd ? [-2] : z64e(buf, i), sc_1 = _a[0], su_1 = _a[1];\n }\n else if (dd)\n sc_1 = -1;\n i += es;\n this_1.c = sc_1;\n var d_1;\n var file_1 = {\n name: fn_1,\n compression: cmp_1,\n start: function () {\n if (!file_1.ondata)\n err(5);\n if (!sc_1)\n file_1.ondata(null, et, true);\n else {\n var ctr = _this.o[cmp_1];\n if (!ctr)\n file_1.ondata(err(14, 'unknown compression type ' + cmp_1, 1), null, false);\n d_1 = sc_1 < 0 ? new ctr(fn_1) : new ctr(fn_1, sc_1, su_1);\n d_1.ondata = function (err, dat, final) { file_1.ondata(err, dat, final); };\n for (var _i = 0, chks_4 = chks_3; _i < chks_4.length; _i++) {\n var dat = chks_4[_i];\n d_1.push(dat, false);\n }\n if (_this.k[0] == chks_3 && _this.c)\n _this.d = d_1;\n else\n d_1.push(et, true);\n }\n },\n terminate: function () {\n if (d_1 && d_1.terminate)\n d_1.terminate();\n }\n };\n if (sc_1 >= 0)\n file_1.size = sc_1, file_1.originalSize = su_1;\n this_1.onfile(file_1);\n }\n return \"break\";\n }\n else if (oc) {\n if (sig == 0x8074B50) {\n is = i += 12 + (oc == -2 && 8), f = 3, this_1.c = 0;\n return \"break\";\n }\n else if (sig == 0x2014B50) {\n is = i -= 4, f = 3, this_1.c = 0;\n return \"break\";\n }\n }\n };\n var this_1 = this;\n for (; i < l - 4; ++i) {\n var state_1 = _loop_2();\n if (state_1 === \"break\")\n break;\n }\n this.p = et;\n if (oc < 0) {\n var dat = f ? buf.subarray(0, is - 12 - (oc == -2 && 8) - (b4(buf, is - 16) == 0x8074B50 && 4)) : buf.subarray(0, i);\n if (add)\n add.push(dat, !!f);\n else\n this.k[+(f == 2)].push(dat);\n }\n if (f & 2)\n return this.push(buf.subarray(i), final);\n this.p = buf.subarray(i);\n }\n if (final) {\n if (this.c)\n err(13);\n this.p = null;\n }\n };\n /**\n * Registers a decoder with the stream, allowing for files compressed with\n * the compression type provided to be expanded correctly\n * @param decoder The decoder constructor\n */\n Unzip.prototype.register = function (decoder) {\n this.o[decoder.compression] = decoder;\n };\n return Unzip;\n}());\nexport { Unzip };\nvar mt = typeof queueMicrotask == 'function' ? queueMicrotask : typeof setTimeout == 'function' ? setTimeout : function (fn) { fn(); };\nexport function unzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var files = {};\n var cbd = function (a, b) {\n mt(function () { cb(a, b); });\n };\n mt(function () { cbd = cb; });\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558) {\n cbd(err(13, 0, 1), null);\n return tAll;\n }\n }\n ;\n var lft = b2(data, e + 8);\n if (lft) {\n var c = lft;\n var o = b4(data, e + 16);\n var z = o == 4294967295 || c == 65535;\n if (z) {\n var ze = b4(data, e - 12);\n z = b4(data, ze) == 0x6064B50;\n if (z) {\n c = lft = b4(data, ze + 32);\n o = b4(data, ze + 48);\n }\n }\n var fltr = opts && opts.filter;\n var _loop_3 = function (i) {\n var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cbd(e, null);\n }\n else {\n if (d)\n files[fn] = d;\n if (!--lft)\n cbd(null, files);\n }\n };\n if (!fltr || fltr({\n name: fn,\n size: sc,\n originalSize: su,\n compression: c_1\n })) {\n if (!c_1)\n cbl(null, slc(data, b, b + sc));\n else if (c_1 == 8) {\n var infl = data.subarray(b, b + sc);\n // Synchronously decompress under 512KB, or barely-compressed data\n if (su < 524288 || sc > 0.8 * su) {\n try {\n cbl(null, inflateSync(infl, { out: new u8(su) }));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(inflate(infl, { size: su }, cbl));\n }\n else\n cbl(err(14, 'unknown compression type ' + c_1, 1), null);\n }\n else\n cbl(null, null);\n };\n for (var i = 0; i < c; ++i) {\n _loop_3(i);\n }\n }\n else\n cbd(null, {});\n return tAll;\n}\n/**\n * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better\n * performance with more than one file.\n * @param data The raw compressed ZIP file\n * @param opts The ZIP extraction options\n * @returns The decompressed files\n */\nexport function unzipSync(data, opts) {\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558)\n err(13);\n }\n ;\n var c = b2(data, e + 8);\n if (!c)\n return {};\n var o = b4(data, e + 16);\n var z = o == 4294967295 || c == 65535;\n if (z) {\n var ze = b4(data, e - 12);\n z = b4(data, ze) == 0x6064B50;\n if (z) {\n c = b4(data, ze + 32);\n o = b4(data, ze + 48);\n }\n }\n var fltr = opts && opts.filter;\n for (var i = 0; i < c; ++i) {\n var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n if (!fltr || fltr({\n name: fn,\n size: sc,\n originalSize: su,\n compression: c_2\n })) {\n if (!c_2)\n files[fn] = slc(data, b, b + sc);\n else if (c_2 == 8)\n files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });\n else\n err(14, 'unknown compression type ' + c_2);\n }\n }\n return files;\n}\n","const e=(()=>{if(\"undefined\"==typeof self)return!1;if(\"top\"in self&&self!==top)try{top.window.document._=0}catch(e){return!1}return\"showOpenFilePicker\"in self})(),t=e?Promise.resolve().then(function(){return l}):Promise.resolve().then(function(){return v});async function n(...e){return(await t).default(...e)}const r=e?Promise.resolve().then(function(){return y}):Promise.resolve().then(function(){return b});async function i(...e){return(await r).default(...e)}const a=e?Promise.resolve().then(function(){return m}):Promise.resolve().then(function(){return k});async function o(...e){return(await a).default(...e)}const s=async e=>{const t=await e.getFile();return t.handle=e,t};var c=async(e=[{}])=>{Array.isArray(e)||(e=[e]);const t=[];e.forEach((e,n)=>{t[n]={description:e.description||\"Files\",accept:{}},e.mimeTypes?e.mimeTypes.map(r=>{t[n].accept[r]=e.extensions||[]}):t[n].accept[\"*/*\"]=e.extensions||[]});const n=await window.showOpenFilePicker({id:e[0].id,startIn:e[0].startIn,types:t,multiple:e[0].multiple||!1,excludeAcceptAllOption:e[0].excludeAcceptAllOption||!1}),r=await Promise.all(n.map(s));return e[0].multiple?r:r[0]},l={__proto__:null,default:c};function u(e){function t(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+\" is not an object.\"));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return u=function(e){this.s=e,this.n=e.next},u.prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var n=this.s.return;return void 0===n?Promise.resolve({value:e,done:!0}):t(n.apply(this.s,arguments))},throw:function(e){var n=this.s.return;return void 0===n?Promise.reject(e):t(n.apply(this.s,arguments))}},new u(e)}const p=async(e,t,n=e.name,r)=>{const i=[],a=[];var o,s=!1,c=!1;try{for(var l,d=function(e){var t,n,r,i=2;for(\"undefined\"!=typeof Symbol&&(n=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(n&&null!=(t=e[n]))return t.call(e);if(r&&null!=(t=e[r]))return new u(t.call(e));n=\"@@asyncIterator\",r=\"@@iterator\"}throw new TypeError(\"Object is not async iterable\")}(e.values());s=!(l=await d.next()).done;s=!1){const o=l.value,s=`${n}/${o.name}`;\"file\"===o.kind?a.push(o.getFile().then(t=>(t.directoryHandle=e,t.handle=o,Object.defineProperty(t,\"webkitRelativePath\",{configurable:!0,enumerable:!0,get:()=>s})))):\"directory\"!==o.kind||!t||r&&r(o)||i.push(p(o,t,s,r))}}catch(e){c=!0,o=e}finally{try{s&&null!=d.return&&await d.return()}finally{if(c)throw o}}return[...(await Promise.all(i)).flat(),...await Promise.all(a)]};var d=async(e={})=>{e.recursive=e.recursive||!1,e.mode=e.mode||\"read\";const t=await window.showDirectoryPicker({id:e.id,startIn:e.startIn,mode:e.mode});return(await(await t.values()).next()).done?[t]:p(t,e.recursive,void 0,e.skipDirectory)},y={__proto__:null,default:d},f=async(e,t=[{}],n=null,r=!1,i=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||\"Untitled\";const a=[];let o=null;if(e instanceof Blob&&e.type?o=e.type:e.headers&&e.headers.get(\"content-type\")&&(o=e.headers.get(\"content-type\")),t.forEach((e,t)=>{a[t]={description:e.description||\"Files\",accept:{}},e.mimeTypes?(0===t&&o&&e.mimeTypes.push(o),e.mimeTypes.map(n=>{a[t].accept[n]=e.extensions||[]})):o?a[t].accept[o]=e.extensions||[]:a[t].accept[\"*/*\"]=e.extensions||[]}),n)try{await n.getFile()}catch(e){if(n=null,r)throw e}const s=n||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:a,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!n&&i&&i(s);const c=await s.createWritable();if(\"stream\"in e){const t=e.stream();return await t.pipeTo(c),s}return\"body\"in e?(await e.body.pipeTo(c),s):(await c.write(await e),await c.close(),s)},m={__proto__:null,default:f},w=async(e=[{}])=>(Array.isArray(e)||(e=[e]),new Promise((t,n)=>{const r=document.createElement(\"input\");r.type=\"file\";const i=[...e.map(e=>e.mimeTypes||[]),...e.map(e=>e.extensions||[])].join();r.multiple=e[0].multiple||!1,r.accept=i||\"\",r.style.display=\"none\",document.body.append(r);const a=e=>{\"function\"==typeof o&&o(),t(e)},o=e[0].legacySetup&&e[0].legacySetup(a,()=>o(n),r),s=()=>{window.removeEventListener(\"focus\",s),r.remove()};r.addEventListener(\"click\",()=>{window.addEventListener(\"focus\",s)}),r.addEventListener(\"change\",()=>{window.removeEventListener(\"focus\",s),r.remove(),a(r.multiple?Array.from(r.files):r.files[0])}),\"showPicker\"in HTMLInputElement.prototype?r.showPicker():r.click()})),v={__proto__:null,default:w},h=async(e=[{}])=>(Array.isArray(e)||(e=[e]),e[0].recursive=e[0].recursive||!1,new Promise((t,n)=>{const r=document.createElement(\"input\");r.type=\"file\",r.webkitdirectory=!0;const i=e=>{\"function\"==typeof a&&a(),t(e)},a=e[0].legacySetup&&e[0].legacySetup(i,()=>a(n),r);r.addEventListener(\"change\",()=>{let t=Array.from(r.files);e[0].recursive?e[0].recursive&&e[0].skipDirectory&&(t=t.filter(t=>t.webkitRelativePath.split(\"/\").every(t=>!e[0].skipDirectory({name:t,kind:\"directory\"})))):t=t.filter(e=>2===e.webkitRelativePath.split(\"/\").length),i(t)}),\"showPicker\"in HTMLInputElement.prototype?r.showPicker():r.click()})),b={__proto__:null,default:h},P=async(e,t={})=>{Array.isArray(t)&&(t=t[0]);const n=document.createElement(\"a\");let r=e;\"body\"in e&&(r=await async function(e,t){const n=e.getReader(),r=new ReadableStream({start:e=>async function t(){return n.read().then(({done:n,value:r})=>{if(!n)return e.enqueue(r),t();e.close()})}()}),i=new Response(r),a=await i.blob();return n.releaseLock(),new Blob([a],{type:t})}(e.body,e.headers.get(\"content-type\"))),n.download=t.fileName||\"Untitled\",n.href=URL.createObjectURL(await r);const i=()=>{\"function\"==typeof a&&a()},a=t.legacySetup&&t.legacySetup(i,()=>a(),n);return n.addEventListener(\"click\",()=>{setTimeout(()=>URL.revokeObjectURL(n.href),3e4),i()}),n.click(),null},k={__proto__:null,default:P};export{i as directoryOpen,h as directoryOpenLegacy,d as directoryOpenModern,n as fileOpen,w as fileOpenLegacy,c as fileOpenModern,o as fileSave,P as fileSaveLegacy,f as fileSaveModern,e as supported};\n","import { openDB } from \"idb\";\nimport { zipSync, strToU8, unzipSync, strFromU8 } from \"fflate\";\nimport { fileSave } from \"browser-fs-access\";\nimport Globals from \"./globals\";\n\nexport class DB {\n constructor() {\n this.dbPromise = openDB(\"os-dpi\", 6, {\n async upgrade(db, oldVersion, _newVersion, transaction) {\n if (oldVersion < 6) {\n let logStore = db.createObjectStore(\"logstore\", {\n keyPath: \"id\",\n autoIncrement: true,\n });\n logStore.createIndex(\"by-name\", \"name\");\n }\n if (oldVersion < 5) {\n let store5 = db.createObjectStore(\"store5\", {\n keyPath: [\"name\", \"type\"],\n });\n store5.createIndex(\"by-name\", \"name\");\n if (oldVersion == 4) {\n // copy data from old store to new\n const store4 = transaction.objectStore(\"store\");\n for await (const cursor of store4) {\n const record4 = cursor.value;\n store5.put(record4);\n }\n db.deleteObjectStore(\"store\");\n // add an etag index to url store\n transaction.objectStore(\"url\").createIndex(\"by-etag\", \"etag\");\n } else if (oldVersion < 4) {\n db.createObjectStore(\"media\");\n let savedStore = db.createObjectStore(\"saved\", {\n keyPath: \"name\",\n });\n savedStore.createIndex(\"by-etag\", \"etag\");\n // track etags for urls\n const urlStore = db.createObjectStore(\"url\", {\n keyPath: \"url\",\n });\n // add an etag index to the url store\n urlStore.createIndex(\"by-etag\", \"etag\");\n }\n }\n },\n blocked(currentVersion, blockedVersion, event) {\n console.log(\"blocked\", { currentVersion, blockedVersion, event });\n },\n blocking(_currentVersion, _blockedVersion, _event) {\n window.location.reload();\n },\n terminated() {\n console.log(\"terminated\");\n },\n });\n this.updateListeners = [];\n this.designName = \"\";\n this.fileName = \"\";\n this.fileHandle = null;\n this.fileVersion = 0.0;\n this.fileUid = \"\";\n }\n\n /** set the name for the current design\n * @param {string} name\n */\n setDesignName(name) {\n this.designName = name;\n document.title = name;\n }\n\n /** rename the design\n * @param {string} newName\n */\n async renameDesign(newName) {\n const db = await this.dbPromise;\n newName = await this.uniqueName(newName);\n const tx = db.transaction([\"store5\", \"media\", \"saved\"], \"readwrite\");\n const index = tx.objectStore(\"store5\").index(\"by-name\");\n for await (const cursor of index.iterate(this.designName)) {\n const record = { ...cursor.value, name: newName };\n cursor.delete();\n tx.objectStore(\"store5\").put(record);\n }\n const mst = tx.objectStore(\"media\");\n for await (const cursor of mst.iterate()) {\n if (cursor && cursor.key[0] == this.designName) {\n const record = { ...cursor.value };\n const key = cursor.key;\n cursor.delete();\n key[0] = newName;\n mst.put(record, key);\n }\n }\n const cursor = await tx.objectStore(\"saved\").openCursor(this.designName);\n if (cursor) {\n cursor.delete();\n }\n await tx.done;\n this.fileHandle = null;\n this.fileName = \"\";\n\n this.notify({ action: \"rename\", name: this.designName, newName });\n this.designName = newName;\n }\n\n /**\n * return list of names of designs in the db\n * @returns {Promise}\n */\n async names() {\n const db = await this.dbPromise;\n const keys = await db.getAllKeysFromIndex(\"store5\", \"by-name\");\n const result = [...new Set(keys.map((key) => key.valueOf()[0]))];\n return result;\n }\n\n /**\n * return list of names of saved designs in the db\n * @returns {Promise}\n */\n async saved() {\n const db = await this.dbPromise;\n const result = [];\n for (const key of await db.getAllKeys(\"saved\")) {\n result.push(key.toString());\n }\n return result;\n }\n\n /**\n * Create a unique name for new design\n * @param {string} name - the desired name\n * @returns {Promise}\n */\n async uniqueName(name = \"new\") {\n // strip off any suffix\n name = name.replace(/\\.osdpi$|\\.zip$/, \"\");\n // strip any -number off the end of base\n name = name.replace(/-\\d+$/, \"\") || name;\n // replace characters we don't want with _\n name = name.replaceAll(/[^a-zA-Z0-9]/g, \"_\");\n // replace multiple _ with one\n name = name.replaceAll(/_+/g, \"_\");\n // remove trailing _\n name = name.replace(/_+$/, \"\");\n // remove leading _\n name = name.replace(/^_+/, \"\");\n // if we're left with nothing the call it noname\n name = name || \"noname\";\n const allNames = await this.names();\n if (allNames.indexOf(name) < 0) return name;\n const base = name;\n for (let i = 1; ; i++) {\n const name = `${base}-${i}`;\n if (allNames.indexOf(name) < 0) return name;\n }\n }\n\n /** Return the record for type or the defaultValue\n * @param {string} type\n * @param {any} defaultValue\n * @returns {Promise}\n */\n async read(type, defaultValue = {}) {\n const db = await this.dbPromise;\n const record = await db.get(\"store5\", [this.designName, type]);\n const data = record ? record.data : defaultValue;\n return data;\n }\n\n /**\n * Read log records\n *\n * @returns {Promise}\n */\n async readLog() {\n const db = await this.dbPromise;\n const index = db.transaction(\"logstore\", \"readonly\").store.index(\"by-name\");\n const key = this.designName;\n const result = [];\n for await (const cursor of index.iterate(key)) {\n const data = cursor.value.data;\n result.push(data);\n }\n return result;\n }\n\n /** Write a design record\n * @param {string} type\n * @param {Object} data\n */\n async write(type, data) {\n const db = await this.dbPromise;\n // do all this in a transaction\n const tx = db.transaction([\"store5\", \"saved\"], \"readwrite\");\n // note that this design has been updated\n await tx.objectStore(\"saved\").delete(this.designName);\n // add the record to the store\n const store = tx.objectStore(\"store5\");\n await store.put({ name: this.designName, type, data });\n await tx.done;\n\n this.notify({ action: \"update\", name: this.designName });\n }\n\n /** Write a log record\n * @param {Object} data\n */\n async writeLog(data) {\n const db = await this.dbPromise;\n const tx = db.transaction([\"logstore\"], \"readwrite\");\n tx.objectStore(\"logstore\").put({ name: this.designName, data });\n await tx.done;\n }\n\n /**\n * delete records of this type\n *\n * @param {string} type\n * @returns {Promise}\n */\n async clear(type) {\n const db = await this.dbPromise;\n return db.delete(\"store5\", [this.designName, type]);\n }\n\n /**\n * delete log records\n *\n * @returns {Promise}\n */\n async clearLog() {\n const db = await this.dbPromise;\n const tx = db.transaction(\"logstore\", \"readwrite\");\n const index = tx.store.index(\"by-name\");\n for await (const cursor of index.iterate(this.designName)) {\n cursor.delete();\n }\n await tx.done;\n }\n\n /** Read a design from a local file\n * @param {import(\"browser-fs-access\").FileWithHandle} file\n */\n async readDesignFromFile(file) {\n // keep the handle so we can save to it later\n this.fileHandle = file.handle;\n return this.readDesignFromBlob(file, file.name);\n }\n\n /** Read a design from a URL\n * @param {string} url\n * @param {string} [name]\n * @returns {Promise}\n */\n async readDesignFromURL(url, name = \"\") {\n if (!url) return false;\n let design_url = url;\n /** @type {Response} */\n let response;\n const db = await this.dbPromise;\n\n // a local URL\n if (!url.startsWith(\"http\")) {\n response = await fetch(url);\n } else {\n // allow for the url to point to HTML that contains the link\n if (!url.match(/.*\\.(osdpi|zip)$/)) {\n response = await fetch(\"https://gb.cs.unc.edu/cors/\", {\n headers: { \"Target-URL\": url },\n });\n if (!response.ok) {\n throw new Error(\n `Fetching the URL (${url}) failed: ${response.status}`,\n );\n }\n const html = await response.text();\n const parser = new DOMParser();\n const doc = parser.parseFromString(html, \"text/html\");\n // find the first link that matches the name\n const link =\n doc.querySelector(`a[href$=\"${name}.zip\"]`) ||\n doc.querySelector(`a[href$=\"${name}.osdpi\"]`);\n if (link instanceof HTMLAnchorElement) {\n design_url = link.href;\n } else {\n throw new Error(`Invalid URL ${url}`);\n }\n }\n // have we seen this url before?\n const urlRecord = await db.get(\"url\", design_url);\n /** @type {HeadersInit} */\n const headers = {}; // for the fetch\n if (urlRecord) {\n /** @type {string} */\n const etag = urlRecord.etag;\n // do we have any saved designs with this etag?\n const savedKey = await db.getKeyFromIndex(\"saved\", \"by-etag\", etag);\n if (savedKey) {\n // yes we have a previously saved design from this url\n // set the headers to check if it has changed\n headers[\"If-None-Match\"] = etag;\n name = savedKey.toString();\n }\n }\n headers[\"Target-URL\"] = design_url;\n\n response = await fetch(\"https://gb.cs.unc.edu/cors/\", { headers });\n }\n if (response.status == 304) {\n // we already have it\n this.designName = name;\n return false;\n }\n if (!response.ok) {\n throw new Error(`Fetching the URL (${url}) failed: ${response.status}`);\n }\n\n const etag = response.headers.get(\"ETag\") || \"\";\n await db.put(\"url\", { url: design_url, page_url: url, etag });\n\n if (!name) {\n const urlParts = new URL(design_url, window.location.origin);\n const pathParts = urlParts.pathname.split(\"/\");\n if (\n pathParts.length > 0 &&\n (pathParts[pathParts.length - 1].endsWith(\".osdpi\") ||\n pathParts[pathParts.length - 1].endsWith(\".zip\"))\n ) {\n name = pathParts[pathParts.length - 1];\n } else {\n throw new Error(`Design files should have .osdpi suffix`);\n }\n }\n\n const blob = await response.blob();\n\n // parse the URL\n return this.readDesignFromBlob(blob, name, etag);\n }\n\n /** Return the URL (if any) this design was imported from\n * @returns {Promise}\n */\n async getDesignURL() {\n const db = await this.dbPromise;\n\n const name = this.designName;\n\n // check saved\n const savedRecord = await db.get(\"saved\", name);\n if (savedRecord && savedRecord.etag && savedRecord.etag != \"none\") {\n // lookup the URL\n const etag = savedRecord.etag;\n const urlRecord = await db.getFromIndex(\"url\", \"by-etag\", etag);\n if (urlRecord) {\n const url = urlRecord.page_url;\n return url;\n }\n }\n return \"\";\n }\n\n /**\n * Reload the design from a URL if and only if:\n * 1. It was loaded from a URL\n * 2. It has not been edited\n * 3. The ETag has changed\n */\n async reloadDesignFromOriginalURL() {\n const url = await this.getDesignURL();\n if (url) {\n if (await this.readDesignFromURL(url)) {\n Globals.restart();\n }\n }\n }\n\n /** Read a design from a zip file\n * @param {Blob} blob\n * @param {string} filename\n * @param {string} etag\n * @returns {Promise}\n */\n async readDesignFromBlob(blob, filename, etag = \"\") {\n const db = await this.dbPromise;\n this.fileName = filename;\n\n const zippedBuf = await readAsArrayBuffer(blob);\n const zippedArray = new Uint8Array(zippedBuf);\n const unzipped = unzipSync(zippedArray);\n\n // normalize the fileName to make the design name\n let name = this.fileName;\n // make sure it is unique\n if (!etag) {\n name = await this.uniqueName(name);\n } else {\n name = name.replace(/\\.(zip|osdpi)$/, \"\");\n }\n\n this.designName = name;\n\n for (const fname in unzipped) {\n const mimetype = mime(fname) || \"application/octet-stream\";\n if (mimetype == \"application/json\") {\n const text = strFromU8(unzipped[fname]);\n let obj = {};\n try {\n obj = JSON.parse(text);\n } catch (e) {\n obj = {};\n console.trace(e);\n }\n const type = fname.split(\".\")[0];\n await this.write(type, obj);\n } else if (\n mimetype.startsWith(\"image\") ||\n mimetype.startsWith(\"audio\") ||\n mimetype.startsWith(\"video\")\n ) {\n const blob = new Blob([unzipped[fname]], {\n type: mimetype,\n });\n await db.put(\n \"media\",\n {\n name: fname,\n content: blob,\n },\n [name, fname],\n );\n }\n }\n await db.put(\"saved\", { name: this.designName, etag });\n this.notify({ action: \"update\", name: this.designName });\n return true;\n }\n\n // do this part async to avoid file picker timeout\n async convertDesignToBlob() {\n const db = await this.dbPromise;\n // collect the parts of the design\n const layout = Globals.layout.toObject();\n const actions = Globals.actions.toObject();\n const content = await this.read(\"content\");\n const method = Globals.method.toObject();\n const pattern = Globals.patterns.toObject();\n const cues = Globals.cues.toObject();\n\n const zipargs = {\n \"layout.json\": strToU8(JSON.stringify(layout)),\n \"actions.json\": strToU8(JSON.stringify(actions)),\n \"content.json\": strToU8(JSON.stringify(content)),\n \"method.json\": strToU8(JSON.stringify(method)),\n \"pattern.json\": strToU8(JSON.stringify(pattern)),\n \"cues.json\": strToU8(JSON.stringify(cues)),\n };\n\n const mediaKeys = (await db.getAllKeys(\"media\")).filter((pair) =>\n Object.values(pair).includes(this.designName),\n );\n\n // add the encoded image to the zipargs\n for (const key of mediaKeys) {\n const record = await db.get(\"media\", key);\n if (record) {\n const contentBuf = await record.content.arrayBuffer();\n const contentArray = new Uint8Array(contentBuf);\n zipargs[key[1]] = contentArray;\n }\n }\n\n // zip it\n const zip = zipSync(zipargs);\n // create a blob from the zipped result\n const blob = new Blob([zip], { type: \"application/octet-stream\" });\n return blob;\n }\n\n /** Save a design into a zip file\n */\n async saveDesign() {\n const db = await this.dbPromise;\n\n const options = {\n fileName: this.fileName || this.designName + \".osdpi\",\n extensions: [\".osdpi\", \".zip\"],\n id: \"osdpi\",\n };\n try {\n await fileSave(this.convertDesignToBlob(), options, this.fileHandle);\n await db.put(\"saved\", { name: this.designName });\n } catch (error) {\n console.error(\"Export failed\");\n console.error(error);\n }\n }\n\n /** Unload a design from the database\n * @param {string} name - the name of the design to delete\n */\n async unload(name) {\n const db = await this.dbPromise;\n const tx = db.transaction(\"store5\", \"readwrite\");\n const index = tx.store.index(\"by-name\");\n for await (const cursor of index.iterate(name)) {\n cursor.delete();\n }\n await tx.done;\n // delete media\n const txm = db.transaction(\"media\", \"readwrite\");\n const mediaKeys = (await txm.store.getAllKeys()).filter(\n (pair) => Object.values(pair)[0] == name,\n );\n\n // delete the media\n for (const key of mediaKeys) {\n await txm.store.delete(key);\n }\n await txm.done;\n await db.delete(\"saved\", name);\n this.notify({ action: \"unload\", name });\n }\n\n /** Return an image from the database\n * @param {string} name\n * @returns {Promise}\n */\n async getImage(name) {\n const db = await this.dbPromise;\n const record = await db.get(\"media\", [this.designName, name]);\n const img = new Image();\n if (record) {\n img.src = URL.createObjectURL(record.content);\n }\n img.title = record.name;\n return img;\n }\n\n /** Return an audio file from the database\n * @param {string} name\n * @returns {Promise}\n */\n async getAudio(name) {\n const db = await this.dbPromise;\n const record = await db.get(\"media\", [this.designName, name]);\n const audio = new Audio();\n if (record) {\n audio.src = URL.createObjectURL(record.content);\n }\n return audio;\n }\n\n /** Return an image URL from the database\n * @param {string} name\n * @returns {Promise}\n */\n async getMediaURL(name) {\n const db = await this.dbPromise;\n const record = await db.get(\"media\", [this.designName, name]);\n if (record) return URL.createObjectURL(record.content);\n else return \"\";\n }\n\n /** Add media to the database\n * @param {Blob} blob\n * @param {string} name\n */\n async addMedia(blob, name) {\n const db = await this.dbPromise;\n return await db.put(\n \"media\",\n {\n name: name,\n content: blob,\n },\n [this.designName, name],\n );\n }\n\n /** List media entries from a given store\n * @returns {Promise}\n * */\n async listMedia() {\n const db = await this.dbPromise;\n const keys = (await db.getAllKeys(\"media\")).filter(\n (key) => key[0] == this.designName, //only show resources from this design\n );\n const result = [];\n for (const key of keys) {\n result.push(key[1].toString());\n }\n return result;\n }\n\n /** delete media files\n * @param {string[]} names\n */\n async deleteMedia(...names) {\n const db = await this.dbPromise;\n const tx = db.transaction([\"media\", \"saved\"], \"readwrite\");\n const mst = tx.objectStore(\"media\");\n for await (const cursor of mst.iterate()) {\n if (\n cursor &&\n cursor.key[0] == this.designName &&\n names.includes(cursor.key[1])\n ) {\n cursor.delete();\n }\n }\n const cursor = await tx.objectStore(\"saved\").openCursor(this.designName);\n if (cursor) {\n cursor.delete();\n }\n await tx.done;\n }\n\n /** Listen for database update\n * @param {(message: UpdateNotification) =>void} callback\n */\n addUpdateListener(callback) {\n this.updateListeners.push(callback);\n }\n\n /** Notify listeners of database update\n * @param {UpdateNotification} message\n */\n notify(message) {\n for (const listener of this.updateListeners) {\n listener(message);\n }\n }\n}\n\nexport default new DB();\n\n/** Convert a blob into an array buffer\n * @param {Blob} blob */\nfunction readAsArrayBuffer(blob) {\n return new Promise((resolve) => {\n const fr = new FileReader();\n fr.onloadend = () => fr.result instanceof ArrayBuffer && resolve(fr.result);\n fr.readAsArrayBuffer(blob);\n });\n}\n\nconst mimetypes = {\n \".json\": \"application/json\",\n \".aac\": \"audio/aac\",\n \".mp3\": \"audio/mpeg\",\n \".mp4\": \"audio/mp4\",\n \".oga\": \"audio/ogg\",\n \".wav\": \"audio/wav\",\n \".weba\": \"audio/webm\",\n \".webm\": \"video/webm\",\n \".avif\": \"image/avif\",\n \".bmp\": \"image/bmp\",\n \".gif\": \"image/gif\",\n \".jpeg\": \"image/jpeg\",\n \".jpg\": \"image/jpeg\",\n \".jfif\": \"image/jpeg\",\n \".png\": \"image/png\",\n \".svg\": \"image/svg+xml\",\n \".tif\": \"image/tiff\",\n \".tiff\": \"image/tiff\",\n \".webp\": \"image/webp\",\n};\n/** Map filenames to mimetypes for unpacking the zip file\n * @param {string} fname\n */\nfunction mime(fname) {\n const extension = /\\.[-a-zA-Z0-9]+$/.exec(fname);\n if (!extension) return false;\n return mimetypes[extension] || false;\n}\n","import expressions from \"angular-expressions\";\nimport Globals from \"./globals\";\nimport db from \"./db\";\n\n/** @param {function(string, string): string} f */\nexport function updateString(f) {\n /** @param {string} value */\n return function (value) {\n /** @param {string | undefined} old */\n return function (old) {\n return f(old || \"\", value);\n };\n };\n}\n/** @param {function(number, number): number} f */\nfunction updateNumber(f) {\n /** @param {number} value */\n return function (value) {\n /** @param {number | undefined} old */\n return function (old) {\n return f(old || 0, value);\n };\n };\n}\nexport const Functions = {\n increment: updateNumber((old, value) => old + value),\n add_word: updateString((old, value) => old + value + \" \"),\n add_letter: updateString((old, value) => old + value),\n complete: updateString((old, value) => {\n if (old.length == 0 || old.endsWith(\" \")) {\n return old + value;\n } else {\n return old.replace(/\\S+$/, value);\n }\n }),\n replace_last: updateString((old, value) => old.replace(/\\S*\\s*$/, value)),\n replace_last_letter: updateString((old, value) => old.slice(0, -1) + value),\n random: (/** @type {string} */ arg) => {\n let args = arg.split(\",\");\n return args[Math.floor(Math.random() * args.length)];\n },\n max: Math.max,\n min: Math.min,\n if: (/** @type {boolean} */ c, /** @type {any} */ t, /** @type {any} */ f) =>\n c ? t : f,\n abs: (/** @type {number} */ v) => Math.abs(v),\n load_design: (url = \"\") => {\n if (!url) db.reloadDesignFromOriginalURL();\n else db.readDesignFromURL(url);\n return \"loaded\";\n },\n open_editor: () => {\n Globals.state.update({ editing: !Globals.state.get(\"editing\") });\n },\n};\n\n/**\n * Translate an expression from Excel-like to Javascript\n *\n * @param {string} expression\n * @returns {string}\n */\nfunction translate(expression) {\n /* translate the expression from the excel like form to javascript */\n // remove any initial = sign\n let exp = expression.replace(/^=/, \"\");\n // translate single = to ==\n exp = exp.replaceAll(/(?!])=/g, \"==\");\n // translate words\n exp = exp.replaceAll(/(?}\n */\nexport const accessed = new Map();\n\n/* intercept access to variables so I can track access to undefined state and field values\n * and map them to empty strings.\n */\nconst variableHandler = {\n /** @param {Object} target\n * @param {string} prop\n */\n get(target, prop) {\n let result = undefined;\n if (prop.startsWith(\"$\")) {\n result = target.states[prop];\n accessed.set(prop, prop in target.states);\n } else if (prop.startsWith(\"_\")) {\n let ps = prop.slice(1);\n result = target.data[ps];\n accessed.set(prop, Globals.data.allFields.has(\"#\" + ps));\n } else if (prop in Functions) {\n result = Functions[prop];\n } else {\n console.error(\"undefined\", prop);\n }\n if (result === undefined || result === null) {\n result = \"\";\n }\n return result;\n },\n\n /** The expressions library is testing for own properties for safety.\n * I need to defeat that for the renaming I want to do.\n * @param {Object} target;\n * @param {string} prop;\n */\n getOwnPropertyDescriptor(target, prop) {\n if (prop.startsWith(\"$\")) {\n return Object.getOwnPropertyDescriptor(target.states, prop);\n } else if (prop.startsWith(\"_\")) {\n return Object.getOwnPropertyDescriptor(target.data, prop.slice(1));\n } else {\n return Object.getOwnPropertyDescriptor(Functions, prop);\n }\n },\n};\n\n/**\n * Compile an expression returning the function or an error\n * @param {string} expression\n * @returns {[ ((context?:Object)=>any ) | undefined, Error | undefined ]}\n *\n * */\nexport function compileExpression(expression) {\n const te = translate(expression);\n try {\n const exp = expressions.compile(te);\n /** @param {EvalContext} context */\n return [\n (context = {}) => {\n let states =\n \"states\" in context\n ? { ...Globals.state.values, ...context.states }\n : Globals.state.values;\n let data = context.data ?? [];\n const r = exp(\n new Proxy(\n {\n Functions,\n states,\n data,\n },\n variableHandler,\n ),\n );\n return r;\n },\n undefined,\n ];\n } catch (e) {\n return [undefined, e];\n }\n}\n","/*\n * Bang color names from http://www.procato.com/rgb+index/?csv\n */\nexport const ColorNames = {\n white: \"#ffffff\",\n red: \"#ff0000\",\n green: \"#00ff00\",\n blue: \"#0000ff\",\n yellow: \"#ffff00\",\n magenta: \"#ff00ff\",\n cyan: \"#00ffff\",\n black: \"#000000\",\n \"pinkish white\": \"#fff6f6\",\n \"very pale pink\": \"#ffe2e2\",\n \"pale pink\": \"#ffc2c2\",\n \"light pink\": \"#ff9e9e\",\n \"light brilliant red\": \"#ff6565\",\n \"luminous vivid red\": \"#ff0000\",\n \"pinkish gray\": \"#e7dada\",\n \"pale grayish pink\": \"#e7b8b8\",\n pink: \"#e78b8b\",\n \"brilliant red\": \"#e75151\",\n \"vivid red\": \"#e70000\",\n \"reddish gray\": \"#a89c9c\",\n \"grayish red\": \"#a87d7d\",\n \"moderate red\": \"#a84a4a\",\n \"strong red\": \"#a80000\",\n \"reddish brownish gray\": \"#595353\",\n \"dark grayish reddish brown\": \"#594242\",\n \"reddish brown\": \"#592727\",\n \"deep reddish brown\": \"#590000\",\n \"reddish brownish black\": \"#1d1a1a\",\n \"very reddish brown\": \"#1d1111\",\n \"very deep reddish brown\": \"#1d0000\",\n \"pale scarlet\": \"#ffc9c2\",\n \"very light scarlet\": \"#ffaa9e\",\n \"light brilliant scarlet\": \"#ff7865\",\n \"luminous vivid scarlet\": \"#ff2000\",\n \"light scarlet\": \"#e7968b\",\n \"brilliant scarlet\": \"#e76451\",\n \"vivid scarlet\": \"#e71d00\",\n \"moderate scarlet\": \"#a8554a\",\n \"strong scarlet\": \"#a81500\",\n \"dark scarlet\": \"#592d27\",\n \"deep scarlet\": \"#590b00\",\n \"very pale vermilion\": \"#ffe9e2\",\n \"pale vermilion\": \"#ffd1c2\",\n \"very light vermilion\": \"#ffb69e\",\n \"light brilliant vermilion\": \"#ff8b65\",\n \"luminous vivid vermilion\": \"#ff4000\",\n \"pale, light grayish vermilion\": \"#e7c4b8\",\n \"light vermilion\": \"#e7a28b\",\n \"brilliant vermilion\": \"#e77751\",\n \"vivid vermilion\": \"#e73a00\",\n \"grayish vermilion\": \"#a8887d\",\n \"moderate vermilion\": \"#a8614a\",\n \"strong vermilion\": \"#a82a00\",\n \"dark grayish vermilion\": \"#594842\",\n \"dark vermilion\": \"#593427\",\n \"deep vermilion\": \"#591600\",\n \"pale tangelo\": \"#ffd9c2\",\n \"very light tangelo\": \"#ffc29e\",\n \"light brilliant tangelo\": \"#ff9f65\",\n \"luminous vivid tangelo\": \"#ff6000\",\n \"light tangelo\": \"#e7ae8b\",\n \"brilliant tangelo\": \"#e78951\",\n \"vivid tangelo\": \"#e75700\",\n \"moderate tangelo\": \"#a86d4a\",\n \"strong tangelo\": \"#a83f00\",\n \"dark tangelo\": \"#593a27\",\n \"deep tangelo\": \"#592100\",\n \"very pale orange\": \"#fff0e2\",\n \"pale orange\": \"#ffe0c2\",\n \"very light orange\": \"#ffcf9e\",\n \"light brilliant orange\": \"#ffb265\",\n \"luminous vivid orange\": \"#ff8000\",\n \"pale, light grayish brown\": \"#e7d0b8\",\n \"light orange\": \"#e7b98b\",\n \"brilliant orange\": \"#e79c51\",\n \"vivid orange\": \"#e77400\",\n \"grayish brown\": \"#a8937d\",\n \"moderate orange\": \"#a8794a\",\n \"strong orange\": \"#a85400\",\n \"dark grayish brown\": \"#594e42\",\n brown: \"#594027\",\n \"deep brown\": \"#592d00\",\n \"very brown\": \"#1d1711\",\n \"very deep brown\": \"#1d0e00\",\n \"pale gamboge\": \"#ffe8c2\",\n \"very light gamboge\": \"#ffdb9e\",\n \"light brilliant gamboge\": \"#ffc565\",\n \"luminous vivid gamboge\": \"#ff9f00\",\n \"light gamboge\": \"#e7c58b\",\n \"brilliant gamboge\": \"#e7af51\",\n \"vivid gamboge\": \"#e79100\",\n \"moderate gamboge\": \"#a8854a\",\n \"strong gamboge\": \"#a86900\",\n \"dark gamboge\": \"#594627\",\n \"deep gamboge\": \"#593800\",\n \"very pale amber\": \"#fff8e2\",\n \"pale amber\": \"#fff0c2\",\n \"very light amber\": \"#ffe79e\",\n \"light brilliant amber\": \"#ffd865\",\n \"luminous vivid amber\": \"#ffbf00\",\n \"pale, light grayish amber\": \"#e7dcb8\",\n \"light amber\": \"#e7d08b\",\n \"brilliant amber\": \"#e7c251\",\n \"vivid amber\": \"#e7ae00\",\n \"grayish amber\": \"#a89e7d\",\n \"moderate amber\": \"#a8914a\",\n \"strong amber\": \"#a87e00\",\n \"dark grayish amber\": \"#595442\",\n \"dark amber\": \"#594d27\",\n \"deep amber\": \"#594300\",\n \"pale gold\": \"#fff7c2\",\n \"very light gold\": \"#fff39e\",\n \"light brilliant gold\": \"#ffec65\",\n \"luminous vivid gold\": \"#ffdf00\",\n \"light gold\": \"#e7dc8b\",\n \"brilliant gold\": \"#e7d551\",\n \"vivid gold\": \"#e7ca00\",\n \"moderate gold\": \"#a89c4a\",\n \"strong gold\": \"#a89300\",\n \"dark gold\": \"#595327\",\n \"deep gold\": \"#594e00\",\n \"yellowish white\": \"#fffff6\",\n \"very pale yellow\": \"#ffffe2\",\n \"pale yellow\": \"#ffffc2\",\n \"very light yellow\": \"#ffff9e\",\n \"light brilliant yellow\": \"#ffff65\",\n \"luminous vivid yellow\": \"#ffff00\",\n \"light yellowish gray\": \"#e7e7da\",\n \"pale, light grayish olive\": \"#e7e7b8\",\n \"light yellow\": \"#e7e78b\",\n \"brilliant yellow\": \"#e7e751\",\n \"vivid yellow\": \"#e7e700\",\n \"yellowish gray\": \"#a8a89c\",\n \"grayish olive\": \"#a8a87d\",\n \"moderate olive\": \"#a8a84a\",\n \"strong olive\": \"#a8a800\",\n \"dark olivish gray\": \"#595953\",\n \"dark grayish olive\": \"#595942\",\n \"dark olive\": \"#595927\",\n \"deep olive\": \"#595900\",\n \"yellowish black\": \"#1d1d1a\",\n \"very dark olive\": \"#1d1d11\",\n \"very deep olive\": \"#1d1d00\",\n \"pale apple green\": \"#f7ffc2\",\n \"very light apple green\": \"#f3ff9e\",\n \"light brilliant apple green\": \"#ecff65\",\n \"luminous vivid apple green\": \"#dfff00\",\n \"light apple green\": \"#dce78b\",\n \"brilliant apple green\": \"#d5e751\",\n \"vivid apple green\": \"#cae700\",\n \"moderate apple green\": \"#9ca84a\",\n \"strong apple green\": \"#93a800\",\n \"dark apple green\": \"#535927\",\n \"deep apple green\": \"#4e5900\",\n \"very pale lime green\": \"#f8ffe2\",\n \"pale lime green\": \"#f0ffc2\",\n \"very light lime green\": \"#e7ff9e\",\n \"light brilliant lime green\": \"#d8ff65\",\n \"luminous vivid lime green\": \"#bfff00\",\n \"pale, light grayish lime green\": \"#dce7b8\",\n \"light lime green\": \"#d0e78b\",\n \"brilliant lime green\": \"#c2e751\",\n \"vivid lime green\": \"#aee700\",\n \"grayish lime green\": \"#9ea87d\",\n \"moderate lime green\": \"#91a84a\",\n \"strong lime green\": \"#7ea800\",\n \"dark grayish lime green\": \"#545942\",\n \"dark lime green\": \"#4d5927\",\n \"deep lime green\": \"#435900\",\n \"pale spring bud\": \"#e8ffc2\",\n \"very light spring bud\": \"#dbff9e\",\n \"light brilliant spring bud\": \"#c5ff65\",\n \"luminous vivid spring bud\": \"#9fff00\",\n \"light spring bud\": \"#c5e78b\",\n \"brilliant spring bud\": \"#afe751\",\n \"vivid spring bud\": \"#91e700\",\n \"moderate spring bud\": \"#85a84a\",\n \"strong spring bud\": \"#69a800\",\n \"dark spring bud\": \"#465927\",\n \"deep spring bud\": \"#385900\",\n \"very pale chartreuse green\": \"#f0ffe2\",\n \"pale chartreuse green\": \"#e0ffc2\",\n \"very light chartreuse green\": \"#cfff9e\",\n \"light brilliant chartreuse green\": \"#b2ff65\",\n \"luminous vivid chartreuse green\": \"#80ff00\",\n \"pale, light grayish chartreuse green\": \"#d0e7b8\",\n \"light chartreuse green\": \"#b9e78b\",\n \"brilliant chartreuse green\": \"#9ce751\",\n \"vivid chartreuse green\": \"#74e700\",\n \"grayish chartreuse green\": \"#93a87d\",\n \"moderate chartreuse green\": \"#79a84a\",\n \"strong chartreuse green\": \"#54a800\",\n \"dark grayish chartreuse green\": \"#4e5942\",\n \"dark chartreuse green\": \"#405927\",\n \"deep chartreuse green\": \"#2d5900\",\n \"very dark chartreuse green\": \"#171d11\",\n \"very deep chartreuse green\": \"#0e1d00\",\n \"pale pistachio\": \"#d9ffc2\",\n \"very light pistachio\": \"#c2ff9e\",\n \"light brilliant pistachio\": \"#9fff65\",\n \"luminous vivid pistachio\": \"#60ff00\",\n \"light pistachio\": \"#aee78b\",\n \"brilliant pistachio\": \"#89e751\",\n \"vivid pistachio\": \"#57e700\",\n \"moderate pistachio\": \"#6da84a\",\n \"strong pistachio\": \"#3fa800\",\n \"dark pistachio\": \"#3a5927\",\n \"deep pistachio\": \"#215900\",\n \"very pale harlequin\": \"#e9ffe2\",\n \"pale harlequin\": \"#d1ffc2\",\n \"very light harlequin\": \"#b6ff9e\",\n \"light brilliant harlequin\": \"#8bff65\",\n \"luminous vivid harlequin\": \"#40ff00\",\n \"pale, light grayish harlequin\": \"#c4e7b8\",\n \"light harlequin\": \"#a2e78b\",\n \"brilliant harlequin\": \"#77e751\",\n \"vivid harlequin\": \"#3ae700\",\n \"grayish harlequin\": \"#88a87d\",\n \"moderate harlequin\": \"#61a84a\",\n \"strong harlequin\": \"#2aa800\",\n \"dark grayish harlequin\": \"#485942\",\n \"dark harlequin\": \"#345927\",\n \"deep harlequin\": \"#165900\",\n \"pale sap green\": \"#c9ffc2\",\n \"very light sap green\": \"#aaff9e\",\n \"light brilliant sap green\": \"#78ff65\",\n \"luminous vivid sap green\": \"#20ff00\",\n \"light sap green\": \"#96e78b\",\n \"brilliant sap green\": \"#64e751\",\n \"vivid sap green\": \"#1de700\",\n \"moderate sap green\": \"#55a84a\",\n \"strong sap green\": \"#15a800\",\n \"dark sap green\": \"#2d5927\",\n \"deep sap green\": \"#0b5900\",\n \"greenish white\": \"#f6fff6\",\n \"very pale green\": \"#e2ffe2\",\n \"pale green\": \"#c2ffc2\",\n \"very light green\": \"#9eff9e\",\n \"light brilliant green\": \"#65ff65\",\n \"luminous vivid green\": \"#00ff00\",\n \"light greenish gray\": \"#dae7da\",\n \"pale, light grayish green\": \"#b8e7b8\",\n \"light green\": \"#8be78b\",\n \"brilliant green\": \"#51e751\",\n \"vivid green\": \"#00e700\",\n \"greenish gray\": \"#9ca89c\",\n \"grayish green\": \"#7da87d\",\n \"moderate green\": \"#4aa84a\",\n \"strong green\": \"#00a800\",\n \"dark greenish gray\": \"#535953\",\n \"dark grayish green\": \"#425942\",\n \"dark green\": \"#275927\",\n \"deep green\": \"#005900\",\n \"greenish black\": \"#1a1d1a\",\n \"very dark green\": \"#111d11\",\n \"very deep green\": \"#001d00\",\n \"pale emerald green\": \"#c2ffc9\",\n \"very light emerald green\": \"#9effaa\",\n \"light brilliant emerald green\": \"#65ff78\",\n \"luminous vivid emerald green\": \"#00ff20\",\n \"light emerald green\": \"#8be796\",\n \"brilliant emerald green\": \"#51e764\",\n \"vivid emerald green\": \"#00e71d\",\n \"moderate emerald green\": \"#4aa855\",\n \"strong emerald green\": \"#00a815\",\n \"dark emerald green\": \"#27592d\",\n \"deep emerald green\": \"#00590b\",\n \"very pale malachite green\": \"#e2ffe9\",\n \"pale malachite green\": \"#c2ffd1\",\n \"very light malachite green\": \"#9effb6\",\n \"light brilliant malachite green\": \"#65ff8b\",\n \"luminous vivid malachite green\": \"#00ff40\",\n \"pale, light grayish malachite green\": \"#b8e7c4\",\n \"light malachite green\": \"#8be7a2\",\n \"brilliant malachite green\": \"#51e777\",\n \"vivid malachite green\": \"#00e73a\",\n \"grayish malachite green\": \"#7da888\",\n \"moderate malachite green\": \"#4aa861\",\n \"strong malachite green\": \"#00a82a\",\n \"dark grayish malachite green\": \"#425948\",\n \"dark malachite green\": \"#275934\",\n \"deep malachite green\": \"#005916\",\n \"pale sea green\": \"#c2ffd9\",\n \"very light sea green\": \"#9effc2\",\n \"light brilliant sea green\": \"#65ff9f\",\n \"luminous vivid sea green\": \"#00ff60\",\n \"light sea green\": \"#8be7ae\",\n \"brilliant sea green\": \"#51e789\",\n \"vivid sea green\": \"#00e757\",\n \"moderate sea green\": \"#4aa86d\",\n \"strong sea green\": \"#00a83f\",\n \"dark sea green\": \"#27593a\",\n \"deep sea green\": \"#005921\",\n \"very pale spring green\": \"#e2fff0\",\n \"pale spring green\": \"#c2ffe0\",\n \"very light spring green\": \"#9effcf\",\n \"light brilliant spring green\": \"#65ffb2\",\n \"luminous vivid spring green\": \"#00ff80\",\n \"pale, light grayish spring green\": \"#b8e7d0\",\n \"light spring green\": \"#8be7b9\",\n \"brilliant spring green\": \"#51e79c\",\n \"vivid spring green\": \"#00e774\",\n \"grayish spring green\": \"#7da893\",\n \"moderate spring green\": \"#4aa879\",\n \"strong spring green\": \"#00a854\",\n \"dark grayish spring green\": \"#42594e\",\n \"dark spring green\": \"#275940\",\n \"deep spring green\": \"#00592d\",\n \"very dark spring green\": \"#111d17\",\n \"very deep spring green\": \"#001d0e\",\n \"pale aquamarine\": \"#c2ffe8\",\n \"very light aquamarine\": \"#9effdb\",\n \"light brilliant aquamarine\": \"#65ffc5\",\n \"luminous vivid aquamarine\": \"#00ff9f\",\n \"light aquamarine\": \"#8be7c5\",\n \"brilliant aquamarine\": \"#51e7af\",\n \"vivid aquamarine\": \"#00e791\",\n \"moderate aquamarine\": \"#4aa885\",\n \"strong aquamarine\": \"#00a869\",\n \"dark aquamarine\": \"#275946\",\n \"deep aquamarine\": \"#005938\",\n \"very pale turquoise\": \"#e2fff8\",\n \"pale turquoise\": \"#c2fff0\",\n \"very light turquoise\": \"#9effe7\",\n \"light brilliant turquoise\": \"#65ffd8\",\n \"luminous vivid turquoise\": \"#00ffbf\",\n \"pale, light grayish turquoise\": \"#b8e7dc\",\n \"light turquoise\": \"#8be7d0\",\n \"brilliant turquoise\": \"#51e7c2\",\n \"vivid turquoise\": \"#00e7ae\",\n \"grayish turquoise\": \"#7da89e\",\n \"moderate turquoise\": \"#4aa891\",\n \"strong turquoise\": \"#00a87e\",\n \"dark grayish turquoise\": \"#425954\",\n \"dark turquoise\": \"#27594d\",\n \"deep turquoise\": \"#005943\",\n \"pale opal\": \"#c2fff7\",\n \"very light opal\": \"#9efff3\",\n \"light brilliant opal\": \"#65ffec\",\n \"luminous vivid opal\": \"#00ffdf\",\n \"light opal\": \"#8be7dc\",\n \"brilliant opal\": \"#51e7d5\",\n \"vivid opal\": \"#00e7ca\",\n \"moderate opal\": \"#4aa89c\",\n \"strong opal\": \"#00a893\",\n \"dark opal\": \"#275953\",\n \"deep opal\": \"#00594e\",\n \"cyanish white\": \"#f6ffff\",\n \"very pale cyan\": \"#e2ffff\",\n \"pale cyan\": \"#c2ffff\",\n \"very light cyan\": \"#9effff\",\n \"light brilliant cyan\": \"#65ffff\",\n \"luminous vivid cyan\": \"#00ffff\",\n \"light cyanish gray\": \"#dae7e7\",\n \"pale, light grayish cyan\": \"#b8e7e7\",\n \"light cyan\": \"#8be7e7\",\n \"brilliant cyan\": \"#51e7e7\",\n \"vivid cyan\": \"#00e7e7\",\n \"cyanish gray\": \"#9ca8a8\",\n \"grayish cyan\": \"#7da8a8\",\n \"moderate cyan\": \"#4aa8a8\",\n \"strong cyan\": \"#00a8a8\",\n \"dark cyanish gray\": \"#535959\",\n \"dark grayish cyan\": \"#425959\",\n \"dark cyan\": \"#275959\",\n \"deep cyan\": \"#005959\",\n \"cyanish black\": \"#1a1d1d\",\n \"very dark cyan\": \"#111d1d\",\n \"very deep cyan\": \"#001d1d\",\n \"pale arctic blue\": \"#c2f7ff\",\n \"very light arctic blue\": \"#9ef3ff\",\n \"light brilliant arctic blue\": \"#65ecff\",\n \"luminous vivid arctic blue\": \"#00dfff\",\n \"light arctic blue\": \"#8bdce7\",\n \"brilliant arctic blue\": \"#51d5e7\",\n \"vivid arctic blue\": \"#00cae7\",\n \"moderate arctic blue\": \"#4a9ca8\",\n \"strong arctic blue\": \"#0093a8\",\n \"dark arctic blue\": \"#275359\",\n \"deep arctic blue\": \"#004e59\",\n \"very pale cerulean\": \"#e2f8ff\",\n \"pale cerulean\": \"#c2f0ff\",\n \"very light cerulean\": \"#9ee7ff\",\n \"light brilliant cerulean\": \"#65d8ff\",\n \"luminous vivid cerulean\": \"#00bfff\",\n \"pale, light grayish cerulean\": \"#b8dce7\",\n \"light cerulean\": \"#8bd0e7\",\n \"brilliant cerulean\": \"#51c2e7\",\n \"vivid cerulean\": \"#00aee7\",\n \"grayish cerulean\": \"#7d9ea8\",\n \"moderate cerulean\": \"#4a91a8\",\n \"strong cerulean\": \"#007ea8\",\n \"dark grayish cerulean\": \"#425459\",\n \"dark cerulean\": \"#274d59\",\n \"deep cerulean\": \"#004359\",\n \"pale cornflower blue\": \"#c2e8ff\",\n \"very light cornflower blue\": \"#9edbff\",\n \"light brilliant cornflower blue\": \"#65c5ff\",\n \"luminous vivid cornflower blue\": \"#009fff\",\n \"light cornflower blue\": \"#8bc5e7\",\n \"brilliant cornflower blue\": \"#51afe7\",\n \"vivid cornflower blue\": \"#0091e7\",\n \"moderate cornflower blue\": \"#4a85a8\",\n \"strong cornflower blue\": \"#0069a8\",\n \"dark cornflower blue\": \"#274659\",\n \"deep cornflower blue\": \"#003859\",\n \"very pale azure\": \"#e2f0ff\",\n \"pale azure\": \"#c2e0ff\",\n \"very light azure\": \"#9ecfff\",\n \"light brilliant azure\": \"#65b2ff\",\n \"luminous vivid azure\": \"#0080ff\",\n \"pale, light grayish azure\": \"#b8d0e7\",\n \"light azure\": \"#8bb9e7\",\n \"brilliant azure\": \"#519ce7\",\n \"vivid azure\": \"#0074e7\",\n \"grayish azure\": \"#7d93a8\",\n \"moderate azure\": \"#4a79a8\",\n \"strong azure\": \"#0054a8\",\n \"dark grayish azure\": \"#424e59\",\n \"dark azure\": \"#274059\",\n \"deep azure\": \"#002d59\",\n \"very dark azure\": \"#11171d\",\n \"very deep azure\": \"#000e1d\",\n \"pale cobalt blue\": \"#c2d9ff\",\n \"very light cobalt blue\": \"#9ec2ff\",\n \"light brilliant cobalt blue\": \"#659fff\",\n \"luminous vivid cobalt blue\": \"#0060ff\",\n \"light cobalt blue\": \"#8baee7\",\n \"brilliant cobalt blue\": \"#5189e7\",\n \"vivid cobalt blue\": \"#0057e7\",\n \"moderate cobalt blue\": \"#4a6da8\",\n \"strong cobalt blue\": \"#003fa8\",\n \"dark cobalt blue\": \"#273a59\",\n \"deep cobalt blue\": \"#002159\",\n \"very pale sapphire blue\": \"#e2e9ff\",\n \"pale sapphire blue\": \"#c2d1ff\",\n \"very light sapphire blue\": \"#9eb6ff\",\n \"light brilliant sapphire blue\": \"#658bff\",\n \"luminous vivid sapphire blue\": \"#0040ff\",\n \"pale, light grayish sapphire blue\": \"#b8c4e7\",\n \"light sapphire blue\": \"#8ba2e7\",\n \"brilliant sapphire blue\": \"#5177e7\",\n \"vivid sapphire blue\": \"#003ae7\",\n \"grayish sapphire blue\": \"#7d88a8\",\n \"moderate sapphire blue\": \"#4a61a8\",\n \"strong sapphire blue\": \"#002aa8\",\n \"dark grayish sapphire blue\": \"#424859\",\n \"dark sapphire blue\": \"#273459\",\n \"deep sapphire blue\": \"#001659\",\n \"pale phthalo blue\": \"#c2c9ff\",\n \"very light phthalo blue\": \"#9eaaff\",\n \"light brilliant phthalo blue\": \"#6578ff\",\n \"luminous vivid phthalo blue\": \"#0020ff\",\n \"light phthalo blue\": \"#8b96e7\",\n \"brilliant phthalo blue\": \"#5164e7\",\n \"vivid phthalo blue\": \"#001de7\",\n \"moderate phthalo blue\": \"#4a55a8\",\n \"strong phthalo blue\": \"#0015a8\",\n \"dark phthalo blue\": \"#272d59\",\n \"deep phthalo blue\": \"#000b59\",\n \"bluish white\": \"#f6f6ff\",\n \"very pale blue\": \"#e2e2ff\",\n \"pale blue\": \"#c2c2ff\",\n \"very light blue\": \"#9e9eff\",\n \"light brilliant blue\": \"#6565ff\",\n \"luminous vivid blue\": \"#0000ff\",\n \"light bluish gray\": \"#dadae7\",\n \"pale, light grayish blue\": \"#b8b8e7\",\n \"light blue\": \"#8b8be7\",\n \"brilliant blue\": \"#5151e7\",\n \"vivid blue\": \"#0000e7\",\n \"bluish gray\": \"#9c9ca8\",\n \"grayish blue\": \"#7d7da8\",\n \"moderate blue\": \"#4a4aa8\",\n \"strong blue\": \"#0000a8\",\n \"dark bluish gray\": \"#535359\",\n \"dark grayish blue\": \"#424259\",\n \"dark blue\": \"#272759\",\n \"deep blue\": \"#000059\",\n \"bluish black\": \"#1a1a1d\",\n \"very dark blue\": \"#11111d\",\n \"very deep blue\": \"#00001d\",\n \"pale persian blue\": \"#c9c2ff\",\n \"very light persian blue\": \"#aa9eff\",\n \"light brilliant persian blue\": \"#7865ff\",\n \"luminous vivid persian blue\": \"#2000ff\",\n \"light persian blue\": \"#968be7\",\n \"brilliant persian blue\": \"#6451e7\",\n \"vivid persian blue\": \"#1d00e7\",\n \"moderate persian blue\": \"#554aa8\",\n \"strong persian blue\": \"#1500a8\",\n \"dark persian blue\": \"#2d2759\",\n \"deep persian blue\": \"#0b0059\",\n \"very pale indigo\": \"#e9e2ff\",\n \"pale indigo\": \"#d1c2ff\",\n \"very light indigo\": \"#b69eff\",\n \"light brilliant indigo\": \"#8b65ff\",\n \"luminous vivid indigo\": \"#4000ff\",\n \"pale, light grayish indigo\": \"#c4b8e7\",\n \"light indigo\": \"#a28be7\",\n \"brilliant indigo\": \"#7751e7\",\n \"vivid indigo\": \"#3a00e7\",\n \"grayish indigo\": \"#887da8\",\n \"moderate indigo\": \"#614aa8\",\n \"strong indigo\": \"#2a00a8\",\n \"dark grayish indigo\": \"#484259\",\n \"dark indigo\": \"#342759\",\n \"deep indigo\": \"#160059\",\n \"pale blue violet\": \"#d9c2ff\",\n \"very light blue violet\": \"#c29eff\",\n \"light brilliant blue violet\": \"#9f65ff\",\n \"luminous vivid blue violet\": \"#6000ff\",\n \"light blue violet\": \"#ae8be7\",\n \"brilliant blue violet\": \"#8951e7\",\n \"vivid blue violet\": \"#5700e7\",\n \"moderate blue violet\": \"#6d4aa8\",\n \"strong blue violet\": \"#3f00a8\",\n \"dark blue violet\": \"#3a2759\",\n \"deep blue violet\": \"#210059\",\n \"very pale violet\": \"#f0e2ff\",\n \"pale violet\": \"#e0c2ff\",\n \"very light violet\": \"#cf9eff\",\n \"light brilliant violet\": \"#b265ff\",\n \"luminous vivid violet\": \"#8000ff\",\n \"pale, light grayish violet\": \"#d0b8e7\",\n \"light violet\": \"#b98be7\",\n \"brilliant violet\": \"#9c51e7\",\n \"vivid violet\": \"#7400e7\",\n \"grayish violet\": \"#937da8\",\n \"moderate violet\": \"#794aa8\",\n \"strong violet\": \"#5400a8\",\n \"dark grayish violet\": \"#4e4259\",\n \"dark violet\": \"#402759\",\n \"deep violet\": \"#2d0059\",\n \"very dark violet\": \"#17111d\",\n \"very deep violet\": \"#0e001d\",\n \"pale purple\": \"#e8c2ff\",\n \"very light purple\": \"#db9eff\",\n \"light brilliant purple\": \"#c565ff\",\n \"luminous vivid purple\": \"#9f00ff\",\n \"light purple\": \"#c58be7\",\n \"brilliant purple\": \"#af51e7\",\n \"vivid purple\": \"#9100e7\",\n \"moderate purple\": \"#854aa8\",\n \"strong purple\": \"#6900a8\",\n \"dark purple\": \"#462759\",\n \"deep purple\": \"#380059\",\n \"very pale mulberry\": \"#f8e2ff\",\n \"pale mulberry\": \"#f0c2ff\",\n \"very light mulberry\": \"#e79eff\",\n \"light brilliant mulberry\": \"#d865ff\",\n \"luminous vivid mulberry\": \"#bf00ff\",\n \"pale, light grayish mulberry\": \"#dcb8e7\",\n \"light mulberry\": \"#d08be7\",\n \"brilliant mulberry\": \"#c251e7\",\n \"vivid mulberry\": \"#ae00e7\",\n \"grayish mulberry\": \"#9e7da8\",\n \"moderate mulberry\": \"#914aa8\",\n \"strong mulberry\": \"#7e00a8\",\n \"dark grayish mulberry\": \"#544259\",\n \"dark mulberry\": \"#4d2759\",\n \"deep mulberry\": \"#430059\",\n \"pale heliotrope\": \"#f7c2ff\",\n \"very light heliotrope\": \"#f39eff\",\n \"light brilliant heliotrope\": \"#ec65ff\",\n \"luminous vivid heliotrope\": \"#df00ff\",\n \"light heliotrope\": \"#dc8be7\",\n \"brilliant heliotrope\": \"#d551e7\",\n \"vivid heliotrope\": \"#ca00e7\",\n \"moderate heliotrope\": \"#9c4aa8\",\n \"strong heliotrope\": \"#9300a8\",\n \"dark heliotrope\": \"#532759\",\n \"deep heliotrope\": \"#4e0059\",\n \"magentaish white\": \"#fff6ff\",\n \"very pale magenta\": \"#ffe2ff\",\n \"pale magenta\": \"#ffc2ff\",\n \"very light magenta\": \"#ff9eff\",\n \"light brilliant magenta\": \"#ff65ff\",\n \"luminous vivid magenta\": \"#ff00ff\",\n \"light magentaish gray\": \"#e7dae7\",\n \"pale, light grayish magenta\": \"#e7b8e7\",\n \"light magenta\": \"#e78be7\",\n \"brilliant magenta\": \"#e751e7\",\n \"vivid magenta\": \"#e700e7\",\n \"magentaish gray\": \"#a89ca8\",\n \"grayish magenta\": \"#a87da8\",\n \"moderate magenta\": \"#a84aa8\",\n \"strong magenta\": \"#a800a8\",\n \"dark magentaish gray\": \"#595359\",\n \"dark grayish magenta\": \"#594259\",\n \"dark magenta\": \"#592759\",\n \"deep magenta\": \"#590059\",\n \"magentaish black\": \"#1d1a1d\",\n \"very dark magenta\": \"#1d111d\",\n \"very deep magenta\": \"#1d001d\",\n \"pale orchid\": \"#ffc2f7\",\n \"very light orchid\": \"#ff9ef3\",\n \"light brilliant orchid\": \"#ff65ec\",\n \"luminous vivid orchid\": \"#ff00df\",\n \"light orchid\": \"#e78bdc\",\n \"brilliant orchid\": \"#e751d5\",\n \"vivid orchid\": \"#e700ca\",\n \"moderate orchid\": \"#a84a9c\",\n \"strong orchid\": \"#a80093\",\n \"dark orchid\": \"#592753\",\n \"deep orchid\": \"#59004e\",\n \"very pale fuchsia\": \"#ffe2f8\",\n \"pale fuchsia\": \"#ffc2f0\",\n \"very light fuchsia\": \"#ff9ee7\",\n \"light brilliant fuchsia\": \"#ff65d8\",\n \"luminous vivid fuchsia\": \"#ff00bf\",\n \"pale, light grayish fuchsia\": \"#e7b8dc\",\n \"light fuchsia\": \"#e78bd0\",\n \"brilliant fuchsia\": \"#e751c2\",\n \"vivid fuchsia\": \"#e700ae\",\n \"grayish fuchsia\": \"#a87d9e\",\n \"moderate fuchsia\": \"#a84a91\",\n \"strong fuchsia\": \"#a8007e\",\n \"dark grayish fuchsia\": \"#594254\",\n \"dark fuchsia\": \"#59274d\",\n \"deep fuchsia\": \"#590043\",\n \"pale cerise\": \"#ffc2e8\",\n \"very light cerise\": \"#ff9edb\",\n \"light brilliant cerise\": \"#ff65c5\",\n \"luminous vivid cerise\": \"#ff009f\",\n \"light cerise\": \"#e78bc5\",\n \"brilliant cerise\": \"#e751af\",\n \"vivid cerise\": \"#e70091\",\n \"moderate cerise\": \"#a84a85\",\n \"strong cerise\": \"#a80069\",\n \"dark cerise\": \"#592746\",\n \"deep cerise\": \"#590038\",\n \"very pale rose\": \"#ffe2f0\",\n \"pale rose\": \"#ffc2e0\",\n \"very light rose\": \"#ff9ecf\",\n \"light brilliant rose\": \"#ff65b2\",\n \"luminous vivid rose\": \"#ff0080\",\n \"pale, light grayish rose\": \"#e7b8d0\",\n \"light rose\": \"#e78bb9\",\n \"brilliant rose\": \"#e7519c\",\n \"vivid rose\": \"#e70074\",\n \"grayish rose\": \"#a87d93\",\n \"moderate rose\": \"#a84a79\",\n \"strong rose\": \"#a80054\",\n \"dark grayish rose\": \"#59424e\",\n \"dark rose\": \"#592740\",\n \"deep rose\": \"#59002d\",\n \"very dark rose\": \"#1d1117\",\n \"very deep rose\": \"#1d000e\",\n \"pale raspberry\": \"#ffc2d9\",\n \"very light raspberry\": \"#ff9ec2\",\n \"light brilliant raspberry\": \"#ff659f\",\n \"luminous vivid raspberry\": \"#ff0060\",\n \"light raspberry\": \"#e78bae\",\n \"brilliant raspberry\": \"#e75189\",\n \"vivid raspberry\": \"#e70057\",\n \"moderate raspberry\": \"#a84a6d\",\n \"strong raspberry\": \"#a8003f\",\n \"dark raspberry\": \"#59273a\",\n \"deep raspberry\": \"#590021\",\n \"very pale crimson\": \"#ffe2e9\",\n \"pale crimson\": \"#ffc2d1\",\n \"very light crimson\": \"#ff9eb6\",\n \"light brilliant crimson\": \"#ff658b\",\n \"luminous vivid crimson\": \"#ff0040\",\n \"pale, light grayish crimson\": \"#e7b8c4\",\n \"light crimson\": \"#e78ba2\",\n \"brilliant crimson\": \"#e75177\",\n \"vivid crimson\": \"#e7003a\",\n \"grayish crimson\": \"#a87d88\",\n \"moderate crimson\": \"#a84a61\",\n \"strong crimson\": \"#a8002a\",\n \"dark grayish crimson\": \"#594248\",\n \"dark crimson\": \"#592734\",\n \"deep crimson\": \"#590016\",\n \"pale amaranth\": \"#ffc2c9\",\n \"very light amaranth\": \"#ff9eaa\",\n \"light brilliant amaranth\": \"#ff6578\",\n \"luminous vivid amaranth\": \"#ff0020\",\n \"light amaranth\": \"#e78b96\",\n \"brilliant amaranth\": \"#e75164\",\n \"vivid amaranth\": \"#e7001d\",\n \"moderate amaranth\": \"#a84a55\",\n \"strong amaranth\": \"#a80015\",\n \"dark amaranth\": \"#59272d\",\n \"deep amaranth\": \"#59000b\",\n};\n","import { html } from \"uhtml\";\nimport { ColorNames } from \"./color-names\";\n\n/** @param {Event & { target: HTMLInputElement }} event\n */\nexport function validateColor(event) {\n const input = event.target;\n if (!isValidColor(input.value)) {\n input.setCustomValidity(\"invalid color\");\n input.reportValidity();\n return false;\n } else {\n input.setCustomValidity(\"\");\n const div = /** @type {HTMLElement} */ (input.nextElementSibling);\n div.style.background = getColor(input.value);\n return true;\n }\n}\n\n/** @param {string} strColor */\nexport function isValidColor(strColor) {\n if (strColor.length == 0 || strColor in ColorNames) {\n return true;\n }\n var s = new Option().style;\n s.color = strColor;\n\n // return 'false' if color wasn't assigned\n return s.color !== \"\";\n}\n\n/** @param {string} name */\nexport function getColor(name) {\n return ColorNames[name] || name;\n}\n\n/** @param {Partial} style */\nfunction normalizeStyle(style) {\n return Object.fromEntries(\n Object.entries(style)\n .filter(([_, value]) => value && value.toString().length)\n .map(([key, value]) =>\n key.toLowerCase().indexOf(\"color\") >= 0\n ? [key, getColor(/** @type {string} */ (value))]\n : [key, value && value.toString()],\n ),\n );\n}\n\n/** @param {HTMLElement} element\n * @param {Partial} styles */\nexport function setStyle(element, styles) {\n Object.assign(element.style, normalizeStyle(styles));\n}\n\n/** @param {Partial} styles */\nexport function styleString(styles) {\n return Object.entries(normalizeStyle(styles)).reduce(\n (acc, [key, value]) =>\n acc +\n key\n .split(/(?=[A-Z])/)\n .join(\"-\")\n .toLowerCase() +\n \":\" +\n value +\n \";\",\n \"\",\n );\n}\n\nexport function colorNamesDataList() {\n return html`\n ${Object.keys(ColorNames).map((name) => html``;\n}\n","/* Thinking about better properties */\n\nimport { html } from \"uhtml\";\nimport \"css/props.css\";\nimport { compileExpression } from \"app/eval\";\nimport Globals from \"app/globals\";\nimport { TreeBaseSwitchable } from \"./treebase\";\nimport { getColor, isValidColor, styleString } from \"./style\";\n\n/**\n * @typedef {Object} PropOptions\n * @property {boolean} [hiddenLabel]\n * @property {string} [placeholder]\n * @property {string} [title]\n * @property {string} [label]\n * @property {string} [defaultValue]\n * @property {string} [group]\n * @property {string} [language]\n * @property {any} [valueWhenEmpty]\n * @property {string} [pattern]\n * @property {function(string):string} [validate]\n * @property {string} [inputmode]\n * @property {string} [datalist]\n * @property {number} [min]\n * @property {number} [max]\n */\n\n/**\n * @template {number|boolean|string} T\n */\nexport class Prop {\n label = \"\";\n /** @type {T} */\n _value;\n\n /** true if this is a formula without leading = */\n isFormulaByDefault = false;\n\n /** If the entered value starts with = treat it as an expression and store it here */\n formula = \"\";\n\n /** @type {((context?:EvalContext)=>any) | undefined} compiled expression if any */\n compiled = undefined;\n\n // Each prop gets a unique id based on the id of its container\n id = \"\";\n\n /** @type {TreeBase} */\n container;\n\n /** attach the prop to its containing TreeBase component\n * @param {string} name\n * @param {any} value\n * @param {TreeBase} container\n * */\n initialize(name, value, container) {\n // create id from the container id\n this.id = `${container.id}-${name}`;\n // link to the container\n this.container = container;\n // set the value if provided\n if (value != undefined) {\n this.set(value);\n }\n // create a label if it has none\n this.label =\n this.label ||\n name // convert from camelCase to Camel Case\n .replace(/(?!^)([A-Z])/g, \" $1\")\n .replace(/^./, (s) => s.toUpperCase());\n }\n\n /** @type {PropOptions} */\n options = {};\n\n /**\n * @param {T} value\n * @param {PropOptions} options */\n constructor(value, options = {}) {\n this._value = value;\n this.options = options;\n if (options.label) {\n this.label = options.label;\n }\n }\n validate = debounce(\n (/** @type {string} */ value, /** @type {HTMLInputElement} */ input) => {\n input.setCustomValidity(\"\");\n if (this.isFormulaByDefault || value.startsWith(\"=\")) {\n const [compiled, error] = compileExpression(value);\n if (error) {\n let message = error.message.replace(/^\\[.*?\\]/, \"\");\n message = message.split(\"\\n\")[0];\n input.setCustomValidity(message);\n } else if (compiled && this.options.validate)\n input.setCustomValidity(this.options.validate(\"\" + compiled({})));\n } else if (this.options.validate) {\n input.setCustomValidity(this.options.validate(value));\n }\n input.reportValidity();\n },\n 100,\n );\n\n input() {\n const text = this.text;\n return this.labeled(\n html`${this.showValue()}`,\n );\n }\n onkeydown = (/** @type {KeyboardEvent} */ event) => {\n // restore the input on Escape\n const { key, target } = event;\n if (key == \"Escape\" && target instanceof HTMLInputElement) {\n const text = this.text;\n this.validate(text, target);\n event.preventDefault();\n target.value = text;\n }\n };\n oninput = (/** @type {InputEvent} */ event) => {\n // validate on each character\n if (event.target instanceof HTMLInputElement) {\n this.validate(event.target.value, event.target);\n event.target.style.width = `${event.target.value.length + 1}ch`;\n }\n };\n onchange = (/** @type {InputEvent} */ event) => {\n if (\n event.target instanceof HTMLInputElement &&\n event.target.checkValidity()\n ) {\n this.set(event.target.value);\n this.update();\n }\n };\n onfocus = (/** @type {FocusEvent}*/ event) => {\n if (this.formula && event.target instanceof HTMLInputElement) {\n const span = event.target.nextElementSibling;\n if (span instanceof HTMLSpanElement) {\n const value = this.value;\n const type = typeof value;\n let text = \"\";\n if (type === \"string\" || type === \"number\" || type === \"boolean\") {\n text = \"\" + value;\n }\n span.innerText = text;\n }\n }\n };\n\n showValue() {\n return this.formula ? [html``] : [];\n }\n\n /** @param {Hole} body */\n labeled(body) {\n return html`\n