@nosto/search-js 1.6.0 → 1.7.1
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 +545 -466
- 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 +8 -7
package/dist/preact/preact.es.js
CHANGED
|
@@ -1,225 +1,147 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { options as U, createContext as W, Fragment as G, toChildArray as oe } from "preact";
|
|
2
|
+
import { useContext as E, 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";
|
|
2
4
|
import { s as q } from "../index.es-B8mbAxS4.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return X(r).map((n) => {
|
|
14
|
-
if (!te(n))
|
|
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
|
-
});
|
|
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
|
-
query: {
|
|
148
|
-
|
|
149
|
-
},
|
|
150
|
-
response: {
|
|
151
|
-
query: ""
|
|
152
|
-
},
|
|
104
|
+
query: {},
|
|
105
|
+
response: {},
|
|
153
106
|
initialized: !1
|
|
154
107
|
};
|
|
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 }) });
|
|
108
|
+
function _(e = {}) {
|
|
109
|
+
return fe(pe, e);
|
|
110
|
+
}
|
|
111
|
+
const A = W(_());
|
|
112
|
+
function y(e = ge) {
|
|
113
|
+
const r = E(A), [t, n] = I(e(r.getState()));
|
|
114
|
+
return r.onChange(e, n), x(() => () => r.clearOnChange(n), [r]), t;
|
|
115
|
+
}
|
|
116
|
+
const ge = (e) => e;
|
|
117
|
+
function Y(e, ...r) {
|
|
118
|
+
return r.reduce(
|
|
119
|
+
(t, n) => (t[n] = e[n], t),
|
|
120
|
+
{}
|
|
121
|
+
);
|
|
190
122
|
}
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
123
|
+
const N = W(null), X = () => {
|
|
124
|
+
const e = E(N);
|
|
125
|
+
if (!e)
|
|
126
|
+
throw new Error("useConfig must be used within a ConfigProvider");
|
|
127
|
+
return e;
|
|
195
128
|
};
|
|
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) {
|
|
129
|
+
function me(e) {
|
|
208
130
|
return Array.from(new Set(e));
|
|
209
131
|
}
|
|
210
|
-
function
|
|
132
|
+
function he(e, r) {
|
|
211
133
|
return {
|
|
212
|
-
...
|
|
134
|
+
...r,
|
|
213
135
|
products: {
|
|
214
136
|
facets: e === "autocomplete" ? void 0 : ["*"],
|
|
215
|
-
fields:
|
|
216
|
-
...
|
|
137
|
+
fields: ye,
|
|
138
|
+
...r.products
|
|
217
139
|
},
|
|
218
|
-
...
|
|
140
|
+
...r.keywords ? {
|
|
219
141
|
keywords: {
|
|
220
|
-
...
|
|
221
|
-
fields:
|
|
222
|
-
highlight:
|
|
142
|
+
...r.keywords,
|
|
143
|
+
fields: me([...ve, ...r.keywords.fields ?? []]),
|
|
144
|
+
highlight: r.keywords.highlight ?? {
|
|
223
145
|
preTag: "<strong>",
|
|
224
146
|
postTag: "</strong>"
|
|
225
147
|
}
|
|
@@ -227,7 +149,7 @@ function pe(e, t) {
|
|
|
227
149
|
} : {}
|
|
228
150
|
};
|
|
229
151
|
}
|
|
230
|
-
const
|
|
152
|
+
const ye = [
|
|
231
153
|
"productId",
|
|
232
154
|
"url",
|
|
233
155
|
"name",
|
|
@@ -279,62 +201,62 @@ const me = [
|
|
|
279
201
|
"tags1",
|
|
280
202
|
"tags2",
|
|
281
203
|
"tags3"
|
|
282
|
-
],
|
|
283
|
-
function
|
|
284
|
-
if (!e.every((
|
|
285
|
-
return e.filter((
|
|
204
|
+
], ve = ["keyword", "_redirect"];
|
|
205
|
+
function we(...e) {
|
|
206
|
+
if (!e.every((r) => r == null))
|
|
207
|
+
return e.filter((r) => Array.isArray(r)).reduce((r, t) => r.concat(t), []);
|
|
286
208
|
}
|
|
287
|
-
const
|
|
209
|
+
const Z = "nosto.search.";
|
|
288
210
|
function Se(e) {
|
|
289
|
-
var
|
|
290
|
-
const
|
|
291
|
-
(
|
|
211
|
+
var t;
|
|
212
|
+
const r = `${Z}${e}`;
|
|
213
|
+
(t = window.performance) == null || t.mark(`${r}.start`);
|
|
292
214
|
}
|
|
293
|
-
function
|
|
294
|
-
var
|
|
295
|
-
const
|
|
296
|
-
(
|
|
215
|
+
function be(e) {
|
|
216
|
+
var t, n;
|
|
217
|
+
const r = `${Z}${e}`;
|
|
218
|
+
(t = window.performance) == null || t.mark(`${r}.end`), (n = window.performance) == null || n.measure(r, `${r}.start`, `${r}.end`);
|
|
297
219
|
}
|
|
298
220
|
function T(e) {
|
|
299
|
-
return Se(e), () =>
|
|
221
|
+
return Se(e), () => be(e);
|
|
300
222
|
}
|
|
301
|
-
function
|
|
302
|
-
const n = JSON.stringify(
|
|
223
|
+
function ke(e, r, t) {
|
|
224
|
+
const n = JSON.stringify(r);
|
|
303
225
|
try {
|
|
304
|
-
console.info("Setting storage", e, n),
|
|
226
|
+
console.info("Setting storage", e, n), t.setItem(e, n);
|
|
305
227
|
} catch (o) {
|
|
306
228
|
console.warn(o);
|
|
307
229
|
}
|
|
308
230
|
}
|
|
309
|
-
function
|
|
231
|
+
function Ce(e, r) {
|
|
310
232
|
try {
|
|
311
|
-
const
|
|
312
|
-
if (
|
|
313
|
-
return JSON.parse(
|
|
314
|
-
} catch (
|
|
315
|
-
console.warn(
|
|
233
|
+
const t = r.getItem(e);
|
|
234
|
+
if (t)
|
|
235
|
+
return JSON.parse(t);
|
|
236
|
+
} catch (t) {
|
|
237
|
+
console.warn(t);
|
|
316
238
|
}
|
|
317
239
|
}
|
|
318
|
-
function Pe(e,
|
|
319
|
-
|
|
240
|
+
function Pe(e, r) {
|
|
241
|
+
ke(e, r, sessionStorage);
|
|
320
242
|
}
|
|
321
|
-
function
|
|
322
|
-
return
|
|
243
|
+
function Fe(e) {
|
|
244
|
+
return Ce(e, sessionStorage);
|
|
323
245
|
}
|
|
324
|
-
const
|
|
325
|
-
function
|
|
246
|
+
const ee = "nosto:search:searchResult";
|
|
247
|
+
function Me(e, r, t) {
|
|
326
248
|
if (!e)
|
|
327
249
|
return;
|
|
328
|
-
Pe(
|
|
250
|
+
Pe(ee, { query: r, result: t });
|
|
329
251
|
}
|
|
330
|
-
function
|
|
252
|
+
function ze(e, r) {
|
|
331
253
|
if (!e)
|
|
332
254
|
return null;
|
|
333
|
-
const
|
|
334
|
-
if (!
|
|
255
|
+
const t = Fe(ee);
|
|
256
|
+
if (!t || !Ae(t))
|
|
335
257
|
return null;
|
|
336
|
-
const n = H(
|
|
337
|
-
return
|
|
258
|
+
const n = H(t.query);
|
|
259
|
+
return M(H(r), n) ? t.result : null;
|
|
338
260
|
}
|
|
339
261
|
function H(e) {
|
|
340
262
|
return {
|
|
@@ -350,295 +272,450 @@ function H(e) {
|
|
|
350
272
|
sessionParams: e.sessionParams
|
|
351
273
|
};
|
|
352
274
|
}
|
|
353
|
-
function
|
|
275
|
+
function Ae(e) {
|
|
354
276
|
return typeof e == "object" && e !== null && "query" in e && "result" in e;
|
|
355
277
|
}
|
|
356
|
-
async function
|
|
357
|
-
var
|
|
358
|
-
const n = T("newSearch"), o = e.config.pageType,
|
|
278
|
+
async function te(e, r, t) {
|
|
279
|
+
var a, d, u;
|
|
280
|
+
const n = T("newSearch"), o = e.config.pageType, c = j(e.store.getInitialState().query, r), s = j(e.config.search, t, {
|
|
359
281
|
track: o,
|
|
360
282
|
redirect: o !== "autocomplete",
|
|
361
|
-
isKeyword: !!(
|
|
283
|
+
isKeyword: !!(t != null && t.isKeyword)
|
|
362
284
|
});
|
|
363
285
|
e.store.updateState({
|
|
364
|
-
query:
|
|
286
|
+
query: c,
|
|
365
287
|
loading: !0,
|
|
366
288
|
initialized: !0
|
|
367
289
|
});
|
|
368
|
-
const
|
|
290
|
+
const i = o !== "autocomplete" && e.config.persistentSearchCache, l = e.config.queryModifications(
|
|
369
291
|
{
|
|
370
|
-
...
|
|
292
|
+
...c,
|
|
371
293
|
products: {
|
|
372
|
-
...
|
|
294
|
+
...c.products,
|
|
373
295
|
// Apply filter merging to avoid overwriting base filters
|
|
374
|
-
filter:
|
|
296
|
+
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
297
|
}
|
|
376
298
|
},
|
|
377
299
|
o
|
|
378
300
|
);
|
|
379
301
|
try {
|
|
380
|
-
let
|
|
381
|
-
const m =
|
|
302
|
+
let f;
|
|
303
|
+
const m = ze(i, l);
|
|
382
304
|
if (m)
|
|
383
|
-
|
|
305
|
+
f = m;
|
|
384
306
|
else {
|
|
385
|
-
const
|
|
386
|
-
|
|
307
|
+
const p = he(o, l);
|
|
308
|
+
f = await ie(p, s), Me(i, l, f);
|
|
387
309
|
}
|
|
388
310
|
e.store.updateState({
|
|
389
|
-
response:
|
|
311
|
+
response: f,
|
|
390
312
|
loading: !1
|
|
391
313
|
});
|
|
392
|
-
} catch (
|
|
393
|
-
console.error("Search action failed",
|
|
314
|
+
} catch (f) {
|
|
315
|
+
console.error("Search action failed", f);
|
|
394
316
|
}
|
|
395
317
|
n();
|
|
396
318
|
}
|
|
397
|
-
async function
|
|
398
|
-
const n = T("updateSearch"), o =
|
|
399
|
-
await
|
|
319
|
+
async function V(e, r, t) {
|
|
320
|
+
const n = T("updateSearch"), o = j(e.store.getState().query, { products: { from: 0 } }, r);
|
|
321
|
+
await te(e, o, t), n();
|
|
400
322
|
}
|
|
401
|
-
async function
|
|
402
|
-
var
|
|
403
|
-
const n = T("replaceFilter"), o = (
|
|
404
|
-
await
|
|
323
|
+
async function Ie(e, r, t) {
|
|
324
|
+
var s;
|
|
325
|
+
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] }] : [];
|
|
326
|
+
await V(e, {
|
|
405
327
|
products: {
|
|
406
|
-
filter: [...(o == null ? void 0 : o.filter((
|
|
328
|
+
filter: [...(o == null ? void 0 : o.filter((i) => i.field !== r)) ?? [], ...c]
|
|
407
329
|
}
|
|
408
330
|
}), n();
|
|
409
331
|
}
|
|
410
|
-
async function
|
|
411
|
-
var l,
|
|
412
|
-
const o = T("toggleProductFilter"),
|
|
413
|
-
...
|
|
414
|
-
value: [...
|
|
332
|
+
async function Re(e, r, t, n) {
|
|
333
|
+
var l, a;
|
|
334
|
+
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 ? {
|
|
335
|
+
...s,
|
|
336
|
+
value: [...s.value.filter((d) => !M(d, t)), ...n ? [t] : []]
|
|
415
337
|
} : n ? {
|
|
416
|
-
field:
|
|
417
|
-
value: [
|
|
338
|
+
field: r,
|
|
339
|
+
value: [t]
|
|
418
340
|
} : void 0;
|
|
419
|
-
await
|
|
341
|
+
await V(e, {
|
|
420
342
|
products: {
|
|
421
|
-
filter: [...(
|
|
343
|
+
filter: [...(c == null ? void 0 : c.filter((d) => d !== s)) ?? [], ...(a = i == null ? void 0 : i.value) != null && a.length ? [i] : []]
|
|
422
344
|
}
|
|
423
345
|
}), o();
|
|
424
346
|
}
|
|
425
|
-
function
|
|
426
|
-
const e =
|
|
347
|
+
function C() {
|
|
348
|
+
const e = X(), r = E(A), t = z(
|
|
427
349
|
() => ({
|
|
428
350
|
config: e,
|
|
429
|
-
store:
|
|
351
|
+
store: r
|
|
430
352
|
}),
|
|
431
|
-
[e,
|
|
432
|
-
), n =
|
|
433
|
-
(
|
|
434
|
-
[
|
|
435
|
-
), o =
|
|
436
|
-
(
|
|
437
|
-
[
|
|
438
|
-
),
|
|
439
|
-
(
|
|
440
|
-
[
|
|
441
|
-
),
|
|
442
|
-
(
|
|
443
|
-
[
|
|
353
|
+
[e, r]
|
|
354
|
+
), n = w(
|
|
355
|
+
(i, l) => te(t, i, l),
|
|
356
|
+
[t]
|
|
357
|
+
), o = w(
|
|
358
|
+
(i, l) => V(t, i, l),
|
|
359
|
+
[t]
|
|
360
|
+
), c = w(
|
|
361
|
+
(i, l, a) => Re(t, i, l, a),
|
|
362
|
+
[t]
|
|
363
|
+
), s = w(
|
|
364
|
+
(i, l) => Ie(t, i, l),
|
|
365
|
+
[t]
|
|
444
366
|
);
|
|
445
367
|
return {
|
|
446
368
|
newSearch: n,
|
|
447
369
|
updateSearch: o,
|
|
448
|
-
toggleProductFilter:
|
|
449
|
-
replaceFilter:
|
|
370
|
+
toggleProductFilter: c,
|
|
371
|
+
replaceFilter: s
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
function xe({ from: e, size: r, pageSize: t }) {
|
|
375
|
+
return J() ? {
|
|
376
|
+
products: { from: e + t }
|
|
377
|
+
} : {
|
|
378
|
+
products: { size: r + t }
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
function re(e = 24) {
|
|
382
|
+
const { from: r, size: t } = y((c) => {
|
|
383
|
+
var s, i;
|
|
384
|
+
return {
|
|
385
|
+
from: ((s = c.query.products) == null ? void 0 : s.from) ?? 0,
|
|
386
|
+
size: ((i = c.query.products) == null ? void 0 : i.size) ?? 0
|
|
387
|
+
};
|
|
388
|
+
}), { updateSearch: n } = C();
|
|
389
|
+
return {
|
|
390
|
+
loadMore: w(async () => {
|
|
391
|
+
await n(xe({ from: r, size: t, pageSize: e }));
|
|
392
|
+
}, [r, t, e, n])
|
|
450
393
|
};
|
|
451
394
|
}
|
|
452
|
-
function
|
|
453
|
-
const
|
|
454
|
-
return
|
|
395
|
+
function _e({ pageSize: e }) {
|
|
396
|
+
const { loadMore: r } = re(e);
|
|
397
|
+
return /* @__PURE__ */ S("button", { onClick: r, children: "More results" });
|
|
398
|
+
}
|
|
399
|
+
function ne(e, r) {
|
|
400
|
+
var c, s, i;
|
|
401
|
+
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;
|
|
402
|
+
return t > 0 && t > n + o;
|
|
403
|
+
}
|
|
404
|
+
function Ne() {
|
|
405
|
+
return !!(window.IntersectionObserver && window.IntersectionObserverEntry && "intersectionRatio" in window.IntersectionObserverEntry.prototype);
|
|
406
|
+
}
|
|
407
|
+
function Te({ children: e, loadMoreComponent: r, pageSize: t }) {
|
|
408
|
+
const { loading: n, query: o, response: c } = y((i) => Y(i, "loading", "query", "response")), s = !n && ne(o, c);
|
|
409
|
+
return /* @__PURE__ */ S(G, { children: [
|
|
410
|
+
e,
|
|
411
|
+
s && (r ? /* @__PURE__ */ S(r, { pageSize: t }) : /* @__PURE__ */ S(_e, { pageSize: t }))
|
|
412
|
+
] });
|
|
413
|
+
}
|
|
414
|
+
function Oe({ children: e, pageSize: r }) {
|
|
415
|
+
const t = se(null), { query: n, response: o } = y((s) => Y(s, "query", "response")), { loadMore: c } = re(r);
|
|
416
|
+
return x(() => {
|
|
417
|
+
let s, i;
|
|
418
|
+
return ne(n, o) && (s = t.current, i = new IntersectionObserver((l) => {
|
|
419
|
+
const a = l[0];
|
|
420
|
+
a != null && a.isIntersecting && c();
|
|
421
|
+
}), s && i.observe(s)), () => {
|
|
422
|
+
s && i.unobserve(s);
|
|
423
|
+
};
|
|
424
|
+
}, [o]), /* @__PURE__ */ S(G, { children: [
|
|
425
|
+
e,
|
|
426
|
+
/* @__PURE__ */ S("div", { ref: t, style: { height: "1px" } })
|
|
427
|
+
] });
|
|
428
|
+
}
|
|
429
|
+
const tt = !J() && Ne() ? Oe : Te;
|
|
430
|
+
function je(e) {
|
|
431
|
+
return e.type === "input";
|
|
432
|
+
}
|
|
433
|
+
function Ee(e) {
|
|
434
|
+
return !!e && typeof e == "object" && "type" in e && "props" in e;
|
|
435
|
+
}
|
|
436
|
+
function B(e, r = { depth: 0 }) {
|
|
437
|
+
const { children: t } = e;
|
|
438
|
+
return oe(t).map((n) => {
|
|
439
|
+
if (!Ee(n))
|
|
440
|
+
return n;
|
|
441
|
+
const o = e.updateElement(n, r);
|
|
442
|
+
return o === null ? null : (o.props = {
|
|
443
|
+
...o.props,
|
|
444
|
+
children: B({ ...e, children: o.props.children }, { depth: r.depth + 1 })
|
|
445
|
+
}, o);
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
function rt({ children: e, onSearchInput: r }) {
|
|
449
|
+
return B({
|
|
450
|
+
children: e,
|
|
451
|
+
updateElement: (t) => (!je(t) || t.props.type !== "search" || (t.props = {
|
|
452
|
+
...t.props,
|
|
453
|
+
onInput: (n) => {
|
|
454
|
+
n.target instanceof HTMLInputElement && r(n.target);
|
|
455
|
+
}
|
|
456
|
+
}), t)
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
const qe = "nosto:search:scrollPos";
|
|
460
|
+
function $e() {
|
|
461
|
+
window.sessionStorage.setItem(qe, window.scrollY.toString());
|
|
455
462
|
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
463
|
+
function nt({ children: e, hit: r, onClick: t }) {
|
|
464
|
+
const { pageType: n } = X(), o = n === "autocomplete" ? void 0 : n;
|
|
465
|
+
return B({
|
|
466
|
+
children: e,
|
|
467
|
+
updateElement: (c, s) => (s.depth > 0 || (c.props = {
|
|
468
|
+
...c.props,
|
|
469
|
+
onClick: (i) => {
|
|
470
|
+
r && o && q((l) => l.recordSearchClick(o, r)), $e(), typeof t == "function" && t(i);
|
|
471
|
+
}
|
|
472
|
+
}), c)
|
|
473
|
+
});
|
|
460
474
|
}
|
|
461
|
-
function
|
|
462
|
-
|
|
463
|
-
|
|
475
|
+
function D() {
|
|
476
|
+
x(() => {
|
|
477
|
+
const e = window.setTimeout(() => {
|
|
478
|
+
console.error("Nosto client script has not loaded after 3 seconds.");
|
|
479
|
+
}, 3e3);
|
|
480
|
+
q(() => {
|
|
481
|
+
window.clearTimeout(e);
|
|
482
|
+
});
|
|
483
|
+
}, []);
|
|
484
|
+
}
|
|
485
|
+
const L = {
|
|
486
|
+
defaultCurrency: "EUR",
|
|
487
|
+
queryModifications: (e) => e
|
|
488
|
+
}, Ve = {
|
|
489
|
+
...L
|
|
490
|
+
};
|
|
491
|
+
function Be(e) {
|
|
492
|
+
return {
|
|
493
|
+
pageType: "autocomplete",
|
|
494
|
+
...Ve,
|
|
495
|
+
...e
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function ot({ config: e, store: r, children: t }) {
|
|
499
|
+
const n = r ?? _();
|
|
500
|
+
return D(), /* @__PURE__ */ S(N, { value: Be(e), children: /* @__PURE__ */ S(A, { value: n, children: t }) });
|
|
501
|
+
}
|
|
502
|
+
const De = {
|
|
503
|
+
...L,
|
|
504
|
+
persistentSearchCache: !1,
|
|
505
|
+
preservePageScroll: !1
|
|
506
|
+
};
|
|
507
|
+
function Le(e) {
|
|
508
|
+
return {
|
|
509
|
+
pageType: "category",
|
|
510
|
+
...De,
|
|
511
|
+
...e
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
function st({ config: e, store: r, children: t }) {
|
|
515
|
+
const n = r ?? _();
|
|
516
|
+
return D(), /* @__PURE__ */ S(N, { value: Le(e), children: /* @__PURE__ */ S(A, { value: n, children: t }) });
|
|
517
|
+
}
|
|
518
|
+
const Ue = {
|
|
519
|
+
...L,
|
|
520
|
+
persistentSearchCache: !1,
|
|
521
|
+
preservePageScroll: !1
|
|
522
|
+
};
|
|
523
|
+
function Qe(e = {}) {
|
|
524
|
+
return {
|
|
525
|
+
pageType: "serp",
|
|
526
|
+
...Ue,
|
|
527
|
+
...e
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
function it({ config: e, store: r, children: t }) {
|
|
531
|
+
const n = r ?? _();
|
|
532
|
+
return D(), /* @__PURE__ */ S(N, { value: Qe(e), children: /* @__PURE__ */ S(A, { value: n, children: t }) });
|
|
533
|
+
}
|
|
534
|
+
function ct(e) {
|
|
535
|
+
const r = y((t) => t.response);
|
|
536
|
+
return e && Array.isArray(e) || e && P(e) ? e : r;
|
|
537
|
+
}
|
|
538
|
+
function at(e) {
|
|
539
|
+
var s;
|
|
540
|
+
const r = ((s = e.data) == null ? void 0 : s.filter((i) => i.selected).length) ?? 0, [t, n] = I(r > 0), { toggleProductFilter: o } = C();
|
|
464
541
|
return {
|
|
465
542
|
/** Active value */
|
|
466
|
-
active:
|
|
543
|
+
active: t,
|
|
467
544
|
/** Selected filters count */
|
|
468
|
-
selectedFiltersCount:
|
|
545
|
+
selectedFiltersCount: r,
|
|
469
546
|
/** Toggle active function */
|
|
470
547
|
toggleActive: () => {
|
|
471
|
-
n(!
|
|
548
|
+
n(!t);
|
|
472
549
|
},
|
|
473
550
|
/** Toggle product filter function */
|
|
474
551
|
toggleProductFilter: o
|
|
475
552
|
};
|
|
476
553
|
}
|
|
477
|
-
function
|
|
478
|
-
const { loading: e, facets:
|
|
554
|
+
function ut() {
|
|
555
|
+
const { loading: e, facets: r } = y((t) => {
|
|
479
556
|
var n, o;
|
|
480
557
|
return {
|
|
481
|
-
loading:
|
|
482
|
-
facets: ((o = (n =
|
|
558
|
+
loading: t.loading,
|
|
559
|
+
facets: ((o = (n = t.response) == null ? void 0 : n.products) == null ? void 0 : o.facets) ?? []
|
|
483
560
|
};
|
|
484
561
|
});
|
|
485
562
|
return {
|
|
486
563
|
/** Loading state */
|
|
487
564
|
loading: e,
|
|
488
565
|
/** Array of facets*/
|
|
489
|
-
facets:
|
|
566
|
+
facets: r
|
|
490
567
|
};
|
|
491
568
|
}
|
|
492
|
-
function
|
|
493
|
-
const
|
|
494
|
-
return !isNaN(
|
|
569
|
+
function Ke(e, r) {
|
|
570
|
+
const t = r - e;
|
|
571
|
+
return !isNaN(t) && t > 0 ? new Array(r - e).fill(void 0).map((n, o) => o + e) : [];
|
|
495
572
|
}
|
|
496
|
-
function
|
|
497
|
-
const { query:
|
|
573
|
+
function lt(e) {
|
|
574
|
+
const { query: r, products: t } = y((n) => ({
|
|
498
575
|
query: n.query,
|
|
499
576
|
products: n.response.products
|
|
500
577
|
}));
|
|
501
|
-
return
|
|
502
|
-
var
|
|
503
|
-
if (!
|
|
578
|
+
return z(() => {
|
|
579
|
+
var k;
|
|
580
|
+
if (!t)
|
|
504
581
|
return {
|
|
505
582
|
totalPages: 0,
|
|
506
583
|
resultsFrom: 0,
|
|
507
584
|
resultsTo: 0,
|
|
508
585
|
pages: []
|
|
509
586
|
};
|
|
510
|
-
const n = ((
|
|
587
|
+
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
588
|
from: n,
|
|
512
|
-
page:
|
|
589
|
+
page: s,
|
|
513
590
|
current: !0
|
|
514
|
-
},
|
|
515
|
-
from: (
|
|
516
|
-
page:
|
|
517
|
-
current:
|
|
518
|
-
}), m =
|
|
591
|
+
}, f = (b) => ({
|
|
592
|
+
from: (b - 1) * t.size,
|
|
593
|
+
page: b,
|
|
594
|
+
current: b === s
|
|
595
|
+
}), 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
596
|
return {
|
|
520
|
-
totalPages:
|
|
521
|
-
resultsFrom:
|
|
522
|
-
resultsTo:
|
|
523
|
-
current:
|
|
597
|
+
totalPages: i,
|
|
598
|
+
resultsFrom: a,
|
|
599
|
+
resultsTo: d,
|
|
600
|
+
current: u,
|
|
524
601
|
prev: m,
|
|
525
|
-
next:
|
|
602
|
+
next: p,
|
|
526
603
|
first: h,
|
|
527
|
-
last:
|
|
528
|
-
pages:
|
|
604
|
+
last: g,
|
|
605
|
+
pages: v
|
|
529
606
|
};
|
|
530
|
-
}, [
|
|
607
|
+
}, [r, t, e == null ? void 0 : e.width]);
|
|
531
608
|
}
|
|
532
|
-
function
|
|
533
|
-
const [e,
|
|
534
|
-
return
|
|
609
|
+
function dt() {
|
|
610
|
+
const [e, r] = I([]), [t, n] = I([]);
|
|
611
|
+
return x(() => {
|
|
535
612
|
q(async (o) => {
|
|
536
|
-
const { products:
|
|
537
|
-
|
|
613
|
+
const { products: c, segments: s } = await o.getSearchSessionParams();
|
|
614
|
+
r(s ?? []), n((c == null ? void 0 : c.personalizationBoost) ?? []);
|
|
538
615
|
});
|
|
539
616
|
}, []), {
|
|
540
617
|
segments: e,
|
|
541
|
-
boost:
|
|
618
|
+
boost: t
|
|
542
619
|
};
|
|
543
620
|
}
|
|
544
|
-
function
|
|
545
|
-
const { facets: e } =
|
|
546
|
-
var
|
|
621
|
+
function He() {
|
|
622
|
+
const { facets: e } = y((a) => {
|
|
623
|
+
var d;
|
|
547
624
|
return {
|
|
548
|
-
facets: ((
|
|
625
|
+
facets: ((d = a.response.products) == null ? void 0 : d.facets) ?? []
|
|
549
626
|
};
|
|
550
|
-
}), { replaceFilter:
|
|
551
|
-
(
|
|
552
|
-
const
|
|
553
|
-
if (
|
|
554
|
-
return
|
|
627
|
+
}), { replaceFilter: r, toggleProductFilter: t } = C(), n = w(
|
|
628
|
+
(a) => {
|
|
629
|
+
const d = e == null ? void 0 : e.find((u) => u.type === "stats" && u.field === a);
|
|
630
|
+
if (d && "min" in d && "max" in d)
|
|
631
|
+
return d;
|
|
555
632
|
},
|
|
556
633
|
[e]
|
|
557
|
-
), o =
|
|
558
|
-
(
|
|
559
|
-
var
|
|
560
|
-
return ((
|
|
634
|
+
), o = w(
|
|
635
|
+
(a) => {
|
|
636
|
+
var d;
|
|
637
|
+
return ((d = e == null ? void 0 : e.find((u) => u.field === a)) == null ? void 0 : d.name) ?? a;
|
|
561
638
|
},
|
|
562
639
|
[e]
|
|
563
|
-
),
|
|
564
|
-
var
|
|
640
|
+
), c = w((a) => "field" in a && (a.value instanceof Array || a.range instanceof Array), []), s = w((a) => {
|
|
641
|
+
var d;
|
|
565
642
|
return {
|
|
566
|
-
...
|
|
567
|
-
range: (
|
|
568
|
-
gt:
|
|
569
|
-
gte:
|
|
570
|
-
lt:
|
|
571
|
-
lte:
|
|
643
|
+
...a,
|
|
644
|
+
range: (d = a.range) == null ? void 0 : d.map((u) => ({
|
|
645
|
+
gt: u.gt ? Number(u.gt) : u.gt,
|
|
646
|
+
gte: u.gte ? Number(u.gte) : u.gte,
|
|
647
|
+
lt: u.lt ? Number(u.lt) : u.lt,
|
|
648
|
+
lte: u.lte ? Number(u.lte) : u.lte
|
|
572
649
|
}))
|
|
573
650
|
};
|
|
574
|
-
}, []),
|
|
575
|
-
(
|
|
576
|
-
value:
|
|
577
|
-
field:
|
|
578
|
-
name: o(
|
|
579
|
-
filter:
|
|
651
|
+
}, []), i = w(
|
|
652
|
+
(a) => (a.value ?? []).map((u) => ({
|
|
653
|
+
value: u,
|
|
654
|
+
field: a.field,
|
|
655
|
+
name: o(a.field),
|
|
656
|
+
filter: s(a),
|
|
580
657
|
remove: () => {
|
|
581
|
-
|
|
658
|
+
t(a.field, u, !1);
|
|
582
659
|
}
|
|
583
660
|
})),
|
|
584
|
-
[
|
|
585
|
-
), l =
|
|
586
|
-
(
|
|
587
|
-
var
|
|
588
|
-
const
|
|
589
|
-
if (
|
|
661
|
+
[s, o, t]
|
|
662
|
+
), l = w(
|
|
663
|
+
(a) => (a.range ?? []).map((u) => {
|
|
664
|
+
var p, h;
|
|
665
|
+
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);
|
|
666
|
+
if (f !== void 0 && m !== void 0)
|
|
590
667
|
return {
|
|
591
|
-
value: `${
|
|
592
|
-
field:
|
|
593
|
-
name: o(
|
|
594
|
-
filter:
|
|
668
|
+
value: `${f} - ${m}`,
|
|
669
|
+
field: a.field,
|
|
670
|
+
name: o(a.field),
|
|
671
|
+
filter: s(a),
|
|
595
672
|
remove: () => {
|
|
596
|
-
|
|
673
|
+
r(a.field, void 0);
|
|
597
674
|
}
|
|
598
675
|
};
|
|
599
676
|
}).filter(Boolean),
|
|
600
|
-
[
|
|
677
|
+
[s, n, o, r]
|
|
601
678
|
);
|
|
602
679
|
return {
|
|
603
|
-
selectFilters:
|
|
604
|
-
toValueFilter:
|
|
680
|
+
selectFilters: c,
|
|
681
|
+
toValueFilter: i,
|
|
605
682
|
toRangeFilter: l
|
|
606
683
|
};
|
|
607
684
|
}
|
|
608
|
-
function
|
|
609
|
-
const { filter: e } =
|
|
685
|
+
function We() {
|
|
686
|
+
const { filter: e } = y((i) => {
|
|
610
687
|
var l;
|
|
611
688
|
return {
|
|
612
|
-
filter: ((l =
|
|
689
|
+
filter: ((l = i.query.products) == null ? void 0 : l.filter) ?? []
|
|
613
690
|
};
|
|
614
|
-
}), { updateSearch:
|
|
615
|
-
|
|
691
|
+
}), { 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(() => {
|
|
692
|
+
r({
|
|
616
693
|
products: {
|
|
617
694
|
filter: []
|
|
618
695
|
}
|
|
619
696
|
});
|
|
620
|
-
}, [
|
|
697
|
+
}, [r]);
|
|
621
698
|
return {
|
|
622
699
|
/** Selected filters array. */
|
|
623
|
-
filters:
|
|
700
|
+
filters: c,
|
|
624
701
|
/** Should remove all selected filters. */
|
|
625
|
-
removeAll:
|
|
702
|
+
removeAll: s
|
|
626
703
|
};
|
|
627
704
|
}
|
|
628
|
-
function
|
|
705
|
+
function R(e) {
|
|
629
706
|
if (typeof e == "number")
|
|
630
707
|
return e;
|
|
631
708
|
if (typeof e != "string")
|
|
632
709
|
return;
|
|
633
|
-
const
|
|
634
|
-
return isNaN(
|
|
635
|
-
}
|
|
636
|
-
function
|
|
637
|
-
var
|
|
638
|
-
const { replaceFilter:
|
|
639
|
-
query:
|
|
640
|
-
products:
|
|
641
|
-
})), o = (
|
|
710
|
+
const r = Number(e);
|
|
711
|
+
return isNaN(r) ? void 0 : r;
|
|
712
|
+
}
|
|
713
|
+
function Ge(e) {
|
|
714
|
+
var u, f, m;
|
|
715
|
+
const { replaceFilter: r } = C(), { query: t, products: n } = y((p) => ({
|
|
716
|
+
query: p.query,
|
|
717
|
+
products: p.response.products
|
|
718
|
+
})), o = (u = n == null ? void 0 : n.facets) == null ? void 0 : u.find((p) => p.id === e);
|
|
642
719
|
if (!o)
|
|
643
720
|
return {
|
|
644
721
|
min: 0,
|
|
@@ -647,140 +724,140 @@ function xe(e) {
|
|
|
647
724
|
updateRange: () => {
|
|
648
725
|
}
|
|
649
726
|
};
|
|
650
|
-
const
|
|
651
|
-
const
|
|
652
|
-
(l ===
|
|
653
|
-
lte:
|
|
654
|
-
}) : (
|
|
655
|
-
gte:
|
|
656
|
-
}) :
|
|
657
|
-
gte:
|
|
658
|
-
lte:
|
|
727
|
+
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]) => {
|
|
728
|
+
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;
|
|
729
|
+
(l === g || !k) && (a === v || !b) ? r(o.field, void 0) : (l === g || !k) && b ? r(o.field, {
|
|
730
|
+
lte: v.toString()
|
|
731
|
+
}) : (a === v || !b) && k ? r(o.field, {
|
|
732
|
+
gte: g.toString()
|
|
733
|
+
}) : k && b && r(o.field, {
|
|
734
|
+
gte: g.toString(),
|
|
735
|
+
lte: v.toString()
|
|
659
736
|
});
|
|
660
737
|
};
|
|
661
738
|
return {
|
|
662
739
|
/** Min value */
|
|
663
740
|
min: l,
|
|
664
741
|
/** Max value */
|
|
665
|
-
max:
|
|
742
|
+
max: a,
|
|
666
743
|
/** Range value */
|
|
667
|
-
range: [
|
|
744
|
+
range: [i[0] ?? l, i[1] ?? a],
|
|
668
745
|
/** Update range function */
|
|
669
|
-
updateRange:
|
|
746
|
+
updateRange: d
|
|
670
747
|
};
|
|
671
748
|
}
|
|
672
|
-
function
|
|
673
|
-
const { min:
|
|
749
|
+
function ft(e, r) {
|
|
750
|
+
const { min: t, max: n, range: o, updateRange: c } = Ge(e), { filters: s } = We(), i = z(() => {
|
|
674
751
|
var h;
|
|
675
|
-
const
|
|
676
|
-
var
|
|
677
|
-
return (
|
|
752
|
+
const u = s.find((g) => {
|
|
753
|
+
var v;
|
|
754
|
+
return (v = g == null ? void 0 : g.filter) == null ? void 0 : v.range;
|
|
678
755
|
});
|
|
679
|
-
let
|
|
680
|
-
if (
|
|
681
|
-
const
|
|
682
|
-
|
|
756
|
+
let f = null;
|
|
757
|
+
if (u) {
|
|
758
|
+
const g = (h = u.filter.range) == null ? void 0 : h[0];
|
|
759
|
+
f = [R(g == null ? void 0 : g.gte), R(g == null ? void 0 : g.lte)];
|
|
683
760
|
}
|
|
684
761
|
const m = [];
|
|
685
|
-
let
|
|
686
|
-
for (;
|
|
687
|
-
const
|
|
762
|
+
let p = Math.floor(t / r) * r;
|
|
763
|
+
for (; p < n; ) {
|
|
764
|
+
const g = p + r, v = f && f[0] === p && f[1] === g;
|
|
688
765
|
m.push({
|
|
689
|
-
min:
|
|
690
|
-
max:
|
|
691
|
-
selected:
|
|
692
|
-
}),
|
|
766
|
+
min: p,
|
|
767
|
+
max: g,
|
|
768
|
+
selected: v
|
|
769
|
+
}), p = g;
|
|
693
770
|
}
|
|
694
771
|
return m;
|
|
695
|
-
}, [
|
|
696
|
-
|
|
697
|
-
},
|
|
698
|
-
|
|
699
|
-
},
|
|
772
|
+
}, [s, t, n, r]), l = (u) => {
|
|
773
|
+
c([u, o[1]]);
|
|
774
|
+
}, a = (u) => {
|
|
775
|
+
c([o[0], u]);
|
|
776
|
+
}, d = t !== o[0] || n !== o[1];
|
|
700
777
|
return {
|
|
701
778
|
/** Minimum value */
|
|
702
|
-
min:
|
|
779
|
+
min: t,
|
|
703
780
|
/** Maximum value */
|
|
704
781
|
max: n,
|
|
705
782
|
/** Range value */
|
|
706
783
|
range: o,
|
|
707
784
|
/** Update range function */
|
|
708
|
-
updateRange:
|
|
785
|
+
updateRange: c,
|
|
709
786
|
/** Ranges */
|
|
710
|
-
ranges:
|
|
787
|
+
ranges: i,
|
|
711
788
|
/** Handle min change */
|
|
712
789
|
handleMinChange: l,
|
|
713
790
|
/** Handle max change */
|
|
714
|
-
handleMaxChange:
|
|
791
|
+
handleMaxChange: a,
|
|
715
792
|
/** Is selected */
|
|
716
|
-
isSelected:
|
|
793
|
+
isSelected: d
|
|
717
794
|
};
|
|
718
795
|
}
|
|
719
|
-
function
|
|
720
|
-
const { products: e, keywords:
|
|
796
|
+
function pt() {
|
|
797
|
+
const { products: e, keywords: r } = y((t) => t.response);
|
|
721
798
|
return {
|
|
722
799
|
/** Array of products */
|
|
723
800
|
products: e ?? { hits: [], total: 0 },
|
|
724
801
|
/** Array of keywords */
|
|
725
|
-
keywords:
|
|
802
|
+
keywords: r ?? { hits: [], total: 0 }
|
|
726
803
|
};
|
|
727
804
|
}
|
|
728
|
-
function
|
|
729
|
-
const e =
|
|
805
|
+
function gt() {
|
|
806
|
+
const e = y((t) => {
|
|
730
807
|
var n;
|
|
731
|
-
return (n =
|
|
808
|
+
return (n = t.query.products) == null ? void 0 : n.filter;
|
|
732
809
|
});
|
|
733
|
-
return
|
|
810
|
+
return z(() => e ? e.reduce((t, n) => t + (Array.isArray(n.value) ? n.value.length : 1), 0) : 0, [e]);
|
|
734
811
|
}
|
|
735
|
-
function
|
|
812
|
+
function O(e) {
|
|
736
813
|
return e && !Number.isNaN(e) ? e : 0;
|
|
737
814
|
}
|
|
738
|
-
function
|
|
739
|
-
const { from:
|
|
740
|
-
var
|
|
815
|
+
function mt(e, r) {
|
|
816
|
+
const { from: t, size: n, total: o } = y((a) => {
|
|
817
|
+
var d, u, f, m, p;
|
|
741
818
|
return {
|
|
742
|
-
from:
|
|
743
|
-
size:
|
|
744
|
-
total:
|
|
819
|
+
from: O(((d = a.query.products) == null ? void 0 : d.from) ?? 0),
|
|
820
|
+
size: O(((f = (u = a.response) == null ? void 0 : u.products) == null ? void 0 : f.size) ?? 0),
|
|
821
|
+
total: O(((p = (m = a.response) == null ? void 0 : m.products) == null ? void 0 : p.total) ?? 0)
|
|
745
822
|
};
|
|
746
|
-
}), { updateSearch:
|
|
823
|
+
}), { updateSearch: c } = C(), s = t + n, i = [...e].reverse().filter((a) => a + r < o);
|
|
747
824
|
return {
|
|
748
825
|
/** from value */
|
|
749
|
-
from:
|
|
826
|
+
from: t,
|
|
750
827
|
/** to value */
|
|
751
|
-
to:
|
|
828
|
+
to: s,
|
|
752
829
|
/** total value */
|
|
753
830
|
total: o,
|
|
754
831
|
/** size value */
|
|
755
832
|
size: n,
|
|
756
833
|
/** Array of size options */
|
|
757
|
-
sizeOptions:
|
|
834
|
+
sizeOptions: i,
|
|
758
835
|
/** Should be called when size is changed */
|
|
759
|
-
handleSizeChange: (
|
|
760
|
-
|
|
836
|
+
handleSizeChange: (a) => {
|
|
837
|
+
c({
|
|
761
838
|
products: {
|
|
762
|
-
size:
|
|
839
|
+
size: a
|
|
763
840
|
}
|
|
764
841
|
});
|
|
765
842
|
}
|
|
766
843
|
};
|
|
767
844
|
}
|
|
768
|
-
function
|
|
769
|
-
return e.length !==
|
|
845
|
+
function Je(e, r) {
|
|
846
|
+
return e.length !== r.length ? !1 : e.every((t) => r.find((n) => t.field === n.field && t.order === n.order));
|
|
770
847
|
}
|
|
771
|
-
function
|
|
772
|
-
var
|
|
773
|
-
const
|
|
848
|
+
function ht(e) {
|
|
849
|
+
var c, s;
|
|
850
|
+
const r = y((i) => i.query), { updateSearch: t } = C();
|
|
774
851
|
return {
|
|
775
852
|
/** Active sort */
|
|
776
|
-
activeSort: ((
|
|
853
|
+
activeSort: ((c = e.find((i) => {
|
|
777
854
|
var l;
|
|
778
|
-
return
|
|
779
|
-
})) == null ? void 0 :
|
|
855
|
+
return Je(i.value.sort, ((l = r.products) == null ? void 0 : l.sort) || []);
|
|
856
|
+
})) == null ? void 0 : c.id) ?? ((s = e[0]) == null ? void 0 : s.id),
|
|
780
857
|
/** Set sort function */
|
|
781
|
-
setSort: (
|
|
782
|
-
const l = e.find((
|
|
783
|
-
l &&
|
|
858
|
+
setSort: (i) => {
|
|
859
|
+
const l = e.find((a) => a.id === i);
|
|
860
|
+
l && t({
|
|
784
861
|
products: {
|
|
785
862
|
sort: l.value.sort
|
|
786
863
|
}
|
|
@@ -789,27 +866,29 @@ function Ze(e) {
|
|
|
789
866
|
};
|
|
790
867
|
}
|
|
791
868
|
export {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
869
|
+
ot as AutocompletePageProvider,
|
|
870
|
+
st as CategoryPageProvider,
|
|
871
|
+
tt as InfiniteScroll,
|
|
872
|
+
rt as SearchInput,
|
|
873
|
+
it as SearchPageProvider,
|
|
874
|
+
nt as SerpElement,
|
|
875
|
+
A as StoreContext,
|
|
876
|
+
fe as createExtendableStore,
|
|
877
|
+
_ as createStore,
|
|
878
|
+
pe as defaultState,
|
|
879
|
+
C as useActions,
|
|
880
|
+
ct as useDecoratedSearchResults,
|
|
881
|
+
at as useFacet,
|
|
882
|
+
ut as useFacets,
|
|
883
|
+
re as useLoadMore,
|
|
884
|
+
y as useNostoAppState,
|
|
885
|
+
lt as usePagination,
|
|
886
|
+
dt as usePersonalization,
|
|
887
|
+
We as useProductFilters,
|
|
888
|
+
Ge as useRange,
|
|
889
|
+
ft as useRangeSelector,
|
|
890
|
+
pt as useResponse,
|
|
891
|
+
gt as useSelectedFiltersCount,
|
|
892
|
+
mt as useSizeOptions,
|
|
893
|
+
ht as useSort
|
|
815
894
|
};
|