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