import { p as proxyCustomElement, H, c as createEvent, h } from './index.js';
import { d as defineCustomElement$3 } from './p-DhNY6ZGA.js';
import { d as defineCustomElement$2 } from './p-BxahGQyq.js';

// utils.ts
function getInitiallySelectedItems(el) {
    return Array.from(el.querySelectorAll('ifx-list-entry'))
        .filter(entry => entry.getAttribute('value') === 'true')
        .map(entry => {
        return {
            label: entry.getAttribute('label'),
            value: entry.getAttribute('value'),
            type: entry.getAttribute('type')
        };
    });
}

const filterAccordionCss = ".header{display:flex;align-items:flex-start;align-self:stretch;cursor:pointer;border-left:3px solid transparent}.text-and-icon{display:flex;padding:12px 16px 12px 20px;align-items:center;gap:16px;flex:1 0 0}.header.expanded{border-left:3px solid #0A8276}.text{display:flex;align-items:center;gap:8px;flex:1 0 0;color:#1D1D1D;font-size:16px;font-style:normal;font-weight:600;line-height:24px}.hidden{display:none}.accordion{border-bottom:1px solid #EEEDED}.filter-accordion-container{display:flex;padding:8px 16px 16px 20px;flex-direction:column;align-items:flex-start;gap:12px;align-self:stretch;border-left:3px solid #0A8276}::slotted(ifx-filter-entry:nth-child(n+7)){display:none}.link{display:flex;align-items:center;gap:8px}.show-more ::slotted(ifx-filter-entry:nth-child(n+7)){display:block}.show-more .show-more-link{display:none}";

const FilterAccordion = /*@__PURE__*/ proxyCustomElement(class FilterAccordion extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.ifxFilterAccordionChange = createEvent(this, "ifxFilterAccordionChange", 7);
        this.initialized = false;
        this.expanded = false;
        this.count = 0;
        this.totalItems = 0;
        this.filterGroupName = "";
        this.handleCheckedChange = (event) => {
            const selectedItems = event.detail.selectedItems;
            this.count = selectedItems.length;
            this.ifxFilterAccordionChange.emit({ filterGroupName: this.filterGroupName, selectedItems });
        };
        this.toggleAccordion = (event) => {
            event.stopPropagation();
            this.expanded = !this.expanded;
        };
    }
    componentWillLoad() {
        this.el.addEventListener('ifxListUpdate', this.handleCheckedChange);
    }
    componentDidLoad() {
        if (!this.initialized) {
            const selectedItems = getInitiallySelectedItems(this.el);
            this.count = selectedItems.length;
            this.initialized = true; // Prevent further execution in future calls
        }
    }
    componentWillUnload() {
        this.el.removeEventListener('ifxListUpdate', this.handleCheckedChange);
    }
    render() {
        return (h("div", { key: '6cbfe75fad6e0ca5809f3094ea6357a896e5c02f', class: `accordion ${this.expanded ? 'expanded' : ''}` }, h("div", { key: 'a9aba4373768d85837132a3bf984033ab80e2fd8', class: `header ${this.expanded ? 'expanded' : ''}`, onClick: this.toggleAccordion }, h("div", { key: '9bbfa75f1d6b55c6f14b4934d0cf9906120075d2', class: `text-and-icon ${this.expanded ? 'expanded' : ''}` }, h("div", { key: 'd7775c4c711efd6d00f8ef8f384e49f0554fb74b', class: "text" }, h("span", { key: 'b11e0152875bf988e8a6cf36909cf5b839d560ac' }, this.filterGroupName), h("ifx-indicator", { key: 'a3abb8630d0069b2fa98293c1cb76ae7172b73ab', variant: 'number', number: this.count })), h("ifx-icon", { key: '94e6aa786f4a1ecb8322fb22edd9948c2d41857b', class: this.expanded ? '' : 'hidden', icon: "minus-16", onClick: this.toggleAccordion }), h("ifx-icon", { key: '8edeb3a9686adf291a52aff6a57d3af10c83d5c9', class: this.expanded ? 'hidden' : '', icon: "plus-16", onClick: this.toggleAccordion }))), this.expanded &&
            h("div", { key: 'c557ca1e3aa2ef881425bb475166c2d49be0758f', class: "filter-accordion-container" }, h("slot", { key: '21f27e28cbd82d95dd3722067034c8f1866f1766', name: "list" }))));
    }
    get el() { return this; }
    static get style() { return filterAccordionCss; }
}, [257, "ifx-filter-accordion", {
        "maxVisibleItems": [2, "max-visible-items"],
        "filterGroupName": [1, "filter-group-name"],
        "expanded": [32],
        "count": [32],
        "totalItems": [32]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["ifx-filter-accordion", "ifx-icon", "ifx-indicator"];
    components.forEach(tagName => { switch (tagName) {
        case "ifx-filter-accordion":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, FilterAccordion);
            }
            break;
        case "ifx-icon":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "ifx-indicator":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
    } });
}

const IfxFilterAccordion = FilterAccordion;
const defineCustomElement = defineCustomElement$1;

export { IfxFilterAccordion, defineCustomElement };
//# sourceMappingURL=ifx-filter-accordion.js.map

//# sourceMappingURL=ifx-filter-accordion.js.map