import { Observable, Subject } from 'rxjs';
import * as i0 from "@angular/core";
export declare namespace TaskManager {
    type TaskState = 'pending' | 'running' | 'delayed' | 'done';
    type Event = BeforeTaskEvent | AfterTaskEvent | CancelTaskEvent | ErrorTaskEvent;
    interface BeforeTaskEvent {
        type: 'BEFORE_TASK';
        task: Task;
    }
    interface AfterTaskEvent {
        type: 'AFTER_TASK';
        task: Task;
        result: any;
    }
    interface CancelTaskEvent {
        type: 'CANCEL_TASK';
        task: Task;
    }
    interface ErrorTaskEvent {
        type: 'ERROR_TASK';
        task: Task;
        error: Error;
        delayed: boolean;
    }
    interface Task {
        id: string;
        priority?: number;
        exec(context?: any): Promise<any>;
        cancel?(): any;
        [key: string]: any;
    }
    interface TaskContainer {
        task: TaskManager.Task;
        events: Subject<TaskManager.Event>;
        meta: {
            state: TaskManager.TaskState;
            result?: any;
            error?: Error;
            context?: any;
        };
    }
}
declare type TaskContainer = TaskManager.TaskContainer;
export declare class TaskManagerService {
    private _tasks;
    private _events;
    get events(): Observable<TaskManager.Event>;
    get tasks(): TaskManager.Task[];
    constructor();
    createTask(task: TaskManager.Task, options?: {
        position?: number;
    }): TaskManager.TaskContainer;
    hasTask(id: string): boolean;
    task(id: string): TaskManager.Task | undefined;
    container(id: string): TaskContainer | undefined;
    cancel(id: string): void;
    taskMeta(id: string): {
        state: TaskManager.TaskState;
        result?: any;
        error?: Error | undefined;
        context?: any;
    } | undefined;
    addTaskContainer(container: TaskManager.TaskContainer): void;
    addTask$(task: TaskManager.Task, options?: {
        position?: number;
    }): Observable<TaskManager.Event>;
    clearTask(id: string): void;
    cancelAll(): void;
    clearAll(): void;
    exec(taskId: string, context: any): Observable<any>;
    private execAsObservable;
    execNext(): Observable<TaskManager.Event>;
    execDelayedTasks(): Observable<TaskManager.Event>;
    execPendingTasks(): Observable<TaskManager.Event>;
    execTasksByState(state: TaskManager.TaskState): Observable<TaskManager.Event>;
    getTaskPosition(id: string): number;
    private _exec;
    private _onTaskExecError;
    private _cancel;
    private _emit;
    private _onError;
    private _isDelayError;
    static ɵfac: i0.ɵɵFactoryDeclaration<TaskManagerService, never>;
    static ɵprov: i0.ɵɵInjectableDeclaration<TaskManagerService>;
}
export {};
