{"version":3,"file":"index.js","sources":["../../src/icons/ControlKeyIcon.tsx","../../src/icons/SearchIcon.tsx","../../src/DocSearchButton.tsx","../../../../node_modules/@algolia/autocomplete-shared/dist/esm/debounce.js","../../../../node_modules/@algolia/autocomplete-shared/dist/esm/flatten.js","../../../../node_modules/@algolia/autocomplete-shared/dist/esm/generateAutocompleteId.js","../../../../node_modules/@algolia/autocomplete-shared/dist/esm/getItemsCount.js","../../../../node_modules/@algolia/autocomplete-shared/dist/esm/isEqual.js","../../../../node_modules/@algolia/autocomplete-shared/dist/esm/noop.js","../../../../node_modules/@algolia/autocomplete-shared/dist/esm/userAgents.js","../../../../node_modules/@algolia/autocomplete-shared/dist/esm/version.js","../../../../node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/createClickedEvent.js","../../../../node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/isModernInsightsClient.js","../../../../node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/createSearchInsightsApi.js","../../../../node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/createViewedEvents.js","../../../../node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/isAlgoliaInsightsHit.js","../../../../node_modules/@algolia/autocomplete-plugin-algolia-insights/dist/esm/createAlgoliaInsightsPlugin.js","../../../../node_modules/@algolia/autocomplete-shared/dist/esm/safelyRunOnBrowser.js","../../../../node_modules/@algolia/autocomplete-shared/dist/esm/createRef.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/utils/createCancelablePromise.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/utils/getNextActiveItemId.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/utils/getNormalizedSources.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/utils/getActiveItem.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/utils/isSamsung.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/createStore.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/utils/createCancelablePromiseList.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/getAutocompleteSetters.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/getDefaultProps.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/reshape.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/resolve.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/utils/mapToAlgoliaResponse.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/onInput.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/utils/createConcurrentSafePromise.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/onKeyDown.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/getPropGetters.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/utils/isOrContainsNode.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/metadata.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/getCompletion.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/stateReducer.js","../../../../node_modules/@algolia/autocomplete-core/dist/esm/createAutocomplete.js","../../src/AlgoliaLogo.tsx","../../src/Footer.tsx","../../src/Hit.tsx","../../src/icons/LoadingIcon.tsx","../../src/icons/RecentIcon.tsx","../../src/icons/ResetIcon.tsx","../../src/icons/SelectIcon.tsx","../../src/icons/SourceIcon.tsx","../../src/icons/StarIcon.tsx","../../src/icons/ErrorIcon.tsx","../../src/icons/NoResultsIcon.tsx","../../src/ErrorScreen.tsx","../../src/NoResultsScreen.tsx","../../src/Snippet.tsx","../../src/Results.tsx","../../src/utils/groupBy.ts","../../src/utils/identity.ts","../../src/utils/isModifierEvent.ts","../../src/utils/noop.ts","../../src/utils/removeHighlightTags.ts","../../src/ResultsScreen.tsx","../../src/StartScreen.tsx","../../src/ScreenState.tsx","../../src/SearchBox.tsx","../../src/constants.ts","../../src/stored-searches.ts","../../node_modules/algoliasearch/dist/algoliasearch-lite.esm.browser.js","../../src/version.ts","../../src/DocSearchModal.tsx","../../src/useSearchClient.ts","../../src/useTouchEvents.ts","../../src/useTrapFocus.ts","../../src/useDocSearchKeyboardEvents.ts","../../src/DocSearch.tsx"],"sourcesContent":["import React from 'react';\n\nexport function ControlKeyIcon() {\n return (\n \n \n \n );\n}\n","import React from 'react';\n\nexport function SearchIcon() {\n return (\n \n \n \n );\n}\n","import React, { useEffect, useState } from 'react';\n\nimport { ControlKeyIcon } from './icons/ControlKeyIcon';\nimport { SearchIcon } from './icons/SearchIcon';\n\nexport type ButtonTranslations = Partial<{\n buttonText: string;\n buttonAriaLabel: string;\n}>;\n\nexport type DocSearchButtonProps = React.ComponentProps<'button'> & {\n translations?: ButtonTranslations;\n};\n\nconst ACTION_KEY_DEFAULT = 'Ctrl' as const;\nconst ACTION_KEY_APPLE = '⌘' as const;\n\nfunction isAppleDevice() {\n return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform);\n}\n\nexport const DocSearchButton = React.forwardRef<\n HTMLButtonElement,\n DocSearchButtonProps\n>(({ translations = {}, ...props }, ref) => {\n const { buttonText = 'Search', buttonAriaLabel = 'Search' } = translations;\n\n const [key, setKey] = useState<\n typeof ACTION_KEY_APPLE | typeof ACTION_KEY_DEFAULT | null\n >(null);\n\n useEffect(() => {\n if (typeof navigator !== 'undefined') {\n isAppleDevice() ? setKey(ACTION_KEY_APPLE) : setKey(ACTION_KEY_DEFAULT);\n }\n }, []);\n\n return (\n \n \n \n {buttonText}\n \n\n \n {key !== null && (\n <>\n \n {key === ACTION_KEY_DEFAULT ? : key}\n \n K\n \n )}\n \n \n );\n});\n\ntype DocSearchButtonKeyProps = {\n reactsToKey?: string;\n};\n\nfunction DocSearchButtonKey({\n reactsToKey,\n children,\n}: React.PropsWithChildren) {\n const [isKeyDown, setIsKeyDown] = useState(false);\n\n useEffect(() => {\n if (!reactsToKey) {\n return undefined;\n }\n\n function handleKeyDown(e: KeyboardEvent) {\n if (e.key === reactsToKey) {\n setIsKeyDown(true);\n }\n }\n\n function handleKeyUp(e: KeyboardEvent) {\n if (\n e.key === reactsToKey ||\n // keyup doesn't fire when Command is held down,\n // workaround is to mark key as also released when Command is released\n // See https://stackoverflow.com/a/73419500\n e.key === 'Meta'\n ) {\n setIsKeyDown(false);\n }\n }\n\n window.addEventListener('keydown', handleKeyDown);\n window.addEventListener('keyup', handleKeyUp);\n\n return () => {\n window.removeEventListener('keydown', handleKeyDown);\n window.removeEventListener('keyup', handleKeyUp);\n };\n }, [reactsToKey]);\n\n return (\n \n {children}\n \n );\n}\n","export function debounce(fn, time) {\n var timerId = undefined;\n return function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n if (timerId) {\n clearTimeout(timerId);\n }\n timerId = setTimeout(function () {\n return fn.apply(void 0, args);\n }, time);\n };\n}","export function flatten(values) {\n return values.reduce(function (a, b) {\n return a.concat(b);\n }, []);\n}","var autocompleteId = 0;\nexport function generateAutocompleteId() {\n return \"autocomplete-\".concat(autocompleteId++);\n}","export function getItemsCount(state) {\n if (state.collections.length === 0) {\n return 0;\n }\n return state.collections.reduce(function (sum, collection) {\n return sum + collection.items.length;\n }, 0);\n}","function isPrimitive(obj) {\n return obj !== Object(obj);\n}\nexport function isEqual(first, second) {\n if (first === second) {\n return true;\n }\n if (isPrimitive(first) || isPrimitive(second) || typeof first === 'function' || typeof second === 'function') {\n return first === second;\n }\n if (Object.keys(first).length !== Object.keys(second).length) {\n return false;\n }\n for (var _i = 0, _Object$keys = Object.keys(first); _i < _Object$keys.length; _i++) {\n var key = _Object$keys[_i];\n if (!(key in second)) {\n return false;\n }\n if (!isEqual(first[key], second[key])) {\n return false;\n }\n }\n return true;\n}","export var noop = function noop() {};","import { version } from './version';\nexport var userAgents = [{\n segment: 'autocomplete-core',\n version: version\n}];","export var version = '1.9.3';","export function createClickedEvent(_ref) {\n var item = _ref.item,\n items = _ref.items;\n return {\n index: item.__autocomplete_indexName,\n items: [item],\n positions: [1 + items.findIndex(function (x) {\n return x.objectID === item.objectID;\n })],\n queryID: item.__autocomplete_queryID,\n algoliaSource: ['autocomplete']\n };\n}","function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : \"undefined\" != typeof Symbol && arr[Symbol.iterator] || arr[\"@@iterator\"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n/**\n * Determines if a given insights `client` supports the optional call to `init`\n * and the ability to set credentials via extra parameters when sending events.\n */\nexport function isModernInsightsClient(client) {\n var _split$map = (client.version || '').split('.').map(Number),\n _split$map2 = _slicedToArray(_split$map, 2),\n major = _split$map2[0],\n minor = _split$map2[1];\n\n /* eslint-disable @typescript-eslint/camelcase */\n var v3 = major >= 3;\n var v2_4 = major === 2 && minor >= 4;\n var v1_10 = major === 1 && minor >= 10;\n return v3 || v2_4 || v1_10;\n /* eslint-enable @typescript-eslint/camelcase */\n}","var _excluded = [\"items\"],\n _excluded2 = [\"items\"];\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport { isModernInsightsClient } from './isModernInsightsClient';\nfunction chunk(item) {\n var chunkSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 20;\n var chunks = [];\n for (var i = 0; i < item.objectIDs.length; i += chunkSize) {\n chunks.push(_objectSpread(_objectSpread({}, item), {}, {\n objectIDs: item.objectIDs.slice(i, i + chunkSize)\n }));\n }\n return chunks;\n}\nfunction mapToInsightsParamsApi(params) {\n return params.map(function (_ref) {\n var items = _ref.items,\n param = _objectWithoutProperties(_ref, _excluded);\n return _objectSpread(_objectSpread({}, param), {}, {\n objectIDs: (items === null || items === void 0 ? void 0 : items.map(function (_ref2) {\n var objectID = _ref2.objectID;\n return objectID;\n })) || param.objectIDs\n });\n });\n}\nexport function createSearchInsightsApi(searchInsights) {\n var canSendHeaders = isModernInsightsClient(searchInsights);\n function sendToInsights(method, payloads, items) {\n if (canSendHeaders && typeof items !== 'undefined') {\n var _items$0$__autocomple = items[0].__autocomplete_algoliaCredentials,\n appId = _items$0$__autocomple.appId,\n apiKey = _items$0$__autocomple.apiKey;\n var headers = {\n 'X-Algolia-Application-Id': appId,\n 'X-Algolia-API-Key': apiKey\n };\n searchInsights.apply(void 0, [method].concat(_toConsumableArray(payloads), [{\n headers: headers\n }]));\n } else {\n searchInsights.apply(void 0, [method].concat(_toConsumableArray(payloads)));\n }\n }\n return {\n /**\n * Initializes Insights with Algolia credentials.\n */\n init: function init(appId, apiKey) {\n searchInsights('init', {\n appId: appId,\n apiKey: apiKey\n });\n },\n /**\n * Sets the user token to attach to events.\n */\n setUserToken: function setUserToken(userToken) {\n searchInsights('setUserToken', userToken);\n },\n /**\n * Sends click events to capture a query and its clicked items and positions.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/clicked-object-ids-after-search/\n */\n clickedObjectIDsAfterSearch: function clickedObjectIDsAfterSearch() {\n for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {\n params[_key] = arguments[_key];\n }\n if (params.length > 0) {\n sendToInsights('clickedObjectIDsAfterSearch', mapToInsightsParamsApi(params), params[0].items);\n }\n },\n /**\n * Sends click events to capture clicked items.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/clicked-object-ids/\n */\n clickedObjectIDs: function clickedObjectIDs() {\n for (var _len2 = arguments.length, params = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {\n params[_key2] = arguments[_key2];\n }\n if (params.length > 0) {\n sendToInsights('clickedObjectIDs', mapToInsightsParamsApi(params), params[0].items);\n }\n },\n /**\n * Sends click events to capture the filters a user clicks on.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/clicked-filters/\n */\n clickedFilters: function clickedFilters() {\n for (var _len3 = arguments.length, params = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {\n params[_key3] = arguments[_key3];\n }\n if (params.length > 0) {\n searchInsights.apply(void 0, ['clickedFilters'].concat(params));\n }\n },\n /**\n * Sends conversion events to capture a query and its clicked items.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/converted-object-ids-after-search/\n */\n convertedObjectIDsAfterSearch: function convertedObjectIDsAfterSearch() {\n for (var _len4 = arguments.length, params = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n params[_key4] = arguments[_key4];\n }\n if (params.length > 0) {\n sendToInsights('convertedObjectIDsAfterSearch', mapToInsightsParamsApi(params), params[0].items);\n }\n },\n /**\n * Sends conversion events to capture clicked items.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/converted-object-ids/\n */\n convertedObjectIDs: function convertedObjectIDs() {\n for (var _len5 = arguments.length, params = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {\n params[_key5] = arguments[_key5];\n }\n if (params.length > 0) {\n sendToInsights('convertedObjectIDs', mapToInsightsParamsApi(params), params[0].items);\n }\n },\n /**\n * Sends conversion events to capture the filters a user uses when converting.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/converted-filters/\n */\n convertedFilters: function convertedFilters() {\n for (var _len6 = arguments.length, params = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {\n params[_key6] = arguments[_key6];\n }\n if (params.length > 0) {\n searchInsights.apply(void 0, ['convertedFilters'].concat(params));\n }\n },\n /**\n * Sends view events to capture clicked items.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/viewed-object-ids/\n */\n viewedObjectIDs: function viewedObjectIDs() {\n for (var _len7 = arguments.length, params = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {\n params[_key7] = arguments[_key7];\n }\n if (params.length > 0) {\n params.reduce(function (acc, _ref3) {\n var items = _ref3.items,\n param = _objectWithoutProperties(_ref3, _excluded2);\n return [].concat(_toConsumableArray(acc), _toConsumableArray(chunk(_objectSpread(_objectSpread({}, param), {}, {\n objectIDs: (items === null || items === void 0 ? void 0 : items.map(function (_ref4) {\n var objectID = _ref4.objectID;\n return objectID;\n })) || param.objectIDs\n })).map(function (payload) {\n return {\n items: items,\n payload: payload\n };\n })));\n }, []).forEach(function (_ref5) {\n var items = _ref5.items,\n payload = _ref5.payload;\n return sendToInsights('viewedObjectIDs', [payload], items);\n });\n }\n },\n /**\n * Sends view events to capture the filters a user uses when viewing.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/viewed-filters/\n */\n viewedFilters: function viewedFilters() {\n for (var _len8 = arguments.length, params = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {\n params[_key8] = arguments[_key8];\n }\n if (params.length > 0) {\n searchInsights.apply(void 0, ['viewedFilters'].concat(params));\n }\n }\n };\n}","export function createViewedEvents(_ref) {\n var items = _ref.items;\n var itemsByIndexName = items.reduce(function (acc, current) {\n var _acc$current$__autoco;\n acc[current.__autocomplete_indexName] = ((_acc$current$__autoco = acc[current.__autocomplete_indexName]) !== null && _acc$current$__autoco !== void 0 ? _acc$current$__autoco : []).concat(current);\n return acc;\n }, {});\n return Object.keys(itemsByIndexName).map(function (indexName) {\n var items = itemsByIndexName[indexName];\n return {\n index: indexName,\n items: items,\n algoliaSource: ['autocomplete']\n };\n });\n}","export function isAlgoliaInsightsHit(hit) {\n return hit.objectID && hit.__autocomplete_indexName && hit.__autocomplete_queryID;\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport { createRef, debounce, isEqual, noop, safelyRunOnBrowser } from '@algolia/autocomplete-shared';\nimport { createClickedEvent } from './createClickedEvent';\nimport { createSearchInsightsApi } from './createSearchInsightsApi';\nimport { createViewedEvents } from './createViewedEvents';\nimport { isAlgoliaInsightsHit } from './isAlgoliaInsightsHit';\nvar VIEW_EVENT_DELAY = 400;\nvar ALGOLIA_INSIGHTS_VERSION = '2.6.0';\nvar ALGOLIA_INSIGHTS_SRC = \"https://cdn.jsdelivr.net/npm/search-insights@\".concat(ALGOLIA_INSIGHTS_VERSION, \"/dist/search-insights.min.js\");\nvar sendViewedObjectIDs = debounce(function (_ref) {\n var onItemsChange = _ref.onItemsChange,\n items = _ref.items,\n insights = _ref.insights,\n state = _ref.state;\n onItemsChange({\n insights: insights,\n insightsEvents: createViewedEvents({\n items: items\n }).map(function (event) {\n return _objectSpread({\n eventName: 'Items Viewed'\n }, event);\n }),\n state: state\n });\n}, VIEW_EVENT_DELAY);\nexport function createAlgoliaInsightsPlugin(options) {\n var _getOptions = getOptions(options),\n providedInsightsClient = _getOptions.insightsClient,\n onItemsChange = _getOptions.onItemsChange,\n onSelectEvent = _getOptions.onSelect,\n onActiveEvent = _getOptions.onActive;\n var insightsClient = providedInsightsClient;\n if (!providedInsightsClient) {\n safelyRunOnBrowser(function (_ref2) {\n var window = _ref2.window;\n var pointer = window.AlgoliaAnalyticsObject || 'aa';\n if (typeof pointer === 'string') {\n insightsClient = window[pointer];\n }\n if (!insightsClient) {\n window.AlgoliaAnalyticsObject = pointer;\n if (!window[pointer]) {\n window[pointer] = function () {\n if (!window[pointer].queue) {\n window[pointer].queue = [];\n }\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n window[pointer].queue.push(args);\n };\n }\n window[pointer].version = ALGOLIA_INSIGHTS_VERSION;\n insightsClient = window[pointer];\n loadInsights(window);\n }\n });\n }\n var insights = createSearchInsightsApi(insightsClient);\n var previousItems = createRef([]);\n var debouncedOnStateChange = debounce(function (_ref3) {\n var state = _ref3.state;\n if (!state.isOpen) {\n return;\n }\n var items = state.collections.reduce(function (acc, current) {\n return [].concat(_toConsumableArray(acc), _toConsumableArray(current.items));\n }, []).filter(isAlgoliaInsightsHit);\n if (!isEqual(previousItems.current.map(function (x) {\n return x.objectID;\n }), items.map(function (x) {\n return x.objectID;\n }))) {\n previousItems.current = items;\n if (items.length > 0) {\n sendViewedObjectIDs({\n onItemsChange: onItemsChange,\n items: items,\n insights: insights,\n state: state\n });\n }\n }\n }, 0);\n return {\n name: 'aa.algoliaInsightsPlugin',\n subscribe: function subscribe(_ref4) {\n var setContext = _ref4.setContext,\n onSelect = _ref4.onSelect,\n onActive = _ref4.onActive;\n insightsClient('addAlgoliaAgent', 'insights-plugin');\n setContext({\n algoliaInsightsPlugin: {\n __algoliaSearchParameters: {\n clickAnalytics: true\n },\n insights: insights\n }\n });\n onSelect(function (_ref5) {\n var item = _ref5.item,\n state = _ref5.state,\n event = _ref5.event;\n if (!isAlgoliaInsightsHit(item)) {\n return;\n }\n onSelectEvent({\n state: state,\n event: event,\n insights: insights,\n item: item,\n insightsEvents: [_objectSpread({\n eventName: 'Item Selected'\n }, createClickedEvent({\n item: item,\n items: previousItems.current\n }))]\n });\n });\n onActive(function (_ref6) {\n var item = _ref6.item,\n state = _ref6.state,\n event = _ref6.event;\n if (!isAlgoliaInsightsHit(item)) {\n return;\n }\n onActiveEvent({\n state: state,\n event: event,\n insights: insights,\n item: item,\n insightsEvents: [_objectSpread({\n eventName: 'Item Active'\n }, createClickedEvent({\n item: item,\n items: previousItems.current\n }))]\n });\n });\n },\n onStateChange: function onStateChange(_ref7) {\n var state = _ref7.state;\n debouncedOnStateChange({\n state: state\n });\n },\n __autocomplete_pluginOptions: options\n };\n}\nfunction getOptions(options) {\n return _objectSpread({\n onItemsChange: function onItemsChange(_ref8) {\n var insights = _ref8.insights,\n insightsEvents = _ref8.insightsEvents;\n insights.viewedObjectIDs.apply(insights, _toConsumableArray(insightsEvents.map(function (event) {\n return _objectSpread(_objectSpread({}, event), {}, {\n algoliaSource: [].concat(_toConsumableArray(event.algoliaSource || []), ['autocomplete-internal'])\n });\n })));\n },\n onSelect: function onSelect(_ref9) {\n var insights = _ref9.insights,\n insightsEvents = _ref9.insightsEvents;\n insights.clickedObjectIDsAfterSearch.apply(insights, _toConsumableArray(insightsEvents.map(function (event) {\n return _objectSpread(_objectSpread({}, event), {}, {\n algoliaSource: [].concat(_toConsumableArray(event.algoliaSource || []), ['autocomplete-internal'])\n });\n })));\n },\n onActive: noop\n }, options);\n}\nfunction loadInsights(environment) {\n var errorMessage = \"[Autocomplete]: Could not load search-insights.js. Please load it manually following https://alg.li/insights-autocomplete\";\n try {\n var script = environment.document.createElement('script');\n script.async = true;\n script.src = ALGOLIA_INSIGHTS_SRC;\n script.onerror = function () {\n // eslint-disable-next-line no-console\n console.error(errorMessage);\n };\n document.body.appendChild(script);\n } catch (cause) {\n // eslint-disable-next-line no-console\n console.error(errorMessage);\n }\n}","/**\n * Safely runs code meant for browser environments only.\n */\nexport function safelyRunOnBrowser(callback) {\n if (typeof window !== 'undefined') {\n return callback({\n window: window\n });\n }\n return undefined;\n}","export function createRef(initialValue) {\n return {\n current: initialValue\n };\n}","function createInternalCancelablePromise(promise, initialState) {\n var state = initialState;\n return {\n then: function then(onfulfilled, onrejected) {\n return createInternalCancelablePromise(promise.then(createCallback(onfulfilled, state, promise), createCallback(onrejected, state, promise)), state);\n },\n catch: function _catch(onrejected) {\n return createInternalCancelablePromise(promise.catch(createCallback(onrejected, state, promise)), state);\n },\n finally: function _finally(onfinally) {\n if (onfinally) {\n state.onCancelList.push(onfinally);\n }\n return createInternalCancelablePromise(promise.finally(createCallback(onfinally && function () {\n state.onCancelList = [];\n return onfinally();\n }, state, promise)), state);\n },\n cancel: function cancel() {\n state.isCanceled = true;\n var callbacks = state.onCancelList;\n state.onCancelList = [];\n callbacks.forEach(function (callback) {\n callback();\n });\n },\n isCanceled: function isCanceled() {\n return state.isCanceled === true;\n }\n };\n}\nexport function createCancelablePromise(executor) {\n return createInternalCancelablePromise(new Promise(function (resolve, reject) {\n return executor(resolve, reject);\n }), {\n isCanceled: false,\n onCancelList: []\n });\n}\ncreateCancelablePromise.resolve = function (value) {\n return cancelable(Promise.resolve(value));\n};\ncreateCancelablePromise.reject = function (reason) {\n return cancelable(Promise.reject(reason));\n};\nexport function cancelable(promise) {\n return createInternalCancelablePromise(promise, {\n isCanceled: false,\n onCancelList: []\n });\n}\nfunction createCallback(onResult, state, fallback) {\n if (!onResult) {\n return fallback;\n }\n return function callback(arg) {\n if (state.isCanceled) {\n return arg;\n }\n return onResult(arg);\n };\n}","/**\n * Returns the next active item ID from the current state.\n *\n * We allow circular keyboard navigation from the base index.\n * The base index can either be `null` (nothing is highlighted) or `0`\n * (the first item is highlighted).\n * The base index is allowed to get assigned `null` only if\n * `props.defaultActiveItemId` is `null`. This pattern allows to \"stop\"\n * by the actual query before navigating to other suggestions as seen on\n * Google or Amazon.\n *\n * @param moveAmount The offset to increment (or decrement) the last index\n * @param baseIndex The current index to compute the next index from\n * @param itemCount The number of items\n * @param defaultActiveItemId The default active index to fallback to\n */\nexport function getNextActiveItemId(moveAmount, baseIndex, itemCount, defaultActiveItemId) {\n if (!itemCount) {\n return null;\n }\n if (moveAmount < 0 && (baseIndex === null || defaultActiveItemId !== null && baseIndex === 0)) {\n return itemCount + moveAmount;\n }\n var numericIndex = (baseIndex === null ? -1 : baseIndex) + moveAmount;\n if (numericIndex <= -1 || numericIndex >= itemCount) {\n return defaultActiveItemId === null ? null : 0;\n }\n return numericIndex;\n}","function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nimport { invariant, decycle, noop } from '@algolia/autocomplete-shared';\nexport function getNormalizedSources(getSources, params) {\n var seenSourceIds = [];\n return Promise.resolve(getSources(params)).then(function (sources) {\n invariant(Array.isArray(sources), function () {\n return \"The `getSources` function must return an array of sources but returned type \".concat(JSON.stringify(_typeof(sources)), \":\\n\\n\").concat(JSON.stringify(decycle(sources), null, 2));\n });\n return Promise.all(sources\n // We allow `undefined` and `false` sources to allow users to use\n // `Boolean(query) && source` (=> `false`).\n // We need to remove these values at this point.\n .filter(function (maybeSource) {\n return Boolean(maybeSource);\n }).map(function (source) {\n invariant(typeof source.sourceId === 'string', 'A source must provide a `sourceId` string.');\n if (seenSourceIds.includes(source.sourceId)) {\n throw new Error(\"[Autocomplete] The `sourceId` \".concat(JSON.stringify(source.sourceId), \" is not unique.\"));\n }\n seenSourceIds.push(source.sourceId);\n var defaultSource = {\n getItemInputValue: function getItemInputValue(_ref) {\n var state = _ref.state;\n return state.query;\n },\n getItemUrl: function getItemUrl() {\n return undefined;\n },\n onSelect: function onSelect(_ref2) {\n var setIsOpen = _ref2.setIsOpen;\n setIsOpen(false);\n },\n onActive: noop,\n onResolve: noop\n };\n Object.keys(defaultSource).forEach(function (key) {\n defaultSource[key].__default = true;\n });\n var normalizedSource = _objectSpread(_objectSpread({}, defaultSource), source);\n return Promise.resolve(normalizedSource);\n }));\n });\n}","// We don't have access to the autocomplete source when we call `onKeyDown`\n// or `onClick` because those are native browser events.\n// However, we can get the source from the suggestion index.\nfunction getCollectionFromActiveItemId(state) {\n // Given 3 sources with respectively 1, 2 and 3 suggestions: [1, 2, 3]\n // We want to get the accumulated counts:\n // [1, 1 + 2, 1 + 2 + 3] = [1, 3, 3 + 3] = [1, 3, 6]\n var accumulatedCollectionsCount = state.collections.map(function (collections) {\n return collections.items.length;\n }).reduce(function (acc, collectionsCount, index) {\n var previousValue = acc[index - 1] || 0;\n var nextValue = previousValue + collectionsCount;\n acc.push(nextValue);\n return acc;\n }, []);\n\n // Based on the accumulated counts, we can infer the index of the suggestion.\n var collectionIndex = accumulatedCollectionsCount.reduce(function (acc, current) {\n if (current <= state.activeItemId) {\n return acc + 1;\n }\n return acc;\n }, 0);\n return state.collections[collectionIndex];\n}\n\n/**\n * Gets the highlighted index relative to a suggestion object (not the absolute\n * highlighted index).\n *\n * Example:\n * [['a', 'b'], ['c', 'd', 'e'], ['f']]\n * ↑\n * (absolute: 3, relative: 1)\n */\nfunction getRelativeActiveItemId(_ref) {\n var state = _ref.state,\n collection = _ref.collection;\n var isOffsetFound = false;\n var counter = 0;\n var previousItemsOffset = 0;\n while (isOffsetFound === false) {\n var currentCollection = state.collections[counter];\n if (currentCollection === collection) {\n isOffsetFound = true;\n break;\n }\n previousItemsOffset += currentCollection.items.length;\n counter++;\n }\n return state.activeItemId - previousItemsOffset;\n}\nexport function getActiveItem(state) {\n var collection = getCollectionFromActiveItemId(state);\n if (!collection) {\n return null;\n }\n var item = collection.items[getRelativeActiveItemId({\n state: state,\n collection: collection\n })];\n var source = collection.source;\n var itemInputValue = source.getItemInputValue({\n item: item,\n state: state\n });\n var itemUrl = source.getItemUrl({\n item: item,\n state: state\n });\n return {\n item: item,\n itemInputValue: itemInputValue,\n itemUrl: itemUrl,\n source: source\n };\n}","var regex = /((gt|sm)-|galaxy nexus)|samsung[- ]|samsungbrowser/i;\nexport function isSamsung(userAgent) {\n return Boolean(userAgent && userAgent.match(regex));\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport { createCancelablePromiseList } from './utils';\nexport function createStore(reducer, props, onStoreStateChange) {\n var state = props.initialState;\n return {\n getState: function getState() {\n return state;\n },\n dispatch: function dispatch(action, payload) {\n var prevState = _objectSpread({}, state);\n state = reducer(state, {\n type: action,\n props: props,\n payload: payload\n });\n onStoreStateChange({\n state: state,\n prevState: prevState\n });\n },\n pendingRequests: createCancelablePromiseList()\n };\n}","export function createCancelablePromiseList() {\n var list = [];\n return {\n add: function add(cancelablePromise) {\n list.push(cancelablePromise);\n return cancelablePromise.finally(function () {\n list = list.filter(function (item) {\n return item !== cancelablePromise;\n });\n });\n },\n cancelAll: function cancelAll() {\n list.forEach(function (promise) {\n return promise.cancel();\n });\n },\n isEmpty: function isEmpty() {\n return list.length === 0;\n }\n };\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport { flatten } from '@algolia/autocomplete-shared';\nexport function getAutocompleteSetters(_ref) {\n var store = _ref.store;\n var setActiveItemId = function setActiveItemId(value) {\n store.dispatch('setActiveItemId', value);\n };\n var setQuery = function setQuery(value) {\n store.dispatch('setQuery', value);\n };\n var setCollections = function setCollections(rawValue) {\n var baseItemId = 0;\n var value = rawValue.map(function (collection) {\n return _objectSpread(_objectSpread({}, collection), {}, {\n // We flatten the stored items to support calling `getAlgoliaResults`\n // from the source itself.\n items: flatten(collection.items).map(function (item) {\n return _objectSpread(_objectSpread({}, item), {}, {\n __autocomplete_id: baseItemId++\n });\n })\n });\n });\n store.dispatch('setCollections', value);\n };\n var setIsOpen = function setIsOpen(value) {\n store.dispatch('setIsOpen', value);\n };\n var setStatus = function setStatus(value) {\n store.dispatch('setStatus', value);\n };\n var setContext = function setContext(value) {\n store.dispatch('setContext', value);\n };\n return {\n setActiveItemId: setActiveItemId,\n setQuery: setQuery,\n setCollections: setCollections,\n setIsOpen: setIsOpen,\n setStatus: setStatus,\n setContext: setContext\n };\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport { getItemsCount, generateAutocompleteId, flatten } from '@algolia/autocomplete-shared';\nimport { getNormalizedSources } from './utils';\nexport function getDefaultProps(props, pluginSubscribers) {\n var _props$id;\n /* eslint-disable no-restricted-globals */\n var environment = typeof window !== 'undefined' ? window : {};\n /* eslint-enable no-restricted-globals */\n var plugins = props.plugins || [];\n return _objectSpread(_objectSpread({\n debug: false,\n openOnFocus: false,\n placeholder: '',\n autoFocus: false,\n defaultActiveItemId: null,\n stallThreshold: 300,\n insights: false,\n environment: environment,\n shouldPanelOpen: function shouldPanelOpen(_ref) {\n var state = _ref.state;\n return getItemsCount(state) > 0;\n },\n reshape: function reshape(_ref2) {\n var sources = _ref2.sources;\n return sources;\n }\n }, props), {}, {\n // Since `generateAutocompleteId` triggers a side effect (it increments\n // an internal counter), we don't want to execute it if unnecessary.\n id: (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : generateAutocompleteId(),\n plugins: plugins,\n // The following props need to be deeply defaulted.\n initialState: _objectSpread({\n activeItemId: null,\n query: '',\n completion: null,\n collections: [],\n isOpen: false,\n status: 'idle',\n context: {}\n }, props.initialState),\n onStateChange: function onStateChange(params) {\n var _props$onStateChange;\n (_props$onStateChange = props.onStateChange) === null || _props$onStateChange === void 0 ? void 0 : _props$onStateChange.call(props, params);\n plugins.forEach(function (x) {\n var _x$onStateChange;\n return (_x$onStateChange = x.onStateChange) === null || _x$onStateChange === void 0 ? void 0 : _x$onStateChange.call(x, params);\n });\n },\n onSubmit: function onSubmit(params) {\n var _props$onSubmit;\n (_props$onSubmit = props.onSubmit) === null || _props$onSubmit === void 0 ? void 0 : _props$onSubmit.call(props, params);\n plugins.forEach(function (x) {\n var _x$onSubmit;\n return (_x$onSubmit = x.onSubmit) === null || _x$onSubmit === void 0 ? void 0 : _x$onSubmit.call(x, params);\n });\n },\n onReset: function onReset(params) {\n var _props$onReset;\n (_props$onReset = props.onReset) === null || _props$onReset === void 0 ? void 0 : _props$onReset.call(props, params);\n plugins.forEach(function (x) {\n var _x$onReset;\n return (_x$onReset = x.onReset) === null || _x$onReset === void 0 ? void 0 : _x$onReset.call(x, params);\n });\n },\n getSources: function getSources(params) {\n return Promise.all([].concat(_toConsumableArray(plugins.map(function (plugin) {\n return plugin.getSources;\n })), [props.getSources]).filter(Boolean).map(function (getSources) {\n return getNormalizedSources(getSources, params);\n })).then(function (nested) {\n return flatten(nested);\n }).then(function (sources) {\n return sources.map(function (source) {\n return _objectSpread(_objectSpread({}, source), {}, {\n onSelect: function onSelect(params) {\n source.onSelect(params);\n pluginSubscribers.forEach(function (x) {\n var _x$onSelect;\n return (_x$onSelect = x.onSelect) === null || _x$onSelect === void 0 ? void 0 : _x$onSelect.call(x, params);\n });\n },\n onActive: function onActive(params) {\n source.onActive(params);\n pluginSubscribers.forEach(function (x) {\n var _x$onActive;\n return (_x$onActive = x.onActive) === null || _x$onActive === void 0 ? void 0 : _x$onActive.call(x, params);\n });\n },\n onResolve: function onResolve(params) {\n source.onResolve(params);\n pluginSubscribers.forEach(function (x) {\n var _x$onResolve;\n return (_x$onResolve = x.onResolve) === null || _x$onResolve === void 0 ? void 0 : _x$onResolve.call(x, params);\n });\n }\n });\n });\n });\n },\n navigator: _objectSpread({\n navigate: function navigate(_ref3) {\n var itemUrl = _ref3.itemUrl;\n environment.location.assign(itemUrl);\n },\n navigateNewTab: function navigateNewTab(_ref4) {\n var itemUrl = _ref4.itemUrl;\n var windowReference = environment.open(itemUrl, '_blank', 'noopener');\n windowReference === null || windowReference === void 0 ? void 0 : windowReference.focus();\n },\n navigateNewWindow: function navigateNewWindow(_ref5) {\n var itemUrl = _ref5.itemUrl;\n environment.open(itemUrl, '_blank', 'noopener');\n }\n }, props.navigator)\n });\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport { flatten } from '@algolia/autocomplete-shared';\nexport function reshape(_ref) {\n var collections = _ref.collections,\n props = _ref.props,\n state = _ref.state;\n // Sources are grouped by `sourceId` to conveniently pick them via destructuring.\n // Example: `const { recentSearchesPlugin } = sourcesBySourceId`\n var originalSourcesBySourceId = collections.reduce(function (acc, collection) {\n return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, collection.source.sourceId, _objectSpread(_objectSpread({}, collection.source), {}, {\n getItems: function getItems() {\n // We provide the resolved items from the collection to the `reshape` prop.\n return flatten(collection.items);\n }\n })));\n }, {});\n var _props$plugins$reduce = props.plugins.reduce(function (acc, plugin) {\n if (plugin.reshape) {\n return plugin.reshape(acc);\n }\n return acc;\n }, {\n sourcesBySourceId: originalSourcesBySourceId,\n state: state\n }),\n sourcesBySourceId = _props$plugins$reduce.sourcesBySourceId;\n var reshapeSources = props.reshape({\n sourcesBySourceId: sourcesBySourceId,\n sources: Object.values(sourcesBySourceId),\n state: state\n });\n\n // We reconstruct the collections with the items modified by the `reshape` prop.\n return flatten(reshapeSources).filter(Boolean).map(function (source) {\n return {\n source: source,\n items: source.getItems()\n };\n });\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _iterableToArray(iter) { if (typeof Symbol !== \"undefined\" && iter[Symbol.iterator] != null || iter[\"@@iterator\"] != null) return Array.from(iter); }\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nimport { decycle, flatten, invariant } from '@algolia/autocomplete-shared';\nimport { mapToAlgoliaResponse } from './utils';\nfunction isDescription(item) {\n return Boolean(item.execute);\n}\nfunction isRequesterDescription(description) {\n return Boolean(description === null || description === void 0 ? void 0 : description.execute);\n}\nexport function preResolve(itemsOrDescription, sourceId, state) {\n if (isRequesterDescription(itemsOrDescription)) {\n var contextParameters = itemsOrDescription.requesterId === 'algolia' ? Object.assign.apply(Object, [{}].concat(_toConsumableArray(Object.keys(state.context).map(function (key) {\n var _state$context$key;\n return (_state$context$key = state.context[key]) === null || _state$context$key === void 0 ? void 0 : _state$context$key.__algoliaSearchParameters;\n })))) : {};\n return _objectSpread(_objectSpread({}, itemsOrDescription), {}, {\n requests: itemsOrDescription.queries.map(function (query) {\n return {\n query: itemsOrDescription.requesterId === 'algolia' ? _objectSpread(_objectSpread({}, query), {}, {\n params: _objectSpread(_objectSpread({}, contextParameters), query.params)\n }) : query,\n sourceId: sourceId,\n transformResponse: itemsOrDescription.transformResponse\n };\n })\n });\n }\n return {\n items: itemsOrDescription,\n sourceId: sourceId\n };\n}\nexport function resolve(items) {\n var packed = items.reduce(function (acc, current) {\n if (!isDescription(current)) {\n acc.push(current);\n return acc;\n }\n var searchClient = current.searchClient,\n execute = current.execute,\n requesterId = current.requesterId,\n requests = current.requests;\n var container = acc.find(function (item) {\n return isDescription(current) && isDescription(item) && item.searchClient === searchClient && Boolean(requesterId) && item.requesterId === requesterId;\n });\n if (container) {\n var _container$items;\n (_container$items = container.items).push.apply(_container$items, _toConsumableArray(requests));\n } else {\n var request = {\n execute: execute,\n requesterId: requesterId,\n items: requests,\n searchClient: searchClient\n };\n acc.push(request);\n }\n return acc;\n }, []);\n var values = packed.map(function (maybeDescription) {\n if (!isDescription(maybeDescription)) {\n return Promise.resolve(maybeDescription);\n }\n var _ref = maybeDescription,\n execute = _ref.execute,\n items = _ref.items,\n searchClient = _ref.searchClient;\n return execute({\n searchClient: searchClient,\n requests: items\n });\n });\n return Promise.all(values).then(function (responses) {\n return flatten(responses);\n });\n}\nexport function postResolve(responses, sources, store) {\n return sources.map(function (source) {\n var matches = responses.filter(function (response) {\n return response.sourceId === source.sourceId;\n });\n var results = matches.map(function (_ref2) {\n var items = _ref2.items;\n return items;\n });\n var transform = matches[0].transformResponse;\n var items = transform ? transform(mapToAlgoliaResponse(results)) : results;\n source.onResolve({\n source: source,\n results: results,\n items: items,\n state: store.getState()\n });\n invariant(Array.isArray(items), function () {\n return \"The `getItems` function from source \\\"\".concat(source.sourceId, \"\\\" must return an array of items but returned type \").concat(JSON.stringify(_typeof(items)), \":\\n\\n\").concat(JSON.stringify(decycle(items), null, 2), \".\\n\\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-getitems\");\n });\n invariant(items.every(Boolean), \"The `getItems` function from source \\\"\".concat(source.sourceId, \"\\\" must return an array of items but returned \").concat(JSON.stringify(undefined), \".\\n\\nDid you forget to return items?\\n\\nSee: https://www.algolia.com/doc/ui-libraries/autocomplete/core-concepts/sources/#param-getitems\"));\n return {\n source: source,\n items: items\n };\n });\n}","export function mapToAlgoliaResponse(rawResults) {\n return {\n results: rawResults,\n hits: rawResults.map(function (result) {\n return result.hits;\n }).filter(Boolean),\n facetHits: rawResults.map(function (result) {\n var _facetHits;\n return (_facetHits = result.facetHits) === null || _facetHits === void 0 ? void 0 : _facetHits.map(function (facetHit) {\n // Bring support for the highlighting components.\n return {\n label: facetHit.value,\n count: facetHit.count,\n _highlightResult: {\n label: {\n value: facetHit.highlighted\n }\n }\n };\n });\n }).filter(Boolean)\n };\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nvar _excluded = [\"event\", \"nextState\", \"props\", \"query\", \"refresh\", \"store\"];\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\nimport { reshape } from './reshape';\nimport { preResolve, resolve, postResolve } from './resolve';\nimport { cancelable, createConcurrentSafePromise, getActiveItem } from './utils';\nvar lastStalledId = null;\nvar runConcurrentSafePromise = createConcurrentSafePromise();\nexport function onInput(_ref) {\n var event = _ref.event,\n _ref$nextState = _ref.nextState,\n nextState = _ref$nextState === void 0 ? {} : _ref$nextState,\n props = _ref.props,\n query = _ref.query,\n refresh = _ref.refresh,\n store = _ref.store,\n setters = _objectWithoutProperties(_ref, _excluded);\n if (lastStalledId) {\n props.environment.clearTimeout(lastStalledId);\n }\n var setCollections = setters.setCollections,\n setIsOpen = setters.setIsOpen,\n setQuery = setters.setQuery,\n setActiveItemId = setters.setActiveItemId,\n setStatus = setters.setStatus;\n setQuery(query);\n setActiveItemId(props.defaultActiveItemId);\n if (!query && props.openOnFocus === false) {\n var _nextState$isOpen;\n var collections = store.getState().collections.map(function (collection) {\n return _objectSpread(_objectSpread({}, collection), {}, {\n items: []\n });\n });\n setStatus('idle');\n setCollections(collections);\n setIsOpen((_nextState$isOpen = nextState.isOpen) !== null && _nextState$isOpen !== void 0 ? _nextState$isOpen : props.shouldPanelOpen({\n state: store.getState()\n }));\n\n // We make sure to update the latest resolved value of the tracked\n // promises to keep late resolving promises from \"cancelling\" the state\n // updates performed in this code path.\n // We chain with a void promise to respect `onInput`'s expected return type.\n var _request = cancelable(runConcurrentSafePromise(collections).then(function () {\n return Promise.resolve();\n }));\n return store.pendingRequests.add(_request);\n }\n setStatus('loading');\n lastStalledId = props.environment.setTimeout(function () {\n setStatus('stalled');\n }, props.stallThreshold);\n\n // We track the entire promise chain triggered by `onInput` before mutating\n // the Autocomplete state to make sure that any state manipulation is based on\n // fresh data regardless of when promises individually resolve.\n // We don't track nested promises and only rely on the full chain resolution,\n // meaning we should only ever manipulate the state once this concurrent-safe\n // promise is resolved.\n var request = cancelable(runConcurrentSafePromise(props.getSources(_objectSpread({\n query: query,\n refresh: refresh,\n state: store.getState()\n }, setters)).then(function (sources) {\n return Promise.all(sources.map(function (source) {\n return Promise.resolve(source.getItems(_objectSpread({\n query: query,\n refresh: refresh,\n state: store.getState()\n }, setters))).then(function (itemsOrDescription) {\n return preResolve(itemsOrDescription, source.sourceId, store.getState());\n });\n })).then(resolve).then(function (responses) {\n return postResolve(responses, sources, store);\n }).then(function (collections) {\n return reshape({\n collections: collections,\n props: props,\n state: store.getState()\n });\n });\n }))).then(function (collections) {\n var _nextState$isOpen2;\n // Parameters passed to `onInput` could be stale when the following code\n // executes, because `onInput` calls may not resolve in order.\n // If it becomes a problem we'll need to save the last passed parameters.\n // See: https://codesandbox.io/s/agitated-cookies-y290z\n\n setStatus('idle');\n setCollections(collections);\n var isPanelOpen = props.shouldPanelOpen({\n state: store.getState()\n });\n setIsOpen((_nextState$isOpen2 = nextState.isOpen) !== null && _nextState$isOpen2 !== void 0 ? _nextState$isOpen2 : props.openOnFocus && !query && isPanelOpen || isPanelOpen);\n var highlightedItem = getActiveItem(store.getState());\n if (store.getState().activeItemId !== null && highlightedItem) {\n var item = highlightedItem.item,\n itemInputValue = highlightedItem.itemInputValue,\n itemUrl = highlightedItem.itemUrl,\n source = highlightedItem.source;\n source.onActive(_objectSpread({\n event: event,\n item: item,\n itemInputValue: itemInputValue,\n itemUrl: itemUrl,\n refresh: refresh,\n source: source,\n state: store.getState()\n }, setters));\n }\n }).finally(function () {\n setStatus('idle');\n if (lastStalledId) {\n props.environment.clearTimeout(lastStalledId);\n }\n });\n return store.pendingRequests.add(request);\n}","/**\n * Creates a runner that executes promises in a concurrent-safe way.\n *\n * This is useful to prevent older promises to resolve after a newer promise,\n * otherwise resulting in stale resolved values.\n */\nexport function createConcurrentSafePromise() {\n var basePromiseId = -1;\n var latestResolvedId = -1;\n var latestResolvedValue = undefined;\n return function runConcurrentSafePromise(promise) {\n basePromiseId++;\n var currentPromiseId = basePromiseId;\n return Promise.resolve(promise).then(function (x) {\n // The promise might take too long to resolve and get outdated. This would\n // result in resolving stale values.\n // When this happens, we ignore the promise value and return the one\n // coming from the latest resolved value.\n //\n // +----------------------------------+\n // | 100ms |\n // | run(1) +---> R1 |\n // | 300ms |\n // | run(2) +-------------> R2 (SKIP) |\n // | 200ms |\n // | run(3) +--------> R3 |\n // +----------------------------------+\n if (latestResolvedValue && currentPromiseId < latestResolvedId) {\n return latestResolvedValue;\n }\n latestResolvedId = currentPromiseId;\n latestResolvedValue = x;\n return x;\n });\n };\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nvar _excluded = [\"event\", \"props\", \"refresh\", \"store\"];\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\nimport { onInput } from './onInput';\nimport { getActiveItem } from './utils';\nexport function onKeyDown(_ref) {\n var event = _ref.event,\n props = _ref.props,\n refresh = _ref.refresh,\n store = _ref.store,\n setters = _objectWithoutProperties(_ref, _excluded);\n if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {\n // eslint-disable-next-line no-inner-declarations\n var triggerScrollIntoView = function triggerScrollIntoView() {\n var nodeItem = props.environment.document.getElementById(\"\".concat(props.id, \"-item-\").concat(store.getState().activeItemId));\n if (nodeItem) {\n if (nodeItem.scrollIntoViewIfNeeded) {\n nodeItem.scrollIntoViewIfNeeded(false);\n } else {\n nodeItem.scrollIntoView(false);\n }\n }\n }; // eslint-disable-next-line no-inner-declarations\n var triggerOnActive = function triggerOnActive() {\n var highlightedItem = getActiveItem(store.getState());\n if (store.getState().activeItemId !== null && highlightedItem) {\n var item = highlightedItem.item,\n itemInputValue = highlightedItem.itemInputValue,\n itemUrl = highlightedItem.itemUrl,\n source = highlightedItem.source;\n source.onActive(_objectSpread({\n event: event,\n item: item,\n itemInputValue: itemInputValue,\n itemUrl: itemUrl,\n refresh: refresh,\n source: source,\n state: store.getState()\n }, setters));\n }\n }; // Default browser behavior changes the caret placement on ArrowUp and\n // ArrowDown.\n event.preventDefault();\n\n // When re-opening the panel, we need to split the logic to keep the actions\n // synchronized as `onInput` returns a promise.\n if (store.getState().isOpen === false && (props.openOnFocus || Boolean(store.getState().query))) {\n onInput(_objectSpread({\n event: event,\n props: props,\n query: store.getState().query,\n refresh: refresh,\n store: store\n }, setters)).then(function () {\n store.dispatch(event.key, {\n nextActiveItemId: props.defaultActiveItemId\n });\n triggerOnActive();\n // Since we rely on the DOM, we need to wait for all the micro tasks to\n // finish (which include re-opening the panel) to make sure all the\n // elements are available.\n setTimeout(triggerScrollIntoView, 0);\n });\n } else {\n store.dispatch(event.key, {});\n triggerOnActive();\n triggerScrollIntoView();\n }\n } else if (event.key === 'Escape') {\n // This prevents the default browser behavior on `input[type=\"search\"]`\n // from removing the query right away because we first want to close the\n // panel.\n event.preventDefault();\n store.dispatch(event.key, null);\n\n // Hitting the `Escape` key signals the end of a user interaction with the\n // autocomplete. At this point, we should ignore any requests that are still\n // pending and could reopen the panel once they resolve, because that would\n // result in an unsolicited UI behavior.\n store.pendingRequests.cancelAll();\n } else if (event.key === 'Tab') {\n store.dispatch('blur', null);\n\n // Hitting the `Escape` key signals the end of a user interaction with the\n // autocomplete. At this point, we should ignore any requests that are still\n // pending and could reopen the panel once they resolve, because that would\n // result in an unsolicited UI behavior.\n store.pendingRequests.cancelAll();\n } else if (event.key === 'Enter') {\n // No active item, so we let the browser handle the native `onSubmit` form\n // event.\n if (store.getState().activeItemId === null || store.getState().collections.every(function (collection) {\n return collection.items.length === 0;\n })) {\n // If requests are still pending when the panel closes, they could reopen\n // the panel once they resolve.\n // We want to prevent any subsequent query from reopening the panel\n // because it would result in an unsolicited UI behavior.\n if (!props.debug) {\n store.pendingRequests.cancelAll();\n }\n return;\n }\n\n // This prevents the `onSubmit` event to be sent because an item is\n // highlighted.\n event.preventDefault();\n var _ref2 = getActiveItem(store.getState()),\n item = _ref2.item,\n itemInputValue = _ref2.itemInputValue,\n itemUrl = _ref2.itemUrl,\n source = _ref2.source;\n if (event.metaKey || event.ctrlKey) {\n if (itemUrl !== undefined) {\n source.onSelect(_objectSpread({\n event: event,\n item: item,\n itemInputValue: itemInputValue,\n itemUrl: itemUrl,\n refresh: refresh,\n source: source,\n state: store.getState()\n }, setters));\n props.navigator.navigateNewTab({\n itemUrl: itemUrl,\n item: item,\n state: store.getState()\n });\n }\n } else if (event.shiftKey) {\n if (itemUrl !== undefined) {\n source.onSelect(_objectSpread({\n event: event,\n item: item,\n itemInputValue: itemInputValue,\n itemUrl: itemUrl,\n refresh: refresh,\n source: source,\n state: store.getState()\n }, setters));\n props.navigator.navigateNewWindow({\n itemUrl: itemUrl,\n item: item,\n state: store.getState()\n });\n }\n } else if (event.altKey) {\n // Keep native browser behavior\n } else {\n if (itemUrl !== undefined) {\n source.onSelect(_objectSpread({\n event: event,\n item: item,\n itemInputValue: itemInputValue,\n itemUrl: itemUrl,\n refresh: refresh,\n source: source,\n state: store.getState()\n }, setters));\n props.navigator.navigate({\n itemUrl: itemUrl,\n item: item,\n state: store.getState()\n });\n return;\n }\n onInput(_objectSpread({\n event: event,\n nextState: {\n isOpen: false\n },\n props: props,\n query: itemInputValue,\n refresh: refresh,\n store: store\n }, setters)).then(function () {\n source.onSelect(_objectSpread({\n event: event,\n item: item,\n itemInputValue: itemInputValue,\n itemUrl: itemUrl,\n refresh: refresh,\n source: source,\n state: store.getState()\n }, setters));\n });\n }\n }\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nvar _excluded = [\"props\", \"refresh\", \"store\"],\n _excluded2 = [\"inputElement\", \"formElement\", \"panelElement\"],\n _excluded3 = [\"inputElement\"],\n _excluded4 = [\"inputElement\", \"maxLength\"],\n _excluded5 = [\"sourceIndex\"],\n _excluded6 = [\"sourceIndex\"],\n _excluded7 = [\"item\", \"source\", \"sourceIndex\"];\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\nimport { noop } from '@algolia/autocomplete-shared';\nimport { onInput } from './onInput';\nimport { onKeyDown as _onKeyDown } from './onKeyDown';\nimport { getActiveItem, isOrContainsNode, isSamsung } from './utils';\nexport function getPropGetters(_ref) {\n var props = _ref.props,\n refresh = _ref.refresh,\n store = _ref.store,\n setters = _objectWithoutProperties(_ref, _excluded);\n var getEnvironmentProps = function getEnvironmentProps(providedProps) {\n var inputElement = providedProps.inputElement,\n formElement = providedProps.formElement,\n panelElement = providedProps.panelElement,\n rest = _objectWithoutProperties(providedProps, _excluded2);\n function onMouseDownOrTouchStart(event) {\n // The `onTouchStart`/`onMouseDown` events shouldn't trigger the `blur`\n // handler when it's not an interaction with Autocomplete.\n // We detect it with the following heuristics:\n // - the panel is closed AND there are no pending requests\n // (no interaction with the autocomplete, no future state updates)\n // - OR the touched target is the input element (should open the panel)\n var isAutocompleteInteraction = store.getState().isOpen || !store.pendingRequests.isEmpty();\n if (!isAutocompleteInteraction || event.target === inputElement) {\n return;\n }\n\n // @TODO: support cases where there are multiple Autocomplete instances.\n // Right now, a second instance makes this computation return false.\n var isTargetWithinAutocomplete = [formElement, panelElement].some(function (contextNode) {\n return isOrContainsNode(contextNode, event.target);\n });\n if (isTargetWithinAutocomplete === false) {\n store.dispatch('blur', null);\n\n // If requests are still pending when the user closes the panel, they\n // could reopen the panel once they resolve.\n // We want to prevent any subsequent query from reopening the panel\n // because it would result in an unsolicited UI behavior.\n if (!props.debug) {\n store.pendingRequests.cancelAll();\n }\n }\n }\n return _objectSpread({\n // We do not rely on the native `blur` event of the input to close the\n // panel, but rather on a custom `touchstart`/`mousedown` event outside\n // of the autocomplete elements.\n // This ensures we don't mistakenly interpret interactions within the\n // autocomplete (but outside of the input) as a signal to close the panel.\n // For example, clicking reset button causes an input blur, but if\n // `openOnFocus=true`, it shouldn't close the panel.\n // On touch devices, scrolling results (`touchmove`) causes an input blur\n // but shouldn't close the panel.\n onTouchStart: onMouseDownOrTouchStart,\n onMouseDown: onMouseDownOrTouchStart,\n // When scrolling on touch devices (mobiles, tablets, etc.), we want to\n // mimic the native platform behavior where the input is blurred to\n // hide the virtual keyboard. This gives more vertical space to\n // discover all the suggestions showing up in the panel.\n onTouchMove: function onTouchMove(event) {\n if (store.getState().isOpen === false || inputElement !== props.environment.document.activeElement || event.target === inputElement) {\n return;\n }\n inputElement.blur();\n }\n }, rest);\n };\n var getRootProps = function getRootProps(rest) {\n return _objectSpread({\n role: 'combobox',\n 'aria-expanded': store.getState().isOpen,\n 'aria-haspopup': 'listbox',\n 'aria-owns': store.getState().isOpen ? \"\".concat(props.id, \"-list\") : undefined,\n 'aria-labelledby': \"\".concat(props.id, \"-label\")\n }, rest);\n };\n var getFormProps = function getFormProps(providedProps) {\n var inputElement = providedProps.inputElement,\n rest = _objectWithoutProperties(providedProps, _excluded3);\n return _objectSpread({\n action: '',\n noValidate: true,\n role: 'search',\n onSubmit: function onSubmit(event) {\n var _providedProps$inputE;\n event.preventDefault();\n props.onSubmit(_objectSpread({\n event: event,\n refresh: refresh,\n state: store.getState()\n }, setters));\n store.dispatch('submit', null);\n (_providedProps$inputE = providedProps.inputElement) === null || _providedProps$inputE === void 0 ? void 0 : _providedProps$inputE.blur();\n },\n onReset: function onReset(event) {\n var _providedProps$inputE2;\n event.preventDefault();\n props.onReset(_objectSpread({\n event: event,\n refresh: refresh,\n state: store.getState()\n }, setters));\n store.dispatch('reset', null);\n (_providedProps$inputE2 = providedProps.inputElement) === null || _providedProps$inputE2 === void 0 ? void 0 : _providedProps$inputE2.focus();\n }\n }, rest);\n };\n var getInputProps = function getInputProps(providedProps) {\n var _props$environment$na;\n function onFocus(event) {\n // We want to trigger a query when `openOnFocus` is true\n // because the panel should open with the current query.\n if (props.openOnFocus || Boolean(store.getState().query)) {\n onInput(_objectSpread({\n event: event,\n props: props,\n query: store.getState().completion || store.getState().query,\n refresh: refresh,\n store: store\n }, setters));\n }\n store.dispatch('focus', null);\n }\n var _ref2 = providedProps || {},\n inputElement = _ref2.inputElement,\n _ref2$maxLength = _ref2.maxLength,\n maxLength = _ref2$maxLength === void 0 ? 512 : _ref2$maxLength,\n rest = _objectWithoutProperties(_ref2, _excluded4);\n var activeItem = getActiveItem(store.getState());\n var userAgent = ((_props$environment$na = props.environment.navigator) === null || _props$environment$na === void 0 ? void 0 : _props$environment$na.userAgent) || '';\n var shouldFallbackKeyHint = isSamsung(userAgent);\n var enterKeyHint = activeItem !== null && activeItem !== void 0 && activeItem.itemUrl && !shouldFallbackKeyHint ? 'go' : 'search';\n return _objectSpread({\n 'aria-autocomplete': 'both',\n 'aria-activedescendant': store.getState().isOpen && store.getState().activeItemId !== null ? \"\".concat(props.id, \"-item-\").concat(store.getState().activeItemId) : undefined,\n 'aria-controls': store.getState().isOpen ? \"\".concat(props.id, \"-list\") : undefined,\n 'aria-labelledby': \"\".concat(props.id, \"-label\"),\n value: store.getState().completion || store.getState().query,\n id: \"\".concat(props.id, \"-input\"),\n autoComplete: 'off',\n autoCorrect: 'off',\n autoCapitalize: 'off',\n enterKeyHint: enterKeyHint,\n spellCheck: 'false',\n autoFocus: props.autoFocus,\n placeholder: props.placeholder,\n maxLength: maxLength,\n type: 'search',\n onChange: function onChange(event) {\n onInput(_objectSpread({\n event: event,\n props: props,\n query: event.currentTarget.value.slice(0, maxLength),\n refresh: refresh,\n store: store\n }, setters));\n },\n onKeyDown: function onKeyDown(event) {\n _onKeyDown(_objectSpread({\n event: event,\n props: props,\n refresh: refresh,\n store: store\n }, setters));\n },\n onFocus: onFocus,\n // We don't rely on the `blur` event.\n // See explanation in `onTouchStart`/`onMouseDown`.\n // @MAJOR See if we need to keep this handler.\n onBlur: noop,\n onClick: function onClick(event) {\n // When the panel is closed and you click on the input while\n // the input is focused, the `onFocus` event is not triggered\n // (default browser behavior).\n // In an autocomplete context, it makes sense to open the panel in this\n // case.\n // We mimic this event by catching the `onClick` event which\n // triggers the `onFocus` for the panel to open.\n if (providedProps.inputElement === props.environment.document.activeElement && !store.getState().isOpen) {\n onFocus(event);\n }\n }\n }, rest);\n };\n var getAutocompleteId = function getAutocompleteId(instanceId, sourceId) {\n return typeof sourceId !== 'undefined' ? \"\".concat(instanceId, \"-\").concat(sourceId) : instanceId;\n };\n var getLabelProps = function getLabelProps(providedProps) {\n var _ref3 = providedProps || {},\n sourceIndex = _ref3.sourceIndex,\n rest = _objectWithoutProperties(_ref3, _excluded5);\n return _objectSpread({\n htmlFor: \"\".concat(getAutocompleteId(props.id, sourceIndex), \"-input\"),\n id: \"\".concat(getAutocompleteId(props.id, sourceIndex), \"-label\")\n }, rest);\n };\n var getListProps = function getListProps(providedProps) {\n var _ref4 = providedProps || {},\n sourceIndex = _ref4.sourceIndex,\n rest = _objectWithoutProperties(_ref4, _excluded6);\n return _objectSpread({\n role: 'listbox',\n 'aria-labelledby': \"\".concat(getAutocompleteId(props.id, sourceIndex), \"-label\"),\n id: \"\".concat(getAutocompleteId(props.id, sourceIndex), \"-list\")\n }, rest);\n };\n var getPanelProps = function getPanelProps(rest) {\n return _objectSpread({\n onMouseDown: function onMouseDown(event) {\n // Prevents the `activeElement` from being changed to the panel so\n // that the blur event is not triggered, otherwise it closes the\n // panel.\n event.preventDefault();\n },\n onMouseLeave: function onMouseLeave() {\n store.dispatch('mouseleave', null);\n }\n }, rest);\n };\n var getItemProps = function getItemProps(providedProps) {\n var item = providedProps.item,\n source = providedProps.source,\n sourceIndex = providedProps.sourceIndex,\n rest = _objectWithoutProperties(providedProps, _excluded7);\n return _objectSpread({\n id: \"\".concat(getAutocompleteId(props.id, sourceIndex), \"-item-\").concat(item.__autocomplete_id),\n role: 'option',\n 'aria-selected': store.getState().activeItemId === item.__autocomplete_id,\n onMouseMove: function onMouseMove(event) {\n if (item.__autocomplete_id === store.getState().activeItemId) {\n return;\n }\n store.dispatch('mousemove', item.__autocomplete_id);\n var activeItem = getActiveItem(store.getState());\n if (store.getState().activeItemId !== null && activeItem) {\n var _item = activeItem.item,\n itemInputValue = activeItem.itemInputValue,\n itemUrl = activeItem.itemUrl,\n _source = activeItem.source;\n _source.onActive(_objectSpread({\n event: event,\n item: _item,\n itemInputValue: itemInputValue,\n itemUrl: itemUrl,\n refresh: refresh,\n source: _source,\n state: store.getState()\n }, setters));\n }\n },\n onMouseDown: function onMouseDown(event) {\n // Prevents the `activeElement` from being changed to the item so it\n // can remain with the current `activeElement`.\n event.preventDefault();\n },\n onClick: function onClick(event) {\n var itemInputValue = source.getItemInputValue({\n item: item,\n state: store.getState()\n });\n var itemUrl = source.getItemUrl({\n item: item,\n state: store.getState()\n });\n\n // If `getItemUrl` is provided, it means that the suggestion\n // is a link, not plain text that aims at updating the query.\n // We can therefore skip the state change because it will update\n // the `activeItemId`, resulting in a UI flash, especially\n // noticeable on mobile.\n var runPreCommand = itemUrl ? Promise.resolve() : onInput(_objectSpread({\n event: event,\n nextState: {\n isOpen: false\n },\n props: props,\n query: itemInputValue,\n refresh: refresh,\n store: store\n }, setters));\n runPreCommand.then(function () {\n source.onSelect(_objectSpread({\n event: event,\n item: item,\n itemInputValue: itemInputValue,\n itemUrl: itemUrl,\n refresh: refresh,\n source: source,\n state: store.getState()\n }, setters));\n });\n }\n }, rest);\n };\n return {\n getEnvironmentProps: getEnvironmentProps,\n getRootProps: getRootProps,\n getFormProps: getFormProps,\n getLabelProps: getLabelProps,\n getInputProps: getInputProps,\n getPanelProps: getPanelProps,\n getListProps: getListProps,\n getItemProps: getItemProps\n };\n}","export function isOrContainsNode(parent, child) {\n return parent === child || parent.contains(child);\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport { userAgents } from '@algolia/autocomplete-shared';\nexport function getMetadata(_ref) {\n var _, _options$__autocomple, _options$__autocomple2, _options$__autocomple3;\n var plugins = _ref.plugins,\n options = _ref.options;\n var optionsKey = (_ = (((_options$__autocomple = options.__autocomplete_metadata) === null || _options$__autocomple === void 0 ? void 0 : _options$__autocomple.userAgents) || [])[0]) === null || _ === void 0 ? void 0 : _.segment;\n var extraOptions = optionsKey ? _defineProperty({}, optionsKey, Object.keys(((_options$__autocomple2 = options.__autocomplete_metadata) === null || _options$__autocomple2 === void 0 ? void 0 : _options$__autocomple2.options) || {})) : {};\n return {\n plugins: plugins.map(function (plugin) {\n return {\n name: plugin.name,\n options: Object.keys(plugin.__autocomplete_pluginOptions || [])\n };\n }),\n options: _objectSpread({\n 'autocomplete-core': Object.keys(options)\n }, extraOptions),\n ua: userAgents.concat(((_options$__autocomple3 = options.__autocomplete_metadata) === null || _options$__autocomple3 === void 0 ? void 0 : _options$__autocomple3.userAgents) || [])\n };\n}\nexport function injectMetadata(_ref3) {\n var _environment$navigato, _environment$navigato2;\n var metadata = _ref3.metadata,\n environment = _ref3.environment;\n var isMetadataEnabled = (_environment$navigato = environment.navigator) === null || _environment$navigato === void 0 ? void 0 : (_environment$navigato2 = _environment$navigato.userAgent) === null || _environment$navigato2 === void 0 ? void 0 : _environment$navigato2.includes('Algolia Crawler');\n if (isMetadataEnabled) {\n var metadataContainer = environment.document.createElement('meta');\n var headRef = environment.document.querySelector('head');\n metadataContainer.name = 'algolia:metadata';\n setTimeout(function () {\n metadataContainer.content = JSON.stringify(metadata);\n headRef.appendChild(metadataContainer);\n }, 0);\n }\n}","import { getActiveItem } from './utils';\nexport function getCompletion(_ref) {\n var _getActiveItem;\n var state = _ref.state;\n if (state.isOpen === false || state.activeItemId === null) {\n return null;\n }\n return ((_getActiveItem = getActiveItem(state)) === null || _getActiveItem === void 0 ? void 0 : _getActiveItem.itemInputValue) || null;\n}","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport { getItemsCount, invariant } from '@algolia/autocomplete-shared';\nimport { getCompletion } from './getCompletion';\nimport { getNextActiveItemId } from './utils';\nexport var stateReducer = function stateReducer(state, action) {\n switch (action.type) {\n case 'setActiveItemId':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n activeItemId: action.payload\n });\n }\n case 'setQuery':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n query: action.payload,\n completion: null\n });\n }\n case 'setCollections':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n collections: action.payload\n });\n }\n case 'setIsOpen':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n isOpen: action.payload\n });\n }\n case 'setStatus':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n status: action.payload\n });\n }\n case 'setContext':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n context: _objectSpread(_objectSpread({}, state.context), action.payload)\n });\n }\n case 'ArrowDown':\n {\n var nextState = _objectSpread(_objectSpread({}, state), {}, {\n activeItemId: action.payload.hasOwnProperty('nextActiveItemId') ? action.payload.nextActiveItemId : getNextActiveItemId(1, state.activeItemId, getItemsCount(state), action.props.defaultActiveItemId)\n });\n return _objectSpread(_objectSpread({}, nextState), {}, {\n completion: getCompletion({\n state: nextState\n })\n });\n }\n case 'ArrowUp':\n {\n var _nextState = _objectSpread(_objectSpread({}, state), {}, {\n activeItemId: getNextActiveItemId(-1, state.activeItemId, getItemsCount(state), action.props.defaultActiveItemId)\n });\n return _objectSpread(_objectSpread({}, _nextState), {}, {\n completion: getCompletion({\n state: _nextState\n })\n });\n }\n case 'Escape':\n {\n if (state.isOpen) {\n return _objectSpread(_objectSpread({}, state), {}, {\n activeItemId: null,\n isOpen: false,\n completion: null\n });\n }\n return _objectSpread(_objectSpread({}, state), {}, {\n activeItemId: null,\n query: '',\n status: 'idle',\n collections: []\n });\n }\n case 'submit':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n activeItemId: null,\n isOpen: false,\n status: 'idle'\n });\n }\n case 'reset':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n activeItemId:\n // Since we open the panel on reset when openOnFocus=true\n // we need to restore the highlighted index to the defaultActiveItemId. (DocSearch use-case)\n\n // Since we close the panel when openOnFocus=false\n // we lose track of the highlighted index. (Query-suggestions use-case)\n action.props.openOnFocus === true ? action.props.defaultActiveItemId : null,\n status: 'idle',\n query: ''\n });\n }\n case 'focus':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n activeItemId: action.props.defaultActiveItemId,\n isOpen: (action.props.openOnFocus || Boolean(state.query)) && action.props.shouldPanelOpen({\n state: state\n })\n });\n }\n case 'blur':\n {\n if (action.props.debug) {\n return state;\n }\n return _objectSpread(_objectSpread({}, state), {}, {\n isOpen: false,\n activeItemId: null\n });\n }\n case 'mousemove':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n activeItemId: action.payload\n });\n }\n case 'mouseleave':\n {\n return _objectSpread(_objectSpread({}, state), {}, {\n activeItemId: action.props.defaultActiveItemId\n });\n }\n default:\n invariant(false, \"The reducer action \".concat(JSON.stringify(action.type), \" is not supported.\"));\n return state;\n }\n};","function _typeof(obj) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \"function\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }, _typeof(obj); }\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nimport { createAlgoliaInsightsPlugin } from '@algolia/autocomplete-plugin-algolia-insights';\nimport { checkOptions } from './checkOptions';\nimport { createStore } from './createStore';\nimport { getAutocompleteSetters } from './getAutocompleteSetters';\nimport { getDefaultProps } from './getDefaultProps';\nimport { getPropGetters } from './getPropGetters';\nimport { getMetadata, injectMetadata } from './metadata';\nimport { onInput } from './onInput';\nimport { stateReducer } from './stateReducer';\nexport function createAutocomplete(options) {\n checkOptions(options);\n var subscribers = [];\n var props = getDefaultProps(options, subscribers);\n var store = createStore(stateReducer, props, onStoreStateChange);\n var setters = getAutocompleteSetters({\n store: store\n });\n var propGetters = getPropGetters(_objectSpread({\n props: props,\n refresh: refresh,\n store: store,\n navigator: props.navigator\n }, setters));\n function onStoreStateChange(_ref) {\n var prevState = _ref.prevState,\n state = _ref.state;\n props.onStateChange(_objectSpread({\n prevState: prevState,\n state: state,\n refresh: refresh,\n navigator: props.navigator\n }, setters));\n }\n function refresh() {\n return onInput(_objectSpread({\n event: new Event('input'),\n nextState: {\n isOpen: store.getState().isOpen\n },\n props: props,\n navigator: props.navigator,\n query: store.getState().query,\n refresh: refresh,\n store: store\n }, setters));\n }\n if (options.insights && !props.plugins.some(function (plugin) {\n return plugin.name === 'aa.algoliaInsightsPlugin';\n })) {\n var insightsParams = typeof options.insights === 'boolean' ? {} : options.insights;\n props.plugins.push(createAlgoliaInsightsPlugin(insightsParams));\n }\n props.plugins.forEach(function (plugin) {\n var _plugin$subscribe;\n return (_plugin$subscribe = plugin.subscribe) === null || _plugin$subscribe === void 0 ? void 0 : _plugin$subscribe.call(plugin, _objectSpread(_objectSpread({}, setters), {}, {\n navigator: props.navigator,\n refresh: refresh,\n onSelect: function onSelect(fn) {\n subscribers.push({\n onSelect: fn\n });\n },\n onActive: function onActive(fn) {\n subscribers.push({\n onActive: fn\n });\n },\n onResolve: function onResolve(fn) {\n subscribers.push({\n onResolve: fn\n });\n }\n }));\n });\n injectMetadata({\n metadata: getMetadata({\n plugins: props.plugins,\n options: options\n }),\n environment: props.environment\n });\n return _objectSpread(_objectSpread({\n refresh: refresh,\n navigator: props.navigator\n }, propGetters), setters);\n}","import React from 'react';\n\ntype AlgoliaLogoTranslations = Partial<{\n searchByText: string;\n}>;\n\ntype AlgoliaLogoProps = {\n translations?: AlgoliaLogoTranslations;\n};\n\nexport function AlgoliaLogo({ translations = {} }: AlgoliaLogoProps) {\n const { searchByText = 'Search by' } = translations;\n\n return (\n \n {searchByText}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n );\n}\n","import React from 'react';\n\nimport { AlgoliaLogo } from './AlgoliaLogo';\n\nexport type FooterTranslations = Partial<{\n selectText: string;\n selectKeyAriaLabel: string;\n navigateText: string;\n navigateUpKeyAriaLabel: string;\n navigateDownKeyAriaLabel: string;\n closeText: string;\n closeKeyAriaLabel: string;\n searchByText: string;\n}>;\n\ntype FooterProps = Partial<{\n translations: FooterTranslations;\n}>;\n\ninterface CommandIconProps {\n children: React.ReactNode;\n ariaLabel: string;\n}\n\nfunction CommandIcon(props: CommandIconProps) {\n return (\n \n \n {props.children}\n \n \n );\n}\n\nexport function Footer({ translations = {} }: FooterProps) {\n const {\n selectText = 'to select',\n selectKeyAriaLabel = 'Enter key',\n navigateText = 'to navigate',\n navigateUpKeyAriaLabel = 'Arrow up',\n navigateDownKeyAriaLabel = 'Arrow down',\n closeText = 'to close',\n closeKeyAriaLabel = 'Escape key',\n searchByText = 'Search by',\n } = translations;\n\n return (\n <>\n
\n \n
\n
    \n
  • \n \n \n \n \n \n {selectText}\n
  • \n
  • \n \n \n \n \n \n \n \n \n \n \n {navigateText}\n
  • \n
  • \n \n \n \n \n \n {closeText}\n
  • \n
\n \n );\n}\n","import React from 'react';\n\nimport type { InternalDocSearchHit, StoredDocSearchHit } from './types';\n\ninterface HitProps {\n hit: InternalDocSearchHit | StoredDocSearchHit;\n children: React.ReactNode;\n}\n\nexport function Hit({ hit, children }: HitProps) {\n return {children};\n}\n","import React from 'react';\n\nexport function LoadingIcon() {\n return (\n \n \n \n \n \n \n \n \n \n \n );\n}\n","import React from 'react';\n\nexport function RecentIcon() {\n return (\n \n \n \n \n \n \n );\n}\n","import React from 'react';\n\nexport function ResetIcon() {\n return (\n \n \n \n );\n}\n","import React from 'react';\n\nexport function SelectIcon() {\n return (\n \n \n \n \n \n \n );\n}\n","import React from 'react';\n\nconst LvlIcon: React.FC = () => {\n return (\n \n \n \n );\n};\n\nexport function SourceIcon(props: { type: string }) {\n switch (props.type) {\n case 'lvl1':\n return ;\n case 'content':\n return ;\n default:\n return ;\n }\n}\n\nfunction AnchorIcon() {\n return (\n \n \n \n );\n}\n\nfunction ContentIcon() {\n return (\n \n \n \n );\n}\n","import React from 'react';\n\nexport function StarIcon() {\n return (\n \n \n \n );\n}\n","import React from 'react';\n\nexport function ErrorIcon() {\n return (\n \n \n \n );\n}\n","import React from 'react';\n\nexport function NoResultsIcon() {\n return (\n \n \n \n );\n}\n","import React from 'react';\n\nimport { ErrorIcon } from './icons';\n\nexport type ErrorScreenTranslations = Partial<{\n titleText: string;\n helpText: string;\n}>;\n\ntype ErrorScreenProps = {\n translations?: ErrorScreenTranslations;\n};\n\nexport function ErrorScreen({ translations = {} }: ErrorScreenProps) {\n const {\n titleText = 'Unable to fetch results',\n helpText = 'You might want to check your network connection.',\n } = translations;\n return (\n
\n
\n \n
\n

{titleText}

\n

{helpText}

\n
\n );\n}\n","import React from 'react';\n\nimport { NoResultsIcon } from './icons';\nimport type { ScreenStateProps } from './ScreenState';\nimport type { InternalDocSearchHit } from './types';\n\nexport type NoResultsScreenTranslations = Partial<{\n noResultsText: string;\n suggestedQueryText: string;\n reportMissingResultsText: string;\n reportMissingResultsLinkText: string;\n}>;\n\ntype NoResultsScreenProps = Omit<\n ScreenStateProps,\n 'translations'\n> & {\n translations?: NoResultsScreenTranslations;\n};\n\nexport function NoResultsScreen({\n translations = {},\n ...props\n}: NoResultsScreenProps) {\n const {\n noResultsText = 'No results for',\n suggestedQueryText = 'Try searching for',\n reportMissingResultsText = 'Believe this query should return results?',\n reportMissingResultsLinkText = 'Let us know.',\n } = translations;\n const searchSuggestions: string[] | undefined = props.state.context\n .searchSuggestions as string[];\n\n return (\n
\n
\n \n
\n

\n {noResultsText} \"{props.state.query}\"\n

\n\n {searchSuggestions && searchSuggestions.length > 0 && (\n
\n

{suggestedQueryText}:

\n
    \n {searchSuggestions.slice(0, 3).reduce(\n (acc, search) => [\n ...acc,\n
  • \n {\n props.setQuery(search.toLowerCase() + ' ');\n props.refresh();\n props.inputRef.current!.focus();\n }}\n >\n {search}\n \n
  • ,\n ],\n []\n )}\n
\n
\n )}\n\n {props.getMissingResultsUrl && (\n

\n {`${reportMissingResultsText} `}\n \n {reportMissingResultsLinkText}\n \n

\n )}\n
\n );\n}\n","import { createElement } from 'react';\n\nimport type { StoredDocSearchHit } from './types';\n\nfunction getPropertyByPath(object: Record, path: string): any {\n const parts = path.split('.');\n\n return parts.reduce((prev, current) => {\n if (prev?.[current]) return prev[current];\n return null;\n }, object);\n}\n\ninterface SnippetProps {\n hit: TItem;\n attribute: string;\n tagName?: string;\n [prop: string]: unknown;\n}\n\nexport function Snippet({\n hit,\n attribute,\n tagName = 'span',\n ...rest\n}: SnippetProps) {\n return createElement(tagName, {\n ...rest,\n dangerouslySetInnerHTML: {\n __html:\n getPropertyByPath(hit, `_snippetResult.${attribute}.value`) ||\n getPropertyByPath(hit, attribute),\n },\n });\n}\n","import type {\n AutocompleteApi,\n AutocompleteState,\n BaseItem,\n} from '@algolia/autocomplete-core';\nimport React from 'react';\n\nimport type { DocSearchProps } from './DocSearch';\nimport { Snippet } from './Snippet';\nimport type { InternalDocSearchHit, StoredDocSearchHit } from './types';\n\ninterface ResultsProps\n extends AutocompleteApi<\n TItem,\n React.FormEvent,\n React.MouseEvent,\n React.KeyboardEvent\n > {\n title: string;\n collection: AutocompleteState['collections'][0];\n renderIcon: (props: { item: TItem; index: number }) => React.ReactNode;\n renderAction: (props: {\n item: TItem;\n runDeleteTransition: (cb: () => void) => void;\n runFavoriteTransition: (cb: () => void) => void;\n }) => React.ReactNode;\n onItemClick: (item: TItem, event: KeyboardEvent | MouseEvent) => void;\n hitComponent: DocSearchProps['hitComponent'];\n}\n\nexport function Results(\n props: ResultsProps\n) {\n if (!props.collection || props.collection.items.length === 0) {\n return null;\n }\n\n return (\n
\n
{props.title}
\n\n
    \n {props.collection.items.map((item, index) => {\n return (\n \n );\n })}\n
\n
\n );\n}\n\ninterface ResultProps extends ResultsProps {\n item: TItem;\n index: number;\n}\n\nfunction Result({\n item,\n index,\n renderIcon,\n renderAction,\n getItemProps,\n onItemClick,\n collection,\n hitComponent,\n}: ResultProps) {\n const [isDeleting, setIsDeleting] = React.useState(false);\n const [isFavoriting, setIsFavoriting] = React.useState(false);\n const action = React.useRef<(() => void) | null>(null);\n const Hit = hitComponent!;\n\n function runDeleteTransition(cb: () => void) {\n setIsDeleting(true);\n action.current = cb;\n }\n\n function runFavoriteTransition(cb: () => void) {\n setIsFavoriting(true);\n action.current = cb;\n }\n\n return (\n {\n if (action.current) {\n action.current();\n }\n }}\n {...getItemProps({\n item,\n source: collection.source,\n onClick(event) {\n onItemClick(item, event);\n },\n })}\n >\n \n
\n {renderIcon({ item, index })}\n\n {item.hierarchy[item.type] && item.type === 'lvl1' && (\n
\n \n {item.content && (\n \n )}\n
\n )}\n\n {item.hierarchy[item.type] &&\n (item.type === 'lvl2' ||\n item.type === 'lvl3' ||\n item.type === 'lvl4' ||\n item.type === 'lvl5' ||\n item.type === 'lvl6') && (\n
\n \n \n
\n )}\n\n {item.type === 'content' && (\n
\n \n \n
\n )}\n\n {renderAction({ item, runDeleteTransition, runFavoriteTransition })}\n
\n
\n \n );\n}\n","export function groupBy>(\n values: TValue[],\n predicate: (value: TValue) => string,\n maxResultsPerGroup?: number\n): Record {\n return values.reduce>((acc, item) => {\n const key = predicate(item);\n\n if (!acc.hasOwnProperty(key)) {\n acc[key] = [];\n }\n\n // We limit each section to show 5 hits maximum.\n // This acts as a frontend alternative to `distinct`.\n if (acc[key].length < (maxResultsPerGroup || 5)) {\n acc[key].push(item);\n }\n\n return acc;\n }, {});\n}\n","export function identity(x: TParam): TParam {\n return x;\n}\n","/**\n * Detect when an event is modified with a special key to let the browser\n * trigger its default behavior.\n */\nexport function isModifierEvent(\n event: TEvent\n): boolean {\n const isMiddleClick = (event as MouseEvent).button === 1;\n\n return (\n isMiddleClick ||\n event.altKey ||\n event.ctrlKey ||\n event.metaKey ||\n event.shiftKey\n );\n}\n","export function noop(..._args: any[]): void {}\n","import type { DocSearchHit, InternalDocSearchHit } from '../types';\n\nconst regexHighlightTags = /(|<\\/mark>)/g;\nconst regexHasHighlightTags = RegExp(regexHighlightTags.source);\n\nexport function removeHighlightTags(\n hit: DocSearchHit | InternalDocSearchHit\n): string {\n const internalDocSearchHit = hit as InternalDocSearchHit;\n\n if (!internalDocSearchHit.__docsearch_parent && !hit._highlightResult) {\n return hit.hierarchy.lvl0;\n }\n\n const { value } =\n (internalDocSearchHit.__docsearch_parent\n ? internalDocSearchHit.__docsearch_parent?._highlightResult?.hierarchy\n ?.lvl0\n : hit._highlightResult?.hierarchy?.lvl0) || {};\n\n return value && regexHasHighlightTags.test(value)\n ? value.replace(regexHighlightTags, '')\n : value;\n}\n","import React from 'react';\n\nimport { SelectIcon, SourceIcon } from './icons';\nimport { Results } from './Results';\nimport type { ScreenStateProps } from './ScreenState';\nimport type { InternalDocSearchHit } from './types';\nimport { removeHighlightTags } from './utils';\n\ntype ResultsScreenProps = Omit<\n ScreenStateProps,\n 'translations'\n>;\n\nexport function ResultsScreen(props: ResultsScreenProps) {\n return (\n
\n {props.state.collections.map((collection) => {\n if (collection.items.length === 0) {\n return null;\n }\n\n const title = removeHighlightTags(collection.items[0]);\n\n return (\n (\n <>\n {item.__docsearch_parent && (\n \n \n {item.__docsearch_parent !==\n collection.items[index + 1]?.__docsearch_parent ? (\n \n ) : (\n \n )}\n \n \n )}\n\n
\n \n
\n \n )}\n renderAction={() => (\n
\n \n
\n )}\n />\n );\n })}\n\n {props.resultsFooterComponent && (\n
\n \n
\n )}\n
\n );\n}\n","import React from 'react';\n\nimport { RecentIcon, ResetIcon, StarIcon } from './icons';\nimport { Results } from './Results';\nimport type { ScreenStateProps } from './ScreenState';\nimport type { InternalDocSearchHit } from './types';\n\nexport type StartScreenTranslations = Partial<{\n recentSearchesTitle: string;\n noRecentSearchesText: string;\n saveRecentSearchButtonTitle: string;\n removeRecentSearchButtonTitle: string;\n favoriteSearchesTitle: string;\n removeFavoriteSearchButtonTitle: string;\n}>;\n\ntype StartScreenProps = Omit<\n ScreenStateProps,\n 'translations'\n> & {\n hasCollections: boolean;\n translations?: StartScreenTranslations;\n};\n\nexport function StartScreen({ translations = {}, ...props }: StartScreenProps) {\n const {\n recentSearchesTitle = 'Recent',\n noRecentSearchesText = 'No recent searches',\n saveRecentSearchButtonTitle = 'Save this search',\n removeRecentSearchButtonTitle = 'Remove this search from history',\n favoriteSearchesTitle = 'Favorite',\n removeFavoriteSearchButtonTitle = 'Remove this search from favorites',\n } = translations;\n if (props.state.status === 'idle' && props.hasCollections === false) {\n if (props.disableUserPersonalization) {\n return null;\n }\n\n return (\n
\n

{noRecentSearchesText}

\n
\n );\n }\n\n if (props.hasCollections === false) {\n return null;\n }\n\n return (\n
\n (\n
\n \n
\n )}\n renderAction={({\n item,\n runFavoriteTransition,\n runDeleteTransition,\n }) => (\n <>\n
\n {\n event.preventDefault();\n event.stopPropagation();\n runFavoriteTransition(() => {\n props.favoriteSearches.add(item);\n props.recentSearches.remove(item);\n props.refresh();\n });\n }}\n >\n \n \n
\n
\n {\n event.preventDefault();\n event.stopPropagation();\n runDeleteTransition(() => {\n props.recentSearches.remove(item);\n props.refresh();\n });\n }}\n >\n \n \n
\n \n )}\n />\n\n (\n
\n \n
\n )}\n renderAction={({ item, runDeleteTransition }) => (\n
\n {\n event.preventDefault();\n event.stopPropagation();\n runDeleteTransition(() => {\n props.favoriteSearches.remove(item);\n props.refresh();\n });\n }}\n >\n \n \n
\n )}\n />\n
\n );\n}\n","import type {\n AutocompleteApi,\n AutocompleteState,\n BaseItem,\n} from '@algolia/autocomplete-core';\nimport React from 'react';\n\nimport type { DocSearchProps } from './DocSearch';\nimport type { ErrorScreenTranslations } from './ErrorScreen';\nimport { ErrorScreen } from './ErrorScreen';\nimport type { NoResultsScreenTranslations } from './NoResultsScreen';\nimport { NoResultsScreen } from './NoResultsScreen';\nimport { ResultsScreen } from './ResultsScreen';\nimport type { StartScreenTranslations } from './StartScreen';\nimport { StartScreen } from './StartScreen';\nimport type { StoredSearchPlugin } from './stored-searches';\nimport type { InternalDocSearchHit, StoredDocSearchHit } from './types';\n\nexport type ScreenStateTranslations = Partial<{\n errorScreen: ErrorScreenTranslations;\n startScreen: StartScreenTranslations;\n noResultsScreen: NoResultsScreenTranslations;\n}>;\n\nexport interface ScreenStateProps\n extends AutocompleteApi<\n TItem,\n React.FormEvent,\n React.MouseEvent,\n React.KeyboardEvent\n > {\n state: AutocompleteState;\n recentSearches: StoredSearchPlugin;\n favoriteSearches: StoredSearchPlugin;\n onItemClick: (\n item: InternalDocSearchHit,\n event: KeyboardEvent | MouseEvent\n ) => void;\n inputRef: React.MutableRefObject;\n hitComponent: DocSearchProps['hitComponent'];\n indexName: DocSearchProps['indexName'];\n disableUserPersonalization: boolean;\n resultsFooterComponent: DocSearchProps['resultsFooterComponent'];\n translations: ScreenStateTranslations;\n getMissingResultsUrl?: DocSearchProps['getMissingResultsUrl'];\n}\n\nexport const ScreenState = React.memo(\n ({ translations = {}, ...props }: ScreenStateProps) => {\n if (props.state.status === 'error') {\n return ;\n }\n\n const hasCollections = props.state.collections.some(\n (collection) => collection.items.length > 0\n );\n\n if (!props.state.query) {\n return (\n \n );\n }\n\n if (hasCollections === false) {\n return (\n \n );\n }\n\n return ;\n },\n function areEqual(_prevProps, nextProps) {\n // We don't update the screen when Autocomplete is loading or stalled to\n // avoid UI flashes:\n // - Empty screen → Results screen\n // - NoResults screen → NoResults screen with another query\n return (\n nextProps.state.status === 'loading' ||\n nextProps.state.status === 'stalled'\n );\n }\n);\n","import type {\n AutocompleteApi,\n AutocompleteState,\n} from '@algolia/autocomplete-core';\nimport type { MutableRefObject } from 'react';\nimport React from 'react';\n\nimport { MAX_QUERY_SIZE } from './constants';\nimport { LoadingIcon } from './icons/LoadingIcon';\nimport { ResetIcon } from './icons/ResetIcon';\nimport { SearchIcon } from './icons/SearchIcon';\nimport type { InternalDocSearchHit } from './types';\n\nexport type SearchBoxTranslations = Partial<{\n resetButtonTitle: string;\n resetButtonAriaLabel: string;\n cancelButtonText: string;\n cancelButtonAriaLabel: string;\n searchInputLabel: string;\n}>;\n\ninterface SearchBoxProps\n extends AutocompleteApi<\n InternalDocSearchHit,\n React.FormEvent,\n React.MouseEvent,\n React.KeyboardEvent\n > {\n state: AutocompleteState;\n autoFocus: boolean;\n inputRef: MutableRefObject;\n onClose: () => void;\n isFromSelection: boolean;\n translations?: SearchBoxTranslations;\n}\n\nexport function SearchBox({ translations = {}, ...props }: SearchBoxProps) {\n const {\n resetButtonTitle = 'Clear the query',\n resetButtonAriaLabel = 'Clear the query',\n cancelButtonText = 'Cancel',\n cancelButtonAriaLabel = 'Cancel',\n searchInputLabel = 'Search',\n } = translations;\n const { onReset } = props.getFormProps({\n inputElement: props.inputRef.current,\n });\n\n React.useEffect(() => {\n if (props.autoFocus && props.inputRef.current) {\n props.inputRef.current.focus();\n }\n }, [props.autoFocus, props.inputRef]);\n\n React.useEffect(() => {\n if (props.isFromSelection && props.inputRef.current) {\n props.inputRef.current.select();\n }\n }, [props.isFromSelection, props.inputRef]);\n\n return (\n <>\n {\n event.preventDefault();\n }}\n onReset={onReset}\n >\n \n\n
\n \n
\n\n \n\n