import { __esDecorate, __runInitializers } from 'tslib';
import * as i0 from '@angular/core';
import { inject, ChangeDetectorRef, booleanAttribute, Input, ViewEncapsulation, Component, NgZone, DestroyRef, input, output, linkedSignal, viewChild, ElementRef, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { filter } from 'rxjs/operators';
import { NzAnimationCollapseDirective } from 'ng-zorro-antd/core/animation';
import { WithConfig, onConfigChangeEventForComponent } from 'ng-zorro-antd/core/config';
import * as i1 from 'ng-zorro-antd/core/outlet';
import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
import { fromEventOutsideAngular } from 'ng-zorro-antd/core/util';
import * as i2 from 'ng-zorro-antd/icon';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { Directionality } from '@angular/cdk/bidi';

const NZ_CONFIG_MODULE_NAME$1 = 'collapse';
let NzCollapseComponent = (() => {
    let _nzAccordion_decorators;
    let _nzAccordion_initializers = [];
    let _nzAccordion_extraInitializers = [];
    let _nzBordered_decorators;
    let _nzBordered_initializers = [];
    let _nzBordered_extraInitializers = [];
    let _nzGhost_decorators;
    let _nzGhost_initializers = [];
    let _nzGhost_extraInitializers = [];
    return class NzCollapseComponent {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
            _nzAccordion_decorators = [WithConfig()];
            _nzBordered_decorators = [WithConfig()];
            _nzGhost_decorators = [WithConfig()];
            __esDecorate(null, null, _nzAccordion_decorators, { kind: "field", name: "nzAccordion", static: false, private: false, access: { has: obj => "nzAccordion" in obj, get: obj => obj.nzAccordion, set: (obj, value) => { obj.nzAccordion = value; } }, metadata: _metadata }, _nzAccordion_initializers, _nzAccordion_extraInitializers);
            __esDecorate(null, null, _nzBordered_decorators, { kind: "field", name: "nzBordered", static: false, private: false, access: { has: obj => "nzBordered" in obj, get: obj => obj.nzBordered, set: (obj, value) => { obj.nzBordered = value; } }, metadata: _metadata }, _nzBordered_initializers, _nzBordered_extraInitializers);
            __esDecorate(null, null, _nzGhost_decorators, { kind: "field", name: "nzGhost", static: false, private: false, access: { has: obj => "nzGhost" in obj, get: obj => obj.nzGhost, set: (obj, value) => { obj.nzGhost = value; } }, metadata: _metadata }, _nzGhost_initializers, _nzGhost_extraInitializers);
            if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        cdr = inject(ChangeDetectorRef);
        dir = inject(Directionality).valueSignal;
        _nzModuleName = NZ_CONFIG_MODULE_NAME$1;
        nzAccordion = __runInitializers(this, _nzAccordion_initializers, false);
        nzBordered = (__runInitializers(this, _nzAccordion_extraInitializers), __runInitializers(this, _nzBordered_initializers, true));
        nzGhost = (__runInitializers(this, _nzBordered_extraInitializers), __runInitializers(this, _nzGhost_initializers, false));
        nzExpandIconPosition = (__runInitializers(this, _nzGhost_extraInitializers), 'start');
        nzSize = 'middle';
        listOfNzCollapsePanelComponent = [];
        constructor() {
            onConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME$1, () => this.cdr.markForCheck());
        }
        addPanel(value) {
            this.listOfNzCollapsePanelComponent.push(value);
        }
        removePanel(value) {
            this.listOfNzCollapsePanelComponent.splice(this.listOfNzCollapsePanelComponent.indexOf(value), 1);
        }
        click(collapse) {
            const active = collapse.active();
            // if accordion mode, close all panels except the clicked one
            if (this.nzAccordion && !active) {
                this.listOfNzCollapsePanelComponent
                    .filter(item => item !== collapse && item.active())
                    .forEach(item => item.activate(false));
            }
            collapse.activate(!active);
        }
        static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NzCollapseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
        static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "22.0.6", type: NzCollapseComponent, isStandalone: true, selector: "nz-collapse", inputs: { nzAccordion: ["nzAccordion", "nzAccordion", booleanAttribute], nzBordered: ["nzBordered", "nzBordered", booleanAttribute], nzGhost: ["nzGhost", "nzGhost", booleanAttribute], nzExpandIconPosition: "nzExpandIconPosition", nzSize: "nzSize" }, host: { properties: { "class.ant-collapse-icon-placement-start": "nzExpandIconPosition === 'start'", "class.ant-collapse-icon-placement-end": "nzExpandIconPosition === 'end'", "class.ant-collapse-ghost": "nzGhost", "class.ant-collapse-borderless": "!nzBordered", "class.ant-collapse-rtl": "dir() === 'rtl'", "class.ant-collapse-small": "nzSize === 'small'", "class.ant-collapse-large": "nzSize === 'large'" }, classAttribute: "ant-collapse" }, exportAs: ["nzCollapse"], ngImport: i0, template: `<ng-content />`, isInline: true, encapsulation: i0.ViewEncapsulation.None });
    };
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NzCollapseComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'nz-collapse',
                    exportAs: 'nzCollapse',
                    encapsulation: ViewEncapsulation.None,
                    template: `<ng-content />`,
                    host: {
                        class: 'ant-collapse',
                        '[class.ant-collapse-icon-placement-start]': `nzExpandIconPosition === 'start'`,
                        '[class.ant-collapse-icon-placement-end]': `nzExpandIconPosition === 'end'`,
                        '[class.ant-collapse-ghost]': `nzGhost`,
                        '[class.ant-collapse-borderless]': '!nzBordered',
                        '[class.ant-collapse-rtl]': `dir() === 'rtl'`,
                        '[class.ant-collapse-small]': `nzSize === 'small'`,
                        '[class.ant-collapse-large]': `nzSize === 'large'`
                    }
                }]
        }], ctorParameters: () => [], propDecorators: { nzAccordion: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], nzBordered: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], nzGhost: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], nzExpandIconPosition: [{
                type: Input
            }], nzSize: [{
                type: Input
            }] } });

const NZ_CONFIG_MODULE_NAME = 'collapsePanel';
let NzCollapsePanelComponent = (() => {
    let _nzShowArrow_decorators;
    let _nzShowArrow_initializers = [];
    let _nzShowArrow_extraInitializers = [];
    return class NzCollapsePanelComponent {
        static {
            const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
            _nzShowArrow_decorators = [WithConfig()];
            __esDecorate(null, null, _nzShowArrow_decorators, { kind: "field", name: "nzShowArrow", static: false, private: false, access: { has: obj => "nzShowArrow" in obj, get: obj => obj.nzShowArrow, set: (obj, value) => { obj.nzShowArrow = value; } }, metadata: _metadata }, _nzShowArrow_initializers, _nzShowArrow_extraInitializers);
            if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
        }
        ngZone = inject(NgZone);
        cdr = inject(ChangeDetectorRef);
        destroyRef = inject(DestroyRef);
        nzCollapseComponent = inject(NzCollapseComponent, { host: true });
        _nzModuleName = NZ_CONFIG_MODULE_NAME;
        nzActive = input(false, { ...(ngDevMode ? { debugName: "nzActive" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
        nzShowArrow = __runInitializers(this, _nzShowArrow_initializers, true);
        nzExtra = __runInitializers(this, _nzShowArrow_extraInitializers);
        nzHeader;
        nzExpandedIcon;
        nzCollapsible;
        nzActiveChange = output();
        get disabled() {
            return this.nzCollapsible === 'disabled';
        }
        /**
         * @description Actual active state of the panel.
         */
        active = linkedSignal(() => this.nzActive(), /* @ts-ignore */
        ...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
        collapseHeader = viewChild.required('collapseHeader', { ...(ngDevMode ? { debugName: "collapseHeader" } : /* istanbul ignore next */ {}), read: ElementRef });
        collapseIcon = viewChild('collapseIcon', { ...(ngDevMode ? { debugName: "collapseIcon" } : /* istanbul ignore next */ {}), read: ElementRef });
        constructor() {
            onConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME, () => this.cdr.markForCheck());
            this.nzCollapseComponent.addPanel(this);
            this.destroyRef.onDestroy(() => {
                this.nzCollapseComponent.removePanel(this);
            });
        }
        ngAfterViewInit() {
            const icon = this.collapseIcon();
            const header = this.collapseHeader();
            const element = this.nzShowArrow && this.nzCollapsible === 'icon' && icon
                ? icon.nativeElement
                : header.nativeElement;
            fromEventOutsideAngular(element, 'click')
                .pipe(filter(() => !this.disabled), takeUntilDestroyed(this.destroyRef))
                .subscribe(() => {
                this.ngZone.run(() => {
                    this.nzCollapseComponent.click(this);
                });
            });
        }
        activate(active) {
            this.active.set(active);
            this.nzActiveChange.emit(active);
        }
        static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NzCollapsePanelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
        static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: NzCollapsePanelComponent, isStandalone: true, selector: "nz-collapse-panel", inputs: { nzActive: { classPropertyName: "nzActive", publicName: "nzActive", isSignal: true, isRequired: false, transformFunction: null }, nzShowArrow: { classPropertyName: "nzShowArrow", publicName: "nzShowArrow", isSignal: false, isRequired: false, transformFunction: booleanAttribute }, nzExtra: { classPropertyName: "nzExtra", publicName: "nzExtra", isSignal: false, isRequired: false, transformFunction: null }, nzHeader: { classPropertyName: "nzHeader", publicName: "nzHeader", isSignal: false, isRequired: false, transformFunction: null }, nzExpandedIcon: { classPropertyName: "nzExpandedIcon", publicName: "nzExpandedIcon", isSignal: false, isRequired: false, transformFunction: null }, nzCollapsible: { classPropertyName: "nzCollapsible", publicName: "nzCollapsible", isSignal: false, isRequired: false, transformFunction: null } }, outputs: { nzActiveChange: "nzActiveChange" }, host: { properties: { "class.ant-collapse-no-arrow": "!nzShowArrow", "class.ant-collapse-item-active": "active()", "class.ant-collapse-item-disabled": "disabled" }, classAttribute: "ant-collapse-item" }, viewQueries: [{ propertyName: "collapseHeader", first: true, predicate: ["collapseHeader"], descendants: true, read: ElementRef, isSignal: true }, { propertyName: "collapseIcon", first: true, predicate: ["collapseIcon"], descendants: true, read: ElementRef, isSignal: true }], exportAs: ["nzCollapsePanel"], ngImport: i0, template: `
    <div
      #collapseHeader
      role="button"
      [attr.aria-expanded]="active()"
      [attr.aria-disabled]="disabled"
      [attr.tabindex]="disabled ? -1 : 0"
      class="ant-collapse-header"
      [class.ant-collapse-collapsible-icon]="nzCollapsible === 'icon'"
      [class.ant-collapse-collapsible-header]="nzCollapsible === 'header'"
    >
      @if (nzShowArrow) {
        <div role="button" #collapseIcon class="ant-collapse-expand-icon">
          <ng-container *nzStringTemplateOutlet="nzExpandedIcon; let expandedIcon">
            <nz-icon [nzType]="expandedIcon || 'right'" class="ant-collapse-arrow" [nzRotate]="active() ? 90 : 0" />
          </ng-container>
        </div>
      }
      <span class="ant-collapse-title">
        <ng-container *nzStringTemplateOutlet="nzHeader">{{ nzHeader }}</ng-container>
      </span>
      @if (nzExtra) {
        <div class="ant-collapse-extra">
          <ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>
        </div>
      }
    </div>
    <div
      class="ant-collapse-panel"
      [class.ant-collapse-panel-active]="active()"
      animation-collapse
      [open]="active()"
      leavedClassName="ant-collapse-panel-hidden"
    >
      <div class="ant-collapse-body">
        <ng-content />
      </div>
    </div>
  `, isInline: true, dependencies: [{ kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i1.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzType", "nzTheme", "nzTwotoneColor", "nzSpin", "nzRotate", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "directive", type: NzAnimationCollapseDirective, selector: "[animation-collapse]", inputs: ["open", "leavedClassName"] }], encapsulation: i0.ViewEncapsulation.None });
    };
})();
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NzCollapsePanelComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'nz-collapse-panel',
                    exportAs: 'nzCollapsePanel',
                    encapsulation: ViewEncapsulation.None,
                    template: `
    <div
      #collapseHeader
      role="button"
      [attr.aria-expanded]="active()"
      [attr.aria-disabled]="disabled"
      [attr.tabindex]="disabled ? -1 : 0"
      class="ant-collapse-header"
      [class.ant-collapse-collapsible-icon]="nzCollapsible === 'icon'"
      [class.ant-collapse-collapsible-header]="nzCollapsible === 'header'"
    >
      @if (nzShowArrow) {
        <div role="button" #collapseIcon class="ant-collapse-expand-icon">
          <ng-container *nzStringTemplateOutlet="nzExpandedIcon; let expandedIcon">
            <nz-icon [nzType]="expandedIcon || 'right'" class="ant-collapse-arrow" [nzRotate]="active() ? 90 : 0" />
          </ng-container>
        </div>
      }
      <span class="ant-collapse-title">
        <ng-container *nzStringTemplateOutlet="nzHeader">{{ nzHeader }}</ng-container>
      </span>
      @if (nzExtra) {
        <div class="ant-collapse-extra">
          <ng-container *nzStringTemplateOutlet="nzExtra">{{ nzExtra }}</ng-container>
        </div>
      }
    </div>
    <div
      class="ant-collapse-panel"
      [class.ant-collapse-panel-active]="active()"
      animation-collapse
      [open]="active()"
      leavedClassName="ant-collapse-panel-hidden"
    >
      <div class="ant-collapse-body">
        <ng-content />
      </div>
    </div>
  `,
                    host: {
                        class: 'ant-collapse-item',
                        '[class.ant-collapse-no-arrow]': '!nzShowArrow',
                        '[class.ant-collapse-item-active]': 'active()',
                        '[class.ant-collapse-item-disabled]': `disabled`
                    },
                    imports: [NzOutletModule, NzIconModule, NzAnimationCollapseDirective]
                }]
        }], ctorParameters: () => [], propDecorators: { nzActive: [{ type: i0.Input, args: [{ isSignal: true, alias: "nzActive", required: false }] }], nzShowArrow: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], nzExtra: [{
                type: Input
            }], nzHeader: [{
                type: Input
            }], nzExpandedIcon: [{
                type: Input
            }], nzCollapsible: [{
                type: Input
            }], nzActiveChange: [{ type: i0.Output, args: ["nzActiveChange"] }], collapseHeader: [{ type: i0.ViewChild, args: ['collapseHeader', { ...{ read: ElementRef }, isSignal: true }] }], collapseIcon: [{ type: i0.ViewChild, args: ['collapseIcon', { ...{ read: ElementRef }, isSignal: true }] }] } });

/**
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
 */
class NzCollapseModule {
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NzCollapseModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
    static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.6", ngImport: i0, type: NzCollapseModule, imports: [NzCollapsePanelComponent, NzCollapseComponent], exports: [NzCollapsePanelComponent, NzCollapseComponent] });
    static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NzCollapseModule, imports: [NzCollapsePanelComponent] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: NzCollapseModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [NzCollapsePanelComponent, NzCollapseComponent],
                    exports: [NzCollapsePanelComponent, NzCollapseComponent]
                }]
        }] });

/**
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
 */

/**
 * Generated bundle index. Do not edit.
 */

export { NzCollapseComponent, NzCollapseModule, NzCollapsePanelComponent };
//# sourceMappingURL=ng-zorro-antd-collapse.mjs.map
