@getlupa/client 1.17.7 → 1.17.8

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.
@@ -7053,1319 +7053,36 @@ const LupaSearchSdk = {
7053
7053
  return loadRedirectionRules(queryKey, (options === null || options === void 0 ? void 0 : options.environment) || "production", options === null || options === void 0 ? void 0 : options.customBaseUrl);
7054
7054
  }
7055
7055
  };
7056
- const getNormalizedString = (str) => {
7057
- var _a, _b;
7058
- if (!str) {
7059
- return "";
7060
- }
7061
- const transformedStr = typeof str === "string" ? str : str.toString();
7062
- return transformedStr.normalize === void 0 ? (_a = transformedStr.toLocaleLowerCase()) == null ? void 0 : _a.trim() : (_b = transformedStr.toLocaleLowerCase().normalize("NFKD").replace(/[^\w\s.-_/]/g, "")) == null ? void 0 : _b.trim();
7063
- };
7064
- const getTransformedString = (str) => {
7065
- var _a, _b;
7066
- if (!str) {
7067
- return "";
7068
- }
7069
- const transformedStr = typeof str === "string" ? str : str.toString();
7070
- return transformedStr.normalize === void 0 ? (_a = transformedStr.toLocaleLowerCase()) == null ? void 0 : _a.trim() : (_b = transformedStr.toLocaleLowerCase().normalize("NFKD")) == null ? void 0 : _b.trim();
7071
- };
7072
- const capitalize$1 = (str) => {
7073
- if (!str) {
7074
- return "";
7075
- }
7076
- return str[0].toLocaleUpperCase() + str.slice(1);
7077
- };
7078
- const addParamsToLabel = (label, ...params) => {
7079
- if (!params || params.length < 1) {
7080
- return label;
7081
- }
7082
- const paramKeys = Array.from(Array(params.length).keys());
7083
- return paramKeys.reduce((a, c2) => a.replace(`{${c2 + 1}}`, params[c2]), label);
7084
- };
7085
- const getRandomString = (length) => {
7086
- const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
7087
- let result2 = "";
7088
- for (let i = length; i > 0; --i) {
7089
- result2 += chars[Math.floor(Math.random() * chars.length)];
7090
- }
7091
- return result2;
7092
- };
7093
- const toFixedIfNecessary = (value, precision = 2) => {
7094
- return (+parseFloat(value).toFixed(precision)).toString();
7095
- };
7096
- const getDisplayValue = (value) => {
7097
- if (value === void 0) {
7098
- return "";
7099
- }
7100
- if (typeof value === "string") {
7101
- return value;
7102
- }
7103
- return toFixedIfNecessary(value.toString());
7104
- };
7105
- const getProductKey = (index, product, idKey) => {
7106
- if (!idKey) {
7107
- return index;
7108
- }
7109
- if (product[idKey]) {
7110
- return product[idKey];
7111
- }
7112
- return index;
7113
- };
7114
- const normalizeFloat = (value) => {
7115
- var _a;
7116
- if (!value) {
7117
- return 0;
7118
- }
7119
- return +((_a = value == null ? void 0 : value.replace(/[^0-9,.]/g, "")) == null ? void 0 : _a.replace(",", "."));
7120
- };
7121
- const escapeHtml$1 = (value) => {
7122
- if (!value) {
7123
- return "";
7124
- }
7125
- let output = "";
7126
- let isSkip = false;
7127
- value.split(/(<del>.*?<\/del>)/g).forEach((segment) => {
7128
- if (segment.startsWith("<del>") && segment.endsWith("</del>")) {
7129
- output += segment;
7130
- isSkip = true;
7131
- }
7132
- if (!isSkip) {
7133
- output += segment.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
7134
- }
7135
- if (isSkip) {
7136
- isSkip = false;
7137
- }
7138
- });
7139
- return output;
7140
- };
7141
- const inputsAreEqual = (input2, possibleValues) => {
7142
- if (!input2) {
7143
- return false;
7144
- }
7145
- const normalizedInput = getTransformedString(input2);
7146
- return possibleValues.some((v) => getTransformedString(v) === normalizedInput);
7147
- };
7148
- const levenshteinDistance = (s = "", t = "") => {
7149
- if (!(s == null ? void 0 : s.length)) {
7150
- return t.length;
7151
- }
7152
- if (!(t == null ? void 0 : t.length)) {
7153
- return s.length;
7154
- }
7155
- const arr = [];
7156
- for (let i = 0; i <= t.length; i++) {
7157
- arr[i] = [i];
7158
- for (let j = 1; j <= s.length; j++) {
7159
- arr[i][j] = i === 0 ? j : Math.min(
7160
- arr[i - 1][j] + 1,
7161
- arr[i][j - 1] + 1,
7162
- arr[i - 1][j - 1] + (s[j - 1] === t[i - 1] ? 0 : 1)
7163
- );
7164
- }
7165
- }
7166
- return arr[t.length][s.length];
7167
- };
7168
- const findClosestStringValue = (input2, possibleValues, key) => {
7169
- var _a;
7170
- const directMatch = possibleValues.find((v) => v[key] === input2);
7171
- if (directMatch) {
7172
- return directMatch;
7173
- }
7174
- const distances = possibleValues.map((v) => levenshteinDistance(`${v[key]}`, input2));
7175
- const minDistance = Math.min(...distances);
7176
- const closestValue = (_a = possibleValues.filter((_, i) => distances[i] === minDistance)) == null ? void 0 : _a[0];
7177
- return closestValue;
7178
- };
7179
- const DEFAULT_SEARCH_BOX_OPTIONS$1 = {
7180
- inputSelector: "#searchBox",
7181
- options: {
7182
- environment: "production"
7183
- },
7184
- showTotalCount: false,
7185
- minInputLength: 1,
7186
- inputAttributes: {
7187
- name: "q"
7188
- },
7189
- debounce: 0,
7190
- labels: {
7191
- placeholder: "Search for products...",
7192
- noResults: "There are no results found.",
7193
- moreResults: "Show more results",
7194
- currency: "€",
7195
- defaultFacetLabel: "Category:"
7196
- },
7197
- links: {
7198
- searchResults: "/search"
7199
- },
7200
- panels: [
7201
- {
7202
- type: "suggestion",
7203
- queryKey: "",
7204
- highlight: true,
7205
- limit: 5
7206
- },
7207
- {
7208
- type: "document",
7209
- queryKey: "",
7210
- limit: 5,
7211
- searchBySuggestion: false,
7212
- links: {
7213
- details: "{url}"
7214
- },
7215
- titleKey: "name",
7216
- elements: []
7217
- }
7218
- ],
7219
- history: {
7220
- labels: {
7221
- clear: "Clear History"
7222
- }
7223
- }
7224
- };
7225
- const DEFAULT_OPTIONS_RESULTS$1 = {
7226
- options: {
7227
- environment: "production"
7228
- },
7229
- queryKey: "",
7230
- containerSelector: "#searchResultsContainer",
7231
- searchTitlePosition: "page-top",
7232
- labels: {
7233
- pageSize: "Page size:",
7234
- sortBy: "Sort by:",
7235
- itemCount: "Items {1} of {2}",
7236
- filteredItemCount: "",
7237
- currency: "€",
7238
- showMore: "Show more",
7239
- searchResults: "Search Query: ",
7240
- emptyResults: "There are no results for the query:",
7241
- mobileFilterButton: "Filter",
7242
- htmlTitleTemplate: "Search Query: '{1}'",
7243
- noResultsSuggestion: "No results found for this query: {1}",
7244
- didYouMean: "Did you mean to search: {1}",
7245
- similarQuery: "Search results for phrase {1}",
7246
- similarQueries: "Similar queries:",
7247
- similarResultsLabel: "Related to your query:"
7248
- },
7249
- grid: {
7250
- columns: {
7251
- xl: 4,
7252
- l: 3,
7253
- md: 2,
7254
- sm: 2,
7255
- xs: 1
7256
- }
7257
- },
7258
- pagination: {
7259
- sizeSelection: {
7260
- position: {
7261
- top: false,
7262
- bottom: true
7263
- },
7264
- sizes: [10, 20, 25]
7265
- },
7266
- pageSelection: {
7267
- position: {
7268
- top: false,
7269
- bottom: true
7270
- },
7271
- display: 5,
7272
- displayMobile: 3
7273
- }
7274
- },
7275
- sort: [],
7276
- filters: {
7277
- currentFilters: {
7278
- visibility: {
7279
- mobileSidebar: true,
7280
- mobileToolbar: true
7281
- },
7282
- labels: {
7283
- title: "Current filters:",
7284
- clearAll: "Clear all"
7056
+ var commonjsGlobal$1 = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
7057
+ function getDefaultExportFromCjs(x2) {
7058
+ return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
7059
+ }
7060
+ function getAugmentedNamespace(n) {
7061
+ if (n.__esModule)
7062
+ return n;
7063
+ var f2 = n.default;
7064
+ if (typeof f2 == "function") {
7065
+ var a = function a2() {
7066
+ if (this instanceof a2) {
7067
+ var args = [null];
7068
+ args.push.apply(args, arguments);
7069
+ var Ctor = Function.bind.apply(f2, args);
7070
+ return new Ctor();
7285
7071
  }
7286
- },
7287
- facets: {
7288
- labels: {
7289
- title: "Filters:",
7290
- showAll: "Show more",
7291
- facetFilter: "Filter...",
7292
- facetClear: "Clear"
7293
- },
7294
- filterable: {
7295
- minValues: 5
7296
- },
7297
- hierarchy: {
7298
- maxInitialLevel: 2,
7299
- topLevelValueCountLimit: 5,
7300
- filterable: true
7301
- },
7302
- facetValueCountLimit: 20,
7303
- showDocumentCount: true,
7304
- style: {
7305
- type: "sidebar"
7306
- }
7307
- }
7308
- },
7309
- toolbar: {
7310
- layoutSelector: true,
7311
- itemSummary: true,
7312
- clearFilters: false
7313
- },
7314
- isInStock: () => {
7315
- return true;
7316
- },
7317
- badges: {
7318
- anchor: "tr",
7319
- elements: []
7320
- },
7321
- links: {
7322
- details: "/{id}"
7323
- },
7324
- elements: [],
7325
- breadcrumbs: []
7326
- };
7327
- const useScreenStore = defineStore("screen", () => {
7328
- const measuredScreenWidth = ref(1e3);
7329
- const optionsStore = useOptionsStore();
7330
- const screenWidth = computed(() => {
7331
- var _a, _b;
7332
- const { searchResultOptions } = storeToRefs(optionsStore);
7333
- return (_b = (_a = searchResultOptions.value.grid) == null ? void 0 : _a.forcedScreenWidth) != null ? _b : measuredScreenWidth.value;
7334
- });
7335
- const configuredGridSizes = computed(() => {
7336
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
7337
- const { searchResultOptions } = storeToRefs(optionsStore);
7338
- return {
7339
- smMin: (_d = (_c = (_b = (_a = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _a.grid) == null ? void 0 : _b.sizes) == null ? void 0 : _c.sm) != null ? _d : S_MIN_WIDTH,
7340
- mdMin: (_h = (_g = (_f = (_e = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _e.grid) == null ? void 0 : _f.sizes) == null ? void 0 : _g.md) != null ? _h : MD_MIN_WIDTH,
7341
- lMin: (_l = (_k = (_j = (_i = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _i.grid) == null ? void 0 : _j.sizes) == null ? void 0 : _k.l) != null ? _l : L_MIN_WIDTH,
7342
- xlMin: (_p = (_o = (_n = (_m = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _m.grid) == null ? void 0 : _n.sizes) == null ? void 0 : _o.xl) != null ? _p : XL_MIN_WIDTH
7072
+ return f2.apply(this, arguments);
7343
7073
  };
7344
- });
7345
- const currentScreenWidth = computed(() => {
7346
- const width = screenWidth.value;
7347
- if (width <= configuredGridSizes.value.smMin) {
7348
- return "xs";
7349
- } else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
7350
- return "sm";
7351
- } else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
7352
- return "md";
7353
- } else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
7354
- return "l";
7355
- } else {
7356
- return "xl";
7357
- }
7358
- });
7359
- const isMobileWidth = computed(() => {
7360
- var _a;
7361
- return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
7362
- });
7363
- const setScreenWidth = ({ width }) => {
7364
- measuredScreenWidth.value = width;
7365
- };
7366
- return { screenWidth, currentScreenWidth, isMobileWidth, setScreenWidth };
7367
- });
7368
- const useOptionsStore = defineStore("options", () => {
7369
- const searchBoxOptions = ref(
7370
- DEFAULT_SEARCH_BOX_OPTIONS$1
7371
- );
7372
- const searchResultOptions = ref(
7373
- DEFAULT_OPTIONS_RESULTS$1
7374
- );
7375
- const trackingOptions = ref({});
7376
- const searchResultInitialFilters = ref({});
7377
- const productRecommendationOptions = ref({});
7378
- const screenStore = useScreenStore();
7379
- const envOptions = computed(
7380
- () => {
7381
- var _a;
7382
- return (_a = searchBoxOptions.value.options) != null ? _a : searchResultOptions.value.options;
7383
- }
7384
- );
7385
- const classMap = computed(() => {
7386
- var _a;
7387
- return (_a = searchResultOptions.value.classMap) != null ? _a : {};
7388
- });
7389
- const initialFilters = computed(() => searchResultInitialFilters.value);
7390
- const boxRoutingBehavior = computed(() => {
7391
- var _a;
7392
- return (_a = searchBoxOptions.value.routingBehavior) != null ? _a : "direct-link";
7393
- });
7394
- const searchResultsRoutingBehavior = computed(
7395
- () => {
7396
- var _a;
7397
- return (_a = searchResultOptions.value.routingBehavior) != null ? _a : "direct-link";
7398
- }
7399
- );
7400
- const defaultSearchResultPageSize = computed(
7401
- () => {
7402
- var _a, _b;
7403
- return (_b = (_a = currentResolutionPageSizes.value) == null ? void 0 : _a[0]) != null ? _b : DEFAULT_PAGE_SIZE;
7404
- }
7405
- );
7406
- const currentResolutionPageSizes = computed(() => {
7407
- var _a, _b, _c, _d;
7408
- const pageSizes = (_d = (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.pagination) == null ? void 0 : _b.sizeSelection) == null ? void 0 : _c.sizes) != null ? _d : DEFAULT_PAGE_SIZE_SELECTION;
7409
- if (Array.isArray(pageSizes)) {
7410
- return pageSizes;
7411
- }
7412
- const screenSize = screenStore.currentScreenWidth;
7413
- switch (screenSize) {
7414
- case "xs":
7415
- return pageSizes.xs;
7416
- case "sm":
7417
- return pageSizes.sm;
7418
- case "md":
7419
- return pageSizes.md;
7420
- case "l":
7421
- return pageSizes.l;
7422
- case "xl":
7423
- return pageSizes.xl;
7424
- }
7425
- });
7426
- const setSearchBoxOptions = ({ options }) => {
7427
- searchBoxOptions.value = options;
7428
- };
7429
- const setTrackingOptions = ({ options }) => {
7430
- trackingOptions.value = options;
7431
- };
7432
- const setSearchResultOptions = ({ options }) => {
7433
- searchResultOptions.value = options;
7434
- };
7435
- const setInitialFilters = ({ initialFilters: initialFilters2 }) => {
7436
- searchResultInitialFilters.value = initialFilters2;
7437
- };
7438
- const setProductRecommendationOptions = ({
7439
- options
7440
- }) => {
7441
- productRecommendationOptions.value = options;
7442
- };
7443
- const getQueryParamName = (param) => {
7444
- var _a;
7445
- const nameMap = searchBoxOptions.value.queryParameterNames;
7446
- return (_a = nameMap == null ? void 0 : nameMap[param]) != null ? _a : param;
7447
- };
7448
- return {
7449
- searchBoxOptions,
7450
- searchResultOptions,
7451
- trackingOptions,
7452
- envOptions,
7453
- classMap,
7454
- initialFilters,
7455
- boxRoutingBehavior,
7456
- searchResultsRoutingBehavior,
7457
- defaultSearchResultPageSize,
7458
- currentResolutionPageSizes,
7459
- productRecommendationOptions,
7460
- setSearchBoxOptions,
7461
- setTrackingOptions,
7462
- setSearchResultOptions,
7463
- setInitialFilters,
7464
- setProductRecommendationOptions,
7465
- getQueryParamName
7466
- };
7467
- });
7468
- const initAnalyticsTracking = (analyticsOptions) => {
7469
- try {
7470
- if (analyticsOptions == null ? void 0 : analyticsOptions.enabled) {
7471
- window.sessionStorage.setItem(TRACKING_ANALYTICS_KEY, JSON.stringify(analyticsOptions));
7472
- } else {
7473
- window.sessionStorage.removeItem(TRACKING_ANALYTICS_KEY);
7474
- }
7475
- } catch (e2) {
7476
- }
7477
- };
7478
- const initBaseTracking = (enabled) => {
7479
- try {
7480
- if (enabled) {
7481
- window.sessionStorage.setItem(TRACKING_STORAGE_KEY_BASE, "1");
7482
- } else {
7483
- window.sessionStorage.removeItem(TRACKING_STORAGE_KEY_BASE);
7484
- clearSessionTracking();
7485
- clearUserTracking();
7486
- }
7487
- } catch (e2) {
7488
- }
7489
- };
7490
- const clearSessionTracking = () => {
7491
- try {
7492
- window.sessionStorage.removeItem(TRACKING_STORAGE_KEY);
7493
- } catch (e2) {
7494
- }
7495
- };
7496
- const initSessionTracking = () => {
7497
- try {
7498
- if (getSessionKey()) {
7499
- return;
7500
- }
7501
- const key = getRandomString(TRACKING_KEY_LENGTH);
7502
- window.sessionStorage.setItem(TRACKING_STORAGE_KEY, key);
7503
- } catch (e2) {
7504
- }
7505
- };
7506
- const initUserTracking = (userKey) => {
7507
- try {
7508
- if (getUserKey()) {
7509
- return;
7510
- }
7511
- const key = userKey || getRandomString(TRACKING_KEY_LENGTH);
7512
- window.localStorage.setItem(TRACKING_STORAGE_KEY, key);
7513
- } catch (e2) {
7514
- }
7515
- };
7516
- const clearUserTracking = () => {
7517
- try {
7518
- window.localStorage.removeItem(TRACKING_STORAGE_KEY);
7519
- } catch (e2) {
7520
- }
7521
- };
7522
- const isTrackingEnabled = () => {
7523
- try {
7524
- return Boolean(window.sessionStorage.getItem(TRACKING_STORAGE_KEY_BASE));
7525
- } catch (e2) {
7526
- return false;
7527
- }
7528
- };
7529
- const isDelayedClickTracking = () => {
7530
- try {
7531
- return Boolean(window.localStorage.getItem(TRACKING_CLICK_DELAYED));
7532
- } catch (e2) {
7533
- return false;
7534
- }
7535
- };
7536
- const getSessionKey = () => {
7537
- var _a;
7538
- try {
7539
- return (_a = window.sessionStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
7540
- } catch (e2) {
7541
- return void 0;
7542
- }
7543
- };
7544
- const getUserKey = () => {
7545
- var _a;
7546
- try {
7547
- return (_a = window.localStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
7548
- } catch (e2) {
7549
- return void 0;
7550
- }
7551
- };
7552
- const initTracking$1 = (options) => {
7553
- initBaseTracking(Boolean(options.trackBase));
7554
- if (options.trackSession) {
7555
- initSessionTracking();
7556
- } else {
7557
- clearSessionTracking();
7558
- }
7559
- if (options.trackUser) {
7560
- initUserTracking(options.userKey);
7561
- } else {
7562
- clearUserTracking();
7563
- }
7564
- if (options.analytics) {
7565
- initAnalyticsTracking(options.analytics);
7566
- }
7567
- if (options.delayedClickTracking) {
7568
- window.localStorage.setItem(TRACKING_CLICK_DELAYED, "1");
7569
- checkAndDispatchDelayedEvents();
7570
- } else {
7571
- window.localStorage.removeItem(TRACKING_CLICK_DELAYED);
7572
- }
7573
- };
7574
- const getLupaTrackingContext = () => {
7575
- if (!isTrackingEnabled()) {
7576
- return {};
7577
- }
7578
- return {
7579
- userId: getUserKey(),
7580
- sessionId: getSessionKey()
7581
- };
7582
- };
7583
- const trackLupaEvent = (queryKey, data = {}, options) => {
7584
- var _a, _b;
7585
- if (!queryKey || !data.type) {
7586
- return;
7587
- }
7588
- const eventData = {
7589
- searchQuery: (_a = data.searchQuery) != null ? _a : "",
7590
- itemId: (_b = data.itemId) != null ? _b : "",
7591
- name: data.type,
7592
- userId: getUserKey(),
7593
- sessionId: getSessionKey(),
7594
- filters: data.filters,
7595
- metadata: data.metadata,
7596
- sourceItemId: data.sourceItemId
7597
- };
7598
- LupaSearchSdk.track(queryKey, eventData, options);
7599
- };
7600
- const sendGa = (name, ...args) => {
7601
- window.ga(() => {
7602
- const trackers = window.ga.getAll();
7603
- const firstTracker = trackers[0];
7604
- if (!firstTracker) {
7605
- console.error("GA tracker not found");
7606
- }
7607
- const trackerName = firstTracker.get("name");
7608
- window.ga(`${trackerName}.${name}`, ...args);
7609
- });
7610
- };
7611
- const trackAnalyticsEvent = (data) => {
7612
- var _a, _b, _c;
7613
- try {
7614
- const options = JSON.parse(
7615
- (_a = window.sessionStorage.getItem(TRACKING_ANALYTICS_KEY)) != null ? _a : "{}"
7616
- );
7617
- if (!data.analytics || !options.enabled || ((_c = options.ignoreEvents) == null ? void 0 : _c.includes((_b = data.analytics) == null ? void 0 : _b.type))) {
7618
- return;
7619
- }
7620
- switch (options.type) {
7621
- case "ua":
7622
- sendUaAnalyticsEvent(data, options);
7623
- break;
7624
- case "ga4":
7625
- sendGa4AnalyticsEvent(data, options);
7626
- break;
7627
- case "debug":
7628
- processDebugEvent(data);
7629
- break;
7630
- default:
7631
- sendUaAnalyticsEvent(data, options);
7632
- }
7633
- } catch (e2) {
7634
- console.error("Unable to send an event to google analytics");
7635
- }
7636
- };
7637
- const parseEcommerceData = (data, title) => {
7638
- var _a, _b;
7639
- return ((_a = data.analytics) == null ? void 0 : _a.items) ? {
7640
- item_list_name: title,
7641
- items: (_b = data.analytics) == null ? void 0 : _b.items
7642
- } : void 0;
7643
- };
7644
- const sendUaAnalyticsEvent = (data, options) => {
7645
- var _a, _b, _c, _d;
7646
- const ga = window.ga;
7647
- if (!ga) {
7648
- console.error("Google Analytics object not found");
7649
- return;
7650
- }
7651
- sendGa(
7652
- "send",
7653
- "event",
7654
- options.parentEventName,
7655
- (_b = (_a = data.analytics) == null ? void 0 : _a.type) != null ? _b : "",
7656
- (_d = (_c = data.analytics) == null ? void 0 : _c.label) != null ? _d : ""
7657
- );
7658
- };
7659
- const sendGa4AnalyticsEvent = (data, options) => {
7660
- var _a, _b, _c, _d, _e, _f, _g;
7661
- if (!window || !window.dataLayer) {
7662
- console.error("dataLayer object not found.");
7663
- return;
7664
- }
7665
- const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
7666
- const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
7667
- const params = __spreadValues2({
7668
- search_text: data.searchQuery,
7669
- item_title: title,
7670
- item_id: data.itemId,
7671
- ecommerce: parseEcommerceData(data, (_c = data.analytics) == null ? void 0 : _c.listLabel)
7672
- }, (_e = (_d = data.analytics) == null ? void 0 : _d.additionalParams) != null ? _e : {});
7673
- window.dataLayer.push(__spreadValues2({
7674
- event: (_g = (_f = data.analytics) == null ? void 0 : _f.type) != null ? _g : options.parentEventName
7675
- }, params));
7676
- };
7677
- const processDebugEvent = (data) => {
7678
- var _a, _b, _c, _d;
7679
- const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
7680
- const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
7681
- const params = {
7682
- event: (_c = data.analytics) == null ? void 0 : _c.type,
7683
- search_text: data.searchQuery,
7684
- item_title: title,
7685
- item_id: data.itemId,
7686
- ecommerce: parseEcommerceData(data, (_d = data.analytics) == null ? void 0 : _d.listLabel)
7687
- };
7688
- console.debug("Analytics debug event:", params);
7689
- };
7690
- const getDelayedEventsCache = () => {
7691
- var _a;
7692
- try {
7693
- return JSON.parse((_a = window.localStorage.getItem(DELAYED_TRACKING_EVENTS_CACHE)) != null ? _a : "{}");
7694
- } catch (e2) {
7695
- return {};
7696
- }
7697
- };
7698
- const storeDelayedEventCache = (cache) => {
7699
- try {
7700
- window.localStorage.setItem(DELAYED_TRACKING_EVENTS_CACHE, JSON.stringify(cache));
7701
- } catch (e2) {
7702
- }
7703
- };
7704
- const checkAndDispatchDelayedEvents = () => {
7705
- var _a, _b;
7706
- const optionsStore = useOptionsStore();
7707
- const eventCache = getDelayedEventsCache();
7708
- const urls = Object.keys(eventCache);
7709
- for (const url of urls) {
7710
- if ((_a = window.location.href) == null ? void 0 : _a.includes(url)) {
7711
- const options = (_b = optionsStore.envOptions) != null ? _b : { environment: "production" };
7712
- const { queryKey, data } = eventCache[url];
7713
- track(queryKey, data, options);
7714
- }
7715
- }
7716
- storeDelayedEventCache({});
7717
- };
7718
- const track = (queryKey, data = {}, options) => {
7719
- var _a;
7720
- if (!isTrackingEnabled()) {
7721
- return;
7722
- }
7723
- const hasSearchQuery = data.searchQuery;
7724
- if (!hasSearchQuery && !((_a = data.options) == null ? void 0 : _a.allowEmptySearchQuery)) {
7725
- return;
7726
- }
7727
- trackAnalyticsEvent(data);
7728
- trackLupaEvent(queryKey, data, options);
7729
- };
7730
- var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
7731
- DocumentElementType2["IMAGE"] = "image";
7732
- DocumentElementType2["TITLE"] = "title";
7733
- DocumentElementType2["CUSTOM"] = "custom";
7734
- DocumentElementType2["DESCRIPTION"] = "description";
7735
- DocumentElementType2["PRICE"] = "price";
7736
- DocumentElementType2["REGULARPRICE"] = "regularPrice";
7737
- DocumentElementType2["RATING"] = "rating";
7738
- DocumentElementType2["SINGLE_STAR_RATING"] = "singleStarRating";
7739
- DocumentElementType2["ADDTOCART"] = "addToCart";
7740
- DocumentElementType2["CUSTOM_HTML"] = "customHtml";
7741
- return DocumentElementType2;
7742
- })(DocumentElementType || {});
7743
- var SearchBoxPanelType = /* @__PURE__ */ ((SearchBoxPanelType2) => {
7744
- SearchBoxPanelType2["SUGGESTION"] = "suggestion";
7745
- SearchBoxPanelType2["DOCUMENT"] = "document";
7746
- SearchBoxPanelType2["RELATED_SOURCE"] = "related-source";
7747
- return SearchBoxPanelType2;
7748
- })(SearchBoxPanelType || {});
7749
- var BadgeType = /* @__PURE__ */ ((BadgeType2) => {
7750
- BadgeType2["NEWITEM"] = "newItem";
7751
- BadgeType2["TEXT"] = "text";
7752
- BadgeType2["IMAGE"] = "image";
7753
- BadgeType2["CUSTOM_HTML"] = "customHtml";
7754
- BadgeType2["DISCOUNT"] = "discount";
7755
- return BadgeType2;
7756
- })(BadgeType || {});
7757
- const retrieveHistory = () => {
7758
- try {
7759
- const historyString = window.localStorage.getItem(HISTORY_LOCAL_STORAGE_KEY);
7760
- return historyString ? JSON.parse(historyString) : [];
7761
- } catch (e2) {
7762
- return [];
7763
- }
7764
- };
7765
- const saveHistory = (items) => {
7766
- try {
7767
- window.localStorage.setItem(
7768
- HISTORY_LOCAL_STORAGE_KEY,
7769
- JSON.stringify(items.slice(0, HISTORY_MAX_ITEMS))
7770
- );
7771
- } catch (e2) {
7772
- }
7773
- };
7774
- const useHistoryStore = defineStore("history", () => {
7775
- const items = ref(retrieveHistory());
7776
- const count = computed(() => items.value.length);
7777
- const add2 = ({ item }) => {
7778
- if (!item) {
7779
- return items.value;
7780
- }
7781
- const newItems = items.value ? [item, ...items.value] : [item];
7782
- const uniqueItems = Array.from(new Set(newItems));
7783
- items.value = uniqueItems;
7784
- saveHistory(uniqueItems);
7785
- return uniqueItems;
7786
- };
7787
- const remove2 = ({ item }) => {
7788
- var _a, _b;
7789
- const tempItems = (_b = (_a = items.value) == null ? void 0 : _a.filter((i) => i !== item)) != null ? _b : [];
7790
- saveHistory(tempItems);
7791
- items.value = tempItems;
7792
- return tempItems;
7793
- };
7794
- const clear2 = () => {
7795
- saveHistory([]);
7796
- items.value = [];
7797
- };
7798
- return { items, count, add: add2, remove: remove2, clear: clear2 };
7799
- });
7800
- const QUERY_PARAMS$1 = {
7801
- QUERY: "q",
7802
- PAGE: "p",
7803
- LIMIT: "l",
7804
- SORT: "s"
7805
- };
7806
- const QUERY_PARAMS_PARSED = {
7807
- QUERY: "query",
7808
- PAGE: "page",
7809
- LIMIT: "limit",
7810
- SORT: "sort"
7811
- };
7812
- const FACET_PARAMS_TYPE = {
7813
- TERMS: "f.",
7814
- RANGE: "fr.",
7815
- HIERARCHY: "fh."
7816
- };
7817
- const FACET_FILTER_MAP = {
7818
- terms: FACET_PARAMS_TYPE.TERMS,
7819
- range: FACET_PARAMS_TYPE.RANGE,
7820
- hierarchy: FACET_PARAMS_TYPE.HIERARCHY
7821
- };
7822
- const FACET_KEY_SEPARATOR = ".";
7823
- const FACET_RANGE_SEPARATOR = ":";
7824
- const HIERARCHY_SEPARATOR = ">";
7825
- const FACET_TERM_RANGE_SEPARATOR = "-";
7826
- const getAmount = (price, separator = ".") => {
7827
- var _a, _b;
7828
- if (typeof price === "number") {
7829
- return `${(_a = price.toFixed(2)) == null ? void 0 : _a.replace(".", separator)}`;
7830
- }
7831
- const value = parseFloat(price);
7832
- if (isNaN(value)) {
7833
- return "";
7834
- }
7835
- return (_b = value.toFixed(2)) == null ? void 0 : _b.replace(".", separator);
7836
- };
7837
- const formatPrice = (price, currency = "€", separator = ",", currencyTemplate = "") => {
7838
- if (price !== 0 && !price) {
7839
- return "";
7840
- }
7841
- const amount = getAmount(price, separator);
7842
- if (!amount) {
7843
- return "";
7844
- }
7845
- if (currencyTemplate) {
7846
- return addParamsToLabel(currencyTemplate, amount);
7847
- }
7848
- return `${amount} ${currency}`;
7849
- };
7850
- const formatPriceSummary = ([min, max], currency, separator = ",", currencyTemplate = "") => {
7851
- if (min !== void 0 && max !== void 0) {
7852
- return `${formatPrice(min, currency, separator, currencyTemplate)} - ${formatPrice(
7853
- max,
7854
- currency,
7855
- separator,
7856
- currencyTemplate
7857
- )}`;
7858
- }
7859
- if (min !== void 0) {
7860
- return `> ${formatPrice(min, currency, separator, currencyTemplate)}`;
7861
- }
7862
- return `< ${formatPrice(max, currency, separator, currencyTemplate)}`;
7863
- };
7864
- const getTranslatedFacetKey = (facet, translations) => {
7865
- var _a, _b;
7866
- return (_b = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[facet.key]) != null ? _b : facet.label;
7867
- };
7868
- const getTranslatedFacetValue = (facet, value, translations) => {
7869
- var _a, _b, _c;
7870
- 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;
7871
- };
7872
- const formatRange = (filter2) => {
7873
- var _a, _b;
7874
- const lt = (_a = filter2.lt) != null ? _a : filter2.lte;
7875
- const gt = (_b = filter2.gt) != null ? _b : filter2.gte;
7876
- if (gt !== void 0 && lt !== void 0) {
7877
- return `${gt} - ${lt}`;
7878
- }
7879
- if (lt !== void 0) {
7880
- return `<${filter2.lte !== void 0 ? "=" : ""} ${lt}`;
7881
- }
7882
- return `>${filter2.gte !== void 0 ? "=" : ""} ${gt}`;
7883
- };
7884
- const unfoldTermFilter = (key, filter2) => {
7885
- const seed = [];
7886
- return filter2.reduce((a, c2) => [...a, { key, value: c2, type: "terms" }], seed);
7887
- };
7888
- const unfoldHierarchyFilter = (key, filter2) => {
7889
- const seed = [];
7890
- return filter2.terms.reduce((a, c2) => [...a, { key, value: c2, type: "hierarchy" }], seed);
7891
- };
7892
- const unfoldRangeFilter = (key, filter2, price = {}) => {
7893
- var _a;
7894
- const gt = filter2.gte || filter2.gt;
7895
- const lt = filter2.lte || filter2.lt;
7896
- if (key.includes(CURRENCY_KEY_INDICATOR) || ((_a = price == null ? void 0 : price.keys) == null ? void 0 : _a.includes(key))) {
7897
- return [
7898
- {
7899
- key,
7900
- value: formatPriceSummary(
7901
- [gt, lt],
7902
- price.currency,
7903
- price.separator,
7904
- price.currencyTemplate
7905
- ),
7906
- type: "range"
7907
- }
7908
- ];
7909
- }
7910
- return [{ key, value: `${gt} - ${lt}`, type: "range" }];
7911
- };
7912
- const unfoldFilter = (key, filter2, price = {}) => {
7913
- if (Array.isArray(filter2)) {
7914
- return unfoldTermFilter(key, filter2);
7915
- }
7916
- if (filter2.gte) {
7917
- return unfoldRangeFilter(key, filter2, price);
7918
- }
7919
- if (filter2.terms) {
7920
- return unfoldHierarchyFilter(key, filter2);
7921
- }
7922
- return [];
7923
- };
7924
- const unfoldFilters = (filters, price = {}) => {
7925
- if (!filters) {
7926
- return [];
7927
- }
7928
- const seed = [];
7929
- return Object.entries(filters).reduce((a, c2) => [...a, ...unfoldFilter(...c2, price)], seed);
7930
- };
7931
- const getLabeledFilters = (filters, facets2, translations) => {
7932
- return filters.map((f2) => {
7933
- var _a, _b, _c, _d;
7934
- return __spreadProps2(__spreadValues2({}, f2), {
7935
- 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),
7936
- value: getTranslatedFacetValue({ key: f2.key }, { title: f2.value }, translations)
7937
- });
7938
- });
7939
- };
7940
- const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY);
7941
- const getMostSpecificHierarchyTerms = (terms) => {
7942
- const specificTerms = [];
7943
- for (const term of terms) {
7944
- if (!terms.some((t) => t.startsWith(term) && t !== term)) {
7945
- specificTerms.push(term);
7946
- }
7947
- }
7948
- return Array.from(new Set(specificTerms));
7949
- };
7950
- const recursiveFilter = (items, query = "") => {
7951
- if (!query) {
7952
- return items;
7953
- }
7954
- return items.map((i) => recursiveFilterItem(i, query)).filter(Boolean);
7955
- };
7956
- const recursiveFilterItem = (item, query = "") => {
7957
- const filterable = getNormalizedString(item.title).includes(getNormalizedString(query)) ? item : void 0;
7958
- if (!item.children) {
7959
- return filterable;
7960
- }
7961
- const children = recursiveFilter(item.children, query).filter(Boolean);
7962
- const include = children.length > 0 || filterable;
7963
- return include ? __spreadProps2(__spreadValues2({}, item), {
7964
- children
7965
- }) : void 0;
7966
- };
7967
- const rangeFilterToString = (rangeFilter, separator) => {
7968
- separator = separator || FACET_TERM_RANGE_SEPARATOR;
7969
- return rangeFilter && Object.keys(rangeFilter).length ? rangeFilter.gte + separator + (rangeFilter.lte || rangeFilter.lt) : "";
7970
- };
7971
- const pick = (obj, keys) => {
7972
- const ret = /* @__PURE__ */ Object.create({});
7973
- for (const k of keys) {
7974
- ret[k] = obj[k];
7975
- }
7976
- return ret;
7977
- };
7978
- const getHint = (suggestion, inputValue) => {
7979
- var _a;
7980
- if (!inputValue) {
7981
- return escapeHtml$1(suggestion);
7982
- }
7983
- return (_a = suggestion == null ? void 0 : suggestion.replace(
7984
- inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
7985
- `<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
7986
- )) != null ? _a : "";
7987
- };
7988
- const reverseKeyValue = (obj) => {
7989
- return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
7990
- };
7991
- const getPageCount = (total, limit) => {
7992
- return Math.ceil(total / limit) || 0;
7993
- };
7994
- const isObject$1 = (value) => {
7995
- return value !== null && typeof value === "object" && !Array.isArray(value);
7996
- };
7997
- const parseParam = (key, params) => {
7998
- const value = params.get(key);
7999
- if (!value) {
8000
- return void 0;
8001
- }
8002
- try {
8003
- return decodeURIComponent(value);
8004
- } catch (e2) {
8005
- return void 0;
8006
- }
8007
- };
8008
- const parseRegularKeys = (regularKeys, searchParams, getQueryParamName) => {
8009
- const params = /* @__PURE__ */ Object.create({});
8010
- const keys = reverseKeyValue({
8011
- QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
8012
- LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
8013
- PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
8014
- SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
8015
- });
8016
- for (const key of regularKeys) {
8017
- const rawKey = keys[key] || key;
8018
- params[rawKey] = parseParam(key, searchParams);
8019
- }
8020
- return params;
8021
- };
8022
- const parseFacetKey = (key, searchParams) => {
8023
- var _a, _b, _c, _d;
8024
- if (key.startsWith(FACET_PARAMS_TYPE.TERMS)) {
8025
- return (_b = (_a = searchParams.getAll(key)) == null ? void 0 : _a.map((v) => decodeURIComponent(v))) != null ? _b : [];
8026
- }
8027
- if (key.startsWith(FACET_PARAMS_TYPE.RANGE)) {
8028
- const range = searchParams.get(key);
8029
- if (!range) {
8030
- return {};
8031
- }
8032
- const [min, max] = range.split(FACET_RANGE_SEPARATOR);
8033
- return {
8034
- gte: min,
8035
- lte: max
8036
- };
8037
- }
8038
- if (key.startsWith(FACET_PARAMS_TYPE.HIERARCHY)) {
8039
- return {
8040
- level: 0,
8041
- terms: (_d = (_c = searchParams.getAll(key)) == null ? void 0 : _c.map((v) => decodeURIComponent(v))) != null ? _d : []
8042
- };
8043
- }
8044
- return [];
8045
- };
8046
- const parseFacetKeys = (facetKeys, searchParams) => {
8047
- const params = {};
8048
- params.filters = {};
8049
- for (const key of facetKeys) {
8050
- const parsedKey = key.slice(key.indexOf(FACET_KEY_SEPARATOR) + 1);
8051
- params.filters = __spreadProps2(__spreadValues2({}, params.filters), {
8052
- [parsedKey]: parseFacetKey(key, searchParams)
8053
- });
8054
- }
8055
- return params;
8056
- };
8057
- const parseParams = (getQueryParamName, searchParams) => {
8058
- const params = /* @__PURE__ */ Object.create({});
8059
- if (!searchParams)
8060
- return params;
8061
- const paramKeys = Array.from(searchParams.keys());
8062
- const facetKeys = paramKeys.filter((k) => isFacetKey(k));
8063
- const regularKeys = paramKeys.filter((k) => !isFacetKey(k));
8064
- const r = __spreadValues2(__spreadValues2({
8065
- [QUERY_PARAMS_PARSED.QUERY]: ""
8066
- }, parseRegularKeys(regularKeys, searchParams, getQueryParamName)), parseFacetKeys(facetKeys, searchParams));
8067
- return r;
8068
- };
8069
- const appendParam = (url, { name, value }, encode2 = true) => {
8070
- if (Array.isArray(value)) {
8071
- appendArrayParams(url, { name, value });
8072
- } else {
8073
- appendSingleParam(url, { name, value }, encode2);
8074
- }
8075
- };
8076
- const appendSingleParam = (url, param, encode2 = true) => {
8077
- const valueToAppend = encode2 ? encodeParam(param.value) : param.value;
8078
- if (url.searchParams.has(param.name)) {
8079
- url.searchParams.set(param.name, valueToAppend);
8080
- } else {
8081
- url.searchParams.append(param.name, valueToAppend);
8082
- }
8083
- };
8084
- const appendArrayParams = (url, param) => {
8085
- url.searchParams.delete(param.name);
8086
- param.value.forEach((v) => url.searchParams.append(param.name, encodeParam(v)));
8087
- };
8088
- const getRemovableParams = (url, getQueryParamName, paramsToRemove) => {
8089
- if (paramsToRemove === "all") {
8090
- const params = {
8091
- QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
8092
- LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
8093
- PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
8094
- SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
8095
- };
8096
- return [
8097
- ...Object.values(params),
8098
- ...Array.from(url.searchParams.keys()).filter((k) => isFacetKey(k))
8099
- ];
8100
- }
8101
- return paramsToRemove;
8102
- };
8103
- const removeParams = (url, params = []) => {
8104
- for (const param of params) {
8105
- if (url.searchParams.has(param)) {
8106
- url.searchParams.delete(param);
8107
- }
8108
- }
8109
- };
8110
- const encodeParam = (param) => {
8111
- const encoded = encodeURIComponent(param);
8112
- return encoded.replace(/%C4%85/g, "ą").replace(/%C4%8D/g, "č").replace(/%C4%99/g, "ę").replace(/%C4%97/g, "ė").replace(/%C4%AF/g, "į").replace(/%C5%A1/g, "š").replace(/%C5%B3/g, "ų").replace(/%C5%AB/g, "ū").replace(/%C5%BE/g, "ž").replace(/%20/g, " ");
8113
- };
8114
- const getQueryParam$1 = (name) => {
8115
- try {
8116
- const urlParams = new URLSearchParams(window.location.search);
8117
- return urlParams.get(name);
8118
- } catch (e2) {
8119
- return null;
8120
- }
8121
- };
8122
- const PATH_REPLACE_REGEXP = /{(.*?)}/gm;
8123
- const generateLink = (linkPattern, document2) => {
8124
- const matches = linkPattern.match(PATH_REPLACE_REGEXP);
8125
- if (!matches) {
8126
- return linkPattern;
8127
- }
8128
- let link = linkPattern;
8129
- for (const match of matches) {
8130
- const propertyKey = match.slice(1, match.length - 1);
8131
- const property = document2[propertyKey] || "";
8132
- link = link.replace(match, property);
8133
- }
8134
- return link;
8135
- };
8136
- const generateResultLink = (link, getQueryParamName, searchText, facet) => {
8137
- if (!searchText) {
8138
- return link;
8139
- }
8140
- const facetParam = facet ? `&${FACET_PARAMS_TYPE.TERMS}${encodeParam(facet.key)}=${encodeParam(facet.title)}` : "";
8141
- const queryParam = `?${getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY}=${encodeParam(searchText)}`;
8142
- return `${link}${queryParam}${facetParam}`;
8143
- };
8144
- const getRelativePath = (link) => {
8145
- try {
8146
- const url = new URL(link);
8147
- const partialUrl = url.toString().substring(url.origin.length);
8148
- return partialUrl.endsWith("/") ? partialUrl.slice(0, partialUrl.length - 1) : partialUrl;
8149
- } catch (e2) {
8150
- return (link == null ? void 0 : link.endsWith("/")) ? link.slice(0, link.length - 1) : link;
8151
- }
8152
- };
8153
- const linksMatch = (link1, link2) => {
8154
- if (!link1 || !link2) {
8155
- return false;
8156
- }
8157
- return link1 === link2 || getRelativePath(link1) === getRelativePath(link2);
8158
- };
8159
- const emitRoutingEvent = (url) => {
8160
- const event = new CustomEvent(LUPA_ROUTING_EVENT, { detail: url });
8161
- window.dispatchEvent(event);
8162
- };
8163
- const handleRoutingEvent = (link, event, hasEventRouting = false) => {
8164
- if (!hasEventRouting) {
8165
- return;
8166
- }
8167
- event == null ? void 0 : event.preventDefault();
8168
- emitRoutingEvent(link);
8169
- };
8170
- const redirectToResultsPage = (link, searchText, getQueryParamName, facet, routingBehavior = "direct-link") => {
8171
- const url = generateResultLink(link, getQueryParamName, searchText, facet);
8172
- if (routingBehavior === "event") {
8173
- emitRoutingEvent(url);
8174
- } else {
8175
- window.location.assign(url);
8176
- }
8177
- };
8178
- const getPageUrl = (pathnameOverride, ssr) => {
8179
- if (typeof window !== "undefined") {
8180
- const pathname = pathnameOverride || window.location.pathname;
8181
- const origin = window.location.origin;
8182
- const search2 = window.location.search;
8183
- return new URL(origin + pathname + search2);
8184
- }
8185
- return new URL(ssr.url, ssr.baseUrl);
8186
- };
8187
- const getFacetKey = (key, type) => {
8188
- return `${FACET_FILTER_MAP[type]}${key}`;
8189
- };
8190
- const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
8191
- return {
8192
- name: `${type}${key}`,
8193
- value
8194
- };
8195
- };
8196
- const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters, paramsToRemove = []) => {
8197
- const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
8198
- const newParams = toggleTermParam(currentFilter, facetAction.value);
8199
- appendParams({
8200
- params: [getFacetParam(facetAction.key, newParams)],
8201
- paramsToRemove: [
8202
- ...paramsToRemove,
8203
- ...[getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
8204
- ]
8205
- });
8206
- };
8207
- const replaceHierarchyParam = (params = [], param = "") => {
8208
- if (params.some((p2) => p2.startsWith(param))) {
8209
- return toggleLastPram(params, param);
8210
- }
8211
- return [param];
8212
- };
8213
- const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
8214
- var _a, _b;
8215
- const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
8216
- const newParams = facetAction.behavior === "replace" ? replaceHierarchyParam((_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [], facetAction.value) : toggleHierarchyParam((_b = currentFilter == null ? void 0 : currentFilter.terms) != null ? _b : [], facetAction.value, removeAllLevels);
8217
- appendParams({
8218
- params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
8219
- paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
8220
- });
8221
- };
8222
- const toggleRangeFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
8223
- const currentFilter = rangeFilterToString(
8224
- currentFilters == null ? void 0 : currentFilters[facetAction.key],
8225
- FACET_RANGE_SEPARATOR
8226
- );
8227
- let facetValue = facetAction.value.join(FACET_RANGE_SEPARATOR);
8228
- facetValue = currentFilter === facetValue ? "" : facetValue;
8229
- appendParams({
8230
- params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
8231
- paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE],
8232
- encode: false
8233
- });
8234
- };
8235
- const toggleTermParam = (params = [], param = "") => {
8236
- if (params == null ? void 0 : params.includes(param)) {
8237
- return params.filter((p2) => p2 !== param);
8238
- }
8239
- return [param, ...params];
8240
- };
8241
- const toggleLastPram = (params = [], param = "") => {
8242
- const paramLevel = param.split(">").length;
8243
- return getMostSpecificHierarchyTerms(
8244
- params.map(
8245
- (p2) => p2.startsWith(param) ? p2.split(HIERARCHY_SEPARATOR).slice(0, paramLevel - 1).join(HIERARCHY_SEPARATOR).trim() : p2
8246
- ).filter(Boolean)
8247
- );
8248
- };
8249
- const toggleHierarchyParam = (params = [], param = "", removeAllLevels = false) => {
8250
- if (params == null ? void 0 : params.some((p2) => p2.startsWith(param))) {
8251
- return removeAllLevels ? getMostSpecificHierarchyTerms(params.filter((p2) => !p2.startsWith(param))) : toggleLastPram(params, param);
8252
- }
8253
- return getMostSpecificHierarchyTerms([param, ...params]);
8254
- };
8255
- const CACHE_KEY = "lupasearch-client-redirections";
8256
- const useRedirectionStore = defineStore("redirections", () => {
8257
- const redirections = ref({ rules: [] });
8258
- const redirectionOptions = ref({ enabled: false, queryKey: "" });
8259
- const saveToLocalStorage2 = () => {
8260
- try {
8261
- localStorage.setItem(
8262
- CACHE_KEY,
8263
- JSON.stringify({
8264
- redirections: redirections.value,
8265
- savedAt: Date.now(),
8266
- queryKey: redirectionOptions.value.queryKey
8267
- })
8268
- );
8269
- } catch (e2) {
8270
- }
8271
- };
8272
- const tryLoadFromLocalStorage2 = (config) => {
8273
- var _a;
8274
- if (!config.cacheSeconds)
8275
- return false;
8276
- try {
8277
- const data = JSON.parse((_a = localStorage.getItem(CACHE_KEY)) != null ? _a : "");
8278
- if (data.queryKey !== config.queryKey) {
8279
- return false;
8280
- }
8281
- if ((data == null ? void 0 : data.redirections) && Date.now() - data.savedAt < 1e3 * config.cacheSeconds) {
8282
- redirections.value = data.redirections;
8283
- return true;
8284
- }
8285
- } catch (e2) {
8286
- }
8287
- return false;
8288
- };
8289
- const initiate = (config, options) => __async2(void 0, null, function* () {
8290
- var _a, _b, _c, _d;
8291
- if ((_a = redirectionOptions.value) == null ? void 0 : _a.enabled) {
8292
- return;
8293
- }
8294
- redirectionOptions.value = config;
8295
- if (!(config == null ? void 0 : config.enabled)) {
8296
- return;
8297
- }
8298
- const loaded = tryLoadFromLocalStorage2(config);
8299
- if (loaded || ((_c = (_b = redirections.value) == null ? void 0 : _b.rules) == null ? void 0 : _c.length) > 0) {
8300
- return;
8301
- }
8302
- try {
8303
- const result2 = yield LupaSearchSdk.loadRedirectionRules(config.queryKey, options);
8304
- if (!((_d = result2 == null ? void 0 : result2.rules) == null ? void 0 : _d.length)) {
8305
- redirections.value = { rules: [] };
8306
- return;
8307
- }
8308
- redirections.value = result2;
8309
- saveToLocalStorage2();
8310
- } catch (e2) {
8311
- }
8312
- });
8313
- const redirectOnKeywordIfConfigured = (input2, routingBehavior = "direct-link") => {
8314
- var _a, _b, _c, _d;
8315
- if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
8316
- return false;
8317
- }
8318
- const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input2, r.sources));
8319
- if (!redirectTo) {
8320
- return false;
8321
- }
8322
- const url = ((_c = redirectionOptions.value) == null ? void 0 : _c.urlTransformer) ? (_d = redirectionOptions.value) == null ? void 0 : _d.urlTransformer(redirectTo == null ? void 0 : redirectTo.target) : redirectTo == null ? void 0 : redirectTo.target;
8323
- if (url === void 0 || url === null || url === "") {
8324
- return false;
8325
- }
8326
- if (routingBehavior === "event") {
8327
- emitRoutingEvent(url);
8328
- } else {
8329
- window.location.assign(url);
8330
- }
8331
- return true;
8332
- };
8333
- return {
8334
- redirections,
8335
- redirectOnKeywordIfConfigured,
8336
- initiate
8337
- };
8338
- });
8339
- var commonjsGlobal$1 = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
8340
- function getDefaultExportFromCjs(x2) {
8341
- return x2 && x2.__esModule && Object.prototype.hasOwnProperty.call(x2, "default") ? x2["default"] : x2;
8342
- }
8343
- function getAugmentedNamespace(n) {
8344
- if (n.__esModule)
8345
- return n;
8346
- var f2 = n.default;
8347
- if (typeof f2 == "function") {
8348
- var a = function a2() {
8349
- if (this instanceof a2) {
8350
- var args = [null];
8351
- args.push.apply(args, arguments);
8352
- var Ctor = Function.bind.apply(f2, args);
8353
- return new Ctor();
8354
- }
8355
- return f2.apply(this, arguments);
8356
- };
8357
- a.prototype = f2.prototype;
8358
- } else
8359
- a = {};
8360
- Object.defineProperty(a, "__esModule", { value: true });
8361
- Object.keys(n).forEach(function(k) {
8362
- var d2 = Object.getOwnPropertyDescriptor(n, k);
8363
- Object.defineProperty(a, k, d2.get ? d2 : {
8364
- enumerable: true,
8365
- get: function() {
8366
- return n[k];
8367
- }
8368
- });
7074
+ a.prototype = f2.prototype;
7075
+ } else
7076
+ a = {};
7077
+ Object.defineProperty(a, "__esModule", { value: true });
7078
+ Object.keys(n).forEach(function(k) {
7079
+ var d2 = Object.getOwnPropertyDescriptor(n, k);
7080
+ Object.defineProperty(a, k, d2.get ? d2 : {
7081
+ enumerable: true,
7082
+ get: function() {
7083
+ return n[k];
7084
+ }
7085
+ });
8369
7086
  });
8370
7087
  return a;
8371
7088
  }
@@ -13839,18 +12556,1308 @@ lodash$1.exports;
13839
12556
  if (symIterator) {
13840
12557
  lodash2.prototype[symIterator] = wrapperToIterator;
13841
12558
  }
13842
- return lodash2;
13843
- };
13844
- var _ = runInContext();
13845
- if (freeModule) {
13846
- (freeModule.exports = _)._ = _;
13847
- freeExports._ = _;
12559
+ return lodash2;
12560
+ };
12561
+ var _ = runInContext();
12562
+ if (freeModule) {
12563
+ (freeModule.exports = _)._ = _;
12564
+ freeExports._ = _;
12565
+ } else {
12566
+ root2._ = _;
12567
+ }
12568
+ }).call(commonjsGlobal$1);
12569
+ })(lodash$1, lodash$1.exports);
12570
+ var lodashExports$1 = lodash$1.exports;
12571
+ const getNormalizedString = (str) => {
12572
+ var _a, _b;
12573
+ if (!str) {
12574
+ return "";
12575
+ }
12576
+ const transformedStr = typeof str === "string" ? str : str.toString();
12577
+ return transformedStr.normalize === void 0 ? (_a = transformedStr.toLocaleLowerCase()) == null ? void 0 : _a.trim() : (_b = transformedStr.toLocaleLowerCase().normalize("NFKD").replace(/[^\w\s.-_/]/g, "")) == null ? void 0 : _b.trim();
12578
+ };
12579
+ const getTransformedString = (str) => {
12580
+ var _a, _b;
12581
+ if (!str) {
12582
+ return "";
12583
+ }
12584
+ const transformedStr = typeof str === "string" ? str : str.toString();
12585
+ return transformedStr.normalize === void 0 ? (_a = transformedStr.toLocaleLowerCase()) == null ? void 0 : _a.trim() : (_b = transformedStr.toLocaleLowerCase().normalize("NFKD")) == null ? void 0 : _b.trim();
12586
+ };
12587
+ const capitalize$1 = (str) => {
12588
+ if (!str) {
12589
+ return "";
12590
+ }
12591
+ return str[0].toLocaleUpperCase() + str.slice(1);
12592
+ };
12593
+ const addParamsToLabel = (label, ...params) => {
12594
+ if (!params || params.length < 1) {
12595
+ return label;
12596
+ }
12597
+ const paramKeys = Array.from(Array(params.length).keys());
12598
+ return paramKeys.reduce((a, c2) => a.replace(`{${c2 + 1}}`, params[c2]), label);
12599
+ };
12600
+ const getRandomString = (length) => {
12601
+ const chars = "0123456789abcdefghijklmnopqrstuvwxyz";
12602
+ let result2 = "";
12603
+ for (let i = length; i > 0; --i) {
12604
+ result2 += chars[Math.floor(Math.random() * chars.length)];
12605
+ }
12606
+ return result2;
12607
+ };
12608
+ const toFixedIfNecessary = (value, precision = 2) => {
12609
+ return (+parseFloat(value).toFixed(precision)).toString();
12610
+ };
12611
+ const getDisplayValue = (value) => {
12612
+ if (value === void 0) {
12613
+ return "";
12614
+ }
12615
+ if (typeof value === "string") {
12616
+ return value;
12617
+ }
12618
+ return toFixedIfNecessary(value.toString());
12619
+ };
12620
+ const getProductKey = (index, product, idKey) => {
12621
+ if (!idKey) {
12622
+ return index;
12623
+ }
12624
+ if (product[idKey]) {
12625
+ return product[idKey];
12626
+ }
12627
+ return index;
12628
+ };
12629
+ const normalizeFloat = (value) => {
12630
+ var _a;
12631
+ if (!value) {
12632
+ return 0;
12633
+ }
12634
+ return +((_a = value == null ? void 0 : value.replace(/[^0-9,.]/g, "")) == null ? void 0 : _a.replace(",", "."));
12635
+ };
12636
+ const escapeHtml$1 = (value) => {
12637
+ if (!value) {
12638
+ return "";
12639
+ }
12640
+ let output = "";
12641
+ let isSkip = false;
12642
+ value.split(/(<del>.*?<\/del>)/g).forEach((segment) => {
12643
+ if (segment.startsWith("<del>") && segment.endsWith("</del>")) {
12644
+ output += segment;
12645
+ isSkip = true;
12646
+ }
12647
+ if (!isSkip) {
12648
+ output += segment.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
12649
+ }
12650
+ if (isSkip) {
12651
+ isSkip = false;
12652
+ }
12653
+ });
12654
+ return output;
12655
+ };
12656
+ const inputsAreEqual = (input2, possibleValues) => {
12657
+ if (!input2) {
12658
+ return false;
12659
+ }
12660
+ const normalizedInput = getTransformedString(input2);
12661
+ return possibleValues.some((v) => getTransformedString(v) === normalizedInput);
12662
+ };
12663
+ const levenshteinDistance = (s = "", t = "") => {
12664
+ if (!(s == null ? void 0 : s.length)) {
12665
+ return t.length;
12666
+ }
12667
+ if (!(t == null ? void 0 : t.length)) {
12668
+ return s.length;
12669
+ }
12670
+ const arr = [];
12671
+ for (let i = 0; i <= t.length; i++) {
12672
+ arr[i] = [i];
12673
+ for (let j = 1; j <= s.length; j++) {
12674
+ arr[i][j] = i === 0 ? j : Math.min(
12675
+ arr[i - 1][j] + 1,
12676
+ arr[i][j - 1] + 1,
12677
+ arr[i - 1][j - 1] + (s[j - 1] === t[i - 1] ? 0 : 1)
12678
+ );
12679
+ }
12680
+ }
12681
+ return arr[t.length][s.length];
12682
+ };
12683
+ const findClosestStringValue = (input2, possibleValues, key) => {
12684
+ var _a;
12685
+ const directMatch = possibleValues.find((v) => v[key] === input2);
12686
+ if (directMatch) {
12687
+ return directMatch;
12688
+ }
12689
+ const distances = possibleValues.map((v) => levenshteinDistance(`${v[key]}`, input2));
12690
+ const minDistance = Math.min(...distances);
12691
+ const closestValue = (_a = possibleValues.filter((_, i) => distances[i] === minDistance)) == null ? void 0 : _a[0];
12692
+ return closestValue;
12693
+ };
12694
+ const slugifyClass = (s) => {
12695
+ let slug = lodashExports$1.kebabCase(s);
12696
+ if (!slug || /^[0-9-]/.test(slug)) {
12697
+ slug = `c-${slug}`;
12698
+ }
12699
+ return slug;
12700
+ };
12701
+ const DEFAULT_SEARCH_BOX_OPTIONS$1 = {
12702
+ inputSelector: "#searchBox",
12703
+ options: {
12704
+ environment: "production"
12705
+ },
12706
+ showTotalCount: false,
12707
+ minInputLength: 1,
12708
+ inputAttributes: {
12709
+ name: "q"
12710
+ },
12711
+ debounce: 0,
12712
+ labels: {
12713
+ placeholder: "Search for products...",
12714
+ noResults: "There are no results found.",
12715
+ moreResults: "Show more results",
12716
+ currency: "€",
12717
+ defaultFacetLabel: "Category:"
12718
+ },
12719
+ links: {
12720
+ searchResults: "/search"
12721
+ },
12722
+ panels: [
12723
+ {
12724
+ type: "suggestion",
12725
+ queryKey: "",
12726
+ highlight: true,
12727
+ limit: 5
12728
+ },
12729
+ {
12730
+ type: "document",
12731
+ queryKey: "",
12732
+ limit: 5,
12733
+ searchBySuggestion: false,
12734
+ links: {
12735
+ details: "{url}"
12736
+ },
12737
+ titleKey: "name",
12738
+ elements: []
12739
+ }
12740
+ ],
12741
+ history: {
12742
+ labels: {
12743
+ clear: "Clear History"
12744
+ }
12745
+ }
12746
+ };
12747
+ const DEFAULT_OPTIONS_RESULTS$1 = {
12748
+ options: {
12749
+ environment: "production"
12750
+ },
12751
+ queryKey: "",
12752
+ containerSelector: "#searchResultsContainer",
12753
+ searchTitlePosition: "page-top",
12754
+ labels: {
12755
+ pageSize: "Page size:",
12756
+ sortBy: "Sort by:",
12757
+ itemCount: "Items {1} of {2}",
12758
+ filteredItemCount: "",
12759
+ currency: "€",
12760
+ showMore: "Show more",
12761
+ searchResults: "Search Query: ",
12762
+ emptyResults: "There are no results for the query:",
12763
+ mobileFilterButton: "Filter",
12764
+ htmlTitleTemplate: "Search Query: '{1}'",
12765
+ noResultsSuggestion: "No results found for this query: {1}",
12766
+ didYouMean: "Did you mean to search: {1}",
12767
+ similarQuery: "Search results for phrase {1}",
12768
+ similarQueries: "Similar queries:",
12769
+ similarResultsLabel: "Related to your query:"
12770
+ },
12771
+ grid: {
12772
+ columns: {
12773
+ xl: 4,
12774
+ l: 3,
12775
+ md: 2,
12776
+ sm: 2,
12777
+ xs: 1
12778
+ }
12779
+ },
12780
+ pagination: {
12781
+ sizeSelection: {
12782
+ position: {
12783
+ top: false,
12784
+ bottom: true
12785
+ },
12786
+ sizes: [10, 20, 25]
12787
+ },
12788
+ pageSelection: {
12789
+ position: {
12790
+ top: false,
12791
+ bottom: true
12792
+ },
12793
+ display: 5,
12794
+ displayMobile: 3
12795
+ }
12796
+ },
12797
+ sort: [],
12798
+ filters: {
12799
+ currentFilters: {
12800
+ visibility: {
12801
+ mobileSidebar: true,
12802
+ mobileToolbar: true
12803
+ },
12804
+ labels: {
12805
+ title: "Current filters:",
12806
+ clearAll: "Clear all"
12807
+ }
12808
+ },
12809
+ facets: {
12810
+ labels: {
12811
+ title: "Filters:",
12812
+ showAll: "Show more",
12813
+ facetFilter: "Filter...",
12814
+ facetClear: "Clear"
12815
+ },
12816
+ filterable: {
12817
+ minValues: 5
12818
+ },
12819
+ hierarchy: {
12820
+ maxInitialLevel: 2,
12821
+ topLevelValueCountLimit: 5,
12822
+ filterable: true
12823
+ },
12824
+ facetValueCountLimit: 20,
12825
+ showDocumentCount: true,
12826
+ style: {
12827
+ type: "sidebar"
12828
+ }
12829
+ }
12830
+ },
12831
+ toolbar: {
12832
+ layoutSelector: true,
12833
+ itemSummary: true,
12834
+ clearFilters: false
12835
+ },
12836
+ isInStock: () => {
12837
+ return true;
12838
+ },
12839
+ badges: {
12840
+ anchor: "tr",
12841
+ elements: []
12842
+ },
12843
+ links: {
12844
+ details: "/{id}"
12845
+ },
12846
+ elements: [],
12847
+ breadcrumbs: []
12848
+ };
12849
+ const useScreenStore = defineStore("screen", () => {
12850
+ const measuredScreenWidth = ref(1e3);
12851
+ const optionsStore = useOptionsStore();
12852
+ const screenWidth = computed(() => {
12853
+ var _a, _b;
12854
+ const { searchResultOptions } = storeToRefs(optionsStore);
12855
+ return (_b = (_a = searchResultOptions.value.grid) == null ? void 0 : _a.forcedScreenWidth) != null ? _b : measuredScreenWidth.value;
12856
+ });
12857
+ const configuredGridSizes = computed(() => {
12858
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
12859
+ const { searchResultOptions } = storeToRefs(optionsStore);
12860
+ return {
12861
+ smMin: (_d = (_c = (_b = (_a = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _a.grid) == null ? void 0 : _b.sizes) == null ? void 0 : _c.sm) != null ? _d : S_MIN_WIDTH,
12862
+ mdMin: (_h = (_g = (_f = (_e = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _e.grid) == null ? void 0 : _f.sizes) == null ? void 0 : _g.md) != null ? _h : MD_MIN_WIDTH,
12863
+ lMin: (_l = (_k = (_j = (_i = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _i.grid) == null ? void 0 : _j.sizes) == null ? void 0 : _k.l) != null ? _l : L_MIN_WIDTH,
12864
+ xlMin: (_p = (_o = (_n = (_m = searchResultOptions == null ? void 0 : searchResultOptions.value) == null ? void 0 : _m.grid) == null ? void 0 : _n.sizes) == null ? void 0 : _o.xl) != null ? _p : XL_MIN_WIDTH
12865
+ };
12866
+ });
12867
+ const currentScreenWidth = computed(() => {
12868
+ const width = screenWidth.value;
12869
+ if (width <= configuredGridSizes.value.smMin) {
12870
+ return "xs";
12871
+ } else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
12872
+ return "sm";
12873
+ } else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
12874
+ return "md";
12875
+ } else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
12876
+ return "l";
12877
+ } else {
12878
+ return "xl";
12879
+ }
12880
+ });
12881
+ const isMobileWidth = computed(() => {
12882
+ var _a;
12883
+ return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
12884
+ });
12885
+ const setScreenWidth = ({ width }) => {
12886
+ measuredScreenWidth.value = width;
12887
+ };
12888
+ return { screenWidth, currentScreenWidth, isMobileWidth, setScreenWidth };
12889
+ });
12890
+ const useOptionsStore = defineStore("options", () => {
12891
+ const searchBoxOptions = ref(
12892
+ DEFAULT_SEARCH_BOX_OPTIONS$1
12893
+ );
12894
+ const searchResultOptions = ref(
12895
+ DEFAULT_OPTIONS_RESULTS$1
12896
+ );
12897
+ const trackingOptions = ref({});
12898
+ const searchResultInitialFilters = ref({});
12899
+ const productRecommendationOptions = ref({});
12900
+ const screenStore = useScreenStore();
12901
+ const envOptions = computed(
12902
+ () => {
12903
+ var _a;
12904
+ return (_a = searchBoxOptions.value.options) != null ? _a : searchResultOptions.value.options;
12905
+ }
12906
+ );
12907
+ const classMap = computed(() => {
12908
+ var _a;
12909
+ return (_a = searchResultOptions.value.classMap) != null ? _a : {};
12910
+ });
12911
+ const initialFilters = computed(() => searchResultInitialFilters.value);
12912
+ const boxRoutingBehavior = computed(() => {
12913
+ var _a;
12914
+ return (_a = searchBoxOptions.value.routingBehavior) != null ? _a : "direct-link";
12915
+ });
12916
+ const searchResultsRoutingBehavior = computed(
12917
+ () => {
12918
+ var _a;
12919
+ return (_a = searchResultOptions.value.routingBehavior) != null ? _a : "direct-link";
12920
+ }
12921
+ );
12922
+ const defaultSearchResultPageSize = computed(
12923
+ () => {
12924
+ var _a, _b;
12925
+ return (_b = (_a = currentResolutionPageSizes.value) == null ? void 0 : _a[0]) != null ? _b : DEFAULT_PAGE_SIZE;
12926
+ }
12927
+ );
12928
+ const currentResolutionPageSizes = computed(() => {
12929
+ var _a, _b, _c, _d;
12930
+ const pageSizes = (_d = (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.pagination) == null ? void 0 : _b.sizeSelection) == null ? void 0 : _c.sizes) != null ? _d : DEFAULT_PAGE_SIZE_SELECTION;
12931
+ if (Array.isArray(pageSizes)) {
12932
+ return pageSizes;
12933
+ }
12934
+ const screenSize = screenStore.currentScreenWidth;
12935
+ switch (screenSize) {
12936
+ case "xs":
12937
+ return pageSizes.xs;
12938
+ case "sm":
12939
+ return pageSizes.sm;
12940
+ case "md":
12941
+ return pageSizes.md;
12942
+ case "l":
12943
+ return pageSizes.l;
12944
+ case "xl":
12945
+ return pageSizes.xl;
12946
+ }
12947
+ });
12948
+ const setSearchBoxOptions = ({ options }) => {
12949
+ searchBoxOptions.value = options;
12950
+ };
12951
+ const setTrackingOptions = ({ options }) => {
12952
+ trackingOptions.value = options;
12953
+ };
12954
+ const setSearchResultOptions = ({ options }) => {
12955
+ searchResultOptions.value = options;
12956
+ };
12957
+ const setInitialFilters = ({ initialFilters: initialFilters2 }) => {
12958
+ searchResultInitialFilters.value = initialFilters2;
12959
+ };
12960
+ const setProductRecommendationOptions = ({
12961
+ options
12962
+ }) => {
12963
+ productRecommendationOptions.value = options;
12964
+ };
12965
+ const getQueryParamName = (param) => {
12966
+ var _a;
12967
+ const nameMap = searchBoxOptions.value.queryParameterNames;
12968
+ return (_a = nameMap == null ? void 0 : nameMap[param]) != null ? _a : param;
12969
+ };
12970
+ return {
12971
+ searchBoxOptions,
12972
+ searchResultOptions,
12973
+ trackingOptions,
12974
+ envOptions,
12975
+ classMap,
12976
+ initialFilters,
12977
+ boxRoutingBehavior,
12978
+ searchResultsRoutingBehavior,
12979
+ defaultSearchResultPageSize,
12980
+ currentResolutionPageSizes,
12981
+ productRecommendationOptions,
12982
+ setSearchBoxOptions,
12983
+ setTrackingOptions,
12984
+ setSearchResultOptions,
12985
+ setInitialFilters,
12986
+ setProductRecommendationOptions,
12987
+ getQueryParamName
12988
+ };
12989
+ });
12990
+ const initAnalyticsTracking = (analyticsOptions) => {
12991
+ try {
12992
+ if (analyticsOptions == null ? void 0 : analyticsOptions.enabled) {
12993
+ window.sessionStorage.setItem(TRACKING_ANALYTICS_KEY, JSON.stringify(analyticsOptions));
12994
+ } else {
12995
+ window.sessionStorage.removeItem(TRACKING_ANALYTICS_KEY);
12996
+ }
12997
+ } catch (e2) {
12998
+ }
12999
+ };
13000
+ const initBaseTracking = (enabled) => {
13001
+ try {
13002
+ if (enabled) {
13003
+ window.sessionStorage.setItem(TRACKING_STORAGE_KEY_BASE, "1");
13004
+ } else {
13005
+ window.sessionStorage.removeItem(TRACKING_STORAGE_KEY_BASE);
13006
+ clearSessionTracking();
13007
+ clearUserTracking();
13008
+ }
13009
+ } catch (e2) {
13010
+ }
13011
+ };
13012
+ const clearSessionTracking = () => {
13013
+ try {
13014
+ window.sessionStorage.removeItem(TRACKING_STORAGE_KEY);
13015
+ } catch (e2) {
13016
+ }
13017
+ };
13018
+ const initSessionTracking = () => {
13019
+ try {
13020
+ if (getSessionKey()) {
13021
+ return;
13022
+ }
13023
+ const key = getRandomString(TRACKING_KEY_LENGTH);
13024
+ window.sessionStorage.setItem(TRACKING_STORAGE_KEY, key);
13025
+ } catch (e2) {
13026
+ }
13027
+ };
13028
+ const initUserTracking = (userKey) => {
13029
+ try {
13030
+ if (getUserKey()) {
13031
+ return;
13032
+ }
13033
+ const key = userKey || getRandomString(TRACKING_KEY_LENGTH);
13034
+ window.localStorage.setItem(TRACKING_STORAGE_KEY, key);
13035
+ } catch (e2) {
13036
+ }
13037
+ };
13038
+ const clearUserTracking = () => {
13039
+ try {
13040
+ window.localStorage.removeItem(TRACKING_STORAGE_KEY);
13041
+ } catch (e2) {
13042
+ }
13043
+ };
13044
+ const isTrackingEnabled = () => {
13045
+ try {
13046
+ return Boolean(window.sessionStorage.getItem(TRACKING_STORAGE_KEY_BASE));
13047
+ } catch (e2) {
13048
+ return false;
13049
+ }
13050
+ };
13051
+ const isDelayedClickTracking = () => {
13052
+ try {
13053
+ return Boolean(window.localStorage.getItem(TRACKING_CLICK_DELAYED));
13054
+ } catch (e2) {
13055
+ return false;
13056
+ }
13057
+ };
13058
+ const getSessionKey = () => {
13059
+ var _a;
13060
+ try {
13061
+ return (_a = window.sessionStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
13062
+ } catch (e2) {
13063
+ return void 0;
13064
+ }
13065
+ };
13066
+ const getUserKey = () => {
13067
+ var _a;
13068
+ try {
13069
+ return (_a = window.localStorage.getItem(TRACKING_STORAGE_KEY)) != null ? _a : void 0;
13070
+ } catch (e2) {
13071
+ return void 0;
13072
+ }
13073
+ };
13074
+ const initTracking$1 = (options) => {
13075
+ initBaseTracking(Boolean(options.trackBase));
13076
+ if (options.trackSession) {
13077
+ initSessionTracking();
13078
+ } else {
13079
+ clearSessionTracking();
13080
+ }
13081
+ if (options.trackUser) {
13082
+ initUserTracking(options.userKey);
13083
+ } else {
13084
+ clearUserTracking();
13085
+ }
13086
+ if (options.analytics) {
13087
+ initAnalyticsTracking(options.analytics);
13088
+ }
13089
+ if (options.delayedClickTracking) {
13090
+ window.localStorage.setItem(TRACKING_CLICK_DELAYED, "1");
13091
+ checkAndDispatchDelayedEvents();
13092
+ } else {
13093
+ window.localStorage.removeItem(TRACKING_CLICK_DELAYED);
13094
+ }
13095
+ };
13096
+ const getLupaTrackingContext = () => {
13097
+ if (!isTrackingEnabled()) {
13098
+ return {};
13099
+ }
13100
+ return {
13101
+ userId: getUserKey(),
13102
+ sessionId: getSessionKey()
13103
+ };
13104
+ };
13105
+ const trackLupaEvent = (queryKey, data = {}, options) => {
13106
+ var _a, _b;
13107
+ if (!queryKey || !data.type) {
13108
+ return;
13109
+ }
13110
+ const eventData = {
13111
+ searchQuery: (_a = data.searchQuery) != null ? _a : "",
13112
+ itemId: (_b = data.itemId) != null ? _b : "",
13113
+ name: data.type,
13114
+ userId: getUserKey(),
13115
+ sessionId: getSessionKey(),
13116
+ filters: data.filters,
13117
+ metadata: data.metadata,
13118
+ sourceItemId: data.sourceItemId
13119
+ };
13120
+ LupaSearchSdk.track(queryKey, eventData, options);
13121
+ };
13122
+ const sendGa = (name, ...args) => {
13123
+ window.ga(() => {
13124
+ const trackers = window.ga.getAll();
13125
+ const firstTracker = trackers[0];
13126
+ if (!firstTracker) {
13127
+ console.error("GA tracker not found");
13128
+ }
13129
+ const trackerName = firstTracker.get("name");
13130
+ window.ga(`${trackerName}.${name}`, ...args);
13131
+ });
13132
+ };
13133
+ const trackAnalyticsEvent = (data) => {
13134
+ var _a, _b, _c;
13135
+ try {
13136
+ const options = JSON.parse(
13137
+ (_a = window.sessionStorage.getItem(TRACKING_ANALYTICS_KEY)) != null ? _a : "{}"
13138
+ );
13139
+ if (!data.analytics || !options.enabled || ((_c = options.ignoreEvents) == null ? void 0 : _c.includes((_b = data.analytics) == null ? void 0 : _b.type))) {
13140
+ return;
13141
+ }
13142
+ switch (options.type) {
13143
+ case "ua":
13144
+ sendUaAnalyticsEvent(data, options);
13145
+ break;
13146
+ case "ga4":
13147
+ sendGa4AnalyticsEvent(data, options);
13148
+ break;
13149
+ case "debug":
13150
+ processDebugEvent(data);
13151
+ break;
13152
+ default:
13153
+ sendUaAnalyticsEvent(data, options);
13154
+ }
13155
+ } catch (e2) {
13156
+ console.error("Unable to send an event to google analytics");
13157
+ }
13158
+ };
13159
+ const parseEcommerceData = (data, title) => {
13160
+ var _a, _b;
13161
+ return ((_a = data.analytics) == null ? void 0 : _a.items) ? {
13162
+ item_list_name: title,
13163
+ items: (_b = data.analytics) == null ? void 0 : _b.items
13164
+ } : void 0;
13165
+ };
13166
+ const sendUaAnalyticsEvent = (data, options) => {
13167
+ var _a, _b, _c, _d;
13168
+ const ga = window.ga;
13169
+ if (!ga) {
13170
+ console.error("Google Analytics object not found");
13171
+ return;
13172
+ }
13173
+ sendGa(
13174
+ "send",
13175
+ "event",
13176
+ options.parentEventName,
13177
+ (_b = (_a = data.analytics) == null ? void 0 : _a.type) != null ? _b : "",
13178
+ (_d = (_c = data.analytics) == null ? void 0 : _c.label) != null ? _d : ""
13179
+ );
13180
+ };
13181
+ const sendGa4AnalyticsEvent = (data, options) => {
13182
+ var _a, _b, _c, _d, _e, _f, _g;
13183
+ if (!window || !window.dataLayer) {
13184
+ console.error("dataLayer object not found.");
13185
+ return;
13186
+ }
13187
+ const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
13188
+ const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
13189
+ const params = __spreadValues2({
13190
+ search_text: data.searchQuery,
13191
+ item_title: title,
13192
+ item_id: data.itemId,
13193
+ ecommerce: parseEcommerceData(data, (_c = data.analytics) == null ? void 0 : _c.listLabel)
13194
+ }, (_e = (_d = data.analytics) == null ? void 0 : _d.additionalParams) != null ? _e : {});
13195
+ window.dataLayer.push(__spreadValues2({
13196
+ event: (_g = (_f = data.analytics) == null ? void 0 : _f.type) != null ? _g : options.parentEventName
13197
+ }, params));
13198
+ };
13199
+ const processDebugEvent = (data) => {
13200
+ var _a, _b, _c, _d;
13201
+ const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
13202
+ const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
13203
+ const params = {
13204
+ event: (_c = data.analytics) == null ? void 0 : _c.type,
13205
+ search_text: data.searchQuery,
13206
+ item_title: title,
13207
+ item_id: data.itemId,
13208
+ ecommerce: parseEcommerceData(data, (_d = data.analytics) == null ? void 0 : _d.listLabel)
13209
+ };
13210
+ console.debug("Analytics debug event:", params);
13211
+ };
13212
+ const getDelayedEventsCache = () => {
13213
+ var _a;
13214
+ try {
13215
+ return JSON.parse((_a = window.localStorage.getItem(DELAYED_TRACKING_EVENTS_CACHE)) != null ? _a : "{}");
13216
+ } catch (e2) {
13217
+ return {};
13218
+ }
13219
+ };
13220
+ const storeDelayedEventCache = (cache) => {
13221
+ try {
13222
+ window.localStorage.setItem(DELAYED_TRACKING_EVENTS_CACHE, JSON.stringify(cache));
13223
+ } catch (e2) {
13224
+ }
13225
+ };
13226
+ const checkAndDispatchDelayedEvents = () => {
13227
+ var _a, _b;
13228
+ const optionsStore = useOptionsStore();
13229
+ const eventCache = getDelayedEventsCache();
13230
+ const urls = Object.keys(eventCache);
13231
+ for (const url of urls) {
13232
+ if ((_a = window.location.href) == null ? void 0 : _a.includes(url)) {
13233
+ const options = (_b = optionsStore.envOptions) != null ? _b : { environment: "production" };
13234
+ const { queryKey, data } = eventCache[url];
13235
+ track(queryKey, data, options);
13236
+ }
13237
+ }
13238
+ storeDelayedEventCache({});
13239
+ };
13240
+ const track = (queryKey, data = {}, options) => {
13241
+ var _a;
13242
+ if (!isTrackingEnabled()) {
13243
+ return;
13244
+ }
13245
+ const hasSearchQuery = data.searchQuery;
13246
+ if (!hasSearchQuery && !((_a = data.options) == null ? void 0 : _a.allowEmptySearchQuery)) {
13247
+ return;
13248
+ }
13249
+ trackAnalyticsEvent(data);
13250
+ trackLupaEvent(queryKey, data, options);
13251
+ };
13252
+ var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
13253
+ DocumentElementType2["IMAGE"] = "image";
13254
+ DocumentElementType2["TITLE"] = "title";
13255
+ DocumentElementType2["CUSTOM"] = "custom";
13256
+ DocumentElementType2["DESCRIPTION"] = "description";
13257
+ DocumentElementType2["PRICE"] = "price";
13258
+ DocumentElementType2["REGULARPRICE"] = "regularPrice";
13259
+ DocumentElementType2["RATING"] = "rating";
13260
+ DocumentElementType2["SINGLE_STAR_RATING"] = "singleStarRating";
13261
+ DocumentElementType2["ADDTOCART"] = "addToCart";
13262
+ DocumentElementType2["CUSTOM_HTML"] = "customHtml";
13263
+ return DocumentElementType2;
13264
+ })(DocumentElementType || {});
13265
+ var SearchBoxPanelType = /* @__PURE__ */ ((SearchBoxPanelType2) => {
13266
+ SearchBoxPanelType2["SUGGESTION"] = "suggestion";
13267
+ SearchBoxPanelType2["DOCUMENT"] = "document";
13268
+ SearchBoxPanelType2["RELATED_SOURCE"] = "related-source";
13269
+ return SearchBoxPanelType2;
13270
+ })(SearchBoxPanelType || {});
13271
+ var BadgeType = /* @__PURE__ */ ((BadgeType2) => {
13272
+ BadgeType2["NEWITEM"] = "newItem";
13273
+ BadgeType2["TEXT"] = "text";
13274
+ BadgeType2["IMAGE"] = "image";
13275
+ BadgeType2["CUSTOM_HTML"] = "customHtml";
13276
+ BadgeType2["DISCOUNT"] = "discount";
13277
+ return BadgeType2;
13278
+ })(BadgeType || {});
13279
+ const retrieveHistory = () => {
13280
+ try {
13281
+ const historyString = window.localStorage.getItem(HISTORY_LOCAL_STORAGE_KEY);
13282
+ return historyString ? JSON.parse(historyString) : [];
13283
+ } catch (e2) {
13284
+ return [];
13285
+ }
13286
+ };
13287
+ const saveHistory = (items) => {
13288
+ try {
13289
+ window.localStorage.setItem(
13290
+ HISTORY_LOCAL_STORAGE_KEY,
13291
+ JSON.stringify(items.slice(0, HISTORY_MAX_ITEMS))
13292
+ );
13293
+ } catch (e2) {
13294
+ }
13295
+ };
13296
+ const useHistoryStore = defineStore("history", () => {
13297
+ const items = ref(retrieveHistory());
13298
+ const count = computed(() => items.value.length);
13299
+ const add2 = ({ item }) => {
13300
+ if (!item) {
13301
+ return items.value;
13302
+ }
13303
+ const newItems = items.value ? [item, ...items.value] : [item];
13304
+ const uniqueItems = Array.from(new Set(newItems));
13305
+ items.value = uniqueItems;
13306
+ saveHistory(uniqueItems);
13307
+ return uniqueItems;
13308
+ };
13309
+ const remove2 = ({ item }) => {
13310
+ var _a, _b;
13311
+ const tempItems = (_b = (_a = items.value) == null ? void 0 : _a.filter((i) => i !== item)) != null ? _b : [];
13312
+ saveHistory(tempItems);
13313
+ items.value = tempItems;
13314
+ return tempItems;
13315
+ };
13316
+ const clear2 = () => {
13317
+ saveHistory([]);
13318
+ items.value = [];
13319
+ };
13320
+ return { items, count, add: add2, remove: remove2, clear: clear2 };
13321
+ });
13322
+ const QUERY_PARAMS$1 = {
13323
+ QUERY: "q",
13324
+ PAGE: "p",
13325
+ LIMIT: "l",
13326
+ SORT: "s"
13327
+ };
13328
+ const QUERY_PARAMS_PARSED = {
13329
+ QUERY: "query",
13330
+ PAGE: "page",
13331
+ LIMIT: "limit",
13332
+ SORT: "sort"
13333
+ };
13334
+ const FACET_PARAMS_TYPE = {
13335
+ TERMS: "f.",
13336
+ RANGE: "fr.",
13337
+ HIERARCHY: "fh."
13338
+ };
13339
+ const FACET_FILTER_MAP = {
13340
+ terms: FACET_PARAMS_TYPE.TERMS,
13341
+ range: FACET_PARAMS_TYPE.RANGE,
13342
+ hierarchy: FACET_PARAMS_TYPE.HIERARCHY
13343
+ };
13344
+ const FACET_KEY_SEPARATOR = ".";
13345
+ const FACET_RANGE_SEPARATOR = ":";
13346
+ const HIERARCHY_SEPARATOR = ">";
13347
+ const FACET_TERM_RANGE_SEPARATOR = "-";
13348
+ const getAmount = (price, separator = ".") => {
13349
+ var _a, _b;
13350
+ if (typeof price === "number") {
13351
+ return `${(_a = price.toFixed(2)) == null ? void 0 : _a.replace(".", separator)}`;
13352
+ }
13353
+ const value = parseFloat(price);
13354
+ if (isNaN(value)) {
13355
+ return "";
13356
+ }
13357
+ return (_b = value.toFixed(2)) == null ? void 0 : _b.replace(".", separator);
13358
+ };
13359
+ const formatPrice = (price, currency = "€", separator = ",", currencyTemplate = "") => {
13360
+ if (price !== 0 && !price) {
13361
+ return "";
13362
+ }
13363
+ const amount = getAmount(price, separator);
13364
+ if (!amount) {
13365
+ return "";
13366
+ }
13367
+ if (currencyTemplate) {
13368
+ return addParamsToLabel(currencyTemplate, amount);
13369
+ }
13370
+ return `${amount} ${currency}`;
13371
+ };
13372
+ const formatPriceSummary = ([min, max], currency, separator = ",", currencyTemplate = "") => {
13373
+ if (min !== void 0 && max !== void 0) {
13374
+ return `${formatPrice(min, currency, separator, currencyTemplate)} - ${formatPrice(
13375
+ max,
13376
+ currency,
13377
+ separator,
13378
+ currencyTemplate
13379
+ )}`;
13380
+ }
13381
+ if (min !== void 0) {
13382
+ return `> ${formatPrice(min, currency, separator, currencyTemplate)}`;
13383
+ }
13384
+ return `< ${formatPrice(max, currency, separator, currencyTemplate)}`;
13385
+ };
13386
+ const getTranslatedFacetKey = (facet, translations) => {
13387
+ var _a, _b;
13388
+ return (_b = (_a = translations == null ? void 0 : translations.keyTranslations) == null ? void 0 : _a[facet.key]) != null ? _b : facet.label;
13389
+ };
13390
+ const getTranslatedFacetValue = (facet, value, translations) => {
13391
+ var _a, _b, _c;
13392
+ 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;
13393
+ };
13394
+ const formatRange = (filter2) => {
13395
+ var _a, _b;
13396
+ const lt = (_a = filter2.lt) != null ? _a : filter2.lte;
13397
+ const gt = (_b = filter2.gt) != null ? _b : filter2.gte;
13398
+ if (gt !== void 0 && lt !== void 0) {
13399
+ return `${gt} - ${lt}`;
13400
+ }
13401
+ if (lt !== void 0) {
13402
+ return `<${filter2.lte !== void 0 ? "=" : ""} ${lt}`;
13403
+ }
13404
+ return `>${filter2.gte !== void 0 ? "=" : ""} ${gt}`;
13405
+ };
13406
+ const unfoldTermFilter = (key, filter2) => {
13407
+ const seed = [];
13408
+ return filter2.reduce((a, c2) => [...a, { key, value: c2, type: "terms" }], seed);
13409
+ };
13410
+ const unfoldHierarchyFilter = (key, filter2) => {
13411
+ const seed = [];
13412
+ return filter2.terms.reduce((a, c2) => [...a, { key, value: c2, type: "hierarchy" }], seed);
13413
+ };
13414
+ const unfoldRangeFilter = (key, filter2, price = {}) => {
13415
+ var _a;
13416
+ const gt = filter2.gte || filter2.gt;
13417
+ const lt = filter2.lte || filter2.lt;
13418
+ if (key.includes(CURRENCY_KEY_INDICATOR) || ((_a = price == null ? void 0 : price.keys) == null ? void 0 : _a.includes(key))) {
13419
+ return [
13420
+ {
13421
+ key,
13422
+ value: formatPriceSummary(
13423
+ [gt, lt],
13424
+ price.currency,
13425
+ price.separator,
13426
+ price.currencyTemplate
13427
+ ),
13428
+ type: "range"
13429
+ }
13430
+ ];
13431
+ }
13432
+ return [{ key, value: `${gt} - ${lt}`, type: "range" }];
13433
+ };
13434
+ const unfoldFilter = (key, filter2, price = {}) => {
13435
+ if (Array.isArray(filter2)) {
13436
+ return unfoldTermFilter(key, filter2);
13437
+ }
13438
+ if (filter2.gte) {
13439
+ return unfoldRangeFilter(key, filter2, price);
13440
+ }
13441
+ if (filter2.terms) {
13442
+ return unfoldHierarchyFilter(key, filter2);
13443
+ }
13444
+ return [];
13445
+ };
13446
+ const unfoldFilters = (filters, price = {}) => {
13447
+ if (!filters) {
13448
+ return [];
13449
+ }
13450
+ const seed = [];
13451
+ return Object.entries(filters).reduce((a, c2) => [...a, ...unfoldFilter(...c2, price)], seed);
13452
+ };
13453
+ const getLabeledFilters = (filters, facets2, translations) => {
13454
+ return filters.map((f2) => {
13455
+ var _a, _b, _c, _d;
13456
+ return __spreadProps2(__spreadValues2({}, f2), {
13457
+ 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),
13458
+ value: getTranslatedFacetValue({ key: f2.key }, { title: f2.value }, translations)
13459
+ });
13460
+ });
13461
+ };
13462
+ const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY);
13463
+ const getMostSpecificHierarchyTerms = (terms) => {
13464
+ const specificTerms = [];
13465
+ for (const term of terms) {
13466
+ if (!terms.some((t) => t.startsWith(term) && t !== term)) {
13467
+ specificTerms.push(term);
13468
+ }
13469
+ }
13470
+ return Array.from(new Set(specificTerms));
13471
+ };
13472
+ const recursiveFilter = (items, query = "") => {
13473
+ if (!query) {
13474
+ return items;
13475
+ }
13476
+ return items.map((i) => recursiveFilterItem(i, query)).filter(Boolean);
13477
+ };
13478
+ const recursiveFilterItem = (item, query = "") => {
13479
+ const filterable = getNormalizedString(item.title).includes(getNormalizedString(query)) ? item : void 0;
13480
+ if (!item.children) {
13481
+ return filterable;
13482
+ }
13483
+ const children = recursiveFilter(item.children, query).filter(Boolean);
13484
+ const include = children.length > 0 || filterable;
13485
+ return include ? __spreadProps2(__spreadValues2({}, item), {
13486
+ children
13487
+ }) : void 0;
13488
+ };
13489
+ const rangeFilterToString = (rangeFilter, separator) => {
13490
+ separator = separator || FACET_TERM_RANGE_SEPARATOR;
13491
+ return rangeFilter && Object.keys(rangeFilter).length ? rangeFilter.gte + separator + (rangeFilter.lte || rangeFilter.lt) : "";
13492
+ };
13493
+ const pick = (obj, keys) => {
13494
+ const ret = /* @__PURE__ */ Object.create({});
13495
+ for (const k of keys) {
13496
+ ret[k] = obj[k];
13497
+ }
13498
+ return ret;
13499
+ };
13500
+ const getHint = (suggestion, inputValue) => {
13501
+ var _a;
13502
+ if (!inputValue) {
13503
+ return escapeHtml$1(suggestion);
13504
+ }
13505
+ return (_a = suggestion == null ? void 0 : suggestion.replace(
13506
+ inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
13507
+ `<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
13508
+ )) != null ? _a : "";
13509
+ };
13510
+ const reverseKeyValue = (obj) => {
13511
+ return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
13512
+ };
13513
+ const getPageCount = (total, limit) => {
13514
+ return Math.ceil(total / limit) || 0;
13515
+ };
13516
+ const isObject$1 = (value) => {
13517
+ return value !== null && typeof value === "object" && !Array.isArray(value);
13518
+ };
13519
+ const parseParam = (key, params) => {
13520
+ const value = params.get(key);
13521
+ if (!value) {
13522
+ return void 0;
13523
+ }
13524
+ try {
13525
+ return decodeURIComponent(value);
13526
+ } catch (e2) {
13527
+ return void 0;
13528
+ }
13529
+ };
13530
+ const parseRegularKeys = (regularKeys, searchParams, getQueryParamName) => {
13531
+ const params = /* @__PURE__ */ Object.create({});
13532
+ const keys = reverseKeyValue({
13533
+ QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
13534
+ LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
13535
+ PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
13536
+ SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
13537
+ });
13538
+ for (const key of regularKeys) {
13539
+ const rawKey = keys[key] || key;
13540
+ params[rawKey] = parseParam(key, searchParams);
13541
+ }
13542
+ return params;
13543
+ };
13544
+ const parseFacetKey = (key, searchParams) => {
13545
+ var _a, _b, _c, _d;
13546
+ if (key.startsWith(FACET_PARAMS_TYPE.TERMS)) {
13547
+ return (_b = (_a = searchParams.getAll(key)) == null ? void 0 : _a.map((v) => decodeURIComponent(v))) != null ? _b : [];
13548
+ }
13549
+ if (key.startsWith(FACET_PARAMS_TYPE.RANGE)) {
13550
+ const range = searchParams.get(key);
13551
+ if (!range) {
13552
+ return {};
13553
+ }
13554
+ const [min, max] = range.split(FACET_RANGE_SEPARATOR);
13555
+ return {
13556
+ gte: min,
13557
+ lte: max
13558
+ };
13559
+ }
13560
+ if (key.startsWith(FACET_PARAMS_TYPE.HIERARCHY)) {
13561
+ return {
13562
+ level: 0,
13563
+ terms: (_d = (_c = searchParams.getAll(key)) == null ? void 0 : _c.map((v) => decodeURIComponent(v))) != null ? _d : []
13564
+ };
13565
+ }
13566
+ return [];
13567
+ };
13568
+ const parseFacetKeys = (facetKeys, searchParams) => {
13569
+ const params = {};
13570
+ params.filters = {};
13571
+ for (const key of facetKeys) {
13572
+ const parsedKey = key.slice(key.indexOf(FACET_KEY_SEPARATOR) + 1);
13573
+ params.filters = __spreadProps2(__spreadValues2({}, params.filters), {
13574
+ [parsedKey]: parseFacetKey(key, searchParams)
13575
+ });
13576
+ }
13577
+ return params;
13578
+ };
13579
+ const parseParams = (getQueryParamName, searchParams) => {
13580
+ const params = /* @__PURE__ */ Object.create({});
13581
+ if (!searchParams)
13582
+ return params;
13583
+ const paramKeys = Array.from(searchParams.keys());
13584
+ const facetKeys = paramKeys.filter((k) => isFacetKey(k));
13585
+ const regularKeys = paramKeys.filter((k) => !isFacetKey(k));
13586
+ const r = __spreadValues2(__spreadValues2({
13587
+ [QUERY_PARAMS_PARSED.QUERY]: ""
13588
+ }, parseRegularKeys(regularKeys, searchParams, getQueryParamName)), parseFacetKeys(facetKeys, searchParams));
13589
+ return r;
13590
+ };
13591
+ const appendParam = (url, { name, value }, encode2 = true) => {
13592
+ if (Array.isArray(value)) {
13593
+ appendArrayParams(url, { name, value });
13594
+ } else {
13595
+ appendSingleParam(url, { name, value }, encode2);
13596
+ }
13597
+ };
13598
+ const appendSingleParam = (url, param, encode2 = true) => {
13599
+ const valueToAppend = encode2 ? encodeParam(param.value) : param.value;
13600
+ if (url.searchParams.has(param.name)) {
13601
+ url.searchParams.set(param.name, valueToAppend);
13602
+ } else {
13603
+ url.searchParams.append(param.name, valueToAppend);
13604
+ }
13605
+ };
13606
+ const appendArrayParams = (url, param) => {
13607
+ url.searchParams.delete(param.name);
13608
+ param.value.forEach((v) => url.searchParams.append(param.name, encodeParam(v)));
13609
+ };
13610
+ const getRemovableParams = (url, getQueryParamName, paramsToRemove) => {
13611
+ if (paramsToRemove === "all") {
13612
+ const params = {
13613
+ QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
13614
+ LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
13615
+ PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
13616
+ SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
13617
+ };
13618
+ return [
13619
+ ...Object.values(params),
13620
+ ...Array.from(url.searchParams.keys()).filter((k) => isFacetKey(k))
13621
+ ];
13622
+ }
13623
+ return paramsToRemove;
13624
+ };
13625
+ const removeParams = (url, params = []) => {
13626
+ for (const param of params) {
13627
+ if (url.searchParams.has(param)) {
13628
+ url.searchParams.delete(param);
13629
+ }
13630
+ }
13631
+ };
13632
+ const encodeParam = (param) => {
13633
+ const encoded = encodeURIComponent(param);
13634
+ return encoded.replace(/%C4%85/g, "ą").replace(/%C4%8D/g, "č").replace(/%C4%99/g, "ę").replace(/%C4%97/g, "ė").replace(/%C4%AF/g, "į").replace(/%C5%A1/g, "š").replace(/%C5%B3/g, "ų").replace(/%C5%AB/g, "ū").replace(/%C5%BE/g, "ž").replace(/%20/g, " ");
13635
+ };
13636
+ const getQueryParam$1 = (name) => {
13637
+ try {
13638
+ const urlParams = new URLSearchParams(window.location.search);
13639
+ return urlParams.get(name);
13640
+ } catch (e2) {
13641
+ return null;
13642
+ }
13643
+ };
13644
+ const PATH_REPLACE_REGEXP = /{(.*?)}/gm;
13645
+ const generateLink = (linkPattern, document2) => {
13646
+ const matches = linkPattern.match(PATH_REPLACE_REGEXP);
13647
+ if (!matches) {
13648
+ return linkPattern;
13649
+ }
13650
+ let link = linkPattern;
13651
+ for (const match of matches) {
13652
+ const propertyKey = match.slice(1, match.length - 1);
13653
+ const property = document2[propertyKey] || "";
13654
+ link = link.replace(match, property);
13655
+ }
13656
+ return link;
13657
+ };
13658
+ const generateResultLink = (link, getQueryParamName, searchText, facet) => {
13659
+ if (!searchText) {
13660
+ return link;
13661
+ }
13662
+ const facetParam = facet ? `&${FACET_PARAMS_TYPE.TERMS}${encodeParam(facet.key)}=${encodeParam(facet.title)}` : "";
13663
+ const queryParam = `?${getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY}=${encodeParam(searchText)}`;
13664
+ return `${link}${queryParam}${facetParam}`;
13665
+ };
13666
+ const getRelativePath = (link) => {
13667
+ try {
13668
+ const url = new URL(link);
13669
+ const partialUrl = url.toString().substring(url.origin.length);
13670
+ return partialUrl.endsWith("/") ? partialUrl.slice(0, partialUrl.length - 1) : partialUrl;
13671
+ } catch (e2) {
13672
+ return (link == null ? void 0 : link.endsWith("/")) ? link.slice(0, link.length - 1) : link;
13673
+ }
13674
+ };
13675
+ const linksMatch = (link1, link2) => {
13676
+ if (!link1 || !link2) {
13677
+ return false;
13678
+ }
13679
+ return link1 === link2 || getRelativePath(link1) === getRelativePath(link2);
13680
+ };
13681
+ const emitRoutingEvent = (url) => {
13682
+ const event = new CustomEvent(LUPA_ROUTING_EVENT, { detail: url });
13683
+ window.dispatchEvent(event);
13684
+ };
13685
+ const handleRoutingEvent = (link, event, hasEventRouting = false) => {
13686
+ if (!hasEventRouting) {
13687
+ return;
13688
+ }
13689
+ event == null ? void 0 : event.preventDefault();
13690
+ emitRoutingEvent(link);
13691
+ };
13692
+ const redirectToResultsPage = (link, searchText, getQueryParamName, facet, routingBehavior = "direct-link") => {
13693
+ const url = generateResultLink(link, getQueryParamName, searchText, facet);
13694
+ if (routingBehavior === "event") {
13695
+ emitRoutingEvent(url);
13696
+ } else {
13697
+ window.location.assign(url);
13698
+ }
13699
+ };
13700
+ const getPageUrl = (pathnameOverride, ssr) => {
13701
+ if (typeof window !== "undefined") {
13702
+ const pathname = pathnameOverride || window.location.pathname;
13703
+ const origin = window.location.origin;
13704
+ const search2 = window.location.search;
13705
+ return new URL(origin + pathname + search2);
13706
+ }
13707
+ return new URL(ssr.url, ssr.baseUrl);
13708
+ };
13709
+ const getFacetKey = (key, type) => {
13710
+ return `${FACET_FILTER_MAP[type]}${key}`;
13711
+ };
13712
+ const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
13713
+ return {
13714
+ name: `${type}${key}`,
13715
+ value
13716
+ };
13717
+ };
13718
+ const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters, paramsToRemove = []) => {
13719
+ const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
13720
+ const newParams = toggleTermParam(currentFilter, facetAction.value);
13721
+ appendParams({
13722
+ params: [getFacetParam(facetAction.key, newParams)],
13723
+ paramsToRemove: [
13724
+ ...paramsToRemove,
13725
+ ...[getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
13726
+ ]
13727
+ });
13728
+ };
13729
+ const replaceHierarchyParam = (params = [], param = "") => {
13730
+ if (params.some((p2) => p2.startsWith(param))) {
13731
+ return toggleLastPram(params, param);
13732
+ }
13733
+ return [param];
13734
+ };
13735
+ const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
13736
+ var _a, _b;
13737
+ const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
13738
+ const newParams = facetAction.behavior === "replace" ? replaceHierarchyParam((_a = currentFilter == null ? void 0 : currentFilter.terms) != null ? _a : [], facetAction.value) : toggleHierarchyParam((_b = currentFilter == null ? void 0 : currentFilter.terms) != null ? _b : [], facetAction.value, removeAllLevels);
13739
+ appendParams({
13740
+ params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
13741
+ paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
13742
+ });
13743
+ };
13744
+ const toggleRangeFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
13745
+ const currentFilter = rangeFilterToString(
13746
+ currentFilters == null ? void 0 : currentFilters[facetAction.key],
13747
+ FACET_RANGE_SEPARATOR
13748
+ );
13749
+ let facetValue = facetAction.value.join(FACET_RANGE_SEPARATOR);
13750
+ facetValue = currentFilter === facetValue ? "" : facetValue;
13751
+ appendParams({
13752
+ params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
13753
+ paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE],
13754
+ encode: false
13755
+ });
13756
+ };
13757
+ const toggleTermParam = (params = [], param = "") => {
13758
+ if (params == null ? void 0 : params.includes(param)) {
13759
+ return params.filter((p2) => p2 !== param);
13760
+ }
13761
+ return [param, ...params];
13762
+ };
13763
+ const toggleLastPram = (params = [], param = "") => {
13764
+ const paramLevel = param.split(">").length;
13765
+ return getMostSpecificHierarchyTerms(
13766
+ params.map(
13767
+ (p2) => p2.startsWith(param) ? p2.split(HIERARCHY_SEPARATOR).slice(0, paramLevel - 1).join(HIERARCHY_SEPARATOR).trim() : p2
13768
+ ).filter(Boolean)
13769
+ );
13770
+ };
13771
+ const toggleHierarchyParam = (params = [], param = "", removeAllLevels = false) => {
13772
+ if (params == null ? void 0 : params.some((p2) => p2.startsWith(param))) {
13773
+ return removeAllLevels ? getMostSpecificHierarchyTerms(params.filter((p2) => !p2.startsWith(param))) : toggleLastPram(params, param);
13774
+ }
13775
+ return getMostSpecificHierarchyTerms([param, ...params]);
13776
+ };
13777
+ const CACHE_KEY = "lupasearch-client-redirections";
13778
+ const useRedirectionStore = defineStore("redirections", () => {
13779
+ const redirections = ref({ rules: [] });
13780
+ const redirectionOptions = ref({ enabled: false, queryKey: "" });
13781
+ const saveToLocalStorage2 = () => {
13782
+ try {
13783
+ localStorage.setItem(
13784
+ CACHE_KEY,
13785
+ JSON.stringify({
13786
+ redirections: redirections.value,
13787
+ savedAt: Date.now(),
13788
+ queryKey: redirectionOptions.value.queryKey
13789
+ })
13790
+ );
13791
+ } catch (e2) {
13792
+ }
13793
+ };
13794
+ const tryLoadFromLocalStorage2 = (config) => {
13795
+ var _a;
13796
+ if (!config.cacheSeconds)
13797
+ return false;
13798
+ try {
13799
+ const data = JSON.parse((_a = localStorage.getItem(CACHE_KEY)) != null ? _a : "");
13800
+ if (data.queryKey !== config.queryKey) {
13801
+ return false;
13802
+ }
13803
+ if ((data == null ? void 0 : data.redirections) && Date.now() - data.savedAt < 1e3 * config.cacheSeconds) {
13804
+ redirections.value = data.redirections;
13805
+ return true;
13806
+ }
13807
+ } catch (e2) {
13808
+ }
13809
+ return false;
13810
+ };
13811
+ const initiate = (config, options) => __async2(void 0, null, function* () {
13812
+ var _a, _b, _c, _d;
13813
+ if ((_a = redirectionOptions.value) == null ? void 0 : _a.enabled) {
13814
+ return;
13815
+ }
13816
+ redirectionOptions.value = config;
13817
+ if (!(config == null ? void 0 : config.enabled)) {
13818
+ return;
13819
+ }
13820
+ const loaded = tryLoadFromLocalStorage2(config);
13821
+ if (loaded || ((_c = (_b = redirections.value) == null ? void 0 : _b.rules) == null ? void 0 : _c.length) > 0) {
13822
+ return;
13823
+ }
13824
+ try {
13825
+ const result2 = yield LupaSearchSdk.loadRedirectionRules(config.queryKey, options);
13826
+ if (!((_d = result2 == null ? void 0 : result2.rules) == null ? void 0 : _d.length)) {
13827
+ redirections.value = { rules: [] };
13828
+ return;
13829
+ }
13830
+ redirections.value = result2;
13831
+ saveToLocalStorage2();
13832
+ } catch (e2) {
13833
+ }
13834
+ });
13835
+ const redirectOnKeywordIfConfigured = (input2, routingBehavior = "direct-link") => {
13836
+ var _a, _b, _c, _d;
13837
+ if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
13838
+ return false;
13839
+ }
13840
+ const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input2, r.sources));
13841
+ if (!redirectTo) {
13842
+ return false;
13843
+ }
13844
+ const url = ((_c = redirectionOptions.value) == null ? void 0 : _c.urlTransformer) ? (_d = redirectionOptions.value) == null ? void 0 : _d.urlTransformer(redirectTo == null ? void 0 : redirectTo.target) : redirectTo == null ? void 0 : redirectTo.target;
13845
+ if (url === void 0 || url === null || url === "") {
13846
+ return false;
13847
+ }
13848
+ if (routingBehavior === "event") {
13849
+ emitRoutingEvent(url);
13848
13850
  } else {
13849
- root2._ = _;
13851
+ window.location.assign(url);
13850
13852
  }
13851
- }).call(commonjsGlobal$1);
13852
- })(lodash$1, lodash$1.exports);
13853
- var lodashExports$1 = lodash$1.exports;
13853
+ return true;
13854
+ };
13855
+ return {
13856
+ redirections,
13857
+ redirectOnKeywordIfConfigured,
13858
+ initiate
13859
+ };
13860
+ });
13854
13861
  const joinUrlParts = (...parts) => {
13855
13862
  var _a, _b, _c;
13856
13863
  if (parts.length === 1) {
@@ -14289,7 +14296,7 @@ const _hoisted_1$1i = { id: "lupa-search-box-input-container" };
14289
14296
  const _hoisted_2$T = { class: "lupa-input-clear" };
14290
14297
  const _hoisted_3$C = { id: "lupa-search-box-input" };
14291
14298
  const _hoisted_4$s = ["value"];
14292
- const _hoisted_5$j = ["aria-label", "placeholder"];
14299
+ const _hoisted_5$i = ["aria-label", "placeholder"];
14293
14300
  const _hoisted_6$9 = /* @__PURE__ */ createBaseVNode("span", { class: "lupa-search-submit-icon" }, null, -1);
14294
14301
  const _hoisted_7$7 = [
14295
14302
  _hoisted_6$9
@@ -14409,7 +14416,7 @@ const _sfc_main$1v = /* @__PURE__ */ defineComponent({
14409
14416
  placeholder: labels.value.placeholder,
14410
14417
  onInput: handleInput,
14411
14418
  onFocus: handleFocus
14412
- }), null, 16, _hoisted_5$j), [
14419
+ }), null, 16, _hoisted_5$i), [
14413
14420
  [vModelText, inputValue.value]
14414
14421
  ]),
14415
14422
  _ctx.options.showSubmitButton ? (openBlock(), createElementBlock("button", {
@@ -14625,7 +14632,7 @@ const _hoisted_4$r = {
14625
14632
  class: "lupa-suggestion-facet-label",
14626
14633
  "data-cy": "lupa-suggestion-facet-label"
14627
14634
  };
14628
- const _hoisted_5$i = {
14635
+ const _hoisted_5$h = {
14629
14636
  class: "lupa-suggestion-facet-value",
14630
14637
  "data-cy": "lupa-suggestion-facet-value"
14631
14638
  };
@@ -14668,7 +14675,7 @@ const _sfc_main$1q = /* @__PURE__ */ defineComponent({
14668
14675
  }, null, 8, _hoisted_1$1e)) : (openBlock(), createElementBlock("div", _hoisted_2$R, toDisplayString(_ctx.suggestion.display), 1)),
14669
14676
  _ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$B, [
14670
14677
  createBaseVNode("span", _hoisted_4$r, toDisplayString(facetLabel.value), 1),
14671
- createBaseVNode("span", _hoisted_5$i, toDisplayString(_ctx.suggestion.facet.title), 1)
14678
+ createBaseVNode("span", _hoisted_5$h, toDisplayString(_ctx.suggestion.facet.title), 1)
14672
14679
  ])) : createCommentVNode("", true)
14673
14680
  ]);
14674
14681
  };
@@ -24162,7 +24169,7 @@ const _hoisted_1$18 = ["innerHTML"];
24162
24169
  const _hoisted_2$N = { key: 0 };
24163
24170
  const _hoisted_3$A = { key: 1 };
24164
24171
  const _hoisted_4$q = { class: "lupa-search-box-custom-label" };
24165
- const _hoisted_5$h = { class: "lupa-search-box-custom-text" };
24172
+ const _hoisted_5$g = { class: "lupa-search-box-custom-text" };
24166
24173
  const _sfc_main$1h = /* @__PURE__ */ defineComponent({
24167
24174
  __name: "SearchBoxProductCustom",
24168
24175
  props: {
@@ -24195,7 +24202,7 @@ const _sfc_main$1h = /* @__PURE__ */ defineComponent({
24195
24202
  }, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
24196
24203
  !label.value ? (openBlock(), createElementBlock("div", _hoisted_2$N, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$A, [
24197
24204
  createBaseVNode("div", _hoisted_4$q, toDisplayString(label.value), 1),
24198
- createBaseVNode("div", _hoisted_5$h, toDisplayString(text.value), 1)
24205
+ createBaseVNode("div", _hoisted_5$g, toDisplayString(text.value), 1)
24199
24206
  ]))
24200
24207
  ], 16));
24201
24208
  };
@@ -25615,7 +25622,7 @@ const _hoisted_4$o = {
25615
25622
  key: 1,
25616
25623
  class: "lupa-panel-title"
25617
25624
  };
25618
- const _hoisted_5$g = {
25625
+ const _hoisted_5$f = {
25619
25626
  key: 1,
25620
25627
  id: "lupa-search-box-panel"
25621
25628
  };
@@ -25839,7 +25846,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
25839
25846
  options: _ctx.options,
25840
25847
  onGoToResults: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("go-to-results"))
25841
25848
  }, null, 8, ["labels", "options"])) : createCommentVNode("", true)
25842
- ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$g, [
25849
+ ])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$f, [
25843
25850
  createVNode(_sfc_main$1s, {
25844
25851
  options: _ctx.options.history,
25845
25852
  history: history.value,
@@ -26404,7 +26411,7 @@ const _hoisted_3$u = {
26404
26411
  class: "lupa-results-total-count"
26405
26412
  };
26406
26413
  const _hoisted_4$m = { class: "lupa-results-total-count-number" };
26407
- const _hoisted_5$f = ["innerHTML"];
26414
+ const _hoisted_5$e = ["innerHTML"];
26408
26415
  const _sfc_main$Z = /* @__PURE__ */ defineComponent({
26409
26416
  __name: "SearchResultsTitle",
26410
26417
  props: {
@@ -26465,7 +26472,7 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
26465
26472
  key: 2,
26466
26473
  class: "lupa-result-page-description-top",
26467
26474
  innerHTML: descriptionTop.value
26468
- }, null, 8, _hoisted_5$f)) : createCommentVNode("", true)
26475
+ }, null, 8, _hoisted_5$e)) : createCommentVNode("", true)
26469
26476
  ]);
26470
26477
  };
26471
26478
  }
@@ -26668,7 +26675,7 @@ const _hoisted_1$P = {
26668
26675
  const _hoisted_2$B = { class: "lupa-category-back" };
26669
26676
  const _hoisted_3$s = ["href"];
26670
26677
  const _hoisted_4$k = ["href"];
26671
- const _hoisted_5$e = { class: "lupa-child-category-list" };
26678
+ const _hoisted_5$d = { class: "lupa-child-category-list" };
26672
26679
  const _sfc_main$V = /* @__PURE__ */ defineComponent({
26673
26680
  __name: "CategoryFilter",
26674
26681
  props: {
@@ -26776,7 +26783,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
26776
26783
  onClick: handleNavigationParent
26777
26784
  }, toDisplayString(parentTitle.value), 11, _hoisted_4$k)
26778
26785
  ], 2),
26779
- createBaseVNode("div", _hoisted_5$e, [
26786
+ createBaseVNode("div", _hoisted_5$d, [
26780
26787
  (openBlock(true), createElementBlock(Fragment, null, renderList(categoryChildren.value, (child) => {
26781
26788
  return openBlock(), createBlock(_sfc_main$W, {
26782
26789
  key: getCategoryKey(child),
@@ -26796,15 +26803,14 @@ const _hoisted_1$O = {
26796
26803
  const _hoisted_2$A = ["placeholder"];
26797
26804
  const _hoisted_3$r = { class: "lupa-terms-list" };
26798
26805
  const _hoisted_4$j = ["onClick"];
26799
- const _hoisted_5$d = { class: "lupa-term-checkbox-wrapper" };
26800
- const _hoisted_6$8 = { class: "lupa-term-checkbox-label" };
26801
- const _hoisted_7$6 = { class: "lupa-term-label" };
26802
- const _hoisted_8$2 = {
26806
+ const _hoisted_5$c = { class: "lupa-term-checkbox-wrapper" };
26807
+ const _hoisted_6$8 = { class: "lupa-term-label" };
26808
+ const _hoisted_7$6 = {
26803
26809
  key: 0,
26804
26810
  class: "lupa-term-count"
26805
26811
  };
26806
- const _hoisted_9$2 = { key: 0 };
26807
- const _hoisted_10$1 = { key: 1 };
26812
+ const _hoisted_8$2 = { key: 0 };
26813
+ const _hoisted_9$2 = { key: 1 };
26808
26814
  const _sfc_main$U = /* @__PURE__ */ defineComponent({
26809
26815
  __name: "TermFacet",
26810
26816
  props: {
@@ -26836,7 +26842,12 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
26836
26842
  return searchResultStore.filterVisibleFilterValues(facet.value.key, (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : []);
26837
26843
  });
26838
26844
  const displayValues = computed(() => {
26839
- return filteredValues.value.slice(0, itemLimit.value).map((v) => __spreadProps2(__spreadValues2({}, v), { title: getDisplayValue(v.title) }));
26845
+ return filteredValues.value.slice(0, itemLimit.value).filter(
26846
+ (v) => {
26847
+ var _a, _b, _c;
26848
+ return ((_a = props.options.excludeValues) == null ? void 0 : _a[facet.value.key]) ? !((_c = (_b = props.options.excludeValues) == null ? void 0 : _b[facet.value.key]) == null ? void 0 : _c[v.title]) : true;
26849
+ }
26850
+ ).map((v) => __spreadProps2(__spreadValues2({}, v), { title: getDisplayValue(v.title) }));
26840
26851
  });
26841
26852
  const filteredValues = computed(() => {
26842
26853
  var _a, _b;
@@ -26881,6 +26892,13 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
26881
26892
  var _a;
26882
26893
  return getTranslatedFacetValue(props.facet, item, (_a = searchResultOptions.value.filters) == null ? void 0 : _a.translations);
26883
26894
  };
26895
+ const getFacetValueClass = (item) => {
26896
+ try {
26897
+ return `lupa-facet-value-${slugifyClass(item.title)}`;
26898
+ } catch (e2) {
26899
+ return "";
26900
+ }
26901
+ };
26884
26902
  return (_ctx, _cache) => {
26885
26903
  return openBlock(), createElementBlock("div", _hoisted_1$O, [
26886
26904
  isFilterable.value ? withDirectives((openBlock(), createElementBlock("input", {
@@ -26900,15 +26918,17 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
26900
26918
  key: item.title,
26901
26919
  onClick: ($event) => handleFacetClick(item)
26902
26920
  }, [
26903
- createBaseVNode("div", _hoisted_5$d, [
26921
+ createBaseVNode("div", _hoisted_5$c, [
26904
26922
  createBaseVNode("span", {
26905
26923
  class: normalizeClass(["lupa-term-checkbox", { checked: isChecked(item) }])
26906
26924
  }, null, 2)
26907
26925
  ]),
26908
- createBaseVNode("div", _hoisted_6$8, [
26909
- createBaseVNode("span", _hoisted_7$6, toDisplayString(getItemLabel(item)), 1),
26910
- _ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_8$2, "(" + toDisplayString(item.count) + ")", 1)) : createCommentVNode("", true)
26911
- ])
26926
+ createBaseVNode("div", {
26927
+ class: normalizeClass(["lupa-term-checkbox-label", { [getFacetValueClass(item)]: true }])
26928
+ }, [
26929
+ createBaseVNode("span", _hoisted_6$8, toDisplayString(getItemLabel(item)), 1),
26930
+ _ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_7$6, "(" + toDisplayString(item.count) + ")", 1)) : createCommentVNode("", true)
26931
+ ], 2)
26912
26932
  ], 10, _hoisted_4$j);
26913
26933
  }), 128))
26914
26934
  ]),
@@ -26918,7 +26938,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
26918
26938
  "data-cy": "lupa-facet-term",
26919
26939
  onClick: toggleShowAll
26920
26940
  }, [
26921
- showAll.value ? (openBlock(), createElementBlock("span", _hoisted_9$2, toDisplayString(_ctx.options.labels.showLess), 1)) : (openBlock(), createElementBlock("span", _hoisted_10$1, toDisplayString(_ctx.options.labels.showAll), 1))
26941
+ showAll.value ? (openBlock(), createElementBlock("span", _hoisted_8$2, toDisplayString(_ctx.options.labels.showLess), 1)) : (openBlock(), createElementBlock("span", _hoisted_9$2, toDisplayString(_ctx.options.labels.showAll), 1))
26922
26942
  ])) : createCommentVNode("", true)
26923
26943
  ]);
26924
26944
  };
@@ -27913,7 +27933,7 @@ const _hoisted_4$i = {
27913
27933
  key: 0,
27914
27934
  class: "lupa-stats-range-label"
27915
27935
  };
27916
- const _hoisted_5$c = { class: "lupa-stats-from" };
27936
+ const _hoisted_5$b = { class: "lupa-stats-from" };
27917
27937
  const _hoisted_6$7 = ["max", "min", "pattern", "aria-label"];
27918
27938
  const _hoisted_7$5 = { key: 0 };
27919
27939
  const _hoisted_8$1 = /* @__PURE__ */ createBaseVNode("div", { class: "lupa-stats-separator" }, null, -1);
@@ -28113,7 +28133,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
28113
28133
  !isInputVisible.value ? (openBlock(), createElementBlock("div", _hoisted_2$z, toDisplayString(statsSummary.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$q, [
28114
28134
  createBaseVNode("div", null, [
28115
28135
  rangeLabelFrom.value ? (openBlock(), createElementBlock("div", _hoisted_4$i, toDisplayString(rangeLabelFrom.value), 1)) : createCommentVNode("", true),
28116
- createBaseVNode("div", _hoisted_5$c, [
28136
+ createBaseVNode("div", _hoisted_5$b, [
28117
28137
  withDirectives(createBaseVNode("input", {
28118
28138
  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => fromValue.value = $event),
28119
28139
  type: "text",
@@ -28177,13 +28197,12 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
28177
28197
  }
28178
28198
  });
28179
28199
  const _hoisted_1$M = { class: "lupa-term-checkbox-wrapper" };
28180
- const _hoisted_2$y = { class: "lupa-term-checkbox-label" };
28181
- const _hoisted_3$p = { class: "lupa-term-label" };
28182
- const _hoisted_4$h = {
28200
+ const _hoisted_2$y = { class: "lupa-term-label" };
28201
+ const _hoisted_3$p = {
28183
28202
  key: 0,
28184
28203
  class: "lupa-term-count"
28185
28204
  };
28186
- const _hoisted_5$b = {
28205
+ const _hoisted_4$h = {
28187
28206
  key: 0,
28188
28207
  class: "lupa-facet-level"
28189
28208
  };
@@ -28223,6 +28242,13 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
28223
28242
  value: item.key
28224
28243
  });
28225
28244
  };
28245
+ const getFacetValueClass = (item) => {
28246
+ try {
28247
+ return `lupa-facet-value-${slugifyClass(item.title)}`;
28248
+ } catch (e2) {
28249
+ return "";
28250
+ }
28251
+ };
28226
28252
  return (_ctx, _cache) => {
28227
28253
  const _component_HierarchyFacetLevel = resolveComponent("HierarchyFacetLevel", true);
28228
28254
  return openBlock(), createElementBlock("div", {
@@ -28238,12 +28264,14 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
28238
28264
  class: normalizeClass(["lupa-term-checkbox", { checked: isChecked.value }])
28239
28265
  }, null, 2)
28240
28266
  ]),
28241
- createBaseVNode("div", _hoisted_2$y, [
28242
- createBaseVNode("span", _hoisted_3$p, toDisplayString(_ctx.item.title) + toDisplayString(" "), 1),
28243
- _ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_4$h, "(" + toDisplayString(_ctx.item.count) + ")", 1)) : createCommentVNode("", true)
28244
- ])
28267
+ createBaseVNode("div", {
28268
+ class: normalizeClass(["lupa-term-checkbox-label", { [getFacetValueClass(_ctx.item)]: true }])
28269
+ }, [
28270
+ createBaseVNode("span", _hoisted_2$y, toDisplayString(_ctx.item.title) + toDisplayString(" "), 1),
28271
+ _ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_3$p, "(" + toDisplayString(_ctx.item.count) + ")", 1)) : createCommentVNode("", true)
28272
+ ], 2)
28245
28273
  ]),
28246
- showChildren.value ? (openBlock(), createElementBlock("div", _hoisted_5$b, [
28274
+ showChildren.value ? (openBlock(), createElementBlock("div", _hoisted_4$h, [
28247
28275
  (openBlock(true), createElementBlock(Fragment, null, renderList(treeItem.value.children, (itemChild) => {
28248
28276
  return openBlock(), createBlock(_component_HierarchyFacetLevel, {
28249
28277
  key: itemChild.title,