import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from "@angular/core";
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "../../../../../../common/menu-item-actions/menu-item-actions.directive";
import * as i3 from "../../../../../../common/is-visible-pipe/is-visible.pipe";
import * as i4 from "./pipes/has-child.pipe";
export class AthenaProfileMenuItemsComponent {
    constructor(_eref) {
        this._eref = _eref;
        this.collapse = new EventEmitter();
        this.isLoaded = false;
        this.isAnyMenuExpanded = false;
    }
    ngOnInit() {
    }
    ngAfterViewInit() {
        setTimeout(() => {
            this.isLoaded = true;
        }, 0);
    }
    toogleOnly(item, menu) {
        this.collapseAll(menu);
        item.expanded = !item.expanded;
        this.isAnyMenuExpanded = item.expanded;
    }
    collapseAll(menu) {
        menu.forEach(x => {
            x.expanded = false;
            if (x.items != null && x.items.length > 0) {
                this.collapseAll(x.items);
            }
        });
        this.isAnyMenuExpanded = false;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: AthenaProfileMenuItemsComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.5", type: AthenaProfileMenuItemsComponent, selector: "[smz-ui-athena-profile-menu-items]", inputs: { items: "items" }, outputs: { collapse: "collapse" }, ngImport: i0, template: `
    <li *ngFor="let item of items | isVisible; let index = index" [ngClass]="{ 'menuitem-active' : item.expanded }">

      <ng-container [ngSwitch]="item | hasChild">

        <ng-container *ngSwitchCase="false">
          <a menuItemAction [item]="item" [parent]="null" [breadcrumbs]="false" [tabindex]="index" class="clickable" (collapse)="collapse.emit()">
            <i *ngIf="item.icon != null" class="topbar-icon" [ngClass]="item.icon"></i>
            <span class="topbar-item-name" [innerHtml]="item.label"></span>
            <span *ngIf="item.badge != null" class="topbar-badge">{{ item.badge }}</span>
          </a>
        </ng-container>

        <ng-container *ngSwitchCase="true">
          <a [tabindex]="index" class="clickable" (click)="toogleOnly(item, item.items)">
            <i *ngIf="item.icon != null" class="topbar-icon" [ngClass]="item.icon"></i>
            <span class="topbar-item-name" [innerHtml]="item.label"></span>
            <span *ngIf="item.badge != null" class="topbar-badge">{{ item.badge }}</span>
          </a>
          <ul *ngIf="item.expanded" smz-ui-athena-profile-menu-items [items]="item.items"></ul>
        </ng-container>

      </ng-container>

    </li>
  `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i2.MenuItemActionsDirective, selector: "[menuItemAction]", inputs: ["item", "parent", "breadcrumbs"], outputs: ["collapse"] }, { kind: "component", type: AthenaProfileMenuItemsComponent, selector: "[smz-ui-athena-profile-menu-items]", inputs: ["items"], outputs: ["collapse"] }, { kind: "pipe", type: i3.IsVisiblePipe, name: "isVisible" }, { kind: "pipe", type: i4.HasChildPipe, name: "hasChild" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: AthenaProfileMenuItemsComponent, decorators: [{
            type: Component,
            args: [{
                    selector: "[smz-ui-athena-profile-menu-items]",
                    changeDetection: ChangeDetectionStrategy.OnPush,
                    template: `
    <li *ngFor="let item of items | isVisible; let index = index" [ngClass]="{ 'menuitem-active' : item.expanded }">

      <ng-container [ngSwitch]="item | hasChild">

        <ng-container *ngSwitchCase="false">
          <a menuItemAction [item]="item" [parent]="null" [breadcrumbs]="false" [tabindex]="index" class="clickable" (collapse)="collapse.emit()">
            <i *ngIf="item.icon != null" class="topbar-icon" [ngClass]="item.icon"></i>
            <span class="topbar-item-name" [innerHtml]="item.label"></span>
            <span *ngIf="item.badge != null" class="topbar-badge">{{ item.badge }}</span>
          </a>
        </ng-container>

        <ng-container *ngSwitchCase="true">
          <a [tabindex]="index" class="clickable" (click)="toogleOnly(item, item.items)">
            <i *ngIf="item.icon != null" class="topbar-icon" [ngClass]="item.icon"></i>
            <span class="topbar-item-name" [innerHtml]="item.label"></span>
            <span *ngIf="item.badge != null" class="topbar-badge">{{ item.badge }}</span>
          </a>
          <ul *ngIf="item.expanded" smz-ui-athena-profile-menu-items [items]="item.items"></ul>
        </ng-container>

      </ng-container>

    </li>
  `,
                }]
        }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { items: [{
                type: Input
            }], collapse: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 