"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runAIAssertion = runAIAssertion;
const AssertStep_1 = __importDefault(require("./mablscript/canonical/AssertStep"));
const variable_utils_1 = require("./variable-utils");
async function runAIAssertion(eventHandler, variables, findDescriptor, assertionProps, newFrameId, newTabId) {
    const { originalFrameId, originalTabId } = eventHandler.maybeSwitchTabAndFrame(newFrameId, newTabId);
    const step = new AssertStep_1.default((0, variable_utils_1.canonicalizeVariablePatternsInObject)(variables, findDescriptor), (0, variable_utils_1.canonicalizeVariablePatternsInObject)(variables, assertionProps));
    const assertionResult = await eventHandler.runSingleStep(step, {
        resolveVariablesInApi: true,
    });
    eventHandler.maybeSwitchTabAndFrame(originalFrameId, originalTabId);
    return assertionResult;
}
