import Component  from '../component.js';
import CoEuiButton from './eui-button.js';
import CoEuiInputGroup from './eui-input-group.js';
import CoEuiInputText from './eui-input-text.js';
import DivComponent from '../div.js';
import CoEuiIconSvg from './eui-icon-svg.js';
import SpanComponent from '../span.js';
import MatDatepickerContent from '../material/mat-datepicker-content.js';
import CdkOverlayContainer from '../cdk-overlay-container.js';
import MatDatepicker from '../material/mat-datepicker.js';

export default class CoEuiDatepicker extends Component {
  constructor(parent) {
    let selector = 'eui-datepicker';
    super(parent, selector);
    //https://citnet.tech.ec.europa.eu/CITnet/stash/projects/CSDR/repos/eui/browse/packages/components/eui-datepicker/eui-datepicker.component.html?at=master
  }

  get inputGroupCO() {
    return new CoEuiInputGroup(this.currentPath);
  }
  get inputGroupAddonDivCO() {
    return new DivComponent(this.inputGroupCO).addPredicateClassContains('eui-input-group-addon');
  }
  get inputTextCO() {
    return new CoEuiInputText(this.inputGroupAddonDivCO);
  }
  async isReadOnly() {
    return await (await $(this.inputTextCO.currentPath + '/self::input[@readonly]')).isExisting();
  }
  async isClearable() {
    return await (await $(this.inputTextCO.currentPath + '/self::input[@euiClearable]')).isExisting();
  }
  async hasNoButton() {
    return await (await $(this.inputTextCO.currentPath + '/self::input[contains(@class, "eui-datepicker--no-button")]')).isExisting();
  }
  async hasLongFormat() {
    return await (await $(this.inputTextCO.currentPath + '/self::input[contains(@class, "eui-datepicker--long-format")]')).isExisting();
  }
  get matDatePickerCO() {
    return new MatDatepicker(this.inputGroupAddonDivCO);
  }
  get btnCO() {
    return new CoEuiButton(this.inputGroupAddonDivCO);
  }
  async hasButton() {
    return await (await this.btnCO.element()).isExisting();
  }
  get openCalendarEuiIconSvgCO() {
    return new CoEuiIconSvg(this.btnCO).byAttributeContains('aria-label', 'Open Calendar');
  }
  async isNotTogglerLabelAndIsNotTogglerIcon() {
    return await (await this.openCalendarEuiIconSvgCO.element()).isExisting();
  }
  get togglerLabelSpanCO() {
    return new SpanComponent(this.btnCO).addSelectorPredicate('[not(contains(@euiicon))]');
  }
  async hasTogglerLabel() {
    return await (await this.togglerLabelSpanCO.element()).isExisting();
  }
  get euiActionButtons() {
    return this.currentPath + '//eui-action-buttons';
  }
    // is not in the template but put here due to datepicker-actions implementation done for ux
  get overlayContainerCO() {
    return new CdkOverlayContainer('//body');
  }
  get matDatepickerContentCo() {
    return new MatDatepickerContent(this.overlayContainerCO.overlayPane);
  }
}


