@getlupa/client 1.17.1 → 1.17.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7863,6 +7863,14 @@ const formatPriceSummary = ([min, max], currency, separator = ",", currencyTempl
7863
7863
  }
7864
7864
  return `< ${formatPrice(max, currency, separator, currencyTemplate)}`;
7865
7865
  };
7866
+ const getTranslatedFacetKey = (facet, translations) => {
7867
+ var _a, _b;
7868
+ return (_b = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[facet.key]) != null ? _b : facet.label;
7869
+ };
7870
+ const getTranslatedFacetValue = (facet, value, translations) => {
7871
+ var _a, _b, _c;
7872
+ return (_c = (_b = (_a = translations == null ? void 0 : translations.valueTranslations) == null ? void 0 : _a[facet.key]) == null ? void 0 : _b[value == null ? void 0 : value.title]) != null ? _c : value.title;
7873
+ };
7866
7874
  const formatRange = (filter2) => {
7867
7875
  var _a, _b;
7868
7876
  const lt = (_a = filter2.lt) != null ? _a : filter2.lte;
@@ -7922,11 +7930,12 @@ const unfoldFilters = (filters, price = {}) => {
7922
7930
  const seed = [];
7923
7931
  return Object.entries(filters).reduce((a, c2) => [...a, ...unfoldFilter(...c2, price)], seed);
7924
7932
  };
7925
- const getLabeledFilters = (filters, facets2) => {
7933
+ const getLabeledFilters = (filters, facets2, translations) => {
7926
7934
  return filters.map((f2) => {
7927
- var _a, _b;
7935
+ var _a, _b, _c, _d;
7928
7936
  return __spreadProps2(__spreadValues2({}, f2), {
7929
- label: (_b = (_a = facets2 == null ? void 0 : facets2.find((ft) => ft.key === f2.key)) == null ? void 0 : _a.label) != null ? _b : capitalize$1(f2.key)
7937
+ label: (_d = (_c = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[f2.key]) != null ? _c : (_b = facets2 == null ? void 0 : facets2.find((ft) => ft.key === f2.key)) == null ? void 0 : _b.label) != null ? _d : capitalize$1(f2.key),
7938
+ value: getTranslatedFacetValue({ key: f2.key }, { title: f2.value }, translations)
7930
7939
  });
7931
7940
  });
7932
7941
  };
@@ -14279,7 +14288,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
14279
14288
  };
14280
14289
  });
14281
14290
  const _hoisted_1$1i = { id: "lupa-search-box-input-container" };
14282
- const _hoisted_2$U = { class: "lupa-input-clear" };
14291
+ const _hoisted_2$T = { class: "lupa-input-clear" };
14283
14292
  const _hoisted_3$C = { id: "lupa-search-box-input" };
14284
14293
  const _hoisted_4$s = ["value"];
14285
14294
  const _hoisted_5$j = ["aria-label", "placeholder"];
@@ -14376,7 +14385,7 @@ const _sfc_main$1v = /* @__PURE__ */ defineComponent({
14376
14385
  __expose({ focus });
14377
14386
  return (_ctx, _cache) => {
14378
14387
  return openBlock(), createElementBlock("div", _hoisted_1$1i, [
14379
- createBaseVNode("div", _hoisted_2$U, [
14388
+ createBaseVNode("div", _hoisted_2$T, [
14380
14389
  createBaseVNode("div", {
14381
14390
  class: normalizeClass(["lupa-input-clear-content", { "lupa-input-clear-filled": inputValue.value }]),
14382
14391
  onClick: clear2
@@ -14459,7 +14468,7 @@ const _sfc_main$1u = /* @__PURE__ */ defineComponent({
14459
14468
  }
14460
14469
  });
14461
14470
  const _hoisted_1$1h = { class: "lupa-search-box-history-item" };
14462
- const _hoisted_2$T = { class: "lupa-search-box-history-item-content" };
14471
+ const _hoisted_2$S = { class: "lupa-search-box-history-item-content" };
14463
14472
  const _sfc_main$1t = /* @__PURE__ */ defineComponent({
14464
14473
  __name: "SearchBoxHistoryItem",
14465
14474
  props: {
@@ -14477,7 +14486,7 @@ const _sfc_main$1t = /* @__PURE__ */ defineComponent({
14477
14486
  };
14478
14487
  return (_ctx, _cache) => {
14479
14488
  return openBlock(), createElementBlock("div", _hoisted_1$1h, [
14480
- createBaseVNode("div", _hoisted_2$T, [
14489
+ createBaseVNode("div", _hoisted_2$S, [
14481
14490
  createBaseVNode("div", {
14482
14491
  class: normalizeClass(["lupa-search-box-history-item-text", { "lupa-search-box-history-item-highlighted": _ctx.highlighted }]),
14483
14492
  onClick: click2
@@ -14604,7 +14613,7 @@ const generateGridTemplate = (elements) => {
14604
14613
  return gridTemplate.join(" ");
14605
14614
  };
14606
14615
  const _hoisted_1$1e = ["innerHTML"];
14607
- const _hoisted_2$S = {
14616
+ const _hoisted_2$R = {
14608
14617
  key: 1,
14609
14618
  "data-cy": "lupa-suggestion-value",
14610
14619
  class: "lupa-suggestion-value"
@@ -14658,7 +14667,7 @@ const _sfc_main$1q = /* @__PURE__ */ defineComponent({
14658
14667
  class: "lupa-suggestion-value",
14659
14668
  "data-cy": "lupa-suggestion-value",
14660
14669
  innerHTML: _ctx.suggestion.displayHighlight
14661
- }, null, 8, _hoisted_1$1e)) : (openBlock(), createElementBlock("div", _hoisted_2$S, toDisplayString(_ctx.suggestion.display), 1)),
14670
+ }, null, 8, _hoisted_1$1e)) : (openBlock(), createElementBlock("div", _hoisted_2$R, toDisplayString(_ctx.suggestion.display), 1)),
14662
14671
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$B, [
14663
14672
  createBaseVNode("span", _hoisted_4$r, toDisplayString(facetLabel.value), 1),
14664
14673
  createBaseVNode("span", _hoisted_5$i, toDisplayString(_ctx.suggestion.facet.title), 1)
@@ -23797,6 +23806,11 @@ const processDisplayCondition = (displayCondition, doc2 = {}) => {
23797
23806
  case "exists": {
23798
23807
  return fields == null ? void 0 : fields.every((field) => getFieldValue(doc2, field) !== void 0);
23799
23808
  }
23809
+ case "notExists": {
23810
+ return fields == null ? void 0 : fields.every(
23811
+ (field) => getFieldValue(doc2, field) === void 0 || getFieldValue(doc2, field) === null
23812
+ );
23813
+ }
23800
23814
  case "equals": {
23801
23815
  if (fields.length < 2)
23802
23816
  return false;
@@ -23853,7 +23867,7 @@ const replaceImageWithPlaceholder = (e2, placeholder) => {
23853
23867
  }
23854
23868
  };
23855
23869
  const _hoisted_1$1c = ["src"];
23856
- const _hoisted_2$R = ["src"];
23870
+ const _hoisted_2$Q = ["src"];
23857
23871
  const _sfc_main$1n = /* @__PURE__ */ defineComponent({
23858
23872
  __name: "ProductImage",
23859
23873
  props: {
@@ -24004,7 +24018,7 @@ const _sfc_main$1n = /* @__PURE__ */ defineComponent({
24004
24018
  class: ["lupa-images-main-image", { [_ctx.imageClass]: true }],
24005
24019
  style: styleOverride.value,
24006
24020
  src: finalMainImageUrl.value
24007
- }, { alt: imageAlt.value ? imageAlt.value : void 0 }, { onError: replaceWithPlaceholder }), null, 16, _hoisted_2$R))
24021
+ }, { alt: imageAlt.value ? imageAlt.value : void 0 }, { onError: replaceWithPlaceholder }), null, 16, _hoisted_2$Q))
24008
24022
  ], 38);
24009
24023
  };
24010
24024
  }
@@ -24027,7 +24041,7 @@ const _sfc_main$1m = /* @__PURE__ */ defineComponent({
24027
24041
  }
24028
24042
  });
24029
24043
  const _hoisted_1$1b = ["innerHTML"];
24030
- const _hoisted_2$Q = {
24044
+ const _hoisted_2$P = {
24031
24045
  key: 1,
24032
24046
  class: "lupa-search-box-product-title"
24033
24047
  };
@@ -24054,14 +24068,14 @@ const _sfc_main$1l = /* @__PURE__ */ defineComponent({
24054
24068
  key: 0,
24055
24069
  class: "lupa-search-box-product-title",
24056
24070
  innerHTML: sanitizedTitle.value
24057
- }, null, 8, _hoisted_1$1b)) : (openBlock(), createElementBlock("div", _hoisted_2$Q, [
24071
+ }, null, 8, _hoisted_1$1b)) : (openBlock(), createElementBlock("div", _hoisted_2$P, [
24058
24072
  createBaseVNode("strong", null, toDisplayString(title.value), 1)
24059
24073
  ]));
24060
24074
  };
24061
24075
  }
24062
24076
  });
24063
24077
  const _hoisted_1$1a = ["innerHTML"];
24064
- const _hoisted_2$P = {
24078
+ const _hoisted_2$O = {
24065
24079
  key: 1,
24066
24080
  class: "lupa-search-box-product-description"
24067
24081
  };
@@ -24088,7 +24102,7 @@ const _sfc_main$1k = /* @__PURE__ */ defineComponent({
24088
24102
  key: 0,
24089
24103
  class: "lupa-search-box-product-description",
24090
24104
  innerHTML: sanitizedDescription.value
24091
- }, null, 8, _hoisted_1$1a)) : (openBlock(), createElementBlock("div", _hoisted_2$P, toDisplayString(description.value), 1));
24105
+ }, null, 8, _hoisted_1$1a)) : (openBlock(), createElementBlock("div", _hoisted_2$O, toDisplayString(description.value), 1));
24092
24106
  };
24093
24107
  }
24094
24108
  });
@@ -24147,7 +24161,7 @@ const _sfc_main$1i = /* @__PURE__ */ defineComponent({
24147
24161
  }
24148
24162
  });
24149
24163
  const _hoisted_1$18 = ["innerHTML"];
24150
- const _hoisted_2$O = { key: 0 };
24164
+ const _hoisted_2$N = { key: 0 };
24151
24165
  const _hoisted_3$A = { key: 1 };
24152
24166
  const _hoisted_4$q = { class: "lupa-search-box-custom-label" };
24153
24167
  const _hoisted_5$h = { class: "lupa-search-box-custom-text" };
@@ -24181,7 +24195,7 @@ const _sfc_main$1h = /* @__PURE__ */ defineComponent({
24181
24195
  key: 1,
24182
24196
  class: [className.value, "lupa-search-box-product-custom"]
24183
24197
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
24184
- !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$O, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$A, [
24198
+ !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$N, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$A, [
24185
24199
  createBaseVNode("div", _hoisted_4$q, toDisplayString(label.value), 1),
24186
24200
  createBaseVNode("div", _hoisted_5$h, toDisplayString(text.value), 1)
24187
24201
  ]))
@@ -24304,6 +24318,10 @@ const useSearchResultStore = defineStore("searchResult", () => {
24304
24318
  var _a, _b, _c;
24305
24319
  return (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.labels) == null ? void 0 : _b.currencyTemplate) != null ? _c : "";
24306
24320
  });
24321
+ const filterTranslations = computed(() => {
24322
+ var _a, _b, _c;
24323
+ return (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.filters) == null ? void 0 : _b.translations) != null ? _c : {};
24324
+ });
24307
24325
  const labeledFilters = computed(
24308
24326
  () => getLabeledFilters(
24309
24327
  unfoldFilters(filters.value, {
@@ -24312,7 +24330,8 @@ const useSearchResultStore = defineStore("searchResult", () => {
24312
24330
  separator: priceSeparator.value,
24313
24331
  currencyTemplate: currencyTemplate.value
24314
24332
  }),
24315
- facets2.value
24333
+ facets2.value,
24334
+ filterTranslations.value
24316
24335
  )
24317
24336
  );
24318
24337
  const displayFilters = computed(() => {
@@ -24495,7 +24514,7 @@ const useSearchResultStore = defineStore("searchResult", () => {
24495
24514
  };
24496
24515
  });
24497
24516
  const _hoisted_1$16 = { class: "lupa-search-box-add-to-cart-wrapper" };
24498
- const _hoisted_2$N = { class: "lupa-search-box-product-addtocart" };
24517
+ const _hoisted_2$M = { class: "lupa-search-box-product-addtocart" };
24499
24518
  const _hoisted_3$z = ["onClick", "disabled"];
24500
24519
  const _sfc_main$1f = /* @__PURE__ */ defineComponent({
24501
24520
  __name: "SearchBoxProductAddToCart",
@@ -24532,7 +24551,7 @@ const _sfc_main$1f = /* @__PURE__ */ defineComponent({
24532
24551
  });
24533
24552
  return (_ctx, _cache) => {
24534
24553
  return openBlock(), createElementBlock("div", _hoisted_1$16, [
24535
- createBaseVNode("div", _hoisted_2$N, [
24554
+ createBaseVNode("div", _hoisted_2$M, [
24536
24555
  createBaseVNode("button", mergeProps({
24537
24556
  onClick: withModifiers(handleClick, ["stop", "prevent"]),
24538
24557
  class: loading.value ? "lupa-add-to-cart-loading" : "lupa-add-to-cart",
@@ -24646,7 +24665,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
24646
24665
  }
24647
24666
  }));
24648
24667
  const _hoisted_1$14 = { class: "lupa-badge-title" };
24649
- const _hoisted_2$M = ["src"];
24668
+ const _hoisted_2$L = ["src"];
24650
24669
  const _hoisted_3$y = { key: 1 };
24651
24670
  const _hoisted_4$p = {
24652
24671
  key: 0,
@@ -24689,7 +24708,7 @@ const _sfc_main$1d = /* @__PURE__ */ defineComponent({
24689
24708
  image.value ? (openBlock(), createElementBlock("img", {
24690
24709
  key: 0,
24691
24710
  src: image.value
24692
- }, null, 8, _hoisted_2$M)) : createCommentVNode("", true),
24711
+ }, null, 8, _hoisted_2$L)) : createCommentVNode("", true),
24693
24712
  hasTitleText.value && showTitle.value ? (openBlock(), createElementBlock("span", _hoisted_3$y, toDisplayString(_ctx.badge.titleText), 1)) : createCommentVNode("", true)
24694
24713
  ]),
24695
24714
  hasAdditionalText.value ? (openBlock(), createElementBlock("span", _hoisted_4$p, toDisplayString(_ctx.badge.additionalText), 1)) : createCommentVNode("", true)
@@ -24789,7 +24808,7 @@ const _sfc_main$1a = /* @__PURE__ */ defineComponent({
24789
24808
  }
24790
24809
  });
24791
24810
  const _hoisted_1$10 = { class: "lupa-image-badges" };
24792
- const _hoisted_2$L = ["src"];
24811
+ const _hoisted_2$K = ["src"];
24793
24812
  const _sfc_main$19 = /* @__PURE__ */ defineComponent({
24794
24813
  __name: "ImageBadge",
24795
24814
  props: {
@@ -24818,7 +24837,7 @@ const _sfc_main$19 = /* @__PURE__ */ defineComponent({
24818
24837
  }, [
24819
24838
  createBaseVNode("img", {
24820
24839
  src: getImageUrl(item)
24821
- }, null, 8, _hoisted_2$L)
24840
+ }, null, 8, _hoisted_2$K)
24822
24841
  ]);
24823
24842
  }), 128))
24824
24843
  ]);
@@ -24977,7 +24996,7 @@ const _sfc_main$17 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
24977
24996
  }
24978
24997
  }));
24979
24998
  const _hoisted_1$_ = ["href"];
24980
- const _hoisted_2$K = { class: "lupa-search-box-product-details-section" };
24999
+ const _hoisted_2$J = { class: "lupa-search-box-product-details-section" };
24981
25000
  const _hoisted_3$x = {
24982
25001
  key: 0,
24983
25002
  class: "lupa-search-box-product-add-to-cart-section"
@@ -25078,7 +25097,7 @@ const _sfc_main$16 = /* @__PURE__ */ defineComponent({
25078
25097
  }, null, 8, ["item", "element", "labels", "link"]);
25079
25098
  }), 128))
25080
25099
  ], 4),
25081
- createBaseVNode("div", _hoisted_2$K, [
25100
+ createBaseVNode("div", _hoisted_2$J, [
25082
25101
  (openBlock(true), createElementBlock(Fragment, null, renderList(detailElements.value, (element) => {
25083
25102
  var _a;
25084
25103
  return openBlock(), createBlock(_sfc_main$1e, {
@@ -25251,6 +25270,9 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
25251
25270
  }
25252
25271
  emit2("product-click");
25253
25272
  handleRoutingEvent(link, event, boxRoutingBehavior.value === "event");
25273
+ if (props.panelOptions.programmaticNavigation) {
25274
+ window.location.assign(link);
25275
+ }
25254
25276
  };
25255
25277
  return (_ctx, _cache) => {
25256
25278
  return openBlock(), createElementBlock("div", _hoisted_1$Z, [
@@ -25281,7 +25303,7 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
25281
25303
  }
25282
25304
  });
25283
25305
  const _hoisted_1$Y = { class: "lupa-search-box-documents-go-to-results-wrapper" };
25284
- const _hoisted_2$J = { key: 0 };
25306
+ const _hoisted_2$I = { key: 0 };
25285
25307
  const _sfc_main$14 = /* @__PURE__ */ defineComponent({
25286
25308
  __name: "SearchBoxProductsGoToResultsButton",
25287
25309
  props: {
@@ -25318,7 +25340,7 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent({
25318
25340
  onClick: goToResults
25319
25341
  }, [
25320
25342
  createTextVNode(toDisplayString(goToResultsLabel.value) + " ", 1),
25321
- totalCount.value ? (openBlock(), createElementBlock("span", _hoisted_2$J, " " + toDisplayString(totalCount.value), 1)) : createCommentVNode("", true)
25343
+ totalCount.value ? (openBlock(), createElementBlock("span", _hoisted_2$I, " " + toDisplayString(totalCount.value), 1)) : createCommentVNode("", true)
25322
25344
  ])
25323
25345
  ]);
25324
25346
  };
@@ -25586,7 +25608,7 @@ const _hoisted_1$X = {
25586
25608
  key: 0,
25587
25609
  id: "lupa-search-box-panel"
25588
25610
  };
25589
- const _hoisted_2$I = ["data-cy"];
25611
+ const _hoisted_2$H = ["data-cy"];
25590
25612
  const _hoisted_3$w = {
25591
25613
  key: 0,
25592
25614
  class: "lupa-panel-title lupa-panel-title-top-results"
@@ -25806,7 +25828,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
25806
25828
  key: "0"
25807
25829
  } : void 0
25808
25830
  ]), 1064, ["panel", "search-box-options", "options", "debounce", "inputValue", "labels"])) : createCommentVNode("", true)
25809
- ], 14, _hoisted_2$I);
25831
+ ], 14, _hoisted_2$H);
25810
25832
  }), 128))
25811
25833
  ], 4),
25812
25834
  !unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1r, {
@@ -25845,8 +25867,7 @@ const unbindSearchTriggers = (triggers = [], event) => {
25845
25867
  const elements = getElements(triggers);
25846
25868
  elements.forEach((e2) => e2 == null ? void 0 : e2.removeEventListener(BIND_EVENT, event));
25847
25869
  };
25848
- const _hoisted_1$W = { id: "lupa-search-box" };
25849
- const _hoisted_2$H = { class: "lupa-search-box-wrapper" };
25870
+ const _hoisted_1$W = { class: "lupa-search-box-wrapper" };
25850
25871
  const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25851
25872
  __name: "SearchBox",
25852
25873
  props: {
@@ -25871,6 +25892,7 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25871
25892
  const suggestedValue = ref(defaultSuggestedValue);
25872
25893
  const opened = ref(props.isSearchContainer);
25873
25894
  const focused = ref(false);
25895
+ const openedAt = ref(null);
25874
25896
  const searchBoxInput = ref(null);
25875
25897
  const { highlightedDocument } = storeToRefs(searchBoxStore);
25876
25898
  const searchValue = computed(() => {
@@ -25907,7 +25929,7 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25907
25929
  });
25908
25930
  const goToResultsDebounced = debounce$1(paramsStore.goToResults, (_a = props.options.debounce) != null ? _a : 300);
25909
25931
  onMounted(() => {
25910
- var _a2;
25932
+ var _a2, _b, _c;
25911
25933
  window.addEventListener("keydown", handleKeyDown);
25912
25934
  window.addEventListener("click", handleMouseClick);
25913
25935
  paramsStore.setSearchResultsLink(props.options.links.searchResults);
@@ -25918,6 +25940,9 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25918
25940
  if (props.isSearchContainer && searchBoxInput.value) {
25919
25941
  (_a2 = searchBoxInput.value) == null ? void 0 : _a2.focus();
25920
25942
  }
25943
+ if ((_b = props.options.callbacks) == null ? void 0 : _b.onMounted) {
25944
+ (_c = props.options.callbacks) == null ? void 0 : _c.onMounted();
25945
+ }
25921
25946
  });
25922
25947
  onBeforeUnmount(() => {
25923
25948
  window.removeEventListener("keydown", handleKeyDown);
@@ -25925,11 +25950,14 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25925
25950
  unbindSearchTriggers(searchTriggers.value, handleCurrentValueSearch);
25926
25951
  });
25927
25952
  const handleMouseClick = (e2) => {
25928
- var _a2, _b;
25953
+ var _a2, _b, _c, _d;
25929
25954
  const el = document.getElementById("lupa-search-box");
25930
25955
  const elementClass = (_b = (_a2 = e2.target) == null ? void 0 : _a2.className) != null ? _b : "";
25931
25956
  const hasLupaClass = typeof elementClass.includes == "function" && elementClass.includes("lupa-search-box");
25932
25957
  const isOutsideElement = el && !el.contains(e2.target) && !hasLupaClass;
25958
+ if (openedAt.value && Date.now() - (openedAt == null ? void 0 : openedAt.value) < 500) {
25959
+ return;
25960
+ }
25933
25961
  if (isOutsideElement && props.options.keepOpen) {
25934
25962
  focused.value = false;
25935
25963
  }
@@ -25938,11 +25966,18 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25938
25966
  }
25939
25967
  opened.value = false;
25940
25968
  suggestedValue.value = defaultSuggestedValue;
25969
+ if ((_c = props.options.callbacks) == null ? void 0 : _c.onClosed) {
25970
+ (_d = props.options.callbacks) == null ? void 0 : _d.onClosed();
25971
+ }
25941
25972
  };
25942
25973
  const close = () => {
25974
+ var _a2, _b;
25943
25975
  opened.value = false;
25944
25976
  focused.value = false;
25945
25977
  suggestedValue.value = defaultSuggestedValue;
25978
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onClosed) {
25979
+ (_b = props.options.callbacks) == null ? void 0 : _b.onClosed();
25980
+ }
25946
25981
  };
25947
25982
  const handleKeyDown = (e2) => {
25948
25983
  var _a2, _b;
@@ -25961,15 +25996,22 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
25961
25996
  handleSearch();
25962
25997
  resetValues();
25963
25998
  break;
25999
+ case "Escape":
26000
+ opened.value = false;
26001
+ focused.value = false;
26002
+ break;
25964
26003
  }
25965
26004
  };
25966
26005
  const handleInput = (value) => {
25967
- var _a2;
26006
+ var _a2, _b;
25968
26007
  opened.value = true;
25969
26008
  focused.value = true;
25970
26009
  inputValue.value = (_a2 = value == null ? void 0 : value.replace(/\s+$/, "")) != null ? _a2 : "";
25971
26010
  suggestedValue.value = defaultSuggestedValue;
25972
26011
  searchBoxStore.resetHighlightIndex();
26012
+ if ((_b = props.options.callbacks) == null ? void 0 : _b.onSearchBoxInput) {
26013
+ props.options.callbacks.onSearchBoxInput(value);
26014
+ }
25973
26015
  trackSearchQuery(value);
25974
26016
  if (props.isSearchContainer) {
25975
26017
  goToResultsDebounced({
@@ -26102,6 +26144,13 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
26102
26144
  });
26103
26145
  };
26104
26146
  watch(() => props.options.debounce, handleCurrentValueSearch);
26147
+ watch(opened, () => {
26148
+ if (opened.value) {
26149
+ openedAt.value = Date.now();
26150
+ } else {
26151
+ openedAt.value = null;
26152
+ }
26153
+ });
26105
26154
  const resetValues = () => {
26106
26155
  inputValue.value = "";
26107
26156
  suggestedValue.value = defaultSuggestedValue;
@@ -26113,10 +26162,27 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
26113
26162
  const slotProps = (props2) => {
26114
26163
  return __spreadValues2({}, props2);
26115
26164
  };
26165
+ const onFocus = () => {
26166
+ var _a2, _b;
26167
+ opened.value = true;
26168
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onFocused) {
26169
+ (_b = props.options.callbacks) == null ? void 0 : _b.onFocused();
26170
+ }
26171
+ };
26172
+ const onBlur = () => {
26173
+ var _a2, _b;
26174
+ focused.value = false;
26175
+ if ((_a2 = props.options.callbacks) == null ? void 0 : _a2.onBlurred) {
26176
+ (_b = props.options.callbacks) == null ? void 0 : _b.onBlurred();
26177
+ }
26178
+ };
26116
26179
  return (_ctx, _cache) => {
26117
26180
  var _a2;
26118
- return openBlock(), createElementBlock("div", _hoisted_1$W, [
26119
- createBaseVNode("div", _hoisted_2$H, [
26181
+ return openBlock(), createElementBlock("div", {
26182
+ id: "lupa-search-box",
26183
+ class: normalizeClass({ "lupa-search-box-opened": opened.value })
26184
+ }, [
26185
+ createBaseVNode("div", _hoisted_1$W, [
26120
26186
  createVNode(_sfc_main$1v, {
26121
26187
  options: inputOptions.value,
26122
26188
  suggestedValue: suggestedValue.value,
@@ -26125,10 +26191,10 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
26125
26191
  ref_key: "searchBoxInput",
26126
26192
  ref: searchBoxInput,
26127
26193
  onInput: handleInput,
26128
- onBlur: _cache[0] || (_cache[0] = ($event) => focused.value = false),
26129
- onFocus: _cache[1] || (_cache[1] = ($event) => opened.value = true),
26194
+ onBlur,
26195
+ onFocus,
26130
26196
  onSearch: handleSearch,
26131
- onClose: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("close"))
26197
+ onClose: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
26132
26198
  }, null, 8, ["options", "suggestedValue", "can-close", "emit-input-on-focus"]),
26133
26199
  opened.value || _ctx.isSearchContainer ? (openBlock(), createBlock(_sfc_main$11, {
26134
26200
  key: 0,
@@ -26151,7 +26217,7 @@ const _sfc_main$10 = /* @__PURE__ */ defineComponent({
26151
26217
  } : void 0
26152
26218
  ]), 1032, ["options", "inputValue", "isSearchContainer", "focused"])) : createCommentVNode("", true)
26153
26219
  ])
26154
- ]);
26220
+ ], 2);
26155
26221
  };
26156
26222
  }
26157
26223
  });
@@ -26745,6 +26811,8 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
26745
26811
  setup(__props, { emit: emit2 }) {
26746
26812
  const props = __props;
26747
26813
  const searchResultStore = useSearchResultStore();
26814
+ const optionsStore = useOptionsStore();
26815
+ const { searchResultOptions } = storeToRefs(optionsStore);
26748
26816
  const facet = computed(() => {
26749
26817
  var _a;
26750
26818
  return (_a = props.facet) != null ? _a : { type: "terms", items: [], key: "" };
@@ -26804,6 +26872,10 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
26804
26872
  selectedItems = isRange.value && selectedItems ? [rangeFilterToString(selectedItems)] : selectedItems;
26805
26873
  return selectedItems == null ? void 0 : selectedItems.includes((_b = item.title) == null ? void 0 : _b.toString());
26806
26874
  };
26875
+ const getItemLabel = (item) => {
26876
+ var _a;
26877
+ return getTranslatedFacetValue(props.facet, item, (_a = searchResultOptions.value.filters) == null ? void 0 : _a.translations);
26878
+ };
26807
26879
  return (_ctx, _cache) => {
26808
26880
  return openBlock(), createElementBlock("div", _hoisted_1$O, [
26809
26881
  isFilterable.value ? withDirectives((openBlock(), createElementBlock("input", {
@@ -26829,7 +26901,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
26829
26901
  }, null, 2)
26830
26902
  ]),
26831
26903
  createBaseVNode("div", _hoisted_6$8, [
26832
- createBaseVNode("span", _hoisted_7$6, toDisplayString(item.title), 1),
26904
+ createBaseVNode("span", _hoisted_7$6, toDisplayString(getItemLabel(item)), 1),
26833
26905
  _ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_8$2, "(" + toDisplayString(item.count) + ")", 1)) : createCommentVNode("", true)
26834
26906
  ])
26835
26907
  ], 10, _hoisted_4$j);
@@ -28313,7 +28385,9 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
28313
28385
  return (_a2 = props.currentFilters) != null ? _a2 : {};
28314
28386
  });
28315
28387
  const searchResultStore = useSearchResultStore();
28388
+ const optionsStore = useOptionsStore();
28316
28389
  const { currentFilterKeys } = storeToRefs(searchResultStore);
28390
+ const { searchResultOptions } = storeToRefs(optionsStore);
28317
28391
  const isOpen = ref((_b = (_a = props.options.expand) == null ? void 0 : _a.includes(props.facet.key)) != null ? _b : false);
28318
28392
  const facetPanel = ref(null);
28319
28393
  const facetType = computed(() => {
@@ -28352,6 +28426,10 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
28352
28426
  const facetKeyClass = computed(() => {
28353
28427
  return `lupa-facet-${facet.value.key}`;
28354
28428
  });
28429
+ const facetLabel = computed(() => {
28430
+ var _a2;
28431
+ return getTranslatedFacetKey(props.facet, (_a2 = searchResultOptions.value.filters) == null ? void 0 : _a2.translations);
28432
+ });
28355
28433
  onMounted(() => {
28356
28434
  var _a2;
28357
28435
  if (((_a2 = props.options.style) == null ? void 0 : _a2.type) === "top-dropdown") {
@@ -28407,7 +28485,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
28407
28485
  "data-cy": "lupa-search-result-facet-label",
28408
28486
  onClick: toggleFacet
28409
28487
  }, [
28410
- createBaseVNode("div", _hoisted_1$K, toDisplayString(facet.value.label), 1),
28488
+ createBaseVNode("div", _hoisted_1$K, toDisplayString(facetLabel.value), 1),
28411
28489
  createBaseVNode("div", {
28412
28490
  class: normalizeClass(["lupa-facet-label-caret", isOpen.value && "open"])
28413
28491
  }, null, 2)
@@ -39597,6 +39675,33 @@ const attatchShadowDom = ({
39597
39675
  shadow.appendChild(style);
39598
39676
  }
39599
39677
  };
39678
+ const createDomPing = () => {
39679
+ let intervalId = null;
39680
+ let remaining = 0;
39681
+ return (intervalMs = 100, count = 50) => {
39682
+ if (intervalId !== null) {
39683
+ clearInterval(intervalId);
39684
+ }
39685
+ remaining = count;
39686
+ const flush = () => {
39687
+ if (remaining-- <= 0) {
39688
+ if (intervalId !== null) {
39689
+ clearInterval(intervalId);
39690
+ intervalId = null;
39691
+ }
39692
+ return;
39693
+ }
39694
+ const el = document.createElement("div");
39695
+ el.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none;";
39696
+ el.setAttribute("data-nudge", Date.now().toString());
39697
+ document.body.appendChild(el);
39698
+ document.body.removeChild(el);
39699
+ };
39700
+ flush();
39701
+ intervalId = window.setInterval(flush, intervalMs);
39702
+ };
39703
+ };
39704
+ const startDomPing = createDomPing();
39600
39705
  const getMountElement = (element, mountingBehavior = "replace", mountToParent) => {
39601
39706
  const parent = element == null ? void 0 : element.parentElement;
39602
39707
  if (mountingBehavior === "replace") {
@@ -39652,6 +39757,58 @@ const app = {
39652
39757
  recommendations: {},
39653
39758
  chat: {}
39654
39759
  };
39760
+ const addSearchBoxDomPingIfConfigured = (options, mountOptions) => {
39761
+ var _a;
39762
+ if (!((_a = mountOptions == null ? void 0 : mountOptions.domPing) == null ? void 0 : _a.count)) {
39763
+ return options;
39764
+ }
39765
+ const newOptions = __spreadProps(__spreadValues({}, options), {
39766
+ callbacks: {
39767
+ onMounted: () => {
39768
+ var _a2, _b;
39769
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onMounted) == null ? void 0 : _b.call(_a2);
39770
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39771
+ },
39772
+ onBlurred: () => {
39773
+ var _a2, _b;
39774
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onBlurred) == null ? void 0 : _b.call(_a2);
39775
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39776
+ },
39777
+ onFocused: () => {
39778
+ var _a2, _b;
39779
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onFocused) == null ? void 0 : _b.call(_a2);
39780
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39781
+ },
39782
+ onSearchBoxInput: (...args) => {
39783
+ var _a2, _b;
39784
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onSearchBoxInput) == null ? void 0 : _b.call(_a2, ...args);
39785
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39786
+ }
39787
+ }
39788
+ });
39789
+ return newOptions;
39790
+ };
39791
+ const addSearchResultsDomPingIfConfigured = (options, mountOptions) => {
39792
+ var _a;
39793
+ if (!((_a = mountOptions == null ? void 0 : mountOptions.domPing) == null ? void 0 : _a.count)) {
39794
+ return options;
39795
+ }
39796
+ const newOptions = __spreadProps(__spreadValues({}, options), {
39797
+ callbacks: {
39798
+ onMounted: () => {
39799
+ var _a2, _b;
39800
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onMounted) == null ? void 0 : _b.call(_a2);
39801
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39802
+ },
39803
+ onUrlQueryChange: (...args) => {
39804
+ var _a2, _b;
39805
+ (_b = (_a2 = options.callbacks) == null ? void 0 : _a2.onUrlQueryChange) == null ? void 0 : _b.call(_a2, ...args);
39806
+ startDomPing(mountOptions.domPing.intervalMs, mountOptions.domPing.count);
39807
+ }
39808
+ }
39809
+ });
39810
+ return newOptions;
39811
+ };
39655
39812
  const applySearchBox = (options, mountOptions) => {
39656
39813
  const existingInstance = app.box[options.inputSelector];
39657
39814
  if (existingInstance) {
@@ -39681,9 +39838,10 @@ const searchBox = (options, mountOptions) => {
39681
39838
  if (!canMount(mountOptions == null ? void 0 : mountOptions.allowedMountUrls)) {
39682
39839
  return;
39683
39840
  }
39841
+ const transformedOptions = addSearchBoxDomPingIfConfigured(options, mountOptions);
39684
39842
  const inputs = (_a = options.inputSelector) == null ? void 0 : _a.split(",");
39685
39843
  for (const input2 of inputs) {
39686
- applySearchBox(__spreadProps(__spreadValues({}, options), { inputSelector: input2.trim() }), mountOptions);
39844
+ applySearchBox(__spreadProps(__spreadValues({}, transformedOptions), { inputSelector: input2.trim() }), mountOptions);
39687
39845
  }
39688
39846
  };
39689
39847
  const searchResults = (options, mountOptions) => {
@@ -39701,12 +39859,13 @@ const searchResults = (options, mountOptions) => {
39701
39859
  }
39702
39860
  return;
39703
39861
  }
39862
+ const transformedOptions = addSearchResultsDomPingIfConfigured(options, mountOptions);
39704
39863
  const instance = createVue(
39705
39864
  options.containerSelector,
39706
39865
  mountOptions == null ? void 0 : mountOptions.mountingBehavior,
39707
39866
  _sfc_main$3,
39708
39867
  {
39709
- searchResultsOptions: options
39868
+ searchResultsOptions: transformedOptions
39710
39869
  }
39711
39870
  );
39712
39871
  if (!instance) {
@@ -40146,6 +40305,7 @@ const mountSearchBox = (configuration, options, optionOverrides, fetch2 = true,
40146
40305
  }
40147
40306
  const resolvedConfiguration = JSON.parse(configuration.searchBox);
40148
40307
  const allowedMountUrls = resolvedConfiguration.allowedMountUrls;
40308
+ const domPing = resolvedConfiguration.domPing;
40149
40309
  const visible = yield waitForElementToBeVisible(
40150
40310
  resolvedConfiguration.inputSelector,
40151
40311
  0,
@@ -40161,7 +40321,7 @@ const mountSearchBox = (configuration, options, optionOverrides, fetch2 = true,
40161
40321
  resolvedConfiguration,
40162
40322
  (_a = optionOverrides == null ? void 0 : optionOverrides.searchBox) != null ? _a : {}
40163
40323
  );
40164
- searchBox(__spreadProps(__spreadValues({}, mergedOptions), { options }), { fetch: fetch2, allowedMountUrls });
40324
+ searchBox(__spreadProps(__spreadValues({}, mergedOptions), { options }), { fetch: fetch2, allowedMountUrls, domPing });
40165
40325
  });
40166
40326
  const mountSearchResults = (configuration, options, optionOverrides, fetch2 = true, remount = false) => __async(exports, null, function* () {
40167
40327
  var _a;
@@ -40170,6 +40330,7 @@ const mountSearchResults = (configuration, options, optionOverrides, fetch2 = tr
40170
40330
  }
40171
40331
  const resolvedConfiguration = JSON.parse(configuration.searchResults);
40172
40332
  const allowedMountUrls = resolvedConfiguration.allowedMountUrls;
40333
+ const domPing = resolvedConfiguration.domPing;
40173
40334
  const visible = yield waitForElementToBeVisible(
40174
40335
  resolvedConfiguration.containerSelector,
40175
40336
  0,
@@ -40185,7 +40346,7 @@ const mountSearchResults = (configuration, options, optionOverrides, fetch2 = tr
40185
40346
  resolvedConfiguration,
40186
40347
  (_a = optionOverrides == null ? void 0 : optionOverrides.searchResults) != null ? _a : {}
40187
40348
  );
40188
- searchResults(__spreadProps(__spreadValues({}, mergedOptions), { options }), { fetch: fetch2, allowedMountUrls });
40349
+ searchResults(__spreadProps(__spreadValues({}, mergedOptions), { options }), { fetch: fetch2, allowedMountUrls, domPing });
40189
40350
  });
40190
40351
  const mountProductList = (configuration, options, optionOverrides, fetch2 = true, remount = false) => __async(exports, null, function* () {
40191
40352
  var _a;