import Component from '../../component.js'
import CoEuiDropdown from './eui-dropdown.js'
import CoEuiButton from './eui-button.js'
import CdkOverlayContainer from '../../cdk-overlay-container.js'
import CoEuiDropdownContent from './eui-dropdown-content.js'
import CoEuiList from './eui-list.js'
import CoEuiLabel from './eui-label.js'


export default class CoEuiTablePaginator extends Component {
  constructor(parent) {
    let selector = 'eui-table-paginator';
    super(parent, selector);
    this.overlayContainer = new CdkOverlayContainer('//body');
  //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components-next/src/lib/components/eui-table/paginator/eui-table-paginator.component.html?at=support/10.x
  }

  get paginator() {
    return this.currentPath + '//div[contains(@class,"eui-table-paginator")]';
  }
  get pageSizeSelector() {
    return this.paginator + '//div[contains(@class, "eui-table-paginator__page-size-selector")]';
  }
  get dropdownCO() {
    return new CoEuiDropdown(this.pageSizeSelector);
  }
  get labelCO() {
    return new CoEuiLabel(this.euiButtonCO);
  }
  get carretDown() {
    return this.dropdownCO.euiButtonCO.container + '//span[contains(@class, "eui-icon-caret-down")]'
  }
  get dropdownContentCO() {
    return new CoEuiDropdownContent(this.overlayContainer.overlayPane);
  }
  get listCO() {
    return new CoEuiList(this.dropdownContentCO);
  }
  get pageSizeOption() {
    return this.listCO.euiListItemCO.itemButton;
  }
  get navigator() {
    return this.paginator + '//div[contains(@class, "eui-table-paginator__page-navigation")]';
  }
  get navigatorItem() {
    return this.navigator + '//div[contains(@class, "eui-table-paginator__page-navigation-item")]';
  }
  get navigatorItemButtonCO() {
    return new CoEuiButton(this.navigatorItem);
  }
  // arrorw buttons and icons
  get caretFirst() {
    return this.navigatorItemButtonCO.container + '//span[contains(@class, "eui-icon-caret-first")]';
  }
  get caretFirstButton() {
    return this.caretFirst + '/ancestor-or-self::button[1]'
  }
  get caretLeft() {
    return this.navigatorItemButtonCO.container + '//span[contains(@class, "eui-icon-caret-left")]';
  }
  get caretLeftButton() {
    return this.caretLeft + '/ancestor-or-self::button[1]';
  }
  get caretRight() {
    return this.navigatorItemButtonCO.container + '//span[contains(@class, "eui-icon-caret-right")]';
  }
  get caretRightButton() {
    return this.caretRight + '/ancestor-or-self::button[1]';
  }
  get caretLast() {
    return this.navigatorItemButtonCO.container + '//span[contains(@class, "eui-icon-caret-last")]';
  }
  get caretLastButton() {
    return this.caretLast + '/ancestor-or-self::button[1]';
  }
  get pageRange() {
    return this.paginator + '//div[contains(@class, "eui-table-paginator__page-range")]';
  }
}


