{"version":3,"file":"ReactInstantSearchCore.min.js","sources":["../../../../node_modules/@babel/runtime/helpers/esm/extends.js","../../../../node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js","../../../../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js","../../../../node_modules/@babel/runtime/helpers/esm/defineProperty.js","../../../../node_modules/@babel/runtime/helpers/esm/objectSpread.js","../../../../node_modules/@babel/runtime/helpers/esm/classCallCheck.js","../../../../node_modules/@babel/runtime/helpers/esm/createClass.js","../../../../node_modules/@babel/runtime/helpers/esm/typeof.js","../../../../node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js","../../../../node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js","../../../../node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js","../../../../node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js","../../../../node_modules/@babel/runtime/helpers/esm/inherits.js","../../../../node_modules/react-fast-compare/index.js","../../src/core/utils.ts","../../src/core/context.ts","../../src/core/createConnector.tsx","../../src/core/highlight.js","../../src/core/version.js","../../src/core/indexUtils.js","../../src/connectors/connectConfigure.js","../../src/widgets/Configure.js","../../../../node_modules/@babel/runtime/helpers/esm/toConsumableArray.js","../../../../node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js","../../../../node_modules/@babel/runtime/helpers/esm/iterableToArray.js","../../../../node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js","../../../../node_modules/algoliasearch-helper/src/functions/merge.js","../../../../node_modules/algoliasearch-helper/src/functions/defaultsPure.js","../../../../node_modules/algoliasearch-helper/src/functions/intersection.js","../../../../node_modules/algoliasearch-helper/src/functions/find.js","../../../../node_modules/algoliasearch-helper/src/functions/valToNumber.js","../../../../node_modules/algoliasearch-helper/src/functions/omit.js","../../../../node_modules/algoliasearch-helper/src/functions/objectHasKeys.js","../../../../node_modules/algoliasearch-helper/src/SearchParameters/RefinementList.js","../../../../node_modules/algoliasearch-helper/src/SearchParameters/index.js","../../../../node_modules/algoliasearch-helper/src/functions/orderBy.js","../../../../node_modules/algoliasearch-helper/src/functions/compact.js","../../../../node_modules/algoliasearch-helper/src/functions/findIndex.js","../../../../node_modules/algoliasearch-helper/src/functions/formatSort.js","../../../../node_modules/algoliasearch-helper/src/SearchResults/generate-hierarchical-tree.js","../../../../node_modules/algoliasearch-helper/src/SearchResults/index.js","../../../../node_modules/events/events.js","../../../../node_modules/algoliasearch-helper/src/functions/inherits.js","../../../../node_modules/algoliasearch-helper/src/DerivedHelper/index.js","../../../../node_modules/algoliasearch-helper/src/requestBuilder.js","../../../../node_modules/algoliasearch-helper/src/version.js","../../../../node_modules/algoliasearch-helper/src/algoliasearch.helper.js","../../../../node_modules/algoliasearch-helper/index.js","../../src/connectors/connectConfigureRelatedItems.ts","../../../../node_modules/rollup-plugin-node-globals/src/global.js","../../../../node_modules/process-es6/browser.js","../../../../node_modules/object-assign/index.js","../../../../node_modules/prop-types/factoryWithThrowingShims.js","../../../../node_modules/prop-types/index.js","../../../../node_modules/prop-types/lib/ReactPropTypesSecret.js","../../src/widgets/ConfigureRelatedItems.tsx","../../src/connectors/connectQueryRules.ts","../../src/widgets/QueryRuleContext.ts","../../src/widgets/Index.tsx","../../src/core/createInstantSearchManager.js","../../src/core/createWidgetsManager.js","../../src/core/createStore.ts","../../src/widgets/InstantSearch.tsx","../../src/connectors/connectAutoComplete.js","../../src/connectors/connectBreadcrumb.js","../../src/connectors/connectCurrentRefinements.js","../../src/connectors/connectGeoSearch.js","../../src/connectors/connectHierarchicalMenu.js","../../src/connectors/connectHighlight.js","../../src/connectors/connectHits.js","../../src/connectors/connectHitsPerPage.js","../../src/connectors/connectInfiniteHits.js","../../src/connectors/connectMenu.js","../../../../node_modules/@babel/runtime/helpers/esm/slicedToArray.js","../../../../node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js","../../../../node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js","../../../../node_modules/@babel/runtime/helpers/esm/nonIterableRest.js","../../src/connectors/connectNumericMenu.js","../../src/connectors/connectPagination.js","../../src/connectors/connectPoweredBy.js","../../src/connectors/connectRange.js","../../src/connectors/connectRefinementList.js","../../src/connectors/connectScrollTo.js","../../src/connectors/connectSearchBox.js","../../src/connectors/connectSortBy.js","../../src/connectors/connectStateResults.js","../../src/connectors/connectStats.js","../../src/connectors/connectToggleRefinement.js","../../src/connectors/connectHitInsights.ts","../../src/connectors/connectVoiceSearch.js","../../src/core/translatable.js"],"sourcesContent":["export default function _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}","import objectWithoutPropertiesLoose from \"./objectWithoutPropertiesLoose\";\nexport default function _objectWithoutProperties(source, excluded) {\n if (source == null) return {};\n var target = objectWithoutPropertiesLoose(source, excluded);\n var key, i;\n\n if (Object.getOwnPropertySymbols) {\n var sourceSymbolKeys = Object.getOwnPropertySymbols(source);\n\n for (i = 0; i < sourceSymbolKeys.length; i++) {\n key = sourceSymbolKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;\n target[key] = source[key];\n }\n }\n\n return target;\n}","export default function _objectWithoutPropertiesLoose(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n\n return target;\n}","export default function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}","import defineProperty from \"./defineProperty\";\nexport default function _objectSpread(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? arguments[i] : {};\n var ownKeys = Object.keys(source);\n\n if (typeof Object.getOwnPropertySymbols === 'function') {\n ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {\n return Object.getOwnPropertyDescriptor(source, sym).enumerable;\n }));\n }\n\n ownKeys.forEach(function (key) {\n defineProperty(target, key, source[key]);\n });\n }\n\n return target;\n}","export default function _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nexport default function _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}","function _typeof2(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof2(obj); }\n\nexport default function _typeof(obj) {\n if (typeof Symbol === \"function\" && _typeof2(Symbol.iterator) === \"symbol\") {\n _typeof = function _typeof(obj) {\n return _typeof2(obj);\n };\n } else {\n _typeof = function _typeof(obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : _typeof2(obj);\n };\n }\n\n return _typeof(obj);\n}","export default function _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}","import _typeof from \"../../helpers/esm/typeof\";\nimport assertThisInitialized from \"./assertThisInitialized\";\nexport default function _possibleConstructorReturn(self, call) {\n if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) {\n return call;\n }\n\n return assertThisInitialized(self);\n}","export default function _getPrototypeOf(o) {\n _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n return _getPrototypeOf(o);\n}","export default function _setPrototypeOf(o, p) {\n _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {\n o.__proto__ = p;\n return o;\n };\n\n return _setPrototypeOf(o, p);\n}","import setPrototypeOf from \"./setPrototypeOf\";\nexport default function _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n writable: true,\n configurable: true\n }\n });\n if (superClass) setPrototypeOf(subClass, superClass);\n}","/* global Map:readonly, Set:readonly, ArrayBuffer:readonly */\n\nvar hasElementType = typeof Element !== 'undefined';\nvar hasMap = typeof Map === 'function';\nvar hasSet = typeof Set === 'function';\nvar hasArrayBuffer = typeof ArrayBuffer === 'function';\n\n// Note: We **don't** need `envHasBigInt64Array` in fde es6/index.js\n\nfunction equal(a, b) {\n // START: fast-deep-equal es6/index.js 3.1.1\n if (a === b) return true;\n\n if (a && b && typeof a == 'object' && typeof b == 'object') {\n if (a.constructor !== b.constructor) return false;\n\n var length, i, keys;\n if (Array.isArray(a)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n // START: Modifications:\n // 1. Extra `has &&` helpers in initial condition allow es6 code\n // to co-exist with es5.\n // 2. Replace `for of` with es5 compliant iteration using `for`.\n // Basically, take:\n //\n // ```js\n // for (i of a.entries())\n // if (!b.has(i[0])) return false;\n // ```\n //\n // ... and convert to:\n //\n // ```js\n // it = a.entries();\n // while (!(i = it.next()).done)\n // if (!b.has(i.value[0])) return false;\n // ```\n //\n // **Note**: `i` access switches to `i.value`.\n var it;\n if (hasMap && (a instanceof Map) && (b instanceof Map)) {\n if (a.size !== b.size) return false;\n it = a.entries();\n while (!(i = it.next()).done)\n if (!b.has(i.value[0])) return false;\n it = a.entries();\n while (!(i = it.next()).done)\n if (!equal(i.value[1], b.get(i.value[0]))) return false;\n return true;\n }\n\n if (hasSet && (a instanceof Set) && (b instanceof Set)) {\n if (a.size !== b.size) return false;\n it = a.entries();\n while (!(i = it.next()).done)\n if (!b.has(i.value[0])) return false;\n return true;\n }\n // END: Modifications\n\n if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {\n length = a.length;\n if (length != b.length) return false;\n for (i = length; i-- !== 0;)\n if (a[i] !== b[i]) return false;\n return true;\n }\n\n if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;\n if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();\n if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();\n\n keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) return false;\n\n for (i = length; i-- !== 0;)\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;\n // END: fast-deep-equal\n\n // START: react-fast-compare\n // custom handling for DOM elements\n if (hasElementType && a instanceof Element) return false;\n\n // custom handling for React\n for (i = length; i-- !== 0;) {\n if (keys[i] === '_owner' && a.$$typeof) {\n // React-specific: avoid traversing React elements' _owner.\n // _owner contains circular references\n // and is not needed when comparing the actual elements (and not their owners)\n // .$$typeof and ._store on just reasonable markers of a react element\n continue;\n }\n\n // all other properties should be traversed as usual\n if (!equal(a[keys[i]], b[keys[i]])) return false;\n }\n // END: react-fast-compare\n\n // START: fast-deep-equal\n return true;\n }\n\n return a !== a && b !== b;\n}\n// end fast-deep-equal\n\nmodule.exports = function isEqual(a, b) {\n try {\n return equal(a, b);\n } catch (error) {\n if (((error.message || '').match(/stack|recursion/i))) {\n // warn on circular references, don't crash\n // browsers give this different errors name and messages:\n // chrome/safari: \"RangeError\", \"Maximum call stack size exceeded\"\n // firefox: \"InternalError\", too much recursion\"\n // edge: \"Error\", \"Out of stack space\"\n console.warn('react-fast-compare cannot handle circular refs');\n return false;\n }\n // some other error. we should definitely know about these\n throw error;\n }\n};\n","// From https://github.com/reactjs/react-redux/blob/master/src/utils/shallowEqual.js\nexport const shallowEqual = (objA, objB) => {\n if (objA === objB) {\n return true;\n }\n\n const keysA = Object.keys(objA);\n const keysB = Object.keys(objB);\n\n if (keysA.length !== keysB.length) {\n return false;\n }\n\n // Test for A's keys different from B.\n const hasOwn = Object.prototype.hasOwnProperty;\n for (let i = 0; i < keysA.length; i++) {\n if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {\n return false;\n }\n }\n\n return true;\n};\n\nexport const getDisplayName = Component =>\n Component.displayName || Component.name || 'UnknownComponent';\n\nconst resolved = Promise.resolve();\nexport const defer = f => {\n resolved.then(f);\n};\n\nconst isPlainObject = (value: unknown): value is object =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport const removeEmptyKey = (obj: object) => {\n Object.keys(obj).forEach(key => {\n const value = obj[key];\n\n if (!isPlainObject(value)) {\n return;\n }\n\n if (!objectHasKeys(value)) {\n delete obj[key];\n } else {\n removeEmptyKey(value);\n }\n });\n\n return obj;\n};\n\nexport const removeEmptyArraysFromObject = (obj: object) => {\n Object.keys(obj).forEach(key => {\n const value = obj[key];\n\n if (Array.isArray(value) && value.length === 0) {\n delete obj[key];\n }\n });\n\n return obj;\n};\n\nexport function addAbsolutePositions(hits, hitsPerPage, page) {\n return hits.map((hit, index) => ({\n ...hit,\n __position: hitsPerPage * page + index + 1,\n }));\n}\n\nexport function addQueryID(hits, queryID) {\n if (!queryID) {\n return hits;\n }\n return hits.map(hit => ({\n ...hit,\n __queryID: queryID,\n }));\n}\n\nexport function find(\n array: TItem[],\n comparator: (item: TItem) => boolean\n): TItem | undefined {\n if (!Array.isArray(array)) {\n return undefined;\n }\n\n for (let i = 0; i < array.length; i++) {\n if (comparator(array[i])) {\n return array[i];\n }\n }\n return undefined;\n}\n\nexport function objectHasKeys(object: object | undefined) {\n return object && Object.keys(object).length > 0;\n}\n\n// https://github.com/babel/babel/blob/3aaafae053fa75febb3aa45d45b6f00646e30ba4/packages/babel-helpers/src/helpers.js#L604-L620\nexport function omit(source: { [key: string]: any }, excluded: string[]) {\n if (source === null || source === undefined) {\n return {};\n }\n const target = {};\n const sourceKeys = Object.keys(source);\n for (let i = 0; i < sourceKeys.length; i++) {\n const key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) {\n // eslint-disable-next-line no-continue\n continue;\n }\n target[key] = source[key];\n }\n return target;\n}\n\n/**\n * Retrieve the value at a path of the object:\n *\n * @example\n * getPropertyByPath(\n * { test: { this: { function: [{ now: { everyone: true } }] } } },\n * 'test.this.function[0].now.everyone'\n * ); // true\n *\n * getPropertyByPath(\n * { test: { this: { function: [{ now: { everyone: true } }] } } },\n * ['test', 'this', 'function', 0, 'now', 'everyone']\n * ); // true\n *\n * @param object Source object to query\n * @param path either an array of properties, or a string form of the properties, separated by .\n */\nexport const getPropertyByPath = (object: object, path: string[] | string) =>\n (Array.isArray(path)\n ? path\n : path.replace(/\\[(\\d+)]/g, '.$1').split('.')\n ).reduce((current, key) => (current ? current[key] : undefined), object);\n\nexport function getObjectType(object: unknown): string {\n return Object.prototype.toString.call(object).slice(8, -1);\n}\n","import { createContext } from 'react';\nimport { Store } from '../core/createStore';\n\nexport type InstantSearchContext = {\n onInternalStateUpdate: (...args: any[]) => any;\n createHrefForState: (...args: any[]) => string;\n onSearchForFacetValues: (...args: any[]) => any;\n onSearchStateChange: (...args: any[]) => any;\n onSearchParameters: (...args: any[]) => any;\n store: Store;\n widgetsManager: any;\n mainTargetedIndex: string;\n};\n\nexport const {\n Consumer: InstantSearchConsumer,\n Provider: InstantSearchProvider,\n} = createContext({\n onInternalStateUpdate: () => undefined,\n createHrefForState: () => '#',\n onSearchForFacetValues: () => undefined,\n onSearchStateChange: () => undefined,\n onSearchParameters: () => undefined,\n store: {} as Store,\n widgetsManager: {},\n mainTargetedIndex: '',\n});\n\nexport type IndexContext =\n | {\n targetedIndex: string;\n }\n | undefined;\n\nexport const {\n Consumer: IndexConsumer,\n Provider: IndexProvider,\n} = createContext(undefined);\n","import React, { Component, ReactType } from 'react';\nimport isEqual from 'react-fast-compare';\nimport { shallowEqual, getDisplayName, removeEmptyKey } from './utils';\nimport {\n InstantSearchConsumer,\n InstantSearchContext,\n IndexConsumer,\n IndexContext,\n} from './context';\n\nexport type ConnectorDescription = {\n displayName: string;\n /**\n * a function to filter the local state\n */\n refine?: (...args: any[]) => any;\n /**\n * function transforming the local state to a SearchParameters\n */\n getSearchParameters?: (...args: any[]) => any;\n /**\n * metadata of the widget (for current refinements)\n */\n getMetadata?: (...args: any[]) => any;\n /**\n * hook after the state has changed\n */\n transitionState?: (...args: any[]) => any;\n /**\n * transform the state into props passed to the wrapped component.\n * Receives (props, widgetStates, searchState, metadata) and returns the local state.\n */\n getProvidedProps: (...args: any[]) => any;\n /**\n * Receives props and return the id that will be used to identify the widget\n */\n getId?: (...args: any[]) => string;\n /**\n * hook when the widget will unmount. Receives (props, searchState) and return a cleaned state.\n */\n cleanUp?: (...args: any[]) => any;\n searchForFacetValues?: (...args: any[]) => any;\n shouldComponentUpdate?: (...args: any[]) => boolean;\n /**\n * PropTypes forwarded to the wrapped component.\n */\n propTypes?: {}; // I can't find a definition for a propTypes object\n defaultProps?: {};\n};\n\ntype ConnectorProps = {\n contextValue: InstantSearchContext;\n indexContextValue?: IndexContext;\n};\n\nexport type ConnectedProps = TWidgetProps & ConnectorProps;\n\ntype ConnectorState = {\n providedProps: {};\n};\n\n/**\n * Connectors are the HOC used to transform React components\n * into InstantSearch widgets.\n * In order to simplify the construction of such connectors\n * `createConnector` takes a description and transform it into\n * a connector.\n * @param {ConnectorDescription} connectorDesc the description of the connector\n * @return {Connector} a function that wraps a component into\n * an instantsearch connected one.\n */\nexport function createConnectorWithoutContext(\n connectorDesc: ConnectorDescription\n) {\n if (!connectorDesc.displayName) {\n throw new Error(\n '`createConnector` requires you to provide a `displayName` property.'\n );\n }\n\n const isWidget =\n typeof connectorDesc.getSearchParameters === 'function' ||\n typeof connectorDesc.getMetadata === 'function' ||\n typeof connectorDesc.transitionState === 'function';\n\n return (Composed: ReactType) => {\n class Connector extends Component {\n static displayName = `${connectorDesc.displayName}(${getDisplayName(\n Composed\n )})`;\n static propTypes = connectorDesc.propTypes;\n static defaultProps = connectorDesc.defaultProps;\n\n unsubscribe?: () => void;\n unregisterWidget?: () => void;\n\n isUnmounting = false;\n\n state: ConnectorState = {\n providedProps: this.getProvidedProps(this.props),\n };\n\n constructor(props: ConnectorProps) {\n super(props);\n\n if (connectorDesc.getSearchParameters) {\n this.props.contextValue.onSearchParameters(\n connectorDesc.getSearchParameters.bind(this),\n {\n ais: this.props.contextValue,\n multiIndexContext: this.props.indexContextValue,\n },\n this.props\n );\n }\n }\n\n componentDidMount() {\n this.unsubscribe = this.props.contextValue.store.subscribe(() => {\n if (!this.isUnmounting) {\n this.setState({\n providedProps: this.getProvidedProps(this.props),\n });\n }\n });\n\n if (isWidget) {\n this.unregisterWidget = this.props.contextValue.widgetsManager.registerWidget(\n this\n );\n }\n }\n\n shouldComponentUpdate(nextProps, nextState) {\n if (typeof connectorDesc.shouldComponentUpdate === 'function') {\n return connectorDesc.shouldComponentUpdate.call(\n this,\n this.props,\n nextProps,\n this.state,\n nextState\n );\n }\n\n const propsEqual = shallowEqual(this.props, nextProps);\n\n if (\n this.state.providedProps === null ||\n nextState.providedProps === null\n ) {\n if (this.state.providedProps === nextState.providedProps) {\n return !propsEqual;\n }\n return true;\n }\n\n return (\n !propsEqual ||\n !shallowEqual(this.state.providedProps, nextState.providedProps)\n );\n }\n\n componentDidUpdate(prevProps) {\n if (!isEqual(prevProps, this.props)) {\n this.setState({\n providedProps: this.getProvidedProps(this.props),\n });\n\n if (isWidget) {\n this.props.contextValue.widgetsManager.update();\n\n if (typeof connectorDesc.transitionState === 'function') {\n this.props.contextValue.onSearchStateChange(\n connectorDesc.transitionState.call(\n this,\n this.props,\n this.props.contextValue.store.getState().widgets,\n this.props.contextValue.store.getState().widgets\n )\n );\n }\n }\n }\n }\n\n componentWillUnmount() {\n this.isUnmounting = true;\n\n if (this.unsubscribe) {\n this.unsubscribe();\n }\n\n if (this.unregisterWidget) {\n this.unregisterWidget();\n\n if (typeof connectorDesc.cleanUp === 'function') {\n const nextState = connectorDesc.cleanUp.call(\n this,\n this.props,\n this.props.contextValue.store.getState().widgets\n );\n\n this.props.contextValue.store.setState({\n ...this.props.contextValue.store.getState(),\n widgets: nextState,\n });\n\n this.props.contextValue.onSearchStateChange(\n removeEmptyKey(nextState)\n );\n }\n }\n }\n\n getProvidedProps(props) {\n const {\n widgets,\n results,\n resultsFacetValues,\n searching,\n searchingForFacetValues,\n isSearchStalled,\n metadata,\n error,\n } = this.props.contextValue.store.getState();\n\n const searchResults = {\n results,\n searching,\n searchingForFacetValues,\n isSearchStalled,\n error,\n };\n\n return connectorDesc.getProvidedProps.call(\n this,\n props,\n widgets,\n searchResults,\n metadata,\n // @MAJOR: move this attribute on the `searchResults` it doesn't\n // makes sense to have it into a separate argument. The search\n // flags are on the object why not the results?\n resultsFacetValues\n );\n }\n\n getSearchParameters(searchParameters) {\n if (typeof connectorDesc.getSearchParameters === 'function') {\n return connectorDesc.getSearchParameters.call(\n this,\n searchParameters,\n this.props,\n this.props.contextValue.store.getState().widgets\n );\n }\n\n return null;\n }\n\n getMetadata(nextWidgetsState) {\n if (typeof connectorDesc.getMetadata === 'function') {\n return connectorDesc.getMetadata.call(\n this,\n this.props,\n nextWidgetsState\n );\n }\n\n return {};\n }\n\n transitionState(prevWidgetsState, nextWidgetsState) {\n if (typeof connectorDesc.transitionState === 'function') {\n return connectorDesc.transitionState.call(\n this,\n this.props,\n prevWidgetsState,\n nextWidgetsState\n );\n }\n\n return nextWidgetsState;\n }\n\n refine = (...args) => {\n this.props.contextValue.onInternalStateUpdate(\n // refine will always be defined here because the prop is only given conditionally\n connectorDesc.refine!.call(\n this,\n this.props,\n this.props.contextValue.store.getState().widgets,\n ...args\n )\n );\n };\n\n createURL = (...args) =>\n this.props.contextValue.createHrefForState(\n // refine will always be defined here because the prop is only given conditionally\n connectorDesc.refine!.call(\n this,\n this.props,\n this.props.contextValue.store.getState().widgets,\n ...args\n )\n );\n\n searchForFacetValues = (...args) => {\n this.props.contextValue.onSearchForFacetValues(\n // searchForFacetValues will always be defined here because the prop is only given conditionally\n connectorDesc.searchForFacetValues!.call(\n this,\n this.props,\n this.props.contextValue.store.getState().widgets,\n ...args\n )\n );\n };\n\n render() {\n const { contextValue, ...props } = this.props;\n const { providedProps } = this.state;\n\n if (providedProps === null) {\n return null;\n }\n\n const refineProps =\n typeof connectorDesc.refine === 'function'\n ? { refine: this.refine, createURL: this.createURL }\n : {};\n\n const searchForFacetValuesProps =\n typeof connectorDesc.searchForFacetValues === 'function'\n ? { searchForItems: this.searchForFacetValues }\n : {};\n\n return (\n \n );\n }\n }\n\n return Connector;\n };\n}\n\nconst createConnectorWithContext = (connectorDesc: ConnectorDescription) => (\n Composed: ReactType\n) => {\n const Connector = createConnectorWithoutContext(connectorDesc)(Composed);\n\n const ConnectorWrapper: React.FC = props => (\n \n {contextValue => (\n \n {indexContextValue => (\n \n )}\n \n )}\n \n );\n\n return ConnectorWrapper;\n};\n\nexport default createConnectorWithContext;\n","import { getPropertyByPath } from './utils';\n\nexport const HIGHLIGHT_TAGS = {\n highlightPreTag: ``,\n highlightPostTag: ``,\n};\n\n/**\n * Parses an highlighted attribute into an array of objects with the string value, and\n * a boolean that indicated if this part is highlighted.\n *\n * @param {string} preTag - string used to identify the start of an highlighted value\n * @param {string} postTag - string used to identify the end of an highlighted value\n * @param {string} highlightedValue - highlighted attribute as returned by Algolia highlight feature\n * @return {object[]} - An array of {value: string, isHighlighted: boolean}.\n */\nfunction parseHighlightedAttribute({ preTag, postTag, highlightedValue = '' }) {\n const splitByPreTag = highlightedValue.split(preTag);\n const firstValue = splitByPreTag.shift();\n const elements =\n firstValue === '' ? [] : [{ value: firstValue, isHighlighted: false }];\n\n if (postTag === preTag) {\n let isHighlighted = true;\n splitByPreTag.forEach(split => {\n elements.push({ value: split, isHighlighted });\n isHighlighted = !isHighlighted;\n });\n } else {\n splitByPreTag.forEach(split => {\n const splitByPostTag = split.split(postTag);\n\n elements.push({\n value: splitByPostTag[0],\n isHighlighted: true,\n });\n\n if (splitByPostTag[1] !== '') {\n elements.push({\n value: splitByPostTag[1],\n isHighlighted: false,\n });\n }\n });\n }\n\n return elements;\n}\n\n/**\n * Find an highlighted attribute given an `attribute` and an `highlightProperty`, parses it,\n * and provided an array of objects with the string value and a boolean if this\n * value is highlighted.\n *\n * In order to use this feature, highlight must be activated in the configuration of\n * the index. The `preTag` and `postTag` attributes are respectively highlightPreTag and\n * highlightPostTag in Algolia configuration.\n *\n * @param {string} preTag - string used to identify the start of an highlighted value\n * @param {string} postTag - string used to identify the end of an highlighted value\n * @param {string} highlightProperty - the property that contains the highlight structure in the results\n * @param {string} attribute - the highlighted attribute to look for\n * @param {object} hit - the actual hit returned by Algolia.\n * @return {object[]} - An array of {value: string, isHighlighted: boolean}.\n */\nexport function parseAlgoliaHit({\n preTag = '',\n postTag = '',\n highlightProperty,\n attribute,\n hit,\n}) {\n if (!hit) throw new Error('`hit`, the matching record, must be provided');\n\n const highlightObject =\n getPropertyByPath(hit[highlightProperty], attribute) || {};\n\n if (Array.isArray(highlightObject)) {\n return highlightObject.map(item =>\n parseHighlightedAttribute({\n preTag,\n postTag,\n highlightedValue: item.value,\n })\n );\n }\n\n return parseHighlightedAttribute({\n preTag,\n postTag,\n highlightedValue: highlightObject.value,\n });\n}\n","export default '6.7.0';\n","import { omit } from './utils';\n\nexport function getIndexId(context) {\n return hasMultipleIndices(context)\n ? context.multiIndexContext.targetedIndex\n : context.ais.mainTargetedIndex;\n}\n\nexport function getResults(searchResults, context) {\n if (searchResults.results) {\n if (searchResults.results.hits) {\n return searchResults.results;\n }\n\n const indexId = getIndexId(context);\n if (searchResults.results[indexId]) {\n return searchResults.results[indexId];\n }\n }\n\n return null;\n}\n\nexport function hasMultipleIndices(context) {\n return context && context.multiIndexContext;\n}\n\n// eslint-disable-next-line max-params\nexport function refineValue(\n searchState,\n nextRefinement,\n context,\n resetPage,\n namespace\n) {\n if (hasMultipleIndices(context)) {\n const indexId = getIndexId(context);\n return namespace\n ? refineMultiIndexWithNamespace(\n searchState,\n nextRefinement,\n indexId,\n resetPage,\n namespace\n )\n : refineMultiIndex(searchState, nextRefinement, indexId, resetPage);\n } else {\n // When we have a multi index page with shared widgets we should also\n // reset their page to 1 if the resetPage is provided. Otherwise the\n // indices will always be reset\n // see: https://github.com/algolia/react-instantsearch/issues/310\n // see: https://github.com/algolia/react-instantsearch/issues/637\n if (searchState.indices && resetPage) {\n Object.keys(searchState.indices).forEach(targetedIndex => {\n searchState = refineValue(\n searchState,\n { page: 1 },\n { multiIndexContext: { targetedIndex } },\n true,\n namespace\n );\n });\n }\n return namespace\n ? refineSingleIndexWithNamespace(\n searchState,\n nextRefinement,\n resetPage,\n namespace\n )\n : refineSingleIndex(searchState, nextRefinement, resetPage);\n }\n}\n\nfunction refineMultiIndex(searchState, nextRefinement, indexId, resetPage) {\n const page = resetPage ? { page: 1 } : undefined;\n const state =\n searchState.indices && searchState.indices[indexId]\n ? {\n ...searchState.indices,\n [indexId]: {\n ...searchState.indices[indexId],\n ...nextRefinement,\n ...page,\n },\n }\n : {\n ...searchState.indices,\n [indexId]: {\n ...nextRefinement,\n ...page,\n },\n };\n\n return {\n ...searchState,\n indices: state,\n };\n}\n\nfunction refineSingleIndex(searchState, nextRefinement, resetPage) {\n const page = resetPage ? { page: 1 } : undefined;\n return { ...searchState, ...nextRefinement, ...page };\n}\n\n// eslint-disable-next-line max-params\nfunction refineMultiIndexWithNamespace(\n searchState,\n nextRefinement,\n indexId,\n resetPage,\n namespace\n) {\n const page = resetPage ? { page: 1 } : undefined;\n const state =\n searchState.indices && searchState.indices[indexId]\n ? {\n ...searchState.indices,\n [indexId]: {\n ...searchState.indices[indexId],\n [namespace]: {\n ...searchState.indices[indexId][namespace],\n ...nextRefinement,\n },\n page: 1,\n },\n }\n : {\n ...searchState.indices,\n [indexId]: {\n [namespace]: nextRefinement,\n ...page,\n },\n };\n\n return {\n ...searchState,\n indices: state,\n };\n}\n\nfunction refineSingleIndexWithNamespace(\n searchState,\n nextRefinement,\n resetPage,\n namespace\n) {\n const page = resetPage ? { page: 1 } : undefined;\n return {\n ...searchState,\n [namespace]: { ...searchState[namespace], ...nextRefinement },\n ...page,\n };\n}\n\nfunction getNamespaceAndAttributeName(id) {\n const parts = id.match(/^([^.]*)\\.(.*)/);\n const namespace = parts && parts[1];\n const attributeName = parts && parts[2];\n\n return { namespace, attributeName };\n}\n\nfunction hasRefinements({\n multiIndex,\n indexId,\n namespace,\n attributeName,\n id,\n searchState,\n}) {\n if (multiIndex && namespace) {\n return (\n searchState.indices &&\n searchState.indices[indexId] &&\n searchState.indices[indexId][namespace] &&\n Object.hasOwnProperty.call(\n searchState.indices[indexId][namespace],\n attributeName\n )\n );\n }\n\n if (multiIndex) {\n return (\n searchState.indices &&\n searchState.indices[indexId] &&\n Object.hasOwnProperty.call(searchState.indices[indexId], id)\n );\n }\n\n if (namespace) {\n return (\n searchState[namespace] &&\n Object.hasOwnProperty.call(searchState[namespace], attributeName)\n );\n }\n\n return Object.hasOwnProperty.call(searchState, id);\n}\n\nfunction getRefinements({\n multiIndex,\n indexId,\n namespace,\n attributeName,\n id,\n searchState,\n}) {\n if (multiIndex && namespace) {\n return searchState.indices[indexId][namespace][attributeName];\n }\n if (multiIndex) {\n return searchState.indices[indexId][id];\n }\n if (namespace) {\n return searchState[namespace][attributeName];\n }\n\n return searchState[id];\n}\n\nexport function getCurrentRefinementValue(\n props,\n searchState,\n context,\n id,\n defaultValue\n) {\n const indexId = getIndexId(context);\n const { namespace, attributeName } = getNamespaceAndAttributeName(id);\n const multiIndex = hasMultipleIndices(context);\n const args = {\n multiIndex,\n indexId,\n namespace,\n attributeName,\n id,\n searchState,\n };\n const hasRefinementsValue = hasRefinements(args);\n\n if (hasRefinementsValue) {\n return getRefinements(args);\n }\n\n if (props.defaultRefinement) {\n return props.defaultRefinement;\n }\n\n return defaultValue;\n}\n\nexport function cleanUpValue(searchState, context, id) {\n const indexId = getIndexId(context);\n const { namespace, attributeName } = getNamespaceAndAttributeName(id);\n\n if (hasMultipleIndices(context) && Boolean(searchState.indices)) {\n return cleanUpValueWithMultiIndex({\n attribute: attributeName,\n searchState,\n indexId,\n id,\n namespace,\n });\n }\n\n return cleanUpValueWithSingleIndex({\n attribute: attributeName,\n searchState,\n id,\n namespace,\n });\n}\n\nfunction cleanUpValueWithSingleIndex({\n searchState,\n id,\n namespace,\n attribute,\n}) {\n if (namespace) {\n return {\n ...searchState,\n [namespace]: omit(searchState[namespace], [attribute]),\n };\n }\n\n return omit(searchState, [id]);\n}\n\nfunction cleanUpValueWithMultiIndex({\n searchState,\n indexId,\n id,\n namespace,\n attribute,\n}) {\n const indexSearchState = searchState.indices[indexId];\n\n if (namespace && indexSearchState) {\n return {\n ...searchState,\n indices: {\n ...searchState.indices,\n [indexId]: {\n ...indexSearchState,\n [namespace]: omit(indexSearchState[namespace], [attribute]),\n },\n },\n };\n }\n\n if (indexSearchState) {\n return {\n ...searchState,\n indices: {\n ...searchState.indices,\n [indexId]: omit(indexSearchState, [id]),\n },\n };\n }\n\n return searchState;\n}\n","import { omit } from '../core/utils';\nimport createConnector from '../core/createConnector';\nimport {\n refineValue,\n getIndexId,\n hasMultipleIndices,\n} from '../core/indexUtils';\n\nfunction getId() {\n return 'configure';\n}\n\nexport default createConnector({\n displayName: 'AlgoliaConfigure',\n getProvidedProps() {\n return {};\n },\n getSearchParameters(searchParameters, props) {\n const { children, contextValue, indexContextValue, ...items } = props;\n return searchParameters.setQueryParameters(items);\n },\n transitionState(props, prevSearchState, nextSearchState) {\n const id = getId();\n const { children, contextValue, indexContextValue, ...items } = props;\n const propKeys = Object.keys(props);\n const nonPresentKeys = this._props\n ? Object.keys(this._props).filter(prop => propKeys.indexOf(prop) === -1)\n : [];\n this._props = props;\n const nextValue = {\n [id]: { ...omit(nextSearchState[id], nonPresentKeys), ...items },\n };\n return refineValue(nextSearchState, nextValue, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n cleanUp(props, searchState) {\n const id = getId();\n const indexId = getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n const subState =\n hasMultipleIndices({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }) && searchState.indices\n ? searchState.indices[indexId]\n : searchState;\n\n const configureKeys =\n subState && subState[id] ? Object.keys(subState[id]) : [];\n\n const configureState = configureKeys.reduce((acc, item) => {\n if (!props[item]) {\n acc[item] = subState[id][item];\n }\n return acc;\n }, {});\n\n const nextValue = { [id]: configureState };\n\n return refineValue(searchState, nextValue, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n});\n","import connectConfigure from '../connectors/connectConfigure';\n\n/**\n * Configure is a widget that lets you provide raw search parameters\n * to the Algolia API.\n *\n * Any of the props added to this widget will be forwarded to Algolia. For more information\n * on the different parameters that can be set, have a look at the\n * [reference](https://www.algolia.com/doc/api-client/javascript/search#search-parameters).\n *\n * This widget can be used either with react-dom and react-native. It will not render anything\n * on screen, only configure some parameters.\n *\n * Read more in the [Search parameters](guide/Search_parameters.html) guide.\n * @name Configure\n * @kind widget\n * @example\n * import React from 'react';\n * import algoliasearch from 'algoliasearch/lite';\n * import { InstantSearch, Configure, Hits } from 'react-instantsearch-dom';\n *\n * const searchClient = algoliasearch(\n * 'latency',\n * '6be0576ff61c053d5f9a3225e2a90f76'\n * );\n *\n * const App = () => (\n * \n * \n * \n * \n * );\n */\n\nexport default connectConfigure(function Configure() {\n return null;\n});\n","import arrayWithoutHoles from \"./arrayWithoutHoles\";\nimport iterableToArray from \"./iterableToArray\";\nimport nonIterableSpread from \"./nonIterableSpread\";\nexport default function _toConsumableArray(arr) {\n return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();\n}","export default function _arrayWithoutHoles(arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n }\n}","export default function _iterableToArray(iter) {\n if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter);\n}","export default function _nonIterableSpread() {\n throw new TypeError(\"Invalid attempt to spread non-iterable instance\");\n}","'use strict';\n\nfunction clone(value) {\n if (typeof value === 'object' && value !== null) {\n return _merge(Array.isArray(value) ? [] : {}, value);\n }\n return value;\n}\n\nfunction isObjectOrArrayOrFunction(value) {\n return (\n typeof value === 'function' ||\n Array.isArray(value) ||\n Object.prototype.toString.call(value) === '[object Object]'\n );\n}\n\nfunction _merge(target, source) {\n if (target === source) {\n return target;\n }\n\n for (var key in source) {\n if (!Object.prototype.hasOwnProperty.call(source, key)) {\n continue;\n }\n\n var sourceVal = source[key];\n var targetVal = target[key];\n\n if (typeof targetVal !== 'undefined' && typeof sourceVal === 'undefined') {\n continue;\n }\n\n if (isObjectOrArrayOrFunction(targetVal) && isObjectOrArrayOrFunction(sourceVal)) {\n target[key] = _merge(targetVal, sourceVal);\n } else {\n target[key] = clone(sourceVal);\n }\n }\n return target;\n}\n\n/**\n * This method is like Object.assign, but recursively merges own and inherited\n * enumerable keyed properties of source objects into the destination object.\n *\n * NOTE: this behaves like lodash/merge, but:\n * - does mutate functions if they are a source\n * - treats non-plain objects as plain\n * - does not work for circular objects\n * - treats sparse arrays as sparse\n * - does not convert Array-like objects (Arguments, NodeLists, etc.) to arrays\n *\n * @param {Object} object The destination object.\n * @param {...Object} [sources] The source objects.\n * @returns {Object} Returns `object`.\n */\n\nfunction merge(target) {\n if (!isObjectOrArrayOrFunction(target)) {\n target = {};\n }\n\n for (var i = 1, l = arguments.length; i < l; i++) {\n var source = arguments[i];\n\n if (isObjectOrArrayOrFunction(source)) {\n _merge(target, source);\n }\n }\n return target;\n}\n\nmodule.exports = merge;\n","'use strict';\n\n// NOTE: this behaves like lodash/defaults, but doesn't mutate the target\nmodule.exports = function defaultsPure() {\n var sources = Array.prototype.slice.call(arguments);\n return sources.reduceRight(function(acc, source) {\n Object.keys(Object(source)).forEach(function(key) {\n if (source[key] !== undefined) {\n acc[key] = source[key];\n }\n });\n return acc;\n }, {});\n};\n","'use strict';\n\nfunction intersection(arr1, arr2) {\n return arr1.filter(function(value, index) {\n return (\n arr2.indexOf(value) > -1 &&\n arr1.indexOf(value) === index /* skips duplicates */\n );\n });\n}\n\nmodule.exports = intersection;\n","'use strict';\n\n// @MAJOR can be replaced by native Array#find when we change support\nmodule.exports = function find(array, comparator) {\n if (!Array.isArray(array)) {\n return undefined;\n }\n\n for (var i = 0; i < array.length; i++) {\n if (comparator(array[i])) {\n return array[i];\n }\n }\n};\n","'use strict';\n\nfunction valToNumber(v) {\n if (typeof v === 'number') {\n return v;\n } else if (typeof v === 'string') {\n return parseFloat(v);\n } else if (Array.isArray(v)) {\n return v.map(valToNumber);\n }\n\n throw new Error('The value should be a number, a parsable string or an array of those.');\n}\n\nmodule.exports = valToNumber;\n","'use strict';\n\n// https://github.com/babel/babel/blob/3aaafae053fa75febb3aa45d45b6f00646e30ba4/packages/babel-helpers/src/helpers.js#L604-L620\nfunction _objectWithoutPropertiesLoose(source, excluded) {\n if (source === null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key;\n var i;\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n return target;\n}\n\nmodule.exports = _objectWithoutPropertiesLoose;\n","'use strict';\n\nfunction objectHasKeys(obj) {\n return obj && Object.keys(obj).length > 0;\n}\n\nmodule.exports = objectHasKeys;\n","'use strict';\n\n/**\n * Functions to manipulate refinement lists\n *\n * The RefinementList is not formally defined through a prototype but is based\n * on a specific structure.\n *\n * @module SearchParameters.refinementList\n *\n * @typedef {string[]} SearchParameters.refinementList.Refinements\n * @typedef {Object.} SearchParameters.refinementList.RefinementList\n */\n\nvar defaultsPure = require('../functions/defaultsPure');\nvar omit = require('../functions/omit');\nvar objectHasKeys = require('../functions/objectHasKeys');\n\nvar lib = {\n /**\n * Adds a refinement to a RefinementList\n * @param {RefinementList} refinementList the initial list\n * @param {string} attribute the attribute to refine\n * @param {string} value the value of the refinement, if the value is not a string it will be converted\n * @return {RefinementList} a new and updated refinement list\n */\n addRefinement: function addRefinement(refinementList, attribute, value) {\n if (lib.isRefined(refinementList, attribute, value)) {\n return refinementList;\n }\n\n var valueAsString = '' + value;\n\n var facetRefinement = !refinementList[attribute] ?\n [valueAsString] :\n refinementList[attribute].concat(valueAsString);\n\n var mod = {};\n\n mod[attribute] = facetRefinement;\n\n return defaultsPure({}, mod, refinementList);\n },\n /**\n * Removes refinement(s) for an attribute:\n * - if the value is specified removes the refinement for the value on the attribute\n * - if no value is specified removes all the refinements for this attribute\n * @param {RefinementList} refinementList the initial list\n * @param {string} attribute the attribute to refine\n * @param {string} [value] the value of the refinement\n * @return {RefinementList} a new and updated refinement lst\n */\n removeRefinement: function removeRefinement(refinementList, attribute, value) {\n if (value === undefined) {\n // we use the \"filter\" form of clearRefinement, since it leaves empty values as-is\n // the form with a string will remove the attribute completely\n return lib.clearRefinement(refinementList, function(v, f) {\n return attribute === f;\n });\n }\n\n var valueAsString = '' + value;\n\n return lib.clearRefinement(refinementList, function(v, f) {\n return attribute === f && valueAsString === v;\n });\n },\n /**\n * Toggles the refinement value for an attribute.\n * @param {RefinementList} refinementList the initial list\n * @param {string} attribute the attribute to refine\n * @param {string} value the value of the refinement\n * @return {RefinementList} a new and updated list\n */\n toggleRefinement: function toggleRefinement(refinementList, attribute, value) {\n if (value === undefined) throw new Error('toggleRefinement should be used with a value');\n\n if (lib.isRefined(refinementList, attribute, value)) {\n return lib.removeRefinement(refinementList, attribute, value);\n }\n\n return lib.addRefinement(refinementList, attribute, value);\n },\n /**\n * Clear all or parts of a RefinementList. Depending on the arguments, three\n * kinds of behavior can happen:\n * - if no attribute is provided: clears the whole list\n * - if an attribute is provided as a string: clears the list for the specific attribute\n * - if an attribute is provided as a function: discards the elements for which the function returns true\n * @param {RefinementList} refinementList the initial list\n * @param {string} [attribute] the attribute or function to discard\n * @param {string} [refinementType] optional parameter to give more context to the attribute function\n * @return {RefinementList} a new and updated refinement list\n */\n clearRefinement: function clearRefinement(refinementList, attribute, refinementType) {\n if (attribute === undefined) {\n if (!objectHasKeys(refinementList)) {\n return refinementList;\n }\n return {};\n } else if (typeof attribute === 'string') {\n return omit(refinementList, attribute);\n } else if (typeof attribute === 'function') {\n var hasChanged = false;\n\n var newRefinementList = Object.keys(refinementList).reduce(function(memo, key) {\n var values = refinementList[key] || [];\n var facetList = values.filter(function(value) {\n return !attribute(value, key, refinementType);\n });\n\n if (facetList.length !== values.length) {\n hasChanged = true;\n }\n memo[key] = facetList;\n\n return memo;\n }, {});\n\n if (hasChanged) return newRefinementList;\n return refinementList;\n }\n },\n /**\n * Test if the refinement value is used for the attribute. If no refinement value\n * is provided, test if the refinementList contains any refinement for the\n * given attribute.\n * @param {RefinementList} refinementList the list of refinement\n * @param {string} attribute name of the attribute\n * @param {string} [refinementValue] value of the filter/refinement\n * @return {boolean}\n */\n isRefined: function isRefined(refinementList, attribute, refinementValue) {\n var containsRefinements = !!refinementList[attribute] &&\n refinementList[attribute].length > 0;\n\n if (refinementValue === undefined || !containsRefinements) {\n return containsRefinements;\n }\n\n var refinementValueAsString = '' + refinementValue;\n\n return refinementList[attribute].indexOf(refinementValueAsString) !== -1;\n }\n};\n\nmodule.exports = lib;\n","'use strict';\n\nvar merge = require('../functions/merge');\nvar defaultsPure = require('../functions/defaultsPure');\nvar intersection = require('../functions/intersection');\nvar find = require('../functions/find');\nvar valToNumber = require('../functions/valToNumber');\nvar omit = require('../functions/omit');\nvar objectHasKeys = require('../functions/objectHasKeys');\n\nvar RefinementList = require('./RefinementList');\n\n/**\n * isEqual, but only for numeric refinement values, possible values:\n * - 5\n * - [5]\n * - [[5]]\n * - [[5,5],[4]]\n */\nfunction isEqualNumericRefinement(a, b) {\n if (Array.isArray(a) && Array.isArray(b)) {\n return (\n a.length === b.length &&\n a.every(function(el, i) {\n return isEqualNumericRefinement(b[i], el);\n })\n );\n }\n return a === b;\n}\n\n/**\n * like _.find but using deep equality to be able to use it\n * to find arrays.\n * @private\n * @param {any[]} array array to search into (elements are base or array of base)\n * @param {any} searchedValue the value we're looking for (base or array of base)\n * @return {any} the searched value or undefined\n */\nfunction findArray(array, searchedValue) {\n return find(array, function(currentValue) {\n return isEqualNumericRefinement(currentValue, searchedValue);\n });\n}\n\n/**\n * The facet list is the structure used to store the list of values used to\n * filter a single attribute.\n * @typedef {string[]} SearchParameters.FacetList\n */\n\n/**\n * Structure to store numeric filters with the operator as the key. The supported operators\n * are `=`, `>`, `<`, `>=`, `<=` and `!=`.\n * @typedef {Object.>} SearchParameters.OperatorList\n */\n\n/**\n * SearchParameters is the data structure that contains all the information\n * usable for making a search to Algolia API. It doesn't do the search itself,\n * nor does it contains logic about the parameters.\n * It is an immutable object, therefore it has been created in a way that each\n * changes does not change the object itself but returns a copy with the\n * modification.\n * This object should probably not be instantiated outside of the helper. It will\n * be provided when needed. This object is documented for reference as you'll\n * get it from events generated by the {@link AlgoliaSearchHelper}.\n * If need be, instantiate the Helper from the factory function {@link SearchParameters.make}\n * @constructor\n * @classdesc contains all the parameters of a search\n * @param {object|SearchParameters} newParameters existing parameters or partial object\n * for the properties of a new SearchParameters\n * @see SearchParameters.make\n * @example SearchParameters of the first query in\n * the instant search demo\n{\n \"query\": \"\",\n \"disjunctiveFacets\": [\n \"customerReviewCount\",\n \"category\",\n \"salePrice_range\",\n \"manufacturer\"\n ],\n \"maxValuesPerFacet\": 30,\n \"page\": 0,\n \"hitsPerPage\": 10,\n \"facets\": [\n \"type\",\n \"shipping\"\n ]\n}\n */\nfunction SearchParameters(newParameters) {\n var params = newParameters ? SearchParameters._parseNumbers(newParameters) : {};\n\n /**\n * This attribute contains the list of all the conjunctive facets\n * used. This list will be added to requested facets in the\n * [facets attribute](https://www.algolia.com/doc/rest-api/search#param-facets) sent to algolia.\n * @member {string[]}\n */\n this.facets = params.facets || [];\n /**\n * This attribute contains the list of all the disjunctive facets\n * used. This list will be added to requested facets in the\n * [facets attribute](https://www.algolia.com/doc/rest-api/search#param-facets) sent to algolia.\n * @member {string[]}\n */\n this.disjunctiveFacets = params.disjunctiveFacets || [];\n /**\n * This attribute contains the list of all the hierarchical facets\n * used. This list will be added to requested facets in the\n * [facets attribute](https://www.algolia.com/doc/rest-api/search#param-facets) sent to algolia.\n * Hierarchical facets are a sub type of disjunctive facets that\n * let you filter faceted attributes hierarchically.\n * @member {string[]|object[]}\n */\n this.hierarchicalFacets = params.hierarchicalFacets || [];\n\n // Refinements\n /**\n * This attribute contains all the filters that need to be\n * applied on the conjunctive facets. Each facet must be properly\n * defined in the `facets` attribute.\n *\n * The key is the name of the facet, and the `FacetList` contains all\n * filters selected for the associated facet name.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `facetFilters` attribute.\n * @member {Object.}\n */\n this.facetsRefinements = params.facetsRefinements || {};\n /**\n * This attribute contains all the filters that need to be\n * excluded from the conjunctive facets. Each facet must be properly\n * defined in the `facets` attribute.\n *\n * The key is the name of the facet, and the `FacetList` contains all\n * filters excluded for the associated facet name.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `facetFilters` attribute.\n * @member {Object.}\n */\n this.facetsExcludes = params.facetsExcludes || {};\n /**\n * This attribute contains all the filters that need to be\n * applied on the disjunctive facets. Each facet must be properly\n * defined in the `disjunctiveFacets` attribute.\n *\n * The key is the name of the facet, and the `FacetList` contains all\n * filters selected for the associated facet name.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `facetFilters` attribute.\n * @member {Object.}\n */\n this.disjunctiveFacetsRefinements = params.disjunctiveFacetsRefinements || {};\n /**\n * This attribute contains all the filters that need to be\n * applied on the numeric attributes.\n *\n * The key is the name of the attribute, and the value is the\n * filters to apply to this attribute.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `numericFilters` attribute.\n * @member {Object.}\n */\n this.numericRefinements = params.numericRefinements || {};\n /**\n * This attribute contains all the tags used to refine the query.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `tagFilters` attribute.\n * @member {string[]}\n */\n this.tagRefinements = params.tagRefinements || [];\n /**\n * This attribute contains all the filters that need to be\n * applied on the hierarchical facets. Each facet must be properly\n * defined in the `hierarchicalFacets` attribute.\n *\n * The key is the name of the facet, and the `FacetList` contains all\n * filters selected for the associated facet name. The FacetList values\n * are structured as a string that contain the values for each level\n * separated by the configured separator.\n *\n * When querying algolia, the values stored in this attribute will\n * be translated into the `facetFilters` attribute.\n * @member {Object.}\n */\n this.hierarchicalFacetsRefinements = params.hierarchicalFacetsRefinements || {};\n\n var self = this;\n Object.keys(params).forEach(function(paramName) {\n var isKeyKnown = SearchParameters.PARAMETERS.indexOf(paramName) !== -1;\n var isValueDefined = params[paramName] !== undefined;\n\n if (!isKeyKnown && isValueDefined) {\n self[paramName] = params[paramName];\n }\n });\n}\n\n/**\n * List all the properties in SearchParameters and therefore all the known Algolia properties\n * This doesn't contain any beta/hidden features.\n * @private\n */\nSearchParameters.PARAMETERS = Object.keys(new SearchParameters());\n\n/**\n * @private\n * @param {object} partialState full or part of a state\n * @return {object} a new object with the number keys as number\n */\nSearchParameters._parseNumbers = function(partialState) {\n // Do not reparse numbers in SearchParameters, they ought to be parsed already\n if (partialState instanceof SearchParameters) return partialState;\n\n var numbers = {};\n\n var numberKeys = [\n 'aroundPrecision',\n 'aroundRadius',\n 'getRankingInfo',\n 'minWordSizefor2Typos',\n 'minWordSizefor1Typo',\n 'page',\n 'maxValuesPerFacet',\n 'distinct',\n 'minimumAroundRadius',\n 'hitsPerPage',\n 'minProximity'\n ];\n\n numberKeys.forEach(function(k) {\n var value = partialState[k];\n if (typeof value === 'string') {\n var parsedValue = parseFloat(value);\n // global isNaN is ok to use here, value is only number or NaN\n numbers[k] = isNaN(parsedValue) ? value : parsedValue;\n }\n });\n\n // there's two formats of insideBoundingBox, we need to parse\n // the one which is an array of float geo rectangles\n if (Array.isArray(partialState.insideBoundingBox)) {\n numbers.insideBoundingBox = partialState.insideBoundingBox.map(function(geoRect) {\n return geoRect.map(function(value) {\n return parseFloat(value);\n });\n });\n }\n\n if (partialState.numericRefinements) {\n var numericRefinements = {};\n Object.keys(partialState.numericRefinements).forEach(function(attribute) {\n var operators = partialState.numericRefinements[attribute] || {};\n numericRefinements[attribute] = {};\n Object.keys(operators).forEach(function(operator) {\n var values = operators[operator];\n var parsedValues = values.map(function(v) {\n if (Array.isArray(v)) {\n return v.map(function(vPrime) {\n if (typeof vPrime === 'string') {\n return parseFloat(vPrime);\n }\n return vPrime;\n });\n } else if (typeof v === 'string') {\n return parseFloat(v);\n }\n return v;\n });\n numericRefinements[attribute][operator] = parsedValues;\n });\n });\n numbers.numericRefinements = numericRefinements;\n }\n\n return merge({}, partialState, numbers);\n};\n\n/**\n * Factory for SearchParameters\n * @param {object|SearchParameters} newParameters existing parameters or partial\n * object for the properties of a new SearchParameters\n * @return {SearchParameters} frozen instance of SearchParameters\n */\nSearchParameters.make = function makeSearchParameters(newParameters) {\n var instance = new SearchParameters(newParameters);\n\n var hierarchicalFacets = newParameters.hierarchicalFacets || [];\n hierarchicalFacets.forEach(function(facet) {\n if (facet.rootPath) {\n var currentRefinement = instance.getHierarchicalRefinement(facet.name);\n\n if (currentRefinement.length > 0 && currentRefinement[0].indexOf(facet.rootPath) !== 0) {\n instance = instance.clearRefinements(facet.name);\n }\n\n // get it again in case it has been cleared\n currentRefinement = instance.getHierarchicalRefinement(facet.name);\n if (currentRefinement.length === 0) {\n instance = instance.toggleHierarchicalFacetRefinement(facet.name, facet.rootPath);\n }\n }\n });\n\n return instance;\n};\n\n/**\n * Validates the new parameters based on the previous state\n * @param {SearchParameters} currentState the current state\n * @param {object|SearchParameters} parameters the new parameters to set\n * @return {Error|null} Error if the modification is invalid, null otherwise\n */\nSearchParameters.validate = function(currentState, parameters) {\n var params = parameters || {};\n\n if (currentState.tagFilters && params.tagRefinements && params.tagRefinements.length > 0) {\n return new Error(\n '[Tags] Cannot switch from the managed tag API to the advanced API. It is probably ' +\n 'an error, if it is really what you want, you should first clear the tags with clearTags method.');\n }\n\n if (currentState.tagRefinements.length > 0 && params.tagFilters) {\n return new Error(\n '[Tags] Cannot switch from the advanced tag API to the managed API. It is probably ' +\n 'an error, if it is not, you should first clear the tags with clearTags method.');\n }\n\n if (\n currentState.numericFilters &&\n params.numericRefinements &&\n objectHasKeys(params.numericRefinements)\n ) {\n return new Error(\n \"[Numeric filters] Can't switch from the advanced to the managed API. It\" +\n ' is probably an error, if this is really what you want, you have to first' +\n ' clear the numeric filters.'\n );\n }\n\n if (objectHasKeys(currentState.numericRefinements) && params.numericFilters) {\n return new Error(\n \"[Numeric filters] Can't switch from the managed API to the advanced. It\" +\n ' is probably an error, if this is really what you want, you have to first' +\n ' clear the numeric filters.');\n }\n\n return null;\n};\n\nSearchParameters.prototype = {\n constructor: SearchParameters,\n\n /**\n * Remove all refinements (disjunctive + conjunctive + excludes + numeric filters)\n * @method\n * @param {undefined|string|SearchParameters.clearCallback} [attribute] optional string or function\n * - If not given, means to clear all the filters.\n * - If `string`, means to clear all refinements for the `attribute` named filter.\n * - If `function`, means to clear all the refinements that return truthy values.\n * @return {SearchParameters}\n */\n clearRefinements: function clearRefinements(attribute) {\n var patch = {\n numericRefinements: this._clearNumericRefinements(attribute),\n facetsRefinements: RefinementList.clearRefinement(\n this.facetsRefinements,\n attribute,\n 'conjunctiveFacet'\n ),\n facetsExcludes: RefinementList.clearRefinement(\n this.facetsExcludes,\n attribute,\n 'exclude'\n ),\n disjunctiveFacetsRefinements: RefinementList.clearRefinement(\n this.disjunctiveFacetsRefinements,\n attribute,\n 'disjunctiveFacet'\n ),\n hierarchicalFacetsRefinements: RefinementList.clearRefinement(\n this.hierarchicalFacetsRefinements,\n attribute,\n 'hierarchicalFacet'\n )\n };\n if (\n patch.numericRefinements === this.numericRefinements &&\n patch.facetsRefinements === this.facetsRefinements &&\n patch.facetsExcludes === this.facetsExcludes &&\n patch.disjunctiveFacetsRefinements === this.disjunctiveFacetsRefinements &&\n patch.hierarchicalFacetsRefinements === this.hierarchicalFacetsRefinements\n ) {\n return this;\n }\n return this.setQueryParameters(patch);\n },\n /**\n * Remove all the refined tags from the SearchParameters\n * @method\n * @return {SearchParameters}\n */\n clearTags: function clearTags() {\n if (this.tagFilters === undefined && this.tagRefinements.length === 0) return this;\n\n return this.setQueryParameters({\n tagFilters: undefined,\n tagRefinements: []\n });\n },\n /**\n * Set the index.\n * @method\n * @param {string} index the index name\n * @return {SearchParameters}\n */\n setIndex: function setIndex(index) {\n if (index === this.index) return this;\n\n return this.setQueryParameters({\n index: index\n });\n },\n /**\n * Query setter\n * @method\n * @param {string} newQuery value for the new query\n * @return {SearchParameters}\n */\n setQuery: function setQuery(newQuery) {\n if (newQuery === this.query) return this;\n\n return this.setQueryParameters({\n query: newQuery\n });\n },\n /**\n * Page setter\n * @method\n * @param {number} newPage new page number\n * @return {SearchParameters}\n */\n setPage: function setPage(newPage) {\n if (newPage === this.page) return this;\n\n return this.setQueryParameters({\n page: newPage\n });\n },\n /**\n * Facets setter\n * The facets are the simple facets, used for conjunctive (and) faceting.\n * @method\n * @param {string[]} facets all the attributes of the algolia records used for conjunctive faceting\n * @return {SearchParameters}\n */\n setFacets: function setFacets(facets) {\n return this.setQueryParameters({\n facets: facets\n });\n },\n /**\n * Disjunctive facets setter\n * Change the list of disjunctive (or) facets the helper chan handle.\n * @method\n * @param {string[]} facets all the attributes of the algolia records used for disjunctive faceting\n * @return {SearchParameters}\n */\n setDisjunctiveFacets: function setDisjunctiveFacets(facets) {\n return this.setQueryParameters({\n disjunctiveFacets: facets\n });\n },\n /**\n * HitsPerPage setter\n * Hits per page represents the number of hits retrieved for this query\n * @method\n * @param {number} n number of hits retrieved per page of results\n * @return {SearchParameters}\n */\n setHitsPerPage: function setHitsPerPage(n) {\n if (this.hitsPerPage === n) return this;\n\n return this.setQueryParameters({\n hitsPerPage: n\n });\n },\n /**\n * typoTolerance setter\n * Set the value of typoTolerance\n * @method\n * @param {string} typoTolerance new value of typoTolerance (\"true\", \"false\", \"min\" or \"strict\")\n * @return {SearchParameters}\n */\n setTypoTolerance: function setTypoTolerance(typoTolerance) {\n if (this.typoTolerance === typoTolerance) return this;\n\n return this.setQueryParameters({\n typoTolerance: typoTolerance\n });\n },\n /**\n * Add a numeric filter for a given attribute\n * When value is an array, they are combined with OR\n * When value is a single value, it will combined with AND\n * @method\n * @param {string} attribute attribute to set the filter on\n * @param {string} operator operator of the filter (possible values: =, >, >=, <, <=, !=)\n * @param {number | number[]} value value of the filter\n * @return {SearchParameters}\n * @example\n * // for price = 50 or 40\n * searchparameter.addNumericRefinement('price', '=', [50, 40]);\n * @example\n * // for size = 38 and 40\n * searchparameter.addNumericRefinement('size', '=', 38);\n * searchparameter.addNumericRefinement('size', '=', 40);\n */\n addNumericRefinement: function(attribute, operator, v) {\n var value = valToNumber(v);\n\n if (this.isNumericRefined(attribute, operator, value)) return this;\n\n var mod = merge({}, this.numericRefinements);\n\n mod[attribute] = merge({}, mod[attribute]);\n\n if (mod[attribute][operator]) {\n // Array copy\n mod[attribute][operator] = mod[attribute][operator].slice();\n // Add the element. Concat can't be used here because value can be an array.\n mod[attribute][operator].push(value);\n } else {\n mod[attribute][operator] = [value];\n }\n\n return this.setQueryParameters({\n numericRefinements: mod\n });\n },\n /**\n * Get the list of conjunctive refinements for a single facet\n * @param {string} facetName name of the attribute used for faceting\n * @return {string[]} list of refinements\n */\n getConjunctiveRefinements: function(facetName) {\n if (!this.isConjunctiveFacet(facetName)) {\n return [];\n }\n return this.facetsRefinements[facetName] || [];\n },\n /**\n * Get the list of disjunctive refinements for a single facet\n * @param {string} facetName name of the attribute used for faceting\n * @return {string[]} list of refinements\n */\n getDisjunctiveRefinements: function(facetName) {\n if (!this.isDisjunctiveFacet(facetName)) {\n return [];\n }\n return this.disjunctiveFacetsRefinements[facetName] || [];\n },\n /**\n * Get the list of hierarchical refinements for a single facet\n * @param {string} facetName name of the attribute used for faceting\n * @return {string[]} list of refinements\n */\n getHierarchicalRefinement: function(facetName) {\n // we send an array but we currently do not support multiple\n // hierarchicalRefinements for a hierarchicalFacet\n return this.hierarchicalFacetsRefinements[facetName] || [];\n },\n /**\n * Get the list of exclude refinements for a single facet\n * @param {string} facetName name of the attribute used for faceting\n * @return {string[]} list of refinements\n */\n getExcludeRefinements: function(facetName) {\n if (!this.isConjunctiveFacet(facetName)) {\n return [];\n }\n return this.facetsExcludes[facetName] || [];\n },\n\n /**\n * Remove all the numeric filter for a given (attribute, operator)\n * @method\n * @param {string} attribute attribute to set the filter on\n * @param {string} [operator] operator of the filter (possible values: =, >, >=, <, <=, !=)\n * @param {number} [number] the value to be removed\n * @return {SearchParameters}\n */\n removeNumericRefinement: function(attribute, operator, paramValue) {\n if (paramValue !== undefined) {\n if (!this.isNumericRefined(attribute, operator, paramValue)) {\n return this;\n }\n return this.setQueryParameters({\n numericRefinements: this._clearNumericRefinements(function(value, key) {\n return (\n key === attribute &&\n value.op === operator &&\n isEqualNumericRefinement(value.val, valToNumber(paramValue))\n );\n })\n });\n } else if (operator !== undefined) {\n if (!this.isNumericRefined(attribute, operator)) return this;\n return this.setQueryParameters({\n numericRefinements: this._clearNumericRefinements(function(value, key) {\n return key === attribute && value.op === operator;\n })\n });\n }\n\n if (!this.isNumericRefined(attribute)) return this;\n return this.setQueryParameters({\n numericRefinements: this._clearNumericRefinements(function(value, key) {\n return key === attribute;\n })\n });\n },\n /**\n * Get the list of numeric refinements for a single facet\n * @param {string} facetName name of the attribute used for faceting\n * @return {SearchParameters.OperatorList[]} list of refinements\n */\n getNumericRefinements: function(facetName) {\n return this.numericRefinements[facetName] || {};\n },\n /**\n * Return the current refinement for the (attribute, operator)\n * @param {string} attribute attribute in the record\n * @param {string} operator operator applied on the refined values\n * @return {Array.} refined values\n */\n getNumericRefinement: function(attribute, operator) {\n return this.numericRefinements[attribute] && this.numericRefinements[attribute][operator];\n },\n /**\n * Clear numeric filters.\n * @method\n * @private\n * @param {string|SearchParameters.clearCallback} [attribute] optional string or function\n * - If not given, means to clear all the filters.\n * - If `string`, means to clear all refinements for the `attribute` named filter.\n * - If `function`, means to clear all the refinements that return truthy values.\n * @return {Object.}\n */\n _clearNumericRefinements: function _clearNumericRefinements(attribute) {\n if (attribute === undefined) {\n if (!objectHasKeys(this.numericRefinements)) {\n return this.numericRefinements;\n }\n return {};\n } else if (typeof attribute === 'string') {\n if (!objectHasKeys(this.numericRefinements[attribute])) {\n return this.numericRefinements;\n }\n return omit(this.numericRefinements, attribute);\n } else if (typeof attribute === 'function') {\n var hasChanged = false;\n var numericRefinements = this.numericRefinements;\n var newNumericRefinements = Object.keys(numericRefinements).reduce(function(memo, key) {\n var operators = numericRefinements[key];\n var operatorList = {};\n\n operators = operators || {};\n Object.keys(operators).forEach(function(operator) {\n var values = operators[operator] || [];\n var outValues = [];\n values.forEach(function(value) {\n var predicateResult = attribute({val: value, op: operator}, key, 'numeric');\n if (!predicateResult) outValues.push(value);\n });\n if (outValues.length !== values.length) {\n hasChanged = true;\n }\n operatorList[operator] = outValues;\n });\n\n memo[key] = operatorList;\n\n return memo;\n }, {});\n\n if (hasChanged) return newNumericRefinements;\n return this.numericRefinements;\n }\n },\n /**\n * Add a facet to the facets attribute of the helper configuration, if it\n * isn't already present.\n * @method\n * @param {string} facet facet name to add\n * @return {SearchParameters}\n */\n addFacet: function addFacet(facet) {\n if (this.isConjunctiveFacet(facet)) {\n return this;\n }\n\n return this.setQueryParameters({\n facets: this.facets.concat([facet])\n });\n },\n /**\n * Add a disjunctive facet to the disjunctiveFacets attribute of the helper\n * configuration, if it isn't already present.\n * @method\n * @param {string} facet disjunctive facet name to add\n * @return {SearchParameters}\n */\n addDisjunctiveFacet: function addDisjunctiveFacet(facet) {\n if (this.isDisjunctiveFacet(facet)) {\n return this;\n }\n\n return this.setQueryParameters({\n disjunctiveFacets: this.disjunctiveFacets.concat([facet])\n });\n },\n /**\n * Add a hierarchical facet to the hierarchicalFacets attribute of the helper\n * configuration.\n * @method\n * @param {object} hierarchicalFacet hierarchical facet to add\n * @return {SearchParameters}\n * @throws will throw an error if a hierarchical facet with the same name was already declared\n */\n addHierarchicalFacet: function addHierarchicalFacet(hierarchicalFacet) {\n if (this.isHierarchicalFacet(hierarchicalFacet.name)) {\n throw new Error(\n 'Cannot declare two hierarchical facets with the same name: `' + hierarchicalFacet.name + '`');\n }\n\n return this.setQueryParameters({\n hierarchicalFacets: this.hierarchicalFacets.concat([hierarchicalFacet])\n });\n },\n /**\n * Add a refinement on a \"normal\" facet\n * @method\n * @param {string} facet attribute to apply the faceting on\n * @param {string} value value of the attribute (will be converted to string)\n * @return {SearchParameters}\n */\n addFacetRefinement: function addFacetRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n if (RefinementList.isRefined(this.facetsRefinements, facet, value)) return this;\n\n return this.setQueryParameters({\n facetsRefinements: RefinementList.addRefinement(this.facetsRefinements, facet, value)\n });\n },\n /**\n * Exclude a value from a \"normal\" facet\n * @method\n * @param {string} facet attribute to apply the exclusion on\n * @param {string} value value of the attribute (will be converted to string)\n * @return {SearchParameters}\n */\n addExcludeRefinement: function addExcludeRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n if (RefinementList.isRefined(this.facetsExcludes, facet, value)) return this;\n\n return this.setQueryParameters({\n facetsExcludes: RefinementList.addRefinement(this.facetsExcludes, facet, value)\n });\n },\n /**\n * Adds a refinement on a disjunctive facet.\n * @method\n * @param {string} facet attribute to apply the faceting on\n * @param {string} value value of the attribute (will be converted to string)\n * @return {SearchParameters}\n */\n addDisjunctiveFacetRefinement: function addDisjunctiveFacetRefinement(facet, value) {\n if (!this.isDisjunctiveFacet(facet)) {\n throw new Error(\n facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');\n }\n\n if (RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)) return this;\n\n return this.setQueryParameters({\n disjunctiveFacetsRefinements: RefinementList.addRefinement(\n this.disjunctiveFacetsRefinements, facet, value)\n });\n },\n /**\n * addTagRefinement adds a tag to the list used to filter the results\n * @param {string} tag tag to be added\n * @return {SearchParameters}\n */\n addTagRefinement: function addTagRefinement(tag) {\n if (this.isTagRefined(tag)) return this;\n\n var modification = {\n tagRefinements: this.tagRefinements.concat(tag)\n };\n\n return this.setQueryParameters(modification);\n },\n /**\n * Remove a facet from the facets attribute of the helper configuration, if it\n * is present.\n * @method\n * @param {string} facet facet name to remove\n * @return {SearchParameters}\n */\n removeFacet: function removeFacet(facet) {\n if (!this.isConjunctiveFacet(facet)) {\n return this;\n }\n\n return this.clearRefinements(facet).setQueryParameters({\n facets: this.facets.filter(function(f) {\n return f !== facet;\n })\n });\n },\n /**\n * Remove a disjunctive facet from the disjunctiveFacets attribute of the\n * helper configuration, if it is present.\n * @method\n * @param {string} facet disjunctive facet name to remove\n * @return {SearchParameters}\n */\n removeDisjunctiveFacet: function removeDisjunctiveFacet(facet) {\n if (!this.isDisjunctiveFacet(facet)) {\n return this;\n }\n\n return this.clearRefinements(facet).setQueryParameters({\n disjunctiveFacets: this.disjunctiveFacets.filter(function(f) {\n return f !== facet;\n })\n });\n },\n /**\n * Remove a hierarchical facet from the hierarchicalFacets attribute of the\n * helper configuration, if it is present.\n * @method\n * @param {string} facet hierarchical facet name to remove\n * @return {SearchParameters}\n */\n removeHierarchicalFacet: function removeHierarchicalFacet(facet) {\n if (!this.isHierarchicalFacet(facet)) {\n return this;\n }\n\n return this.clearRefinements(facet).setQueryParameters({\n hierarchicalFacets: this.hierarchicalFacets.filter(function(f) {\n return f.name !== facet;\n })\n });\n },\n /**\n * Remove a refinement set on facet. If a value is provided, it will clear the\n * refinement for the given value, otherwise it will clear all the refinement\n * values for the faceted attribute.\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {string} [value] value used to filter\n * @return {SearchParameters}\n */\n removeFacetRefinement: function removeFacetRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n if (!RefinementList.isRefined(this.facetsRefinements, facet, value)) return this;\n\n return this.setQueryParameters({\n facetsRefinements: RefinementList.removeRefinement(this.facetsRefinements, facet, value)\n });\n },\n /**\n * Remove a negative refinement on a facet\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {string} value value used to filter\n * @return {SearchParameters}\n */\n removeExcludeRefinement: function removeExcludeRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n if (!RefinementList.isRefined(this.facetsExcludes, facet, value)) return this;\n\n return this.setQueryParameters({\n facetsExcludes: RefinementList.removeRefinement(this.facetsExcludes, facet, value)\n });\n },\n /**\n * Remove a refinement on a disjunctive facet\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {string} value value used to filter\n * @return {SearchParameters}\n */\n removeDisjunctiveFacetRefinement: function removeDisjunctiveFacetRefinement(facet, value) {\n if (!this.isDisjunctiveFacet(facet)) {\n throw new Error(\n facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');\n }\n if (!RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value)) return this;\n\n return this.setQueryParameters({\n disjunctiveFacetsRefinements: RefinementList.removeRefinement(\n this.disjunctiveFacetsRefinements, facet, value)\n });\n },\n /**\n * Remove a tag from the list of tag refinements\n * @method\n * @param {string} tag the tag to remove\n * @return {SearchParameters}\n */\n removeTagRefinement: function removeTagRefinement(tag) {\n if (!this.isTagRefined(tag)) return this;\n\n var modification = {\n tagRefinements: this.tagRefinements.filter(function(t) {\n return t !== tag;\n })\n };\n\n return this.setQueryParameters(modification);\n },\n /**\n * Generic toggle refinement method to use with facet, disjunctive facets\n * and hierarchical facets\n * @param {string} facet the facet to refine\n * @param {string} value the associated value\n * @return {SearchParameters}\n * @throws will throw an error if the facet is not declared in the settings of the helper\n * @deprecated since version 2.19.0, see {@link SearchParameters#toggleFacetRefinement}\n */\n toggleRefinement: function toggleRefinement(facet, value) {\n return this.toggleFacetRefinement(facet, value);\n },\n /**\n * Generic toggle refinement method to use with facet, disjunctive facets\n * and hierarchical facets\n * @param {string} facet the facet to refine\n * @param {string} value the associated value\n * @return {SearchParameters}\n * @throws will throw an error if the facet is not declared in the settings of the helper\n */\n toggleFacetRefinement: function toggleFacetRefinement(facet, value) {\n if (this.isHierarchicalFacet(facet)) {\n return this.toggleHierarchicalFacetRefinement(facet, value);\n } else if (this.isConjunctiveFacet(facet)) {\n return this.toggleConjunctiveFacetRefinement(facet, value);\n } else if (this.isDisjunctiveFacet(facet)) {\n return this.toggleDisjunctiveFacetRefinement(facet, value);\n }\n\n throw new Error('Cannot refine the undeclared facet ' + facet +\n '; it should be added to the helper options facets, disjunctiveFacets or hierarchicalFacets');\n },\n /**\n * Switch the refinement applied over a facet/value\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {SearchParameters}\n */\n toggleConjunctiveFacetRefinement: function toggleConjunctiveFacetRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n\n return this.setQueryParameters({\n facetsRefinements: RefinementList.toggleRefinement(this.facetsRefinements, facet, value)\n });\n },\n /**\n * Switch the refinement applied over a facet/value\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {SearchParameters}\n */\n toggleExcludeFacetRefinement: function toggleExcludeFacetRefinement(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n throw new Error(facet + ' is not defined in the facets attribute of the helper configuration');\n }\n\n return this.setQueryParameters({\n facetsExcludes: RefinementList.toggleRefinement(this.facetsExcludes, facet, value)\n });\n },\n /**\n * Switch the refinement applied over a facet/value\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {SearchParameters}\n */\n toggleDisjunctiveFacetRefinement: function toggleDisjunctiveFacetRefinement(facet, value) {\n if (!this.isDisjunctiveFacet(facet)) {\n throw new Error(\n facet + ' is not defined in the disjunctiveFacets attribute of the helper configuration');\n }\n\n return this.setQueryParameters({\n disjunctiveFacetsRefinements: RefinementList.toggleRefinement(\n this.disjunctiveFacetsRefinements, facet, value)\n });\n },\n /**\n * Switch the refinement applied over a facet/value\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {SearchParameters}\n */\n toggleHierarchicalFacetRefinement: function toggleHierarchicalFacetRefinement(facet, value) {\n if (!this.isHierarchicalFacet(facet)) {\n throw new Error(\n facet + ' is not defined in the hierarchicalFacets attribute of the helper configuration');\n }\n\n var separator = this._getHierarchicalFacetSeparator(this.getHierarchicalFacetByName(facet));\n\n var mod = {};\n\n var upOneOrMultipleLevel = this.hierarchicalFacetsRefinements[facet] !== undefined &&\n this.hierarchicalFacetsRefinements[facet].length > 0 && (\n // remove current refinement:\n // refinement was 'beer > IPA', call is toggleRefine('beer > IPA'), refinement should be `beer`\n this.hierarchicalFacetsRefinements[facet][0] === value ||\n // remove a parent refinement of the current refinement:\n // - refinement was 'beer > IPA > Flying dog'\n // - call is toggleRefine('beer > IPA')\n // - refinement should be `beer`\n this.hierarchicalFacetsRefinements[facet][0].indexOf(value + separator) === 0\n );\n\n if (upOneOrMultipleLevel) {\n if (value.indexOf(separator) === -1) {\n // go back to root level\n mod[facet] = [];\n } else {\n mod[facet] = [value.slice(0, value.lastIndexOf(separator))];\n }\n } else {\n mod[facet] = [value];\n }\n\n return this.setQueryParameters({\n hierarchicalFacetsRefinements: defaultsPure({}, mod, this.hierarchicalFacetsRefinements)\n });\n },\n\n /**\n * Adds a refinement on a hierarchical facet.\n * @param {string} facet the facet name\n * @param {string} path the hierarchical facet path\n * @return {SearchParameter} the new state\n * @throws Error if the facet is not defined or if the facet is refined\n */\n addHierarchicalFacetRefinement: function(facet, path) {\n if (this.isHierarchicalFacetRefined(facet)) {\n throw new Error(facet + ' is already refined.');\n }\n if (!this.isHierarchicalFacet(facet)) {\n throw new Error(facet + ' is not defined in the hierarchicalFacets attribute of the helper configuration.');\n }\n var mod = {};\n mod[facet] = [path];\n return this.setQueryParameters({\n hierarchicalFacetsRefinements: defaultsPure({}, mod, this.hierarchicalFacetsRefinements)\n });\n },\n\n /**\n * Removes the refinement set on a hierarchical facet.\n * @param {string} facet the facet name\n * @return {SearchParameter} the new state\n * @throws Error if the facet is not defined or if the facet is not refined\n */\n removeHierarchicalFacetRefinement: function(facet) {\n if (!this.isHierarchicalFacetRefined(facet)) {\n return this;\n }\n var mod = {};\n mod[facet] = [];\n return this.setQueryParameters({\n hierarchicalFacetsRefinements: defaultsPure({}, mod, this.hierarchicalFacetsRefinements)\n });\n },\n /**\n * Switch the tag refinement\n * @method\n * @param {string} tag the tag to remove or add\n * @return {SearchParameters}\n */\n toggleTagRefinement: function toggleTagRefinement(tag) {\n if (this.isTagRefined(tag)) {\n return this.removeTagRefinement(tag);\n }\n\n return this.addTagRefinement(tag);\n },\n /**\n * Test if the facet name is from one of the disjunctive facets\n * @method\n * @param {string} facet facet name to test\n * @return {boolean}\n */\n isDisjunctiveFacet: function(facet) {\n return this.disjunctiveFacets.indexOf(facet) > -1;\n },\n /**\n * Test if the facet name is from one of the hierarchical facets\n * @method\n * @param {string} facetName facet name to test\n * @return {boolean}\n */\n isHierarchicalFacet: function(facetName) {\n return this.getHierarchicalFacetByName(facetName) !== undefined;\n },\n /**\n * Test if the facet name is from one of the conjunctive/normal facets\n * @method\n * @param {string} facet facet name to test\n * @return {boolean}\n */\n isConjunctiveFacet: function(facet) {\n return this.facets.indexOf(facet) > -1;\n },\n /**\n * Returns true if the facet is refined, either for a specific value or in\n * general.\n * @method\n * @param {string} facet name of the attribute for used for faceting\n * @param {string} value, optional value. If passed will test that this value\n * is filtering the given facet.\n * @return {boolean} returns true if refined\n */\n isFacetRefined: function isFacetRefined(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n return false;\n }\n return RefinementList.isRefined(this.facetsRefinements, facet, value);\n },\n /**\n * Returns true if the facet contains exclusions or if a specific value is\n * excluded.\n *\n * @method\n * @param {string} facet name of the attribute for used for faceting\n * @param {string} [value] optional value. If passed will test that this value\n * is filtering the given facet.\n * @return {boolean} returns true if refined\n */\n isExcludeRefined: function isExcludeRefined(facet, value) {\n if (!this.isConjunctiveFacet(facet)) {\n return false;\n }\n return RefinementList.isRefined(this.facetsExcludes, facet, value);\n },\n /**\n * Returns true if the facet contains a refinement, or if a value passed is a\n * refinement for the facet.\n * @method\n * @param {string} facet name of the attribute for used for faceting\n * @param {string} value optional, will test if the value is used for refinement\n * if there is one, otherwise will test if the facet contains any refinement\n * @return {boolean}\n */\n isDisjunctiveFacetRefined: function isDisjunctiveFacetRefined(facet, value) {\n if (!this.isDisjunctiveFacet(facet)) {\n return false;\n }\n return RefinementList.isRefined(this.disjunctiveFacetsRefinements, facet, value);\n },\n /**\n * Returns true if the facet contains a refinement, or if a value passed is a\n * refinement for the facet.\n * @method\n * @param {string} facet name of the attribute for used for faceting\n * @param {string} value optional, will test if the value is used for refinement\n * if there is one, otherwise will test if the facet contains any refinement\n * @return {boolean}\n */\n isHierarchicalFacetRefined: function isHierarchicalFacetRefined(facet, value) {\n if (!this.isHierarchicalFacet(facet)) {\n return false;\n }\n\n var refinements = this.getHierarchicalRefinement(facet);\n\n if (!value) {\n return refinements.length > 0;\n }\n\n return refinements.indexOf(value) !== -1;\n },\n /**\n * Test if the triple (attribute, operator, value) is already refined.\n * If only the attribute and the operator are provided, it tests if the\n * contains any refinement value.\n * @method\n * @param {string} attribute attribute for which the refinement is applied\n * @param {string} [operator] operator of the refinement\n * @param {string} [value] value of the refinement\n * @return {boolean} true if it is refined\n */\n isNumericRefined: function isNumericRefined(attribute, operator, value) {\n if (value === undefined && operator === undefined) {\n return !!this.numericRefinements[attribute];\n }\n\n var isOperatorDefined =\n this.numericRefinements[attribute] &&\n this.numericRefinements[attribute][operator] !== undefined;\n\n if (value === undefined || !isOperatorDefined) {\n return isOperatorDefined;\n }\n\n var parsedValue = valToNumber(value);\n var isAttributeValueDefined =\n findArray(this.numericRefinements[attribute][operator], parsedValue) !==\n undefined;\n\n return isOperatorDefined && isAttributeValueDefined;\n },\n /**\n * Returns true if the tag refined, false otherwise\n * @method\n * @param {string} tag the tag to check\n * @return {boolean}\n */\n isTagRefined: function isTagRefined(tag) {\n return this.tagRefinements.indexOf(tag) !== -1;\n },\n /**\n * Returns the list of all disjunctive facets refined\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {string[]}\n */\n getRefinedDisjunctiveFacets: function getRefinedDisjunctiveFacets() {\n var self = this;\n\n // attributes used for numeric filter can also be disjunctive\n var disjunctiveNumericRefinedFacets = intersection(\n Object.keys(this.numericRefinements).filter(function(facet) {\n return Object.keys(self.numericRefinements[facet]).length > 0;\n }),\n this.disjunctiveFacets\n );\n\n return Object.keys(this.disjunctiveFacetsRefinements).filter(function(facet) {\n return self.disjunctiveFacetsRefinements[facet].length > 0;\n })\n .concat(disjunctiveNumericRefinedFacets)\n .concat(this.getRefinedHierarchicalFacets());\n },\n /**\n * Returns the list of all disjunctive facets refined\n * @method\n * @param {string} facet name of the attribute used for faceting\n * @param {value} value value used for filtering\n * @return {string[]}\n */\n getRefinedHierarchicalFacets: function getRefinedHierarchicalFacets() {\n var self = this;\n return intersection(\n // enforce the order between the two arrays,\n // so that refinement name index === hierarchical facet index\n this.hierarchicalFacets.map(function(facet) { return facet.name; }),\n Object.keys(this.hierarchicalFacetsRefinements).filter(function(facet) {\n return self.hierarchicalFacetsRefinements[facet].length > 0;\n })\n );\n },\n /**\n * Returned the list of all disjunctive facets not refined\n * @method\n * @return {string[]}\n */\n getUnrefinedDisjunctiveFacets: function() {\n var refinedFacets = this.getRefinedDisjunctiveFacets();\n\n return this.disjunctiveFacets.filter(function(f) {\n return refinedFacets.indexOf(f) === -1;\n });\n },\n\n managedParameters: [\n 'index',\n 'facets', 'disjunctiveFacets', 'facetsRefinements',\n 'facetsExcludes', 'disjunctiveFacetsRefinements',\n 'numericRefinements', 'tagRefinements', 'hierarchicalFacets', 'hierarchicalFacetsRefinements'\n ],\n getQueryParams: function getQueryParams() {\n var managedParameters = this.managedParameters;\n\n var queryParams = {};\n\n var self = this;\n Object.keys(this).forEach(function(paramName) {\n var paramValue = self[paramName];\n if (managedParameters.indexOf(paramName) === -1 && paramValue !== undefined) {\n queryParams[paramName] = paramValue;\n }\n });\n\n return queryParams;\n },\n /**\n * Let the user set a specific value for a given parameter. Will return the\n * same instance if the parameter is invalid or if the value is the same as the\n * previous one.\n * @method\n * @param {string} parameter the parameter name\n * @param {any} value the value to be set, must be compliant with the definition\n * of the attribute on the object\n * @return {SearchParameters} the updated state\n */\n setQueryParameter: function setParameter(parameter, value) {\n if (this[parameter] === value) return this;\n\n var modification = {};\n\n modification[parameter] = value;\n\n return this.setQueryParameters(modification);\n },\n /**\n * Let the user set any of the parameters with a plain object.\n * @method\n * @param {object} params all the keys and the values to be updated\n * @return {SearchParameters} a new updated instance\n */\n setQueryParameters: function setQueryParameters(params) {\n if (!params) return this;\n\n var error = SearchParameters.validate(this, params);\n\n if (error) {\n throw error;\n }\n\n var self = this;\n var nextWithNumbers = SearchParameters._parseNumbers(params);\n var previousPlainObject = Object.keys(this).reduce(function(acc, key) {\n acc[key] = self[key];\n return acc;\n }, {});\n\n var nextPlainObject = Object.keys(nextWithNumbers).reduce(\n function(previous, key) {\n var isPreviousValueDefined = previous[key] !== undefined;\n var isNextValueDefined = nextWithNumbers[key] !== undefined;\n\n if (isPreviousValueDefined && !isNextValueDefined) {\n return omit(previous, [key]);\n }\n\n if (isNextValueDefined) {\n previous[key] = nextWithNumbers[key];\n }\n\n return previous;\n },\n previousPlainObject\n );\n\n return new this.constructor(nextPlainObject);\n },\n\n /**\n * Returns a new instance with the page reset. Two scenarios possible:\n * the page is omitted -> return the given instance\n * the page is set -> return a new instance with a page of 0\n * @return {SearchParameters} a new updated instance\n */\n resetPage: function() {\n if (this.page === undefined) {\n return this;\n }\n\n return this.setPage(0);\n },\n\n /**\n * Helper function to get the hierarchicalFacet separator or the default one (`>`)\n * @param {object} hierarchicalFacet\n * @return {string} returns the hierarchicalFacet.separator or `>` as default\n */\n _getHierarchicalFacetSortBy: function(hierarchicalFacet) {\n return hierarchicalFacet.sortBy || ['isRefined:desc', 'name:asc'];\n },\n\n /**\n * Helper function to get the hierarchicalFacet separator or the default one (`>`)\n * @private\n * @param {object} hierarchicalFacet\n * @return {string} returns the hierarchicalFacet.separator or `>` as default\n */\n _getHierarchicalFacetSeparator: function(hierarchicalFacet) {\n return hierarchicalFacet.separator || ' > ';\n },\n\n /**\n * Helper function to get the hierarchicalFacet prefix path or null\n * @private\n * @param {object} hierarchicalFacet\n * @return {string} returns the hierarchicalFacet.rootPath or null as default\n */\n _getHierarchicalRootPath: function(hierarchicalFacet) {\n return hierarchicalFacet.rootPath || null;\n },\n\n /**\n * Helper function to check if we show the parent level of the hierarchicalFacet\n * @private\n * @param {object} hierarchicalFacet\n * @return {string} returns the hierarchicalFacet.showParentLevel or true as default\n */\n _getHierarchicalShowParentLevel: function(hierarchicalFacet) {\n if (typeof hierarchicalFacet.showParentLevel === 'boolean') {\n return hierarchicalFacet.showParentLevel;\n }\n return true;\n },\n\n /**\n * Helper function to get the hierarchicalFacet by it's name\n * @param {string} hierarchicalFacetName\n * @return {object} a hierarchicalFacet\n */\n getHierarchicalFacetByName: function(hierarchicalFacetName) {\n return find(\n this.hierarchicalFacets,\n function(f) {\n return f.name === hierarchicalFacetName;\n }\n );\n },\n\n /**\n * Get the current breadcrumb for a hierarchical facet, as an array\n * @param {string} facetName Hierarchical facet name\n * @return {array.} the path as an array of string\n */\n getHierarchicalFacetBreadcrumb: function(facetName) {\n if (!this.isHierarchicalFacet(facetName)) {\n return [];\n }\n\n var refinement = this.getHierarchicalRefinement(facetName)[0];\n if (!refinement) return [];\n\n var separator = this._getHierarchicalFacetSeparator(\n this.getHierarchicalFacetByName(facetName)\n );\n var path = refinement.split(separator);\n return path.map(function(part) {\n return part.trim();\n });\n },\n\n toString: function() {\n return JSON.stringify(this, null, 2);\n }\n};\n\n/**\n * Callback used for clearRefinement method\n * @callback SearchParameters.clearCallback\n * @param {OperatorList|FacetList} value the value of the filter\n * @param {string} key the current attribute name\n * @param {string} type `numeric`, `disjunctiveFacet`, `conjunctiveFacet`, `hierarchicalFacet` or `exclude`\n * depending on the type of facet\n * @return {boolean} `true` if the element should be removed. `false` otherwise.\n */\nmodule.exports = SearchParameters;\n","'use strict';\n\nfunction compareAscending(value, other) {\n if (value !== other) {\n var valIsDefined = value !== undefined;\n var valIsNull = value === null;\n\n var othIsDefined = other !== undefined;\n var othIsNull = other === null;\n\n if (\n (!othIsNull && value > other) ||\n (valIsNull && othIsDefined) ||\n !valIsDefined\n ) {\n return 1;\n }\n if (\n (!valIsNull && value < other) ||\n (othIsNull && valIsDefined) ||\n !othIsDefined\n ) {\n return -1;\n }\n }\n return 0;\n}\n\n/**\n * @param {Array} collection object with keys in attributes\n * @param {Array} iteratees attributes\n * @param {Array} orders asc | desc\n */\nfunction orderBy(collection, iteratees, orders) {\n if (!Array.isArray(collection)) {\n return [];\n }\n\n if (!Array.isArray(orders)) {\n orders = [];\n }\n\n var result = collection.map(function(value, index) {\n return {\n criteria: iteratees.map(function(iteratee) {\n return value[iteratee];\n }),\n index: index,\n value: value\n };\n });\n\n result.sort(function comparer(object, other) {\n var index = -1;\n\n while (++index < object.criteria.length) {\n var res = compareAscending(object.criteria[index], other.criteria[index]);\n if (res) {\n if (index >= orders.length) {\n return res;\n }\n if (orders[index] === 'desc') {\n return -res;\n }\n return res;\n }\n }\n\n // This ensures a stable sort in V8 and other engines.\n // See https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.\n return object.index - other.index;\n });\n\n return result.map(function(res) {\n return res.value;\n });\n}\n\nmodule.exports = orderBy;\n","'use strict';\n\nmodule.exports = function compact(array) {\n if (!Array.isArray(array)) {\n return [];\n }\n\n return array.filter(Boolean);\n};\n","'use strict';\n\n// @MAJOR can be replaced by native Array#findIndex when we change support\nmodule.exports = function find(array, comparator) {\n if (!Array.isArray(array)) {\n return -1;\n }\n\n for (var i = 0; i < array.length; i++) {\n if (comparator(array[i])) {\n return i;\n }\n }\n return -1;\n};\n","'use strict';\n\nvar find = require('./find');\n\n/**\n * Transform sort format from user friendly notation to lodash format\n * @param {string[]} sortBy array of predicate of the form \"attribute:order\"\n * @param {string[]} [defaults] array of predicate of the form \"attribute:order\"\n * @return {array.} array containing 2 elements : attributes, orders\n */\nmodule.exports = function formatSort(sortBy, defaults) {\n var defaultInstructions = (defaults || []).map(function(sort) {\n return sort.split(':');\n });\n\n return sortBy.reduce(\n function preparePredicate(out, sort) {\n var sortInstruction = sort.split(':');\n\n var matchingDefault = find(defaultInstructions, function(\n defaultInstruction\n ) {\n return defaultInstruction[0] === sortInstruction[0];\n });\n\n if (sortInstruction.length > 1 || !matchingDefault) {\n out[0].push(sortInstruction[0]);\n out[1].push(sortInstruction[1]);\n return out;\n }\n\n out[0].push(matchingDefault[0]);\n out[1].push(matchingDefault[1]);\n return out;\n },\n [[], []]\n );\n};\n","'use strict';\n\nmodule.exports = generateTrees;\n\nvar orderBy = require('../functions/orderBy');\nvar find = require('../functions/find');\nvar prepareHierarchicalFacetSortBy = require('../functions/formatSort');\n\nfunction generateTrees(state) {\n return function generate(hierarchicalFacetResult, hierarchicalFacetIndex) {\n var hierarchicalFacet = state.hierarchicalFacets[hierarchicalFacetIndex];\n var hierarchicalFacetRefinement =\n (state.hierarchicalFacetsRefinements[hierarchicalFacet.name] &&\n state.hierarchicalFacetsRefinements[hierarchicalFacet.name][0]) ||\n '';\n var hierarchicalSeparator = state._getHierarchicalFacetSeparator(\n hierarchicalFacet\n );\n var hierarchicalRootPath = state._getHierarchicalRootPath(\n hierarchicalFacet\n );\n var hierarchicalShowParentLevel = state._getHierarchicalShowParentLevel(\n hierarchicalFacet\n );\n var sortBy = prepareHierarchicalFacetSortBy(\n state._getHierarchicalFacetSortBy(hierarchicalFacet)\n );\n\n var rootExhaustive = hierarchicalFacetResult.every(function(facetResult) {\n return facetResult.exhaustive;\n });\n\n var generateTreeFn = generateHierarchicalTree(\n sortBy,\n hierarchicalSeparator,\n hierarchicalRootPath,\n hierarchicalShowParentLevel,\n hierarchicalFacetRefinement\n );\n\n var results = hierarchicalFacetResult;\n\n if (hierarchicalRootPath) {\n results = hierarchicalFacetResult.slice(\n hierarchicalRootPath.split(hierarchicalSeparator).length\n );\n }\n\n return results.reduce(generateTreeFn, {\n name: state.hierarchicalFacets[hierarchicalFacetIndex].name,\n count: null, // root level, no count\n isRefined: true, // root level, always refined\n path: null, // root level, no path\n exhaustive: rootExhaustive,\n data: null\n });\n };\n}\n\nfunction generateHierarchicalTree(\n sortBy,\n hierarchicalSeparator,\n hierarchicalRootPath,\n hierarchicalShowParentLevel,\n currentRefinement\n) {\n return function generateTree(\n hierarchicalTree,\n hierarchicalFacetResult,\n currentHierarchicalLevel\n ) {\n var parent = hierarchicalTree;\n\n if (currentHierarchicalLevel > 0) {\n var level = 0;\n\n parent = hierarchicalTree;\n\n while (level < currentHierarchicalLevel) {\n /**\n * @type {object[]]} hierarchical data\n */\n var data = parent && Array.isArray(parent.data) ? parent.data : [];\n parent = find(data, function(subtree) {\n return subtree.isRefined;\n });\n level++;\n }\n }\n\n // we found a refined parent, let's add current level data under it\n if (parent) {\n // filter values in case an object has multiple categories:\n // {\n // categories: {\n // level0: ['beers', 'bières'],\n // level1: ['beers > IPA', 'bières > Belges']\n // }\n // }\n //\n // If parent refinement is `beers`, then we do not want to have `bières > Belges`\n // showing up\n\n var picked = Object.keys(hierarchicalFacetResult.data)\n .map(function(facetValue) {\n return [facetValue, hierarchicalFacetResult.data[facetValue]];\n })\n .filter(function(tuple) {\n var facetValue = tuple[0];\n return onlyMatchingTree(\n facetValue,\n parent.path || hierarchicalRootPath,\n currentRefinement,\n hierarchicalSeparator,\n hierarchicalRootPath,\n hierarchicalShowParentLevel\n );\n });\n\n parent.data = orderBy(\n picked.map(function(tuple) {\n var facetValue = tuple[0];\n var facetCount = tuple[1];\n\n return format(\n facetCount,\n facetValue,\n hierarchicalSeparator,\n currentRefinement,\n hierarchicalFacetResult.exhaustive\n );\n }),\n sortBy[0],\n sortBy[1]\n );\n }\n\n return hierarchicalTree;\n };\n}\n\nfunction onlyMatchingTree(\n facetValue,\n parentPath,\n currentRefinement,\n hierarchicalSeparator,\n hierarchicalRootPath,\n hierarchicalShowParentLevel\n) {\n // we want the facetValue is a child of hierarchicalRootPath\n if (\n hierarchicalRootPath &&\n (facetValue.indexOf(hierarchicalRootPath) !== 0 ||\n hierarchicalRootPath === facetValue)\n ) {\n return false;\n }\n\n // we always want root levels (only when there is no prefix path)\n return (\n (!hierarchicalRootPath &&\n facetValue.indexOf(hierarchicalSeparator) === -1) ||\n // if there is a rootPath, being root level mean 1 level under rootPath\n (hierarchicalRootPath &&\n facetValue.split(hierarchicalSeparator).length -\n hierarchicalRootPath.split(hierarchicalSeparator).length ===\n 1) ||\n // if current refinement is a root level and current facetValue is a root level,\n // keep the facetValue\n (facetValue.indexOf(hierarchicalSeparator) === -1 &&\n currentRefinement.indexOf(hierarchicalSeparator) === -1) ||\n // currentRefinement is a child of the facet value\n currentRefinement.indexOf(facetValue) === 0 ||\n // facetValue is a child of the current parent, add it\n (facetValue.indexOf(parentPath + hierarchicalSeparator) === 0 &&\n (hierarchicalShowParentLevel ||\n facetValue.indexOf(currentRefinement) === 0))\n );\n}\n\nfunction format(\n facetCount,\n facetValue,\n hierarchicalSeparator,\n currentRefinement,\n exhaustive\n) {\n var parts = facetValue.split(hierarchicalSeparator);\n return {\n name: parts[parts.length - 1].trim(),\n path: facetValue,\n count: facetCount,\n isRefined:\n currentRefinement === facetValue ||\n currentRefinement.indexOf(facetValue + hierarchicalSeparator) === 0,\n exhaustive: exhaustive,\n data: null\n };\n}\n","'use strict';\n\nvar merge = require('../functions/merge');\nvar defaultsPure = require('../functions/defaultsPure');\nvar orderBy = require('../functions/orderBy');\nvar compact = require('../functions/compact');\nvar find = require('../functions/find');\nvar findIndex = require('../functions/findIndex');\nvar formatSort = require('../functions/formatSort');\n\nvar generateHierarchicalTree = require('./generate-hierarchical-tree');\n\n/**\n * @typedef SearchResults.Facet\n * @type {object}\n * @property {string} name name of the attribute in the record\n * @property {object} data the faceting data: value, number of entries\n * @property {object} stats undefined unless facet_stats is retrieved from algolia\n */\n\n/**\n * @typedef SearchResults.HierarchicalFacet\n * @type {object}\n * @property {string} name name of the current value given the hierarchical level, trimmed.\n * If root node, you get the facet name\n * @property {number} count number of objects matching this hierarchical value\n * @property {string} path the current hierarchical value full path\n * @property {boolean} isRefined `true` if the current value was refined, `false` otherwise\n * @property {HierarchicalFacet[]} data sub values for the current level\n */\n\n/**\n * @typedef SearchResults.FacetValue\n * @type {object}\n * @property {string} name the facet value itself\n * @property {number} count times this facet appears in the results\n * @property {boolean} isRefined is the facet currently selected\n * @property {boolean} isExcluded is the facet currently excluded (only for conjunctive facets)\n */\n\n/**\n * @typedef Refinement\n * @type {object}\n * @property {string} type the type of filter used:\n * `numeric`, `facet`, `exclude`, `disjunctive`, `hierarchical`\n * @property {string} attributeName name of the attribute used for filtering\n * @property {string} name the value of the filter\n * @property {number} numericValue the value as a number. Only for numeric filters.\n * @property {string} operator the operator used. Only for numeric filters.\n * @property {number} count the number of computed hits for this filter. Only on facets.\n * @property {boolean} exhaustive if the count is exhaustive\n */\n\n/**\n * @param {string[]} attributes\n */\nfunction getIndices(attributes) {\n var indices = {};\n\n attributes.forEach(function(val, idx) {\n indices[val] = idx;\n });\n\n return indices;\n}\n\nfunction assignFacetStats(dest, facetStats, key) {\n if (facetStats && facetStats[key]) {\n dest.stats = facetStats[key];\n }\n}\n\n/**\n * @typedef {Object} HierarchicalFacet\n * @property {string} name\n * @property {string[]} attributes\n */\n\n/**\n * @param {HierarchicalFacet[]} hierarchicalFacets\n * @param {string} hierarchicalAttributeName\n */\nfunction findMatchingHierarchicalFacetFromAttributeName(\n hierarchicalFacets,\n hierarchicalAttributeName\n) {\n return find(hierarchicalFacets, function facetKeyMatchesAttribute(\n hierarchicalFacet\n ) {\n var facetNames = hierarchicalFacet.attributes || [];\n return facetNames.indexOf(hierarchicalAttributeName) > -1;\n });\n}\n\n/*eslint-disable */\n/**\n * Constructor for SearchResults\n * @class\n * @classdesc SearchResults contains the results of a query to Algolia using the\n * {@link AlgoliaSearchHelper}.\n * @param {SearchParameters} state state that led to the response\n * @param {array.} results the results from algolia client\n * @example SearchResults of the first query in\n * the instant search demo\n{\n \"hitsPerPage\": 10,\n \"processingTimeMS\": 2,\n \"facets\": [\n {\n \"name\": \"type\",\n \"data\": {\n \"HardGood\": 6627,\n \"BlackTie\": 550,\n \"Music\": 665,\n \"Software\": 131,\n \"Game\": 456,\n \"Movie\": 1571\n },\n \"exhaustive\": false\n },\n {\n \"exhaustive\": false,\n \"data\": {\n \"Free shipping\": 5507\n },\n \"name\": \"shipping\"\n }\n ],\n \"hits\": [\n {\n \"thumbnailImage\": \"http://img.bbystatic.com/BestBuy_US/images/products/1688/1688832_54x108_s.gif\",\n \"_highlightResult\": {\n \"shortDescription\": {\n \"matchLevel\": \"none\",\n \"value\": \"Safeguard your PC, Mac, Android and iOS devices with comprehensive Internet protection\",\n \"matchedWords\": []\n },\n \"category\": {\n \"matchLevel\": \"none\",\n \"value\": \"Computer Security Software\",\n \"matchedWords\": []\n },\n \"manufacturer\": {\n \"matchedWords\": [],\n \"value\": \"Webroot\",\n \"matchLevel\": \"none\"\n },\n \"name\": {\n \"value\": \"Webroot SecureAnywhere Internet Security (3-Device) (1-Year Subscription) - Mac/Windows\",\n \"matchedWords\": [],\n \"matchLevel\": \"none\"\n }\n },\n \"image\": \"http://img.bbystatic.com/BestBuy_US/images/products/1688/1688832_105x210_sc.jpg\",\n \"shipping\": \"Free shipping\",\n \"bestSellingRank\": 4,\n \"shortDescription\": \"Safeguard your PC, Mac, Android and iOS devices with comprehensive Internet protection\",\n \"url\": \"http://www.bestbuy.com/site/webroot-secureanywhere-internet-security-3-devi…d=1219060687969&skuId=1688832&cmp=RMX&ky=2d3GfEmNIzjA0vkzveHdZEBgpPCyMnLTJ\",\n \"name\": \"Webroot SecureAnywhere Internet Security (3-Device) (1-Year Subscription) - Mac/Windows\",\n \"category\": \"Computer Security Software\",\n \"salePrice_range\": \"1 - 50\",\n \"objectID\": \"1688832\",\n \"type\": \"Software\",\n \"customerReviewCount\": 5980,\n \"salePrice\": 49.99,\n \"manufacturer\": \"Webroot\"\n },\n ....\n ],\n \"nbHits\": 10000,\n \"disjunctiveFacets\": [\n {\n \"exhaustive\": false,\n \"data\": {\n \"5\": 183,\n \"12\": 112,\n \"7\": 149,\n ...\n },\n \"name\": \"customerReviewCount\",\n \"stats\": {\n \"max\": 7461,\n \"avg\": 157.939,\n \"min\": 1\n }\n },\n {\n \"data\": {\n \"Printer Ink\": 142,\n \"Wireless Speakers\": 60,\n \"Point & Shoot Cameras\": 48,\n ...\n },\n \"name\": \"category\",\n \"exhaustive\": false\n },\n {\n \"exhaustive\": false,\n \"data\": {\n \"> 5000\": 2,\n \"1 - 50\": 6524,\n \"501 - 2000\": 566,\n \"201 - 500\": 1501,\n \"101 - 200\": 1360,\n \"2001 - 5000\": 47\n },\n \"name\": \"salePrice_range\"\n },\n {\n \"data\": {\n \"Dynex™\": 202,\n \"Insignia™\": 230,\n \"PNY\": 72,\n ...\n },\n \"name\": \"manufacturer\",\n \"exhaustive\": false\n }\n ],\n \"query\": \"\",\n \"nbPages\": 100,\n \"page\": 0,\n \"index\": \"bestbuy\"\n}\n **/\n/*eslint-enable */\nfunction SearchResults(state, results) {\n var mainSubResponse = results[0];\n\n this._rawResults = results;\n\n /**\n * query used to generate the results\n * @member {string}\n */\n this.query = mainSubResponse.query;\n /**\n * The query as parsed by the engine given all the rules.\n * @member {string}\n */\n this.parsedQuery = mainSubResponse.parsedQuery;\n /**\n * all the records that match the search parameters. Each record is\n * augmented with a new attribute `_highlightResult`\n * which is an object keyed by attribute and with the following properties:\n * - `value` : the value of the facet highlighted (html)\n * - `matchLevel`: full, partial or none depending on how the query terms match\n * @member {object[]}\n */\n this.hits = mainSubResponse.hits;\n /**\n * index where the results come from\n * @member {string}\n */\n this.index = mainSubResponse.index;\n /**\n * number of hits per page requested\n * @member {number}\n */\n this.hitsPerPage = mainSubResponse.hitsPerPage;\n /**\n * total number of hits of this query on the index\n * @member {number}\n */\n this.nbHits = mainSubResponse.nbHits;\n /**\n * total number of pages with respect to the number of hits per page and the total number of hits\n * @member {number}\n */\n this.nbPages = mainSubResponse.nbPages;\n /**\n * current page\n * @member {number}\n */\n this.page = mainSubResponse.page;\n /**\n * sum of the processing time of all the queries\n * @member {number}\n */\n this.processingTimeMS = results.reduce(function(sum, result) {\n return result.processingTimeMS === undefined\n ? sum\n : sum + result.processingTimeMS;\n }, 0);\n /**\n * The position if the position was guessed by IP.\n * @member {string}\n * @example \"48.8637,2.3615\",\n */\n this.aroundLatLng = mainSubResponse.aroundLatLng;\n /**\n * The radius computed by Algolia.\n * @member {string}\n * @example \"126792922\",\n */\n this.automaticRadius = mainSubResponse.automaticRadius;\n /**\n * String identifying the server used to serve this request.\n *\n * getRankingInfo needs to be set to `true` for this to be returned\n *\n * @member {string}\n * @example \"c7-use-2.algolia.net\",\n */\n this.serverUsed = mainSubResponse.serverUsed;\n /**\n * Boolean that indicates if the computation of the counts did time out.\n * @deprecated\n * @member {boolean}\n */\n this.timeoutCounts = mainSubResponse.timeoutCounts;\n /**\n * Boolean that indicates if the computation of the hits did time out.\n * @deprecated\n * @member {boolean}\n */\n this.timeoutHits = mainSubResponse.timeoutHits;\n\n /**\n * True if the counts of the facets is exhaustive\n * @member {boolean}\n */\n this.exhaustiveFacetsCount = mainSubResponse.exhaustiveFacetsCount;\n\n /**\n * True if the number of hits is exhaustive\n * @member {boolean}\n */\n this.exhaustiveNbHits = mainSubResponse.exhaustiveNbHits;\n\n\n /**\n * Contains the userData if they are set by a [query rule](https://www.algolia.com/doc/guides/query-rules/query-rules-overview/).\n * @member {object[]}\n */\n this.userData = mainSubResponse.userData;\n\n /**\n * queryID is the unique identifier of the query used to generate the current search results.\n * This value is only available if the `clickAnalytics` search parameter is set to `true`.\n * @member {string}\n */\n this.queryID = mainSubResponse.queryID;\n\n /**\n * disjunctive facets results\n * @member {SearchResults.Facet[]}\n */\n this.disjunctiveFacets = [];\n /**\n * disjunctive facets results\n * @member {SearchResults.HierarchicalFacet[]}\n */\n this.hierarchicalFacets = state.hierarchicalFacets.map(function initFutureTree() {\n return [];\n });\n /**\n * other facets results\n * @member {SearchResults.Facet[]}\n */\n this.facets = [];\n\n var disjunctiveFacets = state.getRefinedDisjunctiveFacets();\n\n var facetsIndices = getIndices(state.facets);\n var disjunctiveFacetsIndices = getIndices(state.disjunctiveFacets);\n var nextDisjunctiveResult = 1;\n\n var self = this;\n // Since we send request only for disjunctive facets that have been refined,\n // we get the facets information from the first, general, response.\n\n var mainFacets = mainSubResponse.facets || {};\n\n Object.keys(mainFacets).forEach(function(facetKey) {\n var facetValueObject = mainFacets[facetKey];\n\n var hierarchicalFacet = findMatchingHierarchicalFacetFromAttributeName(\n state.hierarchicalFacets,\n facetKey\n );\n\n if (hierarchicalFacet) {\n // Place the hierarchicalFacet data at the correct index depending on\n // the attributes order that was defined at the helper initialization\n var facetIndex = hierarchicalFacet.attributes.indexOf(facetKey);\n var idxAttributeName = findIndex(state.hierarchicalFacets, function(f) {\n return f.name === hierarchicalFacet.name;\n });\n self.hierarchicalFacets[idxAttributeName][facetIndex] = {\n attribute: facetKey,\n data: facetValueObject,\n exhaustive: mainSubResponse.exhaustiveFacetsCount\n };\n } else {\n var isFacetDisjunctive = state.disjunctiveFacets.indexOf(facetKey) !== -1;\n var isFacetConjunctive = state.facets.indexOf(facetKey) !== -1;\n var position;\n\n if (isFacetDisjunctive) {\n position = disjunctiveFacetsIndices[facetKey];\n self.disjunctiveFacets[position] = {\n name: facetKey,\n data: facetValueObject,\n exhaustive: mainSubResponse.exhaustiveFacetsCount\n };\n assignFacetStats(self.disjunctiveFacets[position], mainSubResponse.facets_stats, facetKey);\n }\n if (isFacetConjunctive) {\n position = facetsIndices[facetKey];\n self.facets[position] = {\n name: facetKey,\n data: facetValueObject,\n exhaustive: mainSubResponse.exhaustiveFacetsCount\n };\n assignFacetStats(self.facets[position], mainSubResponse.facets_stats, facetKey);\n }\n }\n });\n\n // Make sure we do not keep holes within the hierarchical facets\n this.hierarchicalFacets = compact(this.hierarchicalFacets);\n\n // aggregate the refined disjunctive facets\n disjunctiveFacets.forEach(function(disjunctiveFacet) {\n var result = results[nextDisjunctiveResult];\n var facets = result && result.facets ? result.facets : {};\n var hierarchicalFacet = state.getHierarchicalFacetByName(disjunctiveFacet);\n\n // There should be only item in facets.\n Object.keys(facets).forEach(function(dfacet) {\n var facetResults = facets[dfacet];\n\n var position;\n\n if (hierarchicalFacet) {\n position = findIndex(state.hierarchicalFacets, function(f) {\n return f.name === hierarchicalFacet.name;\n });\n var attributeIndex = findIndex(self.hierarchicalFacets[position], function(f) {\n return f.attribute === dfacet;\n });\n\n // previous refinements and no results so not able to find it\n if (attributeIndex === -1) {\n return;\n }\n\n self.hierarchicalFacets[position][attributeIndex].data = merge(\n {},\n self.hierarchicalFacets[position][attributeIndex].data,\n facetResults\n );\n } else {\n position = disjunctiveFacetsIndices[dfacet];\n\n var dataFromMainRequest = mainSubResponse.facets && mainSubResponse.facets[dfacet] || {};\n\n self.disjunctiveFacets[position] = {\n name: dfacet,\n data: defaultsPure({}, facetResults, dataFromMainRequest),\n exhaustive: result.exhaustiveFacetsCount\n };\n assignFacetStats(self.disjunctiveFacets[position], result.facets_stats, dfacet);\n\n if (state.disjunctiveFacetsRefinements[dfacet]) {\n state.disjunctiveFacetsRefinements[dfacet].forEach(function(refinementValue) {\n // add the disjunctive refinements if it is no more retrieved\n if (!self.disjunctiveFacets[position].data[refinementValue] &&\n state.disjunctiveFacetsRefinements[dfacet].indexOf(refinementValue) > -1) {\n self.disjunctiveFacets[position].data[refinementValue] = 0;\n }\n });\n }\n }\n });\n nextDisjunctiveResult++;\n });\n\n // if we have some root level values for hierarchical facets, merge them\n state.getRefinedHierarchicalFacets().forEach(function(refinedFacet) {\n var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);\n var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n\n var currentRefinement = state.getHierarchicalRefinement(refinedFacet);\n // if we are already at a root refinement (or no refinement at all), there is no\n // root level values request\n if (currentRefinement.length === 0 || currentRefinement[0].split(separator).length < 2) {\n return;\n }\n\n var result = results[nextDisjunctiveResult];\n var facets = result && result.facets\n ? result.facets\n : {};\n Object.keys(facets).forEach(function(dfacet) {\n var facetResults = facets[dfacet];\n var position = findIndex(state.hierarchicalFacets, function(f) {\n return f.name === hierarchicalFacet.name;\n });\n var attributeIndex = findIndex(self.hierarchicalFacets[position], function(f) {\n return f.attribute === dfacet;\n });\n\n // previous refinements and no results so not able to find it\n if (attributeIndex === -1) {\n return;\n }\n\n // when we always get root levels, if the hits refinement is `beers > IPA` (count: 5),\n // then the disjunctive values will be `beers` (count: 100),\n // but we do not want to display\n // | beers (100)\n // > IPA (5)\n // We want\n // | beers (5)\n // > IPA (5)\n var defaultData = {};\n\n if (currentRefinement.length > 0) {\n var root = currentRefinement[0].split(separator)[0];\n defaultData[root] = self.hierarchicalFacets[position][attributeIndex].data[root];\n }\n\n self.hierarchicalFacets[position][attributeIndex].data = defaultsPure(\n defaultData,\n facetResults,\n self.hierarchicalFacets[position][attributeIndex].data\n );\n });\n\n nextDisjunctiveResult++;\n });\n\n // add the excludes\n Object.keys(state.facetsExcludes).forEach(function(facetName) {\n var excludes = state.facetsExcludes[facetName];\n var position = facetsIndices[facetName];\n\n self.facets[position] = {\n name: facetName,\n data: mainSubResponse.facets[facetName],\n exhaustive: mainSubResponse.exhaustiveFacetsCount\n };\n excludes.forEach(function(facetValue) {\n self.facets[position] = self.facets[position] || {name: facetName};\n self.facets[position].data = self.facets[position].data || {};\n self.facets[position].data[facetValue] = 0;\n });\n });\n\n /**\n * @type {Array}\n */\n this.hierarchicalFacets = this.hierarchicalFacets.map(generateHierarchicalTree(state));\n\n /**\n * @type {Array}\n */\n this.facets = compact(this.facets);\n /**\n * @type {Array}\n */\n this.disjunctiveFacets = compact(this.disjunctiveFacets);\n\n this._state = state;\n}\n\n/**\n * Get a facet object with its name\n * @deprecated\n * @param {string} name name of the faceted attribute\n * @return {SearchResults.Facet} the facet object\n */\nSearchResults.prototype.getFacetByName = function(name) {\n function predicate(facet) {\n return facet.name === name;\n }\n\n return find(this.facets, predicate) ||\n find(this.disjunctiveFacets, predicate) ||\n find(this.hierarchicalFacets, predicate);\n};\n\n/**\n * Get the facet values of a specified attribute from a SearchResults object.\n * @private\n * @param {SearchResults} results the search results to search in\n * @param {string} attribute name of the faceted attribute to search for\n * @return {array|object} facet values. For the hierarchical facets it is an object.\n */\nfunction extractNormalizedFacetValues(results, attribute) {\n function predicate(facet) {\n return facet.name === attribute;\n }\n\n if (results._state.isConjunctiveFacet(attribute)) {\n var facet = find(results.facets, predicate);\n if (!facet) return [];\n\n return Object.keys(facet.data).map(function(name) {\n return {\n name: name,\n count: facet.data[name],\n isRefined: results._state.isFacetRefined(attribute, name),\n isExcluded: results._state.isExcludeRefined(attribute, name)\n };\n });\n } else if (results._state.isDisjunctiveFacet(attribute)) {\n var disjunctiveFacet = find(results.disjunctiveFacets, predicate);\n if (!disjunctiveFacet) return [];\n\n return Object.keys(disjunctiveFacet.data).map(function(name) {\n return {\n name: name,\n count: disjunctiveFacet.data[name],\n isRefined: results._state.isDisjunctiveFacetRefined(attribute, name)\n };\n });\n } else if (results._state.isHierarchicalFacet(attribute)) {\n return find(results.hierarchicalFacets, predicate);\n }\n}\n\n/**\n * Sort nodes of a hierarchical facet results\n * @private\n * @param {HierarchicalFacet} node node to upon which we want to apply the sort\n */\nfunction recSort(sortFn, node) {\n if (!node.data || node.data.length === 0) {\n return node;\n }\n\n var children = node.data.map(function(childNode) {\n return recSort(sortFn, childNode);\n });\n var sortedChildren = sortFn(children);\n var newNode = merge({}, node, {data: sortedChildren});\n return newNode;\n}\n\nSearchResults.DEFAULT_SORT = ['isRefined:desc', 'count:desc', 'name:asc'];\n\nfunction vanillaSortFn(order, data) {\n return data.sort(order);\n}\n\n/**\n * Get a the list of values for a given facet attribute. Those values are sorted\n * refinement first, descending count (bigger value on top), and name ascending\n * (alphabetical order). The sort formula can overridden using either string based\n * predicates or a function.\n *\n * This method will return all the values returned by the Algolia engine plus all\n * the values already refined. This means that it can happen that the\n * `maxValuesPerFacet` [configuration](https://www.algolia.com/doc/rest-api/search#param-maxValuesPerFacet)\n * might not be respected if you have facet values that are already refined.\n * @param {string} attribute attribute name\n * @param {object} opts configuration options.\n * @param {Array. | function} opts.sortBy\n * When using strings, it consists of\n * the name of the [FacetValue](#SearchResults.FacetValue) or the\n * [HierarchicalFacet](#SearchResults.HierarchicalFacet) attributes with the\n * order (`asc` or `desc`). For example to order the value by count, the\n * argument would be `['count:asc']`.\n *\n * If only the attribute name is specified, the ordering defaults to the one\n * specified in the default value for this attribute.\n *\n * When not specified, the order is\n * ascending. This parameter can also be a function which takes two facet\n * values and should return a number, 0 if equal, 1 if the first argument is\n * bigger or -1 otherwise.\n *\n * The default value for this attribute `['isRefined:desc', 'count:desc', 'name:asc']`\n * @return {FacetValue[]|HierarchicalFacet|undefined} depending on the type of facet of\n * the attribute requested (hierarchical, disjunctive or conjunctive)\n * @example\n * helper.on('result', function(event){\n * //get values ordered only by name ascending using the string predicate\n * event.results.getFacetValues('city', {sortBy: ['name:asc']});\n * //get values ordered only by count ascending using a function\n * event.results.getFacetValues('city', {\n * // this is equivalent to ['count:asc']\n * sortBy: function(a, b) {\n * if (a.count === b.count) return 0;\n * if (a.count > b.count) return 1;\n * if (b.count > a.count) return -1;\n * }\n * });\n * });\n */\nSearchResults.prototype.getFacetValues = function(attribute, opts) {\n var facetValues = extractNormalizedFacetValues(this, attribute);\n if (!facetValues) {\n return undefined;\n }\n\n var options = defaultsPure({}, opts, {sortBy: SearchResults.DEFAULT_SORT});\n\n if (Array.isArray(options.sortBy)) {\n var order = formatSort(options.sortBy, SearchResults.DEFAULT_SORT);\n if (Array.isArray(facetValues)) {\n return orderBy(facetValues, order[0], order[1]);\n }\n // If facetValues is not an array, it's an object thus a hierarchical facet object\n return recSort(function(hierarchicalFacetValues) {\n return orderBy(hierarchicalFacetValues, order[0], order[1]);\n }, facetValues);\n } else if (typeof options.sortBy === 'function') {\n if (Array.isArray(facetValues)) {\n return facetValues.sort(options.sortBy);\n }\n // If facetValues is not an array, it's an object thus a hierarchical facet object\n return recSort(function(data) {\n return vanillaSortFn(options.sortBy, data);\n }, facetValues);\n }\n throw new Error(\n 'options.sortBy is optional but if defined it must be ' +\n 'either an array of string (predicates) or a sorting function'\n );\n};\n\n/**\n * Returns the facet stats if attribute is defined and the facet contains some.\n * Otherwise returns undefined.\n * @param {string} attribute name of the faceted attribute\n * @return {object} The stats of the facet\n */\nSearchResults.prototype.getFacetStats = function(attribute) {\n if (this._state.isConjunctiveFacet(attribute)) {\n return getFacetStatsIfAvailable(this.facets, attribute);\n } else if (this._state.isDisjunctiveFacet(attribute)) {\n return getFacetStatsIfAvailable(this.disjunctiveFacets, attribute);\n }\n\n return undefined;\n};\n\n/**\n * @typedef {Object} FacetListItem\n * @property {string} name\n */\n\n/**\n * @param {FacetListItem[]} facetList (has more items, but enough for here)\n * @param {string} facetName\n */\nfunction getFacetStatsIfAvailable(facetList, facetName) {\n var data = find(facetList, function(facet) {\n return facet.name === facetName;\n });\n return data && data.stats;\n}\n\n/**\n * Returns all refinements for all filters + tags. It also provides\n * additional information: count and exhaustiveness for each filter.\n *\n * See the [refinement type](#Refinement) for an exhaustive view of the available\n * data.\n *\n * Note that for a numeric refinement, results are grouped per operator, this\n * means that it will return responses for operators which are empty.\n *\n * @return {Array.} all the refinements\n */\nSearchResults.prototype.getRefinements = function() {\n var state = this._state;\n var results = this;\n var res = [];\n\n Object.keys(state.facetsRefinements).forEach(function(attributeName) {\n state.facetsRefinements[attributeName].forEach(function(name) {\n res.push(getRefinement(state, 'facet', attributeName, name, results.facets));\n });\n });\n\n Object.keys(state.facetsExcludes).forEach(function(attributeName) {\n state.facetsExcludes[attributeName].forEach(function(name) {\n res.push(getRefinement(state, 'exclude', attributeName, name, results.facets));\n });\n });\n\n Object.keys(state.disjunctiveFacetsRefinements).forEach(function(attributeName) {\n state.disjunctiveFacetsRefinements[attributeName].forEach(function(name) {\n res.push(getRefinement(state, 'disjunctive', attributeName, name, results.disjunctiveFacets));\n });\n });\n\n Object.keys(state.hierarchicalFacetsRefinements).forEach(function(attributeName) {\n state.hierarchicalFacetsRefinements[attributeName].forEach(function(name) {\n res.push(getHierarchicalRefinement(state, attributeName, name, results.hierarchicalFacets));\n });\n });\n\n\n Object.keys(state.numericRefinements).forEach(function(attributeName) {\n var operators = state.numericRefinements[attributeName];\n Object.keys(operators).forEach(function(operator) {\n operators[operator].forEach(function(value) {\n res.push({\n type: 'numeric',\n attributeName: attributeName,\n name: value,\n numericValue: value,\n operator: operator\n });\n });\n });\n });\n\n state.tagRefinements.forEach(function(name) {\n res.push({type: 'tag', attributeName: '_tags', name: name});\n });\n\n return res;\n};\n\n/**\n * @typedef {Object} Facet\n * @property {string} name\n * @property {Object} data\n * @property {boolean} exhaustive\n */\n\n/**\n * @param {*} state\n * @param {*} type\n * @param {string} attributeName\n * @param {*} name\n * @param {Facet[]} resultsFacets\n */\nfunction getRefinement(state, type, attributeName, name, resultsFacets) {\n var facet = find(resultsFacets, function(f) {\n return f.name === attributeName;\n });\n var count = facet && facet.data && facet.data[name] ? facet.data[name] : 0;\n var exhaustive = (facet && facet.exhaustive) || false;\n\n return {\n type: type,\n attributeName: attributeName,\n name: name,\n count: count,\n exhaustive: exhaustive\n };\n}\n\n/**\n * @param {*} state\n * @param {string} attributeName\n * @param {*} name\n * @param {Facet[]} resultsFacets\n */\nfunction getHierarchicalRefinement(state, attributeName, name, resultsFacets) {\n var facetDeclaration = state.getHierarchicalFacetByName(attributeName);\n var separator = state._getHierarchicalFacetSeparator(facetDeclaration);\n var split = name.split(separator);\n var rootFacet = find(resultsFacets, function(facet) {\n return facet.name === attributeName;\n });\n\n var facet = split.reduce(function(intermediateFacet, part) {\n var newFacet =\n intermediateFacet && find(intermediateFacet.data, function(f) {\n return f.name === part;\n });\n return newFacet !== undefined ? newFacet : intermediateFacet;\n }, rootFacet);\n\n var count = (facet && facet.count) || 0;\n var exhaustive = (facet && facet.exhaustive) || false;\n var path = (facet && facet.path) || '';\n\n return {\n type: 'hierarchical',\n attributeName: attributeName,\n name: path,\n count: count,\n exhaustive: exhaustive\n };\n}\n\nmodule.exports = SearchResults;\n","// Copyright Joyent, Inc. and other Node contributors.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a\n// copy of this software and associated documentation files (the\n// \"Software\"), to deal in the Software without restriction, including\n// without limitation the rights to use, copy, modify, merge, publish,\n// distribute, sublicense, and/or sell copies of the Software, and to permit\n// persons to whom the Software is furnished to do so, subject to the\n// following conditions:\n//\n// The above copyright notice and this permission notice shall be included\n// in all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN\n// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,\n// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR\n// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE\n// USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nfunction EventEmitter() {\n this._events = this._events || {};\n this._maxListeners = this._maxListeners || undefined;\n}\nmodule.exports = EventEmitter;\n\n// Backwards-compat with node 0.10.x\nEventEmitter.EventEmitter = EventEmitter;\n\nEventEmitter.prototype._events = undefined;\nEventEmitter.prototype._maxListeners = undefined;\n\n// By default EventEmitters will print a warning if more than 10 listeners are\n// added to it. This is a useful default which helps finding memory leaks.\nEventEmitter.defaultMaxListeners = 10;\n\n// Obviously not all Emitters should be limited to 10. This function allows\n// that to be increased. Set to zero for unlimited.\nEventEmitter.prototype.setMaxListeners = function(n) {\n if (!isNumber(n) || n < 0 || isNaN(n))\n throw TypeError('n must be a positive number');\n this._maxListeners = n;\n return this;\n};\n\nEventEmitter.prototype.emit = function(type) {\n var er, handler, len, args, i, listeners;\n\n if (!this._events)\n this._events = {};\n\n // If there is no 'error' event listener then throw.\n if (type === 'error') {\n if (!this._events.error ||\n (isObject(this._events.error) && !this._events.error.length)) {\n er = arguments[1];\n if (er instanceof Error) {\n throw er; // Unhandled 'error' event\n } else {\n // At least give some kind of context to the user\n var err = new Error('Uncaught, unspecified \"error\" event. (' + er + ')');\n err.context = er;\n throw err;\n }\n }\n }\n\n handler = this._events[type];\n\n if (isUndefined(handler))\n return false;\n\n if (isFunction(handler)) {\n switch (arguments.length) {\n // fast cases\n case 1:\n handler.call(this);\n break;\n case 2:\n handler.call(this, arguments[1]);\n break;\n case 3:\n handler.call(this, arguments[1], arguments[2]);\n break;\n // slower\n default:\n args = Array.prototype.slice.call(arguments, 1);\n handler.apply(this, args);\n }\n } else if (isObject(handler)) {\n args = Array.prototype.slice.call(arguments, 1);\n listeners = handler.slice();\n len = listeners.length;\n for (i = 0; i < len; i++)\n listeners[i].apply(this, args);\n }\n\n return true;\n};\n\nEventEmitter.prototype.addListener = function(type, listener) {\n var m;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events)\n this._events = {};\n\n // To avoid recursion in the case that type === \"newListener\"! Before\n // adding it to the listeners, first emit \"newListener\".\n if (this._events.newListener)\n this.emit('newListener', type,\n isFunction(listener.listener) ?\n listener.listener : listener);\n\n if (!this._events[type])\n // Optimize the case of one listener. Don't need the extra array object.\n this._events[type] = listener;\n else if (isObject(this._events[type]))\n // If we've already got an array, just append.\n this._events[type].push(listener);\n else\n // Adding the second element, need to change to array.\n this._events[type] = [this._events[type], listener];\n\n // Check for listener leak\n if (isObject(this._events[type]) && !this._events[type].warned) {\n if (!isUndefined(this._maxListeners)) {\n m = this._maxListeners;\n } else {\n m = EventEmitter.defaultMaxListeners;\n }\n\n if (m && m > 0 && this._events[type].length > m) {\n this._events[type].warned = true;\n console.error('(node) warning: possible EventEmitter memory ' +\n 'leak detected. %d listeners added. ' +\n 'Use emitter.setMaxListeners() to increase limit.',\n this._events[type].length);\n if (typeof console.trace === 'function') {\n // not supported in IE 10\n console.trace();\n }\n }\n }\n\n return this;\n};\n\nEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\nEventEmitter.prototype.once = function(type, listener) {\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n var fired = false;\n\n function g() {\n this.removeListener(type, g);\n\n if (!fired) {\n fired = true;\n listener.apply(this, arguments);\n }\n }\n\n g.listener = listener;\n this.on(type, g);\n\n return this;\n};\n\n// emits a 'removeListener' event iff the listener was removed\nEventEmitter.prototype.removeListener = function(type, listener) {\n var list, position, length, i;\n\n if (!isFunction(listener))\n throw TypeError('listener must be a function');\n\n if (!this._events || !this._events[type])\n return this;\n\n list = this._events[type];\n length = list.length;\n position = -1;\n\n if (list === listener ||\n (isFunction(list.listener) && list.listener === listener)) {\n delete this._events[type];\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n\n } else if (isObject(list)) {\n for (i = length; i-- > 0;) {\n if (list[i] === listener ||\n (list[i].listener && list[i].listener === listener)) {\n position = i;\n break;\n }\n }\n\n if (position < 0)\n return this;\n\n if (list.length === 1) {\n list.length = 0;\n delete this._events[type];\n } else {\n list.splice(position, 1);\n }\n\n if (this._events.removeListener)\n this.emit('removeListener', type, listener);\n }\n\n return this;\n};\n\nEventEmitter.prototype.removeAllListeners = function(type) {\n var key, listeners;\n\n if (!this._events)\n return this;\n\n // not listening for removeListener, no need to emit\n if (!this._events.removeListener) {\n if (arguments.length === 0)\n this._events = {};\n else if (this._events[type])\n delete this._events[type];\n return this;\n }\n\n // emit removeListener for all listeners on all events\n if (arguments.length === 0) {\n for (key in this._events) {\n if (key === 'removeListener') continue;\n this.removeAllListeners(key);\n }\n this.removeAllListeners('removeListener');\n this._events = {};\n return this;\n }\n\n listeners = this._events[type];\n\n if (isFunction(listeners)) {\n this.removeListener(type, listeners);\n } else if (listeners) {\n // LIFO order\n while (listeners.length)\n this.removeListener(type, listeners[listeners.length - 1]);\n }\n delete this._events[type];\n\n return this;\n};\n\nEventEmitter.prototype.listeners = function(type) {\n var ret;\n if (!this._events || !this._events[type])\n ret = [];\n else if (isFunction(this._events[type]))\n ret = [this._events[type]];\n else\n ret = this._events[type].slice();\n return ret;\n};\n\nEventEmitter.prototype.listenerCount = function(type) {\n if (this._events) {\n var evlistener = this._events[type];\n\n if (isFunction(evlistener))\n return 1;\n else if (evlistener)\n return evlistener.length;\n }\n return 0;\n};\n\nEventEmitter.listenerCount = function(emitter, type) {\n return emitter.listenerCount(type);\n};\n\nfunction isFunction(arg) {\n return typeof arg === 'function';\n}\n\nfunction isNumber(arg) {\n return typeof arg === 'number';\n}\n\nfunction isObject(arg) {\n return typeof arg === 'object' && arg !== null;\n}\n\nfunction isUndefined(arg) {\n return arg === void 0;\n}\n","'use strict';\n\nfunction inherits(ctor, superCtor) {\n ctor.prototype = Object.create(superCtor.prototype, {\n constructor: {\n value: ctor,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n}\n\nmodule.exports = inherits;\n","'use strict';\n\nvar events = require('events');\nvar inherits = require('../functions/inherits');\n\n/**\n * A DerivedHelper is a way to create sub requests to\n * Algolia from a main helper.\n * @class\n * @classdesc The DerivedHelper provides an event based interface for search callbacks:\n * - search: when a search is triggered using the `search()` method.\n * - result: when the response is retrieved from Algolia and is processed.\n * This event contains a {@link SearchResults} object and the\n * {@link SearchParameters} corresponding to this answer.\n */\nfunction DerivedHelper(mainHelper, fn) {\n this.main = mainHelper;\n this.fn = fn;\n this.lastResults = null;\n}\n\ninherits(DerivedHelper, events.EventEmitter);\n\n/**\n * Detach this helper from the main helper\n * @return {undefined}\n * @throws Error if the derived helper is already detached\n */\nDerivedHelper.prototype.detach = function() {\n this.removeAllListeners();\n this.main.detachDerivedHelper(this);\n};\n\nDerivedHelper.prototype.getModifiedState = function(parameters) {\n return this.fn(parameters);\n};\n\nmodule.exports = DerivedHelper;\n","'use strict';\n\nvar merge = require('./functions/merge');\n\nvar requestBuilder = {\n /**\n * Get all the queries to send to the client, those queries can used directly\n * with the Algolia client.\n * @private\n * @return {object[]} The queries\n */\n _getQueries: function getQueries(index, state) {\n var queries = [];\n\n // One query for the hits\n queries.push({\n indexName: index,\n params: requestBuilder._getHitsSearchParams(state)\n });\n\n // One for each disjunctive facets\n state.getRefinedDisjunctiveFacets().forEach(function(refinedFacet) {\n queries.push({\n indexName: index,\n params: requestBuilder._getDisjunctiveFacetSearchParams(state, refinedFacet)\n });\n });\n\n // maybe more to get the root level of hierarchical facets when activated\n state.getRefinedHierarchicalFacets().forEach(function(refinedFacet) {\n var hierarchicalFacet = state.getHierarchicalFacetByName(refinedFacet);\n\n var currentRefinement = state.getHierarchicalRefinement(refinedFacet);\n // if we are deeper than level 0 (starting from `beer > IPA`)\n // we want to get the root values\n var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n if (currentRefinement.length > 0 && currentRefinement[0].split(separator).length > 1) {\n queries.push({\n indexName: index,\n params: requestBuilder._getDisjunctiveFacetSearchParams(state, refinedFacet, true)\n });\n }\n });\n\n return queries;\n },\n\n /**\n * Build search parameters used to fetch hits\n * @private\n * @return {object.}\n */\n _getHitsSearchParams: function(state) {\n var facets = state.facets\n .concat(state.disjunctiveFacets)\n .concat(requestBuilder._getHitsHierarchicalFacetsAttributes(state));\n\n\n var facetFilters = requestBuilder._getFacetFilters(state);\n var numericFilters = requestBuilder._getNumericFilters(state);\n var tagFilters = requestBuilder._getTagFilters(state);\n var additionalParams = {\n facets: facets,\n tagFilters: tagFilters\n };\n\n if (facetFilters.length > 0) {\n additionalParams.facetFilters = facetFilters;\n }\n\n if (numericFilters.length > 0) {\n additionalParams.numericFilters = numericFilters;\n }\n\n return merge({}, state.getQueryParams(), additionalParams);\n },\n\n /**\n * Build search parameters used to fetch a disjunctive facet\n * @private\n * @param {string} facet the associated facet name\n * @param {boolean} hierarchicalRootLevel ?? FIXME\n * @return {object}\n */\n _getDisjunctiveFacetSearchParams: function(state, facet, hierarchicalRootLevel) {\n var facetFilters = requestBuilder._getFacetFilters(state, facet, hierarchicalRootLevel);\n var numericFilters = requestBuilder._getNumericFilters(state, facet);\n var tagFilters = requestBuilder._getTagFilters(state);\n var additionalParams = {\n hitsPerPage: 1,\n page: 0,\n attributesToRetrieve: [],\n attributesToHighlight: [],\n attributesToSnippet: [],\n tagFilters: tagFilters,\n analytics: false,\n clickAnalytics: false\n };\n\n var hierarchicalFacet = state.getHierarchicalFacetByName(facet);\n\n if (hierarchicalFacet) {\n additionalParams.facets = requestBuilder._getDisjunctiveHierarchicalFacetAttribute(\n state,\n hierarchicalFacet,\n hierarchicalRootLevel\n );\n } else {\n additionalParams.facets = facet;\n }\n\n if (numericFilters.length > 0) {\n additionalParams.numericFilters = numericFilters;\n }\n\n if (facetFilters.length > 0) {\n additionalParams.facetFilters = facetFilters;\n }\n\n return merge({}, state.getQueryParams(), additionalParams);\n },\n\n /**\n * Return the numeric filters in an algolia request fashion\n * @private\n * @param {string} [facetName] the name of the attribute for which the filters should be excluded\n * @return {string[]} the numeric filters in the algolia format\n */\n _getNumericFilters: function(state, facetName) {\n if (state.numericFilters) {\n return state.numericFilters;\n }\n\n var numericFilters = [];\n\n Object.keys(state.numericRefinements).forEach(function(attribute) {\n var operators = state.numericRefinements[attribute] || {};\n Object.keys(operators).forEach(function(operator) {\n var values = operators[operator] || [];\n if (facetName !== attribute) {\n values.forEach(function(value) {\n if (Array.isArray(value)) {\n var vs = value.map(function(v) {\n return attribute + operator + v;\n });\n numericFilters.push(vs);\n } else {\n numericFilters.push(attribute + operator + value);\n }\n });\n }\n });\n });\n\n return numericFilters;\n },\n\n /**\n * Return the tags filters depending\n * @private\n * @return {string}\n */\n _getTagFilters: function(state) {\n if (state.tagFilters) {\n return state.tagFilters;\n }\n\n return state.tagRefinements.join(',');\n },\n\n\n /**\n * Build facetFilters parameter based on current refinements. The array returned\n * contains strings representing the facet filters in the algolia format.\n * @private\n * @param {string} [facet] if set, the current disjunctive facet\n * @return {array.}\n */\n _getFacetFilters: function(state, facet, hierarchicalRootLevel) {\n var facetFilters = [];\n\n var facetsRefinements = state.facetsRefinements || {};\n Object.keys(facetsRefinements).forEach(function(facetName) {\n var facetValues = facetsRefinements[facetName] || [];\n facetValues.forEach(function(facetValue) {\n facetFilters.push(facetName + ':' + facetValue);\n });\n });\n\n var facetsExcludes = state.facetsExcludes || {};\n Object.keys(facetsExcludes).forEach(function(facetName) {\n var facetValues = facetsExcludes[facetName] || [];\n facetValues.forEach(function(facetValue) {\n facetFilters.push(facetName + ':-' + facetValue);\n });\n });\n\n var disjunctiveFacetsRefinements = state.disjunctiveFacetsRefinements || {};\n Object.keys(disjunctiveFacetsRefinements).forEach(function(facetName) {\n var facetValues = disjunctiveFacetsRefinements[facetName] || [];\n if (facetName === facet || !facetValues || facetValues.length === 0) {\n return;\n }\n var orFilters = [];\n\n facetValues.forEach(function(facetValue) {\n orFilters.push(facetName + ':' + facetValue);\n });\n\n facetFilters.push(orFilters);\n });\n\n var hierarchicalFacetsRefinements = state.hierarchicalFacetsRefinements || {};\n Object.keys(hierarchicalFacetsRefinements).forEach(function(facetName) {\n var facetValues = hierarchicalFacetsRefinements[facetName] || [];\n var facetValue = facetValues[0];\n\n if (facetValue === undefined) {\n return;\n }\n\n var hierarchicalFacet = state.getHierarchicalFacetByName(facetName);\n var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n var rootPath = state._getHierarchicalRootPath(hierarchicalFacet);\n var attributeToRefine;\n var attributesIndex;\n\n // we ask for parent facet values only when the `facet` is the current hierarchical facet\n if (facet === facetName) {\n // if we are at the root level already, no need to ask for facet values, we get them from\n // the hits query\n if (facetValue.indexOf(separator) === -1 || (!rootPath && hierarchicalRootLevel === true) ||\n (rootPath && rootPath.split(separator).length === facetValue.split(separator).length)) {\n return;\n }\n\n if (!rootPath) {\n attributesIndex = facetValue.split(separator).length - 2;\n facetValue = facetValue.slice(0, facetValue.lastIndexOf(separator));\n } else {\n attributesIndex = rootPath.split(separator).length - 1;\n facetValue = rootPath;\n }\n\n attributeToRefine = hierarchicalFacet.attributes[attributesIndex];\n } else {\n attributesIndex = facetValue.split(separator).length - 1;\n\n attributeToRefine = hierarchicalFacet.attributes[attributesIndex];\n }\n\n if (attributeToRefine) {\n facetFilters.push([attributeToRefine + ':' + facetValue]);\n }\n });\n\n return facetFilters;\n },\n\n _getHitsHierarchicalFacetsAttributes: function(state) {\n var out = [];\n\n return state.hierarchicalFacets.reduce(\n // ask for as much levels as there's hierarchical refinements\n function getHitsAttributesForHierarchicalFacet(allAttributes, hierarchicalFacet) {\n var hierarchicalRefinement = state.getHierarchicalRefinement(hierarchicalFacet.name)[0];\n\n // if no refinement, ask for root level\n if (!hierarchicalRefinement) {\n allAttributes.push(hierarchicalFacet.attributes[0]);\n return allAttributes;\n }\n\n var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n var level = hierarchicalRefinement.split(separator).length;\n var newAttributes = hierarchicalFacet.attributes.slice(0, level + 1);\n\n return allAttributes.concat(newAttributes);\n }, out);\n },\n\n _getDisjunctiveHierarchicalFacetAttribute: function(state, hierarchicalFacet, rootLevel) {\n var separator = state._getHierarchicalFacetSeparator(hierarchicalFacet);\n if (rootLevel === true) {\n var rootPath = state._getHierarchicalRootPath(hierarchicalFacet);\n var attributeIndex = 0;\n\n if (rootPath) {\n attributeIndex = rootPath.split(separator).length;\n }\n return [hierarchicalFacet.attributes[attributeIndex]];\n }\n\n var hierarchicalRefinement = state.getHierarchicalRefinement(hierarchicalFacet.name)[0] || '';\n // if refinement is 'beers > IPA > Flying dog',\n // then we want `facets: ['beers > IPA']` as disjunctive facet (parent level values)\n\n var parentLevel = hierarchicalRefinement.split(separator).length - 1;\n return hierarchicalFacet.attributes.slice(0, parentLevel + 1);\n },\n\n getSearchForFacetQuery: function(facetName, query, maxFacetHits, state) {\n var stateForSearchForFacetValues = state.isDisjunctiveFacet(facetName) ?\n state.clearRefinements(facetName) :\n state;\n var searchForFacetSearchParameters = {\n facetQuery: query,\n facetName: facetName\n };\n if (typeof maxFacetHits === 'number') {\n searchForFacetSearchParameters.maxFacetHits = maxFacetHits;\n }\n return merge(\n {},\n requestBuilder._getHitsSearchParams(stateForSearchForFacetValues),\n searchForFacetSearchParameters\n );\n }\n};\n\nmodule.exports = requestBuilder;\n","'use strict';\n\nmodule.exports = '3.1.0';\n","'use strict';\n\nvar SearchParameters = require('./SearchParameters');\nvar SearchResults = require('./SearchResults');\nvar DerivedHelper = require('./DerivedHelper');\nvar requestBuilder = require('./requestBuilder');\n\nvar events = require('events');\nvar inherits = require('./functions/inherits');\nvar objectHasKeys = require('./functions/objectHasKeys');\n\nvar version = require('./version');\n\n/**\n * Event triggered when a parameter is set or updated\n * @event AlgoliaSearchHelper#event:change\n * @property {object} event\n * @property {SearchParameters} event.state the current parameters with the latest changes applied\n * @property {SearchResults} event.results the previous results received from Algolia. `null` before the first request\n * @example\n * helper.on('change', function(event) {\n * console.log('The parameters have changed');\n * });\n */\n\n/**\n * Event triggered when a main search is sent to Algolia\n * @event AlgoliaSearchHelper#event:search\n * @property {object} event\n * @property {SearchParameters} event.state the parameters used for this search\n * @property {SearchResults} event.results the results from the previous search. `null` if it is the first search.\n * @example\n * helper.on('search', function(event) {\n * console.log('Search sent');\n * });\n */\n\n/**\n * Event triggered when a search using `searchForFacetValues` is sent to Algolia\n * @event AlgoliaSearchHelper#event:searchForFacetValues\n * @property {object} event\n * @property {SearchParameters} event.state the parameters used for this search it is the first search.\n * @property {string} event.facet the facet searched into\n * @property {string} event.query the query used to search in the facets\n * @example\n * helper.on('searchForFacetValues', function(event) {\n * console.log('searchForFacetValues sent');\n * });\n */\n\n/**\n * Event triggered when a search using `searchOnce` is sent to Algolia\n * @event AlgoliaSearchHelper#event:searchOnce\n * @property {object} event\n * @property {SearchParameters} event.state the parameters used for this search it is the first search.\n * @example\n * helper.on('searchOnce', function(event) {\n * console.log('searchOnce sent');\n * });\n */\n\n/**\n * Event triggered when the results are retrieved from Algolia\n * @event AlgoliaSearchHelper#event:result\n * @property {object} event\n * @property {SearchResults} event.results the results received from Algolia\n * @property {SearchParameters} event.state the parameters used to query Algolia. Those might be different from the one in the helper instance (for example if the network is unreliable).\n * @example\n * helper.on('result', function(event) {\n * console.log('Search results received');\n * });\n */\n\n/**\n * Event triggered when Algolia sends back an error. For example, if an unknown parameter is\n * used, the error can be caught using this event.\n * @event AlgoliaSearchHelper#event:error\n * @property {object} event\n * @property {Error} event.error the error returned by the Algolia.\n * @example\n * helper.on('error', function(event) {\n * console.log('Houston we got a problem.');\n * });\n */\n\n/**\n * Event triggered when the queue of queries have been depleted (with any result or outdated queries)\n * @event AlgoliaSearchHelper#event:searchQueueEmpty\n * @example\n * helper.on('searchQueueEmpty', function() {\n * console.log('No more search pending');\n * // This is received before the result event if we're not expecting new results\n * });\n *\n * helper.search();\n */\n\n/**\n * Initialize a new AlgoliaSearchHelper\n * @class\n * @classdesc The AlgoliaSearchHelper is a class that ease the management of the\n * search. It provides an event based interface for search callbacks:\n * - change: when the internal search state is changed.\n * This event contains a {@link SearchParameters} object and the\n * {@link SearchResults} of the last result if any.\n * - search: when a search is triggered using the `search()` method.\n * - result: when the response is retrieved from Algolia and is processed.\n * This event contains a {@link SearchResults} object and the\n * {@link SearchParameters} corresponding to this answer.\n * - error: when the response is an error. This event contains the error returned by the server.\n * @param {AlgoliaSearch} client an AlgoliaSearch client\n * @param {string} index the index name to query\n * @param {SearchParameters | object} options an object defining the initial\n * config of the search. It doesn't have to be a {SearchParameters},\n * just an object containing the properties you need from it.\n */\nfunction AlgoliaSearchHelper(client, index, options) {\n if (typeof client.addAlgoliaAgent === 'function') {\n client.addAlgoliaAgent('JS Helper (' + version + ')');\n }\n\n this.setClient(client);\n var opts = options || {};\n opts.index = index;\n this.state = SearchParameters.make(opts);\n this.lastResults = null;\n this._queryId = 0;\n this._lastQueryIdReceived = -1;\n this.derivedHelpers = [];\n this._currentNbQueries = 0;\n}\n\ninherits(AlgoliaSearchHelper, events.EventEmitter);\n\n/**\n * Start the search with the parameters set in the state. When the\n * method is called, it triggers a `search` event. The results will\n * be available through the `result` event. If an error occurs, an\n * `error` will be fired instead.\n * @return {AlgoliaSearchHelper}\n * @fires search\n * @fires result\n * @fires error\n * @chainable\n */\nAlgoliaSearchHelper.prototype.search = function() {\n this._search({onlyWithDerivedHelpers: false});\n return this;\n};\n\nAlgoliaSearchHelper.prototype.searchOnlyWithDerivedHelpers = function() {\n this._search({onlyWithDerivedHelpers: true});\n return this;\n};\n\n/**\n * Gets the search query parameters that would be sent to the Algolia Client\n * for the hits\n * @return {object} Query Parameters\n */\nAlgoliaSearchHelper.prototype.getQuery = function() {\n var state = this.state;\n return requestBuilder._getHitsSearchParams(state);\n};\n\n/**\n * Start a search using a modified version of the current state. This method does\n * not trigger the helper lifecycle and does not modify the state kept internally\n * by the helper. This second aspect means that the next search call will be the\n * same as a search call before calling searchOnce.\n * @param {object} options can contain all the parameters that can be set to SearchParameters\n * plus the index\n * @param {function} [callback] optional callback executed when the response from the\n * server is back.\n * @return {promise|undefined} if a callback is passed the method returns undefined\n * otherwise it returns a promise containing an object with two keys :\n * - content with a SearchResults\n * - state with the state used for the query as a SearchParameters\n * @example\n * // Changing the number of records returned per page to 1\n * // This example uses the callback API\n * var state = helper.searchOnce({hitsPerPage: 1},\n * function(error, content, state) {\n * // if an error occurred it will be passed in error, otherwise its value is null\n * // content contains the results formatted as a SearchResults\n * // state is the instance of SearchParameters used for this search\n * });\n * @example\n * // Changing the number of records returned per page to 1\n * // This example uses the promise API\n * var state1 = helper.searchOnce({hitsPerPage: 1})\n * .then(promiseHandler);\n *\n * function promiseHandler(res) {\n * // res contains\n * // {\n * // content : SearchResults\n * // state : SearchParameters (the one used for this specific search)\n * // }\n * }\n */\nAlgoliaSearchHelper.prototype.searchOnce = function(options, cb) {\n var tempState = !options ? this.state : this.state.setQueryParameters(options);\n var queries = requestBuilder._getQueries(tempState.index, tempState);\n var self = this;\n\n this._currentNbQueries++;\n\n this.emit('searchOnce', {\n state: tempState\n });\n\n if (cb) {\n this.client\n .search(queries)\n .then(function(content) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) {\n self.emit('searchQueueEmpty');\n }\n\n cb(null, new SearchResults(tempState, content.results), tempState);\n })\n .catch(function(err) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) {\n self.emit('searchQueueEmpty');\n }\n\n cb(err, null, tempState);\n });\n\n return undefined;\n }\n\n return this.client.search(queries).then(function(content) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');\n return {\n content: new SearchResults(tempState, content.results),\n state: tempState,\n _originalResponse: content\n };\n }, function(e) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');\n throw e;\n });\n};\n\n/**\n * Structure of each result when using\n * [`searchForFacetValues()`](reference.html#AlgoliaSearchHelper#searchForFacetValues)\n * @typedef FacetSearchHit\n * @type {object}\n * @property {string} value the facet value\n * @property {string} highlighted the facet value highlighted with the query string\n * @property {number} count number of occurrence of this facet value\n * @property {boolean} isRefined true if the value is already refined\n */\n\n/**\n * Structure of the data resolved by the\n * [`searchForFacetValues()`](reference.html#AlgoliaSearchHelper#searchForFacetValues)\n * promise.\n * @typedef FacetSearchResult\n * @type {object}\n * @property {FacetSearchHit} facetHits the results for this search for facet values\n * @property {number} processingTimeMS time taken by the query inside the engine\n */\n\n/**\n * Search for facet values based on an query and the name of a faceted attribute. This\n * triggers a search and will return a promise. On top of using the query, it also sends\n * the parameters from the state so that the search is narrowed down to only the possible values.\n *\n * See the description of [FacetSearchResult](reference.html#FacetSearchResult)\n * @param {string} facet the name of the faceted attribute\n * @param {string} query the string query for the search\n * @param {number} [maxFacetHits] the maximum number values returned. Should be > 0 and <= 100\n * @param {object} [userState] the set of custom parameters to use on top of the current state. Setting a property to `undefined` removes\n * it in the generated query.\n * @return {promise.} the results of the search\n */\nAlgoliaSearchHelper.prototype.searchForFacetValues = function(facet, query, maxFacetHits, userState) {\n var clientHasSFFV = typeof this.client.searchForFacetValues === 'function';\n if (\n !clientHasSFFV &&\n typeof this.client.initIndex !== 'function'\n ) {\n throw new Error(\n 'search for facet values (searchable) was called, but this client does not have a function client.searchForFacetValues or client.initIndex(index).searchForFacetValues'\n );\n }\n var state = this.state.setQueryParameters(userState || {});\n var isDisjunctive = state.isDisjunctiveFacet(facet);\n var algoliaQuery = requestBuilder.getSearchForFacetQuery(facet, query, maxFacetHits, state);\n\n this._currentNbQueries++;\n var self = this;\n\n this.emit('searchForFacetValues', {\n state: state,\n facet: facet,\n query: query\n });\n\n var searchForFacetValuesPromise = clientHasSFFV\n ? this.client.searchForFacetValues([{indexName: state.index, params: algoliaQuery}])\n : this.client.initIndex(state.index).searchForFacetValues(algoliaQuery);\n\n return searchForFacetValuesPromise.then(function addIsRefined(content) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');\n\n content = Array.isArray(content) ? content[0] : content;\n\n content.facetHits.forEach(function(f) {\n f.isRefined = isDisjunctive\n ? state.isDisjunctiveFacetRefined(facet, f.value)\n : state.isFacetRefined(facet, f.value);\n });\n\n return content;\n }, function(e) {\n self._currentNbQueries--;\n if (self._currentNbQueries === 0) self.emit('searchQueueEmpty');\n throw e;\n });\n};\n\n/**\n * Sets the text query used for the search.\n *\n * This method resets the current page to 0.\n * @param {string} q the user query\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.setQuery = function(q) {\n this._change({\n state: this.state.resetPage().setQuery(q),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Remove all the types of refinements except tags. A string can be provided to remove\n * only the refinements of a specific attribute. For more advanced use case, you can\n * provide a function instead. This function should follow the\n * [clearCallback definition](#SearchParameters.clearCallback).\n *\n * This method resets the current page to 0.\n * @param {string} [name] optional name of the facet / attribute on which we want to remove all refinements\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n * @example\n * // Removing all the refinements\n * helper.clearRefinements().search();\n * @example\n * // Removing all the filters on a the category attribute.\n * helper.clearRefinements('category').search();\n * @example\n * // Removing only the exclude filters on the category facet.\n * helper.clearRefinements(function(value, attribute, type) {\n * return type === 'exclude' && attribute === 'category';\n * }).search();\n */\nAlgoliaSearchHelper.prototype.clearRefinements = function(name) {\n this._change({\n state: this.state.resetPage().clearRefinements(name),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Remove all the tag filters.\n *\n * This method resets the current page to 0.\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.clearTags = function() {\n this._change({\n state: this.state.resetPage().clearTags(),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Adds a disjunctive filter to a faceted attribute with the `value` provided. If the\n * filter is already set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value (will be converted to string)\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.addDisjunctiveFacetRefinement = function(facet, value) {\n this._change({\n state: this.state.resetPage().addDisjunctiveFacetRefinement(facet, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addDisjunctiveFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.addDisjunctiveRefine = function() {\n return this.addDisjunctiveFacetRefinement.apply(this, arguments);\n};\n\n/**\n * Adds a refinement on a hierarchical facet. It will throw\n * an exception if the facet is not defined or if the facet\n * is already refined.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet name\n * @param {string} path the hierarchical facet path\n * @return {AlgoliaSearchHelper}\n * @throws Error if the facet is not defined or if the facet is refined\n * @chainable\n * @fires change\n */\nAlgoliaSearchHelper.prototype.addHierarchicalFacetRefinement = function(facet, value) {\n this._change({\n state: this.state.resetPage().addHierarchicalFacetRefinement(facet, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Adds a an numeric filter to an attribute with the `operator` and `value` provided. If the\n * filter is already set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} attribute the attribute on which the numeric filter applies\n * @param {string} operator the operator of the filter\n * @param {number} value the value of the filter\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.addNumericRefinement = function(attribute, operator, value) {\n this._change({\n state: this.state.resetPage().addNumericRefinement(attribute, operator, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Adds a filter to a faceted attribute with the `value` provided. If the\n * filter is already set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value (will be converted to string)\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.addFacetRefinement = function(facet, value) {\n this._change({\n state: this.state.resetPage().addFacetRefinement(facet, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.addRefine = function() {\n return this.addFacetRefinement.apply(this, arguments);\n};\n\n\n/**\n * Adds a an exclusion filter to a faceted attribute with the `value` provided. If the\n * filter is already set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value (will be converted to string)\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.addFacetExclusion = function(facet, value) {\n this._change({\n state: this.state.resetPage().addExcludeRefinement(facet, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#addFacetExclusion}\n */\nAlgoliaSearchHelper.prototype.addExclude = function() {\n return this.addFacetExclusion.apply(this, arguments);\n};\n\n/**\n * Adds a tag filter with the `tag` provided. If the\n * filter is already set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} tag the tag to add to the filter\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.addTag = function(tag) {\n this._change({\n state: this.state.resetPage().addTagRefinement(tag),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Removes an numeric filter to an attribute with the `operator` and `value` provided. If the\n * filter is not set, it doesn't change the filters.\n *\n * Some parameters are optional, triggering different behavior:\n * - if the value is not provided, then all the numeric value will be removed for the\n * specified attribute/operator couple.\n * - if the operator is not provided either, then all the numeric filter on this attribute\n * will be removed.\n *\n * This method resets the current page to 0.\n * @param {string} attribute the attribute on which the numeric filter applies\n * @param {string} [operator] the operator of the filter\n * @param {number} [value] the value of the filter\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeNumericRefinement = function(attribute, operator, value) {\n this._change({\n state: this.state.resetPage().removeNumericRefinement(attribute, operator, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Removes a disjunctive filter to a faceted attribute with the `value` provided. If the\n * filter is not set, it doesn't change the filters.\n *\n * If the value is omitted, then this method will remove all the filters for the\n * attribute.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} [value] the associated value\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeDisjunctiveFacetRefinement = function(facet, value) {\n this._change({\n state: this.state.resetPage().removeDisjunctiveFacetRefinement(facet, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeDisjunctiveFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.removeDisjunctiveRefine = function() {\n return this.removeDisjunctiveFacetRefinement.apply(this, arguments);\n};\n\n/**\n * Removes the refinement set on a hierarchical facet.\n * @param {string} facet the facet name\n * @return {AlgoliaSearchHelper}\n * @throws Error if the facet is not defined or if the facet is not refined\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeHierarchicalFacetRefinement = function(facet) {\n this._change({\n state: this.state.resetPage().removeHierarchicalFacetRefinement(facet),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Removes a filter to a faceted attribute with the `value` provided. If the\n * filter is not set, it doesn't change the filters.\n *\n * If the value is omitted, then this method will remove all the filters for the\n * attribute.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} [value] the associated value\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeFacetRefinement = function(facet, value) {\n this._change({\n state: this.state.resetPage().removeFacetRefinement(facet, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.removeRefine = function() {\n return this.removeFacetRefinement.apply(this, arguments);\n};\n\n/**\n * Removes an exclusion filter to a faceted attribute with the `value` provided. If the\n * filter is not set, it doesn't change the filters.\n *\n * If the value is omitted, then this method will remove all the filters for the\n * attribute.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} [value] the associated value\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeFacetExclusion = function(facet, value) {\n this._change({\n state: this.state.resetPage().removeExcludeRefinement(facet, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#removeFacetExclusion}\n */\nAlgoliaSearchHelper.prototype.removeExclude = function() {\n return this.removeFacetExclusion.apply(this, arguments);\n};\n\n/**\n * Removes a tag filter with the `tag` provided. If the\n * filter is not set, it doesn't change the filters.\n *\n * This method resets the current page to 0.\n * @param {string} tag tag to remove from the filter\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.removeTag = function(tag) {\n this._change({\n state: this.state.resetPage().removeTagRefinement(tag),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Adds or removes an exclusion filter to a faceted attribute with the `value` provided. If\n * the value is set then it removes it, otherwise it adds the filter.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.toggleFacetExclusion = function(facet, value) {\n this._change({\n state: this.state.resetPage().toggleExcludeFacetRefinement(facet, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#toggleFacetExclusion}\n */\nAlgoliaSearchHelper.prototype.toggleExclude = function() {\n return this.toggleFacetExclusion.apply(this, arguments);\n};\n\n/**\n * Adds or removes a filter to a faceted attribute with the `value` provided. If\n * the value is set then it removes it, otherwise it adds the filter.\n *\n * This method can be used for conjunctive, disjunctive and hierarchical filters.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value\n * @return {AlgoliaSearchHelper}\n * @throws Error will throw an error if the facet is not declared in the settings of the helper\n * @fires change\n * @chainable\n * @deprecated since version 2.19.0, see {@link AlgoliaSearchHelper#toggleFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.toggleRefinement = function(facet, value) {\n return this.toggleFacetRefinement(facet, value);\n};\n\n/**\n * Adds or removes a filter to a faceted attribute with the `value` provided. If\n * the value is set then it removes it, otherwise it adds the filter.\n *\n * This method can be used for conjunctive, disjunctive and hierarchical filters.\n *\n * This method resets the current page to 0.\n * @param {string} facet the facet to refine\n * @param {string} value the associated value\n * @return {AlgoliaSearchHelper}\n * @throws Error will throw an error if the facet is not declared in the settings of the helper\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.toggleFacetRefinement = function(facet, value) {\n this._change({\n state: this.state.resetPage().toggleFacetRefinement(facet, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * @deprecated since version 2.4.0, see {@link AlgoliaSearchHelper#toggleFacetRefinement}\n */\nAlgoliaSearchHelper.prototype.toggleRefine = function() {\n return this.toggleFacetRefinement.apply(this, arguments);\n};\n\n/**\n * Adds or removes a tag filter with the `value` provided. If\n * the value is set then it removes it, otherwise it adds the filter.\n *\n * This method resets the current page to 0.\n * @param {string} tag tag to remove or add\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.toggleTag = function(tag) {\n this._change({\n state: this.state.resetPage().toggleTagRefinement(tag),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Increments the page number by one.\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n * @example\n * helper.setPage(0).nextPage().getPage();\n * // returns 1\n */\nAlgoliaSearchHelper.prototype.nextPage = function() {\n var page = this.state.page || 0;\n return this.setPage(page + 1);\n};\n\n/**\n * Decrements the page number by one.\n * @fires change\n * @return {AlgoliaSearchHelper}\n * @chainable\n * @example\n * helper.setPage(1).previousPage().getPage();\n * // returns 0\n */\nAlgoliaSearchHelper.prototype.previousPage = function() {\n var page = this.state.page || 0;\n return this.setPage(page - 1);\n};\n\n/**\n * @private\n */\nfunction setCurrentPage(page) {\n if (page < 0) throw new Error('Page requested below 0.');\n\n this._change({\n state: this.state.setPage(page),\n isPageReset: false\n });\n\n return this;\n}\n\n/**\n * Change the current page\n * @deprecated\n * @param {number} page The page number\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.setCurrentPage = setCurrentPage;\n\n/**\n * Updates the current page.\n * @function\n * @param {number} page The page number\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.setPage = setCurrentPage;\n\n/**\n * Updates the name of the index that will be targeted by the query.\n *\n * This method resets the current page to 0.\n * @param {string} name the index name\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.setIndex = function(name) {\n this._change({\n state: this.state.resetPage().setIndex(name),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Update a parameter of the search. This method reset the page\n *\n * The complete list of parameters is available on the\n * [Algolia website](https://www.algolia.com/doc/rest#query-an-index).\n * The most commonly used parameters have their own [shortcuts](#query-parameters-shortcuts)\n * or benefit from higher-level APIs (all the kind of filters and facets have their own API)\n *\n * This method resets the current page to 0.\n * @param {string} parameter name of the parameter to update\n * @param {any} value new value of the parameter\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n * @example\n * helper.setQueryParameter('hitsPerPage', 20).search();\n */\nAlgoliaSearchHelper.prototype.setQueryParameter = function(parameter, value) {\n this._change({\n state: this.state.resetPage().setQueryParameter(parameter, value),\n isPageReset: true\n });\n\n return this;\n};\n\n/**\n * Set the whole state (warning: will erase previous state)\n * @param {SearchParameters} newState the whole new state\n * @return {AlgoliaSearchHelper}\n * @fires change\n * @chainable\n */\nAlgoliaSearchHelper.prototype.setState = function(newState) {\n this._change({\n state: SearchParameters.make(newState),\n isPageReset: false\n });\n\n return this;\n};\n\n/**\n * Override the current state without triggering a change event.\n * Do not use this method unless you know what you are doing. (see the example\n * for a legit use case)\n * @param {SearchParameters} newState the whole new state\n * @return {AlgoliaSearchHelper}\n * @example\n * helper.on('change', function(state){\n * // In this function you might want to find a way to store the state in the url/history\n * updateYourURL(state)\n * })\n * window.onpopstate = function(event){\n * // This is naive though as you should check if the state is really defined etc.\n * helper.overrideStateWithoutTriggeringChangeEvent(event.state).search()\n * }\n * @chainable\n */\nAlgoliaSearchHelper.prototype.overrideStateWithoutTriggeringChangeEvent = function(newState) {\n this.state = new SearchParameters(newState);\n return this;\n};\n\n/**\n * Check if an attribute has any numeric, conjunctive, disjunctive or hierarchical filters.\n * @param {string} attribute the name of the attribute\n * @return {boolean} true if the attribute is filtered by at least one value\n * @example\n * // hasRefinements works with numeric, conjunctive, disjunctive and hierarchical filters\n * helper.hasRefinements('price'); // false\n * helper.addNumericRefinement('price', '>', 100);\n * helper.hasRefinements('price'); // true\n *\n * helper.hasRefinements('color'); // false\n * helper.addFacetRefinement('color', 'blue');\n * helper.hasRefinements('color'); // true\n *\n * helper.hasRefinements('material'); // false\n * helper.addDisjunctiveFacetRefinement('material', 'plastic');\n * helper.hasRefinements('material'); // true\n *\n * helper.hasRefinements('categories'); // false\n * helper.toggleFacetRefinement('categories', 'kitchen > knife');\n * helper.hasRefinements('categories'); // true\n *\n */\nAlgoliaSearchHelper.prototype.hasRefinements = function(attribute) {\n if (objectHasKeys(this.state.getNumericRefinements(attribute))) {\n return true;\n } else if (this.state.isConjunctiveFacet(attribute)) {\n return this.state.isFacetRefined(attribute);\n } else if (this.state.isDisjunctiveFacet(attribute)) {\n return this.state.isDisjunctiveFacetRefined(attribute);\n } else if (this.state.isHierarchicalFacet(attribute)) {\n return this.state.isHierarchicalFacetRefined(attribute);\n }\n\n // there's currently no way to know that the user did call `addNumericRefinement` at some point\n // thus we cannot distinguish if there once was a numeric refinement that was cleared\n // so we will return false in every other situations to be consistent\n // while what we should do here is throw because we did not find the attribute in any type\n // of refinement\n return false;\n};\n\n/**\n * Check if a value is excluded for a specific faceted attribute. If the value\n * is omitted then the function checks if there is any excluding refinements.\n *\n * @param {string} facet name of the attribute for used for faceting\n * @param {string} [value] optional value. If passed will test that this value\n * is filtering the given facet.\n * @return {boolean} true if refined\n * @example\n * helper.isExcludeRefined('color'); // false\n * helper.isExcludeRefined('color', 'blue') // false\n * helper.isExcludeRefined('color', 'red') // false\n *\n * helper.addFacetExclusion('color', 'red');\n *\n * helper.isExcludeRefined('color'); // true\n * helper.isExcludeRefined('color', 'blue') // false\n * helper.isExcludeRefined('color', 'red') // true\n */\nAlgoliaSearchHelper.prototype.isExcluded = function(facet, value) {\n return this.state.isExcludeRefined(facet, value);\n};\n\n/**\n * @deprecated since 2.4.0, see {@link AlgoliaSearchHelper#hasRefinements}\n */\nAlgoliaSearchHelper.prototype.isDisjunctiveRefined = function(facet, value) {\n return this.state.isDisjunctiveFacetRefined(facet, value);\n};\n\n/**\n * Check if the string is a currently filtering tag.\n * @param {string} tag tag to check\n * @return {boolean}\n */\nAlgoliaSearchHelper.prototype.hasTag = function(tag) {\n return this.state.isTagRefined(tag);\n};\n\n/**\n * @deprecated since 2.4.0, see {@link AlgoliaSearchHelper#hasTag}\n */\nAlgoliaSearchHelper.prototype.isTagRefined = function() {\n return this.hasTagRefinements.apply(this, arguments);\n};\n\n\n/**\n * Get the name of the currently used index.\n * @return {string}\n * @example\n * helper.setIndex('highestPrice_products').getIndex();\n * // returns 'highestPrice_products'\n */\nAlgoliaSearchHelper.prototype.getIndex = function() {\n return this.state.index;\n};\n\nfunction getCurrentPage() {\n return this.state.page;\n}\n\n/**\n * Get the currently selected page\n * @deprecated\n * @return {number} the current page\n */\nAlgoliaSearchHelper.prototype.getCurrentPage = getCurrentPage;\n/**\n * Get the currently selected page\n * @function\n * @return {number} the current page\n */\nAlgoliaSearchHelper.prototype.getPage = getCurrentPage;\n\n/**\n * Get all the tags currently set to filters the results.\n *\n * @return {string[]} The list of tags currently set.\n */\nAlgoliaSearchHelper.prototype.getTags = function() {\n return this.state.tagRefinements;\n};\n\n/**\n * Get the list of refinements for a given attribute. This method works with\n * conjunctive, disjunctive, excluding and numerical filters.\n *\n * See also SearchResults#getRefinements\n *\n * @param {string} facetName attribute name used for faceting\n * @return {Array.} All Refinement are objects that contain a value, and\n * a type. Numeric also contains an operator.\n * @example\n * helper.addNumericRefinement('price', '>', 100);\n * helper.getRefinements('price');\n * // [\n * // {\n * // \"value\": [\n * // 100\n * // ],\n * // \"operator\": \">\",\n * // \"type\": \"numeric\"\n * // }\n * // ]\n * @example\n * helper.addFacetRefinement('color', 'blue');\n * helper.addFacetExclusion('color', 'red');\n * helper.getRefinements('color');\n * // [\n * // {\n * // \"value\": \"blue\",\n * // \"type\": \"conjunctive\"\n * // },\n * // {\n * // \"value\": \"red\",\n * // \"type\": \"exclude\"\n * // }\n * // ]\n * @example\n * helper.addDisjunctiveFacetRefinement('material', 'plastic');\n * // [\n * // {\n * // \"value\": \"plastic\",\n * // \"type\": \"disjunctive\"\n * // }\n * // ]\n */\nAlgoliaSearchHelper.prototype.getRefinements = function(facetName) {\n var refinements = [];\n\n if (this.state.isConjunctiveFacet(facetName)) {\n var conjRefinements = this.state.getConjunctiveRefinements(facetName);\n\n conjRefinements.forEach(function(r) {\n refinements.push({\n value: r,\n type: 'conjunctive'\n });\n });\n\n var excludeRefinements = this.state.getExcludeRefinements(facetName);\n\n excludeRefinements.forEach(function(r) {\n refinements.push({\n value: r,\n type: 'exclude'\n });\n });\n } else if (this.state.isDisjunctiveFacet(facetName)) {\n var disjRefinements = this.state.getDisjunctiveRefinements(facetName);\n\n disjRefinements.forEach(function(r) {\n refinements.push({\n value: r,\n type: 'disjunctive'\n });\n });\n }\n\n var numericRefinements = this.state.getNumericRefinements(facetName);\n\n Object.keys(numericRefinements).forEach(function(operator) {\n var value = numericRefinements[operator];\n\n refinements.push({\n value: value,\n operator: operator,\n type: 'numeric'\n });\n });\n\n return refinements;\n};\n\n/**\n * Return the current refinement for the (attribute, operator)\n * @param {string} attribute attribute in the record\n * @param {string} operator operator applied on the refined values\n * @return {Array.} refined values\n */\nAlgoliaSearchHelper.prototype.getNumericRefinement = function(attribute, operator) {\n return this.state.getNumericRefinement(attribute, operator);\n};\n\n/**\n * Get the current breadcrumb for a hierarchical facet, as an array\n * @param {string} facetName Hierarchical facet name\n * @return {array.} the path as an array of string\n */\nAlgoliaSearchHelper.prototype.getHierarchicalFacetBreadcrumb = function(facetName) {\n return this.state.getHierarchicalFacetBreadcrumb(facetName);\n};\n\n// /////////// PRIVATE\n\n/**\n * Perform the underlying queries\n * @private\n * @return {undefined}\n * @fires search\n * @fires result\n * @fires error\n */\nAlgoliaSearchHelper.prototype._search = function(options) {\n var state = this.state;\n var states = [];\n var mainQueries = [];\n\n if (!options.onlyWithDerivedHelpers) {\n mainQueries = requestBuilder._getQueries(state.index, state);\n\n states.push({\n state: state,\n queriesCount: mainQueries.length,\n helper: this\n });\n\n this.emit('search', {\n state: state,\n results: this.lastResults\n });\n }\n\n var derivedQueries = this.derivedHelpers.map(function(derivedHelper) {\n var derivedState = derivedHelper.getModifiedState(state);\n var derivedStateQueries = requestBuilder._getQueries(derivedState.index, derivedState);\n\n states.push({\n state: derivedState,\n queriesCount: derivedStateQueries.length,\n helper: derivedHelper\n });\n\n derivedHelper.emit('search', {\n state: derivedState,\n results: derivedHelper.lastResults\n });\n\n return derivedStateQueries;\n });\n\n var queries = Array.prototype.concat.apply(mainQueries, derivedQueries);\n var queryId = this._queryId++;\n\n this._currentNbQueries++;\n\n try {\n this.client.search(queries)\n .then(this._dispatchAlgoliaResponse.bind(this, states, queryId))\n .catch(this._dispatchAlgoliaError.bind(this, queryId));\n } catch (error) {\n // If we reach this part, we're in an internal error state\n this.emit('error', {\n error: error\n });\n }\n};\n\n/**\n * Transform the responses as sent by the server and transform them into a user\n * usable object that merge the results of all the batch requests. It will dispatch\n * over the different helper + derived helpers (when there are some).\n * @private\n * @param {array.<{SearchParameters, AlgoliaQueries, AlgoliaSearchHelper}>}\n * state state used for to generate the request\n * @param {number} queryId id of the current request\n * @param {object} content content of the response\n * @return {undefined}\n */\nAlgoliaSearchHelper.prototype._dispatchAlgoliaResponse = function(states, queryId, content) {\n // FIXME remove the number of outdated queries discarded instead of just one\n\n if (queryId < this._lastQueryIdReceived) {\n // Outdated answer\n return;\n }\n\n this._currentNbQueries -= (queryId - this._lastQueryIdReceived);\n this._lastQueryIdReceived = queryId;\n\n if (this._currentNbQueries === 0) this.emit('searchQueueEmpty');\n\n var results = content.results.slice();\n\n states.forEach(function(s) {\n var state = s.state;\n var queriesCount = s.queriesCount;\n var helper = s.helper;\n var specificResults = results.splice(0, queriesCount);\n\n var formattedResponse = helper.lastResults = new SearchResults(state, specificResults);\n\n helper.emit('result', {\n results: formattedResponse,\n state: state\n });\n });\n};\n\nAlgoliaSearchHelper.prototype._dispatchAlgoliaError = function(queryId, error) {\n if (queryId < this._lastQueryIdReceived) {\n // Outdated answer\n return;\n }\n\n this._currentNbQueries -= queryId - this._lastQueryIdReceived;\n this._lastQueryIdReceived = queryId;\n\n this.emit('error', {\n error: error\n });\n\n if (this._currentNbQueries === 0) this.emit('searchQueueEmpty');\n};\n\nAlgoliaSearchHelper.prototype.containsRefinement = function(query, facetFilters, numericFilters, tagFilters) {\n return query ||\n facetFilters.length !== 0 ||\n numericFilters.length !== 0 ||\n tagFilters.length !== 0;\n};\n\n/**\n * Test if there are some disjunctive refinements on the facet\n * @private\n * @param {string} facet the attribute to test\n * @return {boolean}\n */\nAlgoliaSearchHelper.prototype._hasDisjunctiveRefinements = function(facet) {\n return this.state.disjunctiveRefinements[facet] &&\n this.state.disjunctiveRefinements[facet].length > 0;\n};\n\nAlgoliaSearchHelper.prototype._change = function(event) {\n var state = event.state;\n var isPageReset = event.isPageReset;\n\n if (state !== this.state) {\n this.state = state;\n\n this.emit('change', {\n state: this.state,\n results: this.lastResults,\n isPageReset: isPageReset\n });\n }\n};\n\n/**\n * Clears the cache of the underlying Algolia client.\n * @return {AlgoliaSearchHelper}\n */\nAlgoliaSearchHelper.prototype.clearCache = function() {\n this.client.clearCache && this.client.clearCache();\n return this;\n};\n\n/**\n * Updates the internal client instance. If the reference of the clients\n * are equal then no update is actually done.\n * @param {AlgoliaSearch} newClient an AlgoliaSearch client\n * @return {AlgoliaSearchHelper}\n */\nAlgoliaSearchHelper.prototype.setClient = function(newClient) {\n if (this.client === newClient) return this;\n\n if (typeof newClient.addAlgoliaAgent === 'function') {\n newClient.addAlgoliaAgent('JS Helper (' + version + ')');\n }\n this.client = newClient;\n\n return this;\n};\n\n/**\n * Gets the instance of the currently used client.\n * @return {AlgoliaSearch}\n */\nAlgoliaSearchHelper.prototype.getClient = function() {\n return this.client;\n};\n\n/**\n * Creates an derived instance of the Helper. A derived helper\n * is a way to request other indices synchronised with the lifecycle\n * of the main Helper. This mechanism uses the multiqueries feature\n * of Algolia to aggregate all the requests in a single network call.\n *\n * This method takes a function that is used to create a new SearchParameter\n * that will be used to create requests to Algolia. Those new requests\n * are created just before the `search` event. The signature of the function\n * is `SearchParameters -> SearchParameters`.\n *\n * This method returns a new DerivedHelper which is an EventEmitter\n * that fires the same `search`, `result` and `error` events. Those\n * events, however, will receive data specific to this DerivedHelper\n * and the SearchParameters that is returned by the call of the\n * parameter function.\n * @param {function} fn SearchParameters -> SearchParameters\n * @return {DerivedHelper}\n */\nAlgoliaSearchHelper.prototype.derive = function(fn) {\n var derivedHelper = new DerivedHelper(this, fn);\n this.derivedHelpers.push(derivedHelper);\n return derivedHelper;\n};\n\n/**\n * This method detaches a derived Helper from the main one. Prefer using the one from the\n * derived helper itself, to remove the event listeners too.\n * @private\n * @return {undefined}\n * @throws Error\n */\nAlgoliaSearchHelper.prototype.detachDerivedHelper = function(derivedHelper) {\n var pos = this.derivedHelpers.indexOf(derivedHelper);\n if (pos === -1) throw new Error('Derived helper already detached');\n this.derivedHelpers.splice(pos, 1);\n};\n\n/**\n * This method returns true if there is currently at least one on-going search.\n * @return {boolean} true if there is a search pending\n */\nAlgoliaSearchHelper.prototype.hasPendingRequests = function() {\n return this._currentNbQueries > 0;\n};\n\n/**\n * @typedef AlgoliaSearchHelper.NumericRefinement\n * @type {object}\n * @property {number[]} value the numbers that are used for filtering this attribute with\n * the operator specified.\n * @property {string} operator the faceting data: value, number of entries\n * @property {string} type will be 'numeric'\n */\n\n/**\n * @typedef AlgoliaSearchHelper.FacetRefinement\n * @type {object}\n * @property {string} value the string use to filter the attribute\n * @property {string} type the type of filter: 'conjunctive', 'disjunctive', 'exclude'\n */\n\nmodule.exports = AlgoliaSearchHelper;\n","'use strict';\n\nvar AlgoliaSearchHelper = require('./src/algoliasearch.helper');\n\nvar SearchParameters = require('./src/SearchParameters');\nvar SearchResults = require('./src/SearchResults');\n\n/**\n * The algoliasearchHelper module is the function that will let its\n * contains everything needed to use the Algoliasearch\n * Helper. It is a also a function that instanciate the helper.\n * To use the helper, you also need the Algolia JS client v3.\n * @example\n * //using the UMD build\n * var client = algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76');\n * var helper = algoliasearchHelper(client, 'bestbuy', {\n * facets: ['shipping'],\n * disjunctiveFacets: ['category']\n * });\n * helper.on('result', function(event) {\n * console.log(event.results);\n * });\n * helper\n * .toggleFacetRefinement('category', 'Movies & TV Shows')\n * .toggleFacetRefinement('shipping', 'Free shipping')\n * .search();\n * @example\n * // The helper is an event emitter using the node API\n * helper.on('result', updateTheResults);\n * helper.once('result', updateTheResults);\n * helper.removeListener('result', updateTheResults);\n * helper.removeAllListeners('result');\n * @module algoliasearchHelper\n * @param {AlgoliaSearch} client an AlgoliaSearch client\n * @param {string} index the name of the index to query\n * @param {SearchParameters|object} opts an object defining the initial config of the search. It doesn't have to be a {SearchParameters}, just an object containing the properties you need from it.\n * @return {AlgoliaSearchHelper}\n */\nfunction algoliasearchHelper(client, index, opts) {\n return new AlgoliaSearchHelper(client, index, opts);\n}\n\n/**\n * The version currently used\n * @member module:algoliasearchHelper.version\n * @type {number}\n */\nalgoliasearchHelper.version = require('./src/version.js');\n\n/**\n * Constructor for the Helper.\n * @member module:algoliasearchHelper.AlgoliaSearchHelper\n * @type {AlgoliaSearchHelper}\n */\nalgoliasearchHelper.AlgoliaSearchHelper = AlgoliaSearchHelper;\n\n/**\n * Constructor for the object containing all the parameters of the search.\n * @member module:algoliasearchHelper.SearchParameters\n * @type {SearchParameters}\n */\nalgoliasearchHelper.SearchParameters = SearchParameters;\n\n/**\n * Constructor for the object containing the results of the search.\n * @member module:algoliasearchHelper.SearchResults\n * @type {SearchResults}\n */\nalgoliasearchHelper.SearchResults = SearchResults;\n\nmodule.exports = algoliasearchHelper;\n","import algoliasearchHelper, {\n PlainSearchParameters,\n SearchParameters,\n} from 'algoliasearch-helper';\nimport createConnector, { ConnectedProps } from '../core/createConnector';\nimport {\n omit,\n getObjectType,\n removeEmptyKey,\n removeEmptyArraysFromObject,\n} from '../core/utils';\nimport {\n refineValue,\n getIndexId,\n hasMultipleIndices,\n} from '../core/indexUtils';\n\ntype Hit = any;\n\nexport type MatchingPatterns = {\n [attribute: string]: {\n /**\n * The score of the optional filter.\n *\n * @see https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/in-depth/optional-filters/\n */\n score: number;\n };\n};\n\ninterface ConfigureRelatedItemsProps {\n /**\n * The reference hit to extract the filters from.\n */\n hit: Hit;\n /**\n * The schema to create the optional filters.\n * Each key represents an attribute from the hit.\n */\n matchingPatterns: MatchingPatterns;\n /**\n * Function to transform the generated search parameters.\n */\n transformSearchParameters?(\n searchParameters: SearchParameters\n ): PlainSearchParameters;\n}\n\nfunction createOptionalFilter({\n attributeName,\n attributeValue,\n attributeScore,\n}) {\n return `${attributeName}:${attributeValue}`;\n}\n\nconst defaultProps: Partial = {\n transformSearchParameters: x => ({ ...x }),\n};\n\nfunction getId(): string {\n // We store the search state of this widget in `configure`.\n return 'configure';\n}\n\ntype InternalConfigureRelatedItemsProps = ConfigureRelatedItemsProps &\n Required;\n\nfunction getSearchParametersFromProps(\n props: ConnectedProps\n): PlainSearchParameters {\n const optionalFilters = Object.keys(props.matchingPatterns).reduce<\n Array\n >((acc, attributeName) => {\n const attributePattern = props.matchingPatterns[attributeName];\n const attributeValue = props.hit[attributeName];\n const attributeScore = attributePattern.score;\n\n if (Array.isArray(attributeValue)) {\n return [\n ...acc,\n attributeValue.map(attributeSubValue => {\n return createOptionalFilter({\n attributeName,\n attributeValue: attributeSubValue,\n attributeScore,\n });\n }),\n ];\n }\n\n if (typeof attributeValue === 'string') {\n return [\n ...acc,\n createOptionalFilter({\n attributeName,\n attributeValue,\n attributeScore,\n }),\n ];\n }\n\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.warn(\n `The \\`matchingPatterns\\` option returned a value of type ${getObjectType(\n attributeValue\n )} for the \"${attributeName}\" key. This value was not sent to Algolia because \\`optionalFilters\\` only supports strings and array of strings.\n\nYou can remove the \"${attributeName}\" key from the \\`matchingPatterns\\` option.\n\nSee https://www.algolia.com/doc/api-reference/api-parameters/optionalFilters/`\n );\n }\n\n return acc;\n }, []);\n\n return props.transformSearchParameters(\n new algoliasearchHelper.SearchParameters({\n // @ts-ignore @TODO algoliasearch-helper@3.0.1 will contain the type\n // `sumOrFiltersScores`.\n // See https://github.com/algolia/algoliasearch-helper-js/pull/753\n sumOrFiltersScores: true,\n facetFilters: [`objectID:-${props.hit.objectID}`],\n optionalFilters,\n })\n );\n}\n\ninterface ConnectorState {\n _searchParameters: PlainSearchParameters;\n}\n\nexport default createConnector({\n displayName: 'AlgoliaConfigureRelatedItems',\n\n defaultProps,\n\n getProvidedProps() {\n return {};\n },\n\n getSearchParameters(\n searchParameters: SearchParameters,\n props: ConnectedProps\n ) {\n return searchParameters.setQueryParameters(\n getSearchParametersFromProps(props)\n );\n },\n\n transitionState(\n this: ConnectorState,\n props,\n _prevSearchState,\n nextSearchState\n ) {\n const id = getId();\n // We need to transform the exhaustive search parameters back to clean\n // search parameters without the empty default keys so we don't pollute the\n // `configure` search state.\n const searchParameters = removeEmptyArraysFromObject(\n removeEmptyKey(getSearchParametersFromProps(props))\n );\n\n const searchParametersKeys = Object.keys(searchParameters);\n const nonPresentKeys = this._searchParameters\n ? Object.keys(this._searchParameters).filter(\n prop => searchParametersKeys.indexOf(prop) === -1\n )\n : [];\n this._searchParameters = searchParameters;\n const nextValue = {\n [id]: {\n ...omit(nextSearchState[id], nonPresentKeys),\n ...searchParameters,\n },\n };\n\n return refineValue(nextSearchState, nextValue, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n cleanUp(this: ConnectorState, props, searchState) {\n const id = getId();\n const indexId = getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n const subState =\n hasMultipleIndices({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }) && searchState.indices\n ? searchState.indices[indexId]\n : searchState;\n\n const configureKeys =\n subState && subState[id] ? Object.keys(subState[id]) : [];\n\n const configureState = configureKeys.reduce((acc, item) => {\n if (!this._searchParameters[item]) {\n acc[item] = subState[id][item];\n }\n\n return acc;\n }, {});\n\n const nextValue = { [id]: configureState };\n\n return refineValue(searchState, nextValue, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n});\n","export default (typeof global !== \"undefined\" ? global :\n typeof self !== \"undefined\" ? self :\n typeof window !== \"undefined\" ? window : {});\n","// shim for using process in browser\n// based off https://github.com/defunctzombie/node-process/blob/master/browser.js\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\nvar cachedSetTimeout = defaultSetTimout;\nvar cachedClearTimeout = defaultClearTimeout;\nif (typeof global.setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n}\nif (typeof global.clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n}\n\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\nexport function nextTick(fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n}\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nexport var title = 'browser';\nexport var platform = 'browser';\nexport var browser = true;\nexport var env = {};\nexport var argv = [];\nexport var version = ''; // empty string to avoid regexp issues\nexport var versions = {};\nexport var release = {};\nexport var config = {};\n\nfunction noop() {}\n\nexport var on = noop;\nexport var addListener = noop;\nexport var once = noop;\nexport var off = noop;\nexport var removeListener = noop;\nexport var removeAllListeners = noop;\nexport var emit = noop;\n\nexport function binding(name) {\n throw new Error('process.binding is not supported');\n}\n\nexport function cwd () { return '/' }\nexport function chdir (dir) {\n throw new Error('process.chdir is not supported');\n};\nexport function umask() { return 0; }\n\n// from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js\nvar performance = global.performance || {}\nvar performanceNow =\n performance.now ||\n performance.mozNow ||\n performance.msNow ||\n performance.oNow ||\n performance.webkitNow ||\n function(){ return (new Date()).getTime() }\n\n// generate timestamp or delta\n// see http://nodejs.org/api/process.html#process_process_hrtime\nexport function hrtime(previousTimestamp){\n var clocktime = performanceNow.call(performance)*1e-3\n var seconds = Math.floor(clocktime)\n var nanoseconds = Math.floor((clocktime%1)*1e9)\n if (previousTimestamp) {\n seconds = seconds - previousTimestamp[0]\n nanoseconds = nanoseconds - previousTimestamp[1]\n if (nanoseconds<0) {\n seconds--\n nanoseconds += 1e9\n }\n }\n return [seconds,nanoseconds]\n}\n\nvar startTime = new Date();\nexport function uptime() {\n var currentTime = new Date();\n var dif = currentTime - startTime;\n return dif / 1000;\n}\n\nexport default {\n nextTick: nextTick,\n title: title,\n browser: browser,\n env: env,\n argv: argv,\n version: version,\n versions: versions,\n on: on,\n addListener: addListener,\n once: once,\n off: off,\n removeListener: removeListener,\n removeAllListeners: removeAllListeners,\n emit: emit,\n binding: binding,\n cwd: cwd,\n chdir: chdir,\n umask: umask,\n hrtime: hrtime,\n platform: platform,\n release: release,\n config: config,\n uptime: uptime\n};\n","/*\nobject-assign\n(c) Sindre Sorhus\n@license MIT\n*/\n\n'use strict';\n/* eslint-disable no-unused-vars */\nvar getOwnPropertySymbols = Object.getOwnPropertySymbols;\nvar hasOwnProperty = Object.prototype.hasOwnProperty;\nvar propIsEnumerable = Object.prototype.propertyIsEnumerable;\n\nfunction toObject(val) {\n\tif (val === null || val === undefined) {\n\t\tthrow new TypeError('Object.assign cannot be called with null or undefined');\n\t}\n\n\treturn Object(val);\n}\n\nfunction shouldUseNative() {\n\ttry {\n\t\tif (!Object.assign) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Detect buggy property enumeration order in older V8 versions.\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=4118\n\t\tvar test1 = new String('abc'); // eslint-disable-line no-new-wrappers\n\t\ttest1[5] = 'de';\n\t\tif (Object.getOwnPropertyNames(test1)[0] === '5') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test2 = {};\n\t\tfor (var i = 0; i < 10; i++) {\n\t\t\ttest2['_' + String.fromCharCode(i)] = i;\n\t\t}\n\t\tvar order2 = Object.getOwnPropertyNames(test2).map(function (n) {\n\t\t\treturn test2[n];\n\t\t});\n\t\tif (order2.join('') !== '0123456789') {\n\t\t\treturn false;\n\t\t}\n\n\t\t// https://bugs.chromium.org/p/v8/issues/detail?id=3056\n\t\tvar test3 = {};\n\t\t'abcdefghijklmnopqrst'.split('').forEach(function (letter) {\n\t\t\ttest3[letter] = letter;\n\t\t});\n\t\tif (Object.keys(Object.assign({}, test3)).join('') !==\n\t\t\t\t'abcdefghijklmnopqrst') {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t} catch (err) {\n\t\t// We don't expect any of the above to throw, but better to be safe.\n\t\treturn false;\n\t}\n}\n\nmodule.exports = shouldUseNative() ? Object.assign : function (target, source) {\n\tvar from;\n\tvar to = toObject(target);\n\tvar symbols;\n\n\tfor (var s = 1; s < arguments.length; s++) {\n\t\tfrom = Object(arguments[s]);\n\n\t\tfor (var key in from) {\n\t\t\tif (hasOwnProperty.call(from, key)) {\n\t\t\t\tto[key] = from[key];\n\t\t\t}\n\t\t}\n\n\t\tif (getOwnPropertySymbols) {\n\t\t\tsymbols = getOwnPropertySymbols(from);\n\t\t\tfor (var i = 0; i < symbols.length; i++) {\n\t\t\t\tif (propIsEnumerable.call(from, symbols[i])) {\n\t\t\t\t\tto[symbols[i]] = from[symbols[i]];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn to;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = require('./lib/ReactPropTypesSecret');\n\nfunction emptyFunction() {}\n\nmodule.exports = function() {\n function shim(props, propName, componentName, location, propFullName, secret) {\n if (secret === ReactPropTypesSecret) {\n // It is still safe when called from React.\n return;\n }\n var err = new Error(\n 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +\n 'Use PropTypes.checkPropTypes() to call them. ' +\n 'Read more at http://fb.me/use-check-prop-types'\n );\n err.name = 'Invariant Violation';\n throw err;\n };\n shim.isRequired = shim;\n function getShim() {\n return shim;\n };\n // Important!\n // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.\n var ReactPropTypes = {\n array: shim,\n bool: shim,\n func: shim,\n number: shim,\n object: shim,\n string: shim,\n symbol: shim,\n\n any: shim,\n arrayOf: getShim,\n element: shim,\n instanceOf: getShim,\n node: shim,\n objectOf: getShim,\n oneOf: getShim,\n oneOfType: getShim,\n shape: getShim,\n exact: getShim\n };\n\n ReactPropTypes.checkPropTypes = emptyFunction;\n ReactPropTypes.PropTypes = ReactPropTypes;\n\n return ReactPropTypes;\n};\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nif (process.env.NODE_ENV !== 'production') {\n var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&\n Symbol.for &&\n Symbol.for('react.element')) ||\n 0xeac7;\n\n var isValidElement = function(object) {\n return typeof object === 'object' &&\n object !== null &&\n object.$$typeof === REACT_ELEMENT_TYPE;\n };\n\n // By explicitly using `prop-types` you are opting into new development behavior.\n // http://fb.me/prop-types-in-prod\n var throwOnDirectAccess = true;\n module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess);\n} else {\n // By explicitly using `prop-types` you are opting into new production behavior.\n // http://fb.me/prop-types-in-prod\n module.exports = require('./factoryWithThrowingShims')();\n}\n","/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n'use strict';\n\nvar ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';\n\nmodule.exports = ReactPropTypesSecret;\n","import connectConfigureRelatedItems from '../connectors/connectConfigureRelatedItems';\nimport PropTypes from 'prop-types';\n\nfunction ConfigureRelatedItems() {\n return null;\n}\n\nConfigureRelatedItems.propTypes = {\n hit: PropTypes.object.isRequired,\n matchingPatterns: PropTypes.object.isRequired,\n transformSearchParameters: PropTypes.func,\n};\n\nexport default connectConfigureRelatedItems(ConfigureRelatedItems);\n","import createConnector, { ConnectedProps } from '../core/createConnector';\nimport { getResults, getIndexId, hasMultipleIndices } from '../core/indexUtils';\n\ntype SearchState = any;\n\ntype SearchParameters = any;\n\nexport type CustomUserData = {\n [key: string]: any;\n};\n\ntype TrackedFilterRefinement = string | number | boolean;\n\nexport type QueryRulesProps = {\n trackedFilters: {\n [facetName: string]: (\n facetValues: TrackedFilterRefinement[]\n ) => TrackedFilterRefinement[];\n };\n transformRuleContexts: (ruleContexts: string[]) => string[];\n transformItems: (items: TItem[]) => TItem[];\n};\n\n// A context rule must consist only of alphanumeric characters, hyphens, and underscores.\n// See https://www.algolia.com/doc/guides/managing-results/refine-results/merchandising-and-promoting/in-depth/implementing-query-rules/#context\nfunction escapeRuleContext(ruleName: string): string {\n return ruleName.replace(/[^a-z0-9-_]+/gi, '_');\n}\n\nfunction getWidgetRefinements(\n attribute: string,\n widgetKey: string,\n searchState: SearchState\n): TrackedFilterRefinement[] {\n const widgetState = searchState[widgetKey];\n\n switch (widgetKey) {\n case 'range':\n return Object.keys(widgetState[attribute]).map(\n rangeKey => widgetState[attribute][rangeKey]\n );\n\n case 'refinementList':\n return widgetState[attribute];\n\n case 'hierarchicalMenu':\n return [widgetState[attribute]];\n\n case 'menu':\n return [widgetState[attribute]];\n\n case 'multiRange':\n return widgetState[attribute].split(':');\n\n case 'toggle':\n return [widgetState[attribute]];\n\n default:\n return [];\n }\n}\n\nfunction getRefinements(\n attribute: string,\n searchState: SearchState = {}\n): TrackedFilterRefinement[] {\n const refinements = Object.keys(searchState)\n .filter(\n widgetKey =>\n searchState[widgetKey] !== undefined &&\n searchState[widgetKey][attribute] !== undefined\n )\n .map(widgetKey => getWidgetRefinements(attribute, widgetKey, searchState))\n .reduce((acc, current) => acc.concat(current), []); // flatten the refinements\n\n return refinements;\n}\n\nfunction getRuleContextsFromTrackedFilters({\n searchState,\n trackedFilters,\n}: {\n searchState: SearchState;\n trackedFilters: QueryRulesProps['trackedFilters'];\n}) {\n const ruleContexts = Object.keys(trackedFilters).reduce(\n (facets, facetName) => {\n const facetRefinements: TrackedFilterRefinement[] = getRefinements(\n facetName,\n searchState\n );\n\n const getTrackedFacetValues = trackedFilters[facetName];\n const trackedFacetValues = getTrackedFacetValues(facetRefinements);\n\n return [\n ...facets,\n ...facetRefinements\n .filter(facetRefinement =>\n trackedFacetValues.includes(facetRefinement)\n )\n .map(facetValue =>\n escapeRuleContext(`ais-${facetName}-${facetValue}`)\n ),\n ];\n },\n []\n );\n\n return ruleContexts;\n}\n\nconst defaultProps: QueryRulesProps = {\n transformItems: items => items,\n transformRuleContexts: ruleContexts => ruleContexts,\n trackedFilters: {},\n};\n\nexport default createConnector({\n displayName: 'AlgoliaQueryRules',\n\n defaultProps,\n\n getProvidedProps(\n props: ConnectedProps,\n _1: any,\n searchResults: any\n ) {\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n if (results === null) {\n return {\n items: [],\n canRefine: false,\n };\n }\n\n const { userData = [] } = results;\n const { transformItems } = props;\n const transformedItems = transformItems(userData);\n\n return {\n items: transformedItems,\n canRefine: transformedItems.length > 0,\n };\n },\n\n getSearchParameters(\n searchParameters: SearchParameters,\n props: ConnectedProps,\n searchState: SearchState\n ) {\n if (Object.keys(props.trackedFilters).length === 0) {\n return searchParameters;\n }\n\n const indexSearchState =\n hasMultipleIndices({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }) && searchState.indices\n ? searchState.indices[\n getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n })\n ]\n : searchState;\n\n const newRuleContexts = getRuleContextsFromTrackedFilters({\n searchState: indexSearchState,\n trackedFilters: props.trackedFilters,\n });\n\n const initialRuleContexts = searchParameters.ruleContexts || [];\n const nextRuleContexts = [...initialRuleContexts, ...newRuleContexts];\n\n if (process.env.NODE_ENV === 'development') {\n if (nextRuleContexts.length > 10) {\n // eslint-disable-next-line no-console\n console.warn(\n `The maximum number of \\`ruleContexts\\` is 10. They have been sliced to that limit.\nConsider using \\`transformRuleContexts\\` to minimize the number of rules sent to Algolia.`\n );\n }\n }\n\n const ruleContexts = props\n .transformRuleContexts(nextRuleContexts)\n .slice(0, 10);\n\n return searchParameters.setQueryParameter('ruleContexts', ruleContexts);\n },\n});\n","import connectQueryRules from '../connectors/connectQueryRules';\n\nexport default connectQueryRules(function QueryRuleContext() {\n return null;\n});\n","import React, { Component, Children } from 'react';\nimport PropTypes from 'prop-types';\nimport {\n InstantSearchConsumer,\n InstantSearchContext,\n IndexProvider,\n IndexContext,\n} from '../core/context';\n\nfunction getIndexContext(props: Props): IndexContext {\n return {\n targetedIndex: props.indexId,\n };\n}\n\ntype Props = {\n indexName: string;\n indexId: string;\n};\n\ntype InnerProps = Props & { contextValue: InstantSearchContext };\n\ntype State = {\n indexContext: IndexContext;\n};\n\n/**\n * The component that allows you to apply widgets to a dedicated index. It's\n * useful if you want to build an interface that targets multiple indices.\n *\n * @example\n * import React from 'react';\n * import algoliasearch from 'algoliasearch/lite';\n * import { InstantSearch, Index, SearchBox, Hits, Configure } from 'react-instantsearch-dom';\n *\n * const searchClient = algoliasearch(\n * 'latency',\n * '6be0576ff61c053d5f9a3225e2a90f76'\n * );\n *\n * const App = () => (\n * \n * \n * \n * \n * \n * \n * \n * \n * \n * \n * );\n */\nclass Index extends Component {\n static propTypes = {\n indexName: PropTypes.string.isRequired,\n indexId: PropTypes.string.isRequired,\n children: PropTypes.node,\n };\n\n static getDerivedStateFromProps(props: InnerProps) {\n return {\n indexContext: getIndexContext(props),\n };\n }\n\n state = {\n indexContext: getIndexContext(this.props),\n };\n\n unregisterWidget?: () => void;\n\n constructor(props: InnerProps) {\n super(props);\n\n this.props.contextValue.onSearchParameters(\n this.getSearchParameters.bind(this),\n {\n ais: this.props.contextValue,\n multiIndexContext: this.state.indexContext,\n },\n this.props\n );\n }\n\n componentDidMount() {\n this.unregisterWidget = this.props.contextValue.widgetsManager.registerWidget(\n this\n );\n }\n\n componentDidUpdate(prevProps: InnerProps) {\n if (this.props.indexName !== prevProps.indexName) {\n this.props.contextValue.widgetsManager.update();\n }\n }\n\n componentWillUnmount() {\n if (typeof this.unregisterWidget === 'function') {\n this.unregisterWidget();\n }\n }\n\n getSearchParameters(searchParameters, props: InnerProps) {\n return searchParameters.setIndex(\n this.props ? this.props.indexName : props.indexName\n );\n }\n\n render() {\n const childrenCount = Children.count(this.props.children);\n if (childrenCount === 0) {\n return null;\n }\n return (\n \n {this.props.children}\n \n );\n }\n}\n\ntype IndexWrapperProps = {\n indexName: string;\n indexId?: string;\n};\n\nconst IndexWrapper: React.FC = props => {\n const inferredIndexId = props.indexName;\n return (\n \n {contextValue => (\n \n )}\n \n );\n};\n\nIndexWrapper.propTypes = {\n indexName: PropTypes.string.isRequired,\n indexId: PropTypes.string,\n};\n\nexport const IndexComponentWithoutContext = Index;\nexport default IndexWrapper;\n","import algoliasearchHelper from 'algoliasearch-helper';\nimport createWidgetsManager from './createWidgetsManager';\nimport createStore from './createStore';\nimport { HIGHLIGHT_TAGS } from './highlight';\nimport { hasMultipleIndices } from './indexUtils';\nimport { version as ReactVersion } from 'react';\nimport version from './version';\n\nfunction addAlgoliaAgents(searchClient) {\n if (typeof searchClient.addAlgoliaAgent === 'function') {\n searchClient.addAlgoliaAgent(`react (${ReactVersion})`);\n searchClient.addAlgoliaAgent(`react-instantsearch (${version})`);\n }\n}\n\nconst isMultiIndexContext = widget =>\n hasMultipleIndices({\n ais: widget.props.contextValue,\n multiIndexContext: widget.props.indexContextValue,\n });\nconst isTargetedIndexEqualIndex = (widget, indexId) =>\n widget.props.indexContextValue.targetedIndex === indexId;\n\n// Relying on the `indexId` is a bit brittle to detect the `Index` widget.\n// Since it's a class we could rely on `instanceof` or similar. We never\n// had an issue though. Works for now.\nconst isIndexWidget = widget => Boolean(widget.props.indexId);\nconst isIndexWidgetEqualIndex = (widget, indexId) =>\n widget.props.indexId === indexId;\n\nconst sortIndexWidgetsFirst = (firstWidget, secondWidget) => {\n const isFirstWidgetIndex = isIndexWidget(firstWidget);\n const isSecondWidgetIndex = isIndexWidget(secondWidget);\n\n if (isFirstWidgetIndex && !isSecondWidgetIndex) {\n return -1;\n }\n if (!isFirstWidgetIndex && isSecondWidgetIndex) {\n return 1;\n }\n return 0;\n};\n\n// This function is copied from the algoliasearch v4 API Client. If modified,\n// consider updating it also in `serializeQueryParameters` from `@algolia/transporter`.\nfunction serializeQueryParameters(parameters) {\n const isObjectOrArray = value =>\n Object.prototype.toString.call(value) === '[object Object]' ||\n Object.prototype.toString.call(value) === '[object Array]';\n\n const encode = (format, ...args) => {\n let i = 0;\n return format.replace(/%s/g, () => encodeURIComponent(args[i++]));\n };\n\n return Object.keys(parameters)\n .map(key =>\n encode(\n '%s=%s',\n key,\n isObjectOrArray(parameters[key])\n ? JSON.stringify(parameters[key])\n : parameters[key]\n )\n )\n .join('&');\n}\n\n/**\n * Creates a new instance of the InstantSearchManager which controls the widgets and\n * trigger the search when the widgets are updated.\n * @param {string} indexName - the main index name\n * @param {object} initialState - initial widget state\n * @param {object} SearchParameters - optional additional parameters to send to the algolia API\n * @param {number} stalledSearchDelay - time (in ms) after the search is stalled\n * @return {InstantSearchManager} a new instance of InstantSearchManager\n */\nexport default function createInstantSearchManager({\n indexName,\n initialState = {},\n searchClient,\n resultsState,\n stalledSearchDelay,\n}) {\n const helper = algoliasearchHelper(searchClient, indexName, {\n ...HIGHLIGHT_TAGS,\n });\n\n addAlgoliaAgents(searchClient);\n\n helper\n .on('search', handleNewSearch)\n .on('result', handleSearchSuccess({ indexId: indexName }))\n .on('error', handleSearchError);\n\n let skip = false;\n let stalledSearchTimer = null;\n let initialSearchParameters = helper.state;\n\n const widgetsManager = createWidgetsManager(onWidgetsUpdate);\n\n hydrateSearchClient(searchClient, resultsState);\n\n const store = createStore({\n widgets: initialState,\n metadata: [],\n results: hydrateResultsState(resultsState),\n error: null,\n searching: false,\n isSearchStalled: true,\n searchingForFacetValues: false,\n });\n\n function skipSearch() {\n skip = true;\n }\n\n function updateClient(client) {\n addAlgoliaAgents(client);\n helper.setClient(client);\n search();\n }\n\n function clearCache() {\n helper.clearCache();\n search();\n }\n\n function getMetadata(state) {\n return widgetsManager\n .getWidgets()\n .filter(widget => Boolean(widget.getMetadata))\n .map(widget => widget.getMetadata(state));\n }\n\n function getSearchParameters() {\n const sharedParameters = widgetsManager\n .getWidgets()\n .filter(widget => Boolean(widget.getSearchParameters))\n .filter(widget => !isMultiIndexContext(widget) && !isIndexWidget(widget))\n .reduce(\n (res, widget) => widget.getSearchParameters(res),\n initialSearchParameters\n );\n\n const mainParameters = widgetsManager\n .getWidgets()\n .filter(widget => Boolean(widget.getSearchParameters))\n .filter(widget => {\n const targetedIndexEqualMainIndex =\n isMultiIndexContext(widget) &&\n isTargetedIndexEqualIndex(widget, indexName);\n\n const subIndexEqualMainIndex =\n isIndexWidget(widget) && isIndexWidgetEqualIndex(widget, indexName);\n\n return targetedIndexEqualMainIndex || subIndexEqualMainIndex;\n })\n // We have to sort the `Index` widgets first so the `index` parameter\n // is correctly set in the `reduce` function for the following widgets\n .sort(sortIndexWidgetsFirst)\n .reduce(\n (res, widget) => widget.getSearchParameters(res),\n sharedParameters\n );\n\n const derivedIndices = widgetsManager\n .getWidgets()\n .filter(widget => Boolean(widget.getSearchParameters))\n .filter(widget => {\n const targetedIndexNotEqualMainIndex =\n isMultiIndexContext(widget) &&\n !isTargetedIndexEqualIndex(widget, indexName);\n\n const subIndexNotEqualMainIndex =\n isIndexWidget(widget) && !isIndexWidgetEqualIndex(widget, indexName);\n\n return targetedIndexNotEqualMainIndex || subIndexNotEqualMainIndex;\n })\n // We have to sort the `Index` widgets first so the `index` parameter\n // is correctly set in the `reduce` function for the following widgets\n .sort(sortIndexWidgetsFirst)\n .reduce((indices, widget) => {\n const indexId = isMultiIndexContext(widget)\n ? widget.props.indexContextValue.targetedIndex\n : widget.props.indexId;\n\n const widgets = indices[indexId] || [];\n\n return {\n ...indices,\n [indexId]: widgets.concat(widget),\n };\n }, {});\n\n const derivedParameters = Object.keys(derivedIndices).map(indexId => ({\n parameters: derivedIndices[indexId].reduce(\n (res, widget) => widget.getSearchParameters(res),\n sharedParameters\n ),\n indexId,\n }));\n\n return {\n mainParameters,\n derivedParameters,\n };\n }\n\n function search() {\n if (!skip) {\n const { mainParameters, derivedParameters } = getSearchParameters(\n helper.state\n );\n\n // We have to call `slice` because the method `detach` on the derived\n // helpers mutates the value `derivedHelpers`. The `forEach` loop does\n // not iterate on each value and we're not able to correctly clear the\n // previous derived helpers (memory leak + useless requests).\n helper.derivedHelpers.slice().forEach(derivedHelper => {\n // Since we detach the derived helpers on **every** new search they\n // won't receive intermediate results in case of a stalled search.\n // Only the last result is dispatched by the derived helper because\n // they are not detached yet:\n //\n // - a -> main helper receives results\n // - ap -> main helper receives results\n // - app -> main helper + derived helpers receive results\n //\n // The quick fix is to avoid to detach them on search but only once they\n // received the results. But it means that in case of a stalled search\n // all the derived helpers not detached yet register a new search inside\n // the helper. The number grows fast in case of a bad network and it's\n // not deterministic.\n derivedHelper.detach();\n });\n\n derivedParameters.forEach(({ indexId, parameters }) => {\n const derivedHelper = helper.derive(() => parameters);\n\n derivedHelper\n .on('result', handleSearchSuccess({ indexId }))\n .on('error', handleSearchError);\n });\n\n helper.setState(mainParameters);\n\n helper.search();\n }\n }\n\n function handleSearchSuccess({ indexId }) {\n return event => {\n const state = store.getState();\n const isDerivedHelpersEmpty = !helper.derivedHelpers.length;\n\n let results = state.results ? state.results : {};\n\n // Switching from mono index to multi index and vice versa must reset the\n // results to an empty object, otherwise we keep reference of stalled and\n // unused results.\n results = !isDerivedHelpersEmpty && results.getFacetByName ? {} : results;\n\n if (!isDerivedHelpersEmpty) {\n results = { ...results, [indexId]: event.results };\n } else {\n results = event.results;\n }\n\n const currentState = store.getState();\n let nextIsSearchStalled = currentState.isSearchStalled;\n if (!helper.hasPendingRequests()) {\n clearTimeout(stalledSearchTimer);\n stalledSearchTimer = null;\n nextIsSearchStalled = false;\n }\n\n const { resultsFacetValues, ...partialState } = currentState;\n\n store.setState({\n ...partialState,\n results,\n isSearchStalled: nextIsSearchStalled,\n searching: false,\n error: null,\n });\n };\n }\n\n function handleSearchError({ error }) {\n const currentState = store.getState();\n\n let nextIsSearchStalled = currentState.isSearchStalled;\n if (!helper.hasPendingRequests()) {\n clearTimeout(stalledSearchTimer);\n nextIsSearchStalled = false;\n }\n\n const { resultsFacetValues, ...partialState } = currentState;\n\n store.setState({\n ...partialState,\n isSearchStalled: nextIsSearchStalled,\n error,\n searching: false,\n });\n }\n\n function handleNewSearch() {\n if (!stalledSearchTimer) {\n stalledSearchTimer = setTimeout(() => {\n const { resultsFacetValues, ...partialState } = store.getState();\n\n store.setState({\n ...partialState,\n isSearchStalled: true,\n });\n }, stalledSearchDelay);\n }\n }\n\n function hydrateSearchClient(client, results) {\n if (!results) {\n return;\n }\n\n // Disable cache hydration on:\n // - Algoliasearch API Client < v4 with cache disabled\n // - Third party clients (detected by the `addAlgoliaAgent` function missing)\n\n if (\n (!client.transporter || client._cacheHydrated) &&\n (!client._useCache || typeof client.addAlgoliaAgent !== 'function')\n ) {\n return;\n }\n\n // Algoliasearch API Client >= v4\n // To hydrate the client we need to populate the cache with the data from\n // the server (done in `hydrateSearchClientWithMultiIndexRequest` or\n // `hydrateSearchClientWithSingleIndexRequest`). But since there is no way\n // for us to compute the key the same way as `algoliasearch-client` we need\n // to populate it on a custom key and override the `search` method to\n // search on it first.\n if (client.transporter && !client._cacheHydrated) {\n client._cacheHydrated = true;\n\n const baseMethod = client.search;\n client.search = (requests, ...methodArgs) => {\n const requestsWithSerializedParams = requests.map(request => ({\n ...request,\n params: serializeQueryParameters(request.params),\n }));\n\n return client.transporter.responsesCache.get(\n {\n method: 'search',\n args: [requestsWithSerializedParams, ...methodArgs],\n },\n () => {\n return baseMethod(requests, ...methodArgs);\n }\n );\n };\n }\n\n if (Array.isArray(results)) {\n hydrateSearchClientWithMultiIndexRequest(client, results);\n return;\n }\n\n hydrateSearchClientWithSingleIndexRequest(client, results);\n }\n\n function hydrateSearchClientWithMultiIndexRequest(client, results) {\n // Algoliasearch API Client >= v4\n // Populate the cache with the data from the server\n if (client.transporter) {\n client.transporter.responsesCache.set(\n {\n method: 'search',\n args: [\n results.reduce(\n (acc, result) =>\n acc.concat(\n result.rawResults.map(request => ({\n indexName: request.index,\n params: request.params,\n }))\n ),\n []\n ),\n ],\n },\n {\n results: results.reduce(\n (acc, result) => acc.concat(result.rawResults),\n []\n ),\n }\n );\n return;\n }\n\n // Algoliasearch API Client < v4\n // Prior to client v4 we didn't have a proper API to hydrate the client\n // cache from the outside. The following code populates the cache with\n // a single-index result. You can find more information about the\n // computation of the key inside the client (see link below).\n // https://github.com/algolia/algoliasearch-client-javascript/blob/c27e89ff92b2a854ae6f40dc524bffe0f0cbc169/src/AlgoliaSearchCore.js#L232-L240\n const key = `/1/indexes/*/queries_body_${JSON.stringify({\n requests: results.reduce(\n (acc, result) =>\n acc.concat(\n result.rawResults.map(request => ({\n indexName: request.index,\n params: request.params,\n }))\n ),\n []\n ),\n })}`;\n\n client.cache = {\n ...client.cache,\n [key]: JSON.stringify({\n results: results.reduce(\n (acc, result) => acc.concat(result.rawResults),\n []\n ),\n }),\n };\n }\n\n function hydrateSearchClientWithSingleIndexRequest(client, results) {\n // Algoliasearch API Client >= v4\n // Populate the cache with the data from the server\n if (client.transporter) {\n client.transporter.responsesCache.set(\n {\n method: 'search',\n args: [\n results.rawResults.map(request => ({\n indexName: request.index,\n params: request.params,\n })),\n ],\n },\n {\n results: results.rawResults,\n }\n );\n return;\n }\n // Algoliasearch API Client < v4\n // Prior to client v4 we didn't have a proper API to hydrate the client\n // cache from the outside. The following code populates the cache with\n // a single-index result. You can find more information about the\n // computation of the key inside the client (see link below).\n // https://github.com/algolia/algoliasearch-client-javascript/blob/c27e89ff92b2a854ae6f40dc524bffe0f0cbc169/src/AlgoliaSearchCore.js#L232-L240\n const key = `/1/indexes/*/queries_body_${JSON.stringify({\n requests: results.rawResults.map(request => ({\n indexName: request.index,\n params: request.params,\n })),\n })}`;\n\n client.cache = {\n ...client.cache,\n [key]: JSON.stringify({\n results: results.rawResults,\n }),\n };\n }\n\n function hydrateResultsState(results) {\n if (!results) {\n return null;\n }\n\n if (Array.isArray(results)) {\n return results.reduce(\n (acc, result) => ({\n ...acc,\n [result._internalIndexId]: new algoliasearchHelper.SearchResults(\n new algoliasearchHelper.SearchParameters(result.state),\n result.rawResults\n ),\n }),\n {}\n );\n }\n\n return new algoliasearchHelper.SearchResults(\n new algoliasearchHelper.SearchParameters(results.state),\n results.rawResults\n );\n }\n\n // Called whenever a widget has been rendered with new props.\n function onWidgetsUpdate() {\n const metadata = getMetadata(store.getState().widgets);\n\n store.setState({\n ...store.getState(),\n metadata,\n searching: true,\n });\n\n // Since the `getSearchParameters` method of widgets also depends on props,\n // the result search parameters might have changed.\n search();\n }\n\n function transitionState(nextSearchState) {\n const searchState = store.getState().widgets;\n\n return widgetsManager\n .getWidgets()\n .filter(widget => Boolean(widget.transitionState))\n .reduce(\n (res, widget) => widget.transitionState(searchState, res),\n nextSearchState\n );\n }\n\n function onExternalStateUpdate(nextSearchState) {\n const metadata = getMetadata(nextSearchState);\n\n store.setState({\n ...store.getState(),\n widgets: nextSearchState,\n metadata,\n searching: true,\n });\n\n search();\n }\n\n function onSearchForFacetValues({ facetName, query, maxFacetHits = 10 }) {\n // The values 1, 100 are the min / max values that the engine accepts.\n // see: https://www.algolia.com/doc/api-reference/api-parameters/maxFacetHits\n const maxFacetHitsWithinRange = Math.max(1, Math.min(maxFacetHits, 100));\n\n store.setState({\n ...store.getState(),\n searchingForFacetValues: true,\n });\n\n helper\n .searchForFacetValues(facetName, query, maxFacetHitsWithinRange)\n .then(\n content => {\n store.setState({\n ...store.getState(),\n error: null,\n searchingForFacetValues: false,\n resultsFacetValues: {\n ...store.getState().resultsFacetValues,\n [facetName]: content.facetHits,\n query,\n },\n });\n },\n error => {\n store.setState({\n ...store.getState(),\n searchingForFacetValues: false,\n error,\n });\n }\n )\n .catch(error => {\n // Since setState is synchronous, any error that occurs in the render of a\n // component will be swallowed by this promise.\n // This is a trick to make the error show up correctly in the console.\n // See http://stackoverflow.com/a/30741722/969302\n setTimeout(() => {\n throw error;\n });\n });\n }\n\n function updateIndex(newIndex) {\n initialSearchParameters = initialSearchParameters.setIndex(newIndex);\n // No need to trigger a new search here as the widgets will also update and trigger it if needed.\n }\n\n function getWidgetsIds() {\n return store\n .getState()\n .metadata.reduce(\n (res, meta) =>\n typeof meta.id !== 'undefined' ? res.concat(meta.id) : res,\n []\n );\n }\n\n return {\n store,\n widgetsManager,\n getWidgetsIds,\n getSearchParameters,\n onSearchForFacetValues,\n onExternalStateUpdate,\n transitionState,\n updateClient,\n updateIndex,\n clearCache,\n skipSearch,\n };\n}\n","import { defer } from './utils';\n\nexport default function createWidgetsManager(onWidgetsUpdate) {\n const widgets = [];\n // Is an update scheduled?\n let scheduled = false;\n\n // The state manager's updates need to be batched since more than one\n // component can register or unregister widgets during the same tick.\n function scheduleUpdate() {\n if (scheduled) {\n return;\n }\n scheduled = true;\n defer(() => {\n scheduled = false;\n onWidgetsUpdate();\n });\n }\n\n return {\n registerWidget(widget) {\n widgets.push(widget);\n scheduleUpdate();\n return function unregisterWidget() {\n widgets.splice(widgets.indexOf(widget), 1);\n scheduleUpdate();\n };\n },\n update: scheduleUpdate,\n getWidgets() {\n return widgets;\n },\n };\n}\n","type SearchState = any;\ntype ResultsState = any;\ntype ResultsFacetsValues = any;\ntype Listener = () => void;\ntype State = {\n widgets: SearchState;\n metadata: any[];\n results: ResultsState | null;\n resultsFacetValues: ResultsFacetsValues | null;\n error: Error | null;\n searching: boolean;\n isSearchStalled: boolean;\n searchingForFacetValues: boolean;\n};\nexport default function createStore(initialState: State) {\n let state = initialState;\n const listeners: Listener[] = [];\n return {\n getState() {\n return state;\n },\n setState(nextState: State) {\n state = nextState;\n listeners.forEach(listener => listener());\n },\n subscribe(listener: Listener) {\n listeners.push(listener);\n return function unsubscribe() {\n listeners.splice(listeners.indexOf(listener), 1);\n };\n },\n };\n}\n\nexport type Store = ReturnType;\n","import React, { Component, Children } from 'react';\nimport isEqual from 'react-fast-compare';\nimport PropTypes from 'prop-types';\nimport createInstantSearchManager from '../core/createInstantSearchManager';\nimport { InstantSearchProvider, InstantSearchContext } from '../core/context';\nimport { Store } from '../core/createStore';\nimport { PlainSearchParameters, SearchParameters } from 'algoliasearch-helper';\nimport { MultiResponse } from '../types/algoliasearch';\n\ntype ResultsState = {\n state: PlainSearchParameters;\n rawResults: MultiResponse;\n};\n\n// @TODO: move to createInstantSearchManager when it's TS\ntype InstantSearchManager = {\n store: Store;\n widgetsManager: any;\n getWidgetsIds: any;\n getSearchParameters: (\n ...args: any[]\n ) => {\n mainParameters: SearchParameters;\n derivedParameters: SearchParameters;\n };\n onSearchForFacetValues: (...args: any[]) => any;\n onExternalStateUpdate: (...args: any[]) => any;\n transitionState: any;\n updateClient: any;\n updateIndex: any;\n clearCache: () => void;\n skipSearch: any;\n};\n\ntype SearchClient = {\n search: (requests: Array<{}>) => Promise<{}>;\n searchForFacetValues: (requests: Array<{}>) => Promise<{}>;\n};\n\ntype SearchState = any;\n\ntype Props = {\n refresh: boolean;\n indexName: string;\n searchClient: SearchClient;\n createURL?: (searchState: SearchState, knownKeys: any) => string;\n onSearchStateChange?: (searchState: SearchState) => void;\n searchState?: SearchState;\n onSearchParameters?: (\n getSearchParameters: (...args: any) => any,\n context: any,\n props: any,\n searchState: SearchState\n ) => void;\n stalledSearchDelay?: number;\n resultsState: ResultsState | { [indexId: string]: ResultsState };\n};\n\ntype State = {\n isControlled: boolean;\n instantSearchManager: InstantSearchManager;\n contextValue: InstantSearchContext;\n};\n\nfunction isControlled(props: Props) {\n return Boolean(props.searchState);\n}\n\n/**\n * @description\n * `` is the root component of all React InstantSearch implementations.\n * It provides all the connected components (aka widgets) a means to interact\n * with the searchState.\n * @kind widget\n * @name \n * @requirements You will need to have an Algolia account to be able to use this widget.\n * [Create one now](https://www.algolia.com/users/sign_up).\n * @propType {string} indexName - Main index in which to search.\n * @propType {boolean} [refresh=false] - Flag to activate when the cache needs to be cleared so that the front-end is updated when a change occurs in the index.\n * @propType {object} [searchClient] - Provide a custom search client.\n * @propType {func} [onSearchStateChange] - Function to be called everytime a new search is done. Useful for [URL Routing](guide/Routing.html).\n * @propType {object} [searchState] - Object to inject some search state. Switches the InstantSearch component in controlled mode. Useful for [URL Routing](guide/Routing.html).\n * @propType {func} [createURL] - Function to call when creating links, useful for [URL Routing](guide/Routing.html).\n * @propType {SearchResults|SearchResults[]} [resultsState] - Use this to inject the results that will be used at first rendering. Those results are found by using the `findResultsState` function. Useful for [Server Side Rendering](guide/Server-side_rendering.html).\n * @propType {number} [stalledSearchDelay=200] - The amount of time before considering that the search takes too much time. The time is expressed in milliseconds.\n * @propType {{ Root: string|function, props: object }} [root] - Use this to customize the root element. Default value: `{ Root: 'div' }`\n * @example\n * import React from 'react';\n * import algoliasearch from 'algoliasearch/lite';\n * import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom';\n *\n * const searchClient = algoliasearch(\n * 'latency',\n * '6be0576ff61c053d5f9a3225e2a90f76'\n * );\n *\n * const App = () => (\n * \n * \n * \n * \n * );\n */\nclass InstantSearch extends Component {\n static defaultProps = {\n stalledSearchDelay: 200,\n refresh: false,\n };\n\n static propTypes = {\n // @TODO: These props are currently constant.\n indexName: PropTypes.string.isRequired,\n\n searchClient: PropTypes.shape({\n search: PropTypes.func.isRequired,\n searchForFacetValues: PropTypes.func,\n addAlgoliaAgent: PropTypes.func,\n clearCache: PropTypes.func,\n }).isRequired,\n\n createURL: PropTypes.func,\n\n refresh: PropTypes.bool,\n\n searchState: PropTypes.object,\n onSearchStateChange: PropTypes.func,\n\n onSearchParameters: PropTypes.func,\n resultsState: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),\n\n children: PropTypes.node,\n stalledSearchDelay: PropTypes.number,\n };\n\n static getDerivedStateFromProps(\n nextProps: Props,\n prevState: State\n ): Partial {\n const nextIsControlled = isControlled(nextProps);\n const previousSearchState = prevState.instantSearchManager.store.getState()\n .widgets;\n const nextSearchState = nextProps.searchState;\n\n if (nextIsControlled && !isEqual(previousSearchState, nextSearchState)) {\n prevState.instantSearchManager.onExternalStateUpdate(\n nextProps.searchState\n );\n }\n\n return {\n isControlled: nextIsControlled,\n contextValue: {\n ...prevState.contextValue,\n mainTargetedIndex: nextProps.indexName,\n },\n };\n }\n\n isUnmounting: boolean = false;\n\n constructor(props: Props) {\n super(props);\n\n const instantSearchManager = createInstantSearchManager({\n indexName: this.props.indexName,\n searchClient: this.props.searchClient,\n initialState: this.props.searchState || {},\n resultsState: this.props.resultsState,\n stalledSearchDelay: this.props.stalledSearchDelay,\n });\n\n const contextValue = {\n store: instantSearchManager.store,\n widgetsManager: instantSearchManager.widgetsManager,\n mainTargetedIndex: this.props.indexName,\n onInternalStateUpdate: this.onWidgetsInternalStateUpdate.bind(this),\n createHrefForState: this.createHrefForState.bind(this),\n onSearchForFacetValues: this.onSearchForFacetValues.bind(this),\n onSearchStateChange: this.onSearchStateChange.bind(this),\n onSearchParameters: this.onSearchParameters.bind(this),\n };\n\n this.state = {\n isControlled: isControlled(this.props),\n instantSearchManager,\n contextValue,\n };\n }\n\n componentDidUpdate(prevProps: Props) {\n const prevIsControlled = isControlled(prevProps);\n\n if (prevIsControlled && !this.state.isControlled) {\n throw new Error(\n \"You can't switch from being controlled to uncontrolled\"\n );\n }\n\n if (!prevIsControlled && this.state.isControlled) {\n throw new Error(\n \"You can't switch from being uncontrolled to controlled\"\n );\n }\n\n if (this.props.refresh !== prevProps.refresh && this.props.refresh) {\n this.state.instantSearchManager.clearCache();\n }\n\n if (prevProps.indexName !== this.props.indexName) {\n this.state.instantSearchManager.updateIndex(this.props.indexName);\n }\n\n if (prevProps.searchClient !== this.props.searchClient) {\n this.state.instantSearchManager.updateClient(this.props.searchClient);\n }\n }\n\n componentWillUnmount() {\n this.isUnmounting = true;\n this.state.instantSearchManager.skipSearch();\n }\n\n createHrefForState(searchState: SearchState) {\n searchState = this.state.instantSearchManager.transitionState(searchState);\n return this.state.isControlled && this.props.createURL\n ? this.props.createURL(searchState, this.getKnownKeys())\n : '#';\n }\n\n onWidgetsInternalStateUpdate(searchState: SearchState) {\n searchState = this.state.instantSearchManager.transitionState(searchState);\n\n this.onSearchStateChange(searchState);\n\n if (!this.state.isControlled) {\n this.state.instantSearchManager.onExternalStateUpdate(searchState);\n }\n }\n\n onSearchStateChange(searchState) {\n if (this.props.onSearchStateChange && !this.isUnmounting) {\n this.props.onSearchStateChange(searchState);\n }\n }\n\n onSearchParameters(getSearchParameters, context, props) {\n if (this.props.onSearchParameters) {\n const searchState = this.props.searchState ? this.props.searchState : {};\n this.props.onSearchParameters(\n getSearchParameters,\n context,\n props,\n searchState\n );\n }\n }\n\n onSearchForFacetValues(searchState) {\n this.state.instantSearchManager.onSearchForFacetValues(searchState);\n }\n\n getKnownKeys() {\n return this.state.instantSearchManager.getWidgetsIds();\n }\n\n render() {\n if (Children.count(this.props.children) === 0) {\n return null;\n }\n\n return (\n \n {this.props.children}\n \n );\n }\n}\n\nexport default InstantSearch;\n","import createConnector from '../core/createConnector';\nimport {\n cleanUpValue,\n refineValue,\n getCurrentRefinementValue,\n} from '../core/indexUtils';\nimport { addQueryID, addAbsolutePositions } from '../core/utils';\n\nconst getId = () => 'query';\n\nfunction getCurrentRefinement(props, searchState, context) {\n const id = getId();\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n id,\n ''\n );\n\n if (currentRefinement) {\n return currentRefinement;\n }\n return '';\n}\n\nfunction getHits(searchResults) {\n if (searchResults.results) {\n if (\n searchResults.results.hits &&\n Array.isArray(searchResults.results.hits)\n ) {\n return addAbsolutePositions(\n addQueryID(searchResults.results.hits, searchResults.results.queryID),\n searchResults.results.hitsPerPage,\n searchResults.results.page\n );\n } else {\n return Object.keys(searchResults.results).reduce(\n (hits, index) => [\n ...hits,\n {\n index,\n hits: addAbsolutePositions(\n addQueryID(\n searchResults.results[index].hits,\n searchResults.results[index].queryID\n ),\n searchResults.results[index].hitsPerPage,\n searchResults.results[index].page\n ),\n },\n ],\n []\n );\n }\n } else {\n return [];\n }\n}\n\nfunction refine(props, searchState, nextRefinement, context) {\n const id = getId();\n const nextValue = { [id]: nextRefinement };\n const resetPage = true;\n return refineValue(searchState, nextValue, context, resetPage);\n}\n\nfunction cleanUp(props, searchState, context) {\n return cleanUpValue(searchState, context, getId());\n}\n\n/**\n * connectAutoComplete connector provides the logic to create connected\n * components that will render the results retrieved from\n * Algolia.\n *\n * To configure the number of hits retrieved, use [HitsPerPage widget](widgets/HitsPerPage.html),\n * [connectHitsPerPage connector](connectors/connectHitsPerPage.html) or pass the hitsPerPage\n * prop to a [Configure](guide/Search_parameters.html) widget.\n * @name connectAutoComplete\n * @kind connector\n * @propType {string} [defaultRefinement] - Provide a default value for the query\n * @providedPropType {array.} hits - the records that matched the search state\n * @providedPropType {function} refine - a function to change the query\n * @providedPropType {string} currentRefinement - the query to search for\n */\nexport default createConnector({\n displayName: 'AlgoliaAutoComplete',\n\n getProvidedProps(props, searchState, searchResults) {\n return {\n hits: getHits(searchResults),\n currentRefinement: getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n };\n },\n\n refine(props, searchState, nextRefinement) {\n return refine(props, searchState, nextRefinement, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n cleanUp(props, searchState) {\n return cleanUp(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n /**\n * AutoComplete needs to be considered as a widget to trigger a search,\n * even if no other widgets are used.\n *\n * To be considered as a widget you need either:\n * - getSearchParameters\n * - getMetadata\n * - transitionState\n *\n * See: createConnector.tsx\n */\n getSearchParameters(searchParameters, props, searchState) {\n return searchParameters.setQuery(\n getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n })\n );\n },\n});\n","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport { refineValue, getResults } from '../core/indexUtils';\n\nexport const getId = props => props.attributes[0];\n\nconst namespace = 'hierarchicalMenu';\n\nfunction refine(props, searchState, nextRefinement, context) {\n const id = getId(props);\n const nextValue = { [id]: nextRefinement || '' };\n const resetPage = true;\n return refineValue(searchState, nextValue, context, resetPage, namespace);\n}\n\nfunction transformValue(values) {\n return values.reduce((acc, item) => {\n if (item.isRefined) {\n acc.push({\n label: item.name,\n // If dealing with a nested \"items\", \"value\" is equal to the previous value concatenated with the current label\n // If dealing with the first level, \"value\" is equal to the current label\n value: item.path,\n });\n // Create a variable in order to keep the same acc for the recursion, otherwise \"reduce\" returns a new one\n if (item.data) {\n acc = acc.concat(transformValue(item.data, acc));\n }\n }\n return acc;\n }, []);\n}\n\n/**\n * The breadcrumb component is s a type of secondary navigation scheme that\n * reveals the user’s location in a website or web application.\n *\n * @name connectBreadcrumb\n * @requirements To use this widget, your attributes must be formatted in a specific way.\n * If you want for example to have a Breadcrumb of categories, objects in your index\n * should be formatted this way:\n *\n * ```json\n * {\n * \"categories.lvl0\": \"products\",\n * \"categories.lvl1\": \"products > fruits\",\n * \"categories.lvl2\": \"products > fruits > citrus\"\n * }\n * ```\n *\n * It's also possible to provide more than one path for each level:\n *\n * ```json\n * {\n * \"categories.lvl0\": [\"products\", \"goods\"],\n * \"categories.lvl1\": [\"products > fruits\", \"goods > to eat\"]\n * }\n * ```\n *\n * All attributes passed to the `attributes` prop must be present in \"attributes for faceting\"\n * on the Algolia dashboard or configured as `attributesForFaceting` via a set settings call to the Algolia API.\n *\n * @kind connector\n * @propType {array.} attributes - List of attributes to use to generate the hierarchy of the menu. See the example for the convention to follow.\n * @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.\n * @providedPropType {function} refine - a function to toggle a refinement\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n * @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the Breadcrumb can display.\n */\n\nexport default createConnector({\n displayName: 'AlgoliaBreadcrumb',\n\n propTypes: {\n attributes: (props, propName, componentName) => {\n const isNotString = val => typeof val !== 'string';\n if (\n !Array.isArray(props[propName]) ||\n props[propName].some(isNotString) ||\n props[propName].length < 1\n ) {\n return new Error(\n `Invalid prop ${propName} supplied to ${componentName}. Expected an Array of Strings`\n );\n }\n return undefined;\n },\n transformItems: PropTypes.func,\n },\n\n getProvidedProps(props, searchState, searchResults) {\n const id = getId(props);\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n const isFacetPresent =\n Boolean(results) && Boolean(results.getFacetByName(id));\n\n if (!isFacetPresent) {\n return {\n items: [],\n canRefine: false,\n };\n }\n\n const values = results.getFacetValues(id);\n\n const items = values.data ? transformValue(values.data) : [];\n\n const transformedItems = props.transformItems\n ? props.transformItems(items)\n : items;\n\n return {\n canRefine: transformedItems.length > 0,\n items: transformedItems,\n };\n },\n\n refine(props, searchState, nextRefinement) {\n return refine(props, searchState, nextRefinement, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n});\n","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\n\n/**\n * connectCurrentRefinements connector provides the logic to build a widget that will\n * give the user the ability to remove all or some of the filters that were\n * set.\n * @name connectCurrentRefinements\n * @kind connector\n * @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.\n * @propType {function} [clearsQuery=false] - Pass true to also clear the search query\n * @providedPropType {function} refine - a function to remove a single filter\n * @providedPropType {array.<{label: string, attribute: string, currentRefinement: string || object, items: array, value: function}>} items - all the filters, the `value` is to pass to the `refine` function for removing all currentrefinements, `label` is for the display. When existing several refinements for the same atribute name, then you get a nested `items` object that contains a `label` and a `value` function to use to remove a single filter. `attribute` and `currentRefinement` are metadata containing row values.\n * @providedPropType {string} query - the search query\n */\nexport default createConnector({\n displayName: 'AlgoliaCurrentRefinements',\n\n propTypes: {\n transformItems: PropTypes.func,\n },\n\n getProvidedProps(props, searchState, searchResults, metadata) {\n const items = metadata.reduce((res, meta) => {\n if (typeof meta.items !== 'undefined') {\n if (!props.clearsQuery && meta.id === 'query') {\n return res;\n } else {\n if (\n props.clearsQuery &&\n meta.id === 'query' &&\n meta.items[0].currentRefinement === ''\n ) {\n return res;\n }\n return res.concat(\n meta.items.map(item => ({\n ...item,\n id: meta.id,\n index: meta.index,\n }))\n );\n }\n }\n return res;\n }, []);\n\n const transformedItems = props.transformItems\n ? props.transformItems(items)\n : items;\n\n return {\n items: transformedItems,\n canRefine: transformedItems.length > 0,\n };\n },\n\n refine(props, searchState, items) {\n // `value` corresponds to our internal clear function computed in each connector metadata.\n const refinementsToClear =\n items instanceof Array ? items.map(item => item.value) : [items];\n return refinementsToClear.reduce((res, clear) => clear(res), searchState);\n },\n});\n","import { objectHasKeys } from '../core/utils';\nimport createConnector from '../core/createConnector';\nimport {\n getResults,\n getCurrentRefinementValue,\n getIndexId,\n refineValue,\n cleanUpValue,\n} from '../core/indexUtils';\n\n/**\n * The GeoSearch connector provides the logic to build a widget that will display the results on a map.\n * It also provides a way to search for results based on their position. The connector provides function to manage the search experience (search on map interaction).\n * @name connectGeoSearch\n * @kind connector\n * @requirements Note that the GeoSearch connector uses the [geosearch](https://www.algolia.com/doc/guides/searching/geo-search) capabilities of Algolia.\n * Your hits **must** have a `_geoloc` attribute in order to be passed to the rendering function. Currently, the feature is not compatible with multiple values in the `_geoloc` attribute\n * (e.g. a restaurant with multiple locations). In that case you can duplicate your records and use the [distinct](https://www.algolia.com/doc/guides/ranking/distinct) feature of Algolia to only retrieve unique results.\n * @propType {{ northEast: { lat: number, lng: number }, southWest: { lat: number, lng: number } }} [defaultRefinement] - Default search state of the widget containing the bounds for the map\n * @providedPropType {function({ northEast: { lat: number, lng: number }, southWest: { lat: number, lng: number } })} refine - a function to toggle the refinement\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n * @providedPropType {array.} hits - the records that matched the search\n * @providedPropType {boolean} isRefinedWithMap - true if the current refinement is set with the map bounds\n * @providedPropType {{ northEast: { lat: number, lng: number }, southWest: { lat: number, lng: number } }} [currentRefinement] - the refinement currently applied\n * @providedPropType {{ lat: number, lng: number }} [position] - the position of the search\n */\n\n// To control the map with an external widget the other widget\n// **must** write the value in the attribute `aroundLatLng`\nconst getBoundingBoxId = () => 'boundingBox';\nconst getAroundLatLngId = () => 'aroundLatLng';\nconst getConfigureAroundLatLngId = () => 'configure.aroundLatLng';\n\nconst currentRefinementToString = currentRefinement =>\n [\n currentRefinement.northEast.lat,\n currentRefinement.northEast.lng,\n currentRefinement.southWest.lat,\n currentRefinement.southWest.lng,\n ].join();\n\nconst stringToCurrentRefinement = value => {\n const values = value.split(',');\n\n return {\n northEast: {\n lat: parseFloat(values[0]),\n lng: parseFloat(values[1]),\n },\n southWest: {\n lat: parseFloat(values[2]),\n lng: parseFloat(values[3]),\n },\n };\n};\n\nconst latLngRegExp = /^(-?\\d+(?:\\.\\d+)?),\\s*(-?\\d+(?:\\.\\d+)?)$/;\nconst stringToPosition = value => {\n const pattern = value.match(latLngRegExp);\n\n return {\n lat: parseFloat(pattern[1]),\n lng: parseFloat(pattern[2]),\n };\n};\n\nconst getCurrentRefinement = (props, searchState, context) => {\n const refinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n getBoundingBoxId(),\n {}\n );\n\n if (!objectHasKeys(refinement)) {\n return;\n }\n\n // eslint-disable-next-line consistent-return\n return {\n northEast: {\n lat: parseFloat(refinement.northEast.lat),\n lng: parseFloat(refinement.northEast.lng),\n },\n southWest: {\n lat: parseFloat(refinement.southWest.lat),\n lng: parseFloat(refinement.southWest.lng),\n },\n };\n};\n\nconst getCurrentPosition = (props, searchState, context) => {\n const { defaultRefinement, ...propsWithoutDefaultRefinement } = props;\n\n const aroundLatLng = getCurrentRefinementValue(\n propsWithoutDefaultRefinement,\n searchState,\n context,\n getAroundLatLngId()\n );\n\n if (!aroundLatLng) {\n // Fallback on `configure.aroundLatLng`\n const configureAroundLatLng = getCurrentRefinementValue(\n propsWithoutDefaultRefinement,\n searchState,\n context,\n getConfigureAroundLatLngId()\n );\n\n return configureAroundLatLng && stringToPosition(configureAroundLatLng);\n }\n\n return aroundLatLng;\n};\n\nconst refine = (searchState, nextValue, context) => {\n const resetPage = true;\n const nextRefinement = {\n [getBoundingBoxId()]: nextValue,\n };\n\n return refineValue(searchState, nextRefinement, context, resetPage);\n};\n\nexport default createConnector({\n displayName: 'AlgoliaGeoSearch',\n\n getProvidedProps(props, searchState, searchResults) {\n const context = {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n };\n\n const results = getResults(searchResults, context);\n\n // We read it from both because the SearchParameters & the searchState are not always\n // in sync. When we set the refinement the searchState is used but when we clear the refinement\n // the SearchParameters is used. In the first case when we render, the results are not there\n // so we can't find the value from the results. The most up to date value is the searchState.\n // But when we clear the refinement the searchState is immediately cleared even when the items\n // retrieved are still the one from the previous query with the bounding box. It leads to some\n // issue with the position of the map. We should rely on 1 source of truth or at least always\n // be sync.\n\n const currentRefinementFromSearchState = getCurrentRefinement(\n props,\n searchState,\n context\n );\n\n const currentRefinementFromSearchParameters =\n (results &&\n results._state.insideBoundingBox &&\n stringToCurrentRefinement(results._state.insideBoundingBox)) ||\n undefined;\n\n const currentPositionFromSearchState = getCurrentPosition(\n props,\n searchState,\n context\n );\n\n const currentPositionFromSearchParameters =\n (results &&\n results._state.aroundLatLng &&\n stringToPosition(results._state.aroundLatLng)) ||\n undefined;\n\n const currentRefinement =\n currentRefinementFromSearchState || currentRefinementFromSearchParameters;\n\n const position =\n currentPositionFromSearchState || currentPositionFromSearchParameters;\n\n return {\n hits: !results ? [] : results.hits.filter(_ => Boolean(_._geoloc)),\n isRefinedWithMap: Boolean(currentRefinement),\n currentRefinement,\n position,\n };\n },\n\n refine(props, searchState, nextValue) {\n return refine(searchState, nextValue, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n const currentRefinement = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n if (!currentRefinement) {\n return searchParameters;\n }\n\n return searchParameters.setQueryParameter(\n 'insideBoundingBox',\n currentRefinementToString(currentRefinement)\n );\n },\n\n cleanUp(props, searchState) {\n return cleanUpValue(\n searchState,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue },\n getBoundingBoxId()\n );\n },\n\n getMetadata(props, searchState) {\n const items = [];\n const id = getBoundingBoxId();\n const context = {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n };\n const index = getIndexId(context);\n const nextRefinement = {};\n const currentRefinement = getCurrentRefinement(props, searchState, context);\n\n if (currentRefinement) {\n items.push({\n label: `${id}: ${currentRefinementToString(currentRefinement)}`,\n value: nextState => refine(nextState, nextRefinement, context),\n currentRefinement,\n });\n }\n\n return {\n id,\n index,\n items,\n };\n },\n\n shouldComponentUpdate() {\n return true;\n },\n});\n","import PropTypes from 'prop-types';\nimport algoliasearchHelper from 'algoliasearch-helper';\nimport createConnector from '../core/createConnector';\nimport {\n cleanUpValue,\n getIndexId,\n refineValue,\n getCurrentRefinementValue,\n getResults,\n} from '../core/indexUtils';\n\nexport const getId = props => props.attributes[0];\n\nconst namespace = 'hierarchicalMenu';\n\nfunction getCurrentRefinement(props, searchState, context) {\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n `${namespace}.${getId(props)}`,\n null\n );\n\n if (currentRefinement === '') {\n return null;\n }\n return currentRefinement;\n}\n\nfunction getValue(path, props, searchState, context) {\n const { id, attributes, separator, rootPath, showParentLevel } = props;\n\n const currentRefinement = getCurrentRefinement(props, searchState, context);\n let nextRefinement;\n\n if (currentRefinement === null) {\n nextRefinement = path;\n } else {\n const tmpSearchParameters = new algoliasearchHelper.SearchParameters({\n hierarchicalFacets: [\n {\n name: id,\n attributes,\n separator,\n rootPath,\n showParentLevel,\n },\n ],\n });\n\n nextRefinement = tmpSearchParameters\n .toggleHierarchicalFacetRefinement(id, currentRefinement)\n .toggleHierarchicalFacetRefinement(id, path)\n .getHierarchicalRefinement(id)[0];\n }\n\n return nextRefinement;\n}\n\nfunction transformValue(value, props, searchState, context) {\n return value.map(v => ({\n label: v.name,\n value: getValue(v.path, props, searchState, context),\n count: v.count,\n isRefined: v.isRefined,\n items: v.data && transformValue(v.data, props, searchState, context),\n }));\n}\n\nconst truncate = (items = [], limit = 10) =>\n items.slice(0, limit).map((item = {}) =>\n Array.isArray(item.items)\n ? {\n ...item,\n items: truncate(item.items, limit),\n }\n : item\n );\n\nfunction refine(props, searchState, nextRefinement, context) {\n const id = getId(props);\n const nextValue = { [id]: nextRefinement || '' };\n const resetPage = true;\n return refineValue(searchState, nextValue, context, resetPage, namespace);\n}\n\nfunction cleanUp(props, searchState, context) {\n return cleanUpValue(searchState, context, `${namespace}.${getId(props)}`);\n}\n\nconst sortBy = ['name:asc'];\n\n/**\n * connectHierarchicalMenu connector provides the logic to build a widget that will\n * give the user the ability to explore a tree-like structure.\n * This is commonly used for multi-level categorization of products on e-commerce\n * websites. From a UX point of view, we suggest not displaying more than two levels deep.\n * @name connectHierarchicalMenu\n * @requirements To use this widget, your attributes must be formatted in a specific way.\n * If you want for example to have a hiearchical menu of categories, objects in your index\n * should be formatted this way:\n *\n * ```json\n * {\n * \"categories.lvl0\": \"products\",\n * \"categories.lvl1\": \"products > fruits\",\n * \"categories.lvl2\": \"products > fruits > citrus\"\n * }\n * ```\n *\n * It's also possible to provide more than one path for each level:\n *\n * ```json\n * {\n * \"categories.lvl0\": [\"products\", \"goods\"],\n * \"categories.lvl1\": [\"products > fruits\", \"goods > to eat\"]\n * }\n * ```\n *\n * All attributes passed to the `attributes` prop must be present in \"attributes for faceting\"\n * on the Algolia dashboard or configured as `attributesForFaceting` via a set settings call to the Algolia API.\n *\n * @kind connector\n * @propType {array.} attributes - List of attributes to use to generate the hierarchy of the menu. See the example for the convention to follow.\n * @propType {string} [defaultRefinement] - the item value selected by default\n * @propType {boolean} [showMore=false] - Flag to activate the show more button, for toggling the number of items between limit and showMoreLimit.\n * @propType {number} [limit=10] - The maximum number of items displayed.\n * @propType {number} [showMoreLimit=20] - The maximum number of items displayed when the user triggers the show more. Not considered if `showMore` is false.\n * @propType {string} [separator='>'] - Specifies the level separator used in the data.\n * @propType {string} [rootPath=null] - The path to use if the first level is not the root level.\n * @propType {boolean} [showParentLevel=true] - Flag to set if the parent level should be displayed.\n * @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.\n * @providedPropType {function} refine - a function to toggle a refinement\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n * @providedPropType {string} currentRefinement - the refinement currently applied\n * @providedPropType {array.<{items: object, count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the HierarchicalMenu can display. items has the same shape as parent items.\n */\nexport default createConnector({\n displayName: 'AlgoliaHierarchicalMenu',\n\n propTypes: {\n attributes: (props, propName, componentName) => {\n const isNotString = val => typeof val !== 'string';\n if (\n !Array.isArray(props[propName]) ||\n props[propName].some(isNotString) ||\n props[propName].length < 1\n ) {\n return new Error(\n `Invalid prop ${propName} supplied to ${componentName}. Expected an Array of Strings`\n );\n }\n return undefined;\n },\n separator: PropTypes.string,\n rootPath: PropTypes.string,\n showParentLevel: PropTypes.bool,\n defaultRefinement: PropTypes.string,\n showMore: PropTypes.bool,\n limit: PropTypes.number,\n showMoreLimit: PropTypes.number,\n transformItems: PropTypes.func,\n },\n\n defaultProps: {\n showMore: false,\n limit: 10,\n showMoreLimit: 20,\n separator: ' > ',\n rootPath: null,\n showParentLevel: true,\n },\n\n getProvidedProps(props, searchState, searchResults) {\n const { showMore, limit, showMoreLimit } = props;\n const id = getId(props);\n\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n const isFacetPresent =\n Boolean(results) && Boolean(results.getFacetByName(id));\n\n if (!isFacetPresent) {\n return {\n items: [],\n currentRefinement: getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n canRefine: false,\n };\n }\n const itemsLimit = showMore ? showMoreLimit : limit;\n const value = results.getFacetValues(id, { sortBy });\n const items = value.data\n ? transformValue(value.data, props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n })\n : [];\n const transformedItems = props.transformItems\n ? props.transformItems(items)\n : items;\n return {\n items: truncate(transformedItems, itemsLimit),\n currentRefinement: getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n canRefine: transformedItems.length > 0,\n };\n },\n\n refine(props, searchState, nextRefinement) {\n return refine(props, searchState, nextRefinement, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n cleanUp(props, searchState) {\n return cleanUp(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n const {\n attributes,\n separator,\n rootPath,\n showParentLevel,\n showMore,\n limit,\n showMoreLimit,\n contextValue,\n } = props;\n\n const id = getId(props);\n const itemsLimit = showMore ? showMoreLimit : limit;\n\n searchParameters = searchParameters\n .addHierarchicalFacet({\n name: id,\n attributes,\n separator,\n rootPath,\n showParentLevel,\n })\n .setQueryParameters({\n maxValuesPerFacet: Math.max(\n searchParameters.maxValuesPerFacet || 0,\n itemsLimit\n ),\n });\n\n const currentRefinement = getCurrentRefinement(props, searchState, {\n ais: contextValue,\n multiIndexContext: props.indexContextValue,\n });\n if (currentRefinement !== null) {\n searchParameters = searchParameters.toggleHierarchicalFacetRefinement(\n id,\n currentRefinement\n );\n }\n\n return searchParameters;\n },\n\n getMetadata(props, searchState) {\n const rootAttribute = props.attributes[0];\n const id = getId(props);\n const currentRefinement = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n const items = !currentRefinement\n ? []\n : [\n {\n label: `${rootAttribute}: ${currentRefinement}`,\n attribute: rootAttribute,\n value: nextState =>\n refine(props, nextState, '', {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n currentRefinement,\n },\n ];\n\n return {\n id,\n index: getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n items,\n };\n },\n});\n","import createConnector from '../core/createConnector';\nimport { HIGHLIGHT_TAGS, parseAlgoliaHit } from '../core/highlight';\n\nconst highlight = ({\n attribute,\n hit,\n highlightProperty,\n preTag = HIGHLIGHT_TAGS.highlightPreTag,\n postTag = HIGHLIGHT_TAGS.highlightPostTag,\n}) =>\n parseAlgoliaHit({\n attribute,\n highlightProperty,\n hit,\n preTag,\n postTag,\n });\n\n/**\n * connectHighlight connector provides the logic to create an highlighter\n * component that will retrieve, parse and render an highlighted attribute\n * from an Algolia hit.\n * @name connectHighlight\n * @kind connector\n * @category connector\n * @providedPropType {function} highlight - function to retrieve and parse an attribute from a hit. It takes a configuration object with 3 attributes: `highlightProperty` which is the property that contains the highlight structure from the records, `attribute` which is the name of the attribute (it can be either a string or an array of strings) to look for and `hit` which is the hit from Algolia. It returns an array of objects `{value: string, isHighlighted: boolean}`. If the element that corresponds to the attribute is an array of strings, it will return a nested array of objects.\n * @example\n * import React from 'react';\n * import algoliasearch from 'algoliasearch/lite';\n * import { InstantSearch, SearchBox, Hits, connectHighlight } from 'react-instantsearch-dom';\n *\n * const searchClient = algoliasearch(\n * 'latency',\n * '6be0576ff61c053d5f9a3225e2a90f76'\n * );\n *\n * const CustomHighlight = connectHighlight(\n * ({ highlight, attribute, hit, highlightProperty }) => {\n * const highlights = highlight({\n * highlightProperty: '_highlightResult',\n * attribute,\n * hit\n * });\n *\n * return highlights.map(part => part.isHighlighted ? (\n * {part.value}\n * ) : (\n * {part.value}\n * ));\n * }\n * );\n *\n * const Hit = ({ hit }) => (\n *

\n * \n *

\n * );\n *\n * const App = () => (\n * \n * \n * \n * \n * );\n */\nexport default createConnector({\n displayName: 'AlgoliaHighlighter',\n\n propTypes: {},\n\n getProvidedProps() {\n return { highlight };\n },\n});\n","import createConnector from '../core/createConnector';\nimport { getResults } from '../core/indexUtils';\nimport { addAbsolutePositions, addQueryID } from '../core/utils';\n\n/**\n * connectHits connector provides the logic to create connected\n * components that will render the results retrieved from\n * Algolia.\n *\n * To configure the number of hits retrieved, use [HitsPerPage widget](widgets/HitsPerPage.html),\n * [connectHitsPerPage connector](connectors/connectHitsPerPage.html) or pass the hitsPerPage\n * prop to a [Configure](guide/Search_parameters.html) widget.\n *\n * **Warning:** you will need to use the **objectID** property available on every hit as a key\n * when iterating over them. This will ensure you have the best possible UI experience\n * especially on slow networks.\n * @name connectHits\n * @kind connector\n * @providedPropType {array.} hits - the records that matched the search state\n * @example\n * import React from 'react';\n * import algoliasearch from 'algoliasearch/lite';\n * import { InstantSearch, Highlight, connectHits } from 'react-instantsearch-dom';\n *\n * const searchClient = algoliasearch(\n * 'latency',\n * '6be0576ff61c053d5f9a3225e2a90f76'\n * );\n * const CustomHits = connectHits(({ hits }) => (\n *
\n * {hits.map(hit =>\n *

\n * \n *

\n * )}\n *
\n * ));\n *\n * const App = () => (\n * \n * \n * \n * );\n */\nexport default createConnector({\n displayName: 'AlgoliaHits',\n\n getProvidedProps(props, searchState, searchResults) {\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n if (!results) {\n return { hits: [] };\n }\n const hitsWithPositions = addAbsolutePositions(\n results.hits,\n results.hitsPerPage,\n results.page\n );\n const hitsWithPositionsAndQueryID = addQueryID(\n hitsWithPositions,\n results.queryID\n );\n return { hits: hitsWithPositionsAndQueryID };\n },\n\n /**\n * Hits needs to be considered as a widget to trigger a search,\n * even if no other widgets are used.\n *\n * To be considered as a widget you need either:\n * - getSearchParameters\n * - getMetadata\n * - transitionState\n *\n * See: createConnector.tsx\n */\n getSearchParameters(searchParameters) {\n return searchParameters;\n },\n});\n","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport {\n cleanUpValue,\n refineValue,\n getCurrentRefinementValue,\n} from '../core/indexUtils';\n\nfunction getId() {\n return 'hitsPerPage';\n}\n\nfunction getCurrentRefinement(props, searchState, context) {\n const id = getId();\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n id,\n null\n );\n\n if (typeof currentRefinement === 'string') {\n return parseInt(currentRefinement, 10);\n }\n return currentRefinement;\n}\n\n/**\n * connectHitsPerPage connector provides the logic to create connected\n * components that will allow a user to choose to display more or less results from Algolia.\n * @name connectHitsPerPage\n * @kind connector\n * @propType {number} defaultRefinement - The number of items selected by default\n * @propType {{value: number, label: string}[]} items - List of hits per page options.\n * @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.\n * @providedPropType {function} refine - a function to remove a single filter\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n * @providedPropType {string} currentRefinement - the refinement currently applied\n * @providedPropType {array.<{isRefined: boolean, label?: string, value: number}>} items - the list of items the HitsPerPage can display. If no label provided, the value will be displayed.\n */\nexport default createConnector({\n displayName: 'AlgoliaHitsPerPage',\n\n propTypes: {\n defaultRefinement: PropTypes.number.isRequired,\n items: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.string,\n value: PropTypes.number.isRequired,\n })\n ).isRequired,\n transformItems: PropTypes.func,\n },\n\n getProvidedProps(props, searchState) {\n const currentRefinement = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n const items = props.items.map(item =>\n item.value === currentRefinement\n ? { ...item, isRefined: true }\n : { ...item, isRefined: false }\n );\n return {\n items: props.transformItems ? props.transformItems(items) : items,\n currentRefinement,\n };\n },\n\n refine(props, searchState, nextRefinement) {\n const id = getId();\n const nextValue = { [id]: nextRefinement };\n const resetPage = true;\n return refineValue(\n searchState,\n nextValue,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue },\n resetPage\n );\n },\n\n cleanUp(props, searchState) {\n return cleanUpValue(\n searchState,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue },\n getId()\n );\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n return searchParameters.setHitsPerPage(\n getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n })\n );\n },\n\n getMetadata() {\n return { id: getId() };\n },\n});\n","import isEqual from 'react-fast-compare';\n\nimport createConnector from '../core/createConnector';\nimport {\n getCurrentRefinementValue,\n refineValue,\n getResults,\n} from '../core/indexUtils';\nimport { addAbsolutePositions, addQueryID } from '../core/utils';\n\nfunction getId() {\n return 'page';\n}\n\nfunction getCurrentRefinement(props, searchState, context) {\n const id = getId();\n const page = 1;\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n id,\n page\n );\n\n if (typeof currentRefinement === 'string') {\n return parseInt(currentRefinement, 10);\n }\n return currentRefinement;\n}\n\nfunction getStateWithoutPage(state) {\n const { page, ...rest } = state || {};\n return rest;\n}\n\nfunction getInMemoryCache() {\n let cachedHits = undefined;\n let cachedState = undefined;\n return {\n read({ state }) {\n return isEqual(cachedState, getStateWithoutPage(state))\n ? cachedHits\n : null;\n },\n write({ state, hits }) {\n cachedState = getStateWithoutPage(state);\n cachedHits = hits;\n },\n };\n}\n\nfunction extractHitsFromCachedHits(cachedHits) {\n return Object.keys(cachedHits)\n .map(Number)\n .sort((a, b) => a - b)\n .reduce((acc, page) => {\n return acc.concat(cachedHits[page]);\n }, []);\n}\n\n/**\n * InfiniteHits connector provides the logic to create connected\n * components that will render an continuous list of results retrieved from\n * Algolia. This connector provides a function to load more results.\n * @name connectInfiniteHits\n * @kind connector\n * @providedPropType {array.} hits - the records that matched the search state\n * @providedPropType {boolean} hasMore - indicates if there are more pages to load\n * @providedPropType {function} refine - call to load more results\n */\nexport default createConnector({\n displayName: 'AlgoliaInfiniteHits',\n\n getProvidedProps(props, searchState, searchResults) {\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n this._prevState = this._prevState || {};\n\n const cache = props.cache || getInMemoryCache();\n if (this._cachedHits === undefined) {\n this._cachedHits = cache.read({ state: searchState }) || {};\n }\n\n if (!results) {\n return {\n hits: extractHitsFromCachedHits(this._cachedHits),\n hasPrevious: false,\n hasMore: false,\n refine: () => {},\n refinePrevious: () => {},\n refineNext: () => {},\n };\n }\n\n const {\n page,\n hits,\n hitsPerPage,\n nbPages,\n _state: { page: p, ...currentState } = {},\n } = results;\n\n const hitsWithPositions = addAbsolutePositions(hits, hitsPerPage, page);\n const hitsWithPositionsAndQueryID = addQueryID(\n hitsWithPositions,\n results.queryID\n );\n\n if (!isEqual(currentState, this._prevState)) {\n this._cachedHits = cache.read({ state: searchState }) || {};\n }\n if (this._cachedHits[page] === undefined) {\n this._cachedHits[page] = hitsWithPositionsAndQueryID;\n cache.write({ state: searchState, hits: this._cachedHits });\n }\n\n this._prevState = currentState;\n /*\n Math.min() and Math.max() returns Infinity or -Infinity when no argument is given.\n But there is always something in this point because of `this._cachedHits[page]`.\n */\n const firstReceivedPage = Math.min(\n ...Object.keys(this._cachedHits).map(Number)\n );\n const lastReceivedPage = Math.max(\n ...Object.keys(this._cachedHits).map(Number)\n );\n\n const hasPrevious = firstReceivedPage > 0;\n const lastPageIndex = nbPages - 1;\n const hasMore = lastReceivedPage < lastPageIndex;\n const refinePrevious = event => this.refine(event, firstReceivedPage - 1);\n const refineNext = event => this.refine(event, lastReceivedPage + 1);\n\n return {\n hits: extractHitsFromCachedHits(this._cachedHits),\n hasPrevious,\n hasMore,\n refinePrevious,\n refineNext,\n };\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n return searchParameters.setQueryParameters({\n page:\n getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }) - 1,\n });\n },\n\n refine(props, searchState, event, index) {\n const pages = Object.keys(this._cachedHits || {}).map(Number);\n const lastReceivedPage =\n pages.length === 0 ? undefined : Math.max(...pages);\n // If there is no key in `this._cachedHits`,\n // then `lastReceivedPage` should be `undefined`.\n if (index === undefined && lastReceivedPage !== undefined) {\n index = lastReceivedPage + 1;\n } else if (index === undefined) {\n index = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n }\n\n const id = getId();\n const nextValue = { [id]: index + 1 };\n const resetPage = false;\n return refineValue(\n searchState,\n nextValue,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue },\n resetPage\n );\n },\n});\n","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport {\n getIndexId,\n cleanUpValue,\n refineValue,\n getCurrentRefinementValue,\n getResults,\n} from '../core/indexUtils';\n\nconst namespace = 'menu';\n\nfunction getId(props) {\n return props.attribute;\n}\n\nfunction getCurrentRefinement(props, searchState, context) {\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n `${namespace}.${getId(props)}`,\n null\n );\n\n if (currentRefinement === '') {\n return null;\n }\n return currentRefinement;\n}\n\nfunction getValue(name, props, searchState, context) {\n const currentRefinement = getCurrentRefinement(props, searchState, context);\n return name === currentRefinement ? '' : name;\n}\n\nfunction getLimit({ showMore, limit, showMoreLimit }) {\n return showMore ? showMoreLimit : limit;\n}\n\nfunction refine(props, searchState, nextRefinement, context) {\n const id = getId(props);\n const nextValue = { [id]: nextRefinement ? nextRefinement : '' };\n const resetPage = true;\n return refineValue(searchState, nextValue, context, resetPage, namespace);\n}\n\nfunction cleanUp(props, searchState, context) {\n return cleanUpValue(searchState, context, `${namespace}.${getId(props)}`);\n}\n\nconst defaultSortBy = ['count:desc', 'name:asc'];\n\n/**\n * connectMenu connector provides the logic to build a widget that will\n * give the user the ability to choose a single value for a specific facet.\n * @name connectMenu\n * @requirements The attribute passed to the `attribute` prop must be present in \"attributes for faceting\"\n * on the Algolia dashboard or configured as `attributesForFaceting` via a set settings call to the Algolia API.\n * @kind connector\n * @propType {string} attribute - the name of the attribute in the record\n * @propType {boolean} [showMore=false] - true if the component should display a button that will expand the number of items\n * @propType {number} [limit=10] - the minimum number of diplayed items\n * @propType {number} [showMoreLimit=20] - the maximun number of displayed items. Only used when showMore is set to `true`\n * @propType {string} [defaultRefinement] - the value of the item selected by default\n * @propType {boolean} [searchable=false] - allow search inside values\n * @providedPropType {function} refine - a function to toggle a refinement\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n * @providedPropType {string} currentRefinement - the refinement currently applied\n * @providedPropType {array.<{count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the Menu can display.\n * @providedPropType {function} searchForItems - a function to toggle a search inside items values\n * @providedPropType {boolean} isFromSearch - a boolean that says if the `items` props contains facet values from the global search or from the search inside items.\n */\nexport default createConnector({\n displayName: 'AlgoliaMenu',\n\n propTypes: {\n attribute: PropTypes.string.isRequired,\n showMore: PropTypes.bool,\n limit: PropTypes.number,\n showMoreLimit: PropTypes.number,\n defaultRefinement: PropTypes.string,\n transformItems: PropTypes.func,\n searchable: PropTypes.bool,\n },\n\n defaultProps: {\n showMore: false,\n limit: 10,\n showMoreLimit: 20,\n },\n\n getProvidedProps(\n props,\n searchState,\n searchResults,\n meta,\n searchForFacetValuesResults\n ) {\n const { attribute, searchable, indexContextValue } = props;\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n const canRefine =\n Boolean(results) && Boolean(results.getFacetByName(attribute));\n\n const isFromSearch = Boolean(\n searchForFacetValuesResults &&\n searchForFacetValuesResults[attribute] &&\n searchForFacetValuesResults.query !== ''\n );\n\n // Search For Facet Values is not available with derived helper (used for multi index search)\n if (searchable && indexContextValue) {\n throw new Error(\n 'react-instantsearch: searching in *List is not available when used inside a' +\n ' multi index context'\n );\n }\n\n if (!canRefine) {\n return {\n items: [],\n currentRefinement: getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n isFromSearch,\n searchable,\n canRefine,\n };\n }\n\n let items;\n if (isFromSearch) {\n items = searchForFacetValuesResults[attribute].map(v => ({\n label: v.value,\n value: getValue(v.value, props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n _highlightResult: { label: { value: v.highlighted } },\n count: v.count,\n isRefined: v.isRefined,\n }));\n } else {\n items = results\n .getFacetValues(attribute, {\n sortBy: searchable ? undefined : defaultSortBy,\n })\n .map(v => ({\n label: v.name,\n value: getValue(v.name, props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n count: v.count,\n isRefined: v.isRefined,\n }));\n }\n\n const transformedItems = props.transformItems\n ? props.transformItems(items)\n : items;\n\n return {\n items: transformedItems.slice(0, getLimit(props)),\n currentRefinement: getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n isFromSearch,\n searchable,\n canRefine: transformedItems.length > 0,\n };\n },\n\n refine(props, searchState, nextRefinement) {\n return refine(props, searchState, nextRefinement, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n searchForFacetValues(props, searchState, nextRefinement) {\n return {\n facetName: props.attribute,\n query: nextRefinement,\n maxFacetHits: getLimit(props),\n };\n },\n\n cleanUp(props, searchState) {\n return cleanUp(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n const { attribute } = props;\n\n searchParameters = searchParameters.setQueryParameters({\n maxValuesPerFacet: Math.max(\n searchParameters.maxValuesPerFacet || 0,\n getLimit(props)\n ),\n });\n\n searchParameters = searchParameters.addDisjunctiveFacet(attribute);\n\n const currentRefinement = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n if (currentRefinement !== null) {\n searchParameters = searchParameters.addDisjunctiveFacetRefinement(\n attribute,\n currentRefinement\n );\n }\n\n return searchParameters;\n },\n\n getMetadata(props, searchState) {\n const id = getId(props);\n const currentRefinement = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n return {\n id,\n index: getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n items:\n currentRefinement === null\n ? []\n : [\n {\n label: `${props.attribute}: ${currentRefinement}`,\n attribute: props.attribute,\n value: nextState =>\n refine(props, nextState, '', {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n currentRefinement,\n },\n ],\n };\n },\n});\n","import arrayWithHoles from \"./arrayWithHoles\";\nimport iterableToArrayLimit from \"./iterableToArrayLimit\";\nimport nonIterableRest from \"./nonIterableRest\";\nexport default function _slicedToArray(arr, i) {\n return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();\n}","export default function _arrayWithHoles(arr) {\n if (Array.isArray(arr)) return arr;\n}","export default function _iterableToArrayLimit(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"] != null) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n}","export default function _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n}","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport { find } from '../core/utils';\nimport {\n cleanUpValue,\n refineValue,\n getCurrentRefinementValue,\n getResults,\n getIndexId,\n} from '../core/indexUtils';\n\nfunction stringifyItem(item) {\n if (typeof item.start === 'undefined' && typeof item.end === 'undefined') {\n return '';\n }\n const start = typeof item.start !== 'undefined' ? item.start : '';\n const end = typeof item.end !== 'undefined' ? item.end : '';\n return `${start}:${end}`;\n}\n\nfunction parseItem(value) {\n if (value.length === 0) {\n return { start: null, end: null };\n }\n const [startStr, endStr] = value.split(':');\n return {\n start: startStr.length > 0 ? parseInt(startStr, 10) : null,\n end: endStr.length > 0 ? parseInt(endStr, 10) : null,\n };\n}\n\nconst namespace = 'multiRange';\n\nfunction getId(props) {\n return props.attribute;\n}\n\nfunction getCurrentRefinement(props, searchState, context) {\n return getCurrentRefinementValue(\n props,\n searchState,\n context,\n `${namespace}.${getId(props)}`,\n '',\n currentRefinement => {\n if (currentRefinement === '') {\n return '';\n }\n return currentRefinement;\n }\n );\n}\n\nfunction isRefinementsRangeIncludesInsideItemRange(stats, start, end) {\n return (\n (stats.min > start && stats.min < end) ||\n (stats.max > start && stats.max < end)\n );\n}\n\nfunction isItemRangeIncludedInsideRefinementsRange(stats, start, end) {\n return (\n (start > stats.min && start < stats.max) ||\n (end > stats.min && end < stats.max)\n );\n}\n\nfunction itemHasRefinement(attribute, results, value) {\n const stats = results.getFacetByName(attribute)\n ? results.getFacetStats(attribute)\n : null;\n const range = value.split(':');\n const start =\n Number(range[0]) === 0 || value === ''\n ? Number.NEGATIVE_INFINITY\n : Number(range[0]);\n const end =\n Number(range[1]) === 0 || value === ''\n ? Number.POSITIVE_INFINITY\n : Number(range[1]);\n return !(\n Boolean(stats) &&\n (isRefinementsRangeIncludesInsideItemRange(stats, start, end) ||\n isItemRangeIncludedInsideRefinementsRange(stats, start, end))\n );\n}\n\nfunction refine(props, searchState, nextRefinement, context) {\n const nextValue = { [getId(props, searchState)]: nextRefinement };\n const resetPage = true;\n return refineValue(searchState, nextValue, context, resetPage, namespace);\n}\n\nfunction cleanUp(props, searchState, context) {\n return cleanUpValue(searchState, context, `${namespace}.${getId(props)}`);\n}\n\n/**\n * connectNumericMenu connector provides the logic to build a widget that will\n * give the user the ability to select a range value for a numeric attribute.\n * Ranges are defined statically.\n * @name connectNumericMenu\n * @requirements The attribute passed to the `attribute` prop must be holding numerical values.\n * @kind connector\n * @propType {string} attribute - the name of the attribute in the records\n * @propType {{label: string, start: number, end: number}[]} items - List of options. With a text label, and upper and lower bounds.\n * @propType {string} [defaultRefinement] - the value of the item selected by default, follow the shape of a `string` with a pattern of `'{start}:{end}'`.\n * @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.\n * @providedPropType {function} refine - a function to select a range.\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n * @providedPropType {string} currentRefinement - the refinement currently applied. follow the shape of a `string` with a pattern of `'{start}:{end}'` which corresponds to the current selected item. For instance, when the selected item is `{start: 10, end: 20}`, the searchState of the widget is `'10:20'`. When `start` isn't defined, the searchState of the widget is `':{end}'`, and the same way around when `end` isn't defined. However, when neither `start` nor `end` are defined, the searchState is an empty string.\n * @providedPropType {array.<{isRefined: boolean, label: string, value: string, isRefined: boolean, noRefinement: boolean}>} items - the list of ranges the NumericMenu can display.\n */\nexport default createConnector({\n displayName: 'AlgoliaNumericMenu',\n\n propTypes: {\n id: PropTypes.string,\n attribute: PropTypes.string.isRequired,\n items: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.node,\n start: PropTypes.number,\n end: PropTypes.number,\n })\n ).isRequired,\n transformItems: PropTypes.func,\n },\n\n getProvidedProps(props, searchState, searchResults) {\n const attribute = props.attribute;\n const currentRefinement = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n const items = props.items.map(item => {\n const value = stringifyItem(item);\n return {\n label: item.label,\n value,\n isRefined: value === currentRefinement,\n noRefinement: results\n ? itemHasRefinement(getId(props), results, value)\n : false,\n };\n });\n\n const stats =\n results && results.getFacetByName(attribute)\n ? results.getFacetStats(attribute)\n : null;\n const refinedItem = find(items, item => item.isRefined === true);\n if (!items.some(item => item.value === '')) {\n items.push({\n value: '',\n isRefined: refinedItem === undefined,\n noRefinement: !stats,\n label: 'All',\n });\n }\n\n const transformedItems = props.transformItems\n ? props.transformItems(items)\n : items;\n\n return {\n items: transformedItems,\n currentRefinement,\n canRefine:\n transformedItems.length > 0 &&\n transformedItems.some(item => item.noRefinement === false),\n };\n },\n\n refine(props, searchState, nextRefinement) {\n return refine(props, searchState, nextRefinement, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n cleanUp(props, searchState) {\n return cleanUp(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n const { attribute } = props;\n const { start, end } = parseItem(\n getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n })\n );\n searchParameters = searchParameters.addDisjunctiveFacet(attribute);\n\n if (typeof start === 'number') {\n searchParameters = searchParameters.addNumericRefinement(\n attribute,\n '>=',\n start\n );\n }\n if (typeof end === 'number') {\n searchParameters = searchParameters.addNumericRefinement(\n attribute,\n '<=',\n end\n );\n }\n return searchParameters;\n },\n\n getMetadata(props, searchState) {\n const id = getId(props);\n const value = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n const items = [];\n const index = getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n if (value !== '') {\n const { label } = find(\n props.items,\n item => stringifyItem(item) === value\n );\n items.push({\n label: `${props.attribute}: ${label}`,\n attribute: props.attribute,\n currentRefinement: label,\n value: nextState =>\n refine(props, nextState, '', {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n });\n }\n return { id, index, items };\n },\n});\n","import createConnector from '../core/createConnector';\nimport {\n cleanUpValue,\n refineValue,\n getCurrentRefinementValue,\n getResults,\n} from '../core/indexUtils';\n\nfunction getId() {\n return 'page';\n}\n\nfunction getCurrentRefinement(props, searchState, context) {\n const id = getId();\n const page = 1;\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n id,\n page\n );\n\n if (typeof currentRefinement === 'string') {\n return parseInt(currentRefinement, 10);\n }\n return currentRefinement;\n}\n\nfunction refine(props, searchState, nextPage, context) {\n const id = getId();\n const nextValue = { [id]: nextPage };\n const resetPage = false;\n return refineValue(searchState, nextValue, context, resetPage);\n}\n\n/**\n * connectPagination connector provides the logic to build a widget that will\n * let the user displays hits corresponding to a certain page.\n * @name connectPagination\n * @kind connector\n * @propType {boolean} [showFirst=true] - Display the first page link.\n * @propType {boolean} [showLast=false] - Display the last page link.\n * @propType {boolean} [showPrevious=true] - Display the previous page link.\n * @propType {boolean} [showNext=true] - Display the next page link.\n * @propType {number} [padding=3] - How many page links to display around the current page.\n * @propType {number} [totalPages=Infinity] - Maximum number of pages to display.\n * @providedPropType {function} refine - a function to remove a single filter\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n * @providedPropType {number} nbPages - the total of existing pages\n * @providedPropType {number} currentRefinement - the page refinement currently applied\n */\nexport default createConnector({\n displayName: 'AlgoliaPagination',\n\n getProvidedProps(props, searchState, searchResults) {\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n if (!results) {\n return null;\n }\n\n const nbPages = results.nbPages;\n return {\n nbPages,\n currentRefinement: getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n canRefine: nbPages > 1,\n };\n },\n\n refine(props, searchState, nextPage) {\n return refine(props, searchState, nextPage, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n cleanUp(props, searchState) {\n return cleanUpValue(\n searchState,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue },\n getId()\n );\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n return searchParameters.setPage(\n getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }) - 1\n );\n },\n\n getMetadata() {\n return { id: getId() };\n },\n});\n","import createConnector from '../core/createConnector';\n\n/**\n * connectPoweredBy connector provides the logic to build a widget that\n * will display a link to algolia.\n * @name connectPoweredBy\n * @kind connector\n * @providedPropType {string} url - the url to redirect to algolia\n */\nexport default createConnector({\n displayName: 'AlgoliaPoweredBy',\n\n getProvidedProps() {\n const hostname =\n typeof window === 'undefined' ? '' : window.location.hostname;\n\n const url =\n 'https://www.algolia.com/?' +\n 'utm_source=react-instantsearch&' +\n 'utm_medium=website&' +\n `utm_content=${hostname}&` +\n 'utm_campaign=poweredby';\n\n return {\n url,\n };\n },\n});\n","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport {\n cleanUpValue,\n getIndexId,\n refineValue,\n getCurrentRefinementValue,\n getResults,\n} from '../core/indexUtils';\n\n/**\n * connectRange connector provides the logic to create connected\n * components that will give the ability for a user to refine results using\n * a numeric range.\n * @name connectRange\n * @kind connector\n * @requirements The attribute passed to the `attribute` prop must be present in “attributes for faceting”\n * on the Algolia dashboard or configured as `attributesForFaceting` via a set settings call to the Algolia API.\n * The values inside the attribute must be JavaScript numbers (not strings).\n * @propType {string} attribute - Name of the attribute for faceting\n * @propType {{min?: number, max?: number}} [defaultRefinement] - Default searchState of the widget containing the start and the end of the range.\n * @propType {number} [min] - Minimum value. When this isn't set, the minimum value will be automatically computed by Algolia using the data in the index.\n * @propType {number} [max] - Maximum value. When this isn't set, the maximum value will be automatically computed by Algolia using the data in the index.\n * @propType {number} [precision=0] - Number of digits after decimal point to use.\n * @providedPropType {function} refine - a function to select a range.\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n * @providedPropType {string} currentRefinement - the refinement currently applied\n * @providedPropType {number} min - the minimum value available.\n * @providedPropType {number} max - the maximum value available.\n * @providedPropType {number} precision - Number of digits after decimal point to use.\n */\n\nfunction getId(props) {\n return props.attribute;\n}\n\nconst namespace = 'range';\n\nfunction getCurrentRange(boundaries, stats, precision) {\n const pow = Math.pow(10, precision);\n\n let min;\n if (typeof boundaries.min === 'number' && isFinite(boundaries.min)) {\n min = boundaries.min;\n } else if (typeof stats.min === 'number' && isFinite(stats.min)) {\n min = stats.min;\n } else {\n min = undefined;\n }\n\n let max;\n if (typeof boundaries.max === 'number' && isFinite(boundaries.max)) {\n max = boundaries.max;\n } else if (typeof stats.max === 'number' && isFinite(stats.max)) {\n max = stats.max;\n } else {\n max = undefined;\n }\n\n return {\n min: min !== undefined ? Math.floor(min * pow) / pow : min,\n max: max !== undefined ? Math.ceil(max * pow) / pow : max,\n };\n}\n\nfunction getCurrentRefinement(props, searchState, currentRange, context) {\n const { min, max } = getCurrentRefinementValue(\n props,\n searchState,\n context,\n `${namespace}.${getId(props)}`,\n {}\n );\n\n const isFloatPrecision = Boolean(props.precision);\n\n let nextMin = min;\n if (typeof nextMin === 'string') {\n nextMin = isFloatPrecision ? parseFloat(nextMin) : parseInt(nextMin, 10);\n }\n\n let nextMax = max;\n if (typeof nextMax === 'string') {\n nextMax = isFloatPrecision ? parseFloat(nextMax) : parseInt(nextMax, 10);\n }\n\n const refinement = {\n min: nextMin,\n max: nextMax,\n };\n\n const hasMinBound = props.min !== undefined;\n const hasMaxBound = props.max !== undefined;\n\n const hasMinRefinment = refinement.min !== undefined;\n const hasMaxRefinment = refinement.max !== undefined;\n\n if (hasMinBound && hasMinRefinment && refinement.min < currentRange.min) {\n throw Error(\"You can't provide min value lower than range.\");\n }\n\n if (hasMaxBound && hasMaxRefinment && refinement.max > currentRange.max) {\n throw Error(\"You can't provide max value greater than range.\");\n }\n\n if (hasMinBound && !hasMinRefinment) {\n refinement.min = currentRange.min;\n }\n\n if (hasMaxBound && !hasMaxRefinment) {\n refinement.max = currentRange.max;\n }\n\n return refinement;\n}\n\nfunction getCurrentRefinementWithRange(refinement, range) {\n return {\n min: refinement.min !== undefined ? refinement.min : range.min,\n max: refinement.max !== undefined ? refinement.max : range.max,\n };\n}\n\nfunction nextValueForRefinement(hasBound, isReset, range, value) {\n let next;\n if (!hasBound && range === value) {\n next = undefined;\n } else if (hasBound && isReset) {\n next = range;\n } else {\n next = value;\n }\n\n return next;\n}\n\nfunction refine(props, searchState, nextRefinement, currentRange, context) {\n const { min: nextMin, max: nextMax } = nextRefinement;\n const { min: currentMinRange, max: currentMaxRange } = currentRange;\n\n const isMinReset = nextMin === undefined || nextMin === '';\n const isMaxReset = nextMax === undefined || nextMax === '';\n\n const nextMinAsNumber = !isMinReset ? parseFloat(nextMin) : undefined;\n const nextMaxAsNumber = !isMaxReset ? parseFloat(nextMax) : undefined;\n\n const isNextMinValid = isMinReset || isFinite(nextMinAsNumber);\n const isNextMaxValid = isMaxReset || isFinite(nextMaxAsNumber);\n\n if (!isNextMinValid || !isNextMaxValid) {\n throw Error(\"You can't provide non finite values to the range connector.\");\n }\n\n if (nextMinAsNumber < currentMinRange) {\n throw Error(\"You can't provide min value lower than range.\");\n }\n\n if (nextMaxAsNumber > currentMaxRange) {\n throw Error(\"You can't provide max value greater than range.\");\n }\n\n const id = getId(props);\n const resetPage = true;\n const nextValue = {\n [id]: {\n min: nextValueForRefinement(\n props.min !== undefined,\n isMinReset,\n currentMinRange,\n nextMinAsNumber\n ),\n max: nextValueForRefinement(\n props.max !== undefined,\n isMaxReset,\n currentMaxRange,\n nextMaxAsNumber\n ),\n },\n };\n\n return refineValue(searchState, nextValue, context, resetPage, namespace);\n}\n\nfunction cleanUp(props, searchState, context) {\n return cleanUpValue(searchState, context, `${namespace}.${getId(props)}`);\n}\n\nexport default createConnector({\n displayName: 'AlgoliaRange',\n\n propTypes: {\n id: PropTypes.string,\n attribute: PropTypes.string.isRequired,\n defaultRefinement: PropTypes.shape({\n min: PropTypes.number,\n max: PropTypes.number,\n }),\n min: PropTypes.number,\n max: PropTypes.number,\n precision: PropTypes.number,\n header: PropTypes.node,\n footer: PropTypes.node,\n },\n\n defaultProps: {\n precision: 0,\n },\n\n getProvidedProps(props, searchState, searchResults) {\n const { attribute, precision, min: minBound, max: maxBound } = props;\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n const hasFacet = results && results.getFacetByName(attribute);\n const stats = hasFacet ? results.getFacetStats(attribute) || {} : {};\n const facetValues = hasFacet ? results.getFacetValues(attribute) : [];\n\n const count = facetValues.map(v => ({\n value: v.name,\n count: v.count,\n }));\n\n const { min: rangeMin, max: rangeMax } = getCurrentRange(\n { min: minBound, max: maxBound },\n stats,\n precision\n );\n\n // The searchState is not always in sync with the helper state. For example\n // when we set boundaries on the first render the searchState don't have\n // the correct refinement. If this behavior change in the upcoming version\n // we could store the range inside the searchState instead of rely on `this`.\n this._currentRange = {\n min: rangeMin,\n max: rangeMax,\n };\n\n const currentRefinement = getCurrentRefinement(\n props,\n searchState,\n this._currentRange,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue }\n );\n\n return {\n min: rangeMin,\n max: rangeMax,\n canRefine: count.length > 0,\n currentRefinement: getCurrentRefinementWithRange(\n currentRefinement,\n this._currentRange\n ),\n count,\n precision,\n };\n },\n\n refine(props, searchState, nextRefinement) {\n return refine(props, searchState, nextRefinement, this._currentRange, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n cleanUp(props, searchState) {\n return cleanUp(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n getSearchParameters(params, props, searchState) {\n const { attribute } = props;\n const { min, max } = getCurrentRefinement(\n props,\n searchState,\n this._currentRange,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue }\n );\n\n params = params.addDisjunctiveFacet(attribute);\n\n if (min !== undefined) {\n params = params.addNumericRefinement(attribute, '>=', min);\n }\n\n if (max !== undefined) {\n params = params.addNumericRefinement(attribute, '<=', max);\n }\n\n return params;\n },\n\n getMetadata(props, searchState) {\n const { min: minRange, max: maxRange } = this._currentRange;\n const { min: minValue, max: maxValue } = getCurrentRefinement(\n props,\n searchState,\n this._currentRange,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue }\n );\n\n const items = [];\n const hasMin = minValue !== undefined;\n const hasMax = maxValue !== undefined;\n const shouldDisplayMinLabel = hasMin && minValue !== minRange;\n const shouldDisplayMaxLabel = hasMax && maxValue !== maxRange;\n\n if (shouldDisplayMinLabel || shouldDisplayMaxLabel) {\n const fragments = [\n hasMin ? `${minValue} <= ` : '',\n props.attribute,\n hasMax ? ` <= ${maxValue}` : '',\n ];\n\n items.push({\n label: fragments.join(''),\n attribute: props.attribute,\n value: nextState =>\n refine(props, nextState, {}, this._currentRange, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n currentRefinement: getCurrentRefinementWithRange(\n { min: minValue, max: maxValue },\n { min: minRange, max: maxRange }\n ),\n });\n }\n\n return {\n id: getId(props),\n index: getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n items,\n };\n },\n});\n","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport {\n cleanUpValue,\n getIndexId,\n refineValue,\n getCurrentRefinementValue,\n getResults,\n} from '../core/indexUtils';\n\nconst namespace = 'refinementList';\n\nfunction getId(props) {\n return props.attribute;\n}\n\nfunction getCurrentRefinement(props, searchState, context) {\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n `${namespace}.${getId(props)}`,\n []\n );\n\n if (typeof currentRefinement !== 'string') {\n return currentRefinement;\n }\n\n if (currentRefinement) {\n return [currentRefinement];\n }\n\n return [];\n}\n\nfunction getValue(name, props, searchState, context) {\n const currentRefinement = getCurrentRefinement(props, searchState, context);\n const isAnewValue = currentRefinement.indexOf(name) === -1;\n const nextRefinement = isAnewValue\n ? currentRefinement.concat([name]) // cannot use .push(), it mutates\n : currentRefinement.filter(selectedValue => selectedValue !== name); // cannot use .splice(), it mutates\n return nextRefinement;\n}\n\nfunction getLimit({ showMore, limit, showMoreLimit }) {\n return showMore ? showMoreLimit : limit;\n}\n\nfunction refine(props, searchState, nextRefinement, context) {\n const id = getId(props);\n // Setting the value to an empty string ensures that it is persisted in\n // the URL as an empty value.\n // This is necessary in the case where `defaultRefinement` contains one\n // item and we try to deselect it. `nextSelected` would be an empty array,\n // which would not be persisted to the URL.\n // {foo: ['bar']} => \"foo[0]=bar\"\n // {foo: []} => \"\"\n const nextValue = { [id]: nextRefinement.length > 0 ? nextRefinement : '' };\n const resetPage = true;\n return refineValue(searchState, nextValue, context, resetPage, namespace);\n}\n\nfunction cleanUp(props, searchState, context) {\n return cleanUpValue(searchState, context, `${namespace}.${getId(props)}`);\n}\n/**\n * connectRefinementList connector provides the logic to build a widget that will\n * give the user the ability to choose multiple values for a specific facet.\n * @name connectRefinementList\n * @kind connector\n * @requirements The attribute passed to the `attribute` prop must be present in \"attributes for faceting\"\n * on the Algolia dashboard or configured as `attributesForFaceting` via a set settings call to the Algolia API.\n * @propType {string} attribute - the name of the attribute in the record\n * @propType {boolean} [searchable=false] - allow search inside values\n * @propType {string} [operator=or] - How to apply the refinements. Possible values: 'or' or 'and'.\n * @propType {boolean} [showMore=false] - true if the component should display a button that will expand the number of items\n * @propType {number} [limit=10] - the minimum number of displayed items\n * @propType {number} [showMoreLimit=20] - the maximun number of displayed items. Only used when showMore is set to `true`\n * @propType {string[]} defaultRefinement - the values of the items selected by default. The searchState of this widget takes the form of a list of `string`s, which correspond to the values of all selected refinements. However, when there are no refinements selected, the value of the searchState is an empty string.\n * @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.\n * @providedPropType {function} refine - a function to toggle a refinement\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n * @providedPropType {string[]} currentRefinement - the refinement currently applied\n * @providedPropType {array.<{count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the RefinementList can display.\n * @providedPropType {function} searchForItems - a function to toggle a search inside items values\n * @providedPropType {boolean} isFromSearch - a boolean that says if the `items` props contains facet values from the global search or from the search inside items.\n * @providedPropType {boolean} canRefine - a boolean that says whether you can refine\n */\n\nconst sortBy = ['isRefined', 'count:desc', 'name:asc'];\nexport default createConnector({\n displayName: 'AlgoliaRefinementList',\n\n propTypes: {\n id: PropTypes.string,\n attribute: PropTypes.string.isRequired,\n operator: PropTypes.oneOf(['and', 'or']),\n showMore: PropTypes.bool,\n limit: PropTypes.number,\n showMoreLimit: PropTypes.number,\n defaultRefinement: PropTypes.arrayOf(\n PropTypes.oneOfType([PropTypes.string, PropTypes.number])\n ),\n searchable: PropTypes.bool,\n transformItems: PropTypes.func,\n },\n\n defaultProps: {\n operator: 'or',\n showMore: false,\n limit: 10,\n showMoreLimit: 20,\n },\n\n getProvidedProps(\n props,\n searchState,\n searchResults,\n metadata,\n searchForFacetValuesResults\n ) {\n const { attribute, searchable, indexContextValue } = props;\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n const canRefine =\n Boolean(results) && Boolean(results.getFacetByName(attribute));\n\n const isFromSearch = Boolean(\n searchForFacetValuesResults &&\n searchForFacetValuesResults[attribute] &&\n searchForFacetValuesResults.query !== ''\n );\n\n // Search For Facet Values is not available with derived helper (used for multi index search)\n if (searchable && indexContextValue) {\n throw new Error(\n 'react-instantsearch: searching in *List is not available when used inside a' +\n ' multi index context'\n );\n }\n\n if (!canRefine) {\n return {\n items: [],\n currentRefinement: getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n canRefine,\n isFromSearch,\n searchable,\n };\n }\n\n const items = isFromSearch\n ? searchForFacetValuesResults[attribute].map(v => ({\n label: v.value,\n value: getValue(v.value, props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n _highlightResult: { label: { value: v.highlighted } },\n count: v.count,\n isRefined: v.isRefined,\n }))\n : results.getFacetValues(attribute, { sortBy }).map(v => ({\n label: v.name,\n value: getValue(v.name, props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n count: v.count,\n isRefined: v.isRefined,\n }));\n\n const transformedItems = props.transformItems\n ? props.transformItems(items)\n : items;\n\n return {\n items: transformedItems.slice(0, getLimit(props)),\n currentRefinement: getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n isFromSearch,\n searchable,\n canRefine: transformedItems.length > 0,\n };\n },\n\n refine(props, searchState, nextRefinement) {\n return refine(props, searchState, nextRefinement, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n searchForFacetValues(props, searchState, nextRefinement) {\n return {\n facetName: props.attribute,\n query: nextRefinement,\n maxFacetHits: getLimit(props),\n };\n },\n\n cleanUp(props, searchState) {\n return cleanUp(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n const { attribute, operator } = props;\n\n const addKey = operator === 'and' ? 'addFacet' : 'addDisjunctiveFacet';\n const addRefinementKey = `${addKey}Refinement`;\n\n searchParameters = searchParameters.setQueryParameters({\n maxValuesPerFacet: Math.max(\n searchParameters.maxValuesPerFacet || 0,\n getLimit(props)\n ),\n });\n\n searchParameters = searchParameters[addKey](attribute);\n\n return getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }).reduce(\n (res, val) => res[addRefinementKey](attribute, val),\n searchParameters\n );\n },\n\n getMetadata(props, searchState) {\n const id = getId(props);\n const context = {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n };\n return {\n id,\n index: getIndexId(context),\n items:\n getCurrentRefinement(props, searchState, context).length > 0\n ? [\n {\n attribute: props.attribute,\n label: `${props.attribute}: `,\n currentRefinement: getCurrentRefinement(\n props,\n searchState,\n context\n ),\n value: nextState => refine(props, nextState, [], context),\n items: getCurrentRefinement(props, searchState, context).map(\n item => ({\n label: `${item}`,\n value: nextState => {\n const nextSelectedItems = getCurrentRefinement(\n props,\n nextState,\n context\n ).filter(other => other !== item);\n return refine(\n props,\n searchState,\n nextSelectedItems,\n context\n );\n },\n })\n ),\n },\n ]\n : [],\n };\n },\n});\n","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport {\n getCurrentRefinementValue,\n hasMultipleIndices,\n getIndexId,\n} from '../core/indexUtils';\nimport { shallowEqual, omit } from '../core/utils';\n\n/**\n * connectScrollTo connector provides the logic to build a widget that will\n * let the page scroll to a certain point.\n * @name connectScrollTo\n * @kind connector\n * @propType {string} [scrollOn=\"page\"] - Widget searchState key on which to listen for changes, default to the pagination widget.\n * @providedPropType {any} value - the current refinement applied to the widget listened by scrollTo\n * @providedPropType {boolean} hasNotChanged - indicates whether the refinement came from the scrollOn argument (for instance page by default)\n */\nexport default createConnector({\n displayName: 'AlgoliaScrollTo',\n\n propTypes: {\n scrollOn: PropTypes.string,\n },\n\n defaultProps: {\n scrollOn: 'page',\n },\n\n getProvidedProps(props, searchState) {\n const id = props.scrollOn;\n const value = getCurrentRefinementValue(\n props,\n searchState,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue },\n id,\n null\n );\n\n if (!this._prevSearchState) {\n this._prevSearchState = {};\n }\n\n // Get the subpart of the state that interest us\n if (\n hasMultipleIndices({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n })\n ) {\n searchState = searchState.indices\n ? searchState.indices[\n getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n })\n ]\n : {};\n }\n\n // if there is a change in the app that has been triggered by another element\n // than \"props.scrollOn (id) or the Configure widget, we need to keep track of\n // the search state to know if there's a change in the app that was not triggered\n // by the props.scrollOn (id) or the Configure widget. This is useful when\n // using ScrollTo in combination of Pagination. As pagination can be change\n // by every widget, we want to scroll only if it cames from the pagination\n // widget itself. We also remove the configure key from the search state to\n // do this comparison because for now configure values are not present in the\n // search state before a first refinement has been made and will false the results.\n // See: https://github.com/algolia/react-instantsearch/issues/164\n const cleanedSearchState = omit(searchState, ['configure', id]);\n\n const hasNotChanged = shallowEqual(\n this._prevSearchState,\n cleanedSearchState\n );\n\n this._prevSearchState = cleanedSearchState;\n\n return { value, hasNotChanged };\n },\n});\n","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport {\n cleanUpValue,\n refineValue,\n getCurrentRefinementValue,\n getIndexId,\n} from '../core/indexUtils';\n\nfunction getId() {\n return 'query';\n}\n\nfunction getCurrentRefinement(props, searchState, context) {\n const id = getId(props);\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n id,\n ''\n );\n\n if (currentRefinement) {\n return currentRefinement;\n }\n return '';\n}\n\nfunction refine(props, searchState, nextRefinement, context) {\n const id = getId();\n const nextValue = { [id]: nextRefinement };\n const resetPage = true;\n return refineValue(searchState, nextValue, context, resetPage);\n}\n\nfunction cleanUp(props, searchState, context) {\n return cleanUpValue(searchState, context, getId());\n}\n\n/**\n * connectSearchBox connector provides the logic to build a widget that will\n * let the user search for a query\n * @name connectSearchBox\n * @kind connector\n * @propType {string} [defaultRefinement] - Provide a default value for the query\n * @providedPropType {function} refine - a function to change the current query\n * @providedPropType {string} currentRefinement - the current query used\n * @providedPropType {boolean} isSearchStalled - a flag that indicates if InstantSearch has detected that searches are stalled\n */\nexport default createConnector({\n displayName: 'AlgoliaSearchBox',\n\n propTypes: {\n defaultRefinement: PropTypes.string,\n },\n\n getProvidedProps(props, searchState, searchResults) {\n return {\n currentRefinement: getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n isSearchStalled: searchResults.isSearchStalled,\n };\n },\n\n refine(props, searchState, nextRefinement) {\n return refine(props, searchState, nextRefinement, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n cleanUp(props, searchState) {\n return cleanUp(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n return searchParameters.setQuery(\n getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n })\n );\n },\n\n getMetadata(props, searchState) {\n const id = getId(props);\n const currentRefinement = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n return {\n id,\n index: getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n items:\n currentRefinement === null\n ? []\n : [\n {\n label: `${id}: ${currentRefinement}`,\n value: nextState =>\n refine(props, nextState, '', {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n currentRefinement,\n },\n ],\n };\n },\n});\n","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport {\n cleanUpValue,\n refineValue,\n getCurrentRefinementValue,\n} from '../core/indexUtils';\n\nfunction getId() {\n return 'sortBy';\n}\n\nfunction getCurrentRefinement(props, searchState, context) {\n const id = getId(props);\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n id,\n null\n );\n\n if (currentRefinement) {\n return currentRefinement;\n }\n return null;\n}\n\n/**\n * The connectSortBy connector provides the logic to build a widget that will\n * display a list of indices. This allows a user to change how the hits are being sorted.\n * @name connectSortBy\n * @requirements Algolia handles sorting by creating replica indices. [Read more about sorting](https://www.algolia.com/doc/guides/relevance/sorting/) on\n * the Algolia website.\n * @kind connector\n * @propType {string} defaultRefinement - The default selected index.\n * @propType {{value: string, label: string}[]} items - The list of indexes to search in.\n * @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.\n * @providedPropType {function} refine - a function to remove a single filter\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n * @providedPropType {string[]} currentRefinement - the refinement currently applied\n * @providedPropType {array.<{isRefined: boolean, label?: string, value: string}>} items - the list of items the HitsPerPage can display. If no label provided, the value will be displayed.\n */\nexport default createConnector({\n displayName: 'AlgoliaSortBy',\n\n propTypes: {\n defaultRefinement: PropTypes.string,\n items: PropTypes.arrayOf(\n PropTypes.shape({\n label: PropTypes.string,\n value: PropTypes.string.isRequired,\n })\n ).isRequired,\n transformItems: PropTypes.func,\n },\n\n getProvidedProps(props, searchState) {\n const currentRefinement = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n const items = props.items.map(item =>\n item.value === currentRefinement\n ? { ...item, isRefined: true }\n : { ...item, isRefined: false }\n );\n return {\n items: props.transformItems ? props.transformItems(items) : items,\n currentRefinement,\n };\n },\n\n refine(props, searchState, nextRefinement) {\n const id = getId();\n const nextValue = { [id]: nextRefinement };\n const resetPage = true;\n return refineValue(\n searchState,\n nextValue,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue },\n resetPage\n );\n },\n\n cleanUp(props, searchState) {\n return cleanUpValue(\n searchState,\n { ais: props.contextValue, multiIndexContext: props.indexContextValue },\n getId()\n );\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n const selectedIndex = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n return searchParameters.setIndex(selectedIndex);\n },\n\n getMetadata() {\n return { id: getId() };\n },\n});\n","import createConnector from '../core/createConnector';\nimport { getResults } from '../core/indexUtils';\n\n/**\n * The `connectStateResults` connector provides a way to access the `searchState` and the `searchResults`\n * of InstantSearch.\n * For instance this connector allows you to create results/noResults or query/noQuery pages.\n * @name connectStateResults\n * @kind connector\n * @providedPropType {object} searchState - The search state of the instant search component.

See: [Search state structure](https://community.algolia.com/react-instantsearch/guide/Search_state.html)\n * @providedPropType {object} searchResults - The search results.

In case of multiple indices: if used under ``, results will be those of the corresponding index otherwise it'll be those of the root index See: [Search results structure](https://community.algolia.com/algoliasearch-helper-js/reference.html#searchresults)\n * @providedPropType {object} allSearchResults - In case of multiple indices you can retrieve all the results\n * @providedPropType {string} error - If the search failed, the error will be logged here.\n * @providedPropType {boolean} searching - If there is a search in progress.\n * @providedPropType {boolean} isSearchStalled - Flag that indicates if React InstantSearch has detected that searches are stalled.\n * @providedPropType {boolean} searchingForFacetValues - If there is a search in a list in progress.\n * @providedPropType {object} props - component props.\n * @example\n * import React from 'react';\n * import algoliasearch from 'algoliasearch/lite';\n * import { InstantSearch, SearchBox, Hits, connectStateResults } from 'react-instantsearch-dom';\n *\n * const searchClient = algoliasearch(\n * 'latency',\n * '6be0576ff61c053d5f9a3225e2a90f76'\n * );\n *\n * const Content = connectStateResults(({ searchState, searchResults }) => {\n * const hasResults = searchResults && searchResults.nbHits !== 0;\n *\n * return (\n *
\n * \n * \n *
\n * );\n * });\n *\n * const App = () => (\n * \n * \n * \n * \n * );\n */\nexport default createConnector({\n displayName: 'AlgoliaStateResults',\n\n getProvidedProps(props, searchState, searchResults) {\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n return {\n searchState,\n searchResults: results,\n allSearchResults: searchResults.results,\n searching: searchResults.searching,\n isSearchStalled: searchResults.isSearchStalled,\n error: searchResults.error,\n searchingForFacetValues: searchResults.searchingForFacetValues,\n props,\n };\n },\n});\n","import createConnector from '../core/createConnector';\nimport { getResults } from '../core/indexUtils';\n\n/**\n * connectStats connector provides the logic to build a widget that will\n * displays algolia search statistics (hits number and processing time).\n * @name connectStats\n * @kind connector\n * @providedPropType {number} nbHits - number of hits returned by Algolia.\n * @providedPropType {number} processingTimeMS - the time in ms took by Algolia to search for results.\n */\nexport default createConnector({\n displayName: 'AlgoliaStats',\n\n getProvidedProps(props, searchState, searchResults) {\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n if (!results) {\n return null;\n }\n return {\n nbHits: results.nbHits,\n processingTimeMS: results.processingTimeMS,\n };\n },\n});\n","import PropTypes from 'prop-types';\nimport { find } from '../core/utils';\nimport createConnector from '../core/createConnector';\nimport {\n cleanUpValue,\n getIndexId,\n getResults,\n refineValue,\n getCurrentRefinementValue,\n} from '../core/indexUtils';\n\nfunction getId(props) {\n return props.attribute;\n}\n\nconst namespace = 'toggle';\n\nconst falsyStrings = ['0', 'false', 'null', 'undefined'];\n\nfunction getCurrentRefinement(props, searchState, context) {\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n `${namespace}.${getId(props)}`,\n false\n );\n\n if (falsyStrings.indexOf(currentRefinement) !== -1) {\n return false;\n }\n\n return Boolean(currentRefinement);\n}\n\nfunction refine(props, searchState, nextRefinement, context) {\n const id = getId(props);\n const nextValue = { [id]: nextRefinement ? nextRefinement : false };\n const resetPage = true;\n return refineValue(searchState, nextValue, context, resetPage, namespace);\n}\n\nfunction cleanUp(props, searchState, context) {\n return cleanUpValue(searchState, context, `${namespace}.${getId(props)}`);\n}\n\n/**\n * connectToggleRefinement connector provides the logic to build a widget that will\n * provides an on/off filtering feature based on an attribute value.\n * @name connectToggleRefinement\n * @kind connector\n * @requirements To use this widget, you'll need an attribute to toggle on.\n *\n * You can't toggle on null or not-null values. If you want to address this particular use-case you'll need to compute an\n * extra boolean attribute saying if the value exists or not. See this [thread](https://discourse.algolia.com/t/how-to-create-a-toggle-for-the-absence-of-a-string-attribute/2460) for more details.\n *\n * @propType {string} attribute - Name of the attribute on which to apply the `value` refinement. Required when `value` is present.\n * @propType {string} label - Label for the toggle.\n * @propType {string} value - Value of the refinement to apply on `attribute`.\n * @propType {boolean} [defaultRefinement=false] - Default searchState of the widget. Should the toggle be checked by default?\n * @providedPropType {boolean} currentRefinement - `true` when the refinement is applied, `false` otherwise\n * @providedPropType {object} count - an object that contains the count for `checked` and `unchecked` state\n * @providedPropType {function} refine - a function to toggle a refinement\n * @providedPropType {function} createURL - a function to generate a URL for the corresponding search state\n */\nexport default createConnector({\n displayName: 'AlgoliaToggle',\n\n propTypes: {\n label: PropTypes.string.isRequired,\n attribute: PropTypes.string.isRequired,\n value: PropTypes.any.isRequired,\n filter: PropTypes.func,\n defaultRefinement: PropTypes.bool,\n },\n\n getProvidedProps(props, searchState, searchResults) {\n const { attribute, value } = props;\n const results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n const currentRefinement = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n const allFacetValues =\n results && results.getFacetByName(attribute)\n ? results.getFacetValues(attribute)\n : null;\n\n const facetValue =\n // Use null to always be consistent with type of the value\n // count: number | null\n allFacetValues && allFacetValues.length\n ? find(allFacetValues, item => item.name === value.toString())\n : null;\n\n const facetValueCount = facetValue && facetValue.count;\n const allFacetValuesCount =\n // Use null to always be consistent with type of the value\n // count: number | null\n allFacetValues && allFacetValues.length\n ? allFacetValues.reduce((acc, item) => acc + item.count, 0)\n : null;\n\n const canRefine = currentRefinement\n ? allFacetValuesCount !== null && allFacetValuesCount > 0\n : facetValueCount !== null && facetValueCount > 0;\n\n const count = {\n checked: allFacetValuesCount,\n unchecked: facetValueCount,\n };\n\n return {\n currentRefinement,\n canRefine,\n count,\n };\n },\n\n refine(props, searchState, nextRefinement) {\n return refine(props, searchState, nextRefinement, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n cleanUp(props, searchState) {\n return cleanUp(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n const { attribute, value, filter } = props;\n const checked = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n let nextSearchParameters = searchParameters.addDisjunctiveFacet(attribute);\n\n if (checked) {\n nextSearchParameters = nextSearchParameters.addDisjunctiveFacetRefinement(\n attribute,\n value\n );\n\n if (filter) {\n nextSearchParameters = filter(nextSearchParameters);\n }\n }\n\n return nextSearchParameters;\n },\n\n getMetadata(props, searchState) {\n const id = getId(props);\n const checked = getCurrentRefinement(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n const items = [];\n const index = getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n if (checked) {\n items.push({\n label: props.label,\n currentRefinement: checked,\n attribute: props.attribute,\n value: nextState =>\n refine(props, nextState, false, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n });\n }\n\n return { id, index, items };\n },\n});\n","import createConnector from '../core/createConnector';\nimport { getResults } from '../core/indexUtils';\n\ntype Results = { index: string };\ntype Hit = { objectID: string; __position: number; __queryID: string };\n\ntype InsightsClient = (\n method: InsightsClientMethod,\n payload: InsightsClientPayload\n) => void;\n\ntype InsightsClientMethod =\n | 'clickedObjectIDsAfterSearch'\n | 'convertedObjectIDsAfterSearch';\n\ntype InsightsClientPayload = {\n index: string;\n queryID: string;\n eventName: string;\n objectIDs: string[];\n positions?: number[];\n};\n\nfunction inferPayload({\n method,\n results,\n currentHit,\n}: {\n method: InsightsClientMethod;\n results: Results;\n currentHit: Hit;\n}): Omit {\n const { index } = results;\n const queryID = currentHit.__queryID;\n const objectIDs = [currentHit.objectID];\n\n if (!queryID) {\n throw new Error(`Could not infer \\`queryID\\`. Ensure \\`clickAnalytics: true\\` was added with the Configure widget.\nSee: https://alg.li/VpPpLt`);\n }\n\n switch (method) {\n case 'clickedObjectIDsAfterSearch': {\n const positions = [currentHit.__position];\n return { index, queryID, objectIDs, positions };\n }\n\n case 'convertedObjectIDsAfterSearch':\n return { index, queryID, objectIDs };\n\n default:\n throw new Error(\n `Unsupported method \"${method}\" passed to the insights function. The supported methods are: \"clickedObjectIDsAfterSearch\", \"convertedObjectIDsAfterSearch\".`\n );\n }\n}\n\nconst wrapInsightsClient = (\n aa: InsightsClient,\n results: Results,\n currentHit: Hit\n) => (\n method: InsightsClientMethod,\n payload: Partial\n) => {\n if (typeof aa !== 'function') {\n throw new TypeError(`Expected insightsClient to be a Function`);\n }\n const inferredPayload = inferPayload({ method, results, currentHit });\n aa(method, { ...inferredPayload, ...payload } as any);\n};\n\nexport default (insightsClient: InsightsClient) =>\n createConnector({\n displayName: 'AlgoliaInsights',\n\n getProvidedProps(props, _, searchResults) {\n const results: Results = getResults(searchResults, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n\n const insights = wrapInsightsClient(insightsClient, results, props.hit);\n return { insights };\n },\n });\n","import PropTypes from 'prop-types';\nimport createConnector from '../core/createConnector';\nimport {\n cleanUpValue,\n refineValue,\n getCurrentRefinementValue,\n getIndexId,\n} from '../core/indexUtils';\n\nfunction getId() {\n return 'query';\n}\n\nfunction getAdditionalId() {\n return 'additionalVoiceParameters';\n}\n\nfunction getCurrentRefinementQuery(props, searchState, context) {\n const id = getId();\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n id,\n ''\n );\n\n if (currentRefinement) {\n return currentRefinement;\n }\n return '';\n}\n\nfunction getCurrentRefinementAdditional(props, searchState, context) {\n const id = getAdditionalId();\n const currentRefinement = getCurrentRefinementValue(\n props,\n searchState,\n context,\n id,\n ''\n );\n\n if (currentRefinement) {\n return currentRefinement;\n }\n return {};\n}\n\nfunction refine(props, searchState, nextRefinement, context) {\n const id = getId();\n const voiceParams = getAdditionalId();\n const queryLanguages = props.language\n ? { queryLanguages: [props.language.split('-')[0]] }\n : {};\n const additionalQueryParameters =\n typeof props.additionalQueryParameters === 'function'\n ? {\n ignorePlurals: true,\n removeStopWords: true,\n optionalWords: nextRefinement,\n ...props.additionalQueryParameters({ query: nextRefinement }),\n }\n : {};\n const nextValue = {\n [id]: nextRefinement,\n [voiceParams]: {\n ...queryLanguages,\n ...additionalQueryParameters,\n },\n };\n const resetPage = true;\n return refineValue(searchState, nextValue, context, resetPage);\n}\n\nfunction cleanUp(props, searchState, context) {\n const interimState = cleanUpValue(searchState, context, getId());\n return cleanUpValue(interimState, context, getAdditionalId());\n}\n\nexport default createConnector({\n displayName: 'AlgoliaVoiceSearch',\n\n propTypes: {\n defaultRefinement: PropTypes.string,\n },\n\n getProvidedProps(props, searchState, searchResults) {\n return {\n currentRefinement: getCurrentRefinementQuery(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n isSearchStalled: searchResults.isSearchStalled,\n };\n },\n\n refine(props, searchState, nextRefinement) {\n return refine(props, searchState, nextRefinement, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n cleanUp(props, searchState) {\n return cleanUp(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n },\n\n getSearchParameters(searchParameters, props, searchState) {\n const query = getCurrentRefinementQuery(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n const additionalParams = getCurrentRefinementAdditional(\n props,\n searchState,\n {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }\n );\n\n return searchParameters\n .setQuery(query)\n .setQueryParameters(additionalParams);\n },\n\n getMetadata(props, searchState) {\n const id = getId();\n const currentRefinement = getCurrentRefinementQuery(props, searchState, {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n });\n return {\n id,\n index: getIndexId({\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n items:\n currentRefinement === null\n ? []\n : [\n {\n label: `${id}: ${currentRefinement}`,\n value: nextState =>\n refine(props, nextState, '', {\n ais: props.contextValue,\n multiIndexContext: props.indexContextValue,\n }),\n currentRefinement,\n },\n ],\n };\n },\n});\n","import React, { Component } from 'react';\n\nconst withKeysPropType = keys => (props, propName, componentName) => {\n const prop = props[propName];\n if (prop) {\n for (const key of Object.keys(prop)) {\n if (keys.indexOf(key) === -1) {\n return new Error(\n `Unknown \\`${propName}\\` key \\`${key}\\`. Check the render method ` +\n `of \\`${componentName}\\`.`\n );\n }\n }\n }\n return undefined;\n};\n\nexport default function translatable(defaultTranslations) {\n return Composed => {\n class Translatable extends Component {\n translate = (key, ...params) => {\n const { translations } = this.props;\n\n const translation =\n translations && translations.hasOwnProperty(key)\n ? translations[key]\n : defaultTranslations[key];\n\n if (typeof translation === 'function') {\n return translation(...params);\n }\n\n return translation;\n };\n\n render() {\n return ;\n }\n }\n\n const name = Composed.displayName || Composed.name || 'UnknownComponent';\n\n Translatable.displayName = `Translatable(${name})`;\n\n Translatable.propTypes = {\n translations: withKeysPropType(Object.keys(defaultTranslations)),\n };\n\n return Translatable;\n };\n}\n"],"names":["_extends","Object","assign","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","this","_objectWithoutProperties","excluded","sourceKeys","keys","indexOf","objectWithoutPropertiesLoose","getOwnPropertySymbols","sourceSymbolKeys","propertyIsEnumerable","_defineProperty","obj","value","defineProperty","enumerable","configurable","writable","_objectSpread","ownKeys","concat","filter","sym","getOwnPropertyDescriptor","forEach","_classCallCheck","instance","Constructor","TypeError","_defineProperties","props","descriptor","_createClass","protoProps","staticProps","_typeof2","Symbol","iterator","constructor","_typeof","_assertThisInitialized","self","ReferenceError","_possibleConstructorReturn","assertThisInitialized","_getPrototypeOf","o","setPrototypeOf","getPrototypeOf","__proto__","_setPrototypeOf","p","_inherits","subClass","superClass","create","hasElementType","Element","hasMap","Map","hasSet","Set","hasArrayBuffer","ArrayBuffer","a","b","equal","it","Array","isArray","size","entries","next","done","has","get","isView","RegExp","flags","valueOf","toString","$$typeof","error","message","match","console","warn","shallowEqual","objA","objB","keysA","keysB","hasOwn","resolved","Promise","resolve","defer","f","then","removeEmptyKey","objectHasKeys","addAbsolutePositions","hits","hitsPerPage","page","map","hit","index","__position","addQueryID","queryID","__queryID","find","array","comparator","object","omit","createContext","onInternalStateUpdate","createHrefForState","onSearchForFacetValues","onSearchStateChange","onSearchParameters","store","widgetsManager","mainTargetedIndex","InstantSearchConsumer","Consumer","InstantSearchProvider","Provider","undefined","IndexConsumer","IndexProvider","createConnectorWithContext","connectorDesc","Composed","Connector","displayName","Error","isWidget","getSearchParameters","getMetadata","transitionState","Component","providedProps","_this","getProvidedProps","args","contextValue","refine","getState","widgets","searchForFacetValues","bind","ais","multiIndexContext","indexContextValue","unsubscribe","subscribe","_this2","isUnmounting","setState","unregisterWidget","registerWidget","nextProps","nextState","shouldComponentUpdate","state","propsEqual","prevProps","isEqual","update","cleanUp","results","resultsFacetValues","searching","searchingForFacetValues","isSearchStalled","metadata","searchResults","searchParameters","nextWidgetsState","prevWidgetsState","refineProps","createURL","searchForFacetValuesProps","searchForItems","React","name","defaultProps","createConnectorWithoutContext","HIGHLIGHT_TAGS","highlightPreTag","highlightPostTag","parseHighlightedAttribute","preTag","postTag","highlightedValue","splitByPreTag","split","firstValue","shift","elements","isHighlighted","push","splitByPostTag","parseAlgoliaHit","highlightProperty","attribute","path","highlightObject","replace","reduce","current","item","getIndexId","context","hasMultipleIndices","targetedIndex","getResults","indexId","refineValue","searchState","nextRefinement","resetPage","namespace","indices","getNamespaceAndAttributeName","id","parts","attributeName","getCurrentRefinementValue","defaultValue","multiIndex","defaultRefinement","cleanUpValue","Boolean","indexSearchState","cleanUpValueWithMultiIndex","cleanUpValueWithSingleIndex","createConnector","children","items","setQueryParameters","prevSearchState","nextSearchState","propKeys","nonPresentKeys","_props","prop","subState","configureState","acc","connectConfigure","_toConsumableArray","arr","arr2","arrayWithoutHoles","iter","from","iterableToArray","nonIterableSpread","isObjectOrArrayOrFunction","_merge","sourceVal","targetVal","l","slice","reduceRight","arr1","valToNumber","v","parseFloat","lib","addRefinement","refinementList","isRefined","valueAsString","facetRefinement","mod","defaultsPure","removeRefinement","clearRefinement","toggleRefinement","refinementType","hasChanged","newRefinementList","memo","values","facetList","refinementValue","containsRefinements","refinementValueAsString","isEqualNumericRefinement","every","el","SearchParameters","newParameters","params","_parseNumbers","facets","disjunctiveFacets","hierarchicalFacets","facetsRefinements","facetsExcludes","disjunctiveFacetsRefinements","numericRefinements","tagRefinements","hierarchicalFacetsRefinements","paramName","isKeyKnown","PARAMETERS","isValueDefined","partialState","numbers","k","parsedValue","isNaN","insideBoundingBox","geoRect","operators","operator","parsedValues","vPrime","merge","make","facet","rootPath","currentRefinement","getHierarchicalRefinement","clearRefinements","toggleHierarchicalFacetRefinement","validate","currentState","parameters","tagFilters","numericFilters","patch","_clearNumericRefinements","RefinementList","clearTags","setIndex","setQuery","newQuery","query","setPage","newPage","setFacets","setDisjunctiveFacets","setHitsPerPage","n","setTypoTolerance","typoTolerance","addNumericRefinement","isNumericRefined","getConjunctiveRefinements","facetName","isConjunctiveFacet","getDisjunctiveRefinements","isDisjunctiveFacet","getExcludeRefinements","removeNumericRefinement","paramValue","op","val","getNumericRefinements","getNumericRefinement","newNumericRefinements","operatorList","outValues","addFacet","addDisjunctiveFacet","addHierarchicalFacet","hierarchicalFacet","isHierarchicalFacet","addFacetRefinement","addExcludeRefinement","addDisjunctiveFacetRefinement","addTagRefinement","tag","isTagRefined","modification","removeFacet","removeDisjunctiveFacet","removeHierarchicalFacet","removeFacetRefinement","removeExcludeRefinement","removeDisjunctiveFacetRefinement","removeTagRefinement","t","toggleFacetRefinement","toggleConjunctiveFacetRefinement","toggleDisjunctiveFacetRefinement","toggleExcludeFacetRefinement","separator","_getHierarchicalFacetSeparator","getHierarchicalFacetByName","lastIndexOf","addHierarchicalFacetRefinement","isHierarchicalFacetRefined","removeHierarchicalFacetRefinement","toggleTagRefinement","isFacetRefined","isExcludeRefined","isDisjunctiveFacetRefined","refinements","isOperatorDefined","searchedValue","isAttributeValueDefined","currentValue","getRefinedDisjunctiveFacets","disjunctiveNumericRefinedFacets","intersection","getRefinedHierarchicalFacets","getUnrefinedDisjunctiveFacets","refinedFacets","managedParameters","getQueryParams","queryParams","setQueryParameter","parameter","nextWithNumbers","previousPlainObject","nextPlainObject","previous","isPreviousValueDefined","isNextValueDefined","_getHierarchicalFacetSortBy","sortBy","_getHierarchicalRootPath","_getHierarchicalShowParentLevel","showParentLevel","hierarchicalFacetName","getHierarchicalFacetBreadcrumb","refinement","part","trim","JSON","stringify","compareAscending","other","valIsDefined","valIsNull","othIsDefined","othIsNull","collection","iteratees","orders","result","criteria","iteratee","sort","res","defaults","defaultInstructions","out","sortInstruction","matchingDefault","defaultInstruction","hierarchicalFacetResult","hierarchicalFacetIndex","hierarchicalSeparator","hierarchicalRootPath","hierarchicalShowParentLevel","hierarchicalFacetRefinement","prepareHierarchicalFacetSortBy","rootExhaustive","facetResult","exhaustive","generateTreeFn","hierarchicalTree","currentHierarchicalLevel","parent","level","data","subtree","picked","facetValue","tuple","parentPath","orderBy","facetCount","count","getIndices","attributes","idx","assignFacetStats","dest","facetStats","stats","SearchResults","mainSubResponse","_rawResults","parsedQuery","nbHits","nbPages","processingTimeMS","sum","aroundLatLng","automaticRadius","serverUsed","timeoutCounts","timeoutHits","exhaustiveFacetsCount","exhaustiveNbHits","userData","facetsIndices","disjunctiveFacetsIndices","nextDisjunctiveResult","mainFacets","facetKey","hierarchicalAttributeName","facetValueObject","facetIndex","idxAttributeName","findIndex","position","isFacetDisjunctive","isFacetConjunctive","facets_stats","compact","disjunctiveFacet","dfacet","facetResults","attributeIndex","dataFromMainRequest","refinedFacet","defaultData","root","excludes","generateHierarchicalTree","_state","recSort","sortFn","node","childNode","sortedChildren","getFacetStatsIfAvailable","getRefinement","type","resultsFacets","getFacetByName","predicate","DEFAULT_SORT","getFacetValues","opts","facetValues","isExcluded","extractNormalizedFacetValues","options","order","formatSort","hierarchicalFacetValues","getFacetStats","getRefinements","facetDeclaration","rootFacet","intermediateFacet","newFacet","numericValue","EventEmitter","_events","_maxListeners","isFunction","arg","isObject","isUndefined","defaultMaxListeners","setMaxListeners","emit","er","handler","len","listeners","err","on","addListener","listener","m","newListener","warned","trace","once","fired","g","removeListener","list","splice","removeAllListeners","listenerCount","evlistener","emitter","ctor","superCtor","DerivedHelper","mainHelper","fn","main","lastResults","events","detach","detachDerivedHelper","getModifiedState","requestBuilder","_getQueries","queries","indexName","_getHitsSearchParams","_getDisjunctiveFacetSearchParams","_getHitsHierarchicalFacetsAttributes","facetFilters","_getFacetFilters","_getNumericFilters","additionalParams","_getTagFilters","hierarchicalRootLevel","attributesToRetrieve","attributesToHighlight","attributesToSnippet","analytics","clickAnalytics","_getDisjunctiveHierarchicalFacetAttribute","vs","join","orFilters","attributeToRefine","attributesIndex","allAttributes","hierarchicalRefinement","newAttributes","rootLevel","parentLevel","getSearchForFacetQuery","maxFacetHits","stateForSearchForFacetValues","searchForFacetSearchParameters","facetQuery","AlgoliaSearchHelper","client","addAlgoliaAgent","setClient","_queryId","_lastQueryIdReceived","derivedHelpers","_currentNbQueries","setCurrentPage","_change","isPageReset","getCurrentPage","search","_search","onlyWithDerivedHelpers","searchOnlyWithDerivedHelpers","getQuery","searchOnce","cb","tempState","content","_originalResponse","e","catch","userState","clientHasSFFV","initIndex","isDisjunctive","algoliaQuery","facetHits","q","addDisjunctiveRefine","addRefine","addFacetExclusion","addExclude","addTag","removeDisjunctiveRefine","removeRefine","removeFacetExclusion","removeExclude","removeTag","toggleFacetExclusion","toggleExclude","toggleRefine","toggleTag","nextPage","previousPage","newState","overrideStateWithoutTriggeringChangeEvent","hasRefinements","isDisjunctiveRefined","hasTag","hasTagRefinements","getIndex","getPage","getTags","r","states","mainQueries","queriesCount","helper","derivedQueries","derivedHelper","derivedState","derivedStateQueries","queryId","_dispatchAlgoliaResponse","_dispatchAlgoliaError","s","specificResults","formattedResponse","containsRefinement","_hasDisjunctiveRefinements","disjunctiveRefinements","event","clearCache","newClient","getClient","derive","pos","hasPendingRequests","algoliasearchHelper","version","require$$0","createOptionalFilter","attributeValue","attributeScore","getSearchParametersFromProps","optionalFilters","matchingPatterns","attributePattern","score","attributeSubValue","transformSearchParameters","sumOrFiltersScores","objectID","x","_prevSearchState","searchParametersKeys","_searchParameters","global","window","setTimeout","clearTimeout","performance","now","mozNow","msNow","oNow","webkitNow","propIsEnumerable","test1","String","getOwnPropertyNames","test2","fromCharCode","test3","letter","shouldUseNative","emptyFunction","module","shim","propName","componentName","location","propFullName","secret","getShim","ReactPropTypes","isRequired","bool","func","number","string","symbol","any","arrayOf","element","instanceOf","objectOf","oneOf","oneOfType","shape","exact","checkPropTypes","PropTypes","require$$1","ConfigureRelatedItems","propTypes","connectConfigureRelatedItems","widgetKey","widgetState","rangeKey","getWidgetRefinements","transformItems","transformRuleContexts","ruleContexts","trackedFilters","_1","canRefine","transformedItems","newRuleContexts","facetRefinements","trackedFacetValues","getTrackedFacetValues","includes","initialRuleContexts","nextRuleContexts","connectQueryRules","getIndexContext","Index","indexContext","Children","addAlgoliaAgents","searchClient","ReactVersion","isMultiIndexContext","widget","isTargetedIndexEqualIndex","isIndexWidget","isIndexWidgetEqualIndex","sortIndexWidgetsFirst","firstWidget","secondWidget","isFirstWidgetIndex","isSecondWidgetIndex","serializeQueryParameters","format","encodeURIComponent","encode","createInstantSearchManager","initialState","resultsState","stalledSearchDelay","stalledSearchTimer","handleSearchSuccess","handleSearchError","skip","initialSearchParameters","onWidgetsUpdate","scheduled","scheduleUpdate","getWidgets","createWidgetsManager","transporter","_cacheHydrated","_useCache","baseMethod","requests","methodArgs","requestsWithSerializedParams","request","responsesCache","method","set","rawResults","cache","hydrateSearchClientWithMultiIndexRequest","hydrateSearchClientWithSingleIndexRequest","hydrateSearchClient","_internalIndexId","hydrateResultsState","sharedParameters","mainParameters","targetedIndexEqualMainIndex","subIndexEqualMainIndex","derivedIndices","targetedIndexNotEqualMainIndex","subIndexNotEqualMainIndex","derivedParameters","isDerivedHelpersEmpty","nextIsSearchStalled","getWidgetsIds","meta","maxFacetHitsWithinRange","Math","max","min","onExternalStateUpdate","updateClient","updateIndex","newIndex","skipSearch","isControlled","InstantSearch","instantSearchManager","onWidgetsInternalStateUpdate","prevState","nextIsControlled","previousSearchState","prevIsControlled","refresh","getKnownKeys","getCurrentRefinement","getId","some","transformValue","label","clearsQuery","clear","currentRefinementToString","northEast","lat","lng","southWest","latLngRegExp","stringToPosition","pattern","nextValue","currentRefinementFromSearchState","currentRefinementFromSearchParameters","currentPositionFromSearchState","propsWithoutDefaultRefinement","configureAroundLatLng","getCurrentPosition","currentPositionFromSearchParameters","_","_geoloc","isRefinedWithMap","showMore","limit","showMoreLimit","itemsLimit","truncate","maxValuesPerFacet","rootAttribute","highlight","parseInt","getStateWithoutPage","extractHitsFromCachedHits","cachedHits","Number","_prevState","cachedState","read","write","_cachedHits","hasPrevious","hasMore","refinePrevious","refineNext","hitsWithPositionsAndQueryID","firstReceivedPage","lastReceivedPage","pages","getValue","getLimit","defaultSortBy","searchable","searchForFacetValuesResults","isFromSearch","_highlightResult","highlighted","_slicedToArray","arrayWithHoles","_arr","_n","_d","_e","_s","_i","iterableToArrayLimit","nonIterableRest","stringifyItem","start","end","range","noRefinement","NEGATIVE_INFINITY","POSITIVE_INFINITY","refinedItem","startStr","endStr","parseItem","hostname","url","currentRange","isFloatPrecision","precision","nextMin","nextMax","hasMinBound","hasMaxBound","hasMinRefinment","hasMaxRefinment","getCurrentRefinementWithRange","nextValueForRefinement","hasBound","isReset","currentMinRange","currentMaxRange","isMinReset","isMaxReset","nextMinAsNumber","nextMaxAsNumber","isNextMinValid","isFinite","isNextMaxValid","header","footer","boundaries","pow","minBound","maxBound","hasFacet","floor","ceil","rangeMin","rangeMax","_currentRange","minRange","maxRange","minValue","maxValue","hasMin","hasMax","fragments","selectedValue","addKey","addRefinementKey","nextSelectedItems","scrollOn","cleanedSearchState","hasNotChanged","selectedIndex","allSearchResults","falsyStrings","allFacetValues","facetValueCount","allFacetValuesCount","checked","unchecked","nextSearchParameters","wrapInsightsClient","aa","currentHit","payload","inferredPayload","objectIDs","positions","inferPayload","getCurrentRefinementQuery","queryLanguages","language","additionalQueryParameters","ignorePlurals","removeStopWords","optionalWords","inferredIndexId","insightsClient","insights","defaultTranslations","Translatable","translations","translation","translate"],"mappings":";sRAAe,SAASA,IAetB,OAdAA,EAAWC,OAAOC,QAAU,SAAUC,GACpC,IAAK,IAAIC,EAAI,EAAGA,EAAIC,UAAUC,OAAQF,IAAK,CACzC,IAAIG,EAASF,UAAUD,GAEvB,IAAK,IAAII,KAAOD,EACVN,OAAOQ,UAAUC,eAAeC,KAAKJ,EAAQC,KAC/CL,EAAOK,GAAOD,EAAOC,IAK3B,OAAOL,IAGOS,MAAMC,KAAMR,WCdf,SAASS,EAAyBP,EAAQQ,GACvD,GAAc,MAAVR,EAAgB,MAAO,GAC3B,IACIC,EAAKJ,EADLD,ECHS,SAAuCI,EAAQQ,GAC5D,GAAc,MAAVR,EAAgB,MAAO,GAC3B,IAEIC,EAAKJ,EAFLD,EAAS,GACTa,EAAaf,OAAOgB,KAAKV,GAG7B,IAAKH,EAAI,EAAGA,EAAIY,EAAWV,OAAQF,IACjCI,EAAMQ,EAAWZ,GACY,GAAzBW,EAASG,QAAQV,KACrBL,EAAOK,GAAOD,EAAOC,IAGvB,OAAOL,EDTMgB,CAA6BZ,EAAQQ,GAGlD,GAAId,OAAOmB,sBAAuB,CAChC,IAAIC,EAAmBpB,OAAOmB,sBAAsBb,GAEpD,IAAKH,EAAI,EAAGA,EAAIiB,EAAiBf,OAAQF,IACvCI,EAAMa,EAAiBj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