@getlupa/client 1.17.7 → 1.17.9
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.
- package/dist/lupaSearch.iife.js +1388 -1359
- package/dist/lupaSearch.js +1388 -1359
- package/dist/lupaSearch.mjs +1388 -1359
- package/dist/lupaSearch.umd.js +1388 -1359
- package/package.json +2 -2
package/dist/lupaSearch.mjs
CHANGED
|
@@ -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
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
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, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
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
|
-
|
|
7346
|
-
|
|
7347
|
-
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
}
|
|
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,1309 @@ 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, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
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
|
+
originalValue: f2.value
|
|
13460
|
+
});
|
|
13461
|
+
});
|
|
13462
|
+
};
|
|
13463
|
+
const isFacetKey = (key) => key.startsWith(FACET_PARAMS_TYPE.RANGE) || key.startsWith(FACET_PARAMS_TYPE.TERMS) || key.startsWith(FACET_PARAMS_TYPE.HIERARCHY);
|
|
13464
|
+
const getMostSpecificHierarchyTerms = (terms) => {
|
|
13465
|
+
const specificTerms = [];
|
|
13466
|
+
for (const term of terms) {
|
|
13467
|
+
if (!terms.some((t) => t.startsWith(term) && t !== term)) {
|
|
13468
|
+
specificTerms.push(term);
|
|
13469
|
+
}
|
|
13470
|
+
}
|
|
13471
|
+
return Array.from(new Set(specificTerms));
|
|
13472
|
+
};
|
|
13473
|
+
const recursiveFilter = (items, query = "") => {
|
|
13474
|
+
if (!query) {
|
|
13475
|
+
return items;
|
|
13476
|
+
}
|
|
13477
|
+
return items.map((i) => recursiveFilterItem(i, query)).filter(Boolean);
|
|
13478
|
+
};
|
|
13479
|
+
const recursiveFilterItem = (item, query = "") => {
|
|
13480
|
+
const filterable = getNormalizedString(item.title).includes(getNormalizedString(query)) ? item : void 0;
|
|
13481
|
+
if (!item.children) {
|
|
13482
|
+
return filterable;
|
|
13483
|
+
}
|
|
13484
|
+
const children = recursiveFilter(item.children, query).filter(Boolean);
|
|
13485
|
+
const include = children.length > 0 || filterable;
|
|
13486
|
+
return include ? __spreadProps2(__spreadValues2({}, item), {
|
|
13487
|
+
children
|
|
13488
|
+
}) : void 0;
|
|
13489
|
+
};
|
|
13490
|
+
const rangeFilterToString = (rangeFilter, separator) => {
|
|
13491
|
+
separator = separator || FACET_TERM_RANGE_SEPARATOR;
|
|
13492
|
+
return rangeFilter && Object.keys(rangeFilter).length ? rangeFilter.gte + separator + (rangeFilter.lte || rangeFilter.lt) : "";
|
|
13493
|
+
};
|
|
13494
|
+
const pick = (obj, keys) => {
|
|
13495
|
+
const ret = /* @__PURE__ */ Object.create({});
|
|
13496
|
+
for (const k of keys) {
|
|
13497
|
+
ret[k] = obj[k];
|
|
13498
|
+
}
|
|
13499
|
+
return ret;
|
|
13500
|
+
};
|
|
13501
|
+
const getHint = (suggestion, inputValue) => {
|
|
13502
|
+
var _a;
|
|
13503
|
+
if (!inputValue) {
|
|
13504
|
+
return escapeHtml$1(suggestion);
|
|
13505
|
+
}
|
|
13506
|
+
return (_a = suggestion == null ? void 0 : suggestion.replace(
|
|
13507
|
+
inputValue == null ? void 0 : inputValue.toLocaleLowerCase(),
|
|
13508
|
+
`<strong>${escapeHtml$1(inputValue == null ? void 0 : inputValue.toLocaleLowerCase())}</strong>`
|
|
13509
|
+
)) != null ? _a : "";
|
|
13510
|
+
};
|
|
13511
|
+
const reverseKeyValue = (obj) => {
|
|
13512
|
+
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [v, k.toLowerCase()]));
|
|
13513
|
+
};
|
|
13514
|
+
const getPageCount = (total, limit) => {
|
|
13515
|
+
return Math.ceil(total / limit) || 0;
|
|
13516
|
+
};
|
|
13517
|
+
const isObject$1 = (value) => {
|
|
13518
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
13519
|
+
};
|
|
13520
|
+
const parseParam = (key, params) => {
|
|
13521
|
+
const value = params.get(key);
|
|
13522
|
+
if (!value) {
|
|
13523
|
+
return void 0;
|
|
13524
|
+
}
|
|
13525
|
+
try {
|
|
13526
|
+
return decodeURIComponent(value);
|
|
13527
|
+
} catch (e2) {
|
|
13528
|
+
return void 0;
|
|
13529
|
+
}
|
|
13530
|
+
};
|
|
13531
|
+
const parseRegularKeys = (regularKeys, searchParams, getQueryParamName) => {
|
|
13532
|
+
const params = /* @__PURE__ */ Object.create({});
|
|
13533
|
+
const keys = reverseKeyValue({
|
|
13534
|
+
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
|
|
13535
|
+
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
|
|
13536
|
+
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
|
|
13537
|
+
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
|
|
13538
|
+
});
|
|
13539
|
+
for (const key of regularKeys) {
|
|
13540
|
+
const rawKey = keys[key] || key;
|
|
13541
|
+
params[rawKey] = parseParam(key, searchParams);
|
|
13542
|
+
}
|
|
13543
|
+
return params;
|
|
13544
|
+
};
|
|
13545
|
+
const parseFacetKey = (key, searchParams) => {
|
|
13546
|
+
var _a, _b, _c, _d;
|
|
13547
|
+
if (key.startsWith(FACET_PARAMS_TYPE.TERMS)) {
|
|
13548
|
+
return (_b = (_a = searchParams.getAll(key)) == null ? void 0 : _a.map((v) => decodeURIComponent(v))) != null ? _b : [];
|
|
13549
|
+
}
|
|
13550
|
+
if (key.startsWith(FACET_PARAMS_TYPE.RANGE)) {
|
|
13551
|
+
const range = searchParams.get(key);
|
|
13552
|
+
if (!range) {
|
|
13553
|
+
return {};
|
|
13554
|
+
}
|
|
13555
|
+
const [min, max] = range.split(FACET_RANGE_SEPARATOR);
|
|
13556
|
+
return {
|
|
13557
|
+
gte: min,
|
|
13558
|
+
lte: max
|
|
13559
|
+
};
|
|
13560
|
+
}
|
|
13561
|
+
if (key.startsWith(FACET_PARAMS_TYPE.HIERARCHY)) {
|
|
13562
|
+
return {
|
|
13563
|
+
level: 0,
|
|
13564
|
+
terms: (_d = (_c = searchParams.getAll(key)) == null ? void 0 : _c.map((v) => decodeURIComponent(v))) != null ? _d : []
|
|
13565
|
+
};
|
|
13566
|
+
}
|
|
13567
|
+
return [];
|
|
13568
|
+
};
|
|
13569
|
+
const parseFacetKeys = (facetKeys, searchParams) => {
|
|
13570
|
+
const params = {};
|
|
13571
|
+
params.filters = {};
|
|
13572
|
+
for (const key of facetKeys) {
|
|
13573
|
+
const parsedKey = key.slice(key.indexOf(FACET_KEY_SEPARATOR) + 1);
|
|
13574
|
+
params.filters = __spreadProps2(__spreadValues2({}, params.filters), {
|
|
13575
|
+
[parsedKey]: parseFacetKey(key, searchParams)
|
|
13576
|
+
});
|
|
13577
|
+
}
|
|
13578
|
+
return params;
|
|
13579
|
+
};
|
|
13580
|
+
const parseParams = (getQueryParamName, searchParams) => {
|
|
13581
|
+
const params = /* @__PURE__ */ Object.create({});
|
|
13582
|
+
if (!searchParams)
|
|
13583
|
+
return params;
|
|
13584
|
+
const paramKeys = Array.from(searchParams.keys());
|
|
13585
|
+
const facetKeys = paramKeys.filter((k) => isFacetKey(k));
|
|
13586
|
+
const regularKeys = paramKeys.filter((k) => !isFacetKey(k));
|
|
13587
|
+
const r = __spreadValues2(__spreadValues2({
|
|
13588
|
+
[QUERY_PARAMS_PARSED.QUERY]: ""
|
|
13589
|
+
}, parseRegularKeys(regularKeys, searchParams, getQueryParamName)), parseFacetKeys(facetKeys, searchParams));
|
|
13590
|
+
return r;
|
|
13591
|
+
};
|
|
13592
|
+
const appendParam = (url, { name, value }, encode2 = true) => {
|
|
13593
|
+
if (Array.isArray(value)) {
|
|
13594
|
+
appendArrayParams(url, { name, value });
|
|
13595
|
+
} else {
|
|
13596
|
+
appendSingleParam(url, { name, value }, encode2);
|
|
13597
|
+
}
|
|
13598
|
+
};
|
|
13599
|
+
const appendSingleParam = (url, param, encode2 = true) => {
|
|
13600
|
+
const valueToAppend = encode2 ? encodeParam(param.value) : param.value;
|
|
13601
|
+
if (url.searchParams.has(param.name)) {
|
|
13602
|
+
url.searchParams.set(param.name, valueToAppend);
|
|
13603
|
+
} else {
|
|
13604
|
+
url.searchParams.append(param.name, valueToAppend);
|
|
13605
|
+
}
|
|
13606
|
+
};
|
|
13607
|
+
const appendArrayParams = (url, param) => {
|
|
13608
|
+
url.searchParams.delete(param.name);
|
|
13609
|
+
param.value.forEach((v) => url.searchParams.append(param.name, encodeParam(v)));
|
|
13610
|
+
};
|
|
13611
|
+
const getRemovableParams = (url, getQueryParamName, paramsToRemove) => {
|
|
13612
|
+
if (paramsToRemove === "all") {
|
|
13613
|
+
const params = {
|
|
13614
|
+
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
|
|
13615
|
+
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
|
|
13616
|
+
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
|
|
13617
|
+
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
|
|
13618
|
+
};
|
|
13619
|
+
return [
|
|
13620
|
+
...Object.values(params),
|
|
13621
|
+
...Array.from(url.searchParams.keys()).filter((k) => isFacetKey(k))
|
|
13622
|
+
];
|
|
13623
|
+
}
|
|
13624
|
+
return paramsToRemove;
|
|
13625
|
+
};
|
|
13626
|
+
const removeParams = (url, params = []) => {
|
|
13627
|
+
for (const param of params) {
|
|
13628
|
+
if (url.searchParams.has(param)) {
|
|
13629
|
+
url.searchParams.delete(param);
|
|
13630
|
+
}
|
|
13631
|
+
}
|
|
13632
|
+
};
|
|
13633
|
+
const encodeParam = (param) => {
|
|
13634
|
+
const encoded = encodeURIComponent(param);
|
|
13635
|
+
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, " ");
|
|
13636
|
+
};
|
|
13637
|
+
const getQueryParam$1 = (name) => {
|
|
13638
|
+
try {
|
|
13639
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
13640
|
+
return urlParams.get(name);
|
|
13641
|
+
} catch (e2) {
|
|
13642
|
+
return null;
|
|
13643
|
+
}
|
|
13644
|
+
};
|
|
13645
|
+
const PATH_REPLACE_REGEXP = /{(.*?)}/gm;
|
|
13646
|
+
const generateLink = (linkPattern, document2) => {
|
|
13647
|
+
const matches = linkPattern.match(PATH_REPLACE_REGEXP);
|
|
13648
|
+
if (!matches) {
|
|
13649
|
+
return linkPattern;
|
|
13650
|
+
}
|
|
13651
|
+
let link = linkPattern;
|
|
13652
|
+
for (const match of matches) {
|
|
13653
|
+
const propertyKey = match.slice(1, match.length - 1);
|
|
13654
|
+
const property = document2[propertyKey] || "";
|
|
13655
|
+
link = link.replace(match, property);
|
|
13656
|
+
}
|
|
13657
|
+
return link;
|
|
13658
|
+
};
|
|
13659
|
+
const generateResultLink = (link, getQueryParamName, searchText, facet) => {
|
|
13660
|
+
if (!searchText) {
|
|
13661
|
+
return link;
|
|
13662
|
+
}
|
|
13663
|
+
const facetParam = facet ? `&${FACET_PARAMS_TYPE.TERMS}${encodeParam(facet.key)}=${encodeParam(facet.title)}` : "";
|
|
13664
|
+
const queryParam = `?${getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY}=${encodeParam(searchText)}`;
|
|
13665
|
+
return `${link}${queryParam}${facetParam}`;
|
|
13666
|
+
};
|
|
13667
|
+
const getRelativePath = (link) => {
|
|
13668
|
+
try {
|
|
13669
|
+
const url = new URL(link);
|
|
13670
|
+
const partialUrl = url.toString().substring(url.origin.length);
|
|
13671
|
+
return partialUrl.endsWith("/") ? partialUrl.slice(0, partialUrl.length - 1) : partialUrl;
|
|
13672
|
+
} catch (e2) {
|
|
13673
|
+
return (link == null ? void 0 : link.endsWith("/")) ? link.slice(0, link.length - 1) : link;
|
|
13674
|
+
}
|
|
13675
|
+
};
|
|
13676
|
+
const linksMatch = (link1, link2) => {
|
|
13677
|
+
if (!link1 || !link2) {
|
|
13678
|
+
return false;
|
|
13679
|
+
}
|
|
13680
|
+
return link1 === link2 || getRelativePath(link1) === getRelativePath(link2);
|
|
13681
|
+
};
|
|
13682
|
+
const emitRoutingEvent = (url) => {
|
|
13683
|
+
const event = new CustomEvent(LUPA_ROUTING_EVENT, { detail: url });
|
|
13684
|
+
window.dispatchEvent(event);
|
|
13685
|
+
};
|
|
13686
|
+
const handleRoutingEvent = (link, event, hasEventRouting = false) => {
|
|
13687
|
+
if (!hasEventRouting) {
|
|
13688
|
+
return;
|
|
13689
|
+
}
|
|
13690
|
+
event == null ? void 0 : event.preventDefault();
|
|
13691
|
+
emitRoutingEvent(link);
|
|
13692
|
+
};
|
|
13693
|
+
const redirectToResultsPage = (link, searchText, getQueryParamName, facet, routingBehavior = "direct-link") => {
|
|
13694
|
+
const url = generateResultLink(link, getQueryParamName, searchText, facet);
|
|
13695
|
+
if (routingBehavior === "event") {
|
|
13696
|
+
emitRoutingEvent(url);
|
|
13697
|
+
} else {
|
|
13698
|
+
window.location.assign(url);
|
|
13699
|
+
}
|
|
13700
|
+
};
|
|
13701
|
+
const getPageUrl = (pathnameOverride, ssr) => {
|
|
13702
|
+
if (typeof window !== "undefined") {
|
|
13703
|
+
const pathname = pathnameOverride || window.location.pathname;
|
|
13704
|
+
const origin = window.location.origin;
|
|
13705
|
+
const search2 = window.location.search;
|
|
13706
|
+
return new URL(origin + pathname + search2);
|
|
13707
|
+
}
|
|
13708
|
+
return new URL(ssr.url, ssr.baseUrl);
|
|
13709
|
+
};
|
|
13710
|
+
const getFacetKey = (key, type) => {
|
|
13711
|
+
return `${FACET_FILTER_MAP[type]}${key}`;
|
|
13712
|
+
};
|
|
13713
|
+
const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
|
|
13714
|
+
return {
|
|
13715
|
+
name: `${type}${key}`,
|
|
13716
|
+
value
|
|
13717
|
+
};
|
|
13718
|
+
};
|
|
13719
|
+
const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters, paramsToRemove = []) => {
|
|
13720
|
+
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
13721
|
+
const newParams = toggleTermParam(currentFilter, facetAction.value);
|
|
13722
|
+
appendParams({
|
|
13723
|
+
params: [getFacetParam(facetAction.key, newParams)],
|
|
13724
|
+
paramsToRemove: [
|
|
13725
|
+
...paramsToRemove,
|
|
13726
|
+
...[getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
|
|
13727
|
+
]
|
|
13728
|
+
});
|
|
13729
|
+
};
|
|
13730
|
+
const replaceHierarchyParam = (params = [], param = "") => {
|
|
13731
|
+
if (params.some((p2) => p2.startsWith(param))) {
|
|
13732
|
+
return toggleLastPram(params, param);
|
|
13733
|
+
}
|
|
13734
|
+
return [param];
|
|
13735
|
+
};
|
|
13736
|
+
const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
|
|
13737
|
+
var _a, _b;
|
|
13738
|
+
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
13739
|
+
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);
|
|
13740
|
+
appendParams({
|
|
13741
|
+
params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
|
|
13742
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
|
|
13743
|
+
});
|
|
13744
|
+
};
|
|
13745
|
+
const toggleRangeFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
13746
|
+
const currentFilter = rangeFilterToString(
|
|
13747
|
+
currentFilters == null ? void 0 : currentFilters[facetAction.key],
|
|
13748
|
+
FACET_RANGE_SEPARATOR
|
|
13749
|
+
);
|
|
13750
|
+
let facetValue = facetAction.value.join(FACET_RANGE_SEPARATOR);
|
|
13751
|
+
facetValue = currentFilter === facetValue ? "" : facetValue;
|
|
13752
|
+
appendParams({
|
|
13753
|
+
params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
|
|
13754
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE],
|
|
13755
|
+
encode: false
|
|
13756
|
+
});
|
|
13757
|
+
};
|
|
13758
|
+
const toggleTermParam = (params = [], param = "") => {
|
|
13759
|
+
if (params == null ? void 0 : params.includes(param)) {
|
|
13760
|
+
return params.filter((p2) => p2 !== param);
|
|
13761
|
+
}
|
|
13762
|
+
return [param, ...params];
|
|
13763
|
+
};
|
|
13764
|
+
const toggleLastPram = (params = [], param = "") => {
|
|
13765
|
+
const paramLevel = param.split(">").length;
|
|
13766
|
+
return getMostSpecificHierarchyTerms(
|
|
13767
|
+
params.map(
|
|
13768
|
+
(p2) => p2.startsWith(param) ? p2.split(HIERARCHY_SEPARATOR).slice(0, paramLevel - 1).join(HIERARCHY_SEPARATOR).trim() : p2
|
|
13769
|
+
).filter(Boolean)
|
|
13770
|
+
);
|
|
13771
|
+
};
|
|
13772
|
+
const toggleHierarchyParam = (params = [], param = "", removeAllLevels = false) => {
|
|
13773
|
+
if (params == null ? void 0 : params.some((p2) => p2.startsWith(param))) {
|
|
13774
|
+
return removeAllLevels ? getMostSpecificHierarchyTerms(params.filter((p2) => !p2.startsWith(param))) : toggleLastPram(params, param);
|
|
13775
|
+
}
|
|
13776
|
+
return getMostSpecificHierarchyTerms([param, ...params]);
|
|
13777
|
+
};
|
|
13778
|
+
const CACHE_KEY = "lupasearch-client-redirections";
|
|
13779
|
+
const useRedirectionStore = defineStore("redirections", () => {
|
|
13780
|
+
const redirections = ref({ rules: [] });
|
|
13781
|
+
const redirectionOptions = ref({ enabled: false, queryKey: "" });
|
|
13782
|
+
const saveToLocalStorage2 = () => {
|
|
13783
|
+
try {
|
|
13784
|
+
localStorage.setItem(
|
|
13785
|
+
CACHE_KEY,
|
|
13786
|
+
JSON.stringify({
|
|
13787
|
+
redirections: redirections.value,
|
|
13788
|
+
savedAt: Date.now(),
|
|
13789
|
+
queryKey: redirectionOptions.value.queryKey
|
|
13790
|
+
})
|
|
13791
|
+
);
|
|
13792
|
+
} catch (e2) {
|
|
13793
|
+
}
|
|
13794
|
+
};
|
|
13795
|
+
const tryLoadFromLocalStorage2 = (config) => {
|
|
13796
|
+
var _a;
|
|
13797
|
+
if (!config.cacheSeconds)
|
|
13798
|
+
return false;
|
|
13799
|
+
try {
|
|
13800
|
+
const data = JSON.parse((_a = localStorage.getItem(CACHE_KEY)) != null ? _a : "");
|
|
13801
|
+
if (data.queryKey !== config.queryKey) {
|
|
13802
|
+
return false;
|
|
13803
|
+
}
|
|
13804
|
+
if ((data == null ? void 0 : data.redirections) && Date.now() - data.savedAt < 1e3 * config.cacheSeconds) {
|
|
13805
|
+
redirections.value = data.redirections;
|
|
13806
|
+
return true;
|
|
13807
|
+
}
|
|
13808
|
+
} catch (e2) {
|
|
13809
|
+
}
|
|
13810
|
+
return false;
|
|
13811
|
+
};
|
|
13812
|
+
const initiate = (config, options) => __async2(void 0, null, function* () {
|
|
13813
|
+
var _a, _b, _c, _d;
|
|
13814
|
+
if ((_a = redirectionOptions.value) == null ? void 0 : _a.enabled) {
|
|
13815
|
+
return;
|
|
13816
|
+
}
|
|
13817
|
+
redirectionOptions.value = config;
|
|
13818
|
+
if (!(config == null ? void 0 : config.enabled)) {
|
|
13819
|
+
return;
|
|
13820
|
+
}
|
|
13821
|
+
const loaded = tryLoadFromLocalStorage2(config);
|
|
13822
|
+
if (loaded || ((_c = (_b = redirections.value) == null ? void 0 : _b.rules) == null ? void 0 : _c.length) > 0) {
|
|
13823
|
+
return;
|
|
13824
|
+
}
|
|
13825
|
+
try {
|
|
13826
|
+
const result2 = yield LupaSearchSdk.loadRedirectionRules(config.queryKey, options);
|
|
13827
|
+
if (!((_d = result2 == null ? void 0 : result2.rules) == null ? void 0 : _d.length)) {
|
|
13828
|
+
redirections.value = { rules: [] };
|
|
13829
|
+
return;
|
|
13830
|
+
}
|
|
13831
|
+
redirections.value = result2;
|
|
13832
|
+
saveToLocalStorage2();
|
|
13833
|
+
} catch (e2) {
|
|
13834
|
+
}
|
|
13835
|
+
});
|
|
13836
|
+
const redirectOnKeywordIfConfigured = (input2, routingBehavior = "direct-link") => {
|
|
13837
|
+
var _a, _b, _c, _d;
|
|
13838
|
+
if (!((_b = (_a = redirections.value) == null ? void 0 : _a.rules) == null ? void 0 : _b.length)) {
|
|
13839
|
+
return false;
|
|
13840
|
+
}
|
|
13841
|
+
const redirectTo = redirections.value.rules.find((r) => inputsAreEqual(input2, r.sources));
|
|
13842
|
+
if (!redirectTo) {
|
|
13843
|
+
return false;
|
|
13844
|
+
}
|
|
13845
|
+
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;
|
|
13846
|
+
if (url === void 0 || url === null || url === "") {
|
|
13847
|
+
return false;
|
|
13848
|
+
}
|
|
13849
|
+
if (routingBehavior === "event") {
|
|
13850
|
+
emitRoutingEvent(url);
|
|
13848
13851
|
} else {
|
|
13849
|
-
|
|
13852
|
+
window.location.assign(url);
|
|
13850
13853
|
}
|
|
13851
|
-
|
|
13852
|
-
}
|
|
13853
|
-
|
|
13854
|
+
return true;
|
|
13855
|
+
};
|
|
13856
|
+
return {
|
|
13857
|
+
redirections,
|
|
13858
|
+
redirectOnKeywordIfConfigured,
|
|
13859
|
+
initiate
|
|
13860
|
+
};
|
|
13861
|
+
});
|
|
13854
13862
|
const joinUrlParts = (...parts) => {
|
|
13855
13863
|
var _a, _b, _c;
|
|
13856
13864
|
if (parts.length === 1) {
|
|
@@ -14289,7 +14297,7 @@ const _hoisted_1$1i = { id: "lupa-search-box-input-container" };
|
|
|
14289
14297
|
const _hoisted_2$T = { class: "lupa-input-clear" };
|
|
14290
14298
|
const _hoisted_3$C = { id: "lupa-search-box-input" };
|
|
14291
14299
|
const _hoisted_4$s = ["value"];
|
|
14292
|
-
const _hoisted_5$
|
|
14300
|
+
const _hoisted_5$i = ["aria-label", "placeholder"];
|
|
14293
14301
|
const _hoisted_6$9 = /* @__PURE__ */ createBaseVNode("span", { class: "lupa-search-submit-icon" }, null, -1);
|
|
14294
14302
|
const _hoisted_7$7 = [
|
|
14295
14303
|
_hoisted_6$9
|
|
@@ -14409,7 +14417,7 @@ const _sfc_main$1v = /* @__PURE__ */ defineComponent({
|
|
|
14409
14417
|
placeholder: labels.value.placeholder,
|
|
14410
14418
|
onInput: handleInput,
|
|
14411
14419
|
onFocus: handleFocus
|
|
14412
|
-
}), null, 16, _hoisted_5$
|
|
14420
|
+
}), null, 16, _hoisted_5$i), [
|
|
14413
14421
|
[vModelText, inputValue.value]
|
|
14414
14422
|
]),
|
|
14415
14423
|
_ctx.options.showSubmitButton ? (openBlock(), createElementBlock("button", {
|
|
@@ -14625,7 +14633,7 @@ const _hoisted_4$r = {
|
|
|
14625
14633
|
class: "lupa-suggestion-facet-label",
|
|
14626
14634
|
"data-cy": "lupa-suggestion-facet-label"
|
|
14627
14635
|
};
|
|
14628
|
-
const _hoisted_5$
|
|
14636
|
+
const _hoisted_5$h = {
|
|
14629
14637
|
class: "lupa-suggestion-facet-value",
|
|
14630
14638
|
"data-cy": "lupa-suggestion-facet-value"
|
|
14631
14639
|
};
|
|
@@ -14668,7 +14676,7 @@ const _sfc_main$1q = /* @__PURE__ */ defineComponent({
|
|
|
14668
14676
|
}, null, 8, _hoisted_1$1e)) : (openBlock(), createElementBlock("div", _hoisted_2$R, toDisplayString(_ctx.suggestion.display), 1)),
|
|
14669
14677
|
_ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$B, [
|
|
14670
14678
|
createBaseVNode("span", _hoisted_4$r, toDisplayString(facetLabel.value), 1),
|
|
14671
|
-
createBaseVNode("span", _hoisted_5$
|
|
14679
|
+
createBaseVNode("span", _hoisted_5$h, toDisplayString(_ctx.suggestion.facet.title), 1)
|
|
14672
14680
|
])) : createCommentVNode("", true)
|
|
14673
14681
|
]);
|
|
14674
14682
|
};
|
|
@@ -24162,7 +24170,7 @@ const _hoisted_1$18 = ["innerHTML"];
|
|
|
24162
24170
|
const _hoisted_2$N = { key: 0 };
|
|
24163
24171
|
const _hoisted_3$A = { key: 1 };
|
|
24164
24172
|
const _hoisted_4$q = { class: "lupa-search-box-custom-label" };
|
|
24165
|
-
const _hoisted_5$
|
|
24173
|
+
const _hoisted_5$g = { class: "lupa-search-box-custom-text" };
|
|
24166
24174
|
const _sfc_main$1h = /* @__PURE__ */ defineComponent({
|
|
24167
24175
|
__name: "SearchBoxProductCustom",
|
|
24168
24176
|
props: {
|
|
@@ -24195,7 +24203,7 @@ const _sfc_main$1h = /* @__PURE__ */ defineComponent({
|
|
|
24195
24203
|
}, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
|
|
24196
24204
|
!label.value ? (openBlock(), createElementBlock("div", _hoisted_2$N, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$A, [
|
|
24197
24205
|
createBaseVNode("div", _hoisted_4$q, toDisplayString(label.value), 1),
|
|
24198
|
-
createBaseVNode("div", _hoisted_5$
|
|
24206
|
+
createBaseVNode("div", _hoisted_5$g, toDisplayString(text.value), 1)
|
|
24199
24207
|
]))
|
|
24200
24208
|
], 16));
|
|
24201
24209
|
};
|
|
@@ -25615,7 +25623,7 @@ const _hoisted_4$o = {
|
|
|
25615
25623
|
key: 1,
|
|
25616
25624
|
class: "lupa-panel-title"
|
|
25617
25625
|
};
|
|
25618
|
-
const _hoisted_5$
|
|
25626
|
+
const _hoisted_5$f = {
|
|
25619
25627
|
key: 1,
|
|
25620
25628
|
id: "lupa-search-box-panel"
|
|
25621
25629
|
};
|
|
@@ -25839,7 +25847,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
|
|
|
25839
25847
|
options: _ctx.options,
|
|
25840
25848
|
onGoToResults: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("go-to-results"))
|
|
25841
25849
|
}, null, 8, ["labels", "options"])) : createCommentVNode("", true)
|
|
25842
|
-
])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$
|
|
25850
|
+
])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$f, [
|
|
25843
25851
|
createVNode(_sfc_main$1s, {
|
|
25844
25852
|
options: _ctx.options.history,
|
|
25845
25853
|
history: history.value,
|
|
@@ -26404,7 +26412,7 @@ const _hoisted_3$u = {
|
|
|
26404
26412
|
class: "lupa-results-total-count"
|
|
26405
26413
|
};
|
|
26406
26414
|
const _hoisted_4$m = { class: "lupa-results-total-count-number" };
|
|
26407
|
-
const _hoisted_5$
|
|
26415
|
+
const _hoisted_5$e = ["innerHTML"];
|
|
26408
26416
|
const _sfc_main$Z = /* @__PURE__ */ defineComponent({
|
|
26409
26417
|
__name: "SearchResultsTitle",
|
|
26410
26418
|
props: {
|
|
@@ -26465,7 +26473,7 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
|
|
|
26465
26473
|
key: 2,
|
|
26466
26474
|
class: "lupa-result-page-description-top",
|
|
26467
26475
|
innerHTML: descriptionTop.value
|
|
26468
|
-
}, null, 8, _hoisted_5$
|
|
26476
|
+
}, null, 8, _hoisted_5$e)) : createCommentVNode("", true)
|
|
26469
26477
|
]);
|
|
26470
26478
|
};
|
|
26471
26479
|
}
|
|
@@ -26554,7 +26562,7 @@ const _sfc_main$X = /* @__PURE__ */ defineComponent({
|
|
|
26554
26562
|
toggleTermFilter(
|
|
26555
26563
|
// TODO: Fix any
|
|
26556
26564
|
paramsStore.appendParams,
|
|
26557
|
-
{ type: "terms", value: filter2.
|
|
26565
|
+
{ type: "terms", value: filter2.originalValue, key: filter2.key },
|
|
26558
26566
|
optionStore.getQueryParamName,
|
|
26559
26567
|
currentFilters.value
|
|
26560
26568
|
);
|
|
@@ -26562,7 +26570,7 @@ const _sfc_main$X = /* @__PURE__ */ defineComponent({
|
|
|
26562
26570
|
case "hierarchy":
|
|
26563
26571
|
toggleHierarchyFilter(
|
|
26564
26572
|
paramsStore.appendParams,
|
|
26565
|
-
{ type: "hierarchy", value: filter2.
|
|
26573
|
+
{ type: "hierarchy", value: filter2.originalValue, key: filter2.key },
|
|
26566
26574
|
optionStore.getQueryParamName,
|
|
26567
26575
|
currentFilters.value,
|
|
26568
26576
|
true
|
|
@@ -26668,7 +26676,7 @@ const _hoisted_1$P = {
|
|
|
26668
26676
|
const _hoisted_2$B = { class: "lupa-category-back" };
|
|
26669
26677
|
const _hoisted_3$s = ["href"];
|
|
26670
26678
|
const _hoisted_4$k = ["href"];
|
|
26671
|
-
const _hoisted_5$
|
|
26679
|
+
const _hoisted_5$d = { class: "lupa-child-category-list" };
|
|
26672
26680
|
const _sfc_main$V = /* @__PURE__ */ defineComponent({
|
|
26673
26681
|
__name: "CategoryFilter",
|
|
26674
26682
|
props: {
|
|
@@ -26776,7 +26784,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
|
|
|
26776
26784
|
onClick: handleNavigationParent
|
|
26777
26785
|
}, toDisplayString(parentTitle.value), 11, _hoisted_4$k)
|
|
26778
26786
|
], 2),
|
|
26779
|
-
createBaseVNode("div", _hoisted_5$
|
|
26787
|
+
createBaseVNode("div", _hoisted_5$d, [
|
|
26780
26788
|
(openBlock(true), createElementBlock(Fragment, null, renderList(categoryChildren.value, (child) => {
|
|
26781
26789
|
return openBlock(), createBlock(_sfc_main$W, {
|
|
26782
26790
|
key: getCategoryKey(child),
|
|
@@ -26796,15 +26804,14 @@ const _hoisted_1$O = {
|
|
|
26796
26804
|
const _hoisted_2$A = ["placeholder"];
|
|
26797
26805
|
const _hoisted_3$r = { class: "lupa-terms-list" };
|
|
26798
26806
|
const _hoisted_4$j = ["onClick"];
|
|
26799
|
-
const _hoisted_5$
|
|
26800
|
-
const _hoisted_6$8 = { class: "lupa-term-
|
|
26801
|
-
const _hoisted_7$6 = {
|
|
26802
|
-
const _hoisted_8$2 = {
|
|
26807
|
+
const _hoisted_5$c = { class: "lupa-term-checkbox-wrapper" };
|
|
26808
|
+
const _hoisted_6$8 = { class: "lupa-term-label" };
|
|
26809
|
+
const _hoisted_7$6 = {
|
|
26803
26810
|
key: 0,
|
|
26804
26811
|
class: "lupa-term-count"
|
|
26805
26812
|
};
|
|
26806
|
-
const
|
|
26807
|
-
const
|
|
26813
|
+
const _hoisted_8$2 = { key: 0 };
|
|
26814
|
+
const _hoisted_9$2 = { key: 1 };
|
|
26808
26815
|
const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
26809
26816
|
__name: "TermFacet",
|
|
26810
26817
|
props: {
|
|
@@ -26836,7 +26843,12 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
|
26836
26843
|
return searchResultStore.filterVisibleFilterValues(facet.value.key, (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : []);
|
|
26837
26844
|
});
|
|
26838
26845
|
const displayValues = computed(() => {
|
|
26839
|
-
return filteredValues.value.slice(0, itemLimit.value).
|
|
26846
|
+
return filteredValues.value.slice(0, itemLimit.value).filter(
|
|
26847
|
+
(v) => {
|
|
26848
|
+
var _a, _b, _c;
|
|
26849
|
+
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;
|
|
26850
|
+
}
|
|
26851
|
+
).map((v) => __spreadProps2(__spreadValues2({}, v), { title: getDisplayValue(v.title) }));
|
|
26840
26852
|
});
|
|
26841
26853
|
const filteredValues = computed(() => {
|
|
26842
26854
|
var _a, _b;
|
|
@@ -26881,6 +26893,13 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
|
26881
26893
|
var _a;
|
|
26882
26894
|
return getTranslatedFacetValue(props.facet, item, (_a = searchResultOptions.value.filters) == null ? void 0 : _a.translations);
|
|
26883
26895
|
};
|
|
26896
|
+
const getFacetValueClass = (item) => {
|
|
26897
|
+
try {
|
|
26898
|
+
return `lupa-facet-value-${slugifyClass(item.title)}`;
|
|
26899
|
+
} catch (e2) {
|
|
26900
|
+
return "";
|
|
26901
|
+
}
|
|
26902
|
+
};
|
|
26884
26903
|
return (_ctx, _cache) => {
|
|
26885
26904
|
return openBlock(), createElementBlock("div", _hoisted_1$O, [
|
|
26886
26905
|
isFilterable.value ? withDirectives((openBlock(), createElementBlock("input", {
|
|
@@ -26900,15 +26919,17 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
|
26900
26919
|
key: item.title,
|
|
26901
26920
|
onClick: ($event) => handleFacetClick(item)
|
|
26902
26921
|
}, [
|
|
26903
|
-
createBaseVNode("div", _hoisted_5$
|
|
26922
|
+
createBaseVNode("div", _hoisted_5$c, [
|
|
26904
26923
|
createBaseVNode("span", {
|
|
26905
26924
|
class: normalizeClass(["lupa-term-checkbox", { checked: isChecked(item) }])
|
|
26906
26925
|
}, null, 2)
|
|
26907
26926
|
]),
|
|
26908
|
-
createBaseVNode("div",
|
|
26909
|
-
|
|
26910
|
-
|
|
26911
|
-
|
|
26927
|
+
createBaseVNode("div", {
|
|
26928
|
+
class: normalizeClass(["lupa-term-checkbox-label", { [getFacetValueClass(item)]: true }])
|
|
26929
|
+
}, [
|
|
26930
|
+
createBaseVNode("span", _hoisted_6$8, toDisplayString(getItemLabel(item)), 1),
|
|
26931
|
+
_ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_7$6, "(" + toDisplayString(item.count) + ")", 1)) : createCommentVNode("", true)
|
|
26932
|
+
], 2)
|
|
26912
26933
|
], 10, _hoisted_4$j);
|
|
26913
26934
|
}), 128))
|
|
26914
26935
|
]),
|
|
@@ -26918,7 +26939,7 @@ const _sfc_main$U = /* @__PURE__ */ defineComponent({
|
|
|
26918
26939
|
"data-cy": "lupa-facet-term",
|
|
26919
26940
|
onClick: toggleShowAll
|
|
26920
26941
|
}, [
|
|
26921
|
-
showAll.value ? (openBlock(), createElementBlock("span",
|
|
26942
|
+
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
26943
|
])) : createCommentVNode("", true)
|
|
26923
26944
|
]);
|
|
26924
26945
|
};
|
|
@@ -27913,7 +27934,7 @@ const _hoisted_4$i = {
|
|
|
27913
27934
|
key: 0,
|
|
27914
27935
|
class: "lupa-stats-range-label"
|
|
27915
27936
|
};
|
|
27916
|
-
const _hoisted_5$
|
|
27937
|
+
const _hoisted_5$b = { class: "lupa-stats-from" };
|
|
27917
27938
|
const _hoisted_6$7 = ["max", "min", "pattern", "aria-label"];
|
|
27918
27939
|
const _hoisted_7$5 = { key: 0 };
|
|
27919
27940
|
const _hoisted_8$1 = /* @__PURE__ */ createBaseVNode("div", { class: "lupa-stats-separator" }, null, -1);
|
|
@@ -28113,7 +28134,7 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
|
|
|
28113
28134
|
!isInputVisible.value ? (openBlock(), createElementBlock("div", _hoisted_2$z, toDisplayString(statsSummary.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$q, [
|
|
28114
28135
|
createBaseVNode("div", null, [
|
|
28115
28136
|
rangeLabelFrom.value ? (openBlock(), createElementBlock("div", _hoisted_4$i, toDisplayString(rangeLabelFrom.value), 1)) : createCommentVNode("", true),
|
|
28116
|
-
createBaseVNode("div", _hoisted_5$
|
|
28137
|
+
createBaseVNode("div", _hoisted_5$b, [
|
|
28117
28138
|
withDirectives(createBaseVNode("input", {
|
|
28118
28139
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => fromValue.value = $event),
|
|
28119
28140
|
type: "text",
|
|
@@ -28177,13 +28198,12 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
|
|
|
28177
28198
|
}
|
|
28178
28199
|
});
|
|
28179
28200
|
const _hoisted_1$M = { class: "lupa-term-checkbox-wrapper" };
|
|
28180
|
-
const _hoisted_2$y = { class: "lupa-term-
|
|
28181
|
-
const _hoisted_3$p = {
|
|
28182
|
-
const _hoisted_4$h = {
|
|
28201
|
+
const _hoisted_2$y = { class: "lupa-term-label" };
|
|
28202
|
+
const _hoisted_3$p = {
|
|
28183
28203
|
key: 0,
|
|
28184
28204
|
class: "lupa-term-count"
|
|
28185
28205
|
};
|
|
28186
|
-
const
|
|
28206
|
+
const _hoisted_4$h = {
|
|
28187
28207
|
key: 0,
|
|
28188
28208
|
class: "lupa-facet-level"
|
|
28189
28209
|
};
|
|
@@ -28223,6 +28243,13 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
|
28223
28243
|
value: item.key
|
|
28224
28244
|
});
|
|
28225
28245
|
};
|
|
28246
|
+
const getFacetValueClass = (item) => {
|
|
28247
|
+
try {
|
|
28248
|
+
return `lupa-facet-value-${slugifyClass(item.title)}`;
|
|
28249
|
+
} catch (e2) {
|
|
28250
|
+
return "";
|
|
28251
|
+
}
|
|
28252
|
+
};
|
|
28226
28253
|
return (_ctx, _cache) => {
|
|
28227
28254
|
const _component_HierarchyFacetLevel = resolveComponent("HierarchyFacetLevel", true);
|
|
28228
28255
|
return openBlock(), createElementBlock("div", {
|
|
@@ -28238,12 +28265,14 @@ const _sfc_main$S = /* @__PURE__ */ defineComponent({
|
|
|
28238
28265
|
class: normalizeClass(["lupa-term-checkbox", { checked: isChecked.value }])
|
|
28239
28266
|
}, null, 2)
|
|
28240
28267
|
]),
|
|
28241
|
-
createBaseVNode("div",
|
|
28242
|
-
|
|
28243
|
-
|
|
28244
|
-
|
|
28268
|
+
createBaseVNode("div", {
|
|
28269
|
+
class: normalizeClass(["lupa-term-checkbox-label", { [getFacetValueClass(_ctx.item)]: true }])
|
|
28270
|
+
}, [
|
|
28271
|
+
createBaseVNode("span", _hoisted_2$y, toDisplayString(_ctx.item.title) + toDisplayString(" "), 1),
|
|
28272
|
+
_ctx.options.showDocumentCount ? (openBlock(), createElementBlock("span", _hoisted_3$p, "(" + toDisplayString(_ctx.item.count) + ")", 1)) : createCommentVNode("", true)
|
|
28273
|
+
], 2)
|
|
28245
28274
|
]),
|
|
28246
|
-
showChildren.value ? (openBlock(), createElementBlock("div",
|
|
28275
|
+
showChildren.value ? (openBlock(), createElementBlock("div", _hoisted_4$h, [
|
|
28247
28276
|
(openBlock(true), createElementBlock(Fragment, null, renderList(treeItem.value.children, (itemChild) => {
|
|
28248
28277
|
return openBlock(), createBlock(_component_HierarchyFacetLevel, {
|
|
28249
28278
|
key: itemChild.title,
|