// © 2026 SolarWinds Worldwide, LLC. All rights reserved.
import * as fs from "fs";
export class EyesLens {
    constructor(page, settings) {
        this.page = page;
        this.settings = settings;
        this.snapshotsFolderName = "_snapshots";
    }
    async takeSnapshot(label) {
        await this.ensureDir();
        const filePath = this.buildFilePath(label);
        const buffer = await this.page.screenshot({ fullPage: false });
        await fs.promises.writeFile(filePath, buffer);
    }
    async takeFullScreenSnapshot(label) {
        await this.ensureDir();
        const filePath = this.buildFilePath(label);
        const buffer = await this.page.screenshot({ fullPage: true });
        await fs.promises.writeFile(filePath, buffer);
    }
    async cameraON() {
        await this.page.addStyleTag({
            content: "input, textarea { caret-color: transparent;} * {cursor: none !important;}",
        });
    }
    async cameraOFF() {
        // no-op
    }
    toolConfig() {
        return { name: "eyes", outputDir: this.snapshotsFolderName };
    }
    buildFilePath(label) {
        const safeTest = this.settings.currentTestName.replace(/[\\\/\s]/g, "_");
        const safeLabel = label.replace(/[\\\/\s]/g, "_");
        return `${this.snapshotsFolderName}/${safeTest}_${safeLabel}.png`;
    }
    async ensureDir() {
        if (!fs.existsSync(this.snapshotsFolderName)) {
            await fs.promises.mkdir(this.snapshotsFolderName, {
                recursive: true,
            });
        }
    }
}
//# sourceMappingURL=eyes-lens.js.map