import { h } from "@stencil/core";
import Breadcrumb from "@ecl/breadcrumb";
export class EclBreadcrumb {
    constructor() {
        this.styleClass = '';
        this.noScript = false;
        this.minItemsRight = 2;
    }
    getClass() {
        return [
            `ecl-breadcrumb`,
            this.styleClass
        ].join(' ');
    }
    componentWillLoad() {
        var _a;
        this.theme = (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    componentDidRender() {
        const items = this.el.querySelectorAll('.ecl-breadcrumb__segment');
        const itemsCount = items.length;
        const ellipsis = this.el.querySelector('.ecl-breadcrumb__segment--ellipsis');
        const startHidingIndex = Array.from(items).indexOf(ellipsis);
        const toBeHidden = Array.from(items).slice((startHidingIndex + 1), (itemsCount - this.minItemsRight));
        toBeHidden.forEach((item) => {
            item.setAttribute('data-ecl-breadcrumb-item', 'expandable');
        });
        this.el.querySelector('.ecl-breadcrumb__container').innerHTML = '';
        this.el.querySelector('.ecl-breadcrumb__container').append(...items);
        if (!this.noScript) {
            ;
            window.ECL = window.ECL || {};
            ECL.Breadcrumb = Breadcrumb;
            const breadcrumb = new Breadcrumb(this.el.firstElementChild);
            breadcrumb.init();
        }
    }
    render() {
        return (h("nav", { key: 'dc1e482b7aa6514fa790a2bc574d13d57b81db6d', class: this.getClass(), "data-ecl-breadcrumb": true }, h("ol", { key: 'af1bbd7803ce8ac912b45b4998576432569f3bac', class: "ecl-breadcrumb__container" }, h("slot", { key: 'e0cb3c1571257c56d506c1d26f0338b5d1e86380' }))));
    }
    static get is() { return "ecl-breadcrumb"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-breadcrumb-ec.css"],
            "eu": ["./build/styles/ecl-breadcrumb-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-breadcrumb-ec.css"],
            "eu": ["build/styles/ecl-breadcrumb-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": "''"
            },
            "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"
            },
            "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"
            },
            "minItemsRight": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "min-items-right",
                "defaultValue": "2"
            }
        };
    }
    static get elementRef() { return "el"; }
}
