"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConnectorMarketplacePage = void 0;
const sleep_1 = require("../../utils/sleep");
class ConnectorMarketplacePage {
    page;
    searchForConnectorTextbox;
    downloadToProjectButton;
    replaceResourceButton;
    cancelButton;
    constructor(page) {
        this.page = page;
        this.searchForConnectorTextbox = page.getByPlaceholder('Search for a connector');
        this.downloadToProjectButton = page
            .getByRole('button', { name: 'Download to project' })
            .first();
        this.cancelButton = page.getByRole('button', { name: 'Cancel' });
        this.replaceResourceButton = page.getByRole('button', {
            name: 'Replace resource',
        });
    }
    async clickSearchForConnectorTextbox() {
        await this.searchForConnectorTextbox.click({ timeout: 60000 });
        await (0, sleep_1.sleep)(2000);
    }
    async fillSearchForConnectorTextbox(connectorName) {
        await this.searchForConnectorTextbox.fill(connectorName, { timeout: 60000 });
        await (0, sleep_1.sleep)(2000);
    }
    async clickDownloadToProjectButton() {
        await this.downloadToProjectButton.click({ timeout: 60000 });
    }
    async clickCancelButton() {
        await this.cancelButton.click({ timeout: 30000 });
    }
    async clickReplaceResourceButton() {
        await this.replaceResourceButton.click({ timeout: 30000 });
    }
    async downloadConnectorToProject() {
        await this.clickDownloadToProjectButton();
        try {
            await Promise.race([
                this.replaceResourceButton.click({ timeout: 20000 }),
                this.cancelButton.click({ timeout: 20000 }),
            ]);
        }
        catch (e) {
            return;
        }
    }
}
exports.ConnectorMarketplacePage = ConnectorMarketplacePage;
