import { h } from "@stencil/core";
import Accordion from "@ecl/accordion";
export class EclAccordion {
    constructor() {
        this.styleClass = '';
        this.noScript = false;
        this.colorMode = '';
        this.handleToggle = (itemId) => {
            this.openItemId = this.openItemId === itemId ? null : itemId;
        };
    }
    getClass() {
        const styleClasses = [
            `ecl-accordion`,
            this.styleClass
        ];
        if (this.colorMode) {
            styleClasses.push(`ecl-color-mode--${this.colorMode}`);
        }
        return styleClasses.join(' ');
    }
    componentWillLoad() {
        var _a;
        this.theme = (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    componentDidLoad() {
        const items = this.el.querySelectorAll('ecl-accordion-item');
        items.forEach((item, index) => {
            const container = item.querySelector('.ecl-accordion__item');
            if (container) {
                container.classList.toggle('is-first', index === 0);
                container.classList.toggle('is-last', index === items.length - 1);
            }
        });
        if (!this.noScript) {
            ;
            window.ECL = window.ECL || {};
            ECL.accordion = Accordion;
            const accordion = new Accordion(this.el);
            accordion.init();
        }
    }
    render() {
        return (h("div", { key: 'f4f80c7846bc3dd7044e0ae05befa8bad7e052cd', class: this.getClass() }, h("slot", { key: '2c69c26fa3c9c44c1eebca1a052a5a618c291aa3' })));
    }
    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": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "style-class",
                "defaultValue": "''"
            },
            "noScript": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "no-script",
                "defaultValue": "false"
            },
            "theme": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "theme"
            },
            "colorMode": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "color-mode",
                "defaultValue": "''"
            }
        };
    }
    static get states() {
        return {
            "openItemId": {}
        };
    }
    static get elementRef() { return "el"; }
}
