"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MobileFlowRunner = void 0;
const execution_1 = require("@mablhq-internal/runtime/execution");
const importer_1 = require("@mablhq/test-model/importer");
const messaging_1 = require("@mablhq-internal/runtime/core/messaging/messaging");
class MobileFlowRunner extends execution_1.BaseFlowWithStepsRunner {
    constructor(flowController) {
        super(flowController);
    }
    beforeFlow() {
        this.executionContext.executionPhase = messaging_1.ExecutionPhase.BEFORE_FLOW;
        super.beforeFlow();
    }
    run(previousFlowResult) {
        const flowResult = super.run(previousFlowResult);
        this.executionContext.executionPhase = messaging_1.ExecutionPhase.AFTER_FLOW;
        return flowResult;
    }
    loadSteps() {
        return (0, importer_1.interpretStepsFromObjectsInFlow)(this.flowController.flow, true);
    }
    runStep(step) {
        this.executionContext.executionPhase = messaging_1.ExecutionPhase.BEFORE_ACTION;
        const executor = this.flowController.executionContext.executorStore.getStepExecutor(step);
        const result = this.flowController.executionContext.runStep(step, executor);
        this.executionContext.executionPhase = messaging_1.ExecutionPhase.AFTER_ACTION;
        return result;
    }
}
exports.MobileFlowRunner = MobileFlowRunner;
