import { waitForUpdatesAsync } from '@ni/nimble-components/dist/esm/testing/async-helpers';
/**
 * Page object for the `ok-fv-search-input` component to provide consistent
 * ways of querying and interacting with the component during tests.
 */
export class FvSearchInputPageObject {
    constructor(searchInputElement) {
        this.searchInputElement = searchInputElement;
    }
    getInputValue() {
        return this.getInput().value;
    }
    getPlaceholder() {
        return this.getInput().placeholder;
    }
    getInputAriaLabel() {
        return this.getInput().getAttribute('aria-label');
    }
    getInputAriaLabelledby() {
        return this.getInput().getAttribute('aria-labelledby');
    }
    async typeText(text) {
        const input = this.getInput();
        input.value = text;
        input.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
        await waitForUpdatesAsync();
    }
    async commitText(text) {
        const input = this.getInput();
        input.value = text;
        input.dispatchEvent(new Event('change', { bubbles: true }));
        await waitForUpdatesAsync();
    }
    async clickClearButton() {
        const button = this.getClearButton();
        if (!button) {
            throw new Error('Clear button not found — is the search input value non-empty?');
        }
        button.click();
        await waitForUpdatesAsync();
    }
    isClearButtonVisible() {
        return !!this.searchInputElement.shadowRoot?.querySelector('.search-input-clear');
    }
    isInputDisabled() {
        return this.getInput().disabled;
    }
    isInputReadOnly() {
        return this.getInput().readOnly;
    }
    isInputAutofocus() {
        return this.getInput().autofocus;
    }
    getInput() {
        const input = this.searchInputElement.shadowRoot?.querySelector('.search-input');
        if (!input) {
            throw new Error('Search input element not found');
        }
        return input;
    }
    getClearButton() {
        return this.searchInputElement.shadowRoot?.querySelector('.search-input-clear') ?? null;
    }
}
//# sourceMappingURL=fv-search-input.pageobject.js.map