{"version":3,"sources":["render.ts"],"sourcesContent":["import { Datex } from \"datex-core-legacy\";\nimport { OPEN_GRAPH, OpenGraphInformation } from \"../base/open-graph.ts\";\nimport { indent } from \"datex-core-legacy/utils/indent.ts\";\nimport type { HTMLProvider } from \"../providers/html.ts\";\nimport { COMPONENT_CONTEXT, STANDALONE } from \"../standalone/bound_content_properties.ts\";\nimport { app } from \"../app/app.ts\";\nimport { client_type } from \"datex-core-legacy/utils/constants.ts\";\nimport { bindToOrigin, getValueUpdater } from \"../app/datex-over-http.ts\";\nimport { RenderMethod } from \"../base/render-methods.ts\";\nimport { logger } from \"../utils/global-values.ts\";\nimport { domContext, domUtils } from \"../app/dom-context.ts\";\nimport { DOMUtils } from \"../uix-dom/datex-bindings/dom-utils.ts\";\nimport { JSTransferableFunction } from \"datex-core-legacy/types/js-function.ts\";\nimport { convertToWebPath } from \"../app/convert-to-web-path.ts\";\nimport { UIX } from \"../../uix.ts\";\nimport { serializeJSValue } from \"../utils/serialize-js.ts\";\nimport { Component } from \"../components/Component.ts\";\nimport { DX_VALUE } from \"datex-core-legacy/runtime/constants.ts\";\nimport { resolveDependencies } from \"./dependency-resolver.ts\"\nimport { RawHTML } from \"./unsafe-html.ts\";\n\nlet stage:string|undefined = '?'\n\nif (client_type === \"deno\") {\n\t({ stage } = (await import(\"../app/args.ts\" /*lazy*/)))\n}\n\ntype injectScriptData = {declare:Record<string,string>, init:string[]};\n\ntype _renderOptions = {\n\tincludeShadowRoots?:boolean, \n\tinjectStandaloneComponents?: boolean, \n\tforms?:string[], datex_update_type?:string[], \n\t_injectedJsData?:injectScriptData, \n\textractedData?: extractedData,\n\tlang?:string, \n\tallowIgnoreDatexFunctions?: boolean,\n\trequiredPointers?: Set<any>,\n\tplainHTML?: boolean, // if true, only plain html is returned, attributes like uix-ptr are not rendered\n\teditMode?: boolean, // if true, editable content is enabled for editable elements\n\tforceParentLive?: boolean // set by child nodes to indicate parent should be marked as hydratable\n}\n\nexport type extractedData = {\n\ttitle?: string,\n\topenGraph?: OpenGraphInformation,\n}\n\nexport const CACHED_CONTENT = Symbol(\"CACHED_CONTENT\");\n\nconst selfClosingTags = new Set([\n\t\"area\",\n\t\"base\",\n\t\"br\",\n\t\"col\",\n\t\"embed\",\n\t\"hr\",\n\t\"img\",\n\t\"input\",\n\t\"link\",\n\t\"meta\",\n\t\"param\",\n\t\"source\",\n\t\"track\",\n\t\"wbr\"\n])\n\n\nfunction loadStandaloneJS(el:(Element|ShadowRoot) & {standaloneEnabled?:()=>boolean}, opts?:_renderOptions){\n\t// is UIX component with standalone methods?\n\tif (opts?._injectedJsData && opts?.injectStandaloneComponents && el.standaloneEnabled?.()) {\n\t\t// add all class declarations\n\t\tloadClassDeclarations(<any>el.constructor, opts._injectedJsData);\n\t\t// add init script for instance\n\t\tloadInitScript(el, opts._injectedJsData);\n\t}\n}\n\nfunction loadClassDeclarations(componentClass: (typeof Element| typeof ShadowRoot) & {getParentClass?:()=>typeof HTMLElement|null, getStandalonePseudoClass?:()=>string}, _injectedJsData:injectScriptData) {\n\t// no valid component\n\tif (!componentClass.getStandalonePseudoClass || !componentClass.getParentClass) return;\n\t\n\t// add parent class?\n\tconst parent_class = componentClass.getParentClass()\n\tif (parent_class) loadClassDeclarations(<any>parent_class, _injectedJsData);\n\n\tconst name = componentClass.name;\n\tif (!_injectedJsData.declare[name]) {\n\t\t_injectedJsData.declare[name] = componentClass.getStandalonePseudoClass();\n\t}\n}\n\nfunction loadInitScript(component:(Element|ShadowRoot) & {getStandaloneInit?:()=>string}, _injectedJsData:injectScriptData) {\n\tif (component.getStandaloneInit) {\n\t\t_injectedJsData.init.push(component.getStandaloneInit());\n\t}\n}\n\nexport function getInnerHTML(el:Element|ShadowRoot, opts?:_renderOptions, collectedStylesheets?:string[], standaloneContext = false) {\n\tif (!opts?.includeShadowRoots && !opts?.plainHTML) return el.innerHTML;\n\n\tlet html = \"\";\n\n\t// load js (into opts._injectedJsData) if UIX component with standalone methods\n\tloadStandaloneJS(el, opts);\n\n\t// add shadow root\n\tif (el instanceof domContext.Element && el.shadowRoot) {\n\t\thtml += `<template shadowrootmode=\"${el.shadowRoot.mode??\"open\"}\">`\n\t\t// collect stylsheets that children require\n\t\tconst collectedStylesheets:string[] = []\n\t\thtml += getInnerHTML(el.shadowRoot, opts, collectedStylesheets, standaloneContext);\n\t\tfor (const link of collectedStylesheets) html += `<link rel=\"stylesheet\" href=\"${convertToWebPath(link)}\">\\n`;\n\t\t// @ts-ignore\n\t\tif (el.getRenderedStyle) html += el.getRenderedStyle();\n\t\thtml += '</template>'\n\t}\n\n\telse {\n\t\t// @ts-ignore\n\t\tif (el.style_sheets_urls && collectedStylesheets) collectedStylesheets.push(...el.style_sheets_urls)\n\t\t// @ts-ignore\n\t\tif (el.activatedScopedStyles && collectedStylesheets) collectedStylesheets.push(...el.activatedScopedStyles)\n\t}\n\n\tfor (const child of (el.childNodes as unknown as Node[])) {\n\t\thtml += _getOuterHTML(child, opts, collectedStylesheets, standaloneContext);\n\t}\n\n\treturn html || domUtils.escapeHtml((el as HTMLElement).innerText ?? \"\"); // TODO: why sometimes no childnodes in jsdom (e.g UIX.Elements.Button)\n}\n\nfunction _getOuterHTML(el:Node, opts?:_renderOptions, collectedStylesheets?:string[], isStandaloneContext = false):string {\n\tisStandaloneContext = isStandaloneContext || (<any>el)[STANDALONE];\n\n\t// TODO: also for attributes transforms\n\tif (opts?.lang) {\n\t\tfor (const childPtr of (el as DOMUtils.elWithUIXAttributes)[DOMUtils.CHILDREN_DX_VALUES]??[]) {\n\t\t\tif (childPtr.transformSource) {\n\t\t\t\tfor (const ptr of [...childPtr.transformSource.deps, ...childPtr.transformSource.keyedDeps.keys()]) {\n\t\t\t\t\tif (ptr instanceof Datex.Pointer && ptr.transformMap) {\n\t\t\t\t\t\tconst localizedValue = ptr.transformMap[opts.lang] ?? ptr.transformMap[\"en\"];\n\t\t\t\t\t\tif (localizedValue != undefined) ptr.val = localizedValue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (el instanceof RawHTML) {\n        return el.html;\n    }\n\n\tif (el?.[OPEN_GRAPH] && opts?.extractedData) {\n\t\topts.extractedData.openGraph = el[OPEN_GRAPH];\n\t}\n\n\tif (el instanceof domContext.Text) {\n\t\t// special case: localized text\n\t\tlet content: string;\n\t\tif (opts?.lang && (el as any)[DX_VALUE] instanceof Datex.Pointer && (el as any)[DX_VALUE].transformMap) {\n\t\t\tconst map = (el as any)[DX_VALUE].transformMap;\n\t\t\tcontent = map[opts?.lang] ?? map[\"en\"] ?? el.textContent;\n\t\t}\n\t\t// live ref value\n\t\telse if ((el as any)[DX_VALUE] instanceof Datex.ReactiveValue) {\n\t\t\tif (opts) opts.forceParentLive = true;\n\t\t\tcontent = el.textContent;\n\t\t}\n\t\t// static value\n\t\telse {\n\t\t\tcontent = el.textContent\n\t\t}\n\t\treturn domUtils.escapeHtml(content ?? \"\"); // text node\n\t}\n\n\tif (el instanceof domContext.DocumentFragment) {\n\t\tconst content = [];\n\t\tfor (const child of (el.childNodes as unknown as Node[])) {\n\t\t\tcontent.push(_getOuterHTML(child, opts, collectedStylesheets, isStandaloneContext));\n\t\t}\n\t\treturn content.join(\"\\n\");\n\t}\n\n\tif (el instanceof domContext.Comment) {\n\t\treturn `<!--${el.textContent}-->`\n\t}\n\n\t// invalid node/element\n\tif (!(el instanceof domContext.Element)) {\n\t\tconsole.log(\"cannot render node\",el);\n\t\tthrow \"invalid HTML node\"\n\t}\n\n\tconst dataPtr:string|undefined = el.attributes.getNamedItem(\"uix-ptr\")?.value;\n\n\t// add datex-update type to stack\n\tconst datexUpdateType = (el as any)[DOMUtils.DATEX_UPDATE_TYPE];\n\tif (opts && datexUpdateType) {\n\t\tif (!opts.datex_update_type) opts.datex_update_type = []\n\t\topts.datex_update_type.push(datexUpdateType)\n\t}\n\n\t// remember last form\n\tif (el instanceof domContext.HTMLFormElement) {\n\t\tif (!opts.forms) opts.forms = []\n\t\topts.forms.push(dataPtr)\n\t}\n\n\tif (opts) opts.forceParentLive = false;\n\tconst inner = getInnerHTML(el, opts, collectedStylesheets, isStandaloneContext);\n\tconst tag = el.tagName.toLowerCase();\n\tconst attrs = [];\n\n\t// child forced this parent to be live\n\tconst forceLive = opts?.forceParentLive;\n\tif (opts) opts.forceParentLive = false;\n\t\n\t// pop datex-update type from stack\n\tif (opts && datexUpdateType) {\n\t\topts.datex_update_type?.pop()\n\t}\n\n\n\t// TODO: only workaround\n\t// if (opts?.lang) {\n\t// \tUIX.language = opts.lang\n\t// };\n\n\tfor (let i = 0; i < el.attributes.length; i++) {\n\t\tconst attrib = el.attributes[i];\n\n\t\tif (opts?.plainHTML && attrib.name == \"uix-ptr\") continue;\n\t\tif (!opts?.editMode && (attrib.name == \"data-edit-location\" || attrib.name == \"data-edit-props\")) continue;\n\n\t\t// set/override latest uix-title\n\t\tif (attrib.name == \"uix-title\" && opts?.extractedData) {\n\t\t\topts.extractedData.title = attrib.value;\n\t\t}\n\n\t\tlet val:string;\n\n\t\tconst transformMap = opts?.lang && (el as any)[DOMUtils.ATTR_DX_VALUES]?.get(attrib.name)?.transformMap;\n\t\tif (transformMap) {\n\t\t\tval = transformMap[opts!.lang!] ?? transformMap[\"en\"] ?? attrib.value;\n\t\t}\n\t\telse {\n\t\t\tval = attrib.value;\n\t\t}\n\n\t\t// is a module identifier -> resolve - only for specific attributes:\n\t\t// * src\n\t\t// * href\n\t\tif ((attrib.name == \"src\" || attrib.name == \"href\") && val.match(/^[a-zA-Z0-9_]/)) {\n\t\t\tval = import.meta.resolve(val);\n\t\t}\n\n\t\t// relative web path (@...)\n\t\tif (val.startsWith(\"file://\")) val = convertToWebPath(val);\n\t\t// blob -> data url\n\t\telse if (val.startsWith(\"blob:\")) {\n\t\t\tlogger.warn(\"not implemented: ssr blob rendering support\");\n\t\t\t// val = await blobToBase64(val);\n\t\t}\n\n\t\tattrs.push(`${attrib.name}=\"${domUtils.escapeHtml(val.toString())}\"`) // TODO: better escape?\n\t}\n\n\n\t// special attributes (value, checked)\n\tif ('value' in el && el.value) attrs.push(`value=\"${domUtils.escapeHtml(el.value?.toString()??\"\")}\"`)\n\tif ('checked' in el) {\n\t\tif (el.checked === true) attrs.push(`checked`)\n\t\telse if (el.checked !== false) attrs.push(`value=\"${domUtils.escapeHtml(el.checked?.toString()??\"\")}\"`)\n\t}\n\n\tif (!opts?.plainHTML) {\n\t\t// hydratable\n\t\tif (forceLive || isLiveNode(el)) {\n\t\t\tif (opts?.requiredPointers) opts.requiredPointers.add(el);\n\t\t\tattrs.push(\"uix-dry\");\n\t\t}\n\t\t\n\t\t// just static\n\t\telse attrs.push(\"uix-static\");\n\t}\n\n\t// enable edit mode (TODO:)\n\tif (opts?.editMode && el.hasAttribute(\"data-edit-location\")) {\n\t\tattrs.push(\"contenteditable\");\n\t}\n\n\n\t// inject event listeners\n\tif (dataPtr && opts?._injectedJsData && ((<DOMUtils.elWithUIXAttributes>el)[DOMUtils.EVENT_LISTENERS] || (<DOMUtils.elWithUIXAttributes>el)[DOMUtils.ATTR_BINDINGS])) {\n\t\tlet context: HTMLElement|undefined;\n\t\tlet parent: Element|null = el;\n\t\tlet hasScriptContent = false; // indicates whether the generated script actually contains relevant content, not just skeleton code\n\t\tdo {\n\t\t\tconst ctx = <HTMLElement|undefined>(<any>parent)[COMPONENT_CONTEXT];\n\t\t\tif (ctx) {\n\t\t\t\tcontext = ctx;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while ((parent = parent?.parentElement));\n\n\n\t\tlet script = `const el = querySelector('[uix-ptr=\"${dataPtr}\"]');\\n`\n\t\tscript += `el[EVENT_LISTENERS] ??= new Map();\\n`\n\n\t\t// inject listeners\n\t\tfor (const [event, listeners] of (<DOMUtils.elWithUIXAttributes>el)[DOMUtils.EVENT_LISTENERS] ?? []) {\n\t\t\t\n\t\t\tfor (const [listener] of listeners) {\n\n\t\t\t\tconst listenerFn = getFunctionWithContext(listener, isStandaloneContext);\n\t\t\t\tif (Datex.Pointer.isRef(listener)) opts?.requiredPointers?.add(listener);\n\n\n\t\t\t\t// special form \"action\" on submit (no js required)\n\t\t\t\tif (event == \"submit\" && Datex.Pointer.getByValue(listenerFn)) {\n\t\t\t\t\topts?.requiredPointers?.add(listenerFn);\n\t\t\t\t\tattrs.push(`action=\"/@uix/form-action/${Datex.Pointer.getByValue(listenerFn)!.idString()}/\"`);\n\t\t\t\t} \n\n\t\t\t\t// normal event listener\n\t\t\t\telse {\n\t\t\t\t\thasScriptContent = true;\n\t\t\t\t\tconst eventName = String(event);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst fnSource = getFunctionSource(listener, isStandaloneContext)\n\t\t\t\t\t\topts?.requiredPointers?.add(fnSource.listenerFn);\n\t\t\t\t\t\tscript += `{\\n`\n\t\t\t\t\t\tscript += fnSource.companionSource;\n\t\t\t\t\t\tscript += `const __f__ = ${fnSource.source};\\n`;\n\t\t\t\t\t\tscript += `if (!el[EVENT_LISTENERS].has(\"${eventName}\")) el[EVENT_LISTENERS].set(\"${eventName}\", new Set());\\n`;\n\t\t\t\t\t\tscript += `el[EVENT_LISTENERS].get(\"${eventName}\").add([__f__, true]);\\n`;\n\t\t\t\t\t\tscript += `el.addEventListener(\"${eventName}\", __f__);\\n`\n\t\t\t\t\t\tscript += `}\\n`\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\t// if skip datex functions enabled, this function is just ignored and later activated via DATEX\n\t\t\t\t\t\t// (throws if \"standalone\" is not set)\n\t\t\t\t\t\tif (!opts?.allowIgnoreDatexFunctions) throw e;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\n\n\t\t// inject element update triggers\n\t\tconst datexUpdateType:\"onsubmit\"|\"onchange\" = (el as any)[DOMUtils.DATEX_UPDATE_TYPE] ?? opts?.datex_update_type?.at(-1) ?? \"onchange\";\n\t\tconst form = opts?.forms?.at(-1);\n\n\t\tif (datexUpdateType == \"onsubmit\" && !form) {\n\t\t\tthrow new Error(`Invalid datex-update=\"onsubmit\", no form found`)\n\t\t}\n\n\t\tfor (const [attr, ptr] of (<DOMUtils.elWithUIXAttributes>el)[DOMUtils.ATTR_BINDINGS] ?? []) {\n\n\t\t\topts?.requiredPointers?.add(ptr);\n\n\t\t\tlet type: \"string\" | \"number\" | \"bigint\" | \"boolean\" | \"Date\" = \"string\";\n\t\t\tif (!(ptr.type instanceof Datex.Type)) {\n\t\t\t\tconsole.warn(\"Cannot correctly infer type for datex binding for pointer\");\n\t\t\t}\n\t\t\telse if (ptr.type.matchesType(Datex.Type.std.boolean)) type = \"boolean\";\n\t\t\telse if (ptr.type.matchesType(Datex.Type.std.decimal)) type = \"number\";\n\t\t\telse if (ptr.type.matchesType(Datex.Type.std.integer)) type = \"bigint\";\n\t\t\telse if (ptr.type.matchesType(Datex.Type.std.time)) type = \"Date\";\n\t\t\t\n\t\t\thasScriptContent = true;\n\t\t\tconst propName = attr == \"checked\" ? \"checked\" : \"value\";\n\t\t\tconst keepAlive = datexUpdateType == \"onsubmit\"\n\t\t\tconst fn = getValueUpdater(ptr, false, keepAlive, type);\n\t\t\tscript += `{\\n`\n\t\t\tscript += `const __f1__ = ${fn.toString()};`; \n\t\t\tscript += `const __original__ = el.${propName};`;\n\t\t\tscript += `const __f__ = async function(diff, evt) {\n\t\t\t\tconst val = el.${propName};\n\t\t\t\tif (diff && val == __original__) return;\n\t\t\t\ttry {\n\t\t\t\t\tconst valid = el.checkValidity();\n\t\t\t\t\tif (!valid) console.log(\"preventing data updates due to invalid form data\");\n\t\t\t\t\tconst res = valid ? await __f1__(val) : null;\n\t\t\t\t\tel.setCustomValidity(\"\")\n\t\t\t\t\tel.reportValidity()\n\t\t\t\t\treturn res;\n\t\t\t\t} \n\t\t\t\tcatch (e) {\n\t\t\t\t\tconst message = e?.message ?? e?.toString()\n\t\t\t\t\tel.setCustomValidity(message)\n\t\t\t\t\tel.reportValidity()\n\t\t\t\t\tif (evt) evt.preventDefault() // TODO\n\t\t\t\t}\n\t\t\t};\\n`;\n\n\t\t\t// onsubmit\n\t\t\tif (datexUpdateType == \"onsubmit\") {\n\t\t\t\tscript += `const form = querySelector('[uix-ptr=\"${form}\"]');\\n`\n\t\t\t\tscript += `form.addEventListener(\"submit\", (e) => __f__(true, e));\\n`\n\t\t\t}\n\t\t\t// onchange\n\t\t\telse {\n\t\t\t\tconst eventName = attr == \"checked\" ? \"change\" : \"input\";\n\t\t\t\tscript += `el.addEventListener(\"${eventName}\", __f__);\\n`\n\t\t\t}\n\t\t\tscript += `}\\n`\n\n\t\t\t// console.log(\"binding\", attr, Datex.Runtime.valueToDatexStringExperimental(ptr), fn.toString())\n\t\t}\n\n\t\tif (hasScriptContent) opts._injectedJsData.init.push(script);\n\t}\n\n\t// pop last form\n\tif (el instanceof domContext.HTMLFormElement) {\n\t\topts?.forms?.pop()\n\t}\n\n\tif (selfClosingTags.has(tag)) return `<${tag}${attrs.length ? ' ' + attrs.join(\" \") : ''}/>`;\n\telse return `<${tag}${attrs.length ? ' ' + attrs.join(\" \") : ''}>${inner}</${tag}>`\n\t// const outer = el.cloneNode().outerHTML;\n\t// const start = outer.replace(/<\\/[A-Za-z0-9-_ ]+>$/, '');\n\t// const end = outer.match(/<\\/[A-Za-z0-9-_ ]+>$/)?.[0] ?? \"\"; // might not have an end tag\n\t// return start + inner + end;\n}\n\nfunction getFunctionWithContext(fn: (...args: unknown[]) => unknown, isStandaloneContext?: boolean) {\n\tconst isStandaloneFunction = (fn as any)[STANDALONE] || fn instanceof JSTransferableFunction;\n\tconst forceBindToOriginContext = !isStandaloneContext&&!isStandaloneFunction;\n\treturn (forceBindToOriginContext ? bindToOrigin(fn) : fn);\n}\n\nfunction getFunctionSource(fn: (...args: unknown[]) => unknown, isStandaloneContext: boolean) {\n\tconst listenerFn = getFunctionWithContext(fn, isStandaloneContext)\n\n\tlet companionSource = ''\n\n\tconst dependencies = listenerFn instanceof JSTransferableFunction ? listenerFn.deps : {};\n\n\tconst keys = listenerFn instanceof JSTransferableFunction ? Object.keys(listenerFn.deps) : null;\n\tif (listenerFn instanceof JSTransferableFunction && keys!.length && !(keys!.length == 1 && keys![0] === \"this\") && !listenerFn.flags?.includes(\"standalone\")) {\n\t\tthrow new Error('use() declaration must have a \"standalone\" flag because the context has no DATEX runtime: use(\"standalone\")')\n\t}\n\n\tlet hasContext = false;\n\tconst ctxId = Datex.Pointer.getByValue(dependencies['this'])?.id;\n\tif (ctxId && dependencies['this'] instanceof domContext.Element) {\n\t\thasContext = true;\n\t\tcompanionSource += `const ctx = querySelector('[uix-ptr=\"${ctxId}\"]');\\n`\n\t}\n\n\t// add deps if transferable js fn\n\n\tfor (const [varName, value] of Object.entries(dependencies)) {\n\t\t// this already injected\n\t\tif (varName == \"this\") continue;\n\t\t// handle functions\n\t\telse if (typeof value == \"function\") {\n\t\t\tconst fnSource = getFunctionSource(value as (...args: unknown[]) => unknown, isStandaloneContext);\n\t\t\tcompanionSource += fnSource.companionSource;\n\t\t\tcompanionSource += `const ${varName} = ${fnSource.source};\\n`\n\t\t}\t\t\n\t\t// handle dom elements\n\t\telse if (value instanceof domContext.Element) {\n\t\t\tconst ptrId = Datex.Pointer.getByValue(value)?.id;\n\t\t\tif (ptrId) {\n\t\t\t\tcompanionSource += `const ${varName} = querySelector('[uix-ptr=\"${ptrId}\"]');\\n`\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthrow new Error(\"Cannot bind variable '\" + varName + \"' to a frontend context with use() - DOM element has no pointer.\");\n\t\t\t}\n\t\t}\n\t\t// json values\n\t\telse {\n\t\t\ttry {\n\t\t\t\t// with convertJSONInput\n\t\t\t\tif (value && typeof value == \"object\") {\n\t\t\t\t\tcompanionSource += `const {createStaticObject} = await import(\"uix/standalone/create-static-object.ts\" /*lazy*/);\\n`\n\t\t\t\t\tcompanionSource += `const ${varName} = createStaticObject(${serializeJSValue(value)});\\n`\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tcompanionSource += `const ${varName} = ${serializeJSValue(value)};\\n`\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t\tcatch (e){\n\t\t\t\tconsole.log(e)\n\t\t\t\tthrow new Error(\"Cannot bind variable '\" + varName + \"' to a frontend context with use() - this value is not supported.\");\n\t\t\t}\n\t\t}\n\n\t}\n\t\n\t// else if (!context) {\n\t// \tthrow new Error(\"Cannot infer 'this' in runInDisplayContext(). Please provide it as an argument.\")\n\t// }\n\n\tconst source = hasContext ? getFunctionWrapper(listenerFn, \"ctx\") : listenerFn.toString()\n\n\treturn {source, companionSource, listenerFn}\n}\n\nfunction getFunctionWrapper(fn: Function, contextName = \"ctx\") {\n\tconst fnSource = fn.toString();\n\n\t// native function not supported\n\tif (fnSource == 'function () { [native code] }') {\n\t\tthrow new Error(\"Invalid native function binding for standalone mode (If you are using bind(), it is not supported.)\");\n\t}\n\t// normal function with own 'this' context\n\tif (isNormalFunction(fnSource)) return fnSource;\n\t// object methods check if 'this' context is component context;\n\telse if (!isArrowFunction(fnSource) && isObjectMethod(fnSource)) {\n\t\tconsole.log(fn);\n\t\tlogger.warn(\"Unstable function binding (not supported for backend rendering): cannot determine 'this' context for '\"+fn.name+\"()'\");\t\n\t}\n\t// context wrapper for arrow function or object method\n\telse return `(function (...args){return (${fnSource})(...args)}).bind(${contextName})`\n}\n\n\nconst isArrowFunction = (fnSrc:string) => {\n\treturn !!fnSrc.match(/^(async\\s+)?\\([^)]*\\)\\s*=>/)\n}\n\nconst isObjectMethod = (fnSrc:string) => {\n\treturn !!fnSrc.match(/^(async\\s+)?[^\\s(]+ *(\\(|\\*)/)\n}\n \nconst isNormalFunction = (fnSrc:string) => {\n\treturn !!fnSrc.match(/^(async\\s+)?function(\\(| |\\*)/)\n}\n\nfunction isLiveNode(node: Node) {\n\t// hybrid components are always live (TODO: not for backend-only components)\n\tif (node instanceof Component) return true;\n\tif (node[DOMUtils.ATTR_BINDINGS]?.size) return true;\n\tif (node[DOMUtils.EVENT_LISTENERS]?.size) return true;\n\t// uix-placeholder are always live\n\tif (node instanceof domContext.Element && node.tagName?.toLowerCase() == \"uix-placeholder\") return true;\n}\n\nexport function getOuterHTML(el:Element|DocumentFragment, opts?:{\n\tincludeShadowRoots?:boolean, \n\tinjectStandaloneJS?:boolean, \n\tinjectStandaloneComponents?: boolean, \n\tallowIgnoreDatexFunctions?: boolean, \n\textractedData?: extractedData,\n\tlang?:string, \n\tplainHTML?: boolean,\n\teditMode?: boolean\n\trequiredPointers?: Set<any>\n}): [header_script:string, html_content:string] {\n\n\tif ((el as any)[CACHED_CONTENT]) return (el as any)[CACHED_CONTENT];\n\n\tconst scriptData:injectScriptData = {declare:{}, init:[]};\n\tif (opts?.injectStandaloneJS) (opts as any)._injectedJsData = scriptData;\n\n\tconst collectedStylesheets:string[] = []\n\n\t// TODO: only workaround\n\t// if (opts?.lang) UIX.language = opts.lang;\n\n\tlet html = _getOuterHTML(el, opts, collectedStylesheets);\n\n\t// add collected stylesheet urls from html components\n\tlet injectedStyles = \"\"\n\tlet injectedStyleSheets = new Set<string>()\n\tfor (const urlOrStylesheet of collectedStylesheets) {\n\t\tif (urlOrStylesheet instanceof CSSStyleSheet) {\n\t\t\tconst css = urlOrStylesheet._cached_css ?? [...urlOrStylesheet.cssRules].map(c=>c.cssText).join(\"\\n\");\n\t\t\tif (!injectedStyleSheets.has(css)) {\n\t\t\t\tinjectedStyles += `<style>${css}</style>`\n\t\t\t\tinjectedStyleSheets.add(css)\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tconst link = `<link rel=\"stylesheet\" href=\"${convertToWebPath(urlOrStylesheet)}\">`;\n\t\t\tif (!injectedStyles.includes(link)) injectedStyles += `${link}\\n`;\n\t\t}\n\t}\n\thtml = injectedStyles + html;\n\n\tlet script = `<script type=\"module\">\\n`\n\n\tscript += `import {querySelector, querySelectorAll} from \"uix/uix-dom/dom/shadow_dom_selector.ts\";\\n;`;\n\n\tif (opts?.injectStandaloneJS) {\n\t\t// global imports and definitions\n\t\tscript += `import {bindPrototype} from \"uix/standalone/get_prototype_properties.ts\";\\n`\n\t\tscript += `import {bindContentProperties} from \"uix/standalone/bound_content_properties.ts\";\\n`\n\t\tscript += `import \"uix/standalone/call-compat.ts\";\\n`\n\n\t\tscript += `globalThis.querySelector = querySelector;\\nglobalThis.querySelectorAll = querySelectorAll;\\n`\n\t\tscript += `globalThis.bindPrototype = bindPrototype;\\n`\n\t\tscript += `globalThis.bindContentProperties = bindContentProperties;\\n`\n\t\tscript += `const EVENT_LISTENERS = Symbol.for(\"DOMUtils.EVENT_LISTENERS\");\\n`\n\n\t\t// inject declarations\n\t\tif (opts?.injectStandaloneComponents) {\n\t\t\tscript += `globalThis.UIX_Standalone = {};\\n`\n\t\t\tfor (const [name, val] of Object.entries(scriptData.declare)) {\n\t\t\t\tscript += `globalThis.UIX_Standalone.${name} = ${escapeJsContent(val)};\\n`\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\t\n\t// initialization scripts\n\tlet init_script = \"\";\n\tfor (const val of scriptData.init) {\n\t\tinit_script += `{\\n${escapeJsContent(val)}\\n}\\n`\n\t}\n\n\t// scripts when DOM loaded:\n\tscript += `${init_script};`\n\n\tscript += `</script>`\n\n\treturn [script, html];\n}\n\n\n// https://gist.github.com/developit/54f3e3d1ce9ed0e5a171044edcd0784f\n// @ts-ignore\nif (!domContext.Element.prototype.getInnerHTML) {\n\t// @ts-ignore\n\tdomContext.Element.prototype.getInnerHTML = function(opts?:{includeShadowRoots?:boolean, lang?:string}) {\n\t  return getInnerHTML(this, opts);\n\t}\n}\n\n// @ts-ignore\nif (!domContext.Element.prototype.getOuterHTML) {\n\t// @ts-ignore\n\tdomContext.Element.prototype.getOuterHTML = function(opts?:{includeShadowRoots?:boolean, injectStandaloneJS?:boolean, injectStandaloneComponents?: boolean, lang?:string}) {\n\t\treturn getOuterHTML(this, opts);\n\t}\n}\n\nfunction escapeJsContent(content: string) {\n\treturn content.replaceAll(/<\\//g, '<\\\\/');\n}\n\n\nexport type HTMLPageOptions = {\n\tprovider:HTMLProvider, \n\tprerendered_content?:string|[header_scripts:string, html_content:string], \n\trender_method?:RenderMethod, \n\tcolor_scheme: \"dark\"|\"light\",\n\tcss?: string,\n\tjs_files:(URL|string|undefined)[], \n\tstatic_js_files:(URL|string|undefined)[],\n\tglobal_css_files:(URL|string|undefined|Record<string,string>)[], \n\tbody_css_files:(URL|string|undefined)[], \n\tfrontend_entrypoint?:URL|string, \n\tbackend_entrypoint?:URL|string, \n\topen_graph_meta_tags?:OpenGraphInformation, \n\tlang?: string, \n\tlivePointers?: string[],\n\tincludeImportMap?: boolean,\n\tforce_enable_scripts?: boolean,\n\tpreloadDependencies?: boolean,\n\tappColors?: {light?: string, dark?: string}\n}\n\nexport async function generateHTMLPage({\n\tprovider, \n\tprerendered_content, \n\trender_method, \n\tcolor_scheme,\n\tcss,\n\tjs_files, \n\tstatic_js_files,\n\tglobal_css_files, \n\tbody_css_files, \n\tfrontend_entrypoint, \n\tbackend_entrypoint, \n\tforce_enable_scripts,\n\topen_graph_meta_tags, \n\tlang, \n\tlivePointers,\n\tincludeImportMap,\n\tpreloadDependencies,\n\tappColors\n}: HTMLPageOptions) {\n\n\tlang ??= \"en\"\n\trender_method ??= RenderMethod.HYBRID;\n\tjs_files ??= []\n\tstatic_js_files ??= []\n\tglobal_css_files ??= []\n\tbody_css_files ??= []\n\tincludeImportMap ??= true;\n\tpreloadDependencies ??= true;\n\n\t// make sure pinned imports are resolved\n\tawait app.options?.import_map.init();\n\n\tconst modulePreloadUrls = new Set<string>();\n\tconst addPreloadUrl = async (url:string|URL) => {\n\t\tif (preloadDependencies) {\n\t\t\tif (!app.options) throw new Error(\"Missing app options\")\n\t\t\turl = provider.resolveForBackend(url);\n\t\t\t(await resolveDependencies(url, app.options)).forEach(dep => modulePreloadUrls.add(dep));\n\t\t\tmodulePreloadUrls.add(url.toString());\n\t\t}\n\t}\n\n\n\tlet files = '';\n\tlet metaScripts = ''\n\n\t// use frontendRuntime if rendering DYNAMIC or HYDRATION, and entrypoints are loaded, otherwise just static content and standalone js\n\tconst useFrontendRuntime = (render_method == RenderMethod.DYNAMIC || render_method == RenderMethod.HYBRID || render_method == RenderMethod.PREVIEW) && !!(frontend_entrypoint || backend_entrypoint || provider.live || force_enable_scripts);\n\n\t// js files\n\tif (useFrontendRuntime) {\n\t\tfiles += '<script type=\"module\">'\n\n\t\t// js imports\n\t\tfiles += indent(4) `\n\t\t\t${prerendered_content?`${\"import {disableInitScreen}\"} from \"${provider.resolveImport(\"datex-core-legacy/runtime/display.ts\").toString()}\";\\ndisableInitScreen();\\n` : ''}\n\t\t\tconst {f} = (await import(\"${provider.resolveImport(\"datex-core-legacy\").toString()}\"));` \n\t\t\t// await new Promise(resolve=>setTimeout(resolve,5000))\n\t\t\n\t\tfiles += `const {frontendRouter} = (await import(\"${provider.resolveImport(\"uix/routing/frontend-routing.ts\").toString()}\"));`\n\n\t\tif (app.options?.experimental_features.includes(\"indirect-references\")) files +=  indent(4) `\\nDatex.Runtime.OPTIONS.INDIRECT_REFERENCES = true;`\n\n\n\t\t// set app info\n\n\t\tfor (const file of js_files) {\n\t\t\tif (file) {\n\t\t\t\tconst path = provider.resolveImport(file).toString();\n\t\t\t\tfiles += indent(4) `\\nawait import(\"${path}\");`;\n\t\t\t\tawait addPreloadUrl(file);\n\t\t\t}\n\t\t}\n\n\t\t// hydrate\n\t\tif (prerendered_content && render_method == RenderMethod.HYBRID) {\n\t\t\tfiles += indent(4) `\\nimport {hydrate} from \"uix/hydration/hydrate.ts\"; hydrate();`;\n\t\t\tawait addPreloadUrl(\"uix/hydration/hydrate.ts\");\n\t\t}\n\n\n\t\t// load frontend entrypoint first\n\t\tif (frontend_entrypoint) {\n\t\t\tfiles += indent(4) `\\n\\nconst _frontend_entrypoint = await datex.get(\"${provider.resolveImport(frontend_entrypoint).toString()}\");`\n\t\t\tawait addPreloadUrl(frontend_entrypoint);\n\t\t}\n\n\t\t// hydration with backend content after ssr\n\t\tif (backend_entrypoint) {\n\t\t\t// load default export of ts module or dx export\n\t\t\tfiles += indent(4) `\\n\\nconst _backend_entrypoint = await datex.get(\"${provider.resolveImport(backend_entrypoint).toString()}\");let backend_entrypoint;\\nif (_backend_entrypoint.default) backend_entrypoint = _backend_entrypoint.default\\nelse if (_backend_entrypoint && Object.getPrototypeOf(_backend_entrypoint) != null) backend_entrypoint = _backend_entrypoint;`\n\t\t\tawait addPreloadUrl(backend_entrypoint);\n\t\t}\n\t\t// alternative: frontend rendering\n\t\tif (frontend_entrypoint) {\n\t\t\t// load default export of ts module or dx export\n\t\t\tfiles += indent(4) `\\nlet frontend_entrypoint; if (_frontend_entrypoint.default) frontend_entrypoint = _frontend_entrypoint.default\\nelse if (_frontend_entrypoint && Object.getPrototypeOf(_frontend_entrypoint) != null) frontend_entrypoint = _frontend_entrypoint;`\n\t\t}\n\n\t\tconst isHydrating = prerendered_content && (render_method == RenderMethod.HYBRID || render_method == RenderMethod.BACKEND);\n\t\tconst isHydratingVal = isHydrating ? 'true' : 'false'\n\n\t\tconst mergeFrontendVal = render_method == RenderMethod.PREVIEW ? \"'override'\" : \"'insert'\"\n\t\tconst requestBackendContent = render_method == RenderMethod.DYNAMIC ? 'true' : 'false' // content must first be request from backend router via DATEX when using DYNAMIC rendering\n\n\t\tif (backend_entrypoint && frontend_entrypoint)\n\t\t\tfiles += `\\n\\nawait frontendRouter.setEntrypoints(frontend_entrypoint, backend_entrypoint, ${isHydratingVal}, ${mergeFrontendVal}, ${requestBackendContent})`\n\t\telse if (backend_entrypoint)\n\t\t\tfiles += `\\n\\nawait frontendRouter.setEntrypoints(undefined, backend_entrypoint, ${isHydratingVal}, ${mergeFrontendVal}, ${requestBackendContent})`\n\t\telse if (frontend_entrypoint)\n\t\t\tfiles += `\\n\\nawait frontendRouter.setEntrypoints(frontend_entrypoint, undefined, ${isHydratingVal}, ${mergeFrontendVal}, ${requestBackendContent})`\n\n\t\tfiles += '\\n</script>\\n'\n\n\t\t// preload default modules\n\t\tawait addPreloadUrl(\"uix/routing/frontend-routing.ts\");\n\t\tawait addPreloadUrl(\"datex-core-legacy\");\n\t\tif (preloadDependencies) modulePreloadUrls.add(\"/.dx\")\n\t}\n\n\t// inject UIX app metadata and static js files\n\tif (render_method != RenderMethod.STATIC) {\n\t\tmetaScripts += indent(4) `\n\t\t\t<script type=\"uix-app\">\n\t\t\t\t${JSON.stringify({\n\t\t\t\t\tname: provider.app_options.name, \n\t\t\t\t\tversion: provider.app_options.version, \n\t\t\t\t\texperimental_features: provider.app_options.experimental_features,\n\t\t\t\t\tstage: stage, \n\t\t\t\t\tbackend: Datex.Runtime.endpoint.toString(),\n\t\t\t\t\tbackendLibVersions: {\n\t\t\t\t\t\tuix: UIX.version,\n\t\t\t\t\t\tdatex: Datex.Runtime.VERSION,\n\t\t\t\t\t},\n\t\t\t\t\thost: Datex.Unyt.endpoint_info.app?.host ? Datex.Unyt.endpoint_info.app.host.toString() : null,\n\t\t\t\t\tdynamicData: {\n\t\t\t\t\t\tdomains: app.domains\n\t\t\t\t\t},\n\t\t\t\t\tusid: app.uniqueStartId,\n\t\t\t\t\thod: app.metadata.hod\n\t\t\t\t}, null, \"    \")}\n\t\t\t</script>\\n`\n\n\t\t// add pointer sse observers\n\t\tif (livePointers) {\n\t\t\tfiles += indent `<script type=\"module\">\n\t\t\t\tconst {BackgroundRunner} = (await import(\"${provider.resolveImport(\"uix/background-runner/background-runner.ts\").toString()}\"));\n\t\t\t\tconst backgroundRunner = BackgroundRunner.get();\n\t\t\t\tbackgroundRunner.observePointers(${JSON.stringify(livePointers)});\n\t\t\t</script>`\t\n\t\t}\n\n\t\tfor (const file of static_js_files) {\n\t\t\tif (file) files += indent(4) `<script type=\"module\" src=\"${escapeJsContent(provider.resolveImport(file).toString())}\"></script>`\n\t\t}\n\t}\n\n\t// TODO: add condition if (add_importmap), when polyfill for declarative shadow root is no longer required\n\tif (includeImportMap) metaScripts += `<script type=\"importmap\">\\n${JSON.stringify(await provider.getRelativeImportMap(), null, 4)}\\n</script>`;\n\t\n\tlet global_style = '';\n\t// stylesheets\n\tfor (const stylesheet of global_css_files) {\n\t\tif (!stylesheet) continue;\n\t\tif (!(typeof stylesheet == \"string\" || stylesheet instanceof URL)) {\n\t\t\tglobal_style += `<link rel=\"stylesheet\" ${Object.entries(stylesheet).map(([k,v]) => `${k}=\"${k == \"href\" ? provider.resolveImport(v, true) : v}\"`).join(\" \")}>\\n`;\n\t\t}\n\t\telse global_style += `<link rel=\"stylesheet\" href=\"${provider.resolveImport(stylesheet, true)}\">\\n`;\n\t}\n\n\t// custom inline css\n\tif (css) {\n\t\tglobal_style += `<style>${css}</style>`\n\t}\n\t\n\t// available global uix themes\n\tconst themeStylesheets = UIX.Theme.getAllStyleSheets();\n\tconst stylesheetsAttrs:Record<string, string[]> = {};\n\tfor (const [name, stylesheets] of themeStylesheets) {\n\t\tstylesheetsAttrs[name] = stylesheets.map(s => provider.resolveImport(s, true));\n\t}\n\tglobal_style += `<style class=\"uix-themes\" data-stylesheets=\"${encodeURI(JSON.stringify(stylesheetsAttrs))}\">`\n\tglobal_style += UIX.Theme.getThemesCSS().replaceAll(\"\\n\",\"\");\n\tglobal_style += \"</style>\"\n\n\tlet body_style = ''\n\t// stylesheets\n\tfor (const stylesheet of body_css_files) {\n\t\tif (!stylesheet) continue;\n\t\tbody_style += `<link rel=\"stylesheet\" href=\"${provider.resolveImport(stylesheet, true)}\">\\n`;\n\t}\n\n\tlet favicon = \"\";\n\t// TODO: remove icon_path, use icon instead\n\tif (provider.app_options.icon || provider.app_options.icon) favicon = `<link rel=\"icon\" href=\"${provider.resolveImport(provider.app_options.icon??provider.app_options.icon)}\">`\n\n\tlet custom_meta = \"\"\n \n\tif (provider.app_options.meta) {\n\t\tfor (const [key, value] of Object.entries(provider.app_options.meta)) {\n\t\t\tcustom_meta += `<meta name=\"${domUtils.escapeHtml(key)}\" content=\"${domUtils.escapeHtml(value)}\"/>\\n`\n\t\t}\n\t}\n\n\t// TODO: custom color-scheme inheritance not yet implemented (just in firefox)\n\t// ${appColors?.light ? `<meta name=\"theme-color\" media=\"(prefers-color-scheme: light)\" content=\"${appColors.light}\"/>` : \"\"}\n\t// ${appColors?.dark ? `<meta name=\"theme-color\" media=\"(prefers-color-scheme: dark)\" content=\"${appColors.dark}\"/>` : \"\"}\n\t\n\t// TODO: fix open_graph_meta_tags?.getMetaTags()\n\t\n\treturn indent `<!DOCTYPE html>\n\t\t<html lang=\"${lang}\" style=\"color-scheme:${color_scheme}\">\n\t\t\t<head>\n\t\t\t\t<meta charset=\"UTF-8\">\n\t\t\t\t<meta name=\"viewport\" content=\"viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>\n\t\t\t\t<meta name=\"color-scheme\" content=\"${color_scheme}\"/>\n\t\t\t\t<meta name=\"theme-color\"${appColors?.[color_scheme] ? ` content=\"${appColors[color_scheme]}\"` : ''}/>\n\t\t\t\t${metaScripts}\n\t\t\t\t${preloadDependencies ?\n\t\t\t\t\t[...modulePreloadUrls].map(_url => {\n\t\t\t\t\t\tconst url = convertToWebPath(_url);\n\t\t\t\t\t\treturn url.endsWith(\".ts\")||url.endsWith(\".js\")||url.endsWith(\".tsx\")||url.endsWith(\".jsx\") ? \n\t\t\t\t\t\t\t`<link rel=\"modulepreload\" href=\"${url}\">` : \n\t\t\t\t\t\t\t`<link rel=\"preload\" href=\"${url}\" ${\n\t\t\t\t\t\t\t\turl.endsWith(\".css\")||url.endsWith(\".scss\") ? \"\" : \"crossorigin\"\n\t\t\t\t\t\t\t} as=\"${\n\t\t\t\t\t\t\t\turl.endsWith(\".css\")||url.endsWith(\".scss\") ? \"style\" : \n\t\t\t\t\t\t\t\turl.endsWith(\".woff2\")||url.endsWith(\".woff\")||url.endsWith(\".ttf\") ? \"font\" : \n\t\t\t\t\t\t\t\t\"fetch\"\n\t\t\t\t\t\t\t}\">`\n\t\t\t\t\t}).join(\"\\n\") : \"\"\n\t\t\t\t}\n\t\t\t\t${await open_graph_meta_tags?.getMetaTags() ?? (provider.app_options.name ? `<title>${provider.app_options.name}</title>` : '')}\n\t\t\t\t${custom_meta}\n\t\t\t\t${favicon}\n\t\t\t\t${provider.app_options.installable||provider.app_options.manifest ? `<link rel=\"manifest\" href=\"/@uix/manifest.json\">` : ''}\n\t\t\t\t${provider.app_options.installable||provider.app_options.manifest ? `<script async src=\"https://cdn.jsdelivr.net/npm/pwacompat\" crossorigin=\"anonymous\"></script>` : ''}\n\t\t\t\t${global_style}\n\t\t\t\t${prerendered_content instanceof Array ? prerendered_content[0] : ''}\n\t\t\t\t${files}\n\t\t\t\t${\n\t\t\t\t\trender_method != RenderMethod.HYBRID ? \n\t\t\t\t\t`<script>\n\t\t\t\t\t\t(globalThis.addEventListenerOnce ?? globalThis.addEventListener)(\"DOMContentLoaded\", () => {\n\t\t\t\t\t\t\tdocument.body.style.visibility = \"visible\"\n\t\t\t\t\t\t});\n\t\t\t\t\t</script>` : ''\n\t\t\t\t}\n\t\t\t\t${\n\t\t\t\t\tapp.options?.experimental_features.includes(\"view-transitions\") ? `\n\t\t\t\t\t<meta name=\"view-transition\" content=\"same-origin\" />\n\t\t\t\t\t<style>\n\t\t\t\t\t\t@view-transition {\n\t\t\t\t\t\t\tnavigation: auto;\n\t\t\t\t\t\t}\n\t\t\t\t\t</style>` : ''\n\t\t\t\t}\n\t\t\t\t<noscript>\n\t\t\t\t\t${\n\t\t\t\t\t\trender_method != RenderMethod.HYBRID ?\n\t\t\t\t\t\t`<style>\n\t\t\t\t\t\t\tbody {\n\t\t\t\t\t\t\t\tvisibility: visible!important;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</style>` : ''\n\t\t\t\t\t}\n\t\t\t\t\t<link rel=\"stylesheet\" href=\"${provider.resolveImport(\"uix/style/noscript.css\", true)}\">\n\t\t\t\t</noscript>\n\t\t\t</head>\n\t\t\t<body ${render_method != RenderMethod.HYBRID ? 'style=\"visibility:hidden;\"' : ''} data-color-scheme=\"${color_scheme}\">\n\t\t\t` +\n(prerendered_content instanceof Array ? prerendered_content[1] : (prerendered_content??'')) + `\n\t\t\t</body>\n\t\t</html>\n\t`\n\n}"],"names":["Datex","OPEN_GRAPH","indent","COMPONENT_CONTEXT","STANDALONE","app","client_type","bindToOrigin","getValueUpdater","RenderMethod","logger","domContext","domUtils","DOMUtils","JSTransferableFunction","convertToWebPath","UIX","serializeJSValue","Component","DX_VALUE","resolveDependencies","RawHTML","stage","CACHED_CONTENT","Symbol","selfClosingTags","Set","loadStandaloneJS","el","opts","_injectedJsData","injectStandaloneComponents","standaloneEnabled","loadClassDeclarations","constructor","loadInitScript","componentClass","getStandalonePseudoClass","getParentClass","parent_class","name","declare","component","getStandaloneInit","init","push","getInnerHTML","collectedStylesheets","standaloneContext","includeShadowRoots","plainHTML","innerHTML","html","Element","shadowRoot","mode","link","getRenderedStyle","style_sheets_urls","activatedScopedStyles","child","childNodes","_getOuterHTML","escapeHtml","innerText","isStandaloneContext","lang","childPtr","CHILDREN_DX_VALUES","transformSource","ptr","deps","keyedDeps","keys","Pointer","transformMap","localizedValue","undefined","val","extractedData","openGraph","Text","content","map","textContent","ReactiveValue","forceParentLive","DocumentFragment","join","Comment","console","log","dataPtr","attributes","getNamedItem","value","datexUpdateType","DATEX_UPDATE_TYPE","datex_update_type","HTMLFormElement","forms","inner","tag","tagName","toLowerCase","attrs","forceLive","pop","i","length","attrib","editMode","title","ATTR_DX_VALUES","get","match","resolve","startsWith","warn","toString","checked","isLiveNode","requiredPointers","add","hasAttribute","EVENT_LISTENERS","ATTR_BINDINGS","parent","hasScriptContent","parentElement","script","event","listeners","listener","listenerFn","getFunctionWithContext","isRef","getByValue","idString","eventName","String","fnSource","getFunctionSource","companionSource","source","e","allowIgnoreDatexFunctions","at","form","Error","attr","type","Type","matchesType","std","boolean","decimal","integer","time","propName","fn","has","isStandaloneFunction","forceBindToOriginContext","dependencies","Object","flags","includes","hasContext","ctxId","id","varName","entries","ptrId","getFunctionWrapper","contextName","isNormalFunction","isArrowFunction","isObjectMethod","fnSrc","node","size","getOuterHTML","scriptData","injectStandaloneJS","injectedStyles","injectedStyleSheets","urlOrStylesheet","CSSStyleSheet","css","_cached_css","cssRules","c","cssText","escapeJsContent","init_script","replaceAll","prototype","generateHTMLPage","provider","prerendered_content","render_method","color_scheme","js_files","static_js_files","global_css_files","body_css_files","frontend_entrypoint","backend_entrypoint","force_enable_scripts","open_graph_meta_tags","livePointers","includeImportMap","preloadDependencies","appColors","HYBRID","options","import_map","modulePreloadUrls","addPreloadUrl","url","resolveForBackend","forEach","dep","files","metaScripts","DYNAMIC","PREVIEW","live","file","resolveImport","experimental_features","path","isHydratingVal","isHydrating","BACKEND","mergeFrontendVal","requestBackendContent","STATIC","JSON","stringify","app_options","version","backend","Runtime","endpoint","backendLibVersions","uix","datex","VERSION","host","Unyt","endpoint_info","dynamicData","domains","usid","uniqueStartId","hod","metadata","getRelativeImportMap","global_style","stylesheet","URL","k","v","themeStylesheets","Theme","getAllStyleSheets","stylesheetsAttrs","stylesheets","s","encodeURI","getThemesCSS","favicon","icon","custom_meta","meta","key","_url","endsWith","getMetaTags","installable","manifest","Array"],"mappings":"AAAA,SAASA,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,UAAU,QAA8B,wBAAwB;AACzE,SAASC,MAAM,QAAQ,oCAAoC;AAE3D,SAASC,iBAAiB,EAAEC,UAAU,QAAQ,4CAA4C;AAC1F,SAASC,GAAG,QAAQ,gBAAgB;AACpC,SAASC,WAAW,QAAQ,uCAAuC;AACnE,SAASC,YAAY,EAAEC,eAAe,QAAQ,4BAA4B;AAC1E,SAASC,YAAY,QAAQ,4BAA4B;AACzD,SAASC,MAAM,QAAQ,4BAA4B;AACnD,SAASC,UAAU,EAAEC,QAAQ,QAAQ,wBAAwB;AAC7D,SAASC,QAAQ,QAAQ,yCAAyC;AAClE,SAASC,sBAAsB,QAAQ,yCAAyC;AAChF,SAASC,gBAAgB,QAAQ,gCAAgC;AACjE,SAASC,GAAG,QAAQ,eAAe;AACnC,SAASC,gBAAgB,QAAQ,2BAA2B;AAC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