import type { Event, MaybePromise, URI } from '@difizen/mana-common';
import { Emitter } from '@difizen/mana-common';
import type { BaseView } from './default-view';
import type { OpenHandler } from './open-handler';
import { SlotViewManager } from './slot-view-manager';
import { ViewManager } from './view-manager';
import type { ViewOpenOption } from './view-protocol';
export interface ViewOpenHandlerOptions extends ViewOpenOption {
    slot?: string;
    viewOptions?: any;
}
/**
 * Generic base class for {@link OpenHandler}s that are opening a View for a given {@link URI}.
 */
export declare abstract class ViewOpenHandler<W extends BaseView> implements OpenHandler {
    protected readonly viewManager: ViewManager;
    protected readonly slotViewManager: SlotViewManager;
    constructor(viewManager: ViewManager, slotViewManager: SlotViewManager);
    protected readonly onCreatedEmitter: Emitter<W>;
    /**
     * Emit when a new View is created.
     */
    readonly onCreated: Event<W>;
    protected init(): void;
    /**
     * The view open handler id.
     *
     * #### Implementation
     * - A view factory for this id should be registered.
     */
    abstract readonly id: string;
    abstract canHandle(uri: URI, options?: ViewOpenHandlerOptions): MaybePromise<number>;
    /**
     * Open a View for the given uri and options.
     * Reject if the given options are not View options or a View cannot be opened.
     * @param uri the uri of the resource that should be opened.
     * @param options the View opener options.
     *
     * @returns promise of the View that resolves when the View has been opened.
     */
    open(uri: URI, options?: ViewOpenHandlerOptions): Promise<W>;
    protected doOpen(view: W, options: ViewOpenHandlerOptions): Promise<void>;
    /**
     * Tries to get an existing View for the given uri.
     * @param uri the uri of the View.
     *
     * @returns a promise that resolves to the existing View or `undefined` if no View for the given uri exists.
     */
    getByUri(uri: URI): Promise<W | undefined>;
    /**
     * Return an existing View for the given uri or creates a new one.
     *
     * It does not open a View, use {@link ViewOpenHandler#open} instead.
     * @param uri uri of the View.
     *
     * @returns a promise of the existing or newly created View.
     */
    getOrCreateByUri(uri: URI): Promise<W>;
    /**
     * Retrieves all open Views that have been opened by this handler.
     *
     * @returns all open Views for this open handler.
     */
    get all(): Promise<W[]>;
    protected getView(uri: URI, options?: ViewOpenHandlerOptions): Promise<W | undefined>;
    protected getOrCreateView(uri: URI, options?: ViewOpenHandlerOptions): Promise<W>;
    protected abstract createViewOptions(uri: URI, options?: ViewOpenHandlerOptions): Record<any, any>;
    /**
     * Closes all Views that have been opened by this open handler.
     * @param options the close options that should be applied to all Views.
     *
     * @returns a promise of all closed Views that resolves after they have been closed.
     */
    closeAll(slot: string): Promise<void[]>;
}
//# sourceMappingURL=view-open-handler.d.ts.map