import { Component, Injector, Input, ViewChild } from '@angular/core';
import { MatDividerModule } from '@angular/material/divider';
import { MatIconModule } from '@angular/material/icon';
import { MatMenu, MatMenuModule } from '@angular/material/menu';
import { OTranslatePipe } from '../../../../pipes/o-translate.pipe';
import { OContextMenuGroupComponent } from '../../context-menu-group/o-context-menu-group.component';
import { OContextMenuItemComponent } from '../../context-menu-item/o-context-menu-item.component';
import { OContextMenuSeparatorComponent } from '../../context-menu-separator/o-context-menu-separator.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/menu";
import * as i2 from "@angular/material/icon";
import * as i3 from "@angular/material/divider";
export const DEFAULT_CONTEXT_MENU_CONTENT_ITEM_INPUTS = [
    'items',
    'class'
];
export class OWrapperContentMenuComponent {
    constructor(injector) {
        this.injector = injector;
    }
    onClick(item, event) {
        if (item instanceof OContextMenuItemComponent) {
            item.triggerExecute(item.data, event);
        }
    }
    isGroup(item) {
        return item instanceof OContextMenuGroupComponent;
    }
    isSeparator(item) {
        return item instanceof OContextMenuSeparatorComponent;
    }
    isItem(item) {
        return item instanceof OContextMenuItemComponent;
    }
    getChildren(item) {
        return item instanceof OContextMenuGroupComponent ? item.children : [];
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OWrapperContentMenuComponent, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: OWrapperContentMenuComponent, isStandalone: true, selector: "o-wrapper-content-menu", inputs: { items: "items", class: "class" }, viewQueries: [{ propertyName: "childMenu", first: true, predicate: ["childMenu"], descendants: true, static: true }, { propertyName: "menu", first: true, predicate: OWrapperContentMenuComponent, descendants: true, static: true }], ngImport: i0, template: "<mat-menu class=\"o-mat-menu\" #childMenu=\"matMenu\" [class]=\"class\" [overlapTrigger]=\"false\" [hasBackdrop]=\"false\">\n  @for (child of items; track child) {\n    <!-- Handle branch node menu items -->\n    @if (isGroup(child) && child.isVisible) {\n      <span>\n        <button mat-menu-item color=\"primary\" [matMenuTriggerFor]=\"menu.childMenu\" [disabled]=\"child.disabled\">\n          @if (child.svgIcon != null) {\n            <mat-icon [svgIcon]=\"child.svgIcon\"></mat-icon>\n          }\n          @if (child.svgIcon == null && child.icon != null) {\n            <mat-icon>{{ child.icon }}</mat-icon>\n          }\n          <span>{{ child.label | oTranslate}}</span>\n        </button>\n        <o-wrapper-content-menu #menu [items]=\"getChildren(child)\" [class]=\"class\"></o-wrapper-content-menu>\n      </span>\n    }\n    <!-- Handle leaf node menu items -->\n    @if (isItem(child) && child.isVisible) {\n      <button mat-menu-item (click)=\"onClick(child, $event)\" [disabled]=\"child.disabled\">\n        @if (child.svgIcon != null) {\n          <mat-icon [svgIcon]=\"child.svgIcon\"></mat-icon>\n        }\n        @if (child.svgIcon == null && child.icon != null) {\n          <mat-icon>{{ child.icon }}</mat-icon>\n        }\n        <span>{{ child.label | oTranslate}} </span>\n      </button>\n    }\n    <!-- separator leaf node menu items -->\n    @if (isSeparator(child) && child.isVisible) {\n      <mat-divider></mat-divider>\n    }\n  }\n</mat-menu>\n", styles: ["mat-divider.mat-divider:first-child,mat-divider.mat-divider:last-child{display:none}.mat-icon{display:inline-flex}\n"], dependencies: [{ kind: "component", type: OWrapperContentMenuComponent, selector: "o-wrapper-content-menu", inputs: ["items", "class"] }, { kind: "ngmodule", type: MatMenuModule }, { kind: "component", type: i1.MatMenu, selector: "mat-menu", inputs: ["backdropClass", "aria-label", "aria-labelledby", "aria-describedby", "xPosition", "yPosition", "overlapTrigger", "hasBackdrop", "class", "classList"], outputs: ["closed", "close"], exportAs: ["matMenu"] }, { kind: "component", type: i1.MatMenuItem, selector: "[mat-menu-item]", inputs: ["role", "disabled", "disableRipple"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i1.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", inputs: ["mat-menu-trigger-for", "matMenuTriggerFor", "matMenuTriggerData", "matMenuTriggerRestoreFocus"], outputs: ["menuOpened", "onMenuOpen", "menuClosed", "onMenuClose"], exportAs: ["matMenuTrigger"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatDividerModule }, { kind: "component", type: i3.MatDivider, selector: "mat-divider", inputs: ["vertical", "inset"] }, { kind: "pipe", type: OTranslatePipe, name: "oTranslate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OWrapperContentMenuComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [MatMenuModule, MatIconModule, MatDividerModule, OTranslatePipe, OWrapperContentMenuComponent], selector: 'o-wrapper-content-menu', inputs: DEFAULT_CONTEXT_MENU_CONTENT_ITEM_INPUTS, template: "<mat-menu class=\"o-mat-menu\" #childMenu=\"matMenu\" [class]=\"class\" [overlapTrigger]=\"false\" [hasBackdrop]=\"false\">\n  @for (child of items; track child) {\n    <!-- Handle branch node menu items -->\n    @if (isGroup(child) && child.isVisible) {\n      <span>\n        <button mat-menu-item color=\"primary\" [matMenuTriggerFor]=\"menu.childMenu\" [disabled]=\"child.disabled\">\n          @if (child.svgIcon != null) {\n            <mat-icon [svgIcon]=\"child.svgIcon\"></mat-icon>\n          }\n          @if (child.svgIcon == null && child.icon != null) {\n            <mat-icon>{{ child.icon }}</mat-icon>\n          }\n          <span>{{ child.label | oTranslate}}</span>\n        </button>\n        <o-wrapper-content-menu #menu [items]=\"getChildren(child)\" [class]=\"class\"></o-wrapper-content-menu>\n      </span>\n    }\n    <!-- Handle leaf node menu items -->\n    @if (isItem(child) && child.isVisible) {\n      <button mat-menu-item (click)=\"onClick(child, $event)\" [disabled]=\"child.disabled\">\n        @if (child.svgIcon != null) {\n          <mat-icon [svgIcon]=\"child.svgIcon\"></mat-icon>\n        }\n        @if (child.svgIcon == null && child.icon != null) {\n          <mat-icon>{{ child.icon }}</mat-icon>\n        }\n        <span>{{ child.label | oTranslate}} </span>\n      </button>\n    }\n    <!-- separator leaf node menu items -->\n    @if (isSeparator(child) && child.isVisible) {\n      <mat-divider></mat-divider>\n    }\n  }\n</mat-menu>\n", styles: ["mat-divider.mat-divider:first-child,mat-divider.mat-divider:last-child{display:none}.mat-icon{display:inline-flex}\n"] }]
        }], ctorParameters: () => [{ type: i0.Injector }], propDecorators: { items: [{
                type: Input
            }], childMenu: [{
                type: ViewChild,
                args: ['childMenu', { static: true }]
            }], menu: [{
                type: ViewChild,
                args: [OWrapperContentMenuComponent, { static: true }]
            }] } });
//# sourceMappingURL=data:application/json;base64, 