"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExecuteDeleteStepsFlexToolDefinition = exports.executeDeleteStepsFlexResponseSchema = exports.executeDeleteStepsFlexArgumentsSchema = void 0;
var zod_1 = require("zod");
var toolDefinition_js_1 = require("../toolDefinition.js");
var stepIndexDescription_js_1 = require("./shared/stepIndexDescription.js");
var refreshedStepsResponseFields_js_1 = require("./shared/refreshedStepsResponseFields.js");
exports.executeDeleteStepsFlexArgumentsSchema = zod_1.z
    .object({
    target_position: zod_1.z
        .string()
        .optional()
        .meta({
        description: "".concat(stepIndexDescription_js_1.STEP_INDEX_DESCRIPTION, " Position of the first step to delete. Deleting a step group or flow removes it and all its children. Either target_position or step_id must be provided; if both are provided, step_id takes precedence."),
    }),
    end_position: zod_1.z
        .string()
        .optional()
        .meta({
        description: "".concat(stepIndexDescription_js_1.STEP_INDEX_DESCRIPTION, " Position of the last step to delete (inclusive). When provided, deletes all steps from target_position through end_position. Both positions must be siblings (same parent). E.g. target_position=\"2.1\", end_position=\"2.3\" deletes steps 2.1, 2.2, and 2.3. Either end_position or end_step_id can be used; if both are provided, end_step_id takes precedence."),
    }),
    step_id: zod_1.z.string().optional().meta({
        description: 'Stable canonical step id of the first step to delete. Preferred over target_position when the test execution state exposes step ids — ids survive list mutations and avoid stale-index races. When both step_id and target_position are provided, step_id wins.',
    }),
    end_step_id: zod_1.z.string().optional().meta({
        description: 'Stable canonical step id of the last step to delete (inclusive). Must be a sibling of step_id (same parent in the canonical step tree). Preferred over end_position when the test execution state exposes step ids. When both end_step_id and end_position are provided, end_step_id wins.',
    }),
})
    .superRefine(function (value, ctx) {
    if (value.target_position === undefined && value.step_id === undefined) {
        ctx.addIssue({
            code: 'custom',
            path: ['target_position'],
            message: 'Provide either target_position or step_id to identify the first step to delete.',
        });
    }
});
exports.executeDeleteStepsFlexResponseSchema = zod_1.z.object(__assign({ success: zod_1.z.boolean(), message: zod_1.z.string().optional() }, refreshedStepsResponseFields_js_1.refreshedStepsResponseFields));
exports.ExecuteDeleteStepsFlexToolDefinition = (0, toolDefinition_js_1.defineTool)({
    name: 'execute_delete_steps',
    description: 'Deletes the step at the specified position, or a range of sibling steps when an end position is provided. If the step is a step group or flow, the entire container and all children are removed.\n\n' +
        'Identify the target step with either a dot-notation position (target_position) or a stable step id (step_id); the id-based form wins when both are provided. Range deletion likewise accepts end_position or end_step_id.\n\n' +
        "WARNING: Deleting steps changes all subsequent step indices. The refreshed step list is returned in this tool's output (updated_test_steps) — re-anchor on it before using other index-based tools (if absent on an older client, call get_test_context). Step ids, when available, remain stable across deletes of unrelated siblings.\n\n" +
        'CAUTION: mabl automatically inserts "Switch Context" steps when actions target elements inside iframes. Be careful not to delete these — they are required for the test to replay correctly. Always check the step list with get_test_context before deleting.',
    argumentsSchema: exports.executeDeleteStepsFlexArgumentsSchema,
    responseSchema: exports.executeDeleteStepsFlexResponseSchema,
});
//# sourceMappingURL=ExecuteDeleteStepsFlexDefinition.js.map