@nosto/search-js 1.6.0 → 1.7.0
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/preact/preact.cjs.js +1 -1
- package/dist/preact/preact.d.ts +2 -0
- package/dist/preact/preact.es.js +546 -463
- package/dist/preact/src/components/InfiniteScroll/InfiniteScroll.d.ts +51 -0
- package/dist/preact/src/components/InfiniteScroll/InfiniteScrollWithLink.d.ts +6 -0
- package/dist/preact/src/components/InfiniteScroll/InfiniteScrollWithObserver.d.ts +7 -0
- package/dist/preact/src/components/InfiniteScroll/LoadMoreLink.d.ts +7 -0
- package/dist/preact/src/components/InfiniteScroll/utils.d.ts +9 -0
- package/dist/preact/src/hooks/useLoadMore/getNextPageQuery.d.ts +18 -0
- package/dist/preact/src/hooks/useLoadMore/useLoadMore.d.ts +24 -0
- package/dist/utils/src/isBot.d.ts +4 -0
- package/dist/utils/src/pick.d.ts +6 -0
- package/package.json +4 -3
package/dist/preact/preact.es.js
CHANGED
|
@@ -1,148 +1,105 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { s as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return n;
|
|
16
|
-
const o = e.updateElement(n, t);
|
|
17
|
-
return o === null ? null : (o.props = {
|
|
18
|
-
...o.props,
|
|
19
|
-
children: V({ ...e, children: o.props.children }, { depth: t.depth + 1 })
|
|
20
|
-
}, o);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
function $e({ children: e, onSearchInput: t }) {
|
|
24
|
-
return V({
|
|
25
|
-
children: e,
|
|
26
|
-
updateElement: (r) => (!ee(r) || r.props.type !== "search" || (r.props = {
|
|
27
|
-
...r.props,
|
|
28
|
-
onInput: (n) => {
|
|
29
|
-
n.target instanceof HTMLInputElement && t(n.target);
|
|
30
|
-
}
|
|
31
|
-
}), r)
|
|
32
|
-
});
|
|
1
|
+
import { options as U, createContext as W, Fragment as G, toChildArray as oe } from "preact";
|
|
2
|
+
import { useContext as q, useState as I, useEffect as x, useMemo as z, useCallback as w, useRef as se } from "preact/hooks";
|
|
3
|
+
import { s as ie } from "../search-B0-bVNMy.js";
|
|
4
|
+
import { s as E } from "../index.es-B8mbAxS4.js";
|
|
5
|
+
var ce = " daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|adscanner/|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|cookiehubscan|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|jsjcw_scanner|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scanner\\.|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|zgrab", ae = /bot|crawl|http|lighthouse|scan|search|spider/i, F;
|
|
6
|
+
function ue() {
|
|
7
|
+
if (F instanceof RegExp)
|
|
8
|
+
return F;
|
|
9
|
+
try {
|
|
10
|
+
F = new RegExp(ce, "i");
|
|
11
|
+
} catch {
|
|
12
|
+
F = ae;
|
|
13
|
+
}
|
|
14
|
+
return F;
|
|
33
15
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!e)
|
|
37
|
-
throw new Error("useConfig must be used within a ConfigProvider");
|
|
38
|
-
return e;
|
|
39
|
-
}, re = "nosto:search:scrollPos";
|
|
40
|
-
function ne() {
|
|
41
|
-
window.sessionStorage.setItem(re, window.scrollY.toString());
|
|
16
|
+
function le(e) {
|
|
17
|
+
return !!e && ue().test(e);
|
|
42
18
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
return V({
|
|
46
|
-
children: e,
|
|
47
|
-
updateElement: (u, i) => (i.depth > 0 || (u.props = {
|
|
48
|
-
...u.props,
|
|
49
|
-
onClick: (s) => {
|
|
50
|
-
t && o && q((l) => l.recordSearchClick(o, t)), ne(), typeof r == "function" && r(s);
|
|
51
|
-
}
|
|
52
|
-
}), u)
|
|
53
|
-
});
|
|
19
|
+
function J() {
|
|
20
|
+
return le(navigator.userAgent);
|
|
54
21
|
}
|
|
55
|
-
var
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
var
|
|
59
|
-
if ("ref" in l) for (
|
|
60
|
-
var
|
|
61
|
-
if (typeof e == "function" && (
|
|
62
|
-
return
|
|
63
|
-
}
|
|
64
|
-
function $() {
|
|
65
|
-
O(() => {
|
|
66
|
-
const e = window.setTimeout(() => {
|
|
67
|
-
console.error("Nosto client script has not loaded after 3 seconds.");
|
|
68
|
-
}, 3e3);
|
|
69
|
-
q(() => {
|
|
70
|
-
window.clearTimeout(e);
|
|
71
|
-
});
|
|
72
|
-
}, []);
|
|
22
|
+
var de = 0;
|
|
23
|
+
function S(e, r, t, n, o, c) {
|
|
24
|
+
r || (r = {});
|
|
25
|
+
var s, i, l = r;
|
|
26
|
+
if ("ref" in l) for (i in l = {}, r) i == "ref" ? s = r[i] : l[i] = r[i];
|
|
27
|
+
var a = { type: e, props: l, key: t, ref: s, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --de, __i: -1, __u: 0, __source: o, __self: c };
|
|
28
|
+
if (typeof e == "function" && (s = e.defaultProps)) for (i in s) l[i] === void 0 && (l[i] = s[i]);
|
|
29
|
+
return U.vnode && U.vnode(a), a;
|
|
73
30
|
}
|
|
74
|
-
const
|
|
31
|
+
const Q = (e) => String(e) === "[object Object]";
|
|
75
32
|
function P(e) {
|
|
76
|
-
if (!
|
|
33
|
+
if (!Q(e))
|
|
77
34
|
return !1;
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
35
|
+
const r = e.constructor;
|
|
36
|
+
if (r === void 0)
|
|
80
37
|
return !0;
|
|
81
|
-
const
|
|
82
|
-
return !(!
|
|
38
|
+
const t = r.prototype;
|
|
39
|
+
return !(!Q(t) || !t.hasOwnProperty("isPrototypeOf"));
|
|
83
40
|
}
|
|
84
|
-
function
|
|
85
|
-
return e.reduce((
|
|
41
|
+
function j(...e) {
|
|
42
|
+
return e.reduce((r, t) => $(r, t));
|
|
86
43
|
}
|
|
87
|
-
function
|
|
88
|
-
return e.reduce((
|
|
44
|
+
function K(...e) {
|
|
45
|
+
return e.reduce((r, t) => $(r, t));
|
|
89
46
|
}
|
|
90
|
-
function
|
|
91
|
-
return P(e) && P(
|
|
92
|
-
(
|
|
47
|
+
function $(e, r) {
|
|
48
|
+
return P(e) && P(r) ? Object.entries(r).reduce(
|
|
49
|
+
(t, [n, o]) => (t[n] = $(t[n], o), t),
|
|
93
50
|
{ ...e }
|
|
94
|
-
) : P(e) ? e :
|
|
51
|
+
) : P(e) ? e : r;
|
|
95
52
|
}
|
|
96
|
-
function
|
|
97
|
-
if (e ===
|
|
53
|
+
function M(e, r) {
|
|
54
|
+
if (e === r)
|
|
98
55
|
return !0;
|
|
99
|
-
if (e instanceof Date &&
|
|
100
|
-
return e.getTime() ===
|
|
101
|
-
if (Array.isArray(e) && Array.isArray(
|
|
102
|
-
return e.length !==
|
|
103
|
-
if (P(e) && P(
|
|
104
|
-
const
|
|
105
|
-
return
|
|
56
|
+
if (e instanceof Date && r instanceof Date)
|
|
57
|
+
return e.getTime() === r.getTime();
|
|
58
|
+
if (Array.isArray(e) && Array.isArray(r))
|
|
59
|
+
return e.length !== r.length ? !1 : e.every((t, n) => M(t, r[n]));
|
|
60
|
+
if (P(e) && P(r)) {
|
|
61
|
+
const t = Object.entries(e);
|
|
62
|
+
return t.length !== Object.keys(r).length ? !1 : t.every(([n, o]) => M(o, r[n]));
|
|
106
63
|
}
|
|
107
64
|
return !1;
|
|
108
65
|
}
|
|
109
|
-
function
|
|
110
|
-
const
|
|
111
|
-
let n =
|
|
112
|
-
const o =
|
|
113
|
-
function u
|
|
114
|
-
n =
|
|
115
|
-
for (const
|
|
116
|
-
|
|
66
|
+
function fe(e, r = {}) {
|
|
67
|
+
const t = /* @__PURE__ */ new Map();
|
|
68
|
+
let n = K(e, r ?? {});
|
|
69
|
+
const o = K(e, r);
|
|
70
|
+
function c(u) {
|
|
71
|
+
n = u(n);
|
|
72
|
+
for (const f of t.values())
|
|
73
|
+
f(n);
|
|
117
74
|
}
|
|
118
|
-
function
|
|
119
|
-
|
|
75
|
+
function s(u) {
|
|
76
|
+
c((f) => ({ ...f, ...u }));
|
|
120
77
|
}
|
|
121
|
-
function
|
|
78
|
+
function i() {
|
|
122
79
|
return n;
|
|
123
80
|
}
|
|
124
81
|
function l() {
|
|
125
82
|
return structuredClone(o);
|
|
126
83
|
}
|
|
127
|
-
function
|
|
84
|
+
function a(u, f) {
|
|
128
85
|
let m;
|
|
129
|
-
|
|
130
|
-
const h =
|
|
131
|
-
|
|
86
|
+
t.set(f, (p) => {
|
|
87
|
+
const h = u(p);
|
|
88
|
+
M(h, m) || (m = h, f(h));
|
|
132
89
|
});
|
|
133
90
|
}
|
|
134
|
-
function
|
|
135
|
-
|
|
91
|
+
function d(u) {
|
|
92
|
+
t.delete(u);
|
|
136
93
|
}
|
|
137
94
|
return {
|
|
138
|
-
updateState:
|
|
139
|
-
getState:
|
|
95
|
+
updateState: s,
|
|
96
|
+
getState: i,
|
|
140
97
|
getInitialState: l,
|
|
141
|
-
onChange:
|
|
142
|
-
clearOnChange:
|
|
98
|
+
onChange: a,
|
|
99
|
+
clearOnChange: d
|
|
143
100
|
};
|
|
144
101
|
}
|
|
145
|
-
const
|
|
102
|
+
const pe = {
|
|
146
103
|
loading: !0,
|
|
147
104
|
query: {
|
|
148
105
|
query: ""
|
|
@@ -152,74 +109,43 @@ const ie = {
|
|
|
152
109
|
},
|
|
153
110
|
initialized: !1
|
|
154
111
|
};
|
|
155
|
-
function
|
|
156
|
-
return
|
|
157
|
-
}
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
function
|
|
165
|
-
return
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
function De({ config: e, store: t, children: r }) {
|
|
172
|
-
const n = t ?? I();
|
|
173
|
-
return $(), /* @__PURE__ */ k(R, { value: ue(e), children: /* @__PURE__ */ k(M, { value: n, children: r }) });
|
|
174
|
-
}
|
|
175
|
-
const ae = {
|
|
176
|
-
...D,
|
|
177
|
-
persistentSearchCache: !1,
|
|
178
|
-
preservePageScroll: !1
|
|
179
|
-
};
|
|
180
|
-
function le(e) {
|
|
181
|
-
return {
|
|
182
|
-
pageType: "category",
|
|
183
|
-
...ae,
|
|
184
|
-
...e
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
function Ue({ config: e, store: t, children: r }) {
|
|
188
|
-
const n = t ?? I();
|
|
189
|
-
return $(), /* @__PURE__ */ k(R, { value: le(e), children: /* @__PURE__ */ k(M, { value: n, children: r }) });
|
|
112
|
+
function _(e = {}) {
|
|
113
|
+
return fe(pe, e);
|
|
114
|
+
}
|
|
115
|
+
const A = W(_());
|
|
116
|
+
function y(e = ge) {
|
|
117
|
+
const r = q(A), [t, n] = I(e(r.getState()));
|
|
118
|
+
return r.onChange(e, n), x(() => () => r.clearOnChange(n), [r]), t;
|
|
119
|
+
}
|
|
120
|
+
const ge = (e) => e;
|
|
121
|
+
function Y(e, ...r) {
|
|
122
|
+
return r.reduce(
|
|
123
|
+
(t, n) => (t[n] = e[n], t),
|
|
124
|
+
{}
|
|
125
|
+
);
|
|
190
126
|
}
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
127
|
+
const N = W(null), X = () => {
|
|
128
|
+
const e = q(N);
|
|
129
|
+
if (!e)
|
|
130
|
+
throw new Error("useConfig must be used within a ConfigProvider");
|
|
131
|
+
return e;
|
|
195
132
|
};
|
|
196
|
-
function
|
|
197
|
-
return {
|
|
198
|
-
pageType: "serp",
|
|
199
|
-
...fe,
|
|
200
|
-
...e
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
function Be({ config: e, store: t, children: r }) {
|
|
204
|
-
const n = t ?? I();
|
|
205
|
-
return $(), /* @__PURE__ */ k(R, { value: de(e), children: /* @__PURE__ */ k(M, { value: n, children: r }) });
|
|
206
|
-
}
|
|
207
|
-
function ge(e) {
|
|
133
|
+
function me(e) {
|
|
208
134
|
return Array.from(new Set(e));
|
|
209
135
|
}
|
|
210
|
-
function
|
|
136
|
+
function he(e, r) {
|
|
211
137
|
return {
|
|
212
|
-
...
|
|
138
|
+
...r,
|
|
213
139
|
products: {
|
|
214
140
|
facets: e === "autocomplete" ? void 0 : ["*"],
|
|
215
|
-
fields:
|
|
216
|
-
...
|
|
141
|
+
fields: ye,
|
|
142
|
+
...r.products
|
|
217
143
|
},
|
|
218
|
-
...
|
|
144
|
+
...r.keywords ? {
|
|
219
145
|
keywords: {
|
|
220
|
-
...
|
|
221
|
-
fields:
|
|
222
|
-
highlight:
|
|
146
|
+
...r.keywords,
|
|
147
|
+
fields: me([...ve, ...r.keywords.fields ?? []]),
|
|
148
|
+
highlight: r.keywords.highlight ?? {
|
|
223
149
|
preTag: "<strong>",
|
|
224
150
|
postTag: "</strong>"
|
|
225
151
|
}
|
|
@@ -227,7 +153,7 @@ function pe(e, t) {
|
|
|
227
153
|
} : {}
|
|
228
154
|
};
|
|
229
155
|
}
|
|
230
|
-
const
|
|
156
|
+
const ye = [
|
|
231
157
|
"productId",
|
|
232
158
|
"url",
|
|
233
159
|
"name",
|
|
@@ -279,62 +205,62 @@ const me = [
|
|
|
279
205
|
"tags1",
|
|
280
206
|
"tags2",
|
|
281
207
|
"tags3"
|
|
282
|
-
],
|
|
283
|
-
function
|
|
284
|
-
if (!e.every((
|
|
285
|
-
return e.filter((
|
|
208
|
+
], ve = ["keyword", "_redirect"];
|
|
209
|
+
function we(...e) {
|
|
210
|
+
if (!e.every((r) => r == null))
|
|
211
|
+
return e.filter((r) => Array.isArray(r)).reduce((r, t) => r.concat(t), []);
|
|
286
212
|
}
|
|
287
|
-
const
|
|
213
|
+
const Z = "nosto.search.";
|
|
288
214
|
function Se(e) {
|
|
289
|
-
var
|
|
290
|
-
const
|
|
291
|
-
(
|
|
215
|
+
var t;
|
|
216
|
+
const r = `${Z}${e}`;
|
|
217
|
+
(t = window.performance) == null || t.mark(`${r}.start`);
|
|
292
218
|
}
|
|
293
|
-
function
|
|
294
|
-
var
|
|
295
|
-
const
|
|
296
|
-
(
|
|
219
|
+
function be(e) {
|
|
220
|
+
var t, n;
|
|
221
|
+
const r = `${Z}${e}`;
|
|
222
|
+
(t = window.performance) == null || t.mark(`${r}.end`), (n = window.performance) == null || n.measure(r, `${r}.start`, `${r}.end`);
|
|
297
223
|
}
|
|
298
224
|
function T(e) {
|
|
299
|
-
return Se(e), () =>
|
|
225
|
+
return Se(e), () => be(e);
|
|
300
226
|
}
|
|
301
|
-
function
|
|
302
|
-
const n = JSON.stringify(
|
|
227
|
+
function ke(e, r, t) {
|
|
228
|
+
const n = JSON.stringify(r);
|
|
303
229
|
try {
|
|
304
|
-
console.info("Setting storage", e, n),
|
|
230
|
+
console.info("Setting storage", e, n), t.setItem(e, n);
|
|
305
231
|
} catch (o) {
|
|
306
232
|
console.warn(o);
|
|
307
233
|
}
|
|
308
234
|
}
|
|
309
|
-
function
|
|
235
|
+
function Ce(e, r) {
|
|
310
236
|
try {
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
313
|
-
return JSON.parse(
|
|
314
|
-
} catch (
|
|
315
|
-
console.warn(
|
|
237
|
+
const t = r.getItem(e);
|
|
238
|
+
if (t)
|
|
239
|
+
return JSON.parse(t);
|
|
240
|
+
} catch (t) {
|
|
241
|
+
console.warn(t);
|
|
316
242
|
}
|
|
317
243
|
}
|
|
318
|
-
function Pe(e,
|
|
319
|
-
|
|
244
|
+
function Pe(e, r) {
|
|
245
|
+
ke(e, r, sessionStorage);
|
|
320
246
|
}
|
|
321
|
-
function
|
|
322
|
-
return
|
|
247
|
+
function Fe(e) {
|
|
248
|
+
return Ce(e, sessionStorage);
|
|
323
249
|
}
|
|
324
|
-
const
|
|
325
|
-
function
|
|
250
|
+
const ee = "nosto:search:searchResult";
|
|
251
|
+
function Me(e, r, t) {
|
|
326
252
|
if (!e)
|
|
327
253
|
return;
|
|
328
|
-
Pe(
|
|
254
|
+
Pe(ee, { query: r, result: t });
|
|
329
255
|
}
|
|
330
|
-
function
|
|
256
|
+
function ze(e, r) {
|
|
331
257
|
if (!e)
|
|
332
258
|
return null;
|
|
333
|
-
const
|
|
334
|
-
if (!
|
|
259
|
+
const t = Fe(ee);
|
|
260
|
+
if (!t || !Ae(t))
|
|
335
261
|
return null;
|
|
336
|
-
const n = H(
|
|
337
|
-
return
|
|
262
|
+
const n = H(t.query);
|
|
263
|
+
return M(H(r), n) ? t.result : null;
|
|
338
264
|
}
|
|
339
265
|
function H(e) {
|
|
340
266
|
return {
|
|
@@ -350,295 +276,450 @@ function H(e) {
|
|
|
350
276
|
sessionParams: e.sessionParams
|
|
351
277
|
};
|
|
352
278
|
}
|
|
353
|
-
function
|
|
279
|
+
function Ae(e) {
|
|
354
280
|
return typeof e == "object" && e !== null && "query" in e && "result" in e;
|
|
355
281
|
}
|
|
356
|
-
async function
|
|
357
|
-
var
|
|
358
|
-
const n = T("newSearch"), o = e.config.pageType,
|
|
282
|
+
async function te(e, r, t) {
|
|
283
|
+
var a, d, u;
|
|
284
|
+
const n = T("newSearch"), o = e.config.pageType, c = j(e.store.getInitialState().query, r), s = j(e.config.search, t, {
|
|
359
285
|
track: o,
|
|
360
286
|
redirect: o !== "autocomplete",
|
|
361
|
-
isKeyword: !!(
|
|
287
|
+
isKeyword: !!(t != null && t.isKeyword)
|
|
362
288
|
});
|
|
363
289
|
e.store.updateState({
|
|
364
|
-
query:
|
|
290
|
+
query: c,
|
|
365
291
|
loading: !0,
|
|
366
292
|
initialized: !0
|
|
367
293
|
});
|
|
368
|
-
const
|
|
294
|
+
const i = o !== "autocomplete" && e.config.persistentSearchCache, l = e.config.queryModifications(
|
|
369
295
|
{
|
|
370
|
-
...
|
|
296
|
+
...c,
|
|
371
297
|
products: {
|
|
372
|
-
...
|
|
298
|
+
...c.products,
|
|
373
299
|
// Apply filter merging to avoid overwriting base filters
|
|
374
|
-
filter:
|
|
300
|
+
filter: we((d = (a = e.store.getInitialState().query) == null ? void 0 : a.products) == null ? void 0 : d.filter, (u = r.products) == null ? void 0 : u.filter)
|
|
375
301
|
}
|
|
376
302
|
},
|
|
377
303
|
o
|
|
378
304
|
);
|
|
379
305
|
try {
|
|
380
|
-
let
|
|
381
|
-
const m =
|
|
306
|
+
let f;
|
|
307
|
+
const m = ze(i, l);
|
|
382
308
|
if (m)
|
|
383
|
-
|
|
309
|
+
f = m;
|
|
384
310
|
else {
|
|
385
|
-
const
|
|
386
|
-
|
|
311
|
+
const p = he(o, l);
|
|
312
|
+
f = await ie(p, s), Me(i, l, f);
|
|
387
313
|
}
|
|
388
314
|
e.store.updateState({
|
|
389
|
-
response:
|
|
315
|
+
response: f,
|
|
390
316
|
loading: !1
|
|
391
317
|
});
|
|
392
|
-
} catch (
|
|
393
|
-
console.error("Search action failed",
|
|
318
|
+
} catch (f) {
|
|
319
|
+
console.error("Search action failed", f);
|
|
394
320
|
}
|
|
395
321
|
n();
|
|
396
322
|
}
|
|
397
|
-
async function
|
|
398
|
-
const n = T("updateSearch"), o =
|
|
399
|
-
await
|
|
323
|
+
async function V(e, r, t) {
|
|
324
|
+
const n = T("updateSearch"), o = j(e.store.getState().query, { products: { from: 0 } }, r);
|
|
325
|
+
await te(e, o, t), n();
|
|
400
326
|
}
|
|
401
|
-
async function
|
|
402
|
-
var
|
|
403
|
-
const n = T("replaceFilter"), o = (
|
|
404
|
-
await
|
|
327
|
+
async function Ie(e, r, t) {
|
|
328
|
+
var s;
|
|
329
|
+
const n = T("replaceFilter"), o = (s = e.store.getState().query.products) == null ? void 0 : s.filter, c = t !== void 0 ? [{ field: r, [typeof t == "object" ? "range" : "value"]: [t] }] : [];
|
|
330
|
+
await V(e, {
|
|
405
331
|
products: {
|
|
406
|
-
filter: [...(o == null ? void 0 : o.filter((
|
|
332
|
+
filter: [...(o == null ? void 0 : o.filter((i) => i.field !== r)) ?? [], ...c]
|
|
407
333
|
}
|
|
408
334
|
}), n();
|
|
409
335
|
}
|
|
410
|
-
async function
|
|
411
|
-
var l,
|
|
412
|
-
const o = T("toggleProductFilter"),
|
|
413
|
-
...
|
|
414
|
-
value: [...
|
|
336
|
+
async function Re(e, r, t, n) {
|
|
337
|
+
var l, a;
|
|
338
|
+
const o = T("toggleProductFilter"), c = (l = e.store.getState().query.products) == null ? void 0 : l.filter, s = c == null ? void 0 : c.find((d) => d.value instanceof Array && d.field === r), i = s != null && s.value ? {
|
|
339
|
+
...s,
|
|
340
|
+
value: [...s.value.filter((d) => !M(d, t)), ...n ? [t] : []]
|
|
415
341
|
} : n ? {
|
|
416
|
-
field:
|
|
417
|
-
value: [
|
|
342
|
+
field: r,
|
|
343
|
+
value: [t]
|
|
418
344
|
} : void 0;
|
|
419
|
-
await
|
|
345
|
+
await V(e, {
|
|
420
346
|
products: {
|
|
421
|
-
filter: [...(
|
|
347
|
+
filter: [...(c == null ? void 0 : c.filter((d) => d !== s)) ?? [], ...(a = i == null ? void 0 : i.value) != null && a.length ? [i] : []]
|
|
422
348
|
}
|
|
423
349
|
}), o();
|
|
424
350
|
}
|
|
425
|
-
function
|
|
426
|
-
const e =
|
|
351
|
+
function C() {
|
|
352
|
+
const e = X(), r = q(A), t = z(
|
|
427
353
|
() => ({
|
|
428
354
|
config: e,
|
|
429
|
-
store:
|
|
355
|
+
store: r
|
|
430
356
|
}),
|
|
431
|
-
[e,
|
|
432
|
-
), n =
|
|
433
|
-
(
|
|
434
|
-
[
|
|
435
|
-
), o =
|
|
436
|
-
(
|
|
437
|
-
[
|
|
438
|
-
),
|
|
439
|
-
(
|
|
440
|
-
[
|
|
441
|
-
),
|
|
442
|
-
(
|
|
443
|
-
[
|
|
357
|
+
[e, r]
|
|
358
|
+
), n = w(
|
|
359
|
+
(i, l) => te(t, i, l),
|
|
360
|
+
[t]
|
|
361
|
+
), o = w(
|
|
362
|
+
(i, l) => V(t, i, l),
|
|
363
|
+
[t]
|
|
364
|
+
), c = w(
|
|
365
|
+
(i, l, a) => Re(t, i, l, a),
|
|
366
|
+
[t]
|
|
367
|
+
), s = w(
|
|
368
|
+
(i, l) => Ie(t, i, l),
|
|
369
|
+
[t]
|
|
444
370
|
);
|
|
445
371
|
return {
|
|
446
372
|
newSearch: n,
|
|
447
373
|
updateSearch: o,
|
|
448
|
-
toggleProductFilter:
|
|
449
|
-
replaceFilter:
|
|
374
|
+
toggleProductFilter: c,
|
|
375
|
+
replaceFilter: s
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
function xe({ from: e, size: r, pageSize: t }) {
|
|
379
|
+
return J() ? {
|
|
380
|
+
products: { from: e + t }
|
|
381
|
+
} : {
|
|
382
|
+
products: { size: r + t }
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
function re(e = 24) {
|
|
386
|
+
const { from: r, size: t } = y((c) => {
|
|
387
|
+
var s, i;
|
|
388
|
+
return {
|
|
389
|
+
from: ((s = c.query.products) == null ? void 0 : s.from) ?? 0,
|
|
390
|
+
size: ((i = c.query.products) == null ? void 0 : i.size) ?? 0
|
|
391
|
+
};
|
|
392
|
+
}), { updateSearch: n } = C();
|
|
393
|
+
return {
|
|
394
|
+
loadMore: w(async () => {
|
|
395
|
+
await n(xe({ from: r, size: t, pageSize: e }));
|
|
396
|
+
}, [r, t, e, n])
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function _e({ pageSize: e }) {
|
|
400
|
+
const { loadMore: r } = re(e);
|
|
401
|
+
return /* @__PURE__ */ S("button", { onClick: r, children: "More results" });
|
|
402
|
+
}
|
|
403
|
+
function ne(e, r) {
|
|
404
|
+
var c, s, i;
|
|
405
|
+
const t = ((c = r.products) == null ? void 0 : c.total) ?? 0, n = ((s = e.products) == null ? void 0 : s.from) ?? 0, o = ((i = e.products) == null ? void 0 : i.size) ?? 0;
|
|
406
|
+
return t > 0 && t > n + o;
|
|
407
|
+
}
|
|
408
|
+
function Ne() {
|
|
409
|
+
return !!(window.IntersectionObserver && window.IntersectionObserverEntry && "intersectionRatio" in window.IntersectionObserverEntry.prototype);
|
|
410
|
+
}
|
|
411
|
+
function Te({ children: e, loadMoreComponent: r, pageSize: t }) {
|
|
412
|
+
const { loading: n, query: o, response: c } = y((i) => Y(i, "loading", "query", "response")), s = !n && ne(o, c);
|
|
413
|
+
return /* @__PURE__ */ S(G, { children: [
|
|
414
|
+
e,
|
|
415
|
+
s && (r ? /* @__PURE__ */ S(r, { pageSize: t }) : /* @__PURE__ */ S(_e, { pageSize: t }))
|
|
416
|
+
] });
|
|
417
|
+
}
|
|
418
|
+
function Oe({ children: e, pageSize: r }) {
|
|
419
|
+
const t = se(null), { query: n, response: o } = y((s) => Y(s, "query", "response")), { loadMore: c } = re(r);
|
|
420
|
+
return x(() => {
|
|
421
|
+
let s, i;
|
|
422
|
+
return ne(n, o) && (s = t.current, i = new IntersectionObserver((l) => {
|
|
423
|
+
const a = l[0];
|
|
424
|
+
a != null && a.isIntersecting && c();
|
|
425
|
+
}), s && i.observe(s)), () => {
|
|
426
|
+
s && i.unobserve(s);
|
|
427
|
+
};
|
|
428
|
+
}, [o]), /* @__PURE__ */ S(G, { children: [
|
|
429
|
+
e,
|
|
430
|
+
/* @__PURE__ */ S("div", { ref: t, style: { height: "1px" } })
|
|
431
|
+
] });
|
|
432
|
+
}
|
|
433
|
+
const tt = !J() && Ne() ? Oe : Te;
|
|
434
|
+
function je(e) {
|
|
435
|
+
return e.type === "input";
|
|
436
|
+
}
|
|
437
|
+
function qe(e) {
|
|
438
|
+
return !!e && typeof e == "object" && "type" in e && "props" in e;
|
|
439
|
+
}
|
|
440
|
+
function B(e, r = { depth: 0 }) {
|
|
441
|
+
const { children: t } = e;
|
|
442
|
+
return oe(t).map((n) => {
|
|
443
|
+
if (!qe(n))
|
|
444
|
+
return n;
|
|
445
|
+
const o = e.updateElement(n, r);
|
|
446
|
+
return o === null ? null : (o.props = {
|
|
447
|
+
...o.props,
|
|
448
|
+
children: B({ ...e, children: o.props.children }, { depth: r.depth + 1 })
|
|
449
|
+
}, o);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
function rt({ children: e, onSearchInput: r }) {
|
|
453
|
+
return B({
|
|
454
|
+
children: e,
|
|
455
|
+
updateElement: (t) => (!je(t) || t.props.type !== "search" || (t.props = {
|
|
456
|
+
...t.props,
|
|
457
|
+
onInput: (n) => {
|
|
458
|
+
n.target instanceof HTMLInputElement && r(n.target);
|
|
459
|
+
}
|
|
460
|
+
}), t)
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
const Ee = "nosto:search:scrollPos";
|
|
464
|
+
function $e() {
|
|
465
|
+
window.sessionStorage.setItem(Ee, window.scrollY.toString());
|
|
466
|
+
}
|
|
467
|
+
function nt({ children: e, hit: r, onClick: t }) {
|
|
468
|
+
const { pageType: n } = X(), o = n === "autocomplete" ? void 0 : n;
|
|
469
|
+
return B({
|
|
470
|
+
children: e,
|
|
471
|
+
updateElement: (c, s) => (s.depth > 0 || (c.props = {
|
|
472
|
+
...c.props,
|
|
473
|
+
onClick: (i) => {
|
|
474
|
+
r && o && E((l) => l.recordSearchClick(o, r)), $e(), typeof t == "function" && t(i);
|
|
475
|
+
}
|
|
476
|
+
}), c)
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
function D() {
|
|
480
|
+
x(() => {
|
|
481
|
+
const e = window.setTimeout(() => {
|
|
482
|
+
console.error("Nosto client script has not loaded after 3 seconds.");
|
|
483
|
+
}, 3e3);
|
|
484
|
+
E(() => {
|
|
485
|
+
window.clearTimeout(e);
|
|
486
|
+
});
|
|
487
|
+
}, []);
|
|
488
|
+
}
|
|
489
|
+
const L = {
|
|
490
|
+
defaultCurrency: "EUR",
|
|
491
|
+
queryModifications: (e) => e
|
|
492
|
+
}, Ve = {
|
|
493
|
+
...L
|
|
494
|
+
};
|
|
495
|
+
function Be(e) {
|
|
496
|
+
return {
|
|
497
|
+
pageType: "autocomplete",
|
|
498
|
+
...Ve,
|
|
499
|
+
...e
|
|
450
500
|
};
|
|
451
501
|
}
|
|
452
|
-
function
|
|
453
|
-
const
|
|
454
|
-
return
|
|
502
|
+
function ot({ config: e, store: r, children: t }) {
|
|
503
|
+
const n = r ?? _();
|
|
504
|
+
return D(), /* @__PURE__ */ S(N, { value: Be(e), children: /* @__PURE__ */ S(A, { value: n, children: t }) });
|
|
505
|
+
}
|
|
506
|
+
const De = {
|
|
507
|
+
...L,
|
|
508
|
+
persistentSearchCache: !1,
|
|
509
|
+
preservePageScroll: !1
|
|
510
|
+
};
|
|
511
|
+
function Le(e) {
|
|
512
|
+
return {
|
|
513
|
+
pageType: "category",
|
|
514
|
+
...De,
|
|
515
|
+
...e
|
|
516
|
+
};
|
|
455
517
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
return e && Array.isArray(e) || e && P(e) ? e : t;
|
|
518
|
+
function st({ config: e, store: r, children: t }) {
|
|
519
|
+
const n = r ?? _();
|
|
520
|
+
return D(), /* @__PURE__ */ S(N, { value: Le(e), children: /* @__PURE__ */ S(A, { value: n, children: t }) });
|
|
460
521
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
522
|
+
const Ue = {
|
|
523
|
+
...L,
|
|
524
|
+
persistentSearchCache: !1,
|
|
525
|
+
preservePageScroll: !1
|
|
526
|
+
};
|
|
527
|
+
function Qe(e = {}) {
|
|
528
|
+
return {
|
|
529
|
+
pageType: "serp",
|
|
530
|
+
...Ue,
|
|
531
|
+
...e
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
function it({ config: e, store: r, children: t }) {
|
|
535
|
+
const n = r ?? _();
|
|
536
|
+
return D(), /* @__PURE__ */ S(N, { value: Qe(e), children: /* @__PURE__ */ S(A, { value: n, children: t }) });
|
|
537
|
+
}
|
|
538
|
+
function ct(e) {
|
|
539
|
+
const r = y((t) => t.response);
|
|
540
|
+
return e && Array.isArray(e) || e && P(e) ? e : r;
|
|
541
|
+
}
|
|
542
|
+
function at(e) {
|
|
543
|
+
var s;
|
|
544
|
+
const r = ((s = e.data) == null ? void 0 : s.filter((i) => i.selected).length) ?? 0, [t, n] = I(r > 0), { toggleProductFilter: o } = C();
|
|
464
545
|
return {
|
|
465
546
|
/** Active value */
|
|
466
|
-
active:
|
|
547
|
+
active: t,
|
|
467
548
|
/** Selected filters count */
|
|
468
|
-
selectedFiltersCount:
|
|
549
|
+
selectedFiltersCount: r,
|
|
469
550
|
/** Toggle active function */
|
|
470
551
|
toggleActive: () => {
|
|
471
|
-
n(!
|
|
552
|
+
n(!t);
|
|
472
553
|
},
|
|
473
554
|
/** Toggle product filter function */
|
|
474
555
|
toggleProductFilter: o
|
|
475
556
|
};
|
|
476
557
|
}
|
|
477
|
-
function
|
|
478
|
-
const { loading: e, facets:
|
|
558
|
+
function ut() {
|
|
559
|
+
const { loading: e, facets: r } = y((t) => {
|
|
479
560
|
var n, o;
|
|
480
561
|
return {
|
|
481
|
-
loading:
|
|
482
|
-
facets: ((o = (n =
|
|
562
|
+
loading: t.loading,
|
|
563
|
+
facets: ((o = (n = t.response) == null ? void 0 : n.products) == null ? void 0 : o.facets) ?? []
|
|
483
564
|
};
|
|
484
565
|
});
|
|
485
566
|
return {
|
|
486
567
|
/** Loading state */
|
|
487
568
|
loading: e,
|
|
488
569
|
/** Array of facets*/
|
|
489
|
-
facets:
|
|
570
|
+
facets: r
|
|
490
571
|
};
|
|
491
572
|
}
|
|
492
|
-
function
|
|
493
|
-
const
|
|
494
|
-
return !isNaN(
|
|
573
|
+
function Ke(e, r) {
|
|
574
|
+
const t = r - e;
|
|
575
|
+
return !isNaN(t) && t > 0 ? new Array(r - e).fill(void 0).map((n, o) => o + e) : [];
|
|
495
576
|
}
|
|
496
|
-
function
|
|
497
|
-
const { query:
|
|
577
|
+
function lt(e) {
|
|
578
|
+
const { query: r, products: t } = y((n) => ({
|
|
498
579
|
query: n.query,
|
|
499
580
|
products: n.response.products
|
|
500
581
|
}));
|
|
501
|
-
return
|
|
502
|
-
var
|
|
503
|
-
if (!
|
|
582
|
+
return z(() => {
|
|
583
|
+
var k;
|
|
584
|
+
if (!t)
|
|
504
585
|
return {
|
|
505
586
|
totalPages: 0,
|
|
506
587
|
resultsFrom: 0,
|
|
507
588
|
resultsTo: 0,
|
|
508
589
|
pages: []
|
|
509
590
|
};
|
|
510
|
-
const n = ((
|
|
591
|
+
const n = ((k = r.products) == null ? void 0 : k.from) ?? 0, o = (e == null ? void 0 : e.width) ?? 1 / 0, c = Math.max(Math.floor(o - 1) / 2, 1), s = t.size > 0 ? Math.floor(n / t.size) + 1 : 1, i = t.size > 0 ? Math.ceil(t.total / t.size) : 0, l = (b) => b >= s - c && b <= s + c, a = n + 1, d = Math.min(n + t.total, t.total), u = {
|
|
511
592
|
from: n,
|
|
512
|
-
page:
|
|
593
|
+
page: s,
|
|
513
594
|
current: !0
|
|
514
|
-
},
|
|
515
|
-
from: (
|
|
516
|
-
page:
|
|
517
|
-
current:
|
|
518
|
-
}), m =
|
|
595
|
+
}, f = (b) => ({
|
|
596
|
+
from: (b - 1) * t.size,
|
|
597
|
+
page: b,
|
|
598
|
+
current: b === s
|
|
599
|
+
}), m = s > 1 ? f(s - 1) : void 0, p = s < i ? f(s + 1) : void 0, h = c === 1 / 0 || s - c - 1 > 1 ? f(1) : void 0, g = c === 1 / 0 || s + c + 1 < i ? f(i) : void 0, v = Ke(1, i + 1).filter(l).map(f);
|
|
519
600
|
return {
|
|
520
|
-
totalPages:
|
|
521
|
-
resultsFrom:
|
|
522
|
-
resultsTo:
|
|
523
|
-
current:
|
|
601
|
+
totalPages: i,
|
|
602
|
+
resultsFrom: a,
|
|
603
|
+
resultsTo: d,
|
|
604
|
+
current: u,
|
|
524
605
|
prev: m,
|
|
525
|
-
next:
|
|
606
|
+
next: p,
|
|
526
607
|
first: h,
|
|
527
|
-
last:
|
|
528
|
-
pages:
|
|
608
|
+
last: g,
|
|
609
|
+
pages: v
|
|
529
610
|
};
|
|
530
|
-
}, [
|
|
531
|
-
}
|
|
532
|
-
function
|
|
533
|
-
const [e,
|
|
534
|
-
return
|
|
535
|
-
|
|
536
|
-
const { products:
|
|
537
|
-
|
|
611
|
+
}, [r, t, e == null ? void 0 : e.width]);
|
|
612
|
+
}
|
|
613
|
+
function dt() {
|
|
614
|
+
const [e, r] = I([]), [t, n] = I([]);
|
|
615
|
+
return x(() => {
|
|
616
|
+
E(async (o) => {
|
|
617
|
+
const { products: c, segments: s } = await o.getSearchSessionParams();
|
|
618
|
+
r(s ?? []), n((c == null ? void 0 : c.personalizationBoost) ?? []);
|
|
538
619
|
});
|
|
539
620
|
}, []), {
|
|
540
621
|
segments: e,
|
|
541
|
-
boost:
|
|
622
|
+
boost: t
|
|
542
623
|
};
|
|
543
624
|
}
|
|
544
|
-
function
|
|
545
|
-
const { facets: e } =
|
|
546
|
-
var
|
|
625
|
+
function He() {
|
|
626
|
+
const { facets: e } = y((a) => {
|
|
627
|
+
var d;
|
|
547
628
|
return {
|
|
548
|
-
facets: ((
|
|
629
|
+
facets: ((d = a.response.products) == null ? void 0 : d.facets) ?? []
|
|
549
630
|
};
|
|
550
|
-
}), { replaceFilter:
|
|
551
|
-
(
|
|
552
|
-
const
|
|
553
|
-
if (
|
|
554
|
-
return
|
|
631
|
+
}), { replaceFilter: r, toggleProductFilter: t } = C(), n = w(
|
|
632
|
+
(a) => {
|
|
633
|
+
const d = e == null ? void 0 : e.find((u) => u.type === "stats" && u.field === a);
|
|
634
|
+
if (d && "min" in d && "max" in d)
|
|
635
|
+
return d;
|
|
555
636
|
},
|
|
556
637
|
[e]
|
|
557
|
-
), o =
|
|
558
|
-
(
|
|
559
|
-
var
|
|
560
|
-
return ((
|
|
638
|
+
), o = w(
|
|
639
|
+
(a) => {
|
|
640
|
+
var d;
|
|
641
|
+
return ((d = e == null ? void 0 : e.find((u) => u.field === a)) == null ? void 0 : d.name) ?? a;
|
|
561
642
|
},
|
|
562
643
|
[e]
|
|
563
|
-
),
|
|
564
|
-
var
|
|
644
|
+
), c = w((a) => "field" in a && (a.value instanceof Array || a.range instanceof Array), []), s = w((a) => {
|
|
645
|
+
var d;
|
|
565
646
|
return {
|
|
566
|
-
...
|
|
567
|
-
range: (
|
|
568
|
-
gt:
|
|
569
|
-
gte:
|
|
570
|
-
lt:
|
|
571
|
-
lte:
|
|
647
|
+
...a,
|
|
648
|
+
range: (d = a.range) == null ? void 0 : d.map((u) => ({
|
|
649
|
+
gt: u.gt ? Number(u.gt) : u.gt,
|
|
650
|
+
gte: u.gte ? Number(u.gte) : u.gte,
|
|
651
|
+
lt: u.lt ? Number(u.lt) : u.lt,
|
|
652
|
+
lte: u.lte ? Number(u.lte) : u.lte
|
|
572
653
|
}))
|
|
573
654
|
};
|
|
574
|
-
}, []),
|
|
575
|
-
(
|
|
576
|
-
value:
|
|
577
|
-
field:
|
|
578
|
-
name: o(
|
|
579
|
-
filter:
|
|
655
|
+
}, []), i = w(
|
|
656
|
+
(a) => (a.value ?? []).map((u) => ({
|
|
657
|
+
value: u,
|
|
658
|
+
field: a.field,
|
|
659
|
+
name: o(a.field),
|
|
660
|
+
filter: s(a),
|
|
580
661
|
remove: () => {
|
|
581
|
-
|
|
662
|
+
t(a.field, u, !1);
|
|
582
663
|
}
|
|
583
664
|
})),
|
|
584
|
-
[
|
|
585
|
-
), l =
|
|
586
|
-
(
|
|
587
|
-
var
|
|
588
|
-
const
|
|
589
|
-
if (
|
|
665
|
+
[s, o, t]
|
|
666
|
+
), l = w(
|
|
667
|
+
(a) => (a.range ?? []).map((u) => {
|
|
668
|
+
var p, h;
|
|
669
|
+
const f = u.gte ?? u.gt ?? ((p = n(a.field)) == null ? void 0 : p.min), m = u.lte ?? u.lt ?? ((h = n(a.field)) == null ? void 0 : h.max);
|
|
670
|
+
if (f !== void 0 && m !== void 0)
|
|
590
671
|
return {
|
|
591
|
-
value: `${
|
|
592
|
-
field:
|
|
593
|
-
name: o(
|
|
594
|
-
filter:
|
|
672
|
+
value: `${f} - ${m}`,
|
|
673
|
+
field: a.field,
|
|
674
|
+
name: o(a.field),
|
|
675
|
+
filter: s(a),
|
|
595
676
|
remove: () => {
|
|
596
|
-
|
|
677
|
+
r(a.field, void 0);
|
|
597
678
|
}
|
|
598
679
|
};
|
|
599
680
|
}).filter(Boolean),
|
|
600
|
-
[
|
|
681
|
+
[s, n, o, r]
|
|
601
682
|
);
|
|
602
683
|
return {
|
|
603
|
-
selectFilters:
|
|
604
|
-
toValueFilter:
|
|
684
|
+
selectFilters: c,
|
|
685
|
+
toValueFilter: i,
|
|
605
686
|
toRangeFilter: l
|
|
606
687
|
};
|
|
607
688
|
}
|
|
608
|
-
function
|
|
609
|
-
const { filter: e } =
|
|
689
|
+
function We() {
|
|
690
|
+
const { filter: e } = y((i) => {
|
|
610
691
|
var l;
|
|
611
692
|
return {
|
|
612
|
-
filter: ((l =
|
|
693
|
+
filter: ((l = i.query.products) == null ? void 0 : l.filter) ?? []
|
|
613
694
|
};
|
|
614
|
-
}), { updateSearch:
|
|
615
|
-
|
|
695
|
+
}), { updateSearch: r } = C(), { selectFilters: t, toValueFilter: n, toRangeFilter: o } = He(), c = z(() => e ? e.filter(t).flatMap((i) => "value" in i ? n(i) : "range" in i ? o(i) : []).filter(Boolean) : [], [e, t, o, n]), s = w(() => {
|
|
696
|
+
r({
|
|
616
697
|
products: {
|
|
617
698
|
filter: []
|
|
618
699
|
}
|
|
619
700
|
});
|
|
620
|
-
}, [
|
|
701
|
+
}, [r]);
|
|
621
702
|
return {
|
|
622
703
|
/** Selected filters array. */
|
|
623
|
-
filters:
|
|
704
|
+
filters: c,
|
|
624
705
|
/** Should remove all selected filters. */
|
|
625
|
-
removeAll:
|
|
706
|
+
removeAll: s
|
|
626
707
|
};
|
|
627
708
|
}
|
|
628
|
-
function
|
|
709
|
+
function R(e) {
|
|
629
710
|
if (typeof e == "number")
|
|
630
711
|
return e;
|
|
631
712
|
if (typeof e != "string")
|
|
632
713
|
return;
|
|
633
|
-
const
|
|
634
|
-
return isNaN(
|
|
635
|
-
}
|
|
636
|
-
function
|
|
637
|
-
var
|
|
638
|
-
const { replaceFilter:
|
|
639
|
-
query:
|
|
640
|
-
products:
|
|
641
|
-
})), o = (
|
|
714
|
+
const r = Number(e);
|
|
715
|
+
return isNaN(r) ? void 0 : r;
|
|
716
|
+
}
|
|
717
|
+
function Ge(e) {
|
|
718
|
+
var u, f, m;
|
|
719
|
+
const { replaceFilter: r } = C(), { query: t, products: n } = y((p) => ({
|
|
720
|
+
query: p.query,
|
|
721
|
+
products: p.response.products
|
|
722
|
+
})), o = (u = n == null ? void 0 : n.facets) == null ? void 0 : u.find((p) => p.id === e);
|
|
642
723
|
if (!o)
|
|
643
724
|
return {
|
|
644
725
|
min: 0,
|
|
@@ -647,140 +728,140 @@ function xe(e) {
|
|
|
647
728
|
updateRange: () => {
|
|
648
729
|
}
|
|
649
730
|
};
|
|
650
|
-
const
|
|
651
|
-
const
|
|
652
|
-
(l ===
|
|
653
|
-
lte:
|
|
654
|
-
}) : (
|
|
655
|
-
gte:
|
|
656
|
-
}) :
|
|
657
|
-
gte:
|
|
658
|
-
lte:
|
|
731
|
+
const c = (m = (f = t.products) == null ? void 0 : f.filter) == null ? void 0 : m.find((p) => p.field === o.field), s = c != null && c.range ? c.range[0] : void 0, i = typeof s == "object" && ("gte" in s || "lte" in s) ? [R(s.gte), R(s.lte)] : [void 0, void 0], l = "min" in o ? Math.floor(o.min) : 0, a = "max" in o ? Math.ceil(o.max) : 0, d = ([p, h]) => {
|
|
732
|
+
const g = p !== void 0 ? Math.floor(p) : void 0, v = h !== void 0 ? Math.ceil(h) : void 0, k = g !== void 0, b = v !== void 0;
|
|
733
|
+
(l === g || !k) && (a === v || !b) ? r(o.field, void 0) : (l === g || !k) && b ? r(o.field, {
|
|
734
|
+
lte: v.toString()
|
|
735
|
+
}) : (a === v || !b) && k ? r(o.field, {
|
|
736
|
+
gte: g.toString()
|
|
737
|
+
}) : k && b && r(o.field, {
|
|
738
|
+
gte: g.toString(),
|
|
739
|
+
lte: v.toString()
|
|
659
740
|
});
|
|
660
741
|
};
|
|
661
742
|
return {
|
|
662
743
|
/** Min value */
|
|
663
744
|
min: l,
|
|
664
745
|
/** Max value */
|
|
665
|
-
max:
|
|
746
|
+
max: a,
|
|
666
747
|
/** Range value */
|
|
667
|
-
range: [
|
|
748
|
+
range: [i[0] ?? l, i[1] ?? a],
|
|
668
749
|
/** Update range function */
|
|
669
|
-
updateRange:
|
|
750
|
+
updateRange: d
|
|
670
751
|
};
|
|
671
752
|
}
|
|
672
|
-
function
|
|
673
|
-
const { min:
|
|
753
|
+
function ft(e, r) {
|
|
754
|
+
const { min: t, max: n, range: o, updateRange: c } = Ge(e), { filters: s } = We(), i = z(() => {
|
|
674
755
|
var h;
|
|
675
|
-
const
|
|
676
|
-
var
|
|
677
|
-
return (
|
|
756
|
+
const u = s.find((g) => {
|
|
757
|
+
var v;
|
|
758
|
+
return (v = g == null ? void 0 : g.filter) == null ? void 0 : v.range;
|
|
678
759
|
});
|
|
679
|
-
let
|
|
680
|
-
if (
|
|
681
|
-
const
|
|
682
|
-
|
|
760
|
+
let f = null;
|
|
761
|
+
if (u) {
|
|
762
|
+
const g = (h = u.filter.range) == null ? void 0 : h[0];
|
|
763
|
+
f = [R(g == null ? void 0 : g.gte), R(g == null ? void 0 : g.lte)];
|
|
683
764
|
}
|
|
684
765
|
const m = [];
|
|
685
|
-
let
|
|
686
|
-
for (;
|
|
687
|
-
const
|
|
766
|
+
let p = Math.floor(t / r) * r;
|
|
767
|
+
for (; p < n; ) {
|
|
768
|
+
const g = p + r, v = f && f[0] === p && f[1] === g;
|
|
688
769
|
m.push({
|
|
689
|
-
min:
|
|
690
|
-
max:
|
|
691
|
-
selected:
|
|
692
|
-
}),
|
|
770
|
+
min: p,
|
|
771
|
+
max: g,
|
|
772
|
+
selected: v
|
|
773
|
+
}), p = g;
|
|
693
774
|
}
|
|
694
775
|
return m;
|
|
695
|
-
}, [
|
|
696
|
-
|
|
697
|
-
},
|
|
698
|
-
|
|
699
|
-
},
|
|
776
|
+
}, [s, t, n, r]), l = (u) => {
|
|
777
|
+
c([u, o[1]]);
|
|
778
|
+
}, a = (u) => {
|
|
779
|
+
c([o[0], u]);
|
|
780
|
+
}, d = t !== o[0] || n !== o[1];
|
|
700
781
|
return {
|
|
701
782
|
/** Minimum value */
|
|
702
|
-
min:
|
|
783
|
+
min: t,
|
|
703
784
|
/** Maximum value */
|
|
704
785
|
max: n,
|
|
705
786
|
/** Range value */
|
|
706
787
|
range: o,
|
|
707
788
|
/** Update range function */
|
|
708
|
-
updateRange:
|
|
789
|
+
updateRange: c,
|
|
709
790
|
/** Ranges */
|
|
710
|
-
ranges:
|
|
791
|
+
ranges: i,
|
|
711
792
|
/** Handle min change */
|
|
712
793
|
handleMinChange: l,
|
|
713
794
|
/** Handle max change */
|
|
714
|
-
handleMaxChange:
|
|
795
|
+
handleMaxChange: a,
|
|
715
796
|
/** Is selected */
|
|
716
|
-
isSelected:
|
|
797
|
+
isSelected: d
|
|
717
798
|
};
|
|
718
799
|
}
|
|
719
|
-
function
|
|
720
|
-
const { products: e, keywords:
|
|
800
|
+
function pt() {
|
|
801
|
+
const { products: e, keywords: r } = y((t) => t.response);
|
|
721
802
|
return {
|
|
722
803
|
/** Array of products */
|
|
723
804
|
products: e ?? { hits: [], total: 0 },
|
|
724
805
|
/** Array of keywords */
|
|
725
|
-
keywords:
|
|
806
|
+
keywords: r ?? { hits: [], total: 0 }
|
|
726
807
|
};
|
|
727
808
|
}
|
|
728
|
-
function
|
|
729
|
-
const e =
|
|
809
|
+
function gt() {
|
|
810
|
+
const e = y((t) => {
|
|
730
811
|
var n;
|
|
731
|
-
return (n =
|
|
812
|
+
return (n = t.query.products) == null ? void 0 : n.filter;
|
|
732
813
|
});
|
|
733
|
-
return
|
|
814
|
+
return z(() => e ? e.reduce((t, n) => t + (Array.isArray(n.value) ? n.value.length : 1), 0) : 0, [e]);
|
|
734
815
|
}
|
|
735
|
-
function
|
|
816
|
+
function O(e) {
|
|
736
817
|
return e && !Number.isNaN(e) ? e : 0;
|
|
737
818
|
}
|
|
738
|
-
function
|
|
739
|
-
const { from:
|
|
740
|
-
var
|
|
819
|
+
function mt(e, r) {
|
|
820
|
+
const { from: t, size: n, total: o } = y((a) => {
|
|
821
|
+
var d, u, f, m, p;
|
|
741
822
|
return {
|
|
742
|
-
from:
|
|
743
|
-
size:
|
|
744
|
-
total:
|
|
823
|
+
from: O(((d = a.query.products) == null ? void 0 : d.from) ?? 0),
|
|
824
|
+
size: O(((f = (u = a.response) == null ? void 0 : u.products) == null ? void 0 : f.size) ?? 0),
|
|
825
|
+
total: O(((p = (m = a.response) == null ? void 0 : m.products) == null ? void 0 : p.total) ?? 0)
|
|
745
826
|
};
|
|
746
|
-
}), { updateSearch:
|
|
827
|
+
}), { updateSearch: c } = C(), s = t + n, i = [...e].reverse().filter((a) => a + r < o);
|
|
747
828
|
return {
|
|
748
829
|
/** from value */
|
|
749
|
-
from:
|
|
830
|
+
from: t,
|
|
750
831
|
/** to value */
|
|
751
|
-
to:
|
|
832
|
+
to: s,
|
|
752
833
|
/** total value */
|
|
753
834
|
total: o,
|
|
754
835
|
/** size value */
|
|
755
836
|
size: n,
|
|
756
837
|
/** Array of size options */
|
|
757
|
-
sizeOptions:
|
|
838
|
+
sizeOptions: i,
|
|
758
839
|
/** Should be called when size is changed */
|
|
759
|
-
handleSizeChange: (
|
|
760
|
-
|
|
840
|
+
handleSizeChange: (a) => {
|
|
841
|
+
c({
|
|
761
842
|
products: {
|
|
762
|
-
size:
|
|
843
|
+
size: a
|
|
763
844
|
}
|
|
764
845
|
});
|
|
765
846
|
}
|
|
766
847
|
};
|
|
767
848
|
}
|
|
768
|
-
function
|
|
769
|
-
return e.length !==
|
|
849
|
+
function Je(e, r) {
|
|
850
|
+
return e.length !== r.length ? !1 : e.every((t) => r.find((n) => t.field === n.field && t.order === n.order));
|
|
770
851
|
}
|
|
771
|
-
function
|
|
772
|
-
var
|
|
773
|
-
const
|
|
852
|
+
function ht(e) {
|
|
853
|
+
var c, s;
|
|
854
|
+
const r = y((i) => i.query), { updateSearch: t } = C();
|
|
774
855
|
return {
|
|
775
856
|
/** Active sort */
|
|
776
|
-
activeSort: ((
|
|
857
|
+
activeSort: ((c = e.find((i) => {
|
|
777
858
|
var l;
|
|
778
|
-
return
|
|
779
|
-
})) == null ? void 0 :
|
|
859
|
+
return Je(i.value.sort, ((l = r.products) == null ? void 0 : l.sort) || []);
|
|
860
|
+
})) == null ? void 0 : c.id) ?? ((s = e[0]) == null ? void 0 : s.id),
|
|
780
861
|
/** Set sort function */
|
|
781
|
-
setSort: (
|
|
782
|
-
const l = e.find((
|
|
783
|
-
l &&
|
|
862
|
+
setSort: (i) => {
|
|
863
|
+
const l = e.find((a) => a.id === i);
|
|
864
|
+
l && t({
|
|
784
865
|
products: {
|
|
785
866
|
sort: l.value.sort
|
|
786
867
|
}
|
|
@@ -789,27 +870,29 @@ function Ze(e) {
|
|
|
789
870
|
};
|
|
790
871
|
}
|
|
791
872
|
export {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
873
|
+
ot as AutocompletePageProvider,
|
|
874
|
+
st as CategoryPageProvider,
|
|
875
|
+
tt as InfiniteScroll,
|
|
876
|
+
rt as SearchInput,
|
|
877
|
+
it as SearchPageProvider,
|
|
878
|
+
nt as SerpElement,
|
|
879
|
+
A as StoreContext,
|
|
880
|
+
fe as createExtendableStore,
|
|
881
|
+
_ as createStore,
|
|
882
|
+
pe as defaultState,
|
|
883
|
+
C as useActions,
|
|
884
|
+
ct as useDecoratedSearchResults,
|
|
885
|
+
at as useFacet,
|
|
886
|
+
ut as useFacets,
|
|
887
|
+
re as useLoadMore,
|
|
888
|
+
y as useNostoAppState,
|
|
889
|
+
lt as usePagination,
|
|
890
|
+
dt as usePersonalization,
|
|
891
|
+
We as useProductFilters,
|
|
892
|
+
Ge as useRange,
|
|
893
|
+
ft as useRangeSelector,
|
|
894
|
+
pt as useResponse,
|
|
895
|
+
gt as useSelectedFiltersCount,
|
|
896
|
+
mt as useSizeOptions,
|
|
897
|
+
ht as useSort
|
|
815
898
|
};
|