import { r as registerInstance, c as createEvent, h, H as Host, F as Fragment } from './index-345463dd.js';
import { p as parts } from './parts-d5ec35e6.js';
import { K as KlevuInit } from './klevu-init-0abe4d30.js';
import { g as getTranslation } from './getTranslation-c54ce17f.js';
import { t as trendingProducts, K as KlevuUploadImageForSearch, s as stringConcat } from './stringConcat-5973198a.js';
import { g as getKMCSettings } from './getKMCSettings-cd5894f5.js';
import { b as KlevuFetch, f as KlevuLastClickedProducts } from './klevuFetch-4a3f7817.js';
import './isBrowser-38d37bdf.js';
import './search-ba83fe91.js';
import './KlevuApiRawResponse-82e24d1e.js';
import './KlevuDomEvents-a1ecbf7c.js';

const klevuQuicksearchCss = ":host{display:block;}.content{display:flex;padding:var(--klevu-spacing-04);max-width:800px}.content aside{width:180px;flex-shrink:0;padding-right:var(--klevu-spacing-04);border-right:1px solid var(--klevu-color-neutral-4);margin-right:var(--klevu-spacing-04)}klevu-suggestions-list,klevu-popular-searches,klevu-cms-list{margin-bottom:var(--klevu-spacing-05)}klevu-product-grid.desktop{width:600px}.content section{max-width:600px;min-width:300px}.resultheader{display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--klevu-spacing-05)}klevu-pagination{margin-top:var(--klevu-spacing-05)}.tabrow{border-bottom:1px solid var(--klevu-color-neutral-5)}.tabrow klevu-tab{position:relative;bottom:-1px}klevu-moi{position:fixed;top:0;left:0;height:100vh;width:100vw;background-color:#fff;box-sizing:border-box;padding:var(--klevu-spacing-03);z-index:10000}.content aside klevu-button{display:none}@media (max-width: 600px){klevu-product-grid.mobile{display:flex}.content{flex-direction:column;left:0;width:calc(100vw - 60px)}.content aside{width:100%;border:none}.content aside klevu-button{display:block;float:right}}.noResultsMessage{text-align:center;border-bottom:1px solid var(--klevu-color-neutral-5, #d6d6d6)}.noResultsBannerImage{max-width:100%;margin-top:var(--klevu-spacing-04)}klevu-icon.photo-camera{cursor:pointer}";

var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
  if (kind === "m")
    throw new TypeError("Private method is not writable");
  if (kind === "a" && !f)
    throw new TypeError("Private accessor was defined without a setter");
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
    throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
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 _KlevuQuicksearch_instances, _KlevuQuicksearch_searchField, _KlevuQuicksearch_resultObject, _KlevuQuicksearch_imagePickerPopupRef, _KlevuQuicksearch_searchTerm, _KlevuQuicksearch_noResultsOptions, _KlevuQuicksearch_emitChangedData, _KlevuQuicksearch_setNoResults, _KlevuQuicksearch_searchPageChange, _KlevuQuicksearch_handleUrlRedirects, _KlevuQuicksearch_onPopupOpen, _KlevuQuicksearch_startSearch, _KlevuQuicksearch_sizeChange, _KlevuQuicksearch_handleImageSelection, _KlevuQuicksearch_renderResultPage, _KlevuQuicksearch_renderNoResultsPage, _KlevuQuicksearch_renderBanners;
const KlevuQuicksearch = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.klevuData = createEvent(this, "klevuData", 7);
    this.klevuSearch = createEvent(this, "klevuSearch", 7);
    this.klevuImageSearch = createEvent(this, "klevuImageSearch", 7);
    this.klevuRedirect = createEvent(this, "klevuRedirect", 7);
    _KlevuQuicksearch_instances.add(this);
    _KlevuQuicksearch_searchField.set(this, void 0);
    _KlevuQuicksearch_resultObject.set(this, void 0);
    _KlevuQuicksearch_imagePickerPopupRef.set(this, void 0);
    _KlevuQuicksearch_searchTerm.set(this, "");
    _KlevuQuicksearch_noResultsOptions.set(this, void 0);
    this.fallbackTerm = undefined;
    this.popupAnchor = "bottom-end";
    this.searchCategories = undefined;
    this.searchCmsPages = undefined;
    this.placeholder = undefined;
    this.searchText = undefined;
    this.searchFieldVariant = "pill";
    this.resultVariant = "simple";
    this.simpleResultCount = 3;
    this.popularProductsCount = 10;
    this.fullResultCount = 9;
    this.enableChat = undefined;
    this.tSearchResults = getTranslation("quicksearch.tSearchResults");
    this.tStartChat = getTranslation("quicksearch.tStartChat");
    this.tCategoriesCaption = getTranslation("quicksearch.tCategoriesCaption");
    this.tTrendingCaption = undefined;
    this.tPopularProductsTitle = undefined;
    this.tLastClickedProductsCaption = undefined;
    this.showRatings = undefined;
    this.showRatingsCount = undefined;
    this.hideTrendingProducts = undefined;
    this.hideRecentlyViewedProducts = undefined;
    this.hidePopularSearches = undefined;
    this.hideRecentSearches = undefined;
    this.usePersonalisation = undefined;
    this.useKlaviyo = undefined;
    this.hidePopularKeywordsOnNoResultsPage = undefined;
    this.tPopularProductsTitleOnNoResultsPage = undefined;
    this.hideTrendingProductsOnNoResultsPage = undefined;
    this.urlRedirects = undefined;
    this.enableImageSearch = false;
    this.products = [];
    this.trendingProducts = [];
    this.suggestions = [];
    this.cmsPages = undefined;
    this.categories = undefined;
    this.queryResult = undefined;
    this.searchSort = undefined;
    this.lastClickedProducts = undefined;
    this.activeTab = "trending";
    this.chat = false;
    this.noResultsMessage = "";
    this.noResultsBannerDetails = [];
    this.searchResultTopBanners = [];
    this.searchResultBottomBanners = [];
    this.isUploadingImage = false;
    this.currentViewPortSize = undefined;
  }
  async onTextChange(event) {
    if (event.detail.length === 0) {
      this.suggestions = [];
      this.products = [];
      __classPrivateFieldSet(this, _KlevuQuicksearch_searchTerm, "", "f");
    }
  }
  async onResults(event) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
    __classPrivateFieldSet(this, _KlevuQuicksearch_searchTerm, ((_a = event.detail.search) === null || _a === void 0 ? void 0 : _a.query.meta.searchedTerm) || "", "f");
    // Reset the values before assigning new based on logic
    this.noResultsMessage = "";
    this.noResultsBannerDetails = [];
    this.products = [];
    if (((_b = event.detail.search) === null || _b === void 0 ? void 0 : _b.records.length) === 0) {
      if (((_c = event.detail.fallback) === null || _c === void 0 ? void 0 : _c.records) && ((_d = event.detail.fallback) === null || _d === void 0 ? void 0 : _d.records.length) > 0) {
        __classPrivateFieldSet(this, _KlevuQuicksearch_resultObject, event.detail.fallback, "f");
        this.products = (_e = event.detail.fallback) === null || _e === void 0 ? void 0 : _e.records;
      }
      else {
        __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_setNoResults).call(this);
      }
    }
    else {
      __classPrivateFieldSet(this, _KlevuQuicksearch_resultObject, event.detail.search, "f");
      this.products = (_f = event.detail.search) === null || _f === void 0 ? void 0 : _f.records;
    }
    this.cmsPages = (_g = event.detail.cms) === null || _g === void 0 ? void 0 : _g.records;
    this.categories = (_h = event.detail.category) === null || _h === void 0 ? void 0 : _h.records;
    (_j = this.popup) === null || _j === void 0 ? void 0 : _j.openModal();
    this.queryResult = await ((_k = __classPrivateFieldGet(this, _KlevuQuicksearch_searchField, "f")) === null || _k === void 0 ? void 0 : _k.getQueryResult("search"));
    const allBanners = (_m = (await ((_l = event.detail.search) === null || _l === void 0 ? void 0 : _l.getBanners({ searchType: "quicksearch" })))) !== null && _m !== void 0 ? _m : [];
    this.searchResultTopBanners = allBanners.filter((b) => b.position === "top");
    this.searchResultBottomBanners = allBanners.filter((b) => b.position === "bottom");
    __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_emitChangedData).call(this);
  }
  async onSuggestions(event) {
    this.suggestions = event.detail;
  }
  onProductClick(event) {
    var _a, _b, _c;
    const { product } = event.detail;
    (_a = this.popup) === null || _a === void 0 ? void 0 : _a.closeModal();
    if (product.id) {
      (_c = (_b = __classPrivateFieldGet(this, _KlevuQuicksearch_resultObject, "f")) === null || _b === void 0 ? void 0 : _b.searchClickEvent) === null || _c === void 0 ? void 0 : _c.call(_b, {
        productId: product.id,
        variantId: product.itemGroupId || product.id,
      });
    }
  }
  onChatLayoutClose() {
    this.chat = false;
  }
  onKlevuSearchclick(event) {
    setTimeout(() => __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_handleUrlRedirects).call(this, event.detail), 200);
  }
  async connectedCallback() {
    var _a, _b, _c, _d, _e, _f;
    await KlevuInit.ready();
    const settings = getKMCSettings();
    if (settings) {
      __classPrivateFieldSet(this, _KlevuQuicksearch_noResultsOptions, (_a = settings.klevu_uc_userOptions) === null || _a === void 0 ? void 0 : _a.noResultsOptions, "f");
      if (this.showRatings === undefined) {
        this.showRatings = ((_b = settings.klevu_uc_userOptions) === null || _b === void 0 ? void 0 : _b.showRatingsOnQuickSearches) || false;
      }
      if (this.showRatingsCount === undefined) {
        this.showRatingsCount = ((_c = settings.klevu_uc_userOptions) === null || _c === void 0 ? void 0 : _c.showRatingsCountOnQuickSearches) || false;
      }
      if (this.usePersonalisation === undefined && (settings === null || settings === void 0 ? void 0 : settings.klevu_uc_userOptions.enablePersonalisationInSearch)) {
        this.usePersonalisation = true;
      }
      if (this.hideRecentlyViewedProducts === undefined) {
        this.hideRecentlyViewedProducts = !(settings === null || settings === void 0 ? void 0 : settings.klevu_uc_userOptions.showRecentlyViewedItems);
      }
      if (this.tLastClickedProductsCaption === undefined) {
        this.tLastClickedProductsCaption =
          (_d = settings === null || settings === void 0 ? void 0 : settings.klevu_uc_userOptions.showRecentlyViewedItemsCaption) !== null && _d !== void 0 ? _d : getTranslation("quicksearch.tLastClickedProductsCaption");
      }
      if (this.tTrendingCaption === undefined) {
        this.tTrendingCaption =
          (_e = settings === null || settings === void 0 ? void 0 : settings.klevu_uc_userOptions.showTrendingProductsCaption) !== null && _e !== void 0 ? _e : getTranslation("quicksearch.tTrendingCaption");
      }
      if (this.hideRecentSearches === undefined) {
        this.hideRecentSearches = !(settings === null || settings === void 0 ? void 0 : settings.klevu_showRecentSerches);
      }
      if (this.hidePopularSearches === undefined) {
        this.hidePopularSearches = !(settings === null || settings === void 0 ? void 0 : settings.klevu_showPopularSearches);
      }
      if (this.hideTrendingProducts === undefined) {
        this.hideTrendingProducts = !(settings === null || settings === void 0 ? void 0 : settings.klevu_uc_userOptions.showTrendingProducts);
      }
      // No results page settings
      if (this.tPopularProductsTitleOnNoResultsPage === undefined) {
        this.tPopularProductsTitleOnNoResultsPage =
          (_f = settings === null || settings === void 0 ? void 0 : settings.klevu_uc_userOptions.noResultsOptions.productsHeading) !== null && _f !== void 0 ? _f : getTranslation("quicksearch.tPopularProductsTitle");
      }
      if (this.hideTrendingProductsOnNoResultsPage === undefined) {
        this.hideTrendingProductsOnNoResultsPage = !(settings === null || settings === void 0 ? void 0 : settings.klevu_uc_userOptions.noResultsOptions.showPopularProducts);
      }
      if (this.hidePopularKeywordsOnNoResultsPage === undefined) {
        this.hidePopularKeywordsOnNoResultsPage = !(settings === null || settings === void 0 ? void 0 : settings.klevu_uc_userOptions.noResultsOptions.showPopularKeywords);
      }
    }
    if (this.hideTrendingProducts) {
      if (this.hideRecentSearches) {
        this.activeTab = "";
      }
      else {
        this.activeTab = "last";
      }
    }
    if (!this.hideTrendingProducts || !this.hideTrendingProductsOnNoResultsPage) {
      const trendingProductsQuery = await KlevuFetch(trendingProducts({
        limit: this.popularProductsCount,
      }));
      const resultObject = trendingProductsQuery.queriesById("trendingProducts");
      if (resultObject) {
        this.trendingProducts = resultObject.records;
        __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_emitChangedData).call(this);
      }
    }
  }
  render() {
    var _a;
    return (h(Host, null, h("klevu-util-viewport", { onKlevuSizeChanged: __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_sizeChange).bind(this), ref: (el) => (this.viewportUtil = el) }), h("klevu-popup", { anchor: this.popupAnchor, ref: (el) => (this.popup = el), onKlevuPopupOpen: __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_onPopupOpen).bind(this), elevation: 2 }, h("klevu-search-field", { ref: (el) => (__classPrivateFieldSet(this, _KlevuQuicksearch_searchField, el, "f")), limit: this.resultVariant === "simple" ? this.simpleResultCount : this.fullResultCount, sort: this.searchSort, slot: "origin", searchProducts: true, searchSuggestions: true, tSearchText: this.searchText, tPlaceholder: this.placeholder, "fallback-term": this.fallbackTerm, searchCmsPages: this.searchCmsPages, searchCategories: this.searchCategories, variant: this.searchFieldVariant, usePersonalisation: this.usePersonalisation, useKlaviyo: this.useKlaviyo }, this.enableImageSearch && (h("div", { slot: "end-of-input" }, h("klevu-popup", { popupWidth: 400, anchor: "bottom-end", ref: (el) => (__classPrivateFieldSet(this, _KlevuQuicksearch_imagePickerPopupRef, el, "f")) }, h("div", { class: "image-picker", slot: "content" }, h("klevu-image-picker", { isLoading: this.isUploadingImage, onKlevuImageSelected: __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_handleImageSelection).bind(this) })), h("klevu-icon", { slot: "origin", name: "photo_camera", class: "photo-camera" }))))), h("div", { class: "content", slot: "content" }, ((_a = this.products) !== null && _a !== void 0 ? _a : []).length > 0 ? __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_renderResultPage).call(this) : __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_renderNoResultsPage).call(this))), this.chat && h("klevu-moi", null)));
  }
};
_KlevuQuicksearch_searchField = new WeakMap(), _KlevuQuicksearch_resultObject = new WeakMap(), _KlevuQuicksearch_imagePickerPopupRef = new WeakMap(), _KlevuQuicksearch_searchTerm = new WeakMap(), _KlevuQuicksearch_noResultsOptions = new WeakMap(), _KlevuQuicksearch_instances = new WeakSet(), _KlevuQuicksearch_emitChangedData = function _KlevuQuicksearch_emitChangedData() {
  this.klevuData.emit({
    lastClickedProducts: this.lastClickedProducts,
    trendingProducts: this.trendingProducts,
    searchResult: this.queryResult,
  });
}, _KlevuQuicksearch_setNoResults = function _KlevuQuicksearch_setNoResults() {
  var _a, _b, _c, _d, _e;
  this.noResultsMessage = ((_b = (_a = __classPrivateFieldGet(this, _KlevuQuicksearch_noResultsOptions, "f")) === null || _a === void 0 ? void 0 : _a.messages.find((m) => m.showForTerms === null)) === null || _b === void 0 ? void 0 : _b.message) || "";
  this.noResultsBannerDetails =
    ((_c = __classPrivateFieldGet(this, _KlevuQuicksearch_noResultsOptions, "f")) === null || _c === void 0 ? void 0 : _c.banners.filter((m) => m.showOnQuickSearch && m.showForTerms === null)) || [];
  if (__classPrivateFieldGet(this, _KlevuQuicksearch_searchTerm, "f")) {
    const searchTermSpecificMessage = (_d = __classPrivateFieldGet(this, _KlevuQuicksearch_noResultsOptions, "f")) === null || _d === void 0 ? void 0 : _d.messages.find((m) => m.showForTerms && m.showForTerms.includes(__classPrivateFieldGet(this, _KlevuQuicksearch_searchTerm, "f")));
    if (searchTermSpecificMessage)
      this.noResultsMessage = (searchTermSpecificMessage === null || searchTermSpecificMessage === void 0 ? void 0 : searchTermSpecificMessage.message) || "";
    const searchTermSpecificBanner = ((_e = __classPrivateFieldGet(this, _KlevuQuicksearch_noResultsOptions, "f")) === null || _e === void 0 ? void 0 : _e.banners.filter((m) => m.showOnQuickSearch && m.showForTerms && m.showForTerms.includes(__classPrivateFieldGet(this, _KlevuQuicksearch_searchTerm, "f")))) || [];
    if (searchTermSpecificBanner.length > 0)
      this.noResultsBannerDetails.unshift(...searchTermSpecificBanner);
  }
}, _KlevuQuicksearch_searchPageChange = async function _KlevuQuicksearch_searchPageChange(event) {
  var _a;
  if (!__classPrivateFieldGet(this, _KlevuQuicksearch_searchField, "f")) {
    return;
  }
  __classPrivateFieldGet(this, _KlevuQuicksearch_searchField, "f").getPage("search", event.detail - 1);
  this.queryResult = await ((_a = __classPrivateFieldGet(this, _KlevuQuicksearch_searchField, "f")) === null || _a === void 0 ? void 0 : _a.getQueryResult("search"));
  __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_emitChangedData).call(this);
}, _KlevuQuicksearch_handleUrlRedirects = async function _KlevuQuicksearch_handleUrlRedirects(term) {
  var _a, _b;
  let redirect;
  if (this.urlRedirects === undefined && ((_a = __classPrivateFieldGet(this, _KlevuQuicksearch_resultObject, "f")) === null || _a === void 0 ? void 0 : _a.getRedirects)) {
    const redirects = await __classPrivateFieldGet(this, _KlevuQuicksearch_resultObject, "f").getRedirects();
    if (redirects && redirects.length > 0) {
      redirect = redirects[0];
    }
  }
  else {
    redirect = (_b = this.urlRedirects) === null || _b === void 0 ? void 0 : _b.find((redirects) => redirects.keywords.includes(term));
  }
  if (redirect) {
    const emittedEvent = this.klevuRedirect.emit(redirect);
    if (!emittedEvent.defaultPrevented) {
      window.location.href = redirect.url;
    }
  }
  else {
    this.klevuSearch.emit(term);
  }
}, _KlevuQuicksearch_onPopupOpen = function _KlevuQuicksearch_onPopupOpen() {
  var _a, _b, _c, _d, _e;
  this.lastClickedProducts = KlevuLastClickedProducts.getProducts(3);
  __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_emitChangedData).call(this);
  (_e = (_d = (_c = (_b = (_a = __classPrivateFieldGet(this, _KlevuQuicksearch_searchField, "f")) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector("klevu-textfield")) === null || _c === void 0 ? void 0 : _c.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector("input")) === null || _e === void 0 ? void 0 : _e.focus();
}, _KlevuQuicksearch_startSearch = function _KlevuQuicksearch_startSearch(term) {
  var _a;
  this.products = [undefined, undefined, undefined];
  (_a = __classPrivateFieldGet(this, _KlevuQuicksearch_searchField, "f")) === null || _a === void 0 ? void 0 : _a.makeSearch(term);
}, _KlevuQuicksearch_sizeChange = function _KlevuQuicksearch_sizeChange(event) {
  this.currentViewPortSize = event.detail;
}, _KlevuQuicksearch_handleImageSelection = async function _KlevuQuicksearch_handleImageSelection(event) {
  var _a;
  this.isUploadingImage = true;
  const imageUrl = await KlevuUploadImageForSearch(event.detail.image);
  this.klevuImageSearch.emit(imageUrl);
  this.isUploadingImage = false;
  (_a = __classPrivateFieldGet(this, _KlevuQuicksearch_imagePickerPopupRef, "f")) === null || _a === void 0 ? void 0 : _a.closeModal();
}, _KlevuQuicksearch_renderResultPage = function _KlevuQuicksearch_renderResultPage() {
  var _a, _b, _c, _d;
  const isMobile = ((_a = this.currentViewPortSize) === null || _a === void 0 ? void 0 : _a.name) === "xs" || ((_b = this.currentViewPortSize) === null || _b === void 0 ? void 0 : _b.name) === "sm";
  return (h(Fragment, null, h("aside", null, h("klevu-suggestions-list", { suggestions: this.suggestions, onKlevuSuggestionClicked: (event) => __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_startSearch).call(this, event.detail) }), this.cmsPages && this.cmsPages.length > 0 && h("klevu-cms-list", { pages: this.cmsPages, link: true }), this.categories && this.categories.length > 0 && (h("klevu-cms-list", { pages: this.categories, tCaption: this.tCategoriesCaption, link: true }))), h("section", null, this.resultVariant === "full" && (h(Fragment, null, h("div", { class: "resultheader" }, h("klevu-typography", { variant: "h3" }, "Search results"), h("klevu-sort", { variant: "inline", onKlevuSortChanged: (event) => (this.searchSort = event.detail) })), h("slot", { name: "topbanners" }, this.searchResultTopBanners.map((b) => (h("klevu-banner", { imageUrl: b.bannerImg, linkUrl: b.redirectUrl, altText: b.bannerAltTag })))), h("klevu-product-grid", { itemsPerRow: isMobile ? undefined : 3 }, h("slot", { name: "search-products" }, (_c = this.products) === null || _c === void 0 ? void 0 : _c.map((p) => (h("klevu-product", { product: p, fixedWidth: true, variant: isMobile ? "line" : "small", exportparts: parts["klevu-product"], showRatings: this.showRatings, showRatingsCount: this.showRatingsCount }))))), h("klevu-pagination", { queryResult: this.queryResult, onKlevuPaginationChange: __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_searchPageChange).bind(this) }), h("slot", { name: "bottombanners" }, this.searchResultBottomBanners.map((b) => (h("klevu-banner", { imageUrl: b.bannerImg, linkUrl: b.redirectUrl, altText: b.bannerAltTag })))))), this.resultVariant === "simple" && (h(Fragment, null, h("div", { class: "resultheader" }, h("klevu-typography", { variant: "h3" }, this.tSearchResults)), h("slot", { name: "topbanners" }, this.searchResultTopBanners.map((b) => (h("klevu-banner", { imageUrl: b.bannerImg, linkUrl: b.redirectUrl, altText: b.bannerAltTag })))), h("div", { class: "lineproducts" }, h("slot", { name: "search-products" }, (_d = this.products) === null || _d === void 0 ? void 0 : _d.map((p) => (h("klevu-product", { product: p, variant: "line", exportparts: parts["klevu-product"], showRatings: this.showRatings, showRatingsCount: this.showRatingsCount }))))), h("slot", { name: "bottombanners" }, this.searchResultBottomBanners.map((b) => (h("klevu-banner", { imageUrl: b.bannerImg, linkUrl: b.redirectUrl, altText: b.bannerAltTag })))))))));
}, _KlevuQuicksearch_renderNoResultsPage = function _KlevuQuicksearch_renderNoResultsPage() {
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
  const isNoResultsPage = !!__classPrivateFieldGet(this, _KlevuQuicksearch_searchTerm, "f");
  return (h(Fragment, null, h("aside", null, this.enableChat && (h("klevu-button", { size: "small", onClick: () => (this.chat = true) }, this.tStartChat)), ((!this.hidePopularSearches && !isNoResultsPage) ||
    (!this.hidePopularKeywordsOnNoResultsPage && isNoResultsPage)) && (h("klevu-popular-searches", { onKlevuPopularSearchClicked: (event) => __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_startSearch).call(this, event.detail) })), !this.hideRecentSearches && !isNoResultsPage && (h("klevu-latest-searches", { onKlevuLastSearchClicked: (event) => __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_startSearch).call(this, event.detail) }))), h("section", null, h("slot", { name: "noResults" }, isNoResultsPage && this.noResultsMessage ? (h("p", { class: "noResultsMessage" }, h("klevu-typography", { variant: "body-s" }, this.noResultsMessage))) : null, h("div", { class: "tabrow" }, ((!this.hideTrendingProducts && !isNoResultsPage) ||
    (!this.hideTrendingProductsOnNoResultsPage && isNoResultsPage)) && (h("klevu-tab", { caption: stringConcat((_a = this.tTrendingCaption) !== null && _a !== void 0 ? _a : getTranslation("quicksearch.tTrendingCaption"), [
      `${(_c = (_b = this.trendingProducts) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0}`,
    ]), active: this.activeTab === "trending", onClick: () => (this.activeTab = "trending") })), !this.hideRecentlyViewedProducts && !isNoResultsPage && (h("klevu-tab", { caption: stringConcat((_d = this.tLastClickedProductsCaption) !== null && _d !== void 0 ? _d : getTranslation("quicksearch.tLastClickedProductsCaption"), [`${(_f = (_e = this.lastClickedProducts) === null || _e === void 0 ? void 0 : _e.length) !== null && _f !== void 0 ? _f : 0}`]), active: this.activeTab === "last", onClick: () => {
      var _a;
      if (((_a = this.lastClickedProducts) === null || _a === void 0 ? void 0 : _a.length) === 0) {
        return;
      }
      this.activeTab = "last";
    }, disabled: ((_g = this.lastClickedProducts) === null || _g === void 0 ? void 0 : _g.length) === 0 }))), !this.hideTrendingProducts && this.activeTab === "trending" && (h(Fragment, null, isNoResultsPage && (h("klevu-typography", { variant: "body-s" }, this.tPopularProductsTitleOnNoResultsPage)), h("slot", { name: "trending-products" }, (_h = this.trendingProducts) === null || _h === void 0 ? void 0 : _h.map((p) => (h("klevu-product", { product: p, variant: "line", exportparts: parts["klevu-product"] })))))), !this.hideRecentlyViewedProducts && this.activeTab === "last" && (h(Fragment, null, h("slot", { name: "last-clicked-products" }, (_j = this.lastClickedProducts) === null || _j === void 0 ? void 0 : _j.map((p) => (h("klevu-product", { product: p, variant: "line", exportparts: parts["klevu-product"] })))))), __classPrivateFieldGet(this, _KlevuQuicksearch_instances, "m", _KlevuQuicksearch_renderBanners).call(this)))));
}, _KlevuQuicksearch_renderBanners = function _KlevuQuicksearch_renderBanners() {
  return this.noResultsBannerDetails.map((banner) => (h("a", { href: banner.redirectUrl }, h("img", { class: "noResultsBannerImage", src: banner.bannerImageUrl, alt: banner.bannerAltTag, title: banner.bannerAltTag }))));
};
KlevuQuicksearch.style = klevuQuicksearchCss;

export { KlevuQuicksearch as klevu_quicksearch };

//# sourceMappingURL=klevu-quicksearch.entry.js.map