import { h } from "@stencil/core";
import getAssetPath from "../../utils/assetPath";
export class EclAccordion {
    constructor() {
        this.styleClass = '';
        this.eclScript = false;
        this.theme = 'ec';
        this.clickedItem = undefined;
    }
    getClass() {
        return [
            `ecl-accordion`,
            this.styleClass
        ].join(' ');
    }
    componentWillLoad() {
        if (this.eclScript) {
            const src = getAssetPath('./build/scripts/ecl-accordion-vanilla.js');
            if (document.querySelector(`script[src="${src}"]`)) {
                document.querySelector(`script[src="${src}"]`).remove();
            }
            const script = document.createElement('script');
            script.src = src;
            script.onload = () => {
                const accordion = new ECL.Accordion(this.el);
                accordion.init();
            };
            document.body.appendChild(script);
        }
    }
    componentDidRender() {
        this.el.querySelectorAll('.ecl-accordion__item button').forEach((item) => {
            item.addEventListener('click', (e) => {
                const target = e.currentTarget;
                this.clickedItem = target.parentElement.parentElement;
            });
        });
    }
    render() {
        return (h("div", { class: this.getClass() }, h("slot", null)));
    }
    static get is() { return "ecl-accordion"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-accordion-ec.css"],
            "eu": ["./build/styles/ecl-accordion-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-accordion-ec.css"],
            "eu": ["build/styles/ecl-accordion-eu.css"]
        };
    }
    static get assetsDirs() { return ["build"]; }
    static get properties() {
        return {
            "styleClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "style-class",
                "reflect": false,
                "defaultValue": "''"
            },
            "eclScript": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "ecl-script",
                "reflect": false,
                "defaultValue": "false"
            },
            "theme": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "theme",
                "reflect": false,
                "defaultValue": "'ec'"
            },
            "clickedItem": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "HTMLElement",
                    "resolved": "HTMLElement",
                    "references": {
                        "HTMLElement": {
                            "location": "global",
                            "id": "global::HTMLElement"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                }
            }
        };
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=ecl-accordion.js.map
