import * as _angular_core from '@angular/core';
import { WritableSignal, OutputEmitterRef, OnDestroy } from '@angular/core';
import { AXStyleColorType, NXComponent, NXClickEvent, AXOrientation, NXEvent } from '@acorex/cdk/common';
import { AXPoint } from '@acorex/core/utils';
import { UrlTree, IsActiveMatchOptions } from '@angular/router';
import { Subject } from 'rxjs';

type AXMenuOpenTrigger = 'click' | 'hover';
type AXMenuCloseTrigger = 'click' | 'leave';
declare abstract class AXRootMenu {
    orientation: WritableSignal<AXOrientation>;
    openOn: WritableSignal<AXMenuOpenTrigger>;
    closeOn: WritableSignal<AXMenuCloseTrigger>;
    onItemClick: OutputEmitterRef<AXMenuItemClickBaseEvent>;
    nativeElement: HTMLDivElement;
    hasArrow: WritableSignal<boolean>;
}
declare abstract class AXMenuItemComponentBase {
    parent?: AXMenuItemComponentBase | null;
    /** Resolves the parent item, including for `ngTemplateOutlet`-created nested items. */
    getParentMenuItem?(): AXMenuItemComponentBase | null | undefined;
}
/** Shared tree item shape for `ax-menu`, `ax-context-menu`, and `ax-side-menu`. */
interface AXMenuItem {
    text: string;
    name?: string;
    icon?: string;
    data?: unknown;
    disabled?: boolean;
    items?: AXMenuItem[];
    color?: AXStyleColorType;
    suffix?: {
        text: string;
    };
    /** Side-menu alias for `suffix.text`. */
    suffixText?: string;
    break?: boolean;
    group?: {
        name?: string;
        title?: string;
    };
    title?: string;
    routerLink?: string | any[] | UrlTree;
    routerLinkActive?: string | string[];
    routerLinkActiveOptions?: {
        exact: boolean;
    } | IsActiveMatchOptions;
    href?: string;
    target?: '_blank' | '_self' | '_parent' | '_top';
    active?: boolean;
    isLoading?: boolean;
    isCollapsed?: boolean;
    toggleOnClick?: boolean;
}
declare class AXMenuItemClickBaseEvent<T extends NXComponent = NXComponent> extends NXClickEvent<T> {
    item: {
        name?: string;
        text: string;
        data?: any;
    };
    canceled: boolean;
}

declare class AXContextMenuOpeningEvent extends NXEvent<AXContextMenuComponent> {
    items: AXMenuItem[];
    canceled: boolean;
    targetElement: HTMLElement;
}
type AXContextMenuItemsClickEvent = AXMenuItemClickBaseEvent<AXContextMenuComponent>;
/**
 * Represents a menu component that displays context menu.
 * @category Components
 */
declare class AXContextMenuComponent extends NXComponent {
    readonly orientation: _angular_core.InputSignal<AXOrientation>;
    readonly openOn: _angular_core.InputSignal<AXMenuOpenTrigger>;
    readonly closeOn: _angular_core.InputSignal<AXMenuCloseTrigger>;
    /** When true, closes the menu on router navigation (e.g. side-menu route changes). */
    readonly closeOnRouteChange: _angular_core.InputSignal<boolean>;
    readonly originalItems: _angular_core.InputSignal<AXMenuItem[]>;
    readonly target: _angular_core.InputSignal<string | HTMLElement | HTMLElement[]>;
    onItemClick: _angular_core.OutputEmitterRef<AXContextMenuItemsClickEvent>;
    onOpening: _angular_core.OutputEmitterRef<AXContextMenuOpeningEvent>;
    /** Emitted when the menu closes (backdrop, item click, scroll, another menu opening, etc.). */
    onClose: _angular_core.OutputEmitterRef<void>;
    hasArrow: _angular_core.WritableSignal<boolean>;
    private service;
    private renderer;
    private document;
    private platformID;
    private zIndexService;
    private injector;
    private zToken;
    private lastOpenPoint;
    private router;
    private destroyRef;
    /** @ignore */
    constructor();
    ngOnDestroy(): void;
    /**
     * Refreshes the context menu by rebinding event listeners to target elements.
     */
    refresh(): void;
    /**
     * Shows the context menu at a specific point.
     * @param point - The coordinates where the menu should appear
     * @param targetElement - Optional target element for the context menu
     * @param event - Optional opening event with menu items
     */
    showAt(point: AXPoint, targetElement?: HTMLElement, event?: AXContextMenuOpeningEvent): void;
    /**
     * Closes the context menu and removes the backdrop.
     */
    close(): void;
    private backdropElement;
    private originalNextSibling;
    private originalParent;
    protected items: _angular_core.WritableSignal<AXMenuItem[]>;
    /** @ignore */
    private setupCloseOnRouteChange;
    /** @ignore */
    private getTargetElements;
    /** @ignore */
    private bindContextEvent;
    /** @ignore */
    private removeContextEvent;
    /** @ignore */
    private handleContextMenu;
    /** @ignore */
    private internalShowAt;
    /**
     * Positions the menu at `point`, flipping when it would overflow the viewport.
     * Uses a temporary visible layout pass so parents that hide the host (e.g. side-menu `display: none`) do not yield a zero-sized rect.
     */
    private positionAtPoint;
    /** Measures menu size even when an ancestor hides the host with `display: none`. */
    private measureMenuRect;
    /** @ignore */
    private createBackdrop;
    /** @ignore */
    private removeBackdrop;
    private createEventListeners;
    /** @ignore */
    private onWindowEvent;
    /** @ignore */
    get __hostClass(): any;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXContextMenuComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXContextMenuComponent, "ax-context-menu", never, { "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "openOn": { "alias": "openOn"; "required": false; "isSignal": true; }; "closeOn": { "alias": "closeOn"; "required": false; "isSignal": true; }; "closeOnRouteChange": { "alias": "closeOnRouteChange"; "required": false; "isSignal": true; }; "originalItems": { "alias": "items"; "required": false; "isSignal": true; }; "target": { "alias": "target"; "required": false; "isSignal": true; }; }, { "onItemClick": "onItemClick"; "onOpening": "onOpening"; "onClose": "onClose"; }, never, ["ax-menu-item,ax-divider,ax-title,ng-container"], true, never>;
}

type AXMenuItemClickEvent = AXMenuItemClickBaseEvent<AXMenuItemComponent>;
/**
 * Represents a menu item component used within an `ax-menu`.
 * @category Components
 */
declare class AXMenuItemComponent extends NXComponent implements OnDestroy {
    protected isOpen: _angular_core.WritableSignal<boolean>;
    readonly parent: AXMenuItemComponent;
    protected isFirstLevel: _angular_core.Signal<boolean>;
    private readonly childMenuItems;
    private readonly discoveredSubmenuNodeCount;
    private readonly submenuSlot;
    private readonly platformId;
    private readonly destroyRef;
    private childObserver;
    private childRefreshScheduled;
    /**
     * Nested items from the data model. Required for recursive `ngTemplateOutlet` templates
     * because `contentChildren` does not traverse those embedded views.
     */
    subItems: _angular_core.InputSignal<readonly unknown[]>;
    protected hasSubItems: _angular_core.Signal<boolean>;
    protected root: AXRootMenu;
    private service;
    private unsuscriber;
    private renderer;
    private injector;
    private zIndexService;
    private zToken;
    protected arrowIcon: _angular_core.Signal<string>;
    onClick: _angular_core.OutputEmitterRef<AXMenuItemClickEvent>;
    name: _angular_core.InputSignal<string>;
    data: _angular_core.InputSignal<any>;
    disabled: _angular_core.InputSignal<boolean>;
    color: _angular_core.InputSignal<AXStyleColorType>;
    constructor();
    private getText;
    /**
     * Resolves the parent menu item. Items rendered via recursive `ngTemplateOutlet` do not
     * receive a DI parent, so we fall back to the DOM tree after reparenting.
     */
    getParentMenuItem(): AXMenuItemComponent | null;
    /**
     * Opens the submenu of this menu item if it has sub-items and is not disabled.
     */
    open(): void;
    /**
     * Closes the submenu of this menu item if open.
     */
    close(): void;
    /**
     * Positions the submenu after layout so nested levels measure their full height.
     */
    private schedulePositionCalculation;
    /**
     * Calculate the position of the submenu to avoid it going out of the viewport.
     */
    private calculatePosition;
    /** Measures submenu size using the same flex layout as the rendered menu. */
    private measureSubmenuRect;
    /**
     * Moves nested `ax-menu-item` nodes rendered by recursive `ngTemplateOutlet` templates
     * into the submenu slot. Angular content queries do not traverse those embedded views.
     */
    private reparentOrphanedChildren;
    /**
     * Nested submenu nodes rendered by custom recursive templates (direct children of this item only).
     */
    private getDirectSubmenuNodes;
    private updateDiscoveredSubmenuNodeCount;
    private scheduleChildRefresh;
    private hasRelevantChildMutation;
    private nodeListContainsMenuStructuralNode;
    /** Keeps the submenu fully inside the viewport vertically. */
    private clampVerticalPosition;
    private handleClick;
    private handleMouseEnter;
    private mouseLeaveTimeout;
    private handleMouseLeave;
    /** True when the pointer moved into this item's submenu panel or a nested open submenu. */
    private containsSubmenuPointer;
    ngOnDestroy(): void;
    /** @ignore */
    get __hostClass(): string[];
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXMenuItemComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXMenuItemComponent, "ax-menu-item", never, { "subItems": { "alias": "subItems"; "required": false; "isSignal": true; }; "name": { "alias": "name"; "required": false; "isSignal": true; }; "data": { "alias": "data"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "color": { "alias": "color"; "required": false; "isSignal": true; }; }, { "onClick": "onClick"; }, ["childMenuItems"], ["ax-prefix", "ax-text", "ax-suffix", "ax-menu-item,ax-title,ax-divider,ng-container,[ngTemplateOutlet]"], true, never>;
}

declare class AXMenuService {
    closeAll$: Subject<void>;
    open$: Subject<AXMenuItemComponentBase>;
    close$: Subject<AXMenuItemComponentBase>;
    openContextMenu$: Subject<{
        sender: AXRootMenu;
        point: AXPoint;
    }>;
    closeAllContextMenu$: Subject<{
        sender: AXRootMenu;
    }>;
    private readonly destroyRef;
    private readonly document;
    private readonly platformId;
    private readonly openItems;
    private globalListenersBound;
    private rootElement?;
    private scrollableParents;
    private readonly onDocumentClick;
    private readonly onWindowOrScrollEvent;
    constructor();
    /**
     * Registers a single set of document/window/scroll listeners for the whole menu tree.
     */
    initGlobalListeners(rootElement: HTMLElement): void;
    /**
     * Closes open submenus that are not on the ancestor path of the item being opened.
     */
    closeExcept(opener: AXMenuItemComponentBase): void;
    markOpen(item: AXMenuItemComponentBase): void;
    markClosed(item: AXMenuItemComponentBase): void;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXMenuService, never>;
    static ɵprov: _angular_core.ɵɵInjectableDeclaration<AXMenuService>;
}

type AXMenuItemsClickEvent = AXMenuItemClickBaseEvent<AXMenuComponent>;
/**
 * Represents a menu component that displays menu items.
 * @category Components
 */
declare class AXMenuComponent extends NXComponent {
    constructor();
    orientation: _angular_core.InputSignal<AXOrientation>;
    openOn: _angular_core.InputSignal<AXMenuOpenTrigger>;
    closeOn: _angular_core.InputSignal<AXMenuCloseTrigger>;
    service: AXMenuService;
    onItemClick: _angular_core.OutputEmitterRef<AXMenuItemsClickEvent>;
    items: _angular_core.InputSignal<AXMenuItem[]>;
    hasArrow: _angular_core.InputSignal<boolean>;
    /** @ignore */
    get __hostClass(): string[];
    /**
     * Closes all open menus and submenus for this root menu.
     *
     * @returns void - No return value. All open menu overlays are closed and hidden.
     */
    close(): void;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXMenuComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXMenuComponent, "ax-menu", never, { "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "openOn": { "alias": "openOn"; "required": false; "isSignal": true; }; "closeOn": { "alias": "closeOn"; "required": false; "isSignal": true; }; "items": { "alias": "items"; "required": false; "isSignal": true; }; "hasArrow": { "alias": "hasArrow"; "required": false; "isSignal": true; }; }, { "onItemClick": "onItemClick"; }, never, ["ax-menu-item,ax-divider,ax-title,ng-container"], true, never>;
}

declare class AXMenuModule {
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXMenuModule, never>;
    static ɵmod: _angular_core.ɵɵNgModuleDeclaration<AXMenuModule, never, [typeof AXMenuItemComponent, typeof AXMenuComponent, typeof AXContextMenuComponent], [typeof AXMenuItemComponent, typeof AXMenuComponent, typeof AXContextMenuComponent]>;
    static ɵinj: _angular_core.ɵɵInjectorDeclaration<AXMenuModule>;
}

export { AXContextMenuComponent, AXContextMenuOpeningEvent, AXMenuComponent, AXMenuItemClickBaseEvent, AXMenuItemComponent, AXMenuItemComponentBase, AXMenuModule, AXMenuService, AXRootMenu };
export type { AXContextMenuItemsClickEvent, AXMenuCloseTrigger, AXMenuItem, AXMenuItemClickEvent, AXMenuItemsClickEvent, AXMenuOpenTrigger };
