@nosto/search-js 3.4.0 → 3.5.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.
Files changed (72) hide show
  1. package/dist/AutocompletePageProvider-BoV4iLil.js +29 -0
  2. package/dist/AutocompletePageProvider-DPTHPXyz.cjs +1 -0
  3. package/dist/BaseElement-DgwqyaY8.cjs +1 -0
  4. package/dist/BaseElement-iXMoOyxY.js +23 -0
  5. package/dist/CategoryPageProvider-CkeR1heA.cjs +1 -0
  6. package/dist/CategoryPageProvider-Dzcbnz1W.js +26 -0
  7. package/dist/{InfiniteScrollWithObserver-DEmjpb8o.cjs → InfiniteScrollWithObserver-Bmi6zgwp.cjs} +1 -1
  8. package/dist/{InfiniteScrollWithObserver-DfQ4cqvs.js → InfiniteScrollWithObserver-CnR-vqQP.js} +1 -1
  9. package/dist/SerpPageProvider-CCPCHjKU.cjs +1 -0
  10. package/dist/SerpPageProvider-Ca6ZoAOq.js +26 -0
  11. package/dist/{baseConfig-CR4INhSV.cjs → baseConfig-0GdMC5Qa.cjs} +1 -1
  12. package/dist/{baseConfig-BG_h7eA6.js → baseConfig-CvAG6x_p.js} +3 -3
  13. package/dist/bindInput-BnKvCky1.cjs +1 -0
  14. package/dist/bindInput-CCx0Fhsg.js +27 -0
  15. package/dist/core/core.cjs.js +1 -1
  16. package/dist/core/core.es.js +1 -1
  17. package/dist/preact/autocomplete/autocomplete.cjs.js +1 -1
  18. package/dist/preact/autocomplete/autocomplete.d.ts +1 -0
  19. package/dist/preact/autocomplete/autocomplete.es.js +37 -42
  20. package/dist/preact/autocomplete/src/AutocompleteConfig.d.ts +25 -1
  21. package/dist/preact/autocomplete/src/components/HistoryElement.d.ts +23 -0
  22. package/dist/preact/category/category.cjs.js +1 -1
  23. package/dist/preact/category/category.es.js +2 -23
  24. package/dist/preact/common/common.cjs.js +1 -1
  25. package/dist/preact/common/common.es.js +3 -3
  26. package/dist/preact/common/src/components/BaseElement.d.ts +2 -1
  27. package/dist/preact/common/src/store/store.d.ts +1 -0
  28. package/dist/preact/common/src/store/storeContext.d.ts +1 -0
  29. package/dist/preact/common/src/store/storeExtensions.d.ts +1 -0
  30. package/dist/preact/hooks/hooks.cjs.js +1 -1
  31. package/dist/preact/hooks/hooks.es.js +26 -23
  32. package/dist/preact/inject/inject.cjs.js +1 -0
  33. package/dist/preact/inject/inject.d.ts +3 -0
  34. package/dist/preact/inject/inject.es.js +350 -0
  35. package/dist/preact/inject/src/components/ErrorBoundary.d.ts +8 -0
  36. package/dist/preact/inject/src/config.d.ts +117 -0
  37. package/dist/preact/inject/src/helpers/dom.d.ts +12 -0
  38. package/dist/preact/inject/src/init/autocomplete/AutocompleteContext.d.ts +12 -0
  39. package/dist/preact/inject/src/init/autocomplete/components/AutocompleteDropdown.d.ts +14 -0
  40. package/dist/preact/inject/src/init/autocomplete/components/AutocompleteHistory.d.ts +16 -0
  41. package/dist/preact/inject/src/init/autocomplete/components/createComponent.d.ts +13 -0
  42. package/dist/preact/inject/src/init/autocomplete/events/onClick.d.ts +2 -0
  43. package/dist/preact/inject/src/init/autocomplete/events/onFocus.d.ts +2 -0
  44. package/dist/preact/inject/src/init/autocomplete/events/onInput.d.ts +2 -0
  45. package/dist/preact/inject/src/init/autocomplete/events/onKeyDown.d.ts +5 -0
  46. package/dist/preact/inject/src/init/autocomplete/events/onSubmit.d.ts +2 -0
  47. package/dist/preact/inject/src/init/injectAutocomplete.d.ts +15 -0
  48. package/dist/preact/inject/src/init/injectCategory.d.ts +3 -0
  49. package/dist/preact/inject/src/init/injectComponent.d.ts +9 -0
  50. package/dist/preact/inject/src/init/injectSerp.d.ts +3 -0
  51. package/dist/preact/inject/src/init.d.ts +2 -0
  52. package/dist/preact/inject/src/resolveCssSelector.d.ts +8 -0
  53. package/dist/preact/inject/src/wait.d.ts +32 -0
  54. package/dist/preact/legacy/legacy.cjs.js +1 -1
  55. package/dist/preact/legacy/legacy.es.js +3 -3
  56. package/dist/preact/serp/serp.cjs.js +1 -1
  57. package/dist/preact/serp/serp.es.js +15 -34
  58. package/dist/search-DTqo1D6Y.cjs +1 -0
  59. package/dist/search-sC5QgJmw.js +170 -0
  60. package/dist/{useActions-BOhorGOy.js → useActions-Cd7V2qfb.js} +51 -42
  61. package/dist/useActions-yB4RkNMW.cjs +1 -0
  62. package/dist/{useLoadMore-DGGR76Vv.js → useLoadMore-A4IkMv_0.js} +1 -1
  63. package/dist/{useLoadMore-D0TMnfNk.cjs → useLoadMore-IsdiHtZi.cjs} +1 -1
  64. package/dist/utils/src/debounce.d.ts +1 -0
  65. package/dist/utils/utils.cjs.js +1 -1
  66. package/dist/utils/utils.es.js +18 -39
  67. package/package.json +13 -8
  68. package/dist/BaseElement-Ds4INJSy.cjs +0 -1
  69. package/dist/BaseElement-fZSwbg09.js +0 -17
  70. package/dist/search-DTLQih9k.cjs +0 -1
  71. package/dist/search-Iwwxc0Yj.js +0 -162
  72. package/dist/useActions-CDUotElR.cjs +0 -1
@@ -1,41 +1,20 @@
1
- import { d as x, a as A, m as n, u as q } from "../unique-Cv2g464w.js";
2
- import { i as L } from "../isBot-DfEzHKzJ.js";
3
- import { i as t, a as w, l as N } from "../logger-_fg_Za9y.js";
4
- import { p as j } from "../parseNumber-QA48nJLp.js";
5
- import { p as M } from "../pick-DReBictn.js";
6
- function k(s) {
7
- s.setAttribute("autocomplete", "off");
8
- }
9
- function y(s, { onClick: a, onFocus: o, onInput: c, onKeyDown: l, onSubmit: f }, { form: u = s.form ?? void 0, nativeSubmit: p } = {}) {
10
- const d = [];
11
- function r(e, i, v) {
12
- e.addEventListener(i, v), d.push(() => e.removeEventListener(i, v));
13
- }
14
- return (l || f) && r(s, "keydown", (e) => {
15
- l?.(s.value, e.key), l && (e.key === "ArrowDown" || e.key === "ArrowUp") ? e.preventDefault() : f && e.key === "Enter" && (s.value !== "" && !e.repeat && f(s.value), p || e.preventDefault());
16
- }), f && u && (r(u, "submit", (e) => {
17
- p || e.preventDefault(), f(s.value);
18
- }), u.querySelectorAll("[type=submit]").forEach((e) => {
19
- r(e, "click", (i) => {
20
- p || i.preventDefault(), f(s.value);
21
- });
22
- })), a && r(s, "click", () => a(s.value)), o && r(s, "focus", () => o(s.value)), c && r(s, "input", () => c(s.value)), {
23
- destroy() {
24
- d.forEach((e) => e());
25
- }
26
- };
27
- }
1
+ import { b as r, d as s } from "../bindInput-CCx0Fhsg.js";
2
+ import { d as p, a as t, m as i, u as m } from "../unique-Cv2g464w.js";
3
+ import { i as f } from "../isBot-DfEzHKzJ.js";
4
+ import { i as x, a as b, l as d } from "../logger-_fg_Za9y.js";
5
+ import { p as n } from "../parseNumber-QA48nJLp.js";
6
+ import { p as q } from "../pick-DReBictn.js";
28
7
  export {
29
- y as bindInput,
30
- x as deepMerge,
31
- k as disableNativeAutocomplete,
32
- L as isBot,
33
- t as isEqual,
34
- w as isPlainObject,
35
- N as logger,
36
- A as measure,
37
- n as mergeArrays,
38
- j as parseNumber,
39
- M as pick,
40
- q as unique
8
+ r as bindInput,
9
+ p as deepMerge,
10
+ s as disableNativeAutocomplete,
11
+ f as isBot,
12
+ x as isEqual,
13
+ b as isPlainObject,
14
+ d as logger,
15
+ t as measure,
16
+ i as mergeArrays,
17
+ n as parseNumber,
18
+ q as pick,
19
+ m as unique
41
20
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosto/search-js",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "files": [
@@ -37,16 +37,16 @@
37
37
  "import": "./dist/preact/autocomplete/autocomplete.es.js",
38
38
  "require": "./dist/preact/autocomplete/autocomplete.cjs.js"
39
39
  },
40
- "./preact/common": {
41
- "types": "./dist/preact/common/common.d.ts",
42
- "import": "./dist/preact/common/common.es.js",
43
- "require": "./dist/preact/common/common.cjs.js"
44
- },
45
40
  "./preact/category": {
46
41
  "types": "./dist/preact/category/category.d.ts",
47
42
  "import": "./dist/preact/category/category.es.js",
48
43
  "require": "./dist/preact/category/category.cjs.js"
49
44
  },
45
+ "./preact/common": {
46
+ "types": "./dist/preact/common/common.d.ts",
47
+ "import": "./dist/preact/common/common.es.js",
48
+ "require": "./dist/preact/common/common.cjs.js"
49
+ },
50
50
  "./preact/events": {
51
51
  "types": "./dist/preact/events/events.d.ts",
52
52
  "import": "./dist/preact/events/events.es.js",
@@ -57,6 +57,11 @@
57
57
  "import": "./dist/preact/hooks/hooks.es.js",
58
58
  "require": "./dist/preact/hooks/hooks.cjs.js"
59
59
  },
60
+ "./preact/inject": {
61
+ "types": "./dist/preact/inject/inject.d.ts",
62
+ "import": "./dist/preact/inject/inject.es.js",
63
+ "require": "./dist/preact/inject/inject.cjs.js"
64
+ },
60
65
  "./preact/legacy": {
61
66
  "types": "./dist/preact/legacy/legacy.d.ts",
62
67
  "import": "./dist/preact/legacy/legacy.es.js",
@@ -92,7 +97,7 @@
92
97
  "devDependencies": {
93
98
  "@commitlint/cli": "^19.8.1",
94
99
  "@commitlint/config-conventional": "^19.8.1",
95
- "@nosto/nosto-js": "^2.5.0",
100
+ "@nosto/nosto-js": "^2.6.0",
96
101
  "@testing-library/dom": "^10.4.1",
97
102
  "@types/dom-speech-recognition": "^0.0.6",
98
103
  "@types/eslint-config-prettier": "^6.11.3",
@@ -115,7 +120,7 @@
115
120
  "typedoc": "^0.28.10",
116
121
  "typescript": "^5.9.2",
117
122
  "typescript-eslint": "^8.39.1",
118
- "vite": "^7.1.1",
123
+ "vite": "^7.1.2",
119
124
  "vite-plugin-dts": "^4.5.4",
120
125
  "vitest": "^3.1.3"
121
126
  },
@@ -1 +0,0 @@
1
- "use strict";const n=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("preact/hooks");function c({onClick:s,as:u,children:i,componentProps:e}){const t={...e,onClick:r.useCallback(l=>{s(),e?.onClick?.(l)},[s,e])},a=u??(e&&"href"in e?"a":"span");return n.u(a,{...t,children:i})}exports.BaseElement=c;
@@ -1,17 +0,0 @@
1
- import { u as e } from "./jsxRuntime.module-Bzuv3cXw.js";
2
- import { useCallback as s } from "preact/hooks";
3
- function m({ onClick: i, as: r, children: f, componentProps: a }) {
4
- const l = {
5
- ...a,
6
- onClick: s(
7
- (u) => {
8
- i(), a?.onClick?.(u);
9
- },
10
- [i, a]
11
- )
12
- }, t = r ?? (a && "href" in a ? "a" : "span");
13
- return /* @__PURE__ */ e(t, { ...l, children: f });
14
- }
15
- export {
16
- m as B
17
- };
@@ -1 +0,0 @@
1
- "use strict";const S=require("./index.es-Dp6Iaxz3.cjs"),i=require("./logger-Boh_C6Bz.cjs");async function w(t,{hitDecorators:e,...r},c){const n=await c(t,r);if(!n.products?.hits?.length||!e?.length)return n;const s=o=>e.reduce((u,a)=>a(u),o);return{...n,products:{...n.products,hits:n.products.hits.map(s)}}}function m(t,e,r){const c=JSON.stringify(e);try{r.setItem(t,c)}catch(n){i.logger.warn(n)}}function y(t,e){try{const r=e.getItem(t);if(r)return JSON.parse(r)}catch(r){i.logger.warn(r)}}function C(t,e){m(t,e,sessionStorage)}function R(t){return y(t,sessionStorage)}const h="nosto:search-js:cache",b=60*1e3;function N(t,e){C(h,{query:t,result:e,created:Date.now()})}function T(t){const e=R(h);if(!e||!z(e))return null;const r=d(e.query);return!i.isEqual(d(t),r)||Date.now()-e.created>b?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 O(t,r,c);return N(t,n),n}async function O(t,e,r){const{from:c=0,size:n=0}=t.products||{},s=T(t);if(!s)return await r(t,e);const o=s?.products?.size??0,u=s?.products?.hits??[];if(n===o)return s;if(n<o)return{...s,products:{...s.products,size:n,hits:u.slice(0,n),total:s.products?.total||0}};const a=n-u.length,p=c>0?c+1:n-a,g={...t,products:{...t.products,from:p,size:a}},l=await r(g,e);return{...s,products:{...s.products,size:n,hits:[...s.products?.hits||[],...l.products?.hits||[]],total:l.products?.total||0}}}const J=3e4,f=new Map;function k(t,e){const r=f.get(t);if(!r)return;const c=Date.now()-r.created>J,n=i.isEqual(e,r.query);if(c||!n){f.delete(t);return}return r.result}function D(t,e,r){f.set(t,{query:e,result:r,created:Date.now()})}async function I(t,e,r){if(!e.useMemoryCache)return r(t,e);const c=JSON.stringify(t),n=k(c,t);if(n)return n;const s=await r(t,e);return D(c,t,s),s}function M(t){return new Promise(e=>setTimeout(e,t))}async function V(t,{maxRetries:e=0,retryInterval:r=0,...c},n){let s=0;for(;;)try{return await n(t,c)}catch(o){if(s>=e)throw o;if(!W(o))throw i.logger.info("Skipping retry logic for",o),o;s++,await M(r)}}function W(t){return!t||typeof t!="object"?!1:!("status"in t)||j(t.status)}function j(t){return typeof t=="number"&&(t<400||t>=500)}async function _(t,e={}){const r=await new Promise(S.s);return x(r.search,V,I,E,w)(t,e)}function x(t,...e){return e.reduce((r,c)=>(n,s)=>c(n,s,r),t)}exports.search=_;
@@ -1,162 +0,0 @@
1
- import { s as S } from "./index.es-XNBESE3P.js";
2
- import { l as f, i as h } from "./logger-_fg_Za9y.js";
3
- async function w(t, { hitDecorators: e, ...r }, c) {
4
- const n = await c(t, r);
5
- if (!n.products?.hits?.length || !e?.length)
6
- return n;
7
- const s = (o) => e.reduce((i, a) => a(i), o);
8
- return {
9
- ...n,
10
- products: {
11
- ...n.products,
12
- hits: n.products.hits.map(s)
13
- }
14
- };
15
- }
16
- function y(t, e, r) {
17
- const c = JSON.stringify(e);
18
- try {
19
- r.setItem(t, c);
20
- } catch (n) {
21
- f.warn(n);
22
- }
23
- }
24
- function C(t, e) {
25
- try {
26
- const r = e.getItem(t);
27
- if (r)
28
- return JSON.parse(r);
29
- } catch (r) {
30
- f.warn(r);
31
- }
32
- }
33
- function R(t, e) {
34
- y(t, e, sessionStorage);
35
- }
36
- function b(t) {
37
- return C(t, sessionStorage);
38
- }
39
- const p = "nosto:search-js:cache", N = 60 * 1e3;
40
- function T(t, e) {
41
- R(p, { query: t, result: e, created: Date.now() });
42
- }
43
- function z(t) {
44
- const e = b(p);
45
- if (!e || !O(e))
46
- return null;
47
- const r = d(e.query);
48
- return !h(d(t), r) || Date.now() - e.created > N ? null : e.result;
49
- }
50
- function d(t) {
51
- const e = {
52
- ...t,
53
- time: void 0,
54
- products: {
55
- ...t.products,
56
- size: void 0
57
- }
58
- };
59
- return JSON.parse(JSON.stringify(e));
60
- }
61
- function O(t) {
62
- return typeof t == "object" && t !== null && "query" in t && "result" in t && "created" in t;
63
- }
64
- async function E(t, { usePersistentCache: e, ...r }, c) {
65
- if (!e)
66
- return c(t, r);
67
- const n = await J(t, r, c);
68
- return T(t, n), n;
69
- }
70
- async function J(t, e, r) {
71
- const { from: c = 0, size: n = 0 } = t.products || {}, s = z(t);
72
- if (!s)
73
- return await r(t, e);
74
- const o = s?.products?.size ?? 0, i = s?.products?.hits ?? [];
75
- if (n === o)
76
- return s;
77
- if (n < o)
78
- return {
79
- ...s,
80
- products: {
81
- ...s.products,
82
- size: n,
83
- hits: i.slice(0, n),
84
- total: s.products?.total || 0
85
- }
86
- };
87
- const a = n - i.length, g = c > 0 ? c + 1 : n - a, m = {
88
- ...t,
89
- products: {
90
- ...t.products,
91
- from: g,
92
- size: a
93
- }
94
- }, l = await r(m, e);
95
- return {
96
- ...s,
97
- products: {
98
- ...s.products,
99
- size: n,
100
- hits: [...s.products?.hits || [], ...l.products?.hits || []],
101
- total: l.products?.total || 0
102
- }
103
- };
104
- }
105
- const k = 3e4, u = /* @__PURE__ */ new Map();
106
- function D(t, e) {
107
- const r = u.get(t);
108
- if (!r) return;
109
- const c = Date.now() - r.created > k, n = h(e, r.query);
110
- if (c || !n) {
111
- u.delete(t);
112
- return;
113
- }
114
- return r.result;
115
- }
116
- function I(t, e, r) {
117
- u.set(t, {
118
- query: e,
119
- result: r,
120
- created: Date.now()
121
- });
122
- }
123
- async function M(t, e, r) {
124
- if (!e.useMemoryCache)
125
- return r(t, e);
126
- const c = JSON.stringify(t), n = D(c, t);
127
- if (n) return n;
128
- const s = await r(t, e);
129
- return I(c, t, s), s;
130
- }
131
- function V(t) {
132
- return new Promise((e) => setTimeout(e, t));
133
- }
134
- async function W(t, { maxRetries: e = 0, retryInterval: r = 0, ...c }, n) {
135
- let s = 0;
136
- for (; ; )
137
- try {
138
- return await n(t, c);
139
- } catch (o) {
140
- if (s >= e)
141
- throw o;
142
- if (!j(o))
143
- throw f.info("Skipping retry logic for", o), o;
144
- s++, await V(r);
145
- }
146
- }
147
- function j(t) {
148
- return !t || typeof t != "object" ? !1 : !("status" in t) || x(t.status);
149
- }
150
- function x(t) {
151
- return typeof t == "number" && (t < 400 || t >= 500);
152
- }
153
- async function P(t, e = {}) {
154
- const r = await new Promise(S);
155
- return A(r.search, W, M, E, w)(t, e);
156
- }
157
- function A(t, ...e) {
158
- return e.reduce((r, c) => (n, s) => c(n, s, r), t);
159
- }
160
- export {
161
- P as s
162
- };
@@ -1 +0,0 @@
1
- "use strict";const k=require("preact"),g=require("preact/hooks"),c=require("./unique-BXXNictB.cjs"),y=require("./logger-Boh_C6Bz.cjs"),T=require("./search-DTLQih9k.cjs"),m=k.createContext(null),w=()=>{const e=g.useContext(m);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e};function b(e,r={}){const t=new Map;let n=c.deepMergePlain(e,r??{});const o=c.deepMergePlain(e,r);function u(d){n=d(n);for(const f of t.values())f(n)}function i(d){u(f=>({...f,...d}))}function s(){return n}function a(){return structuredClone(o)}function l(d,f){let S;t.set(f,M=>{const h=d(M);y.isEqual(h,S)||(S=h,f(h))})}function q(d){t.delete(d)}return{updateState:i,getState:s,getInitialState:a,onChange:l,clearOnChange:q}}const v={loading:!0,query:{},response:{},initialized:!1};function F(e={}){return b(v,e)}const P=k.createContext(F());function I(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:E,...r.products},...r.keywords?{keywords:{...r.keywords,fields:c.unique([...U,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const E=["productId","url","name","imageUrl","imageHash","thumbUrl","description","brand","variantId","availability","price","priceText","categoryIds","categories","customFields.key","customFields.value","priceCurrencyCode","datePublished","listPrice","unitPricingBaseMeasure","unitPricingUnit","unitPricingMeasure","googleCategory","gtin","ageGroup","gender","condition","alternateImageUrls","ratingValue","reviewCount","inventoryLevel","skus.id","skus.name","skus.price","skus.listPrice","skus.priceText","skus.url","skus.imageUrl","skus.inventoryLevel","skus.customFields.key","skus.customFields.value","skus.availability","pid","onDiscount","extra.key","extra.value","saleable","available","tags1","tags2","tags3"],U=["keyword","_redirect"];async function C(e,r,t){const n=c.measure("newSearch"),o=e.config.pageType,u=o==="search"?"serp":o,i=c.deepMerge(e.store.getInitialState().query,r),s=c.deepMerge(e.config.search,t,{track:u,redirect:o!=="autocomplete",isKeyword:!!t?.isKeyword,usePersistentCache:e.config.pageType!=="autocomplete"&&e.config.persistentSearchCache,useMemoryCache:e.config.pageType==="autocomplete"&&e.config.memoryCache});e.config.onBeforeSearch?.(e,s),e.store.updateState({query:i,loading:!0,initialized:!0});const a=e.config.queryModifications({...i,products:{...i.products,filter:c.mergeArrays(e.store.getInitialState().query?.products?.filter,r.products?.filter)}},o);try{const l=await T.search(I(e.config.pageType,a),s);e.store.updateState({response:l,loading:!1})}catch(l){y.logger.error("Search action failed",l),e.config.onSearchError?.(l,a,s,o)}n()}async function p(e,r,t){const n=c.measure("updateSearch"),o=c.deepMerge(e.store.getState().query,{products:{from:0}},r);await C(e,o,t),n()}async function A(e,r,t){const n=c.measure("replaceFilter"),o=e.store.getState().query.products?.filter,u=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await p(e,{products:{filter:[...o?.filter(i=>i.field!==r)??[],...u]}}),n()}async function Q(e,r,t,n){const o=c.measure("toggleProductFilter"),u=e.store.getState().query.products?.filter,i=u?.find(a=>a.value instanceof Array&&a.field===r),s=i?.value?{...i,value:[...i.value.filter(a=>!y.isEqual(a,t)),...n?[t]:[]]}:n?{field:r,value:[t]}:void 0;await p(e,{products:{filter:[...u?.filter(a=>a!==i)??[],...s?.value?.length?[s]:[]]}}),o()}function K(){const e=w(),r=g.useContext(P),t=g.useMemo(()=>({config:e,store:r}),[e,r]),n=g.useCallback((s,a)=>C(t,s,a),[t]),o=g.useCallback((s,a)=>p(t,s,a),[t]),u=g.useCallback((s,a,l)=>Q(t,s,a,l),[t]),i=g.useCallback((s,a)=>A(t,s,a),[t]);return{newSearch:n,updateSearch:o,toggleProductFilter:u,replaceFilter:i}}exports.ConfigContext=m;exports.StoreContext=P;exports.createExtendableStore=b;exports.createStore=F;exports.defaultState=v;exports.newSearch=C;exports.updateSearch=p;exports.useActions=K;exports.useConfig=w;