import { OnDestroy } from "@angular/core";
import { INavigationBarTab, INavigationBarTabs } from "./shell-tabs-api";
import { Observable } from "rxjs";
export type PotentialTabItem<T = any, U = any> = Partial<OnAttachTab<T> & OnTabEnter & OnTabLeave & OnTabSaveConfirm & OnTabClose & TabWithToolbar<U> & OnDestroy>;
export interface OnAttachTab<T = any> {
    currentNavigationBarTab?: INavigationBarTab<T>;
    /**
     * Runs when a navigation bar tab is first attached to the implementing component.
     * If the tab is recycled, it will only run once.
     */
    onAttachTab?(): void;
}
export interface OnTabEnterParams {
    from?: INavigationBarTab;
    fromSecondary?: INavigationBarTab;
    to: INavigationBarTab;
    toSecondary?: INavigationBarTab;
    recycled: boolean;
}
export type OnTabLeaveParams = Omit<OnTabEnterParams, "recycled">;
export interface OnTabEnter {
    /**
     * Function to run when the tab is entered. This happens on first load as well.
     * @param params - from is the previous tab (possibly undefined on first load), to is always this tab;
     *                 type {@link INavigationBarTab}, recycled indicates whether the component was recycled or not.
     */
    onTabEnter(params: OnTabEnterParams): void;
}
export interface OnTabLeave {
    /**
     * Function to run when the tab is left.
     * @param params - from is always this tab, to is where the user is going; type {@link INavigationBarTab}.
     */
    onTabLeave(params: OnTabLeaveParams): void;
}
export interface TabToolbarFor<T = any> {
    currentComponentAndTab?: {
        tab: INavigationBarTabs;
        component: T;
    };
    onAttachComponent?(): void;
}
export interface TabWithToolbar<T> {
    currentToolbar?: T;
    onAttachToolbar?(): void;
}
export interface OnTabClose {
    /**
     * @param tab The current tab model that is closing.
     */
    onTabClose(tab: INavigationBarTab): boolean | Promise<boolean> | Observable<boolean>;
}
export interface OnTabSaveConfirm {
    /**
     * @param tab The current tab model that is closing.
     */
    onTabSaveConfirm(tab: INavigationBarTab): INavigationBarTabSaveOptions | undefined;
}
export interface INavigationBarTabSaveOptions {
    dialogTitle: string;
    dialogMessage: string;
    saveFunction(): Promise<boolean> | Observable<boolean> | boolean;
}
export type WebElementTabApi<NavBarDataType = any, ComponentType = any> = Omit<PotentialTabItem<NavBarDataType, ComponentType>, "onAttachTab" | keyof TabWithToolbar<ComponentType>> & {
    onAttachTab?(tab: INavigationBarTab<NavBarDataType>): void;
};
export type WebTabApiElement = HTMLElement & {
    tabApi?: WebElementTabApi;
};
