import { MenuItem } from './internals/MenuItem.js';
import type { CommandBase, ContextMenuCommand, CustomMenuEventDetail, MenuOptions, MenuPoint, MenuTriggerInfo } from './internals/types.js';
import type ContextMenuElement from './internals/ContextualMenuElement.js';
import { Logger, ILogObj } from 'tslog';
export type * from './internals/types.js';
import './contextual-menu.js';
/**
 * The base class for the context menu. It can be used as is but in some specific cases
 * you may want to extend this class to be able to find command target accurately.
 *
 * @template S - The definition of the store passed to commands.
 */
export declare class ContextualMenu<S = unknown> extends EventTarget {
    #private;
    workspace: HTMLElement;
    /**
     * @returns true when the menu is connected to the `workspace`.
     */
    get connected(): boolean;
    /**
     * The store initialized with this context menu. Passed to the lifecycle functions.
     */
    store: S;
    /**
     * The root level menu commands
     */
    commands: MenuItem<S>[];
    /**
     * An information about the trigger that initialized this menu.
     */
    triggerInfo?: MenuTriggerInfo;
    /**
     * The Menu configuration options.
     */
    options: MenuOptions;
    currentMenu?: ContextMenuElement<S>;
    get debug(): boolean;
    set debug(value: boolean);
    protected logger: Logger<ILogObj>;
    /**
     * @param workspace The root element that is the click handler
     * @param opts The Menu configuration options.
     */
    constructor(workspace: HTMLElement, opts?: MenuOptions);
    /**
     * Starts listening on user events
     */
    connect(): void;
    /**
     * Cleans up the listeners
     */
    disconnect(): void;
    /**
     * Reads {x,y} point of the click from the pointer event.
     *
     * Override this method to customize position reading.
     */
    readTargetClickPosition(e: MouseEvent): MenuPoint;
    /**
     * Override this method to customize finding event click target.
     * @param e Finds the click target from the event
     */
    findTarget(e: MouseEvent): HTMLElement | SVGElement | undefined;
    /**
     * Maps an element to the target name used by the commands.
     * By default it returns `root` when the click target element is the `workspace` or
     * a combination of element name and list of all classes otherwise.
     *
     * Override this method to customize target name reading.
     *
     * @param element The context click target
     * @returns The target name.
     */
    elementToTarget(element: HTMLElement | SVGElement): string | undefined;
    /**
     * Handler for the context menu event.
     */
    protected contextHandler(e: MouseEvent): void;
    /**
     * A handler for the `custommenu` event handler to trigger the menu without the user interaction.
     */
    protected customMenuHandler(e: CustomEvent<CustomMenuEventDetail>): void;
    /**
     * Handles the click event on the document to close the menu is the click
     * is outside the menu.
     */
    protected clickHandler(e: MouseEvent): void;
    /**
     * Closes the menu when ESC is pressed
     */
    protected keydownHandler(e: KeyboardEvent): void;
    /**
     * Register a list of commands to be rendered in the menu when triggered.
     * This overrides previously registered commands.
     */
    registerCommands(commands: (CommandBase<S> | ContextMenuCommand<S>)[]): void;
    /**
     * Adds a single command to the menu.
     */
    addCommand(command: CommandBase<S> | ContextMenuCommand<S>): void;
    /**
     * Prepares incoming commands for the internal use.
     * @param commands - The commands to process.
     */
    protected prepareCommands(commands: CommandBase<S>[]): MenuItem<S>[];
    protected normalizeMenuItem(item: ContextMenuCommand<S>): ContextMenuCommand<S>;
    /**
     * Builds the menu for the target.
     *
     * @param target The element that triggered the menu
     * @param name The `target` name declared in the commands.
     * @param placementPoint The workspace position of where to place the menu.
     * @param targetPoint The workspace position of the click target
     * @param customData Any data to set on the instance to pass to the `execute` and `enabled` functions.
     */
    build(target: HTMLElement | SVGElement, name: string, placementPoint: MenuPoint, targetPoint: MenuPoint, customData?: unknown): boolean;
    /**
     * A lifecycle method called before the `render()` method.
     */
    protected beforeRender(): void;
    /**
     * @param placementPoint The workspace position of where to place the menu.
     * @param commands The commands render
     */
    render(placementPoint: MenuPoint, commands: MenuItem<S>[]): void;
    /**
     * Lists all commands that matches the target.
     *
     * @param targetName The build target name
     * @param targetElement The element that triggered the menu
     */
    listCommands(targetName: string, targetElement: HTMLElement | SVGElement): MenuItem<S>[];
    /**
     * Removes the currently rendered menu.
     */
    destroy(): void;
    protected afterClose(trigger: MenuTriggerInfo): void;
    /**
     * Handler for the `trigger` event dispatched by the menu
     */
    protected menuTriggerHandler(e: CustomEvent): void;
}
//# sourceMappingURL=ContextualMenu.d.ts.map