@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.
@@ -1,148 +1,105 @@
1
- import { toChildArray as X, createContext as L, options as B } from "preact";
2
- import { s as q } from "../index.es-B8mbAxS4.js";
3
- import { useContext as E, useEffect as O, useMemo as b, useCallback as v, useState as _ } from "preact/hooks";
4
- import { s as Z } from "../search-B0-bVNMy.js";
5
- function ee(e) {
6
- return e.type === "input";
7
- }
8
- function te(e) {
9
- return !!e && typeof e == "object" && "type" in e && "props" in e;
10
- }
11
- function V(e, t = { depth: 0 }) {
12
- const { children: r } = e;
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
- });
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
- const R = L(null), G = () => {
35
- const e = E(R);
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 je({ children: e, hit: t, onClick: r }) {
44
- const { pageType: n } = G(), o = n === "autocomplete" ? void 0 : n;
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 oe = 0;
56
- function k(e, t, r, n, o, u) {
57
- t || (t = {});
58
- var i, s, l = t;
59
- if ("ref" in l) for (s in l = {}, t) s == "ref" ? i = t[s] : l[s] = t[s];
60
- var c = { type: e, props: l, key: r, ref: i, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --oe, __i: -1, __u: 0, __source: o, __self: u };
61
- if (typeof e == "function" && (i = e.defaultProps)) for (s in i) l[s] === void 0 && (l[s] = i[s]);
62
- return B.vnode && B.vnode(c), c;
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 K = (e) => String(e) === "[object Object]";
31
+ const Q = (e) => String(e) === "[object Object]";
75
32
  function P(e) {
76
- if (!K(e))
33
+ if (!Q(e))
77
34
  return !1;
78
- const t = e.constructor;
79
- if (t === void 0)
35
+ const r = e.constructor;
36
+ if (r === void 0)
80
37
  return !0;
81
- const r = t.prototype;
82
- return !(!K(r) || !r.hasOwnProperty("isPrototypeOf"));
38
+ const t = r.prototype;
39
+ return !(!Q(t) || !t.hasOwnProperty("isPrototypeOf"));
83
40
  }
84
- function z(...e) {
85
- return e.reduce((t, r) => j(t, r));
41
+ function j(...e) {
42
+ return e.reduce((r, t) => $(r, t));
86
43
  }
87
- function Q(...e) {
88
- return e.reduce((t, r) => j(t, r));
44
+ function K(...e) {
45
+ return e.reduce((r, t) => $(r, t));
89
46
  }
90
- function j(e, t) {
91
- return P(e) && P(t) ? Object.entries(t).reduce(
92
- (r, [n, o]) => (r[n] = j(r[n], o), r),
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 : t;
51
+ ) : P(e) ? e : r;
95
52
  }
96
- function A(e, t) {
97
- if (e === t)
53
+ function M(e, r) {
54
+ if (e === r)
98
55
  return !0;
99
- if (e instanceof Date && t instanceof Date)
100
- return e.getTime() === t.getTime();
101
- if (Array.isArray(e) && Array.isArray(t))
102
- return e.length !== t.length ? !1 : e.every((r, n) => A(r, t[n]));
103
- if (P(e) && P(t)) {
104
- const r = Object.entries(e);
105
- return r.length !== Object.keys(t).length ? !1 : r.every(([n, o]) => A(o, t[n]));
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 se(e, t = {}) {
110
- const r = /* @__PURE__ */ new Map();
111
- let n = Q(e, t ?? {});
112
- const o = Q(e, t);
113
- function u(a) {
114
- n = a(n);
115
- for (const d of r.values())
116
- d(n);
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 i(a) {
119
- u((d) => ({ ...d, ...a }));
75
+ function s(u) {
76
+ c((f) => ({ ...f, ...u }));
120
77
  }
121
- function s() {
78
+ function i() {
122
79
  return n;
123
80
  }
124
81
  function l() {
125
82
  return structuredClone(o);
126
83
  }
127
- function c(a, d) {
84
+ function a(u, f) {
128
85
  let m;
129
- r.set(d, (g) => {
130
- const h = a(g);
131
- A(h, m) || (m = h, d(h));
86
+ t.set(f, (p) => {
87
+ const h = u(p);
88
+ M(h, m) || (m = h, f(h));
132
89
  });
133
90
  }
134
- function f(a) {
135
- r.delete(a);
91
+ function d(u) {
92
+ t.delete(u);
136
93
  }
137
94
  return {
138
- updateState: i,
139
- getState: s,
95
+ updateState: s,
96
+ getState: i,
140
97
  getInitialState: l,
141
- onChange: c,
142
- clearOnChange: f
98
+ onChange: a,
99
+ clearOnChange: d
143
100
  };
144
101
  }
145
- const ie = {
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 I(e = {}) {
156
- return se(ie, e);
157
- }
158
- const M = L(I()), D = {
159
- defaultCurrency: "EUR",
160
- queryModifications: (e) => e
161
- }, ce = {
162
- ...D
163
- };
164
- function ue(e) {
165
- return {
166
- pageType: "autocomplete",
167
- ...ce,
168
- ...e
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 fe = {
192
- ...D,
193
- persistentSearchCache: !1,
194
- preservePageScroll: !1
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 de(e = {}) {
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 pe(e, t) {
136
+ function he(e, r) {
211
137
  return {
212
- ...t,
138
+ ...r,
213
139
  products: {
214
140
  facets: e === "autocomplete" ? void 0 : ["*"],
215
- fields: me,
216
- ...t.products
141
+ fields: ye,
142
+ ...r.products
217
143
  },
218
- ...t.keywords ? {
144
+ ...r.keywords ? {
219
145
  keywords: {
220
- ...t.keywords,
221
- fields: ge([...he, ...t.keywords.fields ?? []]),
222
- highlight: t.keywords.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 me = [
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
- ], he = ["keyword", "_redirect"];
283
- function ye(...e) {
284
- if (!e.every((t) => t == null))
285
- return e.filter((t) => Array.isArray(t)).reduce((t, r) => t.concat(r), []);
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 J = "nosto.search.";
213
+ const Z = "nosto.search.";
288
214
  function Se(e) {
289
- var r;
290
- const t = `${J}${e}`;
291
- (r = window.performance) == null || r.mark(`${t}.start`);
215
+ var t;
216
+ const r = `${Z}${e}`;
217
+ (t = window.performance) == null || t.mark(`${r}.start`);
292
218
  }
293
- function ve(e) {
294
- var r, n;
295
- const t = `${J}${e}`;
296
- (r = window.performance) == null || r.mark(`${t}.end`), (n = window.performance) == null || n.measure(t, `${t}.start`, `${t}.end`);
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), () => ve(e);
225
+ return Se(e), () => be(e);
300
226
  }
301
- function Ce(e, t, r) {
302
- const n = JSON.stringify(t);
227
+ function ke(e, r, t) {
228
+ const n = JSON.stringify(r);
303
229
  try {
304
- console.info("Setting storage", e, n), r.setItem(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 we(e, t) {
235
+ function Ce(e, r) {
310
236
  try {
311
- const r = t.getItem(e);
312
- if (r)
313
- return JSON.parse(r);
314
- } catch (r) {
315
- console.warn(r);
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, t) {
319
- Ce(e, t, sessionStorage);
244
+ function Pe(e, r) {
245
+ ke(e, r, sessionStorage);
320
246
  }
321
- function ke(e) {
322
- return we(e, sessionStorage);
247
+ function Fe(e) {
248
+ return Ce(e, sessionStorage);
323
249
  }
324
- const Y = "nosto:search:searchResult";
325
- function Fe(e, t, r) {
250
+ const ee = "nosto:search:searchResult";
251
+ function Me(e, r, t) {
326
252
  if (!e)
327
253
  return;
328
- Pe(Y, { query: t, result: r });
254
+ Pe(ee, { query: r, result: t });
329
255
  }
330
- function Ae(e, t) {
256
+ function ze(e, r) {
331
257
  if (!e)
332
258
  return null;
333
- const r = ke(Y);
334
- if (!r || !be(r))
259
+ const t = Fe(ee);
260
+ if (!t || !Ae(t))
335
261
  return null;
336
- const n = H(r.query);
337
- return A(H(t), n) ? r.result : null;
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 be(e) {
279
+ function Ae(e) {
354
280
  return typeof e == "object" && e !== null && "query" in e && "result" in e;
355
281
  }
356
- async function W(e, t, r) {
357
- var c, f, a;
358
- const n = T("newSearch"), o = e.config.pageType, u = z(e.store.getInitialState().query, t), i = z(e.config.search, r, {
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: !!(r != null && r.isKeyword)
287
+ isKeyword: !!(t != null && t.isKeyword)
362
288
  });
363
289
  e.store.updateState({
364
- query: u,
290
+ query: c,
365
291
  loading: !0,
366
292
  initialized: !0
367
293
  });
368
- const s = o !== "autocomplete" && e.config.persistentSearchCache, l = e.config.queryModifications(
294
+ const i = o !== "autocomplete" && e.config.persistentSearchCache, l = e.config.queryModifications(
369
295
  {
370
- ...u,
296
+ ...c,
371
297
  products: {
372
- ...u.products,
298
+ ...c.products,
373
299
  // Apply filter merging to avoid overwriting base filters
374
- filter: ye((f = (c = e.store.getInitialState().query) == null ? void 0 : c.products) == null ? void 0 : f.filter, (a = t.products) == null ? void 0 : a.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 d;
381
- const m = Ae(s, l);
306
+ let f;
307
+ const m = ze(i, l);
382
308
  if (m)
383
- d = m;
309
+ f = m;
384
310
  else {
385
- const g = pe(o, l);
386
- d = await Z(g, i), Fe(s, l, d);
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: d,
315
+ response: f,
390
316
  loading: !1
391
317
  });
392
- } catch (d) {
393
- console.error("Search action failed", d);
318
+ } catch (f) {
319
+ console.error("Search action failed", f);
394
320
  }
395
321
  n();
396
322
  }
397
- async function U(e, t, r) {
398
- const n = T("updateSearch"), o = z(e.store.getState().query, { products: { from: 0 } }, t);
399
- await W(e, o, r), n();
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 Me(e, t, r) {
402
- var i;
403
- const n = T("replaceFilter"), o = (i = e.store.getState().query.products) == null ? void 0 : i.filter, u = r !== void 0 ? [{ field: t, [typeof r == "object" ? "range" : "value"]: [r] }] : [];
404
- await U(e, {
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((s) => s.field !== t)) ?? [], ...u]
332
+ filter: [...(o == null ? void 0 : o.filter((i) => i.field !== r)) ?? [], ...c]
407
333
  }
408
334
  }), n();
409
335
  }
410
- async function _e(e, t, r, n) {
411
- var l, c;
412
- const o = T("toggleProductFilter"), u = (l = e.store.getState().query.products) == null ? void 0 : l.filter, i = u == null ? void 0 : u.find((f) => f.value instanceof Array && f.field === t), s = i != null && i.value ? {
413
- ...i,
414
- value: [...i.value.filter((f) => !A(f, r)), ...n ? [r] : []]
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: t,
417
- value: [r]
342
+ field: r,
343
+ value: [t]
418
344
  } : void 0;
419
- await U(e, {
345
+ await V(e, {
420
346
  products: {
421
- filter: [...(u == null ? void 0 : u.filter((f) => f !== i)) ?? [], ...(c = s == null ? void 0 : s.value) != null && c.length ? [s] : []]
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 F() {
426
- const e = G(), t = E(M), r = b(
351
+ function C() {
352
+ const e = X(), r = q(A), t = z(
427
353
  () => ({
428
354
  config: e,
429
- store: t
355
+ store: r
430
356
  }),
431
- [e, t]
432
- ), n = v(
433
- (s, l) => W(r, s, l),
434
- [r]
435
- ), o = v(
436
- (s, l) => U(r, s, l),
437
- [r]
438
- ), u = v(
439
- (s, l, c) => _e(r, s, l, c),
440
- [r]
441
- ), i = v(
442
- (s, l) => Me(r, s, l),
443
- [r]
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: u,
449
- replaceFilter: i
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 C(e = Ne) {
453
- const t = E(M), [r, n] = _(e(t.getState()));
454
- return t.onChange(e, n), O(() => () => t.clearOnChange(n), [t]), r;
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
- const Ne = (e) => e;
457
- function Ke(e) {
458
- const t = C((r) => r.response);
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
- function Qe(e) {
462
- var i;
463
- const t = ((i = e.data) == null ? void 0 : i.filter((s) => s.selected).length) ?? 0, [r, n] = _(t > 0), { toggleProductFilter: o } = F();
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: r,
547
+ active: t,
467
548
  /** Selected filters count */
468
- selectedFiltersCount: t,
549
+ selectedFiltersCount: r,
469
550
  /** Toggle active function */
470
551
  toggleActive: () => {
471
- n(!r);
552
+ n(!t);
472
553
  },
473
554
  /** Toggle product filter function */
474
555
  toggleProductFilter: o
475
556
  };
476
557
  }
477
- function He() {
478
- const { loading: e, facets: t } = C((r) => {
558
+ function ut() {
559
+ const { loading: e, facets: r } = y((t) => {
479
560
  var n, o;
480
561
  return {
481
- loading: r.loading,
482
- facets: ((o = (n = r.response) == null ? void 0 : n.products) == null ? void 0 : o.facets) ?? []
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: t
570
+ facets: r
490
571
  };
491
572
  }
492
- function Re(e, t) {
493
- const r = t - e;
494
- return !isNaN(r) && r > 0 ? new Array(t - e).fill(void 0).map((n, o) => o + e) : [];
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 Le(e) {
497
- const { query: t, products: r } = C((n) => ({
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 b(() => {
502
- var w;
503
- if (!r)
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 = ((w = t.products) == null ? void 0 : w.from) ?? 0, o = (e == null ? void 0 : e.width) ?? 1 / 0, u = Math.max(Math.floor(o - 1) / 2, 1), i = r.size > 0 ? Math.floor(n / r.size) + 1 : 1, s = r.size > 0 ? Math.ceil(r.total / r.size) : 0, l = (S) => S >= i - u && S <= i + u, c = n + 1, f = Math.min(n + r.total, r.total), a = {
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: i,
593
+ page: s,
513
594
  current: !0
514
- }, d = (S) => ({
515
- from: (S - 1) * r.size,
516
- page: S,
517
- current: S === i
518
- }), m = i > 1 ? d(i - 1) : void 0, g = i < s ? d(i + 1) : void 0, h = u === 1 / 0 || i - u - 1 > 1 ? d(1) : void 0, p = u === 1 / 0 || i + u + 1 < s ? d(s) : void 0, y = Re(1, s + 1).filter(l).map(d);
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: s,
521
- resultsFrom: c,
522
- resultsTo: f,
523
- current: a,
601
+ totalPages: i,
602
+ resultsFrom: a,
603
+ resultsTo: d,
604
+ current: u,
524
605
  prev: m,
525
- next: g,
606
+ next: p,
526
607
  first: h,
527
- last: p,
528
- pages: y
608
+ last: g,
609
+ pages: v
529
610
  };
530
- }, [t, r, e == null ? void 0 : e.width]);
531
- }
532
- function Ge() {
533
- const [e, t] = _([]), [r, n] = _([]);
534
- return O(() => {
535
- q(async (o) => {
536
- const { products: u, segments: i } = await o.getSearchSessionParams();
537
- t(i ?? []), n((u == null ? void 0 : u.personalizationBoost) ?? []);
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: r
622
+ boost: t
542
623
  };
543
624
  }
544
- function Ie() {
545
- const { facets: e } = C((c) => {
546
- var f;
625
+ function He() {
626
+ const { facets: e } = y((a) => {
627
+ var d;
547
628
  return {
548
- facets: ((f = c.response.products) == null ? void 0 : f.facets) ?? []
629
+ facets: ((d = a.response.products) == null ? void 0 : d.facets) ?? []
549
630
  };
550
- }), { replaceFilter: t, toggleProductFilter: r } = F(), n = v(
551
- (c) => {
552
- const f = e == null ? void 0 : e.find((a) => a.type === "stats" && a.field === c);
553
- if (f && "min" in f && "max" in f)
554
- return f;
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 = v(
558
- (c) => {
559
- var f;
560
- return ((f = e == null ? void 0 : e.find((a) => a.field === c)) == null ? void 0 : f.name) ?? c;
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
- ), u = v((c) => "field" in c && (c.value instanceof Array || c.range instanceof Array), []), i = v((c) => {
564
- var f;
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
- ...c,
567
- range: (f = c.range) == null ? void 0 : f.map((a) => ({
568
- gt: a.gt ? Number(a.gt) : a.gt,
569
- gte: a.gte ? Number(a.gte) : a.gte,
570
- lt: a.lt ? Number(a.lt) : a.lt,
571
- lte: a.lte ? Number(a.lte) : a.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
- }, []), s = v(
575
- (c) => (c.value ?? []).map((a) => ({
576
- value: a,
577
- field: c.field,
578
- name: o(c.field),
579
- filter: i(c),
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
- r(c.field, a, !1);
662
+ t(a.field, u, !1);
582
663
  }
583
664
  })),
584
- [i, o, r]
585
- ), l = v(
586
- (c) => (c.range ?? []).map((a) => {
587
- var g, h;
588
- const d = a.gte ?? a.gt ?? ((g = n(c.field)) == null ? void 0 : g.min), m = a.lte ?? a.lt ?? ((h = n(c.field)) == null ? void 0 : h.max);
589
- if (d !== void 0 && m !== void 0)
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: `${d} - ${m}`,
592
- field: c.field,
593
- name: o(c.field),
594
- filter: i(c),
672
+ value: `${f} - ${m}`,
673
+ field: a.field,
674
+ name: o(a.field),
675
+ filter: s(a),
595
676
  remove: () => {
596
- t(c.field, void 0);
677
+ r(a.field, void 0);
597
678
  }
598
679
  };
599
680
  }).filter(Boolean),
600
- [i, n, o, t]
681
+ [s, n, o, r]
601
682
  );
602
683
  return {
603
- selectFilters: u,
604
- toValueFilter: s,
684
+ selectFilters: c,
685
+ toValueFilter: i,
605
686
  toRangeFilter: l
606
687
  };
607
688
  }
608
- function Te() {
609
- const { filter: e } = C((s) => {
689
+ function We() {
690
+ const { filter: e } = y((i) => {
610
691
  var l;
611
692
  return {
612
- filter: ((l = s.query.products) == null ? void 0 : l.filter) ?? []
693
+ filter: ((l = i.query.products) == null ? void 0 : l.filter) ?? []
613
694
  };
614
- }), { updateSearch: t } = F(), { selectFilters: r, toValueFilter: n, toRangeFilter: o } = Ie(), u = b(() => e ? e.filter(r).flatMap((s) => "value" in s ? n(s) : "range" in s ? o(s) : []).filter(Boolean) : [], [e, r, o, n]), i = v(() => {
615
- t({
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
- }, [t]);
701
+ }, [r]);
621
702
  return {
622
703
  /** Selected filters array. */
623
- filters: u,
704
+ filters: c,
624
705
  /** Should remove all selected filters. */
625
- removeAll: i
706
+ removeAll: s
626
707
  };
627
708
  }
628
- function N(e) {
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 t = Number(e);
634
- return isNaN(t) ? void 0 : t;
635
- }
636
- function xe(e) {
637
- var a, d, m;
638
- const { replaceFilter: t } = F(), { query: r, products: n } = C((g) => ({
639
- query: g.query,
640
- products: g.response.products
641
- })), o = (a = n == null ? void 0 : n.facets) == null ? void 0 : a.find((g) => g.id === e);
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 u = (m = (d = r.products) == null ? void 0 : d.filter) == null ? void 0 : m.find((g) => g.field === o.field), i = u != null && u.range ? u.range[0] : void 0, s = typeof i == "object" && ("gte" in i || "lte" in i) ? [N(i.gte), N(i.lte)] : [void 0, void 0], l = "min" in o ? Math.floor(o.min) : 0, c = "max" in o ? Math.ceil(o.max) : 0, f = ([g, h]) => {
651
- const p = g !== void 0 ? Math.floor(g) : void 0, y = h !== void 0 ? Math.ceil(h) : void 0, w = p !== void 0, S = y !== void 0;
652
- (l === p || !w) && (c === y || !S) ? t(o.field, void 0) : (l === p || !w) && S ? t(o.field, {
653
- lte: y.toString()
654
- }) : (c === y || !S) && w ? t(o.field, {
655
- gte: p.toString()
656
- }) : w && S && t(o.field, {
657
- gte: p.toString(),
658
- lte: y.toString()
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: c,
746
+ max: a,
666
747
  /** Range value */
667
- range: [s[0] ?? l, s[1] ?? c],
748
+ range: [i[0] ?? l, i[1] ?? a],
668
749
  /** Update range function */
669
- updateRange: f
750
+ updateRange: d
670
751
  };
671
752
  }
672
- function Je(e, t) {
673
- const { min: r, max: n, range: o, updateRange: u } = xe(e), { filters: i } = Te(), s = b(() => {
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 a = i.find((p) => {
676
- var y;
677
- return (y = p == null ? void 0 : p.filter) == null ? void 0 : y.range;
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 d = null;
680
- if (a) {
681
- const p = (h = a.filter.range) == null ? void 0 : h[0];
682
- d = [N(p == null ? void 0 : p.gte), N(p == null ? void 0 : p.lte)];
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 g = Math.floor(r / t) * t;
686
- for (; g < n; ) {
687
- const p = g + t, y = d && d[0] === g && d[1] === p;
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: g,
690
- max: p,
691
- selected: y
692
- }), g = p;
770
+ min: p,
771
+ max: g,
772
+ selected: v
773
+ }), p = g;
693
774
  }
694
775
  return m;
695
- }, [i, r, n, t]), l = (a) => {
696
- u([a, o[1]]);
697
- }, c = (a) => {
698
- u([o[0], a]);
699
- }, f = r !== o[0] || n !== o[1];
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: r,
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: u,
789
+ updateRange: c,
709
790
  /** Ranges */
710
- ranges: s,
791
+ ranges: i,
711
792
  /** Handle min change */
712
793
  handleMinChange: l,
713
794
  /** Handle max change */
714
- handleMaxChange: c,
795
+ handleMaxChange: a,
715
796
  /** Is selected */
716
- isSelected: f
797
+ isSelected: d
717
798
  };
718
799
  }
719
- function Ye() {
720
- const { products: e, keywords: t } = C((r) => r.response);
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: t ?? { hits: [], total: 0 }
806
+ keywords: r ?? { hits: [], total: 0 }
726
807
  };
727
808
  }
728
- function We() {
729
- const e = C((r) => {
809
+ function gt() {
810
+ const e = y((t) => {
730
811
  var n;
731
- return (n = r.query.products) == null ? void 0 : n.filter;
812
+ return (n = t.query.products) == null ? void 0 : n.filter;
732
813
  });
733
- return b(() => e ? e.reduce((r, n) => r + (Array.isArray(n.value) ? n.value.length : 1), 0) : 0, [e]);
814
+ return z(() => e ? e.reduce((t, n) => t + (Array.isArray(n.value) ? n.value.length : 1), 0) : 0, [e]);
734
815
  }
735
- function x(e) {
816
+ function O(e) {
736
817
  return e && !Number.isNaN(e) ? e : 0;
737
818
  }
738
- function Xe(e, t) {
739
- const { from: r, size: n, total: o } = C((c) => {
740
- var f, a, d, m, g;
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: x(((f = c.query.products) == null ? void 0 : f.from) ?? 0),
743
- size: x(((d = (a = c.response) == null ? void 0 : a.products) == null ? void 0 : d.size) ?? 0),
744
- total: x(((g = (m = c.response) == null ? void 0 : m.products) == null ? void 0 : g.total) ?? 0)
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: u } = F(), i = r + n, s = [...e].reverse().filter((c) => c + t < o);
827
+ }), { updateSearch: c } = C(), s = t + n, i = [...e].reverse().filter((a) => a + r < o);
747
828
  return {
748
829
  /** from value */
749
- from: r,
830
+ from: t,
750
831
  /** to value */
751
- to: i,
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: s,
838
+ sizeOptions: i,
758
839
  /** Should be called when size is changed */
759
- handleSizeChange: (c) => {
760
- u({
840
+ handleSizeChange: (a) => {
841
+ c({
761
842
  products: {
762
- size: c
843
+ size: a
763
844
  }
764
845
  });
765
846
  }
766
847
  };
767
848
  }
768
- function ze(e, t) {
769
- return e.length !== t.length ? !1 : e.every((r) => t.find((n) => r.field === n.field && r.order === n.order));
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 Ze(e) {
772
- var u, i;
773
- const t = C((s) => s.query), { updateSearch: r } = F();
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: ((u = e.find((s) => {
857
+ activeSort: ((c = e.find((i) => {
777
858
  var l;
778
- return ze(s.value.sort, ((l = t.products) == null ? void 0 : l.sort) || []);
779
- })) == null ? void 0 : u.id) ?? ((i = e[0]) == null ? void 0 : i.id),
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: (s) => {
782
- const l = e.find((c) => c.id === s);
783
- l && r({
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
- De as AutocompletePageProvider,
793
- Ue as CategoryPageProvider,
794
- $e as SearchInput,
795
- Be as SearchPageProvider,
796
- je as SerpElement,
797
- M as StoreContext,
798
- se as createExtendableStore,
799
- I as createStore,
800
- ie as defaultState,
801
- F as useActions,
802
- Ke as useDecoratedSearchResults,
803
- Qe as useFacet,
804
- He as useFacets,
805
- C as useNostoAppState,
806
- Le as usePagination,
807
- Ge as usePersonalization,
808
- Te as useProductFilters,
809
- xe as useRange,
810
- Je as useRangeSelector,
811
- Ye as useResponse,
812
- We as useSelectedFiltersCount,
813
- Xe as useSizeOptions,
814
- Ze as useSort
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
  };