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,CAAK,QAAA,CAAS,QAAQ,CAAA,EAAA,EAAK;AAC3C,UAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,QAAA,CAAS,CAAC,CAAA;AAC7B,UAAA,KAAA,CAAM,OAAA,EAAQ;AAAA,QAClB;AAAA,MACJ;AAAA,IAEJ,SAAS,KAAA,EAAO;AACZ,MAAA,MAAA,EAAQ,MAAM,KAAK,CAAA;AAAA,IACvB;AAAA,EACJ;AACJ;AAxCI,eAAA,CAAA;AAAA,EAJC,UAAU,MAAA,CAAO;AAAA,IACd,MAAM,eAAA,CAAgB,SAAA;AAAA,IACtB,KAAA,EAAO,CAAC,OAAO;AAAA,GAClB,CAAA;AAAA,EAEI,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA,CAAA;AAAA,EACjB,4BAAS,QAAQ,CAAA;AAAA,CAAA,EArCb,WAAA,CAkCT,SAAA,EAAA,SAAA,EAAA,CAAA,CAAA;AAlCS,WAAA,GAAN,eAAA,CAAA;AAAA,EAJN,QAAQ,MAAA,CAAO;AAAA,IACZ,SAAA,EAAW,OAAA;AAAA,IACX,WAAA,EAAa;AAAA,GAChB;AAAA,CAAA,EACY,WAAA,CAAA","file":"AreCompiler.component.mjs","sourcesContent":["import { A_Caller, A_Component, A_Feature, A_Inject, A_TYPES__Entity_Constructor, } from \"@adaas/a-concept\";\nimport { A_Frame } from \"@adaas/a-frame/core\";\nimport { A_Logger } from \"@adaas/a-utils/a-logger\";\nimport { AreScene } from \"@adaas/are/scene/AreScene.context\";\nimport { AreNode } from \"@adaas/are/node/AreNode.entity\";\nimport { AreNodeFeatures } from \"@adaas/are/node/AreNode.constants\";\nimport { AreAttribute } from \"@adaas/are/attribute/AreAttribute.entity\";\nimport { AreAttributeFeatures } from \"@adaas/are/attribute/AreAttribute.constants\";\nimport { AreDeclaration } from \"@adaas/are/instruction/types/AreDeclaration.instruction\";\n\n\n@A_Frame.Define({\n    namespace: 'A-ARE',\n    description: 'Walks the transformed AreNode tree and emits a Scene. Translates each node, binding, directive and interpolation into a typed instruction. Knows nothing about the DOM or any rendering target — its only concern is producing a complete and ordered set of instructions that fully describes how the tree should be rendered.'\n})\nexport class AreCompiler extends A_Component {\n\n    /**\n     * Defines a custom method for compiling a node into a set of SceneInstructions. This method is called during the compilation phase of the ARE component and should perform any necessary transformations on the node and its attributes to generate the appropriate instructions for rendering. This can include tasks such as processing directives, evaluating expressions, and generating instructions for dynamic content based on the node's properties and context.\n     * \n     * @param node \n     */\n    static Compile<T extends AreNode>(node: A_TYPES__Entity_Constructor<T>)\n    /**\n     * Defines a custom method for compiling an attribute into a set of SceneInstructions. This method is called during the compilation phase of the ARE component and should perform any necessary transformations on the attribute to generate the appropriate instructions for rendering. This can include tasks such as processing directives, evaluating expressions, and generating instructions for dynamic content based on the attribute's properties and context.\n     * \n     * @param attribute \n     */\n    static Compile<T extends AreAttribute>(attribute: A_TYPES__Entity_Constructor<T>)\n    static Compile<T extends AreNode | AreAttribute>(param1: A_TYPES__Entity_Constructor<T>) {\n        return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {\n            return A_Feature.Extend({\n                name: param1.prototype instanceof AreNode\n                    ? AreNodeFeatures.onCompile\n                    : AreAttributeFeatures.Compile,\n                scope: [param1],\n                override: ['compile']\n            })(target, propertyKey, descriptor);\n        }\n    }\n\n\n    // -----------------------------------------------------------------------------------------\n    // ----------------------------Are-Node Compile Section----------------------------------------\n    // -----------------------------------------------------------------------------------------\n    @A_Feature.Extend({\n        name: AreNodeFeatures.onCompile,\n        scope: [AreNode]\n    })\n    compile(\n        @A_Inject(A_Caller) node: AreNode,\n        @A_Inject(AreScene) scene: AreScene,\n        @A_Inject(A_Logger) logger?: A_Logger,\n        ...args: any[]\n    ) {\n        try {\n            logger?.debug('cyan', `AreCompiler: compile node <${node.aseid.toString()}>`);\n\n            /**\n             * 1. Create & register Host Instructions to add it if no other cases presented\n             * \n             * [!] Note: it can be removed by directives or modified if needed\n             */\n            const hostInstruction = new AreDeclaration()\n            scene.setHost(hostInstruction);\n            scene.plan(hostInstruction);\n\n            /**\n             * 1. Prepare Instructions for attributes and add then to render plan.\n             */\n            for (let i = 0; i < node.attributes.length; i++) {\n                const attribute = node.attributes[i];\n                attribute.compile();\n            }\n\n            /**\n             * 2. Compile all nested nodes of the root node. \n             */\n            if (node.children && node.children.length > 0) {\n                for (let i = 0; i < node.children.length; i++) {\n                    const child = node.children[i];\n                    child.compile();\n                }\n            }\n\n        } catch (error) {\n            logger?.error(error)\n        }\n    }\n}"]}