export class ExclusiveDetails {
    constructor(selector) {
        this.detailsElements = document.querySelectorAll(selector);
        this.bindEvents();
    }
    bindEvents() {
        this.detailsElements.forEach((details) => {
            details.addEventListener('click', (e) => this.handleDetailsClick(e, details));
        });
        document.addEventListener('click', (e) => this.handleClickOutside(e));
    }
    handleDetailsClick(event, details) {
        event.stopPropagation();
        this.detailsElements.forEach((otherDetails) => {
            if (otherDetails !== details) {
                otherDetails.removeAttribute('open');
            }
        });
    }
    handleClickOutside(event) {
        const target = event.target;
        const isClickInside = Array.from(this.detailsElements).some((details) => details.contains(target));
        if (!isClickInside) {
            this.closeAll();
        }
    }
    closeAll() {
        this.detailsElements.forEach((details) => {
            details.removeAttribute('open');
        });
    }
}
//# sourceMappingURL=ExclusiveDetails.js.map