import Component  from '../component.js'

export default class CoUxAtoolbarFilter extends Component {
    constructor(parent) {
      let selector = 'div[@data-e2e="ux-a-toolbar-filter"]';
      super(parent, selector);
    }
    get filterContent() {
      let path = '//div[contains(@class, "ux-a-toolbar-filter-content")]';
      return this.currentPath + path;
    }
    get toolbarFilter() {
      let path = '//div[contains(@class, "ux-a-toolbar-filter-filter")]';
      return this.filterContent + path;
    }
    get inputGroup() {
      let path = '//div[contains(@class, "input-group")]';
      return this.toolbarFilter + path;
    }
    get inputGroupPrepend() {
      let path = '//span[contains(@class, "input-group-prepend")]';
      return this.inputGroup + path;
    }
    get inputGroupTextSpan() {
      let path = '//span[contains(@class, "input-group-text")]';
      return this.inputGroupPrepend + path;
    }
    get inputGroupPrependIcon() {
      let path = '//span[contains(@class, "ux-icon-search")]';
      return this.inputGroupTextSpan + path;
    }

    get inputGroupFilterInput() {
      let path = '//input[contains(@class, "ux-a-toolbar-filter-filter-input")]';
      return this.inputGroup + path;
    }
    async isToggleVisible() {
      let cl = await (await $(this.filterContent + '//div[contains(@class, "ux-a-toolbar-filter-trigger-wrapper")]')).isExisting();
      if (cl) {
         return true;
      } else {
         return false;
      }
    }
    async isFilterVisible() {
      let cl = await (await $(this.filterContent + '//div[contains(@class, "ux-a-toolbar-filter-filter")]')).isExisting();
      if (cl) {
         return true;
      } else {
         return false;
      }
    }
    get toolbarFilterTriggerWrapper() {
      let path = '//div[contains(@class, "ux-a-toolbar-filter-trigger-wrapper")]';
      return this.filterContent + path;
    }
    get toolbarFilterTriggerButton() {
      let path = '//button[contains(@class, "ux-a-toolbar-filter-trigger")]';
      return this.toolbarFilterTriggerWrapper + path;
    }
    get toolbarFilterTriggerButtonIconSpan() {
      let path = '//span[contains(@class, "ux-a-toolbar-filter-trigger-icon")]';
      return this.toolbarFilterTriggerButton + path;
    }
    get toolbarFilterButtonsPlaceholder() {
      let path = '//uxToolbarFilterButtons';
      return this.toolbarFilterTriggerWrapper + path;
    }
    get toolbarFilterTriggerFlex() {
      let path = '//div[contains(@class, "d-flex-none")]';
      return this.filterContent + path;
    }
    async isToggleExpanded() {
      let cl = await (await $(this.toolbarFilterTriggerButtonIconSpan)).getAttribute('class');
      if (cl.includes('ux-icon-level-down')) {
         return false;
      } else if (cl.includes('ux-icon-level-up')) {
         return true;
      }
    }
}


