import { Icon } from '../../../icon-base';
import { Spinner } from '../../../spinner';
/**
 * Page object for `nimble-table-column-mapping`.
 */
export class TableColumnMappingPageObject {
    constructor(tablePageObject) {
        this.tablePageObject = tablePageObject;
    }
    getRenderedCellIconSeverity(rowIndex, columnIndex) {
        const iconOrSpinner = this.getRenderedIconOrSpinner(this.tablePageObject.getRenderedCellView(rowIndex, columnIndex));
        if (!(iconOrSpinner instanceof Icon)) {
            throw new Error(`Icon not found at cell ${rowIndex},${columnIndex}`);
        }
        return iconOrSpinner.severity ?? '';
    }
    getRenderedCellIconAriaLabel(rowIndex, columnIndex) {
        const iconOrSpinner = this.getRenderedIconOrSpinner(this.tablePageObject.getRenderedCellView(rowIndex, columnIndex));
        return iconOrSpinner.getAttribute('aria-label') ?? '';
    }
    getRenderedCellIconAriaHidden(rowIndex, columnIndex) {
        const iconOrSpinner = this.getRenderedIconOrSpinner(this.tablePageObject.getRenderedCellView(rowIndex, columnIndex));
        return iconOrSpinner.getAttribute('aria-hidden') ?? '';
    }
    getRenderedGroupHeaderIconAriaHidden(groupRowIndex) {
        const iconOrSpinner = this.getRenderedIconOrSpinner(this.tablePageObject.getGroupRowHeaderView(groupRowIndex));
        return iconOrSpinner.getAttribute('aria-hidden') ?? '';
    }
    getRenderedCellIconTitle(rowIndex, columnIndex) {
        const iconOrSpinner = this.getRenderedIconOrSpinner(this.tablePageObject.getRenderedCellView(rowIndex, columnIndex));
        return iconOrSpinner.title;
    }
    getRenderedGroupHeaderIconTagName(groupRowIndex) {
        const iconOrSpinner = this.getRenderedIconOrSpinner(this.tablePageObject.getGroupRowHeaderView(groupRowIndex));
        return iconOrSpinner.tagName.toLocaleLowerCase();
    }
    getRenderedCellTextTitle(rowIndex, columnIndex) {
        const cellView = this.tablePageObject.getRenderedCellView(rowIndex, columnIndex);
        const textElement = this.getRenderedTextElement(cellView);
        return textElement?.title ?? '';
    }
    getRenderedGroupHeaderTextTitle(groupRowIndex) {
        const groupHeader = this.tablePageObject.getGroupRowHeaderView(groupRowIndex);
        const textElement = this.getRenderedTextElement(groupHeader);
        return textElement?.title ?? '';
    }
    getRenderedCellText(rowIndex, columnIndex) {
        const cellView = this.tablePageObject.getRenderedCellView(rowIndex, columnIndex);
        const textElement = this.getRenderedTextElement(cellView);
        return textElement?.textContent?.trim() ?? '';
    }
    getRenderedGroupHeaderText(groupRowIndex) {
        const groupHeader = this.tablePageObject.getGroupRowHeaderView(groupRowIndex);
        const textElement = this.getRenderedTextElement(groupHeader);
        return textElement?.textContent?.trim() ?? '';
    }
    dispatchEventToCellText(rowIndex, columnIndex, event) {
        const cellView = this.tablePageObject.getRenderedCellView(rowIndex, columnIndex);
        const textElement = this.getRenderedTextElement(cellView);
        return textElement.dispatchEvent(event);
    }
    dispatchEventToGroupHeaderText(groupRowIndex, event) {
        const groupHeader = this.tablePageObject.getGroupRowHeaderView(groupRowIndex);
        const textElement = this.getRenderedTextElement(groupHeader);
        return textElement.dispatchEvent(event);
    }
    getRenderedIconOrSpinner(view) {
        const viewShadowRoot = view.shadowRoot;
        const spinnerOrIcon = viewShadowRoot.querySelector('.reserve-icon-size')?.firstElementChild;
        if (!(spinnerOrIcon instanceof Icon || spinnerOrIcon instanceof Spinner)) {
            throw new Error('Icon or Spinner not found');
        }
        return spinnerOrIcon;
    }
    getRenderedTextElement(view) {
        return view.shadowRoot.querySelector('.text');
    }
}
//# sourceMappingURL=table-column-mapping.pageobject.js.map