"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setViewportExecutor = void 0;
const toolExecutor_types_1 = require("../toolExecutor-types");
const stepCapture_1 = require("../../background/capture/stepCapture");
exports.setViewportExecutor = {
    needsFind: () => false,
    getStepType: () => 'viewport',
    execute: async (payload, stateProvider, eventHandler, logger) => {
        const toolParams = payload.toolCall
            .toolParams;
        if (toolParams?.width === undefined || toolParams?.height === undefined) {
            logger.error('Set viewport executor requires both width and height parameters');
            return {
                success: false,
                errorMessage: 'Both width and height parameters are required',
            };
        }
        const contextInfo = payload.contextInfo ?? (await stateProvider.getActiveContextInfo());
        const eventMessage = {
            action: 'record',
            listener: 'viewport',
            size: {
                width: toolParams.width,
                height: toolParams.height,
            },
        };
        return (0, toolExecutor_types_1.recordStepAndTrackResult)(() => (0, stepCapture_1.recordTrainedStep)(eventMessage, contextInfo, true, undefined, stateProvider, eventHandler), 0, stateProvider, eventHandler, logger);
    },
};
