import { processUpdates } from '../../../testing/async-helpers';
/**
 * A page object for the elements that use the error pattern mixin.
 */
export class ErrorPatternPageObject {
    constructor(element) {
        this.element = element;
    }
    isErrorIconVisible() {
        const icon = this.getErrorIconElement();
        if (!icon) {
            return false;
        }
        return getComputedStyle(icon).display !== 'none';
    }
    getDisplayedErrorText() {
        const errorTextDiv = this.getErrorTextElement();
        if (!errorTextDiv
            || getComputedStyle(errorTextDiv).display === 'none') {
            return '';
        }
        return errorTextDiv.textContent?.trim() ?? '';
    }
    getErrorTextTitle() {
        const errorTextDiv = this.getErrorTextElement();
        if (!errorTextDiv) {
            throw new Error('Error text element not found');
        }
        return errorTextDiv.title;
    }
    dispatchEventToErrorText(event) {
        const errorTextDiv = this.getErrorTextElement();
        if (!errorTextDiv) {
            throw new Error('Error text element not found');
        }
        errorTextDiv.dispatchEvent(event);
        processUpdates();
    }
    getErrorIconElement() {
        return this.element.shadowRoot.querySelector('.error-icon');
    }
    getErrorTextElement() {
        return this.element.shadowRoot.querySelector('.error-text');
    }
}
//# sourceMappingURL=error-pattern.pageobject.js.map