algoliasearch-helper
Advanced tools
Comparing version 3.17.0 to 3.18.0
@@ -1,3 +0,3 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.algoliasearchHelper=e()}}(function(){return function(){function e(t,i,n){function r(a,c){if(!i[a]){if(!t[a]){var u="function"==typeof require&&require;if(!c&&u)return u(a,!0);if(s)return s(a,!0);var o=new Error("Cannot find module '"+a+"'");throw o.code="MODULE_NOT_FOUND",o}var f=i[a]={exports:{}};t[a][0].call(f.exports,function(e){return r(t[a][1][e]||e)},f,f.exports,e,t,i,n)}return i[a].exports}for(var s="function"==typeof require&&require,a=0;a<n.length;a++)r(n[a]);return r}return e}()({1:[function(e,t,i){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function s(e){return"number"==typeof e}function a(e){return"object"==typeof e&&null!==e}function c(e){return void 0===e}t.exports=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!s(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,i,n,s,u,o;if(this._events||(this._events={}),"error"===e&&(!this._events.error||a(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var f=new Error('Uncaught, unspecified "error" event. ('+t+")");throw f.context=t,f}if(i=this._events[e],c(i))return!1;if(r(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),i.apply(this,s)}else if(a(i))for(s=Array.prototype.slice.call(arguments,1),o=i.slice(),n=o.length,u=0;u<n;u++)o[u].apply(this,s);return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?a(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,a(this._events[e])&&!this._events[e].warned&&(i=c(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var n=!1;return i.listener=t,this.on(e,i),this},n.prototype.removeListener=function(e,t){var i,n,s,c;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],s=i.length,n=-1,i===t||r(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(i)){for(c=s;c-- >0;)if(i[c]===t||i[c].listener&&i[c].listener===t){n=c;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[e],r(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(e,t,i){"use strict";function n(e,t,i,n){return new r(e,t,i,n)}var r=e("./src/algoliasearch.helper"),s=e("./src/SearchParameters"),a=e("./src/SearchResults");n.version=e("./src/version"),n.AlgoliaSearchHelper=r,n.SearchParameters=s,n.SearchResults=a,t.exports=n},{"./src/SearchParameters":6,"./src/SearchResults":8,"./src/algoliasearch.helper":9,"./src/version":25}],3:[function(e,t,i){"use strict";function n(e,t){this.main=e,this.fn=t,this.lastResults=null}var r=e("@algolia/events");e("../functions/inherits")(n,r),n.prototype.detach=function(){this.removeAllListeners(),this.main.detachDerivedHelper(this)},n.prototype.getModifiedState=function(e){return this.fn(e)},t.exports=n},{"../functions/inherits":16,"@algolia/events":1}],4:[function(e,t,i){"use strict";function n(e){e=e||{},this.params=e.params||[]}n.prototype={constructor:n,addParams:function(e){return new n({params:this.params.concat(e)})},removeParams:function(e){return new n({params:this.params.filter(function(t){return t.$$id!==e})})}},t.exports=n},{}],5:[function(e,t,i){"use strict";var n=e("../functions/defaultsPure"),r=e("../functions/objectHasKeys"),s=e("../functions/omit"),a={addRefinement:function(e,t,i){if(a.isRefined(e,t,i))return e;var r=""+i,s=e[t]?e[t].concat(r):[r],c={};return c[t]=s,n({},c,e)},removeRefinement:function(e,t,i){if(void 0===i)return a.clearRefinement(e,function(e,i){return t===i});var n=""+i;return a.clearRefinement(e,function(e,i){return t===i&&n===e})},toggleRefinement:function(e,t,i){if(void 0===i)throw new Error("toggleRefinement should be used with a value");return a.isRefined(e,t,i)?a.removeRefinement(e,t,i):a.addRefinement(e,t,i)},clearRefinement:function(e,t,i){if(void 0===t)return r(e)?{}:e;if("string"==typeof t)return s(e,[t]);if("function"==typeof t){var n=!1,a=Object.keys(e).reduce(function(r,s){var a=e[s]||[],c=a.filter(function(e){return!t(e,s,i)});return c.length!==a.length&&(n=!0),r[s]=c,r},{});return n?a:e}},isRefined:function(e,t,i){var n=Boolean(e[t])&&e[t].length>0;if(void 0===i||!n)return n;var r=""+i;return-1!==e[t].indexOf(r)}};t.exports=a},{"../functions/defaultsPure":11,"../functions/objectHasKeys":19,"../functions/omit":20}],6:[function(e,t,i){"use strict";function n(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every(function(e,i){return n(t[i],e)}):e===t}function r(e,t){return c(e,function(e){return n(e,t)})}function s(e){var t=e?s._parseNumbers(e):{};void 0===t.userToken||m(t.userToken)||console.warn("[algoliasearch-helper] The `userToken` parameter is invalid. This can lead to wrong analytics.\n - Format: [a-zA-Z0-9_-]{1,64}"),this.facets=t.facets||[],this.disjunctiveFacets=t.disjunctiveFacets||[],this.hierarchicalFacets=t.hierarchicalFacets||[],this.facetsRefinements=t.facetsRefinements||{},this.facetsExcludes=t.facetsExcludes||{},this.disjunctiveFacetsRefinements=t.disjunctiveFacetsRefinements||{},this.numericRefinements=t.numericRefinements||{},this.tagRefinements=t.tagRefinements||[],this.hierarchicalFacetsRefinements=t.hierarchicalFacetsRefinements||{};var i=this;Object.keys(t).forEach(function(e){var n=-1!==s.PARAMETERS.indexOf(e),r=void 0!==t[e];!n&&r&&(i[e]=t[e])})}var a=e("../functions/defaultsPure"),c=e("../functions/find"),u=e("../functions/intersection"),o=e("../functions/merge"),f=e("../functions/objectHasKeys"),h=e("../functions/omit"),l=e("../functions/valToNumber"),m=e("../utils/isValidUserToken"),d=e("./RefinementList");s.PARAMETERS=Object.keys(new s),s._parseNumbers=function(e){if(e instanceof s)return e;var t={};if(["aroundPrecision","aroundRadius","getRankingInfo","minWordSizefor2Typos","minWordSizefor1Typo","page","maxValuesPerFacet","distinct","minimumAroundRadius","hitsPerPage","minProximity"].forEach(function(i){var n=e[i];if("string"==typeof n){var r=parseFloat(n);t[i]=isNaN(r)?n:r}}),Array.isArray(e.insideBoundingBox)&&(t.insideBoundingBox=e.insideBoundingBox.map(function(e){return Array.isArray(e)?e.map(function(e){return parseFloat(e)}):e})),e.numericRefinements){var i={};Object.keys(e.numericRefinements).forEach(function(t){var n=e.numericRefinements[t]||{};i[t]={},Object.keys(n).forEach(function(e){var r=n[e],s=r.map(function(e){return Array.isArray(e)?e.map(function(e){return"string"==typeof e?parseFloat(e):e}):"string"==typeof e?parseFloat(e):e});i[t][e]=s})}),t.numericRefinements=i}return o(e,t)},s.make=function(e){var t=new s(e);return(e.hierarchicalFacets||[]).forEach(function(e){if(e.rootPath){var i=t.getHierarchicalRefinement(e.name);i.length>0&&0!==i[0].indexOf(e.rootPath)&&(t=t.clearRefinements(e.name)),i=t.getHierarchicalRefinement(e.name),0===i.length&&(t=t.toggleHierarchicalFacetRefinement(e.name,e.rootPath))}}),t},s.validate=function(e,t){var i=t||{};return e.tagFilters&&i.tagRefinements&&i.tagRefinements.length>0?new Error("[Tags] Cannot switch from the managed tag API to the advanced API. It is probably an error, if it is really what you want, you should first clear the tags with clearTags method."):e.tagRefinements.length>0&&i.tagFilters?new Error("[Tags] Cannot switch from the advanced tag API to the managed API. It is probably an error, if it is not, you should first clear the tags with clearTags method."):e.numericFilters&&i.numericRefinements&&f(i.numericRefinements)?new Error("[Numeric filters] Can't switch from the advanced to the managed API. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):f(e.numericRefinements)&&i.numericFilters?new Error("[Numeric filters] Can't switch from the managed API to the advanced. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):null},s.prototype={constructor:s,clearRefinements:function(e){var t={numericRefinements:this._clearNumericRefinements(e),facetsRefinements:d.clearRefinement(this.facetsRefinements,e,"conjunctiveFacet"),facetsExcludes:d.clearRefinement(this.facetsExcludes,e,"exclude"),disjunctiveFacetsRefinements:d.clearRefinement(this.disjunctiveFacetsRefinements,e,"disjunctiveFacet"),hierarchicalFacetsRefinements:d.clearRefinement(this.hierarchicalFacetsRefinements,e,"hierarchicalFacet")};return t.numericRefinements===this.numericRefinements&&t.facetsRefinements===this.facetsRefinements&&t.facetsExcludes===this.facetsExcludes&&t.disjunctiveFacetsRefinements===this.disjunctiveFacetsRefinements&&t.hierarchicalFacetsRefinements===this.hierarchicalFacetsRefinements?this:this.setQueryParameters(t)},clearTags:function(){return void 0===this.tagFilters&&0===this.tagRefinements.length?this:this.setQueryParameters({tagFilters:void 0,tagRefinements:[]})},setIndex:function(e){return e===this.index?this:this.setQueryParameters({index:e})},setQuery:function(e){return e===this.query?this:this.setQueryParameters({query:e})},setPage:function(e){return e===this.page?this:this.setQueryParameters({page:e})},setFacets:function(e){return this.setQueryParameters({facets:e})},setDisjunctiveFacets:function(e){return this.setQueryParameters({disjunctiveFacets:e})},setHitsPerPage:function(e){return this.hitsPerPage===e?this:this.setQueryParameters({hitsPerPage:e})},setTypoTolerance:function(e){return this.typoTolerance===e?this:this.setQueryParameters({typoTolerance:e})},addNumericRefinement:function(e,t,i){var n=l(i);if(this.isNumericRefined(e,t,n))return this;var r=o({},this.numericRefinements);return r[e]=o({},r[e]),r[e][t]?(r[e][t]=r[e][t].slice(),r[e][t].push(n)):r[e][t]=[n],this.setQueryParameters({numericRefinements:r})},getConjunctiveRefinements:function(e){return this.isConjunctiveFacet(e)?this.facetsRefinements[e]||[]:[]},getDisjunctiveRefinements:function(e){return this.isDisjunctiveFacet(e)?this.disjunctiveFacetsRefinements[e]||[]:[]},getHierarchicalRefinement:function(e){return this.hierarchicalFacetsRefinements[e]||[]},getExcludeRefinements:function(e){return this.isConjunctiveFacet(e)?this.facetsExcludes[e]||[]:[]},removeNumericRefinement:function(e,t,i){var r=i;return void 0!==r?this.isNumericRefined(e,t,r)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements(function(i,s){return s===e&&i.op===t&&n(i.val,l(r))})}):this:void 0!==t?this.isNumericRefined(e,t)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements(function(i,n){return n===e&&i.op===t})}):this:this.isNumericRefined(e)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements(function(t,i){return i===e})}):this},getNumericRefinements:function(e){return this.numericRefinements[e]||{}},getNumericRefinement:function(e,t){return this.numericRefinements[e]&&this.numericRefinements[e][t]},_clearNumericRefinements:function(e){if(void 0===e)return f(this.numericRefinements)?{}:this.numericRefinements;if("string"==typeof e)return h(this.numericRefinements,[e]);if("function"==typeof e){var t=!1,i=this.numericRefinements,n=Object.keys(i).reduce(function(n,r){var s=i[r],a={};return s=s||{},Object.keys(s).forEach(function(i){var n=s[i]||[],c=[];n.forEach(function(t){e({val:t,op:i},r,"numeric")||c.push(t)}),c.length!==n.length&&(t=!0),a[i]=c}),n[r]=a,n},{});return t?n:this.numericRefinements}},addFacet:function(e){return this.isConjunctiveFacet(e)?this:this.setQueryParameters({facets:this.facets.concat([e])})},addDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this:this.setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.concat([e])})},addHierarchicalFacet:function(e){if(this.isHierarchicalFacet(e.name))throw new Error("Cannot declare two hierarchical facets with the same name: `"+e.name+"`");return this.setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.concat([e])})},addFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return d.isRefined(this.facetsRefinements,e,t)?this:this.setQueryParameters({facetsRefinements:d.addRefinement(this.facetsRefinements,e,t)})},addExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return d.isRefined(this.facetsExcludes,e,t)?this:this.setQueryParameters({facetsExcludes:d.addRefinement(this.facetsExcludes,e,t)})},addDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return d.isRefined(this.disjunctiveFacetsRefinements,e,t)?this:this.setQueryParameters({disjunctiveFacetsRefinements:d.addRefinement(this.disjunctiveFacetsRefinements,e,t)})},addTagRefinement:function(e){if(this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.concat(e)};return this.setQueryParameters(t)},removeFacet:function(e){return this.isConjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({facets:this.facets.filter(function(t){return t!==e})}):this},removeDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.filter(function(t){return t!==e})}):this},removeHierarchicalFacet:function(e){return this.isHierarchicalFacet(e)?this.clearRefinements(e).setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.filter(function(t){return t.name!==e})}):this},removeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return d.isRefined(this.facetsRefinements,e,t)?this.setQueryParameters({facetsRefinements:d.removeRefinement(this.facetsRefinements,e,t)}):this},removeExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return d.isRefined(this.facetsExcludes,e,t)?this.setQueryParameters({facetsExcludes:d.removeRefinement(this.facetsExcludes,e,t)}):this},removeDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return d.isRefined(this.disjunctiveFacetsRefinements,e,t)?this.setQueryParameters({disjunctiveFacetsRefinements:d.removeRefinement(this.disjunctiveFacetsRefinements,e,t)}):this},removeTagRefinement:function(e){if(!this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.filter(function(t){return t!==e})};return this.setQueryParameters(t)},toggleRefinement:function(e,t){return this.toggleFacetRefinement(e,t)},toggleFacetRefinement:function(e,t){if(this.isHierarchicalFacet(e))return this.toggleHierarchicalFacetRefinement(e,t);if(this.isConjunctiveFacet(e))return this.toggleConjunctiveFacetRefinement(e,t);if(this.isDisjunctiveFacet(e))return this.toggleDisjunctiveFacetRefinement(e,t);throw new Error("Cannot refine the undeclared facet "+e+"; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets")},toggleConjunctiveFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsRefinements:d.toggleRefinement(this.facetsRefinements,e,t)})},toggleExcludeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsExcludes:d.toggleRefinement(this.facetsExcludes,e,t)})},toggleDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return this.setQueryParameters({disjunctiveFacetsRefinements:d.toggleRefinement(this.disjunctiveFacetsRefinements,e,t)})},toggleHierarchicalFacetRefinement:function(e,t){if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration");var i=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e)),n={};return void 0!==this.hierarchicalFacetsRefinements[e]&&this.hierarchicalFacetsRefinements[e].length>0&&(this.hierarchicalFacetsRefinements[e][0]===t||0===this.hierarchicalFacetsRefinements[e][0].indexOf(t+i))?-1===t.indexOf(i)?n[e]=[]:n[e]=[t.slice(0,t.lastIndexOf(i))]:n[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:a({},n,this.hierarchicalFacetsRefinements)})},addHierarchicalFacetRefinement:function(e,t){if(this.isHierarchicalFacetRefined(e))throw new Error(e+" is already refined.");if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration.");var i={};return i[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:a({},i,this.hierarchicalFacetsRefinements)})},removeHierarchicalFacetRefinement:function(e){if(!this.isHierarchicalFacetRefined(e))return this;var t={};return t[e]=[],this.setQueryParameters({hierarchicalFacetsRefinements:a({},t,this.hierarchicalFacetsRefinements)})},toggleTagRefinement:function(e){return this.isTagRefined(e)?this.removeTagRefinement(e):this.addTagRefinement(e)},isDisjunctiveFacet:function(e){return this.disjunctiveFacets.indexOf(e)>-1},isHierarchicalFacet:function(e){return void 0!==this.getHierarchicalFacetByName(e)},isConjunctiveFacet:function(e){return this.facets.indexOf(e)>-1},isFacetRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&d.isRefined(this.facetsRefinements,e,t)},isExcludeRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&d.isRefined(this.facetsExcludes,e,t)},isDisjunctiveFacetRefined:function(e,t){return!!this.isDisjunctiveFacet(e)&&d.isRefined(this.disjunctiveFacetsRefinements,e,t)},isHierarchicalFacetRefined:function(e,t){if(!this.isHierarchicalFacet(e))return!1;var i=this.getHierarchicalRefinement(e);return t?-1!==i.indexOf(t):i.length>0},isNumericRefined:function(e,t,i){if(void 0===i&&void 0===t)return Boolean(this.numericRefinements[e]);var n=this.numericRefinements[e]&&void 0!==this.numericRefinements[e][t];if(void 0===i||!n)return n;var s=l(i),a=void 0!==r(this.numericRefinements[e][t],s);return n&&a},isTagRefined:function(e){return-1!==this.tagRefinements.indexOf(e)},getRefinedDisjunctiveFacets:function(){var e=this,t=u(Object.keys(this.numericRefinements).filter(function(t){return Object.keys(e.numericRefinements[t]).length>0}),this.disjunctiveFacets);return Object.keys(this.disjunctiveFacetsRefinements).filter(function(t){return e.disjunctiveFacetsRefinements[t].length>0}).concat(t).concat(this.getRefinedHierarchicalFacets()).sort()},getRefinedHierarchicalFacets:function(){var e=this;return u(this.hierarchicalFacets.map(function(e){return e.name}),Object.keys(this.hierarchicalFacetsRefinements).filter(function(t){return e.hierarchicalFacetsRefinements[t].length>0})).sort()},getUnrefinedDisjunctiveFacets:function(){var e=this.getRefinedDisjunctiveFacets();return this.disjunctiveFacets.filter(function(t){return-1===e.indexOf(t)})},managedParameters:["index","facets","disjunctiveFacets","facetsRefinements","hierarchicalFacets","facetsExcludes","disjunctiveFacetsRefinements","numericRefinements","tagRefinements","hierarchicalFacetsRefinements"],getQueryParams:function(){var e=this.managedParameters,t={},i=this;return Object.keys(this).forEach(function(n){var r=i[n];-1===e.indexOf(n)&&void 0!==r&&(t[n]=r)}),t},setQueryParameter:function(e,t){if(this[e]===t)return this;var i={};return i[e]=t,this.setQueryParameters(i)},setQueryParameters:function(e){if(!e)return this;var t=s.validate(this,e);if(t)throw t;var i=this,n=s._parseNumbers(e),r=Object.keys(this).reduce(function(e,t){return e[t]=i[t],e},{}),a=Object.keys(n).reduce(function(e,t){var i=void 0!==e[t],r=void 0!==n[t];return i&&!r?h(e,[t]):(r&&(e[t]=n[t]),e)},r);return new this.constructor(a)},resetPage:function(){return void 0===this.page?this:this.setPage(0)},_getHierarchicalFacetSortBy:function(e){return e.sortBy||["isRefined:desc","name:asc"]},_getHierarchicalFacetSeparator:function(e){return e.separator||" > "},_getHierarchicalRootPath:function(e){return e.rootPath||null},_getHierarchicalShowParentLevel:function(e){return"boolean"!=typeof e.showParentLevel||e.showParentLevel},getHierarchicalFacetByName:function(e){return c(this.hierarchicalFacets,function(t){return t.name===e})},getHierarchicalFacetBreadcrumb:function(e){if(!this.isHierarchicalFacet(e))return[];var t=this.getHierarchicalRefinement(e)[0];if(!t)return[];var i=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e));return t.split(i).map(function(e){return e.trim()})},toString:function(){return JSON.stringify(this,null,2)}},t.exports=s},{"../functions/defaultsPure":11,"../functions/find":13,"../functions/intersection":17,"../functions/merge":18,"../functions/objectHasKeys":19,"../functions/omit":20,"../functions/valToNumber":22,"../utils/isValidUserToken":24,"./RefinementList":5}],7:[function(e,t,i){"use strict";function n(e){return function(t,i){var n=e.hierarchicalFacets[i],s=e.hierarchicalFacetsRefinements[n.name]&&e.hierarchicalFacetsRefinements[n.name][0]||"",a=e._getHierarchicalFacetSeparator(n),c=e._getHierarchicalRootPath(n),u=e._getHierarchicalShowParentLevel(n),f=o(e._getHierarchicalFacetSortBy(n)),h=t.every(function(e){return e.exhaustive}),l=r(f,a,c,u,s),m=t;return c&&(m=t.slice(c.split(a).length)),m.reduce(l,{name:e.hierarchicalFacets[i].name,count:null,isRefined:!0,path:null,escapedValue:null,exhaustive:h,data:null})}}function r(e,t,i,n,r){return function(c,o,h){var m=c;if(h>0){var d=0;for(m=c;d<h;){var p=m&&Array.isArray(m.data)?m.data:[];m=u(p,function(e){return e.isRefined}),d++}}if(m){var v=Object.keys(o.data).map(function(e){return[e,o.data[e]]}).filter(function(e){return s(e[0],m.path||i,r,t,i,n)});m.data=f(v.map(function(e){var i=e[0];return a(e[1],i,t,l(r),o.exhaustive)}),e[0],e[1])}return c}}function s(e,t,i,n,r,s){return(!r||0===e.indexOf(r)&&r!==e)&&(!r&&-1===e.indexOf(n)||r&&e.split(n).length-r.split(n).length==1||-1===e.indexOf(n)&&-1===i.indexOf(n)||0===i.indexOf(e)||0===e.indexOf(t+n)&&(s||0===e.indexOf(i)))}function a(e,t,i,n,r){var s=t.split(i);return{name:s[s.length-1].trim(),path:t,escapedValue:h(t),count:e,isRefined:n===t||0===n.indexOf(t+i),exhaustive:r,data:null}}t.exports=n;var c=e("../functions/escapeFacetValue"),u=e("../functions/find"),o=e("../functions/formatSort"),f=e("../functions/orderBy"),h=c.escapeFacetValue,l=c.unescapeFacetValue},{"../functions/escapeFacetValue":12,"../functions/find":13,"../functions/formatSort":15,"../functions/orderBy":21}],8:[function(e,t,i){"use strict";function n(e){var t={};return e.forEach(function(e,i){t[e]=i}),t}function r(e,t,i){t&&t[i]&&(e.stats=t[i])}function s(e,t){return R(e,function(e){return(e.attributes||[]).indexOf(t)>-1})}function a(e,t,i){var a=t[0];this._rawResults=t;var c=this;Object.keys(a).forEach(function(e){c[e]=a[e]});var u=j({persistHierarchicalRootCount:!1},i);Object.keys(u).forEach(function(e){c[e]=u[e]}),this.processingTimeMS=t.reduce(function(e,t){return void 0===t.processingTimeMS?e:e+t.processingTimeMS},0),this.disjunctiveFacets=[],this.hierarchicalFacets=e.hierarchicalFacets.map(function(){return[]}),this.facets=[];var o=e.getRefinedDisjunctiveFacets(),f=n(e.facets),h=n(e.disjunctiveFacets),l=1,m=a.facets||{};Object.keys(m).forEach(function(t){var i=m[t],n=s(e.hierarchicalFacets,t);if(n){var u=n.attributes.indexOf(t),o=F(e.hierarchicalFacets,function(e){return e.name===n.name});c.hierarchicalFacets[o][u]={attribute:t,data:i,exhaustive:a.exhaustiveFacetsCount}}else{var l,d=-1!==e.disjunctiveFacets.indexOf(t),p=-1!==e.facets.indexOf(t);d&&(l=h[t],c.disjunctiveFacets[l]={name:t,data:i,exhaustive:a.exhaustiveFacetsCount},r(c.disjunctiveFacets[l],a.facets_stats,t)),p&&(l=f[t],c.facets[l]={name:t,data:i,exhaustive:a.exhaustiveFacetsCount},r(c.facets[l],a.facets_stats,t))}}),this.hierarchicalFacets=v(this.hierarchicalFacets),o.forEach(function(i){var n=t[l],s=n&&n.facets?n.facets:{},u=e.getHierarchicalFacetByName(i);Object.keys(s).forEach(function(t){var i,o=s[t];if(u){i=F(e.hierarchicalFacets,function(e){return e.name===u.name});var f=F(c.hierarchicalFacets[i],function(e){return e.attribute===t});if(-1===f)return;c.hierarchicalFacets[i][f].data=j({},c.hierarchicalFacets[i][f].data,o)}else{i=h[t];var l=a.facets&&a.facets[t]||{};c.disjunctiveFacets[i]={name:t,data:g({},o,l),exhaustive:n.exhaustiveFacetsCount},r(c.disjunctiveFacets[i],n.facets_stats,t),e.disjunctiveFacetsRefinements[t]&&e.disjunctiveFacetsRefinements[t].forEach(function(n){!c.disjunctiveFacets[i].data[n]&&e.disjunctiveFacetsRefinements[t].indexOf(P(n))>-1&&(c.disjunctiveFacets[i].data[n]=0)})}}),l++}),e.getRefinedHierarchicalFacets().forEach(function(i){var n=e.getHierarchicalFacetByName(i),r=e._getHierarchicalFacetSeparator(n),s=e.getHierarchicalRefinement(i);0===s.length||s[0].split(r).length<2||t.slice(l).forEach(function(t){var i=t&&t.facets?t.facets:{};Object.keys(i).forEach(function(t){var a=i[t],u=F(e.hierarchicalFacets,function(e){return e.name===n.name}),o=F(c.hierarchicalFacets[u],function(e){return e.attribute===t});if(-1!==o){var f={};if(s.length>0&&!c.persistHierarchicalRootCount){var h=s[0].split(r)[0];f[h]=c.hierarchicalFacets[u][o].data[h]}c.hierarchicalFacets[u][o].data=g(f,a,c.hierarchicalFacets[u][o].data)}}),l++})}),Object.keys(e.facetsExcludes).forEach(function(t){var i=e.facetsExcludes[t],n=f[t];c.facets[n]={name:t,data:m[t],exhaustive:a.exhaustiveFacetsCount},i.forEach(function(e){c.facets[n]=c.facets[n]||{name:t},c.facets[n].data=c.facets[n].data||{},c.facets[n].data[e]=0})}),this.hierarchicalFacets=this.hierarchicalFacets.map(E(e)),this.facets=v(this.facets),this.disjunctiveFacets=v(this.disjunctiveFacets),this._state=e}function c(e,t){function i(e){return e.name===t}if(e._state.isConjunctiveFacet(t)){var n=R(e.facets,i);return n?Object.keys(n.data).map(function(i){var r=b(i);return{name:i,escapedValue:r,count:n.data[i],isRefined:e._state.isFacetRefined(t,r),isExcluded:e._state.isExcludeRefined(t,i)}}):[]}if(e._state.isDisjunctiveFacet(t)){var r=R(e.disjunctiveFacets,i);return r?Object.keys(r.data).map(function(i){var n=b(i);return{name:i,escapedValue:n,count:r.data[i],isRefined:e._state.isDisjunctiveFacetRefined(t,n)}}):[]}if(e._state.isHierarchicalFacet(t)){var s=R(e.hierarchicalFacets,i);if(!s)return s;var a=e._state.getHierarchicalFacetByName(t),c=e._state._getHierarchicalFacetSeparator(a),o=P(e._state.getHierarchicalRefinement(t)[0]||"");0===o.indexOf(a.rootPath)&&(o=o.replace(a.rootPath+c,""));var f=o.split(c);return f.unshift(t),u(s,f,0),s}}function u(e,t,i){e.isRefined=e.name===(t[i]&&t[i].trim()),e.data&&e.data.forEach(function(e){u(e,t,i+1)})}function o(e,t,i,n){if(n=n||0,Array.isArray(t))return e(t,i[n]);if(!t.data||0===t.data.length)return t;var r=t.data.map(function(t){return o(e,t,i,n+1)}),s=e(r,i[n]);return g({data:s},t)}function f(e,t){return t.sort(e)}function h(e,t){var i=[],n=[],r=t.order||[],s=r.reduce(function(e,t,i){return e[t]=i,e},{});e.forEach(function(e){var t=e.path||e.name;void 0!==s[t]?i[s[t]]=e:n.push(e)}),i=i.filter(function(e){return e});var a,c=t.sortRemainingBy;return"hidden"===c?i:(a="alpha"===c?[["path","name"],["asc","asc"]]:[["count"],["desc"]],i.concat(x(n,a[0],a[1])))}function l(e,t){return e.renderingContent&&e.renderingContent.facetOrdering&&e.renderingContent.facetOrdering.values&&e.renderingContent.facetOrdering.values[t]}function m(e,t){var i=R(e,function(e){return e.name===t});return i&&i.stats}function d(e,t,i,n,r){var s=R(r,function(e){return e.name===i}),a=s&&s.data&&s.data[n]?s.data[n]:0,c=s&&s.exhaustive||!1;return{type:t,attributeName:i,name:n,count:a,exhaustive:c}}function p(e,t,i,n){var r=e.getHierarchicalFacetByName(t),s=e._getHierarchicalFacetSeparator(r),a=i.split(s),c=R(n,function(e){return e.name===t}),u=a.reduce(function(e,t){var i=e&&R(e.data,function(e){return e.name===t});return void 0!==i?i:e},c),o=u&&u.count||0,f=u&&u.exhaustive||!1,h=u&&u.path||"";return{type:"hierarchical",attributeName:t,name:h,count:o,exhaustive:f}}var v=e("../functions/compact"),g=e("../functions/defaultsPure"),y=e("../functions/escapeFacetValue"),R=e("../functions/find"),F=e("../functions/findIndex"),_=e("../functions/formatSort"),j=e("../functions/merge"),x=e("../functions/orderBy"),b=y.escapeFacetValue,P=y.unescapeFacetValue,E=e("./generate-hierarchical-tree");a.prototype.getFacetByName=function(e){function t(t){return t.name===e}return R(this.facets,t)||R(this.disjunctiveFacets,t)||R(this.hierarchicalFacets,t)},a.DEFAULT_SORT=["isRefined:desc","count:desc","name:asc"],a.prototype.getFacetValues=function(e,t){var i=c(this,e);if(i){var n,r=g({},t,{sortBy:a.DEFAULT_SORT,facetOrdering:!(t&&t.sortBy)}),s=this;if(Array.isArray(i))n=[e];else{n=s._state.getHierarchicalFacetByName(i.name).attributes}return o(function(e,t){if(r.facetOrdering){var i=l(s,t);if(i)return h(e,i)}if(Array.isArray(r.sortBy)){var n=_(r.sortBy,a.DEFAULT_SORT);return x(e,n[0],n[1])}if("function"==typeof r.sortBy)return f(r.sortBy,e);throw new Error("options.sortBy is optional but if defined it must be either an array of string (predicates) or a sorting function")},i,n)}},a.prototype.getFacetStats=function(e){return this._state.isConjunctiveFacet(e)?m(this.facets,e):this._state.isDisjunctiveFacet(e)?m(this.disjunctiveFacets,e):void 0},a.prototype.getRefinements=function(){var e=this._state,t=this,i=[];return Object.keys(e.facetsRefinements).forEach(function(n){e.facetsRefinements[n].forEach(function(r){i.push(d(e,"facet",n,r,t.facets))})}),Object.keys(e.facetsExcludes).forEach(function(n){e.facetsExcludes[n].forEach(function(r){i.push(d(e,"exclude",n,r,t.facets))})}),Object.keys(e.disjunctiveFacetsRefinements).forEach(function(n){ | ||
e.disjunctiveFacetsRefinements[n].forEach(function(r){i.push(d(e,"disjunctive",n,r,t.disjunctiveFacets))})}),Object.keys(e.hierarchicalFacetsRefinements).forEach(function(n){e.hierarchicalFacetsRefinements[n].forEach(function(r){i.push(p(e,n,r,t.hierarchicalFacets))})}),Object.keys(e.numericRefinements).forEach(function(t){var n=e.numericRefinements[t];Object.keys(n).forEach(function(e){n[e].forEach(function(n){i.push({type:"numeric",attributeName:t,name:n,numericValue:n,operator:e})})})}),e.tagRefinements.forEach(function(e){i.push({type:"tag",attributeName:"_tags",name:e})}),i},t.exports=a},{"../functions/compact":10,"../functions/defaultsPure":11,"../functions/escapeFacetValue":12,"../functions/find":13,"../functions/findIndex":14,"../functions/formatSort":15,"../functions/merge":18,"../functions/orderBy":21,"./generate-hierarchical-tree":7}],9:[function(e,t,i){"use strict";function n(e,t,i,n){"function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+g+")"),this.setClient(e);var r=i||{};r.index=t,this.state=p.make(r),this.recommendState=new m({params:r.recommendState}),this.lastResults=null,this._queryId=0,this._lastQueryIdReceived=-1,this.derivedHelpers=[],this._currentNbQueries=0,this._searchResultsOptions=n}function r(e){if(e<0)throw new Error("Page requested below 0.");return this._change({state:this.state.setPage(e),isPageReset:!1}),this}function s(){return this.state.page}var a=e("@algolia/events"),c=e("./DerivedHelper"),u=e("./functions/escapeFacetValue").escapeFacetValue,o=e("./functions/inherits"),f=e("./functions/merge"),h=e("./functions/objectHasKeys"),l=e("./functions/omit"),m=e("./RecommendParameters"),d=e("./requestBuilder"),p=e("./SearchParameters"),v=e("./SearchResults"),g=e("./version");o(n,a),n.prototype.search=function(){return this._search({onlyWithDerivedHelpers:!1}),this},n.prototype.searchOnlyWithDerivedHelpers=function(){return this._search({onlyWithDerivedHelpers:!0}),this},n.prototype.getQuery=function(){var e=this.state;return d._getHitsSearchParams(e)},n.prototype.searchOnce=function(e,t){var i=e?this.state.setQueryParameters(e):this.state,n=d._getQueries(i.index,i),r=this;return this._currentNbQueries++,this.emit("searchOnce",{state:i}),t?void this.client.search(n).then(function(e){r._currentNbQueries--,0===r._currentNbQueries&&r.emit("searchQueueEmpty"),t(null,new v(i,e.results),i)}).catch(function(e){r._currentNbQueries--,0===r._currentNbQueries&&r.emit("searchQueueEmpty"),t(e,null,i)}):this.client.search(n).then(function(e){return r._currentNbQueries--,0===r._currentNbQueries&&r.emit("searchQueueEmpty"),{content:new v(i,e.results),state:i,_originalResponse:e}},function(e){throw r._currentNbQueries--,0===r._currentNbQueries&&r.emit("searchQueueEmpty"),e})},n.prototype.findAnswers=function(e){console.warn("[algoliasearch-helper] answers is no longer supported");var t=this.state,i=this.derivedHelpers[0];if(!i)return Promise.resolve([]);var n=i.getModifiedState(t),r=f({attributesForPrediction:e.attributesForPrediction,nbHits:e.nbHits},{params:l(d._getHitsSearchParams(n),["attributesToSnippet","hitsPerPage","restrictSearchableAttributes","snippetEllipsisText"])}),s="search for answers was called, but this client does not have a function client.initIndex(index).findAnswers";if("function"!=typeof this.client.initIndex)throw new Error(s);var a=this.client.initIndex(n.index);if("function"!=typeof a.findAnswers)throw new Error(s);return a.findAnswers(n.query,e.queryLanguages,r)},n.prototype.searchForFacetValues=function(e,t,i,n){var r="function"==typeof this.client.searchForFacetValues,s="function"==typeof this.client.initIndex;if(!r&&!s&&"function"!=typeof this.client.search)throw new Error("search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues");var a=this.state.setQueryParameters(n||{}),c=a.isDisjunctiveFacet(e),o=d.getSearchForFacetQuery(e,t,i,a);this._currentNbQueries++;var f,h=this;return r?f=this.client.searchForFacetValues([{indexName:a.index,params:o}]):s?f=this.client.initIndex(a.index).searchForFacetValues(o):(delete o.facetName,f=this.client.search([{type:"facet",facet:e,indexName:a.index,params:o}]).then(function(e){return e.results[0]})),this.emit("searchForFacetValues",{state:a,facet:e,query:t}),f.then(function(t){return h._currentNbQueries--,0===h._currentNbQueries&&h.emit("searchQueueEmpty"),t=Array.isArray(t)?t[0]:t,t.facetHits.forEach(function(t){t.escapedValue=u(t.value),t.isRefined=c?a.isDisjunctiveFacetRefined(e,t.escapedValue):a.isFacetRefined(e,t.escapedValue)}),t},function(e){throw h._currentNbQueries--,0===h._currentNbQueries&&h.emit("searchQueueEmpty"),e})},n.prototype.setQuery=function(e){return this._change({state:this.state.resetPage().setQuery(e),isPageReset:!0}),this},n.prototype.clearRefinements=function(e){return this._change({state:this.state.resetPage().clearRefinements(e),isPageReset:!0}),this},n.prototype.clearTags=function(){return this._change({state:this.state.resetPage().clearTags(),isPageReset:!0}),this},n.prototype.addDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.addDisjunctiveRefine=function(){return this.addDisjunctiveFacetRefinement.apply(this,arguments)},n.prototype.addHierarchicalFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addHierarchicalFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.addNumericRefinement=function(e,t,i){return this._change({state:this.state.resetPage().addNumericRefinement(e,t,i),isPageReset:!0}),this},n.prototype.addFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.addRefine=function(){return this.addFacetRefinement.apply(this,arguments)},n.prototype.addFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().addExcludeRefinement(e,t),isPageReset:!0}),this},n.prototype.addExclude=function(){return this.addFacetExclusion.apply(this,arguments)},n.prototype.addTag=function(e){return this._change({state:this.state.resetPage().addTagRefinement(e),isPageReset:!0}),this},n.prototype.removeNumericRefinement=function(e,t,i){return this._change({state:this.state.resetPage().removeNumericRefinement(e,t,i),isPageReset:!0}),this},n.prototype.removeDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.removeDisjunctiveRefine=function(){return this.removeDisjunctiveFacetRefinement.apply(this,arguments)},n.prototype.removeHierarchicalFacetRefinement=function(e){return this._change({state:this.state.resetPage().removeHierarchicalFacetRefinement(e),isPageReset:!0}),this},n.prototype.removeFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.removeRefine=function(){return this.removeFacetRefinement.apply(this,arguments)},n.prototype.removeFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().removeExcludeRefinement(e,t),isPageReset:!0}),this},n.prototype.removeExclude=function(){return this.removeFacetExclusion.apply(this,arguments)},n.prototype.removeTag=function(e){return this._change({state:this.state.resetPage().removeTagRefinement(e),isPageReset:!0}),this},n.prototype.toggleFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().toggleExcludeFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.toggleExclude=function(){return this.toggleFacetExclusion.apply(this,arguments)},n.prototype.toggleRefinement=function(e,t){return this.toggleFacetRefinement(e,t)},n.prototype.toggleFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().toggleFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.toggleRefine=function(){return this.toggleFacetRefinement.apply(this,arguments)},n.prototype.toggleTag=function(e){return this._change({state:this.state.resetPage().toggleTagRefinement(e),isPageReset:!0}),this},n.prototype.nextPage=function(){var e=this.state.page||0;return this.setPage(e+1)},n.prototype.previousPage=function(){var e=this.state.page||0;return this.setPage(e-1)},n.prototype.setCurrentPage=r,n.prototype.setPage=r,n.prototype.setIndex=function(e){return this._change({state:this.state.resetPage().setIndex(e),isPageReset:!0}),this},n.prototype.setQueryParameter=function(e,t){return this._change({state:this.state.resetPage().setQueryParameter(e,t),isPageReset:!0}),this},n.prototype.setState=function(e){return this._change({state:p.make(e),isPageReset:!1}),this},n.prototype.overrideStateWithoutTriggeringChangeEvent=function(e){return this.state=new p(e),this},n.prototype.hasRefinements=function(e){return!!h(this.state.getNumericRefinements(e))||(this.state.isConjunctiveFacet(e)?this.state.isFacetRefined(e):this.state.isDisjunctiveFacet(e)?this.state.isDisjunctiveFacetRefined(e):!!this.state.isHierarchicalFacet(e)&&this.state.isHierarchicalFacetRefined(e))},n.prototype.isExcluded=function(e,t){return this.state.isExcludeRefined(e,t)},n.prototype.isDisjunctiveRefined=function(e,t){return this.state.isDisjunctiveFacetRefined(e,t)},n.prototype.hasTag=function(e){return this.state.isTagRefined(e)},n.prototype.isTagRefined=function(){return this.hasTagRefinements.apply(this,arguments)},n.prototype.getIndex=function(){return this.state.index},n.prototype.getCurrentPage=s,n.prototype.getPage=s,n.prototype.getTags=function(){return this.state.tagRefinements},n.prototype.getRefinements=function(e){var t=[];if(this.state.isConjunctiveFacet(e)){this.state.getConjunctiveRefinements(e).forEach(function(e){t.push({value:e,type:"conjunctive"})});this.state.getExcludeRefinements(e).forEach(function(e){t.push({value:e,type:"exclude"})})}else if(this.state.isDisjunctiveFacet(e)){var i=this.state.getDisjunctiveRefinements(e);i.forEach(function(e){t.push({value:e,type:"disjunctive"})})}var n=this.state.getNumericRefinements(e);return Object.keys(n).forEach(function(e){var i=n[e];t.push({value:i,operator:e,type:"numeric"})}),t},n.prototype.getNumericRefinement=function(e,t){return this.state.getNumericRefinement(e,t)},n.prototype.getHierarchicalFacetBreadcrumb=function(e){return this.state.getHierarchicalFacetBreadcrumb(e)},n.prototype._search=function(e){var t=this.state,i=[],n=[];e.onlyWithDerivedHelpers||(n=d._getQueries(t.index,t),i.push({state:t,queriesCount:n.length,helper:this}),this.emit("search",{state:t,results:this.lastResults}));var r=this.derivedHelpers.map(function(e){var n=e.getModifiedState(t),r=n.index?d._getQueries(n.index,n):[];return i.push({state:n,queriesCount:r.length,helper:e}),e.emit("search",{state:n,results:e.lastResults}),r}),s=Array.prototype.concat.apply(n,r),a=this._queryId++;if(this._currentNbQueries++,!s.length)return Promise.resolve({results:[]}).then(this._dispatchAlgoliaResponse.bind(this,i,a));try{this.client.search(s).then(this._dispatchAlgoliaResponse.bind(this,i,a)).catch(this._dispatchAlgoliaError.bind(this,a))}catch(e){this.emit("error",{error:e})}},n.prototype._dispatchAlgoliaResponse=function(e,t,i){var n=this;if(!(t<this._lastQueryIdReceived)){this._currentNbQueries-=t-this._lastQueryIdReceived,this._lastQueryIdReceived=t,0===this._currentNbQueries&&this.emit("searchQueueEmpty");var r=i.results.slice();e.forEach(function(e){var t=e.state,i=e.queriesCount,s=e.helper,a=r.splice(0,i);if(!t.index)return void s.emit("result",{results:null,state:t});s.lastResults=new v(t,a,n._searchResultsOptions),s.emit("result",{results:s.lastResults,state:t})})}},n.prototype._dispatchAlgoliaError=function(e,t){e<this._lastQueryIdReceived||(this._currentNbQueries-=e-this._lastQueryIdReceived,this._lastQueryIdReceived=e,this.emit("error",{error:t}),0===this._currentNbQueries&&this.emit("searchQueueEmpty"))},n.prototype.containsRefinement=function(e,t,i,n){return e||0!==t.length||0!==i.length||0!==n.length},n.prototype._hasDisjunctiveRefinements=function(e){return this.state.disjunctiveRefinements[e]&&this.state.disjunctiveRefinements[e].length>0},n.prototype._change=function(e){var t=e.state,i=e.isPageReset;t!==this.state&&(this.state=t,this.emit("change",{state:this.state,results:this.lastResults,isPageReset:i}))},n.prototype._recommendChange=function(e){var t=e.state;t!==this.recommendState&&(this.recommendState=t)},n.prototype.clearCache=function(){return this.client.clearCache&&this.client.clearCache(),this},n.prototype.setClient=function(e){return this.client===e?this:("function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+g+")"),this.client=e,this)},n.prototype.getClient=function(){return this.client},n.prototype.derive=function(e){var t=new c(this,e);return this.derivedHelpers.push(t),t},n.prototype.detachDerivedHelper=function(e){var t=this.derivedHelpers.indexOf(e);if(-1===t)throw new Error("Derived helper already detached");this.derivedHelpers.splice(t,1)},n.prototype.hasPendingRequests=function(){return this._currentNbQueries>0},t.exports=n},{"./DerivedHelper":3,"./RecommendParameters":4,"./SearchParameters":6,"./SearchResults":8,"./functions/escapeFacetValue":12,"./functions/inherits":16,"./functions/merge":18,"./functions/objectHasKeys":19,"./functions/omit":20,"./requestBuilder":23,"./version":25,"@algolia/events":1}],10:[function(e,t,i){"use strict";t.exports=function(e){return Array.isArray(e)?e.filter(Boolean):[]}},{}],11:[function(e,t,i){"use strict";t.exports=function(){return Array.prototype.slice.call(arguments).reduceRight(function(e,t){return Object.keys(Object(t)).forEach(function(i){void 0!==t[i]&&(void 0!==e[i]&&delete e[i],e[i]=t[i])}),e},{})}},{}],12:[function(e,t,i){"use strict";function n(e){return"string"!=typeof e?e:String(e).replace(/^-/,"\\-")}function r(e){return"string"!=typeof e?e:e.replace(/^\\-/,"-")}t.exports={escapeFacetValue:n,unescapeFacetValue:r}},{}],13:[function(e,t,i){"use strict";t.exports=function(e,t){if(Array.isArray(e))for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}},{}],14:[function(e,t,i){"use strict";t.exports=function(e,t){if(!Array.isArray(e))return-1;for(var i=0;i<e.length;i++)if(t(e[i]))return i;return-1}},{}],15:[function(e,t,i){"use strict";var n=e("./find");t.exports=function(e,t){var i=(t||[]).map(function(e){return e.split(":")});return e.reduce(function(e,t){var r=t.split(":"),s=n(i,function(e){return e[0]===r[0]});return r.length>1||!s?(e[0].push(r[0]),e[1].push(r[1]),e):(e[0].push(s[0]),e[1].push(s[1]),e)},[[],[]])}},{"./find":13}],16:[function(e,t,i){"use strict";function n(e,t){e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}t.exports=n},{}],17:[function(e,t,i){"use strict";function n(e,t){return e.filter(function(i,n){return t.indexOf(i)>-1&&e.indexOf(i)===n})}t.exports=n},{}],18:[function(e,t,i){"use strict";function n(e){return"object"==typeof e&&null!==e?s(Array.isArray(e)?[]:{},e):e}function r(e){return"function"==typeof e||Array.isArray(e)||"[object Object]"===Object.prototype.toString.call(e)}function s(e,t){if(e===t)return e;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&"__proto__"!==i&&"constructor"!==i){var a=t[i],c=e[i];void 0!==c&&void 0===a||(r(c)&&r(a)?e[i]=s(c,a):e[i]=n(a))}return e}function a(e){r(e)||(e={});for(var t=1,i=arguments.length;t<i;t++){var n=arguments[t];r(n)&&s(e,n)}return e}t.exports=a},{}],19:[function(e,t,i){"use strict";function n(e){return e&&Object.keys(e).length>0}t.exports=n},{}],20:[function(e,t,i){"use strict";function n(e,t){if(null===e)return{};var i,n,r={},s=Object.keys(e);for(n=0;n<s.length;n++)i=s[n],t.indexOf(i)>=0||(r[i]=e[i]);return r}t.exports=n},{}],21:[function(e,t,i){"use strict";function n(e,t){if(e!==t){var i=void 0!==e,n=null===e,r=void 0!==t,s=null===t;if(!s&&e>t||n&&r||!i)return 1;if(!n&&e<t||s&&i||!r)return-1}return 0}function r(e,t,i){if(!Array.isArray(e))return[];Array.isArray(i)||(i=[]);var r=e.map(function(e,i){return{criteria:t.map(function(t){return e[t]}),index:i,value:e}});return r.sort(function(e,t){for(var r=-1;++r<e.criteria.length;){var s=n(e.criteria[r],t.criteria[r]);if(s)return r>=i.length?s:"desc"===i[r]?-s:s}return e.index-t.index}),r.map(function(e){return e.value})}t.exports=r},{}],22:[function(e,t,i){"use strict";function n(e){if("number"==typeof e)return e;if("string"==typeof e)return parseFloat(e);if(Array.isArray(e))return e.map(n);throw new Error("The value should be a number, a parsable string or an array of those.")}t.exports=n},{}],23:[function(e,t,i){"use strict";function n(e){return Object.keys(e).sort().reduce(function(t,i){return t[i]=e[i],t},{})}var r=e("./functions/merge"),s={_getQueries:function(e,t){var i=[];return i.push({indexName:e,params:s._getHitsSearchParams(t)}),t.getRefinedDisjunctiveFacets().forEach(function(n){i.push({indexName:e,params:s._getDisjunctiveFacetSearchParams(t,n)})}),t.getRefinedHierarchicalFacets().forEach(function(n){var r=t.getHierarchicalFacetByName(n),a=t.getHierarchicalRefinement(n),c=t._getHierarchicalFacetSeparator(r);if(a.length>0&&a[0].split(c).length>1){var u=a[0].split(c).slice(0,-1).reduce(function(e,t,i){return e.concat({attribute:r.attributes[i],value:0===i?t:[e[e.length-1].value,t].join(c)})},[]);u.forEach(function(n,a){function c(e){return r.attributes.some(function(t){return t===e.split(":")[0]})}var o=s._getDisjunctiveFacetSearchParams(t,n.attribute,0===a),f=(o.facetFilters||[]).reduce(function(e,t){if(Array.isArray(t)){var i=t.filter(function(e){return!c(e)});i.length>0&&e.push(i)}return"string"!=typeof t||c(t)||e.push(t),e},[]),h=u[a-1];o.facetFilters=a>0?f.concat(h.attribute+":"+h.value):f.length>0?f:void 0,i.push({indexName:e,params:o})})}}),i},_getHitsSearchParams:function(e){var t=e.facets.concat(e.disjunctiveFacets).concat(s._getHitsHierarchicalFacetsAttributes(e)).sort(),i=s._getFacetFilters(e),a=s._getNumericFilters(e),c=s._getTagFilters(e),u={facets:t.indexOf("*")>-1?["*"]:t,tagFilters:c};return i.length>0&&(u.facetFilters=i),a.length>0&&(u.numericFilters=a),n(r({},e.getQueryParams(),u))},_getDisjunctiveFacetSearchParams:function(e,t,i){var a=s._getFacetFilters(e,t,i),c=s._getNumericFilters(e,t),u=s._getTagFilters(e),o={hitsPerPage:0,page:0,analytics:!1,clickAnalytics:!1};u.length>0&&(o.tagFilters=u);var f=e.getHierarchicalFacetByName(t);return o.facets=f?s._getDisjunctiveHierarchicalFacetAttribute(e,f,i):t,c.length>0&&(o.numericFilters=c),a.length>0&&(o.facetFilters=a),n(r({},e.getQueryParams(),o))},_getNumericFilters:function(e,t){if(e.numericFilters)return e.numericFilters;var i=[];return Object.keys(e.numericRefinements).forEach(function(n){var r=e.numericRefinements[n]||{};Object.keys(r).forEach(function(e){var s=r[e]||[];t!==n&&s.forEach(function(t){if(Array.isArray(t)){var r=t.map(function(t){return n+e+t});i.push(r)}else i.push(n+e+t)})})}),i},_getTagFilters:function(e){return e.tagFilters?e.tagFilters:e.tagRefinements.join(",")},_getFacetFilters:function(e,t,i){var n=[],r=e.facetsRefinements||{};Object.keys(r).sort().forEach(function(e){(r[e]||[]).slice().sort().forEach(function(t){n.push(e+":"+t)})});var s=e.facetsExcludes||{};Object.keys(s).sort().forEach(function(e){(s[e]||[]).sort().forEach(function(t){n.push(e+":-"+t)})});var a=e.disjunctiveFacetsRefinements||{};Object.keys(a).sort().forEach(function(e){var i=a[e]||[];if(e!==t&&i&&0!==i.length){var r=[];i.slice().sort().forEach(function(t){r.push(e+":"+t)}),n.push(r)}});var c=e.hierarchicalFacetsRefinements||{};return Object.keys(c).sort().forEach(function(r){var s=c[r]||[],a=s[0];if(void 0!==a){var u,o,f=e.getHierarchicalFacetByName(r),h=e._getHierarchicalFacetSeparator(f),l=e._getHierarchicalRootPath(f);if(t===r){if(-1===a.indexOf(h)||!l&&!0===i||l&&l.split(h).length===a.split(h).length)return;l?(o=l.split(h).length-1,a=l):(o=a.split(h).length-2,a=a.slice(0,a.lastIndexOf(h))),u=f.attributes[o]}else o=a.split(h).length-1,u=f.attributes[o];u&&n.push([u+":"+a])}}),n},_getHitsHierarchicalFacetsAttributes:function(e){var t=[];return e.hierarchicalFacets.reduce(function(t,i){var n=e.getHierarchicalRefinement(i.name)[0];if(!n)return t.push(i.attributes[0]),t;var r=e._getHierarchicalFacetSeparator(i),s=n.split(r).length,a=i.attributes.slice(0,s+1);return t.concat(a)},t)},_getDisjunctiveHierarchicalFacetAttribute:function(e,t,i){var n=e._getHierarchicalFacetSeparator(t);if(!0===i){var r=e._getHierarchicalRootPath(t),s=0;return r&&(s=r.split(n).length),[t.attributes[s]]}var a=e.getHierarchicalRefinement(t.name)[0]||"",c=a.split(n).length-1;return t.attributes.slice(0,c+1)},getSearchForFacetQuery:function(e,t,i,a){var c=a.isDisjunctiveFacet(e)?a.clearRefinements(e):a,u={facetQuery:t,facetName:e};return"number"==typeof i&&(u.maxFacetHits=i),n(r({},s._getHitsSearchParams(c),u))}};t.exports=s},{"./functions/merge":18}],24:[function(e,t,i){"use strict";t.exports=function(e){return null!==e&&/^[a-zA-Z0-9_-]{1,64}$/.test(e)}},{}],25:[function(e,t,i){"use strict";t.exports="3.17.0"},{}]},{},[2])(2)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.algoliasearchHelper=e()}}(function(){return function(){function e(t,i,n){function r(a,c){if(!i[a]){if(!t[a]){var u="function"==typeof require&&require;if(!c&&u)return u(a,!0);if(s)return s(a,!0);var o=new Error("Cannot find module '"+a+"'");throw o.code="MODULE_NOT_FOUND",o}var h=i[a]={exports:{}};t[a][0].call(h.exports,function(e){return r(t[a][1][e]||e)},h,h.exports,e,t,i,n)}return i[a].exports}for(var s="function"==typeof require&&require,a=0;a<n.length;a++)r(n[a]);return r}return e}()({1:[function(e,t,i){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function s(e){return"number"==typeof e}function a(e){return"object"==typeof e&&null!==e}function c(e){return void 0===e}t.exports=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!s(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,i,n,s,u,o;if(this._events||(this._events={}),"error"===e&&(!this._events.error||a(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var h=new Error('Uncaught, unspecified "error" event. ('+t+")");throw h.context=t,h}if(i=this._events[e],c(i))return!1;if(r(i))switch(arguments.length){case 1:i.call(this);break;case 2:i.call(this,arguments[1]);break;case 3:i.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),i.apply(this,s)}else if(a(i))for(s=Array.prototype.slice.call(arguments,1),o=i.slice(),n=o.length,u=0;u<n;u++)o[u].apply(this,s);return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?a(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,a(this._events[e])&&!this._events[e].warned&&(i=c(this._maxListeners)?n.defaultMaxListeners:this._maxListeners)&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function i(){this.removeListener(e,i),n||(n=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var n=!1;return i.listener=t,this.on(e,i),this},n.prototype.removeListener=function(e,t){var i,n,s,c;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(i=this._events[e],s=i.length,n=-1,i===t||r(i.listener)&&i.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(a(i)){for(c=s;c-- >0;)if(i[c]===t||i[c].listener&&i[c].listener===t){n=c;break}if(n<0)return this;1===i.length?(i.length=0,delete this._events[e]):i.splice(n,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(i=this._events[e],r(i))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){return this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(r(t))return 1;if(t)return t.length}return 0},n.listenerCount=function(e,t){return e.listenerCount(t)}},{}],2:[function(e,t,i){"use strict";function n(e,t,i,n){return new r(e,t,i,n)}var r=e("./src/algoliasearch.helper"),s=e("./src/RecommendParameters"),a=e("./src/SearchParameters"),c=e("./src/SearchResults");n.version=e("./src/version"),n.AlgoliaSearchHelper=r,n.SearchParameters=a,n.RecommendParameters=s,n.SearchResults=c,t.exports=n},{"./src/RecommendParameters":4,"./src/SearchParameters":6,"./src/SearchResults":8,"./src/algoliasearch.helper":9,"./src/version":25}],3:[function(e,t,i){"use strict";function n(e,t,i){this.main=e,this.fn=t,this.recommendFn=i,this.lastResults=null,this.lastRecommendResults=null}var r=e("@algolia/events");e("../functions/inherits")(n,r),n.prototype.detach=function(){this.removeAllListeners(),this.main.detachDerivedHelper(this)},n.prototype.getModifiedState=function(e){return this.fn(e)},n.prototype.getModifiedRecommendState=function(e){return this.recommendFn(e)},t.exports=n},{"../functions/inherits":16,"@algolia/events":1}],4:[function(e,t,i){"use strict";function n(e){e=e||{},this.params=e.params||[]}n.prototype={constructor:n,addParams:function(e){var t=this.params.slice(),i=this.params.findIndex(function(t){return t.$$id===e.$$id});return-1!==i?t.splice(i,1,e):t.push(e),new n({params:t})},removeParams:function(e){return new n({params:this.params.filter(function(t){return t.$$id!==e})})},addFrequentlyBoughtTogether:function(e){return this.addParams(Object.assign({},e,{model:"bought-together"}))},addRelatedProducts:function(e){return this.addParams(Object.assign({},e,{model:"related-products"}))},addTrendingItems:function(e){return this.addParams(Object.assign({},e,{model:"trending-items"}))},addTrendingFacets:function(e){return this.addParams(Object.assign({},e,{model:"trending-facets"}))},addLookingSimilar:function(e){return this.addParams(Object.assign({},e,{model:"looking-similar"}))},_buildQueries:function(e){return this.params.map(function(t){var i=Object.assign({},t,{indexName:e});return delete i.$$id,i})}},t.exports=n},{}],5:[function(e,t,i){"use strict";var n=e("../functions/defaultsPure"),r=e("../functions/objectHasKeys"),s=e("../functions/omit"),a={addRefinement:function(e,t,i){if(a.isRefined(e,t,i))return e;var r=""+i,s=e[t]?e[t].concat(r):[r],c={};return c[t]=s,n({},c,e)},removeRefinement:function(e,t,i){if(void 0===i)return a.clearRefinement(e,function(e,i){return t===i});var n=""+i;return a.clearRefinement(e,function(e,i){return t===i&&n===e})},toggleRefinement:function(e,t,i){if(void 0===i)throw new Error("toggleRefinement should be used with a value");return a.isRefined(e,t,i)?a.removeRefinement(e,t,i):a.addRefinement(e,t,i)},clearRefinement:function(e,t,i){if(void 0===t)return r(e)?{}:e;if("string"==typeof t)return s(e,[t]);if("function"==typeof t){var n=!1,a=Object.keys(e).reduce(function(r,s){var a=e[s]||[],c=a.filter(function(e){return!t(e,s,i)});return c.length!==a.length&&(n=!0),r[s]=c,r},{});return n?a:e}},isRefined:function(e,t,i){var n=Boolean(e[t])&&e[t].length>0;if(void 0===i||!n)return n;var r=""+i;return-1!==e[t].indexOf(r)}};t.exports=a},{"../functions/defaultsPure":11,"../functions/objectHasKeys":19,"../functions/omit":20}],6:[function(e,t,i){"use strict";function n(e,t){return Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every(function(e,i){return n(t[i],e)}):e===t}function r(e,t){return c(e,function(e){return n(e,t)})}function s(e){var t=e?s._parseNumbers(e):{};void 0===t.userToken||m(t.userToken)||console.warn("[algoliasearch-helper] The `userToken` parameter is invalid. This can lead to wrong analytics.\n - Format: [a-zA-Z0-9_-]{1,64}"),this.facets=t.facets||[],this.disjunctiveFacets=t.disjunctiveFacets||[],this.hierarchicalFacets=t.hierarchicalFacets||[],this.facetsRefinements=t.facetsRefinements||{},this.facetsExcludes=t.facetsExcludes||{},this.disjunctiveFacetsRefinements=t.disjunctiveFacetsRefinements||{},this.numericRefinements=t.numericRefinements||{},this.tagRefinements=t.tagRefinements||[],this.hierarchicalFacetsRefinements=t.hierarchicalFacetsRefinements||{};var i=this;Object.keys(t).forEach(function(e){var n=-1!==s.PARAMETERS.indexOf(e),r=void 0!==t[e];!n&&r&&(i[e]=t[e])})}var a=e("../functions/defaultsPure"),c=e("../functions/find"),u=e("../functions/intersection"),o=e("../functions/merge"),h=e("../functions/objectHasKeys"),f=e("../functions/omit"),l=e("../functions/valToNumber"),m=e("../utils/isValidUserToken"),d=e("./RefinementList");s.PARAMETERS=Object.keys(new s),s._parseNumbers=function(e){if(e instanceof s)return e;var t={};if(["aroundPrecision","aroundRadius","getRankingInfo","minWordSizefor2Typos","minWordSizefor1Typo","page","maxValuesPerFacet","distinct","minimumAroundRadius","hitsPerPage","minProximity"].forEach(function(i){var n=e[i];if("string"==typeof n){var r=parseFloat(n);t[i]=isNaN(r)?n:r}}),Array.isArray(e.insideBoundingBox)&&(t.insideBoundingBox=e.insideBoundingBox.map(function(e){return Array.isArray(e)?e.map(function(e){return parseFloat(e)}):e})),e.numericRefinements){var i={};Object.keys(e.numericRefinements).forEach(function(t){var n=e.numericRefinements[t]||{};i[t]={},Object.keys(n).forEach(function(e){var r=n[e],s=r.map(function(e){return Array.isArray(e)?e.map(function(e){return"string"==typeof e?parseFloat(e):e}):"string"==typeof e?parseFloat(e):e});i[t][e]=s})}),t.numericRefinements=i}return o(e,t)},s.make=function(e){var t=new s(e);return(e.hierarchicalFacets||[]).forEach(function(e){if(e.rootPath){var i=t.getHierarchicalRefinement(e.name);i.length>0&&0!==i[0].indexOf(e.rootPath)&&(t=t.clearRefinements(e.name)),i=t.getHierarchicalRefinement(e.name),0===i.length&&(t=t.toggleHierarchicalFacetRefinement(e.name,e.rootPath))}}),t},s.validate=function(e,t){var i=t||{};return e.tagFilters&&i.tagRefinements&&i.tagRefinements.length>0?new Error("[Tags] Cannot switch from the managed tag API to the advanced API. It is probably an error, if it is really what you want, you should first clear the tags with clearTags method."):e.tagRefinements.length>0&&i.tagFilters?new Error("[Tags] Cannot switch from the advanced tag API to the managed API. It is probably an error, if it is not, you should first clear the tags with clearTags method."):e.numericFilters&&i.numericRefinements&&h(i.numericRefinements)?new Error("[Numeric filters] Can't switch from the advanced to the managed API. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):h(e.numericRefinements)&&i.numericFilters?new Error("[Numeric filters] Can't switch from the managed API to the advanced. It is probably an error, if this is really what you want, you have to first clear the numeric filters."):null},s.prototype={constructor:s,clearRefinements:function(e){var t={numericRefinements:this._clearNumericRefinements(e),facetsRefinements:d.clearRefinement(this.facetsRefinements,e,"conjunctiveFacet"),facetsExcludes:d.clearRefinement(this.facetsExcludes,e,"exclude"),disjunctiveFacetsRefinements:d.clearRefinement(this.disjunctiveFacetsRefinements,e,"disjunctiveFacet"),hierarchicalFacetsRefinements:d.clearRefinement(this.hierarchicalFacetsRefinements,e,"hierarchicalFacet")};return t.numericRefinements===this.numericRefinements&&t.facetsRefinements===this.facetsRefinements&&t.facetsExcludes===this.facetsExcludes&&t.disjunctiveFacetsRefinements===this.disjunctiveFacetsRefinements&&t.hierarchicalFacetsRefinements===this.hierarchicalFacetsRefinements?this:this.setQueryParameters(t)},clearTags:function(){return void 0===this.tagFilters&&0===this.tagRefinements.length?this:this.setQueryParameters({tagFilters:void 0,tagRefinements:[]})},setIndex:function(e){return e===this.index?this:this.setQueryParameters({index:e})},setQuery:function(e){return e===this.query?this:this.setQueryParameters({query:e})},setPage:function(e){return e===this.page?this:this.setQueryParameters({page:e})},setFacets:function(e){return this.setQueryParameters({facets:e})},setDisjunctiveFacets:function(e){return this.setQueryParameters({disjunctiveFacets:e})},setHitsPerPage:function(e){return this.hitsPerPage===e?this:this.setQueryParameters({hitsPerPage:e})},setTypoTolerance:function(e){return this.typoTolerance===e?this:this.setQueryParameters({typoTolerance:e})},addNumericRefinement:function(e,t,i){var n=l(i);if(this.isNumericRefined(e,t,n))return this;var r=o({},this.numericRefinements);return r[e]=o({},r[e]),r[e][t]?(r[e][t]=r[e][t].slice(),r[e][t].push(n)):r[e][t]=[n],this.setQueryParameters({numericRefinements:r})},getConjunctiveRefinements:function(e){return this.isConjunctiveFacet(e)?this.facetsRefinements[e]||[]:[]},getDisjunctiveRefinements:function(e){return this.isDisjunctiveFacet(e)?this.disjunctiveFacetsRefinements[e]||[]:[]},getHierarchicalRefinement:function(e){return this.hierarchicalFacetsRefinements[e]||[]},getExcludeRefinements:function(e){return this.isConjunctiveFacet(e)?this.facetsExcludes[e]||[]:[]},removeNumericRefinement:function(e,t,i){var r=i;return void 0!==r?this.isNumericRefined(e,t,r)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements(function(i,s){return s===e&&i.op===t&&n(i.val,l(r))})}):this:void 0!==t?this.isNumericRefined(e,t)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements(function(i,n){return n===e&&i.op===t})}):this:this.isNumericRefined(e)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements(function(t,i){return i===e})}):this},getNumericRefinements:function(e){return this.numericRefinements[e]||{}},getNumericRefinement:function(e,t){return this.numericRefinements[e]&&this.numericRefinements[e][t]},_clearNumericRefinements:function(e){if(void 0===e)return h(this.numericRefinements)?{}:this.numericRefinements;if("string"==typeof e)return f(this.numericRefinements,[e]);if("function"==typeof e){var t=!1,i=this.numericRefinements,n=Object.keys(i).reduce(function(n,r){var s=i[r],a={};return s=s||{},Object.keys(s).forEach(function(i){var n=s[i]||[],c=[];n.forEach(function(t){e({val:t,op:i},r,"numeric")||c.push(t)}),c.length!==n.length&&(t=!0),a[i]=c}),n[r]=a,n},{});return t?n:this.numericRefinements}},addFacet:function(e){return this.isConjunctiveFacet(e)?this:this.setQueryParameters({facets:this.facets.concat([e])})},addDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this:this.setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.concat([e])})},addHierarchicalFacet:function(e){if(this.isHierarchicalFacet(e.name))throw new Error("Cannot declare two hierarchical facets with the same name: `"+e.name+"`");return this.setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.concat([e])})},addFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return d.isRefined(this.facetsRefinements,e,t)?this:this.setQueryParameters({facetsRefinements:d.addRefinement(this.facetsRefinements,e,t)})},addExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return d.isRefined(this.facetsExcludes,e,t)?this:this.setQueryParameters({facetsExcludes:d.addRefinement(this.facetsExcludes,e,t)})},addDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return d.isRefined(this.disjunctiveFacetsRefinements,e,t)?this:this.setQueryParameters({disjunctiveFacetsRefinements:d.addRefinement(this.disjunctiveFacetsRefinements,e,t)})},addTagRefinement:function(e){if(this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.concat(e)};return this.setQueryParameters(t)},removeFacet:function(e){return this.isConjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({facets:this.facets.filter(function(t){return t!==e})}):this},removeDisjunctiveFacet:function(e){return this.isDisjunctiveFacet(e)?this.clearRefinements(e).setQueryParameters({disjunctiveFacets:this.disjunctiveFacets.filter(function(t){return t!==e})}):this},removeHierarchicalFacet:function(e){return this.isHierarchicalFacet(e)?this.clearRefinements(e).setQueryParameters({hierarchicalFacets:this.hierarchicalFacets.filter(function(t){return t.name!==e})}):this},removeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return d.isRefined(this.facetsRefinements,e,t)?this.setQueryParameters({facetsRefinements:d.removeRefinement(this.facetsRefinements,e,t)}):this},removeExcludeRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return d.isRefined(this.facetsExcludes,e,t)?this.setQueryParameters({facetsExcludes:d.removeRefinement(this.facetsExcludes,e,t)}):this},removeDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return d.isRefined(this.disjunctiveFacetsRefinements,e,t)?this.setQueryParameters({disjunctiveFacetsRefinements:d.removeRefinement(this.disjunctiveFacetsRefinements,e,t)}):this},removeTagRefinement:function(e){if(!this.isTagRefined(e))return this;var t={tagRefinements:this.tagRefinements.filter(function(t){return t!==e})};return this.setQueryParameters(t)},toggleRefinement:function(e,t){return this.toggleFacetRefinement(e,t)},toggleFacetRefinement:function(e,t){if(this.isHierarchicalFacet(e))return this.toggleHierarchicalFacetRefinement(e,t);if(this.isConjunctiveFacet(e))return this.toggleConjunctiveFacetRefinement(e,t);if(this.isDisjunctiveFacet(e))return this.toggleDisjunctiveFacetRefinement(e,t);throw new Error("Cannot refine the undeclared facet "+e+"; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets")},toggleConjunctiveFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsRefinements:d.toggleRefinement(this.facetsRefinements,e,t)})},toggleExcludeFacetRefinement:function(e,t){if(!this.isConjunctiveFacet(e))throw new Error(e+" is not defined in the facets attribute of the helper configuration");return this.setQueryParameters({facetsExcludes:d.toggleRefinement(this.facetsExcludes,e,t)})},toggleDisjunctiveFacetRefinement:function(e,t){if(!this.isDisjunctiveFacet(e))throw new Error(e+" is not defined in the disjunctiveFacets attribute of the helper configuration");return this.setQueryParameters({disjunctiveFacetsRefinements:d.toggleRefinement(this.disjunctiveFacetsRefinements,e,t)})},toggleHierarchicalFacetRefinement:function(e,t){if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration");var i=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e)),n={};return void 0!==this.hierarchicalFacetsRefinements[e]&&this.hierarchicalFacetsRefinements[e].length>0&&(this.hierarchicalFacetsRefinements[e][0]===t||0===this.hierarchicalFacetsRefinements[e][0].indexOf(t+i))?-1===t.indexOf(i)?n[e]=[]:n[e]=[t.slice(0,t.lastIndexOf(i))]:n[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:a({},n,this.hierarchicalFacetsRefinements)})},addHierarchicalFacetRefinement:function(e,t){if(this.isHierarchicalFacetRefined(e))throw new Error(e+" is already refined.");if(!this.isHierarchicalFacet(e))throw new Error(e+" is not defined in the hierarchicalFacets attribute of the helper configuration.");var i={};return i[e]=[t],this.setQueryParameters({hierarchicalFacetsRefinements:a({},i,this.hierarchicalFacetsRefinements)})},removeHierarchicalFacetRefinement:function(e){if(!this.isHierarchicalFacetRefined(e))return this;var t={};return t[e]=[],this.setQueryParameters({hierarchicalFacetsRefinements:a({},t,this.hierarchicalFacetsRefinements)})},toggleTagRefinement:function(e){return this.isTagRefined(e)?this.removeTagRefinement(e):this.addTagRefinement(e)},isDisjunctiveFacet:function(e){return this.disjunctiveFacets.indexOf(e)>-1},isHierarchicalFacet:function(e){return void 0!==this.getHierarchicalFacetByName(e)},isConjunctiveFacet:function(e){return this.facets.indexOf(e)>-1},isFacetRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&d.isRefined(this.facetsRefinements,e,t)},isExcludeRefined:function(e,t){return!!this.isConjunctiveFacet(e)&&d.isRefined(this.facetsExcludes,e,t)},isDisjunctiveFacetRefined:function(e,t){return!!this.isDisjunctiveFacet(e)&&d.isRefined(this.disjunctiveFacetsRefinements,e,t)},isHierarchicalFacetRefined:function(e,t){if(!this.isHierarchicalFacet(e))return!1;var i=this.getHierarchicalRefinement(e);return t?-1!==i.indexOf(t):i.length>0},isNumericRefined:function(e,t,i){if(void 0===i&&void 0===t)return Boolean(this.numericRefinements[e]);var n=this.numericRefinements[e]&&void 0!==this.numericRefinements[e][t];if(void 0===i||!n)return n;var s=l(i),a=void 0!==r(this.numericRefinements[e][t],s);return n&&a},isTagRefined:function(e){return-1!==this.tagRefinements.indexOf(e)},getRefinedDisjunctiveFacets:function(){var e=this,t=u(Object.keys(this.numericRefinements).filter(function(t){return Object.keys(e.numericRefinements[t]).length>0}),this.disjunctiveFacets);return Object.keys(this.disjunctiveFacetsRefinements).filter(function(t){return e.disjunctiveFacetsRefinements[t].length>0}).concat(t).concat(this.getRefinedHierarchicalFacets()).sort()},getRefinedHierarchicalFacets:function(){var e=this;return u(this.hierarchicalFacets.map(function(e){return e.name}),Object.keys(this.hierarchicalFacetsRefinements).filter(function(t){return e.hierarchicalFacetsRefinements[t].length>0})).sort()},getUnrefinedDisjunctiveFacets:function(){var e=this.getRefinedDisjunctiveFacets();return this.disjunctiveFacets.filter(function(t){return-1===e.indexOf(t)})},managedParameters:["index","facets","disjunctiveFacets","facetsRefinements","hierarchicalFacets","facetsExcludes","disjunctiveFacetsRefinements","numericRefinements","tagRefinements","hierarchicalFacetsRefinements"],getQueryParams:function(){var e=this.managedParameters,t={},i=this;return Object.keys(this).forEach(function(n){var r=i[n];-1===e.indexOf(n)&&void 0!==r&&(t[n]=r)}),t},setQueryParameter:function(e,t){if(this[e]===t)return this;var i={};return i[e]=t,this.setQueryParameters(i)},setQueryParameters:function(e){if(!e)return this;var t=s.validate(this,e);if(t)throw t;var i=this,n=s._parseNumbers(e),r=Object.keys(this).reduce(function(e,t){return e[t]=i[t],e},{}),a=Object.keys(n).reduce(function(e,t){var i=void 0!==e[t],r=void 0!==n[t];return i&&!r?f(e,[t]):(r&&(e[t]=n[t]),e)},r);return new this.constructor(a)},resetPage:function(){return void 0===this.page?this:this.setPage(0)},_getHierarchicalFacetSortBy:function(e){return e.sortBy||["isRefined:desc","name:asc"]},_getHierarchicalFacetSeparator:function(e){return e.separator||" > "},_getHierarchicalRootPath:function(e){return e.rootPath||null},_getHierarchicalShowParentLevel:function(e){return"boolean"!=typeof e.showParentLevel||e.showParentLevel},getHierarchicalFacetByName:function(e){return c(this.hierarchicalFacets,function(t){return t.name===e})},getHierarchicalFacetBreadcrumb:function(e){if(!this.isHierarchicalFacet(e))return[];var t=this.getHierarchicalRefinement(e)[0];if(!t)return[];var i=this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(e));return t.split(i).map(function(e){return e.trim()})},toString:function(){return JSON.stringify(this,null,2)}},t.exports=s},{"../functions/defaultsPure":11,"../functions/find":13,"../functions/intersection":17,"../functions/merge":18,"../functions/objectHasKeys":19,"../functions/omit":20,"../functions/valToNumber":22,"../utils/isValidUserToken":24,"./RefinementList":5}],7:[function(e,t,i){"use strict";function n(e){return function(t,i){var n=e.hierarchicalFacets[i],s=e.hierarchicalFacetsRefinements[n.name]&&e.hierarchicalFacetsRefinements[n.name][0]||"",a=e._getHierarchicalFacetSeparator(n),c=e._getHierarchicalRootPath(n),u=e._getHierarchicalShowParentLevel(n),h=o(e._getHierarchicalFacetSortBy(n)),f=t.every(function(e){return e.exhaustive}),l=r(h,a,c,u,s),m=t;return c&&(m=t.slice(c.split(a).length)),m.reduce(l,{name:e.hierarchicalFacets[i].name,count:null,isRefined:!0,path:null,escapedValue:null,exhaustive:f,data:null})}}function r(e,t,i,n,r){return function(c,o,f){var m=c;if(f>0){var d=0;for(m=c;d<f;){var p=m&&Array.isArray(m.data)?m.data:[];m=u(p,function(e){return e.isRefined}),d++}}if(m){var v=Object.keys(o.data).map(function(e){return[e,o.data[e]]}).filter(function(e){return s(e[0],m.path||i,r,t,i,n)});m.data=h(v.map(function(e){var i=e[0];return a(e[1],i,t,l(r),o.exhaustive)}),e[0],e[1])}return c}}function s(e,t,i,n,r,s){return(!r||0===e.indexOf(r)&&r!==e)&&(!r&&-1===e.indexOf(n)||r&&e.split(n).length-r.split(n).length==1||-1===e.indexOf(n)&&-1===i.indexOf(n)||0===i.indexOf(e)||0===e.indexOf(t+n)&&(s||0===e.indexOf(i)))}function a(e,t,i,n,r){var s=t.split(i);return{name:s[s.length-1].trim(),path:t,escapedValue:f(t),count:e,isRefined:n===t||0===n.indexOf(t+i),exhaustive:r,data:null}}t.exports=n;var c=e("../functions/escapeFacetValue"),u=e("../functions/find"),o=e("../functions/formatSort"),h=e("../functions/orderBy"),f=c.escapeFacetValue,l=c.unescapeFacetValue},{"../functions/escapeFacetValue":12,"../functions/find":13,"../functions/formatSort":15,"../functions/orderBy":21}],8:[function(e,t,i){"use strict";function n(e){var t={};return e.forEach(function(e,i){t[e]=i}),t}function r(e,t,i){t&&t[i]&&(e.stats=t[i])}function s(e,t){return y(e,function(e){return(e.attributes||[]).indexOf(t)>-1})}function a(e,t,i){var a=t[0];this._rawResults=t;var c=this;Object.keys(a).forEach(function(e){c[e]=a[e]});var u=j({persistHierarchicalRootCount:!1},i);Object.keys(u).forEach(function(e){c[e]=u[e]}),this.processingTimeMS=t.reduce(function(e,t){return void 0===t.processingTimeMS?e:e+t.processingTimeMS},0),this.disjunctiveFacets=[],this.hierarchicalFacets=e.hierarchicalFacets.map(function(){return[]}),this.facets=[];var o=e.getRefinedDisjunctiveFacets(),h=n(e.facets),f=n(e.disjunctiveFacets),l=1,m=a.facets||{};Object.keys(m).forEach(function(t){var i=m[t],n=s(e.hierarchicalFacets,t);if(n){var u=n.attributes.indexOf(t),o=F(e.hierarchicalFacets,function(e){return e.name===n.name});c.hierarchicalFacets[o][u]={attribute:t,data:i,exhaustive:a.exhaustiveFacetsCount}}else{var l,d=-1!==e.disjunctiveFacets.indexOf(t),p=-1!==e.facets.indexOf(t);d&&(l=f[t],c.disjunctiveFacets[l]={name:t,data:i,exhaustive:a.exhaustiveFacetsCount},r(c.disjunctiveFacets[l],a.facets_stats,t)),p&&(l=h[t],c.facets[l]={name:t,data:i,exhaustive:a.exhaustiveFacetsCount},r(c.facets[l],a.facets_stats,t))}}),this.hierarchicalFacets=v(this.hierarchicalFacets),o.forEach(function(i){var n=t[l],s=n&&n.facets?n.facets:{},u=e.getHierarchicalFacetByName(i);Object.keys(s).forEach(function(t){var i,o=s[t];if(u){i=F(e.hierarchicalFacets,function(e){return e.name===u.name});var h=F(c.hierarchicalFacets[i],function(e){return e.attribute===t});if(-1===h)return;c.hierarchicalFacets[i][h].data=j({},c.hierarchicalFacets[i][h].data,o)}else{i=f[t];var l=a.facets&&a.facets[t]||{};c.disjunctiveFacets[i]={name:t,data:g({},o,l),exhaustive:n.exhaustiveFacetsCount},r(c.disjunctiveFacets[i],n.facets_stats,t),e.disjunctiveFacetsRefinements[t]&&e.disjunctiveFacetsRefinements[t].forEach(function(n){!c.disjunctiveFacets[i].data[n]&&e.disjunctiveFacetsRefinements[t].indexOf(P(n))>-1&&(c.disjunctiveFacets[i].data[n]=0)})}}),l++}),e.getRefinedHierarchicalFacets().forEach(function(i){var n=e.getHierarchicalFacetByName(i),r=e._getHierarchicalFacetSeparator(n),s=e.getHierarchicalRefinement(i);0===s.length||s[0].split(r).length<2||t.slice(l).forEach(function(t){var i=t&&t.facets?t.facets:{};Object.keys(i).forEach(function(t){var a=i[t],u=F(e.hierarchicalFacets,function(e){return e.name===n.name}),o=F(c.hierarchicalFacets[u],function(e){return e.attribute===t});if(-1!==o){var h={};if(s.length>0&&!c.persistHierarchicalRootCount){var f=s[0].split(r)[0];h[f]=c.hierarchicalFacets[u][o].data[f]}c.hierarchicalFacets[u][o].data=g(h,a,c.hierarchicalFacets[u][o].data)}}),l++})}),Object.keys(e.facetsExcludes).forEach(function(t){var i=e.facetsExcludes[t],n=h[t];c.facets[n]={name:t,data:m[t],exhaustive:a.exhaustiveFacetsCount},i.forEach(function(e){c.facets[n]=c.facets[n]||{name:t},c.facets[n].data=c.facets[n].data||{},c.facets[n].data[e]=0})}),this.hierarchicalFacets=this.hierarchicalFacets.map(E(e)),this.facets=v(this.facets),this.disjunctiveFacets=v(this.disjunctiveFacets),this._state=e}function c(e,t){function i(e){return e.name===t}if(e._state.isConjunctiveFacet(t)){var n=y(e.facets,i);return n?Object.keys(n.data).map(function(i){var r=b(i);return{name:i,escapedValue:r,count:n.data[i],isRefined:e._state.isFacetRefined(t,r),isExcluded:e._state.isExcludeRefined(t,i)}}):[]}if(e._state.isDisjunctiveFacet(t)){var r=y(e.disjunctiveFacets,i);return r?Object.keys(r.data).map(function(i){var n=b(i);return{name:i,escapedValue:n,count:r.data[i],isRefined:e._state.isDisjunctiveFacetRefined(t,n)}}):[]}if(e._state.isHierarchicalFacet(t)){var s=y(e.hierarchicalFacets,i);if(!s)return s;var a=e._state.getHierarchicalFacetByName(t),c=e._state._getHierarchicalFacetSeparator(a),o=P(e._state.getHierarchicalRefinement(t)[0]||"");0===o.indexOf(a.rootPath)&&(o=o.replace(a.rootPath+c,""));var h=o.split(c);return h.unshift(t),u(s,h,0),s}}function u(e,t,i){e.isRefined=e.name===(t[i]&&t[i].trim()),e.data&&e.data.forEach(function(e){u(e,t,i+1)})}function o(e,t,i,n){if(n=n||0,Array.isArray(t))return e(t,i[n]);if(!t.data||0===t.data.length)return t;var r=t.data.map(function(t){return o(e,t,i,n+1)}),s=e(r,i[n]);return g({data:s},t)}function h(e,t){return t.sort(e)}function f(e,t){var i=[],n=[],r=t.order||[],s=r.reduce(function(e,t,i){return e[t]=i,e},{});e.forEach(function(e){var t=e.path||e.name;void 0!==s[t]?i[s[t]]=e:n.push(e)}),i=i.filter(function(e){return e});var a,c=t.sortRemainingBy;return"hidden"===c?i:(a="alpha"===c?[["path","name"],["asc","asc"]]:[["count"],["desc"]],i.concat(x(n,a[0],a[1])))}function l(e,t){return e.renderingContent&&e.renderingContent.facetOrdering&&e.renderingContent.facetOrdering.values&&e.renderingContent.facetOrdering.values[t]}function m(e,t){var i=y(e,function(e){return e.name===t});return i&&i.stats}function d(e,t,i,n,r){var s=y(r,function(e){return e.name===i}),a=s&&s.data&&s.data[n]?s.data[n]:0,c=s&&s.exhaustive||!1;return{type:t,attributeName:i,name:n,count:a,exhaustive:c}}function p(e,t,i,n){var r=e.getHierarchicalFacetByName(t),s=e._getHierarchicalFacetSeparator(r),a=i.split(s),c=y(n,function(e){return e.name===t}),u=a.reduce(function(e,t){var i=e&&y(e.data,function(e){return e.name===t});return void 0!==i?i:e},c),o=u&&u.count||0,h=u&&u.exhaustive||!1,f=u&&u.path||"";return{type:"hierarchical",attributeName:t,name:f,count:o,exhaustive:h}}var v=e("../functions/compact"),g=e("../functions/defaultsPure"),R=e("../functions/escapeFacetValue"),y=e("../functions/find"),F=e("../functions/findIndex"),_=e("../functions/formatSort"),j=e("../functions/merge"),x=e("../functions/orderBy"),b=R.escapeFacetValue,P=R.unescapeFacetValue,E=e("./generate-hierarchical-tree");a.prototype.getFacetByName=function(e){function t(t){return t.name===e}return y(this.facets,t)||y(this.disjunctiveFacets,t)||y(this.hierarchicalFacets,t)},a.DEFAULT_SORT=["isRefined:desc","count:desc","name:asc"],a.prototype.getFacetValues=function(e,t){var i=c(this,e);if(i){var n,r=g({},t,{sortBy:a.DEFAULT_SORT,facetOrdering:!(t&&t.sortBy)}),s=this;if(Array.isArray(i))n=[e];else{ | ||
n=s._state.getHierarchicalFacetByName(i.name).attributes}return o(function(e,t){if(r.facetOrdering){var i=l(s,t);if(i)return f(e,i)}if(Array.isArray(r.sortBy)){var n=_(r.sortBy,a.DEFAULT_SORT);return x(e,n[0],n[1])}if("function"==typeof r.sortBy)return h(r.sortBy,e);throw new Error("options.sortBy is optional but if defined it must be either an array of string (predicates) or a sorting function")},i,n)}},a.prototype.getFacetStats=function(e){return this._state.isConjunctiveFacet(e)?m(this.facets,e):this._state.isDisjunctiveFacet(e)?m(this.disjunctiveFacets,e):void 0},a.prototype.getRefinements=function(){var e=this._state,t=this,i=[];return Object.keys(e.facetsRefinements).forEach(function(n){e.facetsRefinements[n].forEach(function(r){i.push(d(e,"facet",n,r,t.facets))})}),Object.keys(e.facetsExcludes).forEach(function(n){e.facetsExcludes[n].forEach(function(r){i.push(d(e,"exclude",n,r,t.facets))})}),Object.keys(e.disjunctiveFacetsRefinements).forEach(function(n){e.disjunctiveFacetsRefinements[n].forEach(function(r){i.push(d(e,"disjunctive",n,r,t.disjunctiveFacets))})}),Object.keys(e.hierarchicalFacetsRefinements).forEach(function(n){e.hierarchicalFacetsRefinements[n].forEach(function(r){i.push(p(e,n,r,t.hierarchicalFacets))})}),Object.keys(e.numericRefinements).forEach(function(t){var n=e.numericRefinements[t];Object.keys(n).forEach(function(e){n[e].forEach(function(n){i.push({type:"numeric",attributeName:t,name:n,numericValue:n,operator:e})})})}),e.tagRefinements.forEach(function(e){i.push({type:"tag",attributeName:"_tags",name:e})}),i},t.exports=a},{"../functions/compact":10,"../functions/defaultsPure":11,"../functions/escapeFacetValue":12,"../functions/find":13,"../functions/findIndex":14,"../functions/formatSort":15,"../functions/merge":18,"../functions/orderBy":21,"./generate-hierarchical-tree":7}],9:[function(e,t,i){"use strict";function n(e,t,i,n){"function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+g+")"),this.setClient(e);var r=i||{};r.index=t,this.state=p.make(r),this.recommendState=new m({params:r.recommendState}),this.lastResults=null,this.lastRecommendResults=null,this._queryId=0,this._recommendQueryId=0,this._lastQueryIdReceived=-1,this._lastRecommendQueryIdReceived=-1,this.derivedHelpers=[],this._currentNbQueries=0,this._currentNbRecommendQueries=0,this._searchResultsOptions=n}function r(e){if(e<0)throw new Error("Page requested below 0.");return this._change({state:this.state.setPage(e),isPageReset:!1}),this}function s(){return this.state.page}var a=e("@algolia/events"),c=e("./DerivedHelper"),u=e("./functions/escapeFacetValue").escapeFacetValue,o=e("./functions/inherits"),h=e("./functions/merge"),f=e("./functions/objectHasKeys"),l=e("./functions/omit"),m=e("./RecommendParameters"),d=e("./requestBuilder"),p=e("./SearchParameters"),v=e("./SearchResults"),g=e("./version");o(n,a),n.prototype.search=function(){return this._search({onlyWithDerivedHelpers:!1}),this},n.prototype.searchOnlyWithDerivedHelpers=function(){return this._search({onlyWithDerivedHelpers:!0}),this},n.prototype.recommend=function(){return this._recommend(),this},n.prototype.getQuery=function(){var e=this.state;return d._getHitsSearchParams(e)},n.prototype.searchOnce=function(e,t){var i=e?this.state.setQueryParameters(e):this.state,n=d._getQueries(i.index,i),r=this;return this._currentNbQueries++,this.emit("searchOnce",{state:i}),t?void this.client.search(n).then(function(e){r._currentNbQueries--,0===r._currentNbQueries&&r.emit("searchQueueEmpty"),t(null,new v(i,e.results),i)}).catch(function(e){r._currentNbQueries--,0===r._currentNbQueries&&r.emit("searchQueueEmpty"),t(e,null,i)}):this.client.search(n).then(function(e){return r._currentNbQueries--,0===r._currentNbQueries&&r.emit("searchQueueEmpty"),{content:new v(i,e.results),state:i,_originalResponse:e}},function(e){throw r._currentNbQueries--,0===r._currentNbQueries&&r.emit("searchQueueEmpty"),e})},n.prototype.findAnswers=function(e){console.warn("[algoliasearch-helper] answers is no longer supported");var t=this.state,i=this.derivedHelpers[0];if(!i)return Promise.resolve([]);var n=i.getModifiedState(t),r=h({attributesForPrediction:e.attributesForPrediction,nbHits:e.nbHits},{params:l(d._getHitsSearchParams(n),["attributesToSnippet","hitsPerPage","restrictSearchableAttributes","snippetEllipsisText"])}),s="search for answers was called, but this client does not have a function client.initIndex(index).findAnswers";if("function"!=typeof this.client.initIndex)throw new Error(s);var a=this.client.initIndex(n.index);if("function"!=typeof a.findAnswers)throw new Error(s);return a.findAnswers(n.query,e.queryLanguages,r)},n.prototype.searchForFacetValues=function(e,t,i,n){var r="function"==typeof this.client.searchForFacetValues,s="function"==typeof this.client.initIndex;if(!r&&!s&&"function"!=typeof this.client.search)throw new Error("search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues");var a=this.state.setQueryParameters(n||{}),c=a.isDisjunctiveFacet(e),o=d.getSearchForFacetQuery(e,t,i,a);this._currentNbQueries++;var h,f=this;return r?h=this.client.searchForFacetValues([{indexName:a.index,params:o}]):s?h=this.client.initIndex(a.index).searchForFacetValues(o):(delete o.facetName,h=this.client.search([{type:"facet",facet:e,indexName:a.index,params:o}]).then(function(e){return e.results[0]})),this.emit("searchForFacetValues",{state:a,facet:e,query:t}),h.then(function(t){return f._currentNbQueries--,0===f._currentNbQueries&&f.emit("searchQueueEmpty"),t=Array.isArray(t)?t[0]:t,t.facetHits.forEach(function(t){t.escapedValue=u(t.value),t.isRefined=c?a.isDisjunctiveFacetRefined(e,t.escapedValue):a.isFacetRefined(e,t.escapedValue)}),t},function(e){throw f._currentNbQueries--,0===f._currentNbQueries&&f.emit("searchQueueEmpty"),e})},n.prototype.setQuery=function(e){return this._change({state:this.state.resetPage().setQuery(e),isPageReset:!0}),this},n.prototype.clearRefinements=function(e){return this._change({state:this.state.resetPage().clearRefinements(e),isPageReset:!0}),this},n.prototype.clearTags=function(){return this._change({state:this.state.resetPage().clearTags(),isPageReset:!0}),this},n.prototype.addDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.addDisjunctiveRefine=function(){return this.addDisjunctiveFacetRefinement.apply(this,arguments)},n.prototype.addHierarchicalFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addHierarchicalFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.addNumericRefinement=function(e,t,i){return this._change({state:this.state.resetPage().addNumericRefinement(e,t,i),isPageReset:!0}),this},n.prototype.addFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().addFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.addRefine=function(){return this.addFacetRefinement.apply(this,arguments)},n.prototype.addFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().addExcludeRefinement(e,t),isPageReset:!0}),this},n.prototype.addExclude=function(){return this.addFacetExclusion.apply(this,arguments)},n.prototype.addTag=function(e){return this._change({state:this.state.resetPage().addTagRefinement(e),isPageReset:!0}),this},n.prototype.addFrequentlyBoughtTogether=function(e){return this._recommendChange({state:this.recommendState.addFrequentlyBoughtTogether(e)}),this},n.prototype.addRelatedProducts=function(e){return this._recommendChange({state:this.recommendState.addRelatedProducts(e)}),this},n.prototype.addTrendingItems=function(e){return this._recommendChange({state:this.recommendState.addTrendingItems(e)}),this},n.prototype.addTrendingFacets=function(e){return this._recommendChange({state:this.recommendState.addTrendingFacets(e)}),this},n.prototype.addLookingSimilar=function(e){return this._recommendChange({state:this.recommendState.addLookingSimilar(e)}),this},n.prototype.removeNumericRefinement=function(e,t,i){return this._change({state:this.state.resetPage().removeNumericRefinement(e,t,i),isPageReset:!0}),this},n.prototype.removeDisjunctiveFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeDisjunctiveFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.removeDisjunctiveRefine=function(){return this.removeDisjunctiveFacetRefinement.apply(this,arguments)},n.prototype.removeHierarchicalFacetRefinement=function(e){return this._change({state:this.state.resetPage().removeHierarchicalFacetRefinement(e),isPageReset:!0}),this},n.prototype.removeFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().removeFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.removeRefine=function(){return this.removeFacetRefinement.apply(this,arguments)},n.prototype.removeFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().removeExcludeRefinement(e,t),isPageReset:!0}),this},n.prototype.removeExclude=function(){return this.removeFacetExclusion.apply(this,arguments)},n.prototype.removeTag=function(e){return this._change({state:this.state.resetPage().removeTagRefinement(e),isPageReset:!0}),this},n.prototype.removeFrequentlyBoughtTogether=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},n.prototype.removeRelatedProducts=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},n.prototype.removeTrendingItems=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},n.prototype.removeTrendingFacets=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},n.prototype.removeLookingSimilar=function(e){return this._recommendChange({state:this.recommendState.removeParams(e)}),this},n.prototype.toggleFacetExclusion=function(e,t){return this._change({state:this.state.resetPage().toggleExcludeFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.toggleExclude=function(){return this.toggleFacetExclusion.apply(this,arguments)},n.prototype.toggleRefinement=function(e,t){return this.toggleFacetRefinement(e,t)},n.prototype.toggleFacetRefinement=function(e,t){return this._change({state:this.state.resetPage().toggleFacetRefinement(e,t),isPageReset:!0}),this},n.prototype.toggleRefine=function(){return this.toggleFacetRefinement.apply(this,arguments)},n.prototype.toggleTag=function(e){return this._change({state:this.state.resetPage().toggleTagRefinement(e),isPageReset:!0}),this},n.prototype.nextPage=function(){var e=this.state.page||0;return this.setPage(e+1)},n.prototype.previousPage=function(){var e=this.state.page||0;return this.setPage(e-1)},n.prototype.setCurrentPage=r,n.prototype.setPage=r,n.prototype.setIndex=function(e){return this._change({state:this.state.resetPage().setIndex(e),isPageReset:!0}),this},n.prototype.setQueryParameter=function(e,t){return this._change({state:this.state.resetPage().setQueryParameter(e,t),isPageReset:!0}),this},n.prototype.setState=function(e){return this._change({state:p.make(e),isPageReset:!1}),this},n.prototype.overrideStateWithoutTriggeringChangeEvent=function(e){return this.state=new p(e),this},n.prototype.hasRefinements=function(e){return!!f(this.state.getNumericRefinements(e))||(this.state.isConjunctiveFacet(e)?this.state.isFacetRefined(e):this.state.isDisjunctiveFacet(e)?this.state.isDisjunctiveFacetRefined(e):!!this.state.isHierarchicalFacet(e)&&this.state.isHierarchicalFacetRefined(e))},n.prototype.isExcluded=function(e,t){return this.state.isExcludeRefined(e,t)},n.prototype.isDisjunctiveRefined=function(e,t){return this.state.isDisjunctiveFacetRefined(e,t)},n.prototype.hasTag=function(e){return this.state.isTagRefined(e)},n.prototype.isTagRefined=function(){return this.hasTagRefinements.apply(this,arguments)},n.prototype.getIndex=function(){return this.state.index},n.prototype.getCurrentPage=s,n.prototype.getPage=s,n.prototype.getTags=function(){return this.state.tagRefinements},n.prototype.getRefinements=function(e){var t=[];if(this.state.isConjunctiveFacet(e)){this.state.getConjunctiveRefinements(e).forEach(function(e){t.push({value:e,type:"conjunctive"})});this.state.getExcludeRefinements(e).forEach(function(e){t.push({value:e,type:"exclude"})})}else if(this.state.isDisjunctiveFacet(e)){var i=this.state.getDisjunctiveRefinements(e);i.forEach(function(e){t.push({value:e,type:"disjunctive"})})}var n=this.state.getNumericRefinements(e);return Object.keys(n).forEach(function(e){var i=n[e];t.push({value:i,operator:e,type:"numeric"})}),t},n.prototype.getNumericRefinement=function(e,t){return this.state.getNumericRefinement(e,t)},n.prototype.getHierarchicalFacetBreadcrumb=function(e){return this.state.getHierarchicalFacetBreadcrumb(e)},n.prototype._search=function(e){var t=this.state,i=[],n=[];e.onlyWithDerivedHelpers||(n=d._getQueries(t.index,t),i.push({state:t,queriesCount:n.length,helper:this}),this.emit("search",{state:t,results:this.lastResults}));var r=this.derivedHelpers.map(function(e){var n=e.getModifiedState(t),r=n.index?d._getQueries(n.index,n):[];return i.push({state:n,queriesCount:r.length,helper:e}),e.emit("search",{state:n,results:e.lastResults}),r}),s=Array.prototype.concat.apply(n,r),a=this._queryId++;if(this._currentNbQueries++,!s.length)return Promise.resolve({results:[]}).then(this._dispatchAlgoliaResponse.bind(this,i,a));try{this.client.search(s).then(this._dispatchAlgoliaResponse.bind(this,i,a)).catch(this._dispatchAlgoliaError.bind(this,a))}catch(e){this.emit("error",{error:e})}},n.prototype._recommend=function(){var e=this.state,t=this.recommendState,i=this.getIndex(),n=[{state:t,index:i,helper:this}];this.emit("fetch",{recommend:{state:t,results:this.lastRecommendResults}});var r=this.derivedHelpers.map(function(t){var i=t.getModifiedState(e).index;if(!i)return[];var r=t.getModifiedRecommendState(new m);return n.push({state:r,index:i,helper:t}),t.emit("fetch",{recommend:{state:r,results:t.lastRecommendResults}}),r._buildQueries(i)}),s=Array.prototype.concat.apply(this.recommendState._buildQueries(i),r);if(0!==s.length){if(s.length>0&&void 0===this.client.getRecommendations)return void console.warn("Please update algoliasearch/lite to the latest version in order to use recommendations widgets.");var a=this._recommendQueryId++;this._currentNbRecommendQueries++;try{this.client.getRecommendations(s).then(this._dispatchRecommendResponse.bind(this,a,n)).catch(this._dispatchRecommendError.bind(this,a))}catch(e){this.emit("error",{error:e})}}},n.prototype._dispatchAlgoliaResponse=function(e,t,i){var n=this;if(!(t<this._lastQueryIdReceived)){this._currentNbQueries-=t-this._lastQueryIdReceived,this._lastQueryIdReceived=t,0===this._currentNbQueries&&this.emit("searchQueueEmpty");var r=i.results.slice();e.forEach(function(e){var t=e.state,i=e.queriesCount,s=e.helper,a=r.splice(0,i);if(!t.index)return void s.emit("result",{results:null,state:t});s.lastResults=new v(t,a,n._searchResultsOptions),s.emit("result",{results:s.lastResults,state:t})})}},n.prototype._dispatchRecommendResponse=function(e,t,i){if(!(e<this._lastRecommendQueryIdReceived)){this._currentNbRecommendQueries-=e-this._lastRecommendQueryIdReceived,this._lastRecommendQueryIdReceived=e,0===this._currentNbRecommendQueries&&this.emit("recommendQueueEmpty");var n=i.results.slice();t.forEach(function(e){var t=e.state,i=e.helper;if(!e.index)return void i.emit("recommend:result",{results:null,state:t});i.lastRecommendResults=n,i.emit("recommend:result",{recommend:{results:i.lastRecommendResults,state:t}})})}},n.prototype._dispatchAlgoliaError=function(e,t){e<this._lastQueryIdReceived||(this._currentNbQueries-=e-this._lastQueryIdReceived,this._lastQueryIdReceived=e,this.emit("error",{error:t}),0===this._currentNbQueries&&this.emit("searchQueueEmpty"))},n.prototype._dispatchRecommendError=function(e,t){e<this._lastRecommendQueryIdReceived||(this._currentNbRecommendQueries-=e-this._lastRecommendQueryIdReceived,this._lastRecommendQueryIdReceived=e,this.emit("error",{error:t}),0===this._currentNbRecommendQueries&&this.emit("recommendQueueEmpty"))},n.prototype.containsRefinement=function(e,t,i,n){return e||0!==t.length||0!==i.length||0!==n.length},n.prototype._hasDisjunctiveRefinements=function(e){return this.state.disjunctiveRefinements[e]&&this.state.disjunctiveRefinements[e].length>0},n.prototype._change=function(e){var t=e.state,i=e.isPageReset;t!==this.state&&(this.state=t,this.emit("change",{state:this.state,results:this.lastResults,isPageReset:i}))},n.prototype._recommendChange=function(e){var t=e.state;t!==this.recommendState&&(this.recommendState=t,this.emit("recommend:change",{search:{results:this.lastResults,state:this.state},recommend:{results:this.lastRecommendResults,state:this.recommendState}}))},n.prototype.clearCache=function(){return this.client.clearCache&&this.client.clearCache(),this},n.prototype.setClient=function(e){return this.client===e?this:("function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+g+")"),this.client=e,this)},n.prototype.getClient=function(){return this.client},n.prototype.derive=function(e,t){var i=new c(this,e,t);return this.derivedHelpers.push(i),i},n.prototype.detachDerivedHelper=function(e){var t=this.derivedHelpers.indexOf(e);if(-1===t)throw new Error("Derived helper already detached");this.derivedHelpers.splice(t,1)},n.prototype.hasPendingRequests=function(){return this._currentNbQueries>0},t.exports=n},{"./DerivedHelper":3,"./RecommendParameters":4,"./SearchParameters":6,"./SearchResults":8,"./functions/escapeFacetValue":12,"./functions/inherits":16,"./functions/merge":18,"./functions/objectHasKeys":19,"./functions/omit":20,"./requestBuilder":23,"./version":25,"@algolia/events":1}],10:[function(e,t,i){"use strict";t.exports=function(e){return Array.isArray(e)?e.filter(Boolean):[]}},{}],11:[function(e,t,i){"use strict";t.exports=function(){return Array.prototype.slice.call(arguments).reduceRight(function(e,t){return Object.keys(Object(t)).forEach(function(i){void 0!==t[i]&&(void 0!==e[i]&&delete e[i],e[i]=t[i])}),e},{})}},{}],12:[function(e,t,i){"use strict";function n(e){return"string"!=typeof e?e:String(e).replace(/^-/,"\\-")}function r(e){return"string"!=typeof e?e:e.replace(/^\\-/,"-")}t.exports={escapeFacetValue:n,unescapeFacetValue:r}},{}],13:[function(e,t,i){"use strict";t.exports=function(e,t){if(Array.isArray(e))for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}},{}],14:[function(e,t,i){"use strict";t.exports=function(e,t){if(!Array.isArray(e))return-1;for(var i=0;i<e.length;i++)if(t(e[i]))return i;return-1}},{}],15:[function(e,t,i){"use strict";var n=e("./find");t.exports=function(e,t){var i=(t||[]).map(function(e){return e.split(":")});return e.reduce(function(e,t){var r=t.split(":"),s=n(i,function(e){return e[0]===r[0]});return r.length>1||!s?(e[0].push(r[0]),e[1].push(r[1]),e):(e[0].push(s[0]),e[1].push(s[1]),e)},[[],[]])}},{"./find":13}],16:[function(e,t,i){"use strict";function n(e,t){e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}t.exports=n},{}],17:[function(e,t,i){"use strict";function n(e,t){return e.filter(function(i,n){return t.indexOf(i)>-1&&e.indexOf(i)===n})}t.exports=n},{}],18:[function(e,t,i){"use strict";function n(e){return"object"==typeof e&&null!==e?s(Array.isArray(e)?[]:{},e):e}function r(e){return"function"==typeof e||Array.isArray(e)||"[object Object]"===Object.prototype.toString.call(e)}function s(e,t){if(e===t)return e;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&"__proto__"!==i&&"constructor"!==i){var a=t[i],c=e[i];void 0!==c&&void 0===a||(r(c)&&r(a)?e[i]=s(c,a):e[i]=n(a))}return e}function a(e){r(e)||(e={});for(var t=1,i=arguments.length;t<i;t++){var n=arguments[t];r(n)&&s(e,n)}return e}t.exports=a},{}],19:[function(e,t,i){"use strict";function n(e){return e&&Object.keys(e).length>0}t.exports=n},{}],20:[function(e,t,i){"use strict";function n(e,t){if(null===e)return{};var i,n,r={},s=Object.keys(e);for(n=0;n<s.length;n++)i=s[n],t.indexOf(i)>=0||(r[i]=e[i]);return r}t.exports=n},{}],21:[function(e,t,i){"use strict";function n(e,t){if(e!==t){var i=void 0!==e,n=null===e,r=void 0!==t,s=null===t;if(!s&&e>t||n&&r||!i)return 1;if(!n&&e<t||s&&i||!r)return-1}return 0}function r(e,t,i){if(!Array.isArray(e))return[];Array.isArray(i)||(i=[]);var r=e.map(function(e,i){return{criteria:t.map(function(t){return e[t]}),index:i,value:e}});return r.sort(function(e,t){for(var r=-1;++r<e.criteria.length;){var s=n(e.criteria[r],t.criteria[r]);if(s)return r>=i.length?s:"desc"===i[r]?-s:s}return e.index-t.index}),r.map(function(e){return e.value})}t.exports=r},{}],22:[function(e,t,i){"use strict";function n(e){if("number"==typeof e)return e;if("string"==typeof e)return parseFloat(e);if(Array.isArray(e))return e.map(n);throw new Error("The value should be a number, a parsable string or an array of those.")}t.exports=n},{}],23:[function(e,t,i){"use strict";function n(e){return Object.keys(e).sort().reduce(function(t,i){return t[i]=e[i],t},{})}var r=e("./functions/merge"),s={_getQueries:function(e,t){var i=[];return i.push({indexName:e,params:s._getHitsSearchParams(t)}),t.getRefinedDisjunctiveFacets().forEach(function(n){i.push({indexName:e,params:s._getDisjunctiveFacetSearchParams(t,n)})}),t.getRefinedHierarchicalFacets().forEach(function(n){var r=t.getHierarchicalFacetByName(n),a=t.getHierarchicalRefinement(n),c=t._getHierarchicalFacetSeparator(r);if(a.length>0&&a[0].split(c).length>1){var u=a[0].split(c).slice(0,-1).reduce(function(e,t,i){return e.concat({attribute:r.attributes[i],value:0===i?t:[e[e.length-1].value,t].join(c)})},[]);u.forEach(function(n,a){function c(e){return r.attributes.some(function(t){return t===e.split(":")[0]})}var o=s._getDisjunctiveFacetSearchParams(t,n.attribute,0===a),h=(o.facetFilters||[]).reduce(function(e,t){if(Array.isArray(t)){var i=t.filter(function(e){return!c(e)});i.length>0&&e.push(i)}return"string"!=typeof t||c(t)||e.push(t),e},[]),f=u[a-1];o.facetFilters=a>0?h.concat(f.attribute+":"+f.value):h.length>0?h:void 0,i.push({indexName:e,params:o})})}}),i},_getHitsSearchParams:function(e){var t=e.facets.concat(e.disjunctiveFacets).concat(s._getHitsHierarchicalFacetsAttributes(e)).sort(),i=s._getFacetFilters(e),a=s._getNumericFilters(e),c=s._getTagFilters(e),u={facets:t.indexOf("*")>-1?["*"]:t,tagFilters:c};return i.length>0&&(u.facetFilters=i),a.length>0&&(u.numericFilters=a),n(r({},e.getQueryParams(),u))},_getDisjunctiveFacetSearchParams:function(e,t,i){var a=s._getFacetFilters(e,t,i),c=s._getNumericFilters(e,t),u=s._getTagFilters(e),o={hitsPerPage:0,page:0,analytics:!1,clickAnalytics:!1};u.length>0&&(o.tagFilters=u);var h=e.getHierarchicalFacetByName(t);return o.facets=h?s._getDisjunctiveHierarchicalFacetAttribute(e,h,i):t,c.length>0&&(o.numericFilters=c),a.length>0&&(o.facetFilters=a),n(r({},e.getQueryParams(),o))},_getNumericFilters:function(e,t){if(e.numericFilters)return e.numericFilters;var i=[];return Object.keys(e.numericRefinements).forEach(function(n){var r=e.numericRefinements[n]||{};Object.keys(r).forEach(function(e){var s=r[e]||[];t!==n&&s.forEach(function(t){if(Array.isArray(t)){var r=t.map(function(t){return n+e+t});i.push(r)}else i.push(n+e+t)})})}),i},_getTagFilters:function(e){return e.tagFilters?e.tagFilters:e.tagRefinements.join(",")},_getFacetFilters:function(e,t,i){var n=[],r=e.facetsRefinements||{};Object.keys(r).sort().forEach(function(e){(r[e]||[]).slice().sort().forEach(function(t){n.push(e+":"+t)})});var s=e.facetsExcludes||{};Object.keys(s).sort().forEach(function(e){(s[e]||[]).sort().forEach(function(t){n.push(e+":-"+t)})});var a=e.disjunctiveFacetsRefinements||{};Object.keys(a).sort().forEach(function(e){var i=a[e]||[];if(e!==t&&i&&0!==i.length){var r=[];i.slice().sort().forEach(function(t){r.push(e+":"+t)}),n.push(r)}});var c=e.hierarchicalFacetsRefinements||{};return Object.keys(c).sort().forEach(function(r){var s=c[r]||[],a=s[0];if(void 0!==a){var u,o,h=e.getHierarchicalFacetByName(r),f=e._getHierarchicalFacetSeparator(h),l=e._getHierarchicalRootPath(h);if(t===r){if(-1===a.indexOf(f)||!l&&!0===i||l&&l.split(f).length===a.split(f).length)return;l?(o=l.split(f).length-1,a=l):(o=a.split(f).length-2,a=a.slice(0,a.lastIndexOf(f))),u=h.attributes[o]}else o=a.split(f).length-1,u=h.attributes[o];u&&n.push([u+":"+a])}}),n},_getHitsHierarchicalFacetsAttributes:function(e){var t=[];return e.hierarchicalFacets.reduce(function(t,i){var n=e.getHierarchicalRefinement(i.name)[0];if(!n)return t.push(i.attributes[0]),t;var r=e._getHierarchicalFacetSeparator(i),s=n.split(r).length,a=i.attributes.slice(0,s+1);return t.concat(a)},t)},_getDisjunctiveHierarchicalFacetAttribute:function(e,t,i){var n=e._getHierarchicalFacetSeparator(t);if(!0===i){var r=e._getHierarchicalRootPath(t),s=0;return r&&(s=r.split(n).length),[t.attributes[s]]}var a=e.getHierarchicalRefinement(t.name)[0]||"",c=a.split(n).length-1;return t.attributes.slice(0,c+1)},getSearchForFacetQuery:function(e,t,i,a){var c=a.isDisjunctiveFacet(e)?a.clearRefinements(e):a,u={facetQuery:t,facetName:e};return"number"==typeof i&&(u.maxFacetHits=i),n(r({},s._getHitsSearchParams(c),u))}};t.exports=s},{"./functions/merge":18}],24:[function(e,t,i){"use strict";t.exports=function(e){return null!==e&&/^[a-zA-Z0-9_-]{1,64}$/.test(e)}},{}],25:[function(e,t,i){"use strict";t.exports="3.18.0"},{}]},{},[2])(2)}); | ||
//# sourceMappingURL=dist/algoliasearch.helper.min.js.map |
@@ -14,5 +14,7 @@ import EventEmitter from '@algolia/events'; | ||
import type { | ||
RecommendationsQuery, | ||
RecommendedForYouQuery, | ||
TrendingQuery, | ||
FrequentlyBoughtTogetherQuery as RecommendFrequentlyBoughtTogetherQuery, | ||
LookingSimilarQuery as RecommendLookingSimilarQuery, | ||
RelatedProductsQuery as RecommendRelatedProductsQuery, | ||
TrendingFacetsQuery as RecommendTrendingFacetsQuery, | ||
TrendingItemsQuery as RecommendTrendingItemsQuery, | ||
} from '@algolia/recommend'; | ||
@@ -44,2 +46,3 @@ | ||
lastResults: SearchResults | null; | ||
lastRecommendResults: unknown | null; // TODO: Define type in dedicated PR | ||
derivedHelpers: DerivedHelper[]; | ||
@@ -91,2 +94,4 @@ | ||
recommend(): this; | ||
/** | ||
@@ -273,2 +278,17 @@ * Private method to only search on derived helpers | ||
addTag(tag: string): this; | ||
addFrequentlyBoughtTogether( | ||
params: RecommendParametersWithId<FrequentlyBoughtTogetherQuery> | ||
): this; | ||
addRelatedProducts( | ||
params: RecommendParametersWithId<RelatedProductsQuery> | ||
): this; | ||
addTrendingItems( | ||
params: RecommendParametersWithId<TrendingItemsQuery> | ||
): this; | ||
addTrendingFacets( | ||
params: RecommendParametersWithId<TrendingFacetsQuery> | ||
): this; | ||
addLookingSimilar( | ||
params: RecommendParametersWithId<LookingSimilarQuery> | ||
): this; | ||
removeNumericRefinement( | ||
@@ -296,2 +316,7 @@ facet: string, | ||
removeTag(value: string): this; | ||
removeFrequentlyBoughtTogether(id: string): this; | ||
removeRelatedProducts(id: string): this; | ||
removeTrendingItems(id: string): this; | ||
removeTrendingFacets(id: string): this; | ||
removeLookingSimilar(id: string): this; | ||
toggleFacetExclusion(facet: string, value: string): this; | ||
@@ -363,3 +388,6 @@ /** | ||
derive( | ||
deriveFn: (oldParams: SearchParameters) => SearchParameters | ||
deriveFn: (oldParams: SearchParameters) => SearchParameters, | ||
deriveRecommendFn?: ( | ||
oldParams: RecommendParameters | ||
) => RecommendParameters | ||
): DerivedHelper; | ||
@@ -379,7 +407,18 @@ detachDerivedHelper(derivedHelper: DerivedHelper): void; | ||
): this; | ||
on( | ||
event: 'recommend:result', | ||
cb: (res: { | ||
recommend: { | ||
results: unknown | null; // TODO: Define type in dedicated PR | ||
state: RecommendParameters; | ||
}; | ||
}) => void | ||
): this; | ||
on(event: 'error', cb: (res: { error: Error }) => void): this; | ||
lastResults: SearchResults | null; | ||
lastRecommendResults: unknown | null; // TODO: Define type in dedicated PR | ||
detach(): void; | ||
getModifiedState(): SearchParameters; | ||
getModifiedRecommendState(): RecommendParameters; | ||
} | ||
@@ -1475,8 +1514,23 @@ | ||
// We remove `indexName` from the Recommend query types as the helper | ||
// will fill in this value before sending the queries | ||
type FrequentlyBoughtTogetherQuery = Omit< | ||
RecommendFrequentlyBoughtTogetherQuery, | ||
'indexName' | ||
>; | ||
type LookingSimilarQuery = Omit<RecommendLookingSimilarQuery, 'indexName'>; | ||
type RelatedProductsQuery = Omit<RecommendRelatedProductsQuery, 'indexName'>; | ||
type TrendingFacetsQuery = Omit<RecommendTrendingFacetsQuery, 'indexName'>; | ||
type TrendingItemsQuery = Omit<RecommendTrendingItemsQuery, 'indexName'>; | ||
export type PlainRecommendParameters = | ||
| RecommendationsQuery | ||
| TrendingQuery | ||
| RecommendedForYouQuery; | ||
| FrequentlyBoughtTogetherQuery | ||
| LookingSimilarQuery | ||
| RelatedProductsQuery | ||
| TrendingFacetsQuery | ||
| TrendingItemsQuery; | ||
export type PlainRecommendParametersWithId = PlainRecommendParameters & { | ||
export type RecommendParametersWithId< | ||
T extends PlainRecommendParameters = PlainRecommendParameters | ||
> = T & { | ||
$$id: string; | ||
@@ -1486,10 +1540,25 @@ }; | ||
export type RecommendParametersOptions = { | ||
params?: PlainRecommendParametersWithId[]; | ||
params?: Array<RecommendParametersWithId<PlainRecommendParameters>>; | ||
}; | ||
export class RecommendParameters { | ||
params: PlainRecommendParametersWithId[]; | ||
params: RecommendParametersWithId[]; | ||
constructor(opts?: RecommendParametersOptions); | ||
addParams(params: PlainRecommendParametersWithId): RecommendParameters; | ||
addParams(params: RecommendParametersWithId): RecommendParameters; | ||
removeParams(id: string): RecommendParameters; | ||
addFrequentlyBoughtTogether( | ||
params: RecommendParametersWithId<FrequentlyBoughtTogetherQuery> | ||
): RecommendParameters; | ||
addRelatedProducts( | ||
params: RecommendParametersWithId<RelatedProductsQuery> | ||
): RecommendParameters; | ||
addTrendingItems( | ||
params: RecommendParametersWithId<TrendingItemsQuery> | ||
): RecommendParameters; | ||
addTrendingFacets( | ||
params: RecommendParametersWithId<TrendingFacetsQuery> | ||
): RecommendParameters; | ||
addLookingSimilar( | ||
params: RecommendParametersWithId<LookingSimilarQuery> | ||
): RecommendParameters; | ||
} | ||
@@ -1496,0 +1565,0 @@ } |
'use strict'; | ||
var AlgoliaSearchHelper = require('./src/algoliasearch.helper'); | ||
var RecommendParameters = require('./src/RecommendParameters'); | ||
var SearchParameters = require('./src/SearchParameters'); | ||
@@ -65,2 +66,9 @@ var SearchResults = require('./src/SearchResults'); | ||
/** | ||
* Constructor for the object containing all the parameters for Recommend. | ||
* @member module:algoliasearchHelper.RecommendParameters | ||
* @type {RecommendParameters} | ||
*/ | ||
algoliasearchHelper.RecommendParameters = RecommendParameters; | ||
/** | ||
* Constructor for the object containing the results of the search. | ||
@@ -67,0 +75,0 @@ * @member module:algoliasearchHelper.SearchResults |
{ | ||
"name": "algoliasearch-helper", | ||
"version": "3.17.0", | ||
"version": "3.18.0", | ||
"description": "Helper for implementing advanced search features with algolia", | ||
@@ -37,3 +37,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@algolia/recommend": "4.22.1", | ||
"@algolia/recommend": "4.23.2", | ||
"@metalsmith/sass": "1.4.0", | ||
@@ -61,3 +61,3 @@ "@types/algoliasearch": "3.34.11", | ||
}, | ||
"gitHead": "d309ca3333476a842be080fcb01b8be925aad204" | ||
"gitHead": "17da3c2268354325cc22103260d944d3e4feff90" | ||
} |
@@ -134,6 +134,10 @@ 'use strict'; | ||
this.lastResults = null; | ||
this.lastRecommendResults = null; | ||
this._queryId = 0; | ||
this._recommendQueryId = 0; | ||
this._lastQueryIdReceived = -1; | ||
this._lastRecommendQueryIdReceived = -1; | ||
this.derivedHelpers = []; | ||
this._currentNbQueries = 0; | ||
this._currentNbRecommendQueries = 0; | ||
this._searchResultsOptions = searchResultsOptions; | ||
@@ -166,2 +170,17 @@ } | ||
/** | ||
* Sends the recommendation queries set in the state. When the method is | ||
* called, it triggers a `fetch` event. The results will be available through | ||
* the `result` event. If an error occurs, an `error` will be fired instead. | ||
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires fetch | ||
* @fires result | ||
* @fires error | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.recommend = function () { | ||
this._recommend(); | ||
return this; | ||
}; | ||
/** | ||
* Gets the search query parameters that would be sent to the Algolia Client | ||
@@ -663,2 +682,82 @@ * for the hits | ||
/** | ||
* Adds a "frequently bought together" recommendation query. | ||
* | ||
* @param {FrequentlyBoughtTogetherQuery} params the parameters for the recommendation | ||
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires change | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.addFrequentlyBoughtTogether = function (params) { | ||
this._recommendChange({ | ||
state: this.recommendState.addFrequentlyBoughtTogether(params), | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Adds a "related products" recommendation query. | ||
* | ||
* @param {RelatedProductsQuery} params the parameters for the recommendation | ||
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires change | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.addRelatedProducts = function (params) { | ||
this._recommendChange({ | ||
state: this.recommendState.addRelatedProducts(params), | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Adds a "trending items" recommendation query. | ||
* | ||
* @param {TrendingItemsQuery} params the parameters for the recommendation | ||
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires change | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.addTrendingItems = function (params) { | ||
this._recommendChange({ | ||
state: this.recommendState.addTrendingItems(params), | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Adds a "trending facets" recommendation query. | ||
* | ||
* @param {TrendingFacetsQuery} params the parameters for the recommendation | ||
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires change | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.addTrendingFacets = function (params) { | ||
this._recommendChange({ | ||
state: this.recommendState.addTrendingFacets(params), | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Adds a "looking similar" recommendation query. | ||
* | ||
* @param {LookingSimilarQuery} params the parameters for the recommendation | ||
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires change | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.addLookingSimilar = function (params) { | ||
this._recommendChange({ | ||
state: this.recommendState.addLookingSimilar(params), | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Removes an numeric filter to an attribute with the `operator` and `value` provided. If the | ||
@@ -833,2 +932,82 @@ * filter is not set, it doesn't change the filters. | ||
/** | ||
* Removes a "frequently bought together" recommendation query. | ||
* | ||
* @param {string} id identifier of the recommendation widget | ||
* @returns {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires change | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.removeFrequentlyBoughtTogether = function (id) { | ||
this._recommendChange({ | ||
state: this.recommendState.removeParams(id), | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Removes a "related products" recommendation query. | ||
* | ||
* @param {string} id identifier of the recommendation widget | ||
* @returns {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires change | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.removeRelatedProducts = function (id) { | ||
this._recommendChange({ | ||
state: this.recommendState.removeParams(id), | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Removes a "trending items" recommendation query. | ||
* | ||
* @param {string} id identifier of the recommendation widget | ||
* @returns {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires change | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.removeTrendingItems = function (id) { | ||
this._recommendChange({ | ||
state: this.recommendState.removeParams(id), | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Removes a "trending facets" recommendation query. | ||
* | ||
* @param {string} id identifier of the recommendation widget | ||
* @returns {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires change | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.removeTrendingFacets = function (id) { | ||
this._recommendChange({ | ||
state: this.recommendState.removeParams(id), | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Removes a "looking similar" recommendation query. | ||
* | ||
* @param {string} id identifier of the recommendation widget | ||
* @returns {AlgoliaSearchHelper} Method is chainable, it returns itself | ||
* @fires change | ||
* @chainable | ||
*/ | ||
AlgoliaSearchHelper.prototype.removeLookingSimilar = function (id) { | ||
this._recommendChange({ | ||
state: this.recommendState.removeParams(id), | ||
}); | ||
return this; | ||
}; | ||
/** | ||
* Adds or removes an exclusion filter to a faceted attribute with the `value` provided. If | ||
@@ -1400,2 +1579,81 @@ * the value is set then it removes it, otherwise it adds the filter. | ||
AlgoliaSearchHelper.prototype._recommend = function () { | ||
var searchState = this.state; | ||
var recommendState = this.recommendState; | ||
var index = this.getIndex(); | ||
var states = [{ state: recommendState, index: index, helper: this }]; | ||
this.emit('fetch', { | ||
recommend: { | ||
state: recommendState, | ||
results: this.lastRecommendResults, | ||
}, | ||
}); | ||
var derivedQueries = this.derivedHelpers.map(function (derivedHelper) { | ||
var derivedIndex = derivedHelper.getModifiedState(searchState).index; | ||
if (!derivedIndex) { | ||
return []; | ||
} | ||
// Contrary to what is done when deriving the search state, we don't want to | ||
// provide the current recommend state to the derived helper, as it would | ||
// inherit unwanted queries. We instead provide an empty recommend state. | ||
var derivedState = derivedHelper.getModifiedRecommendState( | ||
new RecommendParameters() | ||
); | ||
states.push({ | ||
state: derivedState, | ||
index: derivedIndex, | ||
helper: derivedHelper, | ||
}); | ||
derivedHelper.emit('fetch', { | ||
recommend: { | ||
state: derivedState, | ||
results: derivedHelper.lastRecommendResults, | ||
}, | ||
}); | ||
return derivedState._buildQueries(derivedIndex); | ||
}); | ||
var queries = Array.prototype.concat.apply( | ||
this.recommendState._buildQueries(index), | ||
derivedQueries | ||
); | ||
if (queries.length === 0) { | ||
return; | ||
} | ||
if ( | ||
queries.length > 0 && | ||
typeof this.client.getRecommendations === 'undefined' | ||
) { | ||
// eslint-disable-next-line no-console | ||
console.warn( | ||
'Please update algoliasearch/lite to the latest version in order to use recommendations widgets.' | ||
); | ||
return; | ||
} | ||
var queryId = this._recommendQueryId++; | ||
this._currentNbRecommendQueries++; | ||
try { | ||
this.client | ||
.getRecommendations(queries) | ||
.then(this._dispatchRecommendResponse.bind(this, queryId, states)) | ||
.catch(this._dispatchRecommendError.bind(this, queryId)); | ||
} catch (error) { | ||
// If we reach this part, we're in an internal error state | ||
this.emit('error', { | ||
error: error, | ||
}); | ||
} | ||
return; | ||
}; | ||
/** | ||
@@ -1460,2 +1718,49 @@ * Transform the responses as sent by the server and transform them into a user | ||
AlgoliaSearchHelper.prototype._dispatchRecommendResponse = function ( | ||
queryId, | ||
states, | ||
content | ||
) { | ||
// @TODO remove the number of outdated queries discarded instead of just one | ||
if (queryId < this._lastRecommendQueryIdReceived) { | ||
// Outdated answer | ||
return; | ||
} | ||
this._currentNbRecommendQueries -= | ||
queryId - this._lastRecommendQueryIdReceived; | ||
this._lastRecommendQueryIdReceived = queryId; | ||
if (this._currentNbRecommendQueries === 0) this.emit('recommendQueueEmpty'); | ||
var results = content.results.slice(); | ||
states.forEach(function (s) { | ||
var state = s.state; | ||
var helper = s.helper; | ||
if (!s.index) { | ||
// eslint-disable-next-line no-warning-comments | ||
// TODO: emit "result" event when events for Recommend are implemented | ||
helper.emit('recommend:result', { | ||
results: null, | ||
state: state, | ||
}); | ||
return; | ||
} | ||
helper.lastRecommendResults = results; | ||
// eslint-disable-next-line no-warning-comments | ||
// TODO: emit "result" event when events for Recommend are implemented | ||
helper.emit('recommend:result', { | ||
recommend: { | ||
results: helper.lastRecommendResults, | ||
state: state, | ||
}, | ||
}); | ||
}); | ||
}; | ||
AlgoliaSearchHelper.prototype._dispatchAlgoliaError = function ( | ||
@@ -1480,2 +1785,22 @@ queryId, | ||
AlgoliaSearchHelper.prototype._dispatchRecommendError = function ( | ||
queryId, | ||
error | ||
) { | ||
if (queryId < this._lastRecommendQueryIdReceived) { | ||
// Outdated answer | ||
return; | ||
} | ||
this._currentNbRecommendQueries -= | ||
queryId - this._lastRecommendQueryIdReceived; | ||
this._lastRecommendQueryIdReceived = queryId; | ||
this.emit('error', { | ||
error: error, | ||
}); | ||
if (this._currentNbRecommendQueries === 0) this.emit('recommendQueueEmpty'); | ||
}; | ||
AlgoliaSearchHelper.prototype.containsRefinement = function ( | ||
@@ -1531,2 +1856,12 @@ query, | ||
// TODO: emit "change" event when events for Recommend are implemented | ||
this.emit('recommend:change', { | ||
search: { | ||
results: this.lastResults, | ||
state: this.state, | ||
}, | ||
recommend: { | ||
results: this.lastRecommendResults, | ||
state: this.recommendState, | ||
}, | ||
}); | ||
} | ||
@@ -1586,6 +1921,7 @@ }; | ||
* @param {function} fn SearchParameters -> SearchParameters | ||
* @param {function} recommendFn RecommendParameters -> RecommendParameters | ||
* @return {DerivedHelper} a new DerivedHelper | ||
*/ | ||
AlgoliaSearchHelper.prototype.derive = function (fn) { | ||
var derivedHelper = new DerivedHelper(this, fn); | ||
AlgoliaSearchHelper.prototype.derive = function (fn, recommendFn) { | ||
var derivedHelper = new DerivedHelper(this, fn, recommendFn); | ||
this.derivedHelpers.push(derivedHelper); | ||
@@ -1592,0 +1928,0 @@ return derivedHelper; |
@@ -17,8 +17,11 @@ 'use strict'; | ||
* @param {AlgoliaSearchHelper} mainHelper the main helper | ||
* @param {function} fn the function to create the derived state | ||
* @param {function} fn the function to create the derived state for search | ||
* @param {function} recommendFn the function to create the derived state for recommendations | ||
*/ | ||
function DerivedHelper(mainHelper, fn) { | ||
function DerivedHelper(mainHelper, fn, recommendFn) { | ||
this.main = mainHelper; | ||
this.fn = fn; | ||
this.recommendFn = recommendFn; | ||
this.lastResults = null; | ||
this.lastRecommendResults = null; | ||
} | ||
@@ -42,2 +45,6 @@ | ||
DerivedHelper.prototype.getModifiedRecommendState = function (parameters) { | ||
return this.recommendFn(parameters); | ||
}; | ||
module.exports = DerivedHelper; |
@@ -25,3 +25,14 @@ 'use strict'; | ||
addParams: function (params) { | ||
return new RecommendParameters({ params: this.params.concat(params) }); | ||
var newParams = this.params.slice(); | ||
var existingParamsIndex = this.params.findIndex(function (currentParams) { | ||
return currentParams.$$id === params.$$id; | ||
}); | ||
if (existingParamsIndex !== -1) { | ||
newParams.splice(existingParamsIndex, 1, params); | ||
} else { | ||
newParams.push(params); | ||
} | ||
return new RecommendParameters({ params: newParams }); | ||
}, | ||
@@ -36,4 +47,43 @@ | ||
}, | ||
addFrequentlyBoughtTogether: function (params) { | ||
return this.addParams( | ||
Object.assign({}, params, { model: 'bought-together' }) | ||
); | ||
}, | ||
addRelatedProducts: function (params) { | ||
return this.addParams( | ||
Object.assign({}, params, { model: 'related-products' }) | ||
); | ||
}, | ||
addTrendingItems: function (params) { | ||
return this.addParams( | ||
Object.assign({}, params, { model: 'trending-items' }) | ||
); | ||
}, | ||
addTrendingFacets: function (params) { | ||
return this.addParams( | ||
Object.assign({}, params, { model: 'trending-facets' }) | ||
); | ||
}, | ||
addLookingSimilar: function (params) { | ||
return this.addParams( | ||
Object.assign({}, params, { model: 'looking-similar' }) | ||
); | ||
}, | ||
_buildQueries: function (indexName) { | ||
return this.params.map(function (params) { | ||
var query = Object.assign({}, params, { indexName: indexName }); | ||
delete query.$$id; | ||
return query; | ||
}); | ||
}, | ||
}; | ||
module.exports = RecommendParameters; |
'use strict'; | ||
module.exports = '3.17.0'; | ||
module.exports = '3.18.0'; |
@@ -175,2 +175,3 @@ // Note: Below, we will be importing all algoliasearch v3,4,5 types. | ||
addAlgoliaAgent?: DefaultSearchClient['addAlgoliaAgent']; | ||
getRecommendations?: DefaultSearchClient['getRecommendations']; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1078230
13336