import * as i0 from '@angular/core';
import { viewChild, contentChild, TemplateRef, input, booleanAttribute, model, output, computed, Component } from '@angular/core';
import { Menu as Menu$1 } from 'primeng/menu';
import * as i1 from 'primeng/api';
import { SharedModule } from 'primeng/api';
import { Icon } from '@masterteam/icons';
import { NgTemplateOutlet } from '@angular/common';

class Menu {
    menuRef = viewChild.required('menu', { read: Menu$1 });
    startTemplate = contentChild('start', { ...(ngDevMode ? { debugName: "startTemplate" } : {}), read: TemplateRef });
    endTemplate = contentChild('end', { ...(ngDevMode ? { debugName: "endTemplate" } : {}), read: TemplateRef });
    headerTemplate = contentChild('header', { ...(ngDevMode ? { debugName: "headerTemplate" } : {}), read: TemplateRef });
    submenuHeaderTemplate = contentChild('submenuheader', { ...(ngDevMode ? { debugName: "submenuHeaderTemplate" } : {}), read: TemplateRef });
    model = input([], ...(ngDevMode ? [{ debugName: "model" }] : []));
    popup = input(true, { ...(ngDevMode ? { debugName: "popup" } : {}), transform: booleanAttribute });
    appendTo = input('body', ...(ngDevMode ? [{ debugName: "appendTo" }] : []));
    style = input(...(ngDevMode ? [undefined, { debugName: "style" }] : []));
    styleClass = input(...(ngDevMode ? [undefined, { debugName: "styleClass" }] : []));
    autoZIndex = input(true, { ...(ngDevMode ? { debugName: "autoZIndex" } : {}), transform: booleanAttribute });
    baseZIndex = input(0, ...(ngDevMode ? [{ debugName: "baseZIndex" }] : []));
    showTransitionOptions = input('0.12s cubic-bezier(0, 0, 0.2, 1)', ...(ngDevMode ? [{ debugName: "showTransitionOptions" }] : []));
    hideTransitionOptions = input('0.1s linear', ...(ngDevMode ? [{ debugName: "hideTransitionOptions" }] : []));
    ariaLabel = input(...(ngDevMode ? [undefined, { debugName: "ariaLabel" }] : []));
    ariaLabelledBy = input(...(ngDevMode ? [undefined, { debugName: "ariaLabelledBy" }] : []));
    id = input(...(ngDevMode ? [undefined, { debugName: "id" }] : []));
    tabindex = input(0, ...(ngDevMode ? [{ debugName: "tabindex" }] : []));
    activeItemId = model(...(ngDevMode ? [undefined, { debugName: "activeItemId" }] : []));
    onShow = output();
    onHide = output();
    onBlur = output();
    onFocus = output();
    onItemSelect = output();
    transformedModel = computed(() => {
        return this.model().map((item) => this.transformMenuItem(item, this.activeItemId()));
    }, ...(ngDevMode ? [{ debugName: "transformedModel" }] : []));
    toggle(event) {
        this.menuRef().toggle(event);
    }
    show(event) {
        this.menuRef().show(event);
    }
    hide() {
        this.menuRef().hide();
    }
    getItemIcon(item) {
        return item?.mtIcon;
    }
    transformMenuItem(item, activeId) {
        const transformed = { ...item };
        if (item.icon) {
            transformed.mtIcon = item.icon;
            delete transformed.icon;
        }
        const classes = [];
        const isActive = activeId && item.id && item.id === activeId;
        if (isActive) {
            classes.push('bg-primary-50', 'text-primary-700', 'dark:bg-primary-900/20', 'dark:text-primary-300');
        }
        else if (item.severity) {
            const severityClass = this.getSeverityClass(item.severity);
            if (severityClass) {
                classes.push(severityClass);
            }
        }
        if (item.styleClass) {
            classes.push(item.styleClass);
        }
        transformed.computedClass = classes.join(' ');
        if (item['items']) {
            transformed['items'] = item['items'].map((subItem) => this.transformMenuItem(subItem, activeId));
        }
        const originalCommand = transformed.command;
        transformed.command = (event) => {
            if (item.id) {
                this.handleItemSelect(item);
            }
            if (originalCommand) {
                originalCommand(event);
            }
        };
        return transformed;
    }
    getSeverityClass(severity) {
        const severityMap = {
            danger: 'text-red-600 hover:bg-red-50 hover:text-red-700',
            warn: 'text-yellow-600 hover:bg-yellow-50 hover:text-yellow-700',
            success: 'text-green-600 hover:bg-green-50 hover:text-green-700',
            info: 'text-blue-600 hover:bg-blue-50 hover:text-blue-700',
            help: 'text-purple-600 hover:bg-purple-50 hover:text-purple-700',
            secondary: 'text-gray-600 hover:bg-gray-50 hover:text-gray-700',
            contrast: 'text-gray-900 hover:bg-gray-100',
        };
        return severityMap[severity] || '';
    }
    handleItemSelect(item) {
        if (item.id) {
            this.activeItemId.set(item.id);
        }
        this.onItemSelect.emit(item);
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Menu, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.0.3", type: Menu, isStandalone: true, selector: "mt-menu", inputs: { model: { classPropertyName: "model", publicName: "model", isSignal: true, isRequired: false, transformFunction: null }, popup: { classPropertyName: "popup", publicName: "popup", isSignal: true, isRequired: false, transformFunction: null }, appendTo: { classPropertyName: "appendTo", publicName: "appendTo", isSignal: true, isRequired: false, transformFunction: null }, style: { classPropertyName: "style", publicName: "style", isSignal: true, isRequired: false, transformFunction: null }, styleClass: { classPropertyName: "styleClass", publicName: "styleClass", isSignal: true, isRequired: false, transformFunction: null }, autoZIndex: { classPropertyName: "autoZIndex", publicName: "autoZIndex", isSignal: true, isRequired: false, transformFunction: null }, baseZIndex: { classPropertyName: "baseZIndex", publicName: "baseZIndex", isSignal: true, isRequired: false, transformFunction: null }, showTransitionOptions: { classPropertyName: "showTransitionOptions", publicName: "showTransitionOptions", isSignal: true, isRequired: false, transformFunction: null }, hideTransitionOptions: { classPropertyName: "hideTransitionOptions", publicName: "hideTransitionOptions", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "ariaLabelledBy", isSignal: true, isRequired: false, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null }, tabindex: { classPropertyName: "tabindex", publicName: "tabindex", isSignal: true, isRequired: false, transformFunction: null }, activeItemId: { classPropertyName: "activeItemId", publicName: "activeItemId", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activeItemId: "activeItemIdChange", onShow: "onShow", onHide: "onHide", onBlur: "onBlur", onFocus: "onFocus", onItemSelect: "onItemSelect" }, queries: [{ propertyName: "startTemplate", first: true, predicate: ["start"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "endTemplate", first: true, predicate: ["end"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "headerTemplate", first: true, predicate: ["header"], descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "submenuHeaderTemplate", first: true, predicate: ["submenuheader"], descendants: true, read: TemplateRef, isSignal: true }], viewQueries: [{ propertyName: "menuRef", first: true, predicate: ["menu"], descendants: true, read: Menu$1, isSignal: true }], ngImport: i0, template: "<p-menu\r\n  #menu\r\n  [model]=\"transformedModel()\"\r\n  [popup]=\"popup()\"\r\n  [appendTo]=\"appendTo()\"\r\n  [style]=\"style()\"\r\n  [styleClass]=\"styleClass()\"\r\n  [autoZIndex]=\"autoZIndex()\"\r\n  [baseZIndex]=\"baseZIndex()\"\r\n  [showTransitionOptions]=\"showTransitionOptions()\"\r\n  [hideTransitionOptions]=\"hideTransitionOptions()\"\r\n  [ariaLabel]=\"ariaLabel()\"\r\n  [ariaLabelledBy]=\"ariaLabelledBy()\"\r\n  [id]=\"id()\"\r\n  [tabindex]=\"tabindex()\"\r\n  (onShow)=\"onShow.emit($event)\"\r\n  (onHide)=\"onHide.emit($event)\"\r\n  (onBlur)=\"onBlur.emit($event)\"\r\n  (onFocus)=\"onFocus.emit($event)\"\r\n>\r\n  @if (startTemplate()) {\r\n    <ng-template pTemplate=\"start\">\r\n      <ng-container *ngTemplateOutlet=\"startTemplate()!\" />\r\n    </ng-template>\r\n  }\r\n\r\n  @if (endTemplate()) {\r\n    <ng-template pTemplate=\"end\">\r\n      <ng-container *ngTemplateOutlet=\"endTemplate()!\" />\r\n    </ng-template>\r\n  }\r\n\r\n  @if (headerTemplate()) {\r\n    <ng-template pTemplate=\"header\">\r\n      <ng-container *ngTemplateOutlet=\"headerTemplate()!\" />\r\n    </ng-template>\r\n  }\r\n\r\n  @if (submenuHeaderTemplate()) {\r\n    <ng-template pTemplate=\"submenuheader\" let-item>\r\n      <ng-container\r\n        *ngTemplateOutlet=\"\r\n          submenuHeaderTemplate()!;\r\n          context: { $implicit: item }\r\n        \"\r\n      />\r\n    </ng-template>\r\n  }\r\n\r\n  <ng-template pTemplate=\"item\" let-item>\r\n    <div\r\n      class=\"flex gap-2 align-middle p-2 cursor-pointer rounded transition-colors\"\r\n      [class]=\"item.computedClass\"\r\n    >\r\n      @if (getItemIcon(item)) {\r\n        <mt-icon\r\n          [icon]=\"getItemIcon(item)!\"\r\n          class=\"p-menu-item-icon\"\r\n          [style.color]=\"'inherit'\"\r\n        />\r\n      }\r\n      @if (item.label) {\r\n        <span class=\"p-menu-item-label\">{{ item.label }}</span>\r\n      }\r\n      @if (item.badge) {\r\n        <span class=\"p-menu-item-badge\">{{ item.badge }}</span>\r\n      }\r\n    </div>\r\n  </ng-template>\r\n</p-menu>\r\n", styles: [":host{display:contents}\n"], dependencies: [{ kind: "component", type: Menu$1, selector: "p-menu", inputs: ["model", "popup", "style", "styleClass", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "ariaLabel", "ariaLabelledBy", "id", "tabindex", "appendTo", "motionOptions"], outputs: ["onShow", "onHide", "onBlur", "onFocus"] }, { kind: "component", type: Icon, selector: "mt-icon", inputs: ["icon"] }, { kind: "ngmodule", type: SharedModule }, { kind: "directive", type: i1.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: Menu, decorators: [{
            type: Component,
            args: [{ selector: 'mt-menu', standalone: true, imports: [Menu$1, Icon, SharedModule, NgTemplateOutlet], template: "<p-menu\r\n  #menu\r\n  [model]=\"transformedModel()\"\r\n  [popup]=\"popup()\"\r\n  [appendTo]=\"appendTo()\"\r\n  [style]=\"style()\"\r\n  [styleClass]=\"styleClass()\"\r\n  [autoZIndex]=\"autoZIndex()\"\r\n  [baseZIndex]=\"baseZIndex()\"\r\n  [showTransitionOptions]=\"showTransitionOptions()\"\r\n  [hideTransitionOptions]=\"hideTransitionOptions()\"\r\n  [ariaLabel]=\"ariaLabel()\"\r\n  [ariaLabelledBy]=\"ariaLabelledBy()\"\r\n  [id]=\"id()\"\r\n  [tabindex]=\"tabindex()\"\r\n  (onShow)=\"onShow.emit($event)\"\r\n  (onHide)=\"onHide.emit($event)\"\r\n  (onBlur)=\"onBlur.emit($event)\"\r\n  (onFocus)=\"onFocus.emit($event)\"\r\n>\r\n  @if (startTemplate()) {\r\n    <ng-template pTemplate=\"start\">\r\n      <ng-container *ngTemplateOutlet=\"startTemplate()!\" />\r\n    </ng-template>\r\n  }\r\n\r\n  @if (endTemplate()) {\r\n    <ng-template pTemplate=\"end\">\r\n      <ng-container *ngTemplateOutlet=\"endTemplate()!\" />\r\n    </ng-template>\r\n  }\r\n\r\n  @if (headerTemplate()) {\r\n    <ng-template pTemplate=\"header\">\r\n      <ng-container *ngTemplateOutlet=\"headerTemplate()!\" />\r\n    </ng-template>\r\n  }\r\n\r\n  @if (submenuHeaderTemplate()) {\r\n    <ng-template pTemplate=\"submenuheader\" let-item>\r\n      <ng-container\r\n        *ngTemplateOutlet=\"\r\n          submenuHeaderTemplate()!;\r\n          context: { $implicit: item }\r\n        \"\r\n      />\r\n    </ng-template>\r\n  }\r\n\r\n  <ng-template pTemplate=\"item\" let-item>\r\n    <div\r\n      class=\"flex gap-2 align-middle p-2 cursor-pointer rounded transition-colors\"\r\n      [class]=\"item.computedClass\"\r\n    >\r\n      @if (getItemIcon(item)) {\r\n        <mt-icon\r\n          [icon]=\"getItemIcon(item)!\"\r\n          class=\"p-menu-item-icon\"\r\n          [style.color]=\"'inherit'\"\r\n        />\r\n      }\r\n      @if (item.label) {\r\n        <span class=\"p-menu-item-label\">{{ item.label }}</span>\r\n      }\r\n      @if (item.badge) {\r\n        <span class=\"p-menu-item-badge\">{{ item.badge }}</span>\r\n      }\r\n    </div>\r\n  </ng-template>\r\n</p-menu>\r\n", styles: [":host{display:contents}\n"] }]
        }], propDecorators: { menuRef: [{ type: i0.ViewChild, args: ['menu', { ...{ read: Menu$1 }, isSignal: true }] }], startTemplate: [{ type: i0.ContentChild, args: ['start', { ...{ read: TemplateRef }, isSignal: true }] }], endTemplate: [{ type: i0.ContentChild, args: ['end', { ...{ read: TemplateRef }, isSignal: true }] }], headerTemplate: [{ type: i0.ContentChild, args: ['header', { ...{ read: TemplateRef }, isSignal: true }] }], submenuHeaderTemplate: [{ type: i0.ContentChild, args: ['submenuheader', { ...{
                            read: TemplateRef,
                        }, isSignal: true }] }], model: [{ type: i0.Input, args: [{ isSignal: true, alias: "model", required: false }] }], popup: [{ type: i0.Input, args: [{ isSignal: true, alias: "popup", required: false }] }], appendTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "appendTo", required: false }] }], style: [{ type: i0.Input, args: [{ isSignal: true, alias: "style", required: false }] }], styleClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "styleClass", required: false }] }], autoZIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoZIndex", required: false }] }], baseZIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "baseZIndex", required: false }] }], showTransitionOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTransitionOptions", required: false }] }], hideTransitionOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideTransitionOptions", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledBy", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], tabindex: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabindex", required: false }] }], activeItemId: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeItemId", required: false }] }, { type: i0.Output, args: ["activeItemIdChange"] }], onShow: [{ type: i0.Output, args: ["onShow"] }], onHide: [{ type: i0.Output, args: ["onHide"] }], onBlur: [{ type: i0.Output, args: ["onBlur"] }], onFocus: [{ type: i0.Output, args: ["onFocus"] }], onItemSelect: [{ type: i0.Output, args: ["onItemSelect"] }] } });

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

export { Menu };
//# sourceMappingURL=masterteam-components-menu.mjs.map
