import { __decorate } from "tslib";
import { Component, ContentChildren, Input } from '@angular/core';
import { Select } from '@ngxs/store';
import { UntilDestroy } from '@ngneat/until-destroy';
import { PrimeTemplate } from 'primeng/api';
import { LayoutUiSelectors } from '../../../../../../state/ui/layout/layout.selectors';
import { RouterState } from '@ngxs/router-plugin';
import { UiHephaestusSelectors } from '../../state/ui-layout.selectors';
import { MenuType } from '../../../../core/models/menu-types';
import { GlobalInjector } from '../../../../../../common/services/global-injector';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/router";
import * as i3 from "../../../../../../common/menu-item-actions/menu-item-actions.directive";
import * as i4 from "./components/menu.component";
import * as i5 from "../../../../../../common/is-visible-pipe/is-visible.pipe";
import * as i6 from "../../../../../../common/url-checker/url-checker.pipe";
let HephaestusSidebarComponent = class HephaestusSidebarComponent {
    constructor() {
        this.isAnyMenuExpanded = false;
        this.menuType = MenuType;
        this.uiConfig = GlobalInjector.config;
    }
    ngAfterContentInit() {
        this.templates.forEach((item) => {
            switch (item.getType()) {
                case 'headerExtras':
                    this.headerExtrasTemplate = item.template;
                    break;
            }
        });
    }
    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;
    }
    isCurrentRoute(routerUrl, routerLink) {
        const currentPath = routerLink.join('/');
        return `/${currentPath}` == routerUrl;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: HephaestusSidebarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.5", type: HephaestusSidebarComponent, selector: "smz-ui-hephaestus-sidebar", inputs: { menu: "menu" }, host: { classAttribute: "z-30" }, queries: [{ propertyName: "templates", predicate: PrimeTemplate }], ngImport: i0, template: "<ng-container *ngIf=\"layout$ | async as layout\">\r\n<ng-container *ngIf=\"appName$ | async as appName\">\r\n<ng-container *ngIf=\"(currentRoute$ | async) as route\">\r\n\r\n    <div class=\"layout-sidebar\" (mouseleave)=\"collapseAll(menu)\">\r\n\r\n        <ng-container *ngIf=\"(appLayoutLogo$ | async) as appLayoutLogo\">\r\n\r\n            <!-- LOGO EM FORMATO DE ICONE -->\r\n            <ng-container *ngIf=\"layout.menu === menuType.SLIM; else elseHeaderTemplate\">\r\n                <a class=\"logo\" [routerLink]=\"uiConfig.rbkUtils.authentication.authenticatedRoot\">\r\n                    <img id=\"app-logo\" [src]=\"appLayoutLogo.icon\" class=\"m-2 slim-mobile-logo\">\r\n                    <span class=\"app-name\">{{ appName }}</span>\r\n                </a>\r\n            </ng-container>\r\n\r\n            <!-- LOGO COMPLETA -->\r\n            <ng-template #elseHeaderTemplate>\r\n                <a class=\"logo\" [routerLink]=\"uiConfig.rbkUtils.authentication.authenticatedRoot\">\r\n                    <img id=\"app-logo\" [src]=\"appLayoutLogo.horizontal\" class=\"pl-4 pr-4\" width=\"100%\">\r\n                </a>\r\n            </ng-template>\r\n\r\n        </ng-container>\r\n\r\n        <!-- INICIO DO MENU -->\r\n        <div class=\"layout-menu-container\">\r\n\r\n            <!-- N\u00CDVEL 1 -->\r\n            <ng-container *ngFor=\"let item of menu | isVisible; let last = last; let itemIndex = index;\">\r\n\r\n                <ul *ngIf=\"layout.menu === menuType.SLIM\" class=\"layout-menu bg-black bg-opacity-20 rounded-md mb-5\">\r\n\r\n                    <ng-container *ngIf=\"item.items == null || item.items.length == 0\">\r\n                        <!-- ACTION -->\r\n                        <li class=\"layout-root-menuitem\" [ngClass]=\"{ 'active-menuitem' : item.expanded }\">\r\n\r\n                            <div class=\"layout-menuitem-root-text pl-4 pt-4\">{{ item.label }}</div>\r\n\r\n                            <a class=\"hover:shadow-none\" [tabindex]=\"itemIndex\" menuItemAction [item]=\"item\" [parent]=\"null\" [breadcrumbs]=\"true\" [ngClass]=\"{ 'active-first-route': route.url | urlChecker : item.routerLink }\">\r\n                                <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\r\n                                <span class=\"layout-menuitem-text\">{{ item.label }}</span>\r\n                                <i class=\"pi pi-fw pi-chevron-down layout-submenu-toggler\"></i>\r\n                                <span class=\"p-ink\"></span>\r\n                            </a>\r\n                        </li>\r\n                    </ng-container>\r\n\r\n                    <ng-container *ngIf=\"item.items?.length > 0\">\r\n                        <!-- CAPTION -->\r\n                        <li class=\"layout-root-menuitem\" [ngClass]=\"{ 'active-menuitem' : item.expanded }\">\r\n                            <div class=\"layout-menuitem-root-text pl-4 pt-4\">{{ item.label }}</div>\r\n\r\n                            <a [tabindex]=\"itemIndex\" class=\"select-none hover:bg-inherit hover:shadow-none cursor-default\">\r\n                                <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\r\n                                <span class=\"layout-menuitem-text break-words uppercase font-bold\">{{ item.label }}</span>\r\n                            </a>\r\n                        </li>\r\n\r\n                        <li class=\"menu-separator m-0\"></li>\r\n                    </ng-container>\r\n\r\n                    <ng-container *ngFor=\"let subItem of item.items | isVisible; let lastSubItem = last; let subItemIndex = index;\">\r\n                        <!-- ACTION GROUP -->\r\n                        <li class=\"layout-root-menuitem\" [ngClass]=\"{ 'active-menuitem' : subItem.expanded }\">\r\n                            <div class=\"layout-menuitem-root-text normal-case\">{{ subItem.label }}</div>\r\n\r\n                            <a class=\"hover:shadow-none\" [tabindex]=\"subItemIndex\" menuItemAction [item]=\"subItem\" [parent]=\"null\" [breadcrumbs]=\"true\" [ngClass]=\"{ 'active-first-route': route.url | urlChecker : subItem.routerLink }\">\r\n                                <i class=\"layout-menuitem-icon\" [ngClass]=\"subItem.icon\"></i>\r\n                                <span class=\"layout-menuitem-text break-words\">{{ subItem.label }}</span>\r\n                            </a>\r\n                        </li>\r\n\r\n                    </ng-container>\r\n\r\n                </ul>\r\n\r\n            </ng-container>\r\n\r\n            <ul *ngIf=\"layout.menu !== menuType.SLIM\" class=\"layout-menu\">\r\n\r\n                <!-- N\u00CDVEL 1 -->\r\n                <ng-container *ngFor=\"let item of menu | isVisible; let last = last; let itemIndex = index;\">\r\n                    <li class=\"layout-root-menuitem\" [ngClass]=\"{ 'active-menuitem' : item.expanded }\">\r\n\r\n                        <!-- CABE\u00C7ALHO DO N\u00CDVEL 1 -->\r\n                        <div *ngIf=\"!$any(item).showAsCaption\" class=\"layout-menuitem-root-text\">{{ item.label }}</div>\r\n                        <div *ngIf=\"$any(item).showAsCaption\" class=\"layout-menuitem-root-text cursor-default bg-black bg-opacity-20\">{{ item.label }}</div>\r\n\r\n                        <!-- ITENS PARA O MENU COLAPSADO -->\r\n                        <a *ngIf=\"item.command == null && item.routerLink == null && !$any(item).showAsCaption\" class=\"p-ripple\" [tabindex]=\"itemIndex\" (click)=\"toogleOnly(item, menu)\" (mouseover)=\"toogleOnly(item, menu)\">\r\n                            <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\r\n                            <span class=\"layout-menuitem-text\">{{ item.label }}</span>\r\n                            <i class=\"pi pi-fw pi-chevron-down layout-submenu-toggler\"></i>\r\n                            <span class=\"p-ink\"></span>\r\n                        </a>\r\n\r\n                        <a *ngIf=\"$any(item).showAsCaption\" class=\"cursor-default bg-black bg-opacity-20\" [tabindex]=\"itemIndex\">\r\n                            <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\r\n                            <span class=\"layout-menuitem-text\">{{ item.label }}</span>\r\n                            <i class=\"pi pi-fw pi-chevron-down layout-submenu-toggler\"></i>\r\n                            <span class=\"p-ink\"></span>\r\n                        </a>\r\n\r\n                        <a *ngIf=\"item.command != null || item.routerLink != null && !$any(item).showAsCaption\" class=\"p-ripple\" [tabindex]=\"itemIndex\" menuItemAction [item]=\"item\" [parent]=\"null\" [breadcrumbs]=\"true\" [ngClass]=\"{ 'active-first-route': route.url | urlChecker : item.routerLink }\">\r\n                            <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\r\n                            <span class=\"layout-menuitem-text\">{{ item.label }}</span>\r\n                            <i class=\"pi pi-fw pi-chevron-down layout-submenu-toggler\"></i>\r\n                            <span class=\"p-ink\"></span>\r\n                        </a>\r\n\r\n                        <ng-container *ngIf=\"item.expanded\">\r\n                            <ul smz-ui-hephaestus-menu-slim-node [item]=\"item\" [parent]=\"null\" [currentUrl]=\"route.url\" role=\"menu\" style=\"z-index: 100;\"></ul>\r\n                        </ng-container>\r\n\r\n                        <smz-ui-hephaestus-menu-node [item]=\"item\" [currentUrl]=\"route.url\"></smz-ui-hephaestus-menu-node>\r\n\r\n                    </li>\r\n\r\n                    <li *ngIf=\"!last && !($any(item).hideSeparator)\" class=\"menu-separator\"></li>\r\n                </ng-container>\r\n\r\n            </ul>\r\n        </div>\r\n    </div>\r\n\r\n</ng-container>\r\n</ng-container>\r\n</ng-container>", styles: [".active-first-route{background-color:#ffffff1a}.slim-mobile-logo{max-width:2.5rem;max-height:2.5rem;margin-left:auto!important;margin-right:auto!important}\n"], 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: i2.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: i3.MenuItemActionsDirective, selector: "[menuItemAction]", inputs: ["item", "parent", "breadcrumbs"], outputs: ["collapse"] }, { kind: "component", type: i4.HephaestusMenuNodeComponent, selector: "smz-ui-hephaestus-menu-node", inputs: ["item", "index", "currentUrl"] }, { kind: "component", type: i4.HephaestusMenuSlimNodeComponent, selector: "[smz-ui-hephaestus-menu-slim-node]", inputs: ["item", "parent", "index", "currentUrl"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.IsVisiblePipe, name: "isVisible" }, { kind: "pipe", type: i6.UrlCheckerPipe, name: "urlChecker" }] }); }
};
__decorate([
    Select(UiHephaestusSelectors.layout)
], HephaestusSidebarComponent.prototype, "layout$", void 0);
__decorate([
    Select(LayoutUiSelectors.appName)
], HephaestusSidebarComponent.prototype, "appName$", void 0);
__decorate([
    Select(RouterState.state)
], HephaestusSidebarComponent.prototype, "currentRoute$", void 0);
__decorate([
    Select(LayoutUiSelectors.appDarkLogo)
], HephaestusSidebarComponent.prototype, "appLayoutLogo$", void 0);
HephaestusSidebarComponent = __decorate([
    UntilDestroy()
], HephaestusSidebarComponent);
export { HephaestusSidebarComponent };
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.5", ngImport: i0, type: HephaestusSidebarComponent, decorators: [{
            type: Component,
            args: [{ selector: 'smz-ui-hephaestus-sidebar', host: { 'class': 'z-30' }, template: "<ng-container *ngIf=\"layout$ | async as layout\">\r\n<ng-container *ngIf=\"appName$ | async as appName\">\r\n<ng-container *ngIf=\"(currentRoute$ | async) as route\">\r\n\r\n    <div class=\"layout-sidebar\" (mouseleave)=\"collapseAll(menu)\">\r\n\r\n        <ng-container *ngIf=\"(appLayoutLogo$ | async) as appLayoutLogo\">\r\n\r\n            <!-- LOGO EM FORMATO DE ICONE -->\r\n            <ng-container *ngIf=\"layout.menu === menuType.SLIM; else elseHeaderTemplate\">\r\n                <a class=\"logo\" [routerLink]=\"uiConfig.rbkUtils.authentication.authenticatedRoot\">\r\n                    <img id=\"app-logo\" [src]=\"appLayoutLogo.icon\" class=\"m-2 slim-mobile-logo\">\r\n                    <span class=\"app-name\">{{ appName }}</span>\r\n                </a>\r\n            </ng-container>\r\n\r\n            <!-- LOGO COMPLETA -->\r\n            <ng-template #elseHeaderTemplate>\r\n                <a class=\"logo\" [routerLink]=\"uiConfig.rbkUtils.authentication.authenticatedRoot\">\r\n                    <img id=\"app-logo\" [src]=\"appLayoutLogo.horizontal\" class=\"pl-4 pr-4\" width=\"100%\">\r\n                </a>\r\n            </ng-template>\r\n\r\n        </ng-container>\r\n\r\n        <!-- INICIO DO MENU -->\r\n        <div class=\"layout-menu-container\">\r\n\r\n            <!-- N\u00CDVEL 1 -->\r\n            <ng-container *ngFor=\"let item of menu | isVisible; let last = last; let itemIndex = index;\">\r\n\r\n                <ul *ngIf=\"layout.menu === menuType.SLIM\" class=\"layout-menu bg-black bg-opacity-20 rounded-md mb-5\">\r\n\r\n                    <ng-container *ngIf=\"item.items == null || item.items.length == 0\">\r\n                        <!-- ACTION -->\r\n                        <li class=\"layout-root-menuitem\" [ngClass]=\"{ 'active-menuitem' : item.expanded }\">\r\n\r\n                            <div class=\"layout-menuitem-root-text pl-4 pt-4\">{{ item.label }}</div>\r\n\r\n                            <a class=\"hover:shadow-none\" [tabindex]=\"itemIndex\" menuItemAction [item]=\"item\" [parent]=\"null\" [breadcrumbs]=\"true\" [ngClass]=\"{ 'active-first-route': route.url | urlChecker : item.routerLink }\">\r\n                                <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\r\n                                <span class=\"layout-menuitem-text\">{{ item.label }}</span>\r\n                                <i class=\"pi pi-fw pi-chevron-down layout-submenu-toggler\"></i>\r\n                                <span class=\"p-ink\"></span>\r\n                            </a>\r\n                        </li>\r\n                    </ng-container>\r\n\r\n                    <ng-container *ngIf=\"item.items?.length > 0\">\r\n                        <!-- CAPTION -->\r\n                        <li class=\"layout-root-menuitem\" [ngClass]=\"{ 'active-menuitem' : item.expanded }\">\r\n                            <div class=\"layout-menuitem-root-text pl-4 pt-4\">{{ item.label }}</div>\r\n\r\n                            <a [tabindex]=\"itemIndex\" class=\"select-none hover:bg-inherit hover:shadow-none cursor-default\">\r\n                                <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\r\n                                <span class=\"layout-menuitem-text break-words uppercase font-bold\">{{ item.label }}</span>\r\n                            </a>\r\n                        </li>\r\n\r\n                        <li class=\"menu-separator m-0\"></li>\r\n                    </ng-container>\r\n\r\n                    <ng-container *ngFor=\"let subItem of item.items | isVisible; let lastSubItem = last; let subItemIndex = index;\">\r\n                        <!-- ACTION GROUP -->\r\n                        <li class=\"layout-root-menuitem\" [ngClass]=\"{ 'active-menuitem' : subItem.expanded }\">\r\n                            <div class=\"layout-menuitem-root-text normal-case\">{{ subItem.label }}</div>\r\n\r\n                            <a class=\"hover:shadow-none\" [tabindex]=\"subItemIndex\" menuItemAction [item]=\"subItem\" [parent]=\"null\" [breadcrumbs]=\"true\" [ngClass]=\"{ 'active-first-route': route.url | urlChecker : subItem.routerLink }\">\r\n                                <i class=\"layout-menuitem-icon\" [ngClass]=\"subItem.icon\"></i>\r\n                                <span class=\"layout-menuitem-text break-words\">{{ subItem.label }}</span>\r\n                            </a>\r\n                        </li>\r\n\r\n                    </ng-container>\r\n\r\n                </ul>\r\n\r\n            </ng-container>\r\n\r\n            <ul *ngIf=\"layout.menu !== menuType.SLIM\" class=\"layout-menu\">\r\n\r\n                <!-- N\u00CDVEL 1 -->\r\n                <ng-container *ngFor=\"let item of menu | isVisible; let last = last; let itemIndex = index;\">\r\n                    <li class=\"layout-root-menuitem\" [ngClass]=\"{ 'active-menuitem' : item.expanded }\">\r\n\r\n                        <!-- CABE\u00C7ALHO DO N\u00CDVEL 1 -->\r\n                        <div *ngIf=\"!$any(item).showAsCaption\" class=\"layout-menuitem-root-text\">{{ item.label }}</div>\r\n                        <div *ngIf=\"$any(item).showAsCaption\" class=\"layout-menuitem-root-text cursor-default bg-black bg-opacity-20\">{{ item.label }}</div>\r\n\r\n                        <!-- ITENS PARA O MENU COLAPSADO -->\r\n                        <a *ngIf=\"item.command == null && item.routerLink == null && !$any(item).showAsCaption\" class=\"p-ripple\" [tabindex]=\"itemIndex\" (click)=\"toogleOnly(item, menu)\" (mouseover)=\"toogleOnly(item, menu)\">\r\n                            <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\r\n                            <span class=\"layout-menuitem-text\">{{ item.label }}</span>\r\n                            <i class=\"pi pi-fw pi-chevron-down layout-submenu-toggler\"></i>\r\n                            <span class=\"p-ink\"></span>\r\n                        </a>\r\n\r\n                        <a *ngIf=\"$any(item).showAsCaption\" class=\"cursor-default bg-black bg-opacity-20\" [tabindex]=\"itemIndex\">\r\n                            <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\r\n                            <span class=\"layout-menuitem-text\">{{ item.label }}</span>\r\n                            <i class=\"pi pi-fw pi-chevron-down layout-submenu-toggler\"></i>\r\n                            <span class=\"p-ink\"></span>\r\n                        </a>\r\n\r\n                        <a *ngIf=\"item.command != null || item.routerLink != null && !$any(item).showAsCaption\" class=\"p-ripple\" [tabindex]=\"itemIndex\" menuItemAction [item]=\"item\" [parent]=\"null\" [breadcrumbs]=\"true\" [ngClass]=\"{ 'active-first-route': route.url | urlChecker : item.routerLink }\">\r\n                            <i class=\"layout-menuitem-icon\" [ngClass]=\"item.icon\"></i>\r\n                            <span class=\"layout-menuitem-text\">{{ item.label }}</span>\r\n                            <i class=\"pi pi-fw pi-chevron-down layout-submenu-toggler\"></i>\r\n                            <span class=\"p-ink\"></span>\r\n                        </a>\r\n\r\n                        <ng-container *ngIf=\"item.expanded\">\r\n                            <ul smz-ui-hephaestus-menu-slim-node [item]=\"item\" [parent]=\"null\" [currentUrl]=\"route.url\" role=\"menu\" style=\"z-index: 100;\"></ul>\r\n                        </ng-container>\r\n\r\n                        <smz-ui-hephaestus-menu-node [item]=\"item\" [currentUrl]=\"route.url\"></smz-ui-hephaestus-menu-node>\r\n\r\n                    </li>\r\n\r\n                    <li *ngIf=\"!last && !($any(item).hideSeparator)\" class=\"menu-separator\"></li>\r\n                </ng-container>\r\n\r\n            </ul>\r\n        </div>\r\n    </div>\r\n\r\n</ng-container>\r\n</ng-container>\r\n</ng-container>", styles: [".active-first-route{background-color:#ffffff1a}.slim-mobile-logo{max-width:2.5rem;max-height:2.5rem;margin-left:auto!important;margin-right:auto!important}\n"] }]
        }], ctorParameters: () => [], propDecorators: { templates: [{
                type: ContentChildren,
                args: [PrimeTemplate]
            }], layout$: [], appName$: [], currentRoute$: [], appLayoutLogo$: [], menu: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 