"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HoverStep = void 0;
const mablscriptFind_1 = require("../mablscriptFind");
const MablStepWithFindAction_1 = require("../MablStepWithFindAction");
const ActionsUtils_1 = require("./ActionsUtils");
class HoverStep extends MablStepWithFindAction_1.MablStepWithFindAction {
    static stepName = 'Hover';
    static actionCode = 'hover';
    static mablScriptStepNames = [HoverStep.actionCode];
    static yamlMablScriptNames = [HoverStep.stepName];
    constructor(descriptor, findAction) {
        super(HoverStep.stepName, descriptor, HoverStep.actionCode, findAction);
    }
    getStepName() {
        return HoverStep.stepName;
    }
    static fromYaml(_stepName, stepArgs) {
        return new HoverStep(stepArgs);
    }
    static fromLegacyMablscript(_args, actions) {
        const findAction = ActionsUtils_1.ActionsUtils.validateSingleFindAction(actions);
        const stepDescriptor = buildStepDescriptor(findAction);
        const step = new HoverStep(stepDescriptor, findAction);
        step.actions = actions;
        return step;
    }
    toMablscript() {
        return `${this.findAction.toMablscript()}.hover()`;
    }
    getInputVariables() {
        return this.findAction.getInputVariables();
    }
    stepDescription() {
        const elementDescription = this.humanizeFind();
        return `Hover over ${elementDescription}`;
    }
}
exports.HoverStep = HoverStep;
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: HoverStep.actionCode,
            };
        default:
            throw new Error(`Error generating step descriptor for ${HoverStep.stepName}: Unexpected find type ${find.findType}`);
    }
}
