@aegis-framework/pandora 0.6.2 → 0.7.0

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.
@@ -1,43 +1,44 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../node_modules/lit-html/development/lit-html.js", "../src/Util.ts", "../src/Component.ts", "../src/ShadowComponent.ts", "../src/Registry.ts", "../src/Decorators.ts", "../src/TypedState.ts", "../src/Testing.ts", "../node_modules/lit-html/development/directive.js", "../node_modules/lit-html/development/directive-helpers.js", "../node_modules/lit-html/development/async-directive.js", "../node_modules/lit-html/development/directives/private-async-helpers.js", "../node_modules/lit-html/development/directives/async-replace.js", "../node_modules/lit-html/development/directives/async-append.js", "../node_modules/lit-html/development/directives/cache.js", "../node_modules/lit-html/development/directives/choose.js", "../node_modules/lit-html/development/directives/class-map.js", "../node_modules/lit-html/development/directives/guard.js", "../node_modules/lit-html/development/directives/if-defined.js", "../node_modules/lit-html/development/directives/join.js", "../node_modules/lit-html/development/directives/keyed.js", "../node_modules/lit-html/development/directives/live.js", "../node_modules/lit-html/development/directives/map.js", "../node_modules/lit-html/development/directives/range.js", "../node_modules/lit-html/development/directives/ref.js", "../node_modules/lit-html/development/directives/repeat.js", "../node_modules/lit-html/development/directives/style-map.js", "../node_modules/lit-html/development/directives/template-content.js", "../node_modules/lit-html/development/directives/unsafe-html.js", "../node_modules/lit-html/development/directives/unsafe-svg.js", "../node_modules/lit-html/development/directives/unsafe-mathml.js", "../node_modules/lit-html/development/directives/until.js", "../node_modules/lit-html/development/directives/when.js", "../src/browser.ts"],
3
+ "sources": ["../node_modules/lit-html/lit-html.js", "../node_modules/lit-html/directive-helpers.js", "../node_modules/lit-html/directive.js", "../node_modules/lit-html/async-directive.js", "../node_modules/lit-html/directives/private-async-helpers.js", "../node_modules/lit-html/directives/async-replace.js", "../node_modules/lit-html/directives/async-append.js", "../node_modules/lit-html/directives/cache.js", "../node_modules/lit-html/directives/choose.js", "../node_modules/lit-html/directives/class-map.js", "../node_modules/lit-html/directives/guard.js", "../node_modules/lit-html/directives/if-defined.js", "../node_modules/lit-html/directives/join.js", "../node_modules/lit-html/directives/keyed.js", "../node_modules/lit-html/directives/live.js", "../node_modules/lit-html/directives/map.js", "../node_modules/lit-html/directives/range.js", "../node_modules/lit-html/directives/ref.js", "../node_modules/lit-html/directives/repeat.js", "../node_modules/lit-html/directives/style-map.js", "../node_modules/lit-html/directives/template-content.js", "../node_modules/lit-html/directives/unsafe-html.js", "../node_modules/lit-html/directives/unsafe-mathml.js", "../node_modules/lit-html/directives/unsafe-svg.js", "../node_modules/lit-html/directives/until.js", "../node_modules/lit-html/directives/when.js", "../src/RenderState.ts", "../src/Util.ts", "../src/Component.ts", "../src/Registry.ts", "../src/Decorators.ts", "../src/ShadowComponent.ts", "../src/Testing.ts", "../src/TypedState.ts", "../src/browser.ts"],
4
4
  "sourcesContent": [
5
- "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst DEV_MODE = true;\nconst ENABLE_EXTRA_SECURITY_HOOKS = true;\nconst ENABLE_SHADYDOM_NOPATCH = true;\nconst NODE_MODE = false;\n// Allows minifiers to rename references to globalThis\nconst global = globalThis;\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event) => {\n const shouldEmit = global\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(new CustomEvent('lit-debug', {\n detail: event,\n }));\n }\n : undefined;\n// Used for connecting beginRender and endRender events when there are nested\n// renders when errors are thrown preventing an endRender event from being\n// called.\nlet debugLogRenderId = 0;\nlet issueWarning;\nif (DEV_MODE) {\n global.litIssuedWarnings ??= new Set();\n /**\n * Issue a warning if we haven't already, based either on `code` or `warning`.\n * Warnings are disabled automatically only by `warning`; disabling via `code`\n * can be done by users.\n */\n issueWarning = (code, warning) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (!global.litIssuedWarnings.has(warning) &&\n !global.litIssuedWarnings.has(code)) {\n console.warn(warning);\n global.litIssuedWarnings.add(warning);\n }\n };\n queueMicrotask(() => {\n issueWarning('dev-mode', `Lit is in dev mode. Not recommended for production!`);\n });\n}\nconst wrap = ENABLE_SHADYDOM_NOPATCH &&\n global.ShadyDOM?.inUse &&\n global.ShadyDOM?.noPatch === true\n ? global.ShadyDOM.wrap\n : (node) => node;\nconst trustedTypes = global.trustedTypes;\n/**\n * Our TrustedTypePolicy for HTML which is declared using the html template\n * tag function.\n *\n * That HTML is a developer-authored constant, and is parsed with innerHTML\n * before any untrusted expressions have been mixed in. Therefor it is\n * considered safe by construction.\n */\nconst policy = trustedTypes\n ? trustedTypes.createPolicy('lit-html', {\n createHTML: (s) => s,\n })\n : undefined;\nconst identityFunction = (value) => value;\nconst noopSanitizer = (_node, _name, _type) => identityFunction;\n/** Sets the global sanitizer factory. */\nconst setSanitizer = (newSanitizer) => {\n if (!ENABLE_EXTRA_SECURITY_HOOKS) {\n return;\n }\n if (sanitizerFactoryInternal !== noopSanitizer) {\n throw new Error(`Attempted to overwrite existing lit-html security policy.` +\n ` setSanitizeDOMValueFactory should be called at most once.`);\n }\n sanitizerFactoryInternal = newSanitizer;\n};\n/**\n * Only used in internal tests, not a part of the public API.\n */\nconst _testOnlyClearSanitizerFactoryDoNotCallOrElse = () => {\n sanitizerFactoryInternal = noopSanitizer;\n};\nconst createSanitizer = (node, name, type) => {\n return sanitizerFactoryInternal(node, name, type);\n};\n// Added to an attribute name to mark the attribute as bound so we can find\n// it easily.\nconst boundAttributeSuffix = '$lit$';\n// This marker is used in many syntactic positions in HTML, so it must be\n// a valid element name and attribute name. We don't support dynamic names (yet)\n// but this at least ensures that the parse tree is closer to the template\n// intention.\nconst marker = `lit$${Math.random().toFixed(9).slice(2)}$`;\n// String used to tell if a comment is a marker comment\nconst markerMatch = '?' + marker;\n// Text used to insert a comment marker node. We use processing instruction\n// syntax because it's slightly smaller, but parses as a comment node.\nconst nodeMarker = `<${markerMatch}>`;\nconst d = NODE_MODE && global.document === undefined\n ? {\n createTreeWalker() {\n return {};\n },\n }\n : document;\n// Creates a dynamic marker. We never have to search for these in the DOM.\nconst createMarker = () => d.createComment('');\nconst isPrimitive = (value) => value === null || (typeof value != 'object' && typeof value != 'function');\nconst isArray = Array.isArray;\nconst isIterable = (value) => isArray(value) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof value?.[Symbol.iterator] === 'function';\nconst SPACE_CHAR = `[ \\t\\n\\f\\r]`;\nconst ATTR_VALUE_CHAR = `[^ \\t\\n\\f\\r\"'\\`<>=]`;\nconst NAME_CHAR = `[^\\\\s\"'>=/]`;\n// These regexes represent the five parsing states that we care about in the\n// Template's HTML scanner. They match the *end* of the state they're named\n// after.\n// Depending on the match, we transition to a new state. If there's no match,\n// we stay in the same state.\n// Note that the regexes are stateful. We utilize lastIndex and sync it\n// across the multiple regexes used. In addition to the five regexes below\n// we also dynamically create a regex to find the matching end tags for raw\n// text elements.\n/**\n * End of text is: `<` followed by:\n * (comment start) or (tag) or (dynamic tag binding)\n */\nconst textEndRegex = /<(?:(!--|\\/[^a-zA-Z])|(\\/?[a-zA-Z][^>\\s]*)|(\\/?$))/g;\nconst COMMENT_START = 1;\nconst TAG_NAME = 2;\nconst DYNAMIC_TAG_NAME = 3;\nconst commentEndRegex = /-->/g;\n/**\n * Comments not started with <!--, like </{, can be ended by a single `>`\n */\nconst comment2EndRegex = />/g;\n/**\n * The tagEnd regex matches the end of the \"inside an opening\" tag syntax\n * position. It either matches a `>`, an attribute-like sequence, or the end\n * of the string after a space (attribute-name position ending).\n *\n * See attributes in the HTML spec:\n * https://www.w3.org/TR/html5/syntax.html#elements-attributes\n *\n * \" \\t\\n\\f\\r\" are HTML space characters:\n * https://infra.spec.whatwg.org/#ascii-whitespace\n *\n * So an attribute is:\n * * The name: any character except a whitespace character, (\"), ('), \">\",\n * \"=\", or \"/\". Note: this is different from the HTML spec which also excludes control characters.\n * * Followed by zero or more space characters\n * * Followed by \"=\"\n * * Followed by zero or more space characters\n * * Followed by:\n * * Any character except space, ('), (\"), \"<\", \">\", \"=\", (`), or\n * * (\") then any non-(\"), or\n * * (') then any non-(')\n */\nconst tagEndRegex = new RegExp(`>|${SPACE_CHAR}(?:(${NAME_CHAR}+)(${SPACE_CHAR}*=${SPACE_CHAR}*(?:${ATTR_VALUE_CHAR}|(\"|')|))|$)`, 'g');\nconst ENTIRE_MATCH = 0;\nconst ATTRIBUTE_NAME = 1;\nconst SPACES_AND_EQUALS = 2;\nconst QUOTE_CHAR = 3;\nconst singleQuoteAttrEndRegex = /'/g;\nconst doubleQuoteAttrEndRegex = /\"/g;\n/**\n * Matches the raw text elements.\n *\n * Comments are not parsed within raw text elements, so we need to search their\n * text content for marker strings.\n */\nconst rawTextElement = /^(?:script|style|textarea|title)$/i;\n/** TemplateResult types */\nconst HTML_RESULT = 1;\nconst SVG_RESULT = 2;\nconst MATHML_RESULT = 3;\n// TemplatePart types\n// IMPORTANT: these must match the values in PartType\nconst ATTRIBUTE_PART = 1;\nconst CHILD_PART = 2;\nconst PROPERTY_PART = 3;\nconst BOOLEAN_ATTRIBUTE_PART = 4;\nconst EVENT_PART = 5;\nconst ELEMENT_PART = 6;\nconst COMMENT_PART = 7;\n/**\n * Generates a template literal tag function that returns a TemplateResult with\n * the given result type.\n */\nconst tag = (type) => (strings, ...values) => {\n // Warn against templates octal escape sequences\n // We do this here rather than in render so that the warning is closer to the\n // template definition.\n if (DEV_MODE && strings.some((s) => s === undefined)) {\n console.warn('Some template strings are undefined.\\n' +\n 'This is probably caused by illegal octal escape sequences.');\n }\n if (DEV_MODE) {\n // Import static-html.js results in a circular dependency which g3 doesn't\n // handle. Instead we know that static values must have the field\n // `_$litStatic$`.\n if (values.some((val) => val?.['_$litStatic$'])) {\n issueWarning('', `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.\\n` +\n `Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`);\n }\n }\n return {\n // This property needs to remain unminified.\n ['_$litType$']: type,\n strings,\n values,\n };\n};\n/**\n * Interprets a template literal as an HTML template that can efficiently\n * render to and update a container.\n *\n * ```ts\n * const header = (title: string) => html`<h1>${title}</h1>`;\n * ```\n *\n * The `html` tag returns a description of the DOM to render as a value. It is\n * lazy, meaning no work is done until the template is rendered. When rendering,\n * if a template comes from the same expression as a previously rendered result,\n * it's efficiently updated instead of replaced.\n */\nexport const html = tag(HTML_RESULT);\n/**\n * Interprets a template literal as an SVG fragment that can efficiently render\n * to and update a container.\n *\n * ```ts\n * const rect = svg`<rect width=\"10\" height=\"10\"></rect>`;\n *\n * const myImage = html`\n * <svg viewBox=\"0 0 10 10\" xmlns=\"http://www.w3.org/2000/svg\">\n * ${rect}\n * </svg>`;\n * ```\n *\n * The `svg` *tag function* should only be used for SVG fragments, or elements\n * that would be contained **inside** an `<svg>` HTML element. A common error is\n * placing an `<svg>` *element* in a template tagged with the `svg` tag\n * function. The `<svg>` element is an HTML element and should be used within a\n * template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an SVG fragment from the\n * `render()` method, as the SVG fragment will be contained within the element's\n * shadow root and thus not be properly contained within an `<svg>` HTML\n * element.\n */\nexport const svg = tag(SVG_RESULT);\n/**\n * Interprets a template literal as MathML fragment that can efficiently render\n * to and update a container.\n *\n * ```ts\n * const num = mathml`<mn>1</mn>`;\n *\n * const eq = html`\n * <math>\n * ${num}\n * </math>`;\n * ```\n *\n * The `mathml` *tag function* should only be used for MathML fragments, or\n * elements that would be contained **inside** a `<math>` HTML element. A common\n * error is placing a `<math>` *element* in a template tagged with the `mathml`\n * tag function. The `<math>` element is an HTML element and should be used\n * within a template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an MathML fragment from the\n * `render()` method, as the MathML fragment will be contained within the\n * element's shadow root and thus not be properly contained within a `<math>`\n * HTML element.\n */\nexport const mathml = tag(MATHML_RESULT);\n/**\n * A sentinel value that signals that a value was handled by a directive and\n * should not be written to the DOM.\n */\nexport const noChange = Symbol.for('lit-noChange');\n/**\n * A sentinel value that signals a ChildPart to fully clear its content.\n *\n * ```ts\n * const button = html`${\n * user.isAdmin\n * ? html`<button>DELETE</button>`\n * : nothing\n * }`;\n * ```\n *\n * Prefer using `nothing` over other falsy values as it provides a consistent\n * behavior between various expression binding contexts.\n *\n * In child expressions, `undefined`, `null`, `''`, and `nothing` all behave the\n * same and render no nodes. In attribute expressions, `nothing` _removes_ the\n * attribute, while `undefined` and `null` will render an empty string. In\n * property expressions `nothing` becomes `undefined`.\n */\nexport const nothing = Symbol.for('lit-nothing');\n/**\n * The cache of prepared templates, keyed by the tagged TemplateStringsArray\n * and _not_ accounting for the specific template tag used. This means that\n * template tags cannot be dynamic - they must statically be one of html, svg,\n * or attr. This restriction simplifies the cache lookup, which is on the hot\n * path for rendering.\n */\nconst templateCache = new WeakMap();\nconst walker = d.createTreeWalker(d, 129 /* NodeFilter.SHOW_{ELEMENT|COMMENT} */);\nlet sanitizerFactoryInternal = noopSanitizer;\nfunction trustFromTemplateString(tsa, stringFromTSA) {\n // A security check to prevent spoofing of Lit template results.\n // In the future, we may be able to replace this with Array.isTemplateObject,\n // though we might need to make that check inside of the html and svg\n // functions, because precompiled templates don't come in as\n // TemplateStringArray objects.\n if (!isArray(tsa) || !tsa.hasOwnProperty('raw')) {\n let message = 'invalid template strings array';\n if (DEV_MODE) {\n message = `\n Internal Error: expected template strings to be an array\n with a 'raw' field. Faking a template strings array by\n calling html or svg like an ordinary function is effectively\n the same as calling unsafeHtml and can lead to major security\n issues, e.g. opening your code up to XSS attacks.\n If you're using the html or svg tagged template functions normally\n and still seeing this error, please file a bug at\n https://github.com/lit/lit/issues/new?template=bug_report.md\n and include information about your build tooling, if any.\n `\n .trim()\n .replace(/\\n */g, '\\n');\n }\n throw new Error(message);\n }\n return policy !== undefined\n ? policy.createHTML(stringFromTSA)\n : stringFromTSA;\n}\n/**\n * Returns an HTML string for the given TemplateStringsArray and result type\n * (HTML or SVG), along with the case-sensitive bound attribute names in\n * template order. The HTML contains comment markers denoting the `ChildPart`s\n * and suffixes on bound attributes denoting the `AttributeParts`.\n *\n * @param strings template strings array\n * @param type HTML or SVG\n * @return Array containing `[html, attrNames]` (array returned for terseness,\n * to avoid object fields since this code is shared with non-minified SSR\n * code)\n */\nconst getTemplateHtml = (strings, type) => {\n // Insert makers into the template HTML to represent the position of\n // bindings. The following code scans the template strings to determine the\n // syntactic position of the bindings. They can be in text position, where\n // we insert an HTML comment, attribute value position, where we insert a\n // sentinel string and re-write the attribute name, or inside a tag where\n // we insert the sentinel string.\n const l = strings.length - 1;\n // Stores the case-sensitive bound attribute names in the order of their\n // parts. ElementParts are also reflected in this array as undefined\n // rather than a string, to disambiguate from attribute bindings.\n const attrNames = [];\n let html = type === SVG_RESULT ? '<svg>' : type === MATHML_RESULT ? '<math>' : '';\n // When we're inside a raw text tag (not it's text content), the regex\n // will still be tagRegex so we can find attributes, but will switch to\n // this regex when the tag ends.\n let rawTextEndRegex;\n // The current parsing state, represented as a reference to one of the\n // regexes\n let regex = textEndRegex;\n for (let i = 0; i < l; i++) {\n const s = strings[i];\n // The index of the end of the last attribute name. When this is\n // positive at end of a string, it means we're in an attribute value\n // position and need to rewrite the attribute name.\n // We also use a special value of -2 to indicate that we encountered\n // the end of a string in attribute name position.\n let attrNameEndIndex = -1;\n let attrName;\n let lastIndex = 0;\n let match;\n // The conditions in this loop handle the current parse state, and the\n // assignments to the `regex` variable are the state transitions.\n while (lastIndex < s.length) {\n // Make sure we start searching from where we previously left off\n regex.lastIndex = lastIndex;\n match = regex.exec(s);\n if (match === null) {\n break;\n }\n lastIndex = regex.lastIndex;\n if (regex === textEndRegex) {\n if (match[COMMENT_START] === '!--') {\n regex = commentEndRegex;\n }\n else if (match[COMMENT_START] !== undefined) {\n // We started a weird comment, like </{\n regex = comment2EndRegex;\n }\n else if (match[TAG_NAME] !== undefined) {\n if (rawTextElement.test(match[TAG_NAME])) {\n // Record if we encounter a raw-text element. We'll switch to\n // this regex at the end of the tag.\n rawTextEndRegex = new RegExp(`</${match[TAG_NAME]}`, 'g');\n }\n regex = tagEndRegex;\n }\n else if (match[DYNAMIC_TAG_NAME] !== undefined) {\n if (DEV_MODE) {\n throw new Error('Bindings in tag names are not supported. Please use static templates instead. ' +\n 'See https://lit.dev/docs/templates/expressions/#static-expressions');\n }\n regex = tagEndRegex;\n }\n }\n else if (regex === tagEndRegex) {\n if (match[ENTIRE_MATCH] === '>') {\n // End of a tag. If we had started a raw-text element, use that\n // regex\n regex = rawTextEndRegex ?? textEndRegex;\n // We may be ending an unquoted attribute value, so make sure we\n // clear any pending attrNameEndIndex\n attrNameEndIndex = -1;\n }\n else if (match[ATTRIBUTE_NAME] === undefined) {\n // Attribute name position\n attrNameEndIndex = -2;\n }\n else {\n attrNameEndIndex = regex.lastIndex - match[SPACES_AND_EQUALS].length;\n attrName = match[ATTRIBUTE_NAME];\n regex =\n match[QUOTE_CHAR] === undefined\n ? tagEndRegex\n : match[QUOTE_CHAR] === '\"'\n ? doubleQuoteAttrEndRegex\n : singleQuoteAttrEndRegex;\n }\n }\n else if (regex === doubleQuoteAttrEndRegex ||\n regex === singleQuoteAttrEndRegex) {\n regex = tagEndRegex;\n }\n else if (regex === commentEndRegex || regex === comment2EndRegex) {\n regex = textEndRegex;\n }\n else {\n // Not one of the five state regexes, so it must be the dynamically\n // created raw text regex and we're at the close of that element.\n regex = tagEndRegex;\n rawTextEndRegex = undefined;\n }\n }\n if (DEV_MODE) {\n // If we have a attrNameEndIndex, which indicates that we should\n // rewrite the attribute name, assert that we're in a valid attribute\n // position - either in a tag, or a quoted attribute value.\n console.assert(attrNameEndIndex === -1 ||\n regex === tagEndRegex ||\n regex === singleQuoteAttrEndRegex ||\n regex === doubleQuoteAttrEndRegex, 'unexpected parse state B');\n }\n // We have four cases:\n // 1. We're in text position, and not in a raw text element\n // (regex === textEndRegex): insert a comment marker.\n // 2. We have a non-negative attrNameEndIndex which means we need to\n // rewrite the attribute name to add a bound attribute suffix.\n // 3. We're at the non-first binding in a multi-binding attribute, use a\n // plain marker.\n // 4. We're somewhere else inside the tag. If we're in attribute name\n // position (attrNameEndIndex === -2), add a sequential suffix to\n // generate a unique attribute name.\n // Detect a binding next to self-closing tag end and insert a space to\n // separate the marker from the tag end:\n const end = regex === tagEndRegex && strings[i + 1].startsWith('/>') ? ' ' : '';\n html +=\n regex === textEndRegex\n ? s + nodeMarker\n : attrNameEndIndex >= 0\n ? (attrNames.push(attrName),\n s.slice(0, attrNameEndIndex) +\n boundAttributeSuffix +\n s.slice(attrNameEndIndex)) +\n marker +\n end\n : s + marker + (attrNameEndIndex === -2 ? i : end);\n }\n const htmlResult = html +\n (strings[l] || '<?>') +\n (type === SVG_RESULT ? '</svg>' : type === MATHML_RESULT ? '</math>' : '');\n // Returned as an array for terseness\n return [trustFromTemplateString(strings, htmlResult), attrNames];\n};\nclass Template {\n constructor(\n // This property needs to remain unminified.\n { strings, ['_$litType$']: type }, options) {\n this.parts = [];\n let node;\n let nodeIndex = 0;\n let attrNameIndex = 0;\n const partCount = strings.length - 1;\n const parts = this.parts;\n // Create template element\n const [html, attrNames] = getTemplateHtml(strings, type);\n this.el = Template.createElement(html, options);\n walker.currentNode = this.el.content;\n // Re-parent SVG or MathML nodes into template root\n if (type === SVG_RESULT || type === MATHML_RESULT) {\n const wrapper = this.el.content.firstChild;\n wrapper.replaceWith(...wrapper.childNodes);\n }\n // Walk the template to find binding markers and create TemplateParts\n while ((node = walker.nextNode()) !== null && parts.length < partCount) {\n if (node.nodeType === 1) {\n if (DEV_MODE) {\n const tag = node.localName;\n // Warn if `textarea` includes an expression and throw if `template`\n // does since these are not supported. We do this by checking\n // innerHTML for anything that looks like a marker. This catches\n // cases like bindings in textarea there markers turn into text nodes.\n if (/^(?:textarea|template)$/i.test(tag) &&\n node.innerHTML.includes(marker)) {\n const m = `Expressions are not supported inside \\`${tag}\\` ` +\n `elements. See https://lit.dev/msg/expression-in-${tag} for more ` +\n `information.`;\n if (tag === 'template') {\n throw new Error(m);\n }\n else\n issueWarning('', m);\n }\n }\n // TODO (justinfagnani): for attempted dynamic tag names, we don't\n // increment the bindingIndex, and it'll be off by 1 in the element\n // and off by two after it.\n if (node.hasAttributes()) {\n for (const name of node.getAttributeNames()) {\n if (name.endsWith(boundAttributeSuffix)) {\n const realName = attrNames[attrNameIndex++];\n const value = node.getAttribute(name);\n const statics = value.split(marker);\n const m = /([.?@])?(.*)/.exec(realName);\n parts.push({\n type: ATTRIBUTE_PART,\n index: nodeIndex,\n name: m[2],\n strings: statics,\n ctor: m[1] === '.'\n ? PropertyPart\n : m[1] === '?'\n ? BooleanAttributePart\n : m[1] === '@'\n ? EventPart\n : AttributePart,\n });\n node.removeAttribute(name);\n }\n else if (name.startsWith(marker)) {\n parts.push({\n type: ELEMENT_PART,\n index: nodeIndex,\n });\n node.removeAttribute(name);\n }\n }\n }\n // TODO (justinfagnani): benchmark the regex against testing for each\n // of the 3 raw text element names.\n if (rawTextElement.test(node.tagName)) {\n // For raw text elements we need to split the text content on\n // markers, create a Text node for each segment, and create\n // a TemplatePart for each marker.\n const strings = node.textContent.split(marker);\n const lastIndex = strings.length - 1;\n if (lastIndex > 0) {\n node.textContent = trustedTypes\n ? trustedTypes.emptyScript\n : '';\n // Generate a new text node for each literal section\n // These nodes are also used as the markers for child parts\n for (let i = 0; i < lastIndex; i++) {\n node.append(strings[i], createMarker());\n // Walk past the marker node we just added\n walker.nextNode();\n parts.push({ type: CHILD_PART, index: ++nodeIndex });\n }\n // Note because this marker is added after the walker's current\n // node, it will be walked to in the outer loop (and ignored), so\n // we don't need to adjust nodeIndex here\n node.append(strings[lastIndex], createMarker());\n }\n }\n }\n else if (node.nodeType === 8) {\n const data = node.data;\n if (data === markerMatch) {\n parts.push({ type: CHILD_PART, index: nodeIndex });\n }\n else {\n let i = -1;\n while ((i = node.data.indexOf(marker, i + 1)) !== -1) {\n // Comment node has a binding marker inside, make an inactive part\n // The binding won't work, but subsequent bindings will\n parts.push({ type: COMMENT_PART, index: nodeIndex });\n // Move to the end of the match\n i += marker.length - 1;\n }\n }\n }\n nodeIndex++;\n }\n if (DEV_MODE) {\n // If there was a duplicate attribute on a tag, then when the tag is\n // parsed into an element the attribute gets de-duplicated. We can detect\n // this mismatch if we haven't precisely consumed every attribute name\n // when preparing the template. This works because `attrNames` is built\n // from the template string and `attrNameIndex` comes from processing the\n // resulting DOM.\n if (attrNames.length !== attrNameIndex) {\n throw new Error(`Detected duplicate attribute bindings. This occurs if your template ` +\n `has duplicate attributes on an element tag. For example ` +\n `\"<input ?disabled=\\${true} ?disabled=\\${false}>\" contains a ` +\n `duplicate \"disabled\" attribute. The error was detected in ` +\n `the following template: \\n` +\n '`' +\n strings.join('${...}') +\n '`');\n }\n }\n // We could set walker.currentNode to another node here to prevent a memory\n // leak, but every time we prepare a template, we immediately render it\n // and re-use the walker in new TemplateInstance._clone().\n debugLogEvent &&\n debugLogEvent({\n kind: 'template prep',\n template: this,\n clonableTemplate: this.el,\n parts: this.parts,\n strings,\n });\n }\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @nocollapse */\n static createElement(html, _options) {\n const el = d.createElement('template');\n el.innerHTML = html;\n return el;\n }\n}\nfunction resolveDirective(part, value, parent = part, attributeIndex) {\n // Bail early if the value is explicitly noChange. Note, this means any\n // nested directive is still attached and is not run.\n if (value === noChange) {\n return value;\n }\n let currentDirective = attributeIndex !== undefined\n ? parent.__directives?.[attributeIndex]\n : parent.__directive;\n const nextDirectiveConstructor = isPrimitive(value)\n ? undefined\n : // This property needs to remain unminified.\n value['_$litDirective$'];\n if (currentDirective?.constructor !== nextDirectiveConstructor) {\n // This property needs to remain unminified.\n currentDirective?.['_$notifyDirectiveConnectionChanged']?.(false);\n if (nextDirectiveConstructor === undefined) {\n currentDirective = undefined;\n }\n else {\n currentDirective = new nextDirectiveConstructor(part);\n currentDirective._$initialize(part, parent, attributeIndex);\n }\n if (attributeIndex !== undefined) {\n (parent.__directives ??= [])[attributeIndex] =\n currentDirective;\n }\n else {\n parent.__directive = currentDirective;\n }\n }\n if (currentDirective !== undefined) {\n value = resolveDirective(part, currentDirective._$resolve(part, value.values), currentDirective, attributeIndex);\n }\n return value;\n}\n/**\n * An updateable instance of a Template. Holds references to the Parts used to\n * update the template instance.\n */\nclass TemplateInstance {\n constructor(template, parent) {\n this._$parts = [];\n /** @internal */\n this._$disconnectableChildren = undefined;\n this._$template = template;\n this._$parent = parent;\n }\n // Called by ChildPart parentNode getter\n get parentNode() {\n return this._$parent.parentNode;\n }\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n // This method is separate from the constructor because we need to return a\n // DocumentFragment and we don't want to hold onto it with an instance field.\n _clone(options) {\n const { el: { content }, parts: parts, } = this._$template;\n const fragment = (options?.creationScope ?? d).importNode(content, true);\n walker.currentNode = fragment;\n let node = walker.nextNode();\n let nodeIndex = 0;\n let partIndex = 0;\n let templatePart = parts[0];\n while (templatePart !== undefined) {\n if (nodeIndex === templatePart.index) {\n let part;\n if (templatePart.type === CHILD_PART) {\n part = new ChildPart(node, node.nextSibling, this, options);\n }\n else if (templatePart.type === ATTRIBUTE_PART) {\n part = new templatePart.ctor(node, templatePart.name, templatePart.strings, this, options);\n }\n else if (templatePart.type === ELEMENT_PART) {\n part = new ElementPart(node, this, options);\n }\n this._$parts.push(part);\n templatePart = parts[++partIndex];\n }\n if (nodeIndex !== templatePart?.index) {\n node = walker.nextNode();\n nodeIndex++;\n }\n }\n // We need to set the currentNode away from the cloned tree so that we\n // don't hold onto the tree even if the tree is detached and should be\n // freed.\n walker.currentNode = d;\n return fragment;\n }\n _update(values) {\n let i = 0;\n for (const part of this._$parts) {\n if (part !== undefined) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'set part',\n part,\n value: values[i],\n valueIndex: i,\n values,\n templateInstance: this,\n });\n if (part.strings !== undefined) {\n part._$setValue(values, part, i);\n // The number of values the part consumes is part.strings.length - 1\n // since values are in between template spans. We increment i by 1\n // later in the loop, so increment it by part.strings.length - 2 here\n i += part.strings.length - 2;\n }\n else {\n part._$setValue(values[i]);\n }\n }\n i++;\n }\n }\n}\nclass ChildPart {\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n // ChildParts that are not at the root should always be created with a\n // parent; only RootChildNode's won't, so they return the local isConnected\n // state\n return this._$parent?._$isConnected ?? this.__isConnected;\n }\n constructor(startNode, endNode, parent, options) {\n this.type = CHILD_PART;\n this._$committedValue = nothing;\n // The following fields will be patched onto ChildParts when required by\n // AsyncDirective\n /** @internal */\n this._$disconnectableChildren = undefined;\n this._$startNode = startNode;\n this._$endNode = endNode;\n this._$parent = parent;\n this.options = options;\n // Note __isConnected is only ever accessed on RootParts (i.e. when there is\n // no _$parent); the value on a non-root-part is \"don't care\", but checking\n // for parent would be more code\n this.__isConnected = options?.isConnected ?? true;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n // Explicitly initialize for consistent class shape.\n this._textSanitizer = undefined;\n }\n }\n /**\n * The parent node into which the part renders its content.\n *\n * A ChildPart's content consists of a range of adjacent child nodes of\n * `.parentNode`, possibly bordered by 'marker nodes' (`.startNode` and\n * `.endNode`).\n *\n * - If both `.startNode` and `.endNode` are non-null, then the part's content\n * consists of all siblings between `.startNode` and `.endNode`, exclusively.\n *\n * - If `.startNode` is non-null but `.endNode` is null, then the part's\n * content consists of all siblings following `.startNode`, up to and\n * including the last child of `.parentNode`. If `.endNode` is non-null, then\n * `.startNode` will always be non-null.\n *\n * - If both `.endNode` and `.startNode` are null, then the part's content\n * consists of all child nodes of `.parentNode`.\n */\n get parentNode() {\n let parentNode = wrap(this._$startNode).parentNode;\n const parent = this._$parent;\n if (parent !== undefined &&\n parentNode?.nodeType === 11 /* Node.DOCUMENT_FRAGMENT */) {\n // If the parentNode is a DocumentFragment, it may be because the DOM is\n // still in the cloned fragment during initial render; if so, get the real\n // parentNode the part will be committed into by asking the parent.\n parentNode = parent.parentNode;\n }\n return parentNode;\n }\n /**\n * The part's leading marker node, if any. See `.parentNode` for more\n * information.\n */\n get startNode() {\n return this._$startNode;\n }\n /**\n * The part's trailing marker node, if any. See `.parentNode` for more\n * information.\n */\n get endNode() {\n return this._$endNode;\n }\n _$setValue(value, directiveParent = this) {\n if (DEV_MODE && this.parentNode === null) {\n throw new Error(`This \\`ChildPart\\` has no \\`parentNode\\` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's \\`innerHTML\\` or \\`textContent\\` can do this.`);\n }\n value = resolveDirective(this, value, directiveParent);\n if (isPrimitive(value)) {\n // Non-rendering child values. It's important that these do not render\n // empty text nodes to avoid issues with preventing default <slot>\n // fallback content.\n if (value === nothing || value == null || value === '') {\n if (this._$committedValue !== nothing) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit nothing to child',\n start: this._$startNode,\n end: this._$endNode,\n parent: this._$parent,\n options: this.options,\n });\n this._$clear();\n }\n this._$committedValue = nothing;\n }\n else if (value !== this._$committedValue && value !== noChange) {\n this._commitText(value);\n }\n // This property needs to remain unminified.\n }\n else if (value['_$litType$'] !== undefined) {\n this._commitTemplateResult(value);\n }\n else if (value.nodeType !== undefined) {\n if (DEV_MODE && this.options?.host === value) {\n this._commitText(`[probable mistake: rendered a template's host in itself ` +\n `(commonly caused by writing \\${this} in a template]`);\n console.warn(`Attempted to render the template host`, value, `inside itself. This is almost always a mistake, and in dev mode `, `we render some warning text. In production however, we'll `, `render it, which will usually result in an error, and sometimes `, `in the element disappearing from the DOM.`);\n return;\n }\n this._commitNode(value);\n }\n else if (isIterable(value)) {\n this._commitIterable(value);\n }\n else {\n // Fallback, will render the string representation\n this._commitText(value);\n }\n }\n _insert(node) {\n return wrap(wrap(this._$startNode).parentNode).insertBefore(node, this._$endNode);\n }\n _commitNode(value) {\n if (this._$committedValue !== value) {\n this._$clear();\n if (ENABLE_EXTRA_SECURITY_HOOKS &&\n sanitizerFactoryInternal !== noopSanitizer) {\n const parentNodeName = this._$startNode.parentNode?.nodeName;\n if (parentNodeName === 'STYLE' || parentNodeName === 'SCRIPT') {\n let message = 'Forbidden';\n if (DEV_MODE) {\n if (parentNodeName === 'STYLE') {\n message =\n `Lit does not support binding inside style nodes. ` +\n `This is a security risk, as style injection attacks can ` +\n `exfiltrate data and spoof UIs. ` +\n `Consider instead using css\\`...\\` literals ` +\n `to compose styles, and do dynamic styling with ` +\n `css custom properties, ::parts, <slot>s, ` +\n `and by mutating the DOM rather than stylesheets.`;\n }\n else {\n message =\n `Lit does not support binding inside script nodes. ` +\n `This is a security risk, as it could allow arbitrary ` +\n `code execution.`;\n }\n }\n throw new Error(message);\n }\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit node',\n start: this._$startNode,\n parent: this._$parent,\n value: value,\n options: this.options,\n });\n this._$committedValue = this._insert(value);\n }\n }\n _commitText(value) {\n // If the committed value is a primitive it means we called _commitText on\n // the previous render, and we know that this._$startNode.nextSibling is a\n // Text node. We can now just replace the text content (.data) of the node.\n if (this._$committedValue !== nothing &&\n isPrimitive(this._$committedValue)) {\n const node = wrap(this._$startNode).nextSibling;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(node, 'data', 'property');\n }\n value = this._textSanitizer(value);\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node,\n value,\n options: this.options,\n });\n node.data = value;\n }\n else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n const textNode = d.createTextNode('');\n this._commitNode(textNode);\n // When setting text content, for security purposes it matters a lot\n // what the parent is. For example, <style> and <script> need to be\n // handled with care, while <span> does not. So first we need to put a\n // text node into the document, then we can sanitize its content.\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(textNode, 'data', 'property');\n }\n value = this._textSanitizer(value);\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node: textNode,\n value,\n options: this.options,\n });\n textNode.data = value;\n }\n else {\n this._commitNode(d.createTextNode(value));\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit text',\n node: wrap(this._$startNode).nextSibling,\n value,\n options: this.options,\n });\n }\n }\n this._$committedValue = value;\n }\n _commitTemplateResult(result) {\n // This property needs to remain unminified.\n const { values, ['_$litType$']: type } = result;\n // If $litType$ is a number, result is a plain TemplateResult and we get\n // the template from the template cache. If not, result is a\n // CompiledTemplateResult and _$litType$ is a CompiledTemplate and we need\n // to create the <template> element the first time we see it.\n const template = typeof type === 'number'\n ? this._$getTemplate(result)\n : (type.el === undefined &&\n (type.el = Template.createElement(trustFromTemplateString(type.h, type.h[0]), this.options)),\n type);\n if (this._$committedValue?._$template === template) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'template updating',\n template,\n instance: this._$committedValue,\n parts: this._$committedValue._$parts,\n options: this.options,\n values,\n });\n this._$committedValue._update(values);\n }\n else {\n const instance = new TemplateInstance(template, this);\n const fragment = instance._clone(this.options);\n debugLogEvent &&\n debugLogEvent({\n kind: 'template instantiated',\n template,\n instance,\n parts: instance._$parts,\n options: this.options,\n fragment,\n values,\n });\n instance._update(values);\n debugLogEvent &&\n debugLogEvent({\n kind: 'template instantiated and updated',\n template,\n instance,\n parts: instance._$parts,\n options: this.options,\n fragment,\n values,\n });\n this._commitNode(fragment);\n this._$committedValue = instance;\n }\n }\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @internal */\n _$getTemplate(result) {\n let template = templateCache.get(result.strings);\n if (template === undefined) {\n templateCache.set(result.strings, (template = new Template(result)));\n }\n return template;\n }\n _commitIterable(value) {\n // For an Iterable, we create a new InstancePart per item, then set its\n // value to the item. This is a little bit of overhead for every item in\n // an Iterable, but it lets us recurse easily and efficiently update Arrays\n // of TemplateResults that will be commonly returned from expressions like:\n // array.map((i) => html`${i}`), by reusing existing TemplateInstances.\n // If value is an array, then the previous render was of an\n // iterable and value will contain the ChildParts from the previous\n // render. If value is not an array, clear this part and make a new\n // array for ChildParts.\n if (!isArray(this._$committedValue)) {\n this._$committedValue = [];\n this._$clear();\n }\n // Lets us keep track of how many items we stamped so we can clear leftover\n // items from a previous render\n const itemParts = this._$committedValue;\n let partIndex = 0;\n let itemPart;\n for (const item of value) {\n if (partIndex === itemParts.length) {\n // If no existing part, create a new one\n // TODO (justinfagnani): test perf impact of always creating two parts\n // instead of sharing parts between nodes\n // https://github.com/lit/lit/issues/1266\n itemParts.push((itemPart = new ChildPart(this._insert(createMarker()), this._insert(createMarker()), this, this.options)));\n }\n else {\n // Reuse an existing part\n itemPart = itemParts[partIndex];\n }\n itemPart._$setValue(item);\n partIndex++;\n }\n if (partIndex < itemParts.length) {\n // itemParts always have end nodes\n this._$clear(itemPart && wrap(itemPart._$endNode).nextSibling, partIndex);\n // Truncate the parts array so _value reflects the current state\n itemParts.length = partIndex;\n }\n }\n /**\n * Removes the nodes contained within this Part from the DOM.\n *\n * @param start Start node to clear from, for clearing a subset of the part's\n * DOM (used when truncating iterables)\n * @param from When `start` is specified, the index within the iterable from\n * which ChildParts are being removed, used for disconnecting directives\n * in those Parts.\n *\n * @internal\n */\n _$clear(start = wrap(this._$startNode).nextSibling, from) {\n this._$notifyConnectionChanged?.(false, true, from);\n while (start !== this._$endNode) {\n // The non-null assertion is safe because if _$startNode.nextSibling is\n // null, then _$endNode is also null, and we would not have entered this\n // loop.\n const n = wrap(start).nextSibling;\n wrap(start).remove();\n start = n;\n }\n }\n /**\n * Implementation of RootPart's `isConnected`. Note that this method\n * should only be called on `RootPart`s (the `ChildPart` returned from a\n * top-level `render()` call). It has no effect on non-root ChildParts.\n * @param isConnected Whether to set\n * @internal\n */\n setConnected(isConnected) {\n if (this._$parent === undefined) {\n this.__isConnected = isConnected;\n this._$notifyConnectionChanged?.(isConnected);\n }\n else if (DEV_MODE) {\n throw new Error('part.setConnected() may only be called on a ' +\n 'RootPart returned from render().');\n }\n }\n}\nclass AttributePart {\n get tagName() {\n return this.element.tagName;\n }\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n constructor(element, name, strings, parent, options) {\n this.type = ATTRIBUTE_PART;\n /** @internal */\n this._$committedValue = nothing;\n /** @internal */\n this._$disconnectableChildren = undefined;\n this.element = element;\n this.name = name;\n this._$parent = parent;\n this.options = options;\n if (strings.length > 2 || strings[0] !== '' || strings[1] !== '') {\n this._$committedValue = new Array(strings.length - 1).fill(new String());\n this.strings = strings;\n }\n else {\n this._$committedValue = nothing;\n }\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n this._sanitizer = undefined;\n }\n }\n /**\n * Sets the value of this part by resolving the value from possibly multiple\n * values and static strings and committing it to the DOM.\n * If this part is single-valued, `this._strings` will be undefined, and the\n * method will be called with a single value argument. If this part is\n * multi-value, `this._strings` will be defined, and the method is called\n * with the value array of the part's owning TemplateInstance, and an offset\n * into the value array from which the values should be read.\n * This method is overloaded this way to eliminate short-lived array slices\n * of the template instance values, and allow a fast-path for single-valued\n * parts.\n *\n * @param value The part value, or an array of values for multi-valued parts\n * @param valueIndex the index to start reading values from. `undefined` for\n * single-valued parts\n * @param noCommit causes the part to not commit its value to the DOM. Used\n * in hydration to prime attribute parts with their first-rendered value,\n * but not set the attribute, and in SSR to no-op the DOM operation and\n * capture the value for serialization.\n *\n * @internal\n */\n _$setValue(value, directiveParent = this, valueIndex, noCommit) {\n const strings = this.strings;\n // Whether any of the values has changed, for dirty-checking\n let change = false;\n if (strings === undefined) {\n // Single-value binding case\n value = resolveDirective(this, value, directiveParent, 0);\n change =\n !isPrimitive(value) ||\n (value !== this._$committedValue && value !== noChange);\n if (change) {\n this._$committedValue = value;\n }\n }\n else {\n // Interpolation case\n const values = value;\n value = strings[0];\n let i, v;\n for (i = 0; i < strings.length - 1; i++) {\n v = resolveDirective(this, values[valueIndex + i], directiveParent, i);\n if (v === noChange) {\n // If the user-provided value is `noChange`, use the previous value\n v = this._$committedValue[i];\n }\n change ||=\n !isPrimitive(v) || v !== this._$committedValue[i];\n if (v === nothing) {\n value = nothing;\n }\n else if (value !== nothing) {\n value += (v ?? '') + strings[i + 1];\n }\n // We always record each value, even if one is `nothing`, for future\n // change detection.\n this._$committedValue[i] = v;\n }\n }\n if (change && !noCommit) {\n this._commitValue(value);\n }\n }\n /** @internal */\n _commitValue(value) {\n if (value === nothing) {\n wrap(this.element).removeAttribute(this.name);\n }\n else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(this.element, this.name, 'attribute');\n }\n value = this._sanitizer(value ?? '');\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit attribute',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n wrap(this.element).setAttribute(this.name, (value ?? ''));\n }\n }\n}\nclass PropertyPart extends AttributePart {\n constructor() {\n super(...arguments);\n this.type = PROPERTY_PART;\n }\n /** @internal */\n _commitValue(value) {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(this.element, this.name, 'property');\n }\n value = this._sanitizer(value);\n }\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit property',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.element[this.name] = value === nothing ? undefined : value;\n }\n}\nclass BooleanAttributePart extends AttributePart {\n constructor() {\n super(...arguments);\n this.type = BOOLEAN_ATTRIBUTE_PART;\n }\n /** @internal */\n _commitValue(value) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit boolean attribute',\n element: this.element,\n name: this.name,\n value: !!(value && value !== nothing),\n options: this.options,\n });\n wrap(this.element).toggleAttribute(this.name, !!value && value !== nothing);\n }\n}\nclass EventPart extends AttributePart {\n constructor(element, name, strings, parent, options) {\n super(element, name, strings, parent, options);\n this.type = EVENT_PART;\n if (DEV_MODE && this.strings !== undefined) {\n throw new Error(`A \\`<${element.localName}>\\` has a \\`@${name}=...\\` listener with ` +\n 'invalid content. Event listeners in templates must have exactly ' +\n 'one expression and no surrounding text.');\n }\n }\n // EventPart does not use the base _$setValue/_resolveValue implementation\n // since the dirty checking is more complex\n /** @internal */\n _$setValue(newListener, directiveParent = this) {\n newListener =\n resolveDirective(this, newListener, directiveParent, 0) ?? nothing;\n if (newListener === noChange) {\n return;\n }\n const oldListener = this._$committedValue;\n // If the new value is nothing or any options change we have to remove the\n // part as a listener.\n const shouldRemoveListener = (newListener === nothing && oldListener !== nothing) ||\n newListener.capture !==\n oldListener.capture ||\n newListener.once !==\n oldListener.once ||\n newListener.passive !==\n oldListener.passive;\n // If the new value is not nothing and we removed the listener, we have\n // to add the part as a listener.\n const shouldAddListener = newListener !== nothing &&\n (oldListener === nothing || shouldRemoveListener);\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit event listener',\n element: this.element,\n name: this.name,\n value: newListener,\n options: this.options,\n removeListener: shouldRemoveListener,\n addListener: shouldAddListener,\n oldListener,\n });\n if (shouldRemoveListener) {\n this.element.removeEventListener(this.name, this, oldListener);\n }\n if (shouldAddListener) {\n this.element.addEventListener(this.name, this, newListener);\n }\n this._$committedValue = newListener;\n }\n handleEvent(event) {\n if (typeof this._$committedValue === 'function') {\n this._$committedValue.call(this.options?.host ?? this.element, event);\n }\n else {\n this._$committedValue.handleEvent(event);\n }\n }\n}\nclass ElementPart {\n constructor(element, parent, options) {\n this.element = element;\n this.type = ELEMENT_PART;\n /** @internal */\n this._$disconnectableChildren = undefined;\n this._$parent = parent;\n this.options = options;\n }\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n _$setValue(value) {\n debugLogEvent &&\n debugLogEvent({\n kind: 'commit to element binding',\n element: this.element,\n value,\n options: this.options,\n });\n resolveDirective(this, value);\n }\n}\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LH object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-element, which re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LH = {\n // Used in lit-ssr\n _boundAttributeSuffix: boundAttributeSuffix,\n _marker: marker,\n _markerMatch: markerMatch,\n _HTML_RESULT: HTML_RESULT,\n _getTemplateHtml: getTemplateHtml,\n // Used in tests and private-ssr-support\n _TemplateInstance: TemplateInstance,\n _isIterable: isIterable,\n _resolveDirective: resolveDirective,\n _ChildPart: ChildPart,\n _AttributePart: AttributePart,\n _BooleanAttributePart: BooleanAttributePart,\n _EventPart: EventPart,\n _PropertyPart: PropertyPart,\n _ElementPart: ElementPart,\n};\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? global.litHtmlPolyfillSupportDevMode\n : global.litHtmlPolyfillSupport;\npolyfillSupport?.(Template, ChildPart);\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for lit-html usage.\n(global.litHtmlVersions ??= []).push('3.3.1');\nif (DEV_MODE && global.litHtmlVersions.length > 1) {\n queueMicrotask(() => {\n issueWarning('multiple-versions', `Multiple versions of Lit loaded. ` +\n `Loading multiple versions is not recommended.`);\n });\n}\n/**\n * Renders a value, usually a lit-html TemplateResult, to the container.\n *\n * This example renders the text \"Hello, Zoe!\" inside a paragraph tag, appending\n * it to the container `document.body`.\n *\n * ```js\n * import {html, render} from 'lit';\n *\n * const name = \"Zoe\";\n * render(html`<p>Hello, ${name}!</p>`, document.body);\n * ```\n *\n * @param value Any [renderable\n * value](https://lit.dev/docs/templates/expressions/#child-expressions),\n * typically a {@linkcode TemplateResult} created by evaluating a template tag\n * like {@linkcode html} or {@linkcode svg}.\n * @param container A DOM container to render to. The first render will append\n * the rendered value to the container, and subsequent renders will\n * efficiently update the rendered value if the same result type was\n * previously rendered there.\n * @param options See {@linkcode RenderOptions} for options documentation.\n * @see\n * {@link https://lit.dev/docs/libraries/standalone-templates/#rendering-lit-html-templates| Rendering Lit HTML Templates}\n */\nexport const render = (value, container, options) => {\n if (DEV_MODE && container == null) {\n // Give a clearer error message than\n // Uncaught TypeError: Cannot read properties of null (reading\n // '_$litPart$')\n // which reads like an internal Lit error.\n throw new TypeError(`The container to render into may not be ${container}`);\n }\n const renderId = DEV_MODE ? debugLogRenderId++ : 0;\n const partOwnerNode = options?.renderBefore ?? container;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let part = partOwnerNode['_$litPart$'];\n debugLogEvent &&\n debugLogEvent({\n kind: 'begin render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n if (part === undefined) {\n const endNode = options?.renderBefore ?? null;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n partOwnerNode['_$litPart$'] = part = new ChildPart(container.insertBefore(createMarker(), endNode), endNode, undefined, options ?? {});\n }\n part._$setValue(value);\n debugLogEvent &&\n debugLogEvent({\n kind: 'end render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n return part;\n};\nif (ENABLE_EXTRA_SECURITY_HOOKS) {\n render.setSanitizer = setSanitizer;\n render.createSanitizer = createSanitizer;\n if (DEV_MODE) {\n render._testOnlyClearSanitizerFactoryDoNotCallOrElse =\n _testOnlyClearSanitizerFactoryDoNotCallOrElse;\n }\n}\n//# sourceMappingURL=lit-html.js.map",
6
- "import { TemplateResult } from 'lit-html';\nimport { CSSObject, DecoratorInstance, DecoratorEffect, ReactiveOptions } from './Types';\n\n/**\n * Invokes a callback and always returns a Promise, regardless of whether the\n * callback itself is sync or async. Lets hooks that may or may not be\n * declared `async` be awaited uniformly without branching at each call site.\n *\n * @internal\n */\nexport function callAsync<T>(callable: (...args: any[]) => T, context: any, ...args: any[]): Promise<T> {\n try {\n const result = callable.apply(context, args);\n return result instanceof Promise ? result : Promise.resolve(result);\n } catch (e) {\n return Promise.reject(e);\n }\n}\n\n/**\n * Duck-types a value as a lit-html `TemplateResult` by looking for its\n * `_$litType$` brand. We avoid `instanceof` so the check survives across\n * realms and when multiple lit-html copies coexist in the same page.\n *\n * @internal\n */\nexport function isTemplateResult(value: unknown): value is TemplateResult {\n return (value !== null && typeof value === 'object' && '_$litType$' in (value as object));\n}\n\n/**\n * Flattens a nested `CSSObject` into a CSS string for injection at render\n * time. When `encapsulation` is a tag selector (light-DOM mode), selectors\n * are scoped under it — `:host` maps to the tag, `&`-prefixed rules nest\n * inline, at-rules pass through untouched, and everything else is prefixed.\n *\n * @internal\n */\nexport function deserializeCSS(object: CSSObject, encapsulation: string = '', level: number = 0): string {\n const keys = Object.keys(object);\n let css = '';\n\n for (const key of keys) {\n const value = object[key];\n\n if (typeof value === 'object' && value !== null) {\n if (encapsulation && !key.startsWith('@')) {\n if (key.startsWith('&')) {\n css += `${key.replace(/&/g, encapsulation)} {\\n`;\n } else if (key === ':host') {\n // In light DOM there is no shadow root, so `:host` is rewritten to\n // the component's tag selector to preserve the same targeting.\n css += `${encapsulation} {\\n`;\n } else {\n css += `${encapsulation} ${key} {\\n`;\n }\n } else {\n css += `${key} {\\n`;\n }\n\n const properties = Object.keys(value);\n for (const property of properties) {\n css += '\\t'.repeat(level);\n const propValue = value[property];\n\n if (typeof propValue === 'object' && propValue !== null) {\n const temp: CSSObject = {};\n temp[property] = propValue;\n css += deserializeCSS(temp, encapsulation, level + 1);\n } else {\n css += `\\t${property}: ${propValue};\\n`;\n }\n }\n css += '}\\n';\n } else {\n css += '\\t'.repeat(level);\n css += `\\t${key}: ${value};\\n`;\n }\n }\n\n return css;\n}\n\n/** Metadata slot: array of attribute names that `@Attribute` wants observed on the element. @internal */\nexport const PROP_ATTRIBUTES: unique symbol = Symbol('pandora:propAttributes');\n\n/** Metadata slot: per-instance effect functions to replay when a class is evolved or lazily registered. @internal */\nexport const DECORATOR_EFFECTS: unique symbol = Symbol('pandora:decoratorEffects');\n\n/** Metadata slot: teardown callbacks attached to an instance so the outgoing class can unwind before an evolve swap. @internal */\nexport const DECORATOR_TEARDOWNS: unique symbol = Symbol('pandora:decoratorTeardowns');\n\n/** Metadata slot: `@Watch` registrations pairing a watched property name with the handler method name. @internal */\nexport const WATCH_HANDLERS: unique symbol = Symbol('pandora:watchHandlers');\n\n/** Metadata slot: set of property names declared reactive via `@State`, `@Attribute`, or `@Property` — used to validate `@Watch` targets. @internal */\nexport const REACTIVE_FIELDS: unique symbol = Symbol('pandora:reactiveFields');\n\n/** Metadata slot: array of `@Listen` registrations describing event name, target resolver, and options. @internal */\nexport const LISTEN_HANDLERS: unique symbol = Symbol('pandora:listenHandlers');\n\n/** Metadata slot: resolved `@Style` output (stylesheet text and encapsulation hints) attached by the style decorator. @internal */\nexport const STYLE_METADATA: unique symbol = Symbol('pandora:styleMetadata');\n\n/** Metadata slot: map from observed attribute names to the handlers that sync them into the instance field. @internal */\nexport const ATTR_HANDLERS: unique symbol = Symbol('pandora:attrHandlers');\n\n/** Metadata slot: per-field `@Subscribe` registrations that wire a store/observable into a property. @internal */\nexport const SUBSCRIBE_HANDLERS: unique symbol = Symbol('pandora:subscribeHandlers');\n\n/**\n * Register a per-instance effect on a class's metadata.\n *\n * Custom-decorator authors call this to attach work that should run once\n * for each component instance — typically during `connectedCallback`. The\n * Registry replays these effects when a class is evolved or lazily\n * registered, so your decorator keeps working across hot swaps.\n *\n * @param meta - The decorator-context metadata object (`context.metadata`).\n * @param effect - A function that receives the component instance.\n *\n * @example\n * function LogMount(): ClassDecorator {\n * return (target, context) => {\n * addDecoratorEffect(context.metadata, (instance) => {\n * console.log(`${instance.tagName} mounted`);\n * });\n * };\n * }\n */\nexport function addDecoratorEffect(meta: Record<symbol, unknown>, effect: DecoratorEffect): void {\n if (!Object.hasOwn(meta, DECORATOR_EFFECTS)) {\n const inherited = meta[DECORATOR_EFFECTS] as DecoratorEffect[] | undefined;\n meta[DECORATOR_EFFECTS] = inherited ? [...inherited] : [];\n }\n\n (meta[DECORATOR_EFFECTS] as DecoratorEffect[]).push(effect);\n}\n\n/**\n * Register a teardown function for a reactive binding on a component instance.\n *\n * The function runs when the component's class is evolved or lazily\n * replaced — letting the incoming implementation tear down subscriptions,\n * observers, or listeners set up by the previous class before new decorator\n * effects install theirs.\n *\n * Teardowns registered via this helper do NOT automatically run on\n * disconnect. If your decorator installs listeners or subscriptions that\n * must unwind on disconnect, register them in the decorator effect and\n * handle their removal explicitly in that effect's returned cleanup, or\n * through the component's own disconnect path.\n *\n * @param instance - The component instance to attach the teardown to.\n * @param teardown - A function that releases any resources held by the decorator when the class is evolved or replaced.\n *\n * @example\n * function ResizeAware(): ClassDecorator {\n * return (target, context) => {\n * addDecoratorEffect(context.metadata, (instance) => {\n * const observer = new ResizeObserver(() => {});\n * observer.observe(instance);\n * // Runs when the class is evolved or lazily replaced, so the\n * // incoming implementation can install its own observer cleanly.\n * addTeardown(instance, () => observer.disconnect());\n * });\n * };\n * }\n */\nexport function addTeardown(instance: DecoratorInstance, teardown: () => void): void {\n if (!instance[DECORATOR_TEARDOWNS]) {\n instance[DECORATOR_TEARDOWNS] = [];\n }\n (instance[DECORATOR_TEARDOWNS] as (() => void)[]).push(teardown);\n}\n\n// Stable symbol registry for `reactive()`. Repeat calls on the same property\n// name must reuse the same hidden slot — otherwise reconnecting a field (for\n// example, after an evolve) would orphan the previous value behind a fresh\n// symbol and the getter would read `undefined`.\nconst reactiveKeys = new Map<string, symbol>();\n\n/**\n * Returns the hidden-slot symbol used to back a reactive field named\n * `propertyKey`, creating it on first use. The symbol is shared across all\n * instances so `reactive()` can be called more than once for the same\n * property without losing its stored value.\n *\n * @internal\n */\nfunction getReactiveKey(propertyKey: string): symbol {\n let key = reactiveKeys.get(propertyKey);\n if (!key) {\n key = Symbol(`__pandora_reactive_${propertyKey}`);\n reactiveKeys.set(propertyKey, key);\n }\n return key;\n}\n\n/**\n * Make a plain field on a component instance reactive at runtime.\n *\n * This is the imperative escape hatch for `@State`: use it when you cannot\n * reach for decorators (for example, in environments without decorator\n * support, or when wiring up a field from a constructor or custom\n * decorator). The field keeps its current value, but writes now trigger\n * `@Watch` handlers, `didChange`, and an auto-rerender unless you opt out.\n *\n * @param instance - The component instance that owns the field.\n * @param propertyKey - The field name to make reactive.\n * @param options - Optional initial value, change callback, equality check, or `render: false` to skip auto-rerender.\n *\n * @example\n * // A custom field decorator that installs reactivity at runtime, so the\n * // author doesn't have to compose it with @State at every call site.\n * function Counter(initialValue: number = 0): (target: undefined, context: ClassFieldDecoratorContext) => void {\n * return (_target, context) => {\n * const propertyKey = String(context.name);\n * addDecoratorEffect(context.metadata, (instance) => {\n * reactive(instance, propertyKey, { initialValue });\n * });\n * };\n * }\n */\nexport function reactive(\n instance: DecoratorInstance,\n propertyKey: string,\n options: ReactiveOptions = {}\n): void {\n const valueKey = getReactiveKey(propertyKey);\n const equals = options.equals ?? ((a: unknown, b: unknown) => a === b);\n\n // Safe on repeat calls: if the slot already holds a value (e.g. reconnection after evolve) we leave the user's last write in place.\n if (options.initialValue !== undefined && instance[valueKey] === undefined) {\n instance[valueKey] = options.initialValue;\n }\n\n Object.defineProperty(instance, propertyKey, {\n get() {\n return instance[valueKey];\n },\n set(newVal: unknown) {\n const oldVal = instance[valueKey];\n if (equals(oldVal, newVal)) return;\n instance[valueKey] = newVal;\n\n if (options.onChange) {\n options.onChange(newVal, oldVal);\n }\n\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = ((instance.constructor as any)[Symbol.metadata]) as Record<symbol, unknown> | undefined;\n const entries = meta?.[WATCH_HANDLERS] as Array<{ property: string; methodName: string }> | undefined;\n if (entries) {\n for (const entry of entries) {\n if (entry.property === propertyKey) {\n const method = (instance as any)[entry.methodName];\n if (typeof method === 'function') {\n method.call(instance, newVal, oldVal);\n }\n }\n }\n }\n }\n\n if (typeof (instance as any).didChange === 'function') {\n (instance as any).didChange(propertyKey, oldVal, newVal, 'reactive');\n }\n\n if (options.render !== false && typeof (instance as any)._queueRender === 'function') {\n (instance as any)._queueRender();\n }\n },\n enumerable: true,\n configurable: true\n });\n}\n\n/**\n * Coerces a raw attribute string into its JavaScript value: `null` becomes\n * `undefined`, the empty string and `\"true\"` become `true`, `\"false\"` becomes\n * `false`, numeric strings become numbers, and everything else is passed\n * through as a string. Used when `@Attribute` syncs HTML into a reactive field.\n *\n * @internal\n */\nexport function parseAttributeValue(value: string | null): unknown {\n if (value === null) {\n return undefined;\n }\n\n if (value === '' || value === 'true') {\n return true;\n }\n\n if (value === 'false') {\n return false;\n }\n\n if (!isNaN(Number(value))) {\n return value.includes('.') ? parseFloat(value) : parseInt(value, 10);\n }\n return value;\n}\n\n/**\n * Resolves the `target` option of `@Listen` to an actual `EventTarget`. The\n * strings `\"window\"` and `\"document\"` map to their globals, `\"self\"` (or an\n * omitted option) returns the host element, and any other string is treated\n * as a CSS selector. Selectors are routed through the component's own\n * `query()` when provided so they resolve against the host's subtree (light\n * or shadow) rather than the whole document.\n *\n * @internal\n */\nexport function resolveListenerTarget(\n host: HTMLElement,\n targetOption?: string,\n query?: (selector: string) => Element | null\n): EventTarget | null {\n if (targetOption === 'window') {\n return window;\n }\n\n if (targetOption === 'document') {\n return document;\n }\n\n if (targetOption && targetOption !== 'self') {\n return query ? query(targetOption) : host.querySelector(targetOption);\n }\n\n return host;\n}\n",
7
- "import { render as litRender, TemplateResult, nothing } from 'lit-html';\nimport {\n callAsync,\n deserializeCSS,\n isTemplateResult,\n parseAttributeValue,\n resolveListenerTarget,\n PROP_ATTRIBUTES,\n WATCH_HANDLERS,\n LISTEN_HANDLERS,\n STYLE_METADATA,\n ATTR_HANDLERS,\n SUBSCRIBE_HANDLERS,\n} from './Util';\nimport type { AttrHandler, SubscribeHandler } from './Types';\nimport { Style, TemplateValue, TemplateFunction } from './Types';\n\n/**\n * The base class every Pandora component extends.\n *\n * `Component` is a thin layer over the native `HTMLElement` that wires up\n * Pandora's reactive lifecycle: subclasses declare state with decorators like\n * `@State`, `@Attribute`, and `@Property`, and the base class takes care of\n * registering the tag, batching state changes into microtask-scheduled\n * renders, managing attributes, and running mount and unmount hooks. Most of\n * the time you only implement `render()` and let the decorators do the rest.\n *\n * Rendering is batched on the microtask queue. Multiple synchronous property\n * updates in the same tick coalesce into a single `render()` call. If you\n * need a synchronous render, call `forceRender()`; if you need to group\n * changes explicitly, wrap them in `batch()`.\n *\n * @example\n * import { Component, Register, State, html } from '@aegis-framework/pandora';\n *\n * @Register('my-greeting')\n * class MyGreeting extends Component {\n * @State() name = 'world';\n *\n * render() {\n * return html`<p>Hello, ${this.name}.</p>`;\n * }\n * }\n *\n * // <my-greeting></my-greeting>\n */\nclass Component extends HTMLElement {\n /**\n * The inner HTML the component was mounted with, captured before the first\n * render runs. Exposed publicly as `slotContent`.\n *\n * @internal\n */\n protected _children: string;\n\n /**\n * Tracks whether the element is currently in the DOM. Flipped in\n * `connectedCallback` / `disconnectedCallback` and surfaced publicly as\n * `isConnected`.\n *\n * @internal\n */\n protected _connected: boolean;\n\n /**\n * Flips to `true` once the first mount (including `didMount` and the initial\n * render) has finished. Surfaced publicly as `isReady`.\n *\n * @internal\n */\n protected _isReady: boolean;\n\n /**\n * Remembers whether this instance has ever been mounted. We flip it on\n * after `didMount` so `isFirstMount` stays `true` for the duration of that\n * hook and only becomes `false` on later reconnects.\n *\n * @internal\n */\n protected _hasBeenMounted: boolean;\n\n /**\n * Gates decorator-driven re-renders so that field initializer assignments\n * during construction don't queue a render. Set to `true` after the first\n * render completes, so subsequent `@State` / `@Attribute` writes during\n * `didMount` and later hooks can schedule renders.\n *\n * @internal\n */\n protected _initRenderDone: boolean;\n\n /**\n * Bumps on every render, letting queued microtask renders detect that they\n * have been superseded and bail out before writing to the DOM.\n *\n * @internal\n */\n protected _renderId: number;\n\n /**\n * Tracks whether a microtask render is already queued, so repeated\n * `_queueRender` calls in the same tick coalesce into a single render.\n *\n * @internal\n */\n protected _renderQueued: boolean;\n\n /**\n * The object-form style currently applied through `setStyle`. Persisted so\n * that merge-mode updates can layer new rules on top of previous ones.\n *\n * @internal\n */\n protected _style: Style;\n\n /**\n * `true` while a `batch()` callback is executing. Used by the reactive\n * setters to defer watcher and render scheduling until the batch flushes.\n *\n * @internal\n */\n protected _batching: boolean;\n\n /**\n * Records reactive changes while a `batch()` is open so watchers and\n * `didChange` don't observe intermediate state. Flushed once at the end of\n * the batch with first and last values per property.\n *\n * @internal\n */\n protected _batchedChanges: Array<{ property: string; oldValue: unknown; newValue: unknown; shouldRender: boolean; source: string }>;\n\n /**\n * Backing storage for the custom element tag this class registers under.\n * Populated lazily by the `tag` getter (kebab-casing the class name) or\n * eagerly by `@Register` and the `tag` setter.\n *\n * @internal\n */\n protected static _tag?: string;\n\n /**\n * Backing storage for a class-level template (string or function). Takes\n * precedence over instance `render()` when set. Read and written through\n * the public `template` accessors.\n *\n * @internal\n */\n protected static _template?: string | TemplateFunction;\n\n /**\n * Backing storage for attributes registered manually through the\n * `observedAttributes` setter. Merged with `@Attribute` / `@Property`\n * metadata in the getter.\n *\n * @internal\n */\n protected static _observedAttributes: string[] = [];\n\n /**\n * The adopted `CSSStyleSheet` shared across every instance of this tag.\n * We keep one per class so `setStyle` on one instance styles them all.\n *\n * @internal\n */\n protected static _styleSheet: CSSStyleSheet | null = null;\n\n /**\n * Object-form style declarations shared across every instance of this tag.\n * `setStyle()` writes to this class-level store because the stylesheet itself\n * is class-wide.\n *\n * @internal\n */\n protected static _sharedStyle: Style = {};\n\n // Registry integration hooks\n\n /**\n * Set by `Registry._init` to notify the registry whenever an instance\n * finishes `connectedCallback`. Left unset when the registry isn't loaded.\n *\n * @internal\n */\n static _onMount?: (component: Component, tag: string) => void;\n\n /**\n * Set by `Registry._init` to notify the registry after\n * `disconnectedCallback` finishes tearing an instance down.\n *\n * @internal\n */\n static _onUnmount?: (component: Component, tag: string) => void;\n\n /**\n * Set by `Registry._init` to route lifecycle errors through the registry's\n * error handler. When unset, errors rethrow from the lifecycle method.\n *\n * @internal\n */\n static _onError?: (error: Error, component: Component, tag: string, lifecycle: string) => void;\n\n /**\n * Set by `Registry._init` so the registry can transform values flowing\n * through reactive setters and render output (currently `render` middleware).\n *\n * @internal\n */\n static _applyMiddleware?: (type: string, component: Component, value: unknown, renderType?: 'string' | 'lit') => unknown;\n\n /**\n * Set by `Registry._init`. Lets `Component` cheaply skip the middleware\n * bridge when no middleware of a given type is registered.\n *\n * @internal\n */\n static _hasMiddleware?: (type: string) => boolean;\n\n // Registry integration hooks for @Subscribe\n\n /**\n * Set by `Registry._init`. Subscribes an instance to a global state key\n * and returns an unsubscribe function. Used to wire up `@Subscribe`\n * handlers on mount.\n *\n * @internal\n */\n static _subscribe?: (stateKey: string, callback: (newVal: unknown, oldVal: unknown) => void) => () => void;\n\n /**\n * Set by `Registry._init`. Reads the current value for a global state key\n * so `@Subscribe` fields can seed themselves on activation.\n *\n * @internal\n */\n static _getGlobalState?: (stateKey: string) => unknown;\n\n /**\n * Set by `Registry._init`. Applies the current implementation registered\n * with `Registry.evolve()` so that instances created after `evolve` pick up\n * the latest behavior.\n *\n * @internal\n */\n static _applyCurrentImplementation?: (instance: Component, tag: string) => void;\n\n /**\n * Activates a single `@Subscribe` handler on an instance, hooking it into\n * the registry's global state so the field tracks the chosen state key.\n * Safe to call more than once — any prior subscription in the handler's\n * slot is torn down first.\n *\n * @internal\n */\n static _activateSubscription(instance: Component, handler: SubscribeHandler): void {\n if (!Component._subscribe) {\n return;\n }\n\n const inst = instance as unknown as Record<symbol, unknown>;\n\n // Tear down any prior subscription occupying this handler's slot so\n // repeated activations don't double-fire on state changes.\n if (inst[handler.unsubKey]) {\n (inst[handler.unsubKey] as () => void)();\n inst[handler.unsubKey] = undefined;\n }\n\n inst[handler.unsubKey] = Component._subscribe(handler.stateKey, (newVal: unknown) => {\n const oldVal = inst[handler.valueKey];\n\n if (oldVal === newVal) {\n return;\n }\n\n inst[handler.valueKey] = newVal;\n instance.didChange(handler.propertyKey, oldVal, newVal, 'consumer');\n\n if (instance.isReady) {\n (instance as unknown as { _queueRender: () => void })._queueRender();\n }\n });\n\n const current = Component._getGlobalState?.(handler.stateKey);\n\n if (current !== undefined) {\n inst[handler.valueKey] = current;\n }\n }\n\n /**\n * The list of attributes the browser will notify Pandora about.\n *\n * This is the standard custom-elements introspection hook. It merges any\n * attributes you registered manually with the ones declared through\n * `@Attribute` and `@Property({ attribute })` decorators, so you rarely need\n * to set it by hand.\n *\n * @returns The tag names of observed attributes, with duplicates removed.\n *\n * @example\n * class MyButton extends Component {\n * @Attribute() disabled = false;\n * }\n *\n * MyButton.observedAttributes; // ['disabled']\n */\n static get observedAttributes(): string[] {\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = (this as any)[Symbol.metadata];\n const metaAttrs = meta?.[PROP_ATTRIBUTES] as string[] | undefined;\n\n if (metaAttrs?.length) {\n return [...new Set([...this._observedAttributes, ...metaAttrs])];\n }\n }\n\n return this._observedAttributes;\n }\n\n /**\n * Overrides the list of observed attributes for this class.\n *\n * Prefer `@Attribute` / `@Property({ attribute })` instead — they keep the\n * attribute list and the reactive field in sync automatically. Setting\n * this by hand is an escape hatch for integrations that need to declare\n * attributes without decorators.\n *\n * @param value - The attribute names the component should react to.\n */\n static set observedAttributes(value: string[]) {\n this._observedAttributes = value;\n }\n\n /**\n * The custom element tag this component registers under.\n *\n * If you used `@Register('my-tag')` the tag is whatever you passed in. If\n * you didn't, Pandora derives one from the class name by converting it to\n * kebab-case (`MyGreeting` becomes `my-greeting`).\n *\n * @returns The tag name the component is known by in the DOM.\n *\n * @example\n * @Register('user-avatar')\n * class UserAvatar extends Component {}\n * UserAvatar.tag; // 'user-avatar'\n *\n * class ThemeToggle extends Component {}\n * ThemeToggle.tag; // 'theme-toggle' — derived from the class name\n */\n static get tag(): string {\n if (typeof this._tag === 'undefined') {\n let tag = this.name;\n const matches = tag.match(/([A-Z])/g);\n\n if (matches !== null) {\n for (const match of matches) {\n tag = tag.replace(match, `-${match}`.toLowerCase());\n }\n }\n\n this._tag = tag.slice(1);\n }\n\n return this._tag;\n }\n\n /**\n * Overrides the tag name this component registers under.\n *\n * `@Register('my-tag')` is the preferred way to set this. Use the setter\n * when you need to assign a tag programmatically before calling\n * `register()` yourself.\n *\n * @param value - The custom element tag (must contain a hyphen).\n */\n static set tag(value: string) {\n this._tag = value;\n }\n\n /**\n * The class-level template used in place of `render()` when defined.\n *\n * Pandora picks this up automatically from an HTML `<template id=\"my-tag\">`\n * on first mount, or you can assign a string or a function that returns\n * one. When set, it takes precedence over the instance `render()` method.\n *\n * @returns The template, or `undefined` if the component renders through\n * `render()`.\n *\n * @example\n * MyGreeting.template = (self) => `<p>Hello, ${self.name}.</p>`;\n */\n static get template(): string | TemplateFunction | undefined {\n return this._template;\n }\n\n /**\n * Replaces the class-level template and refreshes every mounted instance.\n *\n * Assigning a new template triggers `forceRender()` on every live element\n * of this tag, so the UI picks up the new markup immediately. Pass a\n * string for static markup, or a function `(self) => string` when you need\n * access to the instance.\n *\n * @param value - The new template, or `undefined` to clear it.\n *\n * @example\n * // Swap the greeting template at runtime.\n * MyGreeting.template = '<p>Welcome back.</p>';\n */\n static set template(value: string | TemplateFunction | undefined) {\n this._template = value;\n\n if (value !== undefined) {\n document.querySelectorAll(this.tag).forEach((instance) => {\n if (instance instanceof Component && instance._isReady) {\n instance.forceRender();\n }\n });\n }\n }\n\n /**\n * Initializes a component instance.\n *\n * The browser calls this for you when the element is created — either\n * through `document.createElement('my-tag')`, `new MyTag()`, or when the\n * parser encounters the tag in HTML. Subclasses rarely need to override\n * it; reach for `willMount()` or `didMount()` for setup work. If you do\n * override, remember to call `super()` first.\n *\n * @example\n * class MyCounter extends Component {\n * constructor() {\n * super();\n * // your own setup here\n * }\n * }\n */\n constructor() {\n super();\n this._children = '';\n this._connected = false;\n this._isReady = false;\n this._hasBeenMounted = false;\n this._initRenderDone = false;\n this._renderId = 0;\n this._renderQueued = false;\n this._style = {};\n this._batching = false;\n this._batchedChanges = [];\n }\n\n /**\n * The original inner HTML the component was mounted with.\n *\n * Pandora captures whatever markup lived between the opening and closing\n * tags on first mount, before any render runs. Use this when you want to\n * project user-provided content into your template — it is the string-\n * render equivalent of a light-DOM `<slot>`.\n *\n * @returns The trimmed inner HTML at mount time.\n *\n * @example\n * class MyCard extends Component {\n * render() {\n * return `<div class=\"card\">${this.slotContent}</div>`;\n * }\n * }\n *\n * // <my-card>Hello</my-card> → <div class=\"card\">Hello</div>\n */\n get slotContent(): string {\n return this._children;\n }\n\n /**\n * Whether the component is currently attached to the DOM.\n *\n * Flips to `true` inside `connectedCallback()` and back to `false` during\n * `disconnectedCallback()`. Useful if you're running async work that\n * should stop once the element is removed.\n *\n * @returns `true` while the element is in the document.\n *\n * @example\n * async loadData() {\n * const data = await fetch('/api/posts').then(r => r.json());\n * if (!this.isConnected) return; // bail out if the user navigated away\n * this.items = data;\n * }\n */\n get isConnected(): boolean {\n return this._connected;\n }\n\n /**\n * Whether the first mount lifecycle (including the initial render) has\n * finished.\n *\n * Prefer `ready()` when you want to run code once the component is ready;\n * this getter is handy when you need a synchronous check — for example\n * inside a parent component that wants to talk to a freshly inserted\n * child.\n *\n * @returns `true` after `didMount()` and the initial render have run.\n *\n * @example\n * if (avatar.isReady) {\n * avatar.focus();\n * } else {\n * avatar.ready(() => avatar.focus());\n * }\n */\n get isReady(): boolean {\n return this._isReady;\n }\n\n /**\n * Whether this is the component's first time being mounted.\n *\n * `true` during the initial `connectedCallback()` / `didMount()`, `false`\n * on subsequent reconnects (for example if the element is detached and\n * re-attached, or moved in the DOM). Use it to separate first-time setup\n * from re-connect behavior inside lifecycle hooks.\n *\n * @returns `true` until the first mount completes.\n *\n * @example\n * async didMount() {\n * if (this.isFirstMount) {\n * await this.loadInitialData();\n * }\n * }\n */\n get isFirstMount(): boolean {\n return !this._hasBeenMounted;\n }\n\n /**\n * Set eagerly at `Registry` module load (not by `_init` like the other\n * hooks) so that `Component.register()` delegates to the registry as soon\n * as the registry module is imported, regardless of init ordering.\n *\n * @internal\n */\n static _registryRegister?: (tag: string, component: typeof Component) => void;\n\n /**\n * Registers this class as a custom element so the browser will recognise\n * its tag in the DOM.\n *\n * `@Register('my-tag')` is the preferred path — it sets the tag and calls\n * this for you. Call `register()` directly when you're wiring things up\n * without decorators, or when you configured the tag manually through the\n * `tag` setter.\n *\n * @example\n * class MyCounter extends Component {\n * static tag = 'my-counter';\n * render() { return `<p>count</p>`; }\n * }\n * MyCounter.register();\n */\n static register(): void {\n if (Component._registryRegister) {\n Component._registryRegister(this.tag, this);\n } else {\n window.customElements.define(this.tag, this);\n }\n }\n\n /**\n * Whether the component is currently inside a `batch()` call.\n *\n * Mostly useful for code paths that branch on whether an update is part\n * of a larger batched change — for example deciding whether to defer side\n * effects until the batch completes.\n *\n * @returns `true` while a `batch()` callback is running.\n *\n * @example\n * if (!this.isBatching) {\n * this.logAudit(change);\n * }\n */\n get isBatching(): boolean {\n return this._batching;\n }\n\n /**\n * Groups several state changes into a single render.\n *\n * Every reactive property assignment you do inside `fn` is collected and\n * replayed after it returns. `@Watch` callbacks and `didChange()` run\n * once each, with the first and last values seen during the batch, and\n * Pandora queues just one render at the end. Net no-ops (setting `A`\n * back to its original value within the same batch) are skipped entirely.\n *\n * @param fn - A synchronous function that performs the property changes.\n *\n * @example\n * class MyCounter extends Component {\n * @State() count = 0;\n * @State() label = 'clicks';\n *\n * reset() {\n * this.batch(() => {\n * this.count = 0;\n * this.label = 'reset';\n * });\n * // Only one render runs for both changes.\n * }\n * }\n */\n batch(fn: () => void): void {\n this._batching = true;\n this._batchedChanges = [];\n\n try {\n fn();\n } finally {\n this._batching = false;\n const changes = this._batchedChanges;\n this._batchedChanges = [];\n\n if (changes.length > 0) {\n let hasRenderableChange = false;\n for (const { property, oldValue, newValue, shouldRender, source } of changes) {\n // Drop net no-ops (A → B → A within the same batch) so watchers\n // and didChange never observe a change that ultimately didn't happen.\n if (oldValue === newValue) {\n continue;\n }\n\n if (shouldRender) {\n hasRenderableChange = true;\n }\n\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = ((this.constructor as any)[Symbol.metadata]) as Record<symbol, unknown> | undefined;\n const entries = meta?.[WATCH_HANDLERS] as Array<{ property: string; methodName: string }> | undefined;\n\n if (entries) {\n for (const entry of entries) {\n if (entry.property === property) {\n const method = (this as any)[entry.methodName];\n\n if (typeof method === 'function') {\n method.call(this, newValue, oldValue);\n }\n }\n }\n }\n }\n\n this.didChange(property, oldValue, newValue, source);\n }\n\n // Only queue a render if at least one flushed change was actually\n // render-eligible — `@State({ render: false })` fields skip it.\n if (hasRenderableChange && this._connected) {\n this._queueRender();\n }\n }\n }\n }\n\n /*\n * =========================\n * Rendering\n * =========================\n */\n\n /**\n * Schedules a render on the microtask queue. Multiple calls in the same\n * tick coalesce into one render, and errors inside the render surface\n * through the registry error handler (or console as a fallback).\n *\n * @internal\n */\n protected _queueRender(): void {\n if (this._renderQueued || !this._connected) {\n return;\n }\n\n this._renderQueued = true;\n\n queueMicrotask(() => {\n this._renderQueued = false;\n\n if (this._connected) {\n this._render().catch((error: Error) => {\n const tag = (this.constructor as typeof Component).tag;\n\n if (Component._onError) {\n Component._onError(error, this, tag, 'render');\n } else {\n const locator = this.id ? `#${this.id}` : this.className ? `.${this.className.split(/\\s+/).join('.')}` : '';\n console.error(`[Pandora] Unhandled render error in <${tag}${locator}>:`, error, this);\n }\n });\n }\n });\n }\n\n /**\n * Renders the component immediately, skipping microtask batching.\n *\n * Normally you don't need this — property changes schedule a render on\n * the microtask queue automatically. Reach for `forceRender()` when you\n * need the DOM to reflect the latest state right now, for example before\n * measuring an element or taking a screenshot in a test.\n *\n * @returns A promise that resolves once the render (including async\n * `render()` returns and `didRender()`) has completed.\n *\n * @example\n * this.count = 42;\n * await this.forceRender();\n * // the counter has the new value painted at this point\n */\n forceRender(): Promise<void> {\n return this._render();\n }\n\n /**\n * Produces the markup for this component.\n *\n * Override this in your subclass. You can return a lit-html `TemplateResult`\n * (from the `html` tagged template), a plain HTML string, `lit-html`'s\n * `nothing` sentinel to render no content, or an empty string `''` to clear\n * the host. Returning nothing (the default) leaves any HTML-defined\n * children untouched, which is what container components rely on.\n *\n * Pandora calls this for you on mount and whenever a reactive property\n * changes — you rarely invoke it yourself. The return may be synchronous\n * or a promise.\n *\n * @returns The markup to render, or `void` to preserve existing content.\n *\n * @example\n * import { html } from '@aegis-framework/pandora';\n *\n * class MyGreeting extends Component {\n * @State() name = 'friend';\n *\n * render() {\n * return html`<p>Hello, ${this.name}.</p>`;\n * }\n * }\n */\n render(): TemplateValue | Promise<TemplateValue> {\n // Default behavior is a no-op: container components that don't override\n // render() keep their HTML-defined children intact. Returning '' is the\n // explicit way to clear the host.\n }\n\n /**\n * Applies a lit-html template result to the host. We clear and stamp the\n * `data-lit-rendered` marker on first use so pre-existing children don't\n * interfere with lit's reconciliation, then delegate to `litRender`.\n *\n * @internal\n */\n protected _applyLitRender(result: TemplateResult | typeof nothing): void {\n if (!this.hasAttribute('data-lit-rendered')) {\n this.innerHTML = '';\n this.setAttribute('data-lit-rendered', '');\n }\n\n litRender(result, this, { host: this });\n }\n\n /**\n * Applies a string render result. Honours `<slot>` as the injection point\n * when one is present, otherwise sets `innerHTML` directly and re-appends\n * the captured `slotContent` if the new markup didn't already include it.\n *\n * @internal\n */\n protected _applyStringRender(html: string): void {\n // An empty string is an explicit \"clear content\" request.\n if (html === '') {\n this.innerHTML = '';\n return;\n }\n\n const template = document.createElement('template');\n template.innerHTML = html;\n\n const slot = template.content.querySelector('slot');\n\n if (slot !== null) {\n const content = document.createElement('template');\n content.innerHTML = this._children;\n slot.replaceWith(content.content);\n this.innerHTML = '';\n this.appendChild(template.content);\n } else {\n this.innerHTML = html;\n\n if (this._children !== '' && html.indexOf(this._children) === -1) {\n this.innerHTML += this._children;\n }\n }\n }\n\n /**\n * Runs a single render cycle: resolves the template, applies middleware,\n * writes to the DOM, and re-attaches `@Listen` handlers. Bumps `_renderId`\n * up front so any concurrent render that awaited through ours detects it\n * has been superseded and bails before touching the DOM.\n *\n * @internal\n */\n protected async _render(): Promise<void> {\n type RenderResult = TemplateValue;\n\n const renderId = ++this._renderId;\n const ctor = this.constructor as typeof Component;\n\n let renderFn: () => RenderResult | Promise<RenderResult> = this.render;\n\n if (ctor._template !== undefined) {\n renderFn = () => {\n if (typeof ctor._template === 'function') {\n return ctor._template.call(this, this);\n }\n\n return ctor._template as string;\n };\n }\n\n let result = await callAsync(renderFn, this);\n\n // A newer render started while we were awaiting; let it win.\n if (renderId !== this._renderId) {\n return;\n }\n\n // void / null means \"don't touch the DOM\" (container components rely on\n // this to preserve their HTML-defined children), but we still re-bind\n // @Listen handlers and run didRender so consumers see consistent hooks.\n if (result === undefined || result === null) {\n this._detachListeners();\n this._attachListeners();\n await callAsync(this.didRender, this);\n return;\n }\n\n const renderType: 'string' | 'lit' = isTemplateResult(result) || result === nothing ? 'lit' : 'string';\n\n if (Component._hasMiddleware?.('render') && Component._applyMiddleware) {\n result = Component._applyMiddleware('render', this, result, renderType) as RenderResult;\n }\n\n if (isTemplateResult(result) || result === nothing) {\n this._applyLitRender(result as TemplateResult | typeof nothing);\n } else {\n this._applyStringRender((result as string).trim());\n }\n\n // Rebind @Listen handlers on every render: selector-targeted listeners\n // may have pointed at nodes that this render replaced, so stale bindings\n // need to be swapped out for fresh ones.\n this._detachListeners();\n this._attachListeners();\n\n await callAsync(this.didRender, this);\n }\n\n /*\n * =========================\n * Styles\n * =========================\n */\n\n /**\n * Applies styles to the component via an adopted stylesheet.\n *\n * Pass a `Style` object to describe your rules declaratively, or a raw\n * CSS string if you already have text. By default the styles are merged\n * with anything previously applied to the component; pass `reset: true`\n * to replace the stylesheet instead. The stylesheet is shared across\n * every instance of the tag, so setting it once styles them all.\n *\n * @param style - A `Style` object or a CSS string.\n * @param reset - When `true`, replace the existing styles instead of\n * merging on top.\n * @returns The current object-form style after the update (useful when\n * you want to read back the merged state).\n *\n * @example\n * class ThemeToggle extends Component {\n * async didMount() {\n * this.setStyle({\n * ':host': { display: 'inline-block', cursor: 'pointer' },\n * 'button': { padding: '0.5rem 1rem' }\n * });\n * }\n * }\n *\n * // Or with a raw CSS string:\n * this.setStyle(':host { color: rebeccapurple; }');\n */\n setStyle(style: Style | string, reset: boolean = false): Style {\n const staticComponent = this.constructor as typeof Component;\n\n if (!staticComponent._styleSheet) {\n staticComponent._styleSheet = new CSSStyleSheet();\n }\n\n let cssText = '';\n\n if (typeof style === 'object') {\n if (!Object.hasOwn(staticComponent, '_sharedStyle')) {\n staticComponent._sharedStyle = {};\n }\n\n if (!reset) {\n staticComponent._sharedStyle = { ...staticComponent._sharedStyle, ...style };\n } else {\n staticComponent._sharedStyle = { ...style };\n }\n this._style = staticComponent._sharedStyle;\n cssText = deserializeCSS(staticComponent._sharedStyle, staticComponent.tag);\n } else if (typeof style === 'string') {\n if (!reset) {\n const existingRules = Array.from(staticComponent._styleSheet.cssRules || [])\n .map(rule => rule.cssText)\n .join('\\n');\n cssText = existingRules + '\\n' + style;\n } else {\n cssText = style;\n staticComponent._sharedStyle = {};\n this._style = {};\n }\n }\n\n staticComponent._styleSheet.replaceSync(cssText);\n\n if (!document.adoptedStyleSheets.includes(staticComponent._styleSheet)) {\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, staticComponent._styleSheet];\n }\n\n return staticComponent._sharedStyle;\n }\n\n /*\n * =========================\n * Event Helpers\n * =========================\n */\n\n /**\n * Attaches an event listener to the component.\n *\n * A thin, chainable wrapper around `addEventListener` scoped to the host\n * element. Prefer the `@Listen` decorator for anything that should live\n * for the lifetime of the component — `on()` is handy for one-offs and\n * for ad-hoc wiring from outside the class.\n *\n * @param event - The event name to listen for.\n * @param callback - The handler to run when the event fires.\n * @param options - Standard `addEventListener` options.\n * @returns The component, for chaining.\n *\n * @example\n * const button = document.querySelector('my-button');\n * button.on('click', () => console.log('clicked'));\n */\n on<K extends keyof HTMLElementEventMap>(\n event: K,\n callback: (this: this, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ): this;\n on(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;\n on(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this {\n this.addEventListener(event, callback, options);\n return this;\n }\n\n /**\n * Removes a previously attached event listener from the component.\n *\n * Pass the same event name, callback reference, and options you used in\n * `on()` / `once()` — the underlying `removeEventListener` only matches\n * exact triples.\n *\n * @param event - The event name.\n * @param callback - The handler reference to remove.\n * @param options - The options the listener was registered with.\n * @returns The component, for chaining.\n *\n * @example\n * const onClick = () => console.log('clicked');\n * button.on('click', onClick);\n * // later...\n * button.off('click', onClick);\n */\n off<K extends keyof HTMLElementEventMap>(\n event: K,\n callback: (this: this, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | EventListenerOptions\n ): this;\n off(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): this;\n off(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): this {\n this.removeEventListener(event, callback, options);\n return this;\n }\n\n /**\n * Attaches a one-shot event listener to the component.\n *\n * Like `on()`, but the listener is automatically removed after it fires\n * once. Useful for reacting to things like the first click or the next\n * transition end.\n *\n * @param event - The event name to listen for.\n * @param callback - The handler to run the first time the event fires.\n * @param options - Standard `addEventListener` options; `once` is forced\n * to `true`.\n * @returns The component, for chaining.\n *\n * @example\n * modal.once('animationend', () => modal.remove());\n */\n once<K extends keyof HTMLElementEventMap>(\n event: K,\n callback: (this: this, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ): this;\n once(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;\n once(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this {\n const opts = typeof options === 'boolean' ? { capture: options, once: true } : { ...options, once: true };\n this.addEventListener(event, callback, opts);\n return this;\n }\n\n /**\n * Dispatches a `CustomEvent` from the component.\n *\n * By default the event bubbles up through the DOM, is composed (so it\n * crosses shadow-root boundaries), and is cancellable. Pass any of those\n * as `options` to override them. Anything you put in `detail` is\n * delivered to listeners as `event.detail`.\n *\n * @param event - The event name.\n * @param detail - The payload to attach to `event.detail`.\n * @param options - Overrides for `bubbles`, `cancelable`, `composed`, etc.\n * @returns `false` if a listener called `preventDefault()`, otherwise\n * `true`.\n *\n * @example\n * class MyButton extends Component {\n * @Listen('click')\n * onClick() {\n * this.emit('button-pressed', { id: this.id, at: Date.now() });\n * }\n * }\n *\n * // parent listens:\n * myButton.on('button-pressed', (e) => console.log(e.detail.id));\n */\n emit<T = unknown>(event: string, detail?: T, options?: Omit<CustomEventInit<T>, 'detail'>): boolean {\n const customEvent = new CustomEvent(event, {\n detail,\n bubbles: true,\n cancelable: true,\n composed: true,\n ...options\n });\n return this.dispatchEvent(customEvent);\n }\n\n /*\n * =========================\n * Query Helpers\n * =========================\n */\n\n /**\n * Finds the first descendant matching the given CSS selector.\n *\n * A shortcut for `querySelector` scoped to the component's own subtree.\n * Handy inside `didMount()` or `didRender()` when you need to grab a\n * rendered element. Subclasses like `ShadowComponent` scope the search\n * to the shadow root instead.\n *\n * @param selector - Any valid CSS selector.\n * @returns The first matching element, or `null` if nothing matched.\n *\n * @example\n * async didMount() {\n * this.query('input')?.focus();\n * }\n */\n query<E extends Element = Element>(selector: string): E | null {\n return this.querySelector<E>(selector);\n }\n\n /**\n * Finds every descendant matching the given CSS selector.\n *\n * A shortcut for `querySelectorAll` scoped to the component's own\n * subtree. Subclasses like `ShadowComponent` scope the search to the\n * shadow root instead.\n *\n * @param selector - Any valid CSS selector.\n * @returns A `NodeList` of matching elements (possibly empty).\n *\n * @example\n * for (const item of this.queryAll('li.item')) {\n * item.classList.add('ready');\n * }\n */\n queryAll<E extends Element = Element>(selector: string): NodeListOf<E> {\n return this.querySelectorAll<E>(selector);\n }\n\n /*\n * =========================\n * Ready Callback\n * =========================\n */\n\n /**\n * Queue of callbacks registered through `ready()` before the component\n * finished its first mount. Drained in order once `_isReady` flips to\n * `true`, then discarded.\n *\n * @internal\n */\n private _readyCallbacks?: Array<() => void>;\n\n /**\n * Queues a callback to run once the component has finished its first\n * mount and initial render.\n *\n * If the component is already ready, the callback runs on the next\n * microtask. If not, it's queued and fired in order after `didMount()`\n * and the first render. Typical use is deferring DOM work that depends on\n * the rendered markup — focusing an input, measuring size, wiring up a\n * library.\n *\n * @param callback - The function to run when the component is ready.\n *\n * @example\n * class UserAvatar extends Component {\n * render() {\n * return html`<input name=\"handle\" />`;\n * }\n *\n * constructor() {\n * super();\n * this.ready(() => this.query('input')?.focus());\n * }\n * }\n */\n ready(callback: () => void): void {\n if (this._isReady) {\n queueMicrotask(callback);\n } else {\n this._readyCallbacks ??= [];\n this._readyCallbacks.push(callback);\n }\n }\n\n /*\n * =========================\n * Lifecycle\n * =========================\n */\n\n /**\n * Runs just before the component's first render.\n *\n * Override this to do async setup that should finish before users see\n * anything — fetch data, load a dependency, subscribe to a store. The\n * render is awaited on your returned promise, so returning a pending\n * fetch will delay the first paint.\n *\n * @example\n * async willMount() {\n * this.data = await fetch('/api/profile').then(r => r.json());\n * }\n */\n public async willMount(): Promise<void> {}\n\n /**\n * Runs after the component's first mount completes.\n *\n * By this point the initial render has happened, `isReady` is `true`,\n * and the component is in the DOM. Use it for post-render setup that\n * needs to inspect the rendered markup, or for things you only want to\n * do on the very first connection (use `isFirstMount` if you override\n * `didReconnect` too).\n *\n * @example\n * async didMount() {\n * this.query('input')?.focus();\n * }\n */\n public async didMount(): Promise<void> {}\n\n /**\n * Runs after every render cycle.\n *\n * Fires on the initial mount render, on re-renders triggered by\n * reactive state changes, and on every `forceRender()` call. Use it\n * to grab references to freshly rendered elements or to re-apply\n * imperative setup — `didMount()` only runs once, while this runs\n * each time the DOM content is replaced.\n *\n * @example\n * async didRender() {\n * this._chart?.destroy();\n * this._chart = createChart(this.query('canvas'));\n * }\n */\n public async didRender(): Promise<void> {}\n\n /**\n * Runs when the component is re-attached to the DOM after being\n * disconnected.\n *\n * This is the counterpart to `didMount()` for the second and later\n * connection. Use it to re-subscribe to streams or re-start timers\n * that you shut down in `willUnmount()` / `didUnmount()`.\n *\n * @example\n * async didReconnect() {\n * this._timer = setInterval(() => this.tick(), 1000);\n * }\n */\n public async didReconnect(): Promise<void> {}\n\n /**\n * Runs just before the component is removed from the DOM.\n *\n * Override to tear down anything that can't wait: cancel pending\n * fetches, clear timers, close sockets. The returned promise is\n * awaited before `didUnmount()` runs.\n *\n * @example\n * async willUnmount() {\n * this._abort.abort();\n * }\n */\n public async willUnmount(): Promise<void> {}\n\n /**\n * Runs after the component has been removed from the DOM.\n *\n * By this point the element is no longer in the document. Use it for\n * final cleanup — releasing references, logging, telemetry.\n *\n * @example\n * async didUnmount() {\n * analytics.track('card-removed', { id: this.id });\n * }\n */\n public async didUnmount(): Promise<void> {}\n\n /**\n * Runs every time one of the component's reactive fields changes.\n *\n * Override this for a single place to observe state changes across all\n * `@State`, `@Attribute`, `@Property`, and `@Subscribe` fields. It fires\n * synchronously in the setter, after any matching `@Watch` callbacks and\n * before the queued render. Great for logging, audit trails, analytics,\n * or cross-cutting validation.\n *\n * @param property - The name of the field that changed.\n * @param oldValue - The previous value.\n * @param newValue - The new value.\n * @param source - A short label describing where the change came from,\n * such as `'state'`, `'prop'`, `'prop-attribute'`, `'property'`,\n * `'consumer'`, or `'reactive'`.\n *\n * @example\n * class MyCounter extends Component {\n * @State() count = 0;\n *\n * didChange(property, oldValue, newValue, source) {\n * console.log(`[${source}] ${property}: ${oldValue} -> ${newValue}`);\n * }\n * }\n */\n public didChange(_property: string, _oldValue: unknown, _newValue: unknown, _source?: string): void {}\n\n /**\n * The standard custom-elements hook Pandora uses to drive mounting.\n *\n * Pandora runs `@Subscribe` activation, picks up `@Style` metadata, calls\n * `willMount()`, performs the first render, then calls either\n * `didMount()` (on the first connection) or `didReconnect()` (on a later\n * one), and finally fires any pending `ready()` callbacks. Subclasses\n * normally reach for `willMount()`, `didMount()`, or `ready()` instead of\n * overriding this. If you do override it, call `super.connectedCallback()`\n * so the lifecycle keeps working.\n *\n * @example\n * async connectedCallback() {\n * await super.connectedCallback();\n * // extra work that needs to run after the standard mount\n * }\n */\n async connectedCallback(): Promise<void> {\n const ctor = this.constructor as typeof Component;\n const tag = ctor.tag;\n\n try {\n this._connected = true;\n this.dataset.component = tag;\n\n // If `Registry.evolve()` swapped the implementation for this tag after\n // `customElements.define()` ran, reapply it to this instance before any\n // lifecycle code runs — that way evolved behavior lands on fresh\n // instances without requiring re-creation.\n Component._applyCurrentImplementation?.(this, tag);\n\n // Activate `@Subscribe` handlers from class metadata. This has to live\n // on the prototype method (here), not a shadow on the instance, because\n // the browser only calls prototype-defined custom element lifecycle\n // callbacks.\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = (this.constructor as unknown as Record<symbol, unknown>)[Symbol.metadata] as Record<symbol, unknown> | undefined;\n const handlers = meta?.[SUBSCRIBE_HANDLERS] as SubscribeHandler[] | undefined;\n if (handlers) {\n for (const handler of handlers) {\n Component._activateSubscription(this, handler);\n }\n }\n }\n\n const firstMount = !this._hasBeenMounted;\n\n if (firstMount) {\n this._children = this.innerHTML.trim();\n }\n\n // Pick up an HTML `<template id=\"...\">` matching our tag on first mount\n // so consumers can author templates declaratively without touching JS.\n if (firstMount && ctor._template === undefined) {\n const tpl = document.querySelector(`template#${tag}`);\n if (tpl) {\n ctor._template = tpl.innerHTML;\n }\n }\n\n // Apply `@Style` metadata once, on the first mount of any instance of\n // this tag — the stylesheet is shared across instances so later mounts\n // don't need to reapply it.\n if (firstMount && typeof Symbol.metadata !== 'undefined') {\n const meta = (ctor as any)[Symbol.metadata];\n const styleData = meta?.[STYLE_METADATA];\n if (styleData) {\n this.setStyle(styleData as Style | string, true);\n }\n }\n\n await this.willMount();\n await this._render();\n\n // Flip the init-render gate now that the first render has landed. From\n // here on, reactive writes in `didMount` / `didReconnect` and beyond\n // are allowed to queue renders; field-initializer writes that ran\n // during construction already happened before this point and so don't.\n this._initRenderDone = true;\n\n if (firstMount) {\n await this.didMount();\n } else {\n // On reconnect we deliberately call `didReconnect` instead of\n // `didMount` so consumers can separate first-time setup from\n // re-attachment behavior.\n await this.didReconnect();\n }\n\n // We set `_hasBeenMounted` after `didMount` finishes so that\n // `isFirstMount` remains `true` for the entire duration of that hook.\n this._hasBeenMounted = true;\n\n this._isReady = true;\n\n if (this._readyCallbacks) {\n for (const callback of this._readyCallbacks) {\n callback();\n }\n this._readyCallbacks = undefined;\n }\n\n Component._onMount?.(this, tag);\n\n this.emit('pandora:ready', { firstMount, tag }, { bubbles: true, composed: true });\n } catch (error) {\n if (Component._onError) {\n Component._onError(error as Error, this, tag, 'connectedCallback');\n } else {\n throw error;\n }\n }\n }\n\n /**\n * The standard custom-elements hook Pandora uses to drive unmounting.\n *\n * Pandora tears down `@Subscribe` subscriptions and `@Listen` handlers,\n * then calls `willUnmount()` and `didUnmount()` before flipping the\n * component's ready and connected flags back to `false`. Override the\n * lifecycle methods in preference to this hook; if you do override,\n * remember to call `super.disconnectedCallback()`.\n *\n * @example\n * async disconnectedCallback() {\n * await super.disconnectedCallback();\n * this.releaseExternalResource();\n * }\n */\n async disconnectedCallback(): Promise<void> {\n const ctor = this.constructor as typeof Component;\n const tag = ctor.tag;\n\n try {\n // Fire the lifecycle event before tearing anything down so listeners\n // can still read component state from the handler.\n this.emit('pandora:unmount', { tag }, { bubbles: true, composed: true });\n\n // Release `@Subscribe` subscriptions so the removed instance stops\n // receiving global-state updates and can be garbage-collected.\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = (ctor as unknown as Record<symbol, unknown>)[Symbol.metadata] as Record<symbol, unknown> | undefined;\n const handlers = meta?.[SUBSCRIBE_HANDLERS] as SubscribeHandler[] | undefined;\n if (handlers) {\n const inst = this as unknown as Record<symbol, unknown>;\n for (const handler of handlers) {\n if (inst[handler.unsubKey]) {\n (inst[handler.unsubKey] as () => void)();\n inst[handler.unsubKey] = undefined;\n }\n }\n }\n }\n\n this._detachListeners();\n\n await this.willUnmount();\n await this.didUnmount();\n\n this._connected = false;\n this._isReady = false;\n\n Component._onUnmount?.(this, tag);\n } catch (error) {\n if (Component._onError) {\n Component._onError(error as Error, this, tag, 'disconnectedCallback');\n } else {\n throw error;\n }\n }\n }\n\n /**\n * The standard custom-elements hook that tracks attribute changes.\n *\n * Pandora routes attribute updates into the fields you declared with\n * `@Attribute` / `@Property({ attribute })`, parses values for you (so\n * `\"42\"` arrives as a number, `\"true\"` as a boolean), fires `@Watch`\n * callbacks and `didChange()`, and schedules a render. Prefer those\n * decorators over overriding this hook — but if you must, call\n * `super.attributeChangedCallback(...)` first so the reactive plumbing\n * still runs.\n *\n * The browser only calls this hook for attributes named in\n * `observedAttributes`. Fields declared with `@Attribute` or\n * `@Property({ attribute: true })` register themselves in that list\n * automatically.\n *\n * @param property - The attribute name that changed.\n * @param oldValue - The previous attribute value, or `null` if unset.\n * @param newValue - The new attribute value, or `null` if removed.\n *\n * @example\n * class MyButton extends Component {\n * @Attribute() disabled = false;\n * // Pandora keeps `disabled` in sync with the DOM attribute for you.\n * }\n */\n attributeChangedCallback(property: string, _oldValue: string | null, newValue: string | null): void {\n // Dispatch to `@Attribute` / `@Property({ attribute })` handlers from\n // class metadata. Like `connectedCallback`, this has to sit on the\n // prototype because the browser only consults prototype methods at\n // `define()` time — instance-level shadows would be silently ignored on\n // real `setAttribute()` calls.\n if (typeof Symbol.metadata === 'undefined') return;\n const ctor = this.constructor as typeof Component;\n const meta = (ctor as unknown as Record<symbol, unknown>)[Symbol.metadata] as Record<symbol, unknown> | undefined;\n const handlers = meta?.[ATTR_HANDLERS] as AttrHandler[] | undefined;\n if (!handlers) return;\n\n const inst = this as unknown as Record<symbol, unknown>;\n for (const handler of handlers) {\n if (handler.attrName !== property) continue;\n // Break the feedback loop: when our own setter reflects a value back\n // to the DOM attribute, the browser calls us here — the `settingKey`\n // flag lets us tell those re-entrant writes apart from user-driven\n // attribute changes and skip them.\n if (inst[handler.settingKey]) continue;\n\n const parsedNew = newValue !== null ? parseAttributeValue(newValue) : undefined;\n const oldVal = inst[handler.valueKey];\n if (handler.equals(oldVal, parsedNew)) continue;\n\n inst[handler.valueKey] = parsedNew;\n\n const watchMeta = meta?.[WATCH_HANDLERS] as Array<{ property: string; methodName: string }> | undefined;\n if (watchMeta) {\n for (const entry of watchMeta) {\n if (entry.property === handler.propertyKey) {\n const method = (this as unknown as Record<string, unknown>)[entry.methodName];\n if (typeof method === 'function') {\n (method as (n: unknown, o: unknown) => void).call(this, parsedNew, oldVal);\n }\n }\n }\n }\n\n this.didChange(handler.propertyKey, oldVal, parsedNew, 'prop-attribute');\n\n if (handler.shouldRender && this._initRenderDone && this._connected) {\n this._queueRender();\n }\n }\n }\n\n /*\n * =========================\n * @Listen Support\n * =========================\n */\n\n /**\n * The set of `@Listen` bindings currently wired up on this instance.\n * We track them explicitly so `_detachListeners` can remove the exact\n * `(target, event, handler, options)` triples we registered — this matters\n * on disconnect and between renders, when listener targets may have been\n * replaced.\n *\n * @internal\n */\n private _activeListeners: Array<{ target: EventTarget; event: string; handler: EventListener; options?: boolean | AddEventListenerOptions }> = [];\n\n /**\n * Walks `@Listen` metadata and wires up the described listeners against\n * their resolved targets. We resolve selectors at attach time (not at\n * decoration time) because the target nodes may only exist after a render\n * has populated the component's subtree.\n *\n * @internal\n */\n protected _attachListeners(): void {\n if (typeof Symbol.metadata === 'undefined') return;\n\n const meta = ((this.constructor as any)[Symbol.metadata]) as Record<symbol, unknown> | undefined;\n const listeners = meta?.[LISTEN_HANDLERS] as Array<{\n event: string;\n methodName: string;\n options?: {\n target?: string;\n delegate?: string;\n capture?: boolean;\n passive?: boolean;\n once?: boolean;\n };\n }> | undefined;\n\n if (!listeners) return;\n\n for (const listener of listeners) {\n const method = (this as any)[listener.methodName];\n if (typeof method !== 'function') continue;\n\n const boundHandler = method.bind(this) as EventListener;\n const opts = listener.options;\n const resolvedTarget = resolveListenerTarget(this, opts?.target, (s) => this.query(s));\n if (!resolvedTarget) continue;\n\n const eventOpts: AddEventListenerOptions = {};\n if (opts?.capture) {\n eventOpts.capture = true;\n }\n\n if (opts?.passive) {\n eventOpts.passive = true;\n }\n\n // For delegated listeners we implement `once` ourselves: the native\n // `once` option would fire on the first event to bubble through,\n // regardless of whether it matched the delegate selector. We want\n // \"once it actually matches,\" so we remove the listener by hand after\n // the first matching dispatch.\n let handler: EventListener;\n\n if (opts?.delegate) {\n const delegateSelector = opts.delegate;\n const shouldOnce = opts?.once;\n handler = ((event: Event) => {\n const match = (event.target as Element)?.closest(delegateSelector);\n\n if (match) {\n boundHandler(event);\n\n if (shouldOnce) {\n resolvedTarget.removeEventListener(listener.event, handler, eventOpts);\n this._activeListeners = this._activeListeners.filter(l => l.handler !== handler);\n }\n }\n }) as EventListener;\n } else {\n handler = boundHandler;\n if (opts?.once) eventOpts.once = true;\n }\n\n resolvedTarget.addEventListener(listener.event, handler, eventOpts);\n this._activeListeners.push({ target: resolvedTarget, event: listener.event, handler, options: eventOpts });\n }\n }\n\n /**\n * Removes every listener currently recorded in `_activeListeners` and\n * clears the tracking array. Called on disconnect and between renders so\n * stale bindings never outlive the nodes they pointed at.\n *\n * @internal\n */\n protected _detachListeners(): void {\n for (const { target, event, handler, options } of this._activeListeners) {\n target.removeEventListener(event, handler, options);\n }\n\n this._activeListeners = [];\n }\n}\n\nexport default Component;\n",
8
- "import { render as litRender, TemplateResult, nothing } from 'lit-html';\n\nimport Component from './Component';\nimport { deserializeCSS } from './Util';\nimport { Style } from './Types';\n\n/**\n * Component subclass that renders into an open shadow root instead of the host\n * element. Pick it when you need style isolation or slot composition;\n * otherwise extend `Component` directly.\n *\n * The shadow root is attached in the constructor with mode `'open'`, so you\n * can still inspect it from outside via `element.shadowRoot`. Queries,\n * listener targets, and adopted stylesheets all scope to the shadow root\n * rather than the host, which means CSS you apply via `setStyle()` stays\n * encapsulated and doesn't leak to the surrounding page.\n *\n * @example\n * @Register('user-card')\n * class UserCard extends ShadowComponent {\n * @Property() user: { name: string; avatar: string } | null = null;\n *\n * render() {\n * if (!this.user) return nothing;\n * return html`\n * <article>\n * <img src=${this.user.avatar} alt=\"\">\n * <h1>${this.user.name}</h1>\n * <slot></slot>\n * </article>\n * `;\n * }\n *\n * async didMount() {\n * this.setStyle({\n * ':host': { display: 'block' },\n * 'article': { padding: '1rem', borderRadius: '8px' }\n * });\n * }\n * }\n */\nclass ShadowComponent extends Component {\n /**\n * @internal\n * The open shadow root attached to the host element. All queries, renders,\n * and style adoption go through this root rather than the host's light DOM.\n */\n protected _shadowDOM: ShadowRoot;\n\n /**\n * @internal\n * Shared `CSSStyleSheet` adopted into the shadow root by `setStyle`. Lazily\n * created per subclass so every instance of a component reuses the same\n * constructed stylesheet.\n */\n protected static override _styleSheet: CSSStyleSheet | null = null;\n\n /**\n * @internal\n * Class-wide object-form style declarations backing the shared stylesheet.\n */\n protected static override _sharedStyle: Style = {};\n\n /**\n * Attaches an open shadow root to the host element and stores it for use\n * by the query, style, and render helpers. You generally don't call this\n * directly — the browser constructs your component when the tag appears\n * in the DOM. Override it only if you need to run extra setup, and always\n * call `super()` first.\n */\n constructor() {\n super();\n this._shadowDOM = this.attachShadow({ mode: 'open' });\n }\n\n /**\n * Applies styles to the component's shadow root via an adopted stylesheet.\n *\n * Behaves like `Component.setStyle`, but the stylesheet is adopted into\n * the shadow root instead of the document — so the rules stay encapsulated\n * and don't affect anything outside the component. Use `:host` selectors\n * to style the host element itself.\n *\n * @param style - A `Style` object or a CSS string.\n * @param reset - When `true`, replace the existing styles instead of\n * merging on top.\n * @returns The current object-form style after the update.\n *\n * @example\n * async didMount() {\n * this.setStyle({\n * ':host': { display: 'block', padding: '1rem' },\n * 'button': { cursor: 'pointer' }\n * });\n * }\n */\n override setStyle(style: Style | string, reset: boolean = false): Style {\n const staticComponent = this.constructor as typeof ShadowComponent;\n\n if (!staticComponent._styleSheet) {\n staticComponent._styleSheet = new CSSStyleSheet();\n }\n\n let cssText = '';\n\n if (typeof style === 'object') {\n if (!Object.hasOwn(staticComponent, '_sharedStyle')) {\n staticComponent._sharedStyle = {};\n }\n\n if (!reset) {\n staticComponent._sharedStyle = { ...staticComponent._sharedStyle, ...style };\n } else {\n staticComponent._sharedStyle = { ...style };\n }\n\n this._style = staticComponent._sharedStyle;\n cssText = deserializeCSS(staticComponent._sharedStyle);\n } else if (typeof style === 'string') {\n if (!reset) {\n const existingRules = Array.from(staticComponent._styleSheet.cssRules || [])\n .map(rule => rule.cssText)\n .join('\\n');\n\n cssText = existingRules + '\\n' + style;\n } else {\n cssText = style;\n staticComponent._sharedStyle = {};\n this._style = {};\n }\n }\n\n staticComponent._styleSheet.replaceSync(cssText);\n\n this._shadowDOM.adoptedStyleSheets = [staticComponent._styleSheet];\n\n return staticComponent._sharedStyle;\n }\n\n /**\n * @internal\n * Shadow-root variant of the lit-html render hook. Scopes the render target\n * to the shadow root and passes `host: this` so event listeners resolve\n * against the component.\n */\n protected override _applyLitRender(result: TemplateResult | typeof nothing): void {\n litRender(result, this._shadowDOM, { host: this });\n }\n\n /**\n * @internal\n * Shadow-root variant of the string render hook. Wipes the existing shadow\n * content and appends the parsed template so raw HTML strings render inside\n * the encapsulated tree.\n */\n protected override _applyStringRender(html: string): void {\n while (this._shadowDOM.firstChild) {\n this._shadowDOM.firstChild.remove();\n }\n\n if (html === '') {\n return;\n }\n\n const template = document.createElement('template');\n template.innerHTML = html;\n\n this._shadowDOM.appendChild(template.content);\n }\n\n /**\n * The open shadow root attached to this component.\n *\n * Convenience accessor around the built-in `element.shadowRoot` that\n * returns a non-null `ShadowRoot` — because `ShadowComponent` always\n * attaches one in its constructor, you can use it without a null check.\n * The property is read-only; assigning to it throws.\n *\n * @returns The shadow root owned by this component.\n *\n * @example\n * const card = document.querySelector('my-card') as ShadowComponent;\n * const title = card.shadowRoot.querySelector('h1');\n */\n get shadowRoot(): ShadowRoot {\n return this._shadowDOM;\n }\n\n set shadowRoot(_value: ShadowRoot) {\n throw new Error('ShadowComponent shadowRoot can not be overwritten.');\n }\n\n /**\n * Finds the first descendant of the shadow root matching the given CSS\n * selector.\n *\n * Same shape as `Component.query`, but scoped to this component's shadow\n * root instead of its light-DOM subtree. Elements rendered by `render()`\n * live inside the shadow root, so this is the method you want for\n * reaching into your own template.\n *\n * @param selector - Any valid CSS selector.\n * @returns The first matching element, or `null` if nothing matched.\n *\n * @example\n * async didMount() {\n * this.query<HTMLInputElement>('input[name=\"email\"]')?.focus();\n * }\n */\n override query<E extends Element = Element>(selector: string): E | null {\n return this._shadowDOM.querySelector<E>(selector);\n }\n\n /**\n * Finds every descendant of the shadow root matching the given CSS\n * selector.\n *\n * Same shape as `Component.queryAll`, but scoped to this component's\n * shadow root instead of its light-DOM subtree.\n *\n * @param selector - Any valid CSS selector.\n * @returns A `NodeList` of matching elements (possibly empty).\n *\n * @example\n * for (const item of this.queryAll('li.item')) {\n * item.classList.add('ready');\n * }\n */\n override queryAll<E extends Element = Element>(selector: string): NodeListOf<E> {\n return this._shadowDOM.querySelectorAll<E>(selector);\n }\n}\n\nexport default ShadowComponent;\n",
9
- "import Component from './Component';\nimport { DECORATOR_EFFECTS, DECORATOR_TEARDOWNS } from './Util';\n\n/** Tracks the last implementation class applied to an instance, to skip no-op reapplication. */\nconst APPLIED_IMPL: unique symbol = Symbol('pandora:appliedImpl');\n\ntype ComponentClass = typeof Component & {\n tag: string;\n _registered?: boolean;\n};\n\ntype StateSubscriber<T = unknown> = (newValue: T, oldValue: T | undefined) => void;\ntype LifecycleCallback = (component: Component, tag: string) => void;\ntype ErrorCallback = (error: Error, component: Component, tag: string, lifecycle: string) => void;\ntype MiddlewareType = 'render';\ntype RenderType = 'string' | 'lit';\ntype Middleware = (component: Component, value: unknown, renderType?: RenderType) => unknown;\ntype ComponentLoader = () => Promise<ComponentClass | { default: ComponentClass }>;\n\ninterface ComponentStats {\n tag: string;\n instanceCount: number;\n isRegistered: boolean;\n isLazy: boolean;\n}\n\n/**\n * Pandora's central registry for custom elements, global state, lifecycle\n * observers, and the render middleware pipeline.\n *\n * Everything you register with `@Register` flows through here, and you can\n * also talk to it directly: keep a catalog of tags, hot-swap implementations\n * with `evolve()`, share values across the tree with `setState()` /\n * `subscribe()`, watch every mount and unmount, or wrap render output with\n * `use('render', ...)`.\n *\n * Most APIs are designed to be used from anywhere in your app — import the\n * default export and call the static methods directly. There's no instance\n * to construct.\n *\n * @example\n * import Registry, { Component, Register } from '@aegis-framework/pandora';\n *\n * @Register('theme-toggle')\n * class ThemeToggle extends Component {\n * render() {\n * return `<button>Toggle</button>`;\n * }\n * }\n *\n * Registry.setState('theme', 'dark');\n * const unsubscribe = Registry.subscribe('theme', (next) => {\n * document.documentElement.dataset.theme = next as string;\n * });\n */\nclass Registry {\n /** Backing store for the `debug` accessor; defaults off so logging stays quiet in production. @internal */\n private static _debug: boolean = false;\n\n private static components: Record<string, ComponentClass> = {};\n\n private static implementations: Record<string, ComponentClass> = {};\n\n private static state: Record<string, unknown> = {};\n private static subscribers: Record<string, Set<StateSubscriber>> = {};\n\n private static mountCallbacks: Set<LifecycleCallback> = new Set();\n private static unmountCallbacks: Set<LifecycleCallback> = new Set();\n private static errorCallbacks: Set<ErrorCallback> = new Set();\n private static aliases: Record<string, string> = {};\n private static lazyLoaders: Record<string, ComponentLoader> = {};\n private static lazyLoadPromises: Partial<Record<string, Promise<void>>> = {};\n\n private static middleware: Record<MiddlewareType, Set<Middleware>> = {\n render: new Set()\n };\n\n /** Flipped true on the first `_init()` call so subsequent entry points skip re-wiring Component hooks. @internal */\n private static _initialized = false;\n\n /**\n * One-time bootstrap that wires Component's hook slots to Registry methods.\n * The `_initialized` guard keeps repeated entry points (register, lazy,\n * onMount, etc.) from re-installing the hooks on every call.\n *\n * @internal\n */\n private static _init(): void {\n if (this._initialized) return;\n this._initialized = true;\n\n Component._onMount = (component, tag) => this._notifyMount(component, tag);\n Component._onUnmount = (component, tag) => this._notifyUnmount(component, tag);\n Component._onError = (error, component, tag, lifecycle) => this._notifyError(error, component, tag, lifecycle);\n Component._applyMiddleware = (type, component, value, renderType) => this._applyMiddleware(type as MiddlewareType, component, value, renderType);\n Component._hasMiddleware = (type) => this._hasMiddleware(type as MiddlewareType);\n Component._subscribe = (key, cb) => this.subscribe(key, cb);\n Component._getGlobalState = (key) => this.getState(key);\n Component._applyCurrentImplementation = (instance, tag) => {\n // If evolve() has swapped in a different class since this instance was\n // constructed, re-apply it so the instance behaves like the new version.\n // We track the last-applied class on the instance to skip no-ops when\n // the implementation hasn't moved since we last touched it.\n const current = this.implementations[tag];\n if (!current) return;\n const inst = instance as unknown as Record<symbol, unknown>;\n const last = inst[APPLIED_IMPL] as ComponentClass | undefined;\n const base = last ?? (instance.constructor as ComponentClass);\n if (current === base) return;\n this._applyImplementation(instance, current, false);\n };\n }\n\n /**\n * Associates a tag name with a component class and defines it on\n * `window.customElements`.\n *\n * You usually don't call this yourself — `@Register('my-tag')` does it for\n * you — but it's useful when you construct component classes dynamically\n * or register them from a bootstrapper. Throws if the tag is already\n * taken; reach for `evolve()` to swap an implementation instead.\n *\n * @param tag - The custom element tag to register under.\n * @param component - The component class to associate with the tag.\n *\n * @example\n * class MyGreeting extends Component {\n * render() { return `<p>Hello</p>`; }\n * }\n *\n * Registry.register('my-greeting', MyGreeting);\n */\n static register(tag: string, component: ComponentClass): void {\n this._init();\n\n if (typeof this.components[tag] === 'undefined') {\n this.components[tag] = component;\n this.implementations[tag] = component;\n component.tag = tag;\n\n window.customElements.define(tag, component);\n\n this.components[tag]._registered = true;\n this.log(`Registered: <${tag}>`);\n } else {\n throw new Error('A component with this tag has already been registered. Use the evolve() function to modify the component.');\n }\n }\n\n /**\n * Activates a deferred component by running the same work as `register()`.\n *\n * Use this with components decorated `@Register('my-tag', { defer: true })`\n * when you're ready to define them on `customElements`. Behaviorally\n * identical to `register()`; the different name just makes intent clearer\n * at the call site.\n *\n * @param tag - The tag to activate.\n * @param component - The component class to define.\n *\n * @example\n * @Register('lazy-chart', { defer: true })\n * class LazyChart extends Component { render() { return ''; } }\n *\n * // Later, when you're ready to light it up:\n * Registry.define('lazy-chart', LazyChart);\n */\n static define(tag: string, component: ComponentClass): void {\n this.register(tag, component);\n }\n\n /**\n * Returns the class currently backing a tag, including any version\n * installed by `evolve()` or a resolved lazy loader.\n *\n * Unlike `get()`, which always returns the originally-registered class,\n * this method follows `evolve()` swaps so tooling and debuggers can\n * inspect the live behavior.\n *\n * @param tag - The tag to look up.\n * @returns The active implementation, or `undefined` if the tag is unknown.\n *\n * @example\n * const CurrentButton = Registry.getImplementation('my-button');\n */\n static getImplementation(tag: string): ComponentClass | undefined {\n return this.implementations[tag] || this.components[tag];\n }\n\n /**\n * Applies a source class's prototype, field defaults, metadata, and\n * decorator effects to a live instance. Used for both the evolve() swap\n * and lazy-load upgrade paths: we can't redefine the custom element, so\n * we replay the new class's behavior onto each existing instance.\n *\n * @internal\n */\n static _applyImplementation(instance: Component, source: ComponentClass, _merge: boolean = false): void {\n const proto = source.prototype as unknown as Record<string, unknown>;\n const protoMethods = Object.getOwnPropertyNames(proto);\n const inst = instance as unknown as Record<string, unknown>;\n (instance as unknown as Record<symbol, unknown>)[APPLIED_IMPL] = source;\n\n for (const method of protoMethods) {\n if (method === 'constructor') continue;\n const descriptor = Object.getOwnPropertyDescriptor(proto, method);\n if (!descriptor) continue;\n\n if (typeof descriptor.value === 'function') {\n inst[method] = descriptor.value.bind(instance);\n } else if (descriptor.get || descriptor.set) {\n // Copy accessor descriptors onto the prototype so @Computed and\n // other accessor-based decorators remain reachable. Instance-level\n // overrides are installed later when we replay decorator effects.\n Object.defineProperty(Object.getPrototypeOf(instance), method, descriptor);\n }\n }\n\n // We construct a throwaway instance of the source class to run its\n // decorator initializers (which capture field defaults in closures for\n // later replay) and to harvest plain field defaults we can copy over.\n //\n // For evolved or lazy classes, `source` isn't what was handed to\n // customElements.define(), so Reflect.construct(source, [], source)\n // would throw. Passing the registered class as new.target satisfies\n // the browser while still running source's constructor body.\n try {\n const registeredClass = customElements.get(source.tag) ?? source;\n const temp = Reflect.construct(source, [], registeredClass) as unknown as Record<string, unknown>;\n for (const key of Object.keys(temp)) {\n if (!(key in inst) || inst[key] === undefined) {\n inst[key] = temp[key];\n }\n }\n } catch (error) {\n // Abstract classes and unusual constructors can fail this step. We\n // surface it so component authors aren't left guessing why their\n // defaults didn't copy over.\n console.warn(`[Pandora] Could not construct temp instance of <${source.tag}> for default extraction:`, error);\n }\n\n // Move the source class's metadata onto the registered class so that\n // runtime lookups (getWatchersForProperty, @Computed invalidation, and\n // friends) going through instance.constructor[Symbol.metadata] find\n // the new class's definitions instead of the stale originals.\n if (typeof Symbol.metadata !== 'undefined') {\n const sourceMeta = (source as any)[Symbol.metadata];\n if (sourceMeta) {\n const registeredClass = instance.constructor;\n (registeredClass as any)[Symbol.metadata] = sourceMeta;\n }\n }\n\n // Replay the source class's decorator effects. We tear down any\n // effects left from a previous implementation first so subscriptions\n // and watchers don't accumulate across successive evolve() calls.\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = (source as any)[Symbol.metadata];\n const effects = meta?.[DECORATOR_EFFECTS] as ((inst: Component) => void)[] | undefined;\n if (effects?.length) {\n const teardowns = inst[DECORATOR_TEARDOWNS as unknown as string] as (() => void)[] | undefined;\n\n if (teardowns) {\n for (const teardown of teardowns) {\n teardown();\n }\n }\n\n inst[DECORATOR_TEARDOWNS as unknown as string] = [];\n\n for (const effect of effects) {\n effect(instance as any);\n }\n }\n }\n }\n\n /**\n * Hot-swaps the implementation behind a registered tag, so every future\n * instance uses the new class.\n *\n * The browser only lets you call `customElements.define()` once per tag,\n * so Pandora keeps the original class bound to the tag and replays the\n * new class's prototype methods, field defaults, and decorator effects\n * onto each live instance. Aliases created with `alias()` also pick up\n * the swap.\n *\n * Pass `true` as the third argument to force an immediate re-render of\n * every live instance (including aliased ones). Without it, already-mounted\n * components keep running the old code until they naturally re-render.\n *\n * @param tag - The existing tag whose implementation you're replacing.\n * @param component - The new component class to install.\n * @param rerender - When `true`, re-renders every mounted instance right away.\n *\n * @example\n * class MyCounter extends Component {\n * render() { return `<span>v1</span>`; }\n * }\n * Registry.register('my-counter', MyCounter);\n *\n * class MyCounterV2 extends Component {\n * render() { return `<span>v2</span>`; }\n * }\n * Registry.evolve('my-counter', MyCounterV2, true);\n */\n static evolve(tag: string, component: ComponentClass, rerender: boolean = false): void {\n if (typeof this.components[tag] === 'undefined') {\n throw new Error('No component with this tag has been registered. Cannot Evolve.');\n }\n\n this.implementations[tag] = component;\n component._registered = true;\n\n // Propagate the new implementation to every alias of this tag. We do\n // this unconditionally — not only on the rerender path — because\n // _applyCurrentImplementation consults the implementation map on every\n // natural connect, and we want future alias instances to pick up the\n // swap too.\n const aliasTags: string[] = [];\n for (const [aliasTag, originalTag] of Object.entries(this.aliases)) {\n if (originalTag === tag) {\n aliasTags.push(aliasTag);\n this.implementations[aliasTag] = component;\n }\n }\n\n this.log(`Evolved: <${tag}>`);\n\n if (rerender) {\n // Walk aliases alongside the primary tag so live alias instances\n // get the swap too. We gate on isReady because forceRender() against\n // a half-constructed instance would double up its initial render.\n const tagsToUpdate = [tag, ...aliasTags];\n for (const updateTag of tagsToUpdate) {\n document.querySelectorAll(updateTag).forEach((instance) => {\n if (instance instanceof Component && (instance as Component).isReady) {\n this._applyImplementation(instance as Component, component, true);\n (instance as Component).forceRender();\n }\n });\n }\n }\n }\n\n /**\n * Finds every live instance of a tag in the document.\n *\n * With one argument, returns the matching `NodeList` so you can iterate\n * it yourself. Pass a callback as the second argument and Pandora will\n * iterate for you and return nothing. Throws if the tag isn't registered.\n *\n * @param tag - The tag whose instances you want.\n * @param callback - Optional iterator invoked once per instance.\n * @returns A `NodeList` when no callback is provided; otherwise `void`.\n *\n * @example\n * // Collect every instance:\n * const buttons = Registry.instances('my-button');\n *\n * // Or iterate them directly:\n * Registry.instances('my-button', (el) => {\n * (el as HTMLElement).classList.add('ready');\n * });\n */\n static instances(tag: string): NodeListOf<Element>;\n static instances(tag: string, callback: (instance: Element) => void): void;\n static instances(tag: string, callback?: (instance: Element) => void): NodeListOf<Element> | void {\n if (typeof this.components[tag] === 'undefined') {\n throw new Error('No component with the provided tag has been registered.');\n }\n\n if (typeof callback === 'function') {\n document.querySelectorAll(tag).forEach(callback);\n } else {\n return document.querySelectorAll(tag);\n }\n }\n\n /**\n * Builds a detached element for a registered tag and seeds its initial\n * props and attributes.\n *\n * The returned element is created with `document.createElement` but not\n * attached anywhere — you choose where it lives by calling\n * `parent.appendChild(...)` or similar. Values are assigned as properties;\n * for plain fields without a reactive setter, string, number, and truthy\n * boolean values also mirror to the matching attribute.\n *\n * @param tag - The registered tag to create.\n * @param props - Initial property values keyed by field name.\n * @returns A detached component instance ready to attach.\n *\n * @example\n * const avatar = Registry.instantiate('user-avatar', {\n * userId: 'u_42',\n * size: 48\n * });\n * document.body.appendChild(avatar);\n */\n static instantiate(tag: string, props: Record<string, any>): Component {\n if (!this.has(tag)) {\n throw new Error(`No component with tag \"${tag}\" has been registered.`);\n }\n\n if (!this.components[tag]._registered) {\n this.register(tag, this.components[tag]);\n }\n\n const element = document.createElement(this.components[tag].tag) as Component;\n\n // We always assign as a property. @Attribute and @Property({ attribute })\n // fields mirror through their setters to the correct (possibly renamed)\n // attribute on their own, so we only need to manually set an attribute\n // for plain fields that don't have a reactive setter to do it for us.\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || value === null) continue;\n\n (element as any)[key] = value;\n\n const hasReactiveSetter = Object.getOwnPropertyDescriptor(element, key)?.set !== undefined;\n if (hasReactiveSetter) continue;\n\n if (typeof value === 'boolean') {\n if (value) {\n element.setAttribute(key, '');\n }\n } else if (typeof value === 'string' || typeof value === 'number') {\n element.setAttribute(key, String(value));\n }\n }\n\n return element;\n }\n\n /**\n * Checks whether any component is registered under the given tag.\n *\n * Includes aliases and lazy components, since both are tracked in the\n * same catalog.\n *\n * @param tag - The tag to check.\n * @returns `true` if the tag is known to Registry.\n *\n * @example\n * if (!Registry.has('theme-toggle')) {\n * Registry.register('theme-toggle', ThemeToggle);\n * }\n */\n static has(tag: string): boolean {\n return typeof this.components[tag] !== 'undefined';\n }\n\n /**\n * Returns the originally-registered class for a tag.\n *\n * If you want the current implementation (honoring `evolve()`), use\n * `getImplementation()` instead.\n *\n * @param tag - The tag to look up.\n * @returns The registered class, or `undefined` if the tag is unknown.\n *\n * @example\n * const ThemeToggle = Registry.get('theme-toggle');\n */\n static get(tag: string): ComponentClass | undefined {\n return this.components[tag];\n }\n\n /*\n * =========================\n * Global State Management\n * =========================\n */\n\n /**\n * Stores a value under the given key and synchronously notifies every\n * `subscribe()` callback registered on that key.\n *\n * Subscribers run in registration order and receive `(newValue, oldValue)`.\n * If a callback throws, the error propagates — wrap risky work yourself.\n *\n * @param key - The state key.\n * @param value - The new value.\n *\n * @example\n * Registry.setState('theme', 'dark');\n * Registry.setState('user', { id: 'u_42', name: 'Ada' });\n */\n static setState<T>(key: string, value: T): void {\n const oldValue = this.state[key] as T | undefined;\n this.state[key] = value;\n\n if (this.subscribers[key]) {\n this.subscribers[key].forEach((callback) => {\n callback(value, oldValue);\n });\n }\n }\n\n /**\n * Reads the current value stored under a key.\n *\n * Returns `undefined` if nothing has been set, which is indistinguishable\n * from a value that was explicitly set to `undefined` — use `hasState()`\n * if you need to tell them apart.\n *\n * @param key - The state key to read.\n * @returns The current value, or `undefined` if the key is unset.\n *\n * @example\n * const theme = Registry.getState<'light' | 'dark'>('theme');\n */\n static getState<T>(key: string): T | undefined {\n return this.state[key] as T | undefined;\n }\n\n /**\n * Checks whether a state key has been set.\n *\n * Useful when you need to distinguish \"never set\" from \"set to `undefined`.\"\n *\n * @param key - The state key to check.\n * @returns `true` if the key exists in the store.\n *\n * @example\n * if (!Registry.hasState('theme')) {\n * Registry.setState('theme', 'light');\n * }\n */\n static hasState(key: string): boolean {\n return key in this.state;\n }\n\n /**\n * Removes a state key and notifies subscribers with `(undefined, oldValue)`.\n *\n * Returns `false` if the key wasn't present, so subscribers aren't called\n * for no-ops.\n *\n * @param key - The state key to delete.\n * @returns `true` if the key existed and was removed.\n *\n * @example\n * Registry.deleteState('user');\n */\n static deleteState(key: string): boolean {\n if (key in this.state) {\n const oldValue = this.state[key];\n delete this.state[key];\n\n // Subscribers see undefined as the new value — this mirrors what\n // getState() will return from now on, so observers can treat delete\n // and \"set to undefined\" uniformly.\n if (this.subscribers[key]) {\n this.subscribers[key].forEach((callback) => {\n callback(undefined, oldValue);\n });\n }\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Listens for changes to a state key.\n *\n * The callback fires only on future `setState()` and `deleteState()` calls —\n * it does not run immediately with the current value, so call `getState()`\n * yourself if you need to seed initial UI. Call the returned function to\n * stop listening.\n *\n * @param key - The state key to watch.\n * @param callback - Receives `(newValue, oldValue)` whenever the key changes.\n * @returns A function that removes this subscription.\n *\n * @example\n * const stop = Registry.subscribe<'light' | 'dark'>('theme', (next, prev) => {\n * console.log(`theme changed from ${prev} to ${next}`);\n * });\n *\n * // Later, when you no longer care:\n * stop();\n */\n static subscribe<T>(key: string, callback: StateSubscriber<T>): () => void {\n if (!this.subscribers[key]) {\n this.subscribers[key] = new Set();\n }\n\n this.subscribers[key].add(callback as StateSubscriber);\n\n return () => {\n this.unsubscribe(key, callback);\n };\n }\n\n /**\n * Removes a specific callback from a state key's subscription list.\n *\n * Most of the time you'll use the function returned by `subscribe()`\n * instead — this overload is available when you need to hold a reference\n * to the callback separately.\n *\n * @param key - The state key you subscribed to.\n * @param callback - The exact callback reference to remove.\n *\n * @example\n * const onThemeChange = (next: unknown) => console.log(next);\n * Registry.subscribe('theme', onThemeChange);\n * Registry.unsubscribe('theme', onThemeChange);\n */\n static unsubscribe<T>(key: string, callback: StateSubscriber<T>): void {\n if (this.subscribers[key]) {\n this.subscribers[key].delete(callback as StateSubscriber);\n }\n }\n\n /**\n * Returns a shallow copy of every key/value pair currently in the store.\n *\n * Handy for debugging, snapshotting, or serializing state. The copy is\n * shallow, so nested objects still share references with the live state.\n *\n * @returns A new object with all current state entries.\n *\n * @example\n * const snapshot = Registry.getAllState();\n * console.log(snapshot);\n */\n static getAllState(): Record<string, unknown> {\n return { ...this.state };\n }\n\n /**\n * Removes every state key and notifies subscribers for each one.\n *\n * Each key is deleted via `deleteState()`, so subscribers receive\n * `(undefined, oldValue)` per key in insertion order. This is most useful\n * between tests; reach for `deleteState()` for targeted cleanup.\n *\n * @example\n * afterEach(() => {\n * Registry.clearState();\n * });\n */\n static clearState(): void {\n const keys = Object.keys(this.state);\n\n for (const key of keys) {\n this.deleteState(key);\n }\n }\n\n /**\n * Drops every subscription registered via `subscribe()`.\n *\n * After this call, stored values remain untouched, but no callbacks will\n * fire on future changes. Intended for test teardown — in app code,\n * prefer the unsubscribe function each subscription returns.\n *\n * @example\n * afterEach(() => {\n * Registry.clearSubscriptions();\n * });\n */\n static clearSubscriptions(): void {\n for (const key of Object.keys(this.subscribers)) {\n this.subscribers[key] = new Set();\n }\n }\n\n /**\n * Removes every middleware registered through `use()`.\n *\n * Mainly for test isolation, since middleware survives between specs\n * otherwise.\n *\n * @example\n * afterEach(() => {\n * Registry.clearMiddleware();\n * });\n */\n static clearMiddleware(): void {\n for (const key of Object.keys(this.middleware) as MiddlewareType[]) {\n this.middleware[key] = new Set();\n }\n }\n\n /*\n * =========================\n * Debugging Tools\n * =========================\n */\n\n /**\n * Toggles Pandora's debug logging.\n *\n * When `true`, Registry and Component write lifecycle events to the\n * console (`Registered`, `Mounted`, `Evolved`, error traces, and so on).\n * Defaults to `false`.\n *\n * @example\n * Registry.debug = true;\n */\n static get debug(): boolean {\n return this._debug;\n }\n\n static set debug(value: boolean) {\n this._debug = value;\n }\n\n /**\n * Writes a `[Pandora] …` message to the console when debug mode is on.\n *\n * Use this for your own logging if you want it to stay silent in\n * production but pop up when you flip `Registry.debug = true`.\n *\n * @param message - Text to log.\n * @param data - Optional extra value logged alongside the message.\n *\n * @example\n * Registry.debug = true;\n * Registry.log('user signed in', { id: 'u_42' });\n */\n static log(message: string, data?: unknown): void {\n if (this._debug) {\n if (data !== undefined) {\n console.log(`[Pandora] ${message}`, data);\n } else {\n console.log(`[Pandora] ${message}`);\n }\n }\n }\n\n /**\n * Returns every tag currently known to Registry.\n *\n * Includes aliases and lazy placeholders alongside normally-registered\n * tags.\n *\n * @returns An array of tag names.\n *\n * @example\n * console.log(Registry.list()); // ['my-greeting', 'theme-toggle', ...]\n */\n static list(): string[] {\n return Object.keys(this.components);\n }\n\n /**\n * Reports current info about registered components: how many are mounted,\n * whether they're active, and whether they're still lazy.\n *\n * Called with a tag, returns a single stats object (throws if the tag is\n * unknown). Called with no argument, returns an array covering every\n * registered tag.\n *\n * @param tag - Optional specific tag to inspect.\n * @returns Stats for one tag or an array of stats for all tags.\n *\n * @example\n * Registry.stats('my-button');\n * // { tag: 'my-button', instanceCount: 3, isRegistered: true, isLazy: false }\n *\n * Registry.stats();\n * // [{ tag: 'my-button', ... }, { tag: 'theme-toggle', ... }]\n */\n static stats(tag?: string): ComponentStats | ComponentStats[] {\n if (tag) {\n if (!this.has(tag)) {\n throw new Error(`No component with tag \"${tag}\" has been registered.`);\n }\n\n return {\n tag,\n instanceCount: document.querySelectorAll(tag).length,\n isRegistered: this.components[tag]?._registered ?? false,\n isLazy: tag in this.lazyLoaders\n };\n }\n\n return this.list().map((tag) => ({\n tag: tag,\n instanceCount: document.querySelectorAll(tag).length,\n isRegistered: this.components[tag]?._registered ?? false,\n isLazy: tag in this.lazyLoaders\n }));\n }\n\n /*\n * =========================\n * Global Lifecycle Hooks\n * =========================\n */\n\n /**\n * Observes every component mount across your app.\n *\n * Your callback runs once for each component after its `connectedCallback`\n * resolves, receiving the instance and its tag. Useful for analytics,\n * wiring up dev tooling, or running a setup step whenever any Pandora\n * component appears.\n *\n * @param callback - Invoked with `(component, tag)` on every mount.\n * @returns A function that removes this observer.\n *\n * @example\n * const stop = Registry.onMount((component, tag) => {\n * console.log(`<${tag}> mounted`, component);\n * });\n */\n static onMount(callback: LifecycleCallback): () => void {\n this._init();\n this.mountCallbacks.add(callback);\n\n return () => this.mountCallbacks.delete(callback);\n }\n\n /**\n * Observes every component unmount across your app.\n *\n * Fires after `disconnectedCallback` completes, receiving the instance\n * and its tag. Pair it with `onMount()` to track lifecycles globally.\n *\n * @param callback - Invoked with `(component, tag)` on every unmount.\n * @returns A function that removes this observer.\n *\n * @example\n * Registry.onUnmount((component, tag) => {\n * console.log(`<${tag}> unmounted`);\n * });\n */\n static onUnmount(callback: LifecycleCallback): () => void {\n this._init();\n this.unmountCallbacks.add(callback);\n\n return () => this.unmountCallbacks.delete(callback);\n }\n\n /**\n * Fans a mount event out to every onMount observer. Each callback is\n * wrapped in try/catch so one misbehaving handler can't take down the\n * rest of the chain or the mounting component itself.\n *\n * @internal\n */\n static _notifyMount(component: Component, tag: string): void {\n this.log(`Mounted: <${tag}>`);\n this.mountCallbacks.forEach((callback) => {\n try {\n callback(component, tag);\n } catch (error) {\n console.error('[Pandora] Error in onMount callback:', error);\n }\n });\n }\n\n /**\n * Fans an unmount event out to every onUnmount observer. Same\n * per-callback error isolation as _notifyMount so teardown keeps moving\n * even when a single observer throws.\n *\n * @internal\n */\n static _notifyUnmount(component: Component, tag: string): void {\n this.log(`Unmounted: <${tag}>`);\n this.unmountCallbacks.forEach((callback) => {\n try {\n callback(component, tag);\n } catch (error) {\n console.error('[Pandora] Error in onUnmount callback:', error);\n }\n });\n }\n\n /*\n * =========================\n * Error Boundaries\n * =========================\n */\n\n /**\n * Installs a global error handler for component lifecycle errors.\n *\n * When a component throws during mount, render, or another lifecycle\n * step, each registered handler runs with `(error, component, tag,\n * lifecycle)`. If no handlers are registered, the error is re-thrown so\n * you still see failures in development.\n *\n * @param callback - Invoked with details about the failure.\n * @returns A function that removes this handler.\n *\n * @example\n * Registry.onError((error, component, tag, lifecycle) => {\n * console.error(`<${tag}> crashed in ${lifecycle}`, error);\n * reportToSentry(error, { tag, lifecycle });\n * });\n */\n static onError(callback: ErrorCallback): () => void {\n this._init();\n this.errorCallbacks.add(callback);\n\n return () => this.errorCallbacks.delete(callback);\n }\n\n /**\n * Dispatches a component lifecycle error. When no onError observers are\n * registered we re-throw so failures stay visible during development;\n * once any observer is installed, errors flow through the callback\n * chain (each wrapped in try/catch to isolate misbehaving handlers).\n *\n * @internal\n */\n static _notifyError(error: Error, component: Component, tag: string, lifecycle: string): void {\n this.log(`Error in <${tag}> during ${lifecycle}:`, error);\n\n if (this.errorCallbacks.size === 0) {\n throw error;\n }\n\n this.errorCallbacks.forEach((callback) => {\n try {\n callback(error, component, tag, lifecycle);\n } catch (callbackError) {\n console.error('[Pandora] Error in onError callback:', callbackError);\n }\n });\n }\n\n /*\n * =========================\n * Component Aliases\n * =========================\n */\n\n /**\n * Creates a second tag that renders the same component as an existing one.\n *\n * Under the hood, Pandora defines a lightweight subclass of the original\n * component and registers it under the new tag, so both tags render\n * independently while sharing behavior. Later `evolve()` calls on the\n * original flow through to the alias automatically.\n *\n * Set the alias up *before* any `<alias-tag>` element appears in the\n * document — this is what actually defines the custom element. Throws if\n * the alias name is already taken or the original isn't registered.\n *\n * @param aliasTag - The new tag name to register.\n * @param originalTag - The existing tag to mirror.\n *\n * @example\n * Registry.register('my-button', MyButton);\n * Registry.alias('primary-button', 'my-button');\n *\n * // <primary-button> now behaves just like <my-button>.\n */\n static alias(aliasTag: string, originalTag: string): void {\n if (!this.has(originalTag)) {\n throw new Error(`Cannot create alias: no component with tag \"${originalTag}\" has been registered.`);\n }\n\n if (this.has(aliasTag)) {\n throw new Error(`Cannot create alias: a component with tag \"${aliasTag}\" already exists.`);\n }\n\n this.aliases[aliasTag] = originalTag;\n\n // We create a subclass with its own _tag so customElements.define accepts\n // it, but it otherwise inherits everything from the original. Later\n // evolve() calls on the original can be fanned out to the alias through\n // the implementations map.\n const OriginalClass = this.getImplementation(originalTag) ?? this.components[originalTag];\n\n const AliasClass = class extends (OriginalClass as typeof Component) {\n static _tag = aliasTag;\n };\n\n this.components[aliasTag] = AliasClass as unknown as ComponentClass;\n this.implementations[aliasTag] = AliasClass as unknown as ComponentClass;\n window.customElements.define(aliasTag, AliasClass);\n (AliasClass as unknown as ComponentClass)._registered = true;\n\n this.log(`Created alias: <${aliasTag}> -> <${originalTag}>`);\n }\n\n /**\n * Looks up the tag a given alias points to.\n *\n * @param aliasTag - A tag that was created with `alias()`.\n * @returns The underlying tag, or `undefined` if `aliasTag` isn't an alias.\n *\n * @example\n * Registry.alias('primary-button', 'my-button');\n * Registry.getOriginalTag('primary-button'); // 'my-button'\n * Registry.getOriginalTag('my-button'); // undefined\n */\n static getOriginalTag(aliasTag: string): string | undefined {\n return this.aliases[aliasTag];\n }\n\n /**\n * Reports whether a tag was created via `alias()`.\n *\n * @param tag - The tag to check.\n * @returns `true` if this tag is an alias of another registered tag.\n *\n * @example\n * Registry.isAlias('primary-button'); // true\n * Registry.isAlias('my-button'); // false\n */\n static isAlias(tag: string): boolean {\n return tag in this.aliases;\n }\n\n /*\n * =========================\n * Lazy Loading\n * =========================\n */\n\n /**\n * Registers a tag whose implementation is fetched on demand.\n *\n * Pandora defines a placeholder custom element right away, so you can put\n * `<lazy-chart>` in markup immediately. The first time one connects, the\n * loader runs, its resolved class is applied to every pending instance,\n * and the loader is discarded — subsequent instances reuse the already-\n * loaded implementation without calling the loader again.\n *\n * The loader can return either the class directly or a module namespace\n * with a `default` export, so dynamic `import()` calls work out of the box.\n *\n * @param tag - The tag to reserve for lazy loading.\n * @param loader - Async function that resolves to the component class.\n *\n * @example\n * Registry.lazy('lazy-chart', () => import('./LazyChart'));\n *\n * // Somewhere in your markup:\n * // <lazy-chart data-metric=\"signups\"></lazy-chart>\n */\n static lazy(tag: string, loader: ComponentLoader): void {\n this._init();\n\n if (this.has(tag)) {\n throw new Error(`Cannot register lazy component: a component with tag \"${tag}\" already exists.`);\n }\n\n this.lazyLoaders[tag] = loader;\n\n // Capture the static registry as a local so the placeholder's\n // connectedCallback body reads cleanly.\n const registry = Registry;\n\n // A placeholder custom element we can define right away. When its first\n // instance connects we kick off the loader, swap the resolved class's\n // behavior onto this instance via _applyImplementation, then hand off\n // to Component's own connectedCallback so mount proceeds as normal.\n class LazyComponent extends Component {\n static _tag = tag;\n private _lazyLoaded = false;\n\n async connectedCallback(): Promise<void> {\n await registry._loadLazyComponent(tag);\n\n const RealComponent = registry.getImplementation(tag);\n if (RealComponent && RealComponent !== LazyComponent) {\n Registry._applyImplementation(this, RealComponent, false);\n this._lazyLoaded = true;\n }\n\n await super.connectedCallback();\n }\n }\n\n this.components[tag] = LazyComponent as unknown as ComponentClass;\n window.customElements.define(tag, LazyComponent);\n this.log(`Registered lazy component: <${tag}>`);\n }\n\n /**\n * Runs a registered lazy loader once, resolves its module-or-class\n * result, and installs the class as the live implementation for the\n * tag. We delete the loader afterwards so later instances short-circuit\n * and reuse the cached implementation instead of re-invoking import().\n *\n * @internal\n */\n static async _loadLazyComponent(tag: string): Promise<void> {\n if (this.lazyLoadPromises[tag]) {\n return this.lazyLoadPromises[tag];\n }\n\n if (!(tag in this.lazyLoaders)) {\n return;\n }\n\n const loader = this.lazyLoaders[tag];\n this.log(`Loading lazy component: <${tag}>`);\n\n this.lazyLoadPromises[tag] = (async () => {\n try {\n const result = await loader();\n const componentClass = 'default' in result ? result.default : result;\n\n // One-shot: drop the loader so subsequent connects skip the fetch\n // and go straight to the implementation swap.\n delete this.lazyLoaders[tag];\n\n this.implementations[tag] = componentClass;\n componentClass._registered = true;\n\n this.log(`Loaded lazy component: <${tag}>`);\n } catch (error) {\n console.error(`[Pandora] Failed to load lazy component <${tag}>:`, error);\n throw error;\n } finally {\n delete this.lazyLoadPromises[tag];\n }\n })();\n\n return this.lazyLoadPromises[tag];\n }\n\n /**\n * Reports whether a tag is still waiting to be lazily loaded.\n *\n * Returns `true` only while the loader has not yet run; once a lazy\n * component has loaded (via mount or `preload()`), this returns `false`.\n *\n * @param tag - The tag to check.\n * @returns `true` if the loader is registered and hasn't fired yet.\n *\n * @example\n * if (Registry.isLazy('lazy-chart')) {\n * await Registry.preload('lazy-chart');\n * }\n */\n static isLazy(tag: string): boolean {\n return tag in this.lazyLoaders;\n }\n\n /**\n * Runs a lazy component's loader without having to mount it first.\n *\n * Handy for warming up components you'll need soon (route transitions,\n * about-to-open dialogs). No-ops if the tag isn't lazy or has already\n * been loaded.\n *\n * @param tag - The lazy tag to load ahead of time.\n *\n * @example\n * // Prime the chart before the user opens the dashboard:\n * await Registry.preload('lazy-chart');\n */\n static async preload(tag: string): Promise<void> {\n if (this.isLazy(tag)) {\n await this._loadLazyComponent(tag);\n }\n }\n\n /*\n * =========================\n * Middleware\n * =========================\n */\n\n /**\n * Installs a middleware function into one of Pandora's pipelines.\n *\n * Today the only supported type is `'render'`, which receives each\n * component's render output before it's applied to the DOM. Multiple\n * middleware run in registration order, and each one sees the value the\n * previous one returned, so you can chain transforms. The `renderType`\n * argument tells you whether the value is a plain string template or a\n * lit-html `TemplateResult`, so you can handle them appropriately.\n *\n * If a middleware throws, the error is logged via `console.error` and\n * the pipeline continues with the value it received, so one faulty\n * middleware can't break the chain.\n *\n * @param type - The middleware pipeline to hook into (currently `'render'`).\n * @param middleware - Receives `(component, value, renderType?)` and returns the new value.\n * @returns A function that removes this middleware.\n *\n * @example\n * const stop = Registry.use('render', (component, value, renderType) => {\n * if (renderType === 'string' && typeof value === 'string') {\n * return value.replace(/TODO/g, '<mark>TODO</mark>');\n * }\n * return value;\n * });\n */\n static use(type: MiddlewareType, middleware: Middleware): () => void {\n this._init();\n this.middleware[type].add(middleware);\n\n return () => this.middleware[type].delete(middleware);\n }\n\n /**\n * Threads a value through every registered middleware in insertion\n * order, each one seeing the previous one's return value. Throws are\n * caught and logged — the faulty middleware contributes nothing and the\n * previous result passes through unchanged so one bad hook can't break\n * the render pipeline.\n *\n * @internal\n */\n static _applyMiddleware(type: MiddlewareType, component: Component, value: unknown, renderType?: RenderType): unknown {\n let result = value;\n\n this.middleware[type].forEach((middleware) => {\n try {\n result = middleware(component, result, renderType);\n } catch (error) {\n console.error(`[Pandora] Error in ${type} middleware:`, error);\n }\n });\n\n return result;\n }\n\n /**\n * Quick probe used by Component on hot render paths to skip building a\n * middleware context when nothing is registered for this type.\n *\n * @internal\n */\n static _hasMiddleware(type: MiddlewareType): boolean {\n return this.middleware[type].size > 0;\n }\n}\n\n// We wire Component.register() to delegate to Registry.register() at\n// import time rather than inside _init(). That way MyComp.register()\n// works even if it's the very first Registry-adjacent call the user\n// makes, without needing to prime _init() some other way.\nComponent._registryRegister = (tag, component) => Registry.register(tag, component as ComponentClass);\n\nexport default Registry;\n",
10
- "import Component from './Component';\nimport Registry from './Registry';\nimport {\n PROP_ATTRIBUTES, WATCH_HANDLERS, LISTEN_HANDLERS, STYLE_METADATA, REACTIVE_FIELDS,\n ATTR_HANDLERS, SUBSCRIBE_HANDLERS,\n addDecoratorEffect, addTeardown, parseAttributeValue,\n} from './Util';\n\nimport type { AttrHandler, SubscribeHandler } from './Types';\nimport { Style } from './Types';\n\n// TC39 decorator metadata relies on `Symbol.metadata`; polyfill it for runtimes\n// that don't ship the well-known symbol yet so our field decorators can stash\n// data on `context.metadata` the same way everywhere.\n(Symbol as any).metadata ??= Symbol('Symbol.metadata');\n\n// ==========================================\n// Types\n// ==========================================\n\ntype ComponentConstructor = typeof Component & {\n tag: string;\n _registered?: boolean;\n};\n\ntype DecoratorInstance = Component & Record<string | symbol, unknown>;\n\n// ==========================================\n// @Register\n// ==========================================\n\ninterface RegisterOptions {\n defer?: boolean;\n}\n\n/**\n * Registers a class as a custom element with the browser under the given tag.\n *\n * By default the element is defined on `customElements` immediately. Pass\n * `{ defer: true }` when you want to delay registration — useful if you need\n * to wire up dependencies or control mount ordering yourself before the tag\n * becomes usable in the DOM.\n *\n * @param tagName - The custom element tag name (must contain a hyphen).\n * @param options - Pass `{ defer: true }` to skip automatic registration.\n *\n * @example\n * @Register('my-greeting')\n * class MyGreeting extends Component {\n * render() {\n * return html`<p>Hello, world.</p>`;\n * }\n * }\n *\n * // <my-greeting></my-greeting>\n */\nexport function Register(tagName: string, options?: RegisterOptions) {\n return function <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext): T {\n // At this point the class decorator has run but the TC39 runtime hasn't\n // copied metadata onto the constructor yet, so we read from `context.metadata`\n // directly — that's the only reference that reflects field decorators.\n const meta = context.metadata as Record<symbol, unknown> | undefined;\n\n if (meta?.[PROP_ATTRIBUTES]) {\n if (!Object.hasOwn(constructor, '_observedAttributes')) {\n (constructor as any)._observedAttributes = [];\n }\n\n for (const attr of meta[PROP_ATTRIBUTES] as string[]) {\n if (!(constructor as any)._observedAttributes.includes(attr)) {\n (constructor as any)._observedAttributes.push(attr);\n }\n }\n }\n\n // `customElements.define` reads `observedAttributes`, whose getter falls\n // back to `[Symbol.metadata]` for dynamic cases like inherited `@Attribute`\n // fields — so we need metadata attached to the constructor before we register.\n if (meta && (constructor as unknown as Record<symbol, unknown>)[Symbol.metadata] === undefined) {\n (constructor as unknown as Record<symbol, unknown>)[Symbol.metadata] = meta;\n }\n\n constructor.tag = tagName;\n\n if (!options?.defer) {\n Registry.register(tagName, constructor);\n }\n\n return constructor;\n };\n}\n\n// ==========================================\n// @Style\n// ==========================================\n\n/**\n * Attaches scoped CSS to the component. Accepts either a raw CSS string or\n * a structured `Style` object (selectors and declarations).\n *\n * Styles are applied once per class and live alongside the component's\n * shadow or light DOM output, so they don't leak to the rest of the page.\n *\n * @param css - A CSS string or a `Style` object describing the rules.\n *\n * @example\n * @Register('my-button')\n * @Style({\n * button: {\n * padding: '0.5rem 1rem',\n * borderRadius: '6px',\n * background: 'hotpink',\n * color: 'white',\n * },\n * })\n * class MyButton extends Component {\n * render() {\n * return html`<button>Click me</button>`;\n * }\n * }\n */\nexport function Style(css: Style | string) {\n return function <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext): T {\n const meta = context.metadata as Record<symbol, unknown>;\n\n meta[STYLE_METADATA] = css;\n return constructor;\n };\n}\n\n// ==========================================\n// @Watch\n// ==========================================\n\ninterface WatchEntry {\n property: string;\n methodName: string;\n}\n\n/**\n * Runs the decorated method whenever the given reactive property changes,\n * receiving the new and previous values.\n *\n * The watched property must be declared with `@State`, `@Attribute`, or\n * `@Property` — otherwise you'll see a one-time dev warning explaining that\n * the watcher will never fire. Watchers run synchronously on assignment,\n * before the next render is queued.\n *\n * @param property - The name of the reactive field to observe.\n *\n * @example\n * @Register('my-counter')\n * class MyCounter extends Component {\n * @State() count = 0;\n *\n * @Watch('count')\n * onCountChange(next: number, previous: number) {\n * console.log(`count went from ${previous} to ${next}`);\n * }\n *\n * render() {\n * return html`<button @click=${() => this.count++}>${this.count}</button>`;\n * }\n * }\n */\nexport function Watch(property: string) {\n return function <T extends (...args: any[]) => any>(\n _target: T,\n context: ClassMethodDecoratorContext\n ): void {\n const methodName = String(context.name);\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, WATCH_HANDLERS)) {\n const inherited = meta[WATCH_HANDLERS] as WatchEntry[] | undefined;\n meta[WATCH_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n (meta[WATCH_HANDLERS] as WatchEntry[]).push({ property, methodName });\n\n // Field decorators haven't run yet when the method decorator fires, so we\n // defer the \"is this property actually reactive?\" check to `addInitializer`\n // — by the time the first instance constructs, every field has registered.\n let warned = false;\n context.addInitializer(function (this: unknown) {\n if (warned) {\n return;\n }\n\n warned = true;\n\n const reactiveFields = meta[REACTIVE_FIELDS] as Set<string> | undefined;\n\n if (!reactiveFields || !reactiveFields.has(property)) {\n const ctorName = (this as { constructor?: { name?: string } })?.constructor?.name ?? '<anonymous>';\n console.warn(\n `[Pandora] @Watch('${property}') on ${ctorName}.${methodName}(): '${property}' has no @State, @Attribute, or @Property decorator. Add one of those decorators to '${property}', or call reactive(this, '${property}') in the constructor — otherwise the watcher will never fire.`\n );\n }\n });\n };\n}\n\n/**\n * Collects every `@Watch` callback registered for a given property and binds\n * them to the instance. Called from the reactive setters in `applyStateEffect`\n * and `applyPropEffect` each time a tracked field changes.\n *\n * @internal\n */\nfunction getWatchersForProperty(instance: DecoratorInstance, propertyKey: string): Array<(newVal: unknown, oldVal: unknown) => void> {\n if (typeof Symbol.metadata === 'undefined') {\n return [];\n }\n\n const meta = ((instance.constructor as any)[Symbol.metadata]) as Record<symbol, unknown> | undefined;\n const entries = meta?.[WATCH_HANDLERS] as WatchEntry[] | undefined;\n\n if (!entries) {\n return [];\n }\n\n const callbacks: Array<(newVal: unknown, oldVal: unknown) => void> = [];\n\n for (const entry of entries) {\n if (entry.property === propertyKey) {\n const method = (instance as any)[entry.methodName];\n\n if (typeof method === 'function') {\n callbacks.push(method.bind(instance));\n }\n }\n }\n\n return callbacks;\n}\n\n// ==========================================\n// Dev Validation\n// ==========================================\n\n/**\n * HTMLElement properties that, if shadowed by a decorated field, can cause\n * subtle breakage (e.g. our accessor shadows the native one). Checked at\n * decoration time by `warnIfReserved`.\n *\n * @internal\n */\nconst RESERVED_ELEMENT_PROPERTIES = new Set([\n 'hidden', 'title', 'slot', 'style', 'id', 'className', 'tabIndex',\n 'dir', 'lang', 'draggable', 'contentEditable', 'accessKey',\n 'innerHTML', 'outerHTML', 'textContent', 'innerText',\n]);\n\n/**\n * Emits a dev-time warning if a decorator is applied to a field name that\n * collides with a built-in HTMLElement property. Runs once per decoration.\n *\n * @internal\n */\nfunction warnIfReserved(decoratorName: string, propertyKey: string): void {\n if (RESERVED_ELEMENT_PROPERTIES.has(propertyKey)) {\n console.warn(\n `[Pandora] @${decoratorName}('${propertyKey}') conflicts with HTMLElement.${propertyKey}. ` +\n `This may cause unexpected behavior. Consider renaming to avoid the conflict.`\n );\n }\n}\n\n// ==========================================\n// @State\n// ==========================================\n\ninterface StateOptions {\n render?: boolean;\n}\n\n/**\n * Declares a reactive instance field. Assigning to the field queues a render\n * on the next microtask, and multiple assignments in the same tick coalesce\n * into a single render pass.\n *\n * Pass `{ render: false }` to keep the field reactive — `@Watch` handlers\n * still fire and the value still flows through `didChange` — without\n * triggering a re-render on every assignment.\n *\n * @param options - Optional `{ render: false }` to opt out of re-rendering.\n *\n * @example\n * @Register('my-counter')\n * class MyCounter extends Component {\n * @State() count = 0;\n * @State({ render: false }) private lastPing = Date.now();\n *\n * render() {\n * return html`<button @click=${() => this.count++}>${this.count}</button>`;\n * }\n * }\n */\nexport function State(options?: StateOptions) {\n return function (_target: undefined, context: ClassFieldDecoratorContext) {\n const propertyKey = String(context.name);\n warnIfReserved('State', propertyKey);\n const shouldRender = options?.render !== false;\n const valueKey = Symbol(`__pandora_state_${propertyKey}`);\n\n // We capture the class default from the first instance into a closure\n // rather than metadata — the list of known reactive fields lives on the\n // class, but the default value is shared per-decorator-site, so stashing\n // it here keeps metadata from growing per-instance.\n let classDefault: unknown;\n let defaultCaptured = false;\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, REACTIVE_FIELDS)) {\n const inherited = meta[REACTIVE_FIELDS] as Set<string> | undefined;\n meta[REACTIVE_FIELDS] = inherited ? new Set(inherited) : new Set();\n }\n\n (meta[REACTIVE_FIELDS] as Set<string>).add(propertyKey);\n\n addDecoratorEffect(meta, (instance) => {\n applyStateEffect(instance as DecoratorInstance, propertyKey, valueKey, shouldRender);\n // Evolve/lazy replay runs without the original field initializer, so we\n // seed the backing slot with the captured class default when it's empty.\n if (defaultCaptured && (instance as DecoratorInstance)[valueKey] === undefined) {\n (instance as DecoratorInstance)[valueKey] = classDefault;\n }\n });\n\n context.addInitializer(function (this: unknown) {\n const instance = this as DecoratorInstance;\n const initialValue = instance[propertyKey as keyof typeof instance];\n\n applyStateEffect(instance, propertyKey, valueKey, shouldRender);\n\n if (initialValue !== undefined) {\n instance[valueKey] = initialValue;\n if (!defaultCaptured) {\n classDefault = initialValue;\n defaultCaptured = true;\n }\n }\n });\n };\n}\n\n/**\n * Installs a reactive getter/setter pair for a `@State` (or property-only)\n * field on an instance. Called from the state decorator's `addInitializer` on\n * first instantiation and from `Registry.evolve()` / lazy replay when the\n * implementation swaps under a connected element.\n *\n * @internal\n */\nfunction applyStateEffect(\n instance: DecoratorInstance,\n propertyKey: string,\n valueKey: symbol,\n shouldRender: boolean,\n source: string = 'state',\n equals: (a: unknown, b: unknown) => boolean = (a, b) => a === b\n): void {\n // Preserve any pre-existing own value before our accessor replaces it. This\n // matters for decorator replay (evolve/lazy) when the caller wrote to the\n // property on the old base instance before the new implementation applied,\n // and for initializers of plain-field defaults.\n migrateOwnValueTo(instance, propertyKey, valueKey);\n\n Object.defineProperty(instance, propertyKey, {\n get() {\n return instance[valueKey];\n },\n set(newVal: unknown) {\n const oldVal = instance[valueKey];\n if (equals(oldVal, newVal)) return;\n instance[valueKey] = newVal;\n\n // Inside `batch()` we defer `@Watch` and `didChange` until the batch\n // closes. If the same field changes more than once we collapse entries\n // to a single first-to-last span, keeping the original oldValue.\n if ((instance as any)._batching) {\n const changes = (instance as any)._batchedChanges as Array<{ property: string; oldValue: unknown; newValue: unknown; shouldRender: boolean; source: string }>;\n const existing = changes.find((c: any) => c.property === propertyKey);\n if (existing) {\n existing.newValue = newVal;\n if (shouldRender) existing.shouldRender = true;\n } else {\n changes.push({ property: propertyKey, oldValue: oldVal, newValue: newVal, shouldRender, source });\n }\n return;\n }\n\n const watchers = getWatchersForProperty(instance, propertyKey);\n for (const watcher of watchers) {\n watcher(newVal, oldVal);\n }\n\n instance.didChange(propertyKey, oldVal, newVal, source);\n\n // Skip the render queue until the initial render has landed — otherwise\n // field initializers running during construction would trigger renders\n // before the element is actually ready to paint.\n if (shouldRender && (instance as any)._initRenderDone && instance.isConnected) {\n (instance as any)._queueRender();\n }\n },\n enumerable: true,\n configurable: true\n });\n\n addTeardown(instance as any, () => {\n delete (instance as any)[propertyKey];\n });\n}\n\n// ==========================================\n// @Property (reactive, never renders)\n// ==========================================\n\ninterface PropertyOptions {\n attribute?: string | false;\n equals?: (a: unknown, b: unknown) => boolean;\n}\n\n/**\n * Exposes a reactive JavaScript property on the component — ideal for values\n * that aren't string-serializable, like objects, arrays, or class instances.\n *\n * Properties are reactive (they fire `@Watch` handlers and run through\n * `didChange`) but do not trigger re-renders on their own, so a parent can\n * hand a child rich data without causing render thrash. Pass\n * `{ attribute: 'some-name' }` to mirror the value to an attribute for\n * primitives, or provide a custom `equals` comparator to skip updates when\n * a deep-equal object is assigned.\n *\n * @param options - `{ attribute, equals }` to control attribute sync and\n * change detection.\n *\n * @example\n * interface User { id: string; name: string; }\n *\n * @Register('user-avatar')\n * class UserAvatar extends Component {\n * @Property() user!: User;\n *\n * render() {\n * return html`<img alt=${this.user.name} data-id=${this.user.id}>`;\n * }\n * }\n *\n * // In a parent:\n * // const el = document.querySelector('user-avatar');\n * // el.user = { id: 'u_42', name: 'Ada Lovelace' };\n */\nexport function Property(options?: PropertyOptions) {\n return function (_target: undefined, context: ClassFieldDecoratorContext) {\n const propertyKey = String(context.name);\n warnIfReserved('Property', propertyKey);\n const valueKey = Symbol(`__pandora_property_${propertyKey}`);\n const customEquals = options?.equals ?? ((a: unknown, b: unknown) => a === b);\n const attrName = options?.attribute ?? false;\n\n let classDefault: unknown;\n let defaultCaptured = false;\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, REACTIVE_FIELDS)) {\n const inherited = meta[REACTIVE_FIELDS] as Set<string> | undefined;\n meta[REACTIVE_FIELDS] = inherited ? new Set(inherited) : new Set();\n }\n\n (meta[REACTIVE_FIELDS] as Set<string>).add(propertyKey);\n\n if (attrName !== false) {\n // Attribute-mirrored path: reuse the attribute machinery but pass\n // `shouldRender = false` so assignments skip the render queue.\n const settingKey = Symbol(`__pandora_propSetting_${propertyKey}`);\n\n if (!Object.hasOwn(meta, PROP_ATTRIBUTES)) {\n const inherited = meta[PROP_ATTRIBUTES] as string[] | undefined;\n meta[PROP_ATTRIBUTES] = inherited ? [...inherited] : [];\n }\n\n if (!(meta[PROP_ATTRIBUTES] as string[]).includes(attrName)) {\n (meta[PROP_ATTRIBUTES] as string[]).push(attrName);\n }\n\n registerAttrHandler(meta, { attrName, propertyKey, valueKey, settingKey, shouldRender: false, equals: customEquals });\n\n addDecoratorEffect(meta, (instance) => {\n applyPropEffect(instance as DecoratorInstance, attrName, propertyKey, valueKey, settingKey, false, customEquals);\n if (defaultCaptured && (instance as DecoratorInstance)[valueKey] === undefined) {\n if ((instance as DecoratorInstance).hasAttribute(attrName)) {\n (instance as DecoratorInstance)[valueKey] = parseAttributeValue((instance as DecoratorInstance).getAttribute(attrName));\n } else {\n (instance as DecoratorInstance)[valueKey] = classDefault;\n syncToAttribute(instance as DecoratorInstance, attrName, classDefault);\n }\n }\n });\n\n context.addInitializer(function (this: unknown) {\n const instance = this as DecoratorInstance;\n const initialValue = instance[propertyKey as keyof typeof instance];\n const hasInitialAttribute = instance.hasAttribute(attrName);\n const initialAttributeValue = hasInitialAttribute ? parseAttributeValue(instance.getAttribute(attrName)) : undefined;\n\n applyPropEffect(instance, attrName, propertyKey, valueKey, settingKey, false, customEquals);\n\n if (initialValue !== undefined && !defaultCaptured) {\n classDefault = initialValue;\n defaultCaptured = true;\n }\n\n if (hasInitialAttribute) {\n instance[valueKey] = initialAttributeValue;\n } else if (initialValue !== undefined) {\n instance[valueKey] = initialValue;\n syncToAttribute(instance, attrName, initialValue);\n }\n });\n } else {\n // Default path: reactive field with no attribute mirror and no render,\n // so we ride `applyStateEffect` for `@Watch` plumbing alone.\n addDecoratorEffect(meta, (instance) => {\n applyStateEffect(instance as DecoratorInstance, propertyKey, valueKey, false, 'property', customEquals);\n\n if (defaultCaptured && (instance as DecoratorInstance)[valueKey] === undefined) {\n (instance as DecoratorInstance)[valueKey] = classDefault;\n }\n });\n\n context.addInitializer(function (this: unknown) {\n const instance = this as DecoratorInstance;\n const initialValue = instance[propertyKey as keyof typeof instance];\n\n applyStateEffect(instance, propertyKey, valueKey, false, 'property', customEquals);\n\n if (initialValue !== undefined) {\n instance[valueKey] = initialValue;\n if (!defaultCaptured) {\n classDefault = initialValue;\n defaultCaptured = true;\n }\n }\n });\n }\n };\n}\n\n// ==========================================\n// @Attribute\n// ==========================================\n\ninterface AttributeOptions {\n render?: boolean;\n}\n\n/**\n * Binds a reactive field to an HTML attribute. The field reads through to\n * the attribute, and assignments are written back, keeping DOM and JS state\n * in sync.\n *\n * By default the attribute name matches the field name — pass a string to\n * map to a different attribute (e.g. `@Attribute('user-name')`), or pass\n * `{ render: false }` to keep the field reactive without triggering a\n * re-render when the attribute changes. String, number, and boolean values\n * are serialized automatically.\n *\n * @param attributeNameOrOptions - Either the attribute name to bind to, or\n * an options object like `{ render: false }`.\n *\n * @example\n * @Register('my-greeting')\n * class MyGreeting extends Component {\n * @Attribute() name = 'world';\n *\n * render() {\n * return html`<p>Hello, ${this.name}.</p>`;\n * }\n * }\n *\n * // <my-greeting name=\"Ada\"></my-greeting>\n */\nexport function Attribute(attributeNameOrOptions?: string | AttributeOptions) {\n return function (_target: undefined, context: ClassFieldDecoratorContext) {\n const propertyKey = String(context.name);\n warnIfReserved('Attribute', propertyKey);\n\n let attrName: string;\n let shouldRender = true;\n\n if (typeof attributeNameOrOptions === 'object') {\n attrName = propertyKey;\n shouldRender = attributeNameOrOptions.render !== false;\n } else {\n attrName = attributeNameOrOptions ?? propertyKey;\n }\n\n const valueKey = Symbol(`__pandora_attr_${propertyKey}`);\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, REACTIVE_FIELDS)) {\n const inherited = meta[REACTIVE_FIELDS] as Set<string> | undefined;\n meta[REACTIVE_FIELDS] = inherited ? new Set(inherited) : new Set();\n }\n (meta[REACTIVE_FIELDS] as Set<string>).add(propertyKey);\n\n let classDefault: unknown;\n let defaultCaptured = false;\n\n {\n const settingKey = Symbol(`__pandora_propSetting_${propertyKey}`);\n\n if (!Object.hasOwn(meta, PROP_ATTRIBUTES)) {\n const inherited = meta[PROP_ATTRIBUTES] as string[] | undefined;\n meta[PROP_ATTRIBUTES] = inherited ? [...inherited] : [];\n }\n\n if (!(meta[PROP_ATTRIBUTES] as string[]).includes(attrName)) {\n (meta[PROP_ATTRIBUTES] as string[]).push(attrName);\n }\n\n registerAttrHandler(meta, { attrName, propertyKey, valueKey, settingKey, shouldRender, equals: (a, b) => a === b });\n\n addDecoratorEffect(meta, (instance) => {\n applyPropEffect(instance as DecoratorInstance, attrName as string, propertyKey, valueKey, settingKey, shouldRender);\n if (defaultCaptured && (instance as DecoratorInstance)[valueKey] === undefined) {\n if ((instance as DecoratorInstance).hasAttribute(attrName as string)) {\n (instance as DecoratorInstance)[valueKey] = parseAttributeValue((instance as DecoratorInstance).getAttribute(attrName as string));\n } else {\n (instance as DecoratorInstance)[valueKey] = classDefault;\n syncToAttribute(instance as DecoratorInstance, attrName as string, classDefault);\n }\n }\n });\n\n context.addInitializer(function (this: unknown) {\n const instance = this as DecoratorInstance;\n const initialValue = instance[propertyKey as keyof typeof instance];\n const hasInitialAttribute = instance.hasAttribute(attrName);\n const initialAttributeValue = hasInitialAttribute ? parseAttributeValue(instance.getAttribute(attrName)) : undefined;\n\n applyPropEffect(instance, attrName as string, propertyKey, valueKey, settingKey, shouldRender);\n\n if (initialValue !== undefined && !defaultCaptured) {\n classDefault = initialValue;\n defaultCaptured = true;\n }\n\n if (hasInitialAttribute) {\n instance[valueKey] = initialAttributeValue;\n } else if (initialValue !== undefined) {\n instance[valueKey] = initialValue;\n syncToAttribute(instance, attrName as string, initialValue);\n }\n });\n }\n };\n}\n\n\n/**\n * Moves an existing own-data-value out of the property slot and into the\n * backing symbol slot before our accessor descriptor takes over, so a value\n * assigned before decoration survives the install.\n *\n * @internal\n */\nfunction migrateOwnValueTo(instance: DecoratorInstance, propertyKey: string, valueKey: symbol): void {\n const desc = Object.getOwnPropertyDescriptor(instance, propertyKey);\n // A data descriptor means someone wrote a raw value we need to rescue; an\n // accessor descriptor means the reactive getter/setter is already installed,\n // so there's nothing to migrate.\n if (desc && 'value' in desc && desc.value !== undefined && instance[valueKey] === undefined) {\n instance[valueKey] = desc.value;\n }\n}\n\n/**\n * Appends an `AttrHandler` to the class-level handler list stored in metadata.\n * Used by `@Attribute` and attribute-mirroring `@Property` during decoration.\n *\n * @internal\n */\nfunction registerAttrHandler(meta: Record<symbol, unknown>, handler: AttrHandler): void {\n if (!Object.hasOwn(meta, ATTR_HANDLERS)) {\n const inherited = meta[ATTR_HANDLERS] as AttrHandler[] | undefined;\n meta[ATTR_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n (meta[ATTR_HANDLERS] as AttrHandler[]).push(handler);\n}\n\n/**\n * Writes a primitive value back to an element attribute, serializing booleans\n * as presence/absence and strings/numbers via `String()`. Other types are\n * skipped — they can't round-trip through the DOM.\n *\n * @internal\n */\nfunction syncToAttribute(instance: DecoratorInstance, attrName: string, value: unknown): void {\n if (typeof value === 'boolean') {\n if (value) {\n instance.setAttribute(attrName, '');\n } else {\n instance.removeAttribute(attrName);\n }\n } else if (typeof value === 'string' || typeof value === 'number') {\n instance.setAttribute(attrName, String(value));\n }\n}\n\n/**\n * Installs a reactive accessor that mirrors its value to an HTML attribute,\n * used by `@Attribute` and attribute-synced `@Property`. Called on first\n * instantiation and again on evolve/lazy replay.\n *\n * @internal\n */\nfunction applyPropEffect(\n instance: DecoratorInstance,\n attrName: string,\n propertyKey: string,\n valueKey: symbol,\n settingKey: symbol,\n shouldRender: boolean = true,\n equals: (a: unknown, b: unknown) => boolean = (a, b) => a === b\n): void {\n migrateOwnValueTo(instance, propertyKey, valueKey);\n\n Object.defineProperty(instance, propertyKey, {\n get() {\n if (instance[valueKey] !== undefined) {\n return instance[valueKey];\n }\n\n if (instance.hasAttribute(attrName)) {\n return parseAttributeValue(instance.getAttribute(attrName));\n }\n\n return undefined;\n },\n set(newVal: unknown) {\n const oldVal = instance[valueKey];\n instance[valueKey] = newVal;\n instance[settingKey] = true;\n\n // `undefined` / `null` clears the attribute; primitives serialize with\n // boolean-as-presence semantics, matching how HTML natively treats them.\n if (newVal === undefined || newVal === null) {\n instance.removeAttribute(attrName);\n } else if (typeof newVal === 'string' || typeof newVal === 'number' || typeof newVal === 'boolean') {\n if (typeof newVal === 'boolean') {\n if (newVal) {\n instance.setAttribute(attrName, '');\n } else {\n instance.removeAttribute(attrName);\n }\n } else {\n instance.setAttribute(attrName, String(newVal));\n }\n }\n\n instance[settingKey] = false;\n\n if (!equals(oldVal, newVal)) {\n // Same batching dance as `applyStateEffect`: coalesce repeated writes\n // to a single first-to-last record while a batch is open.\n if ((instance as any)._batching) {\n const changes = (instance as any)._batchedChanges as Array<{ property: string; oldValue: unknown; newValue: unknown; shouldRender: boolean; source: string }>;\n const existing = changes.find((c: any) => c.property === propertyKey);\n\n if (existing) {\n existing.newValue = newVal;\n\n if (shouldRender) {\n existing.shouldRender = true;\n }\n } else {\n changes.push({ property: propertyKey, oldValue: oldVal, newValue: newVal, shouldRender, source: 'prop' });\n }\n } else {\n const watchers = getWatchersForProperty(instance, propertyKey);\n\n for (const watcher of watchers) {\n watcher(newVal, oldVal);\n }\n\n instance.didChange(propertyKey, oldVal, newVal, 'prop');\n\n if (shouldRender && (instance as any)._initRenderDone && instance.isConnected) {\n (instance as any)._queueRender();\n }\n }\n }\n },\n enumerable: true,\n configurable: true\n });\n\n if (instance.isConnected && instance.hasAttribute(attrName)) {\n instance[valueKey] = parseAttributeValue(instance.getAttribute(attrName));\n }\n\n addTeardown(instance as any, () => {\n delete (instance as any)[propertyKey];\n });\n}\n\n// ==========================================\n// @Subscribe\n// ==========================================\n\n/**\n * Subscribes a field to a shared state key on the global `Registry`. Reading\n * the field returns the current registry value; assigning writes it back\n * and notifies every other subscriber.\n *\n * Subscriptions activate on connect and tear down on disconnect, so\n * components automatically stay in sync with the store for as long as\n * they're in the DOM — no manual wiring required.\n *\n * @param stateKey - The key in the `Registry` store this field mirrors.\n *\n * @example\n * // Somewhere at startup:\n * Registry.setState('theme', 'light');\n *\n * @Register('theme-toggle')\n * class ThemeToggle extends Component {\n * @Subscribe('theme') theme!: 'light' | 'dark';\n *\n * render() {\n * return html`\n * <button @click=${() => this.theme = this.theme === 'light' ? 'dark' : 'light'}>\n * Theme: ${this.theme}\n * </button>\n * `;\n * }\n * }\n */\nexport function Subscribe(stateKey: string) {\n return function (_target: undefined, context: ClassFieldDecoratorContext) {\n const propertyKey = String(context.name);\n const unsubKey = Symbol(`__pandora_unsub_${propertyKey}`);\n const valueKey = Symbol(`__pandora_value_${propertyKey}`);\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, REACTIVE_FIELDS)) {\n const inherited = meta[REACTIVE_FIELDS] as Set<string> | undefined;\n meta[REACTIVE_FIELDS] = inherited ? new Set(inherited) : new Set();\n }\n\n (meta[REACTIVE_FIELDS] as Set<string>).add(propertyKey);\n\n // We stash subscription handlers on class metadata so the prototype's\n // `connectedCallback` can activate them on mount. The browser invokes\n // lifecycle callbacks through the prototype, so per-instance wrappers\n // registered via `addInitializer` would never fire on a natural mount.\n if (!Object.hasOwn(meta, SUBSCRIBE_HANDLERS)) {\n const inherited = meta[SUBSCRIBE_HANDLERS] as SubscribeHandler[] | undefined;\n meta[SUBSCRIBE_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n (meta[SUBSCRIBE_HANDLERS] as SubscribeHandler[]).push({ stateKey, propertyKey, unsubKey, valueKey });\n\n addDecoratorEffect(meta, (instance) => {\n applyConsumerEffect(instance as DecoratorInstance, stateKey, propertyKey, unsubKey, valueKey);\n });\n\n context.addInitializer(function (this: unknown) {\n applyConsumerEffect(this as DecoratorInstance, stateKey, propertyKey, unsubKey, valueKey);\n });\n };\n}\n\n\n/**\n * Installs a reactive accessor backed by the global `Registry` for\n * `@Subscribe` fields, wiring reads, writes, and subscription lifecycle on\n * the instance. Called on decoration and again on evolve/lazy replay.\n *\n * @internal\n */\nfunction applyConsumerEffect(\n instance: DecoratorInstance,\n stateKey: string,\n propertyKey: string,\n unsubKey: symbol,\n valueKey: symbol\n): void {\n Object.defineProperty(instance, propertyKey, {\n get() {\n return instance[valueKey];\n },\n set(newVal: unknown) {\n const oldVal = instance[valueKey];\n\n if (oldVal === newVal) {\n return;\n }\n\n instance[valueKey] = newVal;\n Registry.setState(stateKey, newVal);\n instance.didChange(propertyKey, oldVal, newVal, 'consumer');\n\n if (instance.isReady) {\n (instance as any)._queueRender();\n }\n },\n enumerable: true,\n configurable: true\n });\n\n // When evolve/lazy re-applies on an already-connected instance, we activate\n // the subscription right here — otherwise we'd miss every state update\n // until the next connect cycle. The prototype `connectedCallback` handles\n // the natural mount path.\n if (instance.isConnected) {\n Component._activateSubscription?.(instance as unknown as Component, { stateKey, propertyKey, unsubKey, valueKey });\n }\n\n addTeardown(instance as any, () => {\n if (instance[unsubKey]) {\n (instance[unsubKey] as () => void)();\n instance[unsubKey] = undefined;\n }\n delete (instance as any)[propertyKey];\n });\n}\n\n// ==========================================\n// @Query / @QueryAll\n// ==========================================\n\n/**\n * Turns a field into a live selector query against the component's rendered\n * DOM. Each access re-runs the lookup, so the reference stays correct even\n * as the template re-renders.\n *\n * @param selector - A CSS selector scoped to the component's root.\n *\n * @example\n * @Register('my-form')\n * class MyForm extends Component {\n * @Query('input[name=\"email\"]') emailInput!: HTMLInputElement | null;\n *\n * submit() {\n * console.log('email:', this.emailInput?.value);\n * }\n *\n * render() {\n * return html`\n * <form @submit=${(e: Event) => { e.preventDefault(); this.submit(); }}>\n * <input name=\"email\" type=\"email\" />\n * <button type=\"submit\">Send</button>\n * </form>\n * `;\n * }\n * }\n */\nexport function Query(selector: string) {\n return function (_target: undefined, context: ClassFieldDecoratorContext) {\n const propertyKey = String(context.name);\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n addDecoratorEffect(meta, (instance) => {\n applyQueryEffect(instance as unknown as Component, propertyKey, selector);\n });\n\n context.addInitializer(function (this: unknown) {\n applyQueryEffect(this as Component, propertyKey, selector);\n });\n };\n}\n\n/**\n * Like `@Query`, but returns every matching element. Each access re-runs\n * the lookup, so the list reflects the current DOM on every read.\n *\n * @param selector - A CSS selector scoped to the component's root.\n *\n * @example\n * @Register('my-tabs')\n * class MyTabs extends Component {\n * @QueryAll('li') items!: NodeListOf<HTMLLIElement>;\n *\n * logItems() {\n * for (const item of this.items) console.log(item.textContent);\n * }\n *\n * render() {\n * return html`\n * <ul>\n * <li>Overview</li>\n * <li>Activity</li>\n * <li>Settings</li>\n * </ul>\n * `;\n * }\n * }\n */\nexport function QueryAll(selector: string) {\n return function (_target: undefined, context: ClassFieldDecoratorContext) {\n const propertyKey = String(context.name);\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n addDecoratorEffect(meta, (instance) => {\n applyQueryAllEffect(instance as unknown as Component, propertyKey, selector);\n });\n\n context.addInitializer(function (this: unknown) {\n applyQueryAllEffect(this as Component, propertyKey, selector);\n });\n };\n}\n\n/**\n * Installs a live `query(selector)` getter on an instance for a `@Query`\n * field, so each read reflects the current rendered DOM.\n *\n * @internal\n */\nfunction applyQueryEffect(instance: Component, propertyKey: string, selector: string): void {\n Object.defineProperty(instance, propertyKey, {\n get() {\n return instance.query(selector);\n },\n enumerable: true,\n configurable: true\n });\n}\n\n/**\n * Installs a live `queryAll(selector)` getter on an instance for a\n * `@QueryAll` field.\n *\n * @internal\n */\nfunction applyQueryAllEffect(instance: Component, propertyKey: string, selector: string): void {\n Object.defineProperty(instance, propertyKey, {\n get() {\n return instance.queryAll(selector);\n },\n enumerable: true,\n configurable: true\n });\n}\n\n// ==========================================\n// @Slot\n// ==========================================\n\n/**\n * Exposes a `<slot>` element from the shadow root as a field, so you can\n * inspect projected children or call slot APIs like `assignedElements()`.\n *\n * Call with no argument to grab the default slot, or pass a name for a\n * named slot.\n *\n * @param name - Optional named slot to target; omit for the default slot.\n *\n * @example\n * @Register('my-card')\n * class MyCard extends ShadowComponent {\n * @Slot('header') headerSlot!: HTMLSlotElement | null;\n *\n * connectedCallback() {\n * super.connectedCallback();\n * console.log('header children:', this.headerSlot?.assignedElements());\n * }\n *\n * render() {\n * return html`\n * <section>\n * <header><slot name=\"header\"></slot></header>\n * <slot></slot>\n * </section>\n * `;\n * }\n * }\n */\nexport function Slot(name?: string) {\n return function (_target: undefined, context: ClassFieldDecoratorContext) {\n const propertyKey = String(context.name);\n const slotSelector = name ? `slot[name=\"${name}\"]` : 'slot:not([name])';\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n addDecoratorEffect(meta, (instance) => {\n applySlotEffect(instance as unknown as Component, propertyKey, slotSelector);\n });\n\n context.addInitializer(function (this: unknown) {\n applySlotEffect(this as Component, propertyKey, slotSelector);\n });\n };\n}\n\n/**\n * Installs a getter that resolves to the requested `<slot>` element inside\n * the component's shadow root for a `@Slot` field.\n *\n * @internal\n */\nfunction applySlotEffect(instance: Component, propertyKey: string, slotSelector: string): void {\n Object.defineProperty(instance, propertyKey, {\n get() {\n const shadowRoot = (instance as any)._shadowDOM || (instance as any).shadowRoot;\n return shadowRoot?.querySelector(slotSelector) ?? null;\n },\n enumerable: true,\n configurable: true\n });\n}\n\n// ==========================================\n// @Listen\n// ==========================================\n\ninterface ListenOptions {\n target?: 'self' | 'window' | 'document' | string;\n delegate?: string;\n capture?: boolean;\n passive?: boolean;\n once?: boolean;\n}\n\n/**\n * Binds a method as an event listener. By default the listener attaches to\n * the component itself, and is added on connect and removed on disconnect.\n *\n * Pass `target` to listen on `'window'`, `'document'`, or any CSS selector\n * scoped to the component's own subtree; pass `delegate` to catch events that\n * bubble up from a child matching a selector; `capture`, `passive`, and `once`\n * forward to the underlying `addEventListener` call.\n *\n * @param event - The event name to listen for (e.g. `'click'`, `'keydown'`).\n * @param options - Optional `{ target, delegate, capture, passive, once }`.\n *\n * @example\n * @Register('my-button')\n * class MyButton extends Component {\n * @State() pressed = 0;\n *\n * @Listen('click')\n * handleClick(event: MouseEvent) {\n * this.pressed++;\n * }\n *\n * render() {\n * return html`<button>Pressed ${this.pressed} times</button>`;\n * }\n * }\n */\nexport function Listen(event: string, options?: ListenOptions) {\n return function <T extends (...args: any[]) => any>(\n _target: T,\n context: ClassMethodDecoratorContext\n ): void {\n const methodName = String(context.name);\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, LISTEN_HANDLERS)) {\n const inherited = meta[LISTEN_HANDLERS] as unknown[] | undefined;\n meta[LISTEN_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n (meta[LISTEN_HANDLERS] as unknown[]).push({\n event,\n methodName,\n options\n });\n };\n}\n\n// ==========================================\n// @Computed\n// ==========================================\n\n/**\n * Turns a getter into a cached derived value. The result is computed once,\n * reused on every read, and invalidated automatically whenever any of the\n * listed reactive dependencies change.\n *\n * List every `@State`, `@Attribute`, or `@Property` the getter reads — those\n * names drive cache invalidation, so anything missing will leave you with a\n * stale result.\n *\n * @param dependencies - Names of reactive fields the getter depends on.\n *\n * @example\n * @Register('cart-summary')\n * class CartSummary extends Component {\n * @State() price = 10;\n * @State() quantity = 3;\n *\n * @Computed('price', 'quantity')\n * get total() {\n * return this.price * this.quantity;\n * }\n *\n * render() {\n * return html`<p>Total: $${this.total}</p>`;\n * }\n * }\n */\nexport function Computed(...dependencies: string[]) {\n return function <T>(\n _target: T,\n context: ClassGetterDecoratorContext\n ): T {\n const propertyKey = String(context.name);\n const cacheKey = Symbol(`__pandora_computed_cache_${propertyKey}`);\n const validKey = Symbol(`__pandora_computed_valid_${propertyKey}`);\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n // We piggy-back on `@Watch`: each dependency gets a watcher that calls\n // the per-instance invalidation method, so cache flushing rides the same\n // change-propagation path as user-written watchers.\n for (const dep of dependencies) {\n if (!Object.hasOwn(meta, WATCH_HANDLERS)) {\n const inherited = meta[WATCH_HANDLERS] as WatchEntry[] | undefined;\n meta[WATCH_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n (meta[WATCH_HANDLERS] as WatchEntry[]).push({\n property: dep,\n methodName: `__invalidate_${propertyKey}`\n });\n }\n\n // Snapshot the getter at decoration time. During evolve/lazy replay the\n // old prototype's getter is long gone, so we need a direct reference to\n // the getter the source class declared here.\n const originalGetter = _target as unknown as () => unknown;\n\n addDecoratorEffect(meta, (instance) => {\n applyComputedEffect(instance as DecoratorInstance, propertyKey, cacheKey, validKey, originalGetter);\n });\n\n context.addInitializer(function (this: unknown) {\n applyComputedEffect(this as DecoratorInstance, propertyKey, cacheKey, validKey, originalGetter);\n });\n\n return _target;\n };\n}\n\n/**\n * Installs the caching getter and `__invalidate_*` companion method for a\n * `@Computed` field on an instance. Runs once per instance and again on\n * evolve/lazy replay so the cache clears on swap.\n *\n * @internal\n */\nfunction applyComputedEffect(\n instance: DecoratorInstance,\n propertyKey: string,\n cacheKey: symbol,\n validKey: symbol,\n originalGetter: () => unknown\n): void {\n // `@Watch` entries for each dependency call into this invalidator; flipping\n // the validity flag lets the next read recompute on demand.\n (instance as any)[`__invalidate_${propertyKey}`] = () => {\n instance[validKey] = false;\n };\n\n Object.defineProperty(instance, propertyKey, {\n get() {\n if (!instance[validKey]) {\n instance[cacheKey] = originalGetter.call(instance);\n instance[validKey] = true;\n }\n\n return instance[cacheKey];\n },\n enumerable: true,\n configurable: true\n });\n}\n\n// ==========================================\n// @ClassList\n// ==========================================\n\ntype ClassListMap = Record<string, string | ((instance: any) => boolean)>;\n\n/**\n * Declaratively toggles classes on the host element based on reactive state.\n * Map a class name to a reactive field name (truthy → class on, falsy →\n * class off) or to a predicate function that receives the instance and\n * returns a boolean.\n *\n * Classes are applied on connect and updated whenever the underlying\n * reactive fields change, so you never have to reach into `classList`\n * by hand.\n *\n * @param map - Object mapping class names to reactive fields or predicates.\n *\n * @example\n * @Register('my-toggle')\n * @ClassList({\n * 'is-active': 'active',\n * 'is-empty': (self: MyToggle) => self.label.length === 0,\n * })\n * class MyToggle extends Component {\n * @State() active = false;\n * @Attribute() label = '';\n *\n * render() {\n * return html`\n * <button @click=${() => this.active = !this.active}>${this.label}</button>\n * `;\n * }\n * }\n */\nexport function ClassList(map: ClassListMap) {\n return function <T extends ComponentConstructor>(constructor: T, _context: ClassDecoratorContext): T {\n const meta = _context.metadata as Record<symbol, unknown>;\n\n const propertyMappings: Array<{ className: string; propertyName: string }> = [];\n const functionMappings: Array<{ className: string; conditionFn: (instance: any) => boolean }> = [];\n\n for (const [className, condition] of Object.entries(map)) {\n if (typeof condition === 'string') {\n propertyMappings.push({ className, propertyName: condition });\n\n // String conditions ride on `@Watch`: each field gets a synthetic\n // watcher whose generated method name re-toggles the class from the\n // current value, keeping classList in sync per-field with no diffing.\n if (!Object.hasOwn(meta, WATCH_HANDLERS)) {\n const inherited = meta[WATCH_HANDLERS] as WatchEntry[] | undefined;\n meta[WATCH_HANDLERS] = inherited ? [...inherited] : [];\n }\n const methodName = `__classlist_${className}_${condition}`;\n (meta[WATCH_HANDLERS] as WatchEntry[]).push({ property: condition, methodName });\n\n (constructor.prototype as any)[methodName] = function (this: Component) {\n this.classList.toggle(className, !!(this as any)[condition]);\n };\n } else {\n functionMappings.push({ className, conditionFn: condition });\n }\n }\n\n // Predicate conditions can read from anywhere, so we hook `didChange` on\n // the prototype — any reactive update re-evaluates every predicate. Less\n // precise than per-field watchers, but it's the only way to catch\n // dependencies we can't statically enumerate.\n if (functionMappings.length > 0) {\n const originalDidChange = constructor.prototype.didChange;\n constructor.prototype.didChange = function (this: Component, prop: string, oldVal: unknown, newVal: unknown, source?: string) {\n originalDidChange?.call(this, prop, oldVal, newVal, source);\n\n for (const { className, conditionFn } of functionMappings) {\n this.classList.toggle(className, conditionFn(this));\n }\n };\n }\n\n const originalConnected = constructor.prototype.connectedCallback;\n constructor.prototype.connectedCallback = async function (this: Component) {\n await originalConnected?.call(this);\n\n for (const { className, propertyName } of propertyMappings) {\n this.classList.toggle(className, !!(this as any)[propertyName]);\n }\n\n for (const { className, conditionFn } of functionMappings) {\n this.classList.toggle(className, conditionFn(this));\n }\n };\n\n return constructor;\n };\n}\n\n// ==========================================\n// @Emitter\n// ==========================================\n\n/**\n * Installs a function on the component that dispatches a bubbling custom\n * event with the given name. Call the field like a method, passing any\n * payload you want to hand up to parents through `event.detail`.\n *\n * The event bubbles and is composed, so parent components and listeners\n * outside a shadow root can subscribe with a plain `addEventListener`.\n *\n * @param eventName - The custom event name to dispatch.\n *\n * @example\n * @Register('my-button')\n * class MyButton extends Component {\n * @Emitter('button-pressed') pressed!: (detail?: { at: number }) => void;\n *\n * @Listen('click')\n * onClick() {\n * this.pressed({ at: Date.now() });\n * }\n *\n * render() {\n * return html`<button>Press me</button>`;\n * }\n * }\n *\n * // In a parent:\n * // el.addEventListener('button-pressed', (e) => console.log(e.detail.at));\n */\nexport function Emitter(eventName: string) {\n return function (_target: undefined, context: ClassFieldDecoratorContext) {\n const propertyKey = String(context.name);\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n addDecoratorEffect(meta, (instance) => {\n applyEmitterEffect(instance as unknown as Component, propertyKey, eventName);\n });\n\n context.addInitializer(function (this: unknown) {\n applyEmitterEffect(this as Component, propertyKey, eventName);\n });\n };\n}\n\n/**\n * Installs the dispatching function on an instance for an `@Emitter` field.\n * The value is non-writable so user code can't accidentally clobber the\n * emitter with a plain assignment.\n *\n * @internal\n */\nfunction applyEmitterEffect(instance: Component, propertyKey: string, eventName: string): void {\n Object.defineProperty(instance, propertyKey, {\n value: (detail?: unknown) => {\n return instance.emit(eventName, detail);\n },\n writable: false,\n enumerable: true,\n configurable: true\n });\n}\n",
11
- "import Registry from './Registry';\n\n/**\n * Typed handle to a single Registry state key.\n *\n * The object returned by `createState` exposes the small surface you need to\n * work with a global value: read it, write it, subscribe to changes, check\n * whether it exists, and delete it. Everything is strongly typed against the\n * generic parameter you pass to `createState`.\n */\nexport interface TypedState<T> {\n /** The underlying Registry state key. */\n readonly key: string;\n\n /** Read the current value. Returns `undefined` if the key was never set or has been deleted. */\n get(): T | undefined;\n\n /** Write a new value. The type is checked against the state's generic parameter. */\n set(value: T): void;\n\n /**\n * Subscribe to changes. The callback runs every time the value is updated,\n * receiving the new and previous values. Returns an unsubscribe function.\n */\n subscribe(callback: (newValue: T | undefined, oldValue: T | undefined) => void): () => void;\n\n /** Return `true` if the key currently has a value in the Registry. */\n has(): boolean;\n\n /** Remove the key from the Registry. Subsequent `get()` calls return `undefined`. */\n delete(): void;\n}\n\n/**\n * Create a typed wrapper around a Registry global state key.\n *\n * Registry state is string-keyed and untyped by default. `createState` gives\n * you a small typed handle so reads, writes, and subscriptions are checked at\n * compile time. If you pass a `defaultValue`, it is written to the Registry\n * immediately when the key does not yet exist, which makes it safe to call\n * during module initialization.\n *\n * @param key - The Registry state key to wrap.\n * @param defaultValue - Optional value to seed the key with if it is not already set.\n * @returns A typed handle with `get`, `set`, `subscribe`, `has`, and `delete`.\n *\n * @example\n * type AppState = { theme: 'light' | 'dark'; user: { id: string } | null };\n *\n * const state = {\n * theme: createState<AppState['theme']>('app.theme', 'light'),\n * user: createState<AppState['user']>('app.user', null),\n * };\n *\n * state.theme.set('dark');\n * const unsubscribe = state.user.subscribe(user => console.log(user));\n */\nexport function createState<T>(key: string, defaultValue?: T): TypedState<T> {\n if (defaultValue !== undefined && !Registry.hasState(key)) {\n Registry.setState(key, defaultValue);\n }\n\n return {\n key,\n get(): T | undefined {\n return Registry.getState(key) as T | undefined;\n },\n set(value: T): void {\n Registry.setState(key, value);\n },\n subscribe(callback: (newValue: T | undefined, oldValue: T | undefined) => void): () => void {\n return Registry.subscribe(key, callback as (newValue: unknown, oldValue: unknown) => void);\n },\n has(): boolean {\n return Registry.hasState(key);\n },\n delete(): void {\n Registry.deleteState(key);\n }\n };\n}\n",
12
- "/**\n * Test helpers for Pandora components.\n *\n * These utilities are re-exported as the `testing` namespace from the main\n * entry (`import { testing } from '@aegis-framework/pandora'`). They smooth\n * over the async nature of component rendering so your specs can assert\n * against stable DOM: wait for microtask renders to flush, mount a tag into\n * the document, and reset global Registry state between cases.\n */\n\nimport Component from './Component';\nimport Registry from './Registry';\n\n/**\n * Flush pending microtask renders.\n *\n * Pandora batches state changes into microtask-scheduled renders. Call\n * `flush` after mutating state so the DOM reflects those changes before your\n * assertions run. Two passes are awaited to cover renders that queue further\n * microtasks during the first pass.\n *\n * @returns A promise that resolves once queued renders have settled.\n *\n * @example\n * const el = await mount('my-counter');\n * el.count = 3;\n * await flush();\n * expect(el.textContent).toContain('3');\n */\nexport async function flush(): Promise<void> {\n await new Promise<void>(resolve => queueMicrotask(resolve));\n\n await new Promise<void>(resolve => queueMicrotask(resolve));\n}\n\n/**\n * Wait until a component reports that it is ready.\n *\n * Resolves immediately if `element.isReady` is already `true`. Otherwise,\n * polls on `requestAnimationFrame` and rejects if the component does not\n * finish its first render within `timeout` milliseconds.\n *\n * @param element - The component element to observe.\n * @param timeout - How long to wait before rejecting, in milliseconds. Defaults to 5000.\n * @returns A promise that resolves once the component is ready.\n *\n * @example\n * const el = document.querySelector('user-avatar')!;\n * await whenReady(el);\n */\nexport function whenReady(element: Element, timeout: number = 5000): Promise<void> {\n const comp = element as Component;\n if (comp.isReady) {\n return Promise.resolve();\n }\n\n return new Promise((resolve, reject) => {\n const timer = setTimeout(() => {\n reject(new Error(`Component <${element.tagName.toLowerCase()}> did not become ready within ${timeout}ms`));\n }, timeout);\n\n const check = () => {\n if (comp.isReady) {\n clearTimeout(timer);\n resolve();\n } else {\n requestAnimationFrame(check);\n }\n };\n\n requestAnimationFrame(check);\n });\n}\n\n/**\n * Reset Registry state between tests.\n *\n * Clears every state key, subscription, and middleware so each spec starts\n * from a clean slate. Component class registrations are not touched. Call\n * this in a `beforeEach` to isolate tests from one another.\n *\n * @example\n * beforeEach(() => {\n * resetRegistry();\n * });\n */\nexport function resetRegistry(): void {\n Registry.clearState();\n Registry.clearSubscriptions();\n Registry.clearMiddleware();\n}\n\n/**\n * Create a component, append it to the DOM, and wait for it to be ready.\n *\n * Wraps the tag in a throwaway container so that attributes and children\n * are parsed in a single pass. Defaults to mounting into `document.body`\n * when no container is provided.\n *\n * @param tagName - The custom element tag to mount (for example `'my-counter'`).\n * @param container - The parent node to append into. Defaults to `document.body`.\n * @param innerHTML - Optional markup to place inside the element's opening and closing tags.\n * @returns The mounted component once it has finished its first render.\n *\n * @example\n * const el = await mount('my-greeting', document.body, '<span slot=\"name\">Ada</span>');\n * expect(el.textContent).toContain('Ada');\n */\nexport async function mount(tagName: string, container?: Element, innerHTML?: string): Promise<Component> {\n const root = container ?? document.body;\n const wrapper = document.createElement('div');\n\n wrapper.innerHTML = `<${tagName}>${innerHTML ?? ''}</${tagName}>`;\n\n const element = wrapper.firstElementChild as Component;\n\n root.appendChild(element);\n await whenReady(element);\n\n return element;\n}\n",
13
- "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nexport const PartType = {\n ATTRIBUTE: 1,\n CHILD: 2,\n PROPERTY: 3,\n BOOLEAN_ATTRIBUTE: 4,\n EVENT: 5,\n ELEMENT: 6,\n};\n/**\n * Creates a user-facing directive function from a Directive class. This\n * function has the same parameters as the directive's render() method.\n */\nexport const directive = (c) => (...values) => ({\n // This property needs to remain unminified.\n ['_$litDirective$']: c,\n values,\n});\n/**\n * Base class for creating custom directives. Users should extend this class,\n * implement `render` and/or `update`, and then pass their subclass to\n * `directive`.\n */\nexport class Directive {\n constructor(_partInfo) { }\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n /** @internal */\n _$initialize(part, parent, attributeIndex) {\n this.__part = part;\n this._$parent = parent;\n this.__attributeIndex = attributeIndex;\n }\n /** @internal */\n _$resolve(part, props) {\n return this.update(part, props);\n }\n update(_part, props) {\n return this.render(...props);\n }\n}\n//# sourceMappingURL=directive.js.map",
14
- "/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { _$LH, } from './lit-html.js';\nconst { _ChildPart: ChildPart } = _$LH;\nconst ENABLE_SHADYDOM_NOPATCH = true;\nconst wrap = ENABLE_SHADYDOM_NOPATCH &&\n window.ShadyDOM?.inUse &&\n window.ShadyDOM?.noPatch === true\n ? window.ShadyDOM.wrap\n : (node) => node;\n/**\n * Tests if a value is a primitive value.\n *\n * See https://tc39.github.io/ecma262/#sec-typeof-operator\n */\nexport const isPrimitive = (value) => value === null || (typeof value != 'object' && typeof value != 'function');\nexport const TemplateResultType = {\n HTML: 1,\n SVG: 2,\n MATHML: 3,\n};\n/**\n * Tests if a value is a TemplateResult or a CompiledTemplateResult.\n */\nexport const isTemplateResult = (value, type) => type === undefined\n ? // This property needs to remain unminified.\n value?.['_$litType$'] !== undefined\n : value?.['_$litType$'] === type;\n/**\n * Tests if a value is a CompiledTemplateResult.\n */\nexport const isCompiledTemplateResult = (value) => {\n return value?.['_$litType$']?.h != null;\n};\n/**\n * Tests if a value is a DirectiveResult.\n */\nexport const isDirectiveResult = (value) => \n// This property needs to remain unminified.\nvalue?.['_$litDirective$'] !== undefined;\n/**\n * Retrieves the Directive class for a DirectiveResult\n */\nexport const getDirectiveClass = (value) => \n// This property needs to remain unminified.\nvalue?.['_$litDirective$'];\n/**\n * Tests whether a part has only a single-expression with no strings to\n * interpolate between.\n *\n * Only AttributePart and PropertyPart can have multiple expressions.\n * Multi-expression parts have a `strings` property and single-expression\n * parts do not.\n */\nexport const isSingleExpression = (part) => part.strings === undefined;\nconst createMarker = () => document.createComment('');\n/**\n * Inserts a ChildPart into the given container ChildPart's DOM, either at the\n * end of the container ChildPart, or before the optional `refPart`.\n *\n * This does not add the part to the containerPart's committed value. That must\n * be done by callers.\n *\n * @param containerPart Part within which to add the new ChildPart\n * @param refPart Part before which to add the new ChildPart; when omitted the\n * part added to the end of the `containerPart`\n * @param part Part to insert, or undefined to create a new part\n */\nexport const insertPart = (containerPart, refPart, part) => {\n const container = wrap(containerPart._$startNode).parentNode;\n const refNode = refPart === undefined ? containerPart._$endNode : refPart._$startNode;\n if (part === undefined) {\n const startNode = wrap(container).insertBefore(createMarker(), refNode);\n const endNode = wrap(container).insertBefore(createMarker(), refNode);\n part = new ChildPart(startNode, endNode, containerPart, containerPart.options);\n }\n else {\n const endNode = wrap(part._$endNode).nextSibling;\n const oldParent = part._$parent;\n const parentChanged = oldParent !== containerPart;\n if (parentChanged) {\n part._$reparentDisconnectables?.(containerPart);\n // Note that although `_$reparentDisconnectables` updates the part's\n // `_$parent` reference after unlinking from its current parent, that\n // method only exists if Disconnectables are present, so we need to\n // unconditionally set it here\n part._$parent = containerPart;\n // Since the _$isConnected getter is somewhat costly, only\n // read it once we know the subtree has directives that need\n // to be notified\n let newConnectionState;\n if (part._$notifyConnectionChanged !== undefined &&\n (newConnectionState = containerPart._$isConnected) !==\n oldParent._$isConnected) {\n part._$notifyConnectionChanged(newConnectionState);\n }\n }\n if (endNode !== refNode || parentChanged) {\n let start = part._$startNode;\n while (start !== endNode) {\n const n = wrap(start).nextSibling;\n wrap(container).insertBefore(start, refNode);\n start = n;\n }\n }\n }\n return part;\n};\n/**\n * Sets the value of a Part.\n *\n * Note that this should only be used to set/update the value of user-created\n * parts (i.e. those created using `insertPart`); it should not be used\n * by directives to set the value of the directive's container part. Directives\n * should return a value from `update`/`render` to update their part state.\n *\n * For directives that require setting their part value asynchronously, they\n * should extend `AsyncDirective` and call `this.setValue()`.\n *\n * @param part Part to set\n * @param value Value to set\n * @param index For `AttributePart`s, the index to set\n * @param directiveParent Used internally; should not be set by user\n */\nexport const setChildPartValue = (part, value, directiveParent = part) => {\n part._$setValue(value, directiveParent);\n return part;\n};\n// A sentinel value that can never appear as a part value except when set by\n// live(). Used to force a dirty-check to fail and cause a re-render.\nconst RESET_VALUE = {};\n/**\n * Sets the committed value of a ChildPart directly without triggering the\n * commit stage of the part.\n *\n * This is useful in cases where a directive needs to update the part such\n * that the next update detects a value change or not. When value is omitted,\n * the next update will be guaranteed to be detected as a change.\n *\n * @param part\n * @param value\n */\nexport const setCommittedValue = (part, value = RESET_VALUE) => (part._$committedValue = value);\n/**\n * Returns the committed value of a ChildPart.\n *\n * The committed value is used for change detection and efficient updates of\n * the part. It can differ from the value set by the template or directive in\n * cases where the template value is transformed before being committed.\n *\n * - `TemplateResult`s are committed as a `TemplateInstance`\n * - Iterables are committed as `Array<ChildPart>`\n * - All other types are committed as the template value or value returned or\n * set by a directive.\n *\n * @param part\n */\nexport const getCommittedValue = (part) => part._$committedValue;\n/**\n * Removes a ChildPart from the DOM, including any of its content and markers.\n *\n * Note: The only difference between this and clearPart() is that this also\n * removes the part's start node. This means that the ChildPart must own its\n * start node, ie it must be a marker node specifically for this part and not an\n * anchor from surrounding content.\n *\n * @param part The Part to remove\n */\nexport const removePart = (part) => {\n part._$clear();\n part._$startNode.remove();\n};\nexport const clearPart = (part) => {\n part._$clear();\n};\n//# sourceMappingURL=directive-helpers.js.map",
15
- "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { isSingleExpression } from './directive-helpers.js';\nimport { Directive, PartType } from './directive.js';\nexport * from './directive.js';\nconst DEV_MODE = true;\n/**\n * Recursively walks down the tree of Parts/TemplateInstances/Directives to set\n * the connected state of directives and run `disconnected`/ `reconnected`\n * callbacks.\n *\n * @return True if there were children to disconnect; false otherwise\n */\nconst notifyChildrenConnectedChanged = (parent, isConnected) => {\n const children = parent._$disconnectableChildren;\n if (children === undefined) {\n return false;\n }\n for (const obj of children) {\n // The existence of `_$notifyDirectiveConnectionChanged` is used as a \"brand\" to\n // disambiguate AsyncDirectives from other DisconnectableChildren\n // (as opposed to using an instanceof check to know when to call it); the\n // redundancy of \"Directive\" in the API name is to avoid conflicting with\n // `_$notifyConnectionChanged`, which exists `ChildParts` which are also in\n // this list\n // Disconnect Directive (and any nested directives contained within)\n // This property needs to remain unminified.\n obj['_$notifyDirectiveConnectionChanged']?.(isConnected, false);\n // Disconnect Part/TemplateInstance\n notifyChildrenConnectedChanged(obj, isConnected);\n }\n return true;\n};\n/**\n * Removes the given child from its parent list of disconnectable children, and\n * if the parent list becomes empty as a result, removes the parent from its\n * parent, and so forth up the tree when that causes subsequent parent lists to\n * become empty.\n */\nconst removeDisconnectableFromParent = (obj) => {\n let parent, children;\n do {\n if ((parent = obj._$parent) === undefined) {\n break;\n }\n children = parent._$disconnectableChildren;\n children.delete(obj);\n obj = parent;\n } while (children?.size === 0);\n};\nconst addDisconnectableToParent = (obj) => {\n // Climb the parent tree, creating a sparse tree of children needing\n // disconnection\n for (let parent; (parent = obj._$parent); obj = parent) {\n let children = parent._$disconnectableChildren;\n if (children === undefined) {\n parent._$disconnectableChildren = children = new Set();\n }\n else if (children.has(obj)) {\n // Once we've reached a parent that already contains this child, we\n // can short-circuit\n break;\n }\n children.add(obj);\n installDisconnectAPI(parent);\n }\n};\n/**\n * Changes the parent reference of the ChildPart, and updates the sparse tree of\n * Disconnectable children accordingly.\n *\n * Note, this method will be patched onto ChildPart instances and called from\n * the core code when parts are moved between different parents.\n */\nfunction reparentDisconnectables(newParent) {\n if (this._$disconnectableChildren !== undefined) {\n removeDisconnectableFromParent(this);\n this._$parent = newParent;\n addDisconnectableToParent(this);\n }\n else {\n this._$parent = newParent;\n }\n}\n/**\n * Sets the connected state on any directives contained within the committed\n * value of this part (i.e. within a TemplateInstance or iterable of\n * ChildParts) and runs their `disconnected`/`reconnected`s, as well as within\n * any directives stored on the ChildPart (when `valueOnly` is false).\n *\n * `isClearingValue` should be passed as `true` on a top-level part that is\n * clearing itself, and not as a result of recursively disconnecting directives\n * as part of a `clear` operation higher up the tree. This both ensures that any\n * directive on this ChildPart that produced a value that caused the clear\n * operation is not disconnected, and also serves as a performance optimization\n * to avoid needless bookkeeping when a subtree is going away; when clearing a\n * subtree, only the top-most part need to remove itself from the parent.\n *\n * `fromPartIndex` is passed only in the case of a partial `_clear` running as a\n * result of truncating an iterable.\n *\n * Note, this method will be patched onto ChildPart instances and called from the\n * core code when parts are cleared or the connection state is changed by the\n * user.\n */\nfunction notifyChildPartConnectedChanged(isConnected, isClearingValue = false, fromPartIndex = 0) {\n const value = this._$committedValue;\n const children = this._$disconnectableChildren;\n if (children === undefined || children.size === 0) {\n return;\n }\n if (isClearingValue) {\n if (Array.isArray(value)) {\n // Iterable case: Any ChildParts created by the iterable should be\n // disconnected and removed from this ChildPart's disconnectable\n // children (starting at `fromPartIndex` in the case of truncation)\n for (let i = fromPartIndex; i < value.length; i++) {\n notifyChildrenConnectedChanged(value[i], false);\n removeDisconnectableFromParent(value[i]);\n }\n }\n else if (value != null) {\n // TemplateInstance case: If the value has disconnectable children (will\n // only be in the case that it is a TemplateInstance), we disconnect it\n // and remove it from this ChildPart's disconnectable children\n notifyChildrenConnectedChanged(value, false);\n removeDisconnectableFromParent(value);\n }\n }\n else {\n notifyChildrenConnectedChanged(this, isConnected);\n }\n}\n/**\n * Patches disconnection API onto ChildParts.\n */\nconst installDisconnectAPI = (obj) => {\n if (obj.type == PartType.CHILD) {\n obj._$notifyConnectionChanged ??=\n notifyChildPartConnectedChanged;\n obj._$reparentDisconnectables ??= reparentDisconnectables;\n }\n};\n/**\n * An abstract `Directive` base class whose `disconnected` method will be\n * called when the part containing the directive is cleared as a result of\n * re-rendering, or when the user calls `part.setConnected(false)` on\n * a part that was previously rendered containing the directive (as happens\n * when e.g. a LitElement disconnects from the DOM).\n *\n * If `part.setConnected(true)` is subsequently called on a\n * containing part, the directive's `reconnected` method will be called prior\n * to its next `update`/`render` callbacks. When implementing `disconnected`,\n * `reconnected` should also be implemented to be compatible with reconnection.\n *\n * Note that updates may occur while the directive is disconnected. As such,\n * directives should generally check the `this.isConnected` flag during\n * render/update to determine whether it is safe to subscribe to resources\n * that may prevent garbage collection.\n */\nexport class AsyncDirective extends Directive {\n constructor() {\n super(...arguments);\n // @internal\n this._$disconnectableChildren = undefined;\n }\n /**\n * Initialize the part with internal fields\n * @param part\n * @param parent\n * @param attributeIndex\n */\n _$initialize(part, parent, attributeIndex) {\n super._$initialize(part, parent, attributeIndex);\n addDisconnectableToParent(this);\n this.isConnected = part._$isConnected;\n }\n // This property needs to remain unminified.\n /**\n * Called from the core code when a directive is going away from a part (in\n * which case `shouldRemoveFromParent` should be true), and from the\n * `setChildrenConnected` helper function when recursively changing the\n * connection state of a tree (in which case `shouldRemoveFromParent` should\n * be false).\n *\n * @param isConnected\n * @param isClearingDirective - True when the directive itself is being\n * removed; false when the tree is being disconnected\n * @internal\n */\n ['_$notifyDirectiveConnectionChanged'](isConnected, isClearingDirective = true) {\n if (isConnected !== this.isConnected) {\n this.isConnected = isConnected;\n if (isConnected) {\n this.reconnected?.();\n }\n else {\n this.disconnected?.();\n }\n }\n if (isClearingDirective) {\n notifyChildrenConnectedChanged(this, isConnected);\n removeDisconnectableFromParent(this);\n }\n }\n /**\n * Sets the value of the directive's Part outside the normal `update`/`render`\n * lifecycle of a directive.\n *\n * This method should not be called synchronously from a directive's `update`\n * or `render`.\n *\n * @param directive The directive to update\n * @param value The value to set\n */\n setValue(value) {\n if (isSingleExpression(this.__part)) {\n this.__part._$setValue(value, this);\n }\n else {\n // this.__attributeIndex will be defined in this case, but\n // assert it in dev mode\n if (DEV_MODE && this.__attributeIndex === undefined) {\n throw new Error(`Expected this.__attributeIndex to be a number`);\n }\n const newValues = [...this.__part._$committedValue];\n newValues[this.__attributeIndex] = value;\n this.__part._$setValue(newValues, this, 0);\n }\n }\n /**\n * User callbacks for implementing logic to release any resources/subscriptions\n * that may have been retained by this directive. Since directives may also be\n * re-connected, `reconnected` should also be implemented to restore the\n * working state of the directive prior to the next render.\n */\n disconnected() { }\n reconnected() { }\n}\n//# sourceMappingURL=async-directive.js.map",
16
- "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n// Note, this module is not included in package exports so that it's private to\n// our first-party directives. If it ends up being useful, we can open it up and\n// export it.\n/**\n * Helper to iterate an AsyncIterable in its own closure.\n * @param iterable The iterable to iterate\n * @param callback The callback to call for each value. If the callback returns\n * `false`, the loop will be broken.\n */\nexport const forAwaitOf = async (iterable, callback) => {\n for await (const v of iterable) {\n if ((await callback(v)) === false) {\n return;\n }\n }\n};\n/**\n * Holds a reference to an instance that can be disconnected and reconnected,\n * so that a closure over the ref (e.g. in a then function to a promise) does\n * not strongly hold a ref to the instance. Approximates a WeakRef but must\n * be manually connected & disconnected to the backing instance.\n */\nexport class PseudoWeakRef {\n constructor(ref) {\n this._ref = ref;\n }\n /**\n * Disassociates the ref with the backing instance.\n */\n disconnect() {\n this._ref = undefined;\n }\n /**\n * Reassociates the ref with the backing instance.\n */\n reconnect(ref) {\n this._ref = ref;\n }\n /**\n * Retrieves the backing instance (will be undefined when disconnected)\n */\n deref() {\n return this._ref;\n }\n}\n/**\n * A helper to pause and resume waiting on a condition in an async function\n */\nexport class Pauser {\n constructor() {\n this._promise = undefined;\n this._resolve = undefined;\n }\n /**\n * When paused, returns a promise to be awaited; when unpaused, returns\n * undefined. Note that in the microtask between the pauser being resumed\n * an await of this promise resolving, the pauser could be paused again,\n * hence callers should check the promise in a loop when awaiting.\n * @returns A promise to be awaited when paused or undefined\n */\n get() {\n return this._promise;\n }\n /**\n * Creates a promise to be awaited\n */\n pause() {\n this._promise ??= new Promise((resolve) => (this._resolve = resolve));\n }\n /**\n * Resolves the promise which may be awaited\n */\n resume() {\n this._resolve?.();\n this._promise = this._resolve = undefined;\n }\n}\n//# sourceMappingURL=private-async-helpers.js.map",
17
- "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { noChange } from '../lit-html.js';\nimport { AsyncDirective, directive, } from '../async-directive.js';\nimport { Pauser, PseudoWeakRef, forAwaitOf } from './private-async-helpers.js';\nexport class AsyncReplaceDirective extends AsyncDirective {\n constructor() {\n super(...arguments);\n this.__weakThis = new PseudoWeakRef(this);\n this.__pauser = new Pauser();\n }\n // @ts-expect-error value not used, but we want a nice parameter for docs\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n render(value, _mapper) {\n return noChange;\n }\n update(_part, [value, mapper]) {\n // If our initial render occurs while disconnected, ensure that the pauser\n // and weakThis are in the disconnected state\n if (!this.isConnected) {\n this.disconnected();\n }\n // If we've already set up this particular iterable, we don't need\n // to do anything.\n if (value === this.__value) {\n return noChange;\n }\n this.__value = value;\n let i = 0;\n const { __weakThis: weakThis, __pauser: pauser } = this;\n // Note, the callback avoids closing over `this` so that the directive\n // can be gc'ed before the promise resolves; instead `this` is retrieved\n // from `weakThis`, which can break the hard reference in the closure when\n // the directive disconnects\n forAwaitOf(value, async (v) => {\n // The while loop here handles the case that the connection state\n // thrashes, causing the pauser to resume and then get re-paused\n while (pauser.get()) {\n await pauser.get();\n }\n // If the callback gets here and there is no `this`, it means that the\n // directive has been disconnected and garbage collected and we don't\n // need to do anything else\n const _this = weakThis.deref();\n if (_this !== undefined) {\n // Check to make sure that value is the still the current value of\n // the part, and if not bail because a new value owns this part\n if (_this.__value !== value) {\n return false;\n }\n // As a convenience, because functional-programming-style\n // transforms of iterables and async iterables requires a library,\n // we accept a mapper function. This is especially convenient for\n // rendering a template for each item.\n if (mapper !== undefined) {\n v = mapper(v, i);\n }\n _this.commitValue(v, i);\n i++;\n }\n return true;\n });\n return noChange;\n }\n // Override point for AsyncAppend to append rather than replace\n commitValue(value, _index) {\n this.setValue(value);\n }\n disconnected() {\n this.__weakThis.disconnect();\n this.__pauser.pause();\n }\n reconnected() {\n this.__weakThis.reconnect(this);\n this.__pauser.resume();\n }\n}\n/**\n * A directive that renders the items of an async iterable[1], replacing\n * previous values with new values, so that only one value is ever rendered\n * at a time. This directive may be used in any expression type.\n *\n * Async iterables are objects with a `[Symbol.asyncIterator]` method, which\n * returns an iterator who's `next()` method returns a Promise. When a new\n * value is available, the Promise resolves and the value is rendered to the\n * Part controlled by the directive. If another value other than this\n * directive has been set on the Part, the iterable will no longer be listened\n * to and new values won't be written to the Part.\n *\n * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\n *\n * @param value An async iterable\n * @param mapper An optional function that maps from (value, index) to another\n * value. Useful for generating templates for each item in the iterable.\n */\nexport const asyncReplace = directive(AsyncReplaceDirective);\n//# sourceMappingURL=async-replace.js.map",
18
- "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { directive, PartType, } from '../directive.js';\nimport { AsyncReplaceDirective } from './async-replace.js';\nimport { clearPart, insertPart, setChildPartValue, } from '../directive-helpers.js';\nclass AsyncAppendDirective extends AsyncReplaceDirective {\n // Override AsyncReplace to narrow the allowed part type to ChildPart only\n constructor(partInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('asyncAppend can only be used in child expressions');\n }\n }\n // Override AsyncReplace to save the part since we need to append into it\n update(part, params) {\n this.__childPart = part;\n return super.update(part, params);\n }\n // Override AsyncReplace to append rather than replace\n commitValue(value, index) {\n // When we get the first value, clear the part. This lets the\n // previous value display until we can replace it.\n if (index === 0) {\n clearPart(this.__childPart);\n }\n // Create and insert a new part and set its value to the next value\n const newPart = insertPart(this.__childPart);\n setChildPartValue(newPart, value);\n }\n}\n/**\n * A directive that renders the items of an async iterable[1], appending new\n * values after previous values, similar to the built-in support for iterables.\n * This directive is usable only in child expressions.\n *\n * Async iterables are objects with a [Symbol.asyncIterator] method, which\n * returns an iterator who's `next()` method returns a Promise. When a new\n * value is available, the Promise resolves and the value is appended to the\n * Part controlled by the directive. If another value other than this\n * directive has been set on the Part, the iterable will no longer be listened\n * to and new values won't be written to the Part.\n *\n * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\n *\n * @param value An async iterable\n * @param mapper An optional function that maps from (value, index) to another\n * value. Useful for generating templates for each item in the iterable.\n */\nexport const asyncAppend = directive(AsyncAppendDirective);\n//# sourceMappingURL=async-append.js.map",
19
- "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { render, nothing, } from '../lit-html.js';\nimport { directive, Directive, } from '../directive.js';\nimport { clearPart, getCommittedValue, insertPart, isCompiledTemplateResult, isTemplateResult, setCommittedValue, } from '../directive-helpers.js';\n/**\n * The template strings array contents are not compatible between the two\n * template result types as the compiled template contains a prepared string;\n * only use the returned template strings array as a cache key.\n */\nconst getStringsFromTemplateResult = (result) => isCompiledTemplateResult(result) ? result['_$litType$'].h : result.strings;\nclass CacheDirective extends Directive {\n constructor(partInfo) {\n super(partInfo);\n this._templateCache = new WeakMap();\n }\n render(v) {\n // Return an array of the value to induce lit-html to create a ChildPart\n // for the value that we can move into the cache.\n return [v];\n }\n update(containerPart, [v]) {\n const _valueKey = isTemplateResult(this._value)\n ? getStringsFromTemplateResult(this._value)\n : null;\n const vKey = isTemplateResult(v) ? getStringsFromTemplateResult(v) : null;\n // If the previous value is a TemplateResult and the new value is not,\n // or is a different Template as the previous value, move the child part\n // into the cache.\n if (_valueKey !== null && (vKey === null || _valueKey !== vKey)) {\n // This is always an array because we return [v] in render()\n const partValue = getCommittedValue(containerPart);\n const childPart = partValue.pop();\n let cachedContainerPart = this._templateCache.get(_valueKey);\n if (cachedContainerPart === undefined) {\n const fragment = document.createDocumentFragment();\n cachedContainerPart = render(nothing, fragment);\n cachedContainerPart.setConnected(false);\n this._templateCache.set(_valueKey, cachedContainerPart);\n }\n // Move into cache\n setCommittedValue(cachedContainerPart, [childPart]);\n insertPart(cachedContainerPart, undefined, childPart);\n }\n // If the new value is a TemplateResult and the previous value is not,\n // or is a different Template as the previous value, restore the child\n // part from the cache.\n if (vKey !== null) {\n if (_valueKey === null || _valueKey !== vKey) {\n const cachedContainerPart = this._templateCache.get(vKey);\n if (cachedContainerPart !== undefined) {\n // Move the cached part back into the container part value\n const partValue = getCommittedValue(cachedContainerPart);\n const cachedPart = partValue.pop();\n // Move cached part back into DOM\n clearPart(containerPart);\n insertPart(containerPart, undefined, cachedPart);\n setCommittedValue(containerPart, [cachedPart]);\n }\n }\n // Because vKey is non null, v must be a TemplateResult.\n this._value = v;\n }\n else {\n this._value = undefined;\n }\n return this.render(v);\n }\n}\n/**\n * Enables fast switching between multiple templates by caching the DOM nodes\n * and TemplateInstances produced by the templates.\n *\n * Example:\n *\n * ```js\n * let checked = false;\n *\n * html`\n * ${cache(checked ? html`input is checked` : html`input is not checked`)}\n * `\n * ```\n */\nexport const cache = directive(CacheDirective);\n//# sourceMappingURL=cache.js.map",
20
- "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n/**\n * Chooses and evaluates a template function from a list based on matching\n * the given `value` to a case.\n *\n * Cases are structured as `[caseValue, func]`. `value` is matched to\n * `caseValue` by strict equality. The first match is selected. Case values\n * can be of any type including primitives, objects, and symbols.\n *\n * This is similar to a switch statement, but as an expression and without\n * fallthrough.\n *\n * @example\n *\n * ```ts\n * render() {\n * return html`\n * ${choose(this.section, [\n * ['home', () => html`<h1>Home</h1>`],\n * ['about', () => html`<h1>About</h1>`]\n * ],\n * () => html`<h1>Error</h1>`)}\n * `;\n * }\n * ```\n */\nexport const choose = (value, cases, defaultCase) => {\n for (const c of cases) {\n const caseValue = c[0];\n if (caseValue === value) {\n const fn = c[1];\n return fn();\n }\n }\n return defaultCase?.();\n};\n//# sourceMappingURL=choose.js.map",
21
- "/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { noChange } from '../lit-html.js';\nimport { directive, Directive, PartType, } from '../directive.js';\nclass ClassMapDirective extends Directive {\n constructor(partInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.ATTRIBUTE ||\n partInfo.name !== 'class' ||\n partInfo.strings?.length > 2) {\n throw new Error('`classMap()` can only be used in the `class` attribute ' +\n 'and must be the only part in the attribute.');\n }\n }\n render(classInfo) {\n // Add spaces to ensure separation from static classes\n return (' ' +\n Object.keys(classInfo)\n .filter((key) => classInfo[key])\n .join(' ') +\n ' ');\n }\n update(part, [classInfo]) {\n // Remember dynamic classes on the first render\n if (this._previousClasses === undefined) {\n this._previousClasses = new Set();\n if (part.strings !== undefined) {\n this._staticClasses = new Set(part.strings\n .join(' ')\n .split(/\\s/)\n .filter((s) => s !== ''));\n }\n for (const name in classInfo) {\n if (classInfo[name] && !this._staticClasses?.has(name)) {\n this._previousClasses.add(name);\n }\n }\n return this.render(classInfo);\n }\n const classList = part.element.classList;\n // Remove old classes that no longer apply\n for (const name of this._previousClasses) {\n if (!(name in classInfo)) {\n classList.remove(name);\n this._previousClasses.delete(name);\n }\n }\n // Add or remove classes based on their classMap value\n for (const name in classInfo) {\n // We explicitly want a loose truthy check of `value` because it seems\n // more convenient that '' and 0 are skipped.\n const value = !!classInfo[name];\n if (value !== this._previousClasses.has(name) &&\n !this._staticClasses?.has(name)) {\n if (value) {\n classList.add(name);\n this._previousClasses.add(name);\n }\n else {\n classList.remove(name);\n this._previousClasses.delete(name);\n }\n }\n }\n return noChange;\n }\n}\n/**\n * A directive that applies dynamic CSS classes.\n *\n * This must be used in the `class` attribute and must be the only part used in\n * the attribute. It takes each property in the `classInfo` argument and adds\n * the property name to the element's `classList` if the property value is\n * truthy; if the property value is falsy, the property name is removed from\n * the element's `class`.\n *\n * For example `{foo: bar}` applies the class `foo` if the value of `bar` is\n * truthy.\n *\n * @param classInfo\n */\nexport const classMap = directive(ClassMapDirective);\n//# sourceMappingURL=class-map.js.map",
22
- "/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { noChange } from '../lit-html.js';\nimport { directive, Directive } from '../directive.js';\n// A sentinel that indicates guard() hasn't rendered anything yet\nconst initialValue = {};\nclass GuardDirective extends Directive {\n constructor() {\n super(...arguments);\n this._previousValue = initialValue;\n }\n render(_value, f) {\n return f();\n }\n update(_part, [value, f]) {\n if (Array.isArray(value)) {\n // Dirty-check arrays by item\n if (Array.isArray(this._previousValue) &&\n this._previousValue.length === value.length &&\n value.every((v, i) => v === this._previousValue[i])) {\n return noChange;\n }\n }\n else if (this._previousValue === value) {\n // Dirty-check non-arrays by identity\n return noChange;\n }\n // Copy the value if it's an array so that if it's mutated we don't forget\n // what the previous values were.\n this._previousValue = Array.isArray(value) ? Array.from(value) : value;\n const r = this.render(value, f);\n return r;\n }\n}\n/**\n * Prevents re-render of a template function until a single value or an array of\n * values changes.\n *\n * Values are checked against previous values with strict equality (`===`), and\n * so the check won't detect nested property changes inside objects or arrays.\n * Arrays values have each item checked against the previous value at the same\n * index with strict equality. Nested arrays are also checked only by strict\n * equality.\n *\n * Example:\n *\n * ```js\n * html`\n * <div>\n * ${guard([user.id, company.id], () => html`...`)}\n * </div>\n * `\n * ```\n *\n * In this case, the template only rerenders if either `user.id` or `company.id`\n * changes.\n *\n * guard() is useful with immutable data patterns, by preventing expensive work\n * until data updates.\n *\n * Example:\n *\n * ```js\n * html`\n * <div>\n * ${guard([immutableItems], () => immutableItems.map(i => html`${i}`))}\n * </div>\n * `\n * ```\n *\n * In this case, items are mapped over only when the array reference changes.\n *\n * @param value the value to check before re-rendering\n * @param f the template function\n */\nexport const guard = directive(GuardDirective);\n//# sourceMappingURL=guard.js.map",
23
- "/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { nothing } from '../lit-html.js';\n/**\n * For AttributeParts, sets the attribute if the value is defined and removes\n * the attribute if the value is undefined.\n *\n * For other part types, this directive is a no-op.\n */\nexport const ifDefined = (value) => value ?? nothing;\n//# sourceMappingURL=if-defined.js.map",
24
- "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nexport function* join(items, joiner) {\n const isFunction = typeof joiner === 'function';\n if (items !== undefined) {\n let i = -1;\n for (const value of items) {\n if (i > -1) {\n yield isFunction ? joiner(i) : joiner;\n }\n i++;\n yield value;\n }\n }\n}\n//# sourceMappingURL=join.js.map",
25
- "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { nothing } from '../lit-html.js';\nimport { directive, Directive, } from '../directive.js';\nimport { setCommittedValue } from '../directive-helpers.js';\nclass Keyed extends Directive {\n constructor() {\n super(...arguments);\n this.key = nothing;\n }\n render(k, v) {\n this.key = k;\n return v;\n }\n update(part, [k, v]) {\n if (k !== this.key) {\n // Clear the part before returning a value. The one-arg form of\n // setCommittedValue sets the value to a sentinel which forces a\n // commit the next render.\n setCommittedValue(part);\n this.key = k;\n }\n return v;\n }\n}\n/**\n * Associates a renderable value with a unique key. When the key changes, the\n * previous DOM is removed and disposed before rendering the next value, even\n * if the value - such as a template - is the same.\n *\n * This is useful for forcing re-renders of stateful components, or working\n * with code that expects new data to generate new HTML elements, such as some\n * animation techniques.\n */\nexport const keyed = directive(Keyed);\n//# sourceMappingURL=keyed.js.map",
26
- "/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { noChange, nothing } from '../lit-html.js';\nimport { directive, Directive, PartType, } from '../directive.js';\nimport { isSingleExpression, setCommittedValue } from '../directive-helpers.js';\nclass LiveDirective extends Directive {\n constructor(partInfo) {\n super(partInfo);\n if (!(partInfo.type === PartType.PROPERTY ||\n partInfo.type === PartType.ATTRIBUTE ||\n partInfo.type === PartType.BOOLEAN_ATTRIBUTE)) {\n throw new Error('The `live` directive is not allowed on child or event bindings');\n }\n if (!isSingleExpression(partInfo)) {\n throw new Error('`live` bindings can only contain a single expression');\n }\n }\n render(value) {\n return value;\n }\n update(part, [value]) {\n if (value === noChange || value === nothing) {\n return value;\n }\n const element = part.element;\n const name = part.name;\n if (part.type === PartType.PROPERTY) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (value === element[name]) {\n return noChange;\n }\n }\n else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {\n if (!!value === element.hasAttribute(name)) {\n return noChange;\n }\n }\n else if (part.type === PartType.ATTRIBUTE) {\n if (element.getAttribute(name) === String(value)) {\n return noChange;\n }\n }\n // Resets the part's value, causing its dirty-check to fail so that it\n // always sets the value.\n setCommittedValue(part);\n return value;\n }\n}\n/**\n * Checks binding values against live DOM values, instead of previously bound\n * values, when determining whether to update the value.\n *\n * This is useful for cases where the DOM value may change from outside of\n * lit-html, such as with a binding to an `<input>` element's `value` property,\n * a content editable elements text, or to a custom element that changes it's\n * own properties or attributes.\n *\n * In these cases if the DOM value changes, but the value set through lit-html\n * bindings hasn't, lit-html won't know to update the DOM value and will leave\n * it alone. If this is not what you want--if you want to overwrite the DOM\n * value with the bound value no matter what--use the `live()` directive:\n *\n * ```js\n * html`<input .value=${live(x)}>`\n * ```\n *\n * `live()` performs a strict equality check against the live DOM value, and if\n * the new value is equal to the live value, does nothing. This means that\n * `live()` should not be used when the binding will cause a type conversion. If\n * you use `live()` with an attribute binding, make sure that only strings are\n * passed in, or the binding will update every render.\n */\nexport const live = directive(LiveDirective);\n//# sourceMappingURL=live.js.map",
27
- "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n/**\n * Returns an iterable containing the result of calling `f(value)` on each\n * value in `items`.\n *\n * @example\n *\n * ```ts\n * render() {\n * return html`\n * <ul>\n * ${map(items, (i) => html`<li>${i}</li>`)}\n * </ul>\n * `;\n * }\n * ```\n */\nexport function* map(items, f) {\n if (items !== undefined) {\n let i = 0;\n for (const value of items) {\n yield f(value, i++);\n }\n }\n}\n//# sourceMappingURL=map.js.map",
28
- "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nexport function* range(startOrEnd, end, step = 1) {\n const start = end === undefined ? 0 : startOrEnd;\n end ??= startOrEnd;\n for (let i = start; step > 0 ? i < end : end < i; i += step) {\n yield i;\n }\n}\n//# sourceMappingURL=range.js.map",
29
- "/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { nothing } from '../lit-html.js';\nimport { directive, AsyncDirective } from '../async-directive.js';\n/**\n * Creates a new Ref object, which is container for a reference to an element.\n */\nexport const createRef = () => new Ref();\n/**\n * An object that holds a ref value.\n */\nclass Ref {\n}\n// When callbacks are used for refs, this map tracks the last value the callback\n// was called with, for ensuring a directive doesn't clear the ref if the ref\n// has already been rendered to a new spot. It is double-keyed on both the\n// context (`options.host`) and the callback, since we auto-bind class methods\n// to `options.host`.\nconst lastElementForContextAndCallback = new WeakMap();\nclass RefDirective extends AsyncDirective {\n render(_ref) {\n return nothing;\n }\n update(part, [ref]) {\n const refChanged = ref !== this._ref;\n if (refChanged && this._ref !== undefined) {\n // The ref passed to the directive has changed;\n // unset the previous ref's value\n this._updateRefValue(undefined);\n }\n if (refChanged || this._lastElementForRef !== this._element) {\n // We either got a new ref or this is the first render;\n // store the ref/element & update the ref value\n this._ref = ref;\n this._context = part.options?.host;\n this._updateRefValue((this._element = part.element));\n }\n return nothing;\n }\n _updateRefValue(element) {\n if (!this.isConnected) {\n element = undefined;\n }\n if (typeof this._ref === 'function') {\n // If the current ref was called with a previous value, call with\n // `undefined`; We do this to ensure callbacks are called in a consistent\n // way regardless of whether a ref might be moving up in the tree (in\n // which case it would otherwise be called with the new value before the\n // previous one unsets it) and down in the tree (where it would be unset\n // before being set). Note that element lookup is keyed by\n // both the context and the callback, since we allow passing unbound\n // functions that are called on options.host, and we want to treat\n // these as unique \"instances\" of a function.\n const context = this._context ?? globalThis;\n let lastElementForCallback = lastElementForContextAndCallback.get(context);\n if (lastElementForCallback === undefined) {\n lastElementForCallback = new WeakMap();\n lastElementForContextAndCallback.set(context, lastElementForCallback);\n }\n if (lastElementForCallback.get(this._ref) !== undefined) {\n this._ref.call(this._context, undefined);\n }\n lastElementForCallback.set(this._ref, element);\n // Call the ref with the new element value\n if (element !== undefined) {\n this._ref.call(this._context, element);\n }\n }\n else {\n this._ref.value = element;\n }\n }\n get _lastElementForRef() {\n return typeof this._ref === 'function'\n ? lastElementForContextAndCallback\n .get(this._context ?? globalThis)\n ?.get(this._ref)\n : this._ref?.value;\n }\n disconnected() {\n // Only clear the box if our element is still the one in it (i.e. another\n // directive instance hasn't rendered its element to it before us); that\n // only happens in the event of the directive being cleared (not via manual\n // disconnection)\n if (this._lastElementForRef === this._element) {\n this._updateRefValue(undefined);\n }\n }\n reconnected() {\n // If we were manually disconnected, we can safely put our element back in\n // the box, since no rendering could have occurred to change its state\n this._updateRefValue(this._element);\n }\n}\n/**\n * Sets the value of a Ref object or calls a ref callback with the element it's\n * bound to.\n *\n * A Ref object acts as a container for a reference to an element. A ref\n * callback is a function that takes an element as its only argument.\n *\n * The ref directive sets the value of the Ref object or calls the ref callback\n * during rendering, if the referenced element changed.\n *\n * Note: If a ref callback is rendered to a different element position or is\n * removed in a subsequent render, it will first be called with `undefined`,\n * followed by another call with the new element it was rendered to (if any).\n *\n * ```js\n * // Using Ref object\n * const inputRef = createRef();\n * render(html`<input ${ref(inputRef)}>`, container);\n * inputRef.value.focus();\n *\n * // Using callback\n * const callback = (inputElement) => inputElement.focus();\n * render(html`<input ${ref(callback)}>`, container);\n * ```\n */\nexport const ref = directive(RefDirective);\n//# sourceMappingURL=ref.js.map",
30
- "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { noChange } from '../lit-html.js';\nimport { directive, Directive, PartType } from '../directive.js';\nimport { insertPart, getCommittedValue, removePart, setCommittedValue, setChildPartValue, } from '../directive-helpers.js';\n// Helper for generating a map of array item to its index over a subset\n// of an array (used to lazily generate `newKeyToIndexMap` and\n// `oldKeyToIndexMap`)\nconst generateMap = (list, start, end) => {\n const map = new Map();\n for (let i = start; i <= end; i++) {\n map.set(list[i], i);\n }\n return map;\n};\nclass RepeatDirective extends Directive {\n constructor(partInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('repeat() can only be used in text expressions');\n }\n }\n _getValuesAndKeys(items, keyFnOrTemplate, template) {\n let keyFn;\n if (template === undefined) {\n template = keyFnOrTemplate;\n }\n else if (keyFnOrTemplate !== undefined) {\n keyFn = keyFnOrTemplate;\n }\n const keys = [];\n const values = [];\n let index = 0;\n for (const item of items) {\n keys[index] = keyFn ? keyFn(item, index) : index;\n values[index] = template(item, index);\n index++;\n }\n return {\n values,\n keys,\n };\n }\n render(items, keyFnOrTemplate, template) {\n return this._getValuesAndKeys(items, keyFnOrTemplate, template).values;\n }\n update(containerPart, [items, keyFnOrTemplate, template]) {\n // Old part & key lists are retrieved from the last update (which may\n // be primed by hydration)\n const oldParts = getCommittedValue(containerPart);\n const { values: newValues, keys: newKeys } = this._getValuesAndKeys(items, keyFnOrTemplate, template);\n // We check that oldParts, the committed value, is an Array as an\n // indicator that the previous value came from a repeat() call. If\n // oldParts is not an Array then this is the first render and we return\n // an array for lit-html's array handling to render, and remember the\n // keys.\n if (!Array.isArray(oldParts)) {\n this._itemKeys = newKeys;\n return newValues;\n }\n // In SSR hydration it's possible for oldParts to be an array but for us\n // to not have item keys because the update() hasn't run yet. We set the\n // keys to an empty array. This will cause all oldKey/newKey comparisons\n // to fail and execution to fall to the last nested brach below which\n // reuses the oldPart.\n const oldKeys = (this._itemKeys ??= []);\n // New part list will be built up as we go (either reused from\n // old parts or created for new keys in this update). This is\n // saved in the above cache at the end of the update.\n const newParts = [];\n // Maps from key to index for current and previous update; these\n // are generated lazily only when needed as a performance\n // optimization, since they are only required for multiple\n // non-contiguous changes in the list, which are less common.\n let newKeyToIndexMap;\n let oldKeyToIndexMap;\n // Head and tail pointers to old parts and new values\n let oldHead = 0;\n let oldTail = oldParts.length - 1;\n let newHead = 0;\n let newTail = newValues.length - 1;\n // Overview of O(n) reconciliation algorithm (general approach\n // based on ideas found in ivi, vue, snabbdom, etc.):\n //\n // * We start with the list of old parts and new values (and\n // arrays of their respective keys), head/tail pointers into\n // each, and we build up the new list of parts by updating\n // (and when needed, moving) old parts or creating new ones.\n // The initial scenario might look like this (for brevity of\n // the diagrams, the numbers in the array reflect keys\n // associated with the old parts or new values, although keys\n // and parts/values are actually stored in parallel arrays\n // indexed using the same head/tail pointers):\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [ , , , , , , ]\n // newKeys: [0, 2, 1, 4, 3, 7, 6] <- reflects the user's new\n // item order\n // newHead ^ ^ newTail\n //\n // * Iterate old & new lists from both sides, updating,\n // swapping, or removing parts at the head/tail locations\n // until neither head nor tail can move.\n //\n // * Example below: keys at head pointers match, so update old\n // part 0 in-place (no need to move it) and record part 0 in\n // the `newParts` list. The last thing we do is advance the\n // `oldHead` and `newHead` pointers (will be reflected in the\n // next diagram).\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , ] <- heads matched: update 0\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldHead\n // & newHead\n // newHead ^ ^ newTail\n //\n // * Example below: head pointers don't match, but tail\n // pointers do, so update part 6 in place (no need to move\n // it), and record part 6 in the `newParts` list. Last,\n // advance the `oldTail` and `oldHead` pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , 6] <- tails matched: update 6\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldTail\n // & newTail\n // newHead ^ ^ newTail\n //\n // * If neither head nor tail match; next check if one of the\n // old head/tail items was removed. We first need to generate\n // the reverse map of new keys to index (`newKeyToIndexMap`),\n // which is done once lazily as a performance optimization,\n // since we only hit this case if multiple non-contiguous\n // changes were made. Note that for contiguous removal\n // anywhere in the list, the head and tails would advance\n // from either end and pass each other before we get to this\n // case and removals would be handled in the final while loop\n // without needing to generate the map.\n //\n // * Example below: The key at `oldTail` was removed (no longer\n // in the `newKeyToIndexMap`), so remove that part from the\n // DOM and advance just the `oldTail` pointer.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , 6] <- 5 not in new map: remove\n // newKeys: [0, 2, 1, 4, 3, 7, 6] 5 and advance oldTail\n // newHead ^ ^ newTail\n //\n // * Once head and tail cannot move, any mismatches are due to\n // either new or moved items; if a new key is in the previous\n // \"old key to old index\" map, move the old part to the new\n // location, otherwise create and insert a new part. Note\n // that when moving an old part we null its position in the\n // oldParts array if it lies between the head and tail so we\n // know to skip it when the pointers get there.\n //\n // * Example below: neither head nor tail match, and neither\n // were removed; so find the `newHead` key in the\n // `oldKeyToIndexMap`, and move that old part's DOM into the\n // next head position (before `oldParts[oldHead]`). Last,\n // null the part in the `oldPart` array since it was\n // somewhere in the remaining oldParts still to be scanned\n // (between the head and tail pointers) so that we know to\n // skip that old part on future iterations.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, , , , , 6] <- stuck: update & move 2\n // newKeys: [0, 2, 1, 4, 3, 7, 6] into place and advance\n // newHead\n // newHead ^ ^ newTail\n //\n // * Note that for moves/insertions like the one above, a part\n // inserted at the head pointer is inserted before the\n // current `oldParts[oldHead]`, and a part inserted at the\n // tail pointer is inserted before `newParts[newTail+1]`. The\n // seeming asymmetry lies in the fact that new parts are\n // moved into place outside in, so to the right of the head\n // pointer are old parts, and to the right of the tail\n // pointer are new parts.\n //\n // * We always restart back from the top of the algorithm,\n // allowing matching and simple updates in place to\n // continue...\n //\n // * Example below: the head pointers once again match, so\n // simply update part 1 and record it in the `newParts`\n // array. Last, advance both head pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, , , , 6] <- heads matched: update 1\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldHead\n // & newHead\n // newHead ^ ^ newTail\n //\n // * As mentioned above, items that were moved as a result of\n // being stuck (the final else clause in the code below) are\n // marked with null, so we always advance old pointers over\n // these so we're comparing the next actual old value on\n // either end.\n //\n // * Example below: `oldHead` is null (already placed in\n // newParts), so advance `oldHead`.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6] <- old head already used:\n // newParts: [0, 2, 1, , , , 6] advance oldHead\n // newKeys: [0, 2, 1, 4, 3, 7, 6]\n // newHead ^ ^ newTail\n //\n // * Note it's not critical to mark old parts as null when they\n // are moved from head to tail or tail to head, since they\n // will be outside the pointer range and never visited again.\n //\n // * Example below: Here the old tail key matches the new head\n // key, so the part at the `oldTail` position and move its\n // DOM to the new head position (before `oldParts[oldHead]`).\n // Last, advance `oldTail` and `newHead` pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, , , 6] <- old tail matches new\n // newKeys: [0, 2, 1, 4, 3, 7, 6] head: update & move 4,\n // advance oldTail & newHead\n // newHead ^ ^ newTail\n //\n // * Example below: Old and new head keys match, so update the\n // old head part in place, and advance the `oldHead` and\n // `newHead` pointers.\n //\n // oldHead v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, 3, ,6] <- heads match: update 3\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance oldHead &\n // newHead\n // newHead ^ ^ newTail\n //\n // * Once the new or old pointers move past each other then all\n // we have left is additions (if old list exhausted) or\n // removals (if new list exhausted). Those are handled in the\n // final while loops at the end.\n //\n // * Example below: `oldHead` exceeded `oldTail`, so we're done\n // with the main loop. Create the remaining part and insert\n // it at the new head position, and the update is complete.\n //\n // (oldHead > oldTail)\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, 3, 7 ,6] <- create and insert 7\n // newKeys: [0, 2, 1, 4, 3, 7, 6]\n // newHead ^ newTail\n //\n // * Note that the order of the if/else clauses is not\n // important to the algorithm, as long as the null checks\n // come first (to ensure we're always working on valid old\n // parts) and that the final else clause comes last (since\n // that's where the expensive moves occur). The order of\n // remaining clauses is just a simple guess at which cases\n // will be most common.\n //\n // * Note, we could calculate the longest\n // increasing subsequence (LIS) of old items in new position,\n // and only move those not in the LIS set. However that costs\n // O(nlogn) time and adds a bit more code, and only helps\n // make rare types of mutations require fewer moves. The\n // above handles removes, adds, reversal, swaps, and single\n // moves of contiguous items in linear time, in the minimum\n // number of moves. As the number of multiple moves where LIS\n // might help approaches a random shuffle, the LIS\n // optimization becomes less helpful, so it seems not worth\n // the code at this point. Could reconsider if a compelling\n // case arises.\n while (oldHead <= oldTail && newHead <= newTail) {\n if (oldParts[oldHead] === null) {\n // `null` means old part at head has already been used\n // below; skip\n oldHead++;\n }\n else if (oldParts[oldTail] === null) {\n // `null` means old part at tail has already been used\n // below; skip\n oldTail--;\n }\n else if (oldKeys[oldHead] === newKeys[newHead]) {\n // Old head matches new head; update in place\n newParts[newHead] = setChildPartValue(oldParts[oldHead], newValues[newHead]);\n oldHead++;\n newHead++;\n }\n else if (oldKeys[oldTail] === newKeys[newTail]) {\n // Old tail matches new tail; update in place\n newParts[newTail] = setChildPartValue(oldParts[oldTail], newValues[newTail]);\n oldTail--;\n newTail--;\n }\n else if (oldKeys[oldHead] === newKeys[newTail]) {\n // Old head matches new tail; update and move to new tail\n newParts[newTail] = setChildPartValue(oldParts[oldHead], newValues[newTail]);\n insertPart(containerPart, newParts[newTail + 1], oldParts[oldHead]);\n oldHead++;\n newTail--;\n }\n else if (oldKeys[oldTail] === newKeys[newHead]) {\n // Old tail matches new head; update and move to new head\n newParts[newHead] = setChildPartValue(oldParts[oldTail], newValues[newHead]);\n insertPart(containerPart, oldParts[oldHead], oldParts[oldTail]);\n oldTail--;\n newHead++;\n }\n else {\n if (newKeyToIndexMap === undefined) {\n // Lazily generate key-to-index maps, used for removals &\n // moves below\n newKeyToIndexMap = generateMap(newKeys, newHead, newTail);\n oldKeyToIndexMap = generateMap(oldKeys, oldHead, oldTail);\n }\n if (!newKeyToIndexMap.has(oldKeys[oldHead])) {\n // Old head is no longer in new list; remove\n removePart(oldParts[oldHead]);\n oldHead++;\n }\n else if (!newKeyToIndexMap.has(oldKeys[oldTail])) {\n // Old tail is no longer in new list; remove\n removePart(oldParts[oldTail]);\n oldTail--;\n }\n else {\n // Any mismatches at this point are due to additions or\n // moves; see if we have an old part we can reuse and move\n // into place\n const oldIndex = oldKeyToIndexMap.get(newKeys[newHead]);\n const oldPart = oldIndex !== undefined ? oldParts[oldIndex] : null;\n if (oldPart === null) {\n // No old part for this value; create a new one and\n // insert it\n const newPart = insertPart(containerPart, oldParts[oldHead]);\n setChildPartValue(newPart, newValues[newHead]);\n newParts[newHead] = newPart;\n }\n else {\n // Reuse old part\n newParts[newHead] = setChildPartValue(oldPart, newValues[newHead]);\n insertPart(containerPart, oldParts[oldHead], oldPart);\n // This marks the old part as having been used, so that\n // it will be skipped in the first two checks above\n oldParts[oldIndex] = null;\n }\n newHead++;\n }\n }\n }\n // Add parts for any remaining new values\n while (newHead <= newTail) {\n // For all remaining additions, we insert before last new\n // tail, since old pointers are no longer valid\n const newPart = insertPart(containerPart, newParts[newTail + 1]);\n setChildPartValue(newPart, newValues[newHead]);\n newParts[newHead++] = newPart;\n }\n // Remove any remaining unused old parts\n while (oldHead <= oldTail) {\n const oldPart = oldParts[oldHead++];\n if (oldPart !== null) {\n removePart(oldPart);\n }\n }\n // Save order of new parts for next round\n this._itemKeys = newKeys;\n // Directly set part value, bypassing it's dirty-checking\n setCommittedValue(containerPart, newParts);\n return noChange;\n }\n}\n/**\n * A directive that repeats a series of values (usually `TemplateResults`)\n * generated from an iterable, and updates those items efficiently when the\n * iterable changes based on user-provided `keys` associated with each item.\n *\n * Note that if a `keyFn` is provided, strict key-to-DOM mapping is maintained,\n * meaning previous DOM for a given key is moved into the new position if\n * needed, and DOM will never be reused with values for different keys (new DOM\n * will always be created for new keys). This is generally the most efficient\n * way to use `repeat` since it performs minimum unnecessary work for insertions\n * and removals.\n *\n * The `keyFn` takes two parameters, the item and its index, and returns a unique key value.\n *\n * ```js\n * html`\n * <ol>\n * ${repeat(this.items, (item) => item.id, (item, index) => {\n * return html`<li>${index}: ${item.name}</li>`;\n * })}\n * </ol>\n * `\n * ```\n *\n * **Important**: If providing a `keyFn`, keys *must* be unique for all items in a\n * given call to `repeat`. The behavior when two or more items have the same key\n * is undefined.\n *\n * If no `keyFn` is provided, this directive will perform similar to mapping\n * items to values, and DOM will be reused against potentially different items.\n */\nexport const repeat = directive(RepeatDirective);\n//# sourceMappingURL=repeat.js.map",
31
- "/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { noChange } from '../lit-html.js';\nimport { directive, Directive, PartType, } from '../directive.js';\nconst important = 'important';\n// The leading space is important\nconst importantFlag = ' !' + important;\n// How many characters to remove from a value, as a negative number\nconst flagTrim = 0 - importantFlag.length;\nclass StyleMapDirective extends Directive {\n constructor(partInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.ATTRIBUTE ||\n partInfo.name !== 'style' ||\n partInfo.strings?.length > 2) {\n throw new Error('The `styleMap` directive must be used in the `style` attribute ' +\n 'and must be the only part in the attribute.');\n }\n }\n render(styleInfo) {\n return Object.keys(styleInfo).reduce((style, prop) => {\n const value = styleInfo[prop];\n if (value == null) {\n return style;\n }\n // Convert property names from camel-case to dash-case, i.e.:\n // `backgroundColor` -> `background-color`\n // Vendor-prefixed names need an extra `-` appended to front:\n // `webkitAppearance` -> `-webkit-appearance`\n // Exception is any property name containing a dash, including\n // custom properties; we assume these are already dash-cased i.e.:\n // `--my-button-color` --> `--my-button-color`\n prop = prop.includes('-')\n ? prop\n : prop\n .replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, '-$&')\n .toLowerCase();\n return style + `${prop}:${value};`;\n }, '');\n }\n update(part, [styleInfo]) {\n const { style } = part.element;\n if (this._previousStyleProperties === undefined) {\n this._previousStyleProperties = new Set(Object.keys(styleInfo));\n return this.render(styleInfo);\n }\n // Remove old properties that no longer exist in styleInfo\n for (const name of this._previousStyleProperties) {\n // If the name isn't in styleInfo or it's null/undefined\n if (styleInfo[name] == null) {\n this._previousStyleProperties.delete(name);\n if (name.includes('-')) {\n style.removeProperty(name);\n }\n else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n style[name] = null;\n }\n }\n }\n // Add or update properties\n for (const name in styleInfo) {\n const value = styleInfo[name];\n if (value != null) {\n this._previousStyleProperties.add(name);\n const isImportant = typeof value === 'string' && value.endsWith(importantFlag);\n if (name.includes('-') || isImportant) {\n style.setProperty(name, isImportant\n ? value.slice(0, flagTrim)\n : value, isImportant ? important : '');\n }\n else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n style[name] = value;\n }\n }\n }\n return noChange;\n }\n}\n/**\n * A directive that applies CSS properties to an element.\n *\n * `styleMap` can only be used in the `style` attribute and must be the only\n * expression in the attribute. It takes the property names in the\n * {@link StyleInfo styleInfo} object and adds the properties to the inline\n * style of the element.\n *\n * Property names with dashes (`-`) are assumed to be valid CSS\n * property names and set on the element's style object using `setProperty()`.\n * Names without dashes are assumed to be camelCased JavaScript property names\n * and set on the element's style object using property assignment, allowing the\n * style object to translate JavaScript-style names to CSS property names.\n *\n * For example `styleMap({backgroundColor: 'red', 'border-top': '5px', '--size':\n * '0'})` sets the `background-color`, `border-top` and `--size` properties.\n *\n * @param styleInfo\n * @see {@link https://lit.dev/docs/templates/directives/#stylemap styleMap code samples on Lit.dev}\n */\nexport const styleMap = directive(StyleMapDirective);\n//# sourceMappingURL=style-map.js.map",
32
- "/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { noChange } from '../lit-html.js';\nimport { directive, Directive, PartType } from '../directive.js';\nclass TemplateContentDirective extends Directive {\n constructor(partInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('templateContent can only be used in child bindings');\n }\n }\n render(template) {\n if (this._previousTemplate === template) {\n return noChange;\n }\n this._previousTemplate = template;\n return document.importNode(template.content, true);\n }\n}\n/**\n * Renders the content of a template element as HTML.\n *\n * Note, the template should be developer controlled and not user controlled.\n * Rendering a user-controlled template with this directive\n * could lead to cross-site-scripting vulnerabilities.\n */\nexport const templateContent = directive(TemplateContentDirective);\n//# sourceMappingURL=template-content.js.map",
33
- "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { nothing, noChange } from '../lit-html.js';\nimport { directive, Directive, PartType } from '../directive.js';\nconst HTML_RESULT = 1;\nexport class UnsafeHTMLDirective extends Directive {\n constructor(partInfo) {\n super(partInfo);\n this._value = nothing;\n if (partInfo.type !== PartType.CHILD) {\n throw new Error(`${this.constructor.directiveName}() can only be used in child bindings`);\n }\n }\n render(value) {\n if (value === nothing || value == null) {\n this._templateResult = undefined;\n return (this._value = value);\n }\n if (value === noChange) {\n return value;\n }\n if (typeof value != 'string') {\n throw new Error(`${this.constructor.directiveName}() called with a non-string value`);\n }\n if (value === this._value) {\n return this._templateResult;\n }\n this._value = value;\n const strings = [value];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n strings.raw = strings;\n // WARNING: impersonating a TemplateResult like this is extremely\n // dangerous. Third-party directives should not do this.\n return (this._templateResult = {\n // Cast to a known set of integers that satisfy ResultType so that we\n // don't have to export ResultType and possibly encourage this pattern.\n // This property needs to remain unminified.\n ['_$litType$']: this.constructor\n .resultType,\n strings,\n values: [],\n });\n }\n}\nUnsafeHTMLDirective.directiveName = 'unsafeHTML';\nUnsafeHTMLDirective.resultType = HTML_RESULT;\n/**\n * Renders the result as HTML, rather than text.\n *\n * The values `undefined`, `null`, and `nothing`, will all result in no content\n * (empty string) being rendered.\n *\n * Note, this is unsafe to use with any user-provided input that hasn't been\n * sanitized or escaped, as it may lead to cross-site-scripting\n * vulnerabilities.\n */\nexport const unsafeHTML = directive(UnsafeHTMLDirective);\n//# sourceMappingURL=unsafe-html.js.map",
34
- "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { directive } from '../directive.js';\nimport { UnsafeHTMLDirective } from './unsafe-html.js';\nconst SVG_RESULT = 2;\nclass UnsafeSVGDirective extends UnsafeHTMLDirective {\n}\nUnsafeSVGDirective.directiveName = 'unsafeSVG';\nUnsafeSVGDirective.resultType = SVG_RESULT;\n/**\n * Renders the result as SVG, rather than text.\n *\n * The values `undefined`, `null`, and `nothing`, will all result in no content\n * (empty string) being rendered.\n *\n * Note, this is unsafe to use with any user-provided input that hasn't been\n * sanitized or escaped, as it may lead to cross-site-scripting\n * vulnerabilities.\n */\nexport const unsafeSVG = directive(UnsafeSVGDirective);\n//# sourceMappingURL=unsafe-svg.js.map",
35
- "/**\n * @license\n * Copyright 2024 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { directive } from '../directive.js';\nimport { UnsafeHTMLDirective } from './unsafe-html.js';\nconst MATHML_RESULT = 3;\nclass UnsafeMathMLDirective extends UnsafeHTMLDirective {\n}\nUnsafeMathMLDirective.directiveName = 'unsafeMath';\nUnsafeMathMLDirective.resultType = MATHML_RESULT;\n/**\n * Renders the result as MathML, rather than text.\n *\n * The values `undefined`, `null`, and `nothing`, will all result in no content\n * (empty string) being rendered.\n *\n * Note, this is unsafe to use with any user-provided input that hasn't been\n * sanitized or escaped, as it may lead to cross-site-scripting\n * vulnerabilities.\n */\nexport const unsafeMathML = directive(UnsafeMathMLDirective);\n//# sourceMappingURL=unsafe-mathml.js.map",
36
- "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport { noChange } from '../lit-html.js';\nimport { isPrimitive } from '../directive-helpers.js';\nimport { directive, AsyncDirective } from '../async-directive.js';\nimport { Pauser, PseudoWeakRef } from './private-async-helpers.js';\nconst isPromise = (x) => {\n return !isPrimitive(x) && typeof x.then === 'function';\n};\n// Effectively infinity, but a SMI.\nconst _infinity = 0x3fffffff;\nexport class UntilDirective extends AsyncDirective {\n constructor() {\n super(...arguments);\n this.__lastRenderedIndex = _infinity;\n this.__values = [];\n this.__weakThis = new PseudoWeakRef(this);\n this.__pauser = new Pauser();\n }\n render(...args) {\n return args.find((x) => !isPromise(x)) ?? noChange;\n }\n update(_part, args) {\n const previousValues = this.__values;\n let previousLength = previousValues.length;\n this.__values = args;\n const weakThis = this.__weakThis;\n const pauser = this.__pauser;\n // If our initial render occurs while disconnected, ensure that the pauser\n // and weakThis are in the disconnected state\n if (!this.isConnected) {\n this.disconnected();\n }\n for (let i = 0; i < args.length; i++) {\n // If we've rendered a higher-priority value already, stop.\n if (i > this.__lastRenderedIndex) {\n break;\n }\n const value = args[i];\n // Render non-Promise values immediately\n if (!isPromise(value)) {\n this.__lastRenderedIndex = i;\n // Since a lower-priority value will never overwrite a higher-priority\n // synchronous value, we can stop processing now.\n return value;\n }\n // If this is a Promise we've already handled, skip it.\n if (i < previousLength && value === previousValues[i]) {\n continue;\n }\n // We have a Promise that we haven't seen before, so priorities may have\n // changed. Forget what we rendered before.\n this.__lastRenderedIndex = _infinity;\n previousLength = 0;\n // Note, the callback avoids closing over `this` so that the directive\n // can be gc'ed before the promise resolves; instead `this` is retrieved\n // from `weakThis`, which can break the hard reference in the closure when\n // the directive disconnects\n Promise.resolve(value).then(async (result) => {\n // If we're disconnected, wait until we're (maybe) reconnected\n // The while loop here handles the case that the connection state\n // thrashes, causing the pauser to resume and then get re-paused\n while (pauser.get()) {\n await pauser.get();\n }\n // If the callback gets here and there is no `this`, it means that the\n // directive has been disconnected and garbage collected and we don't\n // need to do anything else\n const _this = weakThis.deref();\n if (_this !== undefined) {\n const index = _this.__values.indexOf(value);\n // If state.values doesn't contain the value, we've re-rendered without\n // the value, so don't render it. Then, only render if the value is\n // higher-priority than what's already been rendered.\n if (index > -1 && index < _this.__lastRenderedIndex) {\n _this.__lastRenderedIndex = index;\n _this.setValue(result);\n }\n }\n });\n }\n return noChange;\n }\n disconnected() {\n this.__weakThis.disconnect();\n this.__pauser.pause();\n }\n reconnected() {\n this.__weakThis.reconnect(this);\n this.__pauser.resume();\n }\n}\n/**\n * Renders one of a series of values, including Promises, to a Part.\n *\n * Values are rendered in priority order, with the first argument having the\n * highest priority and the last argument having the lowest priority. If a\n * value is a Promise, low-priority values will be rendered until it resolves.\n *\n * The priority of values can be used to create placeholder content for async\n * data. For example, a Promise with pending content can be the first,\n * highest-priority, argument, and a non_promise loading indicator template can\n * be used as the second, lower-priority, argument. The loading indicator will\n * render immediately, and the primary content will render when the Promise\n * resolves.\n *\n * Example:\n *\n * ```js\n * const content = fetch('./content.txt').then(r => r.text());\n * html`${until(content, html`<span>Loading...</span>`)}`\n * ```\n */\nexport const until = directive(UntilDirective);\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\n// export type {UntilDirective};\n//# sourceMappingURL=until.js.map",
37
- "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nexport function when(condition, trueCase, falseCase) {\n return condition ? trueCase(condition) : falseCase?.(condition);\n}\n//# sourceMappingURL=when.js.map",
38
- "/**\n * Browser bundle entrypoint for non-module consumers.\n *\n * Load the built bundle from a plain `<script>` tag, or import from\n * `'@aegis-framework/pandora/browser'` for its side effects: the module\n * assigns the entire Pandora namespace to `window.Pandora` so globals like\n * `Pandora.Component` and `Pandora.html` are available without any import\n * statement.\n *\n * Module-based apps should import from the main entry\n * (`'@aegis-framework/pandora'`) instead. This file exists purely because\n * bundlers cannot yet expose an ESM module as a browser global on their\n * own; once/if Bun grows that capability, the file can go away.\n */\n\nimport * as Pandora from './index';\n\ndeclare global {\n interface Window {\n Pandora: typeof Pandora;\n }\n}\n\nif (typeof window === 'object') {\n window.Pandora = Pandora;\n}\n"
5
+ "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t=globalThis,i=t=>t,s=t.trustedTypes,e=s?s.createPolicy(\"lit-html\",{createHTML:t=>t}):void 0,h=\"$lit$\",o=`lit$${Math.random().toFixed(9).slice(2)}$`,n=\"?\"+o,r=`<${n}>`,l=document,c=()=>l.createComment(\"\"),a=t=>null===t||\"object\"!=typeof t&&\"function\"!=typeof t,u=Array.isArray,d=t=>u(t)||\"function\"==typeof t?.[Symbol.iterator],f=\"[ \\t\\n\\f\\r]\",v=/<(?:(!--|\\/[^a-zA-Z])|(\\/?[a-zA-Z][^>\\s]*)|(\\/?$))/g,_=/-->/g,m=/>/g,p=RegExp(`>|${f}(?:([^\\\\s\"'>=/]+)(${f}*=${f}*(?:[^ \\t\\n\\f\\r\"'\\`<>=]|(\"|')|))|$)`,\"g\"),g=/'/g,$=/\"/g,y=/^(?:script|style|textarea|title)$/i,x=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),b=x(1),w=x(2),T=x(3),E=Symbol.for(\"lit-noChange\"),A=Symbol.for(\"lit-nothing\"),C=new WeakMap,P=l.createTreeWalker(l,129);function V(t,i){if(!u(t)||!t.hasOwnProperty(\"raw\"))throw Error(\"invalid template strings array\");return void 0!==e?e.createHTML(i):i}const N=(t,i)=>{const s=t.length-1,e=[];let n,l=2===i?\"<svg>\":3===i?\"<math>\":\"\",c=v;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,f=0;for(;f<s.length&&(c.lastIndex=f,u=c.exec(s),null!==u);)f=c.lastIndex,c===v?\"!--\"===u[1]?c=_:void 0!==u[1]?c=m:void 0!==u[2]?(y.test(u[2])&&(n=RegExp(\"</\"+u[2],\"g\")),c=p):void 0!==u[3]&&(c=p):c===p?\">\"===u[0]?(c=n??v,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?p:'\"'===u[3]?$:g):c===$||c===g?c=p:c===_||c===m?c=v:(c=p,n=void 0);const x=c===p&&t[i+1].startsWith(\"/>\")?\" \":\"\";l+=c===v?s+r:d>=0?(e.push(a),s.slice(0,d)+h+s.slice(d)+o+x):s+o+(-2===d?i:x)}return[V(t,l+(t[s]||\"<?>\")+(2===i?\"</svg>\":3===i?\"</math>\":\"\")),e]};class S{constructor({strings:t,_$litType$:i},e){let r;this.parts=[];let l=0,a=0;const u=t.length-1,d=this.parts,[f,v]=N(t,i);if(this.el=S.createElement(f,e),P.currentNode=this.el.content,2===i||3===i){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=P.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(h)){const i=v[a++],s=r.getAttribute(t).split(o),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:l,name:e[2],strings:s,ctor:\".\"===e[1]?I:\"?\"===e[1]?L:\"@\"===e[1]?z:H}),r.removeAttribute(t)}else t.startsWith(o)&&(d.push({type:6,index:l}),r.removeAttribute(t));if(y.test(r.tagName)){const t=r.textContent.split(o),i=t.length-1;if(i>0){r.textContent=s?s.emptyScript:\"\";for(let s=0;s<i;s++)r.append(t[s],c()),P.nextNode(),d.push({type:2,index:++l});r.append(t[i],c())}}}else if(8===r.nodeType)if(r.data===n)d.push({type:2,index:l});else{let t=-1;for(;-1!==(t=r.data.indexOf(o,t+1));)d.push({type:7,index:l}),t+=o.length-1}l++}}static createElement(t,i){const s=l.createElement(\"template\");return s.innerHTML=t,s}}function M(t,i,s=t,e){if(i===E)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=a(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=M(t,h._$AS(t,i.values),h,e)),i}class R{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??l).importNode(i,!0);P.currentNode=e;let h=P.nextNode(),o=0,n=0,r=s[0];for(;void 0!==r;){if(o===r.index){let i;2===r.type?i=new k(h,h.nextSibling,this,t):1===r.type?i=new r.ctor(h,r.name,r.strings,this,t):6===r.type&&(i=new Z(h,this,t)),this._$AV.push(i),r=s[++n]}o!==r?.index&&(h=P.nextNode(),o++)}return P.currentNode=l,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class k{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=A,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=M(this,t,i),a(t)?t===A||null==t||\"\"===t?(this._$AH!==A&&this._$AR(),this._$AH=A):t!==this._$AH&&t!==E&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):d(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==A&&a(this._$AH)?this._$AA.nextSibling.data=t:this.T(l.createTextNode(t)),this._$AH=t}$(t){const{values:i,_$litType$:s}=t,e=\"number\"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=S.createElement(V(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else{const t=new R(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t}}_$AC(t){let i=C.get(t.strings);return void 0===i&&C.set(t.strings,i=new S(t)),i}k(t){u(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new k(this.O(c()),this.O(c()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e)}_$AR(t=this._$AA.nextSibling,s){for(this._$AP?.(!1,!0,s);t!==this._$AB;){const s=i(t).nextSibling;i(t).remove(),t=s}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class H{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=A,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||\"\"!==s[0]||\"\"!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=A}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=M(this,t,i,0),o=!a(t)||t!==this._$AH&&t!==E,o&&(this._$AH=t);else{const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=M(this,e[s+n],i,n),r===E&&(r=this._$AH[n]),o||=!a(r)||r!==this._$AH[n],r===A?t=A:t!==A&&(t+=(r??\"\")+h[n+1]),this._$AH[n]=r}o&&!e&&this.j(t)}j(t){t===A?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??\"\")}}class I extends H{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===A?void 0:t}}class L extends H{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==A)}}class z extends H{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5}_$AI(t,i=this){if((t=M(this,t,i,0)??A)===E)return;const s=this._$AH,e=t===A&&s!==A||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==A&&(s===A||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){\"function\"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class Z{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){M(this,t)}}const j={M:h,P:o,A:n,C:1,L:N,R,D:d,V:M,I:k,H,N:L,U:z,B:I,F:Z},B=t.litHtmlPolyfillSupport;B?.(S,k),(t.litHtmlVersions??=[]).push(\"3.3.3\");const D=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new k(i.insertBefore(c(),t),t,void 0,s??{})}return h._$AI(t),h};export{j as _$LH,b as html,T as mathml,E as noChange,A as nothing,D as render,w as svg};\n//# sourceMappingURL=lit-html.js.map\n",
6
+ "import{_$LH as o}from\"./lit-html.js\";\n/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const{I:t}=o,i=o=>o,n=o=>null===o||\"object\"!=typeof o&&\"function\"!=typeof o,e={HTML:1,SVG:2,MATHML:3},l=(o,t)=>void 0===t?void 0!==o?._$litType$:o?._$litType$===t,d=o=>null!=o?._$litType$?.h,c=o=>void 0!==o?._$litDirective$,f=o=>o?._$litDirective$,r=o=>void 0===o.strings,s=()=>document.createComment(\"\"),v=(o,n,e)=>{const l=o._$AA.parentNode,d=void 0===n?o._$AB:n._$AA;if(void 0===e){const i=l.insertBefore(s(),d),n=l.insertBefore(s(),d);e=new t(i,n,o,o.options)}else{const t=e._$AB.nextSibling,n=e._$AM,c=n!==o;if(c){let t;e._$AQ?.(o),e._$AM=o,void 0!==e._$AP&&(t=o._$AU)!==n._$AU&&e._$AP(t)}if(t!==d||c){let o=e._$AA;for(;o!==t;){const t=i(o).nextSibling;i(l).insertBefore(o,d),o=t}}}return e},u=(o,t,i=o)=>(o._$AI(t,i),o),m={},p=(o,t=m)=>o._$AH=t,M=o=>o._$AH,h=o=>{o._$AR(),o._$AA.remove()},j=o=>{o._$AR()};export{e as TemplateResultType,j as clearPart,M as getCommittedValue,f as getDirectiveClass,v as insertPart,d as isCompiledTemplateResult,c as isDirectiveResult,n as isPrimitive,r as isSingleExpression,l as isTemplateResult,h as removePart,u as setChildPartValue,p as setCommittedValue};\n//# sourceMappingURL=directive-helpers.js.map\n",
7
+ "/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}export{i as Directive,t as PartType,e as directive};\n//# sourceMappingURL=directive.js.map\n",
8
+ "import{isSingleExpression as i}from\"./directive-helpers.js\";import{Directive as t,PartType as e}from\"./directive.js\";export{directive}from\"./directive.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const s=(i,t)=>{const e=i._$AN;if(void 0===e)return!1;for(const i of e)i._$AO?.(t,!1),s(i,t);return!0},o=i=>{let t,e;do{if(void 0===(t=i._$AM))break;e=t._$AN,e.delete(i),i=t}while(0===e?.size)},r=i=>{for(let t;t=i._$AM;i=t){let e=t._$AN;if(void 0===e)t._$AN=e=new Set;else if(e.has(i))break;e.add(i),c(t)}};function h(i){void 0!==this._$AN?(o(this),this._$AM=i,r(this)):this._$AM=i}function n(i,t=!1,e=0){const r=this._$AH,h=this._$AN;if(void 0!==h&&0!==h.size)if(t)if(Array.isArray(r))for(let i=e;i<r.length;i++)s(r[i],!1),o(r[i]);else null!=r&&(s(r,!1),o(r));else s(this,i)}const c=i=>{i.type==e.CHILD&&(i._$AP??=n,i._$AQ??=h)};class f extends t{constructor(){super(...arguments),this._$AN=void 0}_$AT(i,t,e){super._$AT(i,t,e),r(this),this.isConnected=i._$AU}_$AO(i,t=!0){i!==this.isConnected&&(this.isConnected=i,i?this.reconnected?.():this.disconnected?.()),t&&(s(this,i),o(this))}setValue(t){if(i(this._$Ct))this._$Ct._$AI(t,this);else{const i=[...this._$Ct._$AH];i[this._$Ci]=t,this._$Ct._$AI(i,this,0)}}disconnected(){}reconnected(){}}export{f as AsyncDirective,t as Directive,e as PartType};\n//# sourceMappingURL=async-directive.js.map\n",
9
+ "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t=async(t,s)=>{for await(const i of t)if(!1===await s(i))return};class s{constructor(t){this.G=t}disconnect(){this.G=void 0}reconnect(t){this.G=t}deref(){return this.G}}class i{constructor(){this.Y=void 0,this.Z=void 0}get(){return this.Y}pause(){this.Y??=new Promise(t=>this.Z=t)}resume(){this.Z?.(),this.Y=this.Z=void 0}}export{i as Pauser,s as PseudoWeakRef,t as forAwaitOf};\n//# sourceMappingURL=private-async-helpers.js.map\n",
10
+ "import{noChange as t}from\"../lit-html.js\";import{AsyncDirective as i}from\"../async-directive.js\";import{PseudoWeakRef as s,Pauser as r,forAwaitOf as e}from\"./private-async-helpers.js\";import{directive as n}from\"../directive.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */class o extends i{constructor(){super(...arguments),this._$CK=new s(this),this._$CX=new r}render(i,s){return t}update(i,[s,r]){if(this.isConnected||this.disconnected(),s===this._$CJ)return t;this._$CJ=s;let n=0;const{_$CK:o,_$CX:h}=this;return e(s,async t=>{for(;h.get();)await h.get();const i=o.deref();if(void 0!==i){if(i._$CJ!==s)return!1;void 0!==r&&(t=r(t,n)),i.commitValue(t,n),n++}return!0}),t}commitValue(t,i){this.setValue(t)}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}const h=n(o);export{o as AsyncReplaceDirective,h as asyncReplace};\n//# sourceMappingURL=async-replace.js.map\n",
11
+ "import{directive as r,PartType as e}from\"../directive.js\";import{AsyncReplaceDirective as s}from\"./async-replace.js\";import{clearPart as t,insertPart as o,setChildPartValue as i}from\"../directive-helpers.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const c=r(class extends s{constructor(r){if(super(r),r.type!==e.CHILD)throw Error(\"asyncAppend can only be used in child expressions\")}update(r,e){return this._$Ctt=r,super.update(r,e)}commitValue(r,e){0===e&&t(this._$Ctt);const s=o(this._$Ctt);i(s,r)}});export{c as asyncAppend};\n//# sourceMappingURL=async-append.js.map\n",
12
+ "import{render as t,nothing as i}from\"../lit-html.js\";import{directive as s,Directive as e}from\"../directive.js\";import{isTemplateResult as o,getCommittedValue as n,setCommittedValue as r,insertPart as l,clearPart as c,isCompiledTemplateResult as u}from\"../directive-helpers.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const d=t=>u(t)?t._$litType$.h:t.strings,h=s(class extends e{constructor(t){super(t),this.et=new WeakMap}render(t){return[t]}update(s,[e]){const u=o(this.it)?d(this.it):null,h=o(e)?d(e):null;if(null!==u&&(null===h||u!==h)){const e=n(s).pop();let o=this.et.get(u);if(void 0===o){const s=document.createDocumentFragment();o=t(i,s),o.setConnected(!1),this.et.set(u,o)}r(o,[e]),l(o,void 0,e)}if(null!==h){if(null===u||u!==h){const t=this.et.get(h);if(void 0!==t){const i=n(t).pop();c(s),l(s,void 0,i),r(s,[i])}}this.it=e}else this.it=void 0;return this.render(e)}});export{h as cache};\n//# sourceMappingURL=cache.js.map\n",
13
+ "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst r=(r,o,t)=>{for(const t of o)if(t[0]===r)return(0,t[1])();return t?.()};export{r as choose};\n//# sourceMappingURL=choose.js.map\n",
14
+ "import{noChange as t}from\"../lit-html.js\";import{directive as s,Directive as i,PartType as r}from\"../directive.js\";\n/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const e=s(class extends i{constructor(t){if(super(t),t.type!==r.ATTRIBUTE||\"class\"!==t.name||t.strings?.length>2)throw Error(\"`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.\")}render(t){return\" \"+Object.keys(t).filter(s=>t[s]).join(\" \")+\" \"}update(s,[i]){if(void 0===this.st){this.st=new Set,void 0!==s.strings&&(this.nt=new Set(s.strings.join(\" \").split(/\\s/).filter(t=>\"\"!==t)));for(const t in i)i[t]&&!this.nt?.has(t)&&this.st.add(t);return this.render(i)}const r=s.element.classList;for(const t of this.st)t in i||(r.remove(t),this.st.delete(t));for(const t in i){const s=!!i[t];s===this.st.has(t)||this.nt?.has(t)||(s?(r.add(t),this.st.add(t)):(r.remove(t),this.st.delete(t)))}return t}});export{e as classMap};\n//# sourceMappingURL=class-map.js.map\n",
15
+ "import{noChange as r}from\"../lit-html.js\";import{directive as t,Directive as s}from\"../directive.js\";\n/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst e={},i=t(class extends s{constructor(){super(...arguments),this.ot=e}render(r,t){return t()}update(t,[s,e]){if(Array.isArray(s)){if(Array.isArray(this.ot)&&this.ot.length===s.length&&s.every((r,t)=>r===this.ot[t]))return r}else if(this.ot===s)return r;return this.ot=Array.isArray(s)?Array.from(s):s,this.render(s,e)}});export{i as guard};\n//# sourceMappingURL=guard.js.map\n",
16
+ "import{nothing as t}from\"../lit-html.js\";\n/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const o=o=>o??t;export{o as ifDefined};\n//# sourceMappingURL=if-defined.js.map\n",
17
+ "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nfunction*o(o,t){const f=\"function\"==typeof t;if(void 0!==o){let i=-1;for(const n of o)i>-1&&(yield f?t(i):t),i++,yield n}}export{o as join};\n//# sourceMappingURL=join.js.map\n",
18
+ "import{nothing as r}from\"../lit-html.js\";import{directive as t,Directive as e}from\"../directive.js\";import{setCommittedValue as s}from\"../directive-helpers.js\";\n/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const i=t(class extends e{constructor(){super(...arguments),this.key=r}render(r,t){return this.key=r,t}update(r,[t,e]){return t!==this.key&&(s(r),this.key=t),e}});export{i as keyed};\n//# sourceMappingURL=keyed.js.map\n",
19
+ "import{noChange as r,nothing as e}from\"../lit-html.js\";import{directive as i,Directive as t,PartType as n}from\"../directive.js\";import{isSingleExpression as o,setCommittedValue as s}from\"../directive-helpers.js\";\n/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const l=i(class extends t{constructor(r){if(super(r),r.type!==n.PROPERTY&&r.type!==n.ATTRIBUTE&&r.type!==n.BOOLEAN_ATTRIBUTE)throw Error(\"The `live` directive is not allowed on child or event bindings\");if(!o(r))throw Error(\"`live` bindings can only contain a single expression\")}render(r){return r}update(i,[t]){if(t===r||t===e)return t;const o=i.element,l=i.name;if(i.type===n.PROPERTY){if(t===o[l])return r}else if(i.type===n.BOOLEAN_ATTRIBUTE){if(!!t===o.hasAttribute(l))return r}else if(i.type===n.ATTRIBUTE&&o.getAttribute(l)===t+\"\")return r;return s(i),t}});export{l as live};\n//# sourceMappingURL=live.js.map\n",
20
+ "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nfunction*o(o,f){if(void 0!==o){let i=0;for(const t of o)yield f(t,i++)}}export{o as map};\n//# sourceMappingURL=map.js.map\n",
21
+ "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nfunction*o(o,t,e=1){const i=void 0===t?0:o;t??=o;for(let o=i;e>0?o<t:t<o;o+=e)yield o}export{o as range};\n//# sourceMappingURL=range.js.map\n",
22
+ "import{nothing as t}from\"../lit-html.js\";import{AsyncDirective as i}from\"../async-directive.js\";import{directive as s}from\"../directive.js\";\n/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const e=()=>new h;class h{}const o=new WeakMap,n=s(class extends i{render(i){return t}update(i,[s]){const e=s!==this.G;return e&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.G=s,this.ht=i.options?.host,this.rt(this.ct=i.element)),t}rt(t){if(void 0!==this.G)if(this.isConnected||(t=void 0),\"function\"==typeof this.G){const i=this.ht??globalThis;let s=o.get(i);void 0===s&&(s=new WeakMap,o.set(i,s)),void 0!==s.get(this.G)&&this.G.call(this.ht,void 0),s.set(this.G,t),void 0!==t&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return\"function\"==typeof this.G?o.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});export{e as createRef,n as ref};\n//# sourceMappingURL=ref.js.map\n",
23
+ "import{noChange as e}from\"../lit-html.js\";import{directive as s,Directive as t,PartType as r}from\"../directive.js\";import{getCommittedValue as l,setChildPartValue as o,insertPart as i,removePart as n,setCommittedValue as f}from\"../directive-helpers.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst u=(e,s,t)=>{const r=new Map;for(let l=s;l<=t;l++)r.set(e[l],l);return r},c=s(class extends t{constructor(e){if(super(e),e.type!==r.CHILD)throw Error(\"repeat() can only be used in text expressions\")}dt(e,s,t){let r;void 0===t?t=s:void 0!==s&&(r=s);const l=[],o=[];let i=0;for(const s of e)l[i]=r?r(s,i):i,o[i]=t(s,i),i++;return{values:o,keys:l}}render(e,s,t){return this.dt(e,s,t).values}update(s,[t,r,c]){const d=l(s),{values:p,keys:a}=this.dt(t,r,c);if(!Array.isArray(d))return this.ut=a,p;const h=this.ut??=[],v=[];let m,y,x=0,j=d.length-1,k=0,w=p.length-1;for(;x<=j&&k<=w;)if(null===d[x])x++;else if(null===d[j])j--;else if(h[x]===a[k])v[k]=o(d[x],p[k]),x++,k++;else if(h[j]===a[w])v[w]=o(d[j],p[w]),j--,w--;else if(h[x]===a[w])v[w]=o(d[x],p[w]),i(s,v[w+1],d[x]),x++,w--;else if(h[j]===a[k])v[k]=o(d[j],p[k]),i(s,d[x],d[j]),j--,k++;else if(void 0===m&&(m=u(a,k,w),y=u(h,x,j)),m.has(h[x]))if(m.has(h[j])){const e=y.get(a[k]),t=void 0!==e?d[e]:null;if(null===t){const e=i(s,d[x]);o(e,p[k]),v[k]=e}else v[k]=o(t,p[k]),i(s,d[x],t),d[e]=null;k++}else n(d[j]),j--;else n(d[x]),x++;for(;k<=w;){const e=i(s,v[w+1]);o(e,p[k]),v[k++]=e}for(;x<=j;){const e=d[x++];null!==e&&n(e)}return this.ut=a,f(s,v),e}});export{c as repeat};\n//# sourceMappingURL=repeat.js.map\n",
24
+ "import{noChange as t}from\"../lit-html.js\";import{directive as e,Directive as r,PartType as s}from\"../directive.js\";\n/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const n=\"important\",i=\" !\"+n,o=e(class extends r{constructor(t){if(super(t),t.type!==s.ATTRIBUTE||\"style\"!==t.name||t.strings?.length>2)throw Error(\"The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.\")}render(t){return Object.keys(t).reduce((e,r)=>{const s=t[r];return null==s?e:e+`${r=r.includes(\"-\")?r:r.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,\"-$&\").toLowerCase()}:${s};`},\"\")}update(e,[r]){const{style:s}=e.element;if(void 0===this.ft)return this.ft=new Set(Object.keys(r)),this.render(r);for(const t of this.ft)null==r[t]&&(this.ft.delete(t),t.includes(\"-\")?s.removeProperty(t):s[t]=null);for(const t in r){const e=r[t];if(null!=e){this.ft.add(t);const r=\"string\"==typeof e&&e.endsWith(i);t.includes(\"-\")||r?s.setProperty(t,r?e.slice(0,-11):e,r?n:\"\"):s[t]=e}}return t}});export{o as styleMap};\n//# sourceMappingURL=style-map.js.map\n",
25
+ "import{noChange as t}from\"../lit-html.js\";import{directive as r,Directive as e,PartType as n}from\"../directive.js\";\n/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const o=r(class extends e{constructor(t){if(super(t),t.type!==n.CHILD)throw Error(\"templateContent can only be used in child bindings\")}render(r){return this.vt===r?t:(this.vt=r,document.importNode(r.content,!0))}});export{o as templateContent};\n//# sourceMappingURL=template-content.js.map\n",
26
+ "import{nothing as t,noChange as i}from\"../lit-html.js\";import{directive as r,Directive as s,PartType as n}from\"../directive.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */class e extends s{constructor(i){if(super(i),this.it=t,i.type!==n.CHILD)throw Error(this.constructor.directiveName+\"() can only be used in child bindings\")}render(r){if(r===t||null==r)return this._t=void 0,this.it=r;if(r===i)return r;if(\"string\"!=typeof r)throw Error(this.constructor.directiveName+\"() called with a non-string value\");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName=\"unsafeHTML\",e.resultType=1;const o=r(e);export{e as UnsafeHTMLDirective,o as unsafeHTML};\n//# sourceMappingURL=unsafe-html.js.map\n",
27
+ "import{directive as s}from\"../directive.js\";import{UnsafeHTMLDirective as t}from\"./unsafe-html.js\";\n/**\n * @license\n * Copyright 2024 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */class e extends t{}e.directiveName=\"unsafeMath\",e.resultType=3;const o=s(e);export{o as unsafeMathML};\n//# sourceMappingURL=unsafe-mathml.js.map\n",
28
+ "import{directive as s}from\"../directive.js\";import{UnsafeHTMLDirective as e}from\"./unsafe-html.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */class t extends e{}t.directiveName=\"unsafeSVG\",t.resultType=2;const o=s(t);export{o as unsafeSVG};\n//# sourceMappingURL=unsafe-svg.js.map\n",
29
+ "import{noChange as t}from\"../lit-html.js\";import{isPrimitive as s}from\"../directive-helpers.js\";import{AsyncDirective as i}from\"../async-directive.js\";import{PseudoWeakRef as e,Pauser as r}from\"./private-async-helpers.js\";import{directive as o}from\"../directive.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */const n=t=>!s(t)&&\"function\"==typeof t.then,h=1073741823;class c extends i{constructor(){super(...arguments),this._$Cwt=h,this._$Cbt=[],this._$CK=new e(this),this._$CX=new r}render(...s){return s.find(t=>!n(t))??t}update(s,i){const e=this._$Cbt;let r=e.length;this._$Cbt=i;const o=this._$CK,c=this._$CX;this.isConnected||this.disconnected();for(let t=0;t<i.length&&!(t>this._$Cwt);t++){const s=i[t];if(!n(s))return this._$Cwt=t,s;t<r&&s===e[t]||(this._$Cwt=h,r=0,Promise.resolve(s).then(async t=>{for(;c.get();)await c.get();const i=o.deref();if(void 0!==i){const e=i._$Cbt.indexOf(s);e>-1&&e<i._$Cwt&&(i._$Cwt=e,i.setValue(t))}}))}return t}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}const m=o(c);export{c as UntilDirective,m as until};\n//# sourceMappingURL=until.js.map\n",
30
+ "/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nfunction n(n,r,t){return n?r(n):t?.(n)}export{n as when};\n//# sourceMappingURL=when.js.map\n",
31
+ "/**\n * What a string render keeps from the markup it replaces: the element that\n * had focus and the scroll positions of the elements inside the component.\n *\n * A string render rebuilds the component's content, so every element in it\n * is new and the browser forgets which one had focus and how far each was\n * scrolled. Before the render, Pandora notes how to find each of them again;\n * after it, it finds the new element in the same place and gives it back its\n * focus, text selection and scroll position. lit-html renders update the\n * elements they already have, so they don't need this.\n *\n * An element is found again by its `data-key` attribute, then its `id`, then\n * its position among its parent's children (checked against its tag name).\n * Give elements whose position can change a `data-key`.\n */\n\n/** One step from a parent to a child: the child's position and tag name. */\ninterface PathStep {\n index: number;\n tagName: string;\n}\n\n/** How an element is found again after a render replaced it. */\ninterface ElementLocator {\n /** A `data-key` or `id` selector, when the element has one. */\n selector: string | null;\n\n /** The steps from the render root down to the element. */\n path: PathStep[];\n}\n\n/** The text selection of a field, to put back after a render. */\ninterface FieldSelection {\n start: number;\n end: number;\n direction: 'forward' | 'backward' | 'none';\n}\n\n/** A scrolled element and how far it was scrolled. */\ninterface ScrollPosition {\n locator: ElementLocator;\n top: number;\n left: number;\n}\n\nconst locatorOf = (root: ParentNode, element: Element): ElementLocator | null => {\n const key = element.getAttribute('data-key');\n let selector: string | null = null;\n\n if (key !== null) {\n selector = `[data-key=\"${CSS.escape(key)}\"]`;\n } else if (element.id !== '') {\n selector = `#${CSS.escape(element.id)}`;\n }\n\n const path: PathStep[] = [];\n let current: Element = element;\n\n while (true) {\n const parent = current.parentNode as ParentNode | null;\n\n if (parent === null) {\n return null;\n }\n\n path.unshift({ index: Array.prototype.indexOf.call(parent.children, current), tagName: current.tagName });\n\n if (parent === root) {\n return { selector, path };\n }\n\n current = parent as Element;\n }\n};\n\nconst findElement = (root: ParentNode, locator: ElementLocator): Element | null => {\n if (locator.selector !== null) {\n const found = root.querySelector(locator.selector);\n\n if (found !== null) {\n return found;\n }\n }\n\n let current: ParentNode = root;\n\n for (const step of locator.path) {\n const child: Element | undefined = current.children[step.index];\n\n if (child === undefined || child.tagName !== step.tagName) {\n return null;\n }\n\n current = child;\n }\n\n return current === root ? null : current as Element;\n};\n\nconst selectionOf = (element: Element): FieldSelection | null => {\n if (!(element instanceof HTMLInputElement) && !(element instanceof HTMLTextAreaElement)) {\n return null;\n }\n\n // Inputs without a text selection (checkboxes, numbers…) report null.\n if (element.selectionStart === null || element.selectionEnd === null) {\n return null;\n }\n\n return { start: element.selectionStart, end: element.selectionEnd, direction: element.selectionDirection ?? 'none' };\n};\n\nconst activeElementIn = (root: ParentNode): Element | null => {\n if (root instanceof ShadowRoot) {\n return root.activeElement;\n }\n\n const active = document.activeElement;\n\n return active !== null && active !== root && root.contains(active) ? active : null;\n};\n\n/**\n * Notes the focused element and the scroll positions inside `root`, and\n * returns a function that restores them once the render has replaced the\n * markup. Focus is only given back when the render took it away, so a render\n * never steals focus from elsewhere on the page.\n *\n * @param root - Where the component renders: the element itself, or its shadow root.\n * @param scrolled - The elements inside `root` that have been scrolled.\n * @returns A function to call right after the render.\n *\n * @internal\n */\nexport const keepFocusAndScroll = (root: ParentNode, scrolled: Set<Element>): (() => void) => {\n const active = activeElementIn(root);\n const focusLocator = active === null ? null : locatorOf(root, active);\n const selection = active === null ? null : selectionOf(active);\n const positions: ScrollPosition[] = [];\n\n for (const element of scrolled) {\n scrolled.delete(element);\n\n if (!root.contains(element) || (element.scrollTop === 0 && element.scrollLeft === 0)) {\n continue;\n }\n\n const locator = locatorOf(root, element);\n\n if (locator !== null) {\n positions.push({ locator, top: element.scrollTop, left: element.scrollLeft });\n }\n }\n\n return () => {\n for (const { locator, top, left } of positions) {\n const element = findElement(root, locator);\n\n if (element !== null) {\n element.scrollTop = top;\n element.scrollLeft = left;\n scrolled.add(element);\n }\n }\n\n if (focusLocator === null || active?.isConnected) {\n return;\n }\n\n const target = findElement(root, focusLocator);\n\n if (!(target instanceof HTMLElement || target instanceof SVGElement)) {\n return;\n }\n\n target.focus({ preventScroll: true });\n\n if (selection !== null && (target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement)) {\n try {\n target.setSelectionRange(selection.start, selection.end, selection.direction);\n } catch {\n // The new field's type doesn't take a selection.\n }\n }\n };\n};\n",
32
+ "import type { TemplateResult } from 'lit-html';\n\nimport type { CSSObject, DecoratorEffect, DecoratorInstance, ReactiveOptions } from './Types.js';\n\n/** Metadata slot: array of attribute names that `@Attribute` wants observed on the element. @internal */\nexport const PROP_ATTRIBUTES: unique symbol = Symbol('pandora:propAttributes');\n\n/** Metadata slot: per-instance effect functions to replay when a class is evolved or lazily registered. @internal */\nexport const DECORATOR_EFFECTS: unique symbol = Symbol('pandora:decoratorEffects');\n\n/** Metadata slot: teardown callbacks attached to an instance so the outgoing class can unwind before an evolve swap. @internal */\nexport const DECORATOR_TEARDOWNS: unique symbol = Symbol('pandora:decoratorTeardowns');\n\n/** Metadata slot: `@Watch` registrations pairing a watched property name with the handler method name. @internal */\nexport const WATCH_HANDLERS: unique symbol = Symbol('pandora:watchHandlers');\n\n/** Metadata slot: set of property names declared reactive via `@State`, `@Attribute`, or `@Property` — used to validate `@Watch` targets. @internal */\nexport const REACTIVE_FIELDS: unique symbol = Symbol('pandora:reactiveFields');\n\n/** Metadata slot: array of `@Listen` registrations describing event name, target resolver, and options. @internal */\nexport const LISTEN_HANDLERS: unique symbol = Symbol('pandora:listenHandlers');\n\n/** Metadata slot: resolved `@Style` output (stylesheet text and encapsulation hints) attached by the style decorator. @internal */\nexport const STYLE_METADATA: unique symbol = Symbol('pandora:styleMetadata');\n\n/** Metadata slot: map from observed attribute names to the handlers that sync them into the instance field. @internal */\nexport const ATTR_HANDLERS: unique symbol = Symbol('pandora:attrHandlers');\n\n/** Metadata slot: per-field `@Subscribe` registrations that wire a store/observable into a property. @internal */\nexport const SUBSCRIBE_HANDLERS: unique symbol = Symbol('pandora:subscribeHandlers');\n\n/** Instance slot: attribute writes that wait for the element to connect, keyed by attribute name. @internal */\nexport const PENDING_ATTRIBUTE_WRITES: unique symbol = Symbol('pandora:pendingAttributeWrites');\n\n// Stable symbol registry for `reactive()`. Repeat calls on the same property\n// name must reuse the same hidden slot — otherwise reconnecting a field (for\n// example, after an evolve) would orphan the previous value behind a fresh\n// symbol and the getter would read `undefined`.\nconst REACTIVE_KEYS = new Map<string, symbol>();\n\n/**\n * Invokes a callback and always returns a Promise, regardless of whether the\n * callback itself is sync or async. Lets hooks that may or may not be\n * declared `async` be awaited uniformly without branching at each call site.\n *\n * @internal\n */\nexport const callAsync = <T>(callable: (...args: any[]) => T, context: any, ...args: any[]): Promise<T> => {\n try {\n const result = callable.apply(context, args);\n return result instanceof Promise ? result : Promise.resolve(result);\n } catch (e) {\n return Promise.reject(e);\n }\n};\n\n/**\n * Duck-types a value as a lit-html `TemplateResult` by looking for its\n * `_$litType$` brand. We avoid `instanceof` so the check survives across\n * realms and when multiple lit-html copies coexist in the same page.\n *\n * @internal\n */\nexport const isTemplateResult = (value: unknown): value is TemplateResult => {\n return (value !== null && typeof value === 'object' && '_$litType$' in (value as object));\n};\n\n/**\n * Flattens a nested `CSSObject` into a CSS string for injection at render\n * time. When `encapsulation` is a tag selector (light-DOM mode), selectors\n * are scoped under it — `:host` maps to the tag, `&`-prefixed rules nest\n * inline, at-rules pass through untouched, and everything else is prefixed.\n *\n * @internal\n */\nexport const deserializeCSS = (object: CSSObject, encapsulation: string = '', level: number = 0): string => {\n const keys = Object.keys(object);\n let css = '';\n\n for (const key of keys) {\n const value = object[key];\n\n if (typeof value === 'object' && value !== null) {\n if (encapsulation && !key.startsWith('@')) {\n if (key.startsWith('&')) {\n css += `${key.replace(/&/g, encapsulation)} {\\n`;\n } else if (key === ':host') {\n // In light DOM there is no shadow root, so `:host` is rewritten to\n // the component's tag selector to preserve the same targeting.\n css += `${encapsulation} {\\n`;\n } else {\n css += `${encapsulation} ${key} {\\n`;\n }\n } else {\n css += `${key} {\\n`;\n }\n\n const properties = Object.keys(value);\n\n for (const property of properties) {\n css += '\\t'.repeat(level);\n const propValue = value[property];\n\n if (typeof propValue === 'object' && propValue !== null) {\n const temp: CSSObject = {};\n temp[property] = propValue;\n css += deserializeCSS(temp, encapsulation, level + 1);\n } else {\n css += `\\t${property}: ${propValue};\\n`;\n }\n }\n\n css += '}\\n';\n } else {\n css += '\\t'.repeat(level);\n css += `\\t${key}: ${value};\\n`;\n }\n }\n\n return css;\n};\n\n/**\n * Register a per-instance effect to replay on hot swaps.\n *\n * The Registry runs these effects on live instances when a class is swapped\n * in with `Registry.evolve()` or a `Registry.lazy()` placeholder loads its\n * real implementation, so a custom decorator keeps working across both.\n * Effects do **not** run when an instance is first constructed: install the\n * same behavior from `context.addInitializer` too, as shown below.\n *\n * @param meta - The decorator-context metadata object (`context.metadata`).\n * @param effect - A function that receives the component instance.\n *\n * @example\n * function Logged(_target: undefined, context: ClassFieldDecoratorContext) {\n * const propertyKey = String(context.name);\n * const install = (instance: DecoratorInstance) => {\n * reactive(instance, propertyKey, { onChange: (value) => console.log(propertyKey, value) });\n * };\n *\n * // Replayed by evolve() / lazy() on live instances...\n * addDecoratorEffect(context.metadata, install);\n * // ...and run for every newly constructed instance.\n * context.addInitializer(function () {\n * install(this as DecoratorInstance);\n * });\n * }\n */\nexport const addDecoratorEffect = (meta: Record<symbol, unknown>, effect: DecoratorEffect): void => {\n if (!Object.hasOwn(meta, DECORATOR_EFFECTS)) {\n const inherited = meta[DECORATOR_EFFECTS] as DecoratorEffect[] | undefined;\n meta[DECORATOR_EFFECTS] = inherited ? [...inherited] : [];\n }\n\n (meta[DECORATOR_EFFECTS] as DecoratorEffect[]).push(effect);\n};\n\n/**\n * Register a teardown function for a reactive binding on a component instance.\n *\n * The function runs when the component's class is evolved or lazily\n * replaced — letting the incoming implementation tear down subscriptions,\n * observers, or listeners set up by the previous class before new decorator\n * effects install theirs.\n *\n * Teardowns registered via this helper do NOT automatically run on\n * disconnect. If your decorator installs listeners or subscriptions that\n * must unwind on disconnect, remove them from the component's own\n * `willUnmount()` / `didUnmount()` path.\n *\n * @param instance - The component instance to attach the teardown to.\n * @param teardown - A function that releases any resources held by the decorator when the class is evolved or replaced.\n *\n * @example\n * function applyResizeAware(instance: DecoratorInstance) {\n * const observer = new ResizeObserver(() => {});\n * observer.observe(instance);\n * // Runs when the class is evolved or lazily replaced, so the incoming\n * // implementation can install its own observer cleanly.\n * addTeardown(instance, () => observer.disconnect());\n * }\n */\nexport const addTeardown = (instance: DecoratorInstance, teardown: () => void): void => {\n if (!instance[DECORATOR_TEARDOWNS]) {\n instance[DECORATOR_TEARDOWNS] = [];\n }\n\n (instance[DECORATOR_TEARDOWNS] as (() => void)[]).push(teardown);\n};\n\n/**\n * Writes the attributes an element couldn't have while it was constructed.\n * `document.createElement()` throws when a new element already has\n * attributes, so `@Attribute` and `@Property({ attribute })` defaults wait\n * for `connectedCallback`, which calls this before the first render.\n *\n * @internal\n */\nexport const writePendingAttributes = (instance: object): void => {\n const slots = instance as Record<symbol, unknown>;\n const pending = slots[PENDING_ATTRIBUTE_WRITES] as Map<string, () => void> | undefined;\n\n if (pending === undefined) {\n return;\n }\n\n delete slots[PENDING_ATTRIBUTE_WRITES];\n\n for (const write of pending.values()) {\n write();\n }\n};\n\n/**\n * The names of a component class's reactive fields: the ones declared with\n * `@State`, `@Property` or `@Attribute`, inherited ones included. Fields made\n * reactive at runtime with `reactive()` aren't listed, since they belong to\n * an instance, not to the class.\n *\n * Use it to check a class against a contract (does it declare `value`?),\n * to build tooling, or to warn about a name before an instance exists.\n *\n * @param componentClass - A component class, decorated or not.\n * @returns A new set of field names; empty when the class declares none.\n *\n * @example\n * class Counter extends Component {\n * @State() count = 0;\n * @Attribute() step = 1;\n * }\n *\n * reactiveFields(Counter); // Set { 'count', 'step' }\n */\nexport const reactiveFields = (componentClass: abstract new (...args: any[]) => unknown): Set<string> => {\n const metadata = (componentClass as unknown as Record<symbol, Record<symbol, unknown> | undefined>)[Symbol.metadata];\n const fields = metadata?.[REACTIVE_FIELDS] as Set<string> | undefined;\n\n return new Set(fields ?? []);\n};\n\n/**\n * One reactive write recorded while a `batch()` is open.\n *\n * @internal\n */\nexport interface BatchedChange {\n property: string;\n oldValue: unknown;\n newValue: unknown;\n shouldRender: boolean;\n source: string;\n}\n\n/**\n * Records a reactive write made inside `batch()` so its `@Watch` callbacks\n * and `didChange` run once when the batch closes. Repeated writes to the\n * same field collapse into a single first-to-last change. Returns `false`\n * (recording nothing) when the instance isn't batching, so the caller\n * notifies right away instead.\n *\n * @internal\n */\nexport const recordBatchedChange = (instance: object, change: BatchedChange): boolean => {\n const component = instance as { _batching?: boolean; _batchedChanges?: BatchedChange[] };\n\n if (!component._batching || !component._batchedChanges) {\n return false;\n }\n\n const existing = component._batchedChanges.find((recorded) => recorded.property === change.property);\n\n if (existing) {\n existing.newValue = change.newValue;\n\n if (change.shouldRender) {\n existing.shouldRender = true;\n }\n } else {\n component._batchedChanges.push({ ...change });\n }\n\n return true;\n};\n\n/**\n * Returns the hidden-slot symbol used to back a reactive field named\n * `propertyKey`, creating it on first use. The symbol is shared across all\n * instances so `reactive()` can be called more than once for the same\n * property without losing its stored value.\n *\n * @internal\n */\nconst getReactiveKey = (propertyKey: string): symbol => {\n let key = REACTIVE_KEYS.get(propertyKey);\n\n if (!key) {\n key = Symbol(`__pandora_reactive_${propertyKey}`);\n REACTIVE_KEYS.set(propertyKey, key);\n }\n\n return key;\n};\n\n/**\n * Make a plain field on a component instance reactive at runtime.\n *\n * This is the imperative escape hatch for `@State`: use it when you cannot\n * reach for decorators (for example, in environments without decorator\n * support, or when wiring up a field from a constructor or custom\n * decorator). The field keeps its current value (unless you pass\n * `initialValue`), but writes now trigger `@Watch` handlers, `didChange`,\n * and an auto-rerender unless you opt out. Writes inside `batch()` defer\n * `@Watch` and `didChange` until the batch closes, like decorated fields.\n *\n * @param instance - The component instance that owns the field.\n * @param propertyKey - The field name to make reactive.\n * @param options - Optional initial value, change callback, equality check, or `render: false` to skip auto-rerender.\n *\n * @example\n * // Without decorators: make a plain field reactive from the constructor.\n * class MyCounter extends Component {\n * count = 0;\n *\n * constructor() {\n * super();\n * reactive(this, 'count'); // keeps the initial 0, re-renders on change\n * }\n * }\n */\nexport const reactive = (\n instance: DecoratorInstance,\n propertyKey: string,\n options: ReactiveOptions = {},\n): void => {\n const valueKey = getReactiveKey(propertyKey);\n const equals = options.equals ?? ((a: unknown, b: unknown) => a === b);\n const shouldRender = options.render !== false;\n\n // Safe on repeat calls: if the slot already holds a value (e.g. reconnection after evolve) we leave the user's last write in place.\n if (instance[valueKey] === undefined) {\n if (options.initialValue !== undefined) {\n instance[valueKey] = options.initialValue;\n } else {\n // Rescue the plain field's current value (a class field initializer,\n // say) before the accessor below replaces the data property.\n const ownDescriptor = Object.getOwnPropertyDescriptor(instance, propertyKey);\n\n if (ownDescriptor && 'value' in ownDescriptor) {\n instance[valueKey] = ownDescriptor.value;\n }\n }\n }\n\n Object.defineProperty(instance, propertyKey, {\n get() {\n return instance[valueKey];\n },\n set(newVal: unknown) {\n const oldVal = instance[valueKey];\n\n if (equals(oldVal, newVal)) {\n return;\n }\n\n instance[valueKey] = newVal;\n\n if (options.onChange) {\n options.onChange(newVal, oldVal);\n }\n\n if (recordBatchedChange(instance, { property: propertyKey, oldValue: oldVal, newValue: newVal, shouldRender, source: 'reactive' })) {\n return;\n }\n\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = ((instance.constructor as any)[Symbol.metadata]) as Record<symbol, unknown> | undefined;\n const entries = meta?.[WATCH_HANDLERS] as Array<{ property: string; methodName: string }> | undefined;\n\n if (entries) {\n for (const entry of entries) {\n if (entry.property === propertyKey) {\n const method = (instance as any)[entry.methodName];\n\n if (typeof method === 'function') {\n method.call(instance, newVal, oldVal);\n }\n }\n }\n }\n }\n\n if (typeof (instance as any).didChange === 'function') {\n (instance as any).didChange(propertyKey, oldVal, newVal, 'reactive');\n }\n\n if (shouldRender && typeof (instance as any)._queueRender === 'function') {\n (instance as any)._queueRender();\n }\n },\n enumerable: true,\n configurable: true,\n });\n};\n\n/**\n * Coerces a raw attribute string into its JavaScript value: `null` becomes\n * `undefined`, the empty string and `\"true\"` become `true`, `\"false\"` becomes\n * `false`, numeric strings become numbers, and everything else is passed\n * through as a string. Used when `@Attribute` syncs HTML into a reactive field.\n *\n * @internal\n */\nexport const parseAttributeValue = (value: string | null): unknown => {\n if (value === null) {\n return undefined;\n }\n\n if (value === '' || value === 'true') {\n return true;\n }\n\n if (value === 'false') {\n return false;\n }\n\n const trimmed = value.trim();\n\n if (/^[+-]?(?:0|[1-9]\\d*)(?:\\.\\d+)?$/.test(trimmed)) {\n const asNumber = Number(trimmed);\n\n if (Number.isFinite(asNumber)) {\n return asNumber;\n }\n }\n\n return value;\n};\n\n/**\n * Resolves the `target` option of `@Listen` to an actual `EventTarget`. The\n * strings `\"window\"` and `\"document\"` map to their globals, `\"self\"` (or an\n * omitted option) returns the host element, and any other string is treated\n * as a CSS selector. Selectors are routed through the component's own\n * `query()` when provided so they resolve against the host's subtree (light\n * or shadow) rather than the whole document.\n *\n * @internal\n */\nexport const resolveListenerTarget = (\n host: HTMLElement,\n targetOption?: string,\n query?: (selector: string) => Element | null,\n): EventTarget | null => {\n if (targetOption === 'window') {\n return window;\n }\n\n if (targetOption === 'document') {\n return document;\n }\n\n if (targetOption && targetOption !== 'self') {\n return query ? query(targetOption) : host.querySelector(targetOption);\n }\n\n return host;\n};\n",
33
+ "import { nothing, render as litRender, type TemplateResult } from 'lit-html';\n\nimport { keepFocusAndScroll } from './RenderState.js';\nimport type { AttrHandler, Style, SubscribeHandler, TemplateFunction, TemplateValue } from './Types.js';\nimport {\n ATTR_HANDLERS,\n callAsync,\n deserializeCSS,\n isTemplateResult,\n LISTEN_HANDLERS,\n parseAttributeValue,\n PROP_ATTRIBUTES,\n resolveListenerTarget,\n STYLE_METADATA,\n SUBSCRIBE_HANDLERS,\n WATCH_HANDLERS,\n writePendingAttributes,\n} from './Util.js';\n\n/** The connected instances of each component class, by class. */\nconst CONNECTED_INSTANCES = new WeakMap<object, Set<Component>>();\n\n/** What `connectedInstances()` returns for a class with none. */\nconst NO_INSTANCES: ReadonlySet<never> = new Set();\n\n/**\n * Takes the properties an element was given before its class was defined:\n * `element.items = [...]` on an element the parser created before the\n * script that defines it ran. The class's own fields would hide them, so\n * they're taken off the element before any field is initialized, and\n * `connectedCallback` assigns them again, through the class's setters.\n */\nconst takeValuesBeforeUpgrade = (element: HTMLElement): Map<string, unknown> | undefined => {\n const keys = Object.keys(element);\n\n if (keys.length === 0) {\n return undefined;\n }\n\n const slots = element as unknown as Record<string, unknown>;\n const values = new Map<string, unknown>();\n\n for (const key of keys) {\n values.set(key, slots[key]);\n delete slots[key];\n }\n\n return values;\n};\n\n/**\n * The base class every Pandora component extends.\n *\n * `Component` is a thin layer over the native `HTMLElement` that wires up\n * Pandora's reactive lifecycle: subclasses declare state with decorators like\n * `@State`, `@Attribute`, and `@Property`, and the base class takes care of\n * registering the tag, batching state changes into microtask-scheduled\n * renders, managing attributes, and running mount and unmount hooks. Most of\n * the time you only implement `render()` and let the decorators do the rest.\n *\n * Rendering is batched on the microtask queue. Multiple synchronous property\n * updates in the same tick coalesce into a single `render()` call. If you\n * need a synchronous render, call `forceRender()`; if you need to group\n * changes explicitly, wrap them in `batch()`.\n *\n * @example\n * import { Component, Register, State, html } from '@aegis-framework/pandora';\n *\n * @Register('my-greeting')\n * class MyGreeting extends Component {\n * @State() name = 'world';\n *\n * render() {\n * return html`<p>Hello, ${this.name}.</p>`;\n * }\n * }\n *\n * // <my-greeting></my-greeting>\n */\nclass Component extends HTMLElement {\n /**\n * Values the element was given before its class was defined. Declared\n * first, so it's taken before any field initializer can hide them.\n *\n * @internal\n */\n private _valuesBeforeUpgrade: Map<string, unknown> | undefined = takeValuesBeforeUpgrade(this);\n\n /**\n * The elements inside the component that have been scrolled, so a string\n * render can scroll their replacements back to the same place.\n *\n * @internal\n */\n protected _scrolledElements: Set<Element> = new Set();\n\n /**\n * The class this instance was counted under in `connectedInstances()`\n * while it's connected.\n *\n * @internal\n */\n private _connectedAs?: object;\n\n /**\n * The inner HTML the component was mounted with, captured before the first\n * render runs. Exposed publicly as `slotContent`.\n *\n * @internal\n */\n protected _children: string;\n\n /**\n * Tracks whether the element is currently in the DOM. Flipped in\n * `connectedCallback` / `disconnectedCallback` and surfaced publicly as\n * `isConnected`.\n *\n * @internal\n */\n protected _connected: boolean;\n\n /**\n * Flips to `true` once the first mount (including `didMount` and the initial\n * render) has finished. Surfaced publicly as `isReady`.\n *\n * @internal\n */\n protected _isReady: boolean;\n\n /**\n * Remembers whether this instance has ever been mounted. We flip it on\n * after `didMount` so `isFirstMount` stays `true` for the duration of that\n * hook and only becomes `false` on later reconnects.\n *\n * @internal\n */\n protected _hasBeenMounted: boolean;\n\n /**\n * Gates decorator-driven re-renders so that field initializer assignments\n * during construction don't queue a render. Set to `true` after the first\n * render completes, so subsequent `@State` / `@Attribute` writes during\n * `didMount` and later hooks can schedule renders.\n *\n * @internal\n */\n protected _initRenderDone: boolean;\n\n /**\n * Bumps on every render, letting queued microtask renders detect that they\n * have been superseded and bail out before writing to the DOM.\n *\n * @internal\n */\n protected _renderId: number;\n\n /**\n * Tracks whether a microtask render is already queued, so repeated\n * `_queueRender` calls in the same tick coalesce into a single render.\n *\n * @internal\n */\n protected _renderQueued: boolean;\n\n /**\n * The kind of output (`'string'` or `'lit'`) applied by the last render that\n * actually wrote to the DOM. Lets `_render` detect a switch between string\n * and lit-html output and reset the render root so the incoming renderer\n * starts from a clean slate instead of inheriting the other's stale nodes.\n *\n * @internal\n */\n protected _lastRenderType?: 'string' | 'lit';\n\n /**\n * The object-form style currently applied through `setStyle`. Persisted so\n * that merge-mode updates can layer new rules on top of previous ones.\n *\n * @internal\n */\n protected _style: Style;\n\n /**\n * `true` while a `batch()` callback is executing. Used by the reactive\n * setters to defer watcher and render scheduling until the batch flushes.\n *\n * @internal\n */\n protected _batching: boolean;\n\n /**\n * Records reactive changes while a `batch()` is open so watchers and\n * `didChange` don't observe intermediate state. Flushed once at the end of\n * the batch with first and last values per property.\n *\n * @internal\n */\n protected _batchedChanges: Array<{ property: string; oldValue: unknown; newValue: unknown; shouldRender: boolean; source: string }>;\n\n /**\n * Backing storage for the custom element tag this class registers under.\n * Populated lazily by the `tag` getter (kebab-casing the class name) or\n * eagerly by `@Register` and the `tag` setter.\n *\n * @internal\n */\n protected static _tag?: string;\n\n /**\n * Backing storage for a class-level template (string or function). Takes\n * precedence over instance `render()` when set. Read and written through\n * the public `template` accessors.\n *\n * @internal\n */\n protected static _template?: string | TemplateFunction;\n\n /**\n * Whether a string render gives back focus and scroll positions.\n *\n * A `render()` that returns a string replaces every element inside the\n * component, so the browser loses which one had focus and how far each\n * was scrolled. Turn this on and Pandora finds the replacement of the\n * focused element and of each scrolled one, by its `data-key`, its `id`\n * or its position, and restores them. lit-html renders keep their\n * elements and don't need it.\n *\n * It's off by default because components that already move focus\n * themselves after a render (in `didRender()`) expect it to be lost.\n *\n * @example\n * class TrackList extends Component {\n * static override keepFocusAndScroll = true;\n * }\n */\n static keepFocusAndScroll: boolean = false;\n\n /**\n * Backing storage for attributes registered manually through the\n * `observedAttributes` setter. Merged with `@Attribute` / `@Property`\n * metadata in the getter.\n *\n * @internal\n */\n protected static _observedAttributes: string[] = [];\n\n /**\n * The adopted `CSSStyleSheet` shared across every instance of this tag.\n * We keep one per class so `setStyle` on one instance styles them all.\n *\n * @internal\n */\n protected static _styleSheet: CSSStyleSheet | null = null;\n\n /**\n * Object-form style declarations shared across every instance of this tag.\n * `setStyle()` writes to this class-level store because the stylesheet itself\n * is class-wide.\n *\n * @internal\n */\n protected static _sharedStyle: Style = {};\n\n // Registry integration hooks\n\n /**\n * Set by `Registry._init` to notify the registry whenever an instance\n * finishes `connectedCallback`. Left unset when the registry isn't loaded.\n *\n * @internal\n */\n static _onMount?: (component: Component, tag: string) => void;\n\n /**\n * Set by `Registry._init` to notify the registry after\n * `disconnectedCallback` finishes tearing an instance down.\n *\n * @internal\n */\n static _onUnmount?: (component: Component, tag: string) => void;\n\n /**\n * Set by `Registry._init` to route lifecycle errors through the registry's\n * error handler. When unset, errors rethrow from the lifecycle method.\n *\n * @internal\n */\n static _onError?: (error: Error, component: Component, tag: string, lifecycle: string) => void;\n\n /**\n * Set by `Registry._init` so the registry can transform values flowing\n * through reactive setters and render output (currently `render` middleware).\n *\n * @internal\n */\n static _applyMiddleware?: (type: string, component: Component, value: unknown, renderType?: 'string' | 'lit') => unknown;\n\n /**\n * Set by `Registry._init`. Lets `Component` cheaply skip the middleware\n * bridge when no middleware of a given type is registered.\n *\n * @internal\n */\n static _hasMiddleware?: (type: string) => boolean;\n\n // Registry integration hooks for @Subscribe\n\n /**\n * Set by `Registry._init`. Subscribes an instance to a global state key\n * and returns an unsubscribe function. Used to wire up `@Subscribe`\n * handlers on mount.\n *\n * @internal\n */\n static _subscribe?: (stateKey: string, callback: (newVal: unknown, oldVal: unknown) => void) => () => void;\n\n /**\n * Set by `Registry._init`. Reads the current value for a global state key\n * so `@Subscribe` fields can seed themselves on activation.\n *\n * @internal\n */\n static _getGlobalState?: (stateKey: string) => unknown;\n\n /**\n * Set by `Registry._init`. Applies the current implementation registered\n * with `Registry.evolve()` so that instances created after `evolve` pick up\n * the latest behavior.\n *\n * @internal\n */\n static _applyCurrentImplementation?: (instance: Component, tag: string) => void;\n\n /**\n * Activates a single `@Subscribe` handler on an instance, hooking it into\n * the registry's global state so the field tracks the chosen state key.\n * Safe to call more than once — any prior subscription in the handler's\n * slot is torn down first.\n *\n * @internal\n */\n static _activateSubscription(instance: Component, handler: SubscribeHandler): void {\n if (!Component._subscribe) {\n return;\n }\n\n const inst = instance as unknown as Record<symbol, unknown>;\n\n // Tear down any prior subscription occupying this handler's slot so\n // repeated activations don't double-fire on state changes.\n if (inst[handler.unsubKey]) {\n (inst[handler.unsubKey] as () => void)();\n inst[handler.unsubKey] = undefined;\n }\n\n inst[handler.unsubKey] = Component._subscribe(handler.stateKey, (newVal: unknown) => {\n const oldVal = inst[handler.valueKey];\n\n if (oldVal === newVal) {\n return;\n }\n\n inst[handler.valueKey] = newVal;\n instance.didChange(handler.propertyKey, oldVal, newVal, 'consumer');\n\n if (instance.isReady) {\n (instance as unknown as { _queueRender: () => void })._queueRender();\n }\n });\n\n const current = Component._getGlobalState?.(handler.stateKey);\n\n if (current !== undefined) {\n inst[handler.valueKey] = current;\n }\n }\n\n /**\n * The list of attributes the browser will notify Pandora about.\n *\n * This is the standard custom-elements introspection hook. It merges any\n * attributes you registered manually with the ones declared through\n * `@Attribute` and `@Property({ attribute })` decorators, so you rarely need\n * to set it by hand.\n *\n * @returns The tag names of observed attributes, with duplicates removed.\n *\n * @example\n * class MyButton extends Component {\n * @Attribute() disabled = false;\n * }\n *\n * MyButton.observedAttributes; // ['disabled']\n */\n static get observedAttributes(): string[] {\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = (this as any)[Symbol.metadata];\n const metaAttrs = meta?.[PROP_ATTRIBUTES] as string[] | undefined;\n\n if (metaAttrs?.length) {\n return [...new Set([...this._observedAttributes, ...metaAttrs])];\n }\n }\n\n return this._observedAttributes;\n }\n\n /**\n * Overrides the list of observed attributes for this class.\n *\n * Prefer `@Attribute` / `@Property({ attribute })` instead — they keep the\n * attribute list and the reactive field in sync automatically. Setting\n * this by hand is an escape hatch for integrations that need to declare\n * attributes without decorators.\n *\n * @param value - The attribute names the component should react to.\n */\n static set observedAttributes(value: string[]) {\n this._observedAttributes = value;\n }\n\n /**\n * The custom element tag this component registers under.\n *\n * If you used `@Register('my-tag')` the tag is whatever you passed in. If\n * you didn't, Pandora derives one from the class name by converting it to\n * kebab-case (`MyGreeting` becomes `my-greeting`).\n *\n * @returns The tag name the component is known by in the DOM.\n *\n * @example\n * @Register('user-avatar')\n * class UserAvatar extends Component {}\n * UserAvatar.tag; // 'user-avatar'\n *\n * class ThemeToggle extends Component {}\n * ThemeToggle.tag; // 'theme-toggle' — derived from the class name\n */\n static get tag(): string {\n if (typeof this._tag === 'undefined') {\n let tag = this.name;\n const matches = tag.match(/([A-Z])/g);\n\n if (matches !== null) {\n for (const match of matches) {\n tag = tag.replace(match, `-${match}`.toLowerCase());\n }\n }\n\n this._tag = tag.slice(1);\n }\n\n return this._tag;\n }\n\n /**\n * Overrides the tag name this component registers under.\n *\n * `@Register('my-tag')` is the preferred way to set this. Use the setter\n * when you need to assign a tag programmatically before calling\n * `register()` yourself.\n *\n * @param value - The custom element tag (must contain a hyphen).\n */\n static set tag(value: string) {\n this._tag = value;\n }\n\n /**\n * The class-level template used in place of `render()` when defined.\n *\n * Pandora picks this up automatically from an HTML `<template id=\"my-tag\">`\n * on first mount, or you can assign a string or a function that returns\n * one. When set, it takes precedence over the instance `render()` method.\n *\n * @returns The template, or `undefined` if the component renders through\n * `render()`.\n *\n * @example\n * MyGreeting.template = (self) => `<p>Hello, ${self.name}.</p>`;\n */\n static get template(): string | TemplateFunction | undefined {\n return this._template;\n }\n\n /**\n * Replaces the class-level template and refreshes every mounted instance.\n *\n * Assigning a new template triggers `forceRender()` on every live element\n * of this tag, so the UI picks up the new markup immediately. Pass a\n * string for static markup, or a function `(self) => string` when you need\n * access to the instance.\n *\n * @param value - The new template, or `undefined` to clear it.\n *\n * @example\n * // Swap the greeting template at runtime.\n * MyGreeting.template = '<p>Welcome back.</p>';\n */\n static set template(value: string | TemplateFunction | undefined) {\n this._template = value;\n\n if (value !== undefined) {\n document.querySelectorAll(this.tag).forEach((instance) => {\n if (instance instanceof Component && instance._isReady) {\n instance.forceRender();\n }\n });\n }\n }\n\n /**\n * Initializes a component instance.\n *\n * The browser calls this for you when the element is created — either\n * through `document.createElement('my-tag')`, `new MyTag()`, or when the\n * parser encounters the tag in HTML. Subclasses rarely need to override\n * it; reach for `willMount()` or `didMount()` for setup work. If you do\n * override, remember to call `super()` first.\n *\n * @example\n * class MyCounter extends Component {\n * constructor() {\n * super();\n * // your own setup here\n * }\n * }\n */\n constructor() {\n super();\n this._children = '';\n this._connected = false;\n this._isReady = false;\n this._hasBeenMounted = false;\n this._initRenderDone = false;\n this._renderId = 0;\n this._renderQueued = false;\n this._style = {};\n this._batching = false;\n this._batchedChanges = [];\n this._trackScrolling(this);\n }\n\n /**\n * The instances of this class that are in the document right now, in the\n * order they connected. Only instances of exactly this class: a subclass\n * has its own set. Use it to reach every live instance without searching\n * the DOM, including the ones inside other components' shadow roots.\n *\n * The set is live: it changes as instances connect and disconnect. Copy it\n * (`[...Dialog.connectedInstances()]`) before iterating if what you do can\n * add or remove components.\n *\n * @returns A read-only view of the connected instances.\n *\n * @example\n * for (const dialog of Dialog.connectedInstances()) {\n * dialog.close();\n * }\n */\n static connectedInstances<T extends typeof Component>(this: T): ReadonlySet<InstanceType<T>> {\n return (CONNECTED_INSTANCES.get(this) ?? NO_INSTANCES) as ReadonlySet<InstanceType<T>>;\n }\n\n /**\n * Where the component renders: the element itself. `ShadowComponent`\n * returns its shadow root.\n *\n * @internal\n */\n protected _renderRoot(): ParentNode {\n return this;\n }\n\n /**\n * Notes the elements under `root` that the user (or code) scrolls. Scroll\n * events don't bubble, so this listens in the capture phase.\n *\n * @internal\n */\n protected _trackScrolling(root: EventTarget): void {\n root.addEventListener('scroll', (event) => {\n if (event.target instanceof Element && event.target !== this) {\n this._scrolledElements.add(event.target);\n }\n }, { capture: true, passive: true });\n }\n\n /**\n * Assigns the values the element was given before its class was defined,\n * through the class's own setters and reactive fields.\n *\n * @internal\n */\n private _assignValuesBeforeUpgrade(): void {\n const values = this._valuesBeforeUpgrade;\n\n if (values === undefined) {\n return;\n }\n\n this._valuesBeforeUpgrade = undefined;\n\n const tag = (this.constructor as typeof Component).tag;\n\n for (const [key, value] of values) {\n try {\n (this as unknown as Record<string, unknown>)[key] = value;\n } catch (error) {\n console.warn(`[Pandora] <${tag}> was given \\`${key}\\` before it was defined, and the value couldn't be kept: ${(error as Error).message}`);\n }\n }\n }\n\n /**\n * The original inner HTML the component was mounted with.\n *\n * Pandora captures whatever markup lived between the opening and closing\n * tags on first mount, before any render runs. Use this when you want to\n * project user-provided content into your template — it is the string-\n * render equivalent of a light-DOM `<slot>`.\n *\n * @returns The trimmed inner HTML at mount time.\n *\n * @example\n * class MyCard extends Component {\n * render() {\n * return `<div class=\"card\">${this.slotContent}</div>`;\n * }\n * }\n *\n * // <my-card>Hello</my-card> → <div class=\"card\">Hello</div>\n */\n get slotContent(): string {\n return this._children;\n }\n\n /**\n * Whether the component is currently attached to the DOM.\n *\n * Flips to `true` at the start of `connectedCallback()` and back to\n * `false` at the start of `disconnectedCallback()`, matching the native\n * `Node.isConnected` it shadows. Useful if you're running async work that\n * should stop once the element is removed.\n *\n * @returns `true` while the element is in the document.\n *\n * @example\n * async loadData() {\n * const data = await fetch('/api/posts').then(r => r.json());\n * if (!this.isConnected) return; // bail out if the user navigated away\n * this.items = data;\n * }\n */\n get isConnected(): boolean {\n return this._connected;\n }\n\n /**\n * Whether the first mount lifecycle (including the initial render) has\n * finished.\n *\n * Prefer `ready()` when you want to run code once the component is ready;\n * this getter is handy when you need a synchronous check — for example\n * inside a parent component that wants to talk to a freshly inserted\n * child. It drops back to `false` as soon as the element is removed, and\n * turns `true` again once a reconnect finishes.\n *\n * @returns `true` after `didMount()` (or `didReconnect()`) and the render\n * before it have run.\n *\n * @example\n * if (avatar.isReady) {\n * avatar.focus();\n * } else {\n * avatar.ready(() => avatar.focus());\n * }\n */\n get isReady(): boolean {\n return this._isReady;\n }\n\n /**\n * Whether this is the component's first time being mounted.\n *\n * `true` during the initial `connectedCallback()` / `didMount()`, `false`\n * on subsequent reconnects (for example if the element is detached and\n * re-attached, or moved in the DOM). Use it to separate first-time setup\n * from re-connect behavior inside lifecycle hooks.\n *\n * @returns `true` until the first mount completes.\n *\n * @example\n * async didMount() {\n * if (this.isFirstMount) {\n * await this.loadInitialData();\n * }\n * }\n */\n get isFirstMount(): boolean {\n return !this._hasBeenMounted;\n }\n\n /**\n * Set eagerly at `Registry` module load (not by `_init` like the other\n * hooks) so that `Component.register()` delegates to the registry as soon\n * as the registry module is imported, regardless of init ordering.\n *\n * @internal\n */\n static _registryRegister?: (tag: string, component: typeof Component) => void;\n\n /**\n * Registers this class as a custom element so the browser will recognise\n * its tag in the DOM.\n *\n * `@Register('my-tag')` is the preferred path — it sets the tag and calls\n * this for you. Call `register()` directly when you're wiring things up\n * without decorators, or when you configured the tag manually through the\n * `tag` setter.\n *\n * @example\n * class MyCounter extends Component {\n * static tag = 'my-counter';\n * render() { return `<p>count</p>`; }\n * }\n * MyCounter.register();\n */\n static register(): void {\n if (Component._registryRegister) {\n Component._registryRegister(this.tag, this);\n } else {\n window.customElements.define(this.tag, this);\n }\n }\n\n /**\n * Whether the component is currently inside a `batch()` call.\n *\n * Mostly useful for code paths that branch on whether an update is part\n * of a larger batched change — for example deciding whether to defer side\n * effects until the batch completes.\n *\n * @returns `true` while a `batch()` callback is running.\n *\n * @example\n * if (!this.isBatching) {\n * this.logAudit(change);\n * }\n */\n get isBatching(): boolean {\n return this._batching;\n }\n\n /**\n * Groups several state changes into a single render.\n *\n * Every reactive property assignment you do inside `fn` is collected and\n * replayed after it returns. `@Watch` callbacks and `didChange()` run\n * once each, with the first and last values seen during the batch, and\n * Pandora queues just one render at the end. Net no-ops (setting `A`\n * back to its original value within the same batch) are skipped entirely.\n *\n * @param fn - A synchronous function that performs the property changes.\n *\n * @example\n * class MyCounter extends Component {\n * @State() count = 0;\n * @State() label = 'clicks';\n *\n * reset() {\n * this.batch(() => {\n * this.count = 0;\n * this.label = 'reset';\n * });\n * // Only one render runs for both changes.\n * }\n * }\n */\n batch(fn: () => void): void {\n this._batching = true;\n this._batchedChanges = [];\n\n try {\n fn();\n } finally {\n this._batching = false;\n const changes = this._batchedChanges;\n this._batchedChanges = [];\n\n if (changes.length > 0) {\n let hasRenderableChange = false;\n\n for (const { property, oldValue, newValue, shouldRender, source } of changes) {\n // Drop net no-ops (A → B → A within the same batch) so watchers\n // and didChange never observe a change that ultimately didn't happen.\n if (oldValue === newValue) {\n continue;\n }\n\n if (shouldRender) {\n hasRenderableChange = true;\n }\n\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = ((this.constructor as any)[Symbol.metadata]) as Record<symbol, unknown> | undefined;\n const entries = meta?.[WATCH_HANDLERS] as Array<{ property: string; methodName: string }> | undefined;\n\n if (entries) {\n for (const entry of entries) {\n if (entry.property === property) {\n const method = (this as any)[entry.methodName];\n\n if (typeof method === 'function') {\n method.call(this, newValue, oldValue);\n }\n }\n }\n }\n }\n\n this.didChange(property, oldValue, newValue, source);\n }\n\n // Only queue a render if at least one flushed change was actually\n // render-eligible — `@State({ render: false })` fields skip it. We gate\n // on `_initRenderDone` too (matching the per-field setters) so a batch\n // run during `willMount` doesn't paint before the initial render lands.\n if (hasRenderableChange && this._initRenderDone && this._connected) {\n this._queueRender();\n }\n }\n }\n }\n\n /*\n * =========================\n * Rendering\n * =========================\n */\n\n /**\n * Schedules a render on the microtask queue. Multiple calls in the same\n * tick coalesce into one render, and errors inside the render surface\n * through the registry error handler (or console as a fallback).\n *\n * @internal\n */\n protected _queueRender(): void {\n if (this._renderQueued || !this._connected) {\n return;\n }\n\n this._renderQueued = true;\n\n queueMicrotask(() => {\n this._renderQueued = false;\n\n if (this._connected) {\n this._render().catch((error: Error) => {\n const tag = (this.constructor as typeof Component).tag;\n\n if (Component._onError) {\n Component._onError(error, this, tag, 'render');\n } else {\n const locator = this.id ? `#${this.id}` : this.className ? `.${this.className.split(/\\s+/).join('.')}` : '';\n console.error(`[Pandora] Unhandled render error in <${tag}${locator}>:`, error, this);\n }\n });\n }\n });\n }\n\n /**\n * Renders the component immediately, skipping microtask batching.\n *\n * Normally you don't need this — property changes schedule a render on\n * the microtask queue automatically. Reach for `forceRender()` when you\n * need the DOM to reflect the latest state right now, for example before\n * measuring an element or taking a screenshot in a test.\n *\n * @returns A promise that resolves once the render (including async\n * `render()` returns and `didRender()`) has completed.\n *\n * @example\n * this.count = 42;\n * await this.forceRender();\n * // the counter has the new value painted at this point\n */\n forceRender(): Promise<void> {\n return this._render();\n }\n\n /**\n * Produces the markup for this component.\n *\n * Override this in your subclass. You can return a lit-html `TemplateResult`\n * (from the `html` tagged template), a plain HTML string, `lit-html`'s\n * `nothing` sentinel to render no content, or an empty string `''` to clear\n * the host. Returning nothing (the default) leaves any HTML-defined\n * children untouched, which is what container components rely on.\n *\n * Pandora calls this for you on mount and whenever a reactive property\n * changes — you rarely invoke it yourself. The return may be synchronous\n * or a promise.\n *\n * @returns The markup to render, or `void` to preserve existing content.\n *\n * @example\n * import { html } from '@aegis-framework/pandora';\n *\n * class MyGreeting extends Component {\n * @State() name = 'friend';\n *\n * render() {\n * return html`<p>Hello, ${this.name}.</p>`;\n * }\n * }\n */\n render(): TemplateValue | Promise<TemplateValue> {\n // Default behavior is a no-op: container components that don't override\n // render() keep their HTML-defined children intact. Returning '' is the\n // explicit way to clear the host.\n }\n\n /**\n * Applies a lit-html template result to the host. We clear and stamp the\n * `data-lit-rendered` marker on first use so pre-existing children don't\n * interfere with lit's reconciliation, then delegate to `litRender`.\n *\n * @internal\n */\n protected _applyLitRender(result: TemplateResult | typeof nothing): void {\n if (!this.hasAttribute('data-lit-rendered')) {\n this.innerHTML = '';\n this.setAttribute('data-lit-rendered', '');\n }\n\n litRender(result, this, { host: this });\n }\n\n /**\n * Applies a string render result. Honours `<slot>` as the injection point\n * when one is present, otherwise sets `innerHTML` directly and re-appends\n * the captured `slotContent` if the new markup didn't already include it.\n *\n * @internal\n */\n protected _applyStringRender(html: string): void {\n // An empty string is an explicit \"clear content\" request.\n if (html === '') {\n this.innerHTML = '';\n return;\n }\n\n const template = document.createElement('template');\n template.innerHTML = html;\n\n const slot = template.content.querySelector('slot');\n\n if (slot !== null) {\n const content = document.createElement('template');\n content.innerHTML = this._children;\n slot.replaceWith(content.content);\n this.innerHTML = '';\n this.appendChild(template.content);\n } else {\n this.innerHTML = html;\n\n if (this._children !== '' && html.indexOf(this._children) === -1) {\n this.innerHTML += this._children;\n }\n }\n }\n\n /**\n * Resets the render root so the other renderer can take over cleanly when a\n * component switches between string and lit-html output. A string render\n * overwrites `innerHTML`, destroying the marker nodes lit-html tracks; its\n * leftover cached part would then throw on the next lit render. We clear the\n * host, drop the `data-lit-rendered` marker, and delete lit-html's cached\n * root part (`_$litPart$`) so the next lit render re-initializes instead of\n * reusing stale markers. `ShadowComponent` overrides this for its root.\n *\n * @internal\n */\n protected _resetRenderRoot(): void {\n this.innerHTML = '';\n this.removeAttribute('data-lit-rendered');\n delete (this as unknown as Record<string, unknown>)['_$litPart$'];\n }\n\n /**\n * Runs a single render cycle: resolves the template, applies middleware,\n * writes to the DOM, and re-attaches `@Listen` handlers. Bumps `_renderId`\n * up front so any concurrent render that awaited through ours detects it\n * has been superseded and bails before touching the DOM.\n *\n * @internal\n */\n protected async _render(): Promise<void> {\n type RenderResult = TemplateValue;\n\n const renderId = ++this._renderId;\n const ctor = this.constructor as typeof Component;\n\n let renderFn: () => RenderResult | Promise<RenderResult> = this.render;\n\n if (ctor._template !== undefined) {\n renderFn = () => {\n if (typeof ctor._template === 'function') {\n return ctor._template.call(this, this);\n }\n\n return ctor._template as string;\n };\n }\n\n let result = await callAsync(renderFn, this);\n\n // A newer render started while we were awaiting; let it win.\n if (renderId !== this._renderId) {\n return;\n }\n\n // void / null means \"don't touch the DOM\" (container components rely on\n // this to preserve their HTML-defined children), but we still re-bind\n // @Listen handlers and run didRender so consumers see consistent hooks.\n if (result === undefined || result === null) {\n this._syncListenersAfterRender();\n await callAsync(this.didRender, this);\n return;\n }\n\n const renderType: 'string' | 'lit' = isTemplateResult(result) || result === nothing ? 'lit' : 'string';\n\n if (Component._hasMiddleware?.('render') && Component._applyMiddleware) {\n result = Component._applyMiddleware('render', this, result, renderType) as RenderResult;\n }\n\n // Re-derive the kind after middleware, which may have swapped a string for\n // a TemplateResult (or vice versa), then drive both the mode-switch reset\n // and the apply branch off the same decision.\n const isLit = isTemplateResult(result) || result === nothing;\n const appliedType: 'string' | 'lit' = isLit ? 'lit' : 'string';\n\n if (!isLit && typeof result !== 'string') {\n const kind = Array.isArray(result) ? 'an array' : `a ${typeof result}`;\n\n throw new TypeError(\n `[Pandora] <${ctor.tag}>'s render() returned ${kind}. Return a string, an html\\`\\` template, \\`nothing\\` `\n + '(to clear the content) or undefined (to leave it as it is). To render a list, put it in a template: html`${items}`.',\n );\n }\n\n // A string render replaces every element, so note the focus and scroll\n // positions first (before a renderer switch wipes the root, too).\n const restoreFocusAndScroll = !isLit && ctor.keepFocusAndScroll\n ? keepFocusAndScroll(this._renderRoot(), this._scrolledElements)\n : null;\n\n // A switch between string and lit output leaves the previous renderer's\n // bookkeeping dangling, so wipe the root before the new renderer writes.\n if (this._lastRenderType !== undefined && this._lastRenderType !== appliedType) {\n this._resetRenderRoot();\n }\n\n if (isLit) {\n this._applyLitRender(result as TemplateResult | typeof nothing);\n } else {\n this._applyStringRender((result as string).trim());\n restoreFocusAndScroll?.();\n }\n\n this._lastRenderType = appliedType;\n\n // Refresh @Listen handlers after the render: selector-targeted listeners\n // may have pointed at nodes this render replaced, so they're re-resolved,\n // while host/window/document listeners (and fired one-shots) stay put.\n this._syncListenersAfterRender();\n\n await callAsync(this.didRender, this);\n }\n\n /*\n * =========================\n * Styles\n * =========================\n */\n\n /**\n * Applies styles to the component via an adopted stylesheet.\n *\n * Pass a `Style` object to describe your rules declaratively, or a raw\n * CSS string if you already have text. By default the styles are merged\n * with anything previously applied to the component; pass `reset: true`\n * to replace the stylesheet instead. The stylesheet is shared across\n * every instance of the tag, so setting it once styles them all.\n *\n * @param style - A `Style` object or a CSS string.\n * @param reset - When `true`, replace the existing styles instead of\n * merging on top.\n * @returns The current object-form style after the update (useful when\n * you want to read back the merged state).\n *\n * @example\n * class ThemeToggle extends Component {\n * async didMount() {\n * this.setStyle({\n * ':host': { display: 'inline-block', cursor: 'pointer' },\n * 'button': { padding: '0.5rem 1rem' }\n * });\n * }\n * }\n *\n * // Or with a raw CSS string:\n * this.setStyle(':host { color: rebeccapurple; }');\n */\n setStyle(style: Style | string, reset: boolean = false): Style {\n const staticComponent = this.constructor as typeof Component;\n\n if (!staticComponent._styleSheet) {\n staticComponent._styleSheet = new CSSStyleSheet();\n }\n\n let cssText = '';\n\n if (typeof style === 'object') {\n if (!Object.hasOwn(staticComponent, '_sharedStyle')) {\n staticComponent._sharedStyle = {};\n }\n\n if (!reset) {\n staticComponent._sharedStyle = { ...staticComponent._sharedStyle, ...style };\n } else {\n staticComponent._sharedStyle = { ...style };\n }\n\n this._style = staticComponent._sharedStyle;\n cssText = deserializeCSS(staticComponent._sharedStyle, staticComponent.tag);\n } else if (typeof style === 'string') {\n if (!reset) {\n const existingRules = Array.from(staticComponent._styleSheet.cssRules || [])\n .map((rule) => rule.cssText)\n .join('\\n');\n\n cssText = existingRules + '\\n' + style;\n } else {\n cssText = style;\n staticComponent._sharedStyle = {};\n this._style = {};\n }\n }\n\n staticComponent._styleSheet.replaceSync(cssText);\n\n if (!document.adoptedStyleSheets.includes(staticComponent._styleSheet)) {\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, staticComponent._styleSheet];\n }\n\n return staticComponent._sharedStyle;\n }\n\n /*\n * =========================\n * Event Helpers\n * =========================\n */\n\n /**\n * Attaches an event listener to the component.\n *\n * A thin, chainable wrapper around `addEventListener` scoped to the host\n * element. Prefer the `@Listen` decorator for anything that should live\n * for the lifetime of the component — `on()` is handy for one-offs and\n * for ad-hoc wiring from outside the class.\n *\n * @param event - The event name to listen for.\n * @param callback - The handler to run when the event fires.\n * @param options - Standard `addEventListener` options.\n * @returns The component, for chaining.\n *\n * @example\n * const button = document.querySelector('my-button');\n * button.on('click', () => console.log('clicked'));\n */\n on<K extends keyof HTMLElementEventMap>(\n event: K,\n callback: (this: this, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ): this;\n\n on(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;\n\n on(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this {\n this.addEventListener(event, callback, options);\n return this;\n }\n\n /**\n * Removes a previously attached event listener from the component.\n *\n * Pass the same event name, callback reference, and options you used in\n * `on()` / `once()` — the underlying `removeEventListener` only matches\n * exact triples.\n *\n * @param event - The event name.\n * @param callback - The handler reference to remove.\n * @param options - The options the listener was registered with.\n * @returns The component, for chaining.\n *\n * @example\n * const onClick = () => console.log('clicked');\n * button.on('click', onClick);\n * // later...\n * button.off('click', onClick);\n */\n off<K extends keyof HTMLElementEventMap>(\n event: K,\n callback: (this: this, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | EventListenerOptions\n ): this;\n\n off(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): this;\n\n off(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): this {\n this.removeEventListener(event, callback, options);\n return this;\n }\n\n /**\n * Attaches a one-shot event listener to the component.\n *\n * Like `on()`, but the listener is automatically removed after it fires\n * once. Useful for reacting to things like the first click or the next\n * transition end.\n *\n * @param event - The event name to listen for.\n * @param callback - The handler to run the first time the event fires.\n * @param options - Standard `addEventListener` options; `once` is forced\n * to `true`.\n * @returns The component, for chaining.\n *\n * @example\n * modal.once('animationend', () => modal.remove());\n */\n once<K extends keyof HTMLElementEventMap>(\n event: K,\n callback: (this: this, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ): this;\n\n once(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;\n\n once(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this {\n const opts = typeof options === 'boolean' ? { capture: options, once: true } : { ...options, once: true };\n this.addEventListener(event, callback, opts);\n return this;\n }\n\n /**\n * Dispatches a `CustomEvent` from the component.\n *\n * By default the event bubbles up through the DOM, is composed (so it\n * crosses shadow-root boundaries), and is cancellable. Pass any of those\n * as `options` to override them. Anything you put in `detail` is\n * delivered to listeners as `event.detail`.\n *\n * @param event - The event name.\n * @param detail - The payload to attach to `event.detail`.\n * @param options - Overrides for `bubbles`, `cancelable`, `composed`, etc.\n * @returns `false` if a listener called `preventDefault()`, otherwise\n * `true`.\n *\n * @example\n * class MyButton extends Component {\n * @Listen('click')\n * onClick() {\n * this.emit('button-pressed', { id: this.id, at: Date.now() });\n * }\n * }\n *\n * // parent listens:\n * myButton.on('button-pressed', (e) => console.log(e.detail.id));\n */\n emit<T = unknown>(event: string, detail?: T, options?: Omit<CustomEventInit<T>, 'detail'>): boolean {\n const customEvent = new CustomEvent(event, {\n detail,\n bubbles: true,\n cancelable: true,\n composed: true,\n ...options,\n });\n\n return this.dispatchEvent(customEvent);\n }\n\n /*\n * =========================\n * Query Helpers\n * =========================\n */\n\n /**\n * Finds the first descendant matching the given CSS selector.\n *\n * A shortcut for `querySelector` scoped to the component's own subtree.\n * Handy inside `didMount()` or `didRender()` when you need to grab a\n * rendered element. Subclasses like `ShadowComponent` scope the search\n * to the shadow root instead.\n *\n * @param selector - Any valid CSS selector.\n * @returns The first matching element, or `null` if nothing matched.\n *\n * @example\n * async didMount() {\n * this.query('input')?.focus();\n * }\n */\n query<E extends Element = Element>(selector: string): E | null {\n return this.querySelector<E>(selector);\n }\n\n /**\n * Finds every descendant matching the given CSS selector.\n *\n * A shortcut for `querySelectorAll` scoped to the component's own\n * subtree. Subclasses like `ShadowComponent` scope the search to the\n * shadow root instead.\n *\n * @param selector - Any valid CSS selector.\n * @returns A `NodeList` of matching elements (possibly empty).\n *\n * @example\n * for (const item of this.queryAll('li.item')) {\n * item.classList.add('ready');\n * }\n */\n queryAll<E extends Element = Element>(selector: string): NodeListOf<E> {\n return this.querySelectorAll<E>(selector);\n }\n\n /*\n * =========================\n * Ready Callback\n * =========================\n */\n\n /**\n * Queue of callbacks registered through `ready()` before the component\n * finished its first mount. Drained in order once `_isReady` flips to\n * `true`, then discarded.\n *\n * @internal\n */\n private _readyCallbacks?: Array<() => void>;\n\n /**\n * Queues a callback to run once the component has finished its first\n * mount and initial render.\n *\n * If the component is already ready, the callback runs on the next\n * microtask. If not, it's queued and fired in order after `didMount()`\n * and the first render. Typical use is deferring DOM work that depends on\n * the rendered markup — focusing an input, measuring size, wiring up a\n * library.\n *\n * @param callback - The function to run when the component is ready.\n *\n * @example\n * class UserAvatar extends Component {\n * render() {\n * return html`<input name=\"handle\" />`;\n * }\n *\n * constructor() {\n * super();\n * this.ready(() => this.query('input')?.focus());\n * }\n * }\n */\n ready(callback: () => void): void {\n if (this._isReady) {\n queueMicrotask(callback);\n } else {\n this._readyCallbacks ??= [];\n this._readyCallbacks.push(callback);\n }\n }\n\n /*\n * =========================\n * Lifecycle\n * =========================\n */\n\n /**\n * Runs just before the component's first render.\n *\n * Override this to do async setup that should finish before users see\n * anything — fetch data, load a dependency, subscribe to a store. The\n * render is awaited on your returned promise, so returning a pending\n * fetch will delay the first paint.\n *\n * @example\n * async willMount() {\n * this.data = await fetch('/api/profile').then(r => r.json());\n * }\n */\n public willMount(): void | Promise<void> {}\n\n /**\n * Runs after the component's first mount completes.\n *\n * By this point the initial render has happened, `isReady` is `true`,\n * and the component is in the DOM. Use it for post-render setup that\n * needs to inspect the rendered markup, or for things you only want to\n * do on the very first connection (use `isFirstMount` if you override\n * `didReconnect` too).\n *\n * @example\n * async didMount() {\n * this.query('input')?.focus();\n * }\n */\n public didMount(): void | Promise<void> {}\n\n /**\n * Runs after every render cycle.\n *\n * Fires on the initial mount render, on re-renders triggered by\n * reactive state changes, and on every `forceRender()` call. Use it\n * to grab references to freshly rendered elements or to re-apply\n * imperative setup — `didMount()` only runs once, while this runs\n * each time the DOM content is replaced.\n *\n * @example\n * async didRender() {\n * this._chart?.destroy();\n * this._chart = createChart(this.query('canvas'));\n * }\n */\n public didRender(): void | Promise<void> {}\n\n /**\n * Runs when the component is re-attached to the DOM after being\n * disconnected.\n *\n * This is the counterpart to `didMount()` for the second and later\n * connection. Use it to re-subscribe to streams or re-start timers\n * that you shut down in `willUnmount()` / `didUnmount()`.\n *\n * @example\n * async didReconnect() {\n * this._timer = setInterval(() => this.tick(), 1000);\n * }\n */\n public didReconnect(): void | Promise<void> {}\n\n /**\n * Runs just before the component is removed from the DOM.\n *\n * Override to tear down anything that can't wait: cancel pending\n * fetches, clear timers, close sockets. The returned promise is\n * awaited before `didUnmount()` runs.\n *\n * @example\n * async willUnmount() {\n * this._abort.abort();\n * }\n */\n public willUnmount(): void | Promise<void> {}\n\n /**\n * Runs after the component has been removed from the DOM.\n *\n * By this point the element is no longer in the document. Use it for\n * final cleanup — releasing references, logging, telemetry.\n *\n * @example\n * async didUnmount() {\n * analytics.track('card-removed', { id: this.id });\n * }\n */\n public didUnmount(): void | Promise<void> {}\n\n /**\n * Runs every time one of the component's reactive fields changes.\n *\n * Override this for a single place to observe state changes across all\n * `@State`, `@Attribute`, `@Property`, and `@Subscribe` fields. It fires\n * synchronously in the setter, after any matching `@Watch` callbacks and\n * before the queued render. Great for logging, audit trails, analytics,\n * or cross-cutting validation.\n *\n * @param property - The name of the field that changed.\n * @param oldValue - The previous value.\n * @param newValue - The new value.\n * @param source - A short label describing where the change came from,\n * such as `'state'`, `'prop'`, `'prop-attribute'`, `'property'`,\n * `'consumer'`, or `'reactive'`.\n *\n * @example\n * class MyCounter extends Component {\n * @State() count = 0;\n *\n * didChange(property, oldValue, newValue, source) {\n * console.log(`[${source}] ${property}: ${oldValue} -> ${newValue}`);\n * }\n * }\n */\n public didChange(_property: string, _oldValue: unknown, _newValue: unknown, _source?: string): void {}\n\n /**\n * Adds the instance to its class's `connectedInstances()`.\n *\n * @internal\n */\n private _countAsConnected(): void {\n const componentClass = this.constructor;\n let instances = CONNECTED_INSTANCES.get(componentClass);\n\n if (instances === undefined) {\n instances = new Set();\n CONNECTED_INSTANCES.set(componentClass, instances);\n }\n\n instances.add(this);\n this._connectedAs = componentClass;\n }\n\n /**\n * Removes the instance from the `connectedInstances()` it was added to,\n * even if `evolve()` has changed its class since.\n *\n * @internal\n */\n private _stopCountingAsConnected(): void {\n if (this._connectedAs !== undefined) {\n CONNECTED_INSTANCES.get(this._connectedAs)?.delete(this);\n this._connectedAs = undefined;\n }\n }\n\n /**\n * The standard custom-elements hook Pandora uses to drive mounting.\n *\n * Pandora runs `@Subscribe` activation, picks up `@Style` metadata, calls\n * `willMount()`, performs the first render, then calls either\n * `didMount()` (on the first connection) or `didReconnect()` (on a later\n * one), and finally fires any pending `ready()` callbacks. Subclasses\n * normally reach for `willMount()`, `didMount()`, or `ready()` instead of\n * overriding this. If you do override it, call `super.connectedCallback()`\n * so the lifecycle keeps working.\n *\n * @example\n * async connectedCallback() {\n * await super.connectedCallback();\n * // extra work that needs to run after the standard mount\n * }\n */\n async connectedCallback(): Promise<void> {\n const ctor = this.constructor as typeof Component;\n const tag = ctor.tag;\n\n try {\n this._connected = true;\n this._countAsConnected();\n this.dataset.component = tag;\n\n // If `Registry.evolve()` swapped the implementation for this tag after\n // `customElements.define()` ran, reapply it to this instance before any\n // lifecycle code runs — that way evolved behavior lands on fresh\n // instances without requiring re-creation.\n Component._applyCurrentImplementation?.(this, tag);\n\n // Activate `@Subscribe` handlers from class metadata. This has to live\n // on the prototype method (here), not a shadow on the instance, because\n // the browser only calls prototype-defined custom element lifecycle\n // callbacks.\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = (this.constructor as unknown as Record<symbol, unknown>)[Symbol.metadata] as Record<symbol, unknown> | undefined;\n const handlers = meta?.[SUBSCRIBE_HANDLERS] as SubscribeHandler[] | undefined;\n\n if (handlers) {\n for (const handler of handlers) {\n Component._activateSubscription(this, handler);\n }\n }\n }\n\n const firstMount = !this._hasBeenMounted;\n\n if (firstMount) {\n this._children = this.innerHTML.trim();\n this._assignValuesBeforeUpgrade();\n }\n\n // Attribute defaults that couldn't be written while the element was\n // constructed (see writePendingAttributes()).\n writePendingAttributes(this);\n\n // Pick up an HTML `<template id=\"...\">` matching our tag on first mount\n // so consumers can author templates declaratively without touching JS.\n if (firstMount && ctor._template === undefined) {\n const tpl = document.querySelector(`template#${tag}`);\n\n if (tpl) {\n ctor._template = tpl.innerHTML;\n }\n }\n\n // Apply `@Style` metadata once per class, not once per instance. The\n // stylesheet is shared across every instance of the tag, so reapplying it\n // with `reset: true` on each new instance's first mount would wipe any\n // runtime `setStyle()` merges made by earlier instances. The own-property\n // guard makes sure only the very first instance seeds the shared sheet.\n if (firstMount && typeof Symbol.metadata !== 'undefined' && !Object.hasOwn(ctor, '_styleMetaApplied')) {\n const meta = (ctor as any)[Symbol.metadata];\n const styleData = meta?.[STYLE_METADATA];\n\n if (styleData) {\n (ctor as unknown as { _styleMetaApplied: boolean })._styleMetaApplied = true;\n this.setStyle(styleData as Style | string, true);\n }\n }\n\n await this.willMount();\n await this._render();\n\n // Flip the init-render gate now that the first render has landed. From\n // here on, reactive writes in `didMount` / `didReconnect` and beyond\n // are allowed to queue renders; field-initializer writes that ran\n // during construction already happened before this point and so don't.\n this._initRenderDone = true;\n\n if (firstMount) {\n await this.didMount();\n } else {\n // On reconnect we deliberately call `didReconnect` instead of\n // `didMount` so consumers can separate first-time setup from\n // re-attachment behavior.\n await this.didReconnect();\n }\n\n // We set `_hasBeenMounted` after `didMount` finishes so that\n // `isFirstMount` remains `true` for the entire duration of that hook.\n this._hasBeenMounted = true;\n\n this._isReady = true;\n\n if (this._readyCallbacks) {\n for (const callback of this._readyCallbacks) {\n callback();\n }\n\n this._readyCallbacks = undefined;\n }\n\n Component._onMount?.(this, tag);\n\n this.emit('pandora:ready', { firstMount, tag }, { bubbles: true, composed: true });\n } catch (error) {\n if (Component._onError) {\n Component._onError(error as Error, this, tag, 'connectedCallback');\n } else {\n throw error;\n }\n }\n }\n\n /**\n * The standard custom-elements hook Pandora uses to drive unmounting.\n *\n * Pandora flips the component's connected and ready flags to `false`\n * right away, tears down `@Subscribe` subscriptions and `@Listen` handlers,\n * then calls `willUnmount()` and `didUnmount()`. Override the lifecycle\n * methods in preference to this hook; if you do override, remember to call\n * `super.disconnectedCallback()`.\n *\n * @example\n * async disconnectedCallback() {\n * await super.disconnectedCallback();\n * this.releaseExternalResource();\n * }\n */\n async disconnectedCallback(): Promise<void> {\n const ctor = this.constructor as typeof Component;\n const tag = ctor.tag;\n\n // Flip the flags synchronously, before any await. Moving an element in\n // the DOM (re-appending it, or lit-html's `repeat` reordering a list)\n // runs `connectedCallback` right after this hook returns its promise, so\n // flipping them after the awaits below would clobber the reconnect and\n // leave the component unable to queue renders.\n this._connected = false;\n this._isReady = false;\n this._stopCountingAsConnected();\n\n try {\n // Fire the lifecycle event before tearing anything down so listeners\n // can still read component state from the handler.\n this.emit('pandora:unmount', { tag }, { bubbles: true, composed: true });\n\n // Release `@Subscribe` subscriptions so the removed instance stops\n // receiving global-state updates and can be garbage-collected.\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = (ctor as unknown as Record<symbol, unknown>)[Symbol.metadata] as Record<symbol, unknown> | undefined;\n const handlers = meta?.[SUBSCRIBE_HANDLERS] as SubscribeHandler[] | undefined;\n\n if (handlers) {\n const inst = this as unknown as Record<symbol, unknown>;\n\n for (const handler of handlers) {\n if (inst[handler.unsubKey]) {\n (inst[handler.unsubKey] as () => void)();\n inst[handler.unsubKey] = undefined;\n }\n }\n }\n }\n\n this._detachListeners();\n\n await this.willUnmount();\n await this.didUnmount();\n\n Component._onUnmount?.(this, tag);\n } catch (error) {\n if (Component._onError) {\n Component._onError(error as Error, this, tag, 'disconnectedCallback');\n } else {\n throw error;\n }\n }\n }\n\n /**\n * The standard custom-elements hook that tracks attribute changes.\n *\n * Pandora routes attribute updates into the fields you declared with\n * `@Attribute` / `@Property({ attribute })`, parses values for you (so\n * `\"42\"` arrives as a number, `\"true\"` as a boolean), fires `@Watch`\n * callbacks and `didChange()`, and schedules a render. Prefer those\n * decorators over overriding this hook — but if you must, call\n * `super.attributeChangedCallback(...)` first so the reactive plumbing\n * still runs.\n *\n * The browser only calls this hook for attributes named in\n * `observedAttributes`. Fields declared with `@Attribute` or\n * `@Property({ attribute: true })` register themselves in that list\n * automatically.\n *\n * @param property - The attribute name that changed.\n * @param oldValue - The previous attribute value, or `null` if unset.\n * @param newValue - The new attribute value, or `null` if removed.\n *\n * @example\n * class MyButton extends Component {\n * @Attribute() disabled = false;\n * // Pandora keeps `disabled` in sync with the DOM attribute for you.\n * }\n */\n attributeChangedCallback(property: string, _oldValue: string | null, newValue: string | null): void {\n // Dispatch to `@Attribute` / `@Property({ attribute })` handlers from\n // class metadata. Like `connectedCallback`, this has to sit on the\n // prototype because the browser only consults prototype methods at\n // `define()` time — instance-level shadows would be silently ignored on\n // real `setAttribute()` calls.\n if (typeof Symbol.metadata === 'undefined') {\n return;\n }\n\n const ctor = this.constructor as typeof Component;\n const meta = (ctor as unknown as Record<symbol, unknown>)[Symbol.metadata] as Record<symbol, unknown> | undefined;\n const handlers = meta?.[ATTR_HANDLERS] as AttrHandler[] | undefined;\n\n if (!handlers) {\n return;\n }\n\n const inst = this as unknown as Record<symbol, unknown>;\n\n for (const handler of handlers) {\n if (handler.attrName !== property) {\n continue;\n }\n\n // Break the feedback loop: when our own setter reflects a value back\n // to the DOM attribute, the browser calls us here — the `settingKey`\n // flag lets us tell those re-entrant writes apart from user-driven\n // attribute changes and skip them.\n if (inst[handler.settingKey]) {\n continue;\n }\n\n const parsedNew = newValue !== null ? parseAttributeValue(newValue) : undefined;\n const oldVal = inst[handler.valueKey];\n\n if (handler.equals(oldVal, parsedNew)) {\n continue;\n }\n\n inst[handler.valueKey] = parsedNew;\n\n const watchMeta = meta?.[WATCH_HANDLERS] as Array<{ property: string; methodName: string }> | undefined;\n\n if (watchMeta) {\n for (const entry of watchMeta) {\n if (entry.property === handler.propertyKey) {\n const method = (this as unknown as Record<string, unknown>)[entry.methodName];\n\n if (typeof method === 'function') {\n (method as (n: unknown, o: unknown) => void).call(this, parsedNew, oldVal);\n }\n }\n }\n }\n\n this.didChange(handler.propertyKey, oldVal, parsedNew, 'prop-attribute');\n\n if (handler.shouldRender && this._initRenderDone && this._connected) {\n this._queueRender();\n }\n }\n }\n\n /*\n * =========================\n * @Listen Support\n * =========================\n */\n\n /**\n * The `@Listen` bindings currently wired up on this instance. We track them\n * explicitly so we can remove the exact `(target, event, handler, options)`\n * triples we registered. `dynamic` flags a binding whose target is a CSS\n * selector — a node a render can replace — so only those are re-cycled\n * between renders; `index` ties a binding back to its metadata entry so a\n * one-shot listener can be recorded as consumed.\n *\n * @internal\n */\n private _activeListeners: Array<{ target: EventTarget; event: string; handler: EventListener; options?: boolean | AddEventListenerOptions; dynamic: boolean; index: number }> = [];\n\n /**\n * Whether the full `@Listen` set has been attached for the current\n * connection. Host, window, and document listeners are attached once per\n * connect and left in place across re-renders; only selector-targeted ones\n * are refreshed. Reset to `false` on disconnect.\n *\n * @internal\n */\n private _listenersAttached: boolean = false;\n\n /**\n * Indices of `@Listen` entries whose `once` has already fired during the\n * current connection. Consulted before (re-)binding so a one-shot listener\n * is never re-armed by a subsequent re-render. Cleared on disconnect, so a\n * reconnect arms one-shot listeners afresh.\n *\n * @internal\n */\n private _consumedOnceListeners: Set<number> = new Set();\n\n /**\n * Reads the `@Listen` metadata array for this instance's class, or\n * `undefined` when there are none (or metadata is unavailable).\n *\n * @internal\n */\n protected _listenerMetadata(): Array<{ event: string; methodName: string; options?: { target?: string; delegate?: string; capture?: boolean; passive?: boolean; once?: boolean } }> | undefined {\n if (typeof Symbol.metadata === 'undefined') {\n return undefined;\n }\n\n const meta = ((this.constructor as any)[Symbol.metadata]) as Record<symbol, unknown> | undefined;\n return meta?.[LISTEN_HANDLERS] as Array<{ event: string; methodName: string; options?: { target?: string; delegate?: string; capture?: boolean; passive?: boolean; once?: boolean } }> | undefined;\n }\n\n /**\n * Whether a listener targets a CSS selector — an element a render can\n * replace — rather than a stable target (the host, window, or document).\n * Only selector-targeted listeners are re-cycled between renders.\n *\n * @internal\n */\n private static _isDynamicListenerTarget(target?: string): boolean {\n return !!(target && target !== 'self' && target !== 'window' && target !== 'document');\n }\n\n /**\n * Binds a single `@Listen` entry to its resolved target and records it in\n * `_activeListeners`. Skips one-shot listeners already consumed this\n * connection, listeners whose method is missing, and selector targets not\n * yet in the DOM. Returns whether a binding was attached.\n *\n * @internal\n */\n protected _bindListener(\n listener: { event: string; methodName: string; options?: { target?: string; delegate?: string; capture?: boolean; passive?: boolean; once?: boolean } },\n index: number,\n ): boolean {\n const opts = listener.options;\n\n // A one-shot listener that already fired this connection must not be\n // re-armed when a later render refreshes the listener set.\n if (opts?.once && this._consumedOnceListeners.has(index)) {\n return false;\n }\n\n const method = (this as any)[listener.methodName];\n\n if (typeof method !== 'function') {\n return false;\n }\n\n const dynamic = Component._isDynamicListenerTarget(opts?.target);\n const resolvedTarget = resolveListenerTarget(this, opts?.target, (s) => this.query(s));\n\n if (!resolvedTarget) {\n return false;\n }\n\n const boundHandler = method.bind(this) as EventListener;\n\n const eventOpts: AddEventListenerOptions = {};\n\n if (opts?.capture) {\n eventOpts.capture = true;\n }\n\n if (opts?.passive) {\n eventOpts.passive = true;\n }\n\n let handler: EventListener;\n\n if (opts?.delegate) {\n // For delegated listeners we implement `once` ourselves: the native\n // `once` option would fire on the first event to bubble through,\n // regardless of whether it matched the delegate selector. We want\n // \"once it actually matches,\" so we retire the listener — and record it\n // as consumed — after the first matching dispatch.\n const delegateSelector = opts.delegate;\n const shouldOnce = opts?.once;\n\n handler = ((event: Event) => {\n const match = (event.target as Element)?.closest(delegateSelector);\n\n if (match) {\n if (shouldOnce) {\n this._consumedOnceListeners.add(index);\n resolvedTarget.removeEventListener(listener.event, handler, eventOpts);\n this._activeListeners = this._activeListeners.filter((l) => l.handler !== handler);\n }\n\n boundHandler(event);\n }\n }) as EventListener;\n } else if (opts?.once) {\n // Native one-shot: the browser auto-removes after the first fire, but we\n // wrap it to record the listener as consumed and keep `_activeListeners`\n // accurate so a later re-render won't re-arm it.\n handler = ((event: Event) => {\n this._consumedOnceListeners.add(index);\n this._activeListeners = this._activeListeners.filter((l) => l.handler !== handler);\n boundHandler(event);\n }) as EventListener;\n\n eventOpts.once = true;\n } else {\n handler = boundHandler;\n }\n\n resolvedTarget.addEventListener(listener.event, handler, eventOpts);\n this._activeListeners.push({ target: resolvedTarget, event: listener.event, handler, options: eventOpts, dynamic, index });\n return true;\n }\n\n /**\n * Wires up every `@Listen` binding. Called once per connection (on the first\n * render). Selectors are resolved at attach time, not at decoration time,\n * because the target nodes may only exist after a render has populated the\n * component's subtree.\n *\n * @internal\n */\n protected _attachListeners(): void {\n const listeners = this._listenerMetadata();\n\n if (!listeners) {\n return;\n }\n\n listeners.forEach((listener, index) => this._bindListener(listener, index));\n }\n\n /**\n * Re-cycles only the selector-targeted (`dynamic`) listeners after a\n * re-render. Their target nodes may have been replaced by the new markup, so\n * we detach the stale bindings and resolve fresh ones — while leaving host,\n * window, and document listeners (and any already-fired one-shots) in place.\n *\n * @internal\n */\n protected _refreshDynamicListeners(): void {\n const stable: typeof this._activeListeners = [];\n\n for (const active of this._activeListeners) {\n if (active.dynamic) {\n active.target.removeEventListener(active.event, active.handler, active.options);\n } else {\n stable.push(active);\n }\n }\n\n this._activeListeners = stable;\n\n const listeners = this._listenerMetadata();\n\n if (!listeners) {\n return;\n }\n\n listeners.forEach((listener, index) => {\n if (Component._isDynamicListenerTarget(listener.options?.target)) {\n this._bindListener(listener, index);\n }\n });\n }\n\n /**\n * Attaches `@Listen` bindings after a render: the full set on the first\n * render of a connection, and only the selector-targeted ones on later\n * re-renders (whose nodes the render may have replaced).\n *\n * @internal\n */\n protected _syncListenersAfterRender(): void {\n if (this._listenersAttached) {\n this._refreshDynamicListeners();\n } else {\n this._attachListeners();\n this._listenersAttached = true;\n }\n }\n\n /**\n * Removes every listener currently recorded in `_activeListeners`, clears the\n * tracking array, and resets the per-connection attach state. Called on\n * disconnect so no binding — or consumed-`once` record — outlives the\n * connection.\n *\n * @internal\n */\n protected _detachListeners(): void {\n for (const { target, event, handler, options } of this._activeListeners) {\n target.removeEventListener(event, handler, options);\n }\n\n this._activeListeners = [];\n this._listenersAttached = false;\n this._consumedOnceListeners.clear();\n }\n}\n\nexport default Component;\n",
34
+ "import Component from './Component.js';\nimport { DECORATOR_EFFECTS, DECORATOR_TEARDOWNS } from './Util.js';\n\n/** Tracks the last implementation class applied to an instance, to skip no-op reapplication. */\nconst APPLIED_IMPL: unique symbol = Symbol('pandora:appliedImpl');\n\n/** The key every copy of Pandora registers under on `globalThis`. */\nconst COPY_KEY = Symbol.for('@aegis-framework/pandora');\n\n/** Replaced with the package version when the bundles are built. */\ndeclare const __PANDORA_VERSION__: string | undefined;\n\n/** The version of Pandora that's running, such as `'0.7.0'` (`'development'` when it runs from source). */\nexport const VERSION: string = typeof __PANDORA_VERSION__ === 'string' ? __PANDORA_VERSION__ : 'development';\n\ntype ComponentClass = typeof Component & {\n tag: string;\n _registered?: boolean;\n};\n\n/** Receives `(newValue, oldValue)` whenever a subscribed state key changes. */\nexport type StateSubscriber<T = unknown> = (newValue: T, oldValue: T | undefined) => void;\n\n/** Receives every component instance (and its tag) passed to `onMount()` / `onUnmount()`. */\nexport type LifecycleCallback = (component: Component, tag: string) => void;\n\n/** Receives lifecycle errors routed through `onError()`. */\nexport type ErrorCallback = (error: Error, component: Component, tag: string, lifecycle: string) => void;\n\n/** The middleware pipelines `use()` accepts. */\nexport type MiddlewareType = 'render';\n\n/** Whether a render value is a plain string template or a lit-html result. */\nexport type RenderType = 'string' | 'lit';\n\n/** Transforms a component's render output; return the (possibly new) value. */\nexport type Middleware = (component: Component, value: unknown, renderType?: RenderType) => unknown;\n\n/** Resolves a lazy component's class, directly or as a module's `default` export. */\nexport type ComponentLoader = () => Promise<ComponentClass | { default: ComponentClass }>;\n\n/** What `stats()` reports for a tag. */\nexport interface ComponentStats {\n tag: string;\n instanceCount: number;\n isRegistered: boolean;\n isLazy: boolean;\n}\n\n/**\n * Pandora's central registry for custom elements, global state, lifecycle\n * observers, and the render middleware pipeline.\n *\n * Everything you register with `@Register` flows through here, and you can\n * also talk to it directly: keep a catalog of tags, hot-swap implementations\n * with `evolve()`, share values across the tree with `setState()` /\n * `subscribe()`, watch every mount and unmount, or wrap render output with\n * `use('render', ...)`.\n *\n * Most APIs are designed to be used from anywhere in your app — import the\n * default export and call the static methods directly. There's no instance\n * to construct.\n *\n * @example\n * import { Registry, Component, Register } from '@aegis-framework/pandora';\n *\n * @Register('theme-toggle')\n * class ThemeToggle extends Component {\n * render() {\n * return `<button>Toggle</button>`;\n * }\n * }\n *\n * Registry.setState('theme', 'dark');\n * const unsubscribe = Registry.subscribe('theme', (next) => {\n * document.documentElement.dataset.theme = next as string;\n * });\n */\nclass Registry {\n /** Backing store for the `debug` accessor; defaults off so logging stays quiet in production. @internal */\n private static _debug: boolean = false;\n\n private static components: Record<string, ComponentClass> = {};\n\n private static implementations: Record<string, ComponentClass> = {};\n\n private static state: Record<string, unknown> = {};\n private static subscribers: Record<string, Set<StateSubscriber>> = {};\n\n private static mountCallbacks: Set<LifecycleCallback> = new Set();\n private static unmountCallbacks: Set<LifecycleCallback> = new Set();\n private static errorCallbacks: Set<ErrorCallback> = new Set();\n private static aliases: Record<string, string> = {};\n private static lazyLoaders: Record<string, ComponentLoader> = {};\n private static lazyLoadPromises: Partial<Record<string, Promise<void>>> = {};\n\n private static middleware: Record<MiddlewareType, Set<Middleware>> = {\n render: new Set(),\n };\n\n /** Flipped true on the first `_init()` call so subsequent entry points skip re-wiring Component hooks. @internal */\n private static _initialized = false;\n\n /**\n * One-time bootstrap that wires Component's hook slots to Registry methods.\n * The `_initialized` guard keeps repeated entry points (register, lazy,\n * onMount, etc.) from re-installing the hooks on every call.\n *\n * @internal\n */\n private static _init(): void {\n if (this._initialized) {\n return;\n }\n\n this._initialized = true;\n\n Component._onMount = (component, tag) => this._notifyMount(component, tag);\n Component._onUnmount = (component, tag) => this._notifyUnmount(component, tag);\n Component._onError = (error, component, tag, lifecycle) => this._notifyError(error, component, tag, lifecycle);\n Component._applyMiddleware = (type, component, value, renderType) => this._applyMiddleware(type as MiddlewareType, component, value, renderType);\n Component._hasMiddleware = (type) => this._hasMiddleware(type as MiddlewareType);\n Component._subscribe = (key, cb) => this.subscribe(key, cb);\n Component._getGlobalState = (key) => this.getState(key);\n\n Component._applyCurrentImplementation = (instance, tag) => {\n // If evolve() has swapped in a different class since this instance was\n // constructed, re-apply it so the instance behaves like the new version.\n // We track the last-applied class on the instance to skip no-ops when\n // the implementation hasn't moved since we last touched it.\n const current = this.implementations[tag];\n\n if (!current) {\n return;\n }\n\n const inst = instance as unknown as Record<symbol, unknown>;\n const last = inst[APPLIED_IMPL] as ComponentClass | undefined;\n const base = last ?? (instance.constructor as ComponentClass);\n\n if (current === base) {\n return;\n }\n\n this._applyImplementation(instance, current, false);\n };\n }\n\n /**\n * Associates a tag name with a component class and defines it on\n * `window.customElements`.\n *\n * You usually don't call this yourself — `@Register('my-tag')` does it for\n * you — but it's useful when you construct component classes dynamically\n * or register them from a bootstrapper. Throws if the tag is already\n * taken; reach for `evolve()` to swap an implementation instead.\n *\n * @param tag - The custom element tag to register under.\n * @param component - The component class to associate with the tag.\n *\n * @example\n * class MyGreeting extends Component {\n * render() { return `<p>Hello</p>`; }\n * }\n *\n * Registry.register('my-greeting', MyGreeting);\n */\n static register(tag: string, component: ComponentClass): void {\n this._init();\n\n if (typeof this.components[tag] === 'undefined') {\n this.components[tag] = component;\n this.implementations[tag] = component;\n component.tag = tag;\n\n window.customElements.define(tag, component);\n\n this.components[tag]._registered = true;\n this.log(`Registered: <${tag}>`);\n } else {\n throw new Error(`[Pandora] <${tag}> is already registered. Use Registry.evolve('${tag}', NewClass) to swap its implementation.`);\n }\n }\n\n /**\n * Activates a deferred component by running the same work as `register()`.\n *\n * Use this with components decorated `@Register('my-tag', { defer: true })`\n * when you're ready to define them on `customElements`. Behaviorally\n * identical to `register()`; the different name just makes intent clearer\n * at the call site.\n *\n * @param tag - The tag to activate.\n * @param component - The component class to define.\n *\n * @example\n * @Register('lazy-chart', { defer: true })\n * class LazyChart extends Component { render() { return ''; } }\n *\n * // Later, when you're ready to light it up:\n * Registry.define('lazy-chart', LazyChart);\n */\n static define(tag: string, component: ComponentClass): void {\n this.register(tag, component);\n }\n\n /**\n * Returns the class currently backing a tag, including any version\n * installed by `evolve()` or a resolved lazy loader.\n *\n * Unlike `get()`, which always returns the originally-registered class,\n * this method follows `evolve()` swaps so tooling and debuggers can\n * inspect the live behavior.\n *\n * @param tag - The tag to look up.\n * @returns The active implementation, or `undefined` if the tag is unknown.\n *\n * @example\n * const CurrentButton = Registry.getImplementation('my-button');\n */\n static getImplementation(tag: string): ComponentClass | undefined {\n return this.implementations[tag] || this.components[tag];\n }\n\n /**\n * Applies a source class's prototype, field defaults, metadata, and\n * decorator effects to a live instance. Used for both the evolve() swap\n * and lazy-load upgrade paths: we can't redefine the custom element, so\n * we replay the new class's behavior onto each existing instance.\n *\n * @internal\n */\n static _applyImplementation(instance: Component, source: ComponentClass, _merge: boolean = false): void {\n const proto = source.prototype as unknown as Record<string, unknown>;\n const protoMethods = Object.getOwnPropertyNames(proto);\n const inst = instance as unknown as Record<string, unknown>;\n (instance as unknown as Record<symbol, unknown>)[APPLIED_IMPL] = source;\n\n for (const method of protoMethods) {\n if (method === 'constructor') {\n continue;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(proto, method);\n\n if (!descriptor) {\n continue;\n }\n\n if (typeof descriptor.value === 'function') {\n inst[method] = descriptor.value.bind(instance);\n } else if (descriptor.get || descriptor.set) {\n // Copy accessor descriptors onto the prototype so @Computed and\n // other accessor-based decorators remain reachable. Instance-level\n // overrides are installed later when we replay decorator effects.\n Object.defineProperty(Object.getPrototypeOf(instance), method, descriptor);\n }\n }\n\n // We construct a throwaway instance of the source class to run its\n // decorator initializers (which capture field defaults in closures for\n // later replay) and to harvest plain field defaults we can copy over.\n //\n // For evolved or lazy classes, `source` isn't what was handed to\n // customElements.define(), so Reflect.construct(source, [], source)\n // would throw. Passing the registered class as new.target satisfies\n // the browser while still running source's constructor body.\n try {\n const registeredClass = customElements.get(instance.localName) ?? (instance.constructor as ComponentClass) ?? source;\n const temp = Reflect.construct(source, [], registeredClass) as unknown as Record<string, unknown>;\n\n for (const key of Object.keys(temp)) {\n if (!(key in inst) || inst[key] === undefined) {\n inst[key] = temp[key];\n }\n }\n } catch (error) {\n // Abstract classes and unusual constructors can fail this step. We\n // surface it so component authors aren't left guessing why their\n // defaults didn't copy over.\n console.warn(`[Pandora] Could not construct temp instance of <${source.tag}> for default extraction:`, error);\n }\n\n // Move the source class's metadata onto the registered class so that\n // runtime lookups (getWatchersForProperty, @Computed invalidation, and\n // friends) going through instance.constructor[Symbol.metadata] find\n // the new class's definitions instead of the stale originals.\n if (typeof Symbol.metadata !== 'undefined') {\n const sourceMeta = (source as any)[Symbol.metadata];\n\n if (sourceMeta) {\n const registeredClass = instance.constructor;\n (registeredClass as any)[Symbol.metadata] = sourceMeta;\n }\n }\n\n // Replay the source class's decorator effects. We tear down any\n // effects left from a previous implementation first so subscriptions\n // and watchers don't accumulate across successive evolve() calls.\n if (typeof Symbol.metadata !== 'undefined') {\n const meta = (source as any)[Symbol.metadata];\n const effects = meta?.[DECORATOR_EFFECTS] as ((inst: Component) => void)[] | undefined;\n\n if (effects?.length) {\n const teardowns = inst[DECORATOR_TEARDOWNS as unknown as string] as (() => void)[] | undefined;\n\n if (teardowns) {\n for (const teardown of teardowns) {\n teardown();\n }\n }\n\n inst[DECORATOR_TEARDOWNS as unknown as string] = [];\n\n for (const effect of effects) {\n effect(instance as any);\n }\n }\n }\n\n // The swap rebinds methods and reassigns metadata, so any `@Listen`\n // handlers attached against the previous implementation are now stale:\n // they still point at the old method functions, and listeners newly\n // declared by `source` aren't bound at all. Detaching here (which also\n // clears the per-connection attach flag) makes the render that always\n // follows an implementation swap re-attach the full listener set —\n // host/window/document and selector targets alike — against the new\n // methods and metadata. It's a no-op for instances not yet rendered.\n (instance as unknown as { _detachListeners(): void })._detachListeners();\n }\n\n /**\n * Hot-swaps the implementation behind a registered tag, so every future\n * instance uses the new class.\n *\n * The browser only lets you call `customElements.define()` once per tag,\n * so Pandora keeps the original class bound to the tag and replays the\n * new class's prototype methods, field defaults, and decorator effects\n * onto each live instance. Aliases created with `alias()` also pick up\n * the swap.\n *\n * Pass `true` as the third argument to force an immediate re-render of\n * every live instance (including aliased ones). Without it, already-mounted\n * components keep running the old code until they naturally re-render.\n *\n * @param tag - The existing tag whose implementation you're replacing.\n * @param component - The new component class to install.\n * @param rerender - When `true`, re-renders every mounted instance right away.\n *\n * @example\n * class MyCounter extends Component {\n * render() { return `<span>v1</span>`; }\n * }\n * Registry.register('my-counter', MyCounter);\n *\n * class MyCounterV2 extends Component {\n * render() { return `<span>v2</span>`; }\n * }\n * Registry.evolve('my-counter', MyCounterV2, true);\n */\n static evolve(tag: string, component: ComponentClass, rerender: boolean = false): void {\n if (typeof this.components[tag] === 'undefined') {\n throw new Error(`[Pandora] Cannot evolve <${tag}>: no component with that tag has been registered.`);\n }\n\n this.implementations[tag] = component;\n component._registered = true;\n\n // Propagate the new implementation to every alias of this tag. We do\n // this unconditionally — not only on the rerender path — because\n // _applyCurrentImplementation consults the implementation map on every\n // natural connect, and we want future alias instances to pick up the\n // swap too.\n const aliasTags: string[] = [];\n\n for (const [aliasTag, originalTag] of Object.entries(this.aliases)) {\n if (originalTag === tag) {\n aliasTags.push(aliasTag);\n this.implementations[aliasTag] = component;\n }\n }\n\n this.log(`Evolved: <${tag}>`);\n\n if (rerender) {\n // Walk aliases alongside the primary tag so live alias instances\n // get the swap too. We gate on isReady because forceRender() against\n // a half-constructed instance would double up its initial render.\n const tagsToUpdate = [tag, ...aliasTags];\n\n for (const updateTag of tagsToUpdate) {\n document.querySelectorAll(updateTag).forEach((instance) => {\n if (instance instanceof Component && (instance as Component).isReady) {\n this._applyImplementation(instance as Component, component, true);\n (instance as Component).forceRender();\n }\n });\n }\n }\n }\n\n /**\n * Finds every live instance of a tag in the document.\n *\n * With one argument, returns the matching `NodeList` so you can iterate\n * it yourself. Pass a callback as the second argument and Pandora will\n * iterate for you and return nothing. Throws if the tag isn't registered.\n *\n * @param tag - The tag whose instances you want.\n * @param callback - Optional iterator invoked once per instance.\n * @returns A `NodeList` when no callback is provided; otherwise `void`.\n *\n * @example\n * // Collect every instance:\n * const buttons = Registry.instances('my-button');\n *\n * // Or iterate them directly:\n * Registry.instances('my-button', (el) => {\n * (el as HTMLElement).classList.add('ready');\n * });\n */\n static instances(tag: string): NodeListOf<Element>;\n\n static instances(tag: string, callback: (instance: Element) => void): void;\n\n static instances(tag: string, callback?: (instance: Element) => void): NodeListOf<Element> | void {\n if (typeof this.components[tag] === 'undefined') {\n throw new Error(`[Pandora] No component with tag <${tag}> has been registered.`);\n }\n\n if (typeof callback === 'function') {\n document.querySelectorAll(tag).forEach(callback);\n } else {\n return document.querySelectorAll(tag);\n }\n }\n\n /**\n * Builds a detached element for a registered tag and seeds its initial\n * props and attributes.\n *\n * The returned element is created with `document.createElement` but not\n * attached anywhere — you choose where it lives by calling\n * `parent.appendChild(...)` or similar. Values are assigned as properties;\n * for plain fields without a reactive setter, string, number, and truthy\n * boolean values also mirror to the matching attribute.\n *\n * @param tag - The registered tag to create.\n * @param props - Initial property values keyed by field name.\n * @returns A detached component instance ready to attach.\n *\n * @example\n * const avatar = Registry.instantiate<UserAvatar>('user-avatar', {\n * userId: 'u_42',\n * size: 48\n * });\n * document.body.appendChild(avatar);\n */\n static instantiate<T extends Component = Component>(tag: string, props: Record<string, any> = {}): T {\n if (!this.has(tag)) {\n throw new Error(`[Pandora] No component with tag <${tag}> has been registered.`);\n }\n\n if (!this.components[tag]._registered) {\n this.register(tag, this.components[tag]);\n }\n\n const element = document.createElement(this.components[tag].tag) as T;\n\n // We always assign as a property. @Attribute and @Property({ attribute })\n // fields mirror through their setters to the correct (possibly renamed)\n // attribute on their own, so we only need to manually set an attribute\n // for plain fields that don't have a reactive setter to do it for us.\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined || value === null) {\n continue;\n }\n\n (element as any)[key] = value;\n\n const hasReactiveSetter = Object.getOwnPropertyDescriptor(element, key)?.set !== undefined;\n\n if (hasReactiveSetter) {\n continue;\n }\n\n if (typeof value === 'boolean') {\n if (value) {\n element.setAttribute(key, '');\n }\n } else if (typeof value === 'string' || typeof value === 'number') {\n element.setAttribute(key, String(value));\n }\n }\n\n return element;\n }\n\n /**\n * Checks whether any component is registered under the given tag.\n *\n * Includes aliases and lazy components, since both are tracked in the\n * same catalog.\n *\n * @param tag - The tag to check.\n * @returns `true` if the tag is known to Registry.\n *\n * @example\n * if (!Registry.has('theme-toggle')) {\n * Registry.register('theme-toggle', ThemeToggle);\n * }\n */\n static has(tag: string): boolean {\n return typeof this.components[tag] !== 'undefined';\n }\n\n /**\n * Returns the originally-registered class for a tag.\n *\n * If you want the current implementation (honoring `evolve()`), use\n * `getImplementation()` instead.\n *\n * @param tag - The tag to look up.\n * @returns The registered class, or `undefined` if the tag is unknown.\n *\n * @example\n * const ThemeToggle = Registry.get('theme-toggle');\n */\n static get(tag: string): ComponentClass | undefined {\n return this.components[tag];\n }\n\n /*\n * =========================\n * Global State Management\n * =========================\n */\n\n /**\n * Stores a value under the given key and synchronously notifies every\n * `subscribe()` callback registered on that key.\n *\n * Subscribers run in registration order and receive `(newValue, oldValue)`.\n * If a callback throws, the error propagates — wrap risky work yourself.\n *\n * @param key - The state key.\n * @param value - The new value.\n *\n * @example\n * Registry.setState('theme', 'dark');\n * Registry.setState('user', { id: 'u_42', name: 'Ada' });\n */\n static setState<T>(key: string, value: T): void {\n const oldValue = this.state[key] as T | undefined;\n this.state[key] = value;\n\n if (this.subscribers[key]) {\n this.subscribers[key].forEach((callback) => {\n callback(value, oldValue);\n });\n }\n }\n\n /**\n * Reads the current value stored under a key.\n *\n * Returns `undefined` if nothing has been set, which is indistinguishable\n * from a value that was explicitly set to `undefined` — use `hasState()`\n * if you need to tell them apart.\n *\n * @param key - The state key to read.\n * @returns The current value, or `undefined` if the key is unset.\n *\n * @example\n * const theme = Registry.getState<'light' | 'dark'>('theme');\n */\n static getState<T>(key: string): T | undefined {\n return this.state[key] as T | undefined;\n }\n\n /**\n * Checks whether a state key has been set.\n *\n * Useful when you need to distinguish \"never set\" from \"set to `undefined`.\"\n *\n * @param key - The state key to check.\n * @returns `true` if the key exists in the store.\n *\n * @example\n * if (!Registry.hasState('theme')) {\n * Registry.setState('theme', 'light');\n * }\n */\n static hasState(key: string): boolean {\n return key in this.state;\n }\n\n /**\n * Removes a state key and notifies subscribers with `(undefined, oldValue)`.\n *\n * Returns `false` if the key wasn't present, so subscribers aren't called\n * for no-ops.\n *\n * @param key - The state key to delete.\n * @returns `true` if the key existed and was removed.\n *\n * @example\n * Registry.deleteState('user');\n */\n static deleteState(key: string): boolean {\n if (key in this.state) {\n const oldValue = this.state[key];\n delete this.state[key];\n\n // Subscribers see undefined as the new value — this mirrors what\n // getState() will return from now on, so observers can treat delete\n // and \"set to undefined\" uniformly.\n if (this.subscribers[key]) {\n this.subscribers[key].forEach((callback) => {\n callback(undefined, oldValue);\n });\n }\n\n return true;\n }\n\n return false;\n }\n\n /**\n * Listens for changes to a state key.\n *\n * The callback fires only on future `setState()` and `deleteState()` calls —\n * it does not run immediately with the current value, so call `getState()`\n * yourself if you need to seed initial UI. Call the returned function to\n * stop listening.\n *\n * @param key - The state key to watch.\n * @param callback - Receives `(newValue, oldValue)` whenever the key changes.\n * @returns A function that removes this subscription.\n *\n * @example\n * const stop = Registry.subscribe<'light' | 'dark'>('theme', (next, prev) => {\n * console.log(`theme changed from ${prev} to ${next}`);\n * });\n *\n * // Later, when you no longer care:\n * stop();\n */\n static subscribe<T>(key: string, callback: StateSubscriber<T>): () => void {\n if (!this.subscribers[key]) {\n this.subscribers[key] = new Set();\n }\n\n this.subscribers[key].add(callback as StateSubscriber);\n\n return () => {\n this.unsubscribe(key, callback);\n };\n }\n\n /**\n * Removes a specific callback from a state key's subscription list.\n *\n * Most of the time you'll use the function returned by `subscribe()`\n * instead — this overload is available when you need to hold a reference\n * to the callback separately.\n *\n * @param key - The state key you subscribed to.\n * @param callback - The exact callback reference to remove.\n *\n * @example\n * const onThemeChange = (next: unknown) => console.log(next);\n * Registry.subscribe('theme', onThemeChange);\n * Registry.unsubscribe('theme', onThemeChange);\n */\n static unsubscribe<T>(key: string, callback: StateSubscriber<T>): void {\n if (this.subscribers[key]) {\n this.subscribers[key].delete(callback as StateSubscriber);\n }\n }\n\n /**\n * Returns a shallow copy of every key/value pair currently in the store.\n *\n * Handy for debugging, snapshotting, or serializing state. The copy is\n * shallow, so nested objects still share references with the live state.\n *\n * @returns A new object with all current state entries.\n *\n * @example\n * const snapshot = Registry.getAllState();\n * console.log(snapshot);\n */\n static getAllState(): Record<string, unknown> {\n return { ...this.state };\n }\n\n /**\n * Removes every state key and notifies subscribers for each one.\n *\n * Each key is deleted via `deleteState()`, so subscribers receive\n * `(undefined, oldValue)` per key in insertion order. This is most useful\n * between tests; reach for `deleteState()` for targeted cleanup.\n *\n * @example\n * afterEach(() => {\n * Registry.clearState();\n * });\n */\n static clearState(): void {\n const keys = Object.keys(this.state);\n\n for (const key of keys) {\n this.deleteState(key);\n }\n }\n\n /**\n * Drops every subscription registered via `subscribe()`.\n *\n * After this call, stored values remain untouched, but no callbacks will\n * fire on future changes. Intended for test teardown — in app code,\n * prefer the unsubscribe function each subscription returns.\n *\n * @example\n * afterEach(() => {\n * Registry.clearSubscriptions();\n * });\n */\n static clearSubscriptions(): void {\n for (const key of Object.keys(this.subscribers)) {\n this.subscribers[key] = new Set();\n }\n }\n\n /**\n * Removes every middleware registered through `use()`.\n *\n * Mainly for test isolation, since middleware survives between specs\n * otherwise.\n *\n * @example\n * afterEach(() => {\n * Registry.clearMiddleware();\n * });\n */\n static clearMiddleware(): void {\n for (const key of Object.keys(this.middleware) as MiddlewareType[]) {\n this.middleware[key] = new Set();\n }\n }\n\n /*\n * =========================\n * Debugging Tools\n * =========================\n */\n\n /**\n * Toggles Pandora's debug logging.\n *\n * When `true`, Registry and Component write lifecycle events to the\n * console (`Registered`, `Mounted`, `Evolved`, error traces, and so on).\n * Defaults to `false`.\n *\n * @example\n * Registry.debug = true;\n */\n static get debug(): boolean {\n return this._debug;\n }\n\n static set debug(value: boolean) {\n this._debug = value;\n }\n\n /**\n * Writes a `[Pandora] …` message to the console when debug mode is on.\n *\n * Use this for your own logging if you want it to stay silent in\n * production but pop up when you flip `Registry.debug = true`.\n *\n * @param message - Text to log.\n * @param data - Optional extra value logged alongside the message.\n *\n * @example\n * Registry.debug = true;\n * Registry.log('user signed in', { id: 'u_42' });\n */\n static log(message: string, data?: unknown): void {\n if (this._debug) {\n if (data !== undefined) {\n console.log(`[Pandora] ${message}`, data);\n } else {\n console.log(`[Pandora] ${message}`);\n }\n }\n }\n\n /**\n * Returns every tag currently known to Registry.\n *\n * Includes aliases and lazy placeholders alongside normally-registered\n * tags.\n *\n * @returns An array of tag names.\n *\n * @example\n * console.log(Registry.list()); // ['my-greeting', 'theme-toggle', ...]\n */\n static list(): string[] {\n return Object.keys(this.components);\n }\n\n /**\n * Reports current info about registered components: how many are mounted,\n * whether they're active, and whether they're still lazy.\n *\n * Called with a tag, returns a single stats object (throws if the tag is\n * unknown). Called with no argument, returns an array covering every\n * registered tag.\n *\n * @param tag - Optional specific tag to inspect.\n * @returns Stats for one tag or an array of stats for all tags.\n *\n * @example\n * Registry.stats('my-button');\n * // { tag: 'my-button', instanceCount: 3, isRegistered: true, isLazy: false }\n *\n * Registry.stats();\n * // [{ tag: 'my-button', ... }, { tag: 'theme-toggle', ... }]\n */\n static stats(tag: string): ComponentStats;\n\n static stats(): ComponentStats[];\n\n static stats(tag?: string): ComponentStats | ComponentStats[] {\n if (tag) {\n if (!this.has(tag)) {\n throw new Error(`[Pandora] No component with tag <${tag}> has been registered.`);\n }\n\n return {\n tag,\n instanceCount: document.querySelectorAll(tag).length,\n isRegistered: this.components[tag]?._registered ?? false,\n isLazy: tag in this.lazyLoaders,\n };\n }\n\n return this.list().map((tag) => ({\n tag: tag,\n instanceCount: document.querySelectorAll(tag).length,\n isRegistered: this.components[tag]?._registered ?? false,\n isLazy: tag in this.lazyLoaders,\n }));\n }\n\n /*\n * =========================\n * Global Lifecycle Hooks\n * =========================\n */\n\n /**\n * Observes every component mount across your app.\n *\n * Your callback runs once for each component after its `connectedCallback`\n * resolves, receiving the instance and its tag. Useful for analytics,\n * wiring up dev tooling, or running a setup step whenever any Pandora\n * component appears.\n *\n * @param callback - Invoked with `(component, tag)` on every mount.\n * @returns A function that removes this observer.\n *\n * @example\n * const stop = Registry.onMount((component, tag) => {\n * console.log(`<${tag}> mounted`, component);\n * });\n */\n static onMount(callback: LifecycleCallback): () => void {\n this._init();\n this.mountCallbacks.add(callback);\n\n return () => this.mountCallbacks.delete(callback);\n }\n\n /**\n * Observes every component unmount across your app.\n *\n * Fires after `disconnectedCallback` completes, receiving the instance\n * and its tag. Pair it with `onMount()` to track lifecycles globally.\n *\n * @param callback - Invoked with `(component, tag)` on every unmount.\n * @returns A function that removes this observer.\n *\n * @example\n * Registry.onUnmount((component, tag) => {\n * console.log(`<${tag}> unmounted`);\n * });\n */\n static onUnmount(callback: LifecycleCallback): () => void {\n this._init();\n this.unmountCallbacks.add(callback);\n\n return () => this.unmountCallbacks.delete(callback);\n }\n\n /**\n * Fans a mount event out to every onMount observer. Each callback is\n * wrapped in try/catch so one misbehaving handler can't take down the\n * rest of the chain or the mounting component itself.\n *\n * @internal\n */\n static _notifyMount(component: Component, tag: string): void {\n this.log(`Mounted: <${tag}>`);\n\n this.mountCallbacks.forEach((callback) => {\n try {\n callback(component, tag);\n } catch (error) {\n console.error('[Pandora] Error in onMount callback:', error);\n }\n });\n }\n\n /**\n * Fans an unmount event out to every onUnmount observer. Same\n * per-callback error isolation as _notifyMount so teardown keeps moving\n * even when a single observer throws.\n *\n * @internal\n */\n static _notifyUnmount(component: Component, tag: string): void {\n this.log(`Unmounted: <${tag}>`);\n\n this.unmountCallbacks.forEach((callback) => {\n try {\n callback(component, tag);\n } catch (error) {\n console.error('[Pandora] Error in onUnmount callback:', error);\n }\n });\n }\n\n /*\n * =========================\n * Error Boundaries\n * =========================\n */\n\n /**\n * Installs a global error handler for component lifecycle errors.\n *\n * When a component throws during mount, render, or another lifecycle\n * step, each registered handler runs with `(error, component, tag,\n * lifecycle)`. If no handlers are registered, the error is re-thrown so\n * you still see failures in development.\n *\n * @param callback - Invoked with details about the failure.\n * @returns A function that removes this handler.\n *\n * @example\n * Registry.onError((error, component, tag, lifecycle) => {\n * console.error(`<${tag}> crashed in ${lifecycle}`, error);\n * reportToSentry(error, { tag, lifecycle });\n * });\n */\n static onError(callback: ErrorCallback): () => void {\n this._init();\n this.errorCallbacks.add(callback);\n\n return () => this.errorCallbacks.delete(callback);\n }\n\n /**\n * Dispatches a component lifecycle error. When no onError observers are\n * registered we re-throw so failures stay visible during development;\n * once any observer is installed, errors flow through the callback\n * chain (each wrapped in try/catch to isolate misbehaving handlers).\n *\n * @internal\n */\n static _notifyError(error: Error, component: Component, tag: string, lifecycle: string): void {\n this.log(`Error in <${tag}> during ${lifecycle}:`, error);\n\n if (this.errorCallbacks.size === 0) {\n throw error;\n }\n\n this.errorCallbacks.forEach((callback) => {\n try {\n callback(error, component, tag, lifecycle);\n } catch (callbackError) {\n console.error('[Pandora] Error in onError callback:', callbackError);\n }\n });\n }\n\n /*\n * =========================\n * Component Aliases\n * =========================\n */\n\n /**\n * Creates a second tag that renders the same component as an existing one.\n *\n * Under the hood, Pandora defines a lightweight subclass of the original\n * component and registers it under the new tag, so both tags render\n * independently while sharing behavior. Later `evolve()` calls on the\n * original flow through to the alias automatically.\n *\n * Set the alias up *before* any `<alias-tag>` element appears in the\n * document — this is what actually defines the custom element. Throws if\n * the alias name is already taken or the original isn't registered.\n *\n * @param aliasTag - The new tag name to register.\n * @param originalTag - The existing tag to mirror.\n *\n * @example\n * Registry.register('my-button', MyButton);\n * Registry.alias('primary-button', 'my-button');\n *\n * // <primary-button> now behaves just like <my-button>.\n */\n static alias(aliasTag: string, originalTag: string): void {\n if (!this.has(originalTag)) {\n throw new Error(`[Pandora] Cannot alias <${aliasTag}>: no component with tag <${originalTag}> has been registered.`);\n }\n\n if (this.has(aliasTag)) {\n throw new Error(`[Pandora] Cannot alias <${aliasTag}>: a component with that tag already exists.`);\n }\n\n this.aliases[aliasTag] = originalTag;\n\n // We create a subclass with its own _tag so customElements.define accepts\n // it, but it otherwise inherits everything from the original. Later\n // evolve() calls on the original can be fanned out to the alias through\n // the implementations map.\n const OriginalClass = this.getImplementation(originalTag) ?? this.components[originalTag];\n\n const AliasClass = class extends (OriginalClass as typeof Component) {\n static _tag = aliasTag;\n };\n\n this.components[aliasTag] = AliasClass as unknown as ComponentClass;\n this.implementations[aliasTag] = AliasClass as unknown as ComponentClass;\n window.customElements.define(aliasTag, AliasClass);\n (AliasClass as unknown as ComponentClass)._registered = true;\n\n this.log(`Created alias: <${aliasTag}> -> <${originalTag}>`);\n }\n\n /**\n * Looks up the tag a given alias points to.\n *\n * @param aliasTag - A tag that was created with `alias()`.\n * @returns The underlying tag, or `undefined` if `aliasTag` isn't an alias.\n *\n * @example\n * Registry.alias('primary-button', 'my-button');\n * Registry.getOriginalTag('primary-button'); // 'my-button'\n * Registry.getOriginalTag('my-button'); // undefined\n */\n static getOriginalTag(aliasTag: string): string | undefined {\n return this.aliases[aliasTag];\n }\n\n /**\n * Reports whether a tag was created via `alias()`.\n *\n * @param tag - The tag to check.\n * @returns `true` if this tag is an alias of another registered tag.\n *\n * @example\n * Registry.isAlias('primary-button'); // true\n * Registry.isAlias('my-button'); // false\n */\n static isAlias(tag: string): boolean {\n return tag in this.aliases;\n }\n\n /*\n * =========================\n * Lazy Loading\n * =========================\n */\n\n /**\n * Registers a tag whose implementation is fetched on demand.\n *\n * Pandora defines a placeholder custom element right away, so you can put\n * `<lazy-chart>` in markup immediately. The first time one connects, the\n * loader runs, its resolved class is applied to every pending instance,\n * and the loader is discarded — subsequent instances reuse the already-\n * loaded implementation without calling the loader again.\n *\n * The loader can return either the class directly or a module namespace\n * with a `default` export, so dynamic `import()` calls work out of the box.\n *\n * @param tag - The tag to reserve for lazy loading.\n * @param loader - Async function that resolves to the component class.\n *\n * @example\n * Registry.lazy('lazy-chart', () => import('./LazyChart'));\n *\n * // Somewhere in your markup:\n * // <lazy-chart data-metric=\"signups\"></lazy-chart>\n */\n static lazy(tag: string, loader: ComponentLoader): void {\n this._init();\n\n if (this.has(tag)) {\n throw new Error(`[Pandora] Cannot register lazy <${tag}>: a component with that tag already exists.`);\n }\n\n this.lazyLoaders[tag] = loader;\n\n // Capture the static registry as a local so the placeholder's\n // connectedCallback body reads cleanly.\n const registry = Registry;\n\n // A placeholder custom element we can define right away. When its first\n // instance connects we kick off the loader, swap the resolved class's\n // behavior onto this instance via _applyImplementation, then hand off\n // to Component's own connectedCallback so mount proceeds as normal.\n class LazyComponent extends Component {\n static _tag = tag;\n private _lazyLoaded = false;\n\n async connectedCallback(): Promise<void> {\n await registry._loadLazyComponent(tag);\n\n const RealComponent = registry.getImplementation(tag);\n\n if (RealComponent && RealComponent !== LazyComponent) {\n Registry._applyImplementation(this, RealComponent, false);\n this._lazyLoaded = true;\n }\n\n await super.connectedCallback();\n }\n }\n\n this.components[tag] = LazyComponent as unknown as ComponentClass;\n window.customElements.define(tag, LazyComponent);\n this.log(`Registered lazy component: <${tag}>`);\n }\n\n /**\n * Runs a registered lazy loader once, resolves its module-or-class\n * result, and installs the class as the live implementation for the\n * tag. We delete the loader afterwards so later instances short-circuit\n * and reuse the cached implementation instead of re-invoking import().\n *\n * @internal\n */\n static async _loadLazyComponent(tag: string): Promise<void> {\n if (this.lazyLoadPromises[tag]) {\n return this.lazyLoadPromises[tag];\n }\n\n if (!(tag in this.lazyLoaders)) {\n return;\n }\n\n const loader = this.lazyLoaders[tag];\n this.log(`Loading lazy component: <${tag}>`);\n\n this.lazyLoadPromises[tag] = (async () => {\n try {\n const result = await loader();\n const componentClass = 'default' in result ? result.default : result;\n\n // One-shot: drop the loader so subsequent connects skip the fetch\n // and go straight to the implementation swap.\n delete this.lazyLoaders[tag];\n\n this.implementations[tag] = componentClass;\n componentClass._registered = true;\n\n this.log(`Loaded lazy component: <${tag}>`);\n } catch (error) {\n console.error(`[Pandora] Failed to load lazy component <${tag}>:`, error);\n throw error;\n } finally {\n delete this.lazyLoadPromises[tag];\n }\n })();\n\n return this.lazyLoadPromises[tag];\n }\n\n /**\n * Reports whether a tag is still waiting to be lazily loaded.\n *\n * Returns `true` only while the loader has not yet run; once a lazy\n * component has loaded (via mount or `preload()`), this returns `false`.\n *\n * @param tag - The tag to check.\n * @returns `true` if the loader is registered and hasn't fired yet.\n *\n * @example\n * if (Registry.isLazy('lazy-chart')) {\n * await Registry.preload('lazy-chart');\n * }\n */\n static isLazy(tag: string): boolean {\n return tag in this.lazyLoaders;\n }\n\n /**\n * Runs a lazy component's loader without having to mount it first.\n *\n * Handy for warming up components you'll need soon (route transitions,\n * about-to-open dialogs). No-ops if the tag isn't lazy or has already\n * been loaded.\n *\n * @param tag - The lazy tag to load ahead of time.\n *\n * @example\n * // Prime the chart before the user opens the dashboard:\n * await Registry.preload('lazy-chart');\n */\n static async preload(tag: string): Promise<void> {\n if (this.isLazy(tag)) {\n await this._loadLazyComponent(tag);\n }\n }\n\n /*\n * =========================\n * Middleware\n * =========================\n */\n\n /**\n * Installs a middleware function into one of Pandora's pipelines.\n *\n * Today the only supported type is `'render'`, which receives each\n * component's render output before it's applied to the DOM. Multiple\n * middleware run in registration order, and each one sees the value the\n * previous one returned, so you can chain transforms. The `renderType`\n * argument tells you whether the value is a plain string template or a\n * lit-html `TemplateResult`, so you can handle them appropriately.\n *\n * If a middleware throws, the error is logged via `console.error` and\n * the pipeline continues with the value it received, so one faulty\n * middleware can't break the chain.\n *\n * @param type - The middleware pipeline to hook into (currently `'render'`).\n * @param middleware - Receives `(component, value, renderType?)` and returns the new value.\n * @returns A function that removes this middleware.\n *\n * @example\n * const stop = Registry.use('render', (component, value, renderType) => {\n * if (renderType === 'string' && typeof value === 'string') {\n * return value.replace(/TODO/g, '<mark>TODO</mark>');\n * }\n * return value;\n * });\n */\n static use(type: MiddlewareType, middleware: Middleware): () => void {\n this._init();\n this.middleware[type].add(middleware);\n\n return () => this.middleware[type].delete(middleware);\n }\n\n /**\n * Threads a value through every registered middleware in insertion\n * order, each one seeing the previous one's return value. Throws are\n * caught and logged — the faulty middleware contributes nothing and the\n * previous result passes through unchanged so one bad hook can't break\n * the render pipeline.\n *\n * @internal\n */\n static _applyMiddleware(type: MiddlewareType, component: Component, value: unknown, renderType?: RenderType): unknown {\n let result = value;\n\n this.middleware[type].forEach((middleware) => {\n try {\n result = middleware(component, result, renderType);\n } catch (error) {\n console.error(`[Pandora] Error in ${type} middleware:`, error);\n }\n });\n\n return result;\n }\n\n /**\n * Quick probe used by Component on hot render paths to skip building a\n * middleware context when nothing is registered for this type.\n *\n * @internal\n */\n static _hasMiddleware(type: MiddlewareType): boolean {\n return this.middleware[type].size > 0;\n }\n}\n\n// We wire Component.register() to delegate to Registry.register() at\n// import time rather than inside _init(). That way MyComp.register()\n// works even if it's the very first Registry-adjacent call the user\n// makes, without needing to prime _init() some other way.\nComponent._registryRegister = (tag, component) => Registry.register(tag, component as ComponentClass);\n\n/** What the first copy of Pandora leaves on `globalThis`. */\nexport interface RegisteredCopy {\n version: string;\n registry: unknown;\n}\n\n/**\n * Registers this copy of Pandora on `scope`, and reports a different copy\n * that's already there.\n *\n * Everything a component connects to lives in one module: the Registry's\n * tags, global state, middleware and lifecycle hooks. When a page ends up\n * with two copies of Pandora (two installed versions, the browser bundle\n * next to a bundled build, or one import resolved to another file), each\n * copy keeps its own, so nothing fails loudly: a component registered with\n * one is unknown to the other, `@Subscribe` never hears the other's state,\n * and a tag both define throws. Re-importing the same module never\n * evaluates it again, so only a real second copy reports. It logs an error\n * instead of throwing, because the page may still work.\n *\n * @param registry - The Registry of the copy being evaluated.\n * @param version - That copy's version.\n * @param scope - Where copies register; tests pass their own object.\n * @returns `true` when this is the only copy, `false` when another one was found.\n *\n * @internal\n */\nexport const registerCopy = (registry: unknown, version: string, scope: object = globalThis): boolean => {\n const copies = scope as Record<symbol, RegisteredCopy | undefined>;\n const existing = copies[COPY_KEY];\n\n if (existing === undefined || existing === null) {\n copies[COPY_KEY] = { version, registry };\n return true;\n }\n\n if (existing.registry === registry) {\n return true;\n }\n\n const versions = existing.version === version\n ? `both are version ${version}`\n : `the first is version ${existing.version}, this one is version ${version}`;\n\n console.error(\n `[Pandora] Two copies of @aegis-framework/pandora are loaded (${versions}). Each copy has its own Registry, so `\n + 'components, global state and middleware registered with one are unknown to the other, and a tag both define throws. '\n + 'To fix it, install a single copy (run `npm ls @aegis-framework/pandora` and dedupe it), import Pandora only by its '\n + 'package name, and don\\'t load the browser bundle (pandora.browser.js) on a page that also bundles the package.',\n );\n\n return false;\n};\n\nregisterCopy(Registry, VERSION);\n\nexport default Registry;\n",
35
+ "import Component from './Component.js';\nimport Registry from './Registry.js';\nimport type { AttrHandler, SubscribeHandler } from './Types.js';\nimport type * as Types from './Types.js';\nimport {\n addDecoratorEffect,\n addTeardown,\n ATTR_HANDLERS,\n LISTEN_HANDLERS,\n parseAttributeValue,\n PENDING_ATTRIBUTE_WRITES,\n PROP_ATTRIBUTES,\n REACTIVE_FIELDS,\n recordBatchedChange,\n STYLE_METADATA,\n SUBSCRIBE_HANDLERS,\n WATCH_HANDLERS,\n} from './Util.js';\n\n/**\n * Native element properties that `HTMLElement.prototype` may not list outside\n * a browser (jsdom and happy-dom leave some out), checked along with it so a\n * name clash is reported in tests too. In a browser the prototype has them all.\n *\n * @internal\n */\nconst NATIVE_ELEMENT_PROPERTIES = new Set([\n 'accessKey',\n 'autocapitalize',\n 'autocorrect',\n 'autofocus',\n 'className',\n 'contentEditable',\n 'dir',\n 'draggable',\n 'enterKeyHint',\n 'hidden',\n 'id',\n 'inert',\n 'innerHTML',\n 'innerText',\n 'inputMode',\n 'lang',\n 'nonce',\n 'outerHTML',\n 'part',\n 'popover',\n 'role',\n 'slot',\n 'spellcheck',\n 'style',\n 'tabIndex',\n 'textContent',\n 'title',\n 'translate',\n 'writingSuggestions',\n]);\n\n/** The classes already warned about, with the field names. @internal */\nconst NATIVE_NAME_WARNINGS = new WeakMap<object, Set<string>>();\n\n// TC39 decorator metadata relies on `Symbol.metadata`; polyfill it for runtimes\n// that don't ship the well-known symbol yet so our field decorators can stash\n// data on `context.metadata` the same way everywhere.\n(Symbol as any).metadata ??= Symbol('Symbol.metadata');\n\n// ==========================================\n// Types\n// ==========================================\n\ntype ComponentConstructor = typeof Component & {\n tag: string;\n _registered?: boolean;\n};\n\ntype DecoratorInstance = Component & Record<string | symbol, unknown>;\n\n/**\n * Throws a clear error when a decorator is called the legacy TypeScript way.\n * With `experimentalDecorators` on (or Babel's legacy mode), a decorator gets\n * `(target, key, descriptor)` instead of a context object, so it would fail\n * further on with an error that doesn't say why.\n *\n * @internal\n */\nconst assertStandardDecorator = (decoratorName: string, context: unknown): void => {\n if (typeof context === 'object' && context !== null && 'kind' in context) {\n return;\n }\n\n throw new TypeError(\n `[Pandora] @${decoratorName} was called as a legacy decorator. Pandora's decorators are standard decorators: remove `\n + '\"experimentalDecorators\" from tsconfig.json (or set it to false), and if Babel compiles your code, set '\n + '@babel/plugin-proposal-decorators to { version: \"2023-11\" }.',\n );\n};\n\n// ==========================================\n// @Register\n// ==========================================\n\nexport interface RegisterOptions {\n /** Skip `customElements.define()`; call `Registry.define()` when ready. */\n defer?: boolean;\n}\n\n/**\n * Registers a class as a custom element with the browser under the given tag.\n *\n * By default the element is defined on `customElements` immediately. Pass\n * `{ defer: true }` when you want to delay registration — useful if you need\n * to wire up dependencies or control mount ordering yourself before the tag\n * becomes usable in the DOM.\n *\n * @param tagName - The custom element tag name (must contain a hyphen).\n * @param options - Pass `{ defer: true }` to skip automatic registration.\n *\n * @example\n * @Register('my-greeting')\n * class MyGreeting extends Component {\n * render() {\n * return html`<p>Hello, world.</p>`;\n * }\n * }\n *\n * // <my-greeting></my-greeting>\n */\nexport const Register = (tagName: string, options?: RegisterOptions) => {\n return <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext): T => {\n assertStandardDecorator('Register', context);\n\n // At this point the class decorator has run but the TC39 runtime hasn't\n // copied metadata onto the constructor yet, so we read from `context.metadata`\n // directly — that's the only reference that reflects field decorators.\n const meta = context.metadata as Record<symbol, unknown> | undefined;\n\n if (meta?.[PROP_ATTRIBUTES]) {\n if (!Object.hasOwn(constructor, '_observedAttributes')) {\n (constructor as any)._observedAttributes = [];\n }\n\n for (const attr of meta[PROP_ATTRIBUTES] as string[]) {\n if (!(constructor as any)._observedAttributes.includes(attr)) {\n (constructor as any)._observedAttributes.push(attr);\n }\n }\n }\n\n // `customElements.define` reads `observedAttributes`, whose getter falls\n // back to `[Symbol.metadata]` for dynamic cases like inherited `@Attribute`\n // fields — so we need metadata attached to the constructor before we register.\n if (meta && (constructor as unknown as Record<symbol, unknown>)[Symbol.metadata] === undefined) {\n (constructor as unknown as Record<symbol, unknown>)[Symbol.metadata] = meta;\n }\n\n constructor.tag = tagName;\n\n if (!options?.defer) {\n Registry.register(tagName, constructor);\n }\n\n return constructor;\n };\n};\n\n// ==========================================\n// @Style\n// ==========================================\n\n/**\n * Attaches scoped CSS to the component. Accepts either a raw CSS string or\n * a structured `Style` object (selectors and declarations).\n *\n * Styles are applied once per class and live alongside the component's\n * shadow or light DOM output, so they don't leak to the rest of the page.\n *\n * @param css - A CSS string or a `Style` object describing the rules.\n *\n * @example\n * @Register('my-button')\n * @Style({\n * button: {\n * padding: '0.5rem 1rem',\n * borderRadius: '6px',\n * background: 'hotpink',\n * color: 'white',\n * },\n * })\n * class MyButton extends Component {\n * render() {\n * return html`<button>Click me</button>`;\n * }\n * }\n */\nexport const Style = (css: Types.Style | string) => {\n return <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext): T => {\n assertStandardDecorator('Style', context);\n const meta = context.metadata as Record<symbol, unknown>;\n\n meta[STYLE_METADATA] = css;\n return constructor;\n };\n};\n\n// ==========================================\n// @Watch\n// ==========================================\n\ninterface WatchEntry {\n property: string;\n methodName: string;\n}\n\n/**\n * Runs the decorated method whenever the given reactive property changes,\n * receiving the new and previous values.\n *\n * The watched property must be reactive — declared with `@State`,\n * `@Attribute`, `@Property`, or `@Subscribe`, or made reactive with\n * `reactive()` in the constructor — otherwise you'll see a one-time dev\n * warning explaining that the watcher will never fire. Watchers run\n * synchronously on assignment, before the next render is queued.\n *\n * @param property - The name of the reactive field to observe.\n *\n * @example\n * @Register('my-counter')\n * class MyCounter extends Component {\n * @State() count = 0;\n *\n * @Watch('count')\n * onCountChange(next: number, previous: number) {\n * console.log(`count went from ${previous} to ${next}`);\n * }\n *\n * render() {\n * return html`<button @click=${() => this.count++}>${this.count}</button>`;\n * }\n * }\n */\nexport const Watch = (property: string) => {\n return <T extends (...args: any[]) => any>(\n _target: T,\n context: ClassMethodDecoratorContext,\n ): void => {\n assertStandardDecorator('Watch', context);\n const methodName = String(context.name);\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, WATCH_HANDLERS)) {\n const inherited = meta[WATCH_HANDLERS] as WatchEntry[] | undefined;\n meta[WATCH_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n (meta[WATCH_HANDLERS] as WatchEntry[]).push({ property, methodName });\n\n // Field decorators haven't run yet when the method decorator fires, so we\n // check \"is this property actually reactive?\" against the first instance.\n // The check waits a microtask so construction can finish: by then every\n // decorated field has registered, and a field made reactive imperatively\n // (`reactive(this, 'x')` in a constructor) or by a subclass decorator has\n // installed its accessor on the instance.\n let checked = false;\n\n context.addInitializer(function(this: unknown) {\n if (checked) {\n return;\n }\n\n checked = true;\n\n const instance = this as object;\n\n queueMicrotask(() => {\n const reactiveFields = meta[REACTIVE_FIELDS] as Set<string> | undefined;\n\n if (reactiveFields?.has(property) || Object.getOwnPropertyDescriptor(instance, property)?.set) {\n return;\n }\n\n const constructorName = instance.constructor?.name || '<anonymous>';\n console.warn(\n `[Pandora] @Watch('${property}') on ${constructorName}.${methodName}(): '${property}' is not reactive. Add @State, @Attribute, @Property, or @Subscribe to '${property}', or call reactive(this, '${property}') in the constructor — otherwise the watcher will never fire.`,\n );\n });\n });\n };\n};\n\n/**\n * Collects every `@Watch` callback registered for a given property and binds\n * them to the instance. Called from the reactive setters in `applyStateEffect`\n * and `applyPropEffect` each time a tracked field changes.\n *\n * @internal\n */\nconst getWatchersForProperty = (instance: DecoratorInstance, propertyKey: string): Array<(newVal: unknown, oldVal: unknown) => void> => {\n if (typeof Symbol.metadata === 'undefined') {\n return [];\n }\n\n const meta = ((instance.constructor as any)[Symbol.metadata]) as Record<symbol, unknown> | undefined;\n const entries = meta?.[WATCH_HANDLERS] as WatchEntry[] | undefined;\n\n if (!entries) {\n return [];\n }\n\n const callbacks: Array<(newVal: unknown, oldVal: unknown) => void> = [];\n\n for (const entry of entries) {\n if (entry.property === propertyKey) {\n const method = (instance as any)[entry.methodName];\n\n if (typeof method === 'function') {\n callbacks.push(method.bind(instance));\n }\n }\n }\n\n return callbacks;\n};\n\n// ==========================================\n// Dev Validation\n// ==========================================\n\n/**\n * Whether elements already have a property with this name: one of their own\n * (`title`, `hidden`, `remove`…), an ARIA reflection (`ariaLabel`) or an\n * event handler (`onclick`).\n *\n * @internal\n */\nconst isNativeElementProperty = (name: string): boolean => {\n if (NATIVE_ELEMENT_PROPERTIES.has(name) || /^aria[A-Z]/.test(name)) {\n return true;\n }\n\n return typeof HTMLElement !== 'undefined' && name in HTMLElement.prototype;\n};\n\n/**\n * Warns, once per class, when a reactive field has the name of a native\n * element property. The field replaces the native property on every\n * instance: the browser's own behavior for it (a tooltip for `title`,\n * hiding for `hidden`, focus order for `tabIndex`) stops working, and code\n * that reads or sets it on the element gets the field instead.\n *\n * It warns instead of throwing because such a field can still work as a\n * plain value, and existing components may rely on that.\n *\n * @internal\n */\nconst warnIfNative = (decoratorName: string, propertyKey: string, context: ClassFieldDecoratorContext): void => {\n if (!isNativeElementProperty(propertyKey)) {\n return;\n }\n\n context.addInitializer(function(this: unknown) {\n const componentClass = (this as object).constructor;\n let warned = NATIVE_NAME_WARNINGS.get(componentClass);\n\n if (warned === undefined) {\n warned = new Set();\n NATIVE_NAME_WARNINGS.set(componentClass, warned);\n }\n\n if (warned.has(propertyKey)) {\n return;\n }\n\n warned.add(propertyKey);\n\n console.warn(\n `[Pandora] ${componentClass.name || 'A component'}: @${decoratorName}() ${propertyKey} has the name of the element's own `\n + `\\`${propertyKey}\\` property and replaces it, so the browser's behavior for \\`${propertyKey}\\` stops working on this `\n + `element and code that uses \\`element.${propertyKey}\\` gets the field instead. Rename the field.`,\n );\n });\n};\n\n// ==========================================\n// Shared by @State, @Property and @Attribute\n// ==========================================\n\n/**\n * Moves an existing own-data-value out of the property slot and into the\n * backing symbol slot before our accessor descriptor takes over, so a value\n * assigned before decoration survives the install.\n *\n * @internal\n */\nconst migrateOwnValueTo = (instance: DecoratorInstance, propertyKey: string, valueKey: symbol): void => {\n const desc = Object.getOwnPropertyDescriptor(instance, propertyKey);\n\n // A data descriptor means someone wrote a raw value we need to rescue; an\n // accessor descriptor means the reactive getter/setter is already installed,\n // so there's nothing to migrate.\n if (desc && 'value' in desc && desc.value !== undefined && instance[valueKey] === undefined) {\n instance[valueKey] = desc.value;\n }\n};\n\n/**\n * Appends an `AttrHandler` to the class-level handler list stored in metadata.\n * Used by `@Attribute` and attribute-mirroring `@Property` during decoration.\n *\n * @internal\n */\nconst registerAttrHandler = (meta: Record<symbol, unknown>, handler: AttrHandler): void => {\n if (!Object.hasOwn(meta, ATTR_HANDLERS)) {\n const inherited = meta[ATTR_HANDLERS] as AttrHandler[] | undefined;\n meta[ATTR_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n (meta[ATTR_HANDLERS] as AttrHandler[]).push(handler);\n};\n\n/**\n * Writes a primitive value back to an element attribute, serializing booleans\n * as presence/absence and strings/numbers via `String()`. Other types are\n * skipped — they can't round-trip through the DOM.\n *\n * @internal\n */\nconst syncToAttribute = (instance: DecoratorInstance, attrName: string, value: unknown): void => {\n if (typeof value === 'boolean') {\n if (value) {\n instance.setAttribute(attrName, '');\n } else {\n instance.removeAttribute(attrName);\n }\n } else if (typeof value === 'string' || typeof value === 'number') {\n instance.setAttribute(attrName, String(value));\n }\n};\n\n/**\n * Writes a field's default value to its attribute. A new element must not\n * have attributes while `document.createElement()` (or `new`) constructs it,\n * or the browser throws `NotSupportedError`, so until the component has\n * connected (as during construction) the write waits for\n * `connectedCallback`, which makes it before the first render. A connected\n * instance (an `evolve()` or lazy replay) is written at once. The value\n * written is the field's value at that moment, and an attribute set in the\n * meantime wins.\n *\n * @internal\n */\nconst writeDefaultToAttribute = (instance: DecoratorInstance, attrName: string, propertyKey: string): void => {\n if (instance.isConnected) {\n syncToAttribute(instance, attrName, instance[propertyKey]);\n return;\n }\n\n let pending = instance[PENDING_ATTRIBUTE_WRITES] as Map<string, () => void> | undefined;\n\n if (pending === undefined) {\n pending = new Map();\n instance[PENDING_ATTRIBUTE_WRITES] = pending;\n }\n\n pending.set(attrName, () => {\n if (!instance.hasAttribute(attrName)) {\n syncToAttribute(instance, attrName, instance[propertyKey]);\n }\n });\n};\n\n/**\n * Installs a reactive accessor that mirrors its value to an HTML attribute,\n * used by `@Attribute` and attribute-synced `@Property`. Called on first\n * instantiation and again on evolve/lazy replay.\n *\n * @internal\n */\nconst applyPropEffect = (\n instance: DecoratorInstance,\n attrName: string,\n propertyKey: string,\n valueKey: symbol,\n settingKey: symbol,\n shouldRender: boolean = true,\n equals: (a: unknown, b: unknown) => boolean = (a, b) => a === b,\n): void => {\n migrateOwnValueTo(instance, propertyKey, valueKey);\n\n Object.defineProperty(instance, propertyKey, {\n get() {\n if (instance[valueKey] !== undefined) {\n return instance[valueKey];\n }\n\n if (instance.hasAttribute(attrName)) {\n return parseAttributeValue(instance.getAttribute(attrName));\n }\n\n return undefined;\n },\n set(newVal: unknown) {\n const oldVal = instance[valueKey];\n instance[valueKey] = newVal;\n instance[settingKey] = true;\n\n // `undefined` / `null` clears the attribute; primitives serialize with\n // boolean-as-presence semantics, matching how HTML natively treats them.\n if (newVal === undefined || newVal === null) {\n instance.removeAttribute(attrName);\n } else if (typeof newVal === 'string' || typeof newVal === 'number' || typeof newVal === 'boolean') {\n if (typeof newVal === 'boolean') {\n if (newVal) {\n instance.setAttribute(attrName, '');\n } else {\n instance.removeAttribute(attrName);\n }\n } else {\n instance.setAttribute(attrName, String(newVal));\n }\n }\n\n instance[settingKey] = false;\n\n if (!equals(oldVal, newVal)) {\n // Same batching dance as `applyStateEffect`: coalesce repeated writes\n // to a single first-to-last record while a batch is open.\n if (!recordBatchedChange(instance, { property: propertyKey, oldValue: oldVal, newValue: newVal, shouldRender, source: 'prop' })) {\n const watchers = getWatchersForProperty(instance, propertyKey);\n\n for (const watcher of watchers) {\n watcher(newVal, oldVal);\n }\n\n instance.didChange(propertyKey, oldVal, newVal, 'prop');\n\n if (shouldRender && (instance as any)._initRenderDone && instance.isConnected) {\n (instance as any)._queueRender();\n }\n }\n }\n },\n enumerable: true,\n configurable: true,\n });\n\n if (instance.isConnected && instance.hasAttribute(attrName)) {\n instance[valueKey] = parseAttributeValue(instance.getAttribute(attrName));\n }\n\n addTeardown(instance as any, () => {\n delete (instance as any)[propertyKey];\n });\n};\n\n// ==========================================\n// @State\n// ==========================================\n\nexport interface StateOptions {\n /** Set to `false` to keep the field reactive without re-rendering. */\n render?: boolean;\n}\n\n/**\n * Installs a reactive getter/setter pair for a `@State` (or property-only)\n * field on an instance. Called from the state decorator's `addInitializer` on\n * first instantiation and from `Registry.evolve()` / lazy replay when the\n * implementation swaps under a connected element.\n *\n * @internal\n */\nconst applyStateEffect = (\n instance: DecoratorInstance,\n propertyKey: string,\n valueKey: symbol,\n shouldRender: boolean,\n source: string = 'state',\n equals: (a: unknown, b: unknown) => boolean = (a, b) => a === b,\n): void => {\n // Preserve any pre-existing own value before our accessor replaces it. This\n // matters for decorator replay (evolve/lazy) when the caller wrote to the\n // property on the old base instance before the new implementation applied,\n // and for initializers of plain-field defaults.\n migrateOwnValueTo(instance, propertyKey, valueKey);\n\n Object.defineProperty(instance, propertyKey, {\n get() {\n return instance[valueKey];\n },\n set(newVal: unknown) {\n const oldVal = instance[valueKey];\n\n if (equals(oldVal, newVal)) {\n return;\n }\n\n instance[valueKey] = newVal;\n\n // Inside `batch()` we defer `@Watch` and `didChange` until the batch\n // closes. If the same field changes more than once we collapse entries\n // to a single first-to-last span, keeping the original oldValue.\n if (recordBatchedChange(instance, { property: propertyKey, oldValue: oldVal, newValue: newVal, shouldRender, source })) {\n return;\n }\n\n const watchers = getWatchersForProperty(instance, propertyKey);\n\n for (const watcher of watchers) {\n watcher(newVal, oldVal);\n }\n\n instance.didChange(propertyKey, oldVal, newVal, source);\n\n // Skip the render queue until the initial render has landed — otherwise\n // field initializers running during construction would trigger renders\n // before the element is actually ready to paint.\n if (shouldRender && (instance as any)._initRenderDone && instance.isConnected) {\n (instance as any)._queueRender();\n }\n },\n enumerable: true,\n configurable: true,\n });\n\n addTeardown(instance as any, () => {\n delete (instance as any)[propertyKey];\n });\n};\n\n/**\n * Declares a reactive instance field. Assigning to the field queues a render\n * on the next microtask, and multiple assignments in the same tick coalesce\n * into a single render pass.\n *\n * Pass `{ render: false }` to keep the field reactive — `@Watch` handlers\n * still fire and the value still flows through `didChange` — without\n * triggering a re-render on every assignment.\n *\n * @param options - Optional `{ render: false }` to opt out of re-rendering.\n *\n * @example\n * @Register('my-counter')\n * class MyCounter extends Component {\n * @State() count = 0;\n * @State({ render: false }) private lastPing = Date.now();\n *\n * render() {\n * return html`<button @click=${() => this.count++}>${this.count}</button>`;\n * }\n * }\n */\nexport const State = (options?: StateOptions) => {\n return (_target: undefined, context: ClassFieldDecoratorContext) => {\n assertStandardDecorator('State', context);\n const propertyKey = String(context.name);\n warnIfNative('State', propertyKey, context);\n const shouldRender = options?.render !== false;\n const valueKey = Symbol(`__pandora_state_${propertyKey}`);\n\n // We capture the class default from the first instance into a closure\n // rather than metadata — the list of known reactive fields lives on the\n // class, but the default value is shared per-decorator-site, so stashing\n // it here keeps metadata from growing per-instance.\n let classDefault: unknown;\n let defaultCaptured = false;\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, REACTIVE_FIELDS)) {\n const inherited = meta[REACTIVE_FIELDS] as Set<string> | undefined;\n meta[REACTIVE_FIELDS] = inherited ? new Set(inherited) : new Set();\n }\n\n (meta[REACTIVE_FIELDS] as Set<string>).add(propertyKey);\n\n addDecoratorEffect(meta, (instance) => {\n applyStateEffect(instance as DecoratorInstance, propertyKey, valueKey, shouldRender);\n\n // Evolve/lazy replay runs without the original field initializer, so we\n // seed the backing slot with the captured class default when it's empty.\n if (defaultCaptured && (instance as DecoratorInstance)[valueKey] === undefined) {\n (instance as DecoratorInstance)[valueKey] = classDefault;\n }\n });\n\n context.addInitializer(function(this: unknown) {\n const instance = this as DecoratorInstance;\n const initialValue = instance[propertyKey as keyof typeof instance];\n\n applyStateEffect(instance, propertyKey, valueKey, shouldRender);\n\n if (initialValue !== undefined) {\n instance[valueKey] = initialValue;\n\n if (!defaultCaptured) {\n classDefault = initialValue;\n defaultCaptured = true;\n }\n }\n });\n };\n};\n\n// ==========================================\n// @Property (reactive, never renders)\n// ==========================================\n\nexport interface PropertyOptions {\n /**\n * Mirror primitive values to an attribute: `true` uses the field name,\n * a string names the attribute, and `false` (the default) skips it.\n */\n attribute?: string | boolean;\n\n /** Custom equality check; assignments it reports as equal are skipped. */\n equals?: (a: unknown, b: unknown) => boolean;\n}\n\n/**\n * Exposes a reactive JavaScript property on the component — ideal for values\n * that aren't string-serializable, like objects, arrays, or class instances.\n *\n * Properties are reactive (they fire `@Watch` handlers and run through\n * `didChange`) but do not trigger re-renders on their own, so a parent can\n * hand a child rich data without causing render thrash. Pass\n * `{ attribute: true }` (or `{ attribute: 'some-name' }`) to mirror the\n * value to an attribute for primitives, or provide a custom `equals`\n * comparator to skip updates when a deep-equal object is assigned.\n *\n * @param options - `{ attribute, equals }` to control attribute sync and\n * change detection.\n *\n * @example\n * interface User { id: string; name: string; }\n *\n * @Register('user-avatar')\n * class UserAvatar extends Component {\n * @Property() user!: User;\n *\n * render() {\n * return html`<img alt=${this.user.name} data-id=${this.user.id}>`;\n * }\n * }\n *\n * // In a parent:\n * // const el = document.querySelector('user-avatar');\n * // el.user = { id: 'u_42', name: 'Ada Lovelace' };\n */\nexport const Property = (options?: PropertyOptions) => {\n return (_target: undefined, context: ClassFieldDecoratorContext) => {\n assertStandardDecorator('Property', context);\n const propertyKey = String(context.name);\n warnIfNative('Property', propertyKey, context);\n const valueKey = Symbol(`__pandora_property_${propertyKey}`);\n const customEquals = options?.equals ?? ((a: unknown, b: unknown) => a === b);\n const attrName = options?.attribute === true ? propertyKey : (options?.attribute ?? false);\n\n let classDefault: unknown;\n let defaultCaptured = false;\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, REACTIVE_FIELDS)) {\n const inherited = meta[REACTIVE_FIELDS] as Set<string> | undefined;\n meta[REACTIVE_FIELDS] = inherited ? new Set(inherited) : new Set();\n }\n\n (meta[REACTIVE_FIELDS] as Set<string>).add(propertyKey);\n\n if (attrName !== false) {\n // Attribute-mirrored path: reuse the attribute machinery but pass\n // `shouldRender = false` so assignments skip the render queue.\n const settingKey = Symbol(`__pandora_propSetting_${propertyKey}`);\n\n if (!Object.hasOwn(meta, PROP_ATTRIBUTES)) {\n const inherited = meta[PROP_ATTRIBUTES] as string[] | undefined;\n meta[PROP_ATTRIBUTES] = inherited ? [...inherited] : [];\n }\n\n if (!(meta[PROP_ATTRIBUTES] as string[]).includes(attrName)) {\n (meta[PROP_ATTRIBUTES] as string[]).push(attrName);\n }\n\n registerAttrHandler(meta, { attrName, propertyKey, valueKey, settingKey, shouldRender: false, equals: customEquals });\n\n addDecoratorEffect(meta, (instance) => {\n applyPropEffect(instance as DecoratorInstance, attrName, propertyKey, valueKey, settingKey, false, customEquals);\n\n if (defaultCaptured && (instance as DecoratorInstance)[valueKey] === undefined) {\n if ((instance as DecoratorInstance).hasAttribute(attrName)) {\n (instance as DecoratorInstance)[valueKey] = parseAttributeValue((instance as DecoratorInstance).getAttribute(attrName));\n } else {\n (instance as DecoratorInstance)[valueKey] = classDefault;\n writeDefaultToAttribute(instance as DecoratorInstance, attrName, propertyKey);\n }\n }\n });\n\n context.addInitializer(function(this: unknown) {\n const instance = this as DecoratorInstance;\n const initialValue = instance[propertyKey as keyof typeof instance];\n const hasInitialAttribute = instance.hasAttribute(attrName);\n const initialAttributeValue = hasInitialAttribute ? parseAttributeValue(instance.getAttribute(attrName)) : undefined;\n\n applyPropEffect(instance, attrName, propertyKey, valueKey, settingKey, false, customEquals);\n\n if (initialValue !== undefined && !defaultCaptured) {\n classDefault = initialValue;\n defaultCaptured = true;\n }\n\n if (hasInitialAttribute) {\n instance[valueKey] = initialAttributeValue;\n } else if (initialValue !== undefined) {\n instance[valueKey] = initialValue;\n writeDefaultToAttribute(instance, attrName, propertyKey);\n }\n });\n } else {\n // Default path: reactive field with no attribute mirror and no render,\n // so we ride `applyStateEffect` for `@Watch` plumbing alone.\n addDecoratorEffect(meta, (instance) => {\n applyStateEffect(instance as DecoratorInstance, propertyKey, valueKey, false, 'property', customEquals);\n\n if (defaultCaptured && (instance as DecoratorInstance)[valueKey] === undefined) {\n (instance as DecoratorInstance)[valueKey] = classDefault;\n }\n });\n\n context.addInitializer(function(this: unknown) {\n const instance = this as DecoratorInstance;\n const initialValue = instance[propertyKey as keyof typeof instance];\n\n applyStateEffect(instance, propertyKey, valueKey, false, 'property', customEquals);\n\n if (initialValue !== undefined) {\n instance[valueKey] = initialValue;\n\n if (!defaultCaptured) {\n classDefault = initialValue;\n defaultCaptured = true;\n }\n }\n });\n }\n };\n};\n\n// ==========================================\n// @Attribute\n// ==========================================\n\nexport interface AttributeOptions {\n /** Set to `false` to keep the field reactive without re-rendering. */\n render?: boolean;\n}\n\n/**\n * Binds a reactive field to an HTML attribute. The field reads through to\n * the attribute, and assignments are written back, keeping DOM and JS state\n * in sync.\n *\n * By default the attribute name matches the field name — pass a string to\n * map to a different attribute (e.g. `@Attribute('user-name')`), or pass\n * `{ render: false }` to keep the field reactive without triggering a\n * re-render when the attribute changes. String, number, and boolean values\n * are serialized automatically.\n *\n * @param attributeNameOrOptions - Either the attribute name to bind to, or\n * an options object like `{ render: false }`.\n *\n * @example\n * @Register('my-greeting')\n * class MyGreeting extends Component {\n * @Attribute() name = 'world';\n *\n * render() {\n * return html`<p>Hello, ${this.name}.</p>`;\n * }\n * }\n *\n * // <my-greeting name=\"Ada\"></my-greeting>\n */\nexport const Attribute = (attributeNameOrOptions?: string | AttributeOptions) => {\n return (_target: undefined, context: ClassFieldDecoratorContext) => {\n assertStandardDecorator('Attribute', context);\n const propertyKey = String(context.name);\n warnIfNative('Attribute', propertyKey, context);\n\n let attrName: string;\n let shouldRender = true;\n\n if (typeof attributeNameOrOptions === 'object') {\n attrName = propertyKey;\n shouldRender = attributeNameOrOptions.render !== false;\n } else {\n attrName = attributeNameOrOptions ?? propertyKey;\n }\n\n const valueKey = Symbol(`__pandora_attr_${propertyKey}`);\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, REACTIVE_FIELDS)) {\n const inherited = meta[REACTIVE_FIELDS] as Set<string> | undefined;\n meta[REACTIVE_FIELDS] = inherited ? new Set(inherited) : new Set();\n }\n\n (meta[REACTIVE_FIELDS] as Set<string>).add(propertyKey);\n\n let classDefault: unknown;\n let defaultCaptured = false;\n\n {\n const settingKey = Symbol(`__pandora_propSetting_${propertyKey}`);\n\n if (!Object.hasOwn(meta, PROP_ATTRIBUTES)) {\n const inherited = meta[PROP_ATTRIBUTES] as string[] | undefined;\n meta[PROP_ATTRIBUTES] = inherited ? [...inherited] : [];\n }\n\n if (!(meta[PROP_ATTRIBUTES] as string[]).includes(attrName)) {\n (meta[PROP_ATTRIBUTES] as string[]).push(attrName);\n }\n\n registerAttrHandler(meta, { attrName, propertyKey, valueKey, settingKey, shouldRender, equals: (a, b) => a === b });\n\n addDecoratorEffect(meta, (instance) => {\n applyPropEffect(instance as DecoratorInstance, attrName as string, propertyKey, valueKey, settingKey, shouldRender);\n\n if (defaultCaptured && (instance as DecoratorInstance)[valueKey] === undefined) {\n if ((instance as DecoratorInstance).hasAttribute(attrName as string)) {\n (instance as DecoratorInstance)[valueKey] = parseAttributeValue((instance as DecoratorInstance).getAttribute(attrName as string));\n } else {\n (instance as DecoratorInstance)[valueKey] = classDefault;\n writeDefaultToAttribute(instance as DecoratorInstance, attrName as string, propertyKey);\n }\n }\n });\n\n context.addInitializer(function(this: unknown) {\n const instance = this as DecoratorInstance;\n const initialValue = instance[propertyKey as keyof typeof instance];\n const hasInitialAttribute = instance.hasAttribute(attrName);\n const initialAttributeValue = hasInitialAttribute ? parseAttributeValue(instance.getAttribute(attrName)) : undefined;\n\n applyPropEffect(instance, attrName as string, propertyKey, valueKey, settingKey, shouldRender);\n\n if (initialValue !== undefined && !defaultCaptured) {\n classDefault = initialValue;\n defaultCaptured = true;\n }\n\n if (hasInitialAttribute) {\n instance[valueKey] = initialAttributeValue;\n } else if (initialValue !== undefined) {\n instance[valueKey] = initialValue;\n writeDefaultToAttribute(instance, attrName as string, propertyKey);\n }\n });\n }\n };\n};\n\n// ==========================================\n// @Subscribe\n// ==========================================\n\n/**\n * Installs a reactive accessor backed by the global `Registry` for\n * `@Subscribe` fields, wiring reads, writes, and subscription lifecycle on\n * the instance. Called on decoration and again on evolve/lazy replay.\n *\n * @internal\n */\nconst applyConsumerEffect = (\n instance: DecoratorInstance,\n stateKey: string,\n propertyKey: string,\n unsubKey: symbol,\n valueKey: symbol,\n): void => {\n Object.defineProperty(instance, propertyKey, {\n get() {\n return instance[valueKey];\n },\n set(newVal: unknown) {\n const oldVal = instance[valueKey];\n\n if (oldVal === newVal) {\n return;\n }\n\n instance[valueKey] = newVal;\n Registry.setState(stateKey, newVal);\n instance.didChange(propertyKey, oldVal, newVal, 'consumer');\n\n if (instance.isReady) {\n (instance as any)._queueRender();\n }\n },\n enumerable: true,\n configurable: true,\n });\n\n // When evolve/lazy re-applies on an already-connected instance, we activate\n // the subscription right here — otherwise we'd miss every state update\n // until the next connect cycle. The prototype `connectedCallback` handles\n // the natural mount path.\n if (instance.isConnected) {\n Component._activateSubscription?.(instance as unknown as Component, { stateKey, propertyKey, unsubKey, valueKey });\n }\n\n addTeardown(instance as any, () => {\n if (instance[unsubKey]) {\n (instance[unsubKey] as () => void)();\n instance[unsubKey] = undefined;\n }\n\n delete (instance as any)[propertyKey];\n });\n};\n\n/**\n * Subscribes a field to a shared state key on the global `Registry`. Reading\n * the field returns the current registry value; assigning writes it back\n * and notifies every other subscriber.\n *\n * Subscriptions activate on connect and tear down on disconnect, so\n * components automatically stay in sync with the store for as long as\n * they're in the DOM — no manual wiring required.\n *\n * @param stateKey - The key in the `Registry` store this field mirrors.\n *\n * @example\n * // Somewhere at startup:\n * Registry.setState('theme', 'light');\n *\n * @Register('theme-toggle')\n * class ThemeToggle extends Component {\n * @Subscribe('theme') theme!: 'light' | 'dark';\n *\n * render() {\n * return html`\n * <button @click=${() => this.theme = this.theme === 'light' ? 'dark' : 'light'}>\n * Theme: ${this.theme}\n * </button>\n * `;\n * }\n * }\n */\nexport const Subscribe = (stateKey: string) => {\n return (_target: undefined, context: ClassFieldDecoratorContext) => {\n assertStandardDecorator('Subscribe', context);\n const propertyKey = String(context.name);\n const unsubKey = Symbol(`__pandora_unsub_${propertyKey}`);\n const valueKey = Symbol(`__pandora_value_${propertyKey}`);\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, REACTIVE_FIELDS)) {\n const inherited = meta[REACTIVE_FIELDS] as Set<string> | undefined;\n meta[REACTIVE_FIELDS] = inherited ? new Set(inherited) : new Set();\n }\n\n (meta[REACTIVE_FIELDS] as Set<string>).add(propertyKey);\n\n // We stash subscription handlers on class metadata so the prototype's\n // `connectedCallback` can activate them on mount. The browser invokes\n // lifecycle callbacks through the prototype, so per-instance wrappers\n // registered via `addInitializer` would never fire on a natural mount.\n if (!Object.hasOwn(meta, SUBSCRIBE_HANDLERS)) {\n const inherited = meta[SUBSCRIBE_HANDLERS] as SubscribeHandler[] | undefined;\n meta[SUBSCRIBE_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n (meta[SUBSCRIBE_HANDLERS] as SubscribeHandler[]).push({ stateKey, propertyKey, unsubKey, valueKey });\n\n addDecoratorEffect(meta, (instance) => {\n applyConsumerEffect(instance as DecoratorInstance, stateKey, propertyKey, unsubKey, valueKey);\n });\n\n context.addInitializer(function(this: unknown) {\n applyConsumerEffect(this as DecoratorInstance, stateKey, propertyKey, unsubKey, valueKey);\n });\n };\n};\n\n// ==========================================\n// @Query / @QueryAll\n// ==========================================\n\n/**\n * Installs a live `query(selector)` getter on an instance for a `@Query`\n * field, so each read reflects the current rendered DOM.\n *\n * @internal\n */\nconst applyQueryEffect = (instance: Component, propertyKey: string, selector: string): void => {\n Object.defineProperty(instance, propertyKey, {\n get() {\n return instance.query(selector);\n },\n enumerable: true,\n configurable: true,\n });\n};\n\n/**\n * Turns a field into a live selector query against the component's rendered\n * DOM. Each access re-runs the lookup, so the reference stays correct even\n * as the template re-renders.\n *\n * @param selector - A CSS selector scoped to the component's root.\n *\n * @example\n * @Register('my-form')\n * class MyForm extends Component {\n * @Query('input[name=\"email\"]') emailInput!: HTMLInputElement | null;\n *\n * submit() {\n * console.log('email:', this.emailInput?.value);\n * }\n *\n * render() {\n * return html`\n * <form @submit=${(e: Event) => { e.preventDefault(); this.submit(); }}>\n * <input name=\"email\" type=\"email\" />\n * <button type=\"submit\">Send</button>\n * </form>\n * `;\n * }\n * }\n */\nexport const Query = (selector: string) => {\n return (_target: undefined, context: ClassFieldDecoratorContext) => {\n assertStandardDecorator('Query', context);\n const propertyKey = String(context.name);\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n addDecoratorEffect(meta, (instance) => {\n applyQueryEffect(instance as unknown as Component, propertyKey, selector);\n });\n\n context.addInitializer(function(this: unknown) {\n applyQueryEffect(this as Component, propertyKey, selector);\n });\n };\n};\n\n/**\n * Installs a live `queryAll(selector)` getter on an instance for a\n * `@QueryAll` field.\n *\n * @internal\n */\nconst applyQueryAllEffect = (instance: Component, propertyKey: string, selector: string): void => {\n Object.defineProperty(instance, propertyKey, {\n get() {\n return instance.queryAll(selector);\n },\n enumerable: true,\n configurable: true,\n });\n};\n\n/**\n * Like `@Query`, but returns every matching element. Each access re-runs\n * the lookup, so the list reflects the current DOM on every read.\n *\n * @param selector - A CSS selector scoped to the component's root.\n *\n * @example\n * @Register('my-tabs')\n * class MyTabs extends Component {\n * @QueryAll('li') items!: NodeListOf<HTMLLIElement>;\n *\n * logItems() {\n * for (const item of this.items) console.log(item.textContent);\n * }\n *\n * render() {\n * return html`\n * <ul>\n * <li>Overview</li>\n * <li>Activity</li>\n * <li>Settings</li>\n * </ul>\n * `;\n * }\n * }\n */\nexport const QueryAll = (selector: string) => {\n return (_target: undefined, context: ClassFieldDecoratorContext) => {\n assertStandardDecorator('QueryAll', context);\n const propertyKey = String(context.name);\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n addDecoratorEffect(meta, (instance) => {\n applyQueryAllEffect(instance as unknown as Component, propertyKey, selector);\n });\n\n context.addInitializer(function(this: unknown) {\n applyQueryAllEffect(this as Component, propertyKey, selector);\n });\n };\n};\n\n// ==========================================\n// @Slot\n// ==========================================\n\n/**\n * Installs a getter that resolves to the requested `<slot>` element inside\n * the component's shadow root for a `@Slot` field.\n *\n * @internal\n */\nconst applySlotEffect = (instance: Component, propertyKey: string, slotSelector: string): void => {\n Object.defineProperty(instance, propertyKey, {\n get() {\n const shadowRoot = (instance as any)._shadowDOM || (instance as any).shadowRoot;\n return shadowRoot?.querySelector(slotSelector) ?? null;\n },\n enumerable: true,\n configurable: true,\n });\n};\n\n/**\n * Exposes a `<slot>` element from the shadow root as a field, so you can\n * inspect projected children or call slot APIs like `assignedElements()`.\n *\n * Call with no argument to grab the default slot, or pass a name for a\n * named slot.\n *\n * @param name - Optional named slot to target; omit for the default slot.\n *\n * @example\n * @Register('my-card')\n * class MyCard extends ShadowComponent {\n * @Slot('header') headerSlot!: HTMLSlotElement | null;\n *\n * async didMount() {\n * // The slot exists once the first render has run.\n * console.log('header children:', this.headerSlot?.assignedElements());\n * }\n *\n * render() {\n * return html`\n * <section>\n * <header><slot name=\"header\"></slot></header>\n * <slot></slot>\n * </section>\n * `;\n * }\n * }\n */\nexport const Slot = (name?: string) => {\n return (_target: undefined, context: ClassFieldDecoratorContext) => {\n assertStandardDecorator('Slot', context);\n const propertyKey = String(context.name);\n const slotSelector = name ? `slot[name=\"${name}\"]` : 'slot:not([name])';\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n addDecoratorEffect(meta, (instance) => {\n applySlotEffect(instance as unknown as Component, propertyKey, slotSelector);\n });\n\n context.addInitializer(function(this: unknown) {\n applySlotEffect(this as Component, propertyKey, slotSelector);\n });\n };\n};\n\n// ==========================================\n// @Listen\n// ==========================================\n\nexport interface ListenOptions {\n /** Where to attach: the host (`'self'`, the default), `'window'`, `'document'`, or a CSS selector inside the component. */\n target?: 'self' | 'window' | 'document' | (string & {});\n\n /** Only fire when the event comes from a descendant matching this selector. */\n delegate?: string;\n\n /** Listen during the capture phase. */\n capture?: boolean;\n\n /** Mark the listener as passive. */\n passive?: boolean;\n\n /** Remove the listener after it first fires (after the first match, with `delegate`). */\n once?: boolean;\n}\n\n/**\n * Binds a method as an event listener. By default the listener attaches to\n * the component itself, and is added on connect and removed on disconnect.\n *\n * Pass `target` to listen on `'window'`, `'document'`, or any CSS selector\n * scoped to the component's own subtree; pass `delegate` to catch events that\n * bubble up from a child matching a selector; `capture`, `passive`, and `once`\n * forward to the underlying `addEventListener` call.\n *\n * @param event - The event name to listen for (e.g. `'click'`, `'keydown'`).\n * @param options - Optional `{ target, delegate, capture, passive, once }`.\n *\n * @example\n * @Register('my-button')\n * class MyButton extends Component {\n * @State() pressed = 0;\n *\n * @Listen('click')\n * handleClick(event: MouseEvent) {\n * this.pressed++;\n * }\n *\n * render() {\n * return html`<button>Pressed ${this.pressed} times</button>`;\n * }\n * }\n */\nexport const Listen = (event: string, options?: ListenOptions) => {\n return <T extends (...args: any[]) => any>(\n _target: T,\n context: ClassMethodDecoratorContext,\n ): void => {\n assertStandardDecorator('Listen', context);\n const methodName = String(context.name);\n const meta = context.metadata as Record<symbol, unknown>;\n\n if (!Object.hasOwn(meta, LISTEN_HANDLERS)) {\n const inherited = meta[LISTEN_HANDLERS] as unknown[] | undefined;\n meta[LISTEN_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n (meta[LISTEN_HANDLERS] as unknown[]).push({\n event,\n methodName,\n options,\n });\n };\n};\n\n// ==========================================\n// @Computed\n// ==========================================\n\n/**\n * Installs the caching getter and `__invalidate_*` companion method for a\n * `@Computed` field on an instance. Runs once per instance and again on\n * evolve/lazy replay so the cache clears on swap.\n *\n * @internal\n */\nconst applyComputedEffect = (\n instance: DecoratorInstance,\n propertyKey: string,\n cacheKey: symbol,\n validKey: symbol,\n originalGetter: () => unknown,\n): void => {\n // `@Watch` entries for each dependency call into this invalidator; flipping\n // the validity flag lets the next read recompute on demand.\n (instance as any)[`__invalidate_${propertyKey}`] = () => {\n instance[validKey] = false;\n };\n\n Object.defineProperty(instance, propertyKey, {\n get() {\n if (!instance[validKey]) {\n instance[cacheKey] = originalGetter.call(instance);\n instance[validKey] = true;\n }\n\n return instance[cacheKey];\n },\n enumerable: true,\n configurable: true,\n });\n};\n\n/**\n * Turns a getter into a cached derived value. The result is computed once,\n * reused on every read, and invalidated automatically whenever any of the\n * listed reactive dependencies change.\n *\n * List every `@State`, `@Attribute`, or `@Property` the getter reads — those\n * names drive cache invalidation, so anything missing will leave you with a\n * stale result.\n *\n * @param dependencies - Names of reactive fields the getter depends on.\n *\n * @example\n * @Register('cart-summary')\n * class CartSummary extends Component {\n * @State() price = 10;\n * @State() quantity = 3;\n *\n * @Computed('price', 'quantity')\n * get total() {\n * return this.price * this.quantity;\n * }\n *\n * render() {\n * return html`<p>Total: $${this.total}</p>`;\n * }\n * }\n */\nexport const Computed = (...dependencies: string[]) => {\n return <T>(\n _target: T,\n context: ClassGetterDecoratorContext,\n ): T => {\n assertStandardDecorator('Computed', context);\n const propertyKey = String(context.name);\n const cacheKey = Symbol(`__pandora_computed_cache_${propertyKey}`);\n const validKey = Symbol(`__pandora_computed_valid_${propertyKey}`);\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n // We piggy-back on `@Watch`: each dependency gets a watcher that calls\n // the per-instance invalidation method, so cache flushing rides the same\n // change-propagation path as user-written watchers.\n for (const dep of dependencies) {\n if (!Object.hasOwn(meta, WATCH_HANDLERS)) {\n const inherited = meta[WATCH_HANDLERS] as WatchEntry[] | undefined;\n meta[WATCH_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n (meta[WATCH_HANDLERS] as WatchEntry[]).push({\n property: dep,\n methodName: `__invalidate_${propertyKey}`,\n });\n }\n\n // Snapshot the getter at decoration time. During evolve/lazy replay the\n // old prototype's getter is long gone, so we need a direct reference to\n // the getter the source class declared here.\n const originalGetter = _target as unknown as () => unknown;\n\n addDecoratorEffect(meta, (instance) => {\n applyComputedEffect(instance as DecoratorInstance, propertyKey, cacheKey, validKey, originalGetter);\n });\n\n context.addInitializer(function(this: unknown) {\n applyComputedEffect(this as DecoratorInstance, propertyKey, cacheKey, validKey, originalGetter);\n });\n\n return _target;\n };\n};\n\n// ==========================================\n// @ClassList\n// ==========================================\n\nexport type ClassListMap = Record<string, string | ((instance: any) => boolean)>;\n\n/**\n * Declaratively toggles classes on the host element based on reactive state.\n * Map a class name to a reactive field name (truthy → class on, falsy →\n * class off) or to a predicate function that receives the instance and\n * returns a boolean.\n *\n * Classes are applied on connect and updated whenever the underlying\n * reactive fields change, so you never have to reach into `classList`\n * by hand.\n *\n * @param map - Object mapping class names to reactive fields or predicates.\n *\n * @example\n * @Register('my-toggle')\n * @ClassList({\n * 'is-active': 'active',\n * 'is-empty': (self: MyToggle) => self.label.length === 0,\n * })\n * class MyToggle extends Component {\n * @State() active = false;\n * @Attribute() label = '';\n *\n * render() {\n * return html`\n * <button @click=${() => this.active = !this.active}>${this.label}</button>\n * `;\n * }\n * }\n */\nexport const ClassList = (map: ClassListMap) => {\n return <T extends ComponentConstructor>(constructor: T, context: ClassDecoratorContext): T => {\n assertStandardDecorator('ClassList', context);\n const meta = context.metadata as Record<symbol, unknown>;\n\n const propertyMappings: Array<{ className: string; propertyName: string }> = [];\n const functionMappings: Array<{ className: string; conditionFn: (instance: any) => boolean }> = [];\n\n for (const [className, condition] of Object.entries(map)) {\n if (typeof condition === 'string') {\n propertyMappings.push({ className, propertyName: condition });\n\n // String conditions ride on `@Watch`: each field gets a synthetic\n // watcher whose generated method name re-toggles the class from the\n // current value, keeping classList in sync per-field with no diffing.\n if (!Object.hasOwn(meta, WATCH_HANDLERS)) {\n const inherited = meta[WATCH_HANDLERS] as WatchEntry[] | undefined;\n meta[WATCH_HANDLERS] = inherited ? [...inherited] : [];\n }\n\n const methodName = `__classlist_${className}_${condition}`;\n (meta[WATCH_HANDLERS] as WatchEntry[]).push({ property: condition, methodName });\n\n (constructor.prototype as any)[methodName] = function(this: Component) {\n this.classList.toggle(className, !!(this as any)[condition]);\n };\n } else {\n functionMappings.push({ className, conditionFn: condition });\n }\n }\n\n // Predicate conditions can read from anywhere, so we hook `didChange` on\n // the prototype — any reactive update re-evaluates every predicate. Less\n // precise than per-field watchers, but it's the only way to catch\n // dependencies we can't statically enumerate.\n if (functionMappings.length > 0) {\n const originalDidChange = constructor.prototype.didChange;\n\n constructor.prototype.didChange = function(this: Component, prop: string, oldVal: unknown, newVal: unknown, source?: string) {\n originalDidChange?.call(this, prop, oldVal, newVal, source);\n\n for (const { className, conditionFn } of functionMappings) {\n this.classList.toggle(className, conditionFn(this));\n }\n };\n }\n\n const originalConnected = constructor.prototype.connectedCallback;\n\n constructor.prototype.connectedCallback = async function(this: Component) {\n await originalConnected?.call(this);\n\n for (const { className, propertyName } of propertyMappings) {\n this.classList.toggle(className, !!(this as any)[propertyName]);\n }\n\n for (const { className, conditionFn } of functionMappings) {\n this.classList.toggle(className, conditionFn(this));\n }\n };\n\n return constructor;\n };\n};\n\n// ==========================================\n// @Emitter\n// ==========================================\n\n/**\n * Installs the dispatching function on an instance for an `@Emitter` field.\n * The value is non-writable so user code can't accidentally clobber the\n * emitter with a plain assignment.\n *\n * @internal\n */\nconst applyEmitterEffect = (instance: Component, propertyKey: string, eventName: string): void => {\n Object.defineProperty(instance, propertyKey, {\n value: (detail?: unknown) => {\n return instance.emit(eventName, detail);\n },\n writable: false,\n enumerable: true,\n configurable: true,\n });\n};\n\n/**\n * Installs a function on the component that dispatches a bubbling custom\n * event with the given name. Call the field like a method, passing any\n * payload you want to hand up to parents through `event.detail`.\n *\n * The event bubbles and is composed, so parent components and listeners\n * outside a shadow root can subscribe with a plain `addEventListener`.\n *\n * @param eventName - The custom event name to dispatch.\n *\n * @example\n * @Register('my-button')\n * class MyButton extends Component {\n * @Emitter('button-pressed') pressed!: (detail?: { at: number }) => void;\n *\n * @Listen('click')\n * onClick() {\n * this.pressed({ at: Date.now() });\n * }\n *\n * render() {\n * return html`<button>Press me</button>`;\n * }\n * }\n *\n * // In a parent:\n * // el.addEventListener('button-pressed', (e) => console.log(e.detail.at));\n */\nexport const Emitter = (eventName: string) => {\n return (_target: undefined, context: ClassFieldDecoratorContext) => {\n assertStandardDecorator('Emitter', context);\n const propertyKey = String(context.name);\n\n const meta = context.metadata as Record<symbol, unknown>;\n\n addDecoratorEffect(meta, (instance) => {\n applyEmitterEffect(instance as unknown as Component, propertyKey, eventName);\n });\n\n context.addInitializer(function(this: unknown) {\n applyEmitterEffect(this as Component, propertyKey, eventName);\n });\n };\n};\n",
36
+ "import { nothing, render as litRender, type TemplateResult } from 'lit-html';\n\nimport Component from './Component.js';\nimport type { Style } from './Types.js';\nimport { deserializeCSS } from './Util.js';\n\n/**\n * Component subclass that renders into an open shadow root instead of the host\n * element. Pick it when you need style isolation or slot composition;\n * otherwise extend `Component` directly.\n *\n * The shadow root is attached in the constructor with mode `'open'`, so you\n * can still inspect it from outside via `element.shadowRoot`. Queries,\n * listener targets, and adopted stylesheets all scope to the shadow root\n * rather than the host, which means CSS you apply via `setStyle()` stays\n * encapsulated and doesn't leak to the surrounding page.\n *\n * @example\n * @Register('user-card')\n * class UserCard extends ShadowComponent {\n * @Property() user: { name: string; avatar: string } | null = null;\n *\n * render() {\n * if (!this.user) return nothing;\n * return html`\n * <article>\n * <img src=${this.user.avatar} alt=\"\">\n * <h1>${this.user.name}</h1>\n * <slot></slot>\n * </article>\n * `;\n * }\n *\n * async didMount() {\n * this.setStyle({\n * ':host': { display: 'block' },\n * 'article': { padding: '1rem', borderRadius: '8px' }\n * });\n * }\n * }\n */\nclass ShadowComponent extends Component {\n /**\n * @internal\n * The open shadow root attached to the host element. All queries, renders,\n * and style adoption go through this root rather than the host's light DOM.\n */\n protected _shadowDOM: ShadowRoot;\n\n /**\n * @internal\n * Shared `CSSStyleSheet` adopted into the shadow root by `setStyle`. Lazily\n * created per subclass so every instance of a component reuses the same\n * constructed stylesheet.\n */\n protected static override _styleSheet: CSSStyleSheet | null = null;\n\n /**\n * @internal\n * Class-wide object-form style declarations backing the shared stylesheet.\n */\n protected static override _sharedStyle: Style = {};\n\n /**\n * Attaches an open shadow root to the host element and stores it for use\n * by the query, style, and render helpers. You generally don't call this\n * directly — the browser constructs your component when the tag appears\n * in the DOM. Override it only if you need to run extra setup, and always\n * call `super()` first.\n */\n constructor() {\n super();\n this._shadowDOM = this.attachShadow({ mode: 'open' });\n\n // Scroll events don't leave the shadow root, so it's watched too.\n this._trackScrolling(this._shadowDOM);\n }\n\n /**\n * Applies styles to the component's shadow root via an adopted stylesheet.\n *\n * Behaves like `Component.setStyle`, but the stylesheet is adopted into\n * the shadow root instead of the document — so the rules stay encapsulated\n * and don't affect anything outside the component. Use `:host` selectors\n * to style the host element itself.\n *\n * @param style - A `Style` object or a CSS string.\n * @param reset - When `true`, replace the existing styles instead of\n * merging on top.\n * @returns The current object-form style after the update.\n *\n * @example\n * async didMount() {\n * this.setStyle({\n * ':host': { display: 'block', padding: '1rem' },\n * 'button': { cursor: 'pointer' }\n * });\n * }\n */\n override setStyle(style: Style | string, reset: boolean = false): Style {\n const staticComponent = this.constructor as typeof ShadowComponent;\n\n if (!staticComponent._styleSheet) {\n staticComponent._styleSheet = new CSSStyleSheet();\n }\n\n let cssText = '';\n\n if (typeof style === 'object') {\n if (!Object.hasOwn(staticComponent, '_sharedStyle')) {\n staticComponent._sharedStyle = {};\n }\n\n if (!reset) {\n staticComponent._sharedStyle = { ...staticComponent._sharedStyle, ...style };\n } else {\n staticComponent._sharedStyle = { ...style };\n }\n\n this._style = staticComponent._sharedStyle;\n cssText = deserializeCSS(staticComponent._sharedStyle);\n } else if (typeof style === 'string') {\n if (!reset) {\n const existingRules = Array.from(staticComponent._styleSheet.cssRules || [])\n .map((rule) => rule.cssText)\n .join('\\n');\n\n cssText = existingRules + '\\n' + style;\n } else {\n cssText = style;\n staticComponent._sharedStyle = {};\n this._style = {};\n }\n }\n\n staticComponent._styleSheet.replaceSync(cssText);\n\n this._shadowDOM.adoptedStyleSheets = [staticComponent._styleSheet];\n\n return staticComponent._sharedStyle;\n }\n\n /**\n * @internal\n * Where a shadow component renders: its shadow root.\n */\n protected override _renderRoot(): ParentNode {\n return this._shadowDOM;\n }\n\n /**\n * @internal\n * Shadow-root variant of the lit-html render hook. Scopes the render target\n * to the shadow root and passes `host: this` so event listeners resolve\n * against the component.\n */\n protected override _applyLitRender(result: TemplateResult | typeof nothing): void {\n litRender(result, this._shadowDOM, { host: this });\n }\n\n /**\n * @internal\n * Shadow-root variant of the render-root reset. Clears the shadow tree and\n * drops lit-html's cached root part so a switch between string and lit output\n * re-initializes cleanly inside the shadow root.\n */\n protected override _resetRenderRoot(): void {\n while (this._shadowDOM.firstChild) {\n this._shadowDOM.firstChild.remove();\n }\n\n delete (this._shadowDOM as unknown as Record<string, unknown>)['_$litPart$'];\n }\n\n /**\n * @internal\n * Shadow-root variant of the string render hook. Wipes the existing shadow\n * content and appends the parsed template so raw HTML strings render inside\n * the encapsulated tree.\n */\n protected override _applyStringRender(html: string): void {\n while (this._shadowDOM.firstChild) {\n this._shadowDOM.firstChild.remove();\n }\n\n if (html === '') {\n return;\n }\n\n const template = document.createElement('template');\n template.innerHTML = html;\n\n this._shadowDOM.appendChild(template.content);\n }\n\n /**\n * The open shadow root attached to this component.\n *\n * Convenience accessor around the built-in `element.shadowRoot` that\n * returns a non-null `ShadowRoot` — because `ShadowComponent` always\n * attaches one in its constructor, you can use it without a null check.\n * The property is read-only; assigning to it throws.\n *\n * @returns The shadow root owned by this component.\n *\n * @example\n * const card = document.querySelector('my-card') as ShadowComponent;\n * const title = card.shadowRoot.querySelector('h1');\n */\n get shadowRoot(): ShadowRoot {\n return this._shadowDOM;\n }\n\n set shadowRoot(_value: ShadowRoot) {\n throw new Error('ShadowComponent shadowRoot can not be overwritten.');\n }\n\n /**\n * Finds the first descendant of the shadow root matching the given CSS\n * selector.\n *\n * Same shape as `Component.query`, but scoped to this component's shadow\n * root instead of its light-DOM subtree. Elements rendered by `render()`\n * live inside the shadow root, so this is the method you want for\n * reaching into your own template.\n *\n * @param selector - Any valid CSS selector.\n * @returns The first matching element, or `null` if nothing matched.\n *\n * @example\n * async didMount() {\n * this.query<HTMLInputElement>('input[name=\"email\"]')?.focus();\n * }\n */\n override query<E extends Element = Element>(selector: string): E | null {\n return this._shadowDOM.querySelector<E>(selector);\n }\n\n /**\n * Finds every descendant of the shadow root matching the given CSS\n * selector.\n *\n * Same shape as `Component.queryAll`, but scoped to this component's\n * shadow root instead of its light-DOM subtree.\n *\n * @param selector - Any valid CSS selector.\n * @returns A `NodeList` of matching elements (possibly empty).\n *\n * @example\n * for (const item of this.queryAll('li.item')) {\n * item.classList.add('ready');\n * }\n */\n override queryAll<E extends Element = Element>(selector: string): NodeListOf<E> {\n return this._shadowDOM.querySelectorAll<E>(selector);\n }\n}\n\nexport default ShadowComponent;\n",
37
+ "/**\n * Test helpers for Pandora components.\n *\n * These utilities are re-exported as the `testing` namespace from the main\n * entry (`import { testing } from '@aegis-framework/pandora'`). They smooth\n * over the async nature of component rendering so your specs can assert\n * against stable DOM: wait for microtask renders to flush, mount a tag into\n * the document, and reset global Registry state between cases.\n */\n\nimport Component from './Component.js';\nimport Registry from './Registry.js';\n\n/**\n * Flush pending microtask renders.\n *\n * Pandora batches state changes into microtask-scheduled renders. Call\n * `flush` after mutating state so the DOM reflects those changes before your\n * assertions run. Two passes are awaited to cover renders that queue further\n * microtasks during the first pass.\n *\n * @returns A promise that resolves once queued renders have settled.\n *\n * @example\n * const el = await mount('my-counter');\n * el.count = 3;\n * await flush();\n * expect(el.textContent).toContain('3');\n */\nexport const flush = async (): Promise<void> => {\n await new Promise<void>((resolve) => queueMicrotask(resolve));\n\n await new Promise<void>((resolve) => queueMicrotask(resolve));\n};\n\n/**\n * Wait until a component reports that it is ready.\n *\n * Resolves immediately if `element.isReady` is already `true`. Otherwise it\n * listens for the component's `pandora:ready` event and also polls on a short\n * timer, rejecting if the component does not finish its first render within\n * `timeout` milliseconds. It avoids `requestAnimationFrame`, whose callbacks\n * are suspended when the page isn't painting (headless runs, background tabs),\n * which would otherwise hang the wait even after the component became ready.\n *\n * @param element - The component element to observe.\n * @param timeout - How long to wait before rejecting, in milliseconds. Defaults to 5000.\n * @returns A promise that resolves once the component is ready.\n *\n * @example\n * const el = document.querySelector('user-avatar')!;\n * await whenReady(el);\n */\nexport const whenReady = (element: Element, timeout: number = 5000): Promise<void> => {\n const comp = element as Component;\n\n if (comp.isReady) {\n return Promise.resolve();\n }\n\n return new Promise((resolve, reject) => {\n const cleanup = () => {\n clearTimeout(timer);\n clearInterval(poll);\n element.removeEventListener('pandora:ready', onReady);\n };\n\n const onReady = () => {\n if (comp.isReady) {\n cleanup();\n resolve();\n }\n };\n\n const timer = setTimeout(() => {\n cleanup();\n reject(new Error(`Component <${element.tagName.toLowerCase()}> did not become ready within ${timeout}ms`));\n }, timeout);\n\n // Prefer the component's own readiness event, but also poll on a timer as a\n // fallback. We deliberately avoid `requestAnimationFrame` here: rAF callbacks\n // are suspended when the page isn't painting (headless runs, background tabs),\n // which would hang the wait even though the component is ready.\n element.addEventListener('pandora:ready', onReady);\n\n const poll = setInterval(onReady, 16);\n });\n};\n\n/**\n * Reset Registry state between tests.\n *\n * Clears every state key, subscription, and middleware so each spec starts\n * from a clean slate. Component class registrations are not touched. Call\n * this in a `beforeEach` to isolate tests from one another.\n *\n * @example\n * beforeEach(() => {\n * resetRegistry();\n * });\n */\nexport const resetRegistry = (): void => {\n Registry.clearState();\n Registry.clearSubscriptions();\n Registry.clearMiddleware();\n};\n\n/**\n * Create a component, append it to the DOM, and wait for it to be ready.\n *\n * Wraps the tag in a throwaway container so that attributes and children\n * are parsed in a single pass. Defaults to mounting into `document.body`\n * when no container is provided.\n *\n * @param tagName - The custom element tag to mount (for example `'my-counter'`).\n * @param container - The parent node to append into. Defaults to `document.body`.\n * @param innerHTML - Optional markup to place inside the element's opening and closing tags.\n * @returns The mounted component once it has finished its first render.\n *\n * @example\n * const el = await mount<MyGreeting>('my-greeting', document.body, '<span slot=\"name\">Ada</span>');\n * expect(el.textContent).toContain('Ada');\n */\nexport const mount = async <T extends Component = Component>(tagName: string, container?: Element, innerHTML?: string): Promise<T> => {\n const root = container ?? document.body;\n const wrapper = document.createElement('div');\n\n wrapper.innerHTML = `<${tagName}>${innerHTML ?? ''}</${tagName}>`;\n\n const element = wrapper.firstElementChild as T;\n\n root.appendChild(element);\n await whenReady(element);\n\n return element;\n};\n",
38
+ "import Registry from './Registry.js';\n\n/**\n * Typed handle to a single Registry state key.\n *\n * The object returned by `createState` exposes the small surface you need to\n * work with a global value: read it, write it, subscribe to changes, check\n * whether it exists, and delete it. Everything is strongly typed against the\n * generic parameter you pass to `createState`.\n */\nexport interface TypedState<T> {\n /** The underlying Registry state key. */\n readonly key: string;\n\n /** Read the current value. Returns `undefined` if the key was never set or has been deleted. */\n get(): T | undefined;\n\n /** Write a new value. The type is checked against the state's generic parameter. */\n set(value: T): void;\n\n /**\n * Subscribe to changes. The callback runs every time the value is updated,\n * receiving the new and previous values. Returns an unsubscribe function.\n */\n subscribe(callback: (newValue: T | undefined, oldValue: T | undefined) => void): () => void;\n\n /** Return `true` if the key currently has a value in the Registry. */\n has(): boolean;\n\n /** Remove the key from the Registry. Subsequent `get()` calls return `undefined`. */\n delete(): void;\n}\n\n/**\n * Create a typed wrapper around a Registry global state key.\n *\n * Registry state is string-keyed and untyped by default. `createState` gives\n * you a small typed handle so reads, writes, and subscriptions are checked at\n * compile time. If you pass a `defaultValue`, it is written to the Registry\n * immediately when the key does not yet exist, which makes it safe to call\n * during module initialization.\n *\n * @param key - The Registry state key to wrap.\n * @param defaultValue - Optional value to seed the key with if it is not already set.\n * @returns A typed handle with `get`, `set`, `subscribe`, `has`, and `delete`.\n *\n * @example\n * type AppState = { theme: 'light' | 'dark'; user: { id: string } | null };\n *\n * const state = {\n * theme: createState<AppState['theme']>('app.theme', 'light'),\n * user: createState<AppState['user']>('app.user', null),\n * };\n *\n * state.theme.set('dark');\n * const unsubscribe = state.user.subscribe(user => console.log(user));\n */\nexport const createState = <T>(key: string, defaultValue?: T): TypedState<T> => {\n if (defaultValue !== undefined && !Registry.hasState(key)) {\n Registry.setState(key, defaultValue);\n }\n\n return {\n key,\n get(): T | undefined {\n return Registry.getState(key) as T | undefined;\n },\n set(value: T): void {\n Registry.setState(key, value);\n },\n subscribe(callback: (newValue: T | undefined, oldValue: T | undefined) => void): () => void {\n return Registry.subscribe(key, callback as (newValue: unknown, oldValue: unknown) => void);\n },\n has(): boolean {\n return Registry.hasState(key);\n },\n delete(): void {\n Registry.deleteState(key);\n },\n };\n};\n",
39
+ "/**\n * Browser bundle entrypoint for non-module consumers.\n *\n * Load the built bundle from a plain `<script>` tag, or import from\n * `'@aegis-framework/pandora/browser'` for its side effects: the module\n * assigns the entire Pandora namespace to `window.Pandora` so globals like\n * `Pandora.Component` and `Pandora.html` are available without any import\n * statement.\n *\n * Module-based apps should import from the main entry\n * (`'@aegis-framework/pandora'`) instead. This file exists purely because\n * bundlers cannot yet expose an ESM module as a browser global on their\n * own; once/if Bun grows that capability, the file can go away.\n */\n\nimport * as Pandora from './index.js';\n\ndeclare global {\n interface Window {\n Pandora: typeof Pandora;\n }\n}\n\nif (typeof window === 'object') {\n window.Pandora = Pandora;\n}\n"
39
40
  ],
40
- "mappings": "gxCAUA,IAAM,EAAS,WAMT,EACA,CAAC,IAAU,CAGT,GAAI,CAFe,EACd,sBAED,OAEJ,EAAO,cAAc,IAAI,YAAY,YAAa,CAC9C,OAAQ,CACZ,CAAC,CAAC,GAMN,GAAmB,EACnB,GAEA,EAAO,oBAAsB,IAAI,IAMjC,GAAe,CAAC,EAAM,IAAY,CAI9B,GAHA,GAAW,EACL,4BAA4B,0BAC5B,GACF,CAAC,EAAO,kBAAkB,IAAI,CAAO,GACrC,CAAC,EAAO,kBAAkB,IAAI,CAAI,EAClC,QAAQ,KAAK,CAAO,EACpB,EAAO,kBAAkB,IAAI,CAAO,GAG5C,eAAe,IAAM,CACjB,GAAa,WAAY,qDAAqD,EACjF,EAEL,IAAM,EACF,EAAO,UAAU,OACjB,EAAO,UAAU,UAAY,GAC3B,EAAO,SAAS,KAChB,CAAC,IAAS,EACV,GAAe,EAAO,aAStB,GAAS,GACT,GAAa,aAAa,WAAY,CACpC,WAAY,CAAC,IAAM,CACvB,CAAC,EACC,OACA,GAAmB,CAAC,IAAU,EAC9B,GAAgB,CAAC,EAAO,EAAO,IAAU,GAEzC,GAAe,CAAC,IAAiB,CAInC,GAAI,IAA6B,GAC7B,MAAU,MAAM,qHACgD,EAEpE,EAA2B,GAKzB,GAAgD,IAAM,CACxD,EAA2B,IAEzB,GAAkB,CAAC,EAAM,EAAM,IAAS,CAC1C,OAAO,EAAyB,EAAM,EAAM,CAAI,GAI9C,GAAuB,QAKvB,EAAS,OAAO,KAAK,OAAO,EAAE,QAAQ,C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