import { ElementIDUtils, ObjectUtils } from "@sankhyalabs/core";
import { h, Host } from "@stencil/core";
import { CSSVarsUtils } from "../../utils";
import initI18n from '../../utils/i18n';
export class EzComboBox {
  constructor() {
    this._changeDeboucingTimeout = null;
    this._deboucingTime = 300;
    this._maxWidthValue = 0;
    this._tabPressed = false;
    this._lookupMode = false;
    this.isOpen = false;
    this._preSelection = undefined;
    this._visibleOptions = undefined;
    this._startLoading = false;
    this._showLoading = true;
    this._criteria = undefined;
    this.limitCharsToSearch = 3;
    this.value = undefined;
    this.label = undefined;
    this.enabled = true;
    this.options = undefined;
    this.errorMessage = undefined;
    this.showSelectedValue = false;
    this.showOptionValue = false;
    this.suppressSearch = false;
    this.optionLoader = undefined;
    this.suppressEmptyOption = false;
    this.stopPropagateEnterKeyEvent = true;
    this.canShowError = true;
    this.mode = "regular";
    this.hideErrorOnFocusOut = true;
    this.listOptionsPosition = undefined;
    this.isTextSearch = false;
    this.autoFocus = false;
    this.preventAutoFocus = false;
    this.alternativePlaceholder = undefined;
    this.textEmptyOption = undefined;
  }
  observeErrorMessage() {
    var _a;
    if (this._textInput) {
      this._textInput.errorMessage = this.errorMessage;
      if (!((_a = this.errorMessage) === null || _a === void 0 ? void 0 : _a.trim())) {
        this.setInputValue();
      }
    }
  }
  observeValue(newValue, oldValue) {
    if (this._textInput && newValue != oldValue) {
      try {
        if (typeof newValue === "string") {
          this.setInputValue();
          return;
        }
        const newValueSelected = this.getSelectedOption(newValue);
        const oldValueSelected = this.getSelectedOption(oldValue);
        const currentValue = this.getSelectedOption(this.value);
        if (this.isDifferentValues(currentValue, newValueSelected)) {
          this.value = newValueSelected;
        }
        if (this.isDifferentValues(newValueSelected, oldValueSelected)) {
          this.setInputValue();
          const valueEmitted = newValueSelected === null ? undefined : newValueSelected;
          if (!this._lookupMode) {
            this.ezChange.emit(valueEmitted);
          }
        }
        this.resetOptions();
      }
      finally {
        this._lookupMode = false;
      }
    }
  }
  observeOptions(newOptions, oldOptions) {
    if (ObjectUtils.equals(newOptions, oldOptions))
      return;
    this.loadOptions(SearchMode.PRELOAD);
  }
  /*
  * Retorna uma promise com o valor da opção selecionada,
  * que será resolvida quando o backend devolver este dado.
  */
  async getValueAsync() {
    if (!this._showLoading) {
      return new Promise(resolve => resolve(this.sanitizeValue(this.value)));
    }
    return new Promise(resolve => {
      let id = setInterval(() => {
        if (!this._showLoading) {
          clearInterval(id);
          resolve(this.sanitizeValue(this.value));
        }
      }, 100);
    });
  }
  /**
   * Aplica o foco no campo.
   */
  async setFocus(options) {
    if (this._textInput) {
      this._textInput.setFocus(options);
    }
  }
  /**
   * Remove o foco do campo.
   */
  async setBlur() {
    if (this._textInput) {
      this._textInput.setBlur();
    }
  }
  /**
   * Retorna se o conteúdo é inválido.
   */
  async isInvalid() {
    return typeof this.errorMessage === "string" && this.errorMessage.trim() !== "";
  }
  /**
   * Limpa o valor do campo de pesquisa
   */
  async clearValue() {
    this.clearSearch();
  }
  isDifferentValues(firstValue, secondValue) {
    return ObjectUtils.objectToString(firstValue || {}) !== ObjectUtils.objectToString(secondValue || {});
  }
  getFormattedText(currentValue) {
    if (currentValue == undefined) {
      return;
    }
    if (!this.showSelectedValue || currentValue.value == undefined) {
      return currentValue.label;
    }
    return currentValue.label ? `${currentValue.value} - ${currentValue.label}` : currentValue.value;
  }
  getText() {
    const currentValue = this.getSelectedOption(this.sanitizeValue(this.value));
    const text = this.getFormattedText(currentValue);
    if (text == undefined) {
      return;
    }
    return String(text)
      .replace(/&amp;/g, '&')
      .replace(/&lt;/g, '<')
      .replace(/&gt;/g, '>')
      .replace(/&quot;/g, '"');
  }
  getSelectedOption(value) {
    if (typeof value === "string" || value instanceof String) {
      return this._visibleOptions.find(o => o.value === value);
    }
    return value;
  }
  updateVisibleOptions() {
    let opts = this._source || [];
    if (this._criteria) {
      const upperCriteria = this._criteria.toUpperCase();
      opts = opts.filter(opt => opt.label.toLocaleUpperCase().indexOf(upperCriteria) > -1);
    }
    if (this.hasToAddEmptyoption(opts)) {
      opts = [{ value: undefined, label: this.textEmptyOption || this.i18n("ez-combo-box.placeholder") }].concat(opts);
    }
    this._visibleOptions = opts;
    this._maxWidthValue = this.getMaxWidthValue();
  }
  hasToAddEmptyoption(opts) {
    return !this.suppressEmptyOption && !opts.filter(opt => !opt.value).length;
  }
  getMaxWidthValue() {
    var _a;
    if (this.showOptionValue) {
      const arrValues = [];
      (_a = this._visibleOptions) === null || _a === void 0 ? void 0 : _a.forEach(opt => {
        const widthValue = this.getWidthValue(opt.value);
        if (!arrValues.includes(widthValue)) {
          arrValues.push(widthValue);
        }
      });
      return arrValues.length > 1 ? Math.max(...arrValues) : 0;
    }
    return 0;
  }
  getWidthValue(value) {
    if (this._itemValueBasis != undefined) {
      const span = this._itemValueBasis;
      if (value != undefined) {
        span.innerHTML = value;
        return span.clientWidth > 0 ? (span.clientWidth + 2) : 0;
      }
      else {
        span.innerHTML = "";
      }
    }
    return 0;
  }
  async showOptions() {
    var _a, _b;
    if (!this.enabled)
      return;
    await this.openPopover();
    const valueString = (_b = (_a = this.value) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : this.value;
    const indexValue = this._visibleOptions.findIndex(option => option.value === valueString);
    this._preSelection = indexValue === -1 ? 0 : indexValue;
    if (!!this._resizeObserver)
      this._resizeObserver.observe(this._textInput);
    if (!this.preventAutoFocus)
      await this.setFocus();
  }
  hideOptions() {
    var _a;
    (_a = this._popover) === null || _a === void 0 ? void 0 : _a.hide();
    if (!!this._resizeObserver)
      this._resizeObserver.unobserve(this._textInput);
  }
  updateSource(source) {
    this._startLoading = false;
    if (source instanceof Promise) {
      this._showLoading = true;
      source.then(result => {
        this._showLoading = false;
        this.updateSource(result);
      }).catch(() => this._showLoading = false);
      this.updateVisibleOptions();
    }
    else {
      this._showLoading = false;
      if (Array.isArray(source)) {
        this._source = source;
        this.updateVisibleOptions();
        if (this._tabPressed) {
          this._tabPressed = false;
        }
      }
      else {
        this.selectOption(source);
      }
    }
  }
  selectOption(newOption, focusOnInput = true) {
    var _a, _b, _c;
    const currentValue = this.getSelectedOption(this.value);
    if ((((_a = currentValue === null || currentValue === void 0 ? void 0 : currentValue.value) === null || _a === void 0 ? void 0 : _a.toString()) !== ((_b = newOption === null || newOption === void 0 ? void 0 : newOption.value) === null || _b === void 0 ? void 0 : _b.toString()))
      || (currentValue == undefined && newOption != undefined && "value" in newOption)) {
      const adjustedOpt = !(newOption === null || newOption === void 0 ? void 0 : newOption.value) ? undefined : newOption;
      this.value = adjustedOpt;
      (_c = this._popover) === null || _c === void 0 ? void 0 : _c.hide();
    }
    else {
      this.resetOptions();
    }
    if (focusOnInput) {
      setTimeout(() => {
        this.setFocus();
      }, 0);
    }
  }
  loadOptions(mode, argument = "") {
    this._criteria = argument;
    this._startLoading = true;
    if (this.optionLoader) {
      const searchArgument = { mode, argument };
      this.updateSource(this.optionLoader(searchArgument));
    }
    else {
      this.updateSource(this.options);
    }
  }
  cancelPreselection() {
    if (!this._textInput.value && this.sanitizeValue(this.value)) {
      this.selectOption(undefined);
    }
    else {
      window.setTimeout(() => {
        this.setInputValue(false);
      }, this._deboucingTime);
    }
  }
  setInputValue(clearError = true) {
    const textValue = this.getText();
    if ((this._textInput.value || '') !== textValue) {
      this._textInput.value = textValue;
      if (clearError) {
        this.errorMessage = null;
      }
    }
  }
  clearSearch() {
    this.value = null;
  }
  resetOptions() {
    this.hideOptions();
    this._criteria = undefined;
    this._preSelection = undefined;
    this.updateVisibleOptions();
  }
  sanitizeValue(value) {
    if (value === "undefined" || value === "null") {
      return undefined;
    }
    return value;
  }
  //---------------------------------------------
  // Lifecycle web component
  //---------------------------------------------
  async componentWillLoad() {
    this.i18n = await initI18n();
    if (this.options === undefined) {
      this.options = [];
      const optionsTags = this.el.querySelectorAll("option");
      if (optionsTags) {
        optionsTags.forEach(e => {
          let label = e.innerText;
          let value = e.getAttribute("value");
          if (!value) {
            value = label;
          }
          this.options.push({ label, value });
          e.hidden = true;
        });
      }
    }
    this.loadOptions(SearchMode.PRELOAD);
  }
  setResizeObserver() {
    this._resizeObserver = new ResizeObserver((entries) => {
      window.requestAnimationFrame(() => {
        if (!Array.isArray(entries) || !entries.length)
          return;
        if (!this._textInput)
          return;
        if (!this._comboBoxList)
          return;
        const textInputWidth = this._textInput.clientWidth;
        this._comboBoxList.width = textInputWidth;
      });
    });
  }
  connectedCallback() {
    if (!this._resizeObserver) {
      this.setResizeObserver();
    }
  }
  componentDidLoad() {
    CSSVarsUtils.applyVarsTextInput(this.el, this._textInput);
    this.setInputValue(false);
    this.setResizeObserver();
    if (this.autoFocus) {
      requestAnimationFrame(() => {
        this.setFocus({ selectText: true });
      });
    }
  }
  disconnectedCallback() {
    var _a;
    (_a = this._popover) === null || _a === void 0 ? void 0 : _a.remove();
    if (this._resizeObserver) {
      this._resizeObserver.disconnect();
      this._resizeObserver = null;
    }
  }
  //---------------------------------------------
  // Event handlers
  //---------------------------------------------
  handlerIconClick() {
    this.showOptions();
  }
  onTextInputChangeHandler(event) {
    var _a;
    this.clearDeboucingTimeout();
    if (this._startLoading) {
      this._changeDeboucingTimeout = window.setTimeout(() => {
        this.onTextInputChangeHandler(event);
      }, this._deboucingTime);
      return;
    }
    const argument = (_a = event.target.value) === null || _a === void 0 ? void 0 : _a.trim();
    if (!this._criteria) {
      this._textInput.value = event.data || argument;
    }
    this._criteria = argument;
    if (argument) {
      this.updateVisibleOptions();
      this.showOptions();
    }
    else {
      this._preSelection = undefined;
      this.updateVisibleOptions();
    }
  }
  clearDeboucingTimeout() {
    if (this._changeDeboucingTimeout) {
      window.clearTimeout(this._changeDeboucingTimeout);
      this._changeDeboucingTimeout = null;
    }
  }
  onTextInputClickHandler() {
    this.showOptions();
  }
  keyDownHandler(event) {
    var _a, _b, _c, _d, _e, _f;
    if (event.ctrlKey && (event.key === "f" || event.key === "F")) {
      this.loadOptions(SearchMode.ADVANCED);
      event.preventDefault();
      event.stopPropagation();
      return;
    }
    switch (event.key) {
      case "ArrowDown":
        event.preventDefault();
        if (this.canShowListOptions()) {
          this.showOptions();
          (_a = this._comboBoxList) === null || _a === void 0 ? void 0 : _a.nextOption();
        }
        break;
      case "ArrowUp":
        event.preventDefault();
        if (this.canShowListOptions()) {
          this.showOptions();
          (_b = this._comboBoxList) === null || _b === void 0 ? void 0 : _b.previousOption();
        }
        break;
      case "Enter":
        if (this.isOpen) {
          event.preventDefault();
          (_c = this._comboBoxList) === null || _c === void 0 ? void 0 : _c.selectCurrentOption();
        }
        break;
      case "Escape":
        if (this.isOpen) {
          event.preventDefault();
          (_d = this._popover) === null || _d === void 0 ? void 0 : _d.hide();
        }
        break;
      case "Tab":
        this._tabPressed = true;
        if (this.isOpen) {
          (_e = this._comboBoxList) === null || _e === void 0 ? void 0 : _e.selectCurrentOption();
          (_f = this._popover) === null || _f === void 0 ? void 0 : _f.hide();
        }
        break;
    }
  }
  onTextInputFocusOutHandler() {
    if (this.hideErrorOnFocusOut)
      this.cancelPreselection();
  }
  canShowListOptions() {
    return !this._showLoading && this._visibleOptions.length > 0;
  }
  async openPopover() {
    var _a;
    this.isOpen = true;
    await ((_a = this._popover) === null || _a === void 0 ? void 0 : _a.showUnder(this._textInput));
  }
  render() {
    var _a;
    ElementIDUtils.addIDInfoIfNotExists(this.el, 'input');
    return (h(Host, null, h("ez-text-input", { "data-element-id": ElementIDUtils.getInternalIDInfo("textInput"), class: `text-input-slot-container ${this.suppressSearch ? "suppressed-search-input" : ""}`, ref: elem => this._textInput = elem, "data-slave-mode": "true", enabled: this.enabled && !this.suppressSearch, onInput: event => this.onTextInputChangeHandler(event), onClick: () => this.onTextInputClickHandler(), onFocusout: () => this.onTextInputFocusOutHandler(), onKeyDown: event => this.keyDownHandler(event), label: this.label, canShowError: this.canShowError, errorMessage: this.errorMessage, mode: this.mode, alternativePlaceholder: this.alternativePlaceholder || this.i18n("ez-combo-box.placeholder") }, h("button", { class: "btn", slot: "rightIcon", disabled: !this.enabled, tabindex: -1, onClick: () => this.handlerIconClick() }, h("ez-icon", { iconName: "chevron-down" }))), h("ez-popover-plus", { ref: elem => this._popover = elem, anchorElement: this._textInput, autoClose: true, boxWidth: 'fit-content', overlayType: 'none', onEzVisibilityChange: event => this.isOpen = event.detail, "data-element-id": this.el.getAttribute("data-element-id") }, h("ez-combo-box-list", { ref: ref => this._comboBoxList = ref, showLoading: this._showLoading, visibleOptions: this._visibleOptions, textEmptyList: this.i18n("ez-combo-box.noResults"), showOptionValue: this.showOptionValue, preSelection: this._preSelection, maxWidth: this._maxWidthValue, width: (_a = this._textInput) === null || _a === void 0 ? void 0 : _a.clientWidth, onOptionSelect: (opt) => this.selectOption(opt), onOptionHover: (index) => this._preSelection = index }))));
  }
  static get is() { return "ez-combo-box"; }
  static get encapsulation() { return "shadow"; }
  static get originalStyleUrls() {
    return {
      "$": ["ez-combo-box.css"]
    };
  }
  static get styleUrls() {
    return {
      "$": ["ez-combo-box.css"]
    };
  }
  static get properties() {
    return {
      "limitCharsToSearch": {
        "type": "number",
        "mutable": false,
        "complexType": {
          "original": "number",
          "resolved": "number",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define o limite de caracteres m\u00EDnimo para realizar uma pesquisa"
        },
        "attribute": "limit-chars-to-search",
        "reflect": false,
        "defaultValue": "3"
      },
      "value": {
        "type": "string",
        "mutable": true,
        "complexType": {
          "original": "IOption | string",
          "resolved": "IOption | string",
          "references": {
            "IOption": {
              "location": "local"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define o valor do campo."
        },
        "attribute": "value",
        "reflect": true
      },
      "label": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Texto a ser apresentado como t\u00EDtulo do campo."
        },
        "attribute": "label",
        "reflect": true
      },
      "enabled": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Se false o usu\u00E1rio n\u00E3o pode interagir com o campo."
        },
        "attribute": "enabled",
        "reflect": true,
        "defaultValue": "true"
      },
      "options": {
        "type": "unknown",
        "mutable": true,
        "complexType": {
          "original": "Array<IOption>",
          "resolved": "IOption[]",
          "references": {
            "Array": {
              "location": "global"
            },
            "IOption": {
              "location": "local"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Array com as op\u00E7\u00F5es do ez-combo-box. Os elementos devem obedecer\no formato: `{value: string, label: string}`."
        }
      },
      "errorMessage": {
        "type": "string",
        "mutable": true,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define uma mensagem de orienta\u00E7\u00E3o ao usu\u00E1rio, colocando o campo em modo inv\u00E1lido."
        },
        "attribute": "error-message",
        "reflect": true
      },
      "showSelectedValue": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Se true a op\u00E7\u00E3o selecionada exibe o `value` junto com `label`."
        },
        "attribute": "show-selected-value",
        "reflect": false,
        "defaultValue": "false"
      },
      "showOptionValue": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Se true cada op\u00E7\u00E3o na lista exibe o `value` junto com `label`."
        },
        "attribute": "show-option-value",
        "reflect": false,
        "defaultValue": "false"
      },
      "suppressSearch": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Se true desabilita a digita\u00E7\u00E3o dentro do componente."
        },
        "attribute": "suppress-search",
        "reflect": false,
        "defaultValue": "false"
      },
      "optionLoader": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "(argument: ISearchArgument) => Promise<Array<IOption>> | Array<IOption> | IOption",
          "resolved": "(argument: ISearchArgument) => IOption | IOption[] | Promise<IOption[]>",
          "references": {
            "ISearchArgument": {
              "location": "local"
            },
            "Promise": {
              "location": "global"
            },
            "Array": {
              "location": "global"
            },
            "IOption": {
              "location": "local"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Carrega as op\u00E7\u00F5es dinamicamente."
        }
      },
      "suppressEmptyOption": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Se true remove a op\u00E7\u00E3o vazia da lista."
        },
        "attribute": "suppress-empty-option",
        "reflect": false,
        "defaultValue": "false"
      },
      "stopPropagateEnterKeyEvent": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Se true, ineterrompe a propaga\u00E7\u00E3o do evento de KeyDown da tecla enter"
        },
        "attribute": "stop-propagate-enter-key-event",
        "reflect": false,
        "defaultValue": "true"
      },
      "canShowError": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Se false deixa de exibir a mensagem de erro dentro do campo."
        },
        "attribute": "can-show-error",
        "reflect": true,
        "defaultValue": "true"
      },
      "mode": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "\"slim\" | \"regular\"",
          "resolved": "\"regular\" | \"slim\"",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define o tamanho do campo."
        },
        "attribute": "mode",
        "reflect": true,
        "defaultValue": "\"regular\""
      },
      "hideErrorOnFocusOut": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Quando verdadeiro deixa de exibir a mensagem de erro (se existente) quando focar em um elemento diferente."
        },
        "attribute": "hide-error-on-focus-out",
        "reflect": false,
        "defaultValue": "true"
      },
      "listOptionsPosition": {
        "type": "unknown",
        "mutable": false,
        "complexType": {
          "original": "IEzCheckBoxListPosition",
          "resolved": "IEzCheckBoxListPosition",
          "references": {
            "IEzCheckBoxListPosition": {
              "location": "local"
            }
          }
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Define um posicionamento fixo para a lista de op\u00E7\u00F5es do CheckBox."
        }
      },
      "isTextSearch": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Informa se a pesquisa \u00E9 do tipo texto."
        },
        "attribute": "is-text-search",
        "reflect": false,
        "defaultValue": "false"
      },
      "autoFocus": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Se true o campo de texto receber\u00E1 o foco ao ser renderizado."
        },
        "attribute": "auto-focus",
        "reflect": false,
        "defaultValue": "false"
      },
      "preventAutoFocus": {
        "type": "boolean",
        "mutable": false,
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Se true, impede que o campo de texto receba foco automaticamente ao abrir as op\u00E7\u00F5es."
        },
        "attribute": "prevent-auto-focus",
        "reflect": false,
        "defaultValue": "false"
      },
      "alternativePlaceholder": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Texto alternativo a ser apresentado como t\u00EDtulo do campo."
        },
        "attribute": "alternative-placeholder",
        "reflect": true
      },
      "textEmptyOption": {
        "type": "string",
        "mutable": false,
        "complexType": {
          "original": "string",
          "resolved": "string",
          "references": {}
        },
        "required": false,
        "optional": false,
        "docs": {
          "tags": [],
          "text": "Texto a ser apresentado na op\u00E7\u00E3o de valor nulo."
        },
        "attribute": "text-empty-option",
        "reflect": false
      }
    };
  }
  static get states() {
    return {
      "isOpen": {},
      "_preSelection": {},
      "_visibleOptions": {},
      "_startLoading": {},
      "_showLoading": {},
      "_criteria": {}
    };
  }
  static get events() {
    return [{
        "method": "ezChange",
        "name": "ezChange",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": "Emitido quando acontece a altera\u00E7\u00E3o de valor do campo."
        },
        "complexType": {
          "original": "IOption",
          "resolved": "IOption",
          "references": {
            "IOption": {
              "location": "local"
            }
          }
        }
      }, {
        "method": "ezVisibilityChange",
        "name": "ezVisibilityChange",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": "Emitido quando acontece a altera\u00E7\u00E3o de visibilidade do popover."
        },
        "complexType": {
          "original": "boolean",
          "resolved": "boolean",
          "references": {}
        }
      }];
  }
  static get methods() {
    return {
      "getValueAsync": {
        "complexType": {
          "signature": "() => Promise<unknown>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<unknown>"
        },
        "docs": {
          "text": "",
          "tags": []
        }
      },
      "setFocus": {
        "complexType": {
          "signature": "(options?: TFocusOptions) => Promise<void>",
          "parameters": [{
              "tags": [],
              "text": ""
            }],
          "references": {
            "Promise": {
              "location": "global"
            },
            "TFocusOptions": {
              "location": "import",
              "path": "../ez-text-input/ez-text-input"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Aplica o foco no campo.",
          "tags": []
        }
      },
      "setBlur": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Remove o foco do campo.",
          "tags": []
        }
      },
      "isInvalid": {
        "complexType": {
          "signature": "() => Promise<boolean>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<boolean>"
        },
        "docs": {
          "text": "Retorna se o conte\u00FAdo \u00E9 inv\u00E1lido.",
          "tags": []
        }
      },
      "clearValue": {
        "complexType": {
          "signature": "() => Promise<void>",
          "parameters": [],
          "references": {
            "Promise": {
              "location": "global"
            }
          },
          "return": "Promise<void>"
        },
        "docs": {
          "text": "Limpa o valor do campo de pesquisa",
          "tags": []
        }
      }
    };
  }
  static get elementRef() { return "el"; }
  static get watchers() {
    return [{
        "propName": "errorMessage",
        "methodName": "observeErrorMessage"
      }, {
        "propName": "value",
        "methodName": "observeValue"
      }, {
        "propName": "options",
        "methodName": "observeOptions"
      }];
  }
}
var SearchMode;
(function (SearchMode) {
  SearchMode["ADVANCED"] = "ADVANCED";
  SearchMode["PRELOAD"] = "PRELOAD";
  SearchMode["PREDICTIVE"] = "PREDICTIVE";
})(SearchMode || (SearchMode = {}));
