import { h } from "@stencil/core";
import { getInitiallySelectedItems } from "../utils";
export class FilterAccordion {
    constructor() {
        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: '70376ec184dcd378c6c595d5b30cdb82c8082de6', class: `accordion ${this.expanded ? 'expanded' : ''}` }, h("div", { key: 'c056174028a70bb2f4e28ced5dd81dca18f1a395', class: `header ${this.expanded ? 'expanded' : ''}`, onClick: this.toggleAccordion }, h("div", { key: 'dcdce6679b05c5acad3ba2216270564ea41cc451', class: `text-and-icon ${this.expanded ? 'expanded' : ''}` }, h("div", { key: '49c6ebef37a4b6798210425c694b4ade083a8216', class: "text" }, h("span", { key: 'd027e2e2cc48441b93d490321ac1b5cb2e8d8103' }, this.filterGroupName), h("ifx-indicator", { key: 'b9c83f3318aadd8c25a232233a83448713c80495', variant: 'number', number: this.count })), h("ifx-icon", { key: 'e4759317302f8f4c876a4f9bb87f1295b816a8a4', class: this.expanded ? '' : 'hidden', icon: "minus-16", onClick: this.toggleAccordion }), h("ifx-icon", { key: '4eb6119e32b9b8871d2b1f77d362499e6d9948ce', class: this.expanded ? 'hidden' : '', icon: "plus-16", onClick: this.toggleAccordion }))), this.expanded &&
            h("div", { key: '833bcbac536f4d39419682e217f1c398c43b8e3b', class: "filter-accordion-container" }, h("slot", { key: '9b6fd50774992f88098423ca1ff8e91587bae9b6', 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",
                "attribute": "max-visible-items",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "filterGroupName": {
                "type": "string",
                "attribute": "filter-group-name",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "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
