/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
 * @module WorkflowTask
 */
/* eslint-disable deprecation/deprecation */
import { ItemDefBase } from "../shared/ItemDefBase";
import { UiFramework } from "../UiFramework";
import { WorkflowManager } from "./Workflow";
/** Task class.
 * A Task is a specific piece of work to accomplish.
 * A Task refers to a Frontstage to activate.
 * @internal
 * @deprecated in 3.0. Task is obsolete.
 */
export class Task extends ItemDefBase {
    constructor(taskProps) {
        super(taskProps);
        this.taskId = taskProps.id;
        this.primaryStageId = taskProps.primaryStageId;
    }
    get id() {
        return this.taskId;
    }
    get isActive() {
        let isActive = false;
        if (WorkflowManager.activeWorkflow && WorkflowManager.activeWorkflow.activeTask === this)
            isActive = true;
        return isActive;
    }
    set isActive(_) {
        // do nothing - needed because subclassing from ItemDefBase
    }
    async onActivated() {
        const frontstage = await UiFramework.frontstages.getFrontstageDef(this.primaryStageId);
        if (frontstage)
            await UiFramework.frontstages.setActiveFrontstageDef(frontstage);
    }
}
// -----------------------------------------------------------------------------
/** Task Manager class.
 * @internal
 * @deprecated in 3.0. TaskManager is obsolete.
 */
export class TaskManager {
    static loadTasks(taskListDef) {
        this.loadTaskDefs(taskListDef.tasks);
    }
    static loadTaskDefs(taskDefs) {
        taskDefs.map((taskDef, _index) => {
            this.loadTaskDef(taskDef);
        });
    }
    static loadTaskDef(taskDef) {
        const task = new Task(taskDef);
        this.addTask(taskDef.id, task);
    }
    static findTask(taskId) {
        return this._tasks.get(taskId);
    }
    static addTask(taskId, task) {
        this._tasks.set(taskId, task);
    }
}
TaskManager._tasks = new Map();
//# sourceMappingURL=Task.js.map