react-instantsearch 7.26.1 → 7.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/cjs/components/AutocompleteSearch.js +18 -11
  2. package/dist/cjs/components/Carousel.js +24 -17
  3. package/dist/cjs/components/index.js +5 -5
  4. package/dist/cjs/index.js +8 -88
  5. package/dist/cjs/lib/useStickToBottom.js +17 -11
  6. package/dist/cjs/types/PartialKeys.js +3 -0
  7. package/dist/cjs/types/Translatable.js +3 -0
  8. package/dist/cjs/types/index.js +6 -0
  9. package/dist/cjs/ui/Breadcrumb.js +31 -24
  10. package/dist/cjs/ui/ClearRefinements.js +19 -12
  11. package/dist/cjs/ui/CurrentRefinements.js +32 -26
  12. package/dist/cjs/ui/HierarchicalMenu.js +35 -28
  13. package/dist/cjs/ui/Highlight.js +20 -13
  14. package/dist/cjs/ui/HitsPerPage.js +21 -14
  15. package/dist/cjs/ui/InfiniteHits.js +38 -31
  16. package/dist/cjs/ui/InternalHighlight.js +14 -8
  17. package/dist/cjs/ui/Menu.js +32 -25
  18. package/dist/cjs/ui/Pagination.js +39 -32
  19. package/dist/cjs/ui/PoweredBy.js +23 -16
  20. package/dist/cjs/ui/RangeInput.js +34 -27
  21. package/dist/cjs/ui/RefinementList.js +40 -33
  22. package/dist/cjs/ui/ReverseHighlight.js +20 -13
  23. package/dist/cjs/ui/SearchBox.js +43 -36
  24. package/dist/cjs/ui/ShowMoreButton.js +13 -6
  25. package/dist/cjs/ui/Snippet.js +20 -13
  26. package/dist/cjs/ui/SortBy.js +21 -14
  27. package/dist/cjs/ui/Stats.js +18 -11
  28. package/dist/cjs/ui/ToggleRefinement.js +23 -16
  29. package/dist/cjs/ui/lib/capitalize.js +9 -2
  30. package/dist/cjs/ui/lib/index.js +6 -7
  31. package/dist/cjs/ui/lib/isModifierClick.js +9 -2
  32. package/dist/cjs/widgets/Autocomplete.js +243 -119
  33. package/dist/cjs/widgets/Breadcrumb.js +17 -10
  34. package/dist/cjs/widgets/Chat.js +69 -47
  35. package/dist/cjs/widgets/ClearRefinements.js +17 -10
  36. package/dist/cjs/widgets/CurrentRefinements.js +17 -10
  37. package/dist/cjs/widgets/FilterSuggestions.js +20 -13
  38. package/dist/cjs/widgets/FrequentlyBoughtTogether.js +23 -16
  39. package/dist/cjs/widgets/HierarchicalMenu.js +18 -11
  40. package/dist/cjs/widgets/Highlight.js +19 -12
  41. package/dist/cjs/widgets/Hits.js +24 -17
  42. package/dist/cjs/widgets/HitsPerPage.js +17 -10
  43. package/dist/cjs/widgets/InfiniteHits.js +17 -10
  44. package/dist/cjs/widgets/LookingSimilar.js +23 -16
  45. package/dist/cjs/widgets/Menu.js +18 -11
  46. package/dist/cjs/widgets/Pagination.js +18 -11
  47. package/dist/cjs/widgets/PoweredBy.js +16 -9
  48. package/dist/cjs/widgets/RangeInput.js +17 -10
  49. package/dist/cjs/widgets/RefinementList.js +23 -16
  50. package/dist/cjs/widgets/RelatedProducts.js +23 -16
  51. package/dist/cjs/widgets/ReverseHighlight.js +19 -12
  52. package/dist/cjs/widgets/SearchBox.js +20 -13
  53. package/dist/cjs/widgets/Snippet.js +19 -12
  54. package/dist/cjs/widgets/SortBy.js +17 -10
  55. package/dist/cjs/widgets/Stats.js +17 -10
  56. package/dist/cjs/widgets/ToggleRefinement.js +17 -10
  57. package/dist/cjs/widgets/TrendingItems.js +23 -16
  58. package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +32 -25
  59. package/dist/cjs/widgets/index.js +29 -76
  60. package/dist/cjs/widgets/index.umd.js +58 -59
  61. package/dist/es/widgets/Autocomplete.d.ts +8 -4
  62. package/dist/es/widgets/Autocomplete.js +146 -29
  63. package/dist/es/widgets/Chat.js +17 -4
  64. package/dist/umd/ReactInstantSearch.js +1190 -1003
  65. package/dist/umd/ReactInstantSearch.min.js +3 -3
  66. package/package.json +5 -5
@@ -1,4 +1,4 @@
1
- /*! React InstantSearch 7.26.1 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! React InstantSearch 7.27.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
@@ -24,7 +24,7 @@
24
24
 
25
25
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
26
26
 
27
- var version$2 = '7.26.1';
27
+ var version$2 = '7.27.0';
28
28
 
29
29
  function getDefaultExportFromCjs (x) {
30
30
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -10081,7 +10081,7 @@
10081
10081
  };
10082
10082
  }
10083
10083
 
10084
- var version = '4.90.0';
10084
+ var version = '4.91.0';
10085
10085
 
10086
10086
  function hydrateSearchClient(client, results) {
10087
10087
  if (!results) {
@@ -13192,6 +13192,7 @@
13192
13192
  var sendEvent;
13193
13193
  var setInput;
13194
13194
  var setOpen;
13195
+ var focusInput;
13195
13196
  var setIsClearing;
13196
13197
  var agentId = 'agentId' in options ? options.agentId : undefined;
13197
13198
  // Extract suggestions from the last assistant message's data-suggestions part
@@ -13348,6 +13349,9 @@
13348
13349
  open = o;
13349
13350
  render();
13350
13351
  };
13352
+ focusInput = function focusInput() {
13353
+ setOpen(true);
13354
+ };
13351
13355
  setInput = function setInput(i) {
13352
13356
  input = i;
13353
13357
  render();
@@ -13409,6 +13413,7 @@
13409
13413
  setIndexUiState: parent.setIndexUiState.bind(parent),
13410
13414
  setInput: setInput,
13411
13415
  setOpen: setOpen,
13416
+ focusInput: focusInput,
13412
13417
  setMessages: setMessages,
13413
13418
  suggestions: getSuggestionsFromMessages(_chatInstance.messages),
13414
13419
  isClearing: isClearing,
@@ -15519,6 +15524,11 @@
15519
15524
  return useConnector(connectPagination, props, additionalWidgetProperties);
15520
15525
  }
15521
15526
 
15527
+ /**
15528
+ * Logs a warning
15529
+ * This is used to log issues in development environment only.
15530
+ */ var warn = noop;
15531
+
15522
15532
  function toArray(value) {
15523
15533
  return Array.isArray(value) ? value : [
15524
15534
  value
@@ -18063,983 +18073,1003 @@
18063
18073
  };
18064
18074
  }
18065
18075
 
18066
- function createAutocompleteRecentSearchComponent(param) {
18076
+ function SparklesIcon(param) {
18067
18077
  var createElement = param.createElement;
18068
- return function AutocompleteRecentSearch(userProps) {
18069
- var item = userProps.item, children = userProps.children, onSelect = userProps.onSelect, onRemoveRecentSearch = userProps.onRemoveRecentSearch, onApply = userProps.onApply, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames;
18070
- return /*#__PURE__*/ createElement("div", {
18071
- onClick: onSelect,
18072
- className: cx('ais-AutocompleteItemWrapper ais-AutocompleteRecentSearchWrapper', classNames.root)
18073
- }, /*#__PURE__*/ createElement("div", {
18074
- className: cx('ais-AutocompleteItemContent', 'ais-AutocompleteRecentSearchItemContent', classNames.content)
18075
- }, /*#__PURE__*/ createElement("div", {
18076
- className: cx('ais-AutocompleteItemIcon', 'ais-AutocompleteRecentSearchItemIcon', classNames.content)
18077
- }, /*#__PURE__*/ createElement(ClockIcon, {
18078
- createElement: createElement
18079
- })), /*#__PURE__*/ createElement("div", {
18080
- className: cx('ais-AutocompleteItemContentBody', 'ais-AutocompleteRecentSearchItemContentBody', classNames.content)
18081
- }, children)), /*#__PURE__*/ createElement("div", {
18082
- className: cx('ais-AutocompleteItemActions', 'ais-AutocompleteRecentSearchItemActions', classNames.actions)
18083
- }, /*#__PURE__*/ createElement("button", {
18084
- className: cx('ais-AutocompleteItemActionButton', 'ais-AutocompleteRecentSearchItemDeleteButton', classNames.deleteButton),
18085
- title: "Remove ".concat(item.query, " from recent searches"),
18086
- onClick: function onClick(evt) {
18087
- evt.stopPropagation();
18088
- onRemoveRecentSearch();
18089
- }
18090
- }, /*#__PURE__*/ createElement(TrashIcon, {
18091
- createElement: createElement
18092
- })), /*#__PURE__*/ createElement("button", {
18093
- className: cx('ais-AutocompleteItemActionButton', 'ais-AutocompleteRecentSearchItemApplyButton', classNames.applyButton),
18094
- title: "Apply ".concat(item.query, " as search"),
18095
- onClick: function onClick(evt) {
18096
- evt.stopPropagation();
18097
- onApply();
18098
- }
18099
- }, /*#__PURE__*/ createElement(ApplyIcon, {
18100
- createElement: createElement
18101
- }))));
18102
- };
18078
+ return /*#__PURE__*/ createElement("svg", {
18079
+ xmlns: "http://www.w3.org/2000/svg",
18080
+ fill: "none",
18081
+ viewBox: "0 0 20 20"
18082
+ }, /*#__PURE__*/ createElement("path", {
18083
+ fill: "currentColor",
18084
+ fillRule: "evenodd",
18085
+ d: "M10 1.875c.27 0 .51.173.594.43l1.593 4.844a1.043 1.043 0 0 0 .664.664l4.844 1.593a.625.625 0 0 1 0 1.188l-4.844 1.593a1.043 1.043 0 0 0-.664.664l-1.593 4.844a.625.625 0 0 1-1.188 0l-1.593-4.844a1.042 1.042 0 0 0-.664-.664l-4.844-1.593a.625.625 0 0 1 0-1.188l4.844-1.593a1.042 1.042 0 0 0 .664-.664l1.593-4.844a.625.625 0 0 1 .594-.43ZM9 7.539A2.292 2.292 0 0 1 7.54 9L4.5 10l3.04 1A2.292 2.292 0 0 1 9 12.46l1 3.04 1-3.04A2.293 2.293 0 0 1 12.46 11l3.04-1-3.04-1A2.292 2.292 0 0 1 11 7.54L10 4.5 9 7.54ZM4.167 1.875c.345 0 .625.28.625.625v3.333a.625.625 0 0 1-1.25 0V2.5c0-.345.28-.625.625-.625ZM15.833 13.542c.345 0 .625.28.625.625V17.5a.625.625 0 1 1-1.25 0v-3.333c0-.345.28-.625.625-.625Z",
18086
+ clipRule: "evenodd"
18087
+ }), /*#__PURE__*/ createElement("path", {
18088
+ fill: "currentColor",
18089
+ fillRule: "evenodd",
18090
+ d: "M1.875 4.167c0-.346.28-.625.625-.625h3.333a.625.625 0 1 1 0 1.25H2.5a.625.625 0 0 1-.625-.625ZM13.542 15.833c0-.345.28-.625.625-.625H17.5a.625.625 0 0 1 0 1.25h-3.333a.625.625 0 0 1-.625-.625Z",
18091
+ clipRule: "evenodd"
18092
+ }));
18103
18093
  }
18104
-
18105
- function createAutocompleteSearchComponent(param) {
18094
+ function ArrowUpIcon(param) {
18106
18095
  var createElement = param.createElement;
18107
- return function AutocompleteSearch(userProps) {
18108
- var inputProps = userProps.inputProps, onClear = userProps.onClear, query = userProps.query, isSearchStalled = userProps.isSearchStalled;
18109
- var inputRef = inputProps.ref;
18110
- return /*#__PURE__*/ createElement("form", {
18111
- className: "ais-AutocompleteForm",
18112
- action: "",
18113
- noValidate: true,
18114
- role: "search",
18115
- onSubmit: function onSubmit(e) {
18116
- return e.preventDefault();
18117
- },
18118
- onReset: function onReset() {
18119
- var _inputRef_current;
18120
- return (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
18121
- }
18122
- }, /*#__PURE__*/ createElement("div", {
18123
- className: "ais-AutocompleteInputWrapperPrefix"
18124
- }, /*#__PURE__*/ createElement("label", {
18125
- className: "ais-AutocompleteLabel",
18126
- "aria-label": "Submit",
18127
- htmlFor: inputProps.id,
18128
- id: "".concat(inputProps.id, "-label")
18129
- }, /*#__PURE__*/ createElement("button", {
18130
- className: "ais-AutocompleteSubmitButton",
18131
- type: "submit",
18132
- title: "Submit"
18133
- }, /*#__PURE__*/ createElement(SubmitIcon, {
18134
- createElement: createElement
18135
- }))), /*#__PURE__*/ createElement("div", {
18136
- className: "ais-AutocompleteLoadingIndicator",
18137
- hidden: !isSearchStalled
18138
- }, /*#__PURE__*/ createElement(LoadingIcon, {
18139
- createElement: createElement
18140
- }))), /*#__PURE__*/ createElement("div", {
18141
- className: "ais-AutocompleteInputWrapper"
18142
- }, /*#__PURE__*/ createElement("input", _object_spreadExports._({
18143
- className: "ais-AutocompleteInput",
18144
- "aria-autocomplete": "both",
18145
- "aria-labelledby": "".concat(inputProps.id, "-label"),
18146
- autoComplete: "off",
18147
- autoCorrect: "off",
18148
- autoCapitalize: "off",
18149
- enterKeyHint: "search",
18150
- spellCheck: "false",
18151
- maxLength: 512,
18152
- type: "search",
18153
- value: query
18154
- }, inputProps))), /*#__PURE__*/ createElement("div", {
18155
- className: "ais-AutocompleteInputWrapperSuffix"
18156
- }, /*#__PURE__*/ createElement("button", {
18157
- className: "ais-AutocompleteClearButton",
18158
- type: "reset",
18159
- title: "Clear",
18160
- hidden: query.length === 0 || isSearchStalled,
18161
- onClick: onClear
18162
- }, /*#__PURE__*/ createElement(ClearIcon, {
18163
- createElement: createElement
18164
- }))));
18165
- };
18096
+ return /*#__PURE__*/ createElement("svg", {
18097
+ xmlns: "http://www.w3.org/2000/svg",
18098
+ viewBox: "0 0 24 24",
18099
+ fill: "none",
18100
+ stroke: "currentColor",
18101
+ strokeLinecap: "round",
18102
+ strokeLinejoin: "round"
18103
+ }, /*#__PURE__*/ createElement("path", {
18104
+ d: "m5 12 7-7 7 7"
18105
+ }), /*#__PURE__*/ createElement("path", {
18106
+ d: "M12 19V5"
18107
+ }));
18166
18108
  }
18167
-
18168
- function createAutocompleteSuggestionComponent(param) {
18109
+ function ArrowRightIcon(param) {
18169
18110
  var createElement = param.createElement;
18170
- return function AutocompleteSuggestion(userProps) {
18171
- var item = userProps.item, children = userProps.children, onSelect = userProps.onSelect, onApply = userProps.onApply, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames;
18172
- return /*#__PURE__*/ createElement("div", {
18173
- onClick: onSelect,
18174
- className: cx('ais-AutocompleteItemWrapper', 'ais-AutocompleteSuggestionWrapper', classNames.root)
18175
- }, /*#__PURE__*/ createElement("div", {
18176
- className: cx('ais-AutocompleteItemContent', 'ais-AutocompleteSuggestionItemContent', classNames.content)
18177
- }, /*#__PURE__*/ createElement("div", {
18178
- className: cx('ais-AutocompleteItemIcon', 'ais-AutocompleteSuggestionItemIcon', classNames.content)
18179
- }, /*#__PURE__*/ createElement(SubmitIcon, {
18180
- createElement: createElement
18181
- })), /*#__PURE__*/ createElement("div", {
18182
- className: cx('ais-AutocompleteItemContentBody', 'ais-AutocompleteSuggestionItemContentBody', classNames.content)
18183
- }, children)), /*#__PURE__*/ createElement("div", {
18184
- className: cx('ais-AutocompleteItemActions', 'ais-AutocompleteSuggestionItemActions', classNames.actions)
18185
- }, /*#__PURE__*/ createElement("button", {
18186
- className: cx('ais-AutocompleteItemActionButton', 'ais-AutocompleteSuggestionItemApplyButton', classNames.applyButton),
18187
- type: "button",
18188
- title: "Apply ".concat(item.query, " as search"),
18189
- onClick: function onClick(evt) {
18190
- evt.stopPropagation();
18191
- onApply();
18192
- }
18193
- }, /*#__PURE__*/ createElement(ApplyIcon, {
18194
- createElement: createElement
18195
- }))));
18196
- };
18111
+ return /*#__PURE__*/ createElement("svg", {
18112
+ xmlns: "http://www.w3.org/2000/svg",
18113
+ viewBox: "0 0 24 24",
18114
+ fill: "none",
18115
+ stroke: "currentColor",
18116
+ strokeLinecap: "round",
18117
+ strokeLinejoin: "round"
18118
+ }, /*#__PURE__*/ createElement("path", {
18119
+ d: "M5 12h14"
18120
+ }), /*#__PURE__*/ createElement("path", {
18121
+ d: "m12 5 7 7-7 7"
18122
+ }));
18197
18123
  }
18198
-
18199
- function find(array, predicate) {
18200
- for(var index = 0; index < array.length; index++){
18201
- var item = array[index];
18202
- if (predicate(item, index, array)) {
18203
- return item;
18204
- }
18205
- }
18206
- return undefined;
18124
+ function ChevronUpIcon(param) {
18125
+ var createElement = param.createElement;
18126
+ return /*#__PURE__*/ createElement("svg", {
18127
+ xmlns: "http://www.w3.org/2000/svg",
18128
+ viewBox: "0 0 24 24",
18129
+ fill: "none",
18130
+ stroke: "currentColor",
18131
+ strokeLinecap: "round",
18132
+ strokeLinejoin: "round"
18133
+ }, /*#__PURE__*/ createElement("path", {
18134
+ d: "m18 15-6-6-6 6"
18135
+ }));
18207
18136
  }
18208
-
18209
- function createAutocompletePropGetters(param) {
18210
- var useEffect = param.useEffect, useId = param.useId, useMemo = param.useMemo, useRef = param.useRef, useState = param.useState;
18211
- return function usePropGetters(param) {
18212
- var indices = param.indices, indicesConfig = param.indicesConfig, onRefine = param.onRefine, globalOnSelect = param.onSelect, onApply = param.onApply, onSubmit = param.onSubmit, placeholder = param.placeholder, _param_isDetached = param.isDetached, isDetached = _param_isDetached === void 0 ? false : _param_isDetached;
18213
- var getElementId = createGetElementId(useId());
18214
- var inputRef = useRef(null);
18215
- var rootRef = useRef(null);
18216
- var _useState = _sliced_to_arrayExports._(useState(false), 2), isOpen = _useState[0], setIsOpen = _useState[1];
18217
- var _useState1 = _sliced_to_arrayExports._(useState(undefined), 2), activeDescendant = _useState1[0], setActiveDescendant = _useState1[1];
18218
- var _useMemo = useMemo(function() {
18219
- return buildItems({
18220
- indices: indices,
18221
- indicesConfig: indicesConfig,
18222
- getElementId: getElementId
18223
- });
18224
- }, [
18225
- indices,
18226
- indicesConfig,
18227
- getElementId
18228
- ]), items = _useMemo.items, itemsIds = _useMemo.itemsIds;
18229
- useEffect(function() {
18230
- // In detached mode, we don't close the panel on body click
18231
- // because the overlay handles closing
18232
- if (isDetached) {
18233
- return function() {};
18234
- }
18235
- var onBodyClick = function onBodyClick(event) {
18236
- var _unwrapRef;
18237
- if ((_unwrapRef = unwrapRef(rootRef)) === null || _unwrapRef === void 0 ? void 0 : _unwrapRef.contains(event.target)) {
18238
- return;
18239
- }
18240
- setIsOpen(false);
18241
- };
18242
- document.body.addEventListener('click', onBodyClick);
18243
- return function() {
18244
- document.body.removeEventListener('click', onBodyClick);
18245
- };
18246
- }, [
18247
- rootRef,
18248
- isDetached
18249
- ]);
18250
- var getNextActiveDescendant = function getNextActiveDescendant(key) {
18251
- switch(key){
18252
- case 'ArrowUp':
18253
- {
18254
- var prevIndex = itemsIds.indexOf(activeDescendant || '') - 1;
18255
- return itemsIds[prevIndex] || itemsIds[itemsIds.length - 1];
18256
- }
18257
- case 'ArrowDown':
18258
- {
18259
- var nextIndex = itemsIds.indexOf(activeDescendant || '') + 1;
18260
- return itemsIds[nextIndex] || itemsIds[0];
18261
- }
18262
- default:
18263
- return undefined;
18264
- }
18265
- };
18266
- var submit = function submit() {
18267
- var override = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
18268
- var _override_activeDescendant;
18269
- if (isOpen) {
18270
- setIsOpen(false);
18271
- } else {
18272
- var _inputRef_current;
18273
- (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.blur();
18274
- }
18275
- var actualDescendant = (_override_activeDescendant = override.activeDescendant) !== null && _override_activeDescendant !== void 0 ? _override_activeDescendant : activeDescendant;
18276
- if (!actualDescendant && override.query) {
18277
- onRefine(override.query);
18278
- }
18279
- if (actualDescendant && items.has(actualDescendant)) {
18280
- var _ref;
18281
- var _items_get = items.get(actualDescendant), item = _items_get.item, _items_get_config = _items_get.config, indexOnSelect = _items_get_config.onSelect, getQuery = _items_get_config.getQuery, getURL = _items_get_config.getURL;
18282
- var actualOnSelect = indexOnSelect !== null && indexOnSelect !== void 0 ? indexOnSelect : globalOnSelect;
18283
- actualOnSelect({
18284
- item: item,
18285
- query: (_ref = getQuery === null || getQuery === void 0 ? void 0 : getQuery(item)) !== null && _ref !== void 0 ? _ref : '',
18286
- url: getURL === null || getURL === void 0 ? void 0 : getURL(item),
18287
- setQuery: function setQuery(query) {
18288
- return onRefine(query);
18289
- }
18290
- });
18291
- setActiveDescendant(undefined);
18292
- }
18293
- onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit();
18294
- };
18295
- return {
18296
- getInputProps: function getInputProps() {
18297
- return {
18298
- id: getElementId('input'),
18299
- ref: inputRef,
18300
- role: 'combobox',
18301
- 'aria-autocomplete': 'list',
18302
- 'aria-expanded': isOpen,
18303
- 'aria-haspopup': 'grid',
18304
- 'aria-controls': getElementId('panel'),
18305
- 'aria-activedescendant': activeDescendant,
18306
- placeholder: placeholder,
18307
- onFocus: function onFocus() {
18308
- return setIsOpen(true);
18309
- },
18310
- onKeyDown: function onKeyDown(event) {
18311
- switch(event.key){
18312
- case 'Escape':
18313
- {
18314
- if (isOpen) {
18315
- setIsOpen(false);
18316
- event.preventDefault();
18317
- } else {
18318
- setActiveDescendant(undefined);
18319
- }
18320
- break;
18321
- }
18322
- case 'ArrowUp':
18323
- case 'ArrowDown':
18324
- {
18325
- var _document_getElementById;
18326
- setIsOpen(true);
18327
- var nextActiveDescendant = getNextActiveDescendant(event.key);
18328
- setActiveDescendant(nextActiveDescendant);
18329
- (_document_getElementById = document.getElementById(nextActiveDescendant)) === null || _document_getElementById === void 0 ? void 0 : _document_getElementById.scrollIntoView(false);
18330
- event.preventDefault();
18331
- break;
18332
- }
18333
- case 'Enter':
18334
- {
18335
- submit({
18336
- query: event.target.value
18337
- });
18338
- break;
18339
- }
18340
- case 'Tab':
18341
- // In detached mode, Tab doesn't close the panel
18342
- if (!isDetached) {
18343
- setIsOpen(false);
18344
- }
18345
- break;
18346
- default:
18347
- setIsOpen(true);
18348
- return;
18349
- }
18350
- },
18351
- onKeyUp: function onKeyUp(event) {
18352
- switch(event.key){
18353
- case 'ArrowLeft':
18354
- case 'ArrowUp':
18355
- case 'ArrowRight':
18356
- case 'ArrowDown':
18357
- case 'Escape':
18358
- case 'Return':
18359
- event.preventDefault();
18360
- return;
18361
- default:
18362
- setActiveDescendant(undefined);
18363
- break;
18364
- }
18365
- }
18366
- };
18367
- },
18368
- getItemProps: function getItemProps(item, index) {
18369
- var id = getElementId('item', item.__indexName, index);
18370
- return {
18371
- id: id,
18372
- role: 'row',
18373
- 'aria-selected': id === activeDescendant,
18374
- onSelect: function onSelect() {
18375
- return submit({
18376
- activeDescendant: id
18377
- });
18378
- },
18379
- onApply: function onApply1() {
18380
- var _ref;
18381
- var _items_get = items.get(id), currentItem = _items_get.item, getQuery = _items_get.config.getQuery;
18382
- onApply((_ref = getQuery === null || getQuery === void 0 ? void 0 : getQuery(currentItem)) !== null && _ref !== void 0 ? _ref : '');
18383
- }
18384
- };
18385
- },
18386
- getPanelProps: function getPanelProps() {
18387
- return {
18388
- hidden: !isOpen,
18389
- id: getElementId('panel'),
18390
- role: 'grid',
18391
- 'aria-labelledby': getElementId('input')
18392
- };
18393
- },
18394
- getRootProps: function getRootProps() {
18395
- return {
18396
- ref: rootRef
18397
- };
18398
- },
18399
- isOpen: isOpen,
18400
- setIsOpen: setIsOpen,
18401
- focusInput: function focusInput() {
18402
- var _inputRef_current;
18403
- (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
18404
- }
18405
- };
18406
- };
18407
- }
18408
- function buildItems(param) {
18409
- var _loop = function _loop(i) {
18410
- var _indices_i;
18411
- var currentIndexConfig = find(indicesConfig, function(config) {
18412
- return config.indexName === indices[i].indexName;
18413
- });
18414
- var hits = ((_indices_i = indices[i]) === null || _indices_i === void 0 ? void 0 : _indices_i.hits) || [];
18415
- for(var position = 0; position < hits.length; position++){
18416
- var itemId = getElementId('item', (currentIndexConfig === null || currentIndexConfig === void 0 ? void 0 : currentIndexConfig.indexName) || indices[i].indexName, position);
18417
- items.set(itemId, {
18418
- item: hits[position],
18419
- config: currentIndexConfig
18420
- });
18421
- itemsIds.push(itemId);
18422
- }
18423
- };
18424
- var indices = param.indices, indicesConfig = param.indicesConfig, getElementId = param.getElementId;
18425
- var itemsIds = [];
18426
- var items = new Map();
18427
- for(var i = 0; i < indices.length; i++)_loop(i);
18428
- return {
18429
- items: items,
18430
- itemsIds: itemsIds
18431
- };
18432
- }
18433
- function createGetElementId(autocompleteId) {
18434
- return function getElementId() {
18435
- for(var _len = arguments.length, suffixes = new Array(_len), _key = 0; _key < _len; _key++){
18436
- suffixes[_key] = arguments[_key];
18437
- }
18438
- var prefix = 'autocomplete';
18439
- return "".concat(prefix).concat(autocompleteId).concat(suffixes.join(':'));
18440
- };
18137
+ function ChevronDownIcon(param) {
18138
+ var createElement = param.createElement;
18139
+ return /*#__PURE__*/ createElement("svg", {
18140
+ xmlns: "http://www.w3.org/2000/svg",
18141
+ viewBox: "0 0 24 24",
18142
+ fill: "none",
18143
+ stroke: "currentColor",
18144
+ strokeLinecap: "round",
18145
+ strokeLinejoin: "round"
18146
+ }, /*#__PURE__*/ createElement("path", {
18147
+ d: "m6 9 6 6 6-6"
18148
+ }));
18441
18149
  }
18442
- /**
18443
- * Returns the framework-agnostic value of a ref.
18444
- */ function unwrapRef(ref) {
18445
- return ref.current && _type_ofExports._(ref.current) === 'object' && 'base' in ref.current ? ref.current.base // Preact
18446
- : ref.current; // React
18150
+ function CloseIcon(param) {
18151
+ var createElement = param.createElement;
18152
+ return /*#__PURE__*/ createElement("svg", {
18153
+ xmlns: "http://www.w3.org/2000/svg",
18154
+ viewBox: "0 0 24 24",
18155
+ fill: "none",
18156
+ stroke: "currentColor",
18157
+ strokeLinecap: "round",
18158
+ strokeLinejoin: "round"
18159
+ }, /*#__PURE__*/ createElement("path", {
18160
+ d: "M18 6 6 18"
18161
+ }), /*#__PURE__*/ createElement("path", {
18162
+ d: "m6 6 12 12"
18163
+ }));
18447
18164
  }
18448
-
18449
- function createAutocompleteStorage(param) {
18450
- var useEffect = param.useEffect, useMemo = param.useMemo, useState = param.useState;
18451
- return function useStorage(param) {
18452
- var showRecent = param.showRecent, query = param.query, indices = param.indices, indicesConfig = param.indicesConfig, suggestionsIndexName = param.suggestionsIndexName;
18453
- var storageKey = showRecent && (typeof showRecent === "undefined" ? "undefined" : _type_ofExports._(showRecent)) === 'object' ? showRecent.storageKey : undefined;
18454
- var storage = useMemo(function() {
18455
- return createStorage({
18456
- limit: 5,
18457
- storageKey: storageKey
18458
- });
18459
- }, [
18460
- storageKey
18461
- ]);
18462
- var _useState = _sliced_to_arrayExports._(useState(storage.getSnapshot()), 2), snapshot = _useState[0], setSnapshot = _useState[1];
18463
- useEffect(function() {
18464
- storage.registerUpdateListener(function() {
18465
- setSnapshot(storage.getSnapshot());
18466
- });
18467
- return function() {
18468
- storage.unregisterUpdateListener();
18469
- };
18470
- }, [
18471
- storage
18472
- ]);
18473
- if (!showRecent) {
18474
- return {
18475
- storage: {
18476
- onAdd: function onAdd() {},
18477
- onRemove: function onRemove() {}
18478
- },
18479
- storageHits: [],
18480
- indicesForPropGetters: indices,
18481
- indicesConfigForPropGetters: indicesConfig
18482
- };
18483
- }
18484
- var storageHits = snapshot.getAll(query).map(function(value) {
18485
- return {
18486
- objectID: value,
18487
- query: value,
18488
- __indexName: 'recent-searches',
18489
- _highlightResult: getHighlightedAttribute({
18490
- item: {
18491
- query: value
18492
- },
18493
- query: query || ''
18494
- })
18495
- };
18496
- });
18497
- var indicesForPropGetters = _to_consumable_arrayExports._(indices.map(function(index) {
18498
- return index.indexName === suggestionsIndexName ? _object_spread_propsExports._(_object_spreadExports._({}, index), {
18499
- hits: index.hits.filter(function(hit) {
18500
- return !find(storageHits, function(storageHit) {
18501
- return storageHit.query === hit.query;
18502
- });
18503
- })
18504
- }) : index;
18505
- }));
18506
- var indicesConfigForPropGetters = _to_consumable_arrayExports._(indicesConfig);
18507
- indicesForPropGetters.unshift({
18508
- indexName: 'recent-searches',
18509
- indexId: 'recent-searches',
18510
- hits: storageHits
18511
- });
18512
- indicesConfigForPropGetters.unshift({
18513
- indexName: 'recent-searches',
18514
- // @ts-expect-error - we know it has query as it's generated from storageHits
18515
- getQuery: function getQuery(item) {
18516
- return item.query;
18517
- }
18518
- });
18519
- return {
18520
- storage: storage,
18521
- storageHits: storageHits,
18522
- indicesForPropGetters: indicesForPropGetters,
18523
- indicesConfigForPropGetters: indicesConfigForPropGetters
18524
- };
18525
- };
18165
+ function MaximizeIcon(param) {
18166
+ var createElement = param.createElement;
18167
+ return /*#__PURE__*/ createElement("svg", {
18168
+ xmlns: "http://www.w3.org/2000/svg",
18169
+ viewBox: "0 0 24 24",
18170
+ fill: "none",
18171
+ stroke: "currentColor",
18172
+ strokeLinecap: "round",
18173
+ strokeLinejoin: "round"
18174
+ }, /*#__PURE__*/ createElement("path", {
18175
+ d: "M15 3h6v6"
18176
+ }), /*#__PURE__*/ createElement("path", {
18177
+ d: "m21 3-7 7"
18178
+ }), /*#__PURE__*/ createElement("path", {
18179
+ d: "m3 21 7-7"
18180
+ }), /*#__PURE__*/ createElement("path", {
18181
+ d: "M9 21H3v-6"
18182
+ }));
18526
18183
  }
18527
- var LOCAL_STORAGE_KEY_TEST = 'test-localstorage-support';
18528
- var LOCAL_STORAGE_KEY = 'autocomplete-recent-searches';
18529
- function isLocalStorageSupported() {
18530
- try {
18531
- localStorage.setItem(LOCAL_STORAGE_KEY_TEST, '');
18532
- localStorage.removeItem(LOCAL_STORAGE_KEY_TEST);
18533
- return true;
18534
- } catch (error) {
18535
- return false;
18536
- }
18184
+ function MinimizeIcon(param) {
18185
+ var createElement = param.createElement;
18186
+ return /*#__PURE__*/ createElement("svg", {
18187
+ xmlns: "http://www.w3.org/2000/svg",
18188
+ viewBox: "0 0 24 24",
18189
+ fill: "none",
18190
+ stroke: "currentColor",
18191
+ strokeLinecap: "round",
18192
+ strokeLinejoin: "round"
18193
+ }, /*#__PURE__*/ createElement("path", {
18194
+ d: "m14 10 7-7"
18195
+ }), /*#__PURE__*/ createElement("path", {
18196
+ d: "M20 10h-6V4"
18197
+ }), /*#__PURE__*/ createElement("path", {
18198
+ d: "m3 21 7-7"
18199
+ }), /*#__PURE__*/ createElement("path", {
18200
+ d: "M4 14h6v6"
18201
+ }));
18537
18202
  }
18538
- function getHighlightedAttribute(param) {
18539
- var item = param.item, query = param.query;
18540
- if (!query.trim().length) {
18541
- return {
18542
- query: {
18543
- matchLevel: 'none'
18544
- }
18545
- };
18546
- }
18547
- return {
18548
- query: {
18549
- value: item.query.replace(new RegExp(query.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'), 'gi'), function(match) {
18550
- return "<mark>".concat(match, "</mark>");
18551
- })
18552
- }
18553
- };
18203
+ function StopIcon(param) {
18204
+ var createElement = param.createElement;
18205
+ return /*#__PURE__*/ createElement("svg", {
18206
+ xmlns: "http://www.w3.org/2000/svg",
18207
+ viewBox: "0 0 24 24",
18208
+ fill: "none",
18209
+ stroke: "currentColor",
18210
+ strokeLinecap: "round",
18211
+ strokeLinejoin: "round"
18212
+ }, /*#__PURE__*/ createElement("circle", {
18213
+ cx: "12",
18214
+ cy: "12",
18215
+ r: "10"
18216
+ }), /*#__PURE__*/ createElement("rect", {
18217
+ x: "9",
18218
+ y: "9",
18219
+ width: "6",
18220
+ height: "6",
18221
+ rx: "1"
18222
+ }));
18554
18223
  }
18555
- function getLocalStorage() {
18556
- var key = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : LOCAL_STORAGE_KEY;
18557
- if (!isLocalStorageSupported()) {
18558
- return {
18559
- setItems: function setItems() {},
18560
- getItems: function getItems() {
18561
- return [];
18562
- }
18563
- };
18564
- }
18565
- return {
18566
- setItems: function setItems(items) {
18567
- try {
18568
- window.localStorage.setItem(key, JSON.stringify(items));
18569
- } catch (unused) {
18570
- // do nothing, this likely means the storage is full
18571
- }
18572
- },
18573
- getItems: function getItems() {
18574
- var items = window.localStorage.getItem(key);
18575
- return items ? JSON.parse(items) : [];
18576
- }
18577
- };
18224
+ function ReloadIcon(param) {
18225
+ var createElement = param.createElement;
18226
+ return /*#__PURE__*/ createElement("svg", {
18227
+ xmlns: "http://www.w3.org/2000/svg",
18228
+ viewBox: "0 0 24 24",
18229
+ fill: "none",
18230
+ stroke: "currentColor",
18231
+ strokeLinecap: "round",
18232
+ strokeLinejoin: "round"
18233
+ }, /*#__PURE__*/ createElement("path", {
18234
+ d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"
18235
+ }), /*#__PURE__*/ createElement("path", {
18236
+ d: "M21 3v5h-5"
18237
+ }), /*#__PURE__*/ createElement("path", {
18238
+ d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"
18239
+ }), /*#__PURE__*/ createElement("path", {
18240
+ d: "M3 21v-5h5"
18241
+ }));
18578
18242
  }
18579
- function createStorage(param) {
18580
- var _param_limit = param.limit, limit = _param_limit === void 0 ? 5 : _param_limit, storageKey = param.storageKey;
18581
- var storage = getLocalStorage(storageKey);
18582
- var updateListener = null;
18583
- return {
18584
- onAdd: function onAdd(query) {
18585
- this.onRemove(query);
18586
- storage.setItems([
18587
- query
18588
- ].concat(_to_consumable_arrayExports._(storage.getItems())));
18589
- },
18590
- onRemove: function onRemove(query) {
18591
- storage.setItems(storage.getItems().filter(function(q) {
18592
- return q !== query;
18593
- }));
18594
- updateListener === null || updateListener === void 0 ? void 0 : updateListener();
18595
- },
18596
- registerUpdateListener: function registerUpdateListener(callback) {
18597
- updateListener = callback;
18598
- },
18599
- unregisterUpdateListener: function unregisterUpdateListener() {
18600
- updateListener = null;
18601
- },
18602
- getSnapshot: function getSnapshot() {
18603
- return {
18604
- getAll: function getAll() {
18605
- var query = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '';
18606
- return storage.getItems().filter(function(q) {
18607
- return q.includes(query);
18608
- }).slice(0, limit);
18609
- }
18610
- };
18611
- }
18612
- };
18243
+ function CopyIcon(param) {
18244
+ var createElement = param.createElement;
18245
+ return /*#__PURE__*/ createElement("svg", {
18246
+ xmlns: "http://www.w3.org/2000/svg",
18247
+ viewBox: "0 0 24 24",
18248
+ fill: "none",
18249
+ stroke: "currentColor",
18250
+ strokeLinecap: "round",
18251
+ strokeLinejoin: "round"
18252
+ }, /*#__PURE__*/ createElement("rect", {
18253
+ width: "14",
18254
+ height: "14",
18255
+ x: "8",
18256
+ y: "8",
18257
+ rx: "2",
18258
+ ry: "2"
18259
+ }), /*#__PURE__*/ createElement("path", {
18260
+ d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
18261
+ }));
18613
18262
  }
18614
-
18615
- function createDefaultItemComponent(param) {
18616
- var createElement = param.createElement, Fragment = param.Fragment;
18617
- return function DefaultItem(userProps) {
18618
- return /*#__PURE__*/ createElement(Fragment, null, JSON.stringify(userProps.item, null, 2));
18619
- };
18263
+ function MenuIcon(param) {
18264
+ var createElement = param.createElement;
18265
+ return /*#__PURE__*/ createElement("svg", {
18266
+ xmlns: "http://www.w3.org/2000/svg",
18267
+ viewBox: "0 0 24 24",
18268
+ fill: "none",
18269
+ stroke: "currentColor",
18270
+ strokeLinecap: "round",
18271
+ strokeLinejoin: "round"
18272
+ }, /*#__PURE__*/ createElement("circle", {
18273
+ cx: "12",
18274
+ cy: "12",
18275
+ r: "1"
18276
+ }), /*#__PURE__*/ createElement("circle", {
18277
+ cx: "12",
18278
+ cy: "5",
18279
+ r: "1"
18280
+ }), /*#__PURE__*/ createElement("circle", {
18281
+ cx: "12",
18282
+ cy: "19",
18283
+ r: "1"
18284
+ }));
18620
18285
  }
18621
-
18622
- var lastCarouselId = 0;
18623
- function generateCarouselId() {
18624
- return "ais-Carousel-".concat(lastCarouselId++);
18286
+ function LoadingSpinnerIcon(param) {
18287
+ var createElement = param.createElement;
18288
+ return /*#__PURE__*/ createElement("svg", {
18289
+ viewBox: "12 12 24 24",
18290
+ role: "status",
18291
+ "aria-busy": "true",
18292
+ "aria-live": "polite"
18293
+ }, /*#__PURE__*/ createElement("title", null, "Loading spinner"), /*#__PURE__*/ createElement("circle", {
18294
+ cx: "24",
18295
+ cy: "24",
18296
+ r: "11",
18297
+ fill: "none",
18298
+ stroke: "currentColor"
18299
+ }));
18625
18300
  }
18626
- function PreviousIconDefaultComponent(param) {
18301
+ function ChevronLeftIcon(param) {
18627
18302
  var createElement = param.createElement;
18628
18303
  return /*#__PURE__*/ createElement("svg", {
18629
- width: "8",
18630
- height: "16",
18631
- viewBox: "0 0 8 16",
18632
- fill: "none"
18304
+ xmlns: "http://www.w3.org/2000/svg",
18305
+ viewBox: "0 0 24 24",
18306
+ fill: "none",
18307
+ stroke: "currentColor",
18308
+ strokeLinecap: "round",
18309
+ strokeLinejoin: "round"
18633
18310
  }, /*#__PURE__*/ createElement("path", {
18634
- fillRule: "evenodd",
18635
- clipRule: "evenodd",
18636
- fill: "currentColor",
18637
- d: "M7.13809 0.744078C7.39844 1.06951 7.39844 1.59715 7.13809 1.92259L2.27616 8L7.13809 14.0774C7.39844 14.4028 7.39844 14.9305 7.13809 15.2559C6.87774 15.5814 6.45563 15.5814 6.19528 15.2559L0.861949 8.58926C0.6016 8.26382 0.6016 7.73618 0.861949 7.41074L6.19528 0.744078C6.45563 0.418641 6.87774 0.418641 7.13809 0.744078Z"
18311
+ d: "m15 18-6-6 6-6"
18638
18312
  }));
18639
18313
  }
18640
- function NextIconDefaultComponent(param) {
18314
+ function ChevronRightIcon(param) {
18641
18315
  var createElement = param.createElement;
18642
18316
  return /*#__PURE__*/ createElement("svg", {
18643
- width: "8",
18644
- height: "16",
18645
- viewBox: "0 0 8 16",
18646
- fill: "none"
18317
+ xmlns: "http://www.w3.org/2000/svg",
18318
+ viewBox: "0 0 24 24",
18319
+ fill: "none",
18320
+ stroke: "currentColor",
18321
+ strokeLinecap: "round",
18322
+ strokeLinejoin: "round"
18647
18323
  }, /*#__PURE__*/ createElement("path", {
18648
- fillRule: "evenodd",
18649
- clipRule: "evenodd",
18650
- fill: "currentColor",
18651
- d: "M0.861908 15.2559C0.601559 14.9305 0.601559 14.4028 0.861908 14.0774L5.72384 8L0.861908 1.92259C0.601559 1.59715 0.601559 1.06952 0.861908 0.744079C1.12226 0.418642 1.54437 0.418642 1.80472 0.744079L7.13805 7.41074C7.3984 7.73618 7.3984 8.26382 7.13805 8.58926L1.80472 15.2559C1.54437 15.5814 1.12226 15.5814 0.861908 15.2559Z"
18324
+ d: "m9 18 6-6-6-6"
18652
18325
  }));
18653
18326
  }
18654
- function createCarouselComponent(param) {
18655
- var createElement = param.createElement, Fragment = param.Fragment;
18656
- return function Carousel(userProps) {
18657
- var listRef = userProps.listRef, nextButtonRef = userProps.nextButtonRef, previousButtonRef = userProps.previousButtonRef, carouselIdRef = userProps.carouselIdRef, canScrollLeft = userProps.canScrollLeft, canScrollRight = userProps.canScrollRight, setCanScrollLeft = userProps.setCanScrollLeft, setCanScrollRight = userProps.setCanScrollRight, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, tmp = userProps.itemComponent, ItemComponent = tmp === void 0 ? createDefaultItemComponent({
18658
- createElement: createElement,
18659
- Fragment: Fragment
18660
- }) : tmp, tmp1 = userProps.previousIconComponent, PreviousIcon = tmp1 === void 0 ? PreviousIconDefaultComponent : tmp1, tmp2 = userProps.nextIconComponent, NextIcon = tmp2 === void 0 ? NextIconDefaultComponent : tmp2, HeaderComponent = userProps.headerComponent, _userProps_showNavigation = userProps.showNavigation, showNavigation = _userProps_showNavigation === void 0 ? true : _userProps_showNavigation, items = userProps.items, userTranslations = userProps.translations, sendEvent = userProps.sendEvent, props = _object_without_propertiesExports._(userProps, [
18661
- "listRef",
18662
- "nextButtonRef",
18663
- "previousButtonRef",
18664
- "carouselIdRef",
18665
- "canScrollLeft",
18666
- "canScrollRight",
18667
- "setCanScrollLeft",
18668
- "setCanScrollRight",
18669
- "classNames",
18670
- "itemComponent",
18671
- "previousIconComponent",
18672
- "nextIconComponent",
18673
- "headerComponent",
18674
- "showNavigation",
18675
- "items",
18676
- "translations",
18677
- "sendEvent"
18678
- ]);
18679
- var translations = _object_spreadExports._({
18680
- listLabel: 'Items',
18681
- nextButtonLabel: 'Next',
18682
- nextButtonTitle: 'Next',
18683
- previousButtonLabel: 'Previous',
18684
- previousButtonTitle: 'Previous'
18685
- }, userTranslations);
18686
- var cssClasses = {
18687
- root: cx('ais-Carousel', classNames.root),
18688
- list: cx('ais-Carousel-list', classNames.list),
18689
- item: cx('ais-Carousel-item', classNames.item),
18690
- navigation: cx('ais-Carousel-navigation', classNames.navigation),
18691
- navigationNext: cx('ais-Carousel-navigation--next', classNames.navigationNext),
18692
- navigationPrevious: cx('ais-Carousel-navigation--previous', classNames.navigationPrevious)
18693
- };
18694
- function scrollLeft() {
18695
- if (listRef.current) {
18696
- listRef.current.scrollLeft -= listRef.current.offsetWidth * 0.75;
18327
+
18328
+ function createAutocompletePromptSuggestionComponent(param) {
18329
+ var createElement = param.createElement;
18330
+ return function AutocompletePromptSuggestion(userProps) {
18331
+ var item = userProps.item, onSelect = userProps.onSelect, children = userProps.children, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames;
18332
+ var label = item.label || item.prompt;
18333
+ return /*#__PURE__*/ createElement("div", {
18334
+ onClick: onSelect,
18335
+ className: cx('ais-AutocompleteItemWrapper', 'ais-AutocompletePromptSuggestionWrapper', classNames.root)
18336
+ }, /*#__PURE__*/ createElement("div", {
18337
+ className: cx('ais-AutocompleteItemContent', 'ais-AutocompletePromptSuggestionItemContent', classNames.content)
18338
+ }, /*#__PURE__*/ createElement("div", {
18339
+ className: cx('ais-AutocompleteItemIcon', 'ais-AutocompletePromptSuggestionItemIcon', classNames.icon)
18340
+ }, /*#__PURE__*/ createElement(SparklesIcon, {
18341
+ createElement: createElement
18342
+ })), /*#__PURE__*/ createElement("div", {
18343
+ className: cx('ais-AutocompleteItemContentBody', 'ais-AutocompletePromptSuggestionItemContentBody', classNames.body)
18344
+ }, children !== null && children !== void 0 ? children : label)));
18345
+ };
18346
+ }
18347
+
18348
+ function createAutocompleteRecentSearchComponent(param) {
18349
+ var createElement = param.createElement;
18350
+ return function AutocompleteRecentSearch(userProps) {
18351
+ var item = userProps.item, children = userProps.children, onSelect = userProps.onSelect, onRemoveRecentSearch = userProps.onRemoveRecentSearch, onApply = userProps.onApply, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames;
18352
+ return /*#__PURE__*/ createElement("div", {
18353
+ onClick: onSelect,
18354
+ className: cx('ais-AutocompleteItemWrapper ais-AutocompleteRecentSearchWrapper', classNames.root)
18355
+ }, /*#__PURE__*/ createElement("div", {
18356
+ className: cx('ais-AutocompleteItemContent', 'ais-AutocompleteRecentSearchItemContent', classNames.content)
18357
+ }, /*#__PURE__*/ createElement("div", {
18358
+ className: cx('ais-AutocompleteItemIcon', 'ais-AutocompleteRecentSearchItemIcon', classNames.content)
18359
+ }, /*#__PURE__*/ createElement(ClockIcon, {
18360
+ createElement: createElement
18361
+ })), /*#__PURE__*/ createElement("div", {
18362
+ className: cx('ais-AutocompleteItemContentBody', 'ais-AutocompleteRecentSearchItemContentBody', classNames.content)
18363
+ }, children)), /*#__PURE__*/ createElement("div", {
18364
+ className: cx('ais-AutocompleteItemActions', 'ais-AutocompleteRecentSearchItemActions', classNames.actions)
18365
+ }, /*#__PURE__*/ createElement("button", {
18366
+ className: cx('ais-AutocompleteItemActionButton', 'ais-AutocompleteRecentSearchItemDeleteButton', classNames.deleteButton),
18367
+ title: "Remove ".concat(item.query, " from recent searches"),
18368
+ onClick: function onClick(evt) {
18369
+ evt.stopPropagation();
18370
+ onRemoveRecentSearch();
18697
18371
  }
18698
- }
18699
- function scrollRight() {
18700
- if (listRef.current) {
18701
- listRef.current.scrollLeft += listRef.current.offsetWidth * 0.75;
18372
+ }, /*#__PURE__*/ createElement(TrashIcon, {
18373
+ createElement: createElement
18374
+ })), /*#__PURE__*/ createElement("button", {
18375
+ className: cx('ais-AutocompleteItemActionButton', 'ais-AutocompleteRecentSearchItemApplyButton', classNames.applyButton),
18376
+ title: "Apply ".concat(item.query, " as search"),
18377
+ onClick: function onClick(evt) {
18378
+ evt.stopPropagation();
18379
+ onApply();
18380
+ }
18381
+ }, /*#__PURE__*/ createElement(ApplyIcon, {
18382
+ createElement: createElement
18383
+ }))));
18384
+ };
18385
+ }
18386
+
18387
+ function createAutocompleteSearchComponent(param) {
18388
+ var createElement = param.createElement;
18389
+ return function AutocompleteSearch(userProps) {
18390
+ var inputProps = userProps.inputProps, onClear = userProps.onClear, query = userProps.query, isSearchStalled = userProps.isSearchStalled;
18391
+ var inputRef = inputProps.ref;
18392
+ return /*#__PURE__*/ createElement("form", {
18393
+ className: "ais-AutocompleteForm",
18394
+ action: "",
18395
+ noValidate: true,
18396
+ role: "search",
18397
+ onSubmit: function onSubmit(e) {
18398
+ return e.preventDefault();
18399
+ },
18400
+ onReset: function onReset() {
18401
+ var _inputRef_current;
18402
+ return (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
18403
+ }
18404
+ }, /*#__PURE__*/ createElement("div", {
18405
+ className: "ais-AutocompleteInputWrapperPrefix"
18406
+ }, /*#__PURE__*/ createElement("label", {
18407
+ className: "ais-AutocompleteLabel",
18408
+ "aria-label": "Submit",
18409
+ htmlFor: inputProps.id,
18410
+ id: "".concat(inputProps.id, "-label")
18411
+ }, /*#__PURE__*/ createElement("button", {
18412
+ className: "ais-AutocompleteSubmitButton",
18413
+ type: "submit",
18414
+ title: "Submit"
18415
+ }, /*#__PURE__*/ createElement(SubmitIcon, {
18416
+ createElement: createElement
18417
+ }))), /*#__PURE__*/ createElement("div", {
18418
+ className: "ais-AutocompleteLoadingIndicator",
18419
+ hidden: !isSearchStalled
18420
+ }, /*#__PURE__*/ createElement(LoadingIcon, {
18421
+ createElement: createElement
18422
+ }))), /*#__PURE__*/ createElement("div", {
18423
+ className: "ais-AutocompleteInputWrapper"
18424
+ }, /*#__PURE__*/ createElement("input", _object_spreadExports._({
18425
+ className: "ais-AutocompleteInput",
18426
+ "aria-autocomplete": "both",
18427
+ "aria-labelledby": "".concat(inputProps.id, "-label"),
18428
+ autoComplete: "off",
18429
+ autoCorrect: "off",
18430
+ autoCapitalize: "off",
18431
+ enterKeyHint: "search",
18432
+ spellCheck: "false",
18433
+ maxLength: 512,
18434
+ type: "search",
18435
+ value: query
18436
+ }, inputProps))), /*#__PURE__*/ createElement("div", {
18437
+ className: "ais-AutocompleteInputWrapperSuffix"
18438
+ }, /*#__PURE__*/ createElement("button", {
18439
+ className: "ais-AutocompleteClearButton",
18440
+ type: "reset",
18441
+ title: "Clear",
18442
+ hidden: query.length === 0 || isSearchStalled,
18443
+ onClick: onClear
18444
+ }, /*#__PURE__*/ createElement(ClearIcon, {
18445
+ createElement: createElement
18446
+ }))));
18447
+ };
18448
+ }
18449
+
18450
+ function createAutocompleteSuggestionComponent(param) {
18451
+ var createElement = param.createElement;
18452
+ return function AutocompleteSuggestion(userProps) {
18453
+ var item = userProps.item, children = userProps.children, onSelect = userProps.onSelect, onApply = userProps.onApply, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames;
18454
+ return /*#__PURE__*/ createElement("div", {
18455
+ onClick: onSelect,
18456
+ className: cx('ais-AutocompleteItemWrapper', 'ais-AutocompleteSuggestionWrapper', classNames.root)
18457
+ }, /*#__PURE__*/ createElement("div", {
18458
+ className: cx('ais-AutocompleteItemContent', 'ais-AutocompleteSuggestionItemContent', classNames.content)
18459
+ }, /*#__PURE__*/ createElement("div", {
18460
+ className: cx('ais-AutocompleteItemIcon', 'ais-AutocompleteSuggestionItemIcon', classNames.content)
18461
+ }, /*#__PURE__*/ createElement(SubmitIcon, {
18462
+ createElement: createElement
18463
+ })), /*#__PURE__*/ createElement("div", {
18464
+ className: cx('ais-AutocompleteItemContentBody', 'ais-AutocompleteSuggestionItemContentBody', classNames.content)
18465
+ }, children)), /*#__PURE__*/ createElement("div", {
18466
+ className: cx('ais-AutocompleteItemActions', 'ais-AutocompleteSuggestionItemActions', classNames.actions)
18467
+ }, /*#__PURE__*/ createElement("button", {
18468
+ className: cx('ais-AutocompleteItemActionButton', 'ais-AutocompleteSuggestionItemApplyButton', classNames.applyButton),
18469
+ type: "button",
18470
+ title: "Apply ".concat(item.query, " as search"),
18471
+ onClick: function onClick(evt) {
18472
+ evt.stopPropagation();
18473
+ onApply();
18702
18474
  }
18475
+ }, /*#__PURE__*/ createElement(ApplyIcon, {
18476
+ createElement: createElement
18477
+ }))));
18478
+ };
18479
+ }
18480
+
18481
+ function find(array, predicate) {
18482
+ for(var index = 0; index < array.length; index++){
18483
+ var item = array[index];
18484
+ if (predicate(item, index, array)) {
18485
+ return item;
18703
18486
  }
18704
- function updateNavigationButtonsProps() {
18705
- if (!listRef.current) {
18706
- return;
18487
+ }
18488
+ return undefined;
18489
+ }
18490
+
18491
+ function createAutocompletePropGetters(param) {
18492
+ var useEffect = param.useEffect, useId = param.useId, useMemo = param.useMemo, useRef = param.useRef, useState = param.useState;
18493
+ return function usePropGetters(param) {
18494
+ var indices = param.indices, indicesConfig = param.indicesConfig, onRefine = param.onRefine, globalOnSelect = param.onSelect, onApply = param.onApply, onSubmit = param.onSubmit, placeholder = param.placeholder, _param_isDetached = param.isDetached, isDetached = _param_isDetached === void 0 ? false : _param_isDetached;
18495
+ var getElementId = createGetElementId(useId());
18496
+ var inputRef = useRef(null);
18497
+ var rootRef = useRef(null);
18498
+ var _useState = _sliced_to_arrayExports._(useState(false), 2), isOpen = _useState[0], setIsOpen = _useState[1];
18499
+ var _useState1 = _sliced_to_arrayExports._(useState(undefined), 2), activeDescendant = _useState1[0], setActiveDescendant = _useState1[1];
18500
+ var _useMemo = useMemo(function() {
18501
+ return buildItems({
18502
+ indices: indices,
18503
+ indicesConfig: indicesConfig,
18504
+ getElementId: getElementId
18505
+ });
18506
+ }, [
18507
+ indices,
18508
+ indicesConfig,
18509
+ getElementId
18510
+ ]), items = _useMemo.items, itemsIds = _useMemo.itemsIds;
18511
+ useEffect(function() {
18512
+ // In detached mode, we don't close the panel on body click
18513
+ // because the overlay handles closing
18514
+ if (isDetached) {
18515
+ return function() {};
18707
18516
  }
18708
- var isLeftHidden = listRef.current.scrollLeft <= 0;
18709
- var isRightHidden = listRef.current.scrollLeft + listRef.current.clientWidth >= listRef.current.scrollWidth;
18710
- setCanScrollLeft(!isLeftHidden);
18711
- setCanScrollRight(!isRightHidden);
18712
- if (previousButtonRef.current) {
18713
- previousButtonRef.current.hidden = isLeftHidden;
18517
+ var onBodyClick = function onBodyClick(event) {
18518
+ var _unwrapRef;
18519
+ if ((_unwrapRef = unwrapRef(rootRef)) === null || _unwrapRef === void 0 ? void 0 : _unwrapRef.contains(event.target)) {
18520
+ return;
18521
+ }
18522
+ setIsOpen(false);
18523
+ };
18524
+ document.body.addEventListener('click', onBodyClick);
18525
+ return function() {
18526
+ document.body.removeEventListener('click', onBodyClick);
18527
+ };
18528
+ }, [
18529
+ rootRef,
18530
+ isDetached
18531
+ ]);
18532
+ var getNextActiveDescendant = function getNextActiveDescendant(key) {
18533
+ switch(key){
18534
+ case 'ArrowUp':
18535
+ {
18536
+ var prevIndex = itemsIds.indexOf(activeDescendant || '') - 1;
18537
+ return itemsIds[prevIndex] || itemsIds[itemsIds.length - 1];
18538
+ }
18539
+ case 'ArrowDown':
18540
+ {
18541
+ var nextIndex = itemsIds.indexOf(activeDescendant || '') + 1;
18542
+ return itemsIds[nextIndex] || itemsIds[0];
18543
+ }
18544
+ default:
18545
+ return undefined;
18714
18546
  }
18715
- if (nextButtonRef.current) {
18716
- nextButtonRef.current.hidden = isRightHidden;
18547
+ };
18548
+ var submit = function submit() {
18549
+ var override = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
18550
+ var _override_activeDescendant;
18551
+ if (isOpen) {
18552
+ setIsOpen(false);
18553
+ } else {
18554
+ var _inputRef_current;
18555
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.blur();
18717
18556
  }
18718
- }
18719
- if (items.length === 0) {
18720
- return null;
18721
- }
18722
- return /*#__PURE__*/ createElement("div", _object_spread_propsExports._(_object_spreadExports._({}, props), {
18723
- className: cx(cssClasses.root)
18724
- }), HeaderComponent && /*#__PURE__*/ createElement(HeaderComponent, {
18725
- canScrollLeft: canScrollLeft,
18726
- canScrollRight: canScrollRight,
18727
- scrollLeft: scrollLeft,
18728
- scrollRight: scrollRight
18729
- }), showNavigation && /*#__PURE__*/ createElement("button", {
18730
- ref: previousButtonRef,
18731
- title: translations.previousButtonTitle,
18732
- "aria-label": translations.previousButtonLabel,
18733
- hidden: true,
18734
- "aria-controls": carouselIdRef.current,
18735
- className: cx(cssClasses.navigation, cssClasses.navigationPrevious),
18736
- onClick: function onClick(event) {
18737
- event.preventDefault();
18738
- scrollLeft();
18557
+ var actualDescendant = (_override_activeDescendant = override.activeDescendant) !== null && _override_activeDescendant !== void 0 ? _override_activeDescendant : activeDescendant;
18558
+ if (!actualDescendant && override.query) {
18559
+ onRefine(override.query);
18739
18560
  }
18740
- }, /*#__PURE__*/ createElement(PreviousIcon, {
18741
- createElement: createElement
18742
- })), /*#__PURE__*/ createElement("ol", {
18743
- className: cx(cssClasses.list),
18744
- ref: listRef,
18745
- tabIndex: 0,
18746
- id: carouselIdRef.current,
18747
- "aria-roledescription": "carousel",
18748
- "aria-label": translations.listLabel,
18749
- "aria-live": "polite",
18750
- onScroll: updateNavigationButtonsProps,
18751
- onKeyDown: function onKeyDown(event) {
18752
- if (event.key === 'ArrowLeft') {
18753
- event.preventDefault();
18754
- scrollLeft();
18755
- } else if (event.key === 'ArrowRight') {
18756
- event.preventDefault();
18757
- scrollRight();
18758
- }
18561
+ if (actualDescendant && items.has(actualDescendant)) {
18562
+ var _ref;
18563
+ var _items_get = items.get(actualDescendant), item = _items_get.item, _items_get_config = _items_get.config, indexOnSelect = _items_get_config.onSelect, getQuery = _items_get_config.getQuery, getURL = _items_get_config.getURL;
18564
+ var actualOnSelect = indexOnSelect !== null && indexOnSelect !== void 0 ? indexOnSelect : globalOnSelect;
18565
+ actualOnSelect({
18566
+ item: item,
18567
+ query: (_ref = getQuery === null || getQuery === void 0 ? void 0 : getQuery(item)) !== null && _ref !== void 0 ? _ref : '',
18568
+ url: getURL === null || getURL === void 0 ? void 0 : getURL(item),
18569
+ setQuery: function setQuery(query) {
18570
+ return onRefine(query);
18571
+ }
18572
+ });
18573
+ setActiveDescendant(undefined);
18759
18574
  }
18760
- }, items.map(function(item, index) {
18761
- return /*#__PURE__*/ createElement("li", {
18762
- key: item.objectID,
18763
- className: cx(cssClasses.item),
18764
- "aria-roledescription": "slide",
18765
- "aria-label": "".concat(index + 1, " of ").concat(items.length),
18766
- onClick: function onClick() {
18767
- sendEvent('click:internal', item, 'Item Clicked');
18768
- },
18769
- onAuxClick: function onAuxClick() {
18770
- sendEvent('click:internal', item, 'Item Clicked');
18771
- }
18772
- }, /*#__PURE__*/ createElement(ItemComponent, {
18773
- item: item,
18774
- sendEvent: sendEvent
18775
- }));
18776
- })), showNavigation && /*#__PURE__*/ createElement("button", {
18777
- ref: nextButtonRef,
18778
- title: translations.nextButtonTitle,
18779
- "aria-label": translations.nextButtonLabel,
18780
- "aria-controls": carouselIdRef.current,
18781
- className: cx(cssClasses.navigation, cssClasses.navigationNext),
18782
- onClick: function onClick(event) {
18783
- event.preventDefault();
18784
- scrollRight();
18575
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit();
18576
+ };
18577
+ return {
18578
+ getInputProps: function getInputProps() {
18579
+ return {
18580
+ id: getElementId('input'),
18581
+ ref: inputRef,
18582
+ role: 'combobox',
18583
+ 'aria-autocomplete': 'list',
18584
+ 'aria-expanded': isOpen,
18585
+ 'aria-haspopup': 'grid',
18586
+ 'aria-controls': getElementId('panel'),
18587
+ 'aria-activedescendant': activeDescendant,
18588
+ placeholder: placeholder,
18589
+ onFocus: function onFocus() {
18590
+ return setIsOpen(true);
18591
+ },
18592
+ onKeyDown: function onKeyDown(event) {
18593
+ switch(event.key){
18594
+ case 'Escape':
18595
+ {
18596
+ if (isOpen) {
18597
+ setIsOpen(false);
18598
+ event.preventDefault();
18599
+ } else {
18600
+ setActiveDescendant(undefined);
18601
+ }
18602
+ break;
18603
+ }
18604
+ case 'ArrowUp':
18605
+ case 'ArrowDown':
18606
+ {
18607
+ var _document_getElementById;
18608
+ setIsOpen(true);
18609
+ var nextActiveDescendant = getNextActiveDescendant(event.key);
18610
+ setActiveDescendant(nextActiveDescendant);
18611
+ (_document_getElementById = document.getElementById(nextActiveDescendant)) === null || _document_getElementById === void 0 ? void 0 : _document_getElementById.scrollIntoView(false);
18612
+ event.preventDefault();
18613
+ break;
18614
+ }
18615
+ case 'Enter':
18616
+ {
18617
+ submit({
18618
+ query: event.target.value
18619
+ });
18620
+ break;
18621
+ }
18622
+ case 'Tab':
18623
+ // In detached mode, Tab doesn't close the panel
18624
+ if (!isDetached) {
18625
+ setIsOpen(false);
18626
+ }
18627
+ break;
18628
+ default:
18629
+ setIsOpen(true);
18630
+ return;
18631
+ }
18632
+ },
18633
+ onKeyUp: function onKeyUp(event) {
18634
+ switch(event.key){
18635
+ case 'ArrowLeft':
18636
+ case 'ArrowUp':
18637
+ case 'ArrowRight':
18638
+ case 'ArrowDown':
18639
+ case 'Escape':
18640
+ case 'Return':
18641
+ event.preventDefault();
18642
+ return;
18643
+ default:
18644
+ setActiveDescendant(undefined);
18645
+ break;
18646
+ }
18647
+ }
18648
+ };
18649
+ },
18650
+ getItemProps: function getItemProps(item, index) {
18651
+ var id = getElementId('item', item.__indexName, index);
18652
+ return {
18653
+ id: id,
18654
+ role: 'row',
18655
+ 'aria-selected': id === activeDescendant,
18656
+ onSelect: function onSelect() {
18657
+ return submit({
18658
+ activeDescendant: id
18659
+ });
18660
+ },
18661
+ onApply: function onApply1() {
18662
+ var _ref;
18663
+ var _items_get = items.get(id), currentItem = _items_get.item, getQuery = _items_get.config.getQuery;
18664
+ onApply((_ref = getQuery === null || getQuery === void 0 ? void 0 : getQuery(currentItem)) !== null && _ref !== void 0 ? _ref : '');
18665
+ }
18666
+ };
18667
+ },
18668
+ getPanelProps: function getPanelProps() {
18669
+ return {
18670
+ hidden: !isOpen,
18671
+ id: getElementId('panel'),
18672
+ role: 'grid',
18673
+ 'aria-labelledby': getElementId('input')
18674
+ };
18675
+ },
18676
+ getRootProps: function getRootProps() {
18677
+ return {
18678
+ ref: rootRef
18679
+ };
18680
+ },
18681
+ isOpen: isOpen,
18682
+ setIsOpen: setIsOpen,
18683
+ focusInput: function focusInput() {
18684
+ var _inputRef_current;
18685
+ (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : _inputRef_current.focus();
18785
18686
  }
18786
- }, /*#__PURE__*/ createElement(NextIcon, {
18787
- createElement: createElement
18788
- })));
18687
+ };
18789
18688
  };
18790
18689
  }
18791
-
18792
- function SparklesIcon(param) {
18793
- var createElement = param.createElement;
18794
- return /*#__PURE__*/ createElement("svg", {
18795
- xmlns: "http://www.w3.org/2000/svg",
18796
- fill: "none",
18797
- viewBox: "0 0 20 20"
18798
- }, /*#__PURE__*/ createElement("path", {
18799
- fill: "currentColor",
18800
- fillRule: "evenodd",
18801
- d: "M10 1.875c.27 0 .51.173.594.43l1.593 4.844a1.043 1.043 0 0 0 .664.664l4.844 1.593a.625.625 0 0 1 0 1.188l-4.844 1.593a1.043 1.043 0 0 0-.664.664l-1.593 4.844a.625.625 0 0 1-1.188 0l-1.593-4.844a1.042 1.042 0 0 0-.664-.664l-4.844-1.593a.625.625 0 0 1 0-1.188l4.844-1.593a1.042 1.042 0 0 0 .664-.664l1.593-4.844a.625.625 0 0 1 .594-.43ZM9 7.539A2.292 2.292 0 0 1 7.54 9L4.5 10l3.04 1A2.292 2.292 0 0 1 9 12.46l1 3.04 1-3.04A2.293 2.293 0 0 1 12.46 11l3.04-1-3.04-1A2.292 2.292 0 0 1 11 7.54L10 4.5 9 7.54ZM4.167 1.875c.345 0 .625.28.625.625v3.333a.625.625 0 0 1-1.25 0V2.5c0-.345.28-.625.625-.625ZM15.833 13.542c.345 0 .625.28.625.625V17.5a.625.625 0 1 1-1.25 0v-3.333c0-.345.28-.625.625-.625Z",
18802
- clipRule: "evenodd"
18803
- }), /*#__PURE__*/ createElement("path", {
18804
- fill: "currentColor",
18805
- fillRule: "evenodd",
18806
- d: "M1.875 4.167c0-.346.28-.625.625-.625h3.333a.625.625 0 1 1 0 1.25H2.5a.625.625 0 0 1-.625-.625ZM13.542 15.833c0-.345.28-.625.625-.625H17.5a.625.625 0 0 1 0 1.25h-3.333a.625.625 0 0 1-.625-.625Z",
18807
- clipRule: "evenodd"
18808
- }));
18809
- }
18810
- function ArrowUpIcon(param) {
18811
- var createElement = param.createElement;
18812
- return /*#__PURE__*/ createElement("svg", {
18813
- xmlns: "http://www.w3.org/2000/svg",
18814
- viewBox: "0 0 24 24",
18815
- fill: "none",
18816
- stroke: "currentColor",
18817
- strokeLinecap: "round",
18818
- strokeLinejoin: "round"
18819
- }, /*#__PURE__*/ createElement("path", {
18820
- d: "m5 12 7-7 7 7"
18821
- }), /*#__PURE__*/ createElement("path", {
18822
- d: "M12 19V5"
18823
- }));
18824
- }
18825
- function ArrowRightIcon(param) {
18826
- var createElement = param.createElement;
18827
- return /*#__PURE__*/ createElement("svg", {
18828
- xmlns: "http://www.w3.org/2000/svg",
18829
- viewBox: "0 0 24 24",
18830
- fill: "none",
18831
- stroke: "currentColor",
18832
- strokeLinecap: "round",
18833
- strokeLinejoin: "round"
18834
- }, /*#__PURE__*/ createElement("path", {
18835
- d: "M5 12h14"
18836
- }), /*#__PURE__*/ createElement("path", {
18837
- d: "m12 5 7 7-7 7"
18838
- }));
18839
- }
18840
- function ChevronUpIcon(param) {
18841
- var createElement = param.createElement;
18842
- return /*#__PURE__*/ createElement("svg", {
18843
- xmlns: "http://www.w3.org/2000/svg",
18844
- viewBox: "0 0 24 24",
18845
- fill: "none",
18846
- stroke: "currentColor",
18847
- strokeLinecap: "round",
18848
- strokeLinejoin: "round"
18849
- }, /*#__PURE__*/ createElement("path", {
18850
- d: "m18 15-6-6-6 6"
18851
- }));
18852
- }
18853
- function ChevronDownIcon(param) {
18854
- var createElement = param.createElement;
18855
- return /*#__PURE__*/ createElement("svg", {
18856
- xmlns: "http://www.w3.org/2000/svg",
18857
- viewBox: "0 0 24 24",
18858
- fill: "none",
18859
- stroke: "currentColor",
18860
- strokeLinecap: "round",
18861
- strokeLinejoin: "round"
18862
- }, /*#__PURE__*/ createElement("path", {
18863
- d: "m6 9 6 6 6-6"
18864
- }));
18690
+ function buildItems(param) {
18691
+ var _loop = function _loop(i) {
18692
+ var _indices_i;
18693
+ var currentIndexConfig = find(indicesConfig, function(config) {
18694
+ return config.indexName === indices[i].indexName;
18695
+ });
18696
+ var hits = ((_indices_i = indices[i]) === null || _indices_i === void 0 ? void 0 : _indices_i.hits) || [];
18697
+ for(var position = 0; position < hits.length; position++){
18698
+ var itemId = getElementId('item', (currentIndexConfig === null || currentIndexConfig === void 0 ? void 0 : currentIndexConfig.indexName) || indices[i].indexName, position);
18699
+ items.set(itemId, {
18700
+ item: hits[position],
18701
+ config: currentIndexConfig
18702
+ });
18703
+ itemsIds.push(itemId);
18704
+ }
18705
+ };
18706
+ var indices = param.indices, indicesConfig = param.indicesConfig, getElementId = param.getElementId;
18707
+ var itemsIds = [];
18708
+ var items = new Map();
18709
+ for(var i = 0; i < indices.length; i++)_loop(i);
18710
+ return {
18711
+ items: items,
18712
+ itemsIds: itemsIds
18713
+ };
18865
18714
  }
18866
- function CloseIcon(param) {
18867
- var createElement = param.createElement;
18868
- return /*#__PURE__*/ createElement("svg", {
18869
- xmlns: "http://www.w3.org/2000/svg",
18870
- viewBox: "0 0 24 24",
18871
- fill: "none",
18872
- stroke: "currentColor",
18873
- strokeLinecap: "round",
18874
- strokeLinejoin: "round"
18875
- }, /*#__PURE__*/ createElement("path", {
18876
- d: "M18 6 6 18"
18877
- }), /*#__PURE__*/ createElement("path", {
18878
- d: "m6 6 12 12"
18879
- }));
18715
+ function createGetElementId(autocompleteId) {
18716
+ return function getElementId() {
18717
+ for(var _len = arguments.length, suffixes = new Array(_len), _key = 0; _key < _len; _key++){
18718
+ suffixes[_key] = arguments[_key];
18719
+ }
18720
+ var prefix = 'autocomplete';
18721
+ return "".concat(prefix).concat(autocompleteId).concat(suffixes.join(':'));
18722
+ };
18880
18723
  }
18881
- function MaximizeIcon(param) {
18882
- var createElement = param.createElement;
18883
- return /*#__PURE__*/ createElement("svg", {
18884
- xmlns: "http://www.w3.org/2000/svg",
18885
- viewBox: "0 0 24 24",
18886
- fill: "none",
18887
- stroke: "currentColor",
18888
- strokeLinecap: "round",
18889
- strokeLinejoin: "round"
18890
- }, /*#__PURE__*/ createElement("path", {
18891
- d: "M15 3h6v6"
18892
- }), /*#__PURE__*/ createElement("path", {
18893
- d: "m21 3-7 7"
18894
- }), /*#__PURE__*/ createElement("path", {
18895
- d: "m3 21 7-7"
18896
- }), /*#__PURE__*/ createElement("path", {
18897
- d: "M9 21H3v-6"
18898
- }));
18724
+ /**
18725
+ * Returns the framework-agnostic value of a ref.
18726
+ */ function unwrapRef(ref) {
18727
+ return ref.current && _type_ofExports._(ref.current) === 'object' && 'base' in ref.current ? ref.current.base // Preact
18728
+ : ref.current; // React
18899
18729
  }
18900
- function MinimizeIcon(param) {
18901
- var createElement = param.createElement;
18902
- return /*#__PURE__*/ createElement("svg", {
18903
- xmlns: "http://www.w3.org/2000/svg",
18904
- viewBox: "0 0 24 24",
18905
- fill: "none",
18906
- stroke: "currentColor",
18907
- strokeLinecap: "round",
18908
- strokeLinejoin: "round"
18909
- }, /*#__PURE__*/ createElement("path", {
18910
- d: "m14 10 7-7"
18911
- }), /*#__PURE__*/ createElement("path", {
18912
- d: "M20 10h-6V4"
18913
- }), /*#__PURE__*/ createElement("path", {
18914
- d: "m3 21 7-7"
18915
- }), /*#__PURE__*/ createElement("path", {
18916
- d: "M4 14h6v6"
18917
- }));
18730
+
18731
+ function createAutocompleteStorage(param) {
18732
+ var useEffect = param.useEffect, useMemo = param.useMemo, useState = param.useState;
18733
+ return function useStorage(param) {
18734
+ var showRecent = param.showRecent, query = param.query, indices = param.indices, indicesConfig = param.indicesConfig, suggestionsIndexName = param.suggestionsIndexName;
18735
+ var storageKey = showRecent && (typeof showRecent === "undefined" ? "undefined" : _type_ofExports._(showRecent)) === 'object' ? showRecent.storageKey : undefined;
18736
+ var storage = useMemo(function() {
18737
+ return createStorage({
18738
+ limit: 5,
18739
+ storageKey: storageKey
18740
+ });
18741
+ }, [
18742
+ storageKey
18743
+ ]);
18744
+ var _useState = _sliced_to_arrayExports._(useState(storage.getSnapshot()), 2), snapshot = _useState[0], setSnapshot = _useState[1];
18745
+ useEffect(function() {
18746
+ storage.registerUpdateListener(function() {
18747
+ setSnapshot(storage.getSnapshot());
18748
+ });
18749
+ return function() {
18750
+ storage.unregisterUpdateListener();
18751
+ };
18752
+ }, [
18753
+ storage
18754
+ ]);
18755
+ if (!showRecent) {
18756
+ return {
18757
+ storage: {
18758
+ onAdd: function onAdd() {},
18759
+ onRemove: function onRemove() {}
18760
+ },
18761
+ storageHits: [],
18762
+ indicesForPropGetters: indices,
18763
+ indicesConfigForPropGetters: indicesConfig
18764
+ };
18765
+ }
18766
+ var storageHits = snapshot.getAll(query).map(function(value) {
18767
+ return {
18768
+ objectID: value,
18769
+ query: value,
18770
+ __indexName: 'recent-searches',
18771
+ _highlightResult: getHighlightedAttribute({
18772
+ item: {
18773
+ query: value
18774
+ },
18775
+ query: query || ''
18776
+ })
18777
+ };
18778
+ });
18779
+ var indicesForPropGetters = _to_consumable_arrayExports._(indices.map(function(index) {
18780
+ return index.indexName === suggestionsIndexName ? _object_spread_propsExports._(_object_spreadExports._({}, index), {
18781
+ hits: index.hits.filter(function(hit) {
18782
+ return !find(storageHits, function(storageHit) {
18783
+ return storageHit.query === hit.query;
18784
+ });
18785
+ })
18786
+ }) : index;
18787
+ }));
18788
+ var indicesConfigForPropGetters = _to_consumable_arrayExports._(indicesConfig);
18789
+ indicesForPropGetters.unshift({
18790
+ indexName: 'recent-searches',
18791
+ indexId: 'recent-searches',
18792
+ hits: storageHits
18793
+ });
18794
+ indicesConfigForPropGetters.unshift({
18795
+ indexName: 'recent-searches',
18796
+ // @ts-expect-error - we know it has query as it's generated from storageHits
18797
+ getQuery: function getQuery(item) {
18798
+ return item.query;
18799
+ }
18800
+ });
18801
+ return {
18802
+ storage: storage,
18803
+ storageHits: storageHits,
18804
+ indicesForPropGetters: indicesForPropGetters,
18805
+ indicesConfigForPropGetters: indicesConfigForPropGetters
18806
+ };
18807
+ };
18918
18808
  }
18919
- function StopIcon(param) {
18920
- var createElement = param.createElement;
18921
- return /*#__PURE__*/ createElement("svg", {
18922
- xmlns: "http://www.w3.org/2000/svg",
18923
- viewBox: "0 0 24 24",
18924
- fill: "none",
18925
- stroke: "currentColor",
18926
- strokeLinecap: "round",
18927
- strokeLinejoin: "round"
18928
- }, /*#__PURE__*/ createElement("circle", {
18929
- cx: "12",
18930
- cy: "12",
18931
- r: "10"
18932
- }), /*#__PURE__*/ createElement("rect", {
18933
- x: "9",
18934
- y: "9",
18935
- width: "6",
18936
- height: "6",
18937
- rx: "1"
18938
- }));
18809
+ var LOCAL_STORAGE_KEY_TEST = 'test-localstorage-support';
18810
+ var LOCAL_STORAGE_KEY = 'autocomplete-recent-searches';
18811
+ function isLocalStorageSupported() {
18812
+ try {
18813
+ localStorage.setItem(LOCAL_STORAGE_KEY_TEST, '');
18814
+ localStorage.removeItem(LOCAL_STORAGE_KEY_TEST);
18815
+ return true;
18816
+ } catch (error) {
18817
+ return false;
18818
+ }
18939
18819
  }
18940
- function ReloadIcon(param) {
18941
- var createElement = param.createElement;
18942
- return /*#__PURE__*/ createElement("svg", {
18943
- xmlns: "http://www.w3.org/2000/svg",
18944
- viewBox: "0 0 24 24",
18945
- fill: "none",
18946
- stroke: "currentColor",
18947
- strokeLinecap: "round",
18948
- strokeLinejoin: "round"
18949
- }, /*#__PURE__*/ createElement("path", {
18950
- d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"
18951
- }), /*#__PURE__*/ createElement("path", {
18952
- d: "M21 3v5h-5"
18953
- }), /*#__PURE__*/ createElement("path", {
18954
- d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"
18955
- }), /*#__PURE__*/ createElement("path", {
18956
- d: "M3 21v-5h5"
18957
- }));
18820
+ function getHighlightedAttribute(param) {
18821
+ var item = param.item, query = param.query;
18822
+ if (!query.trim().length) {
18823
+ return {
18824
+ query: {
18825
+ matchLevel: 'none'
18826
+ }
18827
+ };
18828
+ }
18829
+ return {
18830
+ query: {
18831
+ value: item.query.replace(new RegExp(query.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'), 'gi'), function(match) {
18832
+ return "<mark>".concat(match, "</mark>");
18833
+ })
18834
+ }
18835
+ };
18958
18836
  }
18959
- function CopyIcon(param) {
18960
- var createElement = param.createElement;
18961
- return /*#__PURE__*/ createElement("svg", {
18962
- xmlns: "http://www.w3.org/2000/svg",
18963
- viewBox: "0 0 24 24",
18964
- fill: "none",
18965
- stroke: "currentColor",
18966
- strokeLinecap: "round",
18967
- strokeLinejoin: "round"
18968
- }, /*#__PURE__*/ createElement("rect", {
18969
- width: "14",
18970
- height: "14",
18971
- x: "8",
18972
- y: "8",
18973
- rx: "2",
18974
- ry: "2"
18975
- }), /*#__PURE__*/ createElement("path", {
18976
- d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
18977
- }));
18837
+ function getLocalStorage() {
18838
+ var key = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : LOCAL_STORAGE_KEY;
18839
+ if (!isLocalStorageSupported()) {
18840
+ return {
18841
+ setItems: function setItems() {},
18842
+ getItems: function getItems() {
18843
+ return [];
18844
+ }
18845
+ };
18846
+ }
18847
+ return {
18848
+ setItems: function setItems(items) {
18849
+ try {
18850
+ window.localStorage.setItem(key, JSON.stringify(items));
18851
+ } catch (unused) {
18852
+ // do nothing, this likely means the storage is full
18853
+ }
18854
+ },
18855
+ getItems: function getItems() {
18856
+ var items = window.localStorage.getItem(key);
18857
+ return items ? JSON.parse(items) : [];
18858
+ }
18859
+ };
18978
18860
  }
18979
- function MenuIcon(param) {
18980
- var createElement = param.createElement;
18981
- return /*#__PURE__*/ createElement("svg", {
18982
- xmlns: "http://www.w3.org/2000/svg",
18983
- viewBox: "0 0 24 24",
18984
- fill: "none",
18985
- stroke: "currentColor",
18986
- strokeLinecap: "round",
18987
- strokeLinejoin: "round"
18988
- }, /*#__PURE__*/ createElement("circle", {
18989
- cx: "12",
18990
- cy: "12",
18991
- r: "1"
18992
- }), /*#__PURE__*/ createElement("circle", {
18993
- cx: "12",
18994
- cy: "5",
18995
- r: "1"
18996
- }), /*#__PURE__*/ createElement("circle", {
18997
- cx: "12",
18998
- cy: "19",
18999
- r: "1"
19000
- }));
18861
+ function createStorage(param) {
18862
+ var _param_limit = param.limit, limit = _param_limit === void 0 ? 5 : _param_limit, storageKey = param.storageKey;
18863
+ var storage = getLocalStorage(storageKey);
18864
+ var updateListener = null;
18865
+ return {
18866
+ onAdd: function onAdd(query) {
18867
+ this.onRemove(query);
18868
+ storage.setItems([
18869
+ query
18870
+ ].concat(_to_consumable_arrayExports._(storage.getItems())));
18871
+ },
18872
+ onRemove: function onRemove(query) {
18873
+ storage.setItems(storage.getItems().filter(function(q) {
18874
+ return q !== query;
18875
+ }));
18876
+ updateListener === null || updateListener === void 0 ? void 0 : updateListener();
18877
+ },
18878
+ registerUpdateListener: function registerUpdateListener(callback) {
18879
+ updateListener = callback;
18880
+ },
18881
+ unregisterUpdateListener: function unregisterUpdateListener() {
18882
+ updateListener = null;
18883
+ },
18884
+ getSnapshot: function getSnapshot() {
18885
+ return {
18886
+ getAll: function getAll() {
18887
+ var query = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '';
18888
+ return storage.getItems().filter(function(q) {
18889
+ return q.includes(query);
18890
+ }).slice(0, limit);
18891
+ }
18892
+ };
18893
+ }
18894
+ };
19001
18895
  }
19002
- function LoadingSpinnerIcon(param) {
19003
- var createElement = param.createElement;
19004
- return /*#__PURE__*/ createElement("svg", {
19005
- viewBox: "12 12 24 24",
19006
- role: "status",
19007
- "aria-busy": "true",
19008
- "aria-live": "polite"
19009
- }, /*#__PURE__*/ createElement("title", null, "Loading spinner"), /*#__PURE__*/ createElement("circle", {
19010
- cx: "24",
19011
- cy: "24",
19012
- r: "11",
19013
- fill: "none",
19014
- stroke: "currentColor"
19015
- }));
18896
+
18897
+ function createDefaultItemComponent(param) {
18898
+ var createElement = param.createElement, Fragment = param.Fragment;
18899
+ return function DefaultItem(userProps) {
18900
+ return /*#__PURE__*/ createElement(Fragment, null, JSON.stringify(userProps.item, null, 2));
18901
+ };
19016
18902
  }
19017
- function ChevronLeftIcon(param) {
18903
+
18904
+ var lastCarouselId = 0;
18905
+ function generateCarouselId() {
18906
+ return "ais-Carousel-".concat(lastCarouselId++);
18907
+ }
18908
+ function PreviousIconDefaultComponent(param) {
19018
18909
  var createElement = param.createElement;
19019
18910
  return /*#__PURE__*/ createElement("svg", {
19020
- xmlns: "http://www.w3.org/2000/svg",
19021
- viewBox: "0 0 24 24",
19022
- fill: "none",
19023
- stroke: "currentColor",
19024
- strokeLinecap: "round",
19025
- strokeLinejoin: "round"
18911
+ width: "8",
18912
+ height: "16",
18913
+ viewBox: "0 0 8 16",
18914
+ fill: "none"
19026
18915
  }, /*#__PURE__*/ createElement("path", {
19027
- d: "m15 18-6-6 6-6"
18916
+ fillRule: "evenodd",
18917
+ clipRule: "evenodd",
18918
+ fill: "currentColor",
18919
+ d: "M7.13809 0.744078C7.39844 1.06951 7.39844 1.59715 7.13809 1.92259L2.27616 8L7.13809 14.0774C7.39844 14.4028 7.39844 14.9305 7.13809 15.2559C6.87774 15.5814 6.45563 15.5814 6.19528 15.2559L0.861949 8.58926C0.6016 8.26382 0.6016 7.73618 0.861949 7.41074L6.19528 0.744078C6.45563 0.418641 6.87774 0.418641 7.13809 0.744078Z"
19028
18920
  }));
19029
18921
  }
19030
- function ChevronRightIcon(param) {
18922
+ function NextIconDefaultComponent(param) {
19031
18923
  var createElement = param.createElement;
19032
18924
  return /*#__PURE__*/ createElement("svg", {
19033
- xmlns: "http://www.w3.org/2000/svg",
19034
- viewBox: "0 0 24 24",
19035
- fill: "none",
19036
- stroke: "currentColor",
19037
- strokeLinecap: "round",
19038
- strokeLinejoin: "round"
18925
+ width: "8",
18926
+ height: "16",
18927
+ viewBox: "0 0 8 16",
18928
+ fill: "none"
19039
18929
  }, /*#__PURE__*/ createElement("path", {
19040
- d: "m9 18 6-6-6-6"
18930
+ fillRule: "evenodd",
18931
+ clipRule: "evenodd",
18932
+ fill: "currentColor",
18933
+ d: "M0.861908 15.2559C0.601559 14.9305 0.601559 14.4028 0.861908 14.0774L5.72384 8L0.861908 1.92259C0.601559 1.59715 0.601559 1.06952 0.861908 0.744079C1.12226 0.418642 1.54437 0.418642 1.80472 0.744079L7.13805 7.41074C7.3984 7.73618 7.3984 8.26382 7.13805 8.58926L1.80472 15.2559C1.54437 15.5814 1.12226 15.5814 0.861908 15.2559Z"
19041
18934
  }));
19042
18935
  }
18936
+ function createCarouselComponent(param) {
18937
+ var createElement = param.createElement, Fragment = param.Fragment;
18938
+ return function Carousel(userProps) {
18939
+ var listRef = userProps.listRef, nextButtonRef = userProps.nextButtonRef, previousButtonRef = userProps.previousButtonRef, carouselIdRef = userProps.carouselIdRef, canScrollLeft = userProps.canScrollLeft, canScrollRight = userProps.canScrollRight, setCanScrollLeft = userProps.setCanScrollLeft, setCanScrollRight = userProps.setCanScrollRight, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, tmp = userProps.itemComponent, ItemComponent = tmp === void 0 ? createDefaultItemComponent({
18940
+ createElement: createElement,
18941
+ Fragment: Fragment
18942
+ }) : tmp, tmp1 = userProps.previousIconComponent, PreviousIcon = tmp1 === void 0 ? PreviousIconDefaultComponent : tmp1, tmp2 = userProps.nextIconComponent, NextIcon = tmp2 === void 0 ? NextIconDefaultComponent : tmp2, HeaderComponent = userProps.headerComponent, _userProps_showNavigation = userProps.showNavigation, showNavigation = _userProps_showNavigation === void 0 ? true : _userProps_showNavigation, items = userProps.items, userTranslations = userProps.translations, sendEvent = userProps.sendEvent, props = _object_without_propertiesExports._(userProps, [
18943
+ "listRef",
18944
+ "nextButtonRef",
18945
+ "previousButtonRef",
18946
+ "carouselIdRef",
18947
+ "canScrollLeft",
18948
+ "canScrollRight",
18949
+ "setCanScrollLeft",
18950
+ "setCanScrollRight",
18951
+ "classNames",
18952
+ "itemComponent",
18953
+ "previousIconComponent",
18954
+ "nextIconComponent",
18955
+ "headerComponent",
18956
+ "showNavigation",
18957
+ "items",
18958
+ "translations",
18959
+ "sendEvent"
18960
+ ]);
18961
+ var translations = _object_spreadExports._({
18962
+ listLabel: 'Items',
18963
+ nextButtonLabel: 'Next',
18964
+ nextButtonTitle: 'Next',
18965
+ previousButtonLabel: 'Previous',
18966
+ previousButtonTitle: 'Previous'
18967
+ }, userTranslations);
18968
+ var cssClasses = {
18969
+ root: cx('ais-Carousel', classNames.root),
18970
+ list: cx('ais-Carousel-list', classNames.list),
18971
+ item: cx('ais-Carousel-item', classNames.item),
18972
+ navigation: cx('ais-Carousel-navigation', classNames.navigation),
18973
+ navigationNext: cx('ais-Carousel-navigation--next', classNames.navigationNext),
18974
+ navigationPrevious: cx('ais-Carousel-navigation--previous', classNames.navigationPrevious)
18975
+ };
18976
+ function scrollLeft() {
18977
+ if (listRef.current) {
18978
+ listRef.current.scrollLeft -= listRef.current.offsetWidth * 0.75;
18979
+ }
18980
+ }
18981
+ function scrollRight() {
18982
+ if (listRef.current) {
18983
+ listRef.current.scrollLeft += listRef.current.offsetWidth * 0.75;
18984
+ }
18985
+ }
18986
+ function updateNavigationButtonsProps() {
18987
+ if (!listRef.current) {
18988
+ return;
18989
+ }
18990
+ var isLeftHidden = listRef.current.scrollLeft <= 0;
18991
+ var isRightHidden = listRef.current.scrollLeft + listRef.current.clientWidth >= listRef.current.scrollWidth;
18992
+ setCanScrollLeft(!isLeftHidden);
18993
+ setCanScrollRight(!isRightHidden);
18994
+ if (previousButtonRef.current) {
18995
+ previousButtonRef.current.hidden = isLeftHidden;
18996
+ }
18997
+ if (nextButtonRef.current) {
18998
+ nextButtonRef.current.hidden = isRightHidden;
18999
+ }
19000
+ }
19001
+ if (items.length === 0) {
19002
+ return null;
19003
+ }
19004
+ return /*#__PURE__*/ createElement("div", _object_spread_propsExports._(_object_spreadExports._({}, props), {
19005
+ className: cx(cssClasses.root)
19006
+ }), HeaderComponent && /*#__PURE__*/ createElement(HeaderComponent, {
19007
+ canScrollLeft: canScrollLeft,
19008
+ canScrollRight: canScrollRight,
19009
+ scrollLeft: scrollLeft,
19010
+ scrollRight: scrollRight
19011
+ }), showNavigation && /*#__PURE__*/ createElement("button", {
19012
+ ref: previousButtonRef,
19013
+ title: translations.previousButtonTitle,
19014
+ "aria-label": translations.previousButtonLabel,
19015
+ hidden: true,
19016
+ "aria-controls": carouselIdRef.current,
19017
+ className: cx(cssClasses.navigation, cssClasses.navigationPrevious),
19018
+ onClick: function onClick(event) {
19019
+ event.preventDefault();
19020
+ scrollLeft();
19021
+ }
19022
+ }, /*#__PURE__*/ createElement(PreviousIcon, {
19023
+ createElement: createElement
19024
+ })), /*#__PURE__*/ createElement("ol", {
19025
+ className: cx(cssClasses.list),
19026
+ ref: listRef,
19027
+ tabIndex: 0,
19028
+ id: carouselIdRef.current,
19029
+ "aria-roledescription": "carousel",
19030
+ "aria-label": translations.listLabel,
19031
+ "aria-live": "polite",
19032
+ onScroll: updateNavigationButtonsProps,
19033
+ onKeyDown: function onKeyDown(event) {
19034
+ if (event.key === 'ArrowLeft') {
19035
+ event.preventDefault();
19036
+ scrollLeft();
19037
+ } else if (event.key === 'ArrowRight') {
19038
+ event.preventDefault();
19039
+ scrollRight();
19040
+ }
19041
+ }
19042
+ }, items.map(function(item, index) {
19043
+ return /*#__PURE__*/ createElement("li", {
19044
+ key: item.objectID,
19045
+ className: cx(cssClasses.item),
19046
+ "aria-roledescription": "slide",
19047
+ "aria-label": "".concat(index + 1, " of ").concat(items.length),
19048
+ onClick: function onClick() {
19049
+ sendEvent('click:internal', item, 'Item Clicked');
19050
+ },
19051
+ onAuxClick: function onAuxClick() {
19052
+ sendEvent('click:internal', item, 'Item Clicked');
19053
+ }
19054
+ }, /*#__PURE__*/ createElement(ItemComponent, {
19055
+ item: item,
19056
+ sendEvent: sendEvent
19057
+ }));
19058
+ })), showNavigation && /*#__PURE__*/ createElement("button", {
19059
+ ref: nextButtonRef,
19060
+ title: translations.nextButtonTitle,
19061
+ "aria-label": translations.nextButtonLabel,
19062
+ "aria-controls": carouselIdRef.current,
19063
+ className: cx(cssClasses.navigation, cssClasses.navigationNext),
19064
+ onClick: function onClick(event) {
19065
+ event.preventDefault();
19066
+ scrollRight();
19067
+ }
19068
+ }, /*#__PURE__*/ createElement(NextIcon, {
19069
+ createElement: createElement
19070
+ })));
19071
+ };
19072
+ }
19043
19073
 
19044
19074
  function createChatHeaderComponent(param) {
19045
19075
  var createElement = param.createElement;
@@ -19113,6 +19143,18 @@
19113
19143
  };
19114
19144
  }
19115
19145
 
19146
+ var getTextContent = function getTextContent(message) {
19147
+ return message.parts.map(function(part) {
19148
+ return 'text' in part ? part.text : '';
19149
+ }).join('');
19150
+ };
19151
+ var hasTextContent = function hasTextContent(message) {
19152
+ return getTextContent(message).trim() !== '';
19153
+ };
19154
+ var isPartText = function isPartText(part) {
19155
+ return part.type === 'text';
19156
+ };
19157
+
19116
19158
  function n(){return n=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t]);}return e},n.apply(this,arguments)}const o=["allowFullScreen","allowTransparency","autoComplete","autoFocus","autoPlay","cellPadding","cellSpacing","charSet","classId","colSpan","contentEditable","contextMenu","crossOrigin","encType","formAction","formEncType","formMethod","formNoValidate","formTarget","frameBorder","hrefLang","inputMode","keyParams","keyType","marginHeight","marginWidth","maxLength","mediaGroup","minLength","noValidate","radioGroup","readOnly","rowSpan","spellCheck","srcDoc","srcLang","srcSet","tabIndex","useMap"].reduce((e,n)=>(e[n.toLowerCase()]=n,e),{class:"className",for:"htmlFor"}),a={amp:"&",apos:"'",gt:">",lt:"<",nbsp:" ",quot:"“"},c=["style","script","pre"],i=["src","href","data","formAction","srcDoc","action"],u=/([-A-Z0-9_:]+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|(?:\{((?:\\.|{[^}]*?}|[^}])*)\})))?/gi,l=/\n{2,}$/,s=/^(\s*>[\s\S]*?)(?=\n\n|$)/,f=/^ *> ?/gm,_=/^(?:\[!([^\]]*)\]\n)?([\s\S]*)/,d=/^ {2,}\n/,p=/^(?:([-*_])( *\1){2,}) *(?:\n *)+\n/,y=/^(?: {1,3})?(`{3,}|~{3,}) *(\S+)? *([^\n]*?)?\n([\s\S]*?)(?:\1\n?|$)/,h=/^(?: {4}[^\n]+\n*)+(?:\n *)+\n?/,g=/^(`+)((?:\\`|(?!\1)`|[^`])+)\1/,m=/^(?:\n *)*\n/,k=/\r\n?/g,x=/^\[\^([^\]]+)](:(.*)((\n+ {4,}.*)|(\n(?!\[\^).+))*)/,q=/^\[\^([^\]]+)]/,v=/\f/g,b=/^---[ \t]*\n(.|\n)*\n---[ \t]*\n/,$=/^\s*?\[(x|\s)\]/,S=/^ *(#{1,6}) *([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,z=/^ *(#{1,6}) +([^\n]+?)(?: +#*)?(?:\n *)*(?:\n|$)/,E=/^([^\n]+)\n *(=|-)\2{2,} *\n/,A=/^ *(?!<[a-z][^ >/]* ?\/>)<([a-z][^ >/]*) ?((?:[^>]*[^/])?)>\n?(\s*(?:<\1[^>]*?>[\s\S]*?<\/\1>|(?!<\1\b)[\s\S])*?)<\/\1>(?!<\/\1>)\n*/i,R=/&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-fA-F]{1,6});/gi,B=/^<!--[\s\S]*?(?:-->)/,L=/^(data|aria|x)-[a-z_][a-z\d_.-]*$/,O=/^ *<([a-z][a-z0-9:]*)(?:\s+((?:<.*?>|[^>])*))?\/?>(?!<\/\1>)(\s*\n)?/i,j=/^\{.*\}$/,C=/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,I=/^<([^ >]+[:@\/][^ >]+)>/,T=/-([a-z])?/gi,M=/^(\|.*)\n(?: *(\|? *[-:]+ *\|[-| :]*)\n((?:.*\|.*\n)*))?\n?/,w=/^[^\n]+(?: \n|\n{2,})/,D=/^\[([^\]]*)\]:\s+<?([^\s>]+)>?\s*("([^"]*)")?/,F=/^!\[([^\]]*)\] ?\[([^\]]*)\]/,P=/^\[([^\]]*)\] ?\[([^\]]*)\]/,Z=/(\n|^[-*]\s|^#|^ {2,}|^-{2,}|^>\s)/,N=/\t/g,G=/(^ *\||\| *$)/g,U=/^ *:-+: *$/,V=/^ *:-+ *$/,H=/^ *-+: *$/,Q=e=>`(?=[\\s\\S]+?\\1${e?"\\1":""})`,W="((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|\\\\\\1|[\\s\\S])+?)",J=RegExp(`^([*_])\\1${Q(1)}${W}\\1\\1(?!\\1)`),K=RegExp(`^([*_])${Q(0)}${W}\\1(?!\\1)`),X=RegExp(`^(==)${Q(0)}${W}\\1`),Y=RegExp(`^(~~)${Q(0)}${W}\\1`),ee=/^(:[a-zA-Z0-9-_]+:)/,ne=/^\\([^0-9A-Za-z\s])/,re=/\\([^0-9A-Za-z\s])/g,te=/^[\s\S](?:(?! \n|[0-9]\.|http)[^=*_~\-\n:<`\\\[!])*/,oe=/^\n+/,ae=/^([ \t]*)/,ce=/(?:^|\n)( *)$/,ie="(?:\\d+\\.)",ue="(?:[*+-])";function le(e){return "( *)("+(1===e?ie:ue)+") +"}const se=le(1),fe=le(2);function _e(e){return RegExp("^"+(1===e?se:fe))}const de=_e(1),pe=_e(2);function ye(e){return RegExp("^"+(1===e?se:fe)+"[^\\n]*(?:\\n(?!\\1"+(1===e?ie:ue)+" )[^\\n]*)*(\\n|$)","gm")}const he=ye(1),ge=ye(2);function me(e){const n=1===e?ie:ue;return RegExp("^( *)("+n+") [\\s\\S]+?(?:\\n{2,}(?! )(?!\\1"+n+" (?!"+n+" ))\\n*|\\s*\\n*$)")}const ke=me(1),xe=me(2);function qe(e,n){const r=1===n,t=r?ke:xe,o=r?he:ge,a=r?de:pe;return {t:e=>a.test(e),o:je(function(e,n){const r=ce.exec(n.prevCapture);return r&&(n.list||!n.inline&&!n.simple)?t.exec(e=r[1]+e):null}),i:1,u(e,n,t){const c=r?+e[2]:void 0,i=e[0].replace(l,"\n").match(o);let u=!1;return {items:i.map(function(e,r){const o=a.exec(e)[0].length,c=RegExp("^ {1,"+o+"}","gm"),l=e.replace(c,"").replace(a,""),s=r===i.length-1,f=-1!==l.indexOf("\n\n")||s&&u;u=f;const _=t.inline,d=t.list;let p;t.list=!0,f?(t.inline=!1,p=Se(l)+"\n\n"):(t.inline=!0,p=Se(l));const y=n(p,t);return t.inline=_,t.list=d,y}),ordered:r,start:c}},l:(n,r,t)=>e(n.ordered?"ol":"ul",{key:t.key,start:"20"===n.type?n.start:void 0},n.items.map(function(n,o){return e("li",{key:o},r(n,t))}))}}const ve=RegExp("^\\[((?:\\[[^\\[\\]]*(?:\\[[^\\[\\]]*\\][^\\[\\]]*)*\\]|[^\\[\\]])*)\\]\\(\\s*<?((?:\\([^)]*\\)|[^\\s\\\\]|\\\\.)*?)>?(?:\\s+['\"]([\\s\\S]*?)['\"])?\\s*\\)"),be=/^!\[(.*?)\]\( *((?:\([^)]*\)|[^() ])*) *"?([^)"]*)?"?\)/;function $e(e){return "string"==typeof e}function Se(e){let n=e.length;for(;n>0&&e[n-1]<=" ";)n--;return e.slice(0,n)}function ze(e,n){return e.startsWith(n)}function Ee(e,n,r){if(Array.isArray(r)){for(let n=0;n<r.length;n++)if(ze(e,r[n]))return !0;return !1}return r(e,n)}function Ae(e){return e.replace(/[ÀÁÂÃÄÅàáâãä忯]/g,"a").replace(/[çÇ]/g,"c").replace(/[ðÐ]/g,"d").replace(/[ÈÉÊËéèêë]/g,"e").replace(/[ÏïÎîÍíÌì]/g,"i").replace(/[Ññ]/g,"n").replace(/[øØœŒÕõÔôÓóÒò]/g,"o").replace(/[ÜüÛûÚúÙù]/g,"u").replace(/[ŸÿÝý]/g,"y").replace(/[^a-z0-9- ]/gi,"").replace(/ /gi,"-").toLowerCase()}function Re(e){return H.test(e)?"right":U.test(e)?"center":V.test(e)?"left":null}function Be(e,n,r,t){const o=r.inTable;r.inTable=!0;let a=[[]],c="";function i(){if(!c)return;const e=a[a.length-1];e.push.apply(e,n(c,r)),c="";}return e.trim().split(/(`[^`]*`|\\\||\|)/).filter(Boolean).forEach((e,n,r)=>{"|"===e.trim()&&(i(),t)?0!==n&&n!==r.length-1&&a.push([]):c+=e;}),i(),r.inTable=o,a}function Le(e,n,r){r.inline=!0;const t=e[2]?e[2].replace(G,"").split("|").map(Re):[],o=e[3]?function(e,n,r){return e.trim().split("\n").map(function(e){return Be(e,n,r,!0)})}(e[3],n,r):[],a=Be(e[1],n,r,!!o.length);return r.inline=!1,o.length?{align:t,cells:o,header:a,type:"25"}:{children:a,type:"21"}}function Oe(e,n){return null==e.align[n]?{}:{textAlign:e.align[n]}}function je(e){return e.inline=1,e}function Ce(e){return je(function(n,r){return r.inline?e.exec(n):null})}function Ie(e){return je(function(n,r){return r.inline||r.simple?e.exec(n):null})}function Te(e){return function(n,r){return r.inline||r.simple?null:e.exec(n)}}function Me(e){return je(function(n){return e.exec(n)})}const we=/(javascript|vbscript|data(?!:image)):/i;function De(e){try{const n=decodeURIComponent(e).replace(/[^A-Za-z0-9/:]/g,"");if(we.test(n))return null}catch(e){return null}return e}function Fe(e){return e?e.replace(re,"$1"):e}function Pe(e,n,r){const t=r.inline||!1,o=r.simple||!1;r.inline=!0,r.simple=!0;const a=e(n,r);return r.inline=t,r.simple=o,a}function Ze(e,n,r){const t=r.inline||!1,o=r.simple||!1;r.inline=!1,r.simple=!0;const a=e(n,r);return r.inline=t,r.simple=o,a}function Ne(e,n,r){const t=r.inline||!1;r.inline=!1;const o=e(n,r);return r.inline=t,o}const Ge=(e,n,r)=>({children:Pe(n,e[2],r)});function Ue(){return {}}function Ve(){return null}function He(...e){return e.filter(Boolean).join(" ")}function Qe(e,n,r){let t=e;const o=n.split(".");for(;o.length&&(t=t[o[0]],void 0!==t);)o.shift();return t||r}function We(r="",t={}){t.overrides=t.overrides||{},t.namedCodesToUnicode=t.namedCodesToUnicode?n({},a,t.namedCodesToUnicode):a;const l=t.slugify||Ae,G=t.sanitizer||De,U=t.createElement||React__namespace.createElement,V=[s,y,h,t.enforceAtxHeadings?z:S,E,M,ke,xe],H=[...V,w,A,B,O];function Q(e,n){for(let r=0;r<e.length;r++)if(e[r].test(n))return !0;return !1}function W(e,r,...o){const a=Qe(t.overrides,e+".props",{});return U(function(e,n){const r=Qe(n,e);return r?"function"==typeof r||"object"==typeof r&&"render"in r?r:Qe(n,e+".component",e):e}(e,t.overrides),n({},r,a,{className:He(null==r?void 0:r.className,a.className)||void 0}),...o)}function re(e){e=e.replace(b,"");let n=!1;t.forceInline?n=!0:t.forceBlock||(n=!1===Z.test(e));const r=fe(se(n?e:Se(e).replace(oe,"")+"\n\n",{inline:n}));for(;$e(r[r.length-1])&&!r[r.length-1].trim();)r.pop();if(null===t.wrapper)return r;const o=t.wrapper||(n?"span":"div");let a;if(r.length>1||t.forceWrapper)a=r;else {if(1===r.length)return a=r[0],"string"==typeof a?W("span",{key:"outer"},a):a;a=null;}return U(o,{key:"outer"},a)}function ce(e,n){if(!n||!n.trim())return null;const r=n.match(u);return r?r.reduce(function(n,r){const t=r.indexOf("=");if(-1!==t){const a=function(e){return -1!==e.indexOf("-")&&null===e.match(L)&&(e=e.replace(T,function(e,n){return n.toUpperCase()})),e}(r.slice(0,t)).trim(),c=function(e){const n=e[0];return ('"'===n||"'"===n)&&e.length>=2&&e[e.length-1]===n?e.slice(1,-1):e}(r.slice(t+1).trim()),u=o[a]||a;if("ref"===u)return n;const l=n[u]=function(e,n,r,t){return "style"===n?function(e){const n=[];let r="",t=!1,o=!1,a="";if(!e)return n;for(let c=0;c<e.length;c++){const i=e[c];if('"'!==i&&"'"!==i||t||(o?i===a&&(o=!1,a=""):(o=!0,a=i)),"("===i&&r.endsWith("url")?t=!0:")"===i&&t&&(t=!1),";"!==i||o||t)r+=i;else {const e=r.trim();if(e){const r=e.indexOf(":");if(r>0){const t=e.slice(0,r).trim(),o=e.slice(r+1).trim();n.push([t,o]);}}r="";}}const c=r.trim();if(c){const e=c.indexOf(":");if(e>0){const r=c.slice(0,e).trim(),t=c.slice(e+1).trim();n.push([r,t]);}}return n}(r).reduce(function(n,[r,o]){return n[r.replace(/(-[a-z])/g,e=>e[1].toUpperCase())]=t(o,e,r),n},{}):-1!==i.indexOf(n)?t(Fe(r),e,n):(r.match(j)&&(r=Fe(r.slice(1,r.length-1))),"true"===r||"false"!==r&&r)}(e,a,c,G);"string"==typeof l&&(A.test(l)||O.test(l))&&(n[u]=re(l.trim()));}else "style"!==r&&(n[o[r]||r]=!0);return n},{}):null}const ie=[],ue={},le={0:{t:[">"],o:Te(s),i:1,u(e,n,r){const[,t,o]=e[0].replace(f,"").match(_);return {alert:t,children:n(o,r)}},l(e,n,r){const t={key:r.key};return e.alert&&(t.className="markdown-alert-"+l(e.alert.toLowerCase(),Ae),e.children.unshift({attrs:{},children:[{type:"27",text:e.alert}],noInnerParse:!0,type:"11",tag:"header"})),W("blockquote",t,n(e.children,r))}},1:{t:[" "],o:Me(d),i:1,u:Ue,l:(e,n,r)=>W("br",{key:r.key})},2:{t:["--","__","**","- ","* ","_ "],o:Te(p),i:1,u:Ue,l:(e,n,r)=>W("hr",{key:r.key})},3:{t:[" "],o:Te(h),i:0,u:e=>({lang:void 0,text:Fe(Se(e[0].replace(/^ {4}/gm,"")))}),l:(e,r,t)=>W("pre",{key:t.key},W("code",n({},e.attrs,{className:e.lang?"lang-"+e.lang:""}),e.text))},4:{t:["```","~~~"],o:Te(y),i:0,u:e=>({attrs:ce("code",e[3]||""),lang:e[2]||void 0,text:e[4],type:"3"})},5:{t:["`"],o:Ie(g),i:3,u:e=>({text:Fe(e[2])}),l:(e,n,r)=>W("code",{key:r.key},e.text)},6:{t:["[^"],o:Te(x),i:0,u:e=>(ie.push({footnote:e[2],identifier:e[1]}),{}),l:Ve},7:{t:["[^"],o:Ce(q),i:1,u:e=>({target:"#"+l(e[1],Ae),text:e[1]}),l:(e,n,r)=>W("a",{key:r.key,href:G(e.target,"a","href")},W("sup",{key:r.key},e.text))},8:{t:["[ ]","[x]"],o:Ce($),i:1,u:e=>({completed:"x"===e[1].toLowerCase()}),l:(e,n,r)=>W("input",{checked:e.completed,key:r.key,readOnly:!0,type:"checkbox"})},9:{t:["#"],o:Te(t.enforceAtxHeadings?z:S),i:1,u:(e,n,r)=>({children:Pe(n,e[2],r),id:l(e[2],Ae),level:e[1].length}),l:(e,n,r)=>W("h"+e.level,{id:e.id,key:r.key},n(e.children,r))},10:{t:e=>{const n=e.indexOf("\n");return n>0&&n<e.length-1&&("="===e[n+1]||"-"===e[n+1])},o:Te(E),i:0,u:(e,n,r)=>({children:Pe(n,e[1],r),level:"="===e[2]?1:2,type:"9"})},11:{t:["<"],o:Me(A),i:1,u(e,n,r){const[,t]=e[3].match(ae),o=RegExp("^"+t,"gm"),a=e[3].replace(o,""),i=Q(H,a)?Ne:Pe,u=e[1].toLowerCase(),l=-1!==c.indexOf(u),s=(l?u:e[1]).trim(),f={attrs:ce(s,e[2]),noInnerParse:l,tag:s};if(r.inAnchor=r.inAnchor||"a"===u,l)f.text=e[3];else {const e=r.inHTML;r.inHTML=!0,f.children=i(n,a,r),r.inHTML=e;}return r.inAnchor=!1,f},l:(e,r,t)=>W(e.tag,n({key:t.key},e.attrs),e.text||(e.children?r(e.children,t):""))},13:{t:["<"],o:Me(O),i:1,u(e){const n=e[1].trim();return {attrs:ce(n,e[2]||""),tag:n}},l:(e,r,t)=>W(e.tag,n({},e.attrs,{key:t.key}))},12:{t:["\x3c!--"],o:Me(B),i:1,u:()=>({}),l:Ve},14:{t:["!["],o:Ie(be),i:1,u:e=>({alt:Fe(e[1]),target:Fe(e[2]),title:Fe(e[3])}),l:(e,n,r)=>W("img",{key:r.key,alt:e.alt||void 0,title:e.title||void 0,src:G(e.target,"img","src")})},15:{t:["["],o:Ce(ve),i:3,u:(e,n,r)=>({children:Ze(n,e[1],r),target:Fe(e[2]),title:Fe(e[3])}),l:(e,n,r)=>W("a",{key:r.key,href:G(e.target,"a","href"),title:e.title},n(e.children,r))},16:{t:["<"],o:Ce(I),i:0,u(e){let n=e[1],r=!1;return -1!==n.indexOf("@")&&-1===n.indexOf("//")&&(r=!0,n=n.replace("mailto:","")),{children:[{text:n,type:"27"}],target:r?"mailto:"+n:n,type:"15"}}},17:{t:(e,n)=>!n.inAnchor&&!t.disableAutoLink&&(ze(e,"http://")||ze(e,"https://")),o:Ce(C),i:0,u:e=>({children:[{text:e[1],type:"27"}],target:e[1],title:void 0,type:"15"})},20:qe(W,1),33:qe(W,2),19:{t:["\n"],o:Te(m),i:3,u:Ue,l:()=>"\n"},21:{o:je(function(e,n){if(n.inline||n.simple||n.inHTML&&-1===e.indexOf("\n\n")&&-1===n.prevCapture.indexOf("\n\n"))return null;let r="",t=0;for(;;){const n=e.indexOf("\n",t),o=e.slice(t,-1===n?void 0:n+1);if(Q(V,o))break;if(r+=o,-1===n||!o.trim())break;t=n+1;}const o=Se(r);return ""===o?null:[r,,o]}),i:3,u:Ge,l:(e,n,r)=>W("p",{key:r.key},n(e.children,r))},22:{t:["["],o:Ce(D),i:0,u:e=>(ue[e[1]]={target:e[2],title:e[4]},{}),l:Ve},23:{t:["!["],o:Ie(F),i:0,u:e=>({alt:e[1]?Fe(e[1]):void 0,ref:e[2]}),l:(e,n,r)=>ue[e.ref]?W("img",{key:r.key,alt:e.alt,src:G(ue[e.ref].target,"img","src"),title:ue[e.ref].title}):null},24:{t:e=>"["===e[0]&&-1===e.indexOf("]("),o:Ce(P),i:0,u:(e,n,r)=>({children:n(e[1],r),fallbackChildren:e[0],ref:e[2]}),l:(e,n,r)=>ue[e.ref]?W("a",{key:r.key,href:G(ue[e.ref].target,"a","href"),title:ue[e.ref].title},n(e.children,r)):W("span",{key:r.key},e.fallbackChildren)},25:{t:["|"],o:Te(M),i:1,u:Le,l(e,n,r){const t=e;return W("table",{key:r.key},W("thead",null,W("tr",null,t.header.map(function(e,o){return W("th",{key:o,style:Oe(t,o)},n(e,r))}))),W("tbody",null,t.cells.map(function(e,o){return W("tr",{key:o},e.map(function(e,o){return W("td",{key:o,style:Oe(t,o)},n(e,r))}))})))}},27:{o:je(function(e,n){let r;return ze(e,":")&&(r=ee.exec(e)),r||te.exec(e)}),i:4,u(e){const n=e[0];return {text:-1===n.indexOf("&")?n:n.replace(R,(e,n)=>t.namedCodesToUnicode[n]||e)}},l:e=>e.text},28:{t:["**","__"],o:Ie(J),i:2,u:(e,n,r)=>({children:n(e[2],r)}),l:(e,n,r)=>W("strong",{key:r.key},n(e.children,r))},29:{t:e=>{const n=e[0];return ("*"===n||"_"===n)&&e[1]!==n},o:Ie(K),i:3,u:(e,n,r)=>({children:n(e[2],r)}),l:(e,n,r)=>W("em",{key:r.key},n(e.children,r))},30:{t:["\\"],o:Ie(ne),i:1,u:e=>({text:e[1],type:"27"})},31:{t:["=="],o:Ie(X),i:3,u:Ge,l:(e,n,r)=>W("mark",{key:r.key},n(e.children,r))},32:{t:["~~"],o:Ie(Y),i:3,u:Ge,l:(e,n,r)=>W("del",{key:r.key},n(e.children,r))}};!0===t.disableParsingRawHTML&&(delete le[11],delete le[13]);const se=function(e){var n=Object.keys(e);function r(t,o){var a=[];if(o.prevCapture=o.prevCapture||"",t.trim())for(;t;)for(var c=0;c<n.length;){var i=n[c],u=e[i];if(!u.t||Ee(t,o,u.t)){var l=u.o(t,o);if(l&&l[0]){t=t.substring(l[0].length);var s=u.u(l,r,o);o.prevCapture+=l[0],s.type||(s.type=i),a.push(s);break}c++;}else c++;}return o.prevCapture="",a}return n.sort(function(n,r){return e[n].i-e[r].i||(n<r?-1:1)}),function(e,n){return r(function(e){return e.replace(k,"\n").replace(v,"").replace(N," ")}(e),n)}}(le),fe=function(e,n){return function r(t,o={}){if(Array.isArray(t)){const e=o.key,n=[];let a=!1;for(let e=0;e<t.length;e++){o.key=e;const c=r(t[e],o),i=$e(c);i&&a?n[n.length-1]+=c:null!==c&&n.push(c),a=i;}return o.key=e,n}return function(r,t,o){const a=e[r.type].l;return n?n(()=>a(r,t,o),r,t,o):a(r,t,o)}(t,r,o)}}(le,t.renderRule),_e=re(r);return ie.length?W("div",null,_e,W("footer",{key:"footer"},ie.map(function(e){return W("div",{id:l(e.identifier,Ae),key:e.identifier},e.identifier,fe(se(e.footnote,{inline:!0})))}))):_e}
19117
19159
 
19118
19160
  function startsWith(str, prefix) {
@@ -19127,9 +19169,10 @@
19127
19169
  createElement: createElement
19128
19170
  });
19129
19171
  return function ChatMessage(userProps) {
19130
- var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, message = userProps.message, _userProps_side = userProps.side, side = _userProps_side === void 0 ? 'left' : _userProps_side, _userProps_variant = userProps.variant, variant = _userProps_variant === void 0 ? 'subtle' : _userProps_variant, _userProps_actions = userProps.actions, actions = _userProps_actions === void 0 ? [] : _userProps_actions, _userProps_autoHideActions = userProps.autoHideActions, autoHideActions = _userProps_autoHideActions === void 0 ? false : _userProps_autoHideActions, LeadingComponent = userProps.leadingComponent, ActionsComponent = userProps.actionsComponent, FooterComponent = userProps.footerComponent, _userProps_tools = userProps.tools, tools = _userProps_tools === void 0 ? {} : _userProps_tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, onClose = userProps.onClose, userTranslations = userProps.translations, suggestionsElement = userProps.suggestionsElement, props = _object_without_propertiesExports._(userProps, [
19172
+ var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, message = userProps.message, status = userProps.status, _userProps_side = userProps.side, side = _userProps_side === void 0 ? 'left' : _userProps_side, _userProps_variant = userProps.variant, variant = _userProps_variant === void 0 ? 'subtle' : _userProps_variant, _userProps_actions = userProps.actions, actions = _userProps_actions === void 0 ? [] : _userProps_actions, _userProps_autoHideActions = userProps.autoHideActions, autoHideActions = _userProps_autoHideActions === void 0 ? false : _userProps_autoHideActions, LeadingComponent = userProps.leadingComponent, ActionsComponent = userProps.actionsComponent, FooterComponent = userProps.footerComponent, _userProps_tools = userProps.tools, tools = _userProps_tools === void 0 ? {} : _userProps_tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, onClose = userProps.onClose, userTranslations = userProps.translations, suggestionsElement = userProps.suggestionsElement, props = _object_without_propertiesExports._(userProps, [
19131
19173
  "classNames",
19132
19174
  "message",
19175
+ "status",
19133
19176
  "side",
19134
19177
  "variant",
19135
19178
  "actions",
@@ -19149,7 +19192,7 @@
19149
19192
  actionsLabel: 'Message actions'
19150
19193
  }, userTranslations);
19151
19194
  var hasLeading = Boolean(LeadingComponent);
19152
- var hasActions = Boolean(actions.length > 0 || ActionsComponent);
19195
+ var showActions = Boolean(actions.length > 0 || ActionsComponent) && status === 'ready';
19153
19196
  var cssClasses = {
19154
19197
  root: cx('ais-ChatMessage', "ais-ChatMessage--".concat(side), "ais-ChatMessage--".concat(variant), autoHideActions && 'ais-ChatMessage--auto-hide-actions', classNames.root),
19155
19198
  container: cx('ais-ChatMessage-container', classNames.container),
@@ -19219,7 +19262,7 @@
19219
19262
  className: cx(cssClasses.content)
19220
19263
  }, /*#__PURE__*/ createElement("div", {
19221
19264
  className: cx(cssClasses.message)
19222
- }, message.parts.map(renderMessagePart)), suggestionsElement, hasActions && /*#__PURE__*/ createElement("div", {
19265
+ }, message.parts.map(renderMessagePart)), suggestionsElement, showActions && /*#__PURE__*/ createElement("div", {
19223
19266
  className: cx(cssClasses.actions),
19224
19267
  "aria-label": translations.actionsLabel
19225
19268
  }, ActionsComponent ? /*#__PURE__*/ createElement(ActionsComponent, {
@@ -19326,14 +19369,6 @@
19326
19369
  };
19327
19370
  }
19328
19371
 
19329
- var getTextContent = function getTextContent(message) {
19330
- return message.parts.map(function(part) {
19331
- return 'text' in part ? part.text : '';
19332
- }).join('');
19333
- };
19334
- var hasTextContent = function hasTextContent(message) {
19335
- return getTextContent(message).trim() !== '';
19336
- };
19337
19372
  var copyToClipboard = function copyToClipboard(message) {
19338
19373
  navigator.clipboard.writeText(getTextContent(message));
19339
19374
  };
@@ -19344,7 +19379,7 @@
19344
19379
  Fragment: Fragment
19345
19380
  });
19346
19381
  return function DefaultMessage(param) {
19347
- var message = param.message, userMessageProps = param.userMessageProps, assistantMessageProps = param.assistantMessageProps, tools = param.tools, indexUiState = param.indexUiState, setIndexUiState = param.setIndexUiState, onReload = param.onReload, onClose = param.onClose, actionsComponent = param.actionsComponent, classNames = param.classNames, messageTranslations = param.messageTranslations, translations = param.translations, suggestionsElement = param.suggestionsElement;
19382
+ var message = param.message, status = param.status, userMessageProps = param.userMessageProps, assistantMessageProps = param.assistantMessageProps, tools = param.tools, indexUiState = param.indexUiState, setIndexUiState = param.setIndexUiState, onReload = param.onReload, onClose = param.onClose, actionsComponent = param.actionsComponent, classNames = param.classNames, messageTranslations = param.messageTranslations, translations = param.translations, suggestionsElement = param.suggestionsElement;
19348
19383
  var defaultAssistantActions = _to_consumable_arrayExports._(hasTextContent(message) ? [
19349
19384
  {
19350
19385
  title: translations.copyToClipboardLabel,
@@ -19374,6 +19409,7 @@
19374
19409
  side: message.role === 'user' ? 'right' : 'left',
19375
19410
  variant: message.role === 'user' ? 'neutral' : 'subtle',
19376
19411
  message: message,
19412
+ status: status,
19377
19413
  tools: tools,
19378
19414
  indexUiState: indexUiState,
19379
19415
  setIndexUiState: setIndexUiState,
@@ -19403,6 +19439,7 @@
19403
19439
  createElement: createElement
19404
19440
  });
19405
19441
  return function ChatMessages(userProps) {
19442
+ var _lastMessage_parts;
19406
19443
  var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, _userProps_messageClassNames = userProps.messageClassNames, messageClassNames = _userProps_messageClassNames === void 0 ? {} : _userProps_messageClassNames, messageTranslations = userProps.messageTranslations, _userProps_messages = userProps.messages, messages = _userProps_messages === void 0 ? [] : _userProps_messages, MessageComponent = userProps.messageComponent, LoaderComponent = userProps.loaderComponent, ErrorComponent = userProps.errorComponent, ActionsComponent = userProps.actionsComponent, tools = userProps.tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, _userProps_status = userProps.status, status = _userProps_status === void 0 ? 'ready' : _userProps_status, _userProps_hideScrollToBottom = userProps.hideScrollToBottom, hideScrollToBottom = _userProps_hideScrollToBottom === void 0 ? false : _userProps_hideScrollToBottom, onReload = userProps.onReload, onClose = userProps.onClose, userTranslations = userProps.translations, userMessageProps = userProps.userMessageProps, assistantMessageProps = userProps.assistantMessageProps, _userProps_isClearing = userProps.isClearing, isClearing = _userProps_isClearing === void 0 ? false : _userProps_isClearing, onClearTransitionEnd = userProps.onClearTransitionEnd, isScrollAtBottom = userProps.isScrollAtBottom, scrollRef = userProps.scrollRef, contentRef = userProps.contentRef, onScrollToBottom = userProps.onScrollToBottom, suggestionsElement = userProps.suggestionsElement, props = _object_without_propertiesExports._(userProps, [
19407
19444
  "classNames",
19408
19445
  "messageClassNames",
@@ -19442,6 +19479,12 @@
19442
19479
  scrollToBottom: cx('ais-ChatMessages-scrollToBottom', classNames.scrollToBottom),
19443
19480
  scrollToBottomHidden: cx('ais-ChatMessages-scrollToBottom--hidden', classNames.scrollToBottomHidden)
19444
19481
  };
19482
+ var lastMessage = messages[messages.length - 1];
19483
+ var lastPart = lastMessage === null || lastMessage === void 0 ? void 0 : (_lastMessage_parts = lastMessage.parts) === null || _lastMessage_parts === void 0 ? void 0 : _lastMessage_parts[lastMessage.parts.length - 1];
19484
+ var isWaitingForResponse = status === 'submitted';
19485
+ var isStreamingWithNoContent = status === 'streaming' && !lastPart;
19486
+ var isStreamingNonTextContent = status === 'streaming' && lastPart && !isPartText(lastPart);
19487
+ var showLoader = isWaitingForResponse || isStreamingWithNoContent || isStreamingNonTextContent;
19445
19488
  var DefaultMessage = MessageComponent || DefaultMessageComponent;
19446
19489
  var DefaultLoader = LoaderComponent || DefaultLoaderComponent;
19447
19490
  var DefaultError = ErrorComponent || DefaultErrorComponent;
@@ -19464,6 +19507,7 @@
19464
19507
  return /*#__PURE__*/ createElement(DefaultMessage, {
19465
19508
  key: message.id,
19466
19509
  message: message,
19510
+ status: status,
19467
19511
  userMessageProps: userMessageProps,
19468
19512
  assistantMessageProps: assistantMessageProps,
19469
19513
  tools: tools,
@@ -19477,7 +19521,7 @@
19477
19521
  messageTranslations: messageTranslations,
19478
19522
  suggestionsElement: status === 'ready' && message.role === 'assistant' && index === messages.length - 1 ? suggestionsElement : undefined
19479
19523
  });
19480
- }), status === 'submitted' && /*#__PURE__*/ createElement(DefaultLoader, {
19524
+ }), showLoader && /*#__PURE__*/ createElement(DefaultLoader, {
19481
19525
  translations: {
19482
19526
  loaderText: translations.loaderText
19483
19527
  }
@@ -20722,6 +20766,17 @@
20722
20766
  return instant ? 'instant' : animationCache.get(key);
20723
20767
  }
20724
20768
 
20769
+ var PROMPT_SUGGESTION_FLAG = '__isPromptSuggestion';
20770
+ function getPromptSuggestionHits(param) {
20771
+ var hits = param.hits, limit = param.limit;
20772
+ return hits.slice(0, limit).map(function(hit) {
20773
+ return _object_spread_propsExports._(_object_spreadExports._({}, hit), _define_propertyExports._({}, PROMPT_SUGGESTION_FLAG, true));
20774
+ });
20775
+ }
20776
+ function isPromptSuggestion(item) {
20777
+ return Boolean(item && (typeof item === "undefined" ? "undefined" : _type_ofExports._(item)) === 'object' && item[PROMPT_SUGGESTION_FLAG]);
20778
+ }
20779
+
20725
20780
  var AutocompleteSearchComponent = createAutocompleteSearchComponent({
20726
20781
  createElement: React.createElement,
20727
20782
  Fragment: React.Fragment
@@ -20747,6 +20802,43 @@
20747
20802
  Fragment: React.Fragment
20748
20803
  });
20749
20804
 
20805
+ function Highlight$1(_0) {
20806
+ var _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, props = _object_without_properties(_0, [
20807
+ "classNames"
20808
+ ]);
20809
+ return /*#__PURE__*/ React.createElement(InternalHighlight, _object_spread({
20810
+ classNames: {
20811
+ root: cx('ais-Highlight', classNames.root),
20812
+ highlighted: cx('ais-Highlight-highlighted', classNames.highlighted),
20813
+ nonHighlighted: cx('ais-Highlight-nonHighlighted', classNames.nonHighlighted),
20814
+ separator: cx('ais-Highlight-separator', classNames.separator)
20815
+ }
20816
+ }, props));
20817
+ }
20818
+
20819
+ function Highlight(_0) {
20820
+ var hit = _0.hit, attribute = _0.attribute, highlightedTagName = _0.highlightedTagName, nonHighlightedTagName = _0.nonHighlightedTagName, separator = _0.separator, props = _object_without_properties(_0, [
20821
+ "hit",
20822
+ "attribute",
20823
+ "highlightedTagName",
20824
+ "nonHighlightedTagName",
20825
+ "separator"
20826
+ ]);
20827
+ var property = getPropertyByPath(hit._highlightResult, attribute) || [];
20828
+ var properties = Array.isArray(property) ? property : [
20829
+ property
20830
+ ];
20831
+ var parts = properties.map(function(singleValue) {
20832
+ return getHighlightedParts(unescape$1(singleValue.value || ''));
20833
+ });
20834
+ return /*#__PURE__*/ React.createElement(Highlight$1, _object_spread_props(_object_spread({}, props), {
20835
+ parts: parts,
20836
+ highlightedTagName: highlightedTagName,
20837
+ nonHighlightedTagName: nonHighlightedTagName,
20838
+ separator: separator
20839
+ }));
20840
+ }
20841
+
20750
20842
  function ReverseHighlight$1(_0) {
20751
20843
  var _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, props = _object_without_properties(_0, [
20752
20844
  "classNames"
@@ -20807,6 +20899,10 @@
20807
20899
  createElement: React.createElement,
20808
20900
  Fragment: React.Fragment
20809
20901
  });
20902
+ var AutocompletePromptSuggestion = createAutocompletePromptSuggestionComponent({
20903
+ createElement: React.createElement,
20904
+ Fragment: React.Fragment
20905
+ });
20810
20906
  var AutocompleteRecentSearch = createAutocompleteRecentSearchComponent({
20811
20907
  createElement: React.createElement,
20812
20908
  Fragment: React.Fragment
@@ -20964,9 +21060,10 @@
20964
21060
  };
20965
21061
  }
20966
21062
  function EXPERIMENTAL_Autocomplete(_0) {
20967
- var _0_indices = _0.indices, indices = _0_indices === void 0 ? [] : _0_indices, showSuggestions = _0.showSuggestions, showRecent = _0.showRecent, userSearchParameters = _0.searchParameters, detachedMediaQuery = _0.detachedMediaQuery, tmp = _0.translations, userTranslations = tmp === void 0 ? {} : tmp, props = _object_without_properties(_0, [
21063
+ var _0_indices = _0.indices, indices = _0_indices === void 0 ? [] : _0_indices, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, showRecent = _0.showRecent, userSearchParameters = _0.searchParameters, detachedMediaQuery = _0.detachedMediaQuery, tmp = _0.translations, userTranslations = tmp === void 0 ? {} : tmp, props = _object_without_properties(_0, [
20968
21064
  "indices",
20969
- "showSuggestions",
21065
+ "showQuerySuggestions",
21066
+ "showPromptSuggestions",
20970
21067
  "showRecent",
20971
21068
  "searchParameters",
20972
21069
  "detachedMediaQuery",
@@ -20984,12 +21081,12 @@
20984
21081
  hitsPerPage: 5
20985
21082
  }, userSearchParameters);
20986
21083
  var indicesConfig = _to_consumable_array(indices);
20987
- if (showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName) {
20988
- var _showSuggestions_classNames, _showSuggestions_classNames1, _showSuggestions_classNames2, _showSuggestions_classNames3;
21084
+ if (showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName) {
21085
+ var _showQuerySuggestions_classNames, _showQuerySuggestions_classNames1, _showQuerySuggestions_classNames2, _showQuerySuggestions_classNames3;
20989
21086
  indicesConfig.unshift({
20990
- indexName: showSuggestions.indexName,
20991
- headerComponent: showSuggestions.headerComponent,
20992
- itemComponent: showSuggestions.itemComponent || function(param) {
21087
+ indexName: showQuerySuggestions.indexName,
21088
+ headerComponent: showQuerySuggestions.headerComponent,
21089
+ itemComponent: showQuerySuggestions.itemComponent || function(param) {
20993
21090
  var item = param.item, onSelect = param.onSelect, onApply = param.onApply;
20994
21091
  return /*#__PURE__*/ React.createElement(AutocompleteSuggestion, {
20995
21092
  item: item,
@@ -21000,15 +21097,48 @@
21000
21097
  }));
21001
21098
  },
21002
21099
  classNames: {
21003
- root: cx('ais-AutocompleteSuggestions', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions_classNames = showSuggestions.classNames) === null || _showSuggestions_classNames === void 0 ? void 0 : _showSuggestions_classNames.root),
21004
- list: cx('ais-AutocompleteSuggestionsList', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions_classNames1 = showSuggestions.classNames) === null || _showSuggestions_classNames1 === void 0 ? void 0 : _showSuggestions_classNames1.list),
21005
- header: cx('ais-AutocompleteSuggestionsHeader', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions_classNames2 = showSuggestions.classNames) === null || _showSuggestions_classNames2 === void 0 ? void 0 : _showSuggestions_classNames2.header),
21006
- item: cx('ais-AutocompleteSuggestionsItem', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions_classNames3 = showSuggestions.classNames) === null || _showSuggestions_classNames3 === void 0 ? void 0 : _showSuggestions_classNames3.item)
21100
+ root: cx('ais-AutocompleteSuggestions', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames === void 0 ? void 0 : _showQuerySuggestions_classNames.root),
21101
+ list: cx('ais-AutocompleteSuggestionsList', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames1 = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames1 === void 0 ? void 0 : _showQuerySuggestions_classNames1.list),
21102
+ header: cx('ais-AutocompleteSuggestionsHeader', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames2 = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames2 === void 0 ? void 0 : _showQuerySuggestions_classNames2.header),
21103
+ item: cx('ais-AutocompleteSuggestionsItem', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames3 = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames3 === void 0 ? void 0 : _showQuerySuggestions_classNames3.item)
21007
21104
  },
21105
+ searchParameters: _object_spread({
21106
+ hitsPerPage: 3
21107
+ }, showQuerySuggestions.searchParameters),
21008
21108
  getQuery: function getQuery(item) {
21009
21109
  return item.query;
21010
21110
  },
21011
- getURL: showSuggestions.getURL
21111
+ getURL: showQuerySuggestions.getURL
21112
+ });
21113
+ }
21114
+ if (showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.indexName) {
21115
+ var _showPromptSuggestions_classNames, _showPromptSuggestions_classNames1, _showPromptSuggestions_classNames2, _showPromptSuggestions_classNames3;
21116
+ indicesConfig.push({
21117
+ indexName: showPromptSuggestions.indexName,
21118
+ headerComponent: showPromptSuggestions.headerComponent,
21119
+ itemComponent: showPromptSuggestions.itemComponent || function(param) {
21120
+ var item = param.item, onSelect = param.onSelect;
21121
+ return /*#__PURE__*/ React.createElement(AutocompletePromptSuggestion, {
21122
+ item: item,
21123
+ onSelect: onSelect
21124
+ }, /*#__PURE__*/ React.createElement(ConditionalHighlight, {
21125
+ item: item,
21126
+ attribute: "prompt"
21127
+ }));
21128
+ },
21129
+ classNames: {
21130
+ root: cx('ais-AutocompletePromptSuggestions', (_showPromptSuggestions_classNames = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames === void 0 ? void 0 : _showPromptSuggestions_classNames.root),
21131
+ list: cx('ais-AutocompletePromptSuggestionsList', (_showPromptSuggestions_classNames1 = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames1 === void 0 ? void 0 : _showPromptSuggestions_classNames1.list),
21132
+ header: cx('ais-AutocompletePromptSuggestionsHeader', (_showPromptSuggestions_classNames2 = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames2 === void 0 ? void 0 : _showPromptSuggestions_classNames2.header),
21133
+ item: cx('ais-AutocompletePromptSuggestionsItem', (_showPromptSuggestions_classNames3 = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames3 === void 0 ? void 0 : _showPromptSuggestions_classNames3.item)
21134
+ },
21135
+ searchParameters: _object_spread({
21136
+ hitsPerPage: 3
21137
+ }, showPromptSuggestions.searchParameters),
21138
+ getQuery: function getQuery(item) {
21139
+ return item.prompt;
21140
+ },
21141
+ getURL: showPromptSuggestions.getURL
21012
21142
  });
21013
21143
  }
21014
21144
  var recentSearchConfig = showRecent ? {
@@ -21041,13 +21171,15 @@
21041
21171
  isSearchPage: isSearchPage,
21042
21172
  showRecent: showRecent,
21043
21173
  recentSearchConfig: recentSearchConfig,
21044
- showSuggestions: showSuggestions,
21174
+ showQuerySuggestions: showQuerySuggestions,
21045
21175
  detachedMediaQuery: detachedMediaQuery,
21046
- translations: translations
21176
+ translations: translations,
21177
+ showPromptSuggestions: showPromptSuggestions,
21178
+ chatRenderState: indexRenderState.chat
21047
21179
  }))));
21048
21180
  }
21049
21181
  function InnerAutocomplete(_0) {
21050
- var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showSuggestions = _0.showSuggestions, transformItems = _0.transformItems, placeholder = _0.placeholder, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, props = _object_without_properties(_0, [
21182
+ var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, props = _object_without_properties(_0, [
21051
21183
  "indicesConfig",
21052
21184
  "refineSearchBox",
21053
21185
  "isSearchStalled",
@@ -21058,13 +21190,17 @@
21058
21190
  "panelComponent",
21059
21191
  "showRecent",
21060
21192
  "recentSearchConfig",
21061
- "showSuggestions",
21193
+ "showQuerySuggestions",
21194
+ "showPromptSuggestions",
21195
+ "chatRenderState",
21062
21196
  "transformItems",
21063
21197
  "placeholder",
21064
21198
  "detachedMediaQuery",
21065
21199
  "translations",
21066
21200
  "classNames"
21067
21201
  ]);
21202
+ var _ref;
21203
+ var _showPromptSuggestions_searchParameters;
21068
21204
  var _useAutocomplete = useAutocomplete({
21069
21205
  transformItems: transformItems
21070
21206
  }), indices = _useAutocomplete.indices, refineAutocomplete = _useAutocomplete.refine, currentRefinement = _useAutocomplete.currentRefinement;
@@ -21075,10 +21211,57 @@
21075
21211
  query: currentRefinement,
21076
21212
  indices: indices,
21077
21213
  indicesConfig: indicesConfig,
21078
- suggestionsIndexName: showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName
21214
+ suggestionsIndexName: showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName
21079
21215
  }), storage = _useStorage.storage, storageHits = _useStorage.storageHits, indicesForPropGetters = _useStorage.indicesForPropGetters, indicesConfigForPropGetters = _useStorage.indicesConfigForPropGetters;
21216
+ var promptSuggestionsIndexName = showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.indexName;
21217
+ var promptSuggestionsLimit = (_ref = showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : (_showPromptSuggestions_searchParameters = showPromptSuggestions.searchParameters) === null || _showPromptSuggestions_searchParameters === void 0 ? void 0 : _showPromptSuggestions_searchParameters.hitsPerPage) !== null && _ref !== void 0 ? _ref : 3;
21218
+ var indicesForPanel = React.useMemo(function() {
21219
+ return indices.map(function(index) {
21220
+ var dedupedHits = index.indexName === (showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName) && showRecent ? index.hits.filter(function(suggestionHit) {
21221
+ return !storageHits.find(function(storageHit) {
21222
+ return storageHit.query === suggestionHit.query;
21223
+ });
21224
+ }) : index.hits;
21225
+ if (index.indexName !== promptSuggestionsIndexName) {
21226
+ return _object_spread_props(_object_spread({}, index), {
21227
+ hits: dedupedHits
21228
+ });
21229
+ }
21230
+ return _object_spread_props(_object_spread({}, index), {
21231
+ hits: getPromptSuggestionHits({
21232
+ hits: dedupedHits,
21233
+ limit: promptSuggestionsLimit
21234
+ })
21235
+ });
21236
+ });
21237
+ }, [
21238
+ indices,
21239
+ promptSuggestionsIndexName,
21240
+ promptSuggestionsLimit,
21241
+ showRecent,
21242
+ showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName,
21243
+ storageHits
21244
+ ]);
21245
+ var indicesForPropGettersWithPromptSuggestions = React.useMemo(function() {
21246
+ return indicesForPropGetters.map(function(index) {
21247
+ if (index.indexName !== promptSuggestionsIndexName) {
21248
+ return index;
21249
+ }
21250
+ return _object_spread_props(_object_spread({}, index), {
21251
+ hits: getPromptSuggestionHits({
21252
+ hits: index.hits,
21253
+ limit: promptSuggestionsLimit
21254
+ })
21255
+ });
21256
+ });
21257
+ }, [
21258
+ indicesForPropGetters,
21259
+ promptSuggestionsIndexName,
21260
+ promptSuggestionsLimit
21261
+ ]);
21262
+ var hasWarnedMissingPromptSuggestionsChatRef = React.useRef(false);
21080
21263
  var _usePropGetters = usePropGetters({
21081
- indices: indicesForPropGetters,
21264
+ indices: indicesForPropGettersWithPromptSuggestions,
21082
21265
  indicesConfig: indicesConfigForPropGetters,
21083
21266
  onRefine: function onRefine(query) {
21084
21267
  refineAutocomplete(query);
@@ -21089,7 +21272,23 @@
21089
21272
  refineAutocomplete(query);
21090
21273
  },
21091
21274
  onSelect: userOnSelect !== null && userOnSelect !== void 0 ? userOnSelect : function(param) {
21092
- var query = param.query, setQuery = param.setQuery, url = param.url;
21275
+ var item = param.item, query = param.query, setQuery = param.setQuery, url = param.url;
21276
+ if (isPromptSuggestion(item)) {
21277
+ var chatRenderStateWithFocus = chatRenderState;
21278
+ if (chatRenderStateWithFocus) {
21279
+ var _chatRenderStateWithFocus_setOpen, _chatRenderStateWithFocus_focusInput, _chatRenderStateWithFocus_sendMessage;
21280
+ (_chatRenderStateWithFocus_setOpen = chatRenderStateWithFocus.setOpen) === null || _chatRenderStateWithFocus_setOpen === void 0 ? void 0 : _chatRenderStateWithFocus_setOpen.call(chatRenderStateWithFocus, true);
21281
+ (_chatRenderStateWithFocus_focusInput = chatRenderStateWithFocus.focusInput) === null || _chatRenderStateWithFocus_focusInput === void 0 ? void 0 : _chatRenderStateWithFocus_focusInput.call(chatRenderStateWithFocus);
21282
+ (_chatRenderStateWithFocus_sendMessage = chatRenderStateWithFocus.sendMessage) === null || _chatRenderStateWithFocus_sendMessage === void 0 ? void 0 : _chatRenderStateWithFocus_sendMessage.call(chatRenderStateWithFocus, {
21283
+ text: item.prompt
21284
+ });
21285
+ return;
21286
+ }
21287
+ if ((showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.indexName) && !hasWarnedMissingPromptSuggestionsChatRef.current) {
21288
+ hasWarnedMissingPromptSuggestionsChatRef.current = true;
21289
+ { warn('showPromptSuggestions requires a Chat widget in the same index to open chat and send messages. Add <Chat /> to enable this behavior.'); }
21290
+ }
21291
+ }
21093
21292
  if (url) {
21094
21293
  window.location.href = url;
21095
21294
  return;
@@ -21162,14 +21361,14 @@
21162
21361
  key: "recentSearches"
21163
21362
  });
21164
21363
  }
21165
- indices.forEach(function(param) {
21364
+ indicesForPanel.forEach(function(param) {
21166
21365
  var indexId = param.indexId, indexName = param.indexName, hits = param.hits;
21167
- var elementId = indexName === (showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName) ? 'suggestions' : indexName;
21168
- var filteredHits = elementId === 'suggestions' && showRecent ? hits.filter(function(suggestionHit) {
21169
- return !storageHits.find(function(storageHit) {
21170
- return storageHit.query === suggestionHit.query;
21171
- });
21172
- }) : hits;
21366
+ var elementId = indexName;
21367
+ if (indexName === (showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName)) {
21368
+ elementId = 'suggestions';
21369
+ } else if (indexName === (showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.indexName)) {
21370
+ elementId = 'promptSuggestions';
21371
+ }
21173
21372
  var currentIndexConfig = indicesConfig.find(function(config) {
21174
21373
  return config.indexName === indexName;
21175
21374
  });
@@ -21182,7 +21381,7 @@
21182
21381
  HeaderComponent: currentIndexConfig.headerComponent,
21183
21382
  // @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
21184
21383
  ItemComponent: currentIndexConfig.itemComponent,
21185
- items: filteredHits.map(function(item) {
21384
+ items: hits.map(function(item) {
21186
21385
  return _object_spread_props(_object_spread({}, item), {
21187
21386
  __indexName: indexId
21188
21387
  });
@@ -21206,7 +21405,7 @@
21206
21405
  });
21207
21406
  var panelContent = /*#__PURE__*/ React.createElement(AutocompletePanel, getPanelProps(), PanelComponent ? /*#__PURE__*/ React.createElement(PanelComponent, {
21208
21407
  elements: elements,
21209
- indices: indices
21408
+ indices: indicesForPanel
21210
21409
  }) : Object.keys(elements).map(function(elementId) {
21211
21410
  return elements[elementId];
21212
21411
  }));
@@ -21263,6 +21462,18 @@
21263
21462
  hit: item
21264
21463
  });
21265
21464
  }
21465
+ function ConditionalHighlight(param) {
21466
+ var item = param.item, _param_attribute = param.attribute, attribute = _param_attribute === void 0 ? 'query' : _param_attribute;
21467
+ var _item__highlightResult;
21468
+ if (!((_item__highlightResult = item._highlightResult) === null || _item__highlightResult === void 0 ? void 0 : _item__highlightResult[attribute]) || // @ts-expect-error - we should not have matchLevel as arrays here
21469
+ item._highlightResult[attribute].matchLevel === 'none') {
21470
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, item[attribute]);
21471
+ }
21472
+ return /*#__PURE__*/ React.createElement(Highlight, {
21473
+ attribute: attribute,
21474
+ hit: item
21475
+ });
21476
+ }
21266
21477
 
21267
21478
  function isModifierClick(event) {
21268
21479
  var isMiddleClick = event.button === 1;
@@ -21498,7 +21709,7 @@
21498
21709
  ]);
21499
21710
  var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
21500
21711
  var _useInstantSearch = useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, setIndexUiState = _useInstantSearch.setIndexUiState;
21501
- var _React_useState = _sliced_to_array(React.useState(false), 2), maximized = _React_useState[0], setMaximized = _React_useState[1];
21712
+ var _useState = _sliced_to_array(React.useState(false), 2), maximized = _useState[0], setMaximized = _useState[1];
21502
21713
  var promptRef = React.useRef(null);
21503
21714
  var _useStickToBottom = useStickToBottom({
21504
21715
  initial: 'smooth',
@@ -21516,6 +21727,19 @@
21516
21727
  tools: tools
21517
21728
  }));
21518
21729
  var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, isClearing = chatState.isClearing, clearMessages = chatState.clearMessages, onClearTransitionEnd = chatState.onClearTransitionEnd, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions;
21730
+ var wasOpenRef = React.useRef(false);
21731
+ React.useEffect(function() {
21732
+ var shouldFocusPrompt = !wasOpenRef.current && open;
21733
+ if (shouldFocusPrompt) {
21734
+ window.requestAnimationFrame(function() {
21735
+ var _promptRef_current;
21736
+ (_promptRef_current = promptRef.current) === null || _promptRef_current === void 0 ? void 0 : _promptRef_current.focus();
21737
+ });
21738
+ }
21739
+ wasOpenRef.current = open;
21740
+ }, [
21741
+ open
21742
+ ]);
21519
21743
  if (error) {
21520
21744
  throw error;
21521
21745
  }
@@ -21897,43 +22121,6 @@
21897
22121
  }));
21898
22122
  }
21899
22123
 
21900
- function Highlight$1(_0) {
21901
- var _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, props = _object_without_properties(_0, [
21902
- "classNames"
21903
- ]);
21904
- return /*#__PURE__*/ React.createElement(InternalHighlight, _object_spread({
21905
- classNames: {
21906
- root: cx('ais-Highlight', classNames.root),
21907
- highlighted: cx('ais-Highlight-highlighted', classNames.highlighted),
21908
- nonHighlighted: cx('ais-Highlight-nonHighlighted', classNames.nonHighlighted),
21909
- separator: cx('ais-Highlight-separator', classNames.separator)
21910
- }
21911
- }, props));
21912
- }
21913
-
21914
- function Highlight(_0) {
21915
- var hit = _0.hit, attribute = _0.attribute, highlightedTagName = _0.highlightedTagName, nonHighlightedTagName = _0.nonHighlightedTagName, separator = _0.separator, props = _object_without_properties(_0, [
21916
- "hit",
21917
- "attribute",
21918
- "highlightedTagName",
21919
- "nonHighlightedTagName",
21920
- "separator"
21921
- ]);
21922
- var property = getPropertyByPath(hit._highlightResult, attribute) || [];
21923
- var properties = Array.isArray(property) ? property : [
21924
- property
21925
- ];
21926
- var parts = properties.map(function(singleValue) {
21927
- return getHighlightedParts(unescape$1(singleValue.value || ''));
21928
- });
21929
- return /*#__PURE__*/ React.createElement(Highlight$1, _object_spread_props(_object_spread({}, props), {
21930
- parts: parts,
21931
- highlightedTagName: highlightedTagName,
21932
- nonHighlightedTagName: nonHighlightedTagName,
21933
- separator: separator
21934
- }));
21935
- }
21936
-
21937
22124
  // @MAJOR: Move default hit component back to the UI library
21938
22125
  // once flavour specificities are erased
21939
22126
  function DefaultHitComponent$1(param) {