Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@algolia/recommend-react

Package Overview
Dependencies
Maintainers
83
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/recommend-react - npm Package Compare versions

Comparing version 1.12.0 to 1.12.1

5

dist/esm/useTrendingFacets.js

@@ -62,3 +62,6 @@ import { getTrendingFacets } from '@algolia/recommend-core';

onResult(response) {
setResult(response);
setResult({
...response,
recommendations: response.trendingFacets
});
setStatus('idle');

@@ -65,0 +68,0 @@ }

2

dist/esm/version.d.ts

@@ -1,1 +0,1 @@

export declare const version = "1.12.0";
export declare const version = "1.12.1";

@@ -1,1 +0,1 @@

export const version = '1.12.0';
export const version = '1.12.1';

@@ -1,3 +0,3 @@

/*! @algolia/recommend-react 1.12.0 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/recommend */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/recommend-react"]={},e.React)}(this,(function(e,t){"use strict";function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},n.apply(this,arguments)}function r(...e){return e.filter(Boolean).join(" ")}function a({createElement:e,Fragment:t}){return function(n){return 0===n.recommendations.length&&"idle"===n.status?e(n.Fallback,null):e("section",{className:r("auc-Recommend",n.classNames.root)},e(n.Header,{classNames:n.classNames,recommendations:n.recommendations,translations:n.translations,createElement:e,Fragment:t}),e(n.View,null))}}function s({createElement:e}){return function(t){return!t.recommendations||t.recommendations.length<1?null:t.translations.title?e("h3",{className:r("auc-Recommend-title",t.classNames.title)},t.translations.title):null}}function m({createElement:e,Fragment:t}){return function(n){return e("div",{className:r("auc-Recommend-container",n.classNames.container)},e("ol",{className:r("auc-Recommend-list",n.classNames.list)},n.items.map((a=>e("li",{key:a.objectID,className:r("auc-Recommend-item",n.classNames.item)},e(n.itemComponent,{createElement:e,Fragment:t,item:a}))))))}}function o({hits:e,maxRecommendations:t,nrOfObjs:n}){const r={};e.forEach((e=>{e.forEach(((e,t)=>{r[e.objectID]?r[e.objectID]={indexSum:r[e.objectID].indexSum+t,nr:r[e.objectID].nr+1}:r[e.objectID]={indexSum:t,nr:1}}))}));const a=((e,t)=>{const n=[];for(const r of Object.keys(e))e[r].nr<2&&(e[r].indexSum+=100),n.push({objectID:r,avgOfIndices:e[r].indexSum/t});return n.sort(((e,t)=>e.avgOfIndices>t.avgOfIndices?1:-1))})(r,n);return a.reduce(((t,n)=>{const r=e.flat().find((e=>e.objectID===n.objectID));return r?t.concat(r):t}),[]).slice(0,t&&t>0?t:void 0)}function i({hits:e,maxRecommendations:t}){return function(e,t){const n=[...t];return n.sort(e),n}(((e,t)=>(e._score||0)>(t._score||0)?-1:1),e).slice(0,t&&t>0?t:void 0)}const c="1.12.0";const l=t.createContext({hasProvider:!1}),u=()=>t.useContext(l),d=e=>{const n=t.useContext(l);if(e)return{client:e,isContextClient:!1};if(n.recommendClient)return{client:n.recommendClient,isContextClient:!0};throw new Error("Pass an Algolia `recommendClient` instance either to the Recommend React context, a component or hook.")};function f(e){t.useEffect((()=>{e.recommendClient.addAlgoliaAgent("recommend-react","1.12.0")}),[e.recommendClient])}var g=Object.prototype.hasOwnProperty;function h(e,t){var n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&h(e[r],t[r]););return-1===r}if(!n||"object"==typeof e){for(n in r=0,e){if(g.call(e,n)&&++r&&!g.call(t,n))return!1;if(!(n in t)||!h(e[n],t[n]))return!1}return Object.keys(t).length===r}}return e!=e&&t!=t}function y(e){const[n,r]=t.useState((()=>e));return t.useEffect((()=>{!1===h(n,e)&&r(e)}),[e]),n}function b(e){const n=t.useRef(void 0),[r,a]=t.useState(e);return t.useEffect((()=>{"stalled"!==r&&n.current&&clearTimeout(n.current),"loading"===r&&(n.current=setTimeout((()=>{a("stalled")}),300))}),[r]),{status:r,setStatus:a}}function x({indexName:e,maxRecommendations:n,objectIDs:r,queryParameters:a,recommendClient:s,threshold:m,transformItems:i=(e=>e)}){const[l,g]=t.useState({recommendations:[]}),{status:h,setStatus:x}=b("loading"),R=y(r),p=y(a),{hasProvider:E,register:N}=u(),{client:C,isContextClient:k}=d(s);f({recommendClient:C});const P=t.useRef(i);return t.useEffect((()=>{P.current=i}),[i]),t.useEffect((()=>{const t={indexName:e,maxRecommendations:n,objectIDs:R,queryParameters:p,threshold:m,transformItems:P.current};if(E&&k){const r=JSON.stringify(t),a=R.map((t=>({indexName:e,model:"bought-together",threshold:m,maxRecommendations:n,objectID:t,queryParameters:p})));return N({key:r,getParameters:()=>({queries:a,keyPair:{key:r,value:R.length}}),onRequest(){x("loading")},onResult(e){g(e),x("idle")}})}return x("loading"),function({objectIDs:e,recommendClient:t,transformItems:n=(e=>e),indexName:r,maxRecommendations:a,queryParameters:s,threshold:m}){const i=e.map((e=>({indexName:r,maxRecommendations:a,objectID:e,queryParameters:s,threshold:m})));return t.addAlgoliaAgent("recommend-core",c),t.getFrequentlyBoughtTogether(i).then((t=>o({maxRecommendations:a,hits:t.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:n(e)})))}({...t,recommendClient:C}).then((e=>{g(e),x("idle")})),()=>{}}),[e,n,R,p,C,x,m,E,k,N]),{...l,status:h}}const R=function({createElement:e,Fragment:t}){return function(r){const o={title:"Frequently bought together",sliderLabel:"Frequently bought together products",...r.translations},i=r.classNames??{},c=r.children??a({createElement:e,Fragment:t}),l=r.fallbackComponent??function(){return null},u=r.headerComponent??s({createElement:e,Fragment:t}),d=r.view??m({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:r.items,status:r.status,translations:o,View:a=>e(d,n({classNames:i,itemComponent:r.itemComponent,items:r.items,translations:o,Fragment:t,createElement:e},a))})}}({createElement:t.createElement,Fragment:t.Fragment});function p({fallbackParameters:e,indexName:n,maxRecommendations:r,objectIDs:a,queryParameters:s,recommendClient:m,threshold:i,transformItems:l=(e=>e)}){const[g,h]=t.useState({recommendations:[]}),{status:x,setStatus:R}=b("loading"),p=y(a),E=y(s),N=y(e),{hasProvider:C,register:k}=u(),{client:P,isContextClient:F}=d(m);f({recommendClient:P});const I=t.useRef(l);return t.useEffect((()=>{I.current=l}),[l]),t.useEffect((()=>{const e={fallbackParameters:N,indexName:n,maxRecommendations:r,objectIDs:p,queryParameters:E,threshold:i,transformItems:I.current};if(C&&F){const t=JSON.stringify(e),a=p.map((e=>({indexName:n,model:"related-products",threshold:i,maxRecommendations:r,objectID:e,queryParameters:E,fallbackParameters:N})));return k({key:t,getParameters:()=>({queries:a,keyPair:{key:t,value:p.length}}),onRequest(){R("loading")},onResult(e){h(e),R("idle")}})}return R("loading"),function({objectIDs:e,recommendClient:t,transformItems:n=(e=>e),fallbackParameters:r,indexName:a,maxRecommendations:s,queryParameters:m,threshold:i}){const l=e.map((e=>({fallbackParameters:r,indexName:a,maxRecommendations:s,objectID:e,queryParameters:m,threshold:i})));return t.addAlgoliaAgent("recommend-core",c),t.getRelatedProducts(l).then((t=>o({maxRecommendations:s,hits:t.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:n(e)})))}({...e,recommendClient:P}).then((e=>{h(e),R("idle")})),()=>{}}),[P,N,C,n,F,r,p,E,k,R,i]),{...g,status:x}}const E=function({createElement:e,Fragment:t}){return function(r){const o={title:"Related products",sliderLabel:"Related products",...r.translations},i=r.classNames??{},c=r.children??a({createElement:e,Fragment:t}),l=r.fallbackComponent??function(){return null},u=r.headerComponent??s({createElement:e,Fragment:t}),d=r.view??m({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:r.items,status:r.status,translations:o,View:a=>e(d,n({classNames:i,itemComponent:r.itemComponent,items:r.items,translations:o,Fragment:t,createElement:e},a))})}}({createElement:t.createElement,Fragment:t.Fragment});function N({fallbackParameters:e,indexName:n,maxRecommendations:r,queryParameters:a,recommendClient:s,threshold:m,transformItems:o=(e=>e)}){const[i,l]=t.useState({recommendations:[]}),{status:g,setStatus:h}=b("loading"),x=y(a),R=y(e),{hasProvider:p,register:E}=u(),{client:N,isContextClient:C}=d(s);f({recommendClient:N});const k=t.useRef(o);return t.useEffect((()=>{k.current=o}),[o]),t.useEffect((()=>{const e={fallbackParameters:R,indexName:n,maxRecommendations:r,queryParameters:x,threshold:m,transformItems:k.current};if(p&&C){const t=JSON.stringify(e),a=[{indexName:n,threshold:m,maxRecommendations:r,queryParameters:x,fallbackParameters:R,model:"recommended-for-you"}];return E({key:t,getParameters:()=>({queries:a,keyPair:{key:t,value:1}}),onRequest(){h("loading")},onResult(e){l(e),h("idle")}})}return h("loading"),function({indexName:e,threshold:t,queryParameters:n,recommendClient:r,maxRecommendations:a,transformItems:s=(e=>e)}){r.addAlgoliaAgent("recommend-core",c);const m=[{indexName:e,threshold:t,queryParameters:n,maxRecommendations:a}];return r.getRecommendedForYou(m).then((e=>({recommendations:s(e.results.map((e=>e.hits)).flat())})))}({...e,recommendClient:N}).then((e=>{l(e),h("idle")})),()=>{}}),[N,R,p,n,C,r,x,E,h,m]),{...i,status:g}}const C=function({createElement:e,Fragment:t}){return function(r){const o={title:"Recommended For You",sliderLabel:"Recommended For You",...r.translations},i=r.classNames??{},c=r.children??a({createElement:e,Fragment:t}),l=r.fallbackComponent??function(){return null},u=r.headerComponent??s({createElement:e,Fragment:t}),d=r.view??m({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:r.items,status:r.status,translations:o,View:a=>e(d,n({classNames:i,itemComponent:r.itemComponent,items:r.items,translations:o,Fragment:t,createElement:e},a))})}}({createElement:t.createElement,Fragment:t.Fragment});function k({fallbackParameters:e,indexName:n,maxRecommendations:r,objectIDs:a,queryParameters:s,recommendClient:m,threshold:i,transformItems:l=(e=>e)}){const[g,h]=t.useState({recommendations:[]}),{status:x,setStatus:R}=b("loading"),p=y(a),E=y(s),N=y(e),{hasProvider:C,register:k}=u(),{client:P,isContextClient:F}=d(m);f({recommendClient:P});const I=t.useRef(l);return t.useEffect((()=>{I.current=l}),[l]),t.useEffect((()=>{const e={fallbackParameters:N,indexName:n,maxRecommendations:r,objectIDs:p,queryParameters:E,threshold:i,transformItems:I.current};if(C&&F){const t=JSON.stringify(e),a=p.map((e=>({indexName:n,model:"looking-similar",threshold:i,maxRecommendations:r,objectID:e,queryParameters:E,fallbackParameters:N})));return k({key:t,getParameters:()=>({queries:a,keyPair:{key:t,value:p.length}}),onRequest(){R("loading")},onResult(e){h(e),R("idle")}})}return R("loading"),function({objectIDs:e,recommendClient:t,transformItems:n=(e=>e),fallbackParameters:r,indexName:a,maxRecommendations:s,queryParameters:m,threshold:i}){const l=e.map((e=>({fallbackParameters:r,indexName:a,maxRecommendations:s,objectID:e,queryParameters:m,threshold:i})));return t.addAlgoliaAgent("recommend-core",c),t.getLookingSimilar(l).then((t=>o({maxRecommendations:s,hits:t.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:n(e)})))}({...e,recommendClient:P}).then((e=>{h(e),R("idle")})),()=>{}}),[P,N,C,n,F,r,p,E,k,R,i]),{...g,status:x}}const P=function({createElement:e,Fragment:t}){return function(r){const o={title:"Looking Similar",sliderLabel:"Looking Similar",...r.translations},i=r.classNames??{},c=r.children??a({createElement:e,Fragment:t}),l=r.fallbackComponent??function(){return null},u=r.headerComponent??s({createElement:e,Fragment:t}),d=r.view??m({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:r.items,status:r.status,translations:o,View:a=>e(d,n({classNames:i,itemComponent:r.itemComponent,items:r.items,translations:o,Fragment:t,createElement:e},a))})}}({createElement:t.createElement,Fragment:t.Fragment});function F({indexName:e,maxRecommendations:n,recommendClient:r,threshold:a,transformItems:s=(e=>e),facetName:m}){const[o,l]=t.useState({recommendations:[]}),{status:g,setStatus:h}=b("loading"),{hasProvider:y,register:x}=u(),{client:R,isContextClient:p}=d(r);f({recommendClient:R});const E=t.useRef(s);return t.useEffect((()=>{E.current=s}),[s]),t.useEffect((()=>{const t={model:"trending-facets",indexName:e,facetName:m,threshold:a,maxRecommendations:n,transformItems:E.current};if(y&&p){const e=JSON.stringify(t);return x({key:e,getParameters:()=>({queries:[t],keyPair:{key:e,value:1}}),onRequest(){h("loading")},onResult(e){l(e),h("idle")}})}return h("loading"),function({recommendClient:e,transformItems:t=(e=>e),indexName:n,maxRecommendations:r,threshold:a,facetName:s}){const m={indexName:n,maxRecommendations:r,threshold:a,facetName:s};return e.addAlgoliaAgent("recommend-core",c),e.getTrendingFacets([m]).then((e=>i({maxRecommendations:r,hits:e.results.map((e=>e.hits)).flat()}))).then((e=>({recommendations:t(e)})))}({...t,recommendClient:R,facetName:m,transformItems:E.current}).then((e=>{l(e),h("idle")})),()=>{}}),[e,n,R,h,a,m,y,p,x]),{...o,status:g}}const I=function({createElement:e,Fragment:t}){return function(m){const o={title:"Trending facets",sliderLabel:"Trending facets",...m.translations},i=m.classNames??{},c=m.children??a({createElement:e,Fragment:t}),l=m.fallbackComponent??function(){return null},u=m.headerComponent??s({createElement:e,Fragment:t}),d=m.view??function({createElement:e,Fragment:t}){return function(n){return e("div",{className:r("auc-Recommend-container",n.classNames.container)},e("ol",{className:r("auc-Recommend-list",n.classNames.list)},n.items.map((a=>e("li",{key:a.facetValue,className:r("auc-Recommend-item",n.classNames.item)},e(n.itemComponent,{createElement:e,Fragment:t,item:a}))))))}}({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:m.items,status:m.status,translations:o,View:r=>e(d,n({classNames:i,itemComponent:m.itemComponent,items:m.items,translations:o,Fragment:t,createElement:e},r))})}}({createElement:t.createElement,Fragment:t.Fragment});function q({fallbackParameters:e,indexName:n,maxRecommendations:r,queryParameters:a,recommendClient:s,threshold:m,transformItems:o=(e=>e),facetName:l,facetValue:g}){const[h,x]=t.useState({recommendations:[]}),{status:R,setStatus:p}=b("loading"),E=y(a),N=y(e),{hasProvider:C,register:k}=u(),{client:P,isContextClient:F}=d(s);f({recommendClient:P});const I=t.useRef(o);return t.useEffect((()=>{I.current=o}),[o]),t.useEffect((()=>{const e={model:"trending-items",fallbackParameters:N,indexName:n,maxRecommendations:r,queryParameters:E,threshold:m,facetName:l,facetValue:g,transformItems:I.current};if(C&&F){const t=JSON.stringify(e);return k({key:t,getParameters:()=>({queries:[e],keyPair:{key:t,value:1}}),onRequest(){p("loading")},onResult(e){x(e),p("idle")}})}return p("loading"),function({recommendClient:e,transformItems:t=(e=>e),fallbackParameters:n,indexName:r,maxRecommendations:a,queryParameters:s,threshold:m,facetName:o,facetValue:l}){const u={fallbackParameters:n,indexName:r,maxRecommendations:a,queryParameters:s,threshold:m,facetName:o,facetValue:l};return e.addAlgoliaAgent("recommend-core",c),e.getTrendingItems([u]).then((e=>{return i({maxRecommendations:a,hits:(t="objectID",n=e.results.map((e=>e.hits)).flat(),[...new Map(n.map((e=>[e[t],e]))).values()])});var t,n})).then((e=>({recommendations:t(e)})))}({...e,recommendClient:P,transformItems:I.current}).then((e=>{x(e),p("idle")})),()=>{}}),[N,n,r,E,P,p,m,l,g,C,F,k]),{...h,status:R}}const j=function({createElement:e,Fragment:t}){return function(r){const o={title:"Trending items",sliderLabel:"Trending items",...r.translations},i=r.classNames??{},c=r.children??a({createElement:e,Fragment:t}),l=r.fallbackComponent??function(){return null},u=r.headerComponent??s({createElement:e,Fragment:t}),d=r.view??m({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:r.items,status:r.status,translations:o,View:a=>e(d,n({classNames:i,itemComponent:r.itemComponent,items:r.items,translations:o,Fragment:t,createElement:e},a))})}}({createElement:t.createElement,Fragment:t.Fragment});var v=Object.prototype.hasOwnProperty;function S(e,t,n){for(n of e.keys())if(w(n,t))return n}function w(e,t){var n,r,a;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&w(e[r],t[r]););return-1===r}if(n===Set){if(e.size!==t.size)return!1;for(r of e){if((a=r)&&"object"==typeof a&&!(a=S(t,a)))return!1;if(!t.has(a))return!1}return!0}if(n===Map){if(e.size!==t.size)return!1;for(r of e){if((a=r[0])&&"object"==typeof a&&!(a=S(t,a)))return!1;if(!w(r[1],t.get(a)))return!1}return!0}if(n===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(n===DataView){if((r=e.byteLength)===t.byteLength)for(;r--&&e.getInt8(r)===t.getInt8(r););return-1===r}if(ArrayBuffer.isView(e)){if((r=e.byteLength)===t.byteLength)for(;r--&&e[r]===t[r];);return-1===r}if(!n||"object"==typeof e){for(n in r=0,e){if(v.call(e,n)&&++r&&!v.call(t,n))return!1;if(!(n in t)||!w(e[n],t[n]))return!1}return Object.keys(t).length===r}}return e!=e&&t!=t}function D(e){return null!=e}function O(e){return JSON.stringify(e)}function A(e,t){return e.map((e=>{if(function(e,t){return Boolean(e[O(t)])}(t,e.param.queries)){const n=t[O(e.param.queries)];return e.onResult(n),null}return e.param})).filter(D)}const T=(e,t)=>{const{type:n}=t;switch(n){case"register":{const{widget:n}=t,r=n.getParameters(),a=function(e,t){return Boolean(e.find((e=>w(e.param,t))))}(e.widgets,r);return a?e:{...e,widgets:[...e.widgets,{...n,param:r}],isDirty:Date.now()}}case"unregister":{const{key:n}=t;return{...e,widgets:e.widgets.filter((e=>e.key!==n))}}case"request_success":return{...e,status:"idle",isDirty:null};default:return e}};e.FrequentlyBoughtTogether=function(e){const{recommendations:r,status:a}=x(e);return t.createElement(R,n({},e,{items:r,status:a}))},e.LookingSimilar=function(e){const{recommendations:r,status:a}=k(e);return t.createElement(P,n({},e,{items:r,status:a}))},e.Recommend=function({recommendClient:e,children:n}){const[r,a]=t.useReducer(T,{isDirty:null,cache:{},widgets:[],recommendClient:e});t.useEffect((()=>{if(!r.isDirty)return;const t=A(r.widgets,r.cache);if(0===t.length)return;const{queries:n,keys:s}=function(e){return{queries:e.map((e=>e.queries)).reduce(((e,t)=>e.concat(t)),[]),keys:e.map((e=>e.keyPair))}}(t);s.forEach((e=>{r.widgets.forEach((t=>{t.key===e.key&&t.onRequest()}))})),async function({keys:e,queries:t,recommendClient:n}){n.addAlgoliaAgent("recommend-core",c);const r=await n.getRecommendations(t);let a=0,s=0;const m={};return e.forEach((e=>{const{model:n}=JSON.parse(e.key);s+=e.value;const{maxRecommendations:c,transformItems:l=(e=>e)}=t[a],u=r?.results?.slice(a,s);a+=e.value;let d=[],f=[];"trending-facets"===n?f=u.map((e=>e.hits)).flat():d="trending-items"===n?i({maxRecommendations:c,hits:u.map((e=>e.hits)).flat()}):o({maxRecommendations:c,hits:u.map((e=>e.hits)),nrOfObjs:e.value}),d=l(d),m[e.key]={recommendations:d,trendingFacets:f}})),m}({recommendClient:e,queries:n,keys:s}).then((e=>{Object.entries(e).forEach((([e,t])=>{r.widgets.forEach((n=>{n.key===e&&(n.onResult(t),r.cache[O(n.param.queries)]=t)}))})),a({type:"request_success"})}))}),[r.isDirty,a,r.widgets,r.cache,e]);const s=t.useCallback((e=>(a({type:"register",widget:e}),()=>{a({type:"unregister",key:e.key})})),[]),m=t.useMemo((()=>({register:s,recommendClient:e,hasProvider:!0})),[e,s]);return t.createElement(l.Provider,{value:m},n)},e.RecommendedForYou=function(e){const{recommendations:r,status:a}=N(e);return t.createElement(C,n({},e,{items:r,status:a}))},e.RelatedProducts=function(e){const{recommendations:r,status:a}=p(e);return t.createElement(E,n({},e,{items:r,status:a}))},e.TrendingFacets=function(e){const{recommendations:r,status:a}=F(e);return t.createElement(I,n({},e,{items:r,status:a}))},e.TrendingItems=function(e){const{recommendations:r,status:a}=q(e);return t.createElement(j,n({},e,{items:r,status:a}))},e.useFrequentlyBoughtTogether=x,e.useLookingSimilar=k,e.useRecommendations=function({fallbackParameters:e,indexName:n,maxRecommendations:r,model:a,objectIDs:s,queryParameters:m,recommendClient:i,threshold:l,transformItems:u=(e=>e)}){const[d,g]=t.useState({recommendations:[]}),{status:h,setStatus:x}=b("loading"),R=y(s),p=y(m),E=y(e);f({recommendClient:i});const N=t.useRef(u);return t.useEffect((()=>{N.current=u}),[u]),t.useEffect((()=>{x("loading"),function({objectIDs:e,recommendClient:t,transformItems:n=(e=>e),fallbackParameters:r,indexName:a,maxRecommendations:s,model:m,queryParameters:i,threshold:l}){const u=e.map((e=>({fallbackParameters:r,indexName:a,maxRecommendations:s,model:m,objectID:e,queryParameters:i,threshold:l})));return t.addAlgoliaAgent("recommend-core",c),t.getRecommendations(u).then((t=>o({maxRecommendations:s,hits:t.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:n(e)})))}({fallbackParameters:E,indexName:n,maxRecommendations:r,model:a,objectIDs:R,queryParameters:p,recommendClient:i,threshold:l,transformItems:N.current}).then((e=>{g(e),x("idle")}))}),[E,n,r,a,R,p,i,x,l]),{...d,status:h}},e.useRecommendedForYou=N,e.useRelatedProducts=p,e.useTrendingFacets=F,e.useTrendingItems=q}));
/*! @algolia/recommend-react 1.12.1 | MIT License | © Algolia, Inc. and contributors | https://github.com/algolia/recommend */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/recommend-react"]={},e.React)}(this,(function(e,t){"use strict";function n(){return n=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},n.apply(this,arguments)}function r(...e){return e.filter(Boolean).join(" ")}function a({createElement:e,Fragment:t}){return function(n){return 0===n.recommendations.length&&"idle"===n.status?e(n.Fallback,null):e("section",{className:r("auc-Recommend",n.classNames.root)},e(n.Header,{classNames:n.classNames,recommendations:n.recommendations,translations:n.translations,createElement:e,Fragment:t}),e(n.View,null))}}function s({createElement:e}){return function(t){return!t.recommendations||t.recommendations.length<1?null:t.translations.title?e("h3",{className:r("auc-Recommend-title",t.classNames.title)},t.translations.title):null}}function m({createElement:e,Fragment:t}){return function(n){return e("div",{className:r("auc-Recommend-container",n.classNames.container)},e("ol",{className:r("auc-Recommend-list",n.classNames.list)},n.items.map((a=>e("li",{key:a.objectID,className:r("auc-Recommend-item",n.classNames.item)},e(n.itemComponent,{createElement:e,Fragment:t,item:a}))))))}}function o({hits:e,maxRecommendations:t,nrOfObjs:n}){const r={};e.forEach((e=>{e.forEach(((e,t)=>{r[e.objectID]?r[e.objectID]={indexSum:r[e.objectID].indexSum+t,nr:r[e.objectID].nr+1}:r[e.objectID]={indexSum:t,nr:1}}))}));const a=((e,t)=>{const n=[];for(const r of Object.keys(e))e[r].nr<2&&(e[r].indexSum+=100),n.push({objectID:r,avgOfIndices:e[r].indexSum/t});return n.sort(((e,t)=>e.avgOfIndices>t.avgOfIndices?1:-1))})(r,n);return a.reduce(((t,n)=>{const r=e.flat().find((e=>e.objectID===n.objectID));return r?t.concat(r):t}),[]).slice(0,t&&t>0?t:void 0)}function i({hits:e,maxRecommendations:t}){return function(e,t){const n=[...t];return n.sort(e),n}(((e,t)=>(e._score||0)>(t._score||0)?-1:1),e).slice(0,t&&t>0?t:void 0)}const c="1.12.1";const l=t.createContext({hasProvider:!1}),u=()=>t.useContext(l),d=e=>{const n=t.useContext(l);if(e)return{client:e,isContextClient:!1};if(n.recommendClient)return{client:n.recommendClient,isContextClient:!0};throw new Error("Pass an Algolia `recommendClient` instance either to the Recommend React context, a component or hook.")};function f(e){t.useEffect((()=>{e.recommendClient.addAlgoliaAgent("recommend-react","1.12.1")}),[e.recommendClient])}var g=Object.prototype.hasOwnProperty;function h(e,t){var n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&h(e[r],t[r]););return-1===r}if(!n||"object"==typeof e){for(n in r=0,e){if(g.call(e,n)&&++r&&!g.call(t,n))return!1;if(!(n in t)||!h(e[n],t[n]))return!1}return Object.keys(t).length===r}}return e!=e&&t!=t}function y(e){const[n,r]=t.useState((()=>e));return t.useEffect((()=>{!1===h(n,e)&&r(e)}),[e]),n}function b(e){const n=t.useRef(void 0),[r,a]=t.useState(e);return t.useEffect((()=>{"stalled"!==r&&n.current&&clearTimeout(n.current),"loading"===r&&(n.current=setTimeout((()=>{a("stalled")}),300))}),[r]),{status:r,setStatus:a}}function x({indexName:e,maxRecommendations:n,objectIDs:r,queryParameters:a,recommendClient:s,threshold:m,transformItems:i=(e=>e)}){const[l,g]=t.useState({recommendations:[]}),{status:h,setStatus:x}=b("loading"),R=y(r),p=y(a),{hasProvider:E,register:N}=u(),{client:C,isContextClient:k}=d(s);f({recommendClient:C});const P=t.useRef(i);return t.useEffect((()=>{P.current=i}),[i]),t.useEffect((()=>{const t={indexName:e,maxRecommendations:n,objectIDs:R,queryParameters:p,threshold:m,transformItems:P.current};if(E&&k){const r=JSON.stringify(t),a=R.map((t=>({indexName:e,model:"bought-together",threshold:m,maxRecommendations:n,objectID:t,queryParameters:p})));return N({key:r,getParameters:()=>({queries:a,keyPair:{key:r,value:R.length}}),onRequest(){x("loading")},onResult(e){g(e),x("idle")}})}return x("loading"),function({objectIDs:e,recommendClient:t,transformItems:n=(e=>e),indexName:r,maxRecommendations:a,queryParameters:s,threshold:m}){const i=e.map((e=>({indexName:r,maxRecommendations:a,objectID:e,queryParameters:s,threshold:m})));return t.addAlgoliaAgent("recommend-core",c),t.getFrequentlyBoughtTogether(i).then((t=>o({maxRecommendations:a,hits:t.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:n(e)})))}({...t,recommendClient:C}).then((e=>{g(e),x("idle")})),()=>{}}),[e,n,R,p,C,x,m,E,k,N]),{...l,status:h}}const R=function({createElement:e,Fragment:t}){return function(r){const o={title:"Frequently bought together",sliderLabel:"Frequently bought together products",...r.translations},i=r.classNames??{},c=r.children??a({createElement:e,Fragment:t}),l=r.fallbackComponent??function(){return null},u=r.headerComponent??s({createElement:e,Fragment:t}),d=r.view??m({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:r.items,status:r.status,translations:o,View:a=>e(d,n({classNames:i,itemComponent:r.itemComponent,items:r.items,translations:o,Fragment:t,createElement:e},a))})}}({createElement:t.createElement,Fragment:t.Fragment});function p({fallbackParameters:e,indexName:n,maxRecommendations:r,objectIDs:a,queryParameters:s,recommendClient:m,threshold:i,transformItems:l=(e=>e)}){const[g,h]=t.useState({recommendations:[]}),{status:x,setStatus:R}=b("loading"),p=y(a),E=y(s),N=y(e),{hasProvider:C,register:k}=u(),{client:P,isContextClient:F}=d(m);f({recommendClient:P});const I=t.useRef(l);return t.useEffect((()=>{I.current=l}),[l]),t.useEffect((()=>{const e={fallbackParameters:N,indexName:n,maxRecommendations:r,objectIDs:p,queryParameters:E,threshold:i,transformItems:I.current};if(C&&F){const t=JSON.stringify(e),a=p.map((e=>({indexName:n,model:"related-products",threshold:i,maxRecommendations:r,objectID:e,queryParameters:E,fallbackParameters:N})));return k({key:t,getParameters:()=>({queries:a,keyPair:{key:t,value:p.length}}),onRequest(){R("loading")},onResult(e){h(e),R("idle")}})}return R("loading"),function({objectIDs:e,recommendClient:t,transformItems:n=(e=>e),fallbackParameters:r,indexName:a,maxRecommendations:s,queryParameters:m,threshold:i}){const l=e.map((e=>({fallbackParameters:r,indexName:a,maxRecommendations:s,objectID:e,queryParameters:m,threshold:i})));return t.addAlgoliaAgent("recommend-core",c),t.getRelatedProducts(l).then((t=>o({maxRecommendations:s,hits:t.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:n(e)})))}({...e,recommendClient:P}).then((e=>{h(e),R("idle")})),()=>{}}),[P,N,C,n,F,r,p,E,k,R,i]),{...g,status:x}}const E=function({createElement:e,Fragment:t}){return function(r){const o={title:"Related products",sliderLabel:"Related products",...r.translations},i=r.classNames??{},c=r.children??a({createElement:e,Fragment:t}),l=r.fallbackComponent??function(){return null},u=r.headerComponent??s({createElement:e,Fragment:t}),d=r.view??m({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:r.items,status:r.status,translations:o,View:a=>e(d,n({classNames:i,itemComponent:r.itemComponent,items:r.items,translations:o,Fragment:t,createElement:e},a))})}}({createElement:t.createElement,Fragment:t.Fragment});function N({fallbackParameters:e,indexName:n,maxRecommendations:r,queryParameters:a,recommendClient:s,threshold:m,transformItems:o=(e=>e)}){const[i,l]=t.useState({recommendations:[]}),{status:g,setStatus:h}=b("loading"),x=y(a),R=y(e),{hasProvider:p,register:E}=u(),{client:N,isContextClient:C}=d(s);f({recommendClient:N});const k=t.useRef(o);return t.useEffect((()=>{k.current=o}),[o]),t.useEffect((()=>{const e={fallbackParameters:R,indexName:n,maxRecommendations:r,queryParameters:x,threshold:m,transformItems:k.current};if(p&&C){const t=JSON.stringify(e),a=[{indexName:n,threshold:m,maxRecommendations:r,queryParameters:x,fallbackParameters:R,model:"recommended-for-you"}];return E({key:t,getParameters:()=>({queries:a,keyPair:{key:t,value:1}}),onRequest(){h("loading")},onResult(e){l(e),h("idle")}})}return h("loading"),function({indexName:e,threshold:t,queryParameters:n,recommendClient:r,maxRecommendations:a,transformItems:s=(e=>e)}){r.addAlgoliaAgent("recommend-core",c);const m=[{indexName:e,threshold:t,queryParameters:n,maxRecommendations:a}];return r.getRecommendedForYou(m).then((e=>({recommendations:s(e.results.map((e=>e.hits)).flat())})))}({...e,recommendClient:N}).then((e=>{l(e),h("idle")})),()=>{}}),[N,R,p,n,C,r,x,E,h,m]),{...i,status:g}}const C=function({createElement:e,Fragment:t}){return function(r){const o={title:"Recommended For You",sliderLabel:"Recommended For You",...r.translations},i=r.classNames??{},c=r.children??a({createElement:e,Fragment:t}),l=r.fallbackComponent??function(){return null},u=r.headerComponent??s({createElement:e,Fragment:t}),d=r.view??m({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:r.items,status:r.status,translations:o,View:a=>e(d,n({classNames:i,itemComponent:r.itemComponent,items:r.items,translations:o,Fragment:t,createElement:e},a))})}}({createElement:t.createElement,Fragment:t.Fragment});function k({fallbackParameters:e,indexName:n,maxRecommendations:r,objectIDs:a,queryParameters:s,recommendClient:m,threshold:i,transformItems:l=(e=>e)}){const[g,h]=t.useState({recommendations:[]}),{status:x,setStatus:R}=b("loading"),p=y(a),E=y(s),N=y(e),{hasProvider:C,register:k}=u(),{client:P,isContextClient:F}=d(m);f({recommendClient:P});const I=t.useRef(l);return t.useEffect((()=>{I.current=l}),[l]),t.useEffect((()=>{const e={fallbackParameters:N,indexName:n,maxRecommendations:r,objectIDs:p,queryParameters:E,threshold:i,transformItems:I.current};if(C&&F){const t=JSON.stringify(e),a=p.map((e=>({indexName:n,model:"looking-similar",threshold:i,maxRecommendations:r,objectID:e,queryParameters:E,fallbackParameters:N})));return k({key:t,getParameters:()=>({queries:a,keyPair:{key:t,value:p.length}}),onRequest(){R("loading")},onResult(e){h(e),R("idle")}})}return R("loading"),function({objectIDs:e,recommendClient:t,transformItems:n=(e=>e),fallbackParameters:r,indexName:a,maxRecommendations:s,queryParameters:m,threshold:i}){const l=e.map((e=>({fallbackParameters:r,indexName:a,maxRecommendations:s,objectID:e,queryParameters:m,threshold:i})));return t.addAlgoliaAgent("recommend-core",c),t.getLookingSimilar(l).then((t=>o({maxRecommendations:s,hits:t.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:n(e)})))}({...e,recommendClient:P}).then((e=>{h(e),R("idle")})),()=>{}}),[P,N,C,n,F,r,p,E,k,R,i]),{...g,status:x}}const P=function({createElement:e,Fragment:t}){return function(r){const o={title:"Looking Similar",sliderLabel:"Looking Similar",...r.translations},i=r.classNames??{},c=r.children??a({createElement:e,Fragment:t}),l=r.fallbackComponent??function(){return null},u=r.headerComponent??s({createElement:e,Fragment:t}),d=r.view??m({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:r.items,status:r.status,translations:o,View:a=>e(d,n({classNames:i,itemComponent:r.itemComponent,items:r.items,translations:o,Fragment:t,createElement:e},a))})}}({createElement:t.createElement,Fragment:t.Fragment});function F({indexName:e,maxRecommendations:n,recommendClient:r,threshold:a,transformItems:s=(e=>e),facetName:m}){const[o,l]=t.useState({recommendations:[]}),{status:g,setStatus:h}=b("loading"),{hasProvider:y,register:x}=u(),{client:R,isContextClient:p}=d(r);f({recommendClient:R});const E=t.useRef(s);return t.useEffect((()=>{E.current=s}),[s]),t.useEffect((()=>{const t={model:"trending-facets",indexName:e,facetName:m,threshold:a,maxRecommendations:n,transformItems:E.current};if(y&&p){const e=JSON.stringify(t);return x({key:e,getParameters:()=>({queries:[t],keyPair:{key:e,value:1}}),onRequest(){h("loading")},onResult(e){l({...e,recommendations:e.trendingFacets}),h("idle")}})}return h("loading"),function({recommendClient:e,transformItems:t=(e=>e),indexName:n,maxRecommendations:r,threshold:a,facetName:s}){const m={indexName:n,maxRecommendations:r,threshold:a,facetName:s};return e.addAlgoliaAgent("recommend-core",c),e.getTrendingFacets([m]).then((e=>i({maxRecommendations:r,hits:e.results.map((e=>e.hits)).flat()}))).then((e=>({recommendations:t(e)})))}({...t,recommendClient:R,facetName:m,transformItems:E.current}).then((e=>{l(e),h("idle")})),()=>{}}),[e,n,R,h,a,m,y,p,x]),{...o,status:g}}const I=function({createElement:e,Fragment:t}){return function(m){const o={title:"Trending facets",sliderLabel:"Trending facets",...m.translations},i=m.classNames??{},c=m.children??a({createElement:e,Fragment:t}),l=m.fallbackComponent??function(){return null},u=m.headerComponent??s({createElement:e,Fragment:t}),d=m.view??function({createElement:e,Fragment:t}){return function(n){return e("div",{className:r("auc-Recommend-container",n.classNames.container)},e("ol",{className:r("auc-Recommend-list",n.classNames.list)},n.items.map((a=>e("li",{key:a.facetValue,className:r("auc-Recommend-item",n.classNames.item)},e(n.itemComponent,{createElement:e,Fragment:t,item:a}))))))}}({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:m.items,status:m.status,translations:o,View:r=>e(d,n({classNames:i,itemComponent:m.itemComponent,items:m.items,translations:o,Fragment:t,createElement:e},r))})}}({createElement:t.createElement,Fragment:t.Fragment});function q({fallbackParameters:e,indexName:n,maxRecommendations:r,queryParameters:a,recommendClient:s,threshold:m,transformItems:o=(e=>e),facetName:l,facetValue:g}){const[h,x]=t.useState({recommendations:[]}),{status:R,setStatus:p}=b("loading"),E=y(a),N=y(e),{hasProvider:C,register:k}=u(),{client:P,isContextClient:F}=d(s);f({recommendClient:P});const I=t.useRef(o);return t.useEffect((()=>{I.current=o}),[o]),t.useEffect((()=>{const e={model:"trending-items",fallbackParameters:N,indexName:n,maxRecommendations:r,queryParameters:E,threshold:m,facetName:l,facetValue:g,transformItems:I.current};if(C&&F){const t=JSON.stringify(e);return k({key:t,getParameters:()=>({queries:[e],keyPair:{key:t,value:1}}),onRequest(){p("loading")},onResult(e){x(e),p("idle")}})}return p("loading"),function({recommendClient:e,transformItems:t=(e=>e),fallbackParameters:n,indexName:r,maxRecommendations:a,queryParameters:s,threshold:m,facetName:o,facetValue:l}){const u={fallbackParameters:n,indexName:r,maxRecommendations:a,queryParameters:s,threshold:m,facetName:o,facetValue:l};return e.addAlgoliaAgent("recommend-core",c),e.getTrendingItems([u]).then((e=>{return i({maxRecommendations:a,hits:(t="objectID",n=e.results.map((e=>e.hits)).flat(),[...new Map(n.map((e=>[e[t],e]))).values()])});var t,n})).then((e=>({recommendations:t(e)})))}({...e,recommendClient:P,transformItems:I.current}).then((e=>{x(e),p("idle")})),()=>{}}),[N,n,r,E,P,p,m,l,g,C,F,k]),{...h,status:R}}const j=function({createElement:e,Fragment:t}){return function(r){const o={title:"Trending items",sliderLabel:"Trending items",...r.translations},i=r.classNames??{},c=r.children??a({createElement:e,Fragment:t}),l=r.fallbackComponent??function(){return null},u=r.headerComponent??s({createElement:e,Fragment:t}),d=r.view??m({createElement:e,Fragment:t});return c({classNames:i,Fallback:()=>e(l,{Fragment:t,createElement:e}),Header:u,recommendations:r.items,status:r.status,translations:o,View:a=>e(d,n({classNames:i,itemComponent:r.itemComponent,items:r.items,translations:o,Fragment:t,createElement:e},a))})}}({createElement:t.createElement,Fragment:t.Fragment});var v=Object.prototype.hasOwnProperty;function S(e,t,n){for(n of e.keys())if(w(n,t))return n}function w(e,t){var n,r,a;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&w(e[r],t[r]););return-1===r}if(n===Set){if(e.size!==t.size)return!1;for(r of e){if((a=r)&&"object"==typeof a&&!(a=S(t,a)))return!1;if(!t.has(a))return!1}return!0}if(n===Map){if(e.size!==t.size)return!1;for(r of e){if((a=r[0])&&"object"==typeof a&&!(a=S(t,a)))return!1;if(!w(r[1],t.get(a)))return!1}return!0}if(n===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(n===DataView){if((r=e.byteLength)===t.byteLength)for(;r--&&e.getInt8(r)===t.getInt8(r););return-1===r}if(ArrayBuffer.isView(e)){if((r=e.byteLength)===t.byteLength)for(;r--&&e[r]===t[r];);return-1===r}if(!n||"object"==typeof e){for(n in r=0,e){if(v.call(e,n)&&++r&&!v.call(t,n))return!1;if(!(n in t)||!w(e[n],t[n]))return!1}return Object.keys(t).length===r}}return e!=e&&t!=t}function D(e){return null!=e}function O(e){return JSON.stringify(e)}function A(e,t){return e.map((e=>{if(function(e,t){return Boolean(e[O(t)])}(t,e.param.queries)){const n=t[O(e.param.queries)];return e.onResult(n),null}return e.param})).filter(D)}const T=(e,t)=>{const{type:n}=t;switch(n){case"register":{const{widget:n}=t,r=n.getParameters(),a=function(e,t){return Boolean(e.find((e=>w(e.param,t))))}(e.widgets,r);return a?e:{...e,widgets:[...e.widgets,{...n,param:r}],isDirty:Date.now()}}case"unregister":{const{key:n}=t;return{...e,widgets:e.widgets.filter((e=>e.key!==n))}}case"request_success":return{...e,status:"idle",isDirty:null};default:return e}};e.FrequentlyBoughtTogether=function(e){const{recommendations:r,status:a}=x(e);return t.createElement(R,n({},e,{items:r,status:a}))},e.LookingSimilar=function(e){const{recommendations:r,status:a}=k(e);return t.createElement(P,n({},e,{items:r,status:a}))},e.Recommend=function({recommendClient:e,children:n}){const[r,a]=t.useReducer(T,{isDirty:null,cache:{},widgets:[],recommendClient:e});t.useEffect((()=>{if(!r.isDirty)return;const t=A(r.widgets,r.cache);if(0===t.length)return;const{queries:n,keys:s}=function(e){return{queries:e.map((e=>e.queries)).reduce(((e,t)=>e.concat(t)),[]),keys:e.map((e=>e.keyPair))}}(t);s.forEach((e=>{r.widgets.forEach((t=>{t.key===e.key&&t.onRequest()}))})),async function({keys:e,queries:t,recommendClient:n}){n.addAlgoliaAgent("recommend-core",c);const r=await n.getRecommendations(t);let a=0,s=0;const m={};return e.forEach((e=>{const{model:n}=JSON.parse(e.key);s+=e.value;const{maxRecommendations:c,transformItems:l=(e=>e)}=t[a],u=r?.results?.slice(a,s);a+=e.value;let d=[],f=[];"trending-facets"===n?f=u.map((e=>e.hits)).flat():d="trending-items"===n?i({maxRecommendations:c,hits:u.map((e=>e.hits)).flat()}):o({maxRecommendations:c,hits:u.map((e=>e.hits)),nrOfObjs:e.value}),d=l(d),m[e.key]={recommendations:d,trendingFacets:f}})),m}({recommendClient:e,queries:n,keys:s}).then((e=>{Object.entries(e).forEach((([e,t])=>{r.widgets.forEach((n=>{n.key===e&&(n.onResult(t),r.cache[O(n.param.queries)]=t)}))})),a({type:"request_success"})}))}),[r.isDirty,a,r.widgets,r.cache,e]);const s=t.useCallback((e=>(a({type:"register",widget:e}),()=>{a({type:"unregister",key:e.key})})),[]),m=t.useMemo((()=>({register:s,recommendClient:e,hasProvider:!0})),[e,s]);return t.createElement(l.Provider,{value:m},n)},e.RecommendedForYou=function(e){const{recommendations:r,status:a}=N(e);return t.createElement(C,n({},e,{items:r,status:a}))},e.RelatedProducts=function(e){const{recommendations:r,status:a}=p(e);return t.createElement(E,n({},e,{items:r,status:a}))},e.TrendingFacets=function(e){const{recommendations:r,status:a}=F(e);return t.createElement(I,n({},e,{items:r,status:a}))},e.TrendingItems=function(e){const{recommendations:r,status:a}=q(e);return t.createElement(j,n({},e,{items:r,status:a}))},e.useFrequentlyBoughtTogether=x,e.useLookingSimilar=k,e.useRecommendations=function({fallbackParameters:e,indexName:n,maxRecommendations:r,model:a,objectIDs:s,queryParameters:m,recommendClient:i,threshold:l,transformItems:u=(e=>e)}){const[d,g]=t.useState({recommendations:[]}),{status:h,setStatus:x}=b("loading"),R=y(s),p=y(m),E=y(e);f({recommendClient:i});const N=t.useRef(u);return t.useEffect((()=>{N.current=u}),[u]),t.useEffect((()=>{x("loading"),function({objectIDs:e,recommendClient:t,transformItems:n=(e=>e),fallbackParameters:r,indexName:a,maxRecommendations:s,model:m,queryParameters:i,threshold:l}){const u=e.map((e=>({fallbackParameters:r,indexName:a,maxRecommendations:s,model:m,objectID:e,queryParameters:i,threshold:l})));return t.addAlgoliaAgent("recommend-core",c),t.getRecommendations(u).then((t=>o({maxRecommendations:s,hits:t.results.map((e=>e.hits)),nrOfObjs:e.length}))).then((e=>({recommendations:n(e)})))}({fallbackParameters:E,indexName:n,maxRecommendations:r,model:a,objectIDs:R,queryParameters:p,recommendClient:i,threshold:l,transformItems:N.current}).then((e=>{g(e),x("idle")}))}),[E,n,r,a,R,p,i,x,l]),{...d,status:h}},e.useRecommendedForYou=N,e.useRelatedProducts=p,e.useTrendingFacets=F,e.useTrendingItems=q}));
//# sourceMappingURL=index.js.map
{
"name": "@algolia/recommend-react",
"description": "React package for Algolia Recommend.",
"version": "1.12.0",
"version": "1.12.1",
"license": "MIT",

@@ -32,4 +32,4 @@ "homepage": "https://github.com/algolia/recommend",

"dependencies": {
"@algolia/recommend-core": "1.12.0",
"@algolia/recommend-vdom": "1.12.0",
"@algolia/recommend-core": "1.12.1",
"@algolia/recommend-vdom": "1.12.1",
"dequal": "2.0.3"

@@ -36,0 +36,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc