nuclo 0.1.50 → 0.1.52

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 +1 @@
1
- {"version":3,"file":"nuclo.cjs","sources":["../src/utility/typeGuards.ts","../src/utility/errorHandler.ts","../src/utility/environment.ts","../src/utility/dom.ts","../src/core/reactive.ts","../src/utility/domTypeHelpers.ts","../src/core/styleManager.ts","../src/core/attributeManager.ts","../src/utility/modifierPredicates.ts","../src/core/modifierProcessor.ts","../src/utility/conditionalInfo.ts","../src/internal/applyModifiers.ts","../src/core/conditionalRenderer.ts","../src/core/elementFactory.ts","../src/core/tagRegistry.ts","../src/list/runtime.ts","../src/utility/renderables.ts","../src/utility/arrayUtils.ts","../src/list/renderer.ts","../src/utility/conditions.ts","../src/when/index.ts","../src/core/conditionalUpdater.ts","../src/core/updateController.ts","../src/utility/events.ts","../src/utility/on.ts","../src/utility/render.ts","../src/style/index.ts","../src/core/runtimeBootstrap.ts"],"sourcesContent":["export function isPrimitive(value: unknown): value is Primitive {\n return value === null || (typeof value !== \"object\" && typeof value !== \"function\");\n}\n\nexport function isNode<T>(value: T): value is T & Node {\n return value instanceof Node;\n}\n\nexport function isObject(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function isTagLike<T>(value: T): value is T & { tagName?: string } {\n return isObject(value) && \"tagName\" in (value as object);\n}\n\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === \"boolean\";\n}\n\nexport function isFunction<T extends Function>(value: unknown): value is T {\n return typeof value === \"function\";\n}\n\nexport function isZeroArityFunction(value: unknown): value is () => unknown {\n return isFunction(value) && (value as Function).length === 0;\n}\n","/**\n * Simplified error handling for nuclo - reduced complexity for smaller bundle size\n */\n\n// Basic error logging - no complex context tracking\nexport function logError(message: string, error?: Error | unknown): void {\n if (typeof console !== 'undefined') {\n console.error(`nuclo: ${message}`, error);\n }\n}\n\n// Simplified safe execution - no complex context\nexport function safeExecute<T>(fn: () => T, fallback?: T): T | undefined {\n try {\n return fn();\n } catch (error) {\n logError(\"Operation failed\", error);\n return fallback;\n }\n}\n\n// Basic DOM error handler\nexport function handleDOMError(error: Error | unknown, operation: string): void {\n logError(`DOM ${operation} failed`, error);\n}","/**\n * Simplified environment detection - minimal overhead for smaller bundle size\n */\n\n// Basic environment detection - no complex caching or edge cases\nexport const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';\n","import { isBrowser } from \"./environment\";\nimport { logError } from \"./errorHandler\";\n\nfunction safeAppendChild(parent: Element | Node, child: Node): boolean {\n if (!parent || !child) return false;\n try {\n parent.appendChild(child);\n return true;\n } catch (error) {\n logError('Failed to append child node', error);\n return false;\n }\n}\n\nexport function safeRemoveChild(child: Node): boolean {\n if (!child?.parentNode) return false;\n try {\n child.parentNode.removeChild(child);\n return true;\n } catch (error) {\n logError('Failed to remove child node', error);\n return false;\n }\n}\n\nfunction safeInsertBefore(parent: Node, newNode: Node, referenceNode: Node | null): boolean {\n if (!parent || !newNode) return false;\n try {\n parent.insertBefore(newNode, referenceNode);\n return true;\n } catch (error) {\n logError('Failed to insert node before reference', error);\n return false;\n }\n}\n\nfunction createTextNodeSafely(text: string | number | boolean): Text | null {\n if (!isBrowser) return null;\n try {\n return document.createTextNode(String(text));\n } catch (error) {\n logError('Failed to create text node', error);\n return null;\n }\n}\n\nfunction createCommentSafely(text: string): Comment | null {\n if (!isBrowser) return null;\n try {\n return document.createComment(text);\n } catch (error) {\n logError('Failed to create comment node', error);\n return null;\n }\n}\n\n/**\n * Creates a comment node safely with error handling.\n * Exported for use across the codebase.\n */\nexport function createComment(text: string): Comment | null {\n return createCommentSafely(text);\n}\n\n/**\n * Creates a conditional comment placeholder node.\n * In SSR environments, this will still work because we bypass the isBrowser check.\n */\nexport function createConditionalComment(tagName: string, suffix: string = \"hidden\"): Comment | null {\n // For SSR, we need to create comments even when isBrowser is false\n // This function intentionally skips the isBrowser check for SSR compatibility\n try {\n return document.createComment(`conditional-${tagName}-${suffix}`);\n } catch (error) {\n logError('Failed to create conditional comment', error);\n return null;\n }\n}\n\nexport function createMarkerComment(prefix: string): Comment {\n if (!isBrowser) {\n throw new Error(\"Cannot create comment in non-browser environment\");\n }\n const comment = createCommentSafely(`${prefix}-${Math.random().toString(36).slice(2)}`);\n if (!comment) {\n throw new Error(\"Failed to create comment\");\n }\n return comment;\n}\n\nexport function createMarkerPair(prefix: string): { start: Comment; end: Comment } {\n const endComment = createCommentSafely(`${prefix}-end`);\n if (!endComment) {\n throw new Error(\"Failed to create end comment\");\n }\n return {\n start: createMarkerComment(`${prefix}-start`),\n end: endComment\n };\n}\n\nexport function clearBetweenMarkers(startMarker: Comment, endMarker: Comment): void {\n let current = startMarker.nextSibling;\n while (current && current !== endMarker) {\n const next = current.nextSibling;\n safeRemoveChild(current);\n current = next;\n }\n}\n\nexport function insertNodesBefore(nodes: Node[], referenceNode: Node): void {\n const parent = referenceNode.parentNode;\n if (parent) {\n nodes.forEach(node => safeInsertBefore(parent, node, referenceNode));\n }\n}\n\nexport function appendChildren(\n parent: Element | Node,\n ...children: Array<Element | Node | string | null | undefined>\n): Element | Node {\n if (!parent) return parent;\n\n children.forEach((child) => {\n if (child != null) {\n let nodeToAppend: Node;\n\n if (typeof child === \"string\") {\n const textNode = createTextNodeSafely(child);\n if (textNode) {\n nodeToAppend = textNode;\n } else {\n return;\n }\n } else {\n nodeToAppend = child as Node;\n }\n\n safeAppendChild(parent, nodeToAppend);\n }\n });\n\n return parent;\n}\n\nexport function isNodeConnected(node: Node | null | undefined): boolean {\n if (!node) return false;\n\n // Prefer the built-in isConnected property\n if (typeof node.isConnected === \"boolean\") {\n return node.isConnected;\n }\n\n // Fallback for older browsers (only if in browser environment)\n if (isBrowser && typeof document !== 'undefined') {\n return document.contains(node);\n }\n\n // In SSR or when document is not available, assume disconnected\n return false;\n}\n\n/**\n * Safely replaces an old node with a new node in the DOM.\n * Returns true on success, false on failure (and logs the error).\n */\nexport function replaceNodeSafely(oldNode: Node, newNode: Node): boolean {\n if (!oldNode?.parentNode) return false;\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n return true;\n } catch (error) {\n logError(\"Error replacing conditional node\", error);\n return false;\n }\n}\n","import { logError, safeExecute } from \"../utility/errorHandler\";\nimport { isNodeConnected } from \"../utility/dom\";\n\ntype TextResolver = () => Primitive;\ntype AttributeResolver = () => unknown;\n\ninterface AttributeResolverRecord {\n resolver: AttributeResolver;\n applyValue: (value: unknown) => void;\n}\n\ninterface ReactiveTextNodeInfo {\n resolver: TextResolver;\n lastValue: string;\n}\n\ninterface ReactiveElementInfo {\n attributeResolvers: Map<string, AttributeResolverRecord>;\n updateListener?: EventListener;\n}\n\nconst reactiveTextNodes = new Map<Text, ReactiveTextNodeInfo>();\nconst reactiveElements = new Map<Element, ReactiveElementInfo>();\n\nfunction ensureElementInfo(el: Element): ReactiveElementInfo {\n let info = reactiveElements.get(el);\n if (!info) {\n info = { attributeResolvers: new Map() };\n reactiveElements.set(el, info);\n }\n return info;\n}\n\nfunction applyAttributeResolvers(el: Element, info: ReactiveElementInfo): void {\n info.attributeResolvers.forEach(({ resolver, applyValue }, key) => {\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(`Failed to update reactive attribute: ${key}`, e);\n }\n });\n}\n\n/**\n * Creates a reactive text node that automatically updates when its resolver function changes.\n *\n * The text node will be registered for reactive updates and its content will be synchronized\n * whenever notifyReactiveTextNodes() is called.\n *\n * @param resolver - Function that returns the text content (string, number, boolean, etc.)\n * @param preEvaluated - Optional pre-evaluated value to avoid calling resolver immediately\n * @returns A Text node that will reactively update its content\n *\n * @example\n * ```ts\n * const count = signal(0);\n * const textNode = createReactiveTextNode(() => `Count: ${count.value}`);\n * // Later, when count changes and notifyReactiveTextNodes() is called,\n * // the text content automatically updates\n * ```\n */\nexport function createReactiveTextNode(resolver: TextResolver, preEvaluated?: unknown): Text | DocumentFragment {\n if (typeof resolver !== \"function\") {\n logError(\"Invalid resolver provided to createReactiveTextNode\");\n return document.createTextNode(\"\");\n }\n\n const initial = arguments.length > 1 ? preEvaluated : safeExecute(resolver, \"\");\n const str = initial === undefined ? \"\" : String(initial);\n const txt = document.createTextNode(str);\n\n reactiveTextNodes.set(txt, { resolver, lastValue: str });\n return txt;\n}\n\n/**\n * Registers a reactive attribute resolver for an element.\n *\n * The resolver will be called whenever the element receives an 'update' event,\n * allowing attributes to reactively update based on application state.\n *\n * @param element - The DOM element to make reactive\n * @param key - The attribute name being made reactive (e.g., 'class', 'style', 'disabled')\n * @param resolver - Function that returns the new attribute value\n * @param applyValue - Callback that applies the resolved value to the element\n *\n * @example\n * ```ts\n * const isActive = signal(false);\n * const button = document.createElement('button');\n * registerAttributeResolver(\n * button,\n * 'class',\n * () => isActive.value ? 'active' : 'inactive',\n * (value) => button.className = String(value)\n * );\n * ```\n */\nexport function registerAttributeResolver<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n key: string,\n resolver: AttributeResolver,\n applyValue: (value: unknown) => void\n): void {\n if (!(element instanceof Element) || !key || typeof resolver !== \"function\") {\n logError(\"Invalid parameters for registerAttributeResolver\");\n return;\n }\n const info = ensureElementInfo(element as Element);\n info.attributeResolvers.set(key, { resolver, applyValue });\n\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(\"Failed to apply initial attribute value\", e);\n }\n\n if (!info.updateListener) {\n const listener: EventListener = () => applyAttributeResolvers(element as Element, info);\n (element as Element).addEventListener(\"update\", listener);\n info.updateListener = listener;\n }\n}\n\n/**\n * Updates all registered reactive text nodes.\n *\n * Iterates through all reactive text nodes, re-evaluates their resolver functions,\n * and updates their content if it has changed. Automatically cleans up disconnected nodes.\n *\n * This function should be called after state changes to synchronize the DOM with application state.\n *\n * @example\n * ```ts\n * // After updating application state\n * count.value++;\n * notifyReactiveTextNodes(); // All reactive text nodes update\n * ```\n */\nexport function notifyReactiveTextNodes(): void {\n reactiveTextNodes.forEach((info, node) => {\n if (!isNodeConnected(node)) {\n reactiveTextNodes.delete(node);\n return;\n }\n try {\n const raw = safeExecute(info.resolver);\n const newVal = raw === undefined ? \"\" : String(raw);\n if (newVal !== info.lastValue) {\n node.textContent = newVal;\n info.lastValue = newVal;\n }\n } catch (e) {\n logError(\"Failed to update reactive text node\", e);\n }\n });\n}\n\n/**\n * Updates all registered reactive elements by re-evaluating their attribute resolvers.\n *\n * Iterates through all reactive elements and triggers their registered attribute resolvers\n * to update. Automatically cleans up disconnected elements and their event listeners.\n *\n * This function should be called after state changes to synchronize element attributes\n * with application state.\n *\n * @example\n * ```ts\n * // After updating application state\n * isActive.value = true;\n * notifyReactiveElements(); // All reactive attributes update\n * ```\n */\nexport function notifyReactiveElements(): void {\n reactiveElements.forEach((info, el) => {\n if (!isNodeConnected(el)) {\n if (info.updateListener) el.removeEventListener(\"update\", info.updateListener);\n reactiveElements.delete(el);\n return;\n }\n applyAttributeResolvers(el, info);\n });\n}\n","/**\n * Type-safe DOM helper utilities to reduce type assertions across the codebase.\n * These helpers provide proper typing for DOM operations while maintaining runtime safety.\n */\n\n/**\n * Safely casts an Element-like object to Node & ParentNode interface.\n * This is a common pattern needed when working with DOM manipulation.\n *\n * @param element - The element to cast\n * @returns The element typed as Node & ParentNode\n */\nexport function asParentNode<T extends Element | object>(element: T): Node & ParentNode {\n return element as unknown as Node & ParentNode;\n}\n\n/**\n * Creates a scoped DOM insertion context that temporarily redirects appendChild\n * to insertBefore at a specific reference node. This is useful for inserting\n * content at specific positions in the DOM tree.\n *\n * @param host - The host element\n * @param referenceNode - The node before which new nodes should be inserted\n * @param callback - Function to execute with the scoped context\n * @returns The result of the callback\n */\nexport function withScopedInsertion<T, THost extends Element | object>(\n host: THost,\n referenceNode: Node,\n callback: () => T\n): T {\n const parent = asParentNode(host);\n const originalAppend = parent.appendChild.bind(parent);\n const originalInsert = parent.insertBefore.bind(parent);\n\n // Temporarily override appendChild to insert before the reference node\n // TypeScript doesn't like this override but it's safe at runtime\n (parent as unknown as Record<string, unknown>).appendChild = function(node: Node): Node {\n return originalInsert(node, referenceNode);\n };\n\n try {\n return callback();\n } finally {\n // Restore original method\n (parent as unknown as Record<string, unknown>).appendChild = originalAppend;\n }\n}\n\n/**\n * Type-safe wrapper for setting CSS style properties.\n * Provides better error handling than direct CSSStyleDeclaration access.\n * Supports both camelCase and kebab-case property names.\n *\n * @param element - The element to apply styles to\n * @param property - The CSS property name (camelCase or kebab-case)\n * @param value - The value to set (string, number, or null to remove)\n * @returns true if the style was applied successfully, false otherwise\n */\nexport function setStyleProperty(\n element: HTMLElement,\n property: string,\n value: string | number | null\n): boolean {\n try {\n if (value === null || value === undefined || value === '') {\n // Use bracket notation to remove property (works with camelCase)\n (element.style as unknown as Record<string, string>)[property] = '';\n return true;\n }\n\n // Convert value to string first (might throw if toString() throws)\n const stringValue = String(value);\n // Use bracket notation to set property (works with camelCase)\n (element.style as unknown as Record<string, string>)[property] = stringValue;\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Type-safe wrapper for reading CSS style properties.\n *\n * @param element - The element to read styles from\n * @param property - The CSS property name\n * @returns The computed style value or empty string if not found\n */\nexport function getStyleProperty(\n element: HTMLElement,\n property: string\n): string {\n try {\n return element.style.getPropertyValue(property);\n } catch {\n return '';\n }\n}\n","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver } from \"./reactive\";\nimport { setStyleProperty } from \"../utility/domTypeHelpers\";\nimport { logError } from \"../utility/errorHandler\";\n\ntype StyleAssignment = Partial<CSSStyleDeclaration>;\ntype StyleResolver = () => StyleAssignment | null | undefined;\n\n/**\n * Simplified style management - basic functionality with minimal overhead\n */\nexport function assignInlineStyles<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styles: StyleAssignment | null | undefined,\n): void {\n if (!element?.style || !styles) return;\n\n for (const [property, value] of Object.entries(styles)) {\n const success = setStyleProperty(\n element as HTMLElement,\n property,\n value as string | number | null\n );\n\n if (!success) {\n // Don't try to stringify value in error message as it might throw\n logError(`Failed to set style property '${property}'`);\n }\n }\n}\n\nexport function applyStyleAttribute<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styleValue: StyleAssignment | StyleResolver | null | undefined\n): void {\n if (!element) return;\n\n if (isFunction(styleValue)) {\n registerAttributeResolver(element, 'style', () => {\n try {\n return styleValue();\n } catch (error) {\n logError('Error in style resolver function', error);\n return null;\n }\n }, (resolvedStyles) => {\n assignInlineStyles(element, resolvedStyles as StyleAssignment);\n });\n } else {\n assignInlineStyles(element, styleValue);\n }\n}","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver, createReactiveTextNode } from \"./reactive\";\nimport { applyStyleAttribute } from \"./styleManager\";\n\ntype AttributeKey<TTagName extends ElementTagName> = keyof ExpandedElementAttributes<TTagName>;\ntype AttributeCandidate<TTagName extends ElementTagName> =\n ExpandedElementAttributes<TTagName>[AttributeKey<TTagName>];\n\nfunction applySingleAttribute<TTagName extends ElementTagName>(\n el: ExpandedElement<TTagName>,\n key: AttributeKey<TTagName>,\n raw: AttributeCandidate<TTagName> | undefined,\n shouldMergeClassName = false,\n): void {\n if (raw == null) return;\n\n if (key === \"style\") {\n applyStyleAttribute(el, raw as ExpandedElementAttributes<TTagName>[\"style\"]);\n return;\n }\n\n const setValue = (v: unknown, merge = false): void => {\n if (v == null) return;\n\n // Special handling for className to merge instead of replace (only for non-reactive updates)\n if (key === 'className' && el instanceof HTMLElement && merge) {\n const newClassName = String(v);\n const currentClassName = el.className;\n\n // If there's already a className, merge them (avoid duplicates)\n if (currentClassName && currentClassName !== newClassName) {\n const existing = new Set(currentClassName.split(' ').filter(c => c));\n const newClasses = newClassName.split(' ').filter(c => c);\n newClasses.forEach(c => existing.add(c));\n el.className = Array.from(existing).join(' ');\n } else if (newClassName) {\n el.className = newClassName;\n }\n return;\n }\n\n // SVG elements should always use setAttribute for most attributes\n // because many SVG properties are read-only\n const isSVGElement = el instanceof Element && el.namespaceURI === 'http://www.w3.org/2000/svg';\n\n if (isSVGElement) {\n // Always use setAttribute for SVG elements\n el.setAttribute(String(key), String(v));\n } else if (key in el) {\n // For HTML elements, try to set as property first\n try {\n (el as Record<string, unknown>)[key as string] = v;\n } catch {\n // If property is read-only, fall back to setAttribute\n if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n }\n } else if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n };\n\n if (isFunction(raw) && raw.length === 0) {\n // Type narrowing: zero-arity function that returns an attribute value\n // Reactive attributes should replace, not merge\n const resolver = raw as () => AttributeCandidate<TTagName>;\n registerAttributeResolver(el, String(key), resolver, (v) => setValue(v, false));\n } else {\n // Static attributes should merge classNames\n setValue(raw, shouldMergeClassName);\n }\n}\n\nexport function applyAttributes<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n attributes: ExpandedElementAttributes<TTagName>,\n mergeClassName = true,\n): void {\n if (!attributes) return;\n for (const k of Object.keys(attributes) as Array<AttributeKey<TTagName>>) {\n const value = (attributes as Record<string, unknown>)[k as string] as\n AttributeCandidate<TTagName> | undefined;\n // Only merge className for non-className keys OR when explicitly enabled for className\n const shouldMerge = mergeClassName && k === 'className';\n applySingleAttribute(element, k, value, shouldMerge);\n }\n}\n\nexport { createReactiveTextNode } from \"./reactive\";\n","import { isFunction, isNode, isObject } from \"./typeGuards\";\n\ntype BooleanCondition = () => boolean;\ntype ZeroArityFunction = () => unknown;\n\nconst modifierProbeCache = new WeakMap<ZeroArityFunction, { value: unknown; error: boolean }>();\n\nfunction probeOnce(fn: ZeroArityFunction): { value: unknown; error: boolean } {\n const cached = modifierProbeCache.get(fn);\n if (cached) {\n return cached;\n }\n try {\n const value = fn();\n const record = { value, error: false };\n modifierProbeCache.set(fn, record);\n return record;\n } catch {\n const record = { value: undefined, error: true };\n modifierProbeCache.set(fn, record);\n return record;\n }\n}\n\nfunction isBooleanFunction(fn: ZeroArityFunction): fn is BooleanCondition {\n const { value, error } = probeOnce(fn);\n if (error) return false;\n return typeof value === \"boolean\";\n}\n\nexport function isConditionalModifier(\n modifier: unknown,\n allModifiers: unknown[],\n currentIndex: number\n): modifier is BooleanCondition {\n if (!isFunction(modifier) || modifier.length !== 0) {\n return false;\n }\n\n // After checking length === 0, we know it's a ZeroArityFunction\n const zeroArityFn = modifier as ZeroArityFunction;\n if (!isBooleanFunction(zeroArityFn)) {\n return false;\n }\n\n const otherModifiers = allModifiers.filter((_, index) => index !== currentIndex);\n if (otherModifiers.length === 0) return false;\n\n const hasAttributesOrElements = otherModifiers.some((mod) => {\n if (isObject(mod) || isNode(mod)) return true;\n if (isFunction(mod) && mod.length > 0) return true;\n return false;\n });\n\n return hasAttributesOrElements;\n}\n\nexport function findConditionalModifier(modifiers: unknown[]): number {\n for (let i = 0; i < modifiers.length; i += 1) {\n if (isConditionalModifier(modifiers[i], modifiers, i)) {\n return i;\n }\n }\n return -1;\n}\n\nexport { modifierProbeCache };\n","import { applyAttributes } from \"./attributeManager\";\nimport { createReactiveTextNode } from \"./reactive\";\nimport { logError } from \"../utility/errorHandler\";\nimport { isFunction, isNode, isObject, isPrimitive, isZeroArityFunction } from \"../utility/typeGuards\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { createComment } from \"../utility/dom\";\n\nexport { isConditionalModifier, findConditionalModifier } from \"../utility/modifierPredicates\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport function applyNodeModifier<TTagName extends ElementTagName>(\n parent: ExpandedElement<TTagName>,\n modifier: NodeModifier<TTagName>,\n index: number,\n): Node | null {\n if (modifier == null) return null;\n\n if (isFunction(modifier)) {\n // Handle zero-argument functions (reactive text)\n if (isZeroArityFunction(modifier)) {\n try {\n let record = modifierProbeCache.get(modifier);\n if (!record) {\n const value = (modifier as () => unknown)();\n record = { value, error: false };\n modifierProbeCache.set(modifier, record);\n }\n if (record.error) {\n return createReactiveTextFragment(index, () => \"\");\n }\n const v = record.value;\n if (isPrimitive(v) && v != null) {\n return createReactiveTextFragment(index, modifier as () => Primitive, v);\n }\n return null;\n } catch (error) {\n modifierProbeCache.set(modifier, { value: undefined, error: true });\n logError(\"Error evaluating reactive text function:\", error);\n return createReactiveTextFragment(index, () => \"\");\n }\n }\n\n // Handle NodeModFn functions\n const produced = modifier(parent, index);\n if (produced == null) return null;\n if (isPrimitive(produced)) {\n return createStaticTextFragment(index, produced);\n }\n if (isNode(produced)) return produced;\n if (isObject(produced)) {\n applyAttributes(parent, produced as ExpandedElementAttributes<TTagName>);\n }\n return null;\n }\n\n // Handle non-function modifiers\n const candidate = modifier as NodeMod<TTagName>;\n if (candidate == null) return null;\n if (isPrimitive(candidate)) {\n return createStaticTextFragment(index, candidate);\n }\n if (isNode(candidate)) return candidate;\n if (isObject(candidate)) {\n applyAttributes(parent, candidate as ExpandedElementAttributes<TTagName>);\n }\n return null;\n}\n\nfunction createReactiveTextFragment(\n index: number,\n resolver: () => Primitive,\n preEvaluated?: unknown\n): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const comment = createComment(` text-${index} `);\n if (comment) fragment.appendChild(comment);\n const textNode = createReactiveTextNode(resolver, preEvaluated);\n fragment.appendChild(textNode);\n return fragment;\n}\n\nfunction createStaticTextFragment(index: number, value: Primitive): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const comment = createComment(` text-${index} `);\n if (comment) fragment.appendChild(comment);\n const textNode = document.createTextNode(String(value));\n fragment.appendChild(textNode);\n return fragment;\n}\n","export interface ConditionalInfo<TTagName extends ElementTagName = ElementTagName> {\n condition: () => boolean;\n tagName: TTagName;\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n}\n\ninterface NodeWithConditionalInfo extends Node {\n _conditionalInfo?: ConditionalInfo<keyof HTMLElementTagNameMap>;\n}\n\n/**\n * Registry of all nodes that have conditional info attached.\n * This enables O(nConditionals) updates instead of a full DOM tree walk.\n */\nconst activeConditionalNodes = new Set<Node>();\n\n/**\n * Attach conditional info to a node and register it.\n */\nexport function storeConditionalInfo<TTagName extends ElementTagName>(\n node: Node,\n info: ConditionalInfo<TTagName>\n): void {\n (node as NodeWithConditionalInfo)._conditionalInfo = info as ConditionalInfo<keyof HTMLElementTagNameMap>;\n activeConditionalNodes.add(node);\n}\n\n/**\n * Explicit unregister helper (optional use on teardown if needed).\n */\nexport function unregisterConditionalNode(node: Node): void {\n activeConditionalNodes.delete(node);\n}\n\n/**\n * Returns a readonly view of currently tracked conditional nodes.\n */\nexport function getActiveConditionalNodes(): ReadonlySet<Node> {\n return activeConditionalNodes;\n}\n\nexport function hasConditionalInfo(node: Node): boolean {\n return Boolean((node as NodeWithConditionalInfo)._conditionalInfo);\n}\n\nexport function getConditionalInfo(node: Node): ConditionalInfo<keyof HTMLElementTagNameMap> | null {\n return (node as NodeWithConditionalInfo)._conditionalInfo ?? null;\n}\n","/**\n * Shared helper for applying an array of modifiers to an element.\n * Consolidates the previously duplicated logic in several modules:\n * - conditionalRenderer\n * - conditionalUpdater\n * - elementFactory\n *\n * Goal: single, optimized, well‑typed implementation.\n *\n * A \"modifier\" can:\n * - Return (or be) primitives → appended as text\n * - Return (or be) Node → appended (if not already a child)\n * - Return (or be) attribute objects → merged into element\n * - Be a NodeModFn invoked with (parent, index)\n * - Be a zero‑arg function producing reactive text (handled upstream in applyNodeModifier)\n *\n * Indexing:\n * - startIndex allows callers to continue an index sequence if needed.\n * - Every successfully rendered child Node increments the local index.\n */\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport interface ApplyModifiersResult<TTagName extends ElementTagName> {\n /**\n * The element passed in (for fluent patterns if desired).\n */\n element: ExpandedElement<TTagName>;\n /**\n * The next index after processing (startIndex + rendered children count).\n */\n nextIndex: number;\n /**\n * Number of child nodes appended (not counting attributes-only modifiers).\n */\n appended: number;\n}\n\n/**\n * Applies modifiers to an element, appending newly produced Nodes while avoiding\n * duplicate DOM insertions (i.e. only appends if parentNode differs).\n *\n * Returns meta information that callers can use for continuation indexing.\n */\nexport function applyModifiers<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ApplyModifiersResult<TTagName> {\n if (!modifiers || modifiers.length === 0) {\n return { element, nextIndex: startIndex, appended: 0 };\n }\n\n let localIndex = startIndex;\n let appended = 0;\n const parentNode = element as unknown as Node & ParentNode;\n\n for (let i = 0; i < modifiers.length; i += 1) {\n const mod = modifiers[i];\n // Fast null/undefined skip\n if (mod == null) continue;\n\n const produced = applyNodeModifier(element, mod, localIndex);\n if (!produced) continue;\n\n // Only append if the node isn't already where we expect\n if (produced.parentNode !== parentNode) {\n parentNode.appendChild(produced);\n }\n localIndex += 1;\n appended += 1;\n }\n\n return {\n element,\n nextIndex: localIndex,\n appended\n };\n}\n\n/**\n * Convenience helper: apply modifiers and return the element (fluent style).\n * Discards meta information.\n */\nexport function applyModifiersAndReturn<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ExpandedElement<TTagName> {\n applyModifiers(element, modifiers, startIndex);\n return element;\n}\n\n/**\n * Creates an element with the specified tag name and applies modifiers to it.\n * Centralizes element creation logic used across conditionalRenderer and conditionalUpdater.\n */\nexport function createElementWithModifiers<TTagName extends ElementTagName>(\n tagName: TTagName,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>\n): ExpandedElement<TTagName> {\n const el = document.createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, modifiers, 0);\n return el;\n}","import { findConditionalModifier } from \"./modifierProcessor\";\nimport { isBrowser } from \"../utility/environment\";\nimport { storeConditionalInfo } from \"../utility/conditionalInfo\";\nimport type { ConditionalInfo } from \"../utility/conditionalInfo\";\nimport { createElementWithModifiers, type NodeModifier } from \"../internal/applyModifiers\";\nimport { createConditionalComment } from \"../utility/dom\";\n\nexport function createConditionalElement<TTagName extends ElementTagName>(\n tagName: TTagName,\n condition: () => boolean,\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): ExpandedElement<TTagName> | Comment {\n const passed = condition();\n\n if (!isBrowser) {\n return passed\n ? createElementWithModifiers(tagName, modifiers as ReadonlyArray<NodeModifier<TTagName>>)\n : (createConditionalComment(tagName, \"ssr\") as unknown as ExpandedElement<TTagName>);\n }\n\n const conditionalInfo: ConditionalInfo<TTagName> = { condition, tagName, modifiers };\n\n if (passed) {\n const el = createElementWithModifiers(tagName, modifiers as ReadonlyArray<NodeModifier<TTagName>>);\n storeConditionalInfo(el as Node, conditionalInfo);\n return el;\n }\n\n const comment = createConditionalComment(tagName);\n if (!comment) {\n throw new Error(`Failed to create conditional comment for ${tagName}`);\n }\n storeConditionalInfo(comment as Node, conditionalInfo);\n return comment as unknown as ExpandedElement<TTagName>;\n}\n\nexport function processConditionalModifiers<TTagName extends ElementTagName>(\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): {\n condition: (() => boolean) | null;\n otherModifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n} {\n const conditionalIndex = findConditionalModifier(modifiers);\n\n if (conditionalIndex === -1) {\n return { condition: null, otherModifiers: modifiers };\n }\n\n return {\n condition: modifiers[conditionalIndex] as () => boolean,\n otherModifiers: modifiers.filter((_, index) => index !== conditionalIndex)\n };\n}\n","import { createConditionalElement, processConditionalModifiers } from \"./conditionalRenderer\";\nimport { applyModifiers, type NodeModifier } from \"../internal/applyModifiers\";\nimport { SVG_TAGS } from \"./tagRegistry\";\n\n/**\n * Checks if a tag name is an SVG tag.\n */\nfunction isSVGTag(tagName: string): tagName is keyof SVGElementTagNameMap {\n return (SVG_TAGS as readonly string[]).includes(tagName);\n}\n\n/**\n * Creates an element with proper namespace handling for SVG elements.\n */\nfunction createElementWithNamespace<TTagName extends ElementTagName>(\n tagName: TTagName\n): Element {\n if (isSVGTag(tagName)) {\n return document.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n return document.createElement(tagName);\n}\n\nexport function createElementFactory<TTagName extends ElementTagName>(\n tagName: TTagName,\n ...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): NodeModFn<TTagName> {\n return (parent: ExpandedElement<TTagName>, index: number): ExpandedElement<TTagName> => {\n const { condition, otherModifiers } = processConditionalModifiers(modifiers);\n\n if (condition) {\n return createConditionalElement(tagName, condition, otherModifiers) as ExpandedElement<TTagName>;\n }\n\n const el = createElementWithNamespace(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, otherModifiers as ReadonlyArray<NodeModifier<TTagName>>, index);\n return el;\n };\n}\n\nexport function createTagBuilder<TTagName extends ElementTagName>(\n tagName: TTagName,\n): (...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>) => NodeModFn<TTagName> {\n return (...mods) => createElementFactory(tagName, ...mods);\n}","import { createTagBuilder } from \"./elementFactory\";\n\nexport const HTML_TAGS = [\n \"a\", \"abbr\", \"address\", \"area\", \"article\", \"aside\", \"audio\", \"b\", \"base\",\n \"bdi\", \"bdo\", \"blockquote\", \"body\", \"br\", \"button\", \"canvas\", \"caption\",\n \"cite\", \"code\", \"col\", \"colgroup\", \"data\", \"datalist\", \"dd\", \"del\", \"details\",\n \"dfn\", \"dialog\", \"div\", \"dl\", \"dt\", \"em\", \"embed\", \"fieldset\", \"figcaption\",\n \"figure\", \"footer\", \"form\", \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"head\",\n \"header\", \"hgroup\", \"hr\", \"html\", \"i\", \"iframe\", \"img\", \"input\", \"ins\",\n \"kbd\", \"label\", \"legend\", \"li\", \"link\", \"main\", \"map\", \"mark\", \"menu\",\n \"meta\", \"meter\", \"nav\", \"noscript\", \"object\", \"ol\", \"optgroup\", \"option\",\n \"output\", \"p\", \"picture\", \"pre\", \"progress\", \"q\", \"rp\", \"rt\", \"ruby\", \"s\",\n \"samp\", \"script\", \"search\", \"section\", \"select\", \"slot\", \"small\", \"source\",\n \"span\", \"strong\", \"style\", \"sub\", \"summary\", \"sup\", \"table\", \"tbody\", \"td\",\n \"template\", \"textarea\", \"tfoot\", \"th\", \"thead\", \"time\", \"title\", \"tr\",\n \"track\", \"u\", \"ul\", \"var\", \"video\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nexport const SVG_TAGS = [\n \"a\", \"animate\", \"animateMotion\", \"animateTransform\", \"circle\", \"clipPath\",\n \"defs\", \"desc\", \"ellipse\", \"feBlend\", \"feColorMatrix\", \"feComponentTransfer\",\n \"feComposite\", \"feConvolveMatrix\", \"feDiffuseLighting\", \"feDisplacementMap\",\n \"feDistantLight\", \"feDropShadow\", \"feFlood\", \"feFuncA\", \"feFuncB\", \"feFuncG\",\n \"feFuncR\", \"feGaussianBlur\", \"feImage\", \"feMerge\", \"feMergeNode\", \"feMorphology\",\n \"feOffset\", \"fePointLight\", \"feSpecularLighting\", \"feSpotLight\", \"feTile\",\n \"feTurbulence\", \"filter\", \"foreignObject\", \"g\", \"image\", \"line\", \"linearGradient\",\n \"marker\", \"mask\", \"metadata\", \"mpath\", \"path\", \"pattern\", \"polygon\", \"polyline\",\n \"radialGradient\", \"rect\", \"script\", \"set\", \"stop\", \"style\", \"svg\", \"switch\",\n \"symbol\", \"text\", \"textPath\", \"title\", \"tspan\", \"use\", \"view\",\n] as const satisfies ReadonlyArray<keyof SVGElementTagNameMap>;\n\nexport const SELF_CLOSING_TAGS = [\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\", \"link\", \"meta\",\n \"source\", \"track\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nfunction registerHtmlTag(target: Record<string, unknown>, tagName: ElementTagName): void {\n // Don't overwrite non-function properties (safety check)\n if (tagName in target && typeof target[tagName] !== 'function') {\n return;\n }\n // Register HTML tags - they override SVG tags with same name\n target[tagName] = createTagBuilder(tagName);\n}\n\nfunction registerSvgTag(target: Record<string, unknown>, tagName: keyof SVGElementTagNameMap): void {\n // Some SVG tags conflict with HTML tags or DOM globals\n // Use suffix convention: a_svg, script_svg, style_svg, title_svg, text_svg, stop_\n const conflictingTags = ['a', 'script', 'style', 'title', 'text'];\n const globalConflicts = ['stop']; // 'stop' conflicts with DOM stop property\n\n let exportName: string = tagName;\n if (conflictingTags.includes(tagName)) {\n exportName = `${tagName}_svg`;\n } else if (globalConflicts.includes(tagName)) {\n exportName = `${tagName}_`;\n }\n\n if (!(exportName in target)) {\n target[exportName] = createTagBuilder(tagName as ElementTagName);\n }\n}\n\nexport function registerGlobalTagBuilders(target: Record<string, unknown> = globalThis): void {\n const marker = \"__nuclo_tags_registered\";\n if ((target as Record<string, boolean>)[marker]) return;\n\n // Register SVG tags first with special names for conflicts\n SVG_TAGS.forEach((tagName) => registerSvgTag(target, tagName));\n\n // Then register HTML tags - these will take precedence for conflicting names\n // So 'a' will be HTML by default, and 'a_svg' will be available for SVG anchors\n HTML_TAGS.forEach((tagName) => registerHtmlTag(target, tagName));\n\n (target as Record<string, boolean>)[marker] = true;\n}\n","import { createMarkerPair, safeRemoveChild } from \"../utility/dom\";\nimport { arraysEqual } from \"../utility/arrayUtils\";\nimport { resolveRenderable } from \"../utility/renderables\";\nimport type { ListRenderer, ListRuntime, ListItemRecord, ListItemsProvider } from \"./types\";\n\nconst activeListRuntimes = new Set<ListRuntime<unknown, keyof HTMLElementTagNameMap>>();\n\nfunction renderItem<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>,\n item: TItem,\n index: number,\n): ExpandedElement<TTagName> | null {\n const result = runtime.renderItem(item, index);\n return resolveRenderable<TTagName>(result, runtime.host, index);\n}\n\nfunction remove<TItem, TTagName extends ElementTagName>(record: ListItemRecord<TItem, TTagName>): void {\n safeRemoveChild(record.element as unknown as Node);\n}\n\nexport function sync<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>\n): void {\n const { host, startMarker, endMarker } = runtime;\n const parent = (startMarker.parentNode ?? (host as unknown as Node & ParentNode)) as\n Node & ParentNode;\n\n const currentItems = runtime.itemsProvider();\n\n if (arraysEqual(runtime.lastSyncedItems, currentItems)) return;\n\n const recordsByPosition = new Map<number, ListItemRecord<TItem, TTagName>>();\n const availableRecords = new Map<TItem, ListItemRecord<TItem, TTagName>[]>();\n\n runtime.records.forEach((record) => {\n const items = availableRecords.get(record.item);\n if (items) {\n items.push(record);\n } else {\n availableRecords.set(record.item, [record]);\n }\n });\n\n currentItems.forEach((item, newIndex) => {\n if (\n newIndex < runtime.lastSyncedItems.length &&\n runtime.lastSyncedItems[newIndex] === item\n ) {\n const existingRecord = runtime.records[newIndex];\n if (existingRecord && existingRecord.item === item) {\n recordsByPosition.set(newIndex, existingRecord);\n const items = availableRecords.get(item);\n if (items) {\n const recordIndex = items.indexOf(existingRecord);\n if (recordIndex >= 0) {\n items.splice(recordIndex, 1);\n if (items.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n }\n }\n });\n\n const newRecords: Array<ListItemRecord<TItem, TTagName>> = [];\n const elementsToRemove = new Set<ListItemRecord<TItem, TTagName>>(runtime.records);\n let nextSibling: Node = endMarker;\n\n for (let i = currentItems.length - 1; i >= 0; i--) {\n const item = currentItems[i];\n let record = recordsByPosition.get(i);\n\n if (!record) {\n const availableItems = availableRecords.get(item);\n if (availableItems && availableItems.length > 0) {\n record = availableItems.shift()!;\n if (availableItems.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n\n if (record) {\n elementsToRemove.delete(record);\n } else {\n const element = renderItem(runtime, item, i);\n if (!element) continue;\n record = { item, element };\n }\n\n newRecords.unshift(record);\n\n const recordNode = record.element as unknown as Node;\n if (recordNode.nextSibling !== nextSibling) {\n parent.insertBefore(recordNode, nextSibling);\n }\n nextSibling = recordNode;\n }\n\n elementsToRemove.forEach(remove);\n\n runtime.records = newRecords;\n runtime.lastSyncedItems = [...currentItems];\n}\n\nexport function createListRuntime<TItem, TTagName extends ElementTagName = ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n renderItem: ListRenderer<TItem, TTagName>,\n host: ExpandedElement<TTagName>,\n): ListRuntime<TItem, TTagName> {\n const { start: startMarker, end: endMarker } = createMarkerPair(\"list\");\n\n const runtime: ListRuntime<TItem, TTagName> = {\n itemsProvider,\n renderItem,\n startMarker,\n endMarker,\n records: [],\n host,\n lastSyncedItems: [],\n };\n\n const parentNode = host as unknown as Node & ParentNode;\n parentNode.appendChild(startMarker);\n parentNode.appendChild(endMarker);\n\n activeListRuntimes.add(runtime as ListRuntime<unknown, keyof HTMLElementTagNameMap>);\n sync(runtime);\n\n return runtime;\n}\n\nexport function updateListRuntimes(): void {\n activeListRuntimes.forEach((runtime) => {\n if (!runtime.startMarker.isConnected || !runtime.endMarker.isConnected) {\n activeListRuntimes.delete(runtime);\n return;\n }\n\n sync(runtime);\n });\n}\n","import { isFunction, isTagLike } from \"./typeGuards\";\n\ntype RenderableInput<TTagName extends ElementTagName = ElementTagName> =\n | NodeModFn<TTagName>\n | ExpandedElement<TTagName>\n | Node\n | null\n | undefined;\n\nexport function resolveRenderable<TTagName extends ElementTagName = ElementTagName>(\n result: RenderableInput<TTagName>,\n host: ExpandedElement<TTagName>,\n index: number\n): ExpandedElement<TTagName> | null {\n if (isFunction(result)) {\n const element = result(host, index);\n if (element && isTagLike(element)) {\n return element as ExpandedElement<TTagName>;\n }\n return null;\n }\n\n if (result && isTagLike(result)) {\n return result as ExpandedElement<TTagName>;\n }\n\n return null;\n}\n","export function arraysEqual<T>(a: readonly T[], b: readonly T[]): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if ((i in a ? a[i] : undefined) !== (i in b ? b[i] : undefined)) return false;\n }\n return true;\n}\n","import { createListRuntime } from \"./runtime\";\nimport type { ListRenderer, ListItemsProvider } from \"./types\";\n\n/**\n * Maps items to DOM elements, keeping them in sync with changes.\n */\nexport function list<TItem, TTagName extends ElementTagName = ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n render: ListRenderer<TItem, TTagName>,\n): NodeModFn<TTagName> {\n return (host: ExpandedElement<TTagName>, index: number): Comment => {\n const runtime = createListRuntime(itemsProvider, render, host);\n // Return the start marker comment node\n // NodeModFn can return NodeMod | void, and Comment is a valid Node type\n return runtime.startMarker;\n };\n}\n","export type ConditionInput = boolean | (() => boolean);\n\nexport function runCondition(\n condition: () => boolean,\n onError?: (error: unknown) => void\n): boolean {\n try {\n return condition();\n } catch (error) {\n if (onError) {\n onError(error);\n return false;\n }\n throw error;\n }\n}\n\nexport function resolveCondition(\n value: ConditionInput,\n onError?: (error: unknown) => void\n): boolean {\n return typeof value === \"function\" ? runCondition(value, onError) : Boolean(value);\n}\n","import { isBrowser } from \"../utility/environment\";\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\nimport { createMarkerPair, clearBetweenMarkers, insertNodesBefore, createComment } from \"../utility/dom\";\nimport { resolveCondition } from \"../utility/conditions\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { isFunction, isZeroArityFunction } from \"../utility/typeGuards\";\nimport { asParentNode, withScopedInsertion } from \"../utility/domTypeHelpers\";\n\ntype WhenCondition = boolean | (() => boolean);\ntype WhenContent<TTagName extends ElementTagName = ElementTagName> = \n NodeMod<TTagName> | NodeModFn<TTagName>;\n\ninterface WhenGroup<TTagName extends ElementTagName = ElementTagName> {\n condition: WhenCondition;\n content: WhenContent<TTagName>[];\n}\n\ninterface WhenRuntime<TTagName extends ElementTagName = ElementTagName> {\n startMarker: Comment;\n endMarker: Comment;\n host: ExpandedElement<TTagName>;\n index: number;\n groups: WhenGroup<TTagName>[];\n elseContent: WhenContent<TTagName>[];\n /**\n * Tracks which branch is currently rendered:\n * - null: nothing rendered yet\n * - -1: else branch\n * - >=0: index of groups[]\n */\n activeIndex: number | -1 | null;\n update(): void;\n}\n\nconst activeWhenRuntimes = new Set<WhenRuntime<any>>();\n\n/**\n * Evaluates which condition branch should be active.\n * Returns the index of the first truthy condition, -1 for else branch, or null for no match.\n */\nfunction evaluateActiveCondition<TTagName extends ElementTagName>(\n groups: ReadonlyArray<WhenGroup<TTagName>>,\n elseContent: ReadonlyArray<WhenContent<TTagName>>\n): number | -1 | null {\n for (let i = 0; i < groups.length; i++) {\n if (resolveCondition(groups[i].condition)) {\n return i;\n }\n }\n return elseContent.length > 0 ? -1 : null;\n}\n\n/**\n * Renders a single content item and returns the resulting node if any.\n */\nfunction renderContentItem<TTagName extends ElementTagName>(\n item: WhenContent<TTagName>,\n host: ExpandedElement<TTagName>,\n index: number,\n endMarker: Comment\n): Node | null {\n if (!isFunction(item)) {\n return applyNodeModifier(host, item, index);\n }\n\n // Zero-arity functions need cache cleared\n if (isZeroArityFunction(item)) {\n modifierProbeCache.delete(item);\n return applyNodeModifier(host, item, index);\n }\n\n // Non-zero-arity functions need scoped insertion to insert before endMarker\n return withScopedInsertion(host, endMarker, () => {\n const maybeNode = applyNodeModifier(host, item, index);\n // Only include nodes that weren't already inserted\n return maybeNode && !maybeNode.parentNode ? maybeNode : null;\n });\n}\n\n/**\n * Renders a list of content items and collects the resulting nodes.\n */\nfunction renderContentItems<TTagName extends ElementTagName>(\n items: ReadonlyArray<WhenContent<TTagName>>,\n host: ExpandedElement<TTagName>,\n index: number,\n endMarker: Comment\n): Node[] {\n const nodes: Node[] = [];\n for (const item of items) {\n const node = renderContentItem(item, host, index, endMarker);\n if (node) {\n nodes.push(node);\n }\n }\n return nodes;\n}\n\n/**\n * Main render function for when/else conditionals.\n * Evaluates conditions, clears old content, and renders the active branch.\n */\nfunction renderWhenContent<TTagName extends ElementTagName>(\n runtime: WhenRuntime<TTagName>\n): void {\n const { groups, elseContent, host, index, endMarker } = runtime;\n\n const newActive = evaluateActiveCondition(groups, elseContent);\n\n // No change needed\n if (newActive === runtime.activeIndex) return;\n\n // Clear previous content and update active index\n clearBetweenMarkers(runtime.startMarker, runtime.endMarker);\n runtime.activeIndex = newActive;\n\n // Nothing to render\n if (newActive === null) return;\n\n // Render the active branch\n const contentToRender = newActive >= 0 ? groups[newActive].content : elseContent;\n const nodes = renderContentItems(contentToRender, host, index, endMarker);\n\n insertNodesBefore(nodes, endMarker);\n}\n\nclass WhenBuilderImpl<TTagName extends ElementTagName = ElementTagName> {\n private groups: WhenGroup<TTagName>[] = [];\n private elseContent: WhenContent<TTagName>[] = [];\n\n constructor(initialCondition: WhenCondition, ...content: WhenContent<TTagName>[]) {\n this.groups.push({ condition: initialCondition, content });\n }\n\n when(condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.groups.push({ condition, content });\n return this;\n }\n\n else(...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.elseContent = content;\n return this;\n }\n\n render(host: ExpandedElement<TTagName>, index: number): Node | null {\n if (!isBrowser) {\n const comment = createComment(\"when-ssr\");\n return comment || null;\n }\n\n const { start: startMarker, end: endMarker } = createMarkerPair(\"when\");\n\n const runtime: WhenRuntime<TTagName> = {\n startMarker,\n endMarker,\n host,\n index,\n groups: [...this.groups],\n elseContent: [...this.elseContent],\n activeIndex: null,\n update: () => renderWhenContent(runtime),\n };\n\n activeWhenRuntimes.add(runtime);\n\n const parent = asParentNode(host);\n parent.appendChild(startMarker);\n parent.appendChild(endMarker);\n\n renderWhenContent(runtime);\n\n return startMarker;\n }\n}\n\nfunction createWhenBuilderFunction<TTagName extends ElementTagName>(\n builder: WhenBuilderImpl<TTagName>\n): WhenBuilder<TTagName> {\n const nodeModFn = (host: ExpandedElement<TTagName>, index: number): Node | null => {\n return builder.render(host, index);\n };\n\n return Object.assign(nodeModFn, {\n when: (condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.when(condition, ...content);\n return createWhenBuilderFunction(builder);\n },\n else: (...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.else(...content);\n return createWhenBuilderFunction(builder);\n },\n }) as unknown as WhenBuilder<TTagName>;\n}\n\n/**\n * Updates all active when/else conditional runtimes.\n *\n * Re-evaluates all conditional branches and re-renders if the active branch has changed.\n * Automatically cleans up runtimes that throw errors during update.\n *\n * This function should be called after state changes that affect conditional expressions.\n *\n * @example\n * ```ts\n * isLoggedIn.value = true;\n * updateWhenRuntimes(); // All when() conditionals re-evaluate\n * ```\n */\nexport function updateWhenRuntimes(): void {\n activeWhenRuntimes.forEach((runtime) => {\n try {\n runtime.update();\n } catch (error) {\n activeWhenRuntimes.delete(runtime);\n }\n });\n}\n\n/**\n * Clears all active when/else conditional runtimes.\n *\n * This is typically used for cleanup or testing purposes.\n * After calling this, no when() conditionals will be tracked for updates.\n */\nexport function clearWhenRuntimes(): void {\n activeWhenRuntimes.clear();\n}\n\n/**\n * Creates a conditional rendering block (when/else logic).\n *\n * Renders different content based on boolean conditions, similar to if/else statements.\n * Conditions can be static booleans or reactive functions that are re-evaluated on updates.\n *\n * @param condition - Boolean value or function returning a boolean\n * @param content - Content to render when condition is true\n * @returns A builder that allows chaining additional .when() or .else() branches\n *\n * @example\n * ```ts\n * const isLoggedIn = signal(false);\n *\n * div(\n * when(() => isLoggedIn.value,\n * span('Welcome back!')\n * )\n * .else(\n * button('Login', on('click', () => login()))\n * )\n * )\n * ```\n *\n * @example\n * ```ts\n * // Multiple conditions\n * div(\n * when(() => status.value === 'loading',\n * spinner()\n * )\n * .when(() => status.value === 'error',\n * errorMessage()\n * )\n * .else(\n * contentView()\n * )\n * )\n * ```\n */\nexport function when<TTagName extends ElementTagName = ElementTagName>(\n condition: WhenCondition,\n ...content: WhenContent<TTagName>[]\n): WhenBuilder<TTagName> {\n const builder = new WhenBuilderImpl<TTagName>(condition, ...content);\n return createWhenBuilderFunction(builder);\n}\n","import { createElementWithModifiers } from \"../internal/applyModifiers\";\nimport { isBrowser } from \"../utility/environment\";\nimport {\n ConditionalInfo,\n getConditionalInfo,\n storeConditionalInfo,\n getActiveConditionalNodes,\n unregisterConditionalNode,\n} from \"../utility/conditionalInfo\";\nimport { runCondition } from \"../utility/conditions\";\nimport { replaceNodeSafely, createConditionalComment } from \"../utility/dom\";\nimport { logError } from \"../utility/errorHandler\";\n\nfunction createElementFromConditionalInfo<TTagName extends ElementTagName>(\n conditionalInfo: ConditionalInfo<TTagName>\n): ExpandedElement<TTagName> {\n try {\n return createElementWithModifiers(conditionalInfo.tagName, conditionalInfo.modifiers);\n } catch (error) {\n logError(`Error applying modifiers in conditional element \"${conditionalInfo.tagName}\"`, error);\n // Return a basic element without modifiers as fallback\n return document.createElement(conditionalInfo.tagName) as ExpandedElement<TTagName>;\n }\n}\n\nfunction updateConditionalNode(node: Element | Comment): void {\n const conditionalInfo = getConditionalInfo(node);\n if (!conditionalInfo) {\n return;\n }\n\n const shouldShow = runCondition(conditionalInfo.condition, (error) => {\n logError(\"Error evaluating conditional condition\", error);\n });\n const isElement = node.nodeType === Node.ELEMENT_NODE;\n\n if (shouldShow && !isElement) {\n const element = createElementFromConditionalInfo(conditionalInfo);\n storeConditionalInfo(element as Node, conditionalInfo);\n replaceNodeSafely(node, element as Node);\n } else if (!shouldShow && isElement) {\n const comment = createConditionalComment(conditionalInfo.tagName);\n if (comment) {\n storeConditionalInfo(comment, conditionalInfo);\n replaceNodeSafely(node, comment);\n }\n }\n}\n\nexport function updateConditionalElements(): void {\n if (!isBrowser) return;\n\n try {\n getActiveConditionalNodes().forEach((node) => {\n if (!node.isConnected) {\n unregisterConditionalNode(node);\n return;\n }\n updateConditionalNode(node as Element | Comment);\n });\n } catch (error) {\n logError(\"Error during conditional elements update\", error);\n }\n}\n","import { updateListRuntimes } from \"../list/runtime\";\nimport { notifyReactiveElements, notifyReactiveTextNodes } from \"./reactive\";\nimport { updateWhenRuntimes } from \"../when\";\nimport { updateConditionalElements } from \"./conditionalUpdater\";\nimport { dispatchGlobalUpdateEvent } from \"../utility/events\";\n\nconst updaters = [\n updateListRuntimes,\n updateWhenRuntimes,\n updateConditionalElements,\n notifyReactiveElements,\n notifyReactiveTextNodes,\n dispatchGlobalUpdateEvent,\n] as const;\n\nexport function update(): void {\n for (const fn of updaters) fn();\n}\n","import { logError } from \"./errorHandler\";\n\nexport function dispatchGlobalUpdateEvent(): void {\n if (typeof document === \"undefined\") return;\n\n const targets: EventTarget[] = document.body ? [document.body, document] : [document];\n\n for (const target of targets) {\n try {\n target.dispatchEvent(new Event(\"update\", { bubbles: true }));\n } catch (error) {\n logError(\"Error dispatching global update event\", error);\n }\n }\n}\n","/**\n * Typed event listener helper.\n *\n * Usage:\n * button(\n * \"Click\",\n * on(\"click\", (e) => {\n * // e is correctly typed (e.g. MouseEvent for \"click\")\n * })\n * )\n *\n * Design notes:\n * - Returns a NodeModFn so it can be used like any other modifier.\n * - Produces no child node (returns void in the modifier body).\n * - Provides strong typing of the event object based on the DOM event name.\n */\n\nimport { logError } from \"./errorHandler\";\n\n/**\n * Overload for standard HTMLElement events (strongly typed via lib.dom.d.ts)\n */\nexport function on<\n K extends keyof HTMLElementEventMap,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: HTMLElementEventMap[K]) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\n/**\n * Fallback / custom event overload (arbitrary event names or custom event types).\n * Specify a custom event type with the E generic if needed:\n * on<\"my-event\", CustomEvent<MyDetail>>(\"my-event\", e => { ... })\n */\nexport function on<\n K extends string,\n E extends Event = Event,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: E) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\nexport function on<TTagName extends ElementTagName = ElementTagName>(\n type: string,\n listener: (ev: Event) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName> {\n return (parent: ExpandedElement<TTagName>): void => {\n // Type guard: verify parent is an HTMLElement with addEventListener\n if (!parent || typeof (parent as HTMLElement).addEventListener !== \"function\") {\n return;\n }\n\n const el = parent as HTMLElement;\n const wrapped = (ev: Event): void => {\n try {\n listener.call(el, ev);\n } catch (error) {\n logError(`Error in '${type}' listener`, error);\n }\n };\n\n el.addEventListener(type, wrapped as EventListener, options);\n };\n}\n\n/**\n * (Optional) Helper to detect an on()-produced modifier (placeholder for future use).\n */\nexport function isOnModifier(fn: unknown): boolean {\n return typeof fn === \"function\" && Object.prototype.hasOwnProperty.call(fn, \"__nucloOn\");\n}","/**\n * Renders a NodeModFn to a parent element by calling it and appending the result.\n *\n * @param nodeModFn The NodeModFn to render (created by tag builders like div(), h1(), etc.)\n * @param parent The parent element to render into (defaults to document.body)\n * @param index The index to pass to the NodeModFn (defaults to 0)\n * @returns The rendered element\n */\nexport function render<TTagName extends ElementTagName = ElementTagName>(\n nodeModFn: NodeModFn<TTagName>,\n parent?: Element,\n index: number = 0\n): ExpandedElement<TTagName> {\n const targetParent = (parent || document.body) as ExpandedElement<TTagName>;\n const element = nodeModFn(targetParent, index) as ExpandedElement<TTagName>;\n (parent || document.body).appendChild(element as Node);\n return element;\n}\n","// Cache for generated utility classes to avoid duplicates\nconst classCache = new Map<string, string>();\n\n// Sanitize value for use in class name\nfunction sanitizeValue(value: string): string {\n\t// Remove # from hex colors\n\tvalue = value.replace(/^#/, '');\n\t// Replace special characters with hyphens\n\tvalue = value.replace(/[^a-zA-Z0-9]/g, '-');\n\t// Remove leading/trailing hyphens and collapse multiple hyphens\n\tvalue = value.replace(/^-+|-+$/g, '').replace(/-+/g, '-');\n\treturn value.toLowerCase();\n}\n\n// Generate utility class name from property and value\nfunction generateUtilityClassName(property: string, value: string): string {\n\tconst cacheKey = `${property}:${value}`;\n\t\n\tif (classCache.has(cacheKey)) {\n\t\treturn classCache.get(cacheKey)!;\n\t}\n\n\tlet className: string;\n\t\n\t// Map CSS properties to Tailwind-like class prefixes\n\tconst propertyMap: Record<string, string> = {\n\t\t'background-color': 'bg',\n\t\t'color': 'text',\n\t\t'font-size': 'text',\n\t\t'display': 'display',\n\t\t'flex': 'flex',\n\t\t'justify-content': 'justify',\n\t\t'align-items': 'items',\n\t\t'font-weight': 'font',\n\t\t'padding': 'p',\n\t\t'margin': 'm',\n\t\t'width': 'w',\n\t\t'height': 'h',\n\t\t'border': 'border',\n\t\t'border-radius': 'rounded',\n\t\t'text-align': 'text',\n\t\t'gap': 'gap',\n\t\t'flex-direction': 'flex',\n\t\t'position': 'position',\n\t\t'opacity': 'opacity',\n\t\t'cursor': 'cursor',\n\t\t'box-shadow': 'shadow',\n\t\t'transition': 'transition',\n\t\t'text-decoration': 'underline',\n\t\t'letter-spacing': 'tracking',\n\t\t'min-width': 'min-w',\n\t\t'max-width': 'max-w',\n\t\t'min-height': 'min-h',\n\t\t'accent-color': 'accent',\n\t\t'line-height': 'leading',\n\t\t'font-family': 'font',\n\t\t'outline': 'outline',\n\t};\n\n\tconst prefix = propertyMap[property] || property.replace(/-/g, '-');\n\tconst sanitizedValue = sanitizeValue(value);\n\n\t// Handle special cases\n\tif (property === 'display' && value === 'flex') {\n\t\tclassName = 'flex';\n\t} else if (property === 'display' && value === 'grid') {\n\t\tclassName = 'grid';\n\t} else if (property === 'display' && value === 'block') {\n\t\tclassName = 'display-block';\n\t} else if (property === 'display' && value === 'none') {\n\t\tclassName = 'display-none';\n\t} else if (property === 'justify-content' && value === 'center' && prefix === 'justify') {\n\t\tclassName = 'justify-center';\n\t} else if (property === 'align-items' && value === 'center' && prefix === 'items') {\n\t\tclassName = 'items-center';\n\t} else if (property === 'font-weight' && value === 'bold') {\n\t\tclassName = 'font-bold';\n\t} else if (property === 'text-align' && value === 'center') {\n\t\tclassName = 'text-center';\n\t} else if (property === 'flex-direction' && value === 'column') {\n\t\tclassName = 'flex-col';\n\t} else if (property === 'flex-direction' && value === 'row') {\n\t\tclassName = 'flex-row';\n\t} else if (property === 'cursor' && value === 'pointer') {\n\t\tclassName = 'cursor-pointer';\n\t} else if (property === 'text-decoration' && value === 'line-through') {\n\t\tclassName = 'line-through';\n\t} else {\n\t\t// Default: prefix-value format\n\t\tclassName = `${prefix}-${sanitizedValue}`;\n\t}\n\n\tclassCache.set(cacheKey, className);\n\treturn className;\n}\n\n// CSSStyleSheet API - creates a utility class\nfunction createUtilityClass(className: string, property: string, value: string): void {\n\tlet styleSheet = document.querySelector(\"#nuclo-styles\") as HTMLStyleElement;\n\n\tif (!styleSheet) {\n\t\tstyleSheet = document.createElement(\"style\");\n\t\tstyleSheet.id = \"nuclo-styles\";\n\t\tdocument.head.appendChild(styleSheet);\n\t}\n\n\t// Check if class already exists\n\tconst existingRules = Array.from(styleSheet.sheet?.cssRules || []);\n\tconst classExists = existingRules.some(rule => {\n\t\tif (rule instanceof CSSStyleRule) {\n\t\t\treturn rule.selectorText === `.${className}`;\n\t\t}\n\t\treturn false;\n\t});\n\n\tif (!classExists) {\n\t\tstyleSheet.sheet?.insertRule(`.${className} { ${property}: ${value}; }`, styleSheet.sheet.cssRules.length);\n\t}\n}\n\n// Create utility class with media query\nfunction createUtilityClassWithMedia(className: string, property: string, value: string, mediaQuery: string): void {\n\tlet styleSheet = document.querySelector(\"#nuclo-styles\") as HTMLStyleElement;\n\n\tif (!styleSheet) {\n\t\tstyleSheet = document.createElement(\"style\");\n\t\tstyleSheet.id = \"nuclo-styles\";\n\t\tdocument.head.appendChild(styleSheet);\n\t}\n\n\t// Check if media query rule already exists\n\tconst existingRules = Array.from(styleSheet.sheet?.cssRules || []);\n\tlet mediaRule: CSSMediaRule | null = null;\n\n\tfor (const rule of existingRules) {\n\t\tif (rule instanceof CSSMediaRule && rule.media.mediaText === mediaQuery) {\n\t\t\tmediaRule = rule;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!mediaRule) {\n\t\t// Create new media query rule\n\t\tconst index = styleSheet.sheet?.cssRules.length || 0;\n\t\tstyleSheet.sheet?.insertRule(`@media ${mediaQuery} {}`, index);\n\t\tmediaRule = styleSheet.sheet?.cssRules[index] as CSSMediaRule;\n\t}\n\n\t// Check if class already exists in this media query\n\tconst classExists = Array.from(mediaRule.cssRules).some(rule => {\n\t\tif (rule instanceof CSSStyleRule) {\n\t\t\treturn rule.selectorText === `.${className}`;\n\t\t}\n\t\treturn false;\n\t});\n\n\tif (!classExists) {\n\t\tmediaRule.insertRule(`.${className} { ${property}: ${value}; }`, mediaRule.cssRules.length);\n\t}\n}\n\n// Utility class builder for chaining CSS properties\nclass StyleBuilder {\n\tprivate classNames: string[] = [];\n\tprivate classDefinitions: Array<{ className: string; property: string; value: string }> = [];\n\n\t// Get the accumulated class names\n\tgetClassNames(): string[] {\n\t\treturn [...this.classNames];\n\t}\n\n\t// Get class definitions (for breakpoint support)\n\tgetClassDefinitions(): Array<{ className: string; property: string; value: string }> {\n\t\treturn [...this.classDefinitions];\n\t}\n\n\t// Get class names as space-separated string\n\ttoString(): string {\n\t\treturn this.classNames.join(' ');\n\t}\n\n\t// Add a utility class\n\tprivate addClass(property: string, value: string): this {\n\t\tconst className = generateUtilityClassName(property, value);\n\t\t// Track the property/value that created this class for breakpoint support\n\t\tclassToPropertyMap.set(className, { property, value });\n\t\t\n\t\t// Store the class definition\n\t\tthis.classDefinitions.push({ className, property, value });\n\t\t\n\t\t// Create the class immediately (will be overridden by media queries if needed)\n\t\tcreateUtilityClass(className, property, value);\n\t\t\n\t\tif (!this.classNames.includes(className)) {\n\t\t\tthis.classNames.push(className);\n\t\t}\n\t\treturn this;\n\t}\n\n\t// Add a custom style\n\tadd(property: string, value: string): this {\n\t\treturn this.addClass(property, value);\n\t}\n\n\t// Background color\n\tbg(color: string): this {\n\t\treturn this.addClass(\"background-color\", color);\n\t}\n\n\t// Text color\n\tcolor(color: string): this {\n\t\treturn this.addClass(\"color\", color);\n\t}\n\n\t// Font size\n\tfontSize(size: string): this {\n\t\treturn this.addClass(\"font-size\", size);\n\t}\n\n\t// Display\n\tdisplay(value: string): this {\n\t\treturn this.addClass(\"display\", value);\n\t}\n\n\t// Display flex or flex property\n\tflex(value?: string): this {\n\t\tif (value !== undefined) {\n\t\t\treturn this.addClass(\"flex\", value);\n\t\t} else {\n\t\t\treturn this.addClass(\"display\", \"flex\");\n\t\t}\n\t}\n\n\t// Center content (flex)\n\tcenter(): this {\n\t\tthis.addClass(\"justify-content\", \"center\");\n\t\treturn this.addClass(\"align-items\", \"center\");\n\t}\n\n\t// Bold font\n\tbold(): this {\n\t\treturn this.addClass(\"font-weight\", \"bold\");\n\t}\n\n\t// Padding\n\tpadding(value: string): this {\n\t\treturn this.addClass(\"padding\", value);\n\t}\n\n\t// Margin\n\tmargin(value: string): this {\n\t\treturn this.addClass(\"margin\", value);\n\t}\n\n\t// Width\n\twidth(value: string): this {\n\t\treturn this.addClass(\"width\", value);\n\t}\n\n\t// Height\n\theight(value: string): this {\n\t\treturn this.addClass(\"height\", value);\n\t}\n\n\t// Border\n\tborder(value: string): this {\n\t\treturn this.addClass(\"border\", value);\n\t}\n\n\t// Border radius\n\tborderRadius(value: string): this {\n\t\treturn this.addClass(\"border-radius\", value);\n\t}\n\n\t// Text align\n\ttextAlign(value: string): this {\n\t\treturn this.addClass(\"text-align\", value);\n\t}\n\n\t// Gap (for flex/grid)\n\tgap(value: string): this {\n\t\treturn this.addClass(\"gap\", value);\n\t}\n\n\t// Flex direction\n\tflexDirection(value: string): this {\n\t\treturn this.addClass(\"flex-direction\", value);\n\t}\n\n\t// Display grid\n\tgrid(): this {\n\t\treturn this.addClass(\"display\", \"grid\");\n\t}\n\n\t// Position\n\tposition(value: string): this {\n\t\treturn this.addClass(\"position\", value);\n\t}\n\n\t// Opacity\n\topacity(value: string): this {\n\t\treturn this.addClass(\"opacity\", value);\n\t}\n\n\t// Cursor\n\tcursor(value: string): this {\n\t\treturn this.addClass(\"cursor\", value);\n\t}\n\n\t// Box shadow\n\tboxShadow(value: string): this {\n\t\treturn this.addClass(\"box-shadow\", value);\n\t}\n\n\t// Transition\n\ttransition(value: string): this {\n\t\treturn this.addClass(\"transition\", value);\n\t}\n\n\t// Text decoration\n\ttextDecoration(value: string): this {\n\t\treturn this.addClass(\"text-decoration\", value);\n\t}\n\n\t// Letter spacing\n\tletterSpacing(value: string): this {\n\t\treturn this.addClass(\"letter-spacing\", value);\n\t}\n\n\t// Font weight\n\tfontWeight(value: string): this {\n\t\treturn this.addClass(\"font-weight\", value);\n\t}\n\n\t// Align items\n\talignItems(value: string): this {\n\t\treturn this.addClass(\"align-items\", value);\n\t}\n\n\t// Justify content\n\tjustifyContent(value: string): this {\n\t\treturn this.addClass(\"justify-content\", value);\n\t}\n\n\t// Min width\n\tminWidth(value: string): this {\n\t\treturn this.addClass(\"min-width\", value);\n\t}\n\n\t// Max width\n\tmaxWidth(value: string): this {\n\t\treturn this.addClass(\"max-width\", value);\n\t}\n\n\t// Min height\n\tminHeight(value: string): this {\n\t\treturn this.addClass(\"min-height\", value);\n\t}\n\n\t// Accent color\n\taccentColor(value: string): this {\n\t\treturn this.addClass(\"accent-color\", value);\n\t}\n\n\t// Line height\n\tlineHeight(value: string): this {\n\t\treturn this.addClass(\"line-height\", value);\n\t}\n\n\t// Font family\n\tfontFamily(value: string): this {\n\t\treturn this.addClass(\"font-family\", value);\n\t}\n\n\t// Outline\n\toutline(value: string): this {\n\t\treturn this.addClass(\"outline\", value);\n\t}\n}\n\n// Breakpoints type\ntype BreakpointStyles<T extends string> = Partial<Record<T, StyleBuilder>>;\n\n// Helper to extract property and value from a class name\n// This is a reverse lookup - we need to track what property/value created each class\nconst classToPropertyMap = new Map<string, { property: string; value: string }>();\n\n// Create breakpoints function\nexport function createBreakpoints<T extends string>(breakpoints: Record<T, string>) {\n\treturn function cn(\n\t\tdefaultStylesOrBreakpoints?: StyleBuilder | BreakpointStyles<T>,\n\t\tbreakpointStyles?: BreakpointStyles<T>\n\t): { className: string } | string {\n\t\tlet defaultStyles: StyleBuilder | undefined;\n\t\tlet styles: BreakpointStyles<T> | undefined;\n\n\t\t// Handle both signatures:\n\t\t// 1. cn({ medium: width(\"50%\") }) - single argument with breakpoints\n\t\t// 2. cn(width(\"100%\"), { medium: width(\"50%\") }) - default styles + breakpoints\n\t\tif (breakpointStyles !== undefined) {\n\t\t\t// Two-argument form\n\t\t\tdefaultStyles = defaultStylesOrBreakpoints as StyleBuilder;\n\t\t\tstyles = breakpointStyles;\n\t\t} else if (defaultStylesOrBreakpoints instanceof StyleBuilder) {\n\t\t\t// Single argument, but it's a StyleBuilder (default styles only)\n\t\t\tdefaultStyles = defaultStylesOrBreakpoints;\n\t\t\tstyles = undefined;\n\t\t} else {\n\t\t\t// Single argument with breakpoints\n\t\t\tdefaultStyles = undefined;\n\t\t\tstyles = defaultStylesOrBreakpoints as BreakpointStyles<T>;\n\t\t}\n\n\t\t// If nothing provided, return empty\n\t\tif (!defaultStyles && (!styles || Object.keys(styles).length === 0)) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\tconst allClassNames: string[] = [];\n\n\t\t// Process default styles (no media query)\n\t\tif (defaultStyles) {\n\t\t\tconst classDefinitions = defaultStyles.getClassDefinitions();\n\t\t\tfor (const { className, property, value } of classDefinitions) {\n\t\t\t\tcreateUtilityClass(className, property, value);\n\t\t\t\tallClassNames.push(className);\n\t\t\t}\n\t\t}\n\n\t\t// Process breakpoint styles\n\t\tif (styles && Object.keys(styles).length > 0) {\n\t\t\tconst breakpointEntries = Object.entries(breakpoints) as [T, string][];\n\n\t\t\tfor (const [breakpointName, mediaQuery] of breakpointEntries) {\n\t\t\t\tconst styleBuilder = styles[breakpointName];\n\t\t\t\tif (styleBuilder) {\n\t\t\t\t\tconst classDefinitions = (styleBuilder as StyleBuilder).getClassDefinitions();\n\t\t\t\t\t\n\t\t\t\t\t// For each class definition\n\t\t\t\t\tfor (const { className, property, value } of classDefinitions) {\n\t\t\t\t\t\t// Create unique prefixed classes in media queries\n\t\t\t\t\t\t// This prevents leaking between elements (like Tailwind's sm:, md:, lg:)\n\t\t\t\t\t\tconst prefixedClassName = `${breakpointName}-${className}`;\n\t\t\t\t\t\tcreateUtilityClassWithMedia(prefixedClassName, property, value, mediaQuery);\n\t\t\t\t\t\tallClassNames.push(prefixedClassName);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Return all class names - each breakpoint has unique classes\n\t\treturn { className: allClassNames.join(' ') };\n\t};\n}\n\n// Legacy function for backward compatibility\nexport function createCSSClass(className: string, styles: Record<string, string>): void {\n\tlet styleSheet = document.querySelector(\"#nuclo-styles\") as HTMLStyleElement;\n\n\tif (!styleSheet) {\n\t\tstyleSheet = document.createElement(\"style\");\n\t\tstyleSheet.id = \"nuclo-styles\";\n\t\tdocument.head.appendChild(styleSheet);\n\t}\n\n\tconst rules = Object.entries(styles)\n\t\t.map(([property, value]) => `${property}: ${value}`)\n\t\t.join(\"; \");\n\n\tstyleSheet.sheet?.insertRule(`.${className} { ${rules} }`, styleSheet.sheet.cssRules.length);\n}\n\n// Utility functions that create new StyleBuilders\nexport function bg(color: string): StyleBuilder {\n\treturn new StyleBuilder().bg(color);\n}\n\nexport function color(colorValue: string): StyleBuilder {\n\treturn new StyleBuilder().color(colorValue);\n}\n\nexport function fontSize(size: string): StyleBuilder {\n\treturn new StyleBuilder().fontSize(size);\n}\n\nexport function flex(value?: string): StyleBuilder {\n\treturn new StyleBuilder().flex(value);\n}\n\nexport function center(): StyleBuilder {\n\treturn new StyleBuilder().center();\n}\n\nexport function bold(): StyleBuilder {\n\treturn new StyleBuilder().bold();\n}\n\nexport function padding(value: string): StyleBuilder {\n\treturn new StyleBuilder().padding(value);\n}\n\nexport function margin(value: string): StyleBuilder {\n\treturn new StyleBuilder().margin(value);\n}\n\nexport function width(value: string): StyleBuilder {\n\treturn new StyleBuilder().width(value);\n}\n\nexport function height(value: string): StyleBuilder {\n\treturn new StyleBuilder().height(value);\n}\n\nexport function border(value: string): StyleBuilder {\n\treturn new StyleBuilder().border(value);\n}\n\nexport function borderRadius(value: string): StyleBuilder {\n\treturn new StyleBuilder().borderRadius(value);\n}\n\nexport function textAlign(value: string): StyleBuilder {\n\treturn new StyleBuilder().textAlign(value);\n}\n\nexport function gap(value: string): StyleBuilder {\n\treturn new StyleBuilder().gap(value);\n}\n\nexport function flexDirection(value: string): StyleBuilder {\n\treturn new StyleBuilder().flexDirection(value);\n}\n\nexport function grid(): StyleBuilder {\n\treturn new StyleBuilder().grid();\n}\n\nexport function position(value: string): StyleBuilder {\n\treturn new StyleBuilder().position(value);\n}\n\nexport function opacity(value: string): StyleBuilder {\n\treturn new StyleBuilder().opacity(value);\n}\n\nexport function cursor(value: string): StyleBuilder {\n\treturn new StyleBuilder().cursor(value);\n}\n\nexport function boxShadow(value: string): StyleBuilder {\n\treturn new StyleBuilder().boxShadow(value);\n}\n\nexport function transition(value: string): StyleBuilder {\n\treturn new StyleBuilder().transition(value);\n}\n\nexport function textDecoration(value: string): StyleBuilder {\n\treturn new StyleBuilder().textDecoration(value);\n}\n\nexport function letterSpacing(value: string): StyleBuilder {\n\treturn new StyleBuilder().letterSpacing(value);\n}\n\nexport function fontWeight(value: string): StyleBuilder {\n\treturn new StyleBuilder().fontWeight(value);\n}\n\nexport function alignItems(value: string): StyleBuilder {\n\treturn new StyleBuilder().alignItems(value);\n}\n\nexport function justifyContent(value: string): StyleBuilder {\n\treturn new StyleBuilder().justifyContent(value);\n}\n\nexport function minWidth(value: string): StyleBuilder {\n\treturn new StyleBuilder().minWidth(value);\n}\n\nexport function maxWidth(value: string): StyleBuilder {\n\treturn new StyleBuilder().maxWidth(value);\n}\n\nexport function minHeight(value: string): StyleBuilder {\n\treturn new StyleBuilder().minHeight(value);\n}\n\nexport function accentColor(value: string): StyleBuilder {\n\treturn new StyleBuilder().accentColor(value);\n}\n\nexport function lineHeight(value: string): StyleBuilder {\n\treturn new StyleBuilder().lineHeight(value);\n}\n\nexport function fontFamily(value: string): StyleBuilder {\n\treturn new StyleBuilder().fontFamily(value);\n}\n\nexport function outline(value: string): StyleBuilder {\n\treturn new StyleBuilder().outline(value);\n}\n\nexport function display(value: string): StyleBuilder {\n\treturn new StyleBuilder().display(value);\n}\n","import { registerGlobalTagBuilders } from \"./tagRegistry\";\nimport { list } from \"../list\";\nimport { update } from \"./updateController\";\nimport { when } from \"../when\";\nimport { on } from \"../utility/on\";\nimport { render } from \"../utility/render\";\nimport {\n createCSSClass,\n createBreakpoints,\n bg,\n color,\n fontSize,\n flex,\n center,\n bold,\n padding,\n margin,\n width,\n height,\n border,\n borderRadius,\n textAlign,\n gap,\n flexDirection,\n grid,\n position,\n opacity,\n cursor\n} from \"../style\";\n\n/**\n * Initializes the nuclo runtime by exposing tag builders and utilities.\n */\nexport function initializeRuntime(): void {\n registerGlobalTagBuilders();\n\n if (typeof globalThis !== \"undefined\") {\n const registry = globalThis as Record<string, unknown>;\n registry.list = list;\n registry.update = update;\n registry.when = when;\n registry.on = on;\n registry.render = render;\n\n // Style utilities\n registry.createCSSClass = createCSSClass;\n registry.createBreakpoints = createBreakpoints;\n registry.bg = bg;\n registry.color = color;\n registry.fontSize = fontSize;\n registry.flex = flex;\n registry.center = center;\n registry.bold = bold;\n registry.padding = padding;\n registry.margin = margin;\n registry.width = width;\n registry.height = height;\n registry.border = border;\n registry.borderRadius = borderRadius;\n registry.textAlign = textAlign;\n registry.gap = gap;\n registry.flexDirection = flexDirection;\n registry.grid = grid;\n registry.position = position;\n registry.opacity = opacity;\n registry.cursor = cursor;\n }\n}\n\nif (typeof globalThis !== \"undefined\") {\n initializeRuntime();\n}\n"],"names":["isPrimitive","value","isNode","Node","isObject","isTagLike","isFunction","isZeroArityFunction","length","logError","message","error","console","safeExecute","fn","fallback","isBrowser","window","document","safeRemoveChild","child","parentNode","removeChild","createCommentSafely","text","createComment","createConditionalComment","tagName","suffix","createMarkerComment","prefix","Error","comment","Math","random","toString","slice","createMarkerPair","endComment","start","end","insertNodesBefore","nodes","referenceNode","parent","forEach","node","newNode","insertBefore","safeInsertBefore","isNodeConnected","isConnected","contains","replaceNodeSafely","oldNode","replaceChild","reactiveTextNodes","Map","reactiveElements","applyAttributeResolvers","el","info","attributeResolvers","resolver","applyValue","key","e","registerAttributeResolver","element","Element","get","set","ensureElementInfo","updateListener","listener","addEventListener","setStyleProperty","property","style","stringValue","String","assignInlineStyles","styles","Object","entries","applySingleAttribute","raw","shouldMergeClassName","styleValue","resolvedStyles","setValue","v","merge","HTMLElement","newClassName","currentClassName","className","existing","Set","split","filter","c","add","Array","from","join","namespaceURI","setAttribute","applyAttributes","attributes","mergeClassName","k","keys","modifierProbeCache","WeakMap","isBooleanFunction","cached","record","undefined","probeOnce","isConditionalModifier","modifier","allModifiers","currentIndex","otherModifiers","_","index","some","mod","applyNodeModifier","createReactiveTextFragment","produced","createStaticTextFragment","candidate","preEvaluated","fragment","createDocumentFragment","appendChild","textNode","createTextNode","initial","arguments","str","txt","lastValue","createReactiveTextNode","activeConditionalNodes","storeConditionalInfo","_conditionalInfo","applyModifiers","modifiers","startIndex","nextIndex","appended","localIndex","i","createElementWithModifiers","createElement","processConditionalModifiers","conditionalIndex","findConditionalModifier","condition","createElementWithNamespace","SVG_TAGS","includes","isSVGTag","createElementNS","createElementFactory","passed","conditionalInfo","createConditionalElement","createTagBuilder","mods","HTML_TAGS","registerGlobalTagBuilders","target","globalThis","marker","exportName","registerSvgTag","registerHtmlTag","activeListRuntimes","renderItem","runtime","item","result","host","resolveRenderable","remove","sync","startMarker","endMarker","currentItems","itemsProvider","a","b","arraysEqual","lastSyncedItems","recordsByPosition","availableRecords","records","items","push","newIndex","existingRecord","recordIndex","indexOf","splice","delete","newRecords","elementsToRemove","nextSibling","availableItems","shift","unshift","recordNode","list","render","createListRuntime","runCondition","onError","resolveCondition","Boolean","activeWhenRuntimes","renderContentItem","callback","originalAppend","bind","originalInsert","withScopedInsertion","maybeNode","renderWhenContent","groups","elseContent","newActive","evaluateActiveCondition","activeIndex","current","next","clearBetweenMarkers","renderContentItems","content","WhenBuilderImpl","constructor","initialCondition","this","when","update","createWhenBuilderFunction","builder","assign","else","updateConditionalNode","getConditionalInfo","shouldShow","isElement","nodeType","ELEMENT_NODE","createElementFromConditionalInfo","updaters","unregisterConditionalNode","removeEventListener","newVal","textContent","targets","body","dispatchEvent","Event","bubbles","on","type","options","ev","call","nodeModFn","classCache","createUtilityClass","styleSheet","querySelector","id","head","sheet","cssRules","rule","CSSStyleRule","selectorText","insertRule","createUtilityClassWithMedia","mediaQuery","existingRules","mediaRule","CSSMediaRule","media","mediaText","StyleBuilder","classNames","classDefinitions","getClassNames","getClassDefinitions","addClass","cacheKey","has","color","display","flex","padding","margin","width","height","border","gap","position","opacity","cursor","transition","outline","replace","sanitizedValue","toLowerCase","sanitizeValue","generateUtilityClassName","classToPropertyMap","bg","fontSize","size","center","bold","borderRadius","textAlign","flexDirection","grid","boxShadow","textDecoration","letterSpacing","fontWeight","alignItems","justifyContent","minWidth","maxWidth","minHeight","accentColor","lineHeight","fontFamily","createBreakpoints","breakpoints","defaultStylesOrBreakpoints","breakpointStyles","defaultStyles","allClassNames","breakpointEntries","breakpointName","styleBuilder","prefixedClassName","createCSSClass","rules","map","colorValue","initializeRuntime","registry","children","nodeToAppend","createTextNodeSafely","safeAppendChild"],"mappings":"aAAM,SAAUA,EAAYC,GAC1B,OAAiB,OAAVA,GAAoC,iBAAVA,GAAuC,mBAAVA,CAChE,CAEM,SAAUC,EAAUD,GACxB,OAAOA,aAAiBE,IAC1B,CAEM,SAAUC,EAASH,GACvB,MAAwB,iBAAVA,GAAgC,OAAVA,CACtC,CAEM,SAAUI,EAAaJ,GAC3B,OAAOG,EAASH,IAAU,YAAcA,CAC1C,CAMM,SAAUK,EAA+BL,GAC7C,MAAwB,mBAAVA,CAChB,CAEM,SAAUM,EAAoBN,GAClC,OAAOK,EAAWL,IAAyC,IAA9BA,EAAmBO,MAClD,CCrBM,SAAUC,EAASC,EAAiBC,GACjB,oBAAZC,SACTA,QAAQD,MAAM,UAAUD,IAAWC,EAEvC,CAGM,SAAUE,EAAeC,EAAaC,GAC1C,IACE,OAAOD,GACT,CAAE,MAAOH,GAEP,OADAF,EAAS,mBAAoBE,GACtBI,CACT,CACF,CCdO,MAAMC,EAA8B,oBAAXC,QAA8C,oBAAbC,SCS3D,SAAUC,EAAgBC,GAC9B,IAAKA,GAAOC,WAAY,OAAO,EAC/B,IAEE,OADAD,EAAMC,WAAWC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8BAA+BE,IACjC,CACT,CACF,CA8HM+V,CAAgB9T,EAAQ4T,EAC1B,IAGK5T,GArBaA,CAsBtB,miBH/HM,SAAoB3C,GACxB,MAAwB,kBAAVA,CAChB"}
1
+ {"version":3,"file":"nuclo.cjs","sources":["../src/utility/typeGuards.ts","../src/utility/errorHandler.ts","../src/utility/environment.ts","../src/utility/dom.ts","../src/core/reactive.ts","../src/utility/domTypeHelpers.ts","../src/core/styleManager.ts","../src/core/attributeManager.ts","../src/utility/modifierPredicates.ts","../src/core/modifierProcessor.ts","../src/utility/conditionalInfo.ts","../src/internal/applyModifiers.ts","../src/core/conditionalRenderer.ts","../src/core/elementFactory.ts","../src/core/tagRegistry.ts","../src/list/runtime.ts","../src/utility/renderables.ts","../src/utility/arrayUtils.ts","../src/list/renderer.ts","../src/utility/conditions.ts","../src/when/index.ts","../src/core/conditionalUpdater.ts","../src/core/updateController.ts","../src/utility/events.ts","../src/utility/on.ts","../src/utility/render.ts","../src/style/styleProperties.ts","../src/style/index.ts","../src/core/runtimeBootstrap.ts"],"sourcesContent":["export function isPrimitive(value: unknown): value is Primitive {\n return value === null || (typeof value !== \"object\" && typeof value !== \"function\");\n}\n\nexport function isNode<T>(value: T): value is T & Node {\n return value instanceof Node;\n}\n\nexport function isObject(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\nexport function isTagLike<T>(value: T): value is T & { tagName?: string } {\n return isObject(value) && \"tagName\" in (value as object);\n}\n\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === \"boolean\";\n}\n\nexport function isFunction<T extends Function>(value: unknown): value is T {\n return typeof value === \"function\";\n}\n\nexport function isZeroArityFunction(value: unknown): value is () => unknown {\n return isFunction(value) && (value as Function).length === 0;\n}\n","/**\n * Simplified error handling for nuclo - reduced complexity for smaller bundle size\n */\n\n// Basic error logging - no complex context tracking\nexport function logError(message: string, error?: Error | unknown): void {\n if (typeof console !== 'undefined') {\n console.error(`nuclo: ${message}`, error);\n }\n}\n\n// Simplified safe execution - no complex context\nexport function safeExecute<T>(fn: () => T, fallback?: T): T | undefined {\n try {\n return fn();\n } catch (error) {\n logError(\"Operation failed\", error);\n return fallback;\n }\n}\n\n// Basic DOM error handler\nexport function handleDOMError(error: Error | unknown, operation: string): void {\n logError(`DOM ${operation} failed`, error);\n}","/**\n * Simplified environment detection - minimal overhead for smaller bundle size\n */\n\n// Basic environment detection - no complex caching or edge cases\nexport const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';\n","import { isBrowser } from \"./environment\";\nimport { logError } from \"./errorHandler\";\n\nfunction safeAppendChild(parent: Element | Node, child: Node): boolean {\n if (!parent || !child) return false;\n try {\n parent.appendChild(child);\n return true;\n } catch (error) {\n logError('Failed to append child node', error);\n return false;\n }\n}\n\nexport function safeRemoveChild(child: Node): boolean {\n if (!child?.parentNode) return false;\n try {\n child.parentNode.removeChild(child);\n return true;\n } catch (error) {\n logError('Failed to remove child node', error);\n return false;\n }\n}\n\nfunction safeInsertBefore(parent: Node, newNode: Node, referenceNode: Node | null): boolean {\n if (!parent || !newNode) return false;\n try {\n parent.insertBefore(newNode, referenceNode);\n return true;\n } catch (error) {\n logError('Failed to insert node before reference', error);\n return false;\n }\n}\n\nfunction createTextNodeSafely(text: string | number | boolean): Text | null {\n if (!isBrowser) return null;\n try {\n return document.createTextNode(String(text));\n } catch (error) {\n logError('Failed to create text node', error);\n return null;\n }\n}\n\nfunction createCommentSafely(text: string): Comment | null {\n if (!isBrowser) return null;\n try {\n return document.createComment(text);\n } catch (error) {\n logError('Failed to create comment node', error);\n return null;\n }\n}\n\n/**\n * Creates a comment node safely with error handling.\n * Exported for use across the codebase.\n */\nexport function createComment(text: string): Comment | null {\n return createCommentSafely(text);\n}\n\n/**\n * Creates a conditional comment placeholder node.\n * In SSR environments, this will still work because we bypass the isBrowser check.\n */\nexport function createConditionalComment(tagName: string, suffix: string = \"hidden\"): Comment | null {\n // For SSR, we need to create comments even when isBrowser is false\n // This function intentionally skips the isBrowser check for SSR compatibility\n try {\n return document.createComment(`conditional-${tagName}-${suffix}`);\n } catch (error) {\n logError('Failed to create conditional comment', error);\n return null;\n }\n}\n\nexport function createMarkerComment(prefix: string): Comment {\n if (!isBrowser) {\n throw new Error(\"Cannot create comment in non-browser environment\");\n }\n const comment = createCommentSafely(`${prefix}-${Math.random().toString(36).slice(2)}`);\n if (!comment) {\n throw new Error(\"Failed to create comment\");\n }\n return comment;\n}\n\nexport function createMarkerPair(prefix: string): { start: Comment; end: Comment } {\n const endComment = createCommentSafely(`${prefix}-end`);\n if (!endComment) {\n throw new Error(\"Failed to create end comment\");\n }\n return {\n start: createMarkerComment(`${prefix}-start`),\n end: endComment\n };\n}\n\nexport function clearBetweenMarkers(startMarker: Comment, endMarker: Comment): void {\n let current = startMarker.nextSibling;\n while (current && current !== endMarker) {\n const next = current.nextSibling;\n safeRemoveChild(current);\n current = next;\n }\n}\n\nexport function insertNodesBefore(nodes: Node[], referenceNode: Node): void {\n const parent = referenceNode.parentNode;\n if (parent) {\n nodes.forEach(node => safeInsertBefore(parent, node, referenceNode));\n }\n}\n\nexport function appendChildren(\n parent: Element | Node,\n ...children: Array<Element | Node | string | null | undefined>\n): Element | Node {\n if (!parent) return parent;\n\n children.forEach((child) => {\n if (child != null) {\n let nodeToAppend: Node;\n\n if (typeof child === \"string\") {\n const textNode = createTextNodeSafely(child);\n if (textNode) {\n nodeToAppend = textNode;\n } else {\n return;\n }\n } else {\n nodeToAppend = child as Node;\n }\n\n safeAppendChild(parent, nodeToAppend);\n }\n });\n\n return parent;\n}\n\nexport function isNodeConnected(node: Node | null | undefined): boolean {\n if (!node) return false;\n\n // Prefer the built-in isConnected property\n if (typeof node.isConnected === \"boolean\") {\n return node.isConnected;\n }\n\n // Fallback for older browsers (only if in browser environment)\n if (isBrowser && typeof document !== 'undefined') {\n return document.contains(node);\n }\n\n // In SSR or when document is not available, assume disconnected\n return false;\n}\n\n/**\n * Safely replaces an old node with a new node in the DOM.\n * Returns true on success, false on failure (and logs the error).\n */\nexport function replaceNodeSafely(oldNode: Node, newNode: Node): boolean {\n if (!oldNode?.parentNode) return false;\n try {\n oldNode.parentNode.replaceChild(newNode, oldNode);\n return true;\n } catch (error) {\n logError(\"Error replacing conditional node\", error);\n return false;\n }\n}\n","import { logError, safeExecute } from \"../utility/errorHandler\";\nimport { isNodeConnected } from \"../utility/dom\";\n\ntype TextResolver = () => Primitive;\ntype AttributeResolver = () => unknown;\n\ninterface AttributeResolverRecord {\n resolver: AttributeResolver;\n applyValue: (value: unknown) => void;\n}\n\ninterface ReactiveTextNodeInfo {\n resolver: TextResolver;\n lastValue: string;\n}\n\ninterface ReactiveElementInfo {\n attributeResolvers: Map<string, AttributeResolverRecord>;\n updateListener?: EventListener;\n}\n\nconst reactiveTextNodes = new Map<Text, ReactiveTextNodeInfo>();\nconst reactiveElements = new Map<Element, ReactiveElementInfo>();\n\nfunction ensureElementInfo(el: Element): ReactiveElementInfo {\n let info = reactiveElements.get(el);\n if (!info) {\n info = { attributeResolvers: new Map() };\n reactiveElements.set(el, info);\n }\n return info;\n}\n\nfunction applyAttributeResolvers(el: Element, info: ReactiveElementInfo): void {\n info.attributeResolvers.forEach(({ resolver, applyValue }, key) => {\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(`Failed to update reactive attribute: ${key}`, e);\n }\n });\n}\n\n/**\n * Creates a reactive text node that automatically updates when its resolver function changes.\n *\n * The text node will be registered for reactive updates and its content will be synchronized\n * whenever notifyReactiveTextNodes() is called.\n *\n * @param resolver - Function that returns the text content (string, number, boolean, etc.)\n * @param preEvaluated - Optional pre-evaluated value to avoid calling resolver immediately\n * @returns A Text node that will reactively update its content\n *\n * @example\n * ```ts\n * const count = signal(0);\n * const textNode = createReactiveTextNode(() => `Count: ${count.value}`);\n * // Later, when count changes and notifyReactiveTextNodes() is called,\n * // the text content automatically updates\n * ```\n */\nexport function createReactiveTextNode(resolver: TextResolver, preEvaluated?: unknown): Text | DocumentFragment {\n if (typeof resolver !== \"function\") {\n logError(\"Invalid resolver provided to createReactiveTextNode\");\n return document.createTextNode(\"\");\n }\n\n const initial = arguments.length > 1 ? preEvaluated : safeExecute(resolver, \"\");\n const str = initial === undefined ? \"\" : String(initial);\n const txt = document.createTextNode(str);\n\n reactiveTextNodes.set(txt, { resolver, lastValue: str });\n return txt;\n}\n\n/**\n * Registers a reactive attribute resolver for an element.\n *\n * The resolver will be called whenever the element receives an 'update' event,\n * allowing attributes to reactively update based on application state.\n *\n * @param element - The DOM element to make reactive\n * @param key - The attribute name being made reactive (e.g., 'class', 'style', 'disabled')\n * @param resolver - Function that returns the new attribute value\n * @param applyValue - Callback that applies the resolved value to the element\n *\n * @example\n * ```ts\n * const isActive = signal(false);\n * const button = document.createElement('button');\n * registerAttributeResolver(\n * button,\n * 'class',\n * () => isActive.value ? 'active' : 'inactive',\n * (value) => button.className = String(value)\n * );\n * ```\n */\nexport function registerAttributeResolver<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n key: string,\n resolver: AttributeResolver,\n applyValue: (value: unknown) => void\n): void {\n if (!(element instanceof Element) || !key || typeof resolver !== \"function\") {\n logError(\"Invalid parameters for registerAttributeResolver\");\n return;\n }\n const info = ensureElementInfo(element as Element);\n info.attributeResolvers.set(key, { resolver, applyValue });\n\n try {\n applyValue(safeExecute(resolver));\n } catch (e) {\n logError(\"Failed to apply initial attribute value\", e);\n }\n\n if (!info.updateListener) {\n const listener: EventListener = () => applyAttributeResolvers(element as Element, info);\n (element as Element).addEventListener(\"update\", listener);\n info.updateListener = listener;\n }\n}\n\n/**\n * Updates all registered reactive text nodes.\n *\n * Iterates through all reactive text nodes, re-evaluates their resolver functions,\n * and updates their content if it has changed. Automatically cleans up disconnected nodes.\n *\n * This function should be called after state changes to synchronize the DOM with application state.\n *\n * @example\n * ```ts\n * // After updating application state\n * count.value++;\n * notifyReactiveTextNodes(); // All reactive text nodes update\n * ```\n */\nexport function notifyReactiveTextNodes(): void {\n reactiveTextNodes.forEach((info, node) => {\n if (!isNodeConnected(node)) {\n reactiveTextNodes.delete(node);\n return;\n }\n try {\n const raw = safeExecute(info.resolver);\n const newVal = raw === undefined ? \"\" : String(raw);\n if (newVal !== info.lastValue) {\n node.textContent = newVal;\n info.lastValue = newVal;\n }\n } catch (e) {\n logError(\"Failed to update reactive text node\", e);\n }\n });\n}\n\n/**\n * Updates all registered reactive elements by re-evaluating their attribute resolvers.\n *\n * Iterates through all reactive elements and triggers their registered attribute resolvers\n * to update. Automatically cleans up disconnected elements and their event listeners.\n *\n * This function should be called after state changes to synchronize element attributes\n * with application state.\n *\n * @example\n * ```ts\n * // After updating application state\n * isActive.value = true;\n * notifyReactiveElements(); // All reactive attributes update\n * ```\n */\nexport function notifyReactiveElements(): void {\n reactiveElements.forEach((info, el) => {\n if (!isNodeConnected(el)) {\n if (info.updateListener) el.removeEventListener(\"update\", info.updateListener);\n reactiveElements.delete(el);\n return;\n }\n applyAttributeResolvers(el, info);\n });\n}\n","/**\n * Type-safe DOM helper utilities to reduce type assertions across the codebase.\n * These helpers provide proper typing for DOM operations while maintaining runtime safety.\n */\n\n/**\n * Safely casts an Element-like object to Node & ParentNode interface.\n * This is a common pattern needed when working with DOM manipulation.\n *\n * @param element - The element to cast\n * @returns The element typed as Node & ParentNode\n */\nexport function asParentNode<T extends Element | object>(element: T): Node & ParentNode {\n return element as unknown as Node & ParentNode;\n}\n\n/**\n * Creates a scoped DOM insertion context that temporarily redirects appendChild\n * to insertBefore at a specific reference node. This is useful for inserting\n * content at specific positions in the DOM tree.\n *\n * @param host - The host element\n * @param referenceNode - The node before which new nodes should be inserted\n * @param callback - Function to execute with the scoped context\n * @returns The result of the callback\n */\nexport function withScopedInsertion<T, THost extends Element | object>(\n host: THost,\n referenceNode: Node,\n callback: () => T\n): T {\n const parent = asParentNode(host);\n const originalAppend = parent.appendChild.bind(parent);\n const originalInsert = parent.insertBefore.bind(parent);\n\n // Temporarily override appendChild to insert before the reference node\n // TypeScript doesn't like this override but it's safe at runtime\n (parent as unknown as Record<string, unknown>).appendChild = function(node: Node): Node {\n return originalInsert(node, referenceNode);\n };\n\n try {\n return callback();\n } finally {\n // Restore original method\n (parent as unknown as Record<string, unknown>).appendChild = originalAppend;\n }\n}\n\n/**\n * Type-safe wrapper for setting CSS style properties.\n * Provides better error handling than direct CSSStyleDeclaration access.\n * Supports both camelCase and kebab-case property names.\n *\n * @param element - The element to apply styles to\n * @param property - The CSS property name (camelCase or kebab-case)\n * @param value - The value to set (string, number, or null to remove)\n * @returns true if the style was applied successfully, false otherwise\n */\nexport function setStyleProperty(\n element: HTMLElement,\n property: string,\n value: string | number | null\n): boolean {\n try {\n if (value === null || value === undefined || value === '') {\n // Use bracket notation to remove property (works with camelCase)\n (element.style as unknown as Record<string, string>)[property] = '';\n return true;\n }\n\n // Convert value to string first (might throw if toString() throws)\n const stringValue = String(value);\n // Use bracket notation to set property (works with camelCase)\n (element.style as unknown as Record<string, string>)[property] = stringValue;\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Type-safe wrapper for reading CSS style properties.\n *\n * @param element - The element to read styles from\n * @param property - The CSS property name\n * @returns The computed style value or empty string if not found\n */\nexport function getStyleProperty(\n element: HTMLElement,\n property: string\n): string {\n try {\n return element.style.getPropertyValue(property);\n } catch {\n return '';\n }\n}\n","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver } from \"./reactive\";\nimport { setStyleProperty } from \"../utility/domTypeHelpers\";\nimport { logError } from \"../utility/errorHandler\";\n\ntype StyleAssignment = Partial<CSSStyleDeclaration>;\ntype StyleResolver = () => StyleAssignment | null | undefined;\n\n/**\n * Simplified style management - basic functionality with minimal overhead\n */\nexport function assignInlineStyles<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styles: StyleAssignment | null | undefined,\n): void {\n if (!element?.style || !styles) return;\n\n for (const [property, value] of Object.entries(styles)) {\n const success = setStyleProperty(\n element as HTMLElement,\n property,\n value as string | number | null\n );\n\n if (!success) {\n // Don't try to stringify value in error message as it might throw\n logError(`Failed to set style property '${property}'`);\n }\n }\n}\n\nexport function applyStyleAttribute<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n styleValue: StyleAssignment | StyleResolver | null | undefined\n): void {\n if (!element) return;\n\n if (isFunction(styleValue)) {\n registerAttributeResolver(element, 'style', () => {\n try {\n return styleValue();\n } catch (error) {\n logError('Error in style resolver function', error);\n return null;\n }\n }, (resolvedStyles) => {\n assignInlineStyles(element, resolvedStyles as StyleAssignment);\n });\n } else {\n assignInlineStyles(element, styleValue);\n }\n}","import { isFunction } from \"../utility/typeGuards\";\nimport { registerAttributeResolver, createReactiveTextNode } from \"./reactive\";\nimport { applyStyleAttribute } from \"./styleManager\";\n\ntype AttributeKey<TTagName extends ElementTagName> = keyof ExpandedElementAttributes<TTagName>;\ntype AttributeCandidate<TTagName extends ElementTagName> =\n ExpandedElementAttributes<TTagName>[AttributeKey<TTagName>];\n\nfunction applySingleAttribute<TTagName extends ElementTagName>(\n el: ExpandedElement<TTagName>,\n key: AttributeKey<TTagName>,\n raw: AttributeCandidate<TTagName> | undefined,\n shouldMergeClassName = false,\n): void {\n if (raw == null) return;\n\n if (key === \"style\") {\n applyStyleAttribute(el, raw as ExpandedElementAttributes<TTagName>[\"style\"]);\n return;\n }\n\n const setValue = (v: unknown, merge = false): void => {\n if (v == null) return;\n\n // Special handling for className to merge instead of replace (only for non-reactive updates)\n if (key === 'className' && el instanceof HTMLElement && merge) {\n const newClassName = String(v);\n const currentClassName = el.className;\n\n // If there's already a className, merge them (avoid duplicates)\n if (currentClassName && currentClassName !== newClassName) {\n const existing = new Set(currentClassName.split(' ').filter(c => c));\n const newClasses = newClassName.split(' ').filter(c => c);\n newClasses.forEach(c => existing.add(c));\n el.className = Array.from(existing).join(' ');\n } else if (newClassName) {\n el.className = newClassName;\n }\n return;\n }\n\n // SVG elements should always use setAttribute for most attributes\n // because many SVG properties are read-only\n const isSVGElement = el instanceof Element && el.namespaceURI === 'http://www.w3.org/2000/svg';\n\n if (isSVGElement) {\n // Always use setAttribute for SVG elements\n el.setAttribute(String(key), String(v));\n } else if (key in el) {\n // For HTML elements, try to set as property first\n try {\n (el as Record<string, unknown>)[key as string] = v;\n } catch {\n // If property is read-only, fall back to setAttribute\n if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n }\n } else if (el instanceof Element) {\n el.setAttribute(String(key), String(v));\n }\n };\n\n if (isFunction(raw) && raw.length === 0) {\n // Type narrowing: zero-arity function that returns an attribute value\n // Reactive attributes should replace, not merge\n const resolver = raw as () => AttributeCandidate<TTagName>;\n registerAttributeResolver(el, String(key), resolver, (v) => setValue(v, false));\n } else {\n // Static attributes should merge classNames\n setValue(raw, shouldMergeClassName);\n }\n}\n\nexport function applyAttributes<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n attributes: ExpandedElementAttributes<TTagName>,\n mergeClassName = true,\n): void {\n if (!attributes) return;\n for (const k of Object.keys(attributes) as Array<AttributeKey<TTagName>>) {\n const value = (attributes as Record<string, unknown>)[k as string] as\n AttributeCandidate<TTagName> | undefined;\n // Only merge className for non-className keys OR when explicitly enabled for className\n const shouldMerge = mergeClassName && k === 'className';\n applySingleAttribute(element, k, value, shouldMerge);\n }\n}\n\nexport { createReactiveTextNode } from \"./reactive\";\n","import { isFunction, isNode, isObject } from \"./typeGuards\";\n\ntype BooleanCondition = () => boolean;\ntype ZeroArityFunction = () => unknown;\n\nconst modifierProbeCache = new WeakMap<ZeroArityFunction, { value: unknown; error: boolean }>();\n\nfunction probeOnce(fn: ZeroArityFunction): { value: unknown; error: boolean } {\n const cached = modifierProbeCache.get(fn);\n if (cached) {\n return cached;\n }\n try {\n const value = fn();\n const record = { value, error: false };\n modifierProbeCache.set(fn, record);\n return record;\n } catch {\n const record = { value: undefined, error: true };\n modifierProbeCache.set(fn, record);\n return record;\n }\n}\n\nfunction isBooleanFunction(fn: ZeroArityFunction): fn is BooleanCondition {\n const { value, error } = probeOnce(fn);\n if (error) return false;\n return typeof value === \"boolean\";\n}\n\nexport function isConditionalModifier(\n modifier: unknown,\n allModifiers: unknown[],\n currentIndex: number\n): modifier is BooleanCondition {\n if (!isFunction(modifier) || modifier.length !== 0) {\n return false;\n }\n\n // After checking length === 0, we know it's a ZeroArityFunction\n const zeroArityFn = modifier as ZeroArityFunction;\n if (!isBooleanFunction(zeroArityFn)) {\n return false;\n }\n\n const otherModifiers = allModifiers.filter((_, index) => index !== currentIndex);\n if (otherModifiers.length === 0) return false;\n\n const hasAttributesOrElements = otherModifiers.some((mod) => {\n if (isObject(mod) || isNode(mod)) return true;\n if (isFunction(mod) && mod.length > 0) return true;\n return false;\n });\n\n return hasAttributesOrElements;\n}\n\nexport function findConditionalModifier(modifiers: unknown[]): number {\n for (let i = 0; i < modifiers.length; i += 1) {\n if (isConditionalModifier(modifiers[i], modifiers, i)) {\n return i;\n }\n }\n return -1;\n}\n\nexport { modifierProbeCache };\n","import { applyAttributes } from \"./attributeManager\";\nimport { createReactiveTextNode } from \"./reactive\";\nimport { logError } from \"../utility/errorHandler\";\nimport { isFunction, isNode, isObject, isPrimitive, isZeroArityFunction } from \"../utility/typeGuards\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { createComment } from \"../utility/dom\";\n\nexport { isConditionalModifier, findConditionalModifier } from \"../utility/modifierPredicates\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport function applyNodeModifier<TTagName extends ElementTagName>(\n parent: ExpandedElement<TTagName>,\n modifier: NodeModifier<TTagName>,\n index: number,\n): Node | null {\n if (modifier == null) return null;\n\n if (isFunction(modifier)) {\n // Handle zero-argument functions (reactive text)\n if (isZeroArityFunction(modifier)) {\n try {\n let record = modifierProbeCache.get(modifier);\n if (!record) {\n const value = (modifier as () => unknown)();\n record = { value, error: false };\n modifierProbeCache.set(modifier, record);\n }\n if (record.error) {\n return createReactiveTextFragment(index, () => \"\");\n }\n const v = record.value;\n if (isPrimitive(v) && v != null) {\n return createReactiveTextFragment(index, modifier as () => Primitive, v);\n }\n return null;\n } catch (error) {\n modifierProbeCache.set(modifier, { value: undefined, error: true });\n logError(\"Error evaluating reactive text function:\", error);\n return createReactiveTextFragment(index, () => \"\");\n }\n }\n\n // Handle NodeModFn functions\n const produced = modifier(parent, index);\n if (produced == null) return null;\n if (isPrimitive(produced)) {\n return createStaticTextFragment(index, produced);\n }\n if (isNode(produced)) return produced;\n if (isObject(produced)) {\n applyAttributes(parent, produced as ExpandedElementAttributes<TTagName>);\n }\n return null;\n }\n\n // Handle non-function modifiers\n const candidate = modifier as NodeMod<TTagName>;\n if (candidate == null) return null;\n if (isPrimitive(candidate)) {\n return createStaticTextFragment(index, candidate);\n }\n if (isNode(candidate)) return candidate;\n if (isObject(candidate)) {\n applyAttributes(parent, candidate as ExpandedElementAttributes<TTagName>);\n }\n return null;\n}\n\nfunction createReactiveTextFragment(\n index: number,\n resolver: () => Primitive,\n preEvaluated?: unknown\n): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const comment = createComment(` text-${index} `);\n if (comment) fragment.appendChild(comment);\n const textNode = createReactiveTextNode(resolver, preEvaluated);\n fragment.appendChild(textNode);\n return fragment;\n}\n\nfunction createStaticTextFragment(index: number, value: Primitive): DocumentFragment {\n const fragment = document.createDocumentFragment();\n const comment = createComment(` text-${index} `);\n if (comment) fragment.appendChild(comment);\n const textNode = document.createTextNode(String(value));\n fragment.appendChild(textNode);\n return fragment;\n}\n","export interface ConditionalInfo<TTagName extends ElementTagName = ElementTagName> {\n condition: () => boolean;\n tagName: TTagName;\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n}\n\ninterface NodeWithConditionalInfo extends Node {\n _conditionalInfo?: ConditionalInfo<keyof HTMLElementTagNameMap>;\n}\n\n/**\n * Registry of all nodes that have conditional info attached.\n * This enables O(nConditionals) updates instead of a full DOM tree walk.\n */\nconst activeConditionalNodes = new Set<Node>();\n\n/**\n * Attach conditional info to a node and register it.\n */\nexport function storeConditionalInfo<TTagName extends ElementTagName>(\n node: Node,\n info: ConditionalInfo<TTagName>\n): void {\n (node as NodeWithConditionalInfo)._conditionalInfo = info as ConditionalInfo<keyof HTMLElementTagNameMap>;\n activeConditionalNodes.add(node);\n}\n\n/**\n * Explicit unregister helper (optional use on teardown if needed).\n */\nexport function unregisterConditionalNode(node: Node): void {\n activeConditionalNodes.delete(node);\n}\n\n/**\n * Returns a readonly view of currently tracked conditional nodes.\n */\nexport function getActiveConditionalNodes(): ReadonlySet<Node> {\n return activeConditionalNodes;\n}\n\nexport function hasConditionalInfo(node: Node): boolean {\n return Boolean((node as NodeWithConditionalInfo)._conditionalInfo);\n}\n\nexport function getConditionalInfo(node: Node): ConditionalInfo<keyof HTMLElementTagNameMap> | null {\n return (node as NodeWithConditionalInfo)._conditionalInfo ?? null;\n}\n","/**\n * Shared helper for applying an array of modifiers to an element.\n * Consolidates the previously duplicated logic in several modules:\n * - conditionalRenderer\n * - conditionalUpdater\n * - elementFactory\n *\n * Goal: single, optimized, well‑typed implementation.\n *\n * A \"modifier\" can:\n * - Return (or be) primitives → appended as text\n * - Return (or be) Node → appended (if not already a child)\n * - Return (or be) attribute objects → merged into element\n * - Be a NodeModFn invoked with (parent, index)\n * - Be a zero‑arg function producing reactive text (handled upstream in applyNodeModifier)\n *\n * Indexing:\n * - startIndex allows callers to continue an index sequence if needed.\n * - Every successfully rendered child Node increments the local index.\n */\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\n\nexport type NodeModifier<TTagName extends ElementTagName = ElementTagName> =\n | NodeMod<TTagName>\n | NodeModFn<TTagName>;\n\nexport interface ApplyModifiersResult<TTagName extends ElementTagName> {\n /**\n * The element passed in (for fluent patterns if desired).\n */\n element: ExpandedElement<TTagName>;\n /**\n * The next index after processing (startIndex + rendered children count).\n */\n nextIndex: number;\n /**\n * Number of child nodes appended (not counting attributes-only modifiers).\n */\n appended: number;\n}\n\n/**\n * Applies modifiers to an element, appending newly produced Nodes while avoiding\n * duplicate DOM insertions (i.e. only appends if parentNode differs).\n *\n * Returns meta information that callers can use for continuation indexing.\n */\nexport function applyModifiers<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ApplyModifiersResult<TTagName> {\n if (!modifiers || modifiers.length === 0) {\n return { element, nextIndex: startIndex, appended: 0 };\n }\n\n let localIndex = startIndex;\n let appended = 0;\n const parentNode = element as unknown as Node & ParentNode;\n\n for (let i = 0; i < modifiers.length; i += 1) {\n const mod = modifiers[i];\n // Fast null/undefined skip\n if (mod == null) continue;\n\n const produced = applyNodeModifier(element, mod, localIndex);\n if (!produced) continue;\n\n // Only append if the node isn't already where we expect\n if (produced.parentNode !== parentNode) {\n parentNode.appendChild(produced);\n }\n localIndex += 1;\n appended += 1;\n }\n\n return {\n element,\n nextIndex: localIndex,\n appended\n };\n}\n\n/**\n * Convenience helper: apply modifiers and return the element (fluent style).\n * Discards meta information.\n */\nexport function applyModifiersAndReturn<TTagName extends ElementTagName>(\n element: ExpandedElement<TTagName>,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>,\n startIndex = 0\n): ExpandedElement<TTagName> {\n applyModifiers(element, modifiers, startIndex);\n return element;\n}\n\n/**\n * Creates an element with the specified tag name and applies modifiers to it.\n * Centralizes element creation logic used across conditionalRenderer and conditionalUpdater.\n */\nexport function createElementWithModifiers<TTagName extends ElementTagName>(\n tagName: TTagName,\n modifiers: ReadonlyArray<NodeModifier<TTagName>>\n): ExpandedElement<TTagName> {\n const el = document.createElement(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, modifiers, 0);\n return el;\n}","import { findConditionalModifier } from \"./modifierProcessor\";\nimport { isBrowser } from \"../utility/environment\";\nimport { storeConditionalInfo } from \"../utility/conditionalInfo\";\nimport type { ConditionalInfo } from \"../utility/conditionalInfo\";\nimport { createElementWithModifiers, type NodeModifier } from \"../internal/applyModifiers\";\nimport { createConditionalComment } from \"../utility/dom\";\n\nexport function createConditionalElement<TTagName extends ElementTagName>(\n tagName: TTagName,\n condition: () => boolean,\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): ExpandedElement<TTagName> | Comment {\n const passed = condition();\n\n if (!isBrowser) {\n return passed\n ? createElementWithModifiers(tagName, modifiers as ReadonlyArray<NodeModifier<TTagName>>)\n : (createConditionalComment(tagName, \"ssr\") as unknown as ExpandedElement<TTagName>);\n }\n\n const conditionalInfo: ConditionalInfo<TTagName> = { condition, tagName, modifiers };\n\n if (passed) {\n const el = createElementWithModifiers(tagName, modifiers as ReadonlyArray<NodeModifier<TTagName>>);\n storeConditionalInfo(el as Node, conditionalInfo);\n return el;\n }\n\n const comment = createConditionalComment(tagName);\n if (!comment) {\n throw new Error(`Failed to create conditional comment for ${tagName}`);\n }\n storeConditionalInfo(comment as Node, conditionalInfo);\n return comment as unknown as ExpandedElement<TTagName>;\n}\n\nexport function processConditionalModifiers<TTagName extends ElementTagName>(\n modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): {\n condition: (() => boolean) | null;\n otherModifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>;\n} {\n const conditionalIndex = findConditionalModifier(modifiers);\n\n if (conditionalIndex === -1) {\n return { condition: null, otherModifiers: modifiers };\n }\n\n return {\n condition: modifiers[conditionalIndex] as () => boolean,\n otherModifiers: modifiers.filter((_, index) => index !== conditionalIndex)\n };\n}\n","import { createConditionalElement, processConditionalModifiers } from \"./conditionalRenderer\";\nimport { applyModifiers, type NodeModifier } from \"../internal/applyModifiers\";\nimport { SVG_TAGS } from \"./tagRegistry\";\n\n/**\n * Checks if a tag name is an SVG tag.\n */\nfunction isSVGTag(tagName: string): tagName is keyof SVGElementTagNameMap {\n return (SVG_TAGS as readonly string[]).includes(tagName);\n}\n\n/**\n * Creates an element with proper namespace handling for SVG elements.\n */\nfunction createElementWithNamespace<TTagName extends ElementTagName>(\n tagName: TTagName\n): Element {\n if (isSVGTag(tagName)) {\n return document.createElementNS('http://www.w3.org/2000/svg', tagName);\n }\n return document.createElement(tagName);\n}\n\nexport function createElementFactory<TTagName extends ElementTagName>(\n tagName: TTagName,\n ...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>\n): NodeModFn<TTagName> {\n return (parent: ExpandedElement<TTagName>, index: number): ExpandedElement<TTagName> => {\n const { condition, otherModifiers } = processConditionalModifiers(modifiers);\n\n if (condition) {\n return createConditionalElement(tagName, condition, otherModifiers) as ExpandedElement<TTagName>;\n }\n\n const el = createElementWithNamespace(tagName) as ExpandedElement<TTagName>;\n applyModifiers(el, otherModifiers as ReadonlyArray<NodeModifier<TTagName>>, index);\n return el;\n };\n}\n\nexport function createTagBuilder<TTagName extends ElementTagName>(\n tagName: TTagName,\n): (...modifiers: Array<NodeMod<TTagName> | NodeModFn<TTagName>>) => NodeModFn<TTagName> {\n return (...mods) => createElementFactory(tagName, ...mods);\n}","import { createTagBuilder } from \"./elementFactory\";\n\nexport const HTML_TAGS = [\n \"a\", \"abbr\", \"address\", \"area\", \"article\", \"aside\", \"audio\", \"b\", \"base\",\n \"bdi\", \"bdo\", \"blockquote\", \"body\", \"br\", \"button\", \"canvas\", \"caption\",\n \"cite\", \"code\", \"col\", \"colgroup\", \"data\", \"datalist\", \"dd\", \"del\", \"details\",\n \"dfn\", \"dialog\", \"div\", \"dl\", \"dt\", \"em\", \"embed\", \"fieldset\", \"figcaption\",\n \"figure\", \"footer\", \"form\", \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"head\",\n \"header\", \"hgroup\", \"hr\", \"html\", \"i\", \"iframe\", \"img\", \"input\", \"ins\",\n \"kbd\", \"label\", \"legend\", \"li\", \"link\", \"main\", \"map\", \"mark\", \"menu\",\n \"meta\", \"meter\", \"nav\", \"noscript\", \"object\", \"ol\", \"optgroup\", \"option\",\n \"output\", \"p\", \"picture\", \"pre\", \"progress\", \"q\", \"rp\", \"rt\", \"ruby\", \"s\",\n \"samp\", \"script\", \"search\", \"section\", \"select\", \"slot\", \"small\", \"source\",\n \"span\", \"strong\", \"style\", \"sub\", \"summary\", \"sup\", \"table\", \"tbody\", \"td\",\n \"template\", \"textarea\", \"tfoot\", \"th\", \"thead\", \"time\", \"title\", \"tr\",\n \"track\", \"u\", \"ul\", \"var\", \"video\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nexport const SVG_TAGS = [\n \"a\", \"animate\", \"animateMotion\", \"animateTransform\", \"circle\", \"clipPath\",\n \"defs\", \"desc\", \"ellipse\", \"feBlend\", \"feColorMatrix\", \"feComponentTransfer\",\n \"feComposite\", \"feConvolveMatrix\", \"feDiffuseLighting\", \"feDisplacementMap\",\n \"feDistantLight\", \"feDropShadow\", \"feFlood\", \"feFuncA\", \"feFuncB\", \"feFuncG\",\n \"feFuncR\", \"feGaussianBlur\", \"feImage\", \"feMerge\", \"feMergeNode\", \"feMorphology\",\n \"feOffset\", \"fePointLight\", \"feSpecularLighting\", \"feSpotLight\", \"feTile\",\n \"feTurbulence\", \"filter\", \"foreignObject\", \"g\", \"image\", \"line\", \"linearGradient\",\n \"marker\", \"mask\", \"metadata\", \"mpath\", \"path\", \"pattern\", \"polygon\", \"polyline\",\n \"radialGradient\", \"rect\", \"script\", \"set\", \"stop\", \"style\", \"svg\", \"switch\",\n \"symbol\", \"text\", \"textPath\", \"title\", \"tspan\", \"use\", \"view\",\n] as const satisfies ReadonlyArray<keyof SVGElementTagNameMap>;\n\nexport const SELF_CLOSING_TAGS = [\n \"area\", \"base\", \"br\", \"col\", \"embed\", \"hr\", \"img\", \"input\", \"link\", \"meta\",\n \"source\", \"track\", \"wbr\",\n] as const satisfies ReadonlyArray<ElementTagName>;\n\nfunction registerHtmlTag(target: Record<string, unknown>, tagName: ElementTagName): void {\n // Don't overwrite non-function properties (safety check)\n if (tagName in target && typeof target[tagName] !== 'function') {\n return;\n }\n // Register HTML tags - they override SVG tags with same name\n target[tagName] = createTagBuilder(tagName);\n}\n\nfunction registerSvgTag(target: Record<string, unknown>, tagName: keyof SVGElementTagNameMap): void {\n // Some SVG tags conflict with HTML tags or DOM globals\n // Use suffix convention: a_svg, script_svg, style_svg, title_svg, text_svg, stop_\n const conflictingTags = ['a', 'script', 'style', 'title', 'text'];\n const globalConflicts = ['stop']; // 'stop' conflicts with DOM stop property\n\n let exportName: string = tagName;\n if (conflictingTags.includes(tagName)) {\n exportName = `${tagName}_svg`;\n } else if (globalConflicts.includes(tagName)) {\n exportName = `${tagName}_`;\n }\n\n if (!(exportName in target)) {\n target[exportName] = createTagBuilder(tagName as ElementTagName);\n }\n}\n\nexport function registerGlobalTagBuilders(target: Record<string, unknown> = globalThis): void {\n const marker = \"__nuclo_tags_registered\";\n if ((target as Record<string, boolean>)[marker]) return;\n\n // Register SVG tags first with special names for conflicts\n SVG_TAGS.forEach((tagName) => registerSvgTag(target, tagName));\n\n // Then register HTML tags - these will take precedence for conflicting names\n // So 'a' will be HTML by default, and 'a_svg' will be available for SVG anchors\n HTML_TAGS.forEach((tagName) => registerHtmlTag(target, tagName));\n\n (target as Record<string, boolean>)[marker] = true;\n}\n","import { createMarkerPair, safeRemoveChild } from \"../utility/dom\";\nimport { arraysEqual } from \"../utility/arrayUtils\";\nimport { resolveRenderable } from \"../utility/renderables\";\nimport type { ListRenderer, ListRuntime, ListItemRecord, ListItemsProvider } from \"./types\";\n\nconst activeListRuntimes = new Set<ListRuntime<unknown, keyof HTMLElementTagNameMap>>();\n\nfunction renderItem<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>,\n item: TItem,\n index: number,\n): ExpandedElement<TTagName> | null {\n const result = runtime.renderItem(item, index);\n return resolveRenderable<TTagName>(result, runtime.host, index);\n}\n\nfunction remove<TItem, TTagName extends ElementTagName>(record: ListItemRecord<TItem, TTagName>): void {\n safeRemoveChild(record.element as unknown as Node);\n}\n\nexport function sync<TItem, TTagName extends ElementTagName>(\n runtime: ListRuntime<TItem, TTagName>\n): void {\n const { host, startMarker, endMarker } = runtime;\n const parent = (startMarker.parentNode ?? (host as unknown as Node & ParentNode)) as\n Node & ParentNode;\n\n const currentItems = runtime.itemsProvider();\n\n if (arraysEqual(runtime.lastSyncedItems, currentItems)) return;\n\n const recordsByPosition = new Map<number, ListItemRecord<TItem, TTagName>>();\n const availableRecords = new Map<TItem, ListItemRecord<TItem, TTagName>[]>();\n\n runtime.records.forEach((record) => {\n const items = availableRecords.get(record.item);\n if (items) {\n items.push(record);\n } else {\n availableRecords.set(record.item, [record]);\n }\n });\n\n currentItems.forEach((item, newIndex) => {\n if (\n newIndex < runtime.lastSyncedItems.length &&\n runtime.lastSyncedItems[newIndex] === item\n ) {\n const existingRecord = runtime.records[newIndex];\n if (existingRecord && existingRecord.item === item) {\n recordsByPosition.set(newIndex, existingRecord);\n const items = availableRecords.get(item);\n if (items) {\n const recordIndex = items.indexOf(existingRecord);\n if (recordIndex >= 0) {\n items.splice(recordIndex, 1);\n if (items.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n }\n }\n });\n\n const newRecords: Array<ListItemRecord<TItem, TTagName>> = [];\n const elementsToRemove = new Set<ListItemRecord<TItem, TTagName>>(runtime.records);\n let nextSibling: Node = endMarker;\n\n for (let i = currentItems.length - 1; i >= 0; i--) {\n const item = currentItems[i];\n let record = recordsByPosition.get(i);\n\n if (!record) {\n const availableItems = availableRecords.get(item);\n if (availableItems && availableItems.length > 0) {\n record = availableItems.shift()!;\n if (availableItems.length === 0) {\n availableRecords.delete(item);\n }\n }\n }\n\n if (record) {\n elementsToRemove.delete(record);\n } else {\n const element = renderItem(runtime, item, i);\n if (!element) continue;\n record = { item, element };\n }\n\n newRecords.unshift(record);\n\n const recordNode = record.element as unknown as Node;\n if (recordNode.nextSibling !== nextSibling) {\n parent.insertBefore(recordNode, nextSibling);\n }\n nextSibling = recordNode;\n }\n\n elementsToRemove.forEach(remove);\n\n runtime.records = newRecords;\n runtime.lastSyncedItems = [...currentItems];\n}\n\nexport function createListRuntime<TItem, TTagName extends ElementTagName = ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n renderItem: ListRenderer<TItem, TTagName>,\n host: ExpandedElement<TTagName>,\n): ListRuntime<TItem, TTagName> {\n const { start: startMarker, end: endMarker } = createMarkerPair(\"list\");\n\n const runtime: ListRuntime<TItem, TTagName> = {\n itemsProvider,\n renderItem,\n startMarker,\n endMarker,\n records: [],\n host,\n lastSyncedItems: [],\n };\n\n const parentNode = host as unknown as Node & ParentNode;\n parentNode.appendChild(startMarker);\n parentNode.appendChild(endMarker);\n\n activeListRuntimes.add(runtime as ListRuntime<unknown, keyof HTMLElementTagNameMap>);\n sync(runtime);\n\n return runtime;\n}\n\nexport function updateListRuntimes(): void {\n activeListRuntimes.forEach((runtime) => {\n if (!runtime.startMarker.isConnected || !runtime.endMarker.isConnected) {\n activeListRuntimes.delete(runtime);\n return;\n }\n\n sync(runtime);\n });\n}\n","import { isFunction, isTagLike } from \"./typeGuards\";\n\ntype RenderableInput<TTagName extends ElementTagName = ElementTagName> =\n | NodeModFn<TTagName>\n | ExpandedElement<TTagName>\n | Node\n | null\n | undefined;\n\nexport function resolveRenderable<TTagName extends ElementTagName = ElementTagName>(\n result: RenderableInput<TTagName>,\n host: ExpandedElement<TTagName>,\n index: number\n): ExpandedElement<TTagName> | null {\n if (isFunction(result)) {\n const element = result(host, index);\n if (element && isTagLike(element)) {\n return element as ExpandedElement<TTagName>;\n }\n return null;\n }\n\n if (result && isTagLike(result)) {\n return result as ExpandedElement<TTagName>;\n }\n\n return null;\n}\n","export function arraysEqual<T>(a: readonly T[], b: readonly T[]): boolean {\n if (a === b) return true;\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if ((i in a ? a[i] : undefined) !== (i in b ? b[i] : undefined)) return false;\n }\n return true;\n}\n","import { createListRuntime } from \"./runtime\";\nimport type { ListRenderer, ListItemsProvider } from \"./types\";\n\n/**\n * Maps items to DOM elements, keeping them in sync with changes.\n */\nexport function list<TItem, TTagName extends ElementTagName = ElementTagName>(\n itemsProvider: ListItemsProvider<TItem>,\n render: ListRenderer<TItem, TTagName>,\n): NodeModFn<TTagName> {\n return (host: ExpandedElement<TTagName>, index: number): Comment => {\n const runtime = createListRuntime(itemsProvider, render, host);\n // Return the start marker comment node\n // NodeModFn can return NodeMod | void, and Comment is a valid Node type\n return runtime.startMarker;\n };\n}\n","export type ConditionInput = boolean | (() => boolean);\n\nexport function runCondition(\n condition: () => boolean,\n onError?: (error: unknown) => void\n): boolean {\n try {\n return condition();\n } catch (error) {\n if (onError) {\n onError(error);\n return false;\n }\n throw error;\n }\n}\n\nexport function resolveCondition(\n value: ConditionInput,\n onError?: (error: unknown) => void\n): boolean {\n return typeof value === \"function\" ? runCondition(value, onError) : Boolean(value);\n}\n","import { isBrowser } from \"../utility/environment\";\nimport { applyNodeModifier } from \"../core/modifierProcessor\";\nimport { createMarkerPair, clearBetweenMarkers, insertNodesBefore, createComment } from \"../utility/dom\";\nimport { resolveCondition } from \"../utility/conditions\";\nimport { modifierProbeCache } from \"../utility/modifierPredicates\";\nimport { isFunction, isZeroArityFunction } from \"../utility/typeGuards\";\nimport { asParentNode, withScopedInsertion } from \"../utility/domTypeHelpers\";\n\ntype WhenCondition = boolean | (() => boolean);\ntype WhenContent<TTagName extends ElementTagName = ElementTagName> = \n NodeMod<TTagName> | NodeModFn<TTagName>;\n\ninterface WhenGroup<TTagName extends ElementTagName = ElementTagName> {\n condition: WhenCondition;\n content: WhenContent<TTagName>[];\n}\n\ninterface WhenRuntime<TTagName extends ElementTagName = ElementTagName> {\n startMarker: Comment;\n endMarker: Comment;\n host: ExpandedElement<TTagName>;\n index: number;\n groups: WhenGroup<TTagName>[];\n elseContent: WhenContent<TTagName>[];\n /**\n * Tracks which branch is currently rendered:\n * - null: nothing rendered yet\n * - -1: else branch\n * - >=0: index of groups[]\n */\n activeIndex: number | -1 | null;\n update(): void;\n}\n\nconst activeWhenRuntimes = new Set<WhenRuntime<any>>();\n\n/**\n * Evaluates which condition branch should be active.\n * Returns the index of the first truthy condition, -1 for else branch, or null for no match.\n */\nfunction evaluateActiveCondition<TTagName extends ElementTagName>(\n groups: ReadonlyArray<WhenGroup<TTagName>>,\n elseContent: ReadonlyArray<WhenContent<TTagName>>\n): number | -1 | null {\n for (let i = 0; i < groups.length; i++) {\n if (resolveCondition(groups[i].condition)) {\n return i;\n }\n }\n return elseContent.length > 0 ? -1 : null;\n}\n\n/**\n * Renders a single content item and returns the resulting node if any.\n */\nfunction renderContentItem<TTagName extends ElementTagName>(\n item: WhenContent<TTagName>,\n host: ExpandedElement<TTagName>,\n index: number,\n endMarker: Comment\n): Node | null {\n if (!isFunction(item)) {\n return applyNodeModifier(host, item, index);\n }\n\n // Zero-arity functions need cache cleared\n if (isZeroArityFunction(item)) {\n modifierProbeCache.delete(item);\n return applyNodeModifier(host, item, index);\n }\n\n // Non-zero-arity functions need scoped insertion to insert before endMarker\n return withScopedInsertion(host, endMarker, () => {\n const maybeNode = applyNodeModifier(host, item, index);\n // Only include nodes that weren't already inserted\n return maybeNode && !maybeNode.parentNode ? maybeNode : null;\n });\n}\n\n/**\n * Renders a list of content items and collects the resulting nodes.\n */\nfunction renderContentItems<TTagName extends ElementTagName>(\n items: ReadonlyArray<WhenContent<TTagName>>,\n host: ExpandedElement<TTagName>,\n index: number,\n endMarker: Comment\n): Node[] {\n const nodes: Node[] = [];\n for (const item of items) {\n const node = renderContentItem(item, host, index, endMarker);\n if (node) {\n nodes.push(node);\n }\n }\n return nodes;\n}\n\n/**\n * Main render function for when/else conditionals.\n * Evaluates conditions, clears old content, and renders the active branch.\n */\nfunction renderWhenContent<TTagName extends ElementTagName>(\n runtime: WhenRuntime<TTagName>\n): void {\n const { groups, elseContent, host, index, endMarker } = runtime;\n\n const newActive = evaluateActiveCondition(groups, elseContent);\n\n // No change needed\n if (newActive === runtime.activeIndex) return;\n\n // Clear previous content and update active index\n clearBetweenMarkers(runtime.startMarker, runtime.endMarker);\n runtime.activeIndex = newActive;\n\n // Nothing to render\n if (newActive === null) return;\n\n // Render the active branch\n const contentToRender = newActive >= 0 ? groups[newActive].content : elseContent;\n const nodes = renderContentItems(contentToRender, host, index, endMarker);\n\n insertNodesBefore(nodes, endMarker);\n}\n\nclass WhenBuilderImpl<TTagName extends ElementTagName = ElementTagName> {\n private groups: WhenGroup<TTagName>[] = [];\n private elseContent: WhenContent<TTagName>[] = [];\n\n constructor(initialCondition: WhenCondition, ...content: WhenContent<TTagName>[]) {\n this.groups.push({ condition: initialCondition, content });\n }\n\n when(condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.groups.push({ condition, content });\n return this;\n }\n\n else(...content: WhenContent<TTagName>[]): WhenBuilderImpl<TTagName> {\n this.elseContent = content;\n return this;\n }\n\n render(host: ExpandedElement<TTagName>, index: number): Node | null {\n if (!isBrowser) {\n const comment = createComment(\"when-ssr\");\n return comment || null;\n }\n\n const { start: startMarker, end: endMarker } = createMarkerPair(\"when\");\n\n const runtime: WhenRuntime<TTagName> = {\n startMarker,\n endMarker,\n host,\n index,\n groups: [...this.groups],\n elseContent: [...this.elseContent],\n activeIndex: null,\n update: () => renderWhenContent(runtime),\n };\n\n activeWhenRuntimes.add(runtime);\n\n const parent = asParentNode(host);\n parent.appendChild(startMarker);\n parent.appendChild(endMarker);\n\n renderWhenContent(runtime);\n\n return startMarker;\n }\n}\n\nfunction createWhenBuilderFunction<TTagName extends ElementTagName>(\n builder: WhenBuilderImpl<TTagName>\n): WhenBuilder<TTagName> {\n const nodeModFn = (host: ExpandedElement<TTagName>, index: number): Node | null => {\n return builder.render(host, index);\n };\n\n return Object.assign(nodeModFn, {\n when: (condition: WhenCondition, ...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.when(condition, ...content);\n return createWhenBuilderFunction(builder);\n },\n else: (...content: WhenContent<TTagName>[]): WhenBuilder<TTagName> => {\n builder.else(...content);\n return createWhenBuilderFunction(builder);\n },\n }) as unknown as WhenBuilder<TTagName>;\n}\n\n/**\n * Updates all active when/else conditional runtimes.\n *\n * Re-evaluates all conditional branches and re-renders if the active branch has changed.\n * Automatically cleans up runtimes that throw errors during update.\n *\n * This function should be called after state changes that affect conditional expressions.\n *\n * @example\n * ```ts\n * isLoggedIn.value = true;\n * updateWhenRuntimes(); // All when() conditionals re-evaluate\n * ```\n */\nexport function updateWhenRuntimes(): void {\n activeWhenRuntimes.forEach((runtime) => {\n try {\n runtime.update();\n } catch (error) {\n activeWhenRuntimes.delete(runtime);\n }\n });\n}\n\n/**\n * Clears all active when/else conditional runtimes.\n *\n * This is typically used for cleanup or testing purposes.\n * After calling this, no when() conditionals will be tracked for updates.\n */\nexport function clearWhenRuntimes(): void {\n activeWhenRuntimes.clear();\n}\n\n/**\n * Creates a conditional rendering block (when/else logic).\n *\n * Renders different content based on boolean conditions, similar to if/else statements.\n * Conditions can be static booleans or reactive functions that are re-evaluated on updates.\n *\n * @param condition - Boolean value or function returning a boolean\n * @param content - Content to render when condition is true\n * @returns A builder that allows chaining additional .when() or .else() branches\n *\n * @example\n * ```ts\n * const isLoggedIn = signal(false);\n *\n * div(\n * when(() => isLoggedIn.value,\n * span('Welcome back!')\n * )\n * .else(\n * button('Login', on('click', () => login()))\n * )\n * )\n * ```\n *\n * @example\n * ```ts\n * // Multiple conditions\n * div(\n * when(() => status.value === 'loading',\n * spinner()\n * )\n * .when(() => status.value === 'error',\n * errorMessage()\n * )\n * .else(\n * contentView()\n * )\n * )\n * ```\n */\nexport function when<TTagName extends ElementTagName = ElementTagName>(\n condition: WhenCondition,\n ...content: WhenContent<TTagName>[]\n): WhenBuilder<TTagName> {\n const builder = new WhenBuilderImpl<TTagName>(condition, ...content);\n return createWhenBuilderFunction(builder);\n}\n","import { createElementWithModifiers } from \"../internal/applyModifiers\";\nimport { isBrowser } from \"../utility/environment\";\nimport {\n ConditionalInfo,\n getConditionalInfo,\n storeConditionalInfo,\n getActiveConditionalNodes,\n unregisterConditionalNode,\n} from \"../utility/conditionalInfo\";\nimport { runCondition } from \"../utility/conditions\";\nimport { replaceNodeSafely, createConditionalComment } from \"../utility/dom\";\nimport { logError } from \"../utility/errorHandler\";\n\nfunction createElementFromConditionalInfo<TTagName extends ElementTagName>(\n conditionalInfo: ConditionalInfo<TTagName>\n): ExpandedElement<TTagName> {\n try {\n return createElementWithModifiers(conditionalInfo.tagName, conditionalInfo.modifiers);\n } catch (error) {\n logError(`Error applying modifiers in conditional element \"${conditionalInfo.tagName}\"`, error);\n // Return a basic element without modifiers as fallback\n return document.createElement(conditionalInfo.tagName) as ExpandedElement<TTagName>;\n }\n}\n\nfunction updateConditionalNode(node: Element | Comment): void {\n const conditionalInfo = getConditionalInfo(node);\n if (!conditionalInfo) {\n return;\n }\n\n const shouldShow = runCondition(conditionalInfo.condition, (error) => {\n logError(\"Error evaluating conditional condition\", error);\n });\n const isElement = node.nodeType === Node.ELEMENT_NODE;\n\n if (shouldShow && !isElement) {\n const element = createElementFromConditionalInfo(conditionalInfo);\n storeConditionalInfo(element as Node, conditionalInfo);\n replaceNodeSafely(node, element as Node);\n } else if (!shouldShow && isElement) {\n const comment = createConditionalComment(conditionalInfo.tagName);\n if (comment) {\n storeConditionalInfo(comment, conditionalInfo);\n replaceNodeSafely(node, comment);\n }\n }\n}\n\nexport function updateConditionalElements(): void {\n if (!isBrowser) return;\n\n try {\n getActiveConditionalNodes().forEach((node) => {\n if (!node.isConnected) {\n unregisterConditionalNode(node);\n return;\n }\n updateConditionalNode(node as Element | Comment);\n });\n } catch (error) {\n logError(\"Error during conditional elements update\", error);\n }\n}\n","import { updateListRuntimes } from \"../list/runtime\";\nimport { notifyReactiveElements, notifyReactiveTextNodes } from \"./reactive\";\nimport { updateWhenRuntimes } from \"../when\";\nimport { updateConditionalElements } from \"./conditionalUpdater\";\nimport { dispatchGlobalUpdateEvent } from \"../utility/events\";\n\nconst updaters = [\n updateListRuntimes,\n updateWhenRuntimes,\n updateConditionalElements,\n notifyReactiveElements,\n notifyReactiveTextNodes,\n dispatchGlobalUpdateEvent,\n] as const;\n\nexport function update(): void {\n for (const fn of updaters) fn();\n}\n","import { logError } from \"./errorHandler\";\n\nexport function dispatchGlobalUpdateEvent(): void {\n if (typeof document === \"undefined\") return;\n\n const targets: EventTarget[] = document.body ? [document.body, document] : [document];\n\n for (const target of targets) {\n try {\n target.dispatchEvent(new Event(\"update\", { bubbles: true }));\n } catch (error) {\n logError(\"Error dispatching global update event\", error);\n }\n }\n}\n","/**\n * Typed event listener helper.\n *\n * Usage:\n * button(\n * \"Click\",\n * on(\"click\", (e) => {\n * // e is correctly typed (e.g. MouseEvent for \"click\")\n * })\n * )\n *\n * Design notes:\n * - Returns a NodeModFn so it can be used like any other modifier.\n * - Produces no child node (returns void in the modifier body).\n * - Provides strong typing of the event object based on the DOM event name.\n */\n\nimport { logError } from \"./errorHandler\";\n\n/**\n * Overload for standard HTMLElement events (strongly typed via lib.dom.d.ts)\n */\nexport function on<\n K extends keyof HTMLElementEventMap,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: HTMLElementEventMap[K]) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\n/**\n * Fallback / custom event overload (arbitrary event names or custom event types).\n * Specify a custom event type with the E generic if needed:\n * on<\"my-event\", CustomEvent<MyDetail>>(\"my-event\", e => { ... })\n */\nexport function on<\n K extends string,\n E extends Event = Event,\n TTagName extends ElementTagName = ElementTagName\n>(\n type: K,\n listener: (ev: E) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName>;\n\nexport function on<TTagName extends ElementTagName = ElementTagName>(\n type: string,\n listener: (ev: Event) => unknown,\n options?: boolean | AddEventListenerOptions\n): NodeModFn<TTagName> {\n return (parent: ExpandedElement<TTagName>): void => {\n // Type guard: verify parent is an HTMLElement with addEventListener\n if (!parent || typeof (parent as HTMLElement).addEventListener !== \"function\") {\n return;\n }\n\n const el = parent as HTMLElement;\n const wrapped = (ev: Event): void => {\n try {\n listener.call(el, ev);\n } catch (error) {\n logError(`Error in '${type}' listener`, error);\n }\n };\n\n el.addEventListener(type, wrapped as EventListener, options);\n };\n}\n\n/**\n * (Optional) Helper to detect an on()-produced modifier (placeholder for future use).\n */\nexport function isOnModifier(fn: unknown): boolean {\n return typeof fn === \"function\" && Object.prototype.hasOwnProperty.call(fn, \"__nucloOn\");\n}","/**\n * Renders a NodeModFn to a parent element by calling it and appending the result.\n *\n * @param nodeModFn The NodeModFn to render (created by tag builders like div(), h1(), etc.)\n * @param parent The parent element to render into (defaults to document.body)\n * @param index The index to pass to the NodeModFn (defaults to 0)\n * @returns The rendered element\n */\nexport function render<TTagName extends ElementTagName = ElementTagName>(\n nodeModFn: NodeModFn<TTagName>,\n parent?: Element,\n index: number = 0\n): ExpandedElement<TTagName> {\n const targetParent = (parent || document.body) as ExpandedElement<TTagName>;\n const element = nodeModFn(targetParent, index) as ExpandedElement<TTagName>;\n (parent || document.body).appendChild(element as Node);\n return element;\n}\n","// Style properties registry - defines all CSS properties that can be used\n// This allows dynamic generation of methods and functions\n\nexport interface StylePropertyDefinition {\n\t/** The method/function name (e.g., \"bg\", \"fontSize\") */\n\tname: string;\n\t/** The CSS property name (e.g., \"background-color\", \"font-size\") */\n\tcssProperty: string;\n\t/** Optional: Default value to use if none provided */\n\tdefaultValue?: string;\n\t/** Optional: Whether this is a shorthand that takes no arguments */\n\tisShorthand?: boolean;\n}\n\nexport const STYLE_PROPERTIES: readonly StylePropertyDefinition[] = [\n\t// Display\n\t{ name: \"display\", cssProperty: \"display\" },\n\t{ name: \"grid\", cssProperty: \"display\", defaultValue: \"grid\", isShorthand: true },\n\n\t// Colors\n\t{ name: \"bg\", cssProperty: \"background-color\" },\n\t{ name: \"color\", cssProperty: \"color\" },\n\t{ name: \"accentColor\", cssProperty: \"accent-color\" },\n\n\t// Typography\n\t{ name: \"fontSize\", cssProperty: \"font-size\" },\n\t{ name: \"fontWeight\", cssProperty: \"font-weight\" },\n\t{ name: \"fontFamily\", cssProperty: \"font-family\" },\n\t{ name: \"lineHeight\", cssProperty: \"line-height\" },\n\t{ name: \"letterSpacing\", cssProperty: \"letter-spacing\" },\n\t{ name: \"textAlign\", cssProperty: \"text-align\" },\n\t{ name: \"textDecoration\", cssProperty: \"text-decoration\" },\n\t{ name: \"fontStyle\", cssProperty: \"font-style\" },\n\t{ name: \"fontVariant\", cssProperty: \"font-variant\" },\n\t{ name: \"fontStretch\", cssProperty: \"font-stretch\" },\n\t{ name: \"textTransform\", cssProperty: \"text-transform\" },\n\t{ name: \"textIndent\", cssProperty: \"text-indent\" },\n\t{ name: \"textOverflow\", cssProperty: \"text-overflow\" },\n\t{ name: \"textShadow\", cssProperty: \"text-shadow\" },\n\t{ name: \"whiteSpace\", cssProperty: \"white-space\" },\n\t{ name: \"wordSpacing\", cssProperty: \"word-spacing\" },\n\t{ name: \"wordWrap\", cssProperty: \"word-wrap\" },\n\t{ name: \"overflowWrap\", cssProperty: \"overflow-wrap\" },\n\t{ name: \"textAlignLast\", cssProperty: \"text-align-last\" },\n\t{ name: \"textJustify\", cssProperty: \"text-justify\" },\n\t{ name: \"textDecorationLine\", cssProperty: \"text-decoration-line\" },\n\t{ name: \"textDecorationColor\", cssProperty: \"text-decoration-color\" },\n\t{ name: \"textDecorationStyle\", cssProperty: \"text-decoration-style\" },\n\t{ name: \"textDecorationThickness\", cssProperty: \"text-decoration-thickness\" },\n\t{ name: \"textUnderlineOffset\", cssProperty: \"text-underline-offset\" },\n\t{ name: \"verticalAlign\", cssProperty: \"vertical-align\" },\n\n\t// Layout\n\t{ name: \"position\", cssProperty: \"position\" },\n\t{ name: \"padding\", cssProperty: \"padding\" },\n\t{ name: \"paddingTop\", cssProperty: \"padding-top\" },\n\t{ name: \"paddingRight\", cssProperty: \"padding-right\" },\n\t{ name: \"paddingBottom\", cssProperty: \"padding-bottom\" },\n\t{ name: \"paddingLeft\", cssProperty: \"padding-left\" },\n\t{ name: \"margin\", cssProperty: \"margin\" },\n\t{ name: \"marginTop\", cssProperty: \"margin-top\" },\n\t{ name: \"marginRight\", cssProperty: \"margin-right\" },\n\t{ name: \"marginBottom\", cssProperty: \"margin-bottom\" },\n\t{ name: \"marginLeft\", cssProperty: \"margin-left\" },\n\t{ name: \"width\", cssProperty: \"width\" },\n\t{ name: \"height\", cssProperty: \"height\" },\n\t{ name: \"minWidth\", cssProperty: \"min-width\" },\n\t{ name: \"maxWidth\", cssProperty: \"max-width\" },\n\t{ name: \"minHeight\", cssProperty: \"min-height\" },\n\t{ name: \"maxHeight\", cssProperty: \"max-height\" },\n\t{ name: \"boxSizing\", cssProperty: \"box-sizing\" },\n\n\t// Positioning\n\t{ name: \"top\", cssProperty: \"top\" },\n\t{ name: \"right\", cssProperty: \"right\" },\n\t{ name: \"bottom\", cssProperty: \"bottom\" },\n\t{ name: \"left\", cssProperty: \"left\" },\n\t{ name: \"zIndex\", cssProperty: \"z-index\" },\n\n\t// Flexbox\n\t{ name: \"flexDirection\", cssProperty: \"flex-direction\" },\n\t{ name: \"alignItems\", cssProperty: \"align-items\" },\n\t{ name: \"justifyContent\", cssProperty: \"justify-content\" },\n\t{ name: \"gap\", cssProperty: \"gap\" },\n\t{ name: \"flexWrap\", cssProperty: \"flex-wrap\" },\n\t{ name: \"flexGrow\", cssProperty: \"flex-grow\" },\n\t{ name: \"flexShrink\", cssProperty: \"flex-shrink\" },\n\t{ name: \"flexBasis\", cssProperty: \"flex-basis\" },\n\t{ name: \"alignSelf\", cssProperty: \"align-self\" },\n\t{ name: \"alignContent\", cssProperty: \"align-content\" },\n\t{ name: \"justifySelf\", cssProperty: \"justify-self\" },\n\t{ name: \"justifyItems\", cssProperty: \"justify-items\" },\n\n\t// Grid\n\t{ name: \"gridTemplateColumns\", cssProperty: \"grid-template-columns\" },\n\t{ name: \"gridTemplateRows\", cssProperty: \"grid-template-rows\" },\n\t{ name: \"gridTemplateAreas\", cssProperty: \"grid-template-areas\" },\n\t{ name: \"gridColumn\", cssProperty: \"grid-column\" },\n\t{ name: \"gridRow\", cssProperty: \"grid-row\" },\n\t{ name: \"gridColumnStart\", cssProperty: \"grid-column-start\" },\n\t{ name: \"gridColumnEnd\", cssProperty: \"grid-column-end\" },\n\t{ name: \"gridRowStart\", cssProperty: \"grid-row-start\" },\n\t{ name: \"gridRowEnd\", cssProperty: \"grid-row-end\" },\n\t{ name: \"gridArea\", cssProperty: \"grid-area\" },\n\t{ name: \"gridAutoColumns\", cssProperty: \"grid-auto-columns\" },\n\t{ name: \"gridAutoRows\", cssProperty: \"grid-auto-rows\" },\n\t{ name: \"gridAutoFlow\", cssProperty: \"grid-auto-flow\" },\n\n\t// Borders\n\t{ name: \"border\", cssProperty: \"border\" },\n\t{ name: \"borderTop\", cssProperty: \"border-top\" },\n\t{ name: \"borderRight\", cssProperty: \"border-right\" },\n\t{ name: \"borderBottom\", cssProperty: \"border-bottom\" },\n\t{ name: \"borderLeft\", cssProperty: \"border-left\" },\n\t{ name: \"borderWidth\", cssProperty: \"border-width\" },\n\t{ name: \"borderStyle\", cssProperty: \"border-style\" },\n\t{ name: \"borderColor\", cssProperty: \"border-color\" },\n\t{ name: \"borderTopWidth\", cssProperty: \"border-top-width\" },\n\t{ name: \"borderRightWidth\", cssProperty: \"border-right-width\" },\n\t{ name: \"borderBottomWidth\", cssProperty: \"border-bottom-width\" },\n\t{ name: \"borderLeftWidth\", cssProperty: \"border-left-width\" },\n\t{ name: \"borderTopStyle\", cssProperty: \"border-top-style\" },\n\t{ name: \"borderRightStyle\", cssProperty: \"border-right-style\" },\n\t{ name: \"borderBottomStyle\", cssProperty: \"border-bottom-style\" },\n\t{ name: \"borderLeftStyle\", cssProperty: \"border-left-style\" },\n\t{ name: \"borderTopColor\", cssProperty: \"border-top-color\" },\n\t{ name: \"borderRightColor\", cssProperty: \"border-right-color\" },\n\t{ name: \"borderBottomColor\", cssProperty: \"border-bottom-color\" },\n\t{ name: \"borderLeftColor\", cssProperty: \"border-left-color\" },\n\t{ name: \"borderRadius\", cssProperty: \"border-radius\" },\n\t{ name: \"borderTopLeftRadius\", cssProperty: \"border-top-left-radius\" },\n\t{ name: \"borderTopRightRadius\", cssProperty: \"border-top-right-radius\" },\n\t{ name: \"borderBottomLeftRadius\", cssProperty: \"border-bottom-left-radius\" },\n\t{ name: \"borderBottomRightRadius\", cssProperty: \"border-bottom-right-radius\" },\n\n\t// Outline\n\t{ name: \"outline\", cssProperty: \"outline\" },\n\t{ name: \"outlineWidth\", cssProperty: \"outline-width\" },\n\t{ name: \"outlineStyle\", cssProperty: \"outline-style\" },\n\t{ name: \"outlineColor\", cssProperty: \"outline-color\" },\n\t{ name: \"outlineOffset\", cssProperty: \"outline-offset\" },\n\n\t// Background\n\t{ name: \"backgroundColor\", cssProperty: \"background-color\" },\n\t{ name: \"backgroundImage\", cssProperty: \"background-image\" },\n\t{ name: \"backgroundRepeat\", cssProperty: \"background-repeat\" },\n\t{ name: \"backgroundPosition\", cssProperty: \"background-position\" },\n\t{ name: \"backgroundSize\", cssProperty: \"background-size\" },\n\t{ name: \"backgroundAttachment\", cssProperty: \"background-attachment\" },\n\t{ name: \"backgroundClip\", cssProperty: \"background-clip\" },\n\t{ name: \"backgroundOrigin\", cssProperty: \"background-origin\" },\n\n\t// Effects\n\t{ name: \"boxShadow\", cssProperty: \"box-shadow\" },\n\t{ name: \"opacity\", cssProperty: \"opacity\" },\n\t{ name: \"transition\", cssProperty: \"transition\" },\n\t{ name: \"transitionProperty\", cssProperty: \"transition-property\" },\n\t{ name: \"transitionDuration\", cssProperty: \"transition-duration\" },\n\t{ name: \"transitionTimingFunction\", cssProperty: \"transition-timing-function\" },\n\t{ name: \"transitionDelay\", cssProperty: \"transition-delay\" },\n\n\t// Transform\n\t{ name: \"transform\", cssProperty: \"transform\" },\n\t{ name: \"transformOrigin\", cssProperty: \"transform-origin\" },\n\t{ name: \"transformStyle\", cssProperty: \"transform-style\" },\n\t{ name: \"perspective\", cssProperty: \"perspective\" },\n\t{ name: \"perspectiveOrigin\", cssProperty: \"perspective-origin\" },\n\t{ name: \"backfaceVisibility\", cssProperty: \"backface-visibility\" },\n\n\t// Animation\n\t{ name: \"animation\", cssProperty: \"animation\" },\n\t{ name: \"animationName\", cssProperty: \"animation-name\" },\n\t{ name: \"animationDuration\", cssProperty: \"animation-duration\" },\n\t{ name: \"animationTimingFunction\", cssProperty: \"animation-timing-function\" },\n\t{ name: \"animationDelay\", cssProperty: \"animation-delay\" },\n\t{ name: \"animationIterationCount\", cssProperty: \"animation-iteration-count\" },\n\t{ name: \"animationDirection\", cssProperty: \"animation-direction\" },\n\t{ name: \"animationFillMode\", cssProperty: \"animation-fill-mode\" },\n\t{ name: \"animationPlayState\", cssProperty: \"animation-play-state\" },\n\n\t// Filter\n\t{ name: \"filter\", cssProperty: \"filter\" },\n\t{ name: \"backdropFilter\", cssProperty: \"backdrop-filter\" },\n\n\t// Overflow\n\t{ name: \"overflow\", cssProperty: \"overflow\" },\n\t{ name: \"overflowX\", cssProperty: \"overflow-x\" },\n\t{ name: \"overflowY\", cssProperty: \"overflow-y\" },\n\n\t// Visibility\n\t{ name: \"visibility\", cssProperty: \"visibility\" },\n\n\t// Object fit/position\n\t{ name: \"objectFit\", cssProperty: \"object-fit\" },\n\t{ name: \"objectPosition\", cssProperty: \"object-position\" },\n\n\t// List\n\t{ name: \"listStyle\", cssProperty: \"list-style\" },\n\t{ name: \"listStyleType\", cssProperty: \"list-style-type\" },\n\t{ name: \"listStylePosition\", cssProperty: \"list-style-position\" },\n\t{ name: \"listStyleImage\", cssProperty: \"list-style-image\" },\n\n\t// Table\n\t{ name: \"borderCollapse\", cssProperty: \"border-collapse\" },\n\t{ name: \"borderSpacing\", cssProperty: \"border-spacing\" },\n\t{ name: \"captionSide\", cssProperty: \"caption-side\" },\n\t{ name: \"emptyCells\", cssProperty: \"empty-cells\" },\n\t{ name: \"tableLayout\", cssProperty: \"table-layout\" },\n\n\t// Content\n\t{ name: \"content\", cssProperty: \"content\" },\n\t{ name: \"quotes\", cssProperty: \"quotes\" },\n\t{ name: \"counterReset\", cssProperty: \"counter-reset\" },\n\t{ name: \"counterIncrement\", cssProperty: \"counter-increment\" },\n\n\t// User interface\n\t{ name: \"appearance\", cssProperty: \"appearance\" },\n\t{ name: \"userSelect\", cssProperty: \"user-select\" },\n\t{ name: \"pointerEvents\", cssProperty: \"pointer-events\" },\n\t{ name: \"resize\", cssProperty: \"resize\" },\n\t{ name: \"scrollBehavior\", cssProperty: \"scroll-behavior\" },\n\n\t// Clip\n\t{ name: \"clip\", cssProperty: \"clip\" },\n\t{ name: \"clipPath\", cssProperty: \"clip-path\" },\n\n\t// Isolation\n\t{ name: \"isolation\", cssProperty: \"isolation\" },\n\n\t// Mix blend mode\n\t{ name: \"mixBlendMode\", cssProperty: \"mix-blend-mode\" },\n\n\t// Will change\n\t{ name: \"willChange\", cssProperty: \"will-change\" },\n\n\t// Contain\n\t{ name: \"contain\", cssProperty: \"contain\" },\n\n\t// Page break\n\t{ name: \"pageBreakBefore\", cssProperty: \"page-break-before\" },\n\t{ name: \"pageBreakAfter\", cssProperty: \"page-break-after\" },\n\t{ name: \"pageBreakInside\", cssProperty: \"page-break-inside\" },\n\n\t// Break\n\t{ name: \"breakBefore\", cssProperty: \"break-before\" },\n\t{ name: \"breakAfter\", cssProperty: \"break-after\" },\n\t{ name: \"breakInside\", cssProperty: \"break-inside\" },\n\n\t// Orphans and widows\n\t{ name: \"orphans\", cssProperty: \"orphans\" },\n\t{ name: \"widows\", cssProperty: \"widows\" },\n\n\t// Column\n\t{ name: \"columnCount\", cssProperty: \"column-count\" },\n\t{ name: \"columnFill\", cssProperty: \"column-fill\" },\n\t{ name: \"columnGap\", cssProperty: \"column-gap\" },\n\t{ name: \"columnRule\", cssProperty: \"column-rule\" },\n\t{ name: \"columnRuleColor\", cssProperty: \"column-rule-color\" },\n\t{ name: \"columnRuleStyle\", cssProperty: \"column-rule-style\" },\n\t{ name: \"columnRuleWidth\", cssProperty: \"column-rule-width\" },\n\t{ name: \"columnSpan\", cssProperty: \"column-span\" },\n\t{ name: \"columnWidth\", cssProperty: \"column-width\" },\n\t{ name: \"columns\", cssProperty: \"columns\" },\n\n\t// Interaction\n\t{ name: \"cursor\", cssProperty: \"cursor\" },\n] as const;\n\n// Special methods that have custom logic beyond simple property setting\nexport const SPECIAL_METHODS = [\n\t\"bold\", // Sets font-weight: bold\n\t\"center\", // Sets justify-content: center and align-items: center\n\t\"flex\", // Can set display: flex OR flex property depending on argument\n] as const;\n","import { STYLE_PROPERTIES, SPECIAL_METHODS, type StylePropertyDefinition } from \"./styleProperties\";\n\n// Cache for generated classes: maps CSS property sets to class names\nconst styleCache = new Map<string, string>();\n\n// Simple hash function to generate a short hash from a string (similar to MD5 but simpler)\nfunction simpleHash(str: string): string {\n\tlet hash = 0;\n\tfor (let i = 0; i < str.length; i++) {\n\t\tconst char = str.charCodeAt(i);\n\t\thash = ((hash << 5) - hash) + char;\n\t\thash = hash & hash; // Convert to 32-bit integer\n\t}\n\t// Convert to positive hex string and take first 8 characters\n\treturn Math.abs(hash).toString(16).padStart(8, '0').substring(0, 8);\n}\n\n// Generate a cache key from a set of CSS properties\nfunction generateStyleKey(styles: Record<string, string>): string {\n\tconst sortedEntries = Object.entries(styles)\n\t\t.sort(([a], [b]) => a.localeCompare(b))\n\t\t.map(([property, value]) => `${property}:${value}`)\n\t\t.join('|');\n\treturn sortedEntries;\n}\n\n// Check if a class exists in the DOM\nfunction classExistsInDOM(className: string, mediaQuery?: string): boolean {\n\tconst styleSheet = document.querySelector(\"#nuclo-styles\") as HTMLStyleElement;\n\tif (!styleSheet || !styleSheet.sheet) {\n\t\treturn false;\n\t}\n\n\tif (mediaQuery) {\n\t\tconst rules = Array.from(styleSheet.sheet.cssRules || []);\n\t\tconst mediaRule = rules.find(rule => {\n\t\t\tif (rule instanceof CSSMediaRule) {\n\t\t\t\treturn rule.media.mediaText === mediaQuery;\n\t\t\t}\n\t\t\treturn false;\n\t\t}) as CSSMediaRule | undefined;\n\n\t\tif (!mediaRule) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn Array.from(mediaRule.cssRules).some(rule => {\n\t\t\tif (rule instanceof CSSStyleRule) {\n\t\t\t\treturn rule.selectorText === `.${className}`;\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\t} else {\n\t\tconst rules = Array.from(styleSheet.sheet.cssRules || []);\n\t\treturn rules.some(rule => {\n\t\t\tif (rule instanceof CSSStyleRule) {\n\t\t\t\treturn rule.selectorText === `.${className}`;\n\t\t\t}\n\t\t\treturn false;\n\t\t});\n\t}\n}\n\n// Get or create a class name for a set of CSS properties\nfunction getOrCreateClassName(styles: Record<string, string>, prefix = '', mediaQuery?: string): string {\n\tconst styleKey = generateStyleKey(styles);\n\tconst cacheKey = prefix ? `${prefix}:${styleKey}` : styleKey;\n\n\tif (styleCache.has(cacheKey)) {\n\t\tconst cachedClassName = styleCache.get(cacheKey)!;\n\t\t// Verify the class exists in the DOM, recreate if not (handles test isolation)\n\t\tif (!classExistsInDOM(cachedClassName, mediaQuery)) {\n\t\t\tcreateCSSClassWithStyles(cachedClassName, styles, mediaQuery);\n\t\t}\n\t\treturn cachedClassName;\n\t}\n\n\t// Generate a hash-based class name from the style key\n\tconst hash = simpleHash(styleKey);\n\tconst className = prefix ? `n${prefix}-${hash}` : `n${hash}`;\n\tstyleCache.set(cacheKey, className);\n\n\t// Create the CSS class with media query if provided\n\tcreateCSSClassWithStyles(className, styles, mediaQuery);\n\n\treturn className;\n}\n\n// Create a CSS class with multiple styles\nfunction createCSSClassWithStyles(\n\tclassName: string,\n\tstyles: Record<string, string>,\n\tmediaQuery?: string\n): void {\n\tlet styleSheet = document.querySelector(\"#nuclo-styles\") as HTMLStyleElement;\n\n\tif (!styleSheet) {\n\t\tstyleSheet = document.createElement(\"style\");\n\t\tstyleSheet.id = \"nuclo-styles\";\n\t\tdocument.head.appendChild(styleSheet);\n\t}\n\n\tconst rules = Object.entries(styles)\n\t\t.map(([property, value]) => `${property}: ${value}`)\n\t\t.join(\"; \");\n\n\tif (mediaQuery) {\n\t\t// Create or get media query rule\n\t\tconst existingRules = Array.from(styleSheet.sheet?.cssRules || []);\n\t\tlet mediaRule: CSSMediaRule | null = null;\n\n\t\tfor (const rule of existingRules) {\n\t\t\tif (rule instanceof CSSMediaRule && rule.media.mediaText === mediaQuery) {\n\t\t\t\tmediaRule = rule;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (!mediaRule) {\n\t\t\t// Find the correct insertion index: after all style rules, append media queries in order\n\t\t\t// Since we process breakpoints in registration order, we can simply append\n\t\t\t// This ensures: style rules first, then media queries in the order they're processed\n\t\t\tlet insertIndex = existingRules.length;\n\n\t\t\t// Find the last media query rule to insert after it (maintains order)\n\t\t\tfor (let i = existingRules.length - 1; i >= 0; i--) {\n\t\t\t\tif (existingRules[i] instanceof CSSMediaRule) {\n\t\t\t\t\tinsertIndex = i + 1;\n\t\t\t\t\tbreak;\n\t\t\t\t} else if (existingRules[i] instanceof CSSStyleRule) {\n\t\t\t\t\t// If we hit a style rule, insert after it\n\t\t\t\t\tinsertIndex = i + 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tstyleSheet.sheet?.insertRule(`@media ${mediaQuery} {}`, insertIndex);\n\t\t\tmediaRule = styleSheet.sheet?.cssRules[insertIndex] as CSSMediaRule;\n\t\t}\n\n\t\t// Check if class already exists in this media query\n\t\tlet existingRule: CSSStyleRule | null = null;\n\t\tfor (const rule of Array.from(mediaRule.cssRules)) {\n\t\t\tif (rule instanceof CSSStyleRule && rule.selectorText === `.${className}`) {\n\t\t\t\texistingRule = rule;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (existingRule) {\n\t\t\t// Update existing rule by replacing all styles\n\t\t\t// First, clear all existing properties\n\t\t\twhile (existingRule.style.length > 0) {\n\t\t\t\texistingRule.style.removeProperty(existingRule.style[0]);\n\t\t\t}\n\t\t\t// Then set all new properties\n\t\t\tObject.entries(styles).forEach(([property, value]) => {\n\t\t\t\texistingRule!.style.setProperty(property, value);\n\t\t\t});\n\t\t} else {\n\t\t\tmediaRule.insertRule(`.${className} { ${rules} }`, mediaRule.cssRules.length);\n\t\t}\n\t} else {\n\t\t// Regular style rule (no media query)\n\t\t// Find existing rule or insert at the beginning (before media queries)\n\t\tlet existingRule: CSSStyleRule | null = null;\n\t\tlet insertIndex = 0;\n\n\t\tconst allRules = Array.from(styleSheet.sheet?.cssRules || []);\n\t\tfor (let i = 0; i < allRules.length; i++) {\n\t\t\tconst rule = allRules[i];\n\t\t\tif (rule instanceof CSSStyleRule && rule.selectorText === `.${className}`) {\n\t\t\t\texistingRule = rule;\n\t\t\t\tinsertIndex = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t// Track where media queries start to insert default styles before them\n\t\t\tif (!(rule instanceof CSSMediaRule)) {\n\t\t\t\tinsertIndex = i + 1;\n\t\t\t}\n\t\t}\n\n\t\tif (existingRule) {\n\t\t\t// Update existing rule by replacing all styles\n\t\t\t// First, clear all existing properties\n\t\t\twhile (existingRule.style.length > 0) {\n\t\t\t\texistingRule.style.removeProperty(existingRule.style[0]);\n\t\t\t}\n\t\t\t// Then set all new properties\n\t\t\tObject.entries(styles).forEach(([property, value]) => {\n\t\t\t\texistingRule!.style.setProperty(property, value);\n\t\t\t});\n\t\t} else {\n\t\t\tstyleSheet.sheet?.insertRule(`.${className} { ${rules} }`, insertIndex);\n\t\t}\n\t}\n}\n\n// Utility class builder for chaining CSS properties\nexport class StyleBuilder {\n\tprivate styles: Record<string, string> = {};\n\n\t// Get the accumulated styles\n\tgetStyles(): Record<string, string> {\n\t\treturn { ...this.styles };\n\t}\n\n\t// Get class name for the current styles\n\tgetClassName(prefix = '', mediaQuery?: string): string {\n\t\treturn getOrCreateClassName(this.styles, prefix, mediaQuery);\n\t}\n\n\t// Get class names as space-separated string (for backward compatibility)\n\tgetClassNames(): string[] {\n\t\treturn [this.getClassName()];\n\t}\n\n\t// Get class definitions (for backward compatibility)\n\tgetClassDefinitions(): Array<{ className: string; property: string; value: string }> {\n\t\treturn Object.entries(this.styles).map(([property, value]) => ({\n\t\t\tclassName: this.getClassName(),\n\t\t\tproperty,\n\t\t\tvalue\n\t\t}));\n\t}\n\n\t// Get class names as space-separated string\n\ttoString(): string {\n\t\treturn this.getClassName();\n\t}\n\n\t// Add a custom style\n\tadd(property: string, value: string): this {\n\t\tthis.styles[property] = value;\n\t\treturn this;\n\t}\n\n\t// Special methods with custom logic\n\tbold(): this {\n\t\tthis.styles[\"font-weight\"] = \"bold\";\n\t\treturn this;\n\t}\n\n\tcenter(): this {\n\t\tthis.styles[\"justify-content\"] = \"center\";\n\t\tthis.styles[\"align-items\"] = \"center\";\n\t\treturn this;\n\t}\n\n\tflex(value?: string): this {\n\t\tif (value !== undefined) {\n\t\t\tthis.styles[\"flex\"] = value;\n\t\t} else {\n\t\t\tthis.styles[\"display\"] = \"flex\";\n\t\t}\n\t\treturn this;\n\t}\n}\n\n// TypeScript interface declaration merging - adds types for dynamically generated methods\nexport interface StyleBuilder {\n\tdisplay(value: string): this;\n\tgrid(): this;\n\tbg(color: string): this;\n\tcolor(colorValue: string): this;\n\taccentColor(value: string): this;\n\tfontSize(size: string): this;\n\tfontWeight(value: string): this;\n\tfontFamily(value: string): this;\n\tlineHeight(value: string): this;\n\tletterSpacing(value: string): this;\n\ttextAlign(value: string): this;\n\ttextDecoration(value: string): this;\n\tfontStyle(value: string): this;\n\tfontVariant(value: string): this;\n\tfontStretch(value: string): this;\n\ttextTransform(value: string): this;\n\ttextIndent(value: string): this;\n\ttextOverflow(value: string): this;\n\ttextShadow(value: string): this;\n\twhiteSpace(value: string): this;\n\twordSpacing(value: string): this;\n\twordWrap(value: string): this;\n\toverflowWrap(value: string): this;\n\ttextAlignLast(value: string): this;\n\ttextJustify(value: string): this;\n\ttextDecorationLine(value: string): this;\n\ttextDecorationColor(value: string): this;\n\ttextDecorationStyle(value: string): this;\n\ttextDecorationThickness(value: string): this;\n\ttextUnderlineOffset(value: string): this;\n\tverticalAlign(value: string): this;\n\tposition(value: string): this;\n\tpadding(value: string): this;\n\tpaddingTop(value: string): this;\n\tpaddingRight(value: string): this;\n\tpaddingBottom(value: string): this;\n\tpaddingLeft(value: string): this;\n\tmargin(value: string): this;\n\tmarginTop(value: string): this;\n\tmarginRight(value: string): this;\n\tmarginBottom(value: string): this;\n\tmarginLeft(value: string): this;\n\twidth(value: string): this;\n\theight(value: string): this;\n\tminWidth(value: string): this;\n\tmaxWidth(value: string): this;\n\tminHeight(value: string): this;\n\tmaxHeight(value: string): this;\n\tboxSizing(value: string): this;\n\ttop(value: string): this;\n\tright(value: string): this;\n\tbottom(value: string): this;\n\tleft(value: string): this;\n\tzIndex(value: string): this;\n\tflexDirection(value: string): this;\n\talignItems(value: string): this;\n\tjustifyContent(value: string): this;\n\tgap(value: string): this;\n\tflexWrap(value: string): this;\n\tflexGrow(value: string): this;\n\tflexShrink(value: string): this;\n\tflexBasis(value: string): this;\n\talignSelf(value: string): this;\n\talignContent(value: string): this;\n\tjustifySelf(value: string): this;\n\tjustifyItems(value: string): this;\n\tgridTemplateColumns(value: string): this;\n\tgridTemplateRows(value: string): this;\n\tgridTemplateAreas(value: string): this;\n\tgridColumn(value: string): this;\n\tgridRow(value: string): this;\n\tgridColumnStart(value: string): this;\n\tgridColumnEnd(value: string): this;\n\tgridRowStart(value: string): this;\n\tgridRowEnd(value: string): this;\n\tgridArea(value: string): this;\n\tgridAutoColumns(value: string): this;\n\tgridAutoRows(value: string): this;\n\tgridAutoFlow(value: string): this;\n\tborder(value: string): this;\n\tborderTop(value: string): this;\n\tborderRight(value: string): this;\n\tborderBottom(value: string): this;\n\tborderLeft(value: string): this;\n\tborderWidth(value: string): this;\n\tborderStyle(value: string): this;\n\tborderColor(value: string): this;\n\tborderTopWidth(value: string): this;\n\tborderRightWidth(value: string): this;\n\tborderBottomWidth(value: string): this;\n\tborderLeftWidth(value: string): this;\n\tborderTopStyle(value: string): this;\n\tborderRightStyle(value: string): this;\n\tborderBottomStyle(value: string): this;\n\tborderLeftStyle(value: string): this;\n\tborderTopColor(value: string): this;\n\tborderRightColor(value: string): this;\n\tborderBottomColor(value: string): this;\n\tborderLeftColor(value: string): this;\n\tborderRadius(value: string): this;\n\tborderTopLeftRadius(value: string): this;\n\tborderTopRightRadius(value: string): this;\n\tborderBottomLeftRadius(value: string): this;\n\tborderBottomRightRadius(value: string): this;\n\toutline(value: string): this;\n\toutlineWidth(value: string): this;\n\toutlineStyle(value: string): this;\n\toutlineColor(value: string): this;\n\toutlineOffset(value: string): this;\n\tbackgroundColor(value: string): this;\n\tbackgroundImage(value: string): this;\n\tbackgroundRepeat(value: string): this;\n\tbackgroundPosition(value: string): this;\n\tbackgroundSize(value: string): this;\n\tbackgroundAttachment(value: string): this;\n\tbackgroundClip(value: string): this;\n\tbackgroundOrigin(value: string): this;\n\tboxShadow(value: string): this;\n\topacity(value: string): this;\n\ttransition(value: string): this;\n\ttransitionProperty(value: string): this;\n\ttransitionDuration(value: string): this;\n\ttransitionTimingFunction(value: string): this;\n\ttransitionDelay(value: string): this;\n\ttransform(value: string): this;\n\ttransformOrigin(value: string): this;\n\ttransformStyle(value: string): this;\n\tperspective(value: string): this;\n\tperspectiveOrigin(value: string): this;\n\tbackfaceVisibility(value: string): this;\n\tanimation(value: string): this;\n\tanimationName(value: string): this;\n\tanimationDuration(value: string): this;\n\tanimationTimingFunction(value: string): this;\n\tanimationDelay(value: string): this;\n\tanimationIterationCount(value: string): this;\n\tanimationDirection(value: string): this;\n\tanimationFillMode(value: string): this;\n\tanimationPlayState(value: string): this;\n\tfilter(value: string): this;\n\tbackdropFilter(value: string): this;\n\toverflow(value: string): this;\n\toverflowX(value: string): this;\n\toverflowY(value: string): this;\n\tvisibility(value: string): this;\n\tobjectFit(value: string): this;\n\tobjectPosition(value: string): this;\n\tlistStyle(value: string): this;\n\tlistStyleType(value: string): this;\n\tlistStylePosition(value: string): this;\n\tlistStyleImage(value: string): this;\n\tborderCollapse(value: string): this;\n\tborderSpacing(value: string): this;\n\tcaptionSide(value: string): this;\n\temptyCells(value: string): this;\n\ttableLayout(value: string): this;\n\tcontent(value: string): this;\n\tquotes(value: string): this;\n\tcounterReset(value: string): this;\n\tcounterIncrement(value: string): this;\n\tappearance(value: string): this;\n\tuserSelect(value: string): this;\n\tpointerEvents(value: string): this;\n\tresize(value: string): this;\n\tscrollBehavior(value: string): this;\n\tclip(value: string): this;\n\tclipPath(value: string): this;\n\tisolation(value: string): this;\n\tmixBlendMode(value: string): this;\n\twillChange(value: string): this;\n\tcontain(value: string): this;\n\tpageBreakBefore(value: string): this;\n\tpageBreakAfter(value: string): this;\n\tpageBreakInside(value: string): this;\n\tbreakBefore(value: string): this;\n\tbreakAfter(value: string): this;\n\tbreakInside(value: string): this;\n\torphans(value: string): this;\n\twidows(value: string): this;\n\tcolumnCount(value: string): this;\n\tcolumnFill(value: string): this;\n\tcolumnGap(value: string): this;\n\tcolumnRule(value: string): this;\n\tcolumnRuleColor(value: string): this;\n\tcolumnRuleStyle(value: string): this;\n\tcolumnRuleWidth(value: string): this;\n\tcolumnSpan(value: string): this;\n\tcolumnWidth(value: string): this;\n\tcolumns(value: string): this;\n\tcursor(value: string): this;\n}\n\n// Dynamically add methods to StyleBuilder prototype\nfunction registerStyleMethods(): void {\n\tconst proto = StyleBuilder.prototype as unknown as Record<string, unknown>;\n\n\tfor (const prop of STYLE_PROPERTIES) {\n\t\t// Skip if method already exists (e.g., special methods)\n\t\tif (prop.name in proto) continue;\n\n\t\tif (prop.isShorthand) {\n\t\t\t// Shorthand methods that use default values\n\t\t\tproto[prop.name] = function(this: StyleBuilder) {\n\t\t\t\tthis.add(prop.cssProperty, prop.defaultValue || \"\");\n\t\t\t\treturn this;\n\t\t\t};\n\t\t} else {\n\t\t\t// Regular methods that take a value\n\t\t\tproto[prop.name] = function(this: StyleBuilder, value: string) {\n\t\t\t\tthis.add(prop.cssProperty, value);\n\t\t\t\treturn this;\n\t\t\t};\n\t\t}\n\t}\n}\n\n// Register all methods on StyleBuilder\nregisterStyleMethods();\n\n// Breakpoints type\ntype BreakpointStyles<T extends string> = Partial<Record<T, StyleBuilder>>;\n\n// Create breakpoints function\n// Accepts either Record (for backward compatibility) or Array of [name, mediaQuery] tuples (for explicit order)\nexport function createBreakpoints<T extends string>(\n\tbreakpoints: Record<T, string> | Array<[T, string]>\n) {\n\t// Convert to array format to preserve order\n\tconst breakpointsArray: Array<[T, string]> = Array.isArray(breakpoints)\n\t\t? breakpoints\n\t\t: (Object.entries(breakpoints) as Array<[T, string]>);\n\n\treturn function cn(\n\t\tdefaultStylesOrBreakpoints?: StyleBuilder | BreakpointStyles<T>,\n\t\tbreakpointStyles?: BreakpointStyles<T>\n\t): { className: string } | string {\n\t\tlet defaultStyles: StyleBuilder | undefined;\n\t\tlet styles: BreakpointStyles<T> | undefined;\n\n\t\t// Handle both signatures:\n\t\t// 1. cn({ medium: width(\"50%\") }) - single argument with breakpoints\n\t\t// 2. cn(width(\"100%\"), { medium: width(\"50%\") }) - default styles + breakpoints\n\t\tif (breakpointStyles !== undefined) {\n\t\t\t// Two-argument form\n\t\t\tdefaultStyles = defaultStylesOrBreakpoints as StyleBuilder;\n\t\t\tstyles = breakpointStyles;\n\t\t} else if (defaultStylesOrBreakpoints instanceof StyleBuilder) {\n\t\t\t// Single argument, but it's a StyleBuilder (default styles only)\n\t\t\tdefaultStyles = defaultStylesOrBreakpoints;\n\t\t\tstyles = undefined;\n\t\t} else {\n\t\t\t// Single argument with breakpoints\n\t\t\tdefaultStyles = undefined;\n\t\t\tstyles = defaultStylesOrBreakpoints as BreakpointStyles<T>;\n\t\t}\n\n\t\t// If nothing provided, return empty\n\t\tif (!defaultStyles && (!styles || Object.keys(styles).length === 0)) {\n\t\t\treturn \"\";\n\t\t}\n\n\t\t// If we have breakpoints, create a single class name for all breakpoints\n\t\tif (styles && Object.keys(styles).length > 0) {\n\t\t\t// Collect all breakpoint styles in registration order\n\t\t\tconst allBreakpointStyles: Array<{ breakpointName: T; mediaQuery: string; styles: Record<string, string> }> = [];\n\n\t\t\t// Process breakpoints in the order they were registered\n\t\t\tfor (const [breakpointName, mediaQuery] of breakpointsArray) {\n\t\t\t\tconst styleBuilder = styles[breakpointName];\n\t\t\t\tif (styleBuilder) {\n\t\t\t\t\tallBreakpointStyles.push({\n\t\t\t\t\t\tbreakpointName,\n\t\t\t\t\t\tmediaQuery,\n\t\t\t\t\t\tstyles: (styleBuilder as StyleBuilder).getStyles()\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Generate a combined hash from all breakpoint styles (and default styles if present)\n\t\t\tconst allStyleKeys: string[] = [];\n\n\t\t\tif (defaultStyles) {\n\t\t\t\tconst defaultStylesObj = defaultStyles.getStyles();\n\t\t\t\tallStyleKeys.push(`default:${generateStyleKey(defaultStylesObj)}`);\n\t\t\t}\n\n\t\t\tallStyleKeys.push(...allBreakpointStyles.map(({ breakpointName, styles: bpStyles }) => {\n\t\t\t\tconst styleKey = generateStyleKey(bpStyles);\n\t\t\t\treturn `${breakpointName}:${styleKey}`;\n\t\t\t}));\n\n\t\t\tconst combinedStyleKey = allStyleKeys.sort().join('||');\n\t\t\tconst combinedHash = simpleHash(combinedStyleKey);\n\t\t\tconst className = `n${combinedHash}`;\n\n\t\t\t// Apply default styles first (no media query) - these are base styles\n\t\t\tlet accumulatedStyles: Record<string, string> = {};\n\t\t\tif (defaultStyles) {\n\t\t\t\taccumulatedStyles = { ...defaultStyles.getStyles() };\n\t\t\t\tcreateCSSClassWithStyles(className, accumulatedStyles);\n\t\t\t}\n\n\t\t\t// Apply all breakpoint styles to the same class name in their respective media queries\n\t\t\t// Apply in registration order to ensure proper CSS cascade\n\t\t\t// Each breakpoint inherits from all previous breakpoints (cascading)\n\t\t\tfor (const { breakpointName, mediaQuery, styles: bpStyles } of allBreakpointStyles) {\n\t\t\t\t// Merge accumulated styles (defaults + previous breakpoints) with current breakpoint\n\t\t\t\t// This ensures each breakpoint inherits from previous ones\n\t\t\t\taccumulatedStyles = { ...accumulatedStyles, ...bpStyles };\n\t\t\t\tcreateCSSClassWithStyles(className, accumulatedStyles, mediaQuery);\n\t\t\t}\n\n\t\t\treturn { className };\n\t\t}\n\n\t\t// Only default styles (no breakpoints)\n\t\tif (defaultStyles) {\n\t\t\tconst className = defaultStyles.getClassName();\n\t\t\treturn { className };\n\t\t}\n\n\t\treturn \"\";\n\t};\n}\n\n// Legacy function for backward compatibility\nexport function createCSSClass(className: string, styles: Record<string, string>): void {\n\tcreateCSSClassWithStyles(className, styles);\n}\n\n// Dynamically create and export utility functions\nfunction createStyleFunction(prop: StylePropertyDefinition): (value?: string) => StyleBuilder {\n\tif (prop.isShorthand) {\n\t\treturn () => new StyleBuilder().add(prop.cssProperty, prop.defaultValue || \"\");\n\t} else {\n\t\treturn (value?: string) => new StyleBuilder().add(prop.cssProperty, value || \"\");\n\t}\n}\n\n// Create export object dynamically\nconst styleExports: Record<string, ((value?: string) => StyleBuilder)> = {};\n\n// Add regular properties\nfor (const prop of STYLE_PROPERTIES) {\n\tstyleExports[prop.name] = createStyleFunction(prop);\n}\n\n// Add special methods\nfor (const method of SPECIAL_METHODS) {\n\tif (method === \"bold\" || method === \"center\") {\n\t\tstyleExports[method] = () => new StyleBuilder()[method]();\n\t} else if (method === \"flex\") {\n\t\tstyleExports[method] = (value?: string) => new StyleBuilder().flex(value);\n\t}\n}\n\n// Export all style functions\nexport const {\n\t// Display\n\tdisplay, flex, grid,\n\t// Colors\n\tbg, color, accentColor,\n\t// Typography\n\tfontSize, fontWeight, fontFamily, lineHeight, letterSpacing,\n\ttextAlign, textDecoration, bold, fontStyle, fontVariant,\n\tfontStretch, textTransform, textIndent, textOverflow, textShadow,\n\twhiteSpace, wordSpacing, wordWrap, overflowWrap, textAlignLast,\n\ttextJustify, textDecorationLine, textDecorationColor, textDecorationStyle,\n\ttextDecorationThickness, textUnderlineOffset, verticalAlign,\n\t// Layout\n\tposition, padding, paddingTop, paddingRight, paddingBottom, paddingLeft,\n\tmargin, marginTop, marginRight, marginBottom, marginLeft,\n\twidth, height, minWidth, maxWidth, minHeight, maxHeight, boxSizing,\n\t// Positioning\n\ttop, right, bottom, left, zIndex,\n\t// Flexbox\n\tflexDirection, alignItems, justifyContent, center, gap,\n\tflexWrap, flexGrow, flexShrink, flexBasis, alignSelf,\n\talignContent, justifySelf, justifyItems,\n\t// Grid\n\tgridTemplateColumns, gridTemplateRows, gridTemplateAreas,\n\tgridColumn, gridRow, gridColumnStart, gridColumnEnd,\n\tgridRowStart, gridRowEnd, gridArea, gridAutoColumns,\n\tgridAutoRows, gridAutoFlow,\n\t// Borders\n\tborder, borderTop, borderRight, borderBottom, borderLeft,\n\tborderWidth, borderStyle, borderColor, borderTopWidth,\n\tborderRightWidth, borderBottomWidth, borderLeftWidth,\n\tborderTopStyle, borderRightStyle, borderBottomStyle, borderLeftStyle,\n\tborderTopColor, borderRightColor, borderBottomColor, borderLeftColor,\n\tborderRadius, borderTopLeftRadius, borderTopRightRadius,\n\tborderBottomLeftRadius, borderBottomRightRadius,\n\t// Outline\n\toutline, outlineWidth, outlineStyle, outlineColor, outlineOffset,\n\t// Background\n\tbackgroundColor, backgroundImage, backgroundRepeat, backgroundPosition,\n\tbackgroundSize, backgroundAttachment, backgroundClip, backgroundOrigin,\n\t// Effects\n\tboxShadow, opacity, transition, transitionProperty,\n\ttransitionDuration, transitionTimingFunction, transitionDelay,\n\t// Transform\n\ttransform, transformOrigin, transformStyle, perspective,\n\tperspectiveOrigin, backfaceVisibility,\n\t// Animation\n\tanimation, animationName, animationDuration, animationTimingFunction,\n\tanimationDelay, animationIterationCount, animationDirection,\n\tanimationFillMode, animationPlayState,\n\t// Filter\n\tfilter, backdropFilter,\n\t// Overflow\n\toverflow, overflowX, overflowY,\n\t// Visibility\n\tvisibility,\n\t// Object fit/position\n\tobjectFit, objectPosition,\n\t// List\n\tlistStyle, listStyleType, listStylePosition, listStyleImage,\n\t// Table\n\tborderCollapse, borderSpacing, captionSide, emptyCells, tableLayout,\n\t// Content\n\tcontent, quotes, counterReset, counterIncrement,\n\t// User interface\n\tappearance, userSelect, pointerEvents, resize, scrollBehavior,\n\t// Clip\n\tclip, clipPath,\n\t// Isolation\n\tisolation,\n\t// Mix blend mode\n\tmixBlendMode,\n\t// Will change\n\twillChange,\n\t// Contain\n\tcontain,\n\t// Page break\n\tpageBreakBefore, pageBreakAfter, pageBreakInside,\n\t// Break\n\tbreakBefore, breakAfter, breakInside,\n\t// Orphans and widows\n\torphans, widows,\n\t// Column\n\tcolumnCount, columnFill, columnGap, columnRule,\n\tcolumnRuleColor, columnRuleStyle, columnRuleWidth,\n\tcolumnSpan, columnWidth, columns,\n\t// Interaction\n\tcursor,\n} = styleExports as Record<string, (value?: string) => StyleBuilder>;\n","import { registerGlobalTagBuilders } from \"./tagRegistry\";\nimport { list } from \"../list\";\nimport { update } from \"./updateController\";\nimport { when } from \"../when\";\nimport { on } from \"../utility/on\";\nimport { render } from \"../utility/render\";\nimport * as styleExports from \"../style\";\n\n/**\n * Initializes the nuclo runtime by exposing tag builders and utilities.\n */\nexport function initializeRuntime(): void {\n registerGlobalTagBuilders();\n\n if (typeof globalThis !== \"undefined\") {\n const registry = globalThis as Record<string, unknown>;\n registry.list = list;\n registry.update = update;\n registry.when = when;\n registry.on = on;\n registry.render = render;\n\n // Register all style utilities globally\n // Use individual assignments to avoid errors with readonly properties (like window.top)\n for (const [key, value] of Object.entries(styleExports)) {\n try {\n registry[key] = value;\n } catch (e) {\n // Skip properties that can't be set (e.g., readonly window properties)\n }\n }\n }\n}\n\nif (typeof globalThis !== \"undefined\") {\n initializeRuntime();\n}\n"],"names":["isPrimitive","value","isNode","Node","isObject","isTagLike","isFunction","isZeroArityFunction","length","logError","message","error","console","safeExecute","fn","fallback","isBrowser","window","document","safeRemoveChild","child","parentNode","removeChild","createCommentSafely","text","createComment","createConditionalComment","tagName","suffix","createMarkerComment","prefix","Error","comment","Math","random","toString","slice","createMarkerPair","endComment","start","end","insertNodesBefore","nodes","referenceNode","parent","forEach","node","newNode","insertBefore","safeInsertBefore","isNodeConnected","isConnected","contains","replaceNodeSafely","oldNode","replaceChild","reactiveTextNodes","Map","reactiveElements","applyAttributeResolvers","el","info","attributeResolvers","resolver","applyValue","key","e","registerAttributeResolver","element","Element","get","set","ensureElementInfo","updateListener","listener","addEventListener","setStyleProperty","property","style","stringValue","String","assignInlineStyles","styles","Object","entries","applySingleAttribute","raw","shouldMergeClassName","styleValue","resolvedStyles","setValue","v","merge","HTMLElement","newClassName","currentClassName","className","existing","Set","split","filter","c","add","Array","from","join","namespaceURI","setAttribute","applyAttributes","attributes","mergeClassName","k","keys","modifierProbeCache","WeakMap","isBooleanFunction","cached","record","undefined","probeOnce","isConditionalModifier","modifier","allModifiers","currentIndex","otherModifiers","_","index","some","mod","applyNodeModifier","createReactiveTextFragment","produced","createStaticTextFragment","candidate","preEvaluated","fragment","createDocumentFragment","appendChild","textNode","createTextNode","initial","arguments","str","txt","lastValue","createReactiveTextNode","activeConditionalNodes","storeConditionalInfo","_conditionalInfo","applyModifiers","modifiers","startIndex","nextIndex","appended","localIndex","i","createElementWithModifiers","createElement","processConditionalModifiers","conditionalIndex","findConditionalModifier","condition","createElementWithNamespace","SVG_TAGS","includes","isSVGTag","createElementNS","createElementFactory","passed","conditionalInfo","createConditionalElement","createTagBuilder","mods","HTML_TAGS","registerGlobalTagBuilders","target","globalThis","marker","exportName","registerSvgTag","registerHtmlTag","activeListRuntimes","renderItem","runtime","item","result","host","resolveRenderable","remove","sync","startMarker","endMarker","currentItems","itemsProvider","a","b","arraysEqual","lastSyncedItems","recordsByPosition","availableRecords","records","items","push","newIndex","existingRecord","recordIndex","indexOf","splice","delete","newRecords","elementsToRemove","nextSibling","availableItems","shift","unshift","recordNode","list","render","createListRuntime","runCondition","onError","resolveCondition","Boolean","activeWhenRuntimes","renderContentItem","callback","originalAppend","bind","originalInsert","withScopedInsertion","maybeNode","renderWhenContent","groups","elseContent","newActive","evaluateActiveCondition","activeIndex","current","next","clearBetweenMarkers","renderContentItems","content","WhenBuilderImpl","constructor","initialCondition","this","when","update","createWhenBuilderFunction","builder","assign","else","updateConditionalNode","getConditionalInfo","shouldShow","isElement","nodeType","ELEMENT_NODE","createElementFromConditionalInfo","updaters","unregisterConditionalNode","removeEventListener","newVal","textContent","targets","body","dispatchEvent","Event","bubbles","on","type","options","ev","call","nodeModFn","STYLE_PROPERTIES","name","cssProperty","defaultValue","isShorthand","SPECIAL_METHODS","styleCache","simpleHash","hash","charCodeAt","abs","padStart","substring","generateStyleKey","sort","localeCompare","map","getOrCreateClassName","mediaQuery","styleKey","cacheKey","has","cachedClassName","styleSheet","querySelector","sheet","mediaRule","cssRules","find","rule","CSSMediaRule","media","mediaText","CSSStyleRule","selectorText","classExistsInDOM","createCSSClassWithStyles","id","head","rules","existingRules","insertIndex","insertRule","existingRule","removeProperty","setProperty","allRules","StyleBuilder","getStyles","getClassName","getClassNames","getClassDefinitions","bold","center","flex","createBreakpoints","breakpoints","breakpointsArray","isArray","defaultStylesOrBreakpoints","breakpointStyles","defaultStyles","allBreakpointStyles","breakpointName","styleBuilder","allStyleKeys","defaultStylesObj","bpStyles","accumulatedStyles","createCSSClass","createStyleFunction","prop","proto","prototype","registerStyleMethods","styleExports","method","display","grid","bg","color","accentColor","fontSize","fontWeight","fontFamily","lineHeight","letterSpacing","textAlign","textDecoration","fontStyle","fontVariant","fontStretch","textTransform","textIndent","textOverflow","textShadow","whiteSpace","wordSpacing","wordWrap","overflowWrap","textAlignLast","textJustify","textDecorationLine","textDecorationColor","textDecorationStyle","textDecorationThickness","textUnderlineOffset","verticalAlign","position","padding","paddingTop","paddingRight","paddingBottom","paddingLeft","margin","marginTop","marginRight","marginBottom","marginLeft","width","height","minWidth","maxWidth","minHeight","maxHeight","boxSizing","top","right","bottom","left","zIndex","flexDirection","alignItems","justifyContent","gap","flexWrap","flexGrow","flexShrink","flexBasis","alignSelf","alignContent","justifySelf","justifyItems","gridTemplateColumns","gridTemplateRows","gridTemplateAreas","gridColumn","gridRow","gridColumnStart","gridColumnEnd","gridRowStart","gridRowEnd","gridArea","gridAutoColumns","gridAutoRows","gridAutoFlow","border","borderTop","borderRight","borderBottom","borderLeft","borderWidth","borderStyle","borderColor","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderTopStyle","borderRightStyle","borderBottomStyle","borderLeftStyle","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","borderRadius","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","outline","outlineWidth","outlineStyle","outlineColor","outlineOffset","backgroundColor","backgroundImage","backgroundRepeat","backgroundPosition","backgroundSize","backgroundAttachment","backgroundClip","backgroundOrigin","boxShadow","opacity","transition","transitionProperty","transitionDuration","transitionTimingFunction","transitionDelay","transform","transformOrigin","transformStyle","perspective","perspectiveOrigin","backfaceVisibility","animation","animationName","animationDuration","animationTimingFunction","animationDelay","animationIterationCount","animationDirection","animationFillMode","animationPlayState","backdropFilter","overflow","overflowX","overflowY","visibility","objectFit","objectPosition","listStyle","listStyleType","listStylePosition","listStyleImage","borderCollapse","borderSpacing","captionSide","emptyCells","tableLayout","quotes","counterReset","counterIncrement","appearance","userSelect","pointerEvents","resize","scrollBehavior","clip","clipPath","isolation","mixBlendMode","willChange","contain","pageBreakBefore","pageBreakAfter","pageBreakInside","breakBefore","breakAfter","breakInside","orphans","widows","columnCount","columnFill","columnGap","columnRule","columnRuleColor","columnRuleStyle","columnRuleWidth","columnSpan","columnWidth","columns","cursor","initializeRuntime","registry","children","nodeToAppend","createTextNodeSafely","safeAppendChild"],"mappings":"aAAM,SAAUA,EAAYC,GAC1B,OAAiB,OAAVA,GAAoC,iBAAVA,GAAuC,mBAAVA,CAChE,CAEM,SAAUC,EAAUD,GACxB,OAAOA,aAAiBE,IAC1B,CAEM,SAAUC,EAASH,GACvB,MAAwB,iBAAVA,GAAgC,OAAVA,CACtC,CAEM,SAAUI,EAAaJ,GAC3B,OAAOG,EAASH,IAAU,YAAcA,CAC1C,CAMM,SAAUK,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