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

algoliasearch-helper

Package Overview
Dependencies
Maintainers
5
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

algoliasearch-helper - npm Package Compare versions

Comparing version 3.6.1 to 3.6.2

4

dist/algoliasearch.helper.min.js

@@ -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 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){var i=t[a][1][e];return r(i||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}({1:[function(e,t,i){"use strict";function n(e,t,i){return new r(e,t,i)}var r=e("./src/algoliasearch.helper"),s=e("./src/SearchParameters"),a=e("./src/SearchResults");n.version=e("./src/version.js"),n.AlgoliaSearchHelper=r,n.SearchParameters=s,n.SearchResults=a,t.exports=n},{"./src/SearchParameters":5,"./src/SearchResults":7,"./src/algoliasearch.helper":8,"./src/version.js":23}],2:[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.EventEmitter=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)}},{}],3:[function(e,t,i){"use strict";function n(e,t){this.main=e,this.fn=t,this.lastResults=null}var r=e("events");e("../functions/inherits")(n,r.EventEmitter),n.prototype.detach=function(){this.removeAllListeners(),this.main.detachDerivedHelper(this)},n.prototype.getModifiedState=function(e){return this.fn(e)},t.exports=n},{"../functions/inherits":14,events:2}],4:[function(e,t,i){"use strict";var n=e("../functions/defaultsPure"),r=e("../functions/omit"),s=e("../functions/objectHasKeys"),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 s(e)?{}:e;if("string"==typeof t)return r(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=!!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":10,"../functions/objectHasKeys":17,"../functions/omit":18}],5:[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 o(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/merge"),c=e("../functions/defaultsPure"),u=e("../functions/intersection"),o=e("../functions/find"),f=e("../functions/valToNumber"),h=e("../functions/omit"),l=e("../functions/objectHasKeys"),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 a({},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&&l(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."):l(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=f(i);if(this.isNumericRefined(e,t,n))return this;var r=a({},this.numericRefinements);return r[e]=a({},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){return void 0!==i?this.isNumericRefined(e,t,i)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements(function(r,s){return s===e&&r.op===t&&n(r.val,f(i))})}):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 l(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:c({},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:c({},i,this.hierarchicalFacetsRefinements)})},removeHierarchicalFacetRefinement:function(e){if(!this.isHierarchicalFacetRefined(e))return this;var t={};return t[e]=[],this.setQueryParameters({hierarchicalFacetsRefinements:c({},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!!this.numericRefinements[e];var n=this.numericRefinements[e]&&void 0!==this.numericRefinements[e][t];if(void 0===i||!n)return n;var s=f(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())},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}))},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 o(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":10,"../functions/find":11,"../functions/intersection":15,"../functions/merge":16,"../functions/objectHasKeys":17,"../functions/omit":18,"../functions/valToNumber":20,"../utils/isValidUserToken":22,"./RefinementList":4}],6:[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,exhaustive:h,data:null})}}function r(e,t,i,n,r){return function(o,f,h){var l=o;if(h>0){var m=0;for(l=o;m<h;){var d=l&&Array.isArray(l.data)?l.data:[];l=u(d,function(e){return e.isRefined}),m++}}if(l){var v=Object.keys(f.data).map(function(e){return[e,f.data[e]]}).filter(function(e){return s(e[0],l.path||i,r,t,i,n)});l.data=c(v.map(function(e){var i=e[0];return a(e[1],i,t,r,f.exhaustive)}),e[0],e[1])}return o}}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,count:e,isRefined:n===t||0===n.indexOf(t+i),exhaustive:r,data:null}}t.exports=n;var c=e("../functions/orderBy"),u=e("../functions/find"),o=e("../functions/formatSort")},{"../functions/find":11,"../functions/formatSort":13,"../functions/orderBy":19}],7:[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){var i=t[0];this._rawResults=t;var a=this;Object.keys(i).forEach(function(e){a[e]=i[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 c=e.getRefinedDisjunctiveFacets(),u=n(e.facets),o=n(e.disjunctiveFacets),f=1,h=i.facets||{};Object.keys(h).forEach(function(t){var n=h[t],c=s(e.hierarchicalFacets,t);if(c){var f=c.attributes.indexOf(t),l=F(e.hierarchicalFacets,function(e){return e.name===c.name});a.hierarchicalFacets[l][f]={attribute:t,data:n,exhaustive:i.exhaustiveFacetsCount}}else{var m,d=-1!==e.disjunctiveFacets.indexOf(t),v=-1!==e.facets.indexOf(t);d&&(m=o[t],a.disjunctiveFacets[m]={name:t,data:n,exhaustive:i.exhaustiveFacetsCount},r(a.disjunctiveFacets[m],i.facets_stats,t)),v&&(m=u[t],a.facets[m]={name:t,data:n,exhaustive:i.exhaustiveFacetsCount},r(a.facets[m],i.facets_stats,t))}}),this.hierarchicalFacets=y(this.hierarchicalFacets),c.forEach(function(n){var s=t[f],c=s&&s.facets?s.facets:{},u=e.getHierarchicalFacetByName(n);Object.keys(c).forEach(function(t){var n,f=c[t];if(u){n=F(e.hierarchicalFacets,function(e){return e.name===u.name});var h=F(a.hierarchicalFacets[n],function(e){return e.attribute===t});if(-1===h)return;a.hierarchicalFacets[n][h].data=v({},a.hierarchicalFacets[n][h].data,f)}else{n=o[t];var l=i.facets&&i.facets[t]||{};a.disjunctiveFacets[n]={name:t,data:p({},f,l),exhaustive:s.exhaustiveFacetsCount},r(a.disjunctiveFacets[n],s.facets_stats,t),e.disjunctiveFacetsRefinements[t]&&e.disjunctiveFacetsRefinements[t].forEach(function(i){!a.disjunctiveFacets[n].data[i]&&e.disjunctiveFacetsRefinements[t].indexOf(i)>-1&&(a.disjunctiveFacets[n].data[i]=0)})}}),f++}),e.getRefinedHierarchicalFacets().forEach(function(i){var n=e.getHierarchicalFacetByName(i),r=e._getHierarchicalFacetSeparator(n),s=e.getHierarchicalRefinement(i);if(!(0===s.length||s[0].split(r).length<2)){var c=t[f],u=c&&c.facets?c.facets:{};Object.keys(u).forEach(function(t){var i=u[t],c=F(e.hierarchicalFacets,function(e){return e.name===n.name}),o=F(a.hierarchicalFacets[c],function(e){return e.attribute===t});if(-1!==o){var f={};if(s.length>0){var h=s[0].split(r)[0];f[h]=a.hierarchicalFacets[c][o].data[h]}a.hierarchicalFacets[c][o].data=p(f,i,a.hierarchicalFacets[c][o].data)}}),f++}}),Object.keys(e.facetsExcludes).forEach(function(t){var n=e.facetsExcludes[t],r=u[t];a.facets[r]={name:t,data:i.facets[t],exhaustive:i.exhaustiveFacetsCount},n.forEach(function(e){a.facets[r]=a.facets[r]||{name:t},a.facets[r].data=a.facets[r].data||{},a.facets[r].data[e]=0})}),this.hierarchicalFacets=this.hierarchicalFacets.map(_(e)),this.facets=y(this.facets),this.disjunctiveFacets=y(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){return{name:i,count:n.data[i],isRefined:e._state.isFacetRefined(t,i),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){return{name:i,count:r.data[i],isRefined:e._state.isDisjunctiveFacetRefined(t,i)}}):[]}if(e._state.isHierarchicalFacet(t))return R(e.hierarchicalFacets,i)}function u(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 u(e,t,i,n+1)}),s=e(r,i[n]);return p({data:s},t)}function o(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(g(n,a[0],a[1])))}function h(e,t){return e.renderingContent&&e.renderingContent.facetOrdering&&e.renderingContent.facetOrdering.values&&e.renderingContent.facetOrdering.values[t]}function l(e,t){var i=R(e,function(e){return e.name===t});return i&&i.stats}function m(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 d(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/merge"),p=e("../functions/defaultsPure"),g=e("../functions/orderBy"),y=e("../functions/compact"),R=e("../functions/find"),F=e("../functions/findIndex"),j=e("../functions/formatSort"),_=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=p({},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 u(function(e,t){if(r.facetOrdering){var i=h(s,t);if(Boolean(i))return f(e,i)}if(Array.isArray(r.sortBy)){var n=j(r.sortBy,a.DEFAULT_SORT);return g(e,n[0],n[1])}if("function"==typeof r.sortBy)return o(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)?l(this.facets,e):this._state.isDisjunctiveFacet(e)?l(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(m(e,"facet",n,r,t.facets))})}),Object.keys(e.facetsExcludes).forEach(function(n){e.facetsExcludes[n].forEach(function(r){i.push(m(e,"exclude",n,r,t.facets))})}),Object.keys(e.disjunctiveFacetsRefinements).forEach(function(n){e.disjunctiveFacetsRefinements[n].forEach(function(r){i.push(m(e,"disjunctive",n,r,t.disjunctiveFacets))})}),Object.keys(e.hierarchicalFacetsRefinements).forEach(function(n){e.hierarchicalFacetsRefinements[n].forEach(function(r){i.push(d(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":9,"../functions/defaultsPure":10,"../functions/find":11,"../functions/findIndex":12,"../functions/formatSort":13,"../functions/merge":16,"../functions/orderBy":19,"./generate-hierarchical-tree":6}],8:[function(e,t,i){"use strict";function n(e,t,i){"function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+v+")"),this.setClient(e);var n=i||{};n.index=t,this.state=a.make(n),this.lastResults=null,this._queryId=0,this._lastQueryIdReceived=-1,this.derivedHelpers=[],this._currentNbQueries=0}
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("./SearchParameters"),c=e("./SearchResults"),u=e("./DerivedHelper"),o=e("./requestBuilder"),f=e("events"),h=e("./functions/inherits"),l=e("./functions/objectHasKeys"),m=e("./functions/omit"),d=e("./functions/merge"),v=e("./version");h(n,f.EventEmitter),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 o._getHitsSearchParams(e)},n.prototype.searchOnce=function(e,t){var i=e?this.state.setQueryParameters(e):this.state,n=o._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 c(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 c(i,e.results),state:i,_originalResponse:e}},function(e){throw r._currentNbQueries--,0===r._currentNbQueries&&r.emit("searchQueueEmpty"),e})},n.prototype.findAnswers=function(e){var t=this.state,i=this.derivedHelpers[0];if(!i)return Promise.resolve([]);var n=i.getModifiedState(t),r=d({attributesForPrediction:e.attributesForPrediction,nbHits:e.nbHits},{params:m(o._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;if(!r&&"function"!=typeof this.client.initIndex)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 s=this.state.setQueryParameters(n||{}),a=s.isDisjunctiveFacet(e),c=o.getSearchForFacetQuery(e,t,i,s);this._currentNbQueries++;var u=this;return this.emit("searchForFacetValues",{state:s,facet:e,query:t}),(r?this.client.searchForFacetValues([{indexName:s.index,params:c}]):this.client.initIndex(s.index).searchForFacetValues(c)).then(function(t){return u._currentNbQueries--,0===u._currentNbQueries&&u.emit("searchQueueEmpty"),t=Array.isArray(t)?t[0]:t,t.facetHits.forEach(function(t){t.isRefined=a?s.isDisjunctiveFacetRefined(e,t.value):s.isFacetRefined(e,t.value)}),t},function(e){throw u._currentNbQueries--,0===u._currentNbQueries&&u.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:a.make(e),isPageReset:!1}),this},n.prototype.overrideStateWithoutTriggeringChangeEvent=function(e){return this.state=new a(e),this},n.prototype.hasRefinements=function(e){return!!l(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=o._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=o._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++;this._currentNbQueries++;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){if(!(t<this._lastQueryIdReceived)){this._currentNbQueries-=t-this._lastQueryIdReceived,this._lastQueryIdReceived=t,0===this._currentNbQueries&&this.emit("searchQueueEmpty");var n=i.results.slice();e.forEach(function(e){var t=e.state,i=e.queriesCount,r=e.helper,s=n.splice(0,i),a=r.lastResults=new c(t,s);r.emit("result",{results:a,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.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 ("+v+")"),this.client=e,this)},n.prototype.getClient=function(){return this.client},n.prototype.derive=function(e){var t=new u(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,"./SearchParameters":5,"./SearchResults":7,"./functions/inherits":14,"./functions/merge":16,"./functions/objectHasKeys":17,"./functions/omit":18,"./requestBuilder":21,"./version":23,events:2}],9:[function(e,t,i){"use strict";t.exports=function(e){return Array.isArray(e)?e.filter(Boolean):[]}},{}],10:[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},{})}},{}],11:[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]}},{}],12:[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}},{}],13:[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":11}],14:[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},{}],15:[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},{}],16:[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)){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},{}],17:[function(e,t,i){"use strict";function n(e){return e&&Object.keys(e).length>0}t.exports=n},{}],18:[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},{}],19:[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},{}],20:[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},{}],21:[function(e,t,i){"use strict";var n=e("./functions/merge"),r={_getQueries:function(e,t){var i=[];return i.push({indexName:e,params:r._getHitsSearchParams(t)}),t.getRefinedDisjunctiveFacets().forEach(function(n){i.push({indexName:e,params:r._getDisjunctiveFacetSearchParams(t,n)})}),t.getRefinedHierarchicalFacets().forEach(function(n){var s=t.getHierarchicalFacetByName(n),a=t.getHierarchicalRefinement(n),c=t._getHierarchicalFacetSeparator(s);a.length>0&&a[0].split(c).length>1&&i.push({indexName:e,params:r._getDisjunctiveFacetSearchParams(t,n,!0)})}),i},_getHitsSearchParams:function(e){var t=e.facets.concat(e.disjunctiveFacets).concat(r._getHitsHierarchicalFacetsAttributes(e)),i=r._getFacetFilters(e),s=r._getNumericFilters(e),a=r._getTagFilters(e),c={facets:t.indexOf("*")>-1?["*"]:t,tagFilters:a};return i.length>0&&(c.facetFilters=i),s.length>0&&(c.numericFilters=s),n({},e.getQueryParams(),c)},_getDisjunctiveFacetSearchParams:function(e,t,i){var s=r._getFacetFilters(e,t,i),a=r._getNumericFilters(e,t),c=r._getTagFilters(e),u={hitsPerPage:1,page:0,attributesToRetrieve:[],attributesToHighlight:[],attributesToSnippet:[],tagFilters:c,analytics:!1,clickAnalytics:!1},o=e.getHierarchicalFacetByName(t);return u.facets=o?r._getDisjunctiveHierarchicalFacetAttribute(e,o,i):t,a.length>0&&(u.numericFilters=a),s.length>0&&(u.facetFilters=s),n({},e.getQueryParams(),u)},_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).forEach(function(e){(r[e]||[]).forEach(function(t){n.push(e+":"+t)})});var s=e.facetsExcludes||{};Object.keys(s).forEach(function(e){(s[e]||[]).forEach(function(t){n.push(e+":-"+t)})});var a=e.disjunctiveFacetsRefinements||{};Object.keys(a).forEach(function(e){var i=a[e]||[];if(e!==t&&i&&0!==i.length){var r=[];i.forEach(function(t){r.push(e+":"+t)}),n.push(r)}});var c=e.hierarchicalFacetsRefinements||{};return Object.keys(c).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,s){var a=s.isDisjunctiveFacet(e)?s.clearRefinements(e):s,c={facetQuery:t,facetName:e};return"number"==typeof i&&(c.maxFacetHits=i),n({},r._getHitsSearchParams(a),c)}};t.exports=r},{"./functions/merge":16}],22:[function(e,t,i){"use strict";t.exports=function(e){return null!==e&&/^[a-zA-Z0-9_-]{1,64}$/.test(e)}},{}],23:[function(e,t,i){"use strict";t.exports="3.6.1"},{}]},{},[1])(1)});
!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 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){var i=t[a][1][e];return r(i||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}({1:[function(e,t,i){"use strict";function n(e,t,i){return new r(e,t,i)}var r=e("./src/algoliasearch.helper"),s=e("./src/SearchParameters"),a=e("./src/SearchResults");n.version=e("./src/version.js"),n.AlgoliaSearchHelper=r,n.SearchParameters=s,n.SearchResults=a,t.exports=n},{"./src/SearchParameters":5,"./src/SearchResults":7,"./src/algoliasearch.helper":8,"./src/version.js":23}],2:[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.EventEmitter=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)}},{}],3:[function(e,t,i){"use strict";function n(e,t){this.main=e,this.fn=t,this.lastResults=null}var r=e("events");e("../functions/inherits")(n,r.EventEmitter),n.prototype.detach=function(){this.removeAllListeners(),this.main.detachDerivedHelper(this)},n.prototype.getModifiedState=function(e){return this.fn(e)},t.exports=n},{"../functions/inherits":14,events:2}],4:[function(e,t,i){"use strict";var n=e("../functions/defaultsPure"),r=e("../functions/omit"),s=e("../functions/objectHasKeys"),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 s(e)?{}:e;if("string"==typeof t)return r(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=!!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":10,"../functions/objectHasKeys":17,"../functions/omit":18}],5:[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 o(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/merge"),c=e("../functions/defaultsPure"),u=e("../functions/intersection"),o=e("../functions/find"),f=e("../functions/valToNumber"),h=e("../functions/omit"),l=e("../functions/objectHasKeys"),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 a({},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&&l(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."):l(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=f(i);if(this.isNumericRefined(e,t,n))return this;var r=a({},this.numericRefinements);return r[e]=a({},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){return void 0!==i?this.isNumericRefined(e,t,i)?this.setQueryParameters({numericRefinements:this._clearNumericRefinements(function(r,s){return s===e&&r.op===t&&n(r.val,f(i))})}):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 l(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:c({},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:c({},i,this.hierarchicalFacetsRefinements)})},removeHierarchicalFacetRefinement:function(e){if(!this.isHierarchicalFacetRefined(e))return this;var t={};return t[e]=[],this.setQueryParameters({hierarchicalFacetsRefinements:c({},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!!this.numericRefinements[e];var n=this.numericRefinements[e]&&void 0!==this.numericRefinements[e][t];if(void 0===i||!n)return n;var s=f(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())},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}))},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 o(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":10,"../functions/find":11,"../functions/intersection":15,"../functions/merge":16,"../functions/objectHasKeys":17,"../functions/omit":18,"../functions/valToNumber":20,"../utils/isValidUserToken":22,"./RefinementList":4}],6:[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,exhaustive:h,data:null})}}function r(e,t,i,n,r){return function(o,f,h){var l=o;if(h>0){var m=0;for(l=o;m<h;){var d=l&&Array.isArray(l.data)?l.data:[];l=u(d,function(e){return e.isRefined}),m++}}if(l){var v=Object.keys(f.data).map(function(e){return[e,f.data[e]]}).filter(function(e){return s(e[0],l.path||i,r,t,i,n)});l.data=c(v.map(function(e){var i=e[0];return a(e[1],i,t,r,f.exhaustive)}),e[0],e[1])}return o}}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,count:e,isRefined:n===t||0===n.indexOf(t+i),exhaustive:r,data:null}}t.exports=n;var c=e("../functions/orderBy"),u=e("../functions/find"),o=e("../functions/formatSort")},{"../functions/find":11,"../functions/formatSort":13,"../functions/orderBy":19}],7:[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){var i=t[0];this._rawResults=t;var a=this;Object.keys(i).forEach(function(e){a[e]=i[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 c=e.getRefinedDisjunctiveFacets(),u=n(e.facets),o=n(e.disjunctiveFacets),f=1,h=i.facets||{};Object.keys(h).forEach(function(t){var n=h[t],c=s(e.hierarchicalFacets,t);if(c){var f=c.attributes.indexOf(t),l=F(e.hierarchicalFacets,function(e){return e.name===c.name});a.hierarchicalFacets[l][f]={attribute:t,data:n,exhaustive:i.exhaustiveFacetsCount}}else{var m,d=-1!==e.disjunctiveFacets.indexOf(t),v=-1!==e.facets.indexOf(t);d&&(m=o[t],a.disjunctiveFacets[m]={name:t,data:n,exhaustive:i.exhaustiveFacetsCount},r(a.disjunctiveFacets[m],i.facets_stats,t)),v&&(m=u[t],a.facets[m]={name:t,data:n,exhaustive:i.exhaustiveFacetsCount},r(a.facets[m],i.facets_stats,t))}}),this.hierarchicalFacets=y(this.hierarchicalFacets),c.forEach(function(n){var s=t[f],c=s&&s.facets?s.facets:{},u=e.getHierarchicalFacetByName(n);Object.keys(c).forEach(function(t){var n,f=c[t];if(u){n=F(e.hierarchicalFacets,function(e){return e.name===u.name});var h=F(a.hierarchicalFacets[n],function(e){return e.attribute===t});if(-1===h)return;a.hierarchicalFacets[n][h].data=v({},a.hierarchicalFacets[n][h].data,f)}else{n=o[t];var l=i.facets&&i.facets[t]||{};a.disjunctiveFacets[n]={name:t,data:p({},f,l),exhaustive:s.exhaustiveFacetsCount},r(a.disjunctiveFacets[n],s.facets_stats,t),e.disjunctiveFacetsRefinements[t]&&e.disjunctiveFacetsRefinements[t].forEach(function(i){!a.disjunctiveFacets[n].data[i]&&e.disjunctiveFacetsRefinements[t].indexOf(i)>-1&&(a.disjunctiveFacets[n].data[i]=0)})}}),f++}),e.getRefinedHierarchicalFacets().forEach(function(i){var n=e.getHierarchicalFacetByName(i),r=e._getHierarchicalFacetSeparator(n),s=e.getHierarchicalRefinement(i);if(!(0===s.length||s[0].split(r).length<2)){var c=t[f],u=c&&c.facets?c.facets:{};Object.keys(u).forEach(function(t){var i=u[t],c=F(e.hierarchicalFacets,function(e){return e.name===n.name}),o=F(a.hierarchicalFacets[c],function(e){return e.attribute===t});if(-1!==o){var f={};if(s.length>0){var h=s[0].split(r)[0];f[h]=a.hierarchicalFacets[c][o].data[h]}a.hierarchicalFacets[c][o].data=p(f,i,a.hierarchicalFacets[c][o].data)}}),f++}}),Object.keys(e.facetsExcludes).forEach(function(t){var n=e.facetsExcludes[t],r=u[t];a.facets[r]={name:t,data:i.facets[t],exhaustive:i.exhaustiveFacetsCount},n.forEach(function(e){a.facets[r]=a.facets[r]||{name:t},a.facets[r].data=a.facets[r].data||{},a.facets[r].data[e]=0})}),this.hierarchicalFacets=this.hierarchicalFacets.map(j(e)),this.facets=y(this.facets),this.disjunctiveFacets=y(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){return{name:i,count:n.data[i],isRefined:e._state.isFacetRefined(t,i),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){return{name:i,count:r.data[i],isRefined:e._state.isDisjunctiveFacetRefined(t,i)}}):[]}if(e._state.isHierarchicalFacet(t))return R(e.hierarchicalFacets,i)}function u(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 u(e,t,i,n+1)}),s=e(r,i[n]);return p({data:s},t)}function o(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(g(n,a[0],a[1])))}function h(e,t){return e.renderingContent&&e.renderingContent.facetOrdering&&e.renderingContent.facetOrdering.values&&e.renderingContent.facetOrdering.values[t]}function l(e,t){var i=R(e,function(e){return e.name===t});return i&&i.stats}function m(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 d(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/merge"),p=e("../functions/defaultsPure"),g=e("../functions/orderBy"),y=e("../functions/compact"),R=e("../functions/find"),F=e("../functions/findIndex"),_=e("../functions/formatSort"),j=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=p({},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 u(function(e,t){if(r.facetOrdering){var i=h(s,t);if(Boolean(i))return f(e,i)}if(Array.isArray(r.sortBy)){var n=_(r.sortBy,a.DEFAULT_SORT);return g(e,n[0],n[1])}if("function"==typeof r.sortBy)return o(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)?l(this.facets,e):this._state.isDisjunctiveFacet(e)?l(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(m(e,"facet",n,r,t.facets))})}),Object.keys(e.facetsExcludes).forEach(function(n){e.facetsExcludes[n].forEach(function(r){i.push(m(e,"exclude",n,r,t.facets))})}),Object.keys(e.disjunctiveFacetsRefinements).forEach(function(n){e.disjunctiveFacetsRefinements[n].forEach(function(r){i.push(m(e,"disjunctive",n,r,t.disjunctiveFacets))})}),Object.keys(e.hierarchicalFacetsRefinements).forEach(function(n){e.hierarchicalFacetsRefinements[n].forEach(function(r){i.push(d(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":9,"../functions/defaultsPure":10,"../functions/find":11,"../functions/findIndex":12,"../functions/formatSort":13,"../functions/merge":16,"../functions/orderBy":19,"./generate-hierarchical-tree":6}],8:[function(e,t,i){"use strict";function n(e,t,i){"function"==typeof e.addAlgoliaAgent&&e.addAlgoliaAgent("JS Helper ("+v+")"),this.setClient(e);var n=i||{};n.index=t,this.state=a.make(n),this.lastResults=null,this._queryId=0,this._lastQueryIdReceived=-1,this.derivedHelpers=[],this._currentNbQueries=0}
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("./SearchParameters"),c=e("./SearchResults"),u=e("./DerivedHelper"),o=e("./requestBuilder"),f=e("events"),h=e("./functions/inherits"),l=e("./functions/objectHasKeys"),m=e("./functions/omit"),d=e("./functions/merge"),v=e("./version");h(n,f.EventEmitter),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 o._getHitsSearchParams(e)},n.prototype.searchOnce=function(e,t){var i=e?this.state.setQueryParameters(e):this.state,n=o._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 c(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 c(i,e.results),state:i,_originalResponse:e}},function(e){throw r._currentNbQueries--,0===r._currentNbQueries&&r.emit("searchQueueEmpty"),e})},n.prototype.findAnswers=function(e){var t=this.state,i=this.derivedHelpers[0];if(!i)return Promise.resolve([]);var n=i.getModifiedState(t),r=d({attributesForPrediction:e.attributesForPrediction,nbHits:e.nbHits},{params:m(o._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;if(!r&&"function"!=typeof this.client.initIndex)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 s=this.state.setQueryParameters(n||{}),a=s.isDisjunctiveFacet(e),c=o.getSearchForFacetQuery(e,t,i,s);this._currentNbQueries++;var u=this;return this.emit("searchForFacetValues",{state:s,facet:e,query:t}),(r?this.client.searchForFacetValues([{indexName:s.index,params:c}]):this.client.initIndex(s.index).searchForFacetValues(c)).then(function(t){return u._currentNbQueries--,0===u._currentNbQueries&&u.emit("searchQueueEmpty"),t=Array.isArray(t)?t[0]:t,t.facetHits.forEach(function(t){t.isRefined=a?s.isDisjunctiveFacetRefined(e,t.value):s.isFacetRefined(e,t.value)}),t},function(e){throw u._currentNbQueries--,0===u._currentNbQueries&&u.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:a.make(e),isPageReset:!1}),this},n.prototype.overrideStateWithoutTriggeringChangeEvent=function(e){return this.state=new a(e),this},n.prototype.hasRefinements=function(e){return!!l(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=o._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=o._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++;this._currentNbQueries++;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){if(!(t<this._lastQueryIdReceived)){this._currentNbQueries-=t-this._lastQueryIdReceived,this._lastQueryIdReceived=t,0===this._currentNbQueries&&this.emit("searchQueueEmpty");var n=i.results.slice();e.forEach(function(e){var t=e.state,i=e.queriesCount,r=e.helper,s=n.splice(0,i),a=r.lastResults=new c(t,s);r.emit("result",{results:a,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.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 ("+v+")"),this.client=e,this)},n.prototype.getClient=function(){return this.client},n.prototype.derive=function(e){var t=new u(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,"./SearchParameters":5,"./SearchResults":7,"./functions/inherits":14,"./functions/merge":16,"./functions/objectHasKeys":17,"./functions/omit":18,"./requestBuilder":21,"./version":23,events:2}],9:[function(e,t,i){"use strict";t.exports=function(e){return Array.isArray(e)?e.filter(Boolean):[]}},{}],10:[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},{})}},{}],11:[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]}},{}],12:[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}},{}],13:[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":11}],14:[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},{}],15:[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},{}],16:[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){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},{}],17:[function(e,t,i){"use strict";function n(e){return e&&Object.keys(e).length>0}t.exports=n},{}],18:[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},{}],19:[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},{}],20:[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},{}],21:[function(e,t,i){"use strict";var n=e("./functions/merge"),r={_getQueries:function(e,t){var i=[];return i.push({indexName:e,params:r._getHitsSearchParams(t)}),t.getRefinedDisjunctiveFacets().forEach(function(n){i.push({indexName:e,params:r._getDisjunctiveFacetSearchParams(t,n)})}),t.getRefinedHierarchicalFacets().forEach(function(n){var s=t.getHierarchicalFacetByName(n),a=t.getHierarchicalRefinement(n),c=t._getHierarchicalFacetSeparator(s);a.length>0&&a[0].split(c).length>1&&i.push({indexName:e,params:r._getDisjunctiveFacetSearchParams(t,n,!0)})}),i},_getHitsSearchParams:function(e){var t=e.facets.concat(e.disjunctiveFacets).concat(r._getHitsHierarchicalFacetsAttributes(e)),i=r._getFacetFilters(e),s=r._getNumericFilters(e),a=r._getTagFilters(e),c={facets:t.indexOf("*")>-1?["*"]:t,tagFilters:a};return i.length>0&&(c.facetFilters=i),s.length>0&&(c.numericFilters=s),n({},e.getQueryParams(),c)},_getDisjunctiveFacetSearchParams:function(e,t,i){var s=r._getFacetFilters(e,t,i),a=r._getNumericFilters(e,t),c=r._getTagFilters(e),u={hitsPerPage:1,page:0,attributesToRetrieve:[],attributesToHighlight:[],attributesToSnippet:[],tagFilters:c,analytics:!1,clickAnalytics:!1},o=e.getHierarchicalFacetByName(t);return u.facets=o?r._getDisjunctiveHierarchicalFacetAttribute(e,o,i):t,a.length>0&&(u.numericFilters=a),s.length>0&&(u.facetFilters=s),n({},e.getQueryParams(),u)},_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).forEach(function(e){(r[e]||[]).forEach(function(t){n.push(e+":"+t)})});var s=e.facetsExcludes||{};Object.keys(s).forEach(function(e){(s[e]||[]).forEach(function(t){n.push(e+":-"+t)})});var a=e.disjunctiveFacetsRefinements||{};Object.keys(a).forEach(function(e){var i=a[e]||[];if(e!==t&&i&&0!==i.length){var r=[];i.forEach(function(t){r.push(e+":"+t)}),n.push(r)}});var c=e.hierarchicalFacetsRefinements||{};return Object.keys(c).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,s){var a=s.isDisjunctiveFacet(e)?s.clearRefinements(e):s,c={facetQuery:t,facetName:e};return"number"==typeof i&&(c.maxFacetHits=i),n({},r._getHitsSearchParams(a),c)}};t.exports=r},{"./functions/merge":16}],22:[function(e,t,i){"use strict";t.exports=function(e){return null!==e&&/^[a-zA-Z0-9_-]{1,64}$/.test(e)}},{}],23:[function(e,t,i){"use strict";t.exports="3.6.2"},{}]},{},[1])(1)});
//# sourceMappingURL=dist/algoliasearch.helper.min.js.map
{
"name": "algoliasearch-helper",
"version": "3.6.1",
"version": "3.6.2",
"description": "Helper for implementing advanced search features with algolia",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -24,3 +24,6 @@ 'use strict';

for (var key in source) {
if (!Object.prototype.hasOwnProperty.call(source, key)) {
if (
!Object.prototype.hasOwnProperty.call(source, key) ||
key === '__proto__'
) {
continue;

@@ -36,3 +39,6 @@ }

if (isObjectOrArrayOrFunction(targetVal) && isObjectOrArrayOrFunction(sourceVal)) {
if (
isObjectOrArrayOrFunction(targetVal) &&
isObjectOrArrayOrFunction(sourceVal)
) {
target[key] = _merge(targetVal, sourceVal);

@@ -39,0 +45,0 @@ } else {

'use strict';
module.exports = '3.6.1';
module.exports = '3.6.2';

Sorry, the diff of this file is not supported yet

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc