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B,4BAAS,SAAS,CAAA,CAAA;AAAA,EAClB,4BAAS,mBAAmB,CAAA;AAAA,CAAA,EApMxB,eAAA,CA6LT,SAAA,EAAA,yBAAA,EAAA,CAAA,CAAA;AA7LS,eAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,YAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,eAAA,CAAA","file":"AreHTML.compiler.mjs","sourcesContent":["import { A_Caller, A_Dependency, A_Feature, A_FormatterHelper, A_Inject } from \"@adaas/a-concept\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { AreCompiler, AreScene, AreCompilerError, AreStore, AreSyntax } from \"@adaas/are\";\nimport { AreDirectiveAttribute } from \"@adaas/are-html/attributes/AreDirective.attribute\";\nimport { AreStaticAttribute } from \"@adaas/are-html/attributes/AreStatic.attribute\";\nimport { AreDirectiveFeatures } from \"@adaas/are-html/directive/AreDirective.constants\";\nimport { AreEventAttribute } from \"@adaas/are-html/attributes/AreEvent.attribute\";\nimport { AreBindingAttribute } from \"@adaas/are-html/attributes/AreBinding.attribute\";\nimport { AreInterpolation } from \"@adaas/are-html/nodes/AreInterpolation\";\nimport { AreText } from \"@adaas/are-html/nodes/AreText\";\nimport { AddAttributeInstruction} from \"@adaas/are-html/instructions/AddAttribute.instruction\";\nimport { AddTextInstruction} from \"@adaas/are-html/instructions/AddText.instruction\";\nimport { AddListenerInstruction} from \"@adaas/are-html/instructions/AddListener.instruction\";\nimport { AddStyleInstruction } from \"@adaas/are-html/instructions/AddStyle.instruction\";\nimport { AddStaticHTMLInstruction } from \"@adaas/are-html/instructions/AddStaticHTML.instruction\";\nimport { AreHTMLNode } from \"@adaas/are-html/node\";\nimport { AreDirectiveContext } from \"@adaas/are-html/directive/AreDirective.context\";\n\n\n\n\n@A_Frame.Define({\n    namespace: 'a-are-html',\n    description: 'HTML-specific compiler for A-Concept Rendering Engine (ARE) components, extending the base AreCompiler to handle HTML templates, styles, and rendering logic tailored for web environments.'\n})\nexport class AreHTMLCompiler extends AreCompiler {\n\n    /**\n     * Extends the base compile for all AreHTMLNode instances (elements, components, root nodes).\n     * After the standard element/attribute/children instructions are emitted, checks whether\n     * the node has a registered AreStyle and plans an AddStyleInstruction so the interpreter\n     * can inject the CSS into the document head during mount.\n     */\n    @AreCompiler.Compile(AreHTMLNode)\n    compileHTMLNode(\n        @A_Inject(A_Caller) node: AreHTMLNode,\n        @A_Inject(AreScene) scene: AreScene,\n        @A_Inject(A_Logger) logger?: A_Logger,\n        ...args: any[]\n    ): void {\n        super.compile(node, scene, logger, ...args);\n\n        /**\n         * Static-island materialisation. When the tokenizer flagged this node as\n         * a static island its inner subtree was never exploded into child nodes,\n         * so there is nothing for the base compiler to walk. Emit a single\n         * AddStaticHTML instruction carrying the captured inner markup; the\n         * interpreter injects it onto the host element in one pass (and decodes\n         * HTML entities for free).\n         */\n        if (node.isStaticIsland && scene.host) {\n            scene.plan(new AddStaticHTMLInstruction(scene.host, { html: node.staticInnerHTML! }));\n        }\n\n        if (node.styles?.styles) {\n            const host = scene.host;\n            if (host) {\n                scene.plan(new AddStyleInstruction(host, { styles: node.styles.styles }));\n            }\n        }\n    }\n\n    // -----------------------------------------------------------------------------------------\n    // -------------------------Are-Interpolation Compile Section-----------------------------------\n    // -----------------------------------------------------------------------------------------\n    /**\n     * Default compile method for interpolations, which can be overridden by specific implementations if needed.\n     * \n     * @param interpolation \n     * @param scope \n     * @param scene \n     * @param store \n     * @param feature \n     */\n    @AreCompiler.Compile(AreInterpolation)\n    compileInterpolation(\n        @A_Inject(A_Caller) interpolation: AreInterpolation,\n        @A_Inject(AreScene) scene: AreScene,\n\n        @A_Inject(AreStore) store: AreStore,\n        @A_Inject(A_Logger) logger?: A_Logger,\n        ...args: any[]\n    ) {\n        // if (scene.host)\n        //     console.log('Scene Host: ', scene.host);\n\n        // let content = '';\n\n        // logger?.debug('green', `AreHTMLCompiler: compile interpolation <${interpolation.aseid.toString()}> with key: \"${interpolation.content}\"`, store.get(interpolation.content));\n\n        // try {\n        //     content = AreCommonHelper.evaluate(interpolation.content, store);\n\n        // } catch (error) {\n        //     content = ''\n        // }\n\n        scene.plan(new AddTextInstruction({ content: interpolation.content, evaluate: true }));\n    }\n\n    // -----------------------------------------------------------------------------------------\n    // ------------------------------Are-Text Compile Section-----------------------------------\n    // -----------------------------------------------------------------------------------------\n    @AreCompiler.Compile(AreText)\n    compileText(\n        @A_Inject(A_Caller) text: AreText,\n        @A_Inject(AreScene) scene: AreScene,\n        @A_Inject(A_Logger) logger?: A_Logger,\n        ...args: any[]\n    ) {\n        logger?.debug('cyan', `AreHTMLCompiler: compile text node <${text.aseid.toString()}> with content: \"${text.content}\"`);\n        if (scene.host)\n            scene.unPlan(scene.host);\n\n        scene.plan(new AddTextInstruction({ content: text.content }));\n\n    }\n\n    // -----------------------------------------------------------------------------------------\n    // -------------------------Are-Attribute Compile Section-----------------------------------\n    // -----------------------------------------------------------------------------------------\n\n    @AreCompiler.Compile(AreStaticAttribute)\n    compileStaticAttribute(\n        @A_Inject(A_Caller) attribute: AreStaticAttribute,\n        @A_Inject(AreScene) scene: AreScene,\n        ...args: any[]\n    ) {\n        if (!scene.host)\n            throw new AreCompilerError({\n                title: 'Scene Host Not Found',\n                description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n            });\n\n        const content = attribute.content;\n\n        /**\n         * If the attribute value contains {{ }} interpolations, transform them into\n         * a JS string-concatenation expression so the interpreter can evaluate them.\n         * e.g. \"color:{{expr}}\" → '\"color:\"+(expr)+\"\"'\n         */\n        if (content.includes('{{')) {\n            const transformed = '\"' + content.replace(/\\{\\{([^}]+)\\}\\}/g, '\"+($1)+\"') + '\"';\n            scene.plan(new AddAttributeInstruction(scene.host, {\n                name: attribute.name,\n                content: transformed,\n                evaluate: true,\n            }));\n            return;\n        }\n\n        /**\n         * Default case: regular static attribute rendered as-is.\n         */\n        scene.plan(new AddAttributeInstruction(scene.host, {\n            name: attribute.name,\n            content: attribute.content\n        }));\n    }\n\n    @AreCompiler.Compile(AreDirectiveAttribute)\n    compileDirectiveAttribute(\n        @A_Inject(A_Caller) directive: AreDirectiveAttribute,\n        @A_Inject(AreStore) store: AreStore,\n        @A_Inject(A_Feature) feature: A_Feature,\n        @A_Inject(A_Logger) logger?: A_Logger,\n        ...args: any[]\n    ) {\n        store.watch(directive);\n\n        /**\n         * 3. If the attribute is a directive, then we should find a component that is responsible for\n         *    the directive compiling logic, and call it. \n         *    In case component is not found we just want to log a warning, \n         *    since the directive may be handled by some parent component or simply is a mistake in the template.\n         */\n        if (directive.component) {\n            feature.chain(directive.component, AreDirectiveFeatures.Compile, directive.owner.scope);\n        } else {\n            logger?.warning(`Directive handler component not found for directive: ${directive.name}. Make sure to create a component named \"AreDirective${A_FormatterHelper.toPascalCase(directive.name)}\" to handle this directive.`);\n        }\n\n        store.unwatch(directive);\n    }\n\n\n    @AreCompiler.Compile(AreEventAttribute)\n    compileEventAttribute(\n        @A_Inject(A_Caller) attribute: AreEventAttribute,\n        @A_Inject(AreScene) scene: AreScene,\n        ...args: any[]\n    ) {\n\n        if (!scene.host)\n            throw new AreCompilerError({\n                title: 'Scene Host Not Found',\n                description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n            });\n        /**\n         * 2. In case the attribute is an event listener, then \n         *    we should simply add a callback handler that will be used to proxy an event \n         *    into the ComponentNode component.  \n         *[!] In this case AreAttribute is AreEventAttribute that has prepared callback function to be used \n         *    in the event listener. It is important to store callback function once \n         *    to prevent duplicated functions in case of multiple compilations during development.\n         */\n        scene.plan(new AddListenerInstruction(scene.host, {\n            name: attribute.name,\n            handler: attribute.content\n        }));\n    }\n\n\n    @AreCompiler.Compile(AreBindingAttribute)\n    compileBindingAttribute(\n        @A_Inject(A_Caller) attribute: AreBindingAttribute,\n        @A_Inject(AreScene) scene: AreScene,\n        @A_Dependency.Parent()\n        @A_Inject(AreStore) parentStore: AreStore,\n        @A_Inject(AreStore) store: AreStore,\n        @A_Inject(AreSyntax) syntax: AreSyntax,\n        @A_Inject(AreDirectiveContext) directiveContext?: AreDirectiveContext,\n        ...args: any[]\n    ) {\n        if (!scene.host)\n            throw new AreCompilerError({\n                title: 'Scene Host Not Found',\n                description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`\n            });\n\n\n        const node = attribute.owner;\n        const props = node.component?.props;\n\n        // Component prop names are typically declared in camelCase, while template\n        // markup uses kebab-case. Try both forms when matching.\n        let propName: string | undefined;\n        if (props) {\n            if (props[attribute.name]) {\n                propName = attribute.name;\n            } else {\n                const camel = A_FormatterHelper.toCamelCase(attribute.name);\n                if (props[camel]) propName = camel;\n            }\n        }\n\n        /**\n         * 1. Component prop binding — evaluate against the parent store and\n         *    keep the child store reactive to upstream changes.\n         */\n        if (propName && props) {\n            const propDefinition = props[propName];\n\n            const coerce = (raw: any): any => {\n                let value = raw;\n                if (propDefinition.type) {\n                    switch (propDefinition.type) {\n                        case 'string': value = value === undefined || value === null ? '' : String(value); break;\n                        case 'number': value = Number(value); break;\n                        case 'boolean': value = Boolean(value); break;\n                    }\n                }\n                return value;\n            };\n\n            // Item-scoped variables from an enclosing directive (the `item`/`index`\n            // of a `$for`, or any scope a `$if` merged in) so a prop binding like\n            // `:title=\"item.name\"` resolves the loop variable — checked BEFORE the\n            // store, exactly like plain attribute bindings do in the interpreter.\n            // Read `.scope` lazily inside each evaluation so keyed `$for` updates\n            // that reassign the context's scope are always reflected.\n            const directiveScope = () => directiveContext?.scope ?? {};\n\n            // The watcher entity below is registered against parentStore so that\n            // updates to the bound expression in the parent flow into the child store.\n            const watcher = {\n                update: () => {\n                    try {\n                        parentStore.watch(watcher);\n                        const next = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));\n                        parentStore.unwatch(watcher);\n                        store.set(propName!, next);\n                    } catch (e) {\n                        parentStore.unwatch(watcher);\n                    }\n                }\n            };\n\n            // Initial read with watch active so dependencies are recorded.\n            parentStore.watch(watcher);\n            const initial = coerce(syntax.evaluate(attribute.content, parentStore, directiveScope()));\n            parentStore.unwatch(watcher);\n\n            store.set(propName, initial);\n            return;\n        }\n\n        /**\n         * 2. Default attribute binding — evaluated reactively against the local store.\n         */\n        const instruction = new AddAttributeInstruction(scene.host, {\n            name: attribute.name,\n            content: attribute.content,\n            evaluate: true\n        })\n\n        scene.plan(instruction);\n    }\n\n\n}"]}