'use strict';

var index = require('./index-Bkm7eeWO.js');

const EclCategoryFilterItem = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.styleClass = '';
        this.subItems = false;
        this.expanded = false;
    }
    clickedItem(ev) {
        this.lastClicked = ev.target.closest('.ecl-category-filter__list-item');
    }
    getClass() {
        return [
            `ecl-category-filter__list-item`,
            `sc-ecl-category-filter-${this.theme}`,
            this.styleClass
        ].join(' ');
    }
    getLinkClass() {
        const linkClasses = [
            `ecl-category-filter__item`,
            `sc-ecl-category-filter-${this.theme}`,
            `ecl-category-filter__item--level-${this.level}`,
            this.styleClass
        ];
        if (this.subItems) {
            linkClasses.push(`ecl-category-filter__item--has-children`);
        }
        return linkClasses.join(' ');
    }
    componentWillLoad() {
        var _a;
        this.theme = (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    render() {
        const elAttrs = {};
        if (this.subItems) {
            elAttrs['aria-expanded'] = "false";
        }
        if (this.expanded) {
            elAttrs['aria-expanded'] = "true";
        }
        return (index.h("li", { key: 'dfeb0077a7d82be5677a42c49bbb72c760d4fdf8', class: this.getClass(), onClick: ev => this.clickedItem(ev) }, this.path && !this.subItems && (index.h("ecl-link", { key: 'a96e2cab50a10f5249f0163fd2cb61c6cabcb190', styleClass: this.getLinkClass(), path: this.path }, this.label)), this.path && this.subItems && (index.h("button", Object.assign({ key: 'c61e85e0dbdc7ee041da685729fda5eaba99e785', class: this.getLinkClass() }, elAttrs), this.level === 1 && this.label, index.h("ecl-icon", { key: '9459de74b93230f17d0aa80764ac6c7d4791f370', styleClass: `ecl-category-filter__item-icon sc-ecl-category-filter-${this.theme}`, icon: this.level === 1 ? 'corner-arrow' : 'solid-arrow', rotate: this.level === 1 ? '180' : '90' }), this.level > 1 && this.label)), !this.path && this.label, this.subItems && (index.h("ul", { key: 'd0cadadb8d2b73dadd1eddf6a99a2058618d2628', class: `ecl-category-filter__list sc-ecl-category-filter-${this.theme}` }, index.h("slot", { key: 'd4cb038470b5c77b8ada26d41c1aa8f4751b9bad' })))));
    }
    get el() { return index.getElement(this); }
};

exports.ecl_category_filter_item = EclCategoryFilterItem;
