@nosto/search-js 1.5.1 → 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,122 +1,79 @@
1
- import { toChildArray as X, createContext as L, options as B } from "preact";
2
- import { s as O } from "../index.es-Bcd5IQh9.js";
3
- import { useContext as q, useEffect as z, useMemo as N, useCallback as h, useState as R } from "preact/hooks";
4
- import { search as Z } from "../core/core.es.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 Ve({ 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
- });
33
- }
34
- const M = L(null), G = () => {
35
- const e = q(M);
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());
42
- }
43
- function $e({ 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, c) => (c.depth > 0 || (u.props = {
48
- ...u.props,
49
- onClick: (i) => {
50
- t && o && O((l) => l.recordSearchClick(o, t)), ne(), typeof r == "function" && r(i);
51
- }
52
- }), u)
53
- });
54
- }
55
- var oe = 0;
56
- function w(e, t, r, n, o, u) {
57
- t || (t = {});
58
- var c, i, l = t;
59
- if ("ref" in l) for (i in l = {}, t) i == "ref" ? c = t[i] : l[i] = t[i];
60
- var s = { type: e, props: l, key: r, ref: c, __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" && (c = e.defaultProps)) for (i in c) l[i] === void 0 && (l[i] = c[i]);
62
- return B.vnode && B.vnode(s), s;
63
- }
64
- function $() {
65
- z(() => {
66
- const e = window.setTimeout(() => {
67
- console.error("Nosto client script has not loaded after 3 seconds.");
68
- }, 3e3);
69
- O(() => {
70
- window.clearTimeout(e);
71
- });
72
- }, []);
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;
73
15
  }
74
- const K = (e) => String(e) === "[object Object]";
75
- function C(e) {
76
- if (!K(e))
16
+ function le(e) {
17
+ return !!e && ue().test(e);
18
+ }
19
+ function J() {
20
+ return le(navigator.userAgent);
21
+ }
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;
30
+ }
31
+ const Q = (e) => String(e) === "[object Object]";
32
+ function P(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 E(...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 C(e) && C(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
- ) : C(e) ? e : t;
51
+ ) : P(e) ? e : r;
95
52
  }
96
- function P(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) => P(r, t[n]));
103
- if (C(e) && C(t)) {
104
- const r = Object.entries(e);
105
- return r.length !== Object.keys(t).length ? !1 : r.every(([n, o]) => P(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 c(a) {
119
- u((d) => ({ ...d, ...a }));
75
+ function s(u) {
76
+ c((f) => ({ ...f, ...u }));
120
77
  }
121
78
  function i() {
122
79
  return n;
@@ -124,25 +81,25 @@ function se(e, t = {}) {
124
81
  function l() {
125
82
  return structuredClone(o);
126
83
  }
127
- function s(a, d) {
84
+ function a(u, f) {
128
85
  let m;
129
- r.set(d, (g) => {
130
- const y = a(g);
131
- P(y, m) || (m = y, d(y));
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: c,
95
+ updateState: s,
139
96
  getState: i,
140
97
  getInitialState: l,
141
- onChange: s,
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 F = L(I()), D = {
159
- defaultCurrency: "EUR",
160
- queryModifications: (e) => e
161
- }, ce = {
162
- ...D
163
- };
164
- function ae(e) {
165
- return {
166
- pageType: "autocomplete",
167
- ...ce,
168
- ...e
169
- };
170
- }
171
- function je({ config: e, store: t, children: r }) {
172
- const n = t ?? I();
173
- return $(), /* @__PURE__ */ w(M, { value: ae(e), children: /* @__PURE__ */ w(F, { value: n, children: r }) });
174
- }
175
- const ue = {
176
- ...D,
177
- persistentSearchCache: !1,
178
- preservePageScroll: !1
179
- };
180
- function le(e) {
181
- return {
182
- pageType: "category",
183
- ...ue,
184
- ...e
185
- };
186
- }
187
- function De({ config: e, store: t, children: r }) {
188
- const n = t ?? I();
189
- return $(), /* @__PURE__ */ w(M, { value: le(e), children: /* @__PURE__ */ w(F, { 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 Ue({ config: e, store: t, children: r }) {
204
- const n = t ?? I();
205
- return $(), /* @__PURE__ */ w(M, { value: de(e), children: /* @__PURE__ */ w(F, { 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([...ye, ...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
- ], ye = ["keyword", "_redirect"];
283
- function he(...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 ke(e, t) {
319
- Ce(e, t, sessionStorage);
244
+ function Pe(e, r) {
245
+ ke(e, r, sessionStorage);
320
246
  }
321
- function Pe(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
- ke(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 = Pe(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 P(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,255 +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 s, f, a;
358
- const n = T("newSearch"), o = e.config.pageType, u = E(e.store.getInitialState().query, t), c = E(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
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: he((f = (s = e.store.getInitialState().query) == null ? void 0 : s.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(i, 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, c), Fe(i, 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 = E(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 Re(e, t, r) {
402
- var c;
403
- const n = T("replaceFilter"), o = (c = e.store.getState().query.products) == null ? void 0 : c.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((i) => i.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, s;
412
- const o = T("toggleProductFilter"), u = (l = e.store.getState().query.products) == null ? void 0 : l.filter, c = u == null ? void 0 : u.find((f) => f.value instanceof Array && f.field === t), i = c != null && c.value ? {
413
- ...c,
414
- value: [...c.value.filter((f) => !P(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 !== c)) ?? [], ...(s = i == null ? void 0 : i.value) != null && s.length ? [i] : []]
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 k() {
426
- const e = G(), t = q(F), r = N(
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 = h(
433
- (i, l) => W(r, i, l),
434
- [r]
435
- ), o = h(
436
- (i, l) => U(r, i, l),
437
- [r]
438
- ), u = h(
439
- (i, l, s) => _e(r, i, l, s),
440
- [r]
441
- ), c = h(
442
- (i, l) => Re(r, i, 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: c
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 }
450
383
  };
451
384
  }
452
- function v(e = Ne) {
453
- const t = q(F), [r, n] = R(e(t.getState()));
454
- return t.onChange(e, n), z(() => () => t.clearOnChange(n), [t]), r;
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
+ });
455
462
  }
456
- const Ne = (e) => e;
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
+ };
457
495
  function Be(e) {
458
- const t = v((r) => r.response);
459
- return e && Array.isArray(e) || e && C(e) ? e : t;
496
+ return {
497
+ pageType: "autocomplete",
498
+ ...Ve,
499
+ ...e
500
+ };
501
+ }
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 }) });
460
505
  }
461
- function Ke(e) {
462
- var c;
463
- const t = ((c = e.data) == null ? void 0 : c.filter((i) => i.selected).length) ?? 0, [r, n] = R(t > 0), { toggleProductFilter: o } = k();
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
+ };
517
+ }
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 }) });
521
+ }
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 Qe() {
478
- const { loading: e, facets: t } = v((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 He() {
493
- const [e, t] = R([]), [r, n] = R([]);
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) : [];
576
+ }
577
+ function lt(e) {
578
+ const { query: r, products: t } = y((n) => ({
579
+ query: n.query,
580
+ products: n.response.products
581
+ }));
494
582
  return z(() => {
495
- O(async (o) => {
496
- const { products: u, segments: c } = await o.getSearchSessionParams();
497
- t(c ?? []), n((u == null ? void 0 : u.personalizationBoost) ?? []);
583
+ var k;
584
+ if (!t)
585
+ return {
586
+ totalPages: 0,
587
+ resultsFrom: 0,
588
+ resultsTo: 0,
589
+ pages: []
590
+ };
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 = {
592
+ from: n,
593
+ page: s,
594
+ current: !0
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);
600
+ return {
601
+ totalPages: i,
602
+ resultsFrom: a,
603
+ resultsTo: d,
604
+ current: u,
605
+ prev: m,
606
+ next: p,
607
+ first: h,
608
+ last: g,
609
+ pages: v
610
+ };
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) ?? []);
498
619
  });
499
620
  }, []), {
500
621
  segments: e,
501
- boost: r
622
+ boost: t
502
623
  };
503
624
  }
504
- function Me() {
505
- const { facets: e } = v((s) => {
506
- var f;
625
+ function He() {
626
+ const { facets: e } = y((a) => {
627
+ var d;
507
628
  return {
508
- facets: ((f = s.response.products) == null ? void 0 : f.facets) ?? []
629
+ facets: ((d = a.response.products) == null ? void 0 : d.facets) ?? []
509
630
  };
510
- }), { replaceFilter: t, toggleProductFilter: r } = k(), n = h(
511
- (s) => {
512
- const f = e == null ? void 0 : e.find((a) => a.type === "stats" && a.field === s);
513
- if (f && "min" in f && "max" in f)
514
- 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;
515
636
  },
516
637
  [e]
517
- ), o = h(
518
- (s) => {
519
- var f;
520
- return ((f = e == null ? void 0 : e.find((a) => a.field === s)) == null ? void 0 : f.name) ?? s;
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;
521
642
  },
522
643
  [e]
523
- ), u = h((s) => "field" in s && (s.value instanceof Array || s.range instanceof Array), []), c = h((s) => {
524
- var f;
644
+ ), c = w((a) => "field" in a && (a.value instanceof Array || a.range instanceof Array), []), s = w((a) => {
645
+ var d;
525
646
  return {
526
- ...s,
527
- range: (f = s.range) == null ? void 0 : f.map((a) => ({
528
- gt: a.gt ? Number(a.gt) : a.gt,
529
- gte: a.gte ? Number(a.gte) : a.gte,
530
- lt: a.lt ? Number(a.lt) : a.lt,
531
- 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
532
653
  }))
533
654
  };
534
- }, []), i = h(
535
- (s) => (s.value ?? []).map((a) => ({
536
- value: a,
537
- field: s.field,
538
- name: o(s.field),
539
- filter: c(s),
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),
540
661
  remove: () => {
541
- r(s.field, a, !1);
662
+ t(a.field, u, !1);
542
663
  }
543
664
  })),
544
- [c, o, r]
545
- ), l = h(
546
- (s) => (s.range ?? []).map((a) => {
547
- var g, y;
548
- const d = a.gte ?? a.gt ?? ((g = n(s.field)) == null ? void 0 : g.min), m = a.lte ?? a.lt ?? ((y = n(s.field)) == null ? void 0 : y.max);
549
- 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)
550
671
  return {
551
- value: `${d} - ${m}`,
552
- field: s.field,
553
- name: o(s.field),
554
- filter: c(s),
672
+ value: `${f} - ${m}`,
673
+ field: a.field,
674
+ name: o(a.field),
675
+ filter: s(a),
555
676
  remove: () => {
556
- t(s.field, void 0);
677
+ r(a.field, void 0);
557
678
  }
558
679
  };
559
680
  }).filter(Boolean),
560
- [c, n, o, t]
681
+ [s, n, o, r]
561
682
  );
562
683
  return {
563
- selectFilters: u,
684
+ selectFilters: c,
564
685
  toValueFilter: i,
565
686
  toRangeFilter: l
566
687
  };
567
688
  }
568
- function Ie() {
569
- const { filter: e } = v((i) => {
689
+ function We() {
690
+ const { filter: e } = y((i) => {
570
691
  var l;
571
692
  return {
572
693
  filter: ((l = i.query.products) == null ? void 0 : l.filter) ?? []
573
694
  };
574
- }), { updateSearch: t } = k(), { selectFilters: r, toValueFilter: n, toRangeFilter: o } = Me(), u = N(() => e ? e.filter(r).flatMap((i) => "value" in i ? n(i) : "range" in i ? o(i) : []).filter(Boolean) : [], [e, r, o, n]), c = h(() => {
575
- 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({
576
697
  products: {
577
698
  filter: []
578
699
  }
579
700
  });
580
- }, [t]);
701
+ }, [r]);
581
702
  return {
582
703
  /** Selected filters array. */
583
- filters: u,
704
+ filters: c,
584
705
  /** Should remove all selected filters. */
585
- removeAll: c
706
+ removeAll: s
586
707
  };
587
708
  }
588
- function _(e) {
709
+ function R(e) {
589
710
  if (typeof e == "number")
590
711
  return e;
591
712
  if (typeof e != "string")
592
713
  return;
593
- const t = Number(e);
594
- return isNaN(t) ? void 0 : t;
595
- }
596
- function Te(e) {
597
- var a, d, m;
598
- const { replaceFilter: t } = k(), { query: r, products: n } = v((g) => ({
599
- query: g.query,
600
- products: g.response.products
601
- })), 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);
602
723
  if (!o)
603
724
  return {
604
725
  min: 0,
@@ -607,108 +728,108 @@ function Te(e) {
607
728
  updateRange: () => {
608
729
  }
609
730
  };
610
- const u = (m = (d = r.products) == null ? void 0 : d.filter) == null ? void 0 : m.find((g) => g.field === o.field), c = u != null && u.range ? u.range[0] : void 0, i = typeof c == "object" && ("gte" in c || "lte" in c) ? [_(c.gte), _(c.lte)] : [void 0, void 0], l = "min" in o ? Math.floor(o.min) : 0, s = "max" in o ? Math.ceil(o.max) : 0, f = ([g, y]) => {
611
- const p = g !== void 0 ? Math.floor(g) : void 0, S = y !== void 0 ? Math.ceil(y) : void 0, A = p !== void 0, b = S !== void 0;
612
- (l === p || !A) && (s === S || !b) ? t(o.field, void 0) : (l === p || !A) && b ? t(o.field, {
613
- lte: S.toString()
614
- }) : (s === S || !b) && A ? t(o.field, {
615
- gte: p.toString()
616
- }) : A && b && t(o.field, {
617
- gte: p.toString(),
618
- lte: S.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()
619
740
  });
620
741
  };
621
742
  return {
622
743
  /** Min value */
623
744
  min: l,
624
745
  /** Max value */
625
- max: s,
746
+ max: a,
626
747
  /** Range value */
627
- range: [i[0] ?? l, i[1] ?? s],
748
+ range: [i[0] ?? l, i[1] ?? a],
628
749
  /** Update range function */
629
- updateRange: f
750
+ updateRange: d
630
751
  };
631
752
  }
632
- function Le(e, t) {
633
- const { min: r, max: n, range: o, updateRange: u } = Te(e), { filters: c } = Ie(), i = N(() => {
634
- var y;
635
- const a = c.find((p) => {
636
- var S;
637
- return (S = p == null ? void 0 : p.filter) == null ? void 0 : S.range;
753
+ function ft(e, r) {
754
+ const { min: t, max: n, range: o, updateRange: c } = Ge(e), { filters: s } = We(), i = z(() => {
755
+ var h;
756
+ const u = s.find((g) => {
757
+ var v;
758
+ return (v = g == null ? void 0 : g.filter) == null ? void 0 : v.range;
638
759
  });
639
- let d = null;
640
- if (a) {
641
- const p = (y = a.filter.range) == null ? void 0 : y[0];
642
- d = [_(p == null ? void 0 : p.gte), _(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)];
643
764
  }
644
765
  const m = [];
645
- let g = Math.floor(r / t) * t;
646
- for (; g < n; ) {
647
- const p = g + t, S = 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;
648
769
  m.push({
649
- min: g,
650
- max: p,
651
- selected: S
652
- }), g = p;
770
+ min: p,
771
+ max: g,
772
+ selected: v
773
+ }), p = g;
653
774
  }
654
775
  return m;
655
- }, [c, r, n, t]), l = (a) => {
656
- u([a, o[1]]);
657
- }, s = (a) => {
658
- u([o[0], a]);
659
- }, 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];
660
781
  return {
661
782
  /** Minimum value */
662
- min: r,
783
+ min: t,
663
784
  /** Maximum value */
664
785
  max: n,
665
786
  /** Range value */
666
787
  range: o,
667
788
  /** Update range function */
668
- updateRange: u,
789
+ updateRange: c,
669
790
  /** Ranges */
670
791
  ranges: i,
671
792
  /** Handle min change */
672
793
  handleMinChange: l,
673
794
  /** Handle max change */
674
- handleMaxChange: s,
795
+ handleMaxChange: a,
675
796
  /** Is selected */
676
- isSelected: f
797
+ isSelected: d
677
798
  };
678
799
  }
679
- function Ge() {
680
- const { products: e, keywords: t } = v((r) => r.response);
800
+ function pt() {
801
+ const { products: e, keywords: r } = y((t) => t.response);
681
802
  return {
682
803
  /** Array of products */
683
804
  products: e ?? { hits: [], total: 0 },
684
805
  /** Array of keywords */
685
- keywords: t ?? { hits: [], total: 0 }
806
+ keywords: r ?? { hits: [], total: 0 }
686
807
  };
687
808
  }
688
- function Je() {
689
- const e = v((r) => {
809
+ function gt() {
810
+ const e = y((t) => {
690
811
  var n;
691
- return (n = r.query.products) == null ? void 0 : n.filter;
812
+ return (n = t.query.products) == null ? void 0 : n.filter;
692
813
  });
693
- return N(() => 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]);
694
815
  }
695
- function x(e) {
816
+ function O(e) {
696
817
  return e && !Number.isNaN(e) ? e : 0;
697
818
  }
698
- function Ye(e, t) {
699
- const { from: r, size: n, total: o } = v((s) => {
700
- 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;
701
822
  return {
702
- from: x(((f = s.query.products) == null ? void 0 : f.from) ?? 0),
703
- size: x(((d = (a = s.response) == null ? void 0 : a.products) == null ? void 0 : d.size) ?? 0),
704
- total: x(((g = (m = s.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)
705
826
  };
706
- }), { updateSearch: u } = k(), c = r + n, i = [...e].reverse().filter((s) => s + t < o);
827
+ }), { updateSearch: c } = C(), s = t + n, i = [...e].reverse().filter((a) => a + r < o);
707
828
  return {
708
829
  /** from value */
709
- from: r,
830
+ from: t,
710
831
  /** to value */
711
- to: c,
832
+ to: s,
712
833
  /** total value */
713
834
  total: o,
714
835
  /** size value */
@@ -716,31 +837,31 @@ function Ye(e, t) {
716
837
  /** Array of size options */
717
838
  sizeOptions: i,
718
839
  /** Should be called when size is changed */
719
- handleSizeChange: (s) => {
720
- u({
840
+ handleSizeChange: (a) => {
841
+ c({
721
842
  products: {
722
- size: s
843
+ size: a
723
844
  }
724
845
  });
725
846
  }
726
847
  };
727
848
  }
728
- function xe(e, t) {
729
- 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));
730
851
  }
731
- function We(e) {
732
- var u, c;
733
- const t = v((i) => i.query), { updateSearch: r } = k();
852
+ function ht(e) {
853
+ var c, s;
854
+ const r = y((i) => i.query), { updateSearch: t } = C();
734
855
  return {
735
856
  /** Active sort */
736
- activeSort: ((u = e.find((i) => {
857
+ activeSort: ((c = e.find((i) => {
737
858
  var l;
738
- return xe(i.value.sort, ((l = t.products) == null ? void 0 : l.sort) || []);
739
- })) == null ? void 0 : u.id) ?? ((c = e[0]) == null ? void 0 : c.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),
740
861
  /** Set sort function */
741
862
  setSort: (i) => {
742
- const l = e.find((s) => s.id === i);
743
- l && r({
863
+ const l = e.find((a) => a.id === i);
864
+ l && t({
744
865
  products: {
745
866
  sort: l.value.sort
746
867
  }
@@ -749,26 +870,29 @@ function We(e) {
749
870
  };
750
871
  }
751
872
  export {
752
- je as AutocompletePageProvider,
753
- De as CategoryPageProvider,
754
- Ve as SearchInput,
755
- Ue as SearchPageProvider,
756
- $e as SerpElement,
757
- F as StoreContext,
758
- se as createExtendableStore,
759
- I as createStore,
760
- ie as defaultState,
761
- k as useActions,
762
- Be as useDecoratedSearchResults,
763
- Ke as useFacet,
764
- Qe as useFacets,
765
- v as useNostoAppState,
766
- He as usePersonalization,
767
- Ie as useProductFilters,
768
- Te as useRange,
769
- Le as useRangeSelector,
770
- Ge as useResponse,
771
- Je as useSelectedFiltersCount,
772
- Ye as useSizeOptions,
773
- We 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
774
898
  };