import { h, } from "@stencil/core";
import { getInitiallySelectedItems } from "../utils";
export class FilterAccordion {
    initialized = false;
    el;
    expanded = false;
    maxVisibleItems;
    count = 0;
    totalItems = 0;
    filterGroupName = "";
    ifxFilterAccordionChange;
    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
        }
    }
    handleCheckedChange = (event) => {
        const selectedItems = event.detail.selectedItems;
        this.count = selectedItems.length;
        this.ifxFilterAccordionChange.emit({
            filterGroupName: this.filterGroupName,
            selectedItems,
        });
    };
    disconnectedCallback() {
        this.el.removeEventListener("ifxListUpdate", this.handleCheckedChange);
    }
    toggleAccordion = (event) => {
        event.stopPropagation();
        this.expanded = !this.expanded;
    };
    render() {
        return (h("div", { key: 'be328324ef844c69ff554dfff6b46ed1961cf40a', class: `accordion ${this.expanded ? "expanded" : ""}` }, h("div", { key: '287a3b866d340ae41c768351fdfeaf6252eaf80e', class: `header ${this.expanded ? "expanded" : ""}`, onClick: this.toggleAccordion }, h("div", { key: 'd7b9ca315a87219312695915a7ce36220c4f28be', class: `text-and-icon ${this.expanded ? "expanded" : ""}` }, h("div", { key: 'f810c8079bc7af490cc273e7d2f3a18f3080cd44', class: "text" }, h("span", { key: 'd6f1addaefd9c42a78380d7fb8f9c790ae375096' }, this.filterGroupName), h("ifx-indicator", { key: '437405d71307200633a421d2cea773741f2c1220', variant: "number", number: this.count })), h("ifx-icon", { key: '3a2b72d74688d9ec37ff2b70f42d54794f5f0987', class: this.expanded ? "" : "hidden", icon: "minus-16", onClick: this.toggleAccordion }), h("ifx-icon", { key: '20af9c2c8e3b7ed3164385958114d08093fc38bb', class: this.expanded ? "hidden" : "", icon: "plus-16", onClick: this.toggleAccordion }))), this.expanded && (h("div", { key: 'ac85b656a1df3b8a2c229ce00f70974f6e694f6b', class: "filter-accordion-container" }, h("slot", { key: '06606c2914759f180b22554dfc76394c823144f6', name: "list" })))));
    }
    static get is() { return "ifx-filter-accordion"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["filter-accordion.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["filter-accordion.css"]
        };
    }
    static get properties() {
        return {
            "maxVisibleItems": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "max-visible-items"
            },
            "filterGroupName": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "\"\"",
                    "resolved": "\"\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "filter-group-name",
                "defaultValue": "\"\""
            }
        };
    }
    static get states() {
        return {
            "expanded": {},
            "count": {},
            "totalItems": {}
        };
    }
    static get events() {
        return [{
                "method": "ifxFilterAccordionChange",
                "name": "ifxFilterAccordionChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }];
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=filter-accordion.js.map
