@shortfuse/materialdesignweb 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/components/Grid.js +1 -1
- package/components/Pane.js +2 -0
- package/core/Composition.js +1 -0
- package/dist/CustomElement.min.js +1 -1
- package/dist/CustomElement.min.js.map +2 -2
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +2 -2
- package/dist/meta.json +1 -1
- package/package.json +5 -4
- package/types/core/Composition.d.ts.map +1 -1
- package/dist/core/CustomElement.min.js +0 -2
- package/dist/core/CustomElement.min.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../core/optimizations.js", "../core/CompositionAdapter.js", "../core/css.js", "../core/dom.js", "../core/jsonMergePatch.js", "../core/observe.js", "../core/uid.js", "../core/template.js", "../core/Composition.js", "../core/CustomElement.js"],
|
|
4
|
-
"sourcesContent": ["// Micro-optimized functions\n\nlet BLANK_TEXT;\nlet BLANK_COMMENT;\nlet BLANK_DIV;\n\n/** @return {Text} */\nexport function createEmptyTextNode() {\n // eslint-disable-next-line no-return-assign\n return (BLANK_TEXT ??= new Text()).cloneNode();\n}\n\n/** @return {HTMLDivElement} */\nexport function createEmptyDiv() {\n // eslint-disable-next-line no-return-assign\n return (BLANK_DIV ??= document.createElement('div')).cloneNode();\n}\n\n/** @return {Comment} */\nexport function createEmptyComment() {\n // eslint-disable-next-line no-return-assign\n return (BLANK_COMMENT ??= new Comment()).cloneNode();\n}\n", "import { createEmptyComment } from './optimizations.js';\n\n/**\n * @template T\n * @typedef {import('./Composition.js').default<T>} Composition\n */\n\n/**\n * @template T\n * @typedef {import('./Composition.js').RenderOptions<T>} RenderOptions\n */\n\n/**\n * @template T\n * @typedef {Object} DomAdapterCreateOptions\n * @prop {Comment} anchorNode\n * @prop {(...args:any[]) => HTMLElement} [create]\n * @prop {Composition<T>} composition\n * @prop {RenderOptions<T>} renderOptions\n */\n\n/**\n * @typedef {Object} ItemMetadata\n * @prop {Element} element\n * @prop {any} key\n * @prop {Element|Comment} domNode\n * @prop {Function} render\n * @prop {boolean} [hidden]\n * @prop {Comment} [comment]\n */\n\n/** @template T */\nexport default class CompositionAdapter {\n /** @param {DomAdapterCreateOptions<T>} options */\n constructor(options) {\n this.anchorNode = options.anchorNode;\n\n /** @type {ItemMetadata[]} */\n this.metadata = [];\n /**\n * Ordered-list of metadata keys\n * Chrome and FireFox optimize arrays for indexOf/includes\n * Safari is faster with WeakMap.get(), but can't use Primitive keys\n * TODO: Add Safari path\n * @type {any[]}\n */\n this.keys = [];\n\n /**\n * Chrome needs a hint to know we will need a fast path for array by keys.\n */\n this.needsArrayKeyFastPath = false;\n\n /** @type {Composition<T>} */\n this.composition = options.composition;\n /** @type {RenderOptions<T>} */\n this.renderOptions = options.renderOptions;\n\n /** @type {Map<any, ItemMetadata>} */\n this.metadataCache = null;\n\n /** @type {Element[]} */\n this.queuedElements = [];\n // this.batching = false;\n /** @type {number|null} */\n this.batchStartIndex = null;\n /** @type {number|null} */\n this.batchEndIndex = null;\n }\n\n /**\n * @param {Partial<T>} changes\n * @param {T} data\n * @return {import('./Composition.js').RenderDraw<T>}\n */\n render(changes, data) {\n return this.composition.render(changes, data, this.renderOptions);\n }\n\n startBatch() {\n this.needsArrayKeyFastPath = true;\n // this.batching = true;\n }\n\n writeBatch() {\n if (!this.queuedElements.length) return;\n /** @type {Comment|Element|Document} */\n const previousSibling = this.metadata[this.batchStartIndex - 1]?.domNode ?? this.anchorNode;\n previousSibling.after(...this.queuedElements);\n this.queuedElements.length = 0;\n }\n\n stopBatch() {\n this.writeBatch();\n\n this.needsArrayKeyFastPath = false;\n this.batchStartIndex = null;\n this.batchEndIndex = null;\n if (this.metadataCache) {\n for (const { domNode } of this.metadataCache.values()) {\n domNode.remove();\n }\n this.metadataCache.clear();\n }\n }\n\n /** @param {number} index */\n removeByIndex(index) {\n const [metadata] = this.metadata.splice(index, 1);\n const { domNode, key } = metadata;\n this.keys.splice(index, 1);\n domNode.remove();\n\n // Don't release in case we may need it later\n if (this.metadataCache) {\n this.metadataCache.set(key, metadata);\n } else {\n this.metadataCache = new Map([[key, metadata]]);\n }\n }\n\n /**\n * Worst case scenario\n * @param {number} newIndex expectedIndex\n * @param {*} changes\n * @param {*} data\n * @param {*} key\n * @param {*} change\n * @param {boolean} [skipOnMatch]\n * JSON Merge has no way to express sort change and data change. Best\n * performance is done via invoking render on sort change and another on\n * inner change. Can't skip if mixing change types.\n */\n renderData(newIndex, changes, data, key, change, skipOnMatch) {\n if (newIndex < this.metadata.length) {\n const metadataAtIndex = this.metadata[newIndex];\n\n // There is an element in this slot\n\n // Compare if different\n const currentKey = metadataAtIndex.key;\n const sameKey = (currentKey === key);\n const isPartial = (change !== key);\n\n if (sameKey) {\n // Both reference the same key (correct spot)\n if (isPartial) {\n metadataAtIndex.render(changes, data);\n } else if (skipOnMatch) {\n // Skip overwrite. Presume no change\n // console.warn('same key, no reason to repaint', newIndex);\n } else {\n // console.warn('no skip on match', newIndex);\n metadataAtIndex.render(changes, data);\n }\n return;\n }\n\n // eslint-disable-next-line no-multi-assign\n const metadataCache = (this.metadataCache ??= new Map());\n\n // If not same key. Scan key list.\n // Can avoid checking before current index. Will always be after current\n let failedFastPath = false;\n if (this.needsArrayKeyFastPath) {\n // Invoking includes will ensure Chrome generates an internal hash map\n failedFastPath = !this.keys.includes(key);\n this.needsArrayFastPath = false;\n }\n const oldIndex = failedFastPath ? -1 : this.keys.indexOf(key, newIndex + 1);\n if (oldIndex === -1) {\n // New key\n // console.log('new key?', 'should be at', newIndex);\n // Was key removed in this batch?\n if (metadataCache.has(key)) {\n // console.log('inserting removed element', 'at', newIndex);\n // (Optimistic insert)\n // Key was removed and should be here instead\n // If should have been replace, will correct next step\n const previousMetadata = metadataCache.get(key);\n this.metadata.splice(newIndex, 0, previousMetadata);\n this.keys.splice(newIndex, 0, key);\n\n const previousSibling = this.metadata[newIndex - 1]?.domNode ?? this.anchorNode;\n previousSibling.after(previousMetadata.domNode);\n metadataCache.delete(key);\n return;\n }\n\n // (Optimistic replace)\n // Brand new key. Cache whatever is in current and replace\n // If should have been insert, will correct itself next step.\n // Allows multiple inserts to batch instead of one-by-one\n\n // console.log('completely new key', 'removing old. will replace', newIndex);\n metadataCache.set(currentKey, metadataAtIndex);\n\n // Continue to PUT below\n } else {\n // Key is in the wrong spot (guaranteed to be oldIndex > newIndex)\n // console.warn('Found key for', newIndex, '@', oldIndex);\n // console.warn('swapping', newIndex, '<=>', oldIndex);\n if ((newIndex - oldIndex) === -1) {\n // (Optimistic removal)\n // If element should be one step sooner, remove instead to shift up.\n // If should have been swap, will correct itself next step.\n // console.warn('Removing', newIndex, 'instead');\n this.removeByIndex(newIndex);\n return;\n }\n // Swap with other element\n // Arrays should be iterated sequentially.\n // Array can never swap before current index\n\n // Store what's later in the tree to move here\n\n const correctMetadata = this.metadata[oldIndex];\n\n // Move back <=\n this.metadata[newIndex] = correctMetadata;\n this.metadata.splice(oldIndex, 1);\n\n const { domNode: domNodeToRemove } = metadataAtIndex;\n domNodeToRemove.replaceWith(correctMetadata.domNode);\n\n if (!skipOnMatch) {\n console.warn('no skip on match on swap', newIndex);\n correctMetadata.render(changes, data);\n }\n\n // Remove posterior\n\n this.keys[newIndex] = key;\n this.keys.splice(oldIndex, 1);\n\n domNodeToRemove.remove();\n\n // Don't release in case we may need it later\n // console.debug('Caching key', key);\n metadataCache.set(currentKey, metadataAtIndex);\n\n return;\n }\n }\n\n const render = this.render(changes, data);\n const element = /** @type {Element} */ (render.target);\n\n this.metadata[newIndex] = {\n render,\n element,\n key,\n domNode: element,\n };\n this.keys[newIndex] = key;\n\n if (this.batchEndIndex === null || this.batchEndIndex !== (newIndex - 1)) {\n this.writeBatch();\n // Start new batch\n this.batchStartIndex = newIndex;\n }\n this.batchEndIndex = newIndex;\n this.queuedElements.push(element);\n }\n\n removeEntries(startIndex = 0) {\n const { length } = this.metadata;\n for (let index = length - 1; index >= startIndex; index--) {\n this.metadata[index].domNode.remove();\n }\n this.metadata.length = startIndex;\n this.keys.length = startIndex;\n }\n\n /**\n * @param {number} [index]\n * @param {ItemMetadata} [metadata]\n * @param {any} [key]\n * @return {boolean} changed\n */\n hide(index, metadata, key) {\n if (!metadata) {\n if (index == null) {\n index = this.keys.indexOf(key);\n }\n metadata = this.metadata[index];\n if (!metadata) {\n return false;\n }\n }\n\n if (metadata.hidden) return false;\n\n let { comment, element } = metadata;\n if (!comment) {\n comment = createEmptyComment();\n metadata.comment = comment;\n }\n\n element.replaceWith(comment);\n metadata.domNode = comment;\n metadata.hidden = true;\n return true;\n }\n\n /**\n * @param {number} [index]\n * @param {ItemMetadata} [metadata]\n * @param {any} [key]\n * @return {boolean} changed\n */\n show(index, metadata, key) {\n if (!metadata) {\n if (index == null) {\n index = this.keys.indexOf(key);\n }\n metadata = this.metadata[index];\n if (!metadata) {\n return false;\n }\n }\n\n if (!metadata.hidden) return false;\n\n const { comment, element } = metadata;\n\n comment.replaceWith(element);\n metadata.domNode = element;\n metadata.hidden = false;\n return true;\n }\n}\n", "/** @type {Map<string, CSSStyleSheet>} */\nconst cssStyleSheetsCache = new Map();\n\n/**\n * @param {string} content\n * @param {boolean} [useCache=true]\n * @return {CSSStyleSheet}\n */\nexport function createCSSStyleSheet(content, useCache = true) {\n if (useCache && cssStyleSheetsCache.has(content)) {\n return cssStyleSheetsCache.get(content);\n }\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(content);\n if (useCache) {\n cssStyleSheetsCache.set(content, sheet);\n }\n return sheet;\n}\n\n/** @type {Map<string, HTMLStyleElement>} */\nconst styleElementCache = new Map();\n\n/** @type {Document} */\nlet _inactiveDocument;\n\n/**\n * @param {string} content\n * @param {boolean} [useCache=true]\n * @return {HTMLStyleElement}\n */\nexport function createHTMLStyleElement(content, useCache = true) {\n let style;\n if (useCache && styleElementCache.has(content)) {\n style = styleElementCache.get(content);\n } else {\n _inactiveDocument ??= document.implementation.createHTMLDocument();\n style = _inactiveDocument.createElement('style');\n style.textContent = content;\n if (useCache) {\n styleElementCache.set(content, style);\n }\n }\n return /** @type {HTMLStyleElement} */ (style.cloneNode(true));\n}\n\n/** @type {boolean} */\nlet _cssStyleSheetConstructable;\n\n/**\n * @param {string} content\n * @param {boolean} [useCache=true]\n */\nexport function createCSS(content, useCache = true) {\n if (_cssStyleSheetConstructable == null) {\n try {\n const sheet = createCSSStyleSheet(content, useCache);\n _cssStyleSheetConstructable = true;\n return sheet;\n } catch {\n _cssStyleSheetConstructable = false;\n }\n }\n return _cssStyleSheetConstructable\n ? createCSSStyleSheet(content, useCache)\n : createHTMLStyleElement(content, useCache);\n}\n\n/**\n * @param {Iterable<HTMLStyleElement|CSSStyleSheet>} styles\n * @param {boolean} [useCache=true]\n * @yields composed CSSStyleSheet\n * @return {Generator<CSSStyleSheet>} composed CSSStyleSheet\n */\nexport function* generateCSSStyleSheets(styles, useCache = true) {\n for (const style of styles) {\n if (style instanceof HTMLStyleElement) {\n yield createCSSStyleSheet(style.textContent, useCache);\n } else if (style.ownerNode) {\n console.warn('Stylesheet is part of style');\n yield createCSSStyleSheet([...style.cssRules].map((r) => r.cssText).join(''), useCache);\n } else {\n yield style;\n }\n }\n}\n\n/** @type {WeakMap<CSSStyleSheet, HTMLStyleElement>} */\nconst styleElementFromStyleSheetCache = new WeakMap();\n\n/**\n * @param {Iterable<HTMLStyleElement|CSSStyleSheet>} styles\n * @param {boolean} [useCache=true]\n * @yields composed HTMLStyleElement\n * @return {Generator<HTMLStyleElement>} composed CSSStyleSheet\n */\nexport function* generateHTMLStyleElements(styles, useCache = true) {\n for (const style of styles) {\n if (style instanceof HTMLStyleElement) {\n yield style;\n } else if (style.ownerNode instanceof HTMLStyleElement) {\n // console.log('Cloning parent HTMLStyleElement instead');\n // @ts-ignore Skip cast\n yield style.ownerNode.cloneNode(true);\n } else if (useCache && styleElementFromStyleSheetCache.has(style)) {\n // @ts-ignore Skip cast\n yield styleElementFromStyleSheetCache.get(style).cloneNode(true);\n } else {\n console.warn('Manually constructing HTMLStyleElement', [...style.cssRules].map((r) => r.cssText).join('\\n'));\n const styleElement = document.createElement('style');\n styleElement.textContent = [...style.cssRules].map((r) => r.cssText).join('');\n if (useCache) {\n styleElementFromStyleSheetCache.set(style, styleElement);\n }\n\n // @ts-ignore Skip cast\n yield styleElement.cloneNode(true);\n }\n }\n}\n\n/**\n * @param {TemplateStringsArray|string} array\n * @param {...any} substitutions\n * @return {HTMLStyleElement|CSSStyleSheet}\n */\nexport function css(array, ...substitutions) {\n if (typeof array === 'string') return createCSS(array);\n return createCSS(String.raw({ raw: array }, ...substitutions));\n}\n\n/**\n * @param {TemplateStringsArray|string|HTMLStyleElement|CSSStyleSheet} styles\n * @param {...any} substitutions\n * @return {HTMLStyleElement|CSSStyleSheet}\n */\nexport function addGlobalCss(styles, ...substitutions) {\n /** @type {HTMLStyleElement|CSSStyleSheet} */\n let compiled;\n if (typeof styles === 'string') {\n compiled = css(styles);\n } else if (Array.isArray(styles)) {\n compiled = css(/** @type {TemplateStringsArray} */ (styles), ...substitutions);\n } else {\n compiled = /** @type {HTMLStyleElement|CSSStyleSheet} */ (styles);\n }\n\n if (compiled instanceof HTMLStyleElement) {\n document.head.append(compiled);\n } else {\n document.adoptedStyleSheets = [\n ...document.adoptedStyleSheets,\n compiled,\n ];\n }\n return compiled;\n}\n", "/* eslint-disable no-bitwise */\n\n/**\n * @param {any} value\n * @return {?string}\n */\nexport function attrValueFromDataValue(value) {\n switch (value) {\n case undefined:\n case null:\n case false:\n return null;\n case true:\n return '';\n default:\n return `${value}`;\n }\n}\n\n/** @type {Map<string, string>} */\nlet attrNameFromPropNameCache;\n\n/**\n * Converts property name to attribute name\n * (Similar to DOMStringMap)\n * @param {string} name\n * @return {string}\n */\nexport function attrNameFromPropName(name) {\n attrNameFromPropNameCache ??= new Map();\n if (attrNameFromPropNameCache.has(name)) {\n return attrNameFromPropNameCache.get(name);\n }\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n const value = name.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);\n attrNameFromPropNameCache.set(name, value);\n return value;\n}\n\nexport const CHROME_VERSION = Number.parseFloat(navigator.userAgent.match(/Chrome\\/([\\d.]+)/)?.[1]);\nexport const FIREFOX_VERSION = Number.parseFloat(navigator.userAgent.match(/Firefox\\/([\\d.]+)/)?.[1]);\nexport const SAFARI_VERSION = CHROME_VERSION || !navigator.userAgent.includes('AppleWebKit')\n ? Number.NaN\n : Number.parseFloat(navigator.userAgent.match(/Version\\/([\\d.]+)/)?.[1]);\n\n/**\n * @param {Element} element\n * @return {boolean}\n */\nexport function isFocused(element) {\n if (!element) return false;\n // @ts-ignore runtime check\n if (FIREFOX_VERSION < 113 && element.constructor.formAssociated && element.hasAttribute('disabled')) {\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1818287\n console.warn('Firefox bug 1818287: Disabled form associated custom element cannot receive focus.');\n return false;\n }\n if (document.activeElement === element) return true;\n if (!element.isConnected) return false;\n if (element?.getRootNode() === document) return false; // isInLightDOM\n // console.debug('checking shadowdom', element, element.matches(':focus'));\n return element.matches(':focus');\n}\n\n/**\n * @param {HTMLElement|Element} element\n * @param {Parameters<HTMLElement['focus']>} [options]\n * @return {boolean} Focus was successful\n */\nexport function attemptFocus(element, ...options) {\n if (!element) return false;\n try {\n // @ts-expect-error Use catch if not HTMLElement\n element.focus(...options);\n } catch (e) {\n console.error(e);\n return false;\n // Ignore error.\n }\n return isFocused(element);\n}\n\n/**\n * @param {Element} element\n * @return {boolean}\n */\nexport function isRtl(element) {\n return getComputedStyle(element).direction === 'rtl';\n}\n", "/** @link https://www.rfc-editor.org/rfc/rfc7396 */\n\n/**\n * @template T1\n * @template T2\n * @param {T1} target\n * @param {T2} patch\n * @return {T1|T2|(T1 & T2)}\n */\nexport function applyMergePatch(target, patch) {\n // @ts-ignore Runtime check\n if (target === patch) return target;\n if (target == null || patch == null || typeof patch !== 'object') return patch;\n if (typeof target !== 'object') {\n // @ts-ignore Forced cast to object\n target = {};\n }\n for (const [key, value] of Object.entries(patch)) {\n if (value == null) {\n // @ts-ignore Runtime check\n if (key in target) {\n // @ts-ignore T1 is always object\n delete target[key];\n }\n } else {\n // @ts-ignore T1 is forced object\n target[key] = applyMergePatch(target[key], value);\n }\n }\n return target;\n}\n\n/**\n * Creates a JSON Merge patch based\n * Allows different strategies for arrays\n * - `reference`: Per spec, returns array as is\n * - `clone`: Clones all entries with no inspection.\n * - `object`: Convert to flattened, array-like objects. Requires\n * consumer of patch to be aware of the schema beforehand.\n * @param {object|number|string|boolean} previous\n * @param {object|number|string|boolean} current\n * @param {'clone'|'object'|'reference'} [arrayStrategy='reference']\n * @return {any} Patch\n */\nexport function buildMergePatch(previous, current, arrayStrategy = 'reference') {\n if (previous === current) return null;\n if (current == null || typeof current !== 'object') return current;\n if (previous == null || typeof previous !== 'object') {\n return structuredClone(current);\n }\n\n const patch = {};\n if (Array.isArray(current)) {\n if (arrayStrategy === 'reference') {\n return current;\n }\n // Assume previous is array\n if (arrayStrategy === 'clone') {\n return structuredClone(current);\n }\n for (const [index, value] of current.entries()) {\n if (value === null) {\n // @ts-ignore patch is ArrayLike\n patch[index] = null;\n continue;\n }\n if (value == null) {\n continue; // Skip undefined\n }\n // @ts-ignore previous is ArrayLike\n const changes = buildMergePatch(previous[index], value, arrayStrategy);\n if (changes !== null) {\n // @ts-ignore patch is ArrayLike\n patch[index] = changes;\n }\n }\n // for (let i = current.length; i < previous.length; i++) {\n // patch[i] = null;\n // }\n // @ts-ignore previous is ArrayLike\n if (current.length !== previous.length) {\n patch.length = current.length;\n }\n return patch;\n }\n\n const previousKeys = new Set(Object.keys(previous));\n for (const [key, value] of Object.entries(current)) {\n previousKeys.delete(key);\n if (value === null) {\n // @ts-ignore patch is Object\n patch[key] = null;\n continue;\n }\n if (value == null) {\n continue; // Skip undefined\n }\n // @ts-ignore previous is Object\n const changes = buildMergePatch(previous[key], value, arrayStrategy);\n if (changes !== null) {\n // @ts-ignore patch is Object\n patch[key] = changes;\n }\n }\n for (const key of previousKeys) {\n // @ts-ignore patch is Object\n patch[key] = null;\n }\n\n return patch;\n}\n\n/**\n * Short-circuited JSON Merge Patch evaluation\n * @template T\n * @param {T} target\n * @param {Partial<T>} patch\n * @return {boolean}\n */\nexport function hasMergePatch(target, patch) {\n if (target === patch) return false;\n if (patch == null || typeof patch !== 'object') return true;\n if (target != null && typeof target !== 'object') {\n return true;\n }\n for (const [key, value] of Object.entries(patch)) {\n if (value == null) {\n // @ts-ignore Runtime check\n if (key in target) {\n return true;\n }\n // @ts-ignore T is object\n } else if (hasMergePatch(target[key], value)) {\n return true;\n }\n }\n return false;\n}\n", "import { attrNameFromPropName } from './dom.js';\nimport { buildMergePatch, hasMergePatch } from './jsonMergePatch.js';\n\n/** @typedef {'string' | 'boolean' | 'map' | 'set' | 'float' | 'integer' | 'object' | 'function' | 'array'} ObserverPropertyType */\n\n/**\n * @template {ObserverPropertyType} T\n * @typedef {(\n * T extends 'boolean' ? boolean\n * : T extends 'string' ? string\n * : T extends 'float' | 'integer' ? number\n * : T extends 'array' ? any[]\n * : T extends 'object' ? any\n * : T extends 'function' ? (...args:any) => any\n * : unknown\n * )} ParsedObserverPropertyType\n */\n\n/**\n * @template {ObserverPropertyType} T1\n * @template {any} T2\n * @template {Object} [C=any]\n * @typedef {Object} ObserverOptions\n * @prop {T1} [type]\n * @prop {boolean} [enumerable]\n * @prop {boolean|'write'|'read'} [reflect]\n * @prop {string} [attr]\n * @prop {boolean} [readonly]\n * Defaults to false if type is boolean\n * @prop {boolean} [nullable]\n * @prop {T2} [empty]\n * @prop {T2} [value]\n * @prop {(this:C, data:Partial<C>, fn?: () => T2) => T2} [get]\n * Function used when null passed\n * @prop {(this:C, value:any)=>T2} [parser]\n * @prop {(this:C, value:null|undefined)=>T2} [nullParser]\n * @prop {(this:C, value: T2, fn?:(value2: T2) => any) => any} [set]\n * Function used when comparing\n * @prop {(this:C, a:T2, b:T2)=> any} [diff]\n * @prop {(this:C, a:T2, b:T2)=>boolean} [is]\n * Simple callback\n * @prop {(this:C, oldValue:T2, newValue:T2, changes:any)=>any} [changedCallback]\n * Named callback\n * @prop {(this:C, name:string, oldValue: T2, newValue: T2, changes:any) => any} [propChangedCallback]\n * Attribute callback\n * @prop {(this:C, name:keyof C & string, oldValue: string, newValue: string) => any} [attributeChangedCallback]\n * @prop {[keyof C & string, (this:C, ...args:any[]) => any][]} [watchers]\n * @prop {Set<keyof C & string>} [props]\n * @prop {WeakMap<C,T2>} [values]\n * @prop {WeakMap<C, T2>} [computedValues]\n * @prop {WeakSet<C>} [needsSelfInvalidation]\n */\n\n/**\n * @template {ObserverPropertyType} T1\n * @template {any} [T2=any]\n * @template {Object} [C=any]\n * @template {keyof C & string} [K=any]\n * @typedef {ObserverOptions<T1, T2, C> & { key: K, values?: WeakMap<C, T2>; attrValues?: WeakMap<C, string> }} ObserverConfiguration\n */\n\n/**\n * @param {ObserverPropertyType} type\n * @return {any}\n */\nfunction emptyFromType(type) {\n switch (type) {\n case 'boolean':\n return false;\n case 'integer':\n case 'float':\n return 0;\n case 'map':\n return new Map();\n case 'set':\n return new Set();\n case 'array':\n return [];\n case 'object':\n return null;\n default:\n case 'string':\n return '';\n }\n}\n\n/**\n * @template {Object} T\n * @param {T} proxyTarget\n * @param {Set<string>} set\n * @param {Set<string>} deepSet\n * @param {string} [prefix]\n * @return {T}\n */\nfunction buildProxy(proxyTarget, set, deepSet, prefix) {\n // @ts-ignore\n proxyTarget ??= {};\n return new Proxy(proxyTarget, {\n get(target, p) {\n // @ts-ignore\n const value = target[p];\n if (typeof p !== 'symbol') {\n const arg = prefix ? `${prefix}.${p}` : p;\n if (prefix) {\n deepSet.add(arg);\n } else {\n set.add(arg);\n }\n if (typeof value === 'object' && value != null) {\n return buildProxy(value, set, deepSet, arg);\n }\n }\n return value;\n },\n has(target, p) {\n const value = Reflect.has(target, p);\n if (typeof p !== 'symbol') {\n const arg = prefix ? `${prefix}.p` : p;\n if (prefix) {\n deepSet.add(arg);\n } else {\n set.add(arg);\n }\n }\n return value;\n },\n });\n}\n\n/**\n * @param {ObserverPropertyType} type\n * @return {any}\n */\nfunction defaultParserFromType(type) {\n switch (type) {\n case 'boolean':\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean#boolean_coercion\n * @param {any} v\n * @return {boolean}\n */\n return (v) => !!v;\n case 'integer':\n // Calls ToNumber(x)\n return Math.round;\n case 'float':\n /**\n * Doesn't support `BigInt` types\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#number_coercion\n * @param {any} v\n * @return {number}\n */\n return (v) => +v;\n case 'map':\n return Map;\n case 'set':\n return Set;\n case 'object':\n case 'array':\n /**\n * Reflect self\n * @template T\n * @param {T} o\n * @return {T}\n */\n return (o) => o;\n default:\n case 'string':\n /**\n * Doesn't support `Symbol` types\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion\n * @param {any} v\n * @return {string}\n */\n return (v) => `${v}`;\n }\n}\n\n/**\n * @param {(data: Partial<any>) => any} fn\n * @param {...any} args\n * @this {any}\n * @return {{\n * props: {\n * this: string[],\n * args: string[][],\n * },\n * deepPropStrings: {\n * this: string[],\n * args: string[][],\n * },\n * deepProps: {\n * this: string[][],\n * args: string[][][],\n * },\n * defaultValue: any,\n * reusable: boolean,\n * }}\n */\nexport function observeFunction(fn, ...args) {\n /** @type {Set<string>} */\n const thisPoked = new Set();\n /** @type {Set<string>} */\n const thisPokedDeep = new Set();\n\n const argWatchers = args.map((arg) => {\n const poked = new Set();\n const pokedDeep = new Set();\n const proxy = buildProxy(arg, poked, pokedDeep);\n return { poked, pokedDeep, proxy };\n });\n\n const thisProxy = buildProxy(this ?? {}, thisPoked, thisPokedDeep);\n const defaultValue = fn.apply(thisProxy, argWatchers.map((watcher) => watcher.proxy));\n /* Arrow functions can reused if they don't poke `this` */\n const reusable = fn.name ? true : !thisPoked.size;\n\n return {\n props: {\n this: [...thisPoked],\n args: argWatchers.map((watcher) => [...watcher.poked]),\n },\n deepPropStrings: {\n this: [...thisPokedDeep],\n args: argWatchers.map((watcher) => [...watcher.pokedDeep]),\n },\n deepProps: {\n this: [...thisPokedDeep].map((deepPropString) => deepPropString.split('.')),\n args: argWatchers.map((watcher) => [...watcher.pokedDeep].map((deepPropString) => deepPropString.split('.'))),\n },\n defaultValue,\n reusable,\n };\n}\n\n/** @return {null} */\nfunction defaultNullParser() { return null; }\n\n/**\n * @template {string} K\n * @template {ObserverPropertyType} [T1=any]\n * @template {any} [T2=ParsedObserverPropertyType<T1>]\n * @template {Object} [C=any]\n * @param {K} name\n * @param {T1|ObserverOptions<T1,T2>} [typeOrOptions='string']\n * @param {any} [object]\n * @return {ObserverConfiguration<T1,T2,C,K> & ObserverOptions<T1,T2,C>}\n */\nexport function parseObserverOptions(name, typeOrOptions, object) {\n /** @type {Partial<ObserverOptions<T1,T2>>} */\n const options = (typeof typeOrOptions === 'string')\n ? { type: typeOrOptions }\n : typeOrOptions;\n\n let {\n watchers, value, readonly,\n empty, type,\n enumerable, reflect, attr,\n nullable, parser, nullParser,\n get,\n is, diff,\n props,\n } = options;\n\n watchers ??= [];\n readonly ??= false;\n\n if (empty === undefined) {\n empty = null;\n }\n\n value ??= empty;\n\n if (get && !props) {\n // Custom `get` uses computed values.\n // Invalidate computed value when dependent `prop` changes\n const observeResult = observeFunction(get.bind(object), object, () => value);\n value ??= observeResult.defaultValue;\n const uniqueProps = new Set([\n ...observeResult.props.this,\n ...observeResult.props.args[0],\n ]);\n props = uniqueProps;\n }\n\n /** @type {ObserverPropertyType} */\n if (!type) {\n if (value == null) {\n // @ts-ignore\n type = 'string';\n } else {\n const parsed = typeof value;\n // @ts-ignore\n type = (parsed === 'number')\n ? (Number.isInteger(value) ? 'integer' : 'number')\n : parsed;\n }\n }\n\n enumerable ??= name[0] !== '_';\n nullable ??= (type === 'boolean') ? false : (empty == null);\n if (!nullable) {\n empty ??= emptyFromType(type);\n value ??= empty;\n }\n\n reflect ??= enumerable ? (type !== 'object') : (attr ? 'write' : false);\n attr ??= (reflect ? attrNameFromPropName(name) : null);\n\n // if defined ? value\n // else if boolean ? false\n // else if onNullish ? false\n // else if empty == null\n parser ??= defaultParserFromType(type);\n if (!nullParser) {\n if (nullable) {\n nullParser = defaultNullParser;\n } else {\n nullParser = (empty === null)\n ? () => emptyFromType(type)\n : () => empty;\n }\n }\n\n is ??= (type === 'object')\n ? (a, b) => !hasMergePatch(a, b)\n : ((type === 'array') ? () => false : Object.is);\n\n if (diff === undefined) {\n // @ts-ignore\n diff = ((type === 'object') ? (a, b) => buildMergePatch(a, b, 'reference') : null);\n }\n\n return {\n ...options,\n type,\n is,\n diff,\n attr,\n reflect,\n readonly,\n enumerable,\n value,\n parser,\n nullParser,\n key: name,\n // @ts-ignore Can't cast\n props,\n // @ts-ignore Can't cast\n watchers,\n };\n}\n\n/**\n * @this {ObserverConfiguration<?,?,?>}\n * @param {*} value\n */\nexport function parsePropertyValue(value) {\n let newValue = value;\n newValue = value == null\n ? this.nullParser.call(this, value)\n : this.parser.call(this, newValue);\n return newValue;\n}\n\n/**\n * @param {ObserverConfiguration<?,?,?,?>} config\n * @param {any} oldValue\n * @param {any} value\n * @return {boolean} changed\n */\nfunction detectChange(config, oldValue, value) {\n if (config.get) {\n // TODO: Custom getter vs parser\n }\n\n // Compute real new value after parsing\n const newValue = (value == null)\n ? config.nullParser.call(this, value)\n : config.parser.call(this, value);\n\n // Default change is the newValue\n let changes = newValue;\n\n // Null check\n if (oldValue == null) {\n if (newValue == null) {\n // Both nullish\n return false;\n }\n } else if (newValue != null) {\n // Both non-null, compare\n if (config.diff) {\n // Custom change diff\n changes = config.diff.call(this, oldValue, newValue);\n if (changes == null) {\n // No difference\n return false;\n }\n } else if (config.is.call(this, oldValue, newValue)) {\n // Non-equal\n return false;\n }\n }\n\n // Commit value\n if (config.values) {\n config.values.set(this, newValue);\n } else {\n config.values = new WeakMap([[this, newValue]]);\n }\n\n // Emit change\n\n config.propChangedCallback?.call(this, config.key, oldValue, newValue, changes);\n config.changedCallback?.call(this, oldValue, newValue, changes);\n\n return true;\n}\n\n/**\n * @template {ObserverPropertyType} T1\n * @template {any} T2\n * @template {Object} C\n * @template {keyof C & string} K\n * @param {C} object\n * @param {K} key\n * @param {ObserverOptions<T1, T2, C>} options\n * @return {ObserverConfiguration<T1,T2,C,K>}\n */\nexport function defineObservableProperty(object, key, options) {\n const config = /** @type {ObserverConfiguration<T1,T2,C,K>} */ (\n parseObserverOptions(key, options, object));\n\n /**\n * @this {C}\n * @return {T2}\n */\n function internalGet() {\n return config.values?.has(this) ? config.values.get(this) : config.value;\n }\n\n /**\n * @this {C}\n * @param {T2} value\n * @return {void}\n */\n function internalSet(value) {\n // @ts-ignore\n const oldValue = this[key];\n detectChange.call(this, config, oldValue, value);\n }\n\n /** @return {void} */\n function onInvalidate() {\n // Current value is now invalidated. Recompute and check if changed\n // eslint-disable-next-line no-multi-assign\n\n const oldValue = config.computedValues?.get(this);\n const newValue = this[key];\n config.needsSelfInvalidation?.delete(this);\n detectChange.call(this, config, oldValue, newValue);\n }\n\n if (config.props) {\n for (const prop of config.props) {\n config.watchers.push([prop, onInvalidate]);\n }\n }\n\n /**\n * @this {C}\n * @return {T2}\n */\n function cachedGet() {\n const newValue = config.get.call(this, this, internalGet.bind(this));\n // Store computed value internally. Used by onInvalidate to get previous value\n // eslint-disable-next-line no-multi-assign\n const computedValues = (config.computedValues ??= new WeakMap());\n computedValues.set(this, newValue);\n return newValue;\n }\n\n /**\n * @this {C}\n * @param {T2} value\n * @return {void}\n */\n function cachedSet(value) {\n if (config.needsSelfInvalidation) {\n config.needsSelfInvalidation.add(this);\n } else {\n config.needsSelfInvalidation = new WeakSet([this]);\n }\n const oldValue = this[key];\n config.set.call(this, value, internalSet.bind(this));\n const newValue = this[key];\n if (!config.needsSelfInvalidation.has(this)) return;\n config.needsSelfInvalidation.delete(this);\n detectChange.call(this, config, oldValue, newValue);\n }\n\n /** @type {Partial<PropertyDescriptor>} */\n const descriptor = {\n enumerable: config.enumerable,\n configurable: true,\n get: config.get ? cachedGet : internalGet,\n set: config.set ? cachedSet : internalSet,\n };\n\n Object.defineProperty(object, key, descriptor);\n\n return config;\n}\n", "/** @type {Set<string>} */\nconst generatedUIDs = new Set();\n\n/**\n * @param {string} [prefix='x'] Prefix all UIDs by string to apply a name or ensure starts with [A-Z] character\n * @param {number} [n] Maximum number of variations needed. Calculated as 32^n.\n @return {string} */\nexport function generateUID(prefix = 'mdw_', n = 4) {\n let id;\n while (generatedUIDs.has(id = Math.random().toString(36).slice(2, n + 2)));\n generatedUIDs.add(id);\n return `${prefix}${id}`;\n}\n", "import { generateUID } from './uid.js';\n\n/**\n * Property are bound to an ID+Node\n * Values are either getter or via an function\n * @template {any} T\n * @typedef {Object} InlineFunctionEntry\n * @prop {(data:T) => any} fn\n * @prop {string[]} [props]\n * @prop {string[][]} [deepProps]\n * @prop {string[]} [injectionProps]\n * @prop {string[][]} [injectionDeepProps]\n * @prop {T} [defaultValue]\n */\n\n/** @type {Document} */\nlet _inactiveDocument;\n\n/** @type {DocumentFragment} */\nlet _blankFragment;\n\n/** @type {Range} */\nlet _fragmentRange;\n\n/**\n * @param {string} [fromString]\n * @return {DocumentFragment}\n */\nexport function generateFragment(fromString) {\n _inactiveDocument ??= document.implementation.createHTMLDocument();\n if (!fromString) {\n _blankFragment ??= _inactiveDocument.createDocumentFragment();\n return /** @type {DocumentFragment} */ (_blankFragment.cloneNode());\n }\n _fragmentRange ??= _inactiveDocument.createRange();\n return _fragmentRange.createContextualFragment(fromString);\n}\n\n/** @type {Map<string, InlineFunctionEntry<?>>} */\nexport const inlineFunctions = new Map();\n\n/**\n * @template T\n * @typedef {Object} RenderOptions\n * @prop {Object} context\n * @prop {ParentNode} root\n * @prop {Object<string, HTMLElement>} refs\n */\n\n/**\n * @param {(data: Partial<any>) => any} fn\n * @return {string}\n */\nexport function addInlineFunction(fn) {\n const internalName = `#${generateUID()}`;\n inlineFunctions.set(internalName, { fn });\n return `{${internalName}}`;\n}\n\n/** @type {Map<string, DocumentFragment>} */\nconst fragmentCache = new Map();\n/**\n * @template T1\n * @template T2\n * @param {TemplateStringsArray} strings\n * @param {...(string|DocumentFragment|Element|((this:T1, data:T2) => any))} substitutions\n * @return {DocumentFragment}\n */\nexport function html(strings, ...substitutions) {\n /** @type {Map<string, DocumentFragment|Element>} */\n let tempSlots;\n const replacements = substitutions.map((sub) => {\n switch (typeof sub) {\n case 'string': return sub;\n case 'function': return addInlineFunction(sub);\n case 'object': {\n if (sub == null) {\n console.warn(sub, 'is null', strings);\n return '';\n }\n // Assume Element\n const tempId = generateUID();\n tempSlots ??= new Map();\n tempSlots.set(tempId, sub);\n return `<div id=\"${tempId}\"></div>`;\n }\n default:\n throw new Error(`Unexpected substitution: ${sub}`);\n }\n });\n const compiledString = String.raw({ raw: strings }, ...replacements);\n\n if (tempSlots) {\n const fragment = generateFragment(compiledString);\n for (const [id, element] of tempSlots) {\n const slot = fragment.getElementById(id);\n slot.replaceWith(element);\n }\n return fragment;\n }\n\n let fragment;\n if (fragmentCache.has(compiledString)) {\n fragment = fragmentCache.get(compiledString);\n } else {\n fragment = generateFragment(compiledString);\n fragmentCache.set(compiledString, fragment);\n }\n\n return /** @type {DocumentFragment} */ (fragment.cloneNode(true));\n}\n", "/* eslint-disable sort-class-members/sort-class-members */\n\nimport CompositionAdapter from './CompositionAdapter.js';\nimport { generateCSSStyleSheets, generateHTMLStyleElements } from './css.js';\nimport { observeFunction } from './observe.js';\nimport { createEmptyComment, createEmptyTextNode } from './optimizations.js';\nimport { generateFragment, inlineFunctions } from './template.js';\nimport { generateUID } from './uid.js';\n\n/**\n * @template T\n * @typedef {Composition<?>|HTMLStyleElement|CSSStyleSheet|DocumentFragment|string} CompositionPart\n */\n\n/**\n * @template {any} T\n * @callback Compositor\n * @param {...(CompositionPart<T>)} parts source for interpolation (not mutated)\n * @return {Composition<T>}\n */\n\n/**\n * @template T\n * @typedef {Object} RenderOptions\n * @prop {T} [defaults] what\n * @prop {T} [store] what\n * @prop {DocumentFragment|HTMLElement|Element} [target] where\n * @prop {ShadowRoot} [shadowRoot] where\n * @prop {any} [context] `this` on callbacks/events\n * @prop {any} [injections]\n */\n\n/**\n * @template T\n * @typedef {{\n * target: Element|DocumentFragment,\n * byProp: (prop: keyof T & string, value:any, data?:Partial<T>) => void,\n * state: InitializationState,\n * } & ((changes:Partial<T>, data:T) => void)} RenderDraw\n */\n\n/** @typedef {HTMLElementEventMap & { input: InputEvent; } } HTMLElementEventMapFixed */\n\n/**\n * @typedef {(\n * Pick<HTMLElementEventMapFixed,\n * 'auxclick' |\n * 'beforeinput' |\n * 'click' |\n * 'compositionstart' |\n * 'contextmenu' |\n * 'drag' |\n * 'dragenter' |\n * 'dragover' |\n * 'dragstart' |\n * 'drop' |\n * 'invalid' |\n * 'keydown' |\n * 'keypress' |\n * 'keyup' |\n * 'mousedown' |\n * 'mousemove' |\n * 'mouseout' |\n * 'mouseover' |\n * 'mouseup' |\n * 'pointerdown' |\n * 'pointermove' |\n * 'pointerout' |\n * 'pointerover' |\n * 'pointerup' |\n * 'reset' |\n * 'selectstart' |\n * 'submit' |\n * 'touchend' |\n * 'touchmove' |\n * 'touchstart' |\n * 'wheel'\n * >\n * )} HTMLElementCancellableEventMap\n */\n\n/**\n * @typedef {(\n * HTMLElementEventMapFixed\n * & {[P in keyof HTMLElementCancellableEventMap as `~${P}`]: HTMLElementCancellableEventMap[P]}\n * & Record<string, Event|CustomEvent<any>>\n * )} CompositionEventMap\n */\n\n/**\n * @template {any} T\n * @template {keyof CompositionEventMap} [K = keyof CompositionEventMap]\n * @typedef {{\n * type?: K\n * tag?: string|symbol,\n * capture?: boolean;\n * once?: boolean;\n * passive?: boolean;\n * signal?: AbortSignal;\n * handleEvent?: (\n * this: T,\n * event: (K extends keyof CompositionEventMap ? CompositionEventMap[K] : Event) & {currentTarget:HTMLElement}\n * ) => any;\n * prop?: string;\n * deepProp?: string[],\n * }} CompositionEventListener\n */\n\n/**\n * @template T\n * @typedef {{\n * [P in keyof CompositionEventMap]?: (keyof T & string)\n * | ((this: T, event: CompositionEventMap[P] & {currentTarget:HTMLElement}) => any)\n * | CompositionEventListener<T, P>\n * }} CompositionEventListenerObject\n */\n\n/**\n * @template {any} T\n * @typedef {Object} NodeBindEntry\n * @prop {string} [key]\n * @prop {number} [index]\n * @prop {string} tag\n * @prop {string|number} subnode Index of childNode or attrName\n * @prop {string[]} props\n * @prop {string[][]} deepProps\n * @prop {boolean} [negate]\n * @prop {boolean} [doubleNegate]\n * @prop {Function} [expression]\n * @prop {(options: RenderOptions<?>, element: Element, changes:any, data:any) => any} [render] custom render function\n * @prop {CompositionEventListener<T>[]} [listeners]\n * @prop {Composition<any>} [composition] // Sub composition templating (eg: array)\n * @prop {T} defaultValue\n */\n\n/** @typedef {any[]} RenderState */\n\n/**\n * @typedef RenderGraphSearch\n * @prop {(state:InitializationState, changes:any, data:any) => any} invocation\n * @prop {number} cacheIndex\n * @prop {number} searchIndex\n * @prop {string | Function | string[]} query\n * @prop {boolean} [negate]\n * @prop {boolean} [doubleNegate]\n * @prop {Function} [expression]\n * @prop {string} prop\n * @prop {string[]} deepProp\n * @prop {string[]} propsUsed\n * @prop {string[][]} deepPropsUsed\n * @prop {any} defaultValue\n * @prop {RenderGraphSearch} [subSearch]\n */\n\n/**\n * @typedef RenderGraphAction\n * @prop {(state:InitializationState, value:any, changes: any, data:any) => any} invocation\n * @prop {number} [commentIndex]\n * @prop {number} [nodeIndex]\n * @prop {number} [cacheIndex]\n * @prop {string} [attrName]\n * @prop {any} [defaultValue]\n * @prop {RenderGraphSearch} search\n * @prop {InterpolateOptions['injections']} [injections]\n */\n\n/**\n * @type {RenderGraphAction['invocation']}\n * @this {RenderGraphAction}\n */\nfunction writeDOMAttribute({ nodes }, value) {\n const { nodeIndex, attrName } = this;\n const element = /** @type {Element} */ (nodes[nodeIndex]);\n switch (value) {\n case undefined:\n case null:\n case false:\n element.removeAttribute(attrName);\n return false;\n case true:\n element.setAttribute(attrName, '');\n return '';\n default:\n element.setAttribute(attrName, value);\n return value;\n }\n}\n\n/**\n * @type {RenderGraphAction['invocation']}\n * @this {RenderGraphAction}\n */\nfunction writeDynamicNode({ nodeStates, comments, nodes }, value) {\n const { commentIndex, nodeIndex } = this;\n const nodeState = nodeStates[nodeIndex];\n // eslint-disable-next-line no-bitwise\n const hidden = nodeState & 0b0001;\n const show = value != null && value !== false;\n if (!show) {\n // Should be hidden\n if (hidden) return;\n // Replace whatever node is there with the comment\n let comment = comments[commentIndex];\n if (!comment) {\n comment = createEmptyComment();\n comments[commentIndex] = comment;\n }\n nodes[nodeIndex].replaceWith(comment);\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] |= 0b0001;\n return;\n }\n // Must be shown\n // Update node first (offscreen rendering)\n const node = nodes[nodeIndex];\n // eslint-disable-next-line no-bitwise\n const isDynamicNode = nodeState & 0b0010;\n\n if (typeof value === 'object') {\n // Not string data, need to replace\n console.warn('Dynamic nodes not supported yet');\n } else if (isDynamicNode) {\n const textNode = new Text(value);\n node.replaceWith(textNode);\n nodes[nodeIndex] = textNode;\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] &= ~0b0010;\n } else {\n /** @type {Text} */ (node).data = value;\n }\n\n // Updated, now set hidden state\n\n if (hidden) {\n const comment = comments[commentIndex];\n comment.replaceWith(node);\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] &= ~0b0001;\n }\n // Done\n}\n\n/**\n * @type {RenderGraphAction['invocation']}\n * @this {RenderGraphAction}\n */\nfunction writeDOMElementAttachedState({ nodeStates, nodes, comments }, value) {\n const { commentIndex, nodeIndex } = this;\n // eslint-disable-next-line no-bitwise\n const hidden = nodeStates[nodeIndex] & 1;\n const show = value != null && value !== false;\n if (show === !hidden) return;\n\n const element = nodes[nodeIndex];\n let comment = comments[commentIndex];\n if (!comment) {\n comment = createEmptyComment();\n comments[commentIndex] = comment;\n }\n if (show) {\n comment.replaceWith(element);\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] &= ~0b0001;\n } else {\n element.replaceWith(comment);\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] |= 0b0001;\n }\n}\n\n/**\n * @type {RenderGraphAction['invocation']}\n * @this {RenderGraphAction}\n */\nfunction writeDOMHideNodeOnInit({ comments, nodeStates, nodes }) {\n const { commentIndex, nodeIndex } = this;\n\n const comment = createEmptyComment();\n comments[commentIndex] = comment;\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] |= 1;\n\n nodes[nodeIndex].replaceWith(comment);\n}\n\n/**\n * @param {RenderGraphSearch} search\n * @param {Parameters<RenderGraphSearch['invocation']>} args\n */\nfunction executeSearch(search, ...args) {\n const [{ caches, searchStates }] = args;\n const { cacheIndex, searchIndex, subSearch, invocation } = search;\n const cachedValue = caches[cacheIndex];\n const searchState = searchStates[searchIndex];\n\n // Ran = 0b0001\n // Dirty = 0b0010\n // eslint-disable-next-line no-bitwise\n if (searchState & 0b0001) {\n // Return last result\n return {\n value: cachedValue,\n // eslint-disable-next-line no-bitwise\n dirty: ((searchState & 0b0010) === 0b0010),\n };\n }\n\n // eslint-disable-next-line no-bitwise\n searchStates[searchIndex] |= 0b0001;\n let result;\n if (invocation) {\n if (subSearch) {\n const subResult = executeSearch(subSearch, ...args);\n // Use last cached value (if any)\n if (!subResult.dirty && cachedValue !== undefined) {\n // eslint-disable-next-line no-bitwise\n searchStates[searchIndex] &= ~0b0010;\n return { value: cachedValue, dirty: false };\n }\n // Pass from subquery\n result = search.invocation(subResult.value);\n } else {\n result = search.invocation(...args);\n }\n if ((result === undefined) || (cachedValue === result)) {\n // Return from cache\n return { value: result, dirty: false };\n }\n }\n\n // Overwrite cache and flag as dirty\n caches[cacheIndex] = result;\n // eslint-disable-next-line no-bitwise\n searchStates[searchIndex] |= 0b0010;\n return { value: result, dirty: true };\n}\n\n/**\n * @type {RenderGraphSearch['invocation']}\n * @this {RenderGraphSearch}\n */\nfunction searchWithExpression({ options: { context, store, injections } }, changes, data) {\n return this.expression.call(\n context,\n store ?? data,\n injections,\n );\n}\n\n/**\n * @type {RenderGraphSearch['invocation']}\n * @this {RenderGraphSearch}\n */\nfunction searchWithProp(state, changes) {\n return changes[this.prop];\n}\n\n/**\n * @type {RenderGraphSearch['invocation']}\n * @this {RenderGraphSearch}\n */\nfunction searchWithDeepProp(state, changes, data) {\n let scope = changes;\n for (const prop of this.deepProp) {\n if (scope === null) return null;\n if (prop in scope === false) return undefined;\n scope = scope[prop];\n }\n return scope;\n}\n\n/**\n * @typedef InterpolateOptions\n * @prop {Record<string,any>} [defaults] Default values to use for interpolation\n * @prop {{iterable:string} & Record<string,any> & {index:number}} [injections] Context-specific injected properties. (Experimental)\n */\n\n/**\n * @typedef InitializationState\n * @prop {Element} lastElement\n * @prop {ChildNode} lastChildNode\n * @prop {(Element|Text)[]} nodes\n * @prop {any[]} caches\n * @prop {Comment[]} comments\n * @prop {Uint8Array} nodeStates\n * @prop {Uint8Array} searchStates\n * @prop {HTMLElement[]} refs\n * @prop {number} lastChildNodeIndex\n * @prop {RenderOptions<?>} options\n */\n\n/** Splits: `{template}text{template}` as `['', 'template', 'text', 'template', '']` */\nconst STRING_INTERPOLATION_REGEX = /{([^}]*)}/g;\n\n/**\n * Returns event listener bound to shadow root host.\n * Use this function to avoid generating extra closures\n * @this {HTMLElement}\n * @param {Function} fn\n */\nfunction buildShadowRootChildListener(fn) {\n /** @param {Event & {currentTarget:{getRootNode: () => ShadowRoot}}} event */\n return function onShadowRootChildEvent(event) {\n const host = event.currentTarget.getRootNode().host;\n fn.call(host, event);\n };\n}\n\n/**\n * @example\n * propFromObject('foo', {foo:'bar'}) == ['foo', 'bar'];\n * @param {string} prop\n * @param {any} source\n * @return {any}\n */\nfunction propFromObject(prop, source) {\n if (source) {\n return source[prop];\n }\n return undefined;\n}\n\n/**\n * @example\n * deepPropFromObject(\n * ['address', 'home, 'houseNumber'],\n * {\n * address: {\n * home: {\n * houseNumber:35,\n * },\n * }\n * }\n * ) == [houseNumber, 35]\n * @param {string[]} nameArray\n * @param {any} source\n * @return {any}\n */\nfunction deepPropFromObject(nameArray, source) {\n if (!source) return undefined;\n let scope = source;\n let prop;\n for (prop of nameArray) {\n if (typeof scope === 'object') {\n if (scope === null) return null;\n if (!(prop in scope)) return undefined;\n scope = scope[prop];\n } else {\n return scope[prop];\n }\n }\n return scope;\n}\n\n/**\n * @param {string} prop\n * @param {any} source\n * @return {any}\n */\nfunction valueFromPropName(prop, source) {\n let value = source;\n for (const child of prop.split('.')) {\n if (!child) return null;\n // @ts-ignore Skip cast\n value = value[child];\n if (value == null) return null;\n }\n if (value === source) return null;\n return value;\n}\n\nconst compositionCache = new Map();\n\n/** @template T */\nexport default class Composition {\n static EVENT_PREFIX_REGEX = /^([*1~]+)?(.*)$/;\n\n _interpolationState = {\n nodeIndex: -1,\n searchIndex: 0,\n cacheIndex: 0,\n commentIndex: 0,\n /** @type {this['nodesToBind'][0]} */\n nodeEntry: null,\n };\n\n // eslint-disable-next-line symbol-description\n static shadowRootTag = Symbol();\n\n /** @type {{tag:string, textNodes: number[]}[]} */\n nodesToBind = [];\n\n /** @type {string[]} */\n props = [];\n\n /** @type {RenderGraphSearch[]} */\n searches = [];\n\n /** @type {any[]} */\n initCache = [];\n\n /**\n * Index of searches by query (dotted notation for deep props)\n * @type {Map<Function|string, RenderGraphSearch>}\n */\n searchByQuery;\n\n /**\n * Index of searches by query (dotted notation for deep props)\n * @type {Map<string, RenderGraphAction[]>}\n */\n actionsByPropsUsed;\n\n /** @type {RenderGraphAction[]} */\n postInitActions = [];\n\n /** @type {Set<string>} */\n tagsWithBindings;\n\n /**\n * Array of element tags\n * @type {string[]}\n */\n tags = [];\n\n /**\n * Data of arrays used in templates\n * Usage of a [mdw-for] will create an ArrayLike expectation based on key\n * Only store metadata, not actual data. Currently only needs length.\n * TBD if more is needed later\n * Referenced by property key (string)\n * @type {CompositionAdapter<T>}\n */\n adapter;\n\n /**\n * Collection of events to bind.\n * Indexed by ID\n * @type {Map<string|symbol, CompositionEventListener<any>[]>}\n */\n events;\n\n /**\n * Snapshot of composition at initial state.\n * This fragment can be cloned for first rendering, instead of calling\n * of using `render()` to construct the initial DOM tree.\n * @type {DocumentFragment}\n */\n cloneable;\n\n /** @type {(HTMLStyleElement|CSSStyleSheet)[]} */\n styles = [];\n\n /** @type {CSSStyleSheet[]} */\n adoptedStyleSheets = [];\n\n /** @type {DocumentFragment} */\n stylesFragment;\n\n /**\n * List of IDs used by template elements\n * May be needed to be removed when adding to non-DocumentFragment\n * @type {string[]}\n */\n allIds = [];\n\n /**\n * Collection of IDs used for referencing elements\n * Not meant for live DOM. Removed before attaching to document\n */\n /** @type {Set<string>} */\n temporaryIds;\n\n /** Flag set when template and styles have been interpolated */\n interpolated = false;\n\n /**\n * @param {(CompositionPart<T>)[]} parts\n */\n constructor(...parts) {\n /**\n * Template used to build interpolation and cloneable\n */\n this.template = generateFragment();\n this.append(...parts);\n }\n\n * [Symbol.iterator]() {\n for (const part of this.styles) {\n yield part;\n }\n yield this.template;\n }\n\n /**\n * @template T\n * @param {ConstructorParameters<typeof Composition<T>>} parts\n * @return {Composition<T>}\n */\n static compose(...parts) {\n for (const [cache, comp] of compositionCache) {\n if (cache.length !== parts.length) continue;\n if (parts.every((part, index) => part === cache[index])) {\n return comp;\n }\n }\n\n const composition = new Composition(...parts);\n compositionCache.set(parts, composition);\n return composition;\n }\n\n /**\n * @param {CompositionPart<T>[]} parts\n */\n append(...parts) {\n for (const part of parts) {\n if (typeof part === 'string') {\n this.append(generateFragment(part.trim()));\n } else if (part instanceof Composition) {\n this.append(...part);\n } else if (part instanceof DocumentFragment) {\n this.template.append(part);\n } else if (part instanceof CSSStyleSheet || part instanceof HTMLStyleElement) {\n this.styles.push(part);\n }\n }\n // Allow chaining\n return this;\n }\n\n /** @param {CompositionEventListener<T>} listener */\n addCompositionEventListener(listener) {\n const key = listener.tag ?? '';\n // eslint-disable-next-line no-multi-assign\n const events = (this.events ??= new Map());\n if (events.has(key)) {\n events.get(key).push(listener);\n } else {\n events.set(key, [listener]);\n }\n return this;\n }\n\n /**\n * @param {string|symbol} tag\n * @param {EventTarget} target\n * @param {any} [context]\n * @return {void}\n */\n #bindCompositionEventListeners(tag, target, context) {\n if (!this.events?.has(tag)) return;\n for (const event of this.events.get(tag)) {\n let listener;\n if (event.handleEvent) {\n listener = event.handleEvent;\n } else if (event.deepProp.length) {\n listener = deepPropFromObject(event.deepProp, this.interpolateOptions.defaults);\n } else {\n listener = propFromObject(event.prop, this.interpolateOptions.defaults);\n }\n target.addEventListener(event.type, context ? listener.bind(context) : listener, event);\n }\n }\n\n /**\n * TODO: Add types and clean up closure leak\n * Updates component nodes based on data.\n * Expects data in JSON Merge Patch format\n * @see https://www.rfc-editor.org/rfc/rfc7386\n * @template {Object} T\n * @param {Partial<T>} changes what specifically\n * @param {T} [data]\n * @param {RenderOptions<T>} [options]\n * @return {RenderDraw<T>} anchor\n */\n render(changes, data, options = {}) {\n if (!this.interpolated) {\n this.interpolate({\n defaults: data ?? changes,\n ...options,\n });\n }\n\n const instanceFragment = /** @type {DocumentFragment} */ (this.cloneable.cloneNode(true));\n\n const shadowRoot = options.shadowRoot;\n const target = shadowRoot ?? options.target ?? instanceFragment.firstElementChild;\n\n /** @type {InitializationState} */\n const initState = {\n lastChildNode: null,\n lastChildNodeIndex: 0,\n lastElement: null,\n nodeStates: new Uint8Array(this._interpolationState.nodeIndex + 1),\n searchStates: new Uint8Array(this._interpolationState.searchIndex),\n comments: [],\n nodes: [],\n caches: this.initCache.slice(),\n refs: [],\n options,\n };\n\n const { nodes, refs, searchStates, caches } = initState;\n for (const { tag, textNodes } of this.nodesToBind) {\n /** @type {Text} */\n let textNode;\n if (tag === '') {\n if (!textNodes.length) {\n console.warn('why was root tagged?');\n continue;\n }\n console.warn('found empty tag??');\n refs.push(null);\n nodes.push(null);\n textNode = /** @type {Text} */ (instanceFragment.firstChild);\n } else {\n const element = instanceFragment.getElementById(tag);\n refs.push(element);\n nodes.push(element);\n this.#bindCompositionEventListeners(tag, element, options.context);\n if (!textNodes.length) continue;\n textNode = /** @type {Text} */ (element.firstChild);\n }\n\n let currentIndex = 0;\n for (const index of textNodes) {\n while (index !== currentIndex) {\n textNode = /** @type {Text} */ (textNode.nextSibling);\n currentIndex++;\n }\n nodes.push(textNode);\n }\n }\n this.#bindCompositionEventListeners('', options.context);\n this.#bindCompositionEventListeners(Composition.shadowRootTag, options.context.shadowRoot, options.context);\n\n for (const action of this.postInitActions) {\n action.invocation(initState);\n }\n\n /**\n * @param {Partial<T>} changes\n * @param {T} data\n */\n const draw = (changes, data) => {\n let ranSearch = false;\n for (const prop of this.props) {\n if (!this.actionsByPropsUsed?.has(prop)) continue;\n if (!(prop in changes)) continue;\n const actions = this.actionsByPropsUsed.get(prop);\n for (const action of actions) {\n ranSearch = true;\n const { dirty, value } = executeSearch(action.search, initState, changes, data);\n if (dirty) {\n // console.log('dirty, updating from batch', initState.nodes[action.nodeIndex], 'with', value);\n action.invocation(initState, value, changes, data);\n }\n }\n }\n if (!ranSearch) return;\n searchStates.fill(0);\n };\n\n if (shadowRoot) {\n options.context ??= shadowRoot.host;\n if ('adoptedStyleSheets' in shadowRoot) {\n if (this.adoptedStyleSheets.length) {\n shadowRoot.adoptedStyleSheets = [\n ...shadowRoot.adoptedStyleSheets,\n ...this.adoptedStyleSheets,\n ];\n }\n } else if (this.stylesFragment.hasChildNodes()) {\n instanceFragment.prepend(this.stylesFragment.cloneNode(true));\n }\n } else {\n options.context ??= target;\n }\n\n if (changes !== this.interpolateOptions.defaults) {\n // Not default, overwrite nodes\n draw(changes, data);\n }\n\n if (shadowRoot) {\n shadowRoot.append(instanceFragment);\n customElements.upgrade(shadowRoot);\n }\n\n draw.target = target;\n\n /**\n * @param {keyof T & string} prop\n * @param {any} value\n * @param {Partial<T>} [data]\n */\n draw.byProp = (prop, value, data) => {\n if (!this.actionsByPropsUsed?.has(prop)) return;\n let ranSearch = false;\n\n // Update search\n if (this.searchByQuery?.has(prop)) {\n ranSearch = true;\n const search = this.searchByQuery.get(prop);\n const cachedValue = caches[search.cacheIndex];\n if (cachedValue === value) {\n return;\n }\n caches[search.cacheIndex] = value;\n searchStates[search.searchIndex] = 0b0011;\n }\n\n /** @type {Partial<T>} */\n let changes;\n const actions = this.actionsByPropsUsed.get(prop);\n for (const action of actions) {\n if (action.search.query === prop) {\n action.invocation(initState, value);\n } else {\n // @ts-expect-error Skip cast\n changes ??= { [prop]: value };\n data ??= changes;\n ranSearch = true;\n const result = executeSearch(action.search, initState, changes, data);\n if (result.dirty) {\n // console.debug('dirty, updating by prop', prop, initState.nodes[action.nodeIndex], 'with', result.value);\n action.invocation(initState, result.value, changes, data);\n }\n }\n }\n\n if (!ranSearch) return;\n searchStates.fill(0);\n };\n draw.state = initState;\n return draw;\n }\n\n /**\n * @param {Attr|Text} node\n * @param {Element|null} [element]\n * @param {InterpolateOptions} [options]\n * @param {string} [parsedValue]\n * @return {true|undefined} remove node\n */\n #interpolateNode(node, element, options, parsedValue) {\n const { nodeValue, nodeName, nodeType } = node;\n\n /** @type {Attr} */\n let attr;\n /** @type {Text} */\n let text;\n if (nodeType === Node.ATTRIBUTE_NODE) {\n attr = /** @type {Attr} */ (node);\n } else {\n text = /** @type {Text} */ (node);\n }\n\n // Get template strings(s) in node if not passed\n if (parsedValue == null) {\n if (!nodeValue) return;\n const trimmed = nodeValue.trim();\n if (!trimmed) return;\n if (attr || element?.tagName === 'STYLE') {\n if (trimmed[0] !== '{') return;\n const { length } = trimmed;\n if (trimmed[length - 1] !== '}') return;\n parsedValue = trimmed.slice(1, -1);\n // TODO: Support segmented attribute values\n } else {\n // Split text node into segments\n // TODO: Benchmark indexOf pre-check vs regex\n\n const segments = trimmed.split(STRING_INTERPOLATION_REGEX);\n if (segments.length < 3) return;\n if (segments.length === 3 && !segments[0] && !segments[2]) {\n parsedValue = segments[1];\n } else {\n for (const [index, segment] of segments.entries()) {\n // is even = is template string\n if (index % 2) {\n const newNode = createEmptyTextNode();\n text.before(newNode);\n this.#interpolateNode(newNode, element, options, segment);\n } else if (segment) {\n text.before(segment);\n }\n }\n // eslint-disable-next-line consistent-return\n return true;\n }\n }\n }\n\n // Check mutations\n\n const query = parsedValue;\n const negate = parsedValue[0] === '!';\n let doubleNegate = false;\n if (negate) {\n parsedValue = parsedValue.slice(1);\n doubleNegate = parsedValue[0] === '!';\n if (doubleNegate) {\n parsedValue = parsedValue.slice(1);\n }\n }\n\n let isEvent;\n let textNodeIndex;\n\n if (text) {\n // eslint-disable-next-line unicorn/consistent-destructuring\n if (element !== text.parentElement) {\n console.warn('mismatch?');\n element = text.parentElement;\n }\n textNodeIndex = 0;\n /** @type {ChildNode} */\n let prev = text;\n while ((prev = prev.previousSibling)) {\n textNodeIndex++;\n }\n } else {\n // @ts-ignore Skip cast\n // eslint-disable-next-line unicorn/consistent-destructuring\n if (element !== attr.ownerElement) {\n console.warn('mismatch?');\n element = attr.ownerElement;\n }\n if (nodeName.startsWith('on')) {\n // Do not interpolate inline event listeners\n const hyphenIndex = nodeName.indexOf('-');\n if (hyphenIndex === -1) return;\n isEvent = hyphenIndex === 2;\n }\n }\n\n if (isEvent) {\n element.removeAttribute(nodeName);\n const tag = this.#tagElement(element);\n const eventType = nodeName.slice(3);\n const [, flags, type] = eventType.match(/^([*1~]+)?(.*)$/);\n\n let handleEvent;\n /** @type {string} */\n let prop;\n /** @type {string[]} */\n let deepProp = [];\n if (parsedValue.startsWith('#')) {\n handleEvent = inlineFunctions.get(parsedValue).fn;\n } else {\n const parsedProps = parsedValue.split('.');\n if (parsedProps.length === 1) {\n prop = parsedValue;\n deepProp = [];\n } else {\n prop = parsedProps[0];\n deepProp = parsedProps;\n }\n }\n\n this.addCompositionEventListener({\n tag,\n type,\n handleEvent,\n prop,\n deepProp,\n once: flags?.includes('1'),\n passive: flags?.includes('~'),\n capture: flags?.includes('*'),\n });\n\n return;\n }\n\n /** @type {RenderGraphSearch} */\n let search;\n\n if (this.searchByQuery?.has(query)) {\n search = this.searchByQuery.get(query);\n } else {\n // Has subquery?\n const subquery = parsedValue;\n const isSubquery = subquery !== query;\n /** @type {RenderGraphSearch} */\n let subSearch;\n if (isSubquery && this.searchByQuery?.has(subquery)) {\n subSearch = this.searchByQuery.get(subquery);\n } else {\n // Construct subsearch, even is not subquery.\n /** @type {Function} */\n let expression;\n /** @type {string[]} */\n let propsUsed;\n /** @type {string[][]} */\n let deepPropsUsed;\n let defaultValue;\n let prop;\n let deepProp;\n let invocation;\n\n let inlineFunctionOptions;\n // Is Inline Function?\n if (parsedValue.startsWith('#')) {\n inlineFunctionOptions = inlineFunctions.get(parsedValue);\n if (!inlineFunctionOptions) {\n console.warn(`Invalid interpolation value: ${parsedValue}`);\n return;\n }\n expression = inlineFunctionOptions.fn;\n invocation = searchWithExpression;\n if (inlineFunctionOptions.props) {\n // console.log('This function has already been called. Reuse props', inlineFunctionOptions, this);\n propsUsed = inlineFunctionOptions.props;\n deepPropsUsed = inlineFunctionOptions.deepProps;\n defaultValue = inlineFunctionOptions.defaultValue ?? null;\n } else {\n defaultValue = inlineFunctionOptions.fn;\n }\n } else {\n defaultValue = null;\n if (options?.defaults) {\n defaultValue = deepPropFromObject(parsedValue.split('.'), options.defaults) ?? null;\n }\n if (defaultValue == null && options?.injections) {\n defaultValue = valueFromPropName(parsedValue, options.injections);\n // console.log('default value from injection', parsedValue, { defaultValue });\n }\n }\n\n if (!propsUsed) {\n if (typeof defaultValue === 'function') {\n // Value must be reinterpolated and function observed\n const observeResult = observeFunction.call(this, defaultValue, options?.defaults, options?.injections);\n const uniqueProps = new Set([\n ...observeResult.props.this,\n ...observeResult.props.args[0],\n ...observeResult.props.args[1],\n ]);\n const uniqueDeepProps = new Set([\n ...observeResult.deepPropStrings.this,\n ...observeResult.deepPropStrings.args[0],\n ]);\n expression = defaultValue;\n defaultValue = observeResult.defaultValue;\n propsUsed = [...uniqueProps];\n deepPropsUsed = [...uniqueDeepProps].map((deepPropString) => deepPropString.split('.'));\n invocation = searchWithExpression;\n // console.log(this.static.name, fn.name || parsedValue, combinedSet);\n } else {\n // property binding\n const parsedProps = parsedValue.split('.');\n if (parsedProps.length === 1) {\n prop = parsedValue;\n propsUsed = [prop];\n invocation = searchWithProp;\n } else {\n propsUsed = [parsedProps[0]];\n deepProp = parsedProps;\n deepPropsUsed = [parsedProps];\n invocation = searchWithDeepProp;\n }\n\n // TODO: Rewrite property as deep with array index?\n }\n }\n\n if (inlineFunctionOptions) {\n inlineFunctionOptions.defaultValue = defaultValue;\n inlineFunctionOptions.props = propsUsed;\n inlineFunctionOptions.deepProps = deepPropsUsed;\n }\n subSearch = {\n cacheIndex: this._interpolationState.cacheIndex++,\n searchIndex: this._interpolationState.searchIndex++,\n query: subquery,\n defaultValue,\n subSearch: null,\n prop,\n propsUsed,\n deepProp,\n deepPropsUsed,\n invocation,\n expression,\n };\n this.addSearch(subSearch);\n }\n if (isSubquery) {\n search = {\n cacheIndex: this._interpolationState.cacheIndex++,\n searchIndex: this._interpolationState.searchIndex++,\n query,\n subSearch,\n negate,\n doubleNegate,\n prop: subSearch.prop,\n deepProp: subSearch.deepProp,\n propsUsed: subSearch.propsUsed,\n deepPropsUsed: subSearch.deepPropsUsed,\n defaultValue: doubleNegate ? !!subSearch.defaultValue\n : (negate ? !subSearch.defaultValue : subSearch.defaultValue),\n invocation(value) {\n if (this.doubleNegate) return !!value;\n if (this.negate) return !value;\n console.warn('Unknown query mutation', this.query);\n return value;\n },\n };\n this.addSearch(search);\n } else {\n // Store as search instead\n search = subSearch;\n }\n }\n\n // Tag\n let tag;\n let subnode = null;\n let defaultValue = search.defaultValue;\n if (text) {\n subnode = textNodeIndex;\n } else if (nodeName === 'mdw-if') {\n tag = this.#tagElement(element);\n element.removeAttribute(nodeName);\n defaultValue = defaultValue != null && defaultValue !== false;\n } else {\n subnode = nodeName;\n if (nodeName === 'id' || defaultValue == null || defaultValue === false) {\n element.removeAttribute(nodeName);\n } else {\n element.setAttribute(nodeName, defaultValue === true ? '' : defaultValue);\n }\n }\n\n tag ??= this.#tagElement(element);\n\n // Node entry\n let nodeEntry = this._interpolationState.nodeEntry;\n if (!nodeEntry || nodeEntry.tag !== tag) {\n nodeEntry = {\n tag,\n textNodes: [],\n };\n this._interpolationState.nodeEntry = nodeEntry;\n this.nodesToBind.push(nodeEntry);\n this._interpolationState.nodeIndex++;\n }\n\n /** @type {RenderGraphAction} */\n let action;\n\n // Node Action\n if (text) {\n nodeEntry.textNodes.push(textNodeIndex);\n\n this._interpolationState.nodeIndex++;\n action = {\n nodeIndex: this._interpolationState.nodeIndex,\n commentIndex: this._interpolationState.commentIndex++,\n invocation: writeDynamicNode,\n defaultValue,\n search,\n };\n switch (typeof defaultValue) {\n case 'string':\n text.data = defaultValue;\n break;\n case 'number':\n // Manually coerce to string (0 will be empty otherwise)\n text.data = `${defaultValue}`;\n break;\n default:\n text.data = '';\n break;\n }\n } else if (subnode) {\n action = {\n nodeIndex: this._interpolationState.nodeIndex,\n attrName: /** @type {string} */ (subnode),\n defaultValue,\n invocation: writeDOMAttribute,\n search,\n };\n } else {\n action = {\n nodeIndex: this._interpolationState.nodeIndex,\n commentIndex: this._interpolationState.commentIndex++,\n defaultValue,\n invocation: writeDOMElementAttachedState,\n search,\n };\n if (!defaultValue) {\n this.postInitActions.push({\n ...action,\n invocation: writeDOMHideNodeOnInit,\n });\n }\n }\n\n this.addAction(action);\n // eslint-disable-next-line no-multi-assign\n const tagsWithBindings = (this.tagsWithBindings ??= new Set());\n tagsWithBindings.add(tag);\n }\n\n /**\n * @param {Element} element\n * @return {string}\n */\n #tagElement(element) {\n if (!element) return '';\n let id = element.id;\n if (id) {\n if (!this.allIds.includes(id)) {\n this.allIds.push(id);\n }\n } else {\n id = generateUID();\n // eslint-disable-next-line no-multi-assign\n const temporaryIds = (this.temporaryIds ??= new Set());\n temporaryIds.add(id);\n this.allIds.push(id);\n element.id = id;\n }\n return id;\n }\n\n /**\n * TODO: Subtemplating lacks optimization, though functional.\n * - Would benefit from custom type handler for arrays\n * to avoid multi-iteration change-detection.\n * - Could benefit from debounced/throttled render\n * - Consider remap of {item.prop} as {array[index].prop}\n * @param {Element} element\n * @param {InterpolateOptions} options\n * @return {?Composition<?>}\n */\n #interpolateIterable(element, options) {\n // TODO: Microbenchmark element.attributes\n const forAttr = element.getAttribute('mdw-for');\n const trimmed = forAttr?.trim();\n if (!trimmed) {\n console.warn('Malformed mdw-for found at', element);\n return null;\n }\n\n if (trimmed[0] !== '{') {\n console.warn('Malformed mdw-for found at', element);\n return null;\n }\n const { length } = trimmed;\n if (trimmed[length - 1] !== '}') {\n console.warn('Malformed mdw-for found at', element);\n return null;\n }\n const parsedValue = trimmed.slice(1, -1);\n const [valueName, iterableName] = parsedValue.split(/\\s+of\\s+/);\n element.removeAttribute('mdw-for');\n // Create a new composition targetting element as root\n\n const elementAnchor = element.ownerDocument.createElement('template');\n element.replaceWith(elementAnchor);\n const tag = this.#tagElement(elementAnchor);\n // console.log('tagging placeholder element with', elementAnchor, tag);\n\n let nodeEntry = this._interpolationState.nodeEntry;\n if (!nodeEntry || nodeEntry.tag !== tag) {\n nodeEntry = {\n tag,\n textNodes: [],\n };\n this._interpolationState.nodeEntry = nodeEntry;\n this.nodesToBind.push(nodeEntry);\n this._interpolationState.nodeIndex++;\n }\n\n const newComposition = new Composition();\n newComposition.template.append(element);\n // Move uninterpolated element to new composition template.\n /** @type {InterpolateOptions['injections']} */\n const injections = {\n ...options.injections,\n [valueName]: null,\n index: null,\n };\n\n const propsUsed = [iterableName];\n /** @type {RenderGraphSearch} */\n const search = {\n cacheIndex: this._interpolationState.cacheIndex++,\n searchIndex: this._interpolationState.searchIndex++,\n query: null,\n prop: null,\n deepProp: null,\n propsUsed,\n deepPropsUsed: [[iterableName]],\n defaultValue: {},\n invocation: null,\n };\n\n /** @type {RenderGraphAction} */\n const action = {\n defaultValue: null,\n nodeIndex: this._interpolationState.nodeIndex,\n search,\n commentIndex: this._interpolationState.commentIndex++,\n injections,\n invocation(state, value, changes, data) {\n if (!newComposition.adapter) {\n // console.log({ state.options });\n const instanceAnchorElement = state.nodes[this.nodeIndex];\n const anchorNode = createEmptyComment();\n // Avoid leak\n state.comments[this.commentIndex] = anchorNode;\n instanceAnchorElement.replaceWith(anchorNode);\n newComposition.adapter = new CompositionAdapter({\n anchorNode,\n composition: newComposition,\n renderOptions: {\n target: null,\n context: state.options.context,\n store: state.options.store,\n injections: this.injections,\n },\n });\n }\n const { adapter } = newComposition;\n const iterable = (data ?? state.options.store)[iterableName];\n // Remove oversized\n if (!iterable || iterable.length === 0) {\n adapter.removeEntries();\n return;\n }\n const changeList = changes[iterableName];\n const innerChanges = { ...changes };\n const needTargetAll = newComposition.props.some((prop) => prop !== iterableName && prop in changes);\n\n adapter.startBatch();\n let isArray;\n if (!needTargetAll && !(isArray = Array.isArray(changeList))) {\n const iterator = isArray ? changeList.entries() : Object.entries(changeList);\n // console.log('changeList render', iterator);\n for (const [key, change] of iterator) {\n if (key === 'length') continue;\n if (change === null) {\n // console.warn('null?', 'remove?', key);\n continue;\n }\n const index = (+key);\n const resource = iterable[index];\n innerChanges[valueName] = change;\n this.injections[valueName] = resource;\n this.injections.index = index;\n\n adapter.renderData(index, innerChanges, data, resource, change);\n }\n } else {\n if (!changeList) {\n delete innerChanges[valueName];\n }\n // console.log('full array render', iterable);\n for (const [index, resource] of iterable.entries()) {\n let change;\n if (changeList) {\n // console.warn('full array render has changeList?', changeList);\n if (!needTargetAll && !(index in changeList)) {\n console.warn('huh?');\n continue;\n }\n change = changeList[index];\n if (change === null) {\n // console.warn('remove?');\n continue;\n }\n innerChanges[valueName] = change;\n }\n this.injections[valueName] = resource;\n this.injections.index = index;\n\n adapter.renderData(index, innerChanges, data, resource, change);\n // adapter.renderIndex(index, innerChanges, data, resource);\n }\n }\n adapter.stopBatch();\n\n adapter.removeEntries(iterable.length);\n },\n\n };\n\n newComposition.interpolate({\n defaults: options.defaults,\n injections,\n });\n\n propsUsed.push(...newComposition.props);\n this.addSearch(search);\n this.addAction(action);\n // eslint-disable-next-line no-multi-assign\n const tagsWithBindings = (this.tagsWithBindings ??= new Set());\n tagsWithBindings.add(tag);\n // console.log('adding', iterable, 'bind to', this);\n // this.addBinding(iterable, entry);\n return newComposition;\n }\n\n /**\n * @param {InterpolateOptions} [options]\n */\n interpolate(options) {\n this.interpolateOptions = options;\n // console.log('Template', [...this.template.children].map((child) => child.outerHTML).join('\\n'));\n\n // Copy template before working on it\n // Store into `cloneable` to split later into `interpolation`\n this.cloneable = /** @type {DocumentFragment} */ (this.template.cloneNode(true));\n\n const TREE_WALKER_FILTER = 5; /* NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT */\n\n const treeWalker = document.createTreeWalker(this.cloneable, TREE_WALKER_FILTER);\n /** Note: `node` and treeWalker.currentNode may deviate */\n let node = treeWalker.nextNode();\n while (node) {\n /** @type {Element} */\n let element = null;\n switch (node.nodeType) {\n case Node.ELEMENT_NODE:\n element = /** @type {Element} */ (node);\n if (element.tagName === 'TEMPLATE') {\n while (element.contains(node = treeWalker.nextNode()));\n continue;\n }\n\n if (element.tagName === 'SCRIPT') {\n console.warn('<script> element found.');\n while (element.contains(node = treeWalker.nextNode()));\n continue;\n }\n\n if (element.hasAttribute('mdw-for')) {\n while (element.contains(node = treeWalker.nextNode()));\n this.#interpolateIterable(element, options);\n continue;\n } else {\n // @ts-expect-error Bad typings\n const idAttr = element.attributes.id;\n if (idAttr) {\n this.#interpolateNode(idAttr, element, options);\n this.#tagElement(element);\n }\n for (const attr of [...element.attributes].reverse()) {\n if (attr.nodeName === 'id') continue; // Already handled\n this.#interpolateNode(attr, element, options);\n }\n }\n\n break;\n case Node.TEXT_NODE:\n element = node.parentElement;\n if (this.#interpolateNode(/** @type {Text} */ (node), element, options)) {\n const nextNode = treeWalker.nextNode();\n /** @type {Text} */ (node).remove();\n node = nextNode;\n continue;\n }\n break;\n default:\n throw new Error(`Unexpected node type: ${node.nodeType}`);\n }\n node = treeWalker.nextNode();\n }\n\n if ('adoptedStyleSheets' in document) {\n this.adoptedStyleSheets = [\n ...generateCSSStyleSheets(this.styles),\n ];\n } else {\n this.stylesFragment = generateFragment();\n this.stylesFragment.append(\n ...generateHTMLStyleElements(this.styles),\n );\n }\n\n this.props = this.actionsByPropsUsed\n ? [...this.actionsByPropsUsed.keys()]\n : [];\n\n for (const id of this.allIds) {\n if (!this.tagsWithBindings?.has(id)) {\n this.nodesToBind.push({\n tag: id,\n textNodes: [],\n });\n }\n }\n\n this.tags = this.nodesToBind.map((n) => n.tag);\n this.interpolated = true;\n\n // console.log('Cloneable', [...this.cloneable.children].map((child) => child.outerHTML).join('\\n'));\n }\n\n /**\n * @param {RenderGraphSearch} search\n * @return {RenderGraphSearch}\n */\n addSearch(search) {\n this.searches.push(search);\n if (search.query) {\n // eslint-disable-next-line no-multi-assign\n const searchByQuery = (this.searchByQuery ??= new Map());\n searchByQuery.set(search.query, search);\n this.initCache[search.cacheIndex] = search.defaultValue;\n }\n return search;\n }\n\n /**\n * @param {RenderGraphAction} action\n * @return {RenderGraphAction}\n */\n addAction(action) {\n // eslint-disable-next-line no-multi-assign\n const actionsByPropsUsed = (this.actionsByPropsUsed ??= new Map());\n for (const prop of action.search.propsUsed) {\n if (actionsByPropsUsed.has(prop)) {\n actionsByPropsUsed.get(prop).push(action);\n } else {\n actionsByPropsUsed.set(prop, [action]);\n }\n }\n return action;\n }\n}\n", "/* eslint-disable max-classes-per-file */\n\nimport Composition from './Composition.js';\nimport { css } from './css.js';\nimport { attrNameFromPropName, attrValueFromDataValue } from './dom.js';\nimport { applyMergePatch } from './jsonMergePatch.js';\nimport { defineObservableProperty } from './observe.js';\nimport { addInlineFunction, html } from './template.js';\n\n/** @typedef {import('./observe.js').ObserverPropertyType} ObserverPropertyType */\n\n/**\n * @template {any} T\n * @typedef {{\n * [P in keyof T]:\n * T[P] extends (...args:any[]) => infer T2 ? T2\n * : T[P] extends ObserverPropertyType\n * ? import('./observe.js').ParsedObserverPropertyType<T[P]>\n * : T[P] extends {type: ObserverPropertyType}\n * ? import('./observe.js').ParsedObserverPropertyType<T[P]['type']>\n * : T[P] extends ObserverOptions<null, infer T2>\n * ? unknown extends T2 ? string : T2\n * : never\n * }} ParsedProps\n */\n\n/**\n * @template {ObserverPropertyType} T1\n * @template {any} T2\n * @template {Object} [C=any]\n * @typedef {import('./observe.js').ObserverOptions<T1,T2,C>} ObserverOptions\n */\n\n/**\n * @template {{ prototype: unknown; }} T\n * @typedef {T} ClassOf<T>\n */\n\n/**\n * @template {any} [T=any]\n * @template {any[]} [A=any[]]\n * @typedef {abstract new (...args: A) => T} Class\n */\n\n/**\n * @template {any} T1\n * @template {any} [T2=T1]\n * @callback HTMLTemplater\n * @param {TemplateStringsArray} string\n * @param {...(string|DocumentFragment|Element|((this:T1, data:T2) => any))} substitutions\n * @return {DocumentFragment}\n */\n\n/**\n * @template {any} [T1=any]\n * @template {any} [T2=T1]\n * @typedef {Object} CallbackArguments\n * @prop {Composition<T1>} composition\n * @prop {Record<string, HTMLElement>} refs\n * @prop {HTMLTemplater<T1, Partial<T2>>} html\n * @prop {(fn: (this:T1, data: T2) => any) => string} inline\n * @prop {DocumentFragment} template\n * @prop {T1} element\n */\n\n/**\n * @template {any} T1\n * @template {any} [T2=T1]\n * @typedef {{\n * composed?: (this: T1, options: CallbackArguments<T1, T2>) => any,\n * constructed?: (this: T1, options: CallbackArguments<T1, T2>) => any,\n * connected?: (this: T1, options: CallbackArguments<T1, T2>) => any,\n * disconnected?: (this: T1, options: CallbackArguments<T1, T2>) => any,\n * props?: {\n * [P in keyof T1] : (\n * this: T1,\n * oldValue: T1[P],\n * newValue: T1[P],\n * changes:any,\n * element: T1\n * ) => any\n * },\n * attrs?: {[K in keyof any]: (\n * this: T1,\n * oldValue: string,\n * newValue: string,\n * element: T1\n * ) => unknown\n * },\n * } & {\n * [P in keyof T1 & string as `${P}Changed`]?: (\n * this: T1,\n * oldValue: T1[P],\n * newValue: T1[P],\n * changes:any,\n * element: T1\n * ) => any\n * }} CompositionCallback\n */\n\n/**\n * @template {Object} C\n * @typedef {{\n * [P in string] :\n * ObserverPropertyType\n * | ObserverOptions<ObserverPropertyType, unknown, C>\n * | ((this:C, data:Partial<C>, fn?: () => any) => any)\n * }} IDLParameter\n */\n\n/**\n * @template T\n * @typedef {(T | Array<[keyof T & string, T[keyof T]]>)} ObjectOrObjectEntries\n */\n\n/**\n * @template {abstract new (...args: any) => unknown} T\n * @param {InstanceType<T>} instance\n */\nfunction superOf(instance) {\n const staticContext = instance.constructor;\n const superOfStatic = Object.getPrototypeOf(staticContext);\n return superOfStatic.prototype;\n}\n\n/**\n * Clone attribute\n * @param {string} name\n * @param {string} target\n * @return {(oldValue:string, newValue:string, element: CustomElement) => void}\n */\nexport function cloneAttributeCallback(name, target) {\n return (oldValue, newValue, element) => {\n if (newValue == null) {\n element.refs[target].removeAttribute(name);\n } else {\n element.refs[target].setAttribute(name, newValue);\n }\n };\n}\n\n/**\n * Web Component that can cache templates for minification or performance\n */\nexport default class CustomElement extends HTMLElement {\n /** @type {string} */\n static elementName;\n\n /** @return {Iterable<string>} */\n static get observedAttributes() {\n return this.attrList.keys();\n }\n\n /** @type {import('./Composition.js').Compositor<?>} */\n compose() {\n // eslint-disable-next-line no-return-assign\n return (this.#composition ??= new Composition());\n }\n\n /** @type {Composition<?>} */\n static _composition = null;\n\n /** @type {Map<string, import('./observe.js').ObserverConfiguration<?,?,?>>} */\n static _props = new Map();\n\n /** @type {Map<string, import('./observe.js').ObserverConfiguration<?,?,?>>} */\n static _attrs = new Map();\n\n /** @type {Map<string, Array<(this: any, ...args: any[]) => any>>} */\n static _propChangedCallbacks = new Map();\n\n /** @type {Map<string, Array<(this: any, ...args: any[]) => any>>} */\n static _attributeChangedCallbacks = new Map();\n\n /** @type {Array<(callback: CallbackArguments) => any>} */\n static _onComposeCallbacks = [];\n\n /** @type {Array<(callback: CallbackArguments) => any>} */\n static _onConnectedCallbacks = [];\n\n /** @type {Array<(callback: CallbackArguments) => any>} */\n static _onDisconnectedCallbacks = [];\n\n /** @type {Array<(callback: CallbackArguments) => any>} */\n static _onConstructedCallbacks = [];\n\n static interpolatesTemplate = true;\n\n static supportsElementInternals = 'attachInternals' in HTMLElement.prototype;\n\n static supportsElementInternalsRole = CustomElement.supportsElementInternals\n && 'role' in ElementInternals.prototype;\n\n /** @type {boolean} */\n static templatable = null;\n\n static defined = false;\n\n static autoRegistration = true;\n\n /** @type {Map<string, typeof CustomElement>} */\n static registrations = new Map();\n\n /**\n * Expressions are idempotent functions that are selectively called whenever\n * a render is requested.\n * Expressions are constructed exactly as methods though differ in expected\n * arguments. The first argument should be destructured to ensure each used\n * property is accessed at least once in order to inspect used properties.\n *\n * The Composition API will inspect this function with a proxy for `this` to\n * catalog what observables are used by the expression. This allows the\n * Composition API to build a cache as well as selective invoke the expression\n * only when needed.\n *\n * When used with in element templates, the element itself will be passed as\n * its first argument.\n * ````js\n * Button\n * .prop('filled', 'boolean')\n * .prop('outlined', 'boolean')\n * .expresssions({\n * _isFilledOrOutlined({filled, outlined}) {\n * return (filled || outlined)\n * },\n * })\n * .html`<div custom={_isFilledOrOutlined}></div>`;\n * ````\n *\n * When used with external data source, that data source\n * will be passed to the expression with all properties being `null` at first\n * inspection.\n * ````js\n * const externalData = {first: 'John', last: 'Doe'};\n * ContactCard\n * .expresssions({\n * _fullName({first, last}) {\n * return [first, last].filter(Boolean).join(' ');\n * },\n * })\n * myButton.render(externalData);\n * ````\n *\n * Expressions may be support argumentless calls by using default\n * parameters with `this`.\n * ````js\n * Button\n * .expresssions({\n * isFilledOrOutlined({filled, outlined} = this) {\n * return (filled || outlined)\n * },\n * });\n * myButton.isFilledorOutlined();\n * ````\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends {\n * [K in keyof any]: K extends `_${any}` ? ((data: INSTANCE, state?: Record<string, any>) => string|boolean|null)\n * : ((data?: INSTANCE, state?: Record<string, any>) => string|boolean|null)\n * } & ThisType<INSTANCE>\n * >(this: CLASS, expressions: PROPS & ThisType<INSTANCE & PROPS>):\n * CLASS & Class<{\n * [K in keyof PROPS]: K extends `_${any}` ? never : () => ReturnType<PROPS[K]> }\n * ,ARGS>\n * }}\n */\n static expressions = /** @type {any} */ (this.set);\n\n static methods = this.set;\n\n /**\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends Partial<INSTANCE>>\n * (this: CLASS, source: PROPS & ThisType<PROPS & INSTANCE>, options?: Partial<PropertyDescriptor>)\n * : CLASS & Class<PROPS,ARGS>\n * }}\n */\n static overrides = /** @type {any} */ (this.set);\n\n /**\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * KEY extends string,\n * OPTIONS extends ObserverPropertyType\n * | ObserverOptions<ObserverPropertyType, unknown, INSTANCE>\n * | ((this:INSTANCE, data:Partial<INSTANCE>, fn?: () => any) => any),\n * VALUE extends Record<KEY, OPTIONS extends (...args2:any[]) => infer R ? R\n * : OPTIONS extends ObserverPropertyType ? import('./observe.js').ParsedObserverPropertyType<OPTIONS>\n * : OPTIONS extends {type: 'object'} & ObserverOptions<any, infer R> ? (unknown extends R ? object : R)\n * : OPTIONS extends {type: ObserverPropertyType} ? import('./observe.js').ParsedObserverPropertyType<OPTIONS['type']>\n * : OPTIONS extends ObserverOptions<any, infer R> ? (unknown extends R ? string : R)\n * : never\n * >\n * > (this: CLASS, name: KEY, options: OPTIONS)\n * : CLASS & Class<VALUE,ARGS>;\n * }}\n */\n static props = /** @type {any} */ (this.observe);\n\n static idl = this.prop;\n\n /**\n * @this T\n * @template {typeof CustomElement} T\n * @template {keyof T} K\n * @param {K} collection\n * @param {Function} callback\n */\n static _addCallback(collection, callback) {\n if (!this.hasOwnProperty(collection)) {\n // @ts-expect-error not typed\n this[collection] = [...this[collection], callback];\n return;\n }\n // @ts-expect-error any\n this[collection].push(callback);\n }\n\n /**\n * Append parts to composition\n * @type {{\n * <\n * T extends typeof CustomElement,\n * >\n * (this: T, ...parts: ConstructorParameters<typeof Composition<InstanceType<T>>>): T;\n * }}\n */\n static append(...parts) {\n this._onComposeCallbacks.push(({ composition }) => {\n composition.append(...parts);\n });\n\n this._addCallback('_onComposeCallbacks', /** @type {(opts: CallbackArguments) => unknown} */ ((opts) => {\n const { composition } = opts;\n composition.append(...parts);\n }));\n return this;\n }\n\n /**\n * After composition, invokes callback.\n * May be called multiple times.\n * @type {{\n * <\n * T1 extends (typeof CustomElement),\n * T2 extends InstanceType<T1>,\n * T3 extends CompositionCallback<T2, T2>['composed'],\n * >\n * (this: T1, callback: T3): T1\n * }}\n */\n static recompose(callback) {\n this._addCallback('_onComposeCallbacks', callback);\n return this;\n }\n\n /**\n * Appends styles to composition\n * @type {{\n * <\n * T1 extends (typeof CustomElement),\n * T2 extends TemplateStringsArray|HTMLStyleElement|CSSStyleSheet|string>(\n * this: T1,\n * array: T2,\n * ...rest: T2 extends string ? any : T2 extends TemplateStringsArray ? any[] : (HTMLStyleElement|CSSStyleSheet)[]\n * ): T1\n * }}\n */\n static css(array, ...substitutions) {\n this._addCallback('_onComposeCallbacks', /** @type {(opts: CallbackArguments) => unknown} */ ((opts) => {\n const { composition } = opts;\n if (typeof array === 'string' || Array.isArray(array)) {\n // @ts-expect-error Complex cast\n composition.append(css(array, ...substitutions));\n } else {\n // @ts-expect-error Complex cast\n composition.append(array, ...substitutions);\n }\n }));\n\n return this;\n }\n\n /**\n * Registers class with customElements. If class is registered before then,\n * does nothing.\n * @type {{\n * <T extends typeof CustomElement>(this: T, elementName: string): T;\n * }}\n */\n static autoRegister(elementName) {\n if (this.hasOwnProperty('defined') && this.defined) {\n console.warn(this.elementName, 'already registered.');\n return this;\n }\n this.register(elementName);\n return this;\n }\n\n /**\n * Appends DocumentFragment to composition\n * @type {{\n * <T extends typeof CustomElement>(\n * this: T,\n * string: TemplateStringsArray,\n * ...substitutions: (string|Element|((this:InstanceType<T>, data:InstanceType<T>, injections?:any) => any))[]\n * ): T\n * }}\n */\n static html(strings, ...substitutions) {\n this._addCallback('_onComposeCallbacks', /** @type {(opts: CallbackArguments) => unknown} */ ((opts) => {\n const { composition } = opts;\n // console.log('onComposed:html', strings);\n composition.append(html(strings, ...substitutions));\n }));\n return this;\n }\n\n /**\n * Extends base class into a new class.\n * Use to avoid mutating base class.\n * @type {{\n * <T1 extends typeof CustomElement, T2 extends T1, T3 extends (Base:T1) => T2>\n * (this: T1,customExtender?: T3|null): T3 extends null ? T1 : T2;\n * }}\n */\n static extend(customExtender) {\n // @ts-expect-error Can't cast T\n return customExtender ? customExtender(this) : class extends this {};\n }\n\n /**\n * Assigns static values to class\n * @type {{\n * <\n * T1 extends typeof CustomElement,\n * T2 extends {\n * [K in keyof any]: (\n * ((this:T1, ...args:any[]) => any)\n * |string|number|boolean|any[]|object)}\n * >\n * (this: T1, source: T2 & ThisType<T1 & T2>):T1 & T2;\n * }}\n */\n static setStatic(source) {\n Object.assign(this, source);\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * Assigns values directly to all instances (via prototype)\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends object>\n * (this: CLASS, source: PROPS & ThisType<PROPS & INSTANCE>, options?: Partial<PropertyDescriptor>)\n * : CLASS & Class<PROPS,ARGS>\n * }}\n */\n static readonly(source, options) {\n return this.set(source, { ...options, writable: false });\n }\n\n /**\n * Assigns values directly to all instances (via prototype)\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends object>\n * (this: CLASS, source: PROPS & ThisType<PROPS & INSTANCE>, options?: Partial<PropertyDescriptor>)\n * : CLASS & Class<PROPS,ARGS>\n * }}\n */\n static set(source, options) {\n Object.defineProperties(\n this.prototype,\n Object.fromEntries([\n ...Object.entries(source).map(([name, value]) => {\n // Tap into .map() to avoid double iteration\n // Property may be redefined observable\n this.undefine(name);\n return [\n name,\n {\n enumerable: name[0] !== '_',\n configurable: true,\n value,\n writable: true,\n ...options,\n },\n ];\n }),\n ...Object.getOwnPropertySymbols(source).map((symbol) => [\n symbol,\n {\n enumerable: false,\n configurable: true,\n // @ts-expect-error Can't index by symbol\n value: source[symbol],\n writable: true,\n ...options,\n },\n ]),\n ]),\n );\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * Returns result of calling mixin with current class\n * @type {{\n * <\n * BASE extends typeof CustomElement,\n * FN extends (...args:any[]) => any,\n * RETURN extends ReturnType<FN>,\n * SUBCLASS extends ClassOf<RETURN>,\n * >(this: BASE, mixin: FN): SUBCLASS & BASE\n * }}\n */\n static mixin(mixin) {\n return mixin(this);\n }\n\n /**\n * Registers class with window.customElements synchronously\n * @type {{\n * <T extends typeof CustomElement>(this: T, elementName?: string, force?: boolean): T;\n * }}\n */\n static register(elementName) {\n if (elementName) {\n this.elementName = elementName;\n }\n\n customElements.define(this.elementName, this);\n CustomElement.registrations.set(this.elementName, this);\n this.defined = true;\n return this;\n }\n\n static get propList() {\n if (!this.hasOwnProperty('_props')) {\n this._props = new Map(this._props);\n }\n return this._props;\n }\n\n static get attrList() {\n if (!this.hasOwnProperty('_attrs')) {\n this._attrs = new Map(this._attrs);\n }\n return this._attrs;\n }\n\n static get propChangedCallbacks() {\n if (!this.hasOwnProperty('_propChangedCallbacks')) {\n // structuredClone()\n this._propChangedCallbacks = new Map(\n [\n ...this._propChangedCallbacks,\n ].map(([name, array]) => [name, array.slice()]),\n );\n }\n return this._propChangedCallbacks;\n }\n\n static get attributeChangedCallbacks() {\n if (!this.hasOwnProperty('_attributeChangedCallbacks')) {\n this._attributeChangedCallbacks = new Map(\n [\n ...this._attributeChangedCallbacks,\n ].map(([name, array]) => [name, array.slice()]),\n );\n }\n return this._attributeChangedCallbacks;\n }\n\n /**\n * Creates observable property on instances (via prototype)\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * KEY extends string,\n * OPTIONS extends ObserverPropertyType\n * | ObserverOptions<ObserverPropertyType, unknown, INSTANCE>\n * | ((this:INSTANCE, data:Partial<INSTANCE>, fn?: () => any) => any),\n * VALUE extends Record<KEY, OPTIONS extends (...args2:any[]) => infer R ? R\n * : OPTIONS extends ObserverPropertyType ? import('./observe').ParsedObserverPropertyType<OPTIONS>\n * : OPTIONS extends {type: 'object'} & ObserverOptions<any, infer R> ? (unknown extends R ? object : R)\n * : OPTIONS extends {type: ObserverPropertyType} ? import('./observe').ParsedObserverPropertyType<OPTIONS['type']>\n * : OPTIONS extends ObserverOptions<any, infer R> ? (unknown extends R ? string : R)\n * : never\n * >\n * > (this: CLASS, name: KEY, options: OPTIONS)\n * : CLASS & Class<VALUE,ARGS>\n * }}\n */\n static prop(name, typeOrOptions) {\n // TODO: Cache and save configuration for reuse (mixins)\n const config = defineObservableProperty(\n /** @type {any} */ (this.prototype),\n name,\n /** @type {any} */ (typeOrOptions),\n );\n\n const { changedCallback, attr, reflect, watchers } = config;\n if (changedCallback) {\n watchers.push([name, changedCallback]);\n }\n // TODO: Inspect possible closure bloat\n config.changedCallback = function wrappedChangedCallback(oldValue, newValue, changes) {\n this._onObserverPropertyChanged.call(this, name, oldValue, newValue, changes);\n };\n\n this.propList.set(name, config);\n\n if (attr\n && (reflect === true || reflect === 'read')\n && (config.enumerable || !this.attrList.has(attr) || !this.attrList.get(attr).enumerable)) {\n this.attrList.set(attr, config);\n }\n\n this.onPropChanged(watchers);\n\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * Define properties on instances via Object.defineProperties().\n * Automatically sets property non-enumerable if name begins with `_`.\n * Functions will be remapped as getters\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends {\n * [P in keyof any] :\n * {\n * enumerable?: boolean;\n * configurable?: boolean;\n * writable?: boolean;\n * value?: any;\n * get?: ((this: INSTANCE) => any);\n * set?: (this: INSTANCE, value: any) => void;\n * } | ((this: INSTANCE, ...args:any[]) => any)\n * },\n * VALUE extends {\n * [KEY in keyof PROPS]: PROPS[KEY] extends (...args2:any[]) => infer R ? R\n * : PROPS[KEY] extends TypedPropertyDescriptor<infer R> ? R : never\n * }>\n * (this: CLASS, props: PROPS & ThisType<PROPS & INSTANCE>): CLASS\n * & Class<VALUE,ARGS>\n * }}\n */\n static define(props) {\n Object.defineProperties(\n this.prototype,\n Object.fromEntries(\n Object.entries(props).map(([name, options]) => {\n // Tap into .map() to avoid double iteration\n // Property may be redefined observable\n this.undefine(name);\n return [\n name,\n {\n enumerable: name[0] !== '_',\n configurable: true,\n ...(\n typeof options === 'function'\n ? { get: options }\n : options\n ),\n },\n ];\n }),\n ),\n );\n\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * Assigns values directly to all instances (via prototype)\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROP extends string,\n * PROPS extends INSTANCE & Record<PROP, never>\n * >(this: CLASS, name: PROP):\n * CLASS & Class<PROPS,ARGS>\n * }}\n */\n static undefine(name) {\n Reflect.deleteProperty(this.prototype, name);\n if (this.propList.has(name)) {\n const { watchers, attr, reflect } = this.propList.get(name);\n if (watchers.length && this.propChangedCallbacks.has(name)) {\n const propWatchers = this.propChangedCallbacks.get(name);\n for (const [prop, watcher] of watchers) {\n const index = propWatchers.indexOf(watcher);\n if (index !== -1) {\n console.warn('Unwatching', name);\n propWatchers.splice(index, 1);\n }\n }\n }\n if (attr && (reflect === true || reflect === 'read')) {\n this.attrList.delete(attr);\n }\n this.propList.delete(name);\n }\n\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * Creates observable properties on instances\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends IDLParameter<INSTANCE & VALUE>,\n * VALUE extends {\n * [KEY in keyof PROPS]:\n * PROPS[KEY] extends (...args2:any[]) => infer R ? R\n * : PROPS[KEY] extends ObserverPropertyType ? import('./observe').ParsedObserverPropertyType<PROPS[KEY]>\n * : PROPS[KEY] extends {type: 'object'} & ObserverOptions<any, infer R> ? (unknown extends R ? object : R)\n * : PROPS[KEY] extends {type: ObserverPropertyType} ? import('./observe').ParsedObserverPropertyType<PROPS[KEY]['type']>\n * : PROPS[KEY] extends ObserverOptions<any, infer R> ? (unknown extends R ? string : R)\n * : never\n * },\n * > (this: CLASS, props: PROPS)\n * : CLASS & Class<VALUE,ARGS>\n * }}\n */\n static observe(props) {\n for (const [name, typeOrOptions] of Object.entries(props ?? {})) {\n /** @type {any} */\n const options = (typeof typeOrOptions === 'function')\n ? { reflect: false, get: typeOrOptions }\n : typeOrOptions;\n\n this.prop(name, options);\n }\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * @type {{\n * <\n * T1 extends typeof CustomElement,\n * T2 extends IDLParameter<T1>>\n * (this: T1, props: T2):T1 & ParsedProps<T2>\n * }}\n */\n static defineStatic(props) {\n for (const [name, typeOrOptions] of Object.entries(props ?? {})) {\n const options = (typeof typeOrOptions === 'function')\n ? { get: typeOrOptions }\n : (typeof typeOrOptions === 'string'\n ? { type: typeOrOptions }\n : typeOrOptions);\n // @ts-expect-error Adding property to this\n defineObservableProperty(this, name, {\n reflect: false,\n ...options,\n });\n }\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * @type {{\n * <T extends typeof CustomElement>\n * (\n * this: T,\n * listeners?: import('./Composition').CompositionEventListenerObject<InstanceType<T>>,\n * options?: Partial<import('./Composition').CompositionEventListener<InstanceType<T>>>,\n * ): T;\n * }}\n */\n static events(listeners, options) {\n this.on({\n composed({ composition }) {\n for (const [key, listenerOptions] of Object.entries(listeners)) {\n const [, flags, type] = key.match(/^([*1~]+)?(.*)$/);\n // TODO: Make abstract\n let prop;\n /** @type {string[]} */\n let deepProp = [];\n if (typeof listenerOptions === 'string') {\n const parsedProps = listenerOptions.split('.');\n if (parsedProps.length === 1) {\n prop = listenerOptions;\n deepProp = [];\n } else {\n prop = parsedProps[0];\n deepProp = parsedProps;\n }\n }\n composition.addCompositionEventListener({\n type,\n once: flags?.includes('1'),\n passive: flags?.includes('~'),\n capture: flags?.includes('*'),\n ...(\n typeof listenerOptions === 'function'\n ? { handleEvent: listenerOptions }\n : (typeof listenerOptions === 'string'\n ? { prop, deepProp }\n : listenerOptions)\n ),\n ...(\n options\n )\n ,\n });\n }\n },\n });\n\n return this;\n }\n\n /**\n * @type {{\n * <T extends typeof CustomElement>\n * (\n * this: T,\n * listenerMap: {\n * [P in keyof any]: import('./Composition').CompositionEventListenerObject<InstanceType<T>>\n * },\n * options?: Partial<import('./Composition').CompositionEventListener<InstanceType<T>>>,\n * ): T;\n * }}\n */\n static childEvents(listenerMap, options) {\n for (const [tag, listeners] of Object.entries(listenerMap)) {\n this.events(listeners, {\n tag: attrNameFromPropName(tag),\n ...options,\n });\n }\n\n return this;\n }\n\n /** @type {typeof CustomElement['events']} */\n static rootEvents(listeners, options) {\n return this.events(listeners, {\n tag: Composition.shadowRootTag,\n ...options,\n });\n }\n\n /**\n * @type {{\n * <\n * T1 extends typeof CustomElement,\n * T2 extends InstanceType<T1>,\n * T3 extends CompositionCallback<T2, T2>,\n * T4 extends keyof T3,\n * >\n * (this: T1, name: T3|T4, callbacks?: T3[T4] & ThisType<T2>): T1\n * }}\n */\n static on(nameOrCallbacks, callback) {\n const callbacks = typeof nameOrCallbacks === 'string'\n ? { [nameOrCallbacks]: callback }\n : nameOrCallbacks;\n for (const [name, fn] of Object.entries(callbacks)) {\n /** @type {keyof (typeof CustomElement)} */\n let arrayPropName;\n switch (name) {\n case 'composed': arrayPropName = '_onComposeCallbacks'; break;\n case 'constructed': arrayPropName = '_onConstructedCallbacks'; break;\n case 'connected': arrayPropName = '_onConnectedCallbacks'; break;\n case 'disconnected': arrayPropName = '_onDisconnectedCallbacks'; break;\n case 'props':\n this.onPropChanged(fn);\n continue;\n case 'attrs':\n this.onAttributeChanged(fn);\n continue;\n default:\n if (name.endsWith('Changed')) {\n const prop = name.slice(0, name.length - 'Changed'.length);\n // @ts-expect-error Computed key\n this.onPropChanged({ [prop]: fn });\n continue;\n }\n throw new Error('Invalid callback name');\n }\n this._addCallback(arrayPropName, fn);\n }\n\n return this;\n }\n\n /**\n * @type {{\n * <\n * T1 extends typeof CustomElement,\n * T2 extends InstanceType<T1>\n * >\n * (\n * this: T1,\n * options: ObjectOrObjectEntries<{\n * [P in keyof T2]? : (\n * this: T2,\n * oldValue: T2[P],\n * newValue: T2[P],\n * changes:any,\n * element: T2\n * ) => void\n * }>,\n * ): T1;\n * }}\n */\n static onPropChanged(options) {\n const entries = Array.isArray(options) ? options : Object.entries(options);\n const { propChangedCallbacks } = this;\n for (const [prop, callback] of entries) {\n if (propChangedCallbacks.has(prop)) {\n propChangedCallbacks.get(prop).push(callback);\n } else {\n propChangedCallbacks.set(prop, [callback]);\n }\n }\n\n return this;\n }\n\n /**\n * @type {{\n * <\n * T1 extends typeof CustomElement,\n * T2 extends InstanceType<T1>\n * >\n * (\n * this: T1,\n * options: {\n * [x:string]: (\n * this: T2,\n * oldValue: string,\n * newValue: string,\n * element: T2\n * ) => void\n * },\n * ): T1;\n * }}\n */\n static onAttributeChanged(options) {\n const entries = Array.isArray(options) ? options : Object.entries(options);\n const { attributeChangedCallbacks } = this;\n for (const [name, callback] of entries) {\n if (attributeChangedCallbacks.has(name)) {\n attributeChangedCallbacks.get(name).push(callback);\n } else {\n attributeChangedCallbacks.set(name, [callback]);\n }\n }\n\n return this;\n }\n\n /** @type {Record<string, HTMLElement>}} */\n #refsProxy;\n\n /** @type {Map<string, WeakRef<HTMLElement>>}} */\n #refsCache = new Map();\n\n /** @type {Map<string, WeakRef<HTMLElement>>}} */\n #refsCompositionCache = new Map();\n\n /** @type {Composition<?>} */\n #composition;\n\n #patching = false;\n\n /** @type {Array<[string, any, CustomElement]>} */\n #pendingPatchRenders = [];\n\n /** @type {Map<string,{stringValue:string, parsedValue:any}>} */\n _propAttributeCache;\n\n /** @type {CallbackArguments} */\n _callbackArguments = null;\n\n /** @param {any[]} args */\n constructor(...args) {\n super();\n\n if (CustomElement.supportsElementInternals) {\n this.elementInternals = this.attachInternals();\n }\n\n this.attachShadow({ mode: 'open', delegatesFocus: this.delegatesFocus });\n\n /**\n * Updates nodes based on data\n * Expects data in JSON Merge Patch format\n * @see https://www.rfc-editor.org/rfc/rfc7386\n * @param {Partial<?>} changes\n * @param {any} data\n * @return {void}\n */\n this.render = this.composition.render(\n this.constructor.prototype,\n this,\n {\n defaults: this.constructor.prototype,\n store: this,\n shadowRoot: this.shadowRoot,\n context: this,\n },\n );\n\n for (const callback of this.static._onConstructedCallbacks) {\n callback.call(this, this.callbackArguments);\n }\n }\n\n /**\n * @type {{\n * <\n * T extends CustomElement,\n * K extends string = string,\n * >(this:T,\n * name: K,\n * oldValue: K extends keyof T ? T[K] : unknown,\n * newValue: K extends keyof T ? T[K] : unknown,\n * changes?: K extends keyof T ? T[K] extends object ? Partial<T[K]> : T[K] : unknown): void;\n * }}\n */\n propChangedCallback(name, oldValue, newValue, changes = newValue) {\n if (this.#patching) {\n this.#pendingPatchRenders.push([name, changes, this]);\n } else {\n this.render.byProp(name, changes, this);\n // this.render({ [name]: changes });\n }\n\n const { _propChangedCallbacks } = this.static;\n if (_propChangedCallbacks.has(name)) {\n for (const callback of _propChangedCallbacks.get(name)) {\n callback.call(this, oldValue, newValue, changes, this);\n }\n }\n }\n\n /**\n * @param {string} name\n * @param {string|null} oldValue\n * @param {string|null} newValue\n */\n attributeChangedCallback(name, oldValue, newValue) {\n const { attributeChangedCallbacks } = this.static;\n if (attributeChangedCallbacks.has(name)) {\n for (const callback of attributeChangedCallbacks.get(name)) {\n callback.call(this, oldValue, newValue, this);\n }\n }\n\n // Array.find\n const { attrList } = this.static;\n if (!attrList.has(name)) return;\n\n const config = attrList.get(name);\n\n if (config.attributeChangedCallback) {\n config.attributeChangedCallback.call(this, name, oldValue, newValue);\n return;\n }\n\n let cacheEntry;\n if (this.attributeCache.has(name)) {\n cacheEntry = this.attributeCache.get(name);\n if (cacheEntry.stringValue === newValue) return;\n }\n\n // @ts-expect-error any\n const previousDataValue = this[config.key];\n const parsedValue = newValue === null\n ? config.nullParser(/** @type {null} */ (newValue))\n // Avoid Boolean('') === false\n : (config.type === 'boolean' ? true : config.parser(newValue));\n\n if (parsedValue === previousDataValue) {\n // No internal value change\n return;\n }\n // \"Remember\" that this attrValue equates to this data value\n // Avoids rewriting attribute later on data change event\n if (cacheEntry) {\n cacheEntry.stringValue = newValue;\n cacheEntry.parsedValue = parsedValue;\n } else {\n this.attributeCache.set(name, {\n stringValue: newValue, parsedValue,\n });\n }\n // @ts-expect-error any\n this[config.key] = parsedValue;\n }\n\n get #template() {\n return this.#composition?.template;\n }\n\n /**\n * @param {string} name\n * @param {any} oldValue\n * @param {any} newValue\n * @param {any} changes\n */\n _onObserverPropertyChanged(name, oldValue, newValue, changes) {\n const { propList } = this.static;\n if (propList.has(name)) {\n const { reflect, attr } = propList.get(name);\n if (attr && (reflect === true || reflect === 'write')) {\n /** @type {{stringValue:string, parsedValue:any}} */\n let cacheEntry;\n let needsWrite = false;\n const { attributeCache } = this;\n if (attributeCache.has(attr)) {\n cacheEntry = attributeCache.get(attr);\n needsWrite = (cacheEntry.parsedValue !== newValue);\n } else {\n // @ts-ignore skip cast\n cacheEntry = {};\n attributeCache.set(attr, cacheEntry);\n needsWrite = true;\n }\n if (needsWrite) {\n const stringValue = attrValueFromDataValue(newValue);\n cacheEntry.parsedValue = newValue;\n cacheEntry.stringValue = stringValue;\n // Cache attrValue to ignore attributeChangedCallback later\n if (stringValue == null) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, stringValue);\n }\n }\n }\n }\n\n // Invoke change => render\n this.propChangedCallback(name, oldValue, newValue, changes);\n }\n\n /** @param {any} patch */\n patch(patch) {\n this.#patching = true;\n applyMergePatch(this, patch);\n for (const [name, changes, state] of this.#pendingPatchRenders) {\n if (name in patch) continue;\n this.render.byProp(name, changes, state);\n }\n this.#pendingPatchRenders.slice(0, this.#pendingPatchRenders.length);\n this.render(patch);\n this.#patching = false;\n }\n\n /**\n * Proxy object that returns shadow DOM elements by tag.\n * If called before interpolation (eg: on composed), returns from template\n * @return {Record<string,HTMLElement>}\n */\n get refs() {\n // eslint-disable-next-line no-return-assign\n return (this.#refsProxy ??= new Proxy({}, {\n /**\n * @param {any} target\n * @param {string} tag\n * @return {Element}\n */\n get: (target, tag) => {\n if (!this.#composition) {\n console.warn(this.static.name, 'Attempted to access references before composing!');\n }\n const composition = this.composition;\n let element;\n if (!composition.interpolated) {\n if (this.#refsCompositionCache.has(tag)) {\n element = this.#refsCompositionCache.get(tag).deref();\n if (element) return element;\n }\n const formattedTag = attrNameFromPropName(tag);\n // console.warn(this.tagName, 'Returning template reference');\n element = composition.template.getElementById(formattedTag);\n if (!element) return null;\n this.#refsCompositionCache.set(tag, new WeakRef(element));\n return element;\n }\n if (this.#refsCache.has(tag)) {\n element = this.#refsCache.get(tag).deref();\n if (element) {\n return element;\n }\n }\n\n const formattedTag = attrNameFromPropName(tag);\n const tagIndex = this.composition.tags.indexOf(formattedTag);\n element = this.render.state.refs[tagIndex];\n\n if (!element) return null;\n this.#refsCache.set(tag, new WeakRef(element));\n return element;\n },\n }));\n }\n\n get attributeCache() {\n // eslint-disable-next-line no-return-assign\n return (this._propAttributeCache ??= new Map());\n }\n\n get static() { return /** @type {typeof CustomElement} */ (/** @type {unknown} */ (this.constructor)); }\n\n get unique() { return false; }\n\n /**\n * @template {CustomElement} T\n * @this {T}\n */\n get callbackArguments() {\n // eslint-disable-next-line no-return-assign\n return this._callbackArguments ??= {\n composition: this.#composition,\n refs: this.refs,\n html: html.bind(this),\n inline: addInlineFunction,\n template: this.#template,\n element: this,\n };\n }\n\n /** @return {Composition<?>} */\n get composition() {\n if (this.#composition) return this.#composition;\n\n if (!this.unique && this.static.hasOwnProperty('_composition')) {\n this.#composition = this.static._composition;\n return this.static._composition;\n }\n\n // TODO: Use Composition to track uniqueness\n // console.log('composing', this.static.elementName);\n this.compose();\n for (const callback of this.static._onComposeCallbacks) {\n // console.log(this.static.elementName, 'composition callback');\n callback.call(this, this.callbackArguments);\n }\n\n if (!this.unique) {\n // Cache compilation into static property\n this.static._composition = this.#composition;\n }\n\n return this.#composition;\n }\n\n connectedCallback() {\n for (const callbacks of this.static._onConnectedCallbacks) {\n callbacks.call(this, this.callbackArguments);\n }\n }\n\n disconnectedCallback() {\n for (const callbacks of this.static._onDisconnectedCallbacks) {\n callbacks.call(this, this.callbackArguments);\n }\n }\n}\n\nCustomElement.prototype.delegatesFocus = false;\n"],
|
|
5
|
-
"mappings": "AAEA,IAAIA,GACAC,GAIG,SAASC,IAAsB,CAEpC,OAAQC,KAAe,IAAI,MAAQ,UAAU,CAC/C,CASO,SAASC,GAAqB,CAEnC,OAAQC,KAAkB,IAAI,SAAW,UAAU,CACrD,CCUA,IAAqBC,EAArB,KAAwC,CAEtC,YAAYC,EAAS,CACnB,KAAK,WAAaA,EAAQ,WAG1B,KAAK,SAAW,CAAC,EAQjB,KAAK,KAAO,CAAC,EAKb,KAAK,sBAAwB,GAG7B,KAAK,YAAcA,EAAQ,YAE3B,KAAK,cAAgBA,EAAQ,cAG7B,KAAK,cAAgB,KAGrB,KAAK,eAAiB,CAAC,EAGvB,KAAK,gBAAkB,KAEvB,KAAK,cAAgB,IACvB,CAOA,OAAOC,EAASC,EAAM,C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pB,OAAQ4D,GACR,SAAU,KAAKZ,GACf,QAAS,IACX,CACF,CAGA,IAAI,aAAc,CAChB,GAAI,KAAK5D,GAAc,OAAO,KAAKA,GAEnC,GAAI,CAAC,KAAK,QAAU,KAAK,OAAO,eAAe,cAAc,EAC3D,YAAKA,GAAe,KAAK,OAAO,aACzB,KAAK,OAAO,aAKrB,KAAK,QAAQ,EACb,QAAWG,KAAY,KAAK,OAAO,oBAEjCA,EAAS,KAAK,KAAM,KAAK,iBAAiB,EAG5C,OAAK,KAAK,SAER,KAAK,OAAO,aAAe,KAAKH,IAG3B,KAAKA,EACd,CAEA,mBAAoB,CAClB,QAAW2C,KAAa,KAAK,OAAO,sBAClCA,EAAU,KAAK,KAAM,KAAK,iBAAiB,CAE/C,CAEA,sBAAuB,CACrB,QAAWA,KAAa,KAAK,OAAO,yBAClCA,EAAU,KAAK,KAAM,KAAK,iBAAiB,CAE/C,CACF,EAEA7C,EAAc,UAAU,eAAiB",
|
|
4
|
+
"sourcesContent": ["// Micro-optimized functions\n\nlet BLANK_TEXT;\nlet BLANK_COMMENT;\nlet BLANK_DIV;\n\n/** @return {Text} */\nexport function createEmptyTextNode() {\n // eslint-disable-next-line no-return-assign\n return (BLANK_TEXT ??= new Text()).cloneNode();\n}\n\n/** @return {HTMLDivElement} */\nexport function createEmptyDiv() {\n // eslint-disable-next-line no-return-assign\n return (BLANK_DIV ??= document.createElement('div')).cloneNode();\n}\n\n/** @return {Comment} */\nexport function createEmptyComment() {\n // eslint-disable-next-line no-return-assign\n return (BLANK_COMMENT ??= new Comment()).cloneNode();\n}\n", "import { createEmptyComment } from './optimizations.js';\n\n/**\n * @template T\n * @typedef {import('./Composition.js').default<T>} Composition\n */\n\n/**\n * @template T\n * @typedef {import('./Composition.js').RenderOptions<T>} RenderOptions\n */\n\n/**\n * @template T\n * @typedef {Object} DomAdapterCreateOptions\n * @prop {Comment} anchorNode\n * @prop {(...args:any[]) => HTMLElement} [create]\n * @prop {Composition<T>} composition\n * @prop {RenderOptions<T>} renderOptions\n */\n\n/**\n * @typedef {Object} ItemMetadata\n * @prop {Element} element\n * @prop {any} key\n * @prop {Element|Comment} domNode\n * @prop {Function} render\n * @prop {boolean} [hidden]\n * @prop {Comment} [comment]\n */\n\n/** @template T */\nexport default class CompositionAdapter {\n /** @param {DomAdapterCreateOptions<T>} options */\n constructor(options) {\n this.anchorNode = options.anchorNode;\n\n /** @type {ItemMetadata[]} */\n this.metadata = [];\n /**\n * Ordered-list of metadata keys\n * Chrome and FireFox optimize arrays for indexOf/includes\n * Safari is faster with WeakMap.get(), but can't use Primitive keys\n * TODO: Add Safari path\n * @type {any[]}\n */\n this.keys = [];\n\n /**\n * Chrome needs a hint to know we will need a fast path for array by keys.\n */\n this.needsArrayKeyFastPath = false;\n\n /** @type {Composition<T>} */\n this.composition = options.composition;\n /** @type {RenderOptions<T>} */\n this.renderOptions = options.renderOptions;\n\n /** @type {Map<any, ItemMetadata>} */\n this.metadataCache = null;\n\n /** @type {Element[]} */\n this.queuedElements = [];\n // this.batching = false;\n /** @type {number|null} */\n this.batchStartIndex = null;\n /** @type {number|null} */\n this.batchEndIndex = null;\n }\n\n /**\n * @param {Partial<T>} changes\n * @param {T} data\n * @return {import('./Composition.js').RenderDraw<T>}\n */\n render(changes, data) {\n return this.composition.render(changes, data, this.renderOptions);\n }\n\n startBatch() {\n this.needsArrayKeyFastPath = true;\n // this.batching = true;\n }\n\n writeBatch() {\n if (!this.queuedElements.length) return;\n /** @type {Comment|Element|Document} */\n const previousSibling = this.metadata[this.batchStartIndex - 1]?.domNode ?? this.anchorNode;\n previousSibling.after(...this.queuedElements);\n this.queuedElements.length = 0;\n }\n\n stopBatch() {\n this.writeBatch();\n\n this.needsArrayKeyFastPath = false;\n this.batchStartIndex = null;\n this.batchEndIndex = null;\n if (this.metadataCache) {\n for (const { domNode } of this.metadataCache.values()) {\n domNode.remove();\n }\n this.metadataCache.clear();\n }\n }\n\n /** @param {number} index */\n removeByIndex(index) {\n const [metadata] = this.metadata.splice(index, 1);\n const { domNode, key } = metadata;\n this.keys.splice(index, 1);\n domNode.remove();\n\n // Don't release in case we may need it later\n if (this.metadataCache) {\n this.metadataCache.set(key, metadata);\n } else {\n this.metadataCache = new Map([[key, metadata]]);\n }\n }\n\n /**\n * Worst case scenario\n * @param {number} newIndex expectedIndex\n * @param {*} changes\n * @param {*} data\n * @param {*} key\n * @param {*} change\n * @param {boolean} [skipOnMatch]\n * JSON Merge has no way to express sort change and data change. Best\n * performance is done via invoking render on sort change and another on\n * inner change. Can't skip if mixing change types.\n */\n renderData(newIndex, changes, data, key, change, skipOnMatch) {\n if (newIndex < this.metadata.length) {\n const metadataAtIndex = this.metadata[newIndex];\n\n // There is an element in this slot\n\n // Compare if different\n const currentKey = metadataAtIndex.key;\n const sameKey = (currentKey === key);\n const isPartial = (change !== key);\n\n if (sameKey) {\n // Both reference the same key (correct spot)\n if (isPartial) {\n metadataAtIndex.render(changes, data);\n } else if (skipOnMatch) {\n // Skip overwrite. Presume no change\n // console.warn('same key, no reason to repaint', newIndex);\n } else {\n // console.warn('no skip on match', newIndex);\n metadataAtIndex.render(changes, data);\n }\n return;\n }\n\n // eslint-disable-next-line no-multi-assign\n const metadataCache = (this.metadataCache ??= new Map());\n\n // If not same key. Scan key list.\n // Can avoid checking before current index. Will always be after current\n let failedFastPath = false;\n if (this.needsArrayKeyFastPath) {\n // Invoking includes will ensure Chrome generates an internal hash map\n failedFastPath = !this.keys.includes(key);\n this.needsArrayFastPath = false;\n }\n const oldIndex = failedFastPath ? -1 : this.keys.indexOf(key, newIndex + 1);\n if (oldIndex === -1) {\n // New key\n // console.log('new key?', 'should be at', newIndex);\n // Was key removed in this batch?\n if (metadataCache.has(key)) {\n // console.log('inserting removed element', 'at', newIndex);\n // (Optimistic insert)\n // Key was removed and should be here instead\n // If should have been replace, will correct next step\n const previousMetadata = metadataCache.get(key);\n this.metadata.splice(newIndex, 0, previousMetadata);\n this.keys.splice(newIndex, 0, key);\n\n const previousSibling = this.metadata[newIndex - 1]?.domNode ?? this.anchorNode;\n previousSibling.after(previousMetadata.domNode);\n metadataCache.delete(key);\n return;\n }\n\n // (Optimistic replace)\n // Brand new key. Cache whatever is in current and replace\n // If should have been insert, will correct itself next step.\n // Allows multiple inserts to batch instead of one-by-one\n\n // console.log('completely new key', 'removing old. will replace', newIndex);\n metadataCache.set(currentKey, metadataAtIndex);\n\n // Continue to PUT below\n } else {\n // Key is in the wrong spot (guaranteed to be oldIndex > newIndex)\n // console.warn('Found key for', newIndex, '@', oldIndex);\n // console.warn('swapping', newIndex, '<=>', oldIndex);\n if ((newIndex - oldIndex) === -1) {\n // (Optimistic removal)\n // If element should be one step sooner, remove instead to shift up.\n // If should have been swap, will correct itself next step.\n // console.warn('Removing', newIndex, 'instead');\n this.removeByIndex(newIndex);\n return;\n }\n // Swap with other element\n // Arrays should be iterated sequentially.\n // Array can never swap before current index\n\n // Store what's later in the tree to move here\n\n const correctMetadata = this.metadata[oldIndex];\n\n // Move back <=\n this.metadata[newIndex] = correctMetadata;\n this.metadata.splice(oldIndex, 1);\n\n const { domNode: domNodeToRemove } = metadataAtIndex;\n domNodeToRemove.replaceWith(correctMetadata.domNode);\n\n if (!skipOnMatch) {\n console.warn('no skip on match on swap', newIndex);\n correctMetadata.render(changes, data);\n }\n\n // Remove posterior\n\n this.keys[newIndex] = key;\n this.keys.splice(oldIndex, 1);\n\n domNodeToRemove.remove();\n\n // Don't release in case we may need it later\n // console.debug('Caching key', key);\n metadataCache.set(currentKey, metadataAtIndex);\n\n return;\n }\n }\n\n const render = this.render(changes, data);\n const element = /** @type {Element} */ (render.target);\n\n this.metadata[newIndex] = {\n render,\n element,\n key,\n domNode: element,\n };\n this.keys[newIndex] = key;\n\n if (this.batchEndIndex === null || this.batchEndIndex !== (newIndex - 1)) {\n this.writeBatch();\n // Start new batch\n this.batchStartIndex = newIndex;\n }\n this.batchEndIndex = newIndex;\n this.queuedElements.push(element);\n }\n\n removeEntries(startIndex = 0) {\n const { length } = this.metadata;\n for (let index = length - 1; index >= startIndex; index--) {\n this.metadata[index].domNode.remove();\n }\n this.metadata.length = startIndex;\n this.keys.length = startIndex;\n }\n\n /**\n * @param {number} [index]\n * @param {ItemMetadata} [metadata]\n * @param {any} [key]\n * @return {boolean} changed\n */\n hide(index, metadata, key) {\n if (!metadata) {\n if (index == null) {\n index = this.keys.indexOf(key);\n }\n metadata = this.metadata[index];\n if (!metadata) {\n return false;\n }\n }\n\n if (metadata.hidden) return false;\n\n let { comment, element } = metadata;\n if (!comment) {\n comment = createEmptyComment();\n metadata.comment = comment;\n }\n\n element.replaceWith(comment);\n metadata.domNode = comment;\n metadata.hidden = true;\n return true;\n }\n\n /**\n * @param {number} [index]\n * @param {ItemMetadata} [metadata]\n * @param {any} [key]\n * @return {boolean} changed\n */\n show(index, metadata, key) {\n if (!metadata) {\n if (index == null) {\n index = this.keys.indexOf(key);\n }\n metadata = this.metadata[index];\n if (!metadata) {\n return false;\n }\n }\n\n if (!metadata.hidden) return false;\n\n const { comment, element } = metadata;\n\n comment.replaceWith(element);\n metadata.domNode = element;\n metadata.hidden = false;\n return true;\n }\n}\n", "/** @type {Map<string, CSSStyleSheet>} */\nconst cssStyleSheetsCache = new Map();\n\n/**\n * @param {string} content\n * @param {boolean} [useCache=true]\n * @return {CSSStyleSheet}\n */\nexport function createCSSStyleSheet(content, useCache = true) {\n if (useCache && cssStyleSheetsCache.has(content)) {\n return cssStyleSheetsCache.get(content);\n }\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(content);\n if (useCache) {\n cssStyleSheetsCache.set(content, sheet);\n }\n return sheet;\n}\n\n/** @type {Map<string, HTMLStyleElement>} */\nconst styleElementCache = new Map();\n\n/** @type {Document} */\nlet _inactiveDocument;\n\n/**\n * @param {string} content\n * @param {boolean} [useCache=true]\n * @return {HTMLStyleElement}\n */\nexport function createHTMLStyleElement(content, useCache = true) {\n let style;\n if (useCache && styleElementCache.has(content)) {\n style = styleElementCache.get(content);\n } else {\n _inactiveDocument ??= document.implementation.createHTMLDocument();\n style = _inactiveDocument.createElement('style');\n style.textContent = content;\n if (useCache) {\n styleElementCache.set(content, style);\n }\n }\n return /** @type {HTMLStyleElement} */ (style.cloneNode(true));\n}\n\n/** @type {boolean} */\nlet _cssStyleSheetConstructable;\n\n/**\n * @param {string} content\n * @param {boolean} [useCache=true]\n */\nexport function createCSS(content, useCache = true) {\n if (_cssStyleSheetConstructable == null) {\n try {\n const sheet = createCSSStyleSheet(content, useCache);\n _cssStyleSheetConstructable = true;\n return sheet;\n } catch {\n _cssStyleSheetConstructable = false;\n }\n }\n return _cssStyleSheetConstructable\n ? createCSSStyleSheet(content, useCache)\n : createHTMLStyleElement(content, useCache);\n}\n\n/**\n * @param {Iterable<HTMLStyleElement|CSSStyleSheet>} styles\n * @param {boolean} [useCache=true]\n * @yields composed CSSStyleSheet\n * @return {Generator<CSSStyleSheet>} composed CSSStyleSheet\n */\nexport function* generateCSSStyleSheets(styles, useCache = true) {\n for (const style of styles) {\n if (style instanceof HTMLStyleElement) {\n yield createCSSStyleSheet(style.textContent, useCache);\n } else if (style.ownerNode) {\n console.warn('Stylesheet is part of style');\n yield createCSSStyleSheet([...style.cssRules].map((r) => r.cssText).join(''), useCache);\n } else {\n yield style;\n }\n }\n}\n\n/** @type {WeakMap<CSSStyleSheet, HTMLStyleElement>} */\nconst styleElementFromStyleSheetCache = new WeakMap();\n\n/**\n * @param {Iterable<HTMLStyleElement|CSSStyleSheet>} styles\n * @param {boolean} [useCache=true]\n * @yields composed HTMLStyleElement\n * @return {Generator<HTMLStyleElement>} composed CSSStyleSheet\n */\nexport function* generateHTMLStyleElements(styles, useCache = true) {\n for (const style of styles) {\n if (style instanceof HTMLStyleElement) {\n yield style;\n } else if (style.ownerNode instanceof HTMLStyleElement) {\n // console.log('Cloning parent HTMLStyleElement instead');\n // @ts-ignore Skip cast\n yield style.ownerNode.cloneNode(true);\n } else if (useCache && styleElementFromStyleSheetCache.has(style)) {\n // @ts-ignore Skip cast\n yield styleElementFromStyleSheetCache.get(style).cloneNode(true);\n } else {\n console.warn('Manually constructing HTMLStyleElement', [...style.cssRules].map((r) => r.cssText).join('\\n'));\n const styleElement = document.createElement('style');\n styleElement.textContent = [...style.cssRules].map((r) => r.cssText).join('');\n if (useCache) {\n styleElementFromStyleSheetCache.set(style, styleElement);\n }\n\n // @ts-ignore Skip cast\n yield styleElement.cloneNode(true);\n }\n }\n}\n\n/**\n * @param {TemplateStringsArray|string} array\n * @param {...any} substitutions\n * @return {HTMLStyleElement|CSSStyleSheet}\n */\nexport function css(array, ...substitutions) {\n if (typeof array === 'string') return createCSS(array);\n return createCSS(String.raw({ raw: array }, ...substitutions));\n}\n\n/**\n * @param {TemplateStringsArray|string|HTMLStyleElement|CSSStyleSheet} styles\n * @param {...any} substitutions\n * @return {HTMLStyleElement|CSSStyleSheet}\n */\nexport function addGlobalCss(styles, ...substitutions) {\n /** @type {HTMLStyleElement|CSSStyleSheet} */\n let compiled;\n if (typeof styles === 'string') {\n compiled = css(styles);\n } else if (Array.isArray(styles)) {\n compiled = css(/** @type {TemplateStringsArray} */ (styles), ...substitutions);\n } else {\n compiled = /** @type {HTMLStyleElement|CSSStyleSheet} */ (styles);\n }\n\n if (compiled instanceof HTMLStyleElement) {\n document.head.append(compiled);\n } else {\n document.adoptedStyleSheets = [\n ...document.adoptedStyleSheets,\n compiled,\n ];\n }\n return compiled;\n}\n", "/* eslint-disable no-bitwise */\n\n/**\n * @param {any} value\n * @return {?string}\n */\nexport function attrValueFromDataValue(value) {\n switch (value) {\n case undefined:\n case null:\n case false:\n return null;\n case true:\n return '';\n default:\n return `${value}`;\n }\n}\n\n/** @type {Map<string, string>} */\nlet attrNameFromPropNameCache;\n\n/**\n * Converts property name to attribute name\n * (Similar to DOMStringMap)\n * @param {string} name\n * @return {string}\n */\nexport function attrNameFromPropName(name) {\n attrNameFromPropNameCache ??= new Map();\n if (attrNameFromPropNameCache.has(name)) {\n return attrNameFromPropNameCache.get(name);\n }\n // eslint-disable-next-line unicorn/prefer-string-replace-all\n const value = name.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);\n attrNameFromPropNameCache.set(name, value);\n return value;\n}\n\nexport const CHROME_VERSION = Number.parseFloat(navigator.userAgent.match(/Chrome\\/([\\d.]+)/)?.[1]);\nexport const FIREFOX_VERSION = Number.parseFloat(navigator.userAgent.match(/Firefox\\/([\\d.]+)/)?.[1]);\nexport const SAFARI_VERSION = CHROME_VERSION || !navigator.userAgent.includes('AppleWebKit')\n ? Number.NaN\n : Number.parseFloat(navigator.userAgent.match(/Version\\/([\\d.]+)/)?.[1]);\n\n/**\n * @param {Element} element\n * @return {boolean}\n */\nexport function isFocused(element) {\n if (!element) return false;\n // @ts-ignore runtime check\n if (FIREFOX_VERSION < 113 && element.constructor.formAssociated && element.hasAttribute('disabled')) {\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1818287\n console.warn('Firefox bug 1818287: Disabled form associated custom element cannot receive focus.');\n return false;\n }\n if (document.activeElement === element) return true;\n if (!element.isConnected) return false;\n if (element?.getRootNode() === document) return false; // isInLightDOM\n // console.debug('checking shadowdom', element, element.matches(':focus'));\n return element.matches(':focus');\n}\n\n/**\n * @param {HTMLElement|Element} element\n * @param {Parameters<HTMLElement['focus']>} [options]\n * @return {boolean} Focus was successful\n */\nexport function attemptFocus(element, ...options) {\n if (!element) return false;\n try {\n // @ts-expect-error Use catch if not HTMLElement\n element.focus(...options);\n } catch (e) {\n console.error(e);\n return false;\n // Ignore error.\n }\n return isFocused(element);\n}\n\n/**\n * @param {Element} element\n * @return {boolean}\n */\nexport function isRtl(element) {\n return getComputedStyle(element).direction === 'rtl';\n}\n", "/** @link https://www.rfc-editor.org/rfc/rfc7396 */\n\n/**\n * @template T1\n * @template T2\n * @param {T1} target\n * @param {T2} patch\n * @return {T1|T2|(T1 & T2)}\n */\nexport function applyMergePatch(target, patch) {\n // @ts-ignore Runtime check\n if (target === patch) return target;\n if (target == null || patch == null || typeof patch !== 'object') return patch;\n if (typeof target !== 'object') {\n // @ts-ignore Forced cast to object\n target = {};\n }\n for (const [key, value] of Object.entries(patch)) {\n if (value == null) {\n // @ts-ignore Runtime check\n if (key in target) {\n // @ts-ignore T1 is always object\n delete target[key];\n }\n } else {\n // @ts-ignore T1 is forced object\n target[key] = applyMergePatch(target[key], value);\n }\n }\n return target;\n}\n\n/**\n * Creates a JSON Merge patch based\n * Allows different strategies for arrays\n * - `reference`: Per spec, returns array as is\n * - `clone`: Clones all entries with no inspection.\n * - `object`: Convert to flattened, array-like objects. Requires\n * consumer of patch to be aware of the schema beforehand.\n * @param {object|number|string|boolean} previous\n * @param {object|number|string|boolean} current\n * @param {'clone'|'object'|'reference'} [arrayStrategy='reference']\n * @return {any} Patch\n */\nexport function buildMergePatch(previous, current, arrayStrategy = 'reference') {\n if (previous === current) return null;\n if (current == null || typeof current !== 'object') return current;\n if (previous == null || typeof previous !== 'object') {\n return structuredClone(current);\n }\n\n const patch = {};\n if (Array.isArray(current)) {\n if (arrayStrategy === 'reference') {\n return current;\n }\n // Assume previous is array\n if (arrayStrategy === 'clone') {\n return structuredClone(current);\n }\n for (const [index, value] of current.entries()) {\n if (value === null) {\n // @ts-ignore patch is ArrayLike\n patch[index] = null;\n continue;\n }\n if (value == null) {\n continue; // Skip undefined\n }\n // @ts-ignore previous is ArrayLike\n const changes = buildMergePatch(previous[index], value, arrayStrategy);\n if (changes !== null) {\n // @ts-ignore patch is ArrayLike\n patch[index] = changes;\n }\n }\n // for (let i = current.length; i < previous.length; i++) {\n // patch[i] = null;\n // }\n // @ts-ignore previous is ArrayLike\n if (current.length !== previous.length) {\n patch.length = current.length;\n }\n return patch;\n }\n\n const previousKeys = new Set(Object.keys(previous));\n for (const [key, value] of Object.entries(current)) {\n previousKeys.delete(key);\n if (value === null) {\n // @ts-ignore patch is Object\n patch[key] = null;\n continue;\n }\n if (value == null) {\n continue; // Skip undefined\n }\n // @ts-ignore previous is Object\n const changes = buildMergePatch(previous[key], value, arrayStrategy);\n if (changes !== null) {\n // @ts-ignore patch is Object\n patch[key] = changes;\n }\n }\n for (const key of previousKeys) {\n // @ts-ignore patch is Object\n patch[key] = null;\n }\n\n return patch;\n}\n\n/**\n * Short-circuited JSON Merge Patch evaluation\n * @template T\n * @param {T} target\n * @param {Partial<T>} patch\n * @return {boolean}\n */\nexport function hasMergePatch(target, patch) {\n if (target === patch) return false;\n if (patch == null || typeof patch !== 'object') return true;\n if (target != null && typeof target !== 'object') {\n return true;\n }\n for (const [key, value] of Object.entries(patch)) {\n if (value == null) {\n // @ts-ignore Runtime check\n if (key in target) {\n return true;\n }\n // @ts-ignore T is object\n } else if (hasMergePatch(target[key], value)) {\n return true;\n }\n }\n return false;\n}\n", "import { attrNameFromPropName } from './dom.js';\nimport { buildMergePatch, hasMergePatch } from './jsonMergePatch.js';\n\n/** @typedef {'string' | 'boolean' | 'map' | 'set' | 'float' | 'integer' | 'object' | 'function' | 'array'} ObserverPropertyType */\n\n/**\n * @template {ObserverPropertyType} T\n * @typedef {(\n * T extends 'boolean' ? boolean\n * : T extends 'string' ? string\n * : T extends 'float' | 'integer' ? number\n * : T extends 'array' ? any[]\n * : T extends 'object' ? any\n * : T extends 'function' ? (...args:any) => any\n * : unknown\n * )} ParsedObserverPropertyType\n */\n\n/**\n * @template {ObserverPropertyType} T1\n * @template {any} T2\n * @template {Object} [C=any]\n * @typedef {Object} ObserverOptions\n * @prop {T1} [type]\n * @prop {boolean} [enumerable]\n * @prop {boolean|'write'|'read'} [reflect]\n * @prop {string} [attr]\n * @prop {boolean} [readonly]\n * Defaults to false if type is boolean\n * @prop {boolean} [nullable]\n * @prop {T2} [empty]\n * @prop {T2} [value]\n * @prop {(this:C, data:Partial<C>, fn?: () => T2) => T2} [get]\n * Function used when null passed\n * @prop {(this:C, value:any)=>T2} [parser]\n * @prop {(this:C, value:null|undefined)=>T2} [nullParser]\n * @prop {(this:C, value: T2, fn?:(value2: T2) => any) => any} [set]\n * Function used when comparing\n * @prop {(this:C, a:T2, b:T2)=> any} [diff]\n * @prop {(this:C, a:T2, b:T2)=>boolean} [is]\n * Simple callback\n * @prop {(this:C, oldValue:T2, newValue:T2, changes:any)=>any} [changedCallback]\n * Named callback\n * @prop {(this:C, name:string, oldValue: T2, newValue: T2, changes:any) => any} [propChangedCallback]\n * Attribute callback\n * @prop {(this:C, name:keyof C & string, oldValue: string, newValue: string) => any} [attributeChangedCallback]\n * @prop {[keyof C & string, (this:C, ...args:any[]) => any][]} [watchers]\n * @prop {Set<keyof C & string>} [props]\n * @prop {WeakMap<C,T2>} [values]\n * @prop {WeakMap<C, T2>} [computedValues]\n * @prop {WeakSet<C>} [needsSelfInvalidation]\n */\n\n/**\n * @template {ObserverPropertyType} T1\n * @template {any} [T2=any]\n * @template {Object} [C=any]\n * @template {keyof C & string} [K=any]\n * @typedef {ObserverOptions<T1, T2, C> & { key: K, values?: WeakMap<C, T2>; attrValues?: WeakMap<C, string> }} ObserverConfiguration\n */\n\n/**\n * @param {ObserverPropertyType} type\n * @return {any}\n */\nfunction emptyFromType(type) {\n switch (type) {\n case 'boolean':\n return false;\n case 'integer':\n case 'float':\n return 0;\n case 'map':\n return new Map();\n case 'set':\n return new Set();\n case 'array':\n return [];\n case 'object':\n return null;\n default:\n case 'string':\n return '';\n }\n}\n\n/**\n * @template {Object} T\n * @param {T} proxyTarget\n * @param {Set<string>} set\n * @param {Set<string>} deepSet\n * @param {string} [prefix]\n * @return {T}\n */\nfunction buildProxy(proxyTarget, set, deepSet, prefix) {\n // @ts-ignore\n proxyTarget ??= {};\n return new Proxy(proxyTarget, {\n get(target, p) {\n // @ts-ignore\n const value = target[p];\n if (typeof p !== 'symbol') {\n const arg = prefix ? `${prefix}.${p}` : p;\n if (prefix) {\n deepSet.add(arg);\n } else {\n set.add(arg);\n }\n if (typeof value === 'object' && value != null) {\n return buildProxy(value, set, deepSet, arg);\n }\n }\n return value;\n },\n has(target, p) {\n const value = Reflect.has(target, p);\n if (typeof p !== 'symbol') {\n const arg = prefix ? `${prefix}.p` : p;\n if (prefix) {\n deepSet.add(arg);\n } else {\n set.add(arg);\n }\n }\n return value;\n },\n });\n}\n\n/**\n * @param {ObserverPropertyType} type\n * @return {any}\n */\nfunction defaultParserFromType(type) {\n switch (type) {\n case 'boolean':\n /**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean#boolean_coercion\n * @param {any} v\n * @return {boolean}\n */\n return (v) => !!v;\n case 'integer':\n // Calls ToNumber(x)\n return Math.round;\n case 'float':\n /**\n * Doesn't support `BigInt` types\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number#number_coercion\n * @param {any} v\n * @return {number}\n */\n return (v) => +v;\n case 'map':\n return Map;\n case 'set':\n return Set;\n case 'object':\n case 'array':\n /**\n * Reflect self\n * @template T\n * @param {T} o\n * @return {T}\n */\n return (o) => o;\n default:\n case 'string':\n /**\n * Doesn't support `Symbol` types\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String#string_coercion\n * @param {any} v\n * @return {string}\n */\n return (v) => `${v}`;\n }\n}\n\n/**\n * @param {(data: Partial<any>) => any} fn\n * @param {...any} args\n * @this {any}\n * @return {{\n * props: {\n * this: string[],\n * args: string[][],\n * },\n * deepPropStrings: {\n * this: string[],\n * args: string[][],\n * },\n * deepProps: {\n * this: string[][],\n * args: string[][][],\n * },\n * defaultValue: any,\n * reusable: boolean,\n * }}\n */\nexport function observeFunction(fn, ...args) {\n /** @type {Set<string>} */\n const thisPoked = new Set();\n /** @type {Set<string>} */\n const thisPokedDeep = new Set();\n\n const argWatchers = args.map((arg) => {\n const poked = new Set();\n const pokedDeep = new Set();\n const proxy = buildProxy(arg, poked, pokedDeep);\n return { poked, pokedDeep, proxy };\n });\n\n const thisProxy = buildProxy(this ?? {}, thisPoked, thisPokedDeep);\n const defaultValue = fn.apply(thisProxy, argWatchers.map((watcher) => watcher.proxy));\n /* Arrow functions can reused if they don't poke `this` */\n const reusable = fn.name ? true : !thisPoked.size;\n\n return {\n props: {\n this: [...thisPoked],\n args: argWatchers.map((watcher) => [...watcher.poked]),\n },\n deepPropStrings: {\n this: [...thisPokedDeep],\n args: argWatchers.map((watcher) => [...watcher.pokedDeep]),\n },\n deepProps: {\n this: [...thisPokedDeep].map((deepPropString) => deepPropString.split('.')),\n args: argWatchers.map((watcher) => [...watcher.pokedDeep].map((deepPropString) => deepPropString.split('.'))),\n },\n defaultValue,\n reusable,\n };\n}\n\n/** @return {null} */\nfunction defaultNullParser() { return null; }\n\n/**\n * @template {string} K\n * @template {ObserverPropertyType} [T1=any]\n * @template {any} [T2=ParsedObserverPropertyType<T1>]\n * @template {Object} [C=any]\n * @param {K} name\n * @param {T1|ObserverOptions<T1,T2>} [typeOrOptions='string']\n * @param {any} [object]\n * @return {ObserverConfiguration<T1,T2,C,K> & ObserverOptions<T1,T2,C>}\n */\nexport function parseObserverOptions(name, typeOrOptions, object) {\n /** @type {Partial<ObserverOptions<T1,T2>>} */\n const options = (typeof typeOrOptions === 'string')\n ? { type: typeOrOptions }\n : typeOrOptions;\n\n let {\n watchers, value, readonly,\n empty, type,\n enumerable, reflect, attr,\n nullable, parser, nullParser,\n get,\n is, diff,\n props,\n } = options;\n\n watchers ??= [];\n readonly ??= false;\n\n if (empty === undefined) {\n empty = null;\n }\n\n value ??= empty;\n\n if (get && !props) {\n // Custom `get` uses computed values.\n // Invalidate computed value when dependent `prop` changes\n const observeResult = observeFunction(get.bind(object), object, () => value);\n value ??= observeResult.defaultValue;\n const uniqueProps = new Set([\n ...observeResult.props.this,\n ...observeResult.props.args[0],\n ]);\n props = uniqueProps;\n }\n\n /** @type {ObserverPropertyType} */\n if (!type) {\n if (value == null) {\n // @ts-ignore\n type = 'string';\n } else {\n const parsed = typeof value;\n // @ts-ignore\n type = (parsed === 'number')\n ? (Number.isInteger(value) ? 'integer' : 'number')\n : parsed;\n }\n }\n\n enumerable ??= name[0] !== '_';\n nullable ??= (type === 'boolean') ? false : (empty == null);\n if (!nullable) {\n empty ??= emptyFromType(type);\n value ??= empty;\n }\n\n reflect ??= enumerable ? (type !== 'object') : (attr ? 'write' : false);\n attr ??= (reflect ? attrNameFromPropName(name) : null);\n\n // if defined ? value\n // else if boolean ? false\n // else if onNullish ? false\n // else if empty == null\n parser ??= defaultParserFromType(type);\n if (!nullParser) {\n if (nullable) {\n nullParser = defaultNullParser;\n } else {\n nullParser = (empty === null)\n ? () => emptyFromType(type)\n : () => empty;\n }\n }\n\n is ??= (type === 'object')\n ? (a, b) => !hasMergePatch(a, b)\n : ((type === 'array') ? () => false : Object.is);\n\n if (diff === undefined) {\n // @ts-ignore\n diff = ((type === 'object') ? (a, b) => buildMergePatch(a, b, 'reference') : null);\n }\n\n return {\n ...options,\n type,\n is,\n diff,\n attr,\n reflect,\n readonly,\n enumerable,\n value,\n parser,\n nullParser,\n key: name,\n // @ts-ignore Can't cast\n props,\n // @ts-ignore Can't cast\n watchers,\n };\n}\n\n/**\n * @this {ObserverConfiguration<?,?,?>}\n * @param {*} value\n */\nexport function parsePropertyValue(value) {\n let newValue = value;\n newValue = value == null\n ? this.nullParser.call(this, value)\n : this.parser.call(this, newValue);\n return newValue;\n}\n\n/**\n * @param {ObserverConfiguration<?,?,?,?>} config\n * @param {any} oldValue\n * @param {any} value\n * @return {boolean} changed\n */\nfunction detectChange(config, oldValue, value) {\n if (config.get) {\n // TODO: Custom getter vs parser\n }\n\n // Compute real new value after parsing\n const newValue = (value == null)\n ? config.nullParser.call(this, value)\n : config.parser.call(this, value);\n\n // Default change is the newValue\n let changes = newValue;\n\n // Null check\n if (oldValue == null) {\n if (newValue == null) {\n // Both nullish\n return false;\n }\n } else if (newValue != null) {\n // Both non-null, compare\n if (config.diff) {\n // Custom change diff\n changes = config.diff.call(this, oldValue, newValue);\n if (changes == null) {\n // No difference\n return false;\n }\n } else if (config.is.call(this, oldValue, newValue)) {\n // Non-equal\n return false;\n }\n }\n\n // Commit value\n if (config.values) {\n config.values.set(this, newValue);\n } else {\n config.values = new WeakMap([[this, newValue]]);\n }\n\n // Emit change\n\n config.propChangedCallback?.call(this, config.key, oldValue, newValue, changes);\n config.changedCallback?.call(this, oldValue, newValue, changes);\n\n return true;\n}\n\n/**\n * @template {ObserverPropertyType} T1\n * @template {any} T2\n * @template {Object} C\n * @template {keyof C & string} K\n * @param {C} object\n * @param {K} key\n * @param {ObserverOptions<T1, T2, C>} options\n * @return {ObserverConfiguration<T1,T2,C,K>}\n */\nexport function defineObservableProperty(object, key, options) {\n const config = /** @type {ObserverConfiguration<T1,T2,C,K>} */ (\n parseObserverOptions(key, options, object));\n\n /**\n * @this {C}\n * @return {T2}\n */\n function internalGet() {\n return config.values?.has(this) ? config.values.get(this) : config.value;\n }\n\n /**\n * @this {C}\n * @param {T2} value\n * @return {void}\n */\n function internalSet(value) {\n // @ts-ignore\n const oldValue = this[key];\n detectChange.call(this, config, oldValue, value);\n }\n\n /** @return {void} */\n function onInvalidate() {\n // Current value is now invalidated. Recompute and check if changed\n // eslint-disable-next-line no-multi-assign\n\n const oldValue = config.computedValues?.get(this);\n const newValue = this[key];\n config.needsSelfInvalidation?.delete(this);\n detectChange.call(this, config, oldValue, newValue);\n }\n\n if (config.props) {\n for (const prop of config.props) {\n config.watchers.push([prop, onInvalidate]);\n }\n }\n\n /**\n * @this {C}\n * @return {T2}\n */\n function cachedGet() {\n const newValue = config.get.call(this, this, internalGet.bind(this));\n // Store computed value internally. Used by onInvalidate to get previous value\n // eslint-disable-next-line no-multi-assign\n const computedValues = (config.computedValues ??= new WeakMap());\n computedValues.set(this, newValue);\n return newValue;\n }\n\n /**\n * @this {C}\n * @param {T2} value\n * @return {void}\n */\n function cachedSet(value) {\n if (config.needsSelfInvalidation) {\n config.needsSelfInvalidation.add(this);\n } else {\n config.needsSelfInvalidation = new WeakSet([this]);\n }\n const oldValue = this[key];\n config.set.call(this, value, internalSet.bind(this));\n const newValue = this[key];\n if (!config.needsSelfInvalidation.has(this)) return;\n config.needsSelfInvalidation.delete(this);\n detectChange.call(this, config, oldValue, newValue);\n }\n\n /** @type {Partial<PropertyDescriptor>} */\n const descriptor = {\n enumerable: config.enumerable,\n configurable: true,\n get: config.get ? cachedGet : internalGet,\n set: config.set ? cachedSet : internalSet,\n };\n\n Object.defineProperty(object, key, descriptor);\n\n return config;\n}\n", "/** @type {Set<string>} */\nconst generatedUIDs = new Set();\n\n/**\n * @param {string} [prefix='x'] Prefix all UIDs by string to apply a name or ensure starts with [A-Z] character\n * @param {number} [n] Maximum number of variations needed. Calculated as 32^n.\n @return {string} */\nexport function generateUID(prefix = 'mdw_', n = 4) {\n let id;\n while (generatedUIDs.has(id = Math.random().toString(36).slice(2, n + 2)));\n generatedUIDs.add(id);\n return `${prefix}${id}`;\n}\n", "import { generateUID } from './uid.js';\n\n/**\n * Property are bound to an ID+Node\n * Values are either getter or via an function\n * @template {any} T\n * @typedef {Object} InlineFunctionEntry\n * @prop {(data:T) => any} fn\n * @prop {string[]} [props]\n * @prop {string[][]} [deepProps]\n * @prop {string[]} [injectionProps]\n * @prop {string[][]} [injectionDeepProps]\n * @prop {T} [defaultValue]\n */\n\n/** @type {Document} */\nlet _inactiveDocument;\n\n/** @type {DocumentFragment} */\nlet _blankFragment;\n\n/** @type {Range} */\nlet _fragmentRange;\n\n/**\n * @param {string} [fromString]\n * @return {DocumentFragment}\n */\nexport function generateFragment(fromString) {\n _inactiveDocument ??= document.implementation.createHTMLDocument();\n if (!fromString) {\n _blankFragment ??= _inactiveDocument.createDocumentFragment();\n return /** @type {DocumentFragment} */ (_blankFragment.cloneNode());\n }\n _fragmentRange ??= _inactiveDocument.createRange();\n return _fragmentRange.createContextualFragment(fromString);\n}\n\n/** @type {Map<string, InlineFunctionEntry<?>>} */\nexport const inlineFunctions = new Map();\n\n/**\n * @template T\n * @typedef {Object} RenderOptions\n * @prop {Object} context\n * @prop {ParentNode} root\n * @prop {Object<string, HTMLElement>} refs\n */\n\n/**\n * @param {(data: Partial<any>) => any} fn\n * @return {string}\n */\nexport function addInlineFunction(fn) {\n const internalName = `#${generateUID()}`;\n inlineFunctions.set(internalName, { fn });\n return `{${internalName}}`;\n}\n\n/** @type {Map<string, DocumentFragment>} */\nconst fragmentCache = new Map();\n/**\n * @template T1\n * @template T2\n * @param {TemplateStringsArray} strings\n * @param {...(string|DocumentFragment|Element|((this:T1, data:T2) => any))} substitutions\n * @return {DocumentFragment}\n */\nexport function html(strings, ...substitutions) {\n /** @type {Map<string, DocumentFragment|Element>} */\n let tempSlots;\n const replacements = substitutions.map((sub) => {\n switch (typeof sub) {\n case 'string': return sub;\n case 'function': return addInlineFunction(sub);\n case 'object': {\n if (sub == null) {\n console.warn(sub, 'is null', strings);\n return '';\n }\n // Assume Element\n const tempId = generateUID();\n tempSlots ??= new Map();\n tempSlots.set(tempId, sub);\n return `<div id=\"${tempId}\"></div>`;\n }\n default:\n throw new Error(`Unexpected substitution: ${sub}`);\n }\n });\n const compiledString = String.raw({ raw: strings }, ...replacements);\n\n if (tempSlots) {\n const fragment = generateFragment(compiledString);\n for (const [id, element] of tempSlots) {\n const slot = fragment.getElementById(id);\n slot.replaceWith(element);\n }\n return fragment;\n }\n\n let fragment;\n if (fragmentCache.has(compiledString)) {\n fragment = fragmentCache.get(compiledString);\n } else {\n fragment = generateFragment(compiledString);\n fragmentCache.set(compiledString, fragment);\n }\n\n return /** @type {DocumentFragment} */ (fragment.cloneNode(true));\n}\n", "/* eslint-disable sort-class-members/sort-class-members */\n\nimport CompositionAdapter from './CompositionAdapter.js';\nimport { generateCSSStyleSheets, generateHTMLStyleElements } from './css.js';\nimport { observeFunction } from './observe.js';\nimport { createEmptyComment, createEmptyTextNode } from './optimizations.js';\nimport { generateFragment, inlineFunctions } from './template.js';\nimport { generateUID } from './uid.js';\n\n/**\n * @template T\n * @typedef {Composition<?>|HTMLStyleElement|CSSStyleSheet|DocumentFragment|string} CompositionPart\n */\n\n/**\n * @template {any} T\n * @callback Compositor\n * @param {...(CompositionPart<T>)} parts source for interpolation (not mutated)\n * @return {Composition<T>}\n */\n\n/**\n * @template T\n * @typedef {Object} RenderOptions\n * @prop {T} [defaults] what\n * @prop {T} [store] what\n * @prop {DocumentFragment|HTMLElement|Element} [target] where\n * @prop {ShadowRoot} [shadowRoot] where\n * @prop {any} [context] `this` on callbacks/events\n * @prop {any} [injections]\n */\n\n/**\n * @template T\n * @typedef {{\n * target: Element|DocumentFragment,\n * byProp: (prop: keyof T & string, value:any, data?:Partial<T>) => void,\n * state: InitializationState,\n * } & ((changes:Partial<T>, data:T) => void)} RenderDraw\n */\n\n/** @typedef {HTMLElementEventMap & { input: InputEvent; } } HTMLElementEventMapFixed */\n\n/**\n * @typedef {(\n * Pick<HTMLElementEventMapFixed,\n * 'auxclick' |\n * 'beforeinput' |\n * 'click' |\n * 'compositionstart' |\n * 'contextmenu' |\n * 'drag' |\n * 'dragenter' |\n * 'dragover' |\n * 'dragstart' |\n * 'drop' |\n * 'invalid' |\n * 'keydown' |\n * 'keypress' |\n * 'keyup' |\n * 'mousedown' |\n * 'mousemove' |\n * 'mouseout' |\n * 'mouseover' |\n * 'mouseup' |\n * 'pointerdown' |\n * 'pointermove' |\n * 'pointerout' |\n * 'pointerover' |\n * 'pointerup' |\n * 'reset' |\n * 'selectstart' |\n * 'submit' |\n * 'touchend' |\n * 'touchmove' |\n * 'touchstart' |\n * 'wheel'\n * >\n * )} HTMLElementCancellableEventMap\n */\n\n/**\n * @typedef {(\n * HTMLElementEventMapFixed\n * & {[P in keyof HTMLElementCancellableEventMap as `~${P}`]: HTMLElementCancellableEventMap[P]}\n * & Record<string, Event|CustomEvent<any>>\n * )} CompositionEventMap\n */\n\n/**\n * @template {any} T\n * @template {keyof CompositionEventMap} [K = keyof CompositionEventMap]\n * @typedef {{\n * type?: K\n * tag?: string|symbol,\n * capture?: boolean;\n * once?: boolean;\n * passive?: boolean;\n * signal?: AbortSignal;\n * handleEvent?: (\n * this: T,\n * event: (K extends keyof CompositionEventMap ? CompositionEventMap[K] : Event) & {currentTarget:HTMLElement}\n * ) => any;\n * prop?: string;\n * deepProp?: string[],\n * }} CompositionEventListener\n */\n\n/**\n * @template T\n * @typedef {{\n * [P in keyof CompositionEventMap]?: (keyof T & string)\n * | ((this: T, event: CompositionEventMap[P] & {currentTarget:HTMLElement}) => any)\n * | CompositionEventListener<T, P>\n * }} CompositionEventListenerObject\n */\n\n/**\n * @template {any} T\n * @typedef {Object} NodeBindEntry\n * @prop {string} [key]\n * @prop {number} [index]\n * @prop {string} tag\n * @prop {string|number} subnode Index of childNode or attrName\n * @prop {string[]} props\n * @prop {string[][]} deepProps\n * @prop {boolean} [negate]\n * @prop {boolean} [doubleNegate]\n * @prop {Function} [expression]\n * @prop {(options: RenderOptions<?>, element: Element, changes:any, data:any) => any} [render] custom render function\n * @prop {CompositionEventListener<T>[]} [listeners]\n * @prop {Composition<any>} [composition] // Sub composition templating (eg: array)\n * @prop {T} defaultValue\n */\n\n/** @typedef {any[]} RenderState */\n\n/**\n * @typedef RenderGraphSearch\n * @prop {(state:InitializationState, changes:any, data:any) => any} invocation\n * @prop {number} cacheIndex\n * @prop {number} searchIndex\n * @prop {string | Function | string[]} query\n * @prop {boolean} [negate]\n * @prop {boolean} [doubleNegate]\n * @prop {Function} [expression]\n * @prop {string} prop\n * @prop {string[]} deepProp\n * @prop {string[]} propsUsed\n * @prop {string[][]} deepPropsUsed\n * @prop {any} defaultValue\n * @prop {RenderGraphSearch} [subSearch]\n */\n\n/**\n * @typedef RenderGraphAction\n * @prop {(state:InitializationState, value:any, changes: any, data:any) => any} invocation\n * @prop {number} [commentIndex]\n * @prop {number} [nodeIndex]\n * @prop {number} [cacheIndex]\n * @prop {string} [attrName]\n * @prop {any} [defaultValue]\n * @prop {RenderGraphSearch} search\n * @prop {InterpolateOptions['injections']} [injections]\n */\n\n/**\n * @type {RenderGraphAction['invocation']}\n * @this {RenderGraphAction}\n */\nfunction writeDOMAttribute({ nodes }, value) {\n const { nodeIndex, attrName } = this;\n const element = /** @type {Element} */ (nodes[nodeIndex]);\n switch (value) {\n case undefined:\n case null:\n case false:\n element.removeAttribute(attrName);\n return false;\n case true:\n element.setAttribute(attrName, '');\n return '';\n default:\n element.setAttribute(attrName, value);\n return value;\n }\n}\n\n/**\n * @type {RenderGraphAction['invocation']}\n * @this {RenderGraphAction}\n */\nfunction writeDynamicNode({ nodeStates, comments, nodes }, value) {\n const { commentIndex, nodeIndex } = this;\n const nodeState = nodeStates[nodeIndex];\n // eslint-disable-next-line no-bitwise\n const hidden = nodeState & 0b0001;\n const show = value != null && value !== false;\n if (!show) {\n // Should be hidden\n if (hidden) return;\n // Replace whatever node is there with the comment\n let comment = comments[commentIndex];\n if (!comment) {\n comment = createEmptyComment();\n comments[commentIndex] = comment;\n }\n nodes[nodeIndex].replaceWith(comment);\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] |= 0b0001;\n return;\n }\n // Must be shown\n // Update node first (offscreen rendering)\n const node = nodes[nodeIndex];\n // eslint-disable-next-line no-bitwise\n const isDynamicNode = nodeState & 0b0010;\n\n if (typeof value === 'object') {\n // Not string data, need to replace\n console.warn('Dynamic nodes not supported yet');\n } else if (isDynamicNode) {\n const textNode = new Text(value);\n node.replaceWith(textNode);\n nodes[nodeIndex] = textNode;\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] &= ~0b0010;\n } else {\n /** @type {Text} */ (node).data = value;\n }\n\n // Updated, now set hidden state\n\n if (hidden) {\n const comment = comments[commentIndex];\n comment.replaceWith(node);\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] &= ~0b0001;\n }\n // Done\n}\n\n/**\n * @type {RenderGraphAction['invocation']}\n * @this {RenderGraphAction}\n */\nfunction writeDOMElementAttachedState({ nodeStates, nodes, comments }, value) {\n const { commentIndex, nodeIndex } = this;\n // eslint-disable-next-line no-bitwise\n const hidden = nodeStates[nodeIndex] & 1;\n const show = value != null && value !== false;\n if (show === !hidden) return;\n\n const element = nodes[nodeIndex];\n let comment = comments[commentIndex];\n if (!comment) {\n comment = createEmptyComment();\n comments[commentIndex] = comment;\n }\n if (show) {\n comment.replaceWith(element);\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] &= ~0b0001;\n } else {\n element.replaceWith(comment);\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] |= 0b0001;\n }\n}\n\n/**\n * @type {RenderGraphAction['invocation']}\n * @this {RenderGraphAction}\n */\nfunction writeDOMHideNodeOnInit({ comments, nodeStates, nodes }) {\n const { commentIndex, nodeIndex } = this;\n\n const comment = createEmptyComment();\n comments[commentIndex] = comment;\n // eslint-disable-next-line no-bitwise\n nodeStates[nodeIndex] |= 1;\n\n nodes[nodeIndex].replaceWith(comment);\n}\n\n/**\n * @param {RenderGraphSearch} search\n * @param {Parameters<RenderGraphSearch['invocation']>} args\n */\nfunction executeSearch(search, ...args) {\n const [{ caches, searchStates }] = args;\n const { cacheIndex, searchIndex, subSearch, invocation } = search;\n const cachedValue = caches[cacheIndex];\n const searchState = searchStates[searchIndex];\n\n // Ran = 0b0001\n // Dirty = 0b0010\n // eslint-disable-next-line no-bitwise\n if (searchState & 0b0001) {\n // Return last result\n return {\n value: cachedValue,\n // eslint-disable-next-line no-bitwise\n dirty: ((searchState & 0b0010) === 0b0010),\n };\n }\n\n // eslint-disable-next-line no-bitwise\n searchStates[searchIndex] |= 0b0001;\n let result;\n if (invocation) {\n if (subSearch) {\n const subResult = executeSearch(subSearch, ...args);\n // Use last cached value (if any)\n if (!subResult.dirty && cachedValue !== undefined) {\n // eslint-disable-next-line no-bitwise\n searchStates[searchIndex] &= ~0b0010;\n return { value: cachedValue, dirty: false };\n }\n // Pass from subquery\n result = search.invocation(subResult.value);\n } else {\n result = search.invocation(...args);\n }\n if ((result === undefined) || (cachedValue === result)) {\n // Return from cache\n return { value: result, dirty: false };\n }\n }\n\n // Overwrite cache and flag as dirty\n caches[cacheIndex] = result;\n // eslint-disable-next-line no-bitwise\n searchStates[searchIndex] |= 0b0010;\n return { value: result, dirty: true };\n}\n\n/**\n * @type {RenderGraphSearch['invocation']}\n * @this {RenderGraphSearch}\n */\nfunction searchWithExpression({ options: { context, store, injections } }, changes, data) {\n return this.expression.call(\n context,\n store ?? data,\n injections,\n );\n}\n\n/**\n * @type {RenderGraphSearch['invocation']}\n * @this {RenderGraphSearch}\n */\nfunction searchWithProp(state, changes) {\n return changes[this.prop];\n}\n\n/**\n * @type {RenderGraphSearch['invocation']}\n * @this {RenderGraphSearch}\n */\nfunction searchWithDeepProp(state, changes, data) {\n let scope = changes;\n for (const prop of this.deepProp) {\n if (scope === null) return null;\n if (prop in scope === false) return undefined;\n scope = scope[prop];\n }\n return scope;\n}\n\n/**\n * @typedef InterpolateOptions\n * @prop {Record<string,any>} [defaults] Default values to use for interpolation\n * @prop {{iterable:string} & Record<string,any> & {index:number}} [injections] Context-specific injected properties. (Experimental)\n */\n\n/**\n * @typedef InitializationState\n * @prop {Element} lastElement\n * @prop {ChildNode} lastChildNode\n * @prop {(Element|Text)[]} nodes\n * @prop {any[]} caches\n * @prop {Comment[]} comments\n * @prop {Uint8Array} nodeStates\n * @prop {Uint8Array} searchStates\n * @prop {HTMLElement[]} refs\n * @prop {number} lastChildNodeIndex\n * @prop {RenderOptions<?>} options\n */\n\n/** Splits: `{template}text{template}` as `['', 'template', 'text', 'template', '']` */\nconst STRING_INTERPOLATION_REGEX = /{([^}]*)}/g;\n\n/**\n * Returns event listener bound to shadow root host.\n * Use this function to avoid generating extra closures\n * @this {HTMLElement}\n * @param {Function} fn\n */\nfunction buildShadowRootChildListener(fn) {\n /** @param {Event & {currentTarget:{getRootNode: () => ShadowRoot}}} event */\n return function onShadowRootChildEvent(event) {\n const host = event.currentTarget.getRootNode().host;\n fn.call(host, event);\n };\n}\n\n/**\n * @example\n * propFromObject('foo', {foo:'bar'}) == ['foo', 'bar'];\n * @param {string} prop\n * @param {any} source\n * @return {any}\n */\nfunction propFromObject(prop, source) {\n if (source) {\n return source[prop];\n }\n return undefined;\n}\n\n/**\n * @example\n * deepPropFromObject(\n * ['address', 'home, 'houseNumber'],\n * {\n * address: {\n * home: {\n * houseNumber:35,\n * },\n * }\n * }\n * ) == [houseNumber, 35]\n * @param {string[]} nameArray\n * @param {any} source\n * @return {any}\n */\nfunction deepPropFromObject(nameArray, source) {\n if (!source) return undefined;\n let scope = source;\n let prop;\n for (prop of nameArray) {\n if (typeof scope === 'object') {\n if (scope === null) return null;\n if (!(prop in scope)) return undefined;\n scope = scope[prop];\n } else {\n return scope[prop];\n }\n }\n return scope;\n}\n\n/**\n * @param {string} prop\n * @param {any} source\n * @return {any}\n */\nfunction valueFromPropName(prop, source) {\n let value = source;\n for (const child of prop.split('.')) {\n if (!child) return null;\n // @ts-ignore Skip cast\n value = value[child];\n if (value == null) return null;\n }\n if (value === source) return null;\n return value;\n}\n\nconst compositionCache = new Map();\n\n/** @template T */\nexport default class Composition {\n static EVENT_PREFIX_REGEX = /^([*1~]+)?(.*)$/;\n\n _interpolationState = {\n nodeIndex: -1,\n searchIndex: 0,\n cacheIndex: 0,\n commentIndex: 0,\n /** @type {this['nodesToBind'][0]} */\n nodeEntry: null,\n };\n\n // eslint-disable-next-line symbol-description\n static shadowRootTag = Symbol();\n\n /** @type {{tag:string, textNodes: number[]}[]} */\n nodesToBind = [];\n\n /** @type {string[]} */\n props = [];\n\n /** @type {RenderGraphSearch[]} */\n searches = [];\n\n /** @type {any[]} */\n initCache = [];\n\n /**\n * Index of searches by query (dotted notation for deep props)\n * @type {Map<Function|string, RenderGraphSearch>}\n */\n searchByQuery;\n\n /**\n * Index of searches by query (dotted notation for deep props)\n * @type {Map<string, RenderGraphAction[]>}\n */\n actionsByPropsUsed;\n\n /** @type {RenderGraphAction[]} */\n postInitActions = [];\n\n /** @type {Set<string>} */\n tagsWithBindings;\n\n /**\n * Array of element tags\n * @type {string[]}\n */\n tags = [];\n\n /**\n * Data of arrays used in templates\n * Usage of a [mdw-for] will create an ArrayLike expectation based on key\n * Only store metadata, not actual data. Currently only needs length.\n * TBD if more is needed later\n * Referenced by property key (string)\n * @type {CompositionAdapter<T>}\n */\n adapter;\n\n /**\n * Collection of events to bind.\n * Indexed by ID\n * @type {Map<string|symbol, CompositionEventListener<any>[]>}\n */\n events;\n\n /**\n * Snapshot of composition at initial state.\n * This fragment can be cloned for first rendering, instead of calling\n * of using `render()` to construct the initial DOM tree.\n * @type {DocumentFragment}\n */\n cloneable;\n\n /** @type {(HTMLStyleElement|CSSStyleSheet)[]} */\n styles = [];\n\n /** @type {CSSStyleSheet[]} */\n adoptedStyleSheets = [];\n\n /** @type {DocumentFragment} */\n stylesFragment;\n\n /**\n * List of IDs used by template elements\n * May be needed to be removed when adding to non-DocumentFragment\n * @type {string[]}\n */\n allIds = [];\n\n /**\n * Collection of IDs used for referencing elements\n * Not meant for live DOM. Removed before attaching to document\n */\n /** @type {Set<string>} */\n temporaryIds;\n\n /** Flag set when template and styles have been interpolated */\n interpolated = false;\n\n /**\n * @param {(CompositionPart<T>)[]} parts\n */\n constructor(...parts) {\n /**\n * Template used to build interpolation and cloneable\n */\n this.template = generateFragment();\n this.append(...parts);\n }\n\n * [Symbol.iterator]() {\n for (const part of this.styles) {\n yield part;\n }\n yield this.template;\n }\n\n /**\n * @template T\n * @param {ConstructorParameters<typeof Composition<T>>} parts\n * @return {Composition<T>}\n */\n static compose(...parts) {\n for (const [cache, comp] of compositionCache) {\n if (cache.length !== parts.length) continue;\n if (parts.every((part, index) => part === cache[index])) {\n return comp;\n }\n }\n\n const composition = new Composition(...parts);\n compositionCache.set(parts, composition);\n return composition;\n }\n\n /**\n * @param {CompositionPart<T>[]} parts\n */\n append(...parts) {\n for (const part of parts) {\n if (typeof part === 'string') {\n this.append(generateFragment(part.trim()));\n } else if (part instanceof Composition) {\n this.append(...part);\n } else if (part instanceof DocumentFragment) {\n this.template.append(part);\n } else if (part instanceof CSSStyleSheet || part instanceof HTMLStyleElement) {\n this.styles.push(part);\n }\n }\n // Allow chaining\n return this;\n }\n\n /** @param {CompositionEventListener<T>} listener */\n addCompositionEventListener(listener) {\n const key = listener.tag ?? '';\n // eslint-disable-next-line no-multi-assign\n const events = (this.events ??= new Map());\n if (events.has(key)) {\n events.get(key).push(listener);\n } else {\n events.set(key, [listener]);\n }\n return this;\n }\n\n /**\n * @param {string|symbol} tag\n * @param {EventTarget} target\n * @param {any} [context]\n * @return {void}\n */\n #bindCompositionEventListeners(tag, target, context) {\n if (!this.events?.has(tag)) return;\n for (const event of this.events.get(tag)) {\n let listener;\n if (event.handleEvent) {\n listener = event.handleEvent;\n } else if (event.deepProp.length) {\n listener = deepPropFromObject(event.deepProp, this.interpolateOptions.defaults);\n } else {\n listener = propFromObject(event.prop, this.interpolateOptions.defaults);\n }\n target.addEventListener(event.type, context ? listener.bind(context) : listener, event);\n }\n }\n\n /**\n * TODO: Add types and clean up closure leak\n * Updates component nodes based on data.\n * Expects data in JSON Merge Patch format\n * @see https://www.rfc-editor.org/rfc/rfc7386\n * @template {Object} T\n * @param {Partial<T>} changes what specifically\n * @param {T} [data]\n * @param {RenderOptions<T>} [options]\n * @return {RenderDraw<T>} anchor\n */\n render(changes, data, options = {}) {\n if (!this.interpolated) {\n this.interpolate({\n defaults: data ?? changes,\n ...options,\n });\n }\n\n const instanceFragment = /** @type {DocumentFragment} */ (this.cloneable.cloneNode(true));\n\n const shadowRoot = options.shadowRoot;\n const target = shadowRoot ?? options.target ?? instanceFragment.firstElementChild;\n\n /** @type {InitializationState} */\n const initState = {\n lastChildNode: null,\n lastChildNodeIndex: 0,\n lastElement: null,\n nodeStates: new Uint8Array(this._interpolationState.nodeIndex + 1),\n searchStates: new Uint8Array(this._interpolationState.searchIndex),\n comments: [],\n nodes: [],\n caches: this.initCache.slice(),\n refs: [],\n options,\n };\n\n const { nodes, refs, searchStates, caches } = initState;\n for (const { tag, textNodes } of this.nodesToBind) {\n /** @type {Text} */\n let textNode;\n if (tag === '') {\n if (!textNodes.length) {\n console.warn('why was root tagged?');\n continue;\n }\n console.warn('found empty tag??');\n refs.push(null);\n nodes.push(null);\n textNode = /** @type {Text} */ (instanceFragment.firstChild);\n } else {\n const element = instanceFragment.getElementById(tag);\n refs.push(element);\n nodes.push(element);\n this.#bindCompositionEventListeners(tag, element, options.context);\n if (!textNodes.length) continue;\n textNode = /** @type {Text} */ (element.firstChild);\n }\n\n let currentIndex = 0;\n for (const index of textNodes) {\n while (index !== currentIndex) {\n textNode = /** @type {Text} */ (textNode.nextSibling);\n currentIndex++;\n }\n nodes.push(textNode);\n }\n }\n this.#bindCompositionEventListeners('', options.context);\n this.#bindCompositionEventListeners(Composition.shadowRootTag, options.context.shadowRoot, options.context);\n\n for (const action of this.postInitActions) {\n action.invocation(initState);\n }\n\n /**\n * @param {Partial<T>} changes\n * @param {T} data\n */\n const draw = (changes, data) => {\n if (!changes) return;\n let ranSearch = false;\n for (const prop of this.props) {\n if (!this.actionsByPropsUsed?.has(prop)) continue;\n if (!(prop in changes)) continue;\n const actions = this.actionsByPropsUsed.get(prop);\n for (const action of actions) {\n ranSearch = true;\n const { dirty, value } = executeSearch(action.search, initState, changes, data);\n if (dirty) {\n // console.log('dirty, updating from batch', initState.nodes[action.nodeIndex], 'with', value);\n action.invocation(initState, value, changes, data);\n }\n }\n }\n if (!ranSearch) return;\n searchStates.fill(0);\n };\n\n if (shadowRoot) {\n options.context ??= shadowRoot.host;\n if ('adoptedStyleSheets' in shadowRoot) {\n if (this.adoptedStyleSheets.length) {\n shadowRoot.adoptedStyleSheets = [\n ...shadowRoot.adoptedStyleSheets,\n ...this.adoptedStyleSheets,\n ];\n }\n } else if (this.stylesFragment.hasChildNodes()) {\n instanceFragment.prepend(this.stylesFragment.cloneNode(true));\n }\n } else {\n options.context ??= target;\n }\n\n if (changes !== this.interpolateOptions.defaults) {\n // Not default, overwrite nodes\n draw(changes, data);\n }\n\n if (shadowRoot) {\n shadowRoot.append(instanceFragment);\n customElements.upgrade(shadowRoot);\n }\n\n draw.target = target;\n\n /**\n * @param {keyof T & string} prop\n * @param {any} value\n * @param {Partial<T>} [data]\n */\n draw.byProp = (prop, value, data) => {\n if (!this.actionsByPropsUsed?.has(prop)) return;\n let ranSearch = false;\n\n // Update search\n if (this.searchByQuery?.has(prop)) {\n ranSearch = true;\n const search = this.searchByQuery.get(prop);\n const cachedValue = caches[search.cacheIndex];\n if (cachedValue === value) {\n return;\n }\n caches[search.cacheIndex] = value;\n searchStates[search.searchIndex] = 0b0011;\n }\n\n /** @type {Partial<T>} */\n let changes;\n const actions = this.actionsByPropsUsed.get(prop);\n for (const action of actions) {\n if (action.search.query === prop) {\n action.invocation(initState, value);\n } else {\n // @ts-expect-error Skip cast\n changes ??= { [prop]: value };\n data ??= changes;\n ranSearch = true;\n const result = executeSearch(action.search, initState, changes, data);\n if (result.dirty) {\n // console.debug('dirty, updating by prop', prop, initState.nodes[action.nodeIndex], 'with', result.value);\n action.invocation(initState, result.value, changes, data);\n }\n }\n }\n\n if (!ranSearch) return;\n searchStates.fill(0);\n };\n draw.state = initState;\n return draw;\n }\n\n /**\n * @param {Attr|Text} node\n * @param {Element|null} [element]\n * @param {InterpolateOptions} [options]\n * @param {string} [parsedValue]\n * @return {true|undefined} remove node\n */\n #interpolateNode(node, element, options, parsedValue) {\n const { nodeValue, nodeName, nodeType } = node;\n\n /** @type {Attr} */\n let attr;\n /** @type {Text} */\n let text;\n if (nodeType === Node.ATTRIBUTE_NODE) {\n attr = /** @type {Attr} */ (node);\n } else {\n text = /** @type {Text} */ (node);\n }\n\n // Get template strings(s) in node if not passed\n if (parsedValue == null) {\n if (!nodeValue) return;\n const trimmed = nodeValue.trim();\n if (!trimmed) return;\n if (attr || element?.tagName === 'STYLE') {\n if (trimmed[0] !== '{') return;\n const { length } = trimmed;\n if (trimmed[length - 1] !== '}') return;\n parsedValue = trimmed.slice(1, -1);\n // TODO: Support segmented attribute values\n } else {\n // Split text node into segments\n // TODO: Benchmark indexOf pre-check vs regex\n\n const segments = trimmed.split(STRING_INTERPOLATION_REGEX);\n if (segments.length < 3) return;\n if (segments.length === 3 && !segments[0] && !segments[2]) {\n parsedValue = segments[1];\n } else {\n for (const [index, segment] of segments.entries()) {\n // is even = is template string\n if (index % 2) {\n const newNode = createEmptyTextNode();\n text.before(newNode);\n this.#interpolateNode(newNode, element, options, segment);\n } else if (segment) {\n text.before(segment);\n }\n }\n // eslint-disable-next-line consistent-return\n return true;\n }\n }\n }\n\n // Check mutations\n\n const query = parsedValue;\n const negate = parsedValue[0] === '!';\n let doubleNegate = false;\n if (negate) {\n parsedValue = parsedValue.slice(1);\n doubleNegate = parsedValue[0] === '!';\n if (doubleNegate) {\n parsedValue = parsedValue.slice(1);\n }\n }\n\n let isEvent;\n let textNodeIndex;\n\n if (text) {\n // eslint-disable-next-line unicorn/consistent-destructuring\n if (element !== text.parentElement) {\n console.warn('mismatch?');\n element = text.parentElement;\n }\n textNodeIndex = 0;\n /** @type {ChildNode} */\n let prev = text;\n while ((prev = prev.previousSibling)) {\n textNodeIndex++;\n }\n } else {\n // @ts-ignore Skip cast\n // eslint-disable-next-line unicorn/consistent-destructuring\n if (element !== attr.ownerElement) {\n console.warn('mismatch?');\n element = attr.ownerElement;\n }\n if (nodeName.startsWith('on')) {\n // Do not interpolate inline event listeners\n const hyphenIndex = nodeName.indexOf('-');\n if (hyphenIndex === -1) return;\n isEvent = hyphenIndex === 2;\n }\n }\n\n if (isEvent) {\n element.removeAttribute(nodeName);\n const tag = this.#tagElement(element);\n const eventType = nodeName.slice(3);\n const [, flags, type] = eventType.match(/^([*1~]+)?(.*)$/);\n\n let handleEvent;\n /** @type {string} */\n let prop;\n /** @type {string[]} */\n let deepProp = [];\n if (parsedValue.startsWith('#')) {\n handleEvent = inlineFunctions.get(parsedValue).fn;\n } else {\n const parsedProps = parsedValue.split('.');\n if (parsedProps.length === 1) {\n prop = parsedValue;\n deepProp = [];\n } else {\n prop = parsedProps[0];\n deepProp = parsedProps;\n }\n }\n\n this.addCompositionEventListener({\n tag,\n type,\n handleEvent,\n prop,\n deepProp,\n once: flags?.includes('1'),\n passive: flags?.includes('~'),\n capture: flags?.includes('*'),\n });\n\n return;\n }\n\n /** @type {RenderGraphSearch} */\n let search;\n\n if (this.searchByQuery?.has(query)) {\n search = this.searchByQuery.get(query);\n } else {\n // Has subquery?\n const subquery = parsedValue;\n const isSubquery = subquery !== query;\n /** @type {RenderGraphSearch} */\n let subSearch;\n if (isSubquery && this.searchByQuery?.has(subquery)) {\n subSearch = this.searchByQuery.get(subquery);\n } else {\n // Construct subsearch, even is not subquery.\n /** @type {Function} */\n let expression;\n /** @type {string[]} */\n let propsUsed;\n /** @type {string[][]} */\n let deepPropsUsed;\n let defaultValue;\n let prop;\n let deepProp;\n let invocation;\n\n let inlineFunctionOptions;\n // Is Inline Function?\n if (parsedValue.startsWith('#')) {\n inlineFunctionOptions = inlineFunctions.get(parsedValue);\n if (!inlineFunctionOptions) {\n console.warn(`Invalid interpolation value: ${parsedValue}`);\n return;\n }\n expression = inlineFunctionOptions.fn;\n invocation = searchWithExpression;\n if (inlineFunctionOptions.props) {\n // console.log('This function has already been called. Reuse props', inlineFunctionOptions, this);\n propsUsed = inlineFunctionOptions.props;\n deepPropsUsed = inlineFunctionOptions.deepProps;\n defaultValue = inlineFunctionOptions.defaultValue ?? null;\n } else {\n defaultValue = inlineFunctionOptions.fn;\n }\n } else {\n defaultValue = null;\n if (options?.defaults) {\n defaultValue = deepPropFromObject(parsedValue.split('.'), options.defaults) ?? null;\n }\n if (defaultValue == null && options?.injections) {\n defaultValue = valueFromPropName(parsedValue, options.injections);\n // console.log('default value from injection', parsedValue, { defaultValue });\n }\n }\n\n if (!propsUsed) {\n if (typeof defaultValue === 'function') {\n // Value must be reinterpolated and function observed\n const observeResult = observeFunction.call(this, defaultValue, options?.defaults, options?.injections);\n const uniqueProps = new Set([\n ...observeResult.props.this,\n ...observeResult.props.args[0],\n ...observeResult.props.args[1],\n ]);\n const uniqueDeepProps = new Set([\n ...observeResult.deepPropStrings.this,\n ...observeResult.deepPropStrings.args[0],\n ]);\n expression = defaultValue;\n defaultValue = observeResult.defaultValue;\n propsUsed = [...uniqueProps];\n deepPropsUsed = [...uniqueDeepProps].map((deepPropString) => deepPropString.split('.'));\n invocation = searchWithExpression;\n // console.log(this.static.name, fn.name || parsedValue, combinedSet);\n } else {\n // property binding\n const parsedProps = parsedValue.split('.');\n if (parsedProps.length === 1) {\n prop = parsedValue;\n propsUsed = [prop];\n invocation = searchWithProp;\n } else {\n propsUsed = [parsedProps[0]];\n deepProp = parsedProps;\n deepPropsUsed = [parsedProps];\n invocation = searchWithDeepProp;\n }\n\n // TODO: Rewrite property as deep with array index?\n }\n }\n\n if (inlineFunctionOptions) {\n inlineFunctionOptions.defaultValue = defaultValue;\n inlineFunctionOptions.props = propsUsed;\n inlineFunctionOptions.deepProps = deepPropsUsed;\n }\n subSearch = {\n cacheIndex: this._interpolationState.cacheIndex++,\n searchIndex: this._interpolationState.searchIndex++,\n query: subquery,\n defaultValue,\n subSearch: null,\n prop,\n propsUsed,\n deepProp,\n deepPropsUsed,\n invocation,\n expression,\n };\n this.addSearch(subSearch);\n }\n if (isSubquery) {\n search = {\n cacheIndex: this._interpolationState.cacheIndex++,\n searchIndex: this._interpolationState.searchIndex++,\n query,\n subSearch,\n negate,\n doubleNegate,\n prop: subSearch.prop,\n deepProp: subSearch.deepProp,\n propsUsed: subSearch.propsUsed,\n deepPropsUsed: subSearch.deepPropsUsed,\n defaultValue: doubleNegate ? !!subSearch.defaultValue\n : (negate ? !subSearch.defaultValue : subSearch.defaultValue),\n invocation(value) {\n if (this.doubleNegate) return !!value;\n if (this.negate) return !value;\n console.warn('Unknown query mutation', this.query);\n return value;\n },\n };\n this.addSearch(search);\n } else {\n // Store as search instead\n search = subSearch;\n }\n }\n\n // Tag\n let tag;\n let subnode = null;\n let defaultValue = search.defaultValue;\n if (text) {\n subnode = textNodeIndex;\n } else if (nodeName === 'mdw-if') {\n tag = this.#tagElement(element);\n element.removeAttribute(nodeName);\n defaultValue = defaultValue != null && defaultValue !== false;\n } else {\n subnode = nodeName;\n if (nodeName === 'id' || defaultValue == null || defaultValue === false) {\n element.removeAttribute(nodeName);\n } else {\n element.setAttribute(nodeName, defaultValue === true ? '' : defaultValue);\n }\n }\n\n tag ??= this.#tagElement(element);\n\n // Node entry\n let nodeEntry = this._interpolationState.nodeEntry;\n if (!nodeEntry || nodeEntry.tag !== tag) {\n nodeEntry = {\n tag,\n textNodes: [],\n };\n this._interpolationState.nodeEntry = nodeEntry;\n this.nodesToBind.push(nodeEntry);\n this._interpolationState.nodeIndex++;\n }\n\n /** @type {RenderGraphAction} */\n let action;\n\n // Node Action\n if (text) {\n nodeEntry.textNodes.push(textNodeIndex);\n\n this._interpolationState.nodeIndex++;\n action = {\n nodeIndex: this._interpolationState.nodeIndex,\n commentIndex: this._interpolationState.commentIndex++,\n invocation: writeDynamicNode,\n defaultValue,\n search,\n };\n switch (typeof defaultValue) {\n case 'string':\n text.data = defaultValue;\n break;\n case 'number':\n // Manually coerce to string (0 will be empty otherwise)\n text.data = `${defaultValue}`;\n break;\n default:\n text.data = '';\n break;\n }\n } else if (subnode) {\n action = {\n nodeIndex: this._interpolationState.nodeIndex,\n attrName: /** @type {string} */ (subnode),\n defaultValue,\n invocation: writeDOMAttribute,\n search,\n };\n } else {\n action = {\n nodeIndex: this._interpolationState.nodeIndex,\n commentIndex: this._interpolationState.commentIndex++,\n defaultValue,\n invocation: writeDOMElementAttachedState,\n search,\n };\n if (!defaultValue) {\n this.postInitActions.push({\n ...action,\n invocation: writeDOMHideNodeOnInit,\n });\n }\n }\n\n this.addAction(action);\n // eslint-disable-next-line no-multi-assign\n const tagsWithBindings = (this.tagsWithBindings ??= new Set());\n tagsWithBindings.add(tag);\n }\n\n /**\n * @param {Element} element\n * @return {string}\n */\n #tagElement(element) {\n if (!element) return '';\n let id = element.id;\n if (id) {\n if (!this.allIds.includes(id)) {\n this.allIds.push(id);\n }\n } else {\n id = generateUID();\n // eslint-disable-next-line no-multi-assign\n const temporaryIds = (this.temporaryIds ??= new Set());\n temporaryIds.add(id);\n this.allIds.push(id);\n element.id = id;\n }\n return id;\n }\n\n /**\n * TODO: Subtemplating lacks optimization, though functional.\n * - Would benefit from custom type handler for arrays\n * to avoid multi-iteration change-detection.\n * - Could benefit from debounced/throttled render\n * - Consider remap of {item.prop} as {array[index].prop}\n * @param {Element} element\n * @param {InterpolateOptions} options\n * @return {?Composition<?>}\n */\n #interpolateIterable(element, options) {\n // TODO: Microbenchmark element.attributes\n const forAttr = element.getAttribute('mdw-for');\n const trimmed = forAttr?.trim();\n if (!trimmed) {\n console.warn('Malformed mdw-for found at', element);\n return null;\n }\n\n if (trimmed[0] !== '{') {\n console.warn('Malformed mdw-for found at', element);\n return null;\n }\n const { length } = trimmed;\n if (trimmed[length - 1] !== '}') {\n console.warn('Malformed mdw-for found at', element);\n return null;\n }\n const parsedValue = trimmed.slice(1, -1);\n const [valueName, iterableName] = parsedValue.split(/\\s+of\\s+/);\n element.removeAttribute('mdw-for');\n // Create a new composition targetting element as root\n\n const elementAnchor = element.ownerDocument.createElement('template');\n element.replaceWith(elementAnchor);\n const tag = this.#tagElement(elementAnchor);\n // console.log('tagging placeholder element with', elementAnchor, tag);\n\n let nodeEntry = this._interpolationState.nodeEntry;\n if (!nodeEntry || nodeEntry.tag !== tag) {\n nodeEntry = {\n tag,\n textNodes: [],\n };\n this._interpolationState.nodeEntry = nodeEntry;\n this.nodesToBind.push(nodeEntry);\n this._interpolationState.nodeIndex++;\n }\n\n const newComposition = new Composition();\n newComposition.template.append(element);\n // Move uninterpolated element to new composition template.\n /** @type {InterpolateOptions['injections']} */\n const injections = {\n ...options.injections,\n [valueName]: null,\n index: null,\n };\n\n const propsUsed = [iterableName];\n /** @type {RenderGraphSearch} */\n const search = {\n cacheIndex: this._interpolationState.cacheIndex++,\n searchIndex: this._interpolationState.searchIndex++,\n query: null,\n prop: null,\n deepProp: null,\n propsUsed,\n deepPropsUsed: [[iterableName]],\n defaultValue: {},\n invocation: null,\n };\n\n /** @type {RenderGraphAction} */\n const action = {\n defaultValue: null,\n nodeIndex: this._interpolationState.nodeIndex,\n search,\n commentIndex: this._interpolationState.commentIndex++,\n injections,\n invocation(state, value, changes, data) {\n if (!newComposition.adapter) {\n // console.log({ state.options });\n const instanceAnchorElement = state.nodes[this.nodeIndex];\n const anchorNode = createEmptyComment();\n // Avoid leak\n state.comments[this.commentIndex] = anchorNode;\n instanceAnchorElement.replaceWith(anchorNode);\n newComposition.adapter = new CompositionAdapter({\n anchorNode,\n composition: newComposition,\n renderOptions: {\n target: null,\n context: state.options.context,\n store: state.options.store,\n injections: this.injections,\n },\n });\n }\n const { adapter } = newComposition;\n const iterable = (data ?? state.options.store)[iterableName];\n // Remove oversized\n if (!iterable || iterable.length === 0) {\n adapter.removeEntries();\n return;\n }\n const changeList = changes[iterableName];\n const innerChanges = { ...changes };\n const needTargetAll = newComposition.props.some((prop) => prop !== iterableName && prop in changes);\n\n adapter.startBatch();\n let isArray;\n if (!needTargetAll && !(isArray = Array.isArray(changeList))) {\n const iterator = isArray ? changeList.entries() : Object.entries(changeList);\n // console.log('changeList render', iterator);\n for (const [key, change] of iterator) {\n if (key === 'length') continue;\n if (change === null) {\n // console.warn('null?', 'remove?', key);\n continue;\n }\n const index = (+key);\n const resource = iterable[index];\n innerChanges[valueName] = change;\n this.injections[valueName] = resource;\n this.injections.index = index;\n\n adapter.renderData(index, innerChanges, data, resource, change);\n }\n } else {\n if (!changeList) {\n delete innerChanges[valueName];\n }\n // console.log('full array render', iterable);\n for (const [index, resource] of iterable.entries()) {\n let change;\n if (changeList) {\n // console.warn('full array render has changeList?', changeList);\n if (!needTargetAll && !(index in changeList)) {\n console.warn('huh?');\n continue;\n }\n change = changeList[index];\n if (change === null) {\n // console.warn('remove?');\n continue;\n }\n innerChanges[valueName] = change;\n }\n this.injections[valueName] = resource;\n this.injections.index = index;\n\n adapter.renderData(index, innerChanges, data, resource, change);\n // adapter.renderIndex(index, innerChanges, data, resource);\n }\n }\n adapter.stopBatch();\n\n adapter.removeEntries(iterable.length);\n },\n\n };\n\n newComposition.interpolate({\n defaults: options.defaults,\n injections,\n });\n\n propsUsed.push(...newComposition.props);\n this.addSearch(search);\n this.addAction(action);\n // eslint-disable-next-line no-multi-assign\n const tagsWithBindings = (this.tagsWithBindings ??= new Set());\n tagsWithBindings.add(tag);\n // console.log('adding', iterable, 'bind to', this);\n // this.addBinding(iterable, entry);\n return newComposition;\n }\n\n /**\n * @param {InterpolateOptions} [options]\n */\n interpolate(options) {\n this.interpolateOptions = options;\n // console.log('Template', [...this.template.children].map((child) => child.outerHTML).join('\\n'));\n\n // Copy template before working on it\n // Store into `cloneable` to split later into `interpolation`\n this.cloneable = /** @type {DocumentFragment} */ (this.template.cloneNode(true));\n\n const TREE_WALKER_FILTER = 5; /* NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT */\n\n const treeWalker = document.createTreeWalker(this.cloneable, TREE_WALKER_FILTER);\n /** Note: `node` and treeWalker.currentNode may deviate */\n let node = treeWalker.nextNode();\n while (node) {\n /** @type {Element} */\n let element = null;\n switch (node.nodeType) {\n case Node.ELEMENT_NODE:\n element = /** @type {Element} */ (node);\n if (element.tagName === 'TEMPLATE') {\n while (element.contains(node = treeWalker.nextNode()));\n continue;\n }\n\n if (element.tagName === 'SCRIPT') {\n console.warn('<script> element found.');\n while (element.contains(node = treeWalker.nextNode()));\n continue;\n }\n\n if (element.hasAttribute('mdw-for')) {\n while (element.contains(node = treeWalker.nextNode()));\n this.#interpolateIterable(element, options);\n continue;\n } else {\n // @ts-expect-error Bad typings\n const idAttr = element.attributes.id;\n if (idAttr) {\n this.#interpolateNode(idAttr, element, options);\n this.#tagElement(element);\n }\n for (const attr of [...element.attributes].reverse()) {\n if (attr.nodeName === 'id') continue; // Already handled\n this.#interpolateNode(attr, element, options);\n }\n }\n\n break;\n case Node.TEXT_NODE:\n element = node.parentElement;\n if (this.#interpolateNode(/** @type {Text} */ (node), element, options)) {\n const nextNode = treeWalker.nextNode();\n /** @type {Text} */ (node).remove();\n node = nextNode;\n continue;\n }\n break;\n default:\n throw new Error(`Unexpected node type: ${node.nodeType}`);\n }\n node = treeWalker.nextNode();\n }\n\n if ('adoptedStyleSheets' in document) {\n this.adoptedStyleSheets = [\n ...generateCSSStyleSheets(this.styles),\n ];\n } else {\n this.stylesFragment = generateFragment();\n this.stylesFragment.append(\n ...generateHTMLStyleElements(this.styles),\n );\n }\n\n this.props = this.actionsByPropsUsed\n ? [...this.actionsByPropsUsed.keys()]\n : [];\n\n for (const id of this.allIds) {\n if (!this.tagsWithBindings?.has(id)) {\n this.nodesToBind.push({\n tag: id,\n textNodes: [],\n });\n }\n }\n\n this.tags = this.nodesToBind.map((n) => n.tag);\n this.interpolated = true;\n\n // console.log('Cloneable', [...this.cloneable.children].map((child) => child.outerHTML).join('\\n'));\n }\n\n /**\n * @param {RenderGraphSearch} search\n * @return {RenderGraphSearch}\n */\n addSearch(search) {\n this.searches.push(search);\n if (search.query) {\n // eslint-disable-next-line no-multi-assign\n const searchByQuery = (this.searchByQuery ??= new Map());\n searchByQuery.set(search.query, search);\n this.initCache[search.cacheIndex] = search.defaultValue;\n }\n return search;\n }\n\n /**\n * @param {RenderGraphAction} action\n * @return {RenderGraphAction}\n */\n addAction(action) {\n // eslint-disable-next-line no-multi-assign\n const actionsByPropsUsed = (this.actionsByPropsUsed ??= new Map());\n for (const prop of action.search.propsUsed) {\n if (actionsByPropsUsed.has(prop)) {\n actionsByPropsUsed.get(prop).push(action);\n } else {\n actionsByPropsUsed.set(prop, [action]);\n }\n }\n return action;\n }\n}\n", "/* eslint-disable max-classes-per-file */\n\nimport Composition from './Composition.js';\nimport { css } from './css.js';\nimport { attrNameFromPropName, attrValueFromDataValue } from './dom.js';\nimport { applyMergePatch } from './jsonMergePatch.js';\nimport { defineObservableProperty } from './observe.js';\nimport { addInlineFunction, html } from './template.js';\n\n/** @typedef {import('./observe.js').ObserverPropertyType} ObserverPropertyType */\n\n/**\n * @template {any} T\n * @typedef {{\n * [P in keyof T]:\n * T[P] extends (...args:any[]) => infer T2 ? T2\n * : T[P] extends ObserverPropertyType\n * ? import('./observe.js').ParsedObserverPropertyType<T[P]>\n * : T[P] extends {type: ObserverPropertyType}\n * ? import('./observe.js').ParsedObserverPropertyType<T[P]['type']>\n * : T[P] extends ObserverOptions<null, infer T2>\n * ? unknown extends T2 ? string : T2\n * : never\n * }} ParsedProps\n */\n\n/**\n * @template {ObserverPropertyType} T1\n * @template {any} T2\n * @template {Object} [C=any]\n * @typedef {import('./observe.js').ObserverOptions<T1,T2,C>} ObserverOptions\n */\n\n/**\n * @template {{ prototype: unknown; }} T\n * @typedef {T} ClassOf<T>\n */\n\n/**\n * @template {any} [T=any]\n * @template {any[]} [A=any[]]\n * @typedef {abstract new (...args: A) => T} Class\n */\n\n/**\n * @template {any} T1\n * @template {any} [T2=T1]\n * @callback HTMLTemplater\n * @param {TemplateStringsArray} string\n * @param {...(string|DocumentFragment|Element|((this:T1, data:T2) => any))} substitutions\n * @return {DocumentFragment}\n */\n\n/**\n * @template {any} [T1=any]\n * @template {any} [T2=T1]\n * @typedef {Object} CallbackArguments\n * @prop {Composition<T1>} composition\n * @prop {Record<string, HTMLElement>} refs\n * @prop {HTMLTemplater<T1, Partial<T2>>} html\n * @prop {(fn: (this:T1, data: T2) => any) => string} inline\n * @prop {DocumentFragment} template\n * @prop {T1} element\n */\n\n/**\n * @template {any} T1\n * @template {any} [T2=T1]\n * @typedef {{\n * composed?: (this: T1, options: CallbackArguments<T1, T2>) => any,\n * constructed?: (this: T1, options: CallbackArguments<T1, T2>) => any,\n * connected?: (this: T1, options: CallbackArguments<T1, T2>) => any,\n * disconnected?: (this: T1, options: CallbackArguments<T1, T2>) => any,\n * props?: {\n * [P in keyof T1] : (\n * this: T1,\n * oldValue: T1[P],\n * newValue: T1[P],\n * changes:any,\n * element: T1\n * ) => any\n * },\n * attrs?: {[K in keyof any]: (\n * this: T1,\n * oldValue: string,\n * newValue: string,\n * element: T1\n * ) => unknown\n * },\n * } & {\n * [P in keyof T1 & string as `${P}Changed`]?: (\n * this: T1,\n * oldValue: T1[P],\n * newValue: T1[P],\n * changes:any,\n * element: T1\n * ) => any\n * }} CompositionCallback\n */\n\n/**\n * @template {Object} C\n * @typedef {{\n * [P in string] :\n * ObserverPropertyType\n * | ObserverOptions<ObserverPropertyType, unknown, C>\n * | ((this:C, data:Partial<C>, fn?: () => any) => any)\n * }} IDLParameter\n */\n\n/**\n * @template T\n * @typedef {(T | Array<[keyof T & string, T[keyof T]]>)} ObjectOrObjectEntries\n */\n\n/**\n * @template {abstract new (...args: any) => unknown} T\n * @param {InstanceType<T>} instance\n */\nfunction superOf(instance) {\n const staticContext = instance.constructor;\n const superOfStatic = Object.getPrototypeOf(staticContext);\n return superOfStatic.prototype;\n}\n\n/**\n * Clone attribute\n * @param {string} name\n * @param {string} target\n * @return {(oldValue:string, newValue:string, element: CustomElement) => void}\n */\nexport function cloneAttributeCallback(name, target) {\n return (oldValue, newValue, element) => {\n if (newValue == null) {\n element.refs[target].removeAttribute(name);\n } else {\n element.refs[target].setAttribute(name, newValue);\n }\n };\n}\n\n/**\n * Web Component that can cache templates for minification or performance\n */\nexport default class CustomElement extends HTMLElement {\n /** @type {string} */\n static elementName;\n\n /** @return {Iterable<string>} */\n static get observedAttributes() {\n return this.attrList.keys();\n }\n\n /** @type {import('./Composition.js').Compositor<?>} */\n compose() {\n // eslint-disable-next-line no-return-assign\n return (this.#composition ??= new Composition());\n }\n\n /** @type {Composition<?>} */\n static _composition = null;\n\n /** @type {Map<string, import('./observe.js').ObserverConfiguration<?,?,?>>} */\n static _props = new Map();\n\n /** @type {Map<string, import('./observe.js').ObserverConfiguration<?,?,?>>} */\n static _attrs = new Map();\n\n /** @type {Map<string, Array<(this: any, ...args: any[]) => any>>} */\n static _propChangedCallbacks = new Map();\n\n /** @type {Map<string, Array<(this: any, ...args: any[]) => any>>} */\n static _attributeChangedCallbacks = new Map();\n\n /** @type {Array<(callback: CallbackArguments) => any>} */\n static _onComposeCallbacks = [];\n\n /** @type {Array<(callback: CallbackArguments) => any>} */\n static _onConnectedCallbacks = [];\n\n /** @type {Array<(callback: CallbackArguments) => any>} */\n static _onDisconnectedCallbacks = [];\n\n /** @type {Array<(callback: CallbackArguments) => any>} */\n static _onConstructedCallbacks = [];\n\n static interpolatesTemplate = true;\n\n static supportsElementInternals = 'attachInternals' in HTMLElement.prototype;\n\n static supportsElementInternalsRole = CustomElement.supportsElementInternals\n && 'role' in ElementInternals.prototype;\n\n /** @type {boolean} */\n static templatable = null;\n\n static defined = false;\n\n static autoRegistration = true;\n\n /** @type {Map<string, typeof CustomElement>} */\n static registrations = new Map();\n\n /**\n * Expressions are idempotent functions that are selectively called whenever\n * a render is requested.\n * Expressions are constructed exactly as methods though differ in expected\n * arguments. The first argument should be destructured to ensure each used\n * property is accessed at least once in order to inspect used properties.\n *\n * The Composition API will inspect this function with a proxy for `this` to\n * catalog what observables are used by the expression. This allows the\n * Composition API to build a cache as well as selective invoke the expression\n * only when needed.\n *\n * When used with in element templates, the element itself will be passed as\n * its first argument.\n * ````js\n * Button\n * .prop('filled', 'boolean')\n * .prop('outlined', 'boolean')\n * .expresssions({\n * _isFilledOrOutlined({filled, outlined}) {\n * return (filled || outlined)\n * },\n * })\n * .html`<div custom={_isFilledOrOutlined}></div>`;\n * ````\n *\n * When used with external data source, that data source\n * will be passed to the expression with all properties being `null` at first\n * inspection.\n * ````js\n * const externalData = {first: 'John', last: 'Doe'};\n * ContactCard\n * .expresssions({\n * _fullName({first, last}) {\n * return [first, last].filter(Boolean).join(' ');\n * },\n * })\n * myButton.render(externalData);\n * ````\n *\n * Expressions may be support argumentless calls by using default\n * parameters with `this`.\n * ````js\n * Button\n * .expresssions({\n * isFilledOrOutlined({filled, outlined} = this) {\n * return (filled || outlined)\n * },\n * });\n * myButton.isFilledorOutlined();\n * ````\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends {\n * [K in keyof any]: K extends `_${any}` ? ((data: INSTANCE, state?: Record<string, any>) => string|boolean|null)\n * : ((data?: INSTANCE, state?: Record<string, any>) => string|boolean|null)\n * } & ThisType<INSTANCE>\n * >(this: CLASS, expressions: PROPS & ThisType<INSTANCE & PROPS>):\n * CLASS & Class<{\n * [K in keyof PROPS]: K extends `_${any}` ? never : () => ReturnType<PROPS[K]> }\n * ,ARGS>\n * }}\n */\n static expressions = /** @type {any} */ (this.set);\n\n static methods = this.set;\n\n /**\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends Partial<INSTANCE>>\n * (this: CLASS, source: PROPS & ThisType<PROPS & INSTANCE>, options?: Partial<PropertyDescriptor>)\n * : CLASS & Class<PROPS,ARGS>\n * }}\n */\n static overrides = /** @type {any} */ (this.set);\n\n /**\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * KEY extends string,\n * OPTIONS extends ObserverPropertyType\n * | ObserverOptions<ObserverPropertyType, unknown, INSTANCE>\n * | ((this:INSTANCE, data:Partial<INSTANCE>, fn?: () => any) => any),\n * VALUE extends Record<KEY, OPTIONS extends (...args2:any[]) => infer R ? R\n * : OPTIONS extends ObserverPropertyType ? import('./observe.js').ParsedObserverPropertyType<OPTIONS>\n * : OPTIONS extends {type: 'object'} & ObserverOptions<any, infer R> ? (unknown extends R ? object : R)\n * : OPTIONS extends {type: ObserverPropertyType} ? import('./observe.js').ParsedObserverPropertyType<OPTIONS['type']>\n * : OPTIONS extends ObserverOptions<any, infer R> ? (unknown extends R ? string : R)\n * : never\n * >\n * > (this: CLASS, name: KEY, options: OPTIONS)\n * : CLASS & Class<VALUE,ARGS>;\n * }}\n */\n static props = /** @type {any} */ (this.observe);\n\n static idl = this.prop;\n\n /**\n * @this T\n * @template {typeof CustomElement} T\n * @template {keyof T} K\n * @param {K} collection\n * @param {Function} callback\n */\n static _addCallback(collection, callback) {\n if (!this.hasOwnProperty(collection)) {\n // @ts-expect-error not typed\n this[collection] = [...this[collection], callback];\n return;\n }\n // @ts-expect-error any\n this[collection].push(callback);\n }\n\n /**\n * Append parts to composition\n * @type {{\n * <\n * T extends typeof CustomElement,\n * >\n * (this: T, ...parts: ConstructorParameters<typeof Composition<InstanceType<T>>>): T;\n * }}\n */\n static append(...parts) {\n this._onComposeCallbacks.push(({ composition }) => {\n composition.append(...parts);\n });\n\n this._addCallback('_onComposeCallbacks', /** @type {(opts: CallbackArguments) => unknown} */ ((opts) => {\n const { composition } = opts;\n composition.append(...parts);\n }));\n return this;\n }\n\n /**\n * After composition, invokes callback.\n * May be called multiple times.\n * @type {{\n * <\n * T1 extends (typeof CustomElement),\n * T2 extends InstanceType<T1>,\n * T3 extends CompositionCallback<T2, T2>['composed'],\n * >\n * (this: T1, callback: T3): T1\n * }}\n */\n static recompose(callback) {\n this._addCallback('_onComposeCallbacks', callback);\n return this;\n }\n\n /**\n * Appends styles to composition\n * @type {{\n * <\n * T1 extends (typeof CustomElement),\n * T2 extends TemplateStringsArray|HTMLStyleElement|CSSStyleSheet|string>(\n * this: T1,\n * array: T2,\n * ...rest: T2 extends string ? any : T2 extends TemplateStringsArray ? any[] : (HTMLStyleElement|CSSStyleSheet)[]\n * ): T1\n * }}\n */\n static css(array, ...substitutions) {\n this._addCallback('_onComposeCallbacks', /** @type {(opts: CallbackArguments) => unknown} */ ((opts) => {\n const { composition } = opts;\n if (typeof array === 'string' || Array.isArray(array)) {\n // @ts-expect-error Complex cast\n composition.append(css(array, ...substitutions));\n } else {\n // @ts-expect-error Complex cast\n composition.append(array, ...substitutions);\n }\n }));\n\n return this;\n }\n\n /**\n * Registers class with customElements. If class is registered before then,\n * does nothing.\n * @type {{\n * <T extends typeof CustomElement>(this: T, elementName: string): T;\n * }}\n */\n static autoRegister(elementName) {\n if (this.hasOwnProperty('defined') && this.defined) {\n console.warn(this.elementName, 'already registered.');\n return this;\n }\n this.register(elementName);\n return this;\n }\n\n /**\n * Appends DocumentFragment to composition\n * @type {{\n * <T extends typeof CustomElement>(\n * this: T,\n * string: TemplateStringsArray,\n * ...substitutions: (string|Element|((this:InstanceType<T>, data:InstanceType<T>, injections?:any) => any))[]\n * ): T\n * }}\n */\n static html(strings, ...substitutions) {\n this._addCallback('_onComposeCallbacks', /** @type {(opts: CallbackArguments) => unknown} */ ((opts) => {\n const { composition } = opts;\n // console.log('onComposed:html', strings);\n composition.append(html(strings, ...substitutions));\n }));\n return this;\n }\n\n /**\n * Extends base class into a new class.\n * Use to avoid mutating base class.\n * @type {{\n * <T1 extends typeof CustomElement, T2 extends T1, T3 extends (Base:T1) => T2>\n * (this: T1,customExtender?: T3|null): T3 extends null ? T1 : T2;\n * }}\n */\n static extend(customExtender) {\n // @ts-expect-error Can't cast T\n return customExtender ? customExtender(this) : class extends this {};\n }\n\n /**\n * Assigns static values to class\n * @type {{\n * <\n * T1 extends typeof CustomElement,\n * T2 extends {\n * [K in keyof any]: (\n * ((this:T1, ...args:any[]) => any)\n * |string|number|boolean|any[]|object)}\n * >\n * (this: T1, source: T2 & ThisType<T1 & T2>):T1 & T2;\n * }}\n */\n static setStatic(source) {\n Object.assign(this, source);\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * Assigns values directly to all instances (via prototype)\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends object>\n * (this: CLASS, source: PROPS & ThisType<PROPS & INSTANCE>, options?: Partial<PropertyDescriptor>)\n * : CLASS & Class<PROPS,ARGS>\n * }}\n */\n static readonly(source, options) {\n return this.set(source, { ...options, writable: false });\n }\n\n /**\n * Assigns values directly to all instances (via prototype)\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends object>\n * (this: CLASS, source: PROPS & ThisType<PROPS & INSTANCE>, options?: Partial<PropertyDescriptor>)\n * : CLASS & Class<PROPS,ARGS>\n * }}\n */\n static set(source, options) {\n Object.defineProperties(\n this.prototype,\n Object.fromEntries([\n ...Object.entries(source).map(([name, value]) => {\n // Tap into .map() to avoid double iteration\n // Property may be redefined observable\n this.undefine(name);\n return [\n name,\n {\n enumerable: name[0] !== '_',\n configurable: true,\n value,\n writable: true,\n ...options,\n },\n ];\n }),\n ...Object.getOwnPropertySymbols(source).map((symbol) => [\n symbol,\n {\n enumerable: false,\n configurable: true,\n // @ts-expect-error Can't index by symbol\n value: source[symbol],\n writable: true,\n ...options,\n },\n ]),\n ]),\n );\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * Returns result of calling mixin with current class\n * @type {{\n * <\n * BASE extends typeof CustomElement,\n * FN extends (...args:any[]) => any,\n * RETURN extends ReturnType<FN>,\n * SUBCLASS extends ClassOf<RETURN>,\n * >(this: BASE, mixin: FN): SUBCLASS & BASE\n * }}\n */\n static mixin(mixin) {\n return mixin(this);\n }\n\n /**\n * Registers class with window.customElements synchronously\n * @type {{\n * <T extends typeof CustomElement>(this: T, elementName?: string, force?: boolean): T;\n * }}\n */\n static register(elementName) {\n if (elementName) {\n this.elementName = elementName;\n }\n\n customElements.define(this.elementName, this);\n CustomElement.registrations.set(this.elementName, this);\n this.defined = true;\n return this;\n }\n\n static get propList() {\n if (!this.hasOwnProperty('_props')) {\n this._props = new Map(this._props);\n }\n return this._props;\n }\n\n static get attrList() {\n if (!this.hasOwnProperty('_attrs')) {\n this._attrs = new Map(this._attrs);\n }\n return this._attrs;\n }\n\n static get propChangedCallbacks() {\n if (!this.hasOwnProperty('_propChangedCallbacks')) {\n // structuredClone()\n this._propChangedCallbacks = new Map(\n [\n ...this._propChangedCallbacks,\n ].map(([name, array]) => [name, array.slice()]),\n );\n }\n return this._propChangedCallbacks;\n }\n\n static get attributeChangedCallbacks() {\n if (!this.hasOwnProperty('_attributeChangedCallbacks')) {\n this._attributeChangedCallbacks = new Map(\n [\n ...this._attributeChangedCallbacks,\n ].map(([name, array]) => [name, array.slice()]),\n );\n }\n return this._attributeChangedCallbacks;\n }\n\n /**\n * Creates observable property on instances (via prototype)\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * KEY extends string,\n * OPTIONS extends ObserverPropertyType\n * | ObserverOptions<ObserverPropertyType, unknown, INSTANCE>\n * | ((this:INSTANCE, data:Partial<INSTANCE>, fn?: () => any) => any),\n * VALUE extends Record<KEY, OPTIONS extends (...args2:any[]) => infer R ? R\n * : OPTIONS extends ObserverPropertyType ? import('./observe').ParsedObserverPropertyType<OPTIONS>\n * : OPTIONS extends {type: 'object'} & ObserverOptions<any, infer R> ? (unknown extends R ? object : R)\n * : OPTIONS extends {type: ObserverPropertyType} ? import('./observe').ParsedObserverPropertyType<OPTIONS['type']>\n * : OPTIONS extends ObserverOptions<any, infer R> ? (unknown extends R ? string : R)\n * : never\n * >\n * > (this: CLASS, name: KEY, options: OPTIONS)\n * : CLASS & Class<VALUE,ARGS>\n * }}\n */\n static prop(name, typeOrOptions) {\n // TODO: Cache and save configuration for reuse (mixins)\n const config = defineObservableProperty(\n /** @type {any} */ (this.prototype),\n name,\n /** @type {any} */ (typeOrOptions),\n );\n\n const { changedCallback, attr, reflect, watchers } = config;\n if (changedCallback) {\n watchers.push([name, changedCallback]);\n }\n // TODO: Inspect possible closure bloat\n config.changedCallback = function wrappedChangedCallback(oldValue, newValue, changes) {\n this._onObserverPropertyChanged.call(this, name, oldValue, newValue, changes);\n };\n\n this.propList.set(name, config);\n\n if (attr\n && (reflect === true || reflect === 'read')\n && (config.enumerable || !this.attrList.has(attr) || !this.attrList.get(attr).enumerable)) {\n this.attrList.set(attr, config);\n }\n\n this.onPropChanged(watchers);\n\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * Define properties on instances via Object.defineProperties().\n * Automatically sets property non-enumerable if name begins with `_`.\n * Functions will be remapped as getters\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends {\n * [P in keyof any] :\n * {\n * enumerable?: boolean;\n * configurable?: boolean;\n * writable?: boolean;\n * value?: any;\n * get?: ((this: INSTANCE) => any);\n * set?: (this: INSTANCE, value: any) => void;\n * } | ((this: INSTANCE, ...args:any[]) => any)\n * },\n * VALUE extends {\n * [KEY in keyof PROPS]: PROPS[KEY] extends (...args2:any[]) => infer R ? R\n * : PROPS[KEY] extends TypedPropertyDescriptor<infer R> ? R : never\n * }>\n * (this: CLASS, props: PROPS & ThisType<PROPS & INSTANCE>): CLASS\n * & Class<VALUE,ARGS>\n * }}\n */\n static define(props) {\n Object.defineProperties(\n this.prototype,\n Object.fromEntries(\n Object.entries(props).map(([name, options]) => {\n // Tap into .map() to avoid double iteration\n // Property may be redefined observable\n this.undefine(name);\n return [\n name,\n {\n enumerable: name[0] !== '_',\n configurable: true,\n ...(\n typeof options === 'function'\n ? { get: options }\n : options\n ),\n },\n ];\n }),\n ),\n );\n\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * Assigns values directly to all instances (via prototype)\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROP extends string,\n * PROPS extends INSTANCE & Record<PROP, never>\n * >(this: CLASS, name: PROP):\n * CLASS & Class<PROPS,ARGS>\n * }}\n */\n static undefine(name) {\n Reflect.deleteProperty(this.prototype, name);\n if (this.propList.has(name)) {\n const { watchers, attr, reflect } = this.propList.get(name);\n if (watchers.length && this.propChangedCallbacks.has(name)) {\n const propWatchers = this.propChangedCallbacks.get(name);\n for (const [prop, watcher] of watchers) {\n const index = propWatchers.indexOf(watcher);\n if (index !== -1) {\n console.warn('Unwatching', name);\n propWatchers.splice(index, 1);\n }\n }\n }\n if (attr && (reflect === true || reflect === 'read')) {\n this.attrList.delete(attr);\n }\n this.propList.delete(name);\n }\n\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * Creates observable properties on instances\n * @type {{\n * <\n * CLASS extends typeof CustomElement,\n * ARGS extends ConstructorParameters<CLASS>,\n * INSTANCE extends InstanceType<CLASS>,\n * PROPS extends IDLParameter<INSTANCE & VALUE>,\n * VALUE extends {\n * [KEY in keyof PROPS]:\n * PROPS[KEY] extends (...args2:any[]) => infer R ? R\n * : PROPS[KEY] extends ObserverPropertyType ? import('./observe').ParsedObserverPropertyType<PROPS[KEY]>\n * : PROPS[KEY] extends {type: 'object'} & ObserverOptions<any, infer R> ? (unknown extends R ? object : R)\n * : PROPS[KEY] extends {type: ObserverPropertyType} ? import('./observe').ParsedObserverPropertyType<PROPS[KEY]['type']>\n * : PROPS[KEY] extends ObserverOptions<any, infer R> ? (unknown extends R ? string : R)\n * : never\n * },\n * > (this: CLASS, props: PROPS)\n * : CLASS & Class<VALUE,ARGS>\n * }}\n */\n static observe(props) {\n for (const [name, typeOrOptions] of Object.entries(props ?? {})) {\n /** @type {any} */\n const options = (typeof typeOrOptions === 'function')\n ? { reflect: false, get: typeOrOptions }\n : typeOrOptions;\n\n this.prop(name, options);\n }\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * @type {{\n * <\n * T1 extends typeof CustomElement,\n * T2 extends IDLParameter<T1>>\n * (this: T1, props: T2):T1 & ParsedProps<T2>\n * }}\n */\n static defineStatic(props) {\n for (const [name, typeOrOptions] of Object.entries(props ?? {})) {\n const options = (typeof typeOrOptions === 'function')\n ? { get: typeOrOptions }\n : (typeof typeOrOptions === 'string'\n ? { type: typeOrOptions }\n : typeOrOptions);\n // @ts-expect-error Adding property to this\n defineObservableProperty(this, name, {\n reflect: false,\n ...options,\n });\n }\n // @ts-expect-error Can't cast T\n return this;\n }\n\n /**\n * @type {{\n * <T extends typeof CustomElement>\n * (\n * this: T,\n * listeners?: import('./Composition').CompositionEventListenerObject<InstanceType<T>>,\n * options?: Partial<import('./Composition').CompositionEventListener<InstanceType<T>>>,\n * ): T;\n * }}\n */\n static events(listeners, options) {\n this.on({\n composed({ composition }) {\n for (const [key, listenerOptions] of Object.entries(listeners)) {\n const [, flags, type] = key.match(/^([*1~]+)?(.*)$/);\n // TODO: Make abstract\n let prop;\n /** @type {string[]} */\n let deepProp = [];\n if (typeof listenerOptions === 'string') {\n const parsedProps = listenerOptions.split('.');\n if (parsedProps.length === 1) {\n prop = listenerOptions;\n deepProp = [];\n } else {\n prop = parsedProps[0];\n deepProp = parsedProps;\n }\n }\n composition.addCompositionEventListener({\n type,\n once: flags?.includes('1'),\n passive: flags?.includes('~'),\n capture: flags?.includes('*'),\n ...(\n typeof listenerOptions === 'function'\n ? { handleEvent: listenerOptions }\n : (typeof listenerOptions === 'string'\n ? { prop, deepProp }\n : listenerOptions)\n ),\n ...(\n options\n )\n ,\n });\n }\n },\n });\n\n return this;\n }\n\n /**\n * @type {{\n * <T extends typeof CustomElement>\n * (\n * this: T,\n * listenerMap: {\n * [P in keyof any]: import('./Composition').CompositionEventListenerObject<InstanceType<T>>\n * },\n * options?: Partial<import('./Composition').CompositionEventListener<InstanceType<T>>>,\n * ): T;\n * }}\n */\n static childEvents(listenerMap, options) {\n for (const [tag, listeners] of Object.entries(listenerMap)) {\n this.events(listeners, {\n tag: attrNameFromPropName(tag),\n ...options,\n });\n }\n\n return this;\n }\n\n /** @type {typeof CustomElement['events']} */\n static rootEvents(listeners, options) {\n return this.events(listeners, {\n tag: Composition.shadowRootTag,\n ...options,\n });\n }\n\n /**\n * @type {{\n * <\n * T1 extends typeof CustomElement,\n * T2 extends InstanceType<T1>,\n * T3 extends CompositionCallback<T2, T2>,\n * T4 extends keyof T3,\n * >\n * (this: T1, name: T3|T4, callbacks?: T3[T4] & ThisType<T2>): T1\n * }}\n */\n static on(nameOrCallbacks, callback) {\n const callbacks = typeof nameOrCallbacks === 'string'\n ? { [nameOrCallbacks]: callback }\n : nameOrCallbacks;\n for (const [name, fn] of Object.entries(callbacks)) {\n /** @type {keyof (typeof CustomElement)} */\n let arrayPropName;\n switch (name) {\n case 'composed': arrayPropName = '_onComposeCallbacks'; break;\n case 'constructed': arrayPropName = '_onConstructedCallbacks'; break;\n case 'connected': arrayPropName = '_onConnectedCallbacks'; break;\n case 'disconnected': arrayPropName = '_onDisconnectedCallbacks'; break;\n case 'props':\n this.onPropChanged(fn);\n continue;\n case 'attrs':\n this.onAttributeChanged(fn);\n continue;\n default:\n if (name.endsWith('Changed')) {\n const prop = name.slice(0, name.length - 'Changed'.length);\n // @ts-expect-error Computed key\n this.onPropChanged({ [prop]: fn });\n continue;\n }\n throw new Error('Invalid callback name');\n }\n this._addCallback(arrayPropName, fn);\n }\n\n return this;\n }\n\n /**\n * @type {{\n * <\n * T1 extends typeof CustomElement,\n * T2 extends InstanceType<T1>\n * >\n * (\n * this: T1,\n * options: ObjectOrObjectEntries<{\n * [P in keyof T2]? : (\n * this: T2,\n * oldValue: T2[P],\n * newValue: T2[P],\n * changes:any,\n * element: T2\n * ) => void\n * }>,\n * ): T1;\n * }}\n */\n static onPropChanged(options) {\n const entries = Array.isArray(options) ? options : Object.entries(options);\n const { propChangedCallbacks } = this;\n for (const [prop, callback] of entries) {\n if (propChangedCallbacks.has(prop)) {\n propChangedCallbacks.get(prop).push(callback);\n } else {\n propChangedCallbacks.set(prop, [callback]);\n }\n }\n\n return this;\n }\n\n /**\n * @type {{\n * <\n * T1 extends typeof CustomElement,\n * T2 extends InstanceType<T1>\n * >\n * (\n * this: T1,\n * options: {\n * [x:string]: (\n * this: T2,\n * oldValue: string,\n * newValue: string,\n * element: T2\n * ) => void\n * },\n * ): T1;\n * }}\n */\n static onAttributeChanged(options) {\n const entries = Array.isArray(options) ? options : Object.entries(options);\n const { attributeChangedCallbacks } = this;\n for (const [name, callback] of entries) {\n if (attributeChangedCallbacks.has(name)) {\n attributeChangedCallbacks.get(name).push(callback);\n } else {\n attributeChangedCallbacks.set(name, [callback]);\n }\n }\n\n return this;\n }\n\n /** @type {Record<string, HTMLElement>}} */\n #refsProxy;\n\n /** @type {Map<string, WeakRef<HTMLElement>>}} */\n #refsCache = new Map();\n\n /** @type {Map<string, WeakRef<HTMLElement>>}} */\n #refsCompositionCache = new Map();\n\n /** @type {Composition<?>} */\n #composition;\n\n #patching = false;\n\n /** @type {Array<[string, any, CustomElement]>} */\n #pendingPatchRenders = [];\n\n /** @type {Map<string,{stringValue:string, parsedValue:any}>} */\n _propAttributeCache;\n\n /** @type {CallbackArguments} */\n _callbackArguments = null;\n\n /** @param {any[]} args */\n constructor(...args) {\n super();\n\n if (CustomElement.supportsElementInternals) {\n this.elementInternals = this.attachInternals();\n }\n\n this.attachShadow({ mode: 'open', delegatesFocus: this.delegatesFocus });\n\n /**\n * Updates nodes based on data\n * Expects data in JSON Merge Patch format\n * @see https://www.rfc-editor.org/rfc/rfc7386\n * @param {Partial<?>} changes\n * @param {any} data\n * @return {void}\n */\n this.render = this.composition.render(\n this.constructor.prototype,\n this,\n {\n defaults: this.constructor.prototype,\n store: this,\n shadowRoot: this.shadowRoot,\n context: this,\n },\n );\n\n for (const callback of this.static._onConstructedCallbacks) {\n callback.call(this, this.callbackArguments);\n }\n }\n\n /**\n * @type {{\n * <\n * T extends CustomElement,\n * K extends string = string,\n * >(this:T,\n * name: K,\n * oldValue: K extends keyof T ? T[K] : unknown,\n * newValue: K extends keyof T ? T[K] : unknown,\n * changes?: K extends keyof T ? T[K] extends object ? Partial<T[K]> : T[K] : unknown): void;\n * }}\n */\n propChangedCallback(name, oldValue, newValue, changes = newValue) {\n if (this.#patching) {\n this.#pendingPatchRenders.push([name, changes, this]);\n } else {\n this.render.byProp(name, changes, this);\n // this.render({ [name]: changes });\n }\n\n const { _propChangedCallbacks } = this.static;\n if (_propChangedCallbacks.has(name)) {\n for (const callback of _propChangedCallbacks.get(name)) {\n callback.call(this, oldValue, newValue, changes, this);\n }\n }\n }\n\n /**\n * @param {string} name\n * @param {string|null} oldValue\n * @param {string|null} newValue\n */\n attributeChangedCallback(name, oldValue, newValue) {\n const { attributeChangedCallbacks } = this.static;\n if (attributeChangedCallbacks.has(name)) {\n for (const callback of attributeChangedCallbacks.get(name)) {\n callback.call(this, oldValue, newValue, this);\n }\n }\n\n // Array.find\n const { attrList } = this.static;\n if (!attrList.has(name)) return;\n\n const config = attrList.get(name);\n\n if (config.attributeChangedCallback) {\n config.attributeChangedCallback.call(this, name, oldValue, newValue);\n return;\n }\n\n let cacheEntry;\n if (this.attributeCache.has(name)) {\n cacheEntry = this.attributeCache.get(name);\n if (cacheEntry.stringValue === newValue) return;\n }\n\n // @ts-expect-error any\n const previousDataValue = this[config.key];\n const parsedValue = newValue === null\n ? config.nullParser(/** @type {null} */ (newValue))\n // Avoid Boolean('') === false\n : (config.type === 'boolean' ? true : config.parser(newValue));\n\n if (parsedValue === previousDataValue) {\n // No internal value change\n return;\n }\n // \"Remember\" that this attrValue equates to this data value\n // Avoids rewriting attribute later on data change event\n if (cacheEntry) {\n cacheEntry.stringValue = newValue;\n cacheEntry.parsedValue = parsedValue;\n } else {\n this.attributeCache.set(name, {\n stringValue: newValue, parsedValue,\n });\n }\n // @ts-expect-error any\n this[config.key] = parsedValue;\n }\n\n get #template() {\n return this.#composition?.template;\n }\n\n /**\n * @param {string} name\n * @param {any} oldValue\n * @param {any} newValue\n * @param {any} changes\n */\n _onObserverPropertyChanged(name, oldValue, newValue, changes) {\n const { propList } = this.static;\n if (propList.has(name)) {\n const { reflect, attr } = propList.get(name);\n if (attr && (reflect === true || reflect === 'write')) {\n /** @type {{stringValue:string, parsedValue:any}} */\n let cacheEntry;\n let needsWrite = false;\n const { attributeCache } = this;\n if (attributeCache.has(attr)) {\n cacheEntry = attributeCache.get(attr);\n needsWrite = (cacheEntry.parsedValue !== newValue);\n } else {\n // @ts-ignore skip cast\n cacheEntry = {};\n attributeCache.set(attr, cacheEntry);\n needsWrite = true;\n }\n if (needsWrite) {\n const stringValue = attrValueFromDataValue(newValue);\n cacheEntry.parsedValue = newValue;\n cacheEntry.stringValue = stringValue;\n // Cache attrValue to ignore attributeChangedCallback later\n if (stringValue == null) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, stringValue);\n }\n }\n }\n }\n\n // Invoke change => render\n this.propChangedCallback(name, oldValue, newValue, changes);\n }\n\n /** @param {any} patch */\n patch(patch) {\n this.#patching = true;\n applyMergePatch(this, patch);\n for (const [name, changes, state] of this.#pendingPatchRenders) {\n if (name in patch) continue;\n this.render.byProp(name, changes, state);\n }\n this.#pendingPatchRenders.slice(0, this.#pendingPatchRenders.length);\n this.render(patch);\n this.#patching = false;\n }\n\n /**\n * Proxy object that returns shadow DOM elements by tag.\n * If called before interpolation (eg: on composed), returns from template\n * @return {Record<string,HTMLElement>}\n */\n get refs() {\n // eslint-disable-next-line no-return-assign\n return (this.#refsProxy ??= new Proxy({}, {\n /**\n * @param {any} target\n * @param {string} tag\n * @return {Element}\n */\n get: (target, tag) => {\n if (!this.#composition) {\n console.warn(this.static.name, 'Attempted to access references before composing!');\n }\n const composition = this.composition;\n let element;\n if (!composition.interpolated) {\n if (this.#refsCompositionCache.has(tag)) {\n element = this.#refsCompositionCache.get(tag).deref();\n if (element) return element;\n }\n const formattedTag = attrNameFromPropName(tag);\n // console.warn(this.tagName, 'Returning template reference');\n element = composition.template.getElementById(formattedTag);\n if (!element) return null;\n this.#refsCompositionCache.set(tag, new WeakRef(element));\n return element;\n }\n if (this.#refsCache.has(tag)) {\n element = this.#refsCache.get(tag).deref();\n if (element) {\n return element;\n }\n }\n\n const formattedTag = attrNameFromPropName(tag);\n const tagIndex = this.composition.tags.indexOf(formattedTag);\n element = this.render.state.refs[tagIndex];\n\n if (!element) return null;\n this.#refsCache.set(tag, new WeakRef(element));\n return element;\n },\n }));\n }\n\n get attributeCache() {\n // eslint-disable-next-line no-return-assign\n return (this._propAttributeCache ??= new Map());\n }\n\n get static() { return /** @type {typeof CustomElement} */ (/** @type {unknown} */ (this.constructor)); }\n\n get unique() { return false; }\n\n /**\n * @template {CustomElement} T\n * @this {T}\n */\n get callbackArguments() {\n // eslint-disable-next-line no-return-assign\n return this._callbackArguments ??= {\n composition: this.#composition,\n refs: this.refs,\n html: html.bind(this),\n inline: addInlineFunction,\n template: this.#template,\n element: this,\n };\n }\n\n /** @return {Composition<?>} */\n get composition() {\n if (this.#composition) return this.#composition;\n\n if (!this.unique && this.static.hasOwnProperty('_composition')) {\n this.#composition = this.static._composition;\n return this.static._composition;\n }\n\n // TODO: Use Composition to track uniqueness\n // console.log('composing', this.static.elementName);\n this.compose();\n for (const callback of this.static._onComposeCallbacks) {\n // console.log(this.static.elementName, 'composition callback');\n callback.call(this, this.callbackArguments);\n }\n\n if (!this.unique) {\n // Cache compilation into static property\n this.static._composition = this.#composition;\n }\n\n return this.#composition;\n }\n\n connectedCallback() {\n for (const callbacks of this.static._onConnectedCallbacks) {\n callbacks.call(this, this.callbackArguments);\n }\n }\n\n disconnectedCallback() {\n for (const callbacks of this.static._onDisconnectedCallbacks) {\n callbacks.call(this, this.callbackArguments);\n }\n }\n}\n\nCustomElement.prototype.delegatesFocus = false;\n"],
|
|
5
|
+
"mappings": "AAEA,IAAIA,GACAC,GAIG,SAASC,IAAsB,CAEpC,OAAQC,KAAe,IAAI,MAAQ,UAAU,CAC/C,CASO,SAASC,GAAqB,CAEnC,OAAQC,KAAkB,IAAI,SAAW,UAAU,CACrD,CCUA,IAAqBC,EAArB,KAAwC,CAEtC,YAAYC,EAAS,CACnB,KAAK,WAAaA,EAAQ,WAG1B,KAAK,SAAW,CAAC,EAQjB,KAAK,KAAO,CAAC,EAKb,KAAK,sBAAwB,GAG7B,KAAK,YAAcA,EAAQ,YAE3B,KAAK,cAAgBA,EAAQ,cAG7B,KAAK,cAAgB,KAGrB,KAAK,eAAiB,CAAC,EAGvB,KAAK,gBAAkB,KAEvB,KAAK,cAAgB,IACvB,CAOA,OAAOC,EAASC,EAAM,C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MY,GAAK,KAAK,IAAI,EACpB,OAAQ4D,GACR,SAAU,KAAKZ,GACf,QAAS,IACX,CACF,CAGA,IAAI,aAAc,CAChB,GAAI,KAAK5D,GAAc,OAAO,KAAKA,GAEnC,GAAI,CAAC,KAAK,QAAU,KAAK,OAAO,eAAe,cAAc,EAC3D,YAAKA,GAAe,KAAK,OAAO,aACzB,KAAK,OAAO,aAKrB,KAAK,QAAQ,EACb,QAAWG,KAAY,KAAK,OAAO,oBAEjCA,EAAS,KAAK,KAAM,KAAK,iBAAiB,EAG5C,OAAK,KAAK,SAER,KAAK,OAAO,aAAe,KAAKH,IAG3B,KAAKA,EACd,CAEA,mBAAoB,CAClB,QAAW2C,KAAa,KAAK,OAAO,sBAClCA,EAAU,KAAK,KAAM,KAAK,iBAAiB,CAE/C,CAEA,sBAAuB,CACrB,QAAWA,KAAa,KAAK,OAAO,yBAClCA,EAAU,KAAK,KAAM,KAAK,iBAAiB,CAE/C,CACF,EAEA7C,EAAc,UAAU,eAAiB",
|
|
6
6
|
"names": ["BLANK_TEXT", "BLANK_COMMENT", "createEmptyTextNode", "BLANK_TEXT", "createEmptyComment", "BLANK_COMMENT", "CompositionAdapter", "options", "changes", "data", "_a", "domNode", "index", "metadata", "key", "newIndex", "change", "skipOnMatch", "metadataAtIndex", "currentKey", "sameKey", "isPartial", "metadataCache", "failedFastPath", "oldIndex", "previousMetadata", "correctMetadata", "domNodeToRemove", "render", "element", "startIndex", "length", "comment", "createEmptyComment", "cssStyleSheetsCache", "createCSSStyleSheet", "content", "useCache", "sheet", "styleElementCache", "_inactiveDocument", "createHTMLStyleElement", "style", "_cssStyleSheetConstructable", "createCSS", "generateCSSStyleSheets", "styles", "r", "styleElementFromStyleSheetCache", "generateHTMLStyleElements", "styleElement", "css", "array", "substitutions", "attrValueFromDataValue", "value", "attrNameFromPropNameCache", "attrNameFromPropName", "name", "match", "_a", "CHROME_VERSION", "FIREFOX_VERSION", "SAFARI_VERSION", "applyMergePatch", "target", "patch", "key", "value", "buildMergePatch", "previous", "current", "arrayStrategy", "index", "changes", "previousKeys", "hasMergePatch", "emptyFromType", "type", "buildProxy", "proxyTarget", "set", "deepSet", "prefix", "target", "p", "value", "arg", "defaultParserFromType", "v", "o", "observeFunction", "fn", "args", "thisPoked", "thisPokedDeep", "argWatchers", "poked", "pokedDeep", "proxy", "thisProxy", "defaultValue", "watcher", "reusable", "deepPropString", "defaultNullParser", "parseObserverOptions", "name", "typeOrOptions", "object", "options", "watchers", "readonly", "empty", "enumerable", "reflect", "attr", "nullable", "parser", "nullParser", "get", "is", "diff", "props", "observeResult", "parsed", "attrNameFromPropName", "a", "b", "hasMergePatch", "buildMergePatch", "detectChange", "config", "oldValue", "value", "_a", "_b", "newValue", "changes", "defineObservableProperty", "object", "key", "options", "parseObserverOptions", "internalGet", "internalSet", "onInvalidate", "prop", "cachedGet", "cachedSet", "descriptor", "generatedUIDs", "generateUID", "prefix", "n", "id", "_inactiveDocument", "_blankFragment", "_fragmentRange", "generateFragment", "fromString", "inlineFunctions", "addInlineFunction", "fn", "internalName", "generateUID", "fragmentCache", "html", "strings", "substitutions", "tempSlots", "replacements", "sub", "tempId", "compiledString", "fragment", "id", "element", "writeDOMAttribute", "nodes", "value", "nodeIndex", "attrName", "element", "writeDynamicNode", "nodeStates", "comments", "commentIndex", "nodeState", "hidden", "comment", "createEmptyComment", "node", "isDynamicNode", "textNode", "writeDOMElementAttachedState", "show", "writeDOMHideNodeOnInit", "executeSearch", "search", "args", "caches", "searchStates", "cacheIndex", "searchIndex", "subSearch", "invocation", "cachedValue", "searchState", "result", "subResult", "searchWithExpression", "context", "store", "injections", "changes", "data", "searchWithProp", "state", "searchWithDeepProp", "scope", "prop", "STRING_INTERPOLATION_REGEX", "propFromObject", "prop", "source", "deepPropFromObject", "nameArray", "scope", "valueFromPropName", "value", "child", "compositionCache", "Composition", "_Composition", "parts", "generateFragment", "part", "cache", "comp", "index", "composition", "listener", "key", "events", "#bindCompositionEventListeners", "tag", "target", "context", "_a", "event", "changes", "data", "options", "instanceFragment", "shadowRoot", "initState", "nodes", "refs", "searchStates", "caches", "textNodes", "textNode", "element", "currentIndex", "action", "draw", "ranSearch", "actions", "dirty", "executeSearch", "_b", "search", "result", "#interpolateNode", "node", "parsedValue", "nodeValue", "nodeName", "nodeType", "attr", "text", "trimmed", "length", "segments", "STRING_INTERPOLATION_REGEX", "segment", "newNode", "createEmptyTextNode", "query", "negate", "doubleNegate", "isEvent", "textNodeIndex", "prev", "hyphenIndex", "#tagElement", "eventType", "flags", "type", "handleEvent", "deepProp", "inlineFunctions", "parsedProps", "subquery", "isSubquery", "subSearch", "expression", "propsUsed", "deepPropsUsed", "defaultValue", "invocation", "inlineFunctionOptions", "searchWithExpression", "observeResult", "observeFunction", "uniqueProps", "uniqueDeepProps", "deepPropString", "searchWithProp", "searchWithDeepProp", "subnode", "nodeEntry", "writeDynamicNode", "writeDOMAttribute", "writeDOMElementAttachedState", "writeDOMHideNodeOnInit", "id", "generateUID", "#interpolateIterable", "forAttr", "valueName", "iterableName", "elementAnchor", "newComposition", "injections", "state", "instanceAnchorElement", "anchorNode", "createEmptyComment", "CompositionAdapter", "adapter", "iterable", "changeList", "innerChanges", "needTargetAll", "isArray", "iterator", "change", "resource", "treeWalker", "idAttr", "nextNode", "generateCSSStyleSheets", "generateHTMLStyleElements", "n", "actionsByPropsUsed", "cloneAttributeCallback", "name", "target", "oldValue", "newValue", "element", "CustomElement", "_CustomElement", "#composition", "Composition", "collection", "callback", "parts", "composition", "opts", "array", "substitutions", "css", "elementName", "strings", "html", "customExtender", "source", "options", "value", "symbol", "mixin", "typeOrOptions", "config", "defineObservableProperty", "changedCallback", "attr", "reflect", "watchers", "changes", "props", "propWatchers", "prop", "watcher", "index", "listeners", "key", "listenerOptions", "flags", "type", "deepProp", "parsedProps", "listenerMap", "tag", "attrNameFromPropName", "nameOrCallbacks", "callbacks", "fn", "arrayPropName", "entries", "propChangedCallbacks", "attributeChangedCallbacks", "#refsProxy", "#refsCache", "#refsCompositionCache", "#patching", "#pendingPatchRenders", "args", "_propChangedCallbacks", "attrList", "cacheEntry", "previousDataValue", "parsedValue", "#template", "_a", "propList", "needsWrite", "attributeCache", "stringValue", "attrValueFromDataValue", "patch", "applyMergePatch", "state", "formattedTag", "tagIndex", "addInlineFunction"]
|
|
7
7
|
}
|