"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClientCredentialsDetailsPage = void 0;
const test_1 = require("@playwright/test");
class ClientCredentialsDetailsPage {
    page;
    operateUrlRow;
    operateUrlValue;
    clientNameHeading;
    constructor(page) {
        this.page = page;
        this.operateUrlRow = page.getByRole('cell', { name: 'Operate URL' });
        this.operateUrlValue = this.operateUrlRow.getByRole('textbox');
        this.clientNameHeading = (clientName) => page.getByRole('heading', { name: clientName });
    }
    async isOpen(clientName) {
        await (0, test_1.expect)(this.clientNameHeading(clientName).or(this.operateUrlRow).first()).toBeVisible({ timeout: 60000 });
    }
    async getOperateUrl() {
        if (await this.operateUrlValue.isVisible({ timeout: 10000 }).catch(() => false)) {
            return await this.operateUrlValue.inputValue();
        }
        const text = await this.page.innerText('body');
        const match = text.match(/Operate URL\s*([\w:/.-]+\/?)/i);
        if (!match || !match[1]) {
            throw new Error('Operate URL not found in client credentials page');
        }
        return match[1];
    }
    async goBack() {
        await this.page.goBack();
    }
}
exports.ClientCredentialsDetailsPage = ClientCredentialsDetailsPage;
