import Component from '../component.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import CoEuiInputText from './eui-input-text.js';
import CoEuiInputNumber from './eui-input-number.js';
import DivComponent from '../div.js';

export default class CoEuiTimepicker extends Component {
  constructor(parent) {
    let selector = 'eui-timepicker';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-timepicker/eui-timepicker.component.html?at=master
  }
  get timepickerCO() {
    return new DivComponent(this.currentPath).addPredicateClassContains('eui-timepicker');
  }
  async isDatetimepicker() {
    return await (await $(this.currentPath + '/self::*[contains(@class,"eui-timepicker--centered")]')).isExisting();
  }
  get inputTextCO() {
    return new CoEuiInputText(this.timepickerCO);
  }
  async isOneInputField() {
    return await (await this.inputTextCO.element()).isExisting();
  }
  //hour
  get hourInputContainerCO() {
    return new DivComponent(this.timepickerCO).addPredicateClassContains('eui-timepicker__input-container').addSelectorPredicate('[1]');
  }
  async isMultipleInputs() {
    return await (await this.hourInputContainerCO.element()).isExisting();
  }
  get hourIncreaseLinkCO() {
    return new DivComponent(this.hourInputContainerCO).addPredicateClassContains('eui-timepicker__hours-up');
  }
  async hourIsReadOnly() {
    return ! await (await this.hourIncreaseLinkCO.element()).isExisting();
  }
  get hourIncreaseIconCO() {
    return new CoEuiIconSvg(this.hourIncreaseLinkCO).addPredicateIconContains("eui-chevron-up");
  }
  get hourInputTextCO() {
    return new CoEuiInputNumber(this.hourInputContainerCO).addPredicateClassContains("eui-timepicker__input");
  }
  async hourInputIsReadOnly() {
    return await (await $(this.hourInputTextCO.currentPath + '[@readonly]')).isExisting();
  }
  get hourDecreaseLinkCO() {
    return new DivComponent(this.hourInputContainerCO).addPredicateClassContains('eui-timepicker__hours-down');
  }
  get hourDecreaseIconCO() {
    return new CoEuiIconSvg(this.hourDecreaseLinkCO).addPredicateIconContains("eui-chevron-down");
  }
  get hourMinuteSpacerCO() {
    return new DivComponent(this.timepickerCO).addPredicateClassContains('eui-timepicker__spacer').addSelectorPredicate('[1]');
  }
  //minutes
  get minutesInputContainerCO() {
    return new DivComponent(this.timepickerCO).addPredicateClassContains('eui-timepicker__input-container').addSelectorPredicate('[2]');
  }
  get minutesIncreaseChevronLinkCO() {
    return new DivComponent(this.minutesInputContainerCO).addPredicateClassContains('eui-timepicker__minutes-up');
  }
  get minutesIncreaseChevronIconCO() {
    return new CoEuiIconSvg(this.minutesIncreaseChevronLinkCO).addPredicateIconContains("eui-chevron-up");
  }
  get minutesInputCO() {
    return new CoEuiInputNumber(this.minutesInputContainerCO).addPredicateClassContains("eui-timepicker__input");
  }
  async minutesInputIsReadOnly() {
    return await (await $(this.minutesInputCO.currentPath + '[@readonly]')).isExisting();
  }
  get minutesDecreaseLinkCO() {
    return new DivComponent(this.minutesInputContainerCO).addPredicateClassContains('eui-timepicker__minutes-down');
  }
  get minutesDecreaseIconCO() {
    return new CoEuiIconSvg(this.minutesDecreaseLinkCO).addPredicateIconContains("eui-chevron-down");
  }
  async hasSeconds() {
    let spacerState = await (await this.minutesSecondsSpacerCO.element()).isExisting();
    let secondsInputState = await (await this.secondsInputContainerCO.element()).isExisting();
    if (spacerState && secondsInputState) {
      return true;
    } else {
      return false;
    }
  }
  get minutesSecondsSpacerCO() {
    return new DivComponent(this.timepickerCO).addPredicateClassContains('eui-timepicker__spacer').addSelectorPredicate('[2]');
  }
  //seconds
  get secondsInputContainerCO() {
    return new DivComponent(this.timepickerCO).addPredicateClassContains('eui-timepicker__input-container').addSelectorPredicate('[3]');
  }
  get secondsIncreaseLinkCO() {
    return new DivComponent(this.secondsInputContainerCO).addPredicateClassContains('eui-timepicker__seconds-up');
  }
  get secondsIncreaseIconCO() {
    return new CoEuiIconSvg(this.secondsIncreaseLinkCO).addPredicateIconContains("eui-chevron-up");
  }
  get secondsInputCO() {
    return new CoEuiInputNumber(this.secondsInputContainerCO).addPredicateClassContains("eui-timepicker__input");
  }
  async secondsInputIsReadOnly() {
    return await (await $(this.secondsInputCO.currentPath + '[@readonly]')).isExisting();
  }
  get secondsDecreaseLinkCO() {
    return new DivComponent(this.secondsInputContainerCO).addPredicateClassContains('eui-timepicker__seconds-down');
  }
  get secondsDecreaseIconCO() {
    return new CoEuiIconSvg(this.secondsDecreaseLinkCO).addPredicateIconContains("eui-chevron-down");
  }
}
