{"version":3,"file":"perlite.min.mjs","sources":["../node_modules/hyperactiv/src/tools.js","../node_modules/hyperactiv/src/data.js","../node_modules/hyperactiv/src/batcher.js","../node_modules/hyperactiv/src/observe.js","../node_modules/hyperactiv/src/computed.js","../node_modules/hyperactiv/src/index.js","../node_modules/hyperactiv/src/dispose.js","../node_modules/lit-html/src/lib/directive.ts","../node_modules/lit-html/src/lib/dom.ts","../node_modules/lit-html/src/lib/part.ts","../node_modules/lit-html/src/lib/template.ts","../node_modules/lit-html/src/lib/template-instance.ts","../node_modules/lit-html/src/lib/template-result.ts","../node_modules/lit-html/src/lib/parts.ts","../node_modules/lit-html/src/lib/default-template-processor.ts","../node_modules/lit-html/src/lib/template-factory.ts","../node_modules/lit-html/src/lib/render.ts","../node_modules/lit-html/src/lit-html.ts","../src/utils.ts","../node_modules/lit-html/src/directives/repeat.ts","../node_modules/lit-html/src/directives/cache.ts","../node_modules/lit-html/src/directives/until.ts","../node_modules/lit-html/src/directives/live.ts","../node_modules/lit-html/src/directives/guard.ts","../node_modules/lit-html/src/directives/class-map.ts","../node_modules/lit-html/src/directives/style-map.ts","../node_modules/lit-html/src/directives/if-defined.ts","../node_modules/lit-html/src/directives/async-append.ts","../node_modules/lit-html/src/directives/async-replace.ts","../node_modules/lit-html/src/directives/template-content.ts","../node_modules/lit-html/src/directives/unsafe-html.ts","../node_modules/lit-html/src/directives/unsafe-svg.ts","../src/directives/each.ts","../src/directives/ref.ts","../src/directives/decorator.ts","../src/directives/bind.ts","../src/directives/call.ts","../src/directives/capture.ts","../src/directives/once.ts","../src/directives/passive.ts","../src/directives/prevent.ts","../src/directives/stop.ts","../src/directives/self.ts","../src/index.ts"],"sourcesContent":["const BIND_IGNORED = [\n    'String',\n    'Number',\n    'Object',\n    'Array',\n    'Boolean',\n    'Date'\n]\n\nexport function isObj(object) { return object && typeof object === 'object' }\nexport function setHiddenKey(object, key, value) {\n    Object.defineProperty(object, key, { value, enumerable: false, configurable: true })\n}\nexport function defineBubblingProperties(object, key, parent) {\n    setHiddenKey(object, '__key', key)\n    setHiddenKey(object, '__parent', parent)\n}\nexport function getInstanceMethodKeys(object) {\n    return (\n        Object\n            .getOwnPropertyNames(object)\n            .concat(\n                Object.getPrototypeOf(object) &&\n                BIND_IGNORED.indexOf(Object.getPrototypeOf(object).constructor.name) < 0 ?\n                    Object.getOwnPropertyNames(Object.getPrototypeOf(object)) :\n                    []\n            )\n            .filter(prop => prop !== 'constructor' && typeof object[prop] === 'function')\n    )\n}\n","export const data = {\n    computedStack: [],\n    observersMap: new WeakMap(),\n    computedDependenciesTracker: new WeakMap()\n}\n","let timeout = null\nconst queue = new Set()\nfunction process() {\n    for(const task of queue) {\n        task()\n    }\n    queue.clear()\n    timeout = null\n}\n\nexport function enqueue(task, batch) {\n    if(timeout === null)\n        timeout = setTimeout(process, batch === true ? 0 : batch)\n    queue.add(task)\n}\n\n","import {\n    isObj,\n    defineBubblingProperties,\n    getInstanceMethodKeys,\n    setHiddenKey\n} from './tools'\nimport { data } from './data'\nimport { enqueue } from './batcher'\n\nconst { observersMap, computedStack, computedDependenciesTracker } = data\n\nexport function observe(obj, options = {}) {\n    // 'deep' is slower but reasonable; 'shallow' a performance enhancement but with side-effects\n    const {\n        props,\n        ignore,\n        batch,\n        deep = true,\n        bubble,\n        bind\n    } = options\n\n    // Ignore if the object is already observed\n    if(obj.__observed) {\n        return obj\n    }\n\n    // If the prop is explicitely not excluded\n    const isWatched = prop => (!props || props.includes(prop)) && (!ignore || !ignore.includes(prop))\n\n    // Add the object to the observers map.\n    // observersMap signature : Map<Object, Map<Property, Set<Computed function>>>\n    // In other words, observersMap is a map of observed objects.\n    // For each observed object, each property is mapped with a set of computed functions depending on this property.\n    // Whenever a property is set, we re-run each one of the functions stored inside the matching Set.\n    observersMap.set(obj, new Map())\n\n    // If the deep flag is set, observe nested objects/arrays\n    if(deep) {\n        Object.entries(obj).forEach(function([key, val]) {\n            if(isObj(val)) {\n                obj[key] = observe(val, options)\n                // If bubble is set, we add keys to the object used to bubble up the mutation\n                if(bubble) {\n                    defineBubblingProperties(obj[key], key, obj)\n                }\n            }\n        })\n    }\n\n    // Proxify the object in order to intercept get/set on props\n    const proxy = new Proxy(obj, {\n        get(_, prop) {\n            if(prop === '__observed')\n                return true\n\n            // If the prop is watched\n            if(isWatched(prop)) {\n                // If a computed function is being run\n                if(computedStack.length) {\n                    const propertiesMap = observersMap.get(obj)\n                    if(!propertiesMap.has(prop))\n                        propertiesMap.set(prop, new Set())\n                    // Tracks object and properties accessed during the function call\n                    const tracker = computedDependenciesTracker.get(computedStack[0])\n                    if(tracker) {\n                        if(!tracker.has(obj)) {\n                            tracker.set(obj, new Set())\n                        }\n                        tracker.get(obj).add(prop)\n                    }\n                    // Link the computed function and the property being accessed\n                    propertiesMap.get(prop).add(computedStack[0])\n                }\n            }\n\n            return obj[prop]\n        },\n        set(_, prop, value) {\n            if(prop === '__handler') {\n                // Don't track bubble handlers\n                setHiddenKey(obj, '__handler', value)\n            } else if(!isWatched(prop)) {\n                // If the prop is ignored\n                obj[prop] = value\n            } else if(Array.isArray(obj) && prop === 'length' || obj[prop] !== value) {\n                // If the new/old value are not equal\n                const deeper = deep && isObj(value)\n                const propertiesMap = observersMap.get(obj)\n\n                // Remove bubbling infrastructure and pass old value to handlers\n                const oldValue = obj[prop]\n                if(isObj(oldValue))\n                    delete obj[prop]\n\n                // If the deep flag is set we observe the newly set value\n                obj[prop] = deeper ? observe(value, options) : value\n\n                // Co-opt assigned object into bubbling if appropriate\n                if(deeper && bubble) {\n                    defineBubblingProperties(obj[prop], prop, obj)\n                }\n\n                const ancestry = [ prop ]\n                let parent = obj\n                while(parent) {\n                    // If a handler explicitly returns 'false' then stop propagation\n                    if(parent.__handler && parent.__handler(ancestry, value, oldValue, proxy) === false) {\n                        break\n                    }\n                    // Continue propagation, traversing the mutated property's object hierarchy & call any __handlers along the way\n                    if(parent.__key && parent.__parent) {\n                        ancestry.unshift(parent.__key)\n                        parent = parent.__parent\n                    } else {\n                        parent = null\n                    }\n                }\n\n                const dependents = propertiesMap.get(prop)\n                if(dependents) {\n                    // Retrieve the computed functions depending on the prop\n                    for(const dependent of dependents) {\n                        const tracker = computedDependenciesTracker.get(dependent)\n                        // If the function has been disposed or if the prop has not been used\n                        // during the latest function call, delete the function reference\n                        if(dependent.__disposed || tracker && (!tracker.has(obj) || !tracker.get(obj).has(prop))) {\n                            dependents.delete(dependent)\n                        } else if(dependent !== computedStack[0]) {\n                            // Run the computed function\n                            if(batch) {\n                                enqueue(dependent, batch)\n                            } else {\n                                dependent()\n                            }\n                        }\n                    }\n                }\n            }\n\n            return true\n        }\n    })\n\n    if(bind) {\n        // Need this for binding es6 classes methods which are stored in the object prototype\n        getInstanceMethodKeys(obj).forEach(key => obj[key] = obj[key].bind(proxy))\n    }\n\n    return proxy\n}\n","import { data } from './data'\nconst { computedStack, computedDependenciesTracker } = data\n\nexport function computed(wrappedFunction, { autoRun = true, callback, bind, disableTracking = false } = {}) {\n    // Proxify the function in order to intercept the calls\n    const proxy = new Proxy(wrappedFunction, {\n        apply(target, thisArg, argsList) {\n            function observeComputation(fun) {\n                // Track object and object properties accessed during this function call\n                if(!disableTracking) {\n                    computedDependenciesTracker.set(callback || proxy, new WeakMap())\n                }\n                // Store into the stack a reference to the computed function\n                computedStack.unshift(callback || proxy)\n                // Run the computed function - or the async function\n                const result = fun ?\n                    fun() :\n                    target.apply(bind || thisArg, argsList)\n                // Remove the reference\n                computedStack.shift()\n                // Return the result\n                return result\n            }\n\n            // Inject the computeAsync argument which is used to manually declare when the computation takes part\n            argsList.push({\n                computeAsync: function(target) { return observeComputation(target) }\n            })\n\n            return observeComputation()\n        }\n    })\n\n    // If autoRun, then call the function at once\n    if(autoRun) {\n        proxy()\n    }\n\n    return proxy\n}\n","import { observe } from './observe'\nimport { computed } from './computed'\nimport { dispose } from './dispose'\n\nexport default {\n    observe,\n    computed,\n    dispose\n}\n","import { data } from './data'\n\n// The disposed flag which is used to remove a computed function reference pointer\nexport function dispose(computedFunction) {\n    data.computedDependenciesTracker.delete(computedFunction)\n    return computedFunction.__disposed = true\n}\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {Part} from './part.js';\n\nconst directives = new WeakMap<object, true>();\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type DirectiveFactory = (...args: any[]) => object;\n\nexport type DirectiveFn = (part: Part) => void;\n\n/**\n * Brands a function as a directive factory function so that lit-html will call\n * the function during template rendering, rather than passing as a value.\n *\n * A _directive_ is a function that takes a Part as an argument. It has the\n * signature: `(part: Part) => void`.\n *\n * A directive _factory_ is a function that takes arguments for data and\n * configuration and returns a directive. Users of directive usually refer to\n * the directive factory as the directive. For example, \"The repeat directive\".\n *\n * Usually a template author will invoke a directive factory in their template\n * with relevant arguments, which will then return a directive function.\n *\n * Here's an example of using the `repeat()` directive factory that takes an\n * array and a function to render an item:\n *\n * ```js\n * html`<ul><${repeat(items, (item) => html`<li>${item}</li>`)}</ul>`\n * ```\n *\n * When `repeat` is invoked, it returns a directive function that closes over\n * `items` and the template function. When the outer template is rendered, the\n * return directive function is called with the Part for the expression.\n * `repeat` then performs it's custom logic to render multiple items.\n *\n * @param f The directive factory function. Must be a function that returns a\n * function of the signature `(part: Part) => void`. The returned function will\n * be called with the part object.\n *\n * @example\n *\n * import {directive, html} from 'lit-html';\n *\n * const immutable = directive((v) => (part) => {\n *   if (part.value !== v) {\n *     part.setValue(v)\n *   }\n * });\n */\nexport const directive = <F extends DirectiveFactory>(f: F): F =>\n    ((...args: unknown[]) => {\n      const d = f(...args);\n      directives.set(d, true);\n      return d;\n    }) as F;\n\nexport const isDirective = (o: unknown): o is DirectiveFn => {\n  return typeof o === 'function' && directives.has(o);\n};\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\ninterface MaybePolyfilledCe extends CustomElementRegistry {\n  readonly polyfillWrapFlushCallback?: object;\n}\n\n/**\n * True if the custom elements polyfill is in use.\n */\nexport const isCEPolyfill = typeof window !== 'undefined' &&\n    window.customElements != null &&\n    (window.customElements as MaybePolyfilledCe).polyfillWrapFlushCallback !==\n        undefined;\n\n/**\n * Reparents nodes, starting from `start` (inclusive) to `end` (exclusive),\n * into another container (could be the same container), before `before`. If\n * `before` is null, it appends the nodes to the container.\n */\nexport const reparentNodes =\n    (container: Node,\n     start: Node|null,\n     end: Node|null = null,\n     before: Node|null = null): void => {\n      while (start !== end) {\n        const n = start!.nextSibling;\n        container.insertBefore(start!, before);\n        start = n;\n      }\n    };\n\n/**\n * Removes nodes, starting from `start` (inclusive) to `end` (exclusive), from\n * `container`.\n */\nexport const removeNodes =\n    (container: Node, start: Node|null, end: Node|null = null): void => {\n      while (start !== end) {\n        const n = start!.nextSibling;\n        container.removeChild(start!);\n        start = n;\n      }\n    };\n","/**\n * @license\n * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * The Part interface represents a dynamic part of a template instance rendered\n * by lit-html.\n */\nexport interface Part {\n  readonly value: unknown;\n\n  /**\n   * Sets the current part value, but does not write it to the DOM.\n   * @param value The value that will be committed.\n   */\n  setValue(value: unknown): void;\n\n  /**\n   * Commits the current part value, causing it to actually be written to the\n   * DOM.\n   *\n   * Directives are run at the start of `commit`, so that if they call\n   * `part.setValue(...)` synchronously that value will be used in the current\n   * commit, and there's no need to call `part.commit()` within the directive.\n   * If directives set a part value asynchronously, then they must call\n   * `part.commit()` manually.\n   */\n  commit(): void;\n}\n\n/**\n * A sentinel value that signals that a value was handled by a directive and\n * should not be written to the DOM.\n */\nexport const noChange = {};\n\n/**\n * A sentinel value that signals a NodePart to fully clear its content.\n */\nexport const nothing = {};\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {TemplateResult} from './template-result.js';\n\n/**\n * An expression marker with embedded unique key to avoid collision with\n * possible text in templates.\n */\nexport const marker = `{{lit-${String(Math.random()).slice(2)}}}`;\n\n/**\n * An expression marker used text-positions, multi-binding attributes, and\n * attributes with markup-like text values.\n */\nexport const nodeMarker = `<!--${marker}-->`;\n\nexport const markerRegex = new RegExp(`${marker}|${nodeMarker}`);\n\n/**\n * Suffix appended to all bound attribute names.\n */\nexport const boundAttributeSuffix = '$lit$';\n\n/**\n * An updatable Template that tracks the location of dynamic parts.\n */\nexport class Template {\n  readonly parts: TemplatePart[] = [];\n  readonly element: HTMLTemplateElement;\n\n  constructor(result: TemplateResult, element: HTMLTemplateElement) {\n    this.element = element;\n\n    const nodesToRemove: Node[] = [];\n    const stack: Node[] = [];\n    // Edge needs all 4 parameters present; IE11 needs 3rd parameter to be null\n    const walker = document.createTreeWalker(\n        element.content,\n        133 /* NodeFilter.SHOW_{ELEMENT|COMMENT|TEXT} */,\n        null,\n        false);\n    // Keeps track of the last index associated with a part. We try to delete\n    // unnecessary nodes, but we never want to associate two different parts\n    // to the same index. They must have a constant node between.\n    let lastPartIndex = 0;\n    let index = -1;\n    let partIndex = 0;\n    const {strings, values: {length}} = result;\n    while (partIndex < length) {\n      const node = walker.nextNode() as Element | Comment | Text | null;\n      if (node === null) {\n        // We've exhausted the content inside a nested template element.\n        // Because we still have parts (the outer for-loop), we know:\n        // - There is a template in the stack\n        // - The walker will find a nextNode outside the template\n        walker.currentNode = stack.pop()!;\n        continue;\n      }\n      index++;\n\n      if (node.nodeType === 1 /* Node.ELEMENT_NODE */) {\n        if ((node as Element).hasAttributes()) {\n          const attributes = (node as Element).attributes;\n          const {length} = attributes;\n          // Per\n          // https://developer.mozilla.org/en-US/docs/Web/API/NamedNodeMap,\n          // attributes are not guaranteed to be returned in document order.\n          // In particular, Edge/IE can return them out of order, so we cannot\n          // assume a correspondence between part index and attribute index.\n          let count = 0;\n          for (let i = 0; i < length; i++) {\n            if (endsWith(attributes[i].name, boundAttributeSuffix)) {\n              count++;\n            }\n          }\n          while (count-- > 0) {\n            // Get the template literal section leading up to the first\n            // expression in this attribute\n            const stringForPart = strings[partIndex];\n            // Find the attribute name\n            const name = lastAttributeNameRegex.exec(stringForPart)![2];\n            // Find the corresponding attribute\n            // All bound attributes have had a suffix added in\n            // TemplateResult#getHTML to opt out of special attribute\n            // handling. To look up the attribute value we also need to add\n            // the suffix.\n            const attributeLookupName =\n                name.toLowerCase() + boundAttributeSuffix;\n            const attributeValue =\n                (node as Element).getAttribute(attributeLookupName)!;\n            (node as Element).removeAttribute(attributeLookupName);\n            const statics = attributeValue.split(markerRegex);\n            this.parts.push({type: 'attribute', index, name, strings: statics});\n            partIndex += statics.length - 1;\n          }\n        }\n        if ((node as Element).tagName === 'TEMPLATE') {\n          stack.push(node);\n          walker.currentNode = (node as HTMLTemplateElement).content;\n        }\n      } else if (node.nodeType === 3 /* Node.TEXT_NODE */) {\n        const data = (node as Text).data;\n        if (data.indexOf(marker) >= 0) {\n          const parent = node.parentNode!;\n          const strings = data.split(markerRegex);\n          const lastIndex = strings.length - 1;\n          // Generate a new text node for each literal section\n          // These nodes are also used as the markers for node parts\n          for (let i = 0; i < lastIndex; i++) {\n            let insert: Node;\n            let s = strings[i];\n            if (s === '') {\n              insert = createMarker();\n            } else {\n              const match = lastAttributeNameRegex.exec(s);\n              if (match !== null && endsWith(match[2], boundAttributeSuffix)) {\n                s = s.slice(0, match.index) + match[1] +\n                    match[2].slice(0, -boundAttributeSuffix.length) + match[3];\n              }\n              insert = document.createTextNode(s);\n            }\n            parent.insertBefore(insert, node);\n            this.parts.push({type: 'node', index: ++index});\n          }\n          // If there's no text, we must insert a comment to mark our place.\n          // Else, we can trust it will stick around after cloning.\n          if (strings[lastIndex] === '') {\n            parent.insertBefore(createMarker(), node);\n            nodesToRemove.push(node);\n          } else {\n            (node as Text).data = strings[lastIndex];\n          }\n          // We have a part for each match found\n          partIndex += lastIndex;\n        }\n      } else if (node.nodeType === 8 /* Node.COMMENT_NODE */) {\n        if ((node as Comment).data === marker) {\n          const parent = node.parentNode!;\n          // Add a new marker node to be the startNode of the Part if any of\n          // the following are true:\n          //  * We don't have a previousSibling\n          //  * The previousSibling is already the start of a previous part\n          if (node.previousSibling === null || index === lastPartIndex) {\n            index++;\n            parent.insertBefore(createMarker(), node);\n          }\n          lastPartIndex = index;\n          this.parts.push({type: 'node', index});\n          // If we don't have a nextSibling, keep this node so we have an end.\n          // Else, we can remove it to save future costs.\n          if (node.nextSibling === null) {\n            (node as Comment).data = '';\n          } else {\n            nodesToRemove.push(node);\n            index--;\n          }\n          partIndex++;\n        } else {\n          let i = -1;\n          while ((i = (node as Comment).data.indexOf(marker, i + 1)) !== -1) {\n            // Comment node has a binding marker inside, make an inactive part\n            // The binding won't work, but subsequent bindings will\n            // TODO (justinfagnani): consider whether it's even worth it to\n            // make bindings in comments work\n            this.parts.push({type: 'node', index: -1});\n            partIndex++;\n          }\n        }\n      }\n    }\n\n    // Remove text binding nodes after the walk to not disturb the TreeWalker\n    for (const n of nodesToRemove) {\n      n.parentNode!.removeChild(n);\n    }\n  }\n}\n\nconst endsWith = (str: string, suffix: string): boolean => {\n  const index = str.length - suffix.length;\n  return index >= 0 && str.slice(index) === suffix;\n};\n\n/**\n * A placeholder for a dynamic expression in an HTML template.\n *\n * There are two built-in part types: AttributePart and NodePart. NodeParts\n * always represent a single dynamic expression, while AttributeParts may\n * represent as many expressions are contained in the attribute.\n *\n * A Template's parts are mutable, so parts can be replaced or modified\n * (possibly to implement different template semantics). The contract is that\n * parts can only be replaced, not removed, added or reordered, and parts must\n * always consume the correct number of values in their `update()` method.\n *\n * TODO(justinfagnani): That requirement is a little fragile. A\n * TemplateInstance could instead be more careful about which values it gives\n * to Part.update().\n */\nexport type TemplatePart = {\n  readonly type: 'node'; index: number;\n}|{\n  readonly type: 'attribute';\n  index: number;\n  readonly name: string;\n  readonly strings: ReadonlyArray<string>;\n};\n\nexport const isTemplatePartActive = (part: TemplatePart) => part.index !== -1;\n\n// Allows `document.createComment('')` to be renamed for a\n// small manual size-savings.\nexport const createMarker = () => document.createComment('');\n\n/**\n * This regex extracts the attribute name preceding an attribute-position\n * expression. It does this by matching the syntax allowed for attributes\n * against the string literal directly preceding the expression, assuming that\n * the expression is in an attribute-value position.\n *\n * See attributes in the HTML spec:\n * https://www.w3.org/TR/html5/syntax.html#elements-attributes\n *\n * \" \\x09\\x0a\\x0c\\x0d\" are HTML space characters:\n * https://www.w3.org/TR/html5/infrastructure.html#space-characters\n *\n * \"\\0-\\x1F\\x7F-\\x9F\" are Unicode control characters, which includes every\n * space character except \" \".\n *\n * So an attribute is:\n *  * The name: any character except a control character, space character, ('),\n *    (\"), \">\", \"=\", or \"/\"\n *  * Followed by zero or more space characters\n *  * Followed by \"=\"\n *  * Followed by zero or more space characters\n *  * Followed by:\n *    * Any character except space, ('), (\"), \"<\", \">\", \"=\", (`), or\n *    * (\") then any non-(\"), or\n *    * (') then any non-(')\n */\nexport const lastAttributeNameRegex =\n    // eslint-disable-next-line no-control-regex\n    /([ \\x09\\x0a\\x0c\\x0d])([^\\0-\\x1F\\x7F-\\x9F \"'>=/]+)([ \\x09\\x0a\\x0c\\x0d]*=[ \\x09\\x0a\\x0c\\x0d]*(?:[^ \\x09\\x0a\\x0c\\x0d\"'`<>=]*|\"[^\"]*|'[^']*))$/;\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {isCEPolyfill} from './dom.js';\nimport {Part} from './part.js';\nimport {RenderOptions} from './render-options.js';\nimport {TemplateProcessor} from './template-processor.js';\nimport {isTemplatePartActive, Template, TemplatePart} from './template.js';\n\n/**\n * An instance of a `Template` that can be attached to the DOM and updated\n * with new values.\n */\nexport class TemplateInstance {\n  private readonly __parts: Array<Part|undefined> = [];\n  readonly processor: TemplateProcessor;\n  readonly options: RenderOptions;\n  readonly template: Template;\n\n  constructor(\n      template: Template, processor: TemplateProcessor,\n      options: RenderOptions) {\n    this.template = template;\n    this.processor = processor;\n    this.options = options;\n  }\n\n  update(values: readonly unknown[]) {\n    let i = 0;\n    for (const part of this.__parts) {\n      if (part !== undefined) {\n        part.setValue(values[i]);\n      }\n      i++;\n    }\n    for (const part of this.__parts) {\n      if (part !== undefined) {\n        part.commit();\n      }\n    }\n  }\n\n  _clone(): DocumentFragment {\n    // There are a number of steps in the lifecycle of a template instance's\n    // DOM fragment:\n    //  1. Clone - create the instance fragment\n    //  2. Adopt - adopt into the main document\n    //  3. Process - find part markers and create parts\n    //  4. Upgrade - upgrade custom elements\n    //  5. Update - set node, attribute, property, etc., values\n    //  6. Connect - connect to the document. Optional and outside of this\n    //     method.\n    //\n    // We have a few constraints on the ordering of these steps:\n    //  * We need to upgrade before updating, so that property values will pass\n    //    through any property setters.\n    //  * We would like to process before upgrading so that we're sure that the\n    //    cloned fragment is inert and not disturbed by self-modifying DOM.\n    //  * We want custom elements to upgrade even in disconnected fragments.\n    //\n    // Given these constraints, with full custom elements support we would\n    // prefer the order: Clone, Process, Adopt, Upgrade, Update, Connect\n    //\n    // But Safari does not implement CustomElementRegistry#upgrade, so we\n    // can not implement that order and still have upgrade-before-update and\n    // upgrade disconnected fragments. So we instead sacrifice the\n    // process-before-upgrade constraint, since in Custom Elements v1 elements\n    // must not modify their light DOM in the constructor. We still have issues\n    // when co-existing with CEv0 elements like Polymer 1, and with polyfills\n    // that don't strictly adhere to the no-modification rule because shadow\n    // DOM, which may be created in the constructor, is emulated by being placed\n    // in the light DOM.\n    //\n    // The resulting order is on native is: Clone, Adopt, Upgrade, Process,\n    // Update, Connect. document.importNode() performs Clone, Adopt, and Upgrade\n    // in one step.\n    //\n    // The Custom Elements v1 polyfill supports upgrade(), so the order when\n    // polyfilled is the more ideal: Clone, Process, Adopt, Upgrade, Update,\n    // Connect.\n\n    const fragment = isCEPolyfill ?\n        this.template.element.content.cloneNode(true) as DocumentFragment :\n        document.importNode(this.template.element.content, true);\n\n    const stack: Node[] = [];\n    const parts = this.template.parts;\n    // Edge needs all 4 parameters present; IE11 needs 3rd parameter to be null\n    const walker = document.createTreeWalker(\n        fragment,\n        133 /* NodeFilter.SHOW_{ELEMENT|COMMENT|TEXT} */,\n        null,\n        false);\n    let partIndex = 0;\n    let nodeIndex = 0;\n    let part: TemplatePart;\n    let node = walker.nextNode();\n    // Loop through all the nodes and parts of a template\n    while (partIndex < parts.length) {\n      part = parts[partIndex];\n      if (!isTemplatePartActive(part)) {\n        this.__parts.push(undefined);\n        partIndex++;\n        continue;\n      }\n\n      // Progress the tree walker until we find our next part's node.\n      // Note that multiple parts may share the same node (attribute parts\n      // on a single element), so this loop may not run at all.\n      while (nodeIndex < part.index) {\n        nodeIndex++;\n        if (node!.nodeName === 'TEMPLATE') {\n          stack.push(node!);\n          walker.currentNode = (node as HTMLTemplateElement).content;\n        }\n        if ((node = walker.nextNode()) === null) {\n          // We've exhausted the content inside a nested template element.\n          // Because we still have parts (the outer for-loop), we know:\n          // - There is a template in the stack\n          // - The walker will find a nextNode outside the template\n          walker.currentNode = stack.pop()!;\n          node = walker.nextNode();\n        }\n      }\n\n      // We've arrived at our part's node.\n      if (part.type === 'node') {\n        const part = this.processor.handleTextExpression(this.options);\n        part.insertAfterNode(node!.previousSibling!);\n        this.__parts.push(part);\n      } else {\n        this.__parts.push(...this.processor.handleAttributeExpressions(\n            node as Element, part.name, part.strings, this.options));\n      }\n      partIndex++;\n    }\n\n    if (isCEPolyfill) {\n      document.adoptNode(fragment);\n      customElements.upgrade(fragment);\n    }\n    return fragment;\n  }\n}\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n * @module lit-html\n */\n\nimport {reparentNodes} from './dom.js';\nimport {TemplateProcessor} from './template-processor.js';\nimport {boundAttributeSuffix, lastAttributeNameRegex, marker, nodeMarker} from './template.js';\n\ndeclare const trustedTypes: typeof window.trustedTypes;\n/**\n * Our TrustedTypePolicy for HTML which is declared using the html template\n * tag function.\n *\n * That HTML is a developer-authored constant, and is parsed with innerHTML\n * before any untrusted expressions have been mixed in. Therefor it is\n * considered safe by construction.\n */\nconst policy = window.trustedTypes &&\n    trustedTypes!.createPolicy('lit-html', {createHTML: (s) => s});\n\nconst commentMarker = ` ${marker} `;\n\n/**\n * The return type of `html`, which holds a Template and the values from\n * interpolated expressions.\n */\nexport class TemplateResult {\n  readonly strings: TemplateStringsArray;\n  readonly values: readonly unknown[];\n  readonly type: string;\n  readonly processor: TemplateProcessor;\n\n  constructor(\n      strings: TemplateStringsArray, values: readonly unknown[], type: string,\n      processor: TemplateProcessor) {\n    this.strings = strings;\n    this.values = values;\n    this.type = type;\n    this.processor = processor;\n  }\n\n  /**\n   * Returns a string of HTML used to create a `<template>` element.\n   */\n  getHTML(): string {\n    const l = this.strings.length - 1;\n    let html = '';\n    let isCommentBinding = false;\n\n    for (let i = 0; i < l; i++) {\n      const s = this.strings[i];\n      // For each binding we want to determine the kind of marker to insert\n      // into the template source before it's parsed by the browser's HTML\n      // parser. The marker type is based on whether the expression is in an\n      // attribute, text, or comment position.\n      //   * For node-position bindings we insert a comment with the marker\n      //     sentinel as its text content, like <!--{{lit-guid}}-->.\n      //   * For attribute bindings we insert just the marker sentinel for the\n      //     first binding, so that we support unquoted attribute bindings.\n      //     Subsequent bindings can use a comment marker because multi-binding\n      //     attributes must be quoted.\n      //   * For comment bindings we insert just the marker sentinel so we don't\n      //     close the comment.\n      //\n      // The following code scans the template source, but is *not* an HTML\n      // parser. We don't need to track the tree structure of the HTML, only\n      // whether a binding is inside a comment, and if not, if it appears to be\n      // the first binding in an attribute.\n      const commentOpen = s.lastIndexOf('<!--');\n      // We're in comment position if we have a comment open with no following\n      // comment close. Because <-- can appear in an attribute value there can\n      // be false positives.\n      isCommentBinding = (commentOpen > -1 || isCommentBinding) &&\n          s.indexOf('-->', commentOpen + 1) === -1;\n      // Check to see if we have an attribute-like sequence preceding the\n      // expression. This can match \"name=value\" like structures in text,\n      // comments, and attribute values, so there can be false-positives.\n      const attributeMatch = lastAttributeNameRegex.exec(s);\n      if (attributeMatch === null) {\n        // We're only in this branch if we don't have a attribute-like\n        // preceding sequence. For comments, this guards against unusual\n        // attribute values like <div foo=\"<!--${'bar'}\">. Cases like\n        // <!-- foo=${'bar'}--> are handled correctly in the attribute branch\n        // below.\n        html += s + (isCommentBinding ? commentMarker : nodeMarker);\n      } else {\n        // For attributes we use just a marker sentinel, and also append a\n        // $lit$ suffix to the name to opt-out of attribute-specific parsing\n        // that IE and Edge do for style and certain SVG attributes.\n        html += s.substr(0, attributeMatch.index) + attributeMatch[1] +\n            attributeMatch[2] + boundAttributeSuffix + attributeMatch[3] +\n            marker;\n      }\n    }\n    html += this.strings[l];\n    return html;\n  }\n\n  getTemplateElement(): HTMLTemplateElement {\n    const template = document.createElement('template');\n    let value = this.getHTML();\n    if (policy !== undefined) {\n      // this is secure because `this.strings` is a TemplateStringsArray.\n      // TODO: validate this when\n      // https://github.com/tc39/proposal-array-is-template-object is\n      // implemented.\n      value = policy.createHTML(value) as unknown as string;\n    }\n    template.innerHTML = value;\n    return template;\n  }\n}\n\n/**\n * A TemplateResult for SVG fragments.\n *\n * This class wraps HTML in an `<svg>` tag in order to parse its contents in the\n * SVG namespace, then modifies the template to remove the `<svg>` tag so that\n * clones only container the original fragment.\n */\nexport class SVGTemplateResult extends TemplateResult {\n  getHTML(): string {\n    return `<svg>${super.getHTML()}</svg>`;\n  }\n\n  getTemplateElement(): HTMLTemplateElement {\n    const template = super.getTemplateElement();\n    const content = template.content;\n    const svgElement = content.firstChild!;\n    content.removeChild(svgElement);\n    reparentNodes(content, svgElement.firstChild);\n    return template;\n  }\n}\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {isDirective} from './directive.js';\nimport {removeNodes} from './dom.js';\nimport {noChange, nothing, Part} from './part.js';\nimport {RenderOptions} from './render-options.js';\nimport {TemplateInstance} from './template-instance.js';\nimport {TemplateResult} from './template-result.js';\nimport {createMarker} from './template.js';\n\n// https://tc39.github.io/ecma262/#sec-typeof-operator\nexport type Primitive = null|undefined|boolean|number|string|symbol|bigint;\nexport const isPrimitive = (value: unknown): value is Primitive => {\n  return (\n      value === null ||\n      !(typeof value === 'object' || typeof value === 'function'));\n};\nexport const isIterable = (value: unknown): value is Iterable<unknown> => {\n  return Array.isArray(value) ||\n      // eslint-disable-next-line @typescript-eslint/no-explicit-any\n      !!(value && (value as any)[Symbol.iterator]);\n};\n\n/**\n * Writes attribute values to the DOM for a group of AttributeParts bound to a\n * single attribute. The value is only set once even if there are multiple parts\n * for an attribute.\n */\nexport class AttributeCommitter {\n  readonly element: Element;\n  readonly name: string;\n  readonly strings: ReadonlyArray<string>;\n  readonly parts: ReadonlyArray<AttributePart>;\n  dirty = true;\n\n  constructor(element: Element, name: string, strings: ReadonlyArray<string>) {\n    this.element = element;\n    this.name = name;\n    this.strings = strings;\n    this.parts = [];\n    for (let i = 0; i < strings.length - 1; i++) {\n      (this.parts as AttributePart[])[i] = this._createPart();\n    }\n  }\n\n  /**\n   * Creates a single part. Override this to create a differnt type of part.\n   */\n  protected _createPart(): AttributePart {\n    return new AttributePart(this);\n  }\n\n  protected _getValue(): unknown {\n    const strings = this.strings;\n    const l = strings.length - 1;\n    const parts = this.parts;\n\n    // If we're assigning an attribute via syntax like:\n    //    attr=\"${foo}\"  or  attr=${foo}\n    // but not\n    //    attr=\"${foo} ${bar}\" or attr=\"${foo} baz\"\n    // then we don't want to coerce the attribute value into one long\n    // string. Instead we want to just return the value itself directly,\n    // so that sanitizeDOMValue can get the actual value rather than\n    // String(value)\n    // The exception is if v is an array, in which case we do want to smash\n    // it together into a string without calling String() on the array.\n    //\n    // This also allows trusted values (when using TrustedTypes) being\n    // assigned to DOM sinks without being stringified in the process.\n    if (l === 1 && strings[0] === '' && strings[1] === '') {\n      const v = parts[0].value;\n      if (typeof v === 'symbol') {\n        return String(v);\n      }\n      if (typeof v === 'string' || !isIterable(v)) {\n        return v;\n      }\n    }\n    let text = '';\n\n    for (let i = 0; i < l; i++) {\n      text += strings[i];\n      const part = parts[i];\n      if (part !== undefined) {\n        const v = part.value;\n        if (isPrimitive(v) || !isIterable(v)) {\n          text += typeof v === 'string' ? v : String(v);\n        } else {\n          for (const t of v) {\n            text += typeof t === 'string' ? t : String(t);\n          }\n        }\n      }\n    }\n\n    text += strings[l];\n    return text;\n  }\n\n  commit(): void {\n    if (this.dirty) {\n      this.dirty = false;\n      this.element.setAttribute(this.name, this._getValue() as string);\n    }\n  }\n}\n\n/**\n * A Part that controls all or part of an attribute value.\n */\nexport class AttributePart implements Part {\n  readonly committer: AttributeCommitter;\n  value: unknown = undefined;\n\n  constructor(committer: AttributeCommitter) {\n    this.committer = committer;\n  }\n\n  setValue(value: unknown): void {\n    if (value !== noChange && (!isPrimitive(value) || value !== this.value)) {\n      this.value = value;\n      // If the value is a not a directive, dirty the committer so that it'll\n      // call setAttribute. If the value is a directive, it'll dirty the\n      // committer if it calls setValue().\n      if (!isDirective(value)) {\n        this.committer.dirty = true;\n      }\n    }\n  }\n\n  commit() {\n    while (isDirective(this.value)) {\n      const directive = this.value;\n      this.value = noChange;\n      directive(this);\n    }\n    if (this.value === noChange) {\n      return;\n    }\n    this.committer.commit();\n  }\n}\n\n/**\n * A Part that controls a location within a Node tree. Like a Range, NodePart\n * has start and end locations and can set and update the Nodes between those\n * locations.\n *\n * NodeParts support several value types: primitives, Nodes, TemplateResults,\n * as well as arrays and iterables of those types.\n */\nexport class NodePart implements Part {\n  readonly options: RenderOptions;\n  startNode!: Node;\n  endNode!: Node;\n  value: unknown = undefined;\n  private __pendingValue: unknown = undefined;\n\n  constructor(options: RenderOptions) {\n    this.options = options;\n  }\n\n  /**\n   * Appends this part into a container.\n   *\n   * This part must be empty, as its contents are not automatically moved.\n   */\n  appendInto(container: Node) {\n    this.startNode = container.appendChild(createMarker());\n    this.endNode = container.appendChild(createMarker());\n  }\n\n  /**\n   * Inserts this part after the `ref` node (between `ref` and `ref`'s next\n   * sibling). Both `ref` and its next sibling must be static, unchanging nodes\n   * such as those that appear in a literal section of a template.\n   *\n   * This part must be empty, as its contents are not automatically moved.\n   */\n  insertAfterNode(ref: Node) {\n    this.startNode = ref;\n    this.endNode = ref.nextSibling!;\n  }\n\n  /**\n   * Appends this part into a parent part.\n   *\n   * This part must be empty, as its contents are not automatically moved.\n   */\n  appendIntoPart(part: NodePart) {\n    part.__insert(this.startNode = createMarker());\n    part.__insert(this.endNode = createMarker());\n  }\n\n  /**\n   * Inserts this part after the `ref` part.\n   *\n   * This part must be empty, as its contents are not automatically moved.\n   */\n  insertAfterPart(ref: NodePart) {\n    ref.__insert(this.startNode = createMarker());\n    this.endNode = ref.endNode;\n    ref.endNode = this.startNode;\n  }\n\n  setValue(value: unknown): void {\n    this.__pendingValue = value;\n  }\n\n  commit() {\n    if (this.startNode.parentNode === null) {\n      return;\n    }\n    while (isDirective(this.__pendingValue)) {\n      const directive = this.__pendingValue;\n      this.__pendingValue = noChange;\n      directive(this);\n    }\n    const value = this.__pendingValue;\n    if (value === noChange) {\n      return;\n    }\n    if (isPrimitive(value)) {\n      if (value !== this.value) {\n        this.__commitText(value);\n      }\n    } else if (value instanceof TemplateResult) {\n      this.__commitTemplateResult(value);\n    } else if (value instanceof Node) {\n      this.__commitNode(value);\n    } else if (isIterable(value)) {\n      this.__commitIterable(value);\n    } else if (value === nothing) {\n      this.value = nothing;\n      this.clear();\n    } else {\n      // Fallback, will render the string representation\n      this.__commitText(value);\n    }\n  }\n\n  private __insert(node: Node) {\n    this.endNode.parentNode!.insertBefore(node, this.endNode);\n  }\n\n  private __commitNode(value: Node): void {\n    if (this.value === value) {\n      return;\n    }\n    this.clear();\n    this.__insert(value);\n    this.value = value;\n  }\n\n  private __commitText(value: unknown): void {\n    const node = this.startNode.nextSibling!;\n    value = value == null ? '' : value;\n    // If `value` isn't already a string, we explicitly convert it here in case\n    // it can't be implicitly converted - i.e. it's a symbol.\n    const valueAsString: string =\n        typeof value === 'string' ? value : String(value);\n    if (node === this.endNode.previousSibling &&\n        node.nodeType === 3 /* Node.TEXT_NODE */) {\n      // If we only have a single text node between the markers, we can just\n      // set its value, rather than replacing it.\n      // TODO(justinfagnani): Can we just check if this.value is primitive?\n      (node as Text).data = valueAsString;\n    } else {\n      this.__commitNode(document.createTextNode(valueAsString));\n    }\n    this.value = value;\n  }\n\n  private __commitTemplateResult(value: TemplateResult): void {\n    const template = this.options.templateFactory(value);\n    if (this.value instanceof TemplateInstance &&\n        this.value.template === template) {\n      this.value.update(value.values);\n    } else {\n      // Make sure we propagate the template processor from the TemplateResult\n      // so that we use its syntax extension, etc. The template factory comes\n      // from the render function options so that it can control template\n      // caching and preprocessing.\n      const instance =\n          new TemplateInstance(template, value.processor, this.options);\n      const fragment = instance._clone();\n      instance.update(value.values);\n      this.__commitNode(fragment);\n      this.value = instance;\n    }\n  }\n\n  private __commitIterable(value: Iterable<unknown>): void {\n    // For an Iterable, we create a new InstancePart per item, then set its\n    // value to the item. This is a little bit of overhead for every item in\n    // an Iterable, but it lets us recurse easily and efficiently update Arrays\n    // of TemplateResults that will be commonly returned from expressions like:\n    // array.map((i) => html`${i}`), by reusing existing TemplateInstances.\n\n    // If _value is an array, then the previous render was of an\n    // iterable and _value will contain the NodeParts from the previous\n    // render. If _value is not an array, clear this part and make a new\n    // array for NodeParts.\n    if (!Array.isArray(this.value)) {\n      this.value = [];\n      this.clear();\n    }\n\n    // Lets us keep track of how many items we stamped so we can clear leftover\n    // items from a previous render\n    const itemParts = this.value as NodePart[];\n    let partIndex = 0;\n    let itemPart: NodePart|undefined;\n\n    for (const item of value) {\n      // Try to reuse an existing part\n      itemPart = itemParts[partIndex];\n\n      // If no existing part, create a new one\n      if (itemPart === undefined) {\n        itemPart = new NodePart(this.options);\n        itemParts.push(itemPart);\n        if (partIndex === 0) {\n          itemPart.appendIntoPart(this);\n        } else {\n          itemPart.insertAfterPart(itemParts[partIndex - 1]);\n        }\n      }\n      itemPart.setValue(item);\n      itemPart.commit();\n      partIndex++;\n    }\n\n    if (partIndex < itemParts.length) {\n      // Truncate the parts array so _value reflects the current state\n      itemParts.length = partIndex;\n      this.clear(itemPart && itemPart.endNode);\n    }\n  }\n\n  clear(startNode: Node = this.startNode) {\n    removeNodes(\n        this.startNode.parentNode!, startNode.nextSibling!, this.endNode);\n  }\n}\n\n/**\n * Implements a boolean attribute, roughly as defined in the HTML\n * specification.\n *\n * If the value is truthy, then the attribute is present with a value of\n * ''. If the value is falsey, the attribute is removed.\n */\nexport class BooleanAttributePart implements Part {\n  readonly element: Element;\n  readonly name: string;\n  readonly strings: readonly string[];\n  value: unknown = undefined;\n  private __pendingValue: unknown = undefined;\n\n  constructor(element: Element, name: string, strings: readonly string[]) {\n    if (strings.length !== 2 || strings[0] !== '' || strings[1] !== '') {\n      throw new Error(\n          'Boolean attributes can only contain a single expression');\n    }\n    this.element = element;\n    this.name = name;\n    this.strings = strings;\n  }\n\n  setValue(value: unknown): void {\n    this.__pendingValue = value;\n  }\n\n  commit() {\n    while (isDirective(this.__pendingValue)) {\n      const directive = this.__pendingValue;\n      this.__pendingValue = noChange;\n      directive(this);\n    }\n    if (this.__pendingValue === noChange) {\n      return;\n    }\n    const value = !!this.__pendingValue;\n    if (this.value !== value) {\n      if (value) {\n        this.element.setAttribute(this.name, '');\n      } else {\n        this.element.removeAttribute(this.name);\n      }\n      this.value = value;\n    }\n    this.__pendingValue = noChange;\n  }\n}\n\n/**\n * Sets attribute values for PropertyParts, so that the value is only set once\n * even if there are multiple parts for a property.\n *\n * If an expression controls the whole property value, then the value is simply\n * assigned to the property under control. If there are string literals or\n * multiple expressions, then the strings are expressions are interpolated into\n * a string first.\n */\nexport class PropertyCommitter extends AttributeCommitter {\n  readonly single: boolean;\n\n  constructor(element: Element, name: string, strings: ReadonlyArray<string>) {\n    super(element, name, strings);\n    this.single =\n        (strings.length === 2 && strings[0] === '' && strings[1] === '');\n  }\n\n  protected _createPart(): PropertyPart {\n    return new PropertyPart(this);\n  }\n\n  protected _getValue() {\n    if (this.single) {\n      return this.parts[0].value;\n    }\n    return super._getValue();\n  }\n\n  commit(): void {\n    if (this.dirty) {\n      this.dirty = false;\n      // eslint-disable-next-line @typescript-eslint/no-explicit-any\n      (this.element as any)[this.name] = this._getValue();\n    }\n  }\n}\n\nexport class PropertyPart extends AttributePart {}\n\n// Detect event listener options support. If the `capture` property is read\n// from the options object, then options are supported. If not, then the third\n// argument to add/removeEventListener is interpreted as the boolean capture\n// value so we should only pass the `capture` property.\nlet eventOptionsSupported = false;\n\n// Wrap into an IIFE because MS Edge <= v41 does not support having try/catch\n// blocks right into the body of a module\n(() => {\n  try {\n    const options = {\n      get capture() {\n        eventOptionsSupported = true;\n        return false;\n      }\n    };\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    window.addEventListener('test', options as any, options);\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any\n    window.removeEventListener('test', options as any, options);\n  } catch (_e) {\n    // event options not supported\n  }\n})();\n\ntype EventHandlerWithOptions =\n    EventListenerOrEventListenerObject&Partial<AddEventListenerOptions>;\nexport class EventPart implements Part {\n  readonly element: Element;\n  readonly eventName: string;\n  readonly eventContext?: EventTarget;\n  value: undefined|EventHandlerWithOptions = undefined;\n  private __options?: AddEventListenerOptions;\n  private __pendingValue: undefined|EventHandlerWithOptions = undefined;\n  private readonly __boundHandleEvent: (event: Event) => void;\n\n  constructor(element: Element, eventName: string, eventContext?: EventTarget) {\n    this.element = element;\n    this.eventName = eventName;\n    this.eventContext = eventContext;\n    this.__boundHandleEvent = (e) => this.handleEvent(e);\n  }\n\n  setValue(value: undefined|EventHandlerWithOptions): void {\n    this.__pendingValue = value;\n  }\n\n  commit() {\n    while (isDirective(this.__pendingValue)) {\n      const directive = this.__pendingValue;\n      this.__pendingValue = noChange as EventHandlerWithOptions;\n      directive(this);\n    }\n    if (this.__pendingValue === noChange) {\n      return;\n    }\n\n    const newListener = this.__pendingValue;\n    const oldListener = this.value;\n    const shouldRemoveListener = newListener == null ||\n        oldListener != null &&\n            (newListener.capture !== oldListener.capture ||\n             newListener.once !== oldListener.once ||\n             newListener.passive !== oldListener.passive);\n    const shouldAddListener =\n        newListener != null && (oldListener == null || shouldRemoveListener);\n\n    if (shouldRemoveListener) {\n      this.element.removeEventListener(\n          this.eventName, this.__boundHandleEvent, this.__options);\n    }\n    if (shouldAddListener) {\n      this.__options = getOptions(newListener);\n      this.element.addEventListener(\n          this.eventName, this.__boundHandleEvent, this.__options);\n    }\n    this.value = newListener;\n    this.__pendingValue = noChange as EventHandlerWithOptions;\n  }\n\n  handleEvent(event: Event) {\n    if (typeof this.value === 'function') {\n      this.value.call(this.eventContext || this.element, event);\n    } else {\n      (this.value as EventListenerObject).handleEvent(event);\n    }\n  }\n}\n\n// We copy options because of the inconsistent behavior of browsers when reading\n// the third argument of add/removeEventListener. IE11 doesn't support options\n// at all. Chrome 41 only reads `capture` if the argument is an object.\nconst getOptions = (o: AddEventListenerOptions|undefined) => o &&\n    (eventOptionsSupported ?\n         {capture: o.capture, passive: o.passive, once: o.once} :\n         o.capture as AddEventListenerOptions);\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {Part} from './part.js';\nimport {AttributeCommitter, BooleanAttributePart, EventPart, NodePart, PropertyCommitter} from './parts.js';\nimport {RenderOptions} from './render-options.js';\nimport {TemplateProcessor} from './template-processor.js';\n\n/**\n * Creates Parts when a template is instantiated.\n */\nexport class DefaultTemplateProcessor implements TemplateProcessor {\n  /**\n   * Create parts for an attribute-position binding, given the event, attribute\n   * name, and string literals.\n   *\n   * @param element The element containing the binding\n   * @param name  The attribute name\n   * @param strings The string literals. There are always at least two strings,\n   *   event for fully-controlled bindings with a single expression.\n   */\n  handleAttributeExpressions(\n      element: Element, name: string, strings: string[],\n      options: RenderOptions): ReadonlyArray<Part> {\n    const prefix = name[0];\n    if (prefix === '.') {\n      const committer = new PropertyCommitter(element, name.slice(1), strings);\n      return committer.parts;\n    }\n    if (prefix === '@') {\n      return [new EventPart(element, name.slice(1), options.eventContext)];\n    }\n    if (prefix === '?') {\n      return [new BooleanAttributePart(element, name.slice(1), strings)];\n    }\n    const committer = new AttributeCommitter(element, name, strings);\n    return committer.parts;\n  }\n  /**\n   * Create parts for a text-position binding.\n   * @param templateFactory\n   */\n  handleTextExpression(options: RenderOptions) {\n    return new NodePart(options);\n  }\n}\n\nexport const defaultTemplateProcessor = new DefaultTemplateProcessor();\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {TemplateResult} from './template-result.js';\nimport {marker, Template} from './template.js';\n\n/**\n * A function type that creates a Template from a TemplateResult.\n *\n * This is a hook into the template-creation process for rendering that\n * requires some modification of templates before they're used, like ShadyCSS,\n * which must add classes to elements and remove styles.\n *\n * Templates should be cached as aggressively as possible, so that many\n * TemplateResults produced from the same expression only do the work of\n * creating the Template the first time.\n *\n * Templates are usually cached by TemplateResult.strings and\n * TemplateResult.type, but may be cached by other keys if this function\n * modifies the template.\n *\n * Note that currently TemplateFactories must not add, remove, or reorder\n * expressions, because there is no way to describe such a modification\n * to render() so that values are interpolated to the correct place in the\n * template instances.\n */\nexport type TemplateFactory = (result: TemplateResult) => Template;\n\n/**\n * The default TemplateFactory which caches Templates keyed on\n * result.type and result.strings.\n */\nexport function templateFactory(result: TemplateResult) {\n  let templateCache = templateCaches.get(result.type);\n  if (templateCache === undefined) {\n    templateCache = {\n      stringsArray: new WeakMap<TemplateStringsArray, Template>(),\n      keyString: new Map<string, Template>()\n    };\n    templateCaches.set(result.type, templateCache);\n  }\n\n  let template = templateCache.stringsArray.get(result.strings);\n  if (template !== undefined) {\n    return template;\n  }\n\n  // If the TemplateStringsArray is new, generate a key from the strings\n  // This key is shared between all templates with identical content\n  const key = result.strings.join(marker);\n\n  // Check if we already have a Template for this key\n  template = templateCache.keyString.get(key);\n  if (template === undefined) {\n    // If we have not seen this key before, create a new Template\n    template = new Template(result, result.getTemplateElement());\n    // Cache the Template for this key\n    templateCache.keyString.set(key, template);\n  }\n\n  // Cache all future queries for this TemplateStringsArray\n  templateCache.stringsArray.set(result.strings, template);\n  return template;\n}\n\n/**\n * The first argument to JS template tags retain identity across multiple\n * calls to a tag for the same literal, so we can cache work done per literal\n * in a Map.\n *\n * Safari currently has a bug which occasionally breaks this behavior, so we\n * need to cache the Template at two levels. We first cache the\n * TemplateStringsArray, and if that fails, we cache a key constructed by\n * joining the strings array.\n */\nexport interface TemplateCache {\n  readonly stringsArray: WeakMap<TemplateStringsArray, Template>;\n  readonly keyString: Map<string, Template>;\n}\n\nexport const templateCaches = new Map<string, TemplateCache>();\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {removeNodes} from './dom.js';\nimport {NodePart} from './parts.js';\nimport {RenderOptions} from './render-options.js';\nimport {templateFactory} from './template-factory.js';\n\nexport const parts = new WeakMap<Node, NodePart>();\n\n/**\n * Renders a template result or other value to a container.\n *\n * To update a container with new values, reevaluate the template literal and\n * call `render` with the new result.\n *\n * @param result Any value renderable by NodePart - typically a TemplateResult\n *     created by evaluating a template tag like `html` or `svg`.\n * @param container A DOM parent to render to. The entire contents are either\n *     replaced, or efficiently updated if the same result type was previous\n *     rendered there.\n * @param options RenderOptions for the entire render tree rendered to this\n *     container. Render options must *not* change between renders to the same\n *     container, as those changes will not effect previously rendered DOM.\n */\nexport const render =\n    (result: unknown,\n     container: Element|DocumentFragment,\n     options?: Partial<RenderOptions>) => {\n      let part = parts.get(container);\n      if (part === undefined) {\n        removeNodes(container, container.firstChild);\n        parts.set(container, part = new NodePart({\n                               templateFactory,\n                               ...options,\n                             }));\n        part.appendInto(container);\n      }\n      part.setValue(result);\n      part.commit();\n    };\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\n/**\n *\n * Main lit-html module.\n *\n * Main exports:\n *\n * -  [[html]]\n * -  [[svg]]\n * -  [[render]]\n *\n * @packageDocumentation\n */\n\n/**\n * Do not remove this comment; it keeps typedoc from misplacing the module\n * docs.\n */\nimport {defaultTemplateProcessor} from './lib/default-template-processor.js';\nimport {SVGTemplateResult, TemplateResult} from './lib/template-result.js';\n\nexport {DefaultTemplateProcessor, defaultTemplateProcessor} from './lib/default-template-processor.js';\nexport {directive, DirectiveFn, isDirective} from './lib/directive.js';\n// TODO(justinfagnani): remove line when we get NodePart moving methods\nexport {removeNodes, reparentNodes} from './lib/dom.js';\nexport {noChange, nothing, Part} from './lib/part.js';\nexport {AttributeCommitter, AttributePart, BooleanAttributePart, EventPart, isIterable, isPrimitive, NodePart, PropertyCommitter, PropertyPart} from './lib/parts.js';\nexport {RenderOptions} from './lib/render-options.js';\nexport {parts, render} from './lib/render.js';\nexport {templateCaches, templateFactory} from './lib/template-factory.js';\nexport {TemplateInstance} from './lib/template-instance.js';\nexport {TemplateProcessor} from './lib/template-processor.js';\nexport {SVGTemplateResult, TemplateResult} from './lib/template-result.js';\nexport {createMarker, isTemplatePartActive, Template} from './lib/template.js';\n\ndeclare global {\n  interface Window {\n    litHtmlVersions: string[];\n  }\n}\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for lit-html usage.\n// TODO(justinfagnani): inject version number at build time\nif (typeof window !== 'undefined') {\n  (window['litHtmlVersions'] || (window['litHtmlVersions'] = [])).push('1.3.0');\n}\n\n/**\n * Interprets a template literal as an HTML template that can efficiently\n * render to and update a container.\n */\nexport const html = (strings: TemplateStringsArray, ...values: unknown[]) =>\n    new TemplateResult(strings, values, 'html', defaultTemplateProcessor);\n\n/**\n * Interprets a template literal as an SVG template that can efficiently\n * render to and update a container.\n */\nexport const svg = (strings: TemplateStringsArray, ...values: unknown[]) =>\n    new SVGTemplateResult(strings, values, 'svg', defaultTemplateProcessor);\n","import { render, nothing } from 'lit-html';\n\nexport const unrender = (target: Element | DocumentFragment) => render(nothing, target);\n\nexport const noop = (...args: any[]) => { };\n\nexport const tick = (fn: (() => any) = noop): Promise<undefined> => new Promise((resolve) => setTimeout(resolve)).then(fn);\n\nexport const memo = (fn: (...args: any[]) => any, invalidate?: (...args: any[]) => any) => {\n    const cache = new Map();\n    return (...args: any[]) => {\n        let key;\n        if (typeof invalidate === 'function') {\n            const validOrKey = invalidate.apply(fn, args);\n            if (validOrKey === false) { // invalidate the cache\n                key = JSON.stringify(args);\n                cache.delete(key);\n            } else if (validOrKey !== true) { // set custom cache key\n                key = validOrKey;\n            }\n        }\n\n        if (key === undefined) {\n            key = JSON.stringify(args);\n        }\n\n        if (cache.has(key)) {\n            return cache.get(key);\n        }\n\n        const result = fn.apply(fn, args);\n        cache.set(key, result);\n\n        return result;\n    };\n};\n\nexport function attrToVal(str: string): any {\n    if (str === 'true' || str === 'false') {\n        return str === 'true';\n    } else if (str === 'null') {\n        return null;\n    } else if (str === 'undefined') {\n        return undefined;\n    } else if (str !== '' && !isNaN(Number(str))) {\n        return Number(str);\n    } else {\n        try {\n            return JSON.parse(str);\n        } catch (e) { }\n    }\n    return str;\n}\n\nexport function camelCase(str: string, pascal: boolean = false): string {\n    const camel = str.replace(/-([a-z])/g, (_, w) => w.toUpperCase());\n    return pascal ? camel.replace(/^\\w/, s => s.toUpperCase()) : camel;\n}\n\nexport function kebabCase(str: string): string {\n    return str.replace(/[A-Z]/g, '-$&').toLowerCase();\n}","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {DirectiveFn} from '../lib/directive.js';\nimport {createMarker, directive, NodePart, Part, removeNodes, reparentNodes} from '../lit-html.js';\n\nexport type KeyFn<T> = (item: T, index: number) => unknown;\nexport type ItemTemplate<T> = (item: T, index: number) => unknown;\n\n// Helper functions for manipulating parts\n// TODO(kschaaf): Refactor into Part API?\nconst createAndInsertPart =\n    (containerPart: NodePart, beforePart?: NodePart): NodePart => {\n      const container = containerPart.startNode.parentNode as Node;\n      const beforeNode = beforePart === undefined ? containerPart.endNode :\n                                                    beforePart.startNode;\n      const startNode = container.insertBefore(createMarker(), beforeNode);\n      container.insertBefore(createMarker(), beforeNode);\n      const newPart = new NodePart(containerPart.options);\n      newPart.insertAfterNode(startNode);\n      return newPart;\n    };\n\nconst updatePart = (part: NodePart, value: unknown) => {\n  part.setValue(value);\n  part.commit();\n  return part;\n};\n\nconst insertPartBefore =\n    (containerPart: NodePart, part: NodePart, ref?: NodePart) => {\n      const container = containerPart.startNode.parentNode as Node;\n      const beforeNode = ref ? ref.startNode : containerPart.endNode;\n      const endNode = part.endNode.nextSibling;\n      if (endNode !== beforeNode) {\n        reparentNodes(container, part.startNode, endNode, beforeNode);\n      }\n    };\n\nconst removePart = (part: NodePart) => {\n  removeNodes(\n      part.startNode.parentNode!, part.startNode, part.endNode.nextSibling);\n};\n\n// Helper for generating a map of array item to its index over a subset\n// of an array (used to lazily generate `newKeyToIndexMap` and\n// `oldKeyToIndexMap`)\nconst generateMap = (list: unknown[], start: number, end: number) => {\n  const map = new Map();\n  for (let i = start; i <= end; i++) {\n    map.set(list[i], i);\n  }\n  return map;\n};\n\n// Stores previous ordered list of parts and map of key to index\nconst partListCache = new WeakMap<NodePart, (NodePart | null)[]>();\nconst keyListCache = new WeakMap<NodePart, unknown[]>();\n\n/**\n * A directive that repeats a series of values (usually `TemplateResults`)\n * generated from an iterable, and updates those items efficiently when the\n * iterable changes based on user-provided `keys` associated with each item.\n *\n * Note that if a `keyFn` is provided, strict key-to-DOM mapping is maintained,\n * meaning previous DOM for a given key is moved into the new position if\n * needed, and DOM will never be reused with values for different keys (new DOM\n * will always be created for new keys). This is generally the most efficient\n * way to use `repeat` since it performs minimum unnecessary work for insertions\n * and removals.\n *\n * IMPORTANT: If providing a `keyFn`, keys *must* be unique for all items in a\n * given call to `repeat`. The behavior when two or more items have the same key\n * is undefined.\n *\n * If no `keyFn` is provided, this directive will perform similar to mapping\n * items to values, and DOM will be reused against potentially different items.\n */\nexport const repeat =\n    directive(\n        <T>(items: Iterable<T>,\n            keyFnOrTemplate: KeyFn<T>|ItemTemplate<T>,\n            template?: ItemTemplate<T>):\n            DirectiveFn => {\n              let keyFn: KeyFn<T>;\n              if (template === undefined) {\n                template = keyFnOrTemplate;\n              } else if (keyFnOrTemplate !== undefined) {\n                keyFn = keyFnOrTemplate as KeyFn<T>;\n              }\n\n              return (containerPart: Part): void => {\n                if (!(containerPart instanceof NodePart)) {\n                  throw new Error('repeat can only be used in text bindings');\n                }\n                // Old part & key lists are retrieved from the last update\n                // (associated with the part for this instance of the directive)\n                const oldParts = partListCache.get(containerPart) || [];\n                const oldKeys = keyListCache.get(containerPart) || [];\n\n                // New part list will be built up as we go (either reused from\n                // old parts or created for new keys in this update). This is\n                // saved in the above cache at the end of the update.\n                const newParts: NodePart[] = [];\n\n                // New value list is eagerly generated from items along with a\n                // parallel array indicating its key.\n                const newValues: unknown[] = [];\n                const newKeys: unknown[] = [];\n                let index = 0;\n                for (const item of items) {\n                  newKeys[index] = keyFn ? keyFn(item, index) : index;\n                  newValues[index] = template !(item, index);\n                  index++;\n                }\n\n                // Maps from key to index for current and previous update; these\n                // are generated lazily only when needed as a performance\n                // optimization, since they are only required for multiple\n                // non-contiguous changes in the list, which are less common.\n                let newKeyToIndexMap!: Map<unknown, number>;\n                let oldKeyToIndexMap!: Map<unknown, number>;\n\n                // Head and tail pointers to old parts and new values\n                let oldHead = 0;\n                let oldTail = oldParts.length - 1;\n                let newHead = 0;\n                let newTail = newValues.length - 1;\n\n                // Overview of O(n) reconciliation algorithm (general approach\n                // based on ideas found in ivi, vue, snabbdom, etc.):\n                //\n                // * We start with the list of old parts and new values (and\n                //   arrays of their respective keys), head/tail pointers into\n                //   each, and we build up the new list of parts by updating\n                //   (and when needed, moving) old parts or creating new ones.\n                //   The initial scenario might look like this (for brevity of\n                //   the diagrams, the numbers in the array reflect keys\n                //   associated with the old parts or new values, although keys\n                //   and parts/values are actually stored in parallel arrays\n                //   indexed using the same head/tail pointers):\n                //\n                //      oldHead v                 v oldTail\n                //   oldKeys:  [0, 1, 2, 3, 4, 5, 6]\n                //   newParts: [ ,  ,  ,  ,  ,  ,  ]\n                //   newKeys:  [0, 2, 1, 4, 3, 7, 6] <- reflects the user's new\n                //                                      item order\n                //      newHead ^                 ^ newTail\n                //\n                // * Iterate old & new lists from both sides, updating,\n                //   swapping, or removing parts at the head/tail locations\n                //   until neither head nor tail can move.\n                //\n                // * Example below: keys at head pointers match, so update old\n                //   part 0 in-place (no need to move it) and record part 0 in\n                //   the `newParts` list. The last thing we do is advance the\n                //   `oldHead` and `newHead` pointers (will be reflected in the\n                //   next diagram).\n                //\n                //      oldHead v                 v oldTail\n                //   oldKeys:  [0, 1, 2, 3, 4, 5, 6]\n                //   newParts: [0,  ,  ,  ,  ,  ,  ] <- heads matched: update 0\n                //   newKeys:  [0, 2, 1, 4, 3, 7, 6]    and advance both oldHead\n                //                                      & newHead\n                //      newHead ^                 ^ newTail\n                //\n                // * Example below: head pointers don't match, but tail\n                //   pointers do, so update part 6 in place (no need to move\n                //   it), and record part 6 in the `newParts` list. Last,\n                //   advance the `oldTail` and `oldHead` pointers.\n                //\n                //         oldHead v              v oldTail\n                //   oldKeys:  [0, 1, 2, 3, 4, 5, 6]\n                //   newParts: [0,  ,  ,  ,  ,  , 6] <- tails matched: update 6\n                //   newKeys:  [0, 2, 1, 4, 3, 7, 6]    and advance both oldTail\n                //                                      & newTail\n                //         newHead ^              ^ newTail\n                //\n                // * If neither head nor tail match; next check if one of the\n                //   old head/tail items was removed. We first need to generate\n                //   the reverse map of new keys to index (`newKeyToIndexMap`),\n                //   which is done once lazily as a performance optimization,\n                //   since we only hit this case if multiple non-contiguous\n                //   changes were made. Note that for contiguous removal\n                //   anywhere in the list, the head and tails would advance\n                //   from either end and pass each other before we get to this\n                //   case and removals would be handled in the final while loop\n                //   without needing to generate the map.\n                //\n                // * Example below: The key at `oldTail` was removed (no longer\n                //   in the `newKeyToIndexMap`), so remove that part from the\n                //   DOM and advance just the `oldTail` pointer.\n                //\n                //         oldHead v           v oldTail\n                //   oldKeys:  [0, 1, 2, 3, 4, 5, 6]\n                //   newParts: [0,  ,  ,  ,  ,  , 6] <- 5 not in new map: remove\n                //   newKeys:  [0, 2, 1, 4, 3, 7, 6]    5 and advance oldTail\n                //         newHead ^           ^ newTail\n                //\n                // * Once head and tail cannot move, any mismatches are due to\n                //   either new or moved items; if a new key is in the previous\n                //   \"old key to old index\" map, move the old part to the new\n                //   location, otherwise create and insert a new part. Note\n                //   that when moving an old part we null its position in the\n                //   oldParts array if it lies between the head and tail so we\n                //   know to skip it when the pointers get there.\n                //\n                // * Example below: neither head nor tail match, and neither\n                //   were removed; so find the `newHead` key in the\n                //   `oldKeyToIndexMap`, and move that old part's DOM into the\n                //   next head position (before `oldParts[oldHead]`). Last,\n                //   null the part in the `oldPart` array since it was\n                //   somewhere in the remaining oldParts still to be scanned\n                //   (between the head and tail pointers) so that we know to\n                //   skip that old part on future iterations.\n                //\n                //         oldHead v        v oldTail\n                //   oldKeys:  [0, 1, -, 3, 4, 5, 6]\n                //   newParts: [0, 2,  ,  ,  ,  , 6] <- stuck: update & move 2\n                //   newKeys:  [0, 2, 1, 4, 3, 7, 6]    into place and advance\n                //                                      newHead\n                //         newHead ^           ^ newTail\n                //\n                // * Note that for moves/insertions like the one above, a part\n                //   inserted at the head pointer is inserted before the\n                //   current `oldParts[oldHead]`, and a part inserted at the\n                //   tail pointer is inserted before `newParts[newTail+1]`. The\n                //   seeming asymmetry lies in the fact that new parts are\n                //   moved into place outside in, so to the right of the head\n                //   pointer are old parts, and to the right of the tail\n                //   pointer are new parts.\n                //\n                // * We always restart back from the top of the algorithm,\n                //   allowing matching and simple updates in place to\n                //   continue...\n                //\n                // * Example below: the head pointers once again match, so\n                //   simply update part 1 and record it in the `newParts`\n                //   array.  Last, advance both head pointers.\n                //\n                //         oldHead v        v oldTail\n                //   oldKeys:  [0, 1, -, 3, 4, 5, 6]\n                //   newParts: [0, 2, 1,  ,  ,  , 6] <- heads matched: update 1\n                //   newKeys:  [0, 2, 1, 4, 3, 7, 6]    and advance both oldHead\n                //                                      & newHead\n                //            newHead ^        ^ newTail\n                //\n                // * As mentioned above, items that were moved as a result of\n                //   being stuck (the final else clause in the code below) are\n                //   marked with null, so we always advance old pointers over\n                //   these so we're comparing the next actual old value on\n                //   either end.\n                //\n                // * Example below: `oldHead` is null (already placed in\n                //   newParts), so advance `oldHead`.\n                //\n                //            oldHead v     v oldTail\n                //   oldKeys:  [0, 1, -, 3, 4, 5, 6] <- old head already used:\n                //   newParts: [0, 2, 1,  ,  ,  , 6]    advance oldHead\n                //   newKeys:  [0, 2, 1, 4, 3, 7, 6]\n                //               newHead ^     ^ newTail\n                //\n                // * Note it's not critical to mark old parts as null when they\n                //   are moved from head to tail or tail to head, since they\n                //   will be outside the pointer range and never visited again.\n                //\n                // * Example below: Here the old tail key matches the new head\n                //   key, so the part at the `oldTail` position and move its\n                //   DOM to the new head position (before `oldParts[oldHead]`).\n                //   Last, advance `oldTail` and `newHead` pointers.\n                //\n                //               oldHead v  v oldTail\n                //   oldKeys:  [0, 1, -, 3, 4, 5, 6]\n                //   newParts: [0, 2, 1, 4,  ,  , 6] <- old tail matches new\n                //   newKeys:  [0, 2, 1, 4, 3, 7, 6]   head: update & move 4,\n                //                                     advance oldTail & newHead\n                //               newHead ^     ^ newTail\n                //\n                // * Example below: Old and new head keys match, so update the\n                //   old head part in place, and advance the `oldHead` and\n                //   `newHead` pointers.\n                //\n                //               oldHead v oldTail\n                //   oldKeys:  [0, 1, -, 3, 4, 5, 6]\n                //   newParts: [0, 2, 1, 4, 3,   ,6] <- heads match: update 3\n                //   newKeys:  [0, 2, 1, 4, 3, 7, 6]    and advance oldHead &\n                //                                      newHead\n                //                  newHead ^  ^ newTail\n                //\n                // * Once the new or old pointers move past each other then all\n                //   we have left is additions (if old list exhausted) or\n                //   removals (if new list exhausted). Those are handled in the\n                //   final while loops at the end.\n                //\n                // * Example below: `oldHead` exceeded `oldTail`, so we're done\n                //   with the main loop.  Create the remaining part and insert\n                //   it at the new head position, and the update is complete.\n                //\n                //                   (oldHead > oldTail)\n                //   oldKeys:  [0, 1, -, 3, 4, 5, 6]\n                //   newParts: [0, 2, 1, 4, 3, 7 ,6] <- create and insert 7\n                //   newKeys:  [0, 2, 1, 4, 3, 7, 6]\n                //                     newHead ^ newTail\n                //\n                // * Note that the order of the if/else clauses is not\n                //   important to the algorithm, as long as the null checks\n                //   come first (to ensure we're always working on valid old\n                //   parts) and that the final else clause comes last (since\n                //   that's where the expensive moves occur). The order of\n                //   remaining clauses is is just a simple guess at which cases\n                //   will be most common.\n                //\n                // * TODO(kschaaf) Note, we could calculate the longest\n                //   increasing subsequence (LIS) of old items in new position,\n                //   and only move those not in the LIS set. However that costs\n                //   O(nlogn) time and adds a bit more code, and only helps\n                //   make rare types of mutations require fewer moves. The\n                //   above handles removes, adds, reversal, swaps, and single\n                //   moves of contiguous items in linear time, in the minimum\n                //   number of moves. As the number of multiple moves where LIS\n                //   might help approaches a random shuffle, the LIS\n                //   optimization becomes less helpful, so it seems not worth\n                //   the code at this point. Could reconsider if a compelling\n                //   case arises.\n\n                while (oldHead <= oldTail && newHead <= newTail) {\n                  if (oldParts[oldHead] === null) {\n                    // `null` means old part at head has already been used\n                    // below; skip\n                    oldHead++;\n                  } else if (oldParts[oldTail] === null) {\n                    // `null` means old part at tail has already been used\n                    // below; skip\n                    oldTail--;\n                  } else if (oldKeys[oldHead] === newKeys[newHead]) {\n                    // Old head matches new head; update in place\n                    newParts[newHead] =\n                        updatePart(oldParts[oldHead]!, newValues[newHead]);\n                    oldHead++;\n                    newHead++;\n                  } else if (oldKeys[oldTail] === newKeys[newTail]) {\n                    // Old tail matches new tail; update in place\n                    newParts[newTail] =\n                        updatePart(oldParts[oldTail]!, newValues[newTail]);\n                    oldTail--;\n                    newTail--;\n                  } else if (oldKeys[oldHead] === newKeys[newTail]) {\n                    // Old head matches new tail; update and move to new tail\n                    newParts[newTail] =\n                        updatePart(oldParts[oldHead]!, newValues[newTail]);\n                    insertPartBefore(\n                        containerPart,\n                        oldParts[oldHead]!,\n                        newParts[newTail + 1]);\n                    oldHead++;\n                    newTail--;\n                  } else if (oldKeys[oldTail] === newKeys[newHead]) {\n                    // Old tail matches new head; update and move to new head\n                    newParts[newHead] =\n                        updatePart(oldParts[oldTail]!, newValues[newHead]);\n                    insertPartBefore(\n                        containerPart, oldParts[oldTail]!, oldParts[oldHead]!);\n                    oldTail--;\n                    newHead++;\n                  } else {\n                    if (newKeyToIndexMap === undefined) {\n                      // Lazily generate key-to-index maps, used for removals &\n                      // moves below\n                      newKeyToIndexMap = generateMap(newKeys, newHead, newTail);\n                      oldKeyToIndexMap = generateMap(oldKeys, oldHead, oldTail);\n                    }\n                    if (!newKeyToIndexMap.has(oldKeys[oldHead])) {\n                      // Old head is no longer in new list; remove\n                      removePart(oldParts[oldHead]!);\n                      oldHead++;\n                    } else if (!newKeyToIndexMap.has(oldKeys[oldTail])) {\n                      // Old tail is no longer in new list; remove\n                      removePart(oldParts[oldTail]!);\n                      oldTail--;\n                    } else {\n                      // Any mismatches at this point are due to additions or\n                      // moves; see if we have an old part we can reuse and move\n                      // into place\n                      const oldIndex = oldKeyToIndexMap.get(newKeys[newHead]);\n                      const oldPart =\n                          oldIndex !== undefined ? oldParts[oldIndex] : null;\n                      if (oldPart === null) {\n                        // No old part for this value; create a new one and\n                        // insert it\n                        const newPart = createAndInsertPart(\n                            containerPart, oldParts[oldHead]!);\n                        updatePart(newPart, newValues[newHead]);\n                        newParts[newHead] = newPart;\n                      } else {\n                        // Reuse old part\n                        newParts[newHead] =\n                            updatePart(oldPart, newValues[newHead]);\n                        insertPartBefore(\n                            containerPart, oldPart, oldParts[oldHead]!);\n                        // This marks the old part as having been used, so that\n                        // it will be skipped in the first two checks above\n                        oldParts[oldIndex as number] = null;\n                      }\n                      newHead++;\n                    }\n                  }\n                }\n                // Add parts for any remaining new values\n                while (newHead <= newTail) {\n                  // For all remaining additions, we insert before last new\n                  // tail, since old pointers are no longer valid\n                  const newPart =\n                      createAndInsertPart(containerPart, newParts[newTail + 1]);\n                  updatePart(newPart, newValues[newHead]);\n                  newParts[newHead++] = newPart;\n                }\n                // Remove any remaining unused old parts\n                while (oldHead <= oldTail) {\n                  const oldPart = oldParts[oldHead++];\n                  if (oldPart !== null) {\n                    removePart(oldPart);\n                  }\n                }\n                // Save order of new parts for next round\n                partListCache.set(containerPart, newParts);\n                keyListCache.set(containerPart, newKeys);\n              };\n            }) as\n    <T>(items: Iterable<T>,\n        keyFnOrTemplate: KeyFn<T>|ItemTemplate<T>,\n        template?: ItemTemplate<T>) => DirectiveFn;\n","/**\n * @license\n * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {TemplateInstance} from '../lib/template-instance.js';\nimport {Template} from '../lib/template.js';\nimport {directive, NodePart, Part, reparentNodes, TemplateResult} from '../lit-html.js';\n\ninterface CachedTemplate {\n  readonly instance: TemplateInstance;\n  readonly nodes: DocumentFragment;\n}\nconst templateCaches =\n    new WeakMap<NodePart, WeakMap<Template, CachedTemplate>>();\n\n/**\n * Enables fast switching between multiple templates by caching the DOM nodes\n * and TemplateInstances produced by the templates.\n *\n * Example:\n *\n * ```\n * let checked = false;\n *\n * html`\n *   ${cache(checked ? html`input is checked` : html`input is not checked`)}\n * `\n * ```\n */\nexport const cache = directive((value: unknown) => (part: Part) => {\n  if (!(part instanceof NodePart)) {\n    throw new Error('cache can only be used in text bindings');\n  }\n\n  let templateCache = templateCaches.get(part);\n\n  if (templateCache === undefined) {\n    templateCache = new WeakMap();\n    templateCaches.set(part, templateCache);\n  }\n\n  const previousValue = part.value;\n\n  // First, can we update the current TemplateInstance, or do we need to move\n  // the current nodes into the cache?\n  if (previousValue instanceof TemplateInstance) {\n    if (value instanceof TemplateResult &&\n        previousValue.template === part.options.templateFactory(value)) {\n      // Same Template, just trigger an update of the TemplateInstance\n      part.setValue(value);\n      return;\n    } else {\n      // Not the same Template, move the nodes from the DOM into the cache.\n      let cachedTemplate = templateCache.get(previousValue.template);\n      if (cachedTemplate === undefined) {\n        cachedTemplate = {\n          instance: previousValue,\n          nodes: document.createDocumentFragment(),\n        };\n        templateCache.set(previousValue.template, cachedTemplate);\n      }\n      reparentNodes(\n          cachedTemplate.nodes, part.startNode.nextSibling, part.endNode);\n    }\n  }\n\n  // Next, can we reuse nodes from the cache?\n  if (value instanceof TemplateResult) {\n    const template = part.options.templateFactory(value);\n    const cachedTemplate = templateCache.get(template);\n    if (cachedTemplate !== undefined) {\n      // Move nodes out of cache\n      part.setValue(cachedTemplate.nodes);\n      part.commit();\n      // Set the Part value to the TemplateInstance so it'll update it.\n      part.value = cachedTemplate.instance;\n    }\n  }\n  part.setValue(value);\n});\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {isPrimitive} from '../lib/parts.js';\nimport {directive, Part} from '../lit-html.js';\n\ninterface AsyncState {\n  /**\n   * The last rendered index of a call to until(). A value only renders if its\n   * index is less than the `lastRenderedIndex`.\n   */\n  lastRenderedIndex: number;\n\n  values: unknown[];\n}\n\nconst _state = new WeakMap<Part, AsyncState>();\n// Effectively infinity, but a SMI.\nconst _infinity = 0x7fffffff;\n\n/**\n * Renders one of a series of values, including Promises, to a Part.\n *\n * Values are rendered in priority order, with the first argument having the\n * highest priority and the last argument having the lowest priority. If a\n * value is a Promise, low-priority values will be rendered until it resolves.\n *\n * The priority of values can be used to create placeholder content for async\n * data. For example, a Promise with pending content can be the first,\n * highest-priority, argument, and a non_promise loading indicator template can\n * be used as the second, lower-priority, argument. The loading indicator will\n * render immediately, and the primary content will render when the Promise\n * resolves.\n *\n * Example:\n *\n *     const content = fetch('./content.txt').then(r => r.text());\n *     html`${until(content, html`<span>Loading...</span>`)}`\n */\nexport const until = directive((...args: unknown[]) => (part: Part) => {\n  let state = _state.get(part)!;\n  if (state === undefined) {\n    state = {\n      lastRenderedIndex: _infinity,\n      values: [],\n    };\n    _state.set(part, state);\n  }\n  const previousValues = state.values;\n  let previousLength = previousValues.length;\n  state.values = args;\n\n  for (let i = 0; i < args.length; i++) {\n    // If we've rendered a higher-priority value already, stop.\n    if (i > state.lastRenderedIndex) {\n      break;\n    }\n\n    const value = args[i];\n\n    // Render non-Promise values immediately\n    if (isPrimitive(value) ||\n        typeof (value as {then?: unknown}).then !== 'function') {\n      part.setValue(value);\n      state.lastRenderedIndex = i;\n      // Since a lower-priority value will never overwrite a higher-priority\n      // synchronous value, we can stop processing now.\n      break;\n    }\n\n    // If this is a Promise we've already handled, skip it.\n    if (i < previousLength && value === previousValues[i]) {\n      continue;\n    }\n\n    // We have a Promise that we haven't seen before, so priorities may have\n    // changed. Forget what we rendered before.\n    state.lastRenderedIndex = _infinity;\n    previousLength = 0;\n\n    Promise.resolve(value).then((resolvedValue: unknown) => {\n      const index = state.values.indexOf(value);\n      // If state.values doesn't contain the value, we've re-rendered without\n      // the value, so don't render it. Then, only render if the value is\n      // higher-priority than what's already been rendered.\n      if (index > -1 && index < state.lastRenderedIndex) {\n        state.lastRenderedIndex = index;\n        part.setValue(resolvedValue);\n        part.commit();\n      }\n    });\n  }\n});\n","/**\n * @license\n * Copyright (c) 2020 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {AttributePart, BooleanAttributePart, directive, EventPart, NodePart, PropertyPart} from '../lit-html.js';\n\n/**\n * Checks binding values against live DOM values, instead of previously bound\n * values, when determining whether to update the value.\n *\n * This is useful for cases where the DOM value may change from outside of\n * lit-html, such as with a binding to an `<input>` element's `value` property,\n * a content editable elements text, or to a custom element that changes it's\n * own properties or attributes.\n *\n * In these cases if the DOM value changes, but the value set through lit-html\n * bindings hasn't, lit-html won't know to update the DOM value and will leave\n * it alone. If this is not what you want—if you want to overwrite the DOM\n * value with the bound value no matter what—use the `live()` directive:\n *\n *     html`<input .value=${live(x)}>`\n *\n * `live()` performs a strict equality check agains the live DOM value, and if\n * the new value is equal to the live value, does nothing. This means that\n * `live()` should not be used when the binding will cause a type conversion. If\n * you use `live()` with an attribute binding, make sure that only strings are\n * passed in, or the binding will update every render.\n */\nexport const live = directive(\n    (value: unknown) => (part: AttributePart|PropertyPart|\n                         BooleanAttributePart) => {\n      let previousValue: unknown;\n      if (part instanceof EventPart || part instanceof NodePart) {\n        throw new Error(\n            'The `live` directive is not allowed on text or event bindings');\n      }\n      if (part instanceof BooleanAttributePart) {\n        checkStrings(part.strings);\n        previousValue = part.element.hasAttribute(part.name);\n        // This is a hack needed because BooleanAttributePart doesn't have a\n        // committer and does its own dirty checking after directives\n        part.value = previousValue;\n      } else {\n        const {element, name, strings} = part.committer;\n        checkStrings(strings);\n        if (part instanceof PropertyPart) {\n          // eslint-disable-next-line @typescript-eslint/no-explicit-any\n          previousValue = (element as any)[name];\n          if (previousValue === value) {\n            return;\n          }\n        } else if (part instanceof AttributePart) {\n          previousValue = element.getAttribute(name);\n        }\n        if (previousValue === String(value)) {\n          return;\n        }\n      }\n      part.setValue(value);\n    });\n\nconst checkStrings = (strings: readonly string[]) => {\n  if (strings.length !== 2 || strings[0] !== '' || strings[1] !== '') {\n    throw new Error('`live` bindings can only contain a single expression');\n  }\n};\n","/**\n * @license\n * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {directive, Part} from '../lit-html.js';\n\nconst previousValues = new WeakMap<Part, unknown>();\n\n/**\n * Prevents re-render of a template function until a single value or an array of\n * values changes.\n *\n * Example:\n *\n * ```js\n * html`\n *   <div>\n *     ${guard([user.id, company.id], () => html`...`)}\n *   </div>\n * ```\n *\n * In this case, the template only renders if either `user.id` or `company.id`\n * changes.\n *\n * guard() is useful with immutable data patterns, by preventing expensive work\n * until data updates.\n *\n * Example:\n *\n * ```js\n * html`\n *   <div>\n *     ${guard([immutableItems], () => immutableItems.map(i => html`${i}`))}\n *   </div>\n * ```\n *\n * In this case, items are mapped over only when the array reference changes.\n *\n * @param value the value to check before re-rendering\n * @param f the template function\n */\nexport const guard =\n    directive((value: unknown, f: () => unknown) => (part: Part): void => {\n      const previousValue = previousValues.get(part);\n      if (Array.isArray(value)) {\n        // Dirty-check arrays by item\n        if (Array.isArray(previousValue) &&\n            previousValue.length === value.length &&\n            value.every((v, i) => v === previousValue[i])) {\n          return;\n        }\n      } else if (\n          previousValue === value &&\n          (value !== undefined || previousValues.has(part))) {\n        // Dirty-check non-arrays by identity\n        return;\n      }\n\n      part.setValue(f());\n      // Copy the value if it's an array so that if it's mutated we don't forget\n      // what the previous values were.\n      previousValues.set(\n          part, Array.isArray(value) ? Array.from(value) : value);\n    });\n","/**\n * @license\n * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {AttributePart, directive, Part, PropertyPart} from '../lit-html.js';\n\n// IE11 doesn't support classList on SVG elements, so we emulate it with a Set\nclass ClassList {\n  element: Element;\n  classes: Set<string> = new Set();\n  changed = false;\n\n  constructor(element: Element) {\n    this.element = element;\n    const classList = (element.getAttribute('class') || '').split(/\\s+/);\n    for (const cls of classList) {\n      this.classes.add(cls);\n    }\n  }\n  add(cls: string) {\n    this.classes.add(cls);\n    this.changed = true;\n  }\n\n  remove(cls: string) {\n    this.classes.delete(cls);\n    this.changed = true;\n  }\n\n  commit() {\n    if (this.changed) {\n      let classString = '';\n      this.classes.forEach((cls) => classString += cls + ' ');\n      this.element.setAttribute('class', classString);\n    }\n  }\n}\n\nexport interface ClassInfo {\n  readonly [name: string]: string|boolean|number;\n}\n\n/**\n * Stores the ClassInfo object applied to a given AttributePart.\n * Used to unset existing values when a new ClassInfo object is applied.\n */\nconst previousClassesCache = new WeakMap<Part, Set<string>>();\n\n/**\n * A directive that applies CSS classes. This must be used in the `class`\n * attribute and must be the only part used in the attribute. It takes each\n * property in the `classInfo` argument and adds the property name to the\n * element's `class` if the property value is truthy; if the property value is\n * falsey, the property name is removed from the element's `class`. For example\n * `{foo: bar}` applies the class `foo` if the value of `bar` is truthy.\n * @param classInfo {ClassInfo}\n */\nexport const classMap = directive((classInfo: ClassInfo) => (part: Part) => {\n  if (!(part instanceof AttributePart) || (part instanceof PropertyPart) ||\n      part.committer.name !== 'class' || part.committer.parts.length > 1) {\n    throw new Error(\n        'The `classMap` directive must be used in the `class` attribute ' +\n        'and must be the only part in the attribute.');\n  }\n\n  const {committer} = part;\n  const {element} = committer;\n\n  let previousClasses = previousClassesCache.get(part);\n  if (previousClasses === undefined) {\n    // Write static classes once\n    // Use setAttribute() because className isn't a string on SVG elements\n    element.setAttribute('class', committer.strings.join(' '));\n    previousClassesCache.set(part, previousClasses = new Set());\n  }\n\n  const classList =\n      (element.classList || new ClassList(element)) as DOMTokenList | ClassList;\n\n  // Remove old classes that no longer apply\n  // We use forEach() instead of for-of so that re don't require down-level\n  // iteration.\n  previousClasses.forEach((name) => {\n    if (!(name in classInfo)) {\n      classList.remove(name);\n      previousClasses!.delete(name);\n    }\n  });\n\n  // Add or remove classes based on their classMap value\n  for (const name in classInfo) {\n    const value = classInfo[name];\n    if (value != previousClasses.has(name)) {\n      // We explicitly want a loose truthy check of `value` because it seems\n      // more convenient that '' and 0 are skipped.\n      if (value) {\n        classList.add(name);\n        previousClasses.add(name);\n      } else {\n        classList.remove(name);\n        previousClasses.delete(name);\n      }\n    }\n  }\n  if (typeof (classList as ClassList).commit === 'function') {\n    (classList as ClassList).commit();\n  }\n});\n","/**\n * @license\n * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {AttributePart, directive, Part, PropertyPart} from '../lit-html.js';\n\nexport interface StyleInfo {\n  readonly [name: string]: string;\n}\n\n/**\n * Stores the StyleInfo object applied to a given AttributePart.\n * Used to unset existing values when a new StyleInfo object is applied.\n */\nconst previousStylePropertyCache = new WeakMap<AttributePart, Set<string>>();\n\n/**\n * A directive that applies CSS properties to an element.\n *\n * `styleMap` can only be used in the `style` attribute and must be the only\n * expression in the attribute. It takes the property names in the `styleInfo`\n * object and adds the property values as CSS properties. Property names with\n * dashes (`-`) are assumed to be valid CSS property names and set on the\n * element's style object using `setProperty()`. Names without dashes are\n * assumed to be camelCased JavaScript property names and set on the element's\n * style object using property assignment, allowing the style object to\n * translate JavaScript-style names to CSS property names.\n *\n * For example `styleMap({backgroundColor: 'red', 'border-top': '5px', '--size':\n * '0'})` sets the `background-color`, `border-top` and `--size` properties.\n *\n * @param styleInfo {StyleInfo}\n */\nexport const styleMap = directive((styleInfo: StyleInfo) => (part: Part) => {\n  if (!(part instanceof AttributePart) || (part instanceof PropertyPart) ||\n      part.committer.name !== 'style' || part.committer.parts.length > 1) {\n    throw new Error(\n        'The `styleMap` directive must be used in the style attribute ' +\n        'and must be the only part in the attribute.');\n  }\n\n  const {committer} = part;\n  const {style} = committer.element as HTMLElement;\n\n  let previousStyleProperties = previousStylePropertyCache.get(part);\n\n  if (previousStyleProperties === undefined) {\n    // Write static styles once\n    style.cssText = committer.strings.join(' ');\n    previousStylePropertyCache.set(part, previousStyleProperties = new Set());\n  }\n\n  // Remove old properties that no longer exist in styleInfo\n  // We use forEach() instead of for-of so that re don't require down-level\n  // iteration.\n  previousStyleProperties.forEach((name) => {\n    if (!(name in styleInfo)) {\n      previousStyleProperties!.delete(name);\n      if (name.indexOf('-') === -1) {\n        // eslint-disable-next-line @typescript-eslint/no-explicit-any\n        (style as any)[name] = null;\n      } else {\n        style.removeProperty(name);\n      }\n    }\n  });\n\n  // Add or update properties\n  for (const name in styleInfo) {\n    previousStyleProperties.add(name);\n    if (name.indexOf('-') === -1) {\n      // eslint-disable-next-line @typescript-eslint/no-explicit-any\n      (style as any)[name] = styleInfo[name];\n    } else {\n      style.setProperty(name, styleInfo[name]);\n    }\n  }\n});\n","/**\n * @license\n * Copyright (c) 2018 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {AttributePart, directive, Part} from '../lit-html.js';\n\nconst previousValues = new WeakMap<Part, unknown>();\n\n/**\n * For AttributeParts, sets the attribute if the value is defined and removes\n * the attribute if the value is undefined.\n *\n * For other part types, this directive is a no-op.\n */\nexport const ifDefined = directive((value: unknown) => (part: Part) => {\n  const previousValue = previousValues.get(part);\n\n  if (value === undefined && part instanceof AttributePart) {\n    // If the value is undefined, remove the attribute, but only if the value\n    // was previously defined.\n    if (previousValue !== undefined || !previousValues.has(part)) {\n      const name = part.committer.name;\n      part.committer.element.removeAttribute(name);\n    }\n  } else if (value !== previousValue) {\n    part.setValue(value);\n  }\n\n  previousValues.set(part, value);\n});\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {createMarker, directive, NodePart, Part} from '../lit-html.js';\n\n/**\n * A directive that renders the items of an async iterable[1], appending new\n * values after previous values, similar to the built-in support for iterables.\n *\n * Async iterables are objects with a [Symbol.asyncIterator] method, which\n * returns an iterator who's `next()` method returns a Promise. When a new\n * value is available, the Promise resolves and the value is appended to the\n * Part controlled by the directive. If another value other than this\n * directive has been set on the Part, the iterable will no longer be listened\n * to and new values won't be written to the Part.\n *\n * [1]: https://github.com/tc39/proposal-async-iteration\n *\n * @param value An async iterable\n * @param mapper An optional function that maps from (value, index) to another\n *     value. Useful for generating templates for each item in the iterable.\n */\nexport const asyncAppend = directive(\n    <T>(value: AsyncIterable<T>,\n        mapper?: (v: T, index?: number) => unknown) => async (part: Part) => {\n      if (!(part instanceof NodePart)) {\n        throw new Error('asyncAppend can only be used in text bindings');\n      }\n      // If we've already set up this particular iterable, we don't need\n      // to do anything.\n      if (value === part.value) {\n        return;\n      }\n      part.value = value;\n\n      // We keep track of item Parts across iterations, so that we can\n      // share marker nodes between consecutive Parts.\n      let itemPart;\n      let i = 0;\n\n      for await (let v of value) {\n        // Check to make sure that value is the still the current value of\n        // the part, and if not bail because a new value owns this part\n        if (part.value !== value) {\n          break;\n        }\n\n        // When we get the first value, clear the part. This lets the\n        // previous value display until we can replace it.\n        if (i === 0) {\n          part.clear();\n        }\n\n        // As a convenience, because functional-programming-style\n        // transforms of iterables and async iterables requires a library,\n        // we accept a mapper function. This is especially convenient for\n        // rendering a template for each item.\n        if (mapper !== undefined) {\n          // This is safe because T must otherwise be treated as unknown by\n          // the rest of the system.\n          v = mapper(v, i) as T;\n        }\n\n        // Like with sync iterables, each item induces a Part, so we need\n        // to keep track of start and end nodes for the Part.\n        // Note: Because these Parts are not updatable like with a sync\n        // iterable (if we render a new value, we always clear), it may\n        // be possible to optimize away the Parts and just re-use the\n        // Part.setValue() logic.\n\n        let itemStartNode = part.startNode;\n\n        // Check to see if we have a previous item and Part\n        if (itemPart !== undefined) {\n          // Create a new node to separate the previous and next Parts\n          itemStartNode = createMarker();\n          // itemPart is currently the Part for the previous item. Set\n          // it's endNode to the node we'll use for the next Part's\n          // startNode.\n          itemPart.endNode = itemStartNode;\n          part.endNode.parentNode!.insertBefore(itemStartNode, part.endNode);\n        }\n        itemPart = new NodePart(part.options);\n        itemPart.insertAfterNode(itemStartNode);\n        itemPart.setValue(v);\n        itemPart.commit();\n        i++;\n      }\n    });\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {directive, NodePart, Part} from '../lit-html.js';\n\n/**\n * A directive that renders the items of an async iterable[1], replacing\n * previous values with new values, so that only one value is ever rendered\n * at a time.\n *\n * Async iterables are objects with a [Symbol.asyncIterator] method, which\n * returns an iterator who's `next()` method returns a Promise. When a new\n * value is available, the Promise resolves and the value is rendered to the\n * Part controlled by the directive. If another value other than this\n * directive has been set on the Part, the iterable will no longer be listened\n * to and new values won't be written to the Part.\n *\n * [1]: https://github.com/tc39/proposal-async-iteration\n *\n * @param value An async iterable\n * @param mapper An optional function that maps from (value, index) to another\n *     value. Useful for generating templates for each item in the iterable.\n */\nexport const asyncReplace = directive(\n    <T>(value: AsyncIterable<T>, mapper?: (v: T, index?: number) => unknown) =>\n        async (part: Part) => {\n          if (!(part instanceof NodePart)) {\n            throw new Error('asyncReplace can only be used in text bindings');\n          }\n          // If we've already set up this particular iterable, we don't need\n          // to do anything.\n          if (value === part.value) {\n            return;\n          }\n\n          // We nest a new part to keep track of previous item values separately\n          // of the iterable as a value itself.\n          const itemPart = new NodePart(part.options);\n          part.value = value;\n\n          let i = 0;\n\n          for await (let v of value) {\n            // Check to make sure that value is the still the current value of\n            // the part, and if not bail because a new value owns this part\n            if (part.value !== value) {\n              break;\n            }\n\n            // When we get the first value, clear the part. This let's the\n            // previous value display until we can replace it.\n            if (i === 0) {\n              part.clear();\n              itemPart.appendIntoPart(part);\n            }\n\n            // As a convenience, because functional-programming-style\n            // transforms of iterables and async iterables requires a library,\n            // we accept a mapper function. This is especially convenient for\n            // rendering a template for each item.\n            if (mapper !== undefined) {\n              // This is safe because T must otherwise be treated as unknown by\n              // the rest of the system.\n              v = mapper(v, i) as T;\n            }\n\n            itemPart.setValue(v);\n            itemPart.commit();\n            i++;\n          }\n        });\n","/**\n * @license\n * Copyright (c) 2020 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {directive, NodePart, Part} from '../lit-html.js';\n\ninterface PreviousValue {\n  readonly template: HTMLTemplateElement;\n  readonly fragment: DocumentFragment;\n}\n\n// For each part, remember the value that was last rendered to the part by the\n// templateContent directive, and the DocumentFragment that was last set as a\n// value. The DocumentFragment is used as a unique key to check if the last\n// value rendered to the part was with templateContent. If not, we'll always\n// re-render the value passed to templateContent.\nconst previousValues = new WeakMap<NodePart, PreviousValue>();\n\n/**\n * Renders the content of a template element as HTML.\n *\n * Note, the template should be developer controlled and not user controlled.\n * Rendering a user-controlled template with this directive\n * could lead to cross-site-scripting vulnerabilities.\n */\nexport const templateContent =\n    directive((template: HTMLTemplateElement) => (part: Part): void => {\n      if (!(part instanceof NodePart)) {\n        throw new Error('templateContent can only be used in text bindings');\n      }\n\n      const previousValue = previousValues.get(part);\n\n      if (previousValue !== undefined && template === previousValue.template &&\n          part.value === previousValue.fragment) {\n        return;\n      }\n\n      const fragment = document.importNode(template.content, true);\n      part.setValue(fragment);\n      previousValues.set(part, {template, fragment});\n    });\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {isPrimitive} from '../lib/parts.js';\nimport {directive, NodePart, Part} from '../lit-html.js';\n\ninterface PreviousValue {\n  readonly value: unknown;\n  readonly fragment: DocumentFragment;\n}\n\n// For each part, remember the value that was last rendered to the part by the\n// unsafeHTML directive, and the DocumentFragment that was last set as a value.\n// The DocumentFragment is used as a unique key to check if the last value\n// rendered to the part was with unsafeHTML. If not, we'll always re-render the\n// value passed to unsafeHTML.\nconst previousValues = new WeakMap<NodePart, PreviousValue>();\n\n/**\n * Renders the result as HTML, rather than text.\n *\n * Note, this is unsafe to use with any user-provided input that hasn't been\n * sanitized or escaped, as it may lead to cross-site-scripting\n * vulnerabilities.\n */\nexport const unsafeHTML = directive((value: unknown) => (part: Part): void => {\n  if (!(part instanceof NodePart)) {\n    throw new Error('unsafeHTML can only be used in text bindings');\n  }\n\n  const previousValue = previousValues.get(part);\n\n  if (previousValue !== undefined && isPrimitive(value) &&\n      value === previousValue.value && part.value === previousValue.fragment) {\n    return;\n  }\n\n  const template = document.createElement('template');\n  template.innerHTML = value as string;  // innerHTML casts to string internally\n  const fragment = document.importNode(template.content, true);\n  part.setValue(fragment);\n  previousValues.set(part, {value, fragment});\n});\n","/**\n * @license\n * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.\n * This code may only be used under the BSD style license found at\n * http://polymer.github.io/LICENSE.txt\n * The complete set of authors may be found at\n * http://polymer.github.io/AUTHORS.txt\n * The complete set of contributors may be found at\n * http://polymer.github.io/CONTRIBUTORS.txt\n * Code distributed by Google as part of the polymer project is also\n * subject to an additional IP rights grant found at\n * http://polymer.github.io/PATENTS.txt\n */\n\nimport {reparentNodes} from '../lib/dom.js';\nimport {isPrimitive} from '../lib/parts.js';\nimport {directive, NodePart, Part} from '../lit-html.js';\n\ninterface PreviousValue {\n  readonly value: unknown;\n  readonly fragment: DocumentFragment;\n}\n\n// For each part, remember the value that was last rendered to the part by the\n// unsafeSVG directive, and the DocumentFragment that was last set as a value.\n// The DocumentFragment is used as a unique key to check if the last value\n// rendered to the part was with unsafeSVG. If not, we'll always re-render the\n// value passed to unsafeSVG.\nconst previousValues = new WeakMap<NodePart, PreviousValue>();\n\nconst isIe = window.navigator.userAgent.indexOf('Trident/') > 0;\n\n/**\n * Renders the result as SVG, rather than text.\n *\n * Note, this is unsafe to use with any user-provided input that hasn't been\n * sanitized or escaped, as it may lead to cross-site-scripting\n * vulnerabilities.\n */\nexport const unsafeSVG = directive((value: unknown) => (part: Part): void => {\n  if (!(part instanceof NodePart)) {\n    throw new Error('unsafeSVG can only be used in text bindings');\n  }\n\n  const previousValue = previousValues.get(part);\n\n  if (previousValue !== undefined && isPrimitive(value) &&\n      value === previousValue.value && part.value === previousValue.fragment) {\n    return;\n  }\n\n  const template = document.createElement('template');\n  const content = template.content;\n  let svgElement;\n  if (isIe) {\n    // IE can't set innerHTML of an svg element. However, it also doesn't\n    // support Trusted Types, so it's ok for us to use a string when setting\n    // innerHTML.\n    template.innerHTML = `<svg>${value}</svg>`;\n    svgElement = content.firstChild!;\n  } else {\n    svgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');\n    content.appendChild(svgElement);\n    svgElement.innerHTML = value as string;\n  }\n  content.removeChild(svgElement);\n  reparentNodes(content, svgElement.firstChild);\n  const fragment = document.importNode(content, true);\n  part.setValue(fragment);\n  previousValues.set(part, {value, fragment});\n});\n","import { repeat } from 'lit-html/directives/repeat';\n\nexport const each = (items, template, keyFn = (item) => item) =>\n    repeat(items, keyFn, template);\n","import { directive } from 'lit-html';\n\nexport const ref = directive((fn) => (part) => fn(part.element));","import { directive } from 'lit-html';\n\nconst decorators = new WeakMap();\n\nexport const decorator = directive((handler, ...state) => {\n    const self = (part) => {\n        const el = part.element;\n\n        if (decorators.has(part)) {\n            const [decorator, prevHandler] = decorators.get(part);\n            if (prevHandler !== handler) {\n                decorator.destroy();\n                decorators.delete(part);\n                self(part);\n            } else {\n                decorator.update(...state);\n            }\n        } else {\n            const decorator = handler(el, ...state);\n            decorators.set(part, [decorator, handler]);\n            // decorator.destroy() + decorators.delete(part) ???\n            // https://github.com/Polymer/lit-html/issues/283\n            // wait till lit-html 2 ?\n        }\n    };\n    return self;\n});\n","import { directive, EventPart } from 'lit-html';\n\n// check this later: https://codesandbox.io/s/hyperactiv-tests-works-u47wt?file=/src/bind.js\n\ntype HTMLConrolElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | HTMLButtonElement;\n\nexport const bind = directive((handleEvent) => (part) => {\n    if (!(part instanceof EventPart)) {\n        throw new Error('\"bind\" directive can only be used in event listeners');\n    }\n\n    const el: any = part.element as HTMLConrolElement;\n    const isInput = el instanceof HTMLInputElement;\n    const isSelect = el instanceof HTMLSelectElement;\n    const isTextarea = el instanceof HTMLTextAreaElement;\n    const isButton = el instanceof HTMLButtonElement;\n\n    if (!isInput && !isSelect && !isTextarea && !isButton) {\n        throw new Error(\n            '\"bind\" directive can only be applied to input/select/textarea/button elements.'\n        );\n    }\n\n    part.setValue(function (...args) {\n        let value: string | boolean | any = el.defaultValue;\n        if (isSelect && el.options.length > 0) {\n            const i = el.selectedIndex >= 0 ? el.selectedIndex : 0;\n            value = el.options[i].value;\n        } else if (isInput) {\n            switch (el.type) {\n                case 'number':\n                case 'range':\n                    value = el.valueAsNumber;\n                    break;\n                case 'checkbox':\n                case 'radio':\n                    value = !!el.checked;\n                    break;\n                case 'time':\n                case 'date':\n                case 'datetime':\n                case 'datetime-local':\n                    value = el.valueAsDate;\n                    break;\n                default:\n                    value = el.value;\n            }\n        } else {\n            value = el.value;\n        }\n\n        handleEvent.call(this, value, ...args);\n    });\n});\n","export const call = (handleEvent, ...args) => function (...argv) {\n    handleEvent.call(this, ...argv, ...args);\n};","import { directive, EventPart } from 'lit-html';\n\nexport const capture = directive((handleEvent) => (part) => {\n\n    if (!(part instanceof EventPart)) {\n        throw new Error('\"capture\" directive can only be used in event listeners');\n    }\n\n    part.setValue(typeof handleEvent === 'object' ?\n        { ...handleEvent, capture: true } :\n        { handleEvent, capture: true }\n    );\n});","import { directive, EventPart } from 'lit-html';\n\nexport const once = directive((handleEvent) => (part) => {\n\n    if (!(part instanceof EventPart)) {\n        throw new Error('\"once\" directive can only be used in event listeners');\n    }\n\n    part.setValue(typeof handleEvent === 'object' ?\n        { ...handleEvent, once: true } :\n        { handleEvent, once: true }\n    );\n});","import { directive, EventPart } from 'lit-html';\n\nexport const passive = directive((handleEvent) => (part) => {\n\n    if (!(part instanceof EventPart)) {\n        throw new Error('\"passive\" directive can only be used in event listeners');\n    }\n\n    part.setValue(typeof handleEvent === 'object' ?\n        { ...handleEvent, passive: true } :\n        { handleEvent, passive: true }\n    );\n});","import { directive, EventPart } from 'lit-html';\n\nexport const prevent = directive((handler) => (part) => {\n\n    if (!(part instanceof EventPart)) {\n        throw new Error('\"prevent\" directive can only be used in event listeners');\n    }\n\n    const { handleEvent, ...options } = handler;\n\n    part.setValue({\n        handleEvent: function (event) {\n            event.preventDefault();\n            (handleEvent || handler).call(this, event);\n        },\n        ...options\n    });\n});","import { directive, EventPart } from 'lit-html';\n\nexport const stop = directive((handler, immediate = false) => (part) => {\n\n    if (!(part instanceof EventPart)) {\n        throw new Error('\"stop\" directive can only be used in event listeners');\n    }\n\n    const { handleEvent, ...options } = handler;\n\n    part.setValue({\n        handleEvent: function (event) {\n            immediate ? event.stopImmediatePropagation() : event.stopPropagation();\n            (handleEvent || handler).call(this, event);\n        },\n        ...options\n    });\n});","import { directive, EventPart } from 'lit-html';\n\nexport const self = directive((handler) => (part) => {\n\n    if (!(part instanceof EventPart)) {\n        throw new Error('\"self\" directive can only be used in event listeners');\n    }\n\n    const { handleEvent, ...options } = handler;\n\n    part.setValue({\n        handleEvent: function (event) {\n            (event.target === event.currentTarget)\n                && (handleEvent || handler).call(this, event);\n        },\n        ...options\n    });\n});","import hr from 'hyperactiv';\nimport { render, nothing } from 'lit-html';\n\nimport { attrToVal, camelCase, kebabCase, noop, unrender } from './utils';\n\nimport type * as Type from './types';\n\nconst { observe, computed, dispose } = hr;\n\nexport * from './utils';\nexport * from './types';\nexport * from './directives';\nexport * from 'lit-html';\n\nexport { observe, computed, dispose };\n\nexport const $ = (\n    {\n        render: template = () => nothing,\n        state: data = {},\n        target = document.body,\n        ...options\n    }: Type.Config,\n    ...context\n): Type.Widget => {\n    const model: {} = (typeof data === 'function') ? data(...context) : data;\n\n    Object.entries(target.dataset).forEach(([key, value]) => {\n        if (key in model) model[key] = attrToVal(value);\n    });\n\n    const state: ProxyConstructor = observe(model, {\n        batch: true,\n        deep: true,\n        bind: true,\n        ...options\n    });\n\n    const emit = (type: string, detail: object, { bubbles = false, cancelable = true } = {}) => {\n        target.dispatchEvent(\n            new CustomEvent(type, { detail, bubbles, cancelable })\n        );\n    };\n\n    let mounted = false;\n    const rerender = () => {\n        render(template(state, emit, ...context), target);\n        if (!mounted) {\n            emit('mount', model);\n            mounted = true;\n        }\n        emit('update', model);\n    };\n    const renderer = computed(({ computeAsync }) => {\n        if (mounted && !document.contains(target)) return destroy();\n        emit('state', model);\n        return Promise.resolve()\n            .then(() => computeAsync(rerender))\n            .catch(err => emit('error', err));\n    });\n\n    const events = new Set();\n    const on = (type: string, fn: (e: CustomEvent) => void, opts?: object | boolean) => {\n        target.addEventListener(type, fn, opts);\n        const off = () => {\n            target.removeEventListener(type, fn, opts);\n            return events.delete(off);\n        };\n        events.add(off);\n        return off;\n    };\n\n    const effects = new Set();\n    const effect = (fn: () => void, opts?: object) => {\n        const handle = computed(fn, opts);\n        const cancel = () => {\n            dispose(handle);\n            return effects.delete(cancel);\n        };\n        effects.add(cancel);\n        return cancel;\n    };\n\n    const observer = new MutationObserver((mutations: MutationRecord[]) => {\n        mutations.forEach((mutation) => {\n            if (mutation.type !== 'attributes') return;\n\n            const el: Element = mutation.target as Element;\n            const key = camelCase(mutation.attributeName.replace('data-', ''));\n\n            if (!(key in state)) return;\n\n            const value = el.getAttribute(mutation.attributeName);\n            if (value !== mutation.oldValue) {\n                const val = attrToVal(value);\n                if (state[key] !== val) state[key] = val;\n            }\n        });\n    });\n\n    observer.observe(target, {\n        attributeFilter: Object.entries(model).reduce((attrs, [key, val]) => {\n            if (typeof val !== 'function') {\n                attrs.push(`data-${kebabCase(key)}`);\n            }\n            return attrs;\n        }, []),\n        attributeOldValue: true,\n        characterData: false,\n        childList: false,\n        subtree: false\n    });\n\n    const destroy = (cb = noop) => {\n        observer.disconnect();\n        dispose(renderer);\n        effects.forEach((cancel: () => void) => cancel());\n        effects.clear();\n        emit('destroy', model);\n        events.forEach((off: () => void) => off());\n        events.clear();\n        unrender(target);\n        cb(model);\n    };\n\n    const ctx = (fn: (...ctx: any[]) => any) => fn(...context);\n\n    return {\n        on,\n        ctx,\n        model, // plain state (object)\n        state, // reactive state (proxy)\n        effect,\n        target,\n        destroy,\n        render: rerender,\n    };\n};\n\nexport const $$ = ({ target, ...config }: Type.Configs, ...context): Type.Widgets => {\n    if (!(target as NodeList | Node[]).length) {\n        target = [target] as Node[];\n    }\n\n    const widgets = Array.prototype.map.call(target, (target: HTMLElement) => {\n        return $({ ...config, target } as Type.Config, ...context);\n    });\n\n    return {\n        ...widgets,\n        effect: (fn, opts): () => void => {\n            const cancels = widgets.map((widget: Type.Widget) => widget.effect(fn(widget.state), opts));\n            return () => cancels.forEach(cancel => cancel());\n        },\n        on: (...args): () => void => {\n            const offs = widgets.map((widget: Type.Widget) => widget.on(...args));\n            return () => offs.forEach(off => off());\n        },\n        destroy: (cb): void => widgets.forEach((widget: Type.Widget) => widget.destroy(cb)),\n        render: (): void => widgets.forEach((widget: Type.Widget) => widget.render()),\n        state: (fn: (state: ProxyConstructor) => void): void => {\n            widgets.forEach((widget: Type.Widget) => fn(widget.state))\n        },\n        ctx: (fn: (...ctx: any[]) => any) => fn(...context),\n        forEach: Array.prototype.forEach.bind(widgets),\n        target,\n    };\n};"],"names":["BIND_IGNORED","isObj","object","setHiddenKey","key","value","Object","defineProperty","enumerable","configurable","defineBubblingProperties","parent","data","computedStack","observersMap","WeakMap","computedDependenciesTracker","timeout","queue","Set","process","task","clear","enqueue","batch","setTimeout","add","observe","obj","options","props","ignore","deep","bubble","bind","__observed","isWatched","prop","includes","set","Map","entries","forEach","val","proxy","Proxy","[object Object]","_","length","propertiesMap","get","has","tracker","Array","isArray","deeper","oldValue","ancestry","__handler","__key","__parent","unshift","dependents","dependent","__disposed","delete","getOwnPropertyNames","concat","getPrototypeOf","indexOf","constructor","name","filter","computed","wrappedFunction","autoRun","callback","disableTracking","target","thisArg","argsList","observeComputation","fun","result","apply","shift","push","computeAsync","dispose","computedFunction","directives","directive","f","args","d","isDirective","o","isCEPolyfill","window","customElements","undefined","polyfillWrapFlushCallback","reparentNodes","container","start","end","before","n","nextSibling","insertBefore","removeNodes","removeChild","noChange","nothing","marker","String","Math","random","slice","nodeMarker","markerRegex","RegExp","Template","element","this","nodesToRemove","stack","walker","document","createTreeWalker","content","lastPartIndex","index","partIndex","strings","values","node","nextNode","nodeType","hasAttributes","attributes","count","i","endsWith","stringForPart","lastAttributeNameRegex","exec","attributeLookupName","toLowerCase","attributeValue","getAttribute","removeAttribute","statics","split","parts","type","tagName","currentNode","parentNode","lastIndex","insert","s","createMarker","match","createTextNode","previousSibling","pop","str","suffix","isTemplatePartActive","part","createComment","TemplateInstance","template","processor","__parts","setValue","commit","fragment","cloneNode","importNode","nodeIndex","nodeName","handleTextExpression","insertAfterNode","handleAttributeExpressions","adoptNode","upgrade","policy","trustedTypes","createPolicy","createHTML","commentMarker","TemplateResult","l","html","isCommentBinding","commentOpen","lastIndexOf","attributeMatch","substr","createElement","getHTML","innerHTML","SVGTemplateResult","super","getTemplateElement","svgElement","firstChild","isPrimitive","isIterable","Symbol","iterator","AttributeCommitter","_createPart","AttributePart","v","text","t","dirty","setAttribute","_getValue","committer","NodePart","startNode","appendChild","endNode","ref","__insert","__pendingValue","__commitText","__commitTemplateResult","Node","__commitNode","__commitIterable","valueAsString","templateFactory","update","instance","_clone","itemParts","itemPart","item","appendIntoPart","insertAfterPart","BooleanAttributePart","Error","PropertyCommitter","single","PropertyPart","eventOptionsSupported","capture","addEventListener","removeEventListener","_e","EventPart","eventName","eventContext","__boundHandleEvent","e","handleEvent","newListener","oldListener","shouldRemoveListener","once","passive","shouldAddListener","__options","getOptions","event","call","DefaultTemplateProcessor","prefix","defaultTemplateProcessor","templateCache","templateCaches","stringsArray","keyString","join","render","appendInto","svg","unrender","noop","tick","fn","Promise","resolve","then","memo","invalidate","cache","validOrKey","JSON","stringify","attrToVal","isNaN","Number","parse","camelCase","pascal","camel","replace","w","toUpperCase","kebabCase","createAndInsertPart","containerPart","beforePart","beforeNode","newPart","updatePart","insertPartBefore","removePart","generateMap","list","map","partListCache","keyListCache","repeat","items","keyFnOrTemplate","keyFn","oldParts","oldKeys","newParts","newValues","newKeys","newKeyToIndexMap","oldKeyToIndexMap","oldHead","oldTail","newHead","newTail","oldIndex","oldPart","previousValue","cachedTemplate","nodes","createDocumentFragment","_state","until","state","lastRenderedIndex","previousValues","previousLength","resolvedValue","live","checkStrings","hasAttribute","guard","every","from","ClassList","classList","cls","classes","changed","classString","previousClassesCache","classMap","classInfo","previousClasses","remove","previousStylePropertyCache","styleMap","styleInfo","style","previousStyleProperties","cssText","removeProperty","setProperty","ifDefined","asyncAppend","mapper","async","value_1","__asyncValues","itemStartNode","asyncReplace","templateContent","unsafeHTML","isIe","navigator","userAgent","unsafeSVG","createElementNS","each","decorators","decorator","handler","self","el","prevHandler","destroy","isInput","HTMLInputElement","isSelect","HTMLSelectElement","isTextarea","HTMLTextAreaElement","isButton","HTMLButtonElement","defaultValue","selectedIndex","valueAsNumber","checked","valueAsDate","argv","prevent","preventDefault","stop","immediate","stopImmediatePropagation","stopPropagation","currentTarget","hr","$","body","context","model","dataset","emit","detail","bubbles","cancelable","dispatchEvent","CustomEvent","mounted","rerender","renderer","contains","catch","err","events","effects","observer","MutationObserver","mutations","mutation","attributeName","attributeFilter","reduce","attrs","attributeOldValue","characterData","childList","subtree","cb","disconnect","cancel","off","on","opts","ctx","effect","handle","$$","config","widgets","prototype","cancels","widget","offs"],"mappings":"AAAA,MAAMA,EAAe,CACjB,SACA,SACA,SACA,QACA,UACA,QAGG,SAASC,EAAMC,GAAU,OAAOA,GAA4B,iBAAXA,EACjD,SAASC,EAAaD,EAAQE,EAAKC,GACtCC,OAAOC,eAAeL,EAAQE,EAAK,CAAEC,MAAAA,EAAOG,YAAY,EAAOC,cAAc,IAE1E,SAASC,EAAyBR,EAAQE,EAAKO,GAClDR,EAAaD,EAAQ,QAASE,GAC9BD,EAAaD,EAAQ,WAAYS,GCf9B,MAAMC,EAAO,CAChBC,cAAe,GACfC,aAAc,IAAIC,QAClBC,4BAA6B,IAAID,SCHrC,I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