@nosto/search-js 3.22.0 → 3.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AutocompletePageProvider-Xg9H1y3f.cjs → AutocompletePageProvider-CFcim_G9.cjs} +1 -1
- package/dist/{AutocompletePageProvider-DsUoIbbx.js → AutocompletePageProvider-CJb7OEAr.js} +3 -3
- package/dist/{CategoryPageProvider-DU3DjmnJ.js → CategoryPageProvider-BGqhQtdT.js} +2 -2
- package/dist/{CategoryPageProvider-2ZmajAxh.cjs → CategoryPageProvider-C2nqTdZ8.cjs} +1 -1
- package/dist/{InfiniteScrollWithObserver-B0iiezKy.js → InfiniteScrollWithObserver-CtEBs3Ts.js} +1 -1
- package/dist/{InfiniteScrollWithObserver-LxLj-_bT.cjs → InfiniteScrollWithObserver-DAtCSz5E.cjs} +1 -1
- package/dist/{SerpPageProvider-Dn6PSZoF.cjs → SerpPageProvider-D5cD0ttm.cjs} +1 -1
- package/dist/{SerpPageProvider-DshgTNpM.js → SerpPageProvider-wkZs_QWn.js} +2 -2
- package/dist/{baseConfig-DeHr2N1l.js → baseConfig-BU6c9mCI.js} +1 -1
- package/dist/{baseConfig-CaRa_-zN.cjs → baseConfig-DDoRk8Lk.cjs} +1 -1
- package/dist/core/core.cjs.js +1 -1
- package/dist/core/core.es.js +1 -1
- package/dist/core/src/withRedirects.d.ts +3 -0
- package/dist/preact/autocomplete/autocomplete.cjs.js +1 -1
- package/dist/preact/autocomplete/autocomplete.es.js +1 -1
- package/dist/preact/autocomplete/src/components/AutocompleteElement.d.ts +2 -2
- package/dist/preact/autocomplete/src/types.d.ts +5 -7
- package/dist/preact/category/category.cjs.js +1 -1
- package/dist/preact/category/category.es.js +1 -1
- package/dist/preact/common/common.cjs.js +1 -1
- package/dist/preact/common/common.es.js +3 -3
- package/dist/preact/hooks/hooks.cjs.js +1 -1
- package/dist/preact/hooks/hooks.es.js +101 -100
- package/dist/preact/inject/inject.cjs.js +1 -1
- package/dist/preact/inject/inject.es.js +5 -5
- package/dist/preact/legacy/legacy.cjs.js +1 -1
- package/dist/preact/legacy/legacy.es.js +3 -3
- package/dist/preact/serp/serp.cjs.js +1 -1
- package/dist/preact/serp/serp.es.js +2 -2
- package/dist/search-DItu5YCc.cjs +1 -0
- package/dist/search-xLgL6P5R.js +187 -0
- package/dist/{useActions-CY9uts_o.cjs → useActions-B6FFW8xI.cjs} +1 -1
- package/dist/{useActions-CSNwQtT1.js → useActions-DoZCMPfW.js} +1 -1
- package/dist/{useHistory-joVBx1r2.js → useHistory-BJo9WE5S.js} +2 -2
- package/dist/{useHistory-rc2PvSkv.cjs → useHistory-D_TgfzXK.cjs} +1 -1
- package/dist/{useLoadMore-2OmOqicJ.js → useLoadMore-CdqyUIQQ.js} +1 -1
- package/dist/{useLoadMore-CBshMpps.cjs → useLoadMore-DYxXgyV2.cjs} +1 -1
- package/package.json +6 -6
- package/dist/search-RNs4Cunh.cjs +0 -1
- package/dist/search-mArZ2PXy.js +0 -170
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { h as A } from "../../useActions-
|
|
2
|
-
import { a as
|
|
3
|
-
import { a as S } from "../../useLoadMore-
|
|
4
|
-
import { u as
|
|
5
|
-
import { u as
|
|
6
|
-
import { useState as b, useCallback as p, useMemo as y, useEffect as
|
|
7
|
-
import { a as
|
|
8
|
-
import { s as
|
|
9
|
-
import { d as
|
|
1
|
+
import { h as A } from "../../useActions-DoZCMPfW.js";
|
|
2
|
+
import { a as X } from "../../logger-_fg_Za9y.js";
|
|
3
|
+
import { a as S } from "../../useLoadMore-CdqyUIQQ.js";
|
|
4
|
+
import { u as Le } from "../../useLoadMore-CdqyUIQQ.js";
|
|
5
|
+
import { u as P } from "../../eventBusSubscribe-CzlS132j.js";
|
|
6
|
+
import { useState as b, useCallback as p, useMemo as y, useEffect as k, useRef as z } from "preact/hooks";
|
|
7
|
+
import { a as Me, g as Te, u as Ne } from "../../useHistory-BJo9WE5S.js";
|
|
8
|
+
import { s as C } from "../../index.es-XNBESE3P.js";
|
|
9
|
+
import { d as O } from "../../eventBusDispatch-DPR2Vwd4.js";
|
|
10
10
|
import { p as R } from "../../parseNumber-QA48nJLp.js";
|
|
11
|
-
function
|
|
11
|
+
function le(e) {
|
|
12
12
|
const n = S((t) => t.response);
|
|
13
|
-
return e && Array.isArray(e) || e &&
|
|
13
|
+
return e && Array.isArray(e) || e && X(e) ? e : n;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function de(e, n) {
|
|
16
16
|
const t = e.data?.filter((d) => d.selected).length ?? 0, { active: o } = {
|
|
17
17
|
active: t > 0,
|
|
18
18
|
...n
|
|
19
19
|
}, [r, c] = b(o), { toggleProductFilter: i } = A(), u = p(() => {
|
|
20
20
|
c(!r);
|
|
21
21
|
}, [r]);
|
|
22
|
-
return
|
|
22
|
+
return P({
|
|
23
23
|
event: "events/removeAllFilters",
|
|
24
24
|
callback: () => {
|
|
25
25
|
c(!1);
|
|
@@ -35,7 +35,7 @@ function le(e, n) {
|
|
|
35
35
|
toggleProductFilter: i
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function fe() {
|
|
39
39
|
const { loading: e, facets: n } = S((t) => ({
|
|
40
40
|
loading: t.loading,
|
|
41
41
|
facets: t.response?.products?.facets ?? []
|
|
@@ -47,11 +47,11 @@ function de() {
|
|
|
47
47
|
facets: n
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function j(e, n) {
|
|
51
51
|
const t = n - e;
|
|
52
52
|
return !isNaN(t) && t > 0 ? new Array(n - e).fill(void 0).map((o, r) => r + e) : [];
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function pe(e) {
|
|
55
55
|
const { query: n, products: t } = S((o) => ({
|
|
56
56
|
query: o.query,
|
|
57
57
|
products: o.response.products
|
|
@@ -72,7 +72,7 @@ function fe(e) {
|
|
|
72
72
|
from: (w - 1) * t.size,
|
|
73
73
|
page: w,
|
|
74
74
|
current: w === i
|
|
75
|
-
}), h = i > 1 ? f(i - 1) : void 0, v = i < u ? f(i + 1) : void 0, m = i - c - 1 > 1 ? f(1) : void 0, g = i + c + 1 < u ? f(u) : void 0, F =
|
|
75
|
+
}), h = i > 1 ? f(i - 1) : void 0, v = i < u ? f(i + 1) : void 0, m = i - c - 1 > 1 ? f(1) : void 0, g = i + c + 1 < u ? f(u) : void 0, F = j(1, u + 1).filter(d).map(f);
|
|
76
76
|
return !m && F[0]?.page === 2 && F.unshift(f(1)), !g && F[F.length - 1]?.page === u - 1 && F.push(f(u)), {
|
|
77
77
|
totalPages: u,
|
|
78
78
|
resultsFrom: s,
|
|
@@ -86,10 +86,10 @@ function fe(e) {
|
|
|
86
86
|
};
|
|
87
87
|
}, [n, t, e?.width]);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function ge() {
|
|
90
90
|
const [e, n] = b([]), [t, o] = b([]);
|
|
91
|
-
return
|
|
92
|
-
|
|
91
|
+
return k(() => {
|
|
92
|
+
C(async (r) => {
|
|
93
93
|
const { products: c, segments: i } = await r.getSearchSessionParams();
|
|
94
94
|
n(i ?? []), o(c?.personalizationBoost ?? []);
|
|
95
95
|
});
|
|
@@ -98,7 +98,7 @@ function pe() {
|
|
|
98
98
|
boost: t
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function q() {
|
|
102
102
|
const { facets: e } = S((s) => ({
|
|
103
103
|
facets: s.response.products?.facets ?? []
|
|
104
104
|
})), { replaceFilter: n, toggleProductFilter: t } = A(), o = p(
|
|
@@ -152,15 +152,15 @@ function j() {
|
|
|
152
152
|
toRangeFilter: d
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function E() {
|
|
156
156
|
const { filter: e } = S((u) => ({
|
|
157
157
|
filter: u.query.products?.filter ?? []
|
|
158
|
-
})), { updateSearch: n } = A(), { selectFilters: t, toValueFilter: o, toRangeFilter: r } =
|
|
158
|
+
})), { updateSearch: n } = A(), { selectFilters: t, toValueFilter: o, toRangeFilter: r } = q(), c = y(() => e ? e.filter(t).flatMap((u) => "value" in u ? o(u) : "range" in u ? r(u) : []).filter(Boolean) : [], [e, t, r, o]), i = p(() => {
|
|
159
159
|
n({
|
|
160
160
|
products: {
|
|
161
161
|
filter: []
|
|
162
162
|
}
|
|
163
|
-
}),
|
|
163
|
+
}), O({
|
|
164
164
|
event: "events/removeAllFilters",
|
|
165
165
|
params: null
|
|
166
166
|
});
|
|
@@ -172,22 +172,22 @@ function q() {
|
|
|
172
172
|
removeAll: i
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function V(e) {
|
|
176
176
|
const { replaceFilter: n } = A(), { query: t, products: o } = S((g) => ({
|
|
177
177
|
query: g.query,
|
|
178
178
|
products: g.response.products
|
|
179
|
-
})), r = o?.facets?.find((g) => g.id === e), c = t.products?.filter?.find((g) => g.field === r?.field), [i, u] =
|
|
179
|
+
})), r = o?.facets?.find((g) => g.id === e), c = t.products?.filter?.find((g) => g.field === r?.field), [i, u] = U(c), d = r && "min" in r ? Math.floor(r.min ?? 0) : 0, s = r && "max" in r ? Math.ceil(r.max ?? 0) : 0, a = y(() => [i ?? d, u ?? s], [i, u, d, s]), l = i !== void 0 || u !== void 0, [f, h] = b(l), v = p(() => {
|
|
180
180
|
h((g) => !g);
|
|
181
181
|
}, []), m = p(
|
|
182
182
|
([g, F]) => {
|
|
183
183
|
if (!r)
|
|
184
184
|
return;
|
|
185
|
-
const w =
|
|
185
|
+
const w = B(g, F, d, s);
|
|
186
186
|
n(r.field, w);
|
|
187
187
|
},
|
|
188
188
|
[d, s, n, r]
|
|
189
189
|
);
|
|
190
|
-
return
|
|
190
|
+
return P({
|
|
191
191
|
event: "events/removeAllFilters",
|
|
192
192
|
callback: () => {
|
|
193
193
|
h(!1);
|
|
@@ -205,9 +205,9 @@ function E(e) {
|
|
|
205
205
|
active: f,
|
|
206
206
|
/** Toggle active state function */
|
|
207
207
|
toggleActive: v
|
|
208
|
-
} :
|
|
208
|
+
} : $;
|
|
209
209
|
}
|
|
210
|
-
const
|
|
210
|
+
const $ = {
|
|
211
211
|
min: 0,
|
|
212
212
|
max: 0,
|
|
213
213
|
range: [0, 0],
|
|
@@ -217,19 +217,19 @@ const V = {
|
|
|
217
217
|
updateRange: () => {
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
|
-
function
|
|
220
|
+
function U(e) {
|
|
221
221
|
const n = e?.range?.[0];
|
|
222
222
|
return typeof n == "object" && ("gte" in n || "lte" in n) ? [R(n.gte), R(n.lte)] : [void 0, void 0];
|
|
223
223
|
}
|
|
224
|
-
function
|
|
224
|
+
function B(e, n, t, o) {
|
|
225
225
|
const r = e !== void 0 ? Math.floor(e) : void 0, c = n !== void 0 ? Math.ceil(n) : void 0, i = r !== void 0, u = c !== void 0;
|
|
226
226
|
if ((t === r || !i) && (o === c || !u))
|
|
227
227
|
return;
|
|
228
228
|
const d = {};
|
|
229
229
|
return i && r !== t && (d.gte = r.toString()), u && c !== o && (d.lte = c.toString()), Object.keys(d).length > 0 ? d : void 0;
|
|
230
230
|
}
|
|
231
|
-
function
|
|
232
|
-
const { min: t, max: o, range: r, updateRange: c } =
|
|
231
|
+
function me(e, n) {
|
|
232
|
+
const { min: t, max: o, range: r, updateRange: c } = V(e), { filters: i } = E(), u = y(() => {
|
|
233
233
|
const l = i.find((m) => m?.filter?.range);
|
|
234
234
|
let f = null;
|
|
235
235
|
if (l) {
|
|
@@ -277,12 +277,12 @@ function ge(e, n) {
|
|
|
277
277
|
isSelected: a
|
|
278
278
|
};
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function he() {
|
|
281
281
|
const { products: e, keywords: n, popularSearches: t, categories: o } = S((r) => ({
|
|
282
|
-
products: r.response.products ??
|
|
283
|
-
keywords: r.response.keywords ??
|
|
284
|
-
popularSearches: r.response.popularSearches ??
|
|
285
|
-
categories: r.response.categories ??
|
|
282
|
+
products: r.response.products ?? L,
|
|
283
|
+
keywords: r.response.keywords ?? L,
|
|
284
|
+
popularSearches: r.response.popularSearches ?? L,
|
|
285
|
+
categories: r.response.categories ?? L
|
|
286
286
|
}));
|
|
287
287
|
return {
|
|
288
288
|
/** Array of products */
|
|
@@ -295,18 +295,19 @@ function me() {
|
|
|
295
295
|
categories: o
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
|
-
|
|
298
|
+
const L = { hits: [], total: 0 };
|
|
299
|
+
function ve() {
|
|
299
300
|
const e = S((t) => t.query.products?.filter);
|
|
300
301
|
return y(() => e ? e.reduce((t, o) => t + (Array.isArray(o.value) ? o.value.length : 1), 0) : 0, [e]);
|
|
301
302
|
}
|
|
302
|
-
const
|
|
303
|
-
function
|
|
303
|
+
const D = 5 * 60 * 1e3, M = /* @__PURE__ */ new Map();
|
|
304
|
+
function Se(e) {
|
|
304
305
|
const [n, t] = b({
|
|
305
306
|
product: null,
|
|
306
307
|
loading: !0,
|
|
307
308
|
error: null
|
|
308
309
|
});
|
|
309
|
-
return
|
|
310
|
+
return k(() => {
|
|
310
311
|
if (!e) {
|
|
311
312
|
t({
|
|
312
313
|
product: null,
|
|
@@ -320,7 +321,7 @@ function ve(e) {
|
|
|
320
321
|
loading: !0,
|
|
321
322
|
error: null
|
|
322
323
|
}));
|
|
323
|
-
const o =
|
|
324
|
+
const o = I(e);
|
|
324
325
|
if (o) {
|
|
325
326
|
t({
|
|
326
327
|
product: o,
|
|
@@ -329,8 +330,8 @@ function ve(e) {
|
|
|
329
330
|
});
|
|
330
331
|
return;
|
|
331
332
|
}
|
|
332
|
-
|
|
333
|
-
|
|
333
|
+
H(e).then((r) => {
|
|
334
|
+
K(e, r), t({
|
|
334
335
|
product: r,
|
|
335
336
|
loading: !1,
|
|
336
337
|
error: null
|
|
@@ -344,34 +345,34 @@ function ve(e) {
|
|
|
344
345
|
});
|
|
345
346
|
}, [e]), n;
|
|
346
347
|
}
|
|
347
|
-
function
|
|
348
|
+
function _(e) {
|
|
348
349
|
const n = window.Shopify?.routes?.root;
|
|
349
350
|
return n ? new URL(`${n}products/${e}`, window.location.href) : e;
|
|
350
351
|
}
|
|
351
|
-
async function
|
|
352
|
-
const n = await fetch(
|
|
352
|
+
async function H(e) {
|
|
353
|
+
const n = await fetch(_(`/products/${e}.js`));
|
|
353
354
|
if (!n.ok)
|
|
354
355
|
throw new Error(`Failed to fetch product: ${n.status} ${n.statusText}`);
|
|
355
356
|
return n.json();
|
|
356
357
|
}
|
|
357
|
-
function
|
|
358
|
-
const n =
|
|
359
|
-
return n ? Date.now() - n.created >
|
|
358
|
+
function I(e) {
|
|
359
|
+
const n = M.get(e);
|
|
360
|
+
return n ? Date.now() - n.created > D ? (M.delete(e), null) : n.product : null;
|
|
360
361
|
}
|
|
361
|
-
function
|
|
362
|
-
|
|
362
|
+
function K(e, n) {
|
|
363
|
+
M.set(e, {
|
|
363
364
|
product: n,
|
|
364
365
|
created: Date.now()
|
|
365
366
|
});
|
|
366
367
|
}
|
|
367
|
-
function
|
|
368
|
+
function x(e) {
|
|
368
369
|
return e && !Number.isNaN(e) ? e : 0;
|
|
369
370
|
}
|
|
370
|
-
function
|
|
371
|
+
function ye(e, n) {
|
|
371
372
|
const { from: t, size: o, total: r } = S((s) => ({
|
|
372
|
-
from:
|
|
373
|
-
size:
|
|
374
|
-
total:
|
|
373
|
+
from: x(s.query.products?.from ?? 0),
|
|
374
|
+
size: x(s.response?.products?.size ?? n),
|
|
375
|
+
total: x(s.response?.products?.total ?? 0)
|
|
375
376
|
})), { updateSearch: c } = A(), i = t + o, u = y(() => [...e].reverse().filter((s) => s < r), [e, r]), d = p(
|
|
376
377
|
(s) => {
|
|
377
378
|
c({
|
|
@@ -397,11 +398,11 @@ function Se(e, n) {
|
|
|
397
398
|
handleSizeChange: d
|
|
398
399
|
};
|
|
399
400
|
}
|
|
400
|
-
function
|
|
401
|
+
function Z(e, n) {
|
|
401
402
|
return e.length !== n.length ? !1 : e.every((t) => n.find((o) => t.field === o.field && t.order === o.order));
|
|
402
403
|
}
|
|
403
|
-
function
|
|
404
|
-
const n = S((c) => c.query), { updateSearch: t } = A(), o = e.find((c) =>
|
|
404
|
+
function Fe(e) {
|
|
405
|
+
const n = S((c) => c.query), { updateSearch: t } = A(), o = e.find((c) => Z(c.value.sort, n.products?.sort || []))?.id ?? e[0]?.id, r = p(
|
|
405
406
|
(c) => {
|
|
406
407
|
const i = e.find((u) => u.id === c);
|
|
407
408
|
i && t({
|
|
@@ -419,8 +420,8 @@ function ye(e) {
|
|
|
419
420
|
setSort: r
|
|
420
421
|
};
|
|
421
422
|
}
|
|
422
|
-
const
|
|
423
|
-
function
|
|
423
|
+
const T = window.SpeechRecognition || window.webkitSpeechRecognition, G = !!(T && typeof T == "function");
|
|
424
|
+
function J() {
|
|
424
425
|
return {
|
|
425
426
|
listening: !1,
|
|
426
427
|
startListening: () => {
|
|
@@ -429,14 +430,14 @@ function G() {
|
|
|
429
430
|
}
|
|
430
431
|
};
|
|
431
432
|
}
|
|
432
|
-
function
|
|
433
|
+
function Q({
|
|
433
434
|
language: e = "en-US",
|
|
434
435
|
interimResults: n = !1,
|
|
435
436
|
onResult: t,
|
|
436
437
|
onError: o
|
|
437
438
|
} = {}) {
|
|
438
|
-
const [r, c] = b(!1), i =
|
|
439
|
-
const s = new
|
|
439
|
+
const [r, c] = b(!1), i = z(null), u = p(() => {
|
|
440
|
+
const s = new T();
|
|
440
441
|
s.lang = e, s.interimResults = n, s.onstart = () => c(!0), t && (s.onresult = (a) => {
|
|
441
442
|
const { transcript: l } = a.results?.[0]?.[0];
|
|
442
443
|
t(l);
|
|
@@ -450,8 +451,8 @@ function J({
|
|
|
450
451
|
stopListening: d
|
|
451
452
|
};
|
|
452
453
|
}
|
|
453
|
-
const
|
|
454
|
-
function
|
|
454
|
+
const we = G ? Q : J;
|
|
455
|
+
function W(e, n) {
|
|
455
456
|
if (!e.length || !n.length) return [];
|
|
456
457
|
const t = n.reduce((o, r) => (o[r] = {}, o), {});
|
|
457
458
|
return e.forEach((o) => {
|
|
@@ -469,7 +470,7 @@ function Q(e, n) {
|
|
|
469
470
|
}))
|
|
470
471
|
}));
|
|
471
472
|
}
|
|
472
|
-
function
|
|
473
|
+
function Y(e, n) {
|
|
473
474
|
return e.length ? e.map(({ field: t, options: o }) => ({
|
|
474
475
|
field: t,
|
|
475
476
|
options: o.map((r) => {
|
|
@@ -482,24 +483,24 @@ function W(e, n) {
|
|
|
482
483
|
})
|
|
483
484
|
})) : [];
|
|
484
485
|
}
|
|
485
|
-
const
|
|
486
|
-
function
|
|
487
|
-
if (
|
|
488
|
-
return 1e3 +
|
|
486
|
+
const N = ["4XS", "3XS", "2XS", "XXS", "XS", "S", "M", "L", "XL", "XXL", "2XL", "XXXL", "3XL", "4XL"];
|
|
487
|
+
function ee(e) {
|
|
488
|
+
if (N.includes(e))
|
|
489
|
+
return 1e3 + N.indexOf(e);
|
|
489
490
|
const n = parseFloat(e);
|
|
490
491
|
return isNaN(n) ? e : n;
|
|
491
492
|
}
|
|
492
|
-
function
|
|
493
|
+
function te(e, n) {
|
|
493
494
|
return [...n].sort((t, o) => {
|
|
494
|
-
const [r, c] = [t.value, o.value].map(
|
|
495
|
+
const [r, c] = [t.value, o.value].map(ee);
|
|
495
496
|
return r < c ? -1 : 1;
|
|
496
497
|
});
|
|
497
498
|
}
|
|
498
|
-
function
|
|
499
|
-
const [t, o] = b({}), r = y(() =>
|
|
499
|
+
function be(e = [], n = []) {
|
|
500
|
+
const [t, o] = b({}), r = y(() => W(e, n).map(({ field: s, options: a }) => ({
|
|
500
501
|
field: s,
|
|
501
|
-
options:
|
|
502
|
-
})), [e, n]), c = y(() =>
|
|
502
|
+
options: te(s, a)
|
|
503
|
+
})), [e, n]), c = y(() => Y(r, t), [r, t]), i = p((d, s) => {
|
|
503
504
|
o((a) => {
|
|
504
505
|
const l = { ...a };
|
|
505
506
|
return l[d] === s ? delete l[d] : l[d] = s, l;
|
|
@@ -511,26 +512,26 @@ function we(e = [], n = []) {
|
|
|
511
512
|
return { swatches: c, toggleOption: i, matchedSkus: u };
|
|
512
513
|
}
|
|
513
514
|
export {
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
515
|
+
Me as addToHistory,
|
|
516
|
+
Te as getSavedHistory,
|
|
517
|
+
G as speechToTextSupported,
|
|
517
518
|
A as useActions,
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
519
|
+
le as useDecoratedSearchResults,
|
|
520
|
+
de as useFacet,
|
|
521
|
+
fe as useFacets,
|
|
522
|
+
Ne as useHistory,
|
|
523
|
+
Le as useLoadMore,
|
|
523
524
|
S as useNostoAppState,
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
525
|
+
pe as usePagination,
|
|
526
|
+
ge as usePersonalization,
|
|
527
|
+
E as useProductFilters,
|
|
528
|
+
V as useRange,
|
|
529
|
+
me as useRangeSelector,
|
|
530
|
+
he as useResponse,
|
|
531
|
+
ve as useSelectedFiltersCount,
|
|
532
|
+
Se as useShopifyProduct,
|
|
533
|
+
ye as useSizeOptions,
|
|
534
|
+
Fe as useSort,
|
|
535
|
+
we as useSpeechToText,
|
|
536
|
+
be as useSwatches
|
|
536
537
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../AutocompletePageProvider-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../AutocompletePageProvider-CFcim_G9.cjs"),T=require("../../CategoryPageProvider-C2nqTdZ8.cjs"),h=require("../../useActions-B6FFW8xI.cjs"),I=require("../../SerpPageProvider-D5cD0ttm.cjs"),d=require("../../jsxRuntime.module-B3sGoTIU.cjs"),g=require("../../ErrorBoundary-CKn3Ecpu.cjs"),b=require("../../disableNativeAutocomplete-DI6zaZII.cjs"),P=require("../../unique-BXXNictB.cjs"),C=require("preact"),N=require("../../logger-Boh_C6Bz.cjs"),p=require("../../search-DItu5YCc.cjs");function O(e){let n;return t=>{n&&clearTimeout(n),n=setTimeout(t,e)}}function q(e){return Array.from(document.querySelectorAll(e))}function R(e){const n=[];let t=e.parentNode;for(;t&&t!==document&&t instanceof Element;)n.push(t),t=t.parentNode;return n}function E([e,n],t){const o=r=>{const s=r.target;s instanceof HTMLElement&&e&&s!==e&&s!==n&&!R(s).includes(e)&&t()};return document.addEventListener("click",o),{destroy:()=>{document.removeEventListener("click",o)}}}function A(e,n){e.tabIndex=0,e.addEventListener("blur",n)}function S(e){return typeof e=="string"?{selector:e,position:"last"}:{position:"last",...e}}function H({selector:e,timeout:n=500}){return new Promise(t=>{const o=q(e);if(o.length>0)return t(o);const r=new MutationObserver(()=>{const i=q(e);i.length>0&&(r.disconnect(),clearTimeout(s),t(i))}),s=setTimeout(()=>{r.disconnect(),N.logger.warn(`Timed out (${n}) while waiting for element ${e}`),t([])},n);r.observe(document.body,{childList:!0,subtree:!0})})}function x(e,n,t){n.style.display="none";const o=(()=>{if(e.parentElement&&e.parentElement.classList.contains("nosto-autocomplete-wrapper"))return e.parentElement;const a=document.createElement("div");return a.className="nosto-autocomplete-wrapper",e.parentNode?.insertBefore(a,e.nextSibling),a.appendChild(e),a})(),r=S(t),s=r&&document.querySelector(r.selector);if(s){const a=document.createElement("form");a.className="nosto-dropdown-form",a.appendChild(n),r.position==="first"?s.prepend(a):s.appendChild(a)}else o.appendChild(n);const i={index:-1,onChangeListeners:[]},c=(a,u)=>{const f=a.length;f===0&&(u=-1),i.index=u>=0?u%f:f-1,i.onChangeListeners.forEach(D=>D())},l=()=>{i.index=-1,i.onChangeListeners.forEach(a=>a())},m=()=>i.index;return{element:n,hide:()=>{n.style.display="none",l()},show:()=>{n.style.display="inherit"},isOpen:()=>n.style.display!=="none",goDown:()=>{const a=Array.from(n.getElementsByClassName("ns-autocomplete-element")),u=m();c(a,u+1)},goUp:()=>{const a=Array.from(n.getElementsByClassName("ns-autocomplete-element")),u=m();c(a,u-1)},highlight:c,highlightedIndex:m,submitHighlightedItem:a=>{Array.from(n.querySelectorAll(".ns-autocomplete-element"))[a]?.click()},onHighlightChange:a=>{i.onChangeListeners.push(a)}}}function $(e,n){const t=document.createElement("div");return t.className="nosto-autocomplete-dropdown",{...x(e,t,n),element:t}}const y="nosto:search-js:history";function v(e,n,t){const o=document.createElement("div");return o.className="nosto-autocomplete-history",{...x(e,o,n),element:o,add:s=>{const c=(p.getLocalStorageItem(y)??[]).filter(l=>l!==s).slice(t?-t:0);c.push(s),p.setLocalStorageItem(y,c)},get:()=>(p.getLocalStorageItem(y)??[]).reverse().filter(i=>!!i)}}async function F(e,{config:n,dropdown:t,history:o,renderHistory:r,store:s}){const{historyEnabled:i,minQueryLength:c}=n;if(e.length<c&&i&&r&&!o.isOpen()){o.show();return}if(e.length<c)return;t.hide();const l=s.getState()?.query?.query;l&&l!==e&&await h.newSearch({config:n,store:s},{query:e}),t.show()}async function k(e,n){const{config:t,renderHistory:o,history:r}=n,{historyEnabled:s,minQueryLength:i}=t;if(!o||e.length>=i||!s||r.isOpen())return;const c=j(n);r.onHighlightChange(()=>{c(o,r.element)}),r.show();const l=P.measure("renderHistory");c(o,r.element),l()}async function Q(e,{config:n,dropdown:t,history:o,store:r,debouncer:s}){const{minQueryLength:i,historyEnabled:c}=n;if(e.length<i&&!c){t.hide(),o.hide();return}if(e.length<i&&c){t.hide(),o.show();return}o.hide(),s(async()=>{h.newSearch({config:n,store:r},{query:e}),t.show()})}function M(e,n,t){const{config:o,debouncer:r}=t;if(r(()=>{}),e.length>=o.minQueryLength)return L(n,t.dropdown,t.history);if(o.historyEnabled)return L(n,t.history,t.dropdown)}function L(e,n,t){if(!n.isOpen()&&e==="ArrowDown"){n.show(),t.hide();return}if(e==="Escape"&&n.hide(),!!n.isOpen()){if(e==="ArrowDown")n.goDown();else if(e==="ArrowUp")n.goUp();else if(e==="Enter"){const o=n.highlightedIndex();return o>=0&&n.submitHighlightedItem(o),n.hide(),o>=0}}}function U(e,{config:n,dropdown:t,history:o,onNavigateToSearch:r,store:s}){t.hide(),o.hide(),!(e.length<n.minQueryLength)&&(o.add(e),s.updateState({historyItems:o.get()}),r?.({query:e}))}async function K(e,n){const{inputCssSelector:t,timeout:o}=e,r=S(t).selector,s=await H({selector:r,timeout:o});if(s.length===0)throw new Error(`No elements found for selector: ${r}`);s.forEach(i=>{_(i,e,n)})}async function _(e,n,t){const{config:o,dropdownCssSelector:r}=n,s=$(e,r),i=v(e,r,o.historySize),c={...n,input:e,dropdown:s,history:i,store:t,debouncer:O(o.debounceDelay)};G(c),e.setAttribute("data-nosto-element","search-input"),t.updateState({historyItems:i.get()}),b.disableNativeAutocomplete(e),t.onInit(()=>{z(c)}),b.bindInput(e,{onInput:l=>Q(l,c),onFocus:l=>k(l,c),onClick:l=>F(l,c),onSubmit:l=>U(l,c),onKeyDown:(l,m)=>M(l,m,c)}),A(i.element,i.hide),A(s.element,s.hide),E([i.element,e],i.hide),E([s.element,e],s.hide)}function z(e){const{dropdown:n,renderAutocomplete:t}=e;if(!t)return;const o=j(e);n.onHighlightChange(()=>{o(t,n.element)});const r=P.measure("renderAutocomplete");o(t,n.element),r()}async function G(e){const{input:n,renderSpeechToText:t,config:o,store:r}=e;if(!t)return;const s="ns-autocomplete-voice-position";if(!!n.parentElement?.querySelector(`.${s}`))return;const c=document.createElement("div");c.className=s,n.insertAdjacentElement("afterend",c);const l=await t();C.render(d.u(g.ErrorBoundary,{children:d.u(w.AutocompletePageProvider,{config:o,store:r,children:l})}),c)}function j(e){const{config:n,store:t}=e;return(o,r)=>C.render(d.u(g.ErrorBoundary,{children:d.u(w.AutocompletePageProvider,{config:n,store:t,children:o()})}),r)}async function B({cssSelector:e,timeout:n,renderComponent:t}){const o=S(e).selector,r=await H({selector:o,timeout:n??100});if(r.length===0)throw new Error(`No elements found for selector: ${o}`);r.length>1&&N.logger.warn(`Multiple (${r.length}) elements found for selector: ${o}`),C.render(t(),r[0])}async function J(e,n){const{render:t}=e,o=await t();B({...e,renderComponent:()=>d.u(g.ErrorBoundary,{children:d.u(T.CategoryPageProvider,{store:n,config:e.config,children:o})})})}async function V(e,n){const{render:t}=e,o=await t();B({...e,renderComponent:()=>d.u(g.ErrorBoundary,{children:d.u(I.SearchPageProvider,{store:n,config:e.config,children:o})})})}async function W({autocomplete:e,category:n,serp:t}){const o={};if(e){const r=h.createStore({query:e.query});await K({...e,config:w.makeAutocompleteConfig(e.config)},r),o.autocomplete={store:r}}if(n){const r=h.createStore({query:n.query});await J({...n,config:T.makeCategoryConfig(n.config)},r),o.category={store:r}}if(t){const r=h.createStore({query:t.query});await V({...t,config:I.makeSerpConfig(t.config)},r),o.serp={store:r}}return o}exports.init=W;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { A as L, m as j } from "../../AutocompletePageProvider-
|
|
2
|
-
import { C as O, m as R } from "../../CategoryPageProvider-
|
|
3
|
-
import { n as T, c as p } from "../../useActions-
|
|
4
|
-
import { S as $, m as F } from "../../SerpPageProvider-
|
|
1
|
+
import { A as L, m as j } from "../../AutocompletePageProvider-CJb7OEAr.js";
|
|
2
|
+
import { C as O, m as R } from "../../CategoryPageProvider-BGqhQtdT.js";
|
|
3
|
+
import { n as T, c as p } from "../../useActions-DoZCMPfW.js";
|
|
4
|
+
import { S as $, m as F } from "../../SerpPageProvider-wkZs_QWn.js";
|
|
5
5
|
import { u as d } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
6
6
|
import { E as h } from "../../ErrorBoundary-DTRm_60r.js";
|
|
7
7
|
import { d as k, b as B } from "../../disableNativeAutocomplete-Bkta_WR2.js";
|
|
8
8
|
import { a as I } from "../../unique-Cv2g464w.js";
|
|
9
9
|
import { render as y } from "preact";
|
|
10
10
|
import { l as q } from "../../logger-_fg_Za9y.js";
|
|
11
|
-
import { g as w, a as Q } from "../../search-
|
|
11
|
+
import { g as w, a as Q } from "../../search-xLgL6P5R.js";
|
|
12
12
|
function U(e) {
|
|
13
13
|
let n;
|
|
14
14
|
return (t) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../useActions-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../useActions-B6FFW8xI.cjs"),r=require("../../InfiniteScrollWithObserver-DAtCSz5E.cjs"),t=require("../../useLoadMore-DYxXgyV2.cjs");exports.newSearch=e.newSearch;exports.updateSearch=e.updateSearch;exports.InfiniteScrollWithObserver=r.InfiniteScrollWithObserver;exports.intersectionObserverSupported=r.intersectionObserverSupported;exports.getNextPageQuery=t.getNextPageQuery;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as t, u as a } from "../../useActions-
|
|
2
|
-
import { I as s, i } from "../../InfiniteScrollWithObserver-
|
|
3
|
-
import { g as p } from "../../useLoadMore-
|
|
1
|
+
import { n as t, u as a } from "../../useActions-DoZCMPfW.js";
|
|
2
|
+
import { I as s, i } from "../../InfiniteScrollWithObserver-CtEBs3Ts.js";
|
|
3
|
+
import { g as p } from "../../useLoadMore-CdqyUIQQ.js";
|
|
4
4
|
export {
|
|
5
5
|
s as InfiniteScrollWithObserver,
|
|
6
6
|
p as getNextPageQuery,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../jsxRuntime.module-B3sGoTIU.cjs"),l=require("../../index.es-Dp6Iaxz3.cjs"),u=require("../../BaseElement-CIHACCWd.cjs"),S=require("../../useActions-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../jsxRuntime.module-B3sGoTIU.cjs"),l=require("../../index.es-Dp6Iaxz3.cjs"),u=require("../../BaseElement-CIHACCWd.cjs"),S=require("../../useActions-B6FFW8xI.cjs"),d=require("preact/hooks"),g=require("../../SerpPageProvider-D5cD0ttm.cjs"),P="nosto:search-js:scrollPos";function m(){window.sessionStorage.setItem(P,window.scrollY.toString())}function p({children:s,hit:e,componentProps:t,as:n}){const{pageType:o}=S.useConfig(),r=o==="autocomplete"?void 0:o==="search"?"serp":o,c=d.useCallback(()=>{e&&r&&l.s(i=>i.recordSearchClick(r,e)),m()},[e,r]);return a.u(u.BaseElement,{as:n,onClick:c,componentProps:t,children:s})}exports.SearchPageProvider=g.SearchPageProvider;exports.SerpElement=p;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { u as i } from "../../jsxRuntime.module-Bzuv3cXw.js";
|
|
2
2
|
import { s as l } from "../../index.es-XNBESE3P.js";
|
|
3
3
|
import { B as m } from "../../BaseElement-DD_4UwDm.js";
|
|
4
|
-
import { b as p } from "../../useActions-
|
|
4
|
+
import { b as p } from "../../useActions-DoZCMPfW.js";
|
|
5
5
|
import { useCallback as f } from "preact/hooks";
|
|
6
|
-
import { S as h } from "../../SerpPageProvider-
|
|
6
|
+
import { S as h } from "../../SerpPageProvider-wkZs_QWn.js";
|
|
7
7
|
const S = "nosto:search-js:scrollPos";
|
|
8
8
|
function g() {
|
|
9
9
|
window.sessionStorage.setItem(S, window.scrollY.toString());
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const m=require("./index.es-Dp6Iaxz3.cjs"),i=require("./logger-Boh_C6Bz.cjs");async function y(t,{hitDecorators:e,...r},c){const n=await c(t,r);if(!n.products?.hits?.length||!e?.length)return n;const o=s=>e.reduce((a,u)=>u(a),s);return{...n,products:{...n.products,hits:n.products.hits.map(o)}}}function h(t,e,r){const c=JSON.stringify(e);try{r.setItem(t,c)}catch(n){i.logger.warn(n)}}function g(t,e){try{const r=e.getItem(t);if(r)return JSON.parse(r)}catch(r){i.logger.warn(r)}}function I(t,e){h(t,e,localStorage)}function C(t,e){h(t,e,sessionStorage)}function R(t){return g(t,localStorage)}function b(t){return g(t,sessionStorage)}const p="nosto:search-js:cache",k=60*1e3;function N(t,e){C(p,{query:t,result:e,created:Date.now()})}function T(t){const e=b(p);if(!e||!z(e))return null;const r=d(e.query);return!i.isEqual(d(t),r)||Date.now()-e.created>k?null:e.result}function d(t){const e={...t,time:void 0,products:{...t.products,size:void 0}};return JSON.parse(JSON.stringify(e))}function z(t){return typeof t=="object"&&t!==null&&"query"in t&&"result"in t&&"created"in t}async function E(t,{usePersistentCache:e,...r},c){if(!e)return c(t,r);const n=await L(t,r,c);return N(t,n),n}async function L(t,e,r){const{from:c=0,size:n=0}=t.products||{},o=T(t);if(!o)return await r(t,e);const s=o?.products?.size??0,a=o?.products?.hits??[];if(n===s)return o;if(n<s)return{...o,products:{...o.products,size:n,hits:a.slice(0,n),total:o.products?.total||0}};const u=n-a.length,S=c>0?c+1:n-u,w={...t,products:{...t.products,from:S,size:u}},l=await r(w,e);return{...o,products:{...o.products,size:n,hits:[...o.products?.hits||[],...l.products?.hits||[]],total:l.products?.total||0}}}const O=3e4,f=new Map;function _(t,e){const r=f.get(t);if(!r)return;const c=Date.now()-r.created>O,n=i.isEqual(e,r.query);if(c||!n){f.delete(t);return}return r.result}function J(t,e,r){f.set(t,{query:e,result:r,created:Date.now()})}async function W(t,e,r){if(!e.useMemoryCache)return r(t,e);const c=JSON.stringify(t),n=_(c,t);if(n)return n;const o=await r(t,e);return J(c,t,o),o}async function D(t,e,r){if(!e.redirect)return r(t,e);const c=await r(t,e);if(c.keywords?.hits?.length){const n=c.keywords.hits.find(o=>o.keyword===t.query&&o._redirect);n&&n._redirect&&(window.location.href=n._redirect)}return c}function M(t){return new Promise(e=>setTimeout(e,t))}async function V(t,{maxRetries:e=0,retryInterval:r=0,...c},n){let o=0;for(;;)try{return await n(t,c)}catch(s){if(o>=e)throw s;if(!j(s))throw i.logger.info("Skipping retry logic for",s),s;o++,await M(r)}}function j(t){return!t||typeof t!="object"?!1:!("status"in t)||x(t.status)}function x(t){return typeof t=="number"&&(t<400||t>=500)}async function A(t,e={}){const r=await new Promise(m.s);return K(r.search,V,D,W,E,y)(t,e)}function K(t,...e){return e.reduce((r,c)=>(n,o)=>c(n,o,r),t)}exports.getLocalStorageItem=R;exports.search=A;exports.setLocalStorageItem=I;
|