import { Component, Element, Event, h, Listen, Prop } from "@stencil/core";
import { modifiersToClass } from '../../utils/utils';
export class IbkSearchResult {
  constructor() {
    /** Determina si el enlace se abre en una nueva ventana o en la misma */
    this.hrefTarget = '_self';
    /** Determina si el resultado se encuentra preseleccionado */
    this.over = false;
    /** Configura la clase del componente basado en estados y modificadores */
    this.containerClass = () => {
      return modifiersToClass('ibk-search-result', [{ over: this.over }]);
    };
    /** Envía al contenedor (ibk-searchbar) un objeto con los datos del resultado */
    this.chooseResult = () => {
      const result = {
        value: this.value,
        label: this.label,
        text: this.host.textContent,
        href: this.href,
        hrefTarget: this.hrefTarget
      };
      this.onclick.emit(result);
    };
  }
  mouseOver() { this.host.setAttribute('over', ''); }
  mouseLeave() { this.host.removeAttribute('over'); }
  render() {
    return (h("a", { class: this.containerClass(), href: this.href, target: this.hrefTarget, "data-value": this.value, onClick: this.chooseResult, innerHTML: this.label }));
  }
  static get is() { return "ibk-search-result"; }
  static get originalStyleUrls() { return {
    "$": ["search-result.css"]
  }; }
  static get styleUrls() { return {
    "$": ["search-result.css"]
  }; }
  static get properties() { return {
    "value": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Define un identificador para el resultado de b\u00FAsqueda"
      },
      "attribute": "value",
      "reflect": false
    },
    "label": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Define el texto que se mostrar\u00E1 en el resultado"
      },
      "attribute": "label",
      "reflect": false
    },
    "href": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Crea un enlace a la url especificada"
      },
      "attribute": "href",
      "reflect": false
    },
    "hrefTarget": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "'_self' | '_blank' | '_parent' | '_top'",
        "resolved": "\"_blank\" | \"_parent\" | \"_self\" | \"_top\"",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Determina si el enlace se abre en una nueva ventana o en la misma"
      },
      "attribute": "href-target",
      "reflect": false,
      "defaultValue": "'_self'"
    },
    "over": {
      "type": "boolean",
      "mutable": false,
      "complexType": {
        "original": "boolean",
        "resolved": "boolean",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": "Determina si el resultado se encuentra preseleccionado"
      },
      "attribute": "over",
      "reflect": false,
      "defaultValue": "false"
    }
  }; }
  static get events() { return [{
      "method": "onclick",
      "name": "onclick",
      "bubbles": true,
      "cancelable": true,
      "composed": true,
      "docs": {
        "tags": [],
        "text": "Emite un evento al seleccionar la opci\u00F3n"
      },
      "complexType": {
        "original": "SearchResult",
        "resolved": "SearchResult",
        "references": {
          "SearchResult": {
            "location": "local"
          }
        }
      }
    }]; }
  static get elementRef() { return "host"; }
  static get listeners() { return [{
      "name": "mouseover",
      "method": "mouseOver",
      "target": undefined,
      "capture": false,
      "passive": true
    }, {
      "name": "mouseleave",
      "method": "mouseLeave",
      "target": undefined,
      "capture": false,
      "passive": true
    }]; }
}
