import Component from '../component.js';
import MatDateRangeInput from '../material/mat-date-range-input.js';
import MatDateRangePicker from '../material/mat-date-range-picker.js';
import CoEuiButton from './eui-button.js';
import CoEuiInputText from './eui-input-text.js';
import CoEuiIcon from './eui-icon.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import DivComponent from '../div.js';
import SpanComponent from '../span.js';

export default class CoEuiDateRangeSelector extends Component {
  constructor(parent) {
    let selector = 'eui-date-range-selector';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-date-range-selector/eui-date-range-selector.component.html?at=master
  }
  get divCo() {
    return new DivComponent(this.currentPath).addPredicateAttributeContains('data-e2e', 'eui-date-range-selector');
  }
  async isResponsive() {
    return await (await $(this.divCo.currentPath + '/self::div[contains(@class, "eui-date-range-selector--responsive")]')).isExisting();
  }
  get matDateRangeInputCo() {
    return new MatDateRangeInput(this.divCo);
  }
  async isReadOnly() {
    return await (await $(this.matDateRangeInputCo.currentPath + '/self::div[contains(@class, "mat-date-range-input--read-only")]')).isExisting();
  }
  async isDisabled() {
    return await (await $(this.matDateRangeInputCo.currentPath + '/self::div[contains(@class, "mat-date-range-input--disabled")]')).isExisting();
  }
  async isInvalid() {
    return await (await $(this.matDateRangeInputCo.currentPath + '/self::div[contains(@class, "mat-date-range-input--invalid")]')).isExisting();
  }
  get startDateInputTextCo() {
    return new CoEuiInputText(this.matDateRangeInputCo).addPredicateClassContains('eui-date-range-selector__start-date');
  }
  get endDateInputTextCo() {
    return new CoEuiInputText(this.matDateRangeInputCo).addPredicateClassContains('eui-date-range-selector__end-date');
  }
  get matDateRangePicker() {
    return new MatDateRangePicker(this.divCo);
  }
  get togglerButtonCo() {
    return new CoEuiButton(this.divCo).addPredicateClassContains('eui-date-range-selector__toggler');
  }
  get togglerIconCo() {
    return new CoEuiIcon(this.togglerButtonCo).addPredicateAttributeContains('aria-label', 'Open Calendar');
  }
  async hasTogglerIcon() {
    return await (await this.togglerIconCo.element()).isExisting();
  }
  get togglerIconSvgCo() {
    return new CoEuiIconSvg(this.togglerIconCo).addPredicateAttributeContains('aria-label', 'Open Calendar');
  }
  async hasTogglerIconSvg() {
    return await (await this.togglerIconSvgCo.element()).isExisting();
  }
  get togglerLabelCo() {
    return new SpanComponent(this.togglerButtonCo).addSelectorPredicate('[not(contains(@euiicon))]');
  }
  async hasTogglerLabel() {
    return await (await this.togglerLabelCo.element()).isExisting();
  }
}


