import { r as registerInstance, h, g as getElement } from './index-e78ba223.js';

const EclMenuItem = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.theme = 'ec';
        this.styleClass = undefined;
        this.external = false;
        this.current = false;
        this.hasChildren = false;
        this.child = false;
        this.link = undefined;
        this.triggerAriaLabel = undefined;
    }
    getClass() {
        let styleClasses = [
            'ecl-menu__item',
            `sc-ecl-menu-${this.theme}`,
            this.styleClass
        ];
        if (this.current) {
            styleClasses.push('ecl-menu__item--current');
        }
        if (this.child) {
            styleClasses = [
                'ecl-menu__subitem',
                `sc-ecl-menu-${this.theme}`,
                this.styleClass
            ];
            if (this.current) {
                styleClasses.push('ecl-menu__subitem--current');
            }
        }
        return styleClasses.join(' ');
    }
    getAttrs() {
        let attrs = {
            'data-ecl-menu-item': true,
            'aria-expanded': "false",
        };
        if (this.hasChildren) {
            attrs['data-ecl-has-children'] = true;
        }
        if (this.child) {
            delete attrs['data-ecl-menu-item'];
            attrs['data-ecl-menu-subitem'] = true;
        }
        return attrs;
    }
    getLinkClass() {
        let linkClasses = [
            'ecl-menu__link',
            `sc-ecl-menu-${this.theme}`,
        ];
        if (this.child) {
            linkClasses = [
                'ecl-menu__sublink',
                `sc-ecl-menu-${this.theme}`,
            ];
            if (this.current) {
                linkClasses.push('ecl-menu__sublink--current');
            }
            if (this.external) {
                linkClasses.push('ecl-link--icon-after');
            }
        }
        return linkClasses.join(' ');
    }
    render() {
        const buttonAttrs = this.hasChildren ? { 'data-ecl-menu-caret': true } : {};
        return (h("li", Object.assign({ class: this.getClass() }, this.getAttrs()), h("a", { href: this.link, class: this.getLinkClass(), "data-ecl-menu-link": true }, h("slot", null), this.external ?
            h("ecl-icon", { icon: "external", size: "xs", theme: this.theme, styleClass: `sc-ecl-icon-${this.theme} sc-ecl-menu-${this.theme} ecl-menu__link-icon--external ${this.child ? 'ecl-menu__sublink-icon' : 'ecl-menu__link-icon'}` }) : ''), this.hasChildren ?
            h("ecl-button", Object.assign({ styleClass: `ecl-menu__button-caret sc-ecl-menu-${this.theme}`, type: "button", theme: this.theme, variant: "ghost" }, buttonAttrs), h("ecl-icon", { icon: "corner-arrow", size: "xs", transform: "rotate-180", slot: "icon-after", theme: this.theme, styleClass: `sc-ecl-icon-${this.theme} sc-ecl-menu-${this.theme}` })) : '', this.hasChildren ?
            h("div", { class: `ecl-menu__mega sc-ecl-menu-${this.theme}`, "data-ecl-menu-mega": true }, h("ul", { class: `ecl-menu__sublist sc-ecl-menu-${this.theme}` }, h("slot", { name: "sublist" }))) : ''));
    }
    get el() { return getElement(this); }
};

export { EclMenuItem as ecl_menu_item };

//# sourceMappingURL=ecl-menu-item.entry.js.map