import { h } from "@stencil/core";
import Timeline from "@ecl/timeline";
export class EclTimeline {
    constructor() {
        this.noScript = false;
        this.toBeToggled = false;
    }
    getClass() {
        const styleClasses = [
            `ecl-timeline`,
            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() {
        if (this.el.querySelector('.ecl-timeline__item--headline')) {
            this.el.firstElementChild.classList.add('ecl-timeline--has-headline');
        }
        if (!this.noScript) {
            ;
            window.ECL = window.ECL || {};
            ECL.Timeline = Timeline;
            const timeline = new Timeline(this.el.firstElementChild);
            timeline.init();
        }
        const toggle = this.el.querySelector('.ecl-timeline__item--toggle');
        if (toggle) {
            toggle.addEventListener('click', () => {
                this.toBeToggled = true;
            });
        }
    }
    componentDidRender() {
        const items = this.el.querySelectorAll('.ecl-timeline__item');
        this.el.querySelector('.ecl-timeline').innerHTML = '';
        this.el.querySelector('.ecl-timeline').append(...items);
    }
    render() {
        return (h("ol", { key: 'c09136c169152db192d6c44c6c8a2da2fd89f8f4', class: this.getClass(), "data-ecl-timeline": true }, h("slot", { key: '797ad9687bc6ce6bafc3ca9d4c5a653ac1eb15ac' })));
    }
    static get is() { return "ecl-timeline"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-timeline-ec.css"],
            "eu": ["./build/styles/ecl-timeline-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-timeline-ec.css"],
            "eu": ["build/styles/ecl-timeline-eu.css"]
        };
    }
    static get properties() {
        return {
            "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"
            },
            "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"
            },
            "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"
            },
            "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"
            }
        };
    }
    static get states() {
        return {
            "toBeToggled": {}
        };
    }
    static get elementRef() { return "el"; }
}
