"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.saveScreenshot = saveScreenshot;
exports.errorResult = errorResult;
const logger_1 = require("../../../lib/logger");
const storage_1 = require("../../../lib/storage");
async function saveScreenshot(page, filePath, fullPage) {
    const backend = (0, storage_1.getStorageBackend)();
    const localPath = await backend.getLocalPath(filePath);
    await page.screenshot({ path: localPath, fullPage });
    const { size } = await backend.commitLocalPath(filePath, localPath);
    logger_1.loggerRegistry.info(`[lt-mcp:playwright-cli] screenshot: ${filePath} (${size} bytes)`);
    return { path: filePath, size_bytes: size };
}
function errorResult(message, code, details) {
    return {
        content: [{ type: 'text', text: JSON.stringify({ error: message, code, ...details }) }],
        isError: true,
    };
}
