"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RightClickStep = void 0;
const mablscriptFind_1 = require("../mablscriptFind");
const ActionsUtils_1 = require("./ActionsUtils");
const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
class RightClickStep extends MablStepWithFindAction_1.MablStepWithFindAction {
    static stepName = 'RightClick';
    static actionCode = 'right_click';
    static mablScriptStepNames = [RightClickStep.actionCode];
    static yamlMablScriptNames = [RightClickStep.stepName];
    constructor(descriptor, findAction) {
        super(RightClickStep.stepName, descriptor, RightClickStep.actionCode, findAction);
    }
    getStepName() {
        return RightClickStep.stepName;
    }
    static fromYaml(_stepName, stepArgs) {
        return new RightClickStep(stepArgs);
    }
    static fromLegacyMablscript(_args, actions) {
        const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
        const stepDescriptor = buildStepDescriptor(findAction);
        const step = new RightClickStep(stepDescriptor, findAction);
        step.actions = actions;
        return step;
    }
    toMablscript() {
        return `${this.findAction.toMablscript()}.right_click()`;
    }
    getInputVariables() {
        return this.findAction.getInputVariables();
    }
    stepDescription() {
        const elementDescription = this.humanizeFind();
        return `Right click on ${elementDescription}`;
    }
}
exports.RightClickStep = RightClickStep;
function buildStepDescriptor(findAction) {
    const find = findAction.toDescriptor();
    switch (find.findType) {
        case mablscriptFind_1.FindType.FIND_FIRST:
        case mablscriptFind_1.FindType.FIND_LAST:
        case mablscriptFind_1.FindType.FIND_ANY:
        case mablscriptFind_1.FindType.FIND_ONE:
            return {
                find,
                actionCode: RightClickStep.actionCode,
            };
        default:
            throw new Error(`Error generating step descriptor for ${RightClickStep.stepName}: Unexpected find type ${find.findType}`);
    }
}
