import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
import { d as defineCustomElement$2 } from './klevu-list2.js';
import { d as defineCustomElement$1 } from './klevu-typography2.js';
import { K as KlevuLastSearches } from './lastSearches.js';

const klevuLatestSearchesCss = ":host{display:block}klevu-typography.caption{margin-bottom:var(--klevu-spacing-02)}klevu-list:hover{cursor:pointer;background:var(--klevu-color-neutral-2)}";

var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
  if (kind === "a" && !f)
    throw new TypeError("Private accessor was defined without a getter");
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
    throw new TypeError("Cannot read private member from an object whose class did not declare it");
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _KlevuLatestSearches_instances, _KlevuLatestSearches_lastSearchClick;
const KlevuLatestSearches = /*@__PURE__*/ proxyCustomElement(class KlevuLatestSearches extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
    this.klevuLastSearchClicked = createEvent(this, "klevuLastSearchClicked", 7);
    _KlevuLatestSearches_instances.add(this);
    this.caption = "Last searches";
    this.lastSearches = [];
  }
  async connectedCallback() {
    this.lastSearches = KlevuLastSearches.get().map((s) => s.term);
  }
  render() {
    if (this.lastSearches.length === 0) {
      return null;
    }
    return (h(Host, null, h("klevu-typography", { variant: "h3", class: "caption" }, this.caption), this.lastSearches.map((ls) => (h("klevu-list", { condensed: true, noXPadding: true, onClick: () => __classPrivateFieldGet(this, _KlevuLatestSearches_instances, "m", _KlevuLatestSearches_lastSearchClick).call(this, ls) }, h("span", { slot: "primary" }, ls))))));
  }
  static get style() { return klevuLatestSearchesCss; }
}, [1, "klevu-latest-searches", {
    "caption": [1],
    "lastSearches": [32]
  }]);
_KlevuLatestSearches_instances = new WeakSet(), _KlevuLatestSearches_lastSearchClick = function _KlevuLatestSearches_lastSearchClick(suggestion) {
  this.klevuLastSearchClicked.emit(suggestion);
};
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["klevu-latest-searches", "klevu-list", "klevu-typography"];
  components.forEach(tagName => { switch (tagName) {
    case "klevu-latest-searches":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, KlevuLatestSearches);
      }
      break;
    case "klevu-list":
      if (!customElements.get(tagName)) {
        defineCustomElement$2();
      }
      break;
    case "klevu-typography":
      if (!customElements.get(tagName)) {
        defineCustomElement$1();
      }
      break;
  } });
}
defineCustomElement();

export { KlevuLatestSearches as K, defineCustomElement as d };

//# sourceMappingURL=klevu-latest-searches2.js.map